agents 0.0.0-c69f616 → 0.0.0-c6d9bf1

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 (71) 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 +10 -8
  5. package/dist/ai-chat-agent.js +444 -60
  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 +66 -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-OJFA7RKX.js → chunk-254F4GDT.js} +188 -115
  18. package/dist/chunk-254F4GDT.js.map +1 -0
  19. package/dist/{chunk-HY7ZLHJB.js → chunk-3OT2NNEW.js} +412 -69
  20. package/dist/chunk-3OT2NNEW.js.map +1 -0
  21. package/dist/chunk-5Y6BEZDY.js +276 -0
  22. package/dist/chunk-5Y6BEZDY.js.map +1 -0
  23. package/dist/chunk-BER7KXUJ.js +18 -0
  24. package/dist/chunk-BER7KXUJ.js.map +1 -0
  25. package/dist/chunk-JJBFIGUC.js +5202 -0
  26. package/dist/chunk-JJBFIGUC.js.map +1 -0
  27. package/dist/chunk-PR4QN5HX.js +43 -0
  28. package/dist/chunk-PR4QN5HX.js.map +1 -0
  29. package/dist/{chunk-KUH345EY.js → chunk-QEVM4BVL.js} +5 -5
  30. package/dist/chunk-QEVM4BVL.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-Z44WASMA.js} +11 -3
  36. package/dist/chunk-Z44WASMA.js.map +1 -0
  37. package/dist/{client-CH-eFIfq.d.ts → client-DVoPb3-C.d.ts} +762 -99
  38. package/dist/client.js +3 -1
  39. package/dist/codemode/ai.d.ts +25 -0
  40. package/dist/codemode/ai.js +5112 -0
  41. package/dist/codemode/ai.js.map +1 -0
  42. package/dist/index.d.ts +548 -32
  43. package/dist/index.js +8 -4
  44. package/dist/mcp/client.d.ts +2 -1
  45. package/dist/mcp/client.js +2 -1
  46. package/dist/mcp/do-oauth-client-provider.d.ts +1 -0
  47. package/dist/mcp/do-oauth-client-provider.js +2 -1
  48. package/dist/mcp/index.d.ts +50 -72
  49. package/dist/mcp/index.js +909 -718
  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/mcp-BH1fJeiU.d.ts +58 -0
  55. package/dist/observability/index.d.ts +34 -14
  56. package/dist/observability/index.js +6 -4
  57. package/dist/react.d.ts +13 -7
  58. package/dist/react.js +107 -7
  59. package/dist/react.js.map +1 -1
  60. package/dist/schedule.d.ts +79 -5
  61. package/dist/schedule.js +17 -2
  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/package.json +32 -9
  66. package/src/index.ts +272 -136
  67. package/dist/chunk-HY7ZLHJB.js.map +0 -1
  68. package/dist/chunk-KUH345EY.js.map +0 -1
  69. package/dist/chunk-OJFA7RKX.js.map +0 -1
  70. package/dist/chunk-PVQZBKN7.js.map +0 -1
  71. package/dist/index-BVoermIz.d.ts +0 -615
@@ -1,99 +1,77 @@
1
- import { M as MCPClientManager } from '../client-CH-eFIfq.js';
2
- export { S as SSEEdgeClientTransport, a as StreamableHTTPEdgeClientTransport } from '../client-CH-eFIfq.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-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
10
  import '@modelcontextprotocol/sdk/client/index.js';
11
- import '@modelcontextprotocol/sdk/shared/protocol.js';
11
+ import '../observability/index.js';
12
+ import '../mcp-BH1fJeiU.js';
13
+ import '../ai-types.js';
12
14
  import 'ai';
15
+ import 'zod';
16
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
13
17
  import '@modelcontextprotocol/sdk/client/sse.js';
14
18
  import '@modelcontextprotocol/sdk/client/streamableHttp.js';
15
19
  import './do-oauth-client-provider.js';
16
20
  import '@modelcontextprotocol/sdk/client/auth.js';
17
21
  import '@modelcontextprotocol/sdk/shared/auth.js';
18
22
 
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;
23
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
29
24
  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
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}`.
41
33
  */
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
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}`.
48
38
  */
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 */
49
54
  elicitInput(params: {
50
55
  message: string;
51
56
  requestedSchema: unknown;
52
57
  }): 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
- private _initialize;
66
- fetch(request: Request): Promise<Response>;
67
- getWebSocket(): WebSocket | null;
68
- getWebSocketForResponseID(id: string): WebSocket | null;
69
- onMessage(connection: Connection, event: WSMessage): Promise<void>;
70
- /**
71
- * Wait for elicitation response through storage polling
72
- */
58
+ /** Wait for elicitation response through storage polling */
73
59
  private _waitForElicitationResponse;
74
- /**
75
- * Handle elicitation responses */
60
+ /** Handle elicitation responses */
76
61
  private _handleElicitationResponse;
77
- onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
78
- webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
79
- webSocketError(ws: WebSocket, error: unknown): Promise<void>;
80
- webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
81
- static mount(path: string, { binding, corsOptions }?: {
82
- binding?: string;
83
- corsOptions?: CORSOptions;
84
- }): {
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): {
85
66
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
86
67
  };
87
- static serveSSE(path: string, { binding, corsOptions }?: {
88
- binding?: string;
89
- corsOptions?: CORSOptions;
90
- }): {
68
+ /**
69
+ * Legacy api
70
+ **/
71
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
91
72
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
92
73
  };
93
- static serve(path: string, { binding, corsOptions }?: {
94
- binding?: string;
95
- corsOptions?: CORSOptions;
96
- }): {
74
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
97
75
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
98
76
  };
99
77
  }