@overmux/pi 0.0.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.
Files changed (70) hide show
  1. package/README.md +118 -0
  2. package/dist/cli.d.ts +1 -0
  3. package/dist/cli.js +40 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/config-2jNv4tol.d.ts +34 -0
  6. package/dist/config-2jNv4tol.d.ts.map +1 -0
  7. package/dist/config.d.ts +2 -0
  8. package/dist/config.js +47 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/extension.d.ts +19 -0
  11. package/dist/extension.d.ts.map +1 -0
  12. package/dist/extension.js +265 -0
  13. package/dist/extension.js.map +1 -0
  14. package/dist/index.d.ts +10 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +16 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/jsonl-tail.d.ts +13 -0
  19. package/dist/jsonl-tail.d.ts.map +1 -0
  20. package/dist/jsonl-tail.js +83 -0
  21. package/dist/jsonl-tail.js.map +1 -0
  22. package/dist/live-events-ClhFOMGW.js +497 -0
  23. package/dist/live-events-ClhFOMGW.js.map +1 -0
  24. package/dist/live-events-DAmf6RRx.d.ts +107 -0
  25. package/dist/live-events-DAmf6RRx.d.ts.map +1 -0
  26. package/dist/live-events.d.ts +2 -0
  27. package/dist/live-events.js +2 -0
  28. package/dist/notification-DzOd9cRc.d.ts +20 -0
  29. package/dist/notification-DzOd9cRc.d.ts.map +1 -0
  30. package/dist/notification.d.ts +2 -0
  31. package/dist/notification.js +54 -0
  32. package/dist/notification.js.map +1 -0
  33. package/dist/plugin.d.ts +90 -0
  34. package/dist/plugin.d.ts.map +1 -0
  35. package/dist/plugin.js +213 -0
  36. package/dist/plugin.js.map +1 -0
  37. package/dist/projection.d.ts +101 -0
  38. package/dist/projection.d.ts.map +1 -0
  39. package/dist/projection.js +550 -0
  40. package/dist/projection.js.map +1 -0
  41. package/dist/protocol-CsrnSPOv.d.ts +115 -0
  42. package/dist/protocol-CsrnSPOv.d.ts.map +1 -0
  43. package/dist/protocol.d.ts +2 -0
  44. package/dist/protocol.js +365 -0
  45. package/dist/protocol.js.map +1 -0
  46. package/dist/react.d.ts +139 -0
  47. package/dist/react.d.ts.map +1 -0
  48. package/dist/react.js +796 -0
  49. package/dist/react.js.map +1 -0
  50. package/dist/server.d.ts +5 -0
  51. package/dist/server.js +4 -0
  52. package/dist/session-status-CZLTo8Km.d.ts +71 -0
  53. package/dist/session-status-CZLTo8Km.d.ts.map +1 -0
  54. package/dist/styles.css +619 -0
  55. package/docs/index.md +10 -0
  56. package/package.json +115 -0
  57. package/src/cli.ts +59 -0
  58. package/src/config.ts +87 -0
  59. package/src/extension.ts +486 -0
  60. package/src/index.ts +14 -0
  61. package/src/jsonl-tail.ts +110 -0
  62. package/src/live-events.ts +578 -0
  63. package/src/notification.ts +109 -0
  64. package/src/plugin.ts +369 -0
  65. package/src/projection.ts +995 -0
  66. package/src/protocol.ts +805 -0
  67. package/src/react.tsx +1293 -0
  68. package/src/server.ts +15 -0
  69. package/src/session-status.ts +379 -0
  70. package/src/styles.css +619 -0
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # @overmux/pi
2
+
3
+ The Pi extension and private Unix-socket protocol used by Overmux. It exposes live conversation events, structured inbound messages, and parent/delegate completion notifications over a private Unix socket. It registers no tools or commands.
4
+
5
+ This package was migrated from a standalone Pi extension at commit `52fb1712f205c939d3f58b84619c1fb4e0aab972` and is now owned and versioned by Overmux.
6
+
7
+ ## Integration
8
+
9
+ Install the extension through Pi:
10
+
11
+ ```sh
12
+ pi install npm:@overmux/pi
13
+ ```
14
+
15
+ For development, run `pnpm --filter @overmux/pi build`, then `pi install /absolute/path/to/packages/ecosystem/pi` to use the local package directly. Pi loads the package's built JavaScript extension. Load `@overmux/pi` in every parent and child Pi through the global Pi `settings.json`. A launcher starts a child with `PI_CHILD=1`, `PI_PARENT_SESSION_ID="$PI_SESSION_ID"`, and `PI_TASK_SLUG=<task-slug>`. `PI_TASK_SLUG` is required whenever `PI_CHILD=1`; it must match `[a-z0-9](?:[a-z0-9-]{0,11}[a-z0-9])?`. `PI_PARENT_SESSION_ID` is optional; omitting it disables callbacks to the parent. Parent Pi processes do not need a task slug. The extension captures the inherited parent ID and task slug at load time. It derives the parent's short Unix socket path from the ID; no socket path is passed through the environment.
16
+
17
+ Because the tmux server is an environment boundary, launchers must pass these values explicitly when creating the child. Supervision should react to the model-visible `overmux-pi.delegate-settled` message. Pi runs the configured inspection command, renders its output under `[<task-slug> finished]`, and includes it in model context.
18
+
19
+ ## Configure
20
+
21
+ Create `overmux-pi.jsonc` in `~/.pi/agent`, or in `$PI_EXTENSION_CONFIG_DIR` when set:
22
+
23
+ ```jsonc
24
+ {
25
+ "inspectionCommand": [
26
+ "pi-jq",
27
+ "{{childSessionId}}",
28
+ "--messages",
29
+ "3",
30
+ "--role",
31
+ "assistant",
32
+ ],
33
+ "inspectionTimeoutMs": 5000,
34
+ "supervisionPrompt": "Continue supervision.",
35
+ "liveEventsDir": null,
36
+ }
37
+ ```
38
+
39
+ `inspectionCommand` is executed directly with `pi.exec`, never through a shell. It must contain exactly one `{{childSessionId}}` placeholder, its only permitted template variable. `inspectionTimeoutMs` must be a positive integer no greater than 60000.
40
+
41
+ ## Inbound user messages
42
+
43
+ The per-session private socket also accepts versioned `user_message` requests. `requestId` is required and bounded; retries with the same ID return the original response without delivering twice. Requests have non-empty `message`, `deliverAs: "steer" | "followUp"`, and optional `expandPromptTemplates`, which defaults to `true`.
44
+
45
+ Install the sender CLI with npm, then send from the command line:
46
+
47
+ ```sh
48
+ npm install -g @overmux/pi
49
+ overmux-pi-send <sessionId> [--after-turn|--follow-up] <message>
50
+ printf 'Review the changes.' | overmux-pi-send <sessionId>
51
+ ```
52
+
53
+ `--after-turn` is the default and sends a `steer`; `--follow-up` queues until the current agent run finishes. It prints the JSON response and exits nonzero when delivery is unavailable.
54
+
55
+ Use the exported sender API rather than deriving socket paths. It has native Node.js JavaScript and declaration exports:
56
+
57
+ ```ts
58
+ import { sendUserMessage } from "@overmux/pi/protocol";
59
+
60
+ const response = await sendUserMessage(sessionId, {
61
+ requestId: crypto.randomUUID(),
62
+ message: "Review the changes.",
63
+ deliverAs: "steer",
64
+ });
65
+ ```
66
+
67
+ Successful responses include `delivery: "immediate" | "steer" | "followUp"`. Idle sessions deliver immediately; busy sessions use `steer` after the current assistant turn and tools, or `followUp` after the current agent run. Malformed or oversized frames are disconnected without a response. Delegate notifications retain their existing `ACK` response.
68
+
69
+ ## Live event stream
70
+
71
+ Set `liveEventsDir` to an absolute directory to enable the sidecar. It defaults to `null` because the stream contains conversation and tool data and grows without rotation. The directory must be outside Pi's session directory tree.
72
+
73
+ ```jsonc
74
+ {
75
+ "liveEventsDir": "/home/me/.local/state/overmux/pi/events",
76
+ }
77
+ ```
78
+
79
+ Each session runtime writes one append-only stream:
80
+
81
+ ```text
82
+ <liveEventsDir>/<sessionId>/<streamId>.jsonl
83
+ ```
84
+
85
+ Reloads and session replacements close the old stream and create a new `streamId`. Every complete JSONL record has this envelope:
86
+
87
+ ```json
88
+ {
89
+ "version": 1,
90
+ "sessionId": "...",
91
+ "processInstanceId": "<pid>-<uuid>",
92
+ "streamId": "...",
93
+ "sequence": 1,
94
+ "timestamp": 1700000000000,
95
+ "event": {
96
+ "type": "session_start",
97
+ "reason": "startup",
98
+ "cwd": "/project",
99
+ "pid": 1234
100
+ }
101
+ }
102
+ ```
103
+
104
+ `sequence` starts at 1 and increases within a stream. A tailer should checkpoint `(sessionId, streamId, sequence)` or its byte offset, process only newline-terminated records, and retain an incomplete final line until the next read. `processInstanceId` is stable across extension reloads in one Pi process; `streamId` distinguishes each session runtime.
105
+
106
+ The stream includes session metadata/compaction/tree events, agent and turn boundaries, message lifecycle events, tool execution start/end, and model/thinking changes. `message_start` and `message_end` contain message snapshots. `message_update` deliberately contains only a compact `assistantMessageEvent`: cumulative `message` and `partial` snapshots plus final block content are omitted, while text, thinking, and tool-call deltas retain `contentIndex`. The complete finalized message remains on `message_end`. Generated `messageId` and `messageSequence` correlate each message lifecycle within the stream.
107
+
108
+ Writes are serialized and each record is appended with its newline in one operation. Normal event handlers never await filesystem I/O. Shutdown waits for queued records, including `session_shutdown`; a write or serialization failure disables that stream without notifying, blocking, or changing the TUI. The exported `LiveEventRecord`, `CompactAssistantMessageEvent`, `liveEventSessionDir`, and `liveEventStreamPath` APIs are the supported tailer seam.
109
+
110
+ ## Manual smoke test
111
+
112
+ From the repository root, load only this extension:
113
+
114
+ ```bash
115
+ pi --no-extensions -e ./packages/ecosystem/pi
116
+ ```
117
+
118
+ Launch children through tmux with the parent's current Pi session ID, for example `tmux new-session -e PI_CHILD=1 -e PI_PARENT_SESSION_ID="$PI_SESSION_ID" -e PI_TASK_SLUG=<task-slug> ...`. A child launching a grandchild passes its own `PI_SESSION_ID` the same way. Omit `PI_PARENT_SESSION_ID` when the child should not call back. The extension sends a bounded, acknowledged notification once per settled child leaf, deduplicating receipts by the child session ID and leaf ID; a later leaf produces a new notification.
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {}
package/dist/cli.js ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ import { sendUserMessage } from "./protocol.js";
3
+ import { randomUUID } from "node:crypto";
4
+ import { readFile } from "node:fs/promises";
5
+ //#region src/cli.ts
6
+ const usage = () => "Usage: overmux-pi-send <sessionId> [--after-turn|--follow-up] <message>\n";
7
+ const parseInput = (args) => {
8
+ const [sessionId, ...rest] = args;
9
+ if (!sessionId) return;
10
+ const followUp = rest.at(0) === "--follow-up";
11
+ const afterTurn = rest.at(0) === "--after-turn";
12
+ const message = rest.slice(followUp || afterTurn ? 1 : 0).join(" ").trim();
13
+ return {
14
+ sessionId,
15
+ deliverAs: followUp ? "followUp" : "steer",
16
+ message
17
+ };
18
+ };
19
+ const readMessage = async (message) => message || (process.stdin.isTTY ? "" : (await readFile("/dev/stdin", "utf8")).trim());
20
+ const main = async () => {
21
+ const input = parseInput(process.argv.slice(2));
22
+ if (!input) throw new Error(usage());
23
+ const message = await readMessage(input.message);
24
+ if (!message) throw new Error(usage());
25
+ const response = await sendUserMessage(input.sessionId, {
26
+ requestId: randomUUID(),
27
+ message,
28
+ deliverAs: input.deliverAs
29
+ });
30
+ if (!response?.ok) throw new Error(JSON.stringify(response ?? { error: "unavailable" }));
31
+ process.stdout.write(`${JSON.stringify(response)}\n`);
32
+ };
33
+ main().catch((error) => {
34
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
35
+ process.exitCode = 1;
36
+ });
37
+ //#endregion
38
+ export {};
39
+
40
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { randomUUID } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\n\nimport { sendUserMessage } from \"./protocol.js\";\n\ntype CliInput = {\n sessionId: string;\n deliverAs: \"steer\" | \"followUp\";\n message: string;\n};\n\nconst usage = (): string =>\n \"Usage: overmux-pi-send <sessionId> [--after-turn|--follow-up] <message>\\n\";\n\nconst parseInput = (args: string[]): CliInput | undefined => {\n const [sessionId, ...rest] = args;\n if (!sessionId) {\n return undefined;\n }\n const followUp = rest.at(0) === \"--follow-up\";\n const afterTurn = rest.at(0) === \"--after-turn\";\n const message = rest\n .slice(followUp || afterTurn ? 1 : 0)\n .join(\" \")\n .trim();\n return { sessionId, deliverAs: followUp ? \"followUp\" : \"steer\", message };\n};\n\nconst readMessage = async (message: string): Promise<string> =>\n message ||\n (process.stdin.isTTY ? \"\" : (await readFile(\"/dev/stdin\", \"utf8\")).trim());\n\nconst main = async (): Promise<void> => {\n const input = parseInput(process.argv.slice(2));\n if (!input) {\n throw new Error(usage());\n }\n const message = await readMessage(input.message);\n if (!message) {\n throw new Error(usage());\n }\n const response = await sendUserMessage(input.sessionId, {\n requestId: randomUUID(),\n message,\n deliverAs: input.deliverAs,\n });\n if (!response?.ok) {\n throw new Error(JSON.stringify(response ?? { error: \"unavailable\" }));\n }\n process.stdout.write(`${JSON.stringify(response)}\\n`);\n};\n\nvoid main().catch((error: unknown) => {\n process.stderr.write(\n `${error instanceof Error ? error.message : String(error)}\\n`,\n );\n process.exitCode = 1;\n});\n"],"mappings":";;;;;AAYA,MAAM,cACJ;AAEF,MAAM,cAAc,SAAyC;CAC3D,MAAM,CAAC,WAAW,GAAG,QAAQ;CAC7B,IAAI,CAAC,WACH;CAEF,MAAM,WAAW,KAAK,GAAG,CAAC,MAAM;CAChC,MAAM,YAAY,KAAK,GAAG,CAAC,MAAM;CACjC,MAAM,UAAU,KACb,MAAM,YAAY,YAAY,IAAI,CAAC,CAAC,CACpC,KAAK,GAAG,CAAC,CACT,KAAK;CACR,OAAO;EAAE;EAAW,WAAW,WAAW,aAAa;EAAS;CAAQ;AAC1E;AAEA,MAAM,cAAc,OAAO,YACzB,YACC,QAAQ,MAAM,QAAQ,MAAM,MAAM,SAAS,cAAc,MAAM,EAAA,CAAG,KAAK;AAE1E,MAAM,OAAO,YAA2B;CACtC,MAAM,QAAQ,WAAW,QAAQ,KAAK,MAAM,CAAC,CAAC;CAC9C,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,MAAM,CAAC;CAEzB,MAAM,UAAU,MAAM,YAAY,MAAM,OAAO;CAC/C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,MAAM,CAAC;CAEzB,MAAM,WAAW,MAAM,gBAAgB,MAAM,WAAW;EACtD,WAAW,WAAW;EACtB;EACA,WAAW,MAAM;CACnB,CAAC;CACD,IAAI,CAAC,UAAU,IACb,MAAM,IAAI,MAAM,KAAK,UAAU,YAAY,EAAE,OAAO,cAAc,CAAC,CAAC;CAEtE,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,QAAQ,EAAE,GAAG;AACtD;AAEK,KAAK,CAAC,CAAC,OAAO,UAAmB;CACpC,QAAQ,OAAO,MACb,GAAG,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,GAC5D;CACA,QAAQ,WAAW;AACrB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ //#region src/config.d.ts
3
+ declare const DEFAULT_OVERMUX_PI_CONFIG: {
4
+ inspectionCommand: string[];
5
+ inspectionTimeoutMs: number;
6
+ supervisionPrompt: string;
7
+ liveEventsDir: null;
8
+ };
9
+ declare const OvermuxPiConfigSchema: z.ZodUnion<readonly [z.ZodObject<{
10
+ inspectionCommand: z.ZodArray<z.ZodString>;
11
+ inspectionTimeoutMs: z.ZodDefault<z.ZodNumber>;
12
+ supervisionPrompt: z.ZodDefault<z.ZodString>;
13
+ liveEventsDir: z.ZodDefault<z.ZodNullable<z.ZodString>>;
14
+ }, z.core.$strict>, z.ZodPipe<z.ZodObject<{
15
+ inspectionCommand: z.ZodOptional<z.ZodUndefined>;
16
+ inspectionTimeoutMs: z.ZodOptional<z.ZodNumber>;
17
+ supervisionPrompt: z.ZodOptional<z.ZodString>;
18
+ liveEventsDir: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
+ }, z.core.$strict>, z.ZodTransform<{
20
+ inspectionCommand: string[];
21
+ inspectionTimeoutMs: number;
22
+ supervisionPrompt: string;
23
+ liveEventsDir: string | null;
24
+ }, {
25
+ inspectionCommand?: undefined;
26
+ inspectionTimeoutMs?: number | undefined;
27
+ supervisionPrompt?: string | undefined;
28
+ liveEventsDir?: string | null | undefined;
29
+ }>>]>;
30
+ type OvermuxPiConfig = z.output<typeof OvermuxPiConfigSchema>;
31
+ type OvermuxPiConfigInput = z.input<typeof OvermuxPiConfigSchema>;
32
+ //#endregion
33
+ export { OvermuxPiConfigSchema as i, OvermuxPiConfig as n, OvermuxPiConfigInput as r, DEFAULT_OVERMUX_PI_CONFIG as t };
34
+ //# sourceMappingURL=config-2jNv4tol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-2jNv4tol.d.ts","names":[],"sources":["../src/config.ts"],"mappings":";;cAKa;;;;;;cA2EA,uBAAqB,EAAA,mBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;KAKtB,kBAAkB,EAAE,cAAc;KAClC,uBAAuB,EAAE,aAAa"}
@@ -0,0 +1,2 @@
1
+ import { i as OvermuxPiConfigSchema, n as OvermuxPiConfig, r as OvermuxPiConfigInput, t as DEFAULT_OVERMUX_PI_CONFIG } from "./config-2jNv4tol.js";
2
+ export { DEFAULT_OVERMUX_PI_CONFIG, OvermuxPiConfig, OvermuxPiConfigInput, OvermuxPiConfigSchema };
package/dist/config.js ADDED
@@ -0,0 +1,47 @@
1
+ import { isAbsolute } from "node:path";
2
+ import { templatedString } from "@richardgill/pi-config";
3
+ import { z } from "zod";
4
+ //#region src/config.ts
5
+ const DEFAULT_OVERMUX_PI_CONFIG = {
6
+ inspectionCommand: [
7
+ "pi-jq",
8
+ "{{childSessionId}}",
9
+ "--messages",
10
+ "3",
11
+ "--role",
12
+ "assistant"
13
+ ],
14
+ inspectionTimeoutMs: 5e3,
15
+ supervisionPrompt: "Continue supervision.",
16
+ liveEventsDir: null
17
+ };
18
+ const InspectionArgumentSchema = templatedString({
19
+ variables: ["childSessionId"],
20
+ missing: "keep"
21
+ });
22
+ const InspectionCommandSchema = z.array(InspectionArgumentSchema).min(1).refine((command) => command.reduce((count, argument) => count + argument.split("{{childSessionId}}").length - 1, 0) === 1, "must contain exactly one {{childSessionId}} placeholder");
23
+ const InspectionTimeoutSchema = z.number().int().positive().max(6e4);
24
+ const SupervisionPromptSchema = z.string();
25
+ const LiveEventsDirSchema = z.string().trim().min(1).refine(isAbsolute, "must be an absolute path").nullable();
26
+ const ConfigSchema = z.object({
27
+ inspectionCommand: InspectionCommandSchema,
28
+ inspectionTimeoutMs: InspectionTimeoutSchema.default(DEFAULT_OVERMUX_PI_CONFIG.inspectionTimeoutMs),
29
+ supervisionPrompt: SupervisionPromptSchema.default(DEFAULT_OVERMUX_PI_CONFIG.supervisionPrompt),
30
+ liveEventsDir: LiveEventsDirSchema.default(DEFAULT_OVERMUX_PI_CONFIG.liveEventsDir)
31
+ }).strict();
32
+ const DefaultConfigSchema = z.object({
33
+ inspectionCommand: z.undefined().optional(),
34
+ inspectionTimeoutMs: InspectionTimeoutSchema.optional(),
35
+ supervisionPrompt: SupervisionPromptSchema.optional(),
36
+ liveEventsDir: LiveEventsDirSchema.optional()
37
+ }).strict().transform((config) => ({
38
+ inspectionCommand: [...DEFAULT_OVERMUX_PI_CONFIG.inspectionCommand],
39
+ inspectionTimeoutMs: config.inspectionTimeoutMs ?? DEFAULT_OVERMUX_PI_CONFIG.inspectionTimeoutMs,
40
+ supervisionPrompt: config.supervisionPrompt ?? DEFAULT_OVERMUX_PI_CONFIG.supervisionPrompt,
41
+ liveEventsDir: config.liveEventsDir ?? DEFAULT_OVERMUX_PI_CONFIG.liveEventsDir
42
+ }));
43
+ const OvermuxPiConfigSchema = z.union([ConfigSchema, DefaultConfigSchema]);
44
+ //#endregion
45
+ export { DEFAULT_OVERMUX_PI_CONFIG, OvermuxPiConfigSchema };
46
+
47
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import { isAbsolute } from \"node:path\";\n\nimport { templatedString } from \"@richardgill/pi-config\";\nimport { z } from \"zod\";\n\nexport const DEFAULT_OVERMUX_PI_CONFIG = {\n inspectionCommand: [\n \"pi-jq\",\n \"{{childSessionId}}\",\n \"--messages\",\n \"3\",\n \"--role\",\n \"assistant\",\n ],\n inspectionTimeoutMs: 5000,\n supervisionPrompt: \"Continue supervision.\",\n liveEventsDir: null,\n};\n\nconst InspectionArgumentSchema = templatedString({\n variables: [\"childSessionId\"],\n missing: \"keep\",\n});\n\nconst InspectionCommandSchema = z\n .array(InspectionArgumentSchema)\n .min(1)\n .refine(\n (command) =>\n command.reduce(\n (count, argument) =>\n count + argument.split(\"{{childSessionId}}\").length - 1,\n 0,\n ) === 1,\n \"must contain exactly one {{childSessionId}} placeholder\",\n );\n\nconst InspectionTimeoutSchema = z.number().int().positive().max(60_000);\nconst SupervisionPromptSchema = z.string();\nconst LiveEventsDirSchema = z\n .string()\n .trim()\n .min(1)\n .refine(isAbsolute, \"must be an absolute path\")\n .nullable();\n\nconst ConfigSchema = z\n .object({\n inspectionCommand: InspectionCommandSchema,\n inspectionTimeoutMs: InspectionTimeoutSchema.default(\n DEFAULT_OVERMUX_PI_CONFIG.inspectionTimeoutMs,\n ),\n supervisionPrompt: SupervisionPromptSchema.default(\n DEFAULT_OVERMUX_PI_CONFIG.supervisionPrompt,\n ),\n liveEventsDir: LiveEventsDirSchema.default(\n DEFAULT_OVERMUX_PI_CONFIG.liveEventsDir,\n ),\n })\n .strict();\n\nconst DefaultConfigSchema = z\n .object({\n inspectionCommand: z.undefined().optional(),\n inspectionTimeoutMs: InspectionTimeoutSchema.optional(),\n supervisionPrompt: SupervisionPromptSchema.optional(),\n liveEventsDir: LiveEventsDirSchema.optional(),\n })\n .strict()\n .transform((config) => ({\n inspectionCommand: [...DEFAULT_OVERMUX_PI_CONFIG.inspectionCommand],\n inspectionTimeoutMs:\n config.inspectionTimeoutMs ??\n DEFAULT_OVERMUX_PI_CONFIG.inspectionTimeoutMs,\n supervisionPrompt:\n config.supervisionPrompt ?? DEFAULT_OVERMUX_PI_CONFIG.supervisionPrompt,\n liveEventsDir:\n config.liveEventsDir ?? DEFAULT_OVERMUX_PI_CONFIG.liveEventsDir,\n }));\n\nexport const OvermuxPiConfigSchema = z.union([\n ConfigSchema,\n DefaultConfigSchema,\n]);\n\nexport type OvermuxPiConfig = z.output<typeof OvermuxPiConfigSchema>;\nexport type OvermuxPiConfigInput = z.input<typeof OvermuxPiConfigSchema>;\n"],"mappings":";;;;AAKA,MAAa,4BAA4B;CACvC,mBAAmB;EACjB;EACA;EACA;EACA;EACA;EACA;CACF;CACA,qBAAqB;CACrB,mBAAmB;CACnB,eAAe;AACjB;AAEA,MAAM,2BAA2B,gBAAgB;CAC/C,WAAW,CAAC,gBAAgB;CAC5B,SAAS;AACX,CAAC;AAED,MAAM,0BAA0B,EAC7B,MAAM,wBAAwB,CAAC,CAC/B,IAAI,CAAC,CAAC,CACN,QACE,YACC,QAAQ,QACL,OAAO,aACN,QAAQ,SAAS,MAAM,oBAAoB,CAAC,CAAC,SAAS,GACxD,CACF,MAAM,GACR,yDACF;AAEF,MAAM,0BAA0B,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,GAAM;AACtE,MAAM,0BAA0B,EAAE,OAAO;AACzC,MAAM,sBAAsB,EACzB,OAAO,CAAC,CACR,KAAK,CAAC,CACN,IAAI,CAAC,CAAC,CACN,OAAO,YAAY,0BAA0B,CAAC,CAC9C,SAAS;AAEZ,MAAM,eAAe,EAClB,OAAO;CACN,mBAAmB;CACnB,qBAAqB,wBAAwB,QAC3C,0BAA0B,mBAC5B;CACA,mBAAmB,wBAAwB,QACzC,0BAA0B,iBAC5B;CACA,eAAe,oBAAoB,QACjC,0BAA0B,aAC5B;AACF,CAAC,CAAC,CACD,OAAO;AAEV,MAAM,sBAAsB,EACzB,OAAO;CACN,mBAAmB,EAAE,UAAU,CAAC,CAAC,SAAS;CAC1C,qBAAqB,wBAAwB,SAAS;CACtD,mBAAmB,wBAAwB,SAAS;CACpD,eAAe,oBAAoB,SAAS;AAC9C,CAAC,CAAC,CACD,OAAO,CAAC,CACR,WAAW,YAAY;CACtB,mBAAmB,CAAC,GAAG,0BAA0B,iBAAiB;CAClE,qBACE,OAAO,uBACP,0BAA0B;CAC5B,mBACE,OAAO,qBAAqB,0BAA0B;CACxD,eACE,OAAO,iBAAiB,0BAA0B;AACtD,EAAE;AAEJ,MAAa,wBAAwB,EAAE,MAAM,CAC3C,cACA,mBACF,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { r as OvermuxPiConfigInput } from "./config-2jNv4tol.js";
2
+ import { A as probePiSession, E as parseEnvelope, F as sendUserMessage, I as socketPathForSession, L as startReceiver, M as sendEnvelope, S as UserMessageResponse, b as UserMessageInput, c as ProbeOptions, d as SenderOptions, i as CHILD_ENV, k as parseUserMessageRequest, l as Receiver, o as DelegateSettledEnvelope, s as PARENT_SESSION_ENV, u as ReceiverOptions, v as TASK_SLUG_ENV, w as eventKey, x as UserMessageRequest } from "./protocol-CsrnSPOv.js";
3
+ import { n as OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE, o as truncatePiJqOutput } from "./notification-DzOd9cRc.js";
4
+ import { d as piSessionStatusSchema, i as PiSessionStatusWriter, l as parsePiSessionStatus, o as createPiSessionStatusWriter, r as PiSessionStatusUpdate, s as isLocalPidAlive, t as PiSessionStatus, u as piSessionStatusPath } from "./session-status-CZLTo8Km.js";
5
+ import { a as LiveEventWireRecord, c as compactAssistantMessageEvent, d as liveEventStreamPath, f as parseLiveEventRecord, i as LiveEventRecord, l as createLiveEventWriter, n as LiveEventEnvelope, o as LiveEventWriter, r as LiveEventPayload, s as PROCESS_INSTANCE_ID, t as CompactAssistantMessageEvent, u as liveEventSessionDir } from "./live-events-DAmf6RRx.js";
6
+ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
7
+ //#region src/extension.d.ts
8
+ declare const OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE = "overmux-pi.delegate-settled-receipt";
9
+ type OvermuxPiOptions = OvermuxPiConfigInput & {
10
+ env?: NodeJS.ProcessEnv;
11
+ runtimeDir?: string;
12
+ ackTimeoutMs?: number;
13
+ retryDelaysMs?: readonly number[];
14
+ onLiveEventError?: (error: unknown) => void;
15
+ };
16
+ declare const overmuxPi: (pi: ExtensionAPI, options?: OvermuxPiOptions) => void;
17
+ //#endregion
18
+ export { CHILD_ENV, type CompactAssistantMessageEvent, type DelegateSettledEnvelope, type LiveEventEnvelope, type LiveEventPayload, type LiveEventRecord, type LiveEventWireRecord, type LiveEventWriter, OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE, OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE, OvermuxPiOptions, PARENT_SESSION_ENV, PROCESS_INSTANCE_ID, type PiSessionStatus, type PiSessionStatusUpdate, type PiSessionStatusWriter, type ProbeOptions, type Receiver, type ReceiverOptions, type SenderOptions, TASK_SLUG_ENV, type UserMessageInput, type UserMessageRequest, type UserMessageResponse, compactAssistantMessageEvent, createLiveEventWriter, createPiSessionStatusWriter, eventKey, isLocalPidAlive, liveEventSessionDir, liveEventStreamPath, overmuxPi, parseEnvelope, parseLiveEventRecord, parsePiSessionStatus, parseUserMessageRequest, piSessionStatusPath, piSessionStatusSchema, probePiSession, sendEnvelope, sendUserMessage, socketPathForSession, startReceiver, truncatePiJqOutput };
19
+ //# sourceMappingURL=extension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.d.ts","names":[],"sources":["../src/extension.ts"],"mappings":";;;;;;;cAyGa;KAGD,mBAAmB;EAC7B,MAAM,OAAO;EACb;EACA;EACA;EACA,oBAAoB;;cAwFT,YACX,IAAI,cACJ,UAAS"}
@@ -0,0 +1,265 @@
1
+ import { CHILD_ENV, DEFAULT_OVERMUX_PI_RUNTIME_DIR, PARENT_SESSION_ENV, TASK_SLUG_ENV, TASK_SLUG_PATTERN, ensureRuntimeDir, eventKey, parseEnvelope, parseUserMessageRequest, probePiSession, sendEnvelope, sendUserMessage, socketPathForSession, startReceiver } from "./protocol.js";
2
+ import { OvermuxPiConfigSchema } from "./config.js";
3
+ import { a as liveEventStreamPath, f as parsePiSessionStatus, i as liveEventSessionDir, l as createPiSessionStatusWriter, m as piSessionStatusSchema, n as compactAssistantMessageEvent, o as parseLiveEventRecord, p as piSessionStatusPath, r as createLiveEventWriter, s as registerLiveEventCapture, t as PROCESS_INSTANCE_ID, u as isLocalPidAlive } from "./live-events-ClhFOMGW.js";
4
+ import { OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE, inspectDelegate, notificationMessage, notificationRenderer, truncatePiJqOutput } from "./notification.js";
5
+ //#region src/extension.ts
6
+ const OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE = "overmux-pi.delegate-settled-receipt";
7
+ const notificationEnvelope = (details) => {
8
+ if (typeof details !== "object" || details === null) return;
9
+ const value = details;
10
+ return parseEnvelope(JSON.stringify({
11
+ childSessionId: value.childSessionId,
12
+ taskSlug: value.taskSlug,
13
+ leafId: value.leafId,
14
+ cwd: value.cwd,
15
+ timestamp: value.timestamp
16
+ }));
17
+ };
18
+ const restoreReceipts = (ctx) => {
19
+ const receipts = /* @__PURE__ */ new Map();
20
+ const delivered = /* @__PURE__ */ new Set();
21
+ ctx.sessionManager.getEntries().forEach((entry) => {
22
+ if (entry.type === "custom" && entry.customType === "overmux-pi.delegate-settled-receipt") {
23
+ const envelope = parseEnvelope(JSON.stringify(entry.data));
24
+ if (envelope) receipts.set(eventKey(envelope), envelope);
25
+ }
26
+ if (entry.type === "custom_message" && entry.customType === "overmux-pi.delegate-settled") {
27
+ const envelope = notificationEnvelope(entry.details);
28
+ if (envelope) delivered.add(eventKey(envelope));
29
+ }
30
+ });
31
+ return {
32
+ eventKeys: new Set(receipts.keys()),
33
+ pending: [...receipts.values()].filter((envelope) => !delivered.has(eventKey(envelope)))
34
+ };
35
+ };
36
+ const requiredTaskSlug = (taskSlug) => {
37
+ if (!taskSlug || !TASK_SLUG_PATTERN.test(taskSlug)) throw new Error(`Child Pi requires a valid ${TASK_SLUG_ENV}`);
38
+ return taskSlug;
39
+ };
40
+ const rememberResponse = (responses, response) => {
41
+ responses.set(response.requestId, response);
42
+ if (responses.size > 128) responses.delete(responses.keys().next().value);
43
+ return response;
44
+ };
45
+ const injectNotification = async (pi, ctx, envelope, signal, config) => {
46
+ if (signal.aborted) return;
47
+ const details = await inspectDelegate(pi, envelope, signal, config);
48
+ if (signal.aborted) return;
49
+ pi.sendMessage(notificationMessage(envelope, details, config), ctx.isIdle() ? { triggerTurn: true } : { deliverAs: "steer" });
50
+ };
51
+ const overmuxPi = (pi, options = {}) => {
52
+ pi.registerMessageRenderer(OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE, notificationRenderer);
53
+ const { inspectionCommand, inspectionTimeoutMs, supervisionPrompt, liveEventsDir } = options;
54
+ const config = OvermuxPiConfigSchema.parse({
55
+ inspectionCommand,
56
+ inspectionTimeoutMs,
57
+ supervisionPrompt,
58
+ liveEventsDir
59
+ });
60
+ const env = options.env ?? process.env;
61
+ const isChild = env[CHILD_ENV] === "1";
62
+ const parentSessionId = isChild ? env[PARENT_SESSION_ENV] : void 0;
63
+ const childTaskSlug = isChild ? requiredTaskSlug(env[TASK_SLUG_ENV]) : void 0;
64
+ const runtimeDir = options.runtimeDir ?? DEFAULT_OVERMUX_PI_RUNTIME_DIR;
65
+ const parentSocket = parentSessionId ? socketPathForSession(parentSessionId, runtimeDir) : void 0;
66
+ let receiver;
67
+ let activeSessionId;
68
+ let sessionController;
69
+ let eventKeys = /* @__PURE__ */ new Set();
70
+ let abortResponses = /* @__PURE__ */ new Map();
71
+ let modelResponses = /* @__PURE__ */ new Map();
72
+ let thinkingResponses = /* @__PURE__ */ new Map();
73
+ let userMessageResponses = /* @__PURE__ */ new Map();
74
+ const liveEvents = registerLiveEventCapture(pi, {
75
+ rootDir: config.liveEventsDir,
76
+ env,
77
+ onError: options.onLiveEventError
78
+ });
79
+ pi.on("session_start", async (event, ctx) => {
80
+ await liveEvents.start(event, ctx);
81
+ const previousReceiver = receiver;
82
+ receiver = void 0;
83
+ sessionController?.abort();
84
+ const controller = new AbortController();
85
+ sessionController = controller;
86
+ abortResponses = /* @__PURE__ */ new Map();
87
+ modelResponses = /* @__PURE__ */ new Map();
88
+ thinkingResponses = /* @__PURE__ */ new Map();
89
+ userMessageResponses = /* @__PURE__ */ new Map();
90
+ await previousReceiver?.close();
91
+ const ownSessionId = ctx.sessionManager.getSessionId();
92
+ activeSessionId = ownSessionId;
93
+ const restored = restoreReceipts(ctx);
94
+ eventKeys = restored.eventKeys;
95
+ await ensureRuntimeDir(runtimeDir);
96
+ const startedReceiver = await startReceiver(socketPathForSession(ownSessionId, runtimeDir), (envelope) => {
97
+ if (controller.signal.aborted || sessionController !== controller) return;
98
+ const key = eventKey(envelope);
99
+ if (eventKeys.has(key)) return;
100
+ pi.appendEntry(OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE, envelope);
101
+ eventKeys.add(key);
102
+ injectNotification(pi, ctx, envelope, controller.signal, config).catch(() => void 0);
103
+ }, {
104
+ onSetModel: async (request) => {
105
+ const previous = modelResponses.get(request.requestId);
106
+ if (previous) return previous;
107
+ if (controller.signal.aborted || sessionController !== controller) return rememberResponse(modelResponses, {
108
+ version: 1,
109
+ requestId: request.requestId,
110
+ ok: false,
111
+ error: "shutting_down"
112
+ });
113
+ const model = ctx.modelRegistry.find(request.provider, request.id);
114
+ if (!model) return rememberResponse(modelResponses, {
115
+ version: 1,
116
+ requestId: request.requestId,
117
+ ok: false,
118
+ error: "not_found"
119
+ });
120
+ try {
121
+ if (!await pi.setModel(model)) return rememberResponse(modelResponses, {
122
+ version: 1,
123
+ requestId: request.requestId,
124
+ ok: false,
125
+ error: "no_key"
126
+ });
127
+ return rememberResponse(modelResponses, {
128
+ version: 1,
129
+ requestId: request.requestId,
130
+ ok: true
131
+ });
132
+ } catch {
133
+ return rememberResponse(modelResponses, {
134
+ version: 1,
135
+ requestId: request.requestId,
136
+ ok: false,
137
+ error: "unavailable"
138
+ });
139
+ }
140
+ },
141
+ onSetThinkingLevel: (request) => {
142
+ const previous = thinkingResponses.get(request.requestId);
143
+ if (previous) return previous;
144
+ if (controller.signal.aborted || sessionController !== controller) return rememberResponse(thinkingResponses, {
145
+ version: 1,
146
+ requestId: request.requestId,
147
+ ok: false,
148
+ error: "shutting_down"
149
+ });
150
+ try {
151
+ pi.setThinkingLevel(request.level);
152
+ return rememberResponse(thinkingResponses, {
153
+ version: 1,
154
+ requestId: request.requestId,
155
+ ok: true
156
+ });
157
+ } catch {
158
+ return rememberResponse(thinkingResponses, {
159
+ version: 1,
160
+ requestId: request.requestId,
161
+ ok: false,
162
+ error: "unavailable"
163
+ });
164
+ }
165
+ },
166
+ onAbort: (request) => {
167
+ const previous = abortResponses.get(request.requestId);
168
+ if (previous) return previous;
169
+ if (controller.signal.aborted || sessionController !== controller) return rememberResponse(abortResponses, {
170
+ version: 1,
171
+ requestId: request.requestId,
172
+ ok: false,
173
+ error: "shutting_down"
174
+ });
175
+ if (ctx.isIdle()) return rememberResponse(abortResponses, {
176
+ version: 1,
177
+ requestId: request.requestId,
178
+ ok: false,
179
+ error: "unavailable"
180
+ });
181
+ try {
182
+ ctx.abort();
183
+ return rememberResponse(abortResponses, {
184
+ version: 1,
185
+ requestId: request.requestId,
186
+ ok: true
187
+ });
188
+ } catch {
189
+ return rememberResponse(abortResponses, {
190
+ version: 1,
191
+ requestId: request.requestId,
192
+ ok: false,
193
+ error: "unavailable"
194
+ });
195
+ }
196
+ },
197
+ onUserMessage: (request) => {
198
+ const previous = userMessageResponses.get(request.requestId);
199
+ if (previous) return previous;
200
+ if (controller.signal.aborted || sessionController !== controller) return rememberResponse(userMessageResponses, {
201
+ version: 1,
202
+ requestId: request.requestId,
203
+ ok: false,
204
+ error: "shutting_down"
205
+ });
206
+ const isIdle = ctx.isIdle();
207
+ const delivery = isIdle ? "immediate" : request.deliverAs;
208
+ const userMessageOptions = isIdle ? { expandPromptTemplates: request.expandPromptTemplates } : {
209
+ deliverAs: request.deliverAs,
210
+ expandPromptTemplates: request.expandPromptTemplates
211
+ };
212
+ try {
213
+ pi.sendUserMessage(request.message, userMessageOptions);
214
+ return rememberResponse(userMessageResponses, {
215
+ version: 1,
216
+ requestId: request.requestId,
217
+ ok: true,
218
+ delivery
219
+ });
220
+ } catch {
221
+ return rememberResponse(userMessageResponses, {
222
+ version: 1,
223
+ requestId: request.requestId,
224
+ ok: false,
225
+ error: "unavailable"
226
+ });
227
+ }
228
+ }
229
+ });
230
+ if (controller.signal.aborted || sessionController !== controller) {
231
+ await startedReceiver.close();
232
+ return;
233
+ }
234
+ receiver = startedReceiver;
235
+ await Promise.all(restored.pending.map((envelope) => injectNotification(pi, ctx, envelope, controller.signal, config)));
236
+ });
237
+ pi.on("agent_settled", async (_event, ctx) => {
238
+ const childSessionId = ctx.sessionManager.getSessionId();
239
+ const leafId = ctx.sessionManager.getLeafId();
240
+ if (!parentSocket || !leafId || !childTaskSlug) return;
241
+ await sendEnvelope(parentSocket, {
242
+ childSessionId,
243
+ taskSlug: childTaskSlug,
244
+ leafId,
245
+ cwd: ctx.cwd,
246
+ timestamp: Date.now()
247
+ }, {
248
+ ackTimeoutMs: options.ackTimeoutMs,
249
+ retryDelaysMs: options.retryDelaysMs
250
+ });
251
+ });
252
+ pi.on("session_shutdown", async (event, ctx) => {
253
+ if (ctx.sessionManager.getSessionId() !== activeSessionId) return;
254
+ const ownedReceiver = receiver;
255
+ receiver = void 0;
256
+ activeSessionId = void 0;
257
+ sessionController?.abort();
258
+ sessionController = void 0;
259
+ await Promise.all([ownedReceiver?.close(), liveEvents.stop(event)]);
260
+ });
261
+ };
262
+ //#endregion
263
+ export { CHILD_ENV, OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE, OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE, PARENT_SESSION_ENV, PROCESS_INSTANCE_ID, TASK_SLUG_ENV, compactAssistantMessageEvent, createLiveEventWriter, createPiSessionStatusWriter, eventKey, isLocalPidAlive, liveEventSessionDir, liveEventStreamPath, overmuxPi, parseEnvelope, parseLiveEventRecord, parsePiSessionStatus, parseUserMessageRequest, piSessionStatusPath, piSessionStatusSchema, probePiSession, sendEnvelope, sendUserMessage, socketPathForSession, startReceiver, truncatePiJqOutput };
264
+
265
+ //# sourceMappingURL=extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.js","names":[],"sources":["../src/extension.ts"],"sourcesContent":["import type {\n ExtensionAPI,\n ExtensionContext,\n} from \"@earendil-works/pi-coding-agent\";\n\nimport {\n OvermuxPiConfigSchema,\n type OvermuxPiConfig,\n type OvermuxPiConfigInput,\n} from \"./config.js\";\nimport {\n compactAssistantMessageEvent,\n createLiveEventWriter,\n liveEventSessionDir,\n liveEventStreamPath,\n PROCESS_INSTANCE_ID,\n registerLiveEventCapture,\n type CompactAssistantMessageEvent,\n type LiveEventPayload,\n type LiveEventRecord,\n type LiveEventWriter,\n} from \"./live-events.js\";\nimport {\n inspectDelegate,\n OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE,\n notificationMessage,\n notificationRenderer,\n type DelegateNotificationDetails,\n} from \"./notification.js\";\nimport {\n CHILD_ENV,\n DEFAULT_OVERMUX_PI_RUNTIME_DIR,\n ensureRuntimeDir,\n eventKey,\n PARENT_SESSION_ENV,\n parseEnvelope,\n sendEnvelope,\n sendUserMessage,\n socketPathForSession,\n startReceiver,\n TASK_SLUG_ENV,\n TASK_SLUG_PATTERN,\n type AbortRequest,\n type AbortResponse,\n type DelegateSettledEnvelope,\n type SetModelRequest,\n type SetModelResponse,\n type SetThinkingLevelRequest,\n type SetThinkingLevelResponse,\n type UserMessageRequest,\n type UserMessageResponse,\n} from \"./protocol.js\";\n\nexport {\n CHILD_ENV,\n eventKey,\n PARENT_SESSION_ENV,\n TASK_SLUG_ENV,\n} from \"./protocol.js\";\nexport {\n OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE,\n truncatePiJqOutput,\n} from \"./notification.js\";\nexport {\n createPiSessionStatusWriter,\n isLocalPidAlive,\n piSessionStatusPath,\n piSessionStatusSchema,\n parsePiSessionStatus,\n type PiSessionStatus,\n type PiSessionStatusUpdate,\n type PiSessionStatusWriter,\n} from \"./session-status.js\";\nexport {\n compactAssistantMessageEvent,\n createLiveEventWriter,\n liveEventSessionDir,\n liveEventStreamPath,\n parseLiveEventRecord,\n PROCESS_INSTANCE_ID,\n type CompactAssistantMessageEvent,\n type LiveEventEnvelope,\n type LiveEventPayload,\n type LiveEventRecord,\n type LiveEventWireRecord,\n type LiveEventWriter,\n} from \"./live-events.js\";\nexport {\n parseEnvelope,\n probePiSession,\n sendEnvelope,\n sendUserMessage,\n socketPathForSession,\n startReceiver,\n parseUserMessageRequest,\n type DelegateSettledEnvelope,\n type ProbeOptions,\n type Receiver,\n type ReceiverOptions,\n type SenderOptions,\n type UserMessageInput,\n type UserMessageRequest,\n type UserMessageResponse,\n} from \"./protocol.js\";\n\nexport const OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE =\n \"overmux-pi.delegate-settled-receipt\";\n\nexport type OvermuxPiOptions = OvermuxPiConfigInput & {\n env?: NodeJS.ProcessEnv;\n runtimeDir?: string;\n ackTimeoutMs?: number;\n retryDelaysMs?: readonly number[];\n onLiveEventError?: (error: unknown) => void;\n};\n\nconst notificationEnvelope = (details: unknown) => {\n if (typeof details !== \"object\" || details === null) {\n return undefined;\n }\n const value = details as Record<string, unknown>;\n return parseEnvelope(\n JSON.stringify({\n childSessionId: value.childSessionId,\n taskSlug: value.taskSlug,\n leafId: value.leafId,\n cwd: value.cwd,\n timestamp: value.timestamp,\n }),\n );\n};\n\nconst restoreReceipts = (ctx: ExtensionContext) => {\n const receipts = new Map<string, DelegateSettledEnvelope>();\n const delivered = new Set<string>();\n ctx.sessionManager.getEntries().forEach((entry) => {\n if (\n entry.type === \"custom\" &&\n entry.customType === OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE\n ) {\n const envelope = parseEnvelope(JSON.stringify(entry.data));\n if (envelope) {\n receipts.set(eventKey(envelope), envelope);\n }\n }\n if (\n entry.type === \"custom_message\" &&\n entry.customType === OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE\n ) {\n const envelope = notificationEnvelope(entry.details);\n if (envelope) {\n delivered.add(eventKey(envelope));\n }\n }\n });\n return {\n eventKeys: new Set(receipts.keys()),\n pending: [...receipts.values()].filter(\n (envelope) => !delivered.has(eventKey(envelope)),\n ),\n };\n};\n\nconst requiredTaskSlug = (taskSlug: string | undefined): string => {\n if (!taskSlug || !TASK_SLUG_PATTERN.test(taskSlug)) {\n throw new Error(`Child Pi requires a valid ${TASK_SLUG_ENV}`);\n }\n return taskSlug;\n};\n\nconst rememberResponse = <Response extends { requestId: string }>(\n responses: Map<string, Response>,\n response: Response,\n): Response => {\n responses.set(response.requestId, response);\n if (responses.size > 128) {\n responses.delete(responses.keys().next().value!);\n }\n return response;\n};\n\nconst injectNotification = async (\n pi: ExtensionAPI,\n ctx: ExtensionContext,\n envelope: DelegateSettledEnvelope,\n signal: AbortSignal,\n config: OvermuxPiConfig,\n): Promise<void> => {\n if (signal.aborted) {\n return;\n }\n const details = await inspectDelegate(pi, envelope, signal, config);\n if (signal.aborted) {\n return;\n }\n pi.sendMessage(\n notificationMessage(envelope, details, config),\n ctx.isIdle() ? { triggerTurn: true } : { deliverAs: \"steer\" },\n );\n};\n\nexport const overmuxPi = (\n pi: ExtensionAPI,\n options: OvermuxPiOptions = {},\n): void => {\n pi.registerMessageRenderer<DelegateNotificationDetails>(\n OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE,\n notificationRenderer,\n );\n\n const {\n inspectionCommand,\n inspectionTimeoutMs,\n supervisionPrompt,\n liveEventsDir,\n } = options;\n const config = OvermuxPiConfigSchema.parse({\n inspectionCommand,\n inspectionTimeoutMs,\n supervisionPrompt,\n liveEventsDir,\n });\n const env = options.env ?? process.env;\n const isChild = env[CHILD_ENV] === \"1\";\n const parentSessionId = isChild ? env[PARENT_SESSION_ENV] : undefined;\n const childTaskSlug = isChild\n ? requiredTaskSlug(env[TASK_SLUG_ENV])\n : undefined;\n const runtimeDir = options.runtimeDir ?? DEFAULT_OVERMUX_PI_RUNTIME_DIR;\n const parentSocket = parentSessionId\n ? socketPathForSession(parentSessionId, runtimeDir)\n : undefined;\n let receiver: Awaited<ReturnType<typeof startReceiver>> | undefined;\n let activeSessionId: string | undefined;\n let sessionController: AbortController | undefined;\n let eventKeys = new Set<string>();\n let abortResponses = new Map<string, AbortResponse>();\n let modelResponses = new Map<string, SetModelResponse>();\n let thinkingResponses = new Map<string, SetThinkingLevelResponse>();\n let userMessageResponses = new Map<string, UserMessageResponse>();\n const liveEvents = registerLiveEventCapture(pi, {\n rootDir: config.liveEventsDir,\n env,\n onError: options.onLiveEventError,\n });\n\n pi.on(\"session_start\", async (event, ctx) => {\n await liveEvents.start(event, ctx);\n const previousReceiver = receiver;\n receiver = undefined;\n sessionController?.abort();\n const controller = new AbortController();\n sessionController = controller;\n abortResponses = new Map();\n modelResponses = new Map();\n thinkingResponses = new Map();\n userMessageResponses = new Map();\n await previousReceiver?.close();\n const ownSessionId = ctx.sessionManager.getSessionId();\n activeSessionId = ownSessionId;\n const restored = restoreReceipts(ctx);\n eventKeys = restored.eventKeys;\n await ensureRuntimeDir(runtimeDir);\n const startedReceiver = await startReceiver(\n socketPathForSession(ownSessionId, runtimeDir),\n (envelope) => {\n if (controller.signal.aborted || sessionController !== controller) {\n return;\n }\n const key = eventKey(envelope);\n if (eventKeys.has(key)) {\n return;\n }\n pi.appendEntry(OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE, envelope);\n eventKeys.add(key);\n void injectNotification(\n pi,\n ctx,\n envelope,\n controller.signal,\n config,\n ).catch(() => undefined);\n },\n {\n onSetModel: async (\n request: SetModelRequest,\n ): Promise<SetModelResponse> => {\n const previous = modelResponses.get(request.requestId);\n if (previous) {\n return previous;\n }\n if (controller.signal.aborted || sessionController !== controller) {\n return rememberResponse(modelResponses, {\n version: 1,\n requestId: request.requestId,\n ok: false,\n error: \"shutting_down\",\n });\n }\n const model = ctx.modelRegistry.find(request.provider, request.id);\n if (!model) {\n return rememberResponse(modelResponses, {\n version: 1,\n requestId: request.requestId,\n ok: false,\n error: \"not_found\",\n });\n }\n try {\n if (!(await pi.setModel(model))) {\n return rememberResponse(modelResponses, {\n version: 1,\n requestId: request.requestId,\n ok: false,\n error: \"no_key\",\n });\n }\n return rememberResponse(modelResponses, {\n version: 1,\n requestId: request.requestId,\n ok: true,\n });\n } catch {\n return rememberResponse(modelResponses, {\n version: 1,\n requestId: request.requestId,\n ok: false,\n error: \"unavailable\",\n });\n }\n },\n onSetThinkingLevel: (\n request: SetThinkingLevelRequest,\n ): SetThinkingLevelResponse => {\n const previous = thinkingResponses.get(request.requestId);\n if (previous) {\n return previous;\n }\n if (controller.signal.aborted || sessionController !== controller) {\n return rememberResponse(thinkingResponses, {\n version: 1,\n requestId: request.requestId,\n ok: false,\n error: \"shutting_down\",\n });\n }\n try {\n pi.setThinkingLevel(request.level);\n return rememberResponse(thinkingResponses, {\n version: 1,\n requestId: request.requestId,\n ok: true,\n });\n } catch {\n return rememberResponse(thinkingResponses, {\n version: 1,\n requestId: request.requestId,\n ok: false,\n error: \"unavailable\",\n });\n }\n },\n onAbort: (request: AbortRequest): AbortResponse => {\n const previous = abortResponses.get(request.requestId);\n if (previous) {\n return previous;\n }\n if (controller.signal.aborted || sessionController !== controller) {\n return rememberResponse(abortResponses, {\n version: 1,\n requestId: request.requestId,\n ok: false,\n error: \"shutting_down\",\n });\n }\n if (ctx.isIdle()) {\n return rememberResponse(abortResponses, {\n version: 1,\n requestId: request.requestId,\n ok: false,\n error: \"unavailable\",\n });\n }\n try {\n ctx.abort();\n return rememberResponse(abortResponses, {\n version: 1,\n requestId: request.requestId,\n ok: true,\n });\n } catch {\n return rememberResponse(abortResponses, {\n version: 1,\n requestId: request.requestId,\n ok: false,\n error: \"unavailable\",\n });\n }\n },\n onUserMessage: (request: UserMessageRequest): UserMessageResponse => {\n const previous = userMessageResponses.get(request.requestId);\n if (previous) {\n return previous;\n }\n if (controller.signal.aborted || sessionController !== controller) {\n return rememberResponse(userMessageResponses, {\n version: 1,\n requestId: request.requestId,\n ok: false,\n error: \"shutting_down\",\n });\n }\n const isIdle = ctx.isIdle();\n const delivery = isIdle ? \"immediate\" : request.deliverAs;\n const userMessageOptions = isIdle\n ? { expandPromptTemplates: request.expandPromptTemplates }\n : {\n deliverAs: request.deliverAs,\n expandPromptTemplates: request.expandPromptTemplates,\n };\n try {\n pi.sendUserMessage(request.message, userMessageOptions);\n return rememberResponse(userMessageResponses, {\n version: 1,\n requestId: request.requestId,\n ok: true,\n delivery,\n });\n } catch {\n return rememberResponse(userMessageResponses, {\n version: 1,\n requestId: request.requestId,\n ok: false,\n error: \"unavailable\",\n });\n }\n },\n },\n );\n if (controller.signal.aborted || sessionController !== controller) {\n await startedReceiver.close();\n return;\n }\n receiver = startedReceiver;\n await Promise.all(\n restored.pending.map((envelope) =>\n injectNotification(pi, ctx, envelope, controller.signal, config),\n ),\n );\n });\n\n pi.on(\"agent_settled\", async (_event, ctx) => {\n const childSessionId = ctx.sessionManager.getSessionId();\n const leafId = ctx.sessionManager.getLeafId();\n if (!parentSocket || !leafId || !childTaskSlug) {\n return;\n }\n\n await sendEnvelope(\n parentSocket,\n {\n childSessionId,\n taskSlug: childTaskSlug,\n leafId,\n cwd: ctx.cwd,\n timestamp: Date.now(),\n },\n {\n ackTimeoutMs: options.ackTimeoutMs,\n retryDelaysMs: options.retryDelaysMs,\n },\n );\n });\n\n pi.on(\"session_shutdown\", async (event, ctx) => {\n if (ctx.sessionManager.getSessionId() !== activeSessionId) {\n return;\n }\n const ownedReceiver = receiver;\n receiver = undefined;\n activeSessionId = undefined;\n sessionController?.abort();\n sessionController = undefined;\n await Promise.all([ownedReceiver?.close(), liveEvents.stop(event)]);\n });\n};\n"],"mappings":";;;;;AAyGA,MAAa,2CACX;AAUF,MAAM,wBAAwB,YAAqB;CACjD,IAAI,OAAO,YAAY,YAAY,YAAY,MAC7C;CAEF,MAAM,QAAQ;CACd,OAAO,cACL,KAAK,UAAU;EACb,gBAAgB,MAAM;EACtB,UAAU,MAAM;EAChB,QAAQ,MAAM;EACd,KAAK,MAAM;EACX,WAAW,MAAM;CACnB,CAAC,CACH;AACF;AAEA,MAAM,mBAAmB,QAA0B;CACjD,MAAM,2BAAW,IAAI,IAAqC;CAC1D,MAAM,4BAAY,IAAI,IAAY;CAClC,IAAI,eAAe,WAAW,CAAC,CAAC,SAAS,UAAU;EAC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WAAW,QAAQ;MACnB,IAAI;MACJ,OAAO;KACT,CAAC;IACH;GACF;EACF,CACF;EACA,IAAI,WAAW,OAAO,WAAW,sBAAsB,YAAY;GACjE,MAAM,gBAAgB,MAAM;GAC5B;EACF;EACA,WAAW;EACX,MAAM,QAAQ,IACZ,SAAS,QAAQ,KAAK,aACpB,mBAAmB,IAAI,KAAK,UAAU,WAAW,QAAQ,MAAM,CACjE,CACF;CACF,CAAC;CAED,GAAG,GAAG,iBAAiB,OAAO,QAAQ,QAAQ;EAC5C,MAAM,iBAAiB,IAAI,eAAe,aAAa;EACvD,MAAM,SAAS,IAAI,eAAe,UAAU;EAC5C,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,eAC/B;EAGF,MAAM,aACJ,cACA;GACE;GACA,UAAU;GACV;GACA,KAAK,IAAI;GACT,WAAW,KAAK,IAAI;EACtB,GACA;GACE,cAAc,QAAQ;GACtB,eAAe,QAAQ;EACzB,CACF;CACF,CAAC;CAED,GAAG,GAAG,oBAAoB,OAAO,OAAO,QAAQ;EAC9C,IAAI,IAAI,eAAe,aAAa,MAAM,iBACxC;EAEF,MAAM,gBAAgB;EACtB,WAAW,KAAA;EACX,kBAAkB,KAAA;EAClB,mBAAmB,MAAM;EACzB,oBAAoB,KAAA;EACpB,MAAM,QAAQ,IAAI,CAAC,eAAe,MAAM,GAAG,WAAW,KAAK,KAAK,CAAC,CAAC;CACpE,CAAC;AACH"}
@@ -0,0 +1,10 @@
1
+ import { A as probePiSession, E as parseEnvelope, F as sendUserMessage, I as socketPathForSession, L as startReceiver, M as sendEnvelope, S as UserMessageResponse, b as UserMessageInput, c as ProbeOptions, d as SenderOptions, i as CHILD_ENV, k as parseUserMessageRequest, l as Receiver, o as DelegateSettledEnvelope, s as PARENT_SESSION_ENV, u as ReceiverOptions, v as TASK_SLUG_ENV, w as eventKey, x as UserMessageRequest } from "./protocol-CsrnSPOv.js";
2
+ import { n as OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE, o as truncatePiJqOutput } from "./notification-DzOd9cRc.js";
3
+ import { d as piSessionStatusSchema, i as PiSessionStatusWriter, l as parsePiSessionStatus, o as createPiSessionStatusWriter, r as PiSessionStatusUpdate, s as isLocalPidAlive, t as PiSessionStatus, u as piSessionStatusPath } from "./session-status-CZLTo8Km.js";
4
+ import { a as LiveEventWireRecord, c as compactAssistantMessageEvent, d as liveEventStreamPath, f as parseLiveEventRecord, i as LiveEventRecord, l as createLiveEventWriter, n as LiveEventEnvelope, o as LiveEventWriter, r as LiveEventPayload, s as PROCESS_INSTANCE_ID, t as CompactAssistantMessageEvent, u as liveEventSessionDir } from "./live-events-DAmf6RRx.js";
5
+ import { OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE, OvermuxPiOptions, overmuxPi } from "./extension.js";
6
+ //#region src/index.d.ts
7
+ declare const _default: (pi: Parameters<typeof overmuxPi>[0]) => void;
8
+ //#endregion
9
+ export { CHILD_ENV, type CompactAssistantMessageEvent, type DelegateSettledEnvelope, type LiveEventEnvelope, type LiveEventPayload, type LiveEventRecord, type LiveEventWireRecord, type LiveEventWriter, OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE, OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE, OvermuxPiOptions, PARENT_SESSION_ENV, PROCESS_INSTANCE_ID, type PiSessionStatus, type PiSessionStatusUpdate, type PiSessionStatusWriter, type ProbeOptions, type Receiver, type ReceiverOptions, type SenderOptions, TASK_SLUG_ENV, type UserMessageInput, type UserMessageRequest, type UserMessageResponse, compactAssistantMessageEvent, createLiveEventWriter, createPiSessionStatusWriter, _default as default, eventKey, isLocalPidAlive, liveEventSessionDir, liveEventStreamPath, overmuxPi, parseEnvelope, parseLiveEventRecord, parsePiSessionStatus, parseUserMessageRequest, piSessionStatusPath, piSessionStatusSchema, probePiSession, sendEnvelope, sendUserMessage, socketPathForSession, startReceiver, truncatePiJqOutput };
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;cAYgB,WAAA,IAAI,kBAAkB"}
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ import { CHILD_ENV, PARENT_SESSION_ENV, TASK_SLUG_ENV, eventKey, parseEnvelope, parseUserMessageRequest, probePiSession, sendEnvelope, sendUserMessage, socketPathForSession, startReceiver } from "./protocol.js";
2
+ import { OvermuxPiConfigSchema } from "./config.js";
3
+ import { a as liveEventStreamPath, f as parsePiSessionStatus, i as liveEventSessionDir, l as createPiSessionStatusWriter, m as piSessionStatusSchema, n as compactAssistantMessageEvent, o as parseLiveEventRecord, p as piSessionStatusPath, r as createLiveEventWriter, t as PROCESS_INSTANCE_ID, u as isLocalPidAlive } from "./live-events-ClhFOMGW.js";
4
+ import { OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE, truncatePiJqOutput } from "./notification.js";
5
+ import { OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE, overmuxPi } from "./extension.js";
6
+ import { loadConfigOrDefault } from "@richardgill/pi-config";
7
+ //#region src/index.ts
8
+ const config = loadConfigOrDefault({
9
+ filename: "overmux-pi.jsonc",
10
+ schema: OvermuxPiConfigSchema
11
+ });
12
+ var src_default = (pi) => overmuxPi(pi, config);
13
+ //#endregion
14
+ export { CHILD_ENV, OVERMUX_PI_DELEGATE_SETTLED_MESSAGE_TYPE, OVERMUX_PI_DELEGATE_SETTLED_RECEIPT_TYPE, PARENT_SESSION_ENV, PROCESS_INSTANCE_ID, TASK_SLUG_ENV, compactAssistantMessageEvent, createLiveEventWriter, createPiSessionStatusWriter, src_default as default, eventKey, isLocalPidAlive, liveEventSessionDir, liveEventStreamPath, overmuxPi, parseEnvelope, parseLiveEventRecord, parsePiSessionStatus, parseUserMessageRequest, piSessionStatusPath, piSessionStatusSchema, probePiSession, sendEnvelope, sendUserMessage, socketPathForSession, startReceiver, truncatePiJqOutput };
15
+
16
+ //# sourceMappingURL=index.js.map