pi-web-ui 0.2.4 → 0.2.5
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/bin/pi-web-ui.mjs +1 -1
- package/dist/server/agent-service.js +22 -7
- package/package.json +1 -1
package/bin/pi-web-ui.mjs
CHANGED
|
@@ -80,7 +80,7 @@ function checkNodeVersion() {
|
|
|
80
80
|
console.error(
|
|
81
81
|
`✖ pi-web-ui 需要 Node.js >= ${NODE_MIN.join(".")}(当前 ${process.versions.node})。\n` +
|
|
82
82
|
` pi SDK 的代码使用了 import attributes(with)语法,旧版 Node 无法解析。\n` +
|
|
83
|
-
` 请升级 Node:https://nodejs.org(或 nvm-windows / fnm)后重装:npm i -g pi-web-ui`,
|
|
83
|
+
` 请升级 Node:https://nodejs.org(或 nvm-windows / fnm)后重装:npm i -g pi-web-ui`,
|
|
84
84
|
);
|
|
85
85
|
process.exit(1);
|
|
86
86
|
}
|
|
@@ -562,25 +562,40 @@ export class ClientSession {
|
|
|
562
562
|
this.piCheckCache = { at: now, configured };
|
|
563
563
|
return configured;
|
|
564
564
|
}
|
|
565
|
-
/**
|
|
565
|
+
/**
|
|
566
|
+
* Run a command async, collecting stdout+stderr; kills on timeout.
|
|
567
|
+
* Never throws / never crashes the server: spawn errors (ENOENT etc.)
|
|
568
|
+
* resolve with code -1 so callers can report them as notices.
|
|
569
|
+
*/
|
|
566
570
|
runAsync(cmd, args, timeoutMs) {
|
|
567
571
|
return new Promise((resolve) => {
|
|
568
572
|
let p;
|
|
569
573
|
try {
|
|
570
|
-
p = spawn(cmd, args, {
|
|
574
|
+
p = spawn(cmd, args, {
|
|
575
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
576
|
+
// Windows: npm and friends are .cmd shims — Node can only exec
|
|
577
|
+
// them through the shell (otherwise spawn npm → ENOENT).
|
|
578
|
+
shell: process.platform === "win32",
|
|
579
|
+
});
|
|
571
580
|
}
|
|
572
581
|
catch (err) {
|
|
573
582
|
resolve({ code: -1, out: String(err) });
|
|
574
583
|
return;
|
|
575
584
|
}
|
|
576
585
|
let out = "";
|
|
586
|
+
let settled = false;
|
|
587
|
+
const done = (code, text) => {
|
|
588
|
+
if (settled)
|
|
589
|
+
return;
|
|
590
|
+
settled = true;
|
|
591
|
+
clearTimeout(t);
|
|
592
|
+
resolve({ code, out: text ?? out });
|
|
593
|
+
};
|
|
594
|
+
const t = setTimeout(() => p.kill(), timeoutMs);
|
|
577
595
|
p.stdout?.on("data", (d) => (out += d.toString()));
|
|
578
596
|
p.stderr?.on("data", (d) => (out += d.toString()));
|
|
579
|
-
|
|
580
|
-
p.on("close", (code) =>
|
|
581
|
-
clearTimeout(t);
|
|
582
|
-
resolve({ code, out });
|
|
583
|
-
});
|
|
597
|
+
p.on("error", (err) => done(-1, String(err)));
|
|
598
|
+
p.on("close", (code) => done(code));
|
|
584
599
|
});
|
|
585
600
|
}
|
|
586
601
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-web-ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Web chat interface for the pi coding agent, powered by the pi SDK (@earendil-works/pi-coding-agent) — one-command run, Docker/systemd/launchd deployable",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|