@parcha/agentrun-serve 0.1.0-beta.33 → 0.1.0-beta.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (466) hide show
  1. package/CHANGELOG.md +368 -0
  2. package/README.md +341 -208
  3. package/dist/adapters.d.ts +3 -4
  4. package/dist/adapters.js +18 -15
  5. package/dist/agent-rows.d.ts +99 -0
  6. package/dist/agent-rows.js +1 -0
  7. package/dist/agents-store.d.ts +6 -2
  8. package/dist/agents-store.js +75 -25
  9. package/dist/agents.d.ts +9 -125
  10. package/dist/agents.js +15 -305
  11. package/dist/answer-json.d.ts +23 -0
  12. package/dist/answer-json.js +58 -0
  13. package/dist/api-only.d.ts +1 -1
  14. package/dist/api-only.js +2 -2
  15. package/dist/archil-settings.d.ts +11 -1
  16. package/dist/archil-settings.js +10 -0
  17. package/dist/bash-read-only.d.ts +35 -0
  18. package/dist/bash-read-only.js +778 -0
  19. package/dist/box-settings.d.ts +3 -23
  20. package/dist/box-settings.js +7 -51
  21. package/dist/boxes.d.ts +17 -0
  22. package/dist/boxes.js +27 -20
  23. package/dist/browser-commands.d.ts +5 -2
  24. package/dist/browser-commands.js +4 -4
  25. package/dist/browser-computer.d.ts +5 -0
  26. package/dist/browser-computer.js +21 -0
  27. package/dist/browser-cost.d.ts +9 -6
  28. package/dist/browser-cost.js +95 -51
  29. package/dist/browser-live.d.ts +7 -20
  30. package/dist/browser-live.js +15 -93
  31. package/dist/browser-person.d.ts +18 -51
  32. package/dist/browser-person.js +94 -277
  33. package/dist/budget.d.ts +0 -5
  34. package/dist/budget.js +0 -5
  35. package/dist/cap.d.ts +14 -8
  36. package/dist/cap.js +19 -9
  37. package/dist/cli.js +71 -18
  38. package/dist/closed-pipes.d.ts +2 -0
  39. package/dist/closed-pipes.js +13 -0
  40. package/dist/computer-commands.d.ts +2 -0
  41. package/dist/computer-commands.js +2 -0
  42. package/dist/computer-keys.d.ts +20 -10
  43. package/dist/computer-keys.js +36 -54
  44. package/dist/computer-setting.d.ts +20 -3
  45. package/dist/computer-setting.js +58 -10
  46. package/dist/computers.d.ts +35 -2
  47. package/dist/computers.js +72 -11
  48. package/dist/confine.d.ts +120 -0
  49. package/dist/confine.js +436 -0
  50. package/dist/console/assets/index-B7NKTU8E.css +1 -0
  51. package/dist/console/assets/index-CXZMgJE7.js +550 -0
  52. package/dist/console/index.html +2 -2
  53. package/dist/content-filter.d.ts +7 -0
  54. package/dist/content-filter.js +23 -0
  55. package/dist/decision-cap.d.ts +7 -29
  56. package/dist/decision-cap.js +3 -94
  57. package/dist/decision-rows.d.ts +1 -1
  58. package/dist/decision-rows.js +1 -1
  59. package/dist/docker-daemon.d.ts +31 -0
  60. package/dist/docker-daemon.js +56 -0
  61. package/dist/effort-guidance.js +4 -3
  62. package/dist/environment.d.ts +0 -3
  63. package/dist/environment.js +3 -5
  64. package/dist/errors.d.ts +1 -2
  65. package/dist/errors.js +9 -9
  66. package/dist/explain.js +3 -1
  67. package/dist/filed-answer.d.ts +32 -0
  68. package/dist/filed-answer.js +160 -0
  69. package/dist/files.d.ts +1 -3
  70. package/dist/files.js +2 -4
  71. package/dist/github-connection.d.ts +1 -1
  72. package/dist/github-connection.js +25 -7
  73. package/dist/github-faux.d.ts +26 -0
  74. package/dist/github-faux.js +76 -0
  75. package/dist/github.d.ts +6 -2
  76. package/dist/github.js +5 -3
  77. package/dist/graph-served.d.ts +5 -3
  78. package/dist/graph-served.js +14 -6
  79. package/dist/graph-view.d.ts +3 -5
  80. package/dist/graph-view.js +9 -16
  81. package/dist/handed-values.d.ts +9 -0
  82. package/dist/handed-values.js +26 -0
  83. package/dist/harness-install.d.ts +1 -7
  84. package/dist/harness-install.js +1 -18
  85. package/dist/harness-opencode/adapter.d.ts +7 -0
  86. package/dist/harness-opencode/adapter.js +23 -6
  87. package/dist/harness-opencode/harness.js +0 -1
  88. package/dist/harness-opencode/host/policy.js +2 -2
  89. package/dist/harness-opencode/index.d.ts +1 -1
  90. package/dist/harness-opencode/index.js +1 -1
  91. package/dist/harness-opencode/verify.d.ts +17 -0
  92. package/dist/harness-opencode/verify.js +30 -10
  93. package/dist/harness-table.js +6 -1
  94. package/dist/heard.js +1 -1
  95. package/dist/held-fd.d.ts +5 -0
  96. package/dist/held-fd.js +14 -0
  97. package/dist/host-calls.d.ts +20 -0
  98. package/dist/host-calls.js +12 -0
  99. package/dist/host-tools.d.ts +4 -21
  100. package/dist/host-tools.js +4 -61
  101. package/dist/host.d.ts +2 -4
  102. package/dist/host.js +2 -7
  103. package/dist/import-summary.d.ts +1 -5
  104. package/dist/import-summary.js +0 -21
  105. package/dist/import.d.ts +6 -6
  106. package/dist/import.js +14 -15
  107. package/dist/index.d.ts +1 -0
  108. package/dist/index.js +1 -0
  109. package/dist/key-refusal.d.ts +5 -1
  110. package/dist/key-refusal.js +19 -4
  111. package/dist/learn/check.d.ts +8 -2
  112. package/dist/learn/check.js +85 -31
  113. package/dist/learn/folder.d.ts +11 -4
  114. package/dist/learn/folder.js +17 -19
  115. package/dist/learn/grade.d.ts +18 -1
  116. package/dist/learn/grade.js +108 -14
  117. package/dist/learn/index.d.ts +5 -5
  118. package/dist/learn/index.js +5 -5
  119. package/dist/learn/learning.sh +1 -14
  120. package/dist/learn/notes.d.ts +14 -3
  121. package/dist/learn/notes.js +16 -6
  122. package/dist/learn/reflect.d.ts +31 -2
  123. package/dist/learn/reflect.js +83 -6
  124. package/dist/learn/relevance.d.ts +24 -0
  125. package/dist/learn/relevance.js +91 -0
  126. package/dist/learn/secrets.d.ts +7 -1
  127. package/dist/learn/secrets.js +86 -19
  128. package/dist/learn/skills.d.ts +159 -18
  129. package/dist/learn/skills.js +644 -64
  130. package/dist/learned-nodes.d.ts +14 -0
  131. package/dist/learned-nodes.js +8 -0
  132. package/dist/learned-workflow.d.ts +41 -6
  133. package/dist/learned-workflow.js +153 -18
  134. package/dist/learning-routes.d.ts +49 -4
  135. package/dist/learning-routes.js +113 -31
  136. package/dist/learning-run.d.ts +16 -31
  137. package/dist/learning-run.js +31 -38
  138. package/dist/learning-words.d.ts +12 -5
  139. package/dist/learning-words.js +18 -9
  140. package/dist/learning.d.ts +91 -97
  141. package/dist/learning.js +176 -320
  142. package/dist/live/stream.js +1 -1
  143. package/dist/live/translate.js +12 -2
  144. package/dist/llm.d.ts +4 -1
  145. package/dist/llm.js +4 -2
  146. package/dist/local-models.d.ts +11 -5
  147. package/dist/local-models.js +13 -8
  148. package/dist/mcp-gateway.d.ts +17 -49
  149. package/dist/mcp-gateway.js +55 -136
  150. package/dist/mcp-oauth.d.ts +10 -14
  151. package/dist/mcp-oauth.js +14 -32
  152. package/dist/mcp-probe.d.ts +0 -7
  153. package/dist/mcp-probe.js +4 -10
  154. package/dist/mcp-servers-store.d.ts +18 -18
  155. package/dist/mcp-servers-store.js +12 -14
  156. package/dist/mcp-store.js +3 -4
  157. package/dist/mcp.js +4 -3
  158. package/dist/model.d.ts +9 -7
  159. package/dist/model.js +51 -27
  160. package/dist/monid.d.ts +0 -2
  161. package/dist/monid.js +3 -6
  162. package/dist/openapi.d.ts +8 -1
  163. package/dist/openapi.js +156 -58
  164. package/dist/page.d.ts +1 -3
  165. package/dist/page.js +6 -18
  166. package/dist/paid-calls.d.ts +21 -27
  167. package/dist/paid-calls.js +26 -61
  168. package/dist/pause.d.ts +2 -19
  169. package/dist/pause.js +5 -74
  170. package/dist/port-models.d.ts +10 -3
  171. package/dist/port-models.js +26 -6
  172. package/dist/propose.d.ts +2 -0
  173. package/dist/propose.js +80 -45
  174. package/dist/push-handler.d.ts +1 -1
  175. package/dist/reflect-range.d.ts +25 -0
  176. package/dist/reflect-range.js +30 -0
  177. package/dist/refusal-words.d.ts +5 -1
  178. package/dist/refusal-words.js +5 -1
  179. package/dist/rows.d.ts +1 -1
  180. package/dist/run-cut.d.ts +0 -6
  181. package/dist/run-cut.js +0 -6
  182. package/dist/run-db.d.ts +2 -11
  183. package/dist/run-db.js +2 -37
  184. package/dist/run-launch.d.ts +21 -2
  185. package/dist/run-launch.js +14 -5
  186. package/dist/run-learning-served.d.ts +21 -4
  187. package/dist/run-learning-served.js +23 -13
  188. package/dist/run-reads-over-store.d.ts +5 -3
  189. package/dist/run-reads-over-store.js +25 -14
  190. package/dist/run-secrets.d.ts +1 -1
  191. package/dist/run-timeline-served.d.ts +5 -1
  192. package/dist/run-timeline-served.js +27 -6
  193. package/dist/run-view.d.ts +37 -22
  194. package/dist/run-view.js +85 -38
  195. package/dist/runnable.d.ts +21 -10
  196. package/dist/runnable.js +35 -12
  197. package/dist/runner/adapter-loop.d.ts +36 -5
  198. package/dist/runner/adapter-loop.js +663 -69
  199. package/dist/runner/adapter-run-spec.d.ts +42 -8
  200. package/dist/runner/adapter-run-spec.js +186 -52
  201. package/dist/runner/adapters/index.js +11 -1
  202. package/dist/runner/adapters/pi.d.ts +40 -2
  203. package/dist/runner/adapters/pi.js +110 -27
  204. package/dist/runner/beside.d.ts +38 -3
  205. package/dist/runner/beside.js +54 -5
  206. package/dist/runner/claim-secrets.d.ts +16 -1
  207. package/dist/runner/claim-secrets.js +62 -14
  208. package/dist/runner/cli-run-spec.d.ts +5 -0
  209. package/dist/runner/cli-run-spec.js +159 -41
  210. package/dist/runner/commands.js +1 -1
  211. package/dist/runner/computer-journal.d.ts +15 -2
  212. package/dist/runner/computer-journal.js +41 -5
  213. package/dist/runner/conformance/harness.d.ts +1 -0
  214. package/dist/runner/conformance/harness.js +123 -13
  215. package/dist/runner/conformance/subject.d.ts +4 -1
  216. package/dist/runner/dispatch.d.ts +8 -1
  217. package/dist/runner/dispatch.js +81 -7
  218. package/dist/runner/end-of-run.d.ts +8 -2
  219. package/dist/runner/end-of-run.js +10 -4
  220. package/dist/runner/github-app.d.ts +7 -2
  221. package/dist/runner/github-app.js +47 -16
  222. package/dist/runner/harness-loops.d.ts +15 -2
  223. package/dist/runner/harness-loops.js +38 -2
  224. package/dist/runner/journal-kinds.d.ts +60 -6
  225. package/dist/runner/journal-kinds.js +43 -5
  226. package/dist/runner/journal-reader.d.ts +1 -1
  227. package/dist/runner/journal-reader.js +2 -2
  228. package/dist/runner/learning-ask.d.ts +4 -0
  229. package/dist/runner/learning-ask.js +15 -1
  230. package/dist/runner/learning-end.d.ts +18 -3
  231. package/dist/runner/learning-end.js +194 -20
  232. package/dist/runner/learning-loop.d.ts +7 -0
  233. package/dist/runner/learning-loop.js +36 -8
  234. package/dist/runner/learning-seed.d.ts +6 -0
  235. package/dist/runner/learning-seed.js +6 -0
  236. package/dist/runner/loop-contract.d.ts +4 -0
  237. package/dist/runner/main.d.ts +61 -9
  238. package/dist/runner/main.js +144 -20
  239. package/dist/runner/mcp-claim.d.ts +3 -0
  240. package/dist/runner/mcp-claim.js +7 -3
  241. package/dist/runner/mcp-github.d.ts +11 -2
  242. package/dist/runner/mcp-github.js +55 -4
  243. package/dist/runner/mcp-run.d.ts +2 -0
  244. package/dist/runner/mcp-run.js +16 -5
  245. package/dist/runner/memory-claim.d.ts +9 -0
  246. package/dist/runner/memory-claim.js +25 -0
  247. package/dist/runner/metrics.d.ts +46 -1
  248. package/dist/runner/metrics.js +156 -1
  249. package/dist/runner/model-route.d.ts +16 -0
  250. package/dist/runner/model-route.js +134 -10
  251. package/dist/runner/reflect-hook.d.ts +12 -1
  252. package/dist/runner/reflect-hook.js +33 -3
  253. package/dist/runner/runner.d.ts +20 -0
  254. package/dist/runner/runner.js +146 -18
  255. package/dist/runner/spec-holds.d.ts +7 -2
  256. package/dist/runner/spec-holds.js +4 -3
  257. package/dist/runner/store-port.d.ts +1 -1
  258. package/dist/runner/store-secrets.d.ts +3 -3
  259. package/dist/runner/store-secrets.js +8 -12
  260. package/dist/runner/text-tools.d.ts +44 -0
  261. package/dist/runner/text-tools.js +237 -0
  262. package/dist/runner/workflow-host.d.ts +7 -2
  263. package/dist/runner/workflow-host.js +3 -1
  264. package/dist/runner/workflow-loop.d.ts +10 -1
  265. package/dist/runner/workflow-loop.js +14 -6
  266. package/dist/runner/workflow-spec.d.ts +21 -0
  267. package/dist/runner/workflow-spec.js +217 -93
  268. package/dist/runs-over-store.d.ts +14 -3
  269. package/dist/runs-over-store.js +100 -23
  270. package/dist/seal-key.d.ts +0 -2
  271. package/dist/seal-key.js +5 -45
  272. package/dist/sealed-settings-store.d.ts +19 -4
  273. package/dist/sealed-settings-store.js +9 -9
  274. package/dist/sealing.d.ts +4 -0
  275. package/dist/sealing.js +20 -0
  276. package/dist/secret-cut.d.ts +1 -1
  277. package/dist/secret-cut.js +1 -1
  278. package/dist/secret-name.d.ts +9 -0
  279. package/dist/secret-name.js +15 -0
  280. package/dist/secret-writes.d.ts +0 -1
  281. package/dist/secret-writes.js +0 -1
  282. package/dist/server-fs.d.ts +4 -0
  283. package/dist/server-fs.js +8 -2
  284. package/dist/server-lock.d.ts +0 -24
  285. package/dist/server-lock.js +5 -85
  286. package/dist/server-secrets-store.d.ts +4 -4
  287. package/dist/server-secrets-store.js +9 -31
  288. package/dist/server-secrets.d.ts +4 -9
  289. package/dist/server-secrets.js +12 -36
  290. package/dist/server.d.ts +37 -56
  291. package/dist/server.js +322 -134
  292. package/dist/sign-ins-store.d.ts +34 -36
  293. package/dist/sign-ins-store.js +27 -38
  294. package/dist/sign-ins.d.ts +2 -119
  295. package/dist/sign-ins.js +5 -311
  296. package/dist/standard-webhooks.d.ts +1 -1
  297. package/dist/standard-webhooks.js +1 -1
  298. package/dist/stats.d.ts +3 -2
  299. package/dist/stats.js +1 -1
  300. package/dist/stop-signals.d.ts +4 -2
  301. package/dist/stop-signals.js +5 -3
  302. package/dist/store/agent-body.d.ts +12 -2
  303. package/dist/store/agent-body.js +22 -4
  304. package/dist/store/deadline.d.ts +18 -0
  305. package/dist/store/deadline.js +45 -0
  306. package/dist/store/index.d.ts +2 -2
  307. package/dist/store/index.js +2 -2
  308. package/dist/store/open.d.ts +6 -3
  309. package/dist/store/open.js +2 -2
  310. package/dist/store/postgres/connection.d.ts +22 -2
  311. package/dist/store/postgres/connection.js +211 -41
  312. package/dist/store/postgres/migrate.d.ts +4 -0
  313. package/dist/store/postgres/migrate.js +9 -2
  314. package/dist/store/postgres/migrations/0003_commands_one_answer.check.sql +19 -0
  315. package/dist/store/postgres/migrations/0003_commands_one_answer.sql +13 -0
  316. package/dist/store/postgres/store.d.ts +9 -2
  317. package/dist/store/postgres/store.js +9 -0
  318. package/dist/store/schema.js +1 -1
  319. package/dist/store/seal.js +2 -2
  320. package/dist/store/sqlite/connection.js +14 -5
  321. package/dist/store/sqlite/run-patch.d.ts +3 -0
  322. package/dist/store/sqlite/run-patch.js +3 -0
  323. package/dist/store/sqlite/store.js +41 -12
  324. package/dist/store/store.d.ts +35 -6
  325. package/dist/store/store.js +12 -2
  326. package/dist/store-reads/cap.d.ts +1 -1
  327. package/dist/store-reads/cap.js +22 -4
  328. package/dist/store-reads/journal.d.ts +9 -6
  329. package/dist/store-reads/journal.js +129 -18
  330. package/dist/store-reads/learning.d.ts +82 -8
  331. package/dist/store-reads/learning.js +184 -11
  332. package/dist/store-reads/workflow.d.ts +1 -1
  333. package/dist/store-reads/workflow.js +1 -1
  334. package/dist/store-view.d.ts +19 -1
  335. package/dist/store-view.js +95 -27
  336. package/dist/template-eval.d.ts +60 -4
  337. package/dist/template-eval.js +120 -54
  338. package/dist/templates.d.ts +33 -14
  339. package/dist/templates.js +82 -46
  340. package/dist/timeline/group.d.ts +33 -0
  341. package/dist/timeline/group.js +77 -0
  342. package/dist/timeline/index.d.ts +7 -0
  343. package/dist/timeline/index.js +7 -0
  344. package/dist/timeline/labels.d.ts +79 -0
  345. package/dist/timeline/labels.js +150 -0
  346. package/dist/timeline/origin.d.ts +56 -0
  347. package/dist/timeline/origin.js +92 -0
  348. package/dist/timeline/render-text.d.ts +11 -0
  349. package/dist/timeline/render-text.js +62 -0
  350. package/dist/timeline/timeline.d.ts +282 -0
  351. package/dist/timeline/timeline.js +1308 -0
  352. package/dist/timeline/util.d.ts +17 -0
  353. package/dist/timeline/util.js +49 -0
  354. package/dist/tool-budget.d.ts +18 -0
  355. package/dist/tool-budget.js +50 -0
  356. package/dist/tool-gate.d.ts +47 -218
  357. package/dist/tool-gate.js +87 -545
  358. package/dist/tool-keys-store.d.ts +11 -12
  359. package/dist/tool-keys-store.js +24 -31
  360. package/dist/tool-keys.d.ts +5 -101
  361. package/dist/tool-keys.js +8 -267
  362. package/dist/tool-plane.d.ts +23 -52
  363. package/dist/tool-plane.js +23 -81
  364. package/dist/tool-settings-store.d.ts +1 -2
  365. package/dist/tool-settings-store.js +5 -8
  366. package/dist/tools.d.ts +67 -25
  367. package/dist/tools.js +170 -119
  368. package/dist/trigger-adapter.d.ts +2 -2
  369. package/dist/trigger-targets.d.ts +13 -1
  370. package/dist/trigger-targets.js +31 -1
  371. package/dist/triggers.d.ts +2 -2
  372. package/dist/triggers.js +3 -3
  373. package/dist/turn-end.d.ts +1 -1
  374. package/dist/turn-end.js +1 -1
  375. package/dist/turns.d.ts +0 -6
  376. package/dist/turns.js +0 -19
  377. package/dist/uploads.d.ts +28 -5
  378. package/dist/uploads.js +83 -10
  379. package/dist/usage.d.ts +1 -49
  380. package/dist/usage.js +3 -84
  381. package/dist/validate.d.ts +4 -0
  382. package/dist/validate.js +33 -14
  383. package/dist/webhooks.d.ts +102 -76
  384. package/dist/webhooks.js +266 -233
  385. package/dist/workflow-run.d.ts +114 -0
  386. package/dist/workflow-run.js +144 -0
  387. package/dist/workspace/archil-claim.d.ts +2 -2
  388. package/dist/workspace/archil-claim.js +4 -3
  389. package/dist/workspace/archil-disk.d.ts +10 -1
  390. package/dist/workspace/archil-disk.js +4 -0
  391. package/dist/workspace/archil-exec.d.ts +12 -2
  392. package/dist/workspace/archil-exec.js +16 -0
  393. package/dist/workspace/archil.d.ts +2 -2
  394. package/dist/workspace/archil.js +25 -5
  395. package/dist/workspace/attach.js +2 -0
  396. package/dist/workspace/beneath.d.ts +19 -0
  397. package/dist/workspace/beneath.js +106 -0
  398. package/dist/workspace/computer-deps.d.ts +26 -9
  399. package/dist/workspace/computer-deps.js +144 -43
  400. package/dist/workspace/computer-for-claim.d.ts +17 -14
  401. package/dist/workspace/computer-for-claim.js +99 -26
  402. package/dist/workspace/computer-hold.d.ts +6 -1
  403. package/dist/workspace/computer-hold.js +6 -1
  404. package/dist/workspace/computer-janitor.d.ts +47 -0
  405. package/dist/workspace/computer-janitor.js +182 -0
  406. package/dist/workspace/computer-ledger.d.ts +1 -8
  407. package/dist/workspace/computer-ledger.js +0 -3
  408. package/dist/workspace/computer-providers.d.ts +5 -3
  409. package/dist/workspace/computer-providers.js +11 -9
  410. package/dist/workspace/grep-worker.d.ts +5 -0
  411. package/dist/workspace/grep-worker.js +9 -6
  412. package/dist/workspace/hands.d.ts +5 -2
  413. package/dist/workspace/hands.js +4 -3
  414. package/dist/workspace/index.d.ts +6 -5
  415. package/dist/workspace/index.js +4 -4
  416. package/dist/workspace/local.d.ts +14 -2
  417. package/dist/workspace/local.js +170 -43
  418. package/dist/workspace/paths.js +3 -2
  419. package/dist/workspace/pi-env.d.ts +4 -0
  420. package/dist/workspace/pi-env.js +3 -2
  421. package/dist/workspace/resolve-computer.d.ts +55 -10
  422. package/dist/workspace/resolve-computer.js +66 -14
  423. package/dist/workspace/run-tools.d.ts +15 -31
  424. package/dist/workspace/run-tools.js +19 -30
  425. package/dist/workspace/workspace.d.ts +5 -0
  426. package/dist/workspace-paths.d.ts +0 -17
  427. package/dist/workspace-paths.js +1 -41
  428. package/dist/workspace.d.ts +0 -17
  429. package/dist/workspace.js +4 -110
  430. package/package.json +14 -14
  431. package/skills/agentrun-serve/SKILL.md +1 -1
  432. package/templates/README.md +11 -5
  433. package/templates/code-review/evals/mentions-defused/case.yaml +15 -0
  434. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +254 -0
  435. package/templates/code-review/evals/mentions-defused/graders/no-pings.md +16 -0
  436. package/templates/code-review/evals/mentions-defused/graders/posted-a-review.md +5 -0
  437. package/templates/code-review/evals/mentions-defused/graders/schema.md +5 -0
  438. package/templates/code-review/evals/mentions-defused/prompt.md +10 -0
  439. package/templates/kyb/evals/clean-public-company/graders/no-opensanctions.md +5 -0
  440. package/templates/kyb/evals/opensanctions-on/case.yaml +5 -0
  441. package/templates/kyb/evals/opensanctions-on/graders/licence-and-evidence.md +18 -0
  442. package/templates/kyb/evals/opensanctions-on/graders/schema.md +5 -0
  443. package/templates/kyb/evals/opensanctions-on/prompt.md +11 -0
  444. package/templates/market-monitor/agent.md +2 -2
  445. package/templates/market-monitor/skills/monitor/SKILL.md +6 -4
  446. package/templates/release-notes/agent.md +11 -0
  447. package/dist/bound-files.d.ts +0 -4
  448. package/dist/bound-files.js +0 -164
  449. package/dist/coding-tools.d.ts +0 -47
  450. package/dist/coding-tools.js +0 -189
  451. package/dist/computer-adb.d.ts +0 -12
  452. package/dist/computer-adb.js +0 -14
  453. package/dist/console/assets/index-Dn0ngwG9.js +0 -535
  454. package/dist/console/assets/index-DvW6Aled.css +0 -1
  455. package/dist/grade.d.ts +0 -63
  456. package/dist/grade.js +0 -150
  457. package/dist/mcp-servers.d.ts +0 -269
  458. package/dist/mcp-servers.js +0 -456
  459. package/dist/packs.d.ts +0 -71
  460. package/dist/packs.js +0 -180
  461. package/dist/sealed-settings.d.ts +0 -60
  462. package/dist/sealed-settings.js +0 -171
  463. package/dist/sessions.d.ts +0 -6
  464. package/dist/sessions.js +0 -109
  465. package/dist/workspace/computer-serves.d.ts +0 -12
  466. package/dist/workspace/computer-serves.js +0 -15
@@ -6,8 +6,18 @@
6
6
  // a folder swapped for a link after the walk is never followed: the read, write, rename, unlink, readdir, mkdir and
7
7
  // exec's working directory all go through the handle. The last part is opened with O_NOFOLLOW, or acted on by a call
8
8
  // that does not follow it (rename, unlink, rmdir), after an lstat refuses a link there. A recursive remove walks the
9
- // tree by handles too, and removes a link it meets, never what it points at. Elsewhere (macOS) the walk is the same, but
10
- // later calls resolve the path again, so a swap between the walk and the call can be followed.
9
+ // tree by handles too, and removes a link it meets, never what it points at.
10
+ //
11
+ // Elsewhere (macOS: Docker Desktop binds the run's folder, so a box process can swap a folder in it for a link) there
12
+ // is no /proc/self/fd, and node has no openat, so later calls resolve the path again. There every open (each folder the
13
+ // walk holds, and each file a read, write, append or grep opens) refuses a link anywhere below the root, not only at
14
+ // the end (beneath.ts: macOS's O_NOFOLLOW_ANY): a folder swapped for a link before or during the open is ELOOP, so
15
+ // ESCAPE, and what the handle holds was reached through real folders of the root's at the open itself. Nothing is
16
+ // resolved again after it, so a swap after the open, or one that comes and goes, changes nothing a read returns. A
17
+ // call that acts on a name instead (unlink, rmdir, rename, readdir, lstat, mkdir, exec's cwd) checks, just before,
18
+ // that its folder's path opens the same way to the folder held: a link swapped in by then is ESCAPE. What remains is
19
+ // the gap between that check and the call itself, which only an unlinkat or a fchdir closes. The path-resolving branch
20
+ // is chosen by `procFd`, so a test runs it on Linux too.
11
21
  //
12
22
  // Durability. write is a temporary file in the same folder (O_EXCL), its bytes, fsync, rename over the name, then fsync
13
23
  // of the folder. append is O_APPEND, its bytes, fdatasync, and the folder's fsync when it made the file. mkdir fsyncs
@@ -28,6 +38,7 @@ import { access, lstat, mkdir as makeDir, open, readdir, realpath, rename, rmdir
28
38
  import { join } from "node:path";
29
39
  import { Worker } from "node:worker_threads";
30
40
  import { attachedWorkspace, checkReadBack, noProcesses } from "./attach.js";
41
+ import { openBeneath } from "./beneath.js";
31
42
  import { relativeSegments } from "./paths.js";
32
43
  import { abortError, EXEC_OUTPUT_MAX, GREP_FILE_MAX, GREP_LINE_MAX, GREP_MAX, GREP_TIME_MS, READ_MAX, WorkspaceError, } from "./workspace.js";
33
44
  const { O_APPEND, O_CREAT, O_DIRECTORY, O_EXCL, O_NOFOLLOW, O_NONBLOCK, O_RDONLY, O_RDWR, O_WRONLY } = constants;
@@ -72,64 +83,155 @@ const bytesOf = (data) => {
72
83
  throw new WorkspaceError("REFUSED", "data is bytes (a Uint8Array) or a string");
73
84
  };
74
85
  const byName = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
86
+ /** A link swapped in on the way to `path` since it was walked: ESCAPE. */
87
+ const swapped = (path) => new WorkspaceError("ESCAPE", `${show(path)} runs through a symbolic link swapped in on the way, and a workspace follows none`, { path });
75
88
  /** A folder held open. On Linux a name in it resolves through /proc/self/fd/<fd>, inside the folder the handle holds,
76
- * never through the folder's path again; elsewhere through its path. */
89
+ * never through the folder's path again; elsewhere through its path: opened through no link (open), and each other
90
+ * act checked first (confirm). */
77
91
  class Held {
78
92
  handle;
79
93
  abs;
80
- constructor(handle, abs) {
94
+ reach;
95
+ constructor(handle, abs, reach) {
81
96
  this.handle = handle;
82
97
  this.abs = abs;
98
+ this.reach = reach;
99
+ }
100
+ /** The folder's path below the root ("" for the root). */
101
+ get below() {
102
+ return this.abs === this.reach.root ? "" : this.abs.slice(this.reach.root.length + 1);
83
103
  }
84
104
  /** The folder itself, as a path a call (or exec's cwd) can take. */
85
105
  get self() {
86
- return LINUX ? `/proc/self/fd/${this.handle.fd}` : this.abs;
106
+ return this.reach.procFd ? `/proc/self/fd/${this.handle.fd}` : this.abs;
87
107
  }
88
108
  /** Entry `name` of the folder. */
89
109
  at(name) {
90
- return LINUX ? `/proc/self/fd/${this.handle.fd}/${name}` : join(this.abs, name);
110
+ return this.reach.procFd ? `/proc/self/fd/${this.handle.fd}/${name}` : join(this.abs, name);
111
+ }
112
+ /** Entry `name` opened with `flags`. Off /proc/self/fd through no link anywhere below the root (beneath.ts): a link
113
+ * on the way, a folder swapped for one, fails ELOOP, so what opens is under the root. */
114
+ open(name, flags, mode) {
115
+ if (this.reach.procFd)
116
+ return open(this.at(name), flags, mode);
117
+ return openBeneath(this.reach.root, this.below === "" ? name : `${this.below}/${name}`, flags, mode);
118
+ }
119
+ /** Off /proc/self/fd, that this folder's path still opens, through no link, to the folder held (dev and inode), else
120
+ * ESCAPE (NOT_FOUND when it is gone): run just before each call that resolves a name in it again. On Linux there is
121
+ * nothing to check. */
122
+ async confirm(path) {
123
+ if (this.reach.procFd)
124
+ return;
125
+ let there;
126
+ try {
127
+ there = await openBeneath(this.reach.root, this.below, DIR_FLAGS);
128
+ }
129
+ catch (error) {
130
+ if (errno(error) === "ELOOP")
131
+ throw swapped(path);
132
+ throw failed(error, path);
133
+ }
134
+ try {
135
+ const [held, now] = await Promise.all([this.handle.stat(), there.stat()]);
136
+ if (now.dev !== held.dev || now.ino !== held.ino)
137
+ throw swapped(path);
138
+ }
139
+ finally {
140
+ await there.close();
141
+ }
142
+ }
143
+ /** Makes entry `name`, the file `made` just made by `open`, durable: syncs the folder it was made in. On Linux that is
144
+ * the folder held. Elsewhere `open` went by the folder's path, which may name another folder under the root by now
145
+ * (one put in its place), so the folder the path opens now, through no link, is synced, once its `name` is that very
146
+ * file (dev and inode); else ESCAPE, as for any swap. */
147
+ async syncMade(name, made, path) {
148
+ if (this.reach.procFd)
149
+ return this.handle.sync();
150
+ let parent;
151
+ let entry;
152
+ try {
153
+ parent = await openBeneath(this.reach.root, this.below, DIR_FLAGS);
154
+ entry = await openBeneath(this.reach.root, this.below === "" ? name : `${this.below}/${name}`, O_RDONLY | O_NOFOLLOW | O_NONBLOCK);
155
+ const now = await entry.stat();
156
+ if (now.dev !== made.dev || now.ino !== made.ino)
157
+ throw swapped(path);
158
+ await parent.sync();
159
+ }
160
+ catch (error) {
161
+ throw errno(error) === "ELOOP" ? swapped(path) : error;
162
+ }
163
+ finally {
164
+ await entry?.close();
165
+ await parent?.close();
166
+ }
167
+ }
168
+ /** `fn`, its folder confirmed before and after: what it read was read in the folder held. */
169
+ async confirmed(path, fn) {
170
+ await this.confirm(path);
171
+ const result = await fn();
172
+ await this.confirm(path);
173
+ return result;
174
+ }
175
+ /** Folder `name` of this one, just opened as `handle` (by `open`), held. The caller still owns the handle (it closes
176
+ * it, whether this resolves or not). */
177
+ async hold(handle, name) {
178
+ const next = new Held(handle, join(this.abs, name), this.reach);
179
+ await this.reach.onHeld?.(next.abs);
180
+ return next;
91
181
  }
92
182
  }
93
- /** Everything in held folder `dir` removed, folders by handle: a link is removed, never followed. */
94
- async function emptyTree(dir) {
95
- for (const name of await readdir(dir.self)) {
183
+ /** Everything in held folder `dir` removed, folders by handle: a link is removed, never followed. Off /proc/self/fd,
184
+ * each name is acted on only once its folder is confirmed (Held.confirm), and each folder is entered by Held.open. */
185
+ async function emptyTree(dir, path) {
186
+ for (const name of await dir.confirmed(path, () => readdir(dir.self))) {
187
+ await dir.confirm(path);
96
188
  const stats = await lstatOrNot(dir.at(name));
97
189
  if (stats === undefined)
98
190
  continue;
99
191
  if (!stats.isDirectory()) {
192
+ // Not a folder (a file, or a link: unlink removes the link itself, never what it points at).
193
+ await dir.confirm(path);
100
194
  await unlink(dir.at(name));
101
195
  continue;
102
196
  }
103
197
  let handle;
104
198
  try {
105
- handle = await open(dir.at(name), DIR_FLAGS);
199
+ handle = await dir.open(name, DIR_FLAGS);
106
200
  }
107
201
  catch (error) {
108
202
  if (errno(error) !== "ENOTDIR" && errno(error) !== "ELOOP")
109
203
  throw error;
204
+ await dir.confirm(path);
110
205
  await unlink(dir.at(name));
111
206
  continue;
112
207
  }
113
208
  try {
114
- await emptyTree(new Held(handle, join(dir.abs, name)));
209
+ await emptyTree(await dir.hold(handle, name), path);
115
210
  }
116
211
  finally {
117
212
  await handle.close();
118
213
  }
214
+ await dir.confirm(path);
119
215
  await rmdir(dir.at(name));
120
216
  }
121
217
  }
122
218
  class LocalWorkspace {
123
219
  #root;
124
- #real;
125
- constructor(root) {
220
+ #options;
221
+ #reach;
222
+ constructor(root, options) {
126
223
  this.#root = root;
224
+ this.#options = options;
225
+ }
226
+ /** The folder `work` is over, by its path, when it is a LocalWorkspace; undefined for any other Workspace. */
227
+ static folderOf(work) {
228
+ return work instanceof LocalWorkspace ? work.#root : undefined;
127
229
  }
128
230
  /** The root, its links resolved once (the root itself is trusted; nothing below it is), held open. */
129
231
  async #openRoot() {
130
232
  try {
131
- this.#real ??= await realpath(this.#root);
132
- return new Held(await open(this.#real, DIR_FLAGS), this.#real);
233
+ this.#reach ??= { root: await realpath(this.#root), procFd: this.#options.procFd ?? LINUX, ...(this.#options.onHeld ? { onHeld: this.#options.onHeld } : {}) };
234
+ return new Held(await open(this.#reach.root, DIR_FLAGS), this.#reach.root, this.#reach);
133
235
  }
134
236
  catch (error) {
135
237
  throw new WorkspaceError("UNAVAILABLE", `the workspace's folder ${this.#root} is not there`, { cause: error });
@@ -157,13 +259,14 @@ class LocalWorkspace {
157
259
  let handle;
158
260
  for (let made = false; handle === undefined;) {
159
261
  try {
160
- handle = await open(dir.at(name), DIR_FLAGS);
262
+ handle = await dir.open(name, DIR_FLAGS);
161
263
  }
162
264
  catch (error) {
163
265
  const code = errno(error);
164
266
  if (code === "ENOENT" && options.make && !made) {
165
267
  made = true;
166
268
  try {
269
+ await dir.confirm(path);
167
270
  await makeDir(dir.at(name), 0o777);
168
271
  await dir.handle.sync();
169
272
  }
@@ -183,7 +286,14 @@ class LocalWorkspace {
183
286
  throw new WorkspaceError(options.make ? "EXISTS" : i === count - 1 ? options.notDir ?? "NOT_FOUND" : "NOT_FOUND", `${show(part)} is not a directory`, { path });
184
287
  }
185
288
  }
186
- const next = new Held(handle, join(dir.abs, name));
289
+ let next;
290
+ try {
291
+ next = await dir.hold(handle, name);
292
+ }
293
+ catch (error) {
294
+ await handle.close().catch(() => undefined);
295
+ throw error;
296
+ }
187
297
  await dir.handle.close();
188
298
  dir = next;
189
299
  }
@@ -205,7 +315,7 @@ class LocalWorkspace {
205
315
  return this.#in(path, segments, segments.length - 1, async (dir) => {
206
316
  let handle;
207
317
  try {
208
- handle = await open(dir.at(segments.at(-1)), O_RDONLY | O_NOFOLLOW | O_NONBLOCK);
318
+ handle = await dir.open(segments.at(-1), O_RDONLY | O_NOFOLLOW | O_NONBLOCK);
209
319
  }
210
320
  catch (error) {
211
321
  throw failed(error, path);
@@ -241,19 +351,20 @@ class LocalWorkspace {
241
351
  const name = segments.at(-1);
242
352
  await this.#in(path, segments, segments.length - 1, async (dir) => {
243
353
  try {
244
- const existing = await lstatOrNot(dir.at(name));
354
+ const existing = await dir.confirmed(path, () => lstatOrNot(dir.at(name)));
245
355
  if (existing?.isSymbolicLink())
246
356
  throw escape(path, path);
247
357
  if (existing !== undefined && !existing.isFile())
248
358
  throw new WorkspaceError("REFUSED", `${show(path)} is ${existing.isDirectory() ? "a directory" : "not a file"}`, { path });
249
359
  const temp = `.workspace-${randomBytes(8).toString("hex")}.tmp`;
250
- const handle = await open(dir.at(temp), O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0o666);
360
+ const handle = await dir.open(temp, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0o666);
251
361
  try {
252
362
  if (existing !== undefined)
253
363
  await handle.chmod(existing.mode & 0o777);
254
364
  await handle.writeFile(bytes);
255
365
  await handle.sync();
256
366
  await handle.close();
367
+ await dir.confirm(path);
257
368
  await rename(dir.at(temp), dir.at(name));
258
369
  }
259
370
  catch (error) {
@@ -277,23 +388,25 @@ class LocalWorkspace {
277
388
  let made = false;
278
389
  let handle;
279
390
  try {
280
- handle = await open(dir.at(target), O_RDWR | O_APPEND | O_NOFOLLOW | O_NONBLOCK);
391
+ handle = await dir.open(target, O_RDWR | O_APPEND | O_NOFOLLOW | O_NONBLOCK);
281
392
  }
282
393
  catch (error) {
283
394
  if (errno(error) !== "ENOENT")
284
395
  throw error;
285
396
  try {
286
- handle = await open(dir.at(target), O_RDWR | O_APPEND | O_CREAT | O_EXCL | O_NOFOLLOW, 0o666);
397
+ handle = await dir.open(target, O_RDWR | O_APPEND | O_CREAT | O_EXCL | O_NOFOLLOW, 0o666);
287
398
  made = true;
288
399
  }
289
400
  catch (again) {
290
401
  if (errno(again) !== "EEXIST")
291
402
  throw again;
292
- handle = await open(dir.at(target), O_RDWR | O_APPEND | O_NOFOLLOW | O_NONBLOCK);
403
+ handle = await dir.open(target, O_RDWR | O_APPEND | O_NOFOLLOW | O_NONBLOCK);
293
404
  }
294
405
  }
406
+ let stats;
295
407
  try {
296
- if (!(await handle.stat()).isFile())
408
+ stats = await handle.stat();
409
+ if (!stats.isFile())
297
410
  throw new WorkspaceError("REFUSED", `${show(path)} is not a file`, { path });
298
411
  await handle.writeFile(bytes);
299
412
  await handle.datasync();
@@ -302,7 +415,7 @@ class LocalWorkspace {
302
415
  await handle.close();
303
416
  }
304
417
  if (made)
305
- await dir.handle.sync();
418
+ await dir.syncMade(target, stats, path);
306
419
  }
307
420
  catch (error) {
308
421
  throw failed(error, path);
@@ -321,7 +434,7 @@ class LocalWorkspace {
321
434
  try {
322
435
  return await this.#in(path, segments, segments.length - 1, async (dir) => {
323
436
  try {
324
- const stats = await lstatOrNot(dir.at(segments.at(-1)));
437
+ const stats = await dir.confirmed(path, () => lstatOrNot(dir.at(segments.at(-1))));
325
438
  return stats === undefined ? undefined : of(stats);
326
439
  }
327
440
  catch (error) {
@@ -340,7 +453,8 @@ class LocalWorkspace {
340
453
  const segments = relativeSegments(dir);
341
454
  return this.#in(dir, segments, segments.length, async (held) => {
342
455
  try {
343
- const entries = await Promise.all((await readdir(held.self)).map(async (name) => {
456
+ // Off /proc/self/fd the folder is confirmed before and after: a listing of a folder swapped in is ESCAPE.
457
+ const entries = await held.confirmed(dir, async () => Promise.all((await readdir(held.self)).map(async (name) => {
344
458
  const stats = await lstatOrNot(held.at(name));
345
459
  if (stats?.isDirectory())
346
460
  return { name, kind: "dir", size: 0, mtimeMs: stats.mtimeMs };
@@ -349,7 +463,7 @@ class LocalWorkspace {
349
463
  // Only a flag for the listing: the read itself is what refuses (REFUSED, permission denied).
350
464
  const readable = await access(held.at(name), constants.R_OK).then(() => true, () => false);
351
465
  return { name, kind: "file", size: stats.size, mtimeMs: stats.mtimeMs, ...(readable ? {} : { unreadable: true }) };
352
- }));
466
+ })));
353
467
  return entries.filter((entry) => entry !== undefined).sort((a, b) => byName(a.name, b.name));
354
468
  }
355
469
  catch (error) {
@@ -377,12 +491,16 @@ class LocalWorkspace {
377
491
  const from = options.path ?? "";
378
492
  const segments = relativeSegments(from);
379
493
  const job = { pattern, glob: options.glob, limit: Math.min(max, GREP_MAX), fileMax: GREP_FILE_MAX, lineMax: GREP_LINE_MAX, probe: BINARY_PROBE };
380
- const search = (dir, rel, only) => LocalWorkspace.#searchIn({ ...job, dir: dir.self, rel, ...(only === undefined ? {} : { only }) }, Math.min(timeMs, GREP_TIME_MS));
494
+ // Off /proc/self/fd the worker opens each entry through no link below the root, as a read does (grep-worker.ts).
495
+ const search = async (dir, rel, only) => {
496
+ await dir.confirm(from);
497
+ return LocalWorkspace.#searchIn({ ...job, dir: dir.self, rel, procFd: dir.reach.procFd, root: dir.reach.root, ...(only === undefined ? {} : { only }) }, Math.min(timeMs, GREP_TIME_MS));
498
+ };
381
499
  if (segments.length === 0)
382
500
  return this.#in(from, segments, 0, (root) => search(root, ""));
383
501
  return this.#in(from, segments, segments.length - 1, async (parent) => {
384
502
  const name = segments.at(-1);
385
- const stats = await lstatOrNot(parent.at(name)).catch((error) => { throw failed(error, from); });
503
+ const stats = await parent.confirmed(from, () => lstatOrNot(parent.at(name))).catch((error) => { throw failed(error, from); });
386
504
  if (stats === undefined)
387
505
  throw new WorkspaceError("NOT_FOUND", `${show(from)} is not there`, { path: from });
388
506
  if (stats.isSymbolicLink())
@@ -391,9 +509,9 @@ class LocalWorkspace {
391
509
  return search(parent, segments.join("/"), name);
392
510
  if (!stats.isDirectory())
393
511
  throw new WorkspaceError("REFUSED", `${show(from)} is neither a file nor a directory`, { path: from });
394
- const handle = await open(parent.at(name), DIR_FLAGS).catch((error) => { throw failed(error, from); });
512
+ const handle = await parent.open(name, DIR_FLAGS).catch((error) => { throw failed(error, from); });
395
513
  try {
396
- return await search(new Held(handle, join(parent.abs, name)), segments.join("/"));
514
+ return await search(await parent.hold(handle, name), segments.join("/"));
397
515
  }
398
516
  finally {
399
517
  await handle.close();
@@ -438,23 +556,26 @@ class LocalWorkspace {
438
556
  try {
439
557
  await this.#in(path, segments, segments.length - 1, async (dir) => {
440
558
  try {
441
- const stats = await lstatOrNot(dir.at(name));
559
+ const stats = await dir.confirmed(path, () => lstatOrNot(dir.at(name)));
442
560
  if (stats === undefined)
443
561
  throw new WorkspaceError("NOT_FOUND", `${show(path)} is not there`, { path });
444
562
  if (stats.isSymbolicLink())
445
563
  throw escape(path, path);
446
- if (!stats.isDirectory())
564
+ if (!stats.isDirectory()) {
565
+ await dir.confirm(path);
447
566
  await unlink(dir.at(name));
567
+ }
448
568
  else {
449
569
  if (options.recursive) {
450
- const handle = await open(dir.at(name), DIR_FLAGS);
570
+ const handle = await dir.open(name, DIR_FLAGS);
451
571
  try {
452
- await emptyTree(new Held(handle, join(dir.abs, name)));
572
+ await emptyTree(await dir.hold(handle, name), path);
453
573
  }
454
574
  finally {
455
575
  await handle.close();
456
576
  }
457
577
  }
578
+ await dir.confirm(path);
458
579
  await rmdir(dir.at(name));
459
580
  }
460
581
  await dir.handle.sync();
@@ -484,13 +605,16 @@ class LocalWorkspace {
484
605
  const cap = options.maxOutput ?? EXEC_OUTPUT_MAX;
485
606
  if (!Number.isSafeInteger(cap) || cap < 0)
486
607
  throw new WorkspaceError("REFUSED", "exec's maxOutput is a whole number, 0 or more");
608
+ if (options.network !== undefined)
609
+ throw new WorkspaceError("REFUSED", "a command here runs on this machine, which cannot deny its network: nothing ran");
487
610
  const cwd = options.cwd ?? "";
488
611
  const segments = relativeSegments(cwd);
489
612
  const { signal } = options;
490
613
  if (signal?.aborted)
491
614
  throw abortError(signal);
492
- // The child starts in the held folder itself (/proc/self/fd/<fd> on Linux), held until the child is done.
493
- return this.#in(cwd, segments, segments.length, (dir) => new Promise((resolve, reject) => {
615
+ // The child starts in the held folder itself (/proc/self/fd/<fd> on Linux), held until the child is done. Off
616
+ // /proc/self/fd its path is confirmed just before the spawn.
617
+ return this.#in(cwd, segments, segments.length, (dir) => dir.confirm(cwd).then(() => new Promise((resolve, reject) => {
494
618
  if (signal?.aborted)
495
619
  return reject(abortError(signal));
496
620
  const child = spawn(argv[0], argv.slice(1), {
@@ -574,7 +698,7 @@ class LocalWorkspace {
574
698
  child.stdin.on("error", () => undefined);
575
699
  child.stdin.end(Buffer.from(options.stdin.buffer, options.stdin.byteOffset, options.stdin.byteLength));
576
700
  }
577
- }), { notDir: "REFUSED" });
701
+ })), { notDir: "REFUSED" });
578
702
  }
579
703
  /** No computer: every background call is refused in words. */
580
704
  process = noProcesses;
@@ -596,11 +720,10 @@ class LocalWorkspace {
596
720
  async #syncUp(path, only) {
597
721
  const segments = relativeSegments(path);
598
722
  const entry = await this.#in(path, segments, segments.length - 1, async (dir) => {
599
- const at = dir.at(segments.at(-1));
600
723
  for (const flags of [O_RDONLY, O_WRONLY]) {
601
724
  let handle;
602
725
  try {
603
- handle = await open(at, flags | O_NOFOLLOW | O_NONBLOCK);
726
+ handle = await dir.open(segments.at(-1), flags | O_NOFOLLOW | O_NONBLOCK);
604
727
  }
605
728
  catch (error) {
606
729
  if (errno(error) === "ENOENT" || errno(error) === "ELOOP")
@@ -625,8 +748,12 @@ class LocalWorkspace {
625
748
  return entry;
626
749
  }
627
750
  }
628
- /** A Workspace on folder `root` of this machine. The folder must be there when it is first used (else UNAVAILABLE). */
629
- export const localWorkspace = (root) => new LocalWorkspace(root);
751
+ /** A Workspace on folder `root` of this machine. The folder must be there when it is first used (else UNAVAILABLE).
752
+ * `options` are a test's: the path-resolving branch forced, and a hook where a swap would land. */
753
+ export const localWorkspace = (root, options = {}) => new LocalWorkspace(root, options);
754
+ /** The folder of this machine that `work` is, by its path: a LocalWorkspace's root; undefined for any other Workspace (a
755
+ * Mode 2 run's folder on its disk, one attached to a computer), whose files no local path reaches. */
756
+ export const localFolderOf = (work) => LocalWorkspace.folderOf(work);
630
757
  /** `work` as a Workspace: a folder of this machine, by its path, becomes its LocalWorkspace. For the callers that still
631
758
  * hand a run's folder by its path (the run's start and its process), until they hand the run's Workspace. */
632
759
  export const workspaceAt = (work) => (typeof work === "string" ? localWorkspace(work) : work);
@@ -8,8 +8,9 @@
8
8
  // for it
9
9
  // and on this machine alone:
10
10
  // <data>/scratch/<agent>/<run> a run's scratch folder (scratchFolder): never on the disk above, so in
11
- // no Workspace: a harness's private files and working directory, swept
12
- // at the run's end
11
+ // no Workspace: a harness's working directory, and its private files
12
+ // in harness/<claim's epoch>, swept at that claim's end
13
+ // (runner/cli-run-spec.ts)
13
14
  // <agent> is the id in lower case, a dash, and 16 hex digits of the id's SHA-256, so ids that differ only in case never
14
15
  // share a folder on a disk that folds case.
15
16
  //
@@ -15,8 +15,12 @@ export type PiEnvOptions = {
15
15
  readonly aliases?: readonly string[];
16
16
  /** bash's whole environment: nothing of this process's is passed. */
17
17
  readonly env: Readonly<Record<string, string>>;
18
+ /** Shell text bash runs before each command string (a bash policy's, bash-read-only.ts policyPrelude). */
19
+ readonly prelude?: string;
18
20
  /** bash's deadline when a call names none, in seconds. */
19
21
  readonly defaultTimeoutS: number;
22
+ /** Each command's network (a bash policy's on Archil's exec: run-tools.ts). */
23
+ readonly network?: "deny";
20
24
  };
21
25
  /** pi's ExecutionEnv over `workspace`, the run's folder named `options.cwd`. */
22
26
  export declare function piEnv(workspace: Workspace, options: PiEnvOptions): ExecutionEnv;
@@ -203,13 +203,14 @@ export function piEnv(workspace, options) {
203
203
  };
204
204
  const run = (argv) => workspace.exec(argv, {
205
205
  cwd: where.value, env: { ...options.env, ...(given?.env ?? {}) }, timeoutMs: Math.max(1, Math.round(timeoutS * 1000)), maxOutput: 0,
206
- ...(context.abortSignal ? { signal: context.abortSignal } : {}),
206
+ ...(context.abortSignal ? { signal: context.abortSignal } : {}), ...(options.network ? { network: options.network } : {}),
207
207
  onOutput: ({ stream, data }) => {
208
208
  emit(decoders[stream].decode(data), stream);
209
209
  keep(data);
210
210
  },
211
211
  });
212
- const argvs = typeof command === "string" ? [["bash", "-c", command], ["sh", "-c", command]] : [[...command]];
212
+ const line = typeof command === "string" ? `${options.prelude ?? ""}${command}` : undefined;
213
+ const argvs = line !== undefined ? [["bash", "-c", line], ["sh", "-c", line]] : [[...command]];
213
214
  let ran;
214
215
  try {
215
216
  for (const argv of argvs) {
@@ -1,15 +1,19 @@
1
- import type { CdpSession, ShellPlace } from "@parcha/agentrun-kernel/kernel";
2
- import type { ComputerClient, ComputerSettingKind, Group, KindCapabilities, MountReadBack, MountSpec, ProviderEntry, Result } from "@parcha/agentrun-computer";
1
+ import type { ShellPlace } from "@parcha/agentrun-kernel/kernel";
2
+ import { type ComputerClient, type ComputerSettingKind, type GpuSpec, type Group, type KindCapabilities, type MountReadBack, type MountSpec, type ProviderEntry, type Result } from "@parcha/agentrun-computer";
3
+ import { type DockerDaemon } from "../docker-daemon.js";
3
4
  import type { MountCheck } from "./attach.js";
4
5
  import type { RunComputer } from "./run-tools.js";
5
6
  import type { Workspace } from "./workspace.js";
6
7
  /** The setting kind (what an agent is given, not a computer's capabilities().kind), a machine's kind and groups, and one
7
8
  * provider of the kind registry: the computer module's own types. Where a run's shell is: the kernel registry's. */
8
9
  export type { ComputerSettingKind, KindCapabilities, ProviderEntry, ShellPlace };
9
- /** An agent's computer setting. */
10
+ /** An agent's computer setting. `image`: the one of the provider's configurations it selects; absent, the default. A
11
+ * sandbox's may ask for GPUs. */
10
12
  export type ComputerSetting = {
11
13
  readonly kind: string;
12
14
  readonly provider?: string | null;
15
+ readonly image?: string;
16
+ readonly gpu?: GpuSpec;
13
17
  };
14
18
  /** The computer module's kind registry (src/kinds.ts), by its own names: the setting kinds, why a machine does not serve
15
19
  * one (servingRefusals, whose words a refusal here carries), and the providers. */
@@ -19,25 +23,53 @@ export type KindRegistry = {
19
23
  readonly PROVIDERS: readonly ProviderEntry[];
20
24
  };
21
25
  /** A computer a provider started for the run: its ref, its computerd client and what it offers (sandbox, desktop,
22
- * phone), the read-back of its mount (when mounted), its CDP connect (browser), and its release. */
26
+ * phone), the read-back of its mount (when mounted), and its release. A browser is started by none: the claim gives
27
+ * the run's browser tool its provider (`browser`), which opens each session at the tool's first call, and the release
28
+ * lets go of any the tool left open. */
23
29
  export type LaunchedComputer = {
24
30
  readonly id: string;
25
31
  readonly groups: readonly (Group | string)[];
26
32
  readonly client?: ComputerClient;
27
33
  readBack?(): Promise<Result<MountReadBack>>;
28
- connect?(): Promise<CdpSession>;
34
+ readonly browser?: ClaimBrowser;
29
35
  release(): Promise<void>;
30
36
  };
37
+ /** A browser computer's provider as the run's browser tool opens its sessions through it: each session one computer of
38
+ * the provider's, made under the run's labels and the tool's tag (so a create whose answer was lost is found again),
39
+ * its CDP URL read through the provider's connect at each attach (a secret: it goes only to the driver), and released
40
+ * when the tool lets it go. Errors carry the provider's words, and its code. So the session's time is the time the
41
+ * tool holds it, which is what the run's spend books. */
42
+ export type ClaimBrowser = {
43
+ /** The provider's id: the session's price and its name. */
44
+ readonly provider: string;
45
+ /** The longest a session lives, in seconds. */
46
+ readonly maxLifetimeS: number;
47
+ /** Makes a session for `tag`, to live at most `lifetimeS`: its computer's id. */
48
+ open(tag: string, lifetimeS: number, signal?: AbortSignal): Promise<string>;
49
+ /** The sessions made for `tag`, by id. */
50
+ find(tag: string, signal?: AbortSignal): Promise<string[]>;
51
+ /** The session's CDP URL now. */
52
+ url(id: string): Promise<string>;
53
+ /** Ends the session; one already gone is ended. */
54
+ close(id: string): Promise<void>;
55
+ };
31
56
  /** The claim's side: the keys saved for a provider (Settings → Computers; values, never shown), and the launch of one
32
57
  * computer of the kind, with the run's folder as its mount when it mounts it. A launch that fails throws its words. */
33
58
  export type ClaimSide = {
34
59
  keysOf(provider: string): Promise<Readonly<Record<string, string>>>;
35
60
  /** Whether a provider that binds a folder of this machine (Docker) answers here now: the Mode 1 default asks it. */
36
61
  answers(provider: string): Promise<boolean>;
62
+ /** Its daemon's answer (docker-daemon.ts), asked when a launch on such a provider fails: none answering is refused in
63
+ * the one wording a run's start and Settings → Computers say (noDockerWords). Absent: the launch's own words. */
64
+ daemon?(provider: string): Promise<DockerDaemon>;
65
+ /** `configuration`: the provider's configuration the setting selected; its options go to the provider with the keys,
66
+ * and its image, when it names one, is the computer's. `gpu`: a sandbox's GPUs, held to that configuration. */
37
67
  launch(entry: ProviderEntry, spec: {
38
68
  readonly kind: ComputerSettingKind;
39
69
  readonly keys: Readonly<Record<string, string>>;
70
+ readonly configuration: KindCapabilities;
40
71
  readonly mount?: MountSpec;
72
+ readonly gpu?: GpuSpec;
41
73
  readonly signal?: AbortSignal;
42
74
  }): Promise<LaunchedComputer>;
43
75
  };
@@ -47,15 +79,28 @@ export type Port = "files" | "exec" | "processes" | "screen" | "input" | "phone"
47
79
  /** A provider's keys as the claim reads them: each key its registry entry declares, by `keyOf` (the server's reader:
48
80
  * key-meta.ts keyReader, the environment's value, else the saved one); a key with no value is left out. */
49
81
  export declare const providerKeys: (registry: Pick<KindRegistry, "PROVIDERS">, keyOf: (name: string) => Promise<string | undefined>) => ClaimSide["keysOf"];
82
+ /** Whether a provider's computers run only on the vendor's own network: the network forms it declares (its
83
+ * descriptor's, its capabilities().network) are "open" alone, as a cloud phone's and a hosted browser's are. */
84
+ export declare const vendorNetworkOnly: (network: readonly string[] | undefined) => boolean;
85
+ /** Whether a provider's computers can't have no network: it declares its network forms and "none" isn't one (a cloud
86
+ * phone, a hosted browser, Local Chrome). */
87
+ export declare const needsNetwork: (network: readonly string[] | undefined) => boolean;
88
+ /** Why a computer that needs a network is refused where this server's AGENTRUN_BOX_ALLOW is none, in words that name the
89
+ * fix: the operator said no network at all, and the computer can't run without one. */
90
+ export declare const noNetworkRefusal: (label: string, kind: string) => string;
50
91
  /** Whether an agent's computer `setting` can be had in `mode` now, by the answers the claim gives (resolveComputer: the
51
92
  * kind, the provider and what it serves, the mode's mount, the provider's keys by `keyOf`): ok, or its refusal in words
52
93
  * that name the fix. Nothing starts. A run's start asks it before the run is made (runnable.ts).
53
94
  *
54
- * `answers`: whether a provider that binds a folder of this machine (Docker) answers here now, or why not, in words
55
- * that say how to fix it (the server's start-time probe of it). A Mode 1 sandbox on such a provider is refused in those
56
- * words here, at the start, where the claim would only fail to launch it. Asked here, not in resolveComputer: the claim
57
- * has no such answer and launches it. Absent: not asked. */
58
- export declare function computerReadiness(setting: ComputerSetting, mode: 1 | 2, registry: KindRegistry, keyOf: (name: string) => Promise<string | undefined>, answers?: (provider: string) => true | string): Promise<{
95
+ * `answers`: whether a provider that binds a folder of this machine (Docker) answers here now, or why not (the server's
96
+ * daemon check, docker-daemon.ts). Any computer on such a provider, a sandbox or a desktop in either mode, is refused
97
+ * here, at the start, where the claim would only fail to launch it: no daemon at all in the one wording Settings →
98
+ * Computers and the claim say (noDockerWords), another reason in its own words. Asked here, not in resolveComputer: the
99
+ * claim launches it, and asks only once its launch fails (ClaimSide.daemon). Absent: not asked.
100
+ *
101
+ * `boxAllow`: this server's allow setting (box-settings.ts boxAllowOf). Under "none", a computer whose provider makes no
102
+ * "none" is refused (noNetworkRefusal), as the claim refuses it. Absent: not asked. */
103
+ export declare function computerReadiness(setting: ComputerSetting, mode: 1 | 2, registry: KindRegistry, keyOf: (name: string) => Promise<string | undefined>, answers?: (provider: string) => DockerDaemon | Promise<DockerDaemon>, boxAllow?: readonly string[] | "none"): Promise<{
59
104
  readonly ok: true;
60
105
  } | {
61
106
  readonly refused: string;