@parcha/agentrun-serve 0.1.0-beta.42 → 0.1.0-beta.44

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 (181) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/README.md +221 -31
  3. package/dist/cli.js +42 -8
  4. package/dist/composio-preset.d.ts +4 -3
  5. package/dist/composio-preset.js +12 -4
  6. package/dist/composio-triggers.d.ts +20 -2
  7. package/dist/composio-triggers.js +183 -17
  8. package/dist/computer-lost.d.ts +11 -0
  9. package/dist/computer-lost.js +19 -0
  10. package/dist/computer-record.d.ts +10 -2
  11. package/dist/computer-record.js +50 -18
  12. package/dist/computer-setting.d.ts +1 -0
  13. package/dist/computer-setting.js +2 -2
  14. package/dist/console/assets/index-BUktRvS-.css +1 -0
  15. package/dist/console/assets/index-nB9kTfIN.js +711 -0
  16. package/dist/console/index.html +2 -2
  17. package/dist/decisions.js +0 -4
  18. package/dist/errors.d.ts +1 -0
  19. package/dist/errors.js +3 -0
  20. package/dist/harness-table.d.ts +51 -3
  21. package/dist/harness-table.js +101 -13
  22. package/dist/harness.d.ts +18 -1
  23. package/dist/harness.js +21 -9
  24. package/dist/host.d.ts +12 -10
  25. package/dist/host.js +18 -16
  26. package/dist/import-sources.js +25 -5
  27. package/dist/import-worker.d.ts +3 -0
  28. package/dist/import-worker.js +7 -5
  29. package/dist/import.d.ts +22 -1
  30. package/dist/import.js +141 -28
  31. package/dist/learn/audit.d.ts +123 -0
  32. package/dist/learn/audit.js +159 -0
  33. package/dist/learn/check.d.ts +3 -0
  34. package/dist/learn/check.js +1 -1
  35. package/dist/learn/compile.d.ts +50 -74
  36. package/dist/learn/compile.js +90 -124
  37. package/dist/learn/delete.d.ts +17 -0
  38. package/dist/learn/delete.js +44 -0
  39. package/dist/learn/folder.d.ts +9 -0
  40. package/dist/learn/folder.js +13 -2
  41. package/dist/learn/promote.d.ts +92 -200
  42. package/dist/learn/promote.js +65 -187
  43. package/dist/learn/replay-calls.d.ts +5 -0
  44. package/dist/learn/replay-calls.js +12 -1
  45. package/dist/learn/secrets.d.ts +8 -0
  46. package/dist/learn/secrets.js +12 -0
  47. package/dist/learn/skills.d.ts +4 -0
  48. package/dist/learn/skills.js +19 -5
  49. package/dist/learn/workflow-nodes.d.ts +23 -3
  50. package/dist/learn/workflow-nodes.js +30 -12
  51. package/dist/learned-nodes.d.ts +9 -34
  52. package/dist/learned-nodes.js +11 -23
  53. package/dist/learned-workflow.d.ts +6 -8
  54. package/dist/learned-workflow.js +18 -57
  55. package/dist/learning-batch.d.ts +13 -5
  56. package/dist/learning-batch.js +34 -8
  57. package/dist/learning-cost.d.ts +111 -4
  58. package/dist/learning-cost.js +120 -3
  59. package/dist/learning-evals.d.ts +2 -0
  60. package/dist/learning-evals.js +4 -3
  61. package/dist/learning-routes.d.ts +8 -0
  62. package/dist/learning-routes.js +18 -1
  63. package/dist/learning-setting.d.ts +16 -1
  64. package/dist/learning-setting.js +34 -2
  65. package/dist/learning.d.ts +1 -1
  66. package/dist/listen-first.d.ts +30 -0
  67. package/dist/listen-first.js +115 -0
  68. package/dist/llms.txt +2 -1
  69. package/dist/mcp-servers-store.d.ts +12 -12
  70. package/dist/model.d.ts +8 -4
  71. package/dist/model.js +16 -8
  72. package/dist/openapi.js +203 -87
  73. package/dist/owner.d.ts +8 -0
  74. package/dist/owner.js +11 -0
  75. package/dist/paid-calls.d.ts +6 -0
  76. package/dist/paid-calls.js +11 -1
  77. package/dist/place.d.ts +8 -3
  78. package/dist/place.js +13 -9
  79. package/dist/provider.js +15 -1
  80. package/dist/run-launch.d.ts +6 -3
  81. package/dist/run-launch.js +2 -0
  82. package/dist/run-learning-served.d.ts +1 -1
  83. package/dist/run-model-key.d.ts +64 -0
  84. package/dist/run-model-key.js +147 -0
  85. package/dist/runner/adapter-loop.d.ts +10 -0
  86. package/dist/runner/adapter-loop.js +26 -4
  87. package/dist/runner/adapter-run-spec.d.ts +6 -3
  88. package/dist/runner/adapter-run-spec.js +83 -25
  89. package/dist/runner/adapters/index.d.ts +4 -2
  90. package/dist/runner/adapters/index.js +13 -4
  91. package/dist/runner/audit.d.ts +68 -0
  92. package/dist/runner/audit.js +349 -0
  93. package/dist/runner/beside.d.ts +2 -1
  94. package/dist/runner/beside.js +6 -3
  95. package/dist/runner/claim-secrets.d.ts +49 -0
  96. package/dist/runner/claim-secrets.js +110 -1
  97. package/dist/runner/cli-run-spec.d.ts +2 -1
  98. package/dist/runner/cli-run-spec.js +44 -15
  99. package/dist/runner/commands.d.ts +3 -6
  100. package/dist/runner/feedback-round.d.ts +3 -2
  101. package/dist/runner/feedback-round.js +8 -7
  102. package/dist/runner/harness-loops.js +31 -23
  103. package/dist/runner/journal-kinds.d.ts +5 -7
  104. package/dist/runner/journal-kinds.js +0 -7
  105. package/dist/runner/learning-dispatch.d.ts +0 -16
  106. package/dist/runner/learning-dispatch.js +4 -47
  107. package/dist/runner/learning-end.d.ts +55 -13
  108. package/dist/runner/learning-end.js +128 -44
  109. package/dist/runner/learning-factory.d.ts +1 -1
  110. package/dist/runner/learning-factory.js +1 -4
  111. package/dist/runner/learning-loop.d.ts +2 -38
  112. package/dist/runner/learning-loop.js +8 -116
  113. package/dist/runner/loop-contract.d.ts +6 -0
  114. package/dist/runner/loop-contract.js +4 -0
  115. package/dist/runner/loop.js +6 -2
  116. package/dist/runner/main.d.ts +1 -0
  117. package/dist/runner/main.js +25 -8
  118. package/dist/runner/memory-claim.d.ts +9 -6
  119. package/dist/runner/memory-claim.js +12 -9
  120. package/dist/runner/promotion.d.ts +55 -54
  121. package/dist/runner/promotion.js +232 -585
  122. package/dist/runner/reflect-hook.d.ts +14 -0
  123. package/dist/runner/reflect-hook.js +28 -3
  124. package/dist/runner/runner.js +57 -4
  125. package/dist/runner/store-secrets.js +9 -5
  126. package/dist/runner/workflow-first.d.ts +6 -5
  127. package/dist/runner/workflow-first.js +17 -12
  128. package/dist/runner/workflow-spec.js +10 -2
  129. package/dist/runs-over-store.d.ts +5 -4
  130. package/dist/runs-over-store.js +13 -3
  131. package/dist/sdk/workflows.d.ts +1 -1
  132. package/dist/server.d.ts +64 -50
  133. package/dist/server.js +516 -134
  134. package/dist/store/index.d.ts +2 -2
  135. package/dist/store/index.js +1 -1
  136. package/dist/store/seal.d.ts +20 -2
  137. package/dist/store/seal.js +24 -8
  138. package/dist/store/sqlite/run-launch.d.ts +4 -1
  139. package/dist/store/sqlite/run-launch.js +12 -0
  140. package/dist/store/sqlite/store.d.ts +3 -2
  141. package/dist/store/sqlite/store.js +119 -16
  142. package/dist/store/store.d.ts +41 -3
  143. package/dist/store-reads/analytics.js +11 -1
  144. package/dist/store-reads/learning.d.ts +57 -7
  145. package/dist/store-reads/learning.js +194 -28
  146. package/dist/store-reads/loop.d.ts +4 -39
  147. package/dist/store-reads/loop.js +10 -79
  148. package/dist/store-reads/stats.js +13 -3
  149. package/dist/store-view.d.ts +5 -1
  150. package/dist/store-view.js +12 -1
  151. package/dist/telemetry.d.ts +59 -0
  152. package/dist/telemetry.js +153 -0
  153. package/dist/tool-keys-store.d.ts +1 -1
  154. package/dist/tool-keys.d.ts +2 -2
  155. package/dist/tool-plane.d.ts +12 -12
  156. package/dist/tools.d.ts +11 -11
  157. package/dist/tools.js +18 -5
  158. package/dist/trigger-adapter.d.ts +3 -0
  159. package/dist/trigger-adapters.d.ts +4 -0
  160. package/dist/trigger-adapters.js +13 -0
  161. package/dist/trigger-composio.d.ts +58 -1
  162. package/dist/trigger-composio.js +160 -6
  163. package/dist/triggers.d.ts +4 -0
  164. package/dist/triggers.js +22 -3
  165. package/dist/validate.d.ts +11 -7
  166. package/dist/validate.js +8 -7
  167. package/dist/workspace/computer-for-claim.d.ts +15 -5
  168. package/dist/workspace/computer-for-claim.js +228 -32
  169. package/dist/workspace/resolve-computer.d.ts +8 -2
  170. package/dist/workspace/resolve-computer.js +1 -1
  171. package/dist/workspace/run-tools.d.ts +1 -1
  172. package/dist/workspace/run-tools.js +14 -3
  173. package/package.json +10 -9
  174. package/dist/console/assets/index-C3gNPz58.css +0 -1
  175. package/dist/console/assets/index-DYJ_wj27.js +0 -711
  176. package/dist/learn/general.d.ts +0 -69
  177. package/dist/learn/general.js +0 -75
  178. package/dist/learn/refit.d.ts +0 -48
  179. package/dist/learn/refit.js +0 -264
  180. package/dist/runner/step-guard.d.ts +0 -62
  181. package/dist/runner/step-guard.js +0 -93
@@ -0,0 +1,115 @@
1
+ // The address first. The server's CLI binds its port here, before it loads the rest of the server: on a slow disk (a cold
2
+ // start, a loaded machine), loading the server's modules is most of a start, and the store, the harness probes and Docker
3
+ // come after it. Until the server takes this socket over (ServeOptions.listener), every request is answered here: the
4
+ // server is warming. GET /v2/health says so (503, status "warming", the store "opening"), the API answers 503
5
+ // `unavailable` with a Retry-After, and a browser gets a page that reloads itself. Only node's own modules load here.
6
+ import { randomBytes } from "node:crypto";
7
+ import { statfs } from "node:fs/promises";
8
+ import { createServer } from "node:http";
9
+ /** The port a server takes when none is named: the first free one from here (cli.ts). */
10
+ export const DEFAULT_PORT = 7340;
11
+ /** The address a server listens on when none is named: this machine only. */
12
+ export const DEFAULT_HOST = "127.0.0.1";
13
+ /** The free disk under the data directory below which GET /v2/health fails, in MiB, unless AGENTRUN_MIN_FREE_MB says. */
14
+ export const MIN_FREE_MIB = 64;
15
+ /** How long a warming answer asks its caller to wait before it asks again (Retry-After), and the page's reload. */
16
+ export const WARMING_RETRY_S = 2;
17
+ /** AGENTRUN_MIN_FREE_MB as MiB (MIN_FREE_MIB when unset), or undefined when it is no number of MiB, 0 or more. */
18
+ export function minFreeMibOf(env) {
19
+ const mib = env.AGENTRUN_MIN_FREE_MB ? Number(env.AGENTRUN_MIN_FREE_MB) : MIN_FREE_MIB;
20
+ return Number.isFinite(mib) && mib >= 0 ? mib : undefined;
21
+ }
22
+ /** `server` listening on `host`, from port `first`; with `nextFreePort`, a taken port passes to the next, up to 99 past
23
+ * `first`. Each attempt takes off both its handlers when it ends, so a taken port leaves no listener behind. */
24
+ export async function listenOn(server, host, first, nextFreePort) {
25
+ const last = nextFreePort && first !== 0 ? Math.min(first + 99, 65_535) : first;
26
+ for (let port = first;; port++) {
27
+ try {
28
+ await new Promise((done, reject) => {
29
+ const onError = (error) => (server.off("listening", onListening), reject(error));
30
+ const onListening = () => (server.off("error", onError), done());
31
+ server.once("error", onError);
32
+ server.once("listening", onListening);
33
+ server.listen(port, host);
34
+ });
35
+ return;
36
+ }
37
+ catch (error) {
38
+ if (error.code !== "EADDRINUSE")
39
+ throw error;
40
+ if (port < last)
41
+ continue;
42
+ throw last > first ? Object.assign(new Error(`every port from ${first} to ${last} on ${host} is taken`), { code: "EADDRINUSE" }) : error;
43
+ }
44
+ }
45
+ }
46
+ /** The URL a listening `server` on `host` is reached at on this machine: an address of every interface at its loopback one. */
47
+ export function urlOf(server, host) {
48
+ const shown = host === "0.0.0.0" || host === "::" ? "127.0.0.1" : host;
49
+ return `http://${shown.includes(":") ? `[${shown}]` : shown}:${server.address().port}`;
50
+ }
51
+ const PAGE = `<!doctype html>
52
+ <html lang="en"><head><meta charset="utf-8"><meta http-equiv="refresh" content="${WARMING_RETRY_S}"><meta name="color-scheme" content="light dark"><title>AgentRun is starting</title></head>
53
+ <body style="font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin: 3rem"><p>AgentRun is starting. This page reloads until it is ready.</p></body></html>
54
+ `;
55
+ /** The warming answer to one request: health, a browser's page, or the API's 503. Nothing in it is the server's: no
56
+ * token, no data, so it needs no Host check. */
57
+ function warming(data, minFreeBytes) {
58
+ return (req, res) => {
59
+ res.setHeader("x-request-id", `req_${randomBytes(8).toString("hex")}`);
60
+ res.setHeader("retry-after", String(WARMING_RETRY_S));
61
+ res.setHeader("cache-control", "no-store");
62
+ const path = (req.url ?? "/").split("?")[0];
63
+ const json = (body) => {
64
+ res.writeHead(503, { "content-type": "application/json" });
65
+ res.end(JSON.stringify(body));
66
+ };
67
+ req.resume();
68
+ if (path === "/v2/health") {
69
+ void statfs(data).then((fs) => fs.bavail * fs.bsize, () => undefined).then((free) => {
70
+ const disk = free === undefined || minFreeBytes === undefined ? "cannot_check" : free >= minFreeBytes ? "ok" : "below_floor";
71
+ json({ status: "warming", checks: { store: "opening", disk } });
72
+ });
73
+ return;
74
+ }
75
+ if (req.method === "GET" && !path.startsWith("/v2/") && /\btext\/html\b/i.test(String(req.headers.accept ?? ""))) {
76
+ res.writeHead(503, { "content-type": "text/html; charset=utf-8" });
77
+ res.end(PAGE);
78
+ return;
79
+ }
80
+ json({ error: { code: "unavailable", message: `AgentRun is starting: its store is opening. Send the request again in ${WARMING_RETRY_S} s.`, retryable: true, request_id: res.getHeader("x-request-id") } });
81
+ };
82
+ }
83
+ /** A WebSocket asked for while warming: refused, to be asked again. */
84
+ function warmingUpgrade(_req, socket) {
85
+ socket.on("error", () => socket.destroy());
86
+ socket.end(`HTTP/1.1 503 Service Unavailable\r\nConnection: close\r\nRetry-After: ${WARMING_RETRY_S}\r\nContent-Length: 0\r\n\r\n`);
87
+ }
88
+ /** A server bound on `host` at `port`, answering warming (above) until `takeOver`. Undefined when that port is taken: the
89
+ * port is then left to the start's own listen, which waits for a server it replaces (a restart, a redeploy) to let go of
90
+ * the data directory first, and only then takes the port, or passes to the next free one, as it always has. Any other
91
+ * failure to listen throws. */
92
+ export async function listenFirst(o) {
93
+ const mib = minFreeMibOf(o.env);
94
+ const server = createServer(warming(o.data, mib === undefined ? undefined : mib * 2 ** 20));
95
+ // A request's headers come within 10 s, as the server's own listener has them.
96
+ server.headersTimeout = 10_000;
97
+ server.on("upgrade", warmingUpgrade);
98
+ try {
99
+ await listenOn(server, o.host, o.port, false);
100
+ }
101
+ catch (error) {
102
+ if (error.code === "EADDRINUSE")
103
+ return undefined;
104
+ throw error;
105
+ }
106
+ return server;
107
+ }
108
+ /** The server's own handlers on `server` from now on, in place of the warming ones: a request already being answered
109
+ * finishes as it began. */
110
+ export function takeOver(server, onRequest, onUpgrade) {
111
+ server.removeAllListeners("request");
112
+ server.removeAllListeners("upgrade");
113
+ server.on("request", onRequest);
114
+ server.on("upgrade", onUpgrade);
115
+ }
package/dist/llms.txt CHANGED
@@ -17,7 +17,8 @@ Auth: the API's routes take `Authorization: Bearer <token>`, all but `GET /v2/he
17
17
  - `POST /v2/agents` with `{definition: {name, instructions, tools, harness?, model?, thinking?}}` makes an agent (a workflow one holds `workflow` in place of `instructions`). A refusal is `422 input_invalid` naming each field. `PUT /v2/agents/{id}/definition` makes its next revision.
18
18
  - `POST /v2/agents/{id}/runs` with `{input, file_ids?, effort?, revision?}` starts a run, answered at once, queued. An agentic run's input is `{content: "the first message"}`. An `Idempotency-Key` header makes a retry safe.
19
19
  - `POST /v2/files?path=notes.md` with the file's bytes as the body (`curl --data-binary @notes.md`) uploads a file, answered `201` with the file, ready, its `file_id` under `file`. Name it in a run's `file_ids`, and the run finds it at `inputs/notes.md`. `GET /v2/files` lists the uploads, `DELETE /v2/files/{id}` removes one.
20
- - `GET /v2/runs/{id}`: status (`queued`, `working`, `input_required`, `completed`, `failed`, `cancelled`, `paused`), `result` (`final_answer`, or a workflow's `output`), `error`, `cost` (`usd` is null while unknown, never $0).
20
+ - `GET /v2/runs/{id}`: status (`queued`, `working`, `input_required`, `completed`, `failed`, `cancelled`, `paused`), `result` (`final_answer`, or a workflow's `output`), `error`, `cost` (`usd` is null while unknown, never $0), `path` (`agent`, `workflow`, `handed_back`; null until it ends).
21
+ - An agent that learns: a run its learned workflow served (`path` `workflow`) has the workflow's answer as `result.final_answer`; one handed back (`handed_back`) has the agent's. Its timeline is its `user_message`, the learned_workflow `tool_use` and `tool_result` (its nodes in `learned_nodes`; they write no `decision` rows), then `final_answer` and `usage`; a hand-back puts a `phase` row and the agent's own rows before them. Learning spends on the agent's own model route, key and cap: on `GET /v2/runs/{id}`, `cost.usd` is the run's own spend, the job's; `cost.learning_usd` what learning spent for it (its look-back, its grade, its audit's shadow run, and its share of its workflow revision's compile turn and check, spread over the revision's first `compile_after` served runs; a compile whose drafts all failed is on no run, in the bill's `unattributed_usd`), `cost.all_in_usd` both. A shadow run is in no run list and sends no webhook. `GET /v2/agents/{id}/learning/cost` has the agent's whole bill (`bill`).
21
22
  - `GET /v2/runs/{id}/timeline?after=0&limit=100` pages its steps; follow `next_after` until a page is `final` with `has_more` false.
22
23
  - `GET /v2/runs/{id}/files`, then `GET /v2/runs/{id}/files/{path}`: what it wrote.
23
24
  - `POST /v2/runs/{id}/messages` with `{content}` answers a run that asked a question (`input_required`), or follows up; `POST /v2/runs/{id}/cancel` ends one.
@@ -148,11 +148,11 @@ export declare class McpServersOverStore {
148
148
  not_metered?: string[] | undefined;
149
149
  tools: {
150
150
  grant_problems?: Record<string, string>;
151
- default_permission: "allow" | "ask" | "deny";
152
- permissions: ("allow" | "ask" | "deny")[];
151
+ default_permission: "ask" | "allow" | "deny";
152
+ permissions: ("ask" | "allow" | "deny")[];
153
153
  fallback_allow_reads?: true | undefined;
154
154
  allow_reads?: true | undefined;
155
- permission: "allow" | "ask" | "deny";
155
+ permission: "ask" | "allow" | "deny";
156
156
  effect: import("./tool-gate.js").ToolEffect;
157
157
  name: string;
158
158
  title?: string;
@@ -189,11 +189,11 @@ export declare class McpServersOverStore {
189
189
  not_metered?: string[] | undefined;
190
190
  tools: {
191
191
  grant_problems?: Record<string, string>;
192
- default_permission: "allow" | "ask" | "deny";
193
- permissions: ("allow" | "ask" | "deny")[];
192
+ default_permission: "ask" | "allow" | "deny";
193
+ permissions: ("ask" | "allow" | "deny")[];
194
194
  fallback_allow_reads?: true | undefined;
195
195
  allow_reads?: true | undefined;
196
- permission: "allow" | "ask" | "deny";
196
+ permission: "ask" | "allow" | "deny";
197
197
  effect: import("./tool-gate.js").ToolEffect;
198
198
  name: string;
199
199
  title?: string;
@@ -259,11 +259,11 @@ export declare class McpServersOverStore {
259
259
  not_metered?: string[] | undefined;
260
260
  tools: {
261
261
  grant_problems?: Record<string, string>;
262
- default_permission: "allow" | "ask" | "deny";
263
- permissions: ("allow" | "ask" | "deny")[];
262
+ default_permission: "ask" | "allow" | "deny";
263
+ permissions: ("ask" | "allow" | "deny")[];
264
264
  fallback_allow_reads?: true | undefined;
265
265
  allow_reads?: true | undefined;
266
- permission: "allow" | "ask" | "deny";
266
+ permission: "ask" | "allow" | "deny";
267
267
  effect: import("./tool-gate.js").ToolEffect;
268
268
  name: string;
269
269
  title?: string;
@@ -304,11 +304,11 @@ export declare class McpServersOverStore {
304
304
  not_metered?: string[] | undefined;
305
305
  tools: {
306
306
  grant_problems?: Record<string, string>;
307
- default_permission: "allow" | "ask" | "deny";
308
- permissions: ("allow" | "ask" | "deny")[];
307
+ default_permission: "ask" | "allow" | "deny";
308
+ permissions: ("ask" | "allow" | "deny")[];
309
309
  fallback_allow_reads?: true | undefined;
310
310
  allow_reads?: true | undefined;
311
- permission: "allow" | "ask" | "deny";
311
+ permission: "ask" | "allow" | "deny";
312
312
  effect: import("./tool-gate.js").ToolEffect;
313
313
  name: string;
314
314
  title?: string;
package/dist/model.d.ts CHANGED
@@ -6,10 +6,12 @@ import type { Revision } from "./agent-rows.js";
6
6
  /** The child's environment names the faux module by absolute path. */
7
7
  export declare const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
8
8
  /** Every test hook's name starts so (AGENTRUN_SERVE_FAUX, AGENTRUN_SERVE_FAUX_WEB, ...), but the harness table's
9
- * (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name. */
9
+ * (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name, as it drops the resolved harness modules list
10
+ * (HARNESS_MODULES_ENV). */
10
11
  export declare const FAUX_PREFIX = "AGENTRUN_SERVE_FAUX";
11
- /** `env` without a test hook's name: serve sets those from startServe's options alone, so a name the server's own
12
- * environment holds (an operator's export, a leftover) never gives its runs fake answers or loads a module. */
12
+ /** `env` without a test hook's name or the resolved harness modules list: serve sets those from startServe's options
13
+ * alone, so a name the server's own environment holds (an operator's export, a leftover) never gives its runs fake
14
+ * answers or loads a module. */
13
15
  export declare const withoutFaux: (env: NodeJS.ProcessEnv) => NodeJS.ProcessEnv;
14
16
  /** Under `--faux` only: a module whose default export is the fetch the Anthropic and OpenAI providers send through (the
15
17
  * tests' fake upstream), in place of their APIs. With it they are registered beside the faux model, for a tool's own
@@ -229,7 +231,9 @@ export declare function catalogPrices(): Promise<Map<string, Listed[]>>;
229
231
  * version form: the vendor's entry (the id's segment before it, else `named`); else each level every entry that says
230
232
  * agrees on (gpt-6.1-sol's entries differ on `minimal` alone: openai-codex's asks low), a level they differ on left to
231
233
  * pi-ai's default. None: undefined, pi-ai's defaults. So pi through a gateway at thinking off asks gpt-6.1-sol for no
232
- * effort, as its catalog entries say (off: null), not the "none" it refuses. */
234
+ * effort, as its catalog entries say (off: null), not the "none" it refuses. A model the catalog does not list (a local
235
+ * model, a gateway's own alias) is never asked to stop reasoning either (off: null): pi then thinks at its lowest level,
236
+ * so a model that reasons anyway has its reasoning split out of the answer, never written into it. */
233
237
  export declare function catalogThinking(catalog: ReadonlyMap<string, readonly Listed[]>, id: string, named: string | undefined): ThinkingLevelMap | undefined;
234
238
  /** A gateway model's price in `catalog` (catalogPrices'), by its id as the host or the revision names it: a ref that names
235
239
  * its provider (`named`), priced as that provider's entry, whether the id went whole or bare; a host model set whole
package/dist/model.js CHANGED
@@ -8,7 +8,7 @@
8
8
  import { isRouter, withLocalModels } from "./local-models.js";
9
9
  import { pathToFileURL } from "node:url";
10
10
  import { DEFAULT_HARNESS, PLAN_HARNESSES } from "./harness.js";
11
- import { HARNESS_TABLE_ENV, harnessOf } from "./harness-table.js";
11
+ import { HARNESS_MODULES_ENV, HARNESS_TABLE_ENV, harnessOf } from "./harness-table.js";
12
12
  import { gatewayBase } from "./provider.js";
13
13
  import { modelFormWhy } from "./model-form.js";
14
14
  // Leaves, which the key rows below read as this module loads, in any import order (wires.ts, adapter-facts.ts).
@@ -19,11 +19,13 @@ import { EXPIRED, PLAN_DEFAULT_MODEL, PLAN_ORIGIN, PLAN_PROVIDER, planOf, signed
19
19
  /** The child's environment names the faux module by absolute path. */
20
20
  export const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
21
21
  /** Every test hook's name starts so (AGENTRUN_SERVE_FAUX, AGENTRUN_SERVE_FAUX_WEB, ...), but the harness table's
22
- * (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name. */
22
+ * (harness-table.ts HARNESS_TABLE_ENV), which withoutFaux drops by name, as it drops the resolved harness modules list
23
+ * (HARNESS_MODULES_ENV). */
23
24
  export const FAUX_PREFIX = "AGENTRUN_SERVE_FAUX";
24
- /** `env` without a test hook's name: serve sets those from startServe's options alone, so a name the server's own
25
- * environment holds (an operator's export, a leftover) never gives its runs fake answers or loads a module. */
26
- export const withoutFaux = (env) => Object.fromEntries(Object.entries(env).filter(([name]) => !name.startsWith(FAUX_PREFIX) && name !== HARNESS_TABLE_ENV));
25
+ /** `env` without a test hook's name or the resolved harness modules list: serve sets those from startServe's options
26
+ * alone, so a name the server's own environment holds (an operator's export, a leftover) never gives its runs fake
27
+ * answers or loads a module. */
28
+ export const withoutFaux = (env) => Object.fromEntries(Object.entries(env).filter(([name]) => !name.startsWith(FAUX_PREFIX) && name !== HARNESS_TABLE_ENV && name !== HARNESS_MODULES_ENV));
27
29
  /** Under `--faux` only: a module whose default export is the fetch the Anthropic and OpenAI providers send through (the
28
30
  * tests' fake upstream), in place of their APIs. With it they are registered beside the faux model, for a tool's own
29
31
  * request to the provider the revision's model names (web_search's, hosted-search.ts); the run's turns stay faux. */
@@ -454,7 +456,8 @@ export async function runModels(env, ref, tiers = ["default"], harness = DEFAULT
454
456
  // the provider's client per wire, which pi-ai picks by the model's `api`.
455
457
  const gatewayModels = ids.map((id) => {
456
458
  const cost = priceOf(id);
457
- // The effort each thinking level asks for, as the catalog says of the model (catalogThinking): sol's off sends none.
459
+ // The effort each thinking level asks for, as the catalog says of the model (catalogThinking): sol's off sends none,
460
+ // and so does a model the catalog does not list.
458
461
  const thinking = catalogThinking(catalog, id, namedOf.get(id));
459
462
  const shared = { id, name: id, provider: MODEL_PROVIDER, reasoning: true, input: ["text", "image"], cost, contextWindow: 128_000, maxTokens: 32_000, ...(thinking ? { thinkingLevelMap: thinking } : {}) };
460
463
  return wireOf(id) === "anthropic-messages" ? { ...shared, api: "anthropic-messages", baseUrl: base } : { ...shared, api: "openai-responses", baseUrl, compat: { supportsDeveloperRole: false } };
@@ -712,12 +715,17 @@ export async function catalogPrices() {
712
715
  * version form: the vendor's entry (the id's segment before it, else `named`); else each level every entry that says
713
716
  * agrees on (gpt-6.1-sol's entries differ on `minimal` alone: openai-codex's asks low), a level they differ on left to
714
717
  * pi-ai's default. None: undefined, pi-ai's defaults. So pi through a gateway at thinking off asks gpt-6.1-sol for no
715
- * effort, as its catalog entries say (off: null), not the "none" it refuses. */
718
+ * effort, as its catalog entries say (off: null), not the "none" it refuses. A model the catalog does not list (a local
719
+ * model, a gateway's own alias) is never asked to stop reasoning either (off: null): pi then thinks at its lowest level,
720
+ * so a model that reasons anyway has its reasoning split out of the answer, never written into it. */
716
721
  export function catalogThinking(catalog, id, named) {
717
722
  const segments = id.split("/");
718
723
  const own = segments.at(-1);
719
724
  const vendor = segments.length > 1 ? segments.at(-2) : named;
720
- const saying = [own, ...flippedForms(own)].flatMap((form) => catalog.get(form) ?? []).flatMap((entry) => (entry.thinkingLevelMap ? [{ provider: entry.provider, map: entry.thinkingLevelMap }] : []));
725
+ const listed = [own, ...flippedForms(own)].flatMap((form) => catalog.get(form) ?? []);
726
+ if (!listed.length)
727
+ return { off: null };
728
+ const saying = listed.flatMap((entry) => (entry.thinkingLevelMap ? [{ provider: entry.provider, map: entry.thinkingLevelMap }] : []));
721
729
  const vendors = saying.find((entry) => entry.provider === vendor);
722
730
  if (vendors)
723
731
  return vendors.map;