@dudko.dev/agent-web 0.0.40 → 0.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +305 -22
  2. package/dist/agent-web.js +169 -161
  3. package/dist/agent-web.js.map +1 -1
  4. package/dist/chunk-2MLHZ6LQ.js +510 -0
  5. package/dist/chunk-2MLHZ6LQ.js.map +1 -0
  6. package/dist/{chunk-TZITKUFW.js → chunk-DAREMCXF.js} +152 -20
  7. package/dist/chunk-DAREMCXF.js.map +1 -0
  8. package/dist/{chunk-V3JOK7EW.js → chunk-YPCHD6DV.js} +4 -2
  9. package/dist/chunk-YPCHD6DV.js.map +1 -0
  10. package/dist/chunk-ZSZSSJS4.js +973 -0
  11. package/dist/chunk-ZSZSSJS4.js.map +1 -0
  12. package/dist/elicitation-DS-84_bF.d.cts +680 -0
  13. package/dist/elicitation-DS-84_bF.d.ts +680 -0
  14. package/dist/index.cjs +1939 -225
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +692 -117
  17. package/dist/index.d.ts +692 -117
  18. package/dist/index.js +1325 -189
  19. package/dist/index.js.map +1 -1
  20. package/dist/mcp.cjs +2478 -49
  21. package/dist/mcp.cjs.map +1 -1
  22. package/dist/mcp.d.cts +291 -9
  23. package/dist/mcp.d.ts +291 -9
  24. package/dist/mcp.js +1578 -48
  25. package/dist/mcp.js.map +1 -1
  26. package/dist/{sandbox-KG6OUG24.js → sandbox-3VRX47UY.js} +21 -8
  27. package/dist/sandbox-3VRX47UY.js.map +1 -0
  28. package/dist/sandbox-worker.cjs +3 -1
  29. package/dist/sandbox-worker.cjs.map +1 -1
  30. package/dist/sandbox-worker.js +1 -1
  31. package/package.json +1 -1
  32. package/dist/chunk-A6ZJALLU.js +0 -254
  33. package/dist/chunk-A6ZJALLU.js.map +0 -1
  34. package/dist/chunk-CTXDKSDD.js +0 -39
  35. package/dist/chunk-CTXDKSDD.js.map +0 -1
  36. package/dist/chunk-TZITKUFW.js.map +0 -1
  37. package/dist/chunk-V3JOK7EW.js.map +0 -1
  38. package/dist/sandbox-KG6OUG24.js.map +0 -1
  39. package/dist/vault-BatBaRQP.d.cts +0 -36
  40. package/dist/vault-BatBaRQP.d.ts +0 -36
package/dist/mcp.d.ts 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.js';
4
+ import { O as McpElicitationHandler, P as McpElicitationOptions, D as McpAppResource, E as McpAppVisibility, Q as McpAppDownloadResource, h as McpAppToolResult } from './elicitation-DS-84_bF.js';
5
+ import { McpSkillsSetting, VaultOptions } from './index.js';
6
+ export { i as MCP_APPS_EXTENSION, R as MCP_APP_DEFAULT_VISIBILITY, T as MCP_APP_MAX_DOMAINS, U as MCP_APP_MAX_DOWNLOAD_BYTES, j as MCP_APP_MAX_HTML_CHARS, k as MCP_APP_MAX_RESULT_CHARS, l as MCP_APP_MIME_TYPE, W as MCP_ELICITATION_MAX_PER_RUN, X as MCP_ELICITATION_MAX_PER_TOOL_CALL, Y as MCP_ELICITATION_TIMEOUT_MS, B as McpAppCsp, C as McpAppPermissions, Z as McpAppResourceError, _ as McpAppToolMeta, $ as McpAppsMode, a0 as McpElicitationContent, a1 as McpElicitationContext, F as McpElicitationFieldSchema, g as McpElicitationReason, a2 as McpElicitationRequest, a3 as McpElicitationResult, f as McpElicitationSchema, a4 as isMcpAppMimeType, a5 as isMcpAppUri, a6 as mcpAppCspOf, a7 as mcpAppDownloadOf, J as mcpAppOrigin, a8 as mcpAppPermissionsOf, a9 as mcpAppResourceOf, aa as mcpAppToolMeta, ab as mcpAppToolResultOf, ac as mcpAppsModeOf, ad as normalizeMcpElicitationSchema, ae as validateMcpElicitationContent } from './elicitation-DS-84_bF.js';
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,53 @@ 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, dynamic }`: `consent` is when a person is asked before one of its
130
+ * skills enters the model's context - `'once-per-skill'` (default, or the agent's
131
+ * `mcpSkills.consent`), `'ask'` (every run) or `'never'` (a server you vetted); `dynamic: true`
132
+ * also takes its GENERATED skills (`"resources": "dynamic"`, no checksums - declined by
133
+ * default), each read whole into a snapshot in memory before anyone is asked, approved and used
134
+ * as that copy only (README, "MCP skills").
135
+ */
136
+ skills?: McpSkillsSetting;
137
+ /**
138
+ * MCP Apps for THIS server, over the connection's `apps`: `false` keeps its apps off while
139
+ * other servers' are shown - nothing is declared to it, no app of it is read, no `mcp.app`
140
+ * event is told, and a tool it marks for its app only (`visibility` without `'model'`) is
141
+ * not mounted; its other tools are the model's, as plain tools. `true` turns them on for this
142
+ * server alone. Left out, the connection's `apps` decides.
143
+ */
144
+ apps?: boolean;
66
145
  }
67
146
  interface McpCatalogEntry {
68
147
  name: string;
@@ -70,6 +149,11 @@ interface McpCatalogEntry {
70
149
  server: string;
71
150
  /** The server marked the tool read-only (`annotations.readOnlyHint`). */
72
151
  readOnly?: boolean;
152
+ /**
153
+ * With `apps: true`: the MCP App (`ui://…`) the tool declares. Its results then come with an
154
+ * `mcp.app` event, and the host can show the app (`ConnectedMcp.apps`).
155
+ */
156
+ app?: string;
73
157
  }
74
158
  interface McpServerResult {
75
159
  name: string;
@@ -97,13 +181,75 @@ interface ConnectedMcp {
97
181
  * the agent's config is all a host does.
98
182
  */
99
183
  instructions: McpServerInstructions[];
184
+ /**
185
+ * The protocol revision negotiated with each connected server, in declaration
186
+ * order: `2025-…` after the `initialize` handshake (always, for a server
187
+ * without `protocol`), `2026-07-28` when `protocol: 'auto'` or `'modern'`
188
+ * found a server that offers it. Fixed for the life of the connection.
189
+ */
190
+ protocols: McpServerProtocol[];
100
191
  /**
101
192
  * Re-list one server's tools and rewrite its entries in `tools`/`catalog`.
102
193
  * Both are mutated in place, so anything holding a reference (including a
103
194
  * live agent config) sees the new set. Throws if the server isn't connected.
195
+ * With `skills: true` it lists the server's skills again too (an agent built
196
+ * after the refresh has the new ones; one built before keeps what it read).
104
197
  */
105
198
  refreshServer: (name: string) => Promise<void>;
106
199
  close: () => Promise<void>;
200
+ /**
201
+ * MCP Apps, present only on a connection made with `apps: true`: read an app's HTML and make
202
+ * the tool calls an app asks for. See {@link McpAppsConnection}.
203
+ */
204
+ apps?: McpAppsConnection;
205
+ }
206
+ /** A tool of a server as an app of that server sees it (see `McpAppsConnection.appTool`). */
207
+ interface McpAppTool {
208
+ /** The server's own name for the tool. */
209
+ name: string;
210
+ /**
211
+ * The name the agent's consent rules match: the key the tool is mounted under, or the key it
212
+ * would have (`server__tool`) when it is for apps only and not mounted.
213
+ */
214
+ key: string;
215
+ description: string;
216
+ inputSchema: unknown;
217
+ /** `annotations.readOnlyHint`: the consent gate lets it through in 'ask-writes'. */
218
+ readOnly: boolean;
219
+ visibility: McpAppVisibility[];
220
+ /** The app it declares, if any. */
221
+ resourceUri?: string;
222
+ }
223
+ /**
224
+ * The host's side of MCP Apps for one connection (`apps: true`). Every call names the server:
225
+ * an app may read and call only what its own server declared.
226
+ *
227
+ * - `readUiResource` reads an app's document with `resources/read` - only a `ui://` URI that a
228
+ * tool of THAT server declares in its current listing, from that server and nowhere else;
229
+ * checked (MIME type, size, URI) and cached per connection.
230
+ * - `appTool` is a server's tool an app may call: listed, with `visibility` including `'app'`.
231
+ * - `callAppTool` sends that tool call and returns the raw result for the app. It does NOT ask
232
+ * the user: a host calls it only after its consent, e.g. `Agent.approveAppToolCall`.
233
+ */
234
+ interface McpAppsConnection {
235
+ readUiResource: (server: string, uri: string, options?: {
236
+ signal?: AbortSignal;
237
+ }) => Promise<McpAppResource>;
238
+ appTool: (server: string, name: string) => McpAppTool | undefined;
239
+ /**
240
+ * A resource of that server for a file its app asks the host to save (`ui/download-file` with
241
+ * a `resource_link`): `resources/read` on THAT server only - never a fetch of the URI - its
242
+ * `text` or base64 `blob` as bytes, at most `maxBytes` (default `MCP_APP_MAX_DOWNLOAD_BYTES`),
243
+ * not cached. Only a server whose apps are on. It does NOT ask the user, nor judge the type:
244
+ * the host does both before it saves anything.
245
+ */
246
+ readResource: (server: string, uri: string, options?: {
247
+ signal?: AbortSignal;
248
+ maxBytes?: number;
249
+ }) => Promise<McpAppDownloadResource>;
250
+ callAppTool: (server: string, name: string, args: Record<string, unknown>, options?: {
251
+ signal?: AbortSignal;
252
+ }) => Promise<McpAppToolResult>;
107
253
  }
108
254
  interface ConnectMcpOptions {
109
255
  clientName?: string;
@@ -113,6 +259,17 @@ interface ConnectMcpOptions {
113
259
  * Fires when a server pushes `notifications/tools/list_changed`. Call
114
260
  * `refreshServer(name)` from a point where no run is reading `tools` — this
115
261
  * connector deliberately does not refresh behind a running agent's back.
262
+ * On a 2026-07-28 connection (`protocol`) the notice arrives over a
263
+ * `subscriptions/listen` stream, opened only when this callback is given and
264
+ * opened again when it ends (backoff from 1 s to 60 s, at most 10 attempts in
265
+ * a row; never after a 401 / 403 / 404 / 405). Once a stream is back this
266
+ * callback fires as for a notice, since a change in the gap was not announced.
267
+ * On a server with `skills: true` it also fires for a resource list change
268
+ * (`notifications/resources/list_changed`): that is how a change of its
269
+ * skills is announced, and `refreshServer` lists them again. It fires too,
270
+ * once per loaded skill, when a directory read (`resources/directory/read`,
271
+ * a server that declared `directoryRead`) shows that a skill changed on the
272
+ * server since it was loaded.
116
273
  */
117
274
  onToolsChanged?: (server: string) => void;
118
275
  /**
@@ -121,6 +278,47 @@ interface ConnectMcpOptions {
121
278
  * mount — one hanging server no longer holds every other one hostage.
122
279
  */
123
280
  connectTimeoutMs?: number;
281
+ /**
282
+ * MCP elicitation: a server may ask the user for input in the middle of a tool
283
+ * call (a form, or - with `elicitation.url` - a link to open), and this
284
+ * callback answers: accept with the form's values, decline, or cancel. The
285
+ * HOST decides, never the model: the question is not shown to the model, and
286
+ * the answer goes only to the server that asked - not into the model's
287
+ * context, an event, a log or a run checkpoint.
288
+ *
289
+ * Without the callback the capability is not declared, a server cannot ask,
290
+ * and nothing is sent that was not sent before. The server's message and form
291
+ * are third-party text: cleaned, capped and restricted to a flat form before
292
+ * the callback sees them; the answer is checked against the form before it is
293
+ * sent. A link (URL mode) is only handed to the callback: this package never
294
+ * fetches or opens it. A callback that throws or does not answer in time
295
+ * cancels the question and fails the tool call; nothing is retried.
296
+ *
297
+ * Inside an agent run the two events `mcp.elicitation-requested` /
298
+ * `mcp.elicitation-answered` are emitted (the answered one never carries a
299
+ * value). On the 2025 revisions the calls to a server with this option run
300
+ * one at a time: its question does not say which call it belongs to.
301
+ */
302
+ onElicitation?: McpElicitationHandler;
303
+ /**
304
+ * Its settings: `timeoutMs` (default 300 000: a human is answering; the
305
+ * step's `chatTimeoutMs` stops while a question waits),
306
+ * `maxPerToolCall` (5), `maxPerRun` (20), `url` (also accept URL mode; default
307
+ * false), `subagents` (let a call made by a helper - a subagent - ask too;
308
+ * default false: its question is cancelled without the callback being called).
309
+ */
310
+ elicitation?: McpElicitationOptions;
311
+ /**
312
+ * MCP Apps (the `io.modelcontextprotocol/ui` extension): declare the extension in the
313
+ * handshake, read each tool's `_meta.ui` (its `ui://` app and its `visibility`), emit an
314
+ * `mcp.app` event in a run when such a tool returns, and give the host `ConnectedMcp.apps` to
315
+ * read the app and make the calls it asks for. A tool whose `visibility` leaves out `'model'`
316
+ * is then not mounted (it is for its app only). The app's HTML never reaches the model.
317
+ *
318
+ * Off by default: nothing is declared, `_meta` is not read, every tool is mounted as before and
319
+ * the wire is unchanged. A server's own `apps` (`McpHttpServerConfig.apps`) wins over this one.
320
+ */
321
+ apps?: boolean;
124
322
  }
125
323
  /**
126
324
  * Flatten an MCP tool result's content into something a model can read. Unlike
@@ -141,9 +339,17 @@ declare const flattenContent: (content: unknown) => unknown;
141
339
  * bug that lets OAuth and `initialize` succeed and then kills the connection
142
340
  * moments later, looking for all the world like the consent step failed.
143
341
  *
342
+ * With `protocol: 'auto'` or `'modern'` the transport also sends the request
343
+ * headers of the 2026-07-28 revision, on the very first request. The browser
344
+ * will not say which header a preflight refused either, so each one is tried on
345
+ * its own: the ones that do not get through are the ones missing from the
346
+ * server's `Access-Control-Allow-Headers`, and they are named.
347
+ *
144
348
  * Exported because a UI wants to say this too, not just log it.
145
349
  */
146
- declare const diagnoseMcpCors: (url: string, fetchFn?: FetchLike) => Promise<string | undefined>;
350
+ declare const diagnoseMcpCors: (url: string, fetchFn?: FetchLike, opts?: {
351
+ protocol?: McpProtocolMode;
352
+ }) => Promise<string | undefined>;
147
353
  /**
148
354
  * Connect to one or more HTTP MCP servers and return their tools + catalogue.
149
355
  * Servers connect concurrently; tools, catalogue, and results merge in the
@@ -153,8 +359,9 @@ declare const connectMcpHttp: (servers: Record<string, McpHttpServerConfig>, opt
153
359
 
154
360
  /**
155
361
  * 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).
362
+ * (RFC 7591) or a client ID metadata document (CIMD) - automatically or one of
363
+ * them only (`registration`) - PKCE authorization-code flow, refresh-token
364
+ * rotation, and the `iss` check on the way back (RFC 9207).
158
365
  *
159
366
  * The heavy lifting lives in the MCP SDK — `auth()` discovers the protected
160
367
  * resource (RFC 9728), registers the client if we have no client_id yet,
@@ -196,6 +403,25 @@ declare class MemoryOAuthStorage implements McpOAuthStorage {
196
403
  set(key: string, value: string): Promise<void>;
197
404
  delete(key: string): Promise<void>;
198
405
  }
406
+ /**
407
+ * How the OAuth client is registered with a server's authorization server
408
+ * (`BrowserOAuthProviderOptions.registration`):
409
+ *
410
+ * - `'auto'` (the default): by the client ID metadata document (CIMD) when the
411
+ * authorization server advertises `client_id_metadata_document_supported` and
412
+ * a `clientMetadataUrl` is set, by dynamic client registration (DCR, RFC 7591)
413
+ * otherwise. A client already in storage is used as it is.
414
+ * - `'cimd'`: by the metadata document only. Needs `clientMetadataUrl`. An
415
+ * authorization server that does not advertise support is refused before
416
+ * anything is sent to its registration endpoint.
417
+ * - `'dcr'`: by dynamic registration only, even with a `clientMetadataUrl` set:
418
+ * the SDK is never shown the URL.
419
+ *
420
+ * The Node package has the same option, with the same names; change both.
421
+ */
422
+ type McpOAuthRegistration = 'auto' | 'cimd' | 'dcr';
423
+ /** How a stored client was registered: see {@link BrowserOAuthProvider.registrationKind}. */
424
+ type McpOAuthRegistrationKind = 'cimd' | 'dcr';
199
425
  interface BrowserOAuthProviderOptions {
200
426
  /** The MCP endpoint this provider authorizes against (the resource server). */
201
427
  serverUrl: string;
@@ -219,9 +445,20 @@ interface BrowserOAuthProviderOptions {
219
445
  * this URL is used as the `client_id` and no dynamic registration is made;
220
446
  * otherwise registration runs as before. A registration already in storage
221
447
  * 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`.
448
+ * there must list the same `redirect_uris` as `redirectUrl`. With
449
+ * `registration: 'dcr'` it is never used as the `client_id`.
223
450
  */
224
451
  clientMetadataUrl?: string;
452
+ /**
453
+ * How the client is registered: `'auto'` (default; as described for
454
+ * `clientMetadataUrl`), `'cimd'` (the metadata document only: needs
455
+ * `clientMetadataUrl`, and an authorization server without support is refused
456
+ * before any registration request) or `'dcr'` (dynamic registration only).
457
+ * A stored client of the other kind is not reused: it is forgotten, with the
458
+ * tokens issued to it, and the user signs in again. See
459
+ * {@link McpOAuthRegistration}.
460
+ */
461
+ registration?: McpOAuthRegistration;
225
462
  /** Defaults to the encrypted IndexedDB vault. */
226
463
  storage?: McpOAuthStorage;
227
464
  /** Treat an access token as expired this many seconds early. Default 30. */
@@ -262,13 +499,22 @@ declare class BrowserOAuthProvider implements OAuthClientProvider {
262
499
  private readonly _redirectUrl;
263
500
  private readonly _clientMetadata;
264
501
  private readonly _clientMetadataUrl?;
502
+ private readonly _registration;
265
503
  private readonly skewMs;
266
504
  private readonly onRedirect?;
505
+ /** Once per provider: a stored client of the other kind is forgotten (see `settle`). */
506
+ private settled?;
267
507
  constructor(opts: BrowserOAuthProviderOptions);
268
508
  get redirectUrl(): string;
269
509
  get clientMetadata(): OAuthClientMetadata;
270
- /** The client ID metadata document URL (CIMD), when one was configured. */
510
+ /**
511
+ * The client ID metadata document URL (CIMD), when one was configured - and
512
+ * not with `registration: 'dcr'`: the SDK uses this getter to decide, so a
513
+ * URL it cannot see is a URL it never uses as the `client_id`.
514
+ */
271
515
  get clientMetadataUrl(): string | undefined;
516
+ /** How this provider registers its client: `'auto'`, `'cimd'` or `'dcr'`. */
517
+ get registration(): McpOAuthRegistration;
272
518
  private key;
273
519
  private readJSON;
274
520
  state(): Promise<string>;
@@ -277,8 +523,44 @@ declare class BrowserOAuthProvider implements OAuthClientProvider {
277
523
  * whether or not it matched, so a replayed callback can't pass twice.
278
524
  */
279
525
  verifyState(returned: string | undefined): Promise<boolean>;
526
+ /** The stored client, without our stamp, and how it was registered. */
527
+ private readClient;
528
+ private kindOf;
529
+ /**
530
+ * May this provider use the stored client? Under `'auto'` any; under `'cimd'`
531
+ * only the configured document itself; under `'dcr'` only one that was not
532
+ * registered by a document.
533
+ */
534
+ private fits;
535
+ /** The client and the tokens issued to it go together: a token belongs to a client. */
536
+ private forgetClient;
537
+ /**
538
+ * Under `'cimd'` / `'dcr'`, before the first read of the client or a token: a
539
+ * stored client of the other kind (registered under another setting) is
540
+ * forgotten with its tokens, so the setting is never served by the old
541
+ * client - not even by its access token, which the transport would otherwise
542
+ * keep sending until it expires. Once per provider (its setting is fixed); a
543
+ * failure is not remembered.
544
+ */
545
+ private settle;
546
+ /**
547
+ * `'cimd'` with no usable client: the SDK is about to choose between the
548
+ * document and a dynamic registration, by the authorization server metadata
549
+ * it has just saved (`saveDiscoveryState` comes first). Without support it
550
+ * would register - so it is stopped HERE, before any request is made, and
551
+ * what discovery found is forgotten, so the next attempt reads the server's
552
+ * metadata again (a server that starts supporting CIMD is noticed).
553
+ */
554
+ private assertCimdSupported;
280
555
  clientInformation(): Promise<OAuthClientInformationMixed | undefined>;
281
556
  saveClientInformation(info: OAuthClientInformationMixed): Promise<void>;
557
+ /**
558
+ * How the stored client was registered: `'cimd'` (its `client_id` is the
559
+ * client ID metadata document), `'dcr'` (registered dynamically - or saved by
560
+ * the host), or undefined when there is none this provider would use. Read it
561
+ * after a sign-in to show the user which way was taken.
562
+ */
563
+ registrationKind(): Promise<McpOAuthRegistrationKind | undefined>;
282
564
  tokens(): Promise<OAuthTokens | undefined>;
283
565
  saveTokens(tokens: OAuthTokens): Promise<void>;
284
566
  saveCodeVerifier(verifier: string): Promise<void>;
@@ -667,5 +949,5 @@ declare class BrowserEnterpriseOAuthProvider implements OAuthClientProvider {
667
949
  /** Convenience factory mirroring the rest of the package's `createX` style. */
668
950
  declare const createEnterpriseOAuthProvider: (opts: EnterpriseOAuthProviderOptions) => BrowserEnterpriseOAuthProvider;
669
951
 
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 };
952
+ 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 };
953
+ 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 };