@parcha/agentrun-serve 0.1.0-beta.52 → 0.1.0-beta.54

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 (287) hide show
  1. package/CHANGELOG.md +149 -1
  2. package/README.md +295 -37
  3. package/dist/agent-delete.d.ts +5 -6
  4. package/dist/agent-delete.js +30 -67
  5. package/dist/agent-package.d.ts +71 -0
  6. package/dist/agent-package.js +345 -0
  7. package/dist/agent-rows.d.ts +1 -1
  8. package/dist/agents-store.d.ts +26 -20
  9. package/dist/agents-store.js +42 -34
  10. package/dist/api-only.d.ts +25 -6
  11. package/dist/api-only.js +34 -13
  12. package/dist/claude-login.d.ts +1 -0
  13. package/dist/claude-login.js +1 -1
  14. package/dist/cli-learning/cli.d.ts +3 -0
  15. package/dist/cli-learning/cli.js +17 -3
  16. package/dist/cli-learning/connections.js +3 -2
  17. package/dist/cli-learning/schema.js +2 -1
  18. package/dist/cli.js +76 -8
  19. package/dist/composio-preset.d.ts +3 -1
  20. package/dist/composio-preset.js +5 -3
  21. package/dist/composio-triggers.d.ts +4 -0
  22. package/dist/composio-triggers.js +4 -1
  23. package/dist/computer-needs.d.ts +32 -0
  24. package/dist/computer-needs.js +80 -0
  25. package/dist/computer-setting.d.ts +5 -2
  26. package/dist/computer-setting.js +8 -1
  27. package/dist/computers.d.ts +0 -2
  28. package/dist/computers.js +1 -1
  29. package/dist/console/assets/index-B_85An2t.js +745 -0
  30. package/dist/console/assets/index-n1YsbnYh.css +1 -0
  31. package/dist/console/index.html +2 -2
  32. package/dist/console-links.d.ts +1 -0
  33. package/dist/console-links.js +2 -0
  34. package/dist/env-switch.d.ts +14 -0
  35. package/dist/env-switch.js +23 -0
  36. package/dist/errors.d.ts +5 -0
  37. package/dist/errors.js +10 -0
  38. package/dist/eval-previous.js +4 -3
  39. package/dist/fal-price.js +10 -13
  40. package/dist/github-connection.d.ts +50 -1
  41. package/dist/github-connection.js +96 -3
  42. package/dist/github-faux.d.ts +11 -2
  43. package/dist/github-faux.js +138 -7
  44. package/dist/github-pull-request.d.ts +37 -0
  45. package/dist/github-pull-request.js +110 -0
  46. package/dist/handed-secret.d.ts +4 -0
  47. package/dist/handed-secret.js +10 -0
  48. package/dist/harness-archive.d.ts +15 -5
  49. package/dist/harness-archive.js +71 -34
  50. package/dist/harness-check.d.ts +2 -1
  51. package/dist/harness-check.js +36 -95
  52. package/dist/harness-egress.d.ts +23 -0
  53. package/dist/harness-egress.js +69 -0
  54. package/dist/harness-recipe-entry.d.ts +71 -0
  55. package/dist/harness-recipe-entry.js +184 -0
  56. package/dist/harness-recipe.d.ts +73 -6
  57. package/dist/harness-recipe.js +185 -31
  58. package/dist/harness-sign-in.d.ts +29 -0
  59. package/dist/harness-sign-in.js +122 -0
  60. package/dist/harness-table.d.ts +21 -0
  61. package/dist/harness-table.js +58 -3
  62. package/dist/harness-zip.d.ts +6 -0
  63. package/dist/harness-zip.js +203 -0
  64. package/dist/ids.d.ts +11 -0
  65. package/dist/ids.js +36 -0
  66. package/dist/learn/commit.d.ts +14 -1
  67. package/dist/learn/commit.js +156 -1
  68. package/dist/learn/compile.js +22 -8
  69. package/dist/learn/folder.d.ts +5 -0
  70. package/dist/learn/folder.js +10 -1
  71. package/dist/learn/learning.sh +15 -3
  72. package/dist/learn/promote.d.ts +2 -2
  73. package/dist/learn/secrets.js +30 -7
  74. package/dist/learning-routes.d.ts +23 -11
  75. package/dist/learning-routes.js +110 -20
  76. package/dist/learning.d.ts +9 -6
  77. package/dist/learning.js +9 -4
  78. package/dist/live-reach.d.ts +34 -7
  79. package/dist/live-reach.js +76 -11
  80. package/dist/mcp-gateway.js +15 -2
  81. package/dist/mcp-probe.d.ts +3 -0
  82. package/dist/mcp-probe.js +8 -3
  83. package/dist/mcp-resources.d.ts +44 -0
  84. package/dist/mcp-resources.js +100 -0
  85. package/dist/mcp-servers-store.d.ts +16 -12
  86. package/dist/model.d.ts +4 -4
  87. package/dist/model.js +6 -6
  88. package/dist/native/cli.js +9 -2
  89. package/dist/native/connection.d.ts +2 -2
  90. package/dist/native/connection.js +5 -2
  91. package/dist/native/discovery.d.ts +2 -0
  92. package/dist/native/discovery.js +10 -6
  93. package/dist/native/remote-worker-bridge.js +36 -4
  94. package/dist/native/remote.d.ts +18 -1
  95. package/dist/native/remote.js +126 -37
  96. package/dist/native/schema.d.ts +6 -0
  97. package/dist/native/schema.js +31 -6
  98. package/dist/native/source-account.d.ts +13 -0
  99. package/dist/native/source-account.js +114 -0
  100. package/dist/native/source-capture-hooks.d.ts +5 -0
  101. package/dist/native/source-capture-hooks.js +102 -0
  102. package/dist/native/source-mcp-selection.d.ts +13 -0
  103. package/dist/native/source-mcp-selection.js +72 -0
  104. package/dist/native/source-runtime-tools.d.ts +19 -0
  105. package/dist/native/source-runtime-tools.js +103 -0
  106. package/dist/native/source-snapshot-types.d.ts +138 -0
  107. package/dist/native/source-snapshot-types.js +12 -0
  108. package/dist/native/source-snapshot.d.ts +8 -0
  109. package/dist/native/source-snapshot.js +1201 -0
  110. package/dist/observation/learning.js +3 -2
  111. package/dist/openapi.js +275 -40
  112. package/dist/print.js +1 -1
  113. package/dist/purged-workflow.d.ts +12 -0
  114. package/dist/purged-workflow.js +43 -0
  115. package/dist/run-keys.d.ts +46 -0
  116. package/dist/run-keys.js +109 -0
  117. package/dist/run-launch.d.ts +16 -1
  118. package/dist/run-launch.js +30 -1
  119. package/dist/run-learning-served.d.ts +2 -2
  120. package/dist/run-model-key.d.ts +2 -2
  121. package/dist/run-model-key.js +5 -5
  122. package/dist/run-secrets.d.ts +2 -0
  123. package/dist/run-secrets.js +7 -4
  124. package/dist/run-view.d.ts +17 -0
  125. package/dist/run-view.js +25 -1
  126. package/dist/runner/adapter-loop.d.ts +11 -3
  127. package/dist/runner/adapter-loop.js +138 -22
  128. package/dist/runner/adapter-run-spec.js +26 -13
  129. package/dist/runner/audit.d.ts +2 -0
  130. package/dist/runner/audit.js +9 -1
  131. package/dist/runner/beside.js +2 -1
  132. package/dist/runner/claim-secrets.d.ts +29 -3
  133. package/dist/runner/claim-secrets.js +38 -4
  134. package/dist/runner/cli-run-spec.js +24 -13
  135. package/dist/runner/harness-loops.d.ts +6 -0
  136. package/dist/runner/harness-loops.js +11 -1
  137. package/dist/runner/held.d.ts +4 -0
  138. package/dist/runner/journal-kinds.d.ts +2 -0
  139. package/dist/runner/learned-first.d.ts +2 -0
  140. package/dist/runner/learned-first.js +1 -1
  141. package/dist/runner/learning-end.d.ts +7 -2
  142. package/dist/runner/learning-end.js +22 -10
  143. package/dist/runner/learning-seed.d.ts +9 -3
  144. package/dist/runner/learning-seed.js +2 -2
  145. package/dist/runner/main.d.ts +1 -0
  146. package/dist/runner/main.js +20 -13
  147. package/dist/runner/mcp-claim.js +6 -1
  148. package/dist/runner/mcp-run.d.ts +10 -7
  149. package/dist/runner/mcp-run.js +3 -5
  150. package/dist/runner/metrics.d.ts +4 -2
  151. package/dist/runner/metrics.js +15 -3
  152. package/dist/runner/monid-run.js +9 -11
  153. package/dist/runner/pr-checkout.d.ts +21 -4
  154. package/dist/runner/pr-checkout.js +103 -4
  155. package/dist/runner/project-checkpoint.d.ts +35 -0
  156. package/dist/runner/project-checkpoint.js +116 -0
  157. package/dist/runner/project-drain.d.ts +8 -0
  158. package/dist/runner/project-drain.js +25 -0
  159. package/dist/runner/project-host.d.ts +10 -0
  160. package/dist/runner/project-host.js +52 -0
  161. package/dist/runner/promotion.d.ts +14 -6
  162. package/dist/runner/promotion.js +98 -41
  163. package/dist/runner/redact.d.ts +13 -0
  164. package/dist/runner/redact.js +67 -1
  165. package/dist/runner/run-channel.d.ts +9 -0
  166. package/dist/runner/run-channel.js +15 -2
  167. package/dist/runner/run-child-host.d.ts +8 -4
  168. package/dist/runner/run-child-host.js +178 -45
  169. package/dist/runner/run-errors.js +2 -2
  170. package/dist/runner/runner-check.d.ts +3 -0
  171. package/dist/runner/runner-check.js +28 -2
  172. package/dist/runner/runner.js +26 -9
  173. package/dist/runner/store-secrets.js +7 -3
  174. package/dist/runner/workflow-first.d.ts +4 -0
  175. package/dist/runner/workflow-first.js +13 -0
  176. package/dist/runner/workflow-loop.d.ts +2 -1
  177. package/dist/runner/workflow-loop.js +2 -1
  178. package/dist/runner/workflow-spec.js +1 -1
  179. package/dist/runs-over-store.d.ts +34 -6
  180. package/dist/runs-over-store.js +133 -25
  181. package/dist/sdk/runs.d.ts +11 -1
  182. package/dist/sdk/runs.js +117 -26
  183. package/dist/sdk/schema.js +12 -2
  184. package/dist/sdk/workflows.d.ts +1 -1
  185. package/dist/server.d.ts +79 -32
  186. package/dist/server.js +673 -113
  187. package/dist/skills/agentrun-serve/SKILL.md +2 -1
  188. package/dist/source-sync/adoption.d.ts +15 -0
  189. package/dist/source-sync/adoption.js +36 -0
  190. package/dist/source-sync/auxiliary.d.ts +23 -0
  191. package/dist/source-sync/auxiliary.js +64 -0
  192. package/dist/source-sync/capture-git.d.ts +5 -0
  193. package/dist/source-sync/capture-git.js +272 -0
  194. package/dist/source-sync/capture-project.d.ts +53 -0
  195. package/dist/source-sync/capture-project.js +206 -0
  196. package/dist/source-sync/capture-refusal.d.ts +7 -0
  197. package/dist/source-sync/capture-refusal.js +16 -0
  198. package/dist/source-sync/capture.d.ts +11 -0
  199. package/dist/source-sync/capture.js +22 -0
  200. package/dist/source-sync/checkpoint-gate.d.ts +21 -0
  201. package/dist/source-sync/checkpoint-gate.js +52 -0
  202. package/dist/source-sync/checkpoints.d.ts +66 -0
  203. package/dist/source-sync/checkpoints.js +168 -0
  204. package/dist/source-sync/claim.d.ts +11 -0
  205. package/dist/source-sync/claim.js +48 -0
  206. package/dist/source-sync/destination.d.ts +47 -0
  207. package/dist/source-sync/destination.js +239 -0
  208. package/dist/source-sync/io.d.ts +15 -0
  209. package/dist/source-sync/io.js +52 -0
  210. package/dist/source-sync/local.d.ts +43 -0
  211. package/dist/source-sync/local.js +229 -0
  212. package/dist/source-sync/prepare.d.ts +59 -0
  213. package/dist/source-sync/prepare.js +93 -0
  214. package/dist/source-sync/projects.d.ts +61 -0
  215. package/dist/source-sync/projects.js +130 -0
  216. package/dist/source-sync/registry.d.ts +95 -0
  217. package/dist/source-sync/registry.js +226 -0
  218. package/dist/source-sync/service.d.ts +33 -0
  219. package/dist/source-sync/service.js +118 -0
  220. package/dist/source-sync/skill-edits.d.ts +12 -0
  221. package/dist/source-sync/skill-edits.js +122 -0
  222. package/dist/source-sync/snapshots.d.ts +48 -0
  223. package/dist/source-sync/snapshots.js +448 -0
  224. package/dist/source-sync/types.d.ts +9 -0
  225. package/dist/source-sync/types.js +14 -0
  226. package/dist/source-sync/workspace.d.ts +66 -0
  227. package/dist/source-sync/workspace.js +273 -0
  228. package/dist/store/agent-body.d.ts +6 -2
  229. package/dist/store/agent-body.js +18 -7
  230. package/dist/store/index.d.ts +2 -2
  231. package/dist/store/index.js +1 -1
  232. package/dist/store/schema.d.ts +2 -1
  233. package/dist/store/schema.js +2 -1
  234. package/dist/store/seal.d.ts +5 -1
  235. package/dist/store/seal.js +12 -3
  236. package/dist/store/sqlite/project-checkpoints.d.ts +11 -0
  237. package/dist/store/sqlite/project-checkpoints.js +70 -0
  238. package/dist/store/sqlite/run-launch.d.ts +4 -12
  239. package/dist/store/sqlite/run-launch.js +5 -19
  240. package/dist/store/sqlite/store.js +224 -170
  241. package/dist/store/store.d.ts +116 -39
  242. package/dist/store/store.js +14 -1
  243. package/dist/store-reads/learning.d.ts +2 -2
  244. package/dist/store-view.d.ts +3 -1
  245. package/dist/store-view.js +17 -5
  246. package/dist/suggestions.d.ts +282 -0
  247. package/dist/suggestions.js +919 -0
  248. package/dist/telemetry.d.ts +8 -1
  249. package/dist/telemetry.js +12 -4
  250. package/dist/template-import.d.ts +27 -2
  251. package/dist/template-import.js +148 -13
  252. package/dist/templates.d.ts +103 -77
  253. package/dist/templates.js +71 -17
  254. package/dist/timeline/index.d.ts +1 -1
  255. package/dist/timeline/index.js +1 -1
  256. package/dist/timeline/timeline.d.ts +5 -0
  257. package/dist/timeline/timeline.js +8 -0
  258. package/dist/tool-plane.d.ts +12 -12
  259. package/dist/tools.d.ts +8 -8
  260. package/dist/trigger-launch-hook.d.ts +49 -0
  261. package/dist/trigger-launch-hook.js +91 -0
  262. package/dist/trigger-targets.d.ts +14 -1
  263. package/dist/trigger-targets.js +20 -0
  264. package/dist/triggers.d.ts +54 -5
  265. package/dist/triggers.js +143 -8
  266. package/dist/uploads-archil.js +1 -1
  267. package/dist/uploads.js +1 -1
  268. package/dist/validate.d.ts +1 -1
  269. package/dist/validate.js +3 -4
  270. package/dist/workspace/computer-for-claim.d.ts +2 -0
  271. package/dist/workspace/computer-for-claim.js +43 -0
  272. package/dist/workspace/paths.d.ts +6 -0
  273. package/dist/workspace/paths.js +6 -0
  274. package/dist/workspace/resolve-computer.d.ts +1 -0
  275. package/dist/workspace/run-tools.d.ts +2 -0
  276. package/dist/workspace/run-tools.js +8 -0
  277. package/dist/workspace/synced-folder.d.ts +1 -1
  278. package/dist/workspace/synced-folder.js +11 -14
  279. package/launcher/agentrun-serve +1 -1
  280. package/package.json +10 -10
  281. package/skills/agentrun-serve/SKILL.md +2 -1
  282. package/templates/README.md +8 -4
  283. package/templates/agent-scout/agent.md +46 -0
  284. package/templates/agent-scout/skills/scout/SKILL.md +88 -0
  285. package/templates/agent-scout/skills/scout/suggestions.schema.json +112 -0
  286. package/dist/console/assets/index-B-D0EM3j.js +0 -733
  287. package/dist/console/assets/index-DlQepP2J.css +0 -1
@@ -7,7 +7,11 @@ export declare const TELEMETRY_FILE = ".telemetry.json";
7
7
  /** How often a running server says it still runs. */
8
8
  export declare const HEARTBEAT_MS: number;
9
9
  export declare const TELEMETRY_NOTICE = "AgentRun sends anonymous usage counts (a random id, the version, the platform, how many runs as a range): never prompts, files, keys or names. Nothing was sent at this start. Turn it off with AGENTRUN_TELEMETRY=0 or DO_NOT_TRACK=1. Every field: https://github.com/Parcha-ai/agentrun/blob/main/docs/telemetry.md";
10
- export type TelemetryEventName = "server_started" | "heartbeat" | "first_run_completed";
10
+ /** What someone did with suggested agents (suggestions.ts), said as the name alone: never which repository, suggestion
11
+ * or agent. */
12
+ export type UsageEventName = "suggestions_scanned" | "suggestion_discarded" | "suggested_agent_created";
13
+ export declare const USAGE_EVENTS: readonly UsageEventName[];
14
+ export type TelemetryEventName = "server_started" | "heartbeat" | "first_run_completed" | UsageEventName;
11
15
  /** One event, as sent (and as debug prints it). `runs` is a range, never a count. */
12
16
  export interface TelemetryEvent {
13
17
  api_key: string;
@@ -39,6 +43,9 @@ export interface Telemetry {
39
43
  notice?: string;
40
44
  /** A run reached its end here. `status` is the runner's (`ended` is a completed run). */
41
45
  runEnded(status: string): void;
46
+ /** Someone used a feature the counts name: said at once, except during the start that printed the notice, until its
47
+ * first heartbeat, when it is dropped (never held for later). A name not in USAGE_EVENTS is never sent. */
48
+ used(event: UsageEventName): void;
42
49
  /** Stops the heartbeat and waits for the count's last write. Sends nothing. */
43
50
  close(): Promise<void>;
44
51
  }
package/dist/telemetry.js CHANGED
@@ -1,6 +1,7 @@
1
- // Anonymous usage counts (docs/telemetry.md): that a server started, that it is still running a day later, and that its
2
- // first run completed. Each event holds a random id made for this data directory, the server's version, the platform,
3
- // and how many runs ended here as a range. It never holds a prompt, a workflow, a key, a name, a path or an address.
1
+ // Anonymous usage counts (docs/telemetry.md): that a server started, that it is still running a day later, that its
2
+ // first run completed, and that someone used suggested agents (a scan started, a suggestion discarded, a suggested
3
+ // agent's pull request opened). Each event holds a random id made for this data directory, the server's version, the
4
+ // platform, and how many runs ended here as a range. It never holds a prompt, a workflow, a key, a name, a path or an address.
4
5
  //
5
6
  // Off with AGENTRUN_TELEMETRY=0 or DO_NOT_TRACK=1, in CI, under a test runner, and under --faux. The start that first could send prints one
6
7
  // notice and sends nothing at its start, so a person reads how to turn it off before anything leaves the machine.
@@ -24,6 +25,7 @@ export const HEARTBEAT_MS = 24 * 60 * 60 * 1000;
24
25
  const SEND_TIMEOUT_MS = 3_000;
25
26
  const ownVersion = () => JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
26
27
  export const TELEMETRY_NOTICE = "AgentRun sends anonymous usage counts (a random id, the version, the platform, how many runs as a range): never prompts, files, keys or names. Nothing was sent at this start. Turn it off with AGENTRUN_TELEMETRY=0 or DO_NOT_TRACK=1. Every field: https://github.com/Parcha-ai/agentrun/blob/main/docs/telemetry.md";
28
+ export const USAGE_EVENTS = ["suggestions_scanned", "suggestion_discarded", "suggested_agent_created"];
27
29
  const OFF = new Set(["0", "false", "off", "no"]);
28
30
  /** What this start does, from its environment (docs/telemetry.md). */
29
31
  export function telemetryMode(env, o = {}) {
@@ -68,7 +70,7 @@ export function startTelemetry(o) {
68
70
  const env = o.env ?? process.env;
69
71
  const key = o.key ?? TELEMETRY_KEY;
70
72
  const mode = telemetryMode(env, { ...(o.faux ? { faux: true } : {}), key });
71
- const idle = { mode, runEnded: () => { }, close: () => Promise.resolve() };
73
+ const idle = { mode, runEnded: () => { }, used: () => { }, close: () => Promise.resolve() };
72
74
  if (mode !== "on" && mode !== "debug")
73
75
  return idle;
74
76
  const file = join(o.data, TELEMETRY_FILE);
@@ -171,6 +173,12 @@ export function startTelemetry(o) {
171
173
  if (completed && !holding)
172
174
  emit("first_run_completed");
173
175
  },
176
+ used(event) {
177
+ // The notice's start sends nothing before its first heartbeat; a feature used then is not counted at all.
178
+ if (holding || !USAGE_EVENTS.includes(event))
179
+ return;
180
+ emit(event);
181
+ },
174
182
  close: () => (clearInterval(beat), writing ?? Promise.resolve()),
175
183
  };
176
184
  }
@@ -1,13 +1,17 @@
1
- import type { Store } from "./store/index.js";
1
+ import { type Store, UPLOAD_PREFIX } from "./store/index.js";
2
2
  import { type GithubReach } from "./template-source.js";
3
3
  import { type Package, type TemplateRegistry } from "./templates.js";
4
4
  /** The settings key that holds the GitHub accounts this server's owner trusts as publishers, lower-cased. */
5
5
  export declare const TRUSTED_PUBLISHERS = "templates.trusted_publishers";
6
+ /** An uploaded package's id is this and its manifest's name: the next upload of that name replaces it. */
7
+ export { UPLOAD_PREFIX };
6
8
  export type TemplateImportDeps = {
7
9
  registry: TemplateRegistry;
8
10
  store: Pick<Store, "importedTemplates" | "settings">;
9
11
  /** Where GitHub is read (template-source.ts GithubReach): GitHub's hosts and this server's App token when it has one. */
10
12
  reach: (signal: AbortSignal) => Promise<GithubReach>;
13
+ /** The API-only profile: an upload is taken, a GitHub source refused (its backend sends the package). */
14
+ apiOnly?: boolean;
11
15
  };
12
16
  /** An imported package read from its files, checked whole, with its id and origin: PackageError when it does not check. */
13
17
  export declare function importedPackage(id: string, origin: {
@@ -18,14 +22,35 @@ export declare function importedPackage(id: string, origin: {
18
22
  /** The packages the store keeps, put in the registry beside the bundled ones; one this build no longer takes is left out,
19
23
  * said through `skipped`, never a stop of the start. */
20
24
  export declare function loadImported(deps: Pick<TemplateImportDeps, "registry" | "store">, skipped: (id: string, why: string) => void): Promise<void>;
25
+ /** The uploads served here whose row the store no longer keeps (an agent's purge removed it: Agents.purge), no longer
26
+ * served. Only the package read before the store is removed, so an upload put in meanwhile stays served. */
27
+ export declare function dropRemovedUploads(deps: Pick<TemplateImportDeps, "registry" | "store">): Promise<void>;
21
28
  /** POST /v2/templates/import: the package read at its source's commit and checked; a dry run answers it, storing nothing;
22
- * else it is stored and served (201), in place of the one under its id. `signal` ends the read (the request's). */
29
+ * else it is stored and served (201), in place of the one under its id. `signal` ends the read (the request's). An
30
+ * upload ({files}) is uploadTemplate's. */
23
31
  export declare function importTemplate(deps: TemplateImportDeps, raw: unknown, signal: AbortSignal): Promise<{
24
32
  status: 200 | 201;
25
33
  pkg: Package;
26
34
  trusted: boolean;
27
35
  replaced: string | null;
28
36
  }>;
37
+ /** A package made into an agent here as an imported template, from files this server wrote itself (a suggested agent's,
38
+ * suggestions.ts): checked, kept, then applied. Once `apply` has made the agent nothing after it can fail (the registry
39
+ * is in memory), so a thrown error always means no agent was made, which is what Suggestions.create reads it as. An
40
+ * apply refused (a missing model key, say) takes the kept package back as it was before (removed, or the earlier one),
41
+ * but only while the row is still the one this call kept: an import of the same id meanwhile (POST /v2/templates/import)
42
+ * stands. */
43
+ export declare function applyImported<T>(deps: {
44
+ registry: Pick<TemplateRegistry, "put">;
45
+ store: {
46
+ importedTemplates: Pick<Store["importedTemplates"], "list" | "put" | "remove">;
47
+ };
48
+ apply: (pkg: Package) => Promise<T>;
49
+ }, id: string, origin: {
50
+ source: string;
51
+ sha: string;
52
+ publisher: string;
53
+ }, files: ReadonlyMap<string, Buffer>): Promise<T>;
29
54
  /** DELETE /v2/templates/{id}: an imported package removed from the store and the registry. A bundled one is 403; none of
30
55
  * that id, 404. Agents applied from it stay. */
31
56
  export declare function deleteTemplate(deps: Pick<TemplateImportDeps, "registry" | "store">, id: string): Promise<void>;
@@ -1,15 +1,74 @@
1
- // POST /v2/templates/import and the imported packages' life here: read from GitHub (template-source.ts), checked by the one
2
- // checker (templates.ts readPackage, over the files held in memory), stored (store `imported_templates`) and loaded beside
3
- // the bundled packages at each start. The first import stored from a GitHub account needs its owner's "I trust <account>",
4
- // remembered server-side (settings TRUSTED_PUBLISHERS). Nothing in a package runs.
1
+ // POST /v2/templates/import and the imported packages' life here: read from GitHub (template-source.ts), or uploaded whole
2
+ // as its files ({files}, by `agentrun deploy`), checked by the one checker (templates.ts readPackage, over the files held
3
+ // in memory), stored (store `imported_templates`) and loaded beside the bundled packages at each start. The first import
4
+ // stored from a GitHub account needs its owner's "I trust <account>", remembered server-side (settings
5
+ // TRUSTED_PUBLISHERS); an upload needs none, as only this server's owner (its session or its token) sends one, and it
6
+ // goes with the last agent applied from it (store Agents.purge). Nothing in a package runs.
7
+ import { packageSha256 } from "./agent-package.js";
5
8
  import { ApiError, invalid } from "./errors.js";
9
+ import { UPLOAD_PREFIX } from "./store/index.js";
6
10
  import { fetchPackageFiles, ImportRefused, IMPORT_LIMITS, parseSource, resolveSha } from "./template-source.js";
7
- import { memoryFiles, PackageError, readPackage } from "./templates.js";
11
+ import { MANIFEST, manifestName, memoryFiles, PackageError, readPackage } from "./templates.js";
8
12
  import { isObject, unknownFields } from "./validate.js";
9
13
  /** The settings key that holds the GitHub accounts this server's owner trusts as publishers, lower-cased. */
10
14
  export const TRUSTED_PUBLISHERS = "templates.trusted_publishers";
11
- /** The folder name a package's id ends in: its path's last part, else the repository's name (agent.md's `name` is it). */
12
- const nameOf = (id) => id.slice("github:".length).split("/").at(-1);
15
+ /** An uploaded package's id is this and its manifest's name: the next upload of that name replaces it. */
16
+ export { UPLOAD_PREFIX };
17
+ /** The folder name a package's id ends in: an upload's name, else its path's last part, else the repository's name
18
+ * (agent.md's `name` is it). */
19
+ const nameOf = (id) => (id.startsWith(UPLOAD_PREFIX) ? id.slice(UPLOAD_PREFIX.length) : id.slice("github:".length).split("/").at(-1));
20
+ /** An upload's sha: the digest an export names (agent-package.ts packageSha256), which `agentrun deploy` locks. */
21
+ const uploadSha = (files) => packageSha256([...files].map(([path, data]) => ({ path, encoding: "base64", content: data.toString("base64") })));
22
+ const BASE64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
23
+ /** A path part that is not plain, or a character no package path holds (a control character, a backslash). */
24
+ const NOT_PLAIN = (path) => /[\0-\x1f\x7f\\]/.test(path) || path.split("/").some((part) => part === "" || part === "." || part === "..");
25
+ /** An upload's files ({path, encoding, content}) as the package's bytes by path: 422 under files.<i> for one that is not
26
+ * that shape; the GitHub import's own refusals (ImportRefused "package") for a path that is not plain or is there twice,
27
+ * over its count and over the bytes it keeps. */
28
+ function uploadFiles(raw) {
29
+ const shape = "files is a list of {path, encoding, content}: each file of the package, its encoding utf8 or base64";
30
+ if (!Array.isArray(raw) || raw.length === 0)
31
+ throw invalid([{ field: "files", reason: "wrong_type", message: shape }]);
32
+ if (raw.length > IMPORT_LIMITS.files)
33
+ throw new ImportRefused("package", `The package holds over ${IMPORT_LIMITS.files} files.`);
34
+ const issues = [];
35
+ const read = [];
36
+ raw.forEach((one, i) => {
37
+ if (!isObject(one) || typeof one.path !== "string" || typeof one.content !== "string")
38
+ return void issues.push({ field: `files.${i}`, reason: "wrong_type", message: shape });
39
+ for (const issue of unknownFields(one, ["path", "encoding", "content"]))
40
+ issues.push({ ...issue, field: `files.${i}.${issue.field}` });
41
+ if (one.encoding !== "utf8" && one.encoding !== "base64")
42
+ return void issues.push({ field: `files.${i}.encoding`, reason: "not_an_option", message: "encoding is utf8 or base64" });
43
+ if (one.encoding === "base64" && !BASE64.test(one.content))
44
+ return void issues.push({ field: `files.${i}.content`, reason: "invalid", message: `${JSON.stringify(one.path)}'s content is not base64` });
45
+ read.push([one.path, Buffer.from(one.content, one.encoding)]);
46
+ });
47
+ if (issues.length)
48
+ throw invalid(issues);
49
+ const files = new Map();
50
+ let kept = 0;
51
+ for (const [path, data] of read) {
52
+ if (NOT_PLAIN(path))
53
+ throw new ImportRefused("package", `The package holds ${JSON.stringify(path)}, a path that is not plain: refused.`);
54
+ if (files.has(path))
55
+ throw new ImportRefused("package", `The package holds ${JSON.stringify(path)} twice: refused.`);
56
+ kept += data.length;
57
+ if (kept > IMPORT_LIMITS.packageBytes)
58
+ throw new ImportRefused("package", `The package's files are over the ${IMPORT_LIMITS.packageBytes} bytes an import keeps.`);
59
+ files.set(path, data);
60
+ }
61
+ // A path that is a file and a folder's name at once (agent.md and agent.md/x) is no folder a package could be.
62
+ for (const path of files.keys()) {
63
+ const parts = path.split("/");
64
+ for (let end = 1; end < parts.length; end++) {
65
+ const folder = parts.slice(0, end).join("/");
66
+ if (files.has(folder))
67
+ throw new ImportRefused("package", `The package holds ${JSON.stringify(folder)} as a file and as a folder: refused.`);
68
+ }
69
+ }
70
+ return files;
71
+ }
13
72
  /** An imported package read from its files, checked whole, with its id and origin: PackageError when it does not check. */
14
73
  export function importedPackage(id, origin, files) {
15
74
  const read = readPackage(memoryFiles(nameOf(id), `${id}@${origin.sha}`, files));
@@ -28,6 +87,17 @@ export async function loadImported(deps, skipped) {
28
87
  }
29
88
  }
30
89
  }
90
+ /** The uploads served here whose row the store no longer keeps (an agent's purge removed it: Agents.purge), no longer
91
+ * served. Only the package read before the store is removed, so an upload put in meanwhile stays served. */
92
+ export async function dropRemovedUploads(deps) {
93
+ const served = deps.registry.list().filter((pkg) => pkg.origin !== null && pkg.id.startsWith(UPLOAD_PREFIX));
94
+ if (!served.length)
95
+ return;
96
+ const stored = new Set(await deps.store.importedTemplates.ids());
97
+ for (const pkg of served)
98
+ if (!stored.has(pkg.id) && deps.registry.get(pkg.id) === pkg)
99
+ deps.registry.remove(pkg.id);
100
+ }
31
101
  /** Whether `publisher` is one the owner trusts (case-insensitive, as GitHub's account names are). */
32
102
  async function trusted(deps, publisher) {
33
103
  const list = await deps.store.settings.get(TRUSTED_PUBLISHERS);
@@ -64,25 +134,58 @@ function refusalOf(error) {
64
134
  }
65
135
  throw error;
66
136
  }
67
- /** The body POST /v2/templates/import takes, checked: 422 naming each field that is wrong. */
68
- function bodyOf(body) {
69
- const issues = unknownFields(body, ["source", "dry_run", "trust_publisher"]);
137
+ /** The body POST /v2/templates/import takes, checked: 422 naming each field that is wrong. A GitHub source ({source}), or
138
+ * the package's files ({files}, an upload); on an API-only server, the files alone. */
139
+ function bodyOf(body, apiOnly) {
140
+ const issues = unknownFields(body, ["source", "files", "dry_run", "trust_publisher"]);
70
141
  if (body.dry_run !== undefined && typeof body.dry_run !== "boolean")
71
142
  issues.push({ field: "dry_run", reason: "wrong_type", message: "dry_run is true or false" });
72
143
  if (body.trust_publisher !== undefined && typeof body.trust_publisher !== "boolean")
73
144
  issues.push({ field: "trust_publisher", reason: "wrong_type", message: "trust_publisher is true or false" });
74
145
  if (typeof body.source === "string" && body.source.length > 1024)
75
146
  issues.push({ field: "source", reason: "too_long", message: "source is at most 1024 characters" });
147
+ if (body.files !== undefined && body.source !== undefined)
148
+ issues.push({ field: "files", reason: "not_allowed", message: "The body is {source} or {files}: source or files, not both." });
149
+ if (body.files !== undefined && body.trust_publisher !== undefined)
150
+ issues.push({ field: "trust_publisher", reason: "not_allowed", message: "An upload is this server's owner's own package, so an upload asks no publisher's trust: trust_publisher goes with a source alone." });
151
+ if (apiOnly && body.source !== undefined)
152
+ issues.push({ field: "source", reason: "not_allowed", message: "This server serves the API alone: a package is uploaded here as {files}, never read from GitHub." });
76
153
  if (issues.length)
77
154
  throw invalid(issues);
155
+ if (body.files !== undefined)
156
+ return { files: body.files, dryRun: body.dry_run === true };
78
157
  return { source: parseSource(body.source), dryRun: body.dry_run === true, trustPublisher: body.trust_publisher === true };
79
158
  }
159
+ /** An upload: its files checked as an import's are, its id `upload:<name>` (its manifest's name), its sha the package's
160
+ * sha256; a dry run answers it, storing nothing; else it is stored and served (201), in place of the one of its name. */
161
+ async function uploadTemplate(deps, raw, dryRun) {
162
+ let pkg;
163
+ let files;
164
+ try {
165
+ files = uploadFiles(raw);
166
+ const id = `${UPLOAD_PREFIX}${manifestName(files.get(MANIFEST)?.toString("utf8") ?? "") ?? ""}`;
167
+ pkg = importedPackage(id, { source: id, sha: uploadSha(files), publisher: "" }, files);
168
+ }
169
+ catch (error) {
170
+ refusalOf(error);
171
+ }
172
+ const replaced = deps.registry.get(pkg.id)?.origin?.sha ?? null;
173
+ if (dryRun)
174
+ return { status: 200, pkg, trusted: true, replaced };
175
+ await deps.store.importedTemplates.put({ id: pkg.id, source: pkg.origin.source, sha: pkg.origin.sha, publisher: "", files: Object.fromEntries([...files].map(([path, data]) => [path, data.toString("base64")])) });
176
+ deps.registry.put(pkg);
177
+ return { status: 201, pkg, trusted: true, replaced };
178
+ }
80
179
  /** POST /v2/templates/import: the package read at its source's commit and checked; a dry run answers it, storing nothing;
81
- * else it is stored and served (201), in place of the one under its id. `signal` ends the read (the request's). */
180
+ * else it is stored and served (201), in place of the one under its id. `signal` ends the read (the request's). An
181
+ * upload ({files}) is uploadTemplate's. */
82
182
  export async function importTemplate(deps, raw, signal) {
83
183
  if (!isObject(raw))
84
- throw invalid([{ field: "body", reason: "wrong_type", message: "The body is {source, dry_run?, trust_publisher?}." }]);
85
- const { source, dryRun, trustPublisher } = bodyOf(raw);
184
+ throw invalid([{ field: "body", reason: "wrong_type", message: "The body is {source, dry_run?, trust_publisher?} or {files, dry_run?}." }]);
185
+ const body = bodyOf(raw, deps.apiOnly === true);
186
+ if ("files" in body)
187
+ return uploadTemplate(deps, body.files, body.dryRun);
188
+ const { source, dryRun, trustPublisher } = body;
86
189
  const read = AbortSignal.any([signal, AbortSignal.timeout(IMPORT_LIMITS.ms)]);
87
190
  let pkg;
88
191
  let files;
@@ -108,6 +211,38 @@ export async function importTemplate(deps, raw, signal) {
108
211
  deps.registry.put(pkg);
109
212
  return { status: 201, pkg, trusted: true, replaced };
110
213
  }
214
+ /** A package made into an agent here as an imported template, from files this server wrote itself (a suggested agent's,
215
+ * suggestions.ts): checked, kept, then applied. Once `apply` has made the agent nothing after it can fail (the registry
216
+ * is in memory), so a thrown error always means no agent was made, which is what Suggestions.create reads it as. An
217
+ * apply refused (a missing model key, say) takes the kept package back as it was before (removed, or the earlier one),
218
+ * but only while the row is still the one this call kept: an import of the same id meanwhile (POST /v2/templates/import)
219
+ * stands. */
220
+ export async function applyImported(deps, id, origin, files) {
221
+ const pkg = importedPackage(id, origin, files);
222
+ const templates = deps.store.importedTemplates;
223
+ const row = async () => (await templates.list()).find((one) => one.id === pkg.id);
224
+ const before = await row();
225
+ await templates.put({ id: pkg.id, source: origin.source, sha: origin.sha, publisher: origin.publisher, files: Object.fromEntries([...files].map(([path, data]) => [path, data.toString("base64")])) });
226
+ // The row as this call kept it, stamped by the store: the undo below touches it only while it is still this one.
227
+ const kept = await row();
228
+ let made;
229
+ try {
230
+ made = await deps.apply(pkg);
231
+ }
232
+ catch (error) {
233
+ const now = await row().catch(() => undefined);
234
+ const ours = kept !== undefined && now !== undefined && now.importedAt === kept.importedAt && now.sha === kept.sha && now.source === kept.source;
235
+ if (ours) {
236
+ const undo = before
237
+ ? templates.put({ id: before.id, source: before.source, sha: before.sha, publisher: before.publisher, files: before.files })
238
+ : templates.remove(pkg.id).then(() => undefined);
239
+ await undo.catch(() => { });
240
+ }
241
+ throw error;
242
+ }
243
+ deps.registry.put(pkg);
244
+ return made;
245
+ }
111
246
  /** DELETE /v2/templates/{id}: an imported package removed from the store and the registry. A bundled one is 403; none of
112
247
  * that id, 404. Agents applied from it stay. */
113
248
  export async function deleteTemplate(deps, id) {
@@ -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,14 +127,19 @@ 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?: {
129
137
  bash: BashPolicy;
130
138
  };
131
139
  /** What the server checks out in each run's folder before its first turn (the definition's `checkout`,
132
- * runner/pr-checkout.ts): the pull request the run's GitHub event names. */
133
- checkout?: "pull_request";
140
+ * runner/pr-checkout.ts): the pull request the run's GitHub event names, or the default branch of the repository the
141
+ * run names. */
142
+ checkout?: "pull_request" | "repository";
134
143
  /** The setup an apply takes (manifest `parameters`), compiled as `inputs` are (fieldsSchema): a closed object schema,
135
144
  * with no properties when the package names none. */
136
145
  parameters: Json;
@@ -158,6 +167,8 @@ export type Package = {
158
167
  instructions: string;
159
168
  /** Skill files by path under the agent's skills folder (`review/SKILL.md`), each rule beside each SKILL.md. */
160
169
  skills: Record<string, string>;
170
+ /** The names of its rules/ files (each one in `skills` beside every SKILL.md), so an export writes them as rules/ again. */
171
+ rules?: string[];
161
172
  evals: string[];
162
173
  };
163
174
  /** A package that does not check: every problem, each naming its file. */
@@ -275,7 +286,8 @@ export declare function packageView(p: Package): {
275
286
  bash: BashPolicy;
276
287
  } | null;
277
288
  computer: ("none" | "shell")[] | null;
278
- checkout: "pull_request" | null;
289
+ needs: string[] | null;
290
+ checkout: "pull_request" | "repository" | null;
279
291
  mcp: {
280
292
  source: "url" | "github" | "composio";
281
293
  toolkit: string;
@@ -301,79 +313,84 @@ export declare function packageView(p: Package): {
301
313
  skills: string[];
302
314
  evals: string[];
303
315
  };
304
- /** A package as an import answers it: its listing, and every text its agent would be given, the instructions and each
305
- * skill file by path (a rule and the answer's schema beside each SKILL.md among them), so a person reads what a third
306
- * party's package would tell their agent before it is installed. */
307
- export declare function packageDetail(p: Package): {
316
+ /** A package whole, as an import and a read of one answer it: its listing with the computer it would get here
317
+ * (`computerHere`), and every text its agent would be given, the instructions and each skill file by path (a rule and
318
+ * the answer's schema beside each SKILL.md among them), so a person reads what a package would tell their agent before
319
+ * it is applied. */
320
+ export declare function packageDetail<Pick>(p: Package, computerHere: (p: Package) => Pick): {
321
+ template: {
322
+ computer_here: Pick;
323
+ id: string;
324
+ bundled: boolean;
325
+ source: string | null;
326
+ sha: string | null;
327
+ publisher: string | null;
328
+ name: string;
329
+ display_name: string | null;
330
+ version: string;
331
+ description: string;
332
+ license: string | null;
333
+ author: Json | null;
334
+ repository: string | null;
335
+ category: "engineering" | "security" | "sales" | "marketing" | "research" | "finance" | "operations" | "compliance" | "personal" | null;
336
+ tags: string[];
337
+ output: {
338
+ schema: string;
339
+ json_schema: Json | null;
340
+ } | null;
341
+ harness: string[] | null;
342
+ model: {
343
+ choices?: {
344
+ id: string;
345
+ label: string;
346
+ model: string;
347
+ harness: string;
348
+ warning: string | null;
349
+ note: string | null;
350
+ secrets: string[];
351
+ }[] | undefined;
352
+ tier: string;
353
+ prefer?: string;
354
+ fast?: string;
355
+ strong?: string;
356
+ } | null;
357
+ effort: string | null;
358
+ tools: string[] | null;
359
+ tool_policy: {
360
+ bash: BashPolicy;
361
+ } | null;
362
+ computer: ("none" | "shell")[] | null;
363
+ needs: string[] | null;
364
+ checkout: "pull_request" | "repository" | null;
365
+ mcp: {
366
+ source: "url" | "github" | "composio";
367
+ toolkit: string;
368
+ required: boolean;
369
+ reason: string | null;
370
+ tools: {
371
+ pin?: Record<string, PinValue> | undefined;
372
+ name: string;
373
+ tool: string;
374
+ asks: string;
375
+ }[];
376
+ }[];
377
+ parameters: Json;
378
+ input_schema: Json | null;
379
+ secrets: string[];
380
+ budget: {
381
+ per_run_usd: number;
382
+ max_requests?: number;
383
+ } | null;
384
+ learning: LearningSetting;
385
+ approvals_default: "ask" | "never";
386
+ triggers: Json[];
387
+ skills: string[];
388
+ evals: string[];
389
+ };
308
390
  instructions: string;
309
391
  skill_files: {
310
392
  [x: string]: string;
311
393
  };
312
- id: string;
313
- bundled: boolean;
314
- source: string | null;
315
- sha: string | null;
316
- publisher: string | null;
317
- name: string;
318
- display_name: string | null;
319
- version: string;
320
- description: string;
321
- license: string | null;
322
- author: Json | null;
323
- repository: string | null;
324
- category: "engineering" | "security" | "sales" | "marketing" | "research" | "finance" | "operations" | "compliance" | "personal" | null;
325
- tags: string[];
326
- output: {
327
- schema: string;
328
- json_schema: Json | null;
329
- } | null;
330
- harness: string[] | null;
331
- model: {
332
- choices?: {
333
- id: string;
334
- label: string;
335
- model: string;
336
- harness: string;
337
- warning: string | null;
338
- note: string | null;
339
- secrets: string[];
340
- }[] | undefined;
341
- tier: string;
342
- prefer?: string;
343
- fast?: string;
344
- strong?: string;
345
- } | null;
346
- effort: string | null;
347
- tools: string[] | null;
348
- tool_policy: {
349
- bash: BashPolicy;
350
- } | null;
351
- computer: ("none" | "shell")[] | null;
352
- checkout: "pull_request" | null;
353
- mcp: {
354
- source: "url" | "github" | "composio";
355
- toolkit: string;
356
- required: boolean;
357
- reason: string | null;
358
- tools: {
359
- pin?: Record<string, PinValue> | undefined;
360
- name: string;
361
- tool: string;
362
- asks: string;
363
- }[];
364
- }[];
365
- parameters: Json;
366
- input_schema: Json | null;
367
- secrets: string[];
368
- budget: {
369
- per_run_usd: number;
370
- max_requests?: number;
371
- } | null;
372
- learning: LearningSetting;
373
- approvals_default: "ask" | "never";
374
- triggers: Json[];
375
- skills: string[];
376
- evals: string[];
377
394
  };
378
395
  /** The packages this server serves: the ones it ships, read at its start, and the ones imported here (the store keeps
379
396
  * them; the server loads them beside the bundled ones at its start). An id is one package; a bundled one is never
@@ -390,10 +407,12 @@ export declare class TemplateRegistry {
390
407
  /** Whether an imported package of that id was there to remove. */
391
408
  remove(id: string): boolean;
392
409
  }
393
- /** POST /v2/templates/{name}/apply's body (`{parameters, grants?, servers?, overrides?: {model?, choice?, approvals?}, agent_id?}`), checked
410
+ /** POST /v2/templates/{name}/apply's body (`{parameters, grants?, servers?, overrides?: {model?, choice?, approvals?}, agent_id?, revision?, sha?, dry_run?}`), checked
394
411
  * against the package: the parameters as given (a blank one at its default), the MCP tools the owner allows (each one the
395
412
  * package lists, by its gate name), and the model asked for in place of the package's: one of its own (`model`), or one
396
- * of the package's model choices by id (`choice`), never both. 422 naming every field that is wrong. */
413
+ * of the package's model choices by id (`choice`), never both. `revision` (with agent_id) and `sha` are what the caller
414
+ * read: the agent's current revision and the package's sha, each held to them (412 when another). 422 naming every field
415
+ * that is wrong. */
397
416
  export declare function applyBodyOf(p: Package, body: Json): {
398
417
  parameters: Json;
399
418
  grants: string[];
@@ -402,6 +421,9 @@ export declare function applyBodyOf(p: Package, body: Json): {
402
421
  choice?: ModelChoice;
403
422
  approvals?: Approvals;
404
423
  agentId?: string;
424
+ revision?: string;
425
+ sha?: string;
426
+ dryRun: boolean;
405
427
  };
406
428
  /** The model a package's agent gets here, as `{model?, warning?}`: its `prefer` when this server runs it on `harness`
407
429
  * with a key for its provider, else `refused` (preferUnrunnable): apply makes nothing, never the tier's model in its
@@ -431,6 +453,7 @@ export declare function choiceUnrunnable(env: NodeJS.ProcessEnv, choice: ModelCh
431
453
  export type PickedSetting = {
432
454
  kind: string;
433
455
  provider?: string;
456
+ needs?: string[];
434
457
  };
435
458
  /** The shell this server can give an agent now (server.ts shellHere): the computer setting that gives it, the shell
436
459
  * tools a run there has (tools.ts shellTools), and the shell in words; else, `none`, why it has none. */
@@ -454,13 +477,16 @@ export type ComputerPick = {
454
477
  };
455
478
  /** What to do where a package's computer list has no shell to take: in the apply's refusal and its fallback warning. */
456
479
  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.";
480
+ /** What to do where a package that needs programs (`needs`) has no sandbox to take: a Docker box whose image has them. */
481
+ 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.";
457
482
  /** The first entry of a package's computer list (`[shell, none]`) this server meets now, given the shell it has
458
483
  * (`here`): shell, where it has one; none, always (kind none, and no shell tool: a run on the runner in Mode 2 has bash,
459
484
  * so a shell tool is dropped rather than left to it). Undefined for a package with no list (it runs where a new agent
460
485
  * does); `refused`, in words, when no entry is met. The rule is the package's preference alone: nothing here knows a
461
486
  * template. */
462
- export declare function pickComputer(p: Pick<Package, "name" | "computer" | "tools">, here: ShellHere): ComputerPick | {
487
+ export declare function pickComputer(p: Pick<Package, "name" | "computer" | "tools" | "needs">, here: ShellHere): ComputerPick | {
463
488
  refused: string;
489
+ fix?: string;
464
490
  } | undefined;
465
491
  /** The model of each tier a package's subagents run on here (the definition's model_tiers), as `{modelTiers?, warning?}`:
466
492
  * a tier's model the package names (`model.fast`, `model.strong`) when this server runs it on `harness` with a key for its