@introspection-ai/recipes 0.55.0 → 0.57.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 (190) hide show
  1. package/dist/artifact-links.d.ts +25 -0
  2. package/dist/artifact-links.d.ts.map +1 -0
  3. package/dist/artifact-links.js +92 -0
  4. package/dist/artifact-links.js.map +1 -0
  5. package/dist/artifact-viewer-tui.d.ts +2 -1
  6. package/dist/artifact-viewer-tui.d.ts.map +1 -1
  7. package/dist/artifact-viewer-tui.js.map +1 -1
  8. package/dist/artifact-viewer.d.ts +2 -1
  9. package/dist/artifact-viewer.d.ts.map +1 -1
  10. package/dist/artifact-viewer.js +49 -3
  11. package/dist/artifact-viewer.js.map +1 -1
  12. package/dist/artifact.d.ts +5 -4
  13. package/dist/artifact.d.ts.map +1 -1
  14. package/dist/artifact.js +4 -1
  15. package/dist/artifact.js.map +1 -1
  16. package/dist/batch/files.d.ts +16 -0
  17. package/dist/batch/files.d.ts.map +1 -0
  18. package/dist/batch/files.js +58 -0
  19. package/dist/batch/files.js.map +1 -0
  20. package/dist/batch/index.d.ts +67 -0
  21. package/dist/batch/index.d.ts.map +1 -0
  22. package/dist/batch/index.js +109 -0
  23. package/dist/batch/index.js.map +1 -0
  24. package/dist/batch/limiter.d.ts +20 -0
  25. package/dist/batch/limiter.d.ts.map +1 -0
  26. package/dist/batch/limiter.js +54 -0
  27. package/dist/batch/limiter.js.map +1 -0
  28. package/dist/batch/lines.d.ts +58 -0
  29. package/dist/batch/lines.d.ts.map +1 -0
  30. package/dist/batch/lines.js +77 -0
  31. package/dist/batch/lines.js.map +1 -0
  32. package/dist/batch/params.d.ts +30 -0
  33. package/dist/batch/params.d.ts.map +1 -0
  34. package/dist/batch/params.js +48 -0
  35. package/dist/batch/params.js.map +1 -0
  36. package/dist/batch/runner.d.ts +77 -0
  37. package/dist/batch/runner.d.ts.map +1 -0
  38. package/dist/batch/runner.js +240 -0
  39. package/dist/batch/runner.js.map +1 -0
  40. package/dist/batch/shards.d.ts +42 -0
  41. package/dist/batch/shards.d.ts.map +1 -0
  42. package/dist/batch/shards.js +115 -0
  43. package/dist/batch/shards.js.map +1 -0
  44. package/dist/child/agent.d.ts.map +1 -1
  45. package/dist/child/agent.js +6 -5
  46. package/dist/child/agent.js.map +1 -1
  47. package/dist/child/session.d.ts +1 -0
  48. package/dist/child/session.d.ts.map +1 -1
  49. package/dist/child/session.js +9 -6
  50. package/dist/child/session.js.map +1 -1
  51. package/dist/mcp/daemon/server.d.ts +0 -2
  52. package/dist/mcp/daemon/server.d.ts.map +1 -1
  53. package/dist/mcp/daemon/server.js +1 -1
  54. package/dist/mcp/daemon/server.js.map +1 -1
  55. package/dist/mcp-chunks/{auth-command-PZLSOYAT.js → auth-command-WE7QY6RH.js} +27 -27
  56. package/dist/mcp-chunks/call-arguments-2ABANGLE.js +16 -0
  57. package/dist/mcp-chunks/{call-command-VILJIFYG.js → call-command-OOBUGVTM.js} +56 -70
  58. package/dist/mcp-chunks/{chunk-N2U2FODH.js → chunk-2PTK6KBV.js} +4 -4
  59. package/dist/mcp-chunks/{chunk-F2X4Y2TQ.js → chunk-2R2HWX2E.js} +1 -1
  60. package/dist/mcp-chunks/{chunk-ORJND4AI.js → chunk-2R7UGABC.js} +70 -70
  61. package/dist/mcp-chunks/{chunk-US63Y6XE.js → chunk-32UZRZIL.js} +1 -1
  62. package/dist/mcp-chunks/{chunk-THRMUZZD.js → chunk-37VJZIFW.js} +8 -8
  63. package/dist/mcp-chunks/{chunk-5Z6WSV5D.js → chunk-3KSDZBUJ.js} +5 -5
  64. package/dist/mcp-chunks/{chunk-JTPTAO4M.js → chunk-44KI6DPL.js} +24 -15
  65. package/dist/mcp-chunks/{chunk-BHXCAVFP.js → chunk-4ACA5GWL.js} +1 -1
  66. package/dist/mcp-chunks/{chunk-E76ZUBOJ.js → chunk-4NABHXDS.js} +4 -4
  67. package/dist/mcp-chunks/{chunk-AJDK5Z7O.js → chunk-4SO2DY7F.js} +2 -3
  68. package/dist/mcp-chunks/{chunk-I6UFV7RW.js → chunk-5ZQKSEUN.js} +1 -1
  69. package/dist/mcp-chunks/{chunk-KZGUH7E2.js → chunk-73TMUGJL.js} +2039 -1148
  70. package/dist/mcp-chunks/{chunk-UVRJ3AAD.js → chunk-7KOGD2JK.js} +2 -2
  71. package/dist/mcp-chunks/{chunk-KJ5FPQF6.js → chunk-7SQZWTDU.js} +30 -26
  72. package/dist/mcp-chunks/{chunk-MYAMG6VL.js → chunk-ABPXAKP7.js} +89 -28
  73. package/dist/mcp-chunks/{chunk-2YV72LUA.js → chunk-AIUZOMBB.js} +12 -12
  74. package/dist/mcp-chunks/{chunk-V42T3QNK.js → chunk-BI6L3SYV.js} +9 -9
  75. package/dist/mcp-chunks/{chunk-757ZF552.js → chunk-CFRA424Y.js} +4 -4
  76. package/dist/mcp-chunks/{chunk-DU4SDPEV.js → chunk-CIQX62WO.js} +2 -2
  77. package/dist/mcp-chunks/{chunk-MHUMLEBO.js → chunk-CWM4RO33.js} +1 -1
  78. package/dist/mcp-chunks/{chunk-TUPFPO4L.js → chunk-DEYGZRBD.js} +5 -5
  79. package/dist/mcp-chunks/{chunk-3SXP4S2A.js → chunk-DL3GVI4M.js} +2 -2
  80. package/dist/mcp-chunks/{chunk-O7SIXJM6.js → chunk-EUHXZKP2.js} +108 -108
  81. package/dist/mcp-chunks/{chunk-H5PBSJP3.js → chunk-EV3SP7ME.js} +1 -1
  82. package/dist/mcp-chunks/chunk-EVEVCVYR.js +42 -0
  83. package/dist/mcp-chunks/{chunk-RUF27IUF.js → chunk-FDVES4CU.js} +2 -2
  84. package/dist/mcp-chunks/{chunk-L2MSWQDL.js → chunk-FJNWUAGR.js} +1 -1
  85. package/dist/mcp-chunks/{chunk-IWCVZ46B.js → chunk-G5DK4L6M.js} +2 -2
  86. package/dist/mcp-chunks/{chunk-3ETUDW7N.js → chunk-GQM53HF7.js} +1 -1
  87. package/dist/mcp-chunks/{chunk-2AKSS7WR.js → chunk-H44A4G2O.js} +2 -2
  88. package/dist/mcp-chunks/{chunk-WDWSA7RL.js → chunk-HGEKP2E5.js} +4 -4
  89. package/dist/mcp-chunks/{chunk-ELHS763C.js → chunk-HKMH4N3Z.js} +1 -1
  90. package/dist/mcp-chunks/{chunk-GZ53GNFP.js → chunk-HPFIAALB.js} +13 -10
  91. package/dist/mcp-chunks/chunk-KUJUYFDC.js +224 -0
  92. package/dist/mcp-chunks/{chunk-OIK5AH2S.js → chunk-MG6EVYIM.js} +41 -19
  93. package/dist/mcp-chunks/{chunk-QNXOIF5U.js → chunk-MSPGQEWX.js} +12 -12
  94. package/dist/mcp-chunks/{chunk-JEHI2YU4.js → chunk-MW3YO24Q.js} +3 -3
  95. package/dist/mcp-chunks/{chunk-WQL7FJQ3.js → chunk-NJR33E7V.js} +4 -4
  96. package/dist/mcp-chunks/{chunk-7U5NSQ5T.js → chunk-OSK2JGFH.js} +2 -2
  97. package/dist/mcp-chunks/{chunk-ZEA3Y5ZD.js → chunk-QHD5RXW4.js} +7 -7
  98. package/dist/mcp-chunks/{chunk-TC2JPBFB.js → chunk-QYR3UKJS.js} +7 -4
  99. package/dist/mcp-chunks/{chunk-3FRLDHVD.js → chunk-SYBDN4SV.js} +5 -5
  100. package/dist/mcp-chunks/{chunk-3P3KGT4H.js → chunk-TQ5T5VO7.js} +2 -2
  101. package/dist/mcp-chunks/{chunk-OWGTNJNR.js → chunk-TT3LOCMN.js} +2 -2
  102. package/dist/mcp-chunks/{chunk-3LENTPGE.js → chunk-TTVO6RCP.js} +2 -2
  103. package/dist/mcp-chunks/{chunk-IRSL7JRH.js → chunk-UY2QWZB3.js} +53 -49
  104. package/dist/mcp-chunks/{chunk-B6S43WID.js → chunk-VJ45Y5IO.js} +1 -1
  105. package/dist/mcp-chunks/{chunk-IRARVOUM.js → chunk-VJ5VDK6D.js} +1 -1
  106. package/dist/mcp-chunks/{chunk-6O42UGLI.js → chunk-VLJQSE6L.js} +9 -9
  107. package/dist/mcp-chunks/{chunk-HNQSUT44.js → chunk-W47YAN6W.js} +3 -3
  108. package/dist/mcp-chunks/{chunk-66VSGFXA.js → chunk-XU4D5QN2.js} +1 -1
  109. package/dist/mcp-chunks/{chunk-CXST5CVH.js → chunk-Y7JQJ352.js} +22 -18
  110. package/dist/mcp-chunks/{chunk-3HSC6NHZ.js → chunk-Y7UTXETL.js} +1 -1
  111. package/dist/mcp-chunks/{chunk-O3RTM5HD.js → chunk-YFPPHEDE.js} +1 -1
  112. package/dist/mcp-chunks/{chunk-N6YUOYDS.js → chunk-YGT57XUN.js} +2 -2
  113. package/dist/mcp-chunks/{chunk-BUOGKTKK.js → chunk-Z43KJRXY.js} +1 -1
  114. package/dist/mcp-chunks/{chunk-6P3KAQ5N.js → chunk-Z5XOB522.js} +1 -1
  115. package/dist/mcp-chunks/{chunk-63L6SHK3.js → chunk-ZEMVGFKG.js} +2 -2
  116. package/dist/mcp-chunks/{chunk-MEQXX43K.js → chunk-ZJZ53NIB.js} +1 -1
  117. package/dist/mcp-chunks/{cli-UQ5QXFXU.js → cli-TJFAYJO4.js} +81 -283
  118. package/dist/mcp-chunks/client-LDKUW5K5.js +32 -0
  119. package/dist/mcp-chunks/{config-command-ZSPJI34E.js → config-command-YGNK2VVL.js} +29 -29
  120. package/dist/mcp-chunks/daemon-command-UYAYRHVD.js +36 -0
  121. package/dist/mcp-chunks/dist-5JNZD3JV.js +69 -0
  122. package/dist/mcp-chunks/{dist-Q7WSCBBK.js → dist-IFOLXE2R.js} +351 -1305
  123. package/dist/mcp-chunks/{emit-ts-command-SY4LQE4S.js → emit-ts-command-4EVF6CIG.js} +28 -25
  124. package/dist/mcp-chunks/{generate-cli-runner-LQBBQ7F5.js → generate-cli-runner-UFVSXJVK.js} +58 -49
  125. package/dist/mcp-chunks/generated-daemon-runtime-LTH36X2R.js +32 -0
  126. package/dist/mcp-chunks/{inspect-cli-command-JPX4ON6N.js → inspect-cli-command-L3JGLLTG.js} +11 -11
  127. package/dist/mcp-chunks/{launch-UG7IH27P.js → launch-LUKDWKH4.js} +1 -1
  128. package/dist/mcp-chunks/{lifecycle-QBYGUHQ3.js → lifecycle-H57PYAZ5.js} +1 -1
  129. package/dist/mcp-chunks/{list-command-SDITI3ZM.js → list-command-QBO4LK5Q.js} +53 -42
  130. package/dist/mcp-chunks/logger-LvdykevT-BQ5B4N5O.js +995 -0
  131. package/dist/mcp-chunks/{output-utils-YTMZTA7J.js → output-utils-MB3PEV2M.js} +3 -3
  132. package/dist/mcp-chunks/{pi-mcp-runtime-OLO25D7A.js → pi-mcp-runtime-OIMIJV5A.js} +73 -17
  133. package/dist/mcp-chunks/{prompt-DkftHXS7-N7UENQ4C.js → prompt-DkftHXS7-TE2LNPAM.js} +1 -1
  134. package/dist/mcp-chunks/{record-command-JGTMATYI.js → record-command-RYDP3Y2A.js} +5 -5
  135. package/dist/mcp-chunks/{replay-command-S2VAC4RW.js → replay-command-QDJCQ5JU.js} +6 -6
  136. package/dist/mcp-chunks/{resource-command-SRFQQROJ.js → resource-command-RKHHQBFP.js} +9 -9
  137. package/dist/mcp-chunks/{result-utils-JASGNHXK.js → result-utils-ZD5GFX7P.js} +3 -3
  138. package/dist/mcp-chunks/runtime-F7PP4V25.js +39 -0
  139. package/dist/mcp-chunks/{runtime-wrapper-7HYO3NM5.js → runtime-wrapper-AV4JCNRF.js} +3 -3
  140. package/dist/mcp-chunks/{serve-command-YKSIXG7K.js → serve-command-MRPTK4XX.js} +26 -26
  141. package/dist/mcp-chunks/server-2WSYXDII.js +43 -0
  142. package/dist/mcp-chunks/{timeouts-BJWDJEMH.js → timeouts-2SQIDYBE.js} +4 -3
  143. package/dist/mcp-chunks/{vault-command-EYOIFWEY.js → vault-command-6JVDCFWU.js} +5 -5
  144. package/dist/mcp-chunks/{webapi-WMMA3OEC.js → webapi-CI4O7AUX.js} +1 -1
  145. package/dist/mcp-daemon.js +35 -31
  146. package/dist/mcp-run-worker.js +34 -30
  147. package/dist/model-binding.d.ts +34 -3
  148. package/dist/model-binding.d.ts.map +1 -1
  149. package/dist/model-binding.js +174 -4
  150. package/dist/model-binding.js.map +1 -1
  151. package/dist/otel-baggage.d.ts +7 -0
  152. package/dist/otel-baggage.d.ts.map +1 -0
  153. package/dist/otel-baggage.js +7 -0
  154. package/dist/otel-baggage.js.map +1 -0
  155. package/dist/recipe/manifest.generated.d.ts +2 -1
  156. package/dist/recipe/manifest.generated.d.ts.map +1 -1
  157. package/dist/recipe/manifest.generated.js +2 -1
  158. package/dist/recipe/manifest.generated.js.map +1 -1
  159. package/dist/recipe/model.d.ts +2 -0
  160. package/dist/recipe/model.d.ts.map +1 -1
  161. package/dist/recipe/model.js +15 -1
  162. package/dist/recipe/model.js.map +1 -1
  163. package/dist/review.d.ts +1 -1
  164. package/dist/review.d.ts.map +1 -1
  165. package/dist/review.js +1 -1
  166. package/dist/review.js.map +1 -1
  167. package/dist/session.d.ts +9 -2
  168. package/dist/session.d.ts.map +1 -1
  169. package/dist/session.js +86 -16
  170. package/dist/session.js.map +1 -1
  171. package/dist/suggestion-picker.d.ts +2 -2
  172. package/dist/suggestion-picker.d.ts.map +1 -1
  173. package/dist/suggestion-picker.js +5 -3
  174. package/dist/suggestion-picker.js.map +1 -1
  175. package/docs/README.md +19 -18
  176. package/docs/batch.md +223 -0
  177. package/docs/pi-extension.md +42 -0
  178. package/docs/recipe-format.md +14 -3
  179. package/package.json +20 -15
  180. package/skills/documents/SKILL.md +6 -2
  181. package/skills/issues/SKILL.md +2 -1
  182. package/skills/search/SKILL.md +3 -0
  183. package/skills/signature/SKILL.md +4 -4
  184. package/dist/mcp-chunks/call-arguments-GCXZA4HC.js +0 -16
  185. package/dist/mcp-chunks/client-SBELHRAE.js +0 -32
  186. package/dist/mcp-chunks/daemon-command-MQS6AP2W.js +0 -32
  187. package/dist/mcp-chunks/dist-SDPPH7XQ.js +0 -65
  188. package/dist/mcp-chunks/generated-daemon-runtime-TUCZ3JEP.js +0 -32
  189. package/dist/mcp-chunks/runtime-5SOGEUTQ.js +0 -39
  190. package/dist/mcp-chunks/server-HQBFWAJR.js +0 -41
package/docs/batch.md ADDED
@@ -0,0 +1,223 @@
1
+ # Batch runs
2
+
3
+ Run one agent over many prompts. Each prompt is answered in its own fresh
4
+ session, and each answer is recorded as soon as it finishes. Batches suit work
5
+ where you have many independent questions for the same agent: summarizing a
6
+ set of documents, classifying records, or extracting fields from a backlog of
7
+ text.
8
+
9
+ A batch can be stopped at any time and picks up where it left off: prompts
10
+ that already succeeded are skipped, and everything else runs again.
11
+
12
+ ## Quick start
13
+
14
+ Pass the prompts in, and get the answers back:
15
+
16
+ ```ts
17
+ import { resolveRecipe } from "@introspection-ai/recipes";
18
+ import {
19
+ createInProcessRunController,
20
+ runBatch,
21
+ } from "@introspection-ai/recipes/batch";
22
+
23
+ const recipe = resolveRecipe({ recipeDir: "./my-recipe" });
24
+ const controller = createInProcessRunController({
25
+ recipe,
26
+ cwd: process.cwd(),
27
+ concurrency: 4,
28
+ });
29
+
30
+ const { results } = await runBatch({
31
+ agent: "summarize",
32
+ input: [
33
+ {
34
+ custom_id: "doc-1",
35
+ prompt: "Summarize this report in three sentences: ...",
36
+ },
37
+ {
38
+ custom_id: "doc-2",
39
+ prompt: "Summarize this report in three sentences: ...",
40
+ },
41
+ ],
42
+ controller,
43
+ concurrency: 4,
44
+ });
45
+ await controller.shutdown();
46
+
47
+ for (const line of results) {
48
+ console.log(line.custom_id, line.result.output);
49
+ }
50
+ ```
51
+
52
+ Everything runs in your process, with your Recipe's model settings and
53
+ provider credentials. Nothing is uploaded anywhere.
54
+
55
+ ## Resumable batches
56
+
57
+ For a large batch, give it a `directory`. Results are then written to
58
+ `<directory>/results.jsonl` as each prompt finishes, and running the same batch
59
+ again only runs what is left:
60
+
61
+ ```ts
62
+ const outcome = await runBatch({
63
+ agent: "summarize",
64
+ input: "prompts.jsonl", // read from the directory; inline prompts work too
65
+ directory: "./batch",
66
+ controller,
67
+ });
68
+ console.log(outcome);
69
+ // { total: 1000, already_completed: 600, completed: 400, failed: 0, not_started: 0, stopped: false, results: [...] }
70
+ ```
71
+
72
+ Without a `directory`, results are kept in memory and returned, and the batch
73
+ cannot resume after the process exits.
74
+
75
+ ## Streaming results
76
+
77
+ To act on each answer as it arrives (write it to your own database, update a
78
+ UI), pass `onResult`:
79
+
80
+ ```ts
81
+ await runBatch({
82
+ agent: "summarize",
83
+ input,
84
+ controller,
85
+ onResult: async (line) => {
86
+ await saveSummary(line.custom_id, line.result.output); // your own code
87
+ },
88
+ });
89
+ ```
90
+
91
+ `onResult` is called once per prompt, in the order prompts finish.
92
+
93
+ ## Input format
94
+
95
+ `input` is either an array of prompts, or the path (or `file:` URL) of a JSONL
96
+ file with one prompt per line. Each prompt has:
97
+
98
+ | Field | Required | Meaning |
99
+ | ----------- | -------- | -------------------------------------------------------------------------- |
100
+ | `custom_id` | yes | Your id for the prompt. It must be unique in the batch. |
101
+ | `prompt` | yes | What the agent is asked. |
102
+ | `metadata` | no | Any object. It is copied onto the prompt's result as is, for your own use. |
103
+
104
+ As a file:
105
+
106
+ ```jsonl
107
+ {"custom_id": "doc-1", "prompt": "Summarize this report in three sentences: ..."}
108
+ {"custom_id": "doc-2", "prompt": "Summarize this report in three sentences: ...", "metadata": {"source": "acme"}}
109
+ ```
110
+
111
+ A malformed prompt or a repeated `custom_id` stops the batch before anything
112
+ runs, and the error says which one.
113
+
114
+ ## Results format
115
+
116
+ Each result has the same shape as Anthropic's Message Batches results:
117
+
118
+ ```json
119
+ {
120
+ "custom_id": "doc-1",
121
+ "result": {
122
+ "type": "succeeded",
123
+ "output": "The report finds ...",
124
+ "run_id": "..."
125
+ },
126
+ "batch": { "record_index": 0, "input_sha256": "...", "attempts": 1 },
127
+ "metadata": { "source": "acme" }
128
+ }
129
+ ```
130
+
131
+ - `result.type` is `succeeded`, `errored` (with `result.error.message`), or
132
+ `canceled` (the prompt was still running when the batch was cancelled).
133
+ - `batch.record_index` is the prompt's position in the input, and
134
+ `batch.attempts` is how many times it ran.
135
+ - `runBatch` returns the latest result for every prompt, in input order. In a
136
+ results file, a prompt that runs again is appended again, so read the last
137
+ line for each `custom_id`.
138
+
139
+ ## Options
140
+
141
+ | Option | Default | Meaning |
142
+ | --------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
143
+ | `agent` | required | The Recipe agent that answers each prompt. |
144
+ | `input` | required | The prompts, or a JSONL file of them. |
145
+ | `controller` | required | Runs each prompt: `createInProcessRunController`, or your own `AgentRunController`. |
146
+ | `directory` | none | Where results are written and resumed from. A relative `input` path is read from here too. |
147
+ | `output_name` | `results.jsonl` | The results file name in `directory`. |
148
+ | `concurrency` | 8 (max 32) | How many prompts run at once. |
149
+ | `max_attempts` | 3 (max 5) | How many times a rate-limited prompt is tried. Other failures are not retried. |
150
+ | `deadline_ms` | none | Stop starting new prompts after this long. Prompts not started run next time. |
151
+ | `output_format` | `text` | With `json`, an answer that is not valid JSON is sent back to the agent to fix, up to two times. |
152
+ | `signal` | none | Abort it to stop gracefully. |
153
+ | `onResult` | none | Called with each result as it is recorded. |
154
+ | `onProgress` | none | Called with the counts after every prompt and when the batch stops. |
155
+ | `batch_id` | derived | Names the batch in each prompt's conversation id. Derived from the results file with a `directory`, so a resumed batch keeps its ids; random without one. |
156
+ | `baggage` | none | Extra OpenTelemetry baggage set around each prompt's session: an object, or a function of the prompt. |
157
+
158
+ Unknown options are rejected, so a typo fails fast instead of being ignored.
159
+
160
+ ## Stopping and resuming
161
+
162
+ - **Abort the `signal`** to stop gracefully. No new prompts start, the ones
163
+ already running finish and are recorded, and the rest are counted as
164
+ `not_started`.
165
+ - **Stop the process outright** and only the prompts that were running are
166
+ lost; with a `directory`, they run again next time.
167
+ - **Run again with the same `directory`** and the batch skips every prompt
168
+ whose last result succeeded for the same agent and prompt text. A prompt
169
+ whose text or agent changed runs again, as does any prompt that failed.
170
+
171
+ When the provider rate-limits a prompt, the batch waits and retries it, and
172
+ lowers its concurrency until requests succeed again.
173
+
174
+ ## Traces
175
+
176
+ Each prompt runs as its own conversation, with the id
177
+ `<batch_id>:<index>`. That id is on the prompt's result as
178
+ `result.conversation_id`, so a result and its trace join on it.
179
+
180
+ The batch sets the id as OpenTelemetry baggage (`gen_ai.conversation.id`)
181
+ around the prompt's session. A Recipes session takes its conversation id from
182
+ that baggage, unless its `otel.meta` names one, and so do the subagents it
183
+ starts. Any other baggage entries, including your own from `baggage`, are added
184
+ to every span the session records:
185
+
186
+ ```ts
187
+ await runBatch({
188
+ agent: "summarize",
189
+ input,
190
+ controller,
191
+ baggage: (line) => ({ "acme.document_id": line.custom_id }),
192
+ });
193
+ ```
194
+
195
+ Recipes uses your process's own `@opentelemetry/api` (a peer dependency, any
196
+ 1.x from 1.9), so it sees the context and baggage your SDK registers. Baggage only flows through `await` when your OpenTelemetry SDK has registered
197
+ an async context manager, which the Node SDK does by default. If your SDK also
198
+ propagates W3C baggage on outgoing HTTP requests, these entries are sent with
199
+ those requests too, so keep them to ids rather than anything sensitive.
200
+
201
+ ## Agents that use subagents
202
+
203
+ Each prompt is one run of the controller. If the batch's agent starts
204
+ subagents of its own, those count against the same controller, so give the
205
+ controller a higher `concurrency` than the batch's. If the two are equal, every
206
+ subagent is refused while all the batch's slots are busy.
207
+
208
+ ## Hosting batches
209
+
210
+ Applications that run batches for others can take full control with
211
+ `runBatchWith(params, deps)`. It takes validated settings (`parseBatchParams`)
212
+ and lets you supply each part yourself:
213
+
214
+ - **`results`**: where results are kept. `jsonlResults` appends to one file;
215
+ `ResultShards` closes finished results into numbered files that never change
216
+ once written, so each only needs copying somewhere durable once.
217
+ - **`files`**: replaces the local file system with your own storage.
218
+ - **`lineScope`**: gives each prompt its own conversation id and wraps its
219
+ session, so its full exchange can be read back later.
220
+ - **`cancel`**: a second signal for when a stopping batch can wait no longer;
221
+ prompts still running are recorded as `canceled` and run again next time.
222
+
223
+ None of these are needed to run a batch with `runBatch`.
@@ -158,6 +158,48 @@ available in Pi's interactive terminal, ...` so the model can tell the user
158
158
  where to look. If a Recipe extension registers its own `show_artifact`, the
159
159
  host keeps it and registers neither the built-in tool nor `/recipe view`.
160
160
 
161
+ ### Binary artifacts in a browser host
162
+
163
+ A host with `storeArtifact` can also show DOCX, PDF and common image files
164
+ through the same `show_artifact({ path })` tool. The host receives the original
165
+ `Uint8Array` and MIME type, persists it, and returns its file id. The recorded
166
+ result carries `kind: "file"`, that id and byte count, with empty `content`;
167
+ no binary payload is put in the conversation. Browser hosts render those bytes
168
+ with their file preview component, including after a conversation reload.
169
+
170
+ The existing working-directory and symlink boundary applies, with a 25 MiB cap.
171
+ Binary `ref` and text `diff` requests are refused. Without a binary-capable
172
+ `storeArtifact` implementation the host must not opt into this contract; the
173
+ terminal cannot render binary files. Hosts upgrading from the string-only
174
+ callback must handle both `string` and `Uint8Array` content.
175
+
176
+ ### Explicit artifact links
177
+
178
+ Hosts resolve explicit Markdown destinations against known artifact references
179
+ with `resolveArtifactLink` from `@introspection-ai/recipes/review`. The resolver
180
+ is shared, browser-safe code; it neither parses prose nor reads or uploads files.
181
+ A local host leaves an unuploaded file's authored path intact. A hosted UI can
182
+ map `file.id` to its file page, map `source` to its pinned repository view, and
183
+ return no URL for `path` so the link opens its existing artifact viewer.
184
+
185
+ ```ts
186
+ const link = resolveArtifactLink("outputs/report.md", artifacts, {
187
+ workspaceRoot: "/workspace",
188
+ file: ({ id }) => `/files/${encodeURIComponent(id)}`,
189
+ path: () => undefined,
190
+ });
191
+ ```
192
+
193
+ `artifacts` belongs to the current conversation or selected document, never a
194
+ global basename index. The latest exact workspace-path match wins. `fromPath`
195
+ resolves links relative to a document; absolute paths require `workspaceRoot`
196
+ and cannot escape it. Local `file:` URLs use the same workspace boundary; remote
197
+ file authorities are refused. Percent-encoded filenames and URL fragments are supported.
198
+ External URLs, malformed destinations, query-bearing paths and unknown files
199
+ are left to the host's ordinary link handling. Bare paths, inline code, fenced
200
+ code and images do not invoke this API. Opening a known reference needs no
201
+ additional tool call; persistence remains part of the standard artifact tool.
202
+
161
203
  ### Reviewing several files
162
204
 
163
205
  List `review_artifacts` and the agent can ask the user to review several
@@ -132,6 +132,17 @@ All remaining agent fields are optional. Omitted `tools`, `skills`, and
132
132
  provider or session default. Omitted agent instructions preserve `SYSTEM.md`
133
133
  when present, or Pi's normal base prompt otherwise.
134
134
 
135
+ `ai.fallbacks` MAY list, in order, other `<provider>/<model_id>` models. They
136
+ apply when the agent runs as a subagent in a local Pi, never on a hosted
137
+ runtime or when the host passes its own credentials. The agent starts on its
138
+ `ai.model` when Pi has a credential for it, otherwise on the first fallback
139
+ that has one. When a request fails and Pi retries it (a rate limit, an
140
+ overloaded or failing provider, a timeout such as `ai.options.timeout_ms`),
141
+ the retry goes to the next model, and the agent stays on the model that last
142
+ answered. A model named under `openai` also runs as the same model under
143
+ `openai-codex` when Pi is logged in to ChatGPT and has no OpenAI key, whether
144
+ it is the `ai.model` or a fallback; that alias also applies only to subagents.
145
+
135
146
  `phases` MAY list, in order, the phases the agent moves through, each the
136
147
  prefix of its step skills (`build` for `build-draft`). It changes only what
137
148
  Pi's footer shows: the phase of the step skill last read, with the agent's
@@ -373,13 +384,13 @@ agent a session runs; when that agent offers none, it shows its own defaults.
373
384
 
374
385
  - **In Pi.** A new session in the terminal (`pi --recipe <dir>`, or
375
386
  `introspection local`) with no messages asks once, "What would you like to
376
- do?", with up to three templates the session's agent offers (a random
377
- three, in file order, when it offers more) and a row to type your own
387
+ do?", with up to four templates the session's agent offers (a random
388
+ four, in file order, when it offers more) and a row to type your own
378
389
  request. When it offers none, it does not ask. Picking one sends it as the first message;
379
390
  a template whose `argument-hint` has a required `<argument>` is put in the
380
391
  editor instead, for you to finish. Typing sends what you typed, and Esc
381
392
  leaves the empty prompt. Set `PI_RECIPES_SUGGESTIONS_SEED` to pin which
382
- three show. The picker never appears on resume, outside the terminal UI,
393
+ four show. The picker never appears on resume, outside the terminal UI,
383
394
  or when Pi starts with a message.
384
395
  - **Starting with one.** Pi expands a template given as the initial message,
385
396
  so `pi --recipe <dir> "/redline nda.docx"` (or
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@introspection-ai/recipes",
3
- "version": "0.55.0",
3
+ "version": "0.57.0",
4
4
  "description": "The open format for vertical agents, built on Pi.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -61,6 +61,10 @@
61
61
  "types": "./dist/agents.d.ts",
62
62
  "import": "./dist/agents.js"
63
63
  },
64
+ "./batch": {
65
+ "types": "./dist/batch/index.d.ts",
66
+ "import": "./dist/batch/index.js"
67
+ },
64
68
  "./recipe": {
65
69
  "types": "./dist/recipe/resolve.d.ts",
66
70
  "import": "./dist/recipe/resolve.js"
@@ -122,10 +126,9 @@
122
126
  "dependencies": {
123
127
  "@earendil-works/pi-mcp": ">=1.1.0 <2.0.0",
124
128
  "@introspection-sdk/introspection-pi": ">=0.47.0",
125
- "@opentelemetry/api": "^1.9.1",
126
129
  "ajv": "^8.20.0",
127
- "mcporter": "0.16.1",
128
- "minimatch": "^10.2.6",
130
+ "mcporter": "0.17.0",
131
+ "minimatch": "^11.0.8",
129
132
  "semver": "^7.8.5",
130
133
  "yaml": "^2.9.0"
131
134
  },
@@ -139,24 +142,26 @@
139
142
  "@introspection-ai/recipe-productivity-microsoft": ">=0.1.0",
140
143
  "@introspection-ai/recipe-search": ">=0.1.0",
141
144
  "@introspection-ai/recipe-signature": ">=0.1.0",
142
- "@introspection-ai/mcp-client-linux-x64": "0.55.0",
143
- "@introspection-ai/mcp-client-linux-arm64": "0.55.0",
144
- "@introspection-ai/mcp-client-darwin-arm64": "0.55.0",
145
- "@introspection-ai/mcp-client-darwin-x64": "0.55.0"
145
+ "@introspection-ai/mcp-client-linux-x64": "0.57.0",
146
+ "@introspection-ai/mcp-client-linux-arm64": "0.57.0",
147
+ "@introspection-ai/mcp-client-darwin-arm64": "0.57.0",
148
+ "@introspection-ai/mcp-client-darwin-x64": "0.57.0"
146
149
  },
147
150
  "peerDependencies": {
148
151
  "@earendil-works/pi-agent-core": ">=1.1.0 <2.0.0",
149
152
  "@earendil-works/pi-ai": ">=1.1.0 <2.0.0",
150
153
  "@earendil-works/pi-coding-agent": ">=1.1.0 <2.0.0",
151
154
  "@earendil-works/pi-tui": ">=1.1.0 <2.0.0",
155
+ "@opentelemetry/api": ">=1.9.0 <2.0.0",
152
156
  "typebox": "*"
153
157
  },
154
158
  "devDependencies": {
155
- "@earendil-works/pi-agent-core": "1.5.0",
156
- "@earendil-works/pi-ai": "1.5.0",
157
- "@earendil-works/pi-coding-agent": "1.5.0",
158
- "@earendil-works/pi-tui": "1.5.0",
159
+ "@earendil-works/pi-agent-core": "1.5.2",
160
+ "@earendil-works/pi-ai": "1.5.2",
161
+ "@earendil-works/pi-coding-agent": "1.5.2",
162
+ "@earendil-works/pi-tui": "1.5.2",
159
163
  "@eslint/js": "9.39.5",
164
+ "@opentelemetry/api": "^1.10.0",
160
165
  "@pollyjs/adapter-fetch": "^6.0.7",
161
166
  "@pollyjs/core": "^6.0.6",
162
167
  "@pollyjs/persister-fs": "^6.0.6",
@@ -167,12 +172,12 @@
167
172
  "eslint": "9.39.5",
168
173
  "eslint-config-prettier": "10.1.8",
169
174
  "eslint-plugin-only-warn": "1.2.1",
170
- "knip": "6.44.0",
171
- "prettier": "3.9.10",
175
+ "knip": "6.45.1",
176
+ "prettier": "3.10.1",
172
177
  "ts-json-schema-generator": "^2.9.0",
173
178
  "typebox": "^1.0.56",
174
179
  "typescript": "npm:@typescript/typescript6@^6.0.2",
175
- "typescript-eslint": "8.72.1",
180
+ "typescript-eslint": "8.72.2",
176
181
  "vitest": "^5.0.1"
177
182
  },
178
183
  "scripts": {
@@ -38,8 +38,8 @@ After `convert`, the converted `.docx` is the file you change: pass it as `path`
38
38
 
39
39
  Copy quotes from the text after the paragraph id in `read`, within one paragraph, and
40
40
  pass that `paragraph` id. Quote only enough to find the place once; `near` or
41
- `occurrence` picks one match when it repeats. Spacing, curly quotes and dashes are
42
- forgiven; words and capitalization are not. With `revise` there is nothing to quote:
41
+ `occurrence` picks one match when it repeats. Spacing, curly quotes, dashes,
42
+ capitalization, soft hyphens and a leading list number are forgiven; words are not. With `revise` there is nothing to quote:
43
43
  copy the paragraph's current text and change only what must change.
44
44
 
45
45
  ## PDFs you are asked to mark up
@@ -62,6 +62,10 @@ the rest still went in. Resubmit only the failed ones, with `path` set to the sa
62
62
  - `not_found`: use the `closest` text it lists, or `read` again; your earlier changes may
63
63
  have moved the text. If the paragraph changed a lot, `revise` it by id.
64
64
  - `ambiguous`: add `paragraph`, `near` or `occurrence`.
65
+ - `paragraph_not_found`: take the paragraph id from a fresh `read`.
66
+ - `occurrence_out_of_range`: the quote appears fewer times than `occurrence` says;
67
+ count again in a fresh `read`.
68
+ - `empty_quote`: pass the text to change.
65
69
  - `crosses_marker` or `unaddressable`: the change crosses something Word keeps (a tab, a
66
70
  field, a content control). Change the words on each side separately, or `revise` the
67
71
  paragraph with its full new text.
@@ -9,7 +9,8 @@ The `issues` tool tracks work in the tracker this Recipe declares: Linear, Jira,
9
9
  Introspection's own issues when neither is connected. Each call takes a `command`:
10
10
  `search`, `get`, `create`, `update`, `comment` or `transition`. Only the commands a
11
11
  provider serves are offered, and the tool's description says what each provider leaves
12
- out. `tools list issues --schema` shows every command's arguments.
12
+ out. The tool's schema lists every command's arguments (in `cli` tools mode,
13
+ `tools list issues --schema`).
13
14
 
14
15
  ## Act only on handles
15
16
 
@@ -70,3 +70,6 @@ instructions.
70
70
  another one offered, or say that you could not search.
71
71
  - `out_of_credit`: the provider's account has run out. Use another provider if one is
72
72
  offered, or say that you could not search.
73
+ - `unavailable` or `provider_error`: the provider failed. Try again once, then use another
74
+ provider if one is offered, or say that you could not search.
75
+ - `invalid_request`: fix the arguments the message names and search again.
@@ -19,13 +19,13 @@ The document must be final:
19
19
  1. It is a `.docx` the `documents` tool saved under `outputs/`. Never send the file the
20
20
  person gave you, and never a PDF: convert a PDF with `documents convert` and review
21
21
  the Word copy.
22
- 2. Every tracked change is resolved. `documents read` must show no changes on its
23
- `markup:` line. Accept or reject what is left with `documents respond`, only as the
22
+ 2. Every tracked change is resolved. `documents read`'s first line must say
23
+ 0 tracked change(s). Accept or reject what is left with `documents respond`, only as the
24
24
  person decided; never accept the other side's changes on your own judgement.
25
25
  3. It has no comments, open or resolved. You cannot delete one, so ask the person to
26
26
  remove them in Word.
27
27
  4. Each signer's name is filled in on the `Name:` line of their side of the signature
28
- block, spelled as you will pass it. That line is how the tool finds where they sign.
28
+ block, in a table, spelled as you will pass it. That line is how the tool finds where they sign.
29
29
 
30
30
  `prepare` checks all of this and refuses a document that fails, naming what is left.
31
31
  Fix that and prepare again; don't work around it.
@@ -78,7 +78,7 @@ new answer can exist.
78
78
  ## When a command fails
79
79
 
80
80
  - `not_ready`: resolve what the message names (tracked changes, comments, the path).
81
- - `anchor_not_found`: a signer's name is not on a `Name:` line, or their column has no
81
+ - `anchor_not_found`: a signer's name is not on a `Name:` line in a table, or their column has no
82
82
  `By:` line. Check the spelling against the document.
83
83
  - `ambiguous`: the signer's name is on more than one `Name:` line. Tell the person.
84
84
  - `not_connected`: the person has not connected the signing service. Ask them to, with
@@ -1,16 +0,0 @@
1
- import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
- import {
3
- parseCallArguments
4
- } from "./chunk-JTPTAO4M.js";
5
- import "./chunk-H5PBSJP3.js";
6
- import "./chunk-TC2JPBFB.js";
7
- import "./chunk-L2MSWQDL.js";
8
- import "./chunk-US63Y6XE.js";
9
- import "./chunk-MEQXX43K.js";
10
- import "./chunk-6O42UGLI.js";
11
- import "./chunk-T4MQCFIK.js";
12
- import "./chunk-BHXCAVFP.js";
13
- import "./chunk-LRKZP7DJ.js";
14
- export {
15
- parseCallArguments
16
- };
@@ -1,32 +0,0 @@
1
- import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
- import {
3
- DaemonClient,
4
- resolveDaemonPaths
5
- } from "./chunk-MYAMG6VL.js";
6
- import "./chunk-ORJND4AI.js";
7
- import "./chunk-2AKSS7WR.js";
8
- import "./chunk-6P3KAQ5N.js";
9
- import "./chunk-F2X4Y2TQ.js";
10
- import "./chunk-3ETUDW7N.js";
11
- import "./chunk-QNXOIF5U.js";
12
- import "./chunk-6O42UGLI.js";
13
- import "./chunk-2YV72LUA.js";
14
- import "./chunk-THRMUZZD.js";
15
- import "./chunk-V42T3QNK.js";
16
- import "./chunk-CXST5CVH.js";
17
- import "./chunk-7U5NSQ5T.js";
18
- import "./chunk-3LENTPGE.js";
19
- import "./chunk-JEHI2YU4.js";
20
- import "./chunk-IWCVZ46B.js";
21
- import "./chunk-O3RTM5HD.js";
22
- import "./chunk-T4MQCFIK.js";
23
- import "./chunk-BHXCAVFP.js";
24
- import "./chunk-MHUMLEBO.js";
25
- import "./chunk-IRSL7JRH.js";
26
- import "./chunk-UVRJ3AAD.js";
27
- import "./chunk-O7SIXJM6.js";
28
- import "./chunk-LRKZP7DJ.js";
29
- export {
30
- DaemonClient,
31
- resolveDaemonPaths
32
- };
@@ -1,32 +0,0 @@
1
- import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
- import {
3
- handleDaemonCli
4
- } from "./chunk-OIK5AH2S.js";
5
- import "./chunk-MYAMG6VL.js";
6
- import "./chunk-ORJND4AI.js";
7
- import "./chunk-2AKSS7WR.js";
8
- import "./chunk-6P3KAQ5N.js";
9
- import "./chunk-F2X4Y2TQ.js";
10
- import "./chunk-3ETUDW7N.js";
11
- import "./chunk-QNXOIF5U.js";
12
- import "./chunk-6O42UGLI.js";
13
- import "./chunk-2YV72LUA.js";
14
- import "./chunk-THRMUZZD.js";
15
- import "./chunk-V42T3QNK.js";
16
- import "./chunk-CXST5CVH.js";
17
- import "./chunk-7U5NSQ5T.js";
18
- import "./chunk-3LENTPGE.js";
19
- import "./chunk-JEHI2YU4.js";
20
- import "./chunk-IWCVZ46B.js";
21
- import "./chunk-O3RTM5HD.js";
22
- import "./chunk-T4MQCFIK.js";
23
- import "./chunk-BHXCAVFP.js";
24
- import "./chunk-MHUMLEBO.js";
25
- import "./chunk-IRSL7JRH.js";
26
- import "./chunk-UVRJ3AAD.js";
27
- import "./chunk-O7SIXJM6.js";
28
- import "./chunk-B6S43WID.js";
29
- import "./chunk-LRKZP7DJ.js";
30
- export {
31
- handleDaemonCli
32
- };
@@ -1,65 +0,0 @@
1
- import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
- import {
3
- createServerProxy
4
- } from "./chunk-TUPFPO4L.js";
5
- import {
6
- createGeneratedKeepAliveRuntime
7
- } from "./chunk-757ZF552.js";
8
- import "./chunk-HNQSUT44.js";
9
- import {
10
- handleDaemonCli
11
- } from "./chunk-OIK5AH2S.js";
12
- import "./chunk-MYAMG6VL.js";
13
- import {
14
- createCallResult,
15
- describeConnectionIssue,
16
- wrapCallResult
17
- } from "./chunk-3SXP4S2A.js";
18
- import {
19
- callOnce,
20
- createRuntime
21
- } from "./chunk-ORJND4AI.js";
22
- import "./chunk-2AKSS7WR.js";
23
- import "./chunk-6P3KAQ5N.js";
24
- import {
25
- createInteractiveElicitationResponder,
26
- createNonInteractiveElicitationResponder
27
- } from "./chunk-F2X4Y2TQ.js";
28
- import "./chunk-3ETUDW7N.js";
29
- import "./chunk-QNXOIF5U.js";
30
- import "./chunk-6O42UGLI.js";
31
- import "./chunk-2YV72LUA.js";
32
- import "./chunk-THRMUZZD.js";
33
- import {
34
- VaultEncryptionError
35
- } from "./chunk-V42T3QNK.js";
36
- import {
37
- loadServerDefinitions
38
- } from "./chunk-CXST5CVH.js";
39
- import "./chunk-7U5NSQ5T.js";
40
- import "./chunk-3LENTPGE.js";
41
- import "./chunk-JEHI2YU4.js";
42
- import "./chunk-IWCVZ46B.js";
43
- import "./chunk-O3RTM5HD.js";
44
- import "./chunk-T4MQCFIK.js";
45
- import "./chunk-BHXCAVFP.js";
46
- import "./chunk-MHUMLEBO.js";
47
- import "./chunk-IRSL7JRH.js";
48
- import "./chunk-UVRJ3AAD.js";
49
- import "./chunk-O7SIXJM6.js";
50
- import "./chunk-B6S43WID.js";
51
- import "./chunk-LRKZP7DJ.js";
52
- export {
53
- VaultEncryptionError,
54
- callOnce,
55
- createCallResult,
56
- createGeneratedKeepAliveRuntime,
57
- createInteractiveElicitationResponder,
58
- createNonInteractiveElicitationResponder,
59
- createRuntime,
60
- createServerProxy,
61
- describeConnectionIssue,
62
- handleDaemonCli,
63
- loadServerDefinitions,
64
- wrapCallResult
65
- };
@@ -1,32 +0,0 @@
1
- import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
- import {
3
- createGeneratedKeepAliveRuntime
4
- } from "./chunk-757ZF552.js";
5
- import "./chunk-HNQSUT44.js";
6
- import "./chunk-MYAMG6VL.js";
7
- import "./chunk-ORJND4AI.js";
8
- import "./chunk-2AKSS7WR.js";
9
- import "./chunk-6P3KAQ5N.js";
10
- import "./chunk-F2X4Y2TQ.js";
11
- import "./chunk-3ETUDW7N.js";
12
- import "./chunk-QNXOIF5U.js";
13
- import "./chunk-6O42UGLI.js";
14
- import "./chunk-2YV72LUA.js";
15
- import "./chunk-THRMUZZD.js";
16
- import "./chunk-V42T3QNK.js";
17
- import "./chunk-CXST5CVH.js";
18
- import "./chunk-7U5NSQ5T.js";
19
- import "./chunk-3LENTPGE.js";
20
- import "./chunk-JEHI2YU4.js";
21
- import "./chunk-IWCVZ46B.js";
22
- import "./chunk-O3RTM5HD.js";
23
- import "./chunk-T4MQCFIK.js";
24
- import "./chunk-BHXCAVFP.js";
25
- import "./chunk-MHUMLEBO.js";
26
- import "./chunk-IRSL7JRH.js";
27
- import "./chunk-UVRJ3AAD.js";
28
- import "./chunk-O7SIXJM6.js";
29
- import "./chunk-LRKZP7DJ.js";
30
- export {
31
- createGeneratedKeepAliveRuntime
32
- };