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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (444) hide show
  1. package/CHANGELOG.md +270 -0
  2. package/README.md +343 -246
  3. package/dist/adapters.d.ts +0 -7
  4. package/dist/adapters.js +11 -22
  5. package/dist/agent-rows.d.ts +98 -0
  6. package/dist/agent-rows.js +1 -0
  7. package/dist/agents-store.d.ts +6 -2
  8. package/dist/agents-store.js +60 -25
  9. package/dist/agents.d.ts +9 -125
  10. package/dist/agents.js +15 -305
  11. package/dist/answer-json.d.ts +23 -0
  12. package/dist/answer-json.js +58 -0
  13. package/dist/api-only.d.ts +14 -0
  14. package/dist/api-only.js +33 -0
  15. package/dist/archil-routes.d.ts +1 -1
  16. package/dist/bash-read-only.d.ts +22 -0
  17. package/dist/bash-read-only.js +701 -0
  18. package/dist/box-egress-vm.d.ts +0 -8
  19. package/dist/box-egress-vm.js +0 -10
  20. package/dist/box-egress.d.ts +0 -4
  21. package/dist/box-egress.js +1 -16
  22. package/dist/box-paths.d.ts +25 -2
  23. package/dist/box-paths.js +79 -11
  24. package/dist/box-relay.d.ts +0 -11
  25. package/dist/box-relay.js +0 -20
  26. package/dist/box-settings.d.ts +26 -0
  27. package/dist/box-settings.js +63 -0
  28. package/dist/boxes.d.ts +21 -1
  29. package/dist/boxes.js +27 -20
  30. package/dist/browser-commands.d.ts +5 -2
  31. package/dist/browser-commands.js +4 -4
  32. package/dist/browser-computer.d.ts +5 -0
  33. package/dist/browser-computer.js +21 -0
  34. package/dist/browser-cost.d.ts +9 -6
  35. package/dist/browser-cost.js +94 -51
  36. package/dist/browser-live.d.ts +7 -20
  37. package/dist/browser-live.js +15 -93
  38. package/dist/browser-person.d.ts +18 -53
  39. package/dist/browser-person.js +94 -279
  40. package/dist/budget.d.ts +0 -4
  41. package/dist/budget.js +0 -7
  42. package/dist/cap.d.ts +8 -12
  43. package/dist/cap.js +12 -27
  44. package/dist/cli.js +61 -20
  45. package/dist/closed-pipes.d.ts +2 -0
  46. package/dist/closed-pipes.js +13 -0
  47. package/dist/computer-commands.d.ts +2 -0
  48. package/dist/computer-commands.js +2 -0
  49. package/dist/computer-keys.js +5 -2
  50. package/dist/computer-setting.d.ts +20 -4
  51. package/dist/computer-setting.js +25 -5
  52. package/dist/computers.d.ts +31 -3
  53. package/dist/computers.js +70 -11
  54. package/dist/confine.d.ts +120 -0
  55. package/dist/confine.js +436 -0
  56. package/dist/console/assets/index-RPHGlXmM.js +540 -0
  57. package/dist/console/assets/index-opTN5Naq.css +1 -0
  58. package/dist/console/index.html +2 -2
  59. package/dist/daytona-api.d.ts +0 -11
  60. package/dist/daytona-api.js +1 -82
  61. package/dist/decision-rows.d.ts +1 -1
  62. package/dist/decision-rows.js +1 -1
  63. package/dist/docker-daemon.d.ts +31 -0
  64. package/dist/docker-daemon.js +56 -0
  65. package/dist/docker-host-addresses.d.ts +37 -0
  66. package/dist/docker-host-addresses.js +110 -0
  67. package/dist/effort-guidance.js +4 -3
  68. package/dist/environment.d.ts +0 -3
  69. package/dist/environment.js +3 -5
  70. package/dist/errors.d.ts +0 -2
  71. package/dist/errors.js +6 -9
  72. package/dist/filed-answer.d.ts +32 -0
  73. package/dist/filed-answer.js +160 -0
  74. package/dist/files.d.ts +1 -11
  75. package/dist/files.js +2 -21
  76. package/dist/github-connection.d.ts +2 -2
  77. package/dist/github-connection.js +1 -1
  78. package/dist/graph-view.d.ts +3 -5
  79. package/dist/graph-view.js +4 -14
  80. package/dist/handed-values.d.ts +9 -0
  81. package/dist/handed-values.js +26 -0
  82. package/dist/harness-install.d.ts +22 -5
  83. package/dist/harness-install.js +98 -20
  84. package/dist/harness-opencode/adapter.d.ts +7 -0
  85. package/dist/harness-opencode/adapter.js +23 -6
  86. package/dist/harness-opencode/index.d.ts +1 -1
  87. package/dist/harness-opencode/index.js +1 -1
  88. package/dist/harness-opencode/verify.d.ts +17 -0
  89. package/dist/harness-opencode/verify.js +30 -10
  90. package/dist/harness-table.js +6 -1
  91. package/dist/harness.d.ts +4 -3
  92. package/dist/harness.js +16 -1
  93. package/dist/heard.js +1 -1
  94. package/dist/held-fd.d.ts +5 -0
  95. package/dist/held-fd.js +14 -0
  96. package/dist/host-calls.d.ts +20 -0
  97. package/dist/host-calls.js +12 -0
  98. package/dist/host-tools.d.ts +4 -21
  99. package/dist/host-tools.js +4 -61
  100. package/dist/host.d.ts +2 -4
  101. package/dist/host.js +2 -7
  102. package/dist/import-summary.d.ts +1 -5
  103. package/dist/import-summary.js +0 -21
  104. package/dist/import.d.ts +6 -6
  105. package/dist/import.js +62 -24
  106. package/dist/key-refusal.d.ts +5 -1
  107. package/dist/key-refusal.js +19 -4
  108. package/dist/learn/check.d.ts +6 -2
  109. package/dist/learn/check.js +83 -29
  110. package/dist/learn/folder.d.ts +5 -1
  111. package/dist/learn/folder.js +10 -3
  112. package/dist/learn/grade.d.ts +14 -0
  113. package/dist/learn/grade.js +68 -12
  114. package/dist/learn/index.d.ts +4 -4
  115. package/dist/learn/index.js +4 -4
  116. package/dist/learn/reflect.d.ts +31 -2
  117. package/dist/learn/reflect.js +79 -4
  118. package/dist/learn/relevance.d.ts +24 -0
  119. package/dist/learn/relevance.js +91 -0
  120. package/dist/learn/secrets.d.ts +8 -1
  121. package/dist/learn/secrets.js +95 -15
  122. package/dist/learn/skills.d.ts +112 -14
  123. package/dist/learn/skills.js +556 -52
  124. package/dist/learned-workflow.d.ts +37 -5
  125. package/dist/learned-workflow.js +106 -12
  126. package/dist/learning-routes.d.ts +16 -49
  127. package/dist/learning-routes.js +46 -36
  128. package/dist/learning-run.d.ts +6 -250
  129. package/dist/learning-run.js +11 -665
  130. package/dist/learning-words.d.ts +12 -5
  131. package/dist/learning-words.js +18 -9
  132. package/dist/learning.d.ts +93 -77
  133. package/dist/learning.js +176 -304
  134. package/dist/live/stream.js +1 -1
  135. package/dist/live/translate.js +13 -3
  136. package/dist/local-models.d.ts +11 -5
  137. package/dist/local-models.js +13 -8
  138. package/dist/mcp-gateway.d.ts +11 -52
  139. package/dist/mcp-gateway.js +44 -148
  140. package/dist/mcp-oauth.d.ts +10 -14
  141. package/dist/mcp-oauth.js +14 -32
  142. package/dist/mcp-probe.d.ts +0 -7
  143. package/dist/mcp-probe.js +4 -10
  144. package/dist/mcp-servers-store.d.ts +6 -6
  145. package/dist/mcp-servers-store.js +13 -15
  146. package/dist/mcp-store.js +3 -4
  147. package/dist/mcp.js +4 -3
  148. package/dist/model.d.ts +6 -7
  149. package/dist/model.js +43 -27
  150. package/dist/monid.d.ts +0 -2
  151. package/dist/monid.js +3 -6
  152. package/dist/openapi.d.ts +8 -1
  153. package/dist/openapi.js +124 -50
  154. package/dist/page.d.ts +1 -3
  155. package/dist/page.js +9 -19
  156. package/dist/paid-calls.d.ts +21 -27
  157. package/dist/paid-calls.js +28 -62
  158. package/dist/pause.d.ts +0 -2
  159. package/dist/pause.js +1 -8
  160. package/dist/place.d.ts +0 -5
  161. package/dist/place.js +0 -10
  162. package/dist/print.d.ts +2 -1
  163. package/dist/print.js +4 -2
  164. package/dist/propose.js +83 -39
  165. package/dist/push-handler.d.ts +1 -1
  166. package/dist/reflect-range.d.ts +25 -0
  167. package/dist/reflect-range.js +30 -0
  168. package/dist/refusal-words.d.ts +5 -1
  169. package/dist/refusal-words.js +5 -1
  170. package/dist/rows.d.ts +1 -1
  171. package/dist/run-cut.d.ts +0 -6
  172. package/dist/run-cut.js +0 -6
  173. package/dist/run-db.d.ts +2 -13
  174. package/dist/run-db.js +2 -41
  175. package/dist/run-launch.d.ts +19 -2
  176. package/dist/run-launch.js +13 -5
  177. package/dist/run-learning-served.d.ts +46 -2
  178. package/dist/run-learning-served.js +26 -7
  179. package/dist/run-reads-over-store.d.ts +1 -1
  180. package/dist/run-reads-over-store.js +15 -6
  181. package/dist/run-secrets.d.ts +33 -0
  182. package/dist/run-secrets.js +53 -0
  183. package/dist/run-timeline-served.d.ts +5 -1
  184. package/dist/run-timeline-served.js +19 -5
  185. package/dist/run-view.d.ts +12 -17
  186. package/dist/run-view.js +29 -28
  187. package/dist/runnable.d.ts +18 -10
  188. package/dist/runnable.js +21 -10
  189. package/dist/runner/adapter-loop.d.ts +14 -3
  190. package/dist/runner/adapter-loop.js +464 -62
  191. package/dist/runner/adapter-run-spec.d.ts +29 -8
  192. package/dist/runner/adapter-run-spec.js +96 -37
  193. package/dist/runner/adapters/index.js +11 -1
  194. package/dist/runner/adapters/pi.d.ts +15 -1
  195. package/dist/runner/adapters/pi.js +19 -5
  196. package/dist/runner/beside.d.ts +30 -3
  197. package/dist/runner/beside.js +54 -12
  198. package/dist/runner/claim-secrets.d.ts +10 -1
  199. package/dist/runner/claim-secrets.js +49 -15
  200. package/dist/runner/cli-run-spec.d.ts +2 -0
  201. package/dist/runner/cli-run-spec.js +60 -17
  202. package/dist/runner/commands.js +1 -1
  203. package/dist/runner/computer-journal.d.ts +15 -2
  204. package/dist/runner/computer-journal.js +41 -5
  205. package/dist/runner/conformance/harness.js +118 -8
  206. package/dist/runner/conformance/subject.d.ts +4 -1
  207. package/dist/runner/dispatch.d.ts +8 -1
  208. package/dist/runner/dispatch.js +81 -7
  209. package/dist/runner/end-of-run.d.ts +8 -2
  210. package/dist/runner/end-of-run.js +10 -4
  211. package/dist/runner/github-app.js +1 -1
  212. package/dist/runner/harness-loops.d.ts +9 -1
  213. package/dist/runner/harness-loops.js +15 -2
  214. package/dist/runner/journal-kinds.d.ts +30 -6
  215. package/dist/runner/journal-kinds.js +20 -5
  216. package/dist/runner/journal-reader.d.ts +1 -1
  217. package/dist/runner/journal-reader.js +2 -2
  218. package/dist/runner/learning-ask.d.ts +4 -0
  219. package/dist/runner/learning-ask.js +15 -1
  220. package/dist/runner/learning-end.d.ts +18 -3
  221. package/dist/runner/learning-end.js +113 -11
  222. package/dist/runner/learning-loop.d.ts +5 -0
  223. package/dist/runner/learning-loop.js +26 -6
  224. package/dist/runner/live-ticker.d.ts +1 -1
  225. package/dist/runner/live-ticker.js +28 -4
  226. package/dist/runner/loop-contract.d.ts +3 -2
  227. package/dist/runner/main.d.ts +64 -10
  228. package/dist/runner/main.js +165 -27
  229. package/dist/runner/mcp-claim.d.ts +1 -1
  230. package/dist/runner/mcp-claim.js +2 -3
  231. package/dist/runner/mcp-run.d.ts +2 -0
  232. package/dist/runner/mcp-run.js +15 -5
  233. package/dist/runner/memory-claim.d.ts +9 -0
  234. package/dist/runner/memory-claim.js +25 -0
  235. package/dist/runner/metrics.d.ts +33 -1
  236. package/dist/runner/metrics.js +85 -1
  237. package/dist/runner/model-route.d.ts +13 -0
  238. package/dist/runner/model-route.js +154 -11
  239. package/dist/runner/redact.d.ts +8 -2
  240. package/dist/runner/redact.js +11 -2
  241. package/dist/runner/reflect-hook.d.ts +12 -1
  242. package/dist/runner/reflect-hook.js +33 -3
  243. package/dist/runner/runner.d.ts +20 -0
  244. package/dist/runner/runner.js +56 -10
  245. package/dist/runner/store-port.d.ts +1 -1
  246. package/dist/runner/store-secrets.d.ts +3 -3
  247. package/dist/runner/store-secrets.js +8 -12
  248. package/dist/runner/text-tools.d.ts +44 -0
  249. package/dist/runner/text-tools.js +237 -0
  250. package/dist/runner/workflow-loop.d.ts +6 -0
  251. package/dist/runner/workflow-loop.js +6 -4
  252. package/dist/runner/workflow-spec.d.ts +18 -0
  253. package/dist/runner/workflow-spec.js +68 -26
  254. package/dist/runs-over-store.d.ts +8 -3
  255. package/dist/runs-over-store.js +76 -19
  256. package/dist/seal-key.d.ts +54 -15
  257. package/dist/seal-key.js +232 -82
  258. package/dist/sealed-settings-store.d.ts +19 -4
  259. package/dist/sealed-settings-store.js +9 -9
  260. package/dist/sealing.d.ts +4 -0
  261. package/dist/sealing.js +20 -0
  262. package/dist/secret-cut.d.ts +1 -1
  263. package/dist/secret-cut.js +1 -1
  264. package/dist/secret-name.d.ts +9 -0
  265. package/dist/secret-name.js +15 -0
  266. package/dist/secret-writes.d.ts +0 -1
  267. package/dist/secret-writes.js +0 -1
  268. package/dist/secrets.d.ts +2 -10
  269. package/dist/secrets.js +21 -17
  270. package/dist/server-fs.d.ts +4 -0
  271. package/dist/server-fs.js +8 -2
  272. package/dist/server-lock.d.ts +0 -24
  273. package/dist/server-lock.js +1 -80
  274. package/dist/server-secrets-store.d.ts +4 -4
  275. package/dist/server-secrets-store.js +10 -32
  276. package/dist/server-secrets.d.ts +4 -9
  277. package/dist/server-secrets.js +12 -33
  278. package/dist/server.d.ts +26 -44
  279. package/dist/server.js +229 -142
  280. package/dist/sign-ins-store.d.ts +34 -36
  281. package/dist/sign-ins-store.js +27 -38
  282. package/dist/sign-ins.d.ts +2 -119
  283. package/dist/sign-ins.js +5 -311
  284. package/dist/standard-webhooks.d.ts +1 -1
  285. package/dist/standard-webhooks.js +1 -1
  286. package/dist/stats.d.ts +3 -2
  287. package/dist/stats.js +1 -1
  288. package/dist/store/agent-body.d.ts +8 -2
  289. package/dist/store/agent-body.js +16 -4
  290. package/dist/store/index.d.ts +3 -3
  291. package/dist/store/index.js +3 -3
  292. package/dist/store/open.d.ts +18 -5
  293. package/dist/store/open.js +23 -3
  294. package/dist/store/postgres/connection.d.ts +18 -2
  295. package/dist/store/postgres/connection.js +156 -32
  296. package/dist/store/postgres/migrate.d.ts +4 -0
  297. package/dist/store/postgres/migrate.js +27 -3
  298. package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
  299. package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
  300. package/dist/store/postgres/store.d.ts +9 -2
  301. package/dist/store/postgres/store.js +9 -0
  302. package/dist/store/schema.js +1 -1
  303. package/dist/store/seal.js +2 -2
  304. package/dist/store/sqlite/connection.js +49 -5
  305. package/dist/store/sqlite/run-patch.d.ts +3 -0
  306. package/dist/store/sqlite/run-patch.js +3 -0
  307. package/dist/store/sqlite/store.js +64 -20
  308. package/dist/store/store.d.ts +38 -6
  309. package/dist/store/store.js +12 -2
  310. package/dist/store-reads/cap.d.ts +1 -1
  311. package/dist/store-reads/cap.js +22 -4
  312. package/dist/store-reads/journal.d.ts +25 -6
  313. package/dist/store-reads/journal.js +173 -21
  314. package/dist/store-reads/learning.d.ts +26 -8
  315. package/dist/store-reads/learning.js +12 -4
  316. package/dist/store-reads/workflow.d.ts +1 -1
  317. package/dist/store-reads/workflow.js +1 -1
  318. package/dist/store-view.d.ts +5 -1
  319. package/dist/store-view.js +91 -23
  320. package/dist/template-eval.d.ts +60 -4
  321. package/dist/template-eval.js +120 -54
  322. package/dist/templates.d.ts +24 -10
  323. package/dist/templates.js +69 -38
  324. package/dist/timeline/group.d.ts +33 -0
  325. package/dist/timeline/group.js +77 -0
  326. package/dist/timeline/index.d.ts +7 -0
  327. package/dist/timeline/index.js +7 -0
  328. package/dist/timeline/labels.d.ts +79 -0
  329. package/dist/timeline/labels.js +150 -0
  330. package/dist/timeline/origin.d.ts +56 -0
  331. package/dist/timeline/origin.js +92 -0
  332. package/dist/timeline/render-text.d.ts +11 -0
  333. package/dist/timeline/render-text.js +62 -0
  334. package/dist/timeline/timeline.d.ts +274 -0
  335. package/dist/timeline/timeline.js +1308 -0
  336. package/dist/timeline/util.d.ts +17 -0
  337. package/dist/timeline/util.js +49 -0
  338. package/dist/tool-gate.d.ts +41 -216
  339. package/dist/tool-gate.js +79 -540
  340. package/dist/tool-keys-store.d.ts +11 -12
  341. package/dist/tool-keys-store.js +24 -31
  342. package/dist/tool-keys.d.ts +9 -104
  343. package/dist/tool-keys.js +15 -271
  344. package/dist/tool-plane.d.ts +14 -42
  345. package/dist/tool-plane.js +23 -81
  346. package/dist/tool-settings-store.d.ts +1 -2
  347. package/dist/tool-settings-store.js +5 -8
  348. package/dist/tools.d.ts +31 -19
  349. package/dist/tools.js +101 -108
  350. package/dist/trigger-adapter.d.ts +2 -2
  351. package/dist/trigger-schedule.js +2 -1
  352. package/dist/trigger-secrets-shown.js +5 -1
  353. package/dist/trigger-targets.d.ts +13 -1
  354. package/dist/trigger-targets.js +31 -1
  355. package/dist/triggers.d.ts +2 -2
  356. package/dist/triggers.js +3 -3
  357. package/dist/turn-end.d.ts +1 -1
  358. package/dist/turn-end.js +1 -1
  359. package/dist/turns.d.ts +0 -6
  360. package/dist/turns.js +0 -19
  361. package/dist/uploads.js +1 -1
  362. package/dist/usage.d.ts +0 -2
  363. package/dist/usage.js +0 -2
  364. package/dist/validate.d.ts +2 -0
  365. package/dist/validate.js +23 -14
  366. package/dist/webhooks.d.ts +102 -76
  367. package/dist/webhooks.js +266 -233
  368. package/dist/workflow-run.d.ts +114 -0
  369. package/dist/workflow-run.js +144 -0
  370. package/dist/workspace/beneath.d.ts +19 -0
  371. package/dist/workspace/beneath.js +106 -0
  372. package/dist/workspace/computer-deps.d.ts +52 -5
  373. package/dist/workspace/computer-deps.js +154 -19
  374. package/dist/workspace/computer-for-claim.d.ts +19 -14
  375. package/dist/workspace/computer-for-claim.js +77 -16
  376. package/dist/workspace/computer-hold.d.ts +6 -1
  377. package/dist/workspace/computer-hold.js +6 -1
  378. package/dist/workspace/computer-janitor.d.ts +47 -0
  379. package/dist/workspace/computer-janitor.js +182 -0
  380. package/dist/workspace/computer-providers.d.ts +6 -2
  381. package/dist/workspace/computer-providers.js +1 -1
  382. package/dist/workspace/grep-worker.d.ts +5 -0
  383. package/dist/workspace/grep-worker.js +9 -6
  384. package/dist/workspace/index.d.ts +4 -3
  385. package/dist/workspace/index.js +4 -4
  386. package/dist/workspace/local.d.ts +11 -2
  387. package/dist/workspace/local.js +161 -43
  388. package/dist/workspace/resolve-computer.d.ts +50 -10
  389. package/dist/workspace/resolve-computer.js +46 -11
  390. package/dist/workspace/run-tools.d.ts +13 -31
  391. package/dist/workspace/run-tools.js +10 -27
  392. package/dist/workspace-paths.d.ts +0 -17
  393. package/dist/workspace-paths.js +1 -41
  394. package/dist/workspace.d.ts +0 -17
  395. package/dist/workspace.js +3 -99
  396. package/launcher/agentrun-serve +6 -33
  397. package/package.json +14 -14
  398. package/templates/README.md +9 -3
  399. package/templates/inbound-lead/agent.md +1 -1
  400. package/templates/kyb/agent.md +1 -1
  401. package/templates/market-monitor/agent.md +2 -2
  402. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  403. package/dist/app.d.ts +0 -5
  404. package/dist/app.js +0 -514
  405. package/dist/bound-files.d.ts +0 -4
  406. package/dist/bound-files.js +0 -164
  407. package/dist/bounds.d.ts +0 -26
  408. package/dist/bounds.js +0 -137
  409. package/dist/coding-tools.d.ts +0 -47
  410. package/dist/coding-tools.js +0 -189
  411. package/dist/computer-adb.d.ts +0 -12
  412. package/dist/computer-adb.js +0 -14
  413. package/dist/console/assets/index-35-7aeIZ.js +0 -519
  414. package/dist/console/assets/index-Cejbov-Y.css +0 -1
  415. package/dist/content-filter.d.ts +0 -7
  416. package/dist/content-filter.js +0 -23
  417. package/dist/disk.d.ts +0 -33
  418. package/dist/disk.js +0 -85
  419. package/dist/door-line.d.ts +0 -23
  420. package/dist/door-line.js +0 -83
  421. package/dist/grade.d.ts +0 -63
  422. package/dist/grade.js +0 -150
  423. package/dist/harness-app.d.ts +0 -69
  424. package/dist/harness-app.js +0 -1162
  425. package/dist/mcp-servers.d.ts +0 -269
  426. package/dist/mcp-servers.js +0 -456
  427. package/dist/packs.d.ts +0 -71
  428. package/dist/packs.js +0 -180
  429. package/dist/request-start.d.ts +0 -27
  430. package/dist/request-start.js +0 -381
  431. package/dist/run-box.d.ts +0 -205
  432. package/dist/run-box.js +0 -661
  433. package/dist/run-holder.d.ts +0 -52
  434. package/dist/run-holder.js +0 -139
  435. package/dist/runs.d.ts +0 -1200
  436. package/dist/runs.js +0 -4103
  437. package/dist/sealed-settings.d.ts +0 -60
  438. package/dist/sealed-settings.js +0 -178
  439. package/dist/served-only.d.ts +0 -5
  440. package/dist/served-only.js +0 -12
  441. package/dist/sessions.d.ts +0 -6
  442. package/dist/sessions.js +0 -109
  443. package/dist/workspace/computer-serves.d.ts +0 -12
  444. package/dist/workspace/computer-serves.js +0 -15
@@ -1,4 +1,3 @@
1
- import { type BoxEgress } from "./box-egress.js";
2
1
  /** What `docker info` is asked on a Mac: the daemon's OS type, its kernel, the name it gives its OS, and its host name. */
3
2
  export declare const VM_INFO_FORMAT = "{{.OSType}}|{{.KernelVersion}}|{{.OperatingSystem}}|{{.Name}}";
4
3
  /** The VM runtimes a box's network goes on for, on a Mac. */
@@ -117,10 +116,3 @@ export declare function startEgressContainer(options: {
117
116
  /** What the server hands a run's process on a Mac with the proxy container: its volume's name, which the run's Docker
118
117
  * boxes mount read-only at EGRESS_MOUNT. Unset on Linux, where the run's process starts its own proxy (box-egress.ts). */
119
118
  export declare const RUN_BOX_VOLUME_ENV = "AGENTRUN_RUN_BOX_VOLUME";
120
- /** The run's process's reading of RUN_BOX_VOLUME_ENV: the volume, or undefined when it is unset or not a name this
121
- * server makes. */
122
- export declare function runBoxVolumeOf(env: NodeJS.ProcessEnv): string | undefined;
123
- /** A run's box's egress on a Mac: the server's proxy container, its socket in the volume the Docker provider mounts on
124
- * every box (run-box.ts), so nothing for the run's process to start or bind. The volume outlives each proxy, so a box
125
- * made before one started again reaches the new one. */
126
- export declare const vmEgress: BoxEgress;
@@ -352,13 +352,3 @@ export async function startEgressContainer(options) {
352
352
  /** What the server hands a run's process on a Mac with the proxy container: its volume's name, which the run's Docker
353
353
  * boxes mount read-only at EGRESS_MOUNT. Unset on Linux, where the run's process starts its own proxy (box-egress.ts). */
354
354
  export const RUN_BOX_VOLUME_ENV = "AGENTRUN_RUN_BOX_VOLUME";
355
- /** The run's process's reading of RUN_BOX_VOLUME_ENV: the volume, or undefined when it is unset or not a name this
356
- * server makes. */
357
- export function runBoxVolumeOf(env) {
358
- const value = env[RUN_BOX_VOLUME_ENV]?.trim();
359
- return value && /^agentrun-egress-[0-9a-f]{12}$/.test(value) ? value : undefined;
360
- }
361
- /** A run's box's egress on a Mac: the server's proxy container, its socket in the volume the Docker provider mounts on
362
- * every box (run-box.ts), so nothing for the run's process to start or bind. The volume outlives each proxy, so a box
363
- * made before one started again reaches the new one. */
364
- export const vmEgress = async () => ({ socket: EGRESS_SOCKET, fresh: false });
@@ -37,8 +37,6 @@ export declare function egressDir(runId: string, uid?: number, parent?: string):
37
37
  export declare const MAX_EGRESS_PARENT: number;
38
38
  /** Whether `parent` is too long, in bytes, for a run's proxy directories (MAX_EGRESS_PARENT). */
39
39
  export declare const egressParentTooLong: (parent: string) => boolean;
40
- /** Removes a run's proxy directory once its box is gone. */
41
- export declare const removeEgressDir: (runId: string, parent?: string) => Promise<void>;
42
40
  /** Where a run's box finds its proxy: what is mounted read-only at EGRESS_MOUNT, and the socket's name there. The one
43
41
  * seam between the box's side, which is the same wherever the proxy runs (the mount, the relay, the proxy variables),
44
42
  * and where the proxy runs. Today that is hostEgress: the run's own process, its socket's directory on this machine
@@ -105,5 +103,3 @@ export type DockerNetwork = {
105
103
  /** What the server hands a run's process: the list its box reaches, resolved (boxNetworkOf), or `none`. The run's
106
104
  * process reads this, never AGENTRUN_BOX_ALLOW: unset, it is none. */
107
105
  export declare const RUN_BOX_ALLOW_ENV = "AGENTRUN_RUN_BOX_ALLOW";
108
- /** The run's process's reading of RUN_BOX_ALLOW_ENV: the list, or `none` when it says so, is unset or is not a list. */
109
- export declare function runBoxAllowOf(env: NodeJS.ProcessEnv): readonly string[] | "none";
@@ -16,7 +16,7 @@ import { connect } from "node:net";
16
16
  import { release } from "node:os";
17
17
  import { join } from "node:path";
18
18
  import { pathToFileURL } from "node:url";
19
- import { parseAllow, startEgressProxy } from "./egress-proxy.js";
19
+ import { startEgressProxy } from "./egress-proxy.js";
20
20
  import { FAUX_ENV } from "./model.js";
21
21
  import { withoutSecrets } from "./secrets.js";
22
22
  /** Where the proxy's directory is in the box, read-only. */
@@ -86,8 +86,6 @@ export function egressDir(runId, uid = process.getuid?.() ?? 0, parent = hostPar
86
86
  export const MAX_EGRESS_PARENT = 107 - Buffer.byteLength("/0123456789abcdef/.egress-0123456789ab.sock");
87
87
  /** Whether `parent` is too long, in bytes, for a run's proxy directories (MAX_EGRESS_PARENT). */
88
88
  export const egressParentTooLong = (parent) => Buffer.byteLength(parent) > MAX_EGRESS_PARENT;
89
- /** Removes a run's proxy directory once its box is gone. */
90
- export const removeEgressDir = (runId, parent) => rm(egressDir(runId, undefined, parent), { recursive: true, force: true });
91
89
  /** This user's parent directory in /tmp: made 0700, and refused unless it is a directory of this user's, not a link. */
92
90
  async function ownParent(dir) {
93
91
  await mkdir(dir, { recursive: true, mode: 0o700 });
@@ -256,16 +254,3 @@ function answers(path) {
256
254
  /** What the server hands a run's process: the list its box reaches, resolved (boxNetworkOf), or `none`. The run's
257
255
  * process reads this, never AGENTRUN_BOX_ALLOW: unset, it is none. */
258
256
  export const RUN_BOX_ALLOW_ENV = "AGENTRUN_RUN_BOX_ALLOW";
259
- /** The run's process's reading of RUN_BOX_ALLOW_ENV: the list, or `none` when it says so, is unset or is not a list. */
260
- export function runBoxAllowOf(env) {
261
- const value = env[RUN_BOX_ALLOW_ENV]?.trim();
262
- if (!value || value === "none")
263
- return "none";
264
- try {
265
- const list = parseAllow(value);
266
- return list.length ? list : "none";
267
- }
268
- catch {
269
- return "none";
270
- }
271
- }
@@ -15,12 +15,35 @@ export type DockerPaths = {
15
15
  export declare const IN_COMPOSE = "run AgentRun in a container with `docker compose up` from compose.yaml (its named data volume is how boxes reach a run's files)";
16
16
  /** An engine that cannot mount a volume's subpath. */
17
17
  export declare const OLD_ENGINE = "Docker Engine <26 can't mount a named volume's subpath: upgrade to Docker 26+";
18
+ /** Why a Docker computer can't run for a server whose Docker daemon (at `endpoint`) is another machine's: a run's
19
+ * computer mounts the run's folder (and the computer's daemon) by this server's own paths, which that daemon doesn't
20
+ * have. */
21
+ export declare const remoteDockerWords: (endpoint: string) => string;
22
+ /** Whether a daemon endpoint is another machine's: ssh://, or tcp:// to a host that is not this machine's loopback.
23
+ * Everything else is this machine's: unix:// (and fd://), npipe:// (Docker Desktop on Windows), tcp:// to loopback. Its
24
+ * Docker provider still applies its own allow-list rule to those (the provider's check where it isn't on the host). */
25
+ export declare function remoteEndpoint(endpoint: string): boolean;
26
+ /** The daemon `env`'s docker reaches, when it is another machine's (remoteEndpoint): DOCKER_HOST when set, else the
27
+ * current context's endpoint as the CLI resolves it (DOCKER_CONTEXT, else the saved current context), read as the
28
+ * computer package's Docker provider reads it (`docker context inspect`); undefined for this machine's. A context that
29
+ * can't be read is taken as this machine's: its Docker provider still refuses at create where it isn't. `docker` is
30
+ * the tests'. */
31
+ export declare function remoteDockerOf(env: NodeJS.ProcessEnv, docker?: DockerCall): Promise<string | undefined>;
32
+ export declare function remoteDockerOnce(env: NodeJS.ProcessEnv): Promise<string | undefined>;
33
+ /** Why this server can't run a Docker computer, or undefined when it can: on its Docker's own host (`here`), or in a
34
+ * container of that Docker's with its data on a named volume (`paths`: the computer mounts the run's folder and its
35
+ * daemon as that volume's subpaths, workspace/computer-deps.ts dockerVolumeOf). Any other layout says why (`reason`,
36
+ * dockerPathsOf), and so does a daemon of another machine (`remote`, remoteDockerOf's endpoint). The one check every
37
+ * reader of Docker's offer takes. */
38
+ export declare function dockerComputerRefusal(paths: DockerPaths, remote: string | undefined): string | undefined;
39
+ /** Where a runner's Docker has the data directory `data`, read once by the runner that makes a Docker computer: as the
40
+ * server reads it at its start (dockerPathsOf), on Linux alone; under `--faux` from the mountinfo file the tests name
41
+ * (FAUX_MOUNTINFO_ENV), else as a host. */
42
+ export declare function dockerPathsForRuns(env: NodeJS.ProcessEnv, data: string, platform?: NodeJS.Platform): Promise<DockerPaths>;
18
43
  /** Under `--faux` only: a file the server reads as its /proc/self/mountinfo (server.ts fauxMountinfo). */
19
44
  export declare const FAUX_MOUNTINFO_ENV = "AGENTRUN_SERVE_FAUX_MOUNTINFO";
20
45
  /** What the server hands a run's process: the paths, as JSON; empty on a host. */
21
46
  export declare const RUN_BOX_PATHS_ENV = "AGENTRUN_RUN_BOX_PATHS";
22
- /** The run's process's reading of RUN_BOX_PATHS_ENV: the paths, or undefined when it is empty or not theirs. */
23
- export declare function runBoxPathsOf(env: NodeJS.ProcessEnv): BoxPaths | undefined;
24
47
  /** The directory the runs' egress proxy sockets are in, for a server in a container: on its data volume, so a box can
25
48
  * mount its run's (box-egress.ts egressDir). */
26
49
  export declare const egressParentOf: (data: string) => string;
package/dist/box-paths.js CHANGED
@@ -5,31 +5,99 @@
5
5
  // container, as compose.yaml makes it. The server reads its own container's id from /proc/self/mountinfo (Docker binds
6
6
  // /etc/hostname from `<its root>/containers/<id>/hostname`), asks Docker for that container's mounts, and takes the
7
7
  // named volume that holds the data directory; a box then mounts the run's work/ and its egress directory as that volume's
8
- // subpaths (pi-transport's Docker `paths`, `volume-subpath`: Docker Engine 26 and later), never the volume's root. Any
9
- // other layout, or an older engine, is a reason, said once at the start, and docker is unavailable: a guess would make
10
- // every box fail at its create.
8
+ // subpaths (pi-transport's Docker `paths`, `volume-subpath`: Docker Engine 26 and later), never the volume's root, and a
9
+ // run's Docker computer mounts its run's folder and its daemon copy the same way (workspace/computer-deps.ts
10
+ // dockerVolumeOf, the Docker provider's `volume`). Any other layout, or an older engine, is a reason, said once at the
11
+ // start, and docker is unavailable: a guess would make every box fail at its create.
11
12
  import { execFile } from "node:child_process";
12
13
  import { existsSync } from "node:fs";
13
14
  import { readFile } from "node:fs/promises";
15
+ import { FAUX_ENV } from "./model.js";
14
16
  import { withoutSecrets } from "./secrets.js";
15
17
  /** The one way a server in a container runs boxes. */
16
18
  export const IN_COMPOSE = "run AgentRun in a container with `docker compose up` from compose.yaml (its named data volume is how boxes reach a run's files)";
17
19
  /** An engine that cannot mount a volume's subpath. */
18
20
  export const OLD_ENGINE = "Docker Engine <26 can't mount a named volume's subpath: upgrade to Docker 26+";
19
- /** Under `--faux` only: a file the server reads as its /proc/self/mountinfo (server.ts fauxMountinfo). */
20
- export const FAUX_MOUNTINFO_ENV = "AGENTRUN_SERVE_FAUX_MOUNTINFO";
21
- /** What the server hands a run's process: the paths, as JSON; empty on a host. */
22
- export const RUN_BOX_PATHS_ENV = "AGENTRUN_RUN_BOX_PATHS";
23
- /** The run's process's reading of RUN_BOX_PATHS_ENV: the paths, or undefined when it is empty or not theirs. */
24
- export function runBoxPathsOf(env) {
21
+ /** Why a Docker computer can't run for a server whose Docker daemon (at `endpoint`) is another machine's: a run's
22
+ * computer mounts the run's folder (and the computer's daemon) by this server's own paths, which that daemon doesn't
23
+ * have. */
24
+ export const remoteDockerWords = (endpoint) => `this server's Docker daemon (${endpoint}) is another machine's: it can't mount the run's folder from this machine, so Docker computers aren't available on this setup (give the agent another computer, or run the server on the Docker host)`;
25
+ /** Loopback, by name or address: a daemon this machine reaches over its own loopback. */
26
+ const LOOPBACK = /^(localhost|127(\.\d{1,3}){3}|\[?::1\]?)$/i; // key-gate: loopback-rule names this machine only, to tell its own daemon from another machine; the line dials nothing
27
+ /** Whether a daemon endpoint is another machine's: ssh://, or tcp:// to a host that is not this machine's loopback.
28
+ * Everything else is this machine's: unix:// (and fd://), npipe:// (Docker Desktop on Windows), tcp:// to loopback. Its
29
+ * Docker provider still applies its own allow-list rule to those (the provider's check where it isn't on the host). */
30
+ export function remoteEndpoint(endpoint) {
31
+ const scheme = /^([a-z][a-z0-9+.-]*):\/\//i.exec(endpoint)?.[1]?.toLowerCase();
32
+ if (scheme === "ssh")
33
+ return true;
34
+ if (scheme !== "tcp")
35
+ return false;
36
+ let host;
37
+ try {
38
+ host = new URL(endpoint).hostname;
39
+ }
40
+ catch {
41
+ return true;
42
+ }
43
+ return !LOOPBACK.test(host);
44
+ }
45
+ /** The daemon `env`'s docker reaches, when it is another machine's (remoteEndpoint): DOCKER_HOST when set, else the
46
+ * current context's endpoint as the CLI resolves it (DOCKER_CONTEXT, else the saved current context), read as the
47
+ * computer package's Docker provider reads it (`docker context inspect`); undefined for this machine's. A context that
48
+ * can't be read is taken as this machine's: its Docker provider still refuses at create where it isn't. `docker` is
49
+ * the tests'. */
50
+ export async function remoteDockerOf(env, docker = dockerCall(env)) {
51
+ const host = env.DOCKER_HOST?.trim();
52
+ if (host)
53
+ return remoteEndpoint(host) ? host : undefined;
54
+ const ran = await docker(["context", "inspect", "--format", "{{json .Endpoints.docker.Host}}"]);
55
+ if (ran.code !== 0)
56
+ return undefined;
57
+ let endpoint;
25
58
  try {
26
- const paths = JSON.parse(env[RUN_BOX_PATHS_ENV] || "null");
27
- return typeof paths?.at === "string" && typeof paths.volume === "string" ? { at: paths.at, volume: paths.volume } : undefined;
59
+ endpoint = JSON.parse(ran.stdout.trim());
28
60
  }
29
61
  catch {
30
62
  return undefined;
31
63
  }
64
+ return typeof endpoint === "string" && remoteEndpoint(endpoint) ? endpoint : undefined;
65
+ }
66
+ /** remoteDockerOf, once per process for each environment's docker. */
67
+ const remotes = new Map();
68
+ export function remoteDockerOnce(env) {
69
+ const key = [env.PATH, env.DOCKER_HOST, env.DOCKER_CONTEXT, env.DOCKER_CONFIG].map((one) => one ?? "").join("\0");
70
+ let known = remotes.get(key);
71
+ if (!known)
72
+ remotes.set(key, (known = remoteDockerOf(env)));
73
+ return known;
74
+ }
75
+ /** Why this server can't run a Docker computer, or undefined when it can: on its Docker's own host (`here`), or in a
76
+ * container of that Docker's with its data on a named volume (`paths`: the computer mounts the run's folder and its
77
+ * daemon as that volume's subpaths, workspace/computer-deps.ts dockerVolumeOf). Any other layout says why (`reason`,
78
+ * dockerPathsOf), and so does a daemon of another machine (`remote`, remoteDockerOf's endpoint). The one check every
79
+ * reader of Docker's offer takes. */
80
+ export function dockerComputerRefusal(paths, remote) {
81
+ if ("reason" in paths)
82
+ return paths.reason;
83
+ return remote !== undefined ? remoteDockerWords(remote) : undefined;
84
+ }
85
+ /** Where a runner's Docker has the data directory `data`, read once by the runner that makes a Docker computer: as the
86
+ * server reads it at its start (dockerPathsOf), on Linux alone; under `--faux` from the mountinfo file the tests name
87
+ * (FAUX_MOUNTINFO_ENV), else as a host. */
88
+ export async function dockerPathsForRuns(env, data, platform = process.platform) {
89
+ if (platform !== "linux")
90
+ return { here: true };
91
+ if (env[FAUX_ENV]) {
92
+ const faux = env[FAUX_MOUNTINFO_ENV];
93
+ return faux ? dockerPathsOf(env, data, { mountinfo: await readFile(faux, "utf8"), inContainer: true }) : { here: true };
94
+ }
95
+ return dockerPathsOf(env, data);
32
96
  }
97
+ /** Under `--faux` only: a file the server reads as its /proc/self/mountinfo (server.ts fauxMountinfo). */
98
+ export const FAUX_MOUNTINFO_ENV = "AGENTRUN_SERVE_FAUX_MOUNTINFO";
99
+ /** What the server hands a run's process: the paths, as JSON; empty on a host. */
100
+ export const RUN_BOX_PATHS_ENV = "AGENTRUN_RUN_BOX_PATHS";
33
101
  /** The directory the runs' egress proxy sockets are in, for a server in a container: on its data volume, so a box can
34
102
  * mount its run's (box-egress.ts egressDir). */
35
103
  export const egressParentOf = (data) => `${data}/box-egress`;
@@ -1,8 +1,6 @@
1
1
  import type { vmRelay } from "./box-relay-vm.js";
2
2
  /** The relay's address in the data directory: `{"url": "http://<loopback>:<port>"}`. */
3
3
  export declare const BOX_RELAY_FILE = ".box-relay";
4
- /** What a run's Daytona provider sends as its key: never a key. The relay sends the server's in its place. */
5
- export declare const RELAYED_KEY = "relayed-by-the-server";
6
4
  export type BoxRelayOptions = {
7
5
  /** The data directory: where the relay's address goes. */
8
6
  root: string;
@@ -36,12 +34,3 @@ export declare function relayAddress(root: string, runDir: string): Promise<{
36
34
  url: string;
37
35
  token: string;
38
36
  }>;
39
- /** The `fetch` a run's Daytona provider uses: each call goes to the relay, which sends it on with the key. */
40
- export declare const relayFetch: (root: string, runDir: string, runId: string) => typeof fetch;
41
- /** Asks the relay for run `runId`'s box: made and seeded by the server when it has none. */
42
- export declare function relayedBox(root: string, runDir: string, runId: string, signal?: AbortSignal): Promise<{
43
- id: string;
44
- made: boolean;
45
- replaced?: boolean;
46
- apiUrl?: string;
47
- }>;
package/dist/box-relay.js CHANGED
@@ -19,8 +19,6 @@ import { readJson, RUN_DOOR_TOKEN, writeWhole } from "./files.js";
19
19
  export const BOX_RELAY_FILE = ".box-relay";
20
20
  /** Where the relay listens: only this machine's runs reach it. */
21
21
  const LOOPBACK = "127.0.0.1"; // key-gate: loopback-rule the relay listens on loopback only, for the runs of this machine
22
- /** What a run's Daytona provider sends as its key: never a key. The relay sends the server's in its place. */
23
- export const RELAYED_KEY = "relayed-by-the-server";
24
22
  /** The header that names the Daytona URL a relayed call is for. */
25
23
  const TARGET = "x-agentrun-target";
26
24
  /** The label that names a box's run (run-box.ts RUN_LABEL), kept here so the run's process loads no more than it needs. */
@@ -207,21 +205,3 @@ export async function relayAddress(root, runDir) {
207
205
  throw new Error("this server's box relay is not running, and a run reaches its remote box only through it");
208
206
  return { url, token: token.trim() };
209
207
  }
210
- /** The `fetch` a run's Daytona provider uses: each call goes to the relay, which sends it on with the key. */
211
- export const relayFetch = (root, runDir, runId) => (async (input, init) => {
212
- const { url, token } = await relayAddress(root, runDir);
213
- const headers = new Headers(init?.headers);
214
- headers.set("authorization", `Bearer ${token}`);
215
- headers.set(TARGET, input instanceof Request ? input.url : String(input));
216
- return fetch(`${url}/runs/${encodeURIComponent(runId)}/daytona`, { ...init, headers });
217
- });
218
- /** Asks the relay for run `runId`'s box: made and seeded by the server when it has none. */
219
- export async function relayedBox(root, runDir, runId, signal) {
220
- const { url, token } = await relayAddress(root, runDir);
221
- const sent = await fetch(`${url}/runs/${encodeURIComponent(runId)}/box`, { method: "POST", headers: { authorization: `Bearer ${token}` }, redirect: "error", ...(signal ? { signal } : {}) });
222
- const body = (await sent.json().catch(() => null));
223
- if (!sent.ok || typeof body?.id !== "string") {
224
- throw new Error(`the server did not give the run its box: ${typeof body?.message === "string" ? body.message : `it answered ${sent.status}`}`);
225
- }
226
- return { id: body.id, made: body.made === true, ...(body.replaced === true ? { replaced: true } : {}), ...(typeof body.api_url === "string" ? { apiUrl: body.api_url } : {}) };
227
- }
@@ -0,0 +1,26 @@
1
+ import type { BoxProvider } from "@parcha/pi-transport";
2
+ import { type DockerNetwork, egressBlockedBy } from "./box-egress.js";
3
+ /** The setting that names the hosts a box may reach: a comma list of hosts, each a name or `*.` and a name, which
4
+ * replaces the default list; `none` for no network at all. Unset or empty, the default. */
5
+ export declare const BOX_ALLOW_ENV = "AGENTRUN_BOX_ALLOW";
6
+ /** Whether the operator set the setting (a list of their own, or none), not left it to the default: a browser is held to
7
+ * the operator's list, never to the default, which is a sandbox's package-install list and no browsing policy. */
8
+ export declare const boxAllowSetIn: (env: NodeJS.ProcessEnv) => boolean;
9
+ /** The hosts a box reaches when the setting names none: the package registries pip and npm (and yarn) install from, and
10
+ * GitHub for a clone or an archive. */
11
+ export declare const DEFAULT_BOX_ALLOW: readonly string[];
12
+ /** The most hosts the list may hold: Daytona's own limit on a sandbox's domain list. */
13
+ export declare const MAX_BOX_ALLOW = 100;
14
+ /** The hosts a box may reach, from `env`'s AGENTRUN_BOX_ALLOW: its list, lower-cased, each host once; the default list when
15
+ * unset or empty; `none` for no network. `*`, an IP address, a CIDR, a port, a URL, or more than 100 hosts throws, saying
16
+ * what the setting takes: the start checks it (startServe), so no run meets one. */
17
+ export declare function boxAllowOf(env: NodeJS.ProcessEnv): readonly string[] | "none";
18
+ /** What a server's Docker boxes reach, resolved once at its start: the setting's list (boxAllowOf) where egressBlockedBy
19
+ * (box-egress.ts) finds the daemon is this Linux machine's own, else none with the reason; `none` from the setting, with
20
+ * it as the reason. */
21
+ export declare function boxNetworkOf(env: NodeJS.ProcessEnv, options?: Parameters<typeof egressBlockedBy>[1]): Promise<DockerNetwork>;
22
+ /** Under `--faux` only: a module whose default export, given the data root, is the provider the tests' faux box comes
23
+ * from in place of Docker. */
24
+ export declare const FAUX_BOX_ENV = "AGENTRUN_SERVE_FAUX_BOX";
25
+ /** The tests' faux box provider, from its module. */
26
+ export declare const fauxBoxes: (module: string, root: string) => Promise<BoxProvider>;
@@ -0,0 +1,63 @@
1
+ // A box's settings as the server reads them at its start: the hosts a box may reach (AGENTRUN_BOX_ALLOW) and what a
2
+ // server's Docker boxes reach from them, and, under `--faux` only, the tests' faux box provider. A setting that is not one
3
+ // throws, naming it: the start checks each, so no run meets one. A Docker computer's size (AGENTRUN_BOX_CPUS, _MEMORY,
4
+ // _PIDS) is workspace/computer-deps.ts dockerLimitsOf.
5
+ import { pathToFileURL } from "node:url";
6
+ import { egressBlockedBy } from "./box-egress.js";
7
+ import { vmDocker } from "./box-egress-vm.js";
8
+ /** The setting that names the hosts a box may reach: a comma list of hosts, each a name or `*.` and a name, which
9
+ * replaces the default list; `none` for no network at all. Unset or empty, the default. */
10
+ export const BOX_ALLOW_ENV = "AGENTRUN_BOX_ALLOW";
11
+ /** Whether the operator set the setting (a list of their own, or none), not left it to the default: a browser is held to
12
+ * the operator's list, never to the default, which is a sandbox's package-install list and no browsing policy. */
13
+ export const boxAllowSetIn = (env) => (env[BOX_ALLOW_ENV] ?? "").trim() !== "";
14
+ /** The hosts a box reaches when the setting names none: the package registries pip and npm (and yarn) install from, and
15
+ * GitHub for a clone or an archive. */
16
+ export const DEFAULT_BOX_ALLOW = Object.freeze(["pypi.org", "files.pythonhosted.org", "registry.npmjs.org", "registry.yarnpkg.com", "github.com", "codeload.github.com"]);
17
+ /** The most hosts the list may hold: Daytona's own limit on a sandbox's domain list. */
18
+ export const MAX_BOX_ALLOW = 100;
19
+ /** A host name, or `*.` and one: letters, digits and hyphens in dotted labels, the last one starting with a letter, so no
20
+ * IP address is one. */
21
+ const ALLOW_HOST = /^(?:\*\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
22
+ /** The hosts a box may reach, from `env`'s AGENTRUN_BOX_ALLOW: its list, lower-cased, each host once; the default list when
23
+ * unset or empty; `none` for no network. `*`, an IP address, a CIDR, a port, a URL, or more than 100 hosts throws, saying
24
+ * what the setting takes: the start checks it (startServe), so no run meets one. */
25
+ export function boxAllowOf(env) {
26
+ const value = (env[BOX_ALLOW_ENV] ?? "").trim();
27
+ if (!value)
28
+ return DEFAULT_BOX_ALLOW;
29
+ if (value.toLowerCase() === "none")
30
+ return "none";
31
+ const hosts = [...new Set(value.split(",").map((host) => host.trim().toLowerCase()).filter(Boolean))];
32
+ const takes = "a comma list of host names (such as pypi.org or *.pythonhosted.org), or none for no network";
33
+ const bad = hosts.find((host) => !ALLOW_HOST.test(host));
34
+ if (bad !== undefined)
35
+ throw new Error(`${BOX_ALLOW_ENV} is ${takes}: ${JSON.stringify(bad)} is not a host name${bad === "*" ? " (a box never reaches every host)" : ""}`);
36
+ if (hosts.length === 0)
37
+ throw new Error(`${BOX_ALLOW_ENV} is ${takes}; it is ${JSON.stringify(value)}`);
38
+ if (hosts.length > MAX_BOX_ALLOW)
39
+ throw new Error(`${BOX_ALLOW_ENV} names ${hosts.length} hosts; it takes at most ${MAX_BOX_ALLOW}`);
40
+ return Object.freeze(hosts);
41
+ }
42
+ /** What a server's Docker boxes reach, resolved once at its start: the setting's list (boxAllowOf) where egressBlockedBy
43
+ * (box-egress.ts) finds the daemon is this Linux machine's own, else none with the reason; `none` from the setting, with
44
+ * it as the reason. */
45
+ export async function boxNetworkOf(env, options = {}) {
46
+ const allow = boxAllowOf(env);
47
+ if (allow === "none")
48
+ return { allow: "none", reason: `${BOX_ALLOW_ENV} is none` };
49
+ const blocked = await egressBlockedBy(env, options);
50
+ if (!blocked)
51
+ return { allow };
52
+ // On a Mac only: a Docker that docker info names as a VM runtime this server knows gets the proxy container
53
+ // (box-egress-vm.ts); any other stays none, saying why.
54
+ if ((options.platform ?? process.platform) !== "darwin")
55
+ return { allow: "none", reason: blocked };
56
+ const vm = await vmDocker(env, { ...(options.platform ? { platform: options.platform } : {}), ...(options.kernel ? { kernel: options.kernel } : {}), ...(options.timeoutMs ? { timeoutMs: options.timeoutMs } : {}) });
57
+ return "runtime" in vm ? { allow, vm: vm.runtime } : { allow: "none", reason: vm.reason };
58
+ }
59
+ /** Under `--faux` only: a module whose default export, given the data root, is the provider the tests' faux box comes
60
+ * from in place of Docker. */
61
+ export const FAUX_BOX_ENV = "AGENTRUN_SERVE_FAUX_BOX";
62
+ /** The tests' faux box provider, from its module. */
63
+ export const fauxBoxes = async (module, root) => (await import(pathToFileURL(module).href)).default(root);
package/dist/boxes.d.ts CHANGED
@@ -16,7 +16,9 @@ export type BoxId = (typeof BOX_IDS)[number];
16
16
  * more than the probe did (box-image.ts): `preparing` is available, its image still coming. */
17
17
  /** A box as capabilities show it. `network`: what an available box reaches (BOX_NETWORKS), with `network_reason` when
18
18
  * it is available and has none for a cause of its own (a Docker in a VM, a daemon elsewhere; a Daytona that could not
19
- * keep its domain list). */
19
+ * keep its domain list). `host_addresses`: for Docker from a container (compose.yaml), the Docker host's own addresses
20
+ * its computers' egress proxy refuses as the host's (docker-host-addresses.ts: the read through the socket and
21
+ * AGENTRUN_DOCKER_HOST_ADDRESSES). */
20
22
  export type BoxOffer = {
21
23
  id: BoxId;
22
24
  available: boolean;
@@ -24,6 +26,7 @@ export type BoxOffer = {
24
26
  reason?: string;
25
27
  network?: BoxNetwork;
26
28
  network_reason?: string;
29
+ host_addresses?: string[];
27
30
  };
28
31
  /** What an available box reaches: the hosts of `places.allow` (`allowlist`), or nothing (`none`). */
29
32
  export declare const BOX_NETWORKS: readonly ["allowlist", "none"];
@@ -87,3 +90,20 @@ export declare function enabledBoxes(env: NodeJS.ProcessEnv): Set<BoxId>;
87
90
  export declare function boxRegistry(env: NodeJS.ProcessEnv, options?: BoxRegistryOptions): Promise<BoxRegistry>;
88
91
  /** The start's log line: the boxes available, the rest, and why each box AGENTRUN_BOXES lists (`listed`) is not available. */
89
92
  export declare function boxesLog(offers: readonly BoxOffer[], listed: ReadonlySet<BoxId>): Record<string, string>;
93
+ /** What `docker version` says of this machine's Docker daemon: it answers (`up`), or why not. `absent`: no daemon
94
+ * answers this process (no docker command, a call that fails, or one that names no daemon); not absent: one is there,
95
+ * and its socket refuses this process (the group it lacks). */
96
+ export type DockerDaemon = {
97
+ readonly up: true;
98
+ } | {
99
+ readonly up: false;
100
+ readonly absent: boolean;
101
+ readonly reason: string;
102
+ };
103
+ /** Asks this machine's Docker daemon its version (`docker version`), as the Docker box's start probe and the Docker
104
+ * computer's check (docker-daemon.ts) do: the CLI is on PATH and its daemon answers this user. `signal` bounds it. */
105
+ export declare function askDockerDaemon(env: NodeJS.ProcessEnv, signal: AbortSignal, groups?: {
106
+ file: string;
107
+ user: string;
108
+ ids: readonly number[];
109
+ }): Promise<DockerDaemon>;
package/dist/boxes.js CHANGED
@@ -165,32 +165,39 @@ async function load(name, importer) {
165
165
  return { ok: false, reason: missing ? `install ${name} to use this box` : `${name} did not load (${errorName(error)})` };
166
166
  }
167
167
  }
168
+ /** Asks this machine's Docker daemon its version (`docker version`), as the Docker box's start probe and the Docker
169
+ * computer's check (docker-daemon.ts) do: the CLI is on PATH and its daemon answers this user. `signal` bounds it. */
170
+ export async function askDockerDaemon(env, signal, groups = ownGroups()) {
171
+ // Its environment is the server's through the cut a run's takes (withoutSecrets): no box key, no other secret, no
172
+ // name shaped like a key.
173
+ const dockerEnv = withoutSecrets(env);
174
+ const answer = await new Promise((resolve) => execFile("docker", ["version", "--format", "{{.Server.Version}}"], { env: dockerEnv, signal, maxBuffer: 64 * 1024 }, (error, stdout, stderr) => {
175
+ const code = error?.code;
176
+ resolve({ ...(error ? { failed: typeof code === "number" ? `exit ${code}` : errorName(error), ...(SOCKET_DENIED.test(String(stderr)) ? { denied: true } : {}) } : {}), out: String(stdout) });
177
+ }));
178
+ const absent = (reason) => ({ up: false, absent: true, reason });
179
+ // The box's probe runs once, at the start: each fix takes a restart. Docker is on by default, so its reason is often a
180
+ // first-time user's first read: what is wrong in plain words, what the probe saw, then what to do.
181
+ if (answer.failed === "ENOENT")
182
+ return absent("Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart AgentRun");
183
+ // Its socket refused this process: the group it lacks, and how to get it without a reboot (the words, never docker's):
184
+ // a restart alone where the group file already lists this user, else joining it first.
185
+ if (answer.denied)
186
+ return { up: false, absent: false, reason: (await joinedSince(groups)) ? DOCKER_NOT_IN_GROUP : DOCKER_JOIN_GROUP };
187
+ if (answer.failed)
188
+ return absent(`Docker isn't running on this machine, or this user may not use it (docker version failed: ${answer.failed}): start Docker, or add this user to the docker group, then restart AgentRun`);
189
+ if (!answer.out.trim())
190
+ return absent("Docker isn't running on this machine (docker version named no daemon): start Docker, then restart AgentRun");
191
+ return { up: true };
192
+ }
168
193
  const PROBES = {
169
194
  /** `docker version` names the daemon's version: the CLI is on PATH and its daemon answers this user. */
170
195
  async docker(env, signal, options) {
171
196
  const boxes = await load(TRANSPORT, () => import("@parcha/pi-transport/box/docker").then((module) => module.dockerBoxes));
172
197
  if (!boxes.ok)
173
198
  return unavailable("docker", boxes.reason);
174
- // Its environment is the server's through the cut a run's takes (withoutSecrets): no box key, no other secret, no
175
- // name shaped like a key.
176
- const dockerEnv = withoutSecrets(env);
177
- const answer = await new Promise((resolve) => execFile("docker", ["version", "--format", "{{.Server.Version}}"], { env: dockerEnv, signal, maxBuffer: 64 * 1024 }, (error, stdout, stderr) => {
178
- const code = error?.code;
179
- resolve({ ...(error ? { failed: typeof code === "number" ? `exit ${code}` : errorName(error), ...(SOCKET_DENIED.test(String(stderr)) ? { denied: true } : {}) } : {}), out: String(stdout) });
180
- }));
181
- // The probe runs once, at the start: each fix takes a restart. Docker is on by default, so its reason is often a
182
- // first-time user's first read: what is wrong in plain words, what the probe saw, then what to do.
183
- if (answer.failed === "ENOENT")
184
- return unavailable("docker", "Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart AgentRun");
185
- // Its socket refused this process: the group it lacks, and how to get it without a reboot (the words, never docker's):
186
- // a restart alone where the group file already lists this user, else joining it first.
187
- if (answer.denied)
188
- return unavailable("docker", (await joinedSince(options.groups ?? ownGroups())) ? DOCKER_NOT_IN_GROUP : DOCKER_JOIN_GROUP);
189
- if (answer.failed)
190
- return unavailable("docker", `Docker isn't running on this machine, or this user may not use it (docker version failed: ${answer.failed}): start Docker, or add this user to the docker group, then restart AgentRun`);
191
- if (!answer.out.trim())
192
- return unavailable("docker", "Docker isn't running on this machine (docker version named no daemon): start Docker, then restart AgentRun");
193
- return available("docker", boxes.value());
199
+ const daemon = await askDockerDaemon(env, signal, options.groups);
200
+ return daemon.up ? available("docker", boxes.value()) : unavailable("docker", daemon.reason);
194
201
  },
195
202
  /** One authenticated read the provider makes anyway: the box with a name no box has (lowercase letters, digits and
196
203
  * dashes). An answer of no such box (404) means Daytona took the key; 401 or 403 means it refused it. */
@@ -14,11 +14,14 @@ export interface JournalEntry {
14
14
  readonly kind: string;
15
15
  readonly data: unknown;
16
16
  }
17
+ /** The ask a `waiting` hand-over entry holds, or undefined when the entry is not one (or is damaged). The runner writes the
18
+ * session as `session`; a PendingAsk names it `tag`. The one reading of an ask, the server's and the run's process's. */
19
+ export declare function waitingAsk(data: unknown): PendingAsk | undefined;
17
20
  /** The browser ask the run view shows: the newest ask still waiting (unanswered and not expired), or undefined. Over the
18
- * run's journal entries and its hand-over commands, as the old openAsk read it over the run's files. (store-view.ts calls
21
+ * run's journal entries and its hand-over commands. (store-view.ts calls
19
22
  * this for the run's served `pending`.) */
20
23
  export declare function browserAsk(entries: readonly JournalEntry[], commands?: readonly Command[], now?: number): PendingAsk | undefined;
21
- /** The ask a hand-over answer targets and how it already stands, mirroring the old answerAsk's choice: the newest ask still
24
+ /** The ask a hand-over answer targets and how it already stands: the newest ask still
22
25
  * waiting, else the newest ask at all; its answer when it has one, `expired` when it is past its expiry, else open (no
23
26
  * answer). Undefined when the run has asked nothing. */
24
27
  export declare function handBackTarget(entries: readonly JournalEntry[], commands?: readonly Command[], now?: number): {
@@ -10,8 +10,8 @@ export const BROWSER_HANDOVER_KIND = "agent.handover";
10
10
  const TAG = /^[A-Za-z0-9._:-]{1,200}$/;
11
11
  const OUTCOMES = ["done", "cancelled", "expired"];
12
12
  /** The ask a `waiting` hand-over entry holds, or undefined when the entry is not one (or is damaged). The runner writes the
13
- * session as `session`; a PendingAsk names it `tag`. */
14
- function waitingAsk(data) {
13
+ * session as `session`; a PendingAsk names it `tag`. The one reading of an ask, the server's and the run's process's. */
14
+ export function waitingAsk(data) {
15
15
  const v = data;
16
16
  if (!v || v.state !== "waiting")
17
17
  return undefined;
@@ -68,13 +68,13 @@ function asksIn(entries) {
68
68
  return asks.sort((a, b) => Date.parse(b.asked_at) - Date.parse(a.asked_at) || b.id.localeCompare(a.id));
69
69
  }
70
70
  /** The browser ask the run view shows: the newest ask still waiting (unanswered and not expired), or undefined. Over the
71
- * run's journal entries and its hand-over commands, as the old openAsk read it over the run's files. (store-view.ts calls
71
+ * run's journal entries and its hand-over commands. (store-view.ts calls
72
72
  * this for the run's served `pending`.) */
73
73
  export function browserAsk(entries, commands = [], now = Date.now()) {
74
74
  const answered = answersOf(entries, commands);
75
75
  return asksIn(entries).find((ask) => !answered.has(ask.id) && Date.parse(ask.expires_at) > now);
76
76
  }
77
- /** The ask a hand-over answer targets and how it already stands, mirroring the old answerAsk's choice: the newest ask still
77
+ /** The ask a hand-over answer targets and how it already stands: the newest ask still
78
78
  * waiting, else the newest ask at all; its answer when it has one, `expired` when it is past its expiry, else open (no
79
79
  * answer). Undefined when the run has asked nothing. */
80
80
  export function handBackTarget(entries, commands = [], now = Date.now()) {
@@ -0,0 +1,5 @@
1
+ import type { BrowserProvider } from "@parcha/pi-browser";
2
+ import type { ClaimBrowser } from "./workspace/resolve-computer.js";
3
+ /** pi-browser's provider over the claim's browser `computer`. A session its provider says is gone (or not found) is gone;
4
+ * any other failure to read it is thrown in its words. */
5
+ export declare function claimBrowserProvider(computer: ClaimBrowser): BrowserProvider;
@@ -0,0 +1,21 @@
1
+ /** What a session of the claim's browser is opened with: none of a run's session settings (no proxy, Verified browser,
2
+ * place, region or context by id) and no saved profile, which the computer protocol does not carry. */
3
+ const SETTINGS = { proxies: false, verified: false, geolocation: false, region: false, context: false };
4
+ /** pi-browser's provider over the claim's browser `computer`. A session its provider says is gone (or not found) is gone;
5
+ * any other failure to read it is thrown in its words. */
6
+ export function claimBrowserProvider(computer) {
7
+ return {
8
+ name: computer.provider,
9
+ caps: { timeoutModel: "wall-clock", maxLifetimeS: computer.maxLifetimeS, survivesDisconnect: true, releaseIsAsync: false, profiles: false, extension: "preinstalled", settings: SETTINGS },
10
+ create: async (spec, signal) => ({ id: await computer.open(spec.tag, spec.maxLifetimeS, signal), tag: spec.tag }),
11
+ findByTag: async (tag, signal) => (await computer.find(tag, signal)).map((id) => ({ id, tag })),
12
+ status: (ref) => computer.url(ref.id).then(() => "running", (error) => {
13
+ const code = error?.code;
14
+ if (code === "gone" || code === "not_found")
15
+ return "gone";
16
+ throw error;
17
+ }),
18
+ attach: async (ref) => ({ sdkCdpUrl: await computer.url(ref.id) }),
19
+ release: (ref) => computer.close(ref.id),
20
+ };
21
+ }
@@ -1,16 +1,18 @@
1
1
  import type { Context } from "@earendil-works/chord";
2
2
  import type { Refusal } from "@parcha/agentrun-kernel";
3
- import { type Conversation, type Session, type ToolRegistration, type Tx } from "@earendil-works/pi-durable";
3
+ import { type Harness, type Conversation, type Session, type ToolRegistration, type Tx } from "@earendil-works/pi-durable";
4
4
  import type { SessionCharge } from "@parcha/pi-browser";
5
5
  import type { BeforeCreate } from "@parcha/pi-browser/durable";
6
+ import { BROWSER_CHARGED } from "./cap.js";
6
7
  import { type PaidBooking } from "./paid-calls.js";
7
8
  /** The run journal's record of a browser session about to be created at its provider: its tag (pi-browser's, which a
8
9
  * reconcile finds the vendor's session by), its conversation and the hold its call keeps for it (`held_usd`, null with
9
- * no cap). Written with pi-browser's own `creating` record and synced (barriers.ts browserSessionOpen) before the vendor
10
- * is asked, so a box loss never leaves a session billed that no record in the store names. */
10
+ * no cap). Written with pi-browser's own `creating` record and flushed before the vendor is asked, so a lost box never
11
+ * leaves a session billed that no record in the store names. */
11
12
  export declare const BROWSER_SESSION_OPEN = "agentrun.browser_session_open";
12
13
  /** List prices by pi-browser provider name (`provider.name`): Browserbase's (pi-browser's LIST_PRICES), $0.12 an hour with
13
- * a one-minute minimum; Kernel's headless browser, about $0.06 an hour billed by the second; a local Chrome (`cdp`), free. */
14
+ * a one-minute minimum; Kernel's headless browser, about $0.06 an hour billed by the second; a local Chrome (`cdp`, and
15
+ * the `local` computer provider's), free. */
14
16
  export declare const BROWSER_PRICES: Readonly<Record<string, {
15
17
  usdPerHour: number;
16
18
  minimumS: number;
@@ -32,6 +34,7 @@ export declare function browserPrice(provider: string, env: NodeJS.ProcessEnv):
32
34
  };
33
35
  /** A cap refusal as the run's pause reads it (its words; for good, or for room with its figures). */
34
36
  type LedgerRefusal = Refusal;
37
+ export { BROWSER_CHARGED };
35
38
  /** One run's browser bookings, for its one provider at `price` with pi-browser's idle window `idleS`. `release` lets go of
36
39
  * a conversation's session (pi-browser's release, "close"). `log` takes the line that says a charge went uncounted
37
40
  * (default: the server's stderr). */
@@ -41,12 +44,13 @@ export declare function browserSpend(provider: string, price: {
41
44
  }, idleS: number, release: (conversation: Pick<Conversation, "id" | "commit">, context: Context) => Promise<void>, log?: (line: string) => void, ledger?: {
42
45
  paid?: PaidBooking;
43
46
  pause?: (refusal: LedgerRefusal) => Promise<void>;
47
+ flush?: () => Promise<void>;
44
48
  }): {
45
49
  onCharge: (charge: SessionCharge, tx: Tx, call?: {
46
50
  callId: string;
47
51
  }) => Promise<void>;
48
52
  watch: (harness: Pick<Session, "observeCommits" | "closed">, inventory?: string) => void;
49
- reopened: (harness: Pick<Session, "snapshot">, docs: {
53
+ reopened: (harness: Pick<Session, "snapshot"> & Partial<Pick<Harness, "conversation">>, docs: {
50
54
  Inventory: unknown;
51
55
  Sessions: unknown;
52
56
  }, context: Context) => Promise<void>;
@@ -65,4 +69,3 @@ export declare function browserSpend(provider: string, price: {
65
69
  stretch: number;
66
70
  ledgerIdle: () => Promise<void>;
67
71
  };
68
- export {};