@kodax-ai/kodax 0.7.63 → 0.7.66
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/CHANGELOG.md +2300 -2204
- package/README.md +79 -7
- package/README_CN.md +52 -3
- package/dist/chunks/{agent-SL444XLN.js → agent-KER4WDNO.js} +1 -1
- package/dist/chunks/argument-completer-HK3MHA3K.js +2 -0
- package/dist/chunks/{chunk-ARUWXX25.js → chunk-35P7QL2Q.js} +1 -1
- package/dist/chunks/chunk-3HKBBY74.js +339 -0
- package/dist/chunks/chunk-AKBH2EEE.js +8 -0
- package/dist/chunks/{chunk-KCFVGXVK.js → chunk-ALS32RNZ.js} +1 -1
- package/dist/chunks/chunk-MHRN2LQV.js +328 -0
- package/dist/chunks/{chunk-HP4FXMEM.js → chunk-NBQW7PNZ.js} +2 -2
- package/dist/chunks/{chunk-S4GVQO3W.js → chunk-O7N22GJ3.js} +1 -1
- package/dist/chunks/chunk-ONUPGMER.js +2 -0
- package/dist/chunks/{chunk-ZL5CEANW.js → chunk-PZTG2C33.js} +1 -1
- package/dist/chunks/{chunk-4MIHVNB7.js → chunk-QAQ2HNXD.js} +112 -112
- package/dist/chunks/{chunk-6OZ5KWG3.js → chunk-QJJKMNZF.js} +1 -1
- package/dist/chunks/chunk-QJVZZSEO.js +56 -0
- package/dist/chunks/chunk-TLJGOKBT.js +729 -0
- package/dist/chunks/{chunk-7MPU7TP6.js → chunk-VS4CDDEF.js} +243 -243
- package/dist/chunks/chunk-WBBEJIAY.js +306 -0
- package/dist/chunks/{chunk-L3MF5V64.js → chunk-WMIZCY2J.js} +1 -1
- package/dist/chunks/{chunk-UA744TZM.js → chunk-YRBNXFHY.js} +1 -1
- package/dist/chunks/compaction-config-7GMUFNPB.js +2 -0
- package/dist/chunks/{construction-bootstrap-EFZBONTK.js → construction-bootstrap-3XDS2D5K.js} +1 -1
- package/dist/chunks/{devtools-4CRULTR2.js → devtools-CD6KSIHE.js} +1 -1
- package/dist/chunks/{devtools-YINBSZC7.js → devtools-XR5F2C6T.js} +1 -1
- package/dist/chunks/{dist-73L4OYPD.js → dist-4PXB7U22.js} +1 -1
- package/dist/chunks/dist-4YAYT2TO.js +2 -0
- package/dist/chunks/host-KG3456QP.js +2 -0
- package/dist/chunks/{paste-FDYM7SZX.js → paste-C33GZQV5.js} +1 -1
- package/dist/chunks/run-manager-6CAH3KTA.js +2 -0
- package/dist/chunks/utils-OT5ENFUL.js +2 -0
- package/dist/constructed-handler-worker.js +2 -0
- package/dist/index.d.ts +21 -10
- package/dist/index.js +6 -6
- package/dist/kodax_cli.js +1116 -1089
- package/dist/runtime-worker.js +2843 -0
- package/dist/sdk-agent.d.ts +27 -8
- package/dist/sdk-agent.js +1 -1
- package/dist/sdk-coding.d.ts +76 -1020
- package/dist/sdk-coding.js +1 -1
- package/dist/sdk-llm.js +1 -1
- package/dist/sdk-mcp.d.ts +2 -1
- package/dist/sdk-mcp.js +1 -1
- package/dist/sdk-media.js +1 -1
- package/dist/sdk-repl.d.ts +197 -183
- package/dist/sdk-repl.js +2 -2
- package/dist/sdk-runtime.d.ts +982 -0
- package/dist/sdk-runtime.js +2 -0
- package/dist/sdk-session.d.ts +3 -3
- package/dist/sdk-session.js +1 -1
- package/dist/sdk-skills.js +1 -1
- package/dist/semantic-worker.js +191 -10
- package/dist/types-chunks/{bash-prefix-extractor.d-CZW9fRoa.d.ts → bash-prefix-extractor.d-BjkITAva.d.ts} +142 -3
- package/dist/types-chunks/{run-manager.d-CYTnWhZY.d.ts → capsule.d-hVhPNkHd.d.ts} +5 -92
- package/dist/types-chunks/commands.d-C3B1TdGM.d.ts +213 -0
- package/dist/types-chunks/{types.d-1CnTg7Sd.d.ts → guardrail.d-C_Siraua.d.ts} +3 -128
- package/dist/types-chunks/{guardrail.d-MR6LwMB2.d.ts → guardrail.d-wk-s0psS.d.ts} +2 -2
- package/dist/types-chunks/{manager.d-DBD7SOTT.d.ts → manager.d-Zum9cGHU.d.ts} +3 -173
- package/dist/types-chunks/oauth-login.d-Bgb4rdLN.d.ts +174 -0
- package/dist/types-chunks/public-api.d-jtREVfEq.d.ts +596 -0
- package/dist/types-chunks/run-manager.d-CFknOfo1.d.ts +91 -0
- package/dist/types-chunks/{sdk-session-RBSBBKol.d.ts → sdk-session-CLqyfAmf.d.ts} +8 -306
- package/dist/types-chunks/types.d-BMLxKV69.d.ts +128 -0
- package/dist/types-chunks/types.d-CUN_bZU7.d.ts +975 -0
- package/dist/types-chunks/{utils.d-C14jZ9ZM.d.ts → utils.d-C1rpoeDh.d.ts} +84 -72
- package/package.json +7 -1
- package/dist/chunks/argument-completer-EN63ZVJK.js +0 -2
- package/dist/chunks/chunk-KHICMJIR.js +0 -310
- package/dist/chunks/chunk-LGR7ACBQ.js +0 -326
- package/dist/chunks/chunk-RR7W7UF6.js +0 -341
- package/dist/chunks/chunk-UGTK2JIJ.js +0 -731
- package/dist/chunks/chunk-V4WSBIXB.js +0 -2
- package/dist/chunks/chunk-VSWROENP.js +0 -52
- package/dist/chunks/compaction-config-4VIONMFB.js +0 -2
- package/dist/chunks/dist-EDF2YUF6.js +0 -2
- package/dist/chunks/host-J4HPDLFC.js +0 -2
- package/dist/chunks/run-manager-ZVSW2OWM.js +0 -2
- package/dist/chunks/utils-5HDLYTZJ.js +0 -2
- package/dist/types-chunks/storage.d-C6kkAEch.d.ts +0 -280
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as McpServersConfig, M as McpConnectMode, a as McpServerConfig, c as McpTransportKind } from './config.d-CJy1WENT.js';
|
|
2
2
|
import { K as KodaXBaseProvider } from './base.d-DalIRhbb.js';
|
|
3
3
|
import { a as CostTracker } from './cost-tracker.d-CBLk1fiD.js';
|
|
4
4
|
import { bq as RunnerToolCall } from './process.d-CY2g03Mb.js';
|
|
5
|
-
import {
|
|
5
|
+
import { d as ToolGuardrail } from './guardrail.d-C_Siraua.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* FEATURE_200 Phase F (v0.7.45) — MCP domain types extracted from types.ts.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as McpServerConfig, b as McpServersConfig, M as McpConnectMode } from './config.d-CJy1WENT.js';
|
|
2
1
|
import { a as CapabilityProvider, C as CapabilityKind, b as CapabilityResult } from './capability.d-3C62G8Eq.js';
|
|
2
|
+
import { a as McpServerConfig, b as McpServersConfig, M as McpConnectMode } from './config.d-CJy1WENT.js';
|
|
3
3
|
|
|
4
4
|
type McpCapabilityKind = 'tool' | 'resource' | 'prompt';
|
|
5
5
|
type McpCapabilityRisk = 'read' | 'write' | 'network' | 'exec';
|
|
@@ -348,176 +348,6 @@ declare class McpCapabilityProvider implements CapabilityProvider {
|
|
|
348
348
|
private requireRuntime;
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
interface McpTransportEvents {
|
|
352
|
-
/** Called with a complete JSON-RPC message (raw JSON string). */
|
|
353
|
-
onMessage(raw: string): void;
|
|
354
|
-
onError(error: Error): void;
|
|
355
|
-
onClose(reason: string): void;
|
|
356
|
-
}
|
|
357
|
-
interface McpTransport {
|
|
358
|
-
open(events: McpTransportEvents): Promise<void>;
|
|
359
|
-
/** Send a JSON string. The transport handles framing. */
|
|
360
|
-
send(json: string): Promise<void>;
|
|
361
|
-
setProtocolVersion?(version: string | undefined): void;
|
|
362
|
-
close(): Promise<void>;
|
|
363
|
-
readonly connected: boolean;
|
|
364
|
-
/** Effective transport after auto-detection (diagnostics only). */
|
|
365
|
-
readonly resolvedTransport?: string;
|
|
366
|
-
}
|
|
367
|
-
declare class McpExpiredSessionError extends Error {
|
|
368
|
-
constructor();
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* FEATURE_222 — the server demanded OAuth (401) or a stronger scope (403). It
|
|
372
|
-
* carries the `WWW-Authenticate` header so the connect flow can discover the
|
|
373
|
-
* authorization server (RFC 9728 pointer) or read the step-up scope.
|
|
374
|
-
*/
|
|
375
|
-
declare class McpAuthRequiredError extends Error {
|
|
376
|
-
readonly status: number;
|
|
377
|
-
readonly wwwAuthenticate?: string | undefined;
|
|
378
|
-
constructor(status: number, wwwAuthenticate?: string | undefined);
|
|
379
|
-
}
|
|
380
|
-
type StdioFraming = 'content-length' | 'ndjson';
|
|
381
|
-
interface McpTransportOptions {
|
|
382
|
-
stdioFraming?: StdioFraming;
|
|
383
|
-
httpResolvedTransport?: 'streamable-http' | 'sse';
|
|
384
|
-
}
|
|
385
|
-
declare function createMcpTransport(config: McpServerConfig, options?: McpTransportOptions): McpTransport;
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* FEATURE_222 — MCP OAuth discovery (server→authorization-server resolution).
|
|
389
|
-
*
|
|
390
|
-
* The modern MCP auth flow does NOT require the user to hand-configure
|
|
391
|
-
* authorization/token endpoints. Instead the client discovers them at runtime:
|
|
392
|
-
*
|
|
393
|
-
* 401 WWW-Authenticate (resource_metadata=...) [RFC 9728 pointer]
|
|
394
|
-
* → GET /.well-known/oauth-protected-resource [RFC 9728 PRM]
|
|
395
|
-
* → authorization_servers[0]
|
|
396
|
-
* → GET /.well-known/oauth-authorization-server [RFC 8414]
|
|
397
|
-
* (fallback /.well-known/openid-configuration) [OIDC]
|
|
398
|
-
* → authorization_endpoint / token_endpoint / registration_endpoint
|
|
399
|
-
*
|
|
400
|
-
* This module is the pure-HTTP discovery layer (no PKCE, no browser, no token
|
|
401
|
-
* storage — those compose on top). The path-aware fallback ordering mirrors
|
|
402
|
-
* Claude Code's MCP client so KodaX resolves the same servers it does.
|
|
403
|
-
*/
|
|
404
|
-
interface WwwAuthenticateChallenge {
|
|
405
|
-
readonly scheme: string;
|
|
406
|
-
readonly params: Record<string, string>;
|
|
407
|
-
}
|
|
408
|
-
/** The RFC 9728 `resource_metadata` URL a 401 challenge points at, if any. */
|
|
409
|
-
declare function extractResourceMetadataUrl(header: string | undefined): string | undefined;
|
|
410
|
-
/**
|
|
411
|
-
* For a 403 `error="insufficient_scope"` challenge, the `scope` the server now
|
|
412
|
-
* requires (space-separated). Undefined when the challenge is not a step-up.
|
|
413
|
-
*/
|
|
414
|
-
declare function extractInsufficientScope(header: string | undefined): string | undefined;
|
|
415
|
-
interface ProtectedResourceMetadata {
|
|
416
|
-
readonly authorizationServers: string[];
|
|
417
|
-
readonly resource?: string;
|
|
418
|
-
readonly scopesSupported?: string[];
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Discover the protected-resource metadata for an MCP server URL. Prefers the
|
|
422
|
-
* `resource_metadata` URL from the 401 challenge; otherwise probes the
|
|
423
|
-
* path-specific then root `/.well-known/oauth-protected-resource`.
|
|
424
|
-
*/
|
|
425
|
-
declare function discoverProtectedResourceMetadata(options: {
|
|
426
|
-
serverUrl: string;
|
|
427
|
-
resourceMetadataUrl?: string;
|
|
428
|
-
fetchFn?: typeof fetch;
|
|
429
|
-
}): Promise<ProtectedResourceMetadata | undefined>;
|
|
430
|
-
interface AuthorizationServerMetadata {
|
|
431
|
-
readonly issuer?: string;
|
|
432
|
-
readonly authorizationEndpoint: string;
|
|
433
|
-
readonly tokenEndpoint: string;
|
|
434
|
-
readonly registrationEndpoint?: string;
|
|
435
|
-
readonly scopesSupported?: string[];
|
|
436
|
-
readonly codeChallengeMethodsSupported?: string[];
|
|
437
|
-
}
|
|
438
|
-
/** Discover an authorization server's endpoints. The first candidate returning
|
|
439
|
-
* both an authorization + token endpoint wins. */
|
|
440
|
-
declare function discoverAuthorizationServerMetadata(options: {
|
|
441
|
-
authorizationServerUrl: string;
|
|
442
|
-
fetchFn?: typeof fetch;
|
|
443
|
-
}): Promise<AuthorizationServerMetadata | undefined>;
|
|
444
|
-
/**
|
|
445
|
-
* End-to-end endpoint discovery: PRM → first authorization server → AS metadata.
|
|
446
|
-
* Returns the resolved endpoints plus the resource indicator (RFC 8707) and the
|
|
447
|
-
* scopes the resource advertises. Undefined when discovery fails at any step.
|
|
448
|
-
*/
|
|
449
|
-
interface DiscoveredOAuthEndpoints extends AuthorizationServerMetadata {
|
|
450
|
-
/** RFC 8707 resource indicator (the MCP server's canonical URL). */
|
|
451
|
-
readonly resource?: string;
|
|
452
|
-
/** Scopes from the protected-resource document, when the AS omits them. */
|
|
453
|
-
readonly resourceScopesSupported?: string[];
|
|
454
|
-
}
|
|
455
|
-
declare function discoverOAuthEndpoints(options: {
|
|
456
|
-
serverUrl: string;
|
|
457
|
-
resourceMetadataUrl?: string;
|
|
458
|
-
fetchFn?: typeof fetch;
|
|
459
|
-
}): Promise<DiscoveredOAuthEndpoints | undefined>;
|
|
460
|
-
|
|
461
|
-
interface OAuthToken {
|
|
462
|
-
readonly accessToken: string;
|
|
463
|
-
readonly refreshToken?: string;
|
|
464
|
-
readonly expiresAt?: number;
|
|
465
|
-
readonly tokenType?: string;
|
|
466
|
-
readonly scope?: string;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
/** A dynamically-registered (or pre-configured) OAuth client. */
|
|
470
|
-
interface OAuthClientInfo {
|
|
471
|
-
readonly clientId: string;
|
|
472
|
-
readonly clientSecret?: string;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* RFC 7591 Dynamic Client Registration. Registers a public client (PKCE, no
|
|
476
|
-
* secret) for the loopback redirect and returns the issued client_id.
|
|
477
|
-
*/
|
|
478
|
-
declare function registerOAuthClient(options: {
|
|
479
|
-
registrationEndpoint: string;
|
|
480
|
-
redirectUri: string;
|
|
481
|
-
clientName: string;
|
|
482
|
-
scope?: string;
|
|
483
|
-
fetchFn?: typeof fetch;
|
|
484
|
-
}): Promise<OAuthClientInfo>;
|
|
485
|
-
/**
|
|
486
|
-
* The host's consent gate for a login. Receives the authorization URL and must
|
|
487
|
-
* return true to proceed (the user will open it in their browser). Returning
|
|
488
|
-
* false aborts the login. KodaX never auto-opens the URL.
|
|
489
|
-
*/
|
|
490
|
-
type OAuthLoginConsent = (authorizationUrl: string) => Promise<boolean>;
|
|
491
|
-
interface PerformOAuthLoginOptions {
|
|
492
|
-
serverId: string;
|
|
493
|
-
/** The MCP server URL (resource) we are authenticating to. */
|
|
494
|
-
serverUrl: string;
|
|
495
|
-
/** resource_metadata URL from a 401 challenge, if one was seen. */
|
|
496
|
-
resourceMetadataUrl?: string;
|
|
497
|
-
/** A pre-configured client_id (skips dynamic registration). */
|
|
498
|
-
configuredClientId?: string;
|
|
499
|
-
/** Pre-configured scopes (override discovery). */
|
|
500
|
-
configuredScopes?: readonly string[];
|
|
501
|
-
/** For an insufficient_scope step-up: the elevated scope to request. */
|
|
502
|
-
stepUpScope?: string;
|
|
503
|
-
/** Host consent gate (anti-phishing) — receives the authorization URL. */
|
|
504
|
-
consent: OAuthLoginConsent;
|
|
505
|
-
/** Loopback callback port (defaults to {@link DEFAULT_OAUTH_REDIRECT_PORT}). */
|
|
506
|
-
redirectPort?: number;
|
|
507
|
-
fetchFn?: typeof fetch;
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Run the full interactive login and persist the resulting token. Returns the
|
|
511
|
-
* token, or undefined when discovery fails, no client can be obtained, or the
|
|
512
|
-
* user declines consent. Throws only on a hard protocol error (bad exchange).
|
|
513
|
-
*/
|
|
514
|
-
declare function performOAuthLogin(options: PerformOAuthLoginOptions): Promise<OAuthToken | undefined>;
|
|
515
|
-
/**
|
|
516
|
-
* Return a still-valid cached token for a server, or undefined. (Discovery-based
|
|
517
|
-
* refresh on expiry is driven by the connect flow, which knows the endpoints.)
|
|
518
|
-
*/
|
|
519
|
-
declare function loadValidToken(serverId: string): Promise<OAuthToken | undefined>;
|
|
520
|
-
|
|
521
351
|
/**
|
|
522
352
|
* McpManager — v0.7.42 (extends FEATURE_186 MCP popout surface).
|
|
523
353
|
*
|
|
@@ -697,5 +527,5 @@ declare class McpManager {
|
|
|
697
527
|
*/
|
|
698
528
|
declare function createMcpManager(servers: McpServersConfig | undefined, options?: McpProviderOptions): McpManager;
|
|
699
529
|
|
|
700
|
-
export {
|
|
701
|
-
export type {
|
|
530
|
+
export { normalizeMcpCapabilityId as A, parseMcpCapabilityId as B, searchMcpCatalog as C, McpCapabilityProvider as b, McpManager as h, McpServerRuntime as q, buildInitializeCapabilities as v, createMcpCapabilityId as w, createMcpManager as x, defaultMcpCacheDir as y, getMcpCachePaths as z };
|
|
531
|
+
export type { McpCapabilityDescriptor as M, McpCapabilityKind as a, McpCapabilityRisk as c, McpCatalogItem as d, McpElicitRequest as e, McpElicitResult as f, McpIcon as g, McpProviderOptions as i, McpReverseCapabilities as j, McpRoot as k, McpSamplingRequest as l, McpSamplingResult as m, McpServerCatalog as n, McpServerCatalogSnapshot as o, McpServerLogs as p, McpServerRuntimeDiagnostics as r, McpServerStatus as s, McpServerToolList as t, McpToolTaskSupport as u };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { a as McpServerConfig } from './config.d-CJy1WENT.js';
|
|
2
|
+
|
|
3
|
+
interface McpTransportEvents {
|
|
4
|
+
/** Called with a complete JSON-RPC message (raw JSON string). */
|
|
5
|
+
onMessage(raw: string): void;
|
|
6
|
+
onError(error: Error): void;
|
|
7
|
+
onClose(reason: string): void;
|
|
8
|
+
}
|
|
9
|
+
interface McpTransport {
|
|
10
|
+
open(events: McpTransportEvents): Promise<void>;
|
|
11
|
+
/** Send a JSON string. The transport handles framing. */
|
|
12
|
+
send(json: string): Promise<void>;
|
|
13
|
+
setProtocolVersion?(version: string | undefined): void;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
readonly connected: boolean;
|
|
16
|
+
/** Effective transport after auto-detection (diagnostics only). */
|
|
17
|
+
readonly resolvedTransport?: string;
|
|
18
|
+
}
|
|
19
|
+
declare class McpExpiredSessionError extends Error {
|
|
20
|
+
constructor();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* FEATURE_222 — the server demanded OAuth (401) or a stronger scope (403). It
|
|
24
|
+
* carries the `WWW-Authenticate` header so the connect flow can discover the
|
|
25
|
+
* authorization server (RFC 9728 pointer) or read the step-up scope.
|
|
26
|
+
*/
|
|
27
|
+
declare class McpAuthRequiredError extends Error {
|
|
28
|
+
readonly status: number;
|
|
29
|
+
readonly wwwAuthenticate?: string | undefined;
|
|
30
|
+
constructor(status: number, wwwAuthenticate?: string | undefined);
|
|
31
|
+
}
|
|
32
|
+
type StdioFraming = 'content-length' | 'ndjson';
|
|
33
|
+
interface McpTransportOptions {
|
|
34
|
+
stdioFraming?: StdioFraming;
|
|
35
|
+
httpResolvedTransport?: 'streamable-http' | 'sse';
|
|
36
|
+
}
|
|
37
|
+
declare function createMcpTransport(config: McpServerConfig, options?: McpTransportOptions): McpTransport;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* FEATURE_222 — MCP OAuth discovery (server→authorization-server resolution).
|
|
41
|
+
*
|
|
42
|
+
* The modern MCP auth flow does NOT require the user to hand-configure
|
|
43
|
+
* authorization/token endpoints. Instead the client discovers them at runtime:
|
|
44
|
+
*
|
|
45
|
+
* 401 WWW-Authenticate (resource_metadata=...) [RFC 9728 pointer]
|
|
46
|
+
* → GET /.well-known/oauth-protected-resource [RFC 9728 PRM]
|
|
47
|
+
* → authorization_servers[0]
|
|
48
|
+
* → GET /.well-known/oauth-authorization-server [RFC 8414]
|
|
49
|
+
* (fallback /.well-known/openid-configuration) [OIDC]
|
|
50
|
+
* → authorization_endpoint / token_endpoint / registration_endpoint
|
|
51
|
+
*
|
|
52
|
+
* This module is the pure-HTTP discovery layer (no PKCE, no browser, no token
|
|
53
|
+
* storage — those compose on top). The path-aware fallback ordering mirrors
|
|
54
|
+
* Claude Code's MCP client so KodaX resolves the same servers it does.
|
|
55
|
+
*/
|
|
56
|
+
interface WwwAuthenticateChallenge {
|
|
57
|
+
readonly scheme: string;
|
|
58
|
+
readonly params: Record<string, string>;
|
|
59
|
+
}
|
|
60
|
+
/** The RFC 9728 `resource_metadata` URL a 401 challenge points at, if any. */
|
|
61
|
+
declare function extractResourceMetadataUrl(header: string | undefined): string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* For a 403 `error="insufficient_scope"` challenge, the `scope` the server now
|
|
64
|
+
* requires (space-separated). Undefined when the challenge is not a step-up.
|
|
65
|
+
*/
|
|
66
|
+
declare function extractInsufficientScope(header: string | undefined): string | undefined;
|
|
67
|
+
interface ProtectedResourceMetadata {
|
|
68
|
+
readonly authorizationServers: string[];
|
|
69
|
+
readonly resource?: string;
|
|
70
|
+
readonly scopesSupported?: string[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Discover the protected-resource metadata for an MCP server URL. Prefers the
|
|
74
|
+
* `resource_metadata` URL from the 401 challenge; otherwise probes the
|
|
75
|
+
* path-specific then root `/.well-known/oauth-protected-resource`.
|
|
76
|
+
*/
|
|
77
|
+
declare function discoverProtectedResourceMetadata(options: {
|
|
78
|
+
serverUrl: string;
|
|
79
|
+
resourceMetadataUrl?: string;
|
|
80
|
+
fetchFn?: typeof fetch;
|
|
81
|
+
}): Promise<ProtectedResourceMetadata | undefined>;
|
|
82
|
+
interface AuthorizationServerMetadata {
|
|
83
|
+
readonly issuer?: string;
|
|
84
|
+
readonly authorizationEndpoint: string;
|
|
85
|
+
readonly tokenEndpoint: string;
|
|
86
|
+
readonly registrationEndpoint?: string;
|
|
87
|
+
readonly scopesSupported?: string[];
|
|
88
|
+
readonly codeChallengeMethodsSupported?: string[];
|
|
89
|
+
}
|
|
90
|
+
/** Discover an authorization server's endpoints. The first candidate returning
|
|
91
|
+
* both an authorization + token endpoint wins. */
|
|
92
|
+
declare function discoverAuthorizationServerMetadata(options: {
|
|
93
|
+
authorizationServerUrl: string;
|
|
94
|
+
fetchFn?: typeof fetch;
|
|
95
|
+
}): Promise<AuthorizationServerMetadata | undefined>;
|
|
96
|
+
/**
|
|
97
|
+
* End-to-end endpoint discovery: PRM → first authorization server → AS metadata.
|
|
98
|
+
* Returns the resolved endpoints plus the resource indicator (RFC 8707) and the
|
|
99
|
+
* scopes the resource advertises. Undefined when discovery fails at any step.
|
|
100
|
+
*/
|
|
101
|
+
interface DiscoveredOAuthEndpoints extends AuthorizationServerMetadata {
|
|
102
|
+
/** RFC 8707 resource indicator (the MCP server's canonical URL). */
|
|
103
|
+
readonly resource?: string;
|
|
104
|
+
/** Scopes from the protected-resource document, when the AS omits them. */
|
|
105
|
+
readonly resourceScopesSupported?: string[];
|
|
106
|
+
}
|
|
107
|
+
declare function discoverOAuthEndpoints(options: {
|
|
108
|
+
serverUrl: string;
|
|
109
|
+
resourceMetadataUrl?: string;
|
|
110
|
+
fetchFn?: typeof fetch;
|
|
111
|
+
}): Promise<DiscoveredOAuthEndpoints | undefined>;
|
|
112
|
+
|
|
113
|
+
interface OAuthToken {
|
|
114
|
+
readonly accessToken: string;
|
|
115
|
+
readonly refreshToken?: string;
|
|
116
|
+
readonly expiresAt?: number;
|
|
117
|
+
readonly tokenType?: string;
|
|
118
|
+
readonly scope?: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A dynamically-registered (or pre-configured) OAuth client. */
|
|
122
|
+
interface OAuthClientInfo {
|
|
123
|
+
readonly clientId: string;
|
|
124
|
+
readonly clientSecret?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* RFC 7591 Dynamic Client Registration. Registers a public client (PKCE, no
|
|
128
|
+
* secret) for the loopback redirect and returns the issued client_id.
|
|
129
|
+
*/
|
|
130
|
+
declare function registerOAuthClient(options: {
|
|
131
|
+
registrationEndpoint: string;
|
|
132
|
+
redirectUri: string;
|
|
133
|
+
clientName: string;
|
|
134
|
+
scope?: string;
|
|
135
|
+
fetchFn?: typeof fetch;
|
|
136
|
+
}): Promise<OAuthClientInfo>;
|
|
137
|
+
/**
|
|
138
|
+
* The host's consent gate for a login. Receives the authorization URL and must
|
|
139
|
+
* return true to proceed (the user will open it in their browser). Returning
|
|
140
|
+
* false aborts the login. KodaX never auto-opens the URL.
|
|
141
|
+
*/
|
|
142
|
+
type OAuthLoginConsent = (authorizationUrl: string) => Promise<boolean>;
|
|
143
|
+
interface PerformOAuthLoginOptions {
|
|
144
|
+
serverId: string;
|
|
145
|
+
/** The MCP server URL (resource) we are authenticating to. */
|
|
146
|
+
serverUrl: string;
|
|
147
|
+
/** resource_metadata URL from a 401 challenge, if one was seen. */
|
|
148
|
+
resourceMetadataUrl?: string;
|
|
149
|
+
/** A pre-configured client_id (skips dynamic registration). */
|
|
150
|
+
configuredClientId?: string;
|
|
151
|
+
/** Pre-configured scopes (override discovery). */
|
|
152
|
+
configuredScopes?: readonly string[];
|
|
153
|
+
/** For an insufficient_scope step-up: the elevated scope to request. */
|
|
154
|
+
stepUpScope?: string;
|
|
155
|
+
/** Host consent gate (anti-phishing) — receives the authorization URL. */
|
|
156
|
+
consent: OAuthLoginConsent;
|
|
157
|
+
/** Loopback callback port (defaults to {@link DEFAULT_OAUTH_REDIRECT_PORT}). */
|
|
158
|
+
redirectPort?: number;
|
|
159
|
+
fetchFn?: typeof fetch;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Run the full interactive login and persist the resulting token. Returns the
|
|
163
|
+
* token, or undefined when discovery fails, no client can be obtained, or the
|
|
164
|
+
* user declines consent. Throws only on a hard protocol error (bad exchange).
|
|
165
|
+
*/
|
|
166
|
+
declare function performOAuthLogin(options: PerformOAuthLoginOptions): Promise<OAuthToken | undefined>;
|
|
167
|
+
/**
|
|
168
|
+
* Return a still-valid cached token for a server, or undefined. (Discovery-based
|
|
169
|
+
* refresh on expiry is driven by the connect flow, which knows the endpoints.)
|
|
170
|
+
*/
|
|
171
|
+
declare function loadValidToken(serverId: string): Promise<OAuthToken | undefined>;
|
|
172
|
+
|
|
173
|
+
export { McpAuthRequiredError as M, McpExpiredSessionError as a, createMcpTransport as f, discoverAuthorizationServerMetadata as g, discoverOAuthEndpoints as h, discoverProtectedResourceMetadata as i, extractInsufficientScope as j, extractResourceMetadataUrl as k, loadValidToken as l, performOAuthLogin as p, registerOAuthClient as r };
|
|
174
|
+
export type { AuthorizationServerMetadata as A, DiscoveredOAuthEndpoints as D, OAuthClientInfo as O, PerformOAuthLoginOptions as P, WwwAuthenticateChallenge as W, McpTransport as b, McpTransportEvents as c, OAuthLoginConsent as d, ProtectedResourceMetadata as e };
|