@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
@@ -41,6 +41,9 @@ export declare const MAX_PACKAGE_FILES = 256;
41
41
  /** A file of a package's evals/ (a case's fake MCP server fixture, say), which no agent is given: its own bound, apart
42
42
  * from the agent's files' limits above. The answer's schema is given to the agent, so under evals/ too it keeps those. */
43
43
  export declare const MAX_EVAL_FILE_BYTES: number;
44
+ /** The `name` agent.md's front matter gives (`text`), as text, or undefined: what an upload's folder is named before
45
+ * readPackage checks it whole (the name read as readPackage's front matter reads it). */
46
+ export declare function manifestName(text: string): string | undefined;
44
47
  /** An MCP server a package uses, by where it comes from (`source`, `toolkit`), never by the name an owner saves it under:
45
48
  * inside the package its tools are `mcp:<toolkit>/<tool>`. `tools`, those the agent uses and the package asks the owner to
46
49
  * grant (a consent screen shows each, with `reason`), and `allow`, those of them expected to run without asking (reads);
@@ -79,7 +82,7 @@ export type McpServed = McpNeed & {
79
82
  export declare const fieldsOf: (schema: Json) => Record<string, Json>;
80
83
  /** Where an imported package came from (POST /v2/templates/import): its source as given, ref and all (the ref an upgrade
81
84
  * reads again), the full commit SHA that ref was at when it was read, which is what was imported, and the GitHub account
82
- * that publishes it. */
85
+ * that publishes it. An upload's source is its id, its sha the package's sha256, its publisher empty. */
83
86
  export type PackageOrigin = {
84
87
  source: string;
85
88
  sha: string;
@@ -87,7 +90,8 @@ export type PackageOrigin = {
87
90
  };
88
91
  export type Package = {
89
92
  /** Its identity here, the one apply and delete take: a bundled package's name (`kyb`); an imported one's source without
90
- * its ref (`github:<owner>/<repo>[/<path>]`), so the bundled kyb and an imported kyb are two packages. */
93
+ * its ref (`github:<owner>/<repo>[/<path>]`), so the bundled kyb and an imported kyb are two packages; an upload's
94
+ * `upload:<name>`. */
91
95
  id: string;
92
96
  /** Null for a package this server ships. */
93
97
  origin: PackageOrigin | null;
@@ -123,6 +127,10 @@ export type Package = {
123
127
  /** The computers it prefers, in order (`[shell, none]`): apply takes the first this server meets now (pickComputer)
124
128
  * and writes it as the agent's computer. Absent (or `default` in the manifest): where this server puts a new agent. */
125
129
  computer?: ComputerEntry[];
130
+ /** The programs its sandbox must have on its PATH, or libraries its code loads (`needs`, beside `computer: [shell]` alone): apply writes them onto
131
+ * the sandbox it picks as the agent's `computer.needs`, which each run checks in its box before any model request
132
+ * (computer-needs.ts); it names no image, which stays the server's (AGENTRUN_DOCKER_IMAGE). */
133
+ needs?: string[];
126
134
  /** A policy by tool (bash only: `read-only`, bash-read-only.ts), which apply writes as the tool's `policy` in the
127
135
  * agent's tool settings, so the gate holds its runs to it whatever the tool's permission. */
128
136
  toolPolicy?: {
@@ -140,6 +148,7 @@ export type Package = {
140
148
  /** Each run's limit: its spend cap (the agent's max_cost_usd). */
141
149
  budget?: {
142
150
  per_run_usd: number;
151
+ max_requests?: number;
143
152
  };
144
153
  /** The agent's `learning`, as a definition takes it: true, false, or the loop's settings (agree_on, each path a required
145
154
  * field of the output schema). */
@@ -157,6 +166,8 @@ export type Package = {
157
166
  instructions: string;
158
167
  /** Skill files by path under the agent's skills folder (`review/SKILL.md`), each rule beside each SKILL.md. */
159
168
  skills: Record<string, string>;
169
+ /** The names of its rules/ files (each one in `skills` beside every SKILL.md), so an export writes them as rules/ again. */
170
+ rules?: string[];
160
171
  evals: string[];
161
172
  };
162
173
  /** A package that does not check: every problem, each naming its file. */
@@ -274,6 +285,7 @@ export declare function packageView(p: Package): {
274
285
  bash: BashPolicy;
275
286
  } | null;
276
287
  computer: ("none" | "shell")[] | null;
288
+ needs: string[] | null;
277
289
  checkout: "pull_request" | null;
278
290
  mcp: {
279
291
  source: "url" | "github" | "composio";
@@ -292,6 +304,7 @@ export declare function packageView(p: Package): {
292
304
  secrets: string[];
293
305
  budget: {
294
306
  per_run_usd: number;
307
+ max_requests?: number;
295
308
  } | null;
296
309
  learning: LearningSetting;
297
310
  approvals_default: "ask" | "never";
@@ -347,6 +360,7 @@ export declare function packageDetail(p: Package): {
347
360
  bash: BashPolicy;
348
361
  } | null;
349
362
  computer: ("none" | "shell")[] | null;
363
+ needs: string[] | null;
350
364
  checkout: "pull_request" | null;
351
365
  mcp: {
352
366
  source: "url" | "github" | "composio";
@@ -365,6 +379,7 @@ export declare function packageDetail(p: Package): {
365
379
  secrets: string[];
366
380
  budget: {
367
381
  per_run_usd: number;
382
+ max_requests?: number;
368
383
  } | null;
369
384
  learning: LearningSetting;
370
385
  approvals_default: "ask" | "never";
@@ -387,10 +402,12 @@ export declare class TemplateRegistry {
387
402
  /** Whether an imported package of that id was there to remove. */
388
403
  remove(id: string): boolean;
389
404
  }
390
- /** POST /v2/templates/{name}/apply's body (`{parameters, grants?, servers?, overrides?: {model?, choice?, approvals?}, agent_id?}`), checked
405
+ /** POST /v2/templates/{name}/apply's body (`{parameters, grants?, servers?, overrides?: {model?, choice?, approvals?}, agent_id?, revision?, sha?, dry_run?}`), checked
391
406
  * against the package: the parameters as given (a blank one at its default), the MCP tools the owner allows (each one the
392
407
  * package lists, by its gate name), and the model asked for in place of the package's: one of its own (`model`), or one
393
- * of the package's model choices by id (`choice`), never both. 422 naming every field that is wrong. */
408
+ * of the package's model choices by id (`choice`), never both. `revision` (with agent_id) and `sha` are what the caller
409
+ * read: the agent's current revision and the package's sha, each held to them (412 when another). 422 naming every field
410
+ * that is wrong. */
394
411
  export declare function applyBodyOf(p: Package, body: Json): {
395
412
  parameters: Json;
396
413
  grants: string[];
@@ -399,6 +416,9 @@ export declare function applyBodyOf(p: Package, body: Json): {
399
416
  choice?: ModelChoice;
400
417
  approvals?: Approvals;
401
418
  agentId?: string;
419
+ revision?: string;
420
+ sha?: string;
421
+ dryRun: boolean;
402
422
  };
403
423
  /** The model a package's agent gets here, as `{model?, warning?}`: its `prefer` when this server runs it on `harness`
404
424
  * with a key for its provider, else `refused` (preferUnrunnable): apply makes nothing, never the tier's model in its
@@ -428,6 +448,7 @@ export declare function choiceUnrunnable(env: NodeJS.ProcessEnv, choice: ModelCh
428
448
  export type PickedSetting = {
429
449
  kind: string;
430
450
  provider?: string;
451
+ needs?: string[];
431
452
  };
432
453
  /** The shell this server can give an agent now (server.ts shellHere): the computer setting that gives it, the shell
433
454
  * tools a run there has (tools.ts shellTools), and the shell in words; else, `none`, why it has none. */
@@ -451,13 +472,16 @@ export type ComputerPick = {
451
472
  };
452
473
  /** What to do where a package's computer list has no shell to take: in the apply's refusal and its fallback warning. */
453
474
  export declare const COMPUTER_FIX = "Turn on Archil in Settings \u2192 Workspace, or run AgentRun where Docker answers, then apply again to give it a shell.";
475
+ /** What to do where a package that needs programs (`needs`) has no sandbox to take: a Docker box whose image has them. */
476
+ export declare const NEEDS_FIX = "Run AgentRun where Docker answers, with Archil off in Settings \u2192 Workspace. 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. Then apply again.";
454
477
  /** The first entry of a package's computer list (`[shell, none]`) this server meets now, given the shell it has
455
478
  * (`here`): shell, where it has one; none, always (kind none, and no shell tool: a run on the runner in Mode 2 has bash,
456
479
  * so a shell tool is dropped rather than left to it). Undefined for a package with no list (it runs where a new agent
457
480
  * does); `refused`, in words, when no entry is met. The rule is the package's preference alone: nothing here knows a
458
481
  * template. */
459
- export declare function pickComputer(p: Pick<Package, "name" | "computer" | "tools">, here: ShellHere): ComputerPick | {
482
+ export declare function pickComputer(p: Pick<Package, "name" | "computer" | "tools" | "needs">, here: ShellHere): ComputerPick | {
460
483
  refused: string;
484
+ fix?: string;
461
485
  } | undefined;
462
486
  /** The model of each tier a package's subagents run on here (the definition's model_tiers), as `{modelTiers?, warning?}`:
463
487
  * a tier's model the package names (`model.fast`, `model.strong`) when this server runs it on `harness` with a key for its
package/dist/templates.js CHANGED
@@ -9,6 +9,7 @@ import { basename, join } from "node:path";
9
9
  import { fileURLToPath } from "node:url";
10
10
  import { parseDocument } from "yaml";
11
11
  import { invalid } from "./errors.js";
12
+ import { DOCKER_IMAGE_FIX, needsIssues } from "./computer-needs.js";
12
13
  // Where a package's MCP tools come from (a Composio toolkit, GitHub's MCP server, or any other server by its address): a
13
14
  // saved MCP server records one too, and apply maps each need to a server whose record matches.
14
15
  import { MCP_SOURCES } from "./mcp-sources.js";
@@ -41,7 +42,7 @@ export const GRADER_TYPES = ["llm", "regex", "tool_used", "file_exists", "mailbo
41
42
  /** The entries of a package's `computer` preference list: `shell`, a computer that gives the agent a shell here (bash);
42
43
  * `none`, no shell, the file tools alone. Apply takes the first this server meets now (pickComputer). */
43
44
  export const COMPUTER_ENTRIES = ["shell", "none"];
44
- const FIELDS = ["name", "display_name", "version", "description", "license", "author", "repository", "category", "tags", "harness", "model", "effort", "tools", "mcp", "tool_policy", "computer", "checkout", "parameters", "inputs", "secrets", "budget", "learning", "approvals", "triggers", "output"];
45
+ const FIELDS = ["name", "display_name", "version", "description", "license", "author", "repository", "category", "tags", "harness", "model", "effort", "tools", "mcp", "tool_policy", "computer", "needs", "checkout", "parameters", "inputs", "secrets", "budget", "learning", "approvals", "triggers", "output"];
45
46
  /** What a package is for, shown on a marketplace page and the console's list: display only, never applied. */
46
47
  export const CATEGORIES = ["engineering", "security", "sales", "marketing", "research", "finance", "operations", "compliance", "personal"];
47
48
  const TAG = /^[a-z0-9-]{1,32}$/;
@@ -85,6 +86,23 @@ const PLACEHOLDER = /\$\{parameters\.([^}]*)\}/g;
85
86
  /** Text that is one placeholder alone: it takes the parameter's value with its type (a pin's, a trigger's input's). */
86
87
  const WHOLE = /^\$\{parameters\.([^}]*)\}$/;
87
88
  const FRONT = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;
89
+ /** The `name` agent.md's front matter gives (`text`), as text, or undefined: what an upload's folder is named before
90
+ * readPackage checks it whole (the name read as readPackage's front matter reads it). */
91
+ export function manifestName(text) {
92
+ const match = FRONT.exec(text);
93
+ if (!match)
94
+ return undefined;
95
+ const doc = parseDocument(match[1], { schema: "core", merge: false, uniqueKeys: true, strict: true });
96
+ if (doc.errors.length)
97
+ return undefined;
98
+ try {
99
+ const data = doc.toJS({ maxAliasCount: 0 });
100
+ return isObject(data) && typeof data.name === "string" ? data.name : undefined;
101
+ }
102
+ catch {
103
+ return undefined;
104
+ }
105
+ }
88
106
  /** A package's model choices at most, a choice label's length, and a warning's or a note's. */
89
107
  const MAX_CHOICES = 3;
90
108
  const MAX_CHOICE_LABEL = 40;
@@ -681,6 +699,18 @@ export function readPackage(from, { evalFixtures = true } = {}) {
681
699
  bad(MANIFEST, `computer: [none] gives no shell, so ${shellOnly.join(", ")} would never be granted: add shell to computer, or take ${shellOnly.length === 1 ? "it" : "them"} out of tools`);
682
700
  }
683
701
  }
702
+ // The programs its sandbox must have, checked as a sandbox's computer.needs is: only beside [shell] alone, so a package
703
+ // that needs them is a sandbox's or nothing, never a fallback to no computer.
704
+ let needs;
705
+ if (f.needs !== undefined) {
706
+ const issues = needsIssues(f.needs, "needs");
707
+ for (const issue of issues)
708
+ bad(MANIFEST, issue.message);
709
+ if (computer?.length !== 1 || computer[0] !== "shell")
710
+ bad(MANIFEST, "needs: the programs a sandbox must have, so computer is [shell]: a template that needs them never falls back to no computer, nor runs where a new agent does");
711
+ else if (!issues.length)
712
+ needs = [...f.needs];
713
+ }
684
714
  // The server's checkout before each run's first turn: the pull request the run's GitHub event names, at its head.
685
715
  if (f.checkout !== undefined && f.checkout !== "pull_request")
686
716
  bad(MANIFEST, "checkout is pull_request: the server checks out the pull request the run's GitHub event names, at its head, in repo/ before the first turn");
@@ -691,10 +721,12 @@ export function readPackage(from, { evalFixtures = true } = {}) {
691
721
  const secrets = list(f.secrets, "secrets", (secret) => /^[A-Z][A-Z0-9_]{0,127}$/.test(secret));
692
722
  for (const secret of secrets.filter((name) => !PACKAGE_SECRETS.includes(name)))
693
723
  bad(MANIFEST, `secrets names ${secret}, a key this server cannot hold: a package needs the keys Settings saves and a run is handed (${PACKAGE_SECRETS.join(", ")})`);
694
- // Each run's limit: its spend cap (per_run_usd, the agent's max_cost_usd), required once a budget is given.
724
+ // Each run's limits: its spend cap (per_run_usd, the agent's max_cost_usd), required once a budget is given, and the most
725
+ // requests on free models it makes (max_requests, the agent's max_requests), which a dollar cap cannot bound.
695
726
  const perRun = (value) => typeof value === "number" && Number.isFinite(value) && value > 0;
696
- if (f.budget !== undefined && !(isObject(f.budget) && !unknownFields(f.budget, ["per_run_usd"]).length && perRun(f.budget.per_run_usd)))
697
- bad(MANIFEST, "budget is {per_run_usd: a number above 0}");
727
+ const requests = (value) => value === undefined || (typeof value === "number" && Number.isSafeInteger(value) && value >= 1);
728
+ if (f.budget !== undefined && !(isObject(f.budget) && !unknownFields(f.budget, ["per_run_usd", "max_requests"]).length && perRun(f.budget.per_run_usd) && requests(f.budget.max_requests)))
729
+ bad(MANIFEST, "budget is {per_run_usd: a number above 0, max_requests: a whole number of free-model requests above 0, when given}");
698
730
  const learningIssue = f.learning === undefined ? undefined : learningSettingIssue(f.learning, "learning");
699
731
  if (learningIssue)
700
732
  bad(MANIFEST, learningIssue);
@@ -870,11 +902,13 @@ export function readPackage(from, { evalFixtures = true } = {}) {
870
902
  const rules = kind("rules") === "dir" ? src.entries("rules") : [];
871
903
  if (rules.length && !skillDirs.length)
872
904
  bad("rules/", "rules ship beside each skill's SKILL.md, and the package has no skill");
905
+ const ruleNames = [];
873
906
  for (const entry of rules) {
874
907
  if (!entry.isFile() || !entry.name.endsWith(".md")) {
875
908
  bad(`rules/${entry.name}`, "rules/ holds only .md files");
876
909
  continue;
877
910
  }
911
+ ruleNames.push(entry.name);
878
912
  for (const skill of skillDirs.filter((d) => d.isDirectory())) {
879
913
  const path = `${skill.name}/${entry.name}`;
880
914
  if (Object.hasOwn(skills, path))
@@ -940,8 +974,8 @@ export function readPackage(from, { evalFixtures = true } = {}) {
940
974
  ...(typeof f.license === "string" ? { license: f.license } : {}), ...(isObject(f.author) ? { author: f.author } : {}), ...(typeof f.repository === "string" ? { repository: f.repository } : {}),
941
975
  ...(typeof f.category === "string" ? { category: f.category } : {}), tags,
942
976
  ...(harness ? { harness } : {}), ...(isObject(f.model) ? { model: { ...f.model, ...(choices ? { choices } : {}) } } : {}), ...(typeof f.effort === "string" ? { effort: f.effort } : {}),
943
- ...(tools ? { tools } : {}), mcp, ...(computer ? { computer } : {}), ...(toolPolicy ? { toolPolicy } : {}), ...(f.checkout === "pull_request" ? { checkout: "pull_request" } : {}), parameters, ...(inputSchema ? { inputSchema } : {}), secrets, ...(isObject(f.budget) ? { budget: { per_run_usd: f.budget.per_run_usd } } : {}), ...(f.learning !== undefined ? { learning: learningSettingOf(f.learning) } : {}), ...(f.approvals === "ask" || f.approvals === "never" ? { approvals: f.approvals } : {}),
944
- triggers: triggers, ...(isObject(f.output) ? { output: { schema: f.output.schema } } : {}), ...(isObject(outputSchema) ? { outputSchema } : {}), instructions, skills, evals,
977
+ ...(tools ? { tools } : {}), mcp, ...(computer ? { computer } : {}), ...(needs ? { needs } : {}), ...(toolPolicy ? { toolPolicy } : {}), ...(f.checkout === "pull_request" ? { checkout: "pull_request" } : {}), parameters, ...(inputSchema ? { inputSchema } : {}), secrets, ...(isObject(f.budget) ? { budget: { per_run_usd: f.budget.per_run_usd, ...(f.budget.max_requests !== undefined ? { max_requests: f.budget.max_requests } : {}) } } : {}), ...(f.learning !== undefined ? { learning: learningSettingOf(f.learning) } : {}), ...(f.approvals === "ask" || f.approvals === "never" ? { approvals: f.approvals } : {}),
978
+ triggers: triggers, ...(isObject(f.output) ? { output: { schema: f.output.schema } } : {}), ...(isObject(outputSchema) ? { outputSchema } : {}), instructions, skills, ...(ruleNames.length ? { rules: ruleNames.sort() } : {}), evals,
945
979
  };
946
980
  // What an apply makes, made here with each parameter's default, else a sample of its type, and checked as POST
947
981
  // /v2/agents and POST /v2/triggers check their bodies (all but the agent the trigger names, which an apply makes). A
@@ -1014,11 +1048,12 @@ export function readPackages(dir = TEMPLATES_DIR) {
1014
1048
  /** A package as GET /v2/templates lists it: what an apply asks for and makes. */
1015
1049
  export function packageView(p) {
1016
1050
  return {
1017
- id: p.id, bundled: p.origin === null, source: p.origin?.source ?? null, sha: p.origin?.sha ?? null, publisher: p.origin?.publisher ?? null,
1051
+ // An upload has no publisher: its own owner sent it.
1052
+ id: p.id, bundled: p.origin === null, source: p.origin?.source ?? null, sha: p.origin?.sha ?? null, publisher: p.origin?.publisher || null,
1018
1053
  name: p.name, display_name: p.displayName ?? null, version: p.version, description: p.description, license: p.license ?? null, author: p.author ?? null, repository: p.repository ?? null,
1019
1054
  category: p.category ?? null, tags: p.tags,
1020
1055
  output: p.output ? { schema: p.output.schema, json_schema: p.outputSchema ?? null } : null,
1021
- harness: p.harness ?? null, model: modelView(p.model), effort: p.effort ?? null, tools: p.tools ?? null, tool_policy: p.toolPolicy ?? null, computer: p.computer ?? null, checkout: p.checkout ?? null,
1056
+ harness: p.harness ?? null, model: modelView(p.model), effort: p.effort ?? null, tools: p.tools ?? null, tool_policy: p.toolPolicy ?? null, computer: p.computer ?? null, needs: p.needs ?? null, checkout: p.checkout ?? null,
1022
1057
  mcp: p.mcp.map(({ source, toolkit, tools, required, reason, allow, pin }) => ({ source, toolkit, required, reason: reason ?? null, tools: tools.map((name) => ({ name, tool: mcpToolName(toolkit, name), asks: allow.includes(name) ? "allow" : "ask", ...(Object.hasOwn(pin, name) ? { pin: pin[name] } : {}) })) })), parameters: p.parameters, input_schema: p.inputSchema ?? null, secrets: p.secrets,
1023
1058
  budget: p.budget ?? null, learning: p.learning ?? false, approvals_default: p.approvals ?? "ask", triggers: p.triggers, skills: Object.keys(p.skills).filter((path) => /^[^/]+\/SKILL\.md$/.test(path)).map((path) => path.slice(0, -"/SKILL.md".length)), evals: p.evals,
1024
1059
  };
@@ -1063,15 +1098,25 @@ export class TemplateRegistry {
1063
1098
  return this.imported.delete(id);
1064
1099
  }
1065
1100
  }
1066
- /** POST /v2/templates/{name}/apply's body (`{parameters, grants?, servers?, overrides?: {model?, choice?, approvals?}, agent_id?}`), checked
1101
+ /** POST /v2/templates/{name}/apply's body (`{parameters, grants?, servers?, overrides?: {model?, choice?, approvals?}, agent_id?, revision?, sha?, dry_run?}`), checked
1067
1102
  * against the package: the parameters as given (a blank one at its default), the MCP tools the owner allows (each one the
1068
1103
  * package lists, by its gate name), and the model asked for in place of the package's: one of its own (`model`), or one
1069
- * of the package's model choices by id (`choice`), never both. 422 naming every field that is wrong. */
1104
+ * of the package's model choices by id (`choice`), never both. `revision` (with agent_id) and `sha` are what the caller
1105
+ * read: the agent's current revision and the package's sha, each held to them (412 when another). 422 naming every field
1106
+ * that is wrong. */
1070
1107
  export function applyBodyOf(p, body) {
1071
- const issues = unknownFields(body, ["parameters", "grants", "servers", "overrides", "agent_id"]);
1108
+ const issues = unknownFields(body, ["parameters", "grants", "servers", "overrides", "agent_id", "revision", "sha", "dry_run"]);
1109
+ if (body.dry_run !== undefined && typeof body.dry_run !== "boolean")
1110
+ issues.push({ field: "dry_run", reason: "wrong_type", message: "dry_run is true or false: true answers the apply's plan and writes nothing" });
1072
1111
  // The agent an update writes onto (the server checks it was made from this package): text, else a 422 with the rest.
1073
1112
  if (body.agent_id !== undefined && !(typeof body.agent_id === "string" && body.agent_id.trim()))
1074
1113
  issues.push({ field: "agent_id", reason: "wrong_type", message: `agent_id is the id of an agent the ${p.name} template made: the apply writes a new revision of it in place of making another` });
1114
+ if (body.revision !== undefined && !(typeof body.revision === "string" && body.revision))
1115
+ issues.push({ field: "revision", reason: "wrong_type", message: "revision is the id of the agent's revision you read (GET /agents/{agent_id} `revision`): the apply writes only while it is still the current one" });
1116
+ else if (body.revision !== undefined && body.agent_id === undefined)
1117
+ issues.push({ field: "revision", reason: "not_allowed", message: "revision is the agent's current revision as you read it, so it goes with agent_id: an apply without one makes a new agent" });
1118
+ if (body.sha !== undefined && !(typeof body.sha === "string" && /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(body.sha)))
1119
+ issues.push({ field: "sha", reason: "bad_format", message: "sha is the package's sha as you read it (GET /templates `sha`): a commit's 40 hex characters, or an upload's 64" });
1075
1120
  const listed = p.mcp.flatMap(({ toolkit, tools }) => tools.map((tool) => mcpToolName(toolkit, tool)));
1076
1121
  const grants = [];
1077
1122
  if (body.grants !== undefined && !Array.isArray(body.grants))
@@ -1127,7 +1172,7 @@ export function applyBodyOf(p, body) {
1127
1172
  }
1128
1173
  if (issues.length)
1129
1174
  throw invalid(issues);
1130
- return { parameters, grants, servers, ...(typeof body.agent_id === "string" ? { agentId: body.agent_id.trim() } : {}), ...(isObject(overrides) && typeof overrides.model === "string" ? { model: overrides.model } : {}), ...(choice ? { choice } : {}), ...(isObject(overrides) && (overrides.approvals === "ask" || overrides.approvals === "never") ? { approvals: overrides.approvals } : {}) };
1175
+ return { parameters, grants, servers, dryRun: body.dry_run === true, ...(typeof body.agent_id === "string" ? { agentId: body.agent_id.trim() } : {}), ...(typeof body.revision === "string" ? { revision: body.revision } : {}), ...(typeof body.sha === "string" ? { sha: body.sha } : {}), ...(isObject(overrides) && typeof overrides.model === "string" ? { model: overrides.model } : {}), ...(choice ? { choice } : {}), ...(isObject(overrides) && (overrides.approvals === "ask" || overrides.approvals === "never") ? { approvals: overrides.approvals } : {}) };
1131
1176
  }
1132
1177
  /** The model a package's agent gets here, as `{model?, warning?}`: its `prefer` when this server runs it on `harness`
1133
1178
  * with a key for its provider, else `refused` (preferUnrunnable): apply makes nothing, never the tier's model in its
@@ -1209,6 +1254,8 @@ export async function choiceUnrunnable(env, choice, offer) {
1209
1254
  }
1210
1255
  /** What to do where a package's computer list has no shell to take: in the apply's refusal and its fallback warning. */
1211
1256
  export const COMPUTER_FIX = "Turn on Archil in Settings → Workspace, or run AgentRun where Docker answers, then apply again to give it a shell.";
1257
+ /** What to do where a package that needs programs (`needs`) has no sandbox to take: a Docker box whose image has them. */
1258
+ export const NEEDS_FIX = `Run AgentRun where Docker answers, with Archil off in Settings → Workspace. ${DOCKER_IMAGE_FIX} Then apply again.`;
1212
1259
  /** The first entry of a package's computer list (`[shell, none]`) this server meets now, given the shell it has
1213
1260
  * (`here`): shell, where it has one; none, always (kind none, and no shell tool: a run on the runner in Mode 2 has bash,
1214
1261
  * so a shell tool is dropped rather than left to it). Undefined for a package with no list (it runs where a new agent
@@ -1224,6 +1271,13 @@ export function pickComputer(p, here) {
1224
1271
  const clash = found && found.computer.kind === "sandbox" && runnerOnly.length ? `${found.words} runs ${runnerOnly.join(", ")} nowhere` : undefined;
1225
1272
  const shell = clash ? undefined : found;
1226
1273
  const lack = "none" in here ? here.none : clash ?? "this server has none";
1274
+ // A package that needs programs (its list is [shell] alone) takes a sandbox, whose box each run checks for them: a
1275
+ // shell that is no sandbox (Archil's serverless exec runs on the runner, whose programs no run checks) is refused.
1276
+ if (p.needs && !(shell && shell.computer.kind === "sandbox")) {
1277
+ const why = shell ? `the shell here is ${shell.words}, which is no sandbox` : lack;
1278
+ const list = new Intl.ListFormat("en", { type: "conjunction" }).format(p.needs);
1279
+ return { refused: `The ${p.name} template needs a sandbox that has ${list}, and ${why}. Nothing was created. ${NEEDS_FIX}`, fix: NEEDS_FIX };
1280
+ }
1227
1281
  const entry = p.computer.find((one) => one === "none" || shell);
1228
1282
  if (!entry)
1229
1283
  return { refused: `The ${p.name} template needs a shell, and ${lack}. Nothing was created.` };
@@ -1234,7 +1288,7 @@ export function pickComputer(p, here) {
1234
1288
  ? `${lack.charAt(0).toUpperCase()}${lack.slice(1)}, so the agent was made with the template's next choice, no computer${dropped.length ? `, and without ${without}` : ""}. ${COMPUTER_FIX}`
1235
1289
  : dropped.length && shell ? `The shell here is ${shell.words}, which runs ${runs.join(", ")} alone, so the agent was made without ${without}.` : null;
1236
1290
  return entry === "shell" && shell
1237
- ? { entry, computer: { ...shell.computer }, shell: shell.words, dropped, defaults: [...shell.tools], note }
1291
+ ? { entry, computer: { ...shell.computer, ...(p.needs ? { needs: [...p.needs] } : {}) }, shell: shell.words, dropped, defaults: [...shell.tools], note }
1238
1292
  : { entry, computer: { kind: "none" }, shell: null, dropped, defaults: [], note };
1239
1293
  }
1240
1294
  /** The model of each tier a package's subagents run on here (the definition's model_tiers), as `{modelTiers?, warning?}`:
@@ -1302,7 +1356,7 @@ export function compiled(p, parameters, chosen, _deps) {
1302
1356
  name: p.displayName ? filled(p.displayName, parameters) : p.name, description: p.description, instructions: filled(p.instructions, parameters),
1303
1357
  ...(chosen.harness ? { harness: chosen.harness } : {}), ...(chosen.model ? { model: chosen.model } : {}), ...(chosen.modelTiers && Object.keys(chosen.modelTiers).length ? { model_tiers: chosen.modelTiers } : {}), ...(p.effort ? { thinking: p.effort } : {}),
1304
1358
  ...(pick ? { computer: pick.computer } : {}), ...(tools ? { tools } : {}), ...(Object.keys(settings).length ? { tool_settings: settings } : {}),
1305
- ...(p.learning !== undefined ? { learning: p.learning } : {}), ...(p.budget?.per_run_usd ? { max_cost_usd: p.budget.per_run_usd } : {}), skills,
1359
+ ...(p.learning !== undefined ? { learning: p.learning } : {}), ...(p.budget?.per_run_usd ? { max_cost_usd: p.budget.per_run_usd } : {}), ...(p.budget?.max_requests ? { max_requests: p.budget.max_requests } : {}), skills,
1306
1360
  // The apply's choice: unattended only when it says never (none given: the agent asks).
1307
1361
  ...(chosen.approvals === "never" ? { approvals: "never" } : {}),
1308
1362
  // The package's typed input (manifest `inputs`): what each run's input is checked against, and how the model reads it.
@@ -6,4 +6,4 @@ export { costLabel, endedUsage, PAGE_CHANGED_ROW, RUN_RESUMED, toolCallWords, TU
6
6
  export { FEEDBACK_SUFFIX, isFeedbackRow, isMessageRow, isUserEntry, MESSAGE_ORIGIN, messageOrigins, NOTE_SUFFIX, originMatcher, originOf, TRIGGER_LABELS, TRIGGER_SOURCES, type MessageOrigin, type TriggerSource } from "./origin.js";
7
7
  export { cut, scrubUrl, scrubUrls } from "./util.js";
8
8
  export { webCut, webShownOf, webWithin, type WebShown } from "./web-calls.js";
9
- export { answeredRequests, BROWSER_CHARGE, CALL_ENDED_WITH_RUN, compactionAnswers, CALL_REFUSED, CALL_RESULT_CHARS, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, type AgentEventLike, type DecisionLike, type EntryLike, type RunMetrics, type SideSpend, type TimelineEvent, type TimelineKind, type TimelineOptions, type ToolMetrics, } from "./timeline.js";
9
+ export { answeredRequests, BROWSER_CHARGE, CALL_ENDED_WITH_RUN, compactionAnswers, CALL_REFUSED, CALL_RESULT_CHARS, CAP_REFUSED, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, type AgentEventLike, type DecisionLike, type EntryLike, type RunMetrics, type SideSpend, type TimelineEvent, type TimelineKind, type TimelineOptions, type ToolMetrics, } from "./timeline.js";
@@ -6,4 +6,4 @@ export { costLabel, endedUsage, PAGE_CHANGED_ROW, RUN_RESUMED, toolCallWords, TU
6
6
  export { FEEDBACK_SUFFIX, isFeedbackRow, isMessageRow, isUserEntry, MESSAGE_ORIGIN, messageOrigins, NOTE_SUFFIX, originMatcher, originOf, TRIGGER_LABELS, TRIGGER_SOURCES } from "./origin.js";
7
7
  export { cut, scrubUrl, scrubUrls } from "./util.js";
8
8
  export { webCut, webShownOf, webWithin } from "./web-calls.js";
9
- export { answeredRequests, BROWSER_CHARGE, CALL_ENDED_WITH_RUN, compactionAnswers, CALL_REFUSED, CALL_RESULT_CHARS, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, } from "./timeline.js";
9
+ export { answeredRequests, BROWSER_CHARGE, CALL_ENDED_WITH_RUN, compactionAnswers, CALL_REFUSED, CALL_RESULT_CHARS, CAP_REFUSED, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, } from "./timeline.js";
@@ -134,7 +134,7 @@ const fetchOutcome = (result) => {
134
134
  // web_fetch answers a page, `{ok, url, status, title, text, links, refused?, error?}`.
135
135
  registerLabel("web_fetch", fetchLabel, fetchFold, { name: "Fetch web pages" });
136
136
  registerOutcome("web_fetch", fetchOutcome);
137
- // web_save answers `{ok: true, path, bytes, content_type, url}` or `{ok: false, url, path?, refused | error}` (web-save.ts):
137
+ // web_save answers `{ok: true, path, bytes, content_type, duration_s?, url}` or `{ok: false, url, path?, refused | error}` (web-save.ts):
138
138
  // the path it answered, else the one asked (a bare name under media/, as it saves one), and the host it was asked for.
139
139
  const savedAt = (a, result) => {
140
140
  const answered = result && str(obj(json(result.text))?.path);
@@ -180,6 +180,11 @@ export declare const chargedTool: (row: TimelineEvent) => string | undefined;
180
180
  * told after the note's "AgentRun server note:" label). A row of its own, the server's ("AgentRun: …", labelled once);
181
181
  * no request, no cost. */
182
182
  export declare const CAP_WRAPUP = "agentrun.cap_wrapup";
183
+ /** A tool call the spend cap's wrap-up refused (serve's wrap-up.ts, the runner's gate): `callId` and the cap it was
184
+ * refused under (`capUsd`), on the run's root. The call's own refused row is its result's; this one is data only, for the
185
+ * run's view (`stopped_for`, `budget_refused_calls`): no row, no request, no cost. A call refused twice (a replay) is
186
+ * one call. */
187
+ export declare const CAP_REFUSED = "agentrun.cap_refused";
183
188
  /** The run's model was told once, on its first request after its claim gave it a computer in place of an earlier
184
189
  * claim's, that the old one is gone with what was on it (`words`, what it was told after the label, as the wrap-up's).
185
190
  * A row of its own, the server's, as the wrap-up's; no request, no cost. */
@@ -101,6 +101,11 @@ export const chargedTool = (row) => !row.usage ? undefined : row.kind === "phase
101
101
  * told after the note's "AgentRun server note:" label). A row of its own, the server's ("AgentRun: …", labelled once);
102
102
  * no request, no cost. */
103
103
  export const CAP_WRAPUP = "agentrun.cap_wrapup";
104
+ /** A tool call the spend cap's wrap-up refused (serve's wrap-up.ts, the runner's gate): `callId` and the cap it was
105
+ * refused under (`capUsd`), on the run's root. The call's own refused row is its result's; this one is data only, for the
106
+ * run's view (`stopped_for`, `budget_refused_calls`): no row, no request, no cost. A call refused twice (a replay) is
107
+ * one call. */
108
+ export const CAP_REFUSED = "agentrun.cap_refused";
104
109
  /** The run's model was told once, on its first request after its claim gave it a computer in place of an earlier
105
110
  * claim's, that the old one is gone with what was on it (`words`, what it was told after the label, as the wrap-up's).
106
111
  * A row of its own, the server's, as the wrap-up's; no request, no cost. */
@@ -788,6 +793,9 @@ function createProjector(options) {
788
793
  const add = (row) => { rows.push(row); out.push(row); };
789
794
  const touch = (row) => { if (!out.includes(row))
790
795
  out.push(row); };
796
+ // The wrap-up's refusal of a call, kept for the run's view: its result row is the call's own.
797
+ if (entry.kind === CAP_REFUSED)
798
+ return out;
791
799
  if (entry.kind === CAP_WRAPUP || entry.kind === COMPUTER_NOTE) {
792
800
  // What the run's model was told near its cap, or after its computer was replaced: the server's row (`origin:
793
801
  // "server"`, in the words of its other rows), no request, no cost, and no message any turn took (its id ends in
@@ -40,11 +40,11 @@ export declare const permissionsOf: (name: string) => readonly Permission[];
40
40
  * give it: the one in force under the server's settings (`permission`), the owner's default (`default_permission`) and
41
41
  * those it may be set to. An agent's read gives the same, the agent's own layer over it (agentTools). */
42
42
  export declare const serverGate: (name: string, settings: ToolSettingsMap, effect?: ToolEffect) => {
43
- default_permission: "ask" | "allow" | "deny";
44
- permissions: ("ask" | "allow" | "deny")[];
43
+ default_permission: "ask" | "deny" | "allow";
44
+ permissions: ("ask" | "deny" | "allow")[];
45
45
  fallback_allow_reads?: true | undefined;
46
46
  allow_reads?: true | undefined;
47
- permission: "ask" | "allow" | "deny";
47
+ permission: "ask" | "deny" | "allow";
48
48
  };
49
49
  /** The run's own tools beyond the table, each its own settings key, allowed by default like a table tool: the learned
50
50
  * workflow a run's pin names runs as `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL), and the host's
@@ -289,17 +289,17 @@ export declare function shellUnavailable(name: string, shell: ShellPlace): Resol
289
289
  * computer setting); a tool of bash's family that leaves out resolves unavailable, saying why (shellUnavailable). */
290
290
  export declare function agentTools(env: NodeJS.ProcessEnv, settings: ToolSettingsMap, agent: Tooling, order: readonly string[], shell?: ShellPlace, effectOf?: (name: string) => ToolEffect | undefined): ({
291
291
  resolved: Resolution;
292
- permission: "ask" | "allow" | "deny";
292
+ permission: "ask" | "deny" | "allow";
293
293
  permission_from: import("./refusal-words.js").SettingFrom;
294
- default_permission: "ask" | "allow" | "deny";
295
- permissions: ("ask" | "allow" | "deny")[];
294
+ default_permission: "ask" | "deny" | "allow";
295
+ permissions: ("ask" | "deny" | "allow")[];
296
296
  blurb?: string | undefined;
297
297
  name: string;
298
298
  } | {
299
- permission: "ask" | "allow" | "deny";
299
+ permission: "ask" | "deny" | "allow";
300
300
  permission_from: import("./refusal-words.js").SettingFrom;
301
- default_permission: "ask" | "allow" | "deny";
302
- permissions: ("ask" | "allow" | "deny")[];
301
+ default_permission: "ask" | "deny" | "allow";
302
+ permissions: ("ask" | "deny" | "allow")[];
303
303
  blurb?: string | undefined;
304
304
  name: string;
305
305
  } | {
@@ -307,10 +307,10 @@ export declare function agentTools(env: NodeJS.ProcessEnv, settings: ToolSetting
307
307
  provider_from: string;
308
308
  default_provider: string;
309
309
  resolved: Resolution;
310
- permission: "ask" | "allow" | "deny";
310
+ permission: "ask" | "deny" | "allow";
311
311
  permission_from: import("./refusal-words.js").SettingFrom;
312
- default_permission: "ask" | "allow" | "deny";
313
- permissions: ("ask" | "allow" | "deny")[];
312
+ default_permission: "ask" | "deny" | "allow";
313
+ permissions: ("ask" | "deny" | "allow")[];
314
314
  blurb?: string | undefined;
315
315
  name: string;
316
316
  })[];
package/dist/tools.d.ts CHANGED
@@ -341,13 +341,13 @@ export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettings
341
341
  providers?: string[] | undefined;
342
342
  provider?: string | undefined;
343
343
  default_provider?: string | undefined;
344
- resolves?: Record<"opencode" | "codex" | "claude-agent" | "pi", Resolution> | undefined;
345
- why?: Record<"opencode" | "codex" | "claude-agent" | "pi", string> | undefined;
346
- default_permission: "ask" | "allow" | "deny";
347
- permissions: ("ask" | "allow" | "deny")[];
344
+ resolves?: Record<"opencode" | "codex" | "pi" | "claude-agent", Resolution> | undefined;
345
+ why?: Record<"opencode" | "codex" | "pi" | "claude-agent", string> | undefined;
346
+ default_permission: "ask" | "deny" | "allow";
347
+ permissions: ("ask" | "deny" | "allow")[];
348
348
  fallback_allow_reads?: true | undefined;
349
349
  allow_reads?: true | undefined;
350
- permission: "ask" | "allow" | "deny";
350
+ permission: "ask" | "deny" | "allow";
351
351
  harnesses: string[];
352
352
  missing?: string[] | undefined;
353
353
  reason?: string | undefined;
@@ -360,11 +360,11 @@ export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettings
360
360
  name: string;
361
361
  summary: string;
362
362
  } | {
363
- default_permission: "ask" | "allow" | "deny";
364
- permissions: ("ask" | "allow" | "deny")[];
363
+ default_permission: "ask" | "deny" | "allow";
364
+ permissions: ("ask" | "deny" | "allow")[];
365
365
  fallback_allow_reads?: true | undefined;
366
366
  allow_reads?: true | undefined;
367
- permission: "ask" | "allow" | "deny";
367
+ permission: "ask" | "deny" | "allow";
368
368
  name: string;
369
369
  summary: string;
370
370
  blurb: string;
package/dist/tools.js CHANGED
@@ -628,7 +628,7 @@ export const TOOLS = Object.freeze({
628
628
  // web_save (web-save.ts). It makes no paid request, so nothing books it. No node or call node names it: a workflow's
629
629
  // effect has only a local work path, not the run's Workspace.
630
630
  [WEB_SAVE_TOOL]: {
631
- summary: `Download one public file into the run's work/ (a bare name under media/), never overwriting: { url, path } -> { ok: true, path, bytes, content_type, url } or { ok: false, url, refused | error }; at most ${SAVE_MAX_BYTES / (1024 * 1024)} MiB, a media type only when its bytes agree.`,
631
+ summary: `Download one public file into the run's work/ (a bare name under media/), never overwriting: { url, path } -> { ok: true, path, bytes, content_type, duration_s?, url } (duration_s an mp3, wav, mp4 or m4a's length in seconds) or { ok: false, url, refused | error }; at most ${SAVE_MAX_BYTES / (1024 * 1024)} MiB, a media type only when its bytes agree.`,
632
632
  needs: [],
633
633
  nodes: false,
634
634
  bind: async (host) => {
@@ -0,0 +1,47 @@
1
+ import type { Json } from "./validate.js";
2
+ export declare const LAUNCH_HOOK_URL_ENV = "AGENTRUN_LAUNCH_HOOK_URL";
3
+ export declare const LAUNCH_HOOK_SECRET_ENV = "AGENTRUN_LAUNCH_HOOK_SECRET";
4
+ /** How long the host has to answer a firing, its connection included. */
5
+ export declare const LAUNCH_HOOK_TIMEOUT_MS = 10000;
6
+ /** How long after its 2xx a host that answered without starting the firing's run may still start it (one start, under
7
+ * the firing: triggers.ts handedStart). From the answer, not from fired_at: a catch-up, a firing that waited on its
8
+ * trigger's max_active_runs, or one a stop cut short and the next start handed again reaches the host late, and its
9
+ * host gets the same 10 minutes as any. */
10
+ export declare const LAUNCH_HOOK_LATE_START_MS: number;
11
+ /** The hook a server hands its firings to: where, and the secret it signs with. `timeoutMs`: a test's bound, else
12
+ * LAUNCH_HOOK_TIMEOUT_MS. */
13
+ export type LaunchHook = {
14
+ readonly url: string;
15
+ readonly secret: string;
16
+ readonly timeoutMs?: number;
17
+ };
18
+ /** What the host is sent for a firing: its id (the message's webhook-id too), its trigger, the agent and the revision a
19
+ * run would start on now, the run's input as the trigger gives it, and the firing's time. */
20
+ export type HookFiring = {
21
+ firing_id: string;
22
+ trigger_id: string;
23
+ agent_id: string;
24
+ revision_id: string | null;
25
+ input: Json;
26
+ fired_at: string;
27
+ };
28
+ /** The host's answer: taken (2xx); or why the firing is skipped; or `stopped`, the server's stop cut it short and the
29
+ * firing is left as it was. */
30
+ export type Handed = {
31
+ taken: true;
32
+ } | {
33
+ skipped: string;
34
+ } | {
35
+ stopped: true;
36
+ };
37
+ /** The launch hook `given` sets (the URL from the environment, the secret as the server holds its own), or undefined when
38
+ * neither is set. Throws, in words that never hold the secret, when one is set without the other, the URL is not https
39
+ * (http only to loopback) or holds a user or password, or the secret is not a `whsec_` secret of MIN_KEY_BYTES or more. */
40
+ export declare function launchHookFrom(given: {
41
+ url?: string | undefined;
42
+ secret?: string | undefined;
43
+ }): LaunchHook | undefined;
44
+ /** Where `hook` sends, for the start's banner: its origin alone, never a path or query that may hold a token. */
45
+ export declare const hookOrigin: (hook: LaunchHook) => string;
46
+ /** `firing` handed to `hook`: one signed POST of it, within the hook's bound and cut by `stop`. A redirect is not followed. */
47
+ export declare function handToHost(hook: LaunchHook, firing: HookFiring, stop: AbortSignal): Promise<Handed>;