@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
@@ -15,7 +15,8 @@ import { CAP_TOLERANCE, money } from "./cap.js";
15
15
  import { ApiError, invalid, unsupported } from "./errors.js";
16
16
  import { harnessOfBody } from "./harness.js";
17
17
  import { redacted, redactedOutput } from "./key-refusal.js";
18
- import { givenOf, LEARNING_BUDGET, learnedOf } from "./learning.js";
18
+ import { LEARNING_BUDGET, learnedParts } from "./learning.js";
19
+ import { thinkingLevel } from "./model.js";
19
20
  import { resolvePlace } from "./place.js";
20
21
  import { launchBody } from "./run-launch.js";
21
22
  import { sendCommand } from "./runner/commands.js";
@@ -162,7 +163,7 @@ async function raiseRows(store, runId) {
162
163
  /** Raises the cap of an agentic or workflow run that names one, to `cap`: above its own (by more than CAP_TOLERANCE), or the
163
164
  * same as its newest raise (a retry, which changes nothing). A raise command row the run's runner reads: it resumes a run
164
165
  * paused at its cap and sends its continuation, or (for a run working now) holds the raised cap from the run's next
165
- * process, as the old path did. The answer reports whether the run resumed; the runner owns the resume itself. */
166
+ * step. The answer reports whether the run resumed; the runner owns the resume itself. */
166
167
  export async function raiseCap(store, moment, cap) {
167
168
  if (moment.importedSource !== undefined)
168
169
  throw importedRefusal(moment);
@@ -179,12 +180,23 @@ export async function raiseCap(store, moment, cap) {
179
180
  }
180
181
  if (!(cap > from + CAP_TOLERANCE))
181
182
  throw invalid([{ field: "max_cost_usd", reason: "invalid", message: `A cap is only raised: name more than the run's ${money(from)}.` }]);
182
- await sendCommand(store, moment.id, { kind: "raise", body: { capUsd: cap } });
183
- // A run paused at its cap is brought back by the raise (its runner claims it and sends its continuation); a run working
184
- // now keeps the cap its process was opened with until its next one.
183
+ try {
184
+ await sendCommand(store, moment.id, { kind: "raise", body: { capUsd: cap } });
185
+ }
186
+ catch (error) {
187
+ // A run a person stopped reads waiting on its next message (its moment is not terminal), but its row takes no command
188
+ // until a message reopens it: refused in words, nothing written. (Main took the raise and held it for the run's next
189
+ // process; that waits for a stopped run's reopen here.)
190
+ if (error instanceof RunFinal && (await store.runs.get(moment.id))?.state === "stopped")
191
+ throw new ApiError("not_continuable", "This run was stopped: send it a message to go on, then raise its cap.");
192
+ throw error;
193
+ }
194
+ // A run paused at its cap is brought back by the raise (its runner claims it and sends its continuation).
185
195
  if (moment.paused)
186
196
  return { resumed: true };
187
- return { resumed: false, ...(moment.live ? { note: `The run's process keeps the ${money(from)} cap it was opened with; the ${money(cap)} cap holds from its next process.` } : {}) };
197
+ // A run its runner holds takes the raise as its next command: its next step is admitted under the raised cap (the
198
+ // runner's loop holds the run to its newest raise), and a step already under way keeps the cap it was admitted at.
199
+ return { resumed: false, ...(moment.live ? { note: `The ${money(cap)} cap holds from the run's next step; a step already under way keeps the ${money(from)} cap it was admitted at.` } : {}) };
188
200
  }
189
201
  /** The refusal for a tool call already answered, in the old runs.ts words, by how it was answered; a withdrawal by a run
190
202
  * that ended (completed or failed, `ended`) says its run ended, never that it was stopped. */
@@ -199,6 +211,17 @@ async function sentAnswer(store, runId, id) {
199
211
  const row = (await store.commands(runId, 0)).find((command) => (command.kind === "approve" || command.kind === "deny") && command.refused === null && isObject(command.body) && command.body.approval === id);
200
212
  return row && { decision: row.kind === "approve" ? "allow" : "deny" };
201
213
  }
214
+ /** How a stop or cancel written to run `runId` before `before` (a command id; absent, any) answers every call still waiting:
215
+ * the runner reads commands in the order they were written, so it applies the stop first and withdraws (or, on a cancel,
216
+ * cancels) the call, and refuses every answer written after it. An answer written then is told so at once, the same 409
217
+ * the call's withdrawal gives, never 204 for a call that will not run. Read by the rows' order, so a stop that lands
218
+ * between this read and the answer's write is caught once the answer is written (approve). Untaken rows only, unless
219
+ * `taken` (a run already final: the end its runner applied). */
220
+ async function endBefore(store, runId, { before = Number.POSITIVE_INFINITY, taken = false } = {}) {
221
+ // The first: the runner applies the first stop or cancel it reads and stops reading there.
222
+ const row = (await store.commands(runId, 0)).find((command) => (command.kind === "stop" || command.kind === "cancel") && command.id < before && command.refused === null && (taken || command.takenAt === null));
223
+ return row && { decision: row.kind === "cancel" ? "canceled" : "withdrawn" };
224
+ }
202
225
  /** A person's answer to the tool call `id` that waits for approval (tool-gate.ts): an approve or deny command row the run's
203
226
  * runner reads and acts on. The first answer wins from the moment it is written, before the runner takes it — the same one
204
227
  * again changes nothing, another is 409 already-answered — and a run with no such waiting call is 404. Two answers at once
@@ -214,16 +237,31 @@ export async function approve(store, moment, id, decision, note) {
214
237
  return settle(given);
215
238
  if (!(moment.approvalIds?.has(id) ?? false))
216
239
  throw new ApiError("not_found", `The run ${moment.id} has no tool call ${id} waiting for approval.`);
240
+ const ending = await endBefore(store, moment.id);
241
+ if (ending)
242
+ throw alreadyAnswered(id, ending.decision);
217
243
  const body = { approval: id, ...(note !== undefined ? { note } : {}) };
244
+ let sent;
218
245
  try {
219
- await sendCommand(store, moment.id, { kind: decision === "allow" ? "approve" : "deny", body });
246
+ sent = await sendCommand(store, moment.id, { kind: decision === "allow" ? "approve" : "deny", body });
220
247
  }
221
248
  catch (error) {
249
+ // The run went final since it was read (its runner took a stop or a cancel, or it ended): its calls were answered by
250
+ // that end, so the answer is told how, never a 500.
251
+ if (error instanceof RunFinal) {
252
+ const end = await endBefore(store, moment.id, { taken: true });
253
+ throw alreadyAnswered(id, end?.decision ?? "withdrawn", end === undefined);
254
+ }
222
255
  const won = error instanceof StoreConstraint ? await sentAnswer(store, moment.id, id) : undefined;
223
256
  if (!won)
224
257
  throw error;
225
- settle(won);
258
+ return settle(won);
226
259
  }
260
+ // A stop or cancel written between the read above and this answer comes first in the runner's order: the answer will be
261
+ // refused at that end, so the person is told now.
262
+ const raced = await endBefore(store, moment.id, { before: sent.id });
263
+ if (raced)
264
+ throw alreadyAnswered(id, raced.decision);
227
265
  }
228
266
  // ---- start -----------------------------------------------------------------------------------------------------------
229
267
  /** A UUIDv7 run id: time-ordered, so a listing by start time is stable, and unique per run. */
@@ -239,21 +277,35 @@ function uuidv7(now = Date.now()) {
239
277
  const noShown = { text: (text) => text, name: (name) => name, holds: () => false };
240
278
  /** The run's learning start as the old start decided it (learning-run.ts onStart): undefined when the run does not learn (the
241
279
  * server's learning off, a workflow revision, or its revision does not say learning), else the notes its # Learned section
242
- * names (givenOf, the one decision the runner puts in the prompt), the # Learned text (learnedOf), the seed sha it starts
280
+ * names and the # Learned text (learnedParts, the one decision the runner puts in the prompt), the seed sha it starts
243
281
  * from and the count of all the seed's notes before the budget picked `given` (seedNotes) — or given empty, seed null and no
244
282
  * seedNotes when its seed cannot be read (a learning fault never refuses a run). */
245
- async function learningStartFor(deps, entry, revision, rbody) {
283
+ async function learningStartFor(deps, entry, revision, rbody, input) {
246
284
  const learns = deps.learning !== undefined && deps.learning !== "off" && revision.kind === "agentic" && rbody.learning === true;
247
285
  if (!learns || !deps.seedFor)
248
286
  return undefined;
287
+ const grade = deps.gradeModel ? { gradeModel: deps.gradeModel } : {};
249
288
  const seeded = await deps.seedFor(entry.agent.id);
289
+ // The folder could not be read (main's STOPPED.unreadable), or what it read could not be made into the start (main's
290
+ // copy that threw, STOPPED.notCopied): the run starts with nothing learned, and its learning end says which.
250
291
  if (!("seed" in seeded))
251
- return { given: [], seed: null, section: "" };
252
- const options = { budget: deps.learningBudget ?? LEARNING_BUDGET, read: Array.isArray(rbody.tools) && rbody.tools.includes("read"), shown: deps.shown ? deps.shown() : noShown };
253
- // The notes and the # Learned text are the old start's one decision (learnedParts): givenOf and learnedOf over the same
254
- // seed and options, so the runner lays exactly this section for exactly these notes and reads no learning folder. seedNotes
255
- // is the whole seed's note count, before the budget narrowed `given` (as the old seed_notes was).
256
- return { given: givenOf(seeded.seed, options), seed: seeded.seed.sha, section: learnedOf(seeded.seed, options) ?? "", seedNotes: Object.keys(seeded.seed.notes).length };
292
+ return { given: [], seed: null, section: "", seedFailed: "unreadable", ...grade };
293
+ try {
294
+ // The run's input goes to the note selector (learning.ts NoteSelector; byRelevance, the default, scores the notes by it).
295
+ const options = { budget: deps.learningBudget ?? LEARNING_BUDGET, read: Array.isArray(rbody.tools) && rbody.tools.includes("read"), shown: deps.shown ? deps.shown() : noShown, run: { input } };
296
+ // The notes and the # Learned text are the old start's one decision (learnedParts: one choice of the note selector), so
297
+ // the runner lays exactly this section for exactly these notes and reads no learning folder. seedNotes is the whole
298
+ // seed's note count, before the budget narrowed `given` (as the old seed_notes was).
299
+ const { section, given } = learnedParts(seeded.seed, options);
300
+ // The learned skills the seed offers the run, by name: each with its files (one over a run's skill budget at all is held
301
+ // by its size and never laid) and no host secret in it, as chooseSkills leaves them out. The claim lays them; the
302
+ // end-of-run turn counts the runs each served (runner/learning-end.ts draftForOf).
303
+ const skills = (seeded.seed.skills ?? []).flatMap(({ name, files }) => (files && !options.shown.holds(name) && !Object.entries(files).some(([path, text]) => options.shown.holds(path) || options.shown.holds(text)) ? [name] : []));
304
+ return { given: given.map(({ file, name }) => ({ file, name })), seed: seeded.seed.sha, section: section ?? "", seedNotes: Object.keys(seeded.seed.notes).length, ...(skills.length ? { skills } : {}), ...grade };
305
+ }
306
+ catch {
307
+ return { given: [], seed: null, section: "", seedFailed: "not_copied", ...grade };
308
+ }
257
309
  }
258
310
  /** Starts a run of `entry`'s agent from a create body, as POST /agents/{id}/runs starts it: every check the old start made
259
311
  * before a run started (prepareLaunch), then an INSERT — a queued run and its launch body in one transaction
@@ -370,22 +422,27 @@ export async function prepareLaunch(deps, entry, body, { trigger, capped = false
370
422
  // The run's model, resolved once, at start (the runner reads launch.model only).
371
423
  const model = await deps.modelOf(entry, revision);
372
424
  // The run's learning start, decided here as the old start did (learning-run.ts onStart): a run learns when the server's
373
- // learning is on and its revision says so; then its seed is read now and the notes its # Learned section names (givenOf,
425
+ // learning is on and its revision says so; then its seed is read now and the notes its # Learned section names (learnedParts,
374
426
  // the one decision) are pinned in the launch for the runner to put in the prompt. A seed that cannot be read starts it with
375
427
  // nothing (given empty, seed null); the end state is the runner's.
376
- const learning = await learningStartFor(deps, entry, revision, rbody);
428
+ const learning = await learningStartFor(deps, entry, revision, rbody, input);
429
+ // The run's effort: its own, else its revision's saved thinking, else the host's AGENT_THINKING (each a thinking level,
430
+ // else none). Nothing set: none, so the run gets no effort note and its harness's own default. Kept in its launch, so
431
+ // its harness's thinking, its guidance and its metrics all read the one value.
432
+ const effort = typeof body.effort === "string" ? body.effort : (thinkingLevel(rbody.thinking) ?? thinkingLevel(deps.planeEnv().AGENT_THINKING));
377
433
  const launch = {
378
434
  input,
379
435
  title: clip(redacted(title.trim().replace(/\s+/g, " "), deps.serverSecrets()), 80),
380
436
  place,
381
437
  harness: harnessOfBody(revision.body),
382
- ...(typeof body.effort === "string" ? { effort: body.effort } : {}),
438
+ ...(effort !== undefined ? { effort } : {}),
383
439
  ...(cap !== undefined ? { maxCostUsd: cap } : {}),
384
440
  ...(capMode !== undefined ? { capMode } : {}),
385
441
  ...(Object.keys(plane).length ? { plane } : {}),
386
442
  ...(deps.approvers !== undefined ? { approvers: deps.approvers } : {}),
387
443
  ...(deps.documents !== undefined ? { documents: deps.documents } : {}),
388
444
  ...(deps.boxAllow !== undefined ? { boxAllow: deps.boxAllow } : {}),
445
+ ...(deps.boxAllowSet ? { boxAllowSet: true } : {}),
389
446
  ...(fileIds.length ? { files: fileIds } : {}),
390
447
  ...(learning ? { learning } : {}),
391
448
  ...(trigger ? { trigger } : {}),
@@ -1,9 +1,19 @@
1
- export declare const SEAL_KEY_DIR = "agentrun";
1
+ import type { Store } from "./store/index.js";
2
+ /** The seal key's own directory in the data directory, and its file there. */
3
+ export declare const SEAL_KEY_DIR = "seal";
2
4
  export declare const SEAL_KEY_FILE = "seal.key";
5
+ /** The store setting that records the key's fingerprint. */
6
+ export declare const SEAL_KEY_SETTING = "seal_key";
7
+ /** The refusal of a store whose secrets another key sealed, word for word. */
8
+ export declare const SEALED_ELSEWHERE = "this store's secrets were sealed with another key; hand the server the original AGENTRUN_SEAL_KEY";
3
9
  /** The server has no seal key it can use, in words: it does not start. */
4
10
  export declare class SealKeyRefused extends Error {
5
11
  name: string;
6
12
  }
13
+ /** The key held is not the one the store's secrets were sealed with: it does not start. */
14
+ export declare class SealKeyNotTheStores extends SealKeyRefused {
15
+ name: string;
16
+ }
7
17
  /** The key, as bytes and as its base64 text; where it is kept (null when it was handed over); whether this start made it. */
8
18
  export type SealKey = {
9
19
  readonly key: Buffer;
@@ -11,20 +21,49 @@ export type SealKey = {
11
21
  readonly path: string | null;
12
22
  readonly generated: boolean;
13
23
  };
14
- /** The config home a seal key is kept under: XDG_CONFIG_HOME, else ~/.config; undefined with neither. */
15
- export declare const sealKeyHome: (env: NodeJS.ProcessEnv) => string | undefined;
16
- /**
17
- * The server's seal key: `given` (AGENTRUN_SEAL_KEY as it was handed) when set, else the one kept under `configHome`,
18
- * made there at the first start. Throws SealKeyRefused, in words, when there is none it can use: the server does not start.
19
- */
20
- export declare function ensureSealKey(given: string | undefined, { configHome }: {
21
- configHome: string | undefined;
24
+ /** A key a start booted: on this process's redaction list (secrets.ts holdSealKey) until release(), which its holder calls
25
+ * as it closes. */
26
+ export type BootedSealKey = SealKey & {
27
+ readonly release: () => void;
28
+ };
29
+ /** Where the data directory `dataDir` keeps its seal key. */
30
+ export declare const sealKeyPath: (dataDir: string) => string;
31
+ /** The key file's rules alone, with no store to check against: `given` (AGENTRUN_SEAL_KEY as it was handed) when set,
32
+ * else the one kept in `dataDir`, made there when there is none. A start never calls this by itself: bootSealKey checks
33
+ * the key against the store first, and makes one only for a store that holds no secret. */
34
+ export declare function ensureSealKey(given: string | undefined, { dataDir }: {
35
+ dataDir: string;
22
36
  }): SealKey;
37
+ /** The fingerprint the store records of `key`: an HMAC of a fixed label under it. Neither the key nor a hash of it alone. */
38
+ export declare const sealKeyFingerprint: (key: Buffer) => string;
39
+ /** The store slice the check reads and writes. */
40
+ export type SealKeyStore = Pick<Store, "settings" | "sealedSecrets">;
41
+ /** Who boots the key: the server's start makes one for a store that holds no secret and records its fingerprint, and so
42
+ * does the import, which sets a data directory up as the server does (never its dry run); a runner only reads one and
43
+ * checks it. */
44
+ export type SealKeyRole = "server" | "runner" | "import";
45
+ export interface BootSealKeyOptions {
46
+ /** AGENTRUN_SEAL_KEY as this process was handed it (secrets.ts handedSecret when this is not given). */
47
+ readonly given?: string | undefined;
48
+ /** Who boots it (SealKeyRole): "server" by default. */
49
+ readonly role?: SealKeyRole;
50
+ /** Told the start line when a key is made (stderr by default). */
51
+ readonly say?: (line: string) => void;
52
+ /** false: nothing is written (a dry run). With no key, a store that holds no secret then has none (undefined). */
53
+ readonly write?: boolean;
54
+ }
55
+ /** `env` (one withSecrets made) with `text` as its seal key, read by name and never enumerated, as withSecrets gives a
56
+ * secret: so what reads the key from it gets the one its start checked against its store. */
57
+ export declare function withSealKey(env: NodeJS.ProcessEnv, text: string): NodeJS.ProcessEnv;
23
58
  /** The line a start prints about its seal key: where it is, never the key. */
24
59
  export declare function sealKeyLine(seal: SealKey): string;
25
- /** The seal key every entry point boots the one way — the server, the runner and the `import` command all call this, so
26
- * there is one rule, not three copies: the key handed over (AGENTRUN_SEAL_KEY), else the one kept under the config home of
27
- * `env` (made at the first boot, only its path printed). A made key is held back as this process's own secret, so the
28
- * environment it reads next (withSecrets) carries it. Throws with the start message when there is none and none can be made.
29
- * `say` takes the made-key line (stderr by default). */
30
- export declare function bootSealKey(env?: NodeJS.ProcessEnv, say?: (line: string) => void): SealKey;
60
+ /** The seal key every entry point boots the one way, once its store is open: the server, a runner (beside the server or
61
+ * its own process) and the `import` command all call this, so there is one rule. The key handed over (AGENTRUN_SEAL_KEY),
62
+ * else the one in `dataDir`, checked against what `store` records of its key (refused, in words, when it is not the
63
+ * store's). The server's start makes a key in `dataDir` for a store that holds no secret and records its fingerprint; a
64
+ * runner or the import never makes or records one. The key is on this process's redaction list until release()
65
+ * (secrets.ts holdSealKey); its holder passes it on itself (withSealKey), and nothing reads it from the process by name. Throws SealKeyRefused with the start message when there is no key it can use. */
66
+ export declare function bootSealKey(store: SealKeyStore, dataDir: string, options?: BootSealKeyOptions & {
67
+ readonly write?: true;
68
+ }): Promise<BootedSealKey>;
69
+ export declare function bootSealKey(store: SealKeyStore, dataDir: string, options: BootSealKeyOptions): Promise<BootedSealKey | undefined>;