@nowcrew/daemon 0.5.11 → 0.5.12
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/runtimes/codex.js +15 -4
- package/package.json +1 -1
package/dist/runtimes/codex.js
CHANGED
|
@@ -18,14 +18,25 @@ export function buildCodexArgs(input) {
|
|
|
18
18
|
}
|
|
19
19
|
if (input.dangerous)
|
|
20
20
|
args.push("--dangerously-bypass-approvals-and-sandbox");
|
|
21
|
-
|
|
21
|
+
// `-` instructs codex exec to read the prompt from stdin. Keeping the complete prompt out of argv
|
|
22
|
+
// avoids Windows' command-line length limit when a thread carries a large wake context.
|
|
23
|
+
args.push("-");
|
|
22
24
|
return args;
|
|
23
25
|
}
|
|
24
26
|
export function spawnCodex(input) {
|
|
25
|
-
// stdio 固定
|
|
26
|
-
|
|
27
|
+
// stdio 固定 pipe/pipe/pipe;cross-spawn 类型不带该细化,断言之。
|
|
28
|
+
const child = spawn(input.bin, buildCodexArgs(input), {
|
|
27
29
|
cwd: input.cwd,
|
|
28
30
|
env: input.env,
|
|
29
|
-
stdio: ["
|
|
31
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
30
32
|
});
|
|
33
|
+
// Decode at the pipe boundary so split multi-byte characters are buffered correctly before
|
|
34
|
+
// readline, stderr forwarding, activity reporting, and websocket JSON serialization consume them.
|
|
35
|
+
child.stdout.setEncoding("utf8");
|
|
36
|
+
child.stderr.setEncoding("utf8");
|
|
37
|
+
// Codex may exit before consuming a large prompt (for example on config/auth failure). In that
|
|
38
|
+
// case the pipe can emit EPIPE; the child exit code and stderr remain the authoritative failure.
|
|
39
|
+
child.stdin.on("error", () => undefined);
|
|
40
|
+
child.stdin.end(input.wakePrompt);
|
|
41
|
+
return child;
|
|
31
42
|
}
|