@parcha/agentrun-serve 0.1.0-beta.29 → 0.1.0-beta.30

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 (152) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/README.md +564 -97
  3. package/dist/adapters.d.ts +35 -6
  4. package/dist/adapters.js +152 -26
  5. package/dist/agents.d.ts +11 -5
  6. package/dist/agents.js +16 -10
  7. package/dist/app.js +80 -20
  8. package/dist/background.d.ts +28 -0
  9. package/dist/background.js +376 -0
  10. package/dist/box-egress.d.ts +98 -0
  11. package/dist/box-egress.js +259 -0
  12. package/dist/box-image.d.ts +1 -1
  13. package/dist/box-image.js +9 -7
  14. package/dist/box-relay-vm.d.ts +80 -0
  15. package/dist/box-relay-vm.js +389 -0
  16. package/dist/box-relay.d.ts +8 -5
  17. package/dist/box-relay.js +14 -9
  18. package/dist/boxes.d.ts +21 -3
  19. package/dist/boxes.js +14 -7
  20. package/dist/browser-cost.d.ts +41 -0
  21. package/dist/browser-cost.js +158 -0
  22. package/dist/cap.d.ts +129 -21
  23. package/dist/cap.js +338 -67
  24. package/dist/coding-tools.d.ts +7 -3
  25. package/dist/coding-tools.js +16 -10
  26. package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
  27. package/dist/console/assets/index-34jfpIbQ.js +481 -0
  28. package/dist/console/assets/index-DUHbWcIP.css +1 -0
  29. package/dist/console/index.html +2 -2
  30. package/dist/content-filter.d.ts +7 -0
  31. package/dist/content-filter.js +23 -0
  32. package/dist/decision-rows.d.ts +11 -3
  33. package/dist/decision-rows.js +18 -11
  34. package/dist/errors.d.ts +2 -0
  35. package/dist/errors.js +5 -2
  36. package/dist/files.d.ts +6 -1
  37. package/dist/files.js +7 -2
  38. package/dist/grade.d.ts +7 -10
  39. package/dist/grade.js +31 -51
  40. package/dist/graph-served.d.ts +23 -0
  41. package/dist/graph-served.js +75 -0
  42. package/dist/graph-view.d.ts +7 -5
  43. package/dist/graph-view.js +10 -3
  44. package/dist/harness-app.d.ts +4 -2
  45. package/dist/harness-app.js +101 -19
  46. package/dist/harness-opencode/adapter.d.ts +45 -0
  47. package/dist/harness-opencode/adapter.js +272 -0
  48. package/dist/harness-opencode/binary.d.ts +18 -0
  49. package/dist/harness-opencode/binary.js +87 -0
  50. package/dist/harness-opencode/config.d.ts +24 -0
  51. package/dist/harness-opencode/config.js +61 -0
  52. package/dist/harness-opencode/harness.d.ts +77 -0
  53. package/dist/harness-opencode/harness.js +620 -0
  54. package/dist/harness-opencode/host/mcp.d.ts +40 -0
  55. package/dist/harness-opencode/host/mcp.js +208 -0
  56. package/dist/harness-opencode/host/policy.d.ts +71 -0
  57. package/dist/harness-opencode/host/policy.js +419 -0
  58. package/dist/harness-opencode/host/server.d.ts +55 -0
  59. package/dist/harness-opencode/host/server.js +165 -0
  60. package/dist/harness-opencode/index.d.ts +9 -0
  61. package/dist/harness-opencode/index.js +6 -0
  62. package/dist/harness-opencode/verify.d.ts +32 -0
  63. package/dist/harness-opencode/verify.js +75 -0
  64. package/dist/harness-opencode/versions.d.ts +33 -0
  65. package/dist/harness-opencode/versions.js +64 -0
  66. package/dist/harness.d.ts +4 -1
  67. package/dist/harness.js +5 -2
  68. package/dist/host-tools.d.ts +12 -2
  69. package/dist/host-tools.js +26 -12
  70. package/dist/host.js +6 -2
  71. package/dist/hosted-search.js +5 -1
  72. package/dist/import.d.ts +2 -2
  73. package/dist/import.js +4 -3
  74. package/dist/key-check.d.ts +3 -2
  75. package/dist/key-check.js +7 -3
  76. package/dist/key-refusal.js +8 -4
  77. package/dist/learn/check.d.ts +10 -1
  78. package/dist/learn/check.js +19 -1
  79. package/dist/learn/grade.d.ts +3 -2
  80. package/dist/learn/grade.js +25 -13
  81. package/dist/learn/index.d.ts +2 -2
  82. package/dist/learn/index.js +2 -2
  83. package/dist/learn/notes.js +2 -1
  84. package/dist/learn/reflect.d.ts +2 -2
  85. package/dist/learn/reflect.js +51 -5
  86. package/dist/learn/secrets.js +28 -8
  87. package/dist/learn/skills.d.ts +17 -4
  88. package/dist/learn/skills.js +79 -6
  89. package/dist/learned-workflow.d.ts +59 -0
  90. package/dist/learned-workflow.js +191 -0
  91. package/dist/learning-run.d.ts +7 -5
  92. package/dist/learning-run.js +45 -23
  93. package/dist/learning-words.d.ts +6 -3
  94. package/dist/learning-words.js +8 -5
  95. package/dist/learning.d.ts +44 -3
  96. package/dist/learning.js +148 -3
  97. package/dist/mcp-servers.d.ts +7 -4
  98. package/dist/mcp-servers.js +5 -0
  99. package/dist/mcp.js +5 -5
  100. package/dist/model.d.ts +13 -11
  101. package/dist/model.js +11 -10
  102. package/dist/openapi/agentrun-v2.openapi.json +1 -0
  103. package/dist/openapi.js +358 -48
  104. package/dist/paid-calls.d.ts +5 -1
  105. package/dist/paid-calls.js +1 -1
  106. package/dist/pause.d.ts +2 -0
  107. package/dist/place.d.ts +27 -4
  108. package/dist/place.js +42 -10
  109. package/dist/propose.d.ts +2 -0
  110. package/dist/propose.js +38 -8
  111. package/dist/request-start.d.ts +12 -4
  112. package/dist/request-start.js +139 -15
  113. package/dist/run-box.d.ts +56 -4
  114. package/dist/run-box.js +173 -23
  115. package/dist/runnable.d.ts +5 -2
  116. package/dist/runnable.js +12 -4
  117. package/dist/runs.d.ts +258 -36
  118. package/dist/runs.js +830 -89
  119. package/dist/secrets.d.ts +12 -0
  120. package/dist/secrets.js +18 -0
  121. package/dist/server.d.ts +131 -35
  122. package/dist/server.js +467 -105
  123. package/dist/sign-ins.d.ts +99 -0
  124. package/dist/sign-ins.js +288 -0
  125. package/dist/skills.d.ts +16 -4
  126. package/dist/skills.js +35 -7
  127. package/dist/stats.d.ts +7 -2
  128. package/dist/stats.js +28 -7
  129. package/dist/tool-gate.d.ts +266 -0
  130. package/dist/tool-gate.js +554 -0
  131. package/dist/tool-keys.d.ts +46 -10
  132. package/dist/tool-keys.js +44 -2
  133. package/dist/tool-plane.d.ts +112 -27
  134. package/dist/tool-plane.js +205 -47
  135. package/dist/tools.d.ts +69 -14
  136. package/dist/tools.js +143 -24
  137. package/dist/trigger-secrets.d.ts +32 -0
  138. package/dist/trigger-secrets.js +143 -0
  139. package/dist/triggers.d.ts +439 -0
  140. package/dist/triggers.js +863 -0
  141. package/dist/turn-end.d.ts +3 -2
  142. package/dist/turn-end.js +3 -2
  143. package/dist/usage-lines.d.ts +26 -0
  144. package/dist/usage-lines.js +28 -0
  145. package/dist/validate.d.ts +2 -0
  146. package/dist/validate.js +11 -2
  147. package/dist/webhooks.d.ts +11 -4
  148. package/dist/webhooks.js +17 -1
  149. package/launcher/agentrun-serve +1 -1
  150. package/package.json +19 -13
  151. package/dist/console/assets/index-BN7oVcO4.js +0 -445
  152. package/dist/console/assets/index-By-jkqki.css +0 -1
@@ -0,0 +1,32 @@
1
+ import { OpenCodeNotInstalled, OpenCodePinMismatch } from "./versions.js";
2
+ export interface OpenCodePins {
3
+ /** The release `opencode --version` must report. */
4
+ version: string;
5
+ /** The binary's sha256 for each platform package the pins list; a package not listed is unchecked here. */
6
+ sha256: Readonly<Record<string, string>>;
7
+ }
8
+ /** The pins this package holds. */
9
+ export declare const openCodePins: () => OpenCodePins;
10
+ /**
11
+ * The binary at `found.path` checked against `pins`, in order: its platform package's version, the binary's sha256 (its
12
+ * package's pin, or for a binary named by OPENCODE_BIN the pin of any package this machine may run, when the pins list
13
+ * one), then the version it reports. Returns the path, or the typed error (not thrown) naming the
14
+ * pin, what was expected and what was found. No path, or a binary that cannot be read or run, is `OpenCodeNotInstalled`.
15
+ * The path is made absolute first, from this process's working directory: a session starts the binary from its own
16
+ * directory, where a relative `OPENCODE_BIN` names nothing.
17
+ */
18
+ export declare function verifyOpenCodeBinary(found: {
19
+ path: string;
20
+ pkg?: string;
21
+ packageVersion?: string;
22
+ } | undefined, pins?: OpenCodePins): {
23
+ path: string;
24
+ } | OpenCodePinMismatch | OpenCodeNotInstalled;
25
+ /** This machine's OpenCode checked against the pins: its path, or the typed error thrown. */
26
+ export declare function verifyOpenCode(found?: {
27
+ path: string;
28
+ pkg?: string;
29
+ packageVersion?: string;
30
+ } | undefined, pins?: OpenCodePins): {
31
+ path: string;
32
+ };
@@ -0,0 +1,75 @@
1
+ // The installed OpenCode checked against the pins (src/versions.ts) before anything runs, with the typed errors a host
2
+ // maps to a run's failure line. Written for AgentRun.
3
+ import { execFileSync } from "node:child_process";
4
+ import { existsSync, mkdtempSync, rmSync } from "node:fs";
5
+ import { tmpdir } from "node:os";
6
+ import { join, resolve } from "node:path";
7
+ import { env } from "node:process";
8
+ import { checkedOnce, sha256OfFile } from "@parcha/agentrun-kernel/host";
9
+ import { findOpenCode, openCodePackages } from "./binary.js";
10
+ import { OPENCODE_BINARY_SHA256, OPENCODE_VERSION, OpenCodeNotInstalled, OpenCodePinMismatch } from "./versions.js";
11
+ /** The pins this package holds. */
12
+ export const openCodePins = () => ({ version: OPENCODE_VERSION, sha256: OPENCODE_BINARY_SHA256 });
13
+ /**
14
+ * The binary at `found.path` checked against `pins`, in order: its platform package's version, the binary's sha256 (its
15
+ * package's pin, or for a binary named by OPENCODE_BIN the pin of any package this machine may run, when the pins list
16
+ * one), then the version it reports. Returns the path, or the typed error (not thrown) naming the
17
+ * pin, what was expected and what was found. No path, or a binary that cannot be read or run, is `OpenCodeNotInstalled`.
18
+ * The path is made absolute first, from this process's working directory: a session starts the binary from its own
19
+ * directory, where a relative `OPENCODE_BIN` names nothing.
20
+ */
21
+ export function verifyOpenCodeBinary(found, pins = openCodePins()) {
22
+ if (!found)
23
+ return new OpenCodeNotInstalled("no OpenCode binary found for this platform, and OPENCODE_BIN is not set");
24
+ const path = resolve(found.path);
25
+ if (!existsSync(path))
26
+ return new OpenCodeNotInstalled(`no file at ${path}`);
27
+ if (found.packageVersion !== undefined && found.packageVersion !== pins.version)
28
+ return new OpenCodePinMismatch("package_version", pins.version, found.packageVersion, path);
29
+ // A binary from a platform package is checked against that package's pin; one named by OPENCODE_BIN (no package) against
30
+ // the pins of every package this machine may run.
31
+ const expected = (found.pkg ? [found.pkg] : openCodePackages()).map((pkg) => pins.sha256[pkg]).filter((sha) => typeof sha === "string");
32
+ // Hashed a chunk at a time, and checked once per binary in this process while it stays the same file, unchanged (the
33
+ // kernel's checkedOnce): a host that checks it for each model it resolves, and a run's process that makes its adapter,
34
+ // check it once.
35
+ return checkedOnce(path, JSON.stringify({ version: pins.version, expected }), () => checkBinary(path, pins.version, expected), (result) => !(result instanceof Error));
36
+ }
37
+ /** The binary at `path` (absolute, there) against the sha256 values it may have and the version it must report. */
38
+ function checkBinary(path, version, expected) {
39
+ if (expected.length) {
40
+ let sha256;
41
+ try {
42
+ sha256 = sha256OfFile(path);
43
+ }
44
+ catch (error) {
45
+ return new OpenCodeNotInstalled(`${path} could not be read: ${String(error?.message ?? error).slice(0, 120)}`);
46
+ }
47
+ if (!expected.includes(sha256))
48
+ return new OpenCodePinMismatch("binary_sha256", expected[0], sha256, path);
49
+ }
50
+ let reported;
51
+ // A private home, removed after: `--version` makes OpenCode's directories, and reads no config and writes no state of
52
+ // the host's.
53
+ const home = mkdtempSync(join(tmpdir(), "agentrun-opencode-version-"));
54
+ try {
55
+ const dirs = { HOME: home, XDG_CONFIG_HOME: join(home, "config"), XDG_DATA_HOME: join(home, "data"), XDG_CACHE_HOME: join(home, "cache"), XDG_STATE_HOME: join(home, "state") };
56
+ reported = execFileSync(path, ["--version"], { env: { PATH: env.PATH ?? "/usr/bin:/bin", ...dirs, OPENCODE_DISABLE_AUTOUPDATE: "1" }, cwd: home, encoding: "utf8", timeout: 20_000 }).trim();
57
+ }
58
+ catch (error) {
59
+ return new OpenCodeNotInstalled(`${path} could not be run: ${String(error?.message ?? error).slice(0, 120)}`);
60
+ }
61
+ finally {
62
+ rmSync(home, { recursive: true, force: true });
63
+ }
64
+ const said = /^(\d+\.\d+\.\d+\S*)$/.exec(reported)?.[1] ?? JSON.stringify(reported.slice(0, 60));
65
+ if (said !== version)
66
+ return new OpenCodePinMismatch("version", version, said, path);
67
+ return { path };
68
+ }
69
+ /** This machine's OpenCode checked against the pins: its path, or the typed error thrown. */
70
+ export function verifyOpenCode(found = findOpenCode(), pins = openCodePins()) {
71
+ const result = verifyOpenCodeBinary(found, pins);
72
+ if (result instanceof Error)
73
+ throw result;
74
+ return result;
75
+ }
@@ -0,0 +1,33 @@
1
+ import { OPENCODE_VERSION } from "./binary.js";
2
+ /** The OpenCode CLI release this adapter is built and tested with (`opencode --version` prints it). */
3
+ export { OPENCODE_VERSION };
4
+ /** The install line for the pinned release (npm installs this platform's binary package with it). */
5
+ export declare const OPENCODE_INSTALL = "npm install --save-exact opencode-ai@1.19.5";
6
+ /**
7
+ * npm's integrity of the pinned launcher and of each platform package, as the registry publishes them. npm checks a
8
+ * download against the lockfile's copy of these; test/pins.test.mjs keeps the repository's lockfile equal to them.
9
+ */
10
+ export declare const OPENCODE_NPM_INTEGRITY: Readonly<Record<string, string>>;
11
+ /** The sha256 of the pinned native binary (`bin/opencode` in the platform package), per platform package, read from the
12
+ * packages those integrities name as npm installed them on Linux x64 (the two builds ship the same file). A binary from
13
+ * a package listed here runs only if it matches; one from a package not listed is checked by its package's version and
14
+ * the version it reports, and npm checked its package against the integrity above when it installed it. */
15
+ export declare const OPENCODE_BINARY_SHA256: Readonly<Record<string, string>>;
16
+ /** Which pin a mismatch is about: the binary's sha256, the version it reports, or the platform package's version. */
17
+ export type OpenCodePin = "binary_sha256" | "version" | "package_version";
18
+ /** The installed OpenCode is not the build this adapter is pinned to and checked with: nothing runs. */
19
+ export declare class OpenCodePinMismatch extends Error {
20
+ readonly pin: OpenCodePin;
21
+ readonly expected: string;
22
+ readonly found: string;
23
+ readonly path?: string | undefined;
24
+ readonly code = "OPENCODE_PIN_MISMATCH";
25
+ constructor(pin: OpenCodePin, expected: string, found: string, path?: string | undefined);
26
+ }
27
+ /** No OpenCode binary to run: the host has not installed `opencode-ai` (or this platform's package), or the binary
28
+ * named could not be run. */
29
+ export declare class OpenCodeNotInstalled extends Error {
30
+ readonly detail?: string | undefined;
31
+ readonly code = "OPENCODE_NOT_INSTALLED";
32
+ constructor(detail?: string | undefined);
33
+ }
@@ -0,0 +1,64 @@
1
+ // The OpenCode build this adapter is pinned to and checked against, and the typed errors a host maps to a run's failure
2
+ // line when the installed build is not it. Written for AgentRun.
3
+ //
4
+ // The pin is exact: the adapter mirrors OpenCode's own per-session event log into the session's records and gives it
5
+ // back to a new process (`/sync/replay`), and that log's shape is OpenCode's internal one, which any release may change.
6
+ import { OPENCODE_VERSION } from "./binary.js";
7
+ /** The OpenCode CLI release this adapter is built and tested with (`opencode --version` prints it). */
8
+ export { OPENCODE_VERSION };
9
+ /** The install line for the pinned release (npm installs this platform's binary package with it). */
10
+ export const OPENCODE_INSTALL = `npm install --save-exact opencode-ai@${OPENCODE_VERSION}`;
11
+ /**
12
+ * npm's integrity of the pinned launcher and of each platform package, as the registry publishes them. npm checks a
13
+ * download against the lockfile's copy of these; test/pins.test.mjs keeps the repository's lockfile equal to them.
14
+ */
15
+ export const OPENCODE_NPM_INTEGRITY = Object.freeze({
16
+ "opencode-ai": "sha512-tEqMvQahfhdDj8vceYpXtoIrvjPXm5XRfetWnPN5YISueU7adNx9JcUA3zZ+2GKuDVgDpGdQe1ZLtCZDjqodvA==",
17
+ "opencode-linux-x64": "sha512-i1qh7VooLGML9xX6ud93y0JA8j/1aPeDYRKjsmYXrJX1TjIWHgBBMkEbEJPZthpWbsJg//XfBgR6Kb7+NPaJiQ==",
18
+ "opencode-linux-x64-baseline": "sha512-9kA+st3XXtCXMPx5f3Ld1u19uoHTO2u2Btt8a2cqhJ4GIqVbD1mXLevj3LHFEmtuQoFGk+UstGnl38sCqXj5sQ==",
19
+ "opencode-linux-x64-musl": "sha512-y6nUbH3ViajN37KaVVy0/KnWv/i48Bx5QPv9Ul9ONJya1ossV7CHVb+ZNFc61M5GqlVtjCvZV7T0eBMqhJG7mg==",
20
+ "opencode-linux-x64-baseline-musl": "sha512-kwt6hmTaI6nujjAzdAkXv3j2rDzXNOMfMk8Jf8bwacHtwUl8CWA2psDVg3nWyb4zByAa6F1jSIlmHCPHBq1K/Q==",
21
+ "opencode-linux-arm64": "sha512-u2HFRI6v1nNMVKiV34An8XrGBxJeZ+RCg2tYu3SqlGODKqKsr5RoEbaX1tnsfGb+rETh9AJVX9kS8dSZXPufsA==",
22
+ "opencode-linux-arm64-musl": "sha512-YxvpVPJ/jeevV93DVRiuOVbhkoJAuwQUadPDHPaw65aZkAKZ6OE7XySwCS+Rjlhzt7fPryisvAOjUtZkwfMBuQ==",
23
+ "opencode-darwin-x64": "sha512-+DO7IMPTCrX12UJXnL4pL3ckcwR6BR6f6tA9QIlVQ5nZx66T5U7FRMJT4n5rsOnJxLM/pZ2vfX1G8vrnvXO8FA==",
24
+ "opencode-darwin-x64-baseline": "sha512-rftvAoHBWPVkvwBLr3SQWRZvcIjyMTN0SlhMzlt+lgvoQBBGNEmZQ/7sS/Ux1oHsJV/++UDuLVso4n5L95YD5Q==",
25
+ "opencode-darwin-arm64": "sha512-0MbSbKkmwVHtgP31GJyyECe6QVy4T7W4Wp7s2TsmXHTPPyf01ne3dWSX97X9dkNK28Lc6kt+zMPQUP/9GgDLZg==",
26
+ "opencode-windows-x64": "sha512-xCVbrA8A/qQTAdBIKyhK5tx3/mcq18yF82Mi8phry0MJb2631nnnpxF9m6FFfWAVHyer4qFGrO7hbWXesHQ1Gg==",
27
+ "opencode-windows-x64-baseline": "sha512-yRHN+TsfLjfLmdQVAVWqTGfGP1yq8YtUFy9Jw33XhlPIp77slBdCJrj2PC4amuEl6BJtaIQDhDFbpJ8+a5z7Qw==",
28
+ "opencode-windows-arm64": "sha512-aySF/MDji5KO3I5yl9Ec4g8kW/QIx4Jj5FXwBhh/FrDu0w6L8HAOGH7cyjFb3t8TW7pxRkH3Ei3rfkWAE7cScw==",
29
+ });
30
+ /** The sha256 of the pinned native binary (`bin/opencode` in the platform package), per platform package, read from the
31
+ * packages those integrities name as npm installed them on Linux x64 (the two builds ship the same file). A binary from
32
+ * a package listed here runs only if it matches; one from a package not listed is checked by its package's version and
33
+ * the version it reports, and npm checked its package against the integrity above when it installed it. */
34
+ export const OPENCODE_BINARY_SHA256 = Object.freeze({
35
+ "opencode-linux-x64": "7df4e4136301f16589b0f30bf91a61380fca5f8ef22dd36570f5ebe1d4ec802c",
36
+ "opencode-linux-x64-baseline": "7df4e4136301f16589b0f30bf91a61380fca5f8ef22dd36570f5ebe1d4ec802c",
37
+ });
38
+ /** The installed OpenCode is not the build this adapter is pinned to and checked with: nothing runs. */
39
+ export class OpenCodePinMismatch extends Error {
40
+ pin;
41
+ expected;
42
+ found;
43
+ path;
44
+ code = "OPENCODE_PIN_MISMATCH";
45
+ constructor(pin, expected, found, path) {
46
+ super(`opencode: the OpenCode ${pin === "package_version" ? "platform package" : "binary"}${path ? ` at ${path}` : ""} is not the pinned build: its ${pin.replace("_", " ")} is ${found}, not ${expected}`);
47
+ this.pin = pin;
48
+ this.expected = expected;
49
+ this.found = found;
50
+ this.path = path;
51
+ this.name = "OpenCodePinMismatch";
52
+ }
53
+ }
54
+ /** No OpenCode binary to run: the host has not installed `opencode-ai` (or this platform's package), or the binary
55
+ * named could not be run. */
56
+ export class OpenCodeNotInstalled extends Error {
57
+ detail;
58
+ code = "OPENCODE_NOT_INSTALLED";
59
+ constructor(detail) {
60
+ super(`opencode: OpenCode ${OPENCODE_VERSION} is not installed${detail ? ` (${detail})` : ""}; ${OPENCODE_INSTALL}`);
61
+ this.detail = detail;
62
+ this.name = "OpenCodeNotInstalled";
63
+ }
64
+ }
package/dist/harness.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const HARNESSES: readonly ["pi", "claude-agent", "codex"];
1
+ export declare const HARNESSES: readonly ["pi", "claude-agent", "codex", "opencode"];
2
2
  export type HarnessId = (typeof HARNESSES)[number];
3
3
  export declare const DEFAULT_HARNESS: HarnessId;
4
4
  /** The memory one run of each harness reserves while its process lives, in MiB: what admission counts (host.ts).
@@ -10,6 +10,9 @@ export declare const DEFAULT_HARNESS: HarnessId;
10
10
  * pi: n=1 106, 106; n=3 96, 99 MB a run → 128 (+21%)
11
11
  * codex: n=1 132, 143; n=3 120, 131 MB a run → 192 (+34%)
12
12
  * claude-agent: n=1 215, 208; n=3 211, 208 MB a run → 288 (+34%)
13
+ * opencode: n=1 524, 501; n=3 509, 514 MB a run → 704 (+34%), measured the same way 2026-11-04 on the pinned
14
+ * OpenCode 1.19.5 (its own process, a Bun binary, is most of it; at a 1024M limit two runs were
15
+ * OOM-killed, and at 512M one short run completed)
13
16
  * The margin covers a longer conversation than the probe's three steps; the CLI harnesses (codex, claude-agent) grow
14
17
  * more with one, so theirs is larger. At a 512M limit the same build completed pi x3, codex x2 and claude-agent x1
15
18
  * (and x2). A check that reads a binary whole adds its size to the server and to each run (294 MB for codex, 230 MB
package/dist/harness.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // one of the run adapters. A revision keeps the harness it names; the default is never stored, so a revision written
3
3
  // before this field existed and one that names pi are the same revision. Which harnesses this server runs is said in
4
4
  // capabilities, and a revision naming one it does not run saves with a warning and is refused at run time.
5
- export const HARNESSES = ["pi", "claude-agent", "codex"];
5
+ export const HARNESSES = ["pi", "claude-agent", "codex", "opencode"];
6
6
  export const DEFAULT_HARNESS = "pi";
7
7
  /** The memory one run of each harness reserves while its process lives, in MiB: what admission counts (host.ts).
8
8
  * Measured 2026-11-03 on 529c3882e with the pinned binaries' sha256 checked a chunk at a time, not read whole: a
@@ -13,12 +13,15 @@ export const DEFAULT_HARNESS = "pi";
13
13
  * pi: n=1 106, 106; n=3 96, 99 MB a run → 128 (+21%)
14
14
  * codex: n=1 132, 143; n=3 120, 131 MB a run → 192 (+34%)
15
15
  * claude-agent: n=1 215, 208; n=3 211, 208 MB a run → 288 (+34%)
16
+ * opencode: n=1 524, 501; n=3 509, 514 MB a run → 704 (+34%), measured the same way 2026-11-04 on the pinned
17
+ * OpenCode 1.19.5 (its own process, a Bun binary, is most of it; at a 1024M limit two runs were
18
+ * OOM-killed, and at 512M one short run completed)
16
19
  * The margin covers a longer conversation than the probe's three steps; the CLI harnesses (codex, claude-agent) grow
17
20
  * more with one, so theirs is larger. At a 512M limit the same build completed pi x3, codex x2 and claude-agent x1
18
21
  * (and x2). A check that reads a binary whole adds its size to the server and to each run (294 MB for codex, 230 MB
19
22
  * for the claude-agent CLI), and these sizes do not cover it. The faux model and the faux
20
23
  * harness reserve the size of the harness they stand in for, so tests admit as a real server does. */
21
- export const RUN_MIB = { pi: 128, "claude-agent": 288, codex: 192 };
24
+ export const RUN_MIB = { pi: 128, "claude-agent": 288, codex: 192, opencode: 704 };
22
25
  /** Whether a harness takes a message mid-turn: pi does; another harness's run queues it for the turn's end. */
23
26
  export const steersMidTurn = (id) => id === DEFAULT_HARNESS;
24
27
  /** A module whose `script(spec)` scripts run-adapters' faux harness: with it, every harness but pi runs on that faux
@@ -2,8 +2,11 @@ import type { Context } from "@earendil-works/chord";
2
2
  import { type ToolRegistration } from "@earendil-works/pi-durable";
3
3
  import type { HostTool } from "@parcha/agentrun-kernel";
4
4
  import type { DurableRun } from "@parcha/pi-durable-disk";
5
+ import type { Park, RunGate } from "./tool-gate.js";
5
6
  export { workspaceRelative } from "./workspace-paths.js";
6
- /** Each tool a harness other than pi runs here, by catalog name, and whether a call a crash cut off may run again. */
7
+ /** Each tool a harness other than pi runs here, by catalog name, and whether a call a crash cut off may run again.
8
+ * `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL, named here as a string so the modules do not import
9
+ * each other) is never run again. */
7
10
  export declare const REPLAY: Record<string, "safe" | "never">;
8
11
  /** pi's limits on a tool's output (its DEFAULT_MAX_BYTES and DEFAULT_MAX_LINES), unless the tool names its own: read's
9
12
  * head and bash's tail are held to them (the host-bounds test reads pi's own words for them). */
@@ -17,4 +20,11 @@ export type ToolResults = Map<string, {
17
20
  text: string;
18
21
  isError: boolean;
19
22
  }>;
20
- export declare function hostTools(run: DurableRun, names: readonly string[], context: Context, results: ToolResults, coding?: readonly ToolRegistration[]): HostTool[];
23
+ /** The host tools `names` names, on the run's coding source `coding`. `gated`: the run's tool gate, which every call
24
+ * passes, and the park it takes (harness-app.ts), told of a call it parked, whose turn the harness ends; none (the
25
+ * gate's own run of an approved call), each call runs as asked. `extra`: the run's own tools beyond the table (its
26
+ * learned_workflow, learned-workflow.ts), which the gate passes like the rest. */
27
+ export declare function hostTools(run: DurableRun, names: readonly string[], context: Context, results: ToolResults, coding?: readonly ToolRegistration[], gated?: {
28
+ gate: RunGate;
29
+ park: Park;
30
+ }, extra?: readonly ToolRegistration[]): HostTool[];
@@ -1,15 +1,16 @@
1
1
  // The host tools of a run on a harness other than pi: its coding tools, from the run's coding source (coding-tools.ts:
2
- // pi's own read, write and edit on the run's environment, or in a box those and bash on the box's), so their arguments,
3
- // their confinement and their refusals are pi's, word for word, pi's web_fetch (also under its legacy name,
4
- // fetch_page), the public-host guard included, web_search, and monid's three (monid.ts), which stay on this machine.
2
+ // pi's own read, write and edit on the run's environment, or in a box those, bash and the background tools on the
3
+ // box's), so their arguments, their confinement and their refusals are pi's, word for word, pi's web_fetch (also under
4
+ // its legacy name, fetch_page), the public-host guard included, web_search, and monid's three (monid.ts), which stay on this machine.
5
5
  // pi's tools take only the environment, their output and their diagnostics from a call's API, and a paid one its call's
6
6
  // id and the run's store, so that is all a call here gives them: the output's tail or head as the tool keeps it (pi's
7
- // limits), then the diagnostics, also when the tool failed. read, the web tools, monid.discover and monid.inspect may
8
- // run again after a crash; write, edit, bash and monid.run never: the kernel records each one's intent before it runs,
9
- // and a call a crash cut off is answered interrupted, not run again. A tool is named by its catalog name here and goes
10
- // to the harness under its wire name (catalog.ts: `monid.run` is `monid_run`), which the harness calls and journals. A
7
+ // limits), then the diagnostics, also when the tool failed. read, the web tools, monid.discover, monid.inspect,
8
+ // bash_output and bash_list may run again after a crash; write, edit, bash, monid.run, bash_background, bash_input and
9
+ // bash_signal never: the kernel records each one's intent before it runs, and a call a crash cut off is answered
10
+ // interrupted, not run again. A tool is named by its catalog name here and goes to the harness under its wire name (catalog.ts: `monid.run` is `monid_run`), which the harness calls and journals. A
11
11
  // refusal, an error and a write's or edit's result name a path in the workspace relative to it (`hello.md`), never by
12
- // the server's data directory (`workspaceRelative`); in a box they name the box's paths.
12
+ // the server's data directory (`workspaceRelative`); in a box they name the box's paths. Each call passes the run's tool
13
+ // gate first (tool-gate.ts): a denied call is refused, an asked one parked, and the harness is told so it ends the turn.
13
14
  import { StringDecoder } from "node:string_decoder";
14
15
  import { withAbortSignal } from "@earendil-works/chord/context";
15
16
  import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
@@ -23,8 +24,10 @@ import { WEB_FETCH_TOOL, webFetchTool } from "./web-fetch.js";
23
24
  import { WEB_SEARCH_TOOL, webSearchTool } from "./web-search.js";
24
25
  import { realOf, workspaceRelative } from "./workspace-paths.js";
25
26
  export { workspaceRelative } from "./workspace-paths.js";
26
- /** Each tool a harness other than pi runs here, by catalog name, and whether a call a crash cut off may run again. */
27
- export const REPLAY = { read: "safe", write: "never", edit: "never", bash: "never", [FETCH_PAGE_TOOL]: "safe", [WEB_FETCH_TOOL]: "safe", [WEB_SEARCH_TOOL]: "safe", "monid.discover": "safe", "monid.inspect": "safe", "monid.run": "never" };
27
+ /** Each tool a harness other than pi runs here, by catalog name, and whether a call a crash cut off may run again.
28
+ * `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL, named here as a string so the modules do not import
29
+ * each other) is never run again. */
30
+ export const REPLAY = { read: "safe", write: "never", edit: "never", bash: "never", [FETCH_PAGE_TOOL]: "safe", [WEB_FETCH_TOOL]: "safe", [WEB_SEARCH_TOOL]: "safe", "monid.discover": "safe", "monid.inspect": "safe", "monid.run": "never", bash_background: "never", bash_output: "safe", bash_input: "never", bash_signal: "never", bash_list: "safe", learned_workflow: "never" };
28
31
  /** pi's limits on a tool's output (its DEFAULT_MAX_BYTES and DEFAULT_MAX_LINES), unless the tool names its own: read's
29
32
  * head and bash's tail are held to them (the host-bounds test reads pi's own words for them). */
30
33
  export const MAX_BYTES = 50 * 1024;
@@ -91,7 +94,11 @@ function bounded(limits) {
91
94
  /** The tools whose result is pi's own words about a path (`Successfully wrote to <path>`), never a file's text. */
92
95
  const SAYS_PATH = new Set(["write", "edit"]);
93
96
  const textOf = (content) => Array.isArray(content) ? content.map((block) => (block && typeof block === "object" && "text" in block && typeof block.text === "string" ? block.text : "")).join("") : "";
94
- export function hostTools(run, names, context, results, coding = CodingTools.tools ?? []) {
97
+ /** The host tools `names` names, on the run's coding source `coding`. `gated`: the run's tool gate, which every call
98
+ * passes, and the park it takes (harness-app.ts), told of a call it parked, whose turn the harness ends; none (the
99
+ * gate's own run of an approved call), each call runs as asked. `extra`: the run's own tools beyond the table (its
100
+ * learned_workflow, learned-workflow.ts), which the gate passes like the rest. */
101
+ export function hostTools(run, names, context, results, coding = CodingTools.tools ?? [], gated, extra = []) {
95
102
  // The coding source gives the coding tools and nothing else: the network tools are this machine's own, below.
96
103
  const stray = coding.map((tool) => tool.name).filter((name) => !BOXED_TOOLS.includes(name));
97
104
  if (stray.length)
@@ -102,7 +109,8 @@ export function hostTools(run, names, context, results, coding = CodingTools.too
102
109
  // never in its environment, and its long answers go in the run's work/, the claim's as pi's (`where.work`), read at
103
110
  // the call. They are outside the coding source, which holds the coding tools only.
104
111
  const monid = names.some((name) => name.startsWith("monid.")) ? monidTools(withSecrets(process.env), () => run.claim.work) : [];
105
- const tools = new Map([...coding, ...web, ...monid].map((tool) => [tool.name, tool]));
112
+ // `extra`: the run's own tools beyond the table, its learned_workflow (learned-workflow.ts) when its pin names one.
113
+ const tools = new Map([...coding, ...web, ...monid, ...extra].map((tool) => [tool.name, tool]));
106
114
  return names.flatMap((name) => {
107
115
  // The registrations are keyed by their wire names: the same name for every tool here but monid's.
108
116
  const tool = tools.get(wireName(name));
@@ -115,6 +123,12 @@ export function hostTools(run, names, context, results, coding = CodingTools.too
115
123
  inputSchema: tool.parameters,
116
124
  replay,
117
125
  async call(args, { callId, signal }) {
126
+ const refused = await gated?.gate.enter(name, args, callId, gated.park);
127
+ if (refused) {
128
+ const answer = { text: refused.text, isError: refused.isError };
129
+ results.set(callId, answer);
130
+ return answer;
131
+ }
118
132
  const out = bounded(tool.outputLimits);
119
133
  const notes = [];
120
134
  const env = await run.env({ conversationId: ROOT_CONVERSATION_ID, read: undefined }, context);
package/dist/host.js CHANGED
@@ -35,17 +35,21 @@ export function runsThatFit(harness, memory) {
35
35
  /** The default cap on how many runs at once: as many pi runs, the smallest, as fit. */
36
36
  export const defaultMaxRuns = (memory) => runsThatFit(DEFAULT_HARNESS, memory);
37
37
  const sizeOf = (mib) => `${Math.round(mib)} MB`;
38
+ /** "a pi run", "an opencode run". */
39
+ const aRun = (harness) => `${/^[aeiou]/i.test(harness) ? "an" : "a"} ${harness} run`;
40
+ /** "pi", "pi and codex", "pi, claude-agent and codex". */
41
+ const listed = (names) => (names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names.join(""));
38
42
  /** Why no run of `harness` can ever start on a host of `memory` bytes, in words; undefined when one fits. */
39
43
  export function neverFits(harness, memory) {
40
44
  if (runsThatFit(harness, memory) > 0)
41
45
  return undefined;
42
46
  const fit = HARNESSES.filter((id) => runsThatFit(id, memory) > 0);
43
- return `This server has ${sizeOf(memory / MiB)} of memory and keeps ${sizeOf(SERVER_MIB)} for itself; a ${harness} run needs about ${sizeOf(runMibOf(harness))} more, so it can't start here. ${fit.join(" and ")} runs fit.`;
47
+ return `This server has ${sizeOf(memory / MiB)} of memory and keeps ${sizeOf(SERVER_MIB)} for itself; ${aRun(harness)} needs about ${sizeOf(runMibOf(harness))} more, so it can't start here. ${listed(fit)} runs fit.`;
44
48
  }
45
49
  /** Why a run of `harness` cannot start now, with `heldMib` of the memory for runs held: the memory runs hold, in words. */
46
50
  export function memoryFull(harness, memory, heldMib) {
47
51
  const free = Math.max(0, runsMemoryMib(memory) - heldMib);
48
- return `This server's memory is held by the runs it has going: a ${harness} run needs about ${sizeOf(runMibOf(harness))}, and ${sizeOf(free)} of the ${sizeOf(runsMemoryMib(memory))} it has for runs is free; start this one when another ends.`;
52
+ return `This server's memory is held by the runs it has going: ${aRun(harness)} needs about ${sizeOf(runMibOf(harness))}, and ${sizeOf(free)} of the ${sizeOf(runsMemoryMib(memory))} it has for runs is free; start this one when another ends.`;
49
53
  }
50
54
  /** The cap on how many runs at once: `given`, else `AGENTRUN_MAX_RUNS`, else the default for this host's memory. The
51
55
  * memory each run reserves is checked beside it (runs.ts): both apply. */
@@ -91,7 +91,11 @@ function reader(anthropic) {
91
91
  * run's models, at most `n` results: a Search. `models`: the run's (searchOn). */
92
92
  export async function hostedSearch(query, n, ref, signal, models = runModels) {
93
93
  const slash = ref?.indexOf("/") ?? -1;
94
- const model = models && ref && slash > 0 ? models.getModel(ref.slice(0, slash), ref.slice(slash + 1)) : undefined;
94
+ const provider = ref && slash > 0 ? ref.slice(0, slash) : undefined;
95
+ const id = ref && slash > 0 ? ref.slice(slash + 1) : undefined;
96
+ // The name as written, else Anthropic's own id for it (dots as dashes, as claude-agent prepares a dotted name:
97
+ // adapters.ts claudeModelId), the one the run's models hold.
98
+ const model = models && provider && id ? (models.getModel(provider, id) ?? (provider === "anthropic" ? models.getModel(provider, id.replaceAll(".", "-")) : undefined)) : undefined;
95
99
  if (!models || !model)
96
100
  return { error: `web_search has no model to search on in this run${ref ? ` (${ref})` : ""}` };
97
101
  const anthropic = model.api === "anthropic-messages";
package/dist/import.d.ts CHANGED
@@ -113,8 +113,8 @@ export declare function projectFiles(cwd: string, skipped: Skipped[]): Promise<{
113
113
  skills: Record<string, string>;
114
114
  }>;
115
115
  /** The secrets this server made and keeps in data directory `data`, by value: its API token (`ar_local_...`) and its
116
- * door token (server.ts), its sign-in sessions' secret (owner.ts) and its webhook's signing secret (`whsec_...`;
117
- * webhooks.ts), opened with the seal key of `env`, so left out when that key is not there. One pasted into a session is
116
+ * door token (server.ts), its sign-in sessions' secret (owner.ts), its webhook's signing secret (`whsec_...`;
117
+ * webhooks.ts) and each webhook trigger's (trigger-secrets.ts), opened with the seal key of `env`, so left out when that key is not there. One pasted into a session is
118
118
  * this server's own, so an import cuts it wherever it is, as it cuts the environment's keys. Not among them: a run's own
119
119
  * door token (one file a run; not read at each import), and a key-shaped value this server did not make (a `whsec_`
120
120
  * from elsewhere). A webhook secret that does not open is said to `say`, as ToolKeys says a saved key that does not:
package/dist/import.js CHANGED
@@ -26,6 +26,7 @@ import { REDACTED, secretCut, secretsIn } from "./secret-cut.js";
26
26
  import { SECRET_NAMES, withSecrets } from "./secrets.js";
27
27
  import { SEAL_KEY_ENV, ToolKeys } from "./tool-keys.js";
28
28
  import { WEBHOOK_FILE, webhookSecretIn } from "./webhooks.js";
29
+ import { triggerSecretsIn } from "./trigger-secrets.js";
29
30
  import { readWorkBytes, WorkRefused, walkWork } from "./workspace.js";
30
31
  /** In the data directory while an import the owner asked for at setup has not ended: the server's next start goes on with it. */
31
32
  export const IMPORT_ASKED = ".import-at-setup";
@@ -818,8 +819,8 @@ async function writeMeta(dir, session, read, json) {
818
819
  await chmod(metaPath, 0o600);
819
820
  }
820
821
  /** The secrets this server made and keeps in data directory `data`, by value: its API token (`ar_local_...`) and its
821
- * door token (server.ts), its sign-in sessions' secret (owner.ts) and its webhook's signing secret (`whsec_...`;
822
- * webhooks.ts), opened with the seal key of `env`, so left out when that key is not there. One pasted into a session is
822
+ * door token (server.ts), its sign-in sessions' secret (owner.ts), its webhook's signing secret (`whsec_...`;
823
+ * webhooks.ts) and each webhook trigger's (trigger-secrets.ts), opened with the seal key of `env`, so left out when that key is not there. One pasted into a session is
823
824
  * this server's own, so an import cuts it wherever it is, as it cuts the environment's keys. Not among them: a run's own
824
825
  * door token (one file a run; not read at each import), and a key-shaped value this server did not make (a `whsec_`
825
826
  * from elsewhere). A webhook secret that does not open is said to `say`, as ToolKeys says a saved key that does not:
@@ -836,7 +837,7 @@ export function ownSecrets(data, env, say = () => { }) {
836
837
  const webhook = webhookSecretIn(data, env);
837
838
  if (webhook && "signing" in webhook)
838
839
  say({ condition: webhook.signing, name: SEAL_KEY_ENV, file: join(data, WEBHOOK_FILE), effect: "this server's webhook secret cannot be read, so the import does not cut it" });
839
- const values = [read(TOKEN_FILE), read(DOOR_TOKEN_FILE), read(SESSION_SECRET_FILE), webhook && "secret" in webhook ? webhook.secret : ""];
840
+ const values = [read(TOKEN_FILE), read(DOOR_TOKEN_FILE), read(SESSION_SECRET_FILE), webhook && "secret" in webhook ? webhook.secret : "", ...triggerSecretsIn(data, env)];
840
841
  return [...new Set(values)].filter((value) => value.length >= 8 && !/\s/.test(value));
841
842
  }
842
843
  /** The plan, into `store`: the agents it does not hold, and the runs it does not. A run an earlier import made whose
@@ -28,9 +28,10 @@ export declare const KEY_CHECKS: Record<string, (key: string, env: NodeJS.Proces
28
28
  * list models, which the 401 rule would refuse. */
29
29
  export declare const NOT_CHECKED: Record<string, string>;
30
30
  /** `row`'s key checked against its provider through `fetcher` (undefined: a faux server with no fake for it, so no call
31
- * is made), in at most `ms`, and no longer than `stop` (the server closing) lets it wait. */
31
+ * is made), in at most `ms`, and no longer than `stop` (the server closing) lets it wait. A refusal names the key as
32
+ * `name` (the server's own key, by its variable), else "this key" (the one a PUT sends). */
32
33
  export declare function checkKey(row: {
33
34
  id: string;
34
35
  label: string;
35
- }, key: string, env: NodeJS.ProcessEnv, fetcher: typeof fetch | undefined | null, ms?: number, stop?: AbortSignal): Promise<CheckOutcome>;
36
+ }, key: string, env: NodeJS.ProcessEnv, fetcher: typeof fetch | undefined | null, ms?: number, stop?: AbortSignal, name?: string): Promise<CheckOutcome>;
36
37
  export {};
package/dist/key-check.js CHANGED
@@ -29,6 +29,9 @@ export const KEY_CHECKS = {
29
29
  // A list of the key's projects: Browserbase bills a session's browser time and proxy bandwidth, and this opens no
30
30
  // session (https://docs.browserbase.com/reference/api/list-projects, https://docs.browserbase.com/account/billing/plans).
31
31
  browserbase: (key, env) => ({ url: `${base(env.BROWSERBASE_BASE_URL, "https://api.browserbase.com")}/v1/projects`, headers: { "x-bb-api-key": key } }),
32
+ // A list of the key's browser sessions, one at most: Kernel bills a browser's running time, and this starts none
33
+ // (https://www.kernel.sh/docs/api-reference/browsers/list-browser-sessions, https://www.kernel.sh/docs/info/pricing).
34
+ kernel: (key, env) => ({ url: `${base(env.KERNEL_BASE_URL, "https://api.onkernel.com")}/browsers?limit=1`, headers: { authorization: `Bearer ${key}` } }),
32
35
  // A list of the account's models: TypeSafe prices a System One request's input tokens
33
36
  // (https://docs.typesafe.ai/api/list-models, https://docs.typesafe.ai/models).
34
37
  typesafe: (key, env) => ({ url: `${base(env.TYPESAFE_BASE_URL, "https://api.typesafe.ai")}/v1/models`, headers: { authorization: `Bearer ${key}` } }),
@@ -65,8 +68,9 @@ function quoted(text, key) {
65
68
  return sentence;
66
69
  }
67
70
  /** `row`'s key checked against its provider through `fetcher` (undefined: a faux server with no fake for it, so no call
68
- * is made), in at most `ms`, and no longer than `stop` (the server closing) lets it wait. */
69
- export async function checkKey(row, key, env, fetcher, ms = CHECK_MS, stop) {
71
+ * is made), in at most `ms`, and no longer than `stop` (the server closing) lets it wait. A refusal names the key as
72
+ * `name` (the server's own key, by its variable), else "this key" (the one a PUT sends). */
73
+ export async function checkKey(row, key, env, fetcher, ms = CHECK_MS, stop, name = "this key") {
70
74
  const at = new Date().toISOString();
71
75
  const notChecked = (reason) => ({ state: "not_checked", reason, at });
72
76
  if (Object.hasOwn(NOT_CHECKED, row.id))
@@ -101,7 +105,7 @@ export async function checkKey(row, key, env, fetcher, ms = CHECK_MS, stop) {
101
105
  // 401 whose body is cut off or stalls past the deadline still refuses the key.
102
106
  const said = quoted(await res.text().catch(() => ""), key);
103
107
  if (status === 401)
104
- return { state: "refused", message: `${row.label} refused this key (401${said ? `: ${said}` : ""})` };
108
+ return { state: "refused", message: `${row.label} refused ${name} (401${said ? `: ${said}` : ""})` };
105
109
  if (status === 403)
106
110
  return notChecked(`${row.label} would not answer the check (403${said ? `: ${said}` : ""}); the key may still work for its tools`);
107
111
  return notChecked(`${row.label} answered ${status}${said ? ` (${said})` : ""}`);
@@ -19,8 +19,8 @@ export function runKeyOf(env, harness = DEFAULT_HARNESS, ref) {
19
19
  return row(provider === "openrouter" || openRouterOnly("claude-agent", env) ? "openrouter" : "anthropic");
20
20
  if (env.AGENT_MODEL_BASE_URL)
21
21
  return gateway;
22
- if (harness === "codex")
23
- return row(provider === "openrouter" || openRouterOnly("codex", env) ? "openrouter" : "openai");
22
+ if (harness === "codex" || harness === "opencode")
23
+ return row(provider === "openrouter" || openRouterOnly(harness, env) ? "openrouter" : "openai");
24
24
  return provider === undefined ? undefined : row(provider);
25
25
  }
26
26
  /** The provider's own words after its 401: the message of the JSON it answered, else the text, its status word and any
@@ -112,8 +112,12 @@ export function redactedOutput(value, secrets) {
112
112
  return redactedAnswer(value, secrets);
113
113
  // A held value can be all digits (a gateway's key), and a record can quote it as a number: one whose digits hold a held
114
114
  // value, by the same rule as a string's, is withheld as "[redacted]". A boolean's text is shorter than any held value.
115
- if (typeof value === "number" || typeof value === "bigint")
116
- return redactedAnswer(String(value), secrets) === String(value) ? value : "[redacted]";
115
+ // A number can also EQUAL a held value whose text differs from its own (a leading zero, 1e21, a long key read lossy).
116
+ if (typeof value === "number" || typeof value === "bigint") {
117
+ const text = String(value);
118
+ const held = redactedAnswer(text, secrets) !== text || secrets.some((secret) => secret.trim() !== "" && Number(secret) === Number(value));
119
+ return held ? "[redacted]" : value;
120
+ }
117
121
  if (Array.isArray(value))
118
122
  return value.map((item) => redactedOutput(item, secrets));
119
123
  if (value && typeof value === "object") {
@@ -59,9 +59,12 @@ export type CheckInput = {
59
59
  /** How the run's job ended, its status (`completed`, `failed`, ...). Only a completed run adds or changes a skill:
60
60
  * without it, none does. */
61
61
  readonly outcome?: string;
62
- /** The tools a workflow draft may name: the agent's granted tools a workflow node runs here (tools.ts
62
+ /** The tools a workflow draft may name: the agent's granted tools a workflow's call node runs here (tools.ts
63
63
  * learnedWorkflowTools). Without it, a draft that names a tool is refused. */
64
64
  readonly tools?: readonly string[];
65
+ /** The agent's granted tools the gate does not allow, with what each is set to (tools.ts learnedDraftTools): a draft
66
+ * whose call node calls one is refused, in the words a workflow revision's is (learn/skills.ts gatedNodes). */
67
+ readonly gated?: Readonly<Record<string, string>>;
65
68
  /** The workflow DSL a draft is read with; a proposal that holds a draft is checked with it, never without. */
66
69
  readonly dsl?: DraftReader;
67
70
  /** The skills' and drafts' files whose text in the run's seed has a status (a person retired it, or it waits for its
@@ -86,6 +89,12 @@ export declare function checkNote(path: string, bytes: Uint8Array, refuseValues?
86
89
  };
87
90
  /** Checks what a run proposes against SPEC.md: its notes, and a skill or workflow drafts beside them (learnedChecked).
88
91
  * `MEMORY.md` is the host's: a change to it is ignored, never refused. */
92
+ /** What must never be stored, in every change's name and text, whatever the checks would refuse it for first: the
93
+ * name and text scans (nameScanned, textOf) of each change, its text read whole (an edit, a file over its cap, one not
94
+ * a regular file included), printable as checkProposal's are. A text that is not UTF-8 is `encoding`: unread, so
95
+ * never trusted. Empty when nothing in them must be refused. Ahead of keeping some items of a proposal the checks
96
+ * refuse (propose.ts): an item refused before its text was read hides nothing. */
97
+ export declare function unstorable(changes: readonly Change[], refuseValues?: readonly string[]): Problem[];
89
98
  export declare function checkProposal(input: CheckInput): ProposalCheck;
90
99
  /** The notes the active ones of `notes` supersede, each by the note that supersedes it. A note that waits for its
91
100
  * owner's OK (`status: pending`) supersedes nothing until it is approved: what it names stays active. The one rule the
@@ -123,7 +123,7 @@ function learnedChecked(change, place, refused, input, add) {
123
123
  if (place.kind === "workflow") {
124
124
  if (!input.dsl)
125
125
  throw new TypeError(`${path}: a workflow draft is read with the workflow DSL, which was not given`);
126
- for (const { rule, detail } of draftProblems(input.dsl, text, input.tools))
126
+ for (const { rule, detail } of draftProblems(input.dsl, text, input.tools, input.gated))
127
127
  add(rule, detail, path);
128
128
  return;
129
129
  }
@@ -150,6 +150,24 @@ export function checkNote(path, bytes, refuseValues = []) {
150
150
  }
151
151
  /** Checks what a run proposes against SPEC.md: its notes, and a skill or workflow drafts beside them (learnedChecked).
152
152
  * `MEMORY.md` is the host's: a change to it is ignored, never refused. */
153
+ /** What must never be stored, in every change's name and text, whatever the checks would refuse it for first: the
154
+ * name and text scans (nameScanned, textOf) of each change, its text read whole (an edit, a file over its cap, one not
155
+ * a regular file included), printable as checkProposal's are. A text that is not UTF-8 is `encoding`: unread, so
156
+ * never trusted. Empty when nothing in them must be refused. Ahead of keeping some items of a proposal the checks
157
+ * refuse (propose.ts): an item refused before its text was read hides nothing. */
158
+ export function unstorable(changes, refuseValues = []) {
159
+ const problems = [];
160
+ const add = (rule, detail, path) => void problems.push(printable(path === undefined ? { rule, detail } : { rule, path, detail }, refuseValues));
161
+ const refused = valueMatcher(refuseValues);
162
+ for (const change of changes) {
163
+ if (change.path === INDEX_FILE)
164
+ continue;
165
+ nameScanned(change.path, refused, add);
166
+ if (change.bytes)
167
+ textOf(change.path, change.bytes, refused, add);
168
+ }
169
+ return problems;
170
+ }
153
171
  export function checkProposal(input) {
154
172
  const values = input.refuseValues ?? [];
155
173
  const problems = [];
@@ -52,8 +52,9 @@ export type VerdictItem = {
52
52
  readonly question?: string;
53
53
  readonly why: string;
54
54
  };
55
- /** The whole proposal's verdict: `merge` only when every note is kept, and the grader said so or dropped only notes the
56
- * user asked for, on General alone. */
55
+ /** The whole proposal's verdict, item by item: `merge` when any item is kept (the kept ones merge, the dropped ones are
56
+ * left out), unless an item is dropped as Planted (nothing from that run is kept) or the grader kept every item and
57
+ * still said no merge (dropping only notes the user asked for, on General alone, is no such no). */
57
58
  export type Verdict = {
58
59
  readonly merge: boolean;
59
60
  readonly reason: string;