@introspection-ai/recipes 0.63.1 → 0.65.0

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 (147) hide show
  1. package/dist/agent-tool/arguments.d.ts +39 -0
  2. package/dist/agent-tool/arguments.d.ts.map +1 -0
  3. package/dist/agent-tool/arguments.generated.d.ts +4 -0
  4. package/dist/agent-tool/arguments.generated.d.ts.map +1 -0
  5. package/dist/agent-tool/arguments.generated.js +60 -0
  6. package/dist/agent-tool/arguments.generated.js.map +1 -0
  7. package/dist/agent-tool/arguments.js +8 -0
  8. package/dist/agent-tool/arguments.js.map +1 -0
  9. package/dist/agents.d.ts +28 -6
  10. package/dist/agents.d.ts.map +1 -1
  11. package/dist/agents.js +280 -47
  12. package/dist/agents.js.map +1 -1
  13. package/dist/api-bindings.d.ts.map +1 -1
  14. package/dist/api-bindings.js +2 -2
  15. package/dist/api-bindings.js.map +1 -1
  16. package/dist/artifact-review-tui.js +1 -1
  17. package/dist/artifact-review-tui.js.map +1 -1
  18. package/dist/artifact-viewer-tui.js +1 -1
  19. package/dist/artifact-viewer-tui.js.map +1 -1
  20. package/dist/artifact-viewer.d.ts.map +1 -1
  21. package/dist/artifact-viewer.js +3 -3
  22. package/dist/artifact-viewer.js.map +1 -1
  23. package/dist/batch/agent-batches.d.ts +53 -0
  24. package/dist/batch/agent-batches.d.ts.map +1 -0
  25. package/dist/batch/agent-batches.js +168 -0
  26. package/dist/batch/agent-batches.js.map +1 -0
  27. package/dist/batch/index.d.ts +2 -0
  28. package/dist/batch/index.d.ts.map +1 -1
  29. package/dist/batch/index.js +2 -1
  30. package/dist/batch/index.js.map +1 -1
  31. package/dist/batch/lines.d.ts.map +1 -1
  32. package/dist/batch/lines.js +4 -2
  33. package/dist/batch/lines.js.map +1 -1
  34. package/dist/child/agent-completions.d.ts +16 -1
  35. package/dist/child/agent-completions.d.ts.map +1 -1
  36. package/dist/child/agent-completions.js +31 -5
  37. package/dist/child/agent-completions.js.map +1 -1
  38. package/dist/child/agent-store.d.ts +2 -0
  39. package/dist/child/agent-store.d.ts.map +1 -1
  40. package/dist/child/agent-store.js.map +1 -1
  41. package/dist/child/agent.d.ts +9 -0
  42. package/dist/child/agent.d.ts.map +1 -1
  43. package/dist/child/agent.js +7 -0
  44. package/dist/child/agent.js.map +1 -1
  45. package/dist/child/arguments.d.ts +32 -0
  46. package/dist/child/arguments.d.ts.map +1 -0
  47. package/dist/child/arguments.generated.d.ts +4 -0
  48. package/dist/child/arguments.generated.d.ts.map +1 -0
  49. package/dist/child/arguments.generated.js +29 -0
  50. package/dist/child/arguments.generated.js.map +1 -0
  51. package/dist/child/arguments.js +8 -0
  52. package/dist/child/arguments.js.map +1 -0
  53. package/dist/child/inboxes.d.ts +21 -0
  54. package/dist/child/inboxes.d.ts.map +1 -0
  55. package/dist/child/inboxes.js +35 -0
  56. package/dist/child/inboxes.js.map +1 -0
  57. package/dist/child/messages.d.ts +202 -0
  58. package/dist/child/messages.d.ts.map +1 -0
  59. package/dist/child/messages.js +490 -0
  60. package/dist/child/messages.js.map +1 -0
  61. package/dist/child/run-processes.d.ts +14 -0
  62. package/dist/child/run-processes.d.ts.map +1 -0
  63. package/dist/child/run-processes.js +101 -0
  64. package/dist/child/run-processes.js.map +1 -0
  65. package/dist/child/session.d.ts +10 -0
  66. package/dist/child/session.d.ts.map +1 -1
  67. package/dist/child/session.js +34 -3
  68. package/dist/child/session.js.map +1 -1
  69. package/dist/child/streaming-usage.d.ts +40 -0
  70. package/dist/child/streaming-usage.d.ts.map +1 -0
  71. package/dist/child/streaming-usage.js +101 -0
  72. package/dist/child/streaming-usage.js.map +1 -0
  73. package/dist/documents/python.d.ts.map +1 -1
  74. package/dist/documents/python.js +2 -2
  75. package/dist/documents/python.js.map +1 -1
  76. package/dist/judges/cli-main.d.ts.map +1 -1
  77. package/dist/judges/cli-main.js +1 -1
  78. package/dist/judges/cli-main.js.map +1 -1
  79. package/dist/judges/run.d.ts.map +1 -1
  80. package/dist/judges/run.js +6 -2
  81. package/dist/judges/run.js.map +1 -1
  82. package/dist/judges/verdict.d.ts.map +1 -1
  83. package/dist/judges/verdict.js +1 -1
  84. package/dist/judges/verdict.js.map +1 -1
  85. package/dist/mcp/contract.d.ts.map +1 -1
  86. package/dist/mcp/contract.js +1 -3
  87. package/dist/mcp/contract.js.map +1 -1
  88. package/dist/mcp/daemon/client.d.ts.map +1 -1
  89. package/dist/mcp/daemon/client.js +1 -2
  90. package/dist/mcp/daemon/client.js.map +1 -1
  91. package/dist/mcp/pi-mcp-runtime.js +2 -2
  92. package/dist/mcp/pi-mcp-runtime.js.map +1 -1
  93. package/dist/mcp/pi-runtime.d.ts +3 -3
  94. package/dist/mcp/pi-runtime.d.ts.map +1 -1
  95. package/dist/mcp/pi-runtime.js +11 -20
  96. package/dist/mcp/pi-runtime.js.map +1 -1
  97. package/dist/mcp/tools.d.ts.map +1 -1
  98. package/dist/mcp/tools.js +1 -1
  99. package/dist/mcp/tools.js.map +1 -1
  100. package/dist/mcp-chunks/{chunk-OHAXEQ22.js → chunk-N6QLCGHR.js} +2 -2
  101. package/dist/mcp-chunks/{chunk-3UONQ24E.js → chunk-WVHEDCS6.js} +6 -4
  102. package/dist/mcp-chunks/chunk-ZH6FNTNJ.js +34 -0
  103. package/dist/mcp-chunks/{pi-mcp-runtime-V2OMZAIR.js → pi-mcp-runtime-W5OLELOO.js} +34 -27
  104. package/dist/mcp-chunks/{server-6DQUPUFW.js → server-UZ5OMTWP.js} +3 -3
  105. package/dist/mcp-daemon.js +3 -3
  106. package/dist/mcp-run-worker.js +2 -2
  107. package/dist/pi-extension.d.ts +2 -0
  108. package/dist/pi-extension.d.ts.map +1 -1
  109. package/dist/pi-extension.js +241 -43
  110. package/dist/pi-extension.js.map +1 -1
  111. package/dist/recipe/manifest.generated.d.ts +1 -1
  112. package/dist/recipe/manifest.generated.js +1 -1
  113. package/dist/recipe/package.d.ts +2 -0
  114. package/dist/recipe/package.d.ts.map +1 -1
  115. package/dist/recipe/package.js +15 -21
  116. package/dist/recipe/package.js.map +1 -1
  117. package/dist/recipe/python.d.ts.map +1 -1
  118. package/dist/recipe/python.js +8 -5
  119. package/dist/recipe/python.js.map +1 -1
  120. package/dist/run-controller.d.ts +5 -0
  121. package/dist/run-controller.d.ts.map +1 -1
  122. package/dist/run-controller.js +89 -12
  123. package/dist/run-controller.js.map +1 -1
  124. package/dist/session.d.ts +14 -0
  125. package/dist/session.d.ts.map +1 -1
  126. package/dist/session.js +21 -3
  127. package/dist/session.js.map +1 -1
  128. package/dist/shell-quote.d.ts +3 -0
  129. package/dist/shell-quote.d.ts.map +1 -0
  130. package/dist/shell-quote.js +5 -0
  131. package/dist/shell-quote.js.map +1 -0
  132. package/dist/skill-progress.d.ts +12 -1
  133. package/dist/skill-progress.d.ts.map +1 -1
  134. package/dist/skill-progress.js +11 -4
  135. package/dist/skill-progress.js.map +1 -1
  136. package/docs/agent-batch.md +87 -0
  137. package/docs/agent-composition.md +49 -19
  138. package/docs/batch.md +7 -0
  139. package/docs/documents/README.md +1 -1
  140. package/docs/mcp-auth.md +2 -1
  141. package/docs/mcp-configuration.md +2 -3
  142. package/docs/productivity/google.md +27 -15
  143. package/docs/recipe-format.md +4 -4
  144. package/package.json +15 -14
  145. package/python/shared/pyproject.toml +2 -2
  146. package/python/shared/uv.lock +30 -30
  147. package/dist/mcp-chunks/chunk-V65N6VX7.js +0 -33
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arguments.d.ts","sourceRoot":"","sources":["../../src/child/arguments.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yEAAyE;AACzE,UAAU,gBAAgB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,gGAAgG;IAChG,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC1C;;;OAGG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B"}
@@ -0,0 +1,4 @@
1
+ import type { ArgumentsSchema } from "../command-parameters.js";
2
+ import type { SendMessageArguments } from "./arguments.js";
3
+ export declare const SEND_MESSAGE_ARGUMENTS: ArgumentsSchema<SendMessageArguments>;
4
+ //# sourceMappingURL=arguments.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arguments.generated.d.ts","sourceRoot":"","sources":["../../src/child/arguments.generated.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,eAAO,MAAM,sBAAsB,EA8B9B,eAAe,CAAC,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,29 @@
1
+ export const SEND_MESSAGE_ARGUMENTS = {
2
+ type: "object",
3
+ properties: {
4
+ to: {
5
+ type: "string",
6
+ description: 'Who to message: "root" for the agent that started this work, or another run\'s name or id.',
7
+ },
8
+ message: { type: "string", description: "What to tell them." },
9
+ deliver: {
10
+ type: "string",
11
+ enum: ["steer", "followUp", "status"],
12
+ description: '"steer" (default): something they must act on soon. "followUp": a milestone that can wait until they finish their current work. "status": a one-line progress note shown to the person in place of your current command, never to them; `to` is ignored.',
13
+ },
14
+ usage: {
15
+ type: "object",
16
+ properties: {
17
+ input: { type: "number" },
18
+ output: { type: "number" },
19
+ cost: { type: "number", description: "USD." },
20
+ },
21
+ required: ["input", "output", "cost"],
22
+ additionalProperties: false,
23
+ description: 'With deliver "status" only: the running total of tokens and cost of work you ran elsewhere, such as cloud trials, not your own model calls. Each status replaces the last total.',
24
+ },
25
+ },
26
+ required: ["to", "message"],
27
+ additionalProperties: false,
28
+ };
29
+ //# sourceMappingURL=arguments.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arguments.generated.js","sourceRoot":"","sources":["../../src/child/arguments.generated.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE;YACF,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,4FAA4F;SAC/F;QACD,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oBAAoB,EAAE;QAC9D,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC;YACrC,WAAW,EACT,0PAA0P;SAC7P;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;aAC9C;YACD,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC;YACrC,oBAAoB,EAAE,KAAK;YAC3B,WAAW,EACT,kLAAkL;SACrL;KACF;IACD,QAAQ,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC;IAC3B,oBAAoB,EAAE,KAAK;CACa,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The arguments `send_message` takes, as the model sees them.
3
+ * `scripts/generate-tool-schemas.mjs` turns `SendMessageArguments` into the
4
+ * JSON Schema in `arguments.generated.ts`: a field's doc comment is its
5
+ * description.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=arguments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arguments.js","sourceRoot":"","sources":["../../src/child/arguments.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,21 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import { AgentInbox } from "./messages.js";
3
+ /** A run's inbox, handing messages to its runner; it holds them until the session is up. */
4
+ export declare function createRunnerInbox(runner: () => {
5
+ steer(text: string): Promise<void>;
6
+ followUp(text: string): Promise<void>;
7
+ }): AgentInbox;
8
+ /** Root's inbox, handing messages to the root session through Pi's sendMessage. */
9
+ export interface RootInbox {
10
+ inbox: AgentInbox;
11
+ /** Start a turn for what root holds, once it is idle; see `AgentInbox.flush`. */
12
+ flush(): Promise<void>;
13
+ }
14
+ export declare function createRootInbox(deps: {
15
+ /** Pi's API, once the extension is up. */
16
+ api: () => Pick<ExtensionAPI, "sendMessage"> | undefined;
17
+ session: () => Pick<ExtensionContext, "isIdle"> | null;
18
+ /** Root's idle-gated delivery. */
19
+ onHeld: () => void;
20
+ }): RootInbox;
21
+ //# sourceMappingURL=inboxes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inboxes.d.ts","sourceRoot":"","sources":["../../src/child/inboxes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,UAAU,EAEX,MAAM,eAAe,CAAC;AAEvB,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM;IACZ,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC,GACA,UAAU,CAWZ;AAED,mFAAmF;AACnF,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,UAAU,CAAC;IAClB,iFAAiF;IACjF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,0CAA0C;IAC1C,GAAG,EAAE,MAAM,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,SAAS,CAAC;IACzD,OAAO,EAAE,MAAM,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;IACvD,kCAAkC;IAClC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,GAAG,SAAS,CAyBZ"}
@@ -0,0 +1,35 @@
1
+ import { AGENT_RUN_MESSAGE_TYPE, AgentInbox, renderAgentMessage, } from "./messages.js";
2
+ /** A run's inbox, handing messages to its runner; it holds them until the session is up. */
3
+ export function createRunnerInbox(runner) {
4
+ return new AgentInbox(async (batch, deliver) => {
5
+ for (const message of batch) {
6
+ const text = renderAgentMessage(message);
7
+ if (deliver === "followUp")
8
+ await runner().followUp(text);
9
+ else
10
+ await runner().steer(text);
11
+ }
12
+ }, { phase: "starting" });
13
+ }
14
+ export function createRootInbox(deps) {
15
+ const inbox = new AgentInbox(async (batch, deliver) => {
16
+ for (const message of batch)
17
+ deps.api()?.sendMessage({
18
+ customType: AGENT_RUN_MESSAGE_TYPE,
19
+ content: renderAgentMessage(message),
20
+ display: true,
21
+ details: message,
22
+ },
23
+ // An idle root starts a turn with it; a streaming one queues it as `deliver` says.
24
+ { triggerTurn: true, deliverAs: deliver });
25
+ }, {
26
+ phase: "idle",
27
+ onHeld: deps.onHeld,
28
+ canStartTurn: () => deps.session()?.isIdle?.() ?? true,
29
+ });
30
+ return {
31
+ inbox,
32
+ flush: () => inbox.flush(),
33
+ };
34
+ }
35
+ //# sourceMappingURL=inboxes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inboxes.js","sourceRoot":"","sources":["../../src/child/inboxes.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,sBAAsB,EACtB,UAAU,EACV,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAEvB,4FAA4F;AAC5F,MAAM,UAAU,iBAAiB,CAC/B,MAGC;IAED,OAAO,IAAI,UAAU,CACnB,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACvB,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACzC,IAAI,OAAO,KAAK,UAAU;gBAAE,MAAM,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;;gBACrD,MAAM,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC;IACH,CAAC,EACD,EAAE,KAAK,EAAE,UAAU,EAAE,CACtB,CAAC;AACJ,CAAC;AASD,MAAM,UAAU,eAAe,CAAC,IAM/B;IACC,MAAM,KAAK,GAAG,IAAI,UAAU,CAC1B,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACvB,KAAK,MAAM,OAAO,IAAI,KAAK;YACzB,IAAI,CAAC,GAAG,EAAE,EAAE,WAAW,CACrB;gBACE,UAAU,EAAE,sBAAsB;gBAClC,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC;gBACpC,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,OAAO;aACjB;YACD,mFAAmF;YACnF,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAC1C,CAAC;IACN,CAAC,EACD;QACE,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,IAAI;KACvD,CACF,CAAC;IACF,OAAO;QACL,KAAK;QACL,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE;KAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Messages between the agents of one Pi session: the root agent and the runs
3
+ * it started, at every depth. A run sends one with `send_message`, naming its
4
+ * recipient as `root` or another run's name (its label) or id, as Claude
5
+ * Code's teammates use `SendMessage`.
6
+ *
7
+ * A message reaches an agent that is waiting on its runs at once, whichever
8
+ * run it waits on: Pi delivers a steer only after the current tool call ends,
9
+ * and an `agent` wait blocks until its run settles, so a steer to a waiting
10
+ * agent would never arrive. Otherwise it is steered into the agent's turn, or
11
+ * starts one.
12
+ */
13
+ import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
14
+ /** Pi custom message type of a message delivered to the root agent. */
15
+ export declare const AGENT_RUN_MESSAGE_TYPE = "agent_run_message";
16
+ /** The name the root agent is addressed by. */
17
+ export declare const ROOT_AGENT = "root";
18
+ /** A message one agent sent another. */
19
+ export interface AgentRunMessage {
20
+ /** The sender's name: its run label, or `root`. */
21
+ from: string;
22
+ /** The sender's run id, `root` for the root agent. */
23
+ fromId: string;
24
+ text: string;
25
+ /**
26
+ * How it reaches an agent that is not waiting: `steer`, before its next
27
+ * model call, or `followUp`, once it finishes its current work. A wait in
28
+ * progress takes either at once.
29
+ */
30
+ deliver: AgentMessageDelivery;
31
+ /** Its place in the recipient's inbox, set when the inbox accepts it: what tells two equal texts apart. */
32
+ id?: number;
33
+ }
34
+ /** The ways a message can reach an agent that is not waiting. */
35
+ export type AgentMessageDelivery = "steer" | "followUp";
36
+ /**
37
+ * A run's own progress note, from `send_message` with `deliver: "status"`: shown
38
+ * on its line for the person, never to an agent. `usage` is the running total
39
+ * of work it ran elsewhere, such as cloud trials, apart from its own model calls.
40
+ */
41
+ export interface AgentStatusNote {
42
+ text: string;
43
+ usage?: ReportedUsage;
44
+ }
45
+ /** Usage a run reports for work it ran elsewhere; each report replaces the last. */
46
+ export interface ReportedUsage {
47
+ input_tokens: number;
48
+ output_tokens: number;
49
+ cost_usd: number;
50
+ }
51
+ /** The model-facing text of a delivered message. */
52
+ export declare function renderAgentMessage(message: AgentRunMessage): string;
53
+ /** Several messages, in the order they were sent. */
54
+ export declare function renderAgentMessages(messages: readonly AgentRunMessage[]): string;
55
+ /** Where an inbox hands messages: the agent's session. */
56
+ export type InboxSend = (messages: readonly AgentRunMessage[], deliver: AgentMessageDelivery) => Promise<void>;
57
+ /** What an inbox can see of its session's own queue. */
58
+ export interface InboxSessionQueue {
59
+ /** Whether the session holds messages it was handed and has not read. */
60
+ unread(): boolean;
61
+ /** Empty the session's queue, returning the texts it held unread; absent where it cannot. */
62
+ takeBack?(): readonly string[];
63
+ }
64
+ /** A wait in progress on an inbox. */
65
+ export interface InboxWait {
66
+ /** Resolves when a message comes for this wait, or its signal aborts. */
67
+ arrived: Promise<void>;
68
+ /**
69
+ * End the wait: its result, in send order. With `keep`, the wait failed: what it
70
+ * took stays in the inbox, put back in the same command, so nothing overtakes it.
71
+ */
72
+ end(options?: {
73
+ keep?: boolean;
74
+ }): Promise<AgentRunMessage[]>;
75
+ }
76
+ /** Where an agent is, as its inbox sees it. */
77
+ export type InboxPhase = "starting" | "idle" | "busy" | "waiting" | "closed";
78
+ /**
79
+ * One agent's incoming messages: the only way a message reaches its session.
80
+ * Every operation is a command applied in arrival order, so messages reach the
81
+ * agent in the order they were sent. Modelled in specs/agents/Inbox.tla.
82
+ *
83
+ * - starting: held, and given with the first prompt.
84
+ * - waiting: held, and the wait ends with them.
85
+ * - busy: a steer goes to the session now, behind what is held; a follow-up is held.
86
+ * - idle: held for the turn its owner starts (`onHeld` says one is due).
87
+ * - closed: refused.
88
+ */
89
+ export declare class AgentInbox {
90
+ private phase;
91
+ private beforeWait;
92
+ private readonly held;
93
+ private handed;
94
+ private finished;
95
+ private queue;
96
+ private accepted;
97
+ private readonly waits;
98
+ private calls;
99
+ private requeued;
100
+ private session;
101
+ private readonly send;
102
+ private readonly onHeld;
103
+ private readonly canStartTurn;
104
+ /**
105
+ * `onHeld`: an idle agent holds a message; its owner should start a turn.
106
+ * `canStartTurn`: whether the session is idle, for an agent whose turns the inbox
107
+ * follows from its session rather than being told (root), and may start itself.
108
+ */
109
+ constructor(send: InboxSend, options?: {
110
+ phase?: "starting" | "idle" | "busy";
111
+ onHeld?: () => void;
112
+ canStartTurn?: () => boolean;
113
+ });
114
+ /** Where the agent is. */
115
+ get state(): InboxPhase;
116
+ /** The session read a message it was handed (root: Pi's `message_end` for it). */
117
+ read(message: AgentRunMessage): void;
118
+ private unread;
119
+ /** Let the inbox see the session's queue once the session exists. */
120
+ attach(session: InboxSessionQueue): void;
121
+ private followSession;
122
+ private command;
123
+ private take;
124
+ private hold;
125
+ private hand;
126
+ /** Accept a message; refused once the agent is closed. */
127
+ deliver(sent: AgentRunMessage): Promise<void>;
128
+ /** The session is up and its first turn starts: what is held, for its prompt. */
129
+ started(): Promise<AgentRunMessage[]>;
130
+ /**
131
+ * A turn starts: what is held opens it, behind what the session was handed
132
+ * and has not read, which it takes back so the prompt keeps send order.
133
+ */
134
+ turnStarted(): Promise<AgentRunMessage[]>;
135
+ private takeBackUnread;
136
+ /**
137
+ * The turn is over. What the session was handed and did not read is taken back
138
+ * among what is held, in send order; returns what is held, for the turn the owner starts next.
139
+ * `unsent` is what the turn opened with but never prompted, as when it stopped first.
140
+ */
141
+ turnEnded(unsent?: readonly AgentRunMessage[]): Promise<AgentRunMessage[]>;
142
+ /** Root's idle delivery: once its session is idle, start a turn for what is held. */
143
+ flush(): Promise<void>;
144
+ /**
145
+ * A wait starts. `arrived` resolves when a message comes for it, or once
146
+ * `signal` aborts; the wait ends only through its own `end`.
147
+ */
148
+ waitStarted(signal?: AbortSignal): InboxWait;
149
+ /**
150
+ * A wait is over, however it ended: its result is what came for it. Pi reads
151
+ * a batch's results in call order, so what is held when the last wait ends
152
+ * joins the newest wait's result, or else follows the batch. When the session
153
+ * still has an older message to read, a result goes to it as steers behind
154
+ * that one instead, and comes back empty.
155
+ */
156
+ private waitEnded;
157
+ /**
158
+ * The agent's loop would finish: what is held, to carry on with, or none, and
159
+ * the inbox closes, so nothing is accepted that would never be read.
160
+ */
161
+ finish(): Promise<AgentRunMessage[]>;
162
+ /** A finished run is resumed: it holds what arrives until its next turn opens. */
163
+ resume(): Promise<void>;
164
+ /** The run closed: nothing more is accepted. Returns what it held, never read. */
165
+ close(): Promise<AgentRunMessage[]>;
166
+ /** How many messages it holds, its waits' included, none of them handed over yet. */
167
+ holding(): number;
168
+ /** Whether messages are held. */
169
+ needsTurn(): boolean;
170
+ }
171
+ /** An agent that can receive messages. */
172
+ export interface AgentMessageRecipient {
173
+ /** Run id, or `root`. */
174
+ id: string;
175
+ /** The name it is addressed by: its run label, or `root`. */
176
+ name?: string;
177
+ inbox: AgentInbox;
178
+ /** Whether it can take a message now: a settled run cannot. */
179
+ accepting(): boolean;
180
+ /** Show the note on this agent's line, in place of the tool it is in. Root has none. */
181
+ setStatus?(note: AgentStatusNote): void;
182
+ }
183
+ /** Every agent of a session that can be messaged, by id and by name. */
184
+ export declare class AgentMessageBus {
185
+ private readonly byId;
186
+ private readonly byName;
187
+ /** Whether a live agent already goes by `name`. */
188
+ hasName(name: string): boolean;
189
+ /** Add an agent; a name already in use is refused. Returns its removal. */
190
+ register(recipient: AgentMessageRecipient): () => void;
191
+ /** The line a run's system prompt carries so it knows how it is addressed. */
192
+ introduce(id: string): string;
193
+ /** The name a sender signs a message with: its name, else its id. */
194
+ nameOf(id: string): string;
195
+ /** Set the agent `id`'s own status note; it reaches no other agent. */
196
+ setStatus(id: string, note: AgentStatusNote): void;
197
+ /** Send `text` from the agent `fromId` to `to`, a name or a run id. */
198
+ send(fromId: string, to: string, text: string, deliver?: AgentMessageDelivery): Promise<string>;
199
+ }
200
+ /** The `send_message` tool of the agent `senderId`. */
201
+ export declare function createSendMessageTool(bus: AgentMessageBus, senderId: string): ToolDefinition;
202
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/child/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,iCAAiC,CAAC;AAKzC,uEAAuE;AACvE,eAAO,MAAM,sBAAsB,sBAAsB,CAAC;AAE1D,+CAA+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