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

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 (172) hide show
  1. package/CHANGELOG.md +238 -0
  2. package/README.md +739 -116
  3. package/dist/adapters.d.ts +35 -6
  4. package/dist/adapters.js +152 -26
  5. package/dist/agents.d.ts +18 -7
  6. package/dist/agents.js +19 -10
  7. package/dist/app.js +101 -26
  8. package/dist/background.d.ts +29 -0
  9. package/dist/background.js +397 -0
  10. package/dist/box-egress-vm.d.ts +125 -0
  11. package/dist/box-egress-vm.js +350 -0
  12. package/dist/box-egress.d.ts +99 -0
  13. package/dist/box-egress.js +259 -0
  14. package/dist/box-image.d.ts +1 -1
  15. package/dist/box-image.js +9 -7
  16. package/dist/box-relay-vm.d.ts +84 -0
  17. package/dist/box-relay-vm.js +410 -0
  18. package/dist/box-relay.d.ts +8 -5
  19. package/dist/box-relay.js +14 -9
  20. package/dist/boxes.d.ts +28 -5
  21. package/dist/boxes.js +44 -18
  22. package/dist/browser-cost.d.ts +41 -0
  23. package/dist/browser-cost.js +158 -0
  24. package/dist/cap.d.ts +130 -21
  25. package/dist/cap.js +339 -67
  26. package/dist/cli.js +30 -4
  27. package/dist/coding-tools.d.ts +7 -3
  28. package/dist/coding-tools.js +16 -10
  29. package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
  30. package/dist/console/assets/index-CnJBf7Lc.js +486 -0
  31. package/dist/console/assets/index-DUHbWcIP.css +1 -0
  32. package/dist/console/index.html +2 -2
  33. package/dist/content-filter.d.ts +7 -0
  34. package/dist/content-filter.js +23 -0
  35. package/dist/decision-rows.d.ts +11 -3
  36. package/dist/decision-rows.js +18 -11
  37. package/dist/decisions.d.ts +3 -3
  38. package/dist/decisions.js +4 -3
  39. package/dist/errors.d.ts +2 -0
  40. package/dist/errors.js +5 -2
  41. package/dist/files.d.ts +9 -1
  42. package/dist/files.js +10 -2
  43. package/dist/grade.d.ts +11 -11
  44. package/dist/grade.js +43 -55
  45. package/dist/graph-served.d.ts +23 -0
  46. package/dist/graph-served.js +75 -0
  47. package/dist/graph-view.d.ts +7 -5
  48. package/dist/graph-view.js +10 -3
  49. package/dist/harness-app.d.ts +4 -2
  50. package/dist/harness-app.js +110 -19
  51. package/dist/harness-opencode/adapter.d.ts +45 -0
  52. package/dist/harness-opencode/adapter.js +272 -0
  53. package/dist/harness-opencode/binary.d.ts +18 -0
  54. package/dist/harness-opencode/binary.js +87 -0
  55. package/dist/harness-opencode/config.d.ts +24 -0
  56. package/dist/harness-opencode/config.js +61 -0
  57. package/dist/harness-opencode/harness.d.ts +77 -0
  58. package/dist/harness-opencode/harness.js +620 -0
  59. package/dist/harness-opencode/host/mcp.d.ts +40 -0
  60. package/dist/harness-opencode/host/mcp.js +208 -0
  61. package/dist/harness-opencode/host/policy.d.ts +71 -0
  62. package/dist/harness-opencode/host/policy.js +419 -0
  63. package/dist/harness-opencode/host/server.d.ts +55 -0
  64. package/dist/harness-opencode/host/server.js +165 -0
  65. package/dist/harness-opencode/index.d.ts +9 -0
  66. package/dist/harness-opencode/index.js +6 -0
  67. package/dist/harness-opencode/verify.d.ts +32 -0
  68. package/dist/harness-opencode/verify.js +75 -0
  69. package/dist/harness-opencode/versions.d.ts +33 -0
  70. package/dist/harness-opencode/versions.js +64 -0
  71. package/dist/harness.d.ts +4 -1
  72. package/dist/harness.js +5 -2
  73. package/dist/host-check.d.ts +12 -0
  74. package/dist/host-check.js +34 -0
  75. package/dist/host-tools.d.ts +12 -2
  76. package/dist/host-tools.js +26 -12
  77. package/dist/host.js +6 -2
  78. package/dist/hosted-search.js +5 -1
  79. package/dist/import.d.ts +2 -2
  80. package/dist/import.js +4 -3
  81. package/dist/key-check.d.ts +3 -2
  82. package/dist/key-check.js +7 -3
  83. package/dist/key-refusal.js +8 -4
  84. package/dist/key-words.d.ts +37 -0
  85. package/dist/key-words.js +40 -0
  86. package/dist/learn/check.d.ts +10 -1
  87. package/dist/learn/check.js +19 -1
  88. package/dist/learn/grade.d.ts +6 -2
  89. package/dist/learn/grade.js +28 -14
  90. package/dist/learn/index.d.ts +3 -3
  91. package/dist/learn/index.js +3 -3
  92. package/dist/learn/notes.js +2 -1
  93. package/dist/learn/reflect.d.ts +2 -2
  94. package/dist/learn/reflect.js +53 -5
  95. package/dist/learn/secrets.js +28 -8
  96. package/dist/learn/skills.d.ts +19 -4
  97. package/dist/learn/skills.js +95 -6
  98. package/dist/learned-workflow.d.ts +59 -0
  99. package/dist/learned-workflow.js +191 -0
  100. package/dist/learning-routes.d.ts +30 -1
  101. package/dist/learning-routes.js +173 -19
  102. package/dist/learning-run.d.ts +8 -6
  103. package/dist/learning-run.js +70 -27
  104. package/dist/learning-words.d.ts +12 -5
  105. package/dist/learning-words.js +34 -13
  106. package/dist/learning.d.ts +52 -3
  107. package/dist/learning.js +204 -4
  108. package/dist/mcp-gateway.d.ts +96 -0
  109. package/dist/mcp-gateway.js +408 -0
  110. package/dist/mcp-meta.d.ts +17 -0
  111. package/dist/mcp-meta.js +38 -0
  112. package/dist/mcp-servers.d.ts +33 -9
  113. package/dist/mcp-servers.js +58 -10
  114. package/dist/mcp.js +5 -5
  115. package/dist/model.d.ts +13 -11
  116. package/dist/model.js +11 -10
  117. package/dist/openapi/agentrun-v2.openapi.json +1 -0
  118. package/dist/openapi.js +407 -54
  119. package/dist/page.d.ts +2 -0
  120. package/dist/page.js +3 -0
  121. package/dist/paid-calls.d.ts +5 -1
  122. package/dist/paid-calls.js +1 -1
  123. package/dist/pause.d.ts +2 -0
  124. package/dist/place.d.ts +29 -5
  125. package/dist/place.js +51 -11
  126. package/dist/print.d.ts +7 -0
  127. package/dist/print.js +13 -0
  128. package/dist/propose.d.ts +2 -0
  129. package/dist/propose.js +38 -8
  130. package/dist/request-start.d.ts +12 -4
  131. package/dist/request-start.js +139 -15
  132. package/dist/run-box.d.ts +56 -4
  133. package/dist/run-box.js +183 -23
  134. package/dist/runnable.d.ts +13 -3
  135. package/dist/runnable.js +63 -6
  136. package/dist/runs.d.ts +266 -37
  137. package/dist/runs.js +884 -90
  138. package/dist/secrets.d.ts +27 -0
  139. package/dist/secrets.js +38 -2
  140. package/dist/server.d.ts +141 -36
  141. package/dist/server.js +562 -118
  142. package/dist/sign-ins.d.ts +99 -0
  143. package/dist/sign-ins.js +288 -0
  144. package/dist/skills.d.ts +16 -4
  145. package/dist/skills.js +35 -7
  146. package/dist/stats.d.ts +7 -2
  147. package/dist/stats.js +28 -7
  148. package/dist/tool-gate.d.ts +281 -0
  149. package/dist/tool-gate.js +585 -0
  150. package/dist/tool-keys.d.ts +48 -11
  151. package/dist/tool-keys.js +46 -8
  152. package/dist/tool-plane.d.ts +116 -27
  153. package/dist/tool-plane.js +232 -50
  154. package/dist/tools.d.ts +69 -14
  155. package/dist/tools.js +148 -26
  156. package/dist/trigger-secrets.d.ts +32 -0
  157. package/dist/trigger-secrets.js +143 -0
  158. package/dist/triggers.d.ts +439 -0
  159. package/dist/triggers.js +863 -0
  160. package/dist/turn-end.d.ts +3 -2
  161. package/dist/turn-end.js +3 -2
  162. package/dist/usage-lines.d.ts +26 -0
  163. package/dist/usage-lines.js +28 -0
  164. package/dist/validate.d.ts +2 -0
  165. package/dist/validate.js +11 -2
  166. package/dist/web-fetch.js +3 -3
  167. package/dist/webhooks.d.ts +11 -4
  168. package/dist/webhooks.js +17 -1
  169. package/launcher/agentrun-serve +1 -1
  170. package/package.json +16 -14
  171. package/dist/console/assets/index-BN7oVcO4.js +0 -445
  172. package/dist/console/assets/index-By-jkqki.css +0 -1
@@ -10,11 +10,15 @@ import { join } from "node:path";
10
10
  import { seal, unseal } from "@parcha/pi-durable-agent";
11
11
  import { ApiError, invalid } from "./errors.js";
12
12
  import { writeDurableSync } from "./files.js";
13
+ import { metaToolOf } from "./mcp-meta.js";
13
14
  import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
14
15
  import { isObject, unknownFields } from "./validate.js";
15
16
  export const MCP_SERVERS_FILE = "mcp-servers.json";
16
17
  const FORMAT = "mcp-servers/1";
17
18
  export const MCP_SERVER_NAME = /^[a-z][a-z0-9-]{0,31}$/;
19
+ /** The names AgentRun's own tools are called by, which no MCP server takes: claude-agent calls the kernel's host tools
20
+ * as `mcp__hands__<tool>`, and monid's are `monid_<tool>` (tool-gate.ts settingsKeyOf reads both as AgentRun's). */
21
+ export const RESERVED_MCP_NAMES = ["hands", "monid"];
18
22
  export const MCP_AUTH_TYPES = ["none", "bearer", "headers"];
19
23
  const REQUEST_MS = 15_000;
20
24
  const PREVIEW_MS = 30_000;
@@ -64,19 +68,21 @@ export class McpServers {
64
68
  throw invalid(issues);
65
69
  const name = String(body.name);
66
70
  const kept = this.need(name);
67
- return listServer(new URL(kept.url), this.opened(name, kept, "name"), this.version, stop);
71
+ return marked(kept.url, await listServer(new URL(kept.url), this.opened(name, kept, "name"), this.version, stop));
68
72
  }
69
73
  const { url, auth } = this.admit(body);
70
74
  if (auth.type !== "none" && !auth.headers)
71
75
  throw invalid([credentialMissing(auth.type, "A preview needs the credential it is to connect with.")]);
72
- return listServer(url, auth.headers ?? {}, this.version, stop);
76
+ return marked(url.href, await listServer(url, auth.headers ?? {}, this.version, stop));
73
77
  }
74
78
  /** PUT: preview, then keep the server with the tools listed. A body with no credential keeps the sealed one, while
75
79
  * the auth type and the URL's origin stay the same. */
76
80
  async save(name, body, stop) {
77
81
  if (!MCP_SERVER_NAME.test(name))
78
82
  throw invalid([{ field: "name", reason: "invalid", message: "A server's name is 1 to 32 lowercase letters, digits and dashes, starting with a letter (no underscores, so mcp__<server>__<tool> splits one way)." }]);
79
- const { url, auth } = this.admit(body);
83
+ if (RESERVED_MCP_NAMES.includes(name))
84
+ throw invalid([{ field: "name", reason: "reserved", message: `'${name}' is reserved for AgentRun's own tools: a server under it would take their names and their permissions. Name the server another way.` }]);
85
+ const { url, auth, prices } = this.admit(body, true);
80
86
  if (auth.type !== "none" && !this.key)
81
87
  throw new ApiError("no_sealing_key", `This server was handed no seal key (${SEAL_KEY_ENV}), so it keeps no MCP server credential: it never keeps one in the clear.`);
82
88
  const was = this.servers()[name];
@@ -89,10 +95,14 @@ export class McpServers {
89
95
  headers = this.opened(name, was, auth.type === "bearer" ? "auth.token" : "auth.headers");
90
96
  }
91
97
  const listed = await listServer(url, headers ?? {}, this.version, stop);
98
+ // A price names a tool the server listed now, or nothing is saved.
99
+ const unlisted = Object.keys(prices ?? {}).filter((tool) => !listed.tools.some((listedTool) => listedTool.name === tool));
100
+ if (unlisted.length)
101
+ throw invalid(unlisted.map((tool) => ({ field: `prices.${tool}`, reason: "not_an_option", message: `The server ${name} lists no tool ${tool}; its tools are ${listed.tools.map((t) => t.name).join(", ") || "none"}.` })));
92
102
  const now = new Date().toISOString();
93
103
  const sealed = headers && Object.fromEntries(Object.entries(headers).map(([header, value]) => [header, seal(this.key, Buffer.from(value, "utf8"), aad(name, header)).toString("base64")]));
94
104
  const servers = this.servers();
95
- servers[name] = { url: url.href, auth: { type: auth.type, ...(sealed ? { sealed, check: this.sealCheck } : {}) }, ...listed, listed_at: now, updated_at: now };
105
+ servers[name] = { url: url.href, auth: { type: auth.type, ...(sealed ? { sealed, check: this.sealCheck } : {}) }, ...listed, ...(prices && Object.keys(prices).length ? { prices } : {}), listed_at: now, updated_at: now };
96
106
  this.write(servers);
97
107
  return this.view(name, servers[name]);
98
108
  }
@@ -109,7 +119,14 @@ export class McpServers {
109
119
  throw new ApiError("unavailable", `The server ${name} was changed while its tools were listed: refresh it again.`);
110
120
  const before = new Map(now.tools.map((tool) => [tool.name, canonical(tool)]));
111
121
  const after = new Map(listed.tools.map((tool) => [tool.name, canonical(tool)]));
112
- servers[name] = { ...now, ...listed, listed_at: new Date().toISOString() };
122
+ const next = { ...now, ...listed, listed_at: new Date().toISOString() };
123
+ // A price of a tool the server no longer lists goes with it.
124
+ const prices = Object.entries(now.prices ?? {}).filter(([tool]) => after.has(tool));
125
+ if (prices.length)
126
+ next.prices = Object.fromEntries(prices);
127
+ else
128
+ delete next.prices;
129
+ servers[name] = next;
113
130
  this.write(servers);
114
131
  return {
115
132
  added: [...after.keys()].filter((tool) => !before.has(tool)),
@@ -118,6 +135,15 @@ export class McpServers {
118
135
  server: this.view(name, servers[name]),
119
136
  };
120
137
  }
138
+ /** The saved server's credential, opened, for a run's launch: its headers; undefined when it has none, or none that opens. */
139
+ headers(name) {
140
+ const servers = this.kept();
141
+ const kept = servers === "unreadable" || !Object.hasOwn(servers, name) ? undefined : servers[name];
142
+ if (!kept || kept.auth.type === "none")
143
+ return undefined;
144
+ const opened = this.open(name, kept);
145
+ return "headers" in opened ? opened.headers : undefined;
146
+ }
121
147
  remove(name) {
122
148
  const servers = this.servers();
123
149
  if (!servers[name])
@@ -136,7 +162,7 @@ export class McpServers {
136
162
  const opened = auth.type === "none" ? null : this.open(name, kept);
137
163
  return {
138
164
  name,
139
- ...rest,
165
+ ...marked(kept.url, rest),
140
166
  auth: { type: auth.type, ...(auth.type === "headers" ? { headers: Object.keys(auth.sealed ?? {}) } : {}) },
141
167
  credential: opened === null ? null : "headers" in opened ? "sealed" : opened.unreadable,
142
168
  };
@@ -164,14 +190,15 @@ export class McpServers {
164
190
  throw new ApiError("no_sealing_key", `This server was handed no seal key (${SEAL_KEY_ENV}), so the saved credential of ${name} does not open.`);
165
191
  throw invalid([{ field, reason: "missing", message: `The saved credential of ${name} does not open here (sealed under another seal key, or damaged): send it again.` }]);
166
192
  }
167
- /** A body's URL and auth, or 422. */
168
- admit(body) {
169
- const issues = unknownFields(body, ["url", "auth"]);
193
+ /** A body's URL, auth and prices, or 422. */
194
+ admit(body, priced = false) {
195
+ const issues = unknownFields(body, priced ? ["url", "auth", "prices"] : ["url", "auth"]);
170
196
  const url = urlOf(body.url, issues);
171
197
  const auth = authOf(body.auth, issues);
198
+ const prices = pricesOf(body.prices, issues);
172
199
  if (issues.length)
173
200
  throw invalid(issues);
174
- return { url: url, auth: auth };
201
+ return { url: url, auth: auth, ...(prices ? { prices } : {}) };
175
202
  }
176
203
  /** The saved servers: none with no file, "unreadable" when the file does not read as this format. */
177
204
  kept() {
@@ -194,6 +221,14 @@ export class McpServers {
194
221
  writeDurableSync(this.file, `${JSON.stringify({ format: FORMAT, servers }, null, 2)}\n`);
195
222
  }
196
223
  }
224
+ /** `listed` with each known meta tool (mcp-meta.ts) marked `grantable: false` with its reason: the snapshot keeps what
225
+ * the server listed, and every read says which of its tools can't be granted. */
226
+ function marked(url, listed) {
227
+ return { ...listed, tools: listed.tools.map((tool) => {
228
+ const meta = metaToolOf(url, tool.name);
229
+ return meta ? { ...tool, grantable: false, reason: meta.reason } : tool;
230
+ }) };
231
+ }
197
232
  const aad = (name, header) => `mcp:${name}:${header}`;
198
233
  /** `text` with every credential value cut out: each header's value, and a bearer's token alone, which a server may
199
234
  * echo without its scheme. */
@@ -204,6 +239,19 @@ const credentialMissing = (type, message) => ({ field: type === "bearer" ? "auth
204
239
  const canonical = (value) => Array.isArray(value) ? `[${value.map(canonical).join(",")}]`
205
240
  : isObject(value) ? `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`
206
241
  : JSON.stringify(value) ?? "null";
242
+ /** The body's prices: each tool's USD a call, a finite number, 0 or more. Which tools the server lists is checked once
243
+ * it has listed them. */
244
+ function pricesOf(value, issues) {
245
+ if (value === undefined)
246
+ return undefined;
247
+ if (!isObject(value))
248
+ return void issues.push({ field: "prices", reason: "wrong_type", message: "prices is an object of the server's tool names to their price in USD a call." });
249
+ const bad = Object.entries(value).filter(([, usd]) => typeof usd !== "number" || !Number.isFinite(usd) || usd < 0);
250
+ for (const [tool] of bad)
251
+ issues.push({ field: `prices.${tool}`, reason: "invalid", message: `prices.${tool} is a price in USD a call: a finite number, 0 or more.` });
252
+ // Keyed by tool names, which may be an object's own properties (`__proto__`): no prototype to fall into.
253
+ return bad.length ? undefined : Object.assign(Object.create(null), value);
254
+ }
207
255
  function urlOf(value, issues) {
208
256
  if (typeof value !== "string" || value === "")
209
257
  return void issues.push({ field: "url", reason: value === undefined ? "missing" : "wrong_type", message: "url is the MCP server's Streamable HTTP endpoint, as text." });
package/dist/mcp.js CHANGED
@@ -62,7 +62,7 @@ const AGENT_ID = { type: "string", description: "The agent's id." };
62
62
  const RUN_ID = { type: "string", description: "The run's id." };
63
63
  const DEFINITION = {
64
64
  instructions: { type: "string", description: "What the agent does and how: its system prompt." },
65
- harness: { type: "string", enum: ["pi", "claude-agent", "codex"], description: "What runs it (default pi). whoami says which this server runs." },
65
+ harness: { type: "string", enum: ["pi", "claude-agent", "codex", "opencode"], description: "What runs it (default pi). whoami says which this server runs." },
66
66
  model: { type: ["string", "null"], description: "provider/model-id. Absent, this server's default (whoami names it)." },
67
67
  thinking: { type: ["string", "null"], description: "How hard the model thinks: one of whoami's thinking levels. Absent, the model's own." },
68
68
  tools: { type: "array", items: { type: "string" }, description: "The tools it may use, by name (whoami lists them); [] for none. It writes files only with a tool like write." },
@@ -119,7 +119,7 @@ export const TOOLS = [
119
119
  },
120
120
  {
121
121
  name: "agents_revise", title: "Revise an agent", annotations: WRITE,
122
- description: "Makes the agent's next revision from its current definition with these fields changed, and any other field in definition (GET /v2/agents/{agent_id}, then PUT /v2/agents/{agent_id}/definition on that revision): fields you leave out stay; null clears model or thinking. Its next run runs the new revision. A revision saved in between is refused (precondition_failed), never overwritten. Its name and description stay as it was created.",
122
+ description: "Makes the agent's next revision from its current definition with these fields changed, and any other field in definition (GET /v2/agents/{agent_id}, then PUT /v2/agents/{agent_id}/definition on that revision): fields you leave out stay; null clears model or thinking. definition.max_cost_usd sets the agent's default spend cap of each run started without one; 0 clears it (null is refused), and a revise that leaves it out keeps it. Its next run runs the new revision. A revision saved in between is refused (precondition_failed), never overwritten. Its name and description stay as it was created.",
123
123
  inputSchema: { type: "object", required: ["agent_id"], properties: { agent_id: AGENT_ID, ...DEFINITION, note: { type: "string", description: "Optional: what this revision changes." } } },
124
124
  run: async (args, context) => {
125
125
  const agent = text(args, "agent_id");
@@ -157,7 +157,7 @@ export const TOOLS = [
157
157
  },
158
158
  {
159
159
  name: "runs_get", title: "Get a run", annotations: READ,
160
- description: "A run's status and outcome (GET /v2/runs/{run_id}), and console_url (added here), the run's page. pending is what it waits on, by kind: {kind: \"question\", question} while its status is input_required, else null. status is queued, working, input_required, completed, failed, cancelled or paused. A completed run's answer is result.final_answer (agentic) or result.output (workflow); a failed run's reason is error; cost.usd is null while unknown, never $0.",
160
+ description: "A run's status and outcome (GET /v2/runs/{run_id}), and console_url (added here), the run's page. pending is what it waits on while its status is input_required, by kind: {kind: \"question\", question} for a question it asked, {kind: \"budget\", cap_usd, spent_usd, needs_usd, suggested_cap_usd, said, at} for a run paused at its spend cap (it waits for its cap to be raised, PATCH /v2/runs/{run_id} {max_cost_usd}, which a person decides; suggested_cap_usd is a raise that resumes it; said is why), else null. status is queued, working, input_required, completed, failed, cancelled or paused. A completed run's answer is result.final_answer (agentic) or result.output (workflow); a failed run's reason is error; cost.usd is null while unknown, never $0.",
161
161
  inputSchema: { type: "object", required: ["run_id"], properties: { run_id: RUN_ID } },
162
162
  run: async (args, context) => {
163
163
  const run = text(args, "run_id");
@@ -204,7 +204,7 @@ export const TOOLS = [
204
204
  },
205
205
  {
206
206
  name: "runs_respond", title: "Answer a run", annotations: { ...WRITE, openWorldHint: true },
207
- description: "Sends an agentic run a message (POST /v2/runs/{run_id}/messages): the answer to the question it asked (its status is input_required; runs_get's pending holds the question), or a follow-up once it completed or was stopped: a fresh turn with its history (a stopped turn is not replayed). mode in the answer says which. A cancelled run takes none: 409 not_continuable, start a new run. Then poll runs_get again.",
207
+ description: "Sends an agentic run a message (POST /v2/runs/{run_id}/messages): the answer to the question it asked (its status is input_required; runs_get's pending holds the question), or a follow-up once it completed or was stopped: a fresh turn with its history (a stopped turn is not replayed). mode in the answer says which. A cancelled run takes none: 409 not_continuable, start a new run. A run paused at its spend cap (pending kind budget) takes no message: 409 budget_reached; it waits for its cap to be raised, so tell the person (console_url), never answer it. Then poll runs_get again.",
208
208
  inputSchema: { type: "object", required: ["run_id", "content"], properties: { run_id: RUN_ID, content: { type: "string", description: "The answer, or the message." } } },
209
209
  run: routed((args) => ({ method: "POST", path: `/runs/${id(text(args, "run_id"))}/messages`, body: without(args, ["run_id"]) })),
210
210
  },
@@ -215,7 +215,7 @@ export const TOOLS = [
215
215
  run: routed((args) => ({ method: "POST", path: `/runs/${id(text(args, "run_id"))}/cancel` })),
216
216
  },
217
217
  ];
218
- const INSTRUCTIONS = "Tools over this AgentRun server's agents and runs. Call whoami first. To run an agent: agents_list (or agents_create, after asking the person), then runs_start, then runs_get every few seconds until its status is completed, failed or cancelled. input_required means it asked a question (runs_get's pending, kind question): answer it with runs_respond, or leave it for the person in the console (console_url). Read its steps with runs_events and what it wrote with runs_files.";
218
+ const INSTRUCTIONS = "Tools over this AgentRun server's agents and runs. Call whoami first. To run an agent: agents_list (or agents_create, after asking the person), then runs_start, then runs_get every few seconds until its status is completed, failed or cancelled. input_required means it asked a question (runs_get's pending, kind question): answer it with runs_respond, or leave it for the person in the console (console_url). With pending kind budget the run is paused at its spend cap and waits for its cap to be raised: do not answer it (runs_respond is refused 409 budget_reached); tell the person, with its console_url. Read its steps with runs_events and what it wrote with runs_files.";
219
219
  /** A route's answer, captured: its status, headers and bytes up to `limit`. A route that writes past it is cut off
220
220
  * there (`tooBig`): a file stream stops. */
221
221
  class Answer extends Writable {
package/dist/model.d.ts CHANGED
@@ -29,11 +29,12 @@ export declare const MODEL_NODES: readonly ["agent", "decide", "extract", "repor
29
29
  /** The model providers whose key a person may save here (tool-keys.ts' `model` rows), in the order a default is taken
30
30
  * from, each with the model a run gets on its key when neither its revision nor the host names one: the provider's
31
31
  * capable everyday model, not its dearest (Claude Sonnet 5.5 and GPT-6.1 Sol, each $2 in and $10 out per million
32
- * tokens). `harnesses`: those that run on the key, pi on any model of it and the harness that is the provider's own;
33
- * OpenRouter's runs all three. `models`: a harness's own default on the key where it is not `model`. On OpenRouter:
32
+ * tokens). `harnesses`: those that run on the key, pi on any model of it and the harnesses that talk to that
33
+ * provider's own API (OpenAI's: codex and opencode); OpenRouter's runs them all. `models`: a harness's own default on the
34
+ * key where it is not `model`. On OpenRouter:
34
35
  * pi's is GPT-6 Sol on pi-ai's openrouter provider (/chat/completions, the key as a bearer token, as OpenRouter's docs
35
36
  * name it; its Anthropic models go to /v1/messages with the key in x-api-key, which the docs do not), claude-agent's
36
- * Claude Sonnet 5.5 and codex's GPT-6 Sol, each through OpenRouter's own endpoint for the harness (adapters.ts), the ids
37
+ * Claude Sonnet 5.5 and codex's and opencode's GPT-6 Sol, each through OpenRouter's own endpoint for the harness (adapters.ts), the ids
37
38
  * a live run took through OpenRouter on 2026-10-29. The row order is the order a default is taken in: a direct
38
39
  * provider's key wins over OpenRouter's. */
39
40
  export declare const MODEL_KEYS: readonly [{
@@ -41,32 +42,33 @@ export declare const MODEL_KEYS: readonly [{
41
42
  readonly label: "Anthropic";
42
43
  readonly field: "ANTHROPIC_API_KEY";
43
44
  readonly model: "anthropic/claude-sonnet-5-5";
44
- readonly harnesses: readonly ["pi" | "claude-agent" | "codex", "claude-agent"];
45
+ readonly harnesses: readonly ["pi" | "claude-agent" | "codex" | "opencode", "claude-agent"];
45
46
  }, {
46
47
  readonly id: "openai";
47
48
  readonly label: "OpenAI";
48
49
  readonly field: "OPENAI_API_KEY";
49
50
  readonly model: "openai/gpt-6.1-sol";
50
- readonly harnesses: readonly ["pi" | "claude-agent" | "codex", "codex"];
51
+ readonly harnesses: readonly ["pi" | "claude-agent" | "codex" | "opencode", "codex", "opencode"];
51
52
  }, {
52
53
  readonly id: "openrouter";
53
54
  readonly label: "OpenRouter";
54
55
  readonly field: "OPENROUTER_API_KEY";
55
56
  readonly model: "openrouter/openai/gpt-6-sol";
56
- readonly harnesses: readonly ["pi" | "claude-agent" | "codex", "claude-agent", "codex"];
57
+ readonly harnesses: readonly ["pi" | "claude-agent" | "codex" | "opencode", "claude-agent", "codex", "opencode"];
57
58
  readonly models: {
58
59
  readonly "claude-agent": "anthropic/claude-sonnet-5.5";
59
60
  readonly codex: "openai/gpt-6-sol";
61
+ readonly opencode: "openai/gpt-6-sol";
60
62
  };
61
63
  }];
62
64
  /**
63
65
  * Whether `harness` reaches its vendor's models here only through OpenRouter: OPENROUTER_API_KEY is set and none of the
64
66
  * harness's own settings is. Those win, as on a host with no OpenRouter key: the endpoint the host names
65
- * (ANTHROPIC_BASE_URL for claude-agent, which needs ANTHROPIC_API_KEY; serve's gateway AGENT_MODEL_BASE_URL for codex,
66
- * with AGENT_MODEL_API_KEY or none), then the vendor's own key (ANTHROPIC_API_KEY, OPENAI_API_KEY), then OpenRouter. An
67
+ * (ANTHROPIC_BASE_URL for claude-agent, which needs ANTHROPIC_API_KEY; serve's gateway AGENT_MODEL_BASE_URL for codex
68
+ * and opencode, which take the same route, with AGENT_MODEL_API_KEY or none), then the vendor's own key (ANTHROPIC_API_KEY, OPENAI_API_KEY), then OpenRouter. An
67
69
  * endpoint the host names never gets the OpenRouter key.
68
70
  */
69
- export declare function openRouterOnly(harness: "claude-agent" | "codex", env: NodeJS.ProcessEnv): boolean;
71
+ export declare function openRouterOnly(harness: "claude-agent" | "codex" | "opencode", env: NodeJS.ProcessEnv): boolean;
70
72
  /** Whether `harness`'s model requests for `model` (as named, `provider/model-id`; none, the host's for the harness) go
71
73
  * through OpenRouter: a model named on it (`openrouter/<vendor>/...`), or the harness's vendor reached only through it
72
74
  * (openRouterOnly). The route claudeProvider and codexProvider take (adapters.ts); a gateway (AGENT_MODEL_BASE_URL)
@@ -78,9 +80,9 @@ export declare function viaOpenRouter(env: NodeJS.ProcessEnv, harness: string, m
78
80
  * taken in is MODEL_KEYS' own. */
79
81
  export declare const ADD_A_KEY: string;
80
82
  /** Whether `harness` runs the model `id`: pi any; claude-agent an Anthropic model (`anthropic/...`, or Anthropic's on
81
- * OpenRouter, `openrouter/anthropic/...`), as it talks to an Anthropic Messages endpoint only; codex, behind a gateway
83
+ * OpenRouter, `openrouter/anthropic/...`), as it talks to an Anthropic Messages endpoint only; codex and opencode, behind a gateway
82
84
  * (AGENT_MODEL_BASE_URL), any id, which is the gateway's own string and names no provider here (team/model included),
83
- * as codex takes that gateway for its OpenAI-compatible endpoint; without one, an OpenAI model (`openai/...`, or OpenAI's
85
+ * as each takes that gateway for its OpenAI-compatible endpoint; without one, an OpenAI model (`openai/...`, or OpenAI's
84
86
  * on OpenRouter). On the faux harness every harness runs the run's model. */
85
87
  export declare function harnessRuns(env: NodeJS.ProcessEnv, id: string, harness: string): boolean;
86
88
  /** The model a revision that names none runs on with `harness`, for `tier`: the tier's own variable, else AGENT_MODEL,
package/dist/model.js CHANGED
@@ -36,25 +36,26 @@ export const MODEL_NODES = ["agent", "decide", "extract", "report"];
36
36
  /** The model providers whose key a person may save here (tool-keys.ts' `model` rows), in the order a default is taken
37
37
  * from, each with the model a run gets on its key when neither its revision nor the host names one: the provider's
38
38
  * capable everyday model, not its dearest (Claude Sonnet 5.5 and GPT-6.1 Sol, each $2 in and $10 out per million
39
- * tokens). `harnesses`: those that run on the key, pi on any model of it and the harness that is the provider's own;
40
- * OpenRouter's runs all three. `models`: a harness's own default on the key where it is not `model`. On OpenRouter:
39
+ * tokens). `harnesses`: those that run on the key, pi on any model of it and the harnesses that talk to that
40
+ * provider's own API (OpenAI's: codex and opencode); OpenRouter's runs them all. `models`: a harness's own default on the
41
+ * key where it is not `model`. On OpenRouter:
41
42
  * pi's is GPT-6 Sol on pi-ai's openrouter provider (/chat/completions, the key as a bearer token, as OpenRouter's docs
42
43
  * name it; its Anthropic models go to /v1/messages with the key in x-api-key, which the docs do not), claude-agent's
43
- * Claude Sonnet 5.5 and codex's GPT-6 Sol, each through OpenRouter's own endpoint for the harness (adapters.ts), the ids
44
+ * Claude Sonnet 5.5 and codex's and opencode's GPT-6 Sol, each through OpenRouter's own endpoint for the harness (adapters.ts), the ids
44
45
  * a live run took through OpenRouter on 2026-10-29. The row order is the order a default is taken in: a direct
45
46
  * provider's key wins over OpenRouter's. */
46
47
  export const MODEL_KEYS = [
47
48
  { id: "anthropic", label: "Anthropic", field: "ANTHROPIC_API_KEY", model: "anthropic/claude-sonnet-5-5", harnesses: [DEFAULT_HARNESS, "claude-agent"] },
48
- { id: "openai", label: "OpenAI", field: "OPENAI_API_KEY", model: "openai/gpt-6.1-sol", harnesses: [DEFAULT_HARNESS, "codex"] },
49
- { id: "openrouter", label: "OpenRouter", field: "OPENROUTER_API_KEY", model: "openrouter/openai/gpt-6-sol", harnesses: [DEFAULT_HARNESS, "claude-agent", "codex"], models: { "claude-agent": "anthropic/claude-sonnet-5.5", codex: "openai/gpt-6-sol" } },
49
+ { id: "openai", label: "OpenAI", field: "OPENAI_API_KEY", model: "openai/gpt-6.1-sol", harnesses: [DEFAULT_HARNESS, "codex", "opencode"] },
50
+ { id: "openrouter", label: "OpenRouter", field: "OPENROUTER_API_KEY", model: "openrouter/openai/gpt-6-sol", harnesses: [DEFAULT_HARNESS, "claude-agent", "codex", "opencode"], models: { "claude-agent": "anthropic/claude-sonnet-5.5", codex: "openai/gpt-6-sol", opencode: "openai/gpt-6-sol" } },
50
51
  ];
51
52
  /** `row`'s default for `harness`: its own (`models`), else the row's. */
52
53
  const rowModel = (row, harness) => row.models?.[harness] ?? row.model;
53
54
  /**
54
55
  * Whether `harness` reaches its vendor's models here only through OpenRouter: OPENROUTER_API_KEY is set and none of the
55
56
  * harness's own settings is. Those win, as on a host with no OpenRouter key: the endpoint the host names
56
- * (ANTHROPIC_BASE_URL for claude-agent, which needs ANTHROPIC_API_KEY; serve's gateway AGENT_MODEL_BASE_URL for codex,
57
- * with AGENT_MODEL_API_KEY or none), then the vendor's own key (ANTHROPIC_API_KEY, OPENAI_API_KEY), then OpenRouter. An
57
+ * (ANTHROPIC_BASE_URL for claude-agent, which needs ANTHROPIC_API_KEY; serve's gateway AGENT_MODEL_BASE_URL for codex
58
+ * and opencode, which take the same route, with AGENT_MODEL_API_KEY or none), then the vendor's own key (ANTHROPIC_API_KEY, OPENAI_API_KEY), then OpenRouter. An
58
59
  * endpoint the host names never gets the OpenRouter key.
59
60
  */
60
61
  export function openRouterOnly(harness, env) {
@@ -82,9 +83,9 @@ export const ADD_A_KEY = `add a model key in Settings → Model keys, or set ${[
82
83
  * and codex take it (adapters.ts' claudeModel and codexProvider). */
83
84
  const onOpenRouter = (id, vendor) => new RegExp(`^openrouter/${vendor}/[^/]+$`).test(id);
84
85
  /** Whether `harness` runs the model `id`: pi any; claude-agent an Anthropic model (`anthropic/...`, or Anthropic's on
85
- * OpenRouter, `openrouter/anthropic/...`), as it talks to an Anthropic Messages endpoint only; codex, behind a gateway
86
+ * OpenRouter, `openrouter/anthropic/...`), as it talks to an Anthropic Messages endpoint only; codex and opencode, behind a gateway
86
87
  * (AGENT_MODEL_BASE_URL), any id, which is the gateway's own string and names no provider here (team/model included),
87
- * as codex takes that gateway for its OpenAI-compatible endpoint; without one, an OpenAI model (`openai/...`, or OpenAI's
88
+ * as each takes that gateway for its OpenAI-compatible endpoint; without one, an OpenAI model (`openai/...`, or OpenAI's
88
89
  * on OpenRouter). On the faux harness every harness runs the run's model. */
89
90
  export function harnessRuns(env, id, harness) {
90
91
  if (harness === DEFAULT_HARNESS || env[FAUX_HARNESS_ENV])
@@ -93,7 +94,7 @@ export function harnessRuns(env, id, harness) {
93
94
  const provider = slash > 0 ? id.slice(0, slash) : undefined;
94
95
  if (harness === "claude-agent")
95
96
  return provider === "anthropic" || onOpenRouter(id, "anthropic");
96
- if (harness === "codex")
97
+ if (harness === "codex" || harness === "opencode")
97
98
  return Boolean(env.AGENT_MODEL_BASE_URL) || provider === "openai" || onOpenRouter(id, "openai");
98
99
  return true;
99
100
  }
@@ -2472,6 +2472,7 @@
2472
2472
  },
2473
2473
  "browser": {
2474
2474
  "type": "string",
2475
+ "description": "The browser a run's `browser` tool drives here: the vendor it resolves to under the server's tool settings (`browserbase` or `kernel`) when `tools[]` lists `browser` as available, else `none`.",
2475
2476
  "enum": [
2476
2477
  "browserbase",
2477
2478
  "chrome",