agents 0.0.0-e48e5f9 → 0.0.0-e777fdd

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 (67) hide show
  1. package/README.md +234 -6
  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 +12 -9
  5. package/dist/ai-chat-agent.js +151 -59
  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 +68 -71
  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-5Y6BEZDY.js +276 -0
  18. package/dist/chunk-5Y6BEZDY.js.map +1 -0
  19. package/dist/chunk-BER7KXUJ.js +18 -0
  20. package/dist/chunk-BER7KXUJ.js.map +1 -0
  21. package/dist/chunk-JJBFIGUC.js +5202 -0
  22. package/dist/chunk-JJBFIGUC.js.map +1 -0
  23. package/dist/chunk-PR4QN5HX.js +43 -0
  24. package/dist/chunk-PR4QN5HX.js.map +1 -0
  25. package/dist/{chunk-MW5BQ2FW.js → chunk-QEPGNUG6.js} +213 -32
  26. package/dist/chunk-QEPGNUG6.js.map +1 -0
  27. package/dist/{chunk-KUH345EY.js → chunk-QEVM4BVL.js} +5 -5
  28. package/dist/chunk-QEVM4BVL.js.map +1 -0
  29. package/dist/{chunk-5YIRLLUX.js → chunk-RS5OCNEQ.js} +169 -110
  30. package/dist/chunk-RS5OCNEQ.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-XFS5ERG3.js} +24 -3
  36. package/dist/chunk-XFS5ERG3.js.map +1 -0
  37. package/dist/client-BohGLma8.d.ts +5041 -0
  38. package/dist/client.js +3 -1
  39. package/dist/index.d.ts +564 -32
  40. package/dist/index.js +8 -4
  41. package/dist/mcp/client.d.ts +9 -1053
  42. package/dist/mcp/client.js +2 -1
  43. package/dist/mcp/do-oauth-client-provider.d.ts +9 -0
  44. package/dist/mcp/do-oauth-client-provider.js +2 -1
  45. package/dist/mcp/index.d.ts +57 -63
  46. package/dist/mcp/index.js +954 -638
  47. package/dist/mcp/index.js.map +1 -1
  48. package/dist/mcp/x402.d.ts +39 -0
  49. package/dist/mcp/x402.js +3195 -0
  50. package/dist/mcp/x402.js.map +1 -0
  51. package/dist/observability/index.d.ts +46 -12
  52. package/dist/observability/index.js +6 -4
  53. package/dist/react.d.ts +7 -3
  54. package/dist/react.js +8 -5
  55. package/dist/react.js.map +1 -1
  56. package/dist/schedule.d.ts +83 -9
  57. package/dist/schedule.js +17 -2
  58. package/dist/schedule.js.map +1 -1
  59. package/dist/secp256k1-M22GZP2U.js +2193 -0
  60. package/dist/secp256k1-M22GZP2U.js.map +1 -0
  61. package/package.json +25 -9
  62. package/src/index.ts +240 -131
  63. package/dist/chunk-5YIRLLUX.js.map +0 -1
  64. package/dist/chunk-KUH345EY.js.map +0 -1
  65. package/dist/chunk-MW5BQ2FW.js.map +0 -1
  66. package/dist/chunk-PVQZBKN7.js.map +0 -1
  67. package/dist/index-BIJvkfYt.d.ts +0 -614
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  MCPClientManager,
3
3
  getNamespacedData
4
- } from "../chunk-MW5BQ2FW.js";
4
+ } from "../chunk-QEPGNUG6.js";
5
+ import "../chunk-PR4QN5HX.js";
5
6
  export {
6
7
  MCPClientManager,
7
8
  getNamespacedData
@@ -5,6 +5,9 @@ interface AgentsOAuthProvider extends OAuthClientProvider {
5
5
  authUrl: string | undefined;
6
6
  clientId: string | undefined;
7
7
  serverId: string | undefined;
8
+ saveOAuthTransport(transportType: string): Promise<void>;
9
+ getOAuthTransport(): Promise<string | undefined>;
10
+ clearOAuthTransport(): Promise<void>;
8
11
  }
9
12
  declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
10
13
  storage: DurableObjectStorage;
@@ -15,6 +18,7 @@ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
15
18
  private _clientId_;
16
19
  constructor(storage: DurableObjectStorage, clientName: string, baseRedirectUrl: string);
17
20
  get clientMetadata(): OAuthClientMetadata;
21
+ get clientUri(): string;
18
22
  get redirectUrl(): string;
19
23
  get clientId(): string;
20
24
  set clientId(clientId_: string);
@@ -36,6 +40,11 @@ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
36
40
  codeVerifierKey(clientId: string): string;
37
41
  saveCodeVerifier(verifier: string): Promise<void>;
38
42
  codeVerifier(): Promise<string>;
43
+ /** Transport tracking for OAuth flow */
44
+ oauthTransportKey(): string;
45
+ saveOAuthTransport(transportType: string): Promise<void>;
46
+ getOAuthTransport(): Promise<string | undefined>;
47
+ clearOAuthTransport(): Promise<void>;
39
48
  }
40
49
 
41
50
  export { type AgentsOAuthProvider, DurableObjectOAuthClientProvider };
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  DurableObjectOAuthClientProvider
3
- } from "../chunk-PVQZBKN7.js";
3
+ } from "../chunk-XFS5ERG3.js";
4
+ import "../chunk-PR4QN5HX.js";
4
5
  export {
5
6
  DurableObjectOAuthClientProvider
6
7
  };
@@ -1,82 +1,76 @@
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 '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-BohGLma8.js';
7
+ export { a as SSEEdgeClientTransport, b as StreamableHTTPEdgeClientTransport } from '../client-BohGLma8.js';
8
+ import { Connection, ConnectionContext } from 'partyserver';
9
+ import 'cloudflare:workers';
7
10
  import '@modelcontextprotocol/sdk/client/index.js';
8
- import '@modelcontextprotocol/sdk/client/sse.js';
9
- import '@modelcontextprotocol/sdk/shared/protocol.js';
10
- import '@modelcontextprotocol/sdk/types.js';
11
+ import '../observability/index.js';
12
+ import '../ai-types.js';
11
13
  import 'ai';
14
+ import 'zod';
15
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
16
+ import '@modelcontextprotocol/sdk/client/sse.js';
17
+ import '@modelcontextprotocol/sdk/client/streamableHttp.js';
12
18
  import './do-oauth-client-provider.js';
13
19
  import '@modelcontextprotocol/sdk/client/auth.js';
14
20
  import '@modelcontextprotocol/sdk/shared/auth.js';
15
21
 
16
- interface CORSOptions {
17
- origin?: string;
18
- methods?: string;
19
- headers?: string;
20
- maxAge?: number;
21
- exposeHeaders?: string;
22
- }
23
- type MaybePromise<T> = T | Promise<T>;
24
- declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
25
- private _status;
22
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
26
23
  private _transport?;
27
- private _transportType;
28
- private _requestIdToConnectionId;
29
- /**
30
- * Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
31
- * to the outer class: initialState/state/setState/onStateUpdate/sql
24
+ props?: Props;
25
+ abstract server: MaybePromise<McpServer | Server>;
26
+ abstract init(): Promise<void>;
27
+ setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
28
+ getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
29
+ /** Read the transport type for this agent.
30
+ * This relies on the naming scheme being `sse:${sessionId}`
31
+ * or `streamable-http:${sessionId}`.
32
32
  */
33
- private _agent;
34
- get mcp(): MCPClientManager;
35
- protected constructor(ctx: DurableObjectState, env: Env);
36
- /**
37
- * Agents API allowlist
33
+ getTransportType(): BaseTransportType;
34
+ /** Read the sessionId for this agent.
35
+ * This relies on the naming scheme being `sse:${sessionId}`
36
+ * or `streamable-http:${sessionId}`.
38
37
  */
39
- initialState: State;
40
- get state(): State;
41
- sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
42
- setState(state: State): void;
43
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
44
- onStart(): Promise<void>;
45
- /**
46
- * McpAgent API
38
+ getSessionId(): string;
39
+ /** Get the unique WebSocket. SSE transport only. */
40
+ private getWebSocket;
41
+ /** Returns a new transport matching the type of the Agent. */
42
+ private initTransport;
43
+ /** Update and store the props */
44
+ updateProps(props?: Props): Promise<void>;
45
+ reinitializeServer(): Promise<void>;
46
+ /** Sets up the MCP transport and server every time the Agent is started.*/
47
+ onStart(props?: Props): Promise<void>;
48
+ /** Validates new WebSocket connections. */
49
+ onConnect(conn: Connection, { request: req }: ConnectionContext): Promise<void>;
50
+ /** Handles MCP Messages for the legacy SSE transport. */
51
+ onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
52
+ /** Elicit user input with a message and schema */
53
+ elicitInput(params: {
54
+ message: string;
55
+ requestedSchema: unknown;
56
+ }): Promise<ElicitResult>;
57
+ /** Wait for elicitation response through storage polling */
58
+ private _waitForElicitationResponse;
59
+ /** Handle elicitation responses */
60
+ private _handleElicitationResponse;
61
+ /** Return a handler for the given path for this MCP.
62
+ * Defaults to Streamable HTTP transport.
47
63
  */
48
- abstract server: MaybePromise<McpServer | Server>;
49
- props: Props;
50
- initRun: boolean;
51
- abstract init(): Promise<void>;
52
- _init(props: Props): Promise<void>;
53
- setInitialized(): Promise<void>;
54
- isInitialized(): Promise<boolean>;
55
- private _initialize;
56
- fetch(request: Request): Promise<Response>;
57
- getWebSocket(): WebSocket | null;
58
- getWebSocketForResponseID(id: string): WebSocket | null;
59
- onMessage(connection: Connection, event: WSMessage): Promise<void>;
60
- onSSEMcpMessage(_sessionId: string, request: Request): Promise<Error | null>;
61
- webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
62
- webSocketError(ws: WebSocket, error: unknown): Promise<void>;
63
- webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
64
- static mount(path: string, { binding, corsOptions }?: {
65
- binding?: string;
66
- corsOptions?: CORSOptions;
67
- }): {
64
+ static serve(path: string, { binding, corsOptions, transport }?: ServeOptions): {
68
65
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
69
66
  };
70
- static serveSSE(path: string, { binding, corsOptions }?: {
71
- binding?: string;
72
- corsOptions?: CORSOptions;
73
- }): {
67
+ /**
68
+ * Legacy api
69
+ **/
70
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
74
71
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
75
72
  };
76
- static serve(path: string, { binding, corsOptions }?: {
77
- binding?: string;
78
- corsOptions?: CORSOptions;
79
- }): {
73
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
80
74
  fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
81
75
  };
82
76
  }