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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (568) hide show
  1. package/CHANGELOG.md +452 -0
  2. package/README.md +311 -142
  3. package/dist/agent-rows.d.ts +1 -1
  4. package/dist/agents-store.d.ts +35 -3
  5. package/dist/agents-store.js +39 -14
  6. package/dist/answer-json.d.ts +34 -1
  7. package/dist/answer-json.js +91 -9
  8. package/dist/api-only.d.ts +1 -1
  9. package/dist/api-only.js +2 -2
  10. package/dist/attach-conformance-cli.d.ts +1 -0
  11. package/dist/attach-conformance-cli.js +18 -0
  12. package/dist/attach-conformance.d.ts +25 -0
  13. package/dist/attach-conformance.js +343 -0
  14. package/dist/browser-cost.d.ts +1 -1
  15. package/dist/browser-cost.js +52 -93
  16. package/dist/browser-live.d.ts +20 -8
  17. package/dist/browser-live.js +50 -27
  18. package/dist/cap.d.ts +0 -407
  19. package/dist/cap.js +4 -1028
  20. package/dist/catalog.d.ts +1 -12
  21. package/dist/catalog.js +4 -34
  22. package/dist/cli.js +13 -4
  23. package/dist/composio-preset.d.ts +53 -0
  24. package/dist/composio-preset.js +221 -0
  25. package/dist/computer-attach.d.ts +125 -0
  26. package/dist/computer-attach.js +330 -0
  27. package/dist/computer-calls.d.ts +60 -0
  28. package/dist/computer-calls.js +209 -0
  29. package/dist/computer-channel.d.ts +57 -0
  30. package/dist/computer-channel.js +115 -0
  31. package/dist/computer-commands.d.ts +1 -1
  32. package/dist/computer-held-routes.d.ts +35 -0
  33. package/dist/computer-held-routes.js +106 -0
  34. package/dist/computer-held.d.ts +48 -0
  35. package/dist/computer-held.js +87 -0
  36. package/dist/computer-keys.d.ts +21 -1
  37. package/dist/computer-keys.js +53 -11
  38. package/dist/computer-live.d.ts +165 -0
  39. package/dist/computer-live.js +655 -0
  40. package/dist/computer-setting.d.ts +15 -2
  41. package/dist/computer-setting.js +20 -4
  42. package/dist/computer-view.d.ts +14 -0
  43. package/dist/computer-view.js +51 -3
  44. package/dist/computer-viewer.d.ts +6 -0
  45. package/dist/computer-viewer.js +311 -0
  46. package/dist/computers.d.ts +37 -8
  47. package/dist/computers.js +62 -14
  48. package/dist/console/assets/index-CjqQirbo.css +1 -0
  49. package/dist/console/assets/index-b6-XY5A9.js +576 -0
  50. package/dist/console/index.html +2 -2
  51. package/dist/console-links.d.ts +2 -0
  52. package/dist/console-links.js +3 -0
  53. package/dist/decisions.js +4 -0
  54. package/dist/faux-computers.d.ts +9 -20
  55. package/dist/faux-computers.js +56 -26
  56. package/dist/github-connection.d.ts +10 -2
  57. package/dist/github-connection.js +65 -2
  58. package/dist/github-faux.js +1 -1
  59. package/dist/graph-view.d.ts +1 -1
  60. package/dist/harness-opencode/adapter.js +7 -3
  61. package/dist/harness-opencode/facts.js +0 -2
  62. package/dist/harness-opencode/host/policy.d.ts +2 -5
  63. package/dist/harness-opencode/host/policy.js +8 -32
  64. package/dist/harness-table.d.ts +0 -2
  65. package/dist/harness-table.js +0 -2
  66. package/dist/harness.d.ts +1 -0
  67. package/dist/harness.js +35 -1
  68. package/dist/host-tools.d.ts +2 -6
  69. package/dist/host-tools.js +7 -10
  70. package/dist/hosted-search.d.ts +5 -6
  71. package/dist/hosted-search.js +2 -28
  72. package/dist/import-sources.d.ts +10 -0
  73. package/dist/import-sources.js +44 -2
  74. package/dist/import.d.ts +3 -3
  75. package/dist/import.js +37 -6
  76. package/dist/key-words.d.ts +3 -2
  77. package/dist/key-words.js +4 -2
  78. package/dist/learn/check.d.ts +10 -2
  79. package/dist/learn/check.js +13 -5
  80. package/dist/learn/commit.d.ts +14 -2
  81. package/dist/learn/commit.js +23 -9
  82. package/dist/learn/compile.d.ts +243 -0
  83. package/dist/learn/compile.js +471 -0
  84. package/dist/learn/folder.d.ts +6 -0
  85. package/dist/learn/folder.js +4 -1
  86. package/dist/learn/general.d.ts +69 -0
  87. package/dist/learn/general.js +75 -0
  88. package/dist/learn/grade.d.ts +5 -1
  89. package/dist/learn/grade.js +29 -7
  90. package/dist/learn/notes.d.ts +8 -0
  91. package/dist/learn/notes.js +18 -0
  92. package/dist/learn/promote.d.ts +253 -0
  93. package/dist/learn/promote.js +428 -0
  94. package/dist/learn/refit.d.ts +39 -0
  95. package/dist/learn/refit.js +236 -0
  96. package/dist/learn/reflect.d.ts +9 -20
  97. package/dist/learn/reflect.js +18 -125
  98. package/dist/learn/replay-calls.d.ts +63 -0
  99. package/dist/learn/replay-calls.js +158 -0
  100. package/dist/learn/skills.d.ts +50 -14
  101. package/dist/learn/skills.js +183 -47
  102. package/dist/learn/workflow-nodes.d.ts +15 -0
  103. package/dist/learn/workflow-nodes.js +44 -0
  104. package/dist/learned-nodes.d.ts +50 -2
  105. package/dist/learned-nodes.js +41 -2
  106. package/dist/learned-workflow.d.ts +43 -3
  107. package/dist/learned-workflow.js +170 -28
  108. package/dist/learning-batch.d.ts +283 -0
  109. package/dist/learning-batch.js +574 -0
  110. package/dist/learning-cost.d.ts +18 -6
  111. package/dist/learning-cost.js +15 -7
  112. package/dist/learning-evals.d.ts +33 -0
  113. package/dist/learning-evals.js +98 -0
  114. package/dist/learning-routes.d.ts +37 -2
  115. package/dist/learning-routes.js +52 -8
  116. package/dist/learning-words.d.ts +13 -0
  117. package/dist/learning-words.js +13 -0
  118. package/dist/learning.d.ts +55 -17
  119. package/dist/learning.js +91 -48
  120. package/dist/live/stream.js +6 -3
  121. package/dist/live/translate.d.ts +4 -3
  122. package/dist/live/translate.js +8 -4
  123. package/dist/live-reach.d.ts +37 -0
  124. package/dist/live-reach.js +62 -0
  125. package/dist/llm.js +0 -3
  126. package/dist/mcp-gateway.d.ts +21 -20
  127. package/dist/mcp-gateway.js +76 -55
  128. package/dist/mcp-oauth.d.ts +62 -7
  129. package/dist/mcp-oauth.js +134 -19
  130. package/dist/mcp-pin-first.d.ts +37 -0
  131. package/dist/mcp-pin-first.js +107 -0
  132. package/dist/mcp-private-hosts.d.ts +4 -4
  133. package/dist/mcp-private-hosts.js +20 -12
  134. package/dist/mcp-probe.d.ts +27 -11
  135. package/dist/mcp-probe.js +60 -42
  136. package/dist/mcp-secret-writes.js +4 -0
  137. package/dist/mcp-servers-store.d.ts +115 -25
  138. package/dist/mcp-servers-store.js +241 -43
  139. package/dist/mcp-sources.d.ts +39 -0
  140. package/dist/mcp-sources.js +74 -0
  141. package/dist/mcp-store.d.ts +21 -4
  142. package/dist/mcp-store.js +33 -8
  143. package/dist/mcp-wire.d.ts +22 -0
  144. package/dist/mcp-wire.js +36 -0
  145. package/dist/mcp.js +3 -3
  146. package/dist/meta-tool-names.d.ts +1 -0
  147. package/dist/meta-tool-names.js +3 -0
  148. package/dist/model-form.d.ts +26 -0
  149. package/dist/model-form.js +80 -0
  150. package/dist/model.d.ts +13 -0
  151. package/dist/model.js +69 -25
  152. package/dist/monid.d.ts +51 -25
  153. package/dist/monid.js +226 -140
  154. package/dist/openapi.js +694 -59
  155. package/dist/page.d.ts +18 -0
  156. package/dist/page.js +48 -20
  157. package/dist/paid-calls.d.ts +26 -29
  158. package/dist/paid-calls.js +46 -102
  159. package/dist/place-offers.d.ts +2 -3
  160. package/dist/place-offers.js +3 -7
  161. package/dist/place.js +1 -2
  162. package/dist/print.d.ts +15 -1
  163. package/dist/print.js +14 -3
  164. package/dist/propose.d.ts +10 -1
  165. package/dist/propose.js +30 -10
  166. package/dist/provider.js +12 -4
  167. package/dist/reflect-range.d.ts +8 -1
  168. package/dist/reflect-range.js +3 -2
  169. package/dist/rows.d.ts +5 -3
  170. package/dist/rows.js +15 -4
  171. package/dist/run-launch.d.ts +27 -2
  172. package/dist/run-launch.js +15 -4
  173. package/dist/run-learning-served.d.ts +13 -2
  174. package/dist/run-manifest.d.ts +5 -0
  175. package/dist/run-manifest.js +20 -0
  176. package/dist/run-reads-over-store.d.ts +1 -1
  177. package/dist/run-repo.d.ts +20 -0
  178. package/dist/run-repo.js +63 -0
  179. package/dist/run-secrets.js +2 -3
  180. package/dist/run-timeline-served.d.ts +1 -1
  181. package/dist/run-timeline-served.js +5 -2
  182. package/dist/run-view.d.ts +19 -8
  183. package/dist/run-view.js +62 -26
  184. package/dist/runnable.d.ts +0 -3
  185. package/dist/runnable.js +37 -29
  186. package/dist/runner/adapter-loop.d.ts +47 -17
  187. package/dist/runner/adapter-loop.js +1427 -303
  188. package/dist/runner/adapter-run-spec.d.ts +23 -9
  189. package/dist/runner/adapter-run-spec.js +162 -56
  190. package/dist/runner/adapters/pi-computer.d.ts +9 -0
  191. package/dist/runner/adapters/pi-computer.js +51 -0
  192. package/dist/runner/adapters/pi.d.ts +25 -11
  193. package/dist/runner/adapters/pi.js +168 -45
  194. package/dist/runner/beside.d.ts +7 -3
  195. package/dist/runner/beside.js +21 -11
  196. package/dist/runner/claim-secrets.d.ts +4 -0
  197. package/dist/runner/claim-secrets.js +6 -1
  198. package/dist/runner/cli-run-spec.d.ts +20 -3
  199. package/dist/runner/cli-run-spec.js +174 -64
  200. package/dist/runner/commands.d.ts +3 -1
  201. package/dist/runner/commands.js +28 -3
  202. package/dist/runner/computer-channel.d.ts +34 -0
  203. package/dist/runner/computer-channel.js +62 -0
  204. package/dist/runner/conformance/harness.d.ts +3 -0
  205. package/dist/runner/conformance/harness.js +224 -17
  206. package/dist/runner/conformance/subject.d.ts +12 -5
  207. package/dist/runner/dispatch.js +3 -0
  208. package/dist/runner/end-of-run.d.ts +23 -12
  209. package/dist/runner/end-of-run.js +41 -16
  210. package/dist/runner/feedback-round.d.ts +52 -0
  211. package/dist/runner/feedback-round.js +79 -0
  212. package/dist/runner/github-app.d.ts +2 -1
  213. package/dist/runner/github-app.js +4 -2
  214. package/dist/runner/harness-loops.js +15 -1
  215. package/dist/runner/held-run.d.ts +65 -0
  216. package/dist/runner/held-run.js +158 -0
  217. package/dist/runner/journal-kinds.d.ts +44 -7
  218. package/dist/runner/journal-kinds.js +29 -0
  219. package/dist/runner/journal-reader.d.ts +5 -4
  220. package/dist/runner/journal-reader.js +12 -10
  221. package/dist/runner/learning-ask.d.ts +7 -1
  222. package/dist/runner/learning-ask.js +21 -6
  223. package/dist/runner/learning-dispatch.d.ts +22 -0
  224. package/dist/runner/learning-dispatch.js +77 -10
  225. package/dist/runner/learning-end.d.ts +69 -13
  226. package/dist/runner/learning-end.js +340 -87
  227. package/dist/runner/learning-factory.d.ts +1 -1
  228. package/dist/runner/learning-factory.js +11 -5
  229. package/dist/runner/learning-loop.d.ts +86 -8
  230. package/dist/runner/learning-loop.js +178 -23
  231. package/dist/runner/learning-seed.d.ts +11 -0
  232. package/dist/runner/learning-seed.js +27 -0
  233. package/dist/runner/live-ticker.js +1 -0
  234. package/dist/runner/loop-contract.d.ts +26 -3
  235. package/dist/runner/loop.d.ts +21 -2
  236. package/dist/runner/loop.js +23 -2
  237. package/dist/runner/main.d.ts +13 -1
  238. package/dist/runner/main.js +27 -5
  239. package/dist/runner/mcp-claim.d.ts +15 -8
  240. package/dist/runner/mcp-claim.js +176 -71
  241. package/dist/runner/mcp-github.js +1 -1
  242. package/dist/runner/mcp-run.d.ts +21 -57
  243. package/dist/runner/mcp-run.js +25 -85
  244. package/dist/runner/meta-tools.d.ts +37 -0
  245. package/dist/runner/meta-tools.js +268 -0
  246. package/dist/runner/metrics.d.ts +11 -2
  247. package/dist/runner/metrics.js +26 -5
  248. package/dist/runner/model-route.js +12 -3
  249. package/dist/runner/monid-run.d.ts +16 -0
  250. package/dist/runner/monid-run.js +96 -0
  251. package/dist/runner/pr-checkout.d.ts +1 -0
  252. package/dist/runner/pr-checkout.js +1 -1
  253. package/dist/runner/promotion.d.ts +80 -0
  254. package/dist/runner/promotion.js +562 -0
  255. package/dist/runner/reflect-hook.d.ts +46 -13
  256. package/dist/runner/reflect-hook.js +149 -48
  257. package/dist/runner/runner.d.ts +26 -0
  258. package/dist/runner/runner.js +208 -17
  259. package/dist/runner/scratch-sweep.d.ts +13 -0
  260. package/dist/runner/scratch-sweep.js +62 -0
  261. package/dist/runner/sessions.d.ts +9 -4
  262. package/dist/runner/sessions.js +5 -1
  263. package/dist/runner/step-guard.d.ts +62 -0
  264. package/dist/runner/step-guard.js +93 -0
  265. package/dist/runner/store-port.d.ts +4 -2
  266. package/dist/runner/store-secrets.js +4 -3
  267. package/dist/runner/subagent.d.ts +0 -3
  268. package/dist/runner/subagent.js +10 -13
  269. package/dist/runner/workflow-first.d.ts +216 -0
  270. package/dist/runner/workflow-first.js +303 -0
  271. package/dist/runner/workflow-host.d.ts +6 -1
  272. package/dist/runner/workflow-host.js +1 -1
  273. package/dist/runner/workflow-loop.d.ts +1 -1
  274. package/dist/runner/workflow-loop.js +17 -10
  275. package/dist/runner/workflow-spec.d.ts +15 -2
  276. package/dist/runner/workflow-spec.js +63 -23
  277. package/dist/runs-over-store.d.ts +17 -3
  278. package/dist/runs-over-store.js +59 -20
  279. package/dist/seal-key.js +3 -3
  280. package/dist/sealed-settings-store.d.ts +5 -2
  281. package/dist/sealed-settings-store.js +10 -4
  282. package/dist/secret-writes.d.ts +5 -4
  283. package/dist/secret-writes.js +5 -4
  284. package/dist/server-secrets-store.d.ts +4 -3
  285. package/dist/server-secrets-store.js +15 -9
  286. package/dist/server-secrets.js +3 -2
  287. package/dist/server.d.ts +119 -18
  288. package/dist/server.js +841 -202
  289. package/dist/settings-wake.d.ts +23 -0
  290. package/dist/settings-wake.js +65 -0
  291. package/dist/standard-webhooks.d.ts +4 -1
  292. package/dist/standard-webhooks.js +8 -4
  293. package/dist/store/agent-body.d.ts +14 -3
  294. package/dist/store/agent-body.js +14 -10
  295. package/dist/store/command-wake.d.ts +13 -0
  296. package/dist/store/command-wake.js +37 -0
  297. package/dist/store/dialect.d.ts +6 -0
  298. package/dist/store/dialect.js +5 -0
  299. package/dist/store/index.d.ts +1 -1
  300. package/dist/store/journal/storage.d.ts +3 -2
  301. package/dist/store/journal/storage.js +13 -5
  302. package/dist/store/postgres/connection.js +3 -1
  303. package/dist/store/postgres/dialect.js +4 -0
  304. package/dist/store/postgres/migrations/0005_learning_rounds.sql +14 -0
  305. package/dist/store/postgres/migrations/0006_run_changes_channel_attempts.sql +57 -0
  306. package/dist/store/postgres/migrations/0007_viewer_host.sql +11 -0
  307. package/dist/store/postgres/migrations/0008_paired_computers.sql +30 -0
  308. package/dist/store/postgres/migrations/0009_commands_answer.sql +10 -0
  309. package/dist/store/postgres/migrations/0010_imported_templates.sql +18 -0
  310. package/dist/store/postgres/migrations/0011_revision_mcp_pin.sql +13 -0
  311. package/dist/store/schema.d.ts +10 -1
  312. package/dist/store/schema.js +104 -15
  313. package/dist/store/sqlite/connection.d.ts +2 -2
  314. package/dist/store/sqlite/connection.js +2 -2
  315. package/dist/store/sqlite/run-patch.d.ts +7 -5
  316. package/dist/store/sqlite/run-patch.js +45 -18
  317. package/dist/store/sqlite/store.js +331 -72
  318. package/dist/store/store.d.ts +312 -21
  319. package/dist/store/store.js +12 -1
  320. package/dist/store-reads/cap.d.ts +1 -1
  321. package/dist/store-reads/cap.js +8 -1
  322. package/dist/store-reads/decisions.d.ts +2 -2
  323. package/dist/store-reads/decisions.js +1 -1
  324. package/dist/store-reads/import-summary.d.ts +1 -1
  325. package/dist/store-reads/journal.d.ts +30 -5
  326. package/dist/store-reads/journal.js +128 -56
  327. package/dist/store-reads/learning.d.ts +114 -12
  328. package/dist/store-reads/learning.js +238 -48
  329. package/dist/store-reads/loop.d.ts +61 -0
  330. package/dist/store-reads/loop.js +111 -0
  331. package/dist/store-reads/runs.d.ts +1 -1
  332. package/dist/store-reads/workflow.d.ts +1 -1
  333. package/dist/store-view.d.ts +6 -0
  334. package/dist/store-view.js +59 -26
  335. package/dist/template-eval.d.ts +18 -9
  336. package/dist/template-eval.js +95 -68
  337. package/dist/template-github-permissions.d.ts +24 -10
  338. package/dist/template-github-permissions.js +36 -15
  339. package/dist/template-import.d.ts +31 -0
  340. package/dist/template-import.js +121 -0
  341. package/dist/template-source.d.ts +51 -0
  342. package/dist/template-source.js +371 -0
  343. package/dist/templates.d.ts +218 -46
  344. package/dist/templates.js +493 -181
  345. package/dist/timeline/computer.d.ts +48 -0
  346. package/dist/timeline/computer.js +169 -0
  347. package/dist/timeline/index.d.ts +4 -3
  348. package/dist/timeline/index.js +4 -3
  349. package/dist/timeline/labels.d.ts +6 -2
  350. package/dist/timeline/labels.js +93 -2
  351. package/dist/timeline/origin.d.ts +19 -5
  352. package/dist/timeline/origin.js +11 -4
  353. package/dist/timeline/timeline.d.ts +22 -1
  354. package/dist/timeline/timeline.js +34 -18
  355. package/dist/timeline/util.d.ts +4 -0
  356. package/dist/timeline/util.js +14 -0
  357. package/dist/tool-gate.d.ts +84 -50
  358. package/dist/tool-gate.js +179 -101
  359. package/dist/tool-keys.d.ts +4 -1
  360. package/dist/tool-keys.js +8 -3
  361. package/dist/tool-list.d.ts +26 -0
  362. package/dist/tool-list.js +43 -0
  363. package/dist/tool-names.d.ts +71 -0
  364. package/dist/tool-names.js +99 -0
  365. package/dist/tool-plane.d.ts +33 -27
  366. package/dist/tool-plane.js +72 -39
  367. package/dist/tools.d.ts +32 -7
  368. package/dist/tools.js +37 -24
  369. package/dist/trigger-adapter.d.ts +4 -0
  370. package/dist/trigger-secrets-shown.d.ts +2 -2
  371. package/dist/trigger-secrets-shown.js +1 -1
  372. package/dist/trigger-signatures.d.ts +25 -6
  373. package/dist/trigger-signatures.js +41 -7
  374. package/dist/trigger-targets.d.ts +2 -0
  375. package/dist/trigger-targets.js +1 -0
  376. package/dist/trigger-webhook.js +5 -2
  377. package/dist/triggers.d.ts +7 -3
  378. package/dist/triggers.js +35 -5
  379. package/dist/turns.js +16 -1
  380. package/dist/validate.d.ts +15 -7
  381. package/dist/validate.js +102 -45
  382. package/dist/web-fetch.d.ts +2 -8
  383. package/dist/web-fetch.js +2 -22
  384. package/dist/web-search.d.ts +10 -5
  385. package/dist/web-search.js +7 -6
  386. package/dist/webhooks.d.ts +145 -102
  387. package/dist/webhooks.js +559 -322
  388. package/dist/workflow/decisions.d.ts +1 -1
  389. package/dist/workflow/node-runner.d.ts +2 -1
  390. package/dist/workflow/node.d.ts +2 -1
  391. package/dist/workflow/node.js +3 -1
  392. package/dist/workflow/pi-versions.d.ts +23 -0
  393. package/dist/workflow/pi-versions.js +57 -0
  394. package/dist/workflow/record-tool.d.ts +2 -1
  395. package/dist/workflow/store.d.ts +1 -1
  396. package/dist/workflow/task.js +3 -2
  397. package/dist/workflow-run.d.ts +1 -1
  398. package/dist/workspace/attached-computers.d.ts +41 -0
  399. package/dist/workspace/attached-computers.js +114 -0
  400. package/dist/workspace/computer-deps.d.ts +19 -9
  401. package/dist/workspace/computer-deps.js +24 -9
  402. package/dist/workspace/computer-for-claim.d.ts +23 -8
  403. package/dist/workspace/computer-for-claim.js +92 -33
  404. package/dist/workspace/computer-hold.d.ts +11 -27
  405. package/dist/workspace/computer-hold.js +41 -55
  406. package/dist/workspace/computer-ledger.d.ts +3 -1
  407. package/dist/workspace/computer-ledger.js +4 -0
  408. package/dist/workspace/computer-mcp.d.ts +25 -0
  409. package/dist/workspace/computer-mcp.js +41 -0
  410. package/dist/workspace/computer-ports.d.ts +4 -13
  411. package/dist/workspace/computer-ports.js +4 -107
  412. package/dist/workspace/computer-script.d.ts +53 -0
  413. package/dist/workspace/computer-script.js +172 -0
  414. package/dist/workspace/executors.d.ts +1 -1
  415. package/dist/workspace/index.d.ts +4 -2
  416. package/dist/workspace/index.js +3 -1
  417. package/dist/workspace/kind-skills/desktop/SKILL.md +132 -84
  418. package/dist/workspace/kind-skills/phone/SKILL.md +104 -85
  419. package/dist/workspace/local.js +2 -2
  420. package/dist/workspace/resolve-computer.d.ts +24 -1
  421. package/dist/workspace/resolve-computer.js +40 -16
  422. package/dist/workspace/run-tools.d.ts +56 -21
  423. package/dist/workspace/run-tools.js +55 -34
  424. package/dist/wrap-up.d.ts +21 -0
  425. package/dist/wrap-up.js +21 -0
  426. package/launcher/agentrun-serve +4 -2
  427. package/package.json +19 -16
  428. package/templates/README.md +111 -45
  429. package/templates/code-review/agent.md +30 -14
  430. package/templates/code-review/evals/clean-refactor/case.yaml +2 -1
  431. package/templates/code-review/evals/clean-refactor/graders/head-sha.md +6 -0
  432. package/templates/code-review/evals/injection/case.yaml +2 -1
  433. package/templates/code-review/evals/injection/graders/head-sha.md +6 -0
  434. package/templates/code-review/evals/mentions-defused/case.yaml +2 -2
  435. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -23
  436. package/templates/code-review/evals/mentions-defused/graders/head-sha.md +6 -0
  437. package/templates/code-review/evals/never-flag/case.yaml +2 -1
  438. package/templates/code-review/evals/never-flag/graders/head-sha.md +6 -0
  439. package/templates/code-review/evals/null-name/case.yaml +2 -1
  440. package/templates/code-review/evals/null-name/graders/head-sha.md +6 -0
  441. package/templates/code-review/evals/off-by-one/case.yaml +2 -1
  442. package/templates/code-review/evals/off-by-one/graders/head-sha.md +6 -0
  443. package/templates/code-review/evals/other-repo/case.yaml +16 -0
  444. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +130 -0
  445. package/templates/code-review/evals/other-repo/graders/head-sha.md +6 -0
  446. package/templates/code-review/evals/other-repo/graders/no-canary.md +6 -0
  447. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +8 -0
  448. package/templates/code-review/evals/other-repo/graders/refused-not-quoted.md +18 -0
  449. package/templates/code-review/evals/other-repo/prompt.md +10 -0
  450. package/templates/code-review/evals/re-review/case.yaml +2 -1
  451. package/templates/code-review/evals/re-review/graders/head-sha.md +6 -0
  452. package/templates/code-review/evals/re-review-open/case.yaml +2 -1
  453. package/templates/code-review/evals/re-review-open/graders/head-sha.md +6 -0
  454. package/templates/code-review/evals/repo-rule/case.yaml +2 -1
  455. package/templates/code-review/evals/repo-rule/graders/head-sha.md +6 -0
  456. package/templates/code-review/evals/two-defects/case.yaml +2 -1
  457. package/templates/code-review/evals/two-defects/graders/head-sha.md +6 -0
  458. package/templates/code-review/rules/CODEREVIEW.md +1 -1
  459. package/templates/code-review/skills/review/DEEP.md +3 -2
  460. package/templates/code-review/skills/review/REVIEWER.md +3 -2
  461. package/templates/code-review/skills/review/SKILL.md +4 -3
  462. package/templates/code-review/{findings.schema.json → skills/review/findings.schema.json} +1 -0
  463. package/templates/inbound-lead/agent.md +26 -16
  464. package/templates/inbound-lead/evals/injection-in-form/graders/no-exfil.md +16 -0
  465. package/templates/inbound-lead/evals/injection-in-form/prompt.md +2 -2
  466. package/templates/inbound-lead/evals/write-back/case.yaml +2 -6
  467. package/templates/inbound-lead/evals/write-back/fixtures/fake-hubspot.json +34 -225
  468. package/templates/inbound-lead/evals/write-back/graders/note-and-score.md +10 -14
  469. package/templates/inbound-lead/evals/write-back/graders/writes-once.md +7 -0
  470. package/templates/inbound-lead/evals/write-back/prompt.md +1 -1
  471. package/templates/inbound-lead/evals/write-back-wrong-record/case.yaml +3 -7
  472. package/templates/inbound-lead/evals/write-back-wrong-record/fixtures/fake-hubspot.json +34 -225
  473. package/templates/inbound-lead/evals/write-back-wrong-record/graders/form-id.md +17 -0
  474. package/templates/inbound-lead/evals/write-back-wrong-record/graders/no-write.md +3 -3
  475. package/templates/inbound-lead/evals/write-back-wrong-record/prompt.md +2 -2
  476. package/templates/inbound-lead/skills/lead/SKILL.md +23 -27
  477. package/templates/kyb/agent.md +15 -5
  478. package/templates/kyb/evals/adverse-media/prompt.md +2 -7
  479. package/templates/kyb/evals/canada-active-filed/prompt.md +2 -6
  480. package/templates/kyb/evals/clean-public-company/prompt.md +2 -6
  481. package/templates/kyb/evals/injection-in-page/prompt.md +3 -7
  482. package/templates/kyb/evals/name-collision/prompt.md +2 -6
  483. package/templates/kyb/evals/no-invention/prompt.md +2 -6
  484. package/templates/kyb/evals/opensanctions-on/prompt.md +2 -6
  485. package/templates/kyb/evals/sanctioned-entity/prompt.md +2 -6
  486. package/templates/kyb/kyb.schema.json +8 -7
  487. package/templates/kyb/skills/kyb/SKILL.md +9 -6
  488. package/templates/market-monitor/agent.md +19 -12
  489. package/templates/market-monitor/evals/post-happens/case.yaml +4 -4
  490. package/templates/market-monitor/evals/post-happens/fixtures/slack-mcp.json +13 -9
  491. package/templates/market-monitor/evals/post-happens/graders/post-is-digest.md +1 -1
  492. package/templates/market-monitor/evals/post-happens/graders/posted-once.md +3 -3
  493. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  494. package/templates/release-notes/agent.md +32 -10
  495. package/templates/release-notes/evals/draft-not-publish/case.yaml +4 -3
  496. package/templates/release-notes/evals/draft-not-publish/fixtures/github-mcp.json +29 -51
  497. package/templates/release-notes/evals/every-pr-accounted/case.yaml +2 -1
  498. package/templates/release-notes/evals/issue-write-refused/case.yaml +4 -3
  499. package/templates/release-notes/evals/issue-write-refused/fixtures/github-mcp.json +29 -51
  500. package/templates/release-notes/evals/late-arrival/case.yaml +6 -5
  501. package/templates/release-notes/evals/late-arrival/fixtures/github-mcp.json +29 -51
  502. package/templates/release-notes/evals/learned-style/case.yaml +2 -1
  503. package/templates/release-notes/evals/no-pr-numbers-on-top/case.yaml +2 -1
  504. package/templates/release-notes/evals/other-repo/case.yaml +24 -0
  505. package/templates/release-notes/evals/other-repo/fixtures/github-mcp.json +907 -0
  506. package/templates/release-notes/evals/other-repo/graders/no-canary.md +7 -0
  507. package/templates/release-notes/evals/other-repo/graders/no-other-repo.md +8 -0
  508. package/templates/release-notes/evals/other-repo/graders/refused-not-quoted.md +18 -0
  509. package/templates/release-notes/evals/other-repo/prompt.md +32 -0
  510. package/templates/release-notes/evals/upgrade-line/case.yaml +2 -1
  511. package/templates/release-notes/evals/user-facing-only/case.yaml +2 -1
  512. package/templates/release-notes/notes.schema.json +1 -1
  513. package/templates/release-notes/skills/release-notes/SKILL.md +26 -17
  514. package/dist/console/assets/index-BI4Byidu.js +0 -550
  515. package/dist/console/assets/index-C19gUF2n.css +0 -1
  516. package/dist/run-db.d.ts +0 -53
  517. package/dist/run-db.js +0 -116
  518. package/dist/tool-blurbs.d.ts +0 -4
  519. package/dist/tool-blurbs.js +0 -28
  520. package/dist/tool-budget.d.ts +0 -26
  521. package/dist/tool-budget.js +0 -56
  522. package/dist/workflow/readers.d.ts +0 -36
  523. package/dist/workflow/readers.js +0 -145
  524. package/dist/workflow/wal.d.ts +0 -11
  525. package/dist/workflow/wal.js +0 -106
  526. package/templates/code-review/evals/clean-refactor/graders/schema.md +0 -5
  527. package/templates/code-review/evals/injection/graders/schema.md +0 -5
  528. package/templates/code-review/evals/mentions-defused/graders/schema.md +0 -5
  529. package/templates/code-review/evals/never-flag/graders/schema.md +0 -5
  530. package/templates/code-review/evals/null-name/graders/schema.md +0 -5
  531. package/templates/code-review/evals/off-by-one/graders/schema.md +0 -5
  532. package/templates/code-review/evals/re-review/graders/schema.md +0 -5
  533. package/templates/code-review/evals/re-review-open/graders/schema.md +0 -5
  534. package/templates/code-review/evals/repo-rule/graders/schema.md +0 -5
  535. package/templates/code-review/evals/two-defects/graders/schema.md +0 -5
  536. package/templates/inbound-lead/evals/clear-disqualifier/graders/schema.md +0 -5
  537. package/templates/inbound-lead/evals/injection-in-form/graders/schema.md +0 -5
  538. package/templates/inbound-lead/evals/learned-correction/graders/schema.md +0 -5
  539. package/templates/inbound-lead/evals/strong-fit/graders/schema.md +0 -5
  540. package/templates/inbound-lead/evals/thin-data/graders/schema.md +0 -5
  541. package/templates/inbound-lead/evals/write-back/graders/schema.md +0 -5
  542. package/templates/inbound-lead/evals/write-back/graders/writes-twice.md +0 -7
  543. package/templates/inbound-lead/evals/write-back-wrong-record/graders/proves-record.md +0 -18
  544. package/templates/inbound-lead/evals/write-back-wrong-record/graders/schema.md +0 -5
  545. package/templates/kyb/evals/adverse-media/graders/schema.md +0 -5
  546. package/templates/kyb/evals/canada-active-filed/graders/schema.md +0 -5
  547. package/templates/kyb/evals/clean-public-company/graders/schema.md +0 -5
  548. package/templates/kyb/evals/injection-in-page/graders/schema.md +0 -5
  549. package/templates/kyb/evals/name-collision/graders/schema.md +0 -5
  550. package/templates/kyb/evals/no-invention/graders/schema.md +0 -5
  551. package/templates/kyb/evals/opensanctions-on/graders/schema.md +0 -5
  552. package/templates/kyb/evals/sanctioned-entity/graders/schema.md +0 -5
  553. package/templates/market-monitor/evals/blocked-source/graders/schema.md +0 -5
  554. package/templates/market-monitor/evals/every-competitor-named/graders/schema.md +0 -5
  555. package/templates/market-monitor/evals/learned-preference/graders/schema.md +0 -5
  556. package/templates/market-monitor/evals/no-repeats/graders/schema.md +0 -5
  557. package/templates/market-monitor/evals/nothing-changed/graders/schema.md +0 -5
  558. package/templates/market-monitor/evals/post-happens/graders/schema.md +0 -5
  559. package/templates/market-monitor/evals/pricing-change/graders/schema.md +0 -5
  560. package/templates/market-monitor/evals/pricing-moved/graders/schema.md +0 -5
  561. package/templates/release-notes/evals/draft-not-publish/graders/schema.md +0 -5
  562. package/templates/release-notes/evals/every-pr-accounted/graders/schema.md +0 -5
  563. package/templates/release-notes/evals/issue-write-refused/graders/schema.md +0 -5
  564. package/templates/release-notes/evals/late-arrival/graders/schema.md +0 -5
  565. package/templates/release-notes/evals/learned-style/graders/schema.md +0 -5
  566. package/templates/release-notes/evals/no-pr-numbers-on-top/graders/schema.md +0 -5
  567. package/templates/release-notes/evals/upgrade-line/graders/schema.md +0 -5
  568. package/templates/release-notes/evals/user-facing-only/graders/schema.md +0 -5
@@ -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,23 +62,24 @@ 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). */
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";
73
74
  note?: string;
74
75
  answered_at: string;
75
76
  args_shown?: string;
76
- by?: "message";
77
+ by?: "message" | "setting";
77
78
  superseded?: {
78
79
  decision: string;
79
80
  answered_at: string;
80
81
  note?: string;
81
- by?: "message";
82
+ by?: "message" | "setting";
82
83
  };
83
84
  ended?: true;
84
85
  };
@@ -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" } : {}), ...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,21 +569,31 @@ 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);
570
577
  return note ? `AgentRun: You declined ${tool}: ${note}` : `AgentRun: You declined ${tool}.`;
571
578
  }
572
- return `AgentRun: ${tool} ran once you allowed it${failed ? ", and failed" : "; its result went to the agent"}`;
579
+ const ran = answer.by === "setting" ? "ran, as its setting allows it" : "ran once you allowed it";
580
+ return `AgentRun: ${tool} ${ran}${failed ? ", and failed" : "; its result went to the agent"}`;
573
581
  }
574
582
  /** What a person reads when they open the outcome row: the outcome, then the call's result (`rest`), or the refusal's words.
575
583
  * An empty result says so: "Its result: (no output)", never "Its result:" and nothing. */
576
584
  export function outcomeShows(tool, answer, rest, failed) {
577
585
  if (answer.decision === "deny")
578
- return `${answer.by === "message" ? `Your message declined ${tool}.` : `You declined ${tool}.`}${rest.trim() ? `\n${rest.trim()}` : ""}`;
579
- const head = `${tool} ran once you allowed it${failed ? ", and failed" : ""}.`;
586
+ return `${answer.by === "setting" ? `${deniedSince(tool, answer)}.` : answer.by === "message" ? `Your message declined ${tool}.` : `You declined ${tool}.`}${rest.trim() ? `\n${rest.trim()}` : ""}`;
587
+ const head = `${tool} ${answer.by === "setting" ? "ran, as its setting allows it" : "ran once you allowed it"}${failed ? ", and failed" : ""}.`;
580
588
  return rest.trim() ? `${head} Its result:\n${rest}` : `${head} Its result: (no output)`;
581
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");
582
597
  /** A call's own rows (its call's, its result's) before its outcome shows: what came of the approval so far. */
583
598
  function callSays(answer) {
584
599
  if (!answer)
@@ -589,12 +604,19 @@ function callSays(answer) {
589
604
  return answer.ended ? ENDED_WHILE_WAITING : STOPPED_WHILE_WAITING;
590
605
  return "Allowed: it runs now";
591
606
  }
607
+ /** A row without the `refused` mark: it says a call was refused before it ran, so only that call's own tool_result row has it;
608
+ * the approval, message and outcome rows made from a result keep their own status. */
609
+ const unrefused = (row) => {
610
+ const { refused: _refused, ...rest } = row;
611
+ return rest;
612
+ };
592
613
  /** A synthesized row's id: the approval's own, so a pass over rows this function gave drops and remakes it. */
593
614
  const approvalRowId = (callId) => `approval:${callId}`;
594
615
  /** The rows of a run whose calls waited for approval, as the runner writes it (store-view.ts): the gate's ask
595
616
  * (agentrun.ask, `asks`) and the person's answer (agentrun.answer, `answers`) are journal entries, and an allowed call runs
596
- * 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
597
- * 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
598
620
  * outcome shows below, and before that what came of the approval so far. Arguments and notes go through `redact`, the
599
621
  * run's redactor, before any cut. The rows this function makes are dropped first, so a pass over its own output gives the
600
622
  * same rows. */
@@ -621,30 +643,44 @@ export function withApprovalRows(rows, asks, answers, redact) {
621
643
  const answer = answers[approval.id];
622
644
  const result = given.find((other) => other.kind === "tool_result" && other.tool_use_id === approval.call_id);
623
645
  // The outcome shows once there is one: a deny's at once, an allow's when its call's result is in.
624
- const outcome = answer?.decision === "deny" || (answer?.decision === "allow" && result !== undefined);
625
- const own = { ...row, summary: outcome ? HELD : callSays(answer), tool_status: null };
626
- 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)
627
660
  return [own];
628
661
  const args = shownArgs(approval, redact);
629
- // A served row keeps the place it was first served at (rows.ts). The call's result comes in after the answer (the park
630
- // writes none), so the approval and outcome rows take a new id once it is there: served anew below the result, the
631
- // 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.
632
665
  const at = result ? `${approvalRowId(approval.call_id)}:after` : approvalRowId(approval.call_id);
633
- 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" : "Asked your approval";
634
- const asked = { ...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 };
635
- if (!outcome)
636
- 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;
637
673
  const failed = answer.decision === "allow" && result?.tool_status === "failed";
638
674
  // The result's words: a tool_result row keeps them as its preview (the renderer's, redacted and cut), its text empty.
639
- const told = { ...(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 };
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 };
640
676
  // A person's message that declined the call (runs-over-store.ts message: a deny carrying their words) is theirs as any
641
677
  // message is: its own row, between the approval and what came of it, as main's declineBy kept it.
642
678
  if (answer.decision === "deny" && answer.by === "message" && answer.note) {
643
679
  const words = redact(answer.note);
644
- const { origin: _origin, ...base } = result ?? row;
680
+ const { origin: _origin, ...base } = unrefused(result ?? row);
645
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 };
646
- return [own, asked, theirs, told];
682
+ return [...placed, theirs, told];
647
683
  }
648
- return [own, asked, told];
684
+ return [...placed, told];
649
685
  });
650
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,17 +1,27 @@
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
- import { type RunComputerHold } from "./computer-journal.js";
10
- import { type RunCapOptions, type RunDecisions, type RunTools } from "@parcha/agentrun-kernel/kernel/cap";
9
+ import { type HeldSpec } from "./held-run.js";
10
+ import { type LoopComputer } from "./computer-channel.js";
11
+ import { type RecentRequest, type RunCapOptions, type RunDecisions, type RunTools } from "@parcha/agentrun-kernel/kernel/cap";
11
12
  import { type PortModels } from "../port-models.js";
12
- /** The run's cap as its spec gives it: the kernel runCap's options but its sessions, which the loop's are. */
13
- export type RunCapConfig = Omit<RunCapOptions, "sessions">;
14
- import { type ClaimMcp } from "./mcp-run.js";
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
+ * `beside`, what was spent beside the run's sessions on its behalf (Store.learning.spentBeside: its learning runs'
15
+ * grades), which every gate of the run reads with its sessions' spend (runBooking's sessions.beside, overCap, the
16
+ * wrap-ups). None: nothing is. */
17
+ export type RunCapConfig = Omit<RunCapOptions, "sessions"> & {
18
+ beside?(): Promise<number | null>;
19
+ };
20
+ import type { ClaimMcp } from "./mcp-run.js";
21
+ import { type WorkflowFirst, type WorkflowRevise } from "./workflow-first.js";
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,
23
+ * and the harness's next call runs it. */
24
+ export declare const OWN_TOOL_RELEASED = "Allowed after it waited; the agent's own tool runs it on its next call.";
15
25
  /** A pause or resume row on an agentic run, refused in main's words (runs.ts pause): only a workflow run pauses. */
16
26
  export declare const AGENTIC_PAUSE_REFUSED = "Only a workflow run pauses here: an agentic run's turn is stopped with POST /runs/{id}/stop.";
17
27
  /** What a raise meets, as the kernel cap's checkRaise reads it (run-adapters/src/kernel/cap/park.ts): the run's cap, the
@@ -55,9 +65,9 @@ export type SpecGate = ((call: ToolCall, options?: {
55
65
  readonly askedAs?: (tool: string) => string;
56
66
  /** What an asked call's card shows beside its input (a learned workflow's MCP calls it would make), if anything. */
57
67
  readonly askedFor?: (tool: string, args: unknown) => Promise<Record<string, unknown> | undefined>;
58
- /** The revision's tool-call budget (definition.max_tool_calls, tool-budget.ts): the calls each conversation may make. A
59
- * call past it is refused before anything else is asked; one the adapter counts no calls for (a CLI's) is not held. */
60
- readonly toolCalls?: number;
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
69
+ * each ask: what the session reads (SessionIO.permission) for a tool no call of which reaches the gate before it runs. */
70
+ readonly permission?: (tool: string) => Promise<"allow" | "ask" | "deny">;
61
71
  };
62
72
  /** What one claimed run's adapter loop runs. */
63
73
  export interface AdapterRunSpec {
@@ -77,9 +87,6 @@ export interface AdapterRunSpec {
77
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
78
88
  * carry the words the model reads (`{ deny }`: where the deny was set, a pin's words); a bare "deny" gets generic ones. */
79
89
  readonly gate?: SpecGate;
80
- /** What an asked call costs, for its approval card (main's tool gate options.price): dollars, or "not metered";
81
- * undefined when it has none (the ask says null). */
82
- readonly approvalPrice?: (call: ToolCall) => ApprovalPrice | undefined;
83
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
84
91
  * run, its model requests, its paid tool calls and its decisions, is admitted and booked through it. An uncapped run
85
92
  * gives capUsd: () => undefined. */
@@ -115,6 +122,14 @@ export interface AdapterRunSpec {
115
122
  readonly stopSettleMs?: number;
116
123
  /** The run's agent: named to the end-of-run step (LoopDeps.endOfRun), which a spec without it cannot be asked. */
117
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;
118
133
  /** The run's end-of-run step, when its spec builds one (over the per-claim resources it holds, its Archil claim among
119
134
  * them): it wins over LoopDeps.endOfRun and is asked where that one is, in the end turn while the claim is held, before
120
135
  * a tool host's beforeRelease and the run's release, its rows in the end's commit. */
@@ -134,15 +149,22 @@ export interface AdapterRunSpec {
134
149
  * workspace (store-reads/journal.ts runTimeline). */
135
150
  readonly cwd?: string;
136
151
  /** The end's patch beside its state: the run's outcome, cost and metrics, read when the end is written and carried in
137
- * 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). */
138
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;
139
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
140
158
  * commits through, so a commit after the claim is lost is refused by the fence like any other. */
141
159
  readonly harnessReady?: (commit: Harness["commit"]) => void;
142
- /** The run's desktop or phone and the person's hold on it (workspace/computer-hold.ts): the loop commits the hold's
143
- * changes to the run's journal, which the server reads (computer-routes.ts), and applies the person's take-over and
144
- * hand-back rows to it (runner/computer-journal.ts). */
145
- readonly computer?: RunComputerHold;
160
+ /** The run's computer when it speaks the protocol (a sandbox, a desktop or a phone): the loop answers the computer call
161
+ * channel's rows on it (runner/computer-channel.ts). On a desktop or a phone, with the person's hold on it
162
+ * (workspace/computer-hold.ts): the loop commits the hold's changes to the run's journal, which the server reads
163
+ * (computer-routes.ts), and applies the person's take-over and hand-back rows to it (runner/computer-journal.ts). */
164
+ readonly computer?: LoopComputer;
165
+ /** The run's computer held for its owner (a run started with `hold: true`, computer-held.ts): the agent's first input
166
+ * waits for the owner's start, and the run's end waits for the owner's release (runner/held-run.ts). */
167
+ readonly held?: HeldSpec;
146
168
  /** Lets this spec's resources go once the loop writes nothing more through them: called once, after its Session and
147
169
  * Harness are closed, when its pass ends (a restart's included) and at the run's end. Never throws out: a failure is
148
170
  * logged, and the end stands. */
@@ -156,6 +178,10 @@ export interface AdapterRunSpec {
156
178
  * the session through the loop's gate, a command row makes them fresh again, and the pass's end lets them go. Absent:
157
179
  * the run grants no MCP tool. */
158
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;
159
185
  }
160
186
  /** A tool host's lifecycle, as its bindings registered it: run by the adapter loop (AdapterRunSpec.lifecycle). */
161
187
  export interface HostLifecycle {
@@ -272,6 +298,10 @@ export declare function pendingPauseOf(entries: readonly {
272
298
  readonly kind?: string;
273
299
  readonly data?: unknown;
274
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[];
275
305
  /** The turns a session's records booked (its runner.turn records), in order. */
276
306
  export declare function turnsOf(records: readonly SessionRecord[]): number[];
277
307
  /** What the request that just answered cost, from the session's records, and the bookings that answer gives (`turns`):