@dudko.dev/agent-web 0.0.40 → 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 +301 -22
  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 +1813 -221
  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 +1275 -185
  19. package/dist/index.js.map +1 -1
  20. package/dist/mcp.cjs +2135 -49
  21. package/dist/mcp.cjs.map +1 -1
  22. package/dist/mcp.d.cts +285 -9
  23. package/dist/mcp.d.ts +285 -9
  24. package/dist/mcp.js +1573 -48
  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 +1 -1
  32. package/dist/chunk-A6ZJALLU.js +0 -254
  33. package/dist/chunk-A6ZJALLU.js.map +0 -1
  34. package/dist/chunk-CTXDKSDD.js +0 -39
  35. package/dist/chunk-CTXDKSDD.js.map +0 -1
  36. package/dist/chunk-TZITKUFW.js.map +0 -1
  37. package/dist/chunk-V3JOK7EW.js.map +0 -1
  38. package/dist/sandbox-KG6OUG24.js.map +0 -1
  39. package/dist/vault-BatBaRQP.d.cts +0 -36
  40. package/dist/vault-BatBaRQP.d.ts +0 -36
package/dist/mcp.d.cts CHANGED
@@ -1,11 +1,14 @@
1
1
  import { OAuthClientProvider, FetchLike, StreamableHTTPReconnectionOptions, OAuthClientMetadata, OAuthClientInformationMixed, OAuthTokens, OAuthDiscoveryState } from '@modelcontextprotocol/client';
2
2
  export { UnauthorizedError } from '@modelcontextprotocol/client';
3
3
  import { ToolSet } from 'ai';
4
- import { VaultOptions } from './index.cjs';
4
+ import { H as McpElicitationHandler, J as McpElicitationOptions, y as McpAppResource, z as McpAppVisibility, K as McpAppDownloadResource, g as McpAppToolResult } from './elicitation-BA1knkdA.cjs';
5
+ import { McpSkillsSetting, VaultOptions } from './index.cjs';
6
+ export { h as MCP_APPS_EXTENSION, L as MCP_APP_DEFAULT_VISIBILITY, N as MCP_APP_MAX_DOMAINS, O as MCP_APP_MAX_DOWNLOAD_BYTES, i as MCP_APP_MAX_HTML_CHARS, j as MCP_APP_MAX_RESULT_CHARS, k as MCP_APP_MIME_TYPE, P as MCP_ELICITATION_MAX_PER_RUN, Q as MCP_ELICITATION_MAX_PER_TOOL_CALL, R as MCP_ELICITATION_TIMEOUT_MS, w as McpAppCsp, x as McpAppPermissions, S as McpAppResourceError, T as McpAppToolMeta, U as McpAppsMode, W as McpElicitationContent, X as McpElicitationContext, A as McpElicitationFieldSchema, f as McpElicitationReason, Y as McpElicitationRequest, Z as McpElicitationResult, e as McpElicitationSchema, _ as isMcpAppMimeType, $ as isMcpAppUri, a0 as mcpAppCspOf, a1 as mcpAppDownloadOf, D as mcpAppOrigin, a2 as mcpAppPermissionsOf, a3 as mcpAppResourceOf, a4 as mcpAppToolMeta, a5 as mcpAppToolResultOf, a6 as mcpAppsModeOf, a7 as normalizeMcpElicitationSchema, a8 as validateMcpElicitationContent } from './elicitation-BA1knkdA.cjs';
5
7
 
6
8
  /**
7
9
  * What the MCP connectors of the two agent packages share: how a server's `instructions` reach a
8
- * system prompt, and how a tool result's `structuredContent` reaches the model. Pure, no imports.
10
+ * system prompt, how a tool result's `structuredContent` reaches the model, and what the
11
+ * per-server `protocol` option means. Pure, no imports.
9
12
  *
10
13
  * This file is a COPY, byte for byte, in `@dudko.dev/agent` (`src/mcp-shared.ts`) and
11
14
  * `@dudko.dev/agent-web` (`src/mcp/shared.ts`): change both. The Node package's
@@ -30,6 +33,35 @@ declare const MCP_INSTRUCTIONS_MAX_CHARS_TOTAL = 8000;
30
33
  * or as another server's note.
31
34
  */
32
35
  declare const renderMcpInstructions: (list: readonly McpServerInstructions[] | undefined) => string;
36
+ /**
37
+ * Which revisions of the protocol a connection to one server may use (the server config's
38
+ * `protocol`):
39
+ *
40
+ * - `'legacy'` (default): the 2025 revisions, the `initialize` handshake. Nothing of the 2026
41
+ * revision is sent.
42
+ * - `'auto'`: ask first (`server/discover`); a server that answers with 2026-07-28 is spoken to
43
+ * that way, any other is given the 2025 handshake. Decided once, at connect.
44
+ * - `'modern'`: 2026-07-28 only. A server that does not offer it fails the connect.
45
+ */
46
+ type McpProtocolMode = 'legacy' | 'auto' | 'modern';
47
+ /** The revision `protocol: 'modern'` pins: the one this connector is tested against. */
48
+ declare const MCP_MODERN_PROTOCOL_VERSION = "2026-07-28";
49
+ /** What a connection negotiated with one server. */
50
+ interface McpServerProtocol {
51
+ /** The server's name: its key in the host's configuration. */
52
+ server: string;
53
+ /** The protocol revision in use, e.g. `2025-11-25` or `2026-07-28`. */
54
+ version: string;
55
+ /** `modern` from 2026-07-28 on (stateless, `server/discover`), `legacy` before. */
56
+ era: 'legacy' | 'modern';
57
+ }
58
+ /**
59
+ * The request headers the 2026-07-28 revision adds to every POST (its Streamable HTTP "request
60
+ * metadata"), beside `MCP-Protocol-Version`, which the 2025 revisions already send after
61
+ * `initialize`. A page can send them only to a server whose `Access-Control-Allow-Headers` lists
62
+ * them.
63
+ */
64
+ declare const MCP_MODERN_REQUEST_HEADERS: readonly string[];
33
65
 
34
66
  /**
35
67
  * A remote MCP server reached over StreamableHTTP. Browsers can ONLY speak the
@@ -63,6 +95,50 @@ interface McpHttpServerConfig {
63
95
  reconnection?: Partial<StreamableHTTPReconnectionOptions>;
64
96
  /** Give up on this server after this many ms of connect + listing (overrides the option). */
65
97
  connectTimeoutMs?: number;
98
+ /**
99
+ * Which revisions of the protocol this connection may use. Default `'legacy'`:
100
+ * the 2025 revisions (the `initialize` handshake), exactly what was sent before
101
+ * this option existed. `'auto'` asks the server first (`server/discover`) and
102
+ * speaks 2026-07-28 to one that offers it, the 2025 handshake to any other;
103
+ * `'modern'` is 2026-07-28 only, and a server that does not offer it fails the
104
+ * connect. Decided once, at connect: a tool call is never retried in another
105
+ * revision.
106
+ *
107
+ * CORS: 2026-07-28 adds the request headers `Mcp-Method` and `Mcp-Name` (and
108
+ * sends `MCP-Protocol-Version` on every request, the first included). A server
109
+ * whose `Access-Control-Allow-Headers` does not list them cannot be reached
110
+ * that way from a page: `'modern'` then fails, and `'auto'` falls back to the
111
+ * 2025 revisions with a warning that names the headers. See the README, "CORS".
112
+ *
113
+ * On 2026-07-28 there is no session; a tool-list change arrives over a
114
+ * `subscriptions/listen` stream this connector opens - and opens again, with
115
+ * backoff, when it ends while the connection is open (then `onToolsChanged`
116
+ * fires once: a change in the gap was announced to nobody) - and an
117
+ * `input_required` result fails the call unless the connection was given
118
+ * `onElicitation` (see `ConnectMcpOptions`).
119
+ */
120
+ protocol?: McpProtocolMode;
121
+ /**
122
+ * EXPERIMENTAL (the Skills extension is Beta): load the skills this server serves
123
+ * (`io.modelcontextprotocol/skills`) into the agent's skills catalog, as `<server>/<skill>`.
124
+ * Off by default: without it the extension is not declared and nothing of it is sent. Needs
125
+ * the 2026-07-28 revision (`protocol: 'auto'` or `'modern'`): the extension is written against
126
+ * it. The skills come with the server's tools (each mounted tool carries them, like the
127
+ * server's instructions), so merging `tools` into the agent's config is all a host does. Their
128
+ * text is third-party - knowledge only, never policy; see the README, "MCP skills".
129
+ * `true`, or `{ consent }`: when a person is asked before one of its skills enters the model's
130
+ * context - `'once-per-skill'` (default, or the agent's `mcpSkills.consent`), `'ask'` (every
131
+ * run) or `'never'` (a server you vetted).
132
+ */
133
+ skills?: McpSkillsSetting;
134
+ /**
135
+ * MCP Apps for THIS server, over the connection's `apps`: `false` keeps its apps off while
136
+ * other servers' are shown - nothing is declared to it, no app of it is read, no `mcp.app`
137
+ * event is told, and a tool it marks for its app only (`visibility` without `'model'`) is
138
+ * not mounted; its other tools are the model's, as plain tools. `true` turns them on for this
139
+ * server alone. Left out, the connection's `apps` decides.
140
+ */
141
+ apps?: boolean;
66
142
  }
67
143
  interface McpCatalogEntry {
68
144
  name: string;
@@ -70,6 +146,11 @@ interface McpCatalogEntry {
70
146
  server: string;
71
147
  /** The server marked the tool read-only (`annotations.readOnlyHint`). */
72
148
  readOnly?: boolean;
149
+ /**
150
+ * With `apps: true`: the MCP App (`ui://…`) the tool declares. Its results then come with an
151
+ * `mcp.app` event, and the host can show the app (`ConnectedMcp.apps`).
152
+ */
153
+ app?: string;
73
154
  }
74
155
  interface McpServerResult {
75
156
  name: string;
@@ -97,13 +178,75 @@ interface ConnectedMcp {
97
178
  * the agent's config is all a host does.
98
179
  */
99
180
  instructions: McpServerInstructions[];
181
+ /**
182
+ * The protocol revision negotiated with each connected server, in declaration
183
+ * order: `2025-…` after the `initialize` handshake (always, for a server
184
+ * without `protocol`), `2026-07-28` when `protocol: 'auto'` or `'modern'`
185
+ * found a server that offers it. Fixed for the life of the connection.
186
+ */
187
+ protocols: McpServerProtocol[];
100
188
  /**
101
189
  * Re-list one server's tools and rewrite its entries in `tools`/`catalog`.
102
190
  * Both are mutated in place, so anything holding a reference (including a
103
191
  * live agent config) sees the new set. Throws if the server isn't connected.
192
+ * With `skills: true` it lists the server's skills again too (an agent built
193
+ * after the refresh has the new ones; one built before keeps what it read).
104
194
  */
105
195
  refreshServer: (name: string) => Promise<void>;
106
196
  close: () => Promise<void>;
197
+ /**
198
+ * MCP Apps, present only on a connection made with `apps: true`: read an app's HTML and make
199
+ * the tool calls an app asks for. See {@link McpAppsConnection}.
200
+ */
201
+ apps?: McpAppsConnection;
202
+ }
203
+ /** A tool of a server as an app of that server sees it (see `McpAppsConnection.appTool`). */
204
+ interface McpAppTool {
205
+ /** The server's own name for the tool. */
206
+ name: string;
207
+ /**
208
+ * The name the agent's consent rules match: the key the tool is mounted under, or the key it
209
+ * would have (`server__tool`) when it is for apps only and not mounted.
210
+ */
211
+ key: string;
212
+ description: string;
213
+ inputSchema: unknown;
214
+ /** `annotations.readOnlyHint`: the consent gate lets it through in 'ask-writes'. */
215
+ readOnly: boolean;
216
+ visibility: McpAppVisibility[];
217
+ /** The app it declares, if any. */
218
+ resourceUri?: string;
219
+ }
220
+ /**
221
+ * The host's side of MCP Apps for one connection (`apps: true`). Every call names the server:
222
+ * an app may read and call only what its own server declared.
223
+ *
224
+ * - `readUiResource` reads an app's document with `resources/read` - only a `ui://` URI that a
225
+ * tool of THAT server declares in its current listing, from that server and nowhere else;
226
+ * checked (MIME type, size, URI) and cached per connection.
227
+ * - `appTool` is a server's tool an app may call: listed, with `visibility` including `'app'`.
228
+ * - `callAppTool` sends that tool call and returns the raw result for the app. It does NOT ask
229
+ * the user: a host calls it only after its consent, e.g. `Agent.approveAppToolCall`.
230
+ */
231
+ interface McpAppsConnection {
232
+ readUiResource: (server: string, uri: string, options?: {
233
+ signal?: AbortSignal;
234
+ }) => Promise<McpAppResource>;
235
+ appTool: (server: string, name: string) => McpAppTool | undefined;
236
+ /**
237
+ * A resource of that server for a file its app asks the host to save (`ui/download-file` with
238
+ * a `resource_link`): `resources/read` on THAT server only - never a fetch of the URI - its
239
+ * `text` or base64 `blob` as bytes, at most `maxBytes` (default `MCP_APP_MAX_DOWNLOAD_BYTES`),
240
+ * not cached. Only a server whose apps are on. It does NOT ask the user, nor judge the type:
241
+ * the host does both before it saves anything.
242
+ */
243
+ readResource: (server: string, uri: string, options?: {
244
+ signal?: AbortSignal;
245
+ maxBytes?: number;
246
+ }) => Promise<McpAppDownloadResource>;
247
+ callAppTool: (server: string, name: string, args: Record<string, unknown>, options?: {
248
+ signal?: AbortSignal;
249
+ }) => Promise<McpAppToolResult>;
107
250
  }
108
251
  interface ConnectMcpOptions {
109
252
  clientName?: string;
@@ -113,6 +256,14 @@ interface ConnectMcpOptions {
113
256
  * Fires when a server pushes `notifications/tools/list_changed`. Call
114
257
  * `refreshServer(name)` from a point where no run is reading `tools` — this
115
258
  * connector deliberately does not refresh behind a running agent's back.
259
+ * On a 2026-07-28 connection (`protocol`) the notice arrives over a
260
+ * `subscriptions/listen` stream, opened only when this callback is given and
261
+ * opened again when it ends (backoff from 1 s to 60 s, at most 10 attempts in
262
+ * a row; never after a 401 / 403 / 404 / 405). Once a stream is back this
263
+ * callback fires as for a notice, since a change in the gap was not announced.
264
+ * On a server with `skills: true` it also fires for a resource list change
265
+ * (`notifications/resources/list_changed`): that is how a change of its
266
+ * skills is announced, and `refreshServer` lists them again.
116
267
  */
117
268
  onToolsChanged?: (server: string) => void;
118
269
  /**
@@ -121,6 +272,47 @@ interface ConnectMcpOptions {
121
272
  * mount — one hanging server no longer holds every other one hostage.
122
273
  */
123
274
  connectTimeoutMs?: number;
275
+ /**
276
+ * MCP elicitation: a server may ask the user for input in the middle of a tool
277
+ * call (a form, or - with `elicitation.url` - a link to open), and this
278
+ * callback answers: accept with the form's values, decline, or cancel. The
279
+ * HOST decides, never the model: the question is not shown to the model, and
280
+ * the answer goes only to the server that asked - not into the model's
281
+ * context, an event, a log or a run checkpoint.
282
+ *
283
+ * Without the callback the capability is not declared, a server cannot ask,
284
+ * and nothing is sent that was not sent before. The server's message and form
285
+ * are third-party text: cleaned, capped and restricted to a flat form before
286
+ * the callback sees them; the answer is checked against the form before it is
287
+ * sent. A link (URL mode) is only handed to the callback: this package never
288
+ * fetches or opens it. A callback that throws or does not answer in time
289
+ * cancels the question and fails the tool call; nothing is retried.
290
+ *
291
+ * Inside an agent run the two events `mcp.elicitation-requested` /
292
+ * `mcp.elicitation-answered` are emitted (the answered one never carries a
293
+ * value). On the 2025 revisions the calls to a server with this option run
294
+ * one at a time: its question does not say which call it belongs to.
295
+ */
296
+ onElicitation?: McpElicitationHandler;
297
+ /**
298
+ * Its settings: `timeoutMs` (default 300 000: a human is answering; the
299
+ * step's `chatTimeoutMs` stops while a question waits),
300
+ * `maxPerToolCall` (5), `maxPerRun` (20), `url` (also accept URL mode; default
301
+ * false), `subagents` (let a call made by a helper - a subagent - ask too;
302
+ * default false: its question is cancelled without the callback being called).
303
+ */
304
+ elicitation?: McpElicitationOptions;
305
+ /**
306
+ * MCP Apps (the `io.modelcontextprotocol/ui` extension): declare the extension in the
307
+ * handshake, read each tool's `_meta.ui` (its `ui://` app and its `visibility`), emit an
308
+ * `mcp.app` event in a run when such a tool returns, and give the host `ConnectedMcp.apps` to
309
+ * read the app and make the calls it asks for. A tool whose `visibility` leaves out `'model'`
310
+ * is then not mounted (it is for its app only). The app's HTML never reaches the model.
311
+ *
312
+ * Off by default: nothing is declared, `_meta` is not read, every tool is mounted as before and
313
+ * the wire is unchanged. A server's own `apps` (`McpHttpServerConfig.apps`) wins over this one.
314
+ */
315
+ apps?: boolean;
124
316
  }
125
317
  /**
126
318
  * Flatten an MCP tool result's content into something a model can read. Unlike
@@ -141,9 +333,17 @@ declare const flattenContent: (content: unknown) => unknown;
141
333
  * bug that lets OAuth and `initialize` succeed and then kills the connection
142
334
  * moments later, looking for all the world like the consent step failed.
143
335
  *
336
+ * With `protocol: 'auto'` or `'modern'` the transport also sends the request
337
+ * headers of the 2026-07-28 revision, on the very first request. The browser
338
+ * will not say which header a preflight refused either, so each one is tried on
339
+ * its own: the ones that do not get through are the ones missing from the
340
+ * server's `Access-Control-Allow-Headers`, and they are named.
341
+ *
144
342
  * Exported because a UI wants to say this too, not just log it.
145
343
  */
146
- declare const diagnoseMcpCors: (url: string, fetchFn?: FetchLike) => Promise<string | undefined>;
344
+ declare const diagnoseMcpCors: (url: string, fetchFn?: FetchLike, opts?: {
345
+ protocol?: McpProtocolMode;
346
+ }) => Promise<string | undefined>;
147
347
  /**
148
348
  * Connect to one or more HTTP MCP servers and return their tools + catalogue.
149
349
  * Servers connect concurrently; tools, catalogue, and results merge in the
@@ -153,8 +353,9 @@ declare const connectMcpHttp: (servers: Record<string, McpHttpServerConfig>, opt
153
353
 
154
354
  /**
155
355
  * Browser-side OAuth 2.1 for remote MCP servers: Dynamic Client Registration
156
- * (RFC 7591) or a client ID metadata document (CIMD), PKCE authorization-code
157
- * flow, refresh-token rotation, and the `iss` check on the way back (RFC 9207).
356
+ * (RFC 7591) or a client ID metadata document (CIMD) - automatically or one of
357
+ * them only (`registration`) - PKCE authorization-code flow, refresh-token
358
+ * rotation, and the `iss` check on the way back (RFC 9207).
158
359
  *
159
360
  * The heavy lifting lives in the MCP SDK — `auth()` discovers the protected
160
361
  * resource (RFC 9728), registers the client if we have no client_id yet,
@@ -196,6 +397,25 @@ declare class MemoryOAuthStorage implements McpOAuthStorage {
196
397
  set(key: string, value: string): Promise<void>;
197
398
  delete(key: string): Promise<void>;
198
399
  }
400
+ /**
401
+ * How the OAuth client is registered with a server's authorization server
402
+ * (`BrowserOAuthProviderOptions.registration`):
403
+ *
404
+ * - `'auto'` (the default): by the client ID metadata document (CIMD) when the
405
+ * authorization server advertises `client_id_metadata_document_supported` and
406
+ * a `clientMetadataUrl` is set, by dynamic client registration (DCR, RFC 7591)
407
+ * otherwise. A client already in storage is used as it is.
408
+ * - `'cimd'`: by the metadata document only. Needs `clientMetadataUrl`. An
409
+ * authorization server that does not advertise support is refused before
410
+ * anything is sent to its registration endpoint.
411
+ * - `'dcr'`: by dynamic registration only, even with a `clientMetadataUrl` set:
412
+ * the SDK is never shown the URL.
413
+ *
414
+ * The Node package has the same option, with the same names; change both.
415
+ */
416
+ type McpOAuthRegistration = 'auto' | 'cimd' | 'dcr';
417
+ /** How a stored client was registered: see {@link BrowserOAuthProvider.registrationKind}. */
418
+ type McpOAuthRegistrationKind = 'cimd' | 'dcr';
199
419
  interface BrowserOAuthProviderOptions {
200
420
  /** The MCP endpoint this provider authorizes against (the resource server). */
201
421
  serverUrl: string;
@@ -219,9 +439,20 @@ interface BrowserOAuthProviderOptions {
219
439
  * this URL is used as the `client_id` and no dynamic registration is made;
220
440
  * otherwise registration runs as before. A registration already in storage
221
441
  * wins over both. Must be https with a non-root path, and the document served
222
- * there must list the same `redirect_uris` as `redirectUrl`.
442
+ * there must list the same `redirect_uris` as `redirectUrl`. With
443
+ * `registration: 'dcr'` it is never used as the `client_id`.
223
444
  */
224
445
  clientMetadataUrl?: string;
446
+ /**
447
+ * How the client is registered: `'auto'` (default; as described for
448
+ * `clientMetadataUrl`), `'cimd'` (the metadata document only: needs
449
+ * `clientMetadataUrl`, and an authorization server without support is refused
450
+ * before any registration request) or `'dcr'` (dynamic registration only).
451
+ * A stored client of the other kind is not reused: it is forgotten, with the
452
+ * tokens issued to it, and the user signs in again. See
453
+ * {@link McpOAuthRegistration}.
454
+ */
455
+ registration?: McpOAuthRegistration;
225
456
  /** Defaults to the encrypted IndexedDB vault. */
226
457
  storage?: McpOAuthStorage;
227
458
  /** Treat an access token as expired this many seconds early. Default 30. */
@@ -262,13 +493,22 @@ declare class BrowserOAuthProvider implements OAuthClientProvider {
262
493
  private readonly _redirectUrl;
263
494
  private readonly _clientMetadata;
264
495
  private readonly _clientMetadataUrl?;
496
+ private readonly _registration;
265
497
  private readonly skewMs;
266
498
  private readonly onRedirect?;
499
+ /** Once per provider: a stored client of the other kind is forgotten (see `settle`). */
500
+ private settled?;
267
501
  constructor(opts: BrowserOAuthProviderOptions);
268
502
  get redirectUrl(): string;
269
503
  get clientMetadata(): OAuthClientMetadata;
270
- /** The client ID metadata document URL (CIMD), when one was configured. */
504
+ /**
505
+ * The client ID metadata document URL (CIMD), when one was configured - and
506
+ * not with `registration: 'dcr'`: the SDK uses this getter to decide, so a
507
+ * URL it cannot see is a URL it never uses as the `client_id`.
508
+ */
271
509
  get clientMetadataUrl(): string | undefined;
510
+ /** How this provider registers its client: `'auto'`, `'cimd'` or `'dcr'`. */
511
+ get registration(): McpOAuthRegistration;
272
512
  private key;
273
513
  private readJSON;
274
514
  state(): Promise<string>;
@@ -277,8 +517,44 @@ declare class BrowserOAuthProvider implements OAuthClientProvider {
277
517
  * whether or not it matched, so a replayed callback can't pass twice.
278
518
  */
279
519
  verifyState(returned: string | undefined): Promise<boolean>;
520
+ /** The stored client, without our stamp, and how it was registered. */
521
+ private readClient;
522
+ private kindOf;
523
+ /**
524
+ * May this provider use the stored client? Under `'auto'` any; under `'cimd'`
525
+ * only the configured document itself; under `'dcr'` only one that was not
526
+ * registered by a document.
527
+ */
528
+ private fits;
529
+ /** The client and the tokens issued to it go together: a token belongs to a client. */
530
+ private forgetClient;
531
+ /**
532
+ * Under `'cimd'` / `'dcr'`, before the first read of the client or a token: a
533
+ * stored client of the other kind (registered under another setting) is
534
+ * forgotten with its tokens, so the setting is never served by the old
535
+ * client - not even by its access token, which the transport would otherwise
536
+ * keep sending until it expires. Once per provider (its setting is fixed); a
537
+ * failure is not remembered.
538
+ */
539
+ private settle;
540
+ /**
541
+ * `'cimd'` with no usable client: the SDK is about to choose between the
542
+ * document and a dynamic registration, by the authorization server metadata
543
+ * it has just saved (`saveDiscoveryState` comes first). Without support it
544
+ * would register - so it is stopped HERE, before any request is made, and
545
+ * what discovery found is forgotten, so the next attempt reads the server's
546
+ * metadata again (a server that starts supporting CIMD is noticed).
547
+ */
548
+ private assertCimdSupported;
280
549
  clientInformation(): Promise<OAuthClientInformationMixed | undefined>;
281
550
  saveClientInformation(info: OAuthClientInformationMixed): Promise<void>;
551
+ /**
552
+ * How the stored client was registered: `'cimd'` (its `client_id` is the
553
+ * client ID metadata document), `'dcr'` (registered dynamically - or saved by
554
+ * the host), or undefined when there is none this provider would use. Read it
555
+ * after a sign-in to show the user which way was taken.
556
+ */
557
+ registrationKind(): Promise<McpOAuthRegistrationKind | undefined>;
282
558
  tokens(): Promise<OAuthTokens | undefined>;
283
559
  saveTokens(tokens: OAuthTokens): Promise<void>;
284
560
  saveCodeVerifier(verifier: string): Promise<void>;
@@ -667,5 +943,5 @@ declare class BrowserEnterpriseOAuthProvider implements OAuthClientProvider {
667
943
  /** Convenience factory mirroring the rest of the package's `createX` style. */
668
944
  declare const createEnterpriseOAuthProvider: (opts: EnterpriseOAuthProviderOptions) => BrowserEnterpriseOAuthProvider;
669
945
 
670
- export { BrowserEnterpriseOAuthProvider, BrowserOAuthProvider, ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION, EnterpriseOAuthError, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MemoryOAuthStorage, VaultOAuthStorage, beginMcpOAuth, checkAuthorizationResponseIssuer, connectMcpHttp, createEnterpriseOAuthProvider, diagnoseMcpCors, finishMcpOAuth, flattenContent, readOAuthCallback, renderMcpInstructions };
671
- export type { BrowserOAuthProviderOptions, ConnectMcpOptions, ConnectedMcp, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseIdpOptions, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterpriseOAuthProviderOptions, EnterprisePrivateKey, McpCatalogEntry, McpHttpServerConfig, McpOAuthCallback, McpOAuthRequestOptions, McpOAuthStorage, McpServerInstructions, McpServerResult };
946
+ export { BrowserEnterpriseOAuthProvider, BrowserOAuthProvider, ENTERPRISE_MANAGED_AUTHORIZATION_EXTENSION, EnterpriseOAuthError, MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER, MCP_INSTRUCTIONS_MAX_CHARS_TOTAL, MCP_MODERN_PROTOCOL_VERSION, MCP_MODERN_REQUEST_HEADERS, McpAppDownloadResource, McpAppResource, McpAppToolResult, McpAppVisibility, McpElicitationHandler, McpElicitationOptions, MemoryOAuthStorage, VaultOAuthStorage, beginMcpOAuth, checkAuthorizationResponseIssuer, connectMcpHttp, createEnterpriseOAuthProvider, diagnoseMcpCors, finishMcpOAuth, flattenContent, readOAuthCallback, renderMcpInstructions };
947
+ export type { BrowserOAuthProviderOptions, ConnectMcpOptions, ConnectedMcp, EnterpriseAssertionAlgorithm, EnterpriseAssertionAudience, EnterpriseAssertionType, EnterpriseIdpOptions, EnterpriseOAuthHop, EnterpriseOAuthLog, EnterpriseOAuthProviderOptions, EnterprisePrivateKey, McpAppTool, McpAppsConnection, McpCatalogEntry, McpHttpServerConfig, McpOAuthCallback, McpOAuthRegistration, McpOAuthRegistrationKind, McpOAuthRequestOptions, McpOAuthStorage, McpProtocolMode, McpServerInstructions, McpServerProtocol, McpServerResult };