claude-use 11.35.0 → 11.37.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/dist/cli.cjs +416 -291
- package/dist/index.cjs +354 -236
- package/dist/index.mjs +355 -237
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3106,7 +3106,7 @@ var init_package = __esm({
|
|
|
3106
3106
|
"package.json"() {
|
|
3107
3107
|
package_default = {
|
|
3108
3108
|
name: "claude-use",
|
|
3109
|
-
version: "11.
|
|
3109
|
+
version: "11.37.0",
|
|
3110
3110
|
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.",
|
|
3111
3111
|
license: "MIT",
|
|
3112
3112
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -6261,6 +6261,196 @@ var init_poolPick = __esm({
|
|
|
6261
6261
|
}
|
|
6262
6262
|
});
|
|
6263
6263
|
|
|
6264
|
+
// src/configProfilesStore.ts
|
|
6265
|
+
function profileJsonPath(paths, name) {
|
|
6266
|
+
return import_node_path22.default.join(paths.configProfilesDir, `${name}.json`);
|
|
6267
|
+
}
|
|
6268
|
+
function profileExists(paths, name) {
|
|
6269
|
+
return import_node_fs3.default.existsSync(profileJsonPath(paths, name));
|
|
6270
|
+
}
|
|
6271
|
+
function requireProfileExists(paths, name) {
|
|
6272
|
+
if (!profileExists(paths, name)) {
|
|
6273
|
+
throw new ProfileNotFoundError(name);
|
|
6274
|
+
}
|
|
6275
|
+
}
|
|
6276
|
+
function readProfile(paths, name) {
|
|
6277
|
+
return readJson(profileJsonPath(paths, name), ConfigProfileSchema);
|
|
6278
|
+
}
|
|
6279
|
+
function createProfile(paths, name, extendsList, description) {
|
|
6280
|
+
if (profileExists(paths, name)) {
|
|
6281
|
+
throw new ProfileAlreadyExistsError(name);
|
|
6282
|
+
}
|
|
6283
|
+
const filePath = profileJsonPath(paths, name);
|
|
6284
|
+
const parsed = ConfigProfileSchema.safeParse({
|
|
6285
|
+
...description === void 0 ? {} : { description },
|
|
6286
|
+
...extendsList !== void 0 && extendsList.length > 0 ? { extends: [...extendsList] } : {}
|
|
6287
|
+
});
|
|
6288
|
+
if (!parsed.success) {
|
|
6289
|
+
throw new ConfigValidationError(filePath, parsed.error.issues);
|
|
6290
|
+
}
|
|
6291
|
+
writeJsonAtomic(filePath, parsed.data);
|
|
6292
|
+
return parsed.data;
|
|
6293
|
+
}
|
|
6294
|
+
function listProfiles(paths) {
|
|
6295
|
+
if (!import_node_fs3.default.existsSync(paths.configProfilesDir)) {
|
|
6296
|
+
return [];
|
|
6297
|
+
}
|
|
6298
|
+
const names = import_node_fs3.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort();
|
|
6299
|
+
const result = [];
|
|
6300
|
+
for (const name of names) {
|
|
6301
|
+
const profile = readProfile(paths, name);
|
|
6302
|
+
if (profile !== void 0) {
|
|
6303
|
+
result.push({ name, profile });
|
|
6304
|
+
}
|
|
6305
|
+
}
|
|
6306
|
+
return result;
|
|
6307
|
+
}
|
|
6308
|
+
function globalConfigPath(paths) {
|
|
6309
|
+
return paths.globalConfigFile;
|
|
6310
|
+
}
|
|
6311
|
+
function readGlobalConfig(paths) {
|
|
6312
|
+
return readJson(globalConfigPath(paths), GlobalConfigSchema);
|
|
6313
|
+
}
|
|
6314
|
+
function setGlobalDefaultProfile(paths, name) {
|
|
6315
|
+
return applyPatch(
|
|
6316
|
+
globalConfigPath(paths),
|
|
6317
|
+
GlobalConfigSchema,
|
|
6318
|
+
{ defaultConfigProfile: name },
|
|
6319
|
+
{ defaults: {} }
|
|
6320
|
+
);
|
|
6321
|
+
}
|
|
6322
|
+
function validateCategoryNames(patch) {
|
|
6323
|
+
for (const key of Object.keys(patch)) {
|
|
6324
|
+
if (!isOverridableCategory(key)) {
|
|
6325
|
+
throw new InvalidCategoryNameError(key);
|
|
6326
|
+
}
|
|
6327
|
+
}
|
|
6328
|
+
}
|
|
6329
|
+
function setProfileCategories(paths, name, patch) {
|
|
6330
|
+
requireProfileExists(paths, name);
|
|
6331
|
+
const expandedPatch = expandAllCategoryKey(patch);
|
|
6332
|
+
validateCategoryNames(expandedPatch);
|
|
6333
|
+
const existing = readProfile(paths, name) ?? {};
|
|
6334
|
+
const mergedCategories = { ...existing.categories, ...expandedPatch };
|
|
6335
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { categories: mergedCategories });
|
|
6336
|
+
}
|
|
6337
|
+
function setProfileEntries(paths, name, patch) {
|
|
6338
|
+
requireProfileExists(paths, name);
|
|
6339
|
+
const existing = readProfile(paths, name) ?? {};
|
|
6340
|
+
const mergedEntries = { ...existing.entries, ...patch };
|
|
6341
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { entries: mergedEntries });
|
|
6342
|
+
}
|
|
6343
|
+
function setProfileLaunchFlags(paths, name, patch) {
|
|
6344
|
+
requireProfileExists(paths, name);
|
|
6345
|
+
const existing = readProfile(paths, name) ?? {};
|
|
6346
|
+
const mergedLaunch = { ...existing.launch, ...patch };
|
|
6347
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
6348
|
+
// Read as `unknown` so the check sees the `undefined` a cleared key holds, which LaunchFlags' optional properties hide from the value type.
|
|
6349
|
+
launch: Object.values(mergedLaunch).every((value) => value === void 0) ? void 0 : mergedLaunch
|
|
6350
|
+
});
|
|
6351
|
+
}
|
|
6352
|
+
function setProfileMetadata(paths, name, patch) {
|
|
6353
|
+
requireProfileExists(paths, name);
|
|
6354
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
6355
|
+
...patch.extends === void 0 ? {} : { extends: patch.extends.length === 0 ? void 0 : [...patch.extends] },
|
|
6356
|
+
...patch.description === void 0 ? {} : { description: patch.description === false ? void 0 : patch.description }
|
|
6357
|
+
});
|
|
6358
|
+
}
|
|
6359
|
+
function removeProfile(paths, name) {
|
|
6360
|
+
requireProfileExists(paths, name);
|
|
6361
|
+
import_node_fs3.default.rmSync(profileJsonPath(paths, name));
|
|
6362
|
+
}
|
|
6363
|
+
function applyProfileChange(paths, name, change) {
|
|
6364
|
+
let touched = false;
|
|
6365
|
+
if (change.category !== void 0) {
|
|
6366
|
+
setProfileCategories(paths, name, change.category);
|
|
6367
|
+
touched = true;
|
|
6368
|
+
}
|
|
6369
|
+
if (change.entry !== void 0) {
|
|
6370
|
+
setProfileEntries(paths, name, change.entry);
|
|
6371
|
+
touched = true;
|
|
6372
|
+
}
|
|
6373
|
+
if (change.extends !== void 0 || change.description !== void 0) {
|
|
6374
|
+
setProfileMetadata(paths, name, {
|
|
6375
|
+
...change.extends === void 0 ? {} : { extends: change.extends === false ? [] : change.extends },
|
|
6376
|
+
...change.description === void 0 ? {} : { description: change.description }
|
|
6377
|
+
});
|
|
6378
|
+
touched = true;
|
|
6379
|
+
}
|
|
6380
|
+
const launchPatch = {};
|
|
6381
|
+
if (change.launchSkipPermissions !== void 0) {
|
|
6382
|
+
launchPatch.skipPermissions = change.launchSkipPermissions;
|
|
6383
|
+
}
|
|
6384
|
+
if (change.launchRemoteControl !== void 0) {
|
|
6385
|
+
launchPatch.remoteControl = change.launchRemoteControl;
|
|
6386
|
+
}
|
|
6387
|
+
if (change.launchHeadroom !== void 0) {
|
|
6388
|
+
launchPatch.headroom = change.launchHeadroom;
|
|
6389
|
+
}
|
|
6390
|
+
if (change.launchTrackUsage !== void 0) {
|
|
6391
|
+
launchPatch.trackUsage = change.launchTrackUsage;
|
|
6392
|
+
}
|
|
6393
|
+
if (change.launchProvider !== void 0) {
|
|
6394
|
+
launchPatch.provider = change.launchProvider === false ? void 0 : change.launchProvider;
|
|
6395
|
+
}
|
|
6396
|
+
if (change.launchClaudeVersion !== void 0) {
|
|
6397
|
+
launchPatch.claudeVersion = change.launchClaudeVersion === false ? void 0 : change.launchClaudeVersion;
|
|
6398
|
+
}
|
|
6399
|
+
if (change.launchDelay !== void 0) {
|
|
6400
|
+
launchPatch.delay = change.launchDelay === false ? void 0 : change.launchDelay;
|
|
6401
|
+
}
|
|
6402
|
+
if (change.launchPause !== void 0) {
|
|
6403
|
+
launchPatch.pause = change.launchPause;
|
|
6404
|
+
}
|
|
6405
|
+
if (change.launchExplain !== void 0) {
|
|
6406
|
+
launchPatch.explain = change.launchExplain;
|
|
6407
|
+
}
|
|
6408
|
+
if (change.launchRouteByName !== void 0) {
|
|
6409
|
+
launchPatch.routeByName = change.launchRouteByName;
|
|
6410
|
+
}
|
|
6411
|
+
if (Object.keys(launchPatch).length > 0) {
|
|
6412
|
+
setProfileLaunchFlags(paths, name, launchPatch);
|
|
6413
|
+
touched = true;
|
|
6414
|
+
}
|
|
6415
|
+
return touched;
|
|
6416
|
+
}
|
|
6417
|
+
var import_node_fs3, import_node_path22, ProfileNotFoundError, ProfileAlreadyExistsError, InvalidCategoryNameError;
|
|
6418
|
+
var init_configProfilesStore = __esm({
|
|
6419
|
+
"src/configProfilesStore.ts"() {
|
|
6420
|
+
"use strict";
|
|
6421
|
+
import_node_fs3 = __toESM(require("node:fs"), 1);
|
|
6422
|
+
import_node_path22 = __toESM(require("node:path"), 1);
|
|
6423
|
+
init_store();
|
|
6424
|
+
init_schema();
|
|
6425
|
+
init_cliError();
|
|
6426
|
+
init_load();
|
|
6427
|
+
ProfileNotFoundError = class extends CliError {
|
|
6428
|
+
constructor(profileName) {
|
|
6429
|
+
super(`No configuration profile named "${profileName}". Run \`agent-shim profile add ${profileName}\` first.`);
|
|
6430
|
+
this.profileName = profileName;
|
|
6431
|
+
this.name = "ProfileNotFoundError";
|
|
6432
|
+
}
|
|
6433
|
+
profileName;
|
|
6434
|
+
};
|
|
6435
|
+
ProfileAlreadyExistsError = class extends CliError {
|
|
6436
|
+
constructor(profileName) {
|
|
6437
|
+
super(`A configuration profile named "${profileName}" already exists.`);
|
|
6438
|
+
this.profileName = profileName;
|
|
6439
|
+
this.name = "ProfileAlreadyExistsError";
|
|
6440
|
+
}
|
|
6441
|
+
profileName;
|
|
6442
|
+
};
|
|
6443
|
+
InvalidCategoryNameError = class extends CliError {
|
|
6444
|
+
constructor(categoryName) {
|
|
6445
|
+
super(`"${categoryName}" is not a category a configuration profile may toggle (runtime, history, knowledge, settings).`);
|
|
6446
|
+
this.categoryName = categoryName;
|
|
6447
|
+
this.name = "InvalidCategoryNameError";
|
|
6448
|
+
}
|
|
6449
|
+
categoryName;
|
|
6450
|
+
};
|
|
6451
|
+
}
|
|
6452
|
+
});
|
|
6453
|
+
|
|
6264
6454
|
// src/paths.ts
|
|
6265
6455
|
function resolveAgentShimHome(env = process.env, home = import_node_os4.default.homedir(), isDirectory = isExistingDirectory) {
|
|
6266
6456
|
const fromEnv = env.AGENT_SHIM_HOME;
|
|
@@ -6985,6 +7175,58 @@ function resolveProvider(params) {
|
|
|
6985
7175
|
}
|
|
6986
7176
|
return { ok: true, provider: { name, definition, credential: resolution.credential }, warnings: resolution.credential.warnings };
|
|
6987
7177
|
}
|
|
7178
|
+
function resolveRoutedProviderCredentials(params) {
|
|
7179
|
+
const { models } = params;
|
|
7180
|
+
if (models === void 0) {
|
|
7181
|
+
return { ok: true, checked: [] };
|
|
7182
|
+
}
|
|
7183
|
+
const virtualNames = new Set(Object.keys(models.virtual ?? {}));
|
|
7184
|
+
const providerNames = /* @__PURE__ */ new Set();
|
|
7185
|
+
const collect = (ref) => {
|
|
7186
|
+
if (ref.startsWith("acct:") || ref.startsWith("family:") || virtualNames.has(ref)) {
|
|
7187
|
+
return;
|
|
7188
|
+
}
|
|
7189
|
+
const [provider] = ref.split("/", 1);
|
|
7190
|
+
if (provider !== void 0 && provider !== "") {
|
|
7191
|
+
providerNames.add(provider);
|
|
7192
|
+
}
|
|
7193
|
+
};
|
|
7194
|
+
for (const model of Object.values(models.virtual ?? {})) {
|
|
7195
|
+
for (const member of model.members) {
|
|
7196
|
+
collect(member);
|
|
7197
|
+
}
|
|
7198
|
+
}
|
|
7199
|
+
for (const ref of Object.values(models.tiers ?? {})) {
|
|
7200
|
+
collect(ref);
|
|
7201
|
+
}
|
|
7202
|
+
if (providerNames.size === 0) {
|
|
7203
|
+
return { ok: true, checked: [] };
|
|
7204
|
+
}
|
|
7205
|
+
if (params.credentials === void 0) {
|
|
7206
|
+
return { ok: false, status: 1, message: `agent-shim: the models block routes to providers ${[...providerNames].sort().join(", ")}, which need their credentials resolved, but this launcher has no credential port wired` };
|
|
7207
|
+
}
|
|
7208
|
+
const failures = [];
|
|
7209
|
+
let credentialFailure = false;
|
|
7210
|
+
for (const name of [...providerNames].sort()) {
|
|
7211
|
+
const definition = loadProvider(params.paths.providersDir, name, params.port);
|
|
7212
|
+
if (definition === void 0) {
|
|
7213
|
+
failures.push(`no provider named "${name}"`);
|
|
7214
|
+
continue;
|
|
7215
|
+
}
|
|
7216
|
+
if (isRouterProvider(definition)) {
|
|
7217
|
+
continue;
|
|
7218
|
+
}
|
|
7219
|
+
const resolution = resolveCredential({ credential: definition.credential, env: params.env, port: params.credentials, subject: `provider ${name}` });
|
|
7220
|
+
if (!resolution.ok) {
|
|
7221
|
+
failures.push(resolution.message.replace(/^agent-shim: /, ""));
|
|
7222
|
+
credentialFailure = true;
|
|
7223
|
+
}
|
|
7224
|
+
}
|
|
7225
|
+
if (failures.length > 0) {
|
|
7226
|
+
return { ok: false, status: credentialFailure ? CREDENTIAL_UNAVAILABLE_EXIT : 1, message: `agent-shim: this launch routes model names through the models block, but: ${failures.join("; ")}` };
|
|
7227
|
+
}
|
|
7228
|
+
return { ok: true, checked: [...providerNames].sort() };
|
|
7229
|
+
}
|
|
6988
7230
|
var import_node_fs6, import_node_path25, ProviderNotFoundError, ProviderAlreadyExistsError, InvalidProviderNameError, PROVIDER_NAME_RE, LEGACY_PROVIDER_FIELDS, LEGACY_ENV_CREDENTIAL_KEYS, LEGACY_LITERAL_PLACEHOLDER, LegacyProviderFileError, ProviderKindMismatchError;
|
|
6989
7231
|
var init_providersStore = __esm({
|
|
6990
7232
|
"src/providersStore.ts"() {
|
|
@@ -7302,6 +7544,62 @@ var init_claudeShim = __esm({
|
|
|
7302
7544
|
}
|
|
7303
7545
|
});
|
|
7304
7546
|
|
|
7547
|
+
// src/modelsStore.ts
|
|
7548
|
+
function readModels(paths) {
|
|
7549
|
+
return readGlobalConfig(paths)?.models;
|
|
7550
|
+
}
|
|
7551
|
+
function memberKindOf(ref, models) {
|
|
7552
|
+
if (ref.startsWith("acct:")) {
|
|
7553
|
+
return "account";
|
|
7554
|
+
}
|
|
7555
|
+
if (ref.startsWith("family:")) {
|
|
7556
|
+
return "family";
|
|
7557
|
+
}
|
|
7558
|
+
return models?.virtual !== void 0 && ref in models.virtual ? "virtual" : "provider";
|
|
7559
|
+
}
|
|
7560
|
+
function expandMembers(name, models) {
|
|
7561
|
+
const virtual = models?.virtual ?? {};
|
|
7562
|
+
const expanded = [];
|
|
7563
|
+
const walk = (current, chain) => {
|
|
7564
|
+
const nested = virtual[current];
|
|
7565
|
+
if (nested !== void 0) {
|
|
7566
|
+
if (chain.includes(current)) {
|
|
7567
|
+
throw new Error(`virtual model cycle: ${[...chain, current].join(" -> ")}`);
|
|
7568
|
+
}
|
|
7569
|
+
for (const member of nested.members) {
|
|
7570
|
+
walk(member, [...chain, current]);
|
|
7571
|
+
}
|
|
7572
|
+
return;
|
|
7573
|
+
}
|
|
7574
|
+
if (!expanded.includes(current)) {
|
|
7575
|
+
expanded.push(current);
|
|
7576
|
+
}
|
|
7577
|
+
};
|
|
7578
|
+
const top = virtual[name];
|
|
7579
|
+
if (top === void 0) {
|
|
7580
|
+
throw new VirtualModelNotFoundError(name);
|
|
7581
|
+
}
|
|
7582
|
+
for (const member of top.members) {
|
|
7583
|
+
walk(member, [name]);
|
|
7584
|
+
}
|
|
7585
|
+
return expanded;
|
|
7586
|
+
}
|
|
7587
|
+
var VirtualModelNotFoundError;
|
|
7588
|
+
var init_modelsStore = __esm({
|
|
7589
|
+
"src/modelsStore.ts"() {
|
|
7590
|
+
"use strict";
|
|
7591
|
+
init_store();
|
|
7592
|
+
init_schema();
|
|
7593
|
+
init_configProfilesStore();
|
|
7594
|
+
VirtualModelNotFoundError = class extends Error {
|
|
7595
|
+
constructor(name) {
|
|
7596
|
+
super(`No virtual model named "${name}".`);
|
|
7597
|
+
this.name = "VirtualModelNotFoundError";
|
|
7598
|
+
}
|
|
7599
|
+
};
|
|
7600
|
+
}
|
|
7601
|
+
});
|
|
7602
|
+
|
|
7305
7603
|
// src/frontdoor/probe.ts
|
|
7306
7604
|
function probeFrontDoorSync(port, caPem) {
|
|
7307
7605
|
refuseToBlockInRole("a synchronous probe of the front door");
|
|
@@ -8626,8 +8924,40 @@ function providerModelRows(provider, catalogue = []) {
|
|
|
8626
8924
|
const taken = new Set(named.map((row) => labelOf(row.model)));
|
|
8627
8925
|
return [...named, ...catalogueRows(provider, catalogue).filter((row) => !taken.has(labelOf(row.model)))];
|
|
8628
8926
|
}
|
|
8927
|
+
function routedModelRows(models, providers) {
|
|
8928
|
+
const hidden = new Set(models.hide ?? []);
|
|
8929
|
+
const shown = models.show === void 0 ? void 0 : new Set(models.show);
|
|
8930
|
+
const visible = (model) => shown === void 0 ? !hidden.has(model) : shown.has(model);
|
|
8931
|
+
const tierOf = (model) => {
|
|
8932
|
+
for (const [, provider] of providers) {
|
|
8933
|
+
if (provider.kind !== void 0 && provider.kind !== "http") {
|
|
8934
|
+
continue;
|
|
8935
|
+
}
|
|
8936
|
+
const env = provider.env ?? {};
|
|
8937
|
+
const match = Object.entries(env).find(([, value]) => value === model);
|
|
8938
|
+
if (match?.[0].endsWith("_MODEL") === true) {
|
|
8939
|
+
const tier = match[0].replace("ANTHROPIC_DEFAULT_", "").replace("_MODEL", "").toLowerCase();
|
|
8940
|
+
return tier === "fable" || tier === "opus" || tier === "sonnet" || tier === "haiku" ? tier : void 0;
|
|
8941
|
+
}
|
|
8942
|
+
}
|
|
8943
|
+
return void 0;
|
|
8944
|
+
};
|
|
8945
|
+
const virtual = Object.entries(models.virtual ?? {}).flatMap(([name, definition]) => {
|
|
8946
|
+
if (!visible(name)) {
|
|
8947
|
+
return [];
|
|
8948
|
+
}
|
|
8949
|
+
const first = definition.members.find((member) => member.includes("/"));
|
|
8950
|
+
const tier = first === void 0 ? void 0 : tierOf(first.split("/").slice(1).join("/"));
|
|
8951
|
+
const behavesAs = tier === void 0 ? void 0 : TIER_BEHAVES_AS[tier];
|
|
8952
|
+
return behavesAs === void 0 ? [] : [{ model: name, label: name, description: `Virtual (${definition.mode})`, behavesAs }];
|
|
8953
|
+
});
|
|
8954
|
+
const concrete = providers.flatMap(([name, provider]) => providerModelRows(provider).map((row) => ({ ...row, model: `${name}/${row.model}`, label: `${name} / ${row.label}`, description: `${name}: ${row.description}` })));
|
|
8955
|
+
return [...virtual, ...concrete.filter((row) => visible(row.model))];
|
|
8956
|
+
}
|
|
8629
8957
|
function modelPickerSettings(provider, catalogue = []) {
|
|
8630
|
-
|
|
8958
|
+
return modelPickerSettingsFromRows(providerModelRows(provider, catalogue));
|
|
8959
|
+
}
|
|
8960
|
+
function modelPickerSettingsFromRows(options) {
|
|
8631
8961
|
return options.length === 0 ? void 0 : JSON.stringify({ modelPicker: { options, replaceBuiltInOptions: true } });
|
|
8632
8962
|
}
|
|
8633
8963
|
var CONTEXT_MARKER_1M, TIER_BEHAVES_AS, TIER_ENV_VARIABLES;
|
|
@@ -9075,7 +9405,8 @@ function decideLaunch(params, readOnly) {
|
|
|
9075
9405
|
}
|
|
9076
9406
|
const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
|
|
9077
9407
|
const catalogue = selectedProvider === void 0 ? void 0 : parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, selectedProvider.name)));
|
|
9078
|
-
const
|
|
9408
|
+
const routesByName = flags.routeByName || selectedProvider !== void 0 && isRouterProvider(selectedProvider.definition);
|
|
9409
|
+
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);
|
|
9079
9410
|
const callerSettings = hasSettingsArgument(parsedArgv.rest);
|
|
9080
9411
|
if (pickerSettings !== void 0 && callerSettings) {
|
|
9081
9412
|
notes.push("--settings was passed, so /model keeps Claude Code's own model names");
|
|
@@ -9177,6 +9508,14 @@ function prepareLaunch(params) {
|
|
|
9177
9508
|
if (decided.pinnedVersion !== void 0) {
|
|
9178
9509
|
rows.push(pinnedVersionRow(decided.pinnedVersion.version, decided.pinnedVersion.source));
|
|
9179
9510
|
}
|
|
9511
|
+
const routesByName = resolvedFlags.routeByName || resolvedProvider !== void 0 && isRouterProvider(resolvedProvider.definition);
|
|
9512
|
+
if (routesByName) {
|
|
9513
|
+
const check = resolveRoutedProviderCredentials({ paths, port: params.fs, env, ...params.credentials === void 0 ? {} : { credentials: params.credentials }, models: loadConfigFile(paths.globalConfigFile, GlobalConfigSchema, params.fs.readConfigFile)?.config.models });
|
|
9514
|
+
if (!check.ok) {
|
|
9515
|
+
log.error(check.message);
|
|
9516
|
+
proc.exit(check.status);
|
|
9517
|
+
}
|
|
9518
|
+
}
|
|
9180
9519
|
const frontDoorPort = params.frontdoor;
|
|
9181
9520
|
const frontDoorEngaged = resolvedProvider !== void 0 || resolvedFlags.headroom || resolvedFlags.trackUsage;
|
|
9182
9521
|
if (frontDoorEngaged && frontDoorPort === void 0) {
|
|
@@ -9209,7 +9548,7 @@ function prepareLaunch(params) {
|
|
|
9209
9548
|
...headroom === void 0 ? {} : { headroom },
|
|
9210
9549
|
sessionId,
|
|
9211
9550
|
remoteControl: resolvedFlags.remoteControl,
|
|
9212
|
-
routeByName:
|
|
9551
|
+
routeByName: routesByName
|
|
9213
9552
|
});
|
|
9214
9553
|
const releases = [...headroom === void 0 || headroomPort === void 0 ? [] : [headroomPort.release], ...frontDoorRelease === void 0 ? [] : [frontDoorRelease]];
|
|
9215
9554
|
const release = () => {
|
|
@@ -9292,14 +9631,18 @@ var init_launcher = __esm({
|
|
|
9292
9631
|
init_launchReport();
|
|
9293
9632
|
init_modelPicker();
|
|
9294
9633
|
init_providerCatalogue();
|
|
9634
|
+
init_modelsStore();
|
|
9635
|
+
init_providersStore();
|
|
9295
9636
|
init_pool();
|
|
9296
9637
|
init_resumeContext();
|
|
9297
9638
|
init_lock();
|
|
9298
9639
|
init_spawn();
|
|
9299
9640
|
init_providersStore();
|
|
9641
|
+
init_load();
|
|
9300
9642
|
init_flatten();
|
|
9301
9643
|
init_walk();
|
|
9302
9644
|
init_schema();
|
|
9645
|
+
init_schema();
|
|
9303
9646
|
init_credential();
|
|
9304
9647
|
init_middleware();
|
|
9305
9648
|
init_preflight();
|
|
@@ -13968,192 +14311,7 @@ function collectPoolPick(params) {
|
|
|
13968
14311
|
|
|
13969
14312
|
// src/poolStore.ts
|
|
13970
14313
|
init_cliError();
|
|
13971
|
-
|
|
13972
|
-
// src/configProfilesStore.ts
|
|
13973
|
-
var import_node_fs3 = __toESM(require("node:fs"), 1);
|
|
13974
|
-
var import_node_path22 = __toESM(require("node:path"), 1);
|
|
13975
|
-
init_store();
|
|
13976
|
-
init_schema();
|
|
13977
|
-
init_cliError();
|
|
13978
|
-
init_load();
|
|
13979
|
-
var ProfileNotFoundError = class extends CliError {
|
|
13980
|
-
constructor(profileName) {
|
|
13981
|
-
super(`No configuration profile named "${profileName}". Run \`agent-shim profile add ${profileName}\` first.`);
|
|
13982
|
-
this.profileName = profileName;
|
|
13983
|
-
this.name = "ProfileNotFoundError";
|
|
13984
|
-
}
|
|
13985
|
-
profileName;
|
|
13986
|
-
};
|
|
13987
|
-
var ProfileAlreadyExistsError = class extends CliError {
|
|
13988
|
-
constructor(profileName) {
|
|
13989
|
-
super(`A configuration profile named "${profileName}" already exists.`);
|
|
13990
|
-
this.profileName = profileName;
|
|
13991
|
-
this.name = "ProfileAlreadyExistsError";
|
|
13992
|
-
}
|
|
13993
|
-
profileName;
|
|
13994
|
-
};
|
|
13995
|
-
var InvalidCategoryNameError = class extends CliError {
|
|
13996
|
-
constructor(categoryName) {
|
|
13997
|
-
super(`"${categoryName}" is not a category a configuration profile may toggle (runtime, history, knowledge, settings).`);
|
|
13998
|
-
this.categoryName = categoryName;
|
|
13999
|
-
this.name = "InvalidCategoryNameError";
|
|
14000
|
-
}
|
|
14001
|
-
categoryName;
|
|
14002
|
-
};
|
|
14003
|
-
function profileJsonPath(paths, name) {
|
|
14004
|
-
return import_node_path22.default.join(paths.configProfilesDir, `${name}.json`);
|
|
14005
|
-
}
|
|
14006
|
-
function profileExists(paths, name) {
|
|
14007
|
-
return import_node_fs3.default.existsSync(profileJsonPath(paths, name));
|
|
14008
|
-
}
|
|
14009
|
-
function requireProfileExists(paths, name) {
|
|
14010
|
-
if (!profileExists(paths, name)) {
|
|
14011
|
-
throw new ProfileNotFoundError(name);
|
|
14012
|
-
}
|
|
14013
|
-
}
|
|
14014
|
-
function readProfile(paths, name) {
|
|
14015
|
-
return readJson(profileJsonPath(paths, name), ConfigProfileSchema);
|
|
14016
|
-
}
|
|
14017
|
-
function createProfile(paths, name, extendsList, description) {
|
|
14018
|
-
if (profileExists(paths, name)) {
|
|
14019
|
-
throw new ProfileAlreadyExistsError(name);
|
|
14020
|
-
}
|
|
14021
|
-
const filePath = profileJsonPath(paths, name);
|
|
14022
|
-
const parsed = ConfigProfileSchema.safeParse({
|
|
14023
|
-
...description === void 0 ? {} : { description },
|
|
14024
|
-
...extendsList !== void 0 && extendsList.length > 0 ? { extends: [...extendsList] } : {}
|
|
14025
|
-
});
|
|
14026
|
-
if (!parsed.success) {
|
|
14027
|
-
throw new ConfigValidationError(filePath, parsed.error.issues);
|
|
14028
|
-
}
|
|
14029
|
-
writeJsonAtomic(filePath, parsed.data);
|
|
14030
|
-
return parsed.data;
|
|
14031
|
-
}
|
|
14032
|
-
function listProfiles(paths) {
|
|
14033
|
-
if (!import_node_fs3.default.existsSync(paths.configProfilesDir)) {
|
|
14034
|
-
return [];
|
|
14035
|
-
}
|
|
14036
|
-
const names = import_node_fs3.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort();
|
|
14037
|
-
const result = [];
|
|
14038
|
-
for (const name of names) {
|
|
14039
|
-
const profile = readProfile(paths, name);
|
|
14040
|
-
if (profile !== void 0) {
|
|
14041
|
-
result.push({ name, profile });
|
|
14042
|
-
}
|
|
14043
|
-
}
|
|
14044
|
-
return result;
|
|
14045
|
-
}
|
|
14046
|
-
function globalConfigPath(paths) {
|
|
14047
|
-
return paths.globalConfigFile;
|
|
14048
|
-
}
|
|
14049
|
-
function readGlobalConfig(paths) {
|
|
14050
|
-
return readJson(globalConfigPath(paths), GlobalConfigSchema);
|
|
14051
|
-
}
|
|
14052
|
-
function setGlobalDefaultProfile(paths, name) {
|
|
14053
|
-
return applyPatch(
|
|
14054
|
-
globalConfigPath(paths),
|
|
14055
|
-
GlobalConfigSchema,
|
|
14056
|
-
{ defaultConfigProfile: name },
|
|
14057
|
-
{ defaults: {} }
|
|
14058
|
-
);
|
|
14059
|
-
}
|
|
14060
|
-
function validateCategoryNames(patch) {
|
|
14061
|
-
for (const key of Object.keys(patch)) {
|
|
14062
|
-
if (!isOverridableCategory(key)) {
|
|
14063
|
-
throw new InvalidCategoryNameError(key);
|
|
14064
|
-
}
|
|
14065
|
-
}
|
|
14066
|
-
}
|
|
14067
|
-
function setProfileCategories(paths, name, patch) {
|
|
14068
|
-
requireProfileExists(paths, name);
|
|
14069
|
-
const expandedPatch = expandAllCategoryKey(patch);
|
|
14070
|
-
validateCategoryNames(expandedPatch);
|
|
14071
|
-
const existing = readProfile(paths, name) ?? {};
|
|
14072
|
-
const mergedCategories = { ...existing.categories, ...expandedPatch };
|
|
14073
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { categories: mergedCategories });
|
|
14074
|
-
}
|
|
14075
|
-
function setProfileEntries(paths, name, patch) {
|
|
14076
|
-
requireProfileExists(paths, name);
|
|
14077
|
-
const existing = readProfile(paths, name) ?? {};
|
|
14078
|
-
const mergedEntries = { ...existing.entries, ...patch };
|
|
14079
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { entries: mergedEntries });
|
|
14080
|
-
}
|
|
14081
|
-
function setProfileLaunchFlags(paths, name, patch) {
|
|
14082
|
-
requireProfileExists(paths, name);
|
|
14083
|
-
const existing = readProfile(paths, name) ?? {};
|
|
14084
|
-
const mergedLaunch = { ...existing.launch, ...patch };
|
|
14085
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
14086
|
-
// Read as `unknown` so the check sees the `undefined` a cleared key holds, which LaunchFlags' optional properties hide from the value type.
|
|
14087
|
-
launch: Object.values(mergedLaunch).every((value) => value === void 0) ? void 0 : mergedLaunch
|
|
14088
|
-
});
|
|
14089
|
-
}
|
|
14090
|
-
function setProfileMetadata(paths, name, patch) {
|
|
14091
|
-
requireProfileExists(paths, name);
|
|
14092
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
14093
|
-
...patch.extends === void 0 ? {} : { extends: patch.extends.length === 0 ? void 0 : [...patch.extends] },
|
|
14094
|
-
...patch.description === void 0 ? {} : { description: patch.description === false ? void 0 : patch.description }
|
|
14095
|
-
});
|
|
14096
|
-
}
|
|
14097
|
-
function removeProfile(paths, name) {
|
|
14098
|
-
requireProfileExists(paths, name);
|
|
14099
|
-
import_node_fs3.default.rmSync(profileJsonPath(paths, name));
|
|
14100
|
-
}
|
|
14101
|
-
function applyProfileChange(paths, name, change) {
|
|
14102
|
-
let touched = false;
|
|
14103
|
-
if (change.category !== void 0) {
|
|
14104
|
-
setProfileCategories(paths, name, change.category);
|
|
14105
|
-
touched = true;
|
|
14106
|
-
}
|
|
14107
|
-
if (change.entry !== void 0) {
|
|
14108
|
-
setProfileEntries(paths, name, change.entry);
|
|
14109
|
-
touched = true;
|
|
14110
|
-
}
|
|
14111
|
-
if (change.extends !== void 0 || change.description !== void 0) {
|
|
14112
|
-
setProfileMetadata(paths, name, {
|
|
14113
|
-
...change.extends === void 0 ? {} : { extends: change.extends === false ? [] : change.extends },
|
|
14114
|
-
...change.description === void 0 ? {} : { description: change.description }
|
|
14115
|
-
});
|
|
14116
|
-
touched = true;
|
|
14117
|
-
}
|
|
14118
|
-
const launchPatch = {};
|
|
14119
|
-
if (change.launchSkipPermissions !== void 0) {
|
|
14120
|
-
launchPatch.skipPermissions = change.launchSkipPermissions;
|
|
14121
|
-
}
|
|
14122
|
-
if (change.launchRemoteControl !== void 0) {
|
|
14123
|
-
launchPatch.remoteControl = change.launchRemoteControl;
|
|
14124
|
-
}
|
|
14125
|
-
if (change.launchHeadroom !== void 0) {
|
|
14126
|
-
launchPatch.headroom = change.launchHeadroom;
|
|
14127
|
-
}
|
|
14128
|
-
if (change.launchTrackUsage !== void 0) {
|
|
14129
|
-
launchPatch.trackUsage = change.launchTrackUsage;
|
|
14130
|
-
}
|
|
14131
|
-
if (change.launchProvider !== void 0) {
|
|
14132
|
-
launchPatch.provider = change.launchProvider === false ? void 0 : change.launchProvider;
|
|
14133
|
-
}
|
|
14134
|
-
if (change.launchClaudeVersion !== void 0) {
|
|
14135
|
-
launchPatch.claudeVersion = change.launchClaudeVersion === false ? void 0 : change.launchClaudeVersion;
|
|
14136
|
-
}
|
|
14137
|
-
if (change.launchDelay !== void 0) {
|
|
14138
|
-
launchPatch.delay = change.launchDelay === false ? void 0 : change.launchDelay;
|
|
14139
|
-
}
|
|
14140
|
-
if (change.launchPause !== void 0) {
|
|
14141
|
-
launchPatch.pause = change.launchPause;
|
|
14142
|
-
}
|
|
14143
|
-
if (change.launchExplain !== void 0) {
|
|
14144
|
-
launchPatch.explain = change.launchExplain;
|
|
14145
|
-
}
|
|
14146
|
-
if (change.launchRouteByName !== void 0) {
|
|
14147
|
-
launchPatch.routeByName = change.launchRouteByName;
|
|
14148
|
-
}
|
|
14149
|
-
if (Object.keys(launchPatch).length > 0) {
|
|
14150
|
-
setProfileLaunchFlags(paths, name, launchPatch);
|
|
14151
|
-
touched = true;
|
|
14152
|
-
}
|
|
14153
|
-
return touched;
|
|
14154
|
-
}
|
|
14155
|
-
|
|
14156
|
-
// src/poolStore.ts
|
|
14314
|
+
init_configProfilesStore();
|
|
14157
14315
|
init_store();
|
|
14158
14316
|
init_schema();
|
|
14159
14317
|
init_identity();
|
|
@@ -15234,53 +15392,8 @@ init_credentialCache();
|
|
|
15234
15392
|
init_realCredentialCache();
|
|
15235
15393
|
init_source();
|
|
15236
15394
|
|
|
15237
|
-
// src/modelsStore.ts
|
|
15238
|
-
init_store();
|
|
15239
|
-
init_schema();
|
|
15240
|
-
var VirtualModelNotFoundError = class extends Error {
|
|
15241
|
-
constructor(name) {
|
|
15242
|
-
super(`No virtual model named "${name}".`);
|
|
15243
|
-
this.name = "VirtualModelNotFoundError";
|
|
15244
|
-
}
|
|
15245
|
-
};
|
|
15246
|
-
function memberKindOf(ref, models) {
|
|
15247
|
-
if (ref.startsWith("acct:")) {
|
|
15248
|
-
return "account";
|
|
15249
|
-
}
|
|
15250
|
-
if (ref.startsWith("family:")) {
|
|
15251
|
-
return "family";
|
|
15252
|
-
}
|
|
15253
|
-
return models?.virtual !== void 0 && ref in models.virtual ? "virtual" : "provider";
|
|
15254
|
-
}
|
|
15255
|
-
function expandMembers(name, models) {
|
|
15256
|
-
const virtual = models?.virtual ?? {};
|
|
15257
|
-
const expanded = [];
|
|
15258
|
-
const walk = (current, chain) => {
|
|
15259
|
-
const nested = virtual[current];
|
|
15260
|
-
if (nested !== void 0) {
|
|
15261
|
-
if (chain.includes(current)) {
|
|
15262
|
-
throw new Error(`virtual model cycle: ${[...chain, current].join(" -> ")}`);
|
|
15263
|
-
}
|
|
15264
|
-
for (const member of nested.members) {
|
|
15265
|
-
walk(member, [...chain, current]);
|
|
15266
|
-
}
|
|
15267
|
-
return;
|
|
15268
|
-
}
|
|
15269
|
-
if (!expanded.includes(current)) {
|
|
15270
|
-
expanded.push(current);
|
|
15271
|
-
}
|
|
15272
|
-
};
|
|
15273
|
-
const top = virtual[name];
|
|
15274
|
-
if (top === void 0) {
|
|
15275
|
-
throw new VirtualModelNotFoundError(name);
|
|
15276
|
-
}
|
|
15277
|
-
for (const member of top.members) {
|
|
15278
|
-
walk(member, [name]);
|
|
15279
|
-
}
|
|
15280
|
-
return expanded;
|
|
15281
|
-
}
|
|
15282
|
-
|
|
15283
15395
|
// src/models/doctor.ts
|
|
15396
|
+
init_modelsStore();
|
|
15284
15397
|
function modelsFindings(input) {
|
|
15285
15398
|
const findings = [];
|
|
15286
15399
|
const { models } = input;
|
|
@@ -15335,6 +15448,9 @@ function modelsFindings(input) {
|
|
|
15335
15448
|
return findings;
|
|
15336
15449
|
}
|
|
15337
15450
|
|
|
15451
|
+
// src/doctorReport.ts
|
|
15452
|
+
init_configProfilesStore();
|
|
15453
|
+
|
|
15338
15454
|
// src/headroom/allowlistDrift.ts
|
|
15339
15455
|
init_earlierRelease();
|
|
15340
15456
|
init_state2();
|
|
@@ -16277,6 +16393,7 @@ var import_client2 = require("@orpc/client");
|
|
|
16277
16393
|
var import_openapi3 = require("@orpc/openapi");
|
|
16278
16394
|
init_cliError();
|
|
16279
16395
|
init_schema();
|
|
16396
|
+
init_configProfilesStore();
|
|
16280
16397
|
init_credential();
|
|
16281
16398
|
|
|
16282
16399
|
// src/credentialCacheChange.ts
|
|
@@ -19655,6 +19772,7 @@ init_guard();
|
|
|
19655
19772
|
init_paths();
|
|
19656
19773
|
init_cliError();
|
|
19657
19774
|
init_schema();
|
|
19775
|
+
init_configProfilesStore();
|
|
19658
19776
|
init_providersStore();
|
|
19659
19777
|
init_launcher();
|
|
19660
19778
|
init_spawn();
|