agents 0.0.0-f5b5854 → 0.0.0-f6b2319

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 (77) 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 +55 -8
  5. package/dist/ai-chat-agent.js +574 -90
  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 +78 -67
  10. package/dist/ai-react.js +273 -109
  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-254F4GDT.js +1343 -0
  17. package/dist/chunk-254F4GDT.js.map +1 -0
  18. package/dist/chunk-3OT2NNEW.js +941 -0
  19. package/dist/chunk-3OT2NNEW.js.map +1 -0
  20. package/dist/chunk-5Y6BEZDY.js +276 -0
  21. package/dist/chunk-5Y6BEZDY.js.map +1 -0
  22. package/dist/chunk-BER7KXUJ.js +18 -0
  23. package/dist/chunk-BER7KXUJ.js.map +1 -0
  24. package/dist/chunk-JJBFIGUC.js +5202 -0
  25. package/dist/chunk-JJBFIGUC.js.map +1 -0
  26. package/dist/chunk-PR4QN5HX.js +43 -0
  27. package/dist/chunk-PR4QN5HX.js.map +1 -0
  28. package/dist/chunk-QEVM4BVL.js +116 -0
  29. package/dist/chunk-QEVM4BVL.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-Z44WASMA.js +114 -0
  35. package/dist/chunk-Z44WASMA.js.map +1 -0
  36. package/dist/client-DVoPb3-C.d.ts +5120 -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/codemode/ai.d.ts +25 -0
  41. package/dist/codemode/ai.js +5109 -0
  42. package/dist/codemode/ai.js.map +1 -0
  43. package/dist/index.d.ts +277 -22
  44. package/dist/index.js +18 -6
  45. package/dist/mcp/client.d.ts +10 -761
  46. package/dist/mcp/client.js +4 -402
  47. package/dist/mcp/client.js.map +1 -1
  48. package/dist/mcp/do-oauth-client-provider.d.ts +4 -3
  49. package/dist/mcp/do-oauth-client-provider.js +4 -103
  50. package/dist/mcp/do-oauth-client-provider.js.map +1 -1
  51. package/dist/mcp/index.d.ts +69 -51
  52. package/dist/mcp/index.js +982 -661
  53. package/dist/mcp/index.js.map +1 -1
  54. package/dist/mcp/x402.d.ts +39 -0
  55. package/dist/mcp/x402.js +3195 -0
  56. package/dist/mcp/x402.js.map +1 -0
  57. package/dist/mcp-BH1fJeiU.d.ts +58 -0
  58. package/dist/observability/index.d.ts +34 -0
  59. package/dist/observability/index.js +12 -0
  60. package/dist/observability/index.js.map +1 -0
  61. package/dist/react.d.ts +97 -9
  62. package/dist/react.js +123 -11
  63. package/dist/react.js.map +1 -1
  64. package/dist/schedule.d.ts +81 -7
  65. package/dist/schedule.js +20 -7
  66. package/dist/schedule.js.map +1 -1
  67. package/dist/secp256k1-M22GZP2U.js +2193 -0
  68. package/dist/secp256k1-M22GZP2U.js.map +1 -0
  69. package/dist/serializable.d.ts +32 -0
  70. package/dist/serializable.js +1 -0
  71. package/dist/serializable.js.map +1 -0
  72. package/package.json +98 -64
  73. package/src/index.ts +1271 -152
  74. package/dist/chunk-HMLY7DHA.js +0 -16
  75. package/dist/chunk-XG52S6YY.js +0 -591
  76. package/dist/chunk-XG52S6YY.js.map +0 -1
  77. /package/dist/{chunk-HMLY7DHA.js.map → ai-chat-v5-migration.js.map} +0 -0
@@ -1,60 +1,78 @@
1
- import { DurableObject } from 'cloudflare:workers';
2
- import { Connection, WSMessage } from 'partyserver';
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
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-DVoPb3-C.js';
7
+ export { d as MCPClientOAuthCallbackConfig, c as MCPClientOAuthResult, a as SSEEdgeClientTransport, b as StreamableHTTPEdgeClientTransport } from '../client-DVoPb3-C.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 '../mcp-BH1fJeiU.js';
13
+ import '../ai-types.js';
14
+ import 'ai';
15
+ import 'zod';
16
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
17
+ import '@modelcontextprotocol/sdk/client/sse.js';
18
+ import '@modelcontextprotocol/sdk/client/streamableHttp.js';
19
+ import './do-oauth-client-provider.js';
20
+ import '@modelcontextprotocol/sdk/client/auth.js';
21
+ import '@modelcontextprotocol/sdk/shared/auth.js';
4
22
 
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
23
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
24
+ private _transport?;
25
+ props?: Props;
26
+ abstract server: MaybePromise<McpServer | Server>;
27
+ abstract init(): Promise<void>;
28
+ setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
29
+ getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
30
+ /** Read the transport type for this agent.
31
+ * This relies on the naming scheme being `sse:${sessionId}`
32
+ * or `streamable-http:${sessionId}`.
16
33
  */
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
34
+ getTransportType(): BaseTransportType;
35
+ /** Read the sessionId for this agent.
36
+ * This relies on the naming scheme being `sse:${sessionId}`
37
+ * or `streamable-http:${sessionId}`.
25
38
  */
26
- abstract server: McpServer;
27
- props: Props;
28
- initRun: boolean;
29
- abstract init(): Promise<void>;
30
- _init(props: Props): Promise<void>;
31
- setInitialized(): Promise<void>;
32
- isInitialized(): Promise<boolean>;
33
- fetch(request: Request): Promise<Response>;
34
- getWebSocket(): WebSocket | null;
35
- getWebSocketForResponseID(id: string): WebSocket | null;
36
- onMessage(connection: Connection, event: WSMessage): Promise<void>;
37
- onSSEMcpMessage(sessionId: string, request: Request): Promise<Error | null>;
38
- webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
39
- webSocketError(ws: WebSocket, error: unknown): Promise<void>;
40
- webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
41
- static mount(path: string, { binding, corsOptions, }?: {
42
- binding?: string;
43
- corsOptions?: CORSOptions;
44
- }): {
45
- fetch: (request: Request, env: Record<string, DurableObjectNamespace<McpAgent>>, ctx: ExecutionContext) => Promise<Response>;
39
+ getSessionId(): string;
40
+ /** Get the unique WebSocket. SSE transport only. */
41
+ private getWebSocket;
42
+ /** Returns a new transport matching the type of the Agent. */
43
+ private initTransport;
44
+ /** Update and store the props */
45
+ updateProps(props?: Props): Promise<void>;
46
+ reinitializeServer(): Promise<void>;
47
+ /** Sets up the MCP transport and server every time the Agent is started.*/
48
+ onStart(props?: Props): Promise<void>;
49
+ /** Validates new WebSocket connections. */
50
+ onConnect(conn: Connection, { request: req }: ConnectionContext): Promise<void>;
51
+ /** Handles MCP Messages for the legacy SSE transport. */
52
+ onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
53
+ /** Elicit user input with a message and schema */
54
+ elicitInput(params: {
55
+ message: string;
56
+ requestedSchema: unknown;
57
+ }): Promise<ElicitResult>;
58
+ /** Wait for elicitation response through storage polling */
59
+ private _waitForElicitationResponse;
60
+ /** Handle elicitation responses */
61
+ private _handleElicitationResponse;
62
+ /** Return a handler for the given path for this MCP.
63
+ * Defaults to Streamable HTTP transport.
64
+ */
65
+ static serve(path: string, { binding, corsOptions, transport }?: ServeOptions): {
66
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
46
67
  };
47
- static serveSSE(path: string, { binding, corsOptions, }?: {
48
- binding?: string;
49
- corsOptions?: CORSOptions;
50
- }): {
51
- fetch: (request: Request, env: Record<string, DurableObjectNamespace<McpAgent>>, ctx: ExecutionContext) => Promise<Response>;
68
+ /**
69
+ * Legacy api
70
+ **/
71
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
72
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
52
73
  };
53
- static serve(path: string, { binding, corsOptions, }?: {
54
- binding?: string;
55
- corsOptions?: CORSOptions;
56
- }): {
57
- fetch: (request: Request, env: Record<string, DurableObjectNamespace<McpAgent>>, ctx: ExecutionContext) => Promise<Response>;
74
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
75
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
58
76
  };
59
77
  }
60
78