agents 0.0.0-1f6598e → 0.0.0-2044d1a

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 +57 -7
  5. package/dist/ai-chat-agent.js +578 -94
  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 +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-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 +5112 -0
  42. package/dist/codemode/ai.js.map +1 -0
  43. package/dist/index.d.ts +275 -26
  44. package/dist/index.js +18 -8
  45. package/dist/mcp/client.d.ts +12 -714
  46. package/dist/mcp/client.js +4 -465
  47. package/dist/mcp/client.js.map +1 -1
  48. package/dist/mcp/do-oauth-client-provider.d.ts +42 -0
  49. package/dist/mcp/do-oauth-client-provider.js +8 -0
  50. package/dist/mcp/do-oauth-client-provider.js.map +1 -0
  51. package/dist/mcp/index.d.ts +71 -36
  52. package/dist/mcp/index.js +1016 -257
  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 +140 -28
  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 +100 -52
  73. package/src/index.ts +1268 -156
  74. package/dist/chunk-HMLY7DHA.js +0 -16
  75. package/dist/chunk-YMUU7QHV.js +0 -595
  76. package/dist/chunk-YMUU7QHV.js.map +0 -1
  77. /package/dist/{chunk-HMLY7DHA.js.map → ai-chat-v5-migration.js.map} +0 -0
@@ -1,43 +1,78 @@
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-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
- /**
14
- * 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}`.
15
33
  */
16
- initialState: State;
17
- get state(): State;
18
- sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
19
- setState(state: State): void;
20
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
21
- onStart(): Promise<void>;
22
- /**
23
- * 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}`.
24
38
  */
25
- abstract server: McpServer;
26
- props: Props;
27
- initRun: boolean;
28
- abstract init(): Promise<void>;
29
- _init(props: Props): Promise<void>;
30
- fetch(request: Request): Promise<Response>;
31
- getWebSocket(): WebSocket | null;
32
- onMCPMessage(sessionId: string, request: Request): Promise<Response>;
33
- webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
34
- webSocketError(ws: WebSocket, error: unknown): Promise<void>;
35
- webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
36
- static mount(path: string, { binding, corsOptions, }?: {
37
- binding?: string;
38
- corsOptions?: CORSOptions;
39
- }): {
40
- fetch: (request: Request, env: Record<string, DurableObjectNamespace<McpAgent>>, ctx: ExecutionContext) => Promise<Response | undefined>;
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>;
67
+ };
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>;
73
+ };
74
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
75
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
41
76
  };
42
77
  }
43
78