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.cjs CHANGED
@@ -2663,6 +2663,7 @@ function planFarm(params) {
2663
2663
  const entries = [];
2664
2664
  const materialised = [];
2665
2665
  const links = [];
2666
+ const dangling = [];
2666
2667
  const conditionalPatterns = [...params.flattened.rules.values()].filter((rule) => rule.when !== void 0).map((rule) => rule.canonicalPattern);
2667
2668
  const conditionalRuleCouldReach = (dir) => conditionalPatterns.some((pattern) => patternCouldReachUnder(pattern, dir));
2668
2669
  const subtreeDecision = (rel) => {
@@ -2695,7 +2696,10 @@ function planFarm(params) {
2695
2696
  return;
2696
2697
  }
2697
2698
  if (!fact.isDirectory) {
2698
- if (decision?.shared === true) {
2699
+ if (decision?.shared === true && fact.isDanglingSymlink) {
2700
+ entries.push({ kind: "omit", rel });
2701
+ dangling.push(rel);
2702
+ } else if (decision?.shared === true) {
2699
2703
  entries.push({ kind: "link", rel, target: linkTarget(rel) });
2700
2704
  links.push({ rel, target: linkTarget(rel) });
2701
2705
  } else {
@@ -2730,7 +2734,7 @@ function planFarm(params) {
2730
2734
  for (const rel of children.get("") ?? []) {
2731
2735
  visit(rel);
2732
2736
  }
2733
- return { entries, materialised, links };
2737
+ return { entries, materialised, links, dangling };
2734
2738
  }
2735
2739
  var import_node_path5;
2736
2740
  var init_plan = __esm({
@@ -2975,6 +2979,14 @@ function topLevelNames(facts) {
2975
2979
  function descendPolicyFor(cascade, home) {
2976
2980
  return descendPolicy(flattenLayers(assembleCascade(cascade).layers, { home }).rules.values());
2977
2981
  }
2982
+ function danglingDiagnostic(rel) {
2983
+ return {
2984
+ code: "SHARED_ENTRY_DANGLING",
2985
+ severity: "warning",
2986
+ 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.`,
2987
+ subject: rel
2988
+ };
2989
+ }
2978
2990
  function resolveDecisions(input) {
2979
2991
  const assembled = assembleCascade(input.cascade);
2980
2992
  const flattened = flattenLayers(assembled.layers, { home: input.facts.home });
@@ -2994,7 +3006,7 @@ function resolveDecisions(input) {
2994
3006
  classification,
2995
3007
  decisions: resolved.decisions,
2996
3008
  farm,
2997
- diagnostics: [...assembled.diagnostics, ...resolved.diagnostics]
3009
+ diagnostics: [...assembled.diagnostics, ...resolved.diagnostics, ...farm.dangling.map(danglingDiagnostic)]
2998
3010
  };
2999
3011
  }
3000
3012
  var init_pipeline = __esm({
@@ -3441,6 +3453,34 @@ function readFarmManifest(fs17, farmRoot) {
3441
3453
  const result = FarmManifestSchema.safeParse(parsed);
3442
3454
  return result.success ? result.data : void 0;
3443
3455
  }
3456
+ function danglingFarmLinks(fs17, farmRoot) {
3457
+ const manifest = readFarmManifest(fs17, farmRoot);
3458
+ const recorded = new Map((manifest?.links ?? []).map((link) => [link.rel, link.target]));
3459
+ const materialised = new Set(manifest?.materialised ?? []);
3460
+ const candidates = new Set(recorded.keys());
3461
+ const walk2 = (rel) => {
3462
+ const stat = fs17.lstat(import_node_path10.default.join(farmRoot, rel));
3463
+ if (stat?.kind === "symlink") {
3464
+ candidates.add(rel);
3465
+ } else if (stat?.kind === "dir" && materialised.has(rel)) {
3466
+ for (const name of fs17.readdir(import_node_path10.default.join(farmRoot, rel))) {
3467
+ walk2(`${rel}/${name}`);
3468
+ }
3469
+ }
3470
+ };
3471
+ for (const name of fs17.readdir(farmRoot)) {
3472
+ if (name !== FARM_MANIFEST_FILENAME && name !== LEGACY_FARM_MANIFEST_FILENAME) {
3473
+ walk2(name);
3474
+ }
3475
+ }
3476
+ return [...candidates].sort().filter((rel) => {
3477
+ const absolute = import_node_path10.default.join(farmRoot, rel);
3478
+ return fs17.lstat(absolute)?.kind === "symlink" && !fs17.resolves(absolute);
3479
+ }).map((rel) => {
3480
+ const target = recorded.get(rel);
3481
+ return target === void 0 ? { rel } : { rel, target };
3482
+ });
3483
+ }
3444
3484
  function buildEntryFacts(params) {
3445
3485
  const entries = /* @__PURE__ */ new Map();
3446
3486
  const visit = (rel) => {
@@ -3465,6 +3505,7 @@ function buildEntryFacts(params) {
3465
3505
  relPath: rel,
3466
3506
  isDirectory,
3467
3507
  isSymlink: stat.kind === "symlink",
3508
+ isDanglingSymlink: stat.kind === "symlink" && !params.fs.resolves(absolute),
3468
3509
  mtimeMs: stat.mtimeMs,
3469
3510
  latestMtimeMs,
3470
3511
  sizeBytes: stat.sizeBytes,
@@ -3827,6 +3868,7 @@ function resyncFarm(params) {
3827
3868
  farmRoot,
3828
3869
  noOp: true,
3829
3870
  manifest: previousManifest,
3871
+ previousManifest,
3830
3872
  resolved,
3831
3873
  adopted: outcome.adopted,
3832
3874
  recovery,
@@ -3849,6 +3891,7 @@ function resyncFarm(params) {
3849
3891
  farmRoot,
3850
3892
  noOp: false,
3851
3893
  manifest,
3894
+ ...previousManifest === void 0 ? {} : { previousManifest },
3852
3895
  resolved,
3853
3896
  adopted: outcome.adopted,
3854
3897
  recovery,
@@ -7606,13 +7649,14 @@ async function teleportRcSession(deps, sessionId, marker) {
7606
7649
  function buildRcMarkReadBody(eventId) {
7607
7650
  return eventId === void 0 ? {} : { event_id: eventId };
7608
7651
  }
7609
- var RC_PERMISSION_MODES, RC_CONTEXT_USAGE_DETAILS, RC_READ_FILE_ENCODINGS;
7652
+ var RC_SEND_DELIVERY_NOTE, RC_PERMISSION_MODES, RC_CONTEXT_USAGE_DETAILS, RC_READ_FILE_ENCODINGS;
7610
7653
  var init_rcWrites = __esm({
7611
7654
  "src/frontdoor/rcWrites.ts"() {
7612
7655
  "use strict";
7613
7656
  init_http();
7614
7657
  init_rcSessions();
7615
7658
  init_rcQuestions();
7659
+ 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.";
7616
7660
  RC_PERMISSION_MODES = ["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk", "auto"];
7617
7661
  RC_CONTEXT_USAGE_DETAILS = ["summary", "full"];
7618
7662
  RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
@@ -11071,15 +11115,15 @@ function pathDirectories(target, ports) {
11071
11115
  }
11072
11116
  return directories;
11073
11117
  }
11074
- function headroomDirectoryRefusal(directory, stat, uid, remedy) {
11118
+ function headroomDirectoryRefusal(directory, stat, uid, remedy2) {
11075
11119
  if (stat?.kind !== "dir") {
11076
11120
  return `the directory ${directory} on the allowlist file's path is ${stat === void 0 ? "missing" : "not a directory"}, so headroom refuses the file`;
11077
11121
  }
11078
11122
  if (stat.uid !== uid && stat.uid !== ROOT_UID) {
11079
- 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}` : ""}`;
11123
+ 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}` : ""}`;
11080
11124
  }
11081
11125
  if ((stat.mode & GROUP_OR_OTHER_WRITE_BITS) !== 0) {
11082
- 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}` : ""}`;
11126
+ 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}` : ""}`;
11083
11127
  }
11084
11128
  return void 0;
11085
11129
  }
@@ -11988,6 +12032,9 @@ var init_realPorts = __esm({
11988
12032
  const kind = stat.isSymbolicLink() ? "symlink" : stat.isDirectory() ? "dir" : "file";
11989
12033
  return { kind, mtimeMs: stat.mtimeMs, sizeBytes: stat.size };
11990
12034
  },
12035
+ resolves(filePath) {
12036
+ return import_node_fs6.default.statSync(filePath, { throwIfNoEntry: false }) !== void 0;
12037
+ },
11991
12038
  readdir(dirPath) {
11992
12039
  try {
11993
12040
  return import_node_fs6.default.readdirSync(dirPath);
@@ -14049,8 +14096,8 @@ var init_identityStore = __esm({
14049
14096
  init_identityRecords();
14050
14097
  init_launchRecords();
14051
14098
  IdentityNotFoundError = class extends CliError {
14052
- constructor(name, remedy = `Run \`agent-shim identity add ${name}\` first.`) {
14053
- super(`No identity named "${name}". ${remedy}`);
14099
+ constructor(name, remedy2 = `Run \`agent-shim identity add ${name}\` first.`) {
14100
+ super(`No identity named "${name}". ${remedy2}`);
14054
14101
  this.name = name;
14055
14102
  this.name = "IdentityNotFoundError";
14056
14103
  }
@@ -14108,7 +14155,7 @@ var init_package = __esm({
14108
14155
  "package.json"() {
14109
14156
  package_default = {
14110
14157
  name: "claude-use",
14111
- version: "14.3.0",
14158
+ version: "14.4.0",
14112
14159
  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.",
14113
14160
  license: "MIT",
14114
14161
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -20399,7 +20446,7 @@ function createRcApiRouter(deps) {
20399
20446
  const dropped = statuses.flatMap((status) => status.pendingDropped === void 0 ? [] : [{ sessionId: status.id, count: status.pendingDropped }]);
20400
20447
  return { pending, ...dropped.length === 0 ? {} : { dropped } };
20401
20448
  }),
20402
- send: authed.meta((0, import_openapi.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)) })),
20449
+ send: authed.meta((0, import_openapi.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)) })),
20403
20450
  answer: authed.meta((0, import_openapi.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 }) => {
20404
20451
  const decision = { approve: input.approve, message: input.approve || input.text === void 0 ? void 0 : input.text, ...input.choices === void 0 ? {} : { choices: input.choices } };
20405
20452
  return { session: input.session, request: input.request, sequenceNums: delivered(input.session, await deps.answer(input.session, input.request, decision)) };
@@ -20851,7 +20898,9 @@ var DIAGNOSTIC_CODES = [
20851
20898
  /** A previous launch was interrupted mid-swap and this launch completed or undid the half-finished work. */
20852
20899
  "FARM_SWAP_RECOVERED",
20853
20900
  /** 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. */
20854
- "FARM_PREVIOUS_RETAINED"
20901
+ "FARM_PREVIOUS_RETAINED",
20902
+ /** 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. */
20903
+ "SHARED_ENTRY_DANGLING"
20855
20904
  ];
20856
20905
  var DIAGNOSTIC_SEVERITIES = ["error", "warning", "info"];
20857
20906
 
@@ -21719,6 +21768,31 @@ function pushKeychainFindings(push, platform, run, identities, agentOf) {
21719
21768
  }
21720
21769
  }
21721
21770
 
21771
+ // src/doctorFarmLinks.ts
21772
+ function remedy(agent, name, rel) {
21773
+ if (agent === "codex") {
21774
+ return `Codex cannot write through it. A launch with \`agent-shim run --agent codex @${name}\` resyncs the farm and leaves the link out.`;
21775
+ }
21776
+ const lost = rel === "sessions" ? " (an interactive session's record under sessions/ is lost, so the session is missing from `claude agents`)" : "";
21777
+ 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.`;
21778
+ }
21779
+ function pushFarmLinkFindings(push, farms, agentOf) {
21780
+ let found = false;
21781
+ for (const farm of farms) {
21782
+ for (const link of farm.dangling) {
21783
+ found = true;
21784
+ const points = link.target === void 0 ? "" : ` to ${link.target}`;
21785
+ 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);
21786
+ }
21787
+ }
21788
+ if (!found) {
21789
+ push("farm-links", "pass", "Every identity's farm links lead somewhere.");
21790
+ }
21791
+ }
21792
+
21793
+ // src/doctorReport.ts
21794
+ init_farm();
21795
+
21722
21796
  // src/frontdoor/catalogueFailures.ts
21723
21797
  init_state();
21724
21798
  init_catalogueState();
@@ -22128,6 +22202,7 @@ var DOCTOR_SECTIONS = [
22128
22202
  "config-profile",
22129
22203
  "identity",
22130
22204
  "sign-in",
22205
+ "farm-links",
22131
22206
  "pool",
22132
22207
  "provider",
22133
22208
  "keychain",
@@ -22526,6 +22601,9 @@ function runDoctor(params) {
22526
22601
  push("provider", finding.level, finding.message, finding.alias);
22527
22602
  }
22528
22603
  pushKeychainFindings(push, params.platform, params.run, params.identities, validIdentityAgents);
22604
+ if (params.farmLinks !== void 0) {
22605
+ pushFarmLinkFindings(push, params.farmLinks, validIdentityAgents);
22606
+ }
22529
22607
  if (params.directoryRules.raw === void 0) {
22530
22608
  push("directory-rules", "pass", "No directory-rules.json configured.");
22531
22609
  } else {
@@ -22675,73 +22753,6 @@ function runDoctor(params) {
22675
22753
  }
22676
22754
  return { findings, ok: !findings.some((finding) => finding.severity === "fail") };
22677
22755
  }
22678
- var SECTION_TITLES = {
22679
- models: "Virtual models",
22680
- "ambient-credential": "Ambient-credential exposure",
22681
- "binary-discovery": "Claude Code binary discovery",
22682
- "claude-shim": "`claude` command shim",
22683
- "path-resolution": "PATH resolution",
22684
- "legacy-name": "Former `claude-use` name",
22685
- "config-profile": "Configuration profiles",
22686
- identity: "Identities",
22687
- "sign-in": "Sign-in",
22688
- pool: "Pools",
22689
- provider: "Providers",
22690
- keychain: "macOS Keychain",
22691
- "directory-rules": "Directory rules",
22692
- "global-config": "Global config",
22693
- headroom: "Headroom daemon",
22694
- frontdoor: "Front door",
22695
- "categories-local": "categories.local.json",
22696
- "active-identity": "Active identity"
22697
- };
22698
- var SECTION_ORDER = [
22699
- "ambient-credential",
22700
- "binary-discovery",
22701
- "claude-shim",
22702
- "path-resolution",
22703
- "config-profile",
22704
- "identity",
22705
- "sign-in",
22706
- "pool",
22707
- "provider",
22708
- "keychain",
22709
- "directory-rules",
22710
- "global-config",
22711
- "headroom",
22712
- "frontdoor",
22713
- "categories-local",
22714
- "active-identity"
22715
- ];
22716
- function severityPrefix(severity) {
22717
- switch (severity) {
22718
- case "pass":
22719
- return "[PASS]";
22720
- case "warn":
22721
- return "[WARN]";
22722
- case "fail":
22723
- return "[FAIL]";
22724
- default:
22725
- return severity;
22726
- }
22727
- }
22728
- function formatDoctorReport(report) {
22729
- const lines = [];
22730
- for (const section of SECTION_ORDER) {
22731
- const sectionFindings = report.findings.filter((finding) => finding.section === section);
22732
- if (sectionFindings.length === 0) {
22733
- continue;
22734
- }
22735
- lines.push("", `${SECTION_TITLES[section]}:`);
22736
- for (const finding of sectionFindings) {
22737
- const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
22738
- lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
22739
- }
22740
- }
22741
- const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
22742
- lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
22743
- return lines;
22744
- }
22745
22756
  function servingDoorListeners(paths) {
22746
22757
  const state = readFrontDoorState(realFarmFs, paths.frontdoorStateFile) ?? {};
22747
22758
  const alive = state.supervisorPid !== void 0 && realIsProcessRunning(state.supervisorPid);
@@ -22814,6 +22825,7 @@ function collectDoctorReport(params) {
22814
22825
  chatgptSignIn: { path: paths.chatgptSignInFile, raw: realFsPort.readFileUtf8(paths.chatgptSignInFile) },
22815
22826
  installedClaudeVersions: realInstalledClaudeVersions(),
22816
22827
  identities,
22828
+ farmLinks: identities.map(({ name, id, farmRoot }) => ({ name, id, dangling: danglingFarmLinks(realFarmFs, farmRoot) })),
22817
22829
  usageSnapshots,
22818
22830
  configProfiles,
22819
22831
  providers,
@@ -26840,6 +26852,81 @@ init_names();
26840
26852
  init_providersStore();
26841
26853
  init_poolStore();
26842
26854
  init_directoryRulesStore();
26855
+
26856
+ // src/doctorFormat.ts
26857
+ var SECTION_TITLES = {
26858
+ models: "Virtual models",
26859
+ "ambient-credential": "Ambient-credential exposure",
26860
+ "binary-discovery": "Claude Code binary discovery",
26861
+ "claude-shim": "`claude` command shim",
26862
+ "path-resolution": "PATH resolution",
26863
+ "legacy-name": "Former `claude-use` name",
26864
+ "config-profile": "Configuration profiles",
26865
+ identity: "Identities",
26866
+ "sign-in": "Sign-in",
26867
+ "farm-links": "Farm links",
26868
+ pool: "Pools",
26869
+ provider: "Providers",
26870
+ keychain: "macOS Keychain",
26871
+ "directory-rules": "Directory rules",
26872
+ "global-config": "Global config",
26873
+ headroom: "Headroom daemon",
26874
+ frontdoor: "Front door",
26875
+ "categories-local": "categories.local.json",
26876
+ "active-identity": "Active identity"
26877
+ };
26878
+ var SECTION_ORDER = [
26879
+ "ambient-credential",
26880
+ "binary-discovery",
26881
+ "claude-shim",
26882
+ "path-resolution",
26883
+ "legacy-name",
26884
+ "config-profile",
26885
+ "identity",
26886
+ "sign-in",
26887
+ "farm-links",
26888
+ "pool",
26889
+ "provider",
26890
+ "keychain",
26891
+ "directory-rules",
26892
+ "global-config",
26893
+ "models",
26894
+ "headroom",
26895
+ "frontdoor",
26896
+ "categories-local",
26897
+ "active-identity"
26898
+ ];
26899
+ function severityPrefix(severity) {
26900
+ switch (severity) {
26901
+ case "pass":
26902
+ return "[PASS]";
26903
+ case "warn":
26904
+ return "[WARN]";
26905
+ case "fail":
26906
+ return "[FAIL]";
26907
+ default:
26908
+ return severity;
26909
+ }
26910
+ }
26911
+ function formatDoctorReport(report) {
26912
+ const lines = [];
26913
+ for (const section of SECTION_ORDER) {
26914
+ const sectionFindings = report.findings.filter((finding) => finding.section === section);
26915
+ if (sectionFindings.length === 0) {
26916
+ continue;
26917
+ }
26918
+ lines.push("", `${SECTION_TITLES[section]}:`);
26919
+ for (const finding of sectionFindings) {
26920
+ const subject = finding.subject === void 0 ? "" : `${finding.subject}: `;
26921
+ lines.push(` ${severityPrefix(finding.severity)} ${subject}${finding.message}`);
26922
+ }
26923
+ }
26924
+ const failCount = report.findings.filter((finding) => finding.severity === "fail").length;
26925
+ lines.push("", report.ok ? "All checks passed." : `${String(failCount)} check(s) failed.`);
26926
+ return lines;
26927
+ }
26928
+
26929
+ // src/index.ts
26843
26930
  init_launcher();
26844
26931
  init_spawn();
26845
26932
  init_launchWiring();