anygate 0.6.0 → 0.6.1

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
@@ -19,6 +19,7 @@ import {
19
19
  buildClaudeCodeBillingSystemLine,
20
20
  buildCodexAppRootConfig,
21
21
  buildImportProviderList,
22
+ buildProviderAllModelRoutes,
22
23
  buildVertexRuntimeConfig,
23
24
  cachedModelToLocal,
24
25
  catalogEntryFromModel,
@@ -171,7 +172,7 @@ import {
171
172
  validateModels,
172
173
  writeSecureLogLine,
173
174
  zenRegistryStub
174
- } from "./chunk-CRK6YGKY.js";
175
+ } from "./chunk-BY4AKT2X.js";
175
176
  import {
176
177
  BACKENDS,
177
178
  CONFLICTING_ENV_VARS,
@@ -179,14 +180,14 @@ import {
179
180
  MAX_MODEL_CATALOG,
180
181
  VERSION,
181
182
  VERTEX_ANTHROPIC_NPM
182
- } from "./chunk-QLHVQYQN.js";
183
+ } from "./chunk-UE2I2ETX.js";
183
184
  import {
184
185
  filterTemplates,
185
186
  getTemplateById,
186
187
  listAddableTemplates,
187
188
  listSupportedTemplates,
188
189
  listVisibleOAuthTemplates
189
- } from "./chunk-VGM6EBG4.js";
190
+ } from "./chunk-4N4RDHGZ.js";
190
191
  import "./chunk-UT3JLF3M.js";
191
192
 
192
193
  // src/cli.ts
@@ -2030,6 +2031,10 @@ function resolveLaunchTarget(explicit, prefs, agent) {
2030
2031
  const slug = explicit.modelId ? parseModelSlug(explicit.modelId) : null;
2031
2032
  const providerId = explicit.providerId ?? slug?.providerId ?? (agent === "claude" ? prefs.lastProvider : agent === "codex" ? prefs.lastCodexProvider : agent === "antigravity" ? prefs.lastAntigravityProvider : prefs.lastGeminiProvider);
2032
2033
  const modelId = slug?.modelId ?? explicit.modelId ?? (agent === "claude" ? prefs.lastModel : agent === "codex" ? prefs.lastCodexModel : agent === "antigravity" ? prefs.lastAntigravityModel : prefs.lastGeminiModel);
2034
+ if (explicit.allModels) {
2035
+ if (!providerId) return null;
2036
+ return { providerId, allModels: true };
2037
+ }
2033
2038
  if (!providerId || !modelId) return null;
2034
2039
  return { providerId, modelId };
2035
2040
  }
@@ -2042,6 +2047,7 @@ function findProviderAndModel(providers, target) {
2042
2047
  return { provider, model };
2043
2048
  }
2044
2049
  function hasCompleteExplicitLaunch(explicit) {
2050
+ if (explicit.allModels && explicit.providerId) return true;
2045
2051
  if (explicit.providerId && explicit.modelId) return true;
2046
2052
  if (explicit.modelId) {
2047
2053
  const slug = parseModelSlug(explicit.modelId);
@@ -2059,16 +2065,16 @@ function planLaunchWizard(opts) {
2059
2065
  return {
2060
2066
  skip: false,
2061
2067
  target: null,
2062
- error: "Both --provider and --model are required (or use provider__model slug with --model)."
2068
+ error: "A provider is required \u2014 use --provider, --all-models, or a saved preference."
2063
2069
  };
2064
2070
  }
2065
2071
  return { skip: true, target };
2066
2072
  }
2067
- if (explicit.providerId || explicit.modelId) {
2073
+ if (explicit.providerId || explicit.modelId || explicit.allModels) {
2068
2074
  return {
2069
2075
  skip: false,
2070
2076
  target: null,
2071
- error: "Both --provider and --model are required (or use provider__model slug with --model)."
2077
+ error: explicit.allModels ? "Use --all-models with --provider to launch every model from a provider." : "Both --provider and --model are required (or use provider__model slug with --model)."
2072
2078
  };
2073
2079
  }
2074
2080
  if (nonInteractive) {
@@ -2503,6 +2509,36 @@ ${pc4.bold("Usage:")}
2503
2509
  anygate providers refresh-models Refresh model catalog for all/specific provider
2504
2510
  anygate providers auth <id> Sign in with OAuth (xAI, OpenAI, GitHub Copilot, \u2026)`;
2505
2511
  }
2512
+ async function promptTemplateBaseUrl(template) {
2513
+ const entered = await p5.text({
2514
+ message: template.urlPrompt ?? "API Base URL:",
2515
+ placeholder: template.urlPlaceholder ?? template.defaultBaseUrl,
2516
+ defaultValue: template.defaultBaseUrl ?? "",
2517
+ validate: (v) => v.trim() || template.defaultBaseUrl ? void 0 : "URL is required"
2518
+ });
2519
+ if (p5.isCancel(entered)) return null;
2520
+ const baseUrl = String(entered ?? "").trim() || (template.defaultBaseUrl ?? "");
2521
+ if (!baseUrl) return null;
2522
+ let allowInsecureLocal = false;
2523
+ if (/^http:\/\//i.test(baseUrl)) {
2524
+ p5.log.warn(
2525
+ "HTTP is not encrypted. Only use it for a trusted local or LAN server, like Ollama on your own network."
2526
+ );
2527
+ const allowLocal = await p5.confirm({
2528
+ message: "Allow insecure HTTP for this local/LAN server?",
2529
+ initialValue: true
2530
+ });
2531
+ if (p5.isCancel(allowLocal)) return null;
2532
+ allowInsecureLocal = allowLocal === true;
2533
+ }
2534
+ const valid = await validateCustomEndpointUrl(baseUrl, { allowInsecureLocal });
2535
+ if (!valid.ok || !valid.normalizedUrl) {
2536
+ p5.log.error(valid.error ?? "Invalid URL.");
2537
+ if (valid.hint) p5.log.info(valid.hint);
2538
+ return null;
2539
+ }
2540
+ return valid.normalizedUrl;
2541
+ }
2506
2542
  async function runTemplateAddFlow(t) {
2507
2543
  const template = t ?? await pickTemplateFromCatalog();
2508
2544
  if (!template) return 0;
@@ -2511,9 +2547,16 @@ async function runTemplateAddFlow(t) {
2511
2547
  });
2512
2548
  if (p5.isCancel(inputKey)) return 0;
2513
2549
  const apiKey = String(inputKey ?? "").trim();
2514
- const result = await addProviderFromTemplate(template, apiKey);
2550
+ let baseUrl;
2551
+ if (template.urlPrompt) {
2552
+ const collected = await promptTemplateBaseUrl(template);
2553
+ if (!collected) return 1;
2554
+ baseUrl = collected;
2555
+ }
2556
+ const result = await addProviderFromTemplate(template, apiKey, { baseUrl });
2515
2557
  if (!result.added) {
2516
2558
  if (result.error) p5.log.error(result.error);
2559
+ if (result.hint) p5.log.info(result.hint);
2517
2560
  return 1;
2518
2561
  }
2519
2562
  logConnected(template.name, result.modelCount ?? 0);
@@ -2760,7 +2803,9 @@ async function runProvidersCommand(args) {
2760
2803
 
2761
2804
  // src/cli/claude.ts
2762
2805
  async function handleClaudeCommand(parsed) {
2763
- const { dryRun, setup, trace, launchProvider, launchModel } = parsed;
2806
+ const { dryRun, setup, trace, launchProvider } = parsed;
2807
+ const launchAllModels = parsed.launchAllModels || parsed.launchModel === "All";
2808
+ const launchModel = launchAllModels && !parsed.launchModel ? "All" : parsed.launchModel;
2764
2809
  const claudeArgs = normalizeClaudeAgentArgs(parsed.claudeArgs);
2765
2810
  const agentStdout = wantsCleanAgentStdout("claude", claudeArgs);
2766
2811
  setAgentStdoutMode(agentStdout);
@@ -2775,7 +2820,7 @@ async function handleClaudeCommand(parsed) {
2775
2820
  const conflicts = detectConflicts();
2776
2821
  const favorites = dryRun ? [] : prefs.favoriteModels ?? [];
2777
2822
  const launchPlan = planLaunchWizard({
2778
- explicit: { providerId: launchProvider, modelId: launchModel },
2823
+ explicit: launchAllModels ? { providerId: launchProvider, allModels: true } : { providerId: launchProvider, modelId: launchModel },
2779
2824
  childArgs: claudeArgs,
2780
2825
  agent: "claude",
2781
2826
  prefs
@@ -2786,7 +2831,13 @@ Error: ${launchPlan.error}
2786
2831
  `));
2787
2832
  return 1;
2788
2833
  }
2789
- const switchMenuActive = favorites.length > 0 && !launchPlan.skip;
2834
+ let catalogMode = false;
2835
+ const hasFavorites = favorites.length > 0;
2836
+ if (launchPlan.skip && launchPlan.target) {
2837
+ if (launchPlan.target.allModels) {
2838
+ catalogMode = "provider-all";
2839
+ }
2840
+ }
2790
2841
  if (!agentStdout) gateIntro("Claude Code");
2791
2842
  if (setup && !dryRun && !agentStdout) {
2792
2843
  p6.log.info("Provider setup now lives in anygate providers \u2014 opening that next is recommended.");
@@ -2836,7 +2887,7 @@ Error: ${launchPlan.error}
2836
2887
  }
2837
2888
  return baseOption;
2838
2889
  });
2839
- if (switchMenuActive) {
2890
+ if (hasFavorites) {
2840
2891
  providerOptions.unshift({
2841
2892
  value: "__favorites__",
2842
2893
  label: "\u2B50 Favorites Catalog",
@@ -2847,19 +2898,35 @@ Error: ${launchPlan.error}
2847
2898
  let activeProvider;
2848
2899
  let selectedModel;
2849
2900
  if (launchPlan.skip && launchPlan.target) {
2850
- const resolved = findProviderAndModel(allProviders, launchPlan.target);
2851
- if (!resolved) {
2852
- p6.log.error(
2853
- `Provider/model not found: ${launchPlan.target.providerId} / ${launchPlan.target.modelId}`
2854
- );
2855
- return 1;
2856
- }
2857
- activeProvider = resolved.provider;
2858
- selectedModel = resolved.model;
2859
- if (!agentStdout) {
2860
- p6.log.step(`Using ${selectedModel.name || selectedModel.id} (${activeProvider.name})`);
2901
+ if (launchPlan.target.allModels) {
2902
+ const resolvedProvider = allProviders.find((lp) => lp.id === launchPlan.target.providerId);
2903
+ if (!resolvedProvider) {
2904
+ p6.log.error(`Provider not found: ${launchPlan.target.providerId}`);
2905
+ return 1;
2906
+ }
2907
+ activeProvider = resolvedProvider;
2908
+ selectedModel = activeProvider.models[0];
2909
+ catalogMode = "provider-all";
2910
+ if (!agentStdout) {
2911
+ p6.log.step(`Using all ${activeProvider.models.length} models from ${activeProvider.name}`);
2912
+ }
2913
+ if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
2914
+ } else {
2915
+ const resolved = findProviderAndModel(allProviders, launchPlan.target);
2916
+ if (!resolved) {
2917
+ p6.log.error(
2918
+ `Provider/model not found: ${launchPlan.target.providerId} / ${launchPlan.target.modelId}`
2919
+ );
2920
+ return 1;
2921
+ }
2922
+ activeProvider = resolved.provider;
2923
+ selectedModel = resolved.model;
2924
+ catalogMode = false;
2925
+ if (!agentStdout) {
2926
+ p6.log.step(`Using ${selectedModel.name || selectedModel.id} (${activeProvider.name})`);
2927
+ }
2928
+ if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
2861
2929
  }
2862
- if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
2863
2930
  } else {
2864
2931
  let currentInitialProvider = initialProvider;
2865
2932
  while (true) {
@@ -2901,6 +2968,7 @@ Error: ${launchPlan.error}
2901
2968
  const sel = available[Number(pickedIdx)];
2902
2969
  activeProvider = sel.provider;
2903
2970
  selectedModel = sel.model;
2971
+ catalogMode = "favorites";
2904
2972
  if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
2905
2973
  break;
2906
2974
  } else {
@@ -2931,6 +2999,32 @@ Error: ${launchPlan.error}
2931
2999
  } else {
2932
3000
  activeProvider = selectedProvider;
2933
3001
  }
3002
+ const modelModeChoice = await p6.select({
3003
+ message: `Launch mode for ${activeProvider.name}?`,
3004
+ options: [
3005
+ {
3006
+ value: "specific",
3007
+ label: "One model",
3008
+ hint: "Pick a specific model from this provider"
3009
+ },
3010
+ {
3011
+ value: "all",
3012
+ label: `All models (${activeProvider.models.length})`,
3013
+ hint: "Every model from this provider in the /model switcher"
3014
+ },
3015
+ navOption("__back__", "\u2190 Back", "Choose a different provider")
3016
+ ]
3017
+ });
3018
+ if (p6.isCancel(modelModeChoice) || modelModeChoice === "__back__") {
3019
+ currentInitialProvider = activeProvider.id;
3020
+ continue;
3021
+ }
3022
+ if (modelModeChoice === "all") {
3023
+ catalogMode = "provider-all";
3024
+ selectedModel = activeProvider.models[0];
3025
+ if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
3026
+ break;
3027
+ }
2934
3028
  const pickedModelResult = await pickLocalModel(activeProvider, conflicts, prefs);
2935
3029
  if (pickedModelResult === "back") {
2936
3030
  currentInitialProvider = activeProvider.id;
@@ -2938,13 +3032,14 @@ Error: ${launchPlan.error}
2938
3032
  }
2939
3033
  if (!pickedModelResult) return 0;
2940
3034
  selectedModel = pickedModelResult;
3035
+ catalogMode = false;
2941
3036
  if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
2942
3037
  break;
2943
3038
  }
2944
3039
  }
2945
3040
  }
2946
3041
  const localProviders = catalog.length > 0 ? catalog : null;
2947
- if (switchMenuActive) {
3042
+ if (catalogMode === "favorites") {
2948
3043
  const resolveRoute = makeRouteResolver(localProviders);
2949
3044
  const startingRoute = resolveRoute(activeProvider.id, selectedModel.id) ?? null;
2950
3045
  if (!startingRoute) {
@@ -2993,6 +3088,35 @@ Error: ${launchPlan.error}
2993
3088
  claudeArgs
2994
3089
  );
2995
3090
  }
3091
+ if (catalogMode === "provider-all") {
3092
+ const resolveRoute = makeRouteResolver(localProviders);
3093
+ const startingRoute = resolveRoute(activeProvider.id, selectedModel.id) ?? null;
3094
+ if (!startingRoute) {
3095
+ p6.log.error("Could not resolve a proxy route for the starting model.");
3096
+ return 1;
3097
+ }
3098
+ const catalogRoutes = buildProviderAllModelRoutes(activeProvider, startingRoute, resolveRoute);
3099
+ if (dryRun) {
3100
+ console.log("");
3101
+ console.log(pc5.bold(pc5.cyan(" DRY RUN \u2014 would execute (provider catalog mode):")));
3102
+ console.log("");
3103
+ console.log(` ${pc5.bold("Provider:")} ${activeProvider.name}`);
3104
+ console.log(` ${pc5.bold("Starting model:")} ${selectedModel.id}`);
3105
+ console.log(` ${pc5.bold("/model catalog:")} ${catalogRoutes.length} model(s)`);
3106
+ catalogRoutes.forEach((r) => console.log(` ${pc5.dim(r.displayName)}`));
3107
+ console.log("");
3108
+ console.log(pc5.dim(" (dry run complete \u2014 Claude Code was NOT launched)"));
3109
+ console.log("");
3110
+ return 0;
3111
+ }
3112
+ return launchClaudeViaCatalog(
3113
+ catalogRoutes,
3114
+ startingRoute,
3115
+ selectedModel.contextWindow,
3116
+ trace ?? false,
3117
+ claudeArgs
3118
+ );
3119
+ }
2996
3120
  if (dryRun) {
2997
3121
  const formatDesc = selectedModel.modelFormat === "anthropic" ? "direct passthrough" : "via SDK adapter proxy";
2998
3122
  const endpoint = selectedModel.modelFormat === "anthropic" ? selectedModel.baseUrl ?? "(unknown)" : selectedModel.npm ?? "SDK";
@@ -3158,7 +3282,9 @@ Error: ${launchPlan.error}
3158
3282
  async function launchClaudeViaCatalog(catalogRoutes, startingRoute, contextWindow, trace, claudeArgs) {
3159
3283
  let proxyHandle;
3160
3284
  try {
3161
- proxyHandle = await startProxyCatalog(catalogRoutes, startingRoute.aliasId, trace);
3285
+ proxyHandle = await startProxyCatalog(catalogRoutes, startingRoute.aliasId, trace, {
3286
+ app: "Claude"
3287
+ });
3162
3288
  p6.log.info(
3163
3289
  `Switch menu active \u2014 proxy on port ${proxyHandle.port} ` + pc5.dim(`(${catalogRoutes.length} model${catalogRoutes.length !== 1 ? "s" : ""} in /model)`)
3164
3290
  );
@@ -3979,7 +4105,9 @@ async function writeResponsesStream(fullStream, modelId, write, onDone, onProgre
3979
4105
  toolCallCount: toolStates.length,
3980
4106
  toolNames: toolStates.map((t) => t.name),
3981
4107
  loopDetected,
3982
- dsmlToolCallsRecovered: dsml?.calls.length
4108
+ dsmlToolCallsRecovered: dsml?.calls.length,
4109
+ inputTokens: usage.input_tokens,
4110
+ outputTokens: usage.output_tokens
3983
4111
  });
3984
4112
  emit("response.completed", {
3985
4113
  type: "response.completed",
@@ -4388,6 +4516,24 @@ async function startCodexProxy(routes, options = {}) {
4388
4516
  const opts = typeof options === "boolean" ? { debug: options } : options;
4389
4517
  const debug = opts.debug ?? false;
4390
4518
  const requireAuth = opts.requireAuth ?? true;
4519
+ const analyticsApp = opts.app ?? "codex";
4520
+ const routeByModelId = new Map(routes.map((r) => [r.modelId, r]));
4521
+ const trackUsage = (modelId, inputTokens, outputTokens) => {
4522
+ if (inputTokens <= 0 && outputTokens <= 0) return;
4523
+ try {
4524
+ const route = routeByModelId.get(modelId);
4525
+ recordUsage({
4526
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
4527
+ modelId: route?.upstreamModelId ?? modelId,
4528
+ npm: route?.npm,
4529
+ providerId: route?.providerId,
4530
+ app: analyticsApp,
4531
+ inputTokens,
4532
+ outputTokens
4533
+ });
4534
+ } catch {
4535
+ }
4536
+ };
4391
4537
  silenceSdkWarnings();
4392
4538
  const models = /* @__PURE__ */ new Map();
4393
4539
  for (const route of routes) {
@@ -4622,6 +4768,7 @@ async function startCodexProxy(routes, options = {}) {
4622
4768
  modelId,
4623
4769
  write,
4624
4770
  (summary) => {
4771
+ trackUsage(modelId, summary.inputTokens ?? 0, summary.outputTokens ?? 0);
4625
4772
  if (debug) {
4626
4773
  const failure = `${summary.aborted ? " aborted=yes" : ""}${summary.errorMessage ? ` error=${JSON.stringify(summary.errorMessage)}` : ""}`;
4627
4774
  log17(
@@ -4651,6 +4798,8 @@ async function startCodexProxy(routes, options = {}) {
4651
4798
  } else {
4652
4799
  try {
4653
4800
  const response = await generateResponsesResponse(languageModel, params, modelId);
4801
+ const u = response["usage"];
4802
+ trackUsage(modelId, u?.input_tokens ?? 0, u?.output_tokens ?? 0);
4654
4803
  sendJson(res, 200, response);
4655
4804
  } catch (err) {
4656
4805
  const msg = formatUpstreamError(err);
@@ -4878,6 +5027,7 @@ data: ${JSON.stringify({ error: { message: `Unknown model: ${modelId}` } })}
4878
5027
  modelId,
4879
5028
  sendWsEvent,
4880
5029
  (summary) => {
5030
+ trackUsage(modelId, summary.inputTokens ?? 0, summary.outputTokens ?? 0);
4881
5031
  if (debug) {
4882
5032
  const failure = `${summary.aborted ? " aborted=yes" : ""}${summary.errorMessage ? ` error=${JSON.stringify(summary.errorMessage)}` : ""}`;
4883
5033
  log17(
@@ -5721,7 +5871,7 @@ function buildOAuthAnthropicProxyRoute(model, apiKey, providerId, providerData)
5721
5871
  refreshToken: () => resolveProviderCredential(providerId, oauthAuthRef(providerId))
5722
5872
  };
5723
5873
  }
5724
- async function partitionAndStartCloudCodeBackend(items, toOutput, trace) {
5874
+ async function partitionAndStartCloudCodeBackend(items, toOutput, trace, app) {
5725
5875
  if (items.length === 0) return { backendItems: [], backend: null };
5726
5876
  const proxyRoutes = items.map(
5727
5877
  (item) => item.model.modelFormat === "cloud-code" ? buildCloudCodeProxyRoute(item.model, item.apiKey, item.providerData ?? {}) : buildOAuthAnthropicProxyRoute(
@@ -5731,7 +5881,13 @@ async function partitionAndStartCloudCodeBackend(items, toOutput, trace) {
5731
5881
  item.providerData ?? {}
5732
5882
  )
5733
5883
  );
5734
- const backend = await startCloudCodeCatalogBackend(proxyRoutes, proxyRoutes[0].aliasId, trace);
5884
+ if (app) for (const route of proxyRoutes) route.app = app;
5885
+ const backend = await startCloudCodeCatalogBackend(
5886
+ proxyRoutes,
5887
+ proxyRoutes[0].aliasId,
5888
+ trace,
5889
+ app
5890
+ );
5735
5891
  return {
5736
5892
  backend,
5737
5893
  backendItems: proxyRoutes.map(
@@ -5744,8 +5900,8 @@ async function buildSingleModelCloudCodeRoute(model, apiKey, providerId, provide
5744
5900
  const backend = await startCloudCodeCatalogBackend([proxyRoute], proxyRoute.aliasId, trace);
5745
5901
  return { proxyRoute, backend };
5746
5902
  }
5747
- async function startCloudCodeCatalogBackend(routes, startingAliasId, trace) {
5748
- const handle = await startProxyCatalog(routes, startingAliasId, trace ?? false);
5903
+ async function startCloudCodeCatalogBackend(routes, startingAliasId, trace, app) {
5904
+ const handle = await startProxyCatalog(routes, startingAliasId, trace ?? false, { app });
5749
5905
  return { port: handle.port, token: handle.token, handle };
5750
5906
  }
5751
5907
 
@@ -5855,6 +6011,29 @@ async function writeFavoritesLaunchArtifacts(resolved, starting, proxyPort) {
5855
6011
  );
5856
6012
  return { profilePath, catalogPath };
5857
6013
  }
6014
+ async function writeAllModelsLaunchArtifacts(activeProvider, selectedModel, routable, proxyPort) {
6015
+ const catalogPath = getCatalogOutputPath(activeProvider.id);
6016
+ const catalog = buildCatalogFile(routable, activeProvider.name);
6017
+ writeOverlayFile(catalogPath, serializeCatalog(catalog));
6018
+ const profilePath = getProfileOutputPath();
6019
+ const dummyRoute = {
6020
+ tier: "proxy",
6021
+ modelId: selectedModel.id,
6022
+ providerId: "anygate-proxy",
6023
+ npm: selectedModel.npm ?? "@ai-sdk/openai-compatible",
6024
+ upstreamModelId: selectedModel.upstreamModelId || selectedModel.id,
6025
+ apiKey: ""
6026
+ };
6027
+ writeOverlayFile(
6028
+ profilePath,
6029
+ buildCodexProfileToml({
6030
+ route: dummyRoute,
6031
+ proxyPort,
6032
+ catalogPath
6033
+ })
6034
+ );
6035
+ return { profilePath, catalogPath };
6036
+ }
5858
6037
  function printCodexCleanupReminder(hadProxy) {
5859
6038
  if (isAgentStdoutMode()) return;
5860
6039
  const left = remainingOverlayPaths();
@@ -6019,8 +6198,9 @@ async function runCodexCommand(codexArgs, trace = false, launch = {}) {
6019
6198
  return runCodexVertexLaunch(passthroughArgs, trace);
6020
6199
  }
6021
6200
  const prefs = loadPreferences();
6201
+ const launchAllModels = Boolean(launch.launchAllModels || launch.launchModel === "All");
6022
6202
  const launchPlan = planLaunchWizard({
6023
- explicit: { providerId: launch.launchProvider, modelId: launch.launchModel },
6203
+ explicit: launchAllModels ? { providerId: launch.launchProvider, allModels: true } : { providerId: launch.launchProvider, modelId: launch.launchModel },
6024
6204
  childArgs: passthroughArgs,
6025
6205
  agent: "codex",
6026
6206
  prefs
@@ -6092,8 +6272,16 @@ Error: ${launchPlan.error}
6092
6272
  return 0;
6093
6273
  }
6094
6274
  const favorites = prefs.favoriteModels ?? [];
6095
- const favoritesActive = favorites.length > 0 && !launchPlan.skip;
6096
- if (favoritesActive && !configOnly) {
6275
+ const hasFavorites = favorites.length > 0;
6276
+ let catalogMode = false;
6277
+ if (launchPlan.skip && launchPlan.target && launchPlan.target.allModels) {
6278
+ catalogMode = "provider-all";
6279
+ }
6280
+ let favoritesActive = false;
6281
+ if (configOnly && hasFavorites && !launchPlan.skip) {
6282
+ favoritesActive = true;
6283
+ }
6284
+ if (hasFavorites && !configOnly && !launchPlan.skip) {
6097
6285
  p9.log.info(
6098
6286
  `Favorites mode active \u2014 Codex picker will show ${favorites.length + 1} models (1 starting + ${favorites.length} favorites).`
6099
6287
  );
@@ -6102,17 +6290,31 @@ Error: ${launchPlan.error}
6102
6290
  let activeProvider = compatible.find((lp) => lp.id === prefs.lastCodexProvider) ?? compatible[0];
6103
6291
  let selectedModel = activeProvider.models.find((m) => m.id === prefs.lastCodexModel) ?? activeProvider.models[0];
6104
6292
  if (!configOnly && launchPlan.skip && launchPlan.target) {
6105
- const resolved = findProviderAndModel(compatible, launchPlan.target);
6106
- if (!resolved) {
6107
- p9.log.error(
6108
- `Provider/model not found: ${launchPlan.target.providerId} / ${launchPlan.target.modelId}`
6109
- );
6110
- return 1;
6111
- }
6112
- activeProvider = resolved.provider;
6113
- selectedModel = resolved.model;
6114
- if (!agentStdout) {
6115
- p9.log.step(`Using ${selectedModel.name || selectedModel.id} (${activeProvider.name})`);
6293
+ if (launchPlan.target.allModels) {
6294
+ const foundProvider = compatible.find((lp) => lp.id === launchPlan.target.providerId);
6295
+ if (!foundProvider) {
6296
+ p9.log.error(`Provider not found: ${launchPlan.target.providerId}`);
6297
+ return 1;
6298
+ }
6299
+ activeProvider = foundProvider;
6300
+ selectedModel = activeProvider.models[0];
6301
+ catalogMode = "provider-all";
6302
+ if (!agentStdout) {
6303
+ p9.log.step(`Using all ${activeProvider.models.length} models from ${activeProvider.name}`);
6304
+ }
6305
+ } else {
6306
+ const resolved = findProviderAndModel(compatible, launchPlan.target);
6307
+ if (!resolved) {
6308
+ p9.log.error(
6309
+ `Provider/model not found: ${launchPlan.target.providerId} / ${launchPlan.target.modelId}`
6310
+ );
6311
+ return 1;
6312
+ }
6313
+ activeProvider = resolved.provider;
6314
+ selectedModel = resolved.model;
6315
+ if (!agentStdout) {
6316
+ p9.log.step(`Using ${selectedModel.name || selectedModel.id} (${activeProvider.name})`);
6317
+ }
6116
6318
  }
6117
6319
  } else if (!configOnly) {
6118
6320
  let currentInitialProvider = prefs.lastCodexProvider && compatible.some((o) => o.id === prefs.lastCodexProvider) ? prefs.lastCodexProvider : compatible[0].id;
@@ -6120,7 +6322,7 @@ Error: ${launchPlan.error}
6120
6322
  const pickedProvider = await pickCodexProvider(
6121
6323
  compatible,
6122
6324
  prefs,
6123
- favoritesActive,
6325
+ hasFavorites,
6124
6326
  currentInitialProvider
6125
6327
  );
6126
6328
  if (!pickedProvider) return 0;
@@ -6135,9 +6337,36 @@ Error: ${launchPlan.error}
6135
6337
  if (favoritePick === "cancelled" || favoritePick === "unavailable") return 0;
6136
6338
  activeProvider = favoritePick.provider;
6137
6339
  selectedModel = favoritePick.model;
6340
+ catalogMode = "favorites";
6341
+ favoritesActive = true;
6138
6342
  break;
6139
6343
  } else {
6140
6344
  activeProvider = pickedProvider;
6345
+ const modelModeChoice = await p9.select({
6346
+ message: `Launch mode for ${activeProvider.name}?`,
6347
+ options: [
6348
+ {
6349
+ value: "specific",
6350
+ label: "One model",
6351
+ hint: "Pick a specific model"
6352
+ },
6353
+ {
6354
+ value: "all",
6355
+ label: `All models (${activeProvider.models.length})`,
6356
+ hint: "Every model from this provider in the picker"
6357
+ },
6358
+ navOption("__back__", "\u2190 Back", "Choose a different provider")
6359
+ ]
6360
+ });
6361
+ if (p9.isCancel(modelModeChoice) || modelModeChoice === "__back__") {
6362
+ currentInitialProvider = activeProvider.id;
6363
+ continue;
6364
+ }
6365
+ if (modelModeChoice === "all") {
6366
+ catalogMode = "provider-all";
6367
+ selectedModel = activeProvider.models[0];
6368
+ break;
6369
+ }
6141
6370
  const pickedModelResult = await pickCodexModel(activeProvider, prefs);
6142
6371
  if (pickedModelResult === "back") {
6143
6372
  currentInitialProvider = activeProvider.id;
@@ -6185,7 +6414,64 @@ Error: ${launchPlan.error}
6185
6414
  let cloudCodeBackendFav = null;
6186
6415
  try {
6187
6416
  let proxyPort;
6188
- if (favoritesActive && resolvedFavorites.length > 0) {
6417
+ if (catalogMode === "provider-all") {
6418
+ const routable = routableModelsForProvider(activeProvider, "codex");
6419
+ const backendModels = routable.filter((m) => needsCloudCodeBackend(m, activeProvider.authType));
6420
+ const regularModels = routable.filter((m) => !needsCloudCodeBackend(m, activeProvider.authType));
6421
+ let backendCodexRoutes = [];
6422
+ if (backendModels.length > 0) {
6423
+ const partitioned = await partitionAndStartCloudCodeBackend(
6424
+ backendModels.map((model) => ({
6425
+ providerId: activeProvider.id,
6426
+ model,
6427
+ apiKey,
6428
+ oauthAccountId: activeProvider.oauthAccountId,
6429
+ providerData: activeProvider.providerData ?? {}
6430
+ })),
6431
+ (cr, backend) => ({
6432
+ modelId: cr.aliasId,
6433
+ npm: "@ai-sdk/anthropic",
6434
+ apiKey: backend.token,
6435
+ baseURL: `http://127.0.0.1:${backend.port}`,
6436
+ upstreamModelId: cr.aliasId,
6437
+ providerId: cr.providerId ?? activeProvider.id,
6438
+ authType: "oauth",
6439
+ oauthAccountId: activeProvider.oauthAccountId,
6440
+ providerData: activeProvider.providerData ?? {},
6441
+ contextWindow: cr.contextWindow,
6442
+ supportedParameters: cr.supportedParameters,
6443
+ reasoning: cr.reasoning,
6444
+ interleavedReasoningField: cr.interleavedReasoningField
6445
+ }),
6446
+ trace,
6447
+ "codex"
6448
+ );
6449
+ cloudCodeBackendFav = partitioned.backend;
6450
+ backendCodexRoutes = partitioned.backendItems;
6451
+ }
6452
+ const regularRoutes = regularModels.map((model) => {
6453
+ const r = resolveCodexRoute(activeProvider, model, apiKey);
6454
+ return {
6455
+ modelId: r.modelId,
6456
+ npm: r.npm,
6457
+ apiKey: r.apiKey,
6458
+ baseURL: r.baseURL,
6459
+ upstreamModelId: r.upstreamModelId,
6460
+ providerId: r.providerId,
6461
+ authType: r.authType,
6462
+ oauthAccountId: r.oauthAccountId,
6463
+ providerData: r.providerData,
6464
+ contextWindow: r.contextWindow,
6465
+ supportedParameters: r.supportedParameters,
6466
+ reasoning: r.reasoning,
6467
+ interleavedReasoningField: r.interleavedReasoningField,
6468
+ headers: r.headers
6469
+ };
6470
+ });
6471
+ const allRoutes = [...backendCodexRoutes, ...regularRoutes];
6472
+ proxyHandle = await startCodexProxy(allRoutes, { requireAuth: true, debug: trace });
6473
+ proxyPort = proxyHandle.port;
6474
+ } else if (favoritesActive && resolvedFavorites.length > 0) {
6189
6475
  const needsBackend = (r) => {
6190
6476
  const m = r.model;
6191
6477
  const prov = providersById.get(r.providerId);
@@ -6218,7 +6504,8 @@ Error: ${launchPlan.error}
6218
6504
  providerData: original.providerData,
6219
6505
  contextWindow: cr.contextWindow
6220
6506
  }),
6221
- trace
6507
+ trace,
6508
+ "codex"
6222
6509
  );
6223
6510
  cloudCodeBackendFav = partitioned.backend;
6224
6511
  backendCodexRoutes = partitioned.backendItems;
@@ -6315,7 +6602,12 @@ Error: ${launchPlan.error}
6315
6602
  const startingFavorite = resolvedFavorites.find(
6316
6603
  (r) => r.providerId === activeProvider.id && r.model.id === selectedModel.id
6317
6604
  ) ?? resolvedFavorites[0];
6318
- const { profilePath, catalogPath } = favoritesActive && resolvedFavorites.length > 0 && proxyPort && startingFavorite ? await writeFavoritesLaunchArtifacts(resolvedFavorites, startingFavorite, proxyPort) : await writeLaunchArtifacts(route, selectedModel, activeProvider.name, proxyPort);
6605
+ const { profilePath, catalogPath } = catalogMode === "provider-all" && proxyPort ? await writeAllModelsLaunchArtifacts(
6606
+ activeProvider,
6607
+ selectedModel,
6608
+ routableModelsForProvider(activeProvider, "codex"),
6609
+ proxyPort
6610
+ ) : favoritesActive && resolvedFavorites.length > 0 && proxyPort && startingFavorite ? await writeFavoritesLaunchArtifacts(resolvedFavorites, startingFavorite, proxyPort) : await writeLaunchArtifacts(route, selectedModel, activeProvider.name, proxyPort);
6319
6611
  writeSessionLock({
6320
6612
  pid: process.pid,
6321
6613
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -6329,7 +6621,19 @@ Error: ${launchPlan.error}
6329
6621
  console.log("");
6330
6622
  console.log(pc8.bold(pc8.cyan(" CONFIG PREVIEW \u2014 anygate codex")));
6331
6623
  console.log("");
6332
- if (favoritesActive && resolvedFavorites.length > 0) {
6624
+ if (catalogMode === "provider-all") {
6625
+ const allModels = routableModelsForProvider(activeProvider, "codex");
6626
+ console.log(
6627
+ ` ${pc8.bold("Mode:")} Provider Catalog (${allModels.length} model${allModels.length !== 1 ? "s" : ""})`
6628
+ );
6629
+ console.log(` ${pc8.bold("Provider:")} ${activeProvider.name}`);
6630
+ console.log(` ${pc8.bold("Starting model:")} ${selectedModel.id}`);
6631
+ console.log("");
6632
+ console.log(` ${pc8.bold("Models:")}`);
6633
+ for (const m of allModels) {
6634
+ console.log(` ${pc8.cyan(m.id)}`);
6635
+ }
6636
+ } else if (favoritesActive && resolvedFavorites.length > 0) {
6333
6637
  console.log(
6334
6638
  ` ${pc8.bold("Mode:")} Favorites Catalog (${resolvedFavorites.length} model${resolvedFavorites.length !== 1 ? "s" : ""})`
6335
6639
  );
@@ -6362,6 +6666,7 @@ Error: ${launchPlan.error}
6362
6666
  }
6363
6667
  }
6364
6668
  const favoritesLaunch = favoritesActive && resolvedFavorites.length > 0;
6669
+ const providerAllLaunch = catalogMode === "provider-all";
6365
6670
  const launchModelId = favoritesLaunch ? codexCliFavoritesSlug(activeProvider.id, selectedModel.id) : selectedModel.id;
6366
6671
  if (!agentStdout) {
6367
6672
  logActiveModel(modelLabel, launchModelId);
@@ -6376,11 +6681,9 @@ Error: ${launchPlan.error}
6376
6681
  upstreamModelId: selectedModel.upstreamModelId || selectedModel.id,
6377
6682
  apiKey: ""
6378
6683
  };
6379
- const childEnv = buildCodexChildEnv(
6380
- favoritesLaunch || route.tier === "cloud-code" ? dummyRoute : route,
6381
- proxyPort
6382
- );
6383
- const hadProxy = (route.tier === "proxy" || route.tier === "cloud-code" || favoritesLaunch) && !!proxyPort;
6684
+ const useProxyRoute = favoritesLaunch || providerAllLaunch || route.tier === "cloud-code";
6685
+ const childEnv = buildCodexChildEnv(useProxyRoute ? dummyRoute : route, proxyPort);
6686
+ const hadProxy = (route.tier === "proxy" || route.tier === "cloud-code" || favoritesLaunch || providerAllLaunch) && !!proxyPort;
6384
6687
  const exitCode = await launchCodex(launchModelId, childEnv, passthroughArgs);
6385
6688
  if (trace) printTraceLog(debugLogPath);
6386
6689
  printCodexCleanupReminder(hadProxy);
@@ -6400,7 +6703,7 @@ Error: ${launchPlan.error}
6400
6703
  // src/cli/codex.ts
6401
6704
  async function handleCodexCommand(parsed) {
6402
6705
  if (parsed.showVersion) {
6403
- const { VERSION: VERSION2 } = await import("./constants-GW5BAY6G.js");
6706
+ const { VERSION: VERSION2 } = await import("./constants-WLMOLKEO.js");
6404
6707
  console.log(VERSION2);
6405
6708
  return 0;
6406
6709
  }
@@ -6411,6 +6714,7 @@ async function handleCodexCommand(parsed) {
6411
6714
  return runCodexCommand(parsed.claudeArgs ?? [], parsed.trace ?? false, {
6412
6715
  launchProvider: parsed.launchProvider,
6413
6716
  launchModel: parsed.launchModel,
6717
+ launchAllModels: parsed.launchAllModels || parsed.launchModel === "All",
6414
6718
  vertex: parsed.vertex
6415
6719
  });
6416
6720
  }
@@ -6476,7 +6780,8 @@ async function buildCodexAppProviderCatalogRoutes(provider, apiKey, selectedMode
6476
6780
  interleavedReasoningField: original.model.interleavedReasoningField,
6477
6781
  headers: provider.headers
6478
6782
  }),
6479
- trace
6783
+ trace,
6784
+ "codex-app"
6480
6785
  );
6481
6786
  for (let index = 0; index < backendModels.length; index++) {
6482
6787
  const model = backendModels[index];
@@ -7078,7 +7383,7 @@ async function runCodexAppVertexLaunch(configOnly, trace = false) {
7078
7383
  vertex: vertexConfig,
7079
7384
  contextWindow: m.contextWindow
7080
7385
  })),
7081
- { requireAuth: false, debug: trace }
7386
+ { requireAuth: false, debug: trace, app: "codex-app" }
7082
7387
  );
7083
7388
  const proxyPort = proxyHandle.port;
7084
7389
  const catalogFile = buildAppCatalogFile(vertexModels, "Vertex AI", selectedEntry.id);
@@ -7204,33 +7509,43 @@ async function runCodexAppCommand(args, opts = {}) {
7204
7509
  }
7205
7510
  const prefs = loadPreferences();
7206
7511
  const favorites = prefs.favoriteModels ?? [];
7207
- const favoritesActive = favorites.length > 0;
7512
+ const hasFavorites = favorites.length > 0;
7513
+ let favoritesMode = false;
7514
+ let useProviderAll = false;
7208
7515
  const useFavoritesCatalog = args.includes("--favorites");
7209
- if (favoritesActive && !configOnly) {
7210
- p10.log.info(
7211
- `Favorites mode active \u2014 Codex App picker will show ${favorites.length + 1} models (1 starting + ${favorites.length} favorites).`
7212
- );
7213
- p10.log.info("Edit with `anygate models`.");
7214
- }
7215
7516
  let activeProvider = providerForCodexPicker(
7216
7517
  compatible.find((lp) => lp.id === prefs.lastCodexProvider) ?? compatible[0]
7217
7518
  );
7218
7519
  let selectedModel = activeProvider.models.find((m) => m.id === prefs.lastCodexModel) ?? activeProvider.models[0];
7219
- if (!configOnly && opts.launchProvider && opts.launchModel) {
7220
- const bootSelection = resolveBootSelection(
7221
- compatible,
7222
- opts.launchProvider,
7223
- opts.launchModel,
7224
- providerForCodexPicker
7225
- );
7226
- if ("error" in bootSelection) {
7227
- p10.log.error(bootSelection.error);
7228
- return 1;
7520
+ if (!configOnly && opts.launchProvider && opts.launchModel || opts.launchProvider && (opts.launchAllModels || opts.launchModel === "All")) {
7521
+ if (opts.launchAllModels || opts.launchModel === "All") {
7522
+ const foundProvider = compatible.find((lp) => lp.id === opts.launchProvider);
7523
+ if (!foundProvider) {
7524
+ p10.log.error(`Provider not found: ${opts.launchProvider}`);
7525
+ return 1;
7526
+ }
7527
+ activeProvider = providerForCodexPicker(foundProvider);
7528
+ selectedModel = activeProvider.models[0];
7529
+ useProviderAll = true;
7530
+ if (!configOnly) {
7531
+ p10.log.step(`Using all ${activeProvider.models.length} models from ${activeProvider.name}`);
7532
+ }
7533
+ } else {
7534
+ const bootSelection = resolveBootSelection(
7535
+ compatible,
7536
+ opts.launchProvider,
7537
+ opts.launchModel,
7538
+ providerForCodexPicker
7539
+ );
7540
+ if ("error" in bootSelection) {
7541
+ p10.log.error(bootSelection.error);
7542
+ return 1;
7543
+ }
7544
+ activeProvider = bootSelection.provider;
7545
+ selectedModel = bootSelection.model;
7229
7546
  }
7230
- activeProvider = bootSelection.provider;
7231
- selectedModel = bootSelection.model;
7232
7547
  } else if (!configOnly) {
7233
- if (useFavoritesCatalog && favoritesActive) {
7548
+ if (useFavoritesCatalog && hasFavorites) {
7234
7549
  const firstFavorite = resolveFirstAvailableFavorite(
7235
7550
  favorites,
7236
7551
  compatible.map(providerForCodexPicker)
@@ -7241,13 +7556,14 @@ async function runCodexAppCommand(args, opts = {}) {
7241
7556
  }
7242
7557
  activeProvider = providerForCodexPicker(firstFavorite.provider);
7243
7558
  selectedModel = firstFavorite.model;
7559
+ favoritesMode = true;
7244
7560
  } else {
7245
7561
  let currentInitialProvider = prefs.lastCodexProvider && compatible.some((o) => o.id === prefs.lastCodexProvider) ? prefs.lastCodexProvider : compatible[0].id;
7246
7562
  while (true) {
7247
7563
  const pickedProvider = await pickCodexProvider(
7248
7564
  compatible,
7249
7565
  prefs,
7250
- favoritesActive,
7566
+ hasFavorites,
7251
7567
  currentInitialProvider
7252
7568
  );
7253
7569
  if (!pickedProvider) return 0;
@@ -7262,9 +7578,35 @@ async function runCodexAppCommand(args, opts = {}) {
7262
7578
  if (favoritePick === "cancelled" || favoritePick === "unavailable") return 0;
7263
7579
  activeProvider = favoritePick.provider;
7264
7580
  selectedModel = favoritePick.model;
7581
+ favoritesMode = true;
7265
7582
  break;
7266
7583
  } else {
7267
7584
  activeProvider = providerForCodexPicker(pickedProvider);
7585
+ const modelModeChoice = await p10.select({
7586
+ message: `Launch mode for ${activeProvider.name}?`,
7587
+ options: [
7588
+ {
7589
+ value: "specific",
7590
+ label: "One model",
7591
+ hint: "Pick a specific model"
7592
+ },
7593
+ {
7594
+ value: "all",
7595
+ label: `All models (${activeProvider.models.length})`,
7596
+ hint: "Every model from this provider in the model switcher"
7597
+ },
7598
+ navOption("__back__", "\u2190 Back", "Choose a different provider")
7599
+ ]
7600
+ });
7601
+ if (p10.isCancel(modelModeChoice) || modelModeChoice === "__back__") {
7602
+ currentInitialProvider = activeProvider.id;
7603
+ continue;
7604
+ }
7605
+ if (modelModeChoice === "all") {
7606
+ useProviderAll = true;
7607
+ selectedModel = activeProvider.models[0];
7608
+ break;
7609
+ }
7268
7610
  const pickedModelResult = await pickCodexModel(activeProvider, prefs);
7269
7611
  if (pickedModelResult === "back") {
7270
7612
  currentInitialProvider = activeProvider.id;
@@ -7285,9 +7627,15 @@ async function runCodexAppCommand(args, opts = {}) {
7285
7627
  return 1;
7286
7628
  }
7287
7629
  activeProvider.apiKey = apiKey;
7630
+ if (hasFavorites && !configOnly && !useProviderAll) {
7631
+ p10.log.info(
7632
+ `Favorites mode active \u2014 Codex App picker will show ${favorites.length + 1} models (1 starting + ${favorites.length} favorites).`
7633
+ );
7634
+ p10.log.info("Edit with `anygate models`.");
7635
+ }
7288
7636
  let cloudCodeBackend = null;
7289
7637
  let cloudCodeBackendFav = null;
7290
- const appProviderRoutes = favoritesActive ? null : await buildCodexAppProviderCatalogRoutes(activeProvider, apiKey, selectedModel.id, trace);
7638
+ const appProviderRoutes = !favoritesMode ? await buildCodexAppProviderCatalogRoutes(activeProvider, apiKey, selectedModel.id, trace) : null;
7291
7639
  cloudCodeBackend = appProviderRoutes?.backend ?? null;
7292
7640
  const route = appProviderRoutes ? codexProxyRouteToCodexRoute(appProviderRoutes.selectedRoute, activeProvider.id) : resolveCodexRoute(activeProvider, selectedModel, apiKey);
7293
7641
  const appRoute = { ...route, tier: "proxy" };
@@ -7295,7 +7643,7 @@ async function runCodexAppCommand(args, opts = {}) {
7295
7643
  const catalogModels = appProviderRoutes?.catalogModels ?? routable;
7296
7644
  let resolvedFavorites = [];
7297
7645
  let providersById = /* @__PURE__ */ new Map();
7298
- if (favoritesActive) {
7646
+ if (favoritesMode) {
7299
7647
  const res = await resolveCodexFavorites(
7300
7648
  activeProvider,
7301
7649
  selectedModel,
@@ -7308,7 +7656,8 @@ async function runCodexAppCommand(args, opts = {}) {
7308
7656
  }
7309
7657
  if (!configOnly) {
7310
7658
  const modelLabel = formatCodexModelLabel(selectedModel);
7311
- const confirmed = useFavoritesCatalog || await confirmCodexLaunch(activeProvider.name, modelLabel, selectedModel.id, appRoute);
7659
+ const isExplicitLaunch = Boolean(opts.launchProvider) && Boolean(opts.launchModel || opts.launchAllModels);
7660
+ const confirmed = useFavoritesCatalog || isExplicitLaunch || await confirmCodexLaunch(activeProvider.name, modelLabel, selectedModel.id, appRoute);
7312
7661
  if (!confirmed) {
7313
7662
  cloudCodeBackend?.handle.close();
7314
7663
  return 0;
@@ -7317,8 +7666,8 @@ async function runCodexAppCommand(args, opts = {}) {
7317
7666
  let proxyHandle = null;
7318
7667
  let sessionActive = false;
7319
7668
  try {
7320
- const catalogPath = favoritesActive && resolvedFavorites.length > 0 ? getFavoritesAppCatalogPath() : getAppCatalogPath(route.providerId);
7321
- const activeRoute = favoritesActive && resolvedFavorites.length > 0 ? {
7669
+ const catalogPath = favoritesMode && resolvedFavorites.length > 0 ? getFavoritesAppCatalogPath() : getAppCatalogPath(route.providerId);
7670
+ const activeRoute = favoritesMode && resolvedFavorites.length > 0 ? {
7322
7671
  tier: "proxy",
7323
7672
  modelId: codexCliFavoritesSlug(activeProvider.id, selectedModel.id),
7324
7673
  providerId: activeProvider.id,
@@ -7334,7 +7683,7 @@ async function runCodexAppCommand(args, opts = {}) {
7334
7683
  console.log("");
7335
7684
  console.log(pc9.bold(pc9.cyan(" CONFIG PREVIEW \u2014 anygate codex-app")));
7336
7685
  console.log("");
7337
- if (favoritesActive) {
7686
+ if (favoritesMode) {
7338
7687
  console.log(
7339
7688
  ` ${pc9.bold("Mode:")} Favorites Catalog (${resolvedFavorites.length} model${resolvedFavorites.length !== 1 ? "s" : ""})`
7340
7689
  );
@@ -7370,7 +7719,7 @@ async function runCodexAppCommand(args, opts = {}) {
7370
7719
  return 0;
7371
7720
  }
7372
7721
  let proxyPort;
7373
- if (favoritesActive && resolvedFavorites.length > 0) {
7722
+ if (favoritesMode && resolvedFavorites.length > 0) {
7374
7723
  const needsBackend = (r) => {
7375
7724
  const m = r.model;
7376
7725
  const prov = providersById.get(r.providerId);
@@ -7409,7 +7758,8 @@ async function runCodexAppCommand(args, opts = {}) {
7409
7758
  const regularRoutes = buildCodexProxyRoutesFromResolved(regularResolved, providersById);
7410
7759
  proxyHandle = await startCodexProxy([...backendCodexRoutes, ...regularRoutes], {
7411
7760
  requireAuth: false,
7412
- debug: trace
7761
+ debug: trace,
7762
+ app: "codex-app"
7413
7763
  });
7414
7764
  proxyPort = proxyHandle.port;
7415
7765
  } else {
@@ -7418,12 +7768,13 @@ async function runCodexAppCommand(args, opts = {}) {
7418
7768
  }
7419
7769
  proxyHandle = await startCodexProxy(appProviderRoutes.routes, {
7420
7770
  requireAuth: false,
7421
- debug: trace
7771
+ debug: trace,
7772
+ app: "codex-app"
7422
7773
  });
7423
7774
  proxyPort = proxyHandle.port;
7424
7775
  }
7425
7776
  const modelLabel = formatCodexModelLabel(selectedModel);
7426
- const catalogFile = favoritesActive && resolvedFavorites.length > 0 ? buildFavoritesAppCatalog(resolvedFavorites) : buildAppCatalogFile(catalogModels, activeProvider.name, appRoute.modelId);
7777
+ const catalogFile = favoritesMode && resolvedFavorites.length > 0 ? buildFavoritesAppCatalog(resolvedFavorites) : buildAppCatalogFile(catalogModels, activeProvider.name, appRoute.modelId);
7427
7778
  writeOverlayFile(catalogPath, serializeCatalog(catalogFile));
7428
7779
  const spec = {
7429
7780
  route: activeRoute,
@@ -7495,7 +7846,7 @@ async function runCodexAppCommand(args, opts = {}) {
7495
7846
  // src/cli/codex-app.ts
7496
7847
  async function handleCodexAppCommand(parsed) {
7497
7848
  if (parsed.showVersion) {
7498
- const { VERSION: VERSION2 } = await import("./constants-GW5BAY6G.js");
7849
+ const { VERSION: VERSION2 } = await import("./constants-WLMOLKEO.js");
7499
7850
  console.log(VERSION2);
7500
7851
  return 0;
7501
7852
  }
@@ -7522,7 +7873,8 @@ This command launches the ChatGPT Desktop app with anygate's provider registry.
7522
7873
  return runCodexAppCommand(parsed.claudeArgs ?? [], {
7523
7874
  vertex: parsed.vertex,
7524
7875
  launchProvider: parsed.launchProvider,
7525
- launchModel: parsed.launchModel
7876
+ launchModel: parsed.launchModel,
7877
+ launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
7526
7878
  });
7527
7879
  }
7528
7880
 
@@ -7810,10 +8162,21 @@ async function runClaudeAppCommand(args, boot) {
7810
8162
  const prefs = loadPreferences();
7811
8163
  const favorites = prefs.favoriteModels ?? [];
7812
8164
  const hasFavorites = favorites.length > 0;
8165
+ const launchAllModels = Boolean(boot?.launchAllModels || boot?.launchModel === "All");
7813
8166
  let activeProvider = null;
7814
8167
  let selectedModel = null;
7815
8168
  let useFavorites = false;
7816
- if (boot?.launchProvider && boot?.launchModel) {
8169
+ let useProviderAll = false;
8170
+ if (boot?.launchProvider && launchAllModels) {
8171
+ const foundProvider = compatible.find((lp) => lp.id === boot.launchProvider);
8172
+ if (!foundProvider) {
8173
+ p11.log.error(`Provider not found: ${boot.launchProvider}`);
8174
+ return 1;
8175
+ }
8176
+ activeProvider = foundProvider;
8177
+ selectedModel = activeProvider.models[0];
8178
+ useProviderAll = true;
8179
+ } else if (boot?.launchProvider && boot?.launchModel) {
7817
8180
  const bootSelection = resolveBootSelection(
7818
8181
  compatible,
7819
8182
  boot.launchProvider,
@@ -7840,10 +8203,48 @@ async function runClaudeAppCommand(args, boot) {
7840
8203
  if (pickedProvider === "__favorites__") {
7841
8204
  useFavorites = true;
7842
8205
  } else {
7843
- activeProvider = providerForClaudePicker(pickedProvider);
7844
- const pickedModel = await pickCodexModel(activeProvider, prefs);
7845
- if (!pickedModel) return 0;
7846
- selectedModel = pickedModel;
8206
+ while (true) {
8207
+ const pickedProvider2 = await pickCodexProvider(
8208
+ compatible,
8209
+ prefs,
8210
+ hasFavorites,
8211
+ void 0,
8212
+ "Claude"
8213
+ );
8214
+ if (!pickedProvider2) return 0;
8215
+ if (pickedProvider2 === "__favorites__") {
8216
+ useFavorites = true;
8217
+ break;
8218
+ } else {
8219
+ activeProvider = providerForClaudePicker(pickedProvider2);
8220
+ const modelModeChoice = await p11.select({
8221
+ message: `Launch mode for ${activeProvider.name}?`,
8222
+ options: [
8223
+ {
8224
+ value: "specific",
8225
+ label: "One model",
8226
+ hint: "Pick a specific model"
8227
+ },
8228
+ {
8229
+ value: "all",
8230
+ label: `All models (${activeProvider.models.length})`,
8231
+ hint: "Every model from this provider in the model picker"
8232
+ },
8233
+ navOption("__back__", "\u2190 Back", "Choose a different provider")
8234
+ ]
8235
+ });
8236
+ if (p11.isCancel(modelModeChoice) || modelModeChoice === "__back__") continue;
8237
+ if (modelModeChoice === "all") {
8238
+ useProviderAll = true;
8239
+ selectedModel = activeProvider.models[0];
8240
+ break;
8241
+ }
8242
+ const pickedModel = await pickCodexModel(activeProvider, prefs);
8243
+ if (!pickedModel) return 0;
8244
+ selectedModel = pickedModel;
8245
+ break;
8246
+ }
8247
+ }
7847
8248
  }
7848
8249
  }
7849
8250
  if (activeProvider) {
@@ -7912,6 +8313,54 @@ async function runClaudeAppCommand(args, boot) {
7912
8313
  seen.add(key);
7913
8314
  return true;
7914
8315
  });
8316
+ } else if (useProviderAll) {
8317
+ const routableProvider = providersForTarget(catalog, "claude-app").find(
8318
+ (lp) => lp.id === activeProvider.id
8319
+ );
8320
+ const allServerModels = localProvidersToServerModels(
8321
+ routableProvider ? [routableProvider] : [activeProvider]
8322
+ );
8323
+ const cloudCodeIndices = allServerModels.map((m, i) => m.modelFormat === "cloud-code" ? i : -1).filter((i) => i >= 0);
8324
+ if (cloudCodeIndices.length > 0 && activeProvider.apiKey) {
8325
+ const providerData = activeProvider.providerData ?? {};
8326
+ const cloudCodeModels = cloudCodeIndices.map((i) => allServerModels[i]);
8327
+ const cloudRoutes = cloudCodeModels.map(
8328
+ (model) => buildCloudCodeProxyRoute(
8329
+ { id: model.id, name: model.name, modelFormat: "cloud-code" },
8330
+ activeProvider.apiKey,
8331
+ providerData
8332
+ )
8333
+ );
8334
+ const startingAlias = cloudRoutes[0].aliasId;
8335
+ cloudCodeBackend = await startCloudCodeCatalogBackend(
8336
+ cloudRoutes,
8337
+ startingAlias,
8338
+ trace,
8339
+ "claude-desktop"
8340
+ );
8341
+ const backend = cloudCodeBackend;
8342
+ for (let idx of cloudCodeIndices) {
8343
+ const m = allServerModels[idx];
8344
+ allServerModels[idx] = {
8345
+ ...m,
8346
+ modelFormat: "anthropic",
8347
+ baseUrl: `http://127.0.0.1:${backend.port}`,
8348
+ apiBaseUrl: void 0,
8349
+ apiKey: backend.token,
8350
+ completionsUrl: void 0,
8351
+ authType: void 0,
8352
+ oauthAccountId: void 0,
8353
+ headers: void 0
8354
+ };
8355
+ }
8356
+ }
8357
+ const seen = /* @__PURE__ */ new Set();
8358
+ serverModels = allServerModels.filter((m) => {
8359
+ const key = `${m.providerId}:${m.id}`;
8360
+ if (seen.has(key)) return false;
8361
+ seen.add(key);
8362
+ return true;
8363
+ });
7915
8364
  } else if (selectedModel.modelFormat === "cloud-code") {
7916
8365
  const providerData = activeProvider.providerData ?? {};
7917
8366
  const cloudRoute = buildCloudCodeProxyRoute(selectedModel, activeProvider.apiKey, providerData);
@@ -7946,7 +8395,10 @@ async function runClaudeAppCommand(args, boot) {
7946
8395
  catalog: createGatewayModelCatalog(serverModels, { maskGatewayIds: true }),
7947
8396
  backends: BACKENDS,
7948
8397
  gateway: { maskGatewayIds: true },
7949
- debugLogPath
8398
+ debugLogPath,
8399
+ // Claude Desktop embeds the gateway router rather than running
8400
+ // `anygate server`, so attribute its traffic to the app, not 'gateway'.
8401
+ app: "claude-desktop"
7950
8402
  });
7951
8403
  uuid = writeAnygateIConfig(proxyHandle.port);
7952
8404
  writeSessionLock2({
@@ -7983,6 +8435,10 @@ ${pc10.green("\u2714")} Proxy started on port ${proxyHandle.port}`);
7983
8435
  ${pc10.bold("Claude Desktop 3P Mode Active")}`);
7984
8436
  if (useFavorites) {
7985
8437
  console.log(`${pc10.dim("Catalog:")} Favorite models only`);
8438
+ } else if (useProviderAll) {
8439
+ console.log(
8440
+ `${pc10.dim("Catalog:")} All ${activeProvider.name} models (${serverModels.length})`
8441
+ );
7986
8442
  } else {
7987
8443
  console.log(`${pc10.dim("Model:")} ${selectedModel.id}`);
7988
8444
  console.log(`${pc10.dim("Provider:")} ${activeProvider.name}`);
@@ -8015,7 +8471,7 @@ ${pc10.bold("Claude Desktop 3P Mode Active")}`);
8015
8471
  // src/cli/claude-app.ts
8016
8472
  async function handleClaudeAppCommand(parsed) {
8017
8473
  if (parsed.showVersion) {
8018
- const { VERSION: VERSION2 } = await import("./constants-GW5BAY6G.js");
8474
+ const { VERSION: VERSION2 } = await import("./constants-WLMOLKEO.js");
8019
8475
  console.log(VERSION2);
8020
8476
  return 0;
8021
8477
  }
@@ -8040,7 +8496,8 @@ This command launches the Claude Desktop app with anygate's provider registry.
8040
8496
  }
8041
8497
  return runClaudeAppCommand(parsed.claudeArgs ?? [], {
8042
8498
  launchProvider: parsed.launchProvider,
8043
- launchModel: parsed.launchModel
8499
+ launchModel: parsed.launchModel,
8500
+ launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
8044
8501
  });
8045
8502
  }
8046
8503
 
@@ -8933,7 +9390,8 @@ async function rewriteGeminiBackendRoutes(routes, launchModelId, trace) {
8933
9390
  backendUrl: `http://127.0.0.1:${backend.port}`,
8934
9391
  apiKey: backend.token
8935
9392
  }),
8936
- trace
9393
+ trace,
9394
+ "gemini"
8937
9395
  );
8938
9396
  if (!partitioned.backend) {
8939
9397
  return { routes, launchModelId, backend: null };
@@ -9013,8 +9471,9 @@ async function runGeminiCommand(geminiArgs, trace = false, launch = {}) {
9013
9471
  const agentStdout = wantsCleanAgentStdout("gemini", passthroughArgs);
9014
9472
  setAgentStdoutMode(agentStdout);
9015
9473
  const prefs = loadPreferences();
9474
+ const launchAllModels = Boolean(launch.launchAllModels || launch.launchModel === "All");
9016
9475
  const launchPlan = planLaunchWizard({
9017
- explicit: { providerId: launch.launchProvider, modelId: launch.launchModel },
9476
+ explicit: launchAllModels ? { providerId: launch.launchProvider, allModels: true } : { providerId: launch.launchProvider, modelId: launch.launchModel },
9018
9477
  childArgs: passthroughArgs,
9019
9478
  agent: "gemini",
9020
9479
  prefs
@@ -9209,6 +9668,13 @@ Error: ${launchPlan.error}
9209
9668
  if (!agentStdout) {
9210
9669
  p13.log.info(`Gemini proxy started on port ${proxyHandle.port}`);
9211
9670
  p13.log.info(`\u{1F4A1} Type ${pc11.bold(".model <id>")} in the chat to switch models mid-session.`);
9671
+ if (launchAllModels) {
9672
+ p13.log.info(
9673
+ pc11.dim(
9674
+ `All ${activeProvider.models.length} ${activeProvider.name} models are available \u2014 type .model <id> to switch.`
9675
+ )
9676
+ );
9677
+ }
9212
9678
  }
9213
9679
  let exitCode = 1;
9214
9680
  try {
@@ -9230,7 +9696,7 @@ Error: ${launchPlan.error}
9230
9696
  // src/cli/gemini.ts
9231
9697
  async function handleGeminiCommand(parsed) {
9232
9698
  if (parsed.showVersion) {
9233
- const { VERSION: VERSION2 } = await import("./constants-GW5BAY6G.js");
9699
+ const { VERSION: VERSION2 } = await import("./constants-WLMOLKEO.js");
9234
9700
  console.log(VERSION2);
9235
9701
  return 0;
9236
9702
  }
@@ -9240,7 +9706,8 @@ async function handleGeminiCommand(parsed) {
9240
9706
  }
9241
9707
  return runGeminiCommand(parsed.claudeArgs ?? [], parsed.trace ?? false, {
9242
9708
  launchProvider: parsed.launchProvider,
9243
- launchModel: parsed.launchModel
9709
+ launchModel: parsed.launchModel,
9710
+ launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
9244
9711
  });
9245
9712
  }
9246
9713
 
@@ -12255,6 +12722,15 @@ async function resolveAntigravityLaunch(prefs, boot) {
12255
12722
  p14.log.info(pc12.dim("Run anygate providers add or import to get started."));
12256
12723
  return null;
12257
12724
  }
12725
+ if (boot?.launchProvider && boot?.launchAllModels) {
12726
+ const provider = allProviders.find((p18) => p18.id === boot.launchProvider);
12727
+ if (!provider) {
12728
+ p14.log.error(`Provider not found: ${boot.launchProvider}`);
12729
+ return null;
12730
+ }
12731
+ const model = provider.models[0];
12732
+ return { provider, model, allProviders, allModels: true };
12733
+ }
12258
12734
  if (boot?.launchProvider && boot?.launchModel) {
12259
12735
  const provider = allProviders.find((p18) => p18.id === boot.launchProvider);
12260
12736
  if (!provider) {
@@ -12311,11 +12787,15 @@ async function resolveAntigravityLaunch(prefs, boot) {
12311
12787
  }
12312
12788
  }
12313
12789
  async function resolveAndBuildRoutes(provider, model, allProviders, prefs, opts) {
12790
+ const allModelsFavorites = opts.allModels ? provider.models.map((m) => ({
12791
+ providerId: provider.id,
12792
+ modelId: m.id
12793
+ })) : [];
12314
12794
  const result = await resolveAntigravityLaunchRoutes({
12315
12795
  provider,
12316
12796
  model,
12317
12797
  allProviders,
12318
- favorites: prefs.antigravityCliFavoriteModels ?? [],
12798
+ favorites: opts.allModels ? allModelsFavorites : prefs.antigravityCliFavoriteModels ?? [],
12319
12799
  maxRoutes: opts.maxRoutes
12320
12800
  });
12321
12801
  if (!result) {
@@ -12429,7 +12909,8 @@ async function launchWithSelection(selection, prefs, opts, trace, tracePrefix, b
12429
12909
  maxRoutes: routeLimit,
12430
12910
  validatedSlotCount: routeLimit,
12431
12911
  pauseForCapacityWarning: opts.pauseForCapacityWarning ?? false,
12432
- childArgs: opts.childArgs ?? []
12912
+ childArgs: opts.childArgs ?? [],
12913
+ allModels: selection.allModels
12433
12914
  });
12434
12915
  if (!routeResult) return 1;
12435
12916
  savePreferences({
@@ -12674,7 +13155,7 @@ Examples:
12674
13155
  `;
12675
13156
  async function handleAgyCommand(parsed) {
12676
13157
  if (parsed.showVersion) {
12677
- const { VERSION: VERSION2 } = await import("./constants-GW5BAY6G.js");
13158
+ const { VERSION: VERSION2 } = await import("./constants-WLMOLKEO.js");
12678
13159
  console.log(VERSION2);
12679
13160
  return 0;
12680
13161
  }
@@ -12684,12 +13165,13 @@ async function handleAgyCommand(parsed) {
12684
13165
  }
12685
13166
  return runAgyCommand(parsed.claudeArgs ?? [], parsed.trace ?? false, {
12686
13167
  launchProvider: parsed.launchProvider,
12687
- launchModel: parsed.launchModel
13168
+ launchModel: parsed.launchModel,
13169
+ launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
12688
13170
  });
12689
13171
  }
12690
13172
  async function handleAntigravityAppCommand(parsed) {
12691
13173
  if (parsed.showVersion) {
12692
- const { VERSION: VERSION2 } = await import("./constants-GW5BAY6G.js");
13174
+ const { VERSION: VERSION2 } = await import("./constants-WLMOLKEO.js");
12693
13175
  console.log(VERSION2);
12694
13176
  return 0;
12695
13177
  }
@@ -12699,12 +13181,13 @@ async function handleAntigravityAppCommand(parsed) {
12699
13181
  }
12700
13182
  return runAntigravityAppCommand(parsed.claudeArgs ?? [], parsed.trace ?? false, {
12701
13183
  launchProvider: parsed.launchProvider,
12702
- launchModel: parsed.launchModel
13184
+ launchModel: parsed.launchModel,
13185
+ launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
12703
13186
  });
12704
13187
  }
12705
13188
  async function handleAntigravityIdeCommand(parsed) {
12706
13189
  if (parsed.showVersion) {
12707
- const { VERSION: VERSION2 } = await import("./constants-GW5BAY6G.js");
13190
+ const { VERSION: VERSION2 } = await import("./constants-WLMOLKEO.js");
12708
13191
  console.log(VERSION2);
12709
13192
  return 0;
12710
13193
  }
@@ -12714,7 +13197,8 @@ async function handleAntigravityIdeCommand(parsed) {
12714
13197
  }
12715
13198
  return runAntigravityIdeCommand(parsed.claudeArgs ?? [], parsed.trace ?? false, {
12716
13199
  launchProvider: parsed.launchProvider,
12717
- launchModel: parsed.launchModel
13200
+ launchModel: parsed.launchModel,
13201
+ launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
12718
13202
  });
12719
13203
  }
12720
13204
 
@@ -12809,7 +13293,7 @@ Options:
12809
13293
  `);
12810
13294
  return 0;
12811
13295
  }
12812
- const { runUiCommand } = await import("./command-PFFQI5YC.js");
13296
+ const { runUiCommand } = await import("./command-XIDZGWNR.js");
12813
13297
  return runUiCommand({ trace: parsed.trace });
12814
13298
  }
12815
13299
 
@@ -13238,7 +13722,7 @@ async function runValidateSubcommand(parsed) {
13238
13722
  // src/cli/providers.ts
13239
13723
  async function handleProvidersCommand(parsed) {
13240
13724
  if (parsed.showVersion) {
13241
- const { VERSION: VERSION2 } = await import("./constants-GW5BAY6G.js");
13725
+ const { VERSION: VERSION2 } = await import("./constants-WLMOLKEO.js");
13242
13726
  console.log(VERSION2);
13243
13727
  return 0;
13244
13728
  }
@@ -13351,7 +13835,7 @@ async function runDoctorCommand(_dryRun) {
13351
13835
  // src/cli/doctor.ts
13352
13836
  async function handleDoctorCommand(parsed) {
13353
13837
  if (parsed.showVersion) {
13354
- const { VERSION: VERSION2 } = await import("./constants-GW5BAY6G.js");
13838
+ const { VERSION: VERSION2 } = await import("./constants-WLMOLKEO.js");
13355
13839
  console.log(VERSION2);
13356
13840
  return 0;
13357
13841
  }
@@ -13491,7 +13975,7 @@ function runCompletionsCommand(shellArg) {
13491
13975
  // src/cli/completions.ts
13492
13976
  async function handleCompletionsCommand(parsed) {
13493
13977
  if (parsed.showVersion) {
13494
- const { VERSION: VERSION2 } = await import("./constants-GW5BAY6G.js");
13978
+ const { VERSION: VERSION2 } = await import("./constants-WLMOLKEO.js");
13495
13979
  console.log(VERSION2);
13496
13980
  return 0;
13497
13981
  }
@@ -13518,18 +14002,11 @@ Examples:
13518
14002
 
13519
14003
  // src/apps/shared/self-update.ts
13520
14004
  import pc17 from "picocolors";
13521
- import { spawn as spawn5, execFileSync as execFileSync4 } from "child_process";
14005
+ import { spawn as spawn5 } from "child_process";
13522
14006
  import * as p17 from "@clack/prompts";
13523
- function resolveNpmBin() {
13524
- if (process.platform === "win32") {
13525
- try {
13526
- 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"));
13527
- if (found) return found;
13528
- } catch {
13529
- }
13530
- return "npm.cmd";
13531
- }
13532
- return "npm";
14007
+ var INSTALL_ARGS = ["install", "-g", "anygate@latest"];
14008
+ function resolveNpmSpawn() {
14009
+ return { bin: "npm", shell: process.platform === "win32" };
13533
14010
  }
13534
14011
  async function runUpdateCommand(dryRun) {
13535
14012
  const update = await checkForUpdates();
@@ -13540,9 +14017,9 @@ async function runUpdateCommand(dryRun) {
13540
14017
  p17.log.info(
13541
14018
  `Update available: ${pc17.cyan(`v${update.currentVersion}`)} \u2192 ${pc17.green(`v${update.latestVersion}`)}`
13542
14019
  );
13543
- const npmBin = resolveNpmBin();
14020
+ const { bin: npmBin, shell } = resolveNpmSpawn();
13544
14021
  if (dryRun) {
13545
- p17.log.step(`Would run: ${pc17.bold(`${npmBin} install -g anygate@latest`)}`);
14022
+ p17.log.step(`Would run: ${pc17.bold(`${npmBin} ${INSTALL_ARGS.join(" ")}`)}`);
13546
14023
  p17.log.warn("Dry run \u2014 no changes made.");
13547
14024
  return 0;
13548
14025
  }
@@ -13554,17 +14031,27 @@ async function runUpdateCommand(dryRun) {
13554
14031
  p17.log.info(`Update skipped. Run ${pc17.cyan(UPDATE_COMMAND)} later if you change your mind.`);
13555
14032
  return 0;
13556
14033
  }
13557
- p17.log.info(`Running ${pc17.cyan(`${npmBin} install -g anygate@latest`)}...`);
13558
- const child = spawn5(npmBin, ["install", "-g", "anygate@latest"], {
14034
+ p17.log.info(`Running ${pc17.cyan(`${npmBin} ${INSTALL_ARGS.join(" ")}`)}...`);
14035
+ const child = spawn5(npmBin, [...INSTALL_ARGS], {
13559
14036
  stdio: "inherit",
14037
+ shell,
13560
14038
  windowsHide: true
13561
14039
  });
13562
14040
  return new Promise((resolve) => {
14041
+ let settled = false;
14042
+ const settle = (code) => {
14043
+ settled = true;
14044
+ resolve(code);
14045
+ };
13563
14046
  child.on("error", (err) => {
13564
- p17.log.error(`Failed to start npm: ${err instanceof Error ? err.message : String(err)}`);
13565
- resolve(1);
14047
+ if (settled) return;
14048
+ const msg = err instanceof Error ? err.message : String(err);
14049
+ p17.log.error(`Could not start npm: ${msg}`);
14050
+ p17.log.info(`Update anygate manually with: ${pc17.cyan(UPDATE_COMMAND)}`);
14051
+ settle(1);
13566
14052
  });
13567
14053
  child.on("close", (code) => {
14054
+ if (settled) return;
13568
14055
  if (code === 0) {
13569
14056
  p17.log.success(
13570
14057
  "anygate updated. Restart your shell or re-run anygate to use the new version."
@@ -13572,7 +14059,7 @@ async function runUpdateCommand(dryRun) {
13572
14059
  } else {
13573
14060
  p17.log.error(`Update failed (exit ${code}). Try ${pc17.cyan(UPDATE_COMMAND)} manually.`);
13574
14061
  }
13575
- resolve(code ?? 1);
14062
+ settle(code ?? 1);
13576
14063
  });
13577
14064
  });
13578
14065
  }
@@ -13580,7 +14067,7 @@ async function runUpdateCommand(dryRun) {
13580
14067
  // src/cli/update.ts
13581
14068
  async function handleUpdateCommand(parsed) {
13582
14069
  if (parsed.showVersion) {
13583
- const { VERSION: VERSION2 } = await import("./constants-GW5BAY6G.js");
14070
+ const { VERSION: VERSION2 } = await import("./constants-WLMOLKEO.js");
13584
14071
  console.log(VERSION2);
13585
14072
  return 0;
13586
14073
  }
@@ -13646,6 +14133,10 @@ var STARTER_CLAUDE_FLAGS = /* @__PURE__ */ new Set([
13646
14133
  ]);
13647
14134
  var GATEWAY_LAUNCH_FLAGS = /* @__PURE__ */ new Set(["--provider", "--model"]);
13648
14135
  function parseGatewayLaunchFlag(arg, rest, index, parsed) {
14136
+ if (arg === "--all-models") {
14137
+ parsed.launchAllModels = true;
14138
+ return index;
14139
+ }
13649
14140
  if (arg === "--provider" || arg === "--model") {
13650
14141
  const value = rest[index + 1];
13651
14142
  if (!value || value.startsWith("-")) {