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.mjs
CHANGED
|
@@ -3082,7 +3082,7 @@ var init_package = __esm({
|
|
|
3082
3082
|
"package.json"() {
|
|
3083
3083
|
package_default = {
|
|
3084
3084
|
name: "claude-use",
|
|
3085
|
-
version: "11.
|
|
3085
|
+
version: "11.36.0",
|
|
3086
3086
|
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.",
|
|
3087
3087
|
license: "MIT",
|
|
3088
3088
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -6235,6 +6235,196 @@ var init_poolPick = __esm({
|
|
|
6235
6235
|
}
|
|
6236
6236
|
});
|
|
6237
6237
|
|
|
6238
|
+
// src/configProfilesStore.ts
|
|
6239
|
+
import fs4 from "node:fs";
|
|
6240
|
+
import path22 from "node:path";
|
|
6241
|
+
function profileJsonPath(paths, name) {
|
|
6242
|
+
return path22.join(paths.configProfilesDir, `${name}.json`);
|
|
6243
|
+
}
|
|
6244
|
+
function profileExists(paths, name) {
|
|
6245
|
+
return fs4.existsSync(profileJsonPath(paths, name));
|
|
6246
|
+
}
|
|
6247
|
+
function requireProfileExists(paths, name) {
|
|
6248
|
+
if (!profileExists(paths, name)) {
|
|
6249
|
+
throw new ProfileNotFoundError(name);
|
|
6250
|
+
}
|
|
6251
|
+
}
|
|
6252
|
+
function readProfile(paths, name) {
|
|
6253
|
+
return readJson(profileJsonPath(paths, name), ConfigProfileSchema);
|
|
6254
|
+
}
|
|
6255
|
+
function createProfile(paths, name, extendsList, description) {
|
|
6256
|
+
if (profileExists(paths, name)) {
|
|
6257
|
+
throw new ProfileAlreadyExistsError(name);
|
|
6258
|
+
}
|
|
6259
|
+
const filePath = profileJsonPath(paths, name);
|
|
6260
|
+
const parsed = ConfigProfileSchema.safeParse({
|
|
6261
|
+
...description === void 0 ? {} : { description },
|
|
6262
|
+
...extendsList !== void 0 && extendsList.length > 0 ? { extends: [...extendsList] } : {}
|
|
6263
|
+
});
|
|
6264
|
+
if (!parsed.success) {
|
|
6265
|
+
throw new ConfigValidationError(filePath, parsed.error.issues);
|
|
6266
|
+
}
|
|
6267
|
+
writeJsonAtomic(filePath, parsed.data);
|
|
6268
|
+
return parsed.data;
|
|
6269
|
+
}
|
|
6270
|
+
function listProfiles(paths) {
|
|
6271
|
+
if (!fs4.existsSync(paths.configProfilesDir)) {
|
|
6272
|
+
return [];
|
|
6273
|
+
}
|
|
6274
|
+
const names = fs4.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort();
|
|
6275
|
+
const result = [];
|
|
6276
|
+
for (const name of names) {
|
|
6277
|
+
const profile = readProfile(paths, name);
|
|
6278
|
+
if (profile !== void 0) {
|
|
6279
|
+
result.push({ name, profile });
|
|
6280
|
+
}
|
|
6281
|
+
}
|
|
6282
|
+
return result;
|
|
6283
|
+
}
|
|
6284
|
+
function globalConfigPath(paths) {
|
|
6285
|
+
return paths.globalConfigFile;
|
|
6286
|
+
}
|
|
6287
|
+
function readGlobalConfig(paths) {
|
|
6288
|
+
return readJson(globalConfigPath(paths), GlobalConfigSchema);
|
|
6289
|
+
}
|
|
6290
|
+
function setGlobalDefaultProfile(paths, name) {
|
|
6291
|
+
return applyPatch(
|
|
6292
|
+
globalConfigPath(paths),
|
|
6293
|
+
GlobalConfigSchema,
|
|
6294
|
+
{ defaultConfigProfile: name },
|
|
6295
|
+
{ defaults: {} }
|
|
6296
|
+
);
|
|
6297
|
+
}
|
|
6298
|
+
function validateCategoryNames(patch) {
|
|
6299
|
+
for (const key of Object.keys(patch)) {
|
|
6300
|
+
if (!isOverridableCategory(key)) {
|
|
6301
|
+
throw new InvalidCategoryNameError(key);
|
|
6302
|
+
}
|
|
6303
|
+
}
|
|
6304
|
+
}
|
|
6305
|
+
function setProfileCategories(paths, name, patch) {
|
|
6306
|
+
requireProfileExists(paths, name);
|
|
6307
|
+
const expandedPatch = expandAllCategoryKey(patch);
|
|
6308
|
+
validateCategoryNames(expandedPatch);
|
|
6309
|
+
const existing = readProfile(paths, name) ?? {};
|
|
6310
|
+
const mergedCategories = { ...existing.categories, ...expandedPatch };
|
|
6311
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { categories: mergedCategories });
|
|
6312
|
+
}
|
|
6313
|
+
function setProfileEntries(paths, name, patch) {
|
|
6314
|
+
requireProfileExists(paths, name);
|
|
6315
|
+
const existing = readProfile(paths, name) ?? {};
|
|
6316
|
+
const mergedEntries = { ...existing.entries, ...patch };
|
|
6317
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { entries: mergedEntries });
|
|
6318
|
+
}
|
|
6319
|
+
function setProfileLaunchFlags(paths, name, patch) {
|
|
6320
|
+
requireProfileExists(paths, name);
|
|
6321
|
+
const existing = readProfile(paths, name) ?? {};
|
|
6322
|
+
const mergedLaunch = { ...existing.launch, ...patch };
|
|
6323
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
6324
|
+
// Read as `unknown` so the check sees the `undefined` a cleared key holds, which LaunchFlags' optional properties hide from the value type.
|
|
6325
|
+
launch: Object.values(mergedLaunch).every((value) => value === void 0) ? void 0 : mergedLaunch
|
|
6326
|
+
});
|
|
6327
|
+
}
|
|
6328
|
+
function setProfileMetadata(paths, name, patch) {
|
|
6329
|
+
requireProfileExists(paths, name);
|
|
6330
|
+
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
6331
|
+
...patch.extends === void 0 ? {} : { extends: patch.extends.length === 0 ? void 0 : [...patch.extends] },
|
|
6332
|
+
...patch.description === void 0 ? {} : { description: patch.description === false ? void 0 : patch.description }
|
|
6333
|
+
});
|
|
6334
|
+
}
|
|
6335
|
+
function removeProfile(paths, name) {
|
|
6336
|
+
requireProfileExists(paths, name);
|
|
6337
|
+
fs4.rmSync(profileJsonPath(paths, name));
|
|
6338
|
+
}
|
|
6339
|
+
function applyProfileChange(paths, name, change) {
|
|
6340
|
+
let touched = false;
|
|
6341
|
+
if (change.category !== void 0) {
|
|
6342
|
+
setProfileCategories(paths, name, change.category);
|
|
6343
|
+
touched = true;
|
|
6344
|
+
}
|
|
6345
|
+
if (change.entry !== void 0) {
|
|
6346
|
+
setProfileEntries(paths, name, change.entry);
|
|
6347
|
+
touched = true;
|
|
6348
|
+
}
|
|
6349
|
+
if (change.extends !== void 0 || change.description !== void 0) {
|
|
6350
|
+
setProfileMetadata(paths, name, {
|
|
6351
|
+
...change.extends === void 0 ? {} : { extends: change.extends === false ? [] : change.extends },
|
|
6352
|
+
...change.description === void 0 ? {} : { description: change.description }
|
|
6353
|
+
});
|
|
6354
|
+
touched = true;
|
|
6355
|
+
}
|
|
6356
|
+
const launchPatch = {};
|
|
6357
|
+
if (change.launchSkipPermissions !== void 0) {
|
|
6358
|
+
launchPatch.skipPermissions = change.launchSkipPermissions;
|
|
6359
|
+
}
|
|
6360
|
+
if (change.launchRemoteControl !== void 0) {
|
|
6361
|
+
launchPatch.remoteControl = change.launchRemoteControl;
|
|
6362
|
+
}
|
|
6363
|
+
if (change.launchHeadroom !== void 0) {
|
|
6364
|
+
launchPatch.headroom = change.launchHeadroom;
|
|
6365
|
+
}
|
|
6366
|
+
if (change.launchTrackUsage !== void 0) {
|
|
6367
|
+
launchPatch.trackUsage = change.launchTrackUsage;
|
|
6368
|
+
}
|
|
6369
|
+
if (change.launchProvider !== void 0) {
|
|
6370
|
+
launchPatch.provider = change.launchProvider === false ? void 0 : change.launchProvider;
|
|
6371
|
+
}
|
|
6372
|
+
if (change.launchClaudeVersion !== void 0) {
|
|
6373
|
+
launchPatch.claudeVersion = change.launchClaudeVersion === false ? void 0 : change.launchClaudeVersion;
|
|
6374
|
+
}
|
|
6375
|
+
if (change.launchDelay !== void 0) {
|
|
6376
|
+
launchPatch.delay = change.launchDelay === false ? void 0 : change.launchDelay;
|
|
6377
|
+
}
|
|
6378
|
+
if (change.launchPause !== void 0) {
|
|
6379
|
+
launchPatch.pause = change.launchPause;
|
|
6380
|
+
}
|
|
6381
|
+
if (change.launchExplain !== void 0) {
|
|
6382
|
+
launchPatch.explain = change.launchExplain;
|
|
6383
|
+
}
|
|
6384
|
+
if (change.launchRouteByName !== void 0) {
|
|
6385
|
+
launchPatch.routeByName = change.launchRouteByName;
|
|
6386
|
+
}
|
|
6387
|
+
if (Object.keys(launchPatch).length > 0) {
|
|
6388
|
+
setProfileLaunchFlags(paths, name, launchPatch);
|
|
6389
|
+
touched = true;
|
|
6390
|
+
}
|
|
6391
|
+
return touched;
|
|
6392
|
+
}
|
|
6393
|
+
var ProfileNotFoundError, ProfileAlreadyExistsError, InvalidCategoryNameError;
|
|
6394
|
+
var init_configProfilesStore = __esm({
|
|
6395
|
+
"src/configProfilesStore.ts"() {
|
|
6396
|
+
"use strict";
|
|
6397
|
+
init_store();
|
|
6398
|
+
init_schema();
|
|
6399
|
+
init_cliError();
|
|
6400
|
+
init_load();
|
|
6401
|
+
ProfileNotFoundError = class extends CliError {
|
|
6402
|
+
constructor(profileName) {
|
|
6403
|
+
super(`No configuration profile named "${profileName}". Run \`agent-shim profile add ${profileName}\` first.`);
|
|
6404
|
+
this.profileName = profileName;
|
|
6405
|
+
this.name = "ProfileNotFoundError";
|
|
6406
|
+
}
|
|
6407
|
+
profileName;
|
|
6408
|
+
};
|
|
6409
|
+
ProfileAlreadyExistsError = class extends CliError {
|
|
6410
|
+
constructor(profileName) {
|
|
6411
|
+
super(`A configuration profile named "${profileName}" already exists.`);
|
|
6412
|
+
this.profileName = profileName;
|
|
6413
|
+
this.name = "ProfileAlreadyExistsError";
|
|
6414
|
+
}
|
|
6415
|
+
profileName;
|
|
6416
|
+
};
|
|
6417
|
+
InvalidCategoryNameError = class extends CliError {
|
|
6418
|
+
constructor(categoryName) {
|
|
6419
|
+
super(`"${categoryName}" is not a category a configuration profile may toggle (runtime, history, knowledge, settings).`);
|
|
6420
|
+
this.categoryName = categoryName;
|
|
6421
|
+
this.name = "InvalidCategoryNameError";
|
|
6422
|
+
}
|
|
6423
|
+
categoryName;
|
|
6424
|
+
};
|
|
6425
|
+
}
|
|
6426
|
+
});
|
|
6427
|
+
|
|
6238
6428
|
// src/paths.ts
|
|
6239
6429
|
import fs5 from "node:fs";
|
|
6240
6430
|
import os5 from "node:os";
|
|
@@ -7275,6 +7465,62 @@ var init_claudeShim = __esm({
|
|
|
7275
7465
|
}
|
|
7276
7466
|
});
|
|
7277
7467
|
|
|
7468
|
+
// src/modelsStore.ts
|
|
7469
|
+
function readModels(paths) {
|
|
7470
|
+
return readGlobalConfig(paths)?.models;
|
|
7471
|
+
}
|
|
7472
|
+
function memberKindOf(ref, models) {
|
|
7473
|
+
if (ref.startsWith("acct:")) {
|
|
7474
|
+
return "account";
|
|
7475
|
+
}
|
|
7476
|
+
if (ref.startsWith("family:")) {
|
|
7477
|
+
return "family";
|
|
7478
|
+
}
|
|
7479
|
+
return models?.virtual !== void 0 && ref in models.virtual ? "virtual" : "provider";
|
|
7480
|
+
}
|
|
7481
|
+
function expandMembers(name, models) {
|
|
7482
|
+
const virtual = models?.virtual ?? {};
|
|
7483
|
+
const expanded = [];
|
|
7484
|
+
const walk = (current, chain) => {
|
|
7485
|
+
const nested = virtual[current];
|
|
7486
|
+
if (nested !== void 0) {
|
|
7487
|
+
if (chain.includes(current)) {
|
|
7488
|
+
throw new Error(`virtual model cycle: ${[...chain, current].join(" -> ")}`);
|
|
7489
|
+
}
|
|
7490
|
+
for (const member of nested.members) {
|
|
7491
|
+
walk(member, [...chain, current]);
|
|
7492
|
+
}
|
|
7493
|
+
return;
|
|
7494
|
+
}
|
|
7495
|
+
if (!expanded.includes(current)) {
|
|
7496
|
+
expanded.push(current);
|
|
7497
|
+
}
|
|
7498
|
+
};
|
|
7499
|
+
const top = virtual[name];
|
|
7500
|
+
if (top === void 0) {
|
|
7501
|
+
throw new VirtualModelNotFoundError(name);
|
|
7502
|
+
}
|
|
7503
|
+
for (const member of top.members) {
|
|
7504
|
+
walk(member, [name]);
|
|
7505
|
+
}
|
|
7506
|
+
return expanded;
|
|
7507
|
+
}
|
|
7508
|
+
var VirtualModelNotFoundError;
|
|
7509
|
+
var init_modelsStore = __esm({
|
|
7510
|
+
"src/modelsStore.ts"() {
|
|
7511
|
+
"use strict";
|
|
7512
|
+
init_store();
|
|
7513
|
+
init_schema();
|
|
7514
|
+
init_configProfilesStore();
|
|
7515
|
+
VirtualModelNotFoundError = class extends Error {
|
|
7516
|
+
constructor(name) {
|
|
7517
|
+
super(`No virtual model named "${name}".`);
|
|
7518
|
+
this.name = "VirtualModelNotFoundError";
|
|
7519
|
+
}
|
|
7520
|
+
};
|
|
7521
|
+
}
|
|
7522
|
+
});
|
|
7523
|
+
|
|
7278
7524
|
// src/frontdoor/probe.ts
|
|
7279
7525
|
import { Worker } from "node:worker_threads";
|
|
7280
7526
|
function probeFrontDoorSync(port, caPem) {
|
|
@@ -8598,8 +8844,40 @@ function providerModelRows(provider, catalogue = []) {
|
|
|
8598
8844
|
const taken = new Set(named.map((row) => labelOf(row.model)));
|
|
8599
8845
|
return [...named, ...catalogueRows(provider, catalogue).filter((row) => !taken.has(labelOf(row.model)))];
|
|
8600
8846
|
}
|
|
8847
|
+
function routedModelRows(models, providers) {
|
|
8848
|
+
const hidden = new Set(models.hide ?? []);
|
|
8849
|
+
const shown = models.show === void 0 ? void 0 : new Set(models.show);
|
|
8850
|
+
const visible = (model) => shown === void 0 ? !hidden.has(model) : shown.has(model);
|
|
8851
|
+
const tierOf = (model) => {
|
|
8852
|
+
for (const [, provider] of providers) {
|
|
8853
|
+
if (provider.kind !== void 0 && provider.kind !== "http") {
|
|
8854
|
+
continue;
|
|
8855
|
+
}
|
|
8856
|
+
const env = provider.env ?? {};
|
|
8857
|
+
const match = Object.entries(env).find(([, value]) => value === model);
|
|
8858
|
+
if (match?.[0].endsWith("_MODEL") === true) {
|
|
8859
|
+
const tier = match[0].replace("ANTHROPIC_DEFAULT_", "").replace("_MODEL", "").toLowerCase();
|
|
8860
|
+
return tier === "fable" || tier === "opus" || tier === "sonnet" || tier === "haiku" ? tier : void 0;
|
|
8861
|
+
}
|
|
8862
|
+
}
|
|
8863
|
+
return void 0;
|
|
8864
|
+
};
|
|
8865
|
+
const virtual = Object.entries(models.virtual ?? {}).flatMap(([name, definition]) => {
|
|
8866
|
+
if (!visible(name)) {
|
|
8867
|
+
return [];
|
|
8868
|
+
}
|
|
8869
|
+
const first = definition.members.find((member) => member.includes("/"));
|
|
8870
|
+
const tier = first === void 0 ? void 0 : tierOf(first.split("/").slice(1).join("/"));
|
|
8871
|
+
const behavesAs = tier === void 0 ? void 0 : TIER_BEHAVES_AS[tier];
|
|
8872
|
+
return behavesAs === void 0 ? [] : [{ model: name, label: name, description: `Virtual (${definition.mode})`, behavesAs }];
|
|
8873
|
+
});
|
|
8874
|
+
const concrete = providers.flatMap(([name, provider]) => providerModelRows(provider).map((row) => ({ ...row, model: `${name}/${row.model}`, label: `${name} / ${row.label}`, description: `${name}: ${row.description}` })));
|
|
8875
|
+
return [...virtual, ...concrete.filter((row) => visible(row.model))];
|
|
8876
|
+
}
|
|
8601
8877
|
function modelPickerSettings(provider, catalogue = []) {
|
|
8602
|
-
|
|
8878
|
+
return modelPickerSettingsFromRows(providerModelRows(provider, catalogue));
|
|
8879
|
+
}
|
|
8880
|
+
function modelPickerSettingsFromRows(options) {
|
|
8603
8881
|
return options.length === 0 ? void 0 : JSON.stringify({ modelPicker: { options, replaceBuiltInOptions: true } });
|
|
8604
8882
|
}
|
|
8605
8883
|
var CONTEXT_MARKER_1M, TIER_BEHAVES_AS, TIER_ENV_VARIABLES;
|
|
@@ -9049,7 +9327,8 @@ function decideLaunch(params, readOnly) {
|
|
|
9049
9327
|
}
|
|
9050
9328
|
const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
|
|
9051
9329
|
const catalogue = selectedProvider === void 0 ? void 0 : parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, selectedProvider.name)));
|
|
9052
|
-
const
|
|
9330
|
+
const routesByName = flags.routeByName || selectedProvider !== void 0 && isRouterProvider(selectedProvider.definition);
|
|
9331
|
+
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);
|
|
9053
9332
|
const callerSettings = hasSettingsArgument(parsedArgv.rest);
|
|
9054
9333
|
if (pickerSettings !== void 0 && callerSettings) {
|
|
9055
9334
|
notes.push("--settings was passed, so /model keeps Claude Code's own model names");
|
|
@@ -9263,6 +9542,8 @@ var init_launcher = __esm({
|
|
|
9263
9542
|
init_launchReport();
|
|
9264
9543
|
init_modelPicker();
|
|
9265
9544
|
init_providerCatalogue();
|
|
9545
|
+
init_modelsStore();
|
|
9546
|
+
init_providersStore();
|
|
9266
9547
|
init_pool();
|
|
9267
9548
|
init_resumeContext();
|
|
9268
9549
|
init_lock();
|
|
@@ -13555,192 +13836,7 @@ function collectPoolPick(params) {
|
|
|
13555
13836
|
|
|
13556
13837
|
// src/poolStore.ts
|
|
13557
13838
|
init_cliError();
|
|
13558
|
-
|
|
13559
|
-
// src/configProfilesStore.ts
|
|
13560
|
-
init_store();
|
|
13561
|
-
init_schema();
|
|
13562
|
-
init_cliError();
|
|
13563
|
-
init_load();
|
|
13564
|
-
import fs4 from "node:fs";
|
|
13565
|
-
import path22 from "node:path";
|
|
13566
|
-
var ProfileNotFoundError = class extends CliError {
|
|
13567
|
-
constructor(profileName) {
|
|
13568
|
-
super(`No configuration profile named "${profileName}". Run \`agent-shim profile add ${profileName}\` first.`);
|
|
13569
|
-
this.profileName = profileName;
|
|
13570
|
-
this.name = "ProfileNotFoundError";
|
|
13571
|
-
}
|
|
13572
|
-
profileName;
|
|
13573
|
-
};
|
|
13574
|
-
var ProfileAlreadyExistsError = class extends CliError {
|
|
13575
|
-
constructor(profileName) {
|
|
13576
|
-
super(`A configuration profile named "${profileName}" already exists.`);
|
|
13577
|
-
this.profileName = profileName;
|
|
13578
|
-
this.name = "ProfileAlreadyExistsError";
|
|
13579
|
-
}
|
|
13580
|
-
profileName;
|
|
13581
|
-
};
|
|
13582
|
-
var InvalidCategoryNameError = class extends CliError {
|
|
13583
|
-
constructor(categoryName) {
|
|
13584
|
-
super(`"${categoryName}" is not a category a configuration profile may toggle (runtime, history, knowledge, settings).`);
|
|
13585
|
-
this.categoryName = categoryName;
|
|
13586
|
-
this.name = "InvalidCategoryNameError";
|
|
13587
|
-
}
|
|
13588
|
-
categoryName;
|
|
13589
|
-
};
|
|
13590
|
-
function profileJsonPath(paths, name) {
|
|
13591
|
-
return path22.join(paths.configProfilesDir, `${name}.json`);
|
|
13592
|
-
}
|
|
13593
|
-
function profileExists(paths, name) {
|
|
13594
|
-
return fs4.existsSync(profileJsonPath(paths, name));
|
|
13595
|
-
}
|
|
13596
|
-
function requireProfileExists(paths, name) {
|
|
13597
|
-
if (!profileExists(paths, name)) {
|
|
13598
|
-
throw new ProfileNotFoundError(name);
|
|
13599
|
-
}
|
|
13600
|
-
}
|
|
13601
|
-
function readProfile(paths, name) {
|
|
13602
|
-
return readJson(profileJsonPath(paths, name), ConfigProfileSchema);
|
|
13603
|
-
}
|
|
13604
|
-
function createProfile(paths, name, extendsList, description) {
|
|
13605
|
-
if (profileExists(paths, name)) {
|
|
13606
|
-
throw new ProfileAlreadyExistsError(name);
|
|
13607
|
-
}
|
|
13608
|
-
const filePath = profileJsonPath(paths, name);
|
|
13609
|
-
const parsed = ConfigProfileSchema.safeParse({
|
|
13610
|
-
...description === void 0 ? {} : { description },
|
|
13611
|
-
...extendsList !== void 0 && extendsList.length > 0 ? { extends: [...extendsList] } : {}
|
|
13612
|
-
});
|
|
13613
|
-
if (!parsed.success) {
|
|
13614
|
-
throw new ConfigValidationError(filePath, parsed.error.issues);
|
|
13615
|
-
}
|
|
13616
|
-
writeJsonAtomic(filePath, parsed.data);
|
|
13617
|
-
return parsed.data;
|
|
13618
|
-
}
|
|
13619
|
-
function listProfiles(paths) {
|
|
13620
|
-
if (!fs4.existsSync(paths.configProfilesDir)) {
|
|
13621
|
-
return [];
|
|
13622
|
-
}
|
|
13623
|
-
const names = fs4.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort();
|
|
13624
|
-
const result = [];
|
|
13625
|
-
for (const name of names) {
|
|
13626
|
-
const profile = readProfile(paths, name);
|
|
13627
|
-
if (profile !== void 0) {
|
|
13628
|
-
result.push({ name, profile });
|
|
13629
|
-
}
|
|
13630
|
-
}
|
|
13631
|
-
return result;
|
|
13632
|
-
}
|
|
13633
|
-
function globalConfigPath(paths) {
|
|
13634
|
-
return paths.globalConfigFile;
|
|
13635
|
-
}
|
|
13636
|
-
function readGlobalConfig(paths) {
|
|
13637
|
-
return readJson(globalConfigPath(paths), GlobalConfigSchema);
|
|
13638
|
-
}
|
|
13639
|
-
function setGlobalDefaultProfile(paths, name) {
|
|
13640
|
-
return applyPatch(
|
|
13641
|
-
globalConfigPath(paths),
|
|
13642
|
-
GlobalConfigSchema,
|
|
13643
|
-
{ defaultConfigProfile: name },
|
|
13644
|
-
{ defaults: {} }
|
|
13645
|
-
);
|
|
13646
|
-
}
|
|
13647
|
-
function validateCategoryNames(patch) {
|
|
13648
|
-
for (const key of Object.keys(patch)) {
|
|
13649
|
-
if (!isOverridableCategory(key)) {
|
|
13650
|
-
throw new InvalidCategoryNameError(key);
|
|
13651
|
-
}
|
|
13652
|
-
}
|
|
13653
|
-
}
|
|
13654
|
-
function setProfileCategories(paths, name, patch) {
|
|
13655
|
-
requireProfileExists(paths, name);
|
|
13656
|
-
const expandedPatch = expandAllCategoryKey(patch);
|
|
13657
|
-
validateCategoryNames(expandedPatch);
|
|
13658
|
-
const existing = readProfile(paths, name) ?? {};
|
|
13659
|
-
const mergedCategories = { ...existing.categories, ...expandedPatch };
|
|
13660
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { categories: mergedCategories });
|
|
13661
|
-
}
|
|
13662
|
-
function setProfileEntries(paths, name, patch) {
|
|
13663
|
-
requireProfileExists(paths, name);
|
|
13664
|
-
const existing = readProfile(paths, name) ?? {};
|
|
13665
|
-
const mergedEntries = { ...existing.entries, ...patch };
|
|
13666
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, { entries: mergedEntries });
|
|
13667
|
-
}
|
|
13668
|
-
function setProfileLaunchFlags(paths, name, patch) {
|
|
13669
|
-
requireProfileExists(paths, name);
|
|
13670
|
-
const existing = readProfile(paths, name) ?? {};
|
|
13671
|
-
const mergedLaunch = { ...existing.launch, ...patch };
|
|
13672
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
13673
|
-
// Read as `unknown` so the check sees the `undefined` a cleared key holds, which LaunchFlags' optional properties hide from the value type.
|
|
13674
|
-
launch: Object.values(mergedLaunch).every((value) => value === void 0) ? void 0 : mergedLaunch
|
|
13675
|
-
});
|
|
13676
|
-
}
|
|
13677
|
-
function setProfileMetadata(paths, name, patch) {
|
|
13678
|
-
requireProfileExists(paths, name);
|
|
13679
|
-
return applyPatch(profileJsonPath(paths, name), ConfigProfileSchema, {
|
|
13680
|
-
...patch.extends === void 0 ? {} : { extends: patch.extends.length === 0 ? void 0 : [...patch.extends] },
|
|
13681
|
-
...patch.description === void 0 ? {} : { description: patch.description === false ? void 0 : patch.description }
|
|
13682
|
-
});
|
|
13683
|
-
}
|
|
13684
|
-
function removeProfile(paths, name) {
|
|
13685
|
-
requireProfileExists(paths, name);
|
|
13686
|
-
fs4.rmSync(profileJsonPath(paths, name));
|
|
13687
|
-
}
|
|
13688
|
-
function applyProfileChange(paths, name, change) {
|
|
13689
|
-
let touched = false;
|
|
13690
|
-
if (change.category !== void 0) {
|
|
13691
|
-
setProfileCategories(paths, name, change.category);
|
|
13692
|
-
touched = true;
|
|
13693
|
-
}
|
|
13694
|
-
if (change.entry !== void 0) {
|
|
13695
|
-
setProfileEntries(paths, name, change.entry);
|
|
13696
|
-
touched = true;
|
|
13697
|
-
}
|
|
13698
|
-
if (change.extends !== void 0 || change.description !== void 0) {
|
|
13699
|
-
setProfileMetadata(paths, name, {
|
|
13700
|
-
...change.extends === void 0 ? {} : { extends: change.extends === false ? [] : change.extends },
|
|
13701
|
-
...change.description === void 0 ? {} : { description: change.description }
|
|
13702
|
-
});
|
|
13703
|
-
touched = true;
|
|
13704
|
-
}
|
|
13705
|
-
const launchPatch = {};
|
|
13706
|
-
if (change.launchSkipPermissions !== void 0) {
|
|
13707
|
-
launchPatch.skipPermissions = change.launchSkipPermissions;
|
|
13708
|
-
}
|
|
13709
|
-
if (change.launchRemoteControl !== void 0) {
|
|
13710
|
-
launchPatch.remoteControl = change.launchRemoteControl;
|
|
13711
|
-
}
|
|
13712
|
-
if (change.launchHeadroom !== void 0) {
|
|
13713
|
-
launchPatch.headroom = change.launchHeadroom;
|
|
13714
|
-
}
|
|
13715
|
-
if (change.launchTrackUsage !== void 0) {
|
|
13716
|
-
launchPatch.trackUsage = change.launchTrackUsage;
|
|
13717
|
-
}
|
|
13718
|
-
if (change.launchProvider !== void 0) {
|
|
13719
|
-
launchPatch.provider = change.launchProvider === false ? void 0 : change.launchProvider;
|
|
13720
|
-
}
|
|
13721
|
-
if (change.launchClaudeVersion !== void 0) {
|
|
13722
|
-
launchPatch.claudeVersion = change.launchClaudeVersion === false ? void 0 : change.launchClaudeVersion;
|
|
13723
|
-
}
|
|
13724
|
-
if (change.launchDelay !== void 0) {
|
|
13725
|
-
launchPatch.delay = change.launchDelay === false ? void 0 : change.launchDelay;
|
|
13726
|
-
}
|
|
13727
|
-
if (change.launchPause !== void 0) {
|
|
13728
|
-
launchPatch.pause = change.launchPause;
|
|
13729
|
-
}
|
|
13730
|
-
if (change.launchExplain !== void 0) {
|
|
13731
|
-
launchPatch.explain = change.launchExplain;
|
|
13732
|
-
}
|
|
13733
|
-
if (change.launchRouteByName !== void 0) {
|
|
13734
|
-
launchPatch.routeByName = change.launchRouteByName;
|
|
13735
|
-
}
|
|
13736
|
-
if (Object.keys(launchPatch).length > 0) {
|
|
13737
|
-
setProfileLaunchFlags(paths, name, launchPatch);
|
|
13738
|
-
touched = true;
|
|
13739
|
-
}
|
|
13740
|
-
return touched;
|
|
13741
|
-
}
|
|
13742
|
-
|
|
13743
|
-
// src/poolStore.ts
|
|
13839
|
+
init_configProfilesStore();
|
|
13744
13840
|
init_store();
|
|
13745
13841
|
init_schema();
|
|
13746
13842
|
init_identity();
|
|
@@ -14821,53 +14917,8 @@ init_credentialCache();
|
|
|
14821
14917
|
init_realCredentialCache();
|
|
14822
14918
|
init_source();
|
|
14823
14919
|
|
|
14824
|
-
// src/modelsStore.ts
|
|
14825
|
-
init_store();
|
|
14826
|
-
init_schema();
|
|
14827
|
-
var VirtualModelNotFoundError = class extends Error {
|
|
14828
|
-
constructor(name) {
|
|
14829
|
-
super(`No virtual model named "${name}".`);
|
|
14830
|
-
this.name = "VirtualModelNotFoundError";
|
|
14831
|
-
}
|
|
14832
|
-
};
|
|
14833
|
-
function memberKindOf(ref, models) {
|
|
14834
|
-
if (ref.startsWith("acct:")) {
|
|
14835
|
-
return "account";
|
|
14836
|
-
}
|
|
14837
|
-
if (ref.startsWith("family:")) {
|
|
14838
|
-
return "family";
|
|
14839
|
-
}
|
|
14840
|
-
return models?.virtual !== void 0 && ref in models.virtual ? "virtual" : "provider";
|
|
14841
|
-
}
|
|
14842
|
-
function expandMembers(name, models) {
|
|
14843
|
-
const virtual = models?.virtual ?? {};
|
|
14844
|
-
const expanded = [];
|
|
14845
|
-
const walk = (current, chain) => {
|
|
14846
|
-
const nested = virtual[current];
|
|
14847
|
-
if (nested !== void 0) {
|
|
14848
|
-
if (chain.includes(current)) {
|
|
14849
|
-
throw new Error(`virtual model cycle: ${[...chain, current].join(" -> ")}`);
|
|
14850
|
-
}
|
|
14851
|
-
for (const member of nested.members) {
|
|
14852
|
-
walk(member, [...chain, current]);
|
|
14853
|
-
}
|
|
14854
|
-
return;
|
|
14855
|
-
}
|
|
14856
|
-
if (!expanded.includes(current)) {
|
|
14857
|
-
expanded.push(current);
|
|
14858
|
-
}
|
|
14859
|
-
};
|
|
14860
|
-
const top = virtual[name];
|
|
14861
|
-
if (top === void 0) {
|
|
14862
|
-
throw new VirtualModelNotFoundError(name);
|
|
14863
|
-
}
|
|
14864
|
-
for (const member of top.members) {
|
|
14865
|
-
walk(member, [name]);
|
|
14866
|
-
}
|
|
14867
|
-
return expanded;
|
|
14868
|
-
}
|
|
14869
|
-
|
|
14870
14920
|
// src/models/doctor.ts
|
|
14921
|
+
init_modelsStore();
|
|
14871
14922
|
function modelsFindings(input) {
|
|
14872
14923
|
const findings = [];
|
|
14873
14924
|
const { models } = input;
|
|
@@ -14922,6 +14973,9 @@ function modelsFindings(input) {
|
|
|
14922
14973
|
return findings;
|
|
14923
14974
|
}
|
|
14924
14975
|
|
|
14976
|
+
// src/doctorReport.ts
|
|
14977
|
+
init_configProfilesStore();
|
|
14978
|
+
|
|
14925
14979
|
// src/headroom/allowlistDrift.ts
|
|
14926
14980
|
init_earlierRelease();
|
|
14927
14981
|
init_state2();
|
|
@@ -15862,9 +15916,10 @@ function createCodexApiRouter(deps) {
|
|
|
15862
15916
|
// src/frontdoor/configApi.ts
|
|
15863
15917
|
init_cliError();
|
|
15864
15918
|
init_schema();
|
|
15919
|
+
init_configProfilesStore();
|
|
15920
|
+
init_credential();
|
|
15865
15921
|
import { ORPCError as ORPCError2 } from "@orpc/client";
|
|
15866
15922
|
import { openapi as openapi3 } from "@orpc/openapi";
|
|
15867
|
-
init_credential();
|
|
15868
15923
|
|
|
15869
15924
|
// src/credentialCacheChange.ts
|
|
15870
15925
|
init_cliError();
|
|
@@ -19242,6 +19297,7 @@ init_guard();
|
|
|
19242
19297
|
init_paths();
|
|
19243
19298
|
init_cliError();
|
|
19244
19299
|
init_schema();
|
|
19300
|
+
init_configProfilesStore();
|
|
19245
19301
|
init_providersStore();
|
|
19246
19302
|
init_launcher();
|
|
19247
19303
|
init_spawn();
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6100,7 +6100,6 @@ declare function createConfigApiRouter(deps: ConfigApiDeps): {
|
|
|
6100
6100
|
kind: zod.ZodLiteral<"profile">;
|
|
6101
6101
|
name: zod.ZodString;
|
|
6102
6102
|
value: zod.ZodObject<{
|
|
6103
|
-
description: zod.ZodOptional<zod.ZodString>;
|
|
6104
6103
|
entries: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<readonly [zod.ZodBoolean, zod.ZodObject<{
|
|
6105
6104
|
value: zod.ZodBoolean;
|
|
6106
6105
|
when: zod.ZodUnion<readonly [zod.ZodObject<{
|
|
@@ -6176,6 +6175,7 @@ declare function createConfigApiRouter(deps: ConfigApiDeps): {
|
|
|
6176
6175
|
key: zod.ZodType<trilean.JsonValue, unknown, zod_v4_core.$ZodTypeInternals<trilean.JsonValue, unknown>>;
|
|
6177
6176
|
}, zod_v4_core.$strip>], "kind">]>;
|
|
6178
6177
|
}, zod_v4_core.$strict>]>>>;
|
|
6178
|
+
description: zod.ZodOptional<zod.ZodString>;
|
|
6179
6179
|
models: zod.ZodOptional<zod.ZodObject<{
|
|
6180
6180
|
virtual: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<readonly [zod.ZodObject<{
|
|
6181
6181
|
mode: zod.ZodEnum<{
|
|
@@ -6254,7 +6254,6 @@ declare function createConfigApiRouter(deps: ConfigApiDeps): {
|
|
|
6254
6254
|
kind: zod.ZodLiteral<"profile">;
|
|
6255
6255
|
name: zod.ZodString;
|
|
6256
6256
|
value: zod.ZodObject<{
|
|
6257
|
-
description: zod.ZodOptional<zod.ZodString>;
|
|
6258
6257
|
entries: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<readonly [zod.ZodBoolean, zod.ZodObject<{
|
|
6259
6258
|
value: zod.ZodBoolean;
|
|
6260
6259
|
when: zod.ZodUnion<readonly [zod.ZodObject<{
|
|
@@ -6330,6 +6329,7 @@ declare function createConfigApiRouter(deps: ConfigApiDeps): {
|
|
|
6330
6329
|
key: zod.ZodType<trilean.JsonValue, unknown, zod_v4_core.$ZodTypeInternals<trilean.JsonValue, unknown>>;
|
|
6331
6330
|
}, zod_v4_core.$strip>], "kind">]>;
|
|
6332
6331
|
}, zod_v4_core.$strict>]>>>;
|
|
6332
|
+
description: zod.ZodOptional<zod.ZodString>;
|
|
6333
6333
|
models: zod.ZodOptional<zod.ZodObject<{
|
|
6334
6334
|
virtual: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<readonly [zod.ZodObject<{
|
|
6335
6335
|
mode: zod.ZodEnum<{
|
|
@@ -9255,7 +9255,6 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
9255
9255
|
kind: zod.ZodLiteral<"profile">;
|
|
9256
9256
|
name: zod.ZodString;
|
|
9257
9257
|
value: zod.ZodObject<{
|
|
9258
|
-
description: zod.ZodOptional<zod.ZodString>;
|
|
9259
9258
|
entries: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<readonly [zod.ZodBoolean, zod.ZodObject<{
|
|
9260
9259
|
value: zod.ZodBoolean;
|
|
9261
9260
|
when: zod.ZodUnion<readonly [zod.ZodObject<{
|
|
@@ -9331,6 +9330,7 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
9331
9330
|
key: zod.ZodType<trilean.JsonValue, unknown, zod_v4_core.$ZodTypeInternals<trilean.JsonValue, unknown>>;
|
|
9332
9331
|
}, zod_v4_core.$strip>], "kind">]>;
|
|
9333
9332
|
}, zod_v4_core.$strict>]>>>;
|
|
9333
|
+
description: zod.ZodOptional<zod.ZodString>;
|
|
9334
9334
|
models: zod.ZodOptional<zod.ZodObject<{
|
|
9335
9335
|
virtual: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<readonly [zod.ZodObject<{
|
|
9336
9336
|
mode: zod.ZodEnum<{
|
|
@@ -9409,7 +9409,6 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
9409
9409
|
kind: zod.ZodLiteral<"profile">;
|
|
9410
9410
|
name: zod.ZodString;
|
|
9411
9411
|
value: zod.ZodObject<{
|
|
9412
|
-
description: zod.ZodOptional<zod.ZodString>;
|
|
9413
9412
|
entries: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<readonly [zod.ZodBoolean, zod.ZodObject<{
|
|
9414
9413
|
value: zod.ZodBoolean;
|
|
9415
9414
|
when: zod.ZodUnion<readonly [zod.ZodObject<{
|
|
@@ -9485,6 +9484,7 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
9485
9484
|
key: zod.ZodType<trilean.JsonValue, unknown, zod_v4_core.$ZodTypeInternals<trilean.JsonValue, unknown>>;
|
|
9486
9485
|
}, zod_v4_core.$strip>], "kind">]>;
|
|
9487
9486
|
}, zod_v4_core.$strict>]>>>;
|
|
9487
|
+
description: zod.ZodOptional<zod.ZodString>;
|
|
9488
9488
|
models: zod.ZodOptional<zod.ZodObject<{
|
|
9489
9489
|
virtual: zod.ZodOptional<zod.ZodRecord<zod.ZodString, zod.ZodUnion<readonly [zod.ZodObject<{
|
|
9490
9490
|
mode: zod.ZodEnum<{
|
|
@@ -11514,7 +11514,6 @@ declare const ConfigProfileAddOutputSchema: z.ZodObject<{
|
|
|
11514
11514
|
kind: z.ZodLiteral<"profile">;
|
|
11515
11515
|
name: z.ZodString;
|
|
11516
11516
|
value: z.ZodObject<{
|
|
11517
|
-
description: z.ZodOptional<z.ZodString>;
|
|
11518
11517
|
entries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
11519
11518
|
value: z.ZodBoolean;
|
|
11520
11519
|
when: z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -11590,6 +11589,7 @@ declare const ConfigProfileAddOutputSchema: z.ZodObject<{
|
|
|
11590
11589
|
key: z.ZodType<trilean.JsonValue, unknown, z.core.$ZodTypeInternals<trilean.JsonValue, unknown>>;
|
|
11591
11590
|
}, z.core.$strip>], "kind">]>;
|
|
11592
11591
|
}, z.core.$strict>]>>>;
|
|
11592
|
+
description: z.ZodOptional<z.ZodString>;
|
|
11593
11593
|
models: z.ZodOptional<z.ZodObject<{
|
|
11594
11594
|
virtual: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
11595
11595
|
mode: z.ZodEnum<{
|
|
@@ -11670,7 +11670,6 @@ declare const ConfigProfileSetOutputSchema: z.ZodObject<{
|
|
|
11670
11670
|
kind: z.ZodLiteral<"profile">;
|
|
11671
11671
|
name: z.ZodString;
|
|
11672
11672
|
value: z.ZodObject<{
|
|
11673
|
-
description: z.ZodOptional<z.ZodString>;
|
|
11674
11673
|
entries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
11675
11674
|
value: z.ZodBoolean;
|
|
11676
11675
|
when: z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -11746,6 +11745,7 @@ declare const ConfigProfileSetOutputSchema: z.ZodObject<{
|
|
|
11746
11745
|
key: z.ZodType<trilean.JsonValue, unknown, z.core.$ZodTypeInternals<trilean.JsonValue, unknown>>;
|
|
11747
11746
|
}, z.core.$strip>], "kind">]>;
|
|
11748
11747
|
}, z.core.$strict>]>>>;
|
|
11748
|
+
description: z.ZodOptional<z.ZodString>;
|
|
11749
11749
|
models: z.ZodOptional<z.ZodObject<{
|
|
11750
11750
|
virtual: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
11751
11751
|
mode: z.ZodEnum<{
|