agents 0.0.0-fb503ba → 0.0.0-fb62d22

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 (69) 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 +12 -8
  5. package/dist/ai-chat-agent.js +482 -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 +69 -72
  11. package/dist/ai-react.js +260 -107
  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-OYJXQRRH.js → chunk-QEPGNUG6.js} +230 -45
  26. package/dist/chunk-QEPGNUG6.js.map +1 -0
  27. package/dist/{chunk-VCSB47AK.js → chunk-QEVM4BVL.js} +10 -10
  28. package/dist/chunk-QEVM4BVL.js.map +1 -0
  29. package/dist/chunk-RS5OCNEQ.js +1323 -0
  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-BZXOAZUX.js → chunk-XFS5ERG3.js} +27 -6
  36. package/dist/chunk-XFS5ERG3.js.map +1 -0
  37. package/dist/client-DNEb-lf3.d.ts +5041 -0
  38. package/dist/client.d.ts +2 -2
  39. package/dist/client.js +3 -1
  40. package/dist/index.d.ts +186 -26
  41. package/dist/index.js +14 -4
  42. package/dist/mcp/client.d.ts +9 -781
  43. package/dist/mcp/client.js +2 -1
  44. package/dist/mcp/do-oauth-client-provider.d.ts +9 -0
  45. package/dist/mcp/do-oauth-client-provider.js +2 -1
  46. package/dist/mcp/index.d.ts +58 -64
  47. package/dist/mcp/index.js +956 -639
  48. package/dist/mcp/index.js.map +1 -1
  49. package/dist/mcp/x402.d.ts +39 -0
  50. package/dist/mcp/x402.js +3195 -0
  51. package/dist/mcp/x402.js.map +1 -0
  52. package/dist/observability/index.d.ts +46 -0
  53. package/dist/observability/index.js +12 -0
  54. package/dist/observability/index.js.map +1 -0
  55. package/dist/react.d.ts +12 -8
  56. package/dist/react.js +13 -10
  57. package/dist/react.js.map +1 -1
  58. package/dist/schedule.d.ts +81 -7
  59. package/dist/schedule.js +21 -6
  60. package/dist/schedule.js.map +1 -1
  61. package/dist/secp256k1-M22GZP2U.js +2193 -0
  62. package/dist/secp256k1-M22GZP2U.js.map +1 -0
  63. package/package.json +91 -70
  64. package/src/index.ts +923 -190
  65. package/dist/chunk-BZXOAZUX.js.map +0 -1
  66. package/dist/chunk-MXJNY43J.js +0 -785
  67. package/dist/chunk-MXJNY43J.js.map +0 -1
  68. package/dist/chunk-OYJXQRRH.js.map +0 -1
  69. package/dist/chunk-VCSB47AK.js.map +0 -1
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  MCPClientManager,
3
3
  getNamespacedData
4
- } from "../chunk-OYJXQRRH.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-BZXOAZUX.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
- import { Connection, WSMessage } from 'partyserver';
4
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
1
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
- import 'zod';
7
- import '@modelcontextprotocol/sdk/types.js';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
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-DNEb-lf3.js';
7
+ export { a as SSEEdgeClientTransport, b as StreamableHTTPEdgeClientTransport } from '../client-DNEb-lf3.js';
8
+ import { Connection, ConnectionContext } from 'partyserver';
9
+ import 'cloudflare:workers';
8
10
  import '@modelcontextprotocol/sdk/client/index.js';
11
+ import '../observability/index.js';
12
+ import '../ai-types.js';
13
+ import 'ai';
14
+ import 'zod';
15
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
9
16
  import '@modelcontextprotocol/sdk/client/sse.js';
17
+ import '@modelcontextprotocol/sdk/client/streamableHttp.js';
10
18
  import './do-oauth-client-provider.js';
11
19
  import '@modelcontextprotocol/sdk/client/auth.js';
12
20
  import '@modelcontextprotocol/sdk/shared/auth.js';
13
- import '@modelcontextprotocol/sdk/shared/protocol.js';
14
- import 'ai';
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
  }