anygate 0.6.0 → 0.6.2
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/README.md +1 -1
- package/dist/{chunk-VGM6EBG4.js → chunk-4N4RDHGZ.js} +12 -3
- package/dist/{chunk-VGM6EBG4.js.map → chunk-4N4RDHGZ.js.map} +1 -1
- package/dist/{chunk-CRK6YGKY.js → chunk-EMBABL33.js} +210 -104
- package/dist/chunk-EMBABL33.js.map +1 -0
- package/dist/{chunk-QLHVQYQN.js → chunk-S5WL3M5G.js} +4 -2
- package/dist/{chunk-QLHVQYQN.js.map → chunk-S5WL3M5G.js.map} +1 -1
- package/dist/cli.js +746 -142
- package/dist/cli.js.map +1 -1
- package/dist/{command-PFFQI5YC.js → command-N3R2ZVVS.js} +237 -25
- package/dist/command-N3R2ZVVS.js.map +1 -0
- package/dist/{constants-GW5BAY6G.js → constants-U356SKNS.js} +2 -2
- package/dist/{provider-templates-CRQJII3Z.js → provider-templates-336QE7ZV.js} +2 -2
- package/dist/registry/data/templates/cohere.json +5 -2
- package/dist/registry/data/templates/fireworks.json +1 -1
- package/dist/registry/data/templates/sambanova.json +8 -7
- package/dist/ui/dist/assets/index-bNoUNC_v.css +1 -0
- package/dist/ui/dist/assets/index-q6tXB_gH.js +7 -0
- package/dist/ui/dist/index.html +2 -2
- package/package.json +3 -1
- package/dist/chunk-CRK6YGKY.js.map +0 -1
- package/dist/command-PFFQI5YC.js.map +0 -1
- package/dist/ui/dist/assets/index-D4hWZLit.css +0 -1
- package/dist/ui/dist/assets/index-DyxtUjA-.js +0 -7
- /package/dist/{constants-GW5BAY6G.js.map → constants-U356SKNS.js.map} +0 -0
- /package/dist/{provider-templates-CRQJII3Z.js.map → provider-templates-336QE7ZV.js.map} +0 -0
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,
|
|
@@ -31,6 +32,7 @@ import {
|
|
|
31
32
|
confirmLaunchMessage,
|
|
32
33
|
createGatewayModelCatalog,
|
|
33
34
|
createLanguageModel,
|
|
35
|
+
dedupeByKey,
|
|
34
36
|
deepMergeProviderOptions,
|
|
35
37
|
detectConflicts,
|
|
36
38
|
effectiveProviderBaseUrl,
|
|
@@ -171,7 +173,7 @@ import {
|
|
|
171
173
|
validateModels,
|
|
172
174
|
writeSecureLogLine,
|
|
173
175
|
zenRegistryStub
|
|
174
|
-
} from "./chunk-
|
|
176
|
+
} from "./chunk-EMBABL33.js";
|
|
175
177
|
import {
|
|
176
178
|
BACKENDS,
|
|
177
179
|
CONFLICTING_ENV_VARS,
|
|
@@ -179,14 +181,14 @@ import {
|
|
|
179
181
|
MAX_MODEL_CATALOG,
|
|
180
182
|
VERSION,
|
|
181
183
|
VERTEX_ANTHROPIC_NPM
|
|
182
|
-
} from "./chunk-
|
|
184
|
+
} from "./chunk-S5WL3M5G.js";
|
|
183
185
|
import {
|
|
184
186
|
filterTemplates,
|
|
185
187
|
getTemplateById,
|
|
186
188
|
listAddableTemplates,
|
|
187
189
|
listSupportedTemplates,
|
|
188
190
|
listVisibleOAuthTemplates
|
|
189
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-4N4RDHGZ.js";
|
|
190
192
|
import "./chunk-UT3JLF3M.js";
|
|
191
193
|
|
|
192
194
|
// src/cli.ts
|
|
@@ -2030,6 +2032,10 @@ function resolveLaunchTarget(explicit, prefs, agent) {
|
|
|
2030
2032
|
const slug = explicit.modelId ? parseModelSlug(explicit.modelId) : null;
|
|
2031
2033
|
const providerId = explicit.providerId ?? slug?.providerId ?? (agent === "claude" ? prefs.lastProvider : agent === "codex" ? prefs.lastCodexProvider : agent === "antigravity" ? prefs.lastAntigravityProvider : prefs.lastGeminiProvider);
|
|
2032
2034
|
const modelId = slug?.modelId ?? explicit.modelId ?? (agent === "claude" ? prefs.lastModel : agent === "codex" ? prefs.lastCodexModel : agent === "antigravity" ? prefs.lastAntigravityModel : prefs.lastGeminiModel);
|
|
2035
|
+
if (explicit.allModels) {
|
|
2036
|
+
if (!providerId) return null;
|
|
2037
|
+
return { providerId, allModels: true };
|
|
2038
|
+
}
|
|
2033
2039
|
if (!providerId || !modelId) return null;
|
|
2034
2040
|
return { providerId, modelId };
|
|
2035
2041
|
}
|
|
@@ -2042,6 +2048,7 @@ function findProviderAndModel(providers, target) {
|
|
|
2042
2048
|
return { provider, model };
|
|
2043
2049
|
}
|
|
2044
2050
|
function hasCompleteExplicitLaunch(explicit) {
|
|
2051
|
+
if (explicit.allModels && explicit.providerId) return true;
|
|
2045
2052
|
if (explicit.providerId && explicit.modelId) return true;
|
|
2046
2053
|
if (explicit.modelId) {
|
|
2047
2054
|
const slug = parseModelSlug(explicit.modelId);
|
|
@@ -2059,16 +2066,16 @@ function planLaunchWizard(opts) {
|
|
|
2059
2066
|
return {
|
|
2060
2067
|
skip: false,
|
|
2061
2068
|
target: null,
|
|
2062
|
-
error: "
|
|
2069
|
+
error: "A provider is required \u2014 use --provider, --all-models, or a saved preference."
|
|
2063
2070
|
};
|
|
2064
2071
|
}
|
|
2065
2072
|
return { skip: true, target };
|
|
2066
2073
|
}
|
|
2067
|
-
if (explicit.providerId || explicit.modelId) {
|
|
2074
|
+
if (explicit.providerId || explicit.modelId || explicit.allModels) {
|
|
2068
2075
|
return {
|
|
2069
2076
|
skip: false,
|
|
2070
2077
|
target: null,
|
|
2071
|
-
error: "Both --provider and --model are required (or use provider__model slug with --model)."
|
|
2078
|
+
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
2079
|
};
|
|
2073
2080
|
}
|
|
2074
2081
|
if (nonInteractive) {
|
|
@@ -2203,11 +2210,11 @@ async function runProvidersRemove(id, interactive = false) {
|
|
|
2203
2210
|
return 1;
|
|
2204
2211
|
}
|
|
2205
2212
|
if (interactive) {
|
|
2206
|
-
const
|
|
2213
|
+
const confirm12 = await p5.confirm({
|
|
2207
2214
|
message: `Remove ${provider.name} (${id})?`,
|
|
2208
2215
|
initialValue: false
|
|
2209
2216
|
});
|
|
2210
|
-
if (p5.isCancel(
|
|
2217
|
+
if (p5.isCancel(confirm12) || !confirm12) {
|
|
2211
2218
|
p5.cancel("Cancelled.");
|
|
2212
2219
|
return 0;
|
|
2213
2220
|
}
|
|
@@ -2503,6 +2510,36 @@ ${pc4.bold("Usage:")}
|
|
|
2503
2510
|
anygate providers refresh-models Refresh model catalog for all/specific provider
|
|
2504
2511
|
anygate providers auth <id> Sign in with OAuth (xAI, OpenAI, GitHub Copilot, \u2026)`;
|
|
2505
2512
|
}
|
|
2513
|
+
async function promptTemplateBaseUrl(template) {
|
|
2514
|
+
const entered = await p5.text({
|
|
2515
|
+
message: template.urlPrompt ?? "API Base URL:",
|
|
2516
|
+
placeholder: template.urlPlaceholder ?? template.defaultBaseUrl,
|
|
2517
|
+
defaultValue: template.defaultBaseUrl ?? "",
|
|
2518
|
+
validate: (v) => v.trim() || template.defaultBaseUrl ? void 0 : "URL is required"
|
|
2519
|
+
});
|
|
2520
|
+
if (p5.isCancel(entered)) return null;
|
|
2521
|
+
const baseUrl = String(entered ?? "").trim() || (template.defaultBaseUrl ?? "");
|
|
2522
|
+
if (!baseUrl) return null;
|
|
2523
|
+
let allowInsecureLocal = false;
|
|
2524
|
+
if (/^http:\/\//i.test(baseUrl)) {
|
|
2525
|
+
p5.log.warn(
|
|
2526
|
+
"HTTP is not encrypted. Only use it for a trusted local or LAN server, like Ollama on your own network."
|
|
2527
|
+
);
|
|
2528
|
+
const allowLocal = await p5.confirm({
|
|
2529
|
+
message: "Allow insecure HTTP for this local/LAN server?",
|
|
2530
|
+
initialValue: true
|
|
2531
|
+
});
|
|
2532
|
+
if (p5.isCancel(allowLocal)) return null;
|
|
2533
|
+
allowInsecureLocal = allowLocal === true;
|
|
2534
|
+
}
|
|
2535
|
+
const valid = await validateCustomEndpointUrl(baseUrl, { allowInsecureLocal });
|
|
2536
|
+
if (!valid.ok || !valid.normalizedUrl) {
|
|
2537
|
+
p5.log.error(valid.error ?? "Invalid URL.");
|
|
2538
|
+
if (valid.hint) p5.log.info(valid.hint);
|
|
2539
|
+
return null;
|
|
2540
|
+
}
|
|
2541
|
+
return valid.normalizedUrl;
|
|
2542
|
+
}
|
|
2506
2543
|
async function runTemplateAddFlow(t) {
|
|
2507
2544
|
const template = t ?? await pickTemplateFromCatalog();
|
|
2508
2545
|
if (!template) return 0;
|
|
@@ -2511,9 +2548,16 @@ async function runTemplateAddFlow(t) {
|
|
|
2511
2548
|
});
|
|
2512
2549
|
if (p5.isCancel(inputKey)) return 0;
|
|
2513
2550
|
const apiKey = String(inputKey ?? "").trim();
|
|
2514
|
-
|
|
2551
|
+
let baseUrl;
|
|
2552
|
+
if (template.urlPrompt) {
|
|
2553
|
+
const collected = await promptTemplateBaseUrl(template);
|
|
2554
|
+
if (!collected) return 1;
|
|
2555
|
+
baseUrl = collected;
|
|
2556
|
+
}
|
|
2557
|
+
const result = await addProviderFromTemplate(template, apiKey, { baseUrl });
|
|
2515
2558
|
if (!result.added) {
|
|
2516
2559
|
if (result.error) p5.log.error(result.error);
|
|
2560
|
+
if (result.hint) p5.log.info(result.hint);
|
|
2517
2561
|
return 1;
|
|
2518
2562
|
}
|
|
2519
2563
|
logConnected(template.name, result.modelCount ?? 0);
|
|
@@ -2760,7 +2804,10 @@ async function runProvidersCommand(args) {
|
|
|
2760
2804
|
|
|
2761
2805
|
// src/cli/claude.ts
|
|
2762
2806
|
async function handleClaudeCommand(parsed) {
|
|
2763
|
-
const { dryRun, setup, trace, launchProvider
|
|
2807
|
+
const { dryRun, setup, trace, launchProvider } = parsed;
|
|
2808
|
+
const launchAllModels = parsed.launchAllModels || parsed.launchModel === "All";
|
|
2809
|
+
const launchModel = launchAllModels && !parsed.launchModel ? "All" : parsed.launchModel;
|
|
2810
|
+
const launchWithClaude = Boolean(parsed.launchWithClaude);
|
|
2764
2811
|
const claudeArgs = normalizeClaudeAgentArgs(parsed.claudeArgs);
|
|
2765
2812
|
const agentStdout = wantsCleanAgentStdout("claude", claudeArgs);
|
|
2766
2813
|
setAgentStdoutMode(agentStdout);
|
|
@@ -2775,7 +2822,7 @@ async function handleClaudeCommand(parsed) {
|
|
|
2775
2822
|
const conflicts = detectConflicts();
|
|
2776
2823
|
const favorites = dryRun ? [] : prefs.favoriteModels ?? [];
|
|
2777
2824
|
const launchPlan = planLaunchWizard({
|
|
2778
|
-
explicit: { providerId: launchProvider, modelId: launchModel },
|
|
2825
|
+
explicit: launchAllModels ? { providerId: launchProvider, allModels: true } : { providerId: launchProvider, modelId: launchModel },
|
|
2779
2826
|
childArgs: claudeArgs,
|
|
2780
2827
|
agent: "claude",
|
|
2781
2828
|
prefs
|
|
@@ -2786,7 +2833,13 @@ Error: ${launchPlan.error}
|
|
|
2786
2833
|
`));
|
|
2787
2834
|
return 1;
|
|
2788
2835
|
}
|
|
2789
|
-
|
|
2836
|
+
let catalogMode = false;
|
|
2837
|
+
const hasFavorites = favorites.length > 0;
|
|
2838
|
+
if (launchPlan.skip && launchPlan.target) {
|
|
2839
|
+
if (launchPlan.target.allModels) {
|
|
2840
|
+
catalogMode = "provider-all";
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2790
2843
|
if (!agentStdout) gateIntro("Claude Code");
|
|
2791
2844
|
if (setup && !dryRun && !agentStdout) {
|
|
2792
2845
|
p6.log.info("Provider setup now lives in anygate providers \u2014 opening that next is recommended.");
|
|
@@ -2836,7 +2889,7 @@ Error: ${launchPlan.error}
|
|
|
2836
2889
|
}
|
|
2837
2890
|
return baseOption;
|
|
2838
2891
|
});
|
|
2839
|
-
if (
|
|
2892
|
+
if (hasFavorites) {
|
|
2840
2893
|
providerOptions.unshift({
|
|
2841
2894
|
value: "__favorites__",
|
|
2842
2895
|
label: "\u2B50 Favorites Catalog",
|
|
@@ -2847,19 +2900,35 @@ Error: ${launchPlan.error}
|
|
|
2847
2900
|
let activeProvider;
|
|
2848
2901
|
let selectedModel;
|
|
2849
2902
|
if (launchPlan.skip && launchPlan.target) {
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
`Provider
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2903
|
+
if (launchPlan.target.allModels) {
|
|
2904
|
+
const resolvedProvider = allProviders.find((lp) => lp.id === launchPlan.target.providerId);
|
|
2905
|
+
if (!resolvedProvider) {
|
|
2906
|
+
p6.log.error(`Provider not found: ${launchPlan.target.providerId}`);
|
|
2907
|
+
return 1;
|
|
2908
|
+
}
|
|
2909
|
+
activeProvider = resolvedProvider;
|
|
2910
|
+
selectedModel = activeProvider.models[0];
|
|
2911
|
+
catalogMode = "provider-all";
|
|
2912
|
+
if (!agentStdout) {
|
|
2913
|
+
p6.log.step(`Using all ${activeProvider.models.length} models from ${activeProvider.name}`);
|
|
2914
|
+
}
|
|
2915
|
+
if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
|
|
2916
|
+
} else {
|
|
2917
|
+
const resolved = findProviderAndModel(allProviders, launchPlan.target);
|
|
2918
|
+
if (!resolved) {
|
|
2919
|
+
p6.log.error(
|
|
2920
|
+
`Provider/model not found: ${launchPlan.target.providerId} / ${launchPlan.target.modelId}`
|
|
2921
|
+
);
|
|
2922
|
+
return 1;
|
|
2923
|
+
}
|
|
2924
|
+
activeProvider = resolved.provider;
|
|
2925
|
+
selectedModel = resolved.model;
|
|
2926
|
+
catalogMode = false;
|
|
2927
|
+
if (!agentStdout) {
|
|
2928
|
+
p6.log.step(`Using ${selectedModel.name || selectedModel.id} (${activeProvider.name})`);
|
|
2929
|
+
}
|
|
2930
|
+
if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
|
|
2861
2931
|
}
|
|
2862
|
-
if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
|
|
2863
2932
|
} else {
|
|
2864
2933
|
let currentInitialProvider = initialProvider;
|
|
2865
2934
|
while (true) {
|
|
@@ -2901,6 +2970,7 @@ Error: ${launchPlan.error}
|
|
|
2901
2970
|
const sel = available[Number(pickedIdx)];
|
|
2902
2971
|
activeProvider = sel.provider;
|
|
2903
2972
|
selectedModel = sel.model;
|
|
2973
|
+
catalogMode = "favorites";
|
|
2904
2974
|
if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
|
|
2905
2975
|
break;
|
|
2906
2976
|
} else {
|
|
@@ -2931,6 +3001,32 @@ Error: ${launchPlan.error}
|
|
|
2931
3001
|
} else {
|
|
2932
3002
|
activeProvider = selectedProvider;
|
|
2933
3003
|
}
|
|
3004
|
+
const modelModeChoice = await p6.select({
|
|
3005
|
+
message: `Launch mode for ${activeProvider.name}?`,
|
|
3006
|
+
options: [
|
|
3007
|
+
{
|
|
3008
|
+
value: "specific",
|
|
3009
|
+
label: "One model",
|
|
3010
|
+
hint: "Pick a specific model from this provider"
|
|
3011
|
+
},
|
|
3012
|
+
{
|
|
3013
|
+
value: "all",
|
|
3014
|
+
label: `All models (${activeProvider.models.length})`,
|
|
3015
|
+
hint: "Every model from this provider in the /model switcher"
|
|
3016
|
+
},
|
|
3017
|
+
navOption("__back__", "\u2190 Back", "Choose a different provider")
|
|
3018
|
+
]
|
|
3019
|
+
});
|
|
3020
|
+
if (p6.isCancel(modelModeChoice) || modelModeChoice === "__back__") {
|
|
3021
|
+
currentInitialProvider = activeProvider.id;
|
|
3022
|
+
continue;
|
|
3023
|
+
}
|
|
3024
|
+
if (modelModeChoice === "all") {
|
|
3025
|
+
catalogMode = "provider-all";
|
|
3026
|
+
selectedModel = activeProvider.models[0];
|
|
3027
|
+
if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
|
|
3028
|
+
break;
|
|
3029
|
+
}
|
|
2934
3030
|
const pickedModelResult = await pickLocalModel(activeProvider, conflicts, prefs);
|
|
2935
3031
|
if (pickedModelResult === "back") {
|
|
2936
3032
|
currentInitialProvider = activeProvider.id;
|
|
@@ -2938,13 +3034,79 @@ Error: ${launchPlan.error}
|
|
|
2938
3034
|
}
|
|
2939
3035
|
if (!pickedModelResult) return 0;
|
|
2940
3036
|
selectedModel = pickedModelResult;
|
|
3037
|
+
catalogMode = false;
|
|
2941
3038
|
if (!dryRun) recordLaunchSelection("claude", activeProvider.id, selectedModel.id, prefs);
|
|
2942
3039
|
break;
|
|
2943
3040
|
}
|
|
2944
3041
|
}
|
|
2945
3042
|
}
|
|
2946
3043
|
const localProviders = catalog.length > 0 ? catalog : null;
|
|
2947
|
-
|
|
3044
|
+
const claudeCodeProvider = allProviders.find(
|
|
3045
|
+
(lp) => lp.id === "claude-code" && lp.inRegistry && lp.models.length > 0
|
|
3046
|
+
);
|
|
3047
|
+
const claudeMixEligible = catalogMode === false && activeProvider.id !== "claude-code" && Boolean(claudeCodeProvider);
|
|
3048
|
+
if (claudeMixEligible && launchWithClaude) {
|
|
3049
|
+
catalogMode = "provider-plus-claude";
|
|
3050
|
+
} else if (claudeMixEligible && !agentStdout && !dryRun && !launchPlan.skip) {
|
|
3051
|
+
const keepClaude = await p6.confirm({
|
|
3052
|
+
message: "Keep your normal Claude models available too?",
|
|
3053
|
+
active: `Yes \u2014 add ${claudeCodeProvider.models.length} Anthropic-subscription models to /model`,
|
|
3054
|
+
inactive: "No \u2014 launch with the anygate model only",
|
|
3055
|
+
initialValue: true
|
|
3056
|
+
});
|
|
3057
|
+
if (p6.isCancel(keepClaude)) {
|
|
3058
|
+
p6.cancel("Cancelled.");
|
|
3059
|
+
return 0;
|
|
3060
|
+
}
|
|
3061
|
+
if (keepClaude) catalogMode = "provider-plus-claude";
|
|
3062
|
+
} else if (launchWithClaude && !claudeCodeProvider && !agentStdout) {
|
|
3063
|
+
p6.log.warn(
|
|
3064
|
+
"Ignoring --with-claude: no authenticated Claude Code provider found. Run `anygate providers auth claude-code` first."
|
|
3065
|
+
);
|
|
3066
|
+
}
|
|
3067
|
+
if (catalogMode === "provider-plus-claude") {
|
|
3068
|
+
const resolveRoute = makeRouteResolver(localProviders);
|
|
3069
|
+
const startingRoute = resolveRoute(activeProvider.id, selectedModel.id) ?? null;
|
|
3070
|
+
if (!startingRoute) {
|
|
3071
|
+
p6.log.error("Could not resolve a proxy route for the selected model.");
|
|
3072
|
+
return 1;
|
|
3073
|
+
}
|
|
3074
|
+
const claudeRoutes = (claudeCodeProvider?.models ?? []).map((m) => resolveRoute("claude-code", m.id)).filter((r) => r !== void 0);
|
|
3075
|
+
const { routes: favoriteRoutes } = buildCatalogRoutes(startingRoute, favorites, resolveRoute);
|
|
3076
|
+
const catalogRoutes = dedupeByKey(
|
|
3077
|
+
[
|
|
3078
|
+
startingRoute,
|
|
3079
|
+
...claudeRoutes,
|
|
3080
|
+
...favoriteRoutes.filter((r) => r.aliasId !== startingRoute.aliasId)
|
|
3081
|
+
],
|
|
3082
|
+
(r) => r.aliasId,
|
|
3083
|
+
MAX_MODEL_CATALOG
|
|
3084
|
+
);
|
|
3085
|
+
if (dryRun) {
|
|
3086
|
+
console.log("");
|
|
3087
|
+
console.log(pc5.bold(pc5.cyan(" DRY RUN \u2014 would execute (Anthropic + anygate mixed mode):")));
|
|
3088
|
+
console.log("");
|
|
3089
|
+
console.log(` ${pc5.bold("Provider:")} ${activeProvider.name}`);
|
|
3090
|
+
console.log(` ${pc5.bold("Starting model:")} ${selectedModel.id}`);
|
|
3091
|
+
console.log(
|
|
3092
|
+
` ${pc5.bold("Claude models:")} ${claudeRoutes.length} (from your Anthropic subscription)`
|
|
3093
|
+
);
|
|
3094
|
+
console.log(` ${pc5.bold("/model catalog:")} ${catalogRoutes.length} model(s)`);
|
|
3095
|
+
catalogRoutes.forEach((r) => console.log(` ${pc5.dim(r.displayName)}`));
|
|
3096
|
+
console.log("");
|
|
3097
|
+
console.log(pc5.dim(" (dry run complete \u2014 Claude Code was NOT launched)"));
|
|
3098
|
+
console.log("");
|
|
3099
|
+
return 0;
|
|
3100
|
+
}
|
|
3101
|
+
return launchClaudeViaCatalog(
|
|
3102
|
+
catalogRoutes,
|
|
3103
|
+
startingRoute,
|
|
3104
|
+
selectedModel.contextWindow,
|
|
3105
|
+
trace ?? false,
|
|
3106
|
+
claudeArgs
|
|
3107
|
+
);
|
|
3108
|
+
}
|
|
3109
|
+
if (catalogMode === "favorites") {
|
|
2948
3110
|
const resolveRoute = makeRouteResolver(localProviders);
|
|
2949
3111
|
const startingRoute = resolveRoute(activeProvider.id, selectedModel.id) ?? null;
|
|
2950
3112
|
if (!startingRoute) {
|
|
@@ -2993,6 +3155,35 @@ Error: ${launchPlan.error}
|
|
|
2993
3155
|
claudeArgs
|
|
2994
3156
|
);
|
|
2995
3157
|
}
|
|
3158
|
+
if (catalogMode === "provider-all") {
|
|
3159
|
+
const resolveRoute = makeRouteResolver(localProviders);
|
|
3160
|
+
const startingRoute = resolveRoute(activeProvider.id, selectedModel.id) ?? null;
|
|
3161
|
+
if (!startingRoute) {
|
|
3162
|
+
p6.log.error("Could not resolve a proxy route for the starting model.");
|
|
3163
|
+
return 1;
|
|
3164
|
+
}
|
|
3165
|
+
const catalogRoutes = buildProviderAllModelRoutes(activeProvider, startingRoute, resolveRoute);
|
|
3166
|
+
if (dryRun) {
|
|
3167
|
+
console.log("");
|
|
3168
|
+
console.log(pc5.bold(pc5.cyan(" DRY RUN \u2014 would execute (provider catalog mode):")));
|
|
3169
|
+
console.log("");
|
|
3170
|
+
console.log(` ${pc5.bold("Provider:")} ${activeProvider.name}`);
|
|
3171
|
+
console.log(` ${pc5.bold("Starting model:")} ${selectedModel.id}`);
|
|
3172
|
+
console.log(` ${pc5.bold("/model catalog:")} ${catalogRoutes.length} model(s)`);
|
|
3173
|
+
catalogRoutes.forEach((r) => console.log(` ${pc5.dim(r.displayName)}`));
|
|
3174
|
+
console.log("");
|
|
3175
|
+
console.log(pc5.dim(" (dry run complete \u2014 Claude Code was NOT launched)"));
|
|
3176
|
+
console.log("");
|
|
3177
|
+
return 0;
|
|
3178
|
+
}
|
|
3179
|
+
return launchClaudeViaCatalog(
|
|
3180
|
+
catalogRoutes,
|
|
3181
|
+
startingRoute,
|
|
3182
|
+
selectedModel.contextWindow,
|
|
3183
|
+
trace ?? false,
|
|
3184
|
+
claudeArgs
|
|
3185
|
+
);
|
|
3186
|
+
}
|
|
2996
3187
|
if (dryRun) {
|
|
2997
3188
|
const formatDesc = selectedModel.modelFormat === "anthropic" ? "direct passthrough" : "via SDK adapter proxy";
|
|
2998
3189
|
const endpoint = selectedModel.modelFormat === "anthropic" ? selectedModel.baseUrl ?? "(unknown)" : selectedModel.npm ?? "SDK";
|
|
@@ -3091,11 +3282,32 @@ Error: ${launchPlan.error}
|
|
|
3091
3282
|
selectedModel.contextWindow
|
|
3092
3283
|
);
|
|
3093
3284
|
} else if (selectedModel.modelFormat === "anthropic") {
|
|
3285
|
+
try {
|
|
3286
|
+
proxyHandle = await startProxy(
|
|
3287
|
+
selectedModel.baseUrl ?? "https://api.anthropic.com",
|
|
3288
|
+
selectedModel.id,
|
|
3289
|
+
trace ?? false,
|
|
3290
|
+
selectedModel.contextWindow,
|
|
3291
|
+
{
|
|
3292
|
+
providerId: activeProvider.id,
|
|
3293
|
+
authType: activeProvider.authType,
|
|
3294
|
+
providerData: activeProvider.providerData,
|
|
3295
|
+
modelFormat: "anthropic",
|
|
3296
|
+
headers: activeProvider.headers,
|
|
3297
|
+
app: "Claude"
|
|
3298
|
+
},
|
|
3299
|
+
launchApiKey
|
|
3300
|
+
);
|
|
3301
|
+
if (!isAgentStdoutMode()) p6.log.info(`Proxy started on port ${proxyHandle.port}`);
|
|
3302
|
+
} catch (err) {
|
|
3303
|
+
p6.log.error(`Failed to start proxy: ${err instanceof Error ? err.message : String(err)}`);
|
|
3304
|
+
return 1;
|
|
3305
|
+
}
|
|
3094
3306
|
childEnv = buildChildEnv(
|
|
3095
|
-
|
|
3307
|
+
`http://127.0.0.1:${proxyHandle.port}`,
|
|
3096
3308
|
selectedModel.id,
|
|
3097
|
-
|
|
3098
|
-
|
|
3309
|
+
proxyHandle.token,
|
|
3310
|
+
proxyHandle.port,
|
|
3099
3311
|
selectedModel.contextWindow
|
|
3100
3312
|
);
|
|
3101
3313
|
} else {
|
|
@@ -3140,12 +3352,31 @@ Error: ${launchPlan.error}
|
|
|
3140
3352
|
selectedModel.contextWindow
|
|
3141
3353
|
);
|
|
3142
3354
|
}
|
|
3143
|
-
if (selectedModel.modelFormat === "anthropic" && !isOAuthAnthropic) {
|
|
3144
|
-
childEnv["CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS"] = "1";
|
|
3145
|
-
}
|
|
3146
3355
|
const debugLogPath = prepareClaudeTraceLog();
|
|
3147
3356
|
const traceArgs = trace ? ["--debug-file", debugLogPath] : [];
|
|
3148
3357
|
if (trace) p6.log.info(`Debug log: ${debugLogPath}`);
|
|
3358
|
+
if (trace) {
|
|
3359
|
+
writeSecureLogLine(
|
|
3360
|
+
debugLogPath,
|
|
3361
|
+
`childEnv: ANTHROPIC_BASE_URL=${childEnv["ANTHROPIC_BASE_URL"] ?? "(unset)"}`
|
|
3362
|
+
);
|
|
3363
|
+
writeSecureLogLine(
|
|
3364
|
+
debugLogPath,
|
|
3365
|
+
`childEnv: ANTHROPIC_API_KEY set=${Boolean(childEnv["ANTHROPIC_API_KEY"])}`
|
|
3366
|
+
);
|
|
3367
|
+
writeSecureLogLine(
|
|
3368
|
+
debugLogPath,
|
|
3369
|
+
`childEnv: ANTHROPIC_AUTH_TOKEN set=${Boolean(childEnv["ANTHROPIC_AUTH_TOKEN"])}`
|
|
3370
|
+
);
|
|
3371
|
+
writeSecureLogLine(
|
|
3372
|
+
debugLogPath,
|
|
3373
|
+
`childEnv: ANTHROPIC_MODEL=${childEnv["ANTHROPIC_MODEL"] ?? "(unset)"}`
|
|
3374
|
+
);
|
|
3375
|
+
writeSecureLogLine(
|
|
3376
|
+
debugLogPath,
|
|
3377
|
+
`childEnv: CLAUDE_CODE_MAX_CONTEXT_TOKENS=${childEnv["CLAUDE_CODE_MAX_CONTEXT_TOKENS"] ?? "(unset)"}`
|
|
3378
|
+
);
|
|
3379
|
+
}
|
|
3149
3380
|
const exitCode = await launchClaude(
|
|
3150
3381
|
childEnv,
|
|
3151
3382
|
claudeCodeClientModelId(selectedModel.id, selectedModel.contextWindow),
|
|
@@ -3158,7 +3389,9 @@ Error: ${launchPlan.error}
|
|
|
3158
3389
|
async function launchClaudeViaCatalog(catalogRoutes, startingRoute, contextWindow, trace, claudeArgs) {
|
|
3159
3390
|
let proxyHandle;
|
|
3160
3391
|
try {
|
|
3161
|
-
proxyHandle = await startProxyCatalog(catalogRoutes, startingRoute.aliasId, trace
|
|
3392
|
+
proxyHandle = await startProxyCatalog(catalogRoutes, startingRoute.aliasId, trace, {
|
|
3393
|
+
app: "Claude"
|
|
3394
|
+
});
|
|
3162
3395
|
p6.log.info(
|
|
3163
3396
|
`Switch menu active \u2014 proxy on port ${proxyHandle.port} ` + pc5.dim(`(${catalogRoutes.length} model${catalogRoutes.length !== 1 ? "s" : ""} in /model)`)
|
|
3164
3397
|
);
|
|
@@ -3979,7 +4212,9 @@ async function writeResponsesStream(fullStream, modelId, write, onDone, onProgre
|
|
|
3979
4212
|
toolCallCount: toolStates.length,
|
|
3980
4213
|
toolNames: toolStates.map((t) => t.name),
|
|
3981
4214
|
loopDetected,
|
|
3982
|
-
dsmlToolCallsRecovered: dsml?.calls.length
|
|
4215
|
+
dsmlToolCallsRecovered: dsml?.calls.length,
|
|
4216
|
+
inputTokens: usage.input_tokens,
|
|
4217
|
+
outputTokens: usage.output_tokens
|
|
3983
4218
|
});
|
|
3984
4219
|
emit("response.completed", {
|
|
3985
4220
|
type: "response.completed",
|
|
@@ -4388,6 +4623,24 @@ async function startCodexProxy(routes, options = {}) {
|
|
|
4388
4623
|
const opts = typeof options === "boolean" ? { debug: options } : options;
|
|
4389
4624
|
const debug = opts.debug ?? false;
|
|
4390
4625
|
const requireAuth = opts.requireAuth ?? true;
|
|
4626
|
+
const analyticsApp = opts.app ?? "codex";
|
|
4627
|
+
const routeByModelId = new Map(routes.map((r) => [r.modelId, r]));
|
|
4628
|
+
const trackUsage = (modelId, inputTokens, outputTokens) => {
|
|
4629
|
+
if (inputTokens <= 0 && outputTokens <= 0) return;
|
|
4630
|
+
try {
|
|
4631
|
+
const route = routeByModelId.get(modelId);
|
|
4632
|
+
recordUsage({
|
|
4633
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4634
|
+
modelId: route?.upstreamModelId ?? modelId,
|
|
4635
|
+
npm: route?.npm,
|
|
4636
|
+
providerId: route?.providerId,
|
|
4637
|
+
app: analyticsApp,
|
|
4638
|
+
inputTokens,
|
|
4639
|
+
outputTokens
|
|
4640
|
+
});
|
|
4641
|
+
} catch {
|
|
4642
|
+
}
|
|
4643
|
+
};
|
|
4391
4644
|
silenceSdkWarnings();
|
|
4392
4645
|
const models = /* @__PURE__ */ new Map();
|
|
4393
4646
|
for (const route of routes) {
|
|
@@ -4622,6 +4875,7 @@ async function startCodexProxy(routes, options = {}) {
|
|
|
4622
4875
|
modelId,
|
|
4623
4876
|
write,
|
|
4624
4877
|
(summary) => {
|
|
4878
|
+
trackUsage(modelId, summary.inputTokens ?? 0, summary.outputTokens ?? 0);
|
|
4625
4879
|
if (debug) {
|
|
4626
4880
|
const failure = `${summary.aborted ? " aborted=yes" : ""}${summary.errorMessage ? ` error=${JSON.stringify(summary.errorMessage)}` : ""}`;
|
|
4627
4881
|
log17(
|
|
@@ -4651,6 +4905,8 @@ async function startCodexProxy(routes, options = {}) {
|
|
|
4651
4905
|
} else {
|
|
4652
4906
|
try {
|
|
4653
4907
|
const response = await generateResponsesResponse(languageModel, params, modelId);
|
|
4908
|
+
const u = response["usage"];
|
|
4909
|
+
trackUsage(modelId, u?.input_tokens ?? 0, u?.output_tokens ?? 0);
|
|
4654
4910
|
sendJson(res, 200, response);
|
|
4655
4911
|
} catch (err) {
|
|
4656
4912
|
const msg = formatUpstreamError(err);
|
|
@@ -4878,6 +5134,7 @@ data: ${JSON.stringify({ error: { message: `Unknown model: ${modelId}` } })}
|
|
|
4878
5134
|
modelId,
|
|
4879
5135
|
sendWsEvent,
|
|
4880
5136
|
(summary) => {
|
|
5137
|
+
trackUsage(modelId, summary.inputTokens ?? 0, summary.outputTokens ?? 0);
|
|
4881
5138
|
if (debug) {
|
|
4882
5139
|
const failure = `${summary.aborted ? " aborted=yes" : ""}${summary.errorMessage ? ` error=${JSON.stringify(summary.errorMessage)}` : ""}`;
|
|
4883
5140
|
log17(
|
|
@@ -5721,7 +5978,7 @@ function buildOAuthAnthropicProxyRoute(model, apiKey, providerId, providerData)
|
|
|
5721
5978
|
refreshToken: () => resolveProviderCredential(providerId, oauthAuthRef(providerId))
|
|
5722
5979
|
};
|
|
5723
5980
|
}
|
|
5724
|
-
async function partitionAndStartCloudCodeBackend(items, toOutput, trace) {
|
|
5981
|
+
async function partitionAndStartCloudCodeBackend(items, toOutput, trace, app) {
|
|
5725
5982
|
if (items.length === 0) return { backendItems: [], backend: null };
|
|
5726
5983
|
const proxyRoutes = items.map(
|
|
5727
5984
|
(item) => item.model.modelFormat === "cloud-code" ? buildCloudCodeProxyRoute(item.model, item.apiKey, item.providerData ?? {}) : buildOAuthAnthropicProxyRoute(
|
|
@@ -5731,7 +5988,13 @@ async function partitionAndStartCloudCodeBackend(items, toOutput, trace) {
|
|
|
5731
5988
|
item.providerData ?? {}
|
|
5732
5989
|
)
|
|
5733
5990
|
);
|
|
5734
|
-
const
|
|
5991
|
+
if (app) for (const route of proxyRoutes) route.app = app;
|
|
5992
|
+
const backend = await startCloudCodeCatalogBackend(
|
|
5993
|
+
proxyRoutes,
|
|
5994
|
+
proxyRoutes[0].aliasId,
|
|
5995
|
+
trace,
|
|
5996
|
+
app
|
|
5997
|
+
);
|
|
5735
5998
|
return {
|
|
5736
5999
|
backend,
|
|
5737
6000
|
backendItems: proxyRoutes.map(
|
|
@@ -5744,8 +6007,8 @@ async function buildSingleModelCloudCodeRoute(model, apiKey, providerId, provide
|
|
|
5744
6007
|
const backend = await startCloudCodeCatalogBackend([proxyRoute], proxyRoute.aliasId, trace);
|
|
5745
6008
|
return { proxyRoute, backend };
|
|
5746
6009
|
}
|
|
5747
|
-
async function startCloudCodeCatalogBackend(routes, startingAliasId, trace) {
|
|
5748
|
-
const handle = await startProxyCatalog(routes, startingAliasId, trace ?? false);
|
|
6010
|
+
async function startCloudCodeCatalogBackend(routes, startingAliasId, trace, app) {
|
|
6011
|
+
const handle = await startProxyCatalog(routes, startingAliasId, trace ?? false, { app });
|
|
5749
6012
|
return { port: handle.port, token: handle.token, handle };
|
|
5750
6013
|
}
|
|
5751
6014
|
|
|
@@ -5855,6 +6118,29 @@ async function writeFavoritesLaunchArtifacts(resolved, starting, proxyPort) {
|
|
|
5855
6118
|
);
|
|
5856
6119
|
return { profilePath, catalogPath };
|
|
5857
6120
|
}
|
|
6121
|
+
async function writeAllModelsLaunchArtifacts(activeProvider, selectedModel, routable, proxyPort) {
|
|
6122
|
+
const catalogPath = getCatalogOutputPath(activeProvider.id);
|
|
6123
|
+
const catalog = buildCatalogFile(routable, activeProvider.name);
|
|
6124
|
+
writeOverlayFile(catalogPath, serializeCatalog(catalog));
|
|
6125
|
+
const profilePath = getProfileOutputPath();
|
|
6126
|
+
const dummyRoute = {
|
|
6127
|
+
tier: "proxy",
|
|
6128
|
+
modelId: selectedModel.id,
|
|
6129
|
+
providerId: "anygate-proxy",
|
|
6130
|
+
npm: selectedModel.npm ?? "@ai-sdk/openai-compatible",
|
|
6131
|
+
upstreamModelId: selectedModel.upstreamModelId || selectedModel.id,
|
|
6132
|
+
apiKey: ""
|
|
6133
|
+
};
|
|
6134
|
+
writeOverlayFile(
|
|
6135
|
+
profilePath,
|
|
6136
|
+
buildCodexProfileToml({
|
|
6137
|
+
route: dummyRoute,
|
|
6138
|
+
proxyPort,
|
|
6139
|
+
catalogPath
|
|
6140
|
+
})
|
|
6141
|
+
);
|
|
6142
|
+
return { profilePath, catalogPath };
|
|
6143
|
+
}
|
|
5858
6144
|
function printCodexCleanupReminder(hadProxy) {
|
|
5859
6145
|
if (isAgentStdoutMode()) return;
|
|
5860
6146
|
const left = remainingOverlayPaths();
|
|
@@ -6019,8 +6305,9 @@ async function runCodexCommand(codexArgs, trace = false, launch = {}) {
|
|
|
6019
6305
|
return runCodexVertexLaunch(passthroughArgs, trace);
|
|
6020
6306
|
}
|
|
6021
6307
|
const prefs = loadPreferences();
|
|
6308
|
+
const launchAllModels = Boolean(launch.launchAllModels || launch.launchModel === "All");
|
|
6022
6309
|
const launchPlan = planLaunchWizard({
|
|
6023
|
-
explicit: { providerId: launch.launchProvider, modelId: launch.launchModel },
|
|
6310
|
+
explicit: launchAllModels ? { providerId: launch.launchProvider, allModels: true } : { providerId: launch.launchProvider, modelId: launch.launchModel },
|
|
6024
6311
|
childArgs: passthroughArgs,
|
|
6025
6312
|
agent: "codex",
|
|
6026
6313
|
prefs
|
|
@@ -6092,8 +6379,16 @@ Error: ${launchPlan.error}
|
|
|
6092
6379
|
return 0;
|
|
6093
6380
|
}
|
|
6094
6381
|
const favorites = prefs.favoriteModels ?? [];
|
|
6095
|
-
const
|
|
6096
|
-
|
|
6382
|
+
const hasFavorites = favorites.length > 0;
|
|
6383
|
+
let catalogMode = false;
|
|
6384
|
+
if (launchPlan.skip && launchPlan.target && launchPlan.target.allModels) {
|
|
6385
|
+
catalogMode = "provider-all";
|
|
6386
|
+
}
|
|
6387
|
+
let favoritesActive = false;
|
|
6388
|
+
if (configOnly && hasFavorites && !launchPlan.skip) {
|
|
6389
|
+
favoritesActive = true;
|
|
6390
|
+
}
|
|
6391
|
+
if (hasFavorites && !configOnly && !launchPlan.skip) {
|
|
6097
6392
|
p9.log.info(
|
|
6098
6393
|
`Favorites mode active \u2014 Codex picker will show ${favorites.length + 1} models (1 starting + ${favorites.length} favorites).`
|
|
6099
6394
|
);
|
|
@@ -6102,17 +6397,31 @@ Error: ${launchPlan.error}
|
|
|
6102
6397
|
let activeProvider = compatible.find((lp) => lp.id === prefs.lastCodexProvider) ?? compatible[0];
|
|
6103
6398
|
let selectedModel = activeProvider.models.find((m) => m.id === prefs.lastCodexModel) ?? activeProvider.models[0];
|
|
6104
6399
|
if (!configOnly && launchPlan.skip && launchPlan.target) {
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
`Provider
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6400
|
+
if (launchPlan.target.allModels) {
|
|
6401
|
+
const foundProvider = compatible.find((lp) => lp.id === launchPlan.target.providerId);
|
|
6402
|
+
if (!foundProvider) {
|
|
6403
|
+
p9.log.error(`Provider not found: ${launchPlan.target.providerId}`);
|
|
6404
|
+
return 1;
|
|
6405
|
+
}
|
|
6406
|
+
activeProvider = foundProvider;
|
|
6407
|
+
selectedModel = activeProvider.models[0];
|
|
6408
|
+
catalogMode = "provider-all";
|
|
6409
|
+
if (!agentStdout) {
|
|
6410
|
+
p9.log.step(`Using all ${activeProvider.models.length} models from ${activeProvider.name}`);
|
|
6411
|
+
}
|
|
6412
|
+
} else {
|
|
6413
|
+
const resolved = findProviderAndModel(compatible, launchPlan.target);
|
|
6414
|
+
if (!resolved) {
|
|
6415
|
+
p9.log.error(
|
|
6416
|
+
`Provider/model not found: ${launchPlan.target.providerId} / ${launchPlan.target.modelId}`
|
|
6417
|
+
);
|
|
6418
|
+
return 1;
|
|
6419
|
+
}
|
|
6420
|
+
activeProvider = resolved.provider;
|
|
6421
|
+
selectedModel = resolved.model;
|
|
6422
|
+
if (!agentStdout) {
|
|
6423
|
+
p9.log.step(`Using ${selectedModel.name || selectedModel.id} (${activeProvider.name})`);
|
|
6424
|
+
}
|
|
6116
6425
|
}
|
|
6117
6426
|
} else if (!configOnly) {
|
|
6118
6427
|
let currentInitialProvider = prefs.lastCodexProvider && compatible.some((o) => o.id === prefs.lastCodexProvider) ? prefs.lastCodexProvider : compatible[0].id;
|
|
@@ -6120,7 +6429,7 @@ Error: ${launchPlan.error}
|
|
|
6120
6429
|
const pickedProvider = await pickCodexProvider(
|
|
6121
6430
|
compatible,
|
|
6122
6431
|
prefs,
|
|
6123
|
-
|
|
6432
|
+
hasFavorites,
|
|
6124
6433
|
currentInitialProvider
|
|
6125
6434
|
);
|
|
6126
6435
|
if (!pickedProvider) return 0;
|
|
@@ -6135,9 +6444,36 @@ Error: ${launchPlan.error}
|
|
|
6135
6444
|
if (favoritePick === "cancelled" || favoritePick === "unavailable") return 0;
|
|
6136
6445
|
activeProvider = favoritePick.provider;
|
|
6137
6446
|
selectedModel = favoritePick.model;
|
|
6447
|
+
catalogMode = "favorites";
|
|
6448
|
+
favoritesActive = true;
|
|
6138
6449
|
break;
|
|
6139
6450
|
} else {
|
|
6140
6451
|
activeProvider = pickedProvider;
|
|
6452
|
+
const modelModeChoice = await p9.select({
|
|
6453
|
+
message: `Launch mode for ${activeProvider.name}?`,
|
|
6454
|
+
options: [
|
|
6455
|
+
{
|
|
6456
|
+
value: "specific",
|
|
6457
|
+
label: "One model",
|
|
6458
|
+
hint: "Pick a specific model"
|
|
6459
|
+
},
|
|
6460
|
+
{
|
|
6461
|
+
value: "all",
|
|
6462
|
+
label: `All models (${activeProvider.models.length})`,
|
|
6463
|
+
hint: "Every model from this provider in the picker"
|
|
6464
|
+
},
|
|
6465
|
+
navOption("__back__", "\u2190 Back", "Choose a different provider")
|
|
6466
|
+
]
|
|
6467
|
+
});
|
|
6468
|
+
if (p9.isCancel(modelModeChoice) || modelModeChoice === "__back__") {
|
|
6469
|
+
currentInitialProvider = activeProvider.id;
|
|
6470
|
+
continue;
|
|
6471
|
+
}
|
|
6472
|
+
if (modelModeChoice === "all") {
|
|
6473
|
+
catalogMode = "provider-all";
|
|
6474
|
+
selectedModel = activeProvider.models[0];
|
|
6475
|
+
break;
|
|
6476
|
+
}
|
|
6141
6477
|
const pickedModelResult = await pickCodexModel(activeProvider, prefs);
|
|
6142
6478
|
if (pickedModelResult === "back") {
|
|
6143
6479
|
currentInitialProvider = activeProvider.id;
|
|
@@ -6185,7 +6521,64 @@ Error: ${launchPlan.error}
|
|
|
6185
6521
|
let cloudCodeBackendFav = null;
|
|
6186
6522
|
try {
|
|
6187
6523
|
let proxyPort;
|
|
6188
|
-
if (
|
|
6524
|
+
if (catalogMode === "provider-all") {
|
|
6525
|
+
const routable = routableModelsForProvider(activeProvider, "codex");
|
|
6526
|
+
const backendModels = routable.filter((m) => needsCloudCodeBackend(m, activeProvider.authType));
|
|
6527
|
+
const regularModels = routable.filter((m) => !needsCloudCodeBackend(m, activeProvider.authType));
|
|
6528
|
+
let backendCodexRoutes = [];
|
|
6529
|
+
if (backendModels.length > 0) {
|
|
6530
|
+
const partitioned = await partitionAndStartCloudCodeBackend(
|
|
6531
|
+
backendModels.map((model) => ({
|
|
6532
|
+
providerId: activeProvider.id,
|
|
6533
|
+
model,
|
|
6534
|
+
apiKey,
|
|
6535
|
+
oauthAccountId: activeProvider.oauthAccountId,
|
|
6536
|
+
providerData: activeProvider.providerData ?? {}
|
|
6537
|
+
})),
|
|
6538
|
+
(cr, backend) => ({
|
|
6539
|
+
modelId: cr.aliasId,
|
|
6540
|
+
npm: "@ai-sdk/anthropic",
|
|
6541
|
+
apiKey: backend.token,
|
|
6542
|
+
baseURL: `http://127.0.0.1:${backend.port}`,
|
|
6543
|
+
upstreamModelId: cr.aliasId,
|
|
6544
|
+
providerId: cr.providerId ?? activeProvider.id,
|
|
6545
|
+
authType: "oauth",
|
|
6546
|
+
oauthAccountId: activeProvider.oauthAccountId,
|
|
6547
|
+
providerData: activeProvider.providerData ?? {},
|
|
6548
|
+
contextWindow: cr.contextWindow,
|
|
6549
|
+
supportedParameters: cr.supportedParameters,
|
|
6550
|
+
reasoning: cr.reasoning,
|
|
6551
|
+
interleavedReasoningField: cr.interleavedReasoningField
|
|
6552
|
+
}),
|
|
6553
|
+
trace,
|
|
6554
|
+
"codex"
|
|
6555
|
+
);
|
|
6556
|
+
cloudCodeBackendFav = partitioned.backend;
|
|
6557
|
+
backendCodexRoutes = partitioned.backendItems;
|
|
6558
|
+
}
|
|
6559
|
+
const regularRoutes = regularModels.map((model) => {
|
|
6560
|
+
const r = resolveCodexRoute(activeProvider, model, apiKey);
|
|
6561
|
+
return {
|
|
6562
|
+
modelId: r.modelId,
|
|
6563
|
+
npm: r.npm,
|
|
6564
|
+
apiKey: r.apiKey,
|
|
6565
|
+
baseURL: r.baseURL,
|
|
6566
|
+
upstreamModelId: r.upstreamModelId,
|
|
6567
|
+
providerId: r.providerId,
|
|
6568
|
+
authType: r.authType,
|
|
6569
|
+
oauthAccountId: r.oauthAccountId,
|
|
6570
|
+
providerData: r.providerData,
|
|
6571
|
+
contextWindow: r.contextWindow,
|
|
6572
|
+
supportedParameters: r.supportedParameters,
|
|
6573
|
+
reasoning: r.reasoning,
|
|
6574
|
+
interleavedReasoningField: r.interleavedReasoningField,
|
|
6575
|
+
headers: r.headers
|
|
6576
|
+
};
|
|
6577
|
+
});
|
|
6578
|
+
const allRoutes = [...backendCodexRoutes, ...regularRoutes];
|
|
6579
|
+
proxyHandle = await startCodexProxy(allRoutes, { requireAuth: true, debug: trace });
|
|
6580
|
+
proxyPort = proxyHandle.port;
|
|
6581
|
+
} else if (favoritesActive && resolvedFavorites.length > 0) {
|
|
6189
6582
|
const needsBackend = (r) => {
|
|
6190
6583
|
const m = r.model;
|
|
6191
6584
|
const prov = providersById.get(r.providerId);
|
|
@@ -6218,7 +6611,8 @@ Error: ${launchPlan.error}
|
|
|
6218
6611
|
providerData: original.providerData,
|
|
6219
6612
|
contextWindow: cr.contextWindow
|
|
6220
6613
|
}),
|
|
6221
|
-
trace
|
|
6614
|
+
trace,
|
|
6615
|
+
"codex"
|
|
6222
6616
|
);
|
|
6223
6617
|
cloudCodeBackendFav = partitioned.backend;
|
|
6224
6618
|
backendCodexRoutes = partitioned.backendItems;
|
|
@@ -6315,7 +6709,12 @@ Error: ${launchPlan.error}
|
|
|
6315
6709
|
const startingFavorite = resolvedFavorites.find(
|
|
6316
6710
|
(r) => r.providerId === activeProvider.id && r.model.id === selectedModel.id
|
|
6317
6711
|
) ?? resolvedFavorites[0];
|
|
6318
|
-
const { profilePath, catalogPath } =
|
|
6712
|
+
const { profilePath, catalogPath } = catalogMode === "provider-all" && proxyPort ? await writeAllModelsLaunchArtifacts(
|
|
6713
|
+
activeProvider,
|
|
6714
|
+
selectedModel,
|
|
6715
|
+
routableModelsForProvider(activeProvider, "codex"),
|
|
6716
|
+
proxyPort
|
|
6717
|
+
) : favoritesActive && resolvedFavorites.length > 0 && proxyPort && startingFavorite ? await writeFavoritesLaunchArtifacts(resolvedFavorites, startingFavorite, proxyPort) : await writeLaunchArtifacts(route, selectedModel, activeProvider.name, proxyPort);
|
|
6319
6718
|
writeSessionLock({
|
|
6320
6719
|
pid: process.pid,
|
|
6321
6720
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -6329,7 +6728,19 @@ Error: ${launchPlan.error}
|
|
|
6329
6728
|
console.log("");
|
|
6330
6729
|
console.log(pc8.bold(pc8.cyan(" CONFIG PREVIEW \u2014 anygate codex")));
|
|
6331
6730
|
console.log("");
|
|
6332
|
-
if (
|
|
6731
|
+
if (catalogMode === "provider-all") {
|
|
6732
|
+
const allModels = routableModelsForProvider(activeProvider, "codex");
|
|
6733
|
+
console.log(
|
|
6734
|
+
` ${pc8.bold("Mode:")} Provider Catalog (${allModels.length} model${allModels.length !== 1 ? "s" : ""})`
|
|
6735
|
+
);
|
|
6736
|
+
console.log(` ${pc8.bold("Provider:")} ${activeProvider.name}`);
|
|
6737
|
+
console.log(` ${pc8.bold("Starting model:")} ${selectedModel.id}`);
|
|
6738
|
+
console.log("");
|
|
6739
|
+
console.log(` ${pc8.bold("Models:")}`);
|
|
6740
|
+
for (const m of allModels) {
|
|
6741
|
+
console.log(` ${pc8.cyan(m.id)}`);
|
|
6742
|
+
}
|
|
6743
|
+
} else if (favoritesActive && resolvedFavorites.length > 0) {
|
|
6333
6744
|
console.log(
|
|
6334
6745
|
` ${pc8.bold("Mode:")} Favorites Catalog (${resolvedFavorites.length} model${resolvedFavorites.length !== 1 ? "s" : ""})`
|
|
6335
6746
|
);
|
|
@@ -6362,6 +6773,7 @@ Error: ${launchPlan.error}
|
|
|
6362
6773
|
}
|
|
6363
6774
|
}
|
|
6364
6775
|
const favoritesLaunch = favoritesActive && resolvedFavorites.length > 0;
|
|
6776
|
+
const providerAllLaunch = catalogMode === "provider-all";
|
|
6365
6777
|
const launchModelId = favoritesLaunch ? codexCliFavoritesSlug(activeProvider.id, selectedModel.id) : selectedModel.id;
|
|
6366
6778
|
if (!agentStdout) {
|
|
6367
6779
|
logActiveModel(modelLabel, launchModelId);
|
|
@@ -6376,11 +6788,9 @@ Error: ${launchPlan.error}
|
|
|
6376
6788
|
upstreamModelId: selectedModel.upstreamModelId || selectedModel.id,
|
|
6377
6789
|
apiKey: ""
|
|
6378
6790
|
};
|
|
6379
|
-
const
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
);
|
|
6383
|
-
const hadProxy = (route.tier === "proxy" || route.tier === "cloud-code" || favoritesLaunch) && !!proxyPort;
|
|
6791
|
+
const useProxyRoute = favoritesLaunch || providerAllLaunch || route.tier === "cloud-code";
|
|
6792
|
+
const childEnv = buildCodexChildEnv(useProxyRoute ? dummyRoute : route, proxyPort);
|
|
6793
|
+
const hadProxy = (route.tier === "proxy" || route.tier === "cloud-code" || favoritesLaunch || providerAllLaunch) && !!proxyPort;
|
|
6384
6794
|
const exitCode = await launchCodex(launchModelId, childEnv, passthroughArgs);
|
|
6385
6795
|
if (trace) printTraceLog(debugLogPath);
|
|
6386
6796
|
printCodexCleanupReminder(hadProxy);
|
|
@@ -6400,7 +6810,7 @@ Error: ${launchPlan.error}
|
|
|
6400
6810
|
// src/cli/codex.ts
|
|
6401
6811
|
async function handleCodexCommand(parsed) {
|
|
6402
6812
|
if (parsed.showVersion) {
|
|
6403
|
-
const { VERSION: VERSION2 } = await import("./constants-
|
|
6813
|
+
const { VERSION: VERSION2 } = await import("./constants-U356SKNS.js");
|
|
6404
6814
|
console.log(VERSION2);
|
|
6405
6815
|
return 0;
|
|
6406
6816
|
}
|
|
@@ -6411,6 +6821,7 @@ async function handleCodexCommand(parsed) {
|
|
|
6411
6821
|
return runCodexCommand(parsed.claudeArgs ?? [], parsed.trace ?? false, {
|
|
6412
6822
|
launchProvider: parsed.launchProvider,
|
|
6413
6823
|
launchModel: parsed.launchModel,
|
|
6824
|
+
launchAllModels: parsed.launchAllModels || parsed.launchModel === "All",
|
|
6414
6825
|
vertex: parsed.vertex
|
|
6415
6826
|
});
|
|
6416
6827
|
}
|
|
@@ -6476,7 +6887,8 @@ async function buildCodexAppProviderCatalogRoutes(provider, apiKey, selectedMode
|
|
|
6476
6887
|
interleavedReasoningField: original.model.interleavedReasoningField,
|
|
6477
6888
|
headers: provider.headers
|
|
6478
6889
|
}),
|
|
6479
|
-
trace
|
|
6890
|
+
trace,
|
|
6891
|
+
"codex-app"
|
|
6480
6892
|
);
|
|
6481
6893
|
for (let index = 0; index < backendModels.length; index++) {
|
|
6482
6894
|
const model = backendModels[index];
|
|
@@ -7078,7 +7490,7 @@ async function runCodexAppVertexLaunch(configOnly, trace = false) {
|
|
|
7078
7490
|
vertex: vertexConfig,
|
|
7079
7491
|
contextWindow: m.contextWindow
|
|
7080
7492
|
})),
|
|
7081
|
-
{ requireAuth: false, debug: trace }
|
|
7493
|
+
{ requireAuth: false, debug: trace, app: "codex-app" }
|
|
7082
7494
|
);
|
|
7083
7495
|
const proxyPort = proxyHandle.port;
|
|
7084
7496
|
const catalogFile = buildAppCatalogFile(vertexModels, "Vertex AI", selectedEntry.id);
|
|
@@ -7204,33 +7616,43 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7204
7616
|
}
|
|
7205
7617
|
const prefs = loadPreferences();
|
|
7206
7618
|
const favorites = prefs.favoriteModels ?? [];
|
|
7207
|
-
const
|
|
7619
|
+
const hasFavorites = favorites.length > 0;
|
|
7620
|
+
let favoritesMode = false;
|
|
7621
|
+
let useProviderAll = false;
|
|
7208
7622
|
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
7623
|
let activeProvider = providerForCodexPicker(
|
|
7216
7624
|
compatible.find((lp) => lp.id === prefs.lastCodexProvider) ?? compatible[0]
|
|
7217
7625
|
);
|
|
7218
7626
|
let selectedModel = activeProvider.models.find((m) => m.id === prefs.lastCodexModel) ?? activeProvider.models[0];
|
|
7219
|
-
if (!configOnly && opts.launchProvider && opts.launchModel) {
|
|
7220
|
-
|
|
7221
|
-
compatible
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
7227
|
-
|
|
7228
|
-
|
|
7627
|
+
if (!configOnly && opts.launchProvider && opts.launchModel || opts.launchProvider && (opts.launchAllModels || opts.launchModel === "All")) {
|
|
7628
|
+
if (opts.launchAllModels || opts.launchModel === "All") {
|
|
7629
|
+
const foundProvider = compatible.find((lp) => lp.id === opts.launchProvider);
|
|
7630
|
+
if (!foundProvider) {
|
|
7631
|
+
p10.log.error(`Provider not found: ${opts.launchProvider}`);
|
|
7632
|
+
return 1;
|
|
7633
|
+
}
|
|
7634
|
+
activeProvider = providerForCodexPicker(foundProvider);
|
|
7635
|
+
selectedModel = activeProvider.models[0];
|
|
7636
|
+
useProviderAll = true;
|
|
7637
|
+
if (!configOnly) {
|
|
7638
|
+
p10.log.step(`Using all ${activeProvider.models.length} models from ${activeProvider.name}`);
|
|
7639
|
+
}
|
|
7640
|
+
} else {
|
|
7641
|
+
const bootSelection = resolveBootSelection(
|
|
7642
|
+
compatible,
|
|
7643
|
+
opts.launchProvider,
|
|
7644
|
+
opts.launchModel,
|
|
7645
|
+
providerForCodexPicker
|
|
7646
|
+
);
|
|
7647
|
+
if ("error" in bootSelection) {
|
|
7648
|
+
p10.log.error(bootSelection.error);
|
|
7649
|
+
return 1;
|
|
7650
|
+
}
|
|
7651
|
+
activeProvider = bootSelection.provider;
|
|
7652
|
+
selectedModel = bootSelection.model;
|
|
7229
7653
|
}
|
|
7230
|
-
activeProvider = bootSelection.provider;
|
|
7231
|
-
selectedModel = bootSelection.model;
|
|
7232
7654
|
} else if (!configOnly) {
|
|
7233
|
-
if (useFavoritesCatalog &&
|
|
7655
|
+
if (useFavoritesCatalog && hasFavorites) {
|
|
7234
7656
|
const firstFavorite = resolveFirstAvailableFavorite(
|
|
7235
7657
|
favorites,
|
|
7236
7658
|
compatible.map(providerForCodexPicker)
|
|
@@ -7241,13 +7663,14 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7241
7663
|
}
|
|
7242
7664
|
activeProvider = providerForCodexPicker(firstFavorite.provider);
|
|
7243
7665
|
selectedModel = firstFavorite.model;
|
|
7666
|
+
favoritesMode = true;
|
|
7244
7667
|
} else {
|
|
7245
7668
|
let currentInitialProvider = prefs.lastCodexProvider && compatible.some((o) => o.id === prefs.lastCodexProvider) ? prefs.lastCodexProvider : compatible[0].id;
|
|
7246
7669
|
while (true) {
|
|
7247
7670
|
const pickedProvider = await pickCodexProvider(
|
|
7248
7671
|
compatible,
|
|
7249
7672
|
prefs,
|
|
7250
|
-
|
|
7673
|
+
hasFavorites,
|
|
7251
7674
|
currentInitialProvider
|
|
7252
7675
|
);
|
|
7253
7676
|
if (!pickedProvider) return 0;
|
|
@@ -7262,9 +7685,35 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7262
7685
|
if (favoritePick === "cancelled" || favoritePick === "unavailable") return 0;
|
|
7263
7686
|
activeProvider = favoritePick.provider;
|
|
7264
7687
|
selectedModel = favoritePick.model;
|
|
7688
|
+
favoritesMode = true;
|
|
7265
7689
|
break;
|
|
7266
7690
|
} else {
|
|
7267
7691
|
activeProvider = providerForCodexPicker(pickedProvider);
|
|
7692
|
+
const modelModeChoice = await p10.select({
|
|
7693
|
+
message: `Launch mode for ${activeProvider.name}?`,
|
|
7694
|
+
options: [
|
|
7695
|
+
{
|
|
7696
|
+
value: "specific",
|
|
7697
|
+
label: "One model",
|
|
7698
|
+
hint: "Pick a specific model"
|
|
7699
|
+
},
|
|
7700
|
+
{
|
|
7701
|
+
value: "all",
|
|
7702
|
+
label: `All models (${activeProvider.models.length})`,
|
|
7703
|
+
hint: "Every model from this provider in the model switcher"
|
|
7704
|
+
},
|
|
7705
|
+
navOption("__back__", "\u2190 Back", "Choose a different provider")
|
|
7706
|
+
]
|
|
7707
|
+
});
|
|
7708
|
+
if (p10.isCancel(modelModeChoice) || modelModeChoice === "__back__") {
|
|
7709
|
+
currentInitialProvider = activeProvider.id;
|
|
7710
|
+
continue;
|
|
7711
|
+
}
|
|
7712
|
+
if (modelModeChoice === "all") {
|
|
7713
|
+
useProviderAll = true;
|
|
7714
|
+
selectedModel = activeProvider.models[0];
|
|
7715
|
+
break;
|
|
7716
|
+
}
|
|
7268
7717
|
const pickedModelResult = await pickCodexModel(activeProvider, prefs);
|
|
7269
7718
|
if (pickedModelResult === "back") {
|
|
7270
7719
|
currentInitialProvider = activeProvider.id;
|
|
@@ -7285,9 +7734,15 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7285
7734
|
return 1;
|
|
7286
7735
|
}
|
|
7287
7736
|
activeProvider.apiKey = apiKey;
|
|
7737
|
+
if (hasFavorites && !configOnly && !useProviderAll) {
|
|
7738
|
+
p10.log.info(
|
|
7739
|
+
`Favorites mode active \u2014 Codex App picker will show ${favorites.length + 1} models (1 starting + ${favorites.length} favorites).`
|
|
7740
|
+
);
|
|
7741
|
+
p10.log.info("Edit with `anygate models`.");
|
|
7742
|
+
}
|
|
7288
7743
|
let cloudCodeBackend = null;
|
|
7289
7744
|
let cloudCodeBackendFav = null;
|
|
7290
|
-
const appProviderRoutes =
|
|
7745
|
+
const appProviderRoutes = !favoritesMode ? await buildCodexAppProviderCatalogRoutes(activeProvider, apiKey, selectedModel.id, trace) : null;
|
|
7291
7746
|
cloudCodeBackend = appProviderRoutes?.backend ?? null;
|
|
7292
7747
|
const route = appProviderRoutes ? codexProxyRouteToCodexRoute(appProviderRoutes.selectedRoute, activeProvider.id) : resolveCodexRoute(activeProvider, selectedModel, apiKey);
|
|
7293
7748
|
const appRoute = { ...route, tier: "proxy" };
|
|
@@ -7295,7 +7750,7 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7295
7750
|
const catalogModels = appProviderRoutes?.catalogModels ?? routable;
|
|
7296
7751
|
let resolvedFavorites = [];
|
|
7297
7752
|
let providersById = /* @__PURE__ */ new Map();
|
|
7298
|
-
if (
|
|
7753
|
+
if (favoritesMode) {
|
|
7299
7754
|
const res = await resolveCodexFavorites(
|
|
7300
7755
|
activeProvider,
|
|
7301
7756
|
selectedModel,
|
|
@@ -7308,7 +7763,8 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7308
7763
|
}
|
|
7309
7764
|
if (!configOnly) {
|
|
7310
7765
|
const modelLabel = formatCodexModelLabel(selectedModel);
|
|
7311
|
-
const
|
|
7766
|
+
const isExplicitLaunch = Boolean(opts.launchProvider) && Boolean(opts.launchModel || opts.launchAllModels);
|
|
7767
|
+
const confirmed = useFavoritesCatalog || isExplicitLaunch || await confirmCodexLaunch(activeProvider.name, modelLabel, selectedModel.id, appRoute);
|
|
7312
7768
|
if (!confirmed) {
|
|
7313
7769
|
cloudCodeBackend?.handle.close();
|
|
7314
7770
|
return 0;
|
|
@@ -7317,8 +7773,8 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7317
7773
|
let proxyHandle = null;
|
|
7318
7774
|
let sessionActive = false;
|
|
7319
7775
|
try {
|
|
7320
|
-
const catalogPath =
|
|
7321
|
-
const activeRoute =
|
|
7776
|
+
const catalogPath = favoritesMode && resolvedFavorites.length > 0 ? getFavoritesAppCatalogPath() : getAppCatalogPath(route.providerId);
|
|
7777
|
+
const activeRoute = favoritesMode && resolvedFavorites.length > 0 ? {
|
|
7322
7778
|
tier: "proxy",
|
|
7323
7779
|
modelId: codexCliFavoritesSlug(activeProvider.id, selectedModel.id),
|
|
7324
7780
|
providerId: activeProvider.id,
|
|
@@ -7334,7 +7790,7 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7334
7790
|
console.log("");
|
|
7335
7791
|
console.log(pc9.bold(pc9.cyan(" CONFIG PREVIEW \u2014 anygate codex-app")));
|
|
7336
7792
|
console.log("");
|
|
7337
|
-
if (
|
|
7793
|
+
if (favoritesMode) {
|
|
7338
7794
|
console.log(
|
|
7339
7795
|
` ${pc9.bold("Mode:")} Favorites Catalog (${resolvedFavorites.length} model${resolvedFavorites.length !== 1 ? "s" : ""})`
|
|
7340
7796
|
);
|
|
@@ -7370,7 +7826,7 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7370
7826
|
return 0;
|
|
7371
7827
|
}
|
|
7372
7828
|
let proxyPort;
|
|
7373
|
-
if (
|
|
7829
|
+
if (favoritesMode && resolvedFavorites.length > 0) {
|
|
7374
7830
|
const needsBackend = (r) => {
|
|
7375
7831
|
const m = r.model;
|
|
7376
7832
|
const prov = providersById.get(r.providerId);
|
|
@@ -7409,7 +7865,8 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7409
7865
|
const regularRoutes = buildCodexProxyRoutesFromResolved(regularResolved, providersById);
|
|
7410
7866
|
proxyHandle = await startCodexProxy([...backendCodexRoutes, ...regularRoutes], {
|
|
7411
7867
|
requireAuth: false,
|
|
7412
|
-
debug: trace
|
|
7868
|
+
debug: trace,
|
|
7869
|
+
app: "codex-app"
|
|
7413
7870
|
});
|
|
7414
7871
|
proxyPort = proxyHandle.port;
|
|
7415
7872
|
} else {
|
|
@@ -7418,12 +7875,13 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7418
7875
|
}
|
|
7419
7876
|
proxyHandle = await startCodexProxy(appProviderRoutes.routes, {
|
|
7420
7877
|
requireAuth: false,
|
|
7421
|
-
debug: trace
|
|
7878
|
+
debug: trace,
|
|
7879
|
+
app: "codex-app"
|
|
7422
7880
|
});
|
|
7423
7881
|
proxyPort = proxyHandle.port;
|
|
7424
7882
|
}
|
|
7425
7883
|
const modelLabel = formatCodexModelLabel(selectedModel);
|
|
7426
|
-
const catalogFile =
|
|
7884
|
+
const catalogFile = favoritesMode && resolvedFavorites.length > 0 ? buildFavoritesAppCatalog(resolvedFavorites) : buildAppCatalogFile(catalogModels, activeProvider.name, appRoute.modelId);
|
|
7427
7885
|
writeOverlayFile(catalogPath, serializeCatalog(catalogFile));
|
|
7428
7886
|
const spec = {
|
|
7429
7887
|
route: activeRoute,
|
|
@@ -7495,7 +7953,7 @@ async function runCodexAppCommand(args, opts = {}) {
|
|
|
7495
7953
|
// src/cli/codex-app.ts
|
|
7496
7954
|
async function handleCodexAppCommand(parsed) {
|
|
7497
7955
|
if (parsed.showVersion) {
|
|
7498
|
-
const { VERSION: VERSION2 } = await import("./constants-
|
|
7956
|
+
const { VERSION: VERSION2 } = await import("./constants-U356SKNS.js");
|
|
7499
7957
|
console.log(VERSION2);
|
|
7500
7958
|
return 0;
|
|
7501
7959
|
}
|
|
@@ -7522,7 +7980,8 @@ This command launches the ChatGPT Desktop app with anygate's provider registry.
|
|
|
7522
7980
|
return runCodexAppCommand(parsed.claudeArgs ?? [], {
|
|
7523
7981
|
vertex: parsed.vertex,
|
|
7524
7982
|
launchProvider: parsed.launchProvider,
|
|
7525
|
-
launchModel: parsed.launchModel
|
|
7983
|
+
launchModel: parsed.launchModel,
|
|
7984
|
+
launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
|
|
7526
7985
|
});
|
|
7527
7986
|
}
|
|
7528
7987
|
|
|
@@ -7810,10 +8269,21 @@ async function runClaudeAppCommand(args, boot) {
|
|
|
7810
8269
|
const prefs = loadPreferences();
|
|
7811
8270
|
const favorites = prefs.favoriteModels ?? [];
|
|
7812
8271
|
const hasFavorites = favorites.length > 0;
|
|
8272
|
+
const launchAllModels = Boolean(boot?.launchAllModels || boot?.launchModel === "All");
|
|
7813
8273
|
let activeProvider = null;
|
|
7814
8274
|
let selectedModel = null;
|
|
7815
8275
|
let useFavorites = false;
|
|
7816
|
-
|
|
8276
|
+
let useProviderAll = false;
|
|
8277
|
+
if (boot?.launchProvider && launchAllModels) {
|
|
8278
|
+
const foundProvider = compatible.find((lp) => lp.id === boot.launchProvider);
|
|
8279
|
+
if (!foundProvider) {
|
|
8280
|
+
p11.log.error(`Provider not found: ${boot.launchProvider}`);
|
|
8281
|
+
return 1;
|
|
8282
|
+
}
|
|
8283
|
+
activeProvider = foundProvider;
|
|
8284
|
+
selectedModel = activeProvider.models[0];
|
|
8285
|
+
useProviderAll = true;
|
|
8286
|
+
} else if (boot?.launchProvider && boot?.launchModel) {
|
|
7817
8287
|
const bootSelection = resolveBootSelection(
|
|
7818
8288
|
compatible,
|
|
7819
8289
|
boot.launchProvider,
|
|
@@ -7840,10 +8310,48 @@ async function runClaudeAppCommand(args, boot) {
|
|
|
7840
8310
|
if (pickedProvider === "__favorites__") {
|
|
7841
8311
|
useFavorites = true;
|
|
7842
8312
|
} else {
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
8313
|
+
while (true) {
|
|
8314
|
+
const pickedProvider2 = await pickCodexProvider(
|
|
8315
|
+
compatible,
|
|
8316
|
+
prefs,
|
|
8317
|
+
hasFavorites,
|
|
8318
|
+
void 0,
|
|
8319
|
+
"Claude"
|
|
8320
|
+
);
|
|
8321
|
+
if (!pickedProvider2) return 0;
|
|
8322
|
+
if (pickedProvider2 === "__favorites__") {
|
|
8323
|
+
useFavorites = true;
|
|
8324
|
+
break;
|
|
8325
|
+
} else {
|
|
8326
|
+
activeProvider = providerForClaudePicker(pickedProvider2);
|
|
8327
|
+
const modelModeChoice = await p11.select({
|
|
8328
|
+
message: `Launch mode for ${activeProvider.name}?`,
|
|
8329
|
+
options: [
|
|
8330
|
+
{
|
|
8331
|
+
value: "specific",
|
|
8332
|
+
label: "One model",
|
|
8333
|
+
hint: "Pick a specific model"
|
|
8334
|
+
},
|
|
8335
|
+
{
|
|
8336
|
+
value: "all",
|
|
8337
|
+
label: `All models (${activeProvider.models.length})`,
|
|
8338
|
+
hint: "Every model from this provider in the model picker"
|
|
8339
|
+
},
|
|
8340
|
+
navOption("__back__", "\u2190 Back", "Choose a different provider")
|
|
8341
|
+
]
|
|
8342
|
+
});
|
|
8343
|
+
if (p11.isCancel(modelModeChoice) || modelModeChoice === "__back__") continue;
|
|
8344
|
+
if (modelModeChoice === "all") {
|
|
8345
|
+
useProviderAll = true;
|
|
8346
|
+
selectedModel = activeProvider.models[0];
|
|
8347
|
+
break;
|
|
8348
|
+
}
|
|
8349
|
+
const pickedModel = await pickCodexModel(activeProvider, prefs);
|
|
8350
|
+
if (!pickedModel) return 0;
|
|
8351
|
+
selectedModel = pickedModel;
|
|
8352
|
+
break;
|
|
8353
|
+
}
|
|
8354
|
+
}
|
|
7847
8355
|
}
|
|
7848
8356
|
}
|
|
7849
8357
|
if (activeProvider) {
|
|
@@ -7912,6 +8420,54 @@ async function runClaudeAppCommand(args, boot) {
|
|
|
7912
8420
|
seen.add(key);
|
|
7913
8421
|
return true;
|
|
7914
8422
|
});
|
|
8423
|
+
} else if (useProviderAll) {
|
|
8424
|
+
const routableProvider = providersForTarget(catalog, "claude-app").find(
|
|
8425
|
+
(lp) => lp.id === activeProvider.id
|
|
8426
|
+
);
|
|
8427
|
+
const allServerModels = localProvidersToServerModels(
|
|
8428
|
+
routableProvider ? [routableProvider] : [activeProvider]
|
|
8429
|
+
);
|
|
8430
|
+
const cloudCodeIndices = allServerModels.map((m, i) => m.modelFormat === "cloud-code" ? i : -1).filter((i) => i >= 0);
|
|
8431
|
+
if (cloudCodeIndices.length > 0 && activeProvider.apiKey) {
|
|
8432
|
+
const providerData = activeProvider.providerData ?? {};
|
|
8433
|
+
const cloudCodeModels = cloudCodeIndices.map((i) => allServerModels[i]);
|
|
8434
|
+
const cloudRoutes = cloudCodeModels.map(
|
|
8435
|
+
(model) => buildCloudCodeProxyRoute(
|
|
8436
|
+
{ id: model.id, name: model.name, modelFormat: "cloud-code" },
|
|
8437
|
+
activeProvider.apiKey,
|
|
8438
|
+
providerData
|
|
8439
|
+
)
|
|
8440
|
+
);
|
|
8441
|
+
const startingAlias = cloudRoutes[0].aliasId;
|
|
8442
|
+
cloudCodeBackend = await startCloudCodeCatalogBackend(
|
|
8443
|
+
cloudRoutes,
|
|
8444
|
+
startingAlias,
|
|
8445
|
+
trace,
|
|
8446
|
+
"claude-desktop"
|
|
8447
|
+
);
|
|
8448
|
+
const backend = cloudCodeBackend;
|
|
8449
|
+
for (let idx of cloudCodeIndices) {
|
|
8450
|
+
const m = allServerModels[idx];
|
|
8451
|
+
allServerModels[idx] = {
|
|
8452
|
+
...m,
|
|
8453
|
+
modelFormat: "anthropic",
|
|
8454
|
+
baseUrl: `http://127.0.0.1:${backend.port}`,
|
|
8455
|
+
apiBaseUrl: void 0,
|
|
8456
|
+
apiKey: backend.token,
|
|
8457
|
+
completionsUrl: void 0,
|
|
8458
|
+
authType: void 0,
|
|
8459
|
+
oauthAccountId: void 0,
|
|
8460
|
+
headers: void 0
|
|
8461
|
+
};
|
|
8462
|
+
}
|
|
8463
|
+
}
|
|
8464
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8465
|
+
serverModels = allServerModels.filter((m) => {
|
|
8466
|
+
const key = `${m.providerId}:${m.id}`;
|
|
8467
|
+
if (seen.has(key)) return false;
|
|
8468
|
+
seen.add(key);
|
|
8469
|
+
return true;
|
|
8470
|
+
});
|
|
7915
8471
|
} else if (selectedModel.modelFormat === "cloud-code") {
|
|
7916
8472
|
const providerData = activeProvider.providerData ?? {};
|
|
7917
8473
|
const cloudRoute = buildCloudCodeProxyRoute(selectedModel, activeProvider.apiKey, providerData);
|
|
@@ -7946,7 +8502,10 @@ async function runClaudeAppCommand(args, boot) {
|
|
|
7946
8502
|
catalog: createGatewayModelCatalog(serverModels, { maskGatewayIds: true }),
|
|
7947
8503
|
backends: BACKENDS,
|
|
7948
8504
|
gateway: { maskGatewayIds: true },
|
|
7949
|
-
debugLogPath
|
|
8505
|
+
debugLogPath,
|
|
8506
|
+
// Claude Desktop embeds the gateway router rather than running
|
|
8507
|
+
// `anygate server`, so attribute its traffic to the app, not 'gateway'.
|
|
8508
|
+
app: "claude-desktop"
|
|
7950
8509
|
});
|
|
7951
8510
|
uuid = writeAnygateIConfig(proxyHandle.port);
|
|
7952
8511
|
writeSessionLock2({
|
|
@@ -7983,6 +8542,10 @@ ${pc10.green("\u2714")} Proxy started on port ${proxyHandle.port}`);
|
|
|
7983
8542
|
${pc10.bold("Claude Desktop 3P Mode Active")}`);
|
|
7984
8543
|
if (useFavorites) {
|
|
7985
8544
|
console.log(`${pc10.dim("Catalog:")} Favorite models only`);
|
|
8545
|
+
} else if (useProviderAll) {
|
|
8546
|
+
console.log(
|
|
8547
|
+
`${pc10.dim("Catalog:")} All ${activeProvider.name} models (${serverModels.length})`
|
|
8548
|
+
);
|
|
7986
8549
|
} else {
|
|
7987
8550
|
console.log(`${pc10.dim("Model:")} ${selectedModel.id}`);
|
|
7988
8551
|
console.log(`${pc10.dim("Provider:")} ${activeProvider.name}`);
|
|
@@ -8015,7 +8578,7 @@ ${pc10.bold("Claude Desktop 3P Mode Active")}`);
|
|
|
8015
8578
|
// src/cli/claude-app.ts
|
|
8016
8579
|
async function handleClaudeAppCommand(parsed) {
|
|
8017
8580
|
if (parsed.showVersion) {
|
|
8018
|
-
const { VERSION: VERSION2 } = await import("./constants-
|
|
8581
|
+
const { VERSION: VERSION2 } = await import("./constants-U356SKNS.js");
|
|
8019
8582
|
console.log(VERSION2);
|
|
8020
8583
|
return 0;
|
|
8021
8584
|
}
|
|
@@ -8040,7 +8603,8 @@ This command launches the Claude Desktop app with anygate's provider registry.
|
|
|
8040
8603
|
}
|
|
8041
8604
|
return runClaudeAppCommand(parsed.claudeArgs ?? [], {
|
|
8042
8605
|
launchProvider: parsed.launchProvider,
|
|
8043
|
-
launchModel: parsed.launchModel
|
|
8606
|
+
launchModel: parsed.launchModel,
|
|
8607
|
+
launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
|
|
8044
8608
|
});
|
|
8045
8609
|
}
|
|
8046
8610
|
|
|
@@ -8933,7 +9497,8 @@ async function rewriteGeminiBackendRoutes(routes, launchModelId, trace) {
|
|
|
8933
9497
|
backendUrl: `http://127.0.0.1:${backend.port}`,
|
|
8934
9498
|
apiKey: backend.token
|
|
8935
9499
|
}),
|
|
8936
|
-
trace
|
|
9500
|
+
trace,
|
|
9501
|
+
"gemini"
|
|
8937
9502
|
);
|
|
8938
9503
|
if (!partitioned.backend) {
|
|
8939
9504
|
return { routes, launchModelId, backend: null };
|
|
@@ -9013,8 +9578,9 @@ async function runGeminiCommand(geminiArgs, trace = false, launch = {}) {
|
|
|
9013
9578
|
const agentStdout = wantsCleanAgentStdout("gemini", passthroughArgs);
|
|
9014
9579
|
setAgentStdoutMode(agentStdout);
|
|
9015
9580
|
const prefs = loadPreferences();
|
|
9581
|
+
const launchAllModels = Boolean(launch.launchAllModels || launch.launchModel === "All");
|
|
9016
9582
|
const launchPlan = planLaunchWizard({
|
|
9017
|
-
explicit: { providerId: launch.launchProvider, modelId: launch.launchModel },
|
|
9583
|
+
explicit: launchAllModels ? { providerId: launch.launchProvider, allModels: true } : { providerId: launch.launchProvider, modelId: launch.launchModel },
|
|
9018
9584
|
childArgs: passthroughArgs,
|
|
9019
9585
|
agent: "gemini",
|
|
9020
9586
|
prefs
|
|
@@ -9209,6 +9775,13 @@ Error: ${launchPlan.error}
|
|
|
9209
9775
|
if (!agentStdout) {
|
|
9210
9776
|
p13.log.info(`Gemini proxy started on port ${proxyHandle.port}`);
|
|
9211
9777
|
p13.log.info(`\u{1F4A1} Type ${pc11.bold(".model <id>")} in the chat to switch models mid-session.`);
|
|
9778
|
+
if (launchAllModels) {
|
|
9779
|
+
p13.log.info(
|
|
9780
|
+
pc11.dim(
|
|
9781
|
+
`All ${activeProvider.models.length} ${activeProvider.name} models are available \u2014 type .model <id> to switch.`
|
|
9782
|
+
)
|
|
9783
|
+
);
|
|
9784
|
+
}
|
|
9212
9785
|
}
|
|
9213
9786
|
let exitCode = 1;
|
|
9214
9787
|
try {
|
|
@@ -9230,7 +9803,7 @@ Error: ${launchPlan.error}
|
|
|
9230
9803
|
// src/cli/gemini.ts
|
|
9231
9804
|
async function handleGeminiCommand(parsed) {
|
|
9232
9805
|
if (parsed.showVersion) {
|
|
9233
|
-
const { VERSION: VERSION2 } = await import("./constants-
|
|
9806
|
+
const { VERSION: VERSION2 } = await import("./constants-U356SKNS.js");
|
|
9234
9807
|
console.log(VERSION2);
|
|
9235
9808
|
return 0;
|
|
9236
9809
|
}
|
|
@@ -9240,7 +9813,8 @@ async function handleGeminiCommand(parsed) {
|
|
|
9240
9813
|
}
|
|
9241
9814
|
return runGeminiCommand(parsed.claudeArgs ?? [], parsed.trace ?? false, {
|
|
9242
9815
|
launchProvider: parsed.launchProvider,
|
|
9243
|
-
launchModel: parsed.launchModel
|
|
9816
|
+
launchModel: parsed.launchModel,
|
|
9817
|
+
launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
|
|
9244
9818
|
});
|
|
9245
9819
|
}
|
|
9246
9820
|
|
|
@@ -12255,6 +12829,15 @@ async function resolveAntigravityLaunch(prefs, boot) {
|
|
|
12255
12829
|
p14.log.info(pc12.dim("Run anygate providers add or import to get started."));
|
|
12256
12830
|
return null;
|
|
12257
12831
|
}
|
|
12832
|
+
if (boot?.launchProvider && boot?.launchAllModels) {
|
|
12833
|
+
const provider = allProviders.find((p18) => p18.id === boot.launchProvider);
|
|
12834
|
+
if (!provider) {
|
|
12835
|
+
p14.log.error(`Provider not found: ${boot.launchProvider}`);
|
|
12836
|
+
return null;
|
|
12837
|
+
}
|
|
12838
|
+
const model = provider.models[0];
|
|
12839
|
+
return { provider, model, allProviders, allModels: true };
|
|
12840
|
+
}
|
|
12258
12841
|
if (boot?.launchProvider && boot?.launchModel) {
|
|
12259
12842
|
const provider = allProviders.find((p18) => p18.id === boot.launchProvider);
|
|
12260
12843
|
if (!provider) {
|
|
@@ -12311,11 +12894,15 @@ async function resolveAntigravityLaunch(prefs, boot) {
|
|
|
12311
12894
|
}
|
|
12312
12895
|
}
|
|
12313
12896
|
async function resolveAndBuildRoutes(provider, model, allProviders, prefs, opts) {
|
|
12897
|
+
const allModelsFavorites = opts.allModels ? provider.models.map((m) => ({
|
|
12898
|
+
providerId: provider.id,
|
|
12899
|
+
modelId: m.id
|
|
12900
|
+
})) : [];
|
|
12314
12901
|
const result = await resolveAntigravityLaunchRoutes({
|
|
12315
12902
|
provider,
|
|
12316
12903
|
model,
|
|
12317
12904
|
allProviders,
|
|
12318
|
-
favorites: prefs.antigravityCliFavoriteModels ?? [],
|
|
12905
|
+
favorites: opts.allModels ? allModelsFavorites : prefs.antigravityCliFavoriteModels ?? [],
|
|
12319
12906
|
maxRoutes: opts.maxRoutes
|
|
12320
12907
|
});
|
|
12321
12908
|
if (!result) {
|
|
@@ -12429,7 +13016,8 @@ async function launchWithSelection(selection, prefs, opts, trace, tracePrefix, b
|
|
|
12429
13016
|
maxRoutes: routeLimit,
|
|
12430
13017
|
validatedSlotCount: routeLimit,
|
|
12431
13018
|
pauseForCapacityWarning: opts.pauseForCapacityWarning ?? false,
|
|
12432
|
-
childArgs: opts.childArgs ?? []
|
|
13019
|
+
childArgs: opts.childArgs ?? [],
|
|
13020
|
+
allModels: selection.allModels
|
|
12433
13021
|
});
|
|
12434
13022
|
if (!routeResult) return 1;
|
|
12435
13023
|
savePreferences({
|
|
@@ -12674,7 +13262,7 @@ Examples:
|
|
|
12674
13262
|
`;
|
|
12675
13263
|
async function handleAgyCommand(parsed) {
|
|
12676
13264
|
if (parsed.showVersion) {
|
|
12677
|
-
const { VERSION: VERSION2 } = await import("./constants-
|
|
13265
|
+
const { VERSION: VERSION2 } = await import("./constants-U356SKNS.js");
|
|
12678
13266
|
console.log(VERSION2);
|
|
12679
13267
|
return 0;
|
|
12680
13268
|
}
|
|
@@ -12684,12 +13272,13 @@ async function handleAgyCommand(parsed) {
|
|
|
12684
13272
|
}
|
|
12685
13273
|
return runAgyCommand(parsed.claudeArgs ?? [], parsed.trace ?? false, {
|
|
12686
13274
|
launchProvider: parsed.launchProvider,
|
|
12687
|
-
launchModel: parsed.launchModel
|
|
13275
|
+
launchModel: parsed.launchModel,
|
|
13276
|
+
launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
|
|
12688
13277
|
});
|
|
12689
13278
|
}
|
|
12690
13279
|
async function handleAntigravityAppCommand(parsed) {
|
|
12691
13280
|
if (parsed.showVersion) {
|
|
12692
|
-
const { VERSION: VERSION2 } = await import("./constants-
|
|
13281
|
+
const { VERSION: VERSION2 } = await import("./constants-U356SKNS.js");
|
|
12693
13282
|
console.log(VERSION2);
|
|
12694
13283
|
return 0;
|
|
12695
13284
|
}
|
|
@@ -12699,12 +13288,13 @@ async function handleAntigravityAppCommand(parsed) {
|
|
|
12699
13288
|
}
|
|
12700
13289
|
return runAntigravityAppCommand(parsed.claudeArgs ?? [], parsed.trace ?? false, {
|
|
12701
13290
|
launchProvider: parsed.launchProvider,
|
|
12702
|
-
launchModel: parsed.launchModel
|
|
13291
|
+
launchModel: parsed.launchModel,
|
|
13292
|
+
launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
|
|
12703
13293
|
});
|
|
12704
13294
|
}
|
|
12705
13295
|
async function handleAntigravityIdeCommand(parsed) {
|
|
12706
13296
|
if (parsed.showVersion) {
|
|
12707
|
-
const { VERSION: VERSION2 } = await import("./constants-
|
|
13297
|
+
const { VERSION: VERSION2 } = await import("./constants-U356SKNS.js");
|
|
12708
13298
|
console.log(VERSION2);
|
|
12709
13299
|
return 0;
|
|
12710
13300
|
}
|
|
@@ -12714,7 +13304,8 @@ async function handleAntigravityIdeCommand(parsed) {
|
|
|
12714
13304
|
}
|
|
12715
13305
|
return runAntigravityIdeCommand(parsed.claudeArgs ?? [], parsed.trace ?? false, {
|
|
12716
13306
|
launchProvider: parsed.launchProvider,
|
|
12717
|
-
launchModel: parsed.launchModel
|
|
13307
|
+
launchModel: parsed.launchModel,
|
|
13308
|
+
launchAllModels: parsed.launchAllModels || parsed.launchModel === "All"
|
|
12718
13309
|
});
|
|
12719
13310
|
}
|
|
12720
13311
|
|
|
@@ -12809,7 +13400,7 @@ Options:
|
|
|
12809
13400
|
`);
|
|
12810
13401
|
return 0;
|
|
12811
13402
|
}
|
|
12812
|
-
const { runUiCommand } = await import("./command-
|
|
13403
|
+
const { runUiCommand } = await import("./command-N3R2ZVVS.js");
|
|
12813
13404
|
return runUiCommand({ trace: parsed.trace });
|
|
12814
13405
|
}
|
|
12815
13406
|
|
|
@@ -13238,7 +13829,7 @@ async function runValidateSubcommand(parsed) {
|
|
|
13238
13829
|
// src/cli/providers.ts
|
|
13239
13830
|
async function handleProvidersCommand(parsed) {
|
|
13240
13831
|
if (parsed.showVersion) {
|
|
13241
|
-
const { VERSION: VERSION2 } = await import("./constants-
|
|
13832
|
+
const { VERSION: VERSION2 } = await import("./constants-U356SKNS.js");
|
|
13242
13833
|
console.log(VERSION2);
|
|
13243
13834
|
return 0;
|
|
13244
13835
|
}
|
|
@@ -13351,7 +13942,7 @@ async function runDoctorCommand(_dryRun) {
|
|
|
13351
13942
|
// src/cli/doctor.ts
|
|
13352
13943
|
async function handleDoctorCommand(parsed) {
|
|
13353
13944
|
if (parsed.showVersion) {
|
|
13354
|
-
const { VERSION: VERSION2 } = await import("./constants-
|
|
13945
|
+
const { VERSION: VERSION2 } = await import("./constants-U356SKNS.js");
|
|
13355
13946
|
console.log(VERSION2);
|
|
13356
13947
|
return 0;
|
|
13357
13948
|
}
|
|
@@ -13491,7 +14082,7 @@ function runCompletionsCommand(shellArg) {
|
|
|
13491
14082
|
// src/cli/completions.ts
|
|
13492
14083
|
async function handleCompletionsCommand(parsed) {
|
|
13493
14084
|
if (parsed.showVersion) {
|
|
13494
|
-
const { VERSION: VERSION2 } = await import("./constants-
|
|
14085
|
+
const { VERSION: VERSION2 } = await import("./constants-U356SKNS.js");
|
|
13495
14086
|
console.log(VERSION2);
|
|
13496
14087
|
return 0;
|
|
13497
14088
|
}
|
|
@@ -13518,18 +14109,11 @@ Examples:
|
|
|
13518
14109
|
|
|
13519
14110
|
// src/apps/shared/self-update.ts
|
|
13520
14111
|
import pc17 from "picocolors";
|
|
13521
|
-
import { spawn as spawn5
|
|
14112
|
+
import { spawn as spawn5 } from "child_process";
|
|
13522
14113
|
import * as p17 from "@clack/prompts";
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
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";
|
|
14114
|
+
var INSTALL_ARGS = ["install", "-g", "anygate@latest"];
|
|
14115
|
+
function resolveNpmSpawn() {
|
|
14116
|
+
return { bin: "npm", shell: process.platform === "win32" };
|
|
13533
14117
|
}
|
|
13534
14118
|
async function runUpdateCommand(dryRun) {
|
|
13535
14119
|
const update = await checkForUpdates();
|
|
@@ -13540,9 +14124,9 @@ async function runUpdateCommand(dryRun) {
|
|
|
13540
14124
|
p17.log.info(
|
|
13541
14125
|
`Update available: ${pc17.cyan(`v${update.currentVersion}`)} \u2192 ${pc17.green(`v${update.latestVersion}`)}`
|
|
13542
14126
|
);
|
|
13543
|
-
const npmBin =
|
|
14127
|
+
const { bin: npmBin, shell } = resolveNpmSpawn();
|
|
13544
14128
|
if (dryRun) {
|
|
13545
|
-
p17.log.step(`Would run: ${pc17.bold(`${npmBin}
|
|
14129
|
+
p17.log.step(`Would run: ${pc17.bold(`${npmBin} ${INSTALL_ARGS.join(" ")}`)}`);
|
|
13546
14130
|
p17.log.warn("Dry run \u2014 no changes made.");
|
|
13547
14131
|
return 0;
|
|
13548
14132
|
}
|
|
@@ -13554,17 +14138,27 @@ async function runUpdateCommand(dryRun) {
|
|
|
13554
14138
|
p17.log.info(`Update skipped. Run ${pc17.cyan(UPDATE_COMMAND)} later if you change your mind.`);
|
|
13555
14139
|
return 0;
|
|
13556
14140
|
}
|
|
13557
|
-
p17.log.info(`Running ${pc17.cyan(`${npmBin}
|
|
13558
|
-
const child = spawn5(npmBin, [
|
|
14141
|
+
p17.log.info(`Running ${pc17.cyan(`${npmBin} ${INSTALL_ARGS.join(" ")}`)}...`);
|
|
14142
|
+
const child = spawn5(npmBin, [...INSTALL_ARGS], {
|
|
13559
14143
|
stdio: "inherit",
|
|
14144
|
+
shell,
|
|
13560
14145
|
windowsHide: true
|
|
13561
14146
|
});
|
|
13562
14147
|
return new Promise((resolve) => {
|
|
14148
|
+
let settled = false;
|
|
14149
|
+
const settle = (code) => {
|
|
14150
|
+
settled = true;
|
|
14151
|
+
resolve(code);
|
|
14152
|
+
};
|
|
13563
14153
|
child.on("error", (err) => {
|
|
13564
|
-
|
|
13565
|
-
|
|
14154
|
+
if (settled) return;
|
|
14155
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
14156
|
+
p17.log.error(`Could not start npm: ${msg}`);
|
|
14157
|
+
p17.log.info(`Update anygate manually with: ${pc17.cyan(UPDATE_COMMAND)}`);
|
|
14158
|
+
settle(1);
|
|
13566
14159
|
});
|
|
13567
14160
|
child.on("close", (code) => {
|
|
14161
|
+
if (settled) return;
|
|
13568
14162
|
if (code === 0) {
|
|
13569
14163
|
p17.log.success(
|
|
13570
14164
|
"anygate updated. Restart your shell or re-run anygate to use the new version."
|
|
@@ -13572,7 +14166,7 @@ async function runUpdateCommand(dryRun) {
|
|
|
13572
14166
|
} else {
|
|
13573
14167
|
p17.log.error(`Update failed (exit ${code}). Try ${pc17.cyan(UPDATE_COMMAND)} manually.`);
|
|
13574
14168
|
}
|
|
13575
|
-
|
|
14169
|
+
settle(code ?? 1);
|
|
13576
14170
|
});
|
|
13577
14171
|
});
|
|
13578
14172
|
}
|
|
@@ -13580,7 +14174,7 @@ async function runUpdateCommand(dryRun) {
|
|
|
13580
14174
|
// src/cli/update.ts
|
|
13581
14175
|
async function handleUpdateCommand(parsed) {
|
|
13582
14176
|
if (parsed.showVersion) {
|
|
13583
|
-
const { VERSION: VERSION2 } = await import("./constants-
|
|
14177
|
+
const { VERSION: VERSION2 } = await import("./constants-U356SKNS.js");
|
|
13584
14178
|
console.log(VERSION2);
|
|
13585
14179
|
return 0;
|
|
13586
14180
|
}
|
|
@@ -13644,8 +14238,16 @@ var STARTER_CLAUDE_FLAGS = /* @__PURE__ */ new Set([
|
|
|
13644
14238
|
"--version",
|
|
13645
14239
|
"-v"
|
|
13646
14240
|
]);
|
|
13647
|
-
var GATEWAY_LAUNCH_FLAGS = /* @__PURE__ */ new Set(["--provider", "--model"]);
|
|
14241
|
+
var GATEWAY_LAUNCH_FLAGS = /* @__PURE__ */ new Set(["--provider", "--model", "--all-models", "--with-claude"]);
|
|
13648
14242
|
function parseGatewayLaunchFlag(arg, rest, index, parsed) {
|
|
14243
|
+
if (arg === "--all-models") {
|
|
14244
|
+
parsed.launchAllModels = true;
|
|
14245
|
+
return index;
|
|
14246
|
+
}
|
|
14247
|
+
if (arg === "--with-claude") {
|
|
14248
|
+
parsed.launchWithClaude = true;
|
|
14249
|
+
return index;
|
|
14250
|
+
}
|
|
13649
14251
|
if (arg === "--provider" || arg === "--model") {
|
|
13650
14252
|
const value = rest[index + 1];
|
|
13651
14253
|
if (!value || value.startsWith("-")) {
|
|
@@ -14158,6 +14760,8 @@ ${pc18.bold("Options:")}
|
|
|
14158
14760
|
--trace Write debug logs to ~/.anygate/logs/ and show errors on exit
|
|
14159
14761
|
--provider Boot provider id (skip wizard when paired with --model or in print mode)
|
|
14160
14762
|
--model Boot model id (skip wizard when paired with --provider or in print mode)
|
|
14763
|
+
--all-models Launch with every model from --provider in the /model switcher
|
|
14764
|
+
--with-claude Keep your Anthropic-subscription models in /model alongside the anygate model
|
|
14161
14765
|
--help Show this command help
|
|
14162
14766
|
--version Show version
|
|
14163
14767
|
|