@parcha/agentrun-serve 0.1.0-beta.32 → 0.1.0-beta.34

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 (444) hide show
  1. package/CHANGELOG.md +270 -0
  2. package/README.md +343 -246
  3. package/dist/adapters.d.ts +0 -7
  4. package/dist/adapters.js +11 -22
  5. package/dist/agent-rows.d.ts +98 -0
  6. package/dist/agent-rows.js +1 -0
  7. package/dist/agents-store.d.ts +6 -2
  8. package/dist/agents-store.js +60 -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 +14 -0
  14. package/dist/api-only.js +33 -0
  15. package/dist/archil-routes.d.ts +1 -1
  16. package/dist/bash-read-only.d.ts +22 -0
  17. package/dist/bash-read-only.js +701 -0
  18. package/dist/box-egress-vm.d.ts +0 -8
  19. package/dist/box-egress-vm.js +0 -10
  20. package/dist/box-egress.d.ts +0 -4
  21. package/dist/box-egress.js +1 -16
  22. package/dist/box-paths.d.ts +25 -2
  23. package/dist/box-paths.js +79 -11
  24. package/dist/box-relay.d.ts +0 -11
  25. package/dist/box-relay.js +0 -20
  26. package/dist/box-settings.d.ts +26 -0
  27. package/dist/box-settings.js +63 -0
  28. package/dist/boxes.d.ts +21 -1
  29. package/dist/boxes.js +27 -20
  30. package/dist/browser-commands.d.ts +5 -2
  31. package/dist/browser-commands.js +4 -4
  32. package/dist/browser-computer.d.ts +5 -0
  33. package/dist/browser-computer.js +21 -0
  34. package/dist/browser-cost.d.ts +9 -6
  35. package/dist/browser-cost.js +94 -51
  36. package/dist/browser-live.d.ts +7 -20
  37. package/dist/browser-live.js +15 -93
  38. package/dist/browser-person.d.ts +18 -53
  39. package/dist/browser-person.js +94 -279
  40. package/dist/budget.d.ts +0 -4
  41. package/dist/budget.js +0 -7
  42. package/dist/cap.d.ts +8 -12
  43. package/dist/cap.js +12 -27
  44. package/dist/cli.js +61 -20
  45. package/dist/closed-pipes.d.ts +2 -0
  46. package/dist/closed-pipes.js +13 -0
  47. package/dist/computer-commands.d.ts +2 -0
  48. package/dist/computer-commands.js +2 -0
  49. package/dist/computer-keys.js +5 -2
  50. package/dist/computer-setting.d.ts +20 -4
  51. package/dist/computer-setting.js +25 -5
  52. package/dist/computers.d.ts +31 -3
  53. package/dist/computers.js +70 -11
  54. package/dist/confine.d.ts +120 -0
  55. package/dist/confine.js +436 -0
  56. package/dist/console/assets/index-RPHGlXmM.js +540 -0
  57. package/dist/console/assets/index-opTN5Naq.css +1 -0
  58. package/dist/console/index.html +2 -2
  59. package/dist/daytona-api.d.ts +0 -11
  60. package/dist/daytona-api.js +1 -82
  61. package/dist/decision-rows.d.ts +1 -1
  62. package/dist/decision-rows.js +1 -1
  63. package/dist/docker-daemon.d.ts +31 -0
  64. package/dist/docker-daemon.js +56 -0
  65. package/dist/docker-host-addresses.d.ts +37 -0
  66. package/dist/docker-host-addresses.js +110 -0
  67. package/dist/effort-guidance.js +4 -3
  68. package/dist/environment.d.ts +0 -3
  69. package/dist/environment.js +3 -5
  70. package/dist/errors.d.ts +0 -2
  71. package/dist/errors.js +6 -9
  72. package/dist/filed-answer.d.ts +32 -0
  73. package/dist/filed-answer.js +160 -0
  74. package/dist/files.d.ts +1 -11
  75. package/dist/files.js +2 -21
  76. package/dist/github-connection.d.ts +2 -2
  77. package/dist/github-connection.js +1 -1
  78. package/dist/graph-view.d.ts +3 -5
  79. package/dist/graph-view.js +4 -14
  80. package/dist/handed-values.d.ts +9 -0
  81. package/dist/handed-values.js +26 -0
  82. package/dist/harness-install.d.ts +22 -5
  83. package/dist/harness-install.js +98 -20
  84. package/dist/harness-opencode/adapter.d.ts +7 -0
  85. package/dist/harness-opencode/adapter.js +23 -6
  86. package/dist/harness-opencode/index.d.ts +1 -1
  87. package/dist/harness-opencode/index.js +1 -1
  88. package/dist/harness-opencode/verify.d.ts +17 -0
  89. package/dist/harness-opencode/verify.js +30 -10
  90. package/dist/harness-table.js +6 -1
  91. package/dist/harness.d.ts +4 -3
  92. package/dist/harness.js +16 -1
  93. package/dist/heard.js +1 -1
  94. package/dist/held-fd.d.ts +5 -0
  95. package/dist/held-fd.js +14 -0
  96. package/dist/host-calls.d.ts +20 -0
  97. package/dist/host-calls.js +12 -0
  98. package/dist/host-tools.d.ts +4 -21
  99. package/dist/host-tools.js +4 -61
  100. package/dist/host.d.ts +2 -4
  101. package/dist/host.js +2 -7
  102. package/dist/import-summary.d.ts +1 -5
  103. package/dist/import-summary.js +0 -21
  104. package/dist/import.d.ts +6 -6
  105. package/dist/import.js +62 -24
  106. package/dist/key-refusal.d.ts +5 -1
  107. package/dist/key-refusal.js +19 -4
  108. package/dist/learn/check.d.ts +6 -2
  109. package/dist/learn/check.js +83 -29
  110. package/dist/learn/folder.d.ts +5 -1
  111. package/dist/learn/folder.js +10 -3
  112. package/dist/learn/grade.d.ts +14 -0
  113. package/dist/learn/grade.js +68 -12
  114. package/dist/learn/index.d.ts +4 -4
  115. package/dist/learn/index.js +4 -4
  116. package/dist/learn/reflect.d.ts +31 -2
  117. package/dist/learn/reflect.js +79 -4
  118. package/dist/learn/relevance.d.ts +24 -0
  119. package/dist/learn/relevance.js +91 -0
  120. package/dist/learn/secrets.d.ts +8 -1
  121. package/dist/learn/secrets.js +95 -15
  122. package/dist/learn/skills.d.ts +112 -14
  123. package/dist/learn/skills.js +556 -52
  124. package/dist/learned-workflow.d.ts +37 -5
  125. package/dist/learned-workflow.js +106 -12
  126. package/dist/learning-routes.d.ts +16 -49
  127. package/dist/learning-routes.js +46 -36
  128. package/dist/learning-run.d.ts +6 -250
  129. package/dist/learning-run.js +11 -665
  130. package/dist/learning-words.d.ts +12 -5
  131. package/dist/learning-words.js +18 -9
  132. package/dist/learning.d.ts +93 -77
  133. package/dist/learning.js +176 -304
  134. package/dist/live/stream.js +1 -1
  135. package/dist/live/translate.js +13 -3
  136. package/dist/local-models.d.ts +11 -5
  137. package/dist/local-models.js +13 -8
  138. package/dist/mcp-gateway.d.ts +11 -52
  139. package/dist/mcp-gateway.js +44 -148
  140. package/dist/mcp-oauth.d.ts +10 -14
  141. package/dist/mcp-oauth.js +14 -32
  142. package/dist/mcp-probe.d.ts +0 -7
  143. package/dist/mcp-probe.js +4 -10
  144. package/dist/mcp-servers-store.d.ts +6 -6
  145. package/dist/mcp-servers-store.js +13 -15
  146. package/dist/mcp-store.js +3 -4
  147. package/dist/mcp.js +4 -3
  148. package/dist/model.d.ts +6 -7
  149. package/dist/model.js +43 -27
  150. package/dist/monid.d.ts +0 -2
  151. package/dist/monid.js +3 -6
  152. package/dist/openapi.d.ts +8 -1
  153. package/dist/openapi.js +124 -50
  154. package/dist/page.d.ts +1 -3
  155. package/dist/page.js +9 -19
  156. package/dist/paid-calls.d.ts +21 -27
  157. package/dist/paid-calls.js +28 -62
  158. package/dist/pause.d.ts +0 -2
  159. package/dist/pause.js +1 -8
  160. package/dist/place.d.ts +0 -5
  161. package/dist/place.js +0 -10
  162. package/dist/print.d.ts +2 -1
  163. package/dist/print.js +4 -2
  164. package/dist/propose.js +83 -39
  165. package/dist/push-handler.d.ts +1 -1
  166. package/dist/reflect-range.d.ts +25 -0
  167. package/dist/reflect-range.js +30 -0
  168. package/dist/refusal-words.d.ts +5 -1
  169. package/dist/refusal-words.js +5 -1
  170. package/dist/rows.d.ts +1 -1
  171. package/dist/run-cut.d.ts +0 -6
  172. package/dist/run-cut.js +0 -6
  173. package/dist/run-db.d.ts +2 -13
  174. package/dist/run-db.js +2 -41
  175. package/dist/run-launch.d.ts +19 -2
  176. package/dist/run-launch.js +13 -5
  177. package/dist/run-learning-served.d.ts +46 -2
  178. package/dist/run-learning-served.js +26 -7
  179. package/dist/run-reads-over-store.d.ts +1 -1
  180. package/dist/run-reads-over-store.js +15 -6
  181. package/dist/run-secrets.d.ts +33 -0
  182. package/dist/run-secrets.js +53 -0
  183. package/dist/run-timeline-served.d.ts +5 -1
  184. package/dist/run-timeline-served.js +19 -5
  185. package/dist/run-view.d.ts +12 -17
  186. package/dist/run-view.js +29 -28
  187. package/dist/runnable.d.ts +18 -10
  188. package/dist/runnable.js +21 -10
  189. package/dist/runner/adapter-loop.d.ts +14 -3
  190. package/dist/runner/adapter-loop.js +464 -62
  191. package/dist/runner/adapter-run-spec.d.ts +29 -8
  192. package/dist/runner/adapter-run-spec.js +96 -37
  193. package/dist/runner/adapters/index.js +11 -1
  194. package/dist/runner/adapters/pi.d.ts +15 -1
  195. package/dist/runner/adapters/pi.js +19 -5
  196. package/dist/runner/beside.d.ts +30 -3
  197. package/dist/runner/beside.js +54 -12
  198. package/dist/runner/claim-secrets.d.ts +10 -1
  199. package/dist/runner/claim-secrets.js +49 -15
  200. package/dist/runner/cli-run-spec.d.ts +2 -0
  201. package/dist/runner/cli-run-spec.js +60 -17
  202. package/dist/runner/commands.js +1 -1
  203. package/dist/runner/computer-journal.d.ts +15 -2
  204. package/dist/runner/computer-journal.js +41 -5
  205. package/dist/runner/conformance/harness.js +118 -8
  206. package/dist/runner/conformance/subject.d.ts +4 -1
  207. package/dist/runner/dispatch.d.ts +8 -1
  208. package/dist/runner/dispatch.js +81 -7
  209. package/dist/runner/end-of-run.d.ts +8 -2
  210. package/dist/runner/end-of-run.js +10 -4
  211. package/dist/runner/github-app.js +1 -1
  212. package/dist/runner/harness-loops.d.ts +9 -1
  213. package/dist/runner/harness-loops.js +15 -2
  214. package/dist/runner/journal-kinds.d.ts +30 -6
  215. package/dist/runner/journal-kinds.js +20 -5
  216. package/dist/runner/journal-reader.d.ts +1 -1
  217. package/dist/runner/journal-reader.js +2 -2
  218. package/dist/runner/learning-ask.d.ts +4 -0
  219. package/dist/runner/learning-ask.js +15 -1
  220. package/dist/runner/learning-end.d.ts +18 -3
  221. package/dist/runner/learning-end.js +113 -11
  222. package/dist/runner/learning-loop.d.ts +5 -0
  223. package/dist/runner/learning-loop.js +26 -6
  224. package/dist/runner/live-ticker.d.ts +1 -1
  225. package/dist/runner/live-ticker.js +28 -4
  226. package/dist/runner/loop-contract.d.ts +3 -2
  227. package/dist/runner/main.d.ts +64 -10
  228. package/dist/runner/main.js +165 -27
  229. package/dist/runner/mcp-claim.d.ts +1 -1
  230. package/dist/runner/mcp-claim.js +2 -3
  231. package/dist/runner/mcp-run.d.ts +2 -0
  232. package/dist/runner/mcp-run.js +15 -5
  233. package/dist/runner/memory-claim.d.ts +9 -0
  234. package/dist/runner/memory-claim.js +25 -0
  235. package/dist/runner/metrics.d.ts +33 -1
  236. package/dist/runner/metrics.js +85 -1
  237. package/dist/runner/model-route.d.ts +13 -0
  238. package/dist/runner/model-route.js +154 -11
  239. package/dist/runner/redact.d.ts +8 -2
  240. package/dist/runner/redact.js +11 -2
  241. package/dist/runner/reflect-hook.d.ts +12 -1
  242. package/dist/runner/reflect-hook.js +33 -3
  243. package/dist/runner/runner.d.ts +20 -0
  244. package/dist/runner/runner.js +56 -10
  245. package/dist/runner/store-port.d.ts +1 -1
  246. package/dist/runner/store-secrets.d.ts +3 -3
  247. package/dist/runner/store-secrets.js +8 -12
  248. package/dist/runner/text-tools.d.ts +44 -0
  249. package/dist/runner/text-tools.js +237 -0
  250. package/dist/runner/workflow-loop.d.ts +6 -0
  251. package/dist/runner/workflow-loop.js +6 -4
  252. package/dist/runner/workflow-spec.d.ts +18 -0
  253. package/dist/runner/workflow-spec.js +68 -26
  254. package/dist/runs-over-store.d.ts +8 -3
  255. package/dist/runs-over-store.js +76 -19
  256. package/dist/seal-key.d.ts +54 -15
  257. package/dist/seal-key.js +232 -82
  258. package/dist/sealed-settings-store.d.ts +19 -4
  259. package/dist/sealed-settings-store.js +9 -9
  260. package/dist/sealing.d.ts +4 -0
  261. package/dist/sealing.js +20 -0
  262. package/dist/secret-cut.d.ts +1 -1
  263. package/dist/secret-cut.js +1 -1
  264. package/dist/secret-name.d.ts +9 -0
  265. package/dist/secret-name.js +15 -0
  266. package/dist/secret-writes.d.ts +0 -1
  267. package/dist/secret-writes.js +0 -1
  268. package/dist/secrets.d.ts +2 -10
  269. package/dist/secrets.js +21 -17
  270. package/dist/server-fs.d.ts +4 -0
  271. package/dist/server-fs.js +8 -2
  272. package/dist/server-lock.d.ts +0 -24
  273. package/dist/server-lock.js +1 -80
  274. package/dist/server-secrets-store.d.ts +4 -4
  275. package/dist/server-secrets-store.js +10 -32
  276. package/dist/server-secrets.d.ts +4 -9
  277. package/dist/server-secrets.js +12 -33
  278. package/dist/server.d.ts +26 -44
  279. package/dist/server.js +229 -142
  280. package/dist/sign-ins-store.d.ts +34 -36
  281. package/dist/sign-ins-store.js +27 -38
  282. package/dist/sign-ins.d.ts +2 -119
  283. package/dist/sign-ins.js +5 -311
  284. package/dist/standard-webhooks.d.ts +1 -1
  285. package/dist/standard-webhooks.js +1 -1
  286. package/dist/stats.d.ts +3 -2
  287. package/dist/stats.js +1 -1
  288. package/dist/store/agent-body.d.ts +8 -2
  289. package/dist/store/agent-body.js +16 -4
  290. package/dist/store/index.d.ts +3 -3
  291. package/dist/store/index.js +3 -3
  292. package/dist/store/open.d.ts +18 -5
  293. package/dist/store/open.js +23 -3
  294. package/dist/store/postgres/connection.d.ts +18 -2
  295. package/dist/store/postgres/connection.js +156 -32
  296. package/dist/store/postgres/migrate.d.ts +4 -0
  297. package/dist/store/postgres/migrate.js +27 -3
  298. package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
  299. package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
  300. package/dist/store/postgres/store.d.ts +9 -2
  301. package/dist/store/postgres/store.js +9 -0
  302. package/dist/store/schema.js +1 -1
  303. package/dist/store/seal.js +2 -2
  304. package/dist/store/sqlite/connection.js +49 -5
  305. package/dist/store/sqlite/run-patch.d.ts +3 -0
  306. package/dist/store/sqlite/run-patch.js +3 -0
  307. package/dist/store/sqlite/store.js +64 -20
  308. package/dist/store/store.d.ts +38 -6
  309. package/dist/store/store.js +12 -2
  310. package/dist/store-reads/cap.d.ts +1 -1
  311. package/dist/store-reads/cap.js +22 -4
  312. package/dist/store-reads/journal.d.ts +25 -6
  313. package/dist/store-reads/journal.js +173 -21
  314. package/dist/store-reads/learning.d.ts +26 -8
  315. package/dist/store-reads/learning.js +12 -4
  316. package/dist/store-reads/workflow.d.ts +1 -1
  317. package/dist/store-reads/workflow.js +1 -1
  318. package/dist/store-view.d.ts +5 -1
  319. package/dist/store-view.js +91 -23
  320. package/dist/template-eval.d.ts +60 -4
  321. package/dist/template-eval.js +120 -54
  322. package/dist/templates.d.ts +24 -10
  323. package/dist/templates.js +69 -38
  324. package/dist/timeline/group.d.ts +33 -0
  325. package/dist/timeline/group.js +77 -0
  326. package/dist/timeline/index.d.ts +7 -0
  327. package/dist/timeline/index.js +7 -0
  328. package/dist/timeline/labels.d.ts +79 -0
  329. package/dist/timeline/labels.js +150 -0
  330. package/dist/timeline/origin.d.ts +56 -0
  331. package/dist/timeline/origin.js +92 -0
  332. package/dist/timeline/render-text.d.ts +11 -0
  333. package/dist/timeline/render-text.js +62 -0
  334. package/dist/timeline/timeline.d.ts +274 -0
  335. package/dist/timeline/timeline.js +1308 -0
  336. package/dist/timeline/util.d.ts +17 -0
  337. package/dist/timeline/util.js +49 -0
  338. package/dist/tool-gate.d.ts +41 -216
  339. package/dist/tool-gate.js +79 -540
  340. package/dist/tool-keys-store.d.ts +11 -12
  341. package/dist/tool-keys-store.js +24 -31
  342. package/dist/tool-keys.d.ts +9 -104
  343. package/dist/tool-keys.js +15 -271
  344. package/dist/tool-plane.d.ts +14 -42
  345. package/dist/tool-plane.js +23 -81
  346. package/dist/tool-settings-store.d.ts +1 -2
  347. package/dist/tool-settings-store.js +5 -8
  348. package/dist/tools.d.ts +31 -19
  349. package/dist/tools.js +101 -108
  350. package/dist/trigger-adapter.d.ts +2 -2
  351. package/dist/trigger-schedule.js +2 -1
  352. package/dist/trigger-secrets-shown.js +5 -1
  353. package/dist/trigger-targets.d.ts +13 -1
  354. package/dist/trigger-targets.js +31 -1
  355. package/dist/triggers.d.ts +2 -2
  356. package/dist/triggers.js +3 -3
  357. package/dist/turn-end.d.ts +1 -1
  358. package/dist/turn-end.js +1 -1
  359. package/dist/turns.d.ts +0 -6
  360. package/dist/turns.js +0 -19
  361. package/dist/uploads.js +1 -1
  362. package/dist/usage.d.ts +0 -2
  363. package/dist/usage.js +0 -2
  364. package/dist/validate.d.ts +2 -0
  365. package/dist/validate.js +23 -14
  366. package/dist/webhooks.d.ts +102 -76
  367. package/dist/webhooks.js +266 -233
  368. package/dist/workflow-run.d.ts +114 -0
  369. package/dist/workflow-run.js +144 -0
  370. package/dist/workspace/beneath.d.ts +19 -0
  371. package/dist/workspace/beneath.js +106 -0
  372. package/dist/workspace/computer-deps.d.ts +52 -5
  373. package/dist/workspace/computer-deps.js +154 -19
  374. package/dist/workspace/computer-for-claim.d.ts +19 -14
  375. package/dist/workspace/computer-for-claim.js +77 -16
  376. package/dist/workspace/computer-hold.d.ts +6 -1
  377. package/dist/workspace/computer-hold.js +6 -1
  378. package/dist/workspace/computer-janitor.d.ts +47 -0
  379. package/dist/workspace/computer-janitor.js +182 -0
  380. package/dist/workspace/computer-providers.d.ts +6 -2
  381. package/dist/workspace/computer-providers.js +1 -1
  382. package/dist/workspace/grep-worker.d.ts +5 -0
  383. package/dist/workspace/grep-worker.js +9 -6
  384. package/dist/workspace/index.d.ts +4 -3
  385. package/dist/workspace/index.js +4 -4
  386. package/dist/workspace/local.d.ts +11 -2
  387. package/dist/workspace/local.js +161 -43
  388. package/dist/workspace/resolve-computer.d.ts +50 -10
  389. package/dist/workspace/resolve-computer.js +46 -11
  390. package/dist/workspace/run-tools.d.ts +13 -31
  391. package/dist/workspace/run-tools.js +10 -27
  392. package/dist/workspace-paths.d.ts +0 -17
  393. package/dist/workspace-paths.js +1 -41
  394. package/dist/workspace.d.ts +0 -17
  395. package/dist/workspace.js +3 -99
  396. package/launcher/agentrun-serve +6 -33
  397. package/package.json +14 -14
  398. package/templates/README.md +9 -3
  399. package/templates/inbound-lead/agent.md +1 -1
  400. package/templates/kyb/agent.md +1 -1
  401. package/templates/market-monitor/agent.md +2 -2
  402. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  403. package/dist/app.d.ts +0 -5
  404. package/dist/app.js +0 -514
  405. package/dist/bound-files.d.ts +0 -4
  406. package/dist/bound-files.js +0 -164
  407. package/dist/bounds.d.ts +0 -26
  408. package/dist/bounds.js +0 -137
  409. package/dist/coding-tools.d.ts +0 -47
  410. package/dist/coding-tools.js +0 -189
  411. package/dist/computer-adb.d.ts +0 -12
  412. package/dist/computer-adb.js +0 -14
  413. package/dist/console/assets/index-35-7aeIZ.js +0 -519
  414. package/dist/console/assets/index-Cejbov-Y.css +0 -1
  415. package/dist/content-filter.d.ts +0 -7
  416. package/dist/content-filter.js +0 -23
  417. package/dist/disk.d.ts +0 -33
  418. package/dist/disk.js +0 -85
  419. package/dist/door-line.d.ts +0 -23
  420. package/dist/door-line.js +0 -83
  421. package/dist/grade.d.ts +0 -63
  422. package/dist/grade.js +0 -150
  423. package/dist/harness-app.d.ts +0 -69
  424. package/dist/harness-app.js +0 -1162
  425. package/dist/mcp-servers.d.ts +0 -269
  426. package/dist/mcp-servers.js +0 -456
  427. package/dist/packs.d.ts +0 -71
  428. package/dist/packs.js +0 -180
  429. package/dist/request-start.d.ts +0 -27
  430. package/dist/request-start.js +0 -381
  431. package/dist/run-box.d.ts +0 -205
  432. package/dist/run-box.js +0 -661
  433. package/dist/run-holder.d.ts +0 -52
  434. package/dist/run-holder.js +0 -139
  435. package/dist/runs.d.ts +0 -1200
  436. package/dist/runs.js +0 -4103
  437. package/dist/sealed-settings.d.ts +0 -60
  438. package/dist/sealed-settings.js +0 -178
  439. package/dist/served-only.d.ts +0 -5
  440. package/dist/served-only.js +0 -12
  441. package/dist/sessions.d.ts +0 -6
  442. package/dist/sessions.js +0 -109
  443. package/dist/workspace/computer-serves.d.ts +0 -12
  444. package/dist/workspace/computer-serves.js +0 -15
@@ -1,16 +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
- /** Run `runId`'s learning as GET /runs/{id}/learning serves it, or ApiError forbidden for a withheld run. */
11
- export async function servedRunLearning(deps, store, runId) {
13
+ import { runDiffOverStore } from "./learning-routes.js";
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) {
12
17
  const cut = await runCutValues(deps, store, runId);
13
18
  if (cut === "unreadable")
14
19
  throw new ApiError("forbidden", WITHHELD_SIGN_IN);
15
- 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);
30
+ }
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. */
33
+ export async function servedRunDiff(deps, store, data, runId) {
34
+ return runDiffOverStore(data, store, runId, secretsShown(await learningCutOf(deps, store, runId)));
16
35
  }
@@ -1,5 +1,5 @@
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,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). */
@@ -79,8 +80,12 @@ export async function runGraphView(store, runId, deps) {
79
80
  const status = String(view.status);
80
81
  const ended = view.ended_at !== null;
81
82
  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.
83
+ // 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
84
+ // usage row is its booking's (store-reads/journal.ts bookedUsage), its model nodes', its `llm` calls' and its paid
85
+ // tools', never its decisions', which the graph sums from their receipts. Its `llm` calls' answers are then all in it
86
+ // (llmRead), never counted again from the node log.
83
87
  const rows = ended ? await runTimeline(store, runId, deps.context) : [];
88
+ const booked = ended && costIsBooked(await runEntries(store, runId, deps.context), false);
84
89
  // Every field it serves is cut by the run's one cut (graph-served.ts servedGraphView): its nodes, decisions and calls by
85
90
  // servedPart, and every other field (its workflow, its structure, any added later) whole.
86
91
  const cut = await deps.cutValues(store, runId);
@@ -90,12 +95,11 @@ export async function runGraphView(store, runId, deps) {
90
95
  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 },
91
96
  ended,
92
97
  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: "",
98
+ // No run directory now: the store and a context carry the journal the graph reads.
95
99
  root: "",
96
100
  input: launch?.input ?? {},
97
101
  modelCost: ended ? costOf(rows) : 0,
98
- llmRead: 0,
102
+ llmRead: booked ? Number.MAX_SAFE_INTEGER : 0,
99
103
  store,
100
104
  context: deps.context,
101
105
  }), cut.values, graphParts);
@@ -120,9 +124,14 @@ export function runTimelines(deps) {
120
124
  };
121
125
  const pollMs = deps.pollMs ?? 1_000;
122
126
  async function once(store, runId, after, limit) {
123
- const [rows, view] = await Promise.all([deps.timelineRows(store, runId, deps.context), deps.runView(store, runId)]);
127
+ // The view first, then the rows, never both at once: the journal only grows, so the rows read after the view hold
128
+ // every entry its status was read from. Read together, a message committed between the two reads gave a page that
129
+ // said working before the message row it works on (#2307), or a waiting status with its parked call's row still
130
+ // missing. The rows may run ahead of the status, never behind it.
131
+ const view = await deps.runView(store, runId);
124
132
  if (!view)
125
133
  throw new ApiError("not_found", `There is no run ${runId}.`);
134
+ const rows = await deps.timelineRows(store, runId, deps.context);
126
135
  const status = String(view.status);
127
136
  const state = String(view.state);
128
137
  const log = logOf(runId);
@@ -0,0 +1,33 @@
1
+ import type { Revision } from "./agent-rows.js";
2
+ import { type Tier } from "./model.js";
3
+ /** The secrets a run may be handed: every one but the server's own and the decision keys, which go apart. */
4
+ export declare const RUN_SECRETS: string[];
5
+ type KeyRow = {
6
+ kind: string;
7
+ fields: readonly string[];
8
+ unlocks: readonly string[];
9
+ };
10
+ /** What of a revision decides the secrets its runs are handed, none of it a key, read once per revision (a revision
11
+ * never changes): its harness, the model it names, the tools it binds (an agentic revision's `tools`, a workflow's on
12
+ * its model nodes and its `call` nodes), a workflow's tiers (those its model nodes and `llm` calls run on), and its
13
+ * decision providers (decisions.ts' decisionKeysFor: a workflow's decision nodes', providersNamed, Jev for a node that
14
+ * names none; an agentic revision's, none). Names only: no instruction and no skill. */
15
+ export type RunNeeds = {
16
+ harness: string;
17
+ model?: string;
18
+ tools: readonly string[];
19
+ tiers?: readonly Tier[];
20
+ decisionProviders: readonly string[];
21
+ };
22
+ /** `revision`'s RunNeeds. */
23
+ export declare function needsOf(revision: Revision): Promise<RunNeeds>;
24
+ /** The secrets a run of `needs` is handed, by the keys `env` holds now: RUN_SECRETS but each field of a `tool` row of
25
+ * `rows` (TOOL_KEYS) that unlocks none of the tools the run binds; and but each model key its model does not need, from
26
+ * the host's model settings and the keys in `env`: a pi run's, its models' providers' keys or the gateway's (model.ts'
27
+ * modelKeys: its own model, or the host's of each tier it runs); a run on an adapter's, the one key its wire's route
28
+ * sends for the revision's model (adapters.ts' harnessModelKeys). Read at each claim, so a key saved with no restart
29
+ * counts at the next. */
30
+ export declare function keysFor(needs: RunNeeds, env: NodeJS.ProcessEnv, rows?: readonly KeyRow[]): string[];
31
+ /** The secrets a run of `revision` is handed with the keys `env` holds (needsOf, then keysFor). */
32
+ export declare function secretsFor(revision: Revision, rows?: readonly KeyRow[], env?: NodeJS.ProcessEnv): Promise<string[]>;
33
+ export {};
@@ -0,0 +1,53 @@
1
+ import { harnessModelKeys } from "./adapters.js";
2
+ import { BOX_KEYS } from "./boxes.js";
3
+ import { providersNamed } from "./decisions.js";
4
+ import { harnessOfBody } from "./harness.js";
5
+ import { harnessOf } from "./harness-table.js";
6
+ import { GATEWAY_KEY_ENV, llmTiers, modelKeys, nodeTiers, PROVIDER_KEYS, workflowNodes } from "./model.js";
7
+ import { DECISION_KEYS, SECRET_NAMES } from "./secrets.js";
8
+ import { TOOL_KEYS } from "./tool-keys.js";
9
+ import { workflowTools } from "./tools.js";
10
+ /** The server's own secrets, which a run never gets: the API token, by name or by value, the seal key the tool keys are
11
+ * kept under (tool-keys.ts), the store's URL (it may hold the database's password), and the boxes' keys (boxes.ts),
12
+ * which only the server's box providers use. */
13
+ const SERVER_ONLY = new Set(["AGENTRUN_TOKEN", "AGENTRUN_API_KEY", "AGENTRUN_SEAL_KEY", "AGENTRUN_STORE_URL", ...BOX_KEYS]);
14
+ /** The secrets a run may be handed: every one but the server's own and the decision keys, which go apart. */
15
+ export const RUN_SECRETS = SECRET_NAMES.filter((name) => !SERVER_ONLY.has(name) && !DECISION_KEYS.includes(name));
16
+ /** The fields a run gets only when its revision names what they unlock: a `tool` key's. Any other kind's (a model key's)
17
+ * is the model's to need, as every model key is. */
18
+ const scopedOf = (rows) => rows.filter((row) => row.kind === "tool").flatMap((row) => row.fields);
19
+ /** The model keys: every key of pi-ai's providers (model.ts' PROVIDER_KEYS) and the gateway's. A run gets those its model
20
+ * needs and no other (keysFor). A workflow's decision keys, OpenRouter's among them, go apart (decisions.ts), whatever
21
+ * its model. */
22
+ const MODEL_KEYS = [...new Set([...Object.values(PROVIDER_KEYS).flat(), GATEWAY_KEY_ENV])];
23
+ /** `revision`'s RunNeeds. */
24
+ export async function needsOf(revision) {
25
+ const workflow = revision.kind === "workflow" ? revision.body.workflow : undefined;
26
+ const nodes = workflow ? workflowNodes(workflow, (await import("@parcha/agentrun-dsl")).inspectWorkflow(workflow)) : undefined;
27
+ const bound = nodes && workflowTools(nodes);
28
+ return {
29
+ harness: harnessOfBody(revision.body),
30
+ ...(revision.kind === "agentic" && revision.body.model ? { model: revision.body.model } : {}),
31
+ tools: bound ? [...bound.nodes, ...bound.calls] : [...(revision.body.tools ?? [])],
32
+ ...(nodes ? { tiers: llmTiers(nodes, nodeTiers(nodes)) } : {}),
33
+ decisionProviders: nodes ? providersNamed(nodes) : [],
34
+ };
35
+ }
36
+ /** The secrets a run of `needs` is handed, by the keys `env` holds now: RUN_SECRETS but each field of a `tool` row of
37
+ * `rows` (TOOL_KEYS) that unlocks none of the tools the run binds; and but each model key its model does not need, from
38
+ * the host's model settings and the keys in `env`: a pi run's, its models' providers' keys or the gateway's (model.ts'
39
+ * modelKeys: its own model, or the host's of each tier it runs); a run on an adapter's, the one key its wire's route
40
+ * sends for the revision's model (adapters.ts' harnessModelKeys). Read at each claim, so a key saved with no restart
41
+ * counts at the next. */
42
+ export function keysFor(needs, env, rows = TOOL_KEYS) {
43
+ const named = new Set(needs.tools);
44
+ const unlocked = new Set(rows.filter((row) => row.unlocks.some((name) => named.has(name))).flatMap((row) => row.fields));
45
+ const scoped = scopedOf(rows);
46
+ const entry = harnessOf(env, needs.harness);
47
+ const model = new Set(!entry || entry.facts ? harnessModelKeys(needs.harness, env, needs.model) : needs.tiers ? modelKeys(env, undefined, needs.tiers) : modelKeys(env, needs.model));
48
+ return RUN_SECRETS.filter((name) => (!scoped.includes(name) || unlocked.has(name)) && (!MODEL_KEYS.includes(name) || model.has(name)));
49
+ }
50
+ /** The secrets a run of `revision` is handed with the keys `env` holds (needsOf, then keysFor). */
51
+ export async function secretsFor(revision, rows = TOOL_KEYS, env = process.env) {
52
+ return keysFor(await needsOf(revision), env, rows);
53
+ }
@@ -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,12 +1,15 @@
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
8
  import { answersOf, asksOf, shownOf, withApprovalRows, withAsks } from "./run-view.js";
6
9
  import { journalRecords } from "./runner/journal-reader.js";
7
10
  import { decisionsOverStore } from "./store-reads/decisions.js";
8
11
  import { readRun } from "./store-reads/runs.js";
9
- import { runTimeline } from "./store-reads/journal.js";
12
+ import { runTimeline, wholeAnswerFor, wholeAnswers } from "./store-reads/journal.js";
10
13
  import { FINAL_STATES } from "./store/store.js";
11
14
  /** Run `runId`'s Timeline rows as served: cut by its one cut set, its decision rows among them, its error rows in the
12
15
  * run's error's words; none for a run withheld. */
@@ -27,7 +30,12 @@ export async function servedTimelineRows(deps, store, runId, context) {
27
30
  // A question the agent asked (ask_person) and waits on: its waiting row after the call's result (run-view.ts withAsks), as
28
31
  // the run's view carries it and main's served Timeline did, so the console's "The agent asks" box reads that question,
29
32
  // never an earlier wait's words.
30
- const rows = withApprovalRows(withAsks(await runTimeline(store, runId, context, { redact })), asksOf(records.entries), answersOf(records.entries, { final }), redact);
33
+ // Its final answer whole, as the run's view serves it (store-reads/journal.ts wholeAnswers): a row's cut is no answer's.
34
+ // A run that ended is read settled, as its view reads it: nothing of it is in flight, so a request it left unanswered
35
+ // is a cost unknown, never one still running.
36
+ const options = { redact, settled: ended };
37
+ const timeline = await wholeAnswers(store, runId, context, await runTimeline(store, runId, context, options), options, wholeAnswerFor(values));
38
+ const rows = withApprovalRows(withAsks(timeline), asksOf(records.entries), answersOf(records.entries, { final }), redact);
31
39
  // A workflow's decisions: their rows among the model nodes' by time, each text shown through the cut set, with as many
32
40
  // characters held back from a text stored cut as a held value takes in its widest form (main's decisionShown).
33
41
  const receipts = await decisionsOverStore(store, runId, context).catch(() => null);
@@ -39,14 +47,20 @@ export async function servedTimelineRows(deps, store, runId, context) {
39
47
  const words = await runErrorWordsOf(deps, store, runId, { workflow });
40
48
  if (words === "unreadable")
41
49
  return [];
50
+ // The run's learning row, once its learning was proposed, merged or dropped (learning-run.ts withLearning, main's row):
51
+ // 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
52
+ // folder's main), its words cut by the same set.
53
+ const end = await runLearningEnd(store, runId);
54
+ const learning = end ? (holdsForOk(end) && run && deps.statuses ? currentLearning(end, await deps.statuses(run.agentId)) : end) : undefined;
55
+ const learned = withLearning(own, learning, secretsShown(values));
42
56
  // Each trigger the rows name, read once for this read: its name now, or none for one gone.
43
57
  const names = new Map();
44
- for (const row of own)
58
+ for (const row of learned)
45
59
  if (row.trigger && !names.has(row.trigger.id))
46
60
  names.set(row.trigger.id, (await store.triggers.get(row.trigger.id))?.name);
47
61
  // A refused key's plain words are its summary and its text alike; any other error keeps each in the one rule.
48
62
  const shown = shownOf(values);
49
- return own.map((row) => {
63
+ return learned.map((row) => {
50
64
  if (row.trigger)
51
65
  return named(row, names.get(row.trigger.id), redact);
52
66
  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,14 +47,9 @@ 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 row of a refusal for room a run paused at (servedError): the server's `phase` row in these words (origin server,
52
- * its id the refusal's with NOTE_SUFFIX, so it is no message: isMessageRow), marked `paused`, never an error row. The
53
- * refusal's sentence is the pause's (pending.said), which a client shows once, as its banner. */
54
- export declare const BUDGET_PAUSED = "Paused at the run's cap";
55
50
  /** The waiting row of a run paused at its cap, after the refusal's row: "Waiting for you to raise the cap", and no
56
51
  * more: the refusal's words are the pause's (pending.said), which a client shows once, as its banner. */
57
52
  export declare const BUDGET_WAITING = "Waiting for you to raise the cap";
58
- export declare function withPaused(rows: readonly TimelineEvent[]): TimelineEvent[];
59
53
  /** The waiting row after each answered `ask_person` call, which the timeline module does not know. The question comes from
60
54
  * the call's row, whose label this module registers. The server fed its rows through this; the store-backed view feeds the
61
55
  * same rows through it, so a run waiting on a question reads the same pending. */
@@ -189,7 +183,7 @@ export interface RunFacts {
189
183
  budgetWaiting(): boolean;
190
184
  /** A workflow run paused in its process (pausedIn(run.dir)). */
191
185
  paused(): boolean;
192
- /** The ask its agent made for the person in its browser the run waits on (askShown(run.dir, run.rows)). */
186
+ /** The ask its agent made for the person in its browser the run waits on (browser-commands.ts browserAsk, over its journal). */
193
187
  browserAsk(): PendingAsk | undefined;
194
188
  /** The ask its agent made for the person on its desktop or phone the run waits on (computer-commands.ts computerAsk). */
195
189
  computerAsk?(): ComputerAsk | undefined;
@@ -332,7 +326,8 @@ export interface RunMoment {
332
326
  readonly pausedWords?: string;
333
327
  /** The run is paused at its cap (pausedAt): raising the cap resumes it. */
334
328
  readonly paused: boolean;
335
- /** The run has a live process now (a runner holds its claim): a raise's cap holds from its next process, not this one. */
329
+ /** 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
330
+ * way. */
336
331
  readonly live: boolean;
337
332
  /** A message that may not answer a person (a trigger's) is refused while the run waits on one, before anything else. */
338
333
  readonly waitsOnPerson: boolean;
@@ -352,6 +347,9 @@ export interface RunMoment {
352
347
  export declare function momentOf(run: RunView, facts: RunFacts, live: boolean): RunMoment;
353
348
  /** An ended run's words, withheld while this server can't read the sign-in it was handed (load). */
354
349
  export declare const WITHHELD_SIGN_IN = "This server can't read the run's browser sign-in (its seal key changed or is missing, or the sign-in is damaged), so nothing the run said is shown.";
350
+ /** Why a run is refused at its claim: the browser sign-in it was handed can't be read here (the seal key changed or is
351
+ * missing, or the sign-in is damaged). */
352
+ export declare const UNREADABLE_SIGN_IN = "This server can't read the run's browser sign-in (its seal key changed or is missing, or the sign-in is damaged): the run was stopped, so nothing it says can show it.";
355
353
  /** A withheld run's title: a short line that fits the title's length and holds nothing the run said, so a title that
356
354
  * repeats the handed sign-in is never served when this server can't cut it. The full sentence stays in the run's error
357
355
  * and review. */
@@ -364,9 +362,6 @@ export type Handed = string[] | typeof MALFORMED;
364
362
  /** A run's `sign_in_handed` as read from its serve.json: undefined when absent (never handed one); the hashes it names;
365
363
  * MALFORMED for any other value. */
366
364
  export declare function handedMark(value: unknown): Handed | undefined;
367
- /** Every secret value a run's errors never show, as learning's checker holds them: every one this server never shows
368
- * (serverSecrets, read now, so one rotated is cut at once) and what each launch handed the run. */
369
- export declare const refusedValuesOf: (serverSecrets: () => string[], handed: ReadonlySet<string> | undefined) => string[];
370
365
  /** A run's redactor (decision-rows.ts, tool previews): redacted over its refused values. */
371
366
  export declare const redactorOf: (values: string[]) => (text: string) => string;
372
367
  /** What serve shows of a run's error text, for every run kind: no held secret (redacted, key-refusal.ts' one rule) and
@@ -382,7 +377,7 @@ export declare const servedRunErrorWith: <E extends {
382
377
  export declare const servedReviewWith: <R extends {
383
378
  reason: string;
384
379
  }>(shown: (text: string) => string, unshown: boolean | undefined, review: R | null) => R | null;
385
- /** The pointers a run was handed, read back to cut them (sign-ins.ts peek and forgotten), by its `sign_in_handed`: none
380
+ /** The pointers a run was handed, read back to cut them (sign-ins-store.ts peek and forgotten), by its `sign_in_handed`: none
386
381
  * for a run with no mark (it was never handed one); else, for each hash it names, the live or forgotten pointer whose
387
382
  * SHA-256 it is. `unreadable` when what it was handed can't be read back here: a MALFORMED mark, no vendor browser kept
388
383
  * 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,17 +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 { NOTE_SUFFIX, chargedTool, isMessageRow, registerLabel, registerTurnEnding, scrubUrls } from "@parcha/pi-durable-agent/timeline";
9
+ import { chargedTool, isMessageRow, registerLabel, registerTurnEnding, scrubUrls } from "./timeline/index.js";
10
10
  import { CAP_TOLERANCE, FIT_TOLERANCE, money, roomRefusal } from "./cap.js";
11
- import { servedOnly } from "./served-only.js";
12
11
  import { APPROVAL_ROW, previewOf } from "./tool-gate.js";
13
12
  import { ASK_TOOL } from "./tools.js";
14
13
  import { LEARNING_LABEL } from "./learning.js";
15
14
  import { builtinHarness } from "./harness-table.js";
16
15
  import { cutStrings, redacted, withoutLoopback } from "./key-refusal.js";
17
- import { pointerHash } from "./sign-ins.js";
16
+ import { pointerHash } from "./sign-ins-store.js";
18
17
  import { MIN_SECRET } from "./learn/secrets.js";
19
18
  import { KINDS } from "./runner/journal-kinds.js";
19
+ import { ENDED_WHILE_WAITING, STOPPED_WHILE_WAITING } from "./refusal-words.js";
20
20
  /** The run's newest usage row, which carries its cost. */
21
21
  const usageOf = (rows) => rows.findLast((r) => r.kind === "usage");
22
22
  /** The run's cost from its usage row: null when a response's cost is unknown, 0 before any request. */
@@ -85,26 +85,9 @@ export function withOverCap(rows, cap, bound = 0) {
85
85
  const over = { ...usage, id: `${usage.id}:over_cap`, kind: "phase", summary, text: null };
86
86
  return [...rows.slice(0, at + 1), over, ...rows.slice(at + 1)];
87
87
  }
88
- /** The row of a refusal for room a run paused at (servedError): the server's `phase` row in these words (origin server,
89
- * its id the refusal's with NOTE_SUFFIX, so it is no message: isMessageRow), marked `paused`, never an error row. The
90
- * refusal's sentence is the pause's (pending.said), which a client shows once, as its banner. */
91
- export const BUDGET_PAUSED = "Paused at the run's cap";
92
88
  /** The waiting row of a run paused at its cap, after the refusal's row: "Waiting for you to raise the cap", and no
93
89
  * more: the refusal's words are the pause's (pending.said), which a client shows once, as its banner. */
94
90
  export const BUDGET_WAITING = "Waiting for you to raise the cap";
95
- export function withPaused(rows) {
96
- const at = rows.findLastIndex((row) => row.paused === true);
97
- if (at < 0)
98
- return [...rows];
99
- // The refusal's own marker (`paused`, servedError) and the server's origin stay on the refusal's row: the waiting row
100
- // is no refusal and no row of the server's, and keeps the id it had, the refusal's own with ":paused".
101
- const { paused: _marker, origin: _origin, ...refusal } = rows[at];
102
- const own = refusal.id.endsWith(NOTE_SUFFIX) ? refusal.id.slice(0, -NOTE_SUFFIX.length) : refusal.id;
103
- // Only the served view makes it (servedOnly): once the run is raised, show() stops making it and it goes, even while a
104
- // live process feeds the timeline (keepCommitted).
105
- const paused = servedOnly({ ...refusal, id: `${own}:paused`, kind: "waiting", summary: BUDGET_WAITING, text: BUDGET_WAITING, tool_name: null, tool_use_id: null, tool_status: null, tool_input_preview: null, tool_result_preview: null, tool_result_size_bytes: null });
106
- return [...rows.slice(0, at + 1), paused, ...rows.slice(at + 1)];
107
- }
108
91
  /** A text clipped to `max` characters, with an ellipsis where it is cut (runs.ts' clip). */
109
92
  const clip = (text, max) => (text.length > max ? `${text.slice(0, max - 1)}…` : text);
110
93
  const ASKED = "Asked you: ";
@@ -186,7 +169,7 @@ export function answersOf(entries, { final } = {}) {
186
169
  if (decision === undefined)
187
170
  continue;
188
171
  const given = out[d.callId];
189
- if (given && !(decision === "withdrawn" && d.superseded))
172
+ if (given && !((decision === "withdrawn" || decision === "canceled") && d.superseded))
190
173
  continue;
191
174
  const superseded = given ? { superseded: { decision: given.decision, answered_at: given.answered_at, ...(given.note !== undefined ? { note: given.note } : {}), ...(given.by ? { by: given.by } : {}) } } : {};
192
175
  // A deny a person's message gave keeps that it was (`by`): its row reads "Declined by your message".
@@ -465,6 +448,9 @@ export function momentOf(run, facts, live) {
465
448
  // point: a run whose summary holds a handed pointer serves it cut, and an unreadable handed hash withholds it (rowShown). ---
466
449
  /** An ended run's words, withheld while this server can't read the sign-in it was handed (load). */
467
450
  export const WITHHELD_SIGN_IN = "This server can't read the run's browser sign-in (its seal key changed or is missing, or the sign-in is damaged), so nothing the run said is shown.";
451
+ /** Why a run is refused at its claim: the browser sign-in it was handed can't be read here (the seal key changed or is
452
+ * missing, or the sign-in is damaged). */
453
+ export const UNREADABLE_SIGN_IN = "This server can't read the run's browser sign-in (its seal key changed or is missing, or the sign-in is damaged): the run was stopped, so nothing it says can show it.";
468
454
  /** A withheld run's title: a short line that fits the title's length and holds nothing the run said, so a title that
469
455
  * repeats the handed sign-in is never served when this server can't cut it. The full sentence stays in the run's error
470
456
  * and review. */
@@ -482,9 +468,6 @@ export function handedMark(value) {
482
468
  return [...new Set(value)];
483
469
  return MALFORMED;
484
470
  }
485
- /** Every secret value a run's errors never show, as learning's checker holds them: every one this server never shows
486
- * (serverSecrets, read now, so one rotated is cut at once) and what each launch handed the run. */
487
- export const refusedValuesOf = (serverSecrets, handed) => [...serverSecrets(), ...(handed ?? [])];
488
471
  /** A run's redactor (decision-rows.ts, tool previews): redacted over its refused values. */
489
472
  export const redactorOf = (values) => (text) => redacted(text, values);
490
473
  /** What serve shows of a run's error text, for every run kind: no held secret (redacted, key-refusal.ts' one rule) and
@@ -495,7 +478,7 @@ export const servedRunErrorWith = (shown, error) => ({ ...error, message: shown(
495
478
  /** A run's review as its view serves it: its reason (an escalation's own words) in `shown`'s terms, or withheld as its
496
479
  * other words are while the run is hidden (`unshown`), as a list row read from disk withholds it. */
497
480
  export const servedReviewWith = (shown, unshown, review) => (review && { ...review, reason: unshown ? WITHHELD_SIGN_IN : shown(review.reason) });
498
- /** The pointers a run was handed, read back to cut them (sign-ins.ts peek and forgotten), by its `sign_in_handed`: none
481
+ /** The pointers a run was handed, read back to cut them (sign-ins-store.ts peek and forgotten), by its `sign_in_handed`: none
499
482
  * for a run with no mark (it was never handed one); else, for each hash it names, the live or forgotten pointer whose
500
483
  * SHA-256 it is. `unreadable` when what it was handed can't be read back here: a MALFORMED mark, no vendor browser kept
501
484
  * beside the mark, the sign-ins file can't be read, or any of its hashes matches no pointer that opens (one under another
@@ -574,7 +557,7 @@ function callSays(answer) {
574
557
  if (answer.decision === "canceled")
575
558
  return "Not run: the run was cancelled while it waited";
576
559
  if (answer.decision === "withdrawn")
577
- return answer.ended ? "Not run: the run ended while it waited" : "Not run: the run was stopped while it waited";
560
+ return answer.ended ? ENDED_WHILE_WAITING : STOPPED_WHILE_WAITING;
578
561
  return "Allowed: it runs now";
579
562
  }
580
563
  /** A synthesized row's id: the approval's own, so a pass over rows this function gave drops and remakes it. */
@@ -596,7 +579,13 @@ export function withApprovalRows(rows, asks, answers, redact) {
596
579
  for (const row of given)
597
580
  if (owns(row))
598
581
  lastOf.set(row.tool_use_id, row.id);
582
+ // The result rows of the calls that waited: a Saved row read from such a call's write (pi's `<result>:saved:<n>`) says
583
+ // a file was written that the park never wrote; an allowed call's file is its outcome row's to say, as on main.
584
+ const waitedResults = new Set(given.filter((row) => row.kind === "tool_result" && owns(row)).map((row) => row.id));
599
585
  return given.flatMap((row) => {
586
+ const savedBy = row.kind === "phase" ? /^(.*):saved:\d+$/.exec(row.id)?.[1] : undefined;
587
+ if (savedBy !== undefined && waitedResults.has(savedBy))
588
+ return [];
600
589
  if (!owns(row))
601
590
  return [row];
602
591
  const approval = byCall.get(row.tool_use_id);
@@ -608,13 +597,25 @@ export function withApprovalRows(rows, asks, answers, redact) {
608
597
  if (lastOf.get(approval.call_id) !== row.id)
609
598
  return [own];
610
599
  const args = shownArgs(approval, redact);
600
+ // A served row keeps the place it was first served at (rows.ts). The call's result comes in after the answer (the park
601
+ // writes none), so the approval and outcome rows take a new id once it is there: served anew below the result, the
602
+ // call's own rows, then its approval, then what came of it, as a person reads it.
603
+ const at = result ? `${approvalRowId(approval.call_id)}:after` : approvalRowId(approval.call_id);
611
604
  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";
612
- 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 };
605
+ 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 };
613
606
  if (!outcome)
614
607
  return [own, asked];
615
608
  const failed = answer.decision === "allow" && result?.tool_status === "failed";
616
609
  // The result's words: a tool_result row keeps them as its preview (the renderer's, redacted and cut), its text empty.
617
- 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 };
610
+ 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 };
611
+ // A person's message that declined the call (runs-over-store.ts message: a deny carrying their words) is theirs as any
612
+ // message is: its own row, between the approval and what came of it, as main's declineBy kept it.
613
+ if (answer.decision === "deny" && answer.by === "message" && answer.note) {
614
+ const words = redact(answer.note);
615
+ const { origin: _origin, ...base } = result ?? row;
616
+ 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 };
617
+ return [own, asked, theirs, told];
618
+ }
618
619
  return [own, asked, told];
619
620
  });
620
621
  }
@@ -4,8 +4,18 @@ import { type ModelRef } from "./model.js";
4
4
  import type { BoxOffer } from "./boxes.js";
5
5
  import { type ToolSettingsMap } from "./tool-plane.js";
6
6
  import type { McpTool } from "@parcha/agentrun-kernel";
7
+ import type { ShellPlace } from "@parcha/agentrun-kernel/kernel";
7
8
  /** The harnesses an agent's MCP tools run on here. */
8
9
  export declare const MCP_HARNESSES: readonly string[];
10
+ /** A revision's computer setting: a kind, its provider, and a sandbox's GPUs (computer-setting.ts). */
11
+ export type RevisionComputer = {
12
+ kind: string;
13
+ provider?: string;
14
+ gpu?: {
15
+ type: string;
16
+ count: number;
17
+ };
18
+ };
9
19
  /** A revision's body as it is saved or stored. `unnamed`: its `place` is the one a revision that names none resolves to
10
20
  * (place.ts defaultPlaceOf), not one it names. `computer`: its computer setting (computer-setting.ts), when it has one. */
11
21
  export type RevisionShape = {
@@ -18,10 +28,7 @@ export type RevisionShape = {
18
28
  mode: string;
19
29
  box?: string;
20
30
  };
21
- computer?: {
22
- kind: string;
23
- provider?: string;
24
- };
31
+ computer?: RevisionComputer;
25
32
  unnamed?: true;
26
33
  toolSettings?: ToolSettingsMap;
27
34
  approvals?: "never";
@@ -91,8 +98,11 @@ export declare const CODE_NODES_ENV = "AGENTRUN_SERVE_CODE_NODES";
91
98
  /** What keeps `revision` from running in `env` under the server's tool `settings` (tool-plane.ts). `boxes`: what this
92
99
  * server's box registry set up at its start (boxes.ts); none, every box is unavailable. `offers`: the harnesses' offers
93
100
  * the server already holds (its reading); none given, they are probed here. `computerReady`: whether an agent's computer
94
- * setting can be had here now, or its refusal (resolve-computer.ts computerReadiness); none given, the box check. */
95
- export declare function blockersOf(env: NodeJS.ProcessEnv, revision: RevisionShape, settings?: ToolSettingsMap, { capped, boxes, offers, mcp, decisionPrice, computerReady }?: {
101
+ * setting can be had here now, or its refusal (resolve-computer.ts computerReadiness); none given, the box check.
102
+ * `shellOf`: where a run of an agent with that computer setting has its shell here now (resolve-computer.ts
103
+ * runShellOf, in the server's mode): a sandbox-only tool on the runner is let by it (Mode 2's Archil exec runs bash);
104
+ * none given, the runner has no shell. */
105
+ export declare function blockersOf(env: NodeJS.ProcessEnv, revision: RevisionShape, settings?: ToolSettingsMap, { capped, boxes, offers, mcp, decisionPrice, computerReady, shellOf }?: {
96
106
  capped?: boolean;
97
107
  boxes?: readonly BoxOffer[];
98
108
  offers?: readonly HarnessCapability[];
@@ -101,15 +111,13 @@ export declare function blockersOf(env: NodeJS.ProcessEnv, revision: RevisionSha
101
111
  reason?: string;
102
112
  })[] | undefined;
103
113
  decisionPrice?: (model: string) => Promise<unknown>;
104
- computerReady?: (setting: {
105
- kind: string;
106
- provider?: string;
107
- }) => Promise<{
114
+ computerReady?: (setting: RevisionComputer) => Promise<{
108
115
  readonly ok: true;
109
116
  } | {
110
117
  readonly refused: string;
111
118
  readonly box?: string;
112
119
  }>;
120
+ shellOf?: (setting: RevisionComputer) => Promise<ShellPlace>;
113
121
  }): Promise<Blocker[]>;
114
122
  /** A blocker as a field issue, for a 422 or a warning. */
115
123
  export declare const issueOf: ({ field, reason, message, fix }: Blocker) => InputIssue;