agents 0.0.0-9069759 → 0.0.0-928211f

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 (51) hide show
  1. package/README.md +127 -22
  2. package/dist/ai-chat-agent.d.ts +52 -3
  3. package/dist/ai-chat-agent.js +179 -78
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-react.d.ts +20 -5
  6. package/dist/ai-react.js +62 -48
  7. package/dist/ai-react.js.map +1 -1
  8. package/dist/ai-types.d.ts +5 -0
  9. package/dist/chunk-2DJ6XAU6.js +1270 -0
  10. package/dist/chunk-2DJ6XAU6.js.map +1 -0
  11. package/dist/chunk-KUH345EY.js +116 -0
  12. package/dist/chunk-KUH345EY.js.map +1 -0
  13. package/dist/chunk-PVQZBKN7.js +106 -0
  14. package/dist/chunk-PVQZBKN7.js.map +1 -0
  15. package/dist/chunk-XJR75HO7.js +548 -0
  16. package/dist/chunk-XJR75HO7.js.map +1 -0
  17. package/dist/client.d.ts +16 -2
  18. package/dist/client.js +6 -133
  19. package/dist/client.js.map +1 -1
  20. package/dist/index-CLW1aEBr.d.ts +615 -0
  21. package/dist/index.d.ts +39 -300
  22. package/dist/index.js +12 -4
  23. package/dist/mcp/client.d.ts +1059 -0
  24. package/dist/mcp/client.js +9 -0
  25. package/dist/mcp/do-oauth-client-provider.d.ts +41 -0
  26. package/dist/mcp/do-oauth-client-provider.js +7 -0
  27. package/dist/mcp/do-oauth-client-provider.js.map +1 -0
  28. package/dist/mcp/index.d.ts +122 -0
  29. package/dist/mcp/index.js +908 -0
  30. package/dist/mcp/index.js.map +1 -0
  31. package/dist/observability/index.d.ts +14 -0
  32. package/dist/observability/index.js +10 -0
  33. package/dist/observability/index.js.map +1 -0
  34. package/dist/react.d.ts +87 -5
  35. package/dist/react.js +50 -31
  36. package/dist/react.js.map +1 -1
  37. package/dist/schedule.d.ts +10 -10
  38. package/dist/schedule.js +4 -6
  39. package/dist/schedule.js.map +1 -1
  40. package/dist/serializable.d.ts +32 -0
  41. package/dist/serializable.js +1 -0
  42. package/dist/serializable.js.map +1 -0
  43. package/package.json +84 -51
  44. package/src/index.ts +1192 -185
  45. package/dist/chunk-HMLY7DHA.js +0 -16
  46. package/dist/chunk-X6BBKLSC.js +0 -568
  47. package/dist/chunk-X6BBKLSC.js.map +0 -1
  48. package/dist/mcp.d.ts +0 -58
  49. package/dist/mcp.js +0 -945
  50. package/dist/mcp.js.map +0 -1
  51. /package/dist/{chunk-HMLY7DHA.js.map → mcp/client.js.map} +0 -0
@@ -0,0 +1,9 @@
1
+ import {
2
+ MCPClientManager,
3
+ getNamespacedData
4
+ } from "../chunk-XJR75HO7.js";
5
+ export {
6
+ MCPClientManager,
7
+ getNamespacedData
8
+ };
9
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,41 @@
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 };
@@ -0,0 +1,7 @@
1
+ import {
2
+ DurableObjectOAuthClientProvider
3
+ } from "../chunk-PVQZBKN7.js";
4
+ export {
5
+ DurableObjectOAuthClientProvider
6
+ };
7
+ //# sourceMappingURL=do-oauth-client-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,122 @@
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 { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
6
+ export { ElicitRequest, ElicitRequestSchema, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
7
+ import { Connection, WSMessage } from 'partyserver';
8
+ import { SSEClientTransport, SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
9
+ import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
10
+ import 'zod';
11
+ import '@modelcontextprotocol/sdk/client/index.js';
12
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
13
+ import 'ai';
14
+ import './do-oauth-client-provider.js';
15
+ import '@modelcontextprotocol/sdk/client/auth.js';
16
+ import '@modelcontextprotocol/sdk/shared/auth.js';
17
+
18
+ declare class SSEEdgeClientTransport extends SSEClientTransport {
19
+ private authProvider;
20
+ /**
21
+ * Creates a new EdgeSSEClientTransport, which overrides fetch to be compatible with the CF workers environment
22
+ */
23
+ constructor(url: URL, options: SSEClientTransportOptions);
24
+ authHeaders(): Promise<{
25
+ Authorization: string;
26
+ } | undefined>;
27
+ }
28
+
29
+ declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTransport {
30
+ private authProvider;
31
+ /**
32
+ * Creates a new StreamableHTTPEdgeClientTransport, which overrides fetch to be compatible with the CF workers environment
33
+ */
34
+ constructor(url: URL, options: StreamableHTTPClientTransportOptions);
35
+ authHeaders(): Promise<{
36
+ Authorization: string;
37
+ } | undefined>;
38
+ }
39
+
40
+ interface CORSOptions {
41
+ origin?: string;
42
+ methods?: string;
43
+ headers?: string;
44
+ maxAge?: number;
45
+ exposeHeaders?: string;
46
+ }
47
+ type MaybePromise<T> = T | Promise<T>;
48
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
49
+ private _status;
50
+ private _transport?;
51
+ private _transportType;
52
+ private _requestIdToConnectionId;
53
+ /**
54
+ * Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
55
+ * to the outer class: initialState/state/setState/onStateUpdate/sql
56
+ */
57
+ private _agent;
58
+ get mcp(): MCPClientManager;
59
+ protected constructor(ctx: DurableObjectState, env: Env);
60
+ /**
61
+ * Agents API allowlist
62
+ */
63
+ initialState: State;
64
+ get state(): State;
65
+ sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
66
+ setState(state: State): void;
67
+ /**
68
+ * Elicit user input with a message and schema
69
+ */
70
+ elicitInput(params: {
71
+ message: string;
72
+ requestedSchema: unknown;
73
+ }): Promise<ElicitResult>;
74
+ onStateUpdate(state: State | undefined, source: Connection | "server"): void;
75
+ onStart(): Promise<void>;
76
+ /**
77
+ * McpAgent API
78
+ */
79
+ abstract server: MaybePromise<McpServer | Server>;
80
+ props: Props;
81
+ initRun: boolean;
82
+ abstract init(): Promise<void>;
83
+ _init(props: Props): Promise<void>;
84
+ setInitialized(): Promise<void>;
85
+ isInitialized(): Promise<boolean>;
86
+ private _initialize;
87
+ fetch(request: Request): Promise<Response>;
88
+ getWebSocket(): WebSocket | null;
89
+ getWebSocketForResponseID(id: string): WebSocket | null;
90
+ onMessage(connection: Connection, event: WSMessage): Promise<void>;
91
+ /**
92
+ * Wait for elicitation response through storage polling
93
+ */
94
+ private _waitForElicitationResponse;
95
+ /**
96
+ * Handle elicitation responses */
97
+ private _handleElicitationResponse;
98
+ onSSEMcpMessage(_sessionId: string, request: Request): Promise<Error | null>;
99
+ webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
100
+ webSocketError(ws: WebSocket, error: unknown): Promise<void>;
101
+ webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
102
+ static mount(path: string, { binding, corsOptions }?: {
103
+ binding?: string;
104
+ corsOptions?: CORSOptions;
105
+ }): {
106
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
107
+ };
108
+ static serveSSE(path: string, { binding, corsOptions }?: {
109
+ binding?: string;
110
+ corsOptions?: CORSOptions;
111
+ }): {
112
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
113
+ };
114
+ static serve(path: string, { binding, corsOptions }?: {
115
+ binding?: string;
116
+ corsOptions?: CORSOptions;
117
+ }): {
118
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
119
+ };
120
+ }
121
+
122
+ export { McpAgent, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport };