storyboard-bridge 0.3.0 → 0.3.1
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/index.mjs +10 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -32,7 +32,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
32
32
|
import { tmpdir } from 'node:os';
|
|
33
33
|
import { WebSocket } from 'ws';
|
|
34
34
|
|
|
35
|
-
const VERSION = '0.3.
|
|
35
|
+
const VERSION = '0.3.1';
|
|
36
36
|
|
|
37
37
|
// ---- config ----
|
|
38
38
|
const arg = (name, fallback) => {
|
|
@@ -71,7 +71,7 @@ function wsUrl(httpUrl) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// ---- the same CLI contract the backend uses: `<bin> -p <prompt> --output-format json [--model m]` ----
|
|
74
|
-
function runCli(bin, args) {
|
|
74
|
+
function runCli(bin, args, stdinInput) {
|
|
75
75
|
return new Promise((resolve, reject) => {
|
|
76
76
|
// On Windows the CLI is usually a `.cmd` shim (claude.cmd) that spawn() can't launch without a
|
|
77
77
|
// shell; shell:true uses PATHEXT to resolve it. POSIX (Linux/WSL/macOS) spawns the binary directly.
|
|
@@ -82,6 +82,8 @@ function runCli(bin, args) {
|
|
|
82
82
|
child.stderr.on('data', (d) => (err += d));
|
|
83
83
|
child.on('error', reject);
|
|
84
84
|
child.on('close', (code) => (code === 0 ? resolve(out) : reject(new Error(`${bin} exited ${code}: ${err.slice(0, 300)}`))));
|
|
85
|
+
// Feed the prompt via STDIN (not argv) — see runJob for why this matters on Windows.
|
|
86
|
+
if (stdinInput != null) child.stdin.write(stdinInput);
|
|
85
87
|
child.stdin.end();
|
|
86
88
|
});
|
|
87
89
|
}
|
|
@@ -97,10 +99,14 @@ function extractText(stdout) {
|
|
|
97
99
|
return stdout;
|
|
98
100
|
}
|
|
99
101
|
async function runJob(prompt) {
|
|
100
|
-
|
|
102
|
+
// Pass the prompt via STDIN, not argv. On Windows the bridge spawns through cmd.exe (shell:true, to
|
|
103
|
+
// resolve claude.cmd), and a big multi-line prompt as an arg gets mangled — cmd splits it on newlines,
|
|
104
|
+
// breaking the command ("'claude' is not recognized"). stdin sidesteps shell parsing entirely; `claude
|
|
105
|
+
// -p` / `gemini -p` read the prompt from stdin. (POSIX worked either way, but stdin is correct on both.)
|
|
106
|
+
const args = ['-p'];
|
|
101
107
|
if (USE_JSON) args.push('--output-format', 'json'); // claude wraps as JSON; gemini prints raw text
|
|
102
108
|
if (MODEL) args.push('--model', MODEL);
|
|
103
|
-
return extractText(await runCli(BIN, args));
|
|
109
|
+
return extractText(await runCli(BIN, args, prompt));
|
|
104
110
|
}
|
|
105
111
|
|
|
106
112
|
// is a CLI installed / runnable? (best-effort; a logged-out CLI still answers --version)
|
package/package.json
CHANGED