pi-sdk-web 0.3.8 → 0.3.10

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/cli.js CHANGED
@@ -8,8 +8,40 @@
8
8
  * pi-web help Show this help
9
9
  */
10
10
  import { SettingsManager, createAgentSessionFromServices, createAgentSessionRuntime, createAgentSessionServices, getAgentDir, resolveModelScopeWithDiagnostics, } from "@earendil-works/pi-coding-agent";
11
+ import { existsSync } from "node:fs";
12
+ import { fileURLToPath } from "node:url";
13
+ import { dirname, join } from "node:path";
11
14
  import { findSessionByName, listSessions, loadBuiltinExtensions } from "./session.js";
12
15
  import { PiWebServer } from "./server.js";
16
+ // ---------------------------------------------------------------------------
17
+ // Pretend to be Pi for in-process extensions.
18
+ //
19
+ // Extensions loaded into this process (magic-context historian/dreamer, etc.)
20
+ // derive "how to spawn a Pi subagent" from process.argv[1] — the host entry
21
+ // script (resolvePiInvocation reuses it when it exists on disk). pi-web's own
22
+ // bin is NOT Pi, so without this a subagent would re-exec the web server.
23
+ // Point argv[1] at the real Pi CLI that pi-sdk-web depends on: extension
24
+ // subagents then spawn Pi exactly as they would from a TUI Pi host.
25
+ //
26
+ // Safe because: pi-sdk-web parses its own args via process.argv.slice(2);
27
+ // Pi's core modules never read argv[1] (only Pi's own CLI entries do, which
28
+ // pi-web never invokes); magic-context's createRequire(argv[1]) module
29
+ // resolution still finds @earendil-works/pi-coding-agent (it sits inside
30
+ // pi-sdk-web/node_modules).
31
+ // ---------------------------------------------------------------------------
32
+ const PI_CLI_ENTRY = (() => {
33
+ try {
34
+ const mainEntry = fileURLToPath(import.meta.resolve("@earendil-works/pi-coding-agent"));
35
+ const candidate = join(dirname(mainEntry), "cli.js");
36
+ return existsSync(candidate) ? candidate : undefined;
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ })();
42
+ if (PI_CLI_ENTRY && process.argv[1] !== PI_CLI_ENTRY) {
43
+ process.argv[1] = PI_CLI_ENTRY;
44
+ }
13
45
  const DEFAULT_PORT = 4080;
14
46
  const DOC = `pi-web - browser Web access for Pi (via Pi SDK)
15
47
 
package/dist/server.js CHANGED
@@ -390,7 +390,11 @@ export class PiWebServer {
390
390
  const message = typeof data.message === "string" ? data.message : "";
391
391
  if (!message)
392
392
  throw new Error("Missing 'message'");
393
- await this.session.prompt(message);
393
+ // Queue with steer when the agent is already running (matches TUI's
394
+ // default: user messages submitted mid-turn are steered, i.e. handled
395
+ // right after the current turn; without this Pi throws
396
+ // "Agent is already processing...").
397
+ await this.session.prompt(message, { streamingBehavior: "steer" });
394
398
  break;
395
399
  }
396
400
  case "abort":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-sdk-web",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "description": "Browser Web access for Pi (AI coding agent) via the Pi SDK - standalone module, zero modification to Pi itself",
5
5
  "type": "module",
6
6
  "bin": {