fix: authorize CLI probes and preserve executable identity

This commit is contained in:
amosblomqvist
2026-10-28 19:26:36 +02:00
parent c5a756d707
commit 5093809ea0
9 changed files with 138 additions and 7 deletions
+5 -2
View File
@@ -6,6 +6,7 @@ type BinaryLookup = {
env: Record<string, string | undefined>;
platform: NodeJS.Platform;
homeDir: string;
cwd?: string;
isExecutable: (path: string) => boolean;
};
@@ -51,7 +52,7 @@ function getPosixSearchSpec(env: BinaryLookup["env"], homeDir: string): SearchSp
};
}
export function resolveClaudeBinary({ env, platform, homeDir, isExecutable }: BinaryLookup): string | null {
export function resolveClaudeBinary({ env, platform, homeDir, cwd = process.cwd(), isExecutable }: BinaryLookup): string | null {
const { paths, names, knownDirs } = platform === "win32"
? getWindowsSearchSpec(env, homeDir)
: getPosixSearchSpec(env, homeDir);
@@ -60,7 +61,9 @@ export function resolveClaudeBinary({ env, platform, homeDir, isExecutable }: Bi
for (const name of names) {
for (const dir of [...pathDirs, ...knownDirs]) {
const candidate = paths.join(dir, name);
// Discovery is relative to the server cwd; probes/model work use
// different directories and must receive the same absolute identity.
const candidate = paths.resolve(cwd, dir, name);
if (isExecutable(candidate)) return candidate;
}
}