agent-shim 14.3.0 → 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/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,
@@ -7581,13 +7624,14 @@ async function teleportRcSession(deps, sessionId, marker) {
7581
7624
  function buildRcMarkReadBody(eventId) {
7582
7625
  return eventId === void 0 ? {} : { event_id: eventId };
7583
7626
  }
7584
- var RC_PERMISSION_MODES, RC_CONTEXT_USAGE_DETAILS, RC_READ_FILE_ENCODINGS;
7627
+ var RC_SEND_DELIVERY_NOTE, RC_PERMISSION_MODES, RC_CONTEXT_USAGE_DETAILS, RC_READ_FILE_ENCODINGS;
7585
7628
  var init_rcWrites = __esm({
7586
7629
  "src/frontdoor/rcWrites.ts"() {
7587
7630
  "use strict";
7588
7631
  init_http();
7589
7632
  init_rcSessions();
7590
7633
  init_rcQuestions();
7634
+ RC_SEND_DELIVERY_NOTE = "Claude Code reads it as a message from another session, not as a person typing in an attached client, because the service stamps it with the session's own client platform. Whether it reaches the model is the receiving session's crossSessionInbound setting: with none set, a session that bypasses permission prompts holds it for approval, since the write cannot attest a permission mode.";
7591
7635
  RC_PERMISSION_MODES = ["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk", "auto"];
7592
7636
  RC_CONTEXT_USAGE_DETAILS = ["summary", "full"];
7593
7637
  RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
@@ -11045,15 +11089,15 @@ function pathDirectories(target, ports) {
11045
11089
  }
11046
11090
  return directories;
11047
11091
  }
11048
- function headroomDirectoryRefusal(directory, stat, uid, remedy) {
11092
+ function headroomDirectoryRefusal(directory, stat, uid, remedy2) {
11049
11093
  if (stat?.kind !== "dir") {
11050
11094
  return `the directory ${directory} on the allowlist file's path is ${stat === void 0 ? "missing" : "not a directory"}, so headroom refuses the file`;
11051
11095
  }
11052
11096
  if (stat.uid !== uid && stat.uid !== ROOT_UID) {
11053
- 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${remedy ? `; ${MOVE_ROOT_REMEDY}` : ""}`;
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}` : ""}`;
11054
11098
  }
11055
11099
  if ((stat.mode & GROUP_OR_OTHER_WRITE_BITS) !== 0) {
11056
- 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${remedy ? `; ${stat.uid === uid && (stat.mode & STICKY_BIT) === 0 ? `run \`chmod go-w ${directory}\`` : MOVE_ROOT_REMEDY}` : ""}`;
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}` : ""}`;
11057
11101
  }
11058
11102
  return void 0;
11059
11103
  }
@@ -11961,6 +12005,9 @@ var init_realPorts = __esm({
11961
12005
  const kind = stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "dir" : "file";
11962
12006
  return { kind, mtimeMs: stat.mtimeMs, sizeBytes: stat.size };
11963
12007
  },
12008
+ resolves(filePath) {
12009
+ return fs6.statSync(filePath, { throwIfNoEntry: false }) !== void 0;
12010
+ },
11964
12011
  readdir(dirPath) {
11965
12012
  try {
11966
12013
  return fs6.readdirSync(dirPath);
@@ -14022,8 +14069,8 @@ var init_identityStore = __esm({
14022
14069
  init_identityRecords();
14023
14070
  init_launchRecords();
14024
14071
  IdentityNotFoundError = class extends CliError {
14025
- constructor(name, remedy = `Run \`agent-shim identity add ${name}\` first.`) {
14026
- super(`No identity named "${name}". ${remedy}`);
14072
+ constructor(name, remedy2 = `Run \`agent-shim identity add ${name}\` first.`) {
14073
+ super(`No identity named "${name}". ${remedy2}`);
14027
14074
  this.name = name;
14028
14075
  this.name = "IdentityNotFoundError";
14029
14076
  }
@@ -14081,7 +14128,7 @@ var init_package = __esm({
14081
14128
  "package.json"() {
14082
14129
  package_default = {
14083
14130
  name: "agent-shim",
14084
- version: "14.3.0",
14131
+ version: "14.4.0",
14085
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.",
14086
14133
  license: "MIT",
14087
14134
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -19948,7 +19995,7 @@ function createRcApiRouter(deps) {
19948
19995
  const dropped = statuses.flatMap((status) => status.pendingDropped === void 0 ? [] : [{ sessionId: status.id, count: status.pendingDropped }]);
19949
19996
  return { pending, ...dropped.length === 0 ? {} : { dropped } };
19950
19997
  }),
19951
- send: authed.meta(openapi({ method: "POST", path: "/rest/rc/send", summary: "Send one message into a session", tags: [RC_API_TAG] })).input(RcSendInputSchema).output(RcWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, sequenceNums: delivered(input.session, await deps.inject(input.session, input.text)) })),
19998
+ send: authed.meta(openapi({ method: "POST", path: "/rest/rc/send", summary: "Send one message into a session", description: RC_SEND_DELIVERY_NOTE, tags: [RC_API_TAG] })).input(RcSendInputSchema).output(RcWriteOutputSchema).handler(async ({ input }) => ({ session: input.session, sequenceNums: delivered(input.session, await deps.inject(input.session, input.text)) })),
19952
19999
  answer: authed.meta(openapi({ method: "POST", path: "/rest/rc/answer", summary: "Answer one pending control request: approve or deny it, or choose the options of a pending question", tags: [RC_API_TAG] })).input(RcAnswerInputSchema).output(RcAnswerOutputSchema).handler(async ({ input }) => {
19953
20000
  const decision = { approve: input.approve, message: input.approve || input.text === void 0 ? void 0 : input.text, ...input.choices === void 0 ? {} : { choices: input.choices } };
19954
20001
  return { session: input.session, request: input.request, sequenceNums: delivered(input.session, await deps.answer(input.session, input.request, decision)) };
@@ -20400,7 +20447,9 @@ var DIAGNOSTIC_CODES = [
20400
20447
  /** A previous launch was interrupted mid-swap and this launch completed or undid the half-finished work. */
20401
20448
  "FARM_SWAP_RECOVERED",
20402
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. */
20403
- "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"
20404
20453
  ];
20405
20454
  var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
20406
20455
 
@@ -21268,6 +21317,31 @@ function pushKeychainFindings(push, platform, run, identities, agentOf) {
21268
21317
  }
21269
21318
  }
21270
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
+
21271
21345
  // src/frontdoor/catalogueFailures.ts
21272
21346
  init_state();
21273
21347
  init_catalogueState();
@@ -21677,6 +21751,7 @@ var DOCTOR_SECTIONS = [
21677
21751
  "config-profile",
21678
21752
  "identity",
21679
21753
  "sign-in",
21754
+ "farm-links",
21680
21755
  "pool",
21681
21756
  "provider",
21682
21757
  "keychain",
@@ -22075,6 +22150,9 @@ function runDoctor(params) {
22075
22150
  push("provider", finding.level, finding.message, finding.alias);
22076
22151
  }
22077
22152
  pushKeychainFindings(push, params.platform, params.run, params.identities, validIdentityAgents);
22153
+ if (params.farmLinks !== void 0) {
22154
+ pushFarmLinkFindings(push, params.farmLinks, validIdentityAgents);
22155
+ }
22078
22156
  if (params.directoryRules.raw === void 0) {
22079
22157
  push("directory-rules", "pass", "No directory-rules.json configured.");
22080
22158
  } else {
@@ -22224,73 +22302,6 @@ function runDoctor(params) {
22224
22302
  }
22225
22303
  return { findings, ok: !findings.some((finding) => finding.severity === "fail") };
22226
22304
  }
22227
- var SECTION_TITLES = {
22228
- models: "Virtual models",
22229
- "ambient-credential": "Ambient-credential exposure",
22230
- "binary-discovery": "Claude Code binary discovery",
22231
- "claude-shim": "`claude` command shim",
22232
- "path-resolution": "PATH resolution",
22233
- "legacy-name": "Former `claude-use` name",
22234
- "config-profile": "Configuration profiles",
22235
- identity: "Identities",
22236
- "sign-in": "Sign-in",
22237
- pool: "Pools",
22238
- provider: "Providers",
22239
- keychain: "macOS Keychain",
22240
- "directory-rules": "Directory rules",
22241
- "global-config": "Global config",
22242
- headroom: "Headroom daemon",
22243
- frontdoor: "Front door",
22244
- "categories-local": "categories.local.json",
22245
- "active-identity": "Active identity"
22246
- };
22247
- var SECTION_ORDER = [
22248
- "ambient-credential",
22249
- "binary-discovery",
22250
- "claude-shim",
22251
- "path-resolution",
22252
- "config-profile",
22253
- "identity",
22254
- "sign-in",
22255
- "pool",
22256
- "provider",
22257
- "keychain",
22258
- "directory-rules",
22259
- "global-config",
22260
- "headroom",
22261
- "frontdoor",
22262
- "categories-local",
22263
- "active-identity"
22264
- ];
22265
- function severityPrefix(severity) {
22266
- switch (severity) {
22267
- case "pass":
22268
- return "[PASS]";
22269
- case "warn":
22270
- return "[WARN]";
22271
- case "fail":
22272
- return "[FAIL]";
22273
- default:
22274
- return severity;
22275
- }
22276
- }
22277
- function formatDoctorReport(report) {
22278
- const lines = [];
22279
- for (const section of SECTION_ORDER) {
22280
- const sectionFindings = report.findings.filter((finding) => finding.section === section);
22281
- if (sectionFindings.length === 0) {
22282
- continue;
22283
- }
22284
- lines.push("", `${SECTION_TITLES[section]}:`);
22285
- for (const finding of sectionFindings) {
22286
- const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
22287
- lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
22288
- }
22289
- }
22290
- const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
22291
- lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
22292
- return lines;
22293
- }
22294
22305
  function servingDoorListeners(paths) {
22295
22306
  const state = readFrontDoorState(realFarmFs, paths.frontdoorStateFile) ?? {};
22296
22307
  const alive = state.supervisorPid !== void 0 && realIsProcessRunning(state.supervisorPid);
@@ -22363,6 +22374,7 @@ function collectDoctorReport(params) {
22363
22374
  chatgptSignIn: { path: paths.chatgptSignInFile, raw: realFsPort.readFileUtf8(paths.chatgptSignInFile) },
22364
22375
  installedClaudeVersions: realInstalledClaudeVersions(),
22365
22376
  identities,
22377
+ farmLinks: identities.map(({ name, id, farmRoot }) => ({ name, id, dangling: danglingFarmLinks(realFarmFs, farmRoot) })),
22366
22378
  usageSnapshots,
22367
22379
  configProfiles,
22368
22380
  providers,
@@ -26389,6 +26401,81 @@ init_names();
26389
26401
  init_providersStore();
26390
26402
  init_poolStore();
26391
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
26392
26479
  init_launcher();
26393
26480
  init_spawn();
26394
26481
  init_launchWiring();
@@ -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[];
@@ -7526,16 +7541,7 @@ declare function observingRoutedRoute(route: FrontDoorRoute, tracker: RcSessionT
7526
7541
  declare function rcObserverAsPassthrough(observer: RcExchangeObserver): PassthroughObserver;
7527
7542
 
7528
7543
  /**
7529
- * The Remote Control client-half writes: the payload builders, the write engine and one typed operation per control verb the door can send into an observed session, every one an event write to `/v1/code/sessions/{id}/events` over the door's interception-proof dials, authenticated by the observed bearer and protocol headers the tracker (`rcSessions.ts`) holds.
7530
- *
7531
- * Every request-shaped write goes through one envelope builder (`buildRcControlRequestPayload`) so the family cannot drift apart in shape, and one delivery engine (`deliverRcClientPayload`, module-local) so the two credential guards, the dial and the sequence-cursor advance exist exactly once. The fields each subtype carries are the SDK's own (`@anthropic-ai/claude-agent-sdk` `sdk.d.ts`) where it declares the subtype, and the CLI bundle's own request builders where it does not (`mcp_authenticate`, `mcp_oauth_callback_url`), each named in its builder's doc comment.
7532
- *
7533
- * A write that carried a `control_request` returns the request id it minted, because the worker's `control_response` echoes exactly that id on the stream the door already fans out: a consumer that wants the answer matches it there, and the id is surfaced by the result since only the door ever knew it.
7534
- *
7535
- * Two writes stand outside the events path: the teleport marker, whose channel is the session's teleport-events path (the one write the family addresses elsewhere, and the one the CLI only ever reads), and the read receipt, which is not a payload write at all but the mark_read endpoint's own small body, built here so every surface the door serves it from posts the same shape.
7536
- */
7537
- /**
7538
- * Builds the user-message payload event for one injected prompt: the Agent SDK stream-json `user` message shape (`type`, `uuid`, `session_id`, `parent_tool_use_id`, `message` with a `user` role), the same envelope a claude.ai client sends as a turn. The content is the plain string form, which is the shape validated end to end against the real API by the third-party client survey that settled this protocol.
7544
+ * Builds the user-message payload event for one injected prompt: the Agent SDK stream-json `user` message shape (`type`, `uuid`, `session_id`, `parent_tool_use_id`, `message` with a `user` role), the envelope a claude.ai client sends as a turn. The envelope alone does not decide how the worker reads it: the service adds the writer's `client_platform`, and that is what makes a client's turn a person's and the door's a peer's (`RC_SEND_DELIVERY_NOTE`). The content is the plain string form, which is the shape validated end to end against the real API by the third-party client survey that settled this protocol.
7539
7545
  */
7540
7546
  declare function buildRcUserMessagePayload(uuid: string, sessionId: string, text: string): Record<string, unknown>;
7541
7547
  /** Wraps payload event(s) in the write body the endpoint takes: `{"events": [{"payload": {...}}]}`. */
@@ -7586,7 +7592,7 @@ interface RcInjectDeps {
7586
7592
  readonly newUuid: () => string;
7587
7593
  }
7588
7594
  /**
7589
- * Injects one user-message prompt into an observed session: the documented client-half write, `POST /v1/code/sessions/{id}/events`, authenticated by the observed bearer and carrying the observed protocol headers, the observed `anthropic-client-platform` included, so the door never names an app it is not. The result is the sequence numbers the real service assigned, or a verbose failure. A dial that cannot reach the API host is reported rather than thrown, so a caller with no exception handling still shows the user exactly what failed.
7595
+ * Injects one user-message prompt into an observed session: the documented client-half write, `POST /v1/code/sessions/{id}/events`, authenticated by the observed bearer and carrying the observed protocol headers, the observed `anthropic-client-platform` included, so the door never names an app it is not. The result is the sequence numbers the real service assigned, or a verbose failure: an assigned number confirms the service filed the event, not that the session's model received it, since the worker reads it as a peer message and its own inbound setting decides whether to deliver, hold or drop it (`RC_SEND_DELIVERY_NOTE`). A dial that cannot reach the API host is reported rather than thrown, so a caller with no exception handling still shows the user exactly what failed.
7590
7596
  */
7591
7597
  declare function injectRcUserMessage(deps: RcInjectDeps, sessionId: string, text: string): Promise<RcEventWriteResult>;
7592
7598
  /** The decision an answer carries: approve or deny, with the message a denial shows the worker (the protocol's allow result has no text field, so an approval carries none), and for a question the options chosen. */
@@ -9398,6 +9404,7 @@ declare const CheckReportJsonSchema: z.ZodObject<{
9398
9404
  RECONCILE_SECRET_BLOCKED: "RECONCILE_SECRET_BLOCKED";
9399
9405
  FARM_SWAP_RECOVERED: "FARM_SWAP_RECOVERED";
9400
9406
  FARM_PREVIOUS_RETAINED: "FARM_PREVIOUS_RETAINED";
9407
+ SHARED_ENTRY_DANGLING: "SHARED_ENTRY_DANGLING";
9401
9408
  }>;
9402
9409
  severity: z.ZodEnum<{
9403
9410
  error: "error";
@@ -9886,6 +9893,7 @@ declare const DoctorFindingSchema: z.ZodObject<{
9886
9893
  "path-resolution": "path-resolution";
9887
9894
  "legacy-name": "legacy-name";
9888
9895
  "sign-in": "sign-in";
9896
+ "farm-links": "farm-links";
9889
9897
  "directory-rules": "directory-rules";
9890
9898
  "categories-local": "categories-local";
9891
9899
  "active-identity": "active-identity";
@@ -9918,6 +9926,7 @@ declare const DoctorRunOutputSchema: z.ZodObject<{
9918
9926
  "path-resolution": "path-resolution";
9919
9927
  "legacy-name": "legacy-name";
9920
9928
  "sign-in": "sign-in";
9929
+ "farm-links": "farm-links";
9921
9930
  "directory-rules": "directory-rules";
9922
9931
  "categories-local": "categories-local";
9923
9932
  "active-identity": "active-identity";
@@ -16360,6 +16369,7 @@ declare function createControlApiRouter(deps: ControlApiDeps): {
16360
16369
  RECONCILE_SECRET_BLOCKED: "RECONCILE_SECRET_BLOCKED";
16361
16370
  FARM_SWAP_RECOVERED: "FARM_SWAP_RECOVERED";
16362
16371
  FARM_PREVIOUS_RETAINED: "FARM_PREVIOUS_RETAINED";
16372
+ SHARED_ENTRY_DANGLING: "SHARED_ENTRY_DANGLING";
16363
16373
  }>;
16364
16374
  severity: z.ZodEnum<{
16365
16375
  error: "error";
@@ -16561,6 +16571,7 @@ declare function createControlApiRouter(deps: ControlApiDeps): {
16561
16571
  "path-resolution": "path-resolution";
16562
16572
  "legacy-name": "legacy-name";
16563
16573
  "sign-in": "sign-in";
16574
+ "farm-links": "farm-links";
16564
16575
  "directory-rules": "directory-rules";
16565
16576
  "categories-local": "categories-local";
16566
16577
  "active-identity": "active-identity";
@@ -21456,6 +21467,7 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
21456
21467
  RECONCILE_SECRET_BLOCKED: "RECONCILE_SECRET_BLOCKED";
21457
21468
  FARM_SWAP_RECOVERED: "FARM_SWAP_RECOVERED";
21458
21469
  FARM_PREVIOUS_RETAINED: "FARM_PREVIOUS_RETAINED";
21470
+ SHARED_ENTRY_DANGLING: "SHARED_ENTRY_DANGLING";
21459
21471
  }>;
21460
21472
  severity: z.ZodEnum<{
21461
21473
  error: "error";
@@ -21657,6 +21669,7 @@ declare function createDoorApiRouter(deps: DoorApiDeps): {
21657
21669
  "path-resolution": "path-resolution";
21658
21670
  "legacy-name": "legacy-name";
21659
21671
  "sign-in": "sign-in";
21672
+ "farm-links": "farm-links";
21660
21673
  "directory-rules": "directory-rules";
21661
21674
  "categories-local": "categories-local";
21662
21675
  "active-identity": "active-identity";
@@ -28198,6 +28211,15 @@ interface DisplacedIdentityRecord extends IdentityRecord {
28198
28211
  readonly directoryPresent: boolean;
28199
28212
  }
28200
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
+
28201
28223
  /**
28202
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.
28203
28225
  */
@@ -28282,7 +28304,7 @@ type ProviderAliases = z.infer<typeof ProviderAliasesSchema>;
28282
28304
 
28283
28305
  declare const DOCTOR_SEVERITIES: readonly ["pass", "warn", "fail"];
28284
28306
  type DoctorSeverity = (typeof DOCTOR_SEVERITIES)[number];
28285
- 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"];
28286
28308
  type DoctorSection = (typeof DOCTOR_SECTIONS)[number];
28287
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. */
28288
28310
  interface DoctorFinding {
@@ -28359,6 +28381,8 @@ interface RunDoctorParams {
28359
28381
  readonly raw: string | undefined;
28360
28382
  };
28361
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[];
28362
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. */
28363
28387
  readonly usageSnapshots?: Readonly<Record<string, UsageSnapshot>>;
28364
28388
  readonly configProfiles: readonly DoctorConfigProfileInput[];
@@ -28432,8 +28456,6 @@ interface RunDoctorParams {
28432
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.
28433
28457
  */
28434
28458
  declare function runDoctor(params: RunDoctorParams): DoctorReport;
28435
- /** Renders a full `DoctorReport` as plain text lines, one section header at a time, in the order `agent-shim doctor` prints them. */
28436
- declare function formatDoctorReport(report: DoctorReport): string[];
28437
28459
  /** What `collectDoctorReport` needs from its caller. */
28438
28460
  interface CollectDoctorReportParams {
28439
28461
  readonly paths: LayoutPaths;
@@ -28444,6 +28466,9 @@ interface CollectDoctorReportParams {
28444
28466
  */
28445
28467
  declare function collectDoctorReport(params: CollectDoctorReportParams): DoctorReport;
28446
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
+
28447
28472
  /** Inputs to `spawnClaude`. */
28448
28473
  interface SpawnClaudeParams {
28449
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.0",
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>",