Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): resolve Claude SDK executable path on Windows npm installs #3740

Mergednsxdavid(GitHub profile, opens in a new tab)merged 7 commits intomain fromrefs/pull/3740/headmerged by juliusmarminge View on GitHub

Showing 4 changed files with 220 additions and 1 deletion (loading 1).

x
0 of 4 viewed, 4 left
124 additions and 0 deletionsapps/server/src/provider/Drivers/ClaudeExecutable.test.tsAdded
View file
@@ -0,0 +1,124 @@
+import { describe, expect, it } from "@effect/vitest";
+import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
+import { SpawnExecutableResolution } from "@t3tools/shared/shell";
+import * as Effect from "effect/Effect";
+​
+import { ClaudeExecutableFileCheck, resolveClaudeSdkExecutablePath } from "./ClaudeExecutable.ts";
+​
+const NPM_DIR = "C:\\Users\\dev\\AppData\\Roaming\\npm";
+const NPM_SHIM = `${NPM_DIR}\\claude.cmd`;
+const NPM_PACKAGE_EXE = `${NPM_DIR}\\node_modules\\@anthropic-ai\\claude-code\\bin\\claude.exe`;
+const NPM_PACKAGE_CLI = `${NPM_DIR}\\node_modules\\@anthropic-ai\\claude-code\\cli.js`;
+​
+function withWindowsResolution(input: {
+ readonly resolvedCommand: string | undefined;
+ readonly existingFiles?: ReadonlyArray<string>;
+}) {
+ const existing = new Set(input.existingFiles ?? []);
+ return <A, E, R>(effect: Effect.Effect<A, E, R>) =>
+ effect.pipe(
+ Effect.provideService(HostProcessPlatform, "win32"),
+ Effect.provideService(SpawnExecutableResolution, () => input.resolvedCommand),
+ Effect.provideService(ClaudeExecutableFileCheck, (filePath) => existing.has(filePath)),
+ );
+}
+​
+describe("resolveClaudeSdkExecutablePath", () => {
+ it.effect("returns the configured path unchanged on non-Windows platforms", () =>
+ Effect.gen(function* () {
+ expect(
+ yield* resolveClaudeSdkExecutablePath("claude", {}).pipe(