@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
@@ -0,0 +1,114 @@
1
+ import type { Context } from "@earendil-works/chord";
2
+ import type { Storage } from "@earendil-works/pi-durable";
3
+ import type { Workflow } from "@parcha/agentrun-dsl";
4
+ import type { GraphDiff, NodeState, WorkflowGraph } from "@parcha/agentrun-dsl/graph";
5
+ import type { createWorkflowExtension, WorkflowCaller, WorkflowOutcome } from "@parcha/agentrun-pi/durable";
6
+ /** A workflow run that can't be read here, in words. */
7
+ export declare class WorkflowRunUnread extends Error {
8
+ constructor(message: string);
9
+ }
10
+ export type { GraphDiff, NodeState, WorkflowGraph, WorkflowOutcome };
11
+ /** A workflow revision's body, as a store keeps it: the workflow, the tools it may call, and its skills by path. */
12
+ export type WorkflowBody = {
13
+ workflow: Workflow;
14
+ tools?: string[];
15
+ skills?: Record<string, string>;
16
+ };
17
+ /** The reads a workflow run's view needs from its journal in the one store, as a pi `Storage` serves them (read with no
18
+ * claim). */
19
+ export type WorkflowStorage = Pick<Storage, "findDocument" | "document" | "task">;
20
+ /** A started run of a workflow revision: `storage`, the run's journal in the one store, which `readWorkflowRun` and
21
+ * `workflowCarry` read; the durable runner (`startWorkflowRevision`) does not. */
22
+ export type WorkflowRunStart = {
23
+ runId: string;
24
+ storage?: WorkflowStorage;
25
+ agentId: string;
26
+ revision: {
27
+ id: string;
28
+ kind: "workflow";
29
+ body: WorkflowBody;
30
+ };
31
+ };
32
+ /** One thing wrong with a workflow, at its JSON Pointer path (empty for its root). */
33
+ export type WorkflowIssue = {
34
+ path: string;
35
+ code: string;
36
+ message: string;
37
+ };
38
+ /**
39
+ * Every issue a save of `workflow` as a workflow revision listing `tools` would refuse, and the DSL's warnings: the DSL's
40
+ * structural validation (code not run, no input), a call node `via: "tool"` whose tool is not in `tools`
41
+ * (`TOOL_NOT_LISTED`; `tools` undefined lists every tool), and what the durable runner refuses before any step (only
42
+ * once the DSL found nothing). It writes nothing.
43
+ */
44
+ export declare function workflowIssues(workflow: unknown, tools?: readonly string[]): Promise<{
45
+ issues: WorkflowIssue[];
46
+ warnings: string[];
47
+ }>;
48
+ /** How a run of a workflow revision ended, as the store's `carryBack` takes it. */
49
+ export type RunState = "completed" | "failed" | "stopped" | "escalated";
50
+ type WorkflowStarter = Pick<ReturnType<typeof createWorkflowExtension>, "start">;
51
+ type RunOptions = {
52
+ harness: WorkflowCaller;
53
+ workflows: WorkflowStarter;
54
+ context: Parameters<WorkflowStarter["start"]>[2];
55
+ run: WorkflowRunStart;
56
+ input: Record<string, unknown>;
57
+ tools: readonly string[];
58
+ };
59
+ /**
60
+ * Starts a workflow revision's run as one durable workflow task and waits for its outcome. It refuses with no task when
61
+ * the workflow uses a tool not in `tools` or does not take `input`. The run's id is its key, and the agent and the
62
+ * revision are bound beside the workflow, so the run reopened under another revision is refused
63
+ * (`RUN_STORE_BINDING_MISMATCH`) and nothing runs; reopened as itself, it resumes, or answers its outcome when it ended.
64
+ * It does not read the store file.
65
+ */
66
+ export declare function startWorkflowRevision(options: RunOptions): Promise<WorkflowOutcome>;
67
+ /**
68
+ * What the store's `carryBack` takes for a run whose workflow ended in `outcome` (its `status`, and a refusal's `code`
69
+ * and `message`): the state, and the labels of the nodes that completed, in graph order (chains aside), then `failed at
70
+ * <label>` for each deepest node that failed and `escalated at <label>` for the node a gate fired at; with none of
71
+ * these, `<state> before any node completed`. A refusal before any task is `refused: <message>`. It reads the run with
72
+ * `readWorkflowRun` over the run's journal.
73
+ */
74
+ export declare function workflowCarry(run: Pick<WorkflowRunStart, "runId" | "storage" | "revision">, outcome: Pick<WorkflowOutcome, "status"> & {
75
+ code?: string;
76
+ message?: string;
77
+ }, options?: {
78
+ context?: Context;
79
+ }): Promise<{
80
+ state: RunState;
81
+ summary: string;
82
+ }>;
83
+ /** A node's state in a run: the DSL's, and `stopped` for a node an ended run interrupted. */
84
+ export type RunNodeState = NodeState | "stopped";
85
+ /** A workflow run as its store shows it: the workflow's graph and each node's state; once the run ended, how it ended,
86
+ * the node it escalated at (its path in the graph and its label), the escalation's kind, label and summary as its
87
+ * escalate node wrote them, and the workflow's output when it completed. */
88
+ export type WorkflowRunView = {
89
+ graph: WorkflowGraph;
90
+ status: Record<string, RunNodeState>;
91
+ outcome?: RunState;
92
+ escalatedAt?: {
93
+ path: string;
94
+ label: string;
95
+ };
96
+ escalation?: {
97
+ kind: string | null;
98
+ label: string | null;
99
+ summary: string | null;
100
+ };
101
+ output?: unknown;
102
+ };
103
+ /**
104
+ * Reads a workflow run from its journal in the one store (`storage`), read-only: it never writes and takes no claim. The
105
+ * nodes' states come from the run's journal and its task's terminal result. Working means live: an ended run's
106
+ * interrupted nodes read stopped; in a failed run, every node still running at the end is drawn failed; with parallel
107
+ * branches, that can include branches that were only interrupted. A run in the driver's keyed layout keeps its map items
108
+ * apart and is refused here (WorkflowRunUnread).
109
+ */
110
+ export declare function readWorkflowRun(run: Pick<WorkflowRunStart, "runId" | "storage" | "revision"> & {
111
+ state?: RunState | "running";
112
+ }, options?: {
113
+ context?: Context;
114
+ }): Promise<WorkflowRunView>;
@@ -0,0 +1,144 @@
1
+ /** A workflow run that can't be read here, in words. */
2
+ export class WorkflowRunUnread extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = "WorkflowRunUnread";
6
+ }
7
+ }
8
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
9
+ /**
10
+ * Every issue a save of `workflow` as a workflow revision listing `tools` would refuse, and the DSL's warnings: the DSL's
11
+ * structural validation (code not run, no input), a call node `via: "tool"` whose tool is not in `tools`
12
+ * (`TOOL_NOT_LISTED`; `tools` undefined lists every tool), and what the durable runner refuses before any step (only
13
+ * once the DSL found nothing). It writes nothing.
14
+ */
15
+ export async function workflowIssues(workflow, tools) {
16
+ if (!isRecord(workflow))
17
+ return { issues: [{ path: "", code: "NODE_FIELD_INVALID", message: "the workflow must be an object" }], warnings: [] };
18
+ const { inspectWorkflow, validateWorkflow } = await import("@parcha/agentrun-dsl");
19
+ const checked = validateWorkflow(workflow, { executeCode: false });
20
+ const issues = checked.ok ? [] : checked.issues.map(({ path, code, message }) => ({ path, code, message }));
21
+ const warnings = [...(checked.warnings ?? [])];
22
+ if (issues.length)
23
+ return { issues, warnings };
24
+ if (tools) {
25
+ for (const entry of inspectWorkflow(workflow).nodes) {
26
+ if (entry.kind !== "call")
27
+ continue;
28
+ const node = entry.path.split("/").slice(1).reduce((at, part) => at?.[part.replace(/~1/g, "/").replace(/~0/g, "~")], workflow);
29
+ if (node?.via === "tool" && !tools.includes(node.tool))
30
+ issues.push({ path: entry.path, code: "TOOL_NOT_LISTED", message: `call node "${node.label}" uses the tool ${node.tool}, which the revision does not list in its tools` });
31
+ }
32
+ }
33
+ // What the durable runner refuses before any step (each label once), asked of the runner itself on a memory store.
34
+ const { memoryStore, openRecovery } = await import("@parcha/agentrun-dsl/recovery");
35
+ const driver = await openRecovery(memoryStore(), workflow, { key: "check" });
36
+ const refusal = driver.preStepRefusal;
37
+ await driver.close();
38
+ if (refusal)
39
+ issues.push(refusal.kind === "duplicate_label" ? { path: "", code: "DUPLICATE_LABEL", message: refusal.message } : { path: "", code: `DURABLE_${refusal.code}`, message: refusal.message });
40
+ return { issues, warnings };
41
+ }
42
+ /** A run's DSL outcome as the store's run state: a refusal or a failure is `failed`, a cancel `stopped`. */
43
+ const stateOf = (outcome) => outcome.status === "complete" ? "completed" : outcome.status === "stopped" ? "stopped" : outcome.status === "escalated" ? "escalated" : "failed";
44
+ /** The two refusals `startWorkflowRevision` makes before any task: no task, so no journal for `workflowCarry` to read. */
45
+ const BEFORE_ANY_TASK = new Set(["TOOL_NOT_REGISTERED", "INPUT_NOT_TAKEN"]);
46
+ /**
47
+ * Starts a workflow revision's run as one durable workflow task and waits for its outcome. It refuses with no task when
48
+ * the workflow uses a tool not in `tools` or does not take `input`. The run's id is its key, and the agent and the
49
+ * revision are bound beside the workflow, so the run reopened under another revision is refused
50
+ * (`RUN_STORE_BINDING_MISMATCH`) and nothing runs; reopened as itself, it resumes, or answers its outcome when it ended.
51
+ * It does not read the store file.
52
+ */
53
+ export async function startWorkflowRevision(options) {
54
+ const { run, input } = options;
55
+ const workflow = run.revision.body.workflow;
56
+ const { inspectWorkflow, validateWorkflow } = await import("@parcha/agentrun-dsl");
57
+ const refuse = (code, message) => ({ status: "refused", code, message });
58
+ const unregistered = inspectWorkflow(workflow).requires.tools.filter((tool) => !options.tools.includes(tool));
59
+ if (unregistered.length)
60
+ return refuse("TOOL_NOT_REGISTERED", `the workflow uses ${unregistered.length} tool(s) this host does not register`);
61
+ const fits = validateWorkflow(workflow, { executeCode: false, input });
62
+ if (!fits.ok)
63
+ return refuse("INPUT_NOT_TAKEN", `the workflow does not take this input: ${fits.issues[0]?.code ?? "invalid"} at ${fits.issues[0]?.path || "its root"}`);
64
+ const request = { key: run.runId, workflow, input, bind: { agent: run.agentId, revision: run.revision.id } };
65
+ return (await options.workflows.start(options.harness, request, options.context, { background: true })).wait(options.context);
66
+ }
67
+ /**
68
+ * What the store's `carryBack` takes for a run whose workflow ended in `outcome` (its `status`, and a refusal's `code`
69
+ * and `message`): the state, and the labels of the nodes that completed, in graph order (chains aside), then `failed at
70
+ * <label>` for each deepest node that failed and `escalated at <label>` for the node a gate fired at; with none of
71
+ * these, `<state> before any node completed`. A refusal before any task is `refused: <message>`. It reads the run with
72
+ * `readWorkflowRun` over the run's journal.
73
+ */
74
+ export async function workflowCarry(run, outcome, options = {}) {
75
+ if (outcome.status === "refused" && outcome.code !== undefined && BEFORE_ANY_TASK.has(outcome.code))
76
+ return { state: "failed", summary: `refused: ${outcome.message ?? outcome.code}` };
77
+ const view = await readWorkflowRun(run, options);
78
+ // The nodes that completed (chains, pure sequence, aside), then each deepest node that failed (a container failed only
79
+ // through a node in it is not named again), then the node the run escalated at.
80
+ const inState = (state) => view.graph.nodes.filter((node) => view.status[node.path] === state);
81
+ const done = inState("done").filter((node) => node.kind !== "chain").map((node) => node.label);
82
+ const failed = inState("failed").filter((node, _, all) => !all.some((other) => other.path.startsWith(`${node.path}/`))).map((node) => node.label);
83
+ const summary = [done.join(", "), failed.length ? `failed at ${failed.join(", ")}` : "", view.escalatedAt ? `escalated at ${view.escalatedAt.label}` : ""];
84
+ // The store refuses an empty summary: a run with none of the three still says how it ended.
85
+ const state = stateOf(outcome);
86
+ return { state, summary: summary.filter(Boolean).join("; ") || `${state} before any node completed` };
87
+ }
88
+ const text = (value) => (typeof value === "string" ? value : null);
89
+ /** A session document's value from a pi Storage: the current incarnation of `kind`'s member `key`, materialized
90
+ * (findDocument, then document), or undefined when there is none. The run view reads the run's task and its driver journal
91
+ * from the one store this way. */
92
+ async function sessionDoc(storage, kind, key, context) {
93
+ const record = await storage.findDocument({ kind, scope: { kind: "session" }, key }, "current", context);
94
+ if (!record)
95
+ return undefined;
96
+ return (await storage.document(record.id, "current", context))?.value;
97
+ }
98
+ /**
99
+ * Reads a workflow run from its journal in the one store (`storage`), read-only: it never writes and takes no claim. The
100
+ * nodes' states come from the run's journal and its task's terminal result. Working means live: an ended run's
101
+ * interrupted nodes read stopped; in a failed run, every node still running at the end is drawn failed; with parallel
102
+ * branches, that can include branches that were only interrupted. A run in the driver's keyed layout keeps its map items
103
+ * apart and is refused here (WorkflowRunUnread).
104
+ */
105
+ export async function readWorkflowRun(run, options = {}) {
106
+ const { graphNodeOf, nodeStatus, workflowGraph } = await import("@parcha/agentrun-dsl/graph");
107
+ const graph = workflowGraph(run.revision.body.workflow);
108
+ // The run's task holds how it ended, and the driver's journal holds each node's frame: the task is read before the
109
+ // journal, so a task found terminal means the journal read after it is final.
110
+ let ended;
111
+ const { storage } = run;
112
+ const context = options.context;
113
+ if (!storage || !context)
114
+ throw new WorkflowRunUnread("reading a workflow run needs its journal in the store and a context");
115
+ const task = (await sessionDoc(storage, "agentrun.task", run.runId, context))?.task;
116
+ if (typeof task === "number") {
117
+ const record = await storage.task(task, context);
118
+ const taskState = record?.state;
119
+ if (taskState?.status === "terminal")
120
+ ended = taskState.outcome;
121
+ }
122
+ const state = (await sessionDoc(storage, "agentrun.driver", run.runId, context))?.state;
123
+ // A completed task holds the run's result (complete or escalated); an aborted one was cancelled; any other failed.
124
+ const result = ended?.status === "completed" ? ended.result : undefined;
125
+ if (state?.schema === "agentrun.frozen_run.v4")
126
+ throw new WorkflowRunUnread("a run in the keyed layout is not read here");
127
+ const status = nodeStatus(graph, { pin: state?.pin ?? {}, result: result ?? null });
128
+ const outcome = ended && (result ? stateOf(result) : ended.status === "aborted" ? "stopped" : "failed");
129
+ // An ended run leaves the nodes it was running `working`. They were interrupted: stopped, or failed in a failed run,
130
+ // since the journal keeps no mark for a call that failed.
131
+ if (outcome)
132
+ for (const node of graph.nodes)
133
+ if (status[node.path] === "working")
134
+ status[node.path] = outcome === "failed" ? "failed" : "stopped";
135
+ const at = typeof result?.escalation?.executionPath === "string" ? graphNodeOf(graph, result.escalation.executionPath)?.path : undefined;
136
+ const fired = graph.nodes.find((node) => node.path === at);
137
+ return {
138
+ graph, status,
139
+ ...(outcome ? { outcome } : {}),
140
+ ...(fired ? { escalatedAt: { path: fired.path, label: fired.label } } : {}),
141
+ ...(result?.escalation ? { escalation: { kind: text(result.escalation.kind), label: text(result.escalation.label), summary: text(result.escalation.summary) } } : {}),
142
+ ...(result?.status === "complete" ? { output: result.output } : {}),
143
+ };
144
+ }
@@ -0,0 +1,19 @@
1
+ import { type FileHandle } from "node:fs/promises";
2
+ /** The no-link flags of a platform: O_NOFOLLOW (a link at the last name), O_NOFOLLOW_ANY (macOS: a link anywhere). */
3
+ export interface NoLinkFlags {
4
+ readonly O_NOFOLLOW: number;
5
+ readonly O_NOFOLLOW_ANY: number;
6
+ }
7
+ /** macOS's own values (sys/fcntl.h). node names no O_NOFOLLOW_ANY, so its bit is passed as it is. */
8
+ export declare const DARWIN_NO_LINK: NoLinkFlags;
9
+ /**
10
+ * The flags an open below the root passes on `platform`, from the caller's `flags`. On darwin O_NOFOLLOW_ANY in place
11
+ * of O_NOFOLLOW: the kernel refuses the two together (EINVAL), and O_NOFOLLOW_ANY covers the last name too. Elsewhere
12
+ * O_NOFOLLOW added, for the last name of Linux's walk. `noLink` holds the platform's values: this process's O_NOFOLLOW
13
+ * and macOS's O_NOFOLLOW_ANY by default; a test on Linux passes DARWIN_NO_LINK to compute macOS's.
14
+ */
15
+ export declare function beneathFlags(flags: number, platform: NodeJS.Platform, noLink?: NoLinkFlags): number;
16
+ /** `root`/`below` opened with `flags` (O_NOFOLLOW added), through no link anywhere below `root` (else ELOOP). */
17
+ export declare function openBeneath(root: string, below: string, flags: number, mode?: number): Promise<FileHandle>;
18
+ /** openBeneath, synchronous (grep's worker): the descriptor. */
19
+ export declare function openBeneathSync(root: string, below: string, flags: number, mode?: number): number;
@@ -0,0 +1,106 @@
1
+ // Opening a name below a trusted folder through no symbolic link anywhere on the way: how local.ts and grep-worker.ts
2
+ // open a file or folder where there is no /proc/self/fd (macOS), so that what is opened is under the root at the open
3
+ // itself, whatever the path is swapped to before or after.
4
+ //
5
+ // On macOS that is the kernel's O_NOFOLLOW_ANY (macOS 11; sys/fcntl.h): the open fails ELOOP at a link anywhere in the
6
+ // path, not only at its end. The kernel walks the path folder by folder, each lookup made in the folder before it, so a
7
+ // handle it returns was reached from the root through real folders only. node names no such flag; the bit is passed
8
+ // as it is, and node 24 runs on no macOS without it. On Linux, where local.ts takes this branch only when a test
9
+ // forces it, the same answer comes from a walk from the root: each folder opened with O_NOFOLLOW through
10
+ // /proc/self/fd/<fd> of the one before, and a link met on the way is ELOOP, as on macOS. No other platform has a way
11
+ // to refuse a link on the way, so there the open fails.
12
+ import { closeSync, constants, lstatSync, openSync } from "node:fs";
13
+ import { lstat, open } from "node:fs/promises";
14
+ const { O_DIRECTORY, O_NOFOLLOW, O_RDONLY } = constants;
15
+ /** macOS's own values (sys/fcntl.h). node names no O_NOFOLLOW_ANY, so its bit is passed as it is. */
16
+ export const DARWIN_NO_LINK = { O_NOFOLLOW: 0x100, O_NOFOLLOW_ANY: 0x20000000 };
17
+ /**
18
+ * The flags an open below the root passes on `platform`, from the caller's `flags`. On darwin O_NOFOLLOW_ANY in place
19
+ * of O_NOFOLLOW: the kernel refuses the two together (EINVAL), and O_NOFOLLOW_ANY covers the last name too. Elsewhere
20
+ * O_NOFOLLOW added, for the last name of Linux's walk. `noLink` holds the platform's values: this process's O_NOFOLLOW
21
+ * and macOS's O_NOFOLLOW_ANY by default; a test on Linux passes DARWIN_NO_LINK to compute macOS's.
22
+ */
23
+ export function beneathFlags(flags, platform, noLink = { O_NOFOLLOW, O_NOFOLLOW_ANY: DARWIN_NO_LINK.O_NOFOLLOW_ANY }) {
24
+ if (platform === "darwin")
25
+ return (flags & ~noLink.O_NOFOLLOW) | noLink.O_NOFOLLOW_ANY;
26
+ return flags | noLink.O_NOFOLLOW;
27
+ }
28
+ const DIR_FLAGS = O_RDONLY | O_DIRECTORY | O_NOFOLLOW;
29
+ const DARWIN = process.platform === "darwin";
30
+ const LINUX = process.platform === "linux";
31
+ const errno = (error) => error?.code;
32
+ const failure = (code, message) => Object.assign(new Error(`${code}: ${message}`), { code });
33
+ /** The names of `below` ("" is the root itself, else names joined by "/", none of them "", "." or ".."). */
34
+ function namesOf(below) {
35
+ const names = below === "" ? [] : below.split("/");
36
+ if (names.some((name) => name === "" || name === "." || name === ".."))
37
+ throw failure("EINVAL", `${JSON.stringify(below)} is not a path below the root`);
38
+ return names;
39
+ }
40
+ /** A link on the way as macOS has it: a folder opened with O_DIRECTORY | O_NOFOLLOW that is a link fails ENOTDIR on
41
+ * Linux, ELOOP with O_NOFOLLOW_ANY. */
42
+ const asLoop = (error, at, link) => errno(error) === "ENOTDIR" && link ? failure("ELOOP", `a symbolic link on the way, open '${at}'`) : error;
43
+ /** `root`/`below` opened with `flags` (O_NOFOLLOW added), through no link anywhere below `root` (else ELOOP). */
44
+ export async function openBeneath(root, below, flags, mode) {
45
+ const names = namesOf(below);
46
+ const how = beneathFlags(flags, process.platform);
47
+ if (DARWIN)
48
+ return open(names.length === 0 ? root : `${root}/${below}`, how, mode);
49
+ if (!LINUX)
50
+ throw failure("ENOSYS", `no open on ${process.platform} refuses a symbolic link on the way`);
51
+ if (names.length === 0)
52
+ return open(root, how, mode);
53
+ const step = async (dir, name, how, made) => {
54
+ const at = `/proc/self/fd/${dir.fd}/${name}`;
55
+ try {
56
+ return await open(at, how, made);
57
+ }
58
+ catch (error) {
59
+ throw asLoop(error, at, await lstat(at).then((stats) => stats.isSymbolicLink(), () => false));
60
+ }
61
+ };
62
+ let dir = await open(root, DIR_FLAGS);
63
+ try {
64
+ for (const name of names.slice(0, -1)) {
65
+ const above = dir;
66
+ dir = await step(dir, name, DIR_FLAGS);
67
+ await above.close();
68
+ }
69
+ return await step(dir, names.at(-1), how, mode);
70
+ }
71
+ finally {
72
+ await dir.close().catch(() => undefined);
73
+ }
74
+ }
75
+ /** openBeneath, synchronous (grep's worker): the descriptor. */
76
+ export function openBeneathSync(root, below, flags, mode) {
77
+ const names = namesOf(below);
78
+ const how = beneathFlags(flags, process.platform);
79
+ if (DARWIN)
80
+ return openSync(names.length === 0 ? root : `${root}/${below}`, how, mode);
81
+ if (!LINUX)
82
+ throw failure("ENOSYS", `no open on ${process.platform} refuses a symbolic link on the way`);
83
+ if (names.length === 0)
84
+ return openSync(root, how, mode);
85
+ const step = (dir, name, how, made) => {
86
+ const at = `/proc/self/fd/${dir}/${name}`;
87
+ try {
88
+ return openSync(at, how, made);
89
+ }
90
+ catch (error) {
91
+ throw asLoop(error, at, lstatSync(at, { throwIfNoEntry: false })?.isSymbolicLink() ?? false);
92
+ }
93
+ };
94
+ let dir = openSync(root, DIR_FLAGS);
95
+ try {
96
+ for (const name of names.slice(0, -1)) {
97
+ const above = dir;
98
+ dir = step(dir, name, DIR_FLAGS);
99
+ closeSync(above);
100
+ }
101
+ return step(dir, names.at(-1), how, mode);
102
+ }
103
+ finally {
104
+ closeSync(dir);
105
+ }
106
+ }
@@ -1,13 +1,50 @@
1
+ import { type ComputerSpec, type DockerVolume } from "@parcha/agentrun-computer";
2
+ import type { DockerPaths } from "../box-paths.js";
3
+ import { type HostRead } from "../docker-host-addresses.js";
1
4
  import type { ProviderFactories } from "../computer-keys.js";
2
5
  import type { FauxComputers } from "../faux-computers.js";
3
6
  import { type KeyEnv } from "../key-meta.js";
4
7
  import type { Store } from "../store/index.js";
5
8
  import { type ClaimComputer, type ClaimLaunch, computerForClaim, type ComputerForClaimDeps, type OpenComputerView } from "./computer-for-claim.js";
6
9
  import { type ProviderLoad } from "./computer-providers.js";
7
- import type { KindRegistry } from "./resolve-computer.js";
10
+ import { type KindRegistry } from "./resolve-computer.js";
8
11
  /** How long a run's computer lives whatever happens to the server: a bound on a leaked one, never its clean end (the old
9
12
  * box's lifetime). The clean end is the run's release. */
10
13
  export declare const COMPUTER_LIFETIME_MS: number;
14
+ /** The settings that size a Docker computer (a sandbox or a desktop): its CPUs, its memory (swap included) and how many
15
+ * processes and threads it may hold at once. Unset, the Docker provider's own defaults hold. A vendor's computer sizes
16
+ * itself and is never given them. */
17
+ export declare const BOX_CPUS_ENV = "AGENTRUN_BOX_CPUS";
18
+ export declare const BOX_MEMORY_ENV = "AGENTRUN_BOX_MEMORY";
19
+ export declare const BOX_PIDS_ENV = "AGENTRUN_BOX_PIDS";
20
+ /** A Docker computer's size, as the Docker provider takes it on its spec. */
21
+ export type DockerLimits = Pick<ComputerSpec, "cpus" | "memoryMb" | "pids">;
22
+ /** A Docker computer's size from `env`'s AGENTRUN_BOX_CPUS, _MEMORY and _PIDS: each one set, as its spec field; none set,
23
+ * none, so the provider's defaults hold. A value the Docker provider would refuse at every create throws, in its own
24
+ * words, naming the setting and what it takes: the server's start reads them (startServe), so no run meets one. */
25
+ export declare function dockerLimitsOf(env: KeyEnv): DockerLimits;
26
+ /** The Docker host's own addresses, for a Docker provider whose interfaces aren't that host's (the server in a
27
+ * container): a comma list of IP addresses. The Docker provider's egress proxy refuses them as the host's, so a
28
+ * computer's allow-list never reaches the host itself; without them it refuses any allow-list there. */
29
+ export declare const DOCKER_HOST_ADDRESSES_ENV = "AGENTRUN_DOCKER_HOST_ADDRESSES";
30
+ /** The variables the local browser's provider finds its Chrome by (the computer package's findChrome): the server's own
31
+ * values are handed to it, and no other variable of the server's. */
32
+ export declare const CHROME_LOOKUP: readonly ["CHROME_PATH", "PI_BROWSER_CHROME", "PATH"];
33
+ /** `env`'s AGENTRUN_DOCKER_HOST_ADDRESSES: its addresses, each once; undefined when unset or empty, never one made up.
34
+ * An entry that is not an IP address throws, naming it: the server's start checks the setting, so no run meets one. */
35
+ export declare function dockerHostAddressesOf(env: KeyEnv): string[] | undefined;
36
+ /** Where the Docker provider's daemon copy goes on a server in a container: under the named volume's mount, so the
37
+ * host's Docker reaches it as that volume's subpath, as it reaches the run's folder. */
38
+ export declare const DAEMON_CACHE_IN_VOLUME = ".agentrun/computerd";
39
+ /** The Docker provider's options for a server in a container of its Docker's, its data on a named volume: the volume
40
+ * and where it is mounted here (`root`), under which the run's folder and the daemon copy are mounted as the volume's
41
+ * subpaths, and that daemon copy's place under it. Undefined on a host, or where no such volume was found (its reason
42
+ * then refuses a Docker computer before a run, box-paths.ts dockerComputerRefusal). */
43
+ export type DockerComputerOptions = {
44
+ readonly volume: DockerVolume;
45
+ readonly daemonCache: string;
46
+ };
47
+ export declare function dockerVolumeOf(paths: DockerPaths): DockerComputerOptions | undefined;
11
48
  /** The deps computerForClaim takes once per process: all but the claim's own. */
12
49
  export type ComputerDeps = Omit<ComputerForClaimDeps, "mode" | "workspace" | "sealKey" | "revokeMount" | "signal">;
13
50
  export interface ComputerDepsOptions {
@@ -22,8 +59,18 @@ export interface ComputerDepsOptions {
22
59
  readonly kinds?: KindRegistry;
23
60
  /** How a provider is built from its id and options: the package's providerFor unless given (a test's stand-in). */
24
61
  readonly load?: ProviderLoad;
62
+ /** Where this process's Docker has the data directory (box-paths.ts dockerPathsForRuns), read once when a Docker
63
+ * provider is first built: in a container with a named data volume, the provider mounts by that volume
64
+ * (dockerVolumeOf). Absent: as on a host. */
65
+ readonly dockerPaths?: () => Promise<DockerPaths>;
66
+ /** The Docker host's own addresses, read through its socket (docker-host-addresses.ts hostAddressesOnce), for a server
67
+ * in a container of its Docker's: unioned with AGENTRUN_DOCKER_HOST_ADDRESSES. Absent: the operator's alone. */
68
+ readonly hostAddresses?: () => Promise<HostRead>;
25
69
  /** Whether a provider that binds a folder of this machine answers here now (Docker), for the Mode 1 default. */
26
70
  readonly answers?: ComputerForClaimDeps["answers"];
71
+ /** This machine's Docker daemon, asked when a Docker launch fails (docker-daemon.ts dockerDaemonCheck over `env`
72
+ * unless given; none under --faux, whose launch is its own). */
73
+ readonly daemon?: ComputerForClaimDeps["daemon"];
27
74
  /** The live view's registration for a desktop or a phone (proxy-only): absent, no view is opened. */
28
75
  readonly openComputerView?: OpenComputerView;
29
76
  /** --faux's computers (faux-computers.ts), in place of the computer package's: their kind registry, key table, launch
@@ -33,10 +80,10 @@ export interface ComputerDepsOptions {
33
80
  /** The spec a computer of `kind` on `entry` is made with, besides its labels and its mount: its image (Docker's: the
34
81
  * owner's AGENTRUN_DOCKER_IMAGE when set, else for a sandbox the package's recipe; any other provider's: its registry
35
82
  * entry's defaultImage for the kind, the computer package's PROVIDERS[].defaultImage; a kind with none refused in
36
- * words, a Docker desktop's saying it needs an image with an X server, which the recipe lacks), the leak bound for its lifetime (its clean end is the run's release), and its network. box_allow is a
37
- * sandbox's egress list: a sandbox with none, or "none", has no network; a browser, desktop or phone with none has its
38
- * provider's own ("open"); an explicit list or "none" applies to any kind, narrowed to "none" for a provider that makes
39
- * no other (networkOf). No key and no environment. */
83
+ * words, a Docker desktop's saying it needs an image with an X server, which the recipe lacks), the leak bound for its lifetime (its clean end is the run's release), and its network
84
+ * (networkOf): the run's box_allow, or this server's own (AGENTRUN_BOX_ALLOW, read from `env`) for a launch that names
85
+ * none; and a Docker computer's size, AGENTRUN_BOX_CPUS, _MEMORY and _PIDS (dockerLimitsOf, read once here), on
86
+ * Docker's alone. No key and no environment. */
40
87
  export declare function computerSpecOf(env: KeyEnv): ComputerForClaimDeps["spec"];
41
88
  /** The run's timeline phase while its claim waits on its computer's image (computerForClaim's onImageWait): main's box
42
89
  * image row, the computer's noun for the box's. */