agents 0.0.0-e4a2352 → 0.0.0-e777fdd

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.
Files changed (67) hide show
  1. package/README.md +129 -7
  2. package/dist/_esm-LV5FJ3HK.js +3922 -0
  3. package/dist/_esm-LV5FJ3HK.js.map +1 -0
  4. package/dist/ai-chat-agent.d.ts +9 -8
  5. package/dist/ai-chat-agent.js +151 -59
  6. package/dist/ai-chat-agent.js.map +1 -1
  7. package/dist/ai-chat-v5-migration.d.ts +152 -0
  8. package/dist/ai-chat-v5-migration.js +20 -0
  9. package/dist/ai-chat-v5-migration.js.map +1 -0
  10. package/dist/ai-react.d.ts +65 -70
  11. package/dist/ai-react.js +252 -99
  12. package/dist/ai-react.js.map +1 -1
  13. package/dist/ai-types.d.ts +37 -19
  14. package/dist/ai-types.js +7 -0
  15. package/dist/ccip-CMBYN64O.js +15 -0
  16. package/dist/ccip-CMBYN64O.js.map +1 -0
  17. package/dist/chunk-5Y6BEZDY.js +276 -0
  18. package/dist/chunk-5Y6BEZDY.js.map +1 -0
  19. package/dist/chunk-BER7KXUJ.js +18 -0
  20. package/dist/chunk-BER7KXUJ.js.map +1 -0
  21. package/dist/chunk-JJBFIGUC.js +5202 -0
  22. package/dist/chunk-JJBFIGUC.js.map +1 -0
  23. package/dist/chunk-PR4QN5HX.js +43 -0
  24. package/dist/chunk-PR4QN5HX.js.map +1 -0
  25. package/dist/{chunk-HY7ZLHJB.js → chunk-QEPGNUG6.js} +71 -19
  26. package/dist/chunk-QEPGNUG6.js.map +1 -0
  27. package/dist/{chunk-KUH345EY.js → chunk-QEVM4BVL.js} +5 -5
  28. package/dist/chunk-QEVM4BVL.js.map +1 -0
  29. package/dist/{chunk-JXN5WZFQ.js → chunk-RS5OCNEQ.js} +117 -81
  30. package/dist/chunk-RS5OCNEQ.js.map +1 -0
  31. package/dist/chunk-TYAY6AU6.js +159 -0
  32. package/dist/chunk-TYAY6AU6.js.map +1 -0
  33. package/dist/chunk-UJVEAURM.js +150 -0
  34. package/dist/chunk-UJVEAURM.js.map +1 -0
  35. package/dist/{chunk-PVQZBKN7.js → chunk-XFS5ERG3.js} +24 -3
  36. package/dist/chunk-XFS5ERG3.js.map +1 -0
  37. package/dist/{client-DgyzBU_8.d.ts → client-BohGLma8.d.ts} +461 -21
  38. package/dist/client.js +3 -1
  39. package/dist/index.d.ts +562 -32
  40. package/dist/index.js +8 -4
  41. package/dist/mcp/client.d.ts +1 -1
  42. package/dist/mcp/client.js +2 -1
  43. package/dist/mcp/do-oauth-client-provider.d.ts +9 -0
  44. package/dist/mcp/do-oauth-client-provider.js +2 -1
  45. package/dist/mcp/index.d.ts +49 -73
  46. package/dist/mcp/index.js +906 -721
  47. package/dist/mcp/index.js.map +1 -1
  48. package/dist/mcp/x402.d.ts +39 -0
  49. package/dist/mcp/x402.js +3195 -0
  50. package/dist/mcp/x402.js.map +1 -0
  51. package/dist/observability/index.d.ts +46 -14
  52. package/dist/observability/index.js +6 -4
  53. package/dist/react.d.ts +4 -2
  54. package/dist/react.js +8 -5
  55. package/dist/react.js.map +1 -1
  56. package/dist/schedule.d.ts +79 -5
  57. package/dist/schedule.js +17 -2
  58. package/dist/schedule.js.map +1 -1
  59. package/dist/secp256k1-M22GZP2U.js +2193 -0
  60. package/dist/secp256k1-M22GZP2U.js.map +1 -0
  61. package/package.json +24 -8
  62. package/src/index.ts +164 -94
  63. package/dist/chunk-HY7ZLHJB.js.map +0 -1
  64. package/dist/chunk-JXN5WZFQ.js.map +0 -1
  65. package/dist/chunk-KUH345EY.js.map +0 -1
  66. package/dist/chunk-PVQZBKN7.js.map +0 -1
  67. package/dist/index-BCJclX6q.d.ts +0 -615
@@ -1,100 +1,76 @@
1
- import { M as MCPClientManager } from '../client-DgyzBU_8.js';
2
- export { S as SSEEdgeClientTransport, a as StreamableHTTPEdgeClientTransport } from '../client-DgyzBU_8.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 { Connection, WSMessage } from 'partyserver';
9
- import 'zod';
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 '@modelcontextprotocol/sdk/shared/protocol.js';
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
- interface CORSOptions {
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
- private _transportType;
31
- private _requestIdToConnectionId;
32
- /**
33
- * Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
34
- * to the outer class: initialState/state/setState/onStateUpdate/sql
35
- */
36
- private _agent;
37
- get mcp(): MCPClientManager;
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
- initialState: State;
43
- get state(): State;
44
- sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
45
- setState(state: State): void;
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
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
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
- _init(props: Props): Promise<void>;
63
- setInitialized(): Promise<void>;
64
- isInitialized(): Promise<boolean>;
65
- updateProps(props: Props): Promise<void>;
66
- private _initialize;
67
- fetch(request: Request): Promise<Response>;
68
- getWebSocket(): WebSocket | null;
69
- getWebSocketForResponseID(id: string): WebSocket | null;
70
- onMessage(connection: Connection, event: WSMessage): Promise<void>;
71
- /**
72
- * Wait for elicitation response through storage polling
73
- */
57
+ /** Wait for elicitation response through storage polling */
74
58
  private _waitForElicitationResponse;
75
- /**
76
- * Handle elicitation responses */
59
+ /** Handle elicitation responses */
77
60
  private _handleElicitationResponse;
78
- onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
79
- webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
80
- webSocketError(ws: WebSocket, error: unknown): Promise<void>;
81
- webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
82
- static mount(path: string, { binding, corsOptions }?: {
83
- binding?: string;
84
- corsOptions?: CORSOptions;
85
- }): {
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): {
86
65
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
87
66
  };
88
- static serveSSE(path: string, { binding, corsOptions }?: {
89
- binding?: string;
90
- corsOptions?: CORSOptions;
91
- }): {
67
+ /**
68
+ * Legacy api
69
+ **/
70
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
92
71
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
93
72
  };
94
- static serve(path: string, { binding, corsOptions }?: {
95
- binding?: string;
96
- corsOptions?: CORSOptions;
97
- }): {
73
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
98
74
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
99
75
  };
100
76
  }