MCPcopy
hub / github.com/superagent-ai/grok-cli / resolveConfig

Function resolveConfig

src/index.ts:302–327  ·  view source on GitHub ↗
(options: CliOptions)

Source from the content-addressed store, hash-verified

300}
301
302function 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
329function requireApiKey(apiKey: string | undefined): string {
330 if (!apiKey) {

Callers 1

index.tsFile · 0.85

Calls 9

getApiKeyFunction · 0.90
getBaseURLFunction · 0.90
normalizeModelIdFunction · 0.90
getCurrentSandboxModeFunction · 0.90
mergeSandboxSettingsFunction · 0.90
saveUserSettingsFunction · 0.90
stringOptionFunction · 0.85
resolveCliSandboxModeFunction · 0.85

Tested by

no test coverage detected