@parcha/agentrun-serve 0.1.0-beta.37 → 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 (399) hide show
  1. package/CHANGELOG.md +282 -0
  2. package/README.md +155 -92
  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/browser-cost.js +52 -93
  11. package/dist/cap.d.ts +0 -390
  12. package/dist/cap.js +4 -937
  13. package/dist/catalog.js +1 -1
  14. package/dist/composio-preset.d.ts +17 -0
  15. package/dist/composio-preset.js +43 -1
  16. package/dist/computer-calls.d.ts +36 -24
  17. package/dist/computer-calls.js +110 -27
  18. package/dist/computer-live.d.ts +5 -0
  19. package/dist/computer-live.js +12 -0
  20. package/dist/computer-setting.d.ts +15 -2
  21. package/dist/computer-setting.js +20 -4
  22. package/dist/computer-view.d.ts +3 -2
  23. package/dist/computer-view.js +5 -4
  24. package/dist/computer-viewer.js +26 -12
  25. package/dist/computers.d.ts +4 -1
  26. package/dist/computers.js +12 -6
  27. package/dist/console/assets/index-CjqQirbo.css +1 -0
  28. package/dist/console/assets/index-b6-XY5A9.js +576 -0
  29. package/dist/console/index.html +2 -2
  30. package/dist/console-links.d.ts +2 -0
  31. package/dist/console-links.js +3 -0
  32. package/dist/decisions.js +4 -0
  33. package/dist/faux-computers.js +4 -2
  34. package/dist/harness-opencode/adapter.js +7 -3
  35. package/dist/harness-opencode/facts.js +0 -2
  36. package/dist/harness-opencode/host/policy.d.ts +2 -5
  37. package/dist/harness-opencode/host/policy.js +8 -32
  38. package/dist/harness-table.d.ts +0 -2
  39. package/dist/harness-table.js +0 -2
  40. package/dist/host-tools.d.ts +1 -5
  41. package/dist/host-tools.js +7 -10
  42. package/dist/hosted-search.d.ts +0 -2
  43. package/dist/hosted-search.js +0 -21
  44. package/dist/key-words.d.ts +3 -2
  45. package/dist/key-words.js +4 -2
  46. package/dist/learn/check.d.ts +6 -1
  47. package/dist/learn/check.js +12 -4
  48. package/dist/learn/commit.d.ts +10 -0
  49. package/dist/learn/commit.js +18 -4
  50. package/dist/learn/compile.d.ts +243 -0
  51. package/dist/learn/compile.js +471 -0
  52. package/dist/learn/general.d.ts +3 -0
  53. package/dist/learn/general.js +4 -2
  54. package/dist/learn/grade.d.ts +1 -1
  55. package/dist/learn/grade.js +7 -6
  56. package/dist/learn/notes.d.ts +8 -0
  57. package/dist/learn/notes.js +18 -0
  58. package/dist/learn/promote.d.ts +253 -0
  59. package/dist/learn/promote.js +428 -0
  60. package/dist/learn/refit.d.ts +39 -0
  61. package/dist/learn/refit.js +236 -0
  62. package/dist/learn/reflect.d.ts +5 -25
  63. package/dist/learn/reflect.js +14 -131
  64. package/dist/learn/replay-calls.d.ts +63 -0
  65. package/dist/learn/replay-calls.js +158 -0
  66. package/dist/learn/skills.d.ts +17 -9
  67. package/dist/learn/skills.js +132 -42
  68. package/dist/learn/workflow-nodes.d.ts +15 -0
  69. package/dist/learn/workflow-nodes.js +44 -0
  70. package/dist/learned-nodes.d.ts +50 -2
  71. package/dist/learned-nodes.js +41 -2
  72. package/dist/learned-workflow.d.ts +19 -3
  73. package/dist/learned-workflow.js +105 -26
  74. package/dist/learning-batch.d.ts +2 -2
  75. package/dist/learning-batch.js +1 -1
  76. package/dist/learning-cost.d.ts +18 -6
  77. package/dist/learning-cost.js +15 -7
  78. package/dist/learning-routes.d.ts +14 -2
  79. package/dist/learning-routes.js +14 -3
  80. package/dist/learning-words.d.ts +7 -0
  81. package/dist/learning-words.js +7 -0
  82. package/dist/learning.d.ts +31 -6
  83. package/dist/learning.js +7 -4
  84. package/dist/llm.js +0 -3
  85. package/dist/mcp-gateway.d.ts +12 -20
  86. package/dist/mcp-gateway.js +16 -44
  87. package/dist/mcp-oauth.d.ts +5 -0
  88. package/dist/mcp-oauth.js +1 -1
  89. package/dist/mcp-pin-first.d.ts +37 -0
  90. package/dist/mcp-pin-first.js +107 -0
  91. package/dist/mcp-probe.d.ts +8 -9
  92. package/dist/mcp-probe.js +16 -33
  93. package/dist/mcp-servers-store.d.ts +89 -22
  94. package/dist/mcp-servers-store.js +131 -25
  95. package/dist/mcp-sources.d.ts +39 -0
  96. package/dist/mcp-sources.js +74 -0
  97. package/dist/mcp-store.d.ts +11 -0
  98. package/dist/mcp-store.js +16 -2
  99. package/dist/mcp-wire.d.ts +22 -0
  100. package/dist/mcp-wire.js +36 -0
  101. package/dist/mcp.js +3 -3
  102. package/dist/meta-tool-names.d.ts +1 -0
  103. package/dist/meta-tool-names.js +3 -0
  104. package/dist/model.d.ts +13 -0
  105. package/dist/model.js +46 -15
  106. package/dist/monid.d.ts +51 -25
  107. package/dist/monid.js +226 -140
  108. package/dist/openapi.js +336 -66
  109. package/dist/paid-calls.d.ts +26 -29
  110. package/dist/paid-calls.js +46 -102
  111. package/dist/propose.d.ts +7 -1
  112. package/dist/propose.js +18 -6
  113. package/dist/provider.js +9 -2
  114. package/dist/reflect-range.js +2 -1
  115. package/dist/rows.d.ts +5 -3
  116. package/dist/rows.js +15 -4
  117. package/dist/run-launch.d.ts +13 -0
  118. package/dist/run-launch.js +6 -0
  119. package/dist/run-learning-served.d.ts +13 -2
  120. package/dist/run-manifest.d.ts +5 -0
  121. package/dist/run-manifest.js +20 -0
  122. package/dist/run-secrets.js +2 -3
  123. package/dist/run-timeline-served.js +5 -2
  124. package/dist/run-view.d.ts +17 -6
  125. package/dist/run-view.js +51 -22
  126. package/dist/runnable.d.ts +0 -3
  127. package/dist/runnable.js +37 -29
  128. package/dist/runner/adapter-loop.d.ts +24 -10
  129. package/dist/runner/adapter-loop.js +852 -314
  130. package/dist/runner/adapter-run-spec.d.ts +12 -6
  131. package/dist/runner/adapter-run-spec.js +97 -46
  132. package/dist/runner/adapters/pi-computer.d.ts +3 -1
  133. package/dist/runner/adapters/pi-computer.js +13 -5
  134. package/dist/runner/adapters/pi.d.ts +16 -7
  135. package/dist/runner/adapters/pi.js +94 -33
  136. package/dist/runner/cli-run-spec.js +67 -27
  137. package/dist/runner/computer-channel.js +2 -1
  138. package/dist/runner/conformance/harness.d.ts +3 -0
  139. package/dist/runner/conformance/harness.js +145 -4
  140. package/dist/runner/conformance/subject.d.ts +11 -4
  141. package/dist/runner/end-of-run.d.ts +6 -5
  142. package/dist/runner/end-of-run.js +9 -6
  143. package/dist/runner/feedback-round.d.ts +52 -0
  144. package/dist/runner/feedback-round.js +79 -0
  145. package/dist/runner/journal-kinds.d.ts +24 -6
  146. package/dist/runner/journal-kinds.js +15 -0
  147. package/dist/runner/learning-end.d.ts +54 -19
  148. package/dist/runner/learning-end.js +272 -99
  149. package/dist/runner/learning-loop.d.ts +19 -1
  150. package/dist/runner/learning-loop.js +5 -2
  151. package/dist/runner/learning-seed.d.ts +4 -0
  152. package/dist/runner/learning-seed.js +14 -0
  153. package/dist/runner/loop-contract.d.ts +19 -3
  154. package/dist/runner/loop.d.ts +16 -1
  155. package/dist/runner/loop.js +21 -1
  156. package/dist/runner/mcp-claim.d.ts +5 -1
  157. package/dist/runner/mcp-claim.js +66 -50
  158. package/dist/runner/mcp-run.d.ts +16 -52
  159. package/dist/runner/mcp-run.js +12 -84
  160. package/dist/runner/meta-tools.d.ts +37 -0
  161. package/dist/runner/meta-tools.js +268 -0
  162. package/dist/runner/metrics.js +14 -3
  163. package/dist/runner/model-route.js +12 -3
  164. package/dist/runner/monid-run.d.ts +16 -0
  165. package/dist/runner/monid-run.js +96 -0
  166. package/dist/runner/promotion.d.ts +80 -0
  167. package/dist/runner/promotion.js +562 -0
  168. package/dist/runner/reflect-hook.d.ts +36 -21
  169. package/dist/runner/reflect-hook.js +138 -49
  170. package/dist/runner/runner.js +26 -4
  171. package/dist/runner/sessions.d.ts +8 -3
  172. package/dist/runner/sessions.js +5 -1
  173. package/dist/runner/step-guard.d.ts +62 -0
  174. package/dist/runner/step-guard.js +93 -0
  175. package/dist/runner/subagent.d.ts +0 -3
  176. package/dist/runner/subagent.js +7 -12
  177. package/dist/runner/workflow-first.d.ts +216 -0
  178. package/dist/runner/workflow-first.js +303 -0
  179. package/dist/runner/workflow-loop.js +17 -10
  180. package/dist/runner/workflow-spec.d.ts +1 -0
  181. package/dist/runner/workflow-spec.js +7 -3
  182. package/dist/runs-over-store.d.ts +11 -2
  183. package/dist/runs-over-store.js +21 -11
  184. package/dist/server.d.ts +88 -16
  185. package/dist/server.js +380 -87
  186. package/dist/settings-wake.d.ts +8 -6
  187. package/dist/settings-wake.js +13 -7
  188. package/dist/store/agent-body.d.ts +14 -3
  189. package/dist/store/agent-body.js +14 -10
  190. package/dist/store/command-wake.d.ts +3 -2
  191. package/dist/store/command-wake.js +4 -4
  192. package/dist/store/postgres/connection.js +3 -1
  193. package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
  194. package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
  195. package/dist/store/schema.d.ts +9 -0
  196. package/dist/store/schema.js +28 -8
  197. package/dist/store/sqlite/connection.d.ts +2 -2
  198. package/dist/store/sqlite/connection.js +2 -2
  199. package/dist/store/sqlite/run-patch.js +19 -7
  200. package/dist/store/sqlite/store.js +59 -18
  201. package/dist/store/store.d.ts +46 -14
  202. package/dist/store-reads/journal.d.ts +25 -1
  203. package/dist/store-reads/journal.js +63 -49
  204. package/dist/store-reads/learning.d.ts +101 -15
  205. package/dist/store-reads/learning.js +195 -61
  206. package/dist/store-reads/loop.d.ts +61 -0
  207. package/dist/store-reads/loop.js +111 -0
  208. package/dist/store-view.d.ts +3 -2
  209. package/dist/store-view.js +35 -17
  210. package/dist/template-eval.d.ts +18 -9
  211. package/dist/template-eval.js +91 -66
  212. package/dist/template-github-permissions.d.ts +2 -2
  213. package/dist/template-github-permissions.js +2 -1
  214. package/dist/template-import.d.ts +31 -0
  215. package/dist/template-import.js +121 -0
  216. package/dist/template-source.d.ts +51 -0
  217. package/dist/template-source.js +371 -0
  218. package/dist/templates.d.ts +218 -46
  219. package/dist/templates.js +493 -181
  220. package/dist/timeline/computer.d.ts +48 -0
  221. package/dist/timeline/computer.js +169 -0
  222. package/dist/timeline/index.d.ts +4 -3
  223. package/dist/timeline/index.js +4 -3
  224. package/dist/timeline/labels.d.ts +6 -2
  225. package/dist/timeline/labels.js +93 -2
  226. package/dist/timeline/origin.d.ts +19 -5
  227. package/dist/timeline/origin.js +11 -4
  228. package/dist/timeline/timeline.d.ts +11 -17
  229. package/dist/timeline/timeline.js +24 -9
  230. package/dist/tool-gate.d.ts +73 -46
  231. package/dist/tool-gate.js +133 -66
  232. package/dist/tool-keys.d.ts +4 -1
  233. package/dist/tool-keys.js +8 -3
  234. package/dist/tool-list.d.ts +26 -0
  235. package/dist/tool-list.js +43 -0
  236. package/dist/tool-names.d.ts +71 -0
  237. package/dist/tool-names.js +99 -0
  238. package/dist/tool-plane.d.ts +29 -27
  239. package/dist/tool-plane.js +65 -37
  240. package/dist/tools.d.ts +22 -6
  241. package/dist/tools.js +24 -20
  242. package/dist/validate.d.ts +15 -7
  243. package/dist/validate.js +91 -44
  244. package/dist/web-fetch.d.ts +1 -7
  245. package/dist/web-fetch.js +2 -22
  246. package/dist/workspace/computer-deps.d.ts +3 -0
  247. package/dist/workspace/computer-deps.js +5 -2
  248. package/dist/workspace/computer-for-claim.d.ts +6 -0
  249. package/dist/workspace/computer-for-claim.js +32 -14
  250. package/dist/workspace/computer-hold.js +7 -1
  251. package/dist/workspace/computer-script.d.ts +23 -7
  252. package/dist/workspace/computer-script.js +48 -14
  253. package/dist/workspace/index.d.ts +2 -2
  254. package/dist/workspace/index.js +1 -1
  255. package/dist/workspace/kind-skills/desktop/SKILL.md +13 -0
  256. package/dist/workspace/kind-skills/phone/SKILL.md +4 -0
  257. package/dist/workspace/local.js +2 -2
  258. package/dist/workspace/resolve-computer.d.ts +21 -1
  259. package/dist/workspace/resolve-computer.js +32 -14
  260. package/dist/workspace/run-tools.d.ts +28 -10
  261. package/dist/workspace/run-tools.js +39 -11
  262. package/dist/{tool-budget.d.ts → wrap-up.d.ts} +1 -18
  263. package/dist/wrap-up.js +21 -0
  264. package/launcher/agentrun-serve +4 -2
  265. package/package.json +9 -9
  266. package/templates/README.md +111 -45
  267. package/templates/code-review/agent.md +30 -14
  268. package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
  269. package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
  270. package/templates/code-review/evals/injection/case.yaml +2 -1
  271. package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
  272. package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
  273. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
  274. package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
  275. package/templates/code-review/evals/never-flag/case.yaml +2 -1
  276. package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
  277. package/templates/code-review/evals/null-name/case.yaml +2 -1
  278. package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
  279. package/templates/code-review/evals/off-by-one/case.yaml +2 -1
  280. package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
  281. package/templates/code-review/evals/other-repo/case.yaml +16 -0
  282. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
  283. package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
  284. package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
  285. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
  286. package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
  287. package/templates/code-review/evals/other-repo/prompt.md +10 -0
  288. package/templates/code-review/evals/re-review/case.yaml +2 -1
  289. package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
  290. package/templates/code-review/evals/re-review-open/case.yaml +2 -1
  291. package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
  292. package/templates/code-review/evals/repo-rule/case.yaml +2 -1
  293. package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
  294. package/templates/code-review/evals/two-defects/case.yaml +2 -1
  295. package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
  296. package/templates/code-review/rules/CODEREVIEW.md +1 -1
  297. package/templates/code-review/skills/review/DEEP.md +3 -2
  298. package/templates/code-review/skills/review/REVIEWER.md +3 -2
  299. package/templates/code-review/skills/review/SKILL.md +4 -3
  300. package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
  301. package/templates/inbound-lead/agent.md +26 -16
  302. package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
  303. package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
  304. package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
  305. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
  306. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
  307. package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
  308. package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
  309. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
  310. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
  311. package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
  312. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
  313. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
  314. package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
  315. package/templates/kyb/agent.md +15 -5
  316. package/templates/kyb/evals/adverse-media/prompt.md +2 -7
  317. package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
  318. package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
  319. package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
  320. package/templates/kyb/evals/name-collision/prompt.md +2 -6
  321. package/templates/kyb/evals/no-invention/prompt.md +2 -6
  322. package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
  323. package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
  324. package/templates/kyb/kyb.schema.json +8 -7
  325. package/templates/kyb/skills/kyb/SKILL.md +9 -6
  326. package/templates/market-monitor/agent.md +19 -12
  327. package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
  328. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
  329. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
  330. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
  331. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  332. package/templates/release-notes/agent.md +32 -10
  333. package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
  334. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
  335. package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
  336. package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
  337. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
  338. package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
  339. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
  340. package/templates/release-notes/evals/learned-style/case.yaml +2 -1
  341. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
  342. package/templates/release-notes/evals/other-repo/case.yaml +24 -0
  343. package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
  344. package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
  345. package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
  346. package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
  347. package/templates/release-notes/evals/other-repo/prompt.md +32 -0
  348. package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
  349. package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
  350. package/templates/release-notes/notes.schema.json +1 -1
  351. package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
  352. package/dist/console/assets/index-Cn6JX1uH.js +0 -563
  353. package/dist/console/assets/index-DRN62V5v.css +0 -1
  354. package/dist/tool-blurbs.d.ts +0 -4
  355. package/dist/tool-blurbs.js +0 -28
  356. package/dist/tool-budget.js +0 -62
  357. package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
  358. package/templates/code-review/evals/injection/graders/schema.md +0 -5
  359. package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
  360. package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
  361. package/templates/code-review/evals/null-name/graders/schema.md +0 -5
  362. package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
  363. package/templates/code-review/evals/re-review/graders/schema.md +0 -5
  364. package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
  365. package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
  366. package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
  367. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
  368. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
  369. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
  370. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
  371. package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
  372. package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
  373. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
  374. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
  375. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
  376. package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
  377. package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
  378. package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
  379. package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
  380. package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
  381. package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
  382. package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
  383. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
  384. package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
  385. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
  386. package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
  387. package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
  388. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
  389. package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
  390. package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
  391. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
  392. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
  393. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
  394. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
  395. package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
  396. package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
  397. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
  398. package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
  399. package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
@@ -1,6 +1,5 @@
1
- import type { Context } from "@earendil-works/chord/context";
2
1
  import type { Refusal } from "@parcha/agentrun-kernel";
3
- import { type ToolExecutionApi, type ToolRegistration } from "@earendil-works/pi-durable";
2
+ import type { ToolRegistration } from "@earendil-works/pi-durable";
4
3
  /** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
5
4
  * $1 per 1,000 requests for up to 10 results, each further result $1 per 1,000; an extract $1 per 1,000 URLs. */
6
5
  export declare const PARALLEL_SEARCH_USD = 0.001;
@@ -10,7 +9,6 @@ export declare const PARALLEL_EXTRACT_USD = 0.001;
10
9
  /** One paid request: `name` in the cap's refusal, `tool` and `by` on its records, `usd` its price, `basis` why. */
11
10
  export type Fee = {
12
11
  name: string;
13
- tool: string;
14
12
  by: string;
15
13
  usd: number;
16
14
  basis: string;
@@ -22,23 +20,21 @@ export declare const parallelExtractFee: (urls?: number) => Fee;
22
20
  /** The fee of a request to Parallel's `url` with `body`: its search's, by the results it asks for (10 by default), or its
23
21
  * extract's, by the URLs; undefined for an endpoint the web tools do not ask. */
24
22
  export declare function parallelFeeOf(url: string, body: unknown): Fee | undefined;
25
- /** A paid request the run's cap refused, or whose mark could not be written: nothing was sent. Its message is the
26
- * refusal, in the cap's words. */
23
+ /** A paid request the run's cap refused, whose hold could not be kept, or that has no run's ledger to book it on:
24
+ * nothing was sent. Its message is the refusal, in the cap's words. */
27
25
  export declare class PaidRefused extends Error {
28
26
  readonly name = "PaidRefused";
29
27
  }
30
- /** Where a paid request is booked: the call it is booked under, and one record written to the run's root, where its
31
- * spend is read on every harness (cap.ts, harness-app.ts). */
28
+ /** Where a paid request is booked: the call it is booked under, and the run's one ledger. */
32
29
  export type Ledger = {
33
30
  call: string;
34
- record(kind: string, data: Record<string, string | number | null>): Promise<void>;
35
- /** The run's one ledger on the runner (the kernel cap's paidCalls, the adapter loop's): a paid request is admitted and
36
- * settled there, in the run's runner records, in place of this process's run spend (cap.ts paidCall) and the root's
37
- * TOOL_STARTED/TOOL_COST marks. */
31
+ /** The run's one ledger (the kernel cap's paid tool calls, the adapter loop's): a paid request is admitted and settled
32
+ * there, in the run's runner records. With none, a paid request is refused unsent. */
38
33
  paid?: PaidBooking;
39
34
  /** The run's pause on the runner (the adapter loop's RunLedger.pause): a paid step of the agent's own that `paid`
40
35
  * refused for room is handed to it, so the run pauses at its next request in the cap's words, as main's paidCall
41
- * pauses by default. A person's take-over books through no paid step (browser-cost.ts personTime) and never pauses. */
36
+ * pauses by default. A person's take-over books through no paid step (browser-cost.ts personTime) and never pauses.
37
+ * A refusal for good (stopRun) ends the run there instead. */
42
38
  pause?: (refusal: LedgerRefusal) => Promise<void>;
43
39
  };
44
40
  /** A cap refusal as the run's pause reads it: its words, and for room its figures. */
@@ -65,29 +61,30 @@ export type PaidBooking = {
65
61
  readonly givenBack?: true;
66
62
  }): Promise<unknown>;
67
63
  };
68
- /** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit) before the
69
- * call is sent. Every paid call off the run's one ledger writes its hold here: a paid request (paidRequest) and
70
- * monid.run (monid.ts). A write that fails throws its own error, and the caller sends nothing (holdRefusal says why). */
71
- export declare function writeHold(write: (kind: string, data: Record<string, string | number | null>) => Promise<void>, data: Record<string, string | number | null>): Promise<void>;
72
- /** What a paid call whose hold writeHold could not write tells the model: `name` was not sent, and why. */
73
- export declare const holdRefusal: (name: string, error: unknown) => string;
74
- /** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) and its settle are the
75
- * call's own commits, so a stopped turn sends nothing new. On the
76
- * runner the call runs inside the run's one ledger (the adapter loop's bookedIn, which carries the run's paid tool calls
77
- * and its pause): its `paid` and `pause` are kept, so a paid request is admitted on the run's cap before it is sent and
78
- * settled there, never booked beside it where the cap does not judge it. */
79
- export declare const ledgerOf: (api: ToolExecutionApi, context: Context) => Ledger;
64
+ /** What a paid call with no run's ledger to book it on tells the model: `name` was not sent (as mcp-gateway.ts says it). */
65
+ export declare const unbookedRefusal: (name: string) => string;
66
+ /** The ledger of tool call `call`: the run's one ledger it runs in (the adapter loop's bookedIn, which carries the run's
67
+ * paid tool calls and its pause), under the call's own id, so a paid request is admitted on the run's cap before it is
68
+ * sent and settled there; none outside one. */
69
+ export declare const ledgerOf: (call: string) => Ledger;
80
70
  /** `tool` with each call's paid requests booked under it: its execute runs with the call's ledger set. */
81
71
  export declare function booking<T extends ToolRegistration>(tool: T): T;
82
- /** `work` with its paid requests booked in `ledger` (a workflow call node's); with none, booked nowhere. */
72
+ /** `work` with its paid requests booked in `ledger` (a host tool call's, a workflow call node's); with none, outside any
73
+ * call's ledger, where a paid request is refused. */
83
74
  export declare const bookedIn: <T>(ledger: Ledger | undefined, work: () => Promise<T>) => Promise<T>;
84
- /** `send`, one request to a paid provider at `fee`, under the run's cap and booked under the call it runs in: its
85
- * response; it throws PaidRefused, in the cap's words, when the cap does not hold its price (or the run's spend is
86
- * unknown), when no call is set to book it under, or when its mark could not be written, and then nothing is sent. A request that throws throws, settled at its
87
- * price. */
75
+ /** `send`, one request to a paid provider at `fee`, on the run's one ledger under the call it runs in (Ledger.paid):
76
+ * admitted at the fee's price, then sent, then settled at what it may have charged (its price on a 2xx, a 408 or a 5xx
77
+ * or when it threw after it was sent; $0 on another 4xx); a settle that cannot be written leaves it at its hold, never
78
+ * less. It throws PaidRefused, in the cap's words, when the cap does not hold its price, when its hold could not be kept,
79
+ * or when the call has no run's ledger, and then nothing is sent. A request that throws throws, settled at its price. */
88
80
  export declare function paidRequest(fee: Fee, send: () => Promise<Response>): Promise<Response>;
89
81
  /** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
90
82
  export declare const paidLedger: () => PaidBooking | undefined;
83
+ /** Stops the run the current call books in, in `words`: handed to its pause (Ledger.pause) as a cap refusal no raise
84
+ * could fix, so the run's next request and every tool call after this one (a script's too) are refused in them, and the
85
+ * run ends failed in them, past its cap too, as a cap refusal for good ends it. Its code is the cap's, so the refused
86
+ * request reads as the cap's refusal (no model error row of its own). */
87
+ export declare const stopRun: (words: string) => Promise<void>;
91
88
  /** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
92
89
  * or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold). One refused
93
90
  * for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
@@ -1,22 +1,20 @@
1
- // A web tool's request to Parallel (its search, web-search.ts; its extract, web-fetch.ts), booked as monid.run's call
2
- // is (monid.ts): under the run's cap by cap.ts' rule for a paid call (what the run has spent and holds, plus the
3
- // request's price, within the cap; never on an unknown spend), else refused unsent in the cap's words; marked in the
4
- // run's store before it is sent (TOOL_STARTED, held at its price) and settled after (TOOL_COST, what it charged). A
5
- // charge is the run's cost, a line of its own on its timeline and /usage's `tools` meter. Every request goes through
6
- // the run's one Parallel client's `post` (web-fetch.ts), which books it here by the endpoint it asks.
1
+ // A web tool's request to Parallel (its search, web-search.ts; its extract, web-fetch.ts), booked as a monid endpoint's
2
+ // call is (monid.ts): on the run's one ledger (the kernel cap's paid tool calls, RunTools), admitted at the request's price
3
+ // before it is sent (refused unsent in the cap's words when the cap does not hold it) and settled after at what it
4
+ // charged. A charge is the run's cost, a line of its own on its timeline and /usage's `tools` meter. Every request goes
5
+ // through the run's one Parallel client's `post` (web-fetch.ts), which books it here by the endpoint it asks.
7
6
  // Parallel's answers report what they used as SKU counts, never an amount, so each request is booked at Parallel's
8
7
  // published price, an estimate: its price on a 2xx; nothing on a 4xx other than a 408 (Parallel refused it before any
9
8
  // work); and its price on a 408, a 5xx or a request that failed or was stopped after it was sent, which Parallel may
10
9
  // have billed, as the decision provider books Parallel's (@parcha/agentrun-decisions).
11
- // A request with no call to book it under, or to an endpoint with no price here, is never sent: it fails closed.
12
- // The call a request is booked under (its id, and how a record is written to the run's store) is set around the call:
13
- // around a tool's execute by `booking`, where the web tools are bound (tools.ts, host-tools.ts), and around a workflow
14
- // call node's effect by `bookedIn`, with the ledger the workflow's runner gives it (app.ts). The client deep inside a
15
- // tool books without the call passed down to it.
10
+ // A request with no run's ledger to book it on, or to an endpoint with no price here, is never sent: it fails closed,
11
+ // as a priced MCP call does (mcp-gateway.ts).
12
+ // The ledger a request is booked on (the run's RunTools, its pause, the call it runs under) is set around the call: around
13
+ // each host tool call by the adapter loop's `bookedIn`, around a workflow call node's tool by its own (workflow-spec.ts),
14
+ // and narrowed to the tool's own call by `booking`, where the web tools are bound (tools.ts). The client deep inside a
15
+ // tool books without the ledger passed down to it.
16
16
  import { AsyncLocalStorage } from "node:async_hooks";
17
- import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
18
- import { TOOL_COST, TOOL_STARTED } from "./timeline/index.js";
19
- import { paidCall, SPEND_CAP_REACHED } from "./cap.js";
17
+ import { SPEND_CAP_REACHED } from "./cap.js";
20
18
  /** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
21
19
  * $1 per 1,000 requests for up to 10 results, each further result $1 per 1,000; an extract $1 per 1,000 URLs. */
22
20
  export const PARALLEL_SEARCH_USD = 0.001;
@@ -28,10 +26,10 @@ const usd = (dollars) => Math.round(dollars * 1e6) / 1e6;
28
26
  /** A fast search for `n` results: $0.001, and $0.001 for each past the 10 it includes. */
29
27
  export const parallelSearchFee = (n) => {
30
28
  const more = Math.max(0, n - PARALLEL_SEARCH_INCLUDED);
31
- return { name: "Parallel's search", tool: "web_search", by: "parallel", usd: usd(PARALLEL_SEARCH_USD + PARALLEL_SEARCH_RESULT_USD * more), basis: more ? `Parallel's list price for a fast search of ${n} results` : "Parallel's list price for a fast search" };
29
+ return { name: "Parallel's search", by: "parallel", usd: usd(PARALLEL_SEARCH_USD + PARALLEL_SEARCH_RESULT_USD * more), basis: more ? `Parallel's list price for a fast search of ${n} results` : "Parallel's list price for a fast search" };
32
30
  };
33
31
  /** An extract of `urls` URLs (the web tools ask one at a time). */
34
- export const parallelExtractFee = (urls = 1) => ({ name: "Parallel's extract", tool: "web_fetch", by: "parallel", usd: usd(PARALLEL_EXTRACT_USD * urls), basis: urls === 1 ? "Parallel's list price for one URL" : `Parallel's list price for ${urls} URLs` });
32
+ export const parallelExtractFee = (urls = 1) => ({ name: "Parallel's extract", by: "parallel", usd: usd(PARALLEL_EXTRACT_USD * urls), basis: urls === 1 ? "Parallel's list price for one URL" : `Parallel's list price for ${urls} URLs` });
35
33
  /** The fee of a request to Parallel's `url` with `body`: its search's, by the results it asks for (10 by default), or its
36
34
  * extract's, by the URLs; undefined for an endpoint the web tools do not ask. */
37
35
  export function parallelFeeOf(url, body) {
@@ -43,8 +41,8 @@ export function parallelFeeOf(url, body) {
43
41
  return parallelExtractFee(Array.isArray(asked.urls) ? Math.max(1, asked.urls.length) : 1);
44
42
  return undefined;
45
43
  }
46
- /** A paid request the run's cap refused, or whose mark could not be written: nothing was sent. Its message is the
47
- * refusal, in the cap's words. */
44
+ /** A paid request the run's cap refused, whose hold could not be kept, or that has no run's ledger to book it on:
45
+ * nothing was sent. Its message is the refusal, in the cap's words. */
48
46
  export class PaidRefused extends Error {
49
47
  name = "PaidRefused";
50
48
  }
@@ -65,80 +63,51 @@ const pauseOn = async (error, pause = ledgers.getStore()?.pause) => {
65
63
  await pause(room);
66
64
  };
67
65
  const ledgers = new AsyncLocalStorage();
68
- /** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit) before the
69
- * call is sent. Every paid call off the run's one ledger writes its hold here: a paid request (paidRequest) and
70
- * monid.run (monid.ts). A write that fails throws its own error, and the caller sends nothing (holdRefusal says why). */
71
- export async function writeHold(write, data) {
72
- await write(TOOL_STARTED, data);
73
- }
74
- /** What a paid call whose hold writeHold could not write tells the model: `name` was not sent, and why. */
75
- export const holdRefusal = (name, error) => `${name} was not sent: its mark could not be written (${String(error?.message ?? error).slice(0, 200)})`;
76
- /** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) and its settle are the
77
- * call's own commits, so a stopped turn sends nothing new. On the
78
- * runner the call runs inside the run's one ledger (the adapter loop's bookedIn, which carries the run's paid tool calls
79
- * and its pause): its `paid` and `pause` are kept, so a paid request is admitted on the run's cap before it is sent and
80
- * settled there, never booked beside it where the cap does not judge it. */
81
- export const ledgerOf = (api, context) => {
66
+ /** What a paid call whose hold the run's ledger could not keep tells the model: `name` was not sent, and why. */
67
+ const holdRefusal = (name, error) => `${name} was not sent: its mark could not be written (${String(error?.message ?? error).slice(0, 200)})`;
68
+ /** What a paid call with no run's ledger to book it on tells the model: `name` was not sent (as mcp-gateway.ts says it). */
69
+ export const unbookedRefusal = (name) => `${name} was not sent: this call has no run to book its price under.`;
70
+ /** The ledger of tool call `call`: the run's one ledger it runs in (the adapter loop's bookedIn, which carries the run's
71
+ * paid tool calls and its pause), under the call's own id, so a paid request is admitted on the run's cap before it is
72
+ * sent and settled there; none outside one. */
73
+ export const ledgerOf = (call) => {
82
74
  const outer = ledgers.getStore();
83
- return {
84
- call: api.callId,
85
- record: (kind, data) => api.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind, data })), context),
86
- ...(outer?.paid ? { paid: outer.paid } : {}),
87
- ...(outer?.pause ? { pause: outer.pause } : {}),
88
- };
75
+ return { call, ...(outer?.paid ? { paid: outer.paid } : {}), ...(outer?.pause ? { pause: outer.pause } : {}) };
89
76
  };
90
77
  /** `tool` with each call's paid requests booked under it: its execute runs with the call's ledger set. */
91
78
  export function booking(tool) {
92
- return { ...tool, execute: (args, api, context) => ledgers.run(ledgerOf(api, context), () => tool.execute(args, api, context)) };
79
+ return { ...tool, execute: (args, api, context) => ledgers.run(ledgerOf(api.callId), () => tool.execute(args, api, context)) };
93
80
  }
94
- /** `work` with its paid requests booked in `ledger` (a workflow call node's); with none, booked nowhere. */
81
+ /** `work` with its paid requests booked in `ledger` (a host tool call's, a workflow call node's); with none, outside any
82
+ * call's ledger, where a paid request is refused. */
95
83
  export const bookedIn = (ledger, work) => (ledger ? ledgers.run(ledger, work) : work());
96
84
  /** Whether Parallel may have billed a request it answered `status`: a 2xx, a 408 or a 5xx; never another 4xx. */
97
85
  const billed = (status) => (status >= 200 && status < 300) || status === 408 || status >= 500;
98
- /** `send`, one request to a paid provider at `fee`, under the run's cap and booked under the call it runs in: its
99
- * response; it throws PaidRefused, in the cap's words, when the cap does not hold its price (or the run's spend is
100
- * unknown), when no call is set to book it under, or when its mark could not be written, and then nothing is sent. A request that throws throws, settled at its
101
- * price. */
86
+ /** `send`, one request to a paid provider at `fee`, on the run's one ledger under the call it runs in (Ledger.paid):
87
+ * admitted at the fee's price, then sent, then settled at what it may have charged (its price on a 2xx, a 408 or a 5xx
88
+ * or when it threw after it was sent; $0 on another 4xx); a settle that cannot be written leaves it at its hold, never
89
+ * less. It throws PaidRefused, in the cap's words, when the cap does not hold its price, when its hold could not be kept,
90
+ * or when the call has no run's ledger, and then nothing is sent. A request that throws throws, settled at its price. */
102
91
  export async function paidRequest(fee, send) {
103
92
  const ledger = ledgers.getStore();
104
- if (!ledger)
105
- throw new PaidRefused(`${fee.name} was not sent: this request has no call to book it under`);
106
- const label = { tool: fee.tool, charged_by: fee.by, call: ledger.call };
107
- const chargeOf = (sent) => ("unmarked" in sent ? undefined : "thrown" in sent || billed(sent.response.status) ? fee.usd : 0);
108
- if (ledger.paid)
109
- return paidOn(ledger.paid, ledger.call, fee, send, chargeOf);
110
- const sent = async () => {
111
- try {
112
- await writeHold(ledger.record, { ...label, heldUsd: fee.usd });
113
- }
114
- catch (error) {
115
- return { unmarked: holdRefusal(fee.name, error) };
116
- }
117
- let outcome;
118
- try {
119
- outcome = { response: await send() };
120
- }
121
- catch (thrown) {
122
- outcome = { thrown };
123
- }
124
- // Settled at what it may have charged, even when this cannot be written: the request was sent.
125
- await ledger.record(TOOL_COST, { ...label, usd: chargeOf(outcome) ?? null }).catch(() => undefined);
126
- return outcome;
127
- };
128
- const paid = await paidCall(fee.name, sent, chargeOf, { usd: fee.usd, basis: fee.basis });
129
- if ("refused" in paid)
130
- throw new PaidRefused(paid.refused);
131
- const outcome = paid.result;
132
- if ("unmarked" in outcome)
133
- throw new PaidRefused(outcome.unmarked);
134
- if ("thrown" in outcome)
135
- throw outcome.thrown;
136
- return outcome.response;
93
+ if (!ledger?.paid)
94
+ throw new PaidRefused(unbookedRefusal(fee.name));
95
+ const stepped = await paidStep(ledger.paid, ledger.call, { name: fee.name, holdUsd: fee.usd, basis: fee.basis, by: fee.by }, send, (outcome) => ("thrown" in outcome || billed(outcome.result.status) ? fee.usd : 0));
96
+ if ("refused" in stepped)
97
+ throw new PaidRefused(stepped.refused);
98
+ return stepped.result;
137
99
  }
138
100
  /** Each paid request of this process on the run's one ledger, numbered within its call (one call may make several). */
139
101
  let paidSeq = 0;
140
102
  /** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
141
103
  export const paidLedger = () => ledgers.getStore()?.paid;
104
+ /** Stops the run the current call books in, in `words`: handed to its pause (Ledger.pause) as a cap refusal no raise
105
+ * could fix, so the run's next request and every tool call after this one (a script's too) are refused in them, and the
106
+ * run ends failed in them, past its cap too, as a cap refusal for good ends it. Its code is the cap's, so the refused
107
+ * request reads as the cap's refusal (no model error row of its own). */
108
+ export const stopRun = async (words) => {
109
+ await ledgers.getStore()?.pause?.({ refuse: words, code: SPEND_CAP_REACHED, forGood: true });
110
+ };
142
111
  /** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
143
112
  * or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold). One refused
144
113
  * for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
@@ -169,28 +138,3 @@ export async function paidStep(paid, call, fee, run, chargeOf, pause) {
169
138
  throw outcome.thrown;
170
139
  return outcome;
171
140
  }
172
- /** `send` on the run's one ledger (Ledger.paid): admitted at the fee's price (refused unsent in the cap's words), then
173
- * sent, then settled at what it may have charged (chargeOf: its price on a 2xx, a 408 or a 5xx or when it threw after
174
- * it was sent; $0 on another 4xx). A settle that cannot be written leaves the request at its hold, never less. */
175
- async function paidOn(paid, call, fee, send, chargeOf) {
176
- const id = `${call}#${(paidSeq += 1)}`;
177
- try {
178
- await paid.admit({ id, name: fee.name, holdUsd: fee.usd, basis: fee.basis, call, chargedBy: fee.by });
179
- }
180
- catch (error) {
181
- await pauseOn(error);
182
- const said = String(error?.message ?? error);
183
- throw new PaidRefused(error?.code === "spend_cap_reached" ? said : holdRefusal(fee.name, error));
184
- }
185
- let outcome;
186
- try {
187
- outcome = { response: await send() };
188
- }
189
- catch (thrown) {
190
- outcome = { thrown };
191
- }
192
- await paid.settle(id, chargeOf(outcome) ?? null).catch(() => undefined);
193
- if ("thrown" in outcome)
194
- throw outcome.thrown;
195
- return outcome.response;
196
- }
package/dist/propose.d.ts CHANGED
@@ -29,12 +29,17 @@ export type Proposed = {
29
29
  * seed holds is no change, and `MEMORY.md` is the host's (the checker ignores it). A skill is laid at
30
30
  * `skills/<name>/SKILL.md`; a draft at `workflows/<name>/workflow.json`, with the README.md the host writes from the
31
31
  * description its block gives. `outcome`, how the run's job ended (only a completed run adds or changes a skill);
32
- * `tools`, those a draft may name (tools.ts learnedWorkflowTools); `refuse`: this host's secrets. */
32
+ * `tools`, those a draft may name (tools.ts learnedWorkflowTools); `refuse`: this host's secrets; `outputSchema`: the
33
+ * agent's, which a draft's dry run holds its answer to (learn/skills.ts draftDryRun). */
33
34
  export declare const proposeRun: (input: {
34
35
  folder: Workspace;
35
36
  runDir: string;
36
37
  seed: string;
37
38
  notesSeed?: string;
39
+ revised?: {
40
+ workflow: string;
41
+ base: string;
42
+ };
38
43
  turn: Turn;
39
44
  refuse: readonly string[];
40
45
  outcome?: string;
@@ -44,4 +49,5 @@ export declare const proposeRun: (input: {
44
49
  ask?: DraftAsk;
45
50
  decisions?: DraftDecisions;
46
51
  workflows?: false;
52
+ outputSchema?: unknown;
47
53
  }) => Promise<Proposed>;
package/dist/propose.js CHANGED
@@ -73,7 +73,8 @@ async function seedAt(lw, seed, wanted) {
73
73
  * seed holds is no change, and `MEMORY.md` is the host's (the checker ignores it). A skill is laid at
74
74
  * `skills/<name>/SKILL.md`; a draft at `workflows/<name>/workflow.json`, with the README.md the host writes from the
75
75
  * description its block gives. `outcome`, how the run's job ended (only a completed run adds or changes a skill);
76
- * `tools`, those a draft may name (tools.ts learnedWorkflowTools); `refuse`: this host's secrets. */
76
+ * `tools`, those a draft may name (tools.ts learnedWorkflowTools); `refuse`: this host's secrets; `outputSchema`: the
77
+ * agent's, which a draft's dry run holds its answer to (learn/skills.ts draftDryRun). */
77
78
  export const proposeRun = async (input) => {
78
79
  const parsed = parseReflection(input.turn.answer);
79
80
  // Each skill and draft as the folder would hold it, keyed by its block (kind and name) so the changes keep the
@@ -100,7 +101,17 @@ export const proposeRun = async (input) => {
100
101
  const { snapshot, texts } = await seedAt(input.folder, input.seed, (seedSnapshot) => (parsed.ok ? [...parsed.notes.map(({ file }) => file), ...given.flat().map(({ file }) => file), ...draftSkills, ...activeOf(seedSnapshot)] : []));
101
102
  if (!parsed.ok)
102
103
  return parsed.reason === "empty" ? { state: "dropped", reason: "empty" } : { state: "dropped", reason: "unparsed", detail: parsed.detail };
103
- const { base: seedBase, kept } = baseOf(snapshot);
104
+ const { base: seedBase, kept: seedKept } = baseOf(snapshot);
105
+ // A workflow the compile turn revised from main's text (`revised`) is checked against the commit it read that text at,
106
+ // not the seed: a change made to it on main before that read is what the revision was written over, and only one after
107
+ // it is a conflict (its files' `bases` in the proposal, which the merge checks main against). Every other item keeps
108
+ // the seed.
109
+ const revisedDir = input.revised && input.revised.base !== input.seed ? `${WORKFLOWS_DIR}/${input.revised.workflow}/` : undefined;
110
+ const isRevised = (path) => revisedDir !== undefined && path.startsWith(revisedDir);
111
+ const revisedAt = revisedDir ? await seedAt(input.folder, input.revised.base, () => given.flat().map(({ file }) => file).filter(isRevised)) : undefined;
112
+ const revisedBase = revisedAt ? baseOf(revisedAt.snapshot) : undefined;
113
+ const textAt = (file) => (revisedAt && isRevised(file) ? revisedAt.texts.get(file) : texts.get(file));
114
+ const kept = revisedBase ? [...seedKept.filter((file) => !isRevised(file)), ...revisedBase.kept.filter(isRevised)] : seedKept;
104
115
  // A later round's notes are checked against the main the earlier rounds merged into (`notesSeed`: a note round 1 added
105
116
  // is a supersedes target and a duplicate rule), while a skill's or a draft's files keep `seed` as their conflict base:
106
117
  // the run was laid from it, so a file changed on main since is a conflict, never written over.
@@ -113,9 +124,9 @@ export const proposeRun = async (input) => {
113
124
  }));
114
125
  const learnedPath = (path) => path.startsWith(`${SKILLS_DIR}/`) || path.startsWith(`${WORKFLOWS_DIR}/`);
115
126
  const notedBase = baseOf(noted.snapshot).base;
116
- const base = { files: [...[...notedBase.files].filter((path) => !learnedPath(path)), ...[...seedBase.files].filter(learnedPath)], active: notedBase.active, rules };
127
+ const base = { files: [...[...notedBase.files].filter((path) => !learnedPath(path)), ...[...seedBase.files].filter((path) => learnedPath(path) && !isRevised(path)), ...[...(revisedBase?.base.files ?? [])].filter(isRevised)], active: notedBase.active, rules };
117
128
  const held = new Set(base.files);
118
- const files = given.filter((group) => group.some(({ file, text }) => texts.get(file) !== text)).flat();
129
+ const files = given.filter((group) => group.some(({ file, text }) => textAt(file) !== text)).flat();
119
130
  const changeOf = ({ file, text }) => ({ path: file, status: held.has(file) ? "modified" : "added", mode: "100644", bytes: Buffer.from(text) });
120
131
  // Each changed item in the order the answer gave its block, whatever its kind: a count cap names the items past it in
121
132
  // that order (learn/check.ts), so a skill the answer led with is never the one past the changed-path cap.
@@ -151,7 +162,7 @@ export const proposeRun = async (input) => {
151
162
  if (!whole)
152
163
  for (const { file, text } of files)
153
164
  if (file.endsWith("/workflow.json") && !refused.has(itemOf(file)))
154
- dryRuns[file] = await draftDryRun(dsl, text, examples.get(file));
165
+ dryRuns[file] = await draftDryRun(dsl, text, examples.get(file), input.outputSchema);
155
166
  }
156
167
  // A verdict per item from the checks too: the items a problem names are left out (a draft's two files together),
157
168
  // and the rest is checked again, until it passes; a problem that names no item, or one that refuses the whole (WHOLE),
@@ -196,7 +207,8 @@ export const proposeRun = async (input) => {
196
207
  // reads it there): the format the draft's answer keeps (#2412). Cut of the host's secrets, as what was said is.
197
208
  const proposing = new Set(passing.map(({ file }) => file));
198
209
  const drafted = passing.filter(({ file }) => file.endsWith("/workflow.json")).map(({ file }) => skillOf(file)).filter((file) => !proposing.has(file) && texts.has(file)).map((file) => ({ file, text: redactSecrets(texts.get(file), input.refuse, Number.POSITIVE_INFINITY) }));
199
- const proposal = { seed: input.seed, notes: checked.notes.map(({ file, text }) => ({ file, text })), ...(passing.length ? { files: passing } : {}), ...(Object.keys(ran).length ? { dryRuns: ran } : {}), ...(drafted.length ? { drafted } : {}), asked, ...(triggered.length ? { triggered } : {}) };
210
+ const bases = Object.fromEntries(passing.filter(({ file }) => isRevised(file)).map(({ file }) => [file, input.revised.base]));
211
+ const proposal = { seed: input.seed, ...(Object.keys(bases).length ? { bases } : {}), notes: checked.notes.map(({ file, text }) => ({ file, text })), ...(passing.length ? { files: passing } : {}), ...(Object.keys(ran).length ? { dryRuns: ran } : {}), ...(drafted.length ? { drafted } : {}), asked, ...(triggered.length ? { triggered } : {}) };
200
212
  await writeDurable(join(input.runDir, PROPOSAL), `${JSON.stringify(proposal)}\n`);
201
213
  const count = (suffix) => passing.filter(({ file }) => file.endsWith(suffix)).length;
202
214
  return { state: "proposed", notes: proposal.notes.length, skills: count("/SKILL.md"), workflows: count("/workflow.json"), ...(left.length ? { left } : {}) };
package/dist/provider.js CHANGED
@@ -1,4 +1,4 @@
1
- import { chooseModel, FAUX_ENV, hostModel } from "./model.js";
1
+ import { chooseModel, FAUX_ENV, hostModel, MODEL_PROVIDER } from "./model.js";
2
2
  import { WIRES } from "./wires.js";
3
3
  import { modelFormWhy } from "./model-form.js";
4
4
  // Each wire's own settings live in a leaf module (wires.ts), which the harness table reads as it loads.
@@ -91,9 +91,16 @@ function openRouterKey(env, who, named) {
91
91
  throw new HarnessUnavailable(`${who} runs ${named} through OpenRouter, which needs OPENROUTER_API_KEY.`, undefined, ["OPENROUTER_API_KEY"]);
92
92
  return () => env.OPENROUTER_API_KEY ?? "";
93
93
  }
94
+ /** Serve's gateway (AGENT_MODEL_BASE_URL) on either wire: its base, its key (AGENT_MODEL_API_KEY, or none) as a bearer
95
+ * token, the model id as model.ts chose it, priced as runModels prices it. */
96
+ const gatewayProvider = (env, model) => ({ origin: gatewayBase("AGENT_MODEL_BASE_URL", env.AGENT_MODEL_BASE_URL), credential: () => env.AGENT_MODEL_API_KEY || "none", auth: "bearer", modelId: model.modelId, priceModel: model });
94
97
  export function providerFor(wire, env, model, who) {
95
98
  const named = `${model.provider}/${model.modelId}`;
96
99
  if (wire === "anthropic-messages") {
100
+ // A model of serve's gateway that the gateway takes on Messages (a Claude model, model.ts gatewayWire): the gateway's
101
+ // own route, as on Responses. No harness of this wire chooses one (claude-agent's model is never the gateway's).
102
+ if (model.provider === MODEL_PROVIDER && env.AGENT_MODEL_BASE_URL)
103
+ return gatewayProvider(env, model);
97
104
  if (model.provider === "openrouter" && model.modelId.startsWith("anthropic/")) {
98
105
  const own = anthropicModelId({ provider: "anthropic", modelId: model.modelId.slice("anthropic/".length) });
99
106
  return { origin: OPENROUTER_BASE, credential: openRouterKey(env, who, named), auth: "bearer", modelId: own, priceModel: { provider: "openrouter", modelId: `anthropic/${openRouterName(own)}` } };
@@ -111,7 +118,7 @@ export function providerFor(wire, env, model, who) {
111
118
  return { origin, credential: () => env.ANTHROPIC_API_KEY ?? "", auth: "x-api-key", modelId: own, priceModel: { provider: "anthropic", modelId: own } };
112
119
  }
113
120
  if (env.AGENT_MODEL_BASE_URL)
114
- return { origin: gatewayBase("AGENT_MODEL_BASE_URL", env.AGENT_MODEL_BASE_URL), credential: () => env.AGENT_MODEL_API_KEY || "none", auth: "bearer", modelId: model.modelId, priceModel: model };
121
+ return gatewayProvider(env, model);
115
122
  if (model.provider === "openrouter" && model.modelId.startsWith("openai/"))
116
123
  return { origin: OPENROUTER_BASE, credential: openRouterKey(env, who, named), auth: "bearer", modelId: model.modelId, priceModel: model };
117
124
  if (model.provider !== "openai")
@@ -1,6 +1,7 @@
1
1
  import { LEARNING_LABEL } from "./learning.js";
2
2
  import { said } from "./learning-words.js";
3
3
  import { askedForDryRun } from "./learn/reflect.js";
4
+ import { askedForCompile } from "./learn/compile.js";
4
5
  /** The run asked its end-of-run turn and has not ended since. */
5
6
  export const reflecting = (run) => run.meta.reflect !== undefined && run.meta.reflect.until === undefined;
6
7
  /** A row's store entry, from its id (`<conversation>:<entry>[:...]`); NaN for a row no entry made (a live one, usage). */
@@ -25,6 +26,6 @@ export function labelled(reflect, rows) {
25
26
  ...row, agent_label: LEARNING_LABEL,
26
27
  ...(row.kind === "final_answer" ? { kind: "text_block" } : {}),
27
28
  // The turn asked again for a draft whose dry run failed says so; every other message of the turn is its ask.
28
- ...(row.kind === "user_message" ? (askedForDryRun(row.text) ? { summary: said.askedDryRun, text: said.askedDryRun } : { summary: said.asked, text: said.asked }) : {}),
29
+ ...(row.kind === "user_message" ? ((words) => ({ summary: words, text: words }))(askedForDryRun(row.text) ? said.askedDryRun : askedForCompile(row.text) === "again" ? said.askedCompileAgain : askedForCompile(row.text) ? said.askedCompile : said.asked) : {}),
29
30
  }));
30
31
  }
package/dist/rows.d.ts CHANGED
@@ -30,9 +30,11 @@ export declare class RowLog {
30
30
  private readonly waiters;
31
31
  constructor(clock: ChangeClock);
32
32
  private next;
33
- /** Make the served rows equal `rows`: new ids are added after every row served so far, changed ones keep their seq,
34
- * and ids no longer there are dropped, except those `keep` says stay (a row a committed entry made: the timeline only
35
- * grows). Returns whether anything changed. */
33
+ /** Make the served rows equal `rows`, in their order: new ids are added after every row served so far, changed ones
34
+ * keep their seq, and ids no longer there are dropped, except those `keep` says stay (a row a committed entry made: the
35
+ * timeline only grows). A row that now comes after a row served later than it moves after it (a new seq, as a change),
36
+ * so this log reads as a fresh one synced from the same rows: the learning row, which the view adds after every row of
37
+ * the run, moves after a feedback round's rows or a follow-up's. Returns whether anything changed. */
36
38
  sync(rows: readonly TimelineEvent[], keep?: (id: string) => boolean): boolean;
37
39
  /** The run's status and state, as one more change when they move. */
38
40
  setState(value: string): boolean;
package/dist/rows.js CHANGED
@@ -31,18 +31,27 @@ export class RowLog {
31
31
  next() {
32
32
  return this.clock.next();
33
33
  }
34
- /** Make the served rows equal `rows`: new ids are added after every row served so far, changed ones keep their seq,
35
- * and ids no longer there are dropped, except those `keep` says stay (a row a committed entry made: the timeline only
36
- * grows). Returns whether anything changed. */
34
+ /** Make the served rows equal `rows`, in their order: new ids are added after every row served so far, changed ones
35
+ * keep their seq, and ids no longer there are dropped, except those `keep` says stay (a row a committed entry made: the
36
+ * timeline only grows). A row that now comes after a row served later than it moves after it (a new seq, as a change),
37
+ * so this log reads as a fresh one synced from the same rows: the learning row, which the view adds after every row of
38
+ * the run, moves after a feedback round's rows or a follow-up's. Returns whether anything changed. */
37
39
  sync(rows, keep) {
38
40
  let changed = false;
39
41
  const present = new Set();
42
+ // The latest seq of the rows so far, the usage row's left out (it goes last below).
43
+ let latest = -1;
40
44
  for (const row of rows) {
41
45
  present.add(row.id);
42
46
  const text = SEQ_FREE(row);
43
47
  const slot = this.slots.get(row.id);
44
48
  if (slot && !slot.dropped) {
45
- if (slot.text === text)
49
+ const behind = row.kind !== "usage" && slot.seq < latest;
50
+ if (behind)
51
+ slot.seq = this.seq++;
52
+ if (row.kind !== "usage")
53
+ latest = Math.max(latest, slot.seq);
54
+ if (slot.text === text && !behind)
46
55
  continue;
47
56
  slot.text = text;
48
57
  slot.row = { ...row, id: slot.id, seq: slot.seq };
@@ -56,6 +65,8 @@ export class RowLog {
56
65
  if (slot)
57
66
  this.slots.set(`${row.id}\0${slot.change}`, slot);
58
67
  const seq = this.seq++;
68
+ if (row.kind !== "usage")
69
+ latest = seq;
59
70
  this.slots.set(row.id, { id, source: row.id, seq, row: { ...row, id, seq }, change: this.next(), dropped: false, text });
60
71
  changed = true;
61
72
  }
@@ -72,6 +72,13 @@ export interface RunLaunch {
72
72
  readonly seedFailed?: SeedFailed;
73
73
  readonly use?: true;
74
74
  };
75
+ /** `false`: the run never starts on a learned workflow, even one that fits its input (RunCreate `workflow_first`,
76
+ * runner/workflow-first.ts); its agent takes it from its first turn. Absent: a fitting one serves first. */
77
+ readonly workflowFirst?: false;
78
+ /** A replay run (runner/promotion.ts): learned workflow `workflow` at `digest`, run alone on graded run `of`'s input to
79
+ * decide whether that revision serves first (learn/promote.ts). Its guards read record-only (learn/promote.ts recordOnly), a hand-back ends it
80
+ * with no agent turn, and it asks nothing at its end. Absent: a run of its own. */
81
+ readonly replay?: Replay;
75
82
  /** The trigger and firing that started the run, or none for a person's run. */
76
83
  readonly trigger?: RunTrigger;
77
84
  /** Who the first message is from, when not the person: kept only through the fail-safe below. */
@@ -89,6 +96,12 @@ export interface RunLaunch {
89
96
  readonly minutes: number;
90
97
  };
91
98
  }
99
+ /** What a replay run replays: the graded run, and the learned workflow at the digest it decides. */
100
+ export interface Replay {
101
+ readonly of: string;
102
+ readonly workflow: string;
103
+ readonly digest: string;
104
+ }
92
105
  /** The disk a launch record names, and whose it is. */
93
106
  export interface LaunchDisk {
94
107
  readonly diskId: string;
@@ -10,6 +10,8 @@ import { originOf } from "./timeline/index.js";
10
10
  import { isObject } from "./validate.js";
11
11
  /** The disk a launch body names, as read back, or undefined. */
12
12
  const readDisk = (value) => isObject(value) && typeof value.disk_id === "string" && (value.kind === "launch" || value.kind === "agent") ? { diskId: value.disk_id, kind: value.kind } : undefined;
13
+ /** The replay a launch body names, as read back, or undefined. */
14
+ const readReplay = (value) => isObject(value) && typeof value.of === "string" && typeof value.workflow === "string" && typeof value.digest === "string" ? { of: value.of, workflow: value.workflow, digest: value.digest } : undefined;
13
15
  /** The trigger a launch body names, as read back: `{ id, firing_key }`, or null (triggerOf of the old serve.json). */
14
16
  function readTrigger(value) {
15
17
  return isObject(value) && typeof value.id === "string" && typeof value.firing_key === "string" ? { id: value.id, firing_key: value.firing_key } : null;
@@ -60,6 +62,8 @@ export function launchBody(launch) {
60
62
  ...(launch.boxAllowSet ? { box_allow_set: true } : {}),
61
63
  ...(launch.files?.length ? { files: launch.files } : {}),
62
64
  ...(launch.learning ? { learning: { given: launch.learning.given.map((note) => ({ file: note.file, name: note.name })), seed: launch.learning.seed, section: launch.learning.section, ...(launch.learning.seedNotes !== undefined ? { seedNotes: launch.learning.seedNotes } : {}), ...(launch.learning.notesLeftOut?.length ? { notesLeftOut: [...launch.learning.notesLeftOut] } : {}), ...(launch.learning.skills?.length ? { skills: [...launch.learning.skills] } : {}), ...(launch.learning.notesOnly ? { notesOnly: true } : {}), ...(launch.learning.workflows?.length ? { workflows: [...launch.learning.workflows] } : {}), ...(launch.learning.gradeModel ? { gradeModel: launch.learning.gradeModel } : {}), ...(launch.learning.seedFailed ? { seedFailed: launch.learning.seedFailed } : {}), ...(launch.learning.use ? { use: true } : {}) } } : {}),
65
+ ...(launch.workflowFirst === false ? { workflow_first: false } : {}),
66
+ ...(launch.replay ? { replay: { of: launch.replay.of, workflow: launch.replay.workflow, digest: launch.replay.digest } } : {}),
63
67
  ...(launch.trigger ? { trigger: launch.trigger } : {}),
64
68
  ...(launch.inputOrigin ? { input_origin: launch.inputOrigin } : {}),
65
69
  ...(launch.followUp ? { follow_up: true } : {}),
@@ -111,6 +115,8 @@ export function readLaunchBody(stored) {
111
115
  ...(stored.box_allow_set === true ? { boxAllowSet: true } : {}),
112
116
  ...(Array.isArray(stored.files) && stored.files.every((id) => typeof id === "string") ? { files: stored.files } : {}),
113
117
  ...(stored.learning !== undefined ? { learning: readLearning(stored.learning) ?? { given: [], seed: null, section: "" } } : {}),
118
+ ...(stored.workflow_first === false ? { workflowFirst: false } : {}),
119
+ ...(readReplay(stored.replay) ? { replay: readReplay(stored.replay) } : {}),
114
120
  ...(trigger ? { trigger } : {}),
115
121
  ...(inputOrigin ? { inputOrigin } : {}),
116
122
  ...(stored.follow_up === true ? { followUp: true } : {}),
@@ -30,6 +30,17 @@ export declare function servedRunLearning(deps: {
30
30
  path?: string | undefined;
31
31
  rule: import("./learn/check.js").Rule;
32
32
  }[];
33
+ compiled: {
34
+ workflow: string;
35
+ from_notes: string[];
36
+ attempts: {
37
+ ok: boolean;
38
+ errors: string[];
39
+ }[];
40
+ digest: string | null;
41
+ promoted: boolean | null;
42
+ } | null;
43
+ draft_errors: string[];
33
44
  cost_usd: {
34
45
  grade: number | null;
35
46
  };
@@ -53,8 +64,8 @@ export declare function servedRunLearning(deps: {
53
64
  skills?: import("./learning.js").LearnedFile[];
54
65
  workflows?: import("./learning.js").LearnedFile[];
55
66
  run: string;
56
- state: "dropped" | "proposed" | "merged" | "seeded" | "reflecting";
57
- reason: "cancelled" | "use" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
67
+ state: "proposed" | "dropped" | "merged" | "seeded" | "reflecting";
68
+ reason: "cancelled" | "no_budget" | "empty" | "unparsed" | "use" | "seed_failed" | "unknown_cost" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "grader" | "grade_failed" | null;
58
69
  detail: string | null;
59
70
  at: string;
60
71
  } | null>;
@@ -22,6 +22,11 @@ export declare function filesLine(label: string, files: readonly ManifestFile[],
22
22
  * entered; a dot-name left out. None when there is no inputs/ or a folder of it cannot be read. The run's start still
23
23
  * hands its folder's path. */
24
24
  export declare function inputFiles(given: Workspace | string): Promise<ManifestFile[]>;
25
+ /** The text a run's input is sent to its model as, on every harness: its `content`, then, after a blank line, its other
26
+ * fields (an agent's typed input, definition.input_schema) as one fenced json block under the line `Input:`, so the
27
+ * model reads each field by its name and its value as given, never as prose a value could break out of. The fence is
28
+ * longer than any run of backticks in the JSON, so no value ends the block. No other field: the content alone. */
29
+ export declare function inputMessage(input: unknown): string;
25
30
  /** The run's first message: `content`, then, after a blank line, the files given to it, when it has any: as many named
26
31
  * as keep the message within `budget` (FIRST_MESSAGE_BYTES), else only how many, else no line at all, so the line never
27
32
  * turns a message the run took into one its door refuses. */