agents 0.0.0-d40512c → 0.0.0-d4257c1

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 +234 -6
  2. package/dist/ai-chat-agent.d.ts +20 -18
  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-gdyLiTd8.js +155 -0
  6. package/dist/ai-chat-v5-migration-gdyLiTd8.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 -85
  10. package/dist/ai-react.js +260 -199
  11. package/dist/ai-react.js.map +1 -1
  12. package/dist/ai-types-BWW4umHY.d.ts +95 -0
  13. package/dist/ai-types-UZlfLOYP.js +20 -0
  14. package/dist/ai-types-UZlfLOYP.js.map +1 -0
  15. package/dist/ai-types.d.ts +6 -74
  16. package/dist/ai-types.js +3 -1
  17. package/dist/client-C-nwz-3N.d.ts +5313 -0
  18. package/dist/client-CZBVDDoO.js +786 -0
  19. package/dist/client-CZBVDDoO.js.map +1 -0
  20. package/dist/client-CmMi85Sj.d.ts +104 -0
  21. package/dist/client-DjR-lC16.js +117 -0
  22. package/dist/client-DjR-lC16.js.map +1 -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-B2jr6UNq.js +93 -0
  29. package/dist/do-oauth-client-provider-B2jr6UNq.js.map +1 -0
  30. package/dist/do-oauth-client-provider-CCwGwnrA.d.ts +55 -0
  31. package/dist/{index-CITGJflw.d.ts → index-CkQU40oY.d.ts} +219 -147
  32. package/dist/index-W4JUkafc.d.ts +54 -0
  33. package/dist/index.d.ts +69 -30
  34. package/dist/index.js +7 -22
  35. package/dist/mcp/client.d.ts +4 -1055
  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 +73 -82
  40. package/dist/mcp/index.js +836 -772
  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-BEwaCsxO.d.ts +61 -0
  46. package/dist/observability/index.d.ts +3 -12
  47. package/dist/observability/index.js +7 -10
  48. package/dist/react-B4e1rDid.d.ts +113 -0
  49. package/dist/react.d.ts +10 -119
  50. package/dist/react.js +183 -110
  51. package/dist/react.js.map +1 -1
  52. package/dist/schedule.d.ts +91 -14
  53. package/dist/schedule.js +46 -21
  54. package/dist/schedule.js.map +1 -1
  55. package/dist/serializable-gtr9YMhp.d.ts +34 -0
  56. package/dist/serializable.d.ts +7 -32
  57. package/dist/serializable.js +1 -1
  58. package/dist/src-COfG--3R.js +1179 -0
  59. package/dist/src-COfG--3R.js.map +1 -0
  60. package/package.json +45 -10
  61. package/src/index.ts +853 -187
  62. package/dist/ai-types.js.map +0 -1
  63. package/dist/chunk-4RBEYCWK.js +0 -469
  64. package/dist/chunk-4RBEYCWK.js.map +0 -1
  65. package/dist/chunk-KUH345EY.js +0 -116
  66. package/dist/chunk-KUH345EY.js.map +0 -1
  67. package/dist/chunk-LU2RSO54.js +0 -910
  68. package/dist/chunk-LU2RSO54.js.map +0 -1
  69. package/dist/chunk-PVQZBKN7.js +0 -106
  70. package/dist/chunk-PVQZBKN7.js.map +0 -1
  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
@@ -1,9 +1,3 @@
1
- import {
2
- MCPClientManager,
3
- getNamespacedData
4
- } from "../chunk-4RBEYCWK.js";
5
- export {
6
- MCPClientManager,
7
- getNamespacedData
8
- };
9
- //# sourceMappingURL=client.js.map
1
+ import { MCPClientManager, getNamespacedData } from "../client-CZBVDDoO.js";
2
+
3
+ export { MCPClientManager, getNamespacedData };
@@ -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 { AgentsOAuthProvider, DurableObjectOAuthClientProvider } from "../do-oauth-client-provider-CCwGwnrA.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 { DurableObjectOAuthClientProvider } from "../do-oauth-client-provider-B2jr6UNq.js";
2
+
3
+ export { DurableObjectOAuthClientProvider };
@@ -1,84 +1,75 @@
1
- import { MCPClientManager } from './client.js';
2
- import { DurableObject } from 'cloudflare:workers';
3
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
- import { Connection, WSMessage } from 'partyserver';
6
- import 'zod';
7
- 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 'ai';
12
- import './do-oauth-client-provider.js';
13
- import '@modelcontextprotocol/sdk/client/auth.js';
14
- import '@modelcontextprotocol/sdk/shared/auth.js';
1
+ import { BaseTransportType, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MaybePromise, SSEEdgeClientTransport, ServeOptions, StreamableHTTPEdgeClientTransport } from "../client-C-nwz-3N.js";
2
+ import "../mcp-BEwaCsxO.js";
3
+ import "../do-oauth-client-provider-CCwGwnrA.js";
4
+ import "../index-W4JUkafc.js";
5
+ import "../ai-types-BWW4umHY.js";
6
+ import { Agent, Connection, ConnectionContext } from "../index-CkQU40oY.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";
15
10
 
16
- interface CORSOptions {
17
- origin?: string;
18
- methods?: string;
19
- headers?: string;
20
- maxAge?: number;
21
- exposeHeaders?: string;
11
+ //#region src/mcp/index.d.ts
12
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
13
+ private _transport?;
14
+ props?: Props;
15
+ abstract server: MaybePromise<McpServer | Server>;
16
+ abstract init(): Promise<void>;
17
+ setInitializeRequest(initializeRequest: JSONRPCMessage): Promise<void>;
18
+ getInitializeRequest(): Promise<JSONRPCMessage | undefined>;
19
+ /** Read the transport type for this agent.
20
+ * This relies on the naming scheme being `sse:${sessionId}`
21
+ * or `streamable-http:${sessionId}`.
22
+ */
23
+ getTransportType(): BaseTransportType;
24
+ /** Read the sessionId for this agent.
25
+ * This relies on the naming scheme being `sse:${sessionId}`
26
+ * or `streamable-http:${sessionId}`.
27
+ */
28
+ getSessionId(): string;
29
+ /** Get the unique WebSocket. SSE transport only. */
30
+ private getWebSocket;
31
+ /** Returns a new transport matching the type of the Agent. */
32
+ private initTransport;
33
+ /** Update and store the props */
34
+ updateProps(props?: Props): Promise<void>;
35
+ reinitializeServer(): Promise<void>;
36
+ /** Sets up the MCP transport and server every time the Agent is started.*/
37
+ onStart(props?: Props): Promise<void>;
38
+ /** Validates new WebSocket connections. */
39
+ onConnect(conn: Connection, {
40
+ request: req
41
+ }: ConnectionContext): Promise<void>;
42
+ /** Handles MCP Messages for the legacy SSE transport. */
43
+ onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
44
+ /** Elicit user input with a message and schema */
45
+ elicitInput(params: {
46
+ message: string;
47
+ requestedSchema: unknown;
48
+ }): Promise<ElicitResult$1>;
49
+ /** Wait for elicitation response through storage polling */
50
+ private _waitForElicitationResponse;
51
+ /** Handle elicitation responses */
52
+ private _handleElicitationResponse;
53
+ /** Return a handler for the given path for this MCP.
54
+ * Defaults to Streamable HTTP transport.
55
+ */
56
+ static serve(path: string, {
57
+ binding,
58
+ corsOptions,
59
+ transport
60
+ }?: ServeOptions): {
61
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
62
+ };
63
+ /**
64
+ * Legacy api
65
+ **/
66
+ static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
67
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
68
+ };
69
+ static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
70
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
71
+ };
22
72
  }
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;
26
- 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
32
- */
33
- private _agent;
34
- get mcp(): MCPClientManager;
35
- protected constructor(ctx: DurableObjectState, env: Env);
36
- /**
37
- * Agents API allowlist
38
- */
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
47
- */
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
- }): {
68
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
69
- };
70
- static serveSSE(path: string, { binding, corsOptions }?: {
71
- binding?: string;
72
- corsOptions?: CORSOptions;
73
- }): {
74
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
75
- };
76
- static serve(path: string, { binding, corsOptions }?: {
77
- binding?: string;
78
- corsOptions?: CORSOptions;
79
- }): {
80
- fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
81
- };
82
- }
83
-
84
- export { McpAgent };
73
+ //#endregion
74
+ export { type ElicitRequest, ElicitRequestSchema, type ElicitResult, type MCPClientOAuthCallbackConfig, type MCPClientOAuthResult, McpAgent, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport };
75
+ //# sourceMappingURL=index.d.ts.map