anygate 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -4,9 +4,12 @@ import {
4
4
  BACKENDS,
5
5
  CODEX_APP_AUTO_COMPACT_RATIO,
6
6
  CODEX_APP_PROVIDER_ID,
7
+ CONFLICTING_ENV_VARS,
8
+ GATEWAY_PORT,
7
9
  GLOBAL_OPENCODE_KEYRING_ACCOUNT,
8
10
  MAX_MODEL_CATALOG,
9
11
  PREVIEW_PROXY_PORT,
12
+ UPDATE_COMMAND,
10
13
  VERSION,
11
14
  VERTEX_ANTHROPIC_NPM,
12
15
  addCustomEndpointProvider,
@@ -165,7 +168,7 @@ import {
165
168
  validateCustomEndpointUrl,
166
169
  writeSecureLogLine,
167
170
  zenRegistryStub
168
- } from "./chunk-6GVUN4JO.js";
171
+ } from "./chunk-QPXRFBQI.js";
169
172
  import {
170
173
  filterTemplates,
171
174
  getTemplateById,
@@ -175,8 +178,8 @@ import {
175
178
  } from "./chunk-YYSUTRMV.js";
176
179
 
177
180
  // src/cli.ts
178
- import pc12 from "picocolors";
179
- import * as p14 from "@clack/prompts";
181
+ import pc15 from "picocolors";
182
+ import * as p15 from "@clack/prompts";
180
183
  import { realpathSync } from "fs";
181
184
  import { fileURLToPath } from "url";
182
185
 
@@ -331,7 +334,7 @@ async function importFromOpencode(options = {}) {
331
334
  }
332
335
  continue;
333
336
  }
334
- const existingIdx = registry.providers.findIndex((p15) => p15.id === entry.id);
337
+ const existingIdx = registry.providers.findIndex((p16) => p16.id === entry.id);
335
338
  const existing = existingIdx >= 0 ? registry.providers[existingIdx] : void 0;
336
339
  if (existing && options.resolveConflict) {
337
340
  const choice = await options.resolveConflict({
@@ -369,7 +372,7 @@ async function importFromOpencode(options = {}) {
369
372
  if (isOAuth) oauthImported += 1;
370
373
  }
371
374
  const alreadyReportedIds = new Set(skipped.map((s) => s.id));
372
- const registryProviderIds = new Set(registry.providers.map((p15) => p15.id));
375
+ const registryProviderIds = new Set(registry.providers.map((p16) => p16.id));
373
376
  for (const provider of listCredentialSkippedProviders(
374
377
  raw,
375
378
  authEntries,
@@ -956,7 +959,7 @@ async function resolveLocalProviderApiKey(provider) {
956
959
  if (template?.apiKeyOptional || template?.anonymousFreeModels) {
957
960
  return "anonymous";
958
961
  }
959
- const reg = loadRegistry().providers.find((p15) => p15.id === provider.id);
962
+ const reg = loadRegistry().providers.find((p16) => p16.id === provider.id);
960
963
  const authRef = reg?.authRef ?? (provider.id === "zen" || provider.id === "go" ? "keyring:global:opencode" : oauthAuthRef(provider.id));
961
964
  return resolveProviderCredential(provider.id, authRef);
962
965
  }
@@ -1238,7 +1241,7 @@ async function runProvidersRefreshModels(providerId) {
1238
1241
  const resolveKey = async (provider) => resolveProviderCredential(provider.id, provider.authRef);
1239
1242
  if (providerId) {
1240
1243
  const registry = loadRegistry();
1241
- const provider = registry.providers.find((p15) => p15.id === providerId);
1244
+ const provider = registry.providers.find((p16) => p16.id === providerId);
1242
1245
  if (!provider) {
1243
1246
  p5.log.error(`Provider not found: ${providerId}`);
1244
1247
  return 1;
@@ -1247,7 +1250,7 @@ async function runProvidersRefreshModels(providerId) {
1247
1250
  spinner10.start(`Refreshing ${provider.name}...`);
1248
1251
  const key = await resolveRefreshCredential(
1249
1252
  provider,
1250
- async (p15) => resolveProviderCredential(p15.id, p15.authRef)
1253
+ async (p16) => resolveProviderCredential(p16.id, p16.authRef)
1251
1254
  );
1252
1255
  const result = await refreshProviderModels(providerId, key);
1253
1256
  spinner10.stop("");
@@ -1314,7 +1317,7 @@ async function runProvidersList() {
1314
1317
  async function pickTemplateFromCatalog() {
1315
1318
  while (true) {
1316
1319
  const registry = loadRegistry();
1317
- const configuredIds = new Set(registry.providers.map((p15) => p15.id));
1320
+ const configuredIds = new Set(registry.providers.map((p16) => p16.id));
1318
1321
  const templates = listAddableTemplates(configuredIds);
1319
1322
  if (templates.length === 0) return null;
1320
1323
  const method = await p5.select({
@@ -1369,7 +1372,7 @@ async function pickTemplateFromCatalog() {
1369
1372
  }
1370
1373
  }
1371
1374
  async function runTemplateAddFlow() {
1372
- if (listAddableTemplates(loadRegistry().providers.map((p15) => p15.id)).length === 0) {
1375
+ if (listAddableTemplates(loadRegistry().providers.map((p16) => p16.id)).length === 0) {
1373
1376
  p5.log.info("All catalog providers are already configured.");
1374
1377
  return 0;
1375
1378
  }
@@ -1556,7 +1559,7 @@ async function runProvidersAdd() {
1556
1559
  const registry = loadRegistry();
1557
1560
  const hasOpencode = findOpencodeBinary() !== null;
1558
1561
  const options = [];
1559
- const addableTemplates = listAddableTemplates(registry.providers.map((p15) => p15.id));
1562
+ const addableTemplates = listAddableTemplates(registry.providers.map((p16) => p16.id));
1560
1563
  if (addableTemplates.length > 0) {
1561
1564
  options.push({
1562
1565
  value: "templates",
@@ -1598,11 +1601,11 @@ async function runProvidersRemove(id, interactive = false) {
1598
1601
  return 1;
1599
1602
  }
1600
1603
  if (interactive) {
1601
- const confirm9 = await p5.confirm({
1604
+ const confirm10 = await p5.confirm({
1602
1605
  message: `Remove ${provider.name} (${id})?`,
1603
1606
  initialValue: false
1604
1607
  });
1605
- if (p5.isCancel(confirm9) || !confirm9) {
1608
+ if (p5.isCancel(confirm10) || !confirm10) {
1606
1609
  p5.cancel("Cancelled.");
1607
1610
  return 0;
1608
1611
  }
@@ -1825,10 +1828,10 @@ function isClaudeCodeOAuthRoute(input) {
1825
1828
  return input.providerId === "claude-code" && input.authType === "oauth";
1826
1829
  }
1827
1830
  function prependClaudeCodeBillingLine(system) {
1828
- const line = buildClaudeCodeBillingSystemLine();
1829
- if (!system?.trim()) return line;
1830
- if (system.startsWith(line)) return system;
1831
- return `${line}
1831
+ const line2 = buildClaudeCodeBillingSystemLine();
1832
+ if (!system?.trim()) return line2;
1833
+ if (system.startsWith(line2)) return system;
1834
+ return `${line2}
1832
1835
 
1833
1836
  ${system}`;
1834
1837
  }
@@ -1871,7 +1874,7 @@ function applyClaudeCodeOAuthIdentity(input, sdkParams) {
1871
1874
  import { streamText, generateText, tool, jsonSchema } from "ai";
1872
1875
  function messageText(content) {
1873
1876
  if (typeof content === "string") return content;
1874
- return (content ?? []).map((p15) => p15.type === "output_text" || p15.type === "input_text" || p15.type === "text" ? p15.text ?? "" : "").join("");
1877
+ return (content ?? []).map((p16) => p16.type === "output_text" || p16.type === "input_text" || p16.type === "text" ? p16.text ?? "" : "").join("");
1875
1878
  }
1876
1879
  function extractDeveloperAndInstructions(items, instructions) {
1877
1880
  const developerParts = [];
@@ -2780,9 +2783,9 @@ function estimateCodexRequestChars(params) {
2780
2783
  if (Array.isArray(msg.content)) {
2781
2784
  for (const part of msg.content) {
2782
2785
  if (!part || typeof part !== "object") continue;
2783
- const p15 = part;
2784
- if (typeof p15["text"] === "string") {
2785
- chars += p15["text"].length;
2786
+ const p16 = part;
2787
+ if (typeof p16["text"] === "string") {
2788
+ chars += p16["text"].length;
2786
2789
  } else {
2787
2790
  chars += JSON.stringify(part).length;
2788
2791
  }
@@ -2813,9 +2816,9 @@ function clipLargeTextParts(params, maxCharsPerPart) {
2813
2816
  ...msg,
2814
2817
  content: msg.content.map((part) => {
2815
2818
  if (!part || typeof part !== "object") return part;
2816
- const p15 = part;
2817
- if (typeof p15.text !== "string") return part;
2818
- return { ...p15, text: clipTextForContext(p15.text, maxCharsPerPart) };
2819
+ const p16 = part;
2820
+ if (typeof p16.text !== "string") return part;
2821
+ return { ...p16, text: clipTextForContext(p16.text, maxCharsPerPart) };
2819
2822
  })
2820
2823
  };
2821
2824
  });
@@ -2849,7 +2852,7 @@ var COMPACTION_PROMPT_MARKER = "You are performing a CONTEXT CHECKPOINT COMPACTI
2849
2852
  function inputItemText(content) {
2850
2853
  if (typeof content === "string") return content;
2851
2854
  if (!Array.isArray(content)) return "";
2852
- return content.map((p15) => p15 && typeof p15 === "object" && typeof p15.text === "string" ? p15.text : "").join("");
2855
+ return content.map((p16) => p16 && typeof p16 === "object" && typeof p16.text === "string" ? p16.text : "").join("");
2853
2856
  }
2854
2857
  function isLikelyCodexCompactionRequest(body) {
2855
2858
  if (!Array.isArray(body.input)) return false;
@@ -2935,16 +2938,16 @@ async function startCodexProxy(routes, options = {}) {
2935
2938
  }));
2936
2939
  }
2937
2940
  return new Promise((resolve, reject2) => {
2938
- const log14 = debug ? makeTraceLogger(getCodexProxyDebugLogPath()) : () => {
2941
+ const log15 = debug ? makeTraceLogger(getCodexProxyDebugLogPath()) : () => {
2939
2942
  };
2940
2943
  const onRejection = (reason) => {
2941
- if (debug) log14(`unhandled-rejection: ${formatUpstreamError(reason)}`);
2944
+ if (debug) log15(`unhandled-rejection: ${formatUpstreamError(reason)}`);
2942
2945
  };
2943
2946
  process.on("unhandledRejection", onRejection);
2944
2947
  const server = createServer(async (req, res) => {
2945
2948
  const url = req.url ?? "/";
2946
2949
  if (debug) {
2947
- log14(`-> ${req.method} ${url} content-type=${req.headers["content-type"] ?? "(none)"} content-encoding=${req.headers["content-encoding"] ?? "(none)"} content-length=${req.headers["content-length"] ?? "(none)"}`);
2950
+ log15(`-> ${req.method} ${url} content-type=${req.headers["content-type"] ?? "(none)"} content-encoding=${req.headers["content-encoding"] ?? "(none)"} content-length=${req.headers["content-length"] ?? "(none)"}`);
2948
2951
  }
2949
2952
  if (!requireAuth && req.method === "POST") {
2950
2953
  const origin = req.headers.origin;
@@ -3022,7 +3025,7 @@ async function startCodexProxy(routes, options = {}) {
3022
3025
  rawBody = await readBody(req);
3023
3026
  } catch (err) {
3024
3027
  if (debug) {
3025
- log14(`Error: failed to read/decode request body on POST ${url}: ${formatUpstreamError(err)} content-encoding=${req.headers["content-encoding"] ?? "(none)"}`);
3028
+ log15(`Error: failed to read/decode request body on POST ${url}: ${formatUpstreamError(err)} content-encoding=${req.headers["content-encoding"] ?? "(none)"}`);
3026
3029
  }
3027
3030
  sendJson(res, 400, { error: { message: "Invalid request body", type: "invalid_request_error" } });
3028
3031
  return;
@@ -3033,7 +3036,7 @@ async function startCodexProxy(routes, options = {}) {
3033
3036
  } catch (err) {
3034
3037
  if (debug) {
3035
3038
  const headers = JSON.stringify(req.headers);
3036
- log14(`Error: Invalid JSON body on POST ${url}: ${formatUpstreamError(err)} headers=${headers} rawBody=${JSON.stringify(rawBody.slice(0, 2e3))}`);
3039
+ log15(`Error: Invalid JSON body on POST ${url}: ${formatUpstreamError(err)} headers=${headers} rawBody=${JSON.stringify(rawBody.slice(0, 2e3))}`);
3037
3040
  }
3038
3041
  sendJson(res, 400, { error: { message: "Invalid JSON body", type: "invalid_request_error" } });
3039
3042
  return;
@@ -3043,12 +3046,12 @@ async function startCodexProxy(routes, options = {}) {
3043
3046
  const inputItems = Array.isArray(body.input) ? body.input.length : typeof body.input === "string" ? 1 : 0;
3044
3047
  const tools = Array.isArray(body.tools) ? body.tools : [];
3045
3048
  const toolNames = tools.map((t) => t && typeof t === "object" && "name" in t ? t.name : "?").join(",");
3046
- log14(`request: model=${String(body.model ?? "")} previous_response_id=${prevId ?? "(none)"} input_items=${inputItems} body_bytes=${rawBody.length} tools=[${toolNames || "none"}]`);
3049
+ log15(`request: model=${String(body.model ?? "")} previous_response_id=${prevId ?? "(none)"} input_items=${inputItems} body_bytes=${rawBody.length} tools=[${toolNames || "none"}]`);
3047
3050
  const mcpTools = tools.filter((t) => t && typeof t === "object" && "name" in t && String(t.name).startsWith("mcp__"));
3048
3051
  for (const t of mcpTools) {
3049
3052
  const mt = t;
3050
3053
  const subTools = mt.type === "namespace" && Array.isArray(mt.tools) ? ` subTools=[${mt.tools.length}]` : "";
3051
- log14(` mcp-tool: name=${mt.name} type=${mt.type} desc=${JSON.stringify(String(mt.description ?? "")).slice(0, 120)}${subTools}`);
3054
+ log15(` mcp-tool: name=${mt.name} type=${mt.type} desc=${JSON.stringify(String(mt.description ?? "")).slice(0, 120)}${subTools}`);
3052
3055
  }
3053
3056
  }
3054
3057
  const modelId = String(body.model ?? "");
@@ -3058,12 +3061,12 @@ async function startCodexProxy(routes, options = {}) {
3058
3061
  const fallbackLm = fallbackRoute ? models.get(fallbackRoute.modelId) : void 0;
3059
3062
  if (fallbackRoute && fallbackLm) {
3060
3063
  if (debug) {
3061
- log14(`resolveModel fallback: requested="${modelId}" \u2192 ${fallbackRoute.modelId}`);
3064
+ log15(`resolveModel fallback: requested="${modelId}" \u2192 ${fallbackRoute.modelId}`);
3062
3065
  }
3063
3066
  resolved = { route: fallbackRoute, languageModel: fallbackLm };
3064
3067
  } else {
3065
3068
  if (debug) {
3066
- log14(`resolveModel failed: requested="${modelId}" known=[${routes.map((r) => r.modelId).join(", ")}]`);
3069
+ log15(`resolveModel failed: requested="${modelId}" known=[${routes.map((r) => r.modelId).join(", ")}]`);
3067
3070
  }
3068
3071
  sendJson(res, 404, { error: { message: `Unknown model: ${modelId}`, type: "invalid_request_error" } });
3069
3072
  return;
@@ -3088,16 +3091,16 @@ async function startCodexProxy(routes, options = {}) {
3088
3091
  const before = params.messages.length;
3089
3092
  const estimatedChars = estimateCodexRequestChars(params);
3090
3093
  const compaction = isLikelyCodexCompactionRequest(body);
3091
- if (debug) log14(`context check: model=${route.modelId} window=${route.contextWindow} chars=${estimatedChars} compaction=${compaction ? "yes" : "no"} messages=${before}`);
3094
+ if (debug) log15(`context check: model=${route.modelId} window=${route.contextWindow} chars=${estimatedChars} compaction=${compaction ? "yes" : "no"} messages=${before}`);
3092
3095
  params = protectCodexCompactionParams(body, params, route.contextWindow);
3093
3096
  params.isCompaction = compaction;
3094
3097
  if (debug && params.messages.length < before) {
3095
- log14(`context trim: model=${route.modelId} window=${route.contextWindow} kept=${params.messages.length}/${before} messages`);
3098
+ log15(`context trim: model=${route.modelId} window=${route.contextWindow} kept=${params.messages.length}/${before} messages`);
3096
3099
  }
3097
3100
  }
3098
3101
  if (debug) {
3099
3102
  const effort = body.reasoning?.effort;
3100
- log14(`model=${route.modelId} effort=${effort ?? "(none)"} providerOptions=${JSON.stringify(params.providerOptions)}`);
3103
+ log15(`model=${route.modelId} effort=${effort ?? "(none)"} providerOptions=${JSON.stringify(params.providerOptions)}`);
3101
3104
  }
3102
3105
  if (body.stream) {
3103
3106
  res.writeHead(200, {
@@ -3110,17 +3113,17 @@ async function startCodexProxy(routes, options = {}) {
3110
3113
  await streamResponsesResponse(languageModel, params, modelId, write, (summary) => {
3111
3114
  if (debug) {
3112
3115
  const failure = `${summary.aborted ? " aborted=yes" : ""}${summary.errorMessage ? ` error=${JSON.stringify(summary.errorMessage)}` : ""}`;
3113
- log14(`response done: model=${route.modelId} reasoningChars=${summary.reasoningChars} textChars=${summary.textChars} toolCalls=${summary.toolCallCount} toolNames=[${summary.toolNames.join(",")}] loopDetected=${summary.loopDetected ?? "no"} dsmlRecovered=${summary.dsmlToolCallsRecovered ?? 0}${failure} reasoningPreview=${JSON.stringify(summary.reasoningPreview)}`);
3116
+ log15(`response done: model=${route.modelId} reasoningChars=${summary.reasoningChars} textChars=${summary.textChars} toolCalls=${summary.toolCallCount} toolNames=[${summary.toolNames.join(",")}] loopDetected=${summary.loopDetected ?? "no"} dsmlRecovered=${summary.dsmlToolCallsRecovered ?? 0}${failure} reasoningPreview=${JSON.stringify(summary.reasoningPreview)}`);
3114
3117
  }
3115
3118
  }, (progress) => {
3116
3119
  if (debug) {
3117
- log14(`response progress: model=${route.modelId} elapsedMs=${progress.elapsedMs} reasoningChars=${progress.reasoningChars} textChars=${progress.textChars} toolCalls=${progress.toolCallCount} reasoningTail=${JSON.stringify(progress.reasoningTail)}`);
3120
+ log15(`response progress: model=${route.modelId} elapsedMs=${progress.elapsedMs} reasoningChars=${progress.reasoningChars} textChars=${progress.textChars} toolCalls=${progress.toolCallCount} reasoningTail=${JSON.stringify(progress.reasoningTail)}`);
3118
3121
  }
3119
3122
  });
3120
3123
  } catch (err) {
3121
3124
  const msg = formatUpstreamError(err);
3122
3125
  const status = upstreamHttpStatus(err);
3123
- if (debug) log14(`sdk error: ${route.modelId}: ${msg}`);
3126
+ if (debug) log15(`sdk error: ${route.modelId}: ${msg}`);
3124
3127
  if (status === 429) {
3125
3128
  writeResponsesRateLimitStream(modelId, msg, write);
3126
3129
  } else {
@@ -3135,7 +3138,7 @@ async function startCodexProxy(routes, options = {}) {
3135
3138
  } catch (err) {
3136
3139
  const msg = formatUpstreamError(err);
3137
3140
  const status = upstreamHttpStatus(err);
3138
- if (debug) log14(`sdk error: ${route.modelId}: ${msg}`);
3141
+ if (debug) log15(`sdk error: ${route.modelId}: ${msg}`);
3139
3142
  if (status === 429) {
3140
3143
  sendJson(res, 200, responsesRateLimitBody(modelId, msg));
3141
3144
  } else {
@@ -3145,7 +3148,7 @@ async function startCodexProxy(routes, options = {}) {
3145
3148
  }
3146
3149
  } catch (err) {
3147
3150
  const msg = formatUpstreamError(err);
3148
- log14(`handler error: ${msg}`);
3151
+ log15(`handler error: ${msg}`);
3149
3152
  sendJson(res, 500, { error: { message: msg, type: "api_error" } });
3150
3153
  }
3151
3154
  return;
@@ -3245,9 +3248,9 @@ Sec-WebSocket-Accept: ${wsAcceptKey(clientKey)}\r
3245
3248
  };
3246
3249
  const sendWsEvent = (sseChunk2) => {
3247
3250
  if (socket.destroyed) return;
3248
- for (const line of sseChunk2.split("\n")) {
3249
- if (line.startsWith("data: ")) {
3250
- socket.write(wsEncodeTextFrame(line.slice(6)));
3251
+ for (const line2 of sseChunk2.split("\n")) {
3252
+ if (line2.startsWith("data: ")) {
3253
+ socket.write(wsEncodeTextFrame(line2.slice(6)));
3251
3254
  }
3252
3255
  }
3253
3256
  };
@@ -3263,7 +3266,7 @@ Sec-WebSocket-Accept: ${wsAcceptKey(clientKey)}\r
3263
3266
  try {
3264
3267
  body = JSON.parse(frame.text);
3265
3268
  } catch {
3266
- if (debug) log14(`WS Error: Invalid JSON body: rawBody=${JSON.stringify(frame.text.slice(0, 2e3))}`);
3269
+ if (debug) log15(`WS Error: Invalid JSON body: rawBody=${JSON.stringify(frame.text.slice(0, 2e3))}`);
3267
3270
  sendWsEvent(`event: error
3268
3271
  data: ${JSON.stringify({ error: { message: "Invalid JSON", type: "invalid_request_error" } })}
3269
3272
 
@@ -3276,7 +3279,7 @@ data: ${JSON.stringify({ error: { message: "Invalid JSON", type: "invalid_reques
3276
3279
  const inputItems = Array.isArray(body.input) ? body.input.length : typeof body.input === "string" ? 1 : 0;
3277
3280
  const tools = Array.isArray(body.tools) ? body.tools : [];
3278
3281
  const toolNames = tools.map((t) => t && typeof t === "object" && "name" in t ? t.name : "?").join(",");
3279
- log14(`WS request: model=${String(body.model ?? "")} previous_response_id=${prevId ?? "(none)"} input_items=${inputItems} body_bytes=${frame.text.length} tools=[${toolNames || "none"}]`);
3282
+ log15(`WS request: model=${String(body.model ?? "")} previous_response_id=${prevId ?? "(none)"} input_items=${inputItems} body_bytes=${frame.text.length} tools=[${toolNames || "none"}]`);
3280
3283
  }
3281
3284
  const modelId = String(body.model ?? "");
3282
3285
  let resolved = resolveModel(routes, models, modelId);
@@ -3284,10 +3287,10 @@ data: ${JSON.stringify({ error: { message: "Invalid JSON", type: "invalid_reques
3284
3287
  const fb = routes[0];
3285
3288
  const fbLm = fb ? models.get(fb.modelId) : void 0;
3286
3289
  if (fb && fbLm) {
3287
- if (debug) log14(`WS resolveModel fallback: requested="${modelId}" \u2192 ${fb.modelId}`);
3290
+ if (debug) log15(`WS resolveModel fallback: requested="${modelId}" \u2192 ${fb.modelId}`);
3288
3291
  resolved = { route: fb, languageModel: fbLm };
3289
3292
  } else {
3290
- if (debug) log14(`WS resolveModel failed: requested="${modelId}" known=[${routes.map((r) => r.modelId).join(", ")}]`);
3293
+ if (debug) log15(`WS resolveModel failed: requested="${modelId}" known=[${routes.map((r) => r.modelId).join(", ")}]`);
3291
3294
  sendWsEvent(`event: error
3292
3295
  data: ${JSON.stringify({ error: { message: `Unknown model: ${modelId}` } })}
3293
3296
 
@@ -3315,31 +3318,31 @@ data: ${JSON.stringify({ error: { message: `Unknown model: ${modelId}` } })}
3315
3318
  const before = params.messages.length;
3316
3319
  const estimatedChars = estimateCodexRequestChars(params);
3317
3320
  const compaction = isLikelyCodexCompactionRequest(body);
3318
- if (debug) log14(`WS context check: model=${route.modelId} window=${route.contextWindow} chars=${estimatedChars} compaction=${compaction ? "yes" : "no"} messages=${before} tools=${params.tools ? Object.keys(params.tools).length : 0}`);
3321
+ if (debug) log15(`WS context check: model=${route.modelId} window=${route.contextWindow} chars=${estimatedChars} compaction=${compaction ? "yes" : "no"} messages=${before} tools=${params.tools ? Object.keys(params.tools).length : 0}`);
3319
3322
  params = protectCodexCompactionParams(body, params, route.contextWindow);
3320
3323
  params.isCompaction = compaction;
3321
3324
  if (debug && params.messages.length < before) {
3322
- log14(`WS context trim: model=${route.modelId} window=${route.contextWindow} kept=${params.messages.length}/${before} messages tools=${params.tools ? Object.keys(params.tools).length : 0}`);
3325
+ log15(`WS context trim: model=${route.modelId} window=${route.contextWindow} kept=${params.messages.length}/${before} messages tools=${params.tools ? Object.keys(params.tools).length : 0}`);
3323
3326
  }
3324
3327
  }
3325
3328
  if (debug) {
3326
3329
  const effort = body.reasoning?.effort;
3327
- log14(`WS model=${route.modelId} effort=${effort ?? "(none)"} providerOptions=${JSON.stringify(params.providerOptions)}`);
3330
+ log15(`WS model=${route.modelId} effort=${effort ?? "(none)"} providerOptions=${JSON.stringify(params.providerOptions)}`);
3328
3331
  }
3329
3332
  await streamResponsesResponse(languageModel, params, modelId, sendWsEvent, (summary) => {
3330
3333
  if (debug) {
3331
3334
  const failure = `${summary.aborted ? " aborted=yes" : ""}${summary.errorMessage ? ` error=${JSON.stringify(summary.errorMessage)}` : ""}`;
3332
- log14(`WS response done: model=${route.modelId} reasoningChars=${summary.reasoningChars} textChars=${summary.textChars} toolCalls=${summary.toolCallCount} toolNames=[${summary.toolNames.join(",")}] loopDetected=${summary.loopDetected ?? "no"} dsmlRecovered=${summary.dsmlToolCallsRecovered ?? 0}${failure} reasoningPreview=${JSON.stringify(summary.reasoningPreview)}`);
3335
+ log15(`WS response done: model=${route.modelId} reasoningChars=${summary.reasoningChars} textChars=${summary.textChars} toolCalls=${summary.toolCallCount} toolNames=[${summary.toolNames.join(",")}] loopDetected=${summary.loopDetected ?? "no"} dsmlRecovered=${summary.dsmlToolCallsRecovered ?? 0}${failure} reasoningPreview=${JSON.stringify(summary.reasoningPreview)}`);
3333
3336
  }
3334
3337
  }, (progress) => {
3335
3338
  if (debug) {
3336
- log14(`WS response progress: model=${route.modelId} elapsedMs=${progress.elapsedMs} reasoningChars=${progress.reasoningChars} textChars=${progress.textChars} toolCalls=${progress.toolCallCount} reasoningTail=${JSON.stringify(progress.reasoningTail)}`);
3339
+ log15(`WS response progress: model=${route.modelId} elapsedMs=${progress.elapsedMs} reasoningChars=${progress.reasoningChars} textChars=${progress.textChars} toolCalls=${progress.toolCallCount} reasoningTail=${JSON.stringify(progress.reasoningTail)}`);
3337
3340
  }
3338
3341
  });
3339
3342
  } catch (err) {
3340
3343
  const msg = formatUpstreamError(err);
3341
3344
  const status = upstreamHttpStatus(err);
3342
- if (debug) log14(`WS sdk error: ${route.modelId}: ${msg}`);
3345
+ if (debug) log15(`WS sdk error: ${route.modelId}: ${msg}`);
3343
3346
  if (status === 429) {
3344
3347
  writeResponsesRateLimitStream(modelId, msg, sendWsEvent);
3345
3348
  } else {
@@ -3561,7 +3564,7 @@ function restoreCodexOverlay(env = process.env) {
3561
3564
  return removed;
3562
3565
  }
3563
3566
  function remainingOverlayPaths(env = process.env) {
3564
- return ownedOverlayPaths(env).filter((p15) => existsSync2(p15));
3567
+ return ownedOverlayPaths(env).filter((p16) => existsSync2(p16));
3565
3568
  }
3566
3569
  function recoverInterruptedCodexSession(env = process.env) {
3567
3570
  const before = remainingOverlayPaths(env);
@@ -4274,7 +4277,7 @@ function resolveLaunchTarget(explicit, prefs, agent) {
4274
4277
  }
4275
4278
  function findProviderAndModel(providers, target) {
4276
4279
  if (!target.providerId || !target.modelId) return null;
4277
- const provider = providers.find((p15) => p15.id === target.providerId);
4280
+ const provider = providers.find((p16) => p16.id === target.providerId);
4278
4281
  if (!provider) return null;
4279
4282
  const model = provider.models.find((m) => m.id === target.modelId);
4280
4283
  if (!model) return null;
@@ -4874,7 +4877,7 @@ Error: ${launchPlan.error}
4874
4877
  });
4875
4878
  if (configOnly) {
4876
4879
  const home = process.env["HOME"] ?? "";
4877
- const shortenPath = (p15) => home ? p15.replace(home, "~") : p15;
4880
+ const shortenPath = (p16) => home ? p16.replace(home, "~") : p16;
4878
4881
  console.log("");
4879
4882
  console.log(pc7.bold(pc7.cyan(" CONFIG PREVIEW \u2014 anygate codex")));
4880
4883
  console.log("");
@@ -5214,7 +5217,7 @@ function stripGeminiIdentity(text4) {
5214
5217
  function translateGeminiRequest(body, options = {}) {
5215
5218
  let system;
5216
5219
  if (body.systemInstruction?.parts) {
5217
- const rawSystem = body.systemInstruction.parts.map((p15) => p15.text || "").join("\n");
5220
+ const rawSystem = body.systemInstruction.parts.map((p16) => p16.text || "").join("\n");
5218
5221
  system = stripGeminiIdentity(rawSystem).trim();
5219
5222
  }
5220
5223
  const messages = [];
@@ -5225,9 +5228,9 @@ function translateGeminiRequest(body, options = {}) {
5225
5228
  const parts = [];
5226
5229
  const toolResults = [];
5227
5230
  const turnParts = turn.parts || [];
5228
- for (const p15 of turnParts) {
5229
- if (p15.text !== void 0) {
5230
- const text4 = stripGeminiIdentity(p15.text);
5231
+ for (const p16 of turnParts) {
5232
+ if (p16.text !== void 0) {
5233
+ const text4 = stripGeminiIdentity(p16.text);
5231
5234
  if (text4.includes("<thinking>")) {
5232
5235
  const tokens = text4.split(/<thinking>([\s\S]*?)<\/thinking>/);
5233
5236
  for (let i = 0; i < tokens.length; i++) {
@@ -5238,25 +5241,25 @@ function translateGeminiRequest(body, options = {}) {
5238
5241
  } else {
5239
5242
  parts.push({ type: "text", text: text4 });
5240
5243
  }
5241
- } else if (p15.inlineData) {
5244
+ } else if (p16.inlineData) {
5242
5245
  parts.push({
5243
5246
  type: "image",
5244
- image: Buffer.from(p15.inlineData.data, "base64"),
5245
- mediaType: p15.inlineData.mimeType
5247
+ image: Buffer.from(p16.inlineData.data, "base64"),
5248
+ mediaType: p16.inlineData.mimeType
5246
5249
  });
5247
- } else if (p15.functionCall) {
5250
+ } else if (p16.functionCall) {
5248
5251
  const id = "call_" + randomUUID().replace(/-/g, "");
5249
- const name = p15.functionCall.name;
5252
+ const name = p16.functionCall.name;
5250
5253
  if (!nameToIdList.has(name)) nameToIdList.set(name, []);
5251
5254
  nameToIdList.get(name).push(id);
5252
5255
  parts.push({
5253
5256
  type: "tool-call",
5254
5257
  toolCallId: id,
5255
5258
  toolName: name,
5256
- input: p15.functionCall.args || {}
5259
+ input: p16.functionCall.args || {}
5257
5260
  });
5258
- } else if (p15.functionResponse) {
5259
- const name = p15.functionResponse.name;
5261
+ } else if (p16.functionResponse) {
5262
+ const name = p16.functionResponse.name;
5260
5263
  const idList = nameToIdList.get(name) || [];
5261
5264
  const id = idList.shift() || "call_" + randomUUID().replace(/-/g, "");
5262
5265
  toolResults.push({
@@ -5265,7 +5268,7 @@ function translateGeminiRequest(body, options = {}) {
5265
5268
  toolName: name,
5266
5269
  output: {
5267
5270
  type: "text",
5268
- value: typeof p15.functionResponse.response === "string" ? p15.functionResponse.response : JSON.stringify(p15.functionResponse.response || {})
5271
+ value: typeof p16.functionResponse.response === "string" ? p16.functionResponse.response : JSON.stringify(p16.functionResponse.response || {})
5269
5272
  }
5270
5273
  });
5271
5274
  }
@@ -5471,9 +5474,9 @@ ${JSON.stringify(params, null, 2)}`);
5471
5474
  const toolCallBuffers = /* @__PURE__ */ new Map();
5472
5475
  let isThinking = false;
5473
5476
  for await (const part of fullStream) {
5474
- const p15 = part;
5475
- plog(`Stream chunk type: ${p15.type}`);
5476
- if (isThinking && (p15.type === "tool-input-start" || p15.type === "tool-call" || p15.type === "finish")) {
5477
+ const p16 = part;
5478
+ plog(`Stream chunk type: ${p16.type}`);
5479
+ if (isThinking && (p16.type === "tool-input-start" || p16.type === "tool-call" || p16.type === "finish")) {
5477
5480
  isThinking = false;
5478
5481
  const chunk = {
5479
5482
  candidates: [{ content: { role: "model", parts: [{ text: `
@@ -5486,8 +5489,8 @@ ${JSON.stringify(params, null, 2)}`);
5486
5489
 
5487
5490
  `);
5488
5491
  }
5489
- if (p15.type === "reasoning") {
5490
- let text4 = p15.textDelta ?? p15.text ?? "";
5492
+ if (p16.type === "reasoning") {
5493
+ let text4 = p16.textDelta ?? p16.text ?? "";
5491
5494
  if (!isThinking) {
5492
5495
  isThinking = true;
5493
5496
  text4 = `<thinking>
@@ -5500,8 +5503,8 @@ ${JSON.stringify(params, null, 2)}`);
5500
5503
  res.write(`data: ${JSON.stringify(chunk)}
5501
5504
 
5502
5505
  `);
5503
- } else if (p15.type === "text-delta") {
5504
- let text4 = p15.textDelta ?? p15.text ?? "";
5506
+ } else if (p16.type === "text-delta") {
5507
+ let text4 = p16.textDelta ?? p16.text ?? "";
5505
5508
  if (isThinking) {
5506
5509
  isThinking = false;
5507
5510
  text4 = `
@@ -5521,17 +5524,17 @@ ${JSON.stringify(params, null, 2)}`);
5521
5524
  const data = `data: ${JSON.stringify(chunk)}
5522
5525
 
5523
5526
  `;
5524
- plog(`Streaming text delta: ${p15.textDelta}`);
5527
+ plog(`Streaming text delta: ${p16.textDelta}`);
5525
5528
  res.write(data);
5526
- } else if (p15.type === "tool-input-start") {
5527
- toolCallBuffers.set(p15.toolCallId, { name: p15.toolName, json: "" });
5528
- } else if (p15.type === "tool-input-delta") {
5529
- const buf = toolCallBuffers.get(p15.toolCallId);
5530
- if (buf) buf.json += p15.delta;
5531
- } else if (p15.type === "tool-call") {
5532
- const buf = toolCallBuffers.get(p15.toolCallId);
5533
- const args = buf ? JSON.parse(buf.json || "{}") : p15.input || {};
5534
- const name = buf ? buf.name : p15.toolName;
5529
+ } else if (p16.type === "tool-input-start") {
5530
+ toolCallBuffers.set(p16.toolCallId, { name: p16.toolName, json: "" });
5531
+ } else if (p16.type === "tool-input-delta") {
5532
+ const buf = toolCallBuffers.get(p16.toolCallId);
5533
+ if (buf) buf.json += p16.delta;
5534
+ } else if (p16.type === "tool-call") {
5535
+ const buf = toolCallBuffers.get(p16.toolCallId);
5536
+ const args = buf ? JSON.parse(buf.json || "{}") : p16.input || {};
5537
+ const name = buf ? buf.name : p16.toolName;
5535
5538
  plog(`Streaming tool call: ${name} with args: ${JSON.stringify(args)}`);
5536
5539
  const chunk = {
5537
5540
  candidates: [{
@@ -5547,18 +5550,18 @@ ${JSON.stringify(params, null, 2)}`);
5547
5550
  res.write(`data: ${JSON.stringify(chunk)}
5548
5551
 
5549
5552
  `);
5550
- } else if (p15.type === "finish") {
5553
+ } else if (p16.type === "finish") {
5551
5554
  const chunk = {
5552
5555
  candidates: [{
5553
- finishReason: mapFinishReason(p15.finishReason ?? "")
5556
+ finishReason: mapFinishReason(p16.finishReason ?? "")
5554
5557
  }],
5555
5558
  usageMetadata: {
5556
- promptTokenCount: p15.totalUsage?.inputTokens || 0,
5557
- candidatesTokenCount: p15.totalUsage?.outputTokens || 0
5559
+ promptTokenCount: p16.totalUsage?.inputTokens || 0,
5560
+ candidatesTokenCount: p16.totalUsage?.outputTokens || 0
5558
5561
  },
5559
5562
  modelVersion: route.aliasId
5560
5563
  };
5561
- plog(`Stream finish. Reason: ${p15.finishReason}`);
5564
+ plog(`Stream finish. Reason: ${p16.finishReason}`);
5562
5565
  res.write(`data: ${JSON.stringify(chunk)}
5563
5566
 
5564
5567
  `);
@@ -7780,7 +7783,7 @@ async function startCloudCodeGateway(routes, opts = {}) {
7780
7783
  const templateKey = opts.templateKey ?? "gemini-3.5-flash-low";
7781
7784
  const trace = opts.trace ?? false;
7782
7785
  const trackActiveRoute = opts.trackActiveRoute ?? false;
7783
- const log14 = opts.logFn ?? (() => {
7786
+ const log15 = opts.logFn ?? (() => {
7784
7787
  });
7785
7788
  const catalogFixture = fetchAvailableModels_default;
7786
7789
  const injectedCatalog = injectGatewayModels(catalogFixture, routes, templateKey);
@@ -7830,12 +7833,12 @@ async function startCloudCodeGateway(routes, opts = {}) {
7830
7833
  const contentType = (req.headers["content-type"] ?? "").toLowerCase();
7831
7834
  const lowerUrl = url.toLowerCase();
7832
7835
  if (trace) {
7833
- log14(`[gateway] ${method} ${url}`);
7834
- log14(`[gateway] content-type: ${contentType}`);
7835
- log14(`[gateway] body-size: ${bodyStr.length}`);
7836
+ log15(`[gateway] ${method} ${url}`);
7837
+ log15(`[gateway] content-type: ${contentType}`);
7838
+ log15(`[gateway] body-size: ${bodyStr.length}`);
7836
7839
  }
7837
7840
  if (contentType.includes("proto") || contentType.includes("grpc") && !contentType.includes("json")) {
7838
- log14(`[gateway] UNSUPPORTED content-type: ${contentType}`);
7841
+ log15(`[gateway] UNSUPPORTED content-type: ${contentType}`);
7839
7842
  respondJson(res, 415, {
7840
7843
  error: {
7841
7844
  code: 415,
@@ -7851,35 +7854,35 @@ async function startCloudCodeGateway(routes, opts = {}) {
7851
7854
  }
7852
7855
  if (trace && parsed) {
7853
7856
  const preview = JSON.stringify(parsed).slice(0, 500);
7854
- log14(`[gateway] body-preview: ${preview}`);
7857
+ log15(`[gateway] body-preview: ${preview}`);
7855
7858
  }
7856
7859
  if (lowerUrl.includes("loadcodeassist")) {
7857
- if (trace) log14("[gateway] \u2192 loadCodeAssist");
7860
+ if (trace) log15("[gateway] \u2192 loadCodeAssist");
7858
7861
  respondJson(res, 200, loadCodeAssist_default);
7859
7862
  return;
7860
7863
  }
7861
7864
  if (lowerUrl.includes("fetchavailablemodels") || lowerUrl.includes("getavailablemodels")) {
7862
- if (trace) log14("[gateway] \u2192 fetchAvailableModels");
7865
+ if (trace) log15("[gateway] \u2192 fetchAvailableModels");
7863
7866
  respondJson(res, 200, injectedCatalog);
7864
7867
  return;
7865
7868
  }
7866
7869
  if (lowerUrl.includes("modelconfigs")) {
7867
- if (trace) log14("[gateway] \u2192 listModelConfigs");
7870
+ if (trace) log15("[gateway] \u2192 listModelConfigs");
7868
7871
  respondJson(res, 200, modelConfigsResponse);
7869
7872
  return;
7870
7873
  }
7871
7874
  if (lowerUrl.includes("generatecontent") || lowerUrl.includes("generatechat")) {
7872
7875
  const model = parsed?.model;
7873
- if (trace) log14(`[gateway] extracted model: ${model ?? "N/A"}`);
7876
+ if (trace) log15(`[gateway] extracted model: ${model ?? "N/A"}`);
7874
7877
  const route = resolveRouteForModel(model);
7875
7878
  if (route) {
7876
7879
  if (trackActiveRoute && selectedSlotIds.has(model ?? "") && isUserTurnRequest(parsed)) {
7877
7880
  activeRoute = route;
7878
- if (trace) log14(`[gateway] active route: ${route.catalogId} via ${model}`);
7881
+ if (trace) log15(`[gateway] active route: ${route.catalogId} via ${model}`);
7879
7882
  }
7880
7883
  if (isCloudCodeOAuthRoute(route)) {
7881
- handleCloudCodeForwardRequest(res, route, parsed, lowerUrl, log14).catch((err) => {
7882
- log14(`[gateway] cloud-code forward error: ${err instanceof Error ? err.stack || err.message : String(err)}`);
7884
+ handleCloudCodeForwardRequest(res, route, parsed, lowerUrl, log15).catch((err) => {
7885
+ log15(`[gateway] cloud-code forward error: ${err instanceof Error ? err.stack || err.message : String(err)}`);
7883
7886
  if (!res.headersSent) {
7884
7887
  respondJson(res, 500, { error: { code: 500, message: formatUpstreamError(err) } });
7885
7888
  } else if (!res.writableEnded) {
@@ -7897,11 +7900,11 @@ async function startCloudCodeGateway(routes, opts = {}) {
7897
7900
  rememberReasoningEcho(reasoningEchoesByConversation, conversationKey, reasoning);
7898
7901
  };
7899
7902
  if (isStream) {
7900
- handleStreamingRequest(res, route, baseProviderOptions, parsed, log14, {
7903
+ handleStreamingRequest(res, route, baseProviderOptions, parsed, log15, {
7901
7904
  requestOptions,
7902
7905
  onReasoningWithToolCall: rememberReasoning
7903
7906
  }).catch((err) => {
7904
- log14(`[gateway] stream error: ${err instanceof Error ? err.stack || err.message : String(err)}`);
7907
+ log15(`[gateway] stream error: ${err instanceof Error ? err.stack || err.message : String(err)}`);
7905
7908
  if (!res.headersSent) {
7906
7909
  respondJson(res, 500, { error: { code: 500, message: formatUpstreamError(err) } });
7907
7910
  } else if (!res.writableEnded) {
@@ -7909,11 +7912,11 @@ async function startCloudCodeGateway(routes, opts = {}) {
7909
7912
  }
7910
7913
  });
7911
7914
  } else {
7912
- handleUnaryRequest(res, route, baseProviderOptions, parsed, log14, {
7915
+ handleUnaryRequest(res, route, baseProviderOptions, parsed, log15, {
7913
7916
  requestOptions,
7914
7917
  onReasoningWithToolCall: rememberReasoning
7915
7918
  }).catch((err) => {
7916
- log14(`[gateway] unary error: ${err instanceof Error ? err.stack || err.message : String(err)}`);
7919
+ log15(`[gateway] unary error: ${err instanceof Error ? err.stack || err.message : String(err)}`);
7917
7920
  if (!res.headersSent) {
7918
7921
  respondJson(res, 500, { error: { code: 500, message: formatUpstreamError(err) } });
7919
7922
  }
@@ -8009,7 +8012,7 @@ async function startCloudCodeGateway(routes, opts = {}) {
8009
8012
  return;
8010
8013
  }
8011
8014
  if (trace) {
8012
- log14(`[gateway] unknown endpoint: ${url}`);
8015
+ log15(`[gateway] unknown endpoint: ${url}`);
8013
8016
  }
8014
8017
  respondJson(res, 200, {});
8015
8018
  }).catch((err) => {
@@ -8095,7 +8098,7 @@ function rememberReasoningEcho(cache, key, reasoning) {
8095
8098
  existing.push(normalized);
8096
8099
  cache.set(key, existing.slice(-MAX_REASONING_ECHOES_PER_CONVERSATION));
8097
8100
  }
8098
- async function handleCloudCodeForwardRequest(res, route, parsed, lowerUrl, log14) {
8101
+ async function handleCloudCodeForwardRequest(res, route, parsed, lowerUrl, log15) {
8099
8102
  const projectId = typeof route.providerData?.projectId === "string" ? route.providerData.projectId : "";
8100
8103
  if (!projectId) {
8101
8104
  respondJson(res, 500, {
@@ -8124,7 +8127,7 @@ async function handleCloudCodeForwardRequest(res, route, parsed, lowerUrl, log14
8124
8127
  });
8125
8128
  if (!upstream.ok) {
8126
8129
  const errBody = await upstream.text();
8127
- log14(`[gateway] cloud-code upstream error ${upstream.status}: ${errBody}`);
8130
+ log15(`[gateway] cloud-code upstream error ${upstream.status}: ${errBody}`);
8128
8131
  respondJson(res, upstream.status >= 500 ? 502 : upstream.status, {
8129
8132
  error: { code: upstream.status, message: errBody || upstream.statusText }
8130
8133
  });
@@ -8238,7 +8241,7 @@ function respondJson(res, status, data) {
8238
8241
  });
8239
8242
  res.end(body);
8240
8243
  }
8241
- async function handleStreamingRequest(res, route, providerOptions, parsed, log14, options = {}) {
8244
+ async function handleStreamingRequest(res, route, providerOptions, parsed, log15, options = {}) {
8242
8245
  const sdkParams = applyClaudeCodeOAuthIdentity(route, translateRequest(parsed, {
8243
8246
  ...options.requestOptions,
8244
8247
  maxTools: maxToolsForNpm(route.npm)
@@ -8279,21 +8282,21 @@ async function handleStreamingRequest(res, route, providerOptions, parsed, log14
8279
8282
  let responseReasoning = "";
8280
8283
  let sawToolCall = false;
8281
8284
  for await (const part of fullStream) {
8282
- const p15 = part;
8283
- if (p15.type === "reasoning-delta" || p15.type === "reasoning") {
8284
- const reasoning = reasoningDeltaText(p15);
8285
+ const p16 = part;
8286
+ if (p16.type === "reasoning-delta" || p16.type === "reasoning") {
8287
+ const reasoning = reasoningDeltaText(p16);
8285
8288
  responseReasoning += reasoning;
8286
8289
  emitThinkingDelta(res, route, responseId, reasoning, startSse);
8287
8290
  continue;
8288
8291
  }
8289
- if (p15.type === "text-delta") {
8290
- const { thought, text: text4 } = thinkFilter(reasoningDeltaText(p15));
8292
+ if (p16.type === "text-delta") {
8293
+ const { thought, text: text4 } = thinkFilter(reasoningDeltaText(p16));
8291
8294
  if (thought) {
8292
8295
  responseReasoning += thought;
8293
8296
  emitThinkingDelta(res, route, responseId, thought, startSse);
8294
8297
  }
8295
8298
  if (text4) {
8296
- log14(`[gateway] text-delta: ${JSON.stringify(text4.slice(0, 500))}`);
8299
+ log15(`[gateway] text-delta: ${JSON.stringify(text4.slice(0, 500))}`);
8297
8300
  startSse();
8298
8301
  const chunk = formatCloudCodeChunk({
8299
8302
  text: text4,
@@ -8304,25 +8307,25 @@ async function handleStreamingRequest(res, route, providerOptions, parsed, log14
8304
8307
 
8305
8308
  `);
8306
8309
  }
8307
- } else if (p15.type === "tool-input-start") {
8308
- const id = p15.id ?? p15.toolCallId;
8309
- toolCallBuffers.set(id, { name: p15.toolName, json: "" });
8310
- } else if (p15.type === "tool-input-delta") {
8311
- const id = p15.id ?? p15.toolCallId;
8310
+ } else if (p16.type === "tool-input-start") {
8311
+ const id = p16.id ?? p16.toolCallId;
8312
+ toolCallBuffers.set(id, { name: p16.toolName, json: "" });
8313
+ } else if (p16.type === "tool-input-delta") {
8314
+ const id = p16.id ?? p16.toolCallId;
8312
8315
  const buf = toolCallBuffers.get(id);
8313
- if (buf) buf.json += p15.delta;
8314
- } else if (p15.type === "tool-call") {
8316
+ if (buf) buf.json += p16.delta;
8317
+ } else if (p16.type === "tool-call") {
8315
8318
  sawToolCall = true;
8316
- const id = p15.toolCallId ?? p15.id;
8319
+ const id = p16.toolCallId ?? p16.id;
8317
8320
  const buf = toolCallBuffers.get(id);
8318
8321
  let args = {};
8319
8322
  try {
8320
- args = buf ? JSON.parse(buf.json || "{}") : p15.input || {};
8323
+ args = buf ? JSON.parse(buf.json || "{}") : p16.input || {};
8321
8324
  } catch {
8322
- args = p15.input || {};
8325
+ args = p16.input || {};
8323
8326
  }
8324
- const name = buf ? buf.name : p15.toolName;
8325
- log14(`[gateway] tool-call: ${name}`);
8327
+ const name = buf ? buf.name : p16.toolName;
8328
+ log15(`[gateway] tool-call: ${name}`);
8326
8329
  startSse();
8327
8330
  const chunk = formatCloudCodeChunk({
8328
8331
  functionCall: { name, args: normalizeFunctionCallArgs(args) },
@@ -8332,29 +8335,29 @@ async function handleStreamingRequest(res, route, providerOptions, parsed, log14
8332
8335
  res.write(`data: ${JSON.stringify(chunk)}
8333
8336
 
8334
8337
  `);
8335
- } else if (p15.type === "finish") {
8336
- log14(`[gateway] finish: ${p15.finishReason ?? "unknown"}`);
8338
+ } else if (p16.type === "finish") {
8339
+ log15(`[gateway] finish: ${p16.finishReason ?? "unknown"}`);
8337
8340
  startSse();
8338
- const reason = mapFinishReason2(p15.finishReason ?? "");
8341
+ const reason = mapFinishReason2(p16.finishReason ?? "");
8339
8342
  const chunk = formatCloudCodeChunk({
8340
8343
  modelVersion: route.catalogId,
8341
8344
  responseId,
8342
8345
  finishReason: reason,
8343
8346
  usage: {
8344
- promptTokens: p15.totalUsage?.inputTokens || 0,
8345
- completionTokens: p15.totalUsage?.outputTokens || 0
8347
+ promptTokens: p16.totalUsage?.inputTokens || 0,
8348
+ completionTokens: p16.totalUsage?.outputTokens || 0
8346
8349
  }
8347
8350
  });
8348
8351
  res.write(`data: ${JSON.stringify(chunk)}
8349
8352
 
8350
8353
  `);
8351
- } else if (p15.type === "error") {
8352
- const message = formatUpstreamError(p15.error);
8353
- log14(`[gateway] stream provider error: ${message}`);
8354
+ } else if (p16.type === "error") {
8355
+ const message = formatUpstreamError(p16.error);
8356
+ log15(`[gateway] stream provider error: ${message}`);
8354
8357
  emitStreamError(res, route, responseId, message, startSse);
8355
8358
  break;
8356
- } else if (p15.type === "reasoning-start" || p15.type === "reasoning-end") {
8357
- log14(`[gateway] ${p15.type}`);
8359
+ } else if (p16.type === "reasoning-start" || p16.type === "reasoning-end") {
8360
+ log15(`[gateway] ${p16.type}`);
8358
8361
  }
8359
8362
  }
8360
8363
  if (!res.headersSent) {
@@ -8645,12 +8648,12 @@ function defaultProcessList() {
8645
8648
  function isAntigravityIdeRunning(profileDir, processList = defaultProcessList) {
8646
8649
  if (process.platform === "win32") return winIsProcessRunningForProfile("Antigravity IDE.exe", profileDir);
8647
8650
  const output = processList();
8648
- return output.split("\n").some((line) => line.includes("Antigravity IDE.app") && line.includes(`--user-data-dir=${profileDir}`));
8651
+ return output.split("\n").some((line2) => line2.includes("Antigravity IDE.app") && line2.includes(`--user-data-dir=${profileDir}`));
8649
8652
  }
8650
8653
  function isAntigravityAppRunning(profileDir, processList = defaultProcessList) {
8651
8654
  if (process.platform === "win32") return winIsProcessRunningForProfile("Antigravity.exe", profileDir);
8652
8655
  const output = processList();
8653
- return output.split("\n").some((line) => line.includes("Antigravity.app") && line.includes(`--user-data-dir=${profileDir}`));
8656
+ return output.split("\n").some((line2) => line2.includes("Antigravity.app") && line2.includes(`--user-data-dir=${profileDir}`));
8654
8657
  }
8655
8658
  async function waitForAntigravityIdeQuit(profileDir, options = {}) {
8656
8659
  const processList = options.processList ?? defaultProcessList;
@@ -8898,7 +8901,7 @@ async function resolveAntigravityLaunch(prefs, boot) {
8898
8901
  return null;
8899
8902
  }
8900
8903
  if (boot?.launchProvider && boot?.launchModel) {
8901
- const provider = allProviders.find((p15) => p15.id === boot.launchProvider);
8904
+ const provider = allProviders.find((p16) => p16.id === boot.launchProvider);
8902
8905
  if (!provider) {
8903
8906
  p11.log.error(`Provider not found: ${boot.launchProvider}`);
8904
8907
  return null;
@@ -10079,8 +10082,8 @@ async function runCodexAppCommand(args, opts = {}) {
10079
10082
  ...specBase,
10080
10083
  proxyPort: PREVIEW_PROXY_PORT
10081
10084
  });
10082
- for (const line of tomlPreview.split("\n")) {
10083
- console.log(` ${pc10.dim(line)}`);
10085
+ for (const line2 of tomlPreview.split("\n")) {
10086
+ console.log(` ${pc10.dim(line2)}`);
10084
10087
  }
10085
10088
  console.log("");
10086
10089
  console.log(` ${pc10.bold("Catalog file:")}`);
@@ -10675,8 +10678,8 @@ var SKILL_INSTALL_DIRS = [
10675
10678
  function parseSkillVersion(content) {
10676
10679
  const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
10677
10680
  if (!match) return null;
10678
- for (const line of match[1].split("\n")) {
10679
- const trimmed = line.trim();
10681
+ for (const line2 of match[1].split("\n")) {
10682
+ const trimmed = line2.trim();
10680
10683
  if (!trimmed.startsWith("version:")) continue;
10681
10684
  const raw = trimmed.slice("version:".length).trim();
10682
10685
  return raw.replace(/^["']|["']$/g, "");
@@ -10711,7 +10714,7 @@ function formatProviderModels(provider) {
10711
10714
  function buildLiveStateSection() {
10712
10715
  const prefs = loadPreferences();
10713
10716
  const registry = loadRegistry();
10714
- const enabled = registry.providers.filter((p15) => p15.enabled);
10717
+ const enabled = registry.providers.filter((p16) => p16.enabled);
10715
10718
  const prefLines = [];
10716
10719
  if (prefs.lastProvider || prefs.lastModel) {
10717
10720
  prefLines.push(` Claude last launch: provider=${prefs.lastProvider ?? "(none)"} model=${prefs.lastModel ?? "(none)"}`);
@@ -10728,9 +10731,9 @@ function buildLiveStateSection() {
10728
10731
  prefLines.push(` ${f.providerId} / ${f.modelId}`);
10729
10732
  }
10730
10733
  }
10731
- const providerBlocks = enabled.length === 0 ? [" No registry providers configured. Built-in cloud: zen, go (OpenCode Zen/Go)."] : enabled.map((p15) => [
10732
- ` ${p15.name} (${p15.id}) \u2014 ${p15.modelsCache?.models.length ?? 0} cached model(s)`,
10733
- formatProviderModels(p15)
10734
+ const providerBlocks = enabled.length === 0 ? [" No registry providers configured. Built-in cloud: zen, go (OpenCode Zen/Go)."] : enabled.map((p16) => [
10735
+ ` ${p16.name} (${p16.id}) \u2014 ${p16.modelsCache?.models.length ?? 0} cached model(s)`,
10736
+ formatProviderModels(p16)
10734
10737
  ].join("\n"));
10735
10738
  return `
10736
10739
  ================================================================================
@@ -11225,6 +11228,267 @@ function printAiInstallResult(result) {
11225
11228
  return result.failed.length > 0 ? 1 : 0;
11226
11229
  }
11227
11230
 
11231
+ // src/agents/shared/doctor.ts
11232
+ import pc12 from "picocolors";
11233
+ import { createServer as createServer3 } from "net";
11234
+ function nodeMajor() {
11235
+ const raw = process.versions.node.split(".")[0] ?? "0";
11236
+ return Number.parseInt(raw, 10) || 0;
11237
+ }
11238
+ function checkPortFree(port) {
11239
+ return new Promise((resolve) => {
11240
+ const server = createServer3();
11241
+ server.once("error", () => resolve(false));
11242
+ server.listen(port, () => {
11243
+ server.close(() => resolve(true));
11244
+ });
11245
+ const timer = setTimeout(() => resolve(true), 1500);
11246
+ if (typeof timer.unref === "function") timer.unref();
11247
+ });
11248
+ }
11249
+ function line(ok, label, detail = "") {
11250
+ const mark = ok ? pc12.green("\u2713") : pc12.red("\u2717");
11251
+ const text4 = detail ? `${label} ${pc12.dim(`\u2014 ${detail}`)}` : label;
11252
+ return ` ${mark} ${text4}`;
11253
+ }
11254
+ async function runDoctorCommand(_dryRun) {
11255
+ gateIntro("Doctor");
11256
+ const checks = [];
11257
+ const major = nodeMajor();
11258
+ checks.push({
11259
+ label: "Node.js version",
11260
+ ok: major >= 18,
11261
+ detail: `v${process.versions.node} (requires \u2265 18)`,
11262
+ critical: true
11263
+ });
11264
+ let keyringOk = false;
11265
+ let keyringDetail = "";
11266
+ try {
11267
+ keyringOk = await isSecretServiceAvailable();
11268
+ keyringDetail = keyringOk ? "credential store reachable" : "not available on this system";
11269
+ } catch (err) {
11270
+ keyringDetail = err instanceof Error ? err.message : String(err);
11271
+ }
11272
+ checks.push({
11273
+ label: "Secure credential store",
11274
+ ok: keyringOk,
11275
+ detail: keyringDetail,
11276
+ critical: false
11277
+ });
11278
+ let keyPresent = false;
11279
+ let keyDetail = "";
11280
+ try {
11281
+ const key = await readFromCredentialStore();
11282
+ keyPresent = Boolean(key?.trim());
11283
+ keyDetail = keyPresent ? "OPENCODE_API_KEY found" : "not set (get one at https://opencode.ai/auth)";
11284
+ } catch (err) {
11285
+ keyDetail = err instanceof Error ? err.message : String(err);
11286
+ }
11287
+ checks.push({
11288
+ label: "OpenCode API key",
11289
+ ok: keyPresent,
11290
+ detail: keyDetail,
11291
+ critical: false
11292
+ });
11293
+ const portFree = await checkPortFree(GATEWAY_PORT);
11294
+ checks.push({
11295
+ label: `Gateway port ${GATEWAY_PORT}`,
11296
+ ok: portFree,
11297
+ detail: portFree ? "available" : "in use \u2014 `anygate server` will fail to bind",
11298
+ critical: false
11299
+ });
11300
+ const conflicts = detectConflicts();
11301
+ checks.push({
11302
+ label: "Conflicting env vars",
11303
+ ok: conflicts.length === 0,
11304
+ detail: conflicts.length === 0 ? `none of the ${CONFLICTING_ENV_VARS.length} known conflicts set` : `${conflicts.length} set: ${conflicts.map((c) => c.name).join(", ")}`,
11305
+ critical: false
11306
+ });
11307
+ const failedCritical = checks.filter((c) => !c.ok && c.critical);
11308
+ const failedNonCritical = checks.filter((c) => !c.ok && !c.critical);
11309
+ const reportLines = checks.map((c) => line(c.ok, c.label, c.detail));
11310
+ reportLines.push("");
11311
+ reportLines.push(
11312
+ pc12.dim("Antigravity note: macOS-only today. Windows/Linux app launches are") + pc12.dim(" best-effort \u2014 see help for each agy/antigravity command.")
11313
+ );
11314
+ printPanel("Environment check", reportLines);
11315
+ if (failedCritical.length > 0) {
11316
+ gateOutro("Problems found", pc12.red(`${failedCritical.length} critical check(s) failed`));
11317
+ return 1;
11318
+ }
11319
+ if (failedNonCritical.length > 0) {
11320
+ gateOutro("Mostly OK", pc12.yellow(`${failedNonCritical.length} non-critical warning(s)`));
11321
+ return 0;
11322
+ }
11323
+ gateOutro("All checks passed");
11324
+ return 0;
11325
+ }
11326
+
11327
+ // src/agents/shared/completions.ts
11328
+ import pc13 from "picocolors";
11329
+ var SUBCOMMANDS = [
11330
+ "claude",
11331
+ "claude-app",
11332
+ "codex",
11333
+ "codex-app",
11334
+ "chatgpt",
11335
+ "gemini",
11336
+ "agy",
11337
+ "antigravity",
11338
+ "antigravity-ide",
11339
+ "server",
11340
+ "ui",
11341
+ "models",
11342
+ "favorites",
11343
+ "providers",
11344
+ "doctor",
11345
+ "completions",
11346
+ "update"
11347
+ ];
11348
+ var ROOT_FLAGS = ["--help", "--version", "--ai", "--ai --install", "--force"];
11349
+ function detectShell() {
11350
+ const shell = process.env["SHELL"]?.toLowerCase() ?? "";
11351
+ if (shell.includes("zsh")) return "zsh";
11352
+ if (shell.includes("bash")) return "bash";
11353
+ if (shell.includes("fish")) return "fish";
11354
+ if (process.env["PSModulePath"] || process.env["POWERSHELL_DISTRIBUTION_CHANNEL"]) return "powershell";
11355
+ return void 0;
11356
+ }
11357
+ function normalizeShell(input) {
11358
+ const s = input?.toLowerCase().trim();
11359
+ if (s === "bash" || s === "zsh" || s === "fish" || s === "powershell" || s === "pwsh" || s === "ps") {
11360
+ return s === "pwsh" || s === "ps" ? "powershell" : s;
11361
+ }
11362
+ return void 0;
11363
+ }
11364
+ function bashScript() {
11365
+ const cmds = SUBCOMMANDS.join(" ");
11366
+ return `# anygate bash completion
11367
+ _anygate() {
11368
+ local cur prev
11369
+ COMPREPLY=()
11370
+ cur="\${COMP_WORDS[COMP_CWORD]}"
11371
+ prev="\${COMP_WORDS[COMP_CWORD-1]}"
11372
+ local subcommands='${cmds}'
11373
+ local rootflags='${ROOT_FLAGS.join(" ")}'
11374
+ if [ "\${COMP_CWORD}" -eq 1 ]; then
11375
+ COMPREPLY=( $(compgen -W "\${subcommands} \${rootflags}" -- "\${cur}") )
11376
+ return 0
11377
+ fi
11378
+ COMPREPLY=( $(compgen -W "\${subcommands} \${rootflags}" -- "\${cur}") )
11379
+ return 0
11380
+ }
11381
+ complete -F _anygate anygate
11382
+ `;
11383
+ }
11384
+ function zshScript() {
11385
+ const cmds = SUBCOMMANDS.join(" ");
11386
+ return `# anygate zsh completion
11387
+ #compdef anygate
11388
+ _anygate() {
11389
+ local -a subcommands
11390
+ subcommands=(${cmds})
11391
+ _arguments '1:subcommand:(\${subcommands})' '*:: :_gnu_generic'
11392
+ }
11393
+ _anygate "$@"
11394
+ `;
11395
+ }
11396
+ function fishScript() {
11397
+ const lines = SUBCOMMANDS.map((c) => `complete -c anygate -n "not __fish_seen_subcommand_from ${SUBCOMMANDS.join(" ")}" -a ${c} -d 'anygate ${c}'`);
11398
+ lines.push(`complete -c anygate -s h -l help -d 'Show help'`);
11399
+ lines.push(`complete -c anygate -s v -l version -d 'Show version'`);
11400
+ return `# anygate fish completion
11401
+ ${lines.join("\n")}
11402
+ `;
11403
+ }
11404
+ function powershellScript() {
11405
+ const cmds = SUBCOMMANDS.map((c) => `'${c}'`).join(", ");
11406
+ return `# anygate PowerShell completion
11407
+ Register-ArgumentCompleter -CommandName anygate -ScriptBlock {
11408
+ param($wordToComplete, $commandAst, $cursorPosition)
11409
+ $subcommands = @(${cmds})
11410
+ $subcommands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
11411
+ [System.Management.Automation.CompletionResult]::new($_, $_, 'Command', "anygate $_")
11412
+ }
11413
+ }
11414
+ `;
11415
+ }
11416
+ var SCRIPTS = {
11417
+ bash: bashScript,
11418
+ zsh: zshScript,
11419
+ fish: fishScript,
11420
+ powershell: powershellScript
11421
+ };
11422
+ function runCompletionsCommand(shellArg) {
11423
+ const shell = normalizeShell(shellArg) ?? detectShell();
11424
+ if (!shell) {
11425
+ console.error(pc13.red("\\nError: could not detect your shell.\\n"));
11426
+ console.error("Pass one explicitly: anygate completions <bash|zsh|fish|powershell>\\n");
11427
+ return Promise.resolve(1);
11428
+ }
11429
+ process.stdout.write(SCRIPTS[shell]());
11430
+ return Promise.resolve(0);
11431
+ }
11432
+
11433
+ // src/agents/shared/self-update.ts
11434
+ import pc14 from "picocolors";
11435
+ import { spawn as spawn5, execFileSync as execFileSync4 } from "child_process";
11436
+ import * as p14 from "@clack/prompts";
11437
+ function resolveNpmBin() {
11438
+ if (process.platform === "win32") {
11439
+ try {
11440
+ const found = execFileSync4("where", ["npm"], { stdio: ["ignore", "pipe", "ignore"] }).toString().split(/\r?\n/).map((s) => s.trim()).find((s) => s.toLowerCase().endsWith(".cmd") || s.toLowerCase().endsWith("npm"));
11441
+ if (found) return found;
11442
+ } catch {
11443
+ }
11444
+ return "npm.cmd";
11445
+ }
11446
+ return "npm";
11447
+ }
11448
+ async function runUpdateCommand(dryRun) {
11449
+ const update = await checkForUpdates();
11450
+ if (!update.updateAvailable || !update.latestVersion) {
11451
+ p14.log.success(`anygate is up to date (v${VERSION}).`);
11452
+ return 0;
11453
+ }
11454
+ p14.log.info(
11455
+ `Update available: ${pc14.cyan(`v${update.currentVersion}`)} \u2192 ${pc14.green(`v${update.latestVersion}`)}`
11456
+ );
11457
+ const npmBin = resolveNpmBin();
11458
+ if (dryRun) {
11459
+ p14.log.step(`Would run: ${pc14.bold(`${npmBin} install -g anygate@latest`)}`);
11460
+ p14.log.warn("Dry run \u2014 no changes made.");
11461
+ return 0;
11462
+ }
11463
+ const confirmed = await p14.confirm({
11464
+ message: `Install anygate@${update.latestVersion} now?`,
11465
+ initialValue: false
11466
+ });
11467
+ if (p14.isCancel(confirmed) || !confirmed) {
11468
+ p14.log.info(`Update skipped. Run ${pc14.cyan(UPDATE_COMMAND)} later if you change your mind.`);
11469
+ return 0;
11470
+ }
11471
+ p14.log.info(`Running ${pc14.cyan(`${npmBin} install -g anygate@latest`)}...`);
11472
+ const child = spawn5(npmBin, ["install", "-g", "anygate@latest"], {
11473
+ stdio: "inherit",
11474
+ windowsHide: true
11475
+ });
11476
+ return new Promise((resolve) => {
11477
+ child.on("error", (err) => {
11478
+ p14.log.error(`Failed to start npm: ${err instanceof Error ? err.message : String(err)}`);
11479
+ resolve(1);
11480
+ });
11481
+ child.on("close", (code) => {
11482
+ if (code === 0) {
11483
+ p14.log.success("anygate updated. Restart your shell or re-run anygate to use the new version.");
11484
+ } else {
11485
+ p14.log.error(`Update failed (exit ${code}). Try ${pc14.cyan(UPDATE_COMMAND)} manually.`);
11486
+ }
11487
+ resolve(code ?? 1);
11488
+ });
11489
+ });
11490
+ }
11491
+
11228
11492
  // src/cli.ts
11229
11493
  var STARTER_CLAUDE_FLAGS = /* @__PURE__ */ new Set(["--dry-run", "--setup", "--trace", "--help", "-h", "--version", "-v"]);
11230
11494
  var GATEWAY_LAUNCH_FLAGS = /* @__PURE__ */ new Set(["--provider", "--model"]);
@@ -11549,6 +11813,55 @@ function parseArgs(args) {
11549
11813
  }
11550
11814
  return parsed2;
11551
11815
  }
11816
+ if (first === "doctor") {
11817
+ const parsed2 = emptyParsed("doctor");
11818
+ for (const arg of rest) {
11819
+ if (arg === "--help" || arg === "-h") parsed2.showHelp = true;
11820
+ else if (arg === "--version" || arg === "-v") parsed2.showVersion = true;
11821
+ else if (!parsed2.error) parsed2.error = `Unknown doctor option: ${arg}`;
11822
+ }
11823
+ return parsed2;
11824
+ }
11825
+ if (first === "completions") {
11826
+ const parsed2 = emptyParsed("completions");
11827
+ for (let i = 0; i < rest.length; i += 1) {
11828
+ const arg = rest[i];
11829
+ if (arg === "--help" || arg === "-h") {
11830
+ parsed2.showHelp = true;
11831
+ continue;
11832
+ }
11833
+ if (arg === "--version" || arg === "-v") {
11834
+ parsed2.showVersion = true;
11835
+ continue;
11836
+ }
11837
+ if (arg.startsWith("--shell=")) {
11838
+ parsed2.completionsShell = arg.slice("--shell=".length);
11839
+ continue;
11840
+ }
11841
+ if (arg === "--shell") {
11842
+ const value = rest[i + 1];
11843
+ if (!value || value.startsWith("-")) {
11844
+ parsed2.error = "Missing value for --shell";
11845
+ return parsed2;
11846
+ }
11847
+ parsed2.completionsShell = value;
11848
+ i += 1;
11849
+ continue;
11850
+ }
11851
+ if (!parsed2.error) parsed2.error = `Unknown completions option: ${arg}`;
11852
+ }
11853
+ return parsed2;
11854
+ }
11855
+ if (first === "update") {
11856
+ const parsed2 = emptyParsed("update");
11857
+ for (const arg of rest) {
11858
+ if (arg === "--help" || arg === "-h") parsed2.showHelp = true;
11859
+ else if (arg === "--version" || arg === "-v") parsed2.showVersion = true;
11860
+ else if (arg === "--dry-run") parsed2.dryRun = true;
11861
+ else if (!parsed2.error) parsed2.error = `Unknown update option: ${arg}`;
11862
+ }
11863
+ return parsed2;
11864
+ }
11552
11865
  if (first !== "claude") {
11553
11866
  return {
11554
11867
  ...emptyParsed("root"),
@@ -11581,11 +11894,11 @@ function parseArgs(args) {
11581
11894
  return parsed;
11582
11895
  }
11583
11896
  function rootHelpText() {
11584
- return `${pc12.bold("anygate")} v${VERSION}
11897
+ return `${pc15.bold("anygate")} v${VERSION}
11585
11898
  Launch AI coding tools with OpenCode Zen / Go or local providers (Groq, Mistral,
11586
11899
  OpenAI, Gemini, Ollama, and more).
11587
11900
 
11588
- ${pc12.bold("Usage:")}
11901
+ ${pc15.bold("Usage:")}
11589
11902
  anygate claude [options] [claude-flags]
11590
11903
  anygate claude-app [options]
11591
11904
  anygate codex [options] [codex-flags]
@@ -11600,20 +11913,23 @@ ${pc12.bold("Usage:")}
11600
11913
  anygate models
11601
11914
  anygate favorites
11602
11915
  anygate providers
11916
+ anygate doctor
11917
+ anygate completions <bash|zsh|fish|powershell>
11918
+ anygate update
11603
11919
  anygate --help
11604
11920
  anygate --version
11605
11921
  anygate --ai Full reference for AI agents (run this when unsure)
11606
11922
  anygate --ai --install Install or upgrade agent skill when version changed
11607
11923
  anygate --ai --install --force Reinstall skill even if already current
11608
11924
 
11609
- ${pc12.bold("Root options:")}
11925
+ ${pc15.bold("Root options:")}
11610
11926
  -h, --help Show this help
11611
11927
  -v, --version Show version
11612
11928
  --ai Print the full reference for AI agents
11613
11929
  --ai --install Install or upgrade the anygate agent skill
11614
11930
  --force Reinstall the agent skill when used with --ai --install
11615
11931
 
11616
- ${pc12.bold("Commands:")}
11932
+ ${pc15.bold("Commands:")}
11617
11933
  claude Launch Claude Code \u2014 pick a provider from your registry
11618
11934
  models Manage favorite models for mid-session /model switching (max ${MAX_MODEL_CATALOG})
11619
11935
  favorites Alias for models
@@ -11627,16 +11943,19 @@ ${pc12.bold("Commands:")}
11627
11943
  codex-app Launch ChatGPT desktop app (Codex mode) with registry providers (macOS + Windows)
11628
11944
  chatgpt Alias for codex-app
11629
11945
  claude-app Launch Claude Desktop app with registry providers (macOS + Windows)
11946
+ doctor Run an environment diagnostic (Node, keyring, key, port, env conflicts)
11947
+ completions Print a shell completion script for anygate
11948
+ update Interactively upgrade anygate to the latest published version
11630
11949
 
11631
- ${pc12.bold("Antigravity favorites:")}
11950
+ ${pc15.bold("Antigravity favorites:")}
11632
11951
  agy, antigravity, and antigravity-ide share up to six Antigravity favorites
11633
11952
  from anygate favorites --agy, plus the selected launch model.
11634
11953
 
11635
- ${pc12.bold("Upgradeion:")}
11954
+ ${pc15.bold("Upgradeion:")}
11636
11955
  Bare anygate prints this help instead of launching Claude Code.
11637
11956
  Use anygate claude for the wizard and launcher.
11638
11957
 
11639
- ${pc12.bold("Examples:")}
11958
+ ${pc15.bold("Examples:")}
11640
11959
  anygate claude
11641
11960
  anygate models
11642
11961
  anygate providers
@@ -11653,15 +11972,15 @@ ${pc12.bold("Examples:")}
11653
11972
  anygate claude -- --print "hello"`;
11654
11973
  }
11655
11974
  function claudeHelpText() {
11656
- return `${pc12.bold("anygate claude")} v${VERSION}
11975
+ return `${pc15.bold("anygate claude")} v${VERSION}
11657
11976
  Launch Claude Code with OpenCode Zen, Go, or local providers as the API backend.
11658
11977
 
11659
- ${pc12.bold("Usage:")}
11978
+ ${pc15.bold("Usage:")}
11660
11979
  anygate claude [options] [claude-flags]
11661
11980
  anygate claude --help
11662
11981
  anygate claude --version
11663
11982
 
11664
- ${pc12.bold("Options:")}
11983
+ ${pc15.bold("Options:")}
11665
11984
  --dry-run Run the wizard but show a preview instead of launching Claude Code
11666
11985
  --setup Hint: use anygate providers to add or manage providers
11667
11986
  --trace Write debug logs to ~/.anygate/logs/ and show errors on exit
@@ -11670,22 +11989,22 @@ ${pc12.bold("Options:")}
11670
11989
  --help Show this command help
11671
11990
  --version Show version
11672
11991
 
11673
- ${pc12.bold("Providers:")}
11992
+ ${pc15.bold("Providers:")}
11674
11993
  Cloud (Zen/Go) Requires OPENCODE_API_KEY \u2014 get one at https://opencode.ai/auth
11675
11994
  Registry Configure with anygate providers add or import (Groq, Mistral,
11676
11995
  Nvidia, DeepSeek, OpenAI, custom endpoints, etc.).
11677
11996
 
11678
- ${pc12.bold("Model switching:")}
11997
+ ${pc15.bold("Model switching:")}
11679
11998
  Run anygate models to save favorites (max ${MAX_MODEL_CATALOG}).
11680
11999
  When favorites exist, launch starts a multi-route proxy and Claude Code /model
11681
12000
  lists your starting model plus favorites for live switching.
11682
12001
  With no favorites, launch uses a single model as before.
11683
12002
 
11684
- ${pc12.bold("Note:")}
12003
+ ${pc15.bold("Note:")}
11685
12004
  Claude Code may save the launched model to ~/.claude/settings.json.
11686
12005
  Bare claude later can still show that model \u2014 reset with claude --model sonnet.
11687
12006
 
11688
- ${pc12.bold("Examples:")}
12007
+ ${pc15.bold("Examples:")}
11689
12008
  anygate claude
11690
12009
  anygate claude -c
11691
12010
  anygate claude --resume abc-123
@@ -11699,10 +12018,10 @@ ${pc12.bold("Examples:")}
11699
12018
  anygate claude -- --dangerously-skip-permissions`;
11700
12019
  }
11701
12020
  function serverHelpText() {
11702
- return `${pc12.bold("anygate server")} v${VERSION}
12021
+ return `${pc15.bold("anygate server")} v${VERSION}
11703
12022
  Run a foreground API gateway for registry providers, Zen/Go, or Vertex AI.
11704
12023
 
11705
- ${pc12.bold("Usage:")}
12024
+ ${pc15.bold("Usage:")}
11706
12025
  anygate server
11707
12026
  anygate server --quick
11708
12027
  anygate server --listen network --password <password>
@@ -11710,7 +12029,7 @@ ${pc12.bold("Usage:")}
11710
12029
  anygate server --help
11711
12030
  anygate server --version
11712
12031
 
11713
- ${pc12.bold("Options:")}
12032
+ ${pc15.bold("Options:")}
11714
12033
  --quick, --saved Start immediately from saved/default settings
11715
12034
  --listen local|network One-run listen mode override
11716
12035
  --providers all|favorites|id1,id2
@@ -11721,7 +12040,7 @@ ${pc12.bold("Options:")}
11721
12040
  --password <value> One-run network-mode server password
11722
12041
  --vertex Use Claude on Google Vertex AI
11723
12042
 
11724
- ${pc12.bold("Behavior:")}
12043
+ ${pc15.bold("Behavior:")}
11725
12044
  Default: interactive wizard for exposed providers, discovery id masking (for
11726
12045
  Claude Desktop / Cowork), optional favorites-only catalog, then listen mode.
11727
12046
  Quick mode skips prompts and uses saved settings. Any one-run option also
@@ -11731,129 +12050,129 @@ ${pc12.bold("Behavior:")}
11731
12050
  local gcloud Application Default Credentials (no OpenCode API key).
11732
12051
  Binds to port 17645. Network mode asks for a server password.
11733
12052
 
11734
- ${pc12.bold("Vertex env:")}
12053
+ ${pc15.bold("Vertex env:")}
11735
12054
  ANTHROPIC_VERTEX_PROJECT_ID or GOOGLE_CLOUD_PROJECT \u2014 your GCP project
11736
12055
  GOOGLE_CLOUD_LOCATION or CLOUD_ML_REGION \u2014 region (default: global)
11737
12056
  Optional catalog: ~/.anygate/vertex-models.json (see assets/vertex-models.example.json)
11738
12057
 
11739
- ${pc12.bold("Endpoints:")}
12058
+ ${pc15.bold("Endpoints:")}
11740
12059
  Anthropic-compatible: ANTHROPIC_BASE_URL=http://127.0.0.1:17645/anthropic
11741
12060
  OpenAI-compatible: OPENAI_BASE_URL=http://127.0.0.1:17645/openai/v1
11742
12061
  API key: use anything locally; use the server password in network mode.`;
11743
12062
  }
11744
12063
  function modelsHelpText() {
11745
- return `${pc12.bold("anygate favorites")} v${VERSION}
12064
+ return `${pc15.bold("anygate favorites")} v${VERSION}
11746
12065
  Manage favorite models for mid-session switching.
11747
12066
 
11748
- ${pc12.bold("Usage:")}
12067
+ ${pc15.bold("Usage:")}
11749
12068
  anygate favorites
11750
12069
  anygate favorites --agy
11751
12070
  anygate models
11752
12071
  anygate favorites --help
11753
12072
  anygate favorites --version
11754
12073
 
11755
- ${pc12.bold("Behavior:")}
12074
+ ${pc15.bold("Behavior:")}
11756
12075
  Opens an interactive manager to add or remove favorites.
11757
12076
  Search all providers at once (paginated results) or browse one provider at a time.
11758
12077
  Pick from Zen, Go, or any provider in your registry.
11759
12078
  Global favorites are saved to ~/.anygate/config.json (max ${MAX_MODEL_CATALOG}).
11760
12079
  --agy manages Antigravity CLI favorites only (max 6).
11761
12080
 
11762
- ${pc12.bold("How it works:")}
12081
+ ${pc15.bold("How it works:")}
11763
12082
  Claude/Codex/Gemini/server use the global favorites list.
11764
12083
  Favorites appear in supported /model switch menus.
11765
12084
  anygate agy, antigravity, and antigravity-ide use the Antigravity favorites
11766
12085
  list so the limited native switch slots stay predictable: one selected launch
11767
12086
  model plus up to six Antigravity favorites.
11768
12087
 
11769
- ${pc12.bold("Examples:")}
12088
+ ${pc15.bold("Examples:")}
11770
12089
  anygate favorites
11771
12090
  anygate favorites --agy
11772
12091
  anygate claude # switch menu active when favorites are set`;
11773
12092
  }
11774
12093
  function antigravityCliHelpText() {
11775
- return `${pc12.bold("anygate agy")} v${VERSION}
12094
+ return `${pc15.bold("anygate agy")} v${VERSION}
11776
12095
  Launch Antigravity CLI with anygate provider registry.
11777
12096
 
11778
- ${pc12.bold("Usage:")}
12097
+ ${pc15.bold("Usage:")}
11779
12098
  anygate agy [options] [agy-flags]
11780
12099
  anygate agy --help
11781
12100
  anygate agy --version
11782
12101
 
11783
- ${pc12.bold("Options:")}
12102
+ ${pc15.bold("Options:")}
11784
12103
  --provider <id> Use a specific provider (skip picker)
11785
12104
  --model <id> Use a specific model (skip picker)
11786
12105
  --trace Write debug log to /tmp/anygate-debug.log
11787
12106
  -h, --help Show this help
11788
12107
  -v, --version Show version
11789
12108
 
11790
- ${pc12.bold("How it works:")}
12109
+ ${pc15.bold("How it works:")}
11791
12110
  Starts a local Cloud Code gateway, points agy at it via CLOUD_CODE_URL,
11792
12111
  and injects anygate models into Antigravity's native model picker.
11793
12112
  All Cloud Code traffic routes through anygate \u2014 no Google Cloud Code upstream.
11794
12113
 
11795
- ${pc12.bold("Examples:")}
12114
+ ${pc15.bold("Examples:")}
11796
12115
  anygate agy
11797
12116
  anygate agy --provider zen --model deepseek-v4-flash-free
11798
12117
  anygate agy -p "fix this bug"`;
11799
12118
  }
11800
12119
  function antigravityIdeHelpText() {
11801
- return `${pc12.bold("anygate antigravity-ide")} v${VERSION}
12120
+ return `${pc15.bold("anygate antigravity-ide")} v${VERSION}
11802
12121
  Launch Antigravity IDE with anygate provider registry.
11803
12122
 
11804
- ${pc12.bold("Usage:")}
12123
+ ${pc15.bold("Usage:")}
11805
12124
  anygate antigravity-ide [options]
11806
12125
  anygate antigravity-ide --help
11807
12126
  anygate antigravity-ide --version
11808
12127
 
11809
- ${pc12.bold("Options:")}
12128
+ ${pc15.bold("Options:")}
11810
12129
  --provider <id> Use a specific provider (skip picker)
11811
12130
  --model <id> Use a specific model (skip picker)
11812
12131
  --trace Write debug log to /tmp/anygate-debug.log
11813
12132
  -h, --help Show this help
11814
12133
  -v, --version Show version
11815
12134
 
11816
- ${pc12.bold("How it works:")}
12135
+ ${pc15.bold("How it works:")}
11817
12136
  Creates an isolated anygate-managed IDE profile, starts a local Cloud Code
11818
12137
  gateway, and injects anygate models into Antigravity's native picker.
11819
12138
  The normal IDE profile is never modified.
11820
12139
 
11821
- ${pc12.bold("Platform:")}
12140
+ ${pc15.bold("Platform:")}
11822
12141
  macOS (Apple Silicon) \u2014 other platforms coming after testing.
11823
12142
 
11824
- ${pc12.bold("Examples:")}
12143
+ ${pc15.bold("Examples:")}
11825
12144
  anygate antigravity-ide
11826
12145
  anygate antigravity-ide --provider zen --model deepseek-v4-flash-free`;
11827
12146
  }
11828
12147
  function antigravityAppHelpText() {
11829
- return `${pc12.bold("anygate antigravity")} v${VERSION}
12148
+ return `${pc15.bold("anygate antigravity")} v${VERSION}
11830
12149
  Launch Antigravity with anygate provider registry.
11831
12150
 
11832
- ${pc12.bold("Usage:")}
12151
+ ${pc15.bold("Usage:")}
11833
12152
  anygate antigravity [options]
11834
12153
  anygate antigravity --help
11835
12154
  anygate antigravity --version
11836
12155
 
11837
- ${pc12.bold("Options:")}
12156
+ ${pc15.bold("Options:")}
11838
12157
  --provider <id> Use a specific provider (skip picker)
11839
12158
  --model <id> Use a specific model (skip picker)
11840
12159
  --trace Write debug log to /tmp/anygate-debug.log
11841
12160
  -h, --help Show this help
11842
12161
  -v, --version Show version
11843
12162
 
11844
- ${pc12.bold("How it works:")}
12163
+ ${pc15.bold("How it works:")}
11845
12164
  Creates an isolated anygate-managed Antigravity profile, starts a local Cloud
11846
12165
  Code gateway, and injects anygate models into Antigravity's native picker.
11847
12166
  The normal Antigravity profile is never modified.
11848
12167
 
11849
- ${pc12.bold("Favorites:")}
12168
+ ${pc15.bold("Favorites:")}
11850
12169
  Uses the same Antigravity favorites list as anygate favorites --agy:
11851
12170
  up to six saved favorites plus the selected launch model.
11852
12171
 
11853
- ${pc12.bold("Platform:")}
12172
+ ${pc15.bold("Platform:")}
11854
12173
  macOS (Apple Silicon) \u2014 other platforms coming after testing.
11855
12174
 
11856
- ${pc12.bold("Examples:")}
12175
+ ${pc15.bold("Examples:")}
11857
12176
  anygate antigravity
11858
12177
  anygate antigravity --provider zen --model deepseek-v4-flash-free`;
11859
12178
  }
@@ -11866,11 +12185,11 @@ async function launchClaudeViaCatalog(catalogRoutes, startingRoute, contextWindo
11866
12185
  let proxyHandle;
11867
12186
  try {
11868
12187
  proxyHandle = await startProxyCatalog(catalogRoutes, startingRoute.aliasId, trace);
11869
- p14.log.info(
11870
- `Switch menu active \u2014 proxy on port ${proxyHandle.port} ` + pc12.dim(`(${catalogRoutes.length} model${catalogRoutes.length !== 1 ? "s" : ""} in /model)`)
12188
+ p15.log.info(
12189
+ `Switch menu active \u2014 proxy on port ${proxyHandle.port} ` + pc15.dim(`(${catalogRoutes.length} model${catalogRoutes.length !== 1 ? "s" : ""} in /model)`)
11871
12190
  );
11872
12191
  } catch (err) {
11873
- p14.log.error(`Failed to start proxy: ${err instanceof Error ? err.message : String(err)}`);
12192
+ p15.log.error(`Failed to start proxy: ${err instanceof Error ? err.message : String(err)}`);
11874
12193
  return 1;
11875
12194
  }
11876
12195
  const childEnv = buildChildEnv(
@@ -11883,7 +12202,7 @@ async function launchClaudeViaCatalog(catalogRoutes, startingRoute, contextWindo
11883
12202
  );
11884
12203
  const debugLogPath = prepareClaudeTraceLog();
11885
12204
  const traceArgs = trace ? ["--debug-file", debugLogPath] : [];
11886
- if (trace) p14.log.info(`Debug log: ${debugLogPath}`);
12205
+ if (trace) p15.log.info(`Debug log: ${debugLogPath}`);
11887
12206
  const exitCode = await launchClaude(
11888
12207
  childEnv,
11889
12208
  claudeCodeClientModelId(startingRoute.aliasId, contextWindow),
@@ -11900,7 +12219,7 @@ async function runModelsCommand(opts = {}) {
11900
12219
  const scopeName = scope === "agy" ? "Antigravity CLI Favorites" : "Favorite Models";
11901
12220
  const configKey = scope === "agy" ? "antigravityCliFavoriteModels" : "favoriteModels";
11902
12221
  gateIntro(scopeName);
11903
- const spinner9 = p14.spinner();
12222
+ const spinner9 = p15.spinner();
11904
12223
  spinner9.start("Loading providers...");
11905
12224
  const catalog = await fetchProviderCatalog();
11906
12225
  spinner9.stop("");
@@ -11910,8 +12229,8 @@ async function runModelsCommand(opts = {}) {
11910
12229
  name: favoriteProviderDisplayName(provider)
11911
12230
  }));
11912
12231
  if (favoriteProviders.length === 0) {
11913
- p14.log.warn("No providers found.");
11914
- p14.log.info(`${pc12.dim("OpenCode Zen/Go is always available. Add providers with ")}${pc12.cyan("anygate providers")}${pc12.dim(".")}`);
12232
+ p15.log.warn("No providers found.");
12233
+ p15.log.info(`${pc15.dim("OpenCode Zen/Go is always available. Add providers with ")}${pc15.cyan("anygate providers")}${pc15.dim(".")}`);
11915
12234
  gateOutro("Done");
11916
12235
  return 0;
11917
12236
  }
@@ -11929,50 +12248,50 @@ async function runModelsCommand(opts = {}) {
11929
12248
  for (let i = 0; i < favorites.length; i++) {
11930
12249
  const fav = favorites[i];
11931
12250
  const entry = modelLookup.get(`${fav.providerId}:${fav.modelId}`);
11932
- const label = entry ? `${fmtEnabledStar(true)} ${fmtModel(entry.modelName)} ${pc12.dim(`(${entry.providerName})`)}` : pc12.dim(`\u2605 ${fav.modelId} \u2014 provider gone`);
12251
+ const label = entry ? `${fmtEnabledStar(true)} ${fmtModel(entry.modelName)} ${pc15.dim(`(${entry.providerName})`)}` : pc15.dim(`\u2605 ${fav.modelId} \u2014 provider gone`);
11933
12252
  options.push({ value: `fav-${i}`, label, hint: "select to remove" });
11934
12253
  }
11935
12254
  const atCap = favorites.length >= maxFavorites;
11936
12255
  options.push({
11937
12256
  value: "__add__",
11938
- label: atCap ? pc12.dim(`+ Add a model \u2192 (limit of ${maxFavorites} reached)`) : pc12.cyan("+ Add a model \u2192"),
12257
+ label: atCap ? pc15.dim(`+ Add a model \u2192 (limit of ${maxFavorites} reached)`) : pc15.cyan("+ Add a model \u2192"),
11939
12258
  hint: atCap ? "Remove a favorite first to make room" : `${allProviders.length} provider${allProviders.length !== 1 ? "s" : ""} available`
11940
12259
  });
11941
12260
  options.push({ value: "__done__", label: "Done", hint: "" });
11942
12261
  const header = favorites.length === 0 ? `${scopeName} (0/${maxFavorites})` : `${scopeName} (${favorites.length}/${maxFavorites}) \u2014 select to remove`;
11943
- const choice = await p14.select({
12262
+ const choice = await p15.select({
11944
12263
  message: header,
11945
12264
  options,
11946
12265
  initialValue: "__done__"
11947
12266
  });
11948
- if (p14.isCancel(choice) || choice === "__done__") break;
12267
+ if (p15.isCancel(choice) || choice === "__done__") break;
11949
12268
  if (choice === "__add__") {
11950
12269
  if (atCap) {
11951
- p14.log.warn(`Limit of ${maxFavorites} favorites reached \u2014 remove one first.`);
12270
+ p15.log.warn(`Limit of ${maxFavorites} favorites reached \u2014 remove one first.`);
11952
12271
  continue;
11953
12272
  }
11954
12273
  const globalCount = buildGlobalFavoriteIndex(favoriteProviders).length;
11955
- const addPath = await p14.select({
12274
+ const addPath = await p15.select({
11956
12275
  message: "Add a favorite",
11957
12276
  options: [
11958
12277
  {
11959
12278
  value: "global",
11960
- label: pc12.cyan("Search all providers"),
12279
+ label: pc15.cyan("Search all providers"),
11961
12280
  hint: `${globalCount} models \xB7 ${favoriteProviders.length} provider${favoriteProviders.length !== 1 ? "s" : ""}`
11962
12281
  },
11963
12282
  {
11964
12283
  value: "free",
11965
- label: pc12.cyan("Search free models"),
12284
+ label: pc15.cyan("Search free models"),
11966
12285
  hint: `${buildGlobalFavoriteIndex(favoriteProviders).filter((e) => e.model.isFree || e.model.freeStatus === "verified_free" || e.model.freeStatus === "free_provider").length} free/free-access models`
11967
12286
  },
11968
12287
  {
11969
12288
  value: "provider",
11970
- label: pc12.cyan("Browse by provider \u2192"),
12289
+ label: pc15.cyan("Browse by provider \u2192"),
11971
12290
  hint: "Pick one provider first"
11972
12291
  }
11973
12292
  ]
11974
12293
  });
11975
- if (p14.isCancel(addPath)) continue;
12294
+ if (p15.isCancel(addPath)) continue;
11976
12295
  let provider;
11977
12296
  let browsedMultiple = [];
11978
12297
  if (addPath === "global") {
@@ -11995,12 +12314,12 @@ async function runModelsCommand(opts = {}) {
11995
12314
  let currentInitialProvider = void 0;
11996
12315
  while (true) {
11997
12316
  const providerOptions = favoriteProviders.map((ap) => providerSelectOption(ap));
11998
- const pickedProviderId = await p14.select({
12317
+ const pickedProviderId = await p15.select({
11999
12318
  message: "Which provider?",
12000
12319
  options: providerOptions,
12001
12320
  initialValue: currentInitialProvider
12002
12321
  });
12003
- if (p14.isCancel(pickedProviderId)) break;
12322
+ if (p15.isCancel(pickedProviderId)) break;
12004
12323
  provider = favoriteProviders.find((ap) => ap.id === pickedProviderId);
12005
12324
  const options2 = provider.models.map((m) => {
12006
12325
  const favorited = isFavorite(favorites, { providerId: provider.id, modelId: m.id });
@@ -12008,15 +12327,15 @@ async function runModelsCommand(opts = {}) {
12008
12327
  return {
12009
12328
  value: m.id,
12010
12329
  label: fmtModel(label, m.id),
12011
- hint: favorited ? pc12.yellow("\u2605 already favorite") : ""
12330
+ hint: favorited ? pc15.yellow("\u2605 already favorite") : ""
12012
12331
  };
12013
12332
  });
12014
- const pickedModelIds = await p14.multiselect({
12015
- message: `Select models to add from ${provider.name} ${pc12.dim("(Space to select, Enter to confirm)")}`,
12333
+ const pickedModelIds = await p15.multiselect({
12334
+ message: `Select models to add from ${provider.name} ${pc15.dim("(Space to select, Enter to confirm)")}`,
12016
12335
  options: options2,
12017
12336
  required: false
12018
12337
  });
12019
- if (p14.isCancel(pickedModelIds)) {
12338
+ if (p15.isCancel(pickedModelIds)) {
12020
12339
  currentInitialProvider = provider.id;
12021
12340
  continue;
12022
12341
  }
@@ -12051,27 +12370,27 @@ async function runModelsCommand(opts = {}) {
12051
12370
  if (addedModels.length > 0) {
12052
12371
  if (addedModels.length === 1) {
12053
12372
  const modelName = addedModels[0].name || addedModels[0].id;
12054
- p14.log.success(`Added ${modelName} (${provider.name}) to favorites.`);
12373
+ p15.log.success(`Added ${modelName} (${provider.name}) to favorites.`);
12055
12374
  } else {
12056
- p14.log.success(`Added ${addedModels.length} models from ${provider.name} to favorites.`);
12375
+ p15.log.success(`Added ${addedModels.length} models from ${provider.name} to favorites.`);
12057
12376
  }
12058
12377
  }
12059
12378
  if (duplicateCount > 0) {
12060
- p14.log.warn(`${duplicateCount} selected model(s) were already in your favorites.`);
12379
+ p15.log.warn(`${duplicateCount} selected model(s) were already in your favorites.`);
12061
12380
  }
12062
12381
  if (limitReached) {
12063
- p14.log.warn(`Limit of ${maxFavorites} favorites reached \u2014 some selected models could not be added.`);
12382
+ p15.log.warn(`Limit of ${maxFavorites} favorites reached \u2014 some selected models could not be added.`);
12064
12383
  }
12065
12384
  } else if (choice.startsWith("fav-")) {
12066
12385
  const idx = parseInt(choice.slice(4), 10);
12067
12386
  const fav = favorites[idx];
12068
12387
  const entry = modelLookup.get(`${fav.providerId}:${fav.modelId}`);
12069
12388
  const label = entry ? `${entry.modelName} (${entry.providerName})` : fav.modelId;
12070
- const confirmed = await p14.confirm({ message: `Remove ${label} from favorites?` });
12071
- if (p14.isCancel(confirmed) || !confirmed) continue;
12389
+ const confirmed = await p15.confirm({ message: `Remove ${label} from favorites?` });
12390
+ if (p15.isCancel(confirmed) || !confirmed) continue;
12072
12391
  favorites = removeFavorite(favorites, fav);
12073
12392
  favoritesDirty = true;
12074
- p14.log.success(`Removed ${label} from favorites.`);
12393
+ p15.log.success(`Removed ${label} from favorites.`);
12075
12394
  }
12076
12395
  }
12077
12396
  if (favoritesDirty) {
@@ -12080,7 +12399,7 @@ async function runModelsCommand(opts = {}) {
12080
12399
  const favLabel = scope === "agy" ? "Antigravity CLI " : "";
12081
12400
  gateOutro(
12082
12401
  favorites.length === 0 ? `No ${favLabel}favorites saved` : `${favorites.length} ${favLabel}favorite${favorites.length !== 1 ? "s" : ""} saved`,
12083
- favorites.length === 0 ? pc12.dim("Launch uses single-model mode") : pc12.cyan("/model menu ready on next launch")
12402
+ favorites.length === 0 ? pc15.dim("Launch uses single-model mode") : pc15.cyan("/model menu ready on next launch")
12084
12403
  );
12085
12404
  return 0;
12086
12405
  }
@@ -12091,7 +12410,7 @@ async function runClaudeCommand(parsed) {
12091
12410
  setAgentStdoutMode(agentStdout);
12092
12411
  const claudePath = findClaudeBinary();
12093
12412
  if (!claudePath) {
12094
- console.error(pc12.red("\nError: claude binary not found on PATH.\n"));
12413
+ console.error(pc15.red("\nError: claude binary not found on PATH.\n"));
12095
12414
  console.error("Install Claude Code:");
12096
12415
  console.error(" npm install -g @anthropic-ai/claude-code\n");
12097
12416
  return 1;
@@ -12106,7 +12425,7 @@ async function runClaudeCommand(parsed) {
12106
12425
  prefs
12107
12426
  });
12108
12427
  if (launchPlan.error) {
12109
- console.error(pc12.red(`
12428
+ console.error(pc15.red(`
12110
12429
  Error: ${launchPlan.error}
12111
12430
  `));
12112
12431
  return 1;
@@ -12114,7 +12433,7 @@ Error: ${launchPlan.error}
12114
12433
  const switchMenuActive = favorites.length > 0 && !launchPlan.skip;
12115
12434
  if (!agentStdout) gateIntro("Claude Code");
12116
12435
  if (setup && !dryRun && !agentStdout) {
12117
- p14.log.info("Provider setup now lives in anygate providers \u2014 opening that next is recommended.");
12436
+ p15.log.info("Provider setup now lives in anygate providers \u2014 opening that next is recommended.");
12118
12437
  }
12119
12438
  if (!dryRun && await needsFirstRunSetup()) {
12120
12439
  const firstRun = await runFirstRunWizard(trace);
@@ -12125,25 +12444,25 @@ Error: ${launchPlan.error}
12125
12444
  try {
12126
12445
  catalog = await fetchProviderCatalog();
12127
12446
  } catch (err) {
12128
- console.error(pc12.red(String(err instanceof Error ? err.message : err)));
12447
+ console.error(pc15.red(String(err instanceof Error ? err.message : err)));
12129
12448
  return 1;
12130
12449
  }
12131
12450
  } else {
12132
- const catalogSpinner = p14.spinner();
12451
+ const catalogSpinner = p15.spinner();
12133
12452
  catalogSpinner.start("Loading your providers...");
12134
12453
  try {
12135
12454
  catalog = await fetchProviderCatalog();
12136
12455
  } catch (err) {
12137
12456
  catalogSpinner.stop("");
12138
- console.error(pc12.red(String(err instanceof Error ? err.message : err)));
12457
+ console.error(pc15.red(String(err instanceof Error ? err.message : err)));
12139
12458
  return 1;
12140
12459
  }
12141
12460
  catalogSpinner.stop("");
12142
12461
  }
12143
12462
  const allProviders = providersForTarget(providersForPicker(catalog), "claude");
12144
12463
  if (allProviders.length === 0) {
12145
- p14.log.warn("No providers available.");
12146
- p14.log.info(pc12.dim("Run anygate providers add or import to get started."));
12464
+ p15.log.warn("No providers available.");
12465
+ p15.log.info(pc15.dim("Run anygate providers add or import to get started."));
12147
12466
  return 0;
12148
12467
  }
12149
12468
  const providerOptions = allProviders.map((lp) => providerSelectOption(lp));
@@ -12160,7 +12479,7 @@ Error: ${launchPlan.error}
12160
12479
  if (launchPlan.skip && launchPlan.target) {
12161
12480
  const resolved = findProviderAndModel(allProviders, launchPlan.target);
12162
12481
  if (!resolved) {
12163
- p14.log.error(
12482
+ p15.log.error(
12164
12483
  `Provider/model not found: ${launchPlan.target.providerId} / ${launchPlan.target.modelId}`
12165
12484
  );
12166
12485
  return 1;
@@ -12168,19 +12487,19 @@ Error: ${launchPlan.error}
12168
12487
  activeProvider = resolved.provider;
12169
12488
  selectedModel = resolved.model;
12170
12489
  if (!agentStdout) {
12171
- p14.log.step(`Using ${selectedModel.name || selectedModel.id} (${activeProvider.name})`);
12490
+ p15.log.step(`Using ${selectedModel.name || selectedModel.id} (${activeProvider.name})`);
12172
12491
  }
12173
12492
  if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
12174
12493
  } else {
12175
12494
  let currentInitialProvider = initialProvider;
12176
12495
  while (true) {
12177
- const chosen = await p14.select({
12496
+ const chosen = await p15.select({
12178
12497
  message: "Which provider?",
12179
12498
  options: providerOptions,
12180
12499
  initialValue: currentInitialProvider
12181
12500
  });
12182
- if (p14.isCancel(chosen)) {
12183
- p14.cancel("Cancelled.");
12501
+ if (p15.isCancel(chosen)) {
12502
+ p15.cancel("Cancelled.");
12184
12503
  return 0;
12185
12504
  }
12186
12505
  const providerChoice = chosen;
@@ -12192,7 +12511,7 @@ Error: ${launchPlan.error}
12192
12511
  if (prov && mod) available.push({ provider: prov, model: mod });
12193
12512
  }
12194
12513
  if (available.length === 0) {
12195
- p14.log.warn("No saved favorites are currently available.");
12514
+ p15.log.warn("No saved favorites are currently available.");
12196
12515
  return 0;
12197
12516
  }
12198
12517
  const favOptions = available.map((f, i) => ({
@@ -12200,13 +12519,13 @@ Error: ${launchPlan.error}
12200
12519
  label: `${f.model.name || f.model.id} \u2014 ${f.provider.name}`,
12201
12520
  hint: f.model.id
12202
12521
  }));
12203
- const pickedIdx = await p14.select({
12522
+ const pickedIdx = await p15.select({
12204
12523
  message: "Starting model?",
12205
12524
  options: favOptions,
12206
12525
  initialValue: "0"
12207
12526
  });
12208
- if (p14.isCancel(pickedIdx)) {
12209
- p14.cancel("Cancelled.");
12527
+ if (p15.isCancel(pickedIdx)) {
12528
+ p15.cancel("Cancelled.");
12210
12529
  return 0;
12211
12530
  }
12212
12531
  const sel = available[Number(pickedIdx)];
@@ -12235,27 +12554,27 @@ Error: ${launchPlan.error}
12235
12554
  );
12236
12555
  const startingRoute = resolveRoute(activeProvider.id, selectedModel.id) ?? null;
12237
12556
  if (!startingRoute) {
12238
- p14.log.error("Could not resolve a proxy route for the selected model.");
12557
+ p15.log.error("Could not resolve a proxy route for the selected model.");
12239
12558
  return 1;
12240
12559
  }
12241
12560
  const { routes: catalogRoutes, droppedFavorites } = buildCatalogRoutes(startingRoute, favorites, resolveRoute);
12242
12561
  if (droppedFavorites.length > 0) {
12243
- p14.log.warn(
12562
+ p15.log.warn(
12244
12563
  `Skipping ${droppedFavorites.length} favorite${droppedFavorites.length === 1 ? "" : "s"} that are no longer available in /model`
12245
12564
  );
12246
12565
  }
12247
12566
  if (dryRun) {
12248
12567
  const endpoint = selectedModel.baseUrl ?? selectedModel.completionsUrl ?? "(unknown)";
12249
12568
  console.log("");
12250
- console.log(pc12.bold(pc12.cyan(" DRY RUN \u2014 would execute (switch-menu mode):")));
12569
+ console.log(pc15.bold(pc15.cyan(" DRY RUN \u2014 would execute (switch-menu mode):")));
12251
12570
  console.log("");
12252
- console.log(` ${pc12.bold("Provider:")} ${activeProvider.name}`);
12253
- console.log(` ${pc12.bold("Starting model:")} ${selectedModel.id}`);
12254
- console.log(` ${pc12.bold("Endpoint:")} ${endpoint}`);
12255
- console.log(` ${pc12.bold("/model catalog:")} ${catalogRoutes.length} model(s)`);
12256
- catalogRoutes.forEach((r) => console.log(` ${pc12.dim(r.displayName)}`));
12571
+ console.log(` ${pc15.bold("Provider:")} ${activeProvider.name}`);
12572
+ console.log(` ${pc15.bold("Starting model:")} ${selectedModel.id}`);
12573
+ console.log(` ${pc15.bold("Endpoint:")} ${endpoint}`);
12574
+ console.log(` ${pc15.bold("/model catalog:")} ${catalogRoutes.length} model(s)`);
12575
+ catalogRoutes.forEach((r) => console.log(` ${pc15.dim(r.displayName)}`));
12257
12576
  console.log("");
12258
- console.log(pc12.dim(" (dry run complete \u2014 Claude Code was NOT launched)"));
12577
+ console.log(pc15.dim(" (dry run complete \u2014 Claude Code was NOT launched)"));
12259
12578
  console.log("");
12260
12579
  return 0;
12261
12580
  }
@@ -12271,21 +12590,21 @@ Error: ${launchPlan.error}
12271
12590
  const formatDesc = selectedModel.modelFormat === "anthropic" ? "direct passthrough" : "via SDK adapter proxy";
12272
12591
  const endpoint = selectedModel.modelFormat === "anthropic" ? selectedModel.baseUrl ?? "(unknown)" : selectedModel.npm ?? "SDK";
12273
12592
  console.log("");
12274
- console.log(pc12.bold(pc12.cyan(" DRY RUN \u2014 would execute:")));
12593
+ console.log(pc15.bold(pc15.cyan(" DRY RUN \u2014 would execute:")));
12275
12594
  console.log("");
12276
- console.log(` ${pc12.bold("Provider:")} ${activeProvider.name}`);
12277
- console.log(` ${pc12.bold("Model:")} ${selectedModel.id}`);
12278
- console.log(` ${pc12.bold("Format:")} ${selectedModel.modelFormat} (${formatDesc})`);
12279
- console.log(` ${pc12.bold(selectedModel.modelFormat === "anthropic" ? "Endpoint:" : "SDK npm:")} ${endpoint}`);
12280
- console.log(` ${pc12.bold("Key:")} ${activeProvider.name} provider key`);
12595
+ console.log(` ${pc15.bold("Provider:")} ${activeProvider.name}`);
12596
+ console.log(` ${pc15.bold("Model:")} ${selectedModel.id}`);
12597
+ console.log(` ${pc15.bold("Format:")} ${selectedModel.modelFormat} (${formatDesc})`);
12598
+ console.log(` ${pc15.bold(selectedModel.modelFormat === "anthropic" ? "Endpoint:" : "SDK npm:")} ${endpoint}`);
12599
+ console.log(` ${pc15.bold("Key:")} ${activeProvider.name} provider key`);
12281
12600
  console.log("");
12282
- console.log(pc12.dim(" (dry run complete \u2014 Claude Code was NOT launched)"));
12601
+ console.log(pc15.dim(" (dry run complete \u2014 Claude Code was NOT launched)"));
12283
12602
  console.log("");
12284
12603
  return 0;
12285
12604
  }
12286
12605
  const launchApiKey = await resolveLocalProviderApiKey(activeProvider);
12287
12606
  if (!launchApiKey?.trim()) {
12288
- p14.log.error(
12607
+ p15.log.error(
12289
12608
  `No credential found for ${activeProvider.name}. Add a key with anygate providers or set OPENCODE_API_KEY.`
12290
12609
  );
12291
12610
  return 1;
@@ -12309,9 +12628,9 @@ Error: ${launchPlan.error}
12309
12628
  },
12310
12629
  launchApiKey
12311
12630
  );
12312
- if (!isAgentStdoutMode()) p14.log.info(`Cloud Code proxy started on port ${proxyHandle.port}`);
12631
+ if (!isAgentStdoutMode()) p15.log.info(`Cloud Code proxy started on port ${proxyHandle.port}`);
12313
12632
  } catch (err) {
12314
- p14.log.error(`Failed to start Cloud Code proxy: ${err instanceof Error ? err.message : String(err)}`);
12633
+ p15.log.error(`Failed to start Cloud Code proxy: ${err instanceof Error ? err.message : String(err)}`);
12315
12634
  return 1;
12316
12635
  }
12317
12636
  childEnv = buildChildEnv(
@@ -12337,9 +12656,9 @@ Error: ${launchPlan.error}
12337
12656
  },
12338
12657
  launchApiKey
12339
12658
  );
12340
- if (!isAgentStdoutMode()) p14.log.info(`OAuth proxy started on port ${proxyHandle.port}`);
12659
+ if (!isAgentStdoutMode()) p15.log.info(`OAuth proxy started on port ${proxyHandle.port}`);
12341
12660
  } catch (err) {
12342
- p14.log.error(`Failed to start OAuth proxy: ${err instanceof Error ? err.message : String(err)}`);
12661
+ p15.log.error(`Failed to start OAuth proxy: ${err instanceof Error ? err.message : String(err)}`);
12343
12662
  return 1;
12344
12663
  }
12345
12664
  childEnv = buildChildEnv(
@@ -12380,12 +12699,12 @@ Error: ${launchPlan.error}
12380
12699
  launchApiKey
12381
12700
  );
12382
12701
  if (!isAgentStdoutMode()) {
12383
- p14.log.info(
12384
- `SDK adapter proxy started on port ${proxyHandle.port}` + (selectedModel.npm ? pc12.dim(` (${selectedModel.npm})`) : "")
12702
+ p15.log.info(
12703
+ `SDK adapter proxy started on port ${proxyHandle.port}` + (selectedModel.npm ? pc15.dim(` (${selectedModel.npm})`) : "")
12385
12704
  );
12386
12705
  }
12387
12706
  } catch (err) {
12388
- p14.log.error(`Failed to start SDK adapter proxy: ${err instanceof Error ? err.message : String(err)}`);
12707
+ p15.log.error(`Failed to start SDK adapter proxy: ${err instanceof Error ? err.message : String(err)}`);
12389
12708
  return 1;
12390
12709
  }
12391
12710
  childEnv = buildChildEnv(
@@ -12401,7 +12720,7 @@ Error: ${launchPlan.error}
12401
12720
  }
12402
12721
  const debugLogPath = prepareClaudeTraceLog();
12403
12722
  const traceArgs = trace ? ["--debug-file", debugLogPath] : [];
12404
- if (trace) p14.log.info(`Debug log: ${debugLogPath}`);
12723
+ if (trace) p15.log.info(`Debug log: ${debugLogPath}`);
12405
12724
  const exitCode = await launchClaude(
12406
12725
  childEnv,
12407
12726
  claudeCodeClientModelId(selectedModel.id, selectedModel.contextWindow),
@@ -12425,7 +12744,7 @@ ${formatUpdateNotification(update.currentVersion, update.latestVersion)}
12425
12744
  else console.error(notice);
12426
12745
  }
12427
12746
  if (parsed.error) {
12428
- console.error(pc12.red(`
12747
+ console.error(pc15.red(`
12429
12748
  Error: ${parsed.error}
12430
12749
  `));
12431
12750
  printHelp(rootHelpText());
@@ -12478,7 +12797,7 @@ Error: ${parsed.error}
12478
12797
  console.log("Usage: anygate ui [--trace]\n\nOpen the settings UI in your browser.");
12479
12798
  return 0;
12480
12799
  }
12481
- const { runUiCommand } = await import("./command-OQI56XYG.js");
12800
+ const { runUiCommand } = await import("./command-M5GMEJCO.js");
12482
12801
  return runUiCommand({ trace: parsed.trace });
12483
12802
  }
12484
12803
  if (parsed.command === "models") {
@@ -12591,6 +12910,39 @@ Error: ${parsed.error}
12591
12910
  launchModel: parsed.launchModel
12592
12911
  });
12593
12912
  }
12913
+ if (parsed.command === "doctor") {
12914
+ if (parsed.showVersion) {
12915
+ console.log(VERSION);
12916
+ return 0;
12917
+ }
12918
+ if (parsed.showHelp) {
12919
+ console.log("Usage: anygate doctor [--help] [--version]\n\nRun an environment diagnostic (Node, keyring, API key, port, env conflicts).");
12920
+ return 0;
12921
+ }
12922
+ return runDoctorCommand(parsed.dryRun);
12923
+ }
12924
+ if (parsed.command === "completions") {
12925
+ if (parsed.showVersion) {
12926
+ console.log(VERSION);
12927
+ return 0;
12928
+ }
12929
+ if (parsed.showHelp) {
12930
+ console.log("Usage: anygate completions [bash|zsh|fish|powershell] [--shell <shell>]\n\nPrint a shell completion script for anygate to stdout.");
12931
+ return 0;
12932
+ }
12933
+ return runCompletionsCommand(parsed.completionsShell);
12934
+ }
12935
+ if (parsed.command === "update") {
12936
+ if (parsed.showVersion) {
12937
+ console.log(VERSION);
12938
+ return 0;
12939
+ }
12940
+ if (parsed.showHelp) {
12941
+ console.log("Usage: anygate update [--dry-run] [--help] [--version]\n\nInteractively upgrade anygate to the latest published version.");
12942
+ return 0;
12943
+ }
12944
+ return runUpdateCommand(parsed.dryRun);
12945
+ }
12594
12946
  if (parsed.showVersion) {
12595
12947
  console.log(VERSION);
12596
12948
  return 0;
@@ -12616,7 +12968,7 @@ if (isCliEntryPoint()) {
12616
12968
  if (err === /* @__PURE__ */ Symbol.for("clack:cancel")) {
12617
12969
  process.exit(0);
12618
12970
  }
12619
- console.error(pc12.red("\nUnexpected error:"), err);
12971
+ console.error(pc15.red("\nUnexpected error:"), err);
12620
12972
  process.exit(1);
12621
12973
  });
12622
12974
  }