@dudko.dev/agent-web 0.0.40 → 0.0.42

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 (40) hide show
  1. package/README.md +305 -22
  2. package/dist/agent-web.js +169 -161
  3. package/dist/agent-web.js.map +1 -1
  4. package/dist/chunk-2MLHZ6LQ.js +510 -0
  5. package/dist/chunk-2MLHZ6LQ.js.map +1 -0
  6. package/dist/{chunk-TZITKUFW.js → chunk-DAREMCXF.js} +152 -20
  7. package/dist/chunk-DAREMCXF.js.map +1 -0
  8. package/dist/{chunk-V3JOK7EW.js → chunk-YPCHD6DV.js} +4 -2
  9. package/dist/chunk-YPCHD6DV.js.map +1 -0
  10. package/dist/chunk-ZSZSSJS4.js +973 -0
  11. package/dist/chunk-ZSZSSJS4.js.map +1 -0
  12. package/dist/elicitation-DS-84_bF.d.cts +680 -0
  13. package/dist/elicitation-DS-84_bF.d.ts +680 -0
  14. package/dist/index.cjs +1939 -225
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +692 -117
  17. package/dist/index.d.ts +692 -117
  18. package/dist/index.js +1325 -189
  19. package/dist/index.js.map +1 -1
  20. package/dist/mcp.cjs +2478 -49
  21. package/dist/mcp.cjs.map +1 -1
  22. package/dist/mcp.d.cts +291 -9
  23. package/dist/mcp.d.ts +291 -9
  24. package/dist/mcp.js +1578 -48
  25. package/dist/mcp.js.map +1 -1
  26. package/dist/{sandbox-KG6OUG24.js → sandbox-3VRX47UY.js} +21 -8
  27. package/dist/sandbox-3VRX47UY.js.map +1 -0
  28. package/dist/sandbox-worker.cjs +3 -1
  29. package/dist/sandbox-worker.cjs.map +1 -1
  30. package/dist/sandbox-worker.js +1 -1
  31. package/package.json +1 -1
  32. package/dist/chunk-A6ZJALLU.js +0 -254
  33. package/dist/chunk-A6ZJALLU.js.map +0 -1
  34. package/dist/chunk-CTXDKSDD.js +0 -39
  35. package/dist/chunk-CTXDKSDD.js.map +0 -1
  36. package/dist/chunk-TZITKUFW.js.map +0 -1
  37. package/dist/chunk-V3JOK7EW.js.map +0 -1
  38. package/dist/sandbox-KG6OUG24.js.map +0 -1
  39. package/dist/vault-BatBaRQP.d.cts +0 -36
  40. package/dist/vault-BatBaRQP.d.ts +0 -36
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { LanguageModel, ToolSet, Experimental_DecisionModel, FilePart, ImageModel, SpeechModel, TranscriptionModel, Tool, SystemModelMessage, ModelMessage, generateText, streamText } from 'ai';
2
- import { V as VaultOptions } from './vault-BatBaRQP.js';
3
- export { I as IndexedDBVault } from './vault-BatBaRQP.js';
1
+ import { LanguageModel, ToolSet, Experimental_DecisionModel, Tool, FilePart, ImageModel, SpeechModel, TranscriptionModel, SystemModelMessage, ModelMessage, generateText, streamText } from 'ai';
2
+ import { V as VaultOptions, M as McpSkillSource, a as McpSkillConsent, b as McpSkillGrants, c as McpSkillRunConsent, d as McpSkillConsentView, e as McpSkillSnapshotMemory, f as McpElicitationSchema, g as McpElicitationReason, h as McpAppToolResult } from './elicitation-DS-84_bF.js';
3
+ export { I as IndexedDBVault, i as MCP_APPS_EXTENSION, j as MCP_APP_MAX_HTML_CHARS, k as MCP_APP_MAX_RESULT_CHARS, l as MCP_APP_MIME_TYPE, m as MCP_SKILLS_EXTENSION, n as MCP_SKILLS_MAX_PER_SERVER, o as MCP_SKILLS_MAX_TOTAL, p as MCP_SKILL_BODY_MAX_CHARS, q as MCP_SKILL_CONSENTS, r as MCP_SKILL_CONSENT_DEFAULT, s as MCP_SKILL_DESCRIPTION_MAX_CHARS, t as MCP_SKILL_DIRECTORY_ENTRIES_MAX, u as MCP_SKILL_FILE_MAX_CHARS, v as MCP_SKILL_MAX_RESOURCES, w as MCP_SKILL_MAX_TOTAL_BYTES, x as MCP_SKILL_SNAPSHOTS_MAX_BYTES, y as MCP_SKILL_SNAPSHOT_MAX_DEPTH, z as MCP_SKILL_SNAPSHOT_MAX_DIRECTORIES, A as MCP_SKILL_URI_MAX_CHARS, B as McpAppCsp, C as McpAppPermissions, D as McpAppResource, E as McpAppVisibility, F as McpElicitationFieldSchema, G as McpSkillsOptions, H as McpSkillsSetting, S as SkillDirectoryListing, J as mcpAppOrigin, K as mcpSkillEntryRefusal, L as mcpSkillPreamble, N as mcpSkillUriRefusal } from './elicitation-DS-84_bF.js';
4
4
  import { A as AgentToolSet, a as AgentTool } from './types-DwSMj_Xs.js';
5
5
  export { p as promptHintOf } from './types-DwSMj_Xs.js';
6
6
  import { z, ZodType } from 'zod';
@@ -764,6 +764,16 @@ interface Skill {
764
764
  }[];
765
765
  /** Set on a skill the AGENT wrote (`config.learning`); absent on the host's own. */
766
766
  origin?: SkillOrigin;
767
+ /**
768
+ * Set on a skill an MCP server serves (`skills: true` on its config): which server, and the URI
769
+ * of its SKILL.md. Third-party text: loaded on demand, under a preamble that says so.
770
+ */
771
+ mcp?: McpSkillOrigin;
772
+ }
773
+ /** Where an MCP server's skill comes from: the server's key in the connection, its SKILL.md URI. */
774
+ interface McpSkillOrigin {
775
+ server: string;
776
+ uri: string;
767
777
  }
768
778
  /** Where a learned skill came from. */
769
779
  interface SkillOrigin {
@@ -802,15 +812,53 @@ declare const loadSkillFromUrl: (url: string, opts?: LoadSkillOptions) => Promis
802
812
  * agent's own, subordinate to the user - never as an instruction.
803
813
  */
804
814
  declare const learnedPreamble: (skill: Skill) => string;
815
+ /** What the person answered (`askMcpSkillConsent`). */
816
+ interface McpSkillAnswer {
817
+ approved: boolean;
818
+ /** "Always for this server". */
819
+ remember?: boolean;
820
+ reason?: string;
821
+ /** Who answered: a person, nobody (no handler), or nobody in time / the handler failed. */
822
+ by: 'person' | 'no-handler' | 'no-answer';
823
+ }
824
+ /**
825
+ * What a run hands the MCP skill paths so that a person can be asked: the agent's policy, the
826
+ * session's grants (shared with helpers), the run's own record, and the question itself.
827
+ */
828
+ interface McpSkillConsentScope {
829
+ agentConsent?: McpSkillConsent;
830
+ grants: McpSkillGrants;
831
+ run: McpSkillRunConsent;
832
+ ask: (input: unknown, skill: McpSkillConsentView, signal?: AbortSignal) => Promise<McpSkillAnswer>;
833
+ }
834
+ /**
835
+ * How a skill's text is introduced to the model: a lesson as the agent's own note, an MCP
836
+ * server's skill as third-party knowledge; the host's skills as they are.
837
+ */
838
+ declare const skillPreamble: (skill: Skill) => string;
805
839
  /** "- name: description" lines for the prompts. */
806
840
  declare const renderSkillIndex: (skills: Skill[]) => string;
807
841
  /** The full instructions of the active skills, within a total character budget. */
808
842
  declare const renderActiveSkills: (skills: Skill[]) => string;
843
+ /** What `createSkillTools` needs of the MCP servers whose skills are on (`skills` on a server). */
844
+ interface SkillToolsMcp {
845
+ /**
846
+ * The servers' skill sources (`collectMcpSkillSources`), fixed for the agent: they are named in
847
+ * load_skill's description (run-stable), which then takes `{ server, uri }` too.
848
+ */
849
+ sources: readonly McpSkillSource[];
850
+ /** The run's consent scope: a person is asked through the agent's approval gate. */
851
+ scope?: McpSkillConsentScope;
852
+ /** What the agent's snapshots of generated skills hold (a skill added by URI counts there). */
853
+ memory?: McpSkillSnapshotMemory;
854
+ }
809
855
  /**
810
856
  * The built-in `load_skill` / `read_skill_file` tools. `onLoad` fires when a
811
- * skill is loaded so the runner can keep it active for later steps.
857
+ * skill is loaded so the runner can keep it active for later steps. With `mcp`, an MCP server's
858
+ * skill enters the context only once the person let it in (`acquireMcpSkill`), and a skill a
859
+ * server names by URI can be loaded with `{ server, uri }`.
812
860
  */
813
- declare const createSkillTools: (skills: Skill[], onLoad?: (skill: Skill) => void) => ToolSet;
861
+ declare const createSkillTools: (skills: Skill[], onLoad?: (skill: Skill) => void, mcp?: SkillToolsMcp) => ToolSet;
814
862
 
815
863
  declare const SAVE_SKILL_TOOL = "save_skill";
816
864
  declare const FORGET_SKILL_TOOL = "forget_skill";
@@ -1097,9 +1145,10 @@ declare const createEgressTools: (egress: boolean | IEgressPolicy | undefined) =
1097
1145
 
1098
1146
  /**
1099
1147
  * What the `web_search` tools of the two agent packages share: the result shape and its caps, how
1100
- * a search engine's answer is cleaned before a model reads it, and the built-in adapters as pure
1101
- * request builders and response parsers (one HTTP call each). Pure, no imports: the request itself
1102
- * is made by each package's own safe fetch.
1148
+ * a search engine's answer is cleaned before a model reads it, and the one built-in provider
1149
+ * (Google Search through Gemini grounding) as a pure request builder and response parser (one
1150
+ * HTTP call). Pure, no imports, no clock: the request itself is made by each package's own safe
1151
+ * fetch.
1103
1152
  *
1104
1153
  * This file is a COPY, byte for byte, in `@dudko.dev/agent` (`src/web-search-shared.ts`) and
1105
1154
  * `@dudko.dev/agent-web` (`src/tools/web-search-shared.ts`): change both. The Node package's
@@ -1143,11 +1192,24 @@ interface ISearchOptions {
1143
1192
  * returns is treated like a built-in adapter's answer - cleaned, capped and filtered.
1144
1193
  */
1145
1194
  type SearchEngine = (query: string, options: ISearchOptions) => Promise<ISearchResult[]>;
1146
- /** The hosted search APIs with a built-in adapter. */
1147
- type SearchProvider = 'brave' | 'tavily' | 'searxng';
1195
+ /**
1196
+ * The built-in provider. One: Google Search through the Gemini API's grounding (`google_search`),
1197
+ * which needs a Gemini (Google AI Studio) key and nothing else. Any other search API is the
1198
+ * host's `engine` function.
1199
+ */
1200
+ type SearchProvider = 'google';
1148
1201
  declare const SEARCH_PROVIDERS: readonly SearchProvider[];
1149
- /** Where each hosted API lives. SearXNG is self-hosted: its `baseURL` is the host's to give. */
1150
- declare const SEARCH_API_BASE_URL: Record<'brave' | 'tavily', string>;
1202
+ /** Where the provider's API lives (a `baseURL` of the host - a gateway - replaces it). */
1203
+ declare const SEARCH_API_BASE_URL: Record<SearchProvider, string>;
1204
+ /**
1205
+ * The model the grounding call is made with when the host names none: the cheapest one that
1206
+ * answered a free-tier key with grounding on the day it was measured (2026-11-26).
1207
+ */
1208
+ declare const SEARCH_GOOGLE_DEFAULT_MODEL = "gemini-2.5-flash-lite";
1209
+ /** The most of the grounding model's answer a model sees as `summary`. */
1210
+ declare const SEARCH_MAX_SUMMARY_CHARS = 1000;
1211
+ /** Said in every result of the google provider: what its URLs and its text are. */
1212
+ declare const SEARCH_GOOGLE_NOTE: string;
1151
1213
  /** One HTTP call to a search API. The key, if any, is in `headers` only - never in the URL. */
1152
1214
  interface ISearchRequest {
1153
1215
  url: string;
@@ -1162,19 +1224,48 @@ interface ISearchRequestInput {
1162
1224
  freshness?: SearchFreshness;
1163
1225
  apiKey?: string;
1164
1226
  baseURL?: string;
1227
+ /** The Gemini model that makes the grounding call (default SEARCH_GOOGLE_DEFAULT_MODEL). */
1228
+ model?: string;
1229
+ /** The current time in ms, for `freshness` (this file reads no clock). */
1230
+ now?: number;
1231
+ }
1232
+ /** What a search spent in model tokens, as the API reported it. */
1233
+ interface ISearchUsage {
1234
+ inputTokens: number;
1235
+ outputTokens: number;
1236
+ totalTokens: number;
1237
+ reasoningTokens: number;
1238
+ }
1239
+ /** A provider's answer, parsed: raw third-party values until `sanitizeSearchResults`. */
1240
+ interface ISearchAnswer {
1241
+ results: unknown[];
1242
+ /** The grounding model's whole answer (raw). */
1243
+ summary?: unknown;
1244
+ /** Absent when the API reported none. */
1245
+ usage?: ISearchUsage;
1165
1246
  }
1166
1247
  /**
1167
- * The request for one query, per the API's public documentation:
1168
- * - brave: GET {base}/res/v1/web/search?q=&count= header X-Subscription-Token
1169
- * - tavily: POST {base}/search { query, max_results } header Authorization: Bearer
1170
- * - searxng: GET {base}/search?q=&format=json no key
1248
+ * The request for one query, per the Gemini API's public documentation:
1249
+ * POST {base}/v1beta/models/{model}:generateContent header x-goog-api-key
1250
+ * { systemInstruction, contents: [the query], tools: [{ google_search }], generationConfig }
1251
+ * The query is the only text of the conversation in it. The API has no result count: the list
1252
+ * is cut on the way back.
1171
1253
  */
1172
1254
  declare const buildSearchRequest: (input: ISearchRequestInput) => ISearchRequest;
1173
1255
  /**
1174
- * The results inside an API's JSON answer, mapped to `{ title, url, snippet, date }` and nothing
1175
- * else. Still raw third-party values: `sanitizeSearchResults` is what makes them safe to show.
1256
+ * What a grounded answer holds, mapped to results of `{ title, url, snippet }` and nothing else,
1257
+ * the model's answer, and what the call spent. A source is a `groundingChunks[].web` (`uri` is a
1258
+ * Google redirect link, `title` the site's name); its snippet is the pieces of the answer that
1259
+ * `groundingSupports` attribute to it (fragments as the API cut them, joined with an ellipsis). Still raw third-party values: `sanitizeSearchResults` is
1260
+ * what makes them safe to show.
1261
+ */
1262
+ declare const parseSearchResponse: (provider: SearchProvider, json: unknown) => ISearchAnswer;
1263
+ /**
1264
+ * What a failed call says to the model: the provider, the model, the status, the API's own error
1265
+ * code word and what it usually means. Never the error's text: that is third-party text, and may
1266
+ * echo what was sent. `body` is the parsed error body, if there was one.
1176
1267
  */
1177
- declare const parseSearchResponse: (provider: SearchProvider, json: unknown) => unknown[];
1268
+ declare const searchStatusMessage: (provider: SearchProvider, status: number, model?: string, body?: unknown) => string;
1178
1269
  interface ISanitizedSearch {
1179
1270
  results: ISearchResult[];
1180
1271
  /** Results dropped because the host's egress policy does not let the model reach them. */
@@ -1185,49 +1276,73 @@ interface ISanitizedSearch {
1185
1276
  /**
1186
1277
  * What a model sees of an engine's answer. `raw` is whatever came back - nothing about it is
1187
1278
  * trusted: a result needs a valid http(s) URL, every field is cleaned and capped, duplicates go,
1188
- * `accepts` (the egress policy) drops links the model could not fetch, and the list stops at
1189
- * `maxResults` and at SEARCH_MAX_TOTAL_CHARS.
1279
+ * `accepts` (the egress policy; it is also handed the result's raw title) drops links the model
1280
+ * could not fetch, and the list stops at `maxResults` and at SEARCH_MAX_TOTAL_CHARS.
1190
1281
  */
1191
1282
  declare const sanitizeSearchResults: (raw: unknown, options?: {
1192
1283
  maxResults?: number;
1193
- accepts?: (url: URL) => boolean;
1284
+ accepts?: (url: URL, title: unknown) => boolean;
1194
1285
  }) => ISanitizedSearch;
1286
+ /** What `web_search` returns to the model. */
1287
+ interface ISearchToolResult {
1288
+ query: string;
1289
+ results: ISearchResult[];
1290
+ /** The google provider, when no source came with a snippet: the grounding model's answer, cut. */
1291
+ summary?: string;
1292
+ /** The google provider: what its URLs and its text are. */
1293
+ note?: string;
1294
+ filtered?: number;
1295
+ truncated?: true;
1296
+ untrusted: true;
1297
+ }
1298
+ /**
1299
+ * The tool's result, from the cleaned list and - for the google provider - the parsed answer.
1300
+ * The model's `summary` is attached only when there are sources, none of them carries a snippet
1301
+ * and none was filtered out: a summary cannot be cut to the sources that remain.
1302
+ */
1303
+ declare const searchToolResult: (query: string, clean: ISanitizedSearch, answer?: ISearchAnswer) => ISearchToolResult;
1195
1304
 
1196
1305
  /**
1197
1306
  * `config.search`: the `web_search` tool, the companion of `web_fetch`. Off unless set. The
1198
- * library ships no key and no engine of its own: the host names a hosted search API (a built-in
1199
- * adapter, one HTTP call) or passes a function. Browser sibling of the server's `ISearchConfig`
1200
- * - same names - except that a key is never written here: `credentialRef` names it in the
1201
- * `CredentialStore` the agent was given (`config.credentials`).
1307
+ * library ships no key: the host passes a search engine of its own (a function - any search API)
1308
+ * or names the one built-in provider, Google Search through Gemini grounding. Browser sibling of
1309
+ * the server's `ISearchConfig` - same names - except that a key is never written here:
1310
+ * `credentialRef` names it in the `CredentialStore` the agent was given (`config.credentials`).
1202
1311
  *
1203
- * A page can call an API only if that API allows cross-origin requests. Tavily does; Brave does
1204
- * not answer a preflight (use a gateway of yours as `baseURL`); a SearXNG instance does only if
1205
- * you configure it to (or serve it from your own origin). See docs/capabilities.md.
1312
+ * The Gemini API answers a page directly (CORS). See docs/capabilities.md.
1206
1313
  */
1207
1314
  interface ISearchConfig {
1208
1315
  /**
1209
1316
  * A search engine of your own: `(query, { maxResults, freshness, signal }) => results`. Its
1210
1317
  * requests are yours (like a tool you pass); its results are cleaned, capped and filtered like
1211
- * an adapter's. Exactly one of `engine` / `provider`.
1318
+ * the provider's. Exactly one of `engine` / `provider`.
1212
1319
  */
1213
1320
  engine?: SearchEngine;
1214
- /** A built-in adapter: 'brave' | 'tavily' | 'searxng'. */
1321
+ /**
1322
+ * The built-in provider: 'google' - Google Search through the Gemini API's grounding. One
1323
+ * generateContent call per search with the `google_search` tool: it needs a Gemini (Google AI
1324
+ * Studio) key and nothing else, and it spends that model's tokens (counted in the run's usage,
1325
+ * phase 'search'). Result URLs are Google redirect links, snippets the model's own summary.
1326
+ */
1215
1327
  provider?: SearchProvider;
1216
1328
  /**
1217
- * Where the provider's API key is kept in the agent's `CredentialStore`. Read at each call and
1218
- * sent in a header to that API only; never in a URL, an event, a log line, an error or a result.
1329
+ * Where the Gemini API key is kept in the agent's `CredentialStore` (it can be the ref of a
1330
+ * Gemini model's own key). Read at each call and sent in a header to that API only; never in a
1331
+ * URL, an event, a log line, an error or a result.
1219
1332
  */
1220
1333
  credentialRef?: string;
1334
+ /** The Gemini model that makes the grounding call. Default 'gemini-2.5-flash-lite'. */
1335
+ model?: string;
1221
1336
  /**
1222
- * Where the API lives. Required for 'searxng' (your instance); for the others it replaces the
1223
- * public endpoint (a gateway of yours that holds the key - `credentialRef` is then optional).
1337
+ * Replaces the public endpoint (a gateway of yours that holds the key - `credentialRef` is
1338
+ * then optional).
1224
1339
  */
1225
1340
  baseURL?: string;
1226
1341
  /** Results per call when the model does not say (default 5, at most 10). */
1227
1342
  maxResults?: number;
1228
1343
  /**
1229
1344
  * Let the SEARCH API itself be on a private / loopback address or an internal-looking name (a
1230
- * self-hosted SearXNG). It widens nothing else: the request can still reach only that one host.
1345
+ * gateway of yours). It widens nothing else: the request can still reach only that one host.
1231
1346
  */
1232
1347
  allowPrivateNetwork?: boolean;
1233
1348
  /** Whole request to the search API, in ms. Default 15_000. */
@@ -1261,6 +1376,12 @@ declare const searchEgressPolicy: (search: ISearchConfig, egress?: boolean | IEg
1261
1376
  * request goes through the guarded fetch under `searchEgressPolicy`; what comes back is
1262
1377
  * third-party text and is cleaned, capped and - when the agent has an egress policy - filtered
1263
1378
  * to what `web_fetch` could open, so a search is not a way to read around the allow / deny lists.
1379
+ *
1380
+ * The google provider's links are Google redirect links: the filter can judge only that host
1381
+ * (plus the site the API names, which is enough to drop a denied site and never to allow one).
1382
+ * Nothing here follows them. `web_fetch` opens one only under `egress.followRedirects` (the
1383
+ * guarded fetch then judges where it ended) and, from a page, only through an `egress.fetch`
1384
+ * of the host's: the redirect host sends no CORS headers.
1264
1385
  */
1265
1386
  declare const createWebSearchTool: (options: IWebSearchOptions) => AgentTool;
1266
1387
  /** The tools `config.search` turns on (none when it is off). */
@@ -1529,15 +1650,154 @@ declare const normalizePipeline: (definition: PipelineDefinition) => PipelineDef
1529
1650
  declare const validatePipeline: (definition: PipelineDefinition) => PipelineValidation;
1530
1651
  declare const renderPipelineNodeInput: (input: PipelineNodeInput) => string;
1531
1652
 
1653
+ /**
1654
+ * Tool consent. Every tool call passes a gate that decides allow / ask / deny:
1655
+ *
1656
+ * - `autopilot` — run everything (default; explicit `rules` still apply);
1657
+ * - `ask-writes` — run read-only tools, ask before anything that may change state;
1658
+ * - `ask-all` — ask before every call;
1659
+ * - `read-only` — run read-only tools, refuse the rest without asking.
1660
+ *
1661
+ * A tool is read-only when its MCP annotations say so (`readOnlyHint`) or the
1662
+ * host marked it (`defineTool({ readOnly: true })` / `markReadOnly`). Unknown =
1663
+ * may write: the safe assumption.
1664
+ */
1665
+ type ToolApprovalMode = 'autopilot' | 'ask-writes' | 'ask-all' | 'read-only';
1666
+ type ToolPermission = 'allow' | 'ask' | 'deny';
1667
+ declare const TOOL_APPROVAL_MODES: readonly ToolApprovalMode[];
1668
+ interface ToolApprovalRequest {
1669
+ /** Unique per request — echo it back from a UI. */
1670
+ id: string;
1671
+ toolName: string;
1672
+ input: unknown;
1673
+ readOnly: boolean;
1674
+ step?: IPlanStep;
1675
+ /**
1676
+ * Set when the call comes from a helper the model started (`subagents.dynamic`), not from the
1677
+ * run itself: the helper's id (as in its `subagent.start` event) and its depth.
1678
+ */
1679
+ subagent?: {
1680
+ id: string;
1681
+ depth: number;
1682
+ };
1683
+ /**
1684
+ * Set when the call comes from an MCP App (`Agent.approveAppToolCall`), not from the model:
1685
+ * a UI says so ("The app “travel” wants to run …"). `toolName` above is then the name the
1686
+ * agent's rules match (`server__tool`), `app.tool` the server's own name for it.
1687
+ */
1688
+ app?: ToolApprovalApp;
1689
+ /**
1690
+ * Set when the call runs code (`run_js`, or a tool marked with `markCodeExecution`) while the
1691
+ * run acts on skills an MCP server served: those skills, by name. Such a call is ALWAYS asked,
1692
+ * whatever the mode, a rule or an earlier "always allow" say (the Skills extension: a server's
1693
+ * skill must not lead to code running here without a person's approval).
1694
+ */
1695
+ mcpSkills?: string[];
1696
+ /**
1697
+ * Set when the request is not about a tool call but about an MCP server's skill that is about
1698
+ * to enter the model's context (`load_skill`, the planner's pick, a resumed run; `skills` on a
1699
+ * server, consent `'ask'` / `'once-per-skill'`): the server, the skill, its description and
1700
+ * size and the very text the model would read - the SERVER's words, to show as plain text.
1701
+ * `toolName` is `'load_skill'`. Approve to let it in (`remember: true` = every skill of that
1702
+ * server for the agent's life, nested ones excepted), deny to keep it out. Asked whatever the
1703
+ * approval mode and the rules say.
1704
+ */
1705
+ skill?: McpSkillConsentView;
1706
+ }
1707
+ /** Who asks when an MCP App asks (see `ToolApprovalRequest.app`). */
1708
+ interface ToolApprovalApp {
1709
+ /** The MCP server the app came from (its tools are the only ones it may call). */
1710
+ server: string;
1711
+ /** The tool's own name on that server. */
1712
+ tool: string;
1713
+ /** The app's `ui://` resource. */
1714
+ resourceUri: string;
1715
+ }
1716
+ /** What the gate hands `onRequest` beside the request. */
1717
+ interface ToolApprovalContext {
1718
+ /**
1719
+ * Aborted when the question ends WITHOUT your answer: no decision within `timeoutMs`
1720
+ * (`signal.reason` is an Error named 'TimeoutError'), the run was stopped ('AbortError'), or
1721
+ * the handler failed. Take the prompt down then: an answer given later is ignored. Never
1722
+ * aborted once you have answered.
1723
+ */
1724
+ signal: AbortSignal;
1725
+ }
1726
+ /**
1727
+ * `true`/`false`, or an object. `remember: true` on an approval allows this
1728
+ * tool for the rest of the agent's life ("always allow").
1729
+ */
1730
+ type ToolApprovalDecision = boolean | {
1731
+ approved: boolean;
1732
+ reason?: string;
1733
+ remember?: boolean;
1734
+ };
1735
+ interface ToolApprovalConfig {
1736
+ /** Default policy (default 'autopilot'). */
1737
+ mode?: ToolApprovalMode;
1738
+ /**
1739
+ * Per-tool overrides by exact name or `*` glob, e.g. `{ 'github__delete_*': 'deny' }`.
1740
+ * They win over the mode — an explicit 'ask' still asks under autopilot.
1741
+ */
1742
+ rules?: Record<string, ToolPermission>;
1743
+ /** Resolves an approval request (a UI prompt, a policy service, …). */
1744
+ onRequest?: (req: ToolApprovalRequest, ctx: ToolApprovalContext) => ToolApprovalDecision | Promise<ToolApprovalDecision>;
1745
+ /**
1746
+ * No decision within this many ms → deny. Default 300 000 ({@link TOOL_APPROVAL_TIMEOUT_MS}).
1747
+ * `0` or `Infinity`: no bound - the question waits until the run is stopped; so does a value
1748
+ * above 2^31 - 1 (about 24.8 days, the most a timer holds). Negative or NaN: `createAgent`
1749
+ * throws. The only bound on the wait: the step's `chatTimeoutMs` (and a subagent's
1750
+ * `timeoutMs`) stop while a person decides.
1751
+ */
1752
+ timeoutMs?: number;
1753
+ }
1754
+ /** How long a question waits for a decision when `toolApproval.timeoutMs` is not set: 5 minutes. */
1755
+ declare const TOOL_APPROVAL_TIMEOUT_MS = 300000;
1756
+ /** Raised by a denied tool call; recorded as a failed call the replanner sees. */
1757
+ declare class ToolDeniedError extends Error {
1758
+ constructor(reason?: string);
1759
+ toJSON(): string;
1760
+ }
1761
+ /** Mark a tool as read-only so `ask-writes` / `read-only` let it through. Returns it. */
1762
+ declare const markReadOnly: <T extends object>(tool: T, readOnly?: boolean) => T;
1763
+ /**
1764
+ * Mark a tool as one that runs code (the sandbox's `run_js` is): while a run acts on an MCP
1765
+ * server's skill, every call of it is asked (`decideToolPermission`).
1766
+ */
1767
+ declare const markCodeExecution: <T extends object>(tool: T, codeExecution?: boolean) => T;
1768
+ declare const isCodeExecutionTool: (tool: unknown) => boolean;
1769
+ declare const isReadOnlyTool: (tool: Tool | undefined) => boolean;
1770
+ /** The most specific matching rule: an exact name, else the longest glob. Pure. */
1771
+ declare const matchRule: (rules: Record<string, ToolPermission> | undefined, toolName: string) => ToolPermission | undefined;
1772
+ /**
1773
+ * What the gate does for one call, before any human is involved. Order:
1774
+ * remembered "always allow" → most specific rule → mode default. Pure.
1775
+ * Then one rule that only ever tightens: a call that runs code (`codeExecution`) while the run
1776
+ * acts on an MCP server's skill (`mcpSkills`) is asked when it would have been allowed - by the
1777
+ * mode, a rule or an "always allow" alike. A deny stays a deny.
1778
+ */
1779
+ declare const decideToolPermission: (opts: {
1780
+ toolName: string;
1781
+ readOnly: boolean;
1782
+ mode: ToolApprovalMode;
1783
+ rules?: Record<string, ToolPermission>;
1784
+ remembered?: ReadonlySet<string>;
1785
+ codeExecution?: boolean;
1786
+ mcpSkills?: readonly string[];
1787
+ }) => ToolPermission;
1788
+
1532
1789
  type ReplanMode = 'continue' | 'revise' | 'finish';
1533
1790
  type Phase = 'plan' | 'execute' | 'replan' | 'synthesize';
1534
1791
  /**
1535
1792
  * Phases a `usage` event can be charged to: the four stages plus compaction and subagents;
1536
1793
  * `decision` - a call to `config.decisionModel` (`usage.decisionCalls`, plus the tokens its API
1537
- * reported); and 'media' - a call to an image / speech / transcription model (`config.media`),
1538
- * whose `usage` carries the media fields and zero tokens.
1794
+ * reported); 'media' - a call to an image / speech / transcription model (`config.media`),
1795
+ * whose `usage` carries the media fields and zero tokens; and 'search' - a `web_search` through
1796
+ * the google provider (`config.search`): the grounding call is a model call, and these are the
1797
+ * tokens its API reported.
1539
1798
  */
1540
- type UsagePhase = Phase | 'compact' | 'subagent' | 'decision' | 'media';
1799
+ /** `'app'`: a completion an MCP App asked for (`Agent.sampleForApp`), outside any run. */
1800
+ type UsagePhase = Phase | 'compact' | 'subagent' | 'decision' | 'media' | 'search' | 'app';
1541
1801
  /**
1542
1802
  * Everything the agent does is streamed as a typed event so any UI (or none)
1543
1803
  * can render progress. The final answer arrives as a `final` event; there is no
@@ -1683,10 +1943,12 @@ type AgentEventBody =
1683
1943
  afterTokens: number;
1684
1944
  }
1685
1945
  /** A skill's instructions entered the context (picked by the planner, or loaded by a tool call). */
1946
+ /** `server`: the MCP server the skill came from (a skill served with `skills: true`). */
1686
1947
  | {
1687
1948
  type: 'skill.activated';
1688
1949
  name: string;
1689
1950
  by: 'plan' | 'tool';
1951
+ server?: string;
1690
1952
  }
1691
1953
  /** The agent wrote a lesson down as a skill (`config.learning`). */
1692
1954
  | {
@@ -1718,6 +1980,25 @@ type AgentEventBody =
1718
1980
  model: string;
1719
1981
  step?: IPlanStep;
1720
1982
  }
1983
+ /**
1984
+ * A file tool (`createFileTools`: `fs_write`) or the sandbox's `fs.writeFile` wrote a file to
1985
+ * the virtual file system during the run: `path` is where, `mediaType` its MIME type, `bytes`
1986
+ * its size. The content is never in an event - read it with `vfs.read(path)`. Emitted once per
1987
+ * successful write; a write that was refused or failed emits nothing.
1988
+ */
1989
+ | {
1990
+ type: 'file.written';
1991
+ path: string;
1992
+ mediaType: string;
1993
+ bytes: number;
1994
+ step?: IPlanStep;
1995
+ }
1996
+ /** A file tool (`fs_delete`) deleted a file that existed. */
1997
+ | {
1998
+ type: 'file.deleted';
1999
+ path: string;
2000
+ step?: IPlanStep;
2001
+ }
1721
2002
  /**
1722
2003
  * An audio file was transcribed: one the user attached to the run ('attachment') or one the
1723
2004
  * model asked about ('tool'). `text` is what the model reads of it (cleaned and capped).
@@ -1751,6 +2032,18 @@ type AgentEventBody =
1751
2032
  id: string;
1752
2033
  depth: number;
1753
2034
  };
2035
+ /**
2036
+ * Set when an MCP App asks (`Agent.approveAppToolCall`), not the model: the app's server,
2037
+ * the tool's own name there and the app's `ui://` resource (see `ToolApprovalRequest.app`).
2038
+ */
2039
+ app?: ToolApprovalApp;
2040
+ /** See `ToolApprovalRequest.mcpSkills`. */
2041
+ mcpSkills?: string[];
2042
+ /**
2043
+ * Set when the request is about an MCP server's skill about to enter the model's context,
2044
+ * not a tool call (see `ToolApprovalRequest.skill`): the server's words, as plain text.
2045
+ */
2046
+ skill?: McpSkillConsentView;
1754
2047
  }
1755
2048
  /** A consent decision: from the user, or `automatic` (policy denial). */
1756
2049
  | {
@@ -1761,6 +2054,63 @@ type AgentEventBody =
1761
2054
  reason?: string;
1762
2055
  automatic: boolean;
1763
2056
  }
2057
+ /**
2058
+ * An MCP server asked the user for input during a tool call (the connection's `onElicitation`
2059
+ * is being called). `message`, `requestedSchema` and `url` are the SERVER's text: cleaned and
2060
+ * capped, for a UI to show - never instructions.
2061
+ */
2062
+ | {
2063
+ type: 'mcp.elicitation-requested';
2064
+ id: string;
2065
+ server: string;
2066
+ /** The tool call that asks: the tool's name as the model called it. */
2067
+ tool: string;
2068
+ mode: 'form' | 'url';
2069
+ message: string;
2070
+ requestedSchema?: McpElicitationSchema;
2071
+ url?: string;
2072
+ step?: IPlanStep;
2073
+ /** Set when a helper (a subagent) is the one whose call asks. */
2074
+ subagent?: {
2075
+ id: string;
2076
+ depth: number;
2077
+ };
2078
+ }
2079
+ /**
2080
+ * The question was answered. Never carries a value the user entered: `fields` are the NAMES
2081
+ * of the fields an accepted form was answered with. `automatic`: nobody decided (a guard, a
2082
+ * cap, a timeout, a failed handler, a stopped run) - `reason` says which, the tool call
2083
+ * fails, and no `mcp.elicitation-requested` may have preceded it.
2084
+ */
2085
+ | {
2086
+ type: 'mcp.elicitation-answered';
2087
+ id: string;
2088
+ server: string;
2089
+ tool: string;
2090
+ action: 'accept' | 'decline' | 'cancel';
2091
+ automatic: boolean;
2092
+ reason?: McpElicitationReason;
2093
+ fields?: string[];
2094
+ }
2095
+ /**
2096
+ * A tool that declares an MCP App (`_meta.ui.resourceUri`) returned a result, on a connection
2097
+ * made with `apps: true` (`./mcp`): a UI can show the app next to the call. `tool` is the name
2098
+ * the model called, `toolName` the server's own; `input` the call's arguments; `result` what
2099
+ * the app is given (`content`, `structuredContent`, `isError`, `_meta`), absent when it was
2100
+ * larger than `MCP_APP_MAX_RESULT_CHARS`. The app's HTML is never in an event: read it with
2101
+ * the connection's `apps.readUiResource(server, resourceUri)`.
2102
+ */
2103
+ | {
2104
+ type: 'mcp.app';
2105
+ id: string;
2106
+ server: string;
2107
+ tool: string;
2108
+ toolName: string;
2109
+ resourceUri: string;
2110
+ input: Record<string, unknown>;
2111
+ result?: McpAppToolResult;
2112
+ step?: IPlanStep;
2113
+ }
1764
2114
  /**
1765
2115
  * `profile` is set when the parent chose one of the subagent's named profiles for this call.
1766
2116
  * The tree: `parentId` is the id of the subagent that made the call, or the `runId` of the run
@@ -2048,79 +2398,141 @@ declare const decisionEgressPolicy: (spec: IDecisionModelSpec) => IEgressPolicy;
2048
2398
  declare const resolveDecisionModel: (input: IDecisionModel | IDecisionModelSpec | undefined, credentials?: CredentialStore) => Promise<IDecisionModel | undefined>;
2049
2399
 
2050
2400
  /**
2051
- * Tool consent. Every tool call passes a gate that decides allow / ask / deny:
2052
- *
2053
- * - `autopilot` — run everything (default; explicit `rules` still apply);
2054
- * - `ask-writes` — run read-only tools, ask before anything that may change state;
2055
- * - `ask-all` — ask before every call;
2056
- * - `read-only` — run read-only tools, refuse the rest without asking.
2401
+ * MCP Apps: a completion an app asks the HOST's model for (`sampling/createMessage` sent by the
2402
+ * view, the extension's draft revision; the request is MCP's own `CreateMessageRequest`).
2057
2403
  *
2058
- * A tool is read-only when its MCP annotations say so (`readOnlyHint`) or the
2059
- * host marked it (`defineTool({ readOnly: true })` / `markReadOnly`). Unknown =
2060
- * may write: the safe assumption.
2061
- */
2062
- type ToolApprovalMode = 'autopilot' | 'ask-writes' | 'ask-all' | 'read-only';
2063
- type ToolPermission = 'allow' | 'ask' | 'deny';
2064
- declare const TOOL_APPROVAL_MODES: readonly ToolApprovalMode[];
2065
- interface ToolApprovalRequest {
2066
- /** Unique per request — echo it back from a UI. */
2067
- id: string;
2068
- toolName: string;
2069
- input: unknown;
2070
- readOnly: boolean;
2071
- step?: IPlanStep;
2404
+ * Pure, no imports: what of an app's request is accepted, what the user is shown before anything
2405
+ * is sent (the same text the model gets), and the per-app rate limit. `Agent.sampleForApp`
2406
+ * (`agent/runner.ts`) is the one caller - the request is checked here, counted, put to the host's
2407
+ * consent callback, and only then sent to the agent's model: no tools, nothing of the agent's
2408
+ * context, nothing kept. The answer goes back to the app and nowhere else.
2409
+ */
2410
+ /** The most an app may have the model write per request: a larger `maxTokens` is lowered to it. */
2411
+ declare const APP_SAMPLING_MAX_TOKENS = 1024;
2412
+ /** At most this many messages in one request. */
2413
+ declare const APP_SAMPLING_MAX_MESSAGES = 20;
2414
+ /** The text of a request (its messages and system prompt): at most this many characters. */
2415
+ declare const APP_SAMPLING_MAX_INPUT_CHARS = 16000;
2416
+ /** An app's system prompt: at most this many characters (counted in the input too). */
2417
+ declare const APP_SAMPLING_MAX_SYSTEM_CHARS = 4000;
2418
+ /** Images of one request (only to a model that reads them): at most this many... */
2419
+ declare const APP_SAMPLING_MAX_IMAGES = 4;
2420
+ /** ...each at most this many bytes. */
2421
+ declare const APP_SAMPLING_MAX_IMAGE_BYTES: number;
2422
+ /**
2423
+ * Room for the model's reasoning on top of an app's `maxTokens`, for a model that thinks. On Gemini
2424
+ * and OpenAI the reasoning counts against the output cap, and some models think whatever they are
2425
+ * told (Gemini 3 Flash spent 111 of an app's 120 tokens thinking and answered "(e.g.,"). The app's
2426
+ * `maxTokens` is meant for the answer: a model seen thinking gets this much more.
2427
+ */
2428
+ declare const APP_SAMPLING_REASONING_TOKENS = 2048;
2429
+ /** Requests of one app (server + `ui://` resource) per minute. */
2430
+ declare const APP_SAMPLING_PER_MINUTE = 5;
2431
+ /** Requests of one app for the life of the agent (a page reload starts again). */
2432
+ declare const APP_SAMPLING_PER_APP = 30;
2433
+ /** `config.appSampling`: the caps, or `false` - then `sampleForApp` refuses every request. */
2434
+ interface AppSamplingSettings {
2435
+ /** The most the model writes per request (default `APP_SAMPLING_MAX_TOKENS`). */
2436
+ maxTokens?: number;
2437
+ /** Requests of one app per minute (default `APP_SAMPLING_PER_MINUTE`). */
2438
+ maxRequestsPerMinute?: number;
2439
+ /** Requests of one app for the agent's life (default `APP_SAMPLING_PER_APP`). */
2440
+ maxRequests?: number;
2441
+ /** Characters of a request's text (default `APP_SAMPLING_MAX_INPUT_CHARS`). */
2442
+ maxInputChars?: number;
2072
2443
  /**
2073
- * Set when the call comes from a helper the model started (`subagents.dynamic`), not from the
2074
- * run itself: the helper's id (as in its `subagent.start` event) and its depth.
2444
+ * Tokens of reasoning allowed on top of a request's `maxTokens`, for a model seen thinking
2445
+ * (default `APP_SAMPLING_REASONING_TOKENS`; `0` = never more than the app's `maxTokens`).
2075
2446
  */
2076
- subagent?: {
2077
- id: string;
2078
- depth: number;
2079
- };
2447
+ reasoningTokens?: number;
2080
2448
  }
2081
- /**
2082
- * `true`/`false`, or an object. `remember: true` on an approval allows this
2083
- * tool for the rest of the agent's life ("always allow").
2084
- */
2085
- type ToolApprovalDecision = boolean | {
2086
- approved: boolean;
2087
- reason?: string;
2088
- remember?: boolean;
2089
- };
2090
- interface ToolApprovalConfig {
2091
- /** Default policy (default 'autopilot'). */
2092
- mode?: ToolApprovalMode;
2093
- /**
2094
- * Per-tool overrides by exact name or `*` glob, e.g. `{ 'github__delete_*': 'deny' }`.
2095
- * They win over the mode — an explicit 'ask' still asks under autopilot.
2096
- */
2097
- rules?: Record<string, ToolPermission>;
2098
- /** Resolves an approval request (a UI prompt, a policy service, …). */
2099
- onRequest?: (req: ToolApprovalRequest) => ToolApprovalDecision | Promise<ToolApprovalDecision>;
2100
- /** No decision within this many ms → deny. Default: wait indefinitely. */
2101
- timeoutMs?: number;
2449
+ interface ResolvedAppSampling {
2450
+ enabled: boolean;
2451
+ maxTokens: number;
2452
+ maxRequestsPerMinute: number;
2453
+ maxRequests: number;
2454
+ maxInputChars: number;
2455
+ reasoningTokens: number;
2456
+ }
2457
+ /** `config.appSampling` resolved; throws on a cap that is not a whole number of at least 1 (0 for `reasoningTokens`). */
2458
+ declare const resolveAppSampling: (setting: unknown) => ResolvedAppSampling;
2459
+ /** Why a request was not answered. */
2460
+ type AppSamplingErrorCode = 'disabled' | 'invalid' | 'unsupported' | 'rate-limited' | 'denied';
2461
+ /** The JSON-RPC code an app is answered with for each (`-1`: MCP's "user rejected sampling"). */
2462
+ declare const APP_SAMPLING_RPC_CODES: Record<AppSamplingErrorCode, number>;
2463
+ declare class AppSamplingError extends Error {
2464
+ readonly code: AppSamplingErrorCode;
2465
+ /** What the app is told (`APP_SAMPLING_RPC_CODES`). */
2466
+ readonly rpcCode: number;
2467
+ constructor(code: AppSamplingErrorCode, message: string);
2468
+ }
2469
+ /** An image of a request, as checked (base64, one of four raster types). */
2470
+ interface AppSamplingImage {
2471
+ mimeType: string;
2472
+ /** Base64. */
2473
+ data: string;
2474
+ /** Its size, decoded. */
2475
+ bytes: number;
2102
2476
  }
2103
- /** Raised by a denied tool call; recorded as a failed call the replanner sees. */
2104
- declare class ToolDeniedError extends Error {
2105
- constructor(reason?: string);
2106
- toJSON(): string;
2477
+ /** One message of a request, as the user is shown it and the model is sent it. */
2478
+ interface AppSamplingMessage {
2479
+ role: 'user' | 'assistant';
2480
+ /** Its text blocks, joined, without invisible characters. */
2481
+ text: string;
2482
+ /** Images (a user message only, and only to a model that reads them). */
2483
+ images: AppSamplingImage[];
2484
+ }
2485
+ /** A request as checked: what the consent callback is shown, and exactly what the model gets. */
2486
+ interface AppSamplingView {
2487
+ /** The server whose app asks. */
2488
+ server: string;
2489
+ /** The app (`ui://…`). */
2490
+ resourceUri: string;
2491
+ messages: AppSamplingMessage[];
2492
+ systemPrompt?: string;
2493
+ /** What the model may write: the app's `maxTokens`, at most the cap. */
2494
+ maxTokens: number;
2495
+ /** What the app asked for. */
2496
+ requestedMaxTokens: number;
2497
+ temperature?: number;
2107
2498
  }
2108
- /** Mark a tool as read-only so `ask-writes` / `read-only` let it through. Returns it. */
2109
- declare const markReadOnly: <T extends object>(tool: T, readOnly?: boolean) => T;
2110
- declare const isReadOnlyTool: (tool: Tool | undefined) => boolean;
2111
- /** The most specific matching rule: an exact name, else the longest glob. Pure. */
2112
- declare const matchRule: (rules: Record<string, ToolPermission> | undefined, toolName: string) => ToolPermission | undefined;
2113
- /**
2114
- * What the gate does for one call, before any human is involved. Order:
2115
- * remembered "always allow" → most specific rule → mode default. Pure.
2116
- */
2117
- declare const decideToolPermission: (opts: {
2118
- toolName: string;
2119
- readOnly: boolean;
2120
- mode: ToolApprovalMode;
2121
- rules?: Record<string, ToolPermission>;
2122
- remembered?: ReadonlySet<string>;
2123
- }) => ToolPermission;
2499
+ /** The answer, in MCP's `CreateMessageResult` shape: a text, the model's id, why it stopped. */
2500
+ interface AppSamplingResult {
2501
+ role: 'assistant';
2502
+ content: {
2503
+ type: 'text';
2504
+ text: string;
2505
+ };
2506
+ model: string;
2507
+ stopReason: string;
2508
+ }
2509
+ /** Text as the user is shown it and the model reads it: nothing invisible in it. */
2510
+ declare const appSamplingText: (text: string) => string;
2511
+ /**
2512
+ * The parts of `params` (MCP `CreateMessageRequest.params`) this host takes, checked:
2513
+ * 1 - `APP_SAMPLING_MAX_MESSAGES` messages of role `user` / `assistant`, each a text block or a
2514
+ * list of blocks (text; an image - PNG, JPEG, GIF, WebP, base64 - in a user message only when
2515
+ * `images` is true); a system prompt; `maxTokens` (required, a whole number, lowered to the cap);
2516
+ * a temperature from 0 to 2. Refused: tools (`tools` / `toolChoice`, tool-use and tool-result
2517
+ * blocks - `hostCapabilities.sampling.tools` is not offered), audio, an image the model cannot
2518
+ * read, more text than `maxInputChars`. Ignored: `modelPreferences` (the host picks the model),
2519
+ * `includeContext` (no context is ever added), `stopSequences`, `metadata`. Throws
2520
+ * {@link AppSamplingError}.
2521
+ */
2522
+ declare const appSamplingRequestOf: (params: unknown, limits: {
2523
+ maxTokens: number;
2524
+ maxInputChars: number;
2525
+ images: boolean;
2526
+ }) => Omit<AppSamplingView, "server" | "resourceUri">;
2527
+ /**
2528
+ * The rate limit of `sampleForApp`, per app (its key: server + resource): at most `perMinute`
2529
+ * requests in any 60 s, and `total` for the life of the limiter. `take` counts a request and
2530
+ * answers `undefined`, or says which limit it hit (and does not count it). Pure: the time is
2531
+ * the caller's.
2532
+ */
2533
+ declare const createAppSamplingLimiter: (perMinute: number, total: number) => {
2534
+ take(app: string, now: number): "minute" | "total" | undefined;
2535
+ };
2124
2536
 
2125
2537
  /** Force a tool-calling strategy, or let the agent pick per model ('auto'). */
2126
2538
  type ToolMode = 'auto' | 'native' | 'prompted';
@@ -2191,12 +2603,12 @@ interface BrowserAgentConfig {
2191
2603
  egress?: boolean | IEgressPolicy;
2192
2604
  /**
2193
2605
  * Let the model SEARCH the web (the `web_search` tool: a short list of title / url / snippet).
2194
- * Off unless set. The library ships no key: name a hosted search API (`provider` +
2195
- * `credentialRef` - the key stays in `credentials`, never here - or a SearXNG `baseURL`) or
2196
- * pass a function (`engine`). The adapter's request reaches that API's host only, through the
2197
- * guarded fetch; with `egress` set, results the model could not fetch are left out. Works
2198
- * without `egress` (then there is no `web_fetch` to open a link). The API must allow
2199
- * cross-origin calls from a page - see `ISearchConfig`.
2606
+ * Off unless set. The library ships no key: pass a function (`engine` - any search API) or
2607
+ * name the built-in provider (`provider: 'google'` + `credentialRef` - Google Search through
2608
+ * Gemini grounding, which spends model tokens; the key stays in `credentials`, never here).
2609
+ * The provider's request reaches that API's host only, through the guarded fetch; with
2610
+ * `egress` set, results the model could not fetch are left out. Works without `egress` (then
2611
+ * there is no `web_fetch` to open a link) - see `ISearchConfig`.
2200
2612
  */
2201
2613
  search?: ISearchConfig;
2202
2614
  /**
@@ -2260,6 +2672,14 @@ interface BrowserAgentConfig {
2260
2672
  toolSearchThreshold?: number;
2261
2673
  /** Consent policy for tool calls: autopilot, ask before writes, ask always, read-only. */
2262
2674
  toolApproval?: ToolApprovalConfig;
2675
+ /**
2676
+ * MCP Apps asking this agent's model for a completion (`Agent.sampleForApp`, the app's
2677
+ * `sampling/createMessage`): the caps - `maxTokens` per request (1024), `maxRequestsPerMinute`
2678
+ * (5) and `maxRequests` (30) per app, `maxInputChars` (16 000) - or `false` to refuse every
2679
+ * request. Nothing happens unless a host calls `sampleForApp`, and each request is put to the
2680
+ * host's consent callback first. See docs/capabilities.md, "An app asks the model".
2681
+ */
2682
+ appSampling?: false | AppSamplingSettings;
2263
2683
  /** Reusable instruction bundles (SKILL.md) the planner/executor can pull in. */
2264
2684
  skills?: Skill[];
2265
2685
  /**
@@ -2275,6 +2695,18 @@ interface BrowserAgentConfig {
2275
2695
  * for servers you do not trust to write into a system prompt (see docs/security.md).
2276
2696
  */
2277
2697
  mcpInstructions?: boolean;
2698
+ /**
2699
+ * The MCP servers' skills (`skills` on a server of `./mcp`, experimental). `consent`: when a
2700
+ * person is asked before a skill's text enters the model's context, for every server whose own
2701
+ * `skills: { consent }` does not say - `'once-per-skill'` (default: the first time per skill in
2702
+ * the agent's life, again when its entry changes), `'ask'` (in every run that loads it) or
2703
+ * `'never'` (no question: servers you vetted). Asked through `toolApproval.onRequest`, the
2704
+ * request carrying `skill`; without a handler such a skill is not loaded. Autopilot does not
2705
+ * skip it. See the README, "MCP skills".
2706
+ */
2707
+ mcpSkills?: {
2708
+ consent?: McpSkillConsent;
2709
+ };
2278
2710
  /** Prepended to every phase's system prompt. */
2279
2711
  systemPrompt?: string;
2280
2712
  /** Override any phase prompt builder. */
@@ -2305,7 +2737,13 @@ interface BrowserAgentConfig {
2305
2737
  maxToolCalls?: number;
2306
2738
  /** Cap on the steps of one plan (default 8). */
2307
2739
  maxPlanSteps?: number;
2308
- /** Per-call timeout so a hang can't freeze a run (default 120000). */
2740
+ /**
2741
+ * Per-call timeout so a hang can't freeze a run (default 120000) - for the executor, of a
2742
+ * whole step: its rounds and its tool calls. It does not run while a tool call of the step
2743
+ * waits for a person (a tool approval, an MCP elicitation): the step goes on with the time it
2744
+ * had left once the person has answered. Those waits have bounds of their own
2745
+ * (`toolApproval.timeoutMs`, `elicitation.timeoutMs`), and stopping the run ends them at once.
2746
+ */
2309
2747
  chatTimeoutMs?: number;
2310
2748
  /** Legacy per-phase output caps; `limits.perCall` wins when both are set. */
2311
2749
  budgets?: PhaseBudgets;
@@ -2607,6 +3045,36 @@ declare const REPLAY_NOTE = "[not run again: this exact call already succeeded i
2607
3045
  */
2608
3046
  declare const isReplayedToolOutput: (output: unknown) => boolean;
2609
3047
 
3048
+ /** One deadline of a clock. */
3049
+ interface IWaitTimer {
3050
+ /** Take the deadline down; it will not fire. Safe to call twice, and after it fired. */
3051
+ cancel: () => void;
3052
+ /** Milliseconds of running time left before it fires (0 once it fired or was cancelled). */
3053
+ left: () => number;
3054
+ }
3055
+ interface IWaitClock {
3056
+ /**
3057
+ * Stop the clock: a person is being asked. Returns what starts it again, to be called exactly
3058
+ * when the wait is over (a second call does nothing). Waits may overlap - the clock runs
3059
+ * again when the last of them is over.
3060
+ */
3061
+ pause: () => () => void;
3062
+ /** Whether a wait is going on. */
3063
+ readonly paused: boolean;
3064
+ /**
3065
+ * Call `onExpire` after `ms` of this clock's RUNNING time. `unref`: do not keep a Node
3066
+ * process alive for it (as `AbortSignal.timeout` does not).
3067
+ */
3068
+ timer: (ms: number, onExpire: () => void, options?: {
3069
+ unref?: boolean;
3070
+ }) => IWaitTimer;
3071
+ /**
3072
+ * Be told when the clock stops (`true`) and when it runs again (`false`). Returns what ends
3073
+ * the subscription.
3074
+ */
3075
+ watch: (listener: (waiting: boolean) => void) => () => void;
3076
+ }
3077
+
2610
3078
  /** The effective tool-selection strategy of a run ('auto' already resolved). */
2611
3079
  type EffectiveToolStrategy = 'all' | 'plan-narrowed' | 'search';
2612
3080
  /** One executor tier of an agent with `config.executorTiers`. */
@@ -2656,6 +3124,11 @@ interface AgentContext {
2656
3124
  /** Leveled logger (config.logLevel over config.logger ?? console). */
2657
3125
  log: AgentLogger;
2658
3126
  signal?: AbortSignal;
3127
+ /**
3128
+ * The run's clock (wait-clock.ts): the executor's step limit (`chatTimeoutMs`) runs on it, and
3129
+ * it is stopped while a tool call of the run - or of a subagent below it - waits for a person.
3130
+ */
3131
+ clock?: IWaitClock;
2659
3132
  /** Current world state for grounding, or undefined when no describeState is configured. */
2660
3133
  state: () => Promise<string | undefined>;
2661
3134
  /** Session transcript loaded from memory BEFORE this run's goal was appended. */
@@ -2820,6 +3293,7 @@ interface Agent {
2820
3293
  name: string;
2821
3294
  description: string;
2822
3295
  learned?: true;
3296
+ server?: string;
2823
3297
  }[];
2824
3298
  /** The agent's own lessons (`config.learning`), with where each came from. Empty without it. */
2825
3299
  listLearnedSkills(): Skill[];
@@ -2828,6 +3302,29 @@ interface Agent {
2828
3302
  * Pass `onEvent` to receive the `skill.forgotten` event.
2829
3303
  */
2830
3304
  forgetSkill(name: string, onEvent?: (event: AgentEvent) => void): Promise<boolean>;
3305
+ /**
3306
+ * Ask this agent's consent gate about a tool call an MCP App wants to make (`./mcp` with
3307
+ * `apps: true`: the app's `tools/call`), not the model. The same `toolApproval` - its rules,
3308
+ * its handler (`onRequest`), its timeout - with two differences: under 'autopilot' a write
3309
+ * still asks (an app never writes silently; read-only tools run, as in 'ask-writes'), and
3310
+ * "always allow" given to an app is remembered for apps only, apart from the model's.
3311
+ * `onEvent` receives `tool.approval-requested` (with `app`) and `tool.approval-resolved`; a UI
3312
+ * shows the request as the app's. Resolves when the call may go; throws `ToolDeniedError`.
3313
+ * Make the call afterwards with `ConnectedMcp.apps.callAppTool`.
3314
+ */
3315
+ approveAppToolCall(call: AppToolCallRequest, onEvent?: (event: AgentEvent) => void, signal?: AbortSignal): Promise<void>;
3316
+ /**
3317
+ * Answer a completion an MCP App asks for (its `sampling/createMessage`) with this agent's
3318
+ * synthesizer model - outside any run, with no tools and none of the agent's context. The
3319
+ * request (MCP `CreateMessageRequest.params`) is checked (`appSamplingRequestOf`: text, images
3320
+ * only for a model that reads them, no tools, caps), counted against the app's rate limit
3321
+ * (`config.appSampling`), and put to `options.approve` with what the model will get; only on
3322
+ * `true` is it sent. Its tokens are charged to `usage` (and `sessionUsage`) and reported to
3323
+ * `options.onEvent` as a `usage` event of phase `'app'` - the ONLY event: the answer goes to
3324
+ * the caller, never into memory, an event or a run. Throws {@link AppSamplingError}
3325
+ * (`rpcCode` is what the app is told), or the model's error.
3326
+ */
3327
+ sampleForApp(request: AppSamplingRequest, options: AppSamplingOptions): Promise<AppSamplingResult>;
2831
3328
  /**
2832
3329
  * What the executor model can take, per attachment kind: true / false, or
2833
3330
  * undefined when unknown (the run tries, and a provider refusal becomes a
@@ -2849,6 +3346,42 @@ interface Agent {
2849
3346
  tiers?: Partial<Record<ModelTier, LanguageModel>>;
2850
3347
  };
2851
3348
  }
3349
+ /** A completion an MCP App asks for (see `Agent.sampleForApp`). */
3350
+ interface AppSamplingRequest {
3351
+ /** The server whose app asks. */
3352
+ server: string;
3353
+ /** The app's `ui://` resource: with `server`, the key of its rate limit. */
3354
+ resourceUri: string;
3355
+ /** The app's `sampling/createMessage` params, as they arrived: checked here. */
3356
+ params: unknown;
3357
+ }
3358
+ interface AppSamplingOptions {
3359
+ /**
3360
+ * The user's consent: shown exactly what the model will get (the cleaned messages, the system
3361
+ * prompt, the tokens it may write). `true` sends it. Bounded by `toolApproval.timeoutMs` (no
3362
+ * answer = refused) and `signal`.
3363
+ */
3364
+ approve: (view: AppSamplingView, signal?: AbortSignal) => boolean | Promise<boolean>;
3365
+ signal?: AbortSignal;
3366
+ /** Receives the `usage` event (phase `'app'`) of the call. */
3367
+ onEvent?: (event: AgentEvent) => void;
3368
+ /** The memory session whose `sessionUsage` is charged (default `config.sessionId`). */
3369
+ sessionId?: string;
3370
+ }
3371
+ /** A tool call an MCP App asks for (see `Agent.approveAppToolCall`). */
3372
+ interface AppToolCallRequest {
3373
+ /** The name the consent rules match: the tool's key, `server__tool` (`McpAppTool.key`). */
3374
+ tool: string;
3375
+ /** The tool's own name on its server. */
3376
+ toolName: string;
3377
+ /** The server the app came from. */
3378
+ server: string;
3379
+ /** The app's `ui://` resource. */
3380
+ resourceUri: string;
3381
+ input: unknown;
3382
+ /** The server marked the tool read-only (`McpAppTool.readOnly`). */
3383
+ readOnly: boolean;
3384
+ }
2852
3385
  /**
2853
3386
  * Create a headless plan → execute → replan → synthesize agent. Models are
2854
3387
  * resolved eagerly (dynamic provider imports + vault key fetch), so this is
@@ -3160,6 +3693,15 @@ type ParentToWorker = {
3160
3693
  callId: string;
3161
3694
  ok: boolean;
3162
3695
  output: unknown;
3696
+ }
3697
+ /**
3698
+ * The calling run started (true) / stopped (false) waiting for a person (its clock stopped /
3699
+ * runs again, wait-clock.ts): a host tool call in flight runs in that run, so the clock of the
3700
+ * child run that made it follows.
3701
+ */
3702
+ | {
3703
+ type: 'tool-wait';
3704
+ waiting: boolean;
3163
3705
  };
3164
3706
  type WorkerToParent = {
3165
3707
  type: 'event';
@@ -3247,7 +3789,11 @@ interface SubagentToolOptions {
3247
3789
  tools?: ToolSet;
3248
3790
  /** Parallel delegations allowed at once (default 4); extra calls queue. */
3249
3791
  maxConcurrent?: number;
3250
- /** Give up on one delegated task after this many ms (default: none). */
3792
+ /**
3793
+ * Give up on one delegated task after this many ms (default: none). Time a person takes to
3794
+ * answer a question (a tool approval, an MCP elicitation) of the child, of one of its host
3795
+ * tools or of the calling run does not count.
3796
+ */
3251
3797
  timeoutMs?: number;
3252
3798
  /** Cap on the text handed back to the parent model (default 8000 chars). */
3253
3799
  outputMaxChars?: number;
@@ -3885,7 +4431,8 @@ interface ToolRunContext {
3885
4431
  signal?: AbortSignal;
3886
4432
  /**
3887
4433
  * Add what was spent on the parent's behalf to the run: a subagent's tokens (the default
3888
- * phase, 'subagent'), or a media model's call (phase 'media').
4434
+ * phase, 'subagent'), a media model's call (phase 'media'), or a grounded search's tokens
4435
+ * (phase 'search').
3889
4436
  */
3890
4437
  addUsage: (usage: IUsage, phase?: UsagePhase) => void;
3891
4438
  /** The run's usage so far (media tools read their per-run call count from it). */
@@ -3903,6 +4450,34 @@ interface ToolRunContext {
3903
4450
  fetched?: string[];
3904
4451
  /** Internal - what the built-in `spawn_subagent` tool reads of the run (`subagents.dynamic`). */
3905
4452
  spawn?: SpawnRun;
4453
+ /**
4454
+ * Set on the run of a helper the model started (`subagents.dynamic`): the call is the
4455
+ * helper's, not the run's the host started. An MCP tool reads it to decide whether the call
4456
+ * may ask the user something (`onElicitation`, `elicitation.subagents`).
4457
+ */
4458
+ subagent?: {
4459
+ id: string;
4460
+ depth: number;
4461
+ };
4462
+ /**
4463
+ * The questions MCP servers asked the user in this run (`onElicitation`): one object per run,
4464
+ * shared with the helpers it starts (`elicitation.maxPerRun`).
4465
+ */
4466
+ elicitations?: {
4467
+ count: number;
4468
+ };
4469
+ /**
4470
+ * Internal - the run's clock (wait-clock.ts): the step's `chatTimeoutMs` and the time limits
4471
+ * of the subagents the run's tool calls start are deadlines of it, and whoever asks a person
4472
+ * something on the run's behalf (the consent gate, an MCP question) pauses it for the wait.
4473
+ */
4474
+ clock?: IWaitClock;
4475
+ /**
4476
+ * Internal - the skills of MCP servers the run acts on, its callers' included: a call of a
4477
+ * tool that runs code is asked while there is one (`decideToolPermission`). A helper the model
4478
+ * starts inherits it.
4479
+ */
4480
+ mcpSkills?: () => string[];
3906
4481
  }
3907
4482
  /** Read the run context the agent passes to a tool's execute (undefined outside a run). */
3908
4483
  declare const toolRunContextOf: (options: unknown) => ToolRunContext | undefined;
@@ -3999,5 +4574,5 @@ declare class IndexedDBRunStore implements RunPersistence {
3999
4574
  clear(): Promise<void>;
4000
4575
  }
4001
4576
 
4002
- export { AgentTool, AgentToolSet, AttachmentsNotSupportedError, ContextWindowExceededError, DECISION_PROVIDERS, DEFAULT_COMPACTION_THRESHOLD_RATIO, DEFAULT_DECISION_CONFIDENCE_THRESHOLD, DEFAULT_DECISION_TIMEOUT_MS, EgressError, FILES_STORE, FIND_TOOLS_NAME, FORGET_SKILL_TOOL, GENERATE_IMAGE_TOOL, GENERATE_SPEECH_TOOL, ImagesNotSupportedError, IndexedDBRunStore, IndexedDBStore, KEYS_STORE, MEDIA_AUDIO_TYPES, MEDIA_DEFAULT_MAX_CALLS, MEDIA_FOLDER, MEDIA_IMAGE_TYPES, MEDIA_MAX_ATTACHED_AUDIO, MEDIA_MAX_AUDIO_INPUT_BYTES, MEDIA_MAX_IMAGE_BYTES, MEDIA_MAX_PROMPT_CHARS, MEDIA_MAX_SPEECH_BYTES, MEDIA_MAX_SPEECH_CHARS, MEDIA_MAX_TRANSCRIPT_CHARS, MEDIA_TIMEOUT_MS, MODEL_TIERS, MediaBudgetError, MediaError, MemoryCredentialStore, MemoryRunStore, MemorySkillStore, MemoryStore, PIPELINE_LIMITS, PipelineNodeError, PipelineValidationError, PlanSchema, PlanStepSchema, REPLAY_NOTE, RUNS_STORE, ReplanSchema, SAVE_SKILL_TOOL, SEARCH_API_BASE_URL, SEARCH_DEFAULT_MAX_RESULTS, SEARCH_MAX_QUERY_CHARS, SEARCH_MAX_RESULTS, SEARCH_MAX_SNIPPET_CHARS, SEARCH_MAX_TITLE_CHARS, SEARCH_MAX_TOTAL_CHARS, SEARCH_MAX_URL_CHARS, SEARCH_PROVIDERS, SECRETS_STORE, SESSIONS_STORE, SKILL_TOOL_NAMES, SPAWN_INPUT_SCHEMA, SPAWN_SUBAGENT_TOOL, SUBAGENT_DEFAULTS, SUBAGENT_MAX_DEPTH_LIMIT, SubagentSpawnError, TOOL_APPROVAL_MODES, TOOL_SEARCH_WINDOW_SHARE, TRANSCRIBE_AUDIO_TOOL, TieredPlanSchema, TieredPlanStepSchema, ToolBudgetError, ToolDeniedError, VaultCredentialStore, VaultOptions, VfsSkillStore, VirtualFileSystem, WEBLLM_DEFAULT_CONTEXT_WINDOW, WEB_FETCH_TOOL, WEB_SEARCH_TOOL, acceptMedia, adoptSubagentEvent, askDecisionModel, attachmentKind, buildMediaModelFromSpec, buildModelFromStage, buildSearchRequest, bytesToBase64, checkEgressUrl, checkLimits, classifyAddress, compactHistory, compactSteps, compressHistory, contextOverflowOf, contextWindowOf, createAgent, createEgressTools, createFileTools, createFindToolsTool, createGuardedFetch, createLearning, createLogger, createMedia, createPipeline, createPlan, createRunControl, createSearchTools, createSkillTools, createSubagentTool, createToolResultClearer, createWebFetchTool, createWebLLMModel, createWebSearchTool, decideReplan, decideToolPermission, decisionEgressPolicy, decisionModelFromAiSdk, decryptJSON, defaultPrompts, defineSkill, defineTool, directBrowserOk, dispatch, encryptJSON, escalationReasonOf, messageTokens as estimateMessagesTokens, estimateTokens, executeStep, fileToolBindingOf, findSecret, fitCompactionToWindow, generate, generateStructured, getOrCreateVaultKey, hostMatches, htmlToText, isAttachmentRefusal, isDirectModel, isEscalatableError, isImageRefusal, isProviderSpec, isReadOnlyTool, isReplayedToolOutput, isTextMime, isWebGPUAvailable, learnedPreamble, limitModelOutput, loadSkillFromUrl, looksLikeJson, markReadOnly, matchRule, mediaTypeOf, mediaUsageOf, mergeProviderOptions, mimeFromPath, nextStrongerTier, nodeResolver, normalizePath, normalizePipeline, normalizeSkillName, normalizeSteps, normalizeUsage, openAgentWebDB, outputCapNotice, parseExecutorResponse, parsePlainText, parsePlannerResponse, parseReplannerResponse, parseSearchResponse, parseSkillMarkdown, pickTier, preloadWebLLMModel, renderActiveSkills, renderCatalog, renderPipelineNodeInput, renderSearchCatalog, renderSkillIndex, replanWanted, resolveBudgets, resolveCaching, resolveCompaction, resolveConfig, resolveDecisionModel, resolveDynamicSubagents, resolveEgressPolicy, resolveEscalation, resolveModel, resolveResume, resolveStage, resolveThinking, runToolLoop, sanitizeSearchResults, schemaHintOf, searchEgressPolicy, searchTools, selectToolMode, serveSubagentWorker, shouldReplan, sniffMediaType, splitBlocker, stageOutputCap, stream, supportsImages, supportsNativeTools, supportsPdf, supportsStructuredOutput, synthesizeAnswer, testPipelineCondition, thinkingFor, toFilePart, toImagePart, tokenize, toolCatalogOf, toolDefinitionTokens, toolRunContextOf, unloadWebLLMModel, validatePipeline, webLLMContextWindow, withRollingBreakpoint, withSystem, withWebLLMContextWindow, wrapTranscript };
4003
- export type { Agent, AgentContext, AgentEvent, AgentEventHandler, AgentLogger, AgentLoggerSink, AgentWebDBOptions, AttachmentKind, BrowserAgentConfig, ClearedInfo, CompactOptions, CompactResult, CompactionConfig, CompressOptions, ContextStore, CredentialStore, DecisionFallbackReason, DecisionPoint, EffectiveToolStrategy, EgressErrorCode, EncryptedBlob, EscalationConfig, EscalationReason, ExecutorPromptContext, ExecutorResult, FileToolBinding, FileToolsOptions, GenerateOptions, GuardedFetch, IAiSdkDecisionOptions, IDecisionAnswer, IDecisionCallOptions, IDecisionConfig, IDecisionEvent, IDecisionModel, IDecisionModelSpec, IDecisionOption, IDecisionOutcome, IDecisionQuestion, IDynamicSubagentsConfig, IEgressPolicy, IMedia, IMediaConfig, IMediaFile, IMediaModelSpec, IMediaOptions, IMediaRun, IMediaUsage, IPlan, IPlanStep, IResolvedDynamicSubagents, IResolvedEgressPolicy, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, ISanitizedSearch, ISearchConfig, ISearchOptions, ISearchRequest, ISearchResult, IStepEscalation, IStepResult, ISubagentsConfig, IToolCall, ITranscription, IUsage, IWebFetchOptions, IWebSearchOptions, IndexedDBRunStoreOptions, IndexedDBStoreOptions, Learning, LearningConfig, LimitBreach, LimitKind, LoadSkillOptions, LogLevel, MediaImageModel, MediaKind, MediaModelKind, MediaSpeechModel, MediaTranscriptionModel, MessageEndpoint, ModelInput, ModelTier, NodeResolverOptions, OutputCap, ParentToWorker, Phase, PhaseBudgets, Pipeline, PipelineCondition, PipelineDefinition, PipelineEdge, PipelineEvent, PipelineIssue, PipelineNode, PipelineNodeContext, PipelineNodeInput, PipelineNodeOutput, PipelineNodeRunner, PipelineNodeSource, PipelineOptions, PipelineResult, PipelineRoute, PipelineRunOptions, PipelineStop, PipelineTraceEntry, PipelineUsage, PipelineValidation, PlanShape, PlannerPromptContext, PlannerResult, PromptCachingSetting, PromptParts, Prompts, ProviderModelSpec, ProviderOptionsMap, ProviderType, ProxiedToolSpec, RawAction, ReplanDecision, ReplanMode, ReplanShape, ReplanTrigger, ReplannerPromptContext, ReplannerResult, ResolvedCaching, ResolvedCompaction, ResolvedConfig, ResolvedStage, ResolvedThinking, RunControl, RunFile, RunImage, RunOptions, RunPersistence, RunResult, RunSnapshot, RunStatus, RunStoreOptions, SandboxConfig, SandboxWorkerLike, SaveSkillInput, SearchEngine, SearchFreshness, SearchProvider, SearchToolsOptions, ServeSubagentOptions, Skill, SkillOrigin, SkillStore, StageInput, StageOverride, StepComplexity, StoredMessage, StructuredResult, SubagentDefaultTools, SubagentInfo, SubagentProfile, SubagentToolOptions, SubagentWorkerConfig, SynthesizerPromptContext, ThinkingConfig, ThinkingLevel, ThinkingSetting, ThinkingStage, TierReason, TokenLimits, ToolApprovalConfig, ToolApprovalDecision, ToolApprovalMode, ToolApprovalRequest, ToolCallMode, ToolCatalogEntry, ToolLoopCallbacks, ToolLoopOptions, ToolLoopResult, ToolMode, ToolPermission, ToolResultClearing, ToolRunContext, ToolSelectionStrategy, UsagePhase, VfsListener, VirtualFile, VirtualFileInfo, VirtualFileSystemOptions, WebLLMAppConfigLike, WebLLMModelOptions, WorkerLike, WorkerToParent };
4577
+ export { APP_SAMPLING_MAX_IMAGES, APP_SAMPLING_MAX_IMAGE_BYTES, APP_SAMPLING_MAX_INPUT_CHARS, APP_SAMPLING_MAX_MESSAGES, APP_SAMPLING_MAX_SYSTEM_CHARS, APP_SAMPLING_MAX_TOKENS, APP_SAMPLING_PER_APP, APP_SAMPLING_PER_MINUTE, APP_SAMPLING_REASONING_TOKENS, APP_SAMPLING_RPC_CODES, AgentTool, AgentToolSet, AppSamplingError, AttachmentsNotSupportedError, ContextWindowExceededError, DECISION_PROVIDERS, DEFAULT_COMPACTION_THRESHOLD_RATIO, DEFAULT_DECISION_CONFIDENCE_THRESHOLD, DEFAULT_DECISION_TIMEOUT_MS, EgressError, FILES_STORE, FIND_TOOLS_NAME, FORGET_SKILL_TOOL, GENERATE_IMAGE_TOOL, GENERATE_SPEECH_TOOL, ImagesNotSupportedError, IndexedDBRunStore, IndexedDBStore, KEYS_STORE, MEDIA_AUDIO_TYPES, MEDIA_DEFAULT_MAX_CALLS, MEDIA_FOLDER, MEDIA_IMAGE_TYPES, MEDIA_MAX_ATTACHED_AUDIO, MEDIA_MAX_AUDIO_INPUT_BYTES, MEDIA_MAX_IMAGE_BYTES, MEDIA_MAX_PROMPT_CHARS, MEDIA_MAX_SPEECH_BYTES, MEDIA_MAX_SPEECH_CHARS, MEDIA_MAX_TRANSCRIPT_CHARS, MEDIA_TIMEOUT_MS, MODEL_TIERS, McpAppToolResult, McpElicitationReason, McpElicitationSchema, McpSkillConsent, McpSkillConsentView, MediaBudgetError, MediaError, MemoryCredentialStore, MemoryRunStore, MemorySkillStore, MemoryStore, PIPELINE_LIMITS, PipelineNodeError, PipelineValidationError, PlanSchema, PlanStepSchema, REPLAY_NOTE, RUNS_STORE, ReplanSchema, SAVE_SKILL_TOOL, SEARCH_API_BASE_URL, SEARCH_DEFAULT_MAX_RESULTS, SEARCH_GOOGLE_DEFAULT_MODEL, SEARCH_GOOGLE_NOTE, SEARCH_MAX_QUERY_CHARS, SEARCH_MAX_RESULTS, SEARCH_MAX_SNIPPET_CHARS, SEARCH_MAX_SUMMARY_CHARS, SEARCH_MAX_TITLE_CHARS, SEARCH_MAX_TOTAL_CHARS, SEARCH_MAX_URL_CHARS, SEARCH_PROVIDERS, SECRETS_STORE, SESSIONS_STORE, SKILL_TOOL_NAMES, SPAWN_INPUT_SCHEMA, SPAWN_SUBAGENT_TOOL, SUBAGENT_DEFAULTS, SUBAGENT_MAX_DEPTH_LIMIT, SubagentSpawnError, TOOL_APPROVAL_MODES, TOOL_APPROVAL_TIMEOUT_MS, TOOL_SEARCH_WINDOW_SHARE, TRANSCRIBE_AUDIO_TOOL, TieredPlanSchema, TieredPlanStepSchema, ToolBudgetError, ToolDeniedError, VaultCredentialStore, VaultOptions, VfsSkillStore, VirtualFileSystem, WEBLLM_DEFAULT_CONTEXT_WINDOW, WEB_FETCH_TOOL, WEB_SEARCH_TOOL, acceptMedia, adoptSubagentEvent, appSamplingRequestOf, appSamplingText, askDecisionModel, attachmentKind, buildMediaModelFromSpec, buildModelFromStage, buildSearchRequest, bytesToBase64, checkEgressUrl, checkLimits, classifyAddress, compactHistory, compactSteps, compressHistory, contextOverflowOf, contextWindowOf, createAgent, createAppSamplingLimiter, createEgressTools, createFileTools, createFindToolsTool, createGuardedFetch, createLearning, createLogger, createMedia, createPipeline, createPlan, createRunControl, createSearchTools, createSkillTools, createSubagentTool, createToolResultClearer, createWebFetchTool, createWebLLMModel, createWebSearchTool, decideReplan, decideToolPermission, decisionEgressPolicy, decisionModelFromAiSdk, decryptJSON, defaultPrompts, defineSkill, defineTool, directBrowserOk, dispatch, encryptJSON, escalationReasonOf, messageTokens as estimateMessagesTokens, estimateTokens, executeStep, fileToolBindingOf, findSecret, fitCompactionToWindow, generate, generateStructured, getOrCreateVaultKey, hostMatches, htmlToText, isAttachmentRefusal, isCodeExecutionTool, isDirectModel, isEscalatableError, isImageRefusal, isProviderSpec, isReadOnlyTool, isReplayedToolOutput, isTextMime, isWebGPUAvailable, learnedPreamble, limitModelOutput, loadSkillFromUrl, looksLikeJson, markCodeExecution, markReadOnly, matchRule, mediaTypeOf, mediaUsageOf, mergeProviderOptions, mimeFromPath, nextStrongerTier, nodeResolver, normalizePath, normalizePipeline, normalizeSkillName, normalizeSteps, normalizeUsage, openAgentWebDB, outputCapNotice, parseExecutorResponse, parsePlainText, parsePlannerResponse, parseReplannerResponse, parseSearchResponse, parseSkillMarkdown, pickTier, preloadWebLLMModel, renderActiveSkills, renderCatalog, renderPipelineNodeInput, renderSearchCatalog, renderSkillIndex, replanWanted, resolveAppSampling, resolveBudgets, resolveCaching, resolveCompaction, resolveConfig, resolveDecisionModel, resolveDynamicSubagents, resolveEgressPolicy, resolveEscalation, resolveModel, resolveResume, resolveStage, resolveThinking, runToolLoop, sanitizeSearchResults, schemaHintOf, searchEgressPolicy, searchStatusMessage, searchToolResult, searchTools, selectToolMode, serveSubagentWorker, shouldReplan, skillPreamble, sniffMediaType, splitBlocker, stageOutputCap, stream, supportsImages, supportsNativeTools, supportsPdf, supportsStructuredOutput, synthesizeAnswer, testPipelineCondition, thinkingFor, toFilePart, toImagePart, tokenize, toolCatalogOf, toolDefinitionTokens, toolRunContextOf, unloadWebLLMModel, validatePipeline, webLLMContextWindow, withRollingBreakpoint, withSystem, withWebLLMContextWindow, wrapTranscript };
4578
+ export type { Agent, AgentContext, AgentEvent, AgentEventHandler, AgentLogger, AgentLoggerSink, AgentWebDBOptions, AppSamplingErrorCode, AppSamplingImage, AppSamplingMessage, AppSamplingOptions, AppSamplingRequest, AppSamplingResult, AppSamplingSettings, AppSamplingView, AppToolCallRequest, AttachmentKind, BrowserAgentConfig, ClearedInfo, CompactOptions, CompactResult, CompactionConfig, CompressOptions, ContextStore, CredentialStore, DecisionFallbackReason, DecisionPoint, EffectiveToolStrategy, EgressErrorCode, EncryptedBlob, EscalationConfig, EscalationReason, ExecutorPromptContext, ExecutorResult, FileToolBinding, FileToolsOptions, GenerateOptions, GuardedFetch, IAiSdkDecisionOptions, IDecisionAnswer, IDecisionCallOptions, IDecisionConfig, IDecisionEvent, IDecisionModel, IDecisionModelSpec, IDecisionOption, IDecisionOutcome, IDecisionQuestion, IDynamicSubagentsConfig, IEgressPolicy, IMedia, IMediaConfig, IMediaFile, IMediaModelSpec, IMediaOptions, IMediaRun, IMediaUsage, IPlan, IPlanStep, IResolvedDynamicSubagents, IResolvedEgressPolicy, ISandboxConfig, ISandboxError, ISandboxLimits, ISandboxResult, ISanitizedSearch, ISearchAnswer, ISearchConfig, ISearchOptions, ISearchRequest, ISearchResult, ISearchToolResult, ISearchUsage, IStepEscalation, IStepResult, ISubagentsConfig, IToolCall, ITranscription, IUsage, IWebFetchOptions, IWebSearchOptions, IndexedDBRunStoreOptions, IndexedDBStoreOptions, Learning, LearningConfig, LimitBreach, LimitKind, LoadSkillOptions, LogLevel, McpSkillOrigin, MediaImageModel, MediaKind, MediaModelKind, MediaSpeechModel, MediaTranscriptionModel, MessageEndpoint, ModelInput, ModelTier, NodeResolverOptions, OutputCap, ParentToWorker, Phase, PhaseBudgets, Pipeline, PipelineCondition, PipelineDefinition, PipelineEdge, PipelineEvent, PipelineIssue, PipelineNode, PipelineNodeContext, PipelineNodeInput, PipelineNodeOutput, PipelineNodeRunner, PipelineNodeSource, PipelineOptions, PipelineResult, PipelineRoute, PipelineRunOptions, PipelineStop, PipelineTraceEntry, PipelineUsage, PipelineValidation, PlanShape, PlannerPromptContext, PlannerResult, PromptCachingSetting, PromptParts, Prompts, ProviderModelSpec, ProviderOptionsMap, ProviderType, ProxiedToolSpec, RawAction, ReplanDecision, ReplanMode, ReplanShape, ReplanTrigger, ReplannerPromptContext, ReplannerResult, ResolvedCaching, ResolvedCompaction, ResolvedConfig, ResolvedStage, ResolvedThinking, RunControl, RunFile, RunImage, RunOptions, RunPersistence, RunResult, RunSnapshot, RunStatus, RunStoreOptions, SandboxConfig, SandboxWorkerLike, SaveSkillInput, SearchEngine, SearchFreshness, SearchProvider, SearchToolsOptions, ServeSubagentOptions, Skill, SkillOrigin, SkillStore, StageInput, StageOverride, StepComplexity, StoredMessage, StructuredResult, SubagentDefaultTools, SubagentInfo, SubagentProfile, SubagentToolOptions, SubagentWorkerConfig, SynthesizerPromptContext, ThinkingConfig, ThinkingLevel, ThinkingSetting, ThinkingStage, TierReason, TokenLimits, ToolApprovalApp, ToolApprovalConfig, ToolApprovalContext, ToolApprovalDecision, ToolApprovalMode, ToolApprovalRequest, ToolCallMode, ToolCatalogEntry, ToolLoopCallbacks, ToolLoopOptions, ToolLoopResult, ToolMode, ToolPermission, ToolResultClearing, ToolRunContext, ToolSelectionStrategy, UsagePhase, VfsListener, VirtualFile, VirtualFileInfo, VirtualFileSystemOptions, WebLLMAppConfigLike, WebLLMModelOptions, WorkerLike, WorkerToParent };