(options: CliOptions)
| 300 | } |
| 301 | |
| 302 | function resolveConfig(options: CliOptions) { |
| 303 | const apiKey = stringOption(options.apiKey) || getApiKey(); |
| 304 | const baseURL = stringOption(options.baseUrl) || getBaseURL(); |
| 305 | const explicitModel = stringOption(options.model); |
| 306 | const model = explicitModel ? normalizeModelId(explicitModel) : undefined; |
| 307 | const maxToolRounds = parseInt(stringOption(options.maxToolRounds) || "400", 10) || 400; |
| 308 | const sandboxMode = resolveCliSandboxMode(options.sandbox) || getCurrentSandboxMode(); |
| 309 | |
| 310 | const cliOverrides: SandboxSettings = {}; |
| 311 | if (options.allowNet === true) cliOverrides.allowNet = true; |
| 312 | const allowHostValue = options.allowHost; |
| 313 | if (Array.isArray(allowHostValue) && allowHostValue.length > 0) { |
| 314 | cliOverrides.allowedHosts = allowHostValue as string[]; |
| 315 | if (!cliOverrides.allowNet) cliOverrides.allowNet = true; |
| 316 | } |
| 317 | const portValue = options.port; |
| 318 | if (Array.isArray(portValue) && portValue.length > 0) { |
| 319 | cliOverrides.ports = portValue as string[]; |
| 320 | } |
| 321 | const sandboxSettings = mergeSandboxSettings(getCurrentSandboxSettings(), cliOverrides); |
| 322 | |
| 323 | if (typeof options.apiKey === "string") saveUserSettings({ apiKey: options.apiKey }); |
| 324 | if (typeof options.model === "string") saveUserSettings({ defaultModel: normalizeModelId(options.model) }); |
| 325 | |
| 326 | return { apiKey, baseURL, model, maxToolRounds, sandboxMode, sandboxSettings }; |
| 327 | } |
| 328 | |
| 329 | function requireApiKey(apiKey: string | undefined): string { |
| 330 | if (!apiKey) { |
no test coverage detected