@parcha/agentrun-serve 0.1.0-beta.55 → 0.1.0-beta.57

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 (296) hide show
  1. package/CHANGELOG.md +261 -0
  2. package/README.md +228 -45
  3. package/dist/acp-package.d.ts +2 -0
  4. package/dist/adapters.d.ts +18 -5
  5. package/dist/adapters.js +23 -9
  6. package/dist/agent-package.d.ts +3 -3
  7. package/dist/agent-package.js +17 -8
  8. package/dist/answer-json.d.ts +6 -2
  9. package/dist/answer-json.js +22 -4
  10. package/dist/api-keys.d.ts +76 -0
  11. package/dist/api-keys.js +217 -0
  12. package/dist/api-only.d.ts +17 -5
  13. package/dist/api-only.js +36 -8
  14. package/dist/browser-hold.d.ts +23 -0
  15. package/dist/browser-hold.js +48 -0
  16. package/dist/browser-person.d.ts +3 -0
  17. package/dist/browser-person.js +4 -1
  18. package/dist/calendar/tools.js +3 -2
  19. package/dist/chatgpt-plan.d.ts +28 -3
  20. package/dist/chatgpt-plan.js +182 -21
  21. package/dist/claude-login.d.ts +101 -14
  22. package/dist/claude-login.js +232 -49
  23. package/dist/claude-sign-in.d.ts +46 -0
  24. package/dist/claude-sign-in.js +93 -0
  25. package/dist/cli.js +63 -6
  26. package/dist/composio-made.d.ts +4 -0
  27. package/dist/composio-made.js +4 -0
  28. package/dist/composio-preset.d.ts +43 -2
  29. package/dist/composio-preset.js +92 -4
  30. package/dist/computer-held-routes.d.ts +5 -4
  31. package/dist/computer-held-routes.js +29 -8
  32. package/dist/computer-held.d.ts +6 -1
  33. package/dist/computer-held.js +14 -0
  34. package/dist/computer-record.js +4 -2
  35. package/dist/computer-viewer.js +4 -1
  36. package/dist/console/assets/{backend-D5EmB4N3.js → backend-DVhHzJX2.js} +19 -19
  37. package/dist/console/assets/index-Bwn1oTem.css +1 -0
  38. package/dist/console/assets/index-okP-y8PK.js +747 -0
  39. package/dist/console/index.html +2 -2
  40. package/dist/decisions.d.ts +1 -1
  41. package/dist/decisions.js +1 -1
  42. package/dist/docker-host-addresses.d.ts +22 -11
  43. package/dist/docker-host-addresses.js +38 -26
  44. package/dist/env-switch.d.ts +10 -0
  45. package/dist/env-switch.js +33 -2
  46. package/dist/errors.d.ts +1 -0
  47. package/dist/errors.js +2 -0
  48. package/dist/fal-price.d.ts +58 -20
  49. package/dist/fal-price.js +341 -82
  50. package/dist/handed-values.d.ts +43 -1
  51. package/dist/handed-values.js +119 -2
  52. package/dist/harness-archive.d.ts +13 -10
  53. package/dist/harness-archive.js +60 -34
  54. package/dist/harness-check.d.ts +3 -1
  55. package/dist/harness-check.js +25 -46
  56. package/dist/harness-keys.d.ts +73 -27
  57. package/dist/harness-keys.js +194 -61
  58. package/dist/harness-recipe-entry.d.ts +8 -7
  59. package/dist/harness-recipe-entry.js +21 -32
  60. package/dist/harness-recipe.d.ts +38 -25
  61. package/dist/harness-recipe.js +49 -36
  62. package/dist/harness-sign-in.js +12 -23
  63. package/dist/harness-table.d.ts +10 -3
  64. package/dist/harness-table.js +26 -21
  65. package/dist/harness.d.ts +1 -0
  66. package/dist/harness.js +17 -5
  67. package/dist/host-check.d.ts +4 -0
  68. package/dist/host-check.js +4 -0
  69. package/dist/hosted-search.d.ts +1 -1
  70. package/dist/hosted-search.js +1 -2
  71. package/dist/import-worker.d.ts +4 -2
  72. package/dist/import-worker.js +9 -2
  73. package/dist/in-flight.d.ts +26 -0
  74. package/dist/in-flight.js +52 -0
  75. package/dist/key-refusal.d.ts +26 -5
  76. package/dist/key-refusal.js +313 -37
  77. package/dist/learn/secrets.d.ts +31 -11
  78. package/dist/learn/secrets.js +152 -191
  79. package/dist/learning-cost.d.ts +6 -3
  80. package/dist/learning-cost.js +4 -2
  81. package/dist/link-check.js +1 -1
  82. package/dist/llms.txt +2 -2
  83. package/dist/marketplace.d.ts +77 -0
  84. package/dist/marketplace.js +224 -0
  85. package/dist/mcp-api-only-origins.d.ts +30 -0
  86. package/dist/mcp-api-only-origins.js +57 -0
  87. package/dist/mcp-gateway.d.ts +7 -5
  88. package/dist/mcp-gateway.js +9 -12
  89. package/dist/mcp-secret-writes.js +5 -3
  90. package/dist/mcp-servers-store.d.ts +28 -6
  91. package/dist/mcp-servers-store.js +53 -4
  92. package/dist/media-duration.d.ts +3 -0
  93. package/dist/media-duration.js +90 -9
  94. package/dist/model-form.d.ts +5 -4
  95. package/dist/model-form.js +11 -7
  96. package/dist/model.d.ts +5 -2
  97. package/dist/model.js +9 -5
  98. package/dist/ollama-provider.d.ts +7 -1
  99. package/dist/ollama-provider.js +14 -2
  100. package/dist/openapi.d.ts +3 -3
  101. package/dist/openapi.js +245 -42
  102. package/dist/otel/genai.d.ts +65 -0
  103. package/dist/otel/genai.js +116 -0
  104. package/dist/otel/tracer.d.ts +55 -0
  105. package/dist/otel/tracer.js +308 -0
  106. package/dist/page.d.ts +2 -0
  107. package/dist/page.js +3 -1
  108. package/dist/paid-calls.d.ts +1 -32
  109. package/dist/paid-calls.js +4 -39
  110. package/dist/place-offers.d.ts +14 -6
  111. package/dist/place-offers.js +26 -13
  112. package/dist/provider.d.ts +9 -0
  113. package/dist/provider.js +50 -3
  114. package/dist/redact/match.d.ts +101 -0
  115. package/dist/redact/match.js +1152 -0
  116. package/dist/refusal-words.d.ts +11 -0
  117. package/dist/refusal-words.js +11 -0
  118. package/dist/run-census.d.ts +67 -0
  119. package/dist/run-census.js +240 -0
  120. package/dist/run-computer.d.ts +6 -3
  121. package/dist/run-computer.js +4 -1
  122. package/dist/run-cut.d.ts +15 -6
  123. package/dist/run-cut.js +30 -9
  124. package/dist/run-files.d.ts +3 -0
  125. package/dist/run-files.js +3 -0
  126. package/dist/run-launch.d.ts +12 -1
  127. package/dist/run-launch.js +9 -10
  128. package/dist/run-learning-served.d.ts +2 -0
  129. package/dist/run-model-key.d.ts +8 -0
  130. package/dist/run-model-key.js +31 -1
  131. package/dist/run-reads-over-store.d.ts +24 -6
  132. package/dist/run-reads-over-store.js +67 -23
  133. package/dist/run-recordings.d.ts +5 -1
  134. package/dist/run-recordings.js +39 -14
  135. package/dist/run-timeline-served.d.ts +3 -1
  136. package/dist/run-timeline-served.js +4 -4
  137. package/dist/run-usage.d.ts +1 -0
  138. package/dist/runnable.d.ts +10 -1
  139. package/dist/runnable.js +20 -8
  140. package/dist/runner/adapter-loop.d.ts +14 -0
  141. package/dist/runner/adapter-loop.js +56 -11
  142. package/dist/runner/adapter-run-spec.d.ts +45 -8
  143. package/dist/runner/adapter-run-spec.js +154 -29
  144. package/dist/runner/adapters/pi.js +25 -3
  145. package/dist/runner/beside.js +11 -6
  146. package/dist/runner/big-writes.js +1 -10
  147. package/dist/runner/claim-secrets.d.ts +18 -3
  148. package/dist/runner/claim-secrets.js +35 -6
  149. package/dist/runner/cli-run-spec.d.ts +6 -0
  150. package/dist/runner/cli-run-spec.js +85 -36
  151. package/dist/runner/computer-journal.d.ts +9 -1
  152. package/dist/runner/computer-journal.js +26 -0
  153. package/dist/runner/conformance/harness.js +1 -1
  154. package/dist/runner/feedback-round.js +3 -0
  155. package/dist/runner/harness-loops.d.ts +6 -5
  156. package/dist/runner/harness-loops.js +7 -7
  157. package/dist/runner/held.d.ts +11 -5
  158. package/dist/runner/journal-kinds.d.ts +5 -0
  159. package/dist/runner/journal-kinds.js +5 -0
  160. package/dist/runner/loop-contract.d.ts +4 -0
  161. package/dist/runner/main.js +15 -6
  162. package/dist/runner/mcp-claim.js +30 -3
  163. package/dist/runner/mcp-run.d.ts +12 -0
  164. package/dist/runner/mcp-run.js +12 -5
  165. package/dist/runner/model-route.d.ts +17 -0
  166. package/dist/runner/model-route.js +120 -2
  167. package/dist/runner/presence.d.ts +4 -3
  168. package/dist/runner/presence.js +4 -2
  169. package/dist/runner/run-child-host.d.ts +5 -0
  170. package/dist/runner/run-child-host.js +71 -30
  171. package/dist/runner/run-child.js +5 -2
  172. package/dist/runner/runner.d.ts +18 -3
  173. package/dist/runner/runner.js +162 -36
  174. package/dist/runner/store-port.d.ts +1 -1
  175. package/dist/runner/store-secrets.d.ts +6 -0
  176. package/dist/runner/store-secrets.js +49 -7
  177. package/dist/runner/subagent.js +4 -40
  178. package/dist/runner/workflow-first.d.ts +11 -4
  179. package/dist/runner/workflow-first.js +14 -8
  180. package/dist/runner/workflow-spec.js +3 -2
  181. package/dist/runs-over-store.d.ts +15 -6
  182. package/dist/runs-over-store.js +33 -21
  183. package/dist/scrub-command.d.ts +73 -0
  184. package/dist/scrub-command.js +307 -0
  185. package/dist/secret-cut.d.ts +73 -0
  186. package/dist/secret-cut.js +291 -4
  187. package/dist/secret-rules.d.ts +143 -0
  188. package/dist/secret-rules.js +2564 -0
  189. package/dist/secrets.d.ts +7 -0
  190. package/dist/secrets.js +20 -0
  191. package/dist/server-keys.d.ts +20 -0
  192. package/dist/server-keys.js +25 -6
  193. package/dist/server.d.ts +57 -13
  194. package/dist/server.js +371 -113
  195. package/dist/skills/agentrun-serve/SKILL.md +4 -0
  196. package/dist/store/dialect.d.ts +3 -0
  197. package/dist/store/dialect.js +1 -0
  198. package/dist/store/index.d.ts +1 -1
  199. package/dist/store/index.js +1 -1
  200. package/dist/store/journal/storage.js +1 -1
  201. package/dist/store/postgres/dialect.js +3 -0
  202. package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
  203. package/dist/store/schema.d.ts +6 -0
  204. package/dist/store/schema.js +11 -1
  205. package/dist/store/seal.d.ts +6 -1
  206. package/dist/store/seal.js +5 -3
  207. package/dist/store/sqlite/run-launch.d.ts +9 -1
  208. package/dist/store/sqlite/run-launch.js +24 -13
  209. package/dist/store/sqlite/run-patch.d.ts +1 -1
  210. package/dist/store/sqlite/run-patch.js +13 -4
  211. package/dist/store/sqlite/store.js +76 -16
  212. package/dist/store/store.d.ts +53 -3
  213. package/dist/store/store.js +27 -0
  214. package/dist/store-reads/learning.d.ts +6 -3
  215. package/dist/store-reads/learning.js +22 -7
  216. package/dist/store-view.d.ts +3 -0
  217. package/dist/store-view.js +4 -4
  218. package/dist/suggestions.js +3 -2
  219. package/dist/template-eval.d.ts +22 -11
  220. package/dist/template-eval.js +124 -41
  221. package/dist/template-import.d.ts +10 -0
  222. package/dist/template-import.js +16 -7
  223. package/dist/templates.d.ts +10 -2
  224. package/dist/templates.js +28 -8
  225. package/dist/timeline/index.d.ts +1 -1
  226. package/dist/timeline/index.js +1 -1
  227. package/dist/timeline/labels.d.ts +6 -4
  228. package/dist/timeline/labels.js +18 -6
  229. package/dist/timeline/timeline.d.ts +17 -7
  230. package/dist/timeline/timeline.js +28 -14
  231. package/dist/timeline/util.js +1 -1
  232. package/dist/timeline/web-calls.d.ts +26 -9
  233. package/dist/timeline/web-calls.js +124 -37
  234. package/dist/tool-gate.d.ts +42 -3
  235. package/dist/tool-gate.js +69 -6
  236. package/dist/tool-keys-store.d.ts +2 -4
  237. package/dist/tool-keys-store.js +5 -21
  238. package/dist/tool-keys.d.ts +2 -2
  239. package/dist/tool-keys.js +2 -2
  240. package/dist/tool-list.js +1 -1
  241. package/dist/tool-plane.d.ts +2 -2
  242. package/dist/tool-plane.js +35 -33
  243. package/dist/tools.js +13 -7
  244. package/dist/trigger-targets.d.ts +4 -0
  245. package/dist/trigger-targets.js +9 -2
  246. package/dist/triggers.d.ts +67 -4
  247. package/dist/triggers.js +171 -22
  248. package/dist/until.d.ts +3 -0
  249. package/dist/until.js +11 -0
  250. package/dist/validate.js +1 -1
  251. package/dist/web-fake.d.ts +1 -3
  252. package/dist/web-fake.js +7 -18
  253. package/dist/web-fetch.d.ts +6 -72
  254. package/dist/web-fetch.js +11 -265
  255. package/dist/web-run.d.ts +31 -0
  256. package/dist/web-run.js +90 -0
  257. package/dist/web-save.d.ts +6 -4
  258. package/dist/web-save.js +9 -12
  259. package/dist/web-search.d.ts +9 -127
  260. package/dist/web-search.js +23 -259
  261. package/dist/wires.d.ts +13 -0
  262. package/dist/wires.js +11 -0
  263. package/dist/workflow-run.d.ts +5 -4
  264. package/dist/workflow-run.js +5 -4
  265. package/dist/workspace/computer-deps.d.ts +3 -1
  266. package/dist/workspace/computer-deps.js +12 -4
  267. package/dist/workspace/computer-for-claim.d.ts +19 -2
  268. package/dist/workspace/computer-for-claim.js +101 -13
  269. package/dist/workspace/computer-janitor.d.ts +15 -7
  270. package/dist/workspace/computer-janitor.js +33 -8
  271. package/dist/workspace/computer-kept.d.ts +55 -4
  272. package/dist/workspace/computer-kept.js +129 -8
  273. package/dist/workspace/index.d.ts +1 -1
  274. package/dist/workspace/index.js +1 -1
  275. package/dist/workspace/kind-skills.d.ts +4 -0
  276. package/dist/workspace/kind-skills.js +9 -0
  277. package/dist/workspace/run-end-computers.d.ts +5 -1
  278. package/dist/workspace/run-end-computers.js +27 -1
  279. package/dist/workspace/synced-folder.js +3 -4
  280. package/dist/wrapped.d.ts +65 -0
  281. package/dist/wrapped.js +77 -0
  282. package/package.json +17 -11
  283. package/skills/agentrun-serve/SKILL.md +4 -0
  284. package/templates/README.md +38 -15
  285. package/dist/console/assets/index-DUYLaqiR.js +0 -746
  286. package/dist/console/assets/index-DYhU4adm.css +0 -1
  287. package/dist/exa-keyless.d.ts +0 -34
  288. package/dist/exa-keyless.js +0 -118
  289. package/dist/firecrawl-keyless.d.ts +0 -41
  290. package/dist/firecrawl-keyless.js +0 -152
  291. package/dist/keyless-mcp.d.ts +0 -36
  292. package/dist/keyless-mcp.js +0 -127
  293. package/dist/text-urls.d.ts +0 -38
  294. package/dist/text-urls.js +0 -170
  295. package/dist/web-fetch-direct.d.ts +0 -119
  296. package/dist/web-fetch-direct.js +0 -190
package/dist/tool-gate.js CHANGED
@@ -18,20 +18,22 @@
18
18
  //
19
19
  // An ask has one way to wait, every tool's alike (the owner's ruling of 11-04): it PARKS. The runner's loop holds the
20
20
  // call and the run goes needs_input with the pending approval. On an answer the loop runs the approved call once, through
21
- // the journal, and the session goes on with its result. One call waits at a time: another asked meanwhile is refused.
21
+ // the journal, and the session goes on with its result. A read the runner lost mid-call (its claim lapsed before the
22
+ // call's end was recorded) may run again on its next claim; a call with a side effect never does: that claim answers it
23
+ // interrupted (test/adapter-approved-call-lapse.test.mjs). One call waits at a time: another asked meanwhile is refused.
22
24
  //
23
25
  // The answer: POST /v2/runs/{id}/approvals/{approval_id} { decision: "allow" | "deny", note? } -> 204. The first answer
24
26
  // wins; the same answer again is 204, a conflicting one 409. Only the owner's password session answers (server.ts), never
25
27
  // a token. A cancel marks pending approvals canceled. Where no one can approve (accounts off), an ask is refused at once
26
28
  // in words, never parked.
27
- import { COMPUTER_OP_TOOL, computerToolDefs, defaultPermissionOf, SHELL_FAMILY, SHELL_WATCHERS, shellPermission, shellToolOf } from "@parcha/agentrun-kernel/kernel";
29
+ import { COMPUTER_OP_TOOL, COMPUTER_TOOLS, computerToolDefs, defaultPermissionOf, hostToolDefs, SHELL_FAMILY, SHELL_WATCHERS, shellPermission, shellToolOf } from "@parcha/agentrun-kernel/kernel";
28
30
  import { READ_SKILL_FILE } from "@parcha/agentrun-kernel";
29
31
  import { COMPUTER_ROOT } from "./workspace/paths.js";
30
32
  import { META_TOOLS } from "./meta-tool-names.js";
31
33
  import { DEFAULT_HARNESS } from "./harness.js";
32
34
  import { DECISION_PROVIDER_KEYS, KIND_KEYS, SERVE_OWN_TOOLS } from "./tool-plane.js";
33
35
  import { asksByDefault, isToolRow, tableTools } from "./tool-list.js";
34
- import { CANT_BE_CALLED, DENIED_OPENING, deniedText, NOT_RUN, RAN_UNKNOWN } from "./refusal-words.js";
36
+ import { CANT_BE_CALLED, computerOffText, computerOffWords, DENIED_OPENING, deniedText, NOT_RUN, RAN_UNKNOWN } from "./refusal-words.js";
35
37
  import { approvalsOf } from "./approvals.js";
36
38
  import { settingOfDefinition } from "./computer-setting.js";
37
39
  import { BASH_POLICIES, readOnlyReason, readOnlyText } from "./bash-read-only.js";
@@ -351,6 +353,27 @@ export function runGate(where, runId, revision, serverSettings, approvers) {
351
353
  const kind = settingOfDefinition(revision.body)?.computer.kind;
352
354
  return new RunGate({ root: where.root, work: where.work, runId, harness: revision.body.harness ?? DEFAULT_HARNESS, ...(where.computer === undefined ? {} : { computer: where.computer }), ...(kind !== undefined ? { kind } : {}), ...(where.effectOf ? { effectOf: where.effectOf } : {}), ...(where.argumentsOf ? { argumentsOf: where.argumentsOf } : {}), facts: where.facts }, serverSettings, (revision.body.toolSettings ?? {}), approvers, approvalsOf(revision.body.approvals));
353
355
  }
356
+ /** The host tools that run on a computer that holds the run's shell (the kernel registry's, for shell "computer"). */
357
+ const ON_COMPUTER = new Set(hostToolDefs({ maxExecS: 600, shell: "computer" }).map((def) => def.name));
358
+ /** The tools a run's computer of `kind` serves, by the names its gate decides them by: a desktop's or a phone's own
359
+ * (COMPUTER_TOOLS, held to its kind's key), a browser's (its key), and, where the run's shell is on the computer
360
+ * (`shell` "computer": a sandbox, a desktop that mounts the run's folder), each host tool the agent grants. */
361
+ export function computerToolsOf(kind, granted, shell) {
362
+ const own = kind === "desktop" || kind === "phone" ? [...COMPUTER_TOOLS] : kind === "browser" ? ["browser"] : [];
363
+ return [...own, ...(shell === "computer" ? granted.filter((name) => ON_COMPUTER.has(name)) : [])];
364
+ }
365
+ /** The kind of the agent's computer when every tool it serves (computerToolsOf) is set to deny for `revision` under the
366
+ * server's `server` settings, as its run's gate reads them: a run of it never starts that computer. Undefined for an agent
367
+ * with no computer, one whose computer serves none of its tools, or one any of them is allowed or asked of. `shell`: where
368
+ * a run of it has its shell (resolve-computer.ts runShellOf). Settings that do not read deny nothing (the gate asks). */
369
+ export function computerDenied(revision, shell, server) {
370
+ const kind = settingOfDefinition(revision.body)?.computer.kind;
371
+ if (kind === undefined || kind === "none")
372
+ return undefined;
373
+ const tools = computerToolsOf(kind, revision.body.tools ?? [], shell);
374
+ const gate = runGate({ root: COMPUTER_ROOT, work: COMPUTER_ROOT, computer: shell === "computer", facts: undefined }, "", revision, () => server, true);
375
+ return tools.length > 0 && tools.every((tool) => gate.policy(tool) === "deny") ? kind : undefined;
376
+ }
354
377
  /** A run's tool gate on the runner: its policy, asked before each call's intent (decide). */
355
378
  export class RunGate {
356
379
  where;
@@ -395,15 +418,27 @@ export class RunGate {
395
418
  // call, decided as on a computer, where it runs: a desktop that mounts no folder has a computer to run a command on,
396
419
  // so shell.run and processes.start follow bash's one setting alike, as the run's own tools on a computer do. It is a
397
420
  // computer tool too: the kind's deny (desktop or phone set to deny) refuses it first, in the kind's words, below.
421
+ const ran = options.replayed ? "unknown" : "no";
422
+ // The run's computer once a call of its own tools was refused for a deny is off for the rest of the run: a later call
423
+ // of them is refused here, short, with no setting read and nothing sent to it (a setting changed since included).
424
+ const off = this.offRefusal(name, options);
425
+ if (off)
426
+ return off;
427
+ const own = this.computerOwns(name);
398
428
  const held = heldAs(name, args);
399
429
  if (held && this.policy(name) !== "deny")
400
430
  return this.onComputer().decide(held.tool, held.args, options);
401
431
  const key = this.keyOf(name) ?? name;
402
432
  const tool = this.askedAs(name);
403
- const ran = options.replayed ? "unknown" : "no";
404
433
  const verdict = this.policy(name);
405
- if (verdict === "deny")
406
- return { deny: deniedText(tool, key, this.denyFrom(name), ran) };
434
+ if (verdict === "deny") {
435
+ const text = deniedText(tool, key, this.denyFrom(name), ran);
436
+ if (!own)
437
+ return { deny: text };
438
+ // The first such deny says so, once, in its refusal.
439
+ this.off = true;
440
+ return { deny: `${text} ${computerOffWords(own)}` };
441
+ }
407
442
  const pinned = this.pinned(key, args, ran);
408
443
  if (pinned)
409
444
  return { deny: pinned.text };
@@ -414,6 +449,34 @@ export class RunGate {
414
449
  return "allow";
415
450
  return this.approvers ? "ask" : { deny: noApproverText(tool, ran) };
416
451
  }
452
+ /** The refusal of a call of the run's computer's own tools (computerOwns) once that computer is off for the rest of the
453
+ * run (computerOff): short, decided with no setting read and nothing sent to it, a setting changed since included.
454
+ * Undefined for any other call, or while the computer is on. */
455
+ offRefusal(name, options = {}) {
456
+ const own = this.off ? this.computerOwns(name) : undefined;
457
+ return own ? { deny: computerOffText(own, options.replayed ? "unknown" : "no") } : undefined;
458
+ }
459
+ /** The run's computer's kind once it is off for the rest of the run: by the first deny of a call of its own tools
460
+ * (decide, whose refusal says so once), or from a claim's start (turnOff). Undefined while it is on. */
461
+ get computerOff() {
462
+ return this.off ? this.where.kind : undefined;
463
+ }
464
+ /** The run's computer off from this claim's start: an earlier claim's deny turned it off for the run
465
+ * (computer-journal.ts computerTurnedOff), so each call of its tools is refused short, never said off again. */
466
+ turnOff() {
467
+ this.off = true;
468
+ }
469
+ /** Set by the first deny of a call of the run's computer's own tools (computerOwns), or by turnOff. */
470
+ off = false;
471
+ /** The run's computer kind (where.kind) when `name` is one of that computer's own tools: a desktop's or a phone's
472
+ * (KIND_TOOLS), a browser's (held to the browser key). Undefined for any other call, a shell or file tool the computer
473
+ * runs included: a deny of one of those leaves the computer's own tools as they are. */
474
+ computerOwns(name) {
475
+ const kind = this.where.kind;
476
+ if (kind === "desktop" || kind === "phone")
477
+ return KIND_TOOLS.has(name) ? kind : undefined;
478
+ return kind === "browser" && !KIND_TOOLS.has(name) && this.keyOf(name) === "browser" ? kind : undefined;
479
+ }
417
480
  /** The settings key a call of `name` is held to, the one its refusal and its ask name: a computer tool's is the kind
418
481
  * whose setting decides it (kindSetting), any other's its session's name map. */
419
482
  keyOf(name) {
@@ -1,5 +1,6 @@
1
1
  import { type KeyCheck } from "./key-check.js";
2
- import { rowUnlocks, UNREADABLE } from "./tool-keys.js";
2
+ import { UNREADABLE } from "./server-keys.js";
3
+ import { rowUnlocks } from "./tool-keys.js";
3
4
  import { type SealedKeys, type Settings } from "./store/index.js";
4
5
  /** Where the per-key checks and seal-key fingerprints live in store.settings: one row, outside the sealed values. */
5
6
  export declare const TOOL_KEY_CHECKS_KEY = "tool-key-checks";
@@ -30,9 +31,6 @@ declare class ToolKeysOverStore {
30
31
  /** The checks and fingerprints the settings row holds, failing closed (an unreadable row reads as none, so no value is
31
32
  * lost and each field is just asked to be checked again). */
32
33
  private readChecks;
33
- /** Opens a field's sealed bytes now, or why not: a fingerprint that no longer matches (seal_key_changed); else unseal,
34
- * which fails as file_unreadable. */
35
- private openAt;
36
34
  /** The stored value of the field `name`, opened; undefined with none, or one that does not open: never a clear fallback. */
37
35
  value(name: string): string | undefined;
38
36
  /** Every stored value that opens, by field name. */
@@ -7,14 +7,13 @@
7
7
  // save/remove return a promise the handler awaits (durable before the 204). The reads are served from an in-memory
8
8
  // snapshot the server (the one writer of these rows) loads once at start (load()) and keeps in step with every write, so a
9
9
  // read answers without a round trip.
10
- import { createHmac } from "node:crypto";
11
10
  import { decisionsOf } from "./decisions.js";
12
11
  import { ApiError, invalid } from "./errors.js";
13
12
  import { checkKey } from "./key-check.js";
14
- import { putSealedKey, removeSealedKey } from "./server-keys.js";
15
- import { rowSecrets, rowUnlocks, SEAL_KEY_ENV, sealKeyOf, TOOL_KEYS, UNREADABLE } from "./tool-keys.js";
13
+ import { openSealed, putSealedKey, removeSealedKey, sealFingerprint, UNREADABLE } from "./server-keys.js";
14
+ import { rowSecrets, rowUnlocks, SEAL_KEY_ENV, sealKeyOf, TOOL_KEYS } from "./tool-keys.js";
16
15
  import { toolsView } from "./tools.js";
17
- import { sealColumn, sealedAt, unsealColumn } from "./store/index.js";
16
+ import { sealColumn, sealedAt } from "./store/index.js";
18
17
  import { isObject, unknownFields } from "./validate.js";
19
18
  /** Where the per-key checks and seal-key fingerprints live in store.settings: one row, outside the sealed values. */
20
19
  export const TOOL_KEY_CHECKS_KEY = "tool-key-checks";
@@ -29,9 +28,6 @@ const keptCheck = (entry) => !isObject(entry) ? undefined
29
28
  : entry.state === "accepted" && typeof entry.at === "string" ? { state: "accepted", at: entry.at }
30
29
  : entry.state === "not_checked" && typeof entry.reason === "string" ? { state: "not_checked", reason: entry.reason, ...(typeof entry.at === "string" ? { at: entry.at } : {}) }
31
30
  : undefined;
32
- /** The fingerprint of a seal key: an HMAC of a fixed label under it, stable across restarts, so a value whose fingerprint
33
- * no longer matches was sealed under another key (seal_key_changed), told apart from one that is simply damaged. */
34
- const fingerprint = (key) => createHmac("sha256", key).update("agentrun-serve sealed_keys key check").digest("base64url");
35
31
  /** What the start's log line says to a person when saved keys do not open, by why: where they are kept is the server's
36
32
  * store (`kept=store`), and what to do is to save them again in the console's Settings. */
37
33
  export const REENTER_SAID = {
@@ -58,7 +54,7 @@ class ToolKeysOverStore {
58
54
  if (!key)
59
55
  throw new Error(`tool keys are kept under the server's seal key (${SEAL_KEY_ENV}), and none was handed over: the server does not start without one`);
60
56
  this.key = key;
61
- this.sealCheck = fingerprint(key);
57
+ this.sealCheck = sealFingerprint(key);
62
58
  }
63
59
  /** Reads the store once into the snapshot: each sealed field opened now, the checks and the fingerprints beside them.
64
60
  * Awaited once at start, before the first read. */
@@ -69,7 +65,7 @@ class ToolKeysOverStore {
69
65
  for (const row of await this.store.sealedKeys.all()) {
70
66
  if (!FIELDS.includes(row.name))
71
67
  continue; // the sealed_keys table also holds Archil's keys, which are not tool keys
72
- fields.set(row.name, this.openAt(row.name, row.sealed, seals.get(row.name)));
68
+ fields.set(row.name, openSealed(this.key, row.name, row.sealed, seals.get(row.name)));
73
69
  changed.set(row.name, row.updatedAt);
74
70
  }
75
71
  this.snapshot = { fields, checks, seals, changed };
@@ -93,18 +89,6 @@ class ToolKeysOverStore {
93
89
  }
94
90
  return { checks, seals };
95
91
  }
96
- /** Opens a field's sealed bytes now, or why not: a fingerprint that no longer matches (seal_key_changed); else unseal,
97
- * which fails as file_unreadable. */
98
- openAt(name, sealed, fp) {
99
- if (fp !== undefined && fp !== this.sealCheck)
100
- return { unreadable: "seal_key_changed" };
101
- try {
102
- return { value: unsealColumn(this.key, sealedAt.sealedKey(name), sealed).toString("utf8") };
103
- }
104
- catch {
105
- return { unreadable: "file_unreadable" };
106
- }
107
- }
108
92
  /** The stored value of the field `name`, opened; undefined with none, or one that does not open: never a clear fallback. */
109
93
  value(name) {
110
94
  if (!FIELDS.includes(name))
@@ -87,8 +87,8 @@ export declare const unlocksTool: (unlock: string, name: string) => boolean;
87
87
  /** The key that unlocks the tool `name` (capabilities' `tools[].key`, so a page links "needs the X key" to it), if any. */
88
88
  export declare const keyOf: (name: string) => string | undefined;
89
89
  /** Why a stored value does not open, in the order a re-entry names one: sealed under another key than the server's, or
90
- * its row damaged. */
91
- export declare const UNREADABLE: readonly ["seal_key_changed", "file_unreadable"];
90
+ * its row damaged (server-keys.ts: the one list every sealed key's view reads). */
91
+ export { UNREADABLE } from "./server-keys.js";
92
92
  /** The check of a key the server was started with (tool-keys-store.ts checkServer): a KeyCheck, or refused by its provider, why in
93
93
  * plain words. Held in memory only, for this start. */
94
94
  export type StartCheck = KeyCheck | {
package/dist/tool-keys.js CHANGED
@@ -66,8 +66,8 @@ export const unlocksTool = (unlock, name) => unlock === name || (unlock.endsWith
66
66
  /** The key that unlocks the tool `name` (capabilities' `tools[].key`, so a page links "needs the X key" to it), if any. */
67
67
  export const keyOf = (name) => TOOL_KEYS.find((row) => row.unlocks.some((unlock) => unlocksTool(unlock, name)))?.id;
68
68
  /** Why a stored value does not open, in the order a re-entry names one: sealed under another key than the server's, or
69
- * its row damaged. */
70
- export const UNREADABLE = ["seal_key_changed", "file_unreadable"];
69
+ * its row damaged (server-keys.ts: the one list every sealed key's view reads). */
70
+ export { UNREADABLE } from "./server-keys.js";
71
71
  /** A key row's secrets as every secret's view says them (secret-writes.ts SecretMeta): one per field, named
72
72
  * "<kind>:<FIELD>" (tool:MONID_API_KEY, model:OPENROUTER_API_KEY); source env when the server is started with it, console
73
73
  * when the owner saved it; `changedAt` the time that field's own value was saved (its own row in the store, its own entry
package/dist/tool-list.js CHANGED
@@ -3,7 +3,7 @@ export const TOOL_LIST = Object.freeze({
3
3
  write: { table: true, askable: true, replay: "never", blurb: "Write files in the run's folder" },
4
4
  edit: { table: true, askable: true, replay: "never", blurb: "Edit files in the run's folder" },
5
5
  bash: { table: true, askable: true, replay: "never", blurb: "Run shell commands in the sandbox" },
6
- ask_person: { table: true, replay: "safe", blurb: "Ask you a question mid-run" },
6
+ ask_person: { table: true, replay: "safe", blurb: "Lets the agent stop and ask you a question" },
7
7
  web_fetch: { table: true, askable: true, replay: "safe", host: true, blurb: "Read a public web page" },
8
8
  web_search: { table: true, askable: true, replay: "safe", host: true, blurb: "Search the web" },
9
9
  web_save: { table: true, askable: true, replay: "never", host: true, blurb: "Save a public file into the run's folder" },
@@ -20,8 +20,8 @@ export declare const CAPABILITIES: readonly ["read", "write", "edit", "web_searc
20
20
  * Named once here, so the scan of vendor ids (scripts/check-vendor-ids.mjs) counts it once. */
21
21
  declare const DIRECT_FETCH: "kernel";
22
22
  /** The providers a user may pick for each capability that has a choice, its default first: `auto`, for web_search the
23
- * native search where there is one (never on claude-agent, where Claude's own search is picked as `native`), else
24
- * Parallel where the server holds its key, else keyless Firecrawl; for web_fetch the guarded direct fetch where the
23
+ * Parallel where the server holds its key, else keyless Firecrawl, on every harness (a native search is never `auto`,
24
+ * only `native`); for web_fetch the guarded direct fetch where the
25
25
  * server holds a Parallel key, else keyless Firecrawl; `native`, the harness's own tool or its model provider's hosted
26
26
  * one, and nothing else; `firecrawl-keyless`, Firecrawl's public MCP endpoint, no key, with keyless Exa behind it for
27
27
  * web_search and the guarded direct fetch behind it for web_fetch; `exa-keyless`, Exa's public MCP endpoint alone, no
@@ -1,16 +1,15 @@
1
1
  // The tool plane: the capabilities a pack or a revision may grant, the providers a user may pick for the two that reach
2
2
  // the web, and what each resolves to on a run. A capability resolves in one order: (1) the provider the user picked, the
3
- // agent's own (`definition.tool_settings`) over the server's (`PUT /v2/settings/tools`), optional; (2) the native tool:
4
- // the harness's own (claude-agent's WebSearch), or on pi one request to the run's own model provider with its hosted
5
- // search (hosted-search.ts); (3) for web_search, Parallel where the server holds its key (env or saved, which then bills
6
- // it); (4) the keyless fallback: Firecrawl's public keyless MCP endpoint (firecrawl-keyless.ts), with Exa's
7
- // (exa-keyless.ts) behind it. web_fetch has no (2): its `auto` is the guarded direct fetch where the server holds a
3
+ // agent's own (`definition.tool_settings`) over the server's (`PUT /v2/settings/tools`), optional; (2) for web_search,
4
+ // Parallel where the server holds its key (env or saved, which then bills it); (3) the keyless fallback: Firecrawl's
5
+ // public keyless MCP endpoint (@parcha/agentrun-web providers/firecrawl-keyless.ts), with Exa's
6
+ // (providers/exa-keyless.ts) behind it. web_fetch's `auto` is the guarded direct fetch where the server holds a
8
7
  // Parallel key (as before keyless Firecrawl), else keyless Firecrawl with the guarded direct fetch behind it, and
9
8
  // Parallel's extract is a pick. Through Firecrawl web_fetch sends each URL to a third party, and its `why` says so; a URL
10
- // the public-host guard refuses never goes (web-fetch.ts). On claude-agent `auto` skips (2):
11
- // Claude's own search is an explicit pick, `native`. Codex's own search on codex, Parallel or keyless Firecrawl behind
12
- // a gateway, on OpenRouter or under a spend cap;
13
- // `off` turns web_search off. web_search's default, `auto`, is that order; a pick of `native` is native only,
9
+ // the public-host guard refuses never goes (web-fetch.ts). The native search, a harness's own (Claude's WebSearch,
10
+ // Codex's live search) or on pi one request to the run's own model provider with its hosted search (hosted-search.ts),
11
+ // runs only where it is picked, `native`: `auto` never resolves to it, on any harness. `off` turns web_search off.
12
+ // web_search's default, `auto`, is that order; a pick of `native` is native only,
14
13
  // unavailable where there is none, never a keyless search. A grant names a capability, never a provider. A pick of parallel without
15
14
  // PARALLEL_API_KEY resolves unavailable, never to something else. The server resolves a run's tools at its first
16
15
  // launch, from its pinned revision and the settings then, keeps them for the run's life (runs.ts), and hands the run's
@@ -31,6 +30,7 @@ import { keyNeeded } from "./key-words.js";
31
30
  import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
32
31
  import { factsOf as tableFactsOf, harnessOf } from "./harness-table.js";
33
32
  import { viaOpenRouter, wireOf } from "./provider.js";
33
+ import { routedId } from "./wires.js";
34
34
  import { savedIn } from "./secrets.js";
35
35
  import { hostModel } from "./model.js";
36
36
  import { NEEDS_A_COMPUTER, NO_SHELL } from "@parcha/agentrun-kernel/kernel";
@@ -50,8 +50,8 @@ export const CAPABILITIES = ["read", "write", "edit", "web_search", "web_fetch",
50
50
  * Named once here, so the scan of vendor ids (scripts/check-vendor-ids.mjs) counts it once. */
51
51
  const DIRECT_FETCH = "kernel";
52
52
  /** The providers a user may pick for each capability that has a choice, its default first: `auto`, for web_search the
53
- * native search where there is one (never on claude-agent, where Claude's own search is picked as `native`), else
54
- * Parallel where the server holds its key, else keyless Firecrawl; for web_fetch the guarded direct fetch where the
53
+ * Parallel where the server holds its key, else keyless Firecrawl, on every harness (a native search is never `auto`,
54
+ * only `native`); for web_fetch the guarded direct fetch where the
55
55
  * server holds a Parallel key, else keyless Firecrawl; `native`, the harness's own tool or its model provider's hosted
56
56
  * one, and nothing else; `firecrawl-keyless`, Firecrawl's public MCP endpoint, no key, with keyless Exa behind it for
57
57
  * web_search and the guarded direct fetch behind it for web_fetch; `exa-keyless`, Exa's public MCP endpoint alone, no
@@ -168,16 +168,20 @@ export const ownSearchViaOpenRouter = (env, harness, model) => {
168
168
  function noNative(input) {
169
169
  // Native, where there is one: a harness's own (its facts' webSearch), else pi's, which asks Anthropic's or OpenAI's. A
170
170
  // harness's own search goes with its request on its wire, except on OpenRouter (which runs no harness's own search, nor
171
- // counts its searches), behind serve's gateway on the wire it serves (no known hosted search), or under a spend cap
171
+ // counts its searches), on a model the route translates onto its wire (wires.ts routed: the route asks that model, which
172
+ // has no provider-hosted tool, so the harness's own search is never sent), behind serve's gateway on the wire it serves (no known hosted search), or under a spend cap
172
173
  // (cappedOwn: per-use fees the cap cannot reserve yet, its request's bound holding the pages' input tokens, not the
173
174
  // fees; or a request with no input bound). A harness with none (OpenCode, whose proxy policy refuses a
174
- // provider-hosted tool) has none at all. Where there is none, `native` is unavailable, and `auto` goes to Parallel on
175
- // the server's key (its fee booked and held by a cap, paid-calls.ts), else to keyless Firecrawl.
175
+ // provider-hosted tool) has none at all. Where there is none, `native` is unavailable. `auto` goes to Parallel on the
176
+ // server's key (its fee booked and held by a cap, paid-calls.ts), else to keyless Firecrawl, with a native search or
177
+ // without.
176
178
  const vendor = input.model?.slice(0, Math.max(0, input.model.indexOf("/")));
177
179
  const { facts } = input;
178
180
  if (facts) {
179
181
  if (!facts.webSearch)
180
182
  return { id: `${input.harness}, whose model requests carry no provider-hosted tool`, why: `${facts.label}'s model requests carry no provider-hosted tool` };
183
+ if (input.model && routedId(facts.wire, input.model))
184
+ return { id: `${input.harness} on a model the route translates`, why: `${facts.label}'s own search does not run on a model the route translates` };
181
185
  if (input.openRouter)
182
186
  return { id: `${input.harness} on OpenRouter`, why: `through OpenRouter ${facts.label}'s own search is not run, and its searches are not counted to price` };
183
187
  if (input.gateway && wireOf(facts.wire)?.gateway)
@@ -190,11 +194,13 @@ function noNative(input) {
190
194
  return undefined;
191
195
  return input.model ? { id: input.model, why: `${input.model} has no hosted search here` } : { id: "a model with none named", why: "no model is named, so there is no hosted search" };
192
196
  }
193
- /** The native search of a run that has one, in a sentence. */
194
- const nativeWhy = (input) => {
197
+ /** The native search of a run that has one, by name: the harness's own, else its model provider's hosted one. */
198
+ const ownSearch = (input) => {
195
199
  const { facts } = input;
196
- return facts?.webSearch ? `${facts.label}'s own search` : `${input.model?.startsWith("openai/") ? "OpenAI" : "Anthropic"}'s hosted search, for ${input.model}`;
200
+ return facts?.webSearch ? `${facts.label}'s own search` : `${input.model?.startsWith("openai/") ? "OpenAI" : "Anthropic"}'s hosted search`;
197
201
  };
202
+ /** The native search of a run that has one, in a sentence. */
203
+ const nativeWhy = (input) => (input.facts?.webSearch ? ownSearch(input) : `${ownSearch(input)}, for ${input.model}`);
198
204
  /** Keyless Firecrawl in a sentence, as web_search and web_fetch use it. web_fetch's says plainly that each URL leaves
199
205
  * the server, and how to keep it here. */
200
206
  const FIRECRAWL_SEARCH = "Firecrawl's free keyless search, no key, keyless Exa behind it";
@@ -224,23 +230,19 @@ export function explainCapability(capability, input) {
224
230
  return { resolves: "exa-keyless", why: `keyless Exa, ${picked}: Exa's free search, no key` };
225
231
  if (chosen === "firecrawl-keyless")
226
232
  return { resolves: "firecrawl-keyless", why: `keyless Firecrawl, ${picked}: ${FIRECRAWL_SEARCH}` };
227
- // Under ask, a harness's own search runs inside its CLI, where no call can wait for a person: none on claude-agent or
228
- // codex then, and the kernel's search, which the gate holds, in its place. pi's is a tool of the run's, which it holds.
229
- const asks = input.permission === "ask" && input.facts !== undefined;
233
+ // `native` picked: the native search only. Under ask, a harness's own search runs inside its CLI, where no call can
234
+ // wait for a person, so it is unavailable; pi's is a tool of the run's, which the gate holds.
230
235
  const without = noNative(input);
231
- if (chosen === "native" && asks && without === undefined)
232
- return { resolves: NATIVE_ASKS, why: "native search cannot wait for an approval: it runs inside the harness's CLI" };
233
- const none = without ?? (asks ? { id: input.harness, why: "under ask the harness's own search cannot wait for a person's approval" } : undefined);
234
- if (chosen === "native")
235
- return none === undefined ? { resolves: "native", why: nativeWhy(input) } : { resolves: `unavailable: no native search for ${none.id}`, why: `no native search for ${none.id}` };
236
- // `auto` skips a harness's own search that has per-use fees (its facts' `native`: the provider's search tool), an
237
- // explicit pick (`native`): Parallel on the server's key, else keyless Firecrawl.
238
- const { facts } = input;
239
- if (facts?.webSearch === "native")
240
- return input.parallelKey ? { resolves: "parallel", why: key } : { resolves: "firecrawl-keyless", why: `${FIRECRAWL_SEARCH}; ${facts.label}'s own search is an explicit pick` };
241
- if (none === undefined)
242
- return { resolves: "native", why: nativeWhy(input) };
243
- return input.parallelKey ? { resolves: "parallel", why: `${none.why}; ${key}` } : { resolves: "firecrawl-keyless", why: `${none.why}; ${FIRECRAWL_SEARCH}` };
236
+ if (chosen === "native") {
237
+ if (without !== undefined)
238
+ return { resolves: `unavailable: no native search for ${without.id}`, why: `no native search for ${without.id}` };
239
+ return input.permission === "ask" && input.facts !== undefined ? { resolves: NATIVE_ASKS, why: "native search cannot wait for an approval: it runs inside the harness's CLI" } : { resolves: "native", why: nativeWhy(input) };
240
+ }
241
+ // `auto` never resolves native, on any harness: Parallel on the server's key, else keyless Firecrawl. Where a native
242
+ // search would run, auto's why names it as the pick it is; where none runs (noNative), it says why not.
243
+ if (without === undefined)
244
+ return input.parallelKey ? { resolves: "parallel", why: key } : { resolves: "firecrawl-keyless", why: `${FIRECRAWL_SEARCH}; ${ownSearch(input)} is an explicit pick` };
245
+ return input.parallelKey ? { resolves: "parallel", why: `${without.why}; ${key}` } : { resolves: "firecrawl-keyless", why: `${without.why}; ${FIRECRAWL_SEARCH}` };
244
246
  }
245
247
  /** What `capability` resolves to on a run of `input`. */
246
248
  export const resolveCapability = (capability, input) => explainCapability(capability, input).resolves;
package/dist/tools.js CHANGED
@@ -18,7 +18,8 @@ import { defineExtension, defineTool, ROOT_CONVERSATION_ID } from "@earendil-wor
18
18
  import { registerTurnEnding } from "./timeline/index.js";
19
19
  import { BACKGROUND_LOG_BYTES, BACKGROUND_MAX, BACKGROUND_PAGE_BYTES } from "./background.js";
20
20
  import { isWorkspaceError, localWorkspace } from "./workspace/index.js";
21
- import { fetchOptions, HTML_READ_CHARS, TEXT_CAP } from "./web-fetch-direct.js";
21
+ import { HTML_READ_CHARS, TEXT_CAP } from "@parcha/agentrun-web";
22
+ import { fetchOptions } from "./web-run.js";
22
23
  import { harnessIds, onAdapter } from "./harness-table.js";
23
24
  import { META_TOOLS } from "./meta-tool-names.js";
24
25
  import { localFolderOf } from "./workspace/local.js";
@@ -31,10 +32,10 @@ import { browserPrice, browserSpend } from "./browser-cost.js";
31
32
  import { sessionEnds } from "./browser-sessions.js";
32
33
  import { sessionRecordings } from "./computer-record.js";
33
34
  import { forModel } from "./result.js";
34
- import { fetchFor, pagesOf, WEB_FETCH_TOOL, webFetchTool } from "./web-fetch.js";
35
+ import { fetchFor, WEB_FETCH_TOOL, webFetchTool } from "./web-fetch.js";
35
36
  import { searchFor, WEB_SEARCH_TOOL, webSearchTool } from "./web-search.js";
36
37
  import { fakeFetch, fakeSaveOptions, fakeSearch } from "./web-fake.js";
37
- import { SAVE_MAX_BYTES, WEB_SAVE_TOOL, webSaveTool } from "./web-save.js";
38
+ import { LENGTH_TYPES, SAVE_MAX_BYTES, WEB_SAVE_TOOL, webSaveTool } from "./web-save.js";
38
39
  import { browserNeeds, explainsView, isUnavailable, NO_PARALLEL_KEY, PICKABLE, planeOf, PROVIDERS, serverGate, whyUnavailable, withDefaults } from "./tool-plane.js";
39
40
  import { fauxFetch, PARALLEL_KEY_ENV } from "./decisions.js";
40
41
  import { keyNeeded } from "./key-words.js";
@@ -48,6 +49,7 @@ import { runnerSecrets } from "./runner/redact.js";
48
49
  import { HANDOVER_WAITING } from "./runner/journal-kinds.js";
49
50
  import { provenFor } from "./live-reach.js";
50
51
  import { clearWaitEnded, markWaitEnded } from "./browser-wait-ended.js";
52
+ import { browserHoldWriter } from "./browser-hold.js";
51
53
  import { runSignIn, verifyRunSignIn } from "./sign-ins-store.js";
52
54
  import { held } from "./runner/held.js";
53
55
  export const ASK_TOOL = "ask_person";
@@ -114,9 +116,9 @@ const webFetchEntry = (name) => ({
114
116
  return { tools: [tool], extensions: [extension] };
115
117
  },
116
118
  // A call node's Page is the workflow's, not a model's context: it reads the most of a part by default, from the page
117
- // the run read (pagesOf(run.env)) where it holds the URL. Its request to Parallel, when it makes one, is booked under the call
119
+ // the run read (its Web's pages) where it holds the URL. Its request to Parallel, when it makes one, is booked under the call
118
120
  // (paid-calls.ts); a part from what the run read makes none and books nothing.
119
- effect: async (args, run) => bookedIn(run.ledger, async () => fetchFor(run.env, args.url, { ...(await fetchOptions(run.env, FAUX_ENV)), offset: args.offset, maxChars: args.max_chars ?? TEXT_CAP, pages: pagesOf(run.env), signal: run.signal })),
121
+ effect: async (args, run) => bookedIn(run.ledger, async () => fetchFor(run.env, args.url, { ...(await fetchOptions(run.env, FAUX_ENV)), offset: args.offset, maxChars: args.max_chars ?? TEXT_CAP, signal: run.signal })),
120
122
  });
121
123
  /** A file or shell tool: listed here for its words and its rules, bound by the run's workspace registry
122
124
  * (workspace/run-tools.ts), never by this table. */
@@ -372,6 +374,8 @@ const browserTool = {
372
374
  cursor = page.next;
373
375
  }
374
376
  }, context)) ?? [];
377
+ // The browser's take as the server reads it: written in order, and none from an earlier process of the run kept.
378
+ const holdWriter = host.store && host.claim ? browserHoldWriter(host.store.settings, host.claim.runId, host.claim.epoch) : undefined;
375
379
  const hands = person.personHands({
376
380
  gates,
377
381
  personTime: (what, seconds, options) => spend.personTime(what, seconds, options),
@@ -386,6 +390,8 @@ const browserTool = {
386
390
  if (host.store && host.claim)
387
391
  void markWaitEnded(host.store.settings, host.claim.runId, { at: new Date(at).toISOString(), why }, host.claim.epoch).catch(() => undefined);
388
392
  },
393
+ // Who drives the browser, for the run read's computer state (browser-hold.ts): one settings row while a take is live.
394
+ held: (tag, on, at) => void holdWriter?.held(tag, on, at),
389
395
  note: async (kind, data) => {
390
396
  // A hand-over's waiting entry, on the runner: the row says the run waits on the person in its browser from that
391
397
  // commit (the server tells run.needs_input by it), and no more from its answer's, whoever writes it.
@@ -617,7 +623,7 @@ export const TOOLS = Object.freeze({
617
623
  },
618
624
  [WEB_FETCH_TOOL]: webFetchEntry(WEB_FETCH_TOOL),
619
625
  [WEB_SEARCH_TOOL]: {
620
- summary: "Search the web: codex's own search (claude-agent's where it is picked), on pi the model provider's hosted search (Anthropic, OpenAI), with none of those Parallel's Search API where the server holds its key, else Firecrawl's keyless search with Exa's behind it; or the provider picked: { query, n? } -> { provider, query, results: [{ url, title, snippet, published? }], text? }, provider naming the one that served it, 1 to 25 results, each snippet at most 3,000 characters; { error } when the search gives no answer.",
626
+ summary: "Search the web: Parallel's Search API where the server holds its key, else Firecrawl's keyless search with Exa's behind it; or the provider picked, the harness's own search (claude-agent's, codex's) or on pi the model provider's hosted search (Anthropic, OpenAI) only where native is picked: { query, n? } -> { provider, query, results: [{ url, title, snippet, published? }], text? }, provider naming the one that served it, 1 to 25 results, each snippet at most 3,000 characters; { error } when the search gives no answer.",
621
627
  needs: [],
622
628
  nodes: true,
623
629
  // On the runner its hosted search goes through the run's own route (host.search, run.search), labelled web_search.
@@ -628,7 +634,7 @@ export const TOOLS = Object.freeze({
628
634
  // web_save (web-save.ts). It makes no paid request, so nothing books it. No node or call node names it: a workflow's
629
635
  // effect has only a local work path, not the run's Workspace.
630
636
  [WEB_SAVE_TOOL]: {
631
- summary: `Download one public file into the run's work/ (a bare name under media/), never overwriting: { url, path } -> { ok: true, path, bytes, content_type, duration_s?, url } (duration_s an mp3, wav, mp4 or m4a's length in seconds) or { ok: false, url, refused | error }; at most ${SAVE_MAX_BYTES / (1024 * 1024)} MiB, a media type only when its bytes agree.`,
637
+ summary: `Download one public file into the run's work/ (a bare name under media/), never overwriting: { url, path } -> { ok: true, path, bytes, content_type, duration_s?, url } (duration_s the length in seconds of an ${LENGTH_TYPES}) or { ok: false, url, refused | error }; at most ${SAVE_MAX_BYTES / (1024 * 1024)} MiB, a media type only when its bytes agree.`,
632
638
  needs: [],
633
639
  nodes: false,
634
640
  bind: async (host) => {
@@ -30,6 +30,10 @@ export interface TriggerTargetDeps {
30
30
  /** `work`, a write that may open run `runId` of agent `agentId` again, done in the agent's delete turn (server.ts
31
31
  * runWrite): never under a purge of the run, and 410 purged after one. */
32
32
  runWrite<T>(agentId: string, runId: string, work: () => Promise<T>): Promise<T>;
33
+ /** `text` as a message to run `runId` is written: cut of what the run holds now (server.ts cutHeld), read inside the
34
+ * turn that writes it (runWrite), as a person's message is. A run whose seal doesn't open here refuses it (ApiError
35
+ * WITHHELD_MESSAGE): the firing skips with those words, never writes it uncut. */
36
+ cutHeld(runId: string, text: string): Promise<string>;
33
37
  /** A run's v2 status, or null for an unknown run (the run view): the trigger engine's overlap and active-run checks. */
34
38
  runStatus(runId: string): Promise<string | null>;
35
39
  /** A completed run's result.output as GET /runs/{id} serves it (cut of the secrets it holds; null when it has none), and
@@ -7,6 +7,7 @@
7
7
  import { ApiError, unsupported } from "./errors.js";
8
8
  import { message, startRun, WAITS_ON_A_PERSON } from "./runs-over-store.js";
9
9
  import { runOfOrigin } from "./store-reads/runs.js";
10
+ import { WITHHELD_MESSAGE } from "./handed-values.js";
10
11
  import { NATIVE_CAP_UNSUPPORTED, NATIVE_RUN_OVERRIDES_UNSUPPORTED, nativeOf, nativeRunOverrides } from "./native/binding.js";
11
12
  import { firingsOwe, keysOwedRefusal } from "./run-keys.js";
12
13
  import { isObject } from "./validate.js";
@@ -191,7 +192,9 @@ export function triggerTargets(store, deps) {
191
192
  const cap = handedCap(target.max_cost_usd ?? agentCap, hostCap);
192
193
  const run = await startRun(store, deps.start, entry, { ...body, ...(cap !== undefined ? { max_cost_usd: cap } : {}), ...(target.effort ? { effort: target.effort } : {}) },
193
194
  // Titled from the trigger (the engine's titleOf: "<Source> <name>"), never from its input, a sender's markup.
194
- { trigger, origin: { key: trigger.firing_key }, capped: !native, from, ...(title ? { title } : {}), ...(host?.sealed ? { sealed: host.sealed } : {}), ...(host?.keys ? { keys: host.keys } : {}) });
195
+ // A host's start (`host`) starts the firing it was handed in the run's own write: refused, with nothing written,
196
+ // once that firing has moved (its host released it meanwhile).
197
+ { trigger, origin: { key: trigger.firing_key }, capped: !native, from, ...(title ? { title } : {}), ...(host?.sealed ? { sealed: host.sealed } : {}), ...(host?.keys ? { keys: host.keys } : {}), ...(host ? { firing: { triggerId: trigger.id, key: trigger.firing_key } } : {}) });
195
198
  return { run_id: run.id };
196
199
  },
197
200
  async message(target, input, key, from, bound) {
@@ -219,7 +222,9 @@ export function triggerTargets(store, deps) {
219
222
  // (store.triggers.message): a server that goes down after it never sends it again, and past the bound the firing
220
223
  // is skipped in words. A firing no longer due there (already sent) writes nothing.
221
224
  const triggerId = from.trigger_id;
222
- const queued = await deps.runWrite(run.agentId, run.id, () => message(store, run, String(input.content), {
225
+ // Its text is cut of what the run holds, read in the turn that writes it: a firing hands no key, but its text (its
226
+ // content, the payload it carries) may say one the run was handed, which the run's end erases.
227
+ const queued = await deps.runWrite(run.agentId, run.id, async () => message(store, run, await deps.cutHeld(run.id, String(input.content)), {
223
228
  answers: false,
224
229
  origin: from,
225
230
  requestId: key,
@@ -235,6 +240,8 @@ export function triggerTargets(store, deps) {
235
240
  catch (error) {
236
241
  if (error instanceof ApiError && error.message === WAITS_ON_A_PERSON)
237
242
  return { skipped: WAITS_ON_A_PERSON };
243
+ if (error instanceof ApiError && error.message === WITHHELD_MESSAGE)
244
+ return { skipped: WITHHELD_MESSAGE };
238
245
  throw error;
239
246
  }
240
247
  },