* Parse the optional `model`/`thinking` overrides supplied on a task launch, * reusing the exact parsing the UI uses (`normalizeModelInput` for model alias * resolution; `parseThinkingInput` for named levels OR numeric indices). Numeric * thinking indices stay deferred as a `ParsedThinkingInput`
(args: { model?: string | null; thinking?: string | null })
| 117 | * descriptive error on invalid input so the model can correct the call. |
| 118 | */ |
| 119 | function parseTaskAiOverrides(args: { model?: string | null; thinking?: string | null }): { |
| 120 | modelString?: string; |
| 121 | thinkingLevel?: ParsedThinkingInput; |
| 122 | } { |
| 123 | const overrides: { modelString?: string; thinkingLevel?: ParsedThinkingInput } = {}; |
| 124 | |
| 125 | if (args.model != null) { |
| 126 | const normalized = normalizeModelInput(args.model); |
| 127 | if (normalized.model == null) { |
| 128 | throw new Error( |
| 129 | `task tool: invalid model "${args.model}". Provide a known alias or a "provider:model" string.` |
| 130 | ); |
| 131 | } |
| 132 | overrides.modelString = normalized.model; |
| 133 | } |
| 134 | |
| 135 | if (args.thinking != null) { |
| 136 | const parsed = parseThinkingInput(args.thinking); |
| 137 | if (parsed == null) { |
| 138 | throw new Error( |
| 139 | `task tool: invalid thinking "${args.thinking}". Use a level name (off, low, medium, high, xhigh, max) or a numeric index.` |
| 140 | ); |
| 141 | } |
| 142 | overrides.thinkingLevel = parsed; |
| 143 | } |
| 144 | |
| 145 | return overrides; |
| 146 | } |
| 147 | |
| 148 | interface SpawnedTaskInfo { |
| 149 | taskId: string; |
no test coverage detected