@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
@@ -1,25 +1,35 @@
1
- // GET /runs/{id}/learning over the store: the run's learning view (store-reads/learning.ts runLearningOverStore), cut by the
2
- // run's one cut (run-cut.ts) as its words are: every secret this server keeps and every sign-in pointer the run was
3
- // handed, so a note's name or a proposal's words holding one shows none of it. A run whose hand can't be read back here
4
- // is refused (403, in the view's words), as its graph and its files are.
1
+ // GET /runs/{id}/learning and GET /runs/{id}/learning/diff over the store: the run's learning view (store-reads/learning.ts
2
+ // runLearningOverStore) and its learning diff (learning-routes.ts runDiffOverStore), each cut by the run's one cut
3
+ // (run-cut.ts) as its words are: every secret this server keeps and every sign-in pointer the run was handed, and every
4
+ // pointer of its agent's own sign-ins, live and forgotten (agentPointers), as the agent's learning routes cut them, so a
5
+ // note's name, a patch or a proposal's words holding one shows none of it. A run whose hand can't be read back here is
6
+ // refused (403, in the view's words), as its graph and its files are; so is one whose agent's sign-in can't be.
5
7
  import { ApiError } from "./errors.js";
8
+ import { agentPointers, WITHHELD_LEARNING } from "./handed-values.js";
6
9
  import { secretsShown } from "./learning.js";
7
10
  import { runCutValues } from "./run-cut.js";
8
11
  import { WITHHELD_SIGN_IN } from "./run-view.js";
9
12
  import { runLearningOverStore } from "./store-reads/learning.js";
10
13
  import { runDiffOverStore } from "./learning-routes.js";
11
- /** Run `runId`'s learning as GET /runs/{id}/learning serves it, or ApiError forbidden for a withheld run. */
12
- export async function servedRunLearning(deps, store, runId) {
14
+ /** What run `runId`'s learning reads are cut of: the run's one cut and its agent's own sign-in pointers. ApiError forbidden
15
+ * for a withheld run, and for one whose agent has a pointer that can't be read here (its learning may hold it). */
16
+ async function learningCutOf(deps, store, runId) {
13
17
  const cut = await runCutValues(deps, store, runId);
14
18
  if (cut === "unreadable")
15
19
  throw new ApiError("forbidden", WITHHELD_SIGN_IN);
16
- return runLearningOverStore(store, runId, secretsShown(cut.values), cut.values);
20
+ const agentId = (await store.runs.get(runId))?.agentId;
21
+ const pointers = agentId ? await agentPointers(deps.signIns, agentId) : [];
22
+ if (pointers === "unreadable")
23
+ throw new ApiError("forbidden", WITHHELD_LEARNING);
24
+ return [...cut.values, ...pointers];
25
+ }
26
+ /** Run `runId`'s learning as GET /runs/{id}/learning serves it, or ApiError forbidden for a withheld run. */
27
+ export async function servedRunLearning(deps, store, runId) {
28
+ const values = await learningCutOf(deps, store, runId);
29
+ return runLearningOverStore(store, runId, secretsShown(values), values, deps.statuses);
17
30
  }
18
- /** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut by the
19
- * run's one cut, or ApiError forbidden for a withheld run. */
31
+ /** Run `runId`'s learning diff as GET /runs/{id}/learning/diff serves it (learning-routes.ts runDiffOverStore), cut as its
32
+ * learning is, or ApiError forbidden for a withheld run. */
20
33
  export async function servedRunDiff(deps, store, data, runId) {
21
- const cut = await runCutValues(deps, store, runId);
22
- if (cut === "unreadable")
23
- throw new ApiError("forbidden", WITHHELD_SIGN_IN);
24
- return runDiffOverStore(data, store, runId, secretsShown(cut.values));
34
+ return runDiffOverStore(data, store, runId, secretsShown(await learningCutOf(deps, store, runId)));
25
35
  }
@@ -1,8 +1,9 @@
1
1
  import type { Context } from "@earendil-works/chord";
2
- import type { TimelineEvent } from "@parcha/pi-durable-agent/timeline";
2
+ import type { TimelineEvent } from "./timeline/index.js";
3
3
  import type { IncomingMessage, ServerResponse } from "node:http";
4
4
  import { type Page } from "./rows.js";
5
5
  import { type FileView } from "./run-files.js";
6
+ import type { RunStated } from "./store-view.js";
6
7
  import { type Store } from "./store/index.js";
7
8
  import type { Workspace } from "./workspace/index.js";
8
9
  /** The most files a list answers with (server.ts FILE_LIST_CAP). */
@@ -23,8 +24,9 @@ export interface RunReadsDeps {
23
24
  liveViewer?(runId: string): Promise<{
24
25
  viewer: string;
25
26
  } | undefined>;
26
- /** The run's v2 view as the store serves it (viewOverStore): its status, kind, revision and times, for the graph. */
27
- runView(store: RunReadsStore, runId: string): Promise<Record<string, unknown> | undefined>;
27
+ /** The run's facts (store-view.ts factsOverStore): its status, kind, revision, times and whether it is withheld, for the
28
+ * graph, with no word of the run served, so a graph read redacts nothing outside its own cached parts. */
29
+ runFacts(store: RunReadsStore, runId: string): Promise<RunStated | undefined>;
28
30
  /** Whether the run's served output is withheld: its browser sign-in can't be read, so nothing it said is shown
29
31
  * (store-view's `unshown`). The graph refuses when it is, as the route did. */
30
32
  withheld(store: RunReadsStore, runId: string): Promise<boolean>;
@@ -6,7 +6,8 @@ import { costOf, WITHHELD_SIGN_IN } from "./run-view.js";
6
6
  import { ChangeClock, RowLog } from "./rows.js";
7
7
  import { listFiles, sendFile } from "./run-files.js";
8
8
  import { readLaunchBody } from "./run-launch.js";
9
- import { runTimeline } from "./store-reads/journal.js";
9
+ import { costIsBooked } from "./runner/metrics.js";
10
+ import { runEntries, runTimeline } from "./store-reads/journal.js";
10
11
  import { StoreLaunchMissing } from "./store/index.js";
11
12
  import { isUnavailable, recheckPlane, whyUnavailable } from "./tool-plane.js";
12
13
  /** The most files a list answers with (server.ts FILE_LIST_CAP). */
@@ -67,35 +68,40 @@ const graphParts = new PartCache(GRAPH_CACHE_BYTES);
67
68
  * runGraph, the store path). An agentic run has none (404, the route's words); a run whose output is withheld is refused
68
69
  * (403 WITHHELD_SIGN_IN), as the route refused it, before anything of it is served. */
69
70
  export async function runGraphView(store, runId, deps) {
70
- const view = await deps.runView(store, runId);
71
- if (!view)
71
+ // The run's facts, never its served view: the view serves the run's words (its output, its title), each a redaction
72
+ // pass on every read, and the graph needs none of them. Its own parts are redacted once per held set (servedGraphView).
73
+ const facts = await deps.runFacts(store, runId);
74
+ if (!facts)
72
75
  throw new ApiError("not_found", `There is no run ${runId}.`);
73
- if (view.kind !== "workflow")
76
+ if (facts.kind !== "workflow")
74
77
  throw new ApiError("not_found", `the run ${runId} is an agentic run; only a workflow run has a graph`);
75
- if (await deps.withheld(store, runId))
78
+ if (facts.unshown)
76
79
  throw new ApiError("forbidden", WITHHELD_SIGN_IN);
77
- const revision = await store.agents.revision(String(view.revision));
80
+ const revision = await store.agents.revision(facts.revision);
78
81
  const workflow = revision?.body?.workflow;
79
- const status = String(view.status);
80
- const ended = view.ended_at !== null;
82
+ const status = facts.status;
83
+ const ended = facts.endedAt !== null;
81
84
  const launch = await store.runs.launch(runId).then((row) => readLaunchBody(row.body), (error) => (error instanceof StoreLaunchMissing ? undefined : Promise.reject(error)));
82
- // The run's model-node cost from its rows once it ended (0 before), as the old graph read it from run.rows.
85
+ // The run's model-node cost from its rows once it ended (0 before), as the old graph read it from run.rows: a workflow's
86
+ // usage row is its booking's (store-reads/journal.ts bookedUsage), its model nodes', its `llm` calls' and its paid
87
+ // tools', never its decisions', which the graph sums from their receipts. Its `llm` calls' answers are then all in it
88
+ // (llmRead), never counted again from the node log.
83
89
  const rows = ended ? await runTimeline(store, runId, deps.context) : [];
90
+ const booked = ended && costIsBooked(await runEntries(store, runId, deps.context), false);
84
91
  // Every field it serves is cut by the run's one cut (graph-served.ts servedGraphView): its nodes, decisions and calls by
85
92
  // servedPart, and every other field (its workflow, its structure, any added later) whole.
86
93
  const cut = await deps.cutValues(store, runId);
87
94
  if (cut === "unreadable")
88
95
  throw new ApiError("forbidden", WITHHELD_SIGN_IN);
89
96
  return servedGraphView(await runGraph({
90
- run: { id: runId, agent: String(view.agent_id), revision: String(view.revision), status, paused: status === "paused", startedAt: String(view.created_at), endedAt: view.ended_at },
97
+ run: { id: runId, agent: facts.agentId, revision: facts.revision, status, paused: status === "paused", startedAt: facts.createdAt, endedAt: facts.endedAt },
91
98
  ended,
92
99
  workflow,
93
- // No per-run store file and no run directory now: the store and a context carry the journal the graph reads.
94
- storeFile: "",
100
+ // No run directory now: the store and a context carry the journal the graph reads.
95
101
  root: "",
96
102
  input: launch?.input ?? {},
97
103
  modelCost: ended ? costOf(rows) : 0,
98
- llmRead: 0,
104
+ llmRead: booked ? Number.MAX_SAFE_INTEGER : 0,
99
105
  store,
100
106
  context: deps.context,
101
107
  }), cut.values, graphParts);
@@ -120,9 +126,14 @@ export function runTimelines(deps) {
120
126
  };
121
127
  const pollMs = deps.pollMs ?? 1_000;
122
128
  async function once(store, runId, after, limit) {
123
- const [rows, view] = await Promise.all([deps.timelineRows(store, runId, deps.context), deps.runView(store, runId)]);
129
+ // The view first, then the rows, never both at once: the journal only grows, so the rows read after the view hold
130
+ // every entry its status was read from. Read together, a message committed between the two reads gave a page that
131
+ // said working before the message row it works on (#2307), or a waiting status with its parked call's row still
132
+ // missing. The rows may run ahead of the status, never behind it.
133
+ const view = await deps.runView(store, runId);
124
134
  if (!view)
125
135
  throw new ApiError("not_found", `There is no run ${runId}.`);
136
+ const rows = await deps.timelineRows(store, runId, deps.context);
126
137
  const status = String(view.status);
127
138
  const state = String(view.state);
128
139
  const log = logOf(runId);
@@ -1,4 +1,4 @@
1
- import type { Revision } from "@parcha/pi-durable-agent";
1
+ import type { Revision } from "./agent-rows.js";
2
2
  import { type Tier } from "./model.js";
3
3
  /** The secrets a run may be handed: every one but the server's own and the decision keys, which go apart. */
4
4
  export declare const RUN_SECRETS: string[];
@@ -1,5 +1,6 @@
1
1
  import type { Context } from "@earendil-works/chord";
2
- import { type TimelineEvent } from "@parcha/pi-durable-agent/timeline";
2
+ import { type TimelineEvent } from "./timeline/index.js";
3
+ import { type ItemStatus } from "./learning.js";
3
4
  import { type SignInReader } from "./run-view.js";
4
5
  import { type Store } from "./store/store.js";
5
6
  export type ServedTimelineDeps = {
@@ -7,6 +8,9 @@ export type ServedTimelineDeps = {
7
8
  readonly signIns?: SignInReader;
8
9
  /** The environment a run's model key is read from, with the keys a person saved (withSecrets, as main's plainKey). */
9
10
  readonly keyEnv: () => NodeJS.ProcessEnv;
11
+ /** Each learned item's status on an agent's learning folder's main (learning-routes.ts statusesOf): what a run held for
12
+ * its owner's OK reads as it stands there. None: as the merge wrote it. */
13
+ readonly statuses?: (agentId: string) => Promise<ReadonlyMap<string, ItemStatus> | undefined>;
10
14
  };
11
15
  /** Run `runId`'s Timeline rows as served: cut by its one cut set, its decision rows among them, its error rows in the
12
16
  * run's error's words; none for a run withheld. */
@@ -1,8 +1,14 @@
1
- import { TRIGGER_LABELS } from "@parcha/pi-durable-agent/timeline";
1
+ import { TRIGGER_LABELS } from "./timeline/index.js";
2
2
  import { withDecisions } from "./decision-rows.js";
3
+ import { currentLearning, holdsForOk, secretsShown } from "./learning.js";
4
+ import { withLearning } from "./learning-run.js";
5
+ import { runLearningEnd } from "./store-reads/learning.js";
3
6
  import { redacted } from "./key-refusal.js";
4
7
  import { runCutValues, runErrorWordsOf } from "./run-cut.js";
5
- import { answersOf, asksOf, shownOf, withApprovalRows, withAsks } from "./run-view.js";
8
+ import { answersOf, asksOf, shownOf, withApprovalRows, withAsks, withBudgetRows, withOverCap } from "./run-view.js";
9
+ import { launchOf } from "./handed-values.js";
10
+ import { capNowOf } from "./runner/journal-kinds.js";
11
+ import { overCapBound } from "./runner/metrics.js";
6
12
  import { journalRecords } from "./runner/journal-reader.js";
7
13
  import { decisionsOverStore } from "./store-reads/decisions.js";
8
14
  import { readRun } from "./store-reads/runs.js";
@@ -28,9 +34,18 @@ export async function servedTimelineRows(deps, store, runId, context) {
28
34
  // the run's view carries it and main's served Timeline did, so the console's "The agent asks" box reads that question,
29
35
  // never an earlier wait's words.
30
36
  // Its final answer whole, as the run's view serves it (store-reads/journal.ts wholeAnswers): a row's cut is no answer's.
31
- const options = { redact };
37
+ // A run that ended is read settled, as its view reads it: nothing of it is in flight, so a request it left unanswered
38
+ // is a cost unknown, never one still running.
39
+ const options = { redact, settled: ended };
32
40
  const timeline = await wholeAnswers(store, runId, context, await runTimeline(store, runId, context, options), options, wholeAnswerFor(values));
33
- const rows = withApprovalRows(withAsks(timeline), asksOf(records.entries), answersOf(records.entries, { final }), redact);
41
+ // A run whose booked spend passed its cap says so, by how much, after its usage row (run-view.ts withOverCap, as main's
42
+ // served Timeline did): at the cap as it stands (a raise taken counts, capNowOf), a cache miss within the bound of the
43
+ // requests since its spend last fit said as one (overCapBound).
44
+ const capNow = capNowOf((await launchOf(store, runId))?.maxCostUsd, records.entries);
45
+ const overCap = capNow === undefined ? timeline : withOverCap(timeline, capNow, overCapBound(records.entries, capNow));
46
+ // Each pause at its cap shown as the server's row, and the one it stands at now as its waiting row (withBudgetRows).
47
+ const capped = withBudgetRows(overCap, records.entries, { ended });
48
+ const rows = withApprovalRows(withAsks(capped), asksOf(records.entries), answersOf(records.entries, { final }), redact);
34
49
  // A workflow's decisions: their rows among the model nodes' by time, each text shown through the cut set, with as many
35
50
  // characters held back from a text stored cut as a held value takes in its widest form (main's decisionShown).
36
51
  const receipts = await decisionsOverStore(store, runId, context).catch(() => null);
@@ -42,14 +57,20 @@ export async function servedTimelineRows(deps, store, runId, context) {
42
57
  const words = await runErrorWordsOf(deps, store, runId, { workflow });
43
58
  if (words === "unreadable")
44
59
  return [];
60
+ // The run's learning row, once its learning was proposed, merged or dropped (learning-run.ts withLearning, main's row):
61
+ // its end from the store (runLearningEnd), what it held for the owner's OK read as the run's view reads it (on its agent's
62
+ // folder's main), its words cut by the same set.
63
+ const end = await runLearningEnd(store, runId);
64
+ const learning = end ? (holdsForOk(end) && run && deps.statuses ? currentLearning(end, await deps.statuses(run.agentId)) : end) : undefined;
65
+ const learned = withLearning(own, learning, secretsShown(values));
45
66
  // Each trigger the rows name, read once for this read: its name now, or none for one gone.
46
67
  const names = new Map();
47
- for (const row of own)
68
+ for (const row of learned)
48
69
  if (row.trigger && !names.has(row.trigger.id))
49
70
  names.set(row.trigger.id, (await store.triggers.get(row.trigger.id))?.name);
50
71
  // A refused key's plain words are its summary and its text alike; any other error keeps each in the one rule.
51
72
  const shown = shownOf(values);
52
- return own.map((row) => {
73
+ return learned.map((row) => {
53
74
  if (row.trigger)
54
75
  return named(row, names.get(row.trigger.id), redact);
55
76
  if (row.kind !== "error")
@@ -1,14 +1,13 @@
1
- import { type TimelineEvent } from "@parcha/pi-durable-agent/timeline";
2
- import type { RevisionKind } from "@parcha/pi-durable-agent";
1
+ import { type TimelineEvent } from "./timeline/index.js";
2
+ import type { RevisionKind } from "./agent-rows.js";
3
3
  import { type RefusalFigures } from "./cap.js";
4
4
  import type { Turns } from "./turns.js";
5
5
  import type { PendingAsk } from "./browser-person.js";
6
6
  import { type PendingApproval } from "./tool-gate.js";
7
- import { type SignIns } from "./sign-ins.js";
7
+ import { type signInReads } from "./sign-ins-store.js";
8
8
  /** The sign-in read surface a run's served view needs: a run's handed-pointer cut reads only `peek` (the agent's saved
9
- * pointer) and `forgotten` (its tombstoned ones). Both the old `new SignIns(...)` and the store-backed bridge
10
- * (sign-ins-store.ts signInsOverStore) satisfy it, so a view reads either path with no knowledge of which. */
11
- export type SignInReader = Pick<SignIns, "peek" | "forgotten">;
9
+ * pointer) and `forgotten` (its tombstoned ones), over the store (sign-ins-store.ts signInReads). */
10
+ export type SignInReader = ReturnType<typeof signInReads>;
12
11
  /** The run's cost from its usage row: null when a response's cost is unknown, 0 before any request. */
13
12
  export declare const costOf: (rows: readonly TimelineEvent[]) => number | null;
14
13
  /** What a run's paid tools charged (`tool`'s alone, when given; every other tool's with `others`), from the same rows its
@@ -48,9 +47,6 @@ export declare const overByMiss: (usd: number, cap: number, bound: number) => bo
48
47
  * so a run can pass its cap by its last request. The next request is then refused. `bound`: the requests' that ended since the cost last fit,
49
48
  * bound; when the run passed its cap by no more than it, the row says a cache miss did it, and the most it could have. */
50
49
  export declare function withOverCap(rows: TimelineEvent[], cap: number | undefined, bound?: number): TimelineEvent[];
51
- /** The waiting row of a run paused at its cap, after the refusal's row: "Waiting for you to raise the cap", and no
52
- * more: the refusal's words are the pause's (pending.said), which a client shows once, as its banner. */
53
- export declare const BUDGET_WAITING = "Waiting for you to raise the cap";
54
50
  /** The waiting row after each answered `ask_person` call, which the timeline module does not know. The question comes from
55
51
  * the call's row, whose label this module registers. The server fed its rows through this; the store-backed view feeds the
56
52
  * same rows through it, so a run waiting on a question reads the same pending. */
@@ -90,6 +86,7 @@ export type ApprovalAnswer = {
90
86
  export declare const withdrawn: (answer: ApprovalAnswer | undefined) => boolean;
91
87
  /** The least a journal entry a reader here reads is: its kind and its data. */
92
88
  type JournalEntry = {
89
+ id?: unknown;
93
90
  kind?: string;
94
91
  data?: unknown;
95
92
  };
@@ -111,10 +108,27 @@ export declare function asksOf(entries: readonly JournalEntry[]): Map<string, Ap
111
108
  export declare function answersOf(entries: readonly JournalEntry[], { final }?: {
112
109
  final?: "stopped" | "failed";
113
110
  }): Record<string, ApprovalAnswer>;
114
- /** Whether the run stands parked at its cap now (an active agentrun.budget park, no raise since): the store-backed fact the
115
- * status table reads (RunFacts.budgetWaiting), as the file-backed view read a workflow's pause file and an agentic run's
116
- * turn refusal. */
117
- export declare const budgetWaitingOf: (entries: readonly JournalEntry[]) => boolean;
111
+ /** The server's row of a run's pause at its cap, and its waiting row while it stands paused: the pause's own words are
112
+ * its pending budget's `said`, which a client shows once as its banner, so these rows say no more (#1768). */
113
+ export declare const BUDGET_PAUSED = "Paused at the run's cap";
114
+ export declare const BUDGET_WAITING = "Waiting for you to raise the cap";
115
+ /** `rows` with each pause at the run's cap shown (its agentrun.budget entry: the cap refused the next step for room, and
116
+ * nothing was sent): the server's `phase` row "Paused at the run's cap" (origin server, `paused: true`, its id ending
117
+ * NOTE_SUFFIX, so no message any turn took) where the pause came in the journal's order, kept as the run's history once
118
+ * a raise clears it; and, after the pause the run stands at now, its `waiting` row "Waiting for you to raise the cap".
119
+ * Each new row takes its time from the row before it. `ended`: the run is final (cancelled while paused, say), so it
120
+ * waits on nothing and shows no waiting row. */
121
+ export declare function withBudgetRows(rows: readonly TimelineEvent[], entries: readonly (JournalEntry & {
122
+ conversationId?: unknown;
123
+ })[], { ended }?: {
124
+ ended?: boolean;
125
+ }): TimelineEvent[];
126
+ /** The id of the cap park a run stands at now (its agentrun.budget entry's), or undefined when it is not parked: a raise's
127
+ * follow-up is sent as `agentrun:raise:<this>` (raiseFollowUpId), so a raise's answer names that message. */
128
+ export declare const activePauseOf: (entries: readonly JournalEntry[]) => string | undefined;
129
+ /** The id a raised run's follow-up turn is sent under: one per pause, so raises of the same pause (a retry, two at once)
130
+ * name the same message, and the runner's re-claim never sends it twice. */
131
+ export declare const raiseFollowUpId: (pause: string) => string;
118
132
  /** The budget card a run parked at its cap shows (pending, kind budget), from its agentrun.budget entry, the same way the
119
133
  * file-backed view built it from the run's pause mark (runs.ts workflowBudgetPending): its cap (the run's launch cap, else
120
134
  * the park's), what the cap counted as taken and the least the refused step needs, the raise offered (recomputed from
@@ -173,6 +187,8 @@ export interface RunView {
173
187
  * view, from the cap park entry): the moment reads them when `pausedAt` finds no turn refusal, so a run parked at its cap
174
188
  * reads paused either way. The file-backed view leaves this unset and the moment reads `pausedAt`. */
175
189
  pausedWords?: string;
190
+ /** The cap park the run stands at (activePauseOf), when the store-backed view knows it: the moment's `pause`. */
191
+ pause?: string;
176
192
  meta: RunViewMeta;
177
193
  }
178
194
  /** The facts statusOf reads from a run's files (its directory): a workflow paused at its cap, a workflow paused in its
@@ -182,9 +198,9 @@ export interface RunView {
182
198
  export interface RunFacts {
183
199
  /** A workflow run paused at its cap, as its process wrote it (budgetWaiting). */
184
200
  budgetWaiting(): boolean;
185
- /** A workflow run paused in its process (pausedIn(run.dir)). */
201
+ /** A workflow run paused (the store-backed view reads it from the run's journal). */
186
202
  paused(): boolean;
187
- /** The ask its agent made for the person in its browser the run waits on (askShown(run.dir, run.rows)). */
203
+ /** The ask its agent made for the person in its browser the run waits on (browser-commands.ts browserAsk, over its journal). */
188
204
  browserAsk(): PendingAsk | undefined;
189
205
  /** The ask its agent made for the person on its desktop or phone the run waits on (computer-commands.ts computerAsk). */
190
206
  computerAsk?(): ComputerAsk | undefined;
@@ -272,12 +288,6 @@ export type Pending = {
272
288
  export declare const pendingOf: (rows: readonly TimelineEvent[]) => Pending;
273
289
  /** The run's pending approval (`pending`, kind approval): the call that waits; else undefined. */
274
290
  export declare const approvalOf: (run: Pick<RunView, "approvals" | "meta">, redact: (text: string) => string) => PendingApproval | undefined;
275
- /** A run paused at its cap waits on a raise: its cap, what the cap counted as taken and the least the refused request
276
- * needs (its refusal's mark; none from a store written before it kept them), the raise it is offered (suggestedCap),
277
- * the refusal's words, and when it came (its error row's time). The figures are as the cap counts them, never rounded.
278
- * What was taken is the store's spend once its process is gone (`spentNow`), when that is lower: the refusal counted
279
- * requests still answering at what it held for them, and they have settled. */
280
- export declare const budgetPending: (run: RunView, spentNow?: number) => Pending | undefined;
281
291
  /** A run whose agent asked for the person in its browser waits on their hand-back: what it asked them to do, when it is
282
292
  * done, and when the ask expires. Never the session's tag or the live view's link. The two texts are the model's, so
283
293
  * redacted with the run's redactor (`redact`), as a tool call's arguments are: a held value it echoes never shows. */
@@ -327,6 +337,9 @@ export interface RunMoment {
327
337
  readonly pausedWords?: string;
328
338
  /** The run is paused at its cap (pausedAt): raising the cap resumes it. */
329
339
  readonly paused: boolean;
340
+ /** The cap park it stands at (its agentrun.budget entry's id, activePauseOf), when the store knows it: a raise's answer
341
+ * names the follow-up message the runner sends for it (raiseFollowUpId). */
342
+ readonly pause?: string;
330
343
  /** The run has a live process now (a runner holds its claim): a raise's cap holds from its next step, not the one under
331
344
  * way. */
332
345
  readonly live: boolean;
@@ -377,8 +390,10 @@ export declare const servedRunErrorWith: <E extends {
377
390
  * other words are while the run is hidden (`unshown`), as a list row read from disk withholds it. */
378
391
  export declare const servedReviewWith: <R extends {
379
392
  reason: string;
393
+ kind?: string | null;
394
+ node?: string | null;
380
395
  }>(shown: (text: string) => string, unshown: boolean | undefined, review: R | null) => R | null;
381
- /** The pointers a run was handed, read back to cut them (sign-ins.ts peek and forgotten), by its `sign_in_handed`: none
396
+ /** The pointers a run was handed, read back to cut them (sign-ins-store.ts peek and forgotten), by its `sign_in_handed`: none
382
397
  * for a run with no mark (it was never handed one); else, for each hash it names, the live or forgotten pointer whose
383
398
  * SHA-256 it is. `unreadable` when what it was handed can't be read back here: a MALFORMED mark, no vendor browser kept
384
399
  * beside the mark, the sign-ins file can't be read, or any of its hashes matches no pointer that opens (one under another
package/dist/run-view.js CHANGED
@@ -6,16 +6,17 @@
6
6
  // The pieces here so far: the cost reads (a run's cost, its paid tools' charges, the cost a view shows, what it has cost so
7
7
  // far when the total is unknown) and the served row transforms a view applies to the timeline (the over-cap row, the
8
8
  // paused run's waiting row). All read the same rows the timeline renders.
9
- import { chargedTool, isMessageRow, registerLabel, registerTurnEnding, scrubUrls } from "@parcha/pi-durable-agent/timeline";
9
+ import { chargedTool, isMessageRow, NOTE_SUFFIX, registerLabel, registerTurnEnding, scrubUrls } from "./timeline/index.js";
10
10
  import { CAP_TOLERANCE, FIT_TOLERANCE, money, roomRefusal } from "./cap.js";
11
11
  import { APPROVAL_ROW, previewOf } from "./tool-gate.js";
12
12
  import { ASK_TOOL } from "./tools.js";
13
13
  import { LEARNING_LABEL } from "./learning.js";
14
14
  import { builtinHarness } from "./harness-table.js";
15
15
  import { cutStrings, redacted, withoutLoopback } from "./key-refusal.js";
16
- import { pointerHash } from "./sign-ins.js";
16
+ import { pointerHash } from "./sign-ins-store.js";
17
17
  import { MIN_SECRET } from "./learn/secrets.js";
18
18
  import { KINDS } from "./runner/journal-kinds.js";
19
+ import { ENDED_WHILE_WAITING, STOPPED_WHILE_WAITING } from "./refusal-words.js";
19
20
  /** The run's newest usage row, which carries its cost. */
20
21
  const usageOf = (rows) => rows.findLast((r) => r.kind === "usage");
21
22
  /** The run's cost from its usage row: null when a response's cost is unknown, 0 before any request. */
@@ -84,9 +85,6 @@ export function withOverCap(rows, cap, bound = 0) {
84
85
  const over = { ...usage, id: `${usage.id}:over_cap`, kind: "phase", summary, text: null };
85
86
  return [...rows.slice(0, at + 1), over, ...rows.slice(at + 1)];
86
87
  }
87
- /** The waiting row of a run paused at its cap, after the refusal's row: "Waiting for you to raise the cap", and no
88
- * more: the refusal's words are the pause's (pending.said), which a client shows once, as its banner. */
89
- export const BUDGET_WAITING = "Waiting for you to raise the cap";
90
88
  /** A text clipped to `max` characters, with an ellipsis where it is cut (runs.ts' clip). */
91
89
  const clip = (text, max) => (text.length > max ? `${text.slice(0, max - 1)}…` : text);
92
90
  const ASKED = "Asked you: ";
@@ -168,7 +166,7 @@ export function answersOf(entries, { final } = {}) {
168
166
  if (decision === undefined)
169
167
  continue;
170
168
  const given = out[d.callId];
171
- if (given && !(decision === "withdrawn" && d.superseded))
169
+ if (given && !((decision === "withdrawn" || decision === "canceled") && d.superseded))
172
170
  continue;
173
171
  const superseded = given ? { superseded: { decision: given.decision, answered_at: given.answered_at, ...(given.note !== undefined ? { note: given.note } : {}), ...(given.by ? { by: given.by } : {}) } } : {};
174
172
  // A deny a person's message gave keeps that it was (`by`): its row reads "Declined by your message".
@@ -196,19 +194,61 @@ export function answersOf(entries, { final } = {}) {
196
194
  * room, unless an agentrun.raise after it cleared the pause (the run goes on at the raised cap then). A re-park writes a
197
195
  * fresh budget entry, which a raise before it does not clear, so the last of the two in log order decides. */
198
196
  function activeBudget(entries) {
199
- let mark;
197
+ return activePark(entries)?.mark;
198
+ }
199
+ /** The active cap park and its entry's id: the pause the runner keys a raise's follow-up by (adapter-loop raiseStateOf). */
200
+ function activePark(entries) {
201
+ let park;
200
202
  for (const entry of entries) {
201
203
  if (entry.kind === KINDS.budget)
202
- mark = dataOf(entry);
204
+ park = { mark: dataOf(entry), id: String(entry.id) };
203
205
  else if (entry.kind === KINDS.raise)
204
- mark = undefined;
206
+ park = undefined;
207
+ }
208
+ return park;
209
+ }
210
+ /** The server's row of a run's pause at its cap, and its waiting row while it stands paused: the pause's own words are
211
+ * its pending budget's `said`, which a client shows once as its banner, so these rows say no more (#1768). */
212
+ export const BUDGET_PAUSED = "Paused at the run's cap";
213
+ export const BUDGET_WAITING = "Waiting for you to raise the cap";
214
+ /** `rows` with each pause at the run's cap shown (its agentrun.budget entry: the cap refused the next step for room, and
215
+ * nothing was sent): the server's `phase` row "Paused at the run's cap" (origin server, `paused: true`, its id ending
216
+ * NOTE_SUFFIX, so no message any turn took) where the pause came in the journal's order, kept as the run's history once
217
+ * a raise clears it; and, after the pause the run stands at now, its `waiting` row "Waiting for you to raise the cap".
218
+ * Each new row takes its time from the row before it. `ended`: the run is final (cancelled while paused, say), so it
219
+ * waits on nothing and shows no waiting row. */
220
+ export function withBudgetRows(rows, entries, { ended = false } = {}) {
221
+ const parks = entries.filter((entry) => entry.kind === KINDS.budget).map((entry) => ({ id: Number(entry.id), conversation: Number(entry.conversationId ?? 1) }));
222
+ if (parks.length === 0)
223
+ return [...rows];
224
+ const active = ended ? undefined : activePauseOf(entries);
225
+ const entryOf = (row) => Number(row.id.split(":")[1]);
226
+ const out = [...rows];
227
+ for (const park of parks) {
228
+ // Before the first row of a later entry; else before a trailing usage row, the run's last.
229
+ let at = out.findIndex((row) => entryOf(row) > park.id);
230
+ if (at < 0)
231
+ at = out.length > 0 && out[out.length - 1].kind === "usage" ? out.length - 1 : out.length;
232
+ const base = out[at - 1] ?? out[at];
233
+ const timestamp = base?.timestamp ?? new Date(0).toISOString();
234
+ const row = (id, kind, summary, more) => ({
235
+ id, timestamp, created_at: base?.created_at ?? timestamp, kind, summary, agent_label: null, tool_name: null, tool_use_id: null, tool_status: null,
236
+ tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null, text: null, conversation_id: park.conversation,
237
+ ...(base?.seq !== undefined ? { seq: base.seq } : {}), ...more,
238
+ });
239
+ const shown = [row(`${park.conversation}:${park.id}${NOTE_SUFFIX}`, "phase", BUDGET_PAUSED, { origin: "server", paused: true })];
240
+ if (String(park.id) === active)
241
+ shown.push(row(`${park.conversation}:${park.id}:waiting`, "waiting", BUDGET_WAITING, { text: BUDGET_WAITING }));
242
+ out.splice(at, 0, ...shown);
205
243
  }
206
- return mark;
244
+ return out;
207
245
  }
208
- /** Whether the run stands parked at its cap now (an active agentrun.budget park, no raise since): the store-backed fact the
209
- * status table reads (RunFacts.budgetWaiting), as the file-backed view read a workflow's pause file and an agentic run's
210
- * turn refusal. */
211
- export const budgetWaitingOf = (entries) => activeBudget(entries) !== undefined;
246
+ /** The id of the cap park a run stands at now (its agentrun.budget entry's), or undefined when it is not parked: a raise's
247
+ * follow-up is sent as `agentrun:raise:<this>` (raiseFollowUpId), so a raise's answer names that message. */
248
+ export const activePauseOf = (entries) => activePark(entries)?.id;
249
+ /** The id a raised run's follow-up turn is sent under: one per pause, so raises of the same pause (a retry, two at once)
250
+ * name the same message, and the runner's re-claim never sends it twice. */
251
+ export const raiseFollowUpId = (pause) => `agentrun:raise:${pause}`;
212
252
  /** The budget card a run parked at its cap shows (pending, kind budget), from its agentrun.budget entry, the same way the
213
253
  * file-backed view built it from the run's pause mark (runs.ts workflowBudgetPending): its cap (the run's launch cap, else
214
254
  * the park's), what the cap counted as taken and the least the refused step needs, the raise offered (recomputed from
@@ -315,25 +355,6 @@ export const approvalOf = (run, redact) => {
315
355
  const waiting = waitingApproval(run);
316
356
  return waiting ? { kind: "approval", id: waiting.id, tool: waiting.tool, call_id: waiting.call_id, args_preview: shownArgs(waiting, redact), requested_at: waiting.requested_at, ...(waiting.price !== undefined ? { price: waiting.price } : {}) } : undefined;
317
357
  };
318
- /** A run paused at its cap waits on a raise: its cap, what the cap counted as taken and the least the refused request
319
- * needs (its refusal's mark; none from a store written before it kept them), the raise it is offered (suggestedCap),
320
- * the refusal's words, and when it came (its error row's time). The figures are as the cap counts them, never rounded.
321
- * What was taken is the store's spend once its process is gone (`spentNow`), when that is lower: the refusal counted
322
- * requests still answering at what it held for them, and they have settled. */
323
- export const budgetPending = (run, spentNow) => {
324
- const said = pausedAt(run);
325
- const cap = run.meta.max_cost_usd;
326
- if (said === undefined || cap === undefined)
327
- return undefined;
328
- const r = run.capRefusal;
329
- const spent = r && spentNow !== undefined ? Math.min(r.spentUsd, spentNow) : r?.spentUsd;
330
- // Shown as cost.usd is (to a millionth of a dollar), the suggestion from the figures as the cap counts them. The least cap
331
- // that sends the refused request is the one its words name (`said`), carried from the refusal that wrote them, never
332
- // worked out again here from figures that may have moved since. With them, the most a cache miss could make the refused
333
- // request cost beyond what it needs (cap.ts), 0 for none.
334
- const figures = r && spent !== undefined ? { spent_usd: micro(spent), needs_usd: micro(r.needsUsd), least_cap_usd: r.leastCapUsd, suggested_cap_usd: suggestedCap(cap, spent, r.needsUsd), overshoot_bound_usd: microUp(r.boundUsd ?? 0) } : {};
335
- return { kind: "budget", cap_usd: cap, ...figures, said, at: meaningful(run.rows)?.timestamp ?? run.updatedAt };
336
- };
337
358
  /** A run whose agent asked for the person in its browser waits on their hand-back: what it asked them to do, when it is
338
359
  * done, and when the ask expires. Never the session's tag or the live view's link. The two texts are the model's, so
339
360
  * redacted with the run's redactor (`redact`), as a tool call's arguments are: a held value it echoes never shows. */
@@ -432,6 +453,7 @@ export function momentOf(run, facts, live) {
432
453
  ...(run.meta.max_cost_usd !== undefined ? { maxCostUsd: run.meta.max_cost_usd } : {}),
433
454
  ...(pausedWords !== undefined ? { pausedWords } : {}),
434
455
  paused: pausedWords !== undefined,
456
+ ...(pausedWords !== undefined && run.pause !== undefined ? { pause: run.pause } : {}),
435
457
  live,
436
458
  // Whether it waits on a person (runs.ts waitsOnPerson): a parked approval, a pause at its cap (read through a message
437
459
  // counted but not shown), or a question its turn ended on.
@@ -476,8 +498,15 @@ export const shownOf = (values) => (text) => withoutLoopback(redacted(text, valu
476
498
  export const servedRunErrorWith = (shown, error) => ({ ...error, message: shown(error.message), ...(error.details !== undefined ? { details: cutStrings(error.details, shown) } : {}) });
477
499
  /** A run's review as its view serves it: its reason (an escalation's own words) in `shown`'s terms, or withheld as its
478
500
  * other words are while the run is hidden (`unshown`), as a list row read from disk withholds it. */
479
- export const servedReviewWith = (shown, unshown, review) => (review && { ...review, reason: unshown ? WITHHELD_SIGN_IN : shown(review.reason) });
480
- /** The pointers a run was handed, read back to cut them (sign-ins.ts peek and forgotten), by its `sign_in_handed`: none
501
+ export const servedReviewWith = (shown, unshown, review) => review && {
502
+ ...review,
503
+ // Every word of it is the run's (its escalate node's kind and label, as the workflow wrote them): cut as the reason is,
504
+ // and withheld with it.
505
+ ...("kind" in review ? { kind: unshown || review.kind == null ? null : shown(review.kind) } : {}),
506
+ ...("node" in review ? { node: unshown || review.node == null ? null : shown(review.node) } : {}),
507
+ reason: unshown ? WITHHELD_SIGN_IN : shown(review.reason),
508
+ };
509
+ /** The pointers a run was handed, read back to cut them (sign-ins-store.ts peek and forgotten), by its `sign_in_handed`: none
481
510
  * for a run with no mark (it was never handed one); else, for each hash it names, the live or forgotten pointer whose
482
511
  * SHA-256 it is. `unreadable` when what it was handed can't be read back here: a MALFORMED mark, no vendor browser kept
483
512
  * beside the mark, the sign-ins file can't be read, or any of its hashes matches no pointer that opens (one under another
@@ -556,7 +585,7 @@ function callSays(answer) {
556
585
  if (answer.decision === "canceled")
557
586
  return "Not run: the run was cancelled while it waited";
558
587
  if (answer.decision === "withdrawn")
559
- return answer.ended ? "Not run: the run ended while it waited" : "Not run: the run was stopped while it waited";
588
+ return answer.ended ? ENDED_WHILE_WAITING : STOPPED_WHILE_WAITING;
560
589
  return "Allowed: it runs now";
561
590
  }
562
591
  /** A synthesized row's id: the approval's own, so a pass over rows this function gave drops and remakes it. */
@@ -578,7 +607,13 @@ export function withApprovalRows(rows, asks, answers, redact) {
578
607
  for (const row of given)
579
608
  if (owns(row))
580
609
  lastOf.set(row.tool_use_id, row.id);
610
+ // The result rows of the calls that waited: a Saved row read from such a call's write (pi's `<result>:saved:<n>`) says
611
+ // a file was written that the park never wrote; an allowed call's file is its outcome row's to say, as on main.
612
+ const waitedResults = new Set(given.filter((row) => row.kind === "tool_result" && owns(row)).map((row) => row.id));
581
613
  return given.flatMap((row) => {
614
+ const savedBy = row.kind === "phase" ? /^(.*):saved:\d+$/.exec(row.id)?.[1] : undefined;
615
+ if (savedBy !== undefined && waitedResults.has(savedBy))
616
+ return [];
582
617
  if (!owns(row))
583
618
  return [row];
584
619
  const approval = byCall.get(row.tool_use_id);
@@ -590,13 +625,25 @@ export function withApprovalRows(rows, asks, answers, redact) {
590
625
  if (lastOf.get(approval.call_id) !== row.id)
591
626
  return [own];
592
627
  const args = shownArgs(approval, redact);
628
+ // A served row keeps the place it was first served at (rows.ts). The call's result comes in after the answer (the park
629
+ // writes none), so the approval and outcome rows take a new id once it is there: served anew below the result, the
630
+ // call's own rows, then its approval, then what came of it, as a person reads it.
631
+ const at = result ? `${approvalRowId(approval.call_id)}:after` : approvalRowId(approval.call_id);
593
632
  const head = !answer ? "Waiting for your approval" : answer.decision === "canceled" ? "Withdrawn when the run was cancelled" : answer.decision === "withdrawn" ? (answer.ended ? "Withdrawn when the run ended" : "Withdrawn when the run was stopped") : answer.by === "message" ? "Declined by your message" : "Asked your approval";
594
- const asked = { ...row, id: approvalRowId(approval.call_id), kind: APPROVAL_ROW, summary: `${head}: ${approval.tool} ${clip(args, 400)}`, text: args, tool_name: approval.tool, tool_status: null, tool_input_preview: clip(args, 500), tool_result_preview: null, tool_result_size_bytes: null };
633
+ const asked = { ...row, id: at, kind: APPROVAL_ROW, summary: `${head}: ${approval.tool} ${clip(args, 400)}`, text: args, tool_name: approval.tool, tool_status: null, tool_input_preview: clip(args, 500), tool_result_preview: null, tool_result_size_bytes: null };
595
634
  if (!outcome)
596
635
  return [own, asked];
597
636
  const failed = answer.decision === "allow" && result?.tool_status === "failed";
598
637
  // The result's words: a tool_result row keeps them as its preview (the renderer's, redacted and cut), its text empty.
599
- const told = { ...(result ?? row), id: `${approvalRowId(approval.call_id)}:outcome`, kind: "phase", origin: "server", summary: outcomeSays(approval.tool, answer, failed, redact), text: outcomeShows(approval.tool, answer, redact(result?.text || result?.tool_result_preview || ""), failed), tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null };
638
+ const told = { ...(result ?? row), id: `${at}:outcome`, kind: "phase", origin: "server", summary: outcomeSays(approval.tool, answer, failed, redact), text: outcomeShows(approval.tool, answer, redact(result?.text || result?.tool_result_preview || ""), failed), tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null };
639
+ // A person's message that declined the call (runs-over-store.ts message: a deny carrying their words) is theirs as any
640
+ // message is: its own row, between the approval and what came of it, as main's declineBy kept it.
641
+ if (answer.decision === "deny" && answer.by === "message" && answer.note) {
642
+ const words = redact(answer.note);
643
+ const { origin: _origin, ...base } = result ?? row;
644
+ const theirs = { ...base, id: `${at}:message`, kind: "user_message", summary: clip(`You: ${words.split("\n", 1)[0]}`, 500), text: words, tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null };
645
+ return [own, asked, theirs, told];
646
+ }
600
647
  return [own, asked, told];
601
648
  });
602
649
  }