agents 0.2.23 → 0.2.24
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/{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-CsaP9Irq.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-DEZFuVoU.d.ts → index-Bx5KK3VJ.d.ts} +44 -23
- 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 +11 -11
- package/dist/mcp/index.js +21 -14
- 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-CrV9uP64.d.ts → react-CbwD4fBf.d.ts} +4 -4
- 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-C8K3lu37.js → src-D_KKH_4c.js} +99 -146
- package/dist/src-D_KKH_4c.js.map +1 -0
- package/package.json +7 -7
- package/dist/ai-types-B3aQaFv3.js.map +0 -1
- package/dist/client-DZhjV_XA.js +0 -719
- package/dist/client-DZhjV_XA.js.map +0 -1
- package/dist/client-GfgZTqrS.d.ts +0 -5283
- package/dist/do-oauth-client-provider-CswoD5Lu.js.map +0 -1
- package/dist/src-C8K3lu37.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-CsaP9Irq.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,
|
|
@@ -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;
|
|
@@ -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,20 +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
|
-
/**
|
|
380
|
-
* Clear the auth_url for an MCP server after successful OAuth authentication
|
|
381
|
-
* This prevents the agent from continuously asking for OAuth on reconnect
|
|
382
|
-
* @param id The server ID to clear auth_url for
|
|
383
|
-
*/
|
|
384
|
-
private clearMcpServerAuthUrl;
|
|
385
392
|
getMcpServers(): MCPServersState;
|
|
386
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;
|
|
387
408
|
/**
|
|
388
409
|
* Handle OAuth callback response using MCPClientManager configuration
|
|
389
410
|
* @param result OAuth callback result
|
|
@@ -563,4 +584,4 @@ export {
|
|
|
563
584
|
WSMessage as x,
|
|
564
585
|
StateUpdateMessage as y
|
|
565
586
|
};
|
|
566
|
-
//# sourceMappingURL=index-
|
|
587
|
+
//# sourceMappingURL=index-Bx5KK3VJ.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-CsaP9Irq.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-Bx5KK3VJ.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-CsaP9Irq.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,15 +1,15 @@
|
|
|
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-
|
|
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-CsaP9Irq.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-Bx5KK3VJ.js";
|
|
7
7
|
import { SSEClientTransport, SSEClientTransportOptions } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
8
8
|
import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
9
9
|
import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage, MessageExtraInfo } from "@modelcontextprotocol/sdk/types.js";
|
|
10
10
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
11
11
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12
|
-
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
12
|
+
import { Transport, TransportSendOptions } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
13
13
|
|
|
14
14
|
//#region src/mcp/client-transports.d.ts
|
|
15
15
|
/**
|
|
@@ -91,7 +91,7 @@ declare class WorkerTransport implements Transport {
|
|
|
91
91
|
private handleUnsupportedRequest;
|
|
92
92
|
private validateSession;
|
|
93
93
|
close(): Promise<void>;
|
|
94
|
-
send(message: JSONRPCMessage): Promise<void>;
|
|
94
|
+
send(message: JSONRPCMessage, options?: TransportSendOptions): Promise<void>;
|
|
95
95
|
}
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/mcp/auth-context.d.ts
|
|
@@ -144,7 +144,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
144
144
|
*/
|
|
145
145
|
getSessionId(): string;
|
|
146
146
|
/** Get the unique WebSocket. SSE transport only. */
|
|
147
|
-
|
|
147
|
+
getWebSocket(): Connection<unknown> | null;
|
|
148
148
|
/** Returns a new transport matching the type of the Agent. */
|
|
149
149
|
private initTransport;
|
|
150
150
|
/** Update and store the props */
|
|
@@ -157,7 +157,7 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
157
157
|
request: req
|
|
158
158
|
}: ConnectionContext): Promise<void>;
|
|
159
159
|
/** Handles MCP Messages for the legacy SSE transport. */
|
|
160
|
-
onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
|
|
160
|
+
onSSEMcpMessage(_sessionId: string, messageBody: unknown, extraInfo?: MessageExtraInfo): Promise<Error | null>;
|
|
161
161
|
/** Elicit user input with a message and schema */
|
|
162
162
|
elicitInput(params: {
|
|
163
163
|
message: string;
|
|
@@ -189,5 +189,5 @@ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Re
|
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
191
|
//#endregion
|
|
192
|
-
export { type CreateMcpHandlerOptions, type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, McpAgent, type McpAuthContext, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, type TransportState, WorkerTransport, type WorkerTransportOptions, createMcpHandler, experimental_createMcpHandler, getMcpAuthContext };
|
|
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 };
|
|
193
193
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as MessageType } from "../ai-types-
|
|
2
|
-
import "../client-
|
|
3
|
-
import "../client-
|
|
4
|
-
import "../do-oauth-client-provider-
|
|
5
|
-
import { c as getCurrentAgent, s as getAgentByName, t as Agent } from "../src-
|
|
1
|
+
import { t as MessageType } from "../ai-types-CrMqkwc_.js";
|
|
2
|
+
import "../client-B3SR12TQ.js";
|
|
3
|
+
import "../client-BZq9qau2.js";
|
|
4
|
+
import "../do-oauth-client-provider-CwqK5SXm.js";
|
|
5
|
+
import { c as getCurrentAgent, s as getAgentByName, t as Agent } from "../src-D_KKH_4c.js";
|
|
6
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
7
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
8
8
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
@@ -434,7 +434,8 @@ const createLegacySseHandler = (basePath, namespace, options = {}) => {
|
|
|
434
434
|
jurisdiction: options.jurisdiction
|
|
435
435
|
});
|
|
436
436
|
const messageBody = await request.json();
|
|
437
|
-
const
|
|
437
|
+
const extraInfo = { requestInfo: { headers: Object.fromEntries(request.headers.entries()) } };
|
|
438
|
+
const error = await agent.onSSEMcpMessage(sessionId, messageBody, extraInfo);
|
|
438
439
|
if (error) return new Response(error.message, {
|
|
439
440
|
headers: {
|
|
440
441
|
"Cache-Control": "no-cache",
|
|
@@ -478,9 +479,12 @@ function isDurableObjectNamespace(namespace) {
|
|
|
478
479
|
//#endregion
|
|
479
480
|
//#region src/mcp/transport.ts
|
|
480
481
|
var McpSSETransport = class {
|
|
481
|
-
constructor(
|
|
482
|
+
constructor() {
|
|
482
483
|
this._started = false;
|
|
483
|
-
|
|
484
|
+
const { agent } = getCurrentAgent();
|
|
485
|
+
if (!agent) throw new Error("McpAgent was not found in Transport constructor");
|
|
486
|
+
this.sessionId = agent.getSessionId();
|
|
487
|
+
this._getWebSocket = () => agent.getWebSocket();
|
|
484
488
|
}
|
|
485
489
|
async start() {
|
|
486
490
|
if (this._started) throw new Error("Transport already started");
|
|
@@ -641,6 +645,9 @@ var StreamableHTTPServerTransport = class {
|
|
|
641
645
|
|
|
642
646
|
//#endregion
|
|
643
647
|
//#region src/mcp/client-transports.ts
|
|
648
|
+
/**
|
|
649
|
+
* Deprecated transport wrappers
|
|
650
|
+
*/
|
|
644
651
|
let didWarnAboutSSEEdgeClientTransport = false;
|
|
645
652
|
/**
|
|
646
653
|
* @deprecated Use SSEClientTransport from @modelcontextprotocol/sdk/client/sse.js instead. This alias will be removed in the next major version.
|
|
@@ -861,7 +868,7 @@ var WorkerTransport = class {
|
|
|
861
868
|
}
|
|
862
869
|
async handlePostRequest(request, parsedBody) {
|
|
863
870
|
const acceptHeader = request.headers.get("Accept");
|
|
864
|
-
if (!acceptHeader?.includes("application/json") || !acceptHeader
|
|
871
|
+
if (!acceptHeader?.includes("application/json") || !acceptHeader?.includes("text/event-stream")) return new Response(JSON.stringify({
|
|
865
872
|
jsonrpc: "2.0",
|
|
866
873
|
error: {
|
|
867
874
|
code: -32e3,
|
|
@@ -1101,8 +1108,8 @@ var WorkerTransport = class {
|
|
|
1101
1108
|
this.requestResponseMap.clear();
|
|
1102
1109
|
this.onclose?.();
|
|
1103
1110
|
}
|
|
1104
|
-
async send(message) {
|
|
1105
|
-
let requestId;
|
|
1111
|
+
async send(message, options) {
|
|
1112
|
+
let requestId = options?.relatedRequestId;
|
|
1106
1113
|
if (isJSONRPCResponse(message) || isJSONRPCError(message)) requestId = message.id;
|
|
1107
1114
|
if (requestId === void 0) {
|
|
1108
1115
|
if (isJSONRPCResponse(message) || isJSONRPCError(message)) throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");
|
|
@@ -1250,7 +1257,7 @@ var McpAgent = class McpAgent extends Agent {
|
|
|
1250
1257
|
/** Returns a new transport matching the type of the Agent. */
|
|
1251
1258
|
initTransport() {
|
|
1252
1259
|
switch (this.getTransportType()) {
|
|
1253
|
-
case "sse": return new McpSSETransport(
|
|
1260
|
+
case "sse": return new McpSSETransport();
|
|
1254
1261
|
case "streamable-http": return new StreamableHTTPServerTransport({});
|
|
1255
1262
|
}
|
|
1256
1263
|
}
|
|
@@ -1303,7 +1310,7 @@ var McpAgent = class McpAgent extends Agent {
|
|
|
1303
1310
|
}
|
|
1304
1311
|
}
|
|
1305
1312
|
/** Handles MCP Messages for the legacy SSE transport. */
|
|
1306
|
-
async onSSEMcpMessage(_sessionId, messageBody) {
|
|
1313
|
+
async onSSEMcpMessage(_sessionId, messageBody, extraInfo) {
|
|
1307
1314
|
if (this.getTransportType() !== "sse") return /* @__PURE__ */ new Error("Internal Server Error: Expected SSE transport");
|
|
1308
1315
|
try {
|
|
1309
1316
|
let parsedMessage;
|
|
@@ -1314,7 +1321,7 @@ var McpAgent = class McpAgent extends Agent {
|
|
|
1314
1321
|
throw error;
|
|
1315
1322
|
}
|
|
1316
1323
|
if (await this._handleElicitationResponse(parsedMessage)) return null;
|
|
1317
|
-
this._transport?.onmessage?.(parsedMessage);
|
|
1324
|
+
this._transport?.onmessage?.(parsedMessage, extraInfo);
|
|
1318
1325
|
return null;
|
|
1319
1326
|
} catch (error) {
|
|
1320
1327
|
console.error("Error forwarding message to SSE:", error);
|