claude-use 11.35.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/dist/cli.cjs +353 -290
- package/dist/index.cjs +291 -235
- package/dist/index.mjs +292 -236
- package/dist/types/index.d.ts +6 -6
- 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.36.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;
|
|
@@ -7302,6 +7492,62 @@ var init_claudeShim = __esm({
|
|
|
7302
7492
|
}
|
|
7303
7493
|
});
|
|
7304
7494
|
|
|
7495
|
+
// src/modelsStore.ts
|
|
7496
|
+
function readModels(paths) {
|
|
7497
|
+
return readGlobalConfig(paths)?.models;
|
|
7498
|
+
}
|
|
7499
|
+
function memberKindOf(ref, models) {
|
|
7500
|
+
if (ref.startsWith("acct:")) {
|
|
7501
|
+
return "account";
|
|
7502
|
+
}
|
|
7503
|
+
if (ref.startsWith("family:")) {
|
|
7504
|
+
return "family";
|
|
7505
|
+
}
|
|
7506
|
+
return models?.virtual !== void 0 && ref in models.virtual ? "virtual" : "provider";
|
|
7507
|
+
}
|
|
7508
|
+
function expandMembers(name, models) {
|
|
7509
|
+
const virtual = models?.virtual ?? {};
|
|
7510
|
+
const expanded = [];
|
|
7511
|
+
const walk = (current, chain) => {
|
|
7512
|
+
const nested = virtual[current];
|
|
7513
|
+
if (nested !== void 0) {
|
|
7514
|
+
if (chain.includes(current)) {
|
|
7515
|
+
throw new Error(`virtual model cycle: ${[...chain, current].join(" -> ")}`);
|
|
7516
|
+
}
|
|
7517
|
+
for (const member of nested.members) {
|
|
7518
|
+
walk(member, [...chain, current]);
|
|
7519
|
+
}
|
|
7520
|
+
return;
|
|
7521
|
+
}
|
|
7522
|
+
if (!expanded.includes(current)) {
|
|
7523
|
+
expanded.push(current);
|
|
7524
|
+
}
|
|
7525
|
+
};
|
|
7526
|
+
const top = virtual[name];
|
|
7527
|
+
if (top === void 0) {
|
|
7528
|
+
throw new VirtualModelNotFoundError(name);
|
|
7529
|
+
}
|
|
7530
|
+
for (const member of top.members) {
|
|
7531
|
+
walk(member, [name]);
|
|
7532
|
+
}
|
|
7533
|
+
return expanded;
|
|
7534
|
+
}
|
|
7535
|
+
var VirtualModelNotFoundError;
|
|
7536
|
+
var init_modelsStore = __esm({
|
|
7537
|
+
"src/modelsStore.ts"() {
|
|
7538
|
+
"use strict";
|
|
7539
|
+
init_store();
|
|
7540
|
+
init_schema();
|
|
7541
|
+
init_configProfilesStore();
|
|
7542
|
+
VirtualModelNotFoundError = class extends Error {
|
|
7543
|
+
constructor(name) {
|
|
7544
|
+
super(`No virtual model named "${name}".`);
|
|
7545
|
+
this.name = "VirtualModelNotFoundError";
|
|
7546
|
+
}
|
|
7547
|
+
};
|
|
7548
|
+
}
|
|
7549
|
+
});
|
|
7550
|
+
|
|
7305
7551
|
// src/frontdoor/probe.ts
|
|
7306
7552
|
function probeFrontDoorSync(port, caPem) {
|
|
7307
7553
|
refuseToBlockInRole("a synchronous probe of the front door");
|
|
@@ -8626,8 +8872,40 @@ function providerModelRows(provider, catalogue = []) {
|
|
|
8626
8872
|
const taken = new Set(named.map((row) => labelOf(row.model)));
|
|
8627
8873
|
return [...named, ...catalogueRows(provider, catalogue).filter((row) => !taken.has(labelOf(row.model)))];
|
|
8628
8874
|
}
|
|
8875
|
+
function routedModelRows(models, providers) {
|
|
8876
|
+
const hidden = new Set(models.hide ?? []);
|
|
8877
|
+
const shown = models.show === void 0 ? void 0 : new Set(models.show);
|
|
8878
|
+
const visible = (model) => shown === void 0 ? !hidden.has(model) : shown.has(model);
|
|
8879
|
+
const tierOf = (model) => {
|
|
8880
|
+
for (const [, provider] of providers) {
|
|
8881
|
+
if (provider.kind !== void 0 && provider.kind !== "http") {
|
|
8882
|
+
continue;
|
|
8883
|
+
}
|
|
8884
|
+
const env = provider.env ?? {};
|
|
8885
|
+
const match = Object.entries(env).find(([, value]) => value === model);
|
|
8886
|
+
if (match?.[0].endsWith("_MODEL") === true) {
|
|
8887
|
+
const tier = match[0].replace("ANTHROPIC_DEFAULT_", "").replace("_MODEL", "").toLowerCase();
|
|
8888
|
+
return tier === "fable" || tier === "opus" || tier === "sonnet" || tier === "haiku" ? tier : void 0;
|
|
8889
|
+
}
|
|
8890
|
+
}
|
|
8891
|
+
return void 0;
|
|
8892
|
+
};
|
|
8893
|
+
const virtual = Object.entries(models.virtual ?? {}).flatMap(([name, definition]) => {
|
|
8894
|
+
if (!visible(name)) {
|
|
8895
|
+
return [];
|
|
8896
|
+
}
|
|
8897
|
+
const first = definition.members.find((member) => member.includes("/"));
|
|
8898
|
+
const tier = first === void 0 ? void 0 : tierOf(first.split("/").slice(1).join("/"));
|
|
8899
|
+
const behavesAs = tier === void 0 ? void 0 : TIER_BEHAVES_AS[tier];
|
|
8900
|
+
return behavesAs === void 0 ? [] : [{ model: name, label: name, description: `Virtual (${definition.mode})`, behavesAs }];
|
|
8901
|
+
});
|
|
8902
|
+
const concrete = providers.flatMap(([name, provider]) => providerModelRows(provider).map((row) => ({ ...row, model: `${name}/${row.model}`, label: `${name} / ${row.label}`, description: `${name}: ${row.description}` })));
|
|
8903
|
+
return [...virtual, ...concrete.filter((row) => visible(row.model))];
|
|
8904
|
+
}
|
|
8629
8905
|
function modelPickerSettings(provider, catalogue = []) {
|
|
8630
|
-
|
|
8906
|
+
return modelPickerSettingsFromRows(providerModelRows(provider, catalogue));
|
|
8907
|
+
}
|
|
8908
|
+
function modelPickerSettingsFromRows(options) {
|
|
8631
8909
|
return options.length === 0 ? void 0 : JSON.stringify({ modelPicker: { options, replaceBuiltInOptions: true } });
|
|
8632
8910
|
}
|
|
8633
8911
|
var CONTEXT_MARKER_1M, TIER_BEHAVES_AS, TIER_ENV_VARIABLES;
|
|
@@ -9075,7 +9353,8 @@ function decideLaunch(params, readOnly) {
|
|
|
9075
9353
|
}
|
|
9076
9354
|
const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
|
|
9077
9355
|
const catalogue = selectedProvider === void 0 ? void 0 : parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, selectedProvider.name)));
|
|
9078
|
-
const
|
|
9356
|
+
const routesByName = flags.routeByName || selectedProvider !== void 0 && isRouterProvider(selectedProvider.definition);
|
|
9357
|
+
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
9358
|
const callerSettings = hasSettingsArgument(parsedArgv.rest);
|
|
9080
9359
|
if (pickerSettings !== void 0 && callerSettings) {
|
|
9081
9360
|
notes.push("--settings was passed, so /model keeps Claude Code's own model names");
|
|
@@ -9292,6 +9571,8 @@ var init_launcher = __esm({
|
|
|
9292
9571
|
init_launchReport();
|
|
9293
9572
|
init_modelPicker();
|
|
9294
9573
|
init_providerCatalogue();
|
|
9574
|
+
init_modelsStore();
|
|
9575
|
+
init_providersStore();
|
|
9295
9576
|
init_pool();
|
|
9296
9577
|
init_resumeContext();
|
|
9297
9578
|
init_lock();
|
|
@@ -13968,192 +14249,7 @@ function collectPoolPick(params) {
|
|
|
13968
14249
|
|
|
13969
14250
|
// src/poolStore.ts
|
|
13970
14251
|
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
|
|
14252
|
+
init_configProfilesStore();
|
|
14157
14253
|
init_store();
|
|
14158
14254
|
init_schema();
|
|
14159
14255
|
init_identity();
|
|
@@ -15234,53 +15330,8 @@ init_credentialCache();
|
|
|
15234
15330
|
init_realCredentialCache();
|
|
15235
15331
|
init_source();
|
|
15236
15332
|
|
|
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
15333
|
// src/models/doctor.ts
|
|
15334
|
+
init_modelsStore();
|
|
15284
15335
|
function modelsFindings(input) {
|
|
15285
15336
|
const findings = [];
|
|
15286
15337
|
const { models } = input;
|
|
@@ -15335,6 +15386,9 @@ function modelsFindings(input) {
|
|
|
15335
15386
|
return findings;
|
|
15336
15387
|
}
|
|
15337
15388
|
|
|
15389
|
+
// src/doctorReport.ts
|
|
15390
|
+
init_configProfilesStore();
|
|
15391
|
+
|
|
15338
15392
|
// src/headroom/allowlistDrift.ts
|
|
15339
15393
|
init_earlierRelease();
|
|
15340
15394
|
init_state2();
|
|
@@ -16277,6 +16331,7 @@ var import_client2 = require("@orpc/client");
|
|
|
16277
16331
|
var import_openapi3 = require("@orpc/openapi");
|
|
16278
16332
|
init_cliError();
|
|
16279
16333
|
init_schema();
|
|
16334
|
+
init_configProfilesStore();
|
|
16280
16335
|
init_credential();
|
|
16281
16336
|
|
|
16282
16337
|
// src/credentialCacheChange.ts
|
|
@@ -19655,6 +19710,7 @@ init_guard();
|
|
|
19655
19710
|
init_paths();
|
|
19656
19711
|
init_cliError();
|
|
19657
19712
|
init_schema();
|
|
19713
|
+
init_configProfilesStore();
|
|
19658
19714
|
init_providersStore();
|
|
19659
19715
|
init_launcher();
|
|
19660
19716
|
init_spawn();
|