@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.
- package/README.md +407 -13
- package/dist/agent-web.js +169 -161
- package/dist/agent-web.js.map +1 -1
- package/dist/chunk-4FBTBE74.js +510 -0
- package/dist/chunk-4FBTBE74.js.map +1 -0
- package/dist/{chunk-TZITKUFW.js → chunk-L7Y3QRAM.js} +152 -20
- package/dist/chunk-L7Y3QRAM.js.map +1 -0
- package/dist/{chunk-V3JOK7EW.js → chunk-YPCHD6DV.js} +4 -2
- package/dist/chunk-YPCHD6DV.js.map +1 -0
- package/dist/chunk-YUA2BHRM.js +584 -0
- package/dist/chunk-YUA2BHRM.js.map +1 -0
- package/dist/elicitation-BA1knkdA.d.cts +566 -0
- package/dist/elicitation-BA1knkdA.d.ts +566 -0
- package/dist/index.cjs +1819 -223
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +690 -117
- package/dist/index.d.ts +690 -117
- package/dist/index.js +1281 -187
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +2240 -95
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.d.cts +303 -21
- package/dist/mcp.d.ts +303 -21
- package/dist/mcp.js +1675 -91
- package/dist/mcp.js.map +1 -1
- package/dist/{sandbox-KG6OUG24.js → sandbox-ZDQIIZS7.js} +21 -8
- package/dist/sandbox-ZDQIIZS7.js.map +1 -0
- package/dist/sandbox-worker.cjs +3 -1
- package/dist/sandbox-worker.cjs.map +1 -1
- package/dist/sandbox-worker.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-A6ZJALLU.js +0 -254
- package/dist/chunk-A6ZJALLU.js.map +0 -1
- package/dist/chunk-CTXDKSDD.js +0 -39
- package/dist/chunk-CTXDKSDD.js.map +0 -1
- package/dist/chunk-TZITKUFW.js.map +0 -1
- package/dist/chunk-V3JOK7EW.js.map +0 -1
- package/dist/sandbox-KG6OUG24.js.map +0 -1
- package/dist/vault-BatBaRQP.d.cts +0 -36
- package/dist/vault-BatBaRQP.d.ts +0 -36
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
interface VaultOptions {
|
|
2
|
+
/** Database name, forwarded to the shared IDB owner (default 'agent-web'). */
|
|
3
|
+
dbName?: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Encrypted key/value secret store backed by IndexedDB. Values are encrypted at
|
|
7
|
+
* rest with the non-extractable AES-GCM vault key (see crypto.ts).
|
|
8
|
+
*
|
|
9
|
+
* ── THREAT MODEL (read before shipping any app-owned key to a browser) ──
|
|
10
|
+
* This vault PROTECTS secrets **at rest** — an IndexedDB / disk dump yields
|
|
11
|
+
* only ciphertext — and against **casual DevTools inspection** — no plaintext
|
|
12
|
+
* key is stored, and the AES key cannot be exported even by in-page script.
|
|
13
|
+
*
|
|
14
|
+
* It does **NOT** defend against **active XSS on your origin**: any script that
|
|
15
|
+
* already runs on the page can call `getSecret()`, or use the live `CryptoKey`
|
|
16
|
+
* to decrypt. Browser storage is not a secrets manager.
|
|
17
|
+
*
|
|
18
|
+
* Therefore this vault is for the **end user's OWN key on their OWN device**
|
|
19
|
+
* (bring-your-own-key). A shared, app-owned key must NEVER reach the client —
|
|
20
|
+
* put it behind a server proxy (`ProviderModelSpec.baseURL`) or the Vercel AI
|
|
21
|
+
* Gateway instead.
|
|
22
|
+
*/
|
|
23
|
+
declare class IndexedDBVault {
|
|
24
|
+
private readonly dbName?;
|
|
25
|
+
constructor(opts?: VaultOptions);
|
|
26
|
+
private key;
|
|
27
|
+
/** Encrypt and store a secret string under `id`. */
|
|
28
|
+
setSecret(id: string, value: string): Promise<void>;
|
|
29
|
+
/** Fetch and decrypt a secret, or undefined if absent. */
|
|
30
|
+
getSecret(id: string): Promise<string | undefined>;
|
|
31
|
+
deleteSecret(id: string): Promise<void>;
|
|
32
|
+
listSecretIds(): Promise<string[]>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* MCP Skills (the `io.modelcontextprotocol/skills` extension, SEP-2640, Beta; written against
|
|
37
|
+
* base revision 2026-07-28): what the two agent packages share about a server's skills. The
|
|
38
|
+
* rules on a server's entries (`mcpSkillEntryRefusal`), the names a skill gets in the agent's
|
|
39
|
+
* catalog (`assignMcpSkillNames`: namespaced by the host's label of the server), the caps
|
|
40
|
+
* (`selectMcpSkills`), the files of a loaded skill the model may read (`resolveMcpSkillFile`),
|
|
41
|
+
* the preamble a skill's text is loaded under, the mark that carries a server's skills on its
|
|
42
|
+
* tools (`markMcpSkills` / `collectMcpSkillSources`), a skill the model names by URI
|
|
43
|
+
* (`mcpSkillUriRefusal`, `resolveMcpSkillServer`: `skills/get` to that one server only) and the
|
|
44
|
+
* person's consent before a skill's text enters the model's context (`decideMcpSkillConsent`,
|
|
45
|
+
* `mcpSkillConsentView`). Pure, no imports.
|
|
46
|
+
*
|
|
47
|
+
* A server's skills are third-party text. They reach the model only as knowledge, under
|
|
48
|
+
* `mcpSkillPreamble`, and - unless the host vetted the server (`consent: 'never'`) - only after a
|
|
49
|
+
* person saw them and said yes; nothing here (or anywhere) reads a skill's frontmatter beyond its
|
|
50
|
+
* `name` and `description` - `allowed-tools` included - and a file a skill bundles is read as
|
|
51
|
+
* text, never run.
|
|
52
|
+
*
|
|
53
|
+
* This file is a COPY, byte for byte, in `@dudko.dev/agent` (`src/mcp-skills.ts`) and
|
|
54
|
+
* `@dudko.dev/agent-web` (`src/mcp/skills.ts`): change both. The Node package's
|
|
55
|
+
* `tests/mcp-skills-shared.test.ts` compares the two files and tests every rule and cap here.
|
|
56
|
+
*/
|
|
57
|
+
/** The extension's identifier, in the client's and the server's `extensions` capability. */
|
|
58
|
+
declare const MCP_SKILLS_EXTENSION = "io.modelcontextprotocol/skills";
|
|
59
|
+
/** The specification's limits (Limits): files per skill, `SKILL.md` included. */
|
|
60
|
+
declare const MCP_SKILL_MAX_RESOURCES = 512;
|
|
61
|
+
/** The specification's limits (Limits): the sum of `size` over a skill's files, in bytes. */
|
|
62
|
+
declare const MCP_SKILL_MAX_TOTAL_BYTES: number;
|
|
63
|
+
/** The most skills one server puts in the agent's catalog. */
|
|
64
|
+
declare const MCP_SKILLS_MAX_PER_SERVER = 32;
|
|
65
|
+
/** The most skills all servers put in the agent's catalog together. */
|
|
66
|
+
declare const MCP_SKILLS_MAX_TOTAL = 64;
|
|
67
|
+
/** The most a catalog entry (the description and its origin tag) takes, in characters. */
|
|
68
|
+
declare const MCP_SKILL_DESCRIPTION_MAX_CHARS = 300;
|
|
69
|
+
/** The most of a skill's instructions (its `SKILL.md` body) the model is given, in characters. */
|
|
70
|
+
declare const MCP_SKILL_BODY_MAX_CHARS = 16000;
|
|
71
|
+
/** The most of one file of a skill the model is given, in characters. */
|
|
72
|
+
declare const MCP_SKILL_FILE_MAX_CHARS = 32000;
|
|
73
|
+
/** One file of a skill, as its entry lists it. */
|
|
74
|
+
interface McpSkillResourceLike {
|
|
75
|
+
uri: string;
|
|
76
|
+
digest: string;
|
|
77
|
+
size: number;
|
|
78
|
+
}
|
|
79
|
+
/** A `skills/list` / `skills/get` entry (the extension's `Skill`), as far as this file reads it. */
|
|
80
|
+
interface McpSkillEntryLike {
|
|
81
|
+
uri: string;
|
|
82
|
+
frontmatter: {
|
|
83
|
+
name: string;
|
|
84
|
+
description: string;
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
};
|
|
87
|
+
resources: McpSkillResourceLike[] | 'dynamic';
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Why the agent does not take a skill entry from a server, or `undefined` when it does. The
|
|
91
|
+
* specification's rules on an entry, checked before anything of the skill is read:
|
|
92
|
+
*
|
|
93
|
+
* - its `uri` is a `SKILL.md` inside a named directory, whose last segment is the skill's
|
|
94
|
+
* frontmatter `name` (Resource Mapping; Frontmatter), and that name follows the Agent Skills
|
|
95
|
+
* naming rules;
|
|
96
|
+
* - a description to show in the catalog;
|
|
97
|
+
* - `resources` is the complete list of its files (Resources): `"dynamic"` content is declined
|
|
98
|
+
* (a host MAY: there is nothing to verify it against), anything else is invalid;
|
|
99
|
+
* - every file is `SKILL.md` or a file inside the skill's directory, listed once, with a
|
|
100
|
+
* `sha256:` digest and a byte size, and `SKILL.md` is listed;
|
|
101
|
+
* - at most {@link MCP_SKILL_MAX_RESOURCES} files and {@link MCP_SKILL_MAX_TOTAL_BYTES} bytes
|
|
102
|
+
* (Limits: "both limits are checkable from the entry alone").
|
|
103
|
+
*/
|
|
104
|
+
declare const mcpSkillEntryRefusal: (entry: unknown) => string | undefined;
|
|
105
|
+
/** One skill of a server, as the agent's catalog holds it (the entry stays with the connection). */
|
|
106
|
+
interface McpSkillRecord {
|
|
107
|
+
/** The `SKILL.md` URI: with the server, the skill's identity. */
|
|
108
|
+
uri: string;
|
|
109
|
+
/** The frontmatter `name` (a label: two skills of one server may share it). */
|
|
110
|
+
name: string;
|
|
111
|
+
/** The description, cleaned to one line (not yet capped). */
|
|
112
|
+
description: string;
|
|
113
|
+
/** The skill's path (`acme/billing/refunds`), as segments. */
|
|
114
|
+
path: string[];
|
|
115
|
+
/** Its files other than `SKILL.md`, by their path inside the skill, sorted. */
|
|
116
|
+
files: string[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* How a skill of a server is introduced wherever its text is shown to the model (its
|
|
120
|
+
* instructions, and each file of it): third-party knowledge that cannot change the rules. The
|
|
121
|
+
* wording is the guard.
|
|
122
|
+
*/
|
|
123
|
+
declare const mcpSkillPreamble: (server: string, uri: string) => string;
|
|
124
|
+
/** The longest URI `load_skill` sends to a server, in characters. */
|
|
125
|
+
declare const MCP_SKILL_URI_MAX_CHARS = 512;
|
|
126
|
+
/**
|
|
127
|
+
* Why `load_skill` does not ask a server for the skill at `uri`, or `undefined` when it may. Checked
|
|
128
|
+
* before any request: a `skill://` URI - the conventional scheme; a URI the MODEL hands over (it
|
|
129
|
+
* read it in third-party text) is taken in no other, though a listing may use any - of the
|
|
130
|
+
* `SKILL.md` of a named directory, whose last segment is a skill name, within
|
|
131
|
+
* {@link MCP_SKILL_URI_MAX_CHARS}, with nothing invisible and no space in it.
|
|
132
|
+
*/
|
|
133
|
+
declare const mcpSkillUriRefusal: (uri: unknown) => string | undefined;
|
|
134
|
+
/** When a person is asked before a server's skill enters the model's context. */
|
|
135
|
+
type McpSkillConsent = 'ask' | 'once-per-skill' | 'never';
|
|
136
|
+
/** Every value of {@link McpSkillConsent}. */
|
|
137
|
+
declare const MCP_SKILL_CONSENTS: readonly McpSkillConsent[];
|
|
138
|
+
/**
|
|
139
|
+
* The default: asked the first time a skill would enter the context in the agent's life, and again
|
|
140
|
+
* only when its entry changed - often enough that every text a person did not see is shown, seldom
|
|
141
|
+
* enough that a yes still means something.
|
|
142
|
+
*/
|
|
143
|
+
declare const MCP_SKILL_CONSENT_DEFAULT: McpSkillConsent;
|
|
144
|
+
/** `skills` on a server's config, as an object. */
|
|
145
|
+
interface McpSkillsOptions {
|
|
146
|
+
/**
|
|
147
|
+
* `'once-per-skill'` (default): a person is asked the first time each skill would enter the
|
|
148
|
+
* model's context, and a yes holds for the agent's life while the skill's entry is the same;
|
|
149
|
+
* `'ask'`: asked in every run that loads it; `'never'`: never asked - for a server the host
|
|
150
|
+
* vetted (its skills load as soon as the model asks). Whatever the approval mode says.
|
|
151
|
+
*/
|
|
152
|
+
consent?: McpSkillConsent;
|
|
153
|
+
}
|
|
154
|
+
/** `skills` on a server's config: `true`, or options (on, with them); `false` / absent: off. */
|
|
155
|
+
type McpSkillsSetting = boolean | McpSkillsOptions;
|
|
156
|
+
/** What a person allowed for the agent's life (in memory only, never stored). */
|
|
157
|
+
interface McpSkillGrants {
|
|
158
|
+
/** Skills, each as it was shown: {@link mcpSkillGrantKey}. */
|
|
159
|
+
readonly skills: Set<string>;
|
|
160
|
+
/** Servers whose skills - nested ones excepted - are allowed ("Always for this server"). */
|
|
161
|
+
readonly servers: Set<string>;
|
|
162
|
+
}
|
|
163
|
+
/** What one run was allowed and refused, by {@link mcpSkillGrantKey}. */
|
|
164
|
+
interface McpSkillRunConsent {
|
|
165
|
+
readonly allowed: Set<string>;
|
|
166
|
+
/** Refused by the person in this run: not asked again in it, refused at once. */
|
|
167
|
+
readonly denied: Set<string>;
|
|
168
|
+
/** A question open for a key: a second load of the skill waits for its answer. */
|
|
169
|
+
readonly pending: Map<string, Promise<boolean>>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* What a person is shown before a server's skill enters the model's context - the request's
|
|
173
|
+
* `skill` (the core's `tool.approval-requested` event). Every string is the SERVER's, cleaned:
|
|
174
|
+
* show it as plain text, captioned as the server's.
|
|
175
|
+
*/
|
|
176
|
+
interface McpSkillConsentView {
|
|
177
|
+
/** The host's label of the server that serves it. */
|
|
178
|
+
server: string;
|
|
179
|
+
/** Its name in the agent's catalog (`<server>/<skill>`). */
|
|
180
|
+
name: string;
|
|
181
|
+
/** Its frontmatter name. */
|
|
182
|
+
skill: string;
|
|
183
|
+
/** The URI of its `SKILL.md` (cleaned, at most 200 characters). */
|
|
184
|
+
uri: string;
|
|
185
|
+
/** The description from its entry, on one line, at most {@link MCP_SKILL_DESCRIPTION_MAX_CHARS}. */
|
|
186
|
+
description: string;
|
|
187
|
+
/** Bytes of its `SKILL.md`, and of all its files. */
|
|
188
|
+
size: number;
|
|
189
|
+
totalSize: number;
|
|
190
|
+
/** Its other files, by path (at most {@link MCP_SKILL_FILES_SHOWN_MAX}), and how many there are. */
|
|
191
|
+
files: string[];
|
|
192
|
+
fileCount: number;
|
|
193
|
+
/** Its instructions exactly as the model would read them ({@link mcpSkillBodyPreview}). */
|
|
194
|
+
body: string;
|
|
195
|
+
/** Named by URI (`skills/get`), not in the server's listing. */
|
|
196
|
+
byUri?: true;
|
|
197
|
+
/** It sits inside this skill of the same server, whose approval does not cover it. */
|
|
198
|
+
nestedIn?: string;
|
|
199
|
+
/** Asked for this run only (`'ask'`) or, on a yes, for the agent's life (`'once-per-skill'`). */
|
|
200
|
+
consent: Exclude<McpSkillConsent, 'never'>;
|
|
201
|
+
}
|
|
202
|
+
/** A loaded skill: its instructions, and the entry its files are read against (opaque). */
|
|
203
|
+
interface McpSkillLoaded {
|
|
204
|
+
readonly uri: string;
|
|
205
|
+
/** The `SKILL.md` body (after its frontmatter), verified - not yet cleaned or capped. */
|
|
206
|
+
readonly body: string;
|
|
207
|
+
/** Its files other than `SKILL.md`, as the entry it was loaded with lists them. */
|
|
208
|
+
readonly files: readonly string[];
|
|
209
|
+
/** The entry it was loaded with (the "held entry"): what a consent is bound to and shows. */
|
|
210
|
+
readonly entry: McpSkillEntryLike;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* The skills of one connected server, for the agent (a connection with `skills` on, to a server
|
|
214
|
+
* that offers the extension). `skills` and `added` are live: a refresh of the server replaces
|
|
215
|
+
* `skills`; `get` adds to `added`.
|
|
216
|
+
*/
|
|
217
|
+
interface McpSkillSource {
|
|
218
|
+
/** The host's label of the server: its key in the configuration. */
|
|
219
|
+
readonly server: string;
|
|
220
|
+
/** The skills its listing (`skills/list`) gave, the rules passed. */
|
|
221
|
+
readonly skills: readonly McpSkillRecord[];
|
|
222
|
+
/** Skills it gave by URI (`get`, `skills/get`) that its listing does not hold. */
|
|
223
|
+
readonly added?: readonly McpSkillRecord[];
|
|
224
|
+
/** The consent the server's config names (`skills: { consent }`); absent: the agent's decides. */
|
|
225
|
+
readonly consent?: McpSkillConsent;
|
|
226
|
+
/**
|
|
227
|
+
* Ask the server - this one only - for the skill whose `SKILL.md` is at `uri` (`skills/get`):
|
|
228
|
+
* its entry passes the same rules as a listed one and joins `added`. Throws when the URI is not
|
|
229
|
+
* one to send ({@link mcpSkillUriRefusal}), the server does not serve it (`-32602`) or the entry
|
|
230
|
+
* is refused.
|
|
231
|
+
*/
|
|
232
|
+
get?: (uri: string, options?: {
|
|
233
|
+
signal?: AbortSignal;
|
|
234
|
+
}) => Promise<McpSkillRecord>;
|
|
235
|
+
/**
|
|
236
|
+
* Read the skill's `SKILL.md` and verify it against its entry (size, digest, frontmatter);
|
|
237
|
+
* throws - and gives nothing - when it does not match.
|
|
238
|
+
*/
|
|
239
|
+
load: (uri: string, options?: {
|
|
240
|
+
signal?: AbortSignal;
|
|
241
|
+
}) => Promise<McpSkillLoaded>;
|
|
242
|
+
/**
|
|
243
|
+
* Read one file of a loaded skill - a path its entry lists - and verify it against the entry
|
|
244
|
+
* the skill was loaded with. Text only; throws for anything else.
|
|
245
|
+
*/
|
|
246
|
+
readFile: (loaded: McpSkillLoaded, path: string, options?: {
|
|
247
|
+
signal?: AbortSignal;
|
|
248
|
+
}) => Promise<string>;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* MCP Apps (the `io.modelcontextprotocol/ui` extension, stable revision 2026-01-26): a tool of an
|
|
253
|
+
* MCP server declares an HTML user interface (`_meta.ui.resourceUri`, a `ui://` resource), the
|
|
254
|
+
* host reads it with `resources/read` and shows it next to the tool's result in a sandboxed frame.
|
|
255
|
+
*
|
|
256
|
+
* Pure, no imports: what this package accepts of the server's declarations, before anything is
|
|
257
|
+
* shown. Everything here is third-party data from the server, so every function is a guard:
|
|
258
|
+
*
|
|
259
|
+
* - `mcpAppToolMeta`: the tool's link to its app - a `ui://` URI or nothing - and who may call
|
|
260
|
+
* it (`visibility`: the model, the app, or both).
|
|
261
|
+
* - `mcpAppResourceOf`: the `resources/read` answer - the right URI, the extension's MIME type,
|
|
262
|
+
* a size cap, `text` or base64 `blob` - and the resource's metadata cleaned: CSP origins that
|
|
263
|
+
* are origins and nothing else, the permissions it asks for (reported, never granted here).
|
|
264
|
+
* - `mcpAppToolResultOf`: what of a tool's result is handed to the app, capped.
|
|
265
|
+
*
|
|
266
|
+
* The HTML itself never reaches the model: it is not part of a tool result, an event or a log.
|
|
267
|
+
*/
|
|
268
|
+
/** The extension's identifier: declared under `capabilities.extensions` in the handshake. */
|
|
269
|
+
declare const MCP_APPS_EXTENSION = "io.modelcontextprotocol/ui";
|
|
270
|
+
/** The one content type of the stable revision (`text/html` with the `mcp-app` profile). */
|
|
271
|
+
declare const MCP_APP_MIME_TYPE = "text/html;profile=mcp-app";
|
|
272
|
+
/** An app's HTML above this many characters is refused (a bundled single-file app is ~1 MB). */
|
|
273
|
+
declare const MCP_APP_MAX_HTML_CHARS = 2000000;
|
|
274
|
+
/** A tool result above this many characters (as JSON) is not handed to its app. */
|
|
275
|
+
declare const MCP_APP_MAX_RESULT_CHARS = 512000;
|
|
276
|
+
/** At most this many origins per CSP list of a resource; the rest are refused. */
|
|
277
|
+
declare const MCP_APP_MAX_DOMAINS = 32;
|
|
278
|
+
/** Who may call a tool: the model (it is in the agent's toolbox), an app of its server, or both. */
|
|
279
|
+
type McpAppVisibility = 'model' | 'app';
|
|
280
|
+
/** The specification's default when a tool says nothing. */
|
|
281
|
+
declare const MCP_APP_DEFAULT_VISIBILITY: readonly McpAppVisibility[];
|
|
282
|
+
/**
|
|
283
|
+
* The origins an app's resource declared, after cleaning: each entry an origin
|
|
284
|
+
* (`https://host[:port]`, `wss://…`, `https://*.example.com`, or `http(s)/ws(s)` on loopback),
|
|
285
|
+
* nothing else. An empty list means "none": the frame gets no network for that kind.
|
|
286
|
+
*/
|
|
287
|
+
interface McpAppCsp {
|
|
288
|
+
/** `fetch` / XHR / WebSocket (`connect-src`). */
|
|
289
|
+
connectDomains: string[];
|
|
290
|
+
/** Scripts, styles, images, fonts, media (`script-src`, `style-src`, …). */
|
|
291
|
+
resourceDomains: string[];
|
|
292
|
+
/** Nested frames (`frame-src`). */
|
|
293
|
+
frameDomains: string[];
|
|
294
|
+
/** `<base href>` (`base-uri`). */
|
|
295
|
+
baseUriDomains: string[];
|
|
296
|
+
}
|
|
297
|
+
/** Browser features the resource asks for. Reported to the host; this package grants none. */
|
|
298
|
+
interface McpAppPermissions {
|
|
299
|
+
camera?: true;
|
|
300
|
+
microphone?: true;
|
|
301
|
+
geolocation?: true;
|
|
302
|
+
clipboardWrite?: true;
|
|
303
|
+
}
|
|
304
|
+
/** An app's document, read from the server that declared it and checked. */
|
|
305
|
+
interface McpAppResource {
|
|
306
|
+
/** The server it was read from (the one whose tool declared it). */
|
|
307
|
+
server: string;
|
|
308
|
+
uri: string;
|
|
309
|
+
/** The app's HTML. Third-party code: frame it, never put it in a page or a model's context. */
|
|
310
|
+
html: string;
|
|
311
|
+
/** The origins it declared, cleaned (see `McpAppCsp`). */
|
|
312
|
+
csp: McpAppCsp;
|
|
313
|
+
/** Declared entries that are not origins this package accepts - left out of `csp`. */
|
|
314
|
+
refusedDomains: string[];
|
|
315
|
+
/** What it asked for; not granted by this package. */
|
|
316
|
+
permissions: McpAppPermissions;
|
|
317
|
+
/** Its wish for a visible border; the host decides. */
|
|
318
|
+
prefersBorder?: boolean;
|
|
319
|
+
/** The dedicated origin it asked for; a page-based host cannot give one, so it is only reported. */
|
|
320
|
+
domain?: string;
|
|
321
|
+
}
|
|
322
|
+
/** A tool's result as handed to its app: the MCP `CallToolResult`, unchanged but for unknown keys. */
|
|
323
|
+
interface McpAppToolResult {
|
|
324
|
+
content?: unknown[];
|
|
325
|
+
structuredContent?: Record<string, unknown>;
|
|
326
|
+
isError?: boolean;
|
|
327
|
+
_meta?: Record<string, unknown>;
|
|
328
|
+
}
|
|
329
|
+
/** What a tool declares about apps. */
|
|
330
|
+
interface McpAppToolMeta {
|
|
331
|
+
/** Its app (`ui://…`), when it declares a valid one. */
|
|
332
|
+
resourceUri?: string;
|
|
333
|
+
visibility: McpAppVisibility[];
|
|
334
|
+
/** A declared app URI that was refused (not `ui://`, too long, not text) - for the log. */
|
|
335
|
+
refusedUri?: string;
|
|
336
|
+
}
|
|
337
|
+
/** A `ui://` URI this package will read: text, short, no control characters. */
|
|
338
|
+
declare const isMcpAppUri: (value: unknown) => value is string;
|
|
339
|
+
/**
|
|
340
|
+
* The tool's app and who may call it. `_meta.ui.resourceUri` wins over the deprecated flat
|
|
341
|
+
* `_meta["ui/resourceUri"]`. `visibility` defaults to both; unknown entries are dropped; a list
|
|
342
|
+
* that names nothing known is the default.
|
|
343
|
+
*/
|
|
344
|
+
declare const mcpAppToolMeta: (tool: {
|
|
345
|
+
_meta?: unknown;
|
|
346
|
+
}) => McpAppToolMeta;
|
|
347
|
+
/**
|
|
348
|
+
* Whether a content type is the extension's: `text/html` with `profile=mcp-app`, in any case,
|
|
349
|
+
* with or without spaces or quotes; `charset=utf-8` may come along, nothing else.
|
|
350
|
+
*/
|
|
351
|
+
declare const isMcpAppMimeType: (value: unknown) => boolean;
|
|
352
|
+
/**
|
|
353
|
+
* One declared CSP entry as a source expression this package puts in a policy, or `undefined`.
|
|
354
|
+
* Only an origin: `https://` / `wss://` (a `*.` subdomain wildcard over at least two labels),
|
|
355
|
+
* or `http://` / `ws://` on loopback. No path, no keyword (`'unsafe-eval'`), no bare scheme, no
|
|
356
|
+
* `*`, no separator (`;` `,` space) that could add a directive of its own.
|
|
357
|
+
*/
|
|
358
|
+
declare const mcpAppOrigin: (entry: unknown) => string | undefined;
|
|
359
|
+
/** The resource's declared CSP, cleaned: origins kept, everything else in `refused`. */
|
|
360
|
+
declare const mcpAppCspOf: (raw: unknown) => {
|
|
361
|
+
csp: McpAppCsp;
|
|
362
|
+
refused: string[];
|
|
363
|
+
};
|
|
364
|
+
/** The permissions a resource asks for: the four the specification names, nothing else. */
|
|
365
|
+
declare const mcpAppPermissionsOf: (raw: unknown) => McpAppPermissions;
|
|
366
|
+
/** Why a `resources/read` answer is not an app this package shows. */
|
|
367
|
+
declare class McpAppResourceError extends Error {
|
|
368
|
+
constructor(message: string);
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* The app in a `resources/read` answer for `uri`: the entry with exactly that URI, the
|
|
372
|
+
* extension's MIME type, `text` (or base64 `blob`) under `maxChars`, metadata cleaned. Throws
|
|
373
|
+
* {@link McpAppResourceError} otherwise - nothing of a refused answer is shown.
|
|
374
|
+
*/
|
|
375
|
+
declare const mcpAppResourceOf: (server: string, uri: string, result: unknown, maxChars?: number) => McpAppResource;
|
|
376
|
+
/**
|
|
377
|
+
* The parts of a tool result an app is given (`content`, `structuredContent`, `isError`,
|
|
378
|
+
* `_meta`), or `undefined` when they are more than `maxChars` as JSON or not a result at all.
|
|
379
|
+
*/
|
|
380
|
+
declare const mcpAppToolResultOf: (result: unknown, maxChars?: number) => McpAppToolResult | undefined;
|
|
381
|
+
/**
|
|
382
|
+
* What MCP Apps are for ONE server, from its own setting (`McpHttpServerConfig.apps`) and the
|
|
383
|
+
* connection's (`ConnectMcpOptions.apps`); the server's wins when it has one:
|
|
384
|
+
*
|
|
385
|
+
* - `'on'`: the extension declared, `_meta.ui` read, the server's apps shown.
|
|
386
|
+
* - `'declined'` (the server's `apps: false`): its apps are not shown here. Nothing is declared,
|
|
387
|
+
* no app is read and no `mcp.app` event is told, and a tool marked for its app only
|
|
388
|
+
* (`visibility` without `'model'`) is not mounted - it is for an app that will never run.
|
|
389
|
+
* Every other tool is the model's, as a plain tool.
|
|
390
|
+
* - `'off'` (neither set): MCP Apps unknown - nothing declared, `_meta` not read, every tool
|
|
391
|
+
* mounted: the wire and the tools are what they were before the extension.
|
|
392
|
+
*/
|
|
393
|
+
type McpAppsMode = 'on' | 'declined' | 'off';
|
|
394
|
+
declare const mcpAppsModeOf: (server: boolean | undefined, connection: boolean | undefined) => McpAppsMode;
|
|
395
|
+
/** A file an app asks the host to save, at most this many bytes (`readResource`'s default cap). */
|
|
396
|
+
declare const MCP_APP_MAX_DOWNLOAD_BYTES: number;
|
|
397
|
+
/** A resource read for a download (`McpAppsConnection.readResource`): its bytes, as sent. */
|
|
398
|
+
interface McpAppDownloadResource {
|
|
399
|
+
uri: string;
|
|
400
|
+
/** The type the server gave it, if any (third-party: the host judges it). */
|
|
401
|
+
mimeType?: string;
|
|
402
|
+
bytes: Uint8Array;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* The bytes of a `resources/read` answer for `uri`, for a file the user is about to be asked to
|
|
406
|
+
* save: the entry with exactly that URI, `text` (as UTF-8) or base64 `blob`, at most `maxBytes`.
|
|
407
|
+
* Any MIME type (the host decides what it saves). Throws {@link McpAppResourceError} otherwise.
|
|
408
|
+
*/
|
|
409
|
+
declare const mcpAppDownloadOf: (uri: string, result: unknown, maxBytes?: number) => McpAppDownloadResource;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* MCP elicitation, the part the two agent packages share: a server asks the user for input in
|
|
413
|
+
* the middle of a tool call, the HOST answers through a callback, and the call goes on. Pure, no
|
|
414
|
+
* imports: the limits, what a request must look like before a host sees it, what an answer must
|
|
415
|
+
* look like before a server sees it, the one function that asks, and the two ways a tool call
|
|
416
|
+
* with questions is driven (`elicitation/create` requests on the 2025 revisions, `input_required`
|
|
417
|
+
* results on 2026-07-28).
|
|
418
|
+
*
|
|
419
|
+
* A consent boundary. The server's text is third-party data: cleaned and capped here, shown only
|
|
420
|
+
* to the host's callback and in the `mcp.elicitation-requested` event, never put into a prompt.
|
|
421
|
+
* The answer goes to the server that asked and nowhere else: nothing in this file logs, emits or
|
|
422
|
+
* returns a value the user entered - events and errors carry field NAMES only.
|
|
423
|
+
*
|
|
424
|
+
* This file is a COPY, byte for byte, in `@dudko.dev/agent` (`src/mcp-elicitation.ts`) and
|
|
425
|
+
* `@dudko.dev/agent-web` (`src/mcp/elicitation.ts`): change both. The Node package's
|
|
426
|
+
* `tests/mcp-elicitation-shared.test.ts` compares the two files and tests every guard here; each
|
|
427
|
+
* needs a mutation check.
|
|
428
|
+
*/
|
|
429
|
+
/** How long one question waits for the host's answer, by default: a human is reading it. */
|
|
430
|
+
declare const MCP_ELICITATION_TIMEOUT_MS = 300000;
|
|
431
|
+
/** The most questions one tool call may ask, by default. */
|
|
432
|
+
declare const MCP_ELICITATION_MAX_PER_TOOL_CALL = 5;
|
|
433
|
+
/** The most questions one run may be asked, by default (its helpers' calls included). */
|
|
434
|
+
declare const MCP_ELICITATION_MAX_PER_RUN = 20;
|
|
435
|
+
/** One field of a form: the flat subset of JSON Schema the specification allows, nothing else. */
|
|
436
|
+
interface McpElicitationFieldSchema {
|
|
437
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array';
|
|
438
|
+
title?: string;
|
|
439
|
+
description?: string;
|
|
440
|
+
default?: string | number | boolean | string[];
|
|
441
|
+
/** string */
|
|
442
|
+
minLength?: number;
|
|
443
|
+
maxLength?: number;
|
|
444
|
+
format?: 'email' | 'uri' | 'date' | 'date-time';
|
|
445
|
+
/** string: single-select, plain (`enumNames`: the older titled form). */
|
|
446
|
+
enum?: string[];
|
|
447
|
+
enumNames?: string[];
|
|
448
|
+
/** string: single-select with titles. */
|
|
449
|
+
oneOf?: {
|
|
450
|
+
const: string;
|
|
451
|
+
title: string;
|
|
452
|
+
}[];
|
|
453
|
+
/** number / integer */
|
|
454
|
+
minimum?: number;
|
|
455
|
+
maximum?: number;
|
|
456
|
+
/** array: multi-select. */
|
|
457
|
+
minItems?: number;
|
|
458
|
+
maxItems?: number;
|
|
459
|
+
items?: {
|
|
460
|
+
type?: 'string';
|
|
461
|
+
enum?: string[];
|
|
462
|
+
anyOf?: {
|
|
463
|
+
const: string;
|
|
464
|
+
title: string;
|
|
465
|
+
}[];
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
/** The form a server asks for, as a host is shown it: checked, cleaned and capped. */
|
|
469
|
+
interface McpElicitationSchema {
|
|
470
|
+
type: 'object';
|
|
471
|
+
properties: Record<string, McpElicitationFieldSchema>;
|
|
472
|
+
required?: string[];
|
|
473
|
+
}
|
|
474
|
+
/** What the host's callback is given. Every string in it is third-party text. */
|
|
475
|
+
interface McpElicitationRequest {
|
|
476
|
+
/** Unique per question; the same id is in the two events. */
|
|
477
|
+
id: string;
|
|
478
|
+
/** The server that asks: its key in the host's configuration. */
|
|
479
|
+
server: string;
|
|
480
|
+
/** The tool call during which it asks: the tool's name as the model called it. */
|
|
481
|
+
tool: string;
|
|
482
|
+
mode: 'form' | 'url';
|
|
483
|
+
/** The server's words, cleaned and capped (MCP_ELICITATION_MESSAGE_MAX_CHARS). */
|
|
484
|
+
message: string;
|
|
485
|
+
/** Form mode: the fields to fill in. */
|
|
486
|
+
requestedSchema?: McpElicitationSchema;
|
|
487
|
+
/**
|
|
488
|
+
* URL mode: the link the server wants the user to open. It is only handed over: nothing in
|
|
489
|
+
* these packages fetches or opens it. https, or http on a loopback host.
|
|
490
|
+
*/
|
|
491
|
+
url?: string;
|
|
492
|
+
/** URL mode on the 2025 revisions: the server's id for this interaction. */
|
|
493
|
+
elicitationId?: string;
|
|
494
|
+
runId?: string;
|
|
495
|
+
/** Set when a helper the model started is the one whose call asks (`elicitation.subagents`). */
|
|
496
|
+
subagent?: {
|
|
497
|
+
id: string;
|
|
498
|
+
depth: number;
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
type McpElicitationContent = Record<string, string | number | boolean | string[]>;
|
|
502
|
+
/**
|
|
503
|
+
* The host's answer. `accept` carries the form's values (form mode) or nothing (URL mode: it
|
|
504
|
+
* says the user agreed to open the link); `decline` is a no; `cancel` is "dismissed".
|
|
505
|
+
*/
|
|
506
|
+
type McpElicitationResult = {
|
|
507
|
+
action: 'accept';
|
|
508
|
+
content?: McpElicitationContent;
|
|
509
|
+
} | {
|
|
510
|
+
action: 'decline';
|
|
511
|
+
} | {
|
|
512
|
+
action: 'cancel';
|
|
513
|
+
};
|
|
514
|
+
interface McpElicitationContext {
|
|
515
|
+
/** Aborted when the answer is no longer wanted: the run stopped, or the time ran out. */
|
|
516
|
+
signal: AbortSignal;
|
|
517
|
+
}
|
|
518
|
+
/** `onElicitation`: the host decides, never the model. */
|
|
519
|
+
type McpElicitationHandler = (request: McpElicitationRequest, ctx: McpElicitationContext) => McpElicitationResult | Promise<McpElicitationResult>;
|
|
520
|
+
/** The `elicitation` settings beside `onElicitation`. */
|
|
521
|
+
interface McpElicitationOptions {
|
|
522
|
+
/**
|
|
523
|
+
* How long one question waits for an answer. Default 300 000. `0` or `Infinity` = no limit of
|
|
524
|
+
* its own (the question waits until the run is stopped), and so is a value above 2^31 - 1 (about
|
|
525
|
+
* 24.8 days, the most a timer holds). Negative or NaN: a configuration error.
|
|
526
|
+
*/
|
|
527
|
+
timeoutMs?: number;
|
|
528
|
+
/** Questions one tool call may ask. Default 5. */
|
|
529
|
+
maxPerToolCall?: number;
|
|
530
|
+
/** Questions one run may be asked. Default 20. */
|
|
531
|
+
maxPerRun?: number;
|
|
532
|
+
/** Also accept URL mode (a link to open). Default false: only forms are declared. */
|
|
533
|
+
url?: boolean;
|
|
534
|
+
/**
|
|
535
|
+
* Let a tool call made by a helper (a subagent) ask the user too. Default false: such a
|
|
536
|
+
* question is cancelled without the callback being called.
|
|
537
|
+
*/
|
|
538
|
+
subagents?: boolean;
|
|
539
|
+
}
|
|
540
|
+
/** Why a question was answered without the host deciding. */
|
|
541
|
+
type McpElicitationReason = 'unsupported-schema' | 'unsupported-mode' | 'insecure-url' | 'invalid-request' | 'subagent' | 'cap-per-call' | 'cap-per-run' | 'handler-error' | 'timeout' | 'invalid-answer' | 'aborted' | 'step-timeout' | 'after-failure' | 'no-tool-call';
|
|
542
|
+
type Checked<T> = {
|
|
543
|
+
ok: true;
|
|
544
|
+
value: T;
|
|
545
|
+
} | {
|
|
546
|
+
ok: false;
|
|
547
|
+
reason: string;
|
|
548
|
+
};
|
|
549
|
+
/**
|
|
550
|
+
* The form a server asked for, reduced to what the specification allows a form to be: a flat
|
|
551
|
+
* object of strings, numbers, booleans and selects. Anything else - a nested object, a list of
|
|
552
|
+
* objects, a type union, an unknown format, too many fields or options, a name that could not
|
|
553
|
+
* be sent back verbatim - is refused with a reason (the caller declines the request). Keywords
|
|
554
|
+
* outside the subset are dropped; titles and descriptions are cleaned and capped.
|
|
555
|
+
*/
|
|
556
|
+
declare const normalizeMcpElicitationSchema: (raw: unknown) => Checked<McpElicitationSchema>;
|
|
557
|
+
/**
|
|
558
|
+
* An accepted form, checked against the schema it answers: every value of the type and within
|
|
559
|
+
* the limits its field states, every required field there, and NO field the form did not ask
|
|
560
|
+
* for (what the server did not request is not sent to it). The result is a fresh object holding
|
|
561
|
+
* only the form's own fields. A refusal names the field and the rule, never the value.
|
|
562
|
+
*/
|
|
563
|
+
declare const validateMcpElicitationContent: (schema: McpElicitationSchema, content: unknown) => Checked<McpElicitationContent>;
|
|
564
|
+
|
|
565
|
+
export { isMcpAppUri as $, mcpAppOrigin as D, mcpSkillEntryRefusal as E, mcpSkillPreamble as F, mcpSkillUriRefusal as G, IndexedDBVault as I, MCP_APP_DEFAULT_VISIBILITY as L, MCP_APP_MAX_DOMAINS as N, MCP_APP_MAX_DOWNLOAD_BYTES as O, MCP_ELICITATION_MAX_PER_RUN as P, MCP_ELICITATION_MAX_PER_TOOL_CALL as Q, MCP_ELICITATION_TIMEOUT_MS as R, McpAppResourceError as S, isMcpAppMimeType as _, mcpAppCspOf as a0, mcpAppDownloadOf as a1, mcpAppPermissionsOf as a2, mcpAppResourceOf as a3, mcpAppToolMeta as a4, mcpAppToolResultOf as a5, mcpAppsModeOf as a6, normalizeMcpElicitationSchema as a7, validateMcpElicitationContent as a8, MCP_APPS_EXTENSION as h, MCP_APP_MAX_HTML_CHARS as i, MCP_APP_MAX_RESULT_CHARS as j, MCP_APP_MIME_TYPE as k, MCP_SKILLS_EXTENSION as l, MCP_SKILLS_MAX_PER_SERVER as m, MCP_SKILLS_MAX_TOTAL as n, MCP_SKILL_BODY_MAX_CHARS as o, MCP_SKILL_CONSENTS as p, MCP_SKILL_CONSENT_DEFAULT as q, MCP_SKILL_DESCRIPTION_MAX_CHARS as r, MCP_SKILL_FILE_MAX_CHARS as s, MCP_SKILL_MAX_RESOURCES as t, MCP_SKILL_MAX_TOTAL_BYTES as u, MCP_SKILL_URI_MAX_CHARS as v };
|
|
566
|
+
export type { McpElicitationFieldSchema as A, McpSkillsOptions as B, McpSkillsSetting as C, McpElicitationHandler as H, McpElicitationOptions as J, McpAppDownloadResource as K, McpSkillSource as M, McpAppToolMeta as T, McpAppsMode as U, VaultOptions as V, McpElicitationContent as W, McpElicitationContext as X, McpElicitationRequest as Y, McpElicitationResult as Z, McpSkillConsent as a, McpSkillGrants as b, McpSkillRunConsent as c, McpSkillConsentView as d, McpElicitationSchema as e, McpElicitationReason as f, McpAppToolResult as g, McpAppCsp as w, McpAppPermissions as x, McpAppResource as y, McpAppVisibility as z };
|