Skip to content

Commit 25764bf

Browse files
fix(server): run Claude fork workers on Node 22
1 parent 5a39e19 commit 25764bf

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ export class ClaudeAgentSdkQueryRunner extends Context.Service<
510510
export interface ClaudeAgentSdkSessionForkInput {
511511
readonly sessionId: string;
512512
readonly options: ForkSessionOptions;
513-
/** The instance environment; its CLAUDE_CONFIG_DIR locates the session files. */
514513
readonly environment: NodeJS.ProcessEnv;
515514
readonly threadId: ThreadId;
516515
readonly providerSessionId: OrchestrationV2ProviderSession["id"];
@@ -750,34 +749,27 @@ const decodeClaudeHistoryFork = Schema.decodeUnknownEffect(
750749
Schema.fromJsonString(Schema.Struct({ sessionId: Schema.String })),
751750
);
752751

753-
/** The directory the SDK reads session files from for this environment. */
754752
const claudeConfigDirOf = (
755753
path: Path.Path,
756754
environment: NodeJS.ProcessEnv,
757755
homeDirectory: string,
758-
) => path.resolve(environment.CLAUDE_CONFIG_DIR?.trim() || path.join(homeDirectory, ".claude"));
756+
) => path.resolve(environment.CLAUDE_CONFIG_DIR ?? path.join(homeDirectory, ".claude"));
759757

760-
/**
761-
* The SDK's history helpers read session files through `process.env`, which is
762-
* the server's environment and not the instance's. A fork for an instance whose
763-
* CLAUDE_CONFIG_DIR differs from the server's therefore runs in the history
764-
* worker process under the instance environment, so the server's own
765-
* environment never changes while other providers run.
766-
*/
758+
// The SDK reads CLAUDE_CONFIG_DIR from process.env. Isolate custom homes in a
759+
// worker so concurrent providers keep the server's environment.
767760
const forkClaudeSessionInWorker = Effect.fn("forkClaudeSessionInWorker")(function* (
768761
input: ClaudeAgentSdkSessionForkInput,
769762
) {
770763
const path = yield* Path.Path;
771-
// The single executable has no Node to run a sibling script, so it hosts
772-
// the worker as a hidden subcommand of itself.
764+
const fromSource = import.meta.url.endsWith(".ts");
765+
// A single executable hosts the worker itself; it has no sibling script.
773766
const workerArguments = (yield* HostProcess.IsExecutable)
774767
? ["__claude-history"]
775768
: [
769+
...(fromSource ? ["--experimental-strip-types"] : []),
776770
yield* path.fromFileUrl(
777771
new URL(
778-
import.meta.url.endsWith(".ts")
779-
? "../../claude-history-worker.ts"
780-
: "./claude-history-worker.mjs",
772+
fromSource ? "../../claude-history-worker.ts" : "./claude-history-worker.mjs",
781773
import.meta.url,
782774
),
783775
),

0 commit comments

Comments
 (0)