@parcha/agentrun-serve 0.1.0-beta.47 → 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 (110) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/README.md +84 -14
  3. package/dist/acp-package.d.ts +24 -6
  4. package/dist/adapter-facts.d.ts +0 -4
  5. package/dist/adapter-facts.js +1 -4
  6. package/dist/adapters.d.ts +3 -12
  7. package/dist/adapters.js +1 -70
  8. package/dist/answer-json.d.ts +10 -0
  9. package/dist/answer-json.js +24 -0
  10. package/dist/api-only.d.ts +5 -2
  11. package/dist/api-only.js +10 -2
  12. package/dist/browser-live.d.ts +9 -4
  13. package/dist/browser-live.js +18 -5
  14. package/dist/cap.js +7 -9
  15. package/dist/cli.js +6 -6
  16. package/dist/computer-routes.d.ts +8 -5
  17. package/dist/computer-routes.js +7 -5
  18. package/dist/computers.d.ts +6 -2
  19. package/dist/computers.js +4 -2
  20. package/dist/conformance.d.ts +4 -0
  21. package/dist/conformance.js +6 -0
  22. package/dist/console/assets/index-CTGegcKt.css +1 -0
  23. package/dist/console/assets/{index-BBFzAxLB.js → index-D1Se6mgG.js} +165 -165
  24. package/dist/console/index.html +2 -2
  25. package/dist/harness-check.d.ts +3 -1
  26. package/dist/harness-check.js +99 -70
  27. package/dist/harness-cursor.d.ts +10 -27
  28. package/dist/harness-cursor.js +5 -84
  29. package/dist/harness-goose.d.ts +4 -29
  30. package/dist/harness-goose.js +6 -86
  31. package/dist/harness-module.d.ts +4 -0
  32. package/dist/harness-module.js +1 -0
  33. package/dist/harness-owned.d.ts +52 -0
  34. package/dist/harness-owned.js +92 -0
  35. package/dist/harness-recipe.js +2 -24
  36. package/dist/harness-table.d.ts +109 -6
  37. package/dist/harness-table.js +242 -28
  38. package/dist/harness.js +2 -2
  39. package/dist/key-refusal.d.ts +2 -1
  40. package/dist/key-refusal.js +18 -2
  41. package/dist/learn/promote.d.ts +11 -0
  42. package/dist/learn/secrets.d.ts +4 -0
  43. package/dist/learn/secrets.js +23 -0
  44. package/dist/learning-model.d.ts +18 -0
  45. package/dist/learning-model.js +77 -0
  46. package/dist/llms.txt +1 -0
  47. package/dist/model-form.js +12 -12
  48. package/dist/model.d.ts +5 -4
  49. package/dist/model.js +19 -13
  50. package/dist/openapi.js +35 -5
  51. package/dist/page.d.ts +1 -0
  52. package/dist/page.js +1 -1
  53. package/dist/run-secrets.d.ts +2 -2
  54. package/dist/run-secrets.js +6 -5
  55. package/dist/run-trace.js +6 -3
  56. package/dist/runner/adapter-loop.d.ts +4 -1
  57. package/dist/runner/adapter-loop.js +1 -2
  58. package/dist/runner/adapter-run-spec.d.ts +3 -2
  59. package/dist/runner/adapter-run-spec.js +8 -4
  60. package/dist/runner/adapters/index.d.ts +4 -2
  61. package/dist/runner/adapters/index.js +6 -42
  62. package/dist/runner/cli-run-spec.js +10 -6
  63. package/dist/runner/conformance/host-tools.d.ts +4 -0
  64. package/dist/runner/conformance/host-tools.js +14 -0
  65. package/dist/runner/meta-tools.js +4 -2
  66. package/dist/runner/presence.d.ts +3 -0
  67. package/dist/runner/presence.js +19 -12
  68. package/dist/runner/promotion.d.ts +62 -4
  69. package/dist/runner/promotion.js +146 -15
  70. package/dist/runner/sdk-loop.js +25 -1
  71. package/dist/runner/workflow-spec.js +3 -2
  72. package/dist/runs-over-store.d.ts +2 -1
  73. package/dist/runs-over-store.js +2 -4
  74. package/dist/sdk/check.d.ts +31 -0
  75. package/dist/sdk/check.js +58 -0
  76. package/dist/sdk/runs.d.ts +10 -2
  77. package/dist/sdk/runs.js +87 -17
  78. package/dist/sdk/schema.js +11 -3
  79. package/dist/server.d.ts +3 -0
  80. package/dist/server.js +116 -40
  81. package/dist/store/sqlite/store.js +35 -30
  82. package/dist/store/store.d.ts +20 -18
  83. package/dist/store-view.d.ts +5 -3
  84. package/dist/store-view.js +9 -7
  85. package/dist/template-eval.js +5 -2
  86. package/dist/template-github-permissions.d.ts +5 -1
  87. package/dist/template-github-permissions.js +7 -3
  88. package/dist/timeline/index.d.ts +1 -1
  89. package/dist/timeline/index.js +1 -1
  90. package/dist/timeline/timeline.d.ts +8 -0
  91. package/dist/timeline/timeline.js +18 -6
  92. package/dist/tool-gate.d.ts +8 -4
  93. package/dist/tool-gate.js +6 -7
  94. package/dist/tool-plane.d.ts +4 -0
  95. package/dist/tool-plane.js +10 -10
  96. package/dist/trigger-targets.d.ts +11 -2
  97. package/dist/trigger-targets.js +71 -2
  98. package/dist/validate.js +5 -1
  99. package/dist/viewer-credential.d.ts +25 -0
  100. package/dist/viewer-credential.js +51 -0
  101. package/dist/workspace/resolve-computer.d.ts +5 -0
  102. package/dist/workspace/resolve-computer.js +19 -1
  103. package/package.json +18 -10
  104. package/templates/code-review/agent.md +2 -3
  105. package/templates/code-review/evals/mentions-defused/case.yaml +0 -1
  106. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -27
  107. package/templates/code-review/evals/other-repo/case.yaml +0 -1
  108. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +0 -18
  109. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +1 -1
  110. package/dist/console/assets/index-BRi-Rgq6.css +0 -1
@@ -6,8 +6,8 @@
6
6
  <meta name="color-scheme" content="light dark" />
7
7
  <title>AgentRun</title>
8
8
  <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' fill='%23ff8000'/%3E%3Cpath d='M12 9l11 7-11 7z' fill='%23000'/%3E%3C/svg%3E" />
9
- <script type="module" crossorigin src="./assets/index-BBFzAxLB.js"></script>
10
- <link rel="stylesheet" crossorigin href="./assets/index-BRi-Rgq6.css">
9
+ <script type="module" crossorigin src="./assets/index-D1Se6mgG.js"></script>
10
+ <link rel="stylesheet" crossorigin href="./assets/index-CTGegcKt.css">
11
11
  </head>
12
12
  <body>
13
13
  <div id="root"></div>
@@ -64,7 +64,9 @@ export interface HarnessCheckReport {
64
64
  failures: string[];
65
65
  }
66
66
  /** Runs the check. Never throws for what it judges: a refused recipe, a missing install or a failed stage is in the
67
- * report (`ok: false`, `failures`). */
67
+ * report (`ok: false`, `failures`). Every string of the report and every line it says has the server's secrets and the
68
+ * recipe's keys cut (runner/redact.ts secretRedactor), so an agent's words in it (a failed turn's stderr, a refusal, a
69
+ * log line) never carry a key out to the report's file or the terminal. */
68
70
  export declare function harnessCheck(options: HarnessCheckOptions): Promise<HarnessCheckReport>;
69
71
  /** The three facts and the verdict, as the command prints them. */
70
72
  export declare function printedFacts(report: HarnessCheckReport): string[];
@@ -23,28 +23,16 @@ import { tmpdir } from "node:os";
23
23
  import { join } from "node:path";
24
24
  import { modelPortFor, SessionFenced } from "@parcha/agentrun-kernel";
25
25
  import { beforeRequestOf } from "@parcha/agentrun-kernel/kernel/cap";
26
- import { ACP_PACKAGE } from "./acp-package.js";
27
- import { priceOf } from "./adapters.js";
26
+ import { ACP_PACKAGE, acpPackage } from "./acp-package.js";
28
27
  import { ARCHIVE_CODES, archivePlatform, digestOf } from "./harness-archive.js";
29
28
  import { installDirOf } from "./harness-install.js";
30
29
  import { AGENT_VARS, loadRecipe, pinnedDigest, recipeBinaryOf, recipeInstallLine, RecipeRefused, releaseFor } from "./harness-recipe.js";
30
+ import { acpEntryOf } from "./harness-table.js";
31
31
  import { providerModels } from "./model.js";
32
- import { providerFor } from "./provider.js";
33
32
  import { capModelOf } from "./runner/cli-run-spec.js";
34
33
  import { keyShaped } from "./secret-name.js";
35
- import { SECRET_NAMES } from "./secrets.js";
36
- import { createRequire } from "node:module";
37
- const requireHere = createRequire(import.meta.url);
38
- /** The ACP package beside this server, or undefined. */
39
- function acpCheckPackage() {
40
- try {
41
- requireHere.resolve(ACP_PACKAGE);
42
- }
43
- catch {
44
- return undefined;
45
- }
46
- return requireHere(ACP_PACKAGE);
47
- }
34
+ import { secretRedactor } from "./runner/redact.js";
35
+ import { hostSecrets, SECRET_NAMES } from "./secrets.js";
48
36
  /** The proxy variables the check points at its own egress proxy, in both cases, whatever the recipe sets. */
49
37
  const EGRESS_VARS = ["HTTPS_PROXY", "HTTP_PROXY", "https_proxy", "http_proxy"];
50
38
  const NO_PROXY_VARS = ["NO_PROXY", "no_proxy"];
@@ -173,9 +161,30 @@ function modelRef(ref) {
173
161
  const at = ref.indexOf("/");
174
162
  return at > 0 && at < ref.length - 1 ? { provider: ref.slice(0, at), modelId: ref.slice(at + 1) } : undefined;
175
163
  }
164
+ /** The values of the keys `env` holds but those named in `except`, each read by name (withSecrets keeps the server's off
165
+ * its enumeration): SECRET_NAMES and every key-shaped name. */
166
+ const keyValues = (env, except = []) => [...new Set([...SECRET_NAMES, ...Object.keys(env).filter((name) => keyShaped(name))])]
167
+ .filter((name) => !except.includes(name))
168
+ .map((name) => env[name])
169
+ .filter((value) => typeof value === "string" && value.length >= 8);
170
+ /** `value` with every string in it put through `cut`, its arrays and objects walked (their names are the check's own). */
171
+ const cutEvery = (value, cut) => (typeof value === "string" ? cut(value)
172
+ : Array.isArray(value) ? value.map((each) => cutEvery(each, cut))
173
+ : value && typeof value === "object" ? Object.fromEntries(Object.entries(value).map(([name, each]) => [name, cutEvery(each, cut)]))
174
+ : value);
176
175
  /** Runs the check. Never throws for what it judges: a refused recipe, a missing install or a failed stage is in the
177
- * report (`ok: false`, `failures`). */
176
+ * report (`ok: false`, `failures`). Every string of the report and every line it says has the server's secrets and the
177
+ * recipe's keys cut (runner/redact.ts secretRedactor), so an agent's words in it (a failed turn's stderr, a refusal, a
178
+ * log line) never carry a key out to the report's file or the terminal. */
178
179
  export async function harnessCheck(options) {
180
+ // The values cut: the server's secrets, then the recipe's keys' values once it is loaded (checkRun adds them).
181
+ const held = [...hostSecrets(options.env), ...keyValues(options.env)];
182
+ const cut = () => secretRedactor(held);
183
+ const report = await checkRun({ ...options, say: (line) => options.say?.(cut()(line)) }, held);
184
+ return cutEvery(report, cut());
185
+ }
186
+ /** The check itself (harnessCheck), adding the values of the recipe's keys to `held` once it is loaded. */
187
+ async function checkRun(options, held) {
179
188
  const say = options.say ?? (() => { });
180
189
  const checkedAt = new Date().toISOString();
181
190
  const failures = [];
@@ -189,6 +198,8 @@ export async function harnessCheck(options) {
189
198
  return { ok: false, recipe: { file: options.recipe }, refused: { code: error.code, message: error.message }, checkedAt, failures: [error.message] };
190
199
  }
191
200
  const { recipe } = loaded;
201
+ // The recipe's keys, read by name from the check's environment: the agent holds them, so its words may too.
202
+ held.push(...recipe.keys.map((name) => options.env[name]).filter((value) => typeof value === "string"));
192
203
  const head = { recipe: { id: recipe.id, label: recipe.label, file: loaded.file, sha256: loaded.sha256 }, checkedAt };
193
204
  const refuse = (code, message) => ({ ok: false, ...head, refused: { code, message: `${code}: ${message}` }, failures: [`${code}: ${message}`] });
194
205
  say(`${recipe.label}: the recipe holds the five rules (${loaded.file})`);
@@ -206,32 +217,18 @@ export async function harnessCheck(options) {
206
217
  if (found !== pin.sha256)
207
218
  return refuse(ARCHIVE_CODES.binary, `${binary} has sha256 ${found ?? "(unreadable)"}, and ${pin.by === "recipe" ? "the recipe pins" : "its first install recorded"} ${pin.sha256}. Install it again with: ${line}`);
208
219
  say(`${recipe.label}: the binary is the pinned one (${pin.by === "recipe" ? "the recipe's sha256" : "the first sha256 its install recorded"})`);
209
- const acp = acpCheckPackage();
220
+ const acp = acpPackage();
210
221
  if (!acp)
211
222
  return refuse("HARNESS_NOT_INSTALLED", `the ACP adapter (${ACP_PACKAGE}) is not installed beside this server`);
212
- // The model, and who bills it.
223
+ // The run's model, for a recipe billed through the proxy: named here; its key, the login refusal and its price are its
224
+ // entry's (below), as a server's are.
213
225
  const env = options.env;
214
- let provider;
215
- let price;
216
- let capModel;
226
+ let needs;
217
227
  if (recipe.model.billing === "proxy") {
218
228
  const ref = options.model ? modelRef(options.model) : undefined;
219
229
  if (!ref)
220
230
  return refuse("HARNESS_CHECK_USAGE", `${recipe.label} is billed through the proxy: name the run's model with --model provider/model-id (openrouter/anthropic/claude-haiku-4.5, anthropic/claude-haiku-4-5)`);
221
- try {
222
- provider = providerFor("anthropic-messages", env, ref, recipe.label);
223
- }
224
- catch (error) {
225
- return refuse("HARNESS_CHECK_MODEL", error.message);
226
- }
227
- if (provider.login)
228
- return refuse("HARNESS_CHECK_MODEL", `${recipe.label} runs on a model key: Claude Code's login on this machine is its CLI's alone`);
229
- const models = await providerModels(env);
230
- const listed = models.getModel(provider.priceModel.provider, provider.priceModel.modelId);
231
- price = priceOf({ model: provider.priceModel, models });
232
- capModel = capModelOf(provider.priceModel.modelId, "anthropic-messages", listed, listed === undefined);
233
- if (!capModel.price)
234
- return refuse("HARNESS_CHECK_MODEL", `${provider.priceModel.provider}/${provider.priceModel.modelId} has no price here, so the check's cap could not hold; name a priced model`);
231
+ needs = { model: ref, models: await providerModels(env) };
235
232
  }
236
233
  // The session: the check's tools, its gate, its egress proxy, the recording fetch.
237
234
  const nonce = randomBytes(6).toString("hex");
@@ -277,58 +274,90 @@ export async function harnessCheck(options) {
277
274
  const hostEnv = Object.create(env, { HARNESS_CHECK_CANARY: { value: canary, enumerable: true } });
278
275
  // The values of every key the host holds, the server's own included: withSecrets keeps those off its enumeration, so
279
276
  // each is read by name.
280
- const hostSecrets = [...new Set([...SECRET_NAMES, ...Object.keys(env).filter((name) => keyShaped(name))])]
281
- .filter((name) => !recipe.keys.includes(name))
282
- .map((name) => env[name])
283
- .filter((value) => typeof value === "string" && value.length >= 8);
277
+ const hostKeys = keyValues(env, recipe.keys);
284
278
  const childVars = { ...recipe.env };
285
- if (recipe.model.billing === "proxy")
286
- childVars[recipe.model.env] = provider.modelId;
287
279
  for (const name of EGRESS_VARS)
288
280
  childVars[name] = egress.url;
289
281
  for (const name of NO_PROXY_VARS)
290
282
  childVars[name] = `${LOOPBACK},localhost`; // key-gate: loopback-rule the hosts the agent reaches without the refusing proxy: the model proxy and MCP on this machine
291
- const acpRecipe = {
283
+ // The run's model id reaches a proxy-billed agent under the variable its recipe names.
284
+ const modelVar = recipe.model.billing === "proxy" ? recipe.model.env : undefined;
285
+ const acpRecipeOf = (model) => ({
292
286
  id: recipe.id,
293
287
  label: recipe.label,
294
288
  command: binary,
295
289
  args: [...recipe.args],
296
- env: childVars,
290
+ env: { ...childVars, ...(modelVar && model !== undefined ? { [modelVar]: model } : {}) },
297
291
  keys: [...recipe.keys],
298
292
  files: { ...recipe.files },
299
293
  state: [...recipe.state],
300
294
  declares: { ...recipe.declares },
301
295
  billing: recipe.model.billing === "proxy" ? { kind: "proxy" } : { kind: "plan", maxTurns: recipe.model.maxTurns, maxToolCalls: recipe.model.maxToolCalls },
302
296
  ...(recipe.quirks.mcpCall ? { quirks: { mcpCall: recipe.quirks.mcpCall } } : {}),
297
+ });
298
+ const starts = [];
299
+ // Each start of the agent's process checks the pin again: a binary swapped after the check began never runs.
300
+ const beforeStart = async (command) => {
301
+ const now = await digestOf(command);
302
+ starts.push(now);
303
+ if (now !== pin.sha256)
304
+ throw new Error(`${ARCHIVE_CODES.binary}: ${command} changed after the check began (sha256 ${now})`);
303
305
  };
304
- const messagesProxy = recipe.model.billing === "proxy" ? acp.gooseProxy({ model: provider.modelId, provider: { origin: provider.origin, credential: provider.credential, ...(provider.auth ? { auth: provider.auth } : {}) }, ...(price ? { price } : {}), log, fetch: recording }) : undefined;
306
+ // A recipe starts as an ACP agent outside the built-ins does on a server (harness-table.ts acpEntryOf), on this check's
307
+ // log and host environment. Proxy-billed: as a module's, its model and key chosen and a login refused there, its price,
308
+ // the adapter over its recipe and the session's model proxy (the one on Anthropic's Messages there is, Goose's policy,
309
+ // its address under the variable the recipe names). Billed to its plan: as Cursor's, on its vendor's own default model.
305
310
  const proxyAt = recipe.model.billing === "proxy" ? (recipe.model.hostEnv ?? "ANTHROPIC_HOST") : "ANTHROPIC_HOST";
306
- const proxy = messagesProxy && (async (session) => {
307
- // The proxy's own address, under proxyAt, beside the key that opens it alone (never a provider's).
308
- const started = await messagesProxy(session);
309
- const { ANTHROPIC_HOST: address, ...opens } = started.env;
310
- return { env: { ...opens, [proxyAt]: address }, close: started.close };
311
- });
311
+ const entry = needs ? acpEntryOf({
312
+ facts: { ...acp.gooseFacts, id: recipe.id, label: recipe.label },
313
+ recipe: (launch) => acpRecipeOf(launch.model),
314
+ proxy: (launch) => {
315
+ const messagesProxy = acp.gooseProxy({ model: launch.model, provider: launch.provider, price: launch.price, log: launch.log, fetch: recording });
316
+ return async (session) => {
317
+ // The proxy's own address, under proxyAt, beside the key that opens it alone (never a provider's).
318
+ const started = await messagesProxy(session);
319
+ const { ANTHROPIC_HOST: address, ...opens } = started.env;
320
+ return { env: { ...opens, [proxyAt]: address }, close: started.close };
321
+ };
322
+ },
323
+ beforeStart,
324
+ }, { log }) : acpEntryOf({
325
+ facts: { ...acp.cursorFacts, id: recipe.id, label: recipe.label },
326
+ recipe: () => acpRecipeOf(),
327
+ beforeStart,
328
+ }, { log });
329
+ const planNeeds = { model: { provider: recipe.id, modelId: "default" }, models: { getModel: () => undefined } };
330
+ const adapterFor = async () => entry.adapter(hostEnv, needs ?? planNeeds);
331
+ // The first runner's adapter is made before any turn, so a model this server can't run is refused before the agent
332
+ // starts; with it, the cap's model, priced here or refused.
333
+ let firstAdapter;
334
+ let capModel;
335
+ if (needs) {
336
+ const refuseHere = async (message) => {
337
+ await egress.close();
338
+ await rm(work, { recursive: true, force: true }).catch(() => { });
339
+ return refuse("HARNESS_CHECK_MODEL", message);
340
+ };
341
+ try {
342
+ firstAdapter = await adapterFor();
343
+ }
344
+ catch (error) {
345
+ return refuseHere(error.message);
346
+ }
347
+ const priceModel = entry.priceModel(hostEnv, needs.model);
348
+ const listed = needs.models.getModel(priceModel.provider, priceModel.modelId);
349
+ capModel = capModelOf(priceModel.modelId, "anthropic-messages", listed, listed === undefined);
350
+ if (!capModel.price)
351
+ return refuseHere(`${priceModel.provider}/${priceModel.modelId} has no price here, so the check's cap could not hold; name a priced model`);
352
+ }
312
353
  let capUsd = options.capUsd ?? CHECK_DEFAULT_CAP_USD;
313
354
  const store = checkStore();
314
- const starts = [];
315
- const adapterFor = (sessionsDir) => acp.acpAdapter({
316
- recipe: acpRecipe,
317
- sessionsDir,
318
- env: hostEnv,
319
- log,
320
- // Each start of the agent's process checks the pin again: a binary swapped after the check began never runs.
321
- beforeStart: async (command) => {
322
- const now = await digestOf(command);
323
- starts.push(now);
324
- if (now !== pin.sha256)
325
- throw new Error(`${ARCHIVE_CODES.binary}: ${command} changed after the check began (sha256 ${now})`);
326
- },
327
- ...(proxy ? { proxy } : {}),
328
- });
329
355
  const refusedRequests = [];
330
356
  let lastBooking;
331
- const sessionOn = async (sessionsDir) => {
357
+ // A runner's session, in its own directory (the one a server lends, io.dir), on its own adapter.
358
+ const sessionOn = async (dir) => {
359
+ const adapter = firstAdapter ?? (await adapterFor());
360
+ firstAdapter = undefined;
332
361
  const writer = await store.open("check");
333
362
  const booking = await modelPortFor(writer, {
334
363
  key: "check",
@@ -337,7 +366,7 @@ export async function harnessCheck(options) {
337
366
  });
338
367
  lastBooking = booking;
339
368
  const controller = new AbortController();
340
- const session = await adapterFor(sessionsDir).open({ key: "check", label: "root", system: [], tools, context: "fresh" }, { writer, models: booking.models, signal: controller.signal, onEvent: () => { }, gate });
369
+ const session = await adapter.open({ key: "check", label: "root", system: [], tools, context: "fresh" }, { writer, models: booking.models, signal: controller.signal, onEvent: () => { }, gate, dir });
341
370
  const turn = async (text) => {
342
371
  const timer = setTimeout(() => controller.abort(new Error("the turn took too long")), options.turnMs ?? TURN_MS);
343
372
  try {
@@ -381,9 +410,9 @@ export async function harnessCheck(options) {
381
410
  // Stage 2: the environment is the allowlist.
382
411
  if (environ) {
383
412
  // The recipe's keys too: the adapter hands each over by name (recipe.keys), never through childVars.
384
- const expected = new Set([...Object.values(AGENT_VARS).flat(), ...Object.keys(childVars), ...recipe.keys, ...SHELL_OWN]);
413
+ const expected = new Set([...Object.values(AGENT_VARS).flat(), ...Object.keys(childVars), ...(modelVar ? [modelVar] : []), ...recipe.keys, ...SHELL_OWN]);
385
414
  const extra = Object.keys(environ).filter((name) => !expected.has(name)).sort();
386
- const leaked = Object.entries(environ).filter(([, value]) => hostSecrets.includes(value) || value === canary).map(([name]) => name).sort();
415
+ const leaked = Object.entries(environ).filter(([, value]) => hostKeys.includes(value) || value === canary).map(([name]) => name).sort();
387
416
  stage2.env_allowlist = { ok: extra.length === 0 && leaked.length === 0, names: Object.keys(environ).sort(), beyondAllowlist: extra, hostSecretsSeen: leaked };
388
417
  }
389
418
  else
@@ -1,5 +1,4 @@
1
- import { type AcpPackage } from "./acp-package.js";
2
- import { type ArchiveInstallOptions } from "./harness-archive.js";
1
+ import type { AcpPackage } from "./acp-package.js";
3
2
  export declare const CURSOR_ID = "cursor";
4
3
  /** The key Cursor runs on: the owner's Cursor API key, read by name, handed to Cursor's runs and no other. */
5
4
  export declare const CURSOR_KEY = "CURSOR_API_KEY";
@@ -9,15 +8,15 @@ export declare const CURSOR_MAX_TOOL_CALLS_ENV = "AGENTRUN_CURSOR_MAX_TOOL_CALLS
9
8
  /** The provider a Cursor model is named under (`cursor/<model>`, `cursor/default` for Cursor's own default). */
10
9
  export declare const CURSOR_PROVIDER = "cursor";
11
10
  export declare const CURSOR_DEFAULT_MODEL = "default";
12
- /** Why Cursor does not run here: a code and words that start with it and end with what to do. */
13
- export type CursorMissing = {
14
- readonly code: string;
15
- readonly message: string;
16
- };
17
- /** Cursor's folder in `data`. Its launcher is at the pin's `cmd` inside it (`./dist-package/cursor-agent`). */
18
- export declare const cursorDirOf: (data: string) => string;
19
- /** The command that installs Cursor into `data`: naming it with --data unless it is the agentrun command's own. */
20
- export declare function cursorInstallLine(acp: AcpPackage, data: string, env?: NodeJS.ProcessEnv): string;
11
+ /** Cursor as an owner-installed harness, pinned by its tree: its pin, its install line and its not-installed code are its
12
+ * package's. */
13
+ export declare const CURSOR: import("./harness-owned.js").OwnerInstalled;
14
+ export declare const cursorHidden: (env: NodeJS.ProcessEnv) => string | undefined, cursorMissing: (env: NodeJS.ProcessEnv) => Promise<{
15
+ missing: import("./harness-owned.js").OwnerMissing;
16
+ } | {
17
+ binary: string;
18
+ sha256: string;
19
+ }>;
21
20
  /** The limits a run of Cursor stops at on `env`: the owner's (CURSOR_MAX_TURNS_ENV, CURSOR_MAX_TOOL_CALLS_ENV), else the
22
21
  * package's. A setting that is no whole number is refused by name. */
23
22
  export declare function cursorLimitsOf(acp: AcpPackage, env: NodeJS.ProcessEnv): {
@@ -27,19 +26,3 @@ export declare function cursorLimitsOf(acp: AcpPackage, env: NodeJS.ProcessEnv):
27
26
  /** The card Cursor's owner reads (capabilities' harness `card`), with this server's limits; none where Cursor's adapter is
28
27
  * not beside the server, or its limits are set wrong (its refusal says so). */
29
28
  export declare function cursorCardOf(env: NodeJS.ProcessEnv): string | undefined;
30
- /** Why Cursor is not listed here (HarnessEntry.hidden): not installed, or its launcher not the pinned one, in words that end
31
- * with what to do, restarting AgentRun included. Undefined once it is installed. The files beside the launcher are
32
- * checked off the event loop, by cursorMissing at each run and the start's probe. */
33
- export declare function cursorHidden(env: NodeJS.ProcessEnv): string | undefined;
34
- /** Why Cursor cannot run here, its launcher and every file beside it checked off the event loop; else its launcher. */
35
- export declare function cursorMissing(env: NodeJS.ProcessEnv): Promise<{
36
- missing: CursorMissing;
37
- } | {
38
- binary: string;
39
- }>;
40
- /** Installs the pinned Cursor into `data` (agentrun-serve install-harness cursor). */
41
- export declare function installCursor(data: string, options?: ArchiveInstallOptions, env?: NodeJS.ProcessEnv): Promise<{
42
- installed: "already" | "now";
43
- binary: string;
44
- version: string;
45
- }>;
@@ -1,15 +1,5 @@
1
- // Cursor on this server: where its owner installs it (`<data>/harnesses/cursor`, by `agentrun harness install cursor`,
2
- // harness-archive.ts), the command that does, whether what is there is the pinned release (its launcher and every file
3
- // beside it), the key it runs on (CURSOR_API_KEY, the owner's), the limits a run of it stops at and the card its owner
4
- // reads. Nothing here downloads: a run, a save and the start's probe only look at what is installed, and say the command
5
- // where it is not. Cursor's model is Cursor's, billed to the owner's Cursor plan: no request of it reaches a proxy of ours.
6
- import { existsSync } from "node:fs";
7
- import { join, resolve } from "node:path";
8
1
  import { acpPackage } from "./acp-package.js";
9
- import { commandData } from "./harness-goose.js";
10
- import { installArchive } from "./harness-archive.js";
11
- import { installDirOf, shellWord } from "./harness-install.js";
12
- import { DATA_ENV, defaultData } from "./server-fs.js";
2
+ import { ownerInstalled } from "./harness-owned.js";
13
3
  export const CURSOR_ID = "cursor";
14
4
  /** The key Cursor runs on: the owner's Cursor API key, read by name, handed to Cursor's runs and no other. */
15
5
  export const CURSOR_KEY = "CURSOR_API_KEY";
@@ -19,13 +9,10 @@ export const CURSOR_MAX_TOOL_CALLS_ENV = "AGENTRUN_CURSOR_MAX_TOOL_CALLS";
19
9
  /** The provider a Cursor model is named under (`cursor/<model>`, `cursor/default` for Cursor's own default). */
20
10
  export const CURSOR_PROVIDER = "cursor";
21
11
  export const CURSOR_DEFAULT_MODEL = "default";
22
- const dataOf = (env) => env[DATA_ENV] || defaultData(env);
23
- /** Cursor's folder in `data`. Its launcher is at the pin's `cmd` inside it (`./dist-package/cursor-agent`). */
24
- export const cursorDirOf = (data) => installDirOf(data, CURSOR_ID);
25
- /** The command that installs Cursor into `data`: naming it with --data unless it is the agentrun command's own. */
26
- export function cursorInstallLine(acp, data, env = process.env) {
27
- return resolve(data) === commandData(env) ? acp.CURSOR_INSTALL : `${acp.CURSOR_INSTALL} --data ${shellWord(data)}`;
28
- }
12
+ /** Cursor as an owner-installed harness, pinned by its tree: its pin, its install line and its not-installed code are its
13
+ * package's. */
14
+ export const CURSOR = ownerInstalled({ id: CURSOR_ID, label: "Cursor", pin: (acp) => acp.CURSOR_PIN, installLine: (acp) => acp.CURSOR_INSTALL, notInstalled: (acp) => acp.CURSOR_CODES.notInstalled, tree: true });
15
+ export const { hidden: cursorHidden, missing: cursorMissing } = CURSOR;
29
16
  /** The limits a run of Cursor stops at on `env`: the owner's (CURSOR_MAX_TURNS_ENV, CURSOR_MAX_TOOL_CALLS_ENV), else the
30
17
  * package's. A setting that is no whole number is refused by name. */
31
18
  export function cursorLimitsOf(acp, env) {
@@ -53,69 +40,3 @@ export function cursorCardOf(env) {
53
40
  return undefined;
54
41
  }
55
42
  }
56
- /** What is known of Cursor in `env`'s data before its files are read: why it is missing, or its launcher, its folder and
57
- * the digests they must have, with how a refused check is said. */
58
- function lookup(env) {
59
- const acp = acpPackage();
60
- if (!acp)
61
- return { missing: { code: "HARNESS_NOT_INSTALLED", message: "HARNESS_NOT_INSTALLED: Cursor's adapter (@parcha/agentrun-harness-acp) is not installed beside this server" } };
62
- const data = dataOf(env);
63
- const root = cursorDirOf(data);
64
- const line = cursorInstallLine(acp, data, env);
65
- const { version } = acp.CURSOR_PIN;
66
- const platform = acp.acpPlatform();
67
- const release = acp.cursorRelease(platform);
68
- if (!release)
69
- return { missing: { code: "ACP_BINARY_UNPINNED", message: `ACP_BINARY_UNPINNED: Cursor ${version} has no release pinned for ${platform ?? `${process.platform}-${process.arch}`}, so it does not run here` } };
70
- const binary = join(root, release.cmd);
71
- if (!existsSync(binary))
72
- return { missing: { code: acp.CURSOR_CODES.notInstalled, message: `${acp.CURSOR_CODES.notInstalled}: Cursor ${version} is not installed in ${root}. Install it with: ${line}` } };
73
- return {
74
- acp, binary, root, launcher: release.binarySha256, tree: release.treeSha256,
75
- refused: (error) => {
76
- const code = error?.code;
77
- return { code: typeof code === "string" ? code : acp.CURSOR_CODES.notInstalled, message: `${error.message}. Install Cursor ${version} again with: ${line}` };
78
- },
79
- };
80
- }
81
- /** Why Cursor is not listed here (HarnessEntry.hidden): not installed, or its launcher not the pinned one, in words that end
82
- * with what to do, restarting AgentRun included. Undefined once it is installed. The files beside the launcher are
83
- * checked off the event loop, by cursorMissing at each run and the start's probe. */
84
- export function cursorHidden(env) {
85
- const found = lookup(env);
86
- let missing;
87
- if ("missing" in found)
88
- missing = found.missing;
89
- else {
90
- try {
91
- found.acp.verifyPinnedBinary(found.binary, found.launcher);
92
- }
93
- catch (error) {
94
- missing = found.refused(error);
95
- }
96
- }
97
- return missing && `${missing.message}; then restart AgentRun.`;
98
- }
99
- /** Why Cursor cannot run here, its launcher and every file beside it checked off the event loop; else its launcher. */
100
- export async function cursorMissing(env) {
101
- const found = lookup(env);
102
- if ("missing" in found)
103
- return found;
104
- try {
105
- await found.acp.verifyPinnedBinaryAsync(found.binary, found.launcher);
106
- await found.acp.verifyPinnedTree(found.root, found.tree);
107
- }
108
- catch (error) {
109
- return { missing: found.refused(error) };
110
- }
111
- return { binary: found.binary };
112
- }
113
- /** Installs the pinned Cursor into `data` (agentrun-serve install-harness cursor). */
114
- export async function installCursor(data, options = {}, env = process.env) {
115
- const acp = acpPackage();
116
- if (!acp)
117
- throw new Error("Cursor's adapter (@parcha/agentrun-harness-acp) is not installed beside this server, so it has no pin to install from");
118
- const { id, version, archives } = acp.CURSOR_PIN;
119
- const platform = acp.acpPlatform();
120
- return { version, ...(await installArchive({ id, label: "Cursor", retry: cursorInstallLine(acp, data, env), pin: { version, archives }, tree: (root) => acp.treeDigest(root) }, cursorDirOf(data), { ...(platform ? { platform } : {}), ...options })) };
121
- }
@@ -1,34 +1,9 @@
1
- import { type AcpPackage } from "./acp-package.js";
2
- import { type ArchiveInstallOptions } from "./harness-archive.js";
3
1
  export declare const GOOSE_ID = "goose";
4
- /** Why Goose does not run here: a code (HARNESS_NOT_INSTALLED, ACP_BINARY_MISMATCH, ACP_BINARY_UNPINNED, ...) and words
5
- * that start with it and end with the command that installs it. */
6
- export type GooseMissing = {
7
- readonly code: string;
8
- readonly message: string;
9
- };
10
- /** Goose's folder in `data`, and its binary there. */
11
- export declare const gooseDirOf: (data: string) => string;
12
- export declare const gooseBinaryOf: (data: string) => string;
13
- /** The agentrun command's own data directory, where `npx @parcha/agentrun` keeps its server's store (~/.agentrun: not the
14
- * server's own default, defaultData), and so where `agentrun harness install` installs with no --data. */
15
- export declare const commandData: (env: NodeJS.ProcessEnv) => string;
16
- /** The command that installs Goose into `data`: naming it with --data unless it is the agentrun command's own (commandData). */
17
- export declare function gooseInstallLine(acp: AcpPackage, data: string, env?: NodeJS.ProcessEnv): string;
18
- /** Why Goose is not listed here (HarnessEntry.hidden): not installed, or not the pinned binary, in words that end with what
19
- * to do, restarting AgentRun included (its harnesses are read at its start). Undefined once it is installed and verified.
20
- * The binary's sha256 is kept once per file identity (the package's check), so only the first look reads it. */
21
- export declare function gooseHidden(env: NodeJS.ProcessEnv): string | undefined;
22
- /** Why Goose cannot run here, its binary checked off the event loop; undefined when it can (with the binary to run). */
23
- export declare function gooseMissing(env: NodeJS.ProcessEnv): Promise<{
24
- missing: GooseMissing;
2
+ /** Goose as an owner-installed harness: its pin, its install line and its not-installed code are its package's. */
3
+ export declare const GOOSE: import("./harness-owned.js").OwnerInstalled;
4
+ export declare const gooseHidden: (env: NodeJS.ProcessEnv) => string | undefined, gooseMissing: (env: NodeJS.ProcessEnv) => Promise<{
5
+ missing: import("./harness-owned.js").OwnerMissing;
25
6
  } | {
26
7
  binary: string;
27
8
  sha256: string;
28
9
  }>;
29
- /** Installs the pinned Goose into `data` (agentrun-serve install-harness goose). */
30
- export declare function installGoose(data: string, options?: ArchiveInstallOptions, env?: NodeJS.ProcessEnv): Promise<{
31
- installed: "already" | "now";
32
- binary: string;
33
- version: string;
34
- }>;
@@ -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;