agents 0.0.0-b25bc37 → 0.0.0-b299d20

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 (73) hide show
  1. package/README.md +255 -27
  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 +56 -7
  5. package/dist/ai-chat-agent.js +285 -93
  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-react.d.ts +77 -67
  10. package/dist/ai-react.js +274 -114
  11. package/dist/ai-react.js.map +1 -1
  12. package/dist/ai-types.d.ts +41 -18
  13. package/dist/ai-types.js +7 -0
  14. package/dist/ccip-CMBYN64O.js +15 -0
  15. package/dist/ccip-CMBYN64O.js.map +1 -0
  16. package/dist/chunk-5Y6BEZDY.js +276 -0
  17. package/dist/chunk-5Y6BEZDY.js.map +1 -0
  18. package/dist/chunk-BER7KXUJ.js +18 -0
  19. package/dist/chunk-BER7KXUJ.js.map +1 -0
  20. package/dist/chunk-JJBFIGUC.js +5202 -0
  21. package/dist/chunk-JJBFIGUC.js.map +1 -0
  22. package/dist/chunk-PR4QN5HX.js +43 -0
  23. package/dist/chunk-PR4QN5HX.js.map +1 -0
  24. package/dist/chunk-QEPGNUG6.js +650 -0
  25. package/dist/chunk-QEPGNUG6.js.map +1 -0
  26. package/dist/chunk-QEVM4BVL.js +116 -0
  27. package/dist/chunk-QEVM4BVL.js.map +1 -0
  28. package/dist/chunk-RS5OCNEQ.js +1323 -0
  29. package/dist/chunk-RS5OCNEQ.js.map +1 -0
  30. package/dist/chunk-TYAY6AU6.js +159 -0
  31. package/dist/chunk-TYAY6AU6.js.map +1 -0
  32. package/dist/chunk-UJVEAURM.js +150 -0
  33. package/dist/chunk-UJVEAURM.js.map +1 -0
  34. package/dist/chunk-XFS5ERG3.js +127 -0
  35. package/dist/chunk-XFS5ERG3.js.map +1 -0
  36. package/dist/client-BohGLma8.d.ts +5041 -0
  37. package/dist/client.d.ts +16 -2
  38. package/dist/client.js +8 -126
  39. package/dist/client.js.map +1 -1
  40. package/dist/index.d.ts +289 -26
  41. package/dist/index.js +18 -8
  42. package/dist/mcp/client.d.ts +11 -714
  43. package/dist/mcp/client.js +4 -465
  44. package/dist/mcp/client.js.map +1 -1
  45. package/dist/mcp/do-oauth-client-provider.d.ts +50 -0
  46. package/dist/mcp/do-oauth-client-provider.js +8 -0
  47. package/dist/mcp/do-oauth-client-provider.js.map +1 -0
  48. package/dist/mcp/index.d.ts +70 -37
  49. package/dist/mcp/index.js +1016 -266
  50. package/dist/mcp/index.js.map +1 -1
  51. package/dist/mcp/x402.d.ts +39 -0
  52. package/dist/mcp/x402.js +3195 -0
  53. package/dist/mcp/x402.js.map +1 -0
  54. package/dist/observability/index.d.ts +46 -0
  55. package/dist/observability/index.js +12 -0
  56. package/dist/observability/index.js.map +1 -0
  57. package/dist/react.d.ts +89 -5
  58. package/dist/react.js +24 -9
  59. package/dist/react.js.map +1 -1
  60. package/dist/schedule.d.ts +81 -7
  61. package/dist/schedule.js +20 -7
  62. package/dist/schedule.js.map +1 -1
  63. package/dist/secp256k1-M22GZP2U.js +2193 -0
  64. package/dist/secp256k1-M22GZP2U.js.map +1 -0
  65. package/dist/serializable.d.ts +32 -0
  66. package/dist/serializable.js +1 -0
  67. package/dist/serializable.js.map +1 -0
  68. package/package.json +93 -52
  69. package/src/index.ts +1224 -156
  70. package/dist/chunk-HMLY7DHA.js +0 -16
  71. package/dist/chunk-YMUU7QHV.js +0 -595
  72. package/dist/chunk-YMUU7QHV.js.map +0 -1
  73. /package/dist/{chunk-HMLY7DHA.js.map → ai-chat-v5-migration.js.map} +0 -0
@@ -1,44 +1,77 @@
1
- import { DurableObject } from 'cloudflare:workers';
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- import { Connection } from 'partyserver';
3
+ import { JSONRPCMessage, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
4
+ export { ElicitRequest, ElicitRequestSchema, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
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
+ import '@modelcontextprotocol/sdk/client/index.js';
11
+ import '../observability/index.js';
12
+ import '../ai-types.js';
13
+ import 'ai';
14
+ import 'zod';
15
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
16
+ import '@modelcontextprotocol/sdk/client/sse.js';
17
+ import '@modelcontextprotocol/sdk/client/streamableHttp.js';
18
+ import './do-oauth-client-provider.js';
19
+ import '@modelcontextprotocol/sdk/client/auth.js';
20
+ import '@modelcontextprotocol/sdk/shared/auth.js';
4
21
 
5
- interface CORSOptions {
6
- origin?: string;
7
- methods?: string;
8
- headers?: string;
9
- maxAge?: number;
10
- }
11
- declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
12
- #private;
13
- protected constructor(ctx: DurableObjectState, env: Env);
14
- /**
15
- * Agents API allowlist
22
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
23
+ private _transport?;
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}`.
16
32
  */
17
- initialState: State;
18
- get state(): State;
19
- sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
20
- setState(state: State): void;
21
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
22
- onStart(): Promise<void>;
23
- /**
24
- * McpAgent API
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}`.
25
37
  */
26
- abstract server: McpServer;
27
- props: Props;
28
- initRun: boolean;
29
- abstract init(): Promise<void>;
30
- _init(props: Props): Promise<void>;
31
- fetch(request: Request): Promise<Response>;
32
- getWebSocket(): WebSocket | null;
33
- onMCPMessage(sessionId: string, request: Request): Promise<Response>;
34
- webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
35
- webSocketError(ws: WebSocket, error: unknown): Promise<void>;
36
- webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
37
- static mount(path: string, { binding, corsOptions, }?: {
38
- binding?: string;
39
- corsOptions?: CORSOptions;
40
- }): {
41
- fetch: (request: Request, env: Record<string, DurableObjectNamespace<McpAgent>>, ctx: ExecutionContext) => Promise<Response | undefined>;
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 */
53
+ elicitInput(params: {
54
+ message: string;
55
+ requestedSchema: unknown;
56
+ }): Promise<ElicitResult>;
57
+ /** Wait for elicitation response through storage polling */
58
+ private _waitForElicitationResponse;
59
+ /** Handle elicitation responses */
60
+ private _handleElicitationResponse;
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): {
65
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
66
+ };
67
+ /**
68
+ * Legacy api
69
+ **/
70
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
71
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
72
+ };
73
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
74
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
42
75
  };
43
76
  }
44
77