claude-use 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: "claude-use",
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();