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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/CHANGELOG.md +211 -1
  2. package/NOTICE +4 -0
  3. package/README.md +350 -53
  4. package/dist/acp-package.d.ts +53 -6
  5. package/dist/acp-package.js +3 -3
  6. package/dist/adapter-facts.d.ts +3 -4
  7. package/dist/adapter-facts.js +4 -4
  8. package/dist/adapters.d.ts +3 -5
  9. package/dist/adapters.js +1 -31
  10. package/dist/agents-store.d.ts +5 -3
  11. package/dist/agents-store.js +13 -8
  12. package/dist/answer-json.d.ts +10 -0
  13. package/dist/answer-json.js +24 -0
  14. package/dist/api-only.d.ts +11 -11
  15. package/dist/api-only.js +16 -11
  16. package/dist/archil-routes.js +2 -1
  17. package/dist/browser-live.d.ts +9 -4
  18. package/dist/browser-live.js +18 -5
  19. package/dist/cap.js +10 -2
  20. package/dist/chatgpt-plan.js +2 -1
  21. package/dist/cli.js +109 -41
  22. package/dist/composio-made.d.ts +19 -2
  23. package/dist/composio-made.js +17 -5
  24. package/dist/composio-preset.d.ts +42 -7
  25. package/dist/composio-preset.js +106 -70
  26. package/dist/composio-triggers.d.ts +9 -4
  27. package/dist/composio-triggers.js +20 -13
  28. package/dist/computer-attach.d.ts +11 -10
  29. package/dist/computer-attach.js +13 -14
  30. package/dist/computer-commands.d.ts +3 -0
  31. package/dist/computer-commands.js +3 -2
  32. package/dist/computer-lost.d.ts +4 -0
  33. package/dist/computer-lost.js +8 -3
  34. package/dist/computer-routes.d.ts +8 -5
  35. package/dist/computer-routes.js +7 -5
  36. package/dist/computer-setting.d.ts +2 -0
  37. package/dist/computer-setting.js +2 -0
  38. package/dist/computers.d.ts +14 -76
  39. package/dist/computers.js +24 -68
  40. package/dist/conformance.d.ts +4 -0
  41. package/dist/conformance.js +6 -0
  42. package/dist/console/assets/index-CTGegcKt.css +1 -0
  43. package/dist/console/assets/index-D1Se6mgG.js +715 -0
  44. package/dist/console/index.html +2 -2
  45. package/dist/cost-heal.d.ts +13 -0
  46. package/dist/cost-heal.js +27 -0
  47. package/dist/dial-relay.d.ts +6 -2
  48. package/dist/dial-relay.js +9 -12
  49. package/dist/email/routes.js +2 -1
  50. package/dist/errors.d.ts +2 -0
  51. package/dist/errors.js +5 -0
  52. package/dist/exa-keyless.d.ts +1 -1
  53. package/dist/exa-keyless.js +1 -1
  54. package/dist/faux-computers.d.ts +2 -3
  55. package/dist/faux-computers.js +9 -31
  56. package/dist/github-connection.js +2 -1
  57. package/dist/harness-archive.d.ts +19 -2
  58. package/dist/harness-archive.js +49 -15
  59. package/dist/harness-check.d.ts +75 -0
  60. package/dist/harness-check.js +518 -0
  61. package/dist/harness-cursor.d.ts +28 -0
  62. package/dist/harness-cursor.js +42 -0
  63. package/dist/harness-goose.d.ts +4 -29
  64. package/dist/harness-goose.js +6 -86
  65. package/dist/harness-module.d.ts +4 -0
  66. package/dist/harness-module.js +1 -0
  67. package/dist/harness-owned.d.ts +52 -0
  68. package/dist/harness-owned.js +92 -0
  69. package/dist/harness-recipe.d.ts +127 -0
  70. package/dist/harness-recipe.js +335 -0
  71. package/dist/harness-table.d.ts +120 -5
  72. package/dist/harness-table.js +280 -6
  73. package/dist/harness.d.ts +2 -0
  74. package/dist/harness.js +5 -4
  75. package/dist/host-check.d.ts +6 -0
  76. package/dist/host-check.js +14 -0
  77. package/dist/host.d.ts +10 -3
  78. package/dist/host.js +17 -3
  79. package/dist/import-sources.d.ts +2 -0
  80. package/dist/import-sources.js +2 -0
  81. package/dist/import-summary.d.ts +15 -5
  82. package/dist/import-summary.js +24 -8
  83. package/dist/import.d.ts +24 -4
  84. package/dist/import.js +108 -26
  85. package/dist/key-refusal.d.ts +3 -1
  86. package/dist/key-refusal.js +26 -5
  87. package/dist/key-words.d.ts +1 -1
  88. package/dist/key-words.js +4 -4
  89. package/dist/learn/check.d.ts +3 -0
  90. package/dist/learn/check.js +31 -20
  91. package/dist/learn/compile.js +12 -5
  92. package/dist/learn/promote.d.ts +80 -2
  93. package/dist/learn/promote.js +95 -3
  94. package/dist/learn/secrets.d.ts +4 -0
  95. package/dist/learn/secrets.js +23 -0
  96. package/dist/learned-nodes.d.ts +4 -3
  97. package/dist/learned-workflow.js +4 -1
  98. package/dist/learning-cost.d.ts +6 -16
  99. package/dist/learning-cost.js +6 -12
  100. package/dist/learning-model.d.ts +18 -0
  101. package/dist/learning-model.js +77 -0
  102. package/dist/learning-words.d.ts +2 -0
  103. package/dist/learning-words.js +1 -1
  104. package/dist/listen-first.d.ts +10 -0
  105. package/dist/listen-first.js +25 -1
  106. package/dist/llms.txt +2 -1
  107. package/dist/mcp-gateway.d.ts +2 -1
  108. package/dist/mcp-gateway.js +31 -15
  109. package/dist/mcp-probe.d.ts +18 -6
  110. package/dist/mcp-probe.js +41 -8
  111. package/dist/mcp-secret-writes.d.ts +8 -0
  112. package/dist/mcp-secret-writes.js +104 -4
  113. package/dist/mcp-servers-store.d.ts +11 -5
  114. package/dist/mcp-servers-store.js +46 -20
  115. package/dist/model-form.d.ts +2 -1
  116. package/dist/model-form.js +30 -16
  117. package/dist/model-gateway.d.ts +113 -0
  118. package/dist/model-gateway.js +433 -0
  119. package/dist/model.d.ts +5 -3
  120. package/dist/model.js +26 -18
  121. package/dist/monid.js +1 -1
  122. package/dist/native/binding.d.ts +4 -0
  123. package/dist/native/binding.js +9 -0
  124. package/dist/native/cli.d.ts +3 -2
  125. package/dist/native/cli.js +6 -5
  126. package/dist/openapi.d.ts +2 -0
  127. package/dist/openapi.js +356 -43
  128. package/dist/owner.d.ts +4 -2
  129. package/dist/owner.js +10 -4
  130. package/dist/page.d.ts +9 -0
  131. package/dist/page.js +10 -2
  132. package/dist/port-models.js +17 -10
  133. package/dist/provider.d.ts +3 -3
  134. package/dist/provider.js +12 -3
  135. package/dist/public-address.d.ts +28 -0
  136. package/dist/public-address.js +62 -0
  137. package/dist/run-launch.d.ts +1 -1
  138. package/dist/run-launch.js +1 -1
  139. package/dist/run-secrets.d.ts +3 -2
  140. package/dist/run-secrets.js +7 -4
  141. package/dist/run-trace.js +6 -3
  142. package/dist/runner/adapter-loop.d.ts +14 -8
  143. package/dist/runner/adapter-loop.js +58 -24
  144. package/dist/runner/adapter-run-spec.d.ts +15 -2
  145. package/dist/runner/adapter-run-spec.js +48 -10
  146. package/dist/runner/adapters/index.d.ts +4 -2
  147. package/dist/runner/adapters/index.js +6 -26
  148. package/dist/runner/adapters/pi.d.ts +5 -2
  149. package/dist/runner/adapters/pi.js +7 -4
  150. package/dist/runner/audit.d.ts +7 -0
  151. package/dist/runner/audit.js +15 -6
  152. package/dist/runner/claim-secrets.js +5 -1
  153. package/dist/runner/cli-run-spec.js +22 -10
  154. package/dist/runner/compare-end.d.ts +43 -0
  155. package/dist/runner/compare-end.js +95 -0
  156. package/dist/runner/computer-journal.d.ts +3 -0
  157. package/dist/runner/computer-journal.js +22 -2
  158. package/dist/runner/conformance/host-tools.d.ts +4 -0
  159. package/dist/runner/conformance/host-tools.js +14 -0
  160. package/dist/runner/harness-loops.d.ts +6 -1
  161. package/dist/runner/harness-loops.js +94 -54
  162. package/dist/runner/held.d.ts +5 -4
  163. package/dist/runner/journal-kinds.d.ts +4 -1
  164. package/dist/runner/journal-kinds.js +3 -0
  165. package/dist/runner/loop-contract.d.ts +10 -0
  166. package/dist/runner/main.d.ts +5 -5
  167. package/dist/runner/main.js +62 -11
  168. package/dist/runner/mcp-claim.js +40 -12
  169. package/dist/runner/meta-tools.js +4 -2
  170. package/dist/runner/metrics.d.ts +26 -0
  171. package/dist/runner/metrics.js +44 -1
  172. package/dist/runner/presence.d.ts +44 -0
  173. package/dist/runner/presence.js +96 -0
  174. package/dist/runner/promotion.d.ts +70 -7
  175. package/dist/runner/promotion.js +178 -28
  176. package/dist/runner/run-child-host.js +40 -10
  177. package/dist/runner/runner.d.ts +5 -0
  178. package/dist/runner/runner.js +8 -0
  179. package/dist/runner/sdk-loop.js +25 -1
  180. package/dist/runner/store-port.d.ts +3 -0
  181. package/dist/runner/store-secrets.js +19 -7
  182. package/dist/runner/workflow-first.d.ts +5 -2
  183. package/dist/runner/workflow-first.js +6 -3
  184. package/dist/runner/workflow-spec.js +3 -2
  185. package/dist/runs-over-store.d.ts +7 -2
  186. package/dist/runs-over-store.js +12 -4
  187. package/dist/sdk/check.d.ts +31 -0
  188. package/dist/sdk/check.js +58 -0
  189. package/dist/sdk/runs.d.ts +11 -3
  190. package/dist/sdk/runs.js +90 -15
  191. package/dist/sdk/schema.js +12 -4
  192. package/dist/secret-writes.d.ts +16 -3
  193. package/dist/secret-writes.js +28 -3
  194. package/dist/server-secrets-store.js +5 -0
  195. package/dist/server.d.ts +34 -2
  196. package/dist/server.js +437 -90
  197. package/dist/sign-ins-secrets.js +4 -1
  198. package/dist/skills/agentrun-serve/SKILL.md +11 -0
  199. package/dist/slack-url.d.ts +5 -0
  200. package/dist/slack-url.js +11 -0
  201. package/dist/slack.d.ts +107 -0
  202. package/dist/slack.js +292 -0
  203. package/dist/start-switches.d.ts +28 -0
  204. package/dist/start-switches.js +37 -0
  205. package/dist/stats.d.ts +1 -1
  206. package/dist/stats.js +2 -1
  207. package/dist/stop-signals.d.ts +11 -0
  208. package/dist/stop-signals.js +22 -0
  209. package/dist/store/agent-body.d.ts +1 -1
  210. package/dist/store/agent-body.js +2 -2
  211. package/dist/store/index.d.ts +3 -3
  212. package/dist/store/index.js +1 -1
  213. package/dist/store/postgres/migrations/0020_runners.sql +18 -0
  214. package/dist/store/postgres/store.d.ts +1 -1
  215. package/dist/store/postgres/store.js +4 -2
  216. package/dist/store/schema.d.ts +13 -5
  217. package/dist/store/schema.js +20 -11
  218. package/dist/store/seal.d.ts +16 -4
  219. package/dist/store/sqlite/store.d.ts +1 -1
  220. package/dist/store/sqlite/store.js +112 -28
  221. package/dist/store/store.d.ts +78 -24
  222. package/dist/store/store.js +11 -0
  223. package/dist/store-reads/analytics.js +3 -2
  224. package/dist/store-reads/cap.d.ts +7 -0
  225. package/dist/store-reads/cap.js +11 -1
  226. package/dist/store-reads/journal.js +27 -1
  227. package/dist/store-reads/learning.d.ts +23 -2
  228. package/dist/store-reads/learning.js +29 -8
  229. package/dist/store-reads/runs.d.ts +9 -0
  230. package/dist/store-reads/runs.js +19 -6
  231. package/dist/store-reads/stats.d.ts +4 -1
  232. package/dist/store-reads/stats.js +15 -6
  233. package/dist/store-view.d.ts +125 -14
  234. package/dist/store-view.js +156 -21
  235. package/dist/telemetry.d.ts +7 -7
  236. package/dist/telemetry.js +38 -15
  237. package/dist/template-eval.js +5 -2
  238. package/dist/template-github-permissions.d.ts +5 -1
  239. package/dist/template-github-permissions.js +7 -3
  240. package/dist/timeline/index.d.ts +1 -1
  241. package/dist/timeline/index.js +1 -1
  242. package/dist/timeline/timeline.d.ts +8 -0
  243. package/dist/timeline/timeline.js +30 -0
  244. package/dist/tool-gate.d.ts +8 -4
  245. package/dist/tool-gate.js +6 -7
  246. package/dist/tool-keys-store.js +2 -2
  247. package/dist/tool-keys.js +2 -1
  248. package/dist/tool-plane.d.ts +4 -0
  249. package/dist/tool-plane.js +12 -12
  250. package/dist/trigger-adapter.d.ts +3 -4
  251. package/dist/trigger-adapter.js +2 -2
  252. package/dist/trigger-composio.js +3 -3
  253. package/dist/trigger-email.js +0 -2
  254. package/dist/trigger-feed.js +0 -2
  255. package/dist/trigger-schedule.js +3 -0
  256. package/dist/trigger-secrets-shown.d.ts +6 -3
  257. package/dist/trigger-secrets-shown.js +22 -13
  258. package/dist/trigger-targets.d.ts +12 -3
  259. package/dist/trigger-targets.js +90 -10
  260. package/dist/triggers.d.ts +2 -2
  261. package/dist/validate.js +5 -1
  262. package/dist/viewer-credential.d.ts +25 -0
  263. package/dist/viewer-credential.js +51 -0
  264. package/dist/webhooks.d.ts +82 -8
  265. package/dist/webhooks.js +128 -45
  266. package/dist/wires.d.ts +6 -1
  267. package/dist/wires.js +5 -0
  268. package/dist/workspace/attach.d.ts +3 -2
  269. package/dist/workspace/attach.js +2 -1
  270. package/dist/workspace/attached-computers.d.ts +6 -8
  271. package/dist/workspace/attached-computers.js +27 -24
  272. package/dist/workspace/computer-deps.d.ts +2 -3
  273. package/dist/workspace/computer-deps.js +3 -6
  274. package/dist/workspace/computer-for-claim.js +72 -96
  275. package/dist/workspace/computer-kept.d.ts +0 -7
  276. package/dist/workspace/computer-kept.js +0 -17
  277. package/dist/workspace/resolve-computer.d.ts +23 -14
  278. package/dist/workspace/resolve-computer.js +66 -61
  279. package/dist/workspace/synced-folder.d.ts +20 -15
  280. package/dist/workspace/synced-folder.js +33 -43
  281. package/launcher/agentrun-serve +4 -1
  282. package/package.json +18 -10
  283. package/skills/agentrun-serve/SKILL.md +11 -0
  284. package/templates/README.md +1 -1
  285. package/templates/code-review/agent.md +2 -3
  286. package/templates/code-review/evals/mentions-defused/case.yaml +0 -1
  287. package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -27
  288. package/templates/code-review/evals/other-repo/case.yaml +0 -1
  289. package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +0 -18
  290. package/templates/code-review/evals/other-repo/graders/no-other-repo.md +1 -1
  291. package/dist/console/assets/index-C2MYaUBa.css +0 -1
  292. package/dist/console/assets/index-CZZeCReB.js +0 -701
package/dist/owner.d.ts CHANGED
@@ -48,14 +48,16 @@ export declare class Owner {
48
48
  readonly signIns: SignInLimit;
49
49
  private setupCode;
50
50
  private base;
51
+ private elsewhere;
51
52
  /** Taken while a first password is being set, so a second at the same moment is refused. */
52
53
  private settingUp;
53
54
  /** `openSetup`: no setup code; the first visit sets the password (no public address). `say` prints a setup code. */
54
55
  constructor(dir: string, openSetup: boolean, say?: (line: string) => void, addresses?: number);
55
56
  private read;
56
57
  hasPassword(): boolean;
57
- /** The address the setup link is printed with, fixed once the server listens. */
58
- attach(baseUrl: string): void;
58
+ /** The address the setup link is printed with, fixed once the server listens; `elsewhere`, the addresses another
59
+ * machine reaches it at (a server listening on every address with no public one), each printed with the code too. */
60
+ attach(baseUrl: string, elsewhere?: readonly string[]): void;
59
61
  /** The setup page's link: with its code when setup needs one, a new code printed (never answered) when none is good. */
60
62
  setupLink(): string;
61
63
  /** A setup code to use, for whoever asks with no credential: the one that stands is kept (never voided here), and a
package/dist/owner.js CHANGED
@@ -122,6 +122,7 @@ export class Owner {
122
122
  signIns;
123
123
  setupCode = null;
124
124
  base = "";
125
+ elsewhere = [];
125
126
  /** Taken while a first password is being set, so a second at the same moment is refused. */
126
127
  settingUp = false;
127
128
  /** `openSetup`: no setup code; the first visit sets the password (no public address). `say` prints a setup code. */
@@ -159,19 +160,24 @@ export class Owner {
159
160
  hasPassword() {
160
161
  return this.read().password !== undefined;
161
162
  }
162
- /** The address the setup link is printed with, fixed once the server listens. */
163
- attach(baseUrl) {
163
+ /** The address the setup link is printed with, fixed once the server listens; `elsewhere`, the addresses another
164
+ * machine reaches it at (a server listening on every address with no public one), each printed with the code too. */
165
+ attach(baseUrl, elsewhere = []) {
164
166
  this.base = baseUrl;
167
+ this.elsewhere = elsewhere;
165
168
  }
166
169
  /** The setup page's link: with its code when setup needs one, a new code printed (never answered) when none is good. */
167
170
  setupLink() {
168
171
  if (this.openSetup)
169
172
  return `${this.base}/setup`;
173
+ const linkAt = (base) => `${base}/setup#code=${this.setupCode.code}`;
170
174
  if (!this.setupCode || Date.now() > this.setupCode.until) {
171
175
  this.setupCode = { code: randomBytes(16).toString("base64url"), until: Date.now() + SETUP_TTL_MS, tries: 0 };
172
- this.say(`Set up this server: ${this.base}/setup#code=${this.setupCode.code} (or paste AGENTRUN_TOKEN)`);
176
+ this.say(`Set up this server: ${linkAt(this.base)} (or paste AGENTRUN_TOKEN)`);
177
+ for (const base of this.elsewhere)
178
+ this.say(`From another machine: ${linkAt(base)}`);
173
179
  }
174
- return `${this.base}/setup#code=${this.setupCode.code}`;
180
+ return linkAt(this.base);
175
181
  }
176
182
  /** A setup code to use, for whoever asks with no credential: the one that stands is kept (never voided here), and a
177
183
  * new one is printed only when none is good (expired, or spent). Answers which, and when the code now good runs
package/dist/page.d.ts CHANGED
@@ -20,6 +20,7 @@ export declare class ConsoleSessions {
20
20
  /** Whether `value` is a session this server made. */
21
21
  holds(value: string): boolean;
22
22
  }
23
+ export declare const cookiesOf: (req: IncomingMessage, name: string) => string[];
23
24
  export declare const overHttps: (req: IncomingMessage) => boolean;
24
25
  export declare const ownOrigin: (req: IncomingMessage) => string;
25
26
  export declare const isJson: (req: IncomingMessage) => boolean;
@@ -33,6 +34,14 @@ export declare const heldSessions: (req: IncomingMessage) => string[];
33
34
  export declare const signedIn: (req: IncomingMessage, owner: Owner) => boolean;
34
35
  /** A browser's answer for a Host the server refuses (host-check.ts): 403, a fixed page under the console's CSP. */
35
36
  export declare const sendHostRefused: (req: IncomingMessage, res: ServerResponse) => void;
37
+ /** Whether `raw` is the console's own page, or one of the addresses that send a browser to it (MOVED). */
38
+ export declare const consoleEntry: (raw: string) => boolean;
39
+ /** A browser's answer for the console under the server's earlier public address (public-address.ts): 308 to the new one,
40
+ * `to`, whose console takes the link's #fragment along (a browser keeps it across a redirect). no-store, so no browser
41
+ * keeps the redirect: the address may change back. */
42
+ export declare const sendMoved: (res: ServerResponse, to: string) => undefined;
43
+ /** A browser's answer for any other page under the earlier public address: 403, a fixed page that links to `to`. */
44
+ export declare const sendMovedPage: (req: IncomingMessage, res: ServerResponse, to: string) => void;
36
45
  /** `takesBytes`: whether a request of `method` to `path` (under /v2) goes to a route whose body is bytes (server.ts). */
37
46
  /** `publicUrl`: the address people open (AGENTRUN_PUBLIC_URL); an https one adds HSTS to every page answer (hstsHeaders). */
38
47
  /** `sessions`: the console's sessions on a server with no accounts (ConsoleSessions); with `owner`, none. */
package/dist/page.js CHANGED
@@ -9,7 +9,7 @@ import { readFile, realpath, stat } from "node:fs/promises";
9
9
  import { extname, join, sep } from "node:path";
10
10
  import { fileURLToPath } from "node:url";
11
11
  import { ApiError } from "./errors.js";
12
- import { hostRefusedPage } from "./host-check.js";
12
+ import { hostRefusedPage, movedPage } from "./host-check.js";
13
13
  // img-src names Google's favicon service and the four hosts it redirects to: the console's Keys page shows a provider's
14
14
  // icon from it (apps/console/src/components/ProviderIcon.tsx), sent with no referrer. Everything else is this origin's.
15
15
  const CSP = "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data: https://www.google.com https://t0.gstatic.com https://t1.gstatic.com https://t2.gstatic.com https://t3.gstatic.com; base-uri 'none'; form-action https://github.com; frame-ancestors 'none'";
@@ -67,7 +67,7 @@ export class ConsoleSessions {
67
67
  }
68
68
  /** One name per port: cookies are kept per host, not per port, and another server on this machine has another token. */
69
69
  const cookieName = (req) => `agentrun-${req.socket.localPort}`;
70
- const cookiesOf = (req, name) => String(req.headers.cookie ?? "").split(";").map((part) => part.trim()).filter((part) => part.startsWith(`${name}=`)).map((part) => part.slice(name.length + 1));
70
+ export const cookiesOf = (req, name) => String(req.headers.cookie ?? "").split(";").map((part) => part.trim()).filter((part) => part.startsWith(`${name}=`)).map((part) => part.slice(name.length + 1));
71
71
  export const overHttps = (req) => String(req.headers["x-forwarded-proto"] ?? "").split(",")[0].trim().toLowerCase() === "https";
72
72
  export const ownOrigin = (req) => `${overHttps(req) ? "https" : "http"}://${String(req.headers.host ?? "").toLowerCase()}`;
73
73
  export const isJson = (req) => String(req.headers["content-type"] ?? "").split(";")[0].trim().toLowerCase() === "application/json";
@@ -86,6 +86,14 @@ function send(req, res, status, type, body, headers = {}) {
86
86
  }
87
87
  /** A browser's answer for a Host the server refuses (host-check.ts): 403, a fixed page under the console's CSP. */
88
88
  export const sendHostRefused = (req, res) => send(req, res, 403, HTML, hostRefusedPage(req.socket.localPort ?? 0));
89
+ /** Whether `raw` is the console's own page, or one of the addresses that send a browser to it (MOVED). */
90
+ export const consoleEntry = (raw) => raw === "/" || MOVED.has(raw);
91
+ /** A browser's answer for the console under the server's earlier public address (public-address.ts): 308 to the new one,
92
+ * `to`, whose console takes the link's #fragment along (a browser keeps it across a redirect). no-store, so no browser
93
+ * keeps the redirect: the address may change back. */
94
+ export const sendMoved = (res, to) => (res.writeHead(308, { ...SECURITY, location: `${to}/`, "content-length": 0 }), void res.end());
95
+ /** A browser's answer for any other page under the earlier public address: 403, a fixed page that links to `to`. */
96
+ export const sendMovedPage = (req, res, to) => send(req, res, 403, HTML, movedPage(to));
89
97
  const refuse = (req, res, error) => send(req, res, error.status, "application/json", JSON.stringify(error.body(String(res.getHeader("x-request-id") ?? ""))), error.headers);
90
98
  const redirect = (res, location, headers = {}) => (res.writeHead(303, { ...SECURITY, location, "content-length": 0, ...headers }), void res.end());
91
99
  /** A file of the console: a known type inside `dir`, read through no link that leaves it. Vite's hashed assets are cached
@@ -1,6 +1,7 @@
1
1
  import { anthropicMessagesApi } from "@earendil-works/pi-ai/api/anthropic-messages.lazy";
2
2
  import { openAIResponsesApi } from "@earendil-works/pi-ai/api/openai-responses.lazy";
3
3
  import { createProvider } from "@earendil-works/pi-ai/models";
4
+ import { CONVERSATION_HEADER, conversationLabel } from "@parcha/agentrun-kernel/host";
4
5
  import { attachingImages } from "./attach-images.js";
5
6
  /** The provider id the port's one model is listed under. */
6
7
  export const PORT_PROVIDER = "agentrun-session";
@@ -51,18 +52,24 @@ export function sessionProvider(api, proxy, model, options) {
51
52
  api: sessionApi(api, options.like),
52
53
  });
53
54
  }
54
- /** A translated Chat Completions session carries its cache identity in Messages' existing metadata field: the proxy
55
- * preserves it without forwarding extra headers. The translation uses it only for provider cache affinity. */
55
+ /** The session's client of `api`. Each request names its conversation to the proxy (CONVERSATION_HEADER: pi's own id for
56
+ * it, the request's `sessionId`, one per conversation), so the host knows which of several conversations asking at once
57
+ * a booking is; the proxy sends that header no further. A translated Chat Completions session also carries its cache
58
+ * identity in Messages' existing metadata field: the proxy preserves it without forwarding extra headers. The
59
+ * translation uses it only for provider cache affinity. */
56
60
  function sessionApi(api, like) {
57
61
  const own = attachingImages(api === "anthropic-messages" ? anthropicMessagesApi() : openAIResponsesApi());
58
- if (api !== "anthropic-messages" || !like?.translatedChatCompletions)
59
- return own;
60
- const withSession = (options) => ({
61
- ...options,
62
- // The upstream can have accepted a paid request before this hop fails. Never replay it implicitly.
63
- maxRetries: 0,
64
- ...(options?.cacheRetention === "none" ? { metadata: { ...options.metadata, user_id: "" } } : options?.sessionId ? { metadata: { ...options.metadata, user_id: options.sessionId } } : {}),
65
- });
62
+ const translated = api === "anthropic-messages" && like?.translatedChatCompletions === true;
63
+ const withSession = (options) => {
64
+ const conversation = conversationLabel(options?.sessionId);
65
+ return {
66
+ ...options,
67
+ ...(conversation === undefined ? {} : { headers: { ...options?.headers, [CONVERSATION_HEADER]: conversation } }),
68
+ // The upstream can have accepted a paid request before this hop fails. Never replay it implicitly.
69
+ ...(translated ? { maxRetries: 0 } : {}),
70
+ ...(!translated ? {} : options?.cacheRetention === "none" ? { metadata: { ...options.metadata, user_id: "" } } : options?.sessionId ? { metadata: { ...options.metadata, user_id: options.sessionId } } : {}),
71
+ };
72
+ };
66
73
  return {
67
74
  ...own,
68
75
  stream: (model, context, options) => own.stream(model, context, withSession(options)),
@@ -1,8 +1,8 @@
1
- import type { Wire } from "@parcha/agentrun-kernel";
1
+ import type { HarnessWire as Wire } from "@parcha/agentrun-kernel";
2
2
  import type { ClaudeAgentLogin } from "@parcha/agentrun-harness-claude";
3
3
  import { type ModelNeeds, type ModelRef } from "./model.js";
4
- import { WIRES } from "./wires.js";
5
- export { WIRES };
4
+ import { modelWire, WIRES, wireOf } from "./wires.js";
5
+ export { modelWire, WIRES, wireOf };
6
6
  /** What fixes a harness that is not on this machine as its adapter needs it: `install`, its package or binary is missing;
7
7
  * `pins`, what is installed is not the pinned build. */
8
8
  export type InstallFix = "install" | "pins";
package/dist/provider.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { CLAUDE_LOGIN_PROVIDER, onClaudeLogin, claudeLoginOf } from "./claude-login.js";
2
2
  import { chooseModel, FAUX_ENV, hostModel, MODEL_PROVIDER } from "./model.js";
3
- import { WIRES } from "./wires.js";
3
+ import { modelWire, WIRES, wireOf } from "./wires.js";
4
4
  import { modelFormWhy } from "./model-form.js";
5
5
  import { EXPIRED, PLAN_ORIGIN, PLAN_PROVIDER, planOf, SIGNED_OUT } from "./chatgpt-plan.js";
6
6
  // Each wire's own settings live in a leaf module (wires.ts), which the harness table reads as it loads.
7
- export { WIRES };
7
+ export { modelWire, WIRES, wireOf };
8
8
  /** Why this server cannot run a harness here, in words a person can act on; `fix`, when installing is the fix; `keys`,
9
9
  * when a model key is all it lacks: the keys, any one of which, set, lets it run (a key row names it: tool-keys.ts). */
10
10
  export class HarnessUnavailable extends Error {
@@ -89,13 +89,16 @@ function onServeGateway(env, base) {
89
89
  * endpoint the host names never gets the OpenRouter key.
90
90
  */
91
91
  export function openRouterOnly(wire, env) {
92
+ // A harness on its own plan (Cursor's) reaches nothing through OpenRouter, nor through any route of ours.
93
+ if (!modelWire(wire))
94
+ return false;
92
95
  return Boolean(env.OPENROUTER_API_KEY) && !env[WIRES[wire].base] && !env[WIRES[wire].key];
93
96
  }
94
97
  /** Whether a run on `wire` of `model` (as named, `provider/model-id`; none, the host's) sends through OpenRouter: a model
95
98
  * named on it (`openrouter/<vendor>/...`), or the wire's vendor reached only through it (openRouterOnly). Serve's gateway
96
99
  * comes first on the wire it serves. */
97
100
  export function viaOpenRouter(wire, env, model) {
98
- if (WIRES[wire].gateway && env.AGENT_MODEL_BASE_URL)
101
+ if (!modelWire(wire) || (WIRES[wire].gateway && env.AGENT_MODEL_BASE_URL))
99
102
  return false;
100
103
  return Boolean(model?.startsWith(`openrouter/${WIRES[wire].vendor}/`)) || openRouterOnly(wire, env);
101
104
  }
@@ -119,6 +122,9 @@ function openRouterKey(env, who, named) {
119
122
  const gatewayProvider = (env, model) => ({ origin: modelGatewayBase(env.AGENT_MODEL_BASE_URL), credential: () => env.AGENT_MODEL_API_KEY || "none", auth: "bearer", modelId: model.modelId, priceModel: model });
120
123
  export function providerFor(wire, env, model, who) {
121
124
  const named = `${model.provider}/${model.modelId}`;
125
+ // A harness on its own plan (Cursor's) calls its vendor itself, on its owner's key: no route of ours is its.
126
+ if (!modelWire(wire))
127
+ throw new HarnessUnavailable(`${who} runs its model on its own plan, never through a model route of AgentRun's; ${named} is not one to proxy.`);
122
128
  if (wire === "anthropic-messages") {
123
129
  // A model of serve's gateway that the gateway takes on Messages (a Claude model, model.ts gatewayWire): the gateway's
124
130
  // own route, as on Responses. No harness of this wire chooses one (claude-agent's model is never the gateway's).
@@ -187,6 +193,9 @@ export function priceModelFor(wire, env, model, who) {
187
193
  * (it prices the run): OpenRouter's key is the one providerFor sends. A save, a run and capabilities all ask this.
188
194
  */
189
195
  export async function modelOn(wire, env, ref, harness) {
196
+ // A harness on its own plan chooses its model itself (its table entry's model): none of the host's is its.
197
+ if (!modelWire(wire))
198
+ return { why: `${harness} runs a model of its own plan, which its own entry chooses.`, host: false };
190
199
  const { vendor, label } = WIRES[wire];
191
200
  const named = ref ?? hostModel(env, "default", harness);
192
201
  if (wire === "openai-responses") {
@@ -0,0 +1,28 @@
1
+ /** The file, in the data folder: `{ "url": <the address, or null for none>, "earlier": <the one before it, or null> }`. */
2
+ export declare const PUBLIC_ADDRESS_FILE = ".public-url";
3
+ /** What a start finds: `changed` when the folder remembered another address (none counts), and `earlier`, the address the
4
+ * server had before its current one, kept across starts until the next change. `keep` remembers the current address; a
5
+ * start calls it only once it serves, so a start that fails leaves the folder's address, and its earlier one, as they were. */
6
+ export type PublicAddress = {
7
+ changed?: {
8
+ from: string | null;
9
+ to: string | null;
10
+ };
11
+ earlier: string | null;
12
+ keep: (warn: (said: string) => void) => void;
13
+ };
14
+ /** Reads the address `data` remembers and compares it with `publicUrl`. A folder that remembers none (a first start, or a
15
+ * file that is not one) has no change to report. `keep` writes it as the folder's other files are written (whole and
16
+ * synced, mode 600), and only when it differs; a write that fails is told to `warn` and stops nothing: the next start
17
+ * compares again. */
18
+ export declare function readPublicAddress(data: string, publicUrl: string | undefined): PublicAddress;
19
+ /** The log line's words for a change. */
20
+ export declare const publicAddressChanged = "the public address (AGENTRUN_PUBLIC_URL) changed: the owner signs in again at the new address, and links in earlier webhook messages point to the old one";
21
+ /** Where a request under the earlier address is sent on to: `from`, the earlier address's name, and `to`, the address
22
+ * people open now (`publicUrl`, parsed, so a name in any script is written as a header carries it, without a trailing
23
+ * slash). Set only when the server has a public address now and the earlier one's name is none it answers to (`served`:
24
+ * its own names, its --allow-host names and the new address's). */
25
+ export declare function movedAddress(earlier: string | null, publicUrl: string | undefined, served: ReadonlySet<string>): {
26
+ from: string;
27
+ to: string;
28
+ } | undefined;
@@ -0,0 +1,62 @@
1
+ // The public address this server last served at (AGENTRUN_PUBLIC_URL), kept in its data folder. A change of it signs the
2
+ // owner out (the session cookie is kept per host) and leaves the links in earlier webhook messages on the old address, so a
3
+ // start that finds it changed says so in its log, and the server sends a browser that still opens the old address on to
4
+ // the new one (server.ts, host-check.ts).
5
+ import { readFileSync } from "node:fs";
6
+ import { join } from "node:path";
7
+ import { hostName } from "./host-check.js";
8
+ import { writeDurableSync } from "./server-fs.js";
9
+ /** The file, in the data folder: `{ "url": <the address, or null for none>, "earlier": <the one before it, or null> }`. */
10
+ export const PUBLIC_ADDRESS_FILE = ".public-url";
11
+ /** An address as the CLI takes it: parsed, without a trailing slash. None, null. */
12
+ const normal = (url) => (url === undefined ? null : URL.canParse(url) ? new URL(url).href.replace(/\/+$/, "") : url);
13
+ const keptOf = (text) => {
14
+ try {
15
+ const kept = JSON.parse(text);
16
+ const field = (value) => (typeof value === "string" ? value : null);
17
+ return kept && typeof kept === "object" && "url" in kept ? { url: field(kept.url), earlier: field(kept.earlier) } : undefined;
18
+ }
19
+ catch {
20
+ return undefined;
21
+ }
22
+ };
23
+ /** Reads the address `data` remembers and compares it with `publicUrl`. A folder that remembers none (a first start, or a
24
+ * file that is not one) has no change to report. `keep` writes it as the folder's other files are written (whole and
25
+ * synced, mode 600), and only when it differs; a write that fails is told to `warn` and stops nothing: the next start
26
+ * compares again. */
27
+ export function readPublicAddress(data, publicUrl) {
28
+ const path = join(data, PUBLIC_ADDRESS_FILE);
29
+ const url = normal(publicUrl);
30
+ let text;
31
+ try {
32
+ text = readFileSync(path, "utf8");
33
+ }
34
+ catch { }
35
+ const before = text === undefined ? undefined : keptOf(text);
36
+ const changed = before !== undefined && before.url !== url;
37
+ const now = { url, earlier: changed ? (before.url ?? before.earlier) : (before?.earlier ?? null) };
38
+ const written = JSON.stringify(now);
39
+ const keep = (warn) => {
40
+ if (written === text)
41
+ return;
42
+ try {
43
+ writeDurableSync(path, written);
44
+ }
45
+ catch (error) {
46
+ warn(`the public address could not be remembered in ${PUBLIC_ADDRESS_FILE}: ${error.message}`);
47
+ }
48
+ };
49
+ return { ...(changed ? { changed: { from: before.url, to: url } } : {}), earlier: now.earlier, keep };
50
+ }
51
+ /** The log line's words for a change. */
52
+ export const publicAddressChanged = "the public address (AGENTRUN_PUBLIC_URL) changed: the owner signs in again at the new address, and links in earlier webhook messages point to the old one";
53
+ /** Where a request under the earlier address is sent on to: `from`, the earlier address's name, and `to`, the address
54
+ * people open now (`publicUrl`, parsed, so a name in any script is written as a header carries it, without a trailing
55
+ * slash). Set only when the server has a public address now and the earlier one's name is none it answers to (`served`:
56
+ * its own names, its --allow-host names and the new address's). */
57
+ export function movedAddress(earlier, publicUrl, served) {
58
+ if (earlier === null || publicUrl === undefined || !URL.canParse(earlier) || !URL.canParse(publicUrl))
59
+ return undefined;
60
+ const from = hostName(new URL(earlier).host);
61
+ return from !== undefined && !served.has(from) ? { from, to: normal(publicUrl) } : undefined;
62
+ }
@@ -13,7 +13,7 @@ import type { Place } from "./workspace/place.js";
13
13
  * the old path recomputed; here they are pinned at start, and optional (a built-in run may name none). */
14
14
  export interface RunLaunch {
15
15
  readonly sdk?: {
16
- runtime: "claude-agent-sdk" | "codex-sdk";
16
+ runtime: "claude-agent-sdk" | "codex-sdk" | "eve";
17
17
  instructions: string;
18
18
  model?: string;
19
19
  workflow_tools?: SdkWorkflowTool[];
@@ -104,7 +104,7 @@ export function readLaunchBody(stored) {
104
104
  const archilDisk = readDisk(stored.archil_disk);
105
105
  return {
106
106
  input: stored.input,
107
- ...(isObject(stored.sdk) && (stored.sdk.runtime === "claude-agent-sdk" || stored.sdk.runtime === "codex-sdk") && typeof stored.sdk.instructions === "string" ? { sdk: stored.sdk } : {}),
107
+ ...(isObject(stored.sdk) && (stored.sdk.runtime === "claude-agent-sdk" || stored.sdk.runtime === "codex-sdk" || stored.sdk.runtime === "eve") && typeof stored.sdk.instructions === "string" ? { sdk: stored.sdk } : {}),
108
108
  ...(nativeOf(stored) ? { native: nativeOf(stored) } : {}),
109
109
  title: typeof stored.title === "string" ? stored.title : "",
110
110
  ...(typeof stored.repo === "string" ? { repo: stored.repo } : {}),
@@ -25,8 +25,9 @@ export declare function needsOf(revision: Revision): Promise<RunNeeds>;
25
25
  * `rows` (TOOL_KEYS) that unlocks none of the tools the run binds; and but each model key its model does not need, from
26
26
  * the host's model settings and the keys in `env`: a pi run's, its models' providers' keys or the gateway's (model.ts'
27
27
  * modelKeys: its own model, or the host's of each tier it runs); a run on an adapter's, the one key its wire's route
28
- * sends for the revision's model (adapters.ts' harnessModelKeys). Read at each claim, so a key saved with no restart
29
- * counts at the next. */
28
+ * sends for the revision's model (adapters.ts' harnessModelKeys); and but each built-in harness's own key
29
+ * (HarnessEntry.ownKeys: Cursor's CURSOR_API_KEY) on a run of any other harness. Read at each claim, so a key saved with no restart counts at
30
+ * the next. */
30
31
  export declare function keysFor(needs: RunNeeds, env: NodeJS.ProcessEnv, rows?: readonly KeyRow[]): string[];
31
32
  /** The secrets a run of `revision` is handed with the keys `env` holds (needsOf, then keysFor). */
32
33
  export declare function secretsFor(revision: Revision, rows?: readonly KeyRow[], env?: NodeJS.ProcessEnv): Promise<string[]>;
@@ -3,7 +3,7 @@ import { COMPUTER_KEY_NAMES } from "./computer-keys.js";
3
3
  import { BOX_KEYS } from "./place-offers.js";
4
4
  import { providersNamed } from "./decisions.js";
5
5
  import { harnessOfBody } from "./harness.js";
6
- import { harnessOf } from "./harness-table.js";
6
+ import { BUILTIN_OWN_KEYS, builtinOwns, harnessOf } from "./harness-table.js";
7
7
  import { GATEWAY_KEY_ENV, llmTiers, modelKeys, nodeTiers, PROVIDER_KEYS, workflowNodes } from "./model.js";
8
8
  import { DECISION_KEYS, SECRET_NAMES } from "./secrets.js";
9
9
  import { TOOL_FIELDS, TOOL_KEYS, unlocksTool } from "./tool-keys.js";
@@ -45,14 +45,17 @@ export async function needsOf(revision) {
45
45
  * `rows` (TOOL_KEYS) that unlocks none of the tools the run binds; and but each model key its model does not need, from
46
46
  * the host's model settings and the keys in `env`: a pi run's, its models' providers' keys or the gateway's (model.ts'
47
47
  * modelKeys: its own model, or the host's of each tier it runs); a run on an adapter's, the one key its wire's route
48
- * sends for the revision's model (adapters.ts' harnessModelKeys). Read at each claim, so a key saved with no restart
49
- * counts at the next. */
48
+ * sends for the revision's model (adapters.ts' harnessModelKeys); and but each built-in harness's own key
49
+ * (HarnessEntry.ownKeys: Cursor's CURSOR_API_KEY) on a run of any other harness. Read at each claim, so a key saved with no restart counts at
50
+ * the next. */
50
51
  export function keysFor(needs, env, rows = TOOL_KEYS) {
51
52
  const unlocked = new Set(rows.filter((row) => row.unlocks.some((unlock) => needs.tools.some((name) => unlocksTool(unlock, name)))).flatMap((row) => row.fields));
52
53
  const scoped = scopedOf(rows);
53
54
  const entry = harnessOf(env, needs.harness);
54
55
  const model = new Set(!entry || entry.facts ? harnessModelKeys(needs.harness, env, needs.model) : needs.tiers ? modelKeys(env, undefined, needs.tiers) : modelKeys(env, needs.model));
55
- return RUN_SECRETS.filter((name) => (!scoped.includes(name) || unlocked.has(name)) && (!MODEL_KEYS.includes(name) || model.has(name)));
56
+ // A built-in's own key (BUILTIN_OWN_KEYS) goes to the built-in that owns it alone, by the pair (builtinOwns): an entry of
57
+ // any other id that names it in ownKeys (a module's, a test's) is never handed it, nor moves any key.
58
+ return RUN_SECRETS.filter((name) => (!scoped.includes(name) || unlocked.has(name)) && (!MODEL_KEYS.includes(name) || model.has(name)) && (!BUILTIN_OWN_KEYS.includes(name) || builtinOwns(needs.harness, name)));
56
59
  }
57
60
  /** The secrets a run of `revision` is handed with the keys `env` holds (needsOf, then keysFor). */
58
61
  export async function secretsFor(revision, rows = TOOL_KEYS, env = process.env) {
package/dist/run-trace.js CHANGED
@@ -14,6 +14,9 @@ const finite = (value) => (typeof value === "number" && Number.isFinite(value) ?
14
14
  const count = (value) => (typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined);
15
15
  /** A time as the rows write theirs; undefined for one no Date holds. */
16
16
  const iso = (ms) => (Math.abs(ms) <= 8.64e15 ? new Date(ms).toISOString() : undefined);
17
+ /** An amount with a sum's floating-point noise off (0.1 + 0.2 is 0.3, not 0.30000000000000004), to a millionth of a
18
+ * millionth of a dollar: far below any price, so no cost is rounded away. Every span's cost is written through it. */
19
+ const noiseOff = (usd) => Math.round(usd * 1e12) / 1e12;
17
20
  const STOP_REASONS = new Set(["stop", "length", "toolUse", "error", "aborted", "deferred", "pending"]);
18
21
  /** An answer's tokens, by the usage row's rule (timeline tokensOf): all four known, and some input unless it failed. */
19
22
  function tokensOf(usage, failed) {
@@ -104,7 +107,7 @@ export function traceSpans(rows, entries, options = {}) {
104
107
  stop_reason: typeof message.stopReason === "string" && STOP_REASONS.has(message.stopReason) ? message.stopReason : null,
105
108
  // A request cut before its end reported no final usage and no cost (the usage row counts it unknown).
106
109
  tokens: aborted ? null : tokensOf(message.usage, failed),
107
- usd: booked || aborted || total === undefined || total < 0 ? null : total, decision: false,
110
+ usd: booked || aborted || total === undefined || total < 0 ? null : noiseOff(total), decision: false,
108
111
  charged: false, not_metered: false, tool_use_id: null, input_preview: null, result_preview: null, result_size_bytes: null,
109
112
  });
110
113
  }
@@ -128,7 +131,7 @@ export function traceSpans(rows, entries, options = {}) {
128
131
  stop_reason: null,
129
132
  // A receipt keeps its input whole, with no split by cache.
130
133
  tokens: input !== undefined && output !== undefined ? { input, cache_read: 0, cache_write: 0, output } : null,
131
- usd: cost !== undefined && cost >= 0 ? cost : null, decision: true,
134
+ usd: cost !== undefined && cost >= 0 ? noiseOff(cost) : null, decision: true,
132
135
  charged: false, not_metered: false, tool_use_id: null, input_preview: null, result_preview: null, result_size_bytes: null,
133
136
  });
134
137
  });
@@ -219,7 +222,7 @@ export function traceSpans(rows, entries, options = {}) {
219
222
  at, id: nth === 0 ? `t:${key}` : `t:${key}#${nth + 1}`, kind: "tool", parent_id: parent, name: use.tool_name ?? "tool", agent_label: use.agent_label ?? null,
220
223
  started_at: iso(at) ?? use.timestamp, ended_at: over ? iso(done) ?? null : null, status,
221
224
  stop_reason: null, tokens: null,
222
- usd: charge?.charged ? (charge.unknown ? null : Math.round(charge.known * 1e12) / 1e12) : null,
225
+ usd: charge?.charged ? (charge.unknown ? null : noiseOff(charge.known)) : null,
223
226
  decision: false, charged: charge?.charged ?? false, not_metered: charge?.notMetered ?? false,
224
227
  tool_use_id: use.tool_use_id, input_preview: use.tool_input_preview ?? null,
225
228
  // A call that never ran has no result of its own: what its rows say of it is the Timeline's words, not its output.
@@ -1,5 +1,5 @@
1
1
  import { type ConversationId, type ConversationRetryPolicy, type ConversationStreamOptions, Harness, type Tx } from "@earendil-works/pi-durable";
2
- import { type AgentAdapter, type Refusal, type SessionRecord, type SessionSpec } from "@parcha/agentrun-kernel";
2
+ import { type AdapterFacts, type AgentAdapter, type Refusal, type SessionRecord, type SessionSpec } from "@parcha/agentrun-kernel";
3
3
  import type { KernelHooks, ToolCall } from "./conformance/subject.js";
4
4
  import { type BudgetData, type EndData, type ToolCalls } from "./journal-kinds.js";
5
5
  import { type MessageOrigin } from "../timeline/index.js";
@@ -79,6 +79,9 @@ export type SpecGate = ((call: ToolCall, options?: {
79
79
  /** What one claimed run's adapter loop runs. */
80
80
  export interface AdapterRunSpec {
81
81
  readonly adapter: AgentAdapter;
82
+ /** The adapter's facts on the owner's table (harness-table.ts factsOf: a module's harness's too); undefined for one with
83
+ * none. Always given: what codemode and tool search read, so a caller names them. */
84
+ readonly facts: AdapterFacts | undefined;
82
85
  readonly session: SessionSpec;
83
86
  /** The person's first message, sent once, on the run's first claim. */
84
87
  readonly input: string;
@@ -351,13 +354,16 @@ export declare function pendingPauseOf(entries: readonly {
351
354
  }[]): Refusal | undefined;
352
355
  /** The turns a session's records booked (its runner.turn records), in order. */
353
356
  export declare function turnsOf(records: readonly SessionRecord[]): number[];
354
- /** What the request that just answered cost, from the session's records, and the bookings that answer gives (`turns`):
355
- * every runner.turn record no answer was given yet (`given`). A side request's booking (sideTurnsOf) is given and never
356
- * read: it is no answer's, and it stays on the run's ledger and cap. The answer reads the session's own requests
357
- * booked since the answer before it, their booked figures summed (pi asks one at a time, so that is its own; were a
358
- * retry ever booked without an answer of its own, it would be summed in), null when any is unknown; undefined when none
359
- * is booked. Each booking is given once, so one unknown figure stays that answer's, never every later answer's. */
360
- export declare function bookingOfAnswer(records: readonly SessionRecord[], given: ReadonlySet<number>): {
357
+ /** What the request that just answered cost, from the session's records, and the bookings that answer gives (`turns`),
358
+ * among the runner.turn records no answer was given yet (`given`). The answer reads its own conversation's (`own`: the
359
+ * turns its conversation asked; absent, every turn): a booking of a conversation asking beside it (a subagent's child,
360
+ * answering at about the same time) is left for that conversation's answer, neither read nor given. A side request's
361
+ * booking (sideTurnsOf) is given and never read: it is no answer's, and it stays on the run's ledger and cap. The answer
362
+ * reads its conversation's requests booked since the answer before it, their booked figures summed (a conversation asks
363
+ * one at a time, so that is its own; were a retry ever booked without an answer of its own, it would be summed in), null
364
+ * when any is unknown; undefined when none is booked. Each booking is given once, so one unknown figure stays that
365
+ * answer's, never every later answer's. */
366
+ export declare function bookingOfAnswer(records: readonly SessionRecord[], given: ReadonlySet<number>, own?: (turn: number) => boolean): {
361
367
  turns: number[];
362
368
  usd: number | null | undefined;
363
369
  };