@parcha/agentrun-serve 0.1.0-beta.56 → 0.1.0-beta.57

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 (275) hide show
  1. package/CHANGELOG.md +229 -0
  2. package/README.md +201 -52
  3. package/dist/acp-package.d.ts +2 -0
  4. package/dist/adapters.d.ts +15 -3
  5. package/dist/adapters.js +17 -6
  6. package/dist/agent-package.d.ts +3 -3
  7. package/dist/agent-package.js +17 -8
  8. package/dist/api-keys.d.ts +76 -0
  9. package/dist/api-keys.js +217 -0
  10. package/dist/api-only.d.ts +17 -5
  11. package/dist/api-only.js +34 -8
  12. package/dist/browser-hold.d.ts +23 -0
  13. package/dist/browser-hold.js +48 -0
  14. package/dist/browser-person.d.ts +3 -0
  15. package/dist/browser-person.js +4 -1
  16. package/dist/chatgpt-plan.d.ts +18 -8
  17. package/dist/chatgpt-plan.js +91 -34
  18. package/dist/claude-login.d.ts +74 -16
  19. package/dist/claude-login.js +215 -56
  20. package/dist/claude-sign-in.d.ts +17 -6
  21. package/dist/claude-sign-in.js +42 -39
  22. package/dist/cli.js +63 -6
  23. package/dist/composio-made.d.ts +4 -0
  24. package/dist/composio-made.js +4 -0
  25. package/dist/composio-preset.d.ts +43 -2
  26. package/dist/composio-preset.js +92 -4
  27. package/dist/computer-held-routes.d.ts +5 -4
  28. package/dist/computer-held-routes.js +29 -8
  29. package/dist/computer-held.d.ts +6 -1
  30. package/dist/computer-held.js +14 -0
  31. package/dist/computer-record.js +4 -2
  32. package/dist/computer-viewer.js +4 -1
  33. package/dist/console/assets/{backend-Boh7tC4i.js → backend-DVhHzJX2.js} +19 -19
  34. package/dist/console/assets/index-Bwn1oTem.css +1 -0
  35. package/dist/console/assets/index-okP-y8PK.js +747 -0
  36. package/dist/console/index.html +2 -2
  37. package/dist/decisions.d.ts +1 -1
  38. package/dist/decisions.js +1 -1
  39. package/dist/docker-host-addresses.d.ts +22 -11
  40. package/dist/docker-host-addresses.js +38 -26
  41. package/dist/env-switch.d.ts +10 -0
  42. package/dist/env-switch.js +33 -2
  43. package/dist/errors.d.ts +1 -0
  44. package/dist/errors.js +2 -0
  45. package/dist/fal-price.d.ts +58 -20
  46. package/dist/fal-price.js +341 -82
  47. package/dist/handed-values.d.ts +43 -1
  48. package/dist/handed-values.js +119 -2
  49. package/dist/harness-archive.d.ts +13 -10
  50. package/dist/harness-archive.js +60 -34
  51. package/dist/harness-check.d.ts +3 -1
  52. package/dist/harness-check.js +25 -46
  53. package/dist/harness-keys.d.ts +73 -27
  54. package/dist/harness-keys.js +194 -61
  55. package/dist/harness-recipe-entry.d.ts +8 -7
  56. package/dist/harness-recipe-entry.js +21 -32
  57. package/dist/harness-recipe.d.ts +38 -25
  58. package/dist/harness-recipe.js +49 -36
  59. package/dist/harness-sign-in.js +12 -23
  60. package/dist/harness-table.d.ts +10 -3
  61. package/dist/harness-table.js +26 -21
  62. package/dist/harness.d.ts +1 -0
  63. package/dist/harness.js +17 -5
  64. package/dist/hosted-search.d.ts +1 -1
  65. package/dist/hosted-search.js +1 -2
  66. package/dist/import-worker.d.ts +4 -2
  67. package/dist/import-worker.js +9 -2
  68. package/dist/in-flight.d.ts +26 -0
  69. package/dist/in-flight.js +52 -0
  70. package/dist/key-refusal.d.ts +9 -4
  71. package/dist/key-refusal.js +107 -25
  72. package/dist/learn/secrets.d.ts +13 -3
  73. package/dist/learn/secrets.js +118 -17
  74. package/dist/learning-cost.d.ts +6 -3
  75. package/dist/learning-cost.js +4 -2
  76. package/dist/link-check.js +1 -1
  77. package/dist/llms.txt +1 -1
  78. package/dist/marketplace.d.ts +77 -0
  79. package/dist/marketplace.js +224 -0
  80. package/dist/mcp-api-only-origins.d.ts +30 -0
  81. package/dist/mcp-api-only-origins.js +57 -0
  82. package/dist/mcp-gateway.d.ts +7 -5
  83. package/dist/mcp-gateway.js +9 -12
  84. package/dist/mcp-secret-writes.js +5 -3
  85. package/dist/mcp-servers-store.d.ts +28 -6
  86. package/dist/mcp-servers-store.js +53 -4
  87. package/dist/media-duration.d.ts +3 -0
  88. package/dist/media-duration.js +90 -9
  89. package/dist/model-form.d.ts +5 -4
  90. package/dist/model-form.js +11 -7
  91. package/dist/model.d.ts +5 -2
  92. package/dist/model.js +9 -5
  93. package/dist/ollama-provider.d.ts +7 -1
  94. package/dist/ollama-provider.js +14 -2
  95. package/dist/openapi.js +178 -27
  96. package/dist/otel/genai.d.ts +65 -0
  97. package/dist/otel/genai.js +116 -0
  98. package/dist/otel/tracer.d.ts +55 -0
  99. package/dist/otel/tracer.js +308 -0
  100. package/dist/page.d.ts +2 -0
  101. package/dist/page.js +3 -1
  102. package/dist/paid-calls.d.ts +1 -32
  103. package/dist/paid-calls.js +4 -39
  104. package/dist/provider.d.ts +9 -0
  105. package/dist/provider.js +50 -3
  106. package/dist/redact/match.d.ts +30 -3
  107. package/dist/redact/match.js +422 -41
  108. package/dist/refusal-words.d.ts +11 -0
  109. package/dist/refusal-words.js +11 -0
  110. package/dist/run-census.d.ts +67 -0
  111. package/dist/run-census.js +240 -0
  112. package/dist/run-computer.d.ts +6 -3
  113. package/dist/run-computer.js +4 -1
  114. package/dist/run-cut.d.ts +15 -6
  115. package/dist/run-cut.js +30 -9
  116. package/dist/run-files.d.ts +3 -0
  117. package/dist/run-files.js +3 -0
  118. package/dist/run-launch.d.ts +12 -1
  119. package/dist/run-launch.js +9 -10
  120. package/dist/run-learning-served.d.ts +2 -0
  121. package/dist/run-model-key.d.ts +8 -0
  122. package/dist/run-model-key.js +31 -1
  123. package/dist/run-reads-over-store.d.ts +24 -6
  124. package/dist/run-reads-over-store.js +67 -23
  125. package/dist/run-recordings.d.ts +5 -1
  126. package/dist/run-recordings.js +39 -14
  127. package/dist/run-timeline-served.d.ts +2 -0
  128. package/dist/run-timeline-served.js +2 -2
  129. package/dist/run-usage.d.ts +1 -0
  130. package/dist/runnable.d.ts +10 -1
  131. package/dist/runnable.js +20 -8
  132. package/dist/runner/adapter-loop.d.ts +11 -0
  133. package/dist/runner/adapter-loop.js +55 -10
  134. package/dist/runner/adapter-run-spec.d.ts +45 -8
  135. package/dist/runner/adapter-run-spec.js +150 -28
  136. package/dist/runner/adapters/pi.js +25 -3
  137. package/dist/runner/beside.js +4 -3
  138. package/dist/runner/big-writes.js +1 -10
  139. package/dist/runner/claim-secrets.d.ts +18 -3
  140. package/dist/runner/claim-secrets.js +35 -6
  141. package/dist/runner/cli-run-spec.d.ts +6 -0
  142. package/dist/runner/cli-run-spec.js +82 -35
  143. package/dist/runner/computer-journal.d.ts +9 -1
  144. package/dist/runner/computer-journal.js +26 -0
  145. package/dist/runner/conformance/harness.js +1 -1
  146. package/dist/runner/feedback-round.js +3 -0
  147. package/dist/runner/harness-loops.d.ts +6 -5
  148. package/dist/runner/harness-loops.js +7 -7
  149. package/dist/runner/held.d.ts +11 -5
  150. package/dist/runner/journal-kinds.d.ts +5 -0
  151. package/dist/runner/journal-kinds.js +5 -0
  152. package/dist/runner/main.js +7 -2
  153. package/dist/runner/mcp-claim.js +30 -3
  154. package/dist/runner/mcp-run.d.ts +12 -0
  155. package/dist/runner/mcp-run.js +12 -5
  156. package/dist/runner/model-route.d.ts +17 -0
  157. package/dist/runner/model-route.js +120 -2
  158. package/dist/runner/run-child-host.d.ts +3 -0
  159. package/dist/runner/run-child-host.js +69 -28
  160. package/dist/runner/run-child.js +5 -2
  161. package/dist/runner/runner.d.ts +14 -3
  162. package/dist/runner/runner.js +129 -33
  163. package/dist/runner/store-port.d.ts +1 -1
  164. package/dist/runner/store-secrets.d.ts +6 -0
  165. package/dist/runner/store-secrets.js +49 -7
  166. package/dist/runner/subagent.js +4 -40
  167. package/dist/runner/workflow-first.d.ts +11 -4
  168. package/dist/runner/workflow-first.js +14 -8
  169. package/dist/runner/workflow-spec.js +3 -2
  170. package/dist/runs-over-store.d.ts +15 -6
  171. package/dist/runs-over-store.js +33 -21
  172. package/dist/scrub-command.d.ts +73 -0
  173. package/dist/scrub-command.js +307 -0
  174. package/dist/secret-cut.d.ts +73 -0
  175. package/dist/secret-cut.js +291 -4
  176. package/dist/secret-rules.d.ts +143 -0
  177. package/dist/secret-rules.js +2564 -0
  178. package/dist/secrets.d.ts +7 -0
  179. package/dist/secrets.js +20 -0
  180. package/dist/server-keys.d.ts +20 -0
  181. package/dist/server-keys.js +25 -6
  182. package/dist/server.d.ts +52 -11
  183. package/dist/server.js +345 -118
  184. package/dist/skills/agentrun-serve/SKILL.md +4 -0
  185. package/dist/store/index.d.ts +1 -1
  186. package/dist/store/index.js +1 -1
  187. package/dist/store/journal/storage.js +1 -1
  188. package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
  189. package/dist/store/schema.d.ts +6 -0
  190. package/dist/store/schema.js +11 -1
  191. package/dist/store/seal.d.ts +6 -1
  192. package/dist/store/seal.js +5 -3
  193. package/dist/store/sqlite/run-launch.d.ts +9 -1
  194. package/dist/store/sqlite/run-launch.js +24 -13
  195. package/dist/store/sqlite/run-patch.d.ts +1 -1
  196. package/dist/store/sqlite/run-patch.js +13 -4
  197. package/dist/store/sqlite/store.js +34 -4
  198. package/dist/store/store.d.ts +43 -2
  199. package/dist/store/store.js +20 -0
  200. package/dist/store-reads/learning.d.ts +6 -3
  201. package/dist/store-reads/learning.js +22 -7
  202. package/dist/store-view.d.ts +3 -0
  203. package/dist/store-view.js +3 -3
  204. package/dist/suggestions.js +3 -2
  205. package/dist/template-eval.d.ts +20 -9
  206. package/dist/template-eval.js +115 -33
  207. package/dist/template-import.d.ts +10 -0
  208. package/dist/template-import.js +16 -7
  209. package/dist/templates.d.ts +10 -2
  210. package/dist/templates.js +28 -8
  211. package/dist/timeline/labels.d.ts +6 -4
  212. package/dist/timeline/labels.js +18 -6
  213. package/dist/timeline/timeline.d.ts +5 -0
  214. package/dist/timeline/timeline.js +14 -8
  215. package/dist/timeline/util.js +1 -1
  216. package/dist/timeline/web-calls.d.ts +26 -9
  217. package/dist/timeline/web-calls.js +124 -37
  218. package/dist/tool-gate.d.ts +42 -3
  219. package/dist/tool-gate.js +66 -5
  220. package/dist/tool-keys-store.d.ts +2 -4
  221. package/dist/tool-keys-store.js +5 -21
  222. package/dist/tool-keys.d.ts +2 -2
  223. package/dist/tool-keys.js +2 -2
  224. package/dist/tool-list.js +1 -1
  225. package/dist/tool-plane.d.ts +2 -2
  226. package/dist/tool-plane.js +35 -33
  227. package/dist/tools.js +13 -7
  228. package/dist/trigger-targets.d.ts +4 -0
  229. package/dist/trigger-targets.js +9 -2
  230. package/dist/triggers.d.ts +67 -4
  231. package/dist/triggers.js +171 -22
  232. package/dist/until.d.ts +3 -0
  233. package/dist/until.js +11 -0
  234. package/dist/web-fake.d.ts +1 -3
  235. package/dist/web-fake.js +7 -18
  236. package/dist/web-fetch.d.ts +6 -72
  237. package/dist/web-fetch.js +11 -265
  238. package/dist/web-run.d.ts +31 -0
  239. package/dist/web-run.js +90 -0
  240. package/dist/web-save.d.ts +6 -4
  241. package/dist/web-save.js +9 -12
  242. package/dist/web-search.d.ts +9 -127
  243. package/dist/web-search.js +23 -259
  244. package/dist/wires.d.ts +13 -0
  245. package/dist/wires.js +11 -0
  246. package/dist/workflow-run.d.ts +5 -4
  247. package/dist/workflow-run.js +5 -4
  248. package/dist/workspace/computer-deps.d.ts +2 -1
  249. package/dist/workspace/computer-deps.js +9 -2
  250. package/dist/workspace/computer-for-claim.d.ts +12 -1
  251. package/dist/workspace/computer-for-claim.js +77 -8
  252. package/dist/workspace/computer-kept.d.ts +3 -0
  253. package/dist/workspace/computer-kept.js +11 -2
  254. package/dist/workspace/index.d.ts +1 -1
  255. package/dist/workspace/index.js +1 -1
  256. package/dist/workspace/kind-skills.d.ts +4 -0
  257. package/dist/workspace/kind-skills.js +9 -0
  258. package/dist/workspace/synced-folder.js +3 -4
  259. package/dist/wrapped.d.ts +13 -5
  260. package/dist/wrapped.js +52 -26
  261. package/package.json +17 -11
  262. package/skills/agentrun-serve/SKILL.md +4 -0
  263. package/templates/README.md +30 -8
  264. package/dist/console/assets/index-CQ3cJRzI.js +0 -746
  265. package/dist/console/assets/index-DKkaS3a0.css +0 -1
  266. package/dist/exa-keyless.d.ts +0 -34
  267. package/dist/exa-keyless.js +0 -118
  268. package/dist/firecrawl-keyless.d.ts +0 -41
  269. package/dist/firecrawl-keyless.js +0 -152
  270. package/dist/keyless-mcp.d.ts +0 -36
  271. package/dist/keyless-mcp.js +0 -127
  272. package/dist/text-urls.d.ts +0 -38
  273. package/dist/text-urls.js +0 -170
  274. package/dist/web-fetch-direct.d.ts +0 -119
  275. package/dist/web-fetch-direct.js +0 -190
@@ -1,15 +1,8 @@
1
- // A recipe's harness entry (HARNESS.md#a-recipe), built once for both of its uses: `agentrun harness-check`, which runs
2
- // it for real and judges it on its keys, and a server that names it (--harness-recipe), whose runs start it the same way
3
- // (serverRoute). Only a single-owner server on its owner's own machine (--harness-sign-in) runs one on its owner's own
4
- // sign-in, handing the agent the folder's path and nothing else. AgentRun never reads, refreshes or sends the agent's
5
- // token (HARNESS.md#sign-in): nothing here opens a file at all.
6
- import { existsSync } from "node:fs";
7
1
  import { ACP_PACKAGE, acpPackage } from "./acp-package.js";
8
- import { ARCHIVE_CODES, archivePlatform, digestOf } from "./harness-archive.js";
2
+ import { archivePlatform } from "./harness-archive.js";
9
3
  import { egressProxy, egressVars } from "./harness-egress.js";
10
- import { installDirOf } from "./harness-install.js";
11
4
  import { HARNESS_KEYS_PAGE, harnessKeysSavedHere, keysLaid } from "./harness-keys.js";
12
- import { checkedOf, loadRecipe, pinnedDigest, pinnedTree, recipeBinaryOf, recipeCheckLine, recipeInstallLine, recipeSignInLine, releaseFor, signedIn, signInHomeOf } from "./harness-recipe.js";
5
+ import { checkedOf, installHolds, recipeBinaryOf, recipeCheckLine, recipeInstall, recipeSignInLine, releaseFor, signedIn, signInHomeOf } from "./harness-recipe.js";
13
6
  import { acpEntryOf } from "./harness-table.js";
14
7
  import { HarnessUnavailable } from "./provider.js";
15
8
  /** A recipe with a sign-in on a server started with --harness-sign-in, whose owner has not signed its agent in on this
@@ -90,7 +83,9 @@ export function recipeEntryOf(options) {
90
83
  recipe: (launch) => acpRecipeFor(recipe, binary, release, options.route(launch.env), { vars: options.vars(), model: launch.model }),
91
84
  proxy: (launch) => {
92
85
  const hostEnv = recipe.model.billing === "proxy" ? (recipe.model.hostEnv ?? "ANTHROPIC_HOST") : "ANTHROPIC_HOST";
93
- const messagesProxy = acp.gooseProxy({ model: launch.model, provider: launch.provider, price: launch.price, log: launch.log, ...(options.fetch ? { fetch: options.fetch } : {}) });
86
+ // The check's recorder, else the route's own fetch for a model it translates (ModuleLaunch.fetch), else the network.
87
+ const forward = options.fetch ?? launch.fetch;
88
+ const messagesProxy = acp.gooseProxy({ model: launch.model, provider: launch.provider, price: launch.price, log: launch.log, ...(forward ? { fetch: forward } : {}) });
94
89
  return async (session) => {
95
90
  // The proxy's own address, under the recipe's variable, beside the key that opens it alone (never a provider's).
96
91
  const started = await messagesProxy(session);
@@ -110,21 +105,20 @@ export function recipeEntryOf(options) {
110
105
  }, host);
111
106
  return options.hidden && entry.hidden === undefined ? Object.freeze({ ...entry, hidden: options.hidden }) : entry;
112
107
  }
113
- /** The entry of the recipe at `file` on a server whose data directory is `data` (harness-table.ts HARNESS_RECIPES_ENV),
114
- * loaded under its five rules when the table is (a refused one refuses the start, in words). It runs only on the
115
- * install its owner made and checked: hidden, and each run refused, with the command that fixes it, until the binary
116
- * and every file beside it are the pinned ones and a harness-check passed for this very recipe, binary and tree
117
- * (HARNESS_NOT_CHECKED). Each start of its agent checks the binary and the tree against their pins again. It runs on
108
+ /** The entry of the recipe `loaded` (loadRecipe: read once, so the entry and the digest its keys are bound to are of the
109
+ * same bytes) on a server whose data directory is `data` (harness-table.ts HARNESS_RECIPES_ENV), loaded under its five
110
+ * rules when the table is (a refused one refuses the start, in words). It runs only on the
111
+ * install its owner made and checked: hidden, and each run refused, with the command that fixes it, until a harness-check
112
+ * passed for this very recipe and this install's tree, the binary among it (HARNESS_NOT_CHECKED). Each start of its
113
+ * agent digests the tree again and holds it to its pin (harness-recipe.ts installHolds). It runs on
118
114
  * the route serverRoute gives, its owner's sign-in only where `signIn` (--harness-sign-in). */
119
- export function recipeServerEntry(file, data, { signIn = false } = {}) {
120
- const loaded = loadRecipe(file);
115
+ export function recipeServerEntry(loaded, data, { signIn = false } = {}) {
121
116
  const { recipe } = loaded;
122
117
  const platform = archivePlatform();
123
118
  const release = releaseFor(recipe, platform);
124
119
  if (!platform || !release)
125
120
  throw new Error(`harness recipe ${loaded.file}: ${recipe.label} ${recipe.release.version} has no release for ${platform ?? `${process.platform}-${process.arch}`}`);
126
121
  const binary = recipeBinaryOf(data, recipe, release);
127
- const installed = installDirOf(data, recipe.id);
128
122
  // What the server's listing, offers and checks read (`why`, and the adapter built as a probe): the keys route when its
129
123
  // server holds every one saved on this data directory (harnessKeysSavedHere), whose claims lay them. An agent's start
130
124
  // reads only what its claim laid (`start`): never what the server lists, which a removal can have outrun, nor the
@@ -132,14 +126,13 @@ export function recipeServerEntry(file, data, { signIn = false } = {}) {
132
126
  const route = (env) => serverRoute(recipe, loaded.file, data, env, { signIn, saved: harnessKeysSavedHere(data, recipe.id) });
133
127
  const start = (env) => serverRoute(recipe, loaded.file, data, env, { signIn });
134
128
  /** Why it cannot run on `env`, in words that end with the command that fixes it; undefined when it can. Nothing is
135
- * digested here (each start is, beforeStart): the pins and the check's note are compared. */
129
+ * digested here (each start is, beforeStart): the tree pin and the check's note are compared. */
136
130
  const why = (env) => {
137
- const pin = pinnedDigest(data, recipe, release, platform);
138
- const tree = pinnedTree(data, recipe, release, platform);
139
- if (!existsSync(binary) || !pin || !tree)
140
- return `HARNESS_NOT_INSTALLED: ${recipe.label} ${recipe.release.version} is not installed in ${installed}. Install it with: ${recipeInstallLine(loaded.file, data, env)}`;
131
+ const install = recipeInstall(data, recipe, loaded.file, env, platform);
132
+ if ("code" in install)
133
+ return `${install.code}: ${install.message}`;
141
134
  const checked = checkedOf(data, recipe.id);
142
- if (!checked || checked.recipe !== loaded.sha256 || checked.binary !== pin.sha256 || checked.tree !== tree.sha256 || checked.platform !== platform) {
135
+ if (!checked || checked.recipe !== loaded.sha256 || checked.tree !== install.tree.sha256 || checked.platform !== platform) {
143
136
  return `${HARNESS_NOT_CHECKED}: ${recipe.label} runs on this server once harness-check passes for this recipe and this install${checked ? " (the recipe or its install changed since the last check that passed)" : ""}. Check it with: ${recipeCheckLine(loaded.file, data, env)}`;
144
137
  }
145
138
  const on = route(env);
@@ -169,14 +162,10 @@ export function recipeServerEntry(file, data, { signIn = false } = {}) {
169
162
  },
170
163
  // The binary and every file beside it, digested again before each start: one swapped since the check never runs.
171
164
  beforeStart: async (command) => {
172
- const pin = pinnedDigest(data, recipe, release, platform);
173
- const tree = pinnedTree(data, recipe, release, platform);
174
- const now = await digestOf(command).catch(() => undefined);
175
- if (!pin || now !== pin.sha256)
176
- throw new Error(`${ARCHIVE_CODES.binary}: ${command} has sha256 ${now ?? "(unreadable)"}, not its pin's. Install it again with: ${recipeInstallLine(loaded.file, data)}`);
177
- const files = await acpPackage().treeDigest(installed).catch(() => undefined);
178
- if (!tree || files !== tree.sha256)
179
- throw new Error(`${ARCHIVE_CODES.binary}: the files beside ${command} have the tree sha256 ${files ?? "(unreadable)"}, not their pin's. Install it again with: ${recipeInstallLine(loaded.file, data)}`);
165
+ const install = recipeInstall(data, recipe, loaded.file, process.env, platform);
166
+ const off = "code" in install ? install : await installHolds(install);
167
+ if (off)
168
+ throw new Error(`${off.code}: ${command} does not start: ${off.message}`);
180
169
  },
181
170
  missing: async (env) => {
182
171
  const lacks = why(env);
@@ -127,30 +127,44 @@ export declare const releaseFor: (recipe: Recipe, platform?: string | undefined)
127
127
  export declare const recipeInstallLine: (file: string, data: string, env?: NodeJS.ProcessEnv) => string;
128
128
  /** Where the recipe's binary is once installed: `<data>/harnesses/<id>/<cmd>`. */
129
129
  export declare const recipeBinaryOf: (data: string, recipe: Recipe, release: RecipeArchive) => string;
130
- /** Where the first sha256 of a binary the recipe does not pin is kept: beside the harnesses' folders, never inside the
131
- * one an install replaces, so a reinstall that unpacks a different binary is seen. One per id, version and platform. */
132
- export declare const firstSeenOf: (data: string, recipe: Recipe, platform: string) => string;
133
130
  /** A first-seen digest record in a file of its own (one line, the sha256), written once and never over another's. */
134
131
  export declare function firstSeenRecord(file: string): {
135
132
  read(): string | undefined;
136
133
  write(sha256: string): void;
137
134
  };
138
- /** Where the first digest of every file the archive unpacked to (acp's treeDigest) is kept, for a recipe that pins no
139
- * treeSha256: beside the binary's (firstSeenOf), so a second executable beside the binary (Antigravity's sidecar) is held
140
- * to its first install as the binary is. */
135
+ /** Where the first digest of every file the archive unpacked to (acp's treeDigest), the binary among them, is kept for a
136
+ * recipe that pins no treeSha256: beside the harnesses' folders, never inside the one an install replaces, so a
137
+ * reinstall that unpacks another binary or sidecar (Antigravity's) is seen. One per id, version and platform. */
141
138
  export declare const firstSeenTreeOf: (data: string, recipe: Recipe, platform: string) => string;
142
- /** The sha256 the installed binary must have: the recipe's pin, else the first one its install recorded; undefined when it
143
- * pins none and none was recorded (never installed by the owner's command). */
144
- export declare function pinnedDigest(data: string, recipe: Recipe, release: RecipeArchive, platform: string): {
145
- sha256: string;
146
- by: "recipe" | "first-seen";
147
- } | undefined;
148
- /** The digest every file of the install must have together (treeDigest): the recipe's treeSha256, else the first one its
149
- * install recorded; undefined when neither is there (an install from before trees were recorded, or none at all). */
150
- export declare function pinnedTree(data: string, recipe: Recipe, release: RecipeArchive, platform: string): {
151
- sha256: string;
152
- by: "recipe" | "first-seen";
153
- } | undefined;
139
+ /** A recipe's install on `data` as every reader holds it (harness-check, `harness sign-in`, a server's entry and each of
140
+ * its starts): its release for `platform`, its binary and folder, the owner's command that installs it (`line`), and the
141
+ * digest every file in the folder must have together (treeDigest, the binary among them): the recipe's treeSha256, else
142
+ * the first one its install recorded. Nothing is downloaded. */
143
+ export type RecipeInstall = {
144
+ readonly platform: string;
145
+ readonly release: RecipeArchive;
146
+ readonly binary: string;
147
+ readonly dir: string;
148
+ readonly line: string;
149
+ readonly tree: {
150
+ readonly sha256: string;
151
+ readonly by: "recipe" | "first-seen";
152
+ };
153
+ };
154
+ /** Why a recipe's install does not run, by code, in words that end with the command that fixes it. */
155
+ export type InstallRefusal = {
156
+ readonly code: string;
157
+ readonly message: string;
158
+ };
159
+ /** The recipe's install (RecipeInstall), or why there is none to hold: no release for the platform, nothing installed, or
160
+ * an install from before every file beside its binary was recorded. */
161
+ export declare function recipeInstall(data: string, recipe: Recipe, file: string, env?: NodeJS.ProcessEnv, platform?: string | undefined): RecipeInstall | InstallRefusal;
162
+ /** Whether every file of the install is still its tree's (RecipeInstall), digested now: undefined, or the refusal
163
+ * (HARNESS_BINARY_MISMATCH; HARNESS_NOT_INSTALLED where the ACP adapter that takes the digest is not beside this server).
164
+ * The tree digest holds a link by its target's name, never the file it leads to, so a folder with a link out of it
165
+ * (linkOutOf: the executable behind a linked folder, code it loads from elsewhere) is refused: those bytes would be
166
+ * checked by nothing. */
167
+ export declare function installHolds(install: RecipeInstall): Promise<InstallRefusal | undefined>;
154
168
  /** The folder the agent keeps its owner's sign-in in (given by signIn.homeArg on `agentrun harness sign-in` and on every
155
169
  * run on that sign-in): `<data>/harnesses/<id>.sign-in`, 0700, beside the install and never inside it (a reinstall keeps
156
170
  * the sign-in). The agent alone writes and reads what is in it: AgentRun hands it the path, and never lists, opens,
@@ -164,13 +178,12 @@ export declare const recipeSignInLine: (file: string, data: string, env?: NodeJS
164
178
  /** Whether the agent's own sign-in ended well on `data` (signedInNoteOf): nothing in its folder is read to say so.
165
179
  * Whether the sign-in still holds is the agent's to say when it runs (an ACP -32000, Authentication required). */
166
180
  export declare const signedIn: (data: string, recipe: Recipe) => boolean;
167
- /** What a passing harness-check proved, by digest: the recipe file, the binary and every file beside it, on `platform`. A
168
- * server runs the recipe only while all three are still these (harness-recipe-entry.ts). */
181
+ /** What a passing harness-check proved, by digest: the recipe file (its version in it) and every file of the install, the
182
+ * binary among them, on `platform`. A server runs the recipe only while all three are still these
183
+ * (harness-recipe-entry.ts). */
169
184
  export type RecipeChecked = {
170
185
  readonly recipe: string;
171
- readonly binary: string;
172
186
  readonly tree: string;
173
- readonly version: string;
174
187
  readonly platform: string;
175
188
  };
176
189
  /** AgentRun's own note of the last harness-check that passed for the recipe `id` on `data`: `<data>/harnesses/<id>.checked`,
@@ -181,9 +194,9 @@ export declare function writeChecked(data: string, id: string, checked: RecipeCh
181
194
  /** The note of the last check that passed for `id` on `data`, or undefined where there is none or it is not one. */
182
195
  export declare function checkedOf(data: string, id: string): RecipeChecked | undefined;
183
196
  /** Installs the recipe's release into `<data>/harnesses/<id>` (the owner's command, rule 4): its archive downloaded and
184
- * checked against the recipe's sha256, unpacked, and its binary checked against the recipe's pin, or recorded as the
185
- * first one seen where the recipe pins none (a later one that differs is refused). Every file beside it the same way: the
186
- * recipe's treeSha256, else the first tree digest recorded, so nothing in the archive runs unpinned. */
197
+ * checked against the recipe's sha256, unpacked, its binary checked against the recipe's binarySha256 where it pins one,
198
+ * and every file it unpacked to, the binary among them, held to the recipe's treeSha256, else recorded as the first tree
199
+ * seen (a later one that differs is refused), so nothing in the archive runs unpinned. */
187
200
  export declare function installRecipe(recipe: Recipe, file: string, data: string, options?: ArchiveInstallOptions, env?: NodeJS.ProcessEnv): Promise<{
188
201
  installed: "already" | "now";
189
202
  binary: string;
@@ -3,12 +3,12 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { createHash } from "node:crypto";
4
4
  import { isAbsolute, join, normalize, resolve, sep } from "node:path";
5
5
  import { HARNESS_ID_PATTERN, RESERVED_HARNESS_IDS } from "./harness.js";
6
- import { ARCHIVE_FORMATS, archivePlatform, installArchive } from "./harness-archive.js";
6
+ import { ARCHIVE_CODES, ARCHIVE_FORMATS, archivePlatform, installArchive, linkOutOf } from "./harness-archive.js";
7
7
  import { BUILTIN_HARNESS_IDS } from "./harness-table.js";
8
8
  import { commandData } from "./harness-owned.js";
9
9
  import { harnessesOf, installDirOf, shellWord } from "./harness-install.js";
10
10
  import { ENV_NAME, KEY_NAME, launchEnv } from "@parcha/agentrun-kernel";
11
- import { acpPackage } from "./acp-package.js";
11
+ import { ACP_PACKAGE, acpPackage } from "./acp-package.js";
12
12
  import { keyShaped, SECRET_SEGMENTS } from "./secret-name.js";
13
13
  import { SECRET_NAMES } from "./secrets.js";
14
14
  /** The codes a refused recipe carries, one per rule, and one for a file that is not a recipe at all. */
@@ -37,8 +37,6 @@ export const AGENT_VARS = Object.freeze({
37
37
  reserved: Object.freeze(["HOME", "TMPDIR", "XDG_CONFIG_HOME", "XDG_DATA_HOME", "XDG_CACHE_HOME", "XDG_STATE_HOME", "GIT_CEILING_DIRECTORIES"]),
38
38
  proxy: Object.freeze([...PROXY_HOST_ENVS, "ANTHROPIC_API_KEY"]),
39
39
  });
40
- /** A sign-in method's id as an agent lists it (keyMethod's `gemini-api-key`). */
41
- const SIGN_IN_METHOD = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
42
40
  /** A long flag as signIn.homeArg names one (`--gemini-dir`): its value is the next argument, never after an `=`. */
43
41
  const LONG_FLAG = /^--[a-z0-9][a-z0-9-]{0,63}$/;
44
42
  /** `items` in a sentence: `a`, `a and b`, `a, b and c`. */
@@ -228,7 +226,9 @@ export function recipeProblems(parsed) {
228
226
  handed.add(env);
229
227
  }
230
228
  }
231
- if (r.keyMethod !== undefined && (typeof r.keyMethod !== "string" || !SIGN_IN_METHOD.test(r.keyMethod)))
229
+ // A sign-in method's id: the ACP package's AUTH_METHOD, the one definition, unchecked in form without it (as model.id).
230
+ const methodId = acpPackage()?.AUTH_METHOD;
231
+ if (r.keyMethod !== undefined && (typeof r.keyMethod !== "string" || (methodId !== undefined && !methodId.test(r.keyMethod))))
232
232
  say(RECIPE_CODES.invalid, "keyMethod, when given, is the sign-in method's id the agent's initialize lists for its key (gemini-api-key)");
233
233
  else if (r.keyMethod !== undefined && !entries?.length)
234
234
  say(RECIPE_CODES.invalid, "keyMethod is the method the agent signs in with on its keys: name them in keys");
@@ -396,9 +396,6 @@ export const releaseFor = (recipe, platform = archivePlatform()) => (platform ?
396
396
  export const recipeInstallLine = (file, data, env = process.env) => `agentrun harness install --recipe ${shellWord(file)}${resolve(data) === commandData(env) ? "" : ` --data ${shellWord(data)}`}`;
397
397
  /** Where the recipe's binary is once installed: `<data>/harnesses/<id>/<cmd>`. */
398
398
  export const recipeBinaryOf = (data, recipe, release) => join(installDirOf(data, recipe.id), insideHome(release.cmd));
399
- /** Where the first sha256 of a binary the recipe does not pin is kept: beside the harnesses' folders, never inside the
400
- * one an install replaces, so a reinstall that unpacks a different binary is seen. One per id, version and platform. */
401
- export const firstSeenOf = (data, recipe, platform) => join(harnessesOf(data), ".first-seen", `${recipe.id}@${recipe.release.version}-${platform}.sha256`);
402
399
  /** A first-seen digest record in a file of its own (one line, the sha256), written once and never over another's. */
403
400
  export function firstSeenRecord(file) {
404
401
  return {
@@ -416,25 +413,43 @@ export function firstSeenRecord(file) {
416
413
  },
417
414
  };
418
415
  }
419
- /** Where the first digest of every file the archive unpacked to (acp's treeDigest) is kept, for a recipe that pins no
420
- * treeSha256: beside the binary's (firstSeenOf), so a second executable beside the binary (Antigravity's sidecar) is held
421
- * to its first install as the binary is. */
416
+ /** Where the first digest of every file the archive unpacked to (acp's treeDigest), the binary among them, is kept for a
417
+ * recipe that pins no treeSha256: beside the harnesses' folders, never inside the one an install replaces, so a
418
+ * reinstall that unpacks another binary or sidecar (Antigravity's) is seen. One per id, version and platform. */
422
419
  export const firstSeenTreeOf = (data, recipe, platform) => join(harnessesOf(data), ".first-seen", `${recipe.id}@${recipe.release.version}-${platform}.tree.sha256`);
423
- /** The sha256 the installed binary must have: the recipe's pin, else the first one its install recorded; undefined when it
424
- * pins none and none was recorded (never installed by the owner's command). */
425
- export function pinnedDigest(data, recipe, release, platform) {
426
- if (release.binarySha256)
427
- return { sha256: release.binarySha256, by: "recipe" };
428
- const recorded = firstSeenRecord(firstSeenOf(data, recipe, platform)).read();
429
- return recorded ? { sha256: recorded, by: "first-seen" } : undefined;
420
+ /** The recipe's install (RecipeInstall), or why there is none to hold: no release for the platform, nothing installed, or
421
+ * an install from before every file beside its binary was recorded. */
422
+ export function recipeInstall(data, recipe, file, env = process.env, platform = archivePlatform()) {
423
+ const release = releaseFor(recipe, platform);
424
+ if (!platform || !release)
425
+ return { code: "HARNESS_PLATFORM_UNSUPPORTED", message: `${recipe.label} ${recipe.release.version} has no release for ${platform ?? `${process.platform}-${process.arch}`}` };
426
+ const dir = installDirOf(data, recipe.id);
427
+ const binary = recipeBinaryOf(data, recipe, release);
428
+ const line = recipeInstallLine(file, data, env);
429
+ const recorded = release.treeSha256 ? undefined : firstSeenRecord(firstSeenTreeOf(data, recipe, platform)).read();
430
+ const tree = release.treeSha256 ? { sha256: release.treeSha256, by: "recipe" } : recorded ? { sha256: recorded, by: "first-seen" } : undefined;
431
+ if (!existsSync(binary))
432
+ return { code: "HARNESS_NOT_INSTALLED", message: `${recipe.label} ${recipe.release.version} is not installed in ${dir}. Install it with: ${line}` };
433
+ if (!tree)
434
+ return { code: "HARNESS_NOT_INSTALLED", message: `${recipe.label} ${recipe.release.version}'s files in ${dir} were never recorded by its install, so they cannot be checked. Install it again with: ${line}` };
435
+ return { platform, release, binary, dir, line, tree };
430
436
  }
431
- /** The digest every file of the install must have together (treeDigest): the recipe's treeSha256, else the first one its
432
- * install recorded; undefined when neither is there (an install from before trees were recorded, or none at all). */
433
- export function pinnedTree(data, recipe, release, platform) {
434
- if (release.treeSha256)
435
- return { sha256: release.treeSha256, by: "recipe" };
436
- const recorded = firstSeenRecord(firstSeenTreeOf(data, recipe, platform)).read();
437
- return recorded ? { sha256: recorded, by: "first-seen" } : undefined;
437
+ /** Whether every file of the install is still its tree's (RecipeInstall), digested now: undefined, or the refusal
438
+ * (HARNESS_BINARY_MISMATCH; HARNESS_NOT_INSTALLED where the ACP adapter that takes the digest is not beside this server).
439
+ * The tree digest holds a link by its target's name, never the file it leads to, so a folder with a link out of it
440
+ * (linkOutOf: the executable behind a linked folder, code it loads from elsewhere) is refused: those bytes would be
441
+ * checked by nothing. */
442
+ export async function installHolds(install) {
443
+ const acp = acpPackage();
444
+ if (!acp)
445
+ return { code: "HARNESS_NOT_INSTALLED", message: `the ACP adapter (${ACP_PACKAGE}) is not installed beside this server` };
446
+ const outward = await linkOutOf(install.dir).catch(() => "(unreadable)");
447
+ if (outward !== undefined)
448
+ return { code: ARCHIVE_CODES.binary, message: `${install.dir} holds a link that leads outside it (${outward}), so the digest of its files does not hold what it leads to. Install it again with: ${install.line}` };
449
+ const found = await acp.treeDigest(install.dir).catch(() => undefined);
450
+ if (found === install.tree.sha256)
451
+ return undefined;
452
+ return { code: ARCHIVE_CODES.binary, message: `${install.dir} has the tree sha256 ${found ?? "(unreadable)"}, and ${install.tree.by === "recipe" ? "the recipe pins" : "its first install recorded"} ${install.tree.sha256}. Install it again with: ${install.line}` };
438
453
  }
439
454
  /** The folder the agent keeps its owner's sign-in in (given by signIn.homeArg on `agentrun harness sign-in` and on every
440
455
  * run on that sign-in): `<data>/harnesses/<id>.sign-in`, 0700, beside the install and never inside it (a reinstall keeps
@@ -461,7 +476,7 @@ export function writeChecked(data, id, checked) {
461
476
  export function checkedOf(data, id) {
462
477
  try {
463
478
  const note = JSON.parse(readFileSync(checkedNoteOf(data, id), "utf8"));
464
- const fields = ["recipe", "binary", "tree", "version", "platform"];
479
+ const fields = ["recipe", "tree", "platform"];
465
480
  return fields.every((field) => typeof note[field] === "string") ? Object.fromEntries(fields.map((field) => [field, note[field]])) : undefined;
466
481
  }
467
482
  catch {
@@ -469,20 +484,18 @@ export function checkedOf(data, id) {
469
484
  }
470
485
  }
471
486
  /** Installs the recipe's release into `<data>/harnesses/<id>` (the owner's command, rule 4): its archive downloaded and
472
- * checked against the recipe's sha256, unpacked, and its binary checked against the recipe's pin, or recorded as the
473
- * first one seen where the recipe pins none (a later one that differs is refused). Every file beside it the same way: the
474
- * recipe's treeSha256, else the first tree digest recorded, so nothing in the archive runs unpinned. */
487
+ * checked against the recipe's sha256, unpacked, its binary checked against the recipe's binarySha256 where it pins one,
488
+ * and every file it unpacked to, the binary among them, held to the recipe's treeSha256, else recorded as the first tree
489
+ * seen (a later one that differs is refused), so nothing in the archive runs unpinned. */
475
490
  export async function installRecipe(recipe, file, data, options = {}, env = process.env) {
476
491
  const platform = options.platform ?? archivePlatform();
477
492
  const release = releaseFor(recipe, platform);
478
- const record = platform ? firstSeenRecord(firstSeenOf(data, recipe, platform)) : undefined;
479
- const binary = release && !release.binarySha256 && record ? { binaryRecord: record } : {};
480
493
  const acp = acpPackage();
481
- const trees = release && !release.treeSha256 && platform && acp ? { treeRecord: firstSeenRecord(firstSeenTreeOf(data, recipe, platform)) } : {};
482
- const before = release && !release.binarySha256 ? record?.read() : undefined;
483
- const done = await installArchive({ id: recipe.id, label: recipe.label, retry: recipeInstallLine(file, data, env), pin: { version: recipe.release.version, archives: recipe.release.archives }, ...(acp ? { tree: (root) => acp.treeDigest(root) } : {}) }, installDirOf(data, recipe.id), { ...options, ...binary, ...trees });
484
- // What the binary was held to: the recipe's pin, the first digest an earlier install recorded, or this one's, recorded now.
485
- const pinnedBy = release?.binarySha256 ? "recipe" : before ? "first-seen" : "recorded";
494
+ const record = release && !release.treeSha256 && platform && acp ? firstSeenRecord(firstSeenTreeOf(data, recipe, platform)) : undefined;
495
+ const before = record?.read();
496
+ const done = await installArchive({ id: recipe.id, label: recipe.label, retry: recipeInstallLine(file, data, env), pin: { version: recipe.release.version, archives: recipe.release.archives }, ...(acp ? { tree: (root) => acp.treeDigest(root) } : {}) }, installDirOf(data, recipe.id), { ...options, ...(record ? { treeRecord: record } : {}) });
497
+ // What its files were held to: the recipe's tree pin, the first tree an earlier install recorded, or this one's, recorded now.
498
+ const pinnedBy = release?.treeSha256 ? "recipe" : before ? "first-seen" : "recorded";
486
499
  return { version: recipe.release.version, pinnedBy, ...done };
487
500
  }
488
501
  /** The owner's command that checks the recipe at `file`, installed into `data`. */
@@ -7,13 +7,11 @@
7
7
  // the folder, and judges the sign-in by the agent's exit status alone. AgentRun never reads, refreshes or sends the
8
8
  // sign-in (HARNESS.md#sign-in).
9
9
  import { spawn } from "node:child_process";
10
- import { chmodSync, existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
10
+ import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
11
11
  import { tmpdir } from "node:os";
12
12
  import { join } from "node:path";
13
- import { ACP_PACKAGE, acpPackage } from "./acp-package.js";
14
- import { ARCHIVE_CODES, archivePlatform, digestOf } from "./harness-archive.js";
15
- import { installDirOf } from "./harness-install.js";
16
- import { AGENT_VARS, loadRecipe, pinnedDigest, pinnedTree, recipeBinaryOf, recipeInstallLine, RecipeRefused, releaseFor, signedInNoteOf, signInHomeOf } from "./harness-recipe.js";
13
+ import { archivePlatform } from "./harness-archive.js";
14
+ import { AGENT_VARS, installHolds, loadRecipe, recipeInstall, RecipeRefused, signedInNoteOf, signInHomeOf } from "./harness-recipe.js";
17
15
  /** A recipe with no signIn: it runs on its keys alone, and has nothing to sign in. */
18
16
  export const HARNESS_NO_SIGN_IN = "HARNESS_NO_SIGN_IN";
19
17
  /** The agent's own sign-in did not end well: its exit status, a signal, or the time ran out. */
@@ -39,24 +37,15 @@ export async function signInHarness(options) {
39
37
  const { recipe, file } = loaded;
40
38
  if (!recipe.signIn)
41
39
  return refuse(HARNESS_NO_SIGN_IN, `${recipe.label}'s recipe names no signIn: it runs on its keys (${recipe.keys.join(", ") || "none"}), and has nothing to sign in`);
42
- // The installed binary and every file beside it, the pinned ones, as a check finds them: nothing is downloaded here.
43
- const platform = options.platform ?? archivePlatform();
44
- const release = releaseFor(recipe, platform);
45
- if (!platform || !release)
46
- return refuse("HARNESS_PLATFORM_UNSUPPORTED", `${recipe.label} ${recipe.release.version} has no release for ${platform ?? `${process.platform}-${process.arch}`}`);
47
- const line = recipeInstallLine(file, options.data, options.env);
48
- const binary = recipeBinaryOf(options.data, recipe, release);
49
- const pin = pinnedDigest(options.data, recipe, release, platform);
50
- const treePin = pinnedTree(options.data, recipe, release, platform);
51
- if (!existsSync(binary) || !pin || !treePin)
52
- return refuse("HARNESS_NOT_INSTALLED", `${recipe.label} ${recipe.release.version} is not installed in ${installDirOf(options.data, recipe.id)}. Install it with: ${line}`);
53
- const acp = acpPackage();
54
- if (!acp)
55
- return refuse("HARNESS_NOT_INSTALLED", `the ACP adapter (${ACP_PACKAGE}) beside this server is not installed`);
56
- const found = await digestOf(binary).catch(() => undefined);
57
- const tree = await acp.treeDigest(installDirOf(options.data, recipe.id)).catch(() => undefined);
58
- if (found !== pin.sha256 || tree !== treePin.sha256)
59
- return refuse(ARCHIVE_CODES.binary, `${recipe.label}'s installed files are not the pinned ones. Install it again with: ${line}`);
40
+ // The installed binary and every file beside it, the pinned ones, as a check finds them (recipeInstall, installHolds):
41
+ // nothing is downloaded here.
42
+ const install = recipeInstall(options.data, recipe, file, options.env, options.platform ?? archivePlatform());
43
+ if ("code" in install)
44
+ return refuse(install.code, install.message);
45
+ const off = await installHolds(install);
46
+ if (off)
47
+ return refuse(off.code, off.message);
48
+ const { release, binary } = install;
60
49
  const home = signInHomeOf(options.data, recipe.id);
61
50
  mkdirSync(home, { recursive: true, mode: 0o700 });
62
51
  chmodSync(home, 0o700);
@@ -102,6 +102,10 @@ export interface ModuleLaunch {
102
102
  readonly credential: () => string | Promise<string>;
103
103
  readonly auth?: "bearer" | "x-api-key";
104
104
  };
105
+ /** What the session's proxy forwards with, for a model the route translates onto the harness's wire (an Ollama model on
106
+ * Anthropic's Messages: provider.ts routedProvider): the route's own fetch, answering at `provider.origin`. A module
107
+ * hands it to its model proxy (startModelProxy's `fetch`); absent, the network. */
108
+ readonly fetch?: typeof fetch;
105
109
  readonly price: (model: string, usage: {
106
110
  input: number;
107
111
  output: number;
@@ -229,14 +233,17 @@ export declare function harnessTable(env: NodeJS.ProcessEnv): Readonly<Record<st
229
233
  * that user, never a slot's; and a plan-billed one runs on keys saved for it or, for a person's run alone, its owner's
230
234
  * own sign-in (harness-recipe-entry.ts serverRoute). */
231
235
  export declare const recipeHarness: (env: NodeJS.ProcessEnv, id: string) => "proxy" | "plan" | undefined;
232
- /** A harness on `env`'s table whose keys are saved for it alone (harness-keys.ts): a recipe billed to its vendor's plan. */
236
+ /** A harness on `env`'s table whose keys are saved for it alone (harness-keys.ts): a recipe billed to its vendor's plan.
237
+ * `digest`: its recipe file's sha256 as loaded, which each key saved for it is bound to, so a later file of the same id
238
+ * (another agent, another vendor) never opens them. */
233
239
  export type PlanRecipe = {
234
240
  readonly id: string;
235
241
  readonly label: string;
236
242
  readonly keys: readonly string[];
243
+ readonly digest: string;
237
244
  };
238
- /** The names of the keys `id` runs on when it is a plan-billed recipe's harness on `env`'s table, else undefined. */
239
- export declare const recipeKeysOf: (env: NodeJS.ProcessEnv, id: string) => readonly string[] | undefined;
245
+ /** `id` when it is a plan-billed recipe's harness on `env`'s table, else undefined. */
246
+ export declare const planRecipeOf: (env: NodeJS.ProcessEnv, id: string) => PlanRecipe | undefined;
240
247
  /** Every plan-billed recipe's harness on `env`'s table, in its order: what Settings → Harness keys lists. */
241
248
  export declare const planRecipesOf: (env: NodeJS.ProcessEnv) => PlanRecipe[];
242
249
  /** The owner's setting that names harness modules when no option does: package names or paths, comma-separated. */
@@ -18,9 +18,9 @@ import { gooseHidden, gooseMissing } from "./harness-goose.js";
18
18
  import { CURSOR_DEFAULT_MODEL, CURSOR_KEY, cursorCardOf, cursorHidden, cursorLimitsOf, cursorMissing } from "./harness-cursor.js";
19
19
  import { DEFAULT_HARNESS, HARNESS_ID_PATTERN, PLAN_HARNESSES, RESERVED_HARNESS_IDS } from "./harness.js";
20
20
  import { HARNESS_INSTALLS } from "./harness-install.js";
21
- import { chooseModel } from "./model.js";
21
+ import { chooseModel, hostModel } from "./model.js";
22
22
  import { HarnessUnavailable, modelOn, openRouterOnly, priceModelFor, providerFor } from "./provider.js";
23
- import { modelWire, wireOf, WIRES } from "./wires.js";
23
+ import { modelWire, routedId, wireOf, WIRES } from "./wires.js";
24
24
  import { PLAN_PROVIDER, signedIn } from "./chatgpt-plan.js";
25
25
  import { loadRecipe } from "./harness-recipe.js";
26
26
  import { recipeServerEntry } from "./harness-recipe-entry.js";
@@ -85,7 +85,8 @@ function adapterEntry(facts, make, extra = {}) {
85
85
  ...extra,
86
86
  // Its wire's vendor's model, or that vendor's on OpenRouter; behind serve's gateway, on the wire it serves, any id,
87
87
  // which is the gateway's own string and names no provider here. One that runs on a ChatGPT plan, the plan's models.
88
- runs: (env, model) => (gateway && Boolean(env.AGENT_MODEL_BASE_URL)) || model.slice(0, Math.max(0, model.indexOf("/"))) === vendor || onOpenRouter(model, vendor) || (onPlan && model.startsWith(`${PLAN_PROVIDER}/`)),
88
+ // A model the route translates onto its wire (wires.ts routed: an Ollama model on Messages), except behind a gateway.
89
+ runs: (env, model) => (gateway && Boolean(env.AGENT_MODEL_BASE_URL)) || model.slice(0, Math.max(0, model.indexOf("/"))) === vendor || onOpenRouter(model, vendor) || (onPlan && model.startsWith(`${PLAN_PROVIDER}/`)) || (routedId(wire, model) && !env.AGENT_MODEL_BASE_URL),
89
90
  onWire: (env) => facts.ownModel || openRouterOnly(wire, env),
90
91
  model: async (env, ref, available) => (facts.ownModel && !available ? undefined : modelOn(wire, env, ref, id)),
91
92
  priceModel: (env, model) => priceModelFor(wire, env, model, id),
@@ -96,13 +97,16 @@ function adapterEntry(facts, make, extra = {}) {
96
97
  // A person's Claude Code login is its CLI's alone: no request of serve's own goes on it.
97
98
  if (provider.login)
98
99
  throw new HarnessUnavailable(`${id} runs on Claude Code's login on this machine, which only its CLI uses: this request needs a model key.`);
99
- const policy = facts.policy({ model: provider.modelId, tools: [], auth: provider.auth, ...nativeOptions(facts, env), ...(provider.billing === "plan" ? { plan: true } : {}) });
100
- return { api: wire, options: { policy, model: provider.modelId, origin: provider.origin, credential: async () => provider.credential(), price: priceOf({ ...needs, model: provider.priceModel }) } };
100
+ const policy = facts.policy({ model: provider.modelId, tools: [], auth: provider.auth, ...(provider.fetch ? {} : nativeOptions(facts, env)), ...(provider.billing === "plan" ? { plan: true } : {}) });
101
+ return { api: wire, options: { policy, model: provider.modelId, origin: provider.origin, credential: async () => provider.credential(), price: priceOf({ ...needs, model: provider.priceModel }), ...(provider.fetch ? { fetch: provider.fetch } : {}) } };
101
102
  },
102
103
  refusal: async (env, given, { atStart }) => {
103
104
  const { harnessInstalled, startReason } = await import("./adapters.js");
104
- // Signed in to a ChatGPT plan, a harness that runs on it is asked of the plan's route, which needs no key.
105
- const needs = given ?? { model: { provider: onPlan && signedIn(env) ? PLAN_PROVIDER : vendor, modelId: "default" }, models: { getModel: () => undefined } };
105
+ // Signed in to a ChatGPT plan, a harness that runs on it is asked of the plan's route, which needs no key. One whose
106
+ // default here is a model the route translates onto its wire (the Ollama here, no key held) is asked of that one.
107
+ const local = given ? undefined : hostModel(env, "default", id);
108
+ const probe = local && routedId(wire, local) ? { provider: local.slice(0, local.indexOf("/")), modelId: local.slice(local.indexOf("/") + 1) } : { provider: onPlan && signedIn(env) ? PLAN_PROVIDER : vendor, modelId: "default" };
109
+ const needs = given ?? { model: probe, models: { getModel: () => undefined } };
106
110
  try {
107
111
  // Not installed yet installs on first use (harness-install.ts): until then the provider decides, as it would for
108
112
  // a session.
@@ -125,7 +129,7 @@ function adapterEntry(facts, make, extra = {}) {
125
129
  * throws is a HarnessUnavailable with the fix its code names in the facts (fixOf: install, pins). */
126
130
  function moduleAdapter(facts, build, { missing }, host = {}) {
127
131
  return async (env, needs) => {
128
- const { fixOf, harnessLog, priceOf } = await import("./adapters.js");
132
+ const { fixOf, harnessLog, priceOf, providerOf } = await import("./adapters.js");
129
133
  const unavailable = (error) => (error instanceof HarnessUnavailable ? error : new HarnessUnavailable(error.message, fixOf(facts, error)));
130
134
  // What no key fixes is said first (a binary): a refusal for it names no key.
131
135
  let lacks;
@@ -137,7 +141,7 @@ function moduleAdapter(facts, build, { missing }, host = {}) {
137
141
  }
138
142
  if (lacks)
139
143
  throw new HarnessUnavailable(lacks);
140
- const provider = providerFor(facts.wire, env, needs.model, facts.id);
144
+ const provider = providerOf(facts.wire, env, needs, facts.id);
141
145
  // A person's Claude Code login is its CLI's alone (claude-login.ts): no request of this harness goes on it; a key of
142
146
  // its wire's vendor's, or OpenRouter's, runs it.
143
147
  if (provider.login)
@@ -146,6 +150,7 @@ function moduleAdapter(facts, build, { missing }, host = {}) {
146
150
  return await build({
147
151
  model: provider.modelId,
148
152
  provider: { origin: provider.origin, credential: provider.credential, ...(provider.auth ? { auth: provider.auth } : {}) },
153
+ ...(provider.fetch ? { fetch: provider.fetch } : {}),
149
154
  price: priceOf({ ...needs, model: provider.priceModel }),
150
155
  log: host.log ?? harnessLog(facts.id, env),
151
156
  ...(needs.confine ? { confine: needs.confine } : {}),
@@ -311,6 +316,7 @@ async function gooseLaunch(launch) {
311
316
  return acpPackage().gooseAdapter({
312
317
  binary: found.binary, sha256: found.sha256, model: launch.model, provider: launch.provider, price: launch.price, log: launch.log,
313
318
  ...(launch.confine ? { confine: launch.confine } : {}),
319
+ ...(launch.fetch ? { fetch: launch.fetch } : {}),
314
320
  });
315
321
  }
316
322
  /** What Cursor gives acpEntryOf for its plan-billed entry: billed to its owner's Cursor plan on the owner's Cursor API key
@@ -504,12 +510,14 @@ export function harnessTable(env) {
504
510
  // Then each recipe the owner names (HARNESS_RECIPES_ENV): loaded under its five rules, so a refused one, or one whose
505
511
  // id a module or another recipe already adds, refuses the start in words (a recipe never takes a built-in's id).
506
512
  for (const file of recipes?.files ?? []) {
507
- const entry = recipeServerEntry(file, recipes.data, { signIn: recipes.signIn });
513
+ // One read: the entry, and the digest a run's keys are bound to, are of the same bytes.
514
+ const loadedFile = loadRecipe(file);
515
+ const entry = recipeServerEntry(loadedFile, recipes.data, { signIn: recipes.signIn });
508
516
  if (Object.hasOwn(built, entry.id))
509
517
  throw new Error(`harness recipe ${file} names ${entry.id}, which a harness module or another recipe already adds`);
510
518
  built[entry.id] = entry;
511
- const { recipe } = loadRecipe(file);
512
- madeByRecipe.set(entry, { billing: recipe.model.billing, label: recipe.label, keys: Object.freeze([...recipe.keys]) });
519
+ const { recipe, sha256 } = loadedFile;
520
+ madeByRecipe.set(entry, { billing: recipe.model.billing, label: recipe.label, keys: Object.freeze([...recipe.keys]), digest: sha256 });
513
521
  }
514
522
  table = Object.freeze(built);
515
523
  loaded.set(key, table);
@@ -525,17 +533,14 @@ export const recipeHarness = (env, id) => {
525
533
  const entry = Object.hasOwn(harnessTable(env), id) ? harnessTable(env)[id] : undefined;
526
534
  return entry === undefined ? undefined : madeByRecipe.get(entry)?.billing;
527
535
  };
528
- /** The names of the keys `id` runs on when it is a plan-billed recipe's harness on `env`'s table, else undefined. */
529
- export const recipeKeysOf = (env, id) => {
530
- const entry = Object.hasOwn(harnessTable(env), id) ? harnessTable(env)[id] : undefined;
531
- const made = entry === undefined ? undefined : madeByRecipe.get(entry);
532
- return made?.billing === "plan" ? made.keys : undefined;
536
+ const planRecipe = (entry) => {
537
+ const made = madeByRecipe.get(entry);
538
+ return made?.billing === "plan" ? { id: entry.id, label: made.label, keys: made.keys, digest: made.digest } : undefined;
533
539
  };
540
+ /** `id` when it is a plan-billed recipe's harness on `env`'s table, else undefined. */
541
+ export const planRecipeOf = (env, id) => (Object.hasOwn(harnessTable(env), id) ? planRecipe(harnessTable(env)[id]) : undefined);
534
542
  /** Every plan-billed recipe's harness on `env`'s table, in its order: what Settings → Harness keys lists. */
535
- export const planRecipesOf = (env) => Object.values(harnessTable(env)).flatMap((entry) => {
536
- const made = madeByRecipe.get(entry);
537
- return made?.billing === "plan" ? [{ id: entry.id, label: made.label, keys: made.keys }] : [];
538
- });
543
+ export const planRecipesOf = (env) => Object.values(harnessTable(env)).flatMap((entry) => planRecipe(entry) ?? []);
539
544
  /** The owner's setting that names harness modules when no option does: package names or paths, comma-separated. */
540
545
  export const HARNESS_MODULES_SETTING = "AGENTRUN_SERVE_HARNESS_MODULES";
541
546
  /** The harness modules `given` names (a server's or a runner's `--harness-module`, else HARNESS_MODULES_SETTING): none
package/dist/harness.d.ts CHANGED
@@ -45,6 +45,7 @@ export type HarnessOffer = {
45
45
  export type HarnessCapability = HarnessOffer & {
46
46
  default_model: string | null;
47
47
  models: string[];
48
+ ready_models: string[];
48
49
  free_models: {
49
50
  id: string;
50
51
  context_window: number;