@parcha/agentrun-serve 0.1.0-beta.36 → 0.1.0-beta.38

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 (568) hide show
  1. package/CHANGELOG.md +452 -0
  2. package/README.md +311 -142
  3. package/dist/agent-rows.d.ts +1 -1
  4. package/dist/agents-store.d.ts +35 -3
  5. package/dist/agents-store.js +39 -14
  6. package/dist/answer-json.d.ts +34 -1
  7. package/dist/answer-json.js +91 -9
  8. package/dist/api-only.d.ts +1 -1
  9. package/dist/api-only.js +2 -2
  10. package/dist/attach-conformance-cli.d.ts +1 -0
  11. package/dist/attach-conformance-cli.js +18 -0
  12. package/dist/attach-conformance.d.ts +25 -0
  13. package/dist/attach-conformance.js +343 -0
  14. package/dist/browser-cost.d.ts +1 -1
  15. package/dist/browser-cost.js +52 -93
  16. package/dist/browser-live.d.ts +20 -8
  17. package/dist/browser-live.js +50 -27
  18. package/dist/cap.d.ts +0 -407
  19. package/dist/cap.js +4 -1028
  20. package/dist/catalog.d.ts +1 -12
  21. package/dist/catalog.js +4 -34
  22. package/dist/cli.js +13 -4
  23. package/dist/composio-preset.d.ts +53 -0
  24. package/dist/composio-preset.js +221 -0
  25. package/dist/computer-attach.d.ts +125 -0
  26. package/dist/computer-attach.js +330 -0
  27. package/dist/computer-calls.d.ts +60 -0
  28. package/dist/computer-calls.js +209 -0
  29. package/dist/computer-channel.d.ts +57 -0
  30. package/dist/computer-channel.js +115 -0
  31. package/dist/computer-commands.d.ts +1 -1
  32. package/dist/computer-held-routes.d.ts +35 -0
  33. package/dist/computer-held-routes.js +106 -0
  34. package/dist/computer-held.d.ts +48 -0
  35. package/dist/computer-held.js +87 -0
  36. package/dist/computer-keys.d.ts +21 -1
  37. package/dist/computer-keys.js +53 -11
  38. package/dist/computer-live.d.ts +165 -0
  39. package/dist/computer-live.js +655 -0
  40. package/dist/computer-setting.d.ts +15 -2
  41. package/dist/computer-setting.js +20 -4
  42. package/dist/computer-view.d.ts +14 -0
  43. package/dist/computer-view.js +51 -3
  44. package/dist/computer-viewer.d.ts +6 -0
  45. package/dist/computer-viewer.js +311 -0
  46. package/dist/computers.d.ts +37 -8
  47. package/dist/computers.js +62 -14
  48. package/dist/console/assets/index-CjqQirbo.css +1 -0
  49. package/dist/console/assets/index-b6-XY5A9.js +576 -0
  50. package/dist/console/index.html +2 -2
  51. package/dist/console-links.d.ts +2 -0
  52. package/dist/console-links.js +3 -0
  53. package/dist/decisions.js +4 -0
  54. package/dist/faux-computers.d.ts +9 -20
  55. package/dist/faux-computers.js +56 -26
  56. package/dist/github-connection.d.ts +10 -2
  57. package/dist/github-connection.js +65 -2
  58. package/dist/github-faux.js +1 -1
  59. package/dist/graph-view.d.ts +1 -1
  60. package/dist/harness-opencode/adapter.js +7 -3
  61. package/dist/harness-opencode/facts.js +0 -2
  62. package/dist/harness-opencode/host/policy.d.ts +2 -5
  63. package/dist/harness-opencode/host/policy.js +8 -32
  64. package/dist/harness-table.d.ts +0 -2
  65. package/dist/harness-table.js +0 -2
  66. package/dist/harness.d.ts +1 -0
  67. package/dist/harness.js +35 -1
  68. package/dist/host-tools.d.ts +2 -6
  69. package/dist/host-tools.js +7 -10
  70. package/dist/hosted-search.d.ts +5 -6
  71. package/dist/hosted-search.js +2 -28
  72. package/dist/import-sources.d.ts +10 -0
  73. package/dist/import-sources.js +44 -2
  74. package/dist/import.d.ts +3 -3
  75. package/dist/import.js +37 -6
  76. package/dist/key-words.d.ts +3 -2
  77. package/dist/key-words.js +4 -2
  78. package/dist/learn/check.d.ts +10 -2
  79. package/dist/learn/check.js +13 -5
  80. package/dist/learn/commit.d.ts +14 -2
  81. package/dist/learn/commit.js +23 -9
  82. package/dist/learn/compile.d.ts +243 -0
  83. package/dist/learn/compile.js +471 -0
  84. package/dist/learn/folder.d.ts +6 -0
  85. package/dist/learn/folder.js +4 -1
  86. package/dist/learn/general.d.ts +69 -0
  87. package/dist/learn/general.js +75 -0
  88. package/dist/learn/grade.d.ts +5 -1
  89. package/dist/learn/grade.js +29 -7
  90. package/dist/learn/notes.d.ts +8 -0
  91. package/dist/learn/notes.js +18 -0
  92. package/dist/learn/promote.d.ts +253 -0
  93. package/dist/learn/promote.js +428 -0
  94. package/dist/learn/refit.d.ts +39 -0
  95. package/dist/learn/refit.js +236 -0
  96. package/dist/learn/reflect.d.ts +9 -20
  97. package/dist/learn/reflect.js +18 -125
  98. package/dist/learn/replay-calls.d.ts +63 -0
  99. package/dist/learn/replay-calls.js +158 -0
  100. package/dist/learn/skills.d.ts +50 -14
  101. package/dist/learn/skills.js +183 -47
  102. package/dist/learn/workflow-nodes.d.ts +15 -0
  103. package/dist/learn/workflow-nodes.js +44 -0
  104. package/dist/learned-nodes.d.ts +50 -2
  105. package/dist/learned-nodes.js +41 -2
  106. package/dist/learned-workflow.d.ts +43 -3
  107. package/dist/learned-workflow.js +170 -28
  108. package/dist/learning-batch.d.ts +283 -0
  109. package/dist/learning-batch.js +574 -0
  110. package/dist/learning-cost.d.ts +18 -6
  111. package/dist/learning-cost.js +15 -7
  112. package/dist/learning-evals.d.ts +33 -0
  113. package/dist/learning-evals.js +98 -0
  114. package/dist/learning-routes.d.ts +37 -2
  115. package/dist/learning-routes.js +52 -8
  116. package/dist/learning-words.d.ts +13 -0
  117. package/dist/learning-words.js +13 -0
  118. package/dist/learning.d.ts +55 -17
  119. package/dist/learning.js +91 -48
  120. package/dist/live/stream.js +6 -3
  121. package/dist/live/translate.d.ts +4 -3
  122. package/dist/live/translate.js +8 -4
  123. package/dist/live-reach.d.ts +37 -0
  124. package/dist/live-reach.js +62 -0
  125. package/dist/llm.js +0 -3
  126. package/dist/mcp-gateway.d.ts +21 -20
  127. package/dist/mcp-gateway.js +76 -55
  128. package/dist/mcp-oauth.d.ts +62 -7
  129. package/dist/mcp-oauth.js +134 -19
  130. package/dist/mcp-pin-first.d.ts +37 -0
  131. package/dist/mcp-pin-first.js +107 -0
  132. package/dist/mcp-private-hosts.d.ts +4 -4
  133. package/dist/mcp-private-hosts.js +20 -12
  134. package/dist/mcp-probe.d.ts +27 -11
  135. package/dist/mcp-probe.js +60 -42
  136. package/dist/mcp-secret-writes.js +4 -0
  137. package/dist/mcp-servers-store.d.ts +115 -25
  138. package/dist/mcp-servers-store.js +241 -43
  139. package/dist/mcp-sources.d.ts +39 -0
  140. package/dist/mcp-sources.js +74 -0
  141. package/dist/mcp-store.d.ts +21 -4
  142. package/dist/mcp-store.js +33 -8
  143. package/dist/mcp-wire.d.ts +22 -0
  144. package/dist/mcp-wire.js +36 -0
  145. package/dist/mcp.js +3 -3
  146. package/dist/meta-tool-names.d.ts +1 -0
  147. package/dist/meta-tool-names.js +3 -0
  148. package/dist/model-form.d.ts +26 -0
  149. package/dist/model-form.js +80 -0
  150. package/dist/model.d.ts +13 -0
  151. package/dist/model.js +69 -25
  152. package/dist/monid.d.ts +51 -25
  153. package/dist/monid.js +226 -140
  154. package/dist/openapi.js +694 -59
  155. package/dist/page.d.ts +18 -0
  156. package/dist/page.js +48 -20
  157. package/dist/paid-calls.d.ts +26 -29
  158. package/dist/paid-calls.js +46 -102
  159. package/dist/place-offers.d.ts +2 -3
  160. package/dist/place-offers.js +3 -7
  161. package/dist/place.js +1 -2
  162. package/dist/print.d.ts +15 -1
  163. package/dist/print.js +14 -3
  164. package/dist/propose.d.ts +10 -1
  165. package/dist/propose.js +30 -10
  166. package/dist/provider.js +12 -4
  167. package/dist/reflect-range.d.ts +8 -1
  168. package/dist/reflect-range.js +3 -2
  169. package/dist/rows.d.ts +5 -3
  170. package/dist/rows.js +15 -4
  171. package/dist/run-launch.d.ts +27 -2
  172. package/dist/run-launch.js +15 -4
  173. package/dist/run-learning-served.d.ts +13 -2
  174. package/dist/run-manifest.d.ts +5 -0
  175. package/dist/run-manifest.js +20 -0
  176. package/dist/run-reads-over-store.d.ts +1 -1
  177. package/dist/run-repo.d.ts +20 -0
  178. package/dist/run-repo.js +63 -0
  179. package/dist/run-secrets.js +2 -3
  180. package/dist/run-timeline-served.d.ts +1 -1
  181. package/dist/run-timeline-served.js +5 -2
  182. package/dist/run-view.d.ts +19 -8
  183. package/dist/run-view.js +62 -26
  184. package/dist/runnable.d.ts +0 -3
  185. package/dist/runnable.js +37 -29
  186. package/dist/runner/adapter-loop.d.ts +47 -17
  187. package/dist/runner/adapter-loop.js +1427 -303
  188. package/dist/runner/adapter-run-spec.d.ts +23 -9
  189. package/dist/runner/adapter-run-spec.js +162 -56
  190. package/dist/runner/adapters/pi-computer.d.ts +9 -0
  191. package/dist/runner/adapters/pi-computer.js +51 -0
  192. package/dist/runner/adapters/pi.d.ts +25 -11
  193. package/dist/runner/adapters/pi.js +168 -45
  194. package/dist/runner/beside.d.ts +7 -3
  195. package/dist/runner/beside.js +21 -11
  196. package/dist/runner/claim-secrets.d.ts +4 -0
  197. package/dist/runner/claim-secrets.js +6 -1
  198. package/dist/runner/cli-run-spec.d.ts +20 -3
  199. package/dist/runner/cli-run-spec.js +174 -64
  200. package/dist/runner/commands.d.ts +3 -1
  201. package/dist/runner/commands.js +28 -3
  202. package/dist/runner/computer-channel.d.ts +34 -0
  203. package/dist/runner/computer-channel.js +62 -0
  204. package/dist/runner/conformance/harness.d.ts +3 -0
  205. package/dist/runner/conformance/harness.js +224 -17
  206. package/dist/runner/conformance/subject.d.ts +12 -5
  207. package/dist/runner/dispatch.js +3 -0
  208. package/dist/runner/end-of-run.d.ts +23 -12
  209. package/dist/runner/end-of-run.js +41 -16
  210. package/dist/runner/feedback-round.d.ts +52 -0
  211. package/dist/runner/feedback-round.js +79 -0
  212. package/dist/runner/github-app.d.ts +2 -1
  213. package/dist/runner/github-app.js +4 -2
  214. package/dist/runner/harness-loops.js +15 -1
  215. package/dist/runner/held-run.d.ts +65 -0
  216. package/dist/runner/held-run.js +158 -0
  217. package/dist/runner/journal-kinds.d.ts +44 -7
  218. package/dist/runner/journal-kinds.js +29 -0
  219. package/dist/runner/journal-reader.d.ts +5 -4
  220. package/dist/runner/journal-reader.js +12 -10
  221. package/dist/runner/learning-ask.d.ts +7 -1
  222. package/dist/runner/learning-ask.js +21 -6
  223. package/dist/runner/learning-dispatch.d.ts +22 -0
  224. package/dist/runner/learning-dispatch.js +77 -10
  225. package/dist/runner/learning-end.d.ts +69 -13
  226. package/dist/runner/learning-end.js +340 -87
  227. package/dist/runner/learning-factory.d.ts +1 -1
  228. package/dist/runner/learning-factory.js +11 -5
  229. package/dist/runner/learning-loop.d.ts +86 -8
  230. package/dist/runner/learning-loop.js +178 -23
  231. package/dist/runner/learning-seed.d.ts +11 -0
  232. package/dist/runner/learning-seed.js +27 -0
  233. package/dist/runner/live-ticker.js +1 -0
  234. package/dist/runner/loop-contract.d.ts +26 -3
  235. package/dist/runner/loop.d.ts +21 -2
  236. package/dist/runner/loop.js +23 -2
  237. package/dist/runner/main.d.ts +13 -1
  238. package/dist/runner/main.js +27 -5
  239. package/dist/runner/mcp-claim.d.ts +15 -8
  240. package/dist/runner/mcp-claim.js +176 -71
  241. package/dist/runner/mcp-github.js +1 -1
  242. package/dist/runner/mcp-run.d.ts +21 -57
  243. package/dist/runner/mcp-run.js +25 -85
  244. package/dist/runner/meta-tools.d.ts +37 -0
  245. package/dist/runner/meta-tools.js +268 -0
  246. package/dist/runner/metrics.d.ts +11 -2
  247. package/dist/runner/metrics.js +26 -5
  248. package/dist/runner/model-route.js +12 -3
  249. package/dist/runner/monid-run.d.ts +16 -0
  250. package/dist/runner/monid-run.js +96 -0
  251. package/dist/runner/pr-checkout.d.ts +1 -0
  252. package/dist/runner/pr-checkout.js +1 -1
  253. package/dist/runner/promotion.d.ts +80 -0
  254. package/dist/runner/promotion.js +562 -0
  255. package/dist/runner/reflect-hook.d.ts +46 -13
  256. package/dist/runner/reflect-hook.js +149 -48
  257. package/dist/runner/runner.d.ts +26 -0
  258. package/dist/runner/runner.js +208 -17
  259. package/dist/runner/scratch-sweep.d.ts +13 -0
  260. package/dist/runner/scratch-sweep.js +62 -0
  261. package/dist/runner/sessions.d.ts +9 -4
  262. package/dist/runner/sessions.js +5 -1
  263. package/dist/runner/step-guard.d.ts +62 -0
  264. package/dist/runner/step-guard.js +93 -0
  265. package/dist/runner/store-port.d.ts +4 -2
  266. package/dist/runner/store-secrets.js +4 -3
  267. package/dist/runner/subagent.d.ts +0 -3
  268. package/dist/runner/subagent.js +10 -13
  269. package/dist/runner/workflow-first.d.ts +216 -0
  270. package/dist/runner/workflow-first.js +303 -0
  271. package/dist/runner/workflow-host.d.ts +6 -1
  272. package/dist/runner/workflow-host.js +1 -1
  273. package/dist/runner/workflow-loop.d.ts +1 -1
  274. package/dist/runner/workflow-loop.js +17 -10
  275. package/dist/runner/workflow-spec.d.ts +15 -2
  276. package/dist/runner/workflow-spec.js +63 -23
  277. package/dist/runs-over-store.d.ts +17 -3
  278. package/dist/runs-over-store.js +59 -20
  279. package/dist/seal-key.js +3 -3
  280. package/dist/sealed-settings-store.d.ts +5 -2
  281. package/dist/sealed-settings-store.js +10 -4
  282. package/dist/secret-writes.d.ts +5 -4
  283. package/dist/secret-writes.js +5 -4
  284. package/dist/server-secrets-store.d.ts +4 -3
  285. package/dist/server-secrets-store.js +15 -9
  286. package/dist/server-secrets.js +3 -2
  287. package/dist/server.d.ts +119 -18
  288. package/dist/server.js +841 -202
  289. package/dist/settings-wake.d.ts +23 -0
  290. package/dist/settings-wake.js +65 -0
  291. package/dist/standard-webhooks.d.ts +4 -1
  292. package/dist/standard-webhooks.js +8 -4
  293. package/dist/store/agent-body.d.ts +14 -3
  294. package/dist/store/agent-body.js +14 -10
  295. package/dist/store/command-wake.d.ts +13 -0
  296. package/dist/store/command-wake.js +37 -0
  297. package/dist/store/dialect.d.ts +6 -0
  298. package/dist/store/dialect.js +5 -0
  299. package/dist/store/index.d.ts +1 -1
  300. package/dist/store/journal/storage.d.ts +3 -2
  301. package/dist/store/journal/storage.js +13 -5
  302. package/dist/store/postgres/connection.js +3 -1
  303. package/dist/store/postgres/dialect.js +4 -0
  304. package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
  305. package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
  306. package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
  307. package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
  308. package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
  309. package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
  310. package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
  311. package/dist/store/schema.d.ts +10 -1
  312. package/dist/store/schema.js +104 -15
  313. package/dist/store/sqlite/connection.d.ts +2 -2
  314. package/dist/store/sqlite/connection.js +2 -2
  315. package/dist/store/sqlite/run-patch.d.ts +7 -5
  316. package/dist/store/sqlite/run-patch.js +45 -18
  317. package/dist/store/sqlite/store.js +331 -72
  318. package/dist/store/store.d.ts +312 -21
  319. package/dist/store/store.js +12 -1
  320. package/dist/store-reads/cap.d.ts +1 -1
  321. package/dist/store-reads/cap.js +8 -1
  322. package/dist/store-reads/decisions.d.ts +2 -2
  323. package/dist/store-reads/decisions.js +1 -1
  324. package/dist/store-reads/import-summary.d.ts +1 -1
  325. package/dist/store-reads/journal.d.ts +30 -5
  326. package/dist/store-reads/journal.js +128 -56
  327. package/dist/store-reads/learning.d.ts +114 -12
  328. package/dist/store-reads/learning.js +238 -48
  329. package/dist/store-reads/loop.d.ts +61 -0
  330. package/dist/store-reads/loop.js +111 -0
  331. package/dist/store-reads/runs.d.ts +1 -1
  332. package/dist/store-reads/workflow.d.ts +1 -1
  333. package/dist/store-view.d.ts +6 -0
  334. package/dist/store-view.js +59 -26
  335. package/dist/template-eval.d.ts +18 -9
  336. package/dist/template-eval.js +95 -68
  337. package/dist/template-github-permissions.d.ts +24 -10
  338. package/dist/template-github-permissions.js +36 -15
  339. package/dist/template-import.d.ts +31 -0
  340. package/dist/template-import.js +121 -0
  341. package/dist/template-source.d.ts +51 -0
  342. package/dist/template-source.js +371 -0
  343. package/dist/templates.d.ts +218 -46
  344. package/dist/templates.js +493 -181
  345. package/dist/timeline/computer.d.ts +48 -0
  346. package/dist/timeline/computer.js +169 -0
  347. package/dist/timeline/index.d.ts +4 -3
  348. package/dist/timeline/index.js +4 -3
  349. package/dist/timeline/labels.d.ts +6 -2
  350. package/dist/timeline/labels.js +93 -2
  351. package/dist/timeline/origin.d.ts +19 -5
  352. package/dist/timeline/origin.js +11 -4
  353. package/dist/timeline/timeline.d.ts +22 -1
  354. package/dist/timeline/timeline.js +34 -18
  355. package/dist/timeline/util.d.ts +4 -0
  356. package/dist/timeline/util.js +14 -0
  357. package/dist/tool-gate.d.ts +84 -50
  358. package/dist/tool-gate.js +179 -101
  359. package/dist/tool-keys.d.ts +4 -1
  360. package/dist/tool-keys.js +8 -3
  361. package/dist/tool-list.d.ts +26 -0
  362. package/dist/tool-list.js +43 -0
  363. package/dist/tool-names.d.ts +71 -0
  364. package/dist/tool-names.js +99 -0
  365. package/dist/tool-plane.d.ts +33 -27
  366. package/dist/tool-plane.js +72 -39
  367. package/dist/tools.d.ts +32 -7
  368. package/dist/tools.js +37 -24
  369. package/dist/trigger-adapter.d.ts +4 -0
  370. package/dist/trigger-secrets-shown.d.ts +2 -2
  371. package/dist/trigger-secrets-shown.js +1 -1
  372. package/dist/trigger-signatures.d.ts +25 -6
  373. package/dist/trigger-signatures.js +41 -7
  374. package/dist/trigger-targets.d.ts +2 -0
  375. package/dist/trigger-targets.js +1 -0
  376. package/dist/trigger-webhook.js +5 -2
  377. package/dist/triggers.d.ts +7 -3
  378. package/dist/triggers.js +35 -5
  379. package/dist/turns.js +16 -1
  380. package/dist/validate.d.ts +15 -7
  381. package/dist/validate.js +102 -45
  382. package/dist/web-fetch.d.ts +2 -8
  383. package/dist/web-fetch.js +2 -22
  384. package/dist/web-search.d.ts +10 -5
  385. package/dist/web-search.js +7 -6
  386. package/dist/webhooks.d.ts +145 -102
  387. package/dist/webhooks.js +559 -322
  388. package/dist/workflow/decisions.d.ts +1 -1
  389. package/dist/workflow/node-runner.d.ts +2 -1
  390. package/dist/workflow/node.d.ts +2 -1
  391. package/dist/workflow/node.js +3 -1
  392. package/dist/workflow/pi-versions.d.ts +23 -0
  393. package/dist/workflow/pi-versions.js +57 -0
  394. package/dist/workflow/record-tool.d.ts +2 -1
  395. package/dist/workflow/store.d.ts +1 -1
  396. package/dist/workflow/task.js +3 -2
  397. package/dist/workflow-run.d.ts +1 -1
  398. package/dist/workspace/attached-computers.d.ts +41 -0
  399. package/dist/workspace/attached-computers.js +114 -0
  400. package/dist/workspace/computer-deps.d.ts +19 -9
  401. package/dist/workspace/computer-deps.js +24 -9
  402. package/dist/workspace/computer-for-claim.d.ts +23 -8
  403. package/dist/workspace/computer-for-claim.js +92 -33
  404. package/dist/workspace/computer-hold.d.ts +11 -27
  405. package/dist/workspace/computer-hold.js +41 -55
  406. package/dist/workspace/computer-ledger.d.ts +3 -1
  407. package/dist/workspace/computer-ledger.js +4 -0
  408. package/dist/workspace/computer-mcp.d.ts +25 -0
  409. package/dist/workspace/computer-mcp.js +41 -0
  410. package/dist/workspace/computer-ports.d.ts +4 -13
  411. package/dist/workspace/computer-ports.js +4 -107
  412. package/dist/workspace/computer-script.d.ts +53 -0
  413. package/dist/workspace/computer-script.js +172 -0
  414. package/dist/workspace/executors.d.ts +1 -1
  415. package/dist/workspace/index.d.ts +4 -2
  416. package/dist/workspace/index.js +3 -1
  417. package/dist/workspace/kind-skills/desktop/SKILL.md +132 -84
  418. package/dist/workspace/kind-skills/phone/SKILL.md +104 -85
  419. package/dist/workspace/local.js +2 -2
  420. package/dist/workspace/resolve-computer.d.ts +24 -1
  421. package/dist/workspace/resolve-computer.js +40 -16
  422. package/dist/workspace/run-tools.d.ts +56 -21
  423. package/dist/workspace/run-tools.js +55 -34
  424. package/dist/wrap-up.d.ts +21 -0
  425. package/dist/wrap-up.js +21 -0
  426. package/launcher/agentrun-serve +4 -2
  427. package/package.json +19 -16
  428. package/templates/README.md +111 -45
  429. package/templates/code-review/agent.md +30 -14
  430. package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
  431. package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
  432. package/templates/code-review/evals/injection/case.yaml +2 -1
  433. package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
  434. package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
  435. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
  436. package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
  437. package/templates/code-review/evals/never-flag/case.yaml +2 -1
  438. package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
  439. package/templates/code-review/evals/null-name/case.yaml +2 -1
  440. package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
  441. package/templates/code-review/evals/off-by-one/case.yaml +2 -1
  442. package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
  443. package/templates/code-review/evals/other-repo/case.yaml +16 -0
  444. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
  445. package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
  446. package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
  447. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
  448. package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
  449. package/templates/code-review/evals/other-repo/prompt.md +10 -0
  450. package/templates/code-review/evals/re-review/case.yaml +2 -1
  451. package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
  452. package/templates/code-review/evals/re-review-open/case.yaml +2 -1
  453. package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
  454. package/templates/code-review/evals/repo-rule/case.yaml +2 -1
  455. package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
  456. package/templates/code-review/evals/two-defects/case.yaml +2 -1
  457. package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
  458. package/templates/code-review/rules/CODEREVIEW.md +1 -1
  459. package/templates/code-review/skills/review/DEEP.md +3 -2
  460. package/templates/code-review/skills/review/REVIEWER.md +3 -2
  461. package/templates/code-review/skills/review/SKILL.md +4 -3
  462. package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
  463. package/templates/inbound-lead/agent.md +26 -16
  464. package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
  465. package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
  466. package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
  467. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
  468. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
  469. package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
  470. package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
  471. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
  472. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
  473. package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
  474. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
  475. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
  476. package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
  477. package/templates/kyb/agent.md +15 -5
  478. package/templates/kyb/evals/adverse-media/prompt.md +2 -7
  479. package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
  480. package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
  481. package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
  482. package/templates/kyb/evals/name-collision/prompt.md +2 -6
  483. package/templates/kyb/evals/no-invention/prompt.md +2 -6
  484. package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
  485. package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
  486. package/templates/kyb/kyb.schema.json +8 -7
  487. package/templates/kyb/skills/kyb/SKILL.md +9 -6
  488. package/templates/market-monitor/agent.md +19 -12
  489. package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
  490. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
  491. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
  492. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
  493. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  494. package/templates/release-notes/agent.md +32 -10
  495. package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
  496. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
  497. package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
  498. package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
  499. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
  500. package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
  501. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
  502. package/templates/release-notes/evals/learned-style/case.yaml +2 -1
  503. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
  504. package/templates/release-notes/evals/other-repo/case.yaml +24 -0
  505. package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
  506. package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
  507. package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
  508. package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
  509. package/templates/release-notes/evals/other-repo/prompt.md +32 -0
  510. package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
  511. package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
  512. package/templates/release-notes/notes.schema.json +1 -1
  513. package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
  514. package/dist/console/assets/index-BI4Byidu.js +0 -550
  515. package/dist/console/assets/index-C19gUF2n.css +0 -1
  516. package/dist/run-db.d.ts +0 -53
  517. package/dist/run-db.js +0 -116
  518. package/dist/tool-blurbs.d.ts +0 -4
  519. package/dist/tool-blurbs.js +0 -28
  520. package/dist/tool-budget.d.ts +0 -26
  521. package/dist/tool-budget.js +0 -56
  522. package/dist/workflow/readers.d.ts +0 -36
  523. package/dist/workflow/readers.js +0 -145
  524. package/dist/workflow/wal.d.ts +0 -11
  525. package/dist/workflow/wal.js +0 -106
  526. package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
  527. package/templates/code-review/evals/injection/graders/schema.md +0 -5
  528. package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
  529. package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
  530. package/templates/code-review/evals/null-name/graders/schema.md +0 -5
  531. package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
  532. package/templates/code-review/evals/re-review/graders/schema.md +0 -5
  533. package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
  534. package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
  535. package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
  536. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
  537. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
  538. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
  539. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
  540. package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
  541. package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
  542. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
  543. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
  544. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
  545. package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
  546. package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
  547. package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
  548. package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
  549. package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
  550. package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
  551. package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
  552. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
  553. package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
  554. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
  555. package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
  556. package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
  557. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
  558. package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
  559. package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
  560. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
  561. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
  562. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
  563. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
  564. package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
  565. package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
  566. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
  567. package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
  568. package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
package/dist/cap.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
- import { type Ended } from "@parcha/agentrun-kernel";
3
1
  import { type EntryLike } from "./timeline/index.js";
4
- import type { Api, AssistantMessage, Context, Model, Models } from "@earendil-works/pi-ai";
5
2
  /** How a request the cap refused begins its error, which the server ends the run with. */
6
3
  export declare const SPEND_CAP_REACHED = "spend_cap_reached";
7
4
  /** How near two dollar figures are the same figure: a sum a float puts a hair past the cap (0.0028 + 0.3072 is
@@ -11,90 +8,11 @@ export declare const CAP_TOLERANCE = 1e-9;
11
8
  * against a 0.31 cap), never a spend that is past the cap, by however little (a 1e-11 hair is past it). CAP_TOLERANCE
12
9
  * is the other question: how near two caps are the same cap. */
13
10
  export declare const FIT_TOLERANCE = 1e-12;
14
- /** The option a request's hold rides on from the cap to its marks (request-start.ts): what the cap held for it, its
15
- * expected cost (its worst case under strict). A symbol, so no provider ever sends it. */
16
- export declare const HELD_USD: unique symbol;
17
- /** The option a request's bound rides on to its start mark (request-start.ts, as BOUND_FIELD): the most a cache miss can
18
- * make it cost beyond its hold (its input uncached less its input expected; 0 under strict). A symbol, as HELD_USD. */
19
- export declare const BOUND_USD: unique symbol;
20
- /** The field of a request's start mark that keeps its bound (BOUND_USD), on pi and on another harness (harness-app.ts):
21
- * the run's cost serves it while the request is in flight, and the over-cap row names it (runs.ts). Absent for 0. */
22
- export declare const BOUND_FIELD = "boundUsd";
23
11
  /** How a run's cap prices a request's input (`cap_mode`): "expected" (the default) from the previous request's cache, so
24
12
  * only a cache miss can pass the cap, by at most the request's bound; "strict" every input token uncached, the worst
25
13
  * case, so no request can pass it. */
26
14
  export declare const CAP_MODES: readonly ["expected", "strict"];
27
15
  export type CapMode = (typeof CAP_MODES)[number];
28
- /** How long after a request ended the next one in its conversation is expected to read its cache: 4 minutes, inside
29
- * Anthropic's 5 (a cache kept that long from its last use; OpenAI's lasts longer). A request later than that is priced
30
- * with nothing cached. */
31
- export declare const CACHE_WARM_MS: number;
32
- /** The previous request of a conversation, as the cap reads it: the input tokens its usage reported read from the cache
33
- * or written to it (`cachedTokens`: cache_read + cache_creation, or the Responses API's cached_tokens), the rest of its
34
- * input (`inputTokens`), its input bound (`boundTokens`, inputBound of what it sent: the unit this request's bound is in),
35
- * and when it ended (`endedAt`, ms). */
36
- export type Previous = {
37
- cachedTokens: number;
38
- inputTokens: number;
39
- boundTokens: number;
40
- endedAt: number;
41
- };
42
- /** A request's input as it is priced: `cached` tokens at the cache-read price, `fresh` ones at the dearer of the input
43
- * and cache-write prices. */
44
- export type InputParts = {
45
- cached: number;
46
- fresh: number;
47
- };
48
- /** A request's Previous from the usage it reported (pi's shape: `input` without the cache's reads and writes), its input
49
- * bound and when it ended; undefined when its usage says no input (a usage not read is zeros, never a count) or a
50
- * figure is not a count. */
51
- export declare function previousOf(usage: {
52
- input?: unknown;
53
- cacheRead?: unknown;
54
- cacheWrite?: unknown;
55
- } | undefined, boundTokens: number | undefined, endedAt: number): Previous | undefined;
56
- /** The input of a request of `bound` tokens (inputBound) expected after `previous`, at `now`: the previous request's
57
- * cached input read from the cache, and its input after the cache plus what the body grew by since it (in the bound's
58
- * own unit, bytes, which a token never is fewer of) at full price. Undefined, the whole input uncached, with no previous
59
- * request, one that ended CACHE_WARM_MS or more ago, or a clock that reads before its end. On a cache hit of a
60
- * conversation that grew, what the request is billed for is within this; a miss costs at most its input uncached. */
61
- export declare function expectedInput(bound: number, previous: Previous | undefined, now: number): InputParts | undefined;
62
- /** The wrap-up's trigger (wrapUpDue): what is left of a cap under this many times a priced request's typical cost. */
63
- export declare const WRAP_UP_FACTOR = 3;
64
- /** The wrap-up's other trigger: what is left under this many times the next request's least admission (its least output
65
- * at its price: what the cap refuses it below), room for about one more request, so a run whose requests need far more
66
- * than they cost (a reasoning model's least, Codex's at "high") is told before the cap refuses it. */
67
- export declare const WRAP_UP_LEAST_FACTOR = 2;
68
- /** The output a request is counted at as the wrap-up's typical cost while nothing is priced (step 0): its input bound and
69
- * this many output tokens at the model's price, never its whole output allowance (the hold), which no turn uses and which
70
- * made every cap under about $3 on Sonnet 4.5 hear the wrap-up before the run had done anything. The lead's ruling (d),
71
- * 2026-11-07 (Manuel's retest: every $1 run told at its start). Admission's hold and bound are unchanged. */
72
- export declare const WRAP_UP_STEP0_ANSWER_TOKENS = 4096;
73
- /** A priced request's typical cost, for the wrap-up's trigger: the median of `costs` (the run's own model's requests, a
74
- * cost known and above 0) after the first, which writes the cache and costs several warm ones; with one priced request,
75
- * that one; with none, `nextExpected`, the next request's expected cost (what admission holds it at). No wait for a
76
- * count of requests: a small cap may never reach one, and that run needs the wrap-up most. */
77
- export declare function typicalCost(costs: readonly unknown[], nextExpected: number): number;
78
- /** Whether a run near its cap is due its wrap-up: what is left (`cap` less `spent` and `held`, as admission counts it)
79
- * is under WRAP_UP_FACTOR times `typical`, or under WRAP_UP_LEAST_FACTOR times `leastUsd`, the next request's least
80
- * admission as the cap prices it (CapGuard.leastUsd, Judged.least), when known. The same rule under strict. */
81
- export declare function wrapUpDue(cap: number, spent: number, held: number, typical: number, leastUsd?: number): {
82
- leftUsd: number;
83
- } | undefined;
84
- /** The wrap-up's words, what is left to the cent. `nonePriced`: the run's own model has no priced request yet, so its
85
- * typical cost is the next request's expected cost and the note can come before the run has done anything (step 0):
86
- * the words say the budget and ask for a short answer, not a finish. Read from the same priced costs live and in a
87
- * process opened again (ownCosts), so a restart picks the same words. */
88
- export declare const wrapUpWords: (leftUsd: number, nonePriced?: boolean) => string;
89
- /** A request priced at `price` under `mode`, its input `bound` tokens after `previous` at `now`, plus `feeUsd`: `cost`, what
90
- * it is held at given its output tokens (its expected input, never more than uncached), and `worst`, its input uncached.
91
- * The one rule pi's guard (capModels) and another harness's (capBefore) call. */
92
- export declare function requestPrice(price: (input: InputParts, output: number) => number, bound: number, previous: Previous | undefined, now: number, mode: CapMode, feeUsd?: number): {
93
- cost(output: number): number;
94
- worst(output: number): number;
95
- };
96
- /** Records that `message` ended on an error after its response began. */
97
- export declare const markResponseBegan: (message: AssistantMessage) => void;
98
16
  /** The field of a request's end mark (REQUEST_ENDED) that says what the cap held for it, when its stream ended aborted
99
17
  * or its summary failed: the request counts at that figure. Optional: an end with none (an older store, a run with no
100
18
  * cap) leaves the request cut, at an unknown cost. */
@@ -102,70 +20,6 @@ export declare const HELD_FIELD = "heldUsd";
102
20
  /** The field of the start mark (REQUEST_STARTED) written for a request this cap refused: it never left, and pi's error
103
21
  * entry for it answers this mark, never an earlier request's. */
104
22
  export declare const CAP_REFUSED_FIELD = "capRefused";
105
- /** The option a request the cap limited rides on to its start mark (request-start.ts, as `clamp`): the output tokens it was
106
- * limited to, what was left of the cap for it, and the cap, so a reply cut short there says so. */
107
- export declare const CLAMP: unique symbol;
108
- /** The tokens a limited request keeps for its answer (pi-ai's MIN_ANSWER_TOKENS): a request is refused, never sent, when
109
- * what is left of its cap cannot buy them (or what it asked for, when it asked for fewer). */
110
- export declare const ANSWER_TOKENS_LEAST = 1024;
111
- /** The least thinking budget Anthropic takes: a request that thinks on an API whose thinking takes a budget keeps it
112
- * beside its answer, the budget squeezed to it at the least. */
113
- export declare const THINKING_BUDGET_LEAST = 1024;
114
- /** The output tokens a request the person stopped counts beyond what it streamed: what the provider may have produced after
115
- * the last word read, before it saw the stop. A stopped request counts its input, each byte it streamed as a token, and
116
- * these, never more than it was held at (stoppedFigure). A stated bound, as NATIVE_SEARCH_ALLOWANCE_TOKENS is. */
117
- export declare const STOP_ALLOWANCE_TOKENS = 1024;
118
- /** The option a request's stopped figure rides on to its end mark (request-start.ts): what it counts at, given the answer
119
- * it streamed, when it is stopped before its end. A symbol, so no provider ever sends it. */
120
- export declare const STOPPED_USD: unique symbol;
121
- /** What a model answer streamed, in bytes: its text, its thinking, and each tool call's name and arguments as JSON. Each
122
- * byte counts as a token (a byte-level tokenizer never makes a token of less than one byte), as inputBound counts input. */
123
- export declare function streamedBytes(message: {
124
- content?: unknown;
125
- } | undefined): number;
126
- /** What of a model answer's reasoning streamed, in bytes (streamedBytes' unit): its thinking blocks. */
127
- export declare function reasoningBytes(message: {
128
- content?: unknown;
129
- } | undefined): number;
130
- /** A request's figure if it is stopped before its end, given the answer it had streamed. */
131
- export type Stopped = (message: {
132
- content?: unknown;
133
- }) => number;
134
- /** What a request stopped before its end counts at: its input and `streamed` tokens plus STOP_ALLOWANCE_TOKENS of output,
135
- * at most the output it was sent with (`limit`), at `cost`'s price; never more than `worst`, what it was held at. */
136
- export declare const stoppedFigure: (cost: (output: number) => number, limit: number, worst: number, streamed: number) => number;
137
- /** What a stopped request counts at, having streamed `streamed` tokens: those and STOP_ALLOWANCE_TOKENS of output, at
138
- * most the output it was sent with (`limit`), at `cost`'s price; bookRequest keeps it within the hold. */
139
- export declare const stoppedPriceOf: (cost: (output: number) => number, limit: number) => (streamed: number) => number;
140
- /** The option a request's attempts ride on to its marks (request-start.ts): each HTTP attempt pi-ai made for it, as the
141
- * fetch the cap gave it saw them. A symbol, so no provider ever sends it. */
142
- export declare const ATTEMPTS: unique symbol;
143
- /** One attempt of a request: the status it was answered with, or the code its fetch was refused with, `aborted` when the
144
- * request's own signal had fired by then (the run stopped it: no attempt lost to the provider). */
145
- export type Attempt = {
146
- status: number;
147
- } | {
148
- code: string | undefined;
149
- aborted?: true;
150
- };
151
- /** The APIs whose requests the cap cannot watch through a fetch, each with why: it gives them no recording fetch, and
152
- * a request on one that fails before any event books its hold (piEnded). The one table both read. */
153
- export declare const UNWATCHED_APIS: Readonly<Record<string, string>>;
154
- /** A fetch that does what `inner` does (globalThis.fetch by default) and records each attempt in `attempts`. An attempt
155
- * is `aborted` only when the request's own signal (`stop`, the run's) had fired: the SDKs hand fetch a signal of their
156
- * own, which they also abort on their own timeout, and an attempt that timed out left, so it is lost, never a stop. */
157
- export declare function recordingFetch(attempts: Attempt[], inner?: typeof fetch, stop?: AbortSignal): typeof fetch;
158
- /** Whether one attempt was lost: refused after it could have left (any code but a connect one), a gateway's timeout, or
159
- * an answer that was not the request's last attempt (pi-ai tried again after it). That last reading assumes every fetch
160
- * through the recorder is a model attempt. pi-ai's Anthropic workload identity federation (anthropic-messages.js,
161
- * getAnthropicFederation) exchanges its token through the same fetch, so under it "a 2xx that was not the last" would
162
- * read every answer as lost. It arms only when no API key or auth header resolves, and serve always gives pi-ai an API
163
- * key, so it never arms here. */
164
- export declare const attemptLost: (a: Attempt, last: boolean) => boolean;
165
- /** Whether any attempt of a request was lost (attemptLost), its last counted as the last; one the run's own stop cut is
166
- * none. A request lost so counts at its hold however it then ended: answered, failed or stopped. */
167
- export declare const anyAttemptLost: (attempts: readonly Attempt[] | undefined) => boolean;
168
- export declare function piEnded(message: Pick<AssistantMessage, "stopReason" | "usage" | "api">, began: boolean, attempts: readonly Attempt[] | undefined): Ended;
169
23
  /** How pi's error for a request whose start mark could not be written begins (request-start.ts builds it from this): the
170
24
  * request never left, so the entry answers none, and spentFrom leaves it out by this. */
171
25
  export declare const MARK_NOT_WRITTEN = "the model request was not sent: its mark could not be written";
@@ -176,16 +30,6 @@ export declare const END_NOT_WRITTEN = "the model request's end could not be rec
176
30
  * by its adapter (adapters.ts hands it over): Claude's CLI asks for at most 8 searches a request (max_uses 8), and each
177
31
  * search's results are billed as input, about 25,000 tokens a search as a working estimate. */
178
32
  export declare const NATIVE_SEARCH_ALLOWANCE_TOKENS: number;
179
- /** A tool's own request through the run's models (`completeSimple`), by its context: the label its marks carry, the
180
- * input its hosted tool may add beyond its context (results billed as input) and the most fee it can run up, which the
181
- * cap holds (cap.ts), and the fee its tokens do not show (its searches), read once it ended. */
182
- export type SideRequest = {
183
- label: string;
184
- extraInputTokens: number;
185
- maxFeeUsd: number;
186
- feeUsd(): number;
187
- };
188
- export declare const sideRequests: WeakMap<object, SideRequest>;
189
33
  /** The code a cap's refusal begins with: `spend_cap_reached: `, or with a note after it, as a request it limited refuses
190
34
  * in (CAP_REFUSAL_CODE, "spend_cap_reached (out of budget): "). Every reader of a refusal's text (a run's end, its
191
35
  * learning, the spend read back) reads the code through this, never a bare prefix. */
@@ -201,23 +45,6 @@ export declare const costOf: (entry: EntryLike) => number;
201
45
  * figure its start mark holds (openFigures), each the worst case the cap held for it; without that figure either stays
202
46
  * cut, at an unknown cost. This cap's refusals are left out, as none left. Unknown is null, which a cap never reads as $0. */
203
47
  export declare function spentFrom(rows: readonly EntryLike[]): number | null;
204
- /** A workflow decision's charge as the cap counted it (decision-cap.ts): `call` names the request, `usd` what it charged,
205
- * or its hold when it said none. The run's shown cost reads its decisions from their receipts; this is the cap's own
206
- * reading, kept so a later process counts each decision as this one did. costOf counts none, so nothing counts twice. */
207
- export declare const DECISION_COST = "agentrun.decision_cost";
208
- /** A decision request's hold, kept before it is sent (decision-cap.ts): with no DECISION_COST after it, its process died
209
- * while it was out, and it counts at this figure. */
210
- export declare const DECISION_HOLD = "agentrun.decision_hold";
211
- /** What a workflow run's decisions cost, in its store: what the next process adds to spentFrom's reading. Per decision
212
- * (its id):
213
- * - booked (DECISION_COST entries, at its charge, its hold, or $0 for nothing charged): the larger of what was booked,
214
- * with any hold no booking ended, and what its receipts say it cost (the costs the timeline's decision rows sum);
215
- * - else, with a receipt that names its charge: that charge (its booking lost after the receipt);
216
- * - else, with a hold (DECISION_HOLD, kept once the driver admitted the request, right before its send): that hold, the
217
- * figure the live process held, since the request may have been out when its process died; never $0;
218
- * - else nothing: no hold is kept before the admission, so a request never sent is never counted.
219
- * A booking with no decision id is counted as it is. */
220
- export declare function decisionSpentIn(storeFile: string): number;
221
48
  /** /usage's meters for a run that ended, from its store: `tools`, each TOOL_COST's `usd`, unknown (null) when one is,
222
49
  * or when a call was cut (marked, never settled: what it charged no one knows); and `tokens`, the rest of its root
223
50
  * conversation as its settled timeline prices it; `browser`, the part of `tools` that is browser session time
@@ -255,120 +82,6 @@ export declare function meterFiguresFrom(rows: readonly {
255
82
  others: number;
256
83
  };
257
84
  };
258
- /** What the paid tools of `entries` (TOOL_STARTED and TOOL_COST) spent, as the cap counts it: each charge, and a call
259
- * settled at a charge it did not say, or a crash cut (marked, never settled), at its held figure, as spentFrom counts it;
260
- * null when one has no figure. The run's reported cost reads such a call unknown instead (the timeline). */
261
- export declare function capToolSpend(entries: readonly EntryLike[]): number | null;
262
- /** The worst case of each model request a cap admitted and whose cost is not booked yet, by its turn, for a paid tool's
263
- * check on a harness whose booking counts a request only once its cost is in (harness-app.ts): `admitted` takes what
264
- * the guard held, `started` gives it the turn that request leaves as (admissions run one at a time), `ended` drops it. */
265
- export declare function holdsInFlight(): {
266
- admitted: (usd: number | undefined) => undefined;
267
- started: (turn: number) => undefined;
268
- ended: (turn: number) => undefined;
269
- total: () => number;
270
- };
271
- /** The run's spend as its process counts it, for a paid tool: what it has spent (`spent`; null when unknown), what its
272
- * model requests in flight are held at, at their worst case (`held`, read once `spent` is in; absent: none apart from
273
- * `spent`), and the charge a call adds (`add`). Set by the run's cap, on pi (capModels) and on another harness
274
- * (harness-app.ts); none without a cap. A run is one process, so one is set per process. `now`: the whole figure read at
275
- * once, held requests included, with no wait for a cost still coming in (another harness sets it). */
276
- export type RunSpend = {
277
- cap: number;
278
- spent(): number | null | Promise<number | null>;
279
- held?(): number;
280
- add(usd: number | null): void;
281
- now?(): number | null;
282
- /** Raises the cap this process keeps to `to` (a raise of the run's cap, read by budget.ts): from the next check on. */
283
- raise?(to: number): void;
284
- /** A workflow run's wait for a raise (budget.ts), set once its run opens: a request refused for room waits on it before
285
- * it is sent, and is judged again once it resolves true (the cap was raised); false (a cancel, its signal) refuses it
286
- * as before. Absent on an agentic run, whose turn ends on the refusal instead. */
287
- wait?(refusal: CapRefusal, signal?: AbortSignal): Promise<boolean>;
288
- /** A workflow run's record of a refusal no raise fixes (budget.ts), which its run ends on, in the cap's words. */
289
- stopped?(refusal: CapRefusal): void;
290
- };
291
- /** A refusal of the cap, as a call that was refused is told it: its words (after the code, as a pause serves them),
292
- * whether a higher cap would send it (`room`; not so for no price, no ceiling or an unknown spend), the cap that refused
293
- * it, and its figures when it was refused for room. */
294
- export type CapRefusal = {
295
- words: string;
296
- room: boolean;
297
- capUsd: number;
298
- figures?: RefusalFigures;
299
- };
300
- /** Where a refusal of the cap inside a workflow call node's effect is told (app.ts runEffect): the call ends on it and
301
- * waits for a raise, never handed back as the tool's own failure, which a collecting map would take as the item's. A
302
- * paid call refused there leaves no refusal for a model's next request (takePaidRefusal): no model turn follows it. */
303
- export declare const capRefusals: AsyncLocalStorage<(refusal: CapRefusal) => void>;
304
- /** The run's spend this process counts, when it has a cap: for a workflow run's waits and decisions (app.ts). */
305
- export declare const runSpendNow: () => RunSpend | undefined;
306
- export declare const useSpend: (spend: RunSpend | undefined) => void;
307
- /** What the paid calls under way are held at, together (0 when none is): the one figure every check of the run's cap
308
- * adds to what the run has spent, a model request's (capModels, capBefore) and a paid call's (paidCall). */
309
- export declare const paidHolds: () => number;
310
- /** A paid hold that outlives the paidCall that took it (a browser session's, browser-cost.ts), counted in paidHolds as a
311
- * call's is until `drop`: its figure is `usd`, which its owner moves as charges use it. */
312
- export declare const keepHold: (usd: number) => {
313
- usd: number;
314
- drop(): void;
315
- };
316
- /** A charge booked outside any paidCall (a browser session's, booked in the commit that bills it) joins what the run's
317
- * process counts as spent, as a paid call's does; with no cap, nothing counts it. */
318
- export declare const addSpend: (usd: number | null) => void;
319
- /** The run's cap, when it has one. */
320
- export declare const runCap: () => number | undefined;
321
- /** The paid call's refusal the next model request of the run whose spend is `owner` is refused with, once: undefined
322
- * when there is none, or it is another spend's. Only a run's own guard asks (capModels for pi, harness-app.ts for the
323
- * others), never a guard a caller builds apart. */
324
- export declare function takePaidRefusal(owner: RunSpend | undefined): {
325
- words: string;
326
- figures: RefusalFigures;
327
- } | undefined;
328
- export declare function paidCall<T>(name: string, call: () => Promise<T>, charge: (result: T) => number | null | undefined, hold: {
329
- usd: number;
330
- basis: string;
331
- }, options?: {
332
- pauses?: boolean;
333
- }): Promise<{
334
- refused: string;
335
- leastCapUsd?: number;
336
- } | {
337
- result: T;
338
- }>;
339
- /** A paid call's hold, taken ahead of the call by the rule paidCall keeps (a workflow's decision, decision-cap.ts, which
340
- * must wait for a raise before its request is admitted, never after): refused unless what the run has spent plus what
341
- * is held plus `hold` fits the cap, and whenever the spend is unknown; else held (paidHolds) until the ticket settles it
342
- * at the charge the call reports (null: at its hold, as paidCall counts a charge not said) or drops it (nothing was
343
- * sent). The check takes its turn with paidCall's, but the call it holds for goes beside other calls: each check sees the
344
- * holds of those under way. A refusal for room waits on the run's wait (RunSpend.wait) when it has one and is checked
345
- * again once the cap is raised. With no cap it holds nothing. */
346
- export type PaidTicket = {
347
- settle(usd: number | null): void;
348
- drop(): void;
349
- };
350
- export declare function holdPaid(name: string, hold: {
351
- usd: number;
352
- basis: string;
353
- }, signal?: AbortSignal): Promise<{
354
- refused: CapRefusal;
355
- } | {
356
- ticket: PaidTicket;
357
- }>;
358
- /** The most output tokens one request may take: the model's ceiling, else its context window. A thinking budget can
359
- * raise a request's ceiling up to the model's, whatever maxTokens it asked for. */
360
- export declare const ceilingTokens: (model: Pick<Model<Api>, "maxTokens" | "contextWindow">) => number;
361
- /** A request's input tokens, bounded above: one per UTF-8 byte of what is sent (a byte-level tokenizer never takes
362
- * fewer than one byte a token), plus `overhead`: what the provider adds server-side that the body does not hold, and
363
- * each image at what it is billed as in place of its base64's bytes (below 0 for a large image: piOverhead). The same
364
- * bound on every harness. */
365
- export declare const inputBound: (sent: string, overhead?: number) => number;
366
- /** What pi's provider adds server-side to a request of `context`, the same table the model proxy uses, by the model's API
367
- * kind: undefined for a kind whose additions are not known. The context does not say how the request chooses a tool,
368
- * so the dearer choice is taken. */
369
- export declare function piOverhead(model: Pick<Model<Api>, "api"> & {
370
- id?: string;
371
- }, context: Context): number | undefined;
372
85
  /** An amount in words: two decimals, or as many as it takes (up to eight) to show it whole ($0.50, $0.105, $0.0005). */
373
86
  export declare function money(usd: number): string;
374
87
  /** The code a cap's refusal begins with: `spend_cap_reached`, which the server ends the run with, and "out of budget",
@@ -392,123 +105,3 @@ export type RefusalFigures = {
392
105
  * higher cap would send; undefined for any other text, a refusal no cap could fix included (an unknown spend, no price,
393
106
  * no output ceiling, an input not measured: the bare `spend_cap_reached: ` code). The one reader of that difference. */
394
107
  export declare const roomRefusal: (text: string | undefined) => string | undefined;
395
- /** A least in words: rounded up to the cent, so that it is enough ($0.1024 is $0.11). */
396
- export declare const leastMoney: (usd: number) => string;
397
- /** The cap to raise to for a request past `cap` that needs `total` in all: a cent at least, and above the cap, never
398
- * the cap itself, so a raise to it is one PATCH /runs/{id} takes. */
399
- export declare const raiseTo: (cap: number, total: number) => string;
400
- /** raiseTo's cap as a number, whole cents in dollars: the figure a refusal carries beside its words (leastCapUsd). */
401
- export declare const raiseFigure: (cap: number, total: number) => number;
402
- /** An amount in words, to the nearest cent ($0.0237416 is $0.02), as money says it ($1, $0.20, $0). */
403
- export declare const centsMoney: (usd: number) => string;
404
- /** The least output a pi request may be limited to and still answer: the answer's 1,024 tokens, and when it thinks,
405
- * the least budget on an API whose thinking takes one (squeezed to it), else its thinking level's budget, since its
406
- * reasoning then shares the limit. */
407
- export declare function leastOutput(model: Pick<Model<Api>, "api" | "reasoning">, thinking: string | undefined, budgetOf: (level: string) => number): number;
408
- /** The cap of a run on another harness, before each of its requests: the runner's booking says what the run has spent
409
- * (its session, across processes) and which of its requests are still in flight, each with what it was admitted at;
410
- * the model proxy says each request's input bound (`inputTokensMax`, inputBound of its body; undefined when the body
411
- * could not be measured), the output it asks for, and the least it may be limited to; and the host the session's
412
- * previous request on the same model, as its usage reported it (`previous`, harness-app.ts). */
413
- export interface CapGuard {
414
- beforeRequest(request: GuardRequest): ({
415
- refuse: string;
416
- } & Partial<RefusalFigures>) | Admitted;
417
- /** A request's least admission (its input and least output at its price, under `previous`), the figure beforeRequest
418
- * refuses it below, priced by the same code: the wrap-up's other trigger reads it for the next request (wrapUpDue).
419
- * Undefined for an input that cannot be measured, and on a guard that refuses everything. */
420
- leastUsd?(request: Pick<GuardRequest, "inputTokensMax" | "outputTokensAsked" | "outputTokensLeast" | "previous">): number | undefined;
421
- /** A request's step-0 figure (its input and WRAP_UP_STEP0_ANSWER_TOKENS of output, at most what it asks, under
422
- * `previous`), priced by the same code: the wrap-up's typical cost while nothing is priced, judged on the request taking
423
- * the note itself, as pi's judge does (wrapUpDue). Undefined for an input that cannot be measured. */
424
- typicalUsd?(request: Pick<GuardRequest, "inputTokensMax" | "outputTokensAsked" | "outputTokensLeast" | "previous">): number | undefined;
425
- }
426
- /** A request this guard admitted: the most output it may be sent with (none for a model whose output is free and has no
427
- * ceiling), what it is held at (`holdUsd`: its expected cost at that output, its worst case under strict), which the
428
- * runner records for it and counts it at when its own cost never comes in (cut short, or by a crash), its bound
429
- * (`boundUsd`, BOUND_USD), and what it counts at if its client stops it part way having streamed that many tokens (one a
430
- * byte): its input and those tokens plus STOP_ALLOWANCE_TOKENS of output, at most its output limit, never more than its
431
- * hold. */
432
- export type Admitted = {
433
- outputTokensMax?: number;
434
- holdUsd: number;
435
- boundUsd: number;
436
- stoppedUsd(streamed: number): number;
437
- };
438
- export type GuardRequest = {
439
- spentUsd: number | null;
440
- /** The requests in flight, each held at what it was admitted at (`holdUsd`), else at its worst case at the output limit
441
- * it was admitted with. */
442
- inFlight: readonly {
443
- inputTokensMax?: number;
444
- outputTokensMax?: number;
445
- holdUsd?: number;
446
- }[];
447
- inputTokensMax?: number;
448
- outputTokensAsked?: number;
449
- outputTokensLeast?: number;
450
- /** A request the run sends beside the harness's, on the session's route (ModelRequest.host): judged by the same rule. */
451
- host?: string;
452
- /** The session's previous request on this model (Previous); none, the whole input uncached. */
453
- previous?: Previous;
454
- };
455
- /** A run on another harness: before each request, what the run has spent, plus what each request still in flight was
456
- * admitted at, must leave room for this request at its least output (1,024 tokens, or what its body says it needs to
457
- * think and answer; what it asks for when that is fewer), its input priced by requestPrice under `mode`, else the request
458
- * is refused with spend_cap_reached. Admitted, it is limited to the most output what is left buys (`outputTokensMax`, at
459
- * most what it asks for and its model's ceiling), which the model proxy writes into its body: output never passes the
460
- * cap. A request is priced at the run model's price, as on pi (a request on a cheaper model is held at that price too,
461
- * which only refuses sooner). What cannot be kept within a cap is refused under one: a spend that is unknown (a request a
462
- * crash cut), an input that could not be measured, a model serve has no price for (`listed: false`, or none at all),
463
- * and a model whose output is priced and that has no output ceiling. With no cap, nothing is refused. `now`: the clock a
464
- * previous request's end is read against. */
465
- export declare function capBefore(cap: number | undefined, model: Model<Api> | undefined, { listed, mode, now }?: {
466
- listed?: boolean;
467
- mode?: CapMode;
468
- now?: () => number;
469
- }): Promise<CapGuard | undefined>;
470
- /** A request's input bound (inputBound of its context, plus `overhead(model, context)`, what its provider adds
471
- * server-side) and the most fee it can run up: a tool's own request adds what its hosted tool may read
472
- * (hosted-search.ts), and its most fee. Undefined when its input cannot be measured. */
473
- export declare function requestParts(overhead?: (model: Model<Api>, context: Context) => number | undefined): (model: Model<Api>, context: Context) => {
474
- input: number;
475
- feeUsd: number;
476
- } | undefined;
477
- /** The wrap-up on pi (capModels' `wrapUp`): the run's own model (`model`, its id), that model's priced requests so far
478
- * (`costs`; capModels adds each one it books), whether it was told under this
479
- * cap already (`sent`), and `record`, which writes its row (request-start.ts, CAP_WRAPUP). */
480
- /** The wrap-up's state on pi. `sent`: told, in an answered request, once per cap. `pending`: a request carries the note
481
- * and has not ended: no other request takes it until that one is answered (told) or not (re-armed). */
482
- export type WrapUp = {
483
- model: string;
484
- costs: number[];
485
- sent: boolean;
486
- pending?: boolean;
487
- record(data: {
488
- capUsd: number;
489
- leftUsd: number;
490
- words: string;
491
- }): void;
492
- };
493
- /** `models`, each request limited to the output tokens what is left of `cap` after `spent` USD (and what requests in flight
494
- * hold) can buy, at most what it asks for, thinking included (CLAMP on its marks when that is less), and refused when that
495
- * cannot buy its least (`leastOutput`: 1,024 tokens for the answer, and its thinking's least), saying so in plain words;
496
- * and, under the cap,
497
- * each request to a model in `unpriced` (one serve has no price for) or whose output is priced and that has no output
498
- * ceiling, each whose input cannot be bounded, and every request once what the run has spent is unknown: `spent` null
499
- * (spentFrom), or an answer since whose cost is unknown. A request's input is inputBound of its context, plus
500
- * `overhead(model, context)` (piOverhead), what its provider adds server-side; undefined is unmeasured, never 0. It is
501
- * priced by requestPrice under `mode`, after the previous request of its conversation (the context's last answer, read
502
- * by previousIn; its end as `now` read it when it settled here, else its own timestamp, which is when it began). Each
503
- * request sent carries what it is held at (HELD_USD) and its bound (BOUND_USD) to the marks below, and one stopped
504
- * before its end counts at most its hold.
505
- * `refused` (markRequests') writes the start mark of a refused model request before pi writes its error entry. On
506
- * another harness the run has no models of its own: every request goes through its session's proxy (port-models.ts). */
507
- export declare function capModels<M extends Models>(models: M, cap: number, spent: number | null, { unpriced, overhead, refused: markRefused, mode, now, wrapUp }?: {
508
- unpriced?: ReadonlySet<string>;
509
- overhead?: (model: Model<Api>, context: Context) => number | undefined;
510
- refused?: (figures?: RefusalFigures) => Promise<void>;
511
- mode?: CapMode;
512
- now?: () => number;
513
- wrapUp?: WrapUp;
514
- }): Promise<M>;