@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.35

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 (466) hide show
  1. package/CHANGELOG.md +368 -0
  2. package/README.md +341 -208
  3. package/dist/adapters.d.ts +3 -4
  4. package/dist/adapters.js +18 -15
  5. package/dist/agent-rows.d.ts +99 -0
  6. package/dist/agent-rows.js +1 -0
  7. package/dist/agents-store.d.ts +6 -2
  8. package/dist/agents-store.js +75 -25
  9. package/dist/agents.d.ts +9 -125
  10. package/dist/agents.js +15 -305
  11. package/dist/answer-json.d.ts +23 -0
  12. package/dist/answer-json.js +58 -0
  13. package/dist/api-only.d.ts +1 -1
  14. package/dist/api-only.js +2 -2
  15. package/dist/archil-settings.d.ts +11 -1
  16. package/dist/archil-settings.js +10 -0
  17. package/dist/bash-read-only.d.ts +35 -0
  18. package/dist/bash-read-only.js +778 -0
  19. package/dist/box-settings.d.ts +3 -23
  20. package/dist/box-settings.js +7 -51
  21. package/dist/boxes.d.ts +17 -0
  22. package/dist/boxes.js +27 -20
  23. package/dist/browser-commands.d.ts +5 -2
  24. package/dist/browser-commands.js +4 -4
  25. package/dist/browser-computer.d.ts +5 -0
  26. package/dist/browser-computer.js +21 -0
  27. package/dist/browser-cost.d.ts +9 -6
  28. package/dist/browser-cost.js +95 -51
  29. package/dist/browser-live.d.ts +7 -20
  30. package/dist/browser-live.js +15 -93
  31. package/dist/browser-person.d.ts +18 -51
  32. package/dist/browser-person.js +94 -277
  33. package/dist/budget.d.ts +0 -5
  34. package/dist/budget.js +0 -5
  35. package/dist/cap.d.ts +14 -8
  36. package/dist/cap.js +19 -9
  37. package/dist/cli.js +71 -18
  38. package/dist/closed-pipes.d.ts +2 -0
  39. package/dist/closed-pipes.js +13 -0
  40. package/dist/computer-commands.d.ts +2 -0
  41. package/dist/computer-commands.js +2 -0
  42. package/dist/computer-keys.d.ts +20 -10
  43. package/dist/computer-keys.js +36 -54
  44. package/dist/computer-setting.d.ts +20 -3
  45. package/dist/computer-setting.js +58 -10
  46. package/dist/computers.d.ts +35 -2
  47. package/dist/computers.js +72 -11
  48. package/dist/confine.d.ts +120 -0
  49. package/dist/confine.js +436 -0
  50. package/dist/console/assets/index-B7NKTU8E.css +1 -0
  51. package/dist/console/assets/index-CXZMgJE7.js +550 -0
  52. package/dist/console/index.html +2 -2
  53. package/dist/content-filter.d.ts +7 -0
  54. package/dist/content-filter.js +23 -0
  55. package/dist/decision-cap.d.ts +7 -29
  56. package/dist/decision-cap.js +3 -94
  57. package/dist/decision-rows.d.ts +1 -1
  58. package/dist/decision-rows.js +1 -1
  59. package/dist/docker-daemon.d.ts +31 -0
  60. package/dist/docker-daemon.js +56 -0
  61. package/dist/effort-guidance.js +4 -3
  62. package/dist/environment.d.ts +0 -3
  63. package/dist/environment.js +3 -5
  64. package/dist/errors.d.ts +1 -2
  65. package/dist/errors.js +9 -9
  66. package/dist/explain.js +3 -1
  67. package/dist/filed-answer.d.ts +32 -0
  68. package/dist/filed-answer.js +160 -0
  69. package/dist/files.d.ts +1 -3
  70. package/dist/files.js +2 -4
  71. package/dist/github-connection.d.ts +1 -1
  72. package/dist/github-connection.js +25 -7
  73. package/dist/github-faux.d.ts +26 -0
  74. package/dist/github-faux.js +76 -0
  75. package/dist/github.d.ts +6 -2
  76. package/dist/github.js +5 -3
  77. package/dist/graph-served.d.ts +5 -3
  78. package/dist/graph-served.js +14 -6
  79. package/dist/graph-view.d.ts +3 -5
  80. package/dist/graph-view.js +9 -16
  81. package/dist/handed-values.d.ts +9 -0
  82. package/dist/handed-values.js +26 -0
  83. package/dist/harness-install.d.ts +1 -7
  84. package/dist/harness-install.js +1 -18
  85. package/dist/harness-opencode/adapter.d.ts +7 -0
  86. package/dist/harness-opencode/adapter.js +23 -6
  87. package/dist/harness-opencode/harness.js +0 -1
  88. package/dist/harness-opencode/host/policy.js +2 -2
  89. package/dist/harness-opencode/index.d.ts +1 -1
  90. package/dist/harness-opencode/index.js +1 -1
  91. package/dist/harness-opencode/verify.d.ts +17 -0
  92. package/dist/harness-opencode/verify.js +30 -10
  93. package/dist/harness-table.js +6 -1
  94. package/dist/heard.js +1 -1
  95. package/dist/held-fd.d.ts +5 -0
  96. package/dist/held-fd.js +14 -0
  97. package/dist/host-calls.d.ts +20 -0
  98. package/dist/host-calls.js +12 -0
  99. package/dist/host-tools.d.ts +4 -21
  100. package/dist/host-tools.js +4 -61
  101. package/dist/host.d.ts +2 -4
  102. package/dist/host.js +2 -7
  103. package/dist/import-summary.d.ts +1 -5
  104. package/dist/import-summary.js +0 -21
  105. package/dist/import.d.ts +6 -6
  106. package/dist/import.js +14 -15
  107. package/dist/index.d.ts +1 -0
  108. package/dist/index.js +1 -0
  109. package/dist/key-refusal.d.ts +5 -1
  110. package/dist/key-refusal.js +19 -4
  111. package/dist/learn/check.d.ts +8 -2
  112. package/dist/learn/check.js +85 -31
  113. package/dist/learn/folder.d.ts +11 -4
  114. package/dist/learn/folder.js +17 -19
  115. package/dist/learn/grade.d.ts +18 -1
  116. package/dist/learn/grade.js +108 -14
  117. package/dist/learn/index.d.ts +5 -5
  118. package/dist/learn/index.js +5 -5
  119. package/dist/learn/learning.sh +1 -14
  120. package/dist/learn/notes.d.ts +14 -3
  121. package/dist/learn/notes.js +16 -6
  122. package/dist/learn/reflect.d.ts +31 -2
  123. package/dist/learn/reflect.js +83 -6
  124. package/dist/learn/relevance.d.ts +24 -0
  125. package/dist/learn/relevance.js +91 -0
  126. package/dist/learn/secrets.d.ts +7 -1
  127. package/dist/learn/secrets.js +86 -19
  128. package/dist/learn/skills.d.ts +159 -18
  129. package/dist/learn/skills.js +644 -64
  130. package/dist/learned-nodes.d.ts +14 -0
  131. package/dist/learned-nodes.js +8 -0
  132. package/dist/learned-workflow.d.ts +41 -6
  133. package/dist/learned-workflow.js +153 -18
  134. package/dist/learning-routes.d.ts +49 -4
  135. package/dist/learning-routes.js +113 -31
  136. package/dist/learning-run.d.ts +16 -31
  137. package/dist/learning-run.js +31 -38
  138. package/dist/learning-words.d.ts +12 -5
  139. package/dist/learning-words.js +18 -9
  140. package/dist/learning.d.ts +91 -97
  141. package/dist/learning.js +176 -320
  142. package/dist/live/stream.js +1 -1
  143. package/dist/live/translate.js +12 -2
  144. package/dist/llm.d.ts +4 -1
  145. package/dist/llm.js +4 -2
  146. package/dist/local-models.d.ts +11 -5
  147. package/dist/local-models.js +13 -8
  148. package/dist/mcp-gateway.d.ts +17 -49
  149. package/dist/mcp-gateway.js +55 -136
  150. package/dist/mcp-oauth.d.ts +10 -14
  151. package/dist/mcp-oauth.js +14 -32
  152. package/dist/mcp-probe.d.ts +0 -7
  153. package/dist/mcp-probe.js +4 -10
  154. package/dist/mcp-servers-store.d.ts +18 -18
  155. package/dist/mcp-servers-store.js +12 -14
  156. package/dist/mcp-store.js +3 -4
  157. package/dist/mcp.js +4 -3
  158. package/dist/model.d.ts +9 -7
  159. package/dist/model.js +51 -27
  160. package/dist/monid.d.ts +0 -2
  161. package/dist/monid.js +3 -6
  162. package/dist/openapi.d.ts +8 -1
  163. package/dist/openapi.js +156 -58
  164. package/dist/page.d.ts +1 -3
  165. package/dist/page.js +6 -18
  166. package/dist/paid-calls.d.ts +21 -27
  167. package/dist/paid-calls.js +26 -61
  168. package/dist/pause.d.ts +2 -19
  169. package/dist/pause.js +5 -74
  170. package/dist/port-models.d.ts +10 -3
  171. package/dist/port-models.js +26 -6
  172. package/dist/propose.d.ts +2 -0
  173. package/dist/propose.js +80 -45
  174. package/dist/push-handler.d.ts +1 -1
  175. package/dist/reflect-range.d.ts +25 -0
  176. package/dist/reflect-range.js +30 -0
  177. package/dist/refusal-words.d.ts +5 -1
  178. package/dist/refusal-words.js +5 -1
  179. package/dist/rows.d.ts +1 -1
  180. package/dist/run-cut.d.ts +0 -6
  181. package/dist/run-cut.js +0 -6
  182. package/dist/run-db.d.ts +2 -11
  183. package/dist/run-db.js +2 -37
  184. package/dist/run-launch.d.ts +21 -2
  185. package/dist/run-launch.js +14 -5
  186. package/dist/run-learning-served.d.ts +21 -4
  187. package/dist/run-learning-served.js +23 -13
  188. package/dist/run-reads-over-store.d.ts +5 -3
  189. package/dist/run-reads-over-store.js +25 -14
  190. package/dist/run-secrets.d.ts +1 -1
  191. package/dist/run-timeline-served.d.ts +5 -1
  192. package/dist/run-timeline-served.js +27 -6
  193. package/dist/run-view.d.ts +37 -22
  194. package/dist/run-view.js +85 -38
  195. package/dist/runnable.d.ts +21 -10
  196. package/dist/runnable.js +35 -12
  197. package/dist/runner/adapter-loop.d.ts +36 -5
  198. package/dist/runner/adapter-loop.js +663 -69
  199. package/dist/runner/adapter-run-spec.d.ts +42 -8
  200. package/dist/runner/adapter-run-spec.js +186 -52
  201. package/dist/runner/adapters/index.js +11 -1
  202. package/dist/runner/adapters/pi.d.ts +40 -2
  203. package/dist/runner/adapters/pi.js +110 -27
  204. package/dist/runner/beside.d.ts +38 -3
  205. package/dist/runner/beside.js +54 -5
  206. package/dist/runner/claim-secrets.d.ts +16 -1
  207. package/dist/runner/claim-secrets.js +62 -14
  208. package/dist/runner/cli-run-spec.d.ts +5 -0
  209. package/dist/runner/cli-run-spec.js +159 -41
  210. package/dist/runner/commands.js +1 -1
  211. package/dist/runner/computer-journal.d.ts +15 -2
  212. package/dist/runner/computer-journal.js +41 -5
  213. package/dist/runner/conformance/harness.d.ts +1 -0
  214. package/dist/runner/conformance/harness.js +123 -13
  215. package/dist/runner/conformance/subject.d.ts +4 -1
  216. package/dist/runner/dispatch.d.ts +8 -1
  217. package/dist/runner/dispatch.js +81 -7
  218. package/dist/runner/end-of-run.d.ts +8 -2
  219. package/dist/runner/end-of-run.js +10 -4
  220. package/dist/runner/github-app.d.ts +7 -2
  221. package/dist/runner/github-app.js +47 -16
  222. package/dist/runner/harness-loops.d.ts +15 -2
  223. package/dist/runner/harness-loops.js +38 -2
  224. package/dist/runner/journal-kinds.d.ts +60 -6
  225. package/dist/runner/journal-kinds.js +43 -5
  226. package/dist/runner/journal-reader.d.ts +1 -1
  227. package/dist/runner/journal-reader.js +2 -2
  228. package/dist/runner/learning-ask.d.ts +4 -0
  229. package/dist/runner/learning-ask.js +15 -1
  230. package/dist/runner/learning-end.d.ts +18 -3
  231. package/dist/runner/learning-end.js +194 -20
  232. package/dist/runner/learning-loop.d.ts +7 -0
  233. package/dist/runner/learning-loop.js +36 -8
  234. package/dist/runner/learning-seed.d.ts +6 -0
  235. package/dist/runner/learning-seed.js +6 -0
  236. package/dist/runner/loop-contract.d.ts +4 -0
  237. package/dist/runner/main.d.ts +61 -9
  238. package/dist/runner/main.js +144 -20
  239. package/dist/runner/mcp-claim.d.ts +3 -0
  240. package/dist/runner/mcp-claim.js +7 -3
  241. package/dist/runner/mcp-github.d.ts +11 -2
  242. package/dist/runner/mcp-github.js +55 -4
  243. package/dist/runner/mcp-run.d.ts +2 -0
  244. package/dist/runner/mcp-run.js +16 -5
  245. package/dist/runner/memory-claim.d.ts +9 -0
  246. package/dist/runner/memory-claim.js +25 -0
  247. package/dist/runner/metrics.d.ts +46 -1
  248. package/dist/runner/metrics.js +156 -1
  249. package/dist/runner/model-route.d.ts +16 -0
  250. package/dist/runner/model-route.js +134 -10
  251. package/dist/runner/reflect-hook.d.ts +12 -1
  252. package/dist/runner/reflect-hook.js +33 -3
  253. package/dist/runner/runner.d.ts +20 -0
  254. package/dist/runner/runner.js +146 -18
  255. package/dist/runner/spec-holds.d.ts +7 -2
  256. package/dist/runner/spec-holds.js +4 -3
  257. package/dist/runner/store-port.d.ts +1 -1
  258. package/dist/runner/store-secrets.d.ts +3 -3
  259. package/dist/runner/store-secrets.js +8 -12
  260. package/dist/runner/text-tools.d.ts +44 -0
  261. package/dist/runner/text-tools.js +237 -0
  262. package/dist/runner/workflow-host.d.ts +7 -2
  263. package/dist/runner/workflow-host.js +3 -1
  264. package/dist/runner/workflow-loop.d.ts +10 -1
  265. package/dist/runner/workflow-loop.js +14 -6
  266. package/dist/runner/workflow-spec.d.ts +21 -0
  267. package/dist/runner/workflow-spec.js +217 -93
  268. package/dist/runs-over-store.d.ts +14 -3
  269. package/dist/runs-over-store.js +100 -23
  270. package/dist/seal-key.d.ts +0 -2
  271. package/dist/seal-key.js +5 -45
  272. package/dist/sealed-settings-store.d.ts +19 -4
  273. package/dist/sealed-settings-store.js +9 -9
  274. package/dist/sealing.d.ts +4 -0
  275. package/dist/sealing.js +20 -0
  276. package/dist/secret-cut.d.ts +1 -1
  277. package/dist/secret-cut.js +1 -1
  278. package/dist/secret-name.d.ts +9 -0
  279. package/dist/secret-name.js +15 -0
  280. package/dist/secret-writes.d.ts +0 -1
  281. package/dist/secret-writes.js +0 -1
  282. package/dist/server-fs.d.ts +4 -0
  283. package/dist/server-fs.js +8 -2
  284. package/dist/server-lock.d.ts +0 -24
  285. package/dist/server-lock.js +5 -85
  286. package/dist/server-secrets-store.d.ts +4 -4
  287. package/dist/server-secrets-store.js +9 -31
  288. package/dist/server-secrets.d.ts +4 -9
  289. package/dist/server-secrets.js +12 -36
  290. package/dist/server.d.ts +37 -56
  291. package/dist/server.js +322 -134
  292. package/dist/sign-ins-store.d.ts +34 -36
  293. package/dist/sign-ins-store.js +27 -38
  294. package/dist/sign-ins.d.ts +2 -119
  295. package/dist/sign-ins.js +5 -311
  296. package/dist/standard-webhooks.d.ts +1 -1
  297. package/dist/standard-webhooks.js +1 -1
  298. package/dist/stats.d.ts +3 -2
  299. package/dist/stats.js +1 -1
  300. package/dist/stop-signals.d.ts +4 -2
  301. package/dist/stop-signals.js +5 -3
  302. package/dist/store/agent-body.d.ts +12 -2
  303. package/dist/store/agent-body.js +22 -4
  304. package/dist/store/deadline.d.ts +18 -0
  305. package/dist/store/deadline.js +45 -0
  306. package/dist/store/index.d.ts +2 -2
  307. package/dist/store/index.js +2 -2
  308. package/dist/store/open.d.ts +6 -3
  309. package/dist/store/open.js +2 -2
  310. package/dist/store/postgres/connection.d.ts +22 -2
  311. package/dist/store/postgres/connection.js +211 -41
  312. package/dist/store/postgres/migrate.d.ts +4 -0
  313. package/dist/store/postgres/migrate.js +9 -2
  314. package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
  315. package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
  316. package/dist/store/postgres/store.d.ts +9 -2
  317. package/dist/store/postgres/store.js +9 -0
  318. package/dist/store/schema.js +1 -1
  319. package/dist/store/seal.js +2 -2
  320. package/dist/store/sqlite/connection.js +14 -5
  321. package/dist/store/sqlite/run-patch.d.ts +3 -0
  322. package/dist/store/sqlite/run-patch.js +3 -0
  323. package/dist/store/sqlite/store.js +41 -12
  324. package/dist/store/store.d.ts +35 -6
  325. package/dist/store/store.js +12 -2
  326. package/dist/store-reads/cap.d.ts +1 -1
  327. package/dist/store-reads/cap.js +22 -4
  328. package/dist/store-reads/journal.d.ts +9 -6
  329. package/dist/store-reads/journal.js +129 -18
  330. package/dist/store-reads/learning.d.ts +82 -8
  331. package/dist/store-reads/learning.js +184 -11
  332. package/dist/store-reads/workflow.d.ts +1 -1
  333. package/dist/store-reads/workflow.js +1 -1
  334. package/dist/store-view.d.ts +19 -1
  335. package/dist/store-view.js +95 -27
  336. package/dist/template-eval.d.ts +60 -4
  337. package/dist/template-eval.js +120 -54
  338. package/dist/templates.d.ts +33 -14
  339. package/dist/templates.js +82 -46
  340. package/dist/timeline/group.d.ts +33 -0
  341. package/dist/timeline/group.js +77 -0
  342. package/dist/timeline/index.d.ts +7 -0
  343. package/dist/timeline/index.js +7 -0
  344. package/dist/timeline/labels.d.ts +79 -0
  345. package/dist/timeline/labels.js +150 -0
  346. package/dist/timeline/origin.d.ts +56 -0
  347. package/dist/timeline/origin.js +92 -0
  348. package/dist/timeline/render-text.d.ts +11 -0
  349. package/dist/timeline/render-text.js +62 -0
  350. package/dist/timeline/timeline.d.ts +282 -0
  351. package/dist/timeline/timeline.js +1308 -0
  352. package/dist/timeline/util.d.ts +17 -0
  353. package/dist/timeline/util.js +49 -0
  354. package/dist/tool-budget.d.ts +18 -0
  355. package/dist/tool-budget.js +50 -0
  356. package/dist/tool-gate.d.ts +47 -218
  357. package/dist/tool-gate.js +87 -545
  358. package/dist/tool-keys-store.d.ts +11 -12
  359. package/dist/tool-keys-store.js +24 -31
  360. package/dist/tool-keys.d.ts +5 -101
  361. package/dist/tool-keys.js +8 -267
  362. package/dist/tool-plane.d.ts +23 -52
  363. package/dist/tool-plane.js +23 -81
  364. package/dist/tool-settings-store.d.ts +1 -2
  365. package/dist/tool-settings-store.js +5 -8
  366. package/dist/tools.d.ts +67 -25
  367. package/dist/tools.js +170 -119
  368. package/dist/trigger-adapter.d.ts +2 -2
  369. package/dist/trigger-targets.d.ts +13 -1
  370. package/dist/trigger-targets.js +31 -1
  371. package/dist/triggers.d.ts +2 -2
  372. package/dist/triggers.js +3 -3
  373. package/dist/turn-end.d.ts +1 -1
  374. package/dist/turn-end.js +1 -1
  375. package/dist/turns.d.ts +0 -6
  376. package/dist/turns.js +0 -19
  377. package/dist/uploads.d.ts +28 -5
  378. package/dist/uploads.js +83 -10
  379. package/dist/usage.d.ts +1 -49
  380. package/dist/usage.js +3 -84
  381. package/dist/validate.d.ts +4 -0
  382. package/dist/validate.js +33 -14
  383. package/dist/webhooks.d.ts +102 -76
  384. package/dist/webhooks.js +266 -233
  385. package/dist/workflow-run.d.ts +114 -0
  386. package/dist/workflow-run.js +144 -0
  387. package/dist/workspace/archil-claim.d.ts +2 -2
  388. package/dist/workspace/archil-claim.js +4 -3
  389. package/dist/workspace/archil-disk.d.ts +10 -1
  390. package/dist/workspace/archil-disk.js +4 -0
  391. package/dist/workspace/archil-exec.d.ts +12 -2
  392. package/dist/workspace/archil-exec.js +16 -0
  393. package/dist/workspace/archil.d.ts +2 -2
  394. package/dist/workspace/archil.js +25 -5
  395. package/dist/workspace/attach.js +2 -0
  396. package/dist/workspace/beneath.d.ts +19 -0
  397. package/dist/workspace/beneath.js +106 -0
  398. package/dist/workspace/computer-deps.d.ts +26 -9
  399. package/dist/workspace/computer-deps.js +144 -43
  400. package/dist/workspace/computer-for-claim.d.ts +17 -14
  401. package/dist/workspace/computer-for-claim.js +99 -26
  402. package/dist/workspace/computer-hold.d.ts +6 -1
  403. package/dist/workspace/computer-hold.js +6 -1
  404. package/dist/workspace/computer-janitor.d.ts +47 -0
  405. package/dist/workspace/computer-janitor.js +182 -0
  406. package/dist/workspace/computer-ledger.d.ts +1 -8
  407. package/dist/workspace/computer-ledger.js +0 -3
  408. package/dist/workspace/computer-providers.d.ts +5 -3
  409. package/dist/workspace/computer-providers.js +11 -9
  410. package/dist/workspace/grep-worker.d.ts +5 -0
  411. package/dist/workspace/grep-worker.js +9 -6
  412. package/dist/workspace/hands.d.ts +5 -2
  413. package/dist/workspace/hands.js +4 -3
  414. package/dist/workspace/index.d.ts +6 -5
  415. package/dist/workspace/index.js +4 -4
  416. package/dist/workspace/local.d.ts +14 -2
  417. package/dist/workspace/local.js +170 -43
  418. package/dist/workspace/paths.js +3 -2
  419. package/dist/workspace/pi-env.d.ts +4 -0
  420. package/dist/workspace/pi-env.js +3 -2
  421. package/dist/workspace/resolve-computer.d.ts +55 -10
  422. package/dist/workspace/resolve-computer.js +66 -14
  423. package/dist/workspace/run-tools.d.ts +15 -31
  424. package/dist/workspace/run-tools.js +19 -30
  425. package/dist/workspace/workspace.d.ts +5 -0
  426. package/dist/workspace-paths.d.ts +0 -17
  427. package/dist/workspace-paths.js +1 -41
  428. package/dist/workspace.d.ts +0 -17
  429. package/dist/workspace.js +4 -110
  430. package/package.json +14 -14
  431. package/skills/agentrun-serve/SKILL.md +1 -1
  432. package/templates/README.md +11 -5
  433. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  434. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  435. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  436. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  437. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  438. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  439. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  440. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  441. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  442. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  443. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  444. package/templates/market-monitor/agent.md +2 -2
  445. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  446. package/templates/release-notes/agent.md +11 -0
  447. package/dist/bound-files.d.ts +0 -4
  448. package/dist/bound-files.js +0 -164
  449. package/dist/coding-tools.d.ts +0 -47
  450. package/dist/coding-tools.js +0 -189
  451. package/dist/computer-adb.d.ts +0 -12
  452. package/dist/computer-adb.js +0 -14
  453. package/dist/console/assets/index-Dn0ngwG9.js +0 -535
  454. package/dist/console/assets/index-DvW6Aled.css +0 -1
  455. package/dist/grade.d.ts +0 -63
  456. package/dist/grade.js +0 -150
  457. package/dist/mcp-servers.d.ts +0 -269
  458. package/dist/mcp-servers.js +0 -456
  459. package/dist/packs.d.ts +0 -71
  460. package/dist/packs.js +0 -180
  461. package/dist/sealed-settings.d.ts +0 -60
  462. package/dist/sealed-settings.js +0 -171
  463. package/dist/sessions.d.ts +0 -6
  464. package/dist/sessions.js +0 -109
  465. package/dist/workspace/computer-serves.d.ts +0 -12
  466. package/dist/workspace/computer-serves.js +0 -15
@@ -0,0 +1,237 @@
1
+ // Tools as text, for a model whose provider caches no prefix of a request that carries a `tools` parameter (a catalog
2
+ // entry's 'toolsAs: "text"', local-models.ts; the translated route, model-route.ts, reads it). Measured
3
+ // 2026-11-11 on OpenRouter's particle-1 (one provider, Particle AI): the same request with `tools` renders to a prompt
4
+ // whose token count varies by request (58,791 vs 58,793) and is cached 0-30% of the time; with its tools described in
5
+ // the system prompt and its calls and results written as text it is cached whole from the second send on (57,088 of
6
+ // 57,188 tokens). A tool-using review sends its whole history every turn, so that is the difference between paying
7
+ // $0.25/M (list) and $0.03/M for nearly all of its input. The text protocol is DeepSeek's DSML without its marker
8
+ // ("<function_calls><invoke name><parameter name string>"), the shape particle-1 writes on its own when given tools as
9
+ // text (DeepSeek V3.2's chat template words it so; the provider drops or breaks the `|DSML|` marker in what it streams);
10
+ // a reply with the marker, or a `<tool_call>{json}</tool_call>` block, is read too. Calls and results are rebuilt from
11
+ // history the same way every turn, so each request's prefix is byte for byte the last one's.
12
+ const OPEN = "<tool_call>";
13
+ const CLOSE = "</tool_call>";
14
+ /** The system prompt's tools section, in DeepSeek V3.2's own words: how to call, then each tool's schema. */
15
+ export function toolsSection(tools) {
16
+ return [
17
+ "## Tools",
18
+ "You have access to a set of tools you can use to answer the user's question.",
19
+ 'You can invoke functions by writing a "<function_calls>" block like the following as part of your reply to the user:',
20
+ "<function_calls>",
21
+ '<invoke name="$FUNCTION_NAME">',
22
+ '<parameter name="$PARAMETER_NAME" string="true|false">$PARAMETER_VALUE</parameter>',
23
+ "...",
24
+ "</invoke>",
25
+ '<invoke name="$FUNCTION_NAME2">',
26
+ "...",
27
+ "</invoke>",
28
+ "</function_calls>",
29
+ "",
30
+ 'String and scalar parameters should be specified as is without any escaping or quotes, while lists and objects should use JSON format. The "string" attribute should be set to "true" for string type parameters and "false" for other types (numbers, booleans, arrays, objects).',
31
+ "Several invokes in one block run together, in order. Write nothing after the block; the results come back to you in a <function_results> block. A reply with no block is your final answer.",
32
+ "",
33
+ "### Available Tool Schemas",
34
+ "",
35
+ "<functions>",
36
+ ...tools.map((tool) => JSON.stringify({ name: tool.name, description: (tool.description ?? "").trim(), parameters: tool.parameters ?? { type: "object", properties: {} } })),
37
+ "</functions>",
38
+ "",
39
+ "You MUST strictly follow the above defined tool name and parameter schemas to invoke tool calls.",
40
+ ].join("\n");
41
+ }
42
+ /** One call as a DSML invoke, as `toolsSection` asks for it. */
43
+ const invokeOf = (name, args) => {
44
+ const params = Object.entries((args && typeof args === "object" ? args : {})).map(([key, value]) => `<parameter name="${key}" string="${typeof value === "string"}">${typeof value === "string" ? value : JSON.stringify(value)}</parameter>`);
45
+ return [`<invoke name="${name}">`, ...params, "</invoke>"].join("\n");
46
+ };
47
+ /** `context` with its tools in its system prompt and every tool call and result in its history written as text. */
48
+ export function toolsAsText(context) {
49
+ const tools = context.tools ?? [];
50
+ const messages = [];
51
+ for (const message of context.messages) {
52
+ if (message.role === "assistant" && Array.isArray(message.content)) {
53
+ const said = message.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join("").trim();
54
+ const calls = message.content.filter((part) => part.type === "toolCall").map((part) => invokeOf(part.name ?? "", part.arguments));
55
+ const text = [said, calls.length ? ["<function_calls>", ...calls, "</function_calls>"].join("\n") : ""].filter(Boolean).join("\n\n");
56
+ messages.push({ ...message, content: [{ type: "text", text: text || "(no text)" }] });
57
+ continue;
58
+ }
59
+ if (message.role === "toolResult") {
60
+ const parts = Array.isArray(message.content) ? message.content : [{ type: "text", text: String(message.content) }];
61
+ const body = parts.filter((part) => part.type === "text").map((part) => part.text ?? "").join("\n");
62
+ const images = parts.filter((part) => part.type === "image");
63
+ const text = `<result tool="${message.toolName ?? ""}"${message.isError ? ' error="true"' : ""}>\n${body}\n</result>`;
64
+ // Results of one turn's calls go together, as one user message, in the order called.
65
+ const last = messages[messages.length - 1];
66
+ if (last?.role === "user" && last.fromTools === true && Array.isArray(last.content))
67
+ last.content.push({ type: "text", text: `\n${text}` }, ...images);
68
+ else
69
+ messages.push({ role: "user", content: [{ type: "text", text: `<function_results>\n${text}` }, ...images], timestamp: message.timestamp, fromTools: true });
70
+ continue;
71
+ }
72
+ messages.push(message);
73
+ }
74
+ for (const message of messages) {
75
+ if (message.fromTools === true && Array.isArray(message.content))
76
+ message.content.push({ type: "text", text: "\n</function_results>" });
77
+ delete message.fromTools;
78
+ }
79
+ const system = [context.systemPrompt ?? "", tools.length ? toolsSection(tools) : ""].filter(Boolean).join("\n\n");
80
+ return { ...(system ? { systemPrompt: system } : {}), messages };
81
+ }
82
+ /** A reply's text read as text and calls: each `<tool_call>` block whose JSON names a tool, in order; the rest is
83
+ * text. A block whose JSON does not parse stays text. */
84
+ export function callsOfText(said, tools = []) {
85
+ const calls = [];
86
+ // DSML with its marker or without (the provider may drop it, or put zero-width spaces in its tags), as the model
87
+ // writes it: `<function_calls>` (or "<calls>"), each `<invoke name="...">` with `<parameter name="..." string="...">`
88
+ // values, or `<invoke name="...", "arguments": {...}}`. The slips particle-1 makes are read too: the tool named by a
89
+ // '<parameter name="invoke">', a `<name>value</parameter>` parameter, and an invoke with no name (the one tool whose
90
+ // schema takes every parameter given and all its required ones).
91
+ const text = said.replace(/\u200b/g, "").replace(/|DSML|\s*/g, "");
92
+ const first = text.search(/<(?:function_calls|calls|invoke\b|parameter\b)/);
93
+ const groups = [];
94
+ const current = () => groups[groups.length - 1] ?? (groups.push({ args: {} }), groups[0]);
95
+ // A string is written unescaped, so a value may hold "</parameter>" itself (a file that writes this protocol, an
96
+ // example in a comment): a value ends at the closing tag that the call's next tag, or the reply's end, follows.
97
+ const token = /<invoke\s+name="([^"]+)"(\s*,\s*"arguments"\s*:\s*)?|<\/invoke>|<parameter\s+name="([^"]+)"(?:\s+string="(true|false)")?\s*>([\s\S]*?)<\/(?:parameter|invoke)>(?=\s*(?:<parameter\s+name=|<\/?invoke\b|<\/function_calls>|<\/calls>|<[A-Za-z_][\w-]*>[^<]*<\/parameter>|$))|<([A-Za-z_][\w-]*)>([^<]*)<\/parameter>/g;
98
+ const block = first < 0 ? "" : text.slice(first);
99
+ let closed = false;
100
+ // A call the reply did not finish (cut off, or a tag opened and never closed) is never run on what it holds so far:
101
+ // the reply is broken, and asked again.
102
+ let unfinished = false;
103
+ let end = 0;
104
+ for (const match of block.matchAll(token)) {
105
+ const [whole, invoked, jsonArgs, key, isString, value, slipKey, slipValue] = match;
106
+ if (/<(?:invoke|parameter)\b/.test(block.slice(end, match.index)))
107
+ unfinished = true;
108
+ end = match.index + whole.length;
109
+ if (invoked !== undefined) {
110
+ groups.push({ name: invoked, args: {} });
111
+ closed = false;
112
+ if (jsonArgs) {
113
+ const object = objectAt(block, end);
114
+ if (object === undefined)
115
+ unfinished = true;
116
+ else {
117
+ end += object.length;
118
+ try {
119
+ Object.assign(groups[groups.length - 1].args, JSON.parse(object));
120
+ }
121
+ catch {
122
+ unfinished = true;
123
+ }
124
+ }
125
+ }
126
+ }
127
+ else if (whole === "</invoke>")
128
+ closed = true;
129
+ else if (key === "invoke" && value.includes("<parameter")) {
130
+ // `<parameter name="invoke">` opening a call whose name never came: its first parameter is inside.
131
+ groups.push({ args: {} });
132
+ closed = false;
133
+ const inner = /<parameter\s+name="([^"]+)"(?:\s+string="(true|false)")?\s*>([\s\S]*)$/.exec(value);
134
+ if (inner)
135
+ current().args[inner[1]] = valueOf(inner[3], inner[2]);
136
+ }
137
+ else if (key === "invoke" || key === "name" && current().name === undefined && tools.some((tool) => tool.name === value)) {
138
+ groups.push({ name: value.trim(), args: {} });
139
+ closed = false;
140
+ }
141
+ else if (key !== undefined) {
142
+ if (closed)
143
+ groups.push({ args: {} });
144
+ closed = false;
145
+ current().args[key] = valueOf(value, isString);
146
+ }
147
+ else if (slipKey !== undefined && !["function_calls", "calls", "invoke", "parameter"].includes(slipKey) && !(slipKey in current().args))
148
+ current().args[slipKey] = valueOf(slipValue, undefined);
149
+ }
150
+ if (first >= 0 && /<(?:invoke|parameter)\b/.test(block.slice(end)))
151
+ unfinished = true;
152
+ if (unfinished)
153
+ return { text: text.trim(), calls: [], broken: true };
154
+ for (const group of groups) {
155
+ const name = group.name ?? nameOf(group.args, tools);
156
+ if (name !== undefined)
157
+ calls.push({ name, arguments: group.args });
158
+ }
159
+ if (calls.length)
160
+ return { text: text.slice(0, first).trim(), calls };
161
+ if (first >= 0 && /<(?:function_calls|calls|invoke|parameter)\b/.test(text))
162
+ return { text: text.trim(), calls, broken: true };
163
+ // A `<tool_call>{"name": ..., "arguments": ...}</tool_call>` block.
164
+ let rest = "";
165
+ let at = 0;
166
+ for (;;) {
167
+ const open = text.indexOf(OPEN, at);
168
+ if (open < 0)
169
+ break;
170
+ const close = text.indexOf(CLOSE, open + OPEN.length);
171
+ const raw = text.slice(open + OPEN.length, close < 0 ? undefined : close).trim();
172
+ let call;
173
+ try {
174
+ call = JSON.parse(raw);
175
+ }
176
+ catch {
177
+ call = undefined;
178
+ }
179
+ rest += text.slice(at, open);
180
+ if (call && typeof call.name === "string") {
181
+ const args = typeof call.arguments === "string" ? valueOf(call.arguments, "false") : call.arguments;
182
+ calls.push({ name: call.name, arguments: (args && typeof args === "object" && !Array.isArray(args) ? args : {}) });
183
+ }
184
+ else
185
+ rest += text.slice(open, close < 0 ? undefined : close + CLOSE.length);
186
+ if (close < 0) {
187
+ at = text.length;
188
+ break;
189
+ }
190
+ at = close + CLOSE.length;
191
+ }
192
+ rest += text.slice(at);
193
+ return { text: rest.trim(), calls };
194
+ }
195
+ /** The one tool whose schema takes every argument given and all its required ones, or undefined. */
196
+ function nameOf(args, tools) {
197
+ const keys = Object.keys(args);
198
+ if (!keys.length)
199
+ return undefined;
200
+ const fits = tools.filter((tool) => {
201
+ const schema = (tool.parameters ?? {});
202
+ const known = Object.keys(schema.properties ?? {});
203
+ const props = (schema.properties ?? {});
204
+ return keys.every((key) => known.includes(key) && (!props[key]?.enum || props[key].enum.includes(args[key]))) && (schema.required ?? []).every((key) => keys.includes(key));
205
+ });
206
+ return fits.length === 1 ? fits[0].name : undefined;
207
+ }
208
+ /** A parameter's value: as written when it is a string, else its JSON (a number, a list, an object), else as written. */
209
+ function valueOf(value, isString) {
210
+ if (isString === "true")
211
+ return value;
212
+ try {
213
+ return JSON.parse(value.trim());
214
+ }
215
+ catch {
216
+ return value;
217
+ }
218
+ }
219
+ /** The JSON object that starts at `at` in `text` (its braces matched, strings skipped), or undefined. */
220
+ function objectAt(text, at) {
221
+ if (text[at] !== "{")
222
+ return undefined;
223
+ let depth = 0;
224
+ for (let i = at; i < text.length; i++) {
225
+ const c = text[i];
226
+ if (c === '"') {
227
+ for (i++; i < text.length && text[i] !== '"'; i++)
228
+ if (text[i] === "\\")
229
+ i++;
230
+ }
231
+ else if (c === "{")
232
+ depth++;
233
+ else if (c === "}" && --depth === 0)
234
+ return text.slice(at, i + 1);
235
+ }
236
+ return undefined;
237
+ }
@@ -30,6 +30,8 @@ export interface DecisionDriver {
30
30
  decisionRequests(): Record<string, {
31
31
  status: string;
32
32
  }>;
33
+ /** Resolves once the driver's commits so far are durable (a request it ended, before the run parks on it). */
34
+ flush(): Promise<void>;
33
35
  }
34
36
  /** The run's spend cap over the workflow's adapters (app.ts's budget: stepped/failing/capStopped and the decision cap),
35
37
  * injected so this module holds no money of its own. Each wrapper is applied to its adapter where app.ts applied it; a run
@@ -40,9 +42,12 @@ export interface WorkflowCap {
40
42
  node<F>(fn: F): F;
41
43
  /** stepped(failing(·)): a call node, which waits for a raise on a held effect and goes again. */
42
44
  effect<F>(fn: F): F;
43
- /** stepped(gate(capped.before(·))): a decision, held before the driver admits it (admitting and settling it through the
44
- * kernel cap). The driver tells a replayed request, which holds nothing (main's `capped.before(runJudge, askedBefore)`). */
45
+ /** A decision, before the driver admits its request: priced, or parked by a pause. The driver tells a replayed request,
46
+ * which holds nothing. */
45
47
  judge<F>(fn: F, driver?: DecisionDriver): F;
48
+ /** A decision's judge once the driver has admitted its request: held through the kernel cap, sent, and settled. Absent:
49
+ * the judge runs as given. */
50
+ admitted?<F>(fn: F): F;
46
51
  /** A call node's wait on a raise (deps.held), left out of its deadline. */
47
52
  held?(path: string): number;
48
53
  }
@@ -6,6 +6,7 @@ const identityCap = { node: (fn) => fn, effect: (fn) => fn, judge: (fn) => fn };
6
6
  * Pass the result to createWorkflowLoop's spec.build. */
7
7
  export function workflowHost(deps) {
8
8
  const cap = deps.cap ?? identityCap;
9
+ const admitted = (fn) => (cap.admitted ? cap.admitted(fn) : fn);
9
10
  /** A model node's agent: its tier's model, the tools it names, and the extensions they come from (app.ts nodeAgent). */
10
11
  const nodeAgent = (node) => {
11
12
  const bindings = (node.tools ?? []).flatMap((name) => deps.nodeTool(name) ?? []);
@@ -38,7 +39,8 @@ export function workflowHost(deps) {
38
39
  const recovered = withRecovery(driver, {
39
40
  runNode: nodes.on(taskScope(runtime), context).runNode,
40
41
  runEffect: deps.runEffect,
41
- ...(deps.decisionProviders ? { runJudge: judgeFromProviders({ ...deps.decisionProviders, loadImage: deps.loadImage }), decisionProviders: deps.decisionProviders } : {}),
42
+ // The judge the driver asks once it has admitted a request: the cap holds, sends and settles it there (admitted).
43
+ ...(deps.decisionProviders ? { runJudge: admitted(judgeFromProviders({ ...deps.decisionProviders, loadImage: deps.loadImage })), decisionProviders: deps.decisionProviders } : {}),
42
44
  recordDecision: async (receipt, exchange) => {
43
45
  await decisions.recordDecision(receipt, exchange);
44
46
  deps.onReceipt?.(receipt);
@@ -4,7 +4,7 @@ import type { Models } from "@earendil-works/pi-ai";
4
4
  import type { Workflow } from "@parcha/agentrun-dsl";
5
5
  import { type WorkflowTaskHost } from "@parcha/agentrun-pi/durable";
6
6
  import { type BudgetData, type EndData } from "./journal-kinds.js";
7
- import { type Claim, type LoopFactory } from "./loop-contract.js";
7
+ import { type Claim, type Journal, type LoopFactory } from "./loop-contract.js";
8
8
  /** A cap refusal, as the kernel cap hands one to parkOf/checkRaise (the loop never imports the cap; its rule is handed in
9
9
  * via the spec, so flat or tiered pricing is the cap's, not this loop's). */
10
10
  export type CapRefusal = {
@@ -94,6 +94,12 @@ export interface WorkflowRunSpec {
94
94
  * once, however the run ended (ended, stopped, failed, parked or interrupted), so a parked or resumed run starts fresh
95
95
  * proxies on its next claim. Never throws out. Absent: nothing to let go. */
96
96
  readonly release?: () => Promise<void>;
97
+ /** Resolves once every model request the spec admitted has been booked, or a bound has passed (then a request left
98
+ * unbooked reads at its hold and bound). A request its node let go of (a stop) is booked only once the provider's side
99
+ * ends, which can be after the node ended: once the workflow's task is over, the loop waits for this before it closes
100
+ * the Harness the bookings are written through. Not on a park or a lost claim: the next claim books a request left
101
+ * open there as cut. Absent: nothing to wait for. */
102
+ readonly settle?: () => Promise<void>;
97
103
  }
98
104
  /** What the interpreter's host may ask of the loop while it runs. */
99
105
  export interface WorkflowHostHooks {
@@ -121,6 +127,9 @@ export declare const isWorkflowRevision: (revision: {
121
127
  * the claim opens from the store (redact.ts holdClaimed). */
122
128
  export interface WorkflowSpecRun {
123
129
  readonly redact?: (text: string) => string;
130
+ /** A fresh journal of the claim, for what the spec reads from the run's records at its end (its decisions' booked
131
+ * cost): a fresh one, since the Harness closes its own before the end is written. */
132
+ readonly journal?: () => Journal;
124
133
  }
125
134
  /** Loops for workflow runs: `spec(claim)` gives each claim's run what it runs (its workflow, input, models and host). */
126
135
  export declare function createWorkflowLoop(specOf: (claim: Claim, run: WorkflowSpecRun) => WorkflowRunSpec | Promise<WorkflowRunSpec>): LoopFactory;
@@ -1,6 +1,6 @@
1
1
  // The workflow loop on the runner (design: "Runners carry many loops"; the lead's ruling, workflow agents keep running
2
2
  // after the cutover). A run of a workflow revision, which the runner claims like any run: this loop is its driver, so the
3
- // claim, the fence, a cancel and the end commit are its. The DSL's durable runner (pi-durable-agent/workflow
3
+ // claim, the fence, a cancel and the end commit are its. The DSL's durable runner (workflow-run.ts
4
4
  // startWorkflowRevision over agentrun-pi's workflow task) runs the revision's workflow UNCHANGED — the same nodes,
5
5
  // decisions, call tools and cap it ran with in the per-run process — on the run's journal in the one store (A,
6
6
  // deps.journal(claim)) in place of a per-run store file. The interpreter's host (model nodes on the run's models, call
@@ -20,7 +20,7 @@
20
20
  import { BACKGROUND_CONTEXT, withAbortSignal } from "@earendil-works/chord/context";
21
21
  import { createRegistry, Harness, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
22
22
  import { createWorkflowExtension } from "@parcha/agentrun-pi/durable";
23
- import { readWorkflowRun, startWorkflowRevision, workflowCarry } from "@parcha/pi-durable-agent/workflow";
23
+ import { readWorkflowRun, startWorkflowRevision, workflowCarry } from "../workflow-run.js";
24
24
  import { KINDS } from "./journal-kinds.js";
25
25
  import { endedBy } from "./loop-contract.js";
26
26
  /** The most the end's patch (cost and metrics) may take before the end is written without it (the pi loop's CUT_STEP_MS). */
@@ -213,7 +213,7 @@ function workflowLoop(specOf, deps) {
213
213
  const parkController = new AbortController();
214
214
  let heldRefusal;
215
215
  const context = withAbortSignal(AbortSignal.any([deps.signal, parkController.signal]), BACKGROUND_CONTEXT);
216
- spec = await specOf(claim, deps.redact ? { redact: deps.redact } : {});
216
+ spec = await specOf(claim, { ...(deps.redact ? { redact: deps.redact } : {}), journal: () => deps.journal(claim) });
217
217
  claimNow = claim;
218
218
  specReady();
219
219
  const revision = { id: spec.revisionId, kind: "workflow", body: { workflow: spec.workflow, tools: [...spec.tools] } };
@@ -263,8 +263,10 @@ function workflowLoop(specOf, deps) {
263
263
  void error;
264
264
  return { state: "interrupted" };
265
265
  }
266
- // The task is terminal. Close the Harness, then read the run's view from its journal and write the end, both on a
267
- // fresh journal of the same claim (the Harness closed its own).
266
+ // The task is terminal. Its model requests booked (a stopped one books once its provider's side ends, after the node
267
+ // let go of it), close the Harness, then read the run's view from its journal and write the end, both on a fresh
268
+ // journal of the same claim (the Harness closed its own).
269
+ await spec.settle?.().catch(() => undefined);
268
270
  await closeHarness();
269
271
  const endJournal = deps.journal(claim);
270
272
  // A person stopped or cancelled: the run ends stopped whatever the workflow's own outcome (its last node may have
@@ -279,6 +281,12 @@ function workflowLoop(specOf, deps) {
279
281
  const { output } = await readWorkflowRun({ runId: claim.runId, storage: endJournal, revision }, { context });
280
282
  return await writeEnd(endJournal, context, { ...carry, output: output ?? null });
281
283
  }
284
+ // An escalated run's review, as main's server kept it (runs.ts): the escalation's kind, the escalate node's label (else
285
+ // the node it escalated at), and its summary (else the run's), kept on its end for the run's `review`.
286
+ if (carry.state === "escalated") {
287
+ const { escalation, escalatedAt } = await readWorkflowRun({ runId: claim.runId, storage: endJournal, revision }, { context });
288
+ return await writeEnd(endJournal, context, { ...carry, review: { kind: escalation?.kind ?? null, node: escalation?.label ?? escalatedAt?.label ?? null, reason: escalation?.summary ?? carry.summary } });
289
+ }
282
290
  return await writeEnd(endJournal, context, carry);
283
291
  }
284
292
  finally {
@@ -303,7 +311,7 @@ function workflowLoop(specOf, deps) {
303
311
  async function writeEnd(journal, context, carry) {
304
312
  const state = carry.state === "failed" ? "failed" : carry.state === "stopped" ? "stopped" : "ended";
305
313
  const outcome = carry.state === "escalated" ? "escalated" : undefined;
306
- const base = { state, summary: carry.summary, ...(outcome ? { outcome } : {}), ...(carry.output !== undefined ? { output: carry.output } : {}) };
314
+ const base = { state, summary: carry.summary, ...(outcome ? { outcome } : {}), ...(carry.output !== undefined ? { output: carry.output } : {}), ...(carry.review ? { review: carry.review } : {}) };
307
315
  const patch = await endPatchOf(spec, base);
308
316
  const data = { ...base, ...(patch.costUsd !== undefined ? { costUsd: patch.costUsd } : {}), ...(patch.metrics !== undefined ? { metrics: patch.metrics } : {}) };
309
317
  const runPatch = {
@@ -4,6 +4,7 @@ import { type BeforeRequest, type Wire } from "@parcha/agentrun-kernel";
4
4
  import { type ProviderPolicy, type ProxyUsage } from "@parcha/agentrun-kernel/host";
5
5
  import { type CapModel } from "@parcha/agentrun-kernel/kernel/cap";
6
6
  import { type Tier } from "../model.js";
7
+ import { deniedText } from "../refusal-words.js";
7
8
  import { type PaidBooking } from "../paid-calls.js";
8
9
  import { type RunTools } from "@parcha/agentrun-kernel/kernel/cap";
9
10
  import { type ModelRoute } from "./model-route.js";
@@ -20,6 +21,8 @@ export declare const SUBMIT_TOOL = "submit";
20
21
  export interface WorkflowProvider {
21
22
  /** The model id the node asks for (the tier's model). */
22
23
  readonly modelId: string;
24
+ /** The model as the run names it (`provider/model-id`): what an `llm` call's answer says it ran on. Absent: `modelId`. */
25
+ readonly named?: string;
23
26
  /** The wire the proxy forwards on, and pi-ai's client of it speaks to the proxy (port-models.ts sessionProvider). */
24
27
  readonly api: Wire;
25
28
  /** The catalog's entry for the model (whether it reasons, its window), as pi's session takes it (model-route.ts). */
@@ -107,6 +110,7 @@ export declare function pauseAtEffects(cap: WorkflowCap, hooks: Pick<WorkflowHos
107
110
  export type CallHold = {
108
111
  readonly usd: number;
109
112
  readonly name: string;
113
+ readonly tool?: string;
110
114
  readonly basis: string;
111
115
  readonly chargedBy?: string;
112
116
  readonly llm?: {
@@ -138,6 +142,16 @@ export declare const heldBooking: () => {
138
142
  readonly paid: PaidBooking;
139
143
  } | undefined;
140
144
  export declare const releaseCallHold: () => Promise<void>;
145
+ /** A call tool's permission now, as main's per-run process read it at each call node (app.ts:382-384, the gate's
146
+ * policy): the revision's tool settings and approvals over the server's, the server's read again from the store at each
147
+ * call, so a deny or an ask set while the run goes reaches its next call. A read that fails is unread, as the agentic
148
+ * gate's is (adapter-run-spec.ts storeSettings): with no good read before it every tool asks, so a call node is refused
149
+ * (the revision's own allow never stands alone over settings no read has seen); after one, the gate holds to that read
150
+ * marked unread (RunGate.serverSettings), so its denies still refuse. */
151
+ type CallPolicy = (tool: string) => Promise<{
152
+ permission: "allow" | "ask" | "deny";
153
+ denyFrom: Parameters<typeof deniedText>[2];
154
+ }>;
141
155
  /** `cap` with a call node's recorded tool failure thrown as the node's failure, as main's `failing` (app.ts:417-420):
142
156
  * the driver records the effect's outcome ({ TOOL_FAILED: words }) as its receipt, and this, past the driver, throws it
143
157
  * as an EffectFailure in those words, so the call node fails and the run with it in the tool's words. Applied outside
@@ -151,6 +165,13 @@ export declare const RUNNER_NODE_TOOLS: readonly string[];
151
165
  /** A node naming a tool the runner does not bind for a model node yet: the run is refused at its claim in these words,
152
166
  * the tool never offered and never silently dropped. */
153
167
  export declare const nodeToolUnboundText: (tool: string) => string;
168
+ /** A model node's tool call as its pi-durable task runs it: its args, the task's api and the call's context. */
169
+ type GatedExecute = (args: never, api: never, context: never) => Promise<unknown>;
170
+ /** `execute` behind the gate, for the tool `name`. A call it lets through is marked so in its task first, so when
171
+ * pi-durable's recovery runs the same call again on a later claim (the first attempt cut with its claim, maybe after it
172
+ * was sent) and the tool is now denied or set to ask, the refusal says that whether it took effect is not known
173
+ * (RAN_UNKNOWN), never that it was not run or that nothing was sent and nothing was charged. */
174
+ export declare function gatedNodeCall(name: string, policy: CallPolicy, execute: GatedExecute): GatedExecute;
154
175
  /** The tool names a workflow's model node offers its model: the node's `submit` (pi's SUBMIT_TOOL) and every tool the
155
176
  * workflow's model nodes name. */
156
177
  export declare function nodeOffer(workflow: Workflow): string[];