claude-use 11.34.0 → 11.36.0
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 +2 -1
- package/dist/cli.cjs +392 -301
- package/dist/index.cjs +312 -240
- package/dist/index.mjs +313 -241
- package/dist/types/index.d.ts +15 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -31706,6 +31706,196 @@ var init_identity = __esm({
|
|
|
31706
31706
|
}
|
|
31707
31707
|
});
|
|
31708
31708
|
|
|
31709
|
+
// src/configProfilesStore.ts
|
|
31710
|
+
function profileJsonPath(paths, name) {
|
|
31711
|
+
return import_node_path12.default.join(paths.configProfilesDir, `${name}.json`);
|
|
31712
|
+
}
|
|
31713
|
+
function profileExists(paths, name) {
|
|
31714
|
+
return import_node_fs5.default.existsSync(profileJsonPath(paths, name));
|
|
31715
|
+
}
|
|
31716
|
+
function requireProfileExists(paths, name) {
|
|
31717
|
+
if (!profileExists(paths, name)) {
|
|
31718
|
+
throw new ProfileNotFoundError(name);
|
|
31719
|
+
}
|
|
31720
|
+
}
|
|
31721
|
+
function readProfile(paths, name) {
|
|
31722
|
+
return readJson(profileJsonPath(paths, name), ConfigProfileSchema);
|
|
31723
|
+
}
|
|
31724
|
+
function createProfile(paths, name, extendsList, description) {
|
|
31725
|
+
if (profileExists(paths, name)) {
|
|
31726
|
+
throw new ProfileAlreadyExistsError(name);
|
|
31727
|
+
}
|
|
31728
|
+
const filePath = profileJsonPath(paths, name);
|
|
31729
|
+
const parsed = ConfigProfileSchema.safeParse({
|
|
31730
|
+
...description === void 0 ? {} : { description },
|
|
31731
|
+
...extendsList !== void 0 && extendsList.length > 0 ? { extends: [...extendsList] } : {}
|
|
31732
|
+
});
|
|
31733
|
+
if (!parsed.success) {
|
|
31734
|
+
throw new ConfigValidationError(filePath, parsed.error.issues);
|
|
31735
|
+
}
|
|
31736
|
+
writeJsonAtomic(filePath, parsed.data);
|
|
31737
|
+
return parsed.data;
|
|
31738
|
+
}
|
|
31739
|
+
function listProfiles(paths) {
|
|
31740
|
+
if (!import_node_fs5.default.existsSync(paths.configProfilesDir)) {
|
|
31741
|
+
return [];
|
|
31742
|
+
}
|
|
31743
|
+
const names = import_node_fs5.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort();
|
|
31744
|
+
const result = [];
|
|
31745
|
+
for (const name of names) {
|
|
31746
|
+
const profile = readProfile(paths, name);
|
|
31747
|
+
if (profile !== void 0) {
|
|
31748
|
+
result.push({ name, profile });
|
|
31749
|
+
}
|
|
31750
|
+
}
|
|
31751
|
+
return result;
|
|
31752
|
+
}
|
|
31753
|
+
function globalConfigPath(paths) {
|
|
31754
|
+
return paths.globalConfigFile;
|
|
31755
|
+
}
|
|
31756
|
+
function readGlobalConfig(paths) {
|
|
31757
|
+
return readJson(globalConfigPath(paths), GlobalConfigSchema);
|
|
31758
|
+
}
|
|
31759
|
+
function setGlobalDefaultProfile(paths, name) {
|
|
31760
|
+
return applyPatch(
|
|
31761
|
+
globalConfigPath(paths),
|
|
31762
|
+
GlobalConfigSchema,
|
|
31763
|
+
{ defaultConfigProfile: name },
|
|
31764
|
+
{ defaults: {} }
|
|
31765
|
+
);
|
|
31766
|
+
}
|
|
31767
|
+
function validateCategoryNames(patch) {
|
|
31768
|
+
for (const key of Object.keys(patch)) {
|
|
31769
|
+
if (!isOverridableCategory(key)) {
|
|
31770
|
+
throw new InvalidCategoryNameError(key);
|
|
31771
|
+
}
|
|
31772
|
+
}
|
|
31773
|
+
}
|
|
31774
|
+
function setProfileCategories(paths, name, patch) {
|
|
31775
|
+
requireProfileExists(paths, name);
|
|
31776
|
+
const expandedPatch = expandAllCategoryKey(patch);
|
|
31777
|
+
validateCategoryNames(expandedPatch);
|
|
31778
|
+
const existing = readProfile(paths, name) ?? {};
|
|
31779
|
+
const mergedCategories = { ...existing.categories, ...expandedPatch };
|
|
31780
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { categories: mergedCategories });
|
|
31781
|
+
}
|
|
31782
|
+
function setProfileEntries(paths, name, patch) {
|
|
31783
|
+
requireProfileExists(paths, name);
|
|
31784
|
+
const existing = readProfile(paths, name) ?? {};
|
|
31785
|
+
const mergedEntries = { ...existing.entries, ...patch };
|
|
31786
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { entries: mergedEntries });
|
|
31787
|
+
}
|
|
31788
|
+
function setProfileLaunchFlags(paths, name, patch) {
|
|
31789
|
+
requireProfileExists(paths, name);
|
|
31790
|
+
const existing = readProfile(paths, name) ?? {};
|
|
31791
|
+
const mergedLaunch = { ...existing.launch, ...patch };
|
|
31792
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
31793
|
+
// Read as `unknown` so the check sees the `undefined` a cleared key holds, which LaunchFlags' optional properties hide from the value type.
|
|
31794
|
+
launch: Object.values(mergedLaunch).every((value2) => value2 === void 0) ? void 0 : mergedLaunch
|
|
31795
|
+
});
|
|
31796
|
+
}
|
|
31797
|
+
function setProfileMetadata(paths, name, patch) {
|
|
31798
|
+
requireProfileExists(paths, name);
|
|
31799
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
31800
|
+
...patch.extends === void 0 ? {} : { extends: patch.extends.length === 0 ? void 0 : [...patch.extends] },
|
|
31801
|
+
...patch.description === void 0 ? {} : { description: patch.description === false ? void 0 : patch.description }
|
|
31802
|
+
});
|
|
31803
|
+
}
|
|
31804
|
+
function removeProfile(paths, name) {
|
|
31805
|
+
requireProfileExists(paths, name);
|
|
31806
|
+
import_node_fs5.default.rmSync(profileJsonPath(paths, name));
|
|
31807
|
+
}
|
|
31808
|
+
function applyProfileChange(paths, name, change) {
|
|
31809
|
+
let touched = false;
|
|
31810
|
+
if (change.category !== void 0) {
|
|
31811
|
+
setProfileCategories(paths, name, change.category);
|
|
31812
|
+
touched = true;
|
|
31813
|
+
}
|
|
31814
|
+
if (change.entry !== void 0) {
|
|
31815
|
+
setProfileEntries(paths, name, change.entry);
|
|
31816
|
+
touched = true;
|
|
31817
|
+
}
|
|
31818
|
+
if (change.extends !== void 0 || change.description !== void 0) {
|
|
31819
|
+
setProfileMetadata(paths, name, {
|
|
31820
|
+
...change.extends === void 0 ? {} : { extends: change.extends === false ? [] : change.extends },
|
|
31821
|
+
...change.description === void 0 ? {} : { description: change.description }
|
|
31822
|
+
});
|
|
31823
|
+
touched = true;
|
|
31824
|
+
}
|
|
31825
|
+
const launchPatch = {};
|
|
31826
|
+
if (change.launchSkipPermissions !== void 0) {
|
|
31827
|
+
launchPatch.skipPermissions = change.launchSkipPermissions;
|
|
31828
|
+
}
|
|
31829
|
+
if (change.launchRemoteControl !== void 0) {
|
|
31830
|
+
launchPatch.remoteControl = change.launchRemoteControl;
|
|
31831
|
+
}
|
|
31832
|
+
if (change.launchHeadroom !== void 0) {
|
|
31833
|
+
launchPatch.headroom = change.launchHeadroom;
|
|
31834
|
+
}
|
|
31835
|
+
if (change.launchTrackUsage !== void 0) {
|
|
31836
|
+
launchPatch.trackUsage = change.launchTrackUsage;
|
|
31837
|
+
}
|
|
31838
|
+
if (change.launchProvider !== void 0) {
|
|
31839
|
+
launchPatch.provider = change.launchProvider === false ? void 0 : change.launchProvider;
|
|
31840
|
+
}
|
|
31841
|
+
if (change.launchClaudeVersion !== void 0) {
|
|
31842
|
+
launchPatch.claudeVersion = change.launchClaudeVersion === false ? void 0 : change.launchClaudeVersion;
|
|
31843
|
+
}
|
|
31844
|
+
if (change.launchDelay !== void 0) {
|
|
31845
|
+
launchPatch.delay = change.launchDelay === false ? void 0 : change.launchDelay;
|
|
31846
|
+
}
|
|
31847
|
+
if (change.launchPause !== void 0) {
|
|
31848
|
+
launchPatch.pause = change.launchPause;
|
|
31849
|
+
}
|
|
31850
|
+
if (change.launchExplain !== void 0) {
|
|
31851
|
+
launchPatch.explain = change.launchExplain;
|
|
31852
|
+
}
|
|
31853
|
+
if (change.launchRouteByName !== void 0) {
|
|
31854
|
+
launchPatch.routeByName = change.launchRouteByName;
|
|
31855
|
+
}
|
|
31856
|
+
if (Object.keys(launchPatch).length > 0) {
|
|
31857
|
+
setProfileLaunchFlags(paths, name, launchPatch);
|
|
31858
|
+
touched = true;
|
|
31859
|
+
}
|
|
31860
|
+
return touched;
|
|
31861
|
+
}
|
|
31862
|
+
var import_node_fs5, import_node_path12, ProfileNotFoundError, ProfileAlreadyExistsError, InvalidCategoryNameError;
|
|
31863
|
+
var init_configProfilesStore = __esm({
|
|
31864
|
+
"src/configProfilesStore.ts"() {
|
|
31865
|
+
"use strict";
|
|
31866
|
+
import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
31867
|
+
import_node_path12 = __toESM(require("node:path"), 1);
|
|
31868
|
+
init_store();
|
|
31869
|
+
init_schema();
|
|
31870
|
+
init_cliError();
|
|
31871
|
+
init_load();
|
|
31872
|
+
ProfileNotFoundError = class extends CliError {
|
|
31873
|
+
constructor(profileName) {
|
|
31874
|
+
super(`No configuration profile named "${profileName}". Run \`agent-shim profile add ${profileName}\` first.`);
|
|
31875
|
+
this.profileName = profileName;
|
|
31876
|
+
this.name = "ProfileNotFoundError";
|
|
31877
|
+
}
|
|
31878
|
+
profileName;
|
|
31879
|
+
};
|
|
31880
|
+
ProfileAlreadyExistsError = class extends CliError {
|
|
31881
|
+
constructor(profileName) {
|
|
31882
|
+
super(`A configuration profile named "${profileName}" already exists.`);
|
|
31883
|
+
this.profileName = profileName;
|
|
31884
|
+
this.name = "ProfileAlreadyExistsError";
|
|
31885
|
+
}
|
|
31886
|
+
profileName;
|
|
31887
|
+
};
|
|
31888
|
+
InvalidCategoryNameError = class extends CliError {
|
|
31889
|
+
constructor(categoryName) {
|
|
31890
|
+
super(`"${categoryName}" is not a category a configuration profile may toggle (runtime, history, knowledge, settings).`);
|
|
31891
|
+
this.categoryName = categoryName;
|
|
31892
|
+
this.name = "InvalidCategoryNameError";
|
|
31893
|
+
}
|
|
31894
|
+
categoryName;
|
|
31895
|
+
};
|
|
31896
|
+
}
|
|
31897
|
+
});
|
|
31898
|
+
|
|
31709
31899
|
// src/launcher/lock.ts
|
|
31710
31900
|
function identityLockPath(dir, identity) {
|
|
31711
31901
|
return import_node_path13.default.join(dir, `.${identity}.lock`);
|
|
@@ -32631,6 +32821,9 @@ function flattenLayers(layers, options) {
|
|
|
32631
32821
|
if (layer.launch.explain !== void 0) {
|
|
32632
32822
|
launch.explain = layer.launch.explain;
|
|
32633
32823
|
}
|
|
32824
|
+
if (layer.launch.routeByName !== void 0) {
|
|
32825
|
+
launch.routeByName = layer.launch.routeByName;
|
|
32826
|
+
}
|
|
32634
32827
|
}
|
|
32635
32828
|
if (layer.models !== void 0) {
|
|
32636
32829
|
models = mergeModels(models, layer.models);
|
|
@@ -34442,7 +34635,7 @@ var init_package = __esm({
|
|
|
34442
34635
|
"package.json"() {
|
|
34443
34636
|
package_default = {
|
|
34444
34637
|
name: "claude-use",
|
|
34445
|
-
version: "11.
|
|
34638
|
+
version: "11.36.0",
|
|
34446
34639
|
description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
|
|
34447
34640
|
license: "MIT",
|
|
34448
34641
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -34707,6 +34900,7 @@ function identifyRequest(headers) {
|
|
|
34707
34900
|
sessionId: internalHeaderValue(headers, SESSION_HEADER),
|
|
34708
34901
|
provider: internalHeaderValue(headers, PROVIDER_HEADER),
|
|
34709
34902
|
headroom: internalHeaderValue(headers, HEADROOM_FLAG_HEADER) === "1",
|
|
34903
|
+
routeByName: internalHeaderValue(headers, ROUTE_BY_NAME_HEADER) === "1",
|
|
34710
34904
|
projectId: internalHeaderValue(headers, PROJECT_ID_HEADER)
|
|
34711
34905
|
},
|
|
34712
34906
|
forwardableHeaders: forwardable
|
|
@@ -34726,7 +34920,7 @@ function parseProviderPath(path65) {
|
|
|
34726
34920
|
}
|
|
34727
34921
|
return { provider: decodeURIComponent(tail.slice(0, slash)), rest: tail.slice(slash) };
|
|
34728
34922
|
}
|
|
34729
|
-
var HEADROOM_SESSION_HEADER, INTERNAL_HEADER_NAMES, IDENTITY_HEADER, SESSION_HEADER, PROVIDER_HEADER, HEADROOM_FLAG_HEADER, PROJECT_ID_HEADER, CLIENT_SESSION_HEADER, HEADROOM_BASE_URL_HEADER, AUTH_HEADER, HOP_SECRET_HEADER, HOP_ID_HEADER, PROVIDER_PATH_PREFIX;
|
|
34923
|
+
var HEADROOM_SESSION_HEADER, INTERNAL_HEADER_NAMES, IDENTITY_HEADER, SESSION_HEADER, PROVIDER_HEADER, HEADROOM_FLAG_HEADER, ROUTE_BY_NAME_HEADER, PROJECT_ID_HEADER, CLIENT_SESSION_HEADER, HEADROOM_BASE_URL_HEADER, AUTH_HEADER, HOP_SECRET_HEADER, HOP_ID_HEADER, PROVIDER_PATH_PREFIX;
|
|
34730
34924
|
var init_route = __esm({
|
|
34731
34925
|
"src/frontdoor/route.ts"() {
|
|
34732
34926
|
"use strict";
|
|
@@ -34735,6 +34929,7 @@ var init_route = __esm({
|
|
|
34735
34929
|
"x-agent-shim-identity",
|
|
34736
34930
|
"x-agent-shim-session",
|
|
34737
34931
|
"x-agent-shim-headroom",
|
|
34932
|
+
"x-agent-shim-route-by-name",
|
|
34738
34933
|
"x-agent-shim-auth",
|
|
34739
34934
|
"x-agent-shim-provider",
|
|
34740
34935
|
"x-agent-shim-hop",
|
|
@@ -34747,6 +34942,7 @@ var init_route = __esm({
|
|
|
34747
34942
|
SESSION_HEADER = "x-agent-shim-session";
|
|
34748
34943
|
PROVIDER_HEADER = "x-agent-shim-provider";
|
|
34749
34944
|
HEADROOM_FLAG_HEADER = "x-agent-shim-headroom";
|
|
34945
|
+
ROUTE_BY_NAME_HEADER = "x-agent-shim-route-by-name";
|
|
34750
34946
|
PROJECT_ID_HEADER = "x-headroom-project-id";
|
|
34751
34947
|
CLIENT_SESSION_HEADER = "x-claude-code-session-id";
|
|
34752
34948
|
HEADROOM_BASE_URL_HEADER = "x-headroom-base-url";
|
|
@@ -63266,7 +63462,8 @@ var init_argv = __esm({
|
|
|
63266
63462
|
{ flag: "--remote-control", key: "remoteControl" },
|
|
63267
63463
|
{ flag: "--wait", key: "wait" },
|
|
63268
63464
|
{ flag: "--pause", key: "pause" },
|
|
63269
|
-
{ flag: "--explain", key: "explain" }
|
|
63465
|
+
{ flag: "--explain", key: "explain" },
|
|
63466
|
+
{ flag: "--route-by-name", key: "routeByName" }
|
|
63270
63467
|
];
|
|
63271
63468
|
LAUNCHER_FLAG_NAMES = [
|
|
63272
63469
|
...VALUED_FLAGS,
|
|
@@ -63456,6 +63653,7 @@ function resolveLaunchFlags(params) {
|
|
|
63456
63653
|
trackUsage: params.flags?.trackUsage ?? parseEnvBool("AGENT_SHIM_TRACK_USAGE", params.env.AGENT_SHIM_TRACK_USAGE) ?? params.cascade?.trackUsage ?? true,
|
|
63457
63654
|
pause: params.flags?.pause ?? parseEnvBool("AGENT_SHIM_PAUSE", params.env.AGENT_SHIM_PAUSE) ?? params.cascade?.pause ?? false,
|
|
63458
63655
|
explain: params.flags?.explain ?? parseEnvBool("AGENT_SHIM_EXPLAIN", params.env.AGENT_SHIM_EXPLAIN) ?? params.cascade?.explain ?? false,
|
|
63656
|
+
routeByName: params.flags?.routeByName ?? parseEnvBool("AGENT_SHIM_ROUTE_BY_NAME", params.env.AGENT_SHIM_ROUTE_BY_NAME) ?? params.cascade?.routeByName ?? false,
|
|
63459
63657
|
delayMs: resolveDelayMs(params)
|
|
63460
63658
|
};
|
|
63461
63659
|
}
|
|
@@ -63524,6 +63722,7 @@ function buildEnv(params) {
|
|
|
63524
63722
|
{ name: SESSION_HEADER, value: params.sessionId },
|
|
63525
63723
|
{ name: AUTH_HEADER, value: params.frontdoor.sessionToken },
|
|
63526
63724
|
...params.provider === void 0 ? [] : [{ name: PROVIDER_HEADER, value: params.provider.name }],
|
|
63725
|
+
...params.routeByName ? [{ name: ROUTE_BY_NAME_HEADER, value: "1" }] : [],
|
|
63527
63726
|
...params.headroom === void 0 ? [] : [
|
|
63528
63727
|
{ name: HEADROOM_FLAG_HEADER, value: "1" },
|
|
63529
63728
|
{ name: PROJECT_ID_HEADER, value: params.headroom.projectId }
|
|
@@ -65207,8 +65406,40 @@ function providerModelRows(provider, catalogue = []) {
|
|
|
65207
65406
|
const taken = new Set(named.map((row) => labelOf(row.model)));
|
|
65208
65407
|
return [...named, ...catalogueRows(provider, catalogue).filter((row) => !taken.has(labelOf(row.model)))];
|
|
65209
65408
|
}
|
|
65409
|
+
function routedModelRows(models, providers) {
|
|
65410
|
+
const hidden = new Set(models.hide ?? []);
|
|
65411
|
+
const shown = models.show === void 0 ? void 0 : new Set(models.show);
|
|
65412
|
+
const visible = (model) => shown === void 0 ? !hidden.has(model) : shown.has(model);
|
|
65413
|
+
const tierOf = (model) => {
|
|
65414
|
+
for (const [, provider] of providers) {
|
|
65415
|
+
if (provider.kind !== void 0 && provider.kind !== "http") {
|
|
65416
|
+
continue;
|
|
65417
|
+
}
|
|
65418
|
+
const env = provider.env ?? {};
|
|
65419
|
+
const match = Object.entries(env).find(([, value2]) => value2 === model);
|
|
65420
|
+
if (match?.[0].endsWith("_MODEL") === true) {
|
|
65421
|
+
const tier = match[0].replace("ANTHROPIC_DEFAULT_", "").replace("_MODEL", "").toLowerCase();
|
|
65422
|
+
return tier === "fable" || tier === "opus" || tier === "sonnet" || tier === "haiku" ? tier : void 0;
|
|
65423
|
+
}
|
|
65424
|
+
}
|
|
65425
|
+
return void 0;
|
|
65426
|
+
};
|
|
65427
|
+
const virtual = Object.entries(models.virtual ?? {}).flatMap(([name, definition]) => {
|
|
65428
|
+
if (!visible(name)) {
|
|
65429
|
+
return [];
|
|
65430
|
+
}
|
|
65431
|
+
const first = definition.members.find((member) => member.includes("/"));
|
|
65432
|
+
const tier = first === void 0 ? void 0 : tierOf(first.split("/").slice(1).join("/"));
|
|
65433
|
+
const behavesAs = tier === void 0 ? void 0 : TIER_BEHAVES_AS[tier];
|
|
65434
|
+
return behavesAs === void 0 ? [] : [{ model: name, label: name, description: `Virtual (${definition.mode})`, behavesAs }];
|
|
65435
|
+
});
|
|
65436
|
+
const concrete = providers.flatMap(([name, provider]) => providerModelRows(provider).map((row) => ({ ...row, model: `${name}/${row.model}`, label: `${name} / ${row.label}`, description: `${name}: ${row.description}` })));
|
|
65437
|
+
return [...virtual, ...concrete.filter((row) => visible(row.model))];
|
|
65438
|
+
}
|
|
65210
65439
|
function modelPickerSettings(provider, catalogue = []) {
|
|
65211
|
-
|
|
65440
|
+
return modelPickerSettingsFromRows(providerModelRows(provider, catalogue));
|
|
65441
|
+
}
|
|
65442
|
+
function modelPickerSettingsFromRows(options) {
|
|
65212
65443
|
return options.length === 0 ? void 0 : JSON.stringify({ modelPicker: { options, replaceBuiltInOptions: true } });
|
|
65213
65444
|
}
|
|
65214
65445
|
var CONTEXT_MARKER_1M2, TIER_BEHAVES_AS, TIER_ENV_VARIABLES;
|
|
@@ -65235,6 +65466,114 @@ var init_modelPicker = __esm({
|
|
|
65235
65466
|
}
|
|
65236
65467
|
});
|
|
65237
65468
|
|
|
65469
|
+
// src/modelsStore.ts
|
|
65470
|
+
function readModels(paths) {
|
|
65471
|
+
return readGlobalConfig(paths)?.models;
|
|
65472
|
+
}
|
|
65473
|
+
function writeModels(paths, models) {
|
|
65474
|
+
const emptied = models !== void 0 && Object.keys(models).length === 0 ? void 0 : models;
|
|
65475
|
+
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { models: emptied }, { defaults: {} });
|
|
65476
|
+
}
|
|
65477
|
+
function stripEmpty(models) {
|
|
65478
|
+
const kept = {};
|
|
65479
|
+
if (models.virtual !== void 0 && Object.keys(models.virtual).length > 0) {
|
|
65480
|
+
kept.virtual = models.virtual;
|
|
65481
|
+
}
|
|
65482
|
+
if (models.tiers !== void 0 && Object.keys(models.tiers).length > 0) {
|
|
65483
|
+
kept.tiers = models.tiers;
|
|
65484
|
+
}
|
|
65485
|
+
if (models.prices !== void 0 && Object.keys(models.prices).length > 0) {
|
|
65486
|
+
kept.prices = models.prices;
|
|
65487
|
+
}
|
|
65488
|
+
if (models.hide !== void 0 && models.hide.length > 0) {
|
|
65489
|
+
kept.hide = models.hide;
|
|
65490
|
+
}
|
|
65491
|
+
if (models.show !== void 0 && models.show.length > 0) {
|
|
65492
|
+
kept.show = models.show;
|
|
65493
|
+
}
|
|
65494
|
+
return kept;
|
|
65495
|
+
}
|
|
65496
|
+
function memberKindOf(ref, models) {
|
|
65497
|
+
if (ref.startsWith("acct:")) {
|
|
65498
|
+
return "account";
|
|
65499
|
+
}
|
|
65500
|
+
if (ref.startsWith("family:")) {
|
|
65501
|
+
return "family";
|
|
65502
|
+
}
|
|
65503
|
+
return models?.virtual !== void 0 && ref in models.virtual ? "virtual" : "provider";
|
|
65504
|
+
}
|
|
65505
|
+
function expandMembers(name, models) {
|
|
65506
|
+
const virtual = models?.virtual ?? {};
|
|
65507
|
+
const expanded = [];
|
|
65508
|
+
const walk2 = (current, chain) => {
|
|
65509
|
+
const nested = virtual[current];
|
|
65510
|
+
if (nested !== void 0) {
|
|
65511
|
+
if (chain.includes(current)) {
|
|
65512
|
+
throw new Error(`virtual model cycle: ${[...chain, current].join(" -> ")}`);
|
|
65513
|
+
}
|
|
65514
|
+
for (const member of nested.members) {
|
|
65515
|
+
walk2(member, [...chain, current]);
|
|
65516
|
+
}
|
|
65517
|
+
return;
|
|
65518
|
+
}
|
|
65519
|
+
if (!expanded.includes(current)) {
|
|
65520
|
+
expanded.push(current);
|
|
65521
|
+
}
|
|
65522
|
+
};
|
|
65523
|
+
const top = virtual[name];
|
|
65524
|
+
if (top === void 0) {
|
|
65525
|
+
throw new VirtualModelNotFoundError(name);
|
|
65526
|
+
}
|
|
65527
|
+
for (const member of top.members) {
|
|
65528
|
+
walk2(member, [name]);
|
|
65529
|
+
}
|
|
65530
|
+
return expanded;
|
|
65531
|
+
}
|
|
65532
|
+
function setVirtualModel(paths, name, model) {
|
|
65533
|
+
const current = readModels(paths) ?? {};
|
|
65534
|
+
writeModels(paths, { ...current, virtual: { ...current.virtual ?? {}, [name]: model } });
|
|
65535
|
+
}
|
|
65536
|
+
function removeVirtualModel(paths, name) {
|
|
65537
|
+
const current = readModels(paths);
|
|
65538
|
+
if (current?.virtual?.[name] === void 0) {
|
|
65539
|
+
throw new VirtualModelNotFoundError(name);
|
|
65540
|
+
}
|
|
65541
|
+
const virtual = Object.fromEntries(Object.entries(current.virtual ?? {}).filter(([existing]) => existing !== name));
|
|
65542
|
+
writeModels(paths, stripEmpty({ ...current, virtual: Object.keys(virtual).length === 0 ? void 0 : virtual }));
|
|
65543
|
+
}
|
|
65544
|
+
function setPrice(paths, ref, prices) {
|
|
65545
|
+
const current = readModels(paths) ?? {};
|
|
65546
|
+
const priced = Object.fromEntries(Object.entries(current.prices ?? {}).filter(([existing]) => existing !== ref));
|
|
65547
|
+
const next = prices === void 0 ? priced : { ...priced, [ref]: prices };
|
|
65548
|
+
writeModels(paths, stripEmpty({ ...current, prices: Object.keys(next).length === 0 ? void 0 : next }));
|
|
65549
|
+
}
|
|
65550
|
+
function setTier(paths, tier, ref) {
|
|
65551
|
+
const current = readModels(paths) ?? {};
|
|
65552
|
+
const tiers = {};
|
|
65553
|
+
const merged = { ...current.tiers ?? {}, [tier]: ref };
|
|
65554
|
+
for (const [key, value2] of Object.entries(merged)) {
|
|
65555
|
+
if (value2 !== void 0) {
|
|
65556
|
+
tiers[key] = value2;
|
|
65557
|
+
}
|
|
65558
|
+
}
|
|
65559
|
+
writeModels(paths, stripEmpty({ ...current, tiers: Object.keys(tiers).length === 0 ? void 0 : tiers }));
|
|
65560
|
+
}
|
|
65561
|
+
var VirtualModelNotFoundError;
|
|
65562
|
+
var init_modelsStore = __esm({
|
|
65563
|
+
"src/modelsStore.ts"() {
|
|
65564
|
+
"use strict";
|
|
65565
|
+
init_store();
|
|
65566
|
+
init_schema();
|
|
65567
|
+
init_configProfilesStore();
|
|
65568
|
+
VirtualModelNotFoundError = class extends Error {
|
|
65569
|
+
constructor(name) {
|
|
65570
|
+
super(`No virtual model named "${name}".`);
|
|
65571
|
+
this.name = "VirtualModelNotFoundError";
|
|
65572
|
+
}
|
|
65573
|
+
};
|
|
65574
|
+
}
|
|
65575
|
+
});
|
|
65576
|
+
|
|
65238
65577
|
// src/launcher/pool.ts
|
|
65239
65578
|
function isResuming(passthrough) {
|
|
65240
65579
|
const end = passthrough.indexOf(TERMINATOR3);
|
|
@@ -65645,6 +65984,7 @@ function decideLaunch(params, readOnly) {
|
|
|
65645
65984
|
...parsedArgv.trackUsage === void 0 ? {} : { trackUsage: parsedArgv.trackUsage },
|
|
65646
65985
|
...parsedArgv.pause === void 0 ? {} : { pause: parsedArgv.pause },
|
|
65647
65986
|
...parsedArgv.explain === void 0 ? {} : { explain: parsedArgv.explain },
|
|
65987
|
+
...parsedArgv.routeByName === void 0 ? {} : { routeByName: parsedArgv.routeByName },
|
|
65648
65988
|
...parsedArgv.delay === void 0 ? {} : { delay: parsedArgv.delay }
|
|
65649
65989
|
}
|
|
65650
65990
|
});
|
|
@@ -65655,7 +65995,8 @@ function decideLaunch(params, readOnly) {
|
|
|
65655
65995
|
}
|
|
65656
65996
|
const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
|
|
65657
65997
|
const catalogue = selectedProvider === void 0 ? void 0 : parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, selectedProvider.name)));
|
|
65658
|
-
const
|
|
65998
|
+
const routesByName = flags.routeByName || selectedProvider !== void 0 && isRouterProvider(selectedProvider.definition);
|
|
65999
|
+
const pickerSettings = routesByName ? modelPickerSettingsFromRows(routedModelRows(readModels(paths) ?? {}, listProviders(paths).map((entry) => [entry.name, entry.provider]))) : selectedProvider === void 0 ? void 0 : modelPickerSettings(selectedProvider.definition, catalogue?.models);
|
|
65659
66000
|
const callerSettings = hasSettingsArgument(parsedArgv.rest);
|
|
65660
66001
|
if (pickerSettings !== void 0 && callerSettings) {
|
|
65661
66002
|
notes.push("--settings was passed, so /model keeps Claude Code's own model names");
|
|
@@ -65788,7 +66129,8 @@ function prepareLaunch(params) {
|
|
|
65788
66129
|
...frontDoor === void 0 ? {} : { frontdoor: frontDoor },
|
|
65789
66130
|
...headroom === void 0 ? {} : { headroom },
|
|
65790
66131
|
sessionId,
|
|
65791
|
-
remoteControl: resolvedFlags.remoteControl
|
|
66132
|
+
remoteControl: resolvedFlags.remoteControl,
|
|
66133
|
+
routeByName: resolvedFlags.routeByName || resolvedProvider !== void 0 && isRouterProvider(resolvedProvider.definition)
|
|
65792
66134
|
});
|
|
65793
66135
|
const releases = [...headroom === void 0 || headroomPort === void 0 ? [] : [headroomPort.release], ...frontDoorRelease === void 0 ? [] : [frontDoorRelease]];
|
|
65794
66136
|
const release = () => {
|
|
@@ -65815,7 +66157,8 @@ function resolveLaunch(params) {
|
|
|
65815
66157
|
...frontDoor ? { frontdoor: { port: 0, connectPort: 0, trustBundlePath: "", sessionToken: "" } } : {},
|
|
65816
66158
|
...decided.flags.headroom ? { headroom: { socketPath: "", projectId: "" } } : {},
|
|
65817
66159
|
sessionId: "",
|
|
65818
|
-
remoteControl: decided.flags.remoteControl
|
|
66160
|
+
remoteControl: decided.flags.remoteControl,
|
|
66161
|
+
routeByName: decided.flags.routeByName
|
|
65819
66162
|
});
|
|
65820
66163
|
const credentialNames = decided.identityCredentialBlock === void 0 ? [] : Object.keys(credentialVariables(decided.identityCredentialBlock.target ?? "bearer", ""));
|
|
65821
66164
|
const environment = [.../* @__PURE__ */ new Set([...Object.keys(built).filter((name) => built[name] !== env[name]), ...credentialNames])].sort();
|
|
@@ -65827,7 +66170,7 @@ function resolveLaunch(params) {
|
|
|
65827
66170
|
bin: decided.bin,
|
|
65828
66171
|
args: decided.args,
|
|
65829
66172
|
...credential === void 0 ? {} : { credential },
|
|
65830
|
-
routing: { frontDoor, headroom: decided.flags.headroom },
|
|
66173
|
+
routing: { frontDoor, headroom: decided.flags.headroom, routeByName: decided.flags.routeByName },
|
|
65831
66174
|
environment
|
|
65832
66175
|
};
|
|
65833
66176
|
}
|
|
@@ -65870,6 +66213,8 @@ var init_launcher = __esm({
|
|
|
65870
66213
|
init_launchReport();
|
|
65871
66214
|
init_modelPicker();
|
|
65872
66215
|
init_providerCatalogue();
|
|
66216
|
+
init_modelsStore();
|
|
66217
|
+
init_providersStore();
|
|
65873
66218
|
init_pool();
|
|
65874
66219
|
init_resumeContext();
|
|
65875
66220
|
init_lock();
|
|
@@ -111667,189 +112012,7 @@ init_identity();
|
|
|
111667
112012
|
|
|
111668
112013
|
// src/poolStore.ts
|
|
111669
112014
|
init_cliError();
|
|
111670
|
-
|
|
111671
|
-
// src/configProfilesStore.ts
|
|
111672
|
-
var import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
111673
|
-
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
111674
|
-
init_store();
|
|
111675
|
-
init_schema();
|
|
111676
|
-
init_cliError();
|
|
111677
|
-
init_load();
|
|
111678
|
-
var ProfileNotFoundError = class extends CliError {
|
|
111679
|
-
constructor(profileName) {
|
|
111680
|
-
super(`No configuration profile named "${profileName}". Run \`agent-shim profile add ${profileName}\` first.`);
|
|
111681
|
-
this.profileName = profileName;
|
|
111682
|
-
this.name = "ProfileNotFoundError";
|
|
111683
|
-
}
|
|
111684
|
-
profileName;
|
|
111685
|
-
};
|
|
111686
|
-
var ProfileAlreadyExistsError = class extends CliError {
|
|
111687
|
-
constructor(profileName) {
|
|
111688
|
-
super(`A configuration profile named "${profileName}" already exists.`);
|
|
111689
|
-
this.profileName = profileName;
|
|
111690
|
-
this.name = "ProfileAlreadyExistsError";
|
|
111691
|
-
}
|
|
111692
|
-
profileName;
|
|
111693
|
-
};
|
|
111694
|
-
var InvalidCategoryNameError = class extends CliError {
|
|
111695
|
-
constructor(categoryName) {
|
|
111696
|
-
super(`"${categoryName}" is not a category a configuration profile may toggle (runtime, history, knowledge, settings).`);
|
|
111697
|
-
this.categoryName = categoryName;
|
|
111698
|
-
this.name = "InvalidCategoryNameError";
|
|
111699
|
-
}
|
|
111700
|
-
categoryName;
|
|
111701
|
-
};
|
|
111702
|
-
function profileJsonPath(paths, name) {
|
|
111703
|
-
return import_node_path12.default.join(paths.configProfilesDir, `${name}.json`);
|
|
111704
|
-
}
|
|
111705
|
-
function profileExists(paths, name) {
|
|
111706
|
-
return import_node_fs5.default.existsSync(profileJsonPath(paths, name));
|
|
111707
|
-
}
|
|
111708
|
-
function requireProfileExists(paths, name) {
|
|
111709
|
-
if (!profileExists(paths, name)) {
|
|
111710
|
-
throw new ProfileNotFoundError(name);
|
|
111711
|
-
}
|
|
111712
|
-
}
|
|
111713
|
-
function readProfile(paths, name) {
|
|
111714
|
-
return readJson(profileJsonPath(paths, name), ConfigProfileSchema);
|
|
111715
|
-
}
|
|
111716
|
-
function createProfile(paths, name, extendsList, description) {
|
|
111717
|
-
if (profileExists(paths, name)) {
|
|
111718
|
-
throw new ProfileAlreadyExistsError(name);
|
|
111719
|
-
}
|
|
111720
|
-
const filePath = profileJsonPath(paths, name);
|
|
111721
|
-
const parsed = ConfigProfileSchema.safeParse({
|
|
111722
|
-
...description === void 0 ? {} : { description },
|
|
111723
|
-
...extendsList !== void 0 && extendsList.length > 0 ? { extends: [...extendsList] } : {}
|
|
111724
|
-
});
|
|
111725
|
-
if (!parsed.success) {
|
|
111726
|
-
throw new ConfigValidationError(filePath, parsed.error.issues);
|
|
111727
|
-
}
|
|
111728
|
-
writeJsonAtomic(filePath, parsed.data);
|
|
111729
|
-
return parsed.data;
|
|
111730
|
-
}
|
|
111731
|
-
function listProfiles(paths) {
|
|
111732
|
-
if (!import_node_fs5.default.existsSync(paths.configProfilesDir)) {
|
|
111733
|
-
return [];
|
|
111734
|
-
}
|
|
111735
|
-
const names = import_node_fs5.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort();
|
|
111736
|
-
const result = [];
|
|
111737
|
-
for (const name of names) {
|
|
111738
|
-
const profile = readProfile(paths, name);
|
|
111739
|
-
if (profile !== void 0) {
|
|
111740
|
-
result.push({ name, profile });
|
|
111741
|
-
}
|
|
111742
|
-
}
|
|
111743
|
-
return result;
|
|
111744
|
-
}
|
|
111745
|
-
function globalConfigPath(paths) {
|
|
111746
|
-
return paths.globalConfigFile;
|
|
111747
|
-
}
|
|
111748
|
-
function readGlobalConfig(paths) {
|
|
111749
|
-
return readJson(globalConfigPath(paths), GlobalConfigSchema);
|
|
111750
|
-
}
|
|
111751
|
-
function setGlobalDefaultProfile(paths, name) {
|
|
111752
|
-
return applyPatch(
|
|
111753
|
-
globalConfigPath(paths),
|
|
111754
|
-
GlobalConfigSchema,
|
|
111755
|
-
{ defaultConfigProfile: name },
|
|
111756
|
-
{ defaults: {} }
|
|
111757
|
-
);
|
|
111758
|
-
}
|
|
111759
|
-
function validateCategoryNames(patch) {
|
|
111760
|
-
for (const key of Object.keys(patch)) {
|
|
111761
|
-
if (!isOverridableCategory(key)) {
|
|
111762
|
-
throw new InvalidCategoryNameError(key);
|
|
111763
|
-
}
|
|
111764
|
-
}
|
|
111765
|
-
}
|
|
111766
|
-
function setProfileCategories(paths, name, patch) {
|
|
111767
|
-
requireProfileExists(paths, name);
|
|
111768
|
-
const expandedPatch = expandAllCategoryKey(patch);
|
|
111769
|
-
validateCategoryNames(expandedPatch);
|
|
111770
|
-
const existing = readProfile(paths, name) ?? {};
|
|
111771
|
-
const mergedCategories = { ...existing.categories, ...expandedPatch };
|
|
111772
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { categories: mergedCategories });
|
|
111773
|
-
}
|
|
111774
|
-
function setProfileEntries(paths, name, patch) {
|
|
111775
|
-
requireProfileExists(paths, name);
|
|
111776
|
-
const existing = readProfile(paths, name) ?? {};
|
|
111777
|
-
const mergedEntries = { ...existing.entries, ...patch };
|
|
111778
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { entries: mergedEntries });
|
|
111779
|
-
}
|
|
111780
|
-
function setProfileLaunchFlags(paths, name, patch) {
|
|
111781
|
-
requireProfileExists(paths, name);
|
|
111782
|
-
const existing = readProfile(paths, name) ?? {};
|
|
111783
|
-
const mergedLaunch = { ...existing.launch, ...patch };
|
|
111784
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
111785
|
-
// Read as `unknown` so the check sees the `undefined` a cleared key holds, which LaunchFlags' optional properties hide from the value type.
|
|
111786
|
-
launch: Object.values(mergedLaunch).every((value2) => value2 === void 0) ? void 0 : mergedLaunch
|
|
111787
|
-
});
|
|
111788
|
-
}
|
|
111789
|
-
function setProfileMetadata(paths, name, patch) {
|
|
111790
|
-
requireProfileExists(paths, name);
|
|
111791
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
111792
|
-
...patch.extends === void 0 ? {} : { extends: patch.extends.length === 0 ? void 0 : [...patch.extends] },
|
|
111793
|
-
...patch.description === void 0 ? {} : { description: patch.description === false ? void 0 : patch.description }
|
|
111794
|
-
});
|
|
111795
|
-
}
|
|
111796
|
-
function removeProfile(paths, name) {
|
|
111797
|
-
requireProfileExists(paths, name);
|
|
111798
|
-
import_node_fs5.default.rmSync(profileJsonPath(paths, name));
|
|
111799
|
-
}
|
|
111800
|
-
function applyProfileChange(paths, name, change) {
|
|
111801
|
-
let touched = false;
|
|
111802
|
-
if (change.category !== void 0) {
|
|
111803
|
-
setProfileCategories(paths, name, change.category);
|
|
111804
|
-
touched = true;
|
|
111805
|
-
}
|
|
111806
|
-
if (change.entry !== void 0) {
|
|
111807
|
-
setProfileEntries(paths, name, change.entry);
|
|
111808
|
-
touched = true;
|
|
111809
|
-
}
|
|
111810
|
-
if (change.extends !== void 0 || change.description !== void 0) {
|
|
111811
|
-
setProfileMetadata(paths, name, {
|
|
111812
|
-
...change.extends === void 0 ? {} : { extends: change.extends === false ? [] : change.extends },
|
|
111813
|
-
...change.description === void 0 ? {} : { description: change.description }
|
|
111814
|
-
});
|
|
111815
|
-
touched = true;
|
|
111816
|
-
}
|
|
111817
|
-
const launchPatch = {};
|
|
111818
|
-
if (change.launchSkipPermissions !== void 0) {
|
|
111819
|
-
launchPatch.skipPermissions = change.launchSkipPermissions;
|
|
111820
|
-
}
|
|
111821
|
-
if (change.launchRemoteControl !== void 0) {
|
|
111822
|
-
launchPatch.remoteControl = change.launchRemoteControl;
|
|
111823
|
-
}
|
|
111824
|
-
if (change.launchHeadroom !== void 0) {
|
|
111825
|
-
launchPatch.headroom = change.launchHeadroom;
|
|
111826
|
-
}
|
|
111827
|
-
if (change.launchTrackUsage !== void 0) {
|
|
111828
|
-
launchPatch.trackUsage = change.launchTrackUsage;
|
|
111829
|
-
}
|
|
111830
|
-
if (change.launchProvider !== void 0) {
|
|
111831
|
-
launchPatch.provider = change.launchProvider === false ? void 0 : change.launchProvider;
|
|
111832
|
-
}
|
|
111833
|
-
if (change.launchClaudeVersion !== void 0) {
|
|
111834
|
-
launchPatch.claudeVersion = change.launchClaudeVersion === false ? void 0 : change.launchClaudeVersion;
|
|
111835
|
-
}
|
|
111836
|
-
if (change.launchDelay !== void 0) {
|
|
111837
|
-
launchPatch.delay = change.launchDelay === false ? void 0 : change.launchDelay;
|
|
111838
|
-
}
|
|
111839
|
-
if (change.launchPause !== void 0) {
|
|
111840
|
-
launchPatch.pause = change.launchPause;
|
|
111841
|
-
}
|
|
111842
|
-
if (change.launchExplain !== void 0) {
|
|
111843
|
-
launchPatch.explain = change.launchExplain;
|
|
111844
|
-
}
|
|
111845
|
-
if (Object.keys(launchPatch).length > 0) {
|
|
111846
|
-
setProfileLaunchFlags(paths, name, launchPatch);
|
|
111847
|
-
touched = true;
|
|
111848
|
-
}
|
|
111849
|
-
return touched;
|
|
111850
|
-
}
|
|
111851
|
-
|
|
111852
|
-
// src/poolStore.ts
|
|
112015
|
+
init_configProfilesStore();
|
|
111853
112016
|
init_store();
|
|
111854
112017
|
init_schema();
|
|
111855
112018
|
init_identity();
|
|
@@ -112141,6 +112304,9 @@ function removeIdentity(paths, name) {
|
|
|
112141
112304
|
}
|
|
112142
112305
|
}
|
|
112143
112306
|
|
|
112307
|
+
// src/configure.ts
|
|
112308
|
+
init_configProfilesStore();
|
|
112309
|
+
|
|
112144
112310
|
// src/directoryRulesStore.ts
|
|
112145
112311
|
init_store();
|
|
112146
112312
|
init_load();
|
|
@@ -113069,6 +113235,7 @@ async function resolveFarmConflicts(params) {
|
|
|
113069
113235
|
// src/configProfiles.ts
|
|
113070
113236
|
init_commandDeps();
|
|
113071
113237
|
init_cliError();
|
|
113238
|
+
init_configProfilesStore();
|
|
113072
113239
|
async function ensureProfileExists(deps, name) {
|
|
113073
113240
|
if (profileExists(deps.paths, name)) {
|
|
113074
113241
|
return;
|
|
@@ -113128,7 +113295,7 @@ function registerProfileCommand(program2, deps) {
|
|
|
113128
113295
|
withExamples(
|
|
113129
113296
|
profile.command("set <name>").description(
|
|
113130
113297
|
"Update a configuration profile's categories, entries, extends list, description or launch settings. With no options on a terminal, walks through its categories."
|
|
113131
|
-
).option("--category <category=bool>", "Share (true) or hide (false) a whole category (repeatable).", collectBoolPair).option("--entry <path=bool>", "Share (true) or hide (false) one <category>/<path> entry (repeatable).", collectBoolPair).option("--extends <profile>", "Replace the extends list with these profiles (repeatable, in order).", collectRepeated).option("--no-extends", "Clear the extends list.").option("--description <text>", "Replace the description.").option("--no-description", "Clear the description.").option("--launch-skip-permissions", "Launches under this profile skip permission prompts.").option("--no-launch-skip-permissions", "Launches under this profile keep permission prompts.").option("--launch-remote-control", "Launches under this profile enable Remote Control.").option("--no-launch-remote-control", "Launches under this profile leave Remote Control off.").option("--launch-headroom", "Launches under this profile route through headroom.").option("--no-launch-headroom", "Launches under this profile route direct.").option("--launch-track-usage", "Launches under this profile route through the front door so their requests and quota are recorded, with no headroom needed.").option("--no-launch-track-usage", "Launches under this profile are not recorded unless a provider or headroom routes them anyway.").option("--launch-provider <provider>", "Launches under this profile route through this provider.").option("--no-launch-provider", "Clear this profile's provider selection.").option("--launch-claude-version <version>", "Launches under this profile run exactly this installed Claude Code version (such as 2.1.220); a version that is not installed fails the launch.").option("--no-launch-claude-version", "Clear this profile's Claude Code version pin.").option("--launch-delay <duration>", "Launches under this profile wait this long (such as 5s) after the launcher's own output before starting claude, so the output can be read.", parseDurationLiteral).option("--no-launch-delay", "Clear this profile's launch delay.").option("--launch-pause", "Launches under this profile wait for a key press after the launcher's own output before starting claude.").option("--no-launch-pause", "Launches under this profile start claude without waiting for a key press.").option("--launch-explain", "Launches under this profile that pick from a pool list every member the pick ranked and why, in the launcher's report.").option("--no-launch-explain", "Launches under this profile name only the member a pool pick chose.").option("--json", "Print the result as JSON.").action(async (name, allOptions) => {
|
|
113298
|
+
).option("--category <category=bool>", "Share (true) or hide (false) a whole category (repeatable).", collectBoolPair).option("--entry <path=bool>", "Share (true) or hide (false) one <category>/<path> entry (repeatable).", collectBoolPair).option("--extends <profile>", "Replace the extends list with these profiles (repeatable, in order).", collectRepeated).option("--no-extends", "Clear the extends list.").option("--description <text>", "Replace the description.").option("--no-description", "Clear the description.").option("--launch-skip-permissions", "Launches under this profile skip permission prompts.").option("--no-launch-skip-permissions", "Launches under this profile keep permission prompts.").option("--launch-remote-control", "Launches under this profile enable Remote Control.").option("--no-launch-remote-control", "Launches under this profile leave Remote Control off.").option("--launch-headroom", "Launches under this profile route through headroom.").option("--no-launch-headroom", "Launches under this profile route direct.").option("--launch-track-usage", "Launches under this profile route through the front door so their requests and quota are recorded, with no headroom needed.").option("--no-launch-track-usage", "Launches under this profile are not recorded unless a provider or headroom routes them anyway.").option("--launch-provider <provider>", "Launches under this profile route through this provider.").option("--no-launch-provider", "Clear this profile's provider selection.").option("--launch-claude-version <version>", "Launches under this profile run exactly this installed Claude Code version (such as 2.1.220); a version that is not installed fails the launch.").option("--no-launch-claude-version", "Clear this profile's Claude Code version pin.").option("--launch-delay <duration>", "Launches under this profile wait this long (such as 5s) after the launcher's own output before starting claude, so the output can be read.", parseDurationLiteral).option("--no-launch-delay", "Clear this profile's launch delay.").option("--launch-pause", "Launches under this profile wait for a key press after the launcher's own output before starting claude.").option("--no-launch-pause", "Launches under this profile start claude without waiting for a key press.").option("--launch-explain", "Launches under this profile that pick from a pool list every member the pick ranked and why, in the launcher's report.").option("--no-launch-explain", "Launches under this profile name only the member a pool pick chose.").option("--launch-route-by-name", "Launches under this profile route provider-qualified model names through the models block to the provider that serves them.").option("--no-launch-route-by-name", "Launches under this profile send every request to the launch provider.").option("--json", "Print the result as JSON.").action(async (name, allOptions) => {
|
|
113132
113299
|
const { json: json2, ...options } = allOptions;
|
|
113133
113300
|
requireProfileExists(paths, name);
|
|
113134
113301
|
if (Object.entries(allOptions).every(([key, value2]) => key === "json" || value2 === void 0)) {
|
|
@@ -114880,6 +115047,7 @@ var import_node_crypto25 = require("node:crypto");
|
|
|
114880
115047
|
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
114881
115048
|
var import_node_fs19 = __toESM(require("node:fs"), 1);
|
|
114882
115049
|
init_commandDeps();
|
|
115050
|
+
init_configProfilesStore();
|
|
114883
115051
|
init_schema();
|
|
114884
115052
|
init_conditions();
|
|
114885
115053
|
|
|
@@ -115375,6 +115543,7 @@ var import_node_os7 = __toESM(require("node:os"), 1);
|
|
|
115375
115543
|
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
115376
115544
|
init_package();
|
|
115377
115545
|
init_commandDeps();
|
|
115546
|
+
init_configProfilesStore();
|
|
115378
115547
|
init_store();
|
|
115379
115548
|
init_schema();
|
|
115380
115549
|
init_realFrontDoorPort();
|
|
@@ -115566,6 +115735,7 @@ function registerUpdateCommand(program2, deps, ports = realUpdatePorts) {
|
|
|
115566
115735
|
|
|
115567
115736
|
// src/jobStore.ts
|
|
115568
115737
|
init_cliError();
|
|
115738
|
+
init_configProfilesStore();
|
|
115569
115739
|
init_store();
|
|
115570
115740
|
init_schema();
|
|
115571
115741
|
var JobNotFoundError = class extends CliError {
|
|
@@ -119147,108 +119317,8 @@ init_credentialCache();
|
|
|
119147
119317
|
init_realCredentialCache();
|
|
119148
119318
|
init_source();
|
|
119149
119319
|
|
|
119150
|
-
// src/modelsStore.ts
|
|
119151
|
-
init_store();
|
|
119152
|
-
init_schema();
|
|
119153
|
-
function readModels(paths) {
|
|
119154
|
-
return readGlobalConfig(paths)?.models;
|
|
119155
|
-
}
|
|
119156
|
-
function writeModels(paths, models) {
|
|
119157
|
-
const emptied = models !== void 0 && Object.keys(models).length === 0 ? void 0 : models;
|
|
119158
|
-
applyPatch(paths.globalConfigFile, GlobalConfigSchema, { models: emptied }, { defaults: {} });
|
|
119159
|
-
}
|
|
119160
|
-
function stripEmpty(models) {
|
|
119161
|
-
const kept = {};
|
|
119162
|
-
if (models.virtual !== void 0 && Object.keys(models.virtual).length > 0) {
|
|
119163
|
-
kept.virtual = models.virtual;
|
|
119164
|
-
}
|
|
119165
|
-
if (models.tiers !== void 0 && Object.keys(models.tiers).length > 0) {
|
|
119166
|
-
kept.tiers = models.tiers;
|
|
119167
|
-
}
|
|
119168
|
-
if (models.prices !== void 0 && Object.keys(models.prices).length > 0) {
|
|
119169
|
-
kept.prices = models.prices;
|
|
119170
|
-
}
|
|
119171
|
-
if (models.hide !== void 0 && models.hide.length > 0) {
|
|
119172
|
-
kept.hide = models.hide;
|
|
119173
|
-
}
|
|
119174
|
-
if (models.show !== void 0 && models.show.length > 0) {
|
|
119175
|
-
kept.show = models.show;
|
|
119176
|
-
}
|
|
119177
|
-
return kept;
|
|
119178
|
-
}
|
|
119179
|
-
var VirtualModelNotFoundError = class extends Error {
|
|
119180
|
-
constructor(name) {
|
|
119181
|
-
super(`No virtual model named "${name}".`);
|
|
119182
|
-
this.name = "VirtualModelNotFoundError";
|
|
119183
|
-
}
|
|
119184
|
-
};
|
|
119185
|
-
function memberKindOf(ref, models) {
|
|
119186
|
-
if (ref.startsWith("acct:")) {
|
|
119187
|
-
return "account";
|
|
119188
|
-
}
|
|
119189
|
-
if (ref.startsWith("family:")) {
|
|
119190
|
-
return "family";
|
|
119191
|
-
}
|
|
119192
|
-
return models?.virtual !== void 0 && ref in models.virtual ? "virtual" : "provider";
|
|
119193
|
-
}
|
|
119194
|
-
function expandMembers(name, models) {
|
|
119195
|
-
const virtual = models?.virtual ?? {};
|
|
119196
|
-
const expanded = [];
|
|
119197
|
-
const walk2 = (current, chain) => {
|
|
119198
|
-
const nested = virtual[current];
|
|
119199
|
-
if (nested !== void 0) {
|
|
119200
|
-
if (chain.includes(current)) {
|
|
119201
|
-
throw new Error(`virtual model cycle: ${[...chain, current].join(" -> ")}`);
|
|
119202
|
-
}
|
|
119203
|
-
for (const member of nested.members) {
|
|
119204
|
-
walk2(member, [...chain, current]);
|
|
119205
|
-
}
|
|
119206
|
-
return;
|
|
119207
|
-
}
|
|
119208
|
-
if (!expanded.includes(current)) {
|
|
119209
|
-
expanded.push(current);
|
|
119210
|
-
}
|
|
119211
|
-
};
|
|
119212
|
-
const top = virtual[name];
|
|
119213
|
-
if (top === void 0) {
|
|
119214
|
-
throw new VirtualModelNotFoundError(name);
|
|
119215
|
-
}
|
|
119216
|
-
for (const member of top.members) {
|
|
119217
|
-
walk2(member, [name]);
|
|
119218
|
-
}
|
|
119219
|
-
return expanded;
|
|
119220
|
-
}
|
|
119221
|
-
function setVirtualModel(paths, name, model) {
|
|
119222
|
-
const current = readModels(paths) ?? {};
|
|
119223
|
-
writeModels(paths, { ...current, virtual: { ...current.virtual ?? {}, [name]: model } });
|
|
119224
|
-
}
|
|
119225
|
-
function removeVirtualModel(paths, name) {
|
|
119226
|
-
const current = readModels(paths);
|
|
119227
|
-
if (current?.virtual?.[name] === void 0) {
|
|
119228
|
-
throw new VirtualModelNotFoundError(name);
|
|
119229
|
-
}
|
|
119230
|
-
const virtual = Object.fromEntries(Object.entries(current.virtual ?? {}).filter(([existing]) => existing !== name));
|
|
119231
|
-
writeModels(paths, stripEmpty({ ...current, virtual: Object.keys(virtual).length === 0 ? void 0 : virtual }));
|
|
119232
|
-
}
|
|
119233
|
-
function setPrice(paths, ref, prices) {
|
|
119234
|
-
const current = readModels(paths) ?? {};
|
|
119235
|
-
const priced = Object.fromEntries(Object.entries(current.prices ?? {}).filter(([existing]) => existing !== ref));
|
|
119236
|
-
const next = prices === void 0 ? priced : { ...priced, [ref]: prices };
|
|
119237
|
-
writeModels(paths, stripEmpty({ ...current, prices: Object.keys(next).length === 0 ? void 0 : next }));
|
|
119238
|
-
}
|
|
119239
|
-
function setTier(paths, tier, ref) {
|
|
119240
|
-
const current = readModels(paths) ?? {};
|
|
119241
|
-
const tiers = {};
|
|
119242
|
-
const merged = { ...current.tiers ?? {}, [tier]: ref };
|
|
119243
|
-
for (const [key, value2] of Object.entries(merged)) {
|
|
119244
|
-
if (value2 !== void 0) {
|
|
119245
|
-
tiers[key] = value2;
|
|
119246
|
-
}
|
|
119247
|
-
}
|
|
119248
|
-
writeModels(paths, stripEmpty({ ...current, tiers: Object.keys(tiers).length === 0 ? void 0 : tiers }));
|
|
119249
|
-
}
|
|
119250
|
-
|
|
119251
119320
|
// src/models/doctor.ts
|
|
119321
|
+
init_modelsStore();
|
|
119252
119322
|
function modelsFindings(input2) {
|
|
119253
119323
|
const findings = [];
|
|
119254
119324
|
const { models } = input2;
|
|
@@ -119303,6 +119373,9 @@ function modelsFindings(input2) {
|
|
|
119303
119373
|
return findings;
|
|
119304
119374
|
}
|
|
119305
119375
|
|
|
119376
|
+
// src/doctorReport.ts
|
|
119377
|
+
init_configProfilesStore();
|
|
119378
|
+
|
|
119306
119379
|
// src/headroom/allowlistDrift.ts
|
|
119307
119380
|
init_earlierRelease();
|
|
119308
119381
|
init_state2();
|
|
@@ -128126,6 +128199,7 @@ function createCodexApiRouter(deps) {
|
|
|
128126
128199
|
// src/frontdoor/configApi.ts
|
|
128127
128200
|
init_cliError();
|
|
128128
128201
|
init_schema();
|
|
128202
|
+
init_configProfilesStore();
|
|
128129
128203
|
init_credential();
|
|
128130
128204
|
init_identity();
|
|
128131
128205
|
init_providersStore();
|
|
@@ -128207,7 +128281,8 @@ var ConfigProfileSetInputSchema = external_exports.strictObject({
|
|
|
128207
128281
|
claudeVersion: external_exports.union([external_exports.string().min(1), external_exports.literal(false)]).optional(),
|
|
128208
128282
|
delay: external_exports.union([external_exports.string().regex(DURATION_RE), external_exports.literal(false)]).optional(),
|
|
128209
128283
|
pause: external_exports.boolean().optional(),
|
|
128210
|
-
explain: external_exports.boolean().optional()
|
|
128284
|
+
explain: external_exports.boolean().optional(),
|
|
128285
|
+
routeByName: external_exports.boolean().optional()
|
|
128211
128286
|
}).optional()
|
|
128212
128287
|
});
|
|
128213
128288
|
var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
|
|
@@ -128419,7 +128494,8 @@ function createConfigApiRouter(deps) {
|
|
|
128419
128494
|
...launch?.claudeVersion === void 0 ? {} : { launchClaudeVersion: launch.claudeVersion },
|
|
128420
128495
|
...launch?.delay === void 0 ? {} : { launchDelay: launch.delay },
|
|
128421
128496
|
...launch?.pause === void 0 ? {} : { launchPause: launch.pause },
|
|
128422
|
-
...launch?.explain === void 0 ? {} : { launchExplain: launch.explain }
|
|
128497
|
+
...launch?.explain === void 0 ? {} : { launchExplain: launch.explain },
|
|
128498
|
+
...launch?.routeByName === void 0 ? {} : { launchRouteByName: launch.routeByName }
|
|
128423
128499
|
});
|
|
128424
128500
|
return { action: "updated", kind: "profile", name: input2.name, value: profileValue(input2.name, paths) };
|
|
128425
128501
|
})
|
|
@@ -128721,6 +128797,7 @@ var LaunchFlagsSchema = external_exports.strictObject({
|
|
|
128721
128797
|
trackUsage: external_exports.boolean(),
|
|
128722
128798
|
pause: external_exports.boolean(),
|
|
128723
128799
|
explain: external_exports.boolean(),
|
|
128800
|
+
routeByName: external_exports.boolean(),
|
|
128724
128801
|
/** How long the launch waits after its own output before it starts claude, in milliseconds. */
|
|
128725
128802
|
delayMs: external_exports.number()
|
|
128726
128803
|
});
|
|
@@ -128734,7 +128811,7 @@ var LaunchResolveOutputSchema = external_exports.strictObject({
|
|
|
128734
128811
|
args: external_exports.readonly(external_exports.array(external_exports.string())),
|
|
128735
128812
|
/** The credential the launch would authenticate with, by target and source kinds. Absent when none applies. */
|
|
128736
128813
|
credential: external_exports.strictObject({ subject: external_exports.enum(["provider", "identity"]), name: external_exports.string(), summary: CredentialSummarySchema }).optional(),
|
|
128737
|
-
routing: external_exports.strictObject({ frontDoor: external_exports.boolean(), headroom: external_exports.boolean() }),
|
|
128814
|
+
routing: external_exports.strictObject({ frontDoor: external_exports.boolean(), headroom: external_exports.boolean(), routeByName: external_exports.boolean() }),
|
|
128738
128815
|
/** The names of the environment variables the launch would set or unset, sorted. Values are not reported. */
|
|
128739
128816
|
environment: external_exports.readonly(external_exports.array(external_exports.string())),
|
|
128740
128817
|
warnings: external_exports.readonly(external_exports.array(external_exports.string()))
|
|
@@ -131108,19 +131185,22 @@ function scopeSessionProviderPath(request7) {
|
|
|
131108
131185
|
}
|
|
131109
131186
|
return { ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` };
|
|
131110
131187
|
}
|
|
131111
|
-
function resolveModelTarget(model, models) {
|
|
131188
|
+
function resolveModelTarget(model, models, includeUnqualified) {
|
|
131112
131189
|
if (models === void 0) {
|
|
131113
131190
|
return model.includes("/") && !model.startsWith("acct:") ? model.split("/")[0] : void 0;
|
|
131114
131191
|
}
|
|
131115
131192
|
if (model.includes("/") && !model.startsWith("acct:")) {
|
|
131116
131193
|
return model.split("/")[0];
|
|
131117
131194
|
}
|
|
131195
|
+
if (!includeUnqualified) {
|
|
131196
|
+
return void 0;
|
|
131197
|
+
}
|
|
131118
131198
|
const virtual = models.virtual?.[model];
|
|
131119
131199
|
const first = virtual?.members.find((member) => !member.startsWith("acct:") && !member.startsWith("family:"));
|
|
131120
131200
|
if (first === void 0) {
|
|
131121
131201
|
return void 0;
|
|
131122
131202
|
}
|
|
131123
|
-
return first.includes("/") ? first.split("/")[0] : resolveModelTarget(first, models);
|
|
131203
|
+
return first.includes("/") ? first.split("/")[0] : resolveModelTarget(first, models, true);
|
|
131124
131204
|
}
|
|
131125
131205
|
function createProviderRouteResolver(deps) {
|
|
131126
131206
|
const oauthRoute = createPassthroughRoute("anthropic", { baseUrl: `https://${CONNECT_INTERCEPT_HOST}:${String(HTTPS_PORT)}`, stripPrefix: void 0, headroomUpstream: void 0 });
|
|
@@ -131285,12 +131365,17 @@ function createProviderRouteResolver(deps) {
|
|
|
131285
131365
|
routes = void 0;
|
|
131286
131366
|
isRouter = false;
|
|
131287
131367
|
}
|
|
131288
|
-
|
|
131368
|
+
const routesByName = isRouter || current.session.routeByName && providerName !== void 0;
|
|
131369
|
+
if (routesByName) {
|
|
131289
131370
|
const scan2 = await scanRequestHead(current, false);
|
|
131290
131371
|
if (scan2.replayed !== void 0) {
|
|
131291
131372
|
replay = scan2.replayed;
|
|
131292
131373
|
}
|
|
131293
|
-
const target = scan2.model === void 0 ? void 0 : resolveModelTarget(scan2.model, deps.models?.());
|
|
131374
|
+
const target = scan2.model === void 0 || providerName === void 0 ? void 0 : resolveModelTarget(scan2.model, deps.models?.(), isRouter || current.session.routeByName);
|
|
131375
|
+
if (target === providerName) {
|
|
131376
|
+
const resolution = resolve2(current);
|
|
131377
|
+
return resolution.ok && replay !== void 0 ? { ok: true, route: servingRewritten(resolution.route, { ...replay, url: current.url }), request: { ...replay, url: current.url } } : resolution.ok ? serveScoped(resolution) : resolution;
|
|
131378
|
+
}
|
|
131294
131379
|
if (target !== void 0) {
|
|
131295
131380
|
const rest2 = path65.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(providerName ?? "")}`.length);
|
|
131296
131381
|
const query2 = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
|
|
@@ -131372,6 +131457,7 @@ function attachingProviderCredential(route, deps) {
|
|
|
131372
131457
|
}
|
|
131373
131458
|
|
|
131374
131459
|
// src/frontdoor/commands.ts
|
|
131460
|
+
init_modelsStore();
|
|
131375
131461
|
init_realFrontDoorPort();
|
|
131376
131462
|
|
|
131377
131463
|
// src/frontdoor/rcCommands.ts
|
|
@@ -145979,6 +146065,7 @@ var import_node_http5 = __toESM(require("node:http"), 1);
|
|
|
145979
146065
|
var import_node_path58 = __toESM(require("node:path"), 1);
|
|
145980
146066
|
var import_node_child_process9 = require("node:child_process");
|
|
145981
146067
|
init_commandDeps();
|
|
146068
|
+
init_configProfilesStore();
|
|
145982
146069
|
init_realFrontDoorPort();
|
|
145983
146070
|
init_trust();
|
|
145984
146071
|
|
|
@@ -147300,6 +147387,7 @@ function sameFamilyOtherVersion(a10, b) {
|
|
|
147300
147387
|
}
|
|
147301
147388
|
|
|
147302
147389
|
// src/models.ts
|
|
147390
|
+
init_modelsStore();
|
|
147303
147391
|
function providerModels(paths) {
|
|
147304
147392
|
return listProviders(paths).flatMap((entry) => {
|
|
147305
147393
|
const catalogue = parseCatalogueCache(realFsPort.readFileUtf8(catalogueCachePath(paths, entry.name)));
|
|
@@ -147936,11 +148024,12 @@ Launching:
|
|
|
147936
148024
|
--delay <duration> wait this long (5s, 500ms) after the launcher's own output before starting claude
|
|
147937
148025
|
--[no-]pause wait for a key press after the launcher's own output before starting claude
|
|
147938
148026
|
--[no-]explain with @pool:<name>, list every member the pick ranked and why, not only the one picked
|
|
148027
|
+
--[no-]route-by-name route provider-qualified model names through the models block to the provider that serves them
|
|
147939
148028
|
--native run the real claude with nothing from agent-shim applied (no other launch flag allowed)
|
|
147940
148029
|
|
|
147941
148030
|
Environment:
|
|
147942
148031
|
AGENT_SHIM_IDENTITY, AGENT_SHIM_CONFIG_PROFILE, AGENT_SHIM_SKIP_PERMISSIONS,
|
|
147943
|
-
AGENT_SHIM_REMOTE_CONTROL, AGENT_SHIM_HEADROOM, AGENT_SHIM_TRACK_USAGE, AGENT_SHIM_DELAY, AGENT_SHIM_PAUSE, AGENT_SHIM_EXPLAIN, AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL,
|
|
148032
|
+
AGENT_SHIM_REMOTE_CONTROL, AGENT_SHIM_HEADROOM, AGENT_SHIM_TRACK_USAGE, AGENT_SHIM_DELAY, AGENT_SHIM_PAUSE, AGENT_SHIM_EXPLAIN, AGENT_SHIM_ROUTE_BY_NAME, AGENT_SHIM_ALLOW_AMBIENT_CREDENTIAL,
|
|
147944
148033
|
AGENT_SHIM_CATEGORY_OVERRIDE, AGENT_SHIM_ENTRY_OVERRIDE, AGENT_SHIM_HOME,
|
|
147945
148034
|
AGENT_SHIM_DEBUG (print stack traces), NO_COLOR. Booleans are true, false, 1 or 0.
|
|
147946
148035
|
|
|
@@ -147984,6 +148073,7 @@ function buildProgram(deps) {
|
|
|
147984
148073
|
|
|
147985
148074
|
// src/runClaude.ts
|
|
147986
148075
|
init_cliError();
|
|
148076
|
+
init_configProfilesStore();
|
|
147987
148077
|
init_launchWiring();
|
|
147988
148078
|
init_paths();
|
|
147989
148079
|
|
|
@@ -148664,6 +148754,7 @@ function otherLaunchFlags(parsed) {
|
|
|
148664
148754
|
...parsed.delay === void 0 ? [] : ["--delay"],
|
|
148665
148755
|
...parsed.pause === void 0 ? [] : ["--[no-]pause"],
|
|
148666
148756
|
...parsed.explain === void 0 ? [] : ["--[no-]explain"],
|
|
148757
|
+
...parsed.routeByName === void 0 ? [] : ["--[no-]route-by-name"],
|
|
148667
148758
|
...parsed.headroom === void 0 ? [] : ["--[no-]headroom"],
|
|
148668
148759
|
...parsed.trackUsage === void 0 ? [] : ["--[no-]track-usage"],
|
|
148669
148760
|
...parsed.skipPermissions === void 0 ? [] : ["--[no-]skip-permissions"],
|