agents 0.0.0-fd36bbc → 0.0.0-fd59ae2

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 (48) hide show
  1. package/README.md +130 -28
  2. package/dist/ai-chat-agent.d.ts +52 -3
  3. package/dist/ai-chat-agent.js +170 -82
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-react.d.ts +26 -8
  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-DQJFYHG3.js +1290 -0
  10. package/dist/chunk-DQJFYHG3.js.map +1 -0
  11. package/dist/chunk-EM3J4KV7.js +598 -0
  12. package/dist/chunk-EM3J4KV7.js.map +1 -0
  13. package/dist/chunk-KUH345EY.js +116 -0
  14. package/dist/chunk-KUH345EY.js.map +1 -0
  15. package/dist/chunk-PVQZBKN7.js +106 -0
  16. package/dist/chunk-PVQZBKN7.js.map +1 -0
  17. package/dist/client-DgyzBU_8.d.ts +4601 -0
  18. package/dist/client.d.ts +16 -2
  19. package/dist/client.js +6 -133
  20. package/dist/client.js.map +1 -1
  21. package/dist/index.d.ts +265 -20
  22. package/dist/index.js +12 -4
  23. package/dist/mcp/client.d.ts +11 -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 +112 -0
  29. package/dist/mcp/index.js +955 -0
  30. package/dist/mcp/index.js.map +1 -0
  31. package/dist/observability/index.d.ts +46 -0
  32. package/dist/observability/index.js +10 -0
  33. package/dist/observability/index.js.map +1 -0
  34. package/dist/react.d.ts +88 -5
  35. package/dist/react.js +50 -31
  36. package/dist/react.js.map +1 -1
  37. package/dist/schedule.d.ts +6 -6
  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 +87 -43
  44. package/src/index.ts +1217 -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/{chunk-HMLY7DHA.js.map → mcp/client.js.map} +0 -0
@@ -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,112 @@
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';
18
+
19
+ interface CORSOptions {
20
+ origin?: string;
21
+ methods?: string;
22
+ headers?: string;
23
+ maxAge?: number;
24
+ exposeHeaders?: string;
25
+ }
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
+ /**
63
+ * Handle errors that occur during initialization or operation.
64
+ * Override this method to provide custom error handling.
65
+ * @param error - The error that occurred
66
+ * @returns An error response object with status code and message
67
+ */
68
+ onError(error: Error): {
69
+ status: number;
70
+ message: string;
71
+ };
72
+ _init(props: Props): Promise<void>;
73
+ setInitialized(): Promise<void>;
74
+ isInitialized(): Promise<boolean>;
75
+ updateProps(props: Props): Promise<void>;
76
+ private _initialize;
77
+ fetch(request: Request): Promise<Response>;
78
+ getWebSocket(): WebSocket | null;
79
+ getWebSocketForResponseID(id: string): WebSocket | null;
80
+ onMessage(connection: Connection, event: WSMessage): Promise<void>;
81
+ /**
82
+ * Wait for elicitation response through storage polling
83
+ */
84
+ private _waitForElicitationResponse;
85
+ /**
86
+ * Handle elicitation responses */
87
+ private _handleElicitationResponse;
88
+ onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
89
+ webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
90
+ webSocketError(ws: WebSocket, error: unknown): Promise<void>;
91
+ webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
92
+ static mount(path: string, { binding, corsOptions }?: {
93
+ binding?: string;
94
+ corsOptions?: CORSOptions;
95
+ }): {
96
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
97
+ };
98
+ static serveSSE(path: string, { binding, corsOptions }?: {
99
+ binding?: string;
100
+ corsOptions?: CORSOptions;
101
+ }): {
102
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
103
+ };
104
+ static serve(path: string, { binding, corsOptions }?: {
105
+ binding?: string;
106
+ corsOptions?: CORSOptions;
107
+ }): {
108
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
109
+ };
110
+ }
111
+
112
+ export { McpAgent };