@parcha/agentrun-serve 0.1.0-beta.51 → 0.1.0-beta.53

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 (322) hide show
  1. package/CHANGELOG.md +160 -1
  2. package/README.md +306 -36
  3. package/dist/adapters.js +1 -1
  4. package/dist/agent-delete.d.ts +14 -4
  5. package/dist/agent-delete.js +30 -58
  6. package/dist/agent-package.d.ts +71 -0
  7. package/dist/agent-package.js +345 -0
  8. package/dist/agents-store.d.ts +28 -18
  9. package/dist/agents-store.js +48 -34
  10. package/dist/api-only.d.ts +30 -8
  11. package/dist/api-only.js +40 -16
  12. package/dist/archil-routes.d.ts +1 -0
  13. package/dist/archil-routes.js +28 -2
  14. package/dist/claude-login.d.ts +1 -0
  15. package/dist/claude-login.js +1 -1
  16. package/dist/cli-learning/cli.d.ts +3 -0
  17. package/dist/cli-learning/cli.js +17 -3
  18. package/dist/cli-learning/connections.js +3 -2
  19. package/dist/cli-learning/schema.js +2 -1
  20. package/dist/cli.js +70 -7
  21. package/dist/composio-preset.d.ts +2 -1
  22. package/dist/composio-preset.js +4 -3
  23. package/dist/composio-triggers.d.ts +4 -0
  24. package/dist/composio-triggers.js +4 -1
  25. package/dist/computer-needs.d.ts +32 -0
  26. package/dist/computer-needs.js +80 -0
  27. package/dist/computer-setting.d.ts +9 -0
  28. package/dist/computer-setting.js +19 -1
  29. package/dist/computers.d.ts +6 -2
  30. package/dist/computers.js +2 -2
  31. package/dist/console/assets/index-BFgyZzF_.js +734 -0
  32. package/dist/console/assets/index-DbilxljH.css +1 -0
  33. package/dist/console/index.html +2 -2
  34. package/dist/console-links.d.ts +1 -0
  35. package/dist/console-links.js +2 -0
  36. package/dist/env-switch.d.ts +14 -0
  37. package/dist/env-switch.js +23 -0
  38. package/dist/errors.d.ts +1 -0
  39. package/dist/errors.js +3 -0
  40. package/dist/eval-previous.js +4 -3
  41. package/dist/fal-price.d.ts +76 -0
  42. package/dist/fal-price.js +365 -0
  43. package/dist/handed-secret.d.ts +4 -0
  44. package/dist/handed-secret.js +10 -0
  45. package/dist/harness-archive.d.ts +15 -5
  46. package/dist/harness-archive.js +71 -34
  47. package/dist/harness-check.d.ts +2 -1
  48. package/dist/harness-check.js +36 -95
  49. package/dist/harness-egress.d.ts +23 -0
  50. package/dist/harness-egress.js +69 -0
  51. package/dist/harness-recipe-entry.d.ts +71 -0
  52. package/dist/harness-recipe-entry.js +184 -0
  53. package/dist/harness-recipe.d.ts +73 -6
  54. package/dist/harness-recipe.js +185 -31
  55. package/dist/harness-sign-in.d.ts +29 -0
  56. package/dist/harness-sign-in.js +122 -0
  57. package/dist/harness-table.d.ts +21 -0
  58. package/dist/harness-table.js +58 -3
  59. package/dist/harness-zip.d.ts +6 -0
  60. package/dist/harness-zip.js +203 -0
  61. package/dist/ids.d.ts +11 -0
  62. package/dist/ids.js +36 -0
  63. package/dist/learn/commit.d.ts +19 -1
  64. package/dist/learn/commit.js +160 -2
  65. package/dist/learn/compile.d.ts +13 -5
  66. package/dist/learn/compile.js +46 -15
  67. package/dist/learn/delete.d.ts +12 -6
  68. package/dist/learn/delete.js +17 -11
  69. package/dist/learn/folder.d.ts +16 -0
  70. package/dist/learn/folder.js +30 -4
  71. package/dist/learn/learning-of.d.ts +8 -0
  72. package/dist/learn/learning-of.js +8 -0
  73. package/dist/learn/learning.sh +29 -4
  74. package/dist/learn/promote.d.ts +51 -7
  75. package/dist/learn/promote.js +51 -8
  76. package/dist/learn/secrets.js +30 -7
  77. package/dist/learning-reset.d.ts +18 -0
  78. package/dist/learning-reset.js +115 -0
  79. package/dist/learning-routes.d.ts +23 -11
  80. package/dist/learning-routes.js +110 -20
  81. package/dist/learning-words.d.ts +5 -0
  82. package/dist/learning-words.js +5 -0
  83. package/dist/learning.d.ts +15 -10
  84. package/dist/learning.js +14 -8
  85. package/dist/llms.txt +1 -0
  86. package/dist/mcp-gateway.d.ts +39 -2
  87. package/dist/mcp-gateway.js +56 -12
  88. package/dist/mcp-pin-first.js +1 -1
  89. package/dist/mcp-probe.d.ts +3 -0
  90. package/dist/mcp-probe.js +7 -2
  91. package/dist/mcp-resources.d.ts +44 -0
  92. package/dist/mcp-resources.js +100 -0
  93. package/dist/mcp-servers-store.d.ts +17 -12
  94. package/dist/mcp-servers-store.js +2 -1
  95. package/dist/media-duration.d.ts +2 -0
  96. package/dist/media-duration.js +136 -0
  97. package/dist/model.d.ts +4 -4
  98. package/dist/model.js +6 -6
  99. package/dist/native/cli.js +9 -2
  100. package/dist/native/connection.d.ts +2 -2
  101. package/dist/native/connection.js +5 -2
  102. package/dist/native/discovery.d.ts +2 -0
  103. package/dist/native/discovery.js +10 -6
  104. package/dist/native/remote-worker-bridge.js +36 -4
  105. package/dist/native/remote.d.ts +18 -1
  106. package/dist/native/remote.js +126 -37
  107. package/dist/native/schema.d.ts +6 -0
  108. package/dist/native/schema.js +31 -6
  109. package/dist/native/source-account.d.ts +13 -0
  110. package/dist/native/source-account.js +114 -0
  111. package/dist/native/source-capture-hooks.d.ts +5 -0
  112. package/dist/native/source-capture-hooks.js +102 -0
  113. package/dist/native/source-mcp-selection.d.ts +13 -0
  114. package/dist/native/source-mcp-selection.js +72 -0
  115. package/dist/native/source-runtime-tools.d.ts +19 -0
  116. package/dist/native/source-runtime-tools.js +103 -0
  117. package/dist/native/source-snapshot-types.d.ts +138 -0
  118. package/dist/native/source-snapshot-types.js +12 -0
  119. package/dist/native/source-snapshot.d.ts +8 -0
  120. package/dist/native/source-snapshot.js +1201 -0
  121. package/dist/observation/learning.js +3 -2
  122. package/dist/openapi.js +211 -47
  123. package/dist/print.js +1 -1
  124. package/dist/provider.d.ts +8 -0
  125. package/dist/provider.js +14 -2
  126. package/dist/purged-workflow.d.ts +12 -0
  127. package/dist/purged-workflow.js +43 -0
  128. package/dist/refusal-words.d.ts +0 -3
  129. package/dist/refusal-words.js +0 -3
  130. package/dist/request-metadata.d.ts +20 -0
  131. package/dist/request-metadata.js +24 -0
  132. package/dist/run-keys.d.ts +46 -0
  133. package/dist/run-keys.js +109 -0
  134. package/dist/run-launch.d.ts +29 -5
  135. package/dist/run-launch.js +44 -4
  136. package/dist/run-learning-served.d.ts +2 -2
  137. package/dist/run-model-key.d.ts +2 -2
  138. package/dist/run-model-key.js +5 -5
  139. package/dist/run-secrets.d.ts +2 -0
  140. package/dist/run-secrets.js +7 -4
  141. package/dist/run-usage.d.ts +48 -4
  142. package/dist/run-usage.js +156 -39
  143. package/dist/run-view.d.ts +18 -1
  144. package/dist/run-view.js +28 -8
  145. package/dist/runner/adapter-loop.d.ts +14 -4
  146. package/dist/runner/adapter-loop.js +150 -31
  147. package/dist/runner/adapter-run-spec.d.ts +1 -1
  148. package/dist/runner/adapter-run-spec.js +35 -22
  149. package/dist/runner/audit.d.ts +10 -3
  150. package/dist/runner/audit.js +30 -7
  151. package/dist/runner/beside.js +2 -1
  152. package/dist/runner/claim-secrets.d.ts +31 -4
  153. package/dist/runner/claim-secrets.js +43 -7
  154. package/dist/runner/cli-run-spec.d.ts +1 -1
  155. package/dist/runner/cli-run-spec.js +32 -20
  156. package/dist/runner/conformance/harness.js +4 -2
  157. package/dist/runner/dispatch.js +4 -2
  158. package/dist/runner/harness-loops.d.ts +6 -0
  159. package/dist/runner/harness-loops.js +16 -3
  160. package/dist/runner/held.d.ts +4 -0
  161. package/dist/runner/journal-kinds.d.ts +5 -0
  162. package/dist/runner/learned-first.d.ts +2 -0
  163. package/dist/runner/learned-first.js +1 -1
  164. package/dist/runner/learning-end.d.ts +9 -3
  165. package/dist/runner/learning-end.js +66 -29
  166. package/dist/runner/learning-seed.d.ts +9 -3
  167. package/dist/runner/learning-seed.js +2 -2
  168. package/dist/runner/main.d.ts +1 -0
  169. package/dist/runner/main.js +20 -13
  170. package/dist/runner/mcp-claim.js +7 -2
  171. package/dist/runner/mcp-run.d.ts +12 -0
  172. package/dist/runner/mcp-run.js +14 -1
  173. package/dist/runner/model-route.js +7 -4
  174. package/dist/runner/monid-run.js +9 -11
  175. package/dist/runner/project-checkpoint.d.ts +35 -0
  176. package/dist/runner/project-checkpoint.js +116 -0
  177. package/dist/runner/project-drain.d.ts +8 -0
  178. package/dist/runner/project-drain.js +25 -0
  179. package/dist/runner/project-host.d.ts +10 -0
  180. package/dist/runner/project-host.js +52 -0
  181. package/dist/runner/promotion.d.ts +51 -24
  182. package/dist/runner/promotion.js +206 -78
  183. package/dist/runner/redact.d.ts +13 -0
  184. package/dist/runner/redact.js +67 -1
  185. package/dist/runner/run-channel.d.ts +9 -0
  186. package/dist/runner/run-channel.js +15 -2
  187. package/dist/runner/run-child-host.d.ts +8 -4
  188. package/dist/runner/run-child-host.js +174 -42
  189. package/dist/runner/run-errors.js +2 -2
  190. package/dist/runner/runner-check.js +5 -2
  191. package/dist/runner/runner.js +41 -12
  192. package/dist/runner/sdk-loop.d.ts +2 -2
  193. package/dist/runner/sdk-loop.js +3 -3
  194. package/dist/runner/store-port.d.ts +3 -0
  195. package/dist/runner/store-secrets.js +7 -3
  196. package/dist/runner/workflow-first.d.ts +4 -0
  197. package/dist/runner/workflow-first.js +13 -0
  198. package/dist/runner/workflow-loop.d.ts +2 -1
  199. package/dist/runner/workflow-loop.js +2 -1
  200. package/dist/runner/workflow-spec.js +4 -4
  201. package/dist/runs-over-store.d.ts +39 -8
  202. package/dist/runs-over-store.js +147 -32
  203. package/dist/sdk/check.d.ts +6 -5
  204. package/dist/sdk/check.js +17 -16
  205. package/dist/sdk/runs.d.ts +11 -1
  206. package/dist/sdk/runs.js +185 -78
  207. package/dist/sdk/schema.js +12 -2
  208. package/dist/sdk/workflows.d.ts +1 -1
  209. package/dist/server.d.ts +68 -32
  210. package/dist/server.js +678 -124
  211. package/dist/skills/agentrun-serve/SKILL.md +2 -1
  212. package/dist/source-sync/adoption.d.ts +15 -0
  213. package/dist/source-sync/adoption.js +36 -0
  214. package/dist/source-sync/auxiliary.d.ts +23 -0
  215. package/dist/source-sync/auxiliary.js +64 -0
  216. package/dist/source-sync/capture-git.d.ts +5 -0
  217. package/dist/source-sync/capture-git.js +272 -0
  218. package/dist/source-sync/capture-project.d.ts +53 -0
  219. package/dist/source-sync/capture-project.js +206 -0
  220. package/dist/source-sync/capture-refusal.d.ts +7 -0
  221. package/dist/source-sync/capture-refusal.js +16 -0
  222. package/dist/source-sync/capture.d.ts +11 -0
  223. package/dist/source-sync/capture.js +22 -0
  224. package/dist/source-sync/checkpoint-gate.d.ts +21 -0
  225. package/dist/source-sync/checkpoint-gate.js +52 -0
  226. package/dist/source-sync/checkpoints.d.ts +66 -0
  227. package/dist/source-sync/checkpoints.js +168 -0
  228. package/dist/source-sync/claim.d.ts +11 -0
  229. package/dist/source-sync/claim.js +48 -0
  230. package/dist/source-sync/destination.d.ts +47 -0
  231. package/dist/source-sync/destination.js +239 -0
  232. package/dist/source-sync/io.d.ts +15 -0
  233. package/dist/source-sync/io.js +52 -0
  234. package/dist/source-sync/local.d.ts +43 -0
  235. package/dist/source-sync/local.js +229 -0
  236. package/dist/source-sync/prepare.d.ts +59 -0
  237. package/dist/source-sync/prepare.js +93 -0
  238. package/dist/source-sync/projects.d.ts +61 -0
  239. package/dist/source-sync/projects.js +130 -0
  240. package/dist/source-sync/registry.d.ts +95 -0
  241. package/dist/source-sync/registry.js +226 -0
  242. package/dist/source-sync/service.d.ts +33 -0
  243. package/dist/source-sync/service.js +118 -0
  244. package/dist/source-sync/skill-edits.d.ts +12 -0
  245. package/dist/source-sync/skill-edits.js +122 -0
  246. package/dist/source-sync/snapshots.d.ts +48 -0
  247. package/dist/source-sync/snapshots.js +448 -0
  248. package/dist/source-sync/types.d.ts +9 -0
  249. package/dist/source-sync/types.js +14 -0
  250. package/dist/source-sync/workspace.d.ts +66 -0
  251. package/dist/source-sync/workspace.js +273 -0
  252. package/dist/store/agent-body.d.ts +8 -0
  253. package/dist/store/agent-body.js +20 -6
  254. package/dist/store/index.d.ts +2 -2
  255. package/dist/store/index.js +1 -1
  256. package/dist/store/journal/storage.d.ts +2 -0
  257. package/dist/store/journal/storage.js +2 -1
  258. package/dist/store/postgres/migrations/0025_run_attempts.sql +27 -0
  259. package/dist/store/postgres/migrations/0026_run_disk.sql +23 -0
  260. package/dist/store/schema.d.ts +15 -1
  261. package/dist/store/schema.js +43 -4
  262. package/dist/store/seal.d.ts +5 -1
  263. package/dist/store/seal.js +12 -3
  264. package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
  265. package/dist/store/sqlite/project-checkpoints.js +70 -0
  266. package/dist/store/sqlite/run-launch.d.ts +14 -0
  267. package/dist/store/sqlite/run-launch.js +58 -7
  268. package/dist/store/sqlite/run-patch.d.ts +2 -1
  269. package/dist/store/sqlite/run-patch.js +4 -3
  270. package/dist/store/sqlite/store.js +319 -153
  271. package/dist/store/store-schema.js +2 -2
  272. package/dist/store/store.d.ts +173 -33
  273. package/dist/store/store.js +14 -1
  274. package/dist/store-reads/learning.d.ts +12 -8
  275. package/dist/store-reads/learning.js +33 -24
  276. package/dist/store-reads/loop.d.ts +4 -3
  277. package/dist/store-reads/loop.js +7 -5
  278. package/dist/store-view.d.ts +3 -1
  279. package/dist/store-view.js +17 -5
  280. package/dist/template-eval.js +4 -4
  281. package/dist/template-import.d.ts +10 -2
  282. package/dist/template-import.js +116 -13
  283. package/dist/templates.d.ts +29 -5
  284. package/dist/templates.js +68 -14
  285. package/dist/timeline/index.d.ts +1 -1
  286. package/dist/timeline/index.js +1 -1
  287. package/dist/timeline/labels.js +1 -1
  288. package/dist/timeline/timeline.d.ts +5 -0
  289. package/dist/timeline/timeline.js +8 -0
  290. package/dist/tool-plane.d.ts +12 -12
  291. package/dist/tools.d.ts +8 -8
  292. package/dist/tools.js +1 -1
  293. package/dist/trigger-launch-hook.d.ts +47 -0
  294. package/dist/trigger-launch-hook.js +90 -0
  295. package/dist/trigger-targets.d.ts +14 -1
  296. package/dist/trigger-targets.js +20 -0
  297. package/dist/triggers.d.ts +54 -5
  298. package/dist/triggers.js +143 -8
  299. package/dist/uploads-archil.js +2 -1
  300. package/dist/uploads.d.ts +0 -3
  301. package/dist/uploads.js +2 -11
  302. package/dist/validate.js +4 -1
  303. package/dist/web-save.d.ts +3 -0
  304. package/dist/web-save.js +17 -2
  305. package/dist/workspace/archil-exec.js +1 -1
  306. package/dist/workspace/archil.js +1 -1
  307. package/dist/workspace/computer-for-claim.d.ts +2 -0
  308. package/dist/workspace/computer-for-claim.js +43 -0
  309. package/dist/workspace/paths.d.ts +6 -0
  310. package/dist/workspace/paths.js +6 -0
  311. package/dist/workspace/resolve-computer.d.ts +1 -0
  312. package/dist/workspace/revision-skills.js +24 -11
  313. package/dist/workspace/run-tools.d.ts +2 -0
  314. package/dist/workspace/run-tools.js +8 -0
  315. package/dist/workspace/synced-folder.d.ts +3 -3
  316. package/dist/workspace/synced-folder.js +7 -6
  317. package/launcher/agentrun-serve +1 -1
  318. package/package.json +10 -10
  319. package/skills/agentrun-serve/SKILL.md +2 -1
  320. package/templates/README.md +5 -2
  321. package/dist/console/assets/index-Bt1B51b7.js +0 -733
  322. package/dist/console/assets/index-sVftE9Ht.css +0 -1
package/dist/cli.js CHANGED
@@ -14,8 +14,9 @@ import { REPEAT_MS, stopOnce, stopOnSignals } from "./stop-signals.js";
14
14
  import { resetPassword } from "./owner.js";
15
15
  import { banner } from "./print.js";
16
16
  import { parseTokens } from "./api-token.js";
17
- import { apiOnlyFrom } from "./api-only.js";
18
- import { harnessModulesOf } from "./harness-table.js";
17
+ import { API_ONLY_ENV, RUN_KEYS_ENV, switchFrom } from "./env-switch.js";
18
+ import { harnessModulesOf, harnessRecipesOf } from "./harness-table.js";
19
+ import { hookOrigin, LAUNCH_HOOK_SECRET_ENV, LAUNCH_HOOK_URL_ENV, launchHookFrom } from "./trigger-launch-hook.js";
19
20
  import { surviveClosedPipes } from "./closed-pipes.js";
20
21
  import { installEnvProxy } from "./env-proxy.js";
21
22
  import { startTelemetry } from "./telemetry.js";
@@ -28,22 +29,23 @@ surviveClosedPipes();
28
29
  // Every outbound call through the proxy HTTPS_PROXY or HTTP_PROXY names, NO_PROXY's hosts and loopback direct
29
30
  // (env-proxy.ts): for every command, before anything calls out. Neither set, nothing changes.
30
31
  installEnvProxy();
31
- const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--open] [--faux MODULE] [--faux-browser MODULE] [--faux-github] [--allow-host NAME ...] [--max-runs N] [--drain-timeout D] [--documents DIR] [--allow-code-nodes] [--learning on|off] [--no-runner] [--harness-module MODULE ...]
32
+ const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--open] [--faux MODULE] [--faux-browser MODULE] [--faux-github] [--allow-host NAME ...] [--max-runs N] [--drain-timeout D] [--documents DIR] [--allow-code-nodes] [--learning on|off] [--no-runner] [--harness-module MODULE ...] [--harness-recipe FILE ...] [--harness-sign-in]
32
33
  agentrun-serve reset-password [--data DIR]
33
34
  agentrun-serve validate-template DIR
34
35
  agentrun-serve install-harness goose|cursor [--data DIR]
35
36
  agentrun-serve install-harness --recipe FILE [--data DIR]
37
+ agentrun-serve sign-in-harness --recipe FILE [--data DIR]
36
38
  agentrun-serve check-harness --recipe FILE [--model PROVIDER/MODEL] [--data DIR] [--report FILE] [--cap USD]
37
39
  agentrun-serve eval-template DIR [--case NAME ...] [--runs N] [--server URL | --on-data DIR] [--grader-model PROVIDER/MODEL] [--report FILE] [--faux MODULE]
38
40
  agentrun-serve import [--data DIR] [--from claude-code,codex,pi] [--dry-run] [--include-deleted] [--all] [--verbose] [--port N]
39
- agentrun-serve learning connect|status|disconnect|retry --project PATH --runtime codex|claude-code [--url URL] [--data DIR]
41
+ agentrun-serve learning connect|status|disconnect|retry --project PATH --runtime codex|claude-code [--url URL] [--data DIR] [--no-sync]
40
42
  agentrun-serve runner --data DIR [--loops N] [--drain-timeout D] [--name NAME]
41
43
  agentrun-serve runner --check --data DIR [--name NAME]
42
44
  agentrun-serve runner --check --env [--data DIR]
43
45
  agentrun-serve runner --check --heartbeat --data DIR [--name NAME]
44
46
  agentrun-serve store-schema [--data DIR]
45
47
  agentrun-serve store-schema --build
46
- agentrun-serve native discover|connect --project PATH [--runtime claude-code|codex] [--agent NAME|--profile NAME] [--url URL] [--data DIR]
48
+ agentrun-serve native discover|connect --project PATH [--runtime claude-code|codex] [--agent NAME|--profile NAME] [--url URL] [--data DIR] [--no-sync]
47
49
 
48
50
  --data DIR the agent store and its runs (default ~/.local/share/agentrun/agents); the token is DIR/.token, mode 0600
49
51
  --listen ADDR the address to listen on (default 127.0.0.1); on any other, every Host name is served and the token
@@ -76,6 +78,16 @@ const USAGE = `usage: agentrun-serve [--data DIR] [--listen ADDR] [--port N] [--
76
78
  separated): a path, or a package installed with npm install --prefix DIR/harnesses PACKAGE, whose
77
79
  entries(builtins) export adds harnesses of its own to this server and its runner. It never replaces
78
80
  a built-in harness (pi, claude-agent, codex, opencode); one that does, or is missing, refuses the start
81
+ --harness-recipe FILE
82
+ a harness recipe to add a harness from (repeatable; default AGENTRUN_SERVE_HARNESS_RECIPES, comma-
83
+ separated), installed into DIR with agentrun harness install --recipe FILE. Its harness runs once a
84
+ harness-check of it passed on DIR, through this server's model proxy (a plan-billed one's keys are
85
+ not saved on a server yet); a recipe the loader refuses, or whose id another harness has, refuses
86
+ the start
87
+ --harness-sign-in run a person's runs of a plan-billed recipe with a sign-in on your own sign-in (agentrun harness
88
+ sign-in), never a schedule's or a trigger's. One owner's own machine alone: the start is refused
89
+ unless the server listens on loopback with no public address, keeps its store in DIR (no
90
+ AGENTRUN_STORE_URL), runs its runs beside it as its own user, and takes one API token
79
91
  --no-runner run the server alone, with no runner beside it (default: one runner beside the server); start one or
80
92
  more \`agentrun-serve runner --data DIR\` processes on the same data directory to claim and run runs;
81
93
  each holds at most --loops N runs (default AGENTRUN_MAX_RUNS, else as many pi runs as its host's
@@ -104,6 +116,10 @@ AGENTRUN_TELEMETRY=debug prints each event on stderr and sends none.
104
116
  AGENTRUN_API_ONLY=1 serves the run API alone, for a server behind its caller's backend (the routes in api-only.ts; every
105
117
  other address is a 404, and there are no accounts).
106
118
 
119
+ AGENTRUN_LAUNCH_HOOK_URL with AGENTRUN_LAUNCH_HOOK_SECRET (a whsec_ secret): each trigger firing that would start a run
120
+ is POSTed to that URL, signed as Standard Webhooks, and the host starts the run through the API; this server starts
121
+ none for it. A 2xx answer marks the firing sent; any other, or none in 10 s, skipped. Set both, or neither.
122
+
107
123
  The page is for one person, who signs in with a password (AGENTRUN_ACCOUNTS=0 turns this off; the token works for
108
124
  scripts and the CLI either way). With no AGENTRUN_PUBLIC_URL, listening on loopback, the first visit to the page sets the
109
125
  password; with it, or on any other address, the setup link this server prints carries a code. Sign-in tries are limited
@@ -258,6 +274,32 @@ if (process.argv[2] === "install-harness") {
258
274
  process.exit(1);
259
275
  }
260
276
  }
277
+ // The owner's own sign-in to a recipe's agent, by the agent itself on this terminal (harness-sign-in.ts): the agent prints
278
+ // the address and reads the code, this terminal its stdin, stdout and stderr. 0 once the agent's sign-in exits 0, 1 when
279
+ // it did not sign in (its code), 2 for usage. No key is read. `agentrun harness sign-in` runs it.
280
+ if (process.argv[2] === "sign-in-harness") {
281
+ const usage = (message) => (console.error(`agentrun-serve sign-in-harness: ${message}\n\n${USAGE}`), process.exit(2));
282
+ const read = () => {
283
+ try {
284
+ return parseArgs({ args: process.argv.slice(3), options: { recipe: { type: "string" }, data: { type: "string" } } });
285
+ }
286
+ catch (error) {
287
+ return usage(error.message);
288
+ }
289
+ };
290
+ const { values } = read();
291
+ if (!values.recipe)
292
+ usage("--recipe FILE names the recipe whose agent signs in.");
293
+ const { signInHarness } = await import("./harness-sign-in.js");
294
+ const data = resolve(values.data ?? defaultData());
295
+ const done = await signInHarness({ recipe: values.recipe, data, env: process.env, say: (line) => console.error(line) });
296
+ if (!done.ok) {
297
+ console.error(done.message);
298
+ process.exit(1);
299
+ }
300
+ console.log(`Signed in: the agent keeps its sign-in in ${done.home}, and a server you start with --harness-sign-in on this machine runs your own runs on it. AgentRun never reads it.`);
301
+ process.exit(0);
302
+ }
261
303
  // A recipe's agent run for real and judged (harness-check.ts): its report written as JSON, its stages and the three facts
262
304
  // (resume, tool_gate, billing) printed. 0 when every stage passed, 1 when the recipe was refused, its binary is not the
263
305
  // installed and pinned one, or a stage failed, 2 for usage. It spends: four short turns on --model, under --cap.
@@ -428,6 +470,8 @@ try {
428
470
  learning: { type: "string" },
429
471
  "no-runner": { type: "boolean", default: false },
430
472
  "harness-module": { type: "string", multiple: true, default: [] },
473
+ "harness-recipe": { type: "string", multiple: true, default: [] },
474
+ "harness-sign-in": { type: "boolean", default: false },
431
475
  help: { type: "boolean", short: "h", default: false },
432
476
  },
433
477
  }));
@@ -494,14 +538,27 @@ const signalled = () => {
494
538
  process.on("SIGINT", signalled);
495
539
  process.on("SIGTERM", signalled);
496
540
  // AGENTRUN_API_ONLY=1: the run routes alone (api-only.ts), and no owner; a value that is neither on nor off stops here.
541
+ // AGENTRUN_RUN_KEYS=1: each run brings the tool keys this server does not hold (run-keys.ts), read the same way.
497
542
  let apiOnly;
543
+ let runKeys;
498
544
  try {
499
- apiOnly = apiOnlyFrom(process.env);
545
+ apiOnly = switchFrom(API_ONLY_ENV);
546
+ runKeys = switchFrom(RUN_KEYS_ENV);
500
547
  }
501
548
  catch (error) {
502
549
  console.error(`${error.message}\n\n${USAGE}`);
503
550
  process.exit(2);
504
551
  }
552
+ // The launch hook: the URL from the environment, its secret as the server holds its own (by name, on the launcher's
553
+ // list); half set or malformed stops here, in words that never hold the secret.
554
+ let launchHook;
555
+ try {
556
+ launchHook = launchHookFrom({ url: process.env[LAUNCH_HOOK_URL_ENV], secret: secret(LAUNCH_HOOK_SECRET_ENV) });
557
+ }
558
+ catch (error) {
559
+ console.error(`agentrun-serve: ${error.message}`);
560
+ process.exit(2);
561
+ }
505
562
  const accounts = !apiOnly && process.env.AGENTRUN_ACCOUNTS !== "0";
506
563
  // The address first (listen-first.ts): the port bound and named before the rest of the server loads, then answering that
507
564
  // the server is warming until it takes the socket over. A port already taken is left to the start's own listen below,
@@ -534,10 +591,14 @@ try {
534
591
  ...(values["max-runs"] !== undefined ? { maxRuns: Number(values["max-runs"]) } : {}),
535
592
  // The owner's harness modules: --harness-module, else AGENTRUN_SERVE_HARNESS_MODULES (harness-table.ts).
536
593
  ...(harnessModulesOf(values["harness-module"], process.env).length ? { harnessModules: harnessModulesOf(values["harness-module"], process.env) } : {}),
594
+ // And its harness recipes: --harness-recipe, else AGENTRUN_SERVE_HARNESS_RECIPES (harness-table.ts).
595
+ ...(harnessRecipesOf(values["harness-recipe"], process.env).length ? { harnessRecipes: harnessRecipesOf(values["harness-recipe"], process.env) } : {}),
596
+ // Their runs on the owner's own sign-in, only as the owner says it here (no setting names it) and the start proves.
597
+ ...(values["harness-sign-in"] ? { harnessSignIn: true } : {}),
537
598
  ...(values["drain-timeout"] ? { drainTimeout: values["drain-timeout"] } : {}), ...(values.documents ? { documents: values.documents } : {}), ...(values["allow-code-nodes"] ? { allowCodeNodes: true } : {}), ...(values.learning !== undefined ? { learning: values.learning } : {}), log: (line) => void process.stdout.write(`${line}\n`),
538
599
  // The public address is the server's with accounts on or off: the Host names it serves, the webhook URLs it gives.
539
600
  ...(publicUrl ? { publicUrl } : {}),
540
- ...(accounts ? { accounts, openSetup: !publicUrl, countSessions: true } : {}), ...(apiOnly ? { apiOnly } : {}),
601
+ ...(accounts ? { accounts, openSetup: !publicUrl, countSessions: true } : {}), ...(apiOnly ? { apiOnly } : {}), ...(launchHook ? { launchHook } : {}), ...(runKeys ? { runKeys } : {}),
541
602
  // The proxies whose X-Forwarded-For the sign-in limit reads (comma-separated); none unless set.
542
603
  ...(trustedProxies.length ? { trustedProxies } : {}),
543
604
  // A local install only as its operator says, never inferred: an MCP server on loopback is refused without it.
@@ -594,6 +655,8 @@ if (!values["no-runner"] && askedAt === undefined) {
594
655
  const source = given ? "env" : givenList ? "list" : serve.tokenMade ? "made" : "file";
595
656
  for (const line of banner({ url: serve.url, baseUrl: serve.baseUrl, data, token: serve.token, source, tokenIds: serve.tokenIds, accounts, ...(apiOnly ? { apiOnly } : {}), ...(serve.launchCode ? { launchCode: serve.launchCode } : {}), boxes: serve.boxesLine, ...(values.listen ? { listen: values.listen } : {}), ...(publicUrl ? { publicUrl } : {}) }))
596
657
  console.log(line);
658
+ if (launchHook)
659
+ console.log(`Launch hook (${LAUNCH_HOOK_URL_ENV}): trigger firings go to ${hookOrigin(launchHook)}, whose host starts their runs; this server starts none for them.`);
597
660
  // Open setup (no public address, a loopback listener): the link that sets the password. Any other start printed the
598
661
  // setup link with its code as the code was made (owner.ts).
599
662
  if (serve.setupUrl && serve.setupOpen)
@@ -10,7 +10,8 @@ export type ComposioControl = {
10
10
  export declare const COMPOSIO_USER = "agentrun";
11
11
  /** A Composio toolkit's slug, as a save takes it once trimmed and lower-cased. */
12
12
  export declare const COMPOSIO_TOOLKIT: RegExp;
13
- /** A Composio user id, as a save's `user_id` and a run's binding (mcp_auth's composio_user_id) take it. */
13
+ /** A Composio user id, as a save's `user_id` and a run's binding (mcp_auth's composio_user_id) take it. A `:` is taken:
14
+ * a host names a team's connected accounts by a user such as `team:<tenant>`. */
14
15
  export declare const COMPOSIO_USER_ID: RegExp;
15
16
  /** The `user_id` a save names for a per-run server, reserved for that and never a Composio user: the server keeps no user
16
17
  * and no connected account, and each run names its own (mcp_auth.<server> = {composio_user_id, connected_account_id?}). */
@@ -16,8 +16,9 @@ export const COMPOSIO_USER = "agentrun";
16
16
  /** A Composio toolkit's slug, as a save takes it once trimmed and lower-cased. */
17
17
  export const COMPOSIO_TOOLKIT = /^[a-z0-9][a-z0-9_-]{0,63}$/;
18
18
  const TOOLKIT = COMPOSIO_TOOLKIT;
19
- /** A Composio user id, as a save's `user_id` and a run's binding (mcp_auth's composio_user_id) take it. */
20
- export const COMPOSIO_USER_ID = /^[A-Za-z0-9._@-]{1,128}$/;
19
+ /** A Composio user id, as a save's `user_id` and a run's binding (mcp_auth's composio_user_id) take it. A `:` is taken:
20
+ * a host names a team's connected accounts by a user such as `team:<tenant>`. */
21
+ export const COMPOSIO_USER_ID = /^[A-Za-z0-9._@:-]{1,128}$/;
21
22
  const USER_ID = COMPOSIO_USER_ID;
22
23
  /** The `user_id` a save names for a per-run server, reserved for that and never a Composio user: the server keeps no user
23
24
  * and no connected account, and each run names its own (mcp_auth.<server> = {composio_user_id, connected_account_id?}). */
@@ -196,7 +197,7 @@ export async function composioSave(body, control, save, name, signal, savedUrl)
196
197
  if (!tools.length || tools.length > MAX_TOOLS || !tools.every((t) => typeof t === "string" && t && t.length <= MAX_SLUG))
197
198
  issues.push(issue("tools", "invalid", `Send the slugs of the actions to grant: 1 to ${MAX_TOOLS} of them, each at most ${MAX_SLUG} characters.`));
198
199
  if (!USER_ID.test(user))
199
- issues.push(issue("user_id", "invalid", `A user_id is letters, digits and . _ @ - (at most 128), or "${COMPOSIO_PER_RUN}" for a server each run names its own account for.`));
200
+ issues.push(issue("user_id", "invalid", `A user_id is letters, digits and . _ @ : - (at most 128), or "${COMPOSIO_PER_RUN}" for a server each run names its own account for.`));
200
201
  if (price !== undefined && !priceValid(price))
201
202
  issues.push(issue("price_usd", "invalid", "price_usd is what each call of the server's actions costs, in USD: a finite number, 0 or more."));
202
203
  if (ownConfig !== undefined && !COMPOSIO_AUTH_CONFIG_ID.test(ownConfig))
@@ -1,3 +1,4 @@
1
+ import { ApiError } from "./errors.js";
1
2
  import { type ComposioControl } from "./composio-preset.js";
2
3
  import type { Source } from "./trigger-adapter.js";
3
4
  import type { TriggerUpstream } from "./triggers.js";
@@ -48,6 +49,9 @@ export type ComposioEvent = {
48
49
  polled: boolean;
49
50
  sealed: string[];
50
51
  };
52
+ /** A Composio trigger's refusal on a server with no public URL: made by make, and read by an apply's plan, which asks
53
+ * Composio nothing. */
54
+ export declare const composioNoPublicUrl: () => ApiError;
51
55
  export declare class ComposioTriggers implements TriggerUpstream {
52
56
  private readonly deps;
53
57
  /** Each project's last step queued (serial), by a digest of its key. */
@@ -80,6 +80,9 @@ function onField(error, field) {
80
80
  const issue = error.extra.fields?.[0];
81
81
  return issue && (issue.field === "body" || issue.field === "toolkit") ? invalid([{ ...issue, field }]) : error;
82
82
  }
83
+ /** A Composio trigger's refusal on a server with no public URL: made by make, and read by an apply's plan, which asks
84
+ * Composio nothing. */
85
+ export const composioNoPublicUrl = () => new ApiError("composio_no_public_url", "Composio can't reach this server: set its public URL first (AGENTRUN_PUBLIC_URL, the https address Composio sends events to), then make the trigger.");
83
86
  export class ComposioTriggers {
84
87
  deps;
85
88
  /** Each project's last step queued (serial), by a digest of its key. */
@@ -90,7 +93,7 @@ export class ComposioTriggers {
90
93
  // ---- the trigger engine's (TriggerUpstream) ----------------------------------------------------------------------------
91
94
  async make(source, id, enabled, keep) {
92
95
  if (!this.deps.publicUrl)
93
- throw new ApiError("composio_no_public_url", "Composio can't reach this server: set its public URL first (AGENTRUN_PUBLIC_URL, the https address Composio sends events to), then make the trigger.");
96
+ throw composioNoPublicUrl();
94
97
  for (const field of ["instance_id", "hook", SEALED_FIELD])
95
98
  if (source[field] !== undefined)
96
99
  throw invalid([{ field: `source.${field}`, reason: "not_allowed", message: `${field} is set by this server when it makes the trigger on Composio: leave it out.` }]);
@@ -0,0 +1,32 @@
1
+ import type { ComputerClient, ProviderEntry } from "@parcha/agentrun-computer";
2
+ import type { InputIssue } from "./errors.js";
3
+ /** A need as a setting says it: a program's name a shell finds on its PATH, or a library's pip or npm name; no path, no
4
+ * space and no leading dash, so a scoped npm package (`@scope/name`) can't be named. */
5
+ export declare const NEED_NAME: RegExp;
6
+ /** The most needs one setting names. */
7
+ export declare const MAX_NEEDS = 32;
8
+ /** How long the check in the box may take. */
9
+ export declare const NEEDS_CHECK_MS = 30000;
10
+ /** The media image's recipe in the computer package, as the words of a Docker box's fix name it. */
11
+ export declare const MEDIA_RECIPE_PATH = "packages/computer/media/Dockerfile";
12
+ /** The documents image's recipe folder in the computer package, as the words of a Docker box's fix name it. */
13
+ export declare const DOCUMENTS_RECIPE_DIR = "packages/computer/documents";
14
+ /** What is wrong with `value` as a sandbox's needs, at `field`. */
15
+ export declare function needsIssues(value: unknown, field: string): InputIssue[];
16
+ /** What the box answered: the needs it lacks (none: it has them all), or why it could not be asked. */
17
+ export type NeedsAnswer = {
18
+ readonly missing: readonly string[];
19
+ } | {
20
+ readonly unchecked: string;
21
+ };
22
+ /** Asks the box behind `client` which of `needs` it lacks, by one `sh` with the names as its arguments, under the agent's
23
+ * shell environment (shellEnv): its PATH, never the image's, so a program the check finds is one the agent's bash finds. */
24
+ export declare function missingNeeds(client: ComputerClient, needs: readonly string[], signal?: AbortSignal): Promise<NeedsAnswer>;
25
+ /** How to give the Docker box an image that has what a sandbox needs. */
26
+ export declare const DOCKER_IMAGE_FIX = "Set AGENTRUN_DOCKER_IMAGE to an image that has them and restart the server. For video (chrome, ffmpeg, ffprobe, hyperframes), build the media image: docker build -t agentrun-media:<first 12 hex of its sha256> - < packages/computer/media/Dockerfile, and name that tag. For decks, documents and sheets (python-pptx, python-docx, openpyxl, pptxgenjs, docx, exceljs), build the documents image: docker build -t agentrun-documents:<first 12 hex of the sha256 of its Dockerfile and documents.sh> packages/computer/documents, and name that tag.";
27
+ /** The words a run ends with when its setting needs programs but is no sandbox (`what`: "none", "a desktop on E2B"):
28
+ * only a sandbox's box is checked for them, so nothing ran. The validator keeps needs to a sandbox; a stored body and a
29
+ * launch's computer are read as given, so the claim refuses this too, never running without them. */
30
+ export declare function needsNoSandboxWords(needs: readonly string[], what: string): string;
31
+ /** The words a run ends with when its box lacks what its agent needs, or could not be asked: nothing ran. */
32
+ export declare function needsWords(answer: NeedsAnswer, needs: readonly string[], entry: Pick<ProviderEntry, "label" | "local" | "imageEnv"> | undefined): string;
@@ -0,0 +1,80 @@
1
+ import { shellEnv } from "./workspace/hands.js";
2
+ /** A need as a setting says it: a program's name a shell finds on its PATH, or a library's pip or npm name; no path, no
3
+ * space and no leading dash, so a scoped npm package (`@scope/name`) can't be named. */
4
+ export const NEED_NAME = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/;
5
+ /** The most needs one setting names. */
6
+ export const MAX_NEEDS = 32;
7
+ /** How long the check in the box may take. */
8
+ export const NEEDS_CHECK_MS = 30_000;
9
+ /** The media image's recipe in the computer package, as the words of a Docker box's fix name it. */
10
+ export const MEDIA_RECIPE_PATH = "packages/computer/media/Dockerfile";
11
+ /** The documents image's recipe folder in the computer package, as the words of a Docker box's fix name it. */
12
+ export const DOCUMENTS_RECIPE_DIR = "packages/computer/documents";
13
+ /** What is wrong with `value` as a sandbox's needs, at `field`. */
14
+ export function needsIssues(value, field) {
15
+ const rule = `${field} is a list of 1 to ${MAX_NEEDS} program names the box must have on its PATH (or libraries its python3 or node loads, by their pip or npm names), each once, such as ["ffmpeg", "ffprobe"]`;
16
+ if (!Array.isArray(value) || value.length === 0 || value.length > MAX_NEEDS || !value.every((name) => typeof name === "string"))
17
+ return [{ field, reason: "wrong_type", message: rule }];
18
+ const bad = value.find((name) => !NEED_NAME.test(name));
19
+ if (bad !== undefined)
20
+ return [{ field, reason: "bad_format", message: `${field} holds ${JSON.stringify(bad)}, not a need's name: letters, digits, dots, underscores, plus signs and dashes, starting with a letter or digit, no path` }];
21
+ if (new Set(value).size !== value.length)
22
+ return [{ field, reason: "duplicate", message: `${field} names one need twice` }];
23
+ return [];
24
+ }
25
+ /** Whether the box's python3 has the distribution `sys.argv[1]` installed, by the name pip installs it by (pip's own
26
+ * normalization: case, dots, dashes and underscores alike). */
27
+ const PYTHON_HAS = "import importlib.metadata, sys; importlib.metadata.distribution(sys.argv[1])";
28
+ /** Whether a script of the box's node requires the name it is given (its one argument, the last of process.argv), from the folder the check runs in: node_modules of
29
+ * that folder and of each folder above it, up to /node_modules (where the documents image links its libraries), and
30
+ * node's global folders. */
31
+ const NODE_HAS = 'require("module").createRequire(process.cwd() + "/").resolve(process.argv.at(-1))';
32
+ /** The script the box runs: each argument it finds neither as a program on its PATH, nor as a library its python3 has
33
+ * installed, nor as a package its node requires, one a line. A box with no python3 or no node lacks the libraries that
34
+ * would need it. The names are arguments, never text of the script. */
35
+ const CHECK = `for name do command -v "$name" >/dev/null 2>&1 || python3 -c '${PYTHON_HAS}' "$name" >/dev/null 2>&1 || node -e '${NODE_HAS}' "$name" >/dev/null 2>&1 || printf "%s\\n" "$name"; done`;
36
+ /** Asks the box behind `client` which of `needs` it lacks, by one `sh` with the names as its arguments, under the agent's
37
+ * shell environment (shellEnv): its PATH, never the image's, so a program the check finds is one the agent's bash finds. */
38
+ export async function missingNeeds(client, needs, signal) {
39
+ let ran;
40
+ try {
41
+ ran = await client.call("exec.run", { argv: ["sh", "-c", CHECK, "sh", ...needs], env: { ...shellEnv() }, timeoutMs: NEEDS_CHECK_MS }, signal ? { signal } : undefined);
42
+ }
43
+ catch (error) {
44
+ return { unchecked: error instanceof Error ? error.message : String(error) };
45
+ }
46
+ if (!ran.ok)
47
+ return { unchecked: ran.error.message };
48
+ if (ran.value.exitCode !== 0)
49
+ return { unchecked: ran.value.timedOut ? `the check ran past ${NEEDS_CHECK_MS / 1000} s` : `the check exited ${ran.value.exitCode ?? `on ${ran.value.signal ?? "a signal"}`}` };
50
+ const said = Buffer.from(ran.value.stdout, "base64").toString("utf8").split("\n").filter(Boolean);
51
+ // Only names it was asked about: anything else the box printed is not an answer.
52
+ const missing = needs.filter((name) => said.includes(name));
53
+ return { missing };
54
+ }
55
+ /** How to give the Docker box an image that has what a sandbox needs. */
56
+ export const DOCKER_IMAGE_FIX = `Set AGENTRUN_DOCKER_IMAGE to an image that has them and restart the server. For video (chrome, ffmpeg, ffprobe, hyperframes), build the media image: docker build -t agentrun-media:<first 12 hex of its sha256> - < ${MEDIA_RECIPE_PATH}, and name that tag. For decks, documents and sheets (python-pptx, python-docx, openpyxl, pptxgenjs, docx, exceljs), build the documents image: docker build -t agentrun-documents:<first 12 hex of the sha256 of its Dockerfile and documents.sh> ${DOCUMENTS_RECIPE_DIR}, and name that tag.`;
57
+ /** How to give `entry`'s box an image that has what it lacks: a Docker box's is AGENTRUN_DOCKER_IMAGE (the media or
58
+ * documents image), a provider that names its image by a setting (imageEnv) by that one, any other its own image. */
59
+ function fixFor(entry) {
60
+ if (entry?.local)
61
+ return DOCKER_IMAGE_FIX;
62
+ if (entry?.imageEnv)
63
+ return `Set ${entry.imageEnv} to an image of ${entry.label}'s that has them and restart the server, or run this agent on the Docker box with an image that has them (AGENTRUN_DOCKER_IMAGE).`;
64
+ return `Give this agent a computer whose image has them: on the Docker box, set AGENTRUN_DOCKER_IMAGE to such an image (the media image, ${MEDIA_RECIPE_PATH}, has chrome, ffmpeg, ffprobe and hyperframes).`;
65
+ }
66
+ /** The words a run ends with when its setting needs programs but is no sandbox (`what`: "none", "a desktop on E2B"):
67
+ * only a sandbox's box is checked for them, so nothing ran. The validator keeps needs to a sandbox; a stored body and a
68
+ * launch's computer are read as given, so the claim refuses this too, never running without them. */
69
+ export function needsNoSandboxWords(needs, what) {
70
+ const list = new Intl.ListFormat("en", { type: "conjunction" }).format(needs);
71
+ return `This agent needs ${list} in a sandbox (computer.needs), and its computer is ${what}, which is not checked for them, so nothing ran. Make its computer a sandbox on the Docker box. ${DOCKER_IMAGE_FIX}`;
72
+ }
73
+ /** The words a run ends with when its box lacks what its agent needs, or could not be asked: nothing ran. */
74
+ export function needsWords(answer, needs, entry) {
75
+ const box = `This agent's sandbox${entry ? ` on ${entry.label}` : ""}`;
76
+ if ("unchecked" in answer)
77
+ return `${box} could not be checked for what it needs (${needs.join(", ")}): ${answer.unchecked.replace(/[.!?]+$/, "")}. Nothing ran.`;
78
+ const list = new Intl.ListFormat("en", { type: "conjunction" }).format(answer.missing);
79
+ return `${box} lacks ${list}, which the agent needs (computer.needs), so nothing ran. ${fixFor(entry)}`;
80
+ }
@@ -23,6 +23,7 @@ export type ComputerSetting = {
23
23
  readonly image?: string;
24
24
  readonly gpu?: GpuSetting;
25
25
  readonly persistent?: boolean;
26
+ readonly needs?: readonly string[];
26
27
  } | {
27
28
  readonly kind: "desktop" | "phone";
28
29
  readonly provider: string;
@@ -45,6 +46,14 @@ export declare const gpuOf: (computer: {
45
46
  }) => GpuSetting | undefined;
46
47
  /** The fields a computer of `kind` may set beside its kind and provider, in OPTIONAL's order: none for kind none. */
47
48
  export declare const kindSettings: (kind: ComputerKind) => string[];
49
+ /** Whether a run of a kind can record its screen on this server (GET /v2/computers' `record`), and why not, in words. */
50
+ export type RecordView = {
51
+ available: boolean;
52
+ why?: string;
53
+ };
54
+ /** Whether a run of `kind` can record its screen here: the kind takes record (OPTIONAL's record.kinds) and ffmpeg is on
55
+ * `path` (recorderMissing, the server's PATH now when absent), as a save of record: true is checked. */
56
+ export declare function recordOf(kind: ComputerKind, path?: string | undefined): RecordView;
48
57
  /** A place as the v2 API names it. */
49
58
  export type PlaceView = {
50
59
  mode: "runner";
@@ -1,5 +1,5 @@
1
1
  // An agent's computer, its one setting for where its tools run (Settings → Computers): `computer: { kind, provider?,
2
- // image?, gpu?, persistent?, surface?, exec?, record? }` on its revision. kind is none, sandbox, desktop, phone or browser;
2
+ // image?, gpu?, persistent?, surface?, exec?, record?, needs? }` on its revision. kind is none, sandbox, desktop, phone or browser;
3
3
  // provider names one of the computer providers (the computer package's kind registry), and is absent for none; image
4
4
  // names one the provider offers for the kind, and absent is the kind's default; a sandbox's gpu is { type, count };
5
5
  // persistent: true keeps the agent's own computer between its runs, where the configuration declares persistence. A
@@ -10,6 +10,7 @@
10
10
  // {kind: "sandbox", provider: X}. Writing either sets both. A desktop, phone or browser computer leaves the run's folder
11
11
  // on the runner, so its place reads runner.
12
12
  import { configurationOf, PROVIDERS, serves } from "@parcha/agentrun-computer";
13
+ import { needsIssues } from "./computer-needs.js";
13
14
  import { recorderMissing } from "./computer-record.js";
14
15
  const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
15
16
  /** The kinds of computer an agent can be given. */
@@ -73,9 +74,26 @@ const OPTIONAL = {
73
74
  return [];
74
75
  },
75
76
  },
77
+ // The programs the sandbox must have on its PATH (computer-needs.ts): checked in the box at each claim, before the
78
+ // run's first model request; a box that lacks one ends the run in words. It says what the box holds, never its image.
79
+ needs: {
80
+ kinds: ["sandbox"],
81
+ check: needsIssues,
82
+ },
76
83
  };
77
84
  /** The fields a computer of `kind` may set beside its kind and provider, in OPTIONAL's order: none for kind none. */
78
85
  export const kindSettings = (kind) => kind === "none" ? [] : Object.entries(OPTIONAL).filter(([, { kinds }]) => kinds === undefined || kinds.includes(kind)).map(([key]) => key);
86
+ /** Whether a run of `kind` can record its screen here: the kind takes record (OPTIONAL's record.kinds) and ffmpeg is on
87
+ * `path` (recorderMissing, the server's PATH now when absent), as a save of record: true is checked. */
88
+ export function recordOf(kind, path = process.env.PATH) {
89
+ const kinds = OPTIONAL.record.kinds;
90
+ if (!kinds.includes(kind)) {
91
+ const recorders = kinds.map((one) => `a ${one}`);
92
+ return { available: false, why: kind === "none" ? "with no computer, there is no screen to record" : `a ${kind} has no screen to record (${recorders.slice(0, -1).join(", ")} or ${recorders.at(-1)} does)` };
93
+ }
94
+ const missing = recorderMissing(path);
95
+ return missing ? { available: false, why: missing } : { available: true };
96
+ }
79
97
  /** The place the setting reads as: sandbox on its provider, else the runner (no computer holds the run's folder). */
80
98
  export const placeOfComputer = (computer) => (computer.kind === "sandbox" ? { mode: "sandbox", box: computer.provider } : { mode: "runner" });
81
99
  /** The setting a place says: runner is no computer, a sandbox place a sandbox on its box. */
@@ -1,6 +1,6 @@
1
1
  import { type ComputerProvider, type GpuCapability, type HostCommand, type MountKind, type ProviderEntry } from "@parcha/agentrun-computer";
2
2
  import { type KeyChoice, type KeyTable, type ProviderFactories, type ProviderSettings } from "./computer-keys.js";
3
- import { type ComputerKind } from "./computer-setting.js";
3
+ import { type ComputerKind, type RecordView } from "./computer-setting.js";
4
4
  import { type DockerDaemon } from "./docker-daemon.js";
5
5
  import { type KeyEnv, type KeyMeta } from "./key-meta.js";
6
6
  import type { PairedComputerRow, Store } from "./store/index.js";
@@ -56,6 +56,8 @@ export interface ComputerRoutesOptions {
56
56
  * relays each socket to it, so a dial provider's runs can use it and its row says nothing. Read once per view and per
57
57
  * test. Absent: none does. A paired computer's socket is never relayed. */
58
58
  readonly relayed?: () => Promise<boolean>;
59
+ /** The PATH a kind's `record` looks for ffmpeg on. Absent: the server's, read at each view, as a save's check reads it. */
60
+ readonly path?: string;
59
61
  }
60
62
  /** A provider as Settings shows it: `metered` straight from the kind registry (its computers are billed by the vendor);
61
63
  * its keys as SecretMeta under `secrets`, each named "computer:<provider>:<KEY>", and `required`, the names of the ones
@@ -114,7 +116,8 @@ export declare const NETWORK_REFUSED_WORDS = "needs a network, which this server
114
116
  * the allow-list applies as it is (Docker), or nothing is declared. */
115
117
  export declare function networkWords(network: readonly string[] | undefined, kind?: ComputerKind): string | undefined;
116
118
  /** A kind; kind none, the one "no computer" choice, carries its ShellChoice itself (it has no providers). `settings`: the
117
- * fields its computer may set beside kind and provider (computer-setting.ts kindSettings). */
119
+ * fields its computer may set beside kind and provider (computer-setting.ts kindSettings). `record`: whether a run of it
120
+ * can record its screen on this server, or why not (computer-setting.ts recordOf). */
118
121
  export type KindView = {
119
122
  kind: ComputerKind;
120
123
  offered: boolean;
@@ -122,6 +125,7 @@ export type KindView = {
122
125
  groups: string[];
123
126
  tools: string[];
124
127
  settings: string[];
128
+ record: RecordView;
125
129
  providers: ProviderView[];
126
130
  } & Partial<ShellChoice>;
127
131
  export type TestView = {
package/dist/computers.js CHANGED
@@ -10,7 +10,7 @@
10
10
  import { connectOf, imagesOf } from "@parcha/agentrun-computer";
11
11
  import { BOX_ALLOW_ENV, boxAllowOf } from "./box-settings.js";
12
12
  import { KEY_TABLE, keyChoices, providerOptions, settingOptions, testConnection } from "./computer-keys.js";
13
- import { COMPUTER_KINDS, kindSettings } from "./computer-setting.js";
13
+ import { COMPUTER_KINDS, kindSettings, recordOf } from "./computer-setting.js";
14
14
  import { inArchilMode } from "./archil-settings.js";
15
15
  import { daemonUp, noDockerWords } from "./docker-daemon.js";
16
16
  import { ApiError, invalid } from "./errors.js";
@@ -194,7 +194,7 @@ export function createComputerRoutes(options) {
194
194
  const why = offered ? undefined
195
195
  : serving.length && serving.every(refusedOpen) ? `every provider of a ${kind} computer needs a network, and this server's ${BOX_ALLOW_ENV} is none (no network)`
196
196
  : serving.length ? `no provider of a ${kind} computer can reach this server's run folders` : `no provider serves a ${kind} computer`;
197
- return { kind, offered, ...(why ? { why } : {}), groups: [...spec.required, ...spec.optional], tools: [...tools(kind)], settings: kindSettings(kind), providers, ...(kind === "none" ? choice({ kind: "none" }) : {}) };
197
+ return { kind, offered, ...(why ? { why } : {}), groups: [...spec.required, ...spec.optional], tools: [...tools(kind)], settings: kindSettings(kind), record: recordOf(kind, options.path), providers, ...(kind === "none" ? choice({ kind: "none" }) : {}) };
198
198
  }),
199
199
  paired,
200
200
  };