agents 0.0.0-b5aee9f → 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-3IQQY2UH.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 -1052
  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 +59 -87
  49. package/dist/mcp/index.js +964 -647
  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 +83 -9
  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-3IQQY2UH.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-UNG3FXYX.js +0 -525
  71. package/dist/chunk-UNG3FXYX.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-UNG3FXYX.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,107 +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 { Connection, WSMessage } from 'partyserver';
6
- import { SSEClientTransport, SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
7
- import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
8
- import 'zod';
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-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';
9
10
  import '@modelcontextprotocol/sdk/client/index.js';
10
- import '@modelcontextprotocol/sdk/shared/protocol.js';
11
- import '@modelcontextprotocol/sdk/types.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';
17
+ import '@modelcontextprotocol/sdk/client/sse.js';
18
+ import '@modelcontextprotocol/sdk/client/streamableHttp.js';
13
19
  import './do-oauth-client-provider.js';
14
20
  import '@modelcontextprotocol/sdk/client/auth.js';
15
21
  import '@modelcontextprotocol/sdk/shared/auth.js';
16
22
 
17
- declare class SSEEdgeClientTransport extends SSEClientTransport {
18
- private authProvider;
19
- /**
20
- * Creates a new EdgeSSEClientTransport, which overrides fetch to be compatible with the CF workers environment
21
- */
22
- constructor(url: URL, options: SSEClientTransportOptions);
23
- authHeaders(): Promise<{
24
- Authorization: string;
25
- } | undefined>;
26
- }
27
-
28
- declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTransport {
29
- private authProvider;
30
- /**
31
- * Creates a new StreamableHTTPEdgeClientTransport, which overrides fetch to be compatible with the CF workers environment
32
- */
33
- constructor(url: URL, options: StreamableHTTPClientTransportOptions);
34
- authHeaders(): Promise<{
35
- Authorization: string;
36
- } | undefined>;
37
- }
38
-
39
- interface CORSOptions {
40
- origin?: string;
41
- methods?: string;
42
- headers?: string;
43
- maxAge?: number;
44
- exposeHeaders?: string;
45
- }
46
- type MaybePromise<T> = T | Promise<T>;
47
- declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
48
- private _status;
23
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
49
24
  private _transport?;
50
- private _transportType;
51
- private _requestIdToConnectionId;
52
- /**
53
- * Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
54
- * 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}`.
55
33
  */
56
- private _agent;
57
- get mcp(): MCPClientManager;
58
- protected constructor(ctx: DurableObjectState, env: Env);
59
- /**
60
- * Agents API allowlist
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}`.
61
38
  */
62
- initialState: State;
63
- get state(): State;
64
- sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
65
- setState(state: State): void;
66
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
67
- onStart(): Promise<void>;
68
- /**
69
- * McpAgent API
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.
70
64
  */
71
- abstract server: MaybePromise<McpServer | Server>;
72
- props: Props;
73
- initRun: boolean;
74
- abstract init(): Promise<void>;
75
- _init(props: Props): Promise<void>;
76
- setInitialized(): Promise<void>;
77
- isInitialized(): Promise<boolean>;
78
- private _initialize;
79
- fetch(request: Request): Promise<Response>;
80
- getWebSocket(): WebSocket | null;
81
- getWebSocketForResponseID(id: string): WebSocket | null;
82
- onMessage(connection: Connection, event: WSMessage): Promise<void>;
83
- onSSEMcpMessage(_sessionId: string, request: Request): Promise<Error | null>;
84
- webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
85
- webSocketError(ws: WebSocket, error: unknown): Promise<void>;
86
- webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
87
- static mount(path: string, { binding, corsOptions }?: {
88
- binding?: string;
89
- corsOptions?: CORSOptions;
90
- }): {
65
+ static serve(path: string, { binding, corsOptions, transport }?: ServeOptions): {
91
66
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
92
67
  };
93
- static serveSSE(path: string, { binding, corsOptions }?: {
94
- binding?: string;
95
- corsOptions?: CORSOptions;
96
- }): {
68
+ /**
69
+ * Legacy api
70
+ **/
71
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
97
72
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
98
73
  };
99
- static serve(path: string, { binding, corsOptions }?: {
100
- binding?: string;
101
- corsOptions?: CORSOptions;
102
- }): {
74
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
103
75
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
104
76
  };
105
77
  }
106
78
 
107
- export { McpAgent, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport };
79
+ export { McpAgent };