@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/uploads.js CHANGED
@@ -3,10 +3,11 @@
3
3
  // for it at its start and copied into its workspace at its claim. Each file is `<data>/files/<file_id>/`: its bytes
4
4
  // (`bytes`) and its record (`file.json`, the contract's File), both 0600, the record written whole. A ready file's bytes
5
5
  // never change, and a run gets a copy of them through its Workspace, never a link: nothing a run does reaches the upload.
6
- import { createHash, randomBytes } from "node:crypto";
6
+ import { createHash } from "node:crypto";
7
7
  import { copyFile, link, lstat, mkdir, open, readdir, readFile, rename, rm, unlink } from "node:fs/promises";
8
8
  import { DISK_DIR } from "./server-fs.js";
9
9
  import { dirname, join } from "node:path";
10
+ import { uuidv7 } from "./ids.js";
10
11
  import { ApiError, invalid } from "./errors.js";
11
12
  import { typeOf } from "./file-types.js";
12
13
  import { readJson, serialBy, tempOf, writeDurable } from "./files.js";
@@ -59,16 +60,6 @@ export const uploadUrl = (id) => `/v2/files/${id}`;
59
60
  /** Test seams, tests only: as a run's copy starts, with the run's Workspace, before any file is copied; and as a file
60
61
  * sent in one call writes its record, with the file's folder, its bytes in place. */
61
62
  export const uploadTestHooks = {};
62
- /** A UUIDv7, the form of the agent store's agent and run ids: 48 bits of Unix milliseconds, then random bits, so ids
63
- * sort by creation time. The store mints its own inside it and exports no minter. */
64
- export function uuidv7(now = Date.now()) {
65
- const bytes = randomBytes(16);
66
- bytes.writeUIntBE(now, 0, 6);
67
- bytes[6] = (bytes[6] & 0x0f) | 0x70;
68
- bytes[8] = (bytes[8] & 0x3f) | 0x80;
69
- const hex = bytes.toString("hex");
70
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
71
- }
72
63
  /** Why `path` is not the contract's FilePathString (relative, `/` between segments, no empty segment and none that starts
73
64
  * with `.`, no backslash or NUL, at most 1024 characters), or a segment is longer than a name on disk; undefined when it
74
65
  * is one. */
package/dist/validate.js CHANGED
@@ -18,7 +18,7 @@ export const isObject = (value) => typeof value === "object" && value !== null &
18
18
  /** How long an Idempotency-Key answers with its first answer (capabilities' limits.idempotency_ttl_s). */
19
19
  export const IDEMPOTENCY_TTL_S = 86_400;
20
20
  export const stable = (value) => Array.isArray(value) ? `[${value.map(stable).join(",")}]` : isObject(value) ? `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${stable(value[k])}`).join(",")}}` : JSON.stringify(value);
21
- export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "model_tiers", "thinking", "harness", "place", "computer", "learning", "skills", "tools", "tool_settings", "approvals", "max_cost_usd", "input_schema", "output_schema", "checkout", "native", "sdk", "cli_learning"];
21
+ export const DEFINITION_FIELDS = ["id", "version", "name", "description", "instructions", "workflow", "model", "model_tiers", "thinking", "harness", "place", "computer", "learning", "skills", "tools", "tool_settings", "approvals", "max_cost_usd", "max_requests", "input_schema", "output_schema", "checkout", "native", "sdk", "cli_learning"];
22
22
  /** What an agentic definition may ask the server to check out in each run's folder before its first turn
23
23
  * (runner/pr-checkout.ts): `pull_request`, the pull request the run's GitHub event names, at its head, read-only, in
24
24
  * `repo/`; `none` clears it on an edit. */
@@ -175,6 +175,9 @@ export function definitionIssues(definition, { at = "definition", creating = tru
175
175
  if (!(typeof d.max_cost_usd === "number" && Number.isFinite(d.max_cost_usd) && d.max_cost_usd >= 0))
176
176
  out.push(issue(`${at}.max_cost_usd`, "wrong_type", `${at}.max_cost_usd is a number of at least 0, in US dollars: above 0 sets the agent's default cap, 0 clears it`));
177
177
  }
178
+ // The agent's limit on each run's free-model requests: see DefinitionInput.max_requests (openapi.ts).
179
+ if (d.max_requests !== undefined && !(typeof d.max_requests === "number" && Number.isSafeInteger(d.max_requests) && d.max_requests >= 0))
180
+ out.push(issue(`${at}.max_requests`, "wrong_type", `${at}.max_requests is a whole number of at least 0: above 0 sets the most requests on free models each run makes (the server's own limit holds when it is lower), 0 clears it`));
178
181
  // The server's checkout before each run's first turn: kept by an edit that leaves it out, cleared by `none`.
179
182
  if (d.checkout !== undefined) {
180
183
  if (d.workflow !== undefined)
@@ -16,11 +16,14 @@ export declare const MEDIA_DIR = "media";
16
16
  export declare const PATH_MAX_CHARS = 1024;
17
17
  export declare const TYPE_MAX_CHARS = 255;
18
18
  export declare const WORDS_MAX_CHARS = 2000;
19
+ /** `duration_s`: an audio or video file's length in seconds (to the millisecond), when its bytes give it (mp3, wav, mp4,
20
+ * m4a, mov: media-duration.ts); absent for any other file, so an agent can time a cut or price a job billed by length. */
19
21
  export type Saved = {
20
22
  ok: true;
21
23
  path: string;
22
24
  bytes: number;
23
25
  content_type: string;
26
+ duration_s?: number;
24
27
  url: string;
25
28
  };
26
29
  export type Unsaved = {
package/dist/web-save.js CHANGED
@@ -4,6 +4,7 @@
4
4
  import { extname } from "node:path";
5
5
  import { defineTool } from "@earendil-works/pi-durable";
6
6
  import { extensionOf, typeOf } from "./file-types.js";
7
+ import { mediaSeconds } from "./media-duration.js";
7
8
  import { clip, URL_MAX } from "./web-fetch-direct.js";
8
9
  import { forModel } from "./result.js";
9
10
  import { isWorkspaceError, workspaceErrorWords } from "./workspace/index.js";
@@ -203,12 +204,26 @@ export async function webSave(args, work, options = {}) {
203
204
  catch (error) {
204
205
  return { ...failed(error), url: final };
205
206
  }
206
- return { ok: true, path: at, bytes: file.bytes.length, content_type: typed.type, url: final };
207
+ const seconds = lengthOf(file.bytes, typed.type);
208
+ return { ok: true, path: at, bytes: file.bytes.length, content_type: typed.type, ...(seconds === undefined ? {} : { duration_s: seconds }), url: final };
207
209
  }
208
210
  finally {
209
211
  release();
210
212
  }
211
213
  }
214
+ /** An audio or video file's length in seconds, rounded to the millisecond; undefined for any other type, or when its bytes
215
+ * don't give it. Never throws: a saved file is answered saved whatever its bytes hold. */
216
+ function lengthOf(bytes, type) {
217
+ if (!/^(audio|video)\//.test(type))
218
+ return undefined;
219
+ try {
220
+ const seconds = mediaSeconds(bytes);
221
+ return seconds === undefined ? undefined : Math.round(seconds * 1000) / 1000;
222
+ }
223
+ catch {
224
+ return undefined;
225
+ }
226
+ }
212
227
  /** The words the model reads: the answer's JSON. */
213
228
  export const savedText = (answer) => JSON.stringify(answer);
214
229
  /** web_save on `work`, its download through `guard` (a test's or the fakes' resolver and fetch, none for the network), its
@@ -216,7 +231,7 @@ export const savedText = (answer) => JSON.stringify(answer);
216
231
  export function webSaveTool(work, guard, slots) {
217
232
  return defineTool({
218
233
  name: WEB_SAVE_TOOL,
219
- description: `Download one file from a public URL into this run's folder, where it stays (the run's Files show and play it): use it for a generated image, audio or video a service answered with a link that expires. path is where to save it, relative to the run's folder; a bare name (cat.png) goes under ${MEDIA_DIR}/. A path that already holds a file is refused, never overwritten. The file must be a type its bytes show: an image (png, jpeg, gif, webp), audio (mp3, wav, ogg, m4a) or video (mp4, webm), and the path must have an extension of that type (cat.png, not cat or cat.bin); any other type (a page, a PDF, text) is saved only to a path whose extension names the type the host declares. At most ${SAVE_MAX_BYTES / (1024 * 1024)} MiB and ${SAVE_TIMEOUT_MS / 60_000} minutes. A private or local address, a port other than 80 or 443, or a scheme other than http(s) is refused, at every redirect too. Answers JSON: { ok: true, path, bytes, content_type, url } (url the final one, after redirects), or { ok: false, url, refused } when it was refused, { ok: false, url, error } when it failed; nothing is left at the path when it does not save.`,
234
+ description: `Download one file from a public URL into this run's folder, where it stays (the run's Files show and play it): use it for a generated image, audio or video a service answered with a link that expires. path is where to save it, relative to the run's folder; a bare name (cat.png) goes under ${MEDIA_DIR}/. A path that already holds a file is refused, never overwritten. The file must be a type its bytes show: an image (png, jpeg, gif, webp), audio (mp3, wav, ogg, m4a) or video (mp4, webm), and the path must have an extension of that type (cat.png, not cat or cat.bin); any other type (a page, a PDF, text) is saved only to a path whose extension names the type the host declares. At most ${SAVE_MAX_BYTES / (1024 * 1024)} MiB and ${SAVE_TIMEOUT_MS / 60_000} minutes. A private or local address, a port other than 80 or 443, or a scheme other than http(s) is refused, at every redirect too. Answers JSON: { ok: true, path, bytes, content_type, duration_s?, url } (url the final one, after redirects; duration_s an audio or video file's length in seconds, when its bytes give it: mp3, wav, mp4, m4a), or { ok: false, url, refused } when it was refused, { ok: false, url, error } when it failed; nothing is left at the path when it does not save.`,
220
235
  parameters: {
221
236
  type: "object",
222
237
  additionalProperties: false,
@@ -222,7 +222,7 @@ export async function archilExec(disk, job) {
222
222
  };
223
223
  }
224
224
  case "link": throw new WorkspaceError("ESCAPE", `${show(job.cwd)} has a symbolic link on the way, and a workspace follows none`, { path });
225
- case "nocwd": throw new WorkspaceError("NOT_FOUND", `${show(job.cwd)} is not there`, { path });
225
+ case "nocwd": throw new WorkspaceError("NOT_FOUND", `${show(job.cwd)} is not there (exec; Archil: no folder ${job.root}/${path} on disk ${disk.id})`, { path });
226
226
  case "notdir": throw new WorkspaceError("REFUSED", `${show(job.cwd)} is not a directory`, { path });
227
227
  case "noprog": throw new WorkspaceError("NOT_FOUND", `${JSON.stringify(job.argv[0])} is not a program here (PATH ${JSON.stringify(job.env.PATH ?? "")})`, { path });
228
228
  case "noroot": throw new WorkspaceError("UNAVAILABLE", `the workspace's folder ${job.root} or its spill folder was not mounted`, { path });
@@ -444,7 +444,7 @@ class ArchilWorkspace {
444
444
  if (entries.size === 0 && rel !== "") {
445
445
  const kind = await this.#kind(rel).catch((error) => { throw failed(error, rel, "list"); });
446
446
  if (kind === undefined)
447
- throw new WorkspaceError("NOT_FOUND", `${show(rel)} is not there`, { path: rel });
447
+ throw new WorkspaceError("NOT_FOUND", `${show(rel)} is not there (list; Archil: nothing under ${prefix} on disk ${this.#disk.id})`, { path: rel });
448
448
  if (kind === "file")
449
449
  throw new WorkspaceError("REFUSED", `${show(rel)} is not a directory`, { path: rel });
450
450
  }
@@ -208,6 +208,8 @@ export interface ClaimComputer {
208
208
  * stopped (compute-cost.ts): run before the run's end or park is written (the spec's beforeRelease), so the end's
209
209
  * cost holds it. Absent where nothing is metered. */
210
210
  settle?(): Promise<void>;
211
+ /** Strict durable folder sync for project checkpoints; distinct from metering settlement. */
212
+ syncProject?(signal?: AbortSignal): Promise<void>;
211
213
  release(why?: ViewEnd): Promise<void>;
212
214
  /** The claim's release at the run's park, for `cause`: a computer it `keeps` is kept for KEEP_MS (computer-kept.ts),
213
215
  * its live view closed with the park's cause and the keep's time (ParkedEnd) and its hold ended, but the machine left
@@ -43,6 +43,7 @@ import { startRecording } from "../computer-record.js";
43
43
  import { computerOfPlace } from "../computer-setting.js";
44
44
  import { KEY_TABLE, providerOptions, settingOptions } from "../computer-keys.js";
45
45
  import { LOST_RECREATES, lostEnd, lostInCallWords, lostRecreatedWords } from "../computer-lost.js";
46
+ import { missingNeeds, needsNoSandboxWords, needsWords } from "../computer-needs.js";
46
47
  import { inToolCall, stopRun } from "../paid-calls.js";
47
48
  import { getSealedKey } from "../server-keys.js";
48
49
  import { agentComputerOf, forgetAgentComputer, holdAgentComputer, keepAgentComputer, liveHolderOf, reconcileAgentComputer, serverIdOf } from "./agent-computer.js";
@@ -872,6 +873,13 @@ store, deps) {
872
873
  },
873
874
  };
874
875
  const setting = await settingOf(launch, store);
876
+ // Programs it needs (computer.needs) are checked in a sandbox's box alone: a setting that needs them and is any other
877
+ // kind is refused before anything is rented, never run without them.
878
+ const needs = setting?.needs;
879
+ if (needs?.length && setting?.kind !== "sandbox") {
880
+ const label = setting?.provider ? kinds.PROVIDERS.find((one) => one.id === setting.provider)?.label ?? setting.provider : undefined;
881
+ throw unavailable(needsNoSandboxWords(needs, setting?.kind === "none" || !setting ? "none" : `a ${setting.kind}${label ? ` on ${label}` : ""}`));
882
+ }
875
883
  const resolved = await resolveComputer(setting, deps.mode, kinds, side);
876
884
  if ("refused" in resolved)
877
885
  throw unavailable(resolved.refused);
@@ -900,6 +908,19 @@ store, deps) {
900
908
  throw error;
901
909
  }
902
910
  const computer = started.computer;
911
+ // What the agent needs its sandbox to have (computer.needs): asked of the box it started, before anything of the run
912
+ // reaches a model. A box that lacks one, or that could not be asked, is let go and the run ends in words: never a run on
913
+ // a box without what its work needs.
914
+ if (needs?.length) {
915
+ // A sandbox setting whose start gave no sandbox is no box to check: refused as one that could not be asked.
916
+ const answer = computer?.kind === "sandbox" ? await missingNeeds(computer.computer.client, needs, deps.signal) : { unchecked: "its start gave no sandbox" };
917
+ if ("unchecked" in answer || answer.missing.length > 0) {
918
+ await started.release().catch(() => undefined);
919
+ await meter?.stopAll().catch(() => undefined);
920
+ await revoke().catch(() => undefined);
921
+ throw unavailable(needsWords(answer, needs, kinds.PROVIDERS.find((one) => one.id === resolved.provider)));
922
+ }
923
+ }
903
924
  // A desktop's or a phone's: its hold, parking the run's ports while a person holds it, and its live view, proxy-only (no
904
925
  // vendor's URL reaches a person), opened under this claim. A fenced open is a lost claim. The release ends the hold.
905
926
  let endHold = () => { };
@@ -968,6 +989,28 @@ store, deps) {
968
989
  ...(keeps ? { keeps: keeps.kind } : {}),
969
990
  ...(meter ? { settle: () => meter.stopAll() } : {}),
970
991
  release,
992
+ async syncProject(signal) {
993
+ const cancellation = signal && deps.signal ? AbortSignal.any([signal, deps.signal]) : signal ?? deps.signal;
994
+ cancellation?.throwIfAborted();
995
+ if (started.sync) {
996
+ if (!(await started.sync()).ok)
997
+ throw new Error("The project folder could not be durably synchronized.");
998
+ }
999
+ else if (resolved.folder === "bind") {
1000
+ // A bind is already this Workspace's filesystem, so there is no remote folder delta to pull. File tools
1001
+ // fsync their own writes, but arbitrary shell edits need this final syncfs after dispatch has settled.
1002
+ // Use the supplied host Workspace, never the lost-aware computer client (which could recreate a machine).
1003
+ const flushed = await deps.workspace.exec(["/usr/bin/sync", "-f", "."], {
1004
+ env: { PATH: "/usr/bin:/bin", LANG: "C", LC_ALL: "C" }, timeoutMs: 30_000, maxOutput: 1024,
1005
+ ...(cancellation ? { signal: cancellation } : {}),
1006
+ });
1007
+ if (flushed.code !== 0 || flushed.signal || flushed.timedOut || flushed.truncated)
1008
+ throw new Error("The bound project folder could not be durably synchronized.");
1009
+ }
1010
+ else if (runComputer && "check" in runComputer && runComputer.check)
1011
+ throw new Error("This mounted project has no verified synchronization capability.");
1012
+ cancellation?.throwIfAborted();
1013
+ },
971
1014
  async park(cause) {
972
1015
  if (!keeps || !settings || released) {
973
1016
  await release();
@@ -20,6 +20,12 @@ export declare const agentLearningFolder: (dataDir: string, agentId: string) =>
20
20
  export declare const homeKey: (agentId: string) => string;
21
21
  /** Agent `agentId`'s home, the root of its home Workspace: `<data>/disk/agents/<agent>/home`. */
22
22
  export declare const agentHomeFolder: (dataDir: string, agentId: string) => string;
23
+ /** Immutable source bundles, private to the server and outside every run's tool root. */
24
+ export declare const sourceSnapshotsKey: (agentId: string) => string;
25
+ export declare const sourceSnapshotsFolder: (dataDir: string, agentId: string) => string;
26
+ /** A run's source placement receipt, beside work/ so its tools cannot rewrite the admission proof. */
27
+ export declare const sourceRunControlKey: (agentId: string, runId: string) => string;
28
+ export declare const sourceRunControlFolder: (dataDir: string, agentId: string, runId: string) => string;
23
29
  /** Run `runId`'s scratch folder on this machine: `<data>/scratch/<agent>/<run>`. Outside the disk, so no Workspace
24
30
  * holds it, in either mode. */
25
31
  export declare const scratchFolder: (dataDir: string, agentId: string, runId: string) => string;
@@ -55,6 +55,12 @@ export const agentLearningFolder = (dataDir, agentId) => join(dataDir, DISK_DIR,
55
55
  export const homeKey = (agentId) => `agents/${agentDirName(agentId)}/home`;
56
56
  /** Agent `agentId`'s home, the root of its home Workspace: `<data>/disk/agents/<agent>/home`. */
57
57
  export const agentHomeFolder = (dataDir, agentId) => join(dataDir, DISK_DIR, homeKey(agentId));
58
+ /** Immutable source bundles, private to the server and outside every run's tool root. */
59
+ export const sourceSnapshotsKey = (agentId) => `agents/${agentDirName(agentId)}/source-snapshots`;
60
+ export const sourceSnapshotsFolder = (dataDir, agentId) => join(dataDir, DISK_DIR, sourceSnapshotsKey(agentId));
61
+ /** A run's source placement receipt, beside work/ so its tools cannot rewrite the admission proof. */
62
+ export const sourceRunControlKey = (agentId, runId) => `agents/${agentDirName(agentId)}/runs/${checkId(runId, "run")}/source-control`;
63
+ export const sourceRunControlFolder = (dataDir, agentId, runId) => join(dataDir, DISK_DIR, sourceRunControlKey(agentId, runId));
58
64
  /** Run `runId`'s scratch folder on this machine: `<data>/scratch/<agent>/<run>`. Outside the disk, so no Workspace
59
65
  * holds it, in either mode. */
60
66
  export const scratchFolder = (dataDir, agentId, runId) => join(dataDir, "scratch", agentDirName(agentId), checkId(runId, "run"));
@@ -23,6 +23,7 @@ export type ComputerSetting = {
23
23
  readonly surface?: "code" | "tools";
24
24
  readonly exec?: boolean;
25
25
  readonly record?: boolean;
26
+ readonly needs?: readonly string[];
26
27
  };
27
28
  /** Whether a computer (or its setting) takes its agent's programs away: `exec: false`. Only a desktop or a phone takes
28
29
  * `exec` (computer-setting.ts refuses it on any other kind at save), so a computer without programs is one of those. */
@@ -33,16 +33,29 @@ export async function layOwnSkills(work, skills, options = {}) {
33
33
  files.push([brought[0], kind.text]);
34
34
  if (!files.length)
35
35
  return brought;
36
- const there = await work.list(RUN_SKILLS_DIR).then((entries) => new Set(entries.map((entry) => entry.name)), (error) => {
37
- if (error instanceof WorkspaceError && error.code === "NOT_FOUND")
38
- return new Set();
39
- throw error;
40
- });
41
- const missing = files.filter(([path]) => !there.has(relativeSegments(path)[0]));
42
- if (!missing.length)
43
- return brought;
44
- await work.mkdir(RUN_SKILLS_DIR);
45
- for (const [path, text] of missing)
46
- await work.write(`${RUN_SKILLS_DIR}/${path}`, text);
36
+ try {
37
+ // What is there is asked with stat, which answers a fresh folder's missing .agents/skills/ with undefined: no error
38
+ // is read as "not there", so no check of an error's class decides it (a run's own process gets its errors over its
39
+ // channel, where beta.50 lost WorkspaceError's class and failed every new run that had a skill).
40
+ const there = (await work.stat(RUN_SKILLS_DIR)) === undefined ? new Set() : new Set((await work.list(RUN_SKILLS_DIR)).map((entry) => entry.name));
41
+ const missing = files.filter(([path]) => !there.has(relativeSegments(path)[0]));
42
+ if (!missing.length)
43
+ return brought;
44
+ await work.mkdir(RUN_SKILLS_DIR);
45
+ for (const [path, text] of missing)
46
+ await work.write(`${RUN_SKILLS_DIR}/${path}`, text);
47
+ }
48
+ catch (error) {
49
+ throw laidFailed(error);
50
+ }
47
51
  return brought;
48
52
  }
53
+ /** A lay's failure, saying it was the lay of the run's skills: a WorkspaceError keeps its code, its path and its words
54
+ * (the backend's, an Archil key and Archil's own included) after that. */
55
+ function laidFailed(error) {
56
+ const code = error?.code;
57
+ if (!(error instanceof Error) || error.name !== "WorkspaceError" || typeof code !== "string")
58
+ return error;
59
+ const path = error.path;
60
+ return new WorkspaceError(code, `laying the run's skills in ${RUN_SKILLS_DIR}/: ${error.message}`, { ...(typeof path === "string" ? { path } : {}), cause: error });
61
+ }
@@ -167,6 +167,8 @@ export type RunTools = {
167
167
  /** The run's end, before the computer is let go: its background processes ended (TERM, then KILL 3 s later; none with
168
168
  * no computer), then bash's full outputs and TMPDIR swept. */
169
169
  end(): Promise<void>;
170
+ /** Strict checkpoint stop: cleanup errors or any still-running tracked process refuse publication. */
171
+ settleProject(): Promise<readonly string[]>;
170
172
  };
171
173
  /**
172
174
  * A run's tools on `workspace`, attached to `computer` when its kind has files and exec and its provider mounts the
@@ -180,6 +180,14 @@ export async function runTools(workspace, computer, options) {
180
180
  kindTools,
181
181
  ...(run.computer ? { computer: run.computer } : {}),
182
182
  hostTools: (names, results) => bindTools(run, registry, names, results ? { results } : {}),
183
+ async settleProject() {
184
+ const before = await run.hands.processes?.list() ?? [];
185
+ await endBackground(run.hands);
186
+ if ((await run.hands.processes?.list() ?? []).some(process => process.running))
187
+ throw new Error("Project processes have not settled.");
188
+ await run.sweep();
189
+ return before.filter(process => process.argv[3] === "agentrun-background" && /^[1-9][0-9]*$/.test(process.argv[4] ?? "")).map(process => `background/${process.argv[4]}/output.log`);
190
+ },
183
191
  async end() {
184
192
  await endBackground(run.hands);
185
193
  await run.sweep();
@@ -38,9 +38,9 @@ export type HeldFolder = {
38
38
  };
39
39
  /**
40
40
  * The stored folder pushed into the computer's empty /workspace through `client` (the computer's own, under no sync),
41
- * one streaming tar, then the computer's listing read as the manifest: the sync the claim holds from then on (the
42
- * caller sets HeldFolder.folder to it), at the claim's start and for a new sandbox in place of a lost one, whose fresh
43
- * mtimes the old manifest would read as every file changed. The links an exec made on the disk (linkObjects), now links
41
+ * one streaming tar, each file at PUSHED_MTIME, then the computer's listing read as the manifest: the sync the claim
42
+ * holds from then on (the caller sets HeldFolder.folder to it), at the claim's start and for a new sandbox in place of a
43
+ * lost one, whose files the old manifest does not describe. The links an exec made on the disk (linkObjects), now links
44
44
  * in the computer, are then removed from the disk. Throws in words where the push, the listing or a remove fails.
45
45
  */
46
46
  export declare function holdSynced(store: FolderStore, client: ComputerClient, stored: StoredFolder, signal?: AbortSignal): Promise<FolderSync>;
@@ -23,7 +23,7 @@
23
23
  // the disk (storedFolder, holdSynced).
24
24
  // - Every write of a claim's goes through fencedStore: once a later claim has taken the run (the run's epoch and runner
25
25
  // say so, held or not), it is refused, never sent.
26
- import { fail, folderPathProblem, FolderSync, ok, pushTar, SYNC_MAX_BYTES, SYNC_MAX_ENTRIES, tarStream, WORKSPACE } from "@parcha/agentrun-computer";
26
+ import { fail, folderPathProblem, FolderSync, ok, PUSHED_MTIME, pushTar, SYNC_MAX_BYTES, SYNC_MAX_ENTRIES, tarStream, WORKSPACE } from "@parcha/agentrun-computer";
27
27
  /** How many files a push reads ahead of the one the tar is writing. */
28
28
  const AHEAD = 4;
29
29
  const FILE_MODE = 0o644;
@@ -66,7 +66,8 @@ const quiet = (promise) => {
66
66
  return promise;
67
67
  };
68
68
  /** The folder's entries as tar entries, by path (a directory before what is in it), then its links: each file read
69
- * AHEAD ahead of the one written, so what is held is those few, never the folder. */
69
+ * AHEAD ahead of the one written, so what is held is those few, never the folder; each file at PUSHED_MTIME, which
70
+ * the baseline after the push needs. */
70
71
  async function* tarEntries(store, { entries, meta }) {
71
72
  const modeOf = (path, fallback) => (Object.hasOwn(meta.modes, path) ? meta.modes[path] : fallback);
72
73
  const sorted = [...entries].sort(byPath);
@@ -85,16 +86,16 @@ async function* tarEntries(store, { entries, meta }) {
85
86
  }
86
87
  const body = await reads.shift();
87
88
  ahead();
88
- yield { name: entry.path, type: "file", mode: modeOf(entry.path, FILE_MODE), body };
89
+ yield { name: entry.path, type: "file", mode: modeOf(entry.path, FILE_MODE), body, mtime: PUSHED_MTIME };
89
90
  }
90
91
  for (const [path, target] of Object.entries(meta.links))
91
92
  yield { name: path, type: "symlink", mode: 0o777, link: target };
92
93
  }
93
94
  /**
94
95
  * The stored folder pushed into the computer's empty /workspace through `client` (the computer's own, under no sync),
95
- * one streaming tar, then the computer's listing read as the manifest: the sync the claim holds from then on (the
96
- * caller sets HeldFolder.folder to it), at the claim's start and for a new sandbox in place of a lost one, whose fresh
97
- * mtimes the old manifest would read as every file changed. The links an exec made on the disk (linkObjects), now links
96
+ * one streaming tar, each file at PUSHED_MTIME, then the computer's listing read as the manifest: the sync the claim
97
+ * holds from then on (the caller sets HeldFolder.folder to it), at the claim's start and for a new sandbox in place of a
98
+ * lost one, whose files the old manifest does not describe. The links an exec made on the disk (linkObjects), now links
98
99
  * in the computer, are then removed from the disk. Throws in words where the push, the listing or a remove fails.
99
100
  */
100
101
  export async function holdSynced(store, client, stored, signal) {
@@ -39,7 +39,7 @@
39
39
  # here. Any other variable named like a key (a KEY, TOKEN, SECRET, PASSWORD, PASSWD, PASS, PAT, CREDENTIAL, CREDENTIALS or
40
40
  # DSN segment, or a last PWD after another) stays in the server's environment, as this list does not take it, and in no
41
41
  # run's: name it here to keep it from the server's too.
42
- SECRETS='AGENTRUN_TOKEN AGENTRUN_TOKENS AGENTRUN_API_KEY AGENTRUN_STORE_URL AGENT_MODEL_API_KEY OPENAI_API_KEY ANTHROPIC_API_KEY BROWSERBASE_API_KEY BROWSERBASE_PROJECT_ID KERNEL_API_KEY OPENROUTER_API_KEY PARTICLE_API_KEY TYPESAFE_API_KEY PARALLEL_API_KEY MONID_API_KEY CURSOR_API_KEY AGENTRUN_SEAL_KEY ARCHIL_API_KEY E2B_API_KEY ORGO_API_KEY PHONE_HARNESS_API_KEY AGENT37_API_KEY AGENT37_SSH_KEY DAYTONA_API_KEY BOXD_API_KEY MORPH_API_KEY SMOLCLOUD_API_KEY CLOUDFLARE_RELAY_TOKEN FLY_API_TOKEN MODAL_TOKEN_ID MODAL_TOKEN_SECRET ANTHROPIC_AUTH_TOKEN ANTHROPIC_OAUTH_TOKEN AI_GATEWAY_API_KEY ANT_LING_API_KEY AWS_ACCESS_KEY_ID AWS_BEARER_TOKEN_BEDROCK AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AZURE_OPENAI_API_KEY BASETEN_API_KEY CEREBRAS_API_KEY CLOUDFLARE_API_KEY COPILOT_GITHUB_TOKEN DEEPSEEK_API_KEY FIREWORKS_API_KEY GEMINI_API_KEY GOOGLE_CLOUD_API_KEY GROQ_API_KEY HF_TOKEN KIMI_API_KEY META_API_KEY MINIMAX_API_KEY MINIMAX_CN_API_KEY MISTRAL_API_KEY MOONSHOT_API_KEY NVIDIA_API_KEY OPENCODE_API_KEY QWEN_TOKEN_PLAN_API_KEY QWEN_TOKEN_PLAN_CN_API_KEY RADIUS_API_KEY TOGETHER_API_KEY XAI_API_KEY XIAOMI_API_KEY XIAOMI_TOKEN_PLAN_AMS_API_KEY XIAOMI_TOKEN_PLAN_CN_API_KEY XIAOMI_TOKEN_PLAN_SGP_API_KEY ZAI_API_KEY ZAI_CODING_CN_API_KEY'
42
+ SECRETS='AGENTRUN_TOKEN AGENTRUN_TOKENS AGENTRUN_API_KEY AGENTRUN_STORE_URL AGENT_MODEL_API_KEY OPENAI_API_KEY ANTHROPIC_API_KEY BROWSERBASE_API_KEY BROWSERBASE_PROJECT_ID KERNEL_API_KEY OPENROUTER_API_KEY PARTICLE_API_KEY TYPESAFE_API_KEY PARALLEL_API_KEY MONID_API_KEY CURSOR_API_KEY AGENTRUN_SEAL_KEY AGENTRUN_LAUNCH_HOOK_SECRET ARCHIL_API_KEY E2B_API_KEY ORGO_API_KEY PHONE_HARNESS_API_KEY AGENT37_API_KEY AGENT37_SSH_KEY DAYTONA_API_KEY BOXD_API_KEY MORPH_API_KEY SMOLCLOUD_API_KEY CLOUDFLARE_RELAY_TOKEN FLY_API_TOKEN MODAL_TOKEN_ID MODAL_TOKEN_SECRET ANTHROPIC_AUTH_TOKEN ANTHROPIC_OAUTH_TOKEN AI_GATEWAY_API_KEY ANT_LING_API_KEY AWS_ACCESS_KEY_ID AWS_BEARER_TOKEN_BEDROCK AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AZURE_OPENAI_API_KEY BASETEN_API_KEY CEREBRAS_API_KEY CLOUDFLARE_API_KEY COPILOT_GITHUB_TOKEN DEEPSEEK_API_KEY FIREWORKS_API_KEY GEMINI_API_KEY GOOGLE_CLOUD_API_KEY GROQ_API_KEY HF_TOKEN KIMI_API_KEY META_API_KEY MINIMAX_API_KEY MINIMAX_CN_API_KEY MISTRAL_API_KEY MOONSHOT_API_KEY NVIDIA_API_KEY OPENCODE_API_KEY QWEN_TOKEN_PLAN_API_KEY QWEN_TOKEN_PLAN_CN_API_KEY RADIUS_API_KEY TOGETHER_API_KEY XAI_API_KEY XIAOMI_API_KEY XIAOMI_TOKEN_PLAN_AMS_API_KEY XIAOMI_TOKEN_PLAN_CN_API_KEY XIAOMI_TOKEN_PLAN_SGP_API_KEY ZAI_API_KEY ZAI_CODING_CN_API_KEY'
43
43
  set -eu
44
44
  # Each secret out of the environment and into an unexported variable of this shell (agentrun_secret_<NAME>).
45
45
  for name in $SECRETS; do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcha/agentrun-serve",
3
- "version": "0.1.0-beta.51",
3
+ "version": "0.1.0-beta.53",
4
4
  "description": "The AgentRun server: the /v2 API and console over one store, with runners that run your agents; the deployable process of the AgentRun platform.",
5
5
  "keywords": [
6
6
  "agentrun",
@@ -62,15 +62,15 @@
62
62
  "@earendil-works/pi-coding-agent": "1.5.2",
63
63
  "@modelcontextprotocol/client": "2.4.0",
64
64
  "@modelcontextprotocol/server": "2.4.0",
65
- "@parcha/agentrun-computer": "0.1.0-beta.51",
66
- "@parcha/agentrun-decisions": "0.1.0-beta.51",
67
- "@parcha/agentrun-dsl": "0.1.0-beta.51",
68
- "@parcha/agentrun-harness-acp": "0.1.0-beta.51",
69
- "@parcha/agentrun-harness-claude": "0.1.0-beta.51",
70
- "@parcha/agentrun-harness-codex": "0.1.0-beta.51",
71
- "@parcha/agentrun-jev": "0.1.0-beta.51",
72
- "@parcha/agentrun-kernel": "0.1.0-beta.51",
73
- "@parcha/pi-browser": "0.1.0-beta.51",
65
+ "@parcha/agentrun-computer": "0.1.0-beta.53",
66
+ "@parcha/agentrun-decisions": "0.1.0-beta.53",
67
+ "@parcha/agentrun-dsl": "0.1.0-beta.53",
68
+ "@parcha/agentrun-harness-acp": "0.1.0-beta.53",
69
+ "@parcha/agentrun-harness-claude": "0.1.0-beta.53",
70
+ "@parcha/agentrun-harness-codex": "0.1.0-beta.53",
71
+ "@parcha/agentrun-jev": "0.1.0-beta.53",
72
+ "@parcha/agentrun-kernel": "0.1.0-beta.53",
73
+ "@parcha/pi-browser": "0.1.0-beta.53",
74
74
  "@secretlint/core": "13.1.0",
75
75
  "@secretlint/profiler": "13.1.0",
76
76
  "@secretlint/secretlint-rule-preset-recommend": "13.1.0",
@@ -359,7 +359,8 @@ A refusal comes back as a tool error holding the server's `error`: `code`, `mess
359
359
  ## 4. Create an agent
360
360
 
361
361
  Look for one first with `agents_list` and inspect the server's templates through `GET /v2/templates` or the
362
- matching Node CLI's `template list`. Offer a suitable template or a custom agent; ask only for missing details
362
+ matching Node CLI's `template list`, then read the one you would apply whole (its instructions and every skill file)
363
+ with `GET /v2/templates/{id}` or `template get`. Offer a suitable template or a custom agent; ask only for missing details
363
364
  about the job, inputs, expected result and required tools. Before applying a template, explain its tool grants
364
365
  and triggers and confirm any permissions not already granted. Use the apply schema from this server's OpenAPI document.
365
366
 
@@ -2,7 +2,8 @@
2
2
 
3
3
  A template package is one folder that makes a working agent: its manifest, its instructions, its skills, its rules and
4
4
  its evals. The server ships the packages in this folder, checks each one whole at its start (a broken one stops the
5
- start), lists them at `GET /v2/templates` and applies one with `POST /v2/templates/{name}/apply`. Nothing in a package
5
+ start), lists them at `GET /v2/templates`, reads one whole (its instructions and every skill file) at
6
+ `GET /v2/templates/{name}` and applies one with `POST /v2/templates/{name}/apply`. Nothing in a package
6
7
  runs at apply: it is read, checked, and made into the same agent and trigger records `POST /v2/agents` and
7
8
  `POST /v2/triggers` make. `agentrun template validate DIR` runs the server's own check on a folder.
8
9
 
@@ -371,6 +372,7 @@ package}`, and a line in the markdown).
371
372
  | `mcp` | `[{source, toolkit, tools, required?, reason?, allow?, pin?}]`: the MCP tools the agent uses, by where they come from, never by the name a server saves them under. `source` is `composio` (a Composio toolkit, saved with the Composio preset), `github` (GitHub's MCP server on the GitHub App; its toolkit is `github`) or `url` (any other MCP server). `toolkit` names the tools' set (Composio's toolkit slug, `github`, or the name a `url` server's owner gives it in Settings → MCP servers), lowercase letters, digits and dashes, at most 32, each toolkit once. Inside the package its tools are `mcp:<toolkit>/<tool>`. `tools` are the ones the agent uses (each one tool by its name, `A-Z a-z 0-9 _ -`; never `*`; a Composio action by its slug, `SLACK_SEND_MESSAGE`), `reason` one line (at most 280 characters) on why, shown on the apply screen, and `allow` those of its tools the package asks the owner to grant (`GET /v2/templates` shows each tool with `asks: allow` or `ask`, for a consent screen). Apply maps each need to the saved MCP server whose recorded source and toolkit are the need's (each saved server records them when it is saved, from what made it: the Composio preset its toolkit, a server on the GitHub App (`auth: github_app`) `github`, any other `url` with the toolkit its owner sets; a server on GitHub's MCP address with a token of its own is `url`); where several are, the apply's `servers` (`{<toolkit>: <server>}`) says which, and an apply without it is `422` naming them: a server is never picked for the owner. When the server's name is not the toolkit, apply rewrites `mcp:<toolkit>/` to `mcp:<server>/` in the instructions, the skills and the tool settings. It grants `mcp:<server>/<tool>` only for each tool the apply's `grants` (the owner's answer) name, beside the other tools, with no permission written: each call follows this server's tool settings (under `approvals: ask` a write asks unless the owner allowed it in Settings → Tools, and a read runs unasked only where the server's Allow reads is on). Neither a package nor an apply sets a permission for a granted tool. A tool the owner leaves out is not the agent's at all, under `approvals: never` too, so no harness offers it and a call of it is refused; the owner can grant it later in the agent's tools. Where no saved server matches, the need is not set up here: apply skips it with a warning (`mcp.<toolkit>`, its `fix` saying how to add one: for Composio, the preset with the toolkit and actions), or, when `required` is true, refuses with `409 agent_not_runnable` and makes nothing. `pin`, optional: `{<tool>: {<argument>: <value>}}`, for tools of the entry, 1 to 8 top-level arguments each, every value a scalar (text, which may be or hold `${parameters.<name>}`, a number, `true`/`false`, or `null` for an argument that must be left out) or a list of 1 to 16 of them, the argument one of the list (`event: [null, COMMENT]`), kept with each value once, null first, then by its JSON text, or `{keys: [...]}`, 1 to 16 key names an object argument may hold, any values (`properties: {keys: ["${parameters.crm_score_property}"]}`; a key that is a list parameter's placeholder alone adds each of its items). Apply writes it, filled, as the tool's `pin` in the agent's `tool_settings` (text that is one placeholder alone takes the parameter's value and type), whatever the tool's permission, and the gate refuses any call not as pinned; a pin the server's own settings (Settings → Tools) set for the tool holds too. A pinned tool takes only the arguments its listing declares (and its pinned ones): any other is refused. A pin whose parameter apply is not given sets the tool to `deny` instead, granted or not, with a `pins.mcp:<server>/<tool>` warning. `GET /v2/templates` shows each need's `source`, `toolkit` and `reason`, and each tool's `pin`, unfilled. |
372
373
  | `tool_policy` | `{bash: read-only}`: a policy on the agent's bash, the one tool that takes one. Apply writes it as `policy` on bash in the agent's `tool_settings` (`definition.tool_settings.bash.policy`), whatever bash's permission, and the tool gate reads each shell call's command before it runs or anyone is asked. Under `read-only` it refuses, in words the model reads, any command that could write, run code or read outside the run's folder: a program outside the read list (git's read subcommands `diff`, `show`, `log`, `blame`, `grep`, `ls-files`, `ls-tree`, `rev-parse`, `cat-file`, `merge-base`, `status`, `shortlog`, `rev-list`, `diff-tree`, `name-rev`, `describe`; `grep`, `egrep`, `fgrep`, `rg`, `sed -n 'N,Mp'`, `cat`, `head`, `tail`, `wc`, `nl`, `ls`, `find` without `-exec` or `-delete`, `sort`, `uniq`, `cut`, `tr`, `diff`, `basename`, `dirname`, `echo`, `true`), a redirection other than `2>/dev/null` and `2>&1`, `$` and backticks, a subshell, `\|\|` or a lone `&`, a pipe into anything but a filter (`head`, `tail`, `sed -n`, `grep`, `wc`, `sort`, `uniq`, `cut`, `tr`, `nl`), an unquoted glob (a glob is quoted, and only in a grep pattern, an `--include=` value or a `find -name` value), a path outside the run's folder, or one on the never-open list (`.env*`, `.ssh/`, `id_rsa*`, `*.pem`, `*.key`, `.npmrc`, `.netrc`, `.git-credentials`, `credentials`), which refuses a command that names such a file but is no fence around the folder: a recursive search reads all it holds, the run's own files and never a key of the server's. `git -C <dir>` is allowed to a directory inside the folder. A line with a `cd` joins its commands with `&&` only. `bash_background` and `bash_input` are refused under it. The check reads the command, never the folder, so a symbolic link in the folder reaches what the computer lets it; and it holds bash alone, so a read-only agent's tools are `read` and `bash` (one that may write can change what git obeys). Approvals `never` lifts none of it. A package with `tools` grants `bash` among them. |
373
374
  | `computer` | `default` (or absent): the agent runs where this server puts a new one. Or a preference list, `[shell, none]`, read like `harness`: apply takes the first entry this server meets now and saves it as the agent's `computer`. `shell` is a computer that gives the agent a shell here: Archil's serverless exec on the runner when Archil is on (Settings → Workspace; `bash` alone, so `bash_background` and the other background tools are not granted), else the Docker sandbox where Docker answers. `none` is no shell, and is always met: the shell tools in `tools` (`bash` and the background tools) are not granted, and neither is `tool_policy`'s bash. A package with no `tools` is given the chosen shell's tools, as a new agent in a box is given the box's. A fallback, or a tool not granted, is said in a `computer` warning on the apply. A list with `shell` alone, where there is none, refuses the apply (`409`, nothing made). A list without `shell` grants no shell tool, so one in `tools` is refused, and so is an entry after `none`, which would never be picked. The choice is made at apply: a server that gains a shell later gives it to an agent applied again. `GET /v2/templates` shows the list as `computer`, and as `computer_here` what an apply here would pick now: the entry, the agent's `computer`, the shell in words, the tools it would not grant, and the warning or refusal. |
375
+ | `needs` | A list of 1 to 32 program names its agent's sandbox must have on its `PATH` (`[chrome, ffmpeg, ffprobe, hyperframes]` to render video), each once, a name a shell finds (letters, digits, `.`, `_`, `+`, `-`, no path), or a library the agent's code loads, by its pip or npm name (`[python-pptx, pptxgenjs]` to make decks; the [documents image](../README.md#the-boxs-image) has those). Read only beside `computer: [shell]`, so a template that needs them runs in a sandbox or not at all: never a fallback to no computer. It names no image: the image stays the server's, a Docker box's `AGENTRUN_DOCKER_IMAGE` (the [media image](../README.md#the-boxs-image) has those four). Apply writes them onto the sandbox it picks, as the agent's `computer.needs`, which each run checks in its box before its first model request: a box that lacks one ends the run failed, naming it and the image fix, with nothing spent. Where no sandbox answers (Archil's serverless exec is none, and in Mode 2 the Docker box can't mount Archil's workspaces, so none answers there; or no shell at all), apply refuses (`409`, nothing made) in words naming the programs and `AGENTRUN_DOCKER_IMAGE`. `GET /v2/templates` shows it as `needs`, and on `computer_here.computer`. A server older than the release that reads `needs` refuses a package that names it as an unknown field. |
374
376
  | `checkout` | `pull_request` only: apply sets the agent definition's `checkout`, and the server checks out the pull request each run's GitHub event names before its first turn, in `repo/` of the run's folder, detached at the head, with its base and their merge base (refs `pr/head`, `pr/base`, `pr/merge-base`: `git diff pr/merge-base pr/head` reads the change). The server fetches it with its GitHub App's token, narrowed to that one repository and `contents: read` and revoked after the fetch, or anonymously with no App; the agent never holds a token, and nothing of it is left in the folder or the checkout's git config. The run's system prompt says what was checked out, or why nothing was, so the package's instructions can fall back to the GitHub MCP. It is removed when the run's claim ends. With `tool_policy: {bash: read-only}` the agent reads it with git's read subcommands and never fetches itself. |
375
377
  | `parameters` | The setup an owner fills once, at apply. Written exactly as `inputs` are (the same keys, the same rule: required unless `required: false`, a `default` only on one that is not) and compiled by the same code; `GET /v2/templates` shows them as a JSON Schema like `input_schema`, and the console's Apply form is the run form. The one difference is where they are filled: apply takes them in `parameters` (a blank one takes its `default`; they are checked as a run's input is, with the same `422` words under `parameters.<name>`), and puts them where the package writes `${parameters.<name>}`: `display_name`, the body, a trigger's `target.input`, a schedule's `cron` and `timezone`, the `in` values of a github, webhook, composio or feed trigger's `accept` where conditions, a composio trigger's `config` values, a feed trigger's `urls`, a trigger's `enabled`, and an `mcp` entry's `pin` values, nowhere else. Text takes the value as text (a list as its items joined by `, `). A `target.input` value, a composio trigger's `config` value or a pin value that is one placeholder alone takes the value with its type (a list pinned is a one-of); in `target.input` one given no value is dropped, so the input schema sees the field absent. A trigger's `enabled` takes only one placeholder alone, naming a boolean parameter with a default: the trigger is made on or off by its value. A feed trigger's `urls` that are one placeholder alone take an array-of-strings parameter whole. A parameter a where, a composio `config` or a feed's `urls` take is required or has a default, so none fills empty; one a schedule uses has a default, which the package's own schedule is checked with, and apply checks every trigger with the values given before it makes anything (`422` under `triggers.<i>`). |
376
378
  | `inputs` | By name: each run's typed input, which apply compiles into the agent's `input_schema` (a closed JSON Schema object). Each is `{type: string \| number \| integer \| boolean \| array, required?, title?, description?, examples?, default?, enum?, pattern? and format? (strings), minLength?/maxLength? (strings), minimum?/maximum? (numbers), items? (an array's scalar, with that scalar's keys)}`, nothing else; an input is required unless it says `required: false`, and a `default` is for one that is not. `format` is `uri`, `email`, `hostname`, `date`, `date-time` or `uuid`, which the server checks, or `cron` or `timezone`, which a form reads. A default and each example are checked against their own input. `content` is the run's message: named, it is a string. Every path that starts a run (the API, the CLI, a trigger, the console) checks the input against it and refuses one that does not meet it with `422 input_invalid`, a path per field (`input.country`). The model is sent the input's `content`, then the other fields as one fenced `json` block under the line `Input:`, so the instructions read each field by its name. `GET /v2/templates` shows it as `input_schema`, and the console's run form is drawn from it. A trigger's `target.input` and an eval case's `input` are checked against it too. Absent: a run takes `{content}`, as before. |
@@ -401,7 +403,8 @@ The ref follows the last `@`, so a path with an `@` in it (`packages/@acme/kyb`)
401
403
  file, more than 8 MiB of files, or an archive over 128 MiB is refused (`422`), as is a package that does not check.
402
404
  3. A dry run answers the package whole (its instructions and every skill file) and stores nothing. Otherwise it is
403
405
  stored under its id, `github:<owner>/<repo>[/<path>]`, listed by `GET /v2/templates` with `bundled: false`, its
404
- `source`, `sha` and `publisher`, and applied as below with that id URL-encoded. Importing the id again replaces it;
406
+ `source`, `sha` and `publisher`, read whole by `GET /v2/templates/{id}` and applied as below, each with that id
407
+ URL-encoded. Importing the id again replaces it;
405
408
  `DELETE /v2/templates/{id}` removes it (a bundled package is `403`). Agents applied from it stay as they are, each with
406
409
  `template: {id, version, sha}`.
407
410