agents 0.0.0-ccbea72 → 0.0.0-cccbd0f
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-9Ld2_lnt.js → client-BZ-xTxF5.js} +239 -124
- package/dist/client-BZ-xTxF5.js.map +1 -0
- package/dist/client-ctTw3KHG.d.ts +1440 -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-CswoD5Lu.js → do-oauth-client-provider-Cs9QpXYp.js} +2 -2
- package/dist/do-oauth-client-provider-Cs9QpXYp.js.map +1 -0
- package/dist/do-oauth-client-provider-UhQDpDb8.d.ts +134 -0
- package/dist/{index-DhJCaDWd.d.ts → index-BUle9RiP.d.ts} +2 -2
- package/dist/{index-D6iosdF4.d.ts → index-D2dnUH0r.d.ts} +40 -22
- 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 +88 -24
- package/dist/mcp/index.js +293 -81
- 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-YzfC33jB.d.ts → react-B_ENAdCe.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-C6rC6ZpH.js} +188 -140
- package/dist/src-C6rC6ZpH.js.map +1 -0
- package/package.json +53 -38
- package/dist/ai-types-B3aQaFv3.js.map +0 -1
- package/dist/client-9Ld2_lnt.js.map +0 -1
- package/dist/client-BmMRlvlM.d.ts +0 -5313
- package/dist/do-oauth-client-provider-CswoD5Lu.js.map +0 -1
- package/dist/do-oauth-client-provider-DGc5pP0l.d.ts +0 -55
- 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-BZ-xTxF5.js";
|
|
4
|
+
import "../do-oauth-client-provider-Cs9QpXYp.js";
|
|
5
|
+
import { s as getAgentByName } from "../src-C6rC6ZpH.js";
|
|
6
6
|
import { generateObject, tool } from "ai";
|
|
7
7
|
import { openai } from "@ai-sdk/openai";
|
|
8
8
|
import { z } from "zod/v3";
|
|
@@ -68,7 +68,7 @@ var DurableObjectOAuthClientProvider = class {
|
|
|
68
68
|
* Because this operates on the server side (but we need browser auth), we send this url back to the user
|
|
69
69
|
* and require user interact to initiate the redirect flow
|
|
70
70
|
*/
|
|
71
|
-
|
|
71
|
+
redirectToAuthorization(authUrl) {
|
|
72
72
|
const stateToken = nanoid();
|
|
73
73
|
authUrl.searchParams.set("state", stateToken);
|
|
74
74
|
this._authUrl_ = authUrl.toString();
|
|
@@ -90,4 +90,4 @@ var DurableObjectOAuthClientProvider = class {
|
|
|
90
90
|
|
|
91
91
|
//#endregion
|
|
92
92
|
export { DurableObjectOAuthClientProvider as t };
|
|
93
|
-
//# sourceMappingURL=do-oauth-client-provider-
|
|
93
|
+
//# sourceMappingURL=do-oauth-client-provider-Cs9QpXYp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"do-oauth-client-provider-Cs9QpXYp.js","names":["storage: OAuthClientStorage","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\";\nimport type { OAuthClientStorage } from \"./client-storage\";\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: OAuthClientStorage,\n public clientName: string,\n public baseRedirectUrl: string\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() {\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(clientInformation: OAuthClientInformationFull) {\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() {\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) {\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 redirectToAuthorization(authUrl: URL) {\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) {\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() {\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":";;;AAkBA,IAAa,mCAAb,MAA6E;CAK3E,YACE,AAAOA,SACP,AAAOC,YACP,AAAOC,iBACP;EAHO;EACA;EACA;;CAGT,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,oBAAoB;AACxB,MAAI,CAAC,KAAK,WACR;AAEF,SACG,MAAM,KAAK,QAAQ,IAClB,KAAK,cAAc,KAAK,SAAS,CAClC,IAAK;;CAIV,MAAM,sBAAsB,mBAA+C;AACzE,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,SAAS;AACb,MAAI,CAAC,KAAK,WACR;AAEF,SACG,MAAM,KAAK,QAAQ,IAAiB,KAAK,SAAS,KAAK,SAAS,CAAC,IAClE;;CAIJ,MAAM,WAAW,QAAqB;AACpC,QAAM,KAAK,QAAQ,IAAI,KAAK,SAAS,KAAK,SAAS,EAAE,OAAO;;CAG9D,IAAI,UAAU;AACZ,SAAO,KAAK;;;;;;CAOd,wBAAwB,SAAc;EAEpC,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,UAAkB;EACvC,MAAM,MAAM,KAAK,gBAAgB,KAAK,SAAS;AAI/C,MADiB,MAAM,KAAK,QAAQ,IAAY,IAAI,CAElD;AAGF,QAAM,KAAK,QAAQ,IAAI,KAAK,SAAS;;CAGvC,MAAM,eAAe;EACnB,MAAM,eAAe,MAAM,KAAK,QAAQ,IACtC,KAAK,gBAAgB,KAAK,SAAS,CACpC;AACD,MAAI,CAAC,aACH,OAAM,IAAI,MAAM,yBAAyB;AAE3C,SAAO"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
2
|
+
import {
|
|
3
|
+
OAuthClientInformationFull,
|
|
4
|
+
OAuthClientMetadata,
|
|
5
|
+
OAuthTokens
|
|
6
|
+
} from "@modelcontextprotocol/sdk/shared/auth.js";
|
|
7
|
+
|
|
8
|
+
//#region src/mcp/client-storage.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Represents a row in the cf_agents_mcp_servers table
|
|
11
|
+
*/
|
|
12
|
+
type MCPServerRow = {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
server_url: string;
|
|
16
|
+
client_id: string | null;
|
|
17
|
+
auth_url: string | null;
|
|
18
|
+
callback_url: string;
|
|
19
|
+
server_options: string | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* KV storage interface for OAuth-related data
|
|
23
|
+
* Used by OAuth providers to store tokens, client info, etc.
|
|
24
|
+
*/
|
|
25
|
+
interface OAuthClientStorage {
|
|
26
|
+
/**
|
|
27
|
+
* Get a value from key-value storage (for OAuth data like tokens, client info, etc.)
|
|
28
|
+
*/
|
|
29
|
+
get<T>(key: string): Promise<T | undefined> | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Put a value into key-value storage (for OAuth data like tokens, client info, etc.)
|
|
32
|
+
*/
|
|
33
|
+
put(key: string, value: unknown): Promise<void> | void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Storage interface for MCP client manager
|
|
37
|
+
* Abstracts storage operations to decouple from specific storage implementations
|
|
38
|
+
*/
|
|
39
|
+
interface MCPClientStorage extends OAuthClientStorage {
|
|
40
|
+
/**
|
|
41
|
+
* Save or update an MCP server configuration
|
|
42
|
+
*/
|
|
43
|
+
saveServer(server: MCPServerRow): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Remove an MCP server from storage
|
|
46
|
+
*/
|
|
47
|
+
removeServer(serverId: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* List all MCP servers from storage
|
|
50
|
+
*/
|
|
51
|
+
listServers(): Promise<MCPServerRow[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Get an MCP server by its callback URL
|
|
54
|
+
* Used during OAuth callback to identify which server is being authenticated
|
|
55
|
+
*/
|
|
56
|
+
getServerByCallbackUrl(callbackUrl: string): Promise<MCPServerRow | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Clear auth_url after successful OAuth authentication
|
|
59
|
+
* This prevents the agent from continuously asking for OAuth on reconnect
|
|
60
|
+
* when stored tokens are still valid.
|
|
61
|
+
*/
|
|
62
|
+
clearAuthUrl(serverId: string): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/mcp/do-oauth-client-provider.d.ts
|
|
66
|
+
interface AgentsOAuthProvider extends OAuthClientProvider {
|
|
67
|
+
authUrl: string | undefined;
|
|
68
|
+
clientId: string | undefined;
|
|
69
|
+
serverId: string | undefined;
|
|
70
|
+
}
|
|
71
|
+
declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
|
|
72
|
+
storage: OAuthClientStorage;
|
|
73
|
+
clientName: string;
|
|
74
|
+
baseRedirectUrl: string;
|
|
75
|
+
private _authUrl_;
|
|
76
|
+
private _serverId_;
|
|
77
|
+
private _clientId_;
|
|
78
|
+
constructor(
|
|
79
|
+
storage: OAuthClientStorage,
|
|
80
|
+
clientName: string,
|
|
81
|
+
baseRedirectUrl: string
|
|
82
|
+
);
|
|
83
|
+
get clientMetadata(): OAuthClientMetadata;
|
|
84
|
+
get clientUri(): string;
|
|
85
|
+
get redirectUrl(): string;
|
|
86
|
+
get clientId(): string;
|
|
87
|
+
set clientId(clientId_: string);
|
|
88
|
+
get serverId(): string;
|
|
89
|
+
set serverId(serverId_: string);
|
|
90
|
+
keyPrefix(clientId: string): string;
|
|
91
|
+
clientInfoKey(clientId: string): string;
|
|
92
|
+
clientInformation(): Promise<
|
|
93
|
+
| {
|
|
94
|
+
client_id: string;
|
|
95
|
+
client_secret?: string | undefined;
|
|
96
|
+
client_id_issued_at?: number | undefined;
|
|
97
|
+
client_secret_expires_at?: number | undefined;
|
|
98
|
+
}
|
|
99
|
+
| undefined
|
|
100
|
+
>;
|
|
101
|
+
saveClientInformation(
|
|
102
|
+
clientInformation: OAuthClientInformationFull
|
|
103
|
+
): Promise<void>;
|
|
104
|
+
tokenKey(clientId: string): string;
|
|
105
|
+
tokens(): Promise<
|
|
106
|
+
| {
|
|
107
|
+
access_token: string;
|
|
108
|
+
token_type: string;
|
|
109
|
+
id_token?: string | undefined;
|
|
110
|
+
expires_in?: number | undefined;
|
|
111
|
+
scope?: string | undefined;
|
|
112
|
+
refresh_token?: string | undefined;
|
|
113
|
+
}
|
|
114
|
+
| undefined
|
|
115
|
+
>;
|
|
116
|
+
saveTokens(tokens: OAuthTokens): Promise<void>;
|
|
117
|
+
get authUrl(): string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Because this operates on the server side (but we need browser auth), we send this url back to the user
|
|
120
|
+
* and require user interact to initiate the redirect flow
|
|
121
|
+
*/
|
|
122
|
+
redirectToAuthorization(authUrl: URL): void;
|
|
123
|
+
codeVerifierKey(clientId: string): string;
|
|
124
|
+
saveCodeVerifier(verifier: string): Promise<void>;
|
|
125
|
+
codeVerifier(): Promise<string>;
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export {
|
|
129
|
+
MCPServerRow as i,
|
|
130
|
+
DurableObjectOAuthClientProvider as n,
|
|
131
|
+
MCPClientStorage as r,
|
|
132
|
+
AgentsOAuthProvider as t
|
|
133
|
+
};
|
|
134
|
+
//# sourceMappingURL=do-oauth-client-provider-UhQDpDb8.d.ts.map
|
|
@@ -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
|
-
|
|
3
|
-
|
|
2
|
+
l as MCPConnectionState,
|
|
3
|
+
m as TransportType,
|
|
4
4
|
t as MCPClientManager
|
|
5
|
-
} from "./client-
|
|
6
|
-
import { t as Observability } from "./index-
|
|
7
|
-
import { n as MessageType } from "./ai-types-
|
|
5
|
+
} from "./client-ctTw3KHG.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
|
*
|
|
@@ -374,10 +379,23 @@ declare class Agent<
|
|
|
374
379
|
id: string;
|
|
375
380
|
authUrl: string | undefined;
|
|
376
381
|
}>;
|
|
377
|
-
private _connectToMcpServerInternal;
|
|
378
382
|
removeMcpServer(id: string): Promise<void>;
|
|
379
|
-
getMcpServers(): MCPServersState
|
|
383
|
+
getMcpServers(): Promise<MCPServersState>;
|
|
380
384
|
private broadcastMcpServers;
|
|
385
|
+
/**
|
|
386
|
+
* Handle MCP OAuth callback request if it's an OAuth callback.
|
|
387
|
+
*
|
|
388
|
+
* This method encapsulates the entire OAuth callback flow:
|
|
389
|
+
* 1. Checks if the request is an MCP OAuth callback
|
|
390
|
+
* 2. Processes the OAuth code exchange
|
|
391
|
+
* 3. Establishes the connection if successful
|
|
392
|
+
* 4. Broadcasts MCP server state updates
|
|
393
|
+
* 5. Returns the appropriate HTTP response
|
|
394
|
+
*
|
|
395
|
+
* @param request The incoming HTTP request
|
|
396
|
+
* @returns Response if this was an OAuth callback, null otherwise
|
|
397
|
+
*/
|
|
398
|
+
private handleMcpOAuthCallback;
|
|
381
399
|
/**
|
|
382
400
|
* Handle OAuth callback response using MCPClientManager configuration
|
|
383
401
|
* @param result OAuth callback result
|
|
@@ -494,17 +512,17 @@ type EmailSendOptions = {
|
|
|
494
512
|
*/
|
|
495
513
|
declare function getAgentByName<
|
|
496
514
|
Env,
|
|
497
|
-
T
|
|
515
|
+
T extends Agent<Env>,
|
|
498
516
|
Props extends Record<string, unknown> = Record<string, unknown>
|
|
499
517
|
>(
|
|
500
|
-
namespace: AgentNamespace<T
|
|
518
|
+
namespace: AgentNamespace<T>,
|
|
501
519
|
name: string,
|
|
502
520
|
options?: {
|
|
503
521
|
jurisdiction?: DurableObjectJurisdiction;
|
|
504
522
|
locationHint?: DurableObjectLocationHint;
|
|
505
523
|
props?: Props;
|
|
506
524
|
}
|
|
507
|
-
): Promise<DurableObjectStub<T
|
|
525
|
+
): Promise<DurableObjectStub<T>>;
|
|
508
526
|
/**
|
|
509
527
|
* A wrapper for streaming responses in callable methods
|
|
510
528
|
*/
|
|
@@ -557,4 +575,4 @@ export {
|
|
|
557
575
|
WSMessage as x,
|
|
558
576
|
StateUpdateMessage as y
|
|
559
577
|
};
|
|
560
|
-
//# sourceMappingURL=index-
|
|
578
|
+
//# sourceMappingURL=index-D2dnUH0r.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 { m as TransportType } from "./client-ctTw3KHG.js";
|
|
2
|
+
import "./mcp-BwPscEiF.js";
|
|
3
|
+
import "./do-oauth-client-provider-UhQDpDb8.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-D2dnUH0r.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-BZ-xTxF5.js";
|
|
4
|
+
import "./do-oauth-client-provider-Cs9QpXYp.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-C6rC6ZpH.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 {
|
|
2
|
-
import "../mcp-
|
|
3
|
-
import "../do-oauth-client-provider-
|
|
4
|
-
export { MCPClientManager, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, getNamespacedData };
|
|
1
|
+
import { a as MCPConnectionResult, c as getNamespacedData, i as MCPClientOAuthResult, n as MCPClientManagerOptions, o as MCPServerOptions, r as MCPClientOAuthCallbackConfig, s as RegisterServerOptions, t as MCPClientManager } from "../client-ctTw3KHG.js";
|
|
2
|
+
import "../mcp-BwPscEiF.js";
|
|
3
|
+
import "../do-oauth-client-provider-UhQDpDb8.js";
|
|
4
|
+
export { MCPClientManager, MCPClientManagerOptions, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MCPConnectionResult, 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-BZ-xTxF5.js";
|
|
2
|
+
import "../do-oauth-client-provider-Cs9QpXYp.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-UhQDpDb8.js";
|
|
2
2
|
export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,22 +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 CORSOptions, f as MaybePromise, i as MCPClientOAuthResult, o as MCPServerOptions, p as ServeOptions, r as MCPClientOAuthCallbackConfig, u as BaseTransportType } from "../client-ctTw3KHG.js";
|
|
2
|
+
import "../mcp-BwPscEiF.js";
|
|
3
|
+
import "../do-oauth-client-provider-UhQDpDb8.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-D2dnUH0r.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;
|
|
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;
|
|
17
54
|
}
|
|
18
55
|
declare class WorkerTransport implements Transport {
|
|
19
|
-
|
|
56
|
+
started: boolean;
|
|
20
57
|
private initialized;
|
|
21
58
|
private sessionIdGenerator?;
|
|
22
59
|
private enableJsonResponse;
|
|
@@ -25,12 +62,27 @@ declare class WorkerTransport implements Transport {
|
|
|
25
62
|
private streamMapping;
|
|
26
63
|
private requestToStreamMapping;
|
|
27
64
|
private requestResponseMap;
|
|
65
|
+
private corsOptions?;
|
|
66
|
+
private protocolVersion?;
|
|
67
|
+
private storage?;
|
|
68
|
+
private stateRestored;
|
|
28
69
|
sessionId?: string;
|
|
29
70
|
onclose?: () => void;
|
|
30
71
|
onerror?: (error: Error) => void;
|
|
31
|
-
onmessage?: (message: JSONRPCMessage) => void;
|
|
72
|
+
onmessage?: (message: JSONRPCMessage, extra?: MessageExtraInfo) => void;
|
|
32
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;
|
|
33
83
|
start(): Promise<void>;
|
|
84
|
+
private validateProtocolVersion;
|
|
85
|
+
private getHeaders;
|
|
34
86
|
handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
|
|
35
87
|
private handleGetRequest;
|
|
36
88
|
private handlePostRequest;
|
|
@@ -39,8 +91,14 @@ declare class WorkerTransport implements Transport {
|
|
|
39
91
|
private handleUnsupportedRequest;
|
|
40
92
|
private validateSession;
|
|
41
93
|
close(): Promise<void>;
|
|
42
|
-
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>;
|
|
43
100
|
}
|
|
101
|
+
declare function getMcpAuthContext(): McpAuthContext | undefined;
|
|
44
102
|
//#endregion
|
|
45
103
|
//#region src/mcp/handler.d.ts
|
|
46
104
|
interface CreateMcpHandlerOptions extends WorkerTransportOptions {
|
|
@@ -50,18 +108,23 @@ interface CreateMcpHandlerOptions extends WorkerTransportOptions {
|
|
|
50
108
|
* @default "/mcp"
|
|
51
109
|
*/
|
|
52
110
|
route?: string;
|
|
111
|
+
/**
|
|
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.
|
|
114
|
+
*/
|
|
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;
|
|
53
121
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
122
|
+
declare function createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated This has been renamed to createMcpHandler, and experimental_createMcpHandler will be removed in the next major version
|
|
125
|
+
*/
|
|
57
126
|
declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
58
127
|
//#endregion
|
|
59
|
-
//#region src/mcp/auth-context.d.ts
|
|
60
|
-
interface McpAuthContext {
|
|
61
|
-
props: Record<string, unknown>;
|
|
62
|
-
}
|
|
63
|
-
declare function getMcpAuthContext(): McpAuthContext | undefined;
|
|
64
|
-
//#endregion
|
|
65
128
|
//#region src/mcp/index.d.ts
|
|
66
129
|
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
|
|
67
130
|
private _transport?;
|
|
@@ -81,7 +144,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
81
144
|
*/
|
|
82
145
|
getSessionId(): string;
|
|
83
146
|
/** Get the unique WebSocket. SSE transport only. */
|
|
84
|
-
|
|
147
|
+
getWebSocket(): Connection<unknown> | null;
|
|
85
148
|
/** Returns a new transport matching the type of the Agent. */
|
|
86
149
|
private initTransport;
|
|
87
150
|
/** Update and store the props */
|
|
@@ -94,7 +157,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
94
157
|
request: req
|
|
95
158
|
}: ConnectionContext): Promise<void>;
|
|
96
159
|
/** Handles MCP Messages for the legacy SSE transport. */
|
|
97
|
-
onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
|
|
160
|
+
onSSEMcpMessage(_sessionId: string, messageBody: unknown, extraInfo?: MessageExtraInfo): Promise<Error | null>;
|
|
98
161
|
/** Elicit user input with a message and schema */
|
|
99
162
|
elicitInput(params: {
|
|
100
163
|
message: string;
|
|
@@ -110,7 +173,8 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
110
173
|
static serve(path: string, {
|
|
111
174
|
binding,
|
|
112
175
|
corsOptions,
|
|
113
|
-
transport
|
|
176
|
+
transport,
|
|
177
|
+
jurisdiction
|
|
114
178
|
}?: ServeOptions): {
|
|
115
179
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
116
180
|
};
|
|
@@ -125,5 +189,5 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
125
189
|
};
|
|
126
190
|
}
|
|
127
191
|
//#endregion
|
|
128
|
-
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 MCPServerOptions, McpAgent, type McpAuthContext, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, type TransportState, WorkerTransport, type WorkerTransportOptions, createMcpHandler, experimental_createMcpHandler, getMcpAuthContext };
|
|
129
193
|
//# sourceMappingURL=index.d.ts.map
|