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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/CHANGELOG.md +238 -0
  2. package/README.md +739 -116
  3. package/dist/adapters.d.ts +35 -6
  4. package/dist/adapters.js +152 -26
  5. package/dist/agents.d.ts +18 -7
  6. package/dist/agents.js +19 -10
  7. package/dist/app.js +101 -26
  8. package/dist/background.d.ts +29 -0
  9. package/dist/background.js +397 -0
  10. package/dist/box-egress-vm.d.ts +125 -0
  11. package/dist/box-egress-vm.js +350 -0
  12. package/dist/box-egress.d.ts +99 -0
  13. package/dist/box-egress.js +259 -0
  14. package/dist/box-image.d.ts +1 -1
  15. package/dist/box-image.js +9 -7
  16. package/dist/box-relay-vm.d.ts +84 -0
  17. package/dist/box-relay-vm.js +410 -0
  18. package/dist/box-relay.d.ts +8 -5
  19. package/dist/box-relay.js +14 -9
  20. package/dist/boxes.d.ts +28 -5
  21. package/dist/boxes.js +44 -18
  22. package/dist/browser-cost.d.ts +41 -0
  23. package/dist/browser-cost.js +158 -0
  24. package/dist/cap.d.ts +130 -21
  25. package/dist/cap.js +339 -67
  26. package/dist/cli.js +30 -4
  27. package/dist/coding-tools.d.ts +7 -3
  28. package/dist/coding-tools.js +16 -10
  29. package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
  30. package/dist/console/assets/index-CnJBf7Lc.js +486 -0
  31. package/dist/console/assets/index-DUHbWcIP.css +1 -0
  32. package/dist/console/index.html +2 -2
  33. package/dist/content-filter.d.ts +7 -0
  34. package/dist/content-filter.js +23 -0
  35. package/dist/decision-rows.d.ts +11 -3
  36. package/dist/decision-rows.js +18 -11
  37. package/dist/decisions.d.ts +3 -3
  38. package/dist/decisions.js +4 -3
  39. package/dist/errors.d.ts +2 -0
  40. package/dist/errors.js +5 -2
  41. package/dist/files.d.ts +9 -1
  42. package/dist/files.js +10 -2
  43. package/dist/grade.d.ts +11 -11
  44. package/dist/grade.js +43 -55
  45. package/dist/graph-served.d.ts +23 -0
  46. package/dist/graph-served.js +75 -0
  47. package/dist/graph-view.d.ts +7 -5
  48. package/dist/graph-view.js +10 -3
  49. package/dist/harness-app.d.ts +4 -2
  50. package/dist/harness-app.js +110 -19
  51. package/dist/harness-opencode/adapter.d.ts +45 -0
  52. package/dist/harness-opencode/adapter.js +272 -0
  53. package/dist/harness-opencode/binary.d.ts +18 -0
  54. package/dist/harness-opencode/binary.js +87 -0
  55. package/dist/harness-opencode/config.d.ts +24 -0
  56. package/dist/harness-opencode/config.js +61 -0
  57. package/dist/harness-opencode/harness.d.ts +77 -0
  58. package/dist/harness-opencode/harness.js +620 -0
  59. package/dist/harness-opencode/host/mcp.d.ts +40 -0
  60. package/dist/harness-opencode/host/mcp.js +208 -0
  61. package/dist/harness-opencode/host/policy.d.ts +71 -0
  62. package/dist/harness-opencode/host/policy.js +419 -0
  63. package/dist/harness-opencode/host/server.d.ts +55 -0
  64. package/dist/harness-opencode/host/server.js +165 -0
  65. package/dist/harness-opencode/index.d.ts +9 -0
  66. package/dist/harness-opencode/index.js +6 -0
  67. package/dist/harness-opencode/verify.d.ts +32 -0
  68. package/dist/harness-opencode/verify.js +75 -0
  69. package/dist/harness-opencode/versions.d.ts +33 -0
  70. package/dist/harness-opencode/versions.js +64 -0
  71. package/dist/harness.d.ts +4 -1
  72. package/dist/harness.js +5 -2
  73. package/dist/host-check.d.ts +12 -0
  74. package/dist/host-check.js +34 -0
  75. package/dist/host-tools.d.ts +12 -2
  76. package/dist/host-tools.js +26 -12
  77. package/dist/host.js +6 -2
  78. package/dist/hosted-search.js +5 -1
  79. package/dist/import.d.ts +2 -2
  80. package/dist/import.js +4 -3
  81. package/dist/key-check.d.ts +3 -2
  82. package/dist/key-check.js +7 -3
  83. package/dist/key-refusal.js +8 -4
  84. package/dist/key-words.d.ts +37 -0
  85. package/dist/key-words.js +40 -0
  86. package/dist/learn/check.d.ts +10 -1
  87. package/dist/learn/check.js +19 -1
  88. package/dist/learn/grade.d.ts +6 -2
  89. package/dist/learn/grade.js +28 -14
  90. package/dist/learn/index.d.ts +3 -3
  91. package/dist/learn/index.js +3 -3
  92. package/dist/learn/notes.js +2 -1
  93. package/dist/learn/reflect.d.ts +2 -2
  94. package/dist/learn/reflect.js +53 -5
  95. package/dist/learn/secrets.js +28 -8
  96. package/dist/learn/skills.d.ts +19 -4
  97. package/dist/learn/skills.js +95 -6
  98. package/dist/learned-workflow.d.ts +59 -0
  99. package/dist/learned-workflow.js +191 -0
  100. package/dist/learning-routes.d.ts +30 -1
  101. package/dist/learning-routes.js +173 -19
  102. package/dist/learning-run.d.ts +8 -6
  103. package/dist/learning-run.js +70 -27
  104. package/dist/learning-words.d.ts +12 -5
  105. package/dist/learning-words.js +34 -13
  106. package/dist/learning.d.ts +52 -3
  107. package/dist/learning.js +204 -4
  108. package/dist/mcp-gateway.d.ts +96 -0
  109. package/dist/mcp-gateway.js +408 -0
  110. package/dist/mcp-meta.d.ts +17 -0
  111. package/dist/mcp-meta.js +38 -0
  112. package/dist/mcp-servers.d.ts +33 -9
  113. package/dist/mcp-servers.js +58 -10
  114. package/dist/mcp.js +5 -5
  115. package/dist/model.d.ts +13 -11
  116. package/dist/model.js +11 -10
  117. package/dist/openapi/agentrun-v2.openapi.json +1 -0
  118. package/dist/openapi.js +407 -54
  119. package/dist/page.d.ts +2 -0
  120. package/dist/page.js +3 -0
  121. package/dist/paid-calls.d.ts +5 -1
  122. package/dist/paid-calls.js +1 -1
  123. package/dist/pause.d.ts +2 -0
  124. package/dist/place.d.ts +29 -5
  125. package/dist/place.js +51 -11
  126. package/dist/print.d.ts +7 -0
  127. package/dist/print.js +13 -0
  128. package/dist/propose.d.ts +2 -0
  129. package/dist/propose.js +38 -8
  130. package/dist/request-start.d.ts +12 -4
  131. package/dist/request-start.js +139 -15
  132. package/dist/run-box.d.ts +56 -4
  133. package/dist/run-box.js +183 -23
  134. package/dist/runnable.d.ts +13 -3
  135. package/dist/runnable.js +63 -6
  136. package/dist/runs.d.ts +266 -37
  137. package/dist/runs.js +884 -90
  138. package/dist/secrets.d.ts +27 -0
  139. package/dist/secrets.js +38 -2
  140. package/dist/server.d.ts +141 -36
  141. package/dist/server.js +562 -118
  142. package/dist/sign-ins.d.ts +99 -0
  143. package/dist/sign-ins.js +288 -0
  144. package/dist/skills.d.ts +16 -4
  145. package/dist/skills.js +35 -7
  146. package/dist/stats.d.ts +7 -2
  147. package/dist/stats.js +28 -7
  148. package/dist/tool-gate.d.ts +281 -0
  149. package/dist/tool-gate.js +585 -0
  150. package/dist/tool-keys.d.ts +48 -11
  151. package/dist/tool-keys.js +46 -8
  152. package/dist/tool-plane.d.ts +116 -27
  153. package/dist/tool-plane.js +232 -50
  154. package/dist/tools.d.ts +69 -14
  155. package/dist/tools.js +148 -26
  156. package/dist/trigger-secrets.d.ts +32 -0
  157. package/dist/trigger-secrets.js +143 -0
  158. package/dist/triggers.d.ts +439 -0
  159. package/dist/triggers.js +863 -0
  160. package/dist/turn-end.d.ts +3 -2
  161. package/dist/turn-end.js +3 -2
  162. package/dist/usage-lines.d.ts +26 -0
  163. package/dist/usage-lines.js +28 -0
  164. package/dist/validate.d.ts +2 -0
  165. package/dist/validate.js +11 -2
  166. package/dist/web-fetch.js +3 -3
  167. package/dist/webhooks.d.ts +11 -4
  168. package/dist/webhooks.js +17 -1
  169. package/launcher/agentrun-serve +1 -1
  170. package/package.json +16 -14
  171. package/dist/console/assets/index-BN7oVcO4.js +0 -445
  172. package/dist/console/assets/index-By-jkqki.css +0 -1
@@ -12,13 +12,23 @@
12
12
  // launch, from its pinned revision and the settings then, keeps them for the run's life (runs.ts), and hands the run's
13
13
  // process the outcome as a non-secret description (TOOL_PLANE_ENV): the run reads its tools' providers there, never from
14
14
  // a request.
15
+ //
16
+ // Each tool also has a permission, the tool gate's (tool-gate.ts): allow, ask or deny, the agent's over the server's over
17
+ // the owner's default (a built-in kernel tool allow, a third-party catalog tool ask, told apart by its name), read by
18
+ // the gate's one rule, permissionOf. A capability set to deny resolves to no provider where it is shown; under ask, a
19
+ // harness's own search (inside its CLI, where no call can wait for a person) gives way to the kernel's. A run is never
20
+ // told a deny: its Plane resolves a denied capability as under ask, and the gate, which reads the permission at each
21
+ // call, is the one place that refuses it, so a deny lifted mid-run is lifted at the next call.
15
22
  import { readFileSync } from "node:fs";
23
+ import { isToolSettingsKey } from "@parcha/pi-durable-agent";
16
24
  import { join } from "node:path";
17
25
  import { decisionKeysOf, PARALLEL_KEY_ENV } from "./decisions.js";
26
+ import { keyNeeded } from "./key-words.js";
18
27
  import { writeDurableSync } from "./files.js";
19
28
  import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
20
29
  import { savedIn } from "./secrets.js";
21
30
  import { hostModel, viaOpenRouter } from "./model.js";
31
+ import { isCatalogTool, isMcpTool, PERMISSIONS, permissionFrom, permissionOf, SHELL_FAMILY } from "./tool-gate.js";
22
32
  /**
23
33
  * The capabilities a pack or a revision may grant, by name: the tools the kernel gives a run, bound from serve's closed
24
34
  * table (tools.ts) and named the same on every harness that runs them. `web_search` and `web_fetch` resolve to a
@@ -32,17 +42,38 @@ export const CAPABILITIES = ["read", "write", "edit", "web_search", "web_fetch",
32
42
  * server holds its key, else keyless Exa; `native`, the harness's own tool or its model provider's hosted one, and
33
43
  * nothing else; `exa-keyless`, Exa's public MCP endpoint, no key; `kernel`, the guarded direct fetch; `parallel`,
34
44
  * Parallel's Search and Extract APIs on PARALLEL_API_KEY; `off`, web_search turned off: nothing is searched, and an
35
- * agent naming it is refused until it is turned on again. */
36
- export const PROVIDERS = Object.freeze({ web_search: ["auto", "native", "exa-keyless", "parallel", "off"], web_fetch: ["kernel", "parallel"] });
45
+ * agent naming it is refused until it is turned on again. The browser's: `auto`, Browserbase where the server holds its
46
+ * keys, else Kernel where it holds Kernel's; `browserbase` or `kernel`, that one alone; `chrome`, a Chrome on the
47
+ * server's own host, which no server sets up yet (browserBy). */
48
+ export const PROVIDERS = Object.freeze({ web_search: ["auto", "native", "exa-keyless", "parallel", "off"], web_fetch: ["kernel", "parallel"], browser: ["auto", "browserbase", "kernel", "chrome"] });
37
49
  export const PICKABLE = Object.keys(PROVIDERS);
38
50
  /** Older names a revision may still grant, and the capability each one is: `fetch_page` runs web_fetch, under its own
39
51
  * name, and resolves as web_fetch does. */
40
52
  export const LEGACY_NAMES = Object.freeze({ fetch_page: "web_fetch" });
41
53
  /** The capability a granted name runs: its legacy target, else itself. */
42
54
  export const capabilityOf = (name) => LEGACY_NAMES[name] ?? name;
55
+ /** Every tool of serve's table (tools.ts) and its legacy names, by name, so this module needs no import of it: a test
56
+ * holds the two as one. */
57
+ export const TABLE_TOOLS = ["read", "write", "edit", "bash", "ask_person", "fetch_page", "web_fetch", "web_search", "browser", "pdf_pages", "llm"];
58
+ /** The tools whose approved call the kernel runs itself, outside the model's turn (host-tools.ts's REPLAY): ask is
59
+ * offered for these and for catalog tools. Any other (browser, ask_person, the call-only ones) is allow or deny. The
60
+ * run's learned_workflow is one (tool-gate.ts runs an approved call of it on the run's own tools). */
61
+ export const ASKABLE = ["read", "write", "edit", "bash", "fetch_page", "web_fetch", "web_search", "learned_workflow"];
62
+ /** The permissions `name` may be set to. */
63
+ export const permissionsOf = (name) => (Object.hasOwn(SHELL_FAMILY, name) && SHELL_FAMILY[name] !== name ? permissionsOf(SHELL_FAMILY[name]) : ASKABLE.includes(name) || isCatalogTool(name) ? PERMISSIONS : ["allow", "deny"]);
64
+ /** The run's own tools beyond the table, each its own settings key, allowed by default like a table tool: the learned
65
+ * workflow a run's pin names runs as `learned_workflow` (learned-workflow.ts LEARNED_WORKFLOW_TOOL). */
66
+ export const SERVE_OWN_TOOLS = ["learned_workflow"];
67
+ /** A settings key: a tool of the table, one of the run's own tools (SERVE_OWN_TOOLS), a catalog tool (`monid.<tool>`,
68
+ * `mcp:<server>/<tool>`), or an MCP server's wildcard (`mcp:<server>/*`), which sets each of its tools. */
69
+ const isSettingsKey = (name) => isToolSettingsKey(name) && ((TABLE_TOOLS.includes(name) && !Object.hasOwn(LEGACY_NAMES, name)) || SERVE_OWN_TOOLS.includes(name) || isCatalogTool(name) || /^mcp:[^/]+\/\*$/.test(name));
43
70
  export const NO_PARALLEL_KEY = "unavailable: parallel picked, no PARALLEL_API_KEY";
44
71
  /** web_search with `off` picked: no search leaves the server. */
45
72
  export const SEARCH_OFF = "unavailable: web_search is turned off in settings";
73
+ /** A capability set to deny: no provider is asked, and the gate refuses each call, so its run still starts. */
74
+ export const DENIED = "unavailable: denied";
75
+ /** `native` picked for a capability set to ask on a harness whose own search runs inside its CLI. */
76
+ export const NATIVE_ASKS = "unavailable: native search cannot wait for an approval";
46
77
  /** The model providers whose hosted web search pi's web_search asks (hosted-search.ts), by pi-ai's provider id. */
47
78
  export const HOSTED_SEARCH_PROVIDERS = ["anthropic", "openai"];
48
79
  /** Why claude-agent has no native search under a spend cap, and what works there instead. */
@@ -65,6 +96,9 @@ function noNative(input) {
65
96
  return input.capped ? { id: CLAUDE_CAPPED, why: "under a spend cap Claude's own search is not offered, since a cap cannot reserve its per-use fees yet" } : undefined;
66
97
  if (input.harness === "codex")
67
98
  return input.gateway ? { id: "codex behind a gateway", why: "behind a gateway Codex has no own search" } : input.capped ? { id: "codex under a spend cap", why: "under a spend cap Codex's own search is not offered, since its request has no input bound" } : undefined;
99
+ // OpenCode has none: its model requests carry no provider-hosted tool (its proxy policy refuses one).
100
+ if (input.harness === "opencode")
101
+ return { id: "opencode, whose model requests carry no provider-hosted tool", why: "OpenCode's model requests carry no provider-hosted tool" };
68
102
  if (input.gateway)
69
103
  return { id: `${input.harness} behind a gateway`, why: `behind a gateway ${input.harness} has no hosted search` };
70
104
  if (vendor && HOSTED_SEARCH_PROVIDERS.includes(vendor))
@@ -79,15 +113,25 @@ export function explainCapability(capability, input) {
79
113
  const chosen = input.override ?? input.pick ?? PROVIDERS[capability][0];
80
114
  const picked = input.override !== undefined ? "picked for this agent" : "picked in settings";
81
115
  const key = `your Parallel key (${input.parallelKeyFrom ?? "server"})`;
116
+ if (input.permission === "deny")
117
+ return { resolves: DENIED, why: "set to deny: the gate refuses each call" };
82
118
  if (chosen === "off")
83
119
  return { resolves: SEARCH_OFF, why: "turned off in settings" };
84
120
  if (chosen === "parallel")
85
- return input.parallelKey ? { resolves: "parallel", why: `Parallel, ${picked}: ${key}` } : { resolves: NO_PARALLEL_KEY, why: "Parallel is picked, and no PARALLEL_API_KEY is set or saved" };
121
+ return input.parallelKey ? { resolves: "parallel", why: `Parallel, ${picked}: ${key}` } : { resolves: NO_PARALLEL_KEY, why: `Parallel is picked, and it needs ${keyNeeded([PARALLEL_KEY_ENV])}` };
86
122
  if (capability === "web_fetch")
87
123
  return { resolves: "kernel", why: "the guarded direct fetch" };
124
+ if (capability === "browser")
125
+ return browserBy(chosen, picked, input.browserKeys);
88
126
  if (chosen === "exa-keyless")
89
127
  return { resolves: "exa-keyless", why: `keyless Exa, ${picked}: Exa's free search, no key` };
90
- const none = noNative(input);
128
+ // Under ask, a harness's own search runs inside its CLI, where no call can wait for a person: none on claude-agent or
129
+ // 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.
130
+ const asks = input.permission === "ask" && input.harness !== DEFAULT_HARNESS;
131
+ const without = noNative(input);
132
+ if (chosen === "native" && asks && without === undefined)
133
+ return { resolves: NATIVE_ASKS, why: "native search cannot wait for an approval: it runs inside the harness's CLI" };
134
+ const none = without ?? (asks ? { id: input.harness, why: "under ask the harness's own search cannot wait for a person's approval" } : undefined);
91
135
  if (chosen === "native")
92
136
  return none === undefined ? { resolves: "native", why: nativeWhy(input) } : { resolves: `unavailable: no native search for ${none.id}`, why: `no native search for ${none.id}` };
93
137
  // On claude-agent `auto` skips Claude's own search, an explicit pick (`native`): Parallel on the server's key, else
@@ -102,11 +146,47 @@ export function explainCapability(capability, input) {
102
146
  export const resolveCapability = (capability, input) => explainCapability(capability, input).resolves;
103
147
  export const isUnavailable = (resolution) => resolution?.startsWith("unavailable: ") === true;
104
148
  /** Why a resolution is unavailable: its words after "unavailable: " (any other resolution as it is). */
105
- export const whyUnavailable = (resolution) => resolution.replace(/^unavailable: /, "");
149
+ /** Why `resolution` is unavailable, in words. A vendor picked whose key this server does not hold (its value, kept in a
150
+ * run's meta and read back, names the variables) names where to save the key first, then the variable to set. */
151
+ export const whyUnavailable = (resolution) => {
152
+ if (resolution === NO_BROWSER_KEY)
153
+ return `it needs ${keyNeeded(BROWSER_KEYS.browserbase)}, or ${keyNeeded(BROWSER_KEYS.kernel)}`;
154
+ const why = resolution.replace(/^unavailable: /, "");
155
+ const picked = /^(\S+) picked, no (.+)$/.exec(why);
156
+ return picked ? `${picked[1]} is picked, and it needs ${keyNeeded(picked[2].split(" and "))}` : why;
157
+ };
158
+ /** The keys each of the browser's vendors needs, by name: a tool key's fields (tool-keys.ts), set or saved. Its plane
159
+ * value is the vendor's id: `kernel` on browser is Kernel's hosted browser, never the guarded fetch web_fetch calls so. */
160
+ export const BROWSER_KEYS = Object.freeze({ browserbase: ["BROWSERBASE_API_KEY", "BROWSERBASE_PROJECT_ID"], kernel: ["KERNEL_API_KEY"] });
161
+ const LABELS = { browserbase: "Browserbase", kernel: "Kernel" };
162
+ const isVendor = (name) => name === "browserbase" || name === "kernel";
163
+ const browserKeysOf = (env) => ({ browserbase: BROWSER_KEYS.browserbase.every((name) => Boolean(env[name])), kernel: BROWSER_KEYS.kernel.every((name) => Boolean(env[name])) });
164
+ /** A vendor picked whose keys the server does not hold: unavailable, never the other vendor. */
165
+ const noBrowserKey = (vendor) => `unavailable: ${vendor} picked, no ${BROWSER_KEYS[vendor].join(" and ")}`;
166
+ /** The keys a browser that resolves to `resolution` runs on: its vendor's (BROWSER_KEYS), none for no vendor. */
167
+ export const browserNeeds = (resolution) => (isVendor(resolution) ? BROWSER_KEYS[resolution] : []);
168
+ /** `auto` where the server holds neither vendor's keys. */
169
+ export const NO_BROWSER_KEY = "unavailable: no browser key: set or save Browserbase's (BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID) or Kernel's (KERNEL_API_KEY)";
170
+ /** `chrome` picked: a Chrome on the server's own host, refused by name until a server can set one up. */
171
+ export const NO_CHROME = "unavailable: a local Chrome is not set up on this server";
172
+ /** The browser `chosen` (picked as `picked` says) resolves to with the vendors' `keys`: `auto` is Browserbase where its
173
+ * keys are held, else Kernel where its key is, else unavailable; a vendor picked is that vendor or unavailable; `chrome`
174
+ * is unavailable by name. */
175
+ function browserBy(chosen, picked, keys = { browserbase: false, kernel: false }) {
176
+ if (chosen === "chrome")
177
+ return { resolves: NO_CHROME, why: whyUnavailable(NO_CHROME) };
178
+ if (isVendor(chosen))
179
+ return keys[chosen] ? { resolves: chosen, why: `${LABELS[chosen]}, ${picked}` } : { resolves: noBrowserKey(chosen), why: `${LABELS[chosen]} is picked, and it needs ${keyNeeded(BROWSER_KEYS[chosen])}` };
180
+ if (keys.browserbase)
181
+ return { resolves: "browserbase", why: "Browserbase: its key is set or saved" };
182
+ if (keys.kernel)
183
+ return { resolves: "kernel", why: "Kernel: its key is set or saved, and Browserbase's is not" };
184
+ return { resolves: NO_BROWSER_KEY, why: whyUnavailable(NO_BROWSER_KEY) };
185
+ }
106
186
  /** The server's environment's part of every resolution: its gateway and Parallel's key, and where the key is from. */
107
187
  const served = (env) => {
108
188
  const parallelKey = PARALLEL_KEY_ENV in decisionKeysOf(env);
109
- return { gateway: Boolean(env.AGENT_MODEL_BASE_URL), parallelKey, ...(parallelKey ? { parallelKeyFrom: savedIn(env).has(PARALLEL_KEY_ENV) ? "saved" : "server" } : {}) };
189
+ return { gateway: Boolean(env.AGENT_MODEL_BASE_URL), parallelKey, browserKeys: browserKeysOf(env), ...(parallelKey ? { parallelKeyFrom: savedIn(env).has(PARALLEL_KEY_ENV) ? "saved" : "server" } : {}) };
110
190
  };
111
191
  /** Each pickable capability on each harness under the server's `settings` and an agent's `overrides`, on `model`
112
192
  * (default each harness's host model, the one a run that names none runs on: hostModel): what it resolves to and why, as
@@ -124,11 +204,14 @@ export function explainsView(env, settings, overrides = {}, model) {
124
204
  const picked = (name, settings, overrides = {}) => ({
125
205
  ...(overrides[name]?.provider ? { override: overrides[name].provider } : {}),
126
206
  ...(settings[name]?.provider ? { pick: settings[name].provider } : {}),
207
+ permission: permissionOf(name, settings, overrides),
127
208
  });
128
209
  /** The run's process's description of its tools' providers: JSON of its Plane. */
129
210
  export const TOOL_PLANE_ENV = "AGENTRUN_SERVE_TOOL_PLANE";
130
- /** The Plane of a run of `tooling`, in the server's `env` (with its secrets) under its `settings`. */
131
- export function planeFor(env, tooling, settings, { capped = false } = {}) {
211
+ /** The Plane of a run of `tooling`, in the server's `env` (with its secrets) under its `settings`. `run`: the Plane a
212
+ * run's process is handed, where a capability set to deny resolves as under ask (the provider a held call would use),
213
+ * since the gate refuses its calls while it is denied; else the one shown and checked, where it resolves denied. */
214
+ export function planeFor(env, tooling, settings, { capped = false, run = false } = {}) {
132
215
  const harness = tooling.harness ?? DEFAULT_HARNESS;
133
216
  // A workflow's model nodes may each run on another tier's model, and a native search asks one model's provider: a
134
217
  // workflow's search resolves with no model (keyless Exa, or Parallel where picked), never on a model a node may not use.
@@ -138,18 +221,57 @@ export function planeFor(env, tooling, settings, { capped = false } = {}) {
138
221
  const plane = {};
139
222
  const granted = tooling.tools.map(capabilityOf);
140
223
  for (const name of PICKABLE) {
141
- if (granted.includes(name))
142
- plane[name] = resolveCapability(name, { ...served(env), harness, capped, openRouter: viaOpenRouter(env, harness, model), ...(model ? { model } : {}), ...picked(name, settings, tooling.overrides) });
224
+ if (!granted.includes(name))
225
+ continue;
226
+ const chosen = picked(name, settings, tooling.overrides);
227
+ plane[name] = resolveCapability(name, { ...served(env), harness, capped, openRouter: viaOpenRouter(env, harness, model), ...(model ? { model } : {}), ...chosen, ...(run && chosen.permission === "deny" ? { permission: "ask" } : {}) });
143
228
  }
144
- if (plane.web_search === "native" && harness === DEFAULT_HARNESS && model)
229
+ // The model a search through its provider's hosted search asks (hosted-search.ts): pi's own web_search, and on
230
+ // another harness, whose agent searches with its own tool, a learned workflow's call node (learned-workflow.ts).
231
+ if (plane.web_search === "native" && model)
145
232
  plane.model = model;
146
233
  return plane;
147
234
  }
148
- /** A run's kept Plane at a later launch: as it was, but Parallel where the server no longer holds its key, which is
149
- * unavailable, never another provider. */
150
- export function recheckPlane(plane, env) {
235
+ /** A run's kept Plane at a later launch: as it was, but Parallel, or the browser's vendor, where the server no longer
236
+ * holds its key, which is unavailable, never another provider; and, given `now` (the Plane it would get today and each
237
+ * capability's permission today), a capability set to ask or deny, or kept denied, as it resolves today: a harness's
238
+ * own search cannot wait for a person, and a deny that was lifted is lifted. The browser keeps its vendor, whose
239
+ * sessions it has: only a deny it was kept with is lifted. */
240
+ export function recheckPlane(plane, env, now) {
151
241
  const keyed = served(env).parallelKey;
152
- return Object.fromEntries(Object.entries(plane).map(([name, value]) => [name, value === "parallel" && !keyed ? NO_PARALLEL_KEY : value]));
242
+ return Object.fromEntries(Object.entries(plane).map(([name, value]) => {
243
+ const fresh = name === "model" ? undefined : now?.fresh[name];
244
+ if (fresh !== undefined && (value === DENIED || (name !== "browser" && now.permission(name) !== "allow")))
245
+ return [name, fresh];
246
+ return [name, name === "browser" && isVendor(value) && !browserKeysOf(env)[value] ? noBrowserKey(value) : value === "parallel" && !keyed ? NO_PARALLEL_KEY : value];
247
+ }));
248
+ }
249
+ /** The Plane kept for a run made before its plane was kept, resolved at a later launch (runs.ts): its browser stays
250
+ * Browserbase, the one vendor there was then, never today's pick, which could check its sessions at another vendor. It
251
+ * keeps the vendor, never a refusal: the plane each launch hands over is checked again (recheckPlane), so Browserbase's
252
+ * keys missing make it unavailable for that launch alone, and restored keys make the next one run. */
253
+ export const keptFromBefore = (plane) => (plane.browser === undefined ? plane : { ...plane, browser: "browserbase" });
254
+ /** A run's saved Plane as a launch reads it: a vendor's missing-key refusal an earlier server saved (noBrowserKey's exact
255
+ * words, Browserbase's or Kernel's) is that vendor again, which the launch checks again as usual (recheckPlane), so
256
+ * restored keys make it run. Every other saved value stays as it is: `auto` with no key at a run's first launch
257
+ * (NO_BROWSER_KEY) and `chrome` stay frozen. The same Plane where nothing changes. */
258
+ export function keptVendor(plane) {
259
+ const vendor = Object.keys(BROWSER_KEYS).find((name) => plane.browser === noBrowserKey(name));
260
+ return vendor ? { ...plane, browser: vendor } : plane;
261
+ }
262
+ /** The key row (tool-keys.ts) of the browser's vendor on `resolution` with `picked` the provider in force: Kernel's where
263
+ * Kernel is picked or resolved, else Browserbase's, so a page links a missing key to the row it is saved on. */
264
+ export const browserKeyRow = (picked, resolution) => (picked === "kernel" || resolution === "kernel" ? "kernel" : "browserbase");
265
+ /** The Plane a run's process is handed at a launch, under the server's `settings` now: its kept Plane (as keptVendor
266
+ * reads it) checked again (recheckPlane) against the one it would get today; with none kept, today's, its browser kept
267
+ * (keptFromBefore). At a launch after its first (a relaunch, a follow-up's, one after a restart) a capability set
268
+ * to deny is handed denied (planeFor without `run`), the tool's own refusal backing the gate's; at its `first`, as
269
+ * under ask, so a deny lifted while that process lives is lifted at the next call. */
270
+ export function relaunchPlane(kept, env, tooling, settings, { capped = false, first = false } = {}) {
271
+ const fresh = tooling ? planeFor(env, tooling, settings, { capped, run: first }) : {};
272
+ if (kept)
273
+ return recheckPlane(kept, env, { fresh, permission: (name) => permissionOf(name, settings, tooling?.overrides ?? {}) });
274
+ return tooling ? recheckPlane(keptFromBefore(fresh), env) : {};
153
275
  }
154
276
  /** The Plane the server handed this run's process; empty when it handed none. */
155
277
  export function planeOf(env) {
@@ -163,80 +285,140 @@ export function planeOf(env) {
163
285
  }
164
286
  /** Whether a run is handed Parallel's key: one of its capabilities resolves to Parallel. */
165
287
  export const handsParallel = (plane) => PICKABLE.some((name) => plane[name] === "parallel");
166
- /** What a save of `permission` answers until the tool gate lands, so no one keeps a deny that nothing enforces. */
167
- export const NOT_YET = "permissions arrive with the tool gate";
168
- /** The issues of `value` as a settings map, its fields under `at` (none: a body's own): each capability that has a
169
- * choice to `{provider?}`, the provider one offered for it. */
288
+ /** The issues of `value` as a settings map, its fields under `at` (none: a body's own): each settings key (a tool of the
289
+ * table, a catalog tool, an MCP server's wildcard) to `{provider?, permission?}`, a provider only for a capability that
290
+ * has a choice and one offered for it, a permission one offered for the tool. */
170
291
  export function settingsIssues(value, at = "") {
171
292
  const field = (...names) => [at, ...names].filter(Boolean).join(".");
172
293
  const isPlain = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
173
294
  if (!isPlain(value))
174
- return [{ field: at || "body", reason: "wrong_type", message: `${at || "the body"} is an object of ${PICKABLE.join(", ")} to their settings` }];
295
+ return [{ field: at || "body", reason: "wrong_type", message: `${at || "the body"} is an object of tools to their settings` }];
175
296
  return Object.entries(value).flatMap(([name, setting]) => {
176
- if (!Object.hasOwn(PROVIDERS, name))
177
- return [{ field: field(name), reason: "not_allowed", message: `Tool settings are kept for ${PICKABLE.join(" and ")}; ${name} is not one of them.` }];
297
+ const pickable = Object.hasOwn(PROVIDERS, name);
298
+ if (!isSettingsKey(name))
299
+ return [{ field: field(name), reason: "not_allowed", message: `Tool settings are kept for this server's tools (${[...TABLE_TOOLS, ...SERVE_OWN_TOOLS].join(", ")}), catalog tools (monid.<tool>, mcp:<server>/<tool>) and an MCP server's tools (mcp:<server>/*); ${name} is none of them.` }];
178
300
  if (!isPlain(setting))
179
- return [{ field: field(name), reason: "wrong_type", message: `${field(name)} is an object, {provider}` }];
301
+ return [{ field: field(name), reason: "wrong_type", message: `${field(name)} is an object, {${pickable ? "provider, " : ""}permission}` }];
180
302
  return Object.entries(setting).flatMap(([key, given]) => {
181
- if (key === "permission")
182
- return [{ field: field(name, key), reason: "not_yet", message: NOT_YET }];
183
- if (key !== "provider")
303
+ if (key === "permission") {
304
+ // A wildcard sets each tool of its server's: a catalog tool's permissions.
305
+ const offered = permissionsOf(isMcpTool(name) ? name : name.replace(/\/\*$/, "/_"));
306
+ return offered.includes(given) ? [] : [{ field: field(name, key), reason: "not_an_option", message: `${field(name, key)} is one of ${offered.join(", ")}` }];
307
+ }
308
+ if (key !== "provider" || !pickable)
184
309
  return [{ field: field(name, key), reason: "not_allowed", message: `${field(name)} keeps no field ${key}.` }];
185
310
  const offered = PROVIDERS[name];
186
311
  return offered.includes(given) ? [] : [{ field: field(name, key), reason: "not_an_option", message: `${field(name, key)} is one of ${offered.join(", ")}` }];
187
312
  });
188
313
  });
189
314
  }
190
- /** `map` with each capability's provider, its default where none is picked. */
191
- export const withDefaults = (map) => Object.fromEntries(PICKABLE.map((name) => [name, { provider: map[name]?.provider ?? PROVIDERS[name][0] }]));
315
+ /** `map` with each capability's provider, its default where none is picked; a permission where one is set. */
316
+ export const withDefaults = (map) => ({
317
+ // As served: what is in force, never the internal mark of a stand-in.
318
+ ...Object.fromEntries(Object.entries(map).map(([name, setting]) => [name, setting && { ...(setting.provider ? { provider: setting.provider } : {}), ...(setting.permission ? { permission: setting.permission } : {}) }])),
319
+ ...Object.fromEntries(PICKABLE.map((name) => [name, { provider: map[name]?.provider ?? PROVIDERS[name][0], ...(map[name]?.permission ? { permission: map[name].permission } : {}) }])),
320
+ });
192
321
  /** The server's tool settings, beside the agent store in its data directory: not a secret, and not in store.sqlite,
193
322
  * which runs hold open. Read once at the start, written whole and durably (0600) at each PUT; a missing file is every
194
323
  * default, and so is one it cannot read, which it says in one line. */
324
+ /** The tool settings in `dir` as the server and the tool gate read them, failing closed: each entry that reads is kept;
325
+ * one that does not is dropped, but a known tool keeps what of it reads, and its permission, when not one offered,
326
+ * reads ask (deny where ask is not offered), never its allow default. `problems`: one line for each entry dropped or
327
+ * changed, naming the file and the field, never a value. `unreadable`: the file as a whole does not read (none, a
328
+ * missing file is every default). */
329
+ export function readToolSettings(dir) {
330
+ const file = join(dir, ToolSettings.FILE);
331
+ let read;
332
+ try {
333
+ read = JSON.parse(readFileSync(file, "utf8"));
334
+ }
335
+ catch (error) {
336
+ if (error.code === "ENOENT")
337
+ return { settings: {}, problems: [] };
338
+ return { settings: {}, problems: [`${file} does not read as JSON`], unreadable: true };
339
+ }
340
+ const isPlain = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
341
+ if (!isPlain(read))
342
+ return { settings: {}, problems: [`${file} is not an object of tools to their settings`], unreadable: true };
343
+ const settings = {};
344
+ const problems = [];
345
+ for (const [name, setting] of Object.entries(read)) {
346
+ const issues = settingsIssues({ [name]: setting });
347
+ if (!issues.length) {
348
+ settings[name] = setting;
349
+ continue;
350
+ }
351
+ problems.push(`${file}: ${issues.map((issue) => `${issue.field} ${issue.reason}`).join(", ")}`);
352
+ if (!isSettingsKey(name) || !isPlain(setting))
353
+ continue;
354
+ const kept = {};
355
+ if (typeof setting.provider === "string" && !settingsIssues({ [name]: { provider: setting.provider } }).length)
356
+ kept.provider = setting.provider;
357
+ if (setting.permission !== undefined) {
358
+ const offered = permissionsOf(isMcpTool(name) ? name : name.replace(/\/\*$/, "/_"));
359
+ if (offered.includes(setting.permission))
360
+ kept.permission = setting.permission;
361
+ else {
362
+ // Its fail-closed stand-in, marked so: an ask nobody set lets nothing run unasked (tool-gate.ts SHELL_WATCHERS).
363
+ kept.permission = offered.includes("ask") ? "ask" : "deny";
364
+ kept.fallback = true;
365
+ kept.raw = setting.permission;
366
+ }
367
+ }
368
+ if (Object.keys(kept).length)
369
+ settings[name] = kept;
370
+ }
371
+ return { settings, problems };
372
+ }
195
373
  export class ToolSettings {
196
374
  dir;
197
375
  static FILE = "tool-settings.json";
198
376
  current;
199
377
  constructor(dir, warn = (line) => void process.stderr.write(`${line}\n`)) {
200
378
  this.dir = dir;
201
- const file = join(dir, ToolSettings.FILE);
202
- let read = {};
203
- try {
204
- read = JSON.parse(readFileSync(file, "utf8"));
205
- }
206
- catch (error) {
207
- if (error.code !== "ENOENT")
208
- read = undefined;
209
- }
210
- const bad = read === undefined || settingsIssues(read).length > 0;
211
- if (bad)
212
- warn(`agentrun-serve: ${file} is not tool settings this server reads; every tool takes its default provider until a PUT /v2/settings/tools`);
213
- this.current = bad ? {} : read;
379
+ const { settings, problems, unreadable } = readToolSettings(dir);
380
+ for (const line of problems)
381
+ warn(`agentrun-serve: ${line}; ${unreadable ? "every tool takes its defaults" : "that entry is dropped (a permission that is not offered reads ask)"} until a PUT /v2/settings/tools`);
382
+ this.current = settings;
214
383
  }
215
384
  get() {
216
385
  return structuredClone(this.current);
217
386
  }
218
- /** Replaces the settings: a capability `map` leaves out takes its default. Durable before it returns. */
387
+ /** Replaces the settings: a tool `map` leaves out takes its defaults. Durable before it returns. */
219
388
  put(map) {
220
- const kept = Object.fromEntries(PICKABLE.flatMap((name) => (map[name]?.provider ? [[name, { provider: map[name].provider }]] : [])));
221
- writeDurableSync(join(this.dir, ToolSettings.FILE), `${JSON.stringify(kept)}\n`);
389
+ const kept = Object.fromEntries(Object.entries(map).flatMap(([name, setting]) => {
390
+ const set = { ...(setting?.provider ? { provider: setting.provider } : {}), ...(setting?.permission ? { permission: setting.permission } : {}) };
391
+ // A stand-in sent back as served (a client saves the whole map) is no choice: it stays a stand-in, and the file keeps
392
+ // the value as written, so neither this save nor a restart turns it into a permission set (tool-gate.ts
393
+ // SHELL_WATCHERS). A different permission is a choice, written as given.
394
+ const before = this.current[name];
395
+ if (before?.fallback && set.permission === before.permission)
396
+ Object.assign(set, { fallback: true, raw: before.raw });
397
+ return Object.keys(set).length ? [[name, set]] : [];
398
+ }));
399
+ const written = Object.fromEntries(Object.entries(kept).map(([name, setting]) => [name, { ...(setting.provider ? { provider: setting.provider } : {}), ...(setting.fallback ? { permission: setting.raw } : setting.permission ? { permission: setting.permission } : {}) }]));
400
+ writeDurableSync(join(this.dir, ToolSettings.FILE), `${JSON.stringify(written)}\n`);
222
401
  this.current = kept;
223
402
  return this.get();
224
403
  }
225
404
  }
226
- /** GET /v2/agents/{id}'s `tools`: each tool its current revision grants, in `order` (capabilities.tools'), and for one
227
- * with a provider choice the provider in force and where it came from (the agent's own settings, the server's, or the
228
- * default), the one that applies when the agent sets none (the server's), and what it resolves to on the agent's
229
- * harness and model. A tool with no choice is its name alone. */
405
+ /** GET /v2/agents/{id}'s `tools`: each tool its current revision grants, in `order` (capabilities.tools'), with its
406
+ * permission in force and where it came from (the agent's own settings, the server's, or the default), the one that
407
+ * applies when the agent sets none (the server's, else the default) and those it may be set to; and for one with a
408
+ * provider choice the provider in force and where it came from, the one that applies when the agent sets none, and what
409
+ * it resolves to on the agent's harness and model. */
230
410
  export function agentTools(env, settings, agent, order) {
231
411
  const plane = planeFor(env, agent, settings);
232
412
  const rank = (name) => order.indexOf(capabilityOf(name)) + (name in LEGACY_NAMES ? 0.5 : 0);
233
413
  return [...new Set(agent.tools)].sort((a, b) => rank(a) - rank(b)).map((name) => {
234
414
  const capability = capabilityOf(name);
415
+ const { permission, from } = permissionFrom(name, settings, (agent.overrides ?? {}));
416
+ const gate = { permission, permission_from: from, default_permission: permissionOf(name, settings), permissions: [...permissionsOf(name)] };
235
417
  if (!Object.hasOwn(PROVIDERS, capability))
236
- return { name };
418
+ return { name, ...gate };
237
419
  const pick = capability;
238
420
  const own = agent.overrides?.[pick]?.provider;
239
421
  const server = settings[pick]?.provider;
240
- return { name, provider: own ?? server ?? PROVIDERS[pick][0], provider_from: own ? "agent" : server ? "server" : "default", default_provider: server ?? PROVIDERS[pick][0], resolved: plane[pick] };
422
+ return { name, ...gate, provider: own ?? server ?? PROVIDERS[pick][0], provider_from: own ? "agent" : server ? "server" : "default", default_provider: server ?? PROVIDERS[pick][0], resolved: plane[pick] };
241
423
  });
242
424
  }
package/dist/tools.d.ts CHANGED
@@ -5,10 +5,11 @@ import type { Revision } from "@parcha/pi-durable-agent";
5
5
  import type { CodingSource } from "./coding-tools.js";
6
6
  import { type Complete } from "./llm.js";
7
7
  import { type Ledger } from "./paid-calls.js";
8
- import { type Tooling, type ToolSettingsMap } from "./tool-plane.js";
8
+ import { type Plane, type Tooling, type ToolSettingsMap } from "./tool-plane.js";
9
9
  export declare const ASK_TOOL = "ask_person";
10
- /** Under `--faux` only: a module whose default export gives the browser's `{ provider, driver }`, in place of
11
- * Browserbase's (the tests' fake backend). */
10
+ /** Under `--faux` only: a module whose default export gives the browser's `{ provider, driver }` for the run's
11
+ * environment, the vendor its plane names (`browserbase`, `kernel`) and the saved sign-in it was handed for that
12
+ * vendor (`{ provider, ref, save }`, or undefined), in place of that vendor's (the tests' fake backend). */
12
13
  export declare const FAUX_BROWSER_ENV = "AGENTRUN_SERVE_FAUX_BROWSER";
13
14
  /** What the result of `ask_person` says; the person's page shows the question as a waiting row. */
14
15
  export declare const asked: (question: string) => string;
@@ -83,6 +84,44 @@ export declare const evidenceIn: (work: string) => {
83
84
  bodyLine?: undefined;
84
85
  }>;
85
86
  };
87
+ /** The Browserbase contexts a run's browser may open: its agent's saved sign-in's alone, by its profile name, never one
88
+ * made here (nothing a run makes is kept for its agent). */
89
+ export declare const keptContexts: (ref: string | undefined) => {
90
+ clear: boolean;
91
+ resolve: (key: string) => Promise<string>;
92
+ };
93
+ /** Kernel's provider, opening the agent's saved profile (`ref`, its name at Kernel) where a session asks for the
94
+ * profile `default`: the policy, the session's record and the model see only that name. */
95
+ export declare const keptProfile: <P extends {
96
+ create(spec: {
97
+ profile?: {
98
+ name: string;
99
+ save: boolean;
100
+ };
101
+ }, signal: AbortSignal): unknown;
102
+ }>(provider: P, ref: string) => P;
103
+ /** `provider`, its sessions' profile as this launch was handed it, whatever the policy a conversation was made with (a
104
+ * follow-up's was made under an earlier launch, which may have had no sign-in, or another lease): with a sign-in, every
105
+ * session opens on the profile `default`, saving only as `kept.save` says; without one, none asks for a profile. */
106
+ export declare const asHanded: <P extends {
107
+ create(spec: {
108
+ profile?: {
109
+ name: string;
110
+ save: boolean;
111
+ };
112
+ }, signal: AbortSignal): unknown;
113
+ }>(provider: P, kept: {
114
+ save: boolean;
115
+ } | undefined) => P;
116
+ /** Whether a session's change is one that saved to the run's sign-in, in a run that saves (every session of it runs on
117
+ * the profile, asHanded, whatever its record names): let go by the run (its tool, its idle time, a relaunch, its close,
118
+ * its end), never one the vendor had already lost or never made. */
119
+ export declare const savedOnRelease: (row: {
120
+ session: {
121
+ resourceId: string | null;
122
+ releaseReason: string | null;
123
+ };
124
+ }, change: string) => boolean;
86
125
  export declare const TOOLS: Readonly<Record<string, ToolEntry>>;
87
126
  /** Every name a revision may name, those a workflow's model node may, and those a workflow's call node may run. */
88
127
  export declare const BOUND_TOOLS: readonly string[];
@@ -91,10 +130,20 @@ export declare const CALL_TOOLS: readonly string[];
91
130
  /** Whether `name` is one of `allowed`, or a legacy name for one (fetch_page, web_fetch's): a revision that names it
92
131
  * still saves and runs, though the table lists it no more. */
93
132
  export declare const allows: (allowed: readonly string[], name: string) => boolean;
94
- /** The tools a run's learned workflow draft may name (learn/check.ts): those of the agent's `granted` tools a workflow's
95
- * model or call node runs here (NODE_TOOLS, CALL_TOOLS), each as granted and by its capability's name. A harness's own
96
- * tool (Bash, exec_command, apply_patch) is never one, so the DSL refuses a draft that names it. */
97
- export declare const learnedWorkflowTools: (granted: readonly string[]) => string[];
133
+ /** The tools a run's learned workflow may name (learn/check.ts at learn time, learned-workflow.ts at a call): those of the
134
+ * agent's `granted` tools a workflow's call node runs here (CALL_TOOLS), each as granted and by its capability's name,
135
+ * and with the run's `plane`, none it resolves unavailable (its agent's own tool of the name does not run either). A
136
+ * learned model node runs without tools (learn/skills.ts MODEL_NODE_TOOLS), and a harness's own tool (Bash,
137
+ * exec_command, apply_patch) is never one, so the DSL refuses a draft that names it. */
138
+ export declare const learnedWorkflowTools: (granted: readonly string[], plane?: Plane) => string[];
139
+ /** The tools a learned draft may name (learnedWorkflowTools) that the gate allows: `permission` is what the gate holds a
140
+ * tool to now (tool-gate.ts permissionOf, or the run's gate's policy), by its capability's settings key, as the gate
141
+ * holds a legacy name. One set to ask or deny is left out of `tools`, so the end-of-run prompt never offers it, and named
142
+ * in `gated` with its setting, which the checker and a learned workflow's check before it runs refuse a draft for. */
143
+ export declare const learnedDraftTools: (granted: readonly string[], permission: (name: string) => string, plane?: Plane) => {
144
+ tools: string[];
145
+ gated: Record<string, string>;
146
+ };
98
147
  /** The tools a workflow names (`nodes` from workflowNodes): on its model nodes (`tools`), and on its `call` nodes
99
148
  * `via: "tool"` (`tool`). */
100
149
  export declare function workflowTools(nodes: readonly Record<string, unknown>[]): {
@@ -127,14 +176,20 @@ export declare function toolRefusal(names: readonly string[], env: NodeJS.Proces
127
176
  * sets none), the default, and what it resolves to on each harness under the server's `settings`: available where any
128
177
  * is not unavailable, and missing PARALLEL_API_KEY where Parallel is picked without it. An unavailable tool says why
129
178
  * (`reason`). `noBox`: why no box can run a sandbox-only tool here (place.ts noBoxReason), which leaves it
130
- * unavailable with that reason; undefined, a box can. */
131
- export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettingsMap, noBox?: string) => {
132
- providers?: ("auto" | "off" | "parallel" | "native" | "exa-keyless" | "kernel")[] | undefined;
179
+ * unavailable with that reason; undefined, a box can. `refused`: the variables of the keys this server was started with
180
+ * that their provider refused at the start (ToolKeys.refused), each with why: a tool that needs one is unavailable,
181
+ * saying that. Each tool also gives its permission under the server's settings (tool-gate.ts), the owner's default
182
+ * and the permissions it may be set to. */
183
+ export declare const toolsView: (env: NodeJS.ProcessEnv, settings?: ToolSettingsMap, noBox?: string, refused?: Readonly<Record<string, string>>) => {
184
+ providers?: ("browserbase" | "kernel" | "chrome" | "auto" | "off" | "parallel" | "native" | "exa-keyless")[] | undefined;
133
185
  provider?: string | undefined;
134
- default_provider?: "auto" | "kernel" | undefined;
135
- resolves?: Record<"pi" | "claude-agent" | "codex", import("./tool-plane.js").Resolution> | undefined;
136
- why?: Record<"pi" | "claude-agent" | "codex", string> | undefined;
137
- harnesses: ("pi" | "claude-agent" | "codex")[];
186
+ default_provider?: "kernel" | "auto" | undefined;
187
+ resolves?: Record<"pi" | "claude-agent" | "codex" | "opencode", import("./tool-plane.js").Resolution> | undefined;
188
+ why?: Record<"pi" | "claude-agent" | "codex" | "opencode", string> | undefined;
189
+ harnesses: ("pi" | "claude-agent" | "codex" | "opencode")[];
190
+ permission: "ask" | "deny" | "allow";
191
+ default_permission: "ask" | "deny" | "allow";
192
+ permissions: ("ask" | "deny" | "allow")[];
138
193
  missing?: string[] | undefined;
139
194
  reason?: string | undefined;
140
195
  available: boolean;