@parcha/agentrun-serve 0.1.0-beta.46 → 0.1.0-beta.48

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 (292) hide show
  1. package/CHANGELOG.md +211 -1
  2. package/NOTICE +4 -0
  3. package/README.md +350 -53
  4. package/dist/acp-package.d.ts +53 -6
  5. package/dist/acp-package.js +3 -3
  6. package/dist/adapter-facts.d.ts +3 -4
  7. package/dist/adapter-facts.js +4 -4
  8. package/dist/adapters.d.ts +3 -5
  9. package/dist/adapters.js +1 -31
  10. package/dist/agents-store.d.ts +5 -3
  11. package/dist/agents-store.js +13 -8
  12. package/dist/answer-json.d.ts +10 -0
  13. package/dist/answer-json.js +24 -0
  14. package/dist/api-only.d.ts +11 -11
  15. package/dist/api-only.js +16 -11
  16. package/dist/archil-routes.js +2 -1
  17. package/dist/browser-live.d.ts +9 -4
  18. package/dist/browser-live.js +18 -5
  19. package/dist/cap.js +10 -2
  20. package/dist/chatgpt-plan.js +2 -1
  21. package/dist/cli.js +109 -41
  22. package/dist/composio-made.d.ts +19 -2
  23. package/dist/composio-made.js +17 -5
  24. package/dist/composio-preset.d.ts +42 -7
  25. package/dist/composio-preset.js +106 -70
  26. package/dist/composio-triggers.d.ts +9 -4
  27. package/dist/composio-triggers.js +20 -13
  28. package/dist/computer-attach.d.ts +11 -10
  29. package/dist/computer-attach.js +13 -14
  30. package/dist/computer-commands.d.ts +3 -0
  31. package/dist/computer-commands.js +3 -2
  32. package/dist/computer-lost.d.ts +4 -0
  33. package/dist/computer-lost.js +8 -3
  34. package/dist/computer-routes.d.ts +8 -5
  35. package/dist/computer-routes.js +7 -5
  36. package/dist/computer-setting.d.ts +2 -0
  37. package/dist/computer-setting.js +2 -0
  38. package/dist/computers.d.ts +14 -76
  39. package/dist/computers.js +24 -68
  40. package/dist/conformance.d.ts +4 -0
  41. package/dist/conformance.js +6 -0
  42. package/dist/console/assets/index-CTGegcKt.css +1 -0
  43. package/dist/console/assets/index-D1Se6mgG.js +715 -0
  44. package/dist/console/index.html +2 -2
  45. package/dist/cost-heal.d.ts +13 -0
  46. package/dist/cost-heal.js +27 -0
  47. package/dist/dial-relay.d.ts +6 -2
  48. package/dist/dial-relay.js +9 -12
  49. package/dist/email/routes.js +2 -1
  50. package/dist/errors.d.ts +2 -0
  51. package/dist/errors.js +5 -0
  52. package/dist/exa-keyless.d.ts +1 -1
  53. package/dist/exa-keyless.js +1 -1
  54. package/dist/faux-computers.d.ts +2 -3
  55. package/dist/faux-computers.js +9 -31
  56. package/dist/github-connection.js +2 -1
  57. package/dist/harness-archive.d.ts +19 -2
  58. package/dist/harness-archive.js +49 -15
  59. package/dist/harness-check.d.ts +75 -0
  60. package/dist/harness-check.js +518 -0
  61. package/dist/harness-cursor.d.ts +28 -0
  62. package/dist/harness-cursor.js +42 -0
  63. package/dist/harness-goose.d.ts +4 -29
  64. package/dist/harness-goose.js +6 -86
  65. package/dist/harness-module.d.ts +4 -0
  66. package/dist/harness-module.js +1 -0
  67. package/dist/harness-owned.d.ts +52 -0
  68. package/dist/harness-owned.js +92 -0
  69. package/dist/harness-recipe.d.ts +127 -0
  70. package/dist/harness-recipe.js +335 -0
  71. package/dist/harness-table.d.ts +120 -5
  72. package/dist/harness-table.js +280 -6
  73. package/dist/harness.d.ts +2 -0
  74. package/dist/harness.js +5 -4
  75. package/dist/host-check.d.ts +6 -0
  76. package/dist/host-check.js +14 -0
  77. package/dist/host.d.ts +10 -3
  78. package/dist/host.js +17 -3
  79. package/dist/import-sources.d.ts +2 -0
  80. package/dist/import-sources.js +2 -0
  81. package/dist/import-summary.d.ts +15 -5
  82. package/dist/import-summary.js +24 -8
  83. package/dist/import.d.ts +24 -4
  84. package/dist/import.js +108 -26
  85. package/dist/key-refusal.d.ts +3 -1
  86. package/dist/key-refusal.js +26 -5
  87. package/dist/key-words.d.ts +1 -1
  88. package/dist/key-words.js +4 -4
  89. package/dist/learn/check.d.ts +3 -0
  90. package/dist/learn/check.js +31 -20
  91. package/dist/learn/compile.js +12 -5
  92. package/dist/learn/promote.d.ts +80 -2
  93. package/dist/learn/promote.js +95 -3
  94. package/dist/learn/secrets.d.ts +4 -0
  95. package/dist/learn/secrets.js +23 -0
  96. package/dist/learned-nodes.d.ts +4 -3
  97. package/dist/learned-workflow.js +4 -1
  98. package/dist/learning-cost.d.ts +6 -16
  99. package/dist/learning-cost.js +6 -12
  100. package/dist/learning-model.d.ts +18 -0
  101. package/dist/learning-model.js +77 -0
  102. package/dist/learning-words.d.ts +2 -0
  103. package/dist/learning-words.js +1 -1
  104. package/dist/listen-first.d.ts +10 -0
  105. package/dist/listen-first.js +25 -1
  106. package/dist/llms.txt +2 -1
  107. package/dist/mcp-gateway.d.ts +2 -1
  108. package/dist/mcp-gateway.js +31 -15
  109. package/dist/mcp-probe.d.ts +18 -6
  110. package/dist/mcp-probe.js +41 -8
  111. package/dist/mcp-secret-writes.d.ts +8 -0
  112. package/dist/mcp-secret-writes.js +104 -4
  113. package/dist/mcp-servers-store.d.ts +11 -5
  114. package/dist/mcp-servers-store.js +46 -20
  115. package/dist/model-form.d.ts +2 -1
  116. package/dist/model-form.js +30 -16
  117. package/dist/model-gateway.d.ts +113 -0
  118. package/dist/model-gateway.js +433 -0
  119. package/dist/model.d.ts +5 -3
  120. package/dist/model.js +26 -18
  121. package/dist/monid.js +1 -1
  122. package/dist/native/binding.d.ts +4 -0
  123. package/dist/native/binding.js +9 -0
  124. package/dist/native/cli.d.ts +3 -2
  125. package/dist/native/cli.js +6 -5
  126. package/dist/openapi.d.ts +2 -0
  127. package/dist/openapi.js +356 -43
  128. package/dist/owner.d.ts +4 -2
  129. package/dist/owner.js +10 -4
  130. package/dist/page.d.ts +9 -0
  131. package/dist/page.js +10 -2
  132. package/dist/port-models.js +17 -10
  133. package/dist/provider.d.ts +3 -3
  134. package/dist/provider.js +12 -3
  135. package/dist/public-address.d.ts +28 -0
  136. package/dist/public-address.js +62 -0
  137. package/dist/run-launch.d.ts +1 -1
  138. package/dist/run-launch.js +1 -1
  139. package/dist/run-secrets.d.ts +3 -2
  140. package/dist/run-secrets.js +7 -4
  141. package/dist/run-trace.js +6 -3
  142. package/dist/runner/adapter-loop.d.ts +14 -8
  143. package/dist/runner/adapter-loop.js +58 -24
  144. package/dist/runner/adapter-run-spec.d.ts +15 -2
  145. package/dist/runner/adapter-run-spec.js +48 -10
  146. package/dist/runner/adapters/index.d.ts +4 -2
  147. package/dist/runner/adapters/index.js +6 -26
  148. package/dist/runner/adapters/pi.d.ts +5 -2
  149. package/dist/runner/adapters/pi.js +7 -4
  150. package/dist/runner/audit.d.ts +7 -0
  151. package/dist/runner/audit.js +15 -6
  152. package/dist/runner/claim-secrets.js +5 -1
  153. package/dist/runner/cli-run-spec.js +22 -10
  154. package/dist/runner/compare-end.d.ts +43 -0
  155. package/dist/runner/compare-end.js +95 -0
  156. package/dist/runner/computer-journal.d.ts +3 -0
  157. package/dist/runner/computer-journal.js +22 -2
  158. package/dist/runner/conformance/host-tools.d.ts +4 -0
  159. package/dist/runner/conformance/host-tools.js +14 -0
  160. package/dist/runner/harness-loops.d.ts +6 -1
  161. package/dist/runner/harness-loops.js +94 -54
  162. package/dist/runner/held.d.ts +5 -4
  163. package/dist/runner/journal-kinds.d.ts +4 -1
  164. package/dist/runner/journal-kinds.js +3 -0
  165. package/dist/runner/loop-contract.d.ts +10 -0
  166. package/dist/runner/main.d.ts +5 -5
  167. package/dist/runner/main.js +62 -11
  168. package/dist/runner/mcp-claim.js +40 -12
  169. package/dist/runner/meta-tools.js +4 -2
  170. package/dist/runner/metrics.d.ts +26 -0
  171. package/dist/runner/metrics.js +44 -1
  172. package/dist/runner/presence.d.ts +44 -0
  173. package/dist/runner/presence.js +96 -0
  174. package/dist/runner/promotion.d.ts +70 -7
  175. package/dist/runner/promotion.js +178 -28
  176. package/dist/runner/run-child-host.js +40 -10
  177. package/dist/runner/runner.d.ts +5 -0
  178. package/dist/runner/runner.js +8 -0
  179. package/dist/runner/sdk-loop.js +25 -1
  180. package/dist/runner/store-port.d.ts +3 -0
  181. package/dist/runner/store-secrets.js +19 -7
  182. package/dist/runner/workflow-first.d.ts +5 -2
  183. package/dist/runner/workflow-first.js +6 -3
  184. package/dist/runner/workflow-spec.js +3 -2
  185. package/dist/runs-over-store.d.ts +7 -2
  186. package/dist/runs-over-store.js +12 -4
  187. package/dist/sdk/check.d.ts +31 -0
  188. package/dist/sdk/check.js +58 -0
  189. package/dist/sdk/runs.d.ts +11 -3
  190. package/dist/sdk/runs.js +90 -15
  191. package/dist/sdk/schema.js +12 -4
  192. package/dist/secret-writes.d.ts +16 -3
  193. package/dist/secret-writes.js +28 -3
  194. package/dist/server-secrets-store.js +5 -0
  195. package/dist/server.d.ts +34 -2
  196. package/dist/server.js +437 -90
  197. package/dist/sign-ins-secrets.js +4 -1
  198. package/dist/skills/agentrun-serve/SKILL.md +11 -0
  199. package/dist/slack-url.d.ts +5 -0
  200. package/dist/slack-url.js +11 -0
  201. package/dist/slack.d.ts +107 -0
  202. package/dist/slack.js +292 -0
  203. package/dist/start-switches.d.ts +28 -0
  204. package/dist/start-switches.js +37 -0
  205. package/dist/stats.d.ts +1 -1
  206. package/dist/stats.js +2 -1
  207. package/dist/stop-signals.d.ts +11 -0
  208. package/dist/stop-signals.js +22 -0
  209. package/dist/store/agent-body.d.ts +1 -1
  210. package/dist/store/agent-body.js +2 -2
  211. package/dist/store/index.d.ts +3 -3
  212. package/dist/store/index.js +1 -1
  213. package/dist/store/postgres/migrations/0020_runners.sql +18 -0
  214. package/dist/store/postgres/store.d.ts +1 -1
  215. package/dist/store/postgres/store.js +4 -2
  216. package/dist/store/schema.d.ts +13 -5
  217. package/dist/store/schema.js +20 -11
  218. package/dist/store/seal.d.ts +16 -4
  219. package/dist/store/sqlite/store.d.ts +1 -1
  220. package/dist/store/sqlite/store.js +112 -28
  221. package/dist/store/store.d.ts +78 -24
  222. package/dist/store/store.js +11 -0
  223. package/dist/store-reads/analytics.js +3 -2
  224. package/dist/store-reads/cap.d.ts +7 -0
  225. package/dist/store-reads/cap.js +11 -1
  226. package/dist/store-reads/journal.js +27 -1
  227. package/dist/store-reads/learning.d.ts +23 -2
  228. package/dist/store-reads/learning.js +29 -8
  229. package/dist/store-reads/runs.d.ts +9 -0
  230. package/dist/store-reads/runs.js +19 -6
  231. package/dist/store-reads/stats.d.ts +4 -1
  232. package/dist/store-reads/stats.js +15 -6
  233. package/dist/store-view.d.ts +125 -14
  234. package/dist/store-view.js +156 -21
  235. package/dist/telemetry.d.ts +7 -7
  236. package/dist/telemetry.js +38 -15
  237. package/dist/template-eval.js +5 -2
  238. package/dist/template-github-permissions.d.ts +5 -1
  239. package/dist/template-github-permissions.js +7 -3
  240. package/dist/timeline/index.d.ts +1 -1
  241. package/dist/timeline/index.js +1 -1
  242. package/dist/timeline/timeline.d.ts +8 -0
  243. package/dist/timeline/timeline.js +30 -0
  244. package/dist/tool-gate.d.ts +8 -4
  245. package/dist/tool-gate.js +6 -7
  246. package/dist/tool-keys-store.js +2 -2
  247. package/dist/tool-keys.js +2 -1
  248. package/dist/tool-plane.d.ts +4 -0
  249. package/dist/tool-plane.js +12 -12
  250. package/dist/trigger-adapter.d.ts +3 -4
  251. package/dist/trigger-adapter.js +2 -2
  252. package/dist/trigger-composio.js +3 -3
  253. package/dist/trigger-email.js +0 -2
  254. package/dist/trigger-feed.js +0 -2
  255. package/dist/trigger-schedule.js +3 -0
  256. package/dist/trigger-secrets-shown.d.ts +6 -3
  257. package/dist/trigger-secrets-shown.js +22 -13
  258. package/dist/trigger-targets.d.ts +12 -3
  259. package/dist/trigger-targets.js +90 -10
  260. package/dist/triggers.d.ts +2 -2
  261. package/dist/validate.js +5 -1
  262. package/dist/viewer-credential.d.ts +25 -0
  263. package/dist/viewer-credential.js +51 -0
  264. package/dist/webhooks.d.ts +82 -8
  265. package/dist/webhooks.js +128 -45
  266. package/dist/wires.d.ts +6 -1
  267. package/dist/wires.js +5 -0
  268. package/dist/workspace/attach.d.ts +3 -2
  269. package/dist/workspace/attach.js +2 -1
  270. package/dist/workspace/attached-computers.d.ts +6 -8
  271. package/dist/workspace/attached-computers.js +27 -24
  272. package/dist/workspace/computer-deps.d.ts +2 -3
  273. package/dist/workspace/computer-deps.js +3 -6
  274. package/dist/workspace/computer-for-claim.js +72 -96
  275. package/dist/workspace/computer-kept.d.ts +0 -7
  276. package/dist/workspace/computer-kept.js +0 -17
  277. package/dist/workspace/resolve-computer.d.ts +23 -14
  278. package/dist/workspace/resolve-computer.js +66 -61
  279. package/dist/workspace/synced-folder.d.ts +20 -15
  280. package/dist/workspace/synced-folder.js +33 -43
  281. package/launcher/agentrun-serve +4 -1
  282. package/package.json +18 -10
  283. package/skills/agentrun-serve/SKILL.md +11 -0
  284. package/templates/README.md +1 -1
  285. package/templates/code-review/agent.md +2 -3
  286. package/templates/code-review/evals/mentions-defused/case.yaml +0 -1
  287. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -27
  288. package/templates/code-review/evals/other-repo/case.yaml +0 -1
  289. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +0 -18
  290. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +1 -1
  291. package/dist/console/assets/index-C2MYaUBa.css +0 -1
  292. package/dist/console/assets/index-CZZeCReB.js +0 -701
@@ -1,87 +1,7 @@
1
- // Goose on this server: where its owner installs it (`<data>/harnesses/goose/goose`, by `agentrun harness install goose`,
2
- // harness-archive.ts), the command that does, and whether the binary there is the pinned one. Nothing here downloads:
3
- // a run, a save and the start's probe only look at what is installed, and say the command where it is not.
4
- import { existsSync } from "node:fs";
5
- import { homedir } from "node:os";
6
- import { join, resolve } from "node:path";
7
- import { acpPackage } from "./acp-package.js";
8
- import { installArchive } from "./harness-archive.js";
9
- import { installDirOf, shellWord } from "./harness-install.js";
10
- import { DATA_ENV, defaultData } from "./server-fs.js";
1
+ // Goose on this server: installed by its owner (`<data>/harnesses/goose/goose`, by `agentrun harness install goose`),
2
+ // held to its pinned binary (harness-owned.ts).
3
+ import { ownerInstalled } from "./harness-owned.js";
11
4
  export const GOOSE_ID = "goose";
12
- /** The data directory `env` names (the server's own, else the default one). */
13
- const dataOf = (env) => env[DATA_ENV] || defaultData(env);
14
- /** Goose's folder in `data`, and its binary there. */
15
- export const gooseDirOf = (data) => installDirOf(data, GOOSE_ID);
16
- export const gooseBinaryOf = (data) => join(gooseDirOf(data), GOOSE_ID);
17
- /** The agentrun command's own data directory, where `npx @parcha/agentrun` keeps its server's store (~/.agentrun: not the
18
- * server's own default, defaultData), and so where `agentrun harness install` installs with no --data. */
19
- export const commandData = (env) => join(env.HOME || homedir(), ".agentrun");
20
- /** The command that installs Goose into `data`: naming it with --data unless it is the agentrun command's own (commandData). */
21
- export function gooseInstallLine(acp, data, env = process.env) {
22
- return resolve(data) === commandData(env) ? acp.GOOSE_INSTALL : `${acp.GOOSE_INSTALL} --data ${shellWord(data)}`;
23
- }
24
- /** What is known of Goose in `env`'s data before its binary is read: why it is missing, or the binary and the digest it
25
- * must have, with how a refused check is said. */
26
- function lookup(env) {
27
- const acp = acpPackage();
28
- if (!acp)
29
- return { missing: { code: "HARNESS_NOT_INSTALLED", message: "HARNESS_NOT_INSTALLED: Goose's adapter (@parcha/agentrun-harness-acp) is not installed beside this server" } };
30
- const data = dataOf(env);
31
- const binary = gooseBinaryOf(data);
32
- const line = gooseInstallLine(acp, data, env);
33
- const { version, archives } = acp.GOOSE_PIN;
34
- const platform = acp.acpPlatform();
35
- const sha256 = platform ? archives[platform]?.binarySha256 : undefined;
36
- if (!sha256)
37
- return { missing: { code: "ACP_BINARY_UNPINNED", message: `ACP_BINARY_UNPINNED: Goose ${version} has no binary pinned for ${platform ?? `${process.platform}-${process.arch}`}, so it does not run here` } };
38
- if (!existsSync(binary))
39
- return { missing: { code: acp.GOOSE_NOT_INSTALLED, message: `${acp.GOOSE_NOT_INSTALLED}: Goose ${version} is not installed in ${gooseDirOf(data)}. Install it with: ${line}` } };
40
- return {
41
- acp, binary, sha256,
42
- refused: (error) => {
43
- const code = error?.code;
44
- return { code: typeof code === "string" ? code : acp.GOOSE_NOT_INSTALLED, message: `${error.message}. Install Goose ${version} again with: ${line}` };
45
- },
46
- };
47
- }
48
- /** Why Goose is not listed here (HarnessEntry.hidden): not installed, or not the pinned binary, in words that end with what
49
- * to do, restarting AgentRun included (its harnesses are read at its start). Undefined once it is installed and verified.
50
- * The binary's sha256 is kept once per file identity (the package's check), so only the first look reads it. */
51
- export function gooseHidden(env) {
52
- const found = lookup(env);
53
- let missing;
54
- if ("missing" in found)
55
- missing = found.missing;
56
- else {
57
- try {
58
- found.acp.verifyPinnedBinary(found.binary, found.sha256);
59
- }
60
- catch (error) {
61
- missing = found.refused(error);
62
- }
63
- }
64
- return missing && `${missing.message}; then restart AgentRun.`;
65
- }
66
- /** Why Goose cannot run here, its binary checked off the event loop; undefined when it can (with the binary to run). */
67
- export async function gooseMissing(env) {
68
- const found = lookup(env);
69
- if ("missing" in found)
70
- return found;
71
- try {
72
- await found.acp.verifyPinnedBinaryAsync(found.binary, found.sha256);
73
- }
74
- catch (error) {
75
- return { missing: found.refused(error) };
76
- }
77
- return { binary: found.binary, sha256: found.sha256 };
78
- }
79
- /** Installs the pinned Goose into `data` (agentrun-serve install-harness goose). */
80
- export async function installGoose(data, options = {}, env = process.env) {
81
- const acp = acpPackage();
82
- if (!acp)
83
- throw new Error("Goose's adapter (@parcha/agentrun-harness-acp) is not installed beside this server, so it has no pin to install from");
84
- const { id, version, archives } = acp.GOOSE_PIN;
85
- const platform = acp.acpPlatform();
86
- return { version, ...(await installArchive({ id, label: "Goose", retry: gooseInstallLine(acp, data, env), pin: { version, archives } }, gooseDirOf(data), { ...(platform ? { platform } : {}), ...options })) };
87
- }
5
+ /** Goose as an owner-installed harness: its pin, its install line and its not-installed code are its package's. */
6
+ export const GOOSE = ownerInstalled({ id: GOOSE_ID, label: "Goose", pin: (acp) => acp.GOOSE_PIN, installLine: (acp) => acp.GOOSE_INSTALL, notInstalled: (acp) => acp.GOOSE_NOT_INSTALLED });
7
+ export const { hidden: gooseHidden, missing: gooseMissing } = GOOSE;
@@ -0,0 +1,4 @@
1
+ export type { AcpEntryOptions, HarnessEntry, HarnessModuleKit, HarnessPromises, HarnessTableModule, ModuleChecks, ModuleLaunch, Refusal, SessionRoute } from "./harness-table.js";
2
+ export type { HarnessLaunch, RunnerHarness } from "./runner/adapters/index.js";
3
+ export type { AdapterNeeds } from "./adapters.js";
4
+ export type { ModelChoice } from "./provider.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ import { type AcpPackage, type AcpPin } from "./acp-package.js";
2
+ import { type ArchiveInstallOptions, installArchive } from "./harness-archive.js";
3
+ /** Why an owner-installed harness does not run here: a code (HARNESS_NOT_INSTALLED, ACP_BINARY_MISMATCH,
4
+ * ACP_BINARY_UNPINNED, ...) and words that start with it and end with what to do. */
5
+ export type OwnerMissing = {
6
+ readonly code: string;
7
+ readonly message: string;
8
+ };
9
+ /** The agentrun command's own data directory, where `npx @parcha/agentrun` keeps its server's store (~/.agentrun: not the
10
+ * server's own default, defaultData), and so where `agentrun harness install` installs with no --data. */
11
+ export declare const commandData: (env: NodeJS.ProcessEnv) => string;
12
+ /** What an owner-installed harness is, from the ACP package: its pin, the command that installs it and the code a
13
+ * missing install is refused by. `tree`: its release is pinned by the digest of every file it unpacks to, its launcher
14
+ * among them (Cursor's), not by its binary alone (Goose's). */
15
+ export interface OwnerInstalledSpec {
16
+ readonly id: string;
17
+ readonly label: string;
18
+ readonly pin: (acp: AcpPackage) => AcpPin;
19
+ readonly installLine: (acp: AcpPackage) => string;
20
+ readonly notInstalled: (acp: AcpPackage) => string;
21
+ readonly tree?: boolean;
22
+ }
23
+ /** An owner-installed harness on this server. */
24
+ export interface OwnerInstalled {
25
+ readonly id: string;
26
+ readonly label: string;
27
+ /** What the install's last step checks, as the installer says it. */
28
+ readonly verified: string;
29
+ /** Its folder in `data`. */
30
+ dirOf(data: string): string;
31
+ /** The command that installs it into `data`: naming it with --data unless it is the agentrun command's own. */
32
+ installLine(acp: AcpPackage, data: string, env?: NodeJS.ProcessEnv): string;
33
+ /** Why it is not listed here (HarnessEntry.hidden): not installed, or its binary not the pinned one, in words that end
34
+ * with what to do, restarting AgentRun included (its harnesses are read at its start). Undefined once it is. The
35
+ * binary's sha256 is kept once per file identity (the package's check), so only the first look reads it; a tree is
36
+ * checked off the event loop, by `missing` at each run and the start's probe. */
37
+ hidden(env: NodeJS.ProcessEnv): string | undefined;
38
+ /** Why it cannot run here, its binary (or every file of its tree) checked off the event loop; else its binary, with the
39
+ * binary's pinned sha256. */
40
+ missing(env: NodeJS.ProcessEnv): Promise<{
41
+ missing: OwnerMissing;
42
+ } | {
43
+ binary: string;
44
+ sha256: string;
45
+ }>;
46
+ /** Installs its pinned release into `data` (agentrun-serve install-harness <id>). */
47
+ install(data: string, options?: ArchiveInstallOptions, env?: NodeJS.ProcessEnv): Promise<{
48
+ version: string;
49
+ } & Awaited<ReturnType<typeof installArchive>>>;
50
+ }
51
+ /** `spec`'s harness on this server. */
52
+ export declare function ownerInstalled(spec: OwnerInstalledSpec): OwnerInstalled;
@@ -0,0 +1,92 @@
1
+ // A harness its owner installs from a pinned archive (`agentrun harness install <id>`, harness-archive.ts): Goose and
2
+ // Cursor, from the ACP package's pins. One shape for each: where it is installed, the command that installs it, why it
3
+ // is not listed or cannot run, and its install. Nothing here downloads: a run, a save and the start's probe only look at
4
+ // what is installed, and say the command where it is not.
5
+ import { existsSync } from "node:fs";
6
+ import { homedir } from "node:os";
7
+ import { join, resolve } from "node:path";
8
+ import { acpPackage } from "./acp-package.js";
9
+ import { installArchive } from "./harness-archive.js";
10
+ import { installDirOf, shellWord } from "./harness-install.js";
11
+ import { DATA_ENV, defaultData } from "./server-fs.js";
12
+ /** The agentrun command's own data directory, where `npx @parcha/agentrun` keeps its server's store (~/.agentrun: not the
13
+ * server's own default, defaultData), and so where `agentrun harness install` installs with no --data. */
14
+ export const commandData = (env) => join(env.HOME || homedir(), ".agentrun");
15
+ /** The data directory `env` names (the server's own, else the default one). */
16
+ const dataOf = (env) => env[DATA_ENV] || defaultData(env);
17
+ /** `spec`'s harness on this server. */
18
+ export function ownerInstalled(spec) {
19
+ const { id, label, tree = false } = spec;
20
+ const dirOf = (data) => installDirOf(data, id);
21
+ const installLine = (acp, data, env = process.env) => resolve(data) === commandData(env) ? spec.installLine(acp) : `${spec.installLine(acp)} --data ${shellWord(data)}`;
22
+ /** What is known of it in `env`'s data before its files are read: why it is missing, or its binary, its folder and the
23
+ * digests they must have, with how a refused check is said. */
24
+ const lookup = (env) => {
25
+ const acp = acpPackage();
26
+ // No package, so no code of its own: the server's own for a harness that is not installed.
27
+ if (!acp)
28
+ return { missing: { code: "HARNESS_NOT_INSTALLED", message: `HARNESS_NOT_INSTALLED: ${label}'s adapter (@parcha/agentrun-harness-acp) is not installed beside this server` } };
29
+ const data = dataOf(env);
30
+ const root = dirOf(data);
31
+ const line = installLine(acp, data, env);
32
+ const { version } = spec.pin(acp);
33
+ const notInstalled = spec.notInstalled(acp);
34
+ const platform = acp.acpPlatform();
35
+ const release = acp.pinnedRelease(spec.pin(acp), platform, tree);
36
+ if (!release)
37
+ return { missing: { code: "ACP_BINARY_UNPINNED", message: `ACP_BINARY_UNPINNED: ${label} ${version} has no release pinned for ${platform ?? `${process.platform}-${process.arch}`}, so it does not run here` } };
38
+ const binary = join(root, release.cmd);
39
+ if (!existsSync(binary))
40
+ return { missing: { code: notInstalled, message: `${notInstalled}: ${label} ${version} is not installed in ${root}. Install it with: ${line}` } };
41
+ return {
42
+ acp, binary, root, sha256: release.binarySha256, ...(tree && release.treeSha256 ? { treeSha256: release.treeSha256 } : {}),
43
+ refused: (error) => {
44
+ const code = error?.code;
45
+ return { code: typeof code === "string" ? code : notInstalled, message: `${error.message}. Install ${label} ${version} again with: ${line}` };
46
+ },
47
+ };
48
+ };
49
+ return {
50
+ id, label, dirOf, installLine,
51
+ verified: tree ? "its launcher's sha256 and every file's tree digest match the pin" : "the binary's sha256 matches the pin",
52
+ hidden: (env) => {
53
+ const found = lookup(env);
54
+ let missing;
55
+ if ("missing" in found)
56
+ missing = found.missing;
57
+ else {
58
+ try {
59
+ found.acp.verifyPinnedBinary(found.binary, found.sha256);
60
+ }
61
+ catch (error) {
62
+ missing = found.refused(error);
63
+ }
64
+ }
65
+ return missing && `${missing.message}; then restart AgentRun.`;
66
+ },
67
+ missing: async (env) => {
68
+ const found = lookup(env);
69
+ if ("missing" in found)
70
+ return found;
71
+ try {
72
+ // A tree's digest covers its launcher: its own check is the binary's alone.
73
+ if (found.treeSha256)
74
+ await found.acp.verifyPinnedTree(found.root, found.treeSha256);
75
+ else
76
+ await found.acp.verifyPinnedBinaryAsync(found.binary, found.sha256);
77
+ }
78
+ catch (error) {
79
+ return { missing: found.refused(error) };
80
+ }
81
+ return { binary: found.binary, sha256: found.sha256 };
82
+ },
83
+ install: async (data, options = {}, env = process.env) => {
84
+ const acp = acpPackage();
85
+ if (!acp)
86
+ throw new Error(`${label}'s adapter (@parcha/agentrun-harness-acp) is not installed beside this server, so it has no pin to install from`);
87
+ const { version, archives } = spec.pin(acp);
88
+ const platform = acp.acpPlatform();
89
+ return { version, ...(await installArchive({ id, label, retry: installLine(acp, data, env), pin: { version, archives }, ...(tree ? { tree: (root) => acp.treeDigest(root) } : {}) }, dirOf(data), { ...(platform ? { platform } : {}), ...options })) };
90
+ },
91
+ };
92
+ }
@@ -0,0 +1,127 @@
1
+ import { type ArchiveFormat, type ArchiveInstallOptions, type ArchiveRelease } from "./harness-archive.js";
2
+ /** The codes a refused recipe carries, one per rule, and one for a file that is not a recipe at all. */
3
+ export declare const RECIPE_CODES: Readonly<{
4
+ /** Not JSON, not an object, or a field missing, of the wrong type, or unknown. */
5
+ readonly invalid: "RECIPE_INVALID";
6
+ /** Rule 1: a key that is not the harness's own. */
7
+ readonly keys: "RECIPE_KEY_NOT_OWN";
8
+ /** Rule 2: a binary that is not a registry archive pinned by its sha256. */
9
+ readonly binary: "RECIPE_BINARY_UNPINNED";
10
+ /** Rule 3: a file, a state folder or the binary outside its private place. */
11
+ readonly paths: "RECIPE_PATH_OUTSIDE";
12
+ /** Rule 4: an install step of the recipe's own. */
13
+ readonly install: "RECIPE_INSTALLS_ITSELF";
14
+ /** Rule 5: an environment beyond the allowlist and the recipe's own literal values. */
15
+ readonly env: "RECIPE_ENV_NOT_ALLOWLIST";
16
+ }>;
17
+ export type RecipeCode = (typeof RECIPE_CODES)[keyof typeof RECIPE_CODES];
18
+ /** One platform's release of the agent, copied from its ACP registry entry (`distribution.binary.<platform>`). */
19
+ export type RecipeArchive = ArchiveRelease & {
20
+ readonly format: ArchiveFormat;
21
+ };
22
+ /** The variables a proxy-billed agent may read the proxy's address from: Goose's, and the Anthropic SDKs'. */
23
+ export declare const PROXY_HOST_ENVS: readonly string[];
24
+ /** The variables the agent's environment gets from the adapter and the model proxy, never from a recipe, by part: what
25
+ * it takes from the host (`inherited`, run-adapters-acp's INHERITED_ENV), what the adapter sets for the private HOME
26
+ * (`reserved`, its RESERVED_ENV), and the proxy's address and key (`proxy`). The loader refuses a recipe that names one;
27
+ * the check's env_allowlist expects each. */
28
+ export declare const AGENT_VARS: Readonly<Record<"inherited" | "reserved" | "proxy", readonly string[]>>;
29
+ /** How the agent's model is billed. `proxy`: it speaks Anthropic's Messages API to the address in `hostEnv` (default
30
+ * ANTHROPIC_HOST) with ANTHROPIC_API_KEY, both the session's model proxy's (the run's cap and books hold), and reads the
31
+ * run's model from `env`. `plan`: the vendor bills the owner's plan on the recipe's own keys; the adapter stops the run
32
+ * at these limits. */
33
+ export type RecipeModel = {
34
+ readonly billing: "proxy";
35
+ readonly wire: "anthropic-messages";
36
+ readonly env: string;
37
+ readonly hostEnv?: "ANTHROPIC_HOST" | "ANTHROPIC_BASE_URL";
38
+ } | {
39
+ readonly billing: "plan";
40
+ readonly maxTurns: number;
41
+ readonly maxToolCalls: number;
42
+ readonly hosts?: readonly string[];
43
+ };
44
+ /** A recipe file, as the loader passes it. */
45
+ export interface Recipe {
46
+ readonly id: string;
47
+ readonly label: string;
48
+ readonly release: {
49
+ readonly registry: string;
50
+ readonly version: string;
51
+ readonly archives: Readonly<Record<string, RecipeArchive>>;
52
+ };
53
+ readonly args: readonly string[];
54
+ readonly keys: readonly string[];
55
+ readonly env: Readonly<Record<string, string>>;
56
+ readonly model: RecipeModel;
57
+ readonly files: Readonly<Record<string, string>>;
58
+ readonly state: readonly string[];
59
+ readonly declares: {
60
+ readonly load: boolean;
61
+ readonly mcp: "http" | "stdio";
62
+ };
63
+ readonly quirks: {
64
+ readonly mcpCall?: "match" | "mint";
65
+ };
66
+ }
67
+ /** A recipe the loader refused: `code` is the first problem's, and the message says every one. */
68
+ export declare class RecipeRefused extends Error {
69
+ readonly code: RecipeCode;
70
+ readonly problems: readonly {
71
+ code: RecipeCode;
72
+ words: string;
73
+ }[];
74
+ constructor(code: RecipeCode, problems: readonly {
75
+ code: RecipeCode;
76
+ words: string;
77
+ }[]);
78
+ }
79
+ /** Whether `name` is a key the server holds for anything but this harness: the launcher's secrets (model providers, the
80
+ * gateway, tools, computers, serve's own) and every AGENTRUN_ and AGENT_MODEL_ name. */
81
+ export declare const serverKey: (name: string) => boolean;
82
+ /** `path` inside HOME, or undefined when it leaves it (absolute, `..`, or empty); a `$HOME/` prefix is HOME. */
83
+ export declare function insideHome(path: string): string | undefined;
84
+ /** Every problem with `parsed` as a recipe, by its rule's code. */
85
+ export declare function recipeProblems(parsed: unknown): {
86
+ code: RecipeCode;
87
+ words: string;
88
+ }[];
89
+ /** The recipe in `text`, or RecipeRefused with every problem. */
90
+ export declare function parseRecipe(text: string): Recipe;
91
+ /** The recipe file at `path`, read and loaded. */
92
+ export declare function loadRecipe(path: string): {
93
+ recipe: Recipe;
94
+ file: string;
95
+ sha256: string;
96
+ };
97
+ /** The recipe's release for `platform` (this host's by default), or undefined where it lists none. */
98
+ export declare const releaseFor: (recipe: Recipe, platform?: string | undefined) => RecipeArchive | undefined;
99
+ /** The owner's command that installs the recipe at `file` into `data`. */
100
+ export declare const recipeInstallLine: (file: string, data: string, env?: NodeJS.ProcessEnv) => string;
101
+ /** Where the recipe's binary is once installed: `<data>/harnesses/<id>/<cmd>`. */
102
+ export declare const recipeBinaryOf: (data: string, recipe: Recipe, release: RecipeArchive) => string;
103
+ /** Where the first sha256 of a binary the recipe does not pin is kept: beside the harnesses' folders, never inside the
104
+ * one an install replaces, so a reinstall that unpacks a different binary is seen. One per id, version and platform. */
105
+ export declare const firstSeenOf: (data: string, recipe: Recipe, platform: string) => string;
106
+ /** A first-seen digest record in a file of its own (one line, the sha256), written once and never over another's. */
107
+ export declare function firstSeenRecord(file: string): {
108
+ read(): string | undefined;
109
+ write(sha256: string): void;
110
+ };
111
+ /** The sha256 the installed binary must have: the recipe's pin, else the first one its install recorded; undefined when it
112
+ * pins none and none was recorded (never installed by the owner's command). */
113
+ export declare function pinnedDigest(data: string, recipe: Recipe, release: RecipeArchive, platform: string): {
114
+ sha256: string;
115
+ by: "recipe" | "first-seen";
116
+ } | undefined;
117
+ /** Installs the recipe's release into `<data>/harnesses/<id>` (the owner's command, rule 4): its archive downloaded and
118
+ * checked against the recipe's sha256, unpacked, and its binary checked against the recipe's pin, or recorded as the
119
+ * first one seen where the recipe pins none (a later one that differs is refused). */
120
+ export declare function installRecipe(recipe: Recipe, file: string, data: string, options?: ArchiveInstallOptions, env?: NodeJS.ProcessEnv): Promise<{
121
+ installed: "already" | "now";
122
+ binary: string;
123
+ version: string;
124
+ pinnedBy: "recipe" | "recorded" | "first-seen";
125
+ }>;
126
+ /** The owner's command that checks the recipe at `file`, installed into `data`. */
127
+ export declare const recipeCheckLine: (file: string, data: string, env?: NodeJS.ProcessEnv) => string;