agent-shim 8.5.1 → 8.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -55107,18 +55107,14 @@ function discoverClaudeBinary(options) {
55107
55107
  version: highestVersion
55108
55108
  };
55109
55109
  }
55110
- const ownInstallDirs = new Set(options.ownInstallDirs.map((dir) => import_node_path3.default.resolve(dir)));
55111
55110
  for (const dir of options.pathDirs) {
55112
- if (ownInstallDirs.has(import_node_path3.default.resolve(dir))) {
55113
- continue;
55114
- }
55115
55111
  const found = options.findExecutableInDir(dir, "claude");
55116
- if (found !== void 0) {
55112
+ if (found !== void 0 && !options.isOwnBinary(found)) {
55117
55113
  return { path: found, source: "path-fallback" };
55118
55114
  }
55119
55115
  }
55120
55116
  throw new Error(
55121
- `Could not find a claude binary. Looked for genuinely-executable versioned binaries under "${versionsDir}" (missing, empty, or containing nothing executable) and for a "claude" executable on PATH (excluding this tool's own install directory). Install Claude Code, or set the versions directory / PATH correctly, then try again.`
55117
+ `Could not find a claude binary. Looked for genuinely-executable versioned binaries under "${versionsDir}" (missing, empty, or containing nothing executable) and for a "claude" executable on PATH (never this tool's own binary). Install Claude Code, or set the versions directory / PATH correctly, then try again.`
55122
55118
  );
55123
55119
  }
55124
55120
 
@@ -55970,12 +55966,12 @@ function resolveContentSourcePath(env) {
55970
55966
  function realContentSourcePath() {
55971
55967
  return resolveContentSourcePath({ isSea: (0, import_node_sea.isSea)(), execPath: process.execPath, argv1: process.argv[1] });
55972
55968
  }
55973
- function realResolveClaudeBinary(ownInstallDirs) {
55969
+ function realResolveClaudeBinary(isOwnBinary) {
55974
55970
  return () => discoverClaudeBinary({
55975
55971
  listVersionsDir,
55976
55972
  pathDirs: (process.env.PATH ?? "").split(import_node_path6.default.delimiter).filter((dir) => dir !== ""),
55977
55973
  findExecutableInDir,
55978
- ownInstallDirs: [...ownInstallDirs]
55974
+ isOwnBinary
55979
55975
  });
55980
55976
  }
55981
55977
 
@@ -56017,13 +56013,19 @@ function commandFilename(ownExecutablePath, commandName) {
56017
56013
  function isInvokedAsClaude(invokedName) {
56018
56014
  return invokedName === "claude" || invokedName.toLowerCase() === "claude.exe";
56019
56015
  }
56020
- function resolveOwnInstallDirs(paths, ownExecutablePath) {
56021
- const dirs = [import_node_path7.default.dirname(ownExecutablePath)];
56016
+ function resolveOwnBinaryCheck(paths, contentSourcePath) {
56022
56017
  const state = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
56023
- if (state !== void 0) {
56024
- dirs.push(import_node_path7.default.dirname(state.targetPath));
56025
- }
56026
- return dirs;
56018
+ const recordedTarget = state === void 0 ? void 0 : import_node_path7.default.resolve(state.targetPath);
56019
+ let ownStat;
56020
+ return (candidate) => {
56021
+ if (recordedTarget !== void 0 && import_node_path7.default.resolve(candidate) === recordedTarget) {
56022
+ return true;
56023
+ }
56024
+ ownStat ??= statOrUndefined(contentSourcePath);
56025
+ const candidateStat = statOrUndefined(candidate);
56026
+ return ownStat !== void 0 && candidateStat !== void 0 && // A platform reporting no inode number for either file must not read every candidate as this tool.
56027
+ ownStat.ino !== 0 && candidateStat.ino !== 0 && candidateStat.dev === ownStat.dev && candidateStat.ino === ownStat.ino;
56028
+ };
56027
56029
  }
56028
56030
  function resolveClaudeTargetPath(ownExecutablePath, dir) {
56029
56031
  return import_node_path7.default.join(dir ?? import_node_path7.default.dirname(ownExecutablePath), claudeTargetFilename(ownExecutablePath));
@@ -56044,6 +56046,16 @@ function lstatOrUndefined(target) {
56044
56046
  throw error62;
56045
56047
  }
56046
56048
  }
56049
+ function statOrUndefined(target) {
56050
+ try {
56051
+ return import_node_fs4.default.statSync(target);
56052
+ } catch (error62) {
56053
+ if (isEnoent3(error62)) {
56054
+ return void 0;
56055
+ }
56056
+ throw error62;
56057
+ }
56058
+ }
56047
56059
  var nodeLinkFs = { link: import_node_fs4.default.linkSync, copyFile: import_node_fs4.default.copyFileSync, chmod: import_node_fs4.default.chmodSync };
56048
56060
  function enableClaudeShim(params, linkFs = nodeLinkFs) {
56049
56061
  const realContentPath = import_node_fs4.default.realpathSync(params.contentSourcePath);
@@ -61040,7 +61052,7 @@ function registerIdentityCommand(program2, deps) {
61040
61052
  // package.json
61041
61053
  var package_default = {
61042
61054
  name: "agent-shim",
61043
- version: "8.5.1",
61055
+ version: "8.5.2",
61044
61056
  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.",
61045
61057
  license: "MIT",
61046
61058
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -69034,7 +69046,7 @@ function collectDoctorReport(params) {
69034
69046
  const ownExecutablePath = realOwnExecutablePath();
69035
69047
  let binaryDiscovery;
69036
69048
  try {
69037
- const binary = realResolveClaudeBinary(resolveOwnInstallDirs(paths, ownExecutablePath))();
69049
+ const binary = realResolveClaudeBinary(resolveOwnBinaryCheck(paths, realContentSourcePath()))();
69038
69050
  binaryDiscovery = { ok: true, binary };
69039
69051
  } catch (error62) {
69040
69052
  binaryDiscovery = { ok: false, message: error62 instanceof Error ? error62.message : String(error62) };
@@ -71114,7 +71126,7 @@ function realPrepareLaunchParams(paths, options) {
71114
71126
  fs: realFsPort,
71115
71127
  proc: options.proc,
71116
71128
  log: options.log,
71117
- resolveClaudeBinary: realResolveClaudeBinary(resolveOwnInstallDirs(paths, realOwnExecutablePath())),
71129
+ resolveClaudeBinary: realResolveClaudeBinary(resolveOwnBinaryCheck(paths, realContentSourcePath())),
71118
71130
  farm: farm.runtime,
71119
71131
  headroom: realHeadroomPort(paths, { spawnDaemon: options.spawnDaemon, cwd: farm.runtime.cwd }),
71120
71132
  frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
package/dist/index.cjs CHANGED
@@ -6987,18 +6987,14 @@ function discoverClaudeBinary(options) {
6987
6987
  version: highestVersion
6988
6988
  };
6989
6989
  }
6990
- const ownInstallDirs = new Set(options.ownInstallDirs.map((dir) => import_node_path20.default.resolve(dir)));
6991
6990
  for (const dir of options.pathDirs) {
6992
- if (ownInstallDirs.has(import_node_path20.default.resolve(dir))) {
6993
- continue;
6994
- }
6995
6991
  const found = options.findExecutableInDir(dir, "claude");
6996
- if (found !== void 0) {
6992
+ if (found !== void 0 && !options.isOwnBinary(found)) {
6997
6993
  return { path: found, source: "path-fallback" };
6998
6994
  }
6999
6995
  }
7000
6996
  throw new Error(
7001
- `Could not find a claude binary. Looked for genuinely-executable versioned binaries under "${versionsDir}" (missing, empty, or containing nothing executable) and for a "claude" executable on PATH (excluding this tool's own install directory). Install Claude Code, or set the versions directory / PATH correctly, then try again.`
6997
+ `Could not find a claude binary. Looked for genuinely-executable versioned binaries under "${versionsDir}" (missing, empty, or containing nothing executable) and for a "claude" executable on PATH (never this tool's own binary). Install Claude Code, or set the versions directory / PATH correctly, then try again.`
7002
6998
  );
7003
6999
  }
7004
7000
 
@@ -7396,12 +7392,18 @@ function realOwnExecutablePath() {
7396
7392
  findExecutableInDir
7397
7393
  });
7398
7394
  }
7399
- function realResolveClaudeBinary(ownInstallDirs) {
7395
+ function resolveContentSourcePath(env) {
7396
+ return env.isSea ? env.execPath : env.argv1 ?? env.execPath;
7397
+ }
7398
+ function realContentSourcePath() {
7399
+ return resolveContentSourcePath({ isSea: (0, import_node_sea.isSea)(), execPath: process.execPath, argv1: process.argv[1] });
7400
+ }
7401
+ function realResolveClaudeBinary(isOwnBinary) {
7400
7402
  return () => discoverClaudeBinary({
7401
7403
  listVersionsDir,
7402
7404
  pathDirs: (process.env.PATH ?? "").split(import_node_path21.default.delimiter).filter((dir) => dir !== ""),
7403
7405
  findExecutableInDir,
7404
- ownInstallDirs: [...ownInstallDirs]
7406
+ isOwnBinary
7405
7407
  });
7406
7408
  }
7407
7409
 
@@ -7817,13 +7819,32 @@ var ClaudeShimStateSchema = import_zod11.z.strictObject({
7817
7819
  function commandFilename(ownExecutablePath, commandName) {
7818
7820
  return ownExecutablePath.toLowerCase().endsWith(".exe") ? `${commandName}.exe` : commandName;
7819
7821
  }
7820
- function resolveOwnInstallDirs(paths, ownExecutablePath) {
7821
- const dirs = [import_node_path23.default.dirname(ownExecutablePath)];
7822
+ function resolveOwnBinaryCheck(paths, contentSourcePath) {
7822
7823
  const state = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
7823
- if (state !== void 0) {
7824
- dirs.push(import_node_path23.default.dirname(state.targetPath));
7824
+ const recordedTarget = state === void 0 ? void 0 : import_node_path23.default.resolve(state.targetPath);
7825
+ let ownStat;
7826
+ return (candidate) => {
7827
+ if (recordedTarget !== void 0 && import_node_path23.default.resolve(candidate) === recordedTarget) {
7828
+ return true;
7829
+ }
7830
+ ownStat ??= statOrUndefined(contentSourcePath);
7831
+ const candidateStat = statOrUndefined(candidate);
7832
+ return ownStat !== void 0 && candidateStat !== void 0 && // A platform reporting no inode number for either file must not read every candidate as this tool.
7833
+ ownStat.ino !== 0 && candidateStat.ino !== 0 && candidateStat.dev === ownStat.dev && candidateStat.ino === ownStat.ino;
7834
+ };
7835
+ }
7836
+ function isEnoent4(error) {
7837
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
7838
+ }
7839
+ function statOrUndefined(target) {
7840
+ try {
7841
+ return import_node_fs7.default.statSync(target);
7842
+ } catch (error) {
7843
+ if (isEnoent4(error)) {
7844
+ return void 0;
7845
+ }
7846
+ throw error;
7825
7847
  }
7826
- return dirs;
7827
7848
  }
7828
7849
  var nodeLinkFs = { link: import_node_fs7.default.linkSync, copyFile: import_node_fs7.default.copyFileSync, chmod: import_node_fs7.default.chmodSync };
7829
7850
  function findPathShadow(params) {
@@ -8264,7 +8285,7 @@ function collectDoctorReport(params) {
8264
8285
  const ownExecutablePath = realOwnExecutablePath();
8265
8286
  let binaryDiscovery;
8266
8287
  try {
8267
- const binary = realResolveClaudeBinary(resolveOwnInstallDirs(paths, ownExecutablePath))();
8288
+ const binary = realResolveClaudeBinary(resolveOwnBinaryCheck(paths, realContentSourcePath()))();
8268
8289
  binaryDiscovery = { ok: true, binary };
8269
8290
  } catch (error) {
8270
8291
  binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
@@ -9240,7 +9261,7 @@ function realPrepareLaunchParams(paths, options) {
9240
9261
  fs: realFsPort,
9241
9262
  proc: options.proc,
9242
9263
  log: options.log,
9243
- resolveClaudeBinary: realResolveClaudeBinary(resolveOwnInstallDirs(paths, realOwnExecutablePath())),
9264
+ resolveClaudeBinary: realResolveClaudeBinary(resolveOwnBinaryCheck(paths, realContentSourcePath())),
9244
9265
  farm: farm.runtime,
9245
9266
  headroom: realHeadroomPort(paths, { spawnDaemon: options.spawnDaemon, cwd: farm.runtime.cwd }),
9246
9267
  frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
package/dist/index.mjs CHANGED
@@ -6803,18 +6803,14 @@ function discoverClaudeBinary(options) {
6803
6803
  version: highestVersion
6804
6804
  };
6805
6805
  }
6806
- const ownInstallDirs = new Set(options.ownInstallDirs.map((dir) => path20.resolve(dir)));
6807
6806
  for (const dir of options.pathDirs) {
6808
- if (ownInstallDirs.has(path20.resolve(dir))) {
6809
- continue;
6810
- }
6811
6807
  const found = options.findExecutableInDir(dir, "claude");
6812
- if (found !== void 0) {
6808
+ if (found !== void 0 && !options.isOwnBinary(found)) {
6813
6809
  return { path: found, source: "path-fallback" };
6814
6810
  }
6815
6811
  }
6816
6812
  throw new Error(
6817
- `Could not find a claude binary. Looked for genuinely-executable versioned binaries under "${versionsDir}" (missing, empty, or containing nothing executable) and for a "claude" executable on PATH (excluding this tool's own install directory). Install Claude Code, or set the versions directory / PATH correctly, then try again.`
6813
+ `Could not find a claude binary. Looked for genuinely-executable versioned binaries under "${versionsDir}" (missing, empty, or containing nothing executable) and for a "claude" executable on PATH (never this tool's own binary). Install Claude Code, or set the versions directory / PATH correctly, then try again.`
6818
6814
  );
6819
6815
  }
6820
6816
 
@@ -7212,12 +7208,18 @@ function realOwnExecutablePath() {
7212
7208
  findExecutableInDir
7213
7209
  });
7214
7210
  }
7215
- function realResolveClaudeBinary(ownInstallDirs) {
7211
+ function resolveContentSourcePath(env) {
7212
+ return env.isSea ? env.execPath : env.argv1 ?? env.execPath;
7213
+ }
7214
+ function realContentSourcePath() {
7215
+ return resolveContentSourcePath({ isSea: isSea(), execPath: process.execPath, argv1: process.argv[1] });
7216
+ }
7217
+ function realResolveClaudeBinary(isOwnBinary) {
7216
7218
  return () => discoverClaudeBinary({
7217
7219
  listVersionsDir,
7218
7220
  pathDirs: (process.env.PATH ?? "").split(path21.delimiter).filter((dir) => dir !== ""),
7219
7221
  findExecutableInDir,
7220
- ownInstallDirs: [...ownInstallDirs]
7222
+ isOwnBinary
7221
7223
  });
7222
7224
  }
7223
7225
 
@@ -7633,13 +7635,32 @@ var ClaudeShimStateSchema = z11.strictObject({
7633
7635
  function commandFilename(ownExecutablePath, commandName) {
7634
7636
  return ownExecutablePath.toLowerCase().endsWith(".exe") ? `${commandName}.exe` : commandName;
7635
7637
  }
7636
- function resolveOwnInstallDirs(paths, ownExecutablePath) {
7637
- const dirs = [path23.dirname(ownExecutablePath)];
7638
+ function resolveOwnBinaryCheck(paths, contentSourcePath) {
7638
7639
  const state = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
7639
- if (state !== void 0) {
7640
- dirs.push(path23.dirname(state.targetPath));
7640
+ const recordedTarget = state === void 0 ? void 0 : path23.resolve(state.targetPath);
7641
+ let ownStat;
7642
+ return (candidate) => {
7643
+ if (recordedTarget !== void 0 && path23.resolve(candidate) === recordedTarget) {
7644
+ return true;
7645
+ }
7646
+ ownStat ??= statOrUndefined(contentSourcePath);
7647
+ const candidateStat = statOrUndefined(candidate);
7648
+ return ownStat !== void 0 && candidateStat !== void 0 && // A platform reporting no inode number for either file must not read every candidate as this tool.
7649
+ ownStat.ino !== 0 && candidateStat.ino !== 0 && candidateStat.dev === ownStat.dev && candidateStat.ino === ownStat.ino;
7650
+ };
7651
+ }
7652
+ function isEnoent4(error) {
7653
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
7654
+ }
7655
+ function statOrUndefined(target) {
7656
+ try {
7657
+ return fs8.statSync(target);
7658
+ } catch (error) {
7659
+ if (isEnoent4(error)) {
7660
+ return void 0;
7661
+ }
7662
+ throw error;
7641
7663
  }
7642
- return dirs;
7643
7664
  }
7644
7665
  var nodeLinkFs = { link: fs8.linkSync, copyFile: fs8.copyFileSync, chmod: fs8.chmodSync };
7645
7666
  function findPathShadow(params) {
@@ -8080,7 +8101,7 @@ function collectDoctorReport(params) {
8080
8101
  const ownExecutablePath = realOwnExecutablePath();
8081
8102
  let binaryDiscovery;
8082
8103
  try {
8083
- const binary = realResolveClaudeBinary(resolveOwnInstallDirs(paths, ownExecutablePath))();
8104
+ const binary = realResolveClaudeBinary(resolveOwnBinaryCheck(paths, realContentSourcePath()))();
8084
8105
  binaryDiscovery = { ok: true, binary };
8085
8106
  } catch (error) {
8086
8107
  binaryDiscovery = { ok: false, message: error instanceof Error ? error.message : String(error) };
@@ -9056,7 +9077,7 @@ function realPrepareLaunchParams(paths, options) {
9056
9077
  fs: realFsPort,
9057
9078
  proc: options.proc,
9058
9079
  log: options.log,
9059
- resolveClaudeBinary: realResolveClaudeBinary(resolveOwnInstallDirs(paths, realOwnExecutablePath())),
9080
+ resolveClaudeBinary: realResolveClaudeBinary(resolveOwnBinaryCheck(paths, realContentSourcePath())),
9060
9081
  farm: farm.runtime,
9061
9082
  headroom: realHeadroomPort(paths, { spawnDaemon: options.spawnDaemon, cwd: farm.runtime.cwd }),
9062
9083
  frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-shim",
3
- "version": "8.5.1",
3
+ "version": "8.5.2",
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>",