mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 06:30:10 +08:00
Upgrade from 0.1.53 to 0.1.62 and recreate the spawn->fork patch for proper IPC communication in Electron.
36 lines
2.0 KiB
Diff
Vendored
36 lines
2.0 KiB
Diff
Vendored
diff --git a/sdk.mjs b/sdk.mjs
|
|
index dea7766a3432a1e809f12d6daba4f2834a219689..e0b02ef73da177ba32b903887d7bbbeaa08cc6d3 100755
|
|
--- a/sdk.mjs
|
|
+++ b/sdk.mjs
|
|
@@ -6250,7 +6250,7 @@ function createAbortController(maxListeners = DEFAULT_MAX_LISTENERS) {
|
|
}
|
|
|
|
// ../src/transport/ProcessTransport.ts
|
|
-import { spawn } from "child_process";
|
|
+import { fork } from "child_process";
|
|
import { createInterface } from "readline";
|
|
|
|
// ../src/utils/fsOperations.ts
|
|
@@ -6644,18 +6644,11 @@ class ProcessTransport {
|
|
const errorMessage = isNativeBinary(pathToClaudeCodeExecutable) ? `Claude Code native binary not found at ${pathToClaudeCodeExecutable}. Please ensure Claude Code is installed via native installer or specify a valid path with options.pathToClaudeCodeExecutable.` : `Claude Code executable not found at ${pathToClaudeCodeExecutable}. Is options.pathToClaudeCodeExecutable set?`;
|
|
throw new ReferenceError(errorMessage);
|
|
}
|
|
- const isNative = isNativeBinary(pathToClaudeCodeExecutable);
|
|
- const spawnCommand = isNative ? pathToClaudeCodeExecutable : executable;
|
|
- const spawnArgs = isNative ? [...executableArgs, ...args] : [...executableArgs, pathToClaudeCodeExecutable, ...args];
|
|
- const spawnMessage = isNative ? `Spawning Claude Code native binary: ${spawnCommand} ${spawnArgs.join(" ")}` : `Spawning Claude Code process: ${spawnCommand} ${spawnArgs.join(" ")}`;
|
|
- logForSdkDebugging(spawnMessage);
|
|
- if (stderr) {
|
|
- stderr(spawnMessage);
|
|
- }
|
|
+ logForSdkDebugging(`Forking Claude Code Node.js process: ${pathToClaudeCodeExecutable} ${args.join(" ")}`);
|
|
const stderrMode = env.DEBUG_CLAUDE_AGENT_SDK || stderr ? "pipe" : "ignore";
|
|
- this.child = spawn(spawnCommand, spawnArgs, {
|
|
+ this.child = fork(pathToClaudeCodeExecutable, args, {
|
|
cwd,
|
|
- stdio: ["pipe", "pipe", stderrMode],
|
|
+ stdio: stderrMode === "pipe" ? ["pipe", "pipe", "pipe", "ipc"] : ["pipe", "pipe", "ignore", "ipc"],
|
|
signal: this.abortController.signal,
|
|
env
|
|
});
|