@dudko.dev/agent-web 0.0.39 → 0.0.41

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 +407 -13
  2. package/dist/agent-web.js +169 -161
  3. package/dist/agent-web.js.map +1 -1
  4. package/dist/chunk-4FBTBE74.js +510 -0
  5. package/dist/chunk-4FBTBE74.js.map +1 -0
  6. package/dist/{chunk-TZITKUFW.js → chunk-L7Y3QRAM.js} +152 -20
  7. package/dist/chunk-L7Y3QRAM.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-YUA2BHRM.js +584 -0
  11. package/dist/chunk-YUA2BHRM.js.map +1 -0
  12. package/dist/elicitation-BA1knkdA.d.cts +566 -0
  13. package/dist/elicitation-BA1knkdA.d.ts +566 -0
  14. package/dist/index.cjs +1819 -223
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +690 -117
  17. package/dist/index.d.ts +690 -117
  18. package/dist/index.js +1281 -187
  19. package/dist/index.js.map +1 -1
  20. package/dist/mcp.cjs +2240 -95
  21. package/dist/mcp.cjs.map +1 -1
  22. package/dist/mcp.d.cts +303 -21
  23. package/dist/mcp.d.ts +303 -21
  24. package/dist/mcp.js +1675 -91
  25. package/dist/mcp.js.map +1 -1
  26. package/dist/{sandbox-KG6OUG24.js → sandbox-ZDQIIZS7.js} +21 -8
  27. package/dist/sandbox-ZDQIIZS7.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 +5 -5
  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.cts 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.cjs';
3
- export { I as IndexedDBVault } from './vault-BatBaRQP.cjs';
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 McpElicitationSchema, f as McpElicitationReason, g as McpAppToolResult } from './elicitation-BA1knkdA.cjs';
3
+ export { I as IndexedDBVault, h as MCP_APPS_EXTENSION, i as MCP_APP_MAX_HTML_CHARS, j as MCP_APP_MAX_RESULT_CHARS, k as MCP_APP_MIME_TYPE, l as MCP_SKILLS_EXTENSION, m as MCP_SKILLS_MAX_PER_SERVER, n as MCP_SKILLS_MAX_TOTAL, o as MCP_SKILL_BODY_MAX_CHARS, p as MCP_SKILL_CONSENTS, q as MCP_SKILL_CONSENT_DEFAULT, r as MCP_SKILL_DESCRIPTION_MAX_CHARS, s as MCP_SKILL_FILE_MAX_CHARS, t as MCP_SKILL_MAX_RESOURCES, u as MCP_SKILL_MAX_TOTAL_BYTES, v as MCP_SKILL_URI_MAX_CHARS, w as McpAppCsp, x as McpAppPermissions, y as McpAppResource, z as McpAppVisibility, A as McpElicitationFieldSchema, B as McpSkillsOptions, C as McpSkillsSetting, D as mcpAppOrigin, E as mcpSkillEntryRefusal, F as mcpSkillPreamble, G as mcpSkillUriRefusal } from './elicitation-BA1knkdA.cjs';
4
4
  import { A as AgentToolSet, a as AgentTool } from './types-DwSMj_Xs.cjs';
5
5
  export { p as promptHintOf } from './types-DwSMj_Xs.cjs';
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,51 @@ 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
+ }
809
853
  /**
810
854
  * 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.
855
+ * skill is loaded so the runner can keep it active for later steps. With `mcp`, an MCP server's
856
+ * skill enters the context only once the person let it in (`acquireMcpSkill`), and a skill a
857
+ * server names by URI can be loaded with `{ server, uri }`.
812
858
  */
813
- declare const createSkillTools: (skills: Skill[], onLoad?: (skill: Skill) => void) => ToolSet;
859
+ declare const createSkillTools: (skills: Skill[], onLoad?: (skill: Skill) => void, mcp?: SkillToolsMcp) => ToolSet;
814
860
 
815
861
  declare const SAVE_SKILL_TOOL = "save_skill";
816
862
  declare const FORGET_SKILL_TOOL = "forget_skill";
@@ -1097,9 +1143,10 @@ declare const createEgressTools: (egress: boolean | IEgressPolicy | undefined) =
1097
1143
 
1098
1144
  /**
1099
1145
  * 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.
1146
+ * a search engine's answer is cleaned before a model reads it, and the one built-in provider
1147
+ * (Google Search through Gemini grounding) as a pure request builder and response parser (one
1148
+ * HTTP call). Pure, no imports, no clock: the request itself is made by each package's own safe
1149
+ * fetch.
1103
1150
  *
1104
1151
  * This file is a COPY, byte for byte, in `@dudko.dev/agent` (`src/web-search-shared.ts`) and
1105
1152
  * `@dudko.dev/agent-web` (`src/tools/web-search-shared.ts`): change both. The Node package's
@@ -1143,11 +1190,24 @@ interface ISearchOptions {
1143
1190
  * returns is treated like a built-in adapter's answer - cleaned, capped and filtered.
1144
1191
  */
1145
1192
  type SearchEngine = (query: string, options: ISearchOptions) => Promise<ISearchResult[]>;
1146
- /** The hosted search APIs with a built-in adapter. */
1147
- type SearchProvider = 'brave' | 'tavily' | 'searxng';
1193
+ /**
1194
+ * The built-in provider. One: Google Search through the Gemini API's grounding (`google_search`),
1195
+ * which needs a Gemini (Google AI Studio) key and nothing else. Any other search API is the
1196
+ * host's `engine` function.
1197
+ */
1198
+ type SearchProvider = 'google';
1148
1199
  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>;
1200
+ /** Where the provider's API lives (a `baseURL` of the host - a gateway - replaces it). */
1201
+ declare const SEARCH_API_BASE_URL: Record<SearchProvider, string>;
1202
+ /**
1203
+ * The model the grounding call is made with when the host names none: the cheapest one that
1204
+ * answered a free-tier key with grounding on the day it was measured (2026-11-26).
1205
+ */
1206
+ declare const SEARCH_GOOGLE_DEFAULT_MODEL = "gemini-2.5-flash-lite";
1207
+ /** The most of the grounding model's answer a model sees as `summary`. */
1208
+ declare const SEARCH_MAX_SUMMARY_CHARS = 1000;
1209
+ /** Said in every result of the google provider: what its URLs and its text are. */
1210
+ declare const SEARCH_GOOGLE_NOTE: string;
1151
1211
  /** One HTTP call to a search API. The key, if any, is in `headers` only - never in the URL. */
1152
1212
  interface ISearchRequest {
1153
1213
  url: string;
@@ -1162,19 +1222,48 @@ interface ISearchRequestInput {
1162
1222
  freshness?: SearchFreshness;
1163
1223
  apiKey?: string;
1164
1224
  baseURL?: string;
1225
+ /** The Gemini model that makes the grounding call (default SEARCH_GOOGLE_DEFAULT_MODEL). */
1226
+ model?: string;
1227
+ /** The current time in ms, for `freshness` (this file reads no clock). */
1228
+ now?: number;
1229
+ }
1230
+ /** What a search spent in model tokens, as the API reported it. */
1231
+ interface ISearchUsage {
1232
+ inputTokens: number;
1233
+ outputTokens: number;
1234
+ totalTokens: number;
1235
+ reasoningTokens: number;
1236
+ }
1237
+ /** A provider's answer, parsed: raw third-party values until `sanitizeSearchResults`. */
1238
+ interface ISearchAnswer {
1239
+ results: unknown[];
1240
+ /** The grounding model's whole answer (raw). */
1241
+ summary?: unknown;
1242
+ /** Absent when the API reported none. */
1243
+ usage?: ISearchUsage;
1165
1244
  }
1166
1245
  /**
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
1246
+ * The request for one query, per the Gemini API's public documentation:
1247
+ * POST {base}/v1beta/models/{model}:generateContent header x-goog-api-key
1248
+ * { systemInstruction, contents: [the query], tools: [{ google_search }], generationConfig }
1249
+ * The query is the only text of the conversation in it. The API has no result count: the list
1250
+ * is cut on the way back.
1171
1251
  */
1172
1252
  declare const buildSearchRequest: (input: ISearchRequestInput) => ISearchRequest;
1173
1253
  /**
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.
1254
+ * What a grounded answer holds, mapped to results of `{ title, url, snippet }` and nothing else,
1255
+ * the model's answer, and what the call spent. A source is a `groundingChunks[].web` (`uri` is a
1256
+ * Google redirect link, `title` the site's name); its snippet is the pieces of the answer that
1257
+ * `groundingSupports` attribute to it (fragments as the API cut them, joined with an ellipsis). Still raw third-party values: `sanitizeSearchResults` is
1258
+ * what makes them safe to show.
1259
+ */
1260
+ declare const parseSearchResponse: (provider: SearchProvider, json: unknown) => ISearchAnswer;
1261
+ /**
1262
+ * What a failed call says to the model: the provider, the model, the status, the API's own error
1263
+ * code word and what it usually means. Never the error's text: that is third-party text, and may
1264
+ * echo what was sent. `body` is the parsed error body, if there was one.
1176
1265
  */
1177
- declare const parseSearchResponse: (provider: SearchProvider, json: unknown) => unknown[];
1266
+ declare const searchStatusMessage: (provider: SearchProvider, status: number, model?: string, body?: unknown) => string;
1178
1267
  interface ISanitizedSearch {
1179
1268
  results: ISearchResult[];
1180
1269
  /** Results dropped because the host's egress policy does not let the model reach them. */
@@ -1185,49 +1274,73 @@ interface ISanitizedSearch {
1185
1274
  /**
1186
1275
  * What a model sees of an engine's answer. `raw` is whatever came back - nothing about it is
1187
1276
  * 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.
1277
+ * `accepts` (the egress policy; it is also handed the result's raw title) drops links the model
1278
+ * could not fetch, and the list stops at `maxResults` and at SEARCH_MAX_TOTAL_CHARS.
1190
1279
  */
1191
1280
  declare const sanitizeSearchResults: (raw: unknown, options?: {
1192
1281
  maxResults?: number;
1193
- accepts?: (url: URL) => boolean;
1282
+ accepts?: (url: URL, title: unknown) => boolean;
1194
1283
  }) => ISanitizedSearch;
1284
+ /** What `web_search` returns to the model. */
1285
+ interface ISearchToolResult {
1286
+ query: string;
1287
+ results: ISearchResult[];
1288
+ /** The google provider, when no source came with a snippet: the grounding model's answer, cut. */
1289
+ summary?: string;
1290
+ /** The google provider: what its URLs and its text are. */
1291
+ note?: string;
1292
+ filtered?: number;
1293
+ truncated?: true;
1294
+ untrusted: true;
1295
+ }
1296
+ /**
1297
+ * The tool's result, from the cleaned list and - for the google provider - the parsed answer.
1298
+ * The model's `summary` is attached only when there are sources, none of them carries a snippet
1299
+ * and none was filtered out: a summary cannot be cut to the sources that remain.
1300
+ */
1301
+ declare const searchToolResult: (query: string, clean: ISanitizedSearch, answer?: ISearchAnswer) => ISearchToolResult;
1195
1302
 
1196
1303
  /**
1197
1304
  * `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`).
1305
+ * library ships no key: the host passes a search engine of its own (a function - any search API)
1306
+ * or names the one built-in provider, Google Search through Gemini grounding. Browser sibling of
1307
+ * the server's `ISearchConfig` - same names - except that a key is never written here:
1308
+ * `credentialRef` names it in the `CredentialStore` the agent was given (`config.credentials`).
1202
1309
  *
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.
1310
+ * The Gemini API answers a page directly (CORS). See docs/capabilities.md.
1206
1311
  */
1207
1312
  interface ISearchConfig {
1208
1313
  /**
1209
1314
  * A search engine of your own: `(query, { maxResults, freshness, signal }) => results`. Its
1210
1315
  * 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`.
1316
+ * the provider's. Exactly one of `engine` / `provider`.
1212
1317
  */
1213
1318
  engine?: SearchEngine;
1214
- /** A built-in adapter: 'brave' | 'tavily' | 'searxng'. */
1319
+ /**
1320
+ * The built-in provider: 'google' - Google Search through the Gemini API's grounding. One
1321
+ * generateContent call per search with the `google_search` tool: it needs a Gemini (Google AI
1322
+ * Studio) key and nothing else, and it spends that model's tokens (counted in the run's usage,
1323
+ * phase 'search'). Result URLs are Google redirect links, snippets the model's own summary.
1324
+ */
1215
1325
  provider?: SearchProvider;
1216
1326
  /**
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.
1327
+ * Where the Gemini API key is kept in the agent's `CredentialStore` (it can be the ref of a
1328
+ * Gemini model's own key). Read at each call and sent in a header to that API only; never in a
1329
+ * URL, an event, a log line, an error or a result.
1219
1330
  */
1220
1331
  credentialRef?: string;
1332
+ /** The Gemini model that makes the grounding call. Default 'gemini-2.5-flash-lite'. */
1333
+ model?: string;
1221
1334
  /**
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).
1335
+ * Replaces the public endpoint (a gateway of yours that holds the key - `credentialRef` is
1336
+ * then optional).
1224
1337
  */
1225
1338
  baseURL?: string;
1226
1339
  /** Results per call when the model does not say (default 5, at most 10). */
1227
1340
  maxResults?: number;
1228
1341
  /**
1229
1342
  * 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.
1343
+ * gateway of yours). It widens nothing else: the request can still reach only that one host.
1231
1344
  */
1232
1345
  allowPrivateNetwork?: boolean;
1233
1346
  /** Whole request to the search API, in ms. Default 15_000. */
@@ -1261,6 +1374,12 @@ declare const searchEgressPolicy: (search: ISearchConfig, egress?: boolean | IEg
1261
1374
  * request goes through the guarded fetch under `searchEgressPolicy`; what comes back is
1262
1375
  * third-party text and is cleaned, capped and - when the agent has an egress policy - filtered
1263
1376
  * to what `web_fetch` could open, so a search is not a way to read around the allow / deny lists.
1377
+ *
1378
+ * The google provider's links are Google redirect links: the filter can judge only that host
1379
+ * (plus the site the API names, which is enough to drop a denied site and never to allow one).
1380
+ * Nothing here follows them. `web_fetch` opens one only under `egress.followRedirects` (the
1381
+ * guarded fetch then judges where it ended) and, from a page, only through an `egress.fetch`
1382
+ * of the host's: the redirect host sends no CORS headers.
1264
1383
  */
1265
1384
  declare const createWebSearchTool: (options: IWebSearchOptions) => AgentTool;
1266
1385
  /** The tools `config.search` turns on (none when it is off). */
@@ -1529,15 +1648,154 @@ declare const normalizePipeline: (definition: PipelineDefinition) => PipelineDef
1529
1648
  declare const validatePipeline: (definition: PipelineDefinition) => PipelineValidation;
1530
1649
  declare const renderPipelineNodeInput: (input: PipelineNodeInput) => string;
1531
1650
 
1651
+ /**
1652
+ * Tool consent. Every tool call passes a gate that decides allow / ask / deny:
1653
+ *
1654
+ * - `autopilot` — run everything (default; explicit `rules` still apply);
1655
+ * - `ask-writes` — run read-only tools, ask before anything that may change state;
1656
+ * - `ask-all` — ask before every call;
1657
+ * - `read-only` — run read-only tools, refuse the rest without asking.
1658
+ *
1659
+ * A tool is read-only when its MCP annotations say so (`readOnlyHint`) or the
1660
+ * host marked it (`defineTool({ readOnly: true })` / `markReadOnly`). Unknown =
1661
+ * may write: the safe assumption.
1662
+ */
1663
+ type ToolApprovalMode = 'autopilot' | 'ask-writes' | 'ask-all' | 'read-only';
1664
+ type ToolPermission = 'allow' | 'ask' | 'deny';
1665
+ declare const TOOL_APPROVAL_MODES: readonly ToolApprovalMode[];
1666
+ interface ToolApprovalRequest {
1667
+ /** Unique per request — echo it back from a UI. */
1668
+ id: string;
1669
+ toolName: string;
1670
+ input: unknown;
1671
+ readOnly: boolean;
1672
+ step?: IPlanStep;
1673
+ /**
1674
+ * Set when the call comes from a helper the model started (`subagents.dynamic`), not from the
1675
+ * run itself: the helper's id (as in its `subagent.start` event) and its depth.
1676
+ */
1677
+ subagent?: {
1678
+ id: string;
1679
+ depth: number;
1680
+ };
1681
+ /**
1682
+ * Set when the call comes from an MCP App (`Agent.approveAppToolCall`), not from the model:
1683
+ * a UI says so ("The app “travel” wants to run …"). `toolName` above is then the name the
1684
+ * agent's rules match (`server__tool`), `app.tool` the server's own name for it.
1685
+ */
1686
+ app?: ToolApprovalApp;
1687
+ /**
1688
+ * Set when the call runs code (`run_js`, or a tool marked with `markCodeExecution`) while the
1689
+ * run acts on skills an MCP server served: those skills, by name. Such a call is ALWAYS asked,
1690
+ * whatever the mode, a rule or an earlier "always allow" say (the Skills extension: a server's
1691
+ * skill must not lead to code running here without a person's approval).
1692
+ */
1693
+ mcpSkills?: string[];
1694
+ /**
1695
+ * Set when the request is not about a tool call but about an MCP server's skill that is about
1696
+ * to enter the model's context (`load_skill`, the planner's pick, a resumed run; `skills` on a
1697
+ * server, consent `'ask'` / `'once-per-skill'`): the server, the skill, its description and
1698
+ * size and the very text the model would read - the SERVER's words, to show as plain text.
1699
+ * `toolName` is `'load_skill'`. Approve to let it in (`remember: true` = every skill of that
1700
+ * server for the agent's life, nested ones excepted), deny to keep it out. Asked whatever the
1701
+ * approval mode and the rules say.
1702
+ */
1703
+ skill?: McpSkillConsentView;
1704
+ }
1705
+ /** Who asks when an MCP App asks (see `ToolApprovalRequest.app`). */
1706
+ interface ToolApprovalApp {
1707
+ /** The MCP server the app came from (its tools are the only ones it may call). */
1708
+ server: string;
1709
+ /** The tool's own name on that server. */
1710
+ tool: string;
1711
+ /** The app's `ui://` resource. */
1712
+ resourceUri: string;
1713
+ }
1714
+ /** What the gate hands `onRequest` beside the request. */
1715
+ interface ToolApprovalContext {
1716
+ /**
1717
+ * Aborted when the question ends WITHOUT your answer: no decision within `timeoutMs`
1718
+ * (`signal.reason` is an Error named 'TimeoutError'), the run was stopped ('AbortError'), or
1719
+ * the handler failed. Take the prompt down then: an answer given later is ignored. Never
1720
+ * aborted once you have answered.
1721
+ */
1722
+ signal: AbortSignal;
1723
+ }
1724
+ /**
1725
+ * `true`/`false`, or an object. `remember: true` on an approval allows this
1726
+ * tool for the rest of the agent's life ("always allow").
1727
+ */
1728
+ type ToolApprovalDecision = boolean | {
1729
+ approved: boolean;
1730
+ reason?: string;
1731
+ remember?: boolean;
1732
+ };
1733
+ interface ToolApprovalConfig {
1734
+ /** Default policy (default 'autopilot'). */
1735
+ mode?: ToolApprovalMode;
1736
+ /**
1737
+ * Per-tool overrides by exact name or `*` glob, e.g. `{ 'github__delete_*': 'deny' }`.
1738
+ * They win over the mode — an explicit 'ask' still asks under autopilot.
1739
+ */
1740
+ rules?: Record<string, ToolPermission>;
1741
+ /** Resolves an approval request (a UI prompt, a policy service, …). */
1742
+ onRequest?: (req: ToolApprovalRequest, ctx: ToolApprovalContext) => ToolApprovalDecision | Promise<ToolApprovalDecision>;
1743
+ /**
1744
+ * No decision within this many ms → deny. Default 300 000 ({@link TOOL_APPROVAL_TIMEOUT_MS}).
1745
+ * `0` or `Infinity`: no bound - the question waits until the run is stopped; so does a value
1746
+ * above 2^31 - 1 (about 24.8 days, the most a timer holds). Negative or NaN: `createAgent`
1747
+ * throws. The only bound on the wait: the step's `chatTimeoutMs` (and a subagent's
1748
+ * `timeoutMs`) stop while a person decides.
1749
+ */
1750
+ timeoutMs?: number;
1751
+ }
1752
+ /** How long a question waits for a decision when `toolApproval.timeoutMs` is not set: 5 minutes. */
1753
+ declare const TOOL_APPROVAL_TIMEOUT_MS = 300000;
1754
+ /** Raised by a denied tool call; recorded as a failed call the replanner sees. */
1755
+ declare class ToolDeniedError extends Error {
1756
+ constructor(reason?: string);
1757
+ toJSON(): string;
1758
+ }
1759
+ /** Mark a tool as read-only so `ask-writes` / `read-only` let it through. Returns it. */
1760
+ declare const markReadOnly: <T extends object>(tool: T, readOnly?: boolean) => T;
1761
+ /**
1762
+ * Mark a tool as one that runs code (the sandbox's `run_js` is): while a run acts on an MCP
1763
+ * server's skill, every call of it is asked (`decideToolPermission`).
1764
+ */
1765
+ declare const markCodeExecution: <T extends object>(tool: T, codeExecution?: boolean) => T;
1766
+ declare const isCodeExecutionTool: (tool: unknown) => boolean;
1767
+ declare const isReadOnlyTool: (tool: Tool | undefined) => boolean;
1768
+ /** The most specific matching rule: an exact name, else the longest glob. Pure. */
1769
+ declare const matchRule: (rules: Record<string, ToolPermission> | undefined, toolName: string) => ToolPermission | undefined;
1770
+ /**
1771
+ * What the gate does for one call, before any human is involved. Order:
1772
+ * remembered "always allow" → most specific rule → mode default. Pure.
1773
+ * Then one rule that only ever tightens: a call that runs code (`codeExecution`) while the run
1774
+ * acts on an MCP server's skill (`mcpSkills`) is asked when it would have been allowed - by the
1775
+ * mode, a rule or an "always allow" alike. A deny stays a deny.
1776
+ */
1777
+ declare const decideToolPermission: (opts: {
1778
+ toolName: string;
1779
+ readOnly: boolean;
1780
+ mode: ToolApprovalMode;
1781
+ rules?: Record<string, ToolPermission>;
1782
+ remembered?: ReadonlySet<string>;
1783
+ codeExecution?: boolean;
1784
+ mcpSkills?: readonly string[];
1785
+ }) => ToolPermission;
1786
+
1532
1787
  type ReplanMode = 'continue' | 'revise' | 'finish';
1533
1788
  type Phase = 'plan' | 'execute' | 'replan' | 'synthesize';
1534
1789
  /**
1535
1790
  * Phases a `usage` event can be charged to: the four stages plus compaction and subagents;
1536
1791
  * `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.
1792
+ * reported); 'media' - a call to an image / speech / transcription model (`config.media`),
1793
+ * whose `usage` carries the media fields and zero tokens; and 'search' - a `web_search` through
1794
+ * the google provider (`config.search`): the grounding call is a model call, and these are the
1795
+ * tokens its API reported.
1539
1796
  */
1540
- type UsagePhase = Phase | 'compact' | 'subagent' | 'decision' | 'media';
1797
+ /** `'app'`: a completion an MCP App asked for (`Agent.sampleForApp`), outside any run. */
1798
+ type UsagePhase = Phase | 'compact' | 'subagent' | 'decision' | 'media' | 'search' | 'app';
1541
1799
  /**
1542
1800
  * Everything the agent does is streamed as a typed event so any UI (or none)
1543
1801
  * can render progress. The final answer arrives as a `final` event; there is no
@@ -1683,10 +1941,12 @@ type AgentEventBody =
1683
1941
  afterTokens: number;
1684
1942
  }
1685
1943
  /** A skill's instructions entered the context (picked by the planner, or loaded by a tool call). */
1944
+ /** `server`: the MCP server the skill came from (a skill served with `skills: true`). */
1686
1945
  | {
1687
1946
  type: 'skill.activated';
1688
1947
  name: string;
1689
1948
  by: 'plan' | 'tool';
1949
+ server?: string;
1690
1950
  }
1691
1951
  /** The agent wrote a lesson down as a skill (`config.learning`). */
1692
1952
  | {
@@ -1718,6 +1978,25 @@ type AgentEventBody =
1718
1978
  model: string;
1719
1979
  step?: IPlanStep;
1720
1980
  }
1981
+ /**
1982
+ * A file tool (`createFileTools`: `fs_write`) or the sandbox's `fs.writeFile` wrote a file to
1983
+ * the virtual file system during the run: `path` is where, `mediaType` its MIME type, `bytes`
1984
+ * its size. The content is never in an event - read it with `vfs.read(path)`. Emitted once per
1985
+ * successful write; a write that was refused or failed emits nothing.
1986
+ */
1987
+ | {
1988
+ type: 'file.written';
1989
+ path: string;
1990
+ mediaType: string;
1991
+ bytes: number;
1992
+ step?: IPlanStep;
1993
+ }
1994
+ /** A file tool (`fs_delete`) deleted a file that existed. */
1995
+ | {
1996
+ type: 'file.deleted';
1997
+ path: string;
1998
+ step?: IPlanStep;
1999
+ }
1721
2000
  /**
1722
2001
  * An audio file was transcribed: one the user attached to the run ('attachment') or one the
1723
2002
  * model asked about ('tool'). `text` is what the model reads of it (cleaned and capped).
@@ -1751,6 +2030,18 @@ type AgentEventBody =
1751
2030
  id: string;
1752
2031
  depth: number;
1753
2032
  };
2033
+ /**
2034
+ * Set when an MCP App asks (`Agent.approveAppToolCall`), not the model: the app's server,
2035
+ * the tool's own name there and the app's `ui://` resource (see `ToolApprovalRequest.app`).
2036
+ */
2037
+ app?: ToolApprovalApp;
2038
+ /** See `ToolApprovalRequest.mcpSkills`. */
2039
+ mcpSkills?: string[];
2040
+ /**
2041
+ * Set when the request is about an MCP server's skill about to enter the model's context,
2042
+ * not a tool call (see `ToolApprovalRequest.skill`): the server's words, as plain text.
2043
+ */
2044
+ skill?: McpSkillConsentView;
1754
2045
  }
1755
2046
  /** A consent decision: from the user, or `automatic` (policy denial). */
1756
2047
  | {
@@ -1761,6 +2052,63 @@ type AgentEventBody =
1761
2052
  reason?: string;
1762
2053
  automatic: boolean;
1763
2054
  }
2055
+ /**
2056
+ * An MCP server asked the user for input during a tool call (the connection's `onElicitation`
2057
+ * is being called). `message`, `requestedSchema` and `url` are the SERVER's text: cleaned and
2058
+ * capped, for a UI to show - never instructions.
2059
+ */
2060
+ | {
2061
+ type: 'mcp.elicitation-requested';
2062
+ id: string;
2063
+ server: string;
2064
+ /** The tool call that asks: the tool's name as the model called it. */
2065
+ tool: string;
2066
+ mode: 'form' | 'url';
2067
+ message: string;
2068
+ requestedSchema?: McpElicitationSchema;
2069
+ url?: string;
2070
+ step?: IPlanStep;
2071
+ /** Set when a helper (a subagent) is the one whose call asks. */
2072
+ subagent?: {
2073
+ id: string;
2074
+ depth: number;
2075
+ };
2076
+ }
2077
+ /**
2078
+ * The question was answered. Never carries a value the user entered: `fields` are the NAMES
2079
+ * of the fields an accepted form was answered with. `automatic`: nobody decided (a guard, a
2080
+ * cap, a timeout, a failed handler, a stopped run) - `reason` says which, the tool call
2081
+ * fails, and no `mcp.elicitation-requested` may have preceded it.
2082
+ */
2083
+ | {
2084
+ type: 'mcp.elicitation-answered';
2085
+ id: string;
2086
+ server: string;
2087
+ tool: string;
2088
+ action: 'accept' | 'decline' | 'cancel';
2089
+ automatic: boolean;
2090
+ reason?: McpElicitationReason;
2091
+ fields?: string[];
2092
+ }
2093
+ /**
2094
+ * A tool that declares an MCP App (`_meta.ui.resourceUri`) returned a result, on a connection
2095
+ * made with `apps: true` (`./mcp`): a UI can show the app next to the call. `tool` is the name
2096
+ * the model called, `toolName` the server's own; `input` the call's arguments; `result` what
2097
+ * the app is given (`content`, `structuredContent`, `isError`, `_meta`), absent when it was
2098
+ * larger than `MCP_APP_MAX_RESULT_CHARS`. The app's HTML is never in an event: read it with
2099
+ * the connection's `apps.readUiResource(server, resourceUri)`.
2100
+ */
2101
+ | {
2102
+ type: 'mcp.app';
2103
+ id: string;
2104
+ server: string;
2105
+ tool: string;
2106
+ toolName: string;
2107
+ resourceUri: string;
2108
+ input: Record<string, unknown>;
2109
+ result?: McpAppToolResult;
2110
+ step?: IPlanStep;
2111
+ }
1764
2112
  /**
1765
2113
  * `profile` is set when the parent chose one of the subagent's named profiles for this call.
1766
2114
  * The tree: `parentId` is the id of the subagent that made the call, or the `runId` of the run
@@ -2048,79 +2396,141 @@ declare const decisionEgressPolicy: (spec: IDecisionModelSpec) => IEgressPolicy;
2048
2396
  declare const resolveDecisionModel: (input: IDecisionModel | IDecisionModelSpec | undefined, credentials?: CredentialStore) => Promise<IDecisionModel | undefined>;
2049
2397
 
2050
2398
  /**
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.
2399
+ * MCP Apps: a completion an app asks the HOST's model for (`sampling/createMessage` sent by the
2400
+ * view, the extension's draft revision; the request is MCP's own `CreateMessageRequest`).
2057
2401
  *
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;
2402
+ * Pure, no imports: what of an app's request is accepted, what the user is shown before anything
2403
+ * is sent (the same text the model gets), and the per-app rate limit. `Agent.sampleForApp`
2404
+ * (`agent/runner.ts`) is the one caller - the request is checked here, counted, put to the host's
2405
+ * consent callback, and only then sent to the agent's model: no tools, nothing of the agent's
2406
+ * context, nothing kept. The answer goes back to the app and nowhere else.
2407
+ */
2408
+ /** The most an app may have the model write per request: a larger `maxTokens` is lowered to it. */
2409
+ declare const APP_SAMPLING_MAX_TOKENS = 1024;
2410
+ /** At most this many messages in one request. */
2411
+ declare const APP_SAMPLING_MAX_MESSAGES = 20;
2412
+ /** The text of a request (its messages and system prompt): at most this many characters. */
2413
+ declare const APP_SAMPLING_MAX_INPUT_CHARS = 16000;
2414
+ /** An app's system prompt: at most this many characters (counted in the input too). */
2415
+ declare const APP_SAMPLING_MAX_SYSTEM_CHARS = 4000;
2416
+ /** Images of one request (only to a model that reads them): at most this many... */
2417
+ declare const APP_SAMPLING_MAX_IMAGES = 4;
2418
+ /** ...each at most this many bytes. */
2419
+ declare const APP_SAMPLING_MAX_IMAGE_BYTES: number;
2420
+ /**
2421
+ * Room for the model's reasoning on top of an app's `maxTokens`, for a model that thinks. On Gemini
2422
+ * and OpenAI the reasoning counts against the output cap, and some models think whatever they are
2423
+ * told (Gemini 3 Flash spent 111 of an app's 120 tokens thinking and answered "(e.g.,"). The app's
2424
+ * `maxTokens` is meant for the answer: a model seen thinking gets this much more.
2425
+ */
2426
+ declare const APP_SAMPLING_REASONING_TOKENS = 2048;
2427
+ /** Requests of one app (server + `ui://` resource) per minute. */
2428
+ declare const APP_SAMPLING_PER_MINUTE = 5;
2429
+ /** Requests of one app for the life of the agent (a page reload starts again). */
2430
+ declare const APP_SAMPLING_PER_APP = 30;
2431
+ /** `config.appSampling`: the caps, or `false` - then `sampleForApp` refuses every request. */
2432
+ interface AppSamplingSettings {
2433
+ /** The most the model writes per request (default `APP_SAMPLING_MAX_TOKENS`). */
2434
+ maxTokens?: number;
2435
+ /** Requests of one app per minute (default `APP_SAMPLING_PER_MINUTE`). */
2436
+ maxRequestsPerMinute?: number;
2437
+ /** Requests of one app for the agent's life (default `APP_SAMPLING_PER_APP`). */
2438
+ maxRequests?: number;
2439
+ /** Characters of a request's text (default `APP_SAMPLING_MAX_INPUT_CHARS`). */
2440
+ maxInputChars?: number;
2072
2441
  /**
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.
2442
+ * Tokens of reasoning allowed on top of a request's `maxTokens`, for a model seen thinking
2443
+ * (default `APP_SAMPLING_REASONING_TOKENS`; `0` = never more than the app's `maxTokens`).
2075
2444
  */
2076
- subagent?: {
2077
- id: string;
2078
- depth: number;
2079
- };
2445
+ reasoningTokens?: number;
2080
2446
  }
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;
2447
+ interface ResolvedAppSampling {
2448
+ enabled: boolean;
2449
+ maxTokens: number;
2450
+ maxRequestsPerMinute: number;
2451
+ maxRequests: number;
2452
+ maxInputChars: number;
2453
+ reasoningTokens: number;
2454
+ }
2455
+ /** `config.appSampling` resolved; throws on a cap that is not a whole number of at least 1 (0 for `reasoningTokens`). */
2456
+ declare const resolveAppSampling: (setting: unknown) => ResolvedAppSampling;
2457
+ /** Why a request was not answered. */
2458
+ type AppSamplingErrorCode = 'disabled' | 'invalid' | 'unsupported' | 'rate-limited' | 'denied';
2459
+ /** The JSON-RPC code an app is answered with for each (`-1`: MCP's "user rejected sampling"). */
2460
+ declare const APP_SAMPLING_RPC_CODES: Record<AppSamplingErrorCode, number>;
2461
+ declare class AppSamplingError extends Error {
2462
+ readonly code: AppSamplingErrorCode;
2463
+ /** What the app is told (`APP_SAMPLING_RPC_CODES`). */
2464
+ readonly rpcCode: number;
2465
+ constructor(code: AppSamplingErrorCode, message: string);
2466
+ }
2467
+ /** An image of a request, as checked (base64, one of four raster types). */
2468
+ interface AppSamplingImage {
2469
+ mimeType: string;
2470
+ /** Base64. */
2471
+ data: string;
2472
+ /** Its size, decoded. */
2473
+ bytes: number;
2102
2474
  }
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;
2475
+ /** One message of a request, as the user is shown it and the model is sent it. */
2476
+ interface AppSamplingMessage {
2477
+ role: 'user' | 'assistant';
2478
+ /** Its text blocks, joined, without invisible characters. */
2479
+ text: string;
2480
+ /** Images (a user message only, and only to a model that reads them). */
2481
+ images: AppSamplingImage[];
2482
+ }
2483
+ /** A request as checked: what the consent callback is shown, and exactly what the model gets. */
2484
+ interface AppSamplingView {
2485
+ /** The server whose app asks. */
2486
+ server: string;
2487
+ /** The app (`ui://…`). */
2488
+ resourceUri: string;
2489
+ messages: AppSamplingMessage[];
2490
+ systemPrompt?: string;
2491
+ /** What the model may write: the app's `maxTokens`, at most the cap. */
2492
+ maxTokens: number;
2493
+ /** What the app asked for. */
2494
+ requestedMaxTokens: number;
2495
+ temperature?: number;
2107
2496
  }
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;
2497
+ /** The answer, in MCP's `CreateMessageResult` shape: a text, the model's id, why it stopped. */
2498
+ interface AppSamplingResult {
2499
+ role: 'assistant';
2500
+ content: {
2501
+ type: 'text';
2502
+ text: string;
2503
+ };
2504
+ model: string;
2505
+ stopReason: string;
2506
+ }
2507
+ /** Text as the user is shown it and the model reads it: nothing invisible in it. */
2508
+ declare const appSamplingText: (text: string) => string;
2509
+ /**
2510
+ * The parts of `params` (MCP `CreateMessageRequest.params`) this host takes, checked:
2511
+ * 1 - `APP_SAMPLING_MAX_MESSAGES` messages of role `user` / `assistant`, each a text block or a
2512
+ * list of blocks (text; an image - PNG, JPEG, GIF, WebP, base64 - in a user message only when
2513
+ * `images` is true); a system prompt; `maxTokens` (required, a whole number, lowered to the cap);
2514
+ * a temperature from 0 to 2. Refused: tools (`tools` / `toolChoice`, tool-use and tool-result
2515
+ * blocks - `hostCapabilities.sampling.tools` is not offered), audio, an image the model cannot
2516
+ * read, more text than `maxInputChars`. Ignored: `modelPreferences` (the host picks the model),
2517
+ * `includeContext` (no context is ever added), `stopSequences`, `metadata`. Throws
2518
+ * {@link AppSamplingError}.
2519
+ */
2520
+ declare const appSamplingRequestOf: (params: unknown, limits: {
2521
+ maxTokens: number;
2522
+ maxInputChars: number;
2523
+ images: boolean;
2524
+ }) => Omit<AppSamplingView, "server" | "resourceUri">;
2525
+ /**
2526
+ * The rate limit of `sampleForApp`, per app (its key: server + resource): at most `perMinute`
2527
+ * requests in any 60 s, and `total` for the life of the limiter. `take` counts a request and
2528
+ * answers `undefined`, or says which limit it hit (and does not count it). Pure: the time is
2529
+ * the caller's.
2530
+ */
2531
+ declare const createAppSamplingLimiter: (perMinute: number, total: number) => {
2532
+ take(app: string, now: number): "minute" | "total" | undefined;
2533
+ };
2124
2534
 
2125
2535
  /** Force a tool-calling strategy, or let the agent pick per model ('auto'). */
2126
2536
  type ToolMode = 'auto' | 'native' | 'prompted';
@@ -2191,12 +2601,12 @@ interface BrowserAgentConfig {
2191
2601
  egress?: boolean | IEgressPolicy;
2192
2602
  /**
2193
2603
  * 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`.
2604
+ * Off unless set. The library ships no key: pass a function (`engine` - any search API) or
2605
+ * name the built-in provider (`provider: 'google'` + `credentialRef` - Google Search through
2606
+ * Gemini grounding, which spends model tokens; the key stays in `credentials`, never here).
2607
+ * The provider's request reaches that API's host only, through the guarded fetch; with
2608
+ * `egress` set, results the model could not fetch are left out. Works without `egress` (then
2609
+ * there is no `web_fetch` to open a link) - see `ISearchConfig`.
2200
2610
  */
2201
2611
  search?: ISearchConfig;
2202
2612
  /**
@@ -2260,6 +2670,14 @@ interface BrowserAgentConfig {
2260
2670
  toolSearchThreshold?: number;
2261
2671
  /** Consent policy for tool calls: autopilot, ask before writes, ask always, read-only. */
2262
2672
  toolApproval?: ToolApprovalConfig;
2673
+ /**
2674
+ * MCP Apps asking this agent's model for a completion (`Agent.sampleForApp`, the app's
2675
+ * `sampling/createMessage`): the caps - `maxTokens` per request (1024), `maxRequestsPerMinute`
2676
+ * (5) and `maxRequests` (30) per app, `maxInputChars` (16 000) - or `false` to refuse every
2677
+ * request. Nothing happens unless a host calls `sampleForApp`, and each request is put to the
2678
+ * host's consent callback first. See docs/capabilities.md, "An app asks the model".
2679
+ */
2680
+ appSampling?: false | AppSamplingSettings;
2263
2681
  /** Reusable instruction bundles (SKILL.md) the planner/executor can pull in. */
2264
2682
  skills?: Skill[];
2265
2683
  /**
@@ -2275,6 +2693,18 @@ interface BrowserAgentConfig {
2275
2693
  * for servers you do not trust to write into a system prompt (see docs/security.md).
2276
2694
  */
2277
2695
  mcpInstructions?: boolean;
2696
+ /**
2697
+ * The MCP servers' skills (`skills` on a server of `./mcp`, experimental). `consent`: when a
2698
+ * person is asked before a skill's text enters the model's context, for every server whose own
2699
+ * `skills: { consent }` does not say - `'once-per-skill'` (default: the first time per skill in
2700
+ * the agent's life, again when its entry changes), `'ask'` (in every run that loads it) or
2701
+ * `'never'` (no question: servers you vetted). Asked through `toolApproval.onRequest`, the
2702
+ * request carrying `skill`; without a handler such a skill is not loaded. Autopilot does not
2703
+ * skip it. See the README, "MCP skills".
2704
+ */
2705
+ mcpSkills?: {
2706
+ consent?: McpSkillConsent;
2707
+ };
2278
2708
  /** Prepended to every phase's system prompt. */
2279
2709
  systemPrompt?: string;
2280
2710
  /** Override any phase prompt builder. */
@@ -2305,7 +2735,13 @@ interface BrowserAgentConfig {
2305
2735
  maxToolCalls?: number;
2306
2736
  /** Cap on the steps of one plan (default 8). */
2307
2737
  maxPlanSteps?: number;
2308
- /** Per-call timeout so a hang can't freeze a run (default 120000). */
2738
+ /**
2739
+ * Per-call timeout so a hang can't freeze a run (default 120000) - for the executor, of a
2740
+ * whole step: its rounds and its tool calls. It does not run while a tool call of the step
2741
+ * waits for a person (a tool approval, an MCP elicitation): the step goes on with the time it
2742
+ * had left once the person has answered. Those waits have bounds of their own
2743
+ * (`toolApproval.timeoutMs`, `elicitation.timeoutMs`), and stopping the run ends them at once.
2744
+ */
2309
2745
  chatTimeoutMs?: number;
2310
2746
  /** Legacy per-phase output caps; `limits.perCall` wins when both are set. */
2311
2747
  budgets?: PhaseBudgets;
@@ -2607,6 +3043,36 @@ declare const REPLAY_NOTE = "[not run again: this exact call already succeeded i
2607
3043
  */
2608
3044
  declare const isReplayedToolOutput: (output: unknown) => boolean;
2609
3045
 
3046
+ /** One deadline of a clock. */
3047
+ interface IWaitTimer {
3048
+ /** Take the deadline down; it will not fire. Safe to call twice, and after it fired. */
3049
+ cancel: () => void;
3050
+ /** Milliseconds of running time left before it fires (0 once it fired or was cancelled). */
3051
+ left: () => number;
3052
+ }
3053
+ interface IWaitClock {
3054
+ /**
3055
+ * Stop the clock: a person is being asked. Returns what starts it again, to be called exactly
3056
+ * when the wait is over (a second call does nothing). Waits may overlap - the clock runs
3057
+ * again when the last of them is over.
3058
+ */
3059
+ pause: () => () => void;
3060
+ /** Whether a wait is going on. */
3061
+ readonly paused: boolean;
3062
+ /**
3063
+ * Call `onExpire` after `ms` of this clock's RUNNING time. `unref`: do not keep a Node
3064
+ * process alive for it (as `AbortSignal.timeout` does not).
3065
+ */
3066
+ timer: (ms: number, onExpire: () => void, options?: {
3067
+ unref?: boolean;
3068
+ }) => IWaitTimer;
3069
+ /**
3070
+ * Be told when the clock stops (`true`) and when it runs again (`false`). Returns what ends
3071
+ * the subscription.
3072
+ */
3073
+ watch: (listener: (waiting: boolean) => void) => () => void;
3074
+ }
3075
+
2610
3076
  /** The effective tool-selection strategy of a run ('auto' already resolved). */
2611
3077
  type EffectiveToolStrategy = 'all' | 'plan-narrowed' | 'search';
2612
3078
  /** One executor tier of an agent with `config.executorTiers`. */
@@ -2656,6 +3122,11 @@ interface AgentContext {
2656
3122
  /** Leveled logger (config.logLevel over config.logger ?? console). */
2657
3123
  log: AgentLogger;
2658
3124
  signal?: AbortSignal;
3125
+ /**
3126
+ * The run's clock (wait-clock.ts): the executor's step limit (`chatTimeoutMs`) runs on it, and
3127
+ * it is stopped while a tool call of the run - or of a subagent below it - waits for a person.
3128
+ */
3129
+ clock?: IWaitClock;
2659
3130
  /** Current world state for grounding, or undefined when no describeState is configured. */
2660
3131
  state: () => Promise<string | undefined>;
2661
3132
  /** Session transcript loaded from memory BEFORE this run's goal was appended. */
@@ -2820,6 +3291,7 @@ interface Agent {
2820
3291
  name: string;
2821
3292
  description: string;
2822
3293
  learned?: true;
3294
+ server?: string;
2823
3295
  }[];
2824
3296
  /** The agent's own lessons (`config.learning`), with where each came from. Empty without it. */
2825
3297
  listLearnedSkills(): Skill[];
@@ -2828,6 +3300,29 @@ interface Agent {
2828
3300
  * Pass `onEvent` to receive the `skill.forgotten` event.
2829
3301
  */
2830
3302
  forgetSkill(name: string, onEvent?: (event: AgentEvent) => void): Promise<boolean>;
3303
+ /**
3304
+ * Ask this agent's consent gate about a tool call an MCP App wants to make (`./mcp` with
3305
+ * `apps: true`: the app's `tools/call`), not the model. The same `toolApproval` - its rules,
3306
+ * its handler (`onRequest`), its timeout - with two differences: under 'autopilot' a write
3307
+ * still asks (an app never writes silently; read-only tools run, as in 'ask-writes'), and
3308
+ * "always allow" given to an app is remembered for apps only, apart from the model's.
3309
+ * `onEvent` receives `tool.approval-requested` (with `app`) and `tool.approval-resolved`; a UI
3310
+ * shows the request as the app's. Resolves when the call may go; throws `ToolDeniedError`.
3311
+ * Make the call afterwards with `ConnectedMcp.apps.callAppTool`.
3312
+ */
3313
+ approveAppToolCall(call: AppToolCallRequest, onEvent?: (event: AgentEvent) => void, signal?: AbortSignal): Promise<void>;
3314
+ /**
3315
+ * Answer a completion an MCP App asks for (its `sampling/createMessage`) with this agent's
3316
+ * synthesizer model - outside any run, with no tools and none of the agent's context. The
3317
+ * request (MCP `CreateMessageRequest.params`) is checked (`appSamplingRequestOf`: text, images
3318
+ * only for a model that reads them, no tools, caps), counted against the app's rate limit
3319
+ * (`config.appSampling`), and put to `options.approve` with what the model will get; only on
3320
+ * `true` is it sent. Its tokens are charged to `usage` (and `sessionUsage`) and reported to
3321
+ * `options.onEvent` as a `usage` event of phase `'app'` - the ONLY event: the answer goes to
3322
+ * the caller, never into memory, an event or a run. Throws {@link AppSamplingError}
3323
+ * (`rpcCode` is what the app is told), or the model's error.
3324
+ */
3325
+ sampleForApp(request: AppSamplingRequest, options: AppSamplingOptions): Promise<AppSamplingResult>;
2831
3326
  /**
2832
3327
  * What the executor model can take, per attachment kind: true / false, or
2833
3328
  * undefined when unknown (the run tries, and a provider refusal becomes a
@@ -2849,6 +3344,42 @@ interface Agent {
2849
3344
  tiers?: Partial<Record<ModelTier, LanguageModel>>;
2850
3345
  };
2851
3346
  }
3347
+ /** A completion an MCP App asks for (see `Agent.sampleForApp`). */
3348
+ interface AppSamplingRequest {
3349
+ /** The server whose app asks. */
3350
+ server: string;
3351
+ /** The app's `ui://` resource: with `server`, the key of its rate limit. */
3352
+ resourceUri: string;
3353
+ /** The app's `sampling/createMessage` params, as they arrived: checked here. */
3354
+ params: unknown;
3355
+ }
3356
+ interface AppSamplingOptions {
3357
+ /**
3358
+ * The user's consent: shown exactly what the model will get (the cleaned messages, the system
3359
+ * prompt, the tokens it may write). `true` sends it. Bounded by `toolApproval.timeoutMs` (no
3360
+ * answer = refused) and `signal`.
3361
+ */
3362
+ approve: (view: AppSamplingView, signal?: AbortSignal) => boolean | Promise<boolean>;
3363
+ signal?: AbortSignal;
3364
+ /** Receives the `usage` event (phase `'app'`) of the call. */
3365
+ onEvent?: (event: AgentEvent) => void;
3366
+ /** The memory session whose `sessionUsage` is charged (default `config.sessionId`). */
3367
+ sessionId?: string;
3368
+ }
3369
+ /** A tool call an MCP App asks for (see `Agent.approveAppToolCall`). */
3370
+ interface AppToolCallRequest {
3371
+ /** The name the consent rules match: the tool's key, `server__tool` (`McpAppTool.key`). */
3372
+ tool: string;
3373
+ /** The tool's own name on its server. */
3374
+ toolName: string;
3375
+ /** The server the app came from. */
3376
+ server: string;
3377
+ /** The app's `ui://` resource. */
3378
+ resourceUri: string;
3379
+ input: unknown;
3380
+ /** The server marked the tool read-only (`McpAppTool.readOnly`). */
3381
+ readOnly: boolean;
3382
+ }
2852
3383
  /**
2853
3384
  * Create a headless plan → execute → replan → synthesize agent. Models are
2854
3385
  * resolved eagerly (dynamic provider imports + vault key fetch), so this is
@@ -3160,6 +3691,15 @@ type ParentToWorker = {
3160
3691
  callId: string;
3161
3692
  ok: boolean;
3162
3693
  output: unknown;
3694
+ }
3695
+ /**
3696
+ * The calling run started (true) / stopped (false) waiting for a person (its clock stopped /
3697
+ * runs again, wait-clock.ts): a host tool call in flight runs in that run, so the clock of the
3698
+ * child run that made it follows.
3699
+ */
3700
+ | {
3701
+ type: 'tool-wait';
3702
+ waiting: boolean;
3163
3703
  };
3164
3704
  type WorkerToParent = {
3165
3705
  type: 'event';
@@ -3247,7 +3787,11 @@ interface SubagentToolOptions {
3247
3787
  tools?: ToolSet;
3248
3788
  /** Parallel delegations allowed at once (default 4); extra calls queue. */
3249
3789
  maxConcurrent?: number;
3250
- /** Give up on one delegated task after this many ms (default: none). */
3790
+ /**
3791
+ * Give up on one delegated task after this many ms (default: none). Time a person takes to
3792
+ * answer a question (a tool approval, an MCP elicitation) of the child, of one of its host
3793
+ * tools or of the calling run does not count.
3794
+ */
3251
3795
  timeoutMs?: number;
3252
3796
  /** Cap on the text handed back to the parent model (default 8000 chars). */
3253
3797
  outputMaxChars?: number;
@@ -3885,7 +4429,8 @@ interface ToolRunContext {
3885
4429
  signal?: AbortSignal;
3886
4430
  /**
3887
4431
  * 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').
4432
+ * phase, 'subagent'), a media model's call (phase 'media'), or a grounded search's tokens
4433
+ * (phase 'search').
3889
4434
  */
3890
4435
  addUsage: (usage: IUsage, phase?: UsagePhase) => void;
3891
4436
  /** The run's usage so far (media tools read their per-run call count from it). */
@@ -3903,6 +4448,34 @@ interface ToolRunContext {
3903
4448
  fetched?: string[];
3904
4449
  /** Internal - what the built-in `spawn_subagent` tool reads of the run (`subagents.dynamic`). */
3905
4450
  spawn?: SpawnRun;
4451
+ /**
4452
+ * Set on the run of a helper the model started (`subagents.dynamic`): the call is the
4453
+ * helper's, not the run's the host started. An MCP tool reads it to decide whether the call
4454
+ * may ask the user something (`onElicitation`, `elicitation.subagents`).
4455
+ */
4456
+ subagent?: {
4457
+ id: string;
4458
+ depth: number;
4459
+ };
4460
+ /**
4461
+ * The questions MCP servers asked the user in this run (`onElicitation`): one object per run,
4462
+ * shared with the helpers it starts (`elicitation.maxPerRun`).
4463
+ */
4464
+ elicitations?: {
4465
+ count: number;
4466
+ };
4467
+ /**
4468
+ * Internal - the run's clock (wait-clock.ts): the step's `chatTimeoutMs` and the time limits
4469
+ * of the subagents the run's tool calls start are deadlines of it, and whoever asks a person
4470
+ * something on the run's behalf (the consent gate, an MCP question) pauses it for the wait.
4471
+ */
4472
+ clock?: IWaitClock;
4473
+ /**
4474
+ * Internal - the skills of MCP servers the run acts on, its callers' included: a call of a
4475
+ * tool that runs code is asked while there is one (`decideToolPermission`). A helper the model
4476
+ * starts inherits it.
4477
+ */
4478
+ mcpSkills?: () => string[];
3906
4479
  }
3907
4480
  /** Read the run context the agent passes to a tool's execute (undefined outside a run). */
3908
4481
  declare const toolRunContextOf: (options: unknown) => ToolRunContext | undefined;
@@ -3999,5 +4572,5 @@ declare class IndexedDBRunStore implements RunPersistence {
3999
4572
  clear(): Promise<void>;
4000
4573
  }
4001
4574
 
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 };
4575
+ 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 };
4576
+ 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 };