agents 0.0.0-b63b4a6 → 0.0.0-b6af48a

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 (72) hide show
  1. package/README.md +130 -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 +11 -8
  5. package/dist/ai-chat-agent.js +485 -66
  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 +246 -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-DBXG3DYU.js → chunk-2Y6KNRNP.js} +188 -115
  18. package/dist/chunk-2Y6KNRNP.js.map +1 -0
  19. package/dist/chunk-5Y6BEZDY.js +276 -0
  20. package/dist/chunk-5Y6BEZDY.js.map +1 -0
  21. package/dist/chunk-BER7KXUJ.js +18 -0
  22. package/dist/chunk-BER7KXUJ.js.map +1 -0
  23. package/dist/{chunk-PVQZBKN7.js → chunk-C2OEBJZ2.js} +14 -7
  24. package/dist/chunk-C2OEBJZ2.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-QUOGV3WN.js +949 -0
  32. package/dist/chunk-QUOGV3WN.js.map +1 -0
  33. package/dist/chunk-TYAY6AU6.js +159 -0
  34. package/dist/chunk-TYAY6AU6.js.map +1 -0
  35. package/dist/chunk-UJVEAURM.js +150 -0
  36. package/dist/chunk-UJVEAURM.js.map +1 -0
  37. package/dist/client-C8tswVoM.d.ts +5248 -0
  38. package/dist/client.js +3 -1
  39. package/dist/codemode/ai.d.ts +25 -0
  40. package/dist/codemode/ai.js +5200 -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 +10 -1057
  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 +53 -96
  49. package/dist/mcp/index.js +925 -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 +38 -10
  66. package/src/index.ts +272 -136
  67. package/dist/chunk-DBXG3DYU.js.map +0 -1
  68. package/dist/chunk-KUH345EY.js.map +0 -1
  69. package/dist/chunk-PVQZBKN7.js.map +0 -1
  70. package/dist/chunk-UYXBO2TX.js +0 -566
  71. package/dist/chunk-UYXBO2TX.js.map +0 -1
  72. package/dist/index-CLW1aEBr.d.ts +0 -615
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  MCPClientManager,
3
3
  getNamespacedData
4
- } from "../chunk-UYXBO2TX.js";
4
+ } from "../chunk-QUOGV3WN.js";
5
+ import "../chunk-PR4QN5HX.js";
5
6
  export {
6
7
  MCPClientManager,
7
8
  getNamespacedData
@@ -15,6 +15,7 @@ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
15
15
  private _clientId_;
16
16
  constructor(storage: DurableObjectStorage, clientName: string, baseRedirectUrl: string);
17
17
  get clientMetadata(): OAuthClientMetadata;
18
+ get clientUri(): string;
18
19
  get redirectUrl(): string;
19
20
  get clientId(): string;
20
21
  set clientId(clientId_: string);
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  DurableObjectOAuthClientProvider
3
- } from "../chunk-PVQZBKN7.js";
3
+ } from "../chunk-C2OEBJZ2.js";
4
+ import "../chunk-PR4QN5HX.js";
4
5
  export {
5
6
  DurableObjectOAuthClientProvider
6
7
  };
@@ -1,122 +1,79 @@
1
- import { MCPClientManager } from './client.js';
2
- import { DurableObject } from 'cloudflare:workers';
3
1
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
- import { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
3
+ import { JSONRPCMessage, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
6
4
  export { ElicitRequest, ElicitRequestSchema, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
7
- import { Connection, WSMessage } from 'partyserver';
8
- import { SSEClientTransport, SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
9
- import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
10
- import 'zod';
5
+ import { Agent } from '../index.js';
6
+ import { M as MaybePromise, B as BaseTransportType, S as ServeOptions } from '../client-C8tswVoM.js';
7
+ export { d as MCPClientOAuthCallbackConfig, c as MCPClientOAuthResult, a as SSEEdgeClientTransport, b as StreamableHTTPEdgeClientTransport } from '../client-C8tswVoM.js';
8
+ import { Connection, ConnectionContext } from 'partyserver';
9
+ import 'cloudflare:workers';
11
10
  import '@modelcontextprotocol/sdk/client/index.js';
12
- import '@modelcontextprotocol/sdk/shared/protocol.js';
11
+ import '../observability/index.js';
12
+ import '../mcp-BH1fJeiU.js';
13
+ import '../ai-types.js';
13
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';
14
19
  import './do-oauth-client-provider.js';
15
20
  import '@modelcontextprotocol/sdk/client/auth.js';
16
21
  import '@modelcontextprotocol/sdk/shared/auth.js';
17
22
 
18
- declare class SSEEdgeClientTransport extends SSEClientTransport {
19
- private authProvider;
20
- /**
21
- * Creates a new EdgeSSEClientTransport, which overrides fetch to be compatible with the CF workers environment
22
- */
23
- constructor(url: URL, options: SSEClientTransportOptions);
24
- authHeaders(): Promise<{
25
- Authorization: string;
26
- } | undefined>;
27
- }
28
-
29
- declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTransport {
30
- private authProvider;
31
- /**
32
- * Creates a new StreamableHTTPEdgeClientTransport, which overrides fetch to be compatible with the CF workers environment
33
- */
34
- constructor(url: URL, options: StreamableHTTPClientTransportOptions);
35
- authHeaders(): Promise<{
36
- Authorization: string;
37
- } | undefined>;
38
- }
39
-
40
- interface CORSOptions {
41
- origin?: string;
42
- methods?: string;
43
- headers?: string;
44
- maxAge?: number;
45
- exposeHeaders?: string;
46
- }
47
- type MaybePromise<T> = T | Promise<T>;
48
- declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
49
- private _status;
23
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
50
24
  private _transport?;
51
- private _transportType;
52
- private _requestIdToConnectionId;
53
- /**
54
- * Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
55
- * to the outer class: initialState/state/setState/onStateUpdate/sql
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}`.
56
33
  */
57
- private _agent;
58
- get mcp(): MCPClientManager;
59
- protected constructor(ctx: DurableObjectState, env: Env);
60
- /**
61
- * Agents API allowlist
62
- */
63
- initialState: State;
64
- get state(): State;
65
- sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
66
- setState(state: State): void;
67
- /**
68
- * 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}`.
69
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 */
70
54
  elicitInput(params: {
71
55
  message: string;
72
56
  requestedSchema: unknown;
73
57
  }): Promise<ElicitResult>;
74
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
75
- onStart(): Promise<void>;
76
- /**
77
- * McpAgent API
78
- */
79
- abstract server: MaybePromise<McpServer | Server>;
80
- props: Props;
81
- initRun: boolean;
82
- abstract init(): Promise<void>;
83
- _init(props: Props): Promise<void>;
84
- setInitialized(): Promise<void>;
85
- isInitialized(): Promise<boolean>;
86
- private _initialize;
87
- fetch(request: Request): Promise<Response>;
88
- getWebSocket(): WebSocket | null;
89
- getWebSocketForResponseID(id: string): WebSocket | null;
90
- onMessage(connection: Connection, event: WSMessage): Promise<void>;
91
- /**
92
- * Wait for elicitation response through storage polling
93
- */
58
+ /** Wait for elicitation response through storage polling */
94
59
  private _waitForElicitationResponse;
95
- /**
96
- * Handle elicitation responses */
60
+ /** Handle elicitation responses */
97
61
  private _handleElicitationResponse;
98
- onSSEMcpMessage(_sessionId: string, request: Request): Promise<Error | null>;
99
- webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
100
- webSocketError(ws: WebSocket, error: unknown): Promise<void>;
101
- webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
102
- static mount(path: string, { binding, corsOptions }?: {
103
- binding?: string;
104
- corsOptions?: CORSOptions;
105
- }): {
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): {
106
66
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
107
67
  };
108
- static serveSSE(path: string, { binding, corsOptions }?: {
109
- binding?: string;
110
- corsOptions?: CORSOptions;
111
- }): {
68
+ /**
69
+ * Legacy api
70
+ **/
71
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
112
72
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
113
73
  };
114
- static serve(path: string, { binding, corsOptions }?: {
115
- binding?: string;
116
- corsOptions?: CORSOptions;
117
- }): {
74
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
118
75
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
119
76
  };
120
77
  }
121
78
 
122
- export { McpAgent, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport };
79
+ export { McpAgent };