agents 0.0.0-c3e8618 → 0.0.0-c41ebbc

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 (76) 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 +78 -23
  5. package/dist/ai-chat-agent.js +657 -0
  6. package/dist/ai-chat-agent.js.map +1 -0
  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 +86 -47
  11. package/dist/ai-react.js +356 -0
  12. package/dist/ai-react.js.map +1 -0
  13. package/dist/ai-types.d.ts +84 -41
  14. package/dist/ai-types.js +8 -0
  15. package/dist/ai-types.js.map +1 -0
  16. package/dist/ccip-CMBYN64O.js +15 -0
  17. package/dist/ccip-CMBYN64O.js.map +1 -0
  18. package/dist/chunk-5Y6BEZDY.js +276 -0
  19. package/dist/chunk-5Y6BEZDY.js.map +1 -0
  20. package/dist/chunk-BER7KXUJ.js +18 -0
  21. package/dist/chunk-BER7KXUJ.js.map +1 -0
  22. package/dist/chunk-C2OEBJZ2.js +113 -0
  23. package/dist/chunk-C2OEBJZ2.js.map +1 -0
  24. package/dist/chunk-JJBFIGUC.js +5202 -0
  25. package/dist/chunk-JJBFIGUC.js.map +1 -0
  26. package/dist/chunk-PR4QN5HX.js +43 -0
  27. package/dist/chunk-PR4QN5HX.js.map +1 -0
  28. package/dist/chunk-QEVM4BVL.js +116 -0
  29. package/dist/chunk-QEVM4BVL.js.map +1 -0
  30. package/dist/chunk-TYAY6AU6.js +159 -0
  31. package/dist/chunk-TYAY6AU6.js.map +1 -0
  32. package/dist/chunk-UJVEAURM.js +150 -0
  33. package/dist/chunk-UJVEAURM.js.map +1 -0
  34. package/dist/chunk-XGMKNUJA.js +1343 -0
  35. package/dist/chunk-XGMKNUJA.js.map +1 -0
  36. package/dist/chunk-ZMMHNOMZ.js +942 -0
  37. package/dist/chunk-ZMMHNOMZ.js.map +1 -0
  38. package/dist/client-D1Fa-xS_.d.ts +5120 -0
  39. package/dist/client.d.ts +71 -37
  40. package/dist/client.js +13 -0
  41. package/dist/client.js.map +1 -0
  42. package/dist/codemode/ai.d.ts +25 -0
  43. package/dist/codemode/ai.js +5200 -0
  44. package/dist/codemode/ai.js.map +1 -0
  45. package/dist/index.d.ts +479 -181
  46. package/dist/index.js +32 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/mcp/client.d.ts +12 -675
  49. package/dist/mcp/client.js +10 -0
  50. package/dist/mcp/client.js.map +1 -0
  51. package/dist/mcp/do-oauth-client-provider.d.ts +42 -0
  52. package/dist/mcp/do-oauth-client-provider.js +8 -0
  53. package/dist/mcp/do-oauth-client-provider.js.map +1 -0
  54. package/dist/mcp/index.d.ts +71 -33
  55. package/dist/mcp/index.js +1099 -0
  56. package/dist/mcp/index.js.map +1 -0
  57. package/dist/mcp/x402.d.ts +39 -0
  58. package/dist/mcp/x402.js +3195 -0
  59. package/dist/mcp/x402.js.map +1 -0
  60. package/dist/mcp-BH1fJeiU.d.ts +58 -0
  61. package/dist/observability/index.d.ts +34 -0
  62. package/dist/observability/index.js +12 -0
  63. package/dist/observability/index.js.map +1 -0
  64. package/dist/react.d.ts +115 -18
  65. package/dist/react.js +216 -0
  66. package/dist/react.js.map +1 -0
  67. package/dist/schedule.d.ts +106 -22
  68. package/dist/schedule.js +86 -0
  69. package/dist/schedule.js.map +1 -0
  70. package/dist/secp256k1-M22GZP2U.js +2193 -0
  71. package/dist/secp256k1-M22GZP2U.js.map +1 -0
  72. package/dist/serializable.d.ts +32 -0
  73. package/dist/serializable.js +1 -0
  74. package/dist/serializable.js.map +1 -0
  75. package/package.json +103 -52
  76. package/src/index.ts +1268 -156
@@ -0,0 +1,10 @@
1
+ import {
2
+ MCPClientManager,
3
+ getNamespacedData
4
+ } from "../chunk-ZMMHNOMZ.js";
5
+ import "../chunk-PR4QN5HX.js";
6
+ export {
7
+ MCPClientManager,
8
+ getNamespacedData
9
+ };
10
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,42 @@
1
+ import { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
2
+ import { OAuthClientMetadata, OAuthClientInformation, OAuthClientInformationFull, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
3
+
4
+ interface AgentsOAuthProvider extends OAuthClientProvider {
5
+ authUrl: string | undefined;
6
+ clientId: string | undefined;
7
+ serverId: string | undefined;
8
+ }
9
+ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
10
+ storage: DurableObjectStorage;
11
+ clientName: string;
12
+ baseRedirectUrl: string;
13
+ private _authUrl_;
14
+ private _serverId_;
15
+ private _clientId_;
16
+ constructor(storage: DurableObjectStorage, clientName: string, baseRedirectUrl: string);
17
+ get clientMetadata(): OAuthClientMetadata;
18
+ get clientUri(): string;
19
+ get redirectUrl(): string;
20
+ get clientId(): string;
21
+ set clientId(clientId_: string);
22
+ get serverId(): string;
23
+ set serverId(serverId_: string);
24
+ keyPrefix(clientId: string): string;
25
+ clientInfoKey(clientId: string): string;
26
+ clientInformation(): Promise<OAuthClientInformation | undefined>;
27
+ saveClientInformation(clientInformation: OAuthClientInformationFull): Promise<void>;
28
+ tokenKey(clientId: string): string;
29
+ tokens(): Promise<OAuthTokens | undefined>;
30
+ saveTokens(tokens: OAuthTokens): Promise<void>;
31
+ get authUrl(): string | undefined;
32
+ /**
33
+ * Because this operates on the server side (but we need browser auth), we send this url back to the user
34
+ * and require user interact to initiate the redirect flow
35
+ */
36
+ redirectToAuthorization(authUrl: URL): Promise<void>;
37
+ codeVerifierKey(clientId: string): string;
38
+ saveCodeVerifier(verifier: string): Promise<void>;
39
+ codeVerifier(): Promise<string>;
40
+ }
41
+
42
+ export { type AgentsOAuthProvider, DurableObjectOAuthClientProvider };
@@ -0,0 +1,8 @@
1
+ import {
2
+ DurableObjectOAuthClientProvider
3
+ } from "../chunk-C2OEBJZ2.js";
4
+ import "../chunk-PR4QN5HX.js";
5
+ export {
6
+ DurableObjectOAuthClientProvider
7
+ };
8
+ //# sourceMappingURL=do-oauth-client-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,40 +1,78 @@
1
- import { DurableObject } from 'cloudflare:workers';
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
- import { Connection } from 'partyserver';
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-D1Fa-xS_.js';
7
+ export { d as MCPClientOAuthCallbackConfig, c as MCPClientOAuthResult, a as SSEEdgeClientTransport, b as StreamableHTTPEdgeClientTransport } from '../client-D1Fa-xS_.js';
8
+ import { Connection, ConnectionContext } from 'partyserver';
9
+ import 'cloudflare:workers';
10
+ import '@modelcontextprotocol/sdk/client/index.js';
11
+ import '../observability/index.js';
12
+ import '../mcp-BH1fJeiU.js';
13
+ import '../ai-types.js';
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';
19
+ import './do-oauth-client-provider.js';
20
+ import '@modelcontextprotocol/sdk/client/auth.js';
21
+ import '@modelcontextprotocol/sdk/shared/auth.js';
4
22
 
5
- interface CORSOptions {
6
- origin?: string;
7
- methods?: string;
8
- headers?: string;
9
- maxAge?: number;
10
- }
11
- declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
12
- #private;
13
- protected constructor(ctx: DurableObjectState, env: Env);
14
- /**
15
- * Agents API allowlist
23
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
24
+ private _transport?;
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}`.
16
33
  */
17
- initialState: State;
18
- get state(): State;
19
- sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
20
- setState(state: State): void;
21
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
22
- /**
23
- * McpAgent API
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}`.
24
38
  */
25
- abstract server: McpServer;
26
- private transport;
27
- props: Props;
28
- initRun: boolean;
29
- abstract init(): Promise<void>;
30
- _init(props: Props): Promise<void>;
31
- onSSE(path: string): Promise<Response>;
32
- onMCPMessage(request: Request): Promise<Response>;
33
- static mount(path: string, { binding, corsOptions, }?: {
34
- binding?: string;
35
- corsOptions?: CORSOptions;
36
- }): {
37
- fetch: (request: Request, env: Record<string, DurableObjectNamespace<McpAgent>>, ctx: ExecutionContext) => Promise<Response>;
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.
64
+ */
65
+ static serve(path: string, { binding, corsOptions, transport }?: ServeOptions): {
66
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
67
+ };
68
+ /**
69
+ * Legacy api
70
+ **/
71
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
72
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
73
+ };
74
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
75
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
38
76
  };
39
77
  }
40
78