@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
@@ -56,6 +56,26 @@ export async function inputFiles(given) {
56
56
  await into(INPUTS_DIR, 1);
57
57
  return files.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
58
58
  }
59
+ /** The text a run's input is sent to its model as, on every harness: its `content`, then, after a blank line, its other
60
+ * fields (an agent's typed input, definition.input_schema) as one fenced json block under the line `Input:`, so the
61
+ * model reads each field by its name and its value as given, never as prose a value could break out of. The fence is
62
+ * longer than any run of backticks in the JSON, so no value ends the block. No other field: the content alone. */
63
+ export function inputMessage(input) {
64
+ if (typeof input !== "object" || input === null || Array.isArray(input))
65
+ return "";
66
+ const { content, ...fields } = input;
67
+ const text = typeof content === "string" ? content : "";
68
+ if (!Object.keys(fields).length)
69
+ return text;
70
+ const json = JSON.stringify(fields, null, 2);
71
+ // A loop, never a spread into Math.max: a value may hold more runs of backticks than a call takes arguments.
72
+ let longest = 3;
73
+ for (const run of json.matchAll(/`+/g))
74
+ longest = Math.max(longest, run[0].length + 1);
75
+ const fence = "`".repeat(longest);
76
+ const block = `Input:\n${fence}json\n${json}\n${fence}`;
77
+ return text ? `${text}\n\n${block}` : block;
78
+ }
59
79
  /** The run's first message: `content`, then, after a blank line, the files given to it, when it has any: as many named
60
80
  * as keep the message within `budget` (FIRST_MESSAGE_BYTES), else only how many, else no line at all, so the line never
61
81
  * turns a message the run took into one its door refuses. */
@@ -5,7 +5,7 @@ import { harnessOfBody } from "./harness.js";
5
5
  import { harnessOf } from "./harness-table.js";
6
6
  import { GATEWAY_KEY_ENV, llmTiers, modelKeys, nodeTiers, PROVIDER_KEYS, workflowNodes } from "./model.js";
7
7
  import { DECISION_KEYS, SECRET_NAMES } from "./secrets.js";
8
- import { TOOL_KEYS } from "./tool-keys.js";
8
+ import { TOOL_KEYS, unlocksTool } from "./tool-keys.js";
9
9
  import { workflowTools } from "./tools.js";
10
10
  /** The server's own secrets, which a run never gets: the API token, by name or by value, the seal key the tool keys are
11
11
  * kept under (tool-keys.ts), the store's URL (it may hold the database's password), and the remote boxes' keys
@@ -40,8 +40,7 @@ export async function needsOf(revision) {
40
40
  * sends for the revision's model (adapters.ts' harnessModelKeys). Read at each claim, so a key saved with no restart
41
41
  * counts at the next. */
42
42
  export function keysFor(needs, env, rows = TOOL_KEYS) {
43
- const named = new Set(needs.tools);
44
- const unlocked = new Set(rows.filter((row) => row.unlocks.some((name) => named.has(name))).flatMap((row) => row.fields));
43
+ const unlocked = new Set(rows.filter((row) => row.unlocks.some((unlock) => needs.tools.some((name) => unlocksTool(unlock, name)))).flatMap((row) => row.fields));
45
44
  const scoped = scopedOf(rows);
46
45
  const entry = harnessOf(env, needs.harness);
47
46
  const model = new Set(!entry || entry.facts ? harnessModelKeys(needs.harness, env, needs.model) : needs.tiers ? modelKeys(env, undefined, needs.tiers) : modelKeys(env, needs.model));
@@ -40,8 +40,11 @@ export async function servedTimelineRows(deps, store, runId, context) {
40
40
  // never an earlier wait's words.
41
41
  // Its final answer whole, as the run's view serves it (store-reads/journal.ts wholeAnswers): a row's cut is no answer's.
42
42
  // A run that ended is read settled, as its view reads it: nothing of it is in flight, so a request it left unanswered
43
- // is a cost unknown, never one still running.
44
- const options = { redact, settled: ended };
43
+ // is a cost unknown, never one still running; its usage row says its cost, never what it has cost so far.
44
+ // Over is not final: an agentic run a person stopped is final in the store but reads running in its view (readRun: its
45
+ // turn is over, the run can go on), and its usage row says what it has cost so far there, so here too.
46
+ const view = await readRun(snapshot, runId, context);
47
+ const options = { redact, settled: ended, ended: view ? view.state !== "running" : false };
45
48
  const timeline = await wholeAnswers(snapshot, runId, context, await runTimeline(snapshot, runId, context, options), options, wholeAnswerFor(values));
46
49
  // A run whose booked spend passed its cap says so, by how much, after its usage row (run-view.ts withOverCap, as main's
47
50
  // served Timeline did): at the cap as it stands (a raise taken counts, capNowOf), a cache miss within the bound of the
@@ -62,11 +62,12 @@ export type Approval = {
62
62
  args_json: string;
63
63
  requested_at: string;
64
64
  price?: number | "not metered";
65
+ destructive?: true;
65
66
  resolved?: true;
66
67
  };
67
68
  /** `args_shown`: the call's arguments as the server shows them (shownArgs), which the gate's resume message names. */
68
- /** `by`: "message", a deny a person's message gave while the call waited (Runs.message); "setting", the allow the tool's setting gave an ask that waited (the person flipped the tool to allow). */
69
- /** `superseded`: the answer a stop or a cancel overrode before the run's process acted on it, kept as it was given. */
69
+ /** `by`: "message", a deny a person's message gave while the call waited (Runs.message); "setting", the allow or deny the tool's setting gave an ask that waited (the tool set to allow or deny since it asked). */
70
+ /** `superseded`: the answer a stop or a cancel overrode before the run's process acted on it, or the person's allow a deny set since overrode, kept as it was given. */
70
71
  /** `ended`: a withdrawal by a run that ended (completed or failed) with the call waiting, which nobody stopped. */
71
72
  export type ApprovalAnswer = {
72
73
  decision: "allow" | "deny" | "canceled" | "withdrawn";
@@ -349,6 +350,8 @@ export interface RunMoment {
349
350
  readonly waitingApprovalId?: string;
350
351
  /** The tool calls this run has or had waiting for approval, by id (for the not-found refusal). */
351
352
  readonly approvalIds?: ReadonlySet<string>;
353
+ /** Those of them its pin marks destructive: an allow of one needs confirm_destructive (runs-over-store.ts approve). */
354
+ readonly destructiveIds?: ReadonlySet<string>;
352
355
  /** What is archived of it, when anything is: its agent, else the run itself. Archiving closes a run: it takes no message
353
356
  * (runs-over-store.ts message). Absent when neither is. */
354
357
  readonly archived?: "run" | "agent";
@@ -415,8 +418,9 @@ export declare function rowShown(deps: {
415
418
  serverSecrets: () => string[];
416
419
  signIns: SignInReader | undefined;
417
420
  }, agentId: string, browser: string | undefined, handed: Handed | undefined, damaged?: boolean): Promise<((text: string) => string) | "withheld">;
418
- /** A call that waited for approval, once its outcome shows below its approval: its own rows (the call's, its result's) say
419
- * only that it was held. A client folds them into the call's step, at the call's place above the approval row. */
421
+ /** A call that waited for approval and was declined, once its outcome shows below its approval: its own rows (the call's,
422
+ * its result's) say only that it was held. A client folds them into the call's step, at the call's place above the
423
+ * approval row. (One allowed reads as any call that ran, once it ran.) */
420
424
  export declare const HELD = "Held for your approval";
421
425
  /** At most this many code points of a person's note on a row's summary; the record keeps it whole. */
422
426
  export declare const NOTE_CHARS = 200;
@@ -432,17 +436,24 @@ export declare function outcomeSays(tool: string, answer: {
432
436
  decision: string;
433
437
  by?: string;
434
438
  note?: string;
439
+ superseded?: {
440
+ decision: string;
441
+ };
435
442
  }, failed: boolean, redact: (text: string) => string): string;
436
443
  /** What a person reads when they open the outcome row: the outcome, then the call's result (`rest`), or the refusal's words.
437
444
  * An empty result says so: "Its result: (no output)", never "Its result:" and nothing. */
438
445
  export declare function outcomeShows(tool: string, answer: {
439
446
  decision: string;
440
447
  by?: string;
448
+ superseded?: {
449
+ decision: string;
450
+ };
441
451
  }, rest: string, failed: boolean): string;
442
452
  /** The rows of a run whose calls waited for approval, as the runner writes it (store-view.ts): the gate's ask
443
453
  * (agentrun.ask, `asks`) and the person's answer (agentrun.answer, `answers`) are journal entries, and an allowed call runs
444
- * in place, so its result row is its real result; a denied one's is the refusal. Each such call reads in order: its own
445
- * rows, then the approval row, then, once there is one, the outcome row; its own rows say only that it was held once the
454
+ * in place, so its result row is its real result; a denied one's is the refusal. Each such call reads in order: its call,
455
+ * then the approval row at the ask's time, then its result, then, once there is one, the outcome row (before a result is
456
+ * in, the approval row and any outcome follow its own rows); its own rows say only that it was held once the
446
457
  * outcome shows below, and before that what came of the approval so far. Arguments and notes go through `redact`, the
447
458
  * run's redactor, before any cut. The rows this function makes are dropped first, so a pass over its own output gives the
448
459
  * same rows. */
package/dist/run-view.js CHANGED
@@ -138,6 +138,7 @@ export function asksOf(entries) {
138
138
  args_json: JSON.stringify(d.args ?? {}) ?? "{}",
139
139
  requested_at: d.requestedAt,
140
140
  ...(typeof d.price === "number" || d.price === "not metered" ? { price: d.price } : {}),
141
+ ...(d.destructive === true ? { destructive: true } : {}),
141
142
  ...(answered.has(d.callId) ? { resolved: true } : {}),
142
143
  });
143
144
  }
@@ -168,9 +169,12 @@ export function answersOf(entries, { final } = {}) {
168
169
  const given = out[d.callId];
169
170
  if (given && !((decision === "withdrawn" || decision === "canceled") && d.superseded))
170
171
  continue;
171
- const superseded = given ? { superseded: { decision: given.decision, answered_at: given.answered_at, ...(given.note !== undefined ? { note: given.note } : {}), ...(given.by ? { by: given.by } : {}) } } : {};
172
- // A deny a person's message gave keeps that it was (`by`): its row reads "Declined by your message".
173
- out[d.callId] = { decision, ...(d.note !== undefined ? { note: d.note } : {}), answered_at: d.answeredAt ?? "", ...(decision === "deny" && d.by === "message" ? { by: "message" } : decision === "allow" && d.by === "setting" ? { by: "setting" } : {}), ...superseded };
172
+ // The answer it overrode: one given before it, or, for a deny its tool's setting gave over a person's allow taken with
173
+ // it (adapter-loop.ts deniedBySetting), the allow its entry keeps.
174
+ const superseded = given ? { superseded: { decision: given.decision, answered_at: given.answered_at, ...(given.note !== undefined ? { note: given.note } : {}), ...(given.by ? { by: given.by } : {}) } } : d.superseded ? { superseded: { decision: d.superseded.decision, answered_at: d.superseded.answeredAt ?? "" } } : {};
175
+ // A deny a person's message gave keeps that it was (`by`): its row reads "Declined by your message"; so does an answer
176
+ // the tool's setting gave (an allow, or a deny set since the call asked).
177
+ out[d.callId] = { decision, ...(d.note !== undefined ? { note: d.note } : {}), answered_at: d.answeredAt ?? "", ...(decision === "deny" && d.by === "message" ? { by: "message" } : (decision === "allow" || decision === "deny") && d.by === "setting" ? { by: "setting" } : {}), ...superseded };
174
178
  }
175
179
  // How the run ended after each entry: the state of the first agentrun.end at or after it, else the final row's.
176
180
  let endedAs = final;
@@ -354,7 +358,7 @@ export const pendingOf = (rows) => {
354
358
  /** The run's pending approval (`pending`, kind approval): the call that waits; else undefined. */
355
359
  export const approvalOf = (run, redact) => {
356
360
  const waiting = waitingApproval(run);
357
- return waiting ? { kind: "approval", id: waiting.id, tool: waiting.tool, call_id: waiting.call_id, args_preview: shownArgs(waiting, redact), requested_at: waiting.requested_at, ...(waiting.price !== undefined ? { price: waiting.price } : {}) } : undefined;
361
+ return waiting ? { kind: "approval", id: waiting.id, tool: waiting.tool, call_id: waiting.call_id, args_preview: shownArgs(waiting, redact), requested_at: waiting.requested_at, ...(waiting.price !== undefined ? { price: waiting.price } : {}), ...(waiting.destructive ? { destructive: true } : {}) } : undefined;
358
362
  };
359
363
  /** A run whose agent asked for the person in its browser waits on their hand-back: what it asked them to do, when it is
360
364
  * done, and when the ask expires. Never the session's tag or the live view's link. The two texts are the model's, so
@@ -460,7 +464,7 @@ export function momentOf(run, facts, live) {
460
464
  // counted but not shown), or a question its turn ended on.
461
465
  waitsOnPerson: run.kind === "agentic" && (waiting !== undefined || pausedAt(run, { inFlight: false }) !== undefined || (status === "input_required" && state === "waiting")),
462
466
  ...(waiting ? { waitingApprovalId: waiting.id } : {}),
463
- ...(run.approvals ? { approvalIds: new Set(run.approvals.keys()) } : {}),
467
+ ...(run.approvals ? { approvalIds: new Set(run.approvals.keys()), destructiveIds: new Set([...run.approvals.values()].filter((one) => one.destructive).map((one) => one.id)) } : {}),
464
468
  ...(answered ? { answeredApprovals: Object.fromEntries(Object.entries(answered).map(([id, a]) => [id, { decision: a.decision, ...(a.ended ? { ended: true } : {}) }])) } : {}),
465
469
  };
466
470
  }
@@ -541,8 +545,9 @@ export async function rowShown(deps, agentId, browser, handed, damaged = false)
541
545
  const values = [...deps.serverSecrets(), ...pointers.refs.filter((ref) => ref.length >= MIN_SECRET)];
542
546
  return (text) => withoutLoopback(redacted(text, values));
543
547
  }
544
- /** A call that waited for approval, once its outcome shows below its approval: its own rows (the call's, its result's) say
545
- * only that it was held. A client folds them into the call's step, at the call's place above the approval row. */
548
+ /** A call that waited for approval and was declined, once its outcome shows below its approval: its own rows (the call's,
549
+ * its result's) say only that it was held. A client folds them into the call's step, at the call's place above the
550
+ * approval row. (One allowed reads as any call that ran, once it ran.) */
546
551
  export const HELD = "Held for your approval";
547
552
  /** At most this many code points of a person's note on a row's summary; the record keeps it whole. */
548
553
  export const NOTE_CHARS = 200;
@@ -564,6 +569,8 @@ export function noteShown(note, redact) {
564
569
  * ran and where its result went, or that it failed; a note sent with an allow is shown nowhere, as on main. */
565
570
  export function outcomeSays(tool, answer, failed, redact) {
566
571
  if (answer.decision === "deny") {
572
+ if (answer.by === "setting")
573
+ return `AgentRun: ${deniedSince(tool, answer)}`;
567
574
  if (answer.by === "message")
568
575
  return `AgentRun: Your message declined ${tool}.`;
569
576
  const note = noteShown(answer.note, redact);
@@ -576,10 +583,17 @@ export function outcomeSays(tool, answer, failed, redact) {
576
583
  * An empty result says so: "Its result: (no output)", never "Its result:" and nothing. */
577
584
  export function outcomeShows(tool, answer, rest, failed) {
578
585
  if (answer.decision === "deny")
579
- return `${answer.by === "message" ? `Your message declined ${tool}.` : `You declined ${tool}.`}${rest.trim() ? `\n${rest.trim()}` : ""}`;
586
+ return `${answer.by === "setting" ? `${deniedSince(tool, answer)}.` : answer.by === "message" ? `Your message declined ${tool}.` : `You declined ${tool}.`}${rest.trim() ? `\n${rest.trim()}` : ""}`;
580
587
  const head = `${tool} ${answer.by === "setting" ? "ran, as its setting allows it" : "ran once you allowed it"}${failed ? ", and failed" : ""}.`;
581
588
  return rest.trim() ? `${head} Its result:\n${rest}` : `${head} Its result: (no output)`;
582
589
  }
590
+ /** A call refused by a deny its tool's setting gained while it waited (adapter-loop.ts deniedBySetting), as its outcome
591
+ * says it: that the person allowed it first, when they did (the allow the deny overrode). */
592
+ const deniedSince = (tool, answer) => answer.superseded?.decision === "allow" ? `You allowed ${tool}, but it is now set to deny on this server, so it was not run` : `${tool} was not run: it is now set to deny on this server`;
593
+ /** The own rows of a call refused so. */
594
+ const DENIED_SINCE = "Not run: its tool is now set to deny on this server";
595
+ /** How an allowed call came to run, as its own result row says it beside its outcome. */
596
+ const ranAs = (answer) => (answer.by === "setting" ? "ran, as its setting allows it" : "ran once you allowed it");
583
597
  /** A call's own rows (its call's, its result's) before its outcome shows: what came of the approval so far. */
584
598
  function callSays(answer) {
585
599
  if (!answer)
@@ -600,8 +614,9 @@ const unrefused = (row) => {
600
614
  const approvalRowId = (callId) => `approval:${callId}`;
601
615
  /** The rows of a run whose calls waited for approval, as the runner writes it (store-view.ts): the gate's ask
602
616
  * (agentrun.ask, `asks`) and the person's answer (agentrun.answer, `answers`) are journal entries, and an allowed call runs
603
- * in place, so its result row is its real result; a denied one's is the refusal. Each such call reads in order: its own
604
- * rows, then the approval row, then, once there is one, the outcome row; its own rows say only that it was held once the
617
+ * in place, so its result row is its real result; a denied one's is the refusal. Each such call reads in order: its call,
618
+ * then the approval row at the ask's time, then its result, then, once there is one, the outcome row (before a result is
619
+ * in, the approval row and any outcome follow its own rows); its own rows say only that it was held once the
605
620
  * outcome shows below, and before that what came of the approval so far. Arguments and notes go through `redact`, the
606
621
  * run's redactor, before any cut. The rows this function makes are dropped first, so a pass over its own output gives the
607
622
  * same rows. */
@@ -628,19 +643,33 @@ export function withApprovalRows(rows, asks, answers, redact) {
628
643
  const answer = answers[approval.id];
629
644
  const result = given.find((other) => other.kind === "tool_result" && other.tool_use_id === approval.call_id);
630
645
  // The outcome shows once there is one: a deny's at once, an allow's when its call's result is in.
631
- const outcome = answer?.decision === "deny" || (answer?.decision === "allow" && result !== undefined);
632
- const own = { ...row, summary: outcome ? HELD : callSays(answer), tool_status: null };
633
- if (lastOf.get(approval.call_id) !== row.id)
646
+ const ran = answer?.decision === "allow" && result !== undefined;
647
+ const outcome = answer?.decision === "deny" || ran;
648
+ // An allowed call that ran reads as any call (its summary, its status), its result row saying too how it came to run;
649
+ // one a deny set since refused says so; any other only that it was held, or what came of its approval so far.
650
+ // Said once: a pass over its own output keeps the words it added.
651
+ const said = ran ? `(${ranAs(answer)})` : "";
652
+ const own = ran ? (row.kind === "tool_result" && !row.summary?.endsWith(said) ? { ...row, summary: row.summary ? `${row.summary} ${said}` : said } : row)
653
+ : answer?.decision === "deny" && answer.by === "setting" ? { ...row, summary: DENIED_SINCE }
654
+ : { ...row, summary: outcome ? HELD : callSays(answer), tool_status: null };
655
+ // The approval row sits above the call's result once there is one (the ask came before the call ran), else below its
656
+ // last own row; the outcome rows below its last own row.
657
+ const askHere = row.id === (result?.id ?? lastOf.get(approval.call_id));
658
+ const last = lastOf.get(approval.call_id) === row.id;
659
+ if (!askHere && !last)
634
660
  return [own];
635
661
  const args = shownArgs(approval, redact);
636
- // A served row keeps the place it was first served at (rows.ts). The call's result comes in after the answer (the park
637
- // writes none), so the approval and outcome rows take a new id once it is there: served anew below the result, the
638
- // call's own rows, then its approval, then what came of it, as a person reads it.
662
+ // A served row keeps the place it was first served at (rows.ts). The approval row is served while the call waits, above
663
+ // the result yet to come, so it keeps its id. The call's result comes in after the answer (the park writes none), so the
664
+ // outcome rows take a new id once it is there: served anew below the result, as a person reads it.
639
665
  const at = result ? `${approvalRowId(approval.call_id)}:after` : approvalRowId(approval.call_id);
640
- const head = !answer ? "Waiting for your approval" : answer.decision === "canceled" ? "Withdrawn when the run was cancelled" : answer.decision === "withdrawn" ? (answer.ended ? "Withdrawn when the run ended" : "Withdrawn when the run was stopped") : answer.by === "message" ? "Declined by your message" : answer.by === "setting" ? "Allowed by the tool's setting" : "Asked your approval";
641
- const asked = { ...unrefused(row), id: at, kind: APPROVAL_ROW, summary: `${head}: ${approval.tool} ${clip(args, 400)}`, text: args, tool_name: approval.tool, tool_status: null, tool_input_preview: clip(args, 500), tool_result_preview: null, tool_result_size_bytes: null };
642
- if (!outcome)
643
- return [own, asked];
666
+ const head = !answer ? "Waiting for your approval" : answer.decision === "canceled" ? "Withdrawn when the run was cancelled" : answer.decision === "withdrawn" ? (answer.ended ? "Withdrawn when the run ended" : "Withdrawn when the run was stopped") : answer.by === "message" ? "Declined by your message" : answer.by === "setting" ? (answer.decision === "deny" ? "Denied by the tool's setting on this server" : "Allowed by the tool's setting") : "Asked your approval";
667
+ // Its time is the ask's (the gate's requestedAt), never the row it was made from.
668
+ const when = approval.requested_at ? { timestamp: approval.requested_at, created_at: approval.requested_at } : {};
669
+ const asked = { ...unrefused(row), ...when, id: approvalRowId(approval.call_id), kind: APPROVAL_ROW, summary: `${head}: ${approval.tool} ${clip(args, 400)}`, text: args, tool_name: approval.tool, tool_status: null, tool_input_preview: clip(args, 500), tool_result_preview: null, tool_result_size_bytes: null };
670
+ const placed = !askHere ? [own] : result ? [asked, own] : [own, asked];
671
+ if (!last || !outcome)
672
+ return placed;
644
673
  const failed = answer.decision === "allow" && result?.tool_status === "failed";
645
674
  // The result's words: a tool_result row keeps them as its preview (the renderer's, redacted and cut), its text empty.
646
675
  const told = { ...unrefused(result ?? row), id: `${at}:outcome`, kind: "phase", origin: "server", summary: outcomeSays(approval.tool, answer, failed, redact), text: outcomeShows(approval.tool, answer, redact(result?.text || result?.tool_result_preview || ""), failed), tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null };
@@ -650,8 +679,8 @@ export function withApprovalRows(rows, asks, answers, redact) {
650
679
  const words = redact(answer.note);
651
680
  const { origin: _origin, ...base } = unrefused(result ?? row);
652
681
  const theirs = { ...base, id: `${at}:message`, kind: "user_message", summary: clip(`You: ${words.split("\n", 1)[0]}`, 500), text: words, tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null };
653
- return [own, asked, theirs, told];
682
+ return [...placed, theirs, told];
654
683
  }
655
- return [own, asked, told];
684
+ return [...placed, told];
656
685
  });
657
686
  }
@@ -5,8 +5,6 @@ import type { BoxOffer } from "./place-offers.js";
5
5
  import { type ToolSettingsMap } from "./tool-plane.js";
6
6
  import type { McpTool } from "@parcha/agentrun-kernel";
7
7
  import type { ShellPlace } from "@parcha/agentrun-kernel/kernel";
8
- /** The harnesses an agent's MCP tools run on here. */
9
- export declare const MCP_HARNESSES: readonly string[];
10
8
  /** A revision's computer setting: a kind, its provider, the image it starts from, and a sandbox's GPUs
11
9
  * (computer-setting.ts). */
12
10
  export type RevisionComputer = {
@@ -34,7 +32,6 @@ export type RevisionShape = {
34
32
  unnamed?: true;
35
33
  toolSettings?: ToolSettingsMap;
36
34
  approvals?: "never";
37
- maxToolCalls?: number;
38
35
  } | {
39
36
  kind: "workflow";
40
37
  workflow: unknown;
package/dist/runnable.js CHANGED
@@ -4,10 +4,10 @@
4
4
  // provider's key, a default model, a tier's model) saves as a warning. Either refuses a run, 409 agent_not_runnable.
5
5
  import { WORKFLOW_ADAPTERS } from "./runner/workflow-adapters.js";
6
6
  import { DECISION_ADAPTER, decisionModelsNamed, providerMissing, providersNamed } from "./decisions.js";
7
- import { REPLAY } from "./host-tools.js";
7
+ import { isHostTool } from "./tool-list.js";
8
8
  import { sentence } from "./errors.js";
9
- import { DEFAULT_HARNESS, HARNESSES, harnessOffers } from "./harness.js";
10
- import { builtinHarness, harnessOf, onAdapter } from "./harness-table.js";
9
+ import { DEFAULT_HARNESS, harnessOffers } from "./harness.js";
10
+ import { harnessOf, onAdapter } from "./harness-table.js";
11
11
  import { chooseModel } from "./model.js";
12
12
  import { llmTiers, MODEL_NODES, nodeTiers, unpricedModels, workflowNodes } from "./model.js";
13
13
  import { boxAvailability, newAgentPlace, placeFix, RUN_BOXES } from "./place.js";
@@ -17,10 +17,9 @@ import { denyPlace, permissionFrom, permissionOf } from "./tool-gate.js";
17
17
  import { approvalsOf } from "./approvals.js";
18
18
  import { PARALLEL_KEY_ENV } from "./decisions.js";
19
19
  import { keyNeeded } from "./key-words.js";
20
- import { wireName } from "./catalog.js";
21
- import { mcpHeaderProblem, mcpNameOf } from "./mcp-gateway.js";
22
- /** The harnesses an agent's MCP tools run on here. */
23
- export const MCP_HARNESSES = HARNESSES.filter((id) => builtinHarness(id).mcp);
20
+ import { MONID_KEY_ENV } from "./monid.js";
21
+ import { mcpHeaderProblem } from "./mcp-gateway.js";
22
+ import { isMcpName, isMonidName, mcpDroppedWords, MCP_HANDS_WORDS, mcpNameOf, mcpWireProblem, MONID_NAME_WORDS, parseToolName } from "./tool-names.js";
24
23
  /**
25
24
  * The model `harness` runs an agentic revision on here: `ref`, its own `provider/model-id`, or with none this host's
26
25
  * default for that harness. `why`: the model itself is the problem (`host`, a setting of this host could fix it);
@@ -121,9 +120,9 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
121
120
  // save. A bound or a format it only strips is not: the server still checks it, and its error reaches the model.
122
121
  const schemaProblems = revision.kind === "agentic" ? harnessOf(env, harness)?.facts?.schemaProblems : undefined;
123
122
  /** What keeps the grant of `tool`, an `mcp:` name, from running here (the first thing), at `field`; undefined when
124
- * nothing does. A remote MCP server's tool runs when its saved snapshot lists it, on a harness that binds them; a
125
- * workflow's nodes bind none. The one check of an MCP grant, for an agentic revision's tools and for every tool a
126
- * workflow grants (grantedTools). */
123
+ * nothing does. A remote MCP server's tool runs when its saved snapshot lists it, on every harness (a host tool
124
+ * like any other); a workflow's nodes bind none. The one check of an MCP grant, for an agentic revision's tools and
125
+ * for every tool a workflow grants (grantedTools). */
127
126
  const mcpGrant = (field, tool) => {
128
127
  const named = mcpNameOf(tool);
129
128
  const saved = named && mcp?.(named.server);
@@ -134,10 +133,10 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
134
133
  // Refused here, not missing at the run (schemaProblems above).
135
134
  const dropped = schema && named && schemaProblems ? schemaProblems(`mcp__${named.server}__${named.tool}`, schema)[0] : undefined;
136
135
  if (!named)
137
- return { field, reason: "not_an_option", message: `${tool} is not an MCP tool's name: mcp:<server>/<tool>, the server's name in lowercase letters, digits and -.`, host: false, tool };
136
+ return { field, reason: "not_an_option", message: `${tool} is not an MCP tool's name: mcp:<server>/<tool>, the server's name in lowercase letters, digits and -, the tool's in letters, digits, _ and -, at most 64.`, host: false, tool };
138
137
  // claude-agent's own tools are its MCP server `hands`: a remote server of that name could never be called there.
139
138
  if (named.server === "hands")
140
- return { field, reason: "not_an_option", message: `${tool} names the MCP server hands, a name the harnesses keep for their own tools: save the server under another name.`, host: false, tool };
139
+ return { field, reason: "not_an_option", message: `${tool} ${MCP_HANDS_WORDS}`, host: false, tool };
141
140
  // A meta tool runs other actions by name: a grant of it could not name the action (mcp-meta.ts). Refused before
142
141
  // the harness's check, since no host setup makes it grantable.
143
142
  if (listedTool?.grantable === false)
@@ -145,18 +144,17 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
145
144
  // A workflow's nodes bind no MCP tool here (app.ts): its run would go without it, so its grant is refused.
146
145
  if (revision.kind === "workflow")
147
146
  return { field, reason: "not_an_option", message: `${tool}: a workflow's nodes don't bind MCP tools here yet; grant it to an agentic agent.`, host: false, tool };
148
- if (!MCP_HARNESSES.includes(harness))
149
- return { field, reason: NOT_SET_UP, message: `${tool} runs on ${MCP_HARNESSES.slice(0, -1).join(", ")} and ${MCP_HARNESSES.at(-1)} here; on ${harness} MCP tools are not bound yet.`, host: true, tool };
150
147
  if (!listed)
151
148
  return { field, reason: "not_an_option", message: `No MCP server ${named.server} is saved on this server: add it in Settings → MCP servers first.`, host: false, tool };
152
149
  if (!listed.includes(named.tool))
153
150
  return { field, reason: "not_an_option", message: `The MCP server ${named.server} has no tool ${named.tool}; its tools are ${listed.join(", ") || "none"}.`, host: false, tool };
154
151
  if (dropped)
155
- return { field, reason: "not_an_option", message: `The MCP server ${named.server}'s tool ${named.tool} cannot be offered on ${harness}: ${dropped.replace(/^mcp__\S+: /, "")}.`, host: false, tool };
152
+ return { field, reason: "not_an_option", message: mcpDroppedWords(named.server, named.tool, harness, dropped), host: false, tool };
156
153
  if (declared)
157
154
  return { field, reason: "not_an_option", message: `The MCP server ${named.server}'s tool ${named.tool} declares a header it cannot send: ${declared}.`, host: false, tool };
158
- if (wireName(tool) !== `mcp__${named.server}__${named.tool}`)
159
- return { field, reason: "not_an_option", message: `${tool} is too long: mcp__${named.server}__${named.tool} must be at most 52 characters, the budget every harness's tool names share.`, host: false, tool };
155
+ const wire = mcpWireProblem(named.server, named.tool);
156
+ if (wire)
157
+ return { field, reason: "not_an_option", message: `${tool} ${wire}`, host: false, tool };
160
158
  return undefined;
161
159
  };
162
160
  if (revision.kind === "agentic") {
@@ -164,7 +162,16 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
164
162
  if (!revision.instructions.trim())
165
163
  out.push({ field: "definition.instructions", reason: "too_short", message: "definition.instructions is empty: an agentic revision needs instructions.", host: false });
166
164
  (revision.tools ?? []).forEach((tool, index) => {
167
- if (tool.startsWith("mcp:")) {
165
+ // A monid endpoint is a host tool on every harness; whether monid lists it is read at the save, as it is pinned
166
+ // (monid.ts pinMonid). Its run needs the monid key.
167
+ if (isMonidName(tool)) {
168
+ if (!parseToolName(tool))
169
+ out.push({ field: `definition.tools[${index}]`, reason: "not_an_option", message: MONID_NAME_WORDS(tool), host: false, tool });
170
+ else if (!env[MONID_KEY_ENV]?.trim())
171
+ out.push({ field: `definition.tools[${index}]`, reason: NOT_SET_UP, message: `The tool ${tool} needs ${keyNeeded([MONID_KEY_ENV])}.`, host: true, missing: { tool, vars: [MONID_KEY_ENV] } });
172
+ return;
173
+ }
174
+ if (isMcpName(tool)) {
168
175
  const blocker = mcpGrant(`definition.tools[${index}]`, tool);
169
176
  if (blocker)
170
177
  out.push(blocker);
@@ -178,10 +185,10 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
178
185
  // Its writes into work/ go by path from this machine, and a box's command could swap a link in on their way.
179
186
  else if (toolOf(tool).runnerOnly && place?.mode === "sandbox")
180
187
  out.push({ field: `definition.tools[${index}]`, reason: "not_an_option", message: `${tool} does not run in a sandbox place yet: it saves files into the run's work/ from this server, outside the box, and a command in the box could point those writes elsewhere on this server. Give it to an agent whose place is the runner.`, fix: `Remove "${tool}" from definition.tools.`, host: false, tool });
181
- // Another harness gets the host tools only (host-tools.ts: the file tools, web_fetch, web_search and
182
- // monid's): any other tool this host binds, ask_person among them, is pi's here and refuses the run, never runs
183
- // without it.
184
- else if (onAdapter(env, harness) && !(tool in REPLAY))
188
+ // Another harness gets the host tools only (host-tools.ts: the file tools, ask_person, web_fetch and web_search):
189
+ // any other tool this host binds (the browser, subagent, pdf_pages, llm) is pi's here and refuses the
190
+ // run, never runs without it.
191
+ else if (onAdapter(env, harness) && !isHostTool(tool))
185
192
  out.push({ field: `definition.tools[${index}]`, reason: NOT_SET_UP, message: `${tool} runs on pi here; on ${harness} it is not bound yet.`, host: true, tool });
186
193
  else {
187
194
  unset(`definition.tools[${index}]`, tool);
@@ -191,10 +198,6 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
191
198
  unavailable(`definition.tools[${index}]`, revision.tools ?? [], tool);
192
199
  }
193
200
  });
194
- // The tool-call budget is counted from pi's own journal (tool-budget.ts): on another harness it would hold nothing, so
195
- // the definition is refused, never saved to run without it.
196
- if (revision.maxToolCalls !== undefined && onAdapter(env, harness))
197
- out.push({ field: "definition.max_tool_calls", reason: NOT_SET_UP, message: `A tool-call budget is held on pi here; on ${harness} it is not counted yet.`, fix: "Run the agent on pi, or set max_tool_calls to 0.", host: false, harness });
198
201
  const resolved = await harnessModel(env, harness, revision.model, offer?.available === true);
199
202
  if (!resolved)
200
203
  return out;
@@ -222,12 +225,17 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
222
225
  // Every MCP tool a workflow grants, at its top level or on a node, is held to the one check (mcpGrant): refused at the
223
226
  // save, never a workflow whose run goes without it or cannot launch.
224
227
  const granted = await grantedTools(revision);
225
- for (const tool of granted.filter((name) => name.startsWith("mcp:"))) {
228
+ for (const tool of granted.filter(isMcpName)) {
226
229
  const index = (revision.tools ?? []).indexOf(tool);
227
230
  const blocker = mcpGrant(index >= 0 ? `definition.tools[${index}]` : "definition.workflow", tool);
228
231
  if (blocker)
229
232
  out.push(blocker);
230
233
  }
234
+ // Nor does a workflow's node bind a monid endpoint.
235
+ for (const tool of granted.filter(isMonidName)) {
236
+ const index = (revision.tools ?? []).indexOf(tool);
237
+ out.push({ field: index >= 0 ? `definition.tools[${index}]` : "definition.workflow", reason: "not_an_option", message: `${tool}: a workflow's nodes don't bind monid endpoints yet; grant it to an agentic agent.`, host: false, tool });
238
+ }
231
239
  // A workflow's model nodes run on pi here; on another harness they are not bound yet, and never run on pi instead.
232
240
  if (onAdapter(env, harness))
233
241
  out.push({ field: "definition.workflow", reason: NOT_SET_UP, message: `A workflow runs on pi here; on ${harness} its model nodes are not bound yet.`, host: true, harness });
@@ -259,13 +267,13 @@ export async function blockersOf(env, revision, settings = {}, { capped = false,
259
267
  const named = workflowTools(nodes);
260
268
  for (const tool of named.nodes) {
261
269
  // An MCP tool is said once, by mcpGrant above.
262
- if (tool.startsWith("mcp:"))
270
+ if (isMcpName(tool))
263
271
  continue;
264
272
  if (!allows(NODE_TOOLS, tool))
265
273
  out.push({ field: "definition.workflow", reason: "not_an_option", message: `A workflow's model nodes get the tools ${NODE_TOOLS.join(", ")} here; this workflow also names ${tool}.`, host: false, tool });
266
274
  }
267
275
  for (const tool of named.calls) {
268
- if (tool.startsWith("mcp:"))
276
+ if (isMcpName(tool))
269
277
  continue;
270
278
  if (!allows(CALL_TOOLS, tool))
271
279
  out.push({ field: "definition.workflow", reason: "not_an_option", message: `A workflow's call nodes run the tools ${CALL_TOOLS.join(", ")} here; this workflow also calls ${tool}.`, host: false, tool });
@@ -1,14 +1,14 @@
1
1
  import { type ConversationId, type ConversationRetryPolicy, type ConversationStreamOptions, Harness, type Tx } from "@earendil-works/pi-durable";
2
2
  import { type AgentAdapter, type Refusal, type SessionRecord, type SessionSpec } from "@parcha/agentrun-kernel";
3
3
  import type { KernelHooks, ToolCall } from "./conformance/subject.js";
4
- import { type ApprovalPrice, type BudgetData, type EndData } from "./journal-kinds.js";
4
+ import { type BudgetData, type EndData } from "./journal-kinds.js";
5
5
  import { type MessageOrigin } from "../timeline/index.js";
6
6
  import { type Claim, type EndOfRunTurn, type LoopFactory } from "./loop-contract.js";
7
7
  import { Parked } from "./loop.js";
8
8
  import type { PiRun } from "./adapters/pi.js";
9
9
  import { type HeldSpec } from "./held-run.js";
10
10
  import { type LoopComputer } from "./computer-channel.js";
11
- import { type RunCapOptions, type RunDecisions, type RunTools } from "@parcha/agentrun-kernel/kernel/cap";
11
+ import { type RecentRequest, type RunCapOptions, type RunDecisions, type RunTools } from "@parcha/agentrun-kernel/kernel/cap";
12
12
  import { type PortModels } from "../port-models.js";
13
13
  /** The run's cap's config, as its spec gives it: the kernel runCap's options but its sessions (the loop's own), and
14
14
  * `beside`, what was spent beside the run's sessions on its behalf (Store.learning.spentBeside: its learning runs'
@@ -17,7 +17,8 @@ import { type PortModels } from "../port-models.js";
17
17
  export type RunCapConfig = Omit<RunCapOptions, "sessions"> & {
18
18
  beside?(): Promise<number | null>;
19
19
  };
20
- import { type ClaimMcp } from "./mcp-run.js";
20
+ import type { ClaimMcp } from "./mcp-run.js";
21
+ import { type WorkflowFirst, type WorkflowRevise } from "./workflow-first.js";
21
22
  /** The end of a harness's own call (Claude Code's WebSearch) the gate held and then let run: the host ran nothing of it,
22
23
  * and the harness's next call runs it. */
23
24
  export declare const OWN_TOOL_RELEASED = "Allowed after it waited; the agent's own tool runs it on its next call.";
@@ -64,9 +65,6 @@ export type SpecGate = ((call: ToolCall, options?: {
64
65
  readonly askedAs?: (tool: string) => string;
65
66
  /** What an asked call's card shows beside its input (a learned workflow's MCP calls it would make), if anything. */
66
67
  readonly askedFor?: (tool: string, args: unknown) => Promise<Record<string, unknown> | undefined>;
67
- /** The revision's tool-call budget (definition.max_tool_calls, tool-budget.ts): the calls each conversation may make. A
68
- * call past it is refused before anything else is asked; one the adapter counts no calls for (a CLI's) is not held. */
69
- readonly toolCalls?: number;
70
68
  /** A tool's setting now, by any name a call reaches the gate by (a harness's own, Codex's `web_search`), read again at
71
69
  * each ask: what the session reads (SessionIO.permission) for a tool no call of which reaches the gate before it runs. */
72
70
  readonly permission?: (tool: string) => Promise<"allow" | "ask" | "deny">;
@@ -89,9 +87,6 @@ export interface AdapterRunSpec {
89
87
  /** The gate's answer for a call, before its intent: run it, refuse it, or ask a person (the run parks). A refusal may
90
88
  * carry the words the model reads (`{ deny }`: where the deny was set, a pin's words); a bare "deny" gets generic ones. */
91
89
  readonly gate?: SpecGate;
92
- /** What an asked call costs, for its approval card (main's tool gate options.price): dollars, or "not metered";
93
- * undefined when it has none (the ask says null). */
94
- readonly approvalPrice?: (call: ToolCall) => ApprovalPrice | undefined;
95
90
  /** The run's one cap (the kernel's runCap, built by the loop from the run's own sessions): every paid request of the
96
91
  * run, its model requests, its paid tool calls and its decisions, is admitted and booked through it. An uncapped run
97
92
  * gives capUsd: () => undefined. */
@@ -127,6 +122,14 @@ export interface AdapterRunSpec {
127
122
  readonly stopSettleMs?: number;
128
123
  /** The run's agent: named to the end-of-run step (LoopDeps.endOfRun), which a spec without it cannot be asked. */
129
124
  readonly agentId?: string;
125
+ /** The learned workflow the run starts on, before its agent's first turn (runner/workflow-first.ts workflowFirstOf):
126
+ * run once through the session's own learned_workflow tool (its gate, record, ledger and cap), its answer the run's
127
+ * answer, or its handback the agent's first input. Absent: the agent takes the run from its first turn. */
128
+ readonly workflowFirst?: WorkflowFirst;
129
+ /** The learned workflow that fits the run but that the money rule stopped from running first (workflow-first.ts
130
+ * costLineOf): the loop keeps why on the root (WORKFLOW_FIRST, outcome needs_revision, the two numbers) as the agent
131
+ * takes the run, and the run's end-of-run turn asks for its revision. */
132
+ readonly workflowRevise?: WorkflowRevise;
130
133
  /** The run's end-of-run step, when its spec builds one (over the per-claim resources it holds, its Archil claim among
131
134
  * them): it wins over LoopDeps.endOfRun and is asked where that one is, in the end turn while the claim is held, before
132
135
  * a tool host's beforeRelease and the run's release, its rows in the end's commit. */
@@ -146,8 +149,11 @@ export interface AdapterRunSpec {
146
149
  * workspace (store-reads/journal.ts runTimeline). */
147
150
  readonly cwd?: string;
148
151
  /** The end's patch beside its state: the run's outcome, cost and metrics, read when the end is written and carried in
149
- * its commit. Bounded (CUT_STEP_MS): a reader that stalls gives no patch, and the end is still written. */
152
+ * its commit. Bounded (endPatchMs): a reader that stalls gives no patch, and the end is still written, its cost and
153
+ * metrics unknown (END_PATCH_UNKNOWN). */
150
154
  readonly endPatch?: (end: EndData) => Promise<Pick<EndData, "outcome" | "costUsd" | "metrics">>;
155
+ /** The most the end's patch may take before the end is written without it. Default END_PATCH_MS. */
156
+ readonly endPatchMs?: number;
151
157
  /** Handed the run's own Harness commit once it opens (and after each restart's re-open): what a mark of the run's
152
158
  * commits through, so a commit after the claim is lost is refused by the fence like any other. */
153
159
  readonly harnessReady?: (commit: Harness["commit"]) => void;
@@ -172,6 +178,10 @@ export interface AdapterRunSpec {
172
178
  * the session through the loop's gate, a command row makes them fresh again, and the pass's end lets them go. Absent:
173
179
  * the run grants no MCP tool. */
174
180
  readonly mcp?: ClaimMcp;
181
+ /** The JSON Schema the run's final answer's last json block meets (its revision's definition.output_schema). An answer
182
+ * that misses it is asked again once, in the same session under the same cap (the output contract's retry); absent:
183
+ * the run's answer is never checked here. */
184
+ readonly outputSchema?: unknown;
175
185
  }
176
186
  /** A tool host's lifecycle, as its bindings registered it: run by the adapter loop (AdapterRunSpec.lifecycle). */
177
187
  export interface HostLifecycle {
@@ -288,6 +298,10 @@ export declare function pendingPauseOf(entries: readonly {
288
298
  readonly kind?: string;
289
299
  readonly data?: unknown;
290
300
  }[]): Refusal | undefined;
301
+ /** The session's recent requests as its newest KINDS.capRecent record kept them: each that reads as one (a model, and each
302
+ * figure a finite number of 0 or more); none without a record. One that does not read is left out: a request is then
303
+ * priced from another or uncached, never under its worst. */
304
+ export declare function recentIn(records: readonly SessionRecord[]): RecentRequest[];
291
305
  /** The turns a session's records booked (its runner.turn records), in order. */
292
306
  export declare function turnsOf(records: readonly SessionRecord[]): number[];
293
307
  /** What the request that just answered cost, from the session's records, and the bookings that answer gives (`turns`):