@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
package/dist/page.d.ts CHANGED
@@ -21,7 +21,6 @@ export declare const sendHostRefused: (req: IncomingMessage, res: ServerResponse
21
21
  /** `publicUrl`: the address people open (AGENTRUN_PUBLIC_URL); an https one adds HSTS to every page answer (hstsHeaders). */
22
22
  type PageServer = {
23
23
  token: string;
24
- dir: string;
25
24
  authFailed?: (route: string, reason: string) => void;
26
25
  owner?: Owner;
27
26
  console?: string | undefined;
@@ -34,8 +33,7 @@ export declare const byOwnerSession: (req: IncomingMessage) => boolean;
34
33
  /** Whether `req` came from the accounts-off console's page session (answerPage). */
35
34
  export declare const byConsoleSession: (req: IncomingMessage) => boolean;
36
35
  /**
37
- * Answers the console's paths ("/" and its /assets/*, and the addresses that moved to "/") and the store's /api/*, and
38
- * returns true; returns false for every other path. On a /v2 path with no Authorization header, the browser's cookie
36
+ * Answers the console's paths ("/" and its /assets/*, and the addresses that moved to "/"), and returns true; returns false for every other path. On a /v2 path with no Authorization header, the browser's cookie
39
37
  * becomes the Bearer header for a GET or HEAD, and for any other method only when the request's Origin is this server's
40
38
  * own origin and its body is application/json, or the request is a PUT or POST to a route that takes bytes, with any
41
39
  * content type.
package/dist/page.js CHANGED
@@ -2,13 +2,11 @@
2
2
  // hashed assets under /assets/, public, under one strict CSP. The console signs a person in itself. With accounts it
3
3
  // takes the owner's session cookie (owner.ts); without, the server's token as a cookie that the printed link (`/?token=`)
4
4
  // sets once. Either stands in for the Bearer header on /v2, and for a write only from this origin with a JSON body, or
5
- // with any body on a route that takes bytes (a PUT or POST marked `raw` in server.ts). The
6
- // store's read-only JSON (/api/*, pi-durable-agent's store page's data) answers the Bearer token or either cookie.
5
+ // with any body on a route that takes bytes (a PUT or POST marked `raw` in server.ts).
7
6
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
8
7
  import { readFile, realpath, stat } from "node:fs/promises";
9
8
  import { extname, join, sep } from "node:path";
10
9
  import { fileURLToPath } from "node:url";
11
- import { storeApi } from "@parcha/pi-durable-agent/serve";
12
10
  import { ApiError } from "./errors.js";
13
11
  import { hostRefusedPage } from "./host-check.js";
14
12
  // img-src names Google's favicon service and the four hosts it redirects to: the console's Keys page shows a provider's
@@ -79,18 +77,9 @@ async function file(req, res, raw, dir, rel, status = 200) {
79
77
  return missing();
80
78
  send(req, res, status, type, await readFile(real), { "cache-control": rel.startsWith("assets/") ? "public, max-age=31536000, immutable" : "no-store" });
81
79
  }
82
- async function answer(req, res, raw, server, held) {
80
+ async function answer(req, res, raw, server) {
83
81
  if (req.method !== "GET" && req.method !== "HEAD")
84
82
  return refuse(req, res, new ApiError("method_not_allowed", `the console answers GET and HEAD; ${req.method} is not one`, {}, { allow: "GET, HEAD" }));
85
- if (raw.startsWith("/api/")) {
86
- if (!held && !same(String(req.headers.authorization ?? ""), `Bearer ${server.token}`)) {
87
- server.authFailed?.(raw, req.headers.authorization === undefined ? "no_credential" : "wrong_token");
88
- return refuse(req, res, new ApiError("unauthenticated", "the page's data needs the cookie the printed link sets, or Authorization: Bearer <the token>"));
89
- }
90
- const url = new URL(req.url ?? "/", "http://serve");
91
- const { status, value } = await storeApi({ dir: server.dir })(url.pathname, url.searchParams);
92
- return send(req, res, status, "application/json; charset=utf-8", JSON.stringify(value));
93
- }
94
83
  const dir = server.console ?? CONSOLE_DIR;
95
84
  if (MOVED.has(raw))
96
85
  return redirect(res, `/${(req.url ?? "").slice(raw.length)}`);
@@ -124,8 +113,7 @@ const consoleSessions = new WeakSet();
124
113
  /** Whether `req` came from the accounts-off console's page session (answerPage). */
125
114
  export const byConsoleSession = (req) => consoleSessions.has(req);
126
115
  /**
127
- * Answers the console's paths ("/" and its /assets/*, and the addresses that moved to "/") and the store's /api/*, and
128
- * returns true; returns false for every other path. On a /v2 path with no Authorization header, the browser's cookie
116
+ * Answers the console's paths ("/" and its /assets/*, and the addresses that moved to "/"), and returns true; returns false for every other path. On a /v2 path with no Authorization header, the browser's cookie
129
117
  * becomes the Bearer header for a GET or HEAD, and for any other method only when the request's Origin is this server's
130
118
  * own origin and its body is application/json, or the request is a PUT or POST to a route that takes bytes, with any
131
119
  * content type.
@@ -146,12 +134,12 @@ export function answerPage(req, res, raw, server) {
146
134
  }
147
135
  return false;
148
136
  }
149
- if (raw !== "/" && !raw.startsWith("/assets/") && !raw.startsWith("/api/") && !MOVED.has(raw))
137
+ if (raw !== "/" && !raw.startsWith("/assets/") && !MOVED.has(raw))
150
138
  return false;
151
- // Every page answer (the console, its assets, its redirects, the store's data) at an https public address: HSTS.
139
+ // Every page answer (the console, its assets, its redirects) at an https public address: HSTS.
152
140
  for (const [name, value] of Object.entries(hstsHeaders(server.publicUrl)))
153
141
  res.setHeader(name, value);
154
- answer(req, res, raw, server, held).catch(() => {
142
+ answer(req, res, raw, server).catch(() => {
155
143
  if (!res.headersSent)
156
144
  refuse(req, res, new ApiError("internal", "the console could not be read"));
157
145
  else
@@ -1,7 +1,6 @@
1
1
  import type { Context } from "@earendil-works/chord";
2
2
  import type { Refusal } from "@parcha/agentrun-kernel";
3
3
  import { type ToolExecutionApi, type ToolRegistration } from "@earendil-works/pi-durable";
4
- import { type SyncTarget } from "@parcha/pi-durable-disk";
5
4
  /** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
6
5
  * $1 per 1,000 requests for up to 10 results, each further result $1 per 1,000; an extract $1 per 1,000 URLs. */
7
6
  export declare const PARALLEL_SEARCH_USD = 0.001;
@@ -55,37 +54,25 @@ export type PaidBooking = {
55
54
  basis: string;
56
55
  call?: string;
57
56
  chargedBy?: string;
57
+ tool?: string;
58
+ tag?: string;
59
+ owed?: true;
60
+ hold?: true;
61
+ ref?: string;
58
62
  }): Promise<unknown>;
59
63
  /** `givenBack`: the hold let go unused, nothing sent (RunTools.settle). */
60
64
  settle(id: string, usd: number | null, options?: {
61
65
  readonly givenBack?: true;
62
66
  }): Promise<unknown>;
63
67
  };
64
- export declare const settleIn: (record: Ledger["record"] | undefined, store: SyncTarget | undefined, journal?: "FULL" | "NORMAL") => void;
65
- /** Whether a barrier on the run journal has nothing to sync: no store open, while the journal syncs only at barriers. A
66
- * hold or a start mark written then would sit in the store with nothing to make it durable, so none is written. */
67
- export declare const noStoreToSync: (store: SyncTarget | undefined) => boolean;
68
- /** A hold that could not be made durable (writeHold): nothing was sent. Its message says why, after "was not sent: ". */
69
- export declare class HoldNotDurable extends Error {
70
- readonly name = "HoldNotDurable";
71
- }
72
- /** The run's journal a hold is synced in (settleIn), for another barrier before a paid effect: browser-cost.ts'. */
73
- export declare const runJournal: () => SyncTarget | undefined;
74
- /** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit), then the
75
- * run journal's barrier (pi-durable-disk barriers.ts, paidToolHold): the hold is on disk before the call is sent, so a
76
- * box loss never leaves a sent call the cap does not count. Every paid call writes its hold here: a paid request
77
- * (paidRequest), monid.run (monid.ts) and a priced MCP call (mcp-gateway.ts), so a new paid tool gets the sync with it.
78
- * Whatever throws, the caller sends nothing (holdRefusal says why): with no store to sync it writes no hold
79
- * (HoldNotDurable); a write that fails throws its own error; a sync that fails after the write settles the hold at $0
80
- * under its call (best effort), so no cap counts a call that never left, and throws HoldNotDurable. */
68
+ /** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit) before the
69
+ * call is sent. Every paid call off the run's one ledger writes its hold here: a paid request (paidRequest) and
70
+ * monid.run (monid.ts). A write that fails throws its own error, and the caller sends nothing (holdRefusal says why). */
81
71
  export declare function writeHold(write: (kind: string, data: Record<string, string | number | null>) => Promise<void>, data: Record<string, string | number | null>): Promise<void>;
82
- /** What a paid call that writeHold refused tells the model: `name` was not sent, and why. */
72
+ /** What a paid call whose hold writeHold could not write tells the model: `name` was not sent, and why. */
83
73
  export declare const holdRefusal: (name: string, error: unknown) => string;
84
- /** A settle of `kind` written to the run's root (settleIn), when that is set; else undefined, for the caller's own commit.
85
- * monid.run's settle goes here too. */
86
- export declare const settleOnRoot: (kind: string, data: Record<string, string | number | null>) => Promise<void> | undefined;
87
- /** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) is the call's own
88
- * commit, so a stopped turn sends nothing new; its settle goes to the run's root when that is set (settleIn). On the
74
+ /** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) and its settle are the
75
+ * call's own commits, so a stopped turn sends nothing new. On the
89
76
  * runner the call runs inside the run's one ledger (the adapter loop's bookedIn, which carries the run's paid tool calls
90
77
  * and its pause): its `paid` and `pause` are kept, so a paid request is admitted on the run's cap before it is sent and
91
78
  * settled there, never booked beside it where the cap does not judge it. */
@@ -102,17 +89,24 @@ export declare function paidRequest(fee: Fee, send: () => Promise<Response>): Pr
102
89
  /** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
103
90
  export declare const paidLedger: () => PaidBooking | undefined;
104
91
  /** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
105
- * or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold). */
106
- export declare function paidStep<T>(paid: PaidBooking, call: string, fee: {
92
+ * or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold). One refused
93
+ * for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
94
+ * paidCall pauses: a step outside any host tool call (a pi-native tool's, the browser's) passes the run's own. */
95
+ export declare function paidStep<T>(paid: PaidBooking, call: string | undefined, fee: {
107
96
  name: string;
108
97
  holdUsd: number;
109
98
  basis: string;
110
99
  by: string;
100
+ tool?: string;
101
+ tag?: string;
102
+ owed?: true;
103
+ hold?: true;
104
+ ref?: string;
111
105
  }, run: () => Promise<T>, chargeOf: (outcome: {
112
106
  result: T;
113
107
  } | {
114
108
  thrown: unknown;
115
- }) => number | null): Promise<{
109
+ }) => number | null, pause?: Ledger["pause"]): Promise<{
116
110
  refused: string;
117
111
  } | {
118
112
  result: T;
@@ -15,8 +15,7 @@
15
15
  // tool books without the call passed down to it.
16
16
  import { AsyncLocalStorage } from "node:async_hooks";
17
17
  import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
18
- import { TOOL_COST, TOOL_STARTED } from "@parcha/pi-durable-agent/timeline";
19
- import { BARRIER, JOURNAL_SYNCHRONOUS, syncNow } from "@parcha/pi-durable-disk";
18
+ import { TOOL_COST, TOOL_STARTED } from "./timeline/index.js";
20
19
  import { paidCall, SPEND_CAP_REACHED } from "./cap.js";
21
20
  /** Parallel's published prices (https://docs.parallel.ai/getting-started/pricing, read 2026-11-03): a `fast` search
22
21
  * $1 per 1,000 requests for up to 10 results, each further result $1 per 1,000; an extract $1 per 1,000 URLs. */
@@ -58,65 +57,24 @@ const roomOf = (error) => {
58
57
  // Its code rides with it: the model request the pause refuses next is the cap's refusal (Refusal.code), never a failure.
59
58
  return { refuse: String(given.message), code: SPEND_CAP_REACHED, forGood: false, figures: given.figures };
60
59
  };
61
- /** A paid step refused for room pauses the run, through the call's ledger (Ledger.pause), before its refusal is told. */
62
- const pauseOn = async (error) => {
60
+ /** A paid step refused for room pauses the run, through `pause` (the call's ledger's, Ledger.pause, by default), before
61
+ * its refusal is told. */
62
+ const pauseOn = async (error, pause = ledgers.getStore()?.pause) => {
63
63
  const room = roomOf(error);
64
- const pause = ledgers.getStore()?.pause;
65
64
  if (room && pause)
66
65
  await pause(room);
67
66
  };
68
67
  const ledgers = new AsyncLocalStorage();
69
- /** The run process's own commit to its run's root, outside any one call's turn (app.ts sets it once the run's harness is
70
- * open). A request's settle (TOOL_COST) is written there: once a turn is stopped, its tool call can no longer commit
71
- * (pi-durable refuses a task with a durable abort mark), though the request was sent and its charge stands. */
72
- let rootRecord;
73
- /** The run's store, for the barrier after each hold (writeHold): set with the root's commit, once the run is open. */
74
- let holdStore;
75
- /** The run journal's level: the store's own once one is open, this before (FULL syncs every commit, NORMAL only at a
76
- * barrier). */
77
- let journalLevel = JOURNAL_SYNCHRONOUS;
78
- export const settleIn = (record, store, journal = JOURNAL_SYNCHRONOUS) => {
79
- rootRecord = record;
80
- holdStore = store;
81
- // Only a test passes `journal`, to run the barriers at NORMAL before the run journal is NORMAL (pi-durable-disk 2b).
82
- journalLevel = journal;
83
- };
84
- /** Whether a barrier on the run journal has nothing to sync: no store open, while the journal syncs only at barriers. A
85
- * hold or a start mark written then would sit in the store with nothing to make it durable, so none is written. */
86
- export const noStoreToSync = (store) => store === undefined && journalLevel !== "FULL";
87
- /** A hold that could not be made durable (writeHold): nothing was sent. Its message says why, after "was not sent: ". */
88
- export class HoldNotDurable extends Error {
89
- name = "HoldNotDurable";
90
- }
91
- /** The run's journal a hold is synced in (settleIn), for another barrier before a paid effect: browser-cost.ts'. */
92
- export const runJournal = () => holdStore;
93
- /** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit), then the
94
- * run journal's barrier (pi-durable-disk barriers.ts, paidToolHold): the hold is on disk before the call is sent, so a
95
- * box loss never leaves a sent call the cap does not count. Every paid call writes its hold here: a paid request
96
- * (paidRequest), monid.run (monid.ts) and a priced MCP call (mcp-gateway.ts), so a new paid tool gets the sync with it.
97
- * Whatever throws, the caller sends nothing (holdRefusal says why): with no store to sync it writes no hold
98
- * (HoldNotDurable); a write that fails throws its own error; a sync that fails after the write settles the hold at $0
99
- * under its call (best effort), so no cap counts a call that never left, and throws HoldNotDurable. */
68
+ /** A paid call's hold (TOOL_STARTED, at what the cap holds it at), written by `write` (the call's own commit) before the
69
+ * call is sent. Every paid call off the run's one ledger writes its hold here: a paid request (paidRequest) and
70
+ * monid.run (monid.ts). A write that fails throws its own error, and the caller sends nothing (holdRefusal says why). */
100
71
  export async function writeHold(write, data) {
101
- if (noStoreToSync(holdStore))
102
- throw new HoldNotDurable("the run's store is not open, so its hold cannot be made durable");
103
72
  await write(TOOL_STARTED, data);
104
- try {
105
- await syncNow(holdStore, BARRIER.paidToolHold);
106
- }
107
- catch (error) {
108
- const { heldUsd: _held, ...label } = data;
109
- await write(TOOL_COST, { ...label, usd: 0 }).catch(() => undefined);
110
- throw new HoldNotDurable(`its hold could not be made durable (${String(error?.message ?? error).slice(0, 200)})`);
111
- }
112
73
  }
113
- /** What a paid call that writeHold refused tells the model: `name` was not sent, and why. */
114
- export const holdRefusal = (name, error) => error instanceof HoldNotDurable ? `${name} was not sent: ${error.message}` : `${name} was not sent: its mark could not be written (${String(error?.message ?? error).slice(0, 200)})`;
115
- /** A settle of `kind` written to the run's root (settleIn), when that is set; else undefined, for the caller's own commit.
116
- * monid.run's settle goes here too. */
117
- export const settleOnRoot = (kind, data) => rootRecord?.(kind, data);
118
- /** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) is the call's own
119
- * commit, so a stopped turn sends nothing new; its settle goes to the run's root when that is set (settleIn). On the
74
+ /** What a paid call whose hold writeHold could not write tells the model: `name` was not sent, and why. */
75
+ export const holdRefusal = (name, error) => `${name} was not sent: its mark could not be written (${String(error?.message ?? error).slice(0, 200)})`;
76
+ /** The ledger of a tool call: its id, and its commits to the run's store. Its mark (TOOL_STARTED) and its settle are the
77
+ * call's own commits, so a stopped turn sends nothing new. On the
120
78
  * runner the call runs inside the run's one ledger (the adapter loop's bookedIn, which carries the run's paid tool calls
121
79
  * and its pause): its `paid` and `pause` are kept, so a paid request is admitted on the run's cap before it is sent and
122
80
  * settled there, never booked beside it where the cap does not judge it. */
@@ -124,7 +82,7 @@ export const ledgerOf = (api, context) => {
124
82
  const outer = ledgers.getStore();
125
83
  return {
126
84
  call: api.callId,
127
- record: (kind, data) => ((kind === TOOL_COST ? settleOnRoot(kind, data) : undefined) ?? api.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind, data })), context)),
85
+ record: (kind, data) => api.commit(async (tx) => void (await tx.appendEntry(ROOT_CONVERSATION_ID, { kind, data })), context),
128
86
  ...(outer?.paid ? { paid: outer.paid } : {}),
129
87
  ...(outer?.pause ? { pause: outer.pause } : {}),
130
88
  };
@@ -182,16 +140,22 @@ let paidSeq = 0;
182
140
  /** The run's one ledger the current call books on (Ledger.paid), when it has one: the runner's. */
183
141
  export const paidLedger = () => ledgers.getStore()?.paid;
184
142
  /** One paid step on the run's one ledger `paid`, under call `call`: admitted at `holdUsd` (refused unsent: the cap's words,
185
- * or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold). */
186
- export async function paidStep(paid, call, fee, run, chargeOf) {
187
- const id = `${call}#${(paidSeq += 1)}`;
143
+ * or why its hold could not be kept), then `run`, then settled at `chargeOf` its outcome (null: at its hold). One refused
144
+ * for room pauses the run through `pause`, else through the ledger of the call it runs in (bookedIn's), as main's
145
+ * paidCall pauses: a step outside any host tool call (a pi-native tool's, the browser's) passes the run's own. */
146
+ export async function paidStep(paid, call, fee, run, chargeOf, pause) {
147
+ const id = `${call ?? fee.ref ?? fee.name}#${(paidSeq += 1)}`;
148
+ let admitted;
188
149
  try {
189
- await paid.admit({ id, name: fee.name, holdUsd: fee.holdUsd, basis: fee.basis, call, chargedBy: fee.by });
150
+ admitted = await paid.admit({ id, name: fee.name, holdUsd: fee.holdUsd, basis: fee.basis, ...(call === undefined ? {} : { call }), chargedBy: fee.by, ...(fee.tool ? { tool: fee.tool } : {}), ...(fee.tag ? { tag: fee.tag } : {}), ...(fee.owed ? { owed: true } : {}), ...(fee.hold ? { hold: true } : {}), ...(fee.ref === undefined ? {} : { ref: fee.ref }) });
190
151
  }
191
152
  catch (error) {
192
- await pauseOn(error);
153
+ await pauseOn(error, pause);
193
154
  return { refused: error?.code === "spend_cap_reached" ? String(error.message) : holdRefusal(fee.name, error) };
194
155
  }
156
+ // Its ref booked already (by this claim or an earlier one): no step was opened, so nothing is settled.
157
+ if (admitted?.booked === true)
158
+ return { result: await run() };
195
159
  let outcome;
196
160
  try {
197
161
  outcome = { result: await run() };
@@ -199,7 +163,8 @@ export async function paidStep(paid, call, fee, run, chargeOf) {
199
163
  catch (thrown) {
200
164
  outcome = { thrown };
201
165
  }
202
- await paid.settle(id, chargeOf(outcome)).catch(() => undefined);
166
+ // A hold-only step (`hold`) is given back, never a charge: its money is booked by its own charges' steps.
167
+ await (fee.hold ? paid.settle(id, 0, { givenBack: true }) : paid.settle(id, chargeOf(outcome))).catch(() => undefined);
203
168
  if ("thrown" in outcome)
204
169
  throw outcome.thrown;
205
170
  return outcome;
@@ -210,7 +175,7 @@ export async function paidStep(paid, call, fee, run, chargeOf) {
210
175
  async function paidOn(paid, call, fee, send, chargeOf) {
211
176
  const id = `${call}#${(paidSeq += 1)}`;
212
177
  try {
213
- await paid.admit({ id, name: fee.name, holdUsd: fee.usd, basis: fee.basis, call, chargedBy: fee.by });
178
+ await paid.admit({ id, name: fee.name, tool: fee.tool, holdUsd: fee.usd, basis: fee.basis, call, chargedBy: fee.by });
214
179
  }
215
180
  catch (error) {
216
181
  await pauseOn(error);
package/dist/pause.d.ts CHANGED
@@ -1,11 +1,5 @@
1
- export declare const RUN_PAUSED = "paused";
2
- export declare const NODE_LOG = "nodes.jsonl";
3
- export declare const LIVE_VIEW = "live.json";
4
- export declare const pausedIn: (root: string) => boolean;
5
- /** `fn`, waiting before each call while the run at `root` is paused. A cancel, or the call's own signal aborting, lets
6
- * the call go to meet its abort. */
7
- export declare function gated<P, R>(root: string, fn: (params: P) => Promise<R>): (params: P) => Promise<R>;
8
- /** One line of the node log. `path` is the execution path; `item` the map item's index, null outside a map. */
1
+ /** One line of the node log (the runner's KINDS.nodeEffect entries). `path` is the execution path; `item` the map item's
2
+ * index, null outside a map. */
9
3
  export type NodeLine = {
10
4
  t: "node.start" | "node.end";
11
5
  path: string;
@@ -34,8 +28,6 @@ export type NodeLine = {
34
28
  error_truncated?: boolean;
35
29
  at: string;
36
30
  };
37
- /** The node log of the run at `root`, in order; a torn last line is left out. */
38
- export declare function readNodeLog(root: string): Promise<NodeLine[]>;
39
31
  /** The llm calls the node log says answered, in order: a run's `llmRead` counts them, and its cost reads the rest. */
40
32
  export declare const llmAnswers: (lines: readonly NodeLine[]) => {
41
33
  t: "effect.end";
@@ -55,14 +47,5 @@ export type LiveView = {
55
47
  pin: Record<string, unknown>;
56
48
  receipts: Array<Record<string, unknown>>;
57
49
  };
58
- /** The run's live view writer: `receipts` are the ones earlier processes recorded; `driver` is handed over once the
59
- * workflow's driver is open. It rewrites `live.json` every 300 ms while something changed, and once more at `stop`. */
60
- export declare function liveView(root: string, receipts: Array<Record<string, unknown>>): {
61
- driver(next: {
62
- pinJson(): string;
63
- }): void;
64
- receipt(receipt: Record<string, unknown>): void;
65
- stop(): void;
66
- };
67
50
  /** The live view of the run at `root`; undefined when its process wrote none, or it does not parse. */
68
51
  export declare function readLiveView(root: string): Promise<LiveView | undefined>;
package/dist/pause.js CHANGED
@@ -1,82 +1,13 @@
1
- // A workflow run's pause and its node log, both files in the run's directory beside serve.json.
1
+ // A workflow run's node log and live view, as the graph reads them.
2
2
  //
3
- // Pause: POST /v2/runs/{id}/pause writes the mark `paused`; resume removes it. The run's process gates each node's start,
4
- // each model call and each decision on it: what is in flight finishes, and nothing new starts while the mark is there.
5
- // The gate sits before the durable admission of a call and before a call node's deadline is armed, so a node waiting at
6
- // it was never booked and a kill while paused interrupts nothing. Being a file, a pause outlives the server and the run's
7
- // process.
3
+ // Node log: one line per node start and end and per call's start and end with its input and output (the runner's
4
+ // KINDS.nodeEffect entries), so GET /v2/runs/{id}/graph shows timings and call I/O while the run goes.
8
5
  //
9
- // Node log: `nodes.jsonl`, one JSON line per node start and end and per call's start and end with its input and output,
10
- // appended by the run's process as they happen, so GET /v2/runs/{id}/graph shows timings and call I/O while the run goes.
11
- //
12
- // Live view: `live.json`, the driver's frame and the run's decision receipts, rewritten whole by the run's process when
13
- // they change. The run's process holds its store exclusively (pi-durable-disk's exclusive profile: no other connection
14
- // reads it until the process exits), so this file is what GET /v2/runs/{id}/graph reads while the run goes.
15
- import { existsSync, renameSync, writeFileSync } from "node:fs";
6
+ // Live view: `live.json`, the driver's frame and the run's decision receipts, as GET /v2/runs/{id}/graph reads it.
16
7
  import { join } from "node:path";
17
- import { RUN_CANCELLED } from "./files.js";
18
- export const RUN_PAUSED = "paused";
19
- export const NODE_LOG = "nodes.jsonl";
20
- export const LIVE_VIEW = "live.json";
21
- const LIVE_MS = 300;
22
- const POLL_MS = 250;
23
- export const pausedIn = (root) => existsSync(join(root, RUN_PAUSED));
24
- /** `fn`, waiting before each call while the run at `root` is paused. A cancel, or the call's own signal aborting, lets
25
- * the call go to meet its abort. */
26
- export function gated(root, fn) {
27
- return async (params) => {
28
- const signal = params?.signal instanceof AbortSignal ? params.signal : undefined;
29
- while (pausedIn(root) && !existsSync(join(root, RUN_CANCELLED)) && !signal?.aborted)
30
- await new Promise((resolve) => setTimeout(resolve, POLL_MS));
31
- return fn(params);
32
- };
33
- }
34
- /** The node log of the run at `root`, in order; a torn last line is left out. */
35
- export async function readNodeLog(root) {
36
- const { readFile } = await import("node:fs/promises");
37
- const text = await readFile(join(root, NODE_LOG), "utf8").catch(() => "");
38
- const out = [];
39
- for (const line of text.split("\n")) {
40
- if (!line)
41
- continue;
42
- try {
43
- out.push(JSON.parse(line));
44
- }
45
- catch { }
46
- }
47
- return out;
48
- }
8
+ const LIVE_VIEW = "live.json";
49
9
  /** The llm calls the node log says answered, in order: a run's `llmRead` counts them, and its cost reads the rest. */
50
10
  export const llmAnswers = (lines) => lines.filter((line) => line.t === "effect.end" && line.tool === "llm" && line.status === "done");
51
- /** The run's live view writer: `receipts` are the ones earlier processes recorded; `driver` is handed over once the
52
- * workflow's driver is open. It rewrites `live.json` every 300 ms while something changed, and once more at `stop`. */
53
- export function liveView(root, receipts) {
54
- let driver;
55
- let last = "";
56
- const file = join(root, LIVE_VIEW);
57
- const write = () => {
58
- if (!driver)
59
- return;
60
- try {
61
- const text = `{"at":${JSON.stringify(new Date().toISOString())},"receipts":${JSON.stringify(receipts)},"pin":${driver.pinJson()}}`;
62
- // The time is left out of the comparison: an unchanged view is not written again.
63
- const same = text.slice(text.indexOf(',"receipts":'));
64
- if (same === last)
65
- return;
66
- writeFileSync(`${file}.tmp`, text, { mode: 0o600 });
67
- renameSync(`${file}.tmp`, file);
68
- last = same;
69
- }
70
- catch { }
71
- };
72
- const timer = setInterval(write, LIVE_MS);
73
- timer.unref();
74
- return {
75
- driver(next) { driver = next; write(); },
76
- receipt(receipt) { receipts.push(receipt); },
77
- stop() { clearInterval(timer); write(); },
78
- };
79
- }
80
11
  /** The live view of the run at `root`; undefined when its process wrote none, or it does not parse. */
81
12
  export async function readLiveView(root) {
82
13
  const { readFile } = await import("node:fs/promises");
@@ -3,6 +3,9 @@ import { createProvider } from "@earendil-works/pi-ai/models";
3
3
  import type { SessionPort } from "@parcha/agentrun-kernel";
4
4
  /** The provider id the port's one model is listed under. */
5
5
  export declare const PORT_PROVIDER = "agentrun-session";
6
+ /** The provider id a tier's port model is listed under (tieredModels): the run's model of that tier, on a proxy of its
7
+ * own beside the session's (AdapterSession.port's `tier`). */
8
+ export declare const tierProvider: (tier: string) => string;
6
9
  /** Where pi-ai's client of `api` is pointed to reach a session's proxy at `url`: Anthropic's SDK adds /v1/messages to its
7
10
  * base; OpenAI's adds /responses to a base that holds /v1. The one rule for the port's models and pi's own (runner
8
11
  * adapters/pi.ts). */
@@ -48,6 +51,10 @@ export type PortModels = {
48
51
  completeSimple(model: Model<Api>, context: Context, options?: SimpleStreamOptions): Promise<AssistantMessage>;
49
52
  };
50
53
  /** Models over `port` (the session's, read at each request: undefined until a drive has attached a proxy, and anew for
51
- * each drive), one model named by any provider and id: the session's own. `like`: the catalog's entry for the model the
52
- * run is priced by, whose reasoning, limits and price the port's model takes. */
53
- export declare function portModels(port: () => SessionPort | undefined, like?: Partial<Model<Api>>): Promise<PortModels>;
54
+ * each drive), one model named by any provider and id: the session's own, listed under `provider`. `like`: the
55
+ * catalog's entry for the model the run is priced by, whose reasoning, limits and price the port's model takes. */
56
+ export declare function portModels(port: () => SessionPort | undefined, like?: Partial<Model<Api>>, provider?: string): Promise<PortModels>;
57
+ /** Port models of several ports as one registry (learned-workflow.ts takes one): each listed under its own provider id
58
+ * (PORT_PROVIDER for the session's, tierProvider(tier) for a tier's), a model's request sent through the port it came
59
+ * from. */
60
+ export declare function tieredModels(byProvider: ReadonlyMap<string, PortModels>): PortModels;
@@ -3,6 +3,9 @@ import { openAIResponsesApi } from "@earendil-works/pi-ai/api/openai-responses.l
3
3
  import { createProvider } from "@earendil-works/pi-ai/models";
4
4
  /** The provider id the port's one model is listed under. */
5
5
  export const PORT_PROVIDER = "agentrun-session";
6
+ /** The provider id a tier's port model is listed under (tieredModels): the run's model of that tier, on a proxy of its
7
+ * own beside the session's (AdapterSession.port's `tier`). */
8
+ export const tierProvider = (tier) => `${PORT_PROVIDER}-${tier}`;
6
9
  /** Where pi-ai's client of `api` is pointed to reach a session's proxy at `url`: Anthropic's SDK adds /v1/messages to its
7
10
  * base; OpenAI's adds /responses to a base that holds /v1. The one rule for the port's models and pi's own (runner
8
11
  * adapters/pi.ts). */
@@ -43,9 +46,9 @@ export function sessionProvider(api, proxy, model, options) {
43
46
  });
44
47
  }
45
48
  /** Models over `port` (the session's, read at each request: undefined until a drive has attached a proxy, and anew for
46
- * each drive), one model named by any provider and id: the session's own. `like`: the catalog's entry for the model the
47
- * run is priced by, whose reasoning, limits and price the port's model takes. */
48
- export async function portModels(port, like) {
49
+ * each drive), one model named by any provider and id: the session's own, listed under `provider`. `like`: the
50
+ * catalog's entry for the model the run is priced by, whose reasoning, limits and price the port's model takes. */
51
+ export async function portModels(port, like, provider = PORT_PROVIDER) {
49
52
  const [{ createModels, createProvider }, { anthropicMessagesApi }, { openAIResponsesApi }] = await Promise.all([
50
53
  import("@earendil-works/pi-ai/models"),
51
54
  import("@earendil-works/pi-ai/api/anthropic-messages.lazy"),
@@ -64,15 +67,15 @@ export async function portModels(port, like) {
64
67
  // The side key as the proxy reads a key (a bearer token), and no beta header pi-ai would add of its own: the session's
65
68
  // policy admits the betas its harness sends, and these requests need none.
66
69
  const headers = { authorization: `Bearer ${now.key}`, ...(now.api === "anthropic-messages" ? { "anthropic-beta": null } : {}) };
67
- const model = sessionModel(now.api, now.url, now.model, { provider: PORT_PROVIDER, headers, ...(like ? { like } : {}), reasoning: true });
70
+ const model = sessionModel(now.api, now.url, now.model, { provider, headers, ...(like ? { like } : {}), reasoning: true });
68
71
  const models = createModels({});
69
72
  models.setProvider(createProvider({
70
- id: PORT_PROVIDER, baseUrl,
73
+ id: provider, baseUrl,
71
74
  auth: { apiKey: { name: "the session's side key", resolve: async () => ({ auth: { apiKey: now.key }, source: "session" }) } },
72
75
  models: [model],
73
76
  api: now.api === "anthropic-messages" ? anthropicMessagesApi() : openAIResponsesApi(),
74
77
  }));
75
- built = { at, models, model: models.getModel(PORT_PROVIDER, now.model) };
78
+ built = { at, models, model: models.getModel(provider, now.model) };
76
79
  return built;
77
80
  };
78
81
  const registry = (model) => {
@@ -91,3 +94,20 @@ export async function portModels(port, like) {
91
94
  completeSimple: (model, context, options) => registry(model).completeSimple(model, context, options),
92
95
  };
93
96
  }
97
+ /** Port models of several ports as one registry (learned-workflow.ts takes one): each listed under its own provider id
98
+ * (PORT_PROVIDER for the session's, tierProvider(tier) for a tier's), a model's request sent through the port it came
99
+ * from. */
100
+ export function tieredModels(byProvider) {
101
+ const of = (model) => {
102
+ const port = byProvider.get(model.provider);
103
+ if (!port)
104
+ throw new Error(`no port of the run lists the model ${model.provider}/${model.id}`);
105
+ return port;
106
+ };
107
+ return {
108
+ getModel: (provider, id) => byProvider.get(provider)?.getModel(provider, id),
109
+ getModels: () => [...byProvider.values()].flatMap((port) => port.getModels()),
110
+ streamSimple: (model, context, options) => of(model).streamSimple(model, context, options),
111
+ completeSimple: (model, context, options) => of(model).completeSimple(model, context, options),
112
+ };
113
+ }
package/dist/propose.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { DraftAsk } from "./learn/skills.js";
1
2
  import { type Problem } from "./learn/index.js";
2
3
  import { type Turn } from "./learning.js";
3
4
  import type { Workspace } from "./workspace/index.js";
@@ -38,4 +39,5 @@ export declare const proposeRun: (input: {
38
39
  tools?: readonly string[];
39
40
  gated?: Readonly<Record<string, string>>;
40
41
  deniedBy?: Readonly<Record<string, "agent" | "server" | "default">>;
42
+ ask?: DraftAsk;
41
43
  }) => Promise<Proposed>;