(raw: unknown)
| 102 | } |
| 103 | |
| 104 | export function normalizeTaskSettings(raw: unknown): TaskSettings { |
| 105 | const record = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : ({} as const); |
| 106 | |
| 107 | const maxParallelAgentTasks = clampInt( |
| 108 | record.maxParallelAgentTasks, |
| 109 | DEFAULT_TASK_SETTINGS.maxParallelAgentTasks, |
| 110 | TASK_SETTINGS_LIMITS.maxParallelAgentTasks.min, |
| 111 | TASK_SETTINGS_LIMITS.maxParallelAgentTasks.max |
| 112 | ); |
| 113 | const maxTaskNestingDepth = clampInt( |
| 114 | record.maxTaskNestingDepth, |
| 115 | DEFAULT_TASK_SETTINGS.maxTaskNestingDepth, |
| 116 | TASK_SETTINGS_LIMITS.maxTaskNestingDepth.min, |
| 117 | TASK_SETTINGS_LIMITS.maxTaskNestingDepth.max |
| 118 | ); |
| 119 | |
| 120 | const proposePlanImplementReplacesChatHistory = |
| 121 | typeof record.proposePlanImplementReplacesChatHistory === "boolean" |
| 122 | ? record.proposePlanImplementReplacesChatHistory |
| 123 | : (DEFAULT_TASK_SETTINGS.proposePlanImplementReplacesChatHistory ?? false); |
| 124 | |
| 125 | const preserveSubagentsUntilArchive = |
| 126 | typeof record.preserveSubagentsUntilArchive === "boolean" |
| 127 | ? record.preserveSubagentsUntilArchive |
| 128 | : DEFAULT_TASK_SETTINGS.preserveSubagentsUntilArchive; |
| 129 | |
| 130 | const result: TaskSettings = { |
| 131 | maxParallelAgentTasks, |
| 132 | maxTaskNestingDepth, |
| 133 | proposePlanImplementReplacesChatHistory, |
| 134 | preserveSubagentsUntilArchive, |
| 135 | }; |
| 136 | |
| 137 | assert( |
| 138 | Number.isInteger(maxParallelAgentTasks), |
| 139 | "normalizeTaskSettings: maxParallelAgentTasks must be an integer" |
| 140 | ); |
| 141 | assert( |
| 142 | Number.isInteger(maxTaskNestingDepth), |
| 143 | "normalizeTaskSettings: maxTaskNestingDepth must be an integer" |
| 144 | ); |
| 145 | |
| 146 | assert( |
| 147 | typeof proposePlanImplementReplacesChatHistory === "boolean", |
| 148 | "normalizeTaskSettings: proposePlanImplementReplacesChatHistory must be a boolean" |
| 149 | ); |
| 150 | assert( |
| 151 | typeof preserveSubagentsUntilArchive === "boolean", |
| 152 | "normalizeTaskSettings: preserveSubagentsUntilArchive must be a boolean" |
| 153 | ); |
| 154 | |
| 155 | return result; |
| 156 | } |
no test coverage detected