agents 0.0.0-e4a2352 → 0.0.0-e8f693b

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 (77) hide show
  1. package/README.md +129 -7
  2. package/dist/ai-chat-agent.d.ts +20 -20
  3. package/dist/ai-chat-agent.js +532 -260
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-chat-v5-migration-DBHGW4Hv.js +155 -0
  6. package/dist/ai-chat-v5-migration-DBHGW4Hv.js.map +1 -0
  7. package/dist/ai-chat-v5-migration.d.ts +155 -0
  8. package/dist/ai-chat-v5-migration.js +3 -0
  9. package/dist/ai-react.d.ts +73 -87
  10. package/dist/ai-react.js +261 -199
  11. package/dist/ai-react.js.map +1 -1
  12. package/dist/ai-types-B3aQaFv3.js +20 -0
  13. package/dist/ai-types-B3aQaFv3.js.map +1 -0
  14. package/dist/ai-types-D5YoPrBZ.d.ts +95 -0
  15. package/dist/ai-types.d.ts +6 -74
  16. package/dist/ai-types.js +3 -1
  17. package/dist/client-9Ld2_lnt.js +786 -0
  18. package/dist/client-9Ld2_lnt.js.map +1 -0
  19. package/dist/client-B17XUTV7.d.ts +5313 -0
  20. package/dist/client-BfiZ3HQd.js +117 -0
  21. package/dist/client-BfiZ3HQd.js.map +1 -0
  22. package/dist/client-CbWe9FBd.d.ts +104 -0
  23. package/dist/client.d.ts +11 -92
  24. package/dist/client.js +4 -11
  25. package/dist/codemode/ai.d.ts +27 -0
  26. package/dist/codemode/ai.js +151 -0
  27. package/dist/codemode/ai.js.map +1 -0
  28. package/dist/do-oauth-client-provider-CswoD5Lu.js +93 -0
  29. package/dist/do-oauth-client-provider-CswoD5Lu.js.map +1 -0
  30. package/dist/do-oauth-client-provider-DGc5pP0l.d.ts +55 -0
  31. package/dist/{index-BCJclX6q.d.ts → index-B6MjW6n-.d.ts} +100 -155
  32. package/dist/index-DhJCaDWd.d.ts +58 -0
  33. package/dist/index.d.ts +69 -40
  34. package/dist/index.js +7 -28
  35. package/dist/mcp/client.d.ts +4 -11
  36. package/dist/mcp/client.js +3 -9
  37. package/dist/mcp/do-oauth-client-provider.d.ts +2 -41
  38. package/dist/mcp/do-oauth-client-provider.js +3 -7
  39. package/dist/mcp/index.d.ts +126 -99
  40. package/dist/mcp/index.js +1222 -901
  41. package/dist/mcp/index.js.map +1 -1
  42. package/dist/mcp/x402.d.ts +34 -0
  43. package/dist/mcp/x402.js +194 -0
  44. package/dist/mcp/x402.js.map +1 -0
  45. package/dist/mcp-Dw5vDrY8.d.ts +61 -0
  46. package/dist/observability/index.d.ts +3 -14
  47. package/dist/observability/index.js +7 -10
  48. package/dist/react-CRBsIQ1z.d.ts +115 -0
  49. package/dist/react.d.ts +10 -121
  50. package/dist/react.js +183 -110
  51. package/dist/react.js.map +1 -1
  52. package/dist/schedule.d.ts +87 -10
  53. package/dist/schedule.js +46 -21
  54. package/dist/schedule.js.map +1 -1
  55. package/dist/serializable-CymX8ovI.d.ts +39 -0
  56. package/dist/serializable.d.ts +7 -32
  57. package/dist/serializable.js +1 -1
  58. package/dist/src-Dz0H9hSU.js +1200 -0
  59. package/dist/src-Dz0H9hSU.js.map +1 -0
  60. package/package.json +45 -11
  61. package/dist/ai-types.js.map +0 -1
  62. package/dist/chunk-HY7ZLHJB.js +0 -598
  63. package/dist/chunk-HY7ZLHJB.js.map +0 -1
  64. package/dist/chunk-JXN5WZFQ.js +0 -1287
  65. package/dist/chunk-JXN5WZFQ.js.map +0 -1
  66. package/dist/chunk-KUH345EY.js +0 -116
  67. package/dist/chunk-KUH345EY.js.map +0 -1
  68. package/dist/chunk-PVQZBKN7.js +0 -106
  69. package/dist/chunk-PVQZBKN7.js.map +0 -1
  70. package/dist/client-DgyzBU_8.d.ts +0 -4601
  71. package/dist/client.js.map +0 -1
  72. package/dist/index.js.map +0 -1
  73. package/dist/mcp/client.js.map +0 -1
  74. package/dist/mcp/do-oauth-client-provider.js.map +0 -1
  75. package/dist/observability/index.js.map +0 -1
  76. package/dist/serializable.js.map +0 -1
  77. package/src/index.ts +0 -1917
@@ -1,41 +1,2 @@
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 redirectUrl(): string;
19
- get clientId(): string;
20
- set clientId(clientId_: string);
21
- get serverId(): string;
22
- set serverId(serverId_: string);
23
- keyPrefix(clientId: string): string;
24
- clientInfoKey(clientId: string): string;
25
- clientInformation(): Promise<OAuthClientInformation | undefined>;
26
- saveClientInformation(clientInformation: OAuthClientInformationFull): Promise<void>;
27
- tokenKey(clientId: string): string;
28
- tokens(): Promise<OAuthTokens | undefined>;
29
- saveTokens(tokens: OAuthTokens): Promise<void>;
30
- get authUrl(): string | undefined;
31
- /**
32
- * Because this operates on the server side (but we need browser auth), we send this url back to the user
33
- * and require user interact to initiate the redirect flow
34
- */
35
- redirectToAuthorization(authUrl: URL): Promise<void>;
36
- codeVerifierKey(clientId: string): string;
37
- saveCodeVerifier(verifier: string): Promise<void>;
38
- codeVerifier(): Promise<string>;
39
- }
40
-
41
- export { type AgentsOAuthProvider, DurableObjectOAuthClientProvider };
1
+ import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider-DGc5pP0l.js";
2
+ export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
@@ -1,7 +1,3 @@
1
- import {
2
- DurableObjectOAuthClientProvider
3
- } from "../chunk-PVQZBKN7.js";
4
- export {
5
- DurableObjectOAuthClientProvider
6
- };
7
- //# sourceMappingURL=do-oauth-client-provider.js.map
1
+ import { t as DurableObjectOAuthClientProvider } from "../do-oauth-client-provider-CswoD5Lu.js";
2
+
3
+ export { DurableObjectOAuthClientProvider };
@@ -1,102 +1,129 @@
1
- import { M as MCPClientManager } from '../client-DgyzBU_8.js';
2
- export { S as SSEEdgeClientTransport, a as StreamableHTTPEdgeClientTransport } from '../client-DgyzBU_8.js';
3
- import { DurableObject } from 'cloudflare:workers';
4
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
7
- export { ElicitRequest, ElicitRequestSchema, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
8
- import { Connection, WSMessage } from 'partyserver';
9
- import 'zod';
10
- import '@modelcontextprotocol/sdk/client/index.js';
11
- import '@modelcontextprotocol/sdk/shared/protocol.js';
12
- import 'ai';
13
- import '@modelcontextprotocol/sdk/client/sse.js';
14
- import '@modelcontextprotocol/sdk/client/streamableHttp.js';
15
- import './do-oauth-client-provider.js';
16
- import '@modelcontextprotocol/sdk/client/auth.js';
17
- import '@modelcontextprotocol/sdk/shared/auth.js';
1
+ import { c as ServeOptions, d as SSEEdgeClientTransport, n as MCPClientOAuthCallbackConfig, o as BaseTransportType, r as MCPClientOAuthResult, s as MaybePromise, u as StreamableHTTPEdgeClientTransport } from "../client-B17XUTV7.js";
2
+ import "../mcp-Dw5vDrY8.js";
3
+ import "../do-oauth-client-provider-DGc5pP0l.js";
4
+ import "../index-DhJCaDWd.js";
5
+ import "../ai-types-D5YoPrBZ.js";
6
+ import { c as ConnectionContext, s as Connection, t as Agent } from "../index-B6MjW6n-.js";
7
+ import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js";
8
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
9
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
+ import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
18
11
 
19
- interface CORSOptions {
20
- origin?: string;
21
- methods?: string;
22
- headers?: string;
23
- maxAge?: number;
24
- exposeHeaders?: string;
12
+ //#region src/mcp/worker-transport.d.ts
13
+ interface WorkerTransportOptions {
14
+ sessionIdGenerator?: () => string;
15
+ enableJsonResponse?: boolean;
16
+ onsessioninitialized?: (sessionId: string) => void;
25
17
  }
26
- type MaybePromise<T> = T | Promise<T>;
27
- declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
28
- private _status;
29
- private _transport?;
30
- private _transportType;
31
- private _requestIdToConnectionId;
32
- /**
33
- * Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
34
- * to the outer class: initialState/state/setState/onStateUpdate/sql
35
- */
36
- private _agent;
37
- get mcp(): MCPClientManager;
38
- protected constructor(ctx: DurableObjectState, env: Env);
39
- /**
40
- * Agents API allowlist
41
- */
42
- initialState: State;
43
- get state(): State;
44
- sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
45
- setState(state: State): void;
46
- /**
47
- * Elicit user input with a message and schema
48
- */
49
- elicitInput(params: {
50
- message: string;
51
- requestedSchema: unknown;
52
- }): Promise<ElicitResult>;
53
- onStateUpdate(state: State | undefined, source: Connection | "server"): void;
54
- onStart(): Promise<void>;
55
- /**
56
- * McpAgent API
57
- */
58
- abstract server: MaybePromise<McpServer | Server>;
59
- props: Props;
60
- initRun: boolean;
61
- abstract init(): Promise<void>;
62
- _init(props: Props): Promise<void>;
63
- setInitialized(): Promise<void>;
64
- isInitialized(): Promise<boolean>;
65
- updateProps(props: Props): Promise<void>;
66
- private _initialize;
67
- fetch(request: Request): Promise<Response>;
68
- getWebSocket(): WebSocket | null;
69
- getWebSocketForResponseID(id: string): WebSocket | null;
70
- onMessage(connection: Connection, event: WSMessage): Promise<void>;
71
- /**
72
- * Wait for elicitation response through storage polling
73
- */
74
- private _waitForElicitationResponse;
75
- /**
76
- * Handle elicitation responses */
77
- private _handleElicitationResponse;
78
- onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
79
- webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
80
- webSocketError(ws: WebSocket, error: unknown): Promise<void>;
81
- webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
82
- static mount(path: string, { binding, corsOptions }?: {
83
- binding?: string;
84
- corsOptions?: CORSOptions;
85
- }): {
86
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
87
- };
88
- static serveSSE(path: string, { binding, corsOptions }?: {
89
- binding?: string;
90
- corsOptions?: CORSOptions;
91
- }): {
92
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
93
- };
94
- static serve(path: string, { binding, corsOptions }?: {
95
- binding?: string;
96
- corsOptions?: CORSOptions;
97
- }): {
98
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
99
- };
18
+ declare class WorkerTransport implements Transport {
19
+ private started;
20
+ private initialized;
21
+ private sessionIdGenerator?;
22
+ private enableJsonResponse;
23
+ private onsessioninitialized?;
24
+ private standaloneSseStreamId;
25
+ private streamMapping;
26
+ private requestToStreamMapping;
27
+ private requestResponseMap;
28
+ sessionId?: string;
29
+ onclose?: () => void;
30
+ onerror?: (error: Error) => void;
31
+ onmessage?: (message: JSONRPCMessage) => void;
32
+ constructor(options?: WorkerTransportOptions);
33
+ start(): Promise<void>;
34
+ handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
35
+ private handleGetRequest;
36
+ private handlePostRequest;
37
+ private handleDeleteRequest;
38
+ private handleOptionsRequest;
39
+ private handleUnsupportedRequest;
40
+ private validateSession;
41
+ close(): Promise<void>;
42
+ send(message: JSONRPCMessage): Promise<void>;
100
43
  }
101
-
102
- export { McpAgent };
44
+ //#endregion
45
+ //#region src/mcp/handler.d.ts
46
+ interface CreateMcpHandlerOptions extends WorkerTransportOptions {
47
+ /**
48
+ * The route path that this MCP handler should respond to.
49
+ * If specified, the handler will only process requests that match this route.
50
+ * @default "/mcp"
51
+ */
52
+ route?: string;
53
+ }
54
+ type OAuthExecutionContext = ExecutionContext & {
55
+ props?: Record<string, unknown>;
56
+ };
57
+ declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
58
+ //#endregion
59
+ //#region src/mcp/auth-context.d.ts
60
+ interface McpAuthContext {
61
+ props: Record<string, unknown>;
62
+ }
63
+ declare function getMcpAuthContext(): McpAuthContext | undefined;
64
+ //#endregion
65
+ //#region src/mcp/index.d.ts
66
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
67
+ private _transport?;
68
+ props?: Props;
69
+ abstract server: MaybePromise<McpServer | Server>;
70
+ abstract init(): Promise<void>;
71
+ setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
72
+ getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
73
+ /** Read the transport type for this agent.
74
+ * This relies on the naming scheme being `sse:${sessionId}`
75
+ * or `streamable-http:${sessionId}`.
76
+ */
77
+ getTransportType(): BaseTransportType;
78
+ /** Read the sessionId for this agent.
79
+ * This relies on the naming scheme being `sse:${sessionId}`
80
+ * or `streamable-http:${sessionId}`.
81
+ */
82
+ getSessionId(): string;
83
+ /** Get the unique WebSocket. SSE transport only. */
84
+ private getWebSocket;
85
+ /** Returns a new transport matching the type of the Agent. */
86
+ private initTransport;
87
+ /** Update and store the props */
88
+ updateProps(props?: Props): Promise<void>;
89
+ reinitializeServer(): Promise<void>;
90
+ /** Sets up the MCP transport and server every time the Agent is started.*/
91
+ onStart(props?: Props): Promise<void>;
92
+ /** Validates new WebSocket connections. */
93
+ onConnect(conn: Connection, {
94
+ request: req
95
+ }: ConnectionContext): Promise<void>;
96
+ /** Handles MCP Messages for the legacy SSE transport. */
97
+ onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
98
+ /** Elicit user input with a message and schema */
99
+ elicitInput(params: {
100
+ message: string;
101
+ requestedSchema: unknown;
102
+ }): Promise<ElicitResult$1>;
103
+ /** Wait for elicitation response through storage polling */
104
+ private _waitForElicitationResponse;
105
+ /** Handle elicitation responses */
106
+ private _handleElicitationResponse;
107
+ /** Return a handler for the given path for this MCP.
108
+ * Defaults to Streamable HTTP transport.
109
+ */
110
+ static serve(path: string, {
111
+ binding,
112
+ corsOptions,
113
+ transport
114
+ }?: ServeOptions): {
115
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
116
+ };
117
+ /**
118
+ * Legacy api
119
+ **/
120
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
121
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
122
+ };
123
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
124
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
125
+ };
126
+ }
127
+ //#endregion
128
+ export { type CreateMcpHandlerOptions, type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, McpAgent, type McpAuthContext, type OAuthExecutionContext, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport, WorkerTransport, type WorkerTransportOptions, experimental_createMcpHandler, getMcpAuthContext };
129
+ //# sourceMappingURL=index.d.ts.map