agents 0.0.0-d7a460e → 0.0.0-da2bb57
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 +5 -3
- package/dist/ai-chat-agent.d.ts +86 -13
- package/dist/ai-chat-agent.js +340 -74
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/{ai-chat-v5-migration-DBHGW4Hv.js → ai-chat-v5-migration-BSiGZmYU.js} +1 -1
- package/dist/{ai-chat-v5-migration-DBHGW4Hv.js.map → ai-chat-v5-migration-BSiGZmYU.js.map} +1 -1
- package/dist/ai-chat-v5-migration.js +1 -1
- package/dist/ai-react.d.ts +14 -9
- package/dist/ai-react.js +164 -29
- package/dist/ai-react.js.map +1 -1
- package/dist/{ai-types-D5YoPrBZ.d.ts → ai-types-81H_-Uxh.d.ts} +15 -7
- package/dist/{ai-types-B3aQaFv3.js → ai-types-CrMqkwc_.js} +5 -1
- package/dist/ai-types-CrMqkwc_.js.map +1 -0
- package/dist/ai-types.d.ts +1 -1
- package/dist/ai-types.js +1 -1
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +27 -0
- package/dist/cli.js.map +1 -0
- package/dist/{client-BfiZ3HQd.js → client-B3SR12TQ.js} +2 -2
- package/dist/{client-BfiZ3HQd.js.map → client-B3SR12TQ.js.map} +1 -1
- package/dist/{client-CbWe9FBd.d.ts → client-BAQA84dr.d.ts} +2 -2
- package/dist/client-BZq9qau2.js +1093 -0
- package/dist/client-BZq9qau2.js.map +1 -0
- package/dist/client-DJhQNTez.d.ts +1528 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.js +2 -2
- package/dist/codemode/ai.js +5 -5
- package/dist/{do-oauth-client-provider-DGc5pP0l.d.ts → do-oauth-client-provider-C2CHH5x-.d.ts} +1 -1
- package/dist/{do-oauth-client-provider-CswoD5Lu.js → do-oauth-client-provider-CwqK5SXm.js} +2 -1
- package/dist/do-oauth-client-provider-CwqK5SXm.js.map +1 -0
- package/dist/{index-DhJCaDWd.d.ts → index-BUle9RiP.d.ts} +2 -2
- package/dist/{index-DFqsR7mb.d.ts → index-BvEldExU.d.ts} +53 -26
- package/dist/index.d.ts +6 -6
- package/dist/index.js +5 -5
- package/dist/mcp/client.d.ts +4 -4
- package/dist/mcp/client.js +2 -1
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/do-oauth-client-provider.js +1 -1
- package/dist/mcp/index.d.ts +75 -36
- package/dist/mcp/index.js +99 -21
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/x402.js +10 -6
- package/dist/mcp/x402.js.map +1 -1
- package/dist/{mcp-Dw5vDrY8.d.ts → mcp-BwPscEiF.d.ts} +1 -1
- package/dist/observability/index.d.ts +2 -2
- package/dist/observability/index.js +5 -5
- package/dist/{react-NCPvtyCY.d.ts → react-Ccc1FohP.d.ts} +33 -35
- package/dist/react.d.ts +9 -9
- package/dist/react.js +2 -2
- package/dist/react.js.map +1 -1
- package/dist/{serializable-CymX8ovI.d.ts → serializable-faDkMCai.d.ts} +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/{src-Dz0H9hSU.js → src-D_KKH_4c.js} +123 -139
- package/dist/src-D_KKH_4c.js.map +1 -0
- package/package.json +53 -38
- package/dist/ai-types-B3aQaFv3.js.map +0 -1
- package/dist/client-9Ld2_lnt.js +0 -786
- package/dist/client-9Ld2_lnt.js.map +0 -1
- package/dist/client-Csp_m13H.d.ts +0 -5315
- package/dist/do-oauth-client-provider-CswoD5Lu.js.map +0 -1
- package/dist/src-Dz0H9hSU.js.map +0 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./serializable-
|
|
1
|
+
import "./serializable-faDkMCai.js";
|
|
2
2
|
import {
|
|
3
3
|
a as agentFetch,
|
|
4
4
|
i as StreamOptions,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
o as camelCaseToKebabCase,
|
|
7
7
|
r as AgentClientOptions,
|
|
8
8
|
t as AgentClient
|
|
9
|
-
} from "./client-
|
|
9
|
+
} from "./client-BAQA84dr.js";
|
|
10
10
|
export {
|
|
11
11
|
AgentClient,
|
|
12
12
|
AgentClientFetchOptions,
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./ai-types-
|
|
2
|
-
import { n as agentFetch, r as camelCaseToKebabCase, t as AgentClient } from "./client-
|
|
1
|
+
import "./ai-types-CrMqkwc_.js";
|
|
2
|
+
import { n as agentFetch, r as camelCaseToKebabCase, t as AgentClient } from "./client-B3SR12TQ.js";
|
|
3
3
|
|
|
4
4
|
export { AgentClient, agentFetch, camelCaseToKebabCase };
|
package/dist/codemode/ai.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../ai-types-
|
|
2
|
-
import "../client-
|
|
3
|
-
import "../client-
|
|
4
|
-
import "../do-oauth-client-provider-
|
|
5
|
-
import { s as getAgentByName } from "../src-
|
|
1
|
+
import "../ai-types-CrMqkwc_.js";
|
|
2
|
+
import "../client-B3SR12TQ.js";
|
|
3
|
+
import "../client-BZq9qau2.js";
|
|
4
|
+
import "../do-oauth-client-provider-CwqK5SXm.js";
|
|
5
|
+
import { s as getAgentByName } from "../src-D_KKH_4c.js";
|
|
6
6
|
import { generateObject, tool } from "ai";
|
|
7
7
|
import { openai } from "@ai-sdk/openai";
|
|
8
8
|
import { z } from "zod/v3";
|
package/dist/{do-oauth-client-provider-DGc5pP0l.d.ts → do-oauth-client-provider-C2CHH5x-.d.ts}
RENAMED
|
@@ -52,4 +52,4 @@ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
|
|
|
52
52
|
}
|
|
53
53
|
//#endregion
|
|
54
54
|
export { DurableObjectOAuthClientProvider as n, AgentsOAuthProvider as t };
|
|
55
|
-
//# sourceMappingURL=do-oauth-client-provider-
|
|
55
|
+
//# sourceMappingURL=do-oauth-client-provider-C2CHH5x-.d.ts.map
|
|
@@ -6,6 +6,7 @@ var DurableObjectOAuthClientProvider = class {
|
|
|
6
6
|
this.storage = storage;
|
|
7
7
|
this.clientName = clientName;
|
|
8
8
|
this.baseRedirectUrl = baseRedirectUrl;
|
|
9
|
+
if (!storage) throw new Error("DurableObjectOAuthClientProvider requires a valid DurableObjectStorage instance");
|
|
9
10
|
}
|
|
10
11
|
get clientMetadata() {
|
|
11
12
|
return {
|
|
@@ -90,4 +91,4 @@ var DurableObjectOAuthClientProvider = class {
|
|
|
90
91
|
|
|
91
92
|
//#endregion
|
|
92
93
|
export { DurableObjectOAuthClientProvider as t };
|
|
93
|
-
//# sourceMappingURL=do-oauth-client-provider-
|
|
94
|
+
//# sourceMappingURL=do-oauth-client-provider-CwqK5SXm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"do-oauth-client-provider-CwqK5SXm.js","names":["storage: DurableObjectStorage","clientName: string","baseRedirectUrl: string"],"sources":["../src/mcp/do-oauth-client-provider.ts"],"sourcesContent":["import type { OAuthClientProvider } from \"@modelcontextprotocol/sdk/client/auth.js\";\nimport type {\n OAuthClientInformation,\n OAuthClientInformationFull,\n OAuthClientMetadata,\n OAuthTokens\n} from \"@modelcontextprotocol/sdk/shared/auth.js\";\nimport { nanoid } from \"nanoid\";\n\n// A slight extension to the standard OAuthClientProvider interface because `redirectToAuthorization` doesn't give us the interface we need\n// This allows us to track authentication for a specific server and associated dynamic client registration\nexport interface AgentsOAuthProvider extends OAuthClientProvider {\n authUrl: string | undefined;\n clientId: string | undefined;\n serverId: string | undefined;\n}\n\nexport class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {\n private _authUrl_: string | undefined;\n private _serverId_: string | undefined;\n private _clientId_: string | undefined;\n\n constructor(\n public storage: DurableObjectStorage,\n public clientName: string,\n public baseRedirectUrl: string\n ) {\n if (!storage) {\n throw new Error(\n \"DurableObjectOAuthClientProvider requires a valid DurableObjectStorage instance\"\n );\n }\n }\n\n get clientMetadata(): OAuthClientMetadata {\n return {\n client_name: this.clientName,\n client_uri: this.clientUri,\n grant_types: [\"authorization_code\", \"refresh_token\"],\n redirect_uris: [this.redirectUrl],\n response_types: [\"code\"],\n token_endpoint_auth_method: \"none\"\n };\n }\n\n get clientUri() {\n return new URL(this.redirectUrl).origin;\n }\n\n get redirectUrl() {\n return `${this.baseRedirectUrl}/${this.serverId}`;\n }\n\n get clientId() {\n if (!this._clientId_) {\n throw new Error(\"Trying to access clientId before it was set\");\n }\n return this._clientId_;\n }\n\n set clientId(clientId_: string) {\n this._clientId_ = clientId_;\n }\n\n get serverId() {\n if (!this._serverId_) {\n throw new Error(\"Trying to access serverId before it was set\");\n }\n return this._serverId_;\n }\n\n set serverId(serverId_: string) {\n this._serverId_ = serverId_;\n }\n\n keyPrefix(clientId: string) {\n return `/${this.clientName}/${this.serverId}/${clientId}`;\n }\n\n clientInfoKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/client_info/`;\n }\n\n async clientInformation(): Promise<OAuthClientInformation | undefined> {\n if (!this._clientId_) {\n return undefined;\n }\n return (\n (await this.storage.get<OAuthClientInformation>(\n this.clientInfoKey(this.clientId)\n )) ?? undefined\n );\n }\n\n async saveClientInformation(\n clientInformation: OAuthClientInformationFull\n ): Promise<void> {\n await this.storage.put(\n this.clientInfoKey(clientInformation.client_id),\n clientInformation\n );\n this.clientId = clientInformation.client_id;\n }\n\n tokenKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/token`;\n }\n\n async tokens(): Promise<OAuthTokens | undefined> {\n if (!this._clientId_) {\n return undefined;\n }\n return (\n (await this.storage.get<OAuthTokens>(this.tokenKey(this.clientId))) ??\n undefined\n );\n }\n\n async saveTokens(tokens: OAuthTokens): Promise<void> {\n await this.storage.put(this.tokenKey(this.clientId), tokens);\n }\n\n get authUrl() {\n return this._authUrl_;\n }\n\n /**\n * Because this operates on the server side (but we need browser auth), we send this url back to the user\n * and require user interact to initiate the redirect flow\n */\n async redirectToAuthorization(authUrl: URL): Promise<void> {\n // Generate secure random token for state parameter\n const stateToken = nanoid();\n authUrl.searchParams.set(\"state\", stateToken);\n this._authUrl_ = authUrl.toString();\n }\n\n codeVerifierKey(clientId: string) {\n return `${this.keyPrefix(clientId)}/code_verifier`;\n }\n\n async saveCodeVerifier(verifier: string): Promise<void> {\n const key = this.codeVerifierKey(this.clientId);\n\n // Don't overwrite existing verifier to preserve first PKCE verifier\n const existing = await this.storage.get<string>(key);\n if (existing) {\n return;\n }\n\n await this.storage.put(key, verifier);\n }\n\n async codeVerifier(): Promise<string> {\n const codeVerifier = await this.storage.get<string>(\n this.codeVerifierKey(this.clientId)\n );\n if (!codeVerifier) {\n throw new Error(\"No code verifier found\");\n }\n return codeVerifier;\n }\n}\n"],"mappings":";;;AAiBA,IAAa,mCAAb,MAA6E;CAK3E,YACE,AAAOA,SACP,AAAOC,YACP,AAAOC,iBACP;EAHO;EACA;EACA;AAEP,MAAI,CAAC,QACH,OAAM,IAAI,MACR,kFACD;;CAIL,IAAI,iBAAsC;AACxC,SAAO;GACL,aAAa,KAAK;GAClB,YAAY,KAAK;GACjB,aAAa,CAAC,sBAAsB,gBAAgB;GACpD,eAAe,CAAC,KAAK,YAAY;GACjC,gBAAgB,CAAC,OAAO;GACxB,4BAA4B;GAC7B;;CAGH,IAAI,YAAY;AACd,SAAO,IAAI,IAAI,KAAK,YAAY,CAAC;;CAGnC,IAAI,cAAc;AAChB,SAAO,GAAG,KAAK,gBAAgB,GAAG,KAAK;;CAGzC,IAAI,WAAW;AACb,MAAI,CAAC,KAAK,WACR,OAAM,IAAI,MAAM,8CAA8C;AAEhE,SAAO,KAAK;;CAGd,IAAI,SAAS,WAAmB;AAC9B,OAAK,aAAa;;CAGpB,IAAI,WAAW;AACb,MAAI,CAAC,KAAK,WACR,OAAM,IAAI,MAAM,8CAA8C;AAEhE,SAAO,KAAK;;CAGd,IAAI,SAAS,WAAmB;AAC9B,OAAK,aAAa;;CAGpB,UAAU,UAAkB;AAC1B,SAAO,IAAI,KAAK,WAAW,GAAG,KAAK,SAAS,GAAG;;CAGjD,cAAc,UAAkB;AAC9B,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,oBAAiE;AACrE,MAAI,CAAC,KAAK,WACR;AAEF,SACG,MAAM,KAAK,QAAQ,IAClB,KAAK,cAAc,KAAK,SAAS,CAClC,IAAK;;CAIV,MAAM,sBACJ,mBACe;AACf,QAAM,KAAK,QAAQ,IACjB,KAAK,cAAc,kBAAkB,UAAU,EAC/C,kBACD;AACD,OAAK,WAAW,kBAAkB;;CAGpC,SAAS,UAAkB;AACzB,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,SAA2C;AAC/C,MAAI,CAAC,KAAK,WACR;AAEF,SACG,MAAM,KAAK,QAAQ,IAAiB,KAAK,SAAS,KAAK,SAAS,CAAC,IAClE;;CAIJ,MAAM,WAAW,QAAoC;AACnD,QAAM,KAAK,QAAQ,IAAI,KAAK,SAAS,KAAK,SAAS,EAAE,OAAO;;CAG9D,IAAI,UAAU;AACZ,SAAO,KAAK;;;;;;CAOd,MAAM,wBAAwB,SAA6B;EAEzD,MAAM,aAAa,QAAQ;AAC3B,UAAQ,aAAa,IAAI,SAAS,WAAW;AAC7C,OAAK,YAAY,QAAQ,UAAU;;CAGrC,gBAAgB,UAAkB;AAChC,SAAO,GAAG,KAAK,UAAU,SAAS,CAAC;;CAGrC,MAAM,iBAAiB,UAAiC;EACtD,MAAM,MAAM,KAAK,gBAAgB,KAAK,SAAS;AAI/C,MADiB,MAAM,KAAK,QAAQ,IAAY,IAAI,CAElD;AAGF,QAAM,KAAK,QAAQ,IAAI,KAAK,SAAS;;CAGvC,MAAM,eAAgC;EACpC,MAAM,eAAe,MAAM,KAAK,QAAQ,IACtC,KAAK,gBAAgB,KAAK,SAAS,CACpC;AACD,MAAI,CAAC,aACH,OAAM,IAAI,MAAM,yBAAyB;AAE3C,SAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as BaseEvent, t as MCPObservabilityEvent } from "./mcp-
|
|
1
|
+
import { n as BaseEvent, t as MCPObservabilityEvent } from "./mcp-BwPscEiF.js";
|
|
2
2
|
|
|
3
3
|
//#region src/observability/agent.d.ts
|
|
4
4
|
|
|
@@ -55,4 +55,4 @@ export {
|
|
|
55
55
|
genericObservability as r,
|
|
56
56
|
Observability as t
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=index-
|
|
58
|
+
//# sourceMappingURL=index-BUle9RiP.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
h as TransportType,
|
|
3
3
|
t as MCPClientManager,
|
|
4
|
-
u as
|
|
5
|
-
} from "./client-
|
|
6
|
-
import { t as Observability } from "./index-
|
|
7
|
-
import { n as MessageType } from "./ai-types-
|
|
4
|
+
u as MCPConnectionState
|
|
5
|
+
} from "./client-DJhQNTez.js";
|
|
6
|
+
import { t as Observability } from "./index-BUle9RiP.js";
|
|
7
|
+
import { n as MessageType } from "./ai-types-81H_-Uxh.js";
|
|
8
8
|
import {
|
|
9
9
|
Connection,
|
|
10
10
|
Connection as Connection$1,
|
|
@@ -87,9 +87,9 @@ declare function callable(
|
|
|
87
87
|
* @param metadata Optional metadata about the callable method
|
|
88
88
|
*/
|
|
89
89
|
declare const unstable_callable: (metadata?: CallableMetadata) => void;
|
|
90
|
-
type QueueItem<T
|
|
90
|
+
type QueueItem<T = string> = {
|
|
91
91
|
id: string;
|
|
92
|
-
payload: T
|
|
92
|
+
payload: T;
|
|
93
93
|
callback: keyof Agent<unknown>;
|
|
94
94
|
created_at: number;
|
|
95
95
|
};
|
|
@@ -97,13 +97,13 @@ type QueueItem<T$1 = string> = {
|
|
|
97
97
|
* Represents a scheduled task within an Agent
|
|
98
98
|
* @template T Type of the payload data
|
|
99
99
|
*/
|
|
100
|
-
type Schedule<T
|
|
100
|
+
type Schedule<T = string> = {
|
|
101
101
|
/** Unique identifier for the schedule */
|
|
102
102
|
id: string;
|
|
103
103
|
/** Name of the method to be called */
|
|
104
104
|
callback: string;
|
|
105
105
|
/** Data to be passed to the callback */
|
|
106
|
-
payload: T
|
|
106
|
+
payload: T;
|
|
107
107
|
} & (
|
|
108
108
|
| {
|
|
109
109
|
/** Type of schedule for one-time execution at a specific time */
|
|
@@ -139,9 +139,15 @@ type MCPServersState = {
|
|
|
139
139
|
servers: {
|
|
140
140
|
[id: string]: MCPServer;
|
|
141
141
|
};
|
|
142
|
-
tools: Tool
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
tools: (Tool & {
|
|
143
|
+
serverId: string;
|
|
144
|
+
})[];
|
|
145
|
+
prompts: (Prompt & {
|
|
146
|
+
serverId: string;
|
|
147
|
+
})[];
|
|
148
|
+
resources: (Resource & {
|
|
149
|
+
serverId: string;
|
|
150
|
+
})[];
|
|
145
151
|
};
|
|
146
152
|
type MCPServer = {
|
|
147
153
|
name: string;
|
|
@@ -152,9 +158,9 @@ type MCPServer = {
|
|
|
152
158
|
capabilities: ServerCapabilities | null;
|
|
153
159
|
};
|
|
154
160
|
declare function getCurrentAgent<
|
|
155
|
-
T
|
|
161
|
+
T extends Agent<unknown, unknown> = Agent<unknown, unknown>
|
|
156
162
|
>(): {
|
|
157
|
-
agent: T
|
|
163
|
+
agent: T | undefined;
|
|
158
164
|
connection: Connection | undefined;
|
|
159
165
|
request: Request | undefined;
|
|
160
166
|
email: AgentEmail | undefined;
|
|
@@ -171,7 +177,7 @@ declare class Agent<
|
|
|
171
177
|
> extends Server<Env, Props> {
|
|
172
178
|
private _state;
|
|
173
179
|
private _disposables;
|
|
174
|
-
private
|
|
180
|
+
private _destroyed;
|
|
175
181
|
private _ParentClass;
|
|
176
182
|
readonly mcp: MCPClientManager;
|
|
177
183
|
/**
|
|
@@ -347,7 +353,6 @@ declare class Agent<
|
|
|
347
353
|
* @returns A map of method names to their metadata
|
|
348
354
|
*/
|
|
349
355
|
private _isCallable;
|
|
350
|
-
private _ensureMcpStateRestored;
|
|
351
356
|
/**
|
|
352
357
|
* Connect to a new MCP Server
|
|
353
358
|
*
|
|
@@ -356,7 +361,8 @@ declare class Agent<
|
|
|
356
361
|
* @param callbackHost Base host for the agent, used for the redirect URI. If not provided, will be derived from the current request.
|
|
357
362
|
* @param agentsPrefix agents routing prefix if not using `agents`
|
|
358
363
|
* @param options MCP client and transport options
|
|
359
|
-
* @returns authUrl
|
|
364
|
+
* @returns Server id and state - either "authenticating" with authUrl, or "ready"
|
|
365
|
+
* @throws If connection or discovery fails
|
|
360
366
|
*/
|
|
361
367
|
addMcpServer(
|
|
362
368
|
serverName: string,
|
|
@@ -370,14 +376,35 @@ declare class Agent<
|
|
|
370
376
|
type?: TransportType;
|
|
371
377
|
};
|
|
372
378
|
}
|
|
373
|
-
): Promise<
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
379
|
+
): Promise<
|
|
380
|
+
| {
|
|
381
|
+
id: string;
|
|
382
|
+
state: typeof MCPConnectionState.AUTHENTICATING;
|
|
383
|
+
authUrl: string;
|
|
384
|
+
}
|
|
385
|
+
| {
|
|
386
|
+
id: string;
|
|
387
|
+
state: typeof MCPConnectionState.READY;
|
|
388
|
+
authUrl?: undefined;
|
|
389
|
+
}
|
|
390
|
+
>;
|
|
378
391
|
removeMcpServer(id: string): Promise<void>;
|
|
379
392
|
getMcpServers(): MCPServersState;
|
|
380
393
|
private broadcastMcpServers;
|
|
394
|
+
/**
|
|
395
|
+
* Handle MCP OAuth callback request if it's an OAuth callback.
|
|
396
|
+
*
|
|
397
|
+
* This method encapsulates the entire OAuth callback flow:
|
|
398
|
+
* 1. Checks if the request is an MCP OAuth callback
|
|
399
|
+
* 2. Processes the OAuth code exchange
|
|
400
|
+
* 3. Establishes the connection if successful
|
|
401
|
+
* 4. Broadcasts MCP server state updates
|
|
402
|
+
* 5. Returns the appropriate HTTP response
|
|
403
|
+
*
|
|
404
|
+
* @param request The incoming HTTP request
|
|
405
|
+
* @returns Response if this was an OAuth callback, null otherwise
|
|
406
|
+
*/
|
|
407
|
+
private handleMcpOAuthCallback;
|
|
381
408
|
/**
|
|
382
409
|
* Handle OAuth callback response using MCPClientManager configuration
|
|
383
410
|
* @param result OAuth callback result
|
|
@@ -494,17 +521,17 @@ type EmailSendOptions = {
|
|
|
494
521
|
*/
|
|
495
522
|
declare function getAgentByName<
|
|
496
523
|
Env,
|
|
497
|
-
T
|
|
524
|
+
T extends Agent<Env>,
|
|
498
525
|
Props extends Record<string, unknown> = Record<string, unknown>
|
|
499
526
|
>(
|
|
500
|
-
namespace: AgentNamespace<T
|
|
527
|
+
namespace: AgentNamespace<T>,
|
|
501
528
|
name: string,
|
|
502
529
|
options?: {
|
|
503
530
|
jurisdiction?: DurableObjectJurisdiction;
|
|
504
531
|
locationHint?: DurableObjectLocationHint;
|
|
505
532
|
props?: Props;
|
|
506
533
|
}
|
|
507
|
-
): Promise<DurableObjectStub<T
|
|
534
|
+
): Promise<DurableObjectStub<T>>;
|
|
508
535
|
/**
|
|
509
536
|
* A wrapper for streaming responses in callable methods
|
|
510
537
|
*/
|
|
@@ -557,4 +584,4 @@ export {
|
|
|
557
584
|
WSMessage as x,
|
|
558
585
|
StateUpdateMessage as y
|
|
559
586
|
};
|
|
560
|
-
//# sourceMappingURL=index-
|
|
587
|
+
//# sourceMappingURL=index-BvEldExU.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./mcp-
|
|
3
|
-
import "./do-oauth-client-provider-
|
|
4
|
-
import "./index-
|
|
5
|
-
import "./ai-types-
|
|
1
|
+
import { h as TransportType } from "./client-DJhQNTez.js";
|
|
2
|
+
import "./mcp-BwPscEiF.js";
|
|
3
|
+
import "./do-oauth-client-provider-C2CHH5x-.js";
|
|
4
|
+
import "./index-BUle9RiP.js";
|
|
5
|
+
import "./ai-types-81H_-Uxh.js";
|
|
6
6
|
import {
|
|
7
7
|
A as unstable_callable,
|
|
8
8
|
C as createAddressBasedEmailResolver,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
w as createCatchAllEmailResolver,
|
|
35
35
|
x as WSMessage,
|
|
36
36
|
y as StateUpdateMessage
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-BvEldExU.js";
|
|
38
38
|
export {
|
|
39
39
|
Agent,
|
|
40
40
|
AgentContext,
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./ai-types-
|
|
2
|
-
import "./client-
|
|
3
|
-
import "./client-
|
|
4
|
-
import "./do-oauth-client-provider-
|
|
5
|
-
import { a as createCatchAllEmailResolver, c as getCurrentAgent, d as unstable_callable, i as createAddressBasedEmailResolver, l as routeAgentEmail, n as StreamingResponse, o as createHeaderBasedEmailResolver, r as callable, s as getAgentByName, t as Agent, u as routeAgentRequest } from "./src-
|
|
1
|
+
import "./ai-types-CrMqkwc_.js";
|
|
2
|
+
import "./client-B3SR12TQ.js";
|
|
3
|
+
import "./client-BZq9qau2.js";
|
|
4
|
+
import "./do-oauth-client-provider-CwqK5SXm.js";
|
|
5
|
+
import { a as createCatchAllEmailResolver, c as getCurrentAgent, d as unstable_callable, i as createAddressBasedEmailResolver, l as routeAgentEmail, n as StreamingResponse, o as createHeaderBasedEmailResolver, r as callable, s as getAgentByName, t as Agent, u as routeAgentRequest } from "./src-D_KKH_4c.js";
|
|
6
6
|
|
|
7
7
|
export { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable };
|
package/dist/mcp/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as getNamespacedData, n as
|
|
2
|
-
import "../mcp-
|
|
3
|
-
import "../do-oauth-client-provider-
|
|
4
|
-
export { MCPClientManager, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, getNamespacedData };
|
|
1
|
+
import { a as MCPConnectionResult, c as RegisterServerOptions, i as MCPClientOAuthResult, l as getNamespacedData, n as MCPClientManagerOptions, o as MCPDiscoverResult, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions, t as MCPClientManager } from "../client-DJhQNTez.js";
|
|
2
|
+
import "../mcp-BwPscEiF.js";
|
|
3
|
+
import "../do-oauth-client-provider-C2CHH5x-.js";
|
|
4
|
+
export { MCPClientManager, MCPClientManagerOptions, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MCPConnectionResult, MCPDiscoverResult, MCPServerOptions, RegisterServerOptions, getNamespacedData };
|
package/dist/mcp/client.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { n as getNamespacedData, t as MCPClientManager } from "../client-
|
|
1
|
+
import { n as getNamespacedData, t as MCPClientManager } from "../client-BZq9qau2.js";
|
|
2
|
+
import "../do-oauth-client-provider-CwqK5SXm.js";
|
|
2
3
|
|
|
3
4
|
export { MCPClientManager, getNamespacedData };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider-
|
|
1
|
+
import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider-C2CHH5x-.js";
|
|
2
2
|
export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,23 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../mcp-
|
|
3
|
-
import "../do-oauth-client-provider-
|
|
4
|
-
import "../index-
|
|
5
|
-
import "../ai-types-
|
|
6
|
-
import { c as ConnectionContext, s as Connection, t as Agent } from "../index-
|
|
7
|
-
import {
|
|
1
|
+
import { a as MCPConnectionResult, d as BaseTransportType, f as CORSOptions, i as MCPClientOAuthResult, m as ServeOptions, o as MCPDiscoverResult, p as MaybePromise, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions } from "../client-DJhQNTez.js";
|
|
2
|
+
import "../mcp-BwPscEiF.js";
|
|
3
|
+
import "../do-oauth-client-provider-C2CHH5x-.js";
|
|
4
|
+
import "../index-BUle9RiP.js";
|
|
5
|
+
import "../ai-types-81H_-Uxh.js";
|
|
6
|
+
import { c as ConnectionContext, s as Connection, t as Agent } from "../index-BvEldExU.js";
|
|
7
|
+
import { SSEClientTransport, SSEClientTransportOptions } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
8
|
+
import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
9
|
+
import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage, MessageExtraInfo } from "@modelcontextprotocol/sdk/types.js";
|
|
8
10
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
9
11
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
10
|
-
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
12
|
+
import { Transport, TransportSendOptions } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
11
13
|
|
|
14
|
+
//#region src/mcp/client-transports.d.ts
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use SSEClientTransport from @modelcontextprotocol/sdk/client/sse.js instead. This alias will be removed in the next major version.
|
|
17
|
+
*/
|
|
18
|
+
declare class SSEEdgeClientTransport extends SSEClientTransport {
|
|
19
|
+
constructor(url: URL, options: SSEClientTransportOptions);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use StreamableHTTPClientTransport from @modelcontextprotocol/sdk/client/streamableHttp.js instead. This alias will be removed in the next major version.
|
|
23
|
+
*/
|
|
24
|
+
declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTransport {
|
|
25
|
+
constructor(url: URL, options: StreamableHTTPClientTransportOptions);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
12
28
|
//#region src/mcp/worker-transport.d.ts
|
|
29
|
+
declare const SUPPORTED_PROTOCOL_VERSIONS: readonly ["2025-03-26", "2025-06-18"];
|
|
30
|
+
type ProtocolVersion = (typeof SUPPORTED_PROTOCOL_VERSIONS)[number];
|
|
31
|
+
interface MCPStorageApi {
|
|
32
|
+
get(): Promise<TransportState | undefined> | TransportState | undefined;
|
|
33
|
+
set(state: TransportState): Promise<void> | void;
|
|
34
|
+
}
|
|
35
|
+
interface TransportState {
|
|
36
|
+
sessionId?: string;
|
|
37
|
+
initialized: boolean;
|
|
38
|
+
protocolVersion?: ProtocolVersion;
|
|
39
|
+
}
|
|
13
40
|
interface WorkerTransportOptions {
|
|
14
41
|
sessionIdGenerator?: () => string;
|
|
42
|
+
/**
|
|
43
|
+
* Enable traditional Request/Response mode, this will disable streaming.
|
|
44
|
+
*/
|
|
15
45
|
enableJsonResponse?: boolean;
|
|
16
46
|
onsessioninitialized?: (sessionId: string) => void;
|
|
17
47
|
corsOptions?: CORSOptions;
|
|
48
|
+
/**
|
|
49
|
+
* Optional storage api for persisting transport state.
|
|
50
|
+
* Use this to store session state in Durable Object/Agent storage
|
|
51
|
+
* so it survives hibernation/restart.
|
|
52
|
+
*/
|
|
53
|
+
storage?: MCPStorageApi;
|
|
18
54
|
}
|
|
19
55
|
declare class WorkerTransport implements Transport {
|
|
20
|
-
|
|
56
|
+
started: boolean;
|
|
21
57
|
private initialized;
|
|
22
58
|
private sessionIdGenerator?;
|
|
23
59
|
private enableJsonResponse;
|
|
@@ -28,11 +64,22 @@ declare class WorkerTransport implements Transport {
|
|
|
28
64
|
private requestResponseMap;
|
|
29
65
|
private corsOptions?;
|
|
30
66
|
private protocolVersion?;
|
|
67
|
+
private storage?;
|
|
68
|
+
private stateRestored;
|
|
31
69
|
sessionId?: string;
|
|
32
70
|
onclose?: () => void;
|
|
33
71
|
onerror?: (error: Error) => void;
|
|
34
|
-
onmessage?: (message: JSONRPCMessage) => void;
|
|
72
|
+
onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
|
|
35
73
|
constructor(options?: WorkerTransportOptions);
|
|
74
|
+
/**
|
|
75
|
+
* Restore transport state from persistent storage.
|
|
76
|
+
* This is automatically called on start.
|
|
77
|
+
*/
|
|
78
|
+
private restoreState;
|
|
79
|
+
/**
|
|
80
|
+
* Persist current transport state to storage.
|
|
81
|
+
*/
|
|
82
|
+
private saveState;
|
|
36
83
|
start(): Promise<void>;
|
|
37
84
|
private validateProtocolVersion;
|
|
38
85
|
private getHeaders;
|
|
@@ -44,8 +91,14 @@ declare class WorkerTransport implements Transport {
|
|
|
44
91
|
private handleUnsupportedRequest;
|
|
45
92
|
private validateSession;
|
|
46
93
|
close(): Promise<void>;
|
|
47
|
-
send(message: JSONRPCMessage): Promise<void>;
|
|
94
|
+
send(message: JSONRPCMessage, options?: TransportSendOptions): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/mcp/auth-context.d.ts
|
|
98
|
+
interface McpAuthContext {
|
|
99
|
+
props: Record<string, unknown>;
|
|
48
100
|
}
|
|
101
|
+
declare function getMcpAuthContext(): McpAuthContext | undefined;
|
|
49
102
|
//#endregion
|
|
50
103
|
//#region src/mcp/handler.d.ts
|
|
51
104
|
interface CreateMcpHandlerOptions extends WorkerTransportOptions {
|
|
@@ -56,36 +109,22 @@ interface CreateMcpHandlerOptions extends WorkerTransportOptions {
|
|
|
56
109
|
*/
|
|
57
110
|
route?: string;
|
|
58
111
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* CORS headers to all responses.
|
|
62
|
-
*
|
|
63
|
-
* Default values are:
|
|
64
|
-
* - origin: "*"
|
|
65
|
-
* - headers: "Content-Type, Accept, Authorization, mcp-session-id, MCP-Protocol-Version"
|
|
66
|
-
* - methods: "GET, POST, DELETE, OPTIONS"
|
|
67
|
-
* - exposeHeaders: "mcp-session-id"
|
|
68
|
-
* - maxAge: 86400
|
|
69
|
-
*
|
|
70
|
-
* Provided options will overwrite the defaults.
|
|
112
|
+
* An optional auth context to use for handling MCP requests.
|
|
113
|
+
* If not provided, the handler will look for props in the execution context.
|
|
71
114
|
*/
|
|
72
|
-
|
|
115
|
+
authContext?: McpAuthContext;
|
|
116
|
+
/**
|
|
117
|
+
* An optional transport to use for handling MCP requests.
|
|
118
|
+
* If not provided, a WorkerTransport will be created with the provided WorkerTransportOptions.
|
|
119
|
+
*/
|
|
120
|
+
transport?: WorkerTransport;
|
|
73
121
|
}
|
|
74
|
-
type OAuthExecutionContext = ExecutionContext & {
|
|
75
|
-
props?: Record<string, unknown>;
|
|
76
|
-
};
|
|
77
122
|
declare function createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
78
123
|
/**
|
|
79
124
|
* @deprecated This has been renamed to createMcpHandler, and experimental_createMcpHandler will be removed in the next major version
|
|
80
125
|
*/
|
|
81
126
|
declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
82
127
|
//#endregion
|
|
83
|
-
//#region src/mcp/auth-context.d.ts
|
|
84
|
-
interface McpAuthContext {
|
|
85
|
-
props: Record<string, unknown>;
|
|
86
|
-
}
|
|
87
|
-
declare function getMcpAuthContext(): McpAuthContext | undefined;
|
|
88
|
-
//#endregion
|
|
89
128
|
//#region src/mcp/index.d.ts
|
|
90
129
|
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
|
|
91
130
|
private _transport?;
|
|
@@ -105,7 +144,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
105
144
|
*/
|
|
106
145
|
getSessionId(): string;
|
|
107
146
|
/** Get the unique WebSocket. SSE transport only. */
|
|
108
|
-
|
|
147
|
+
getWebSocket(): Connection<unknown> | null;
|
|
109
148
|
/** Returns a new transport matching the type of the Agent. */
|
|
110
149
|
private initTransport;
|
|
111
150
|
/** Update and store the props */
|
|
@@ -118,7 +157,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
118
157
|
request: req
|
|
119
158
|
}: ConnectionContext): Promise<void>;
|
|
120
159
|
/** Handles MCP Messages for the legacy SSE transport. */
|
|
121
|
-
onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
|
|
160
|
+
onSSEMcpMessage(_sessionId: string, messageBody: unknown, extraInfo?: MessageExtraInfo): Promise<Error | null>;
|
|
122
161
|
/** Elicit user input with a message and schema */
|
|
123
162
|
elicitInput(params: {
|
|
124
163
|
message: string;
|
|
@@ -150,5 +189,5 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
150
189
|
};
|
|
151
190
|
}
|
|
152
191
|
//#endregion
|
|
153
|
-
export { type CreateMcpHandlerOptions, type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult,
|
|
192
|
+
export { type CreateMcpHandlerOptions, type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, type MCPConnectionResult, type MCPDiscoverResult, type MCPServerOptions, McpAgent, type McpAuthContext, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, type TransportState, WorkerTransport, type WorkerTransportOptions, createMcpHandler, experimental_createMcpHandler, getMcpAuthContext };
|
|
154
193
|
//# sourceMappingURL=index.d.ts.map
|