agents 0.0.0-feef082 → 0.0.0-ff9329f
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 +125 -3
- package/dist/_esm-LV5FJ3HK.js +3922 -0
- package/dist/_esm-LV5FJ3HK.js.map +1 -0
- package/dist/ai-chat-agent.d.ts +1 -1
- package/dist/ai-chat-agent.js +80 -57
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-chat-v5-migration.js +1 -0
- package/dist/ai-react.d.ts +7 -1
- package/dist/ai-react.js +157 -111
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types.d.ts +1 -0
- package/dist/ai-types.js +2 -1
- package/dist/ccip-CMBYN64O.js +15 -0
- package/dist/ccip-CMBYN64O.js.map +1 -0
- package/dist/chunk-5Y6BEZDY.js +276 -0
- package/dist/chunk-5Y6BEZDY.js.map +1 -0
- package/dist/{chunk-AVYJQSLW.js → chunk-BER7KXUJ.js} +2 -1
- package/dist/chunk-BER7KXUJ.js.map +1 -0
- package/dist/chunk-JJBFIGUC.js +5202 -0
- package/dist/chunk-JJBFIGUC.js.map +1 -0
- package/dist/chunk-PR4QN5HX.js +43 -0
- package/dist/chunk-PR4QN5HX.js.map +1 -0
- package/dist/{chunk-VYENMKFS.js → chunk-QEPGNUG6.js} +55 -17
- package/dist/chunk-QEPGNUG6.js.map +1 -0
- package/dist/{chunk-PNF6ZMUA.js → chunk-RS5OCNEQ.js} +37 -10
- package/dist/chunk-RS5OCNEQ.js.map +1 -0
- package/dist/chunk-TYAY6AU6.js +159 -0
- package/dist/chunk-TYAY6AU6.js.map +1 -0
- package/dist/{chunk-LL2AFX7V.js → chunk-XFS5ERG3.js} +20 -2
- package/dist/chunk-XFS5ERG3.js.map +1 -0
- package/dist/{client-B9tFv5gX.d.ts → client-BohGLma8.d.ts} +449 -15
- package/dist/client.js +2 -1
- package/dist/index.d.ts +22 -6
- package/dist/index.js +5 -4
- package/dist/mcp/client.d.ts +1 -1
- package/dist/mcp/client.js +2 -1
- package/dist/mcp/do-oauth-client-provider.d.ts +8 -0
- package/dist/mcp/do-oauth-client-provider.js +2 -1
- package/dist/mcp/index.d.ts +49 -83
- package/dist/mcp/index.js +903 -760
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/x402.d.ts +31 -0
- package/dist/mcp/x402.js +3195 -0
- package/dist/mcp/x402.js.map +1 -0
- package/dist/observability/index.js +5 -4
- package/dist/react.d.ts +1 -1
- package/dist/react.js +2 -1
- package/dist/react.js.map +1 -1
- package/dist/schedule.js +2 -0
- package/dist/schedule.js.map +1 -1
- package/dist/secp256k1-M22GZP2U.js +2193 -0
- package/dist/secp256k1-M22GZP2U.js.map +1 -0
- package/package.json +14 -6
- package/src/index.ts +61 -12
- package/dist/chunk-AVYJQSLW.js.map +0 -1
- package/dist/chunk-LL2AFX7V.js.map +0 -1
- package/dist/chunk-PNF6ZMUA.js.map +0 -1
- package/dist/chunk-VYENMKFS.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
9
9
|
import { Server, Connection, PartyServerOptions } from "partyserver";
|
|
10
10
|
export { Connection, ConnectionContext, WSMessage } from "partyserver";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
c as MCPClientManager,
|
|
13
|
+
T as TransportType
|
|
14
|
+
} from "./client-BohGLma8.js";
|
|
12
15
|
import { Observability } from "./observability/index.js";
|
|
13
16
|
import { MessageType } from "./ai-types.js";
|
|
14
17
|
import "zod";
|
|
@@ -124,6 +127,7 @@ type Schedule<T = string> = {
|
|
|
124
127
|
cron: string;
|
|
125
128
|
}
|
|
126
129
|
);
|
|
130
|
+
|
|
127
131
|
/**
|
|
128
132
|
* MCP Server state update message from server -> Client
|
|
129
133
|
*/
|
|
@@ -160,10 +164,14 @@ declare function getCurrentAgent<
|
|
|
160
164
|
* @template Env Environment type containing bindings
|
|
161
165
|
* @template State State type to store within the Agent
|
|
162
166
|
*/
|
|
163
|
-
declare class Agent<
|
|
167
|
+
declare class Agent<
|
|
168
|
+
Env = typeof env,
|
|
169
|
+
State = unknown,
|
|
170
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
171
|
+
> extends Server<Env, Props> {
|
|
164
172
|
private _state;
|
|
165
173
|
private _ParentClass;
|
|
166
|
-
mcp: MCPClientManager;
|
|
174
|
+
readonly mcp: MCPClientManager;
|
|
167
175
|
/**
|
|
168
176
|
* Initial state for the Agent
|
|
169
177
|
* Override to provide default state values
|
|
@@ -340,8 +348,9 @@ declare class Agent<Env = typeof env, State = unknown> extends Server<Env> {
|
|
|
340
348
|
/**
|
|
341
349
|
* Connect to a new MCP Server
|
|
342
350
|
*
|
|
351
|
+
* @param serverName Name of the MCP server
|
|
343
352
|
* @param url MCP Server SSE URL
|
|
344
|
-
* @param callbackHost Base host for the agent, used for the redirect URI.
|
|
353
|
+
* @param callbackHost Base host for the agent, used for the redirect URI. If not provided, will be derived from the current request.
|
|
345
354
|
* @param agentsPrefix agents routing prefix if not using `agents`
|
|
346
355
|
* @param options MCP client and transport (header) options
|
|
347
356
|
* @returns authUrl
|
|
@@ -349,7 +358,7 @@ declare class Agent<Env = typeof env, State = unknown> extends Server<Env> {
|
|
|
349
358
|
addMcpServer(
|
|
350
359
|
serverName: string,
|
|
351
360
|
url: string,
|
|
352
|
-
callbackHost
|
|
361
|
+
callbackHost?: string,
|
|
353
362
|
agentsPrefix?: string,
|
|
354
363
|
options?: {
|
|
355
364
|
client?: ConstructorParameters<typeof Client>[1];
|
|
@@ -376,6 +385,7 @@ declare class Agent<Env = typeof env, State = unknown> extends Server<Env> {
|
|
|
376
385
|
*/
|
|
377
386
|
transport?: {
|
|
378
387
|
headers?: HeadersInit;
|
|
388
|
+
type?: TransportType;
|
|
379
389
|
};
|
|
380
390
|
},
|
|
381
391
|
reconnect?: {
|
|
@@ -496,12 +506,17 @@ type EmailSendOptions = {
|
|
|
496
506
|
* @param options Options for Agent creation
|
|
497
507
|
* @returns Promise resolving to an Agent instance stub
|
|
498
508
|
*/
|
|
499
|
-
declare function getAgentByName<
|
|
509
|
+
declare function getAgentByName<
|
|
510
|
+
Env,
|
|
511
|
+
T extends Agent<Env>,
|
|
512
|
+
Props extends Record<string, unknown> = Record<string, unknown>
|
|
513
|
+
>(
|
|
500
514
|
namespace: AgentNamespace<T>,
|
|
501
515
|
name: string,
|
|
502
516
|
options?: {
|
|
503
517
|
jurisdiction?: DurableObjectJurisdiction;
|
|
504
518
|
locationHint?: DurableObjectLocationHint;
|
|
519
|
+
props?: Props;
|
|
505
520
|
}
|
|
506
521
|
): Promise<DurableObjectStub<T>>;
|
|
507
522
|
/**
|
|
@@ -543,6 +558,7 @@ export {
|
|
|
543
558
|
type Schedule,
|
|
544
559
|
type StateUpdateMessage,
|
|
545
560
|
StreamingResponse,
|
|
561
|
+
TransportType,
|
|
546
562
|
callable,
|
|
547
563
|
createAddressBasedEmailResolver,
|
|
548
564
|
createCatchAllEmailResolver,
|
package/dist/index.js
CHANGED
|
@@ -10,11 +10,12 @@ import {
|
|
|
10
10
|
routeAgentEmail,
|
|
11
11
|
routeAgentRequest,
|
|
12
12
|
unstable_callable
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-RS5OCNEQ.js";
|
|
14
|
+
import "./chunk-QEPGNUG6.js";
|
|
15
|
+
import "./chunk-XFS5ERG3.js";
|
|
16
16
|
import "./chunk-QEVM4BVL.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-BER7KXUJ.js";
|
|
18
|
+
import "./chunk-PR4QN5HX.js";
|
|
18
19
|
export {
|
|
19
20
|
Agent,
|
|
20
21
|
StreamingResponse,
|
package/dist/mcp/client.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import '@modelcontextprotocol/sdk/client/index.js';
|
|
|
3
3
|
import '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
4
4
|
import '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import 'ai';
|
|
6
|
-
export {
|
|
6
|
+
export { c as MCPClientManager, g as getNamespacedData } from '../client-BohGLma8.js';
|
|
7
7
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
8
8
|
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
9
9
|
import './do-oauth-client-provider.js';
|
package/dist/mcp/client.js
CHANGED
|
@@ -5,6 +5,9 @@ interface AgentsOAuthProvider extends OAuthClientProvider {
|
|
|
5
5
|
authUrl: string | undefined;
|
|
6
6
|
clientId: string | undefined;
|
|
7
7
|
serverId: string | undefined;
|
|
8
|
+
saveOAuthTransport(transportType: string): Promise<void>;
|
|
9
|
+
getOAuthTransport(): Promise<string | undefined>;
|
|
10
|
+
clearOAuthTransport(): Promise<void>;
|
|
8
11
|
}
|
|
9
12
|
declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
|
|
10
13
|
storage: DurableObjectStorage;
|
|
@@ -37,6 +40,11 @@ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
|
|
|
37
40
|
codeVerifierKey(clientId: string): string;
|
|
38
41
|
saveCodeVerifier(verifier: string): Promise<void>;
|
|
39
42
|
codeVerifier(): Promise<string>;
|
|
43
|
+
/** Transport tracking for OAuth flow */
|
|
44
|
+
oauthTransportKey(): string;
|
|
45
|
+
saveOAuthTransport(transportType: string): Promise<void>;
|
|
46
|
+
getOAuthTransport(): Promise<string | undefined>;
|
|
47
|
+
clearOAuthTransport(): Promise<void>;
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
export { type AgentsOAuthProvider, DurableObjectOAuthClientProvider };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,110 +1,76 @@
|
|
|
1
|
-
import { M as MCPClientManager } from '../client-B9tFv5gX.js';
|
|
2
|
-
export { S as SSEEdgeClientTransport, a as StreamableHTTPEdgeClientTransport } from '../client-B9tFv5gX.js';
|
|
3
|
-
import { DurableObject } from 'cloudflare:workers';
|
|
4
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
5
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
-
import { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { JSONRPCMessage, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
7
4
|
export { ElicitRequest, ElicitRequestSchema, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
-
import {
|
|
9
|
-
import '
|
|
5
|
+
import { Agent } from '../index.js';
|
|
6
|
+
import { M as MaybePromise, B as BaseTransportType, S as ServeOptions } from '../client-BohGLma8.js';
|
|
7
|
+
export { a as SSEEdgeClientTransport, b as StreamableHTTPEdgeClientTransport } from '../client-BohGLma8.js';
|
|
8
|
+
import { Connection, ConnectionContext } from 'partyserver';
|
|
9
|
+
import 'cloudflare:workers';
|
|
10
10
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
11
|
-
import '
|
|
11
|
+
import '../observability/index.js';
|
|
12
|
+
import '../ai-types.js';
|
|
12
13
|
import 'ai';
|
|
14
|
+
import 'zod';
|
|
15
|
+
import '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
13
16
|
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
14
17
|
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
15
18
|
import './do-oauth-client-provider.js';
|
|
16
19
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
17
20
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
origin?: string;
|
|
21
|
-
methods?: string;
|
|
22
|
-
headers?: string;
|
|
23
|
-
maxAge?: number;
|
|
24
|
-
exposeHeaders?: string;
|
|
25
|
-
}
|
|
26
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
27
|
-
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
|
|
28
|
-
private _status;
|
|
22
|
+
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
|
|
29
23
|
private _transport?;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
protected constructor(ctx: DurableObjectState, env: Env);
|
|
39
|
-
/**
|
|
40
|
-
* Agents API allowlist
|
|
24
|
+
props?: Props;
|
|
25
|
+
abstract server: MaybePromise<McpServer | Server>;
|
|
26
|
+
abstract init(): Promise<void>;
|
|
27
|
+
setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
|
|
28
|
+
getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
|
|
29
|
+
/** Read the transport type for this agent.
|
|
30
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
31
|
+
* or `streamable-http:${sessionId}`.
|
|
41
32
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Elicit user input with a message and schema
|
|
33
|
+
getTransportType(): BaseTransportType;
|
|
34
|
+
/** Read the sessionId for this agent.
|
|
35
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
36
|
+
* or `streamable-http:${sessionId}`.
|
|
48
37
|
*/
|
|
38
|
+
getSessionId(): string;
|
|
39
|
+
/** Get the unique WebSocket. SSE transport only. */
|
|
40
|
+
private getWebSocket;
|
|
41
|
+
/** Returns a new transport matching the type of the Agent. */
|
|
42
|
+
private initTransport;
|
|
43
|
+
/** Update and store the props */
|
|
44
|
+
updateProps(props?: Props): Promise<void>;
|
|
45
|
+
reinitializeServer(): Promise<void>;
|
|
46
|
+
/** Sets up the MCP transport and server every time the Agent is started.*/
|
|
47
|
+
onStart(props?: Props): Promise<void>;
|
|
48
|
+
/** Validates new WebSocket connections. */
|
|
49
|
+
onConnect(conn: Connection, { request: req }: ConnectionContext): Promise<void>;
|
|
50
|
+
/** Handles MCP Messages for the legacy SSE transport. */
|
|
51
|
+
onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
|
|
52
|
+
/** Elicit user input with a message and schema */
|
|
49
53
|
elicitInput(params: {
|
|
50
54
|
message: string;
|
|
51
55
|
requestedSchema: unknown;
|
|
52
56
|
}): Promise<ElicitResult>;
|
|
53
|
-
|
|
54
|
-
onStart(): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* McpAgent API
|
|
57
|
-
*/
|
|
58
|
-
abstract server: MaybePromise<McpServer | Server>;
|
|
59
|
-
props: Props;
|
|
60
|
-
initRun: boolean;
|
|
61
|
-
abstract init(): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Handle errors that occur during initialization or operation.
|
|
64
|
-
* Override this method to provide custom error handling.
|
|
65
|
-
* @param error - The error that occurred
|
|
66
|
-
* @returns An error response object with status code and message
|
|
67
|
-
*/
|
|
68
|
-
onError(error: Error): {
|
|
69
|
-
status: number;
|
|
70
|
-
message: string;
|
|
71
|
-
};
|
|
72
|
-
_init(props: Props): Promise<void>;
|
|
73
|
-
setInitialized(): Promise<void>;
|
|
74
|
-
isInitialized(): Promise<boolean>;
|
|
75
|
-
updateProps(props: Props): Promise<void>;
|
|
76
|
-
private _initialize;
|
|
77
|
-
fetch(request: Request): Promise<Response>;
|
|
78
|
-
getWebSocket(): WebSocket | null;
|
|
79
|
-
getWebSocketForResponseID(id: string): WebSocket | null;
|
|
80
|
-
onMessage(connection: Connection, event: WSMessage): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* Wait for elicitation response through storage polling
|
|
83
|
-
*/
|
|
57
|
+
/** Wait for elicitation response through storage polling */
|
|
84
58
|
private _waitForElicitationResponse;
|
|
85
|
-
/**
|
|
86
|
-
* Handle elicitation responses */
|
|
59
|
+
/** Handle elicitation responses */
|
|
87
60
|
private _handleElicitationResponse;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
static mount(path: string, { binding, corsOptions }?: {
|
|
93
|
-
binding?: string;
|
|
94
|
-
corsOptions?: CORSOptions;
|
|
95
|
-
}): {
|
|
61
|
+
/** Return a handler for the given path for this MCP.
|
|
62
|
+
* Defaults to Streamable HTTP transport.
|
|
63
|
+
*/
|
|
64
|
+
static serve(path: string, { binding, corsOptions, transport }?: ServeOptions): {
|
|
96
65
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
97
66
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Legacy api
|
|
69
|
+
**/
|
|
70
|
+
static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
102
71
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
103
72
|
};
|
|
104
|
-
static
|
|
105
|
-
binding?: string;
|
|
106
|
-
corsOptions?: CORSOptions;
|
|
107
|
-
}): {
|
|
73
|
+
static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
108
74
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
109
75
|
};
|
|
110
76
|
}
|