agent-shim 14.3.1 → 14.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cli.cjs +1502 -1290
- package/dist/index.cjs +163 -77
- package/dist/index.mjs +163 -77
- package/dist/types/index.d.ts +38 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2642,6 +2642,7 @@ function planFarm(params) {
|
|
|
2642
2642
|
const entries = [];
|
|
2643
2643
|
const materialised = [];
|
|
2644
2644
|
const links = [];
|
|
2645
|
+
const dangling = [];
|
|
2645
2646
|
const conditionalPatterns = [...params.flattened.rules.values()].filter((rule) => rule.when !== void 0).map((rule) => rule.canonicalPattern);
|
|
2646
2647
|
const conditionalRuleCouldReach = (dir) => conditionalPatterns.some((pattern) => patternCouldReachUnder(pattern, dir));
|
|
2647
2648
|
const subtreeDecision = (rel) => {
|
|
@@ -2674,7 +2675,10 @@ function planFarm(params) {
|
|
|
2674
2675
|
return;
|
|
2675
2676
|
}
|
|
2676
2677
|
if (!fact.isDirectory) {
|
|
2677
|
-
if (decision?.shared === true) {
|
|
2678
|
+
if (decision?.shared === true && fact.isDanglingSymlink) {
|
|
2679
|
+
entries.push({ kind: "omit", rel });
|
|
2680
|
+
dangling.push(rel);
|
|
2681
|
+
} else if (decision?.shared === true) {
|
|
2678
2682
|
entries.push({ kind: "link", rel, target: linkTarget(rel) });
|
|
2679
2683
|
links.push({ rel, target: linkTarget(rel) });
|
|
2680
2684
|
} else {
|
|
@@ -2709,7 +2713,7 @@ function planFarm(params) {
|
|
|
2709
2713
|
for (const rel of children.get("") ?? []) {
|
|
2710
2714
|
visit(rel);
|
|
2711
2715
|
}
|
|
2712
|
-
return { entries, materialised, links };
|
|
2716
|
+
return { entries, materialised, links, dangling };
|
|
2713
2717
|
}
|
|
2714
2718
|
var init_plan = __esm({
|
|
2715
2719
|
"src/resolve/plan.ts"() {
|
|
@@ -2951,6 +2955,14 @@ function topLevelNames(facts) {
|
|
|
2951
2955
|
function descendPolicyFor(cascade, home) {
|
|
2952
2956
|
return descendPolicy(flattenLayers(assembleCascade(cascade).layers, { home }).rules.values());
|
|
2953
2957
|
}
|
|
2958
|
+
function danglingDiagnostic(rel) {
|
|
2959
|
+
return {
|
|
2960
|
+
code: "SHARED_ENTRY_DANGLING",
|
|
2961
|
+
severity: "warning",
|
|
2962
|
+
message: `"${rel}" is shared, but ~/.claude/${rel} is a symlink that leads nowhere, so the farm does not link it and this identity keeps its own copy. Once the symlink leads somewhere, the next launch, or \`agent-shim identity resync <identity>\` in this directory, links the entry.`,
|
|
2963
|
+
subject: rel
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2954
2966
|
function resolveDecisions(input) {
|
|
2955
2967
|
const assembled = assembleCascade(input.cascade);
|
|
2956
2968
|
const flattened = flattenLayers(assembled.layers, { home: input.facts.home });
|
|
@@ -2970,7 +2982,7 @@ function resolveDecisions(input) {
|
|
|
2970
2982
|
classification,
|
|
2971
2983
|
decisions: resolved.decisions,
|
|
2972
2984
|
farm,
|
|
2973
|
-
diagnostics: [...assembled.diagnostics, ...resolved.diagnostics]
|
|
2985
|
+
diagnostics: [...assembled.diagnostics, ...resolved.diagnostics, ...farm.dangling.map(danglingDiagnostic)]
|
|
2974
2986
|
};
|
|
2975
2987
|
}
|
|
2976
2988
|
var init_pipeline = __esm({
|
|
@@ -3419,6 +3431,34 @@ function readFarmManifest(fs17, farmRoot) {
|
|
|
3419
3431
|
const result = FarmManifestSchema.safeParse(parsed);
|
|
3420
3432
|
return result.success ? result.data : void 0;
|
|
3421
3433
|
}
|
|
3434
|
+
function danglingFarmLinks(fs17, farmRoot) {
|
|
3435
|
+
const manifest = readFarmManifest(fs17, farmRoot);
|
|
3436
|
+
const recorded = new Map((manifest?.links ?? []).map((link) => [link.rel, link.target]));
|
|
3437
|
+
const materialised = new Set(manifest?.materialised ?? []);
|
|
3438
|
+
const candidates = new Set(recorded.keys());
|
|
3439
|
+
const walk2 = (rel) => {
|
|
3440
|
+
const stat = fs17.lstat(path10.join(farmRoot, rel));
|
|
3441
|
+
if (stat?.kind === "symlink") {
|
|
3442
|
+
candidates.add(rel);
|
|
3443
|
+
} else if (stat?.kind === "dir" && materialised.has(rel)) {
|
|
3444
|
+
for (const name of fs17.readdir(path10.join(farmRoot, rel))) {
|
|
3445
|
+
walk2(`${rel}/${name}`);
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
};
|
|
3449
|
+
for (const name of fs17.readdir(farmRoot)) {
|
|
3450
|
+
if (name !== FARM_MANIFEST_FILENAME && name !== LEGACY_FARM_MANIFEST_FILENAME) {
|
|
3451
|
+
walk2(name);
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
return [...candidates].sort().filter((rel) => {
|
|
3455
|
+
const absolute = path10.join(farmRoot, rel);
|
|
3456
|
+
return fs17.lstat(absolute)?.kind === "symlink" && !fs17.resolves(absolute);
|
|
3457
|
+
}).map((rel) => {
|
|
3458
|
+
const target = recorded.get(rel);
|
|
3459
|
+
return target === void 0 ? { rel } : { rel, target };
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3422
3462
|
function buildEntryFacts(params) {
|
|
3423
3463
|
const entries = /* @__PURE__ */ new Map();
|
|
3424
3464
|
const visit = (rel) => {
|
|
@@ -3443,6 +3483,7 @@ function buildEntryFacts(params) {
|
|
|
3443
3483
|
relPath: rel,
|
|
3444
3484
|
isDirectory,
|
|
3445
3485
|
isSymlink: stat.kind === "symlink",
|
|
3486
|
+
isDanglingSymlink: stat.kind === "symlink" && !params.fs.resolves(absolute),
|
|
3446
3487
|
mtimeMs: stat.mtimeMs,
|
|
3447
3488
|
latestMtimeMs,
|
|
3448
3489
|
sizeBytes: stat.sizeBytes,
|
|
@@ -3805,6 +3846,7 @@ function resyncFarm(params) {
|
|
|
3805
3846
|
farmRoot,
|
|
3806
3847
|
noOp: true,
|
|
3807
3848
|
manifest: previousManifest,
|
|
3849
|
+
previousManifest,
|
|
3808
3850
|
resolved,
|
|
3809
3851
|
adopted: outcome.adopted,
|
|
3810
3852
|
recovery,
|
|
@@ -3827,6 +3869,7 @@ function resyncFarm(params) {
|
|
|
3827
3869
|
farmRoot,
|
|
3828
3870
|
noOp: false,
|
|
3829
3871
|
manifest,
|
|
3872
|
+
...previousManifest === void 0 ? {} : { previousManifest },
|
|
3830
3873
|
resolved,
|
|
3831
3874
|
adopted: outcome.adopted,
|
|
3832
3875
|
recovery,
|
|
@@ -11046,15 +11089,15 @@ function pathDirectories(target, ports) {
|
|
|
11046
11089
|
}
|
|
11047
11090
|
return directories;
|
|
11048
11091
|
}
|
|
11049
|
-
function headroomDirectoryRefusal(directory, stat, uid,
|
|
11092
|
+
function headroomDirectoryRefusal(directory, stat, uid, remedy2) {
|
|
11050
11093
|
if (stat?.kind !== "dir") {
|
|
11051
11094
|
return `the directory ${directory} on the allowlist file's path is ${stat === void 0 ? "missing" : "not a directory"}, so headroom refuses the file`;
|
|
11052
11095
|
}
|
|
11053
11096
|
if (stat.uid !== uid && stat.uid !== ROOT_UID) {
|
|
11054
|
-
return `the directory ${directory} on the allowlist file's path is owned by uid ${String(stat.uid)}, not by this user (uid ${String(uid)}) or root, so headroom refuses the file${
|
|
11097
|
+
return `the directory ${directory} on the allowlist file's path is owned by uid ${String(stat.uid)}, not by this user (uid ${String(uid)}) or root, so headroom refuses the file${remedy2 ? `; ${MOVE_ROOT_REMEDY}` : ""}`;
|
|
11055
11098
|
}
|
|
11056
11099
|
if ((stat.mode & GROUP_OR_OTHER_WRITE_BITS) !== 0) {
|
|
11057
|
-
return `the directory ${directory} on the allowlist file's path is writable by group or others (mode ${stat.mode.toString(OCTAL_RADIX2).padStart(MODE_DIGITS, "0")}), so headroom refuses the file${
|
|
11100
|
+
return `the directory ${directory} on the allowlist file's path is writable by group or others (mode ${stat.mode.toString(OCTAL_RADIX2).padStart(MODE_DIGITS, "0")}), so headroom refuses the file${remedy2 ? `; ${stat.uid === uid && (stat.mode & STICKY_BIT) === 0 ? `run \`chmod go-w ${directory}\`` : MOVE_ROOT_REMEDY}` : ""}`;
|
|
11058
11101
|
}
|
|
11059
11102
|
return void 0;
|
|
11060
11103
|
}
|
|
@@ -11962,6 +12005,9 @@ var init_realPorts = __esm({
|
|
|
11962
12005
|
const kind = stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "dir" : "file";
|
|
11963
12006
|
return { kind, mtimeMs: stat.mtimeMs, sizeBytes: stat.size };
|
|
11964
12007
|
},
|
|
12008
|
+
resolves(filePath) {
|
|
12009
|
+
return fs6.statSync(filePath, { throwIfNoEntry: false }) !== void 0;
|
|
12010
|
+
},
|
|
11965
12011
|
readdir(dirPath) {
|
|
11966
12012
|
try {
|
|
11967
12013
|
return fs6.readdirSync(dirPath);
|
|
@@ -14023,8 +14069,8 @@ var init_identityStore = __esm({
|
|
|
14023
14069
|
init_identityRecords();
|
|
14024
14070
|
init_launchRecords();
|
|
14025
14071
|
IdentityNotFoundError = class extends CliError {
|
|
14026
|
-
constructor(name,
|
|
14027
|
-
super(`No identity named "${name}". ${
|
|
14072
|
+
constructor(name, remedy2 = `Run \`agent-shim identity add ${name}\` first.`) {
|
|
14073
|
+
super(`No identity named "${name}". ${remedy2}`);
|
|
14028
14074
|
this.name = name;
|
|
14029
14075
|
this.name = "IdentityNotFoundError";
|
|
14030
14076
|
}
|
|
@@ -14082,7 +14128,7 @@ var init_package = __esm({
|
|
|
14082
14128
|
"package.json"() {
|
|
14083
14129
|
package_default = {
|
|
14084
14130
|
name: "agent-shim",
|
|
14085
|
-
version: "14.
|
|
14131
|
+
version: "14.4.0",
|
|
14086
14132
|
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.",
|
|
14087
14133
|
license: "MIT",
|
|
14088
14134
|
author: "Joseph Mearman <joseph@mearman.co.uk>",
|
|
@@ -20401,7 +20447,9 @@ var DIAGNOSTIC_CODES = [
|
|
|
20401
20447
|
/** A previous launch was interrupted mid-swap and this launch completed or undid the half-finished work. */
|
|
20402
20448
|
"FARM_SWAP_RECOVERED",
|
|
20403
20449
|
/** A superseded farm could not be discarded because it still held data the new farm has its own entry for, so it was left on disk for the user to look at. */
|
|
20404
|
-
"FARM_PREVIOUS_RETAINED"
|
|
20450
|
+
"FARM_PREVIOUS_RETAINED",
|
|
20451
|
+
/** A shared `~/.claude` entry is a symlink that reaches nothing, so the farm does not link it and the identity keeps its own copy until the entry leads somewhere. */
|
|
20452
|
+
"SHARED_ENTRY_DANGLING"
|
|
20405
20453
|
];
|
|
20406
20454
|
var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
|
|
20407
20455
|
|
|
@@ -21269,6 +21317,31 @@ function pushKeychainFindings(push, platform, run, identities, agentOf) {
|
|
|
21269
21317
|
}
|
|
21270
21318
|
}
|
|
21271
21319
|
|
|
21320
|
+
// src/doctorFarmLinks.ts
|
|
21321
|
+
function remedy(agent, name, rel) {
|
|
21322
|
+
if (agent === "codex") {
|
|
21323
|
+
return `Codex cannot write through it. A launch with \`agent-shim run --agent codex @${name}\` resyncs the farm and leaves the link out.`;
|
|
21324
|
+
}
|
|
21325
|
+
const lost = rel === "sessions" ? " (an interactive session's record under sessions/ is lost, so the session is missing from `claude agents`)" : "";
|
|
21326
|
+
return `Claude Code cannot write through it${lost}. A launch through agent-shim resyncs the farm and leaves the link out, but a session started with this directory as CLAUDE_CONFIG_DIR does not. Run \`agent-shim identity resync ${name}\` in the directory those sessions start in to bring the farm up to date without launching.`;
|
|
21327
|
+
}
|
|
21328
|
+
function pushFarmLinkFindings(push, farms, agentOf) {
|
|
21329
|
+
let found = false;
|
|
21330
|
+
for (const farm of farms) {
|
|
21331
|
+
for (const link of farm.dangling) {
|
|
21332
|
+
found = true;
|
|
21333
|
+
const points = link.target === void 0 ? "" : ` to ${link.target}`;
|
|
21334
|
+
push("farm-links", "warn", `identities/${farm.id}/${link.rel} is a farm link${points} that leads nowhere, so ${remedy(agentOf.get(farm.name) ?? "claude", farm.name, link.rel)}`, farm.name);
|
|
21335
|
+
}
|
|
21336
|
+
}
|
|
21337
|
+
if (!found) {
|
|
21338
|
+
push("farm-links", "pass", "Every identity's farm links lead somewhere.");
|
|
21339
|
+
}
|
|
21340
|
+
}
|
|
21341
|
+
|
|
21342
|
+
// src/doctorReport.ts
|
|
21343
|
+
init_farm();
|
|
21344
|
+
|
|
21272
21345
|
// src/frontdoor/catalogueFailures.ts
|
|
21273
21346
|
init_state();
|
|
21274
21347
|
init_catalogueState();
|
|
@@ -21678,6 +21751,7 @@ var DOCTOR_SECTIONS = [
|
|
|
21678
21751
|
"config-profile",
|
|
21679
21752
|
"identity",
|
|
21680
21753
|
"sign-in",
|
|
21754
|
+
"farm-links",
|
|
21681
21755
|
"pool",
|
|
21682
21756
|
"provider",
|
|
21683
21757
|
"keychain",
|
|
@@ -22076,6 +22150,9 @@ function runDoctor(params) {
|
|
|
22076
22150
|
push("provider", finding.level, finding.message, finding.alias);
|
|
22077
22151
|
}
|
|
22078
22152
|
pushKeychainFindings(push, params.platform, params.run, params.identities, validIdentityAgents);
|
|
22153
|
+
if (params.farmLinks !== void 0) {
|
|
22154
|
+
pushFarmLinkFindings(push, params.farmLinks, validIdentityAgents);
|
|
22155
|
+
}
|
|
22079
22156
|
if (params.directoryRules.raw === void 0) {
|
|
22080
22157
|
push("directory-rules", "pass", "No directory-rules.json configured.");
|
|
22081
22158
|
} else {
|
|
@@ -22225,73 +22302,6 @@ function runDoctor(params) {
|
|
|
22225
22302
|
}
|
|
22226
22303
|
return { findings, ok: !findings.some((finding) => finding.severity === "fail") };
|
|
22227
22304
|
}
|
|
22228
|
-
var SECTION_TITLES = {
|
|
22229
|
-
models: "Virtual models",
|
|
22230
|
-
"ambient-credential": "Ambient-credential exposure",
|
|
22231
|
-
"binary-discovery": "Claude Code binary discovery",
|
|
22232
|
-
"claude-shim": "`claude` command shim",
|
|
22233
|
-
"path-resolution": "PATH resolution",
|
|
22234
|
-
"legacy-name": "Former `claude-use` name",
|
|
22235
|
-
"config-profile": "Configuration profiles",
|
|
22236
|
-
identity: "Identities",
|
|
22237
|
-
"sign-in": "Sign-in",
|
|
22238
|
-
pool: "Pools",
|
|
22239
|
-
provider: "Providers",
|
|
22240
|
-
keychain: "macOS Keychain",
|
|
22241
|
-
"directory-rules": "Directory rules",
|
|
22242
|
-
"global-config": "Global config",
|
|
22243
|
-
headroom: "Headroom daemon",
|
|
22244
|
-
frontdoor: "Front door",
|
|
22245
|
-
"categories-local": "categories.local.json",
|
|
22246
|
-
"active-identity": "Active identity"
|
|
22247
|
-
};
|
|
22248
|
-
var SECTION_ORDER = [
|
|
22249
|
-
"ambient-credential",
|
|
22250
|
-
"binary-discovery",
|
|
22251
|
-
"claude-shim",
|
|
22252
|
-
"path-resolution",
|
|
22253
|
-
"config-profile",
|
|
22254
|
-
"identity",
|
|
22255
|
-
"sign-in",
|
|
22256
|
-
"pool",
|
|
22257
|
-
"provider",
|
|
22258
|
-
"keychain",
|
|
22259
|
-
"directory-rules",
|
|
22260
|
-
"global-config",
|
|
22261
|
-
"headroom",
|
|
22262
|
-
"frontdoor",
|
|
22263
|
-
"categories-local",
|
|
22264
|
-
"active-identity"
|
|
22265
|
-
];
|
|
22266
|
-
function severityPrefix(severity) {
|
|
22267
|
-
switch (severity) {
|
|
22268
|
-
case "pass":
|
|
22269
|
-
return "[PASS]";
|
|
22270
|
-
case "warn":
|
|
22271
|
-
return "[WARN]";
|
|
22272
|
-
case "fail":
|
|
22273
|
-
return "[FAIL]";
|
|
22274
|
-
default:
|
|
22275
|
-
return severity;
|
|
22276
|
-
}
|
|
22277
|
-
}
|
|
22278
|
-
function formatDoctorReport(report) {
|
|
22279
|
-
const lines = [];
|
|
22280
|
-
for (const section of SECTION_ORDER) {
|
|
22281
|
-
const sectionFindings = report.findings.filter((finding) => finding.section === section);
|
|
22282
|
-
if (sectionFindings.length === 0) {
|
|
22283
|
-
continue;
|
|
22284
|
-
}
|
|
22285
|
-
lines.push("", `${SECTION_TITLES[section]}:`);
|
|
22286
|
-
for (const finding of sectionFindings) {
|
|
22287
|
-
const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
|
|
22288
|
-
lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
|
|
22289
|
-
}
|
|
22290
|
-
}
|
|
22291
|
-
const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
|
|
22292
|
-
lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
|
|
22293
|
-
return lines;
|
|
22294
|
-
}
|
|
22295
22305
|
function servingDoorListeners(paths) {
|
|
22296
22306
|
const state = readFrontDoorState(realFarmFs, paths.frontdoorStateFile) ?? {};
|
|
22297
22307
|
const alive = state.supervisorPid !== void 0 && realIsProcessRunning(state.supervisorPid);
|
|
@@ -22364,6 +22374,7 @@ function collectDoctorReport(params) {
|
|
|
22364
22374
|
chatgptSignIn: { path: paths.chatgptSignInFile, raw: realFsPort.readFileUtf8(paths.chatgptSignInFile) },
|
|
22365
22375
|
installedClaudeVersions: realInstalledClaudeVersions(),
|
|
22366
22376
|
identities,
|
|
22377
|
+
farmLinks: identities.map(({ name, id, farmRoot }) => ({ name, id, dangling: danglingFarmLinks(realFarmFs, farmRoot) })),
|
|
22367
22378
|
usageSnapshots,
|
|
22368
22379
|
configProfiles,
|
|
22369
22380
|
providers,
|
|
@@ -26390,6 +26401,81 @@ init_names();
|
|
|
26390
26401
|
init_providersStore();
|
|
26391
26402
|
init_poolStore();
|
|
26392
26403
|
init_directoryRulesStore();
|
|
26404
|
+
|
|
26405
|
+
// src/doctorFormat.ts
|
|
26406
|
+
var SECTION_TITLES = {
|
|
26407
|
+
models: "Virtual models",
|
|
26408
|
+
"ambient-credential": "Ambient-credential exposure",
|
|
26409
|
+
"binary-discovery": "Claude Code binary discovery",
|
|
26410
|
+
"claude-shim": "`claude` command shim",
|
|
26411
|
+
"path-resolution": "PATH resolution",
|
|
26412
|
+
"legacy-name": "Former `claude-use` name",
|
|
26413
|
+
"config-profile": "Configuration profiles",
|
|
26414
|
+
identity: "Identities",
|
|
26415
|
+
"sign-in": "Sign-in",
|
|
26416
|
+
"farm-links": "Farm links",
|
|
26417
|
+
pool: "Pools",
|
|
26418
|
+
provider: "Providers",
|
|
26419
|
+
keychain: "macOS Keychain",
|
|
26420
|
+
"directory-rules": "Directory rules",
|
|
26421
|
+
"global-config": "Global config",
|
|
26422
|
+
headroom: "Headroom daemon",
|
|
26423
|
+
frontdoor: "Front door",
|
|
26424
|
+
"categories-local": "categories.local.json",
|
|
26425
|
+
"active-identity": "Active identity"
|
|
26426
|
+
};
|
|
26427
|
+
var SECTION_ORDER = [
|
|
26428
|
+
"ambient-credential",
|
|
26429
|
+
"binary-discovery",
|
|
26430
|
+
"claude-shim",
|
|
26431
|
+
"path-resolution",
|
|
26432
|
+
"legacy-name",
|
|
26433
|
+
"config-profile",
|
|
26434
|
+
"identity",
|
|
26435
|
+
"sign-in",
|
|
26436
|
+
"farm-links",
|
|
26437
|
+
"pool",
|
|
26438
|
+
"provider",
|
|
26439
|
+
"keychain",
|
|
26440
|
+
"directory-rules",
|
|
26441
|
+
"global-config",
|
|
26442
|
+
"models",
|
|
26443
|
+
"headroom",
|
|
26444
|
+
"frontdoor",
|
|
26445
|
+
"categories-local",
|
|
26446
|
+
"active-identity"
|
|
26447
|
+
];
|
|
26448
|
+
function severityPrefix(severity) {
|
|
26449
|
+
switch (severity) {
|
|
26450
|
+
case "pass":
|
|
26451
|
+
return "[PASS]";
|
|
26452
|
+
case "warn":
|
|
26453
|
+
return "[WARN]";
|
|
26454
|
+
case "fail":
|
|
26455
|
+
return "[FAIL]";
|
|
26456
|
+
default:
|
|
26457
|
+
return severity;
|
|
26458
|
+
}
|
|
26459
|
+
}
|
|
26460
|
+
function formatDoctorReport(report) {
|
|
26461
|
+
const lines = [];
|
|
26462
|
+
for (const section of SECTION_ORDER) {
|
|
26463
|
+
const sectionFindings = report.findings.filter((finding) => finding.section === section);
|
|
26464
|
+
if (sectionFindings.length === 0) {
|
|
26465
|
+
continue;
|
|
26466
|
+
}
|
|
26467
|
+
lines.push("", `${SECTION_TITLES[section]}:`);
|
|
26468
|
+
for (const finding of sectionFindings) {
|
|
26469
|
+
const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
|
|
26470
|
+
lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
|
|
26471
|
+
}
|
|
26472
|
+
}
|
|
26473
|
+
const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
|
|
26474
|
+
lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
|
|
26475
|
+
return lines;
|
|
26476
|
+
}
|
|
26477
|
+
|
|
26478
|
+
// src/index.ts
|
|
26393
26479
|
init_launcher();
|
|
26394
26480
|
init_spawn();
|
|
26395
26481
|
init_launchWiring();
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5684,6 +5684,8 @@ interface EntryFact {
|
|
|
5684
5684
|
readonly isDirectory: boolean;
|
|
5685
5685
|
/** True when the entry is itself a symlink (including the relative, tree-escaping symlinks that already exist inside a real `~/.claude`). */
|
|
5686
5686
|
readonly isSymlink: boolean;
|
|
5687
|
+
/** True when the entry is a symlink that reaches nothing once followed to its end, so what it would be is unknown; false for every other entry. */
|
|
5688
|
+
readonly isDanglingSymlink: boolean;
|
|
5687
5689
|
/** The entry's own mtime. */
|
|
5688
5690
|
readonly mtimeMs: number;
|
|
5689
5691
|
/** The most recent mtime anywhere in this entry's subtree — its own mtime for a plain file. A directory-scoped `newerThan` must read this, never the directory's own inode mtime, which does not change when a file three levels down is rewritten. */
|
|
@@ -5754,7 +5756,7 @@ interface EliminatedRule {
|
|
|
5754
5756
|
readonly failed: readonly string[];
|
|
5755
5757
|
}
|
|
5756
5758
|
/** Every diagnostic the resolver can raise. Codes are stable strings so `agent-shim check` and tests can assert on them. */
|
|
5757
|
-
declare const DIAGNOSTIC_CODES: readonly ["EXTENDS_CYCLE", "MISSING_PROFILE", "SECRET_ENTRY_KEY", "SECRET_PATH_NEUTRALISED", "CATEGORY_PREFIX_MISMATCH", "MALFORMED_ENTRY_KEY", "EXACT_ENTRY_OVERRIDDEN_BY_LATER_GLOB", "AMBIGUOUS_PROJECT_ENCODING", "UNROOTED_PROJECT_PATH", "UNCLASSIFIED_ENTRY", "EMPTY_WHEN", "FARM_MANIFEST_MISSING", "RECONCILE_CONFLICT", "RECONCILE_SECRET_BLOCKED", "FARM_SWAP_RECOVERED", "FARM_PREVIOUS_RETAINED"];
|
|
5759
|
+
declare const DIAGNOSTIC_CODES: readonly ["EXTENDS_CYCLE", "MISSING_PROFILE", "SECRET_ENTRY_KEY", "SECRET_PATH_NEUTRALISED", "CATEGORY_PREFIX_MISMATCH", "MALFORMED_ENTRY_KEY", "EXACT_ENTRY_OVERRIDDEN_BY_LATER_GLOB", "AMBIGUOUS_PROJECT_ENCODING", "UNROOTED_PROJECT_PATH", "UNCLASSIFIED_ENTRY", "EMPTY_WHEN", "FARM_MANIFEST_MISSING", "RECONCILE_CONFLICT", "RECONCILE_SECRET_BLOCKED", "FARM_SWAP_RECOVERED", "FARM_PREVIOUS_RETAINED", "SHARED_ENTRY_DANGLING"];
|
|
5758
5760
|
type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[number];
|
|
5759
5761
|
/** Severity of a diagnostic. An `error` means a configuration layer asked for something the tool refused to do. */
|
|
5760
5762
|
declare const DIAGNOSTIC_SEVERITIES: readonly ["error", "warning", "info"];
|
|
@@ -5823,6 +5825,8 @@ interface FarmPlan {
|
|
|
5823
5825
|
readonly rel: string;
|
|
5824
5826
|
readonly target: string;
|
|
5825
5827
|
}[];
|
|
5828
|
+
/** Shared entries left out of the farm because their `~/.claude` path is a symlink that reaches nothing, in plan order. */
|
|
5829
|
+
readonly dangling: readonly string[];
|
|
5826
5830
|
}
|
|
5827
5831
|
|
|
5828
5832
|
/**
|
|
@@ -6089,6 +6093,8 @@ interface PrivateWriteOptions {
|
|
|
6089
6093
|
interface FarmFs {
|
|
6090
6094
|
/** Stats one path without following symlinks, or returns undefined when nothing is there. */
|
|
6091
6095
|
readonly lstat: (path: string) => FarmStat | undefined;
|
|
6096
|
+
/** Whether `path` reaches something once every symlink along it is followed to its end: false when nothing is there, or when a symlink on the way points at nothing. Used to tell a symlink that leads somewhere from one that dangles, which `lstat` alone cannot. */
|
|
6097
|
+
readonly resolves: (path: string) => boolean;
|
|
6092
6098
|
/** Lists one directory's immediate child names, or an empty list when it does not exist. */
|
|
6093
6099
|
readonly readdir: (path: string) => readonly string[];
|
|
6094
6100
|
/** Creates a directory and any missing parents, succeeding silently when it already exists. */
|
|
@@ -6229,6 +6235,13 @@ interface FrontDoorUp {
|
|
|
6229
6235
|
declare const FARM_MANIFEST_FILENAME = ".agent-shim-farm.json";
|
|
6230
6236
|
/** Reads and validates the manifest at a farm root, or undefined when it is missing, unparseable, or does not validate. */
|
|
6231
6237
|
declare function readFarmManifest(fs: FarmFs, farmRoot: string): FarmManifest | undefined;
|
|
6238
|
+
/** A link in an identity's farm that leads nowhere. */
|
|
6239
|
+
interface DanglingFarmLink {
|
|
6240
|
+
/** The link's path relative to the farm root. */
|
|
6241
|
+
readonly rel: string;
|
|
6242
|
+
/** Where the farm's manifest records the link pointing; undefined for a link the manifest does not record. */
|
|
6243
|
+
readonly target?: string;
|
|
6244
|
+
}
|
|
6232
6245
|
/** Everything `buildEntryFacts` needs. Everything except the tree itself is injected, so the fact manifest is reproducible from a fake filesystem, a fake clock, and a fake branch. */
|
|
6233
6246
|
interface BuildEntryFactsParams {
|
|
6234
6247
|
readonly fs: FarmFs;
|
|
@@ -6365,6 +6378,8 @@ interface ResyncFarmResult {
|
|
|
6365
6378
|
readonly noOp: boolean;
|
|
6366
6379
|
/** The manifest the farm now carries — the newly written one, or the existing one on a no-op. */
|
|
6367
6380
|
readonly manifest: FarmManifest;
|
|
6381
|
+
/** The manifest the farm carried before this resync, read under the lock; undefined when the farm had none this release can read. Comparing its links with `manifest`'s says which links this resync removed. */
|
|
6382
|
+
readonly previousManifest?: FarmManifest;
|
|
6368
6383
|
/** The fully resolved state, including the flattened cascade's launch flags, which the launcher goes on to use. */
|
|
6369
6384
|
readonly resolved: ResolvedState;
|
|
6370
6385
|
readonly adopted: readonly string[];
|
|
@@ -9389,6 +9404,7 @@ declare const CheckReportJsonSchema: z.ZodObject<{
|
|
|
9389
9404
|
RECONCILE_SECRET_BLOCKED: "RECONCILE_SECRET_BLOCKED";
|
|
9390
9405
|
FARM_SWAP_RECOVERED: "FARM_SWAP_RECOVERED";
|
|
9391
9406
|
FARM_PREVIOUS_RETAINED: "FARM_PREVIOUS_RETAINED";
|
|
9407
|
+
SHARED_ENTRY_DANGLING: "SHARED_ENTRY_DANGLING";
|
|
9392
9408
|
}>;
|
|
9393
9409
|
severity: z.ZodEnum<{
|
|
9394
9410
|
error: "error";
|
|
@@ -9877,6 +9893,7 @@ declare const DoctorFindingSchema: z.ZodObject<{
|
|
|
9877
9893
|
"path-resolution": "path-resolution";
|
|
9878
9894
|
"legacy-name": "legacy-name";
|
|
9879
9895
|
"sign-in": "sign-in";
|
|
9896
|
+
"farm-links": "farm-links";
|
|
9880
9897
|
"directory-rules": "directory-rules";
|
|
9881
9898
|
"categories-local": "categories-local";
|
|
9882
9899
|
"active-identity": "active-identity";
|
|
@@ -9909,6 +9926,7 @@ declare const DoctorRunOutputSchema: z.ZodObject<{
|
|
|
9909
9926
|
"path-resolution": "path-resolution";
|
|
9910
9927
|
"legacy-name": "legacy-name";
|
|
9911
9928
|
"sign-in": "sign-in";
|
|
9929
|
+
"farm-links": "farm-links";
|
|
9912
9930
|
"directory-rules": "directory-rules";
|
|
9913
9931
|
"categories-local": "categories-local";
|
|
9914
9932
|
"active-identity": "active-identity";
|
|
@@ -16351,6 +16369,7 @@ declare function createControlApiRouter(deps: ControlApiDeps): {
|
|
|
16351
16369
|
RECONCILE_SECRET_BLOCKED: "RECONCILE_SECRET_BLOCKED";
|
|
16352
16370
|
FARM_SWAP_RECOVERED: "FARM_SWAP_RECOVERED";
|
|
16353
16371
|
FARM_PREVIOUS_RETAINED: "FARM_PREVIOUS_RETAINED";
|
|
16372
|
+
SHARED_ENTRY_DANGLING: "SHARED_ENTRY_DANGLING";
|
|
16354
16373
|
}>;
|
|
16355
16374
|
severity: z.ZodEnum<{
|
|
16356
16375
|
error: "error";
|
|
@@ -16552,6 +16571,7 @@ declare function createControlApiRouter(deps: ControlApiDeps): {
|
|
|
16552
16571
|
"path-resolution": "path-resolution";
|
|
16553
16572
|
"legacy-name": "legacy-name";
|
|
16554
16573
|
"sign-in": "sign-in";
|
|
16574
|
+
"farm-links": "farm-links";
|
|
16555
16575
|
"directory-rules": "directory-rules";
|
|
16556
16576
|
"categories-local": "categories-local";
|
|
16557
16577
|
"active-identity": "active-identity";
|
|
@@ -21447,6 +21467,7 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
21447
21467
|
RECONCILE_SECRET_BLOCKED: "RECONCILE_SECRET_BLOCKED";
|
|
21448
21468
|
FARM_SWAP_RECOVERED: "FARM_SWAP_RECOVERED";
|
|
21449
21469
|
FARM_PREVIOUS_RETAINED: "FARM_PREVIOUS_RETAINED";
|
|
21470
|
+
SHARED_ENTRY_DANGLING: "SHARED_ENTRY_DANGLING";
|
|
21450
21471
|
}>;
|
|
21451
21472
|
severity: z.ZodEnum<{
|
|
21452
21473
|
error: "error";
|
|
@@ -21648,6 +21669,7 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
|
|
|
21648
21669
|
"path-resolution": "path-resolution";
|
|
21649
21670
|
"legacy-name": "legacy-name";
|
|
21650
21671
|
"sign-in": "sign-in";
|
|
21672
|
+
"farm-links": "farm-links";
|
|
21651
21673
|
"directory-rules": "directory-rules";
|
|
21652
21674
|
"categories-local": "categories-local";
|
|
21653
21675
|
"active-identity": "active-identity";
|
|
@@ -28189,6 +28211,15 @@ interface DisplacedIdentityRecord extends IdentityRecord {
|
|
|
28189
28211
|
readonly directoryPresent: boolean;
|
|
28190
28212
|
}
|
|
28191
28213
|
|
|
28214
|
+
/** One identity's farm as the farm-links section reads it: the links in it that lead nowhere (`danglingFarmLinks`). */
|
|
28215
|
+
interface DoctorFarmLinksInput {
|
|
28216
|
+
/** The identity's name, which the finding is filed under and the remedy names. */
|
|
28217
|
+
readonly name: string;
|
|
28218
|
+
/** Its id, the directory under `identities/` the farm is. */
|
|
28219
|
+
readonly id: string;
|
|
28220
|
+
readonly dangling: readonly DanglingFarmLink[];
|
|
28221
|
+
}
|
|
28222
|
+
|
|
28192
28223
|
/**
|
|
28193
28224
|
* How the allowlist the headroom daemon serves lags the allowlist computed now. The daemon re-reads its allowlist file on every request that follows a change to it, and its supervisor rewrites the file and records the hash in the same tick, so a lag that lasts beyond one tick means the supervisor is not running or cannot write the file. A daemon started by an earlier release reads no file, and is reported as such instead.
|
|
28194
28225
|
*/
|
|
@@ -28273,7 +28304,7 @@ type ProviderAliases = z.infer<typeof ProviderAliasesSchema>;
|
|
|
28273
28304
|
|
|
28274
28305
|
declare const DOCTOR_SEVERITIES: readonly ["pass", "warn", "fail"];
|
|
28275
28306
|
type DoctorSeverity = (typeof DOCTOR_SEVERITIES)[number];
|
|
28276
|
-
declare const DOCTOR_SECTIONS: readonly ["ambient-credential", "binary-discovery", "claude-shim", "path-resolution", "legacy-name", "config-profile", "identity", "sign-in", "pool", "provider", "keychain", "directory-rules", "global-config", "categories-local", "active-identity", "headroom", "frontdoor", "models"];
|
|
28307
|
+
declare const DOCTOR_SECTIONS: readonly ["ambient-credential", "binary-discovery", "claude-shim", "path-resolution", "legacy-name", "config-profile", "identity", "sign-in", "farm-links", "pool", "provider", "keychain", "directory-rules", "global-config", "categories-local", "active-identity", "headroom", "frontdoor", "models"];
|
|
28277
28308
|
type DoctorSection = (typeof DOCTOR_SECTIONS)[number];
|
|
28278
28309
|
/** One line of `agent-shim doctor`'s report. `subject` names the identity/profile/rule the finding is about, when the section has more than one of those. */
|
|
28279
28310
|
interface DoctorFinding {
|
|
@@ -28350,6 +28381,8 @@ interface RunDoctorParams {
|
|
|
28350
28381
|
readonly raw: string | undefined;
|
|
28351
28382
|
};
|
|
28352
28383
|
readonly identities: readonly DoctorIdentityInput[];
|
|
28384
|
+
/** The links in each identity's farm that lead nowhere (`danglingFarmLinks`). Omit to leave the farm-links section out; with it, each such link warns, naming the identity, the entry and what brings the farm up to date. */
|
|
28385
|
+
readonly farmLinks?: readonly DoctorFarmLinksInput[];
|
|
28353
28386
|
/** Each identity's last recorded usage snapshot, by identity name. Omit to skip checking that pools and jobs read only windows their identities receive; an identity missing from it has no readable snapshot, so what it receives is unknown and nothing is reported for it. */
|
|
28354
28387
|
readonly usageSnapshots?: Readonly<Record<string, UsageSnapshot>>;
|
|
28355
28388
|
readonly configProfiles: readonly DoctorConfigProfileInput[];
|
|
@@ -28423,8 +28456,6 @@ interface RunDoctorParams {
|
|
|
28423
28456
|
* Every check aggregates rather than throws: a malformed file becomes one `fail` finding for that file, not an aborted report. This is the one place in the codebase that deliberately breaks the "throw a validation error and let it propagate" convention every other command relies on — `doctor`'s whole purpose is to survive a broken file and keep auditing everything else.
|
|
28424
28457
|
*/
|
|
28425
28458
|
declare function runDoctor(params: RunDoctorParams): DoctorReport;
|
|
28426
|
-
/** Renders a full `DoctorReport` as plain text lines, one section header at a time, in the order `agent-shim doctor` prints them. */
|
|
28427
|
-
declare function formatDoctorReport(report: DoctorReport): string[];
|
|
28428
28459
|
/** What `collectDoctorReport` needs from its caller. */
|
|
28429
28460
|
interface CollectDoctorReportParams {
|
|
28430
28461
|
readonly paths: LayoutPaths;
|
|
@@ -28435,6 +28466,9 @@ interface CollectDoctorReportParams {
|
|
|
28435
28466
|
*/
|
|
28436
28467
|
declare function collectDoctorReport(params: CollectDoctorReportParams): DoctorReport;
|
|
28437
28468
|
|
|
28469
|
+
/** Renders a full `DoctorReport` as plain text lines, one section header at a time, in the order `agent-shim doctor` prints them. */
|
|
28470
|
+
declare function formatDoctorReport(report: DoctorReport): string[];
|
|
28471
|
+
|
|
28438
28472
|
/** Inputs to `spawnClaude`. */
|
|
28439
28473
|
interface SpawnClaudeParams {
|
|
28440
28474
|
/** Full path to the real `claude` binary to run, as discovered by `src/versionDiscovery.ts`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-shim",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.4.0",
|
|
4
4
|
"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.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Joseph Mearman <joseph@mearman.co.uk>",
|