agents 0.0.0-a20932f → 0.0.0-a45f8f3

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 +129 -28
  2. package/dist/ai-chat-agent.d.ts +52 -3
  3. package/dist/ai-chat-agent.js +179 -81
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-react.d.ts +25 -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-3IQQY2UH.js +1270 -0
  10. package/dist/chunk-3IQQY2UH.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-UNG3FXYX.js +525 -0
  16. package/dist/chunk-UNG3FXYX.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 +1054 -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 +107 -0
  29. package/dist/mcp/index.js +798 -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 +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 +84 -43
  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/{chunk-HMLY7DHA.js.map → mcp/client.js.map} +0 -0
@@ -0,0 +1,9 @@
1
+ import {
2
+ MCPClientManager,
3
+ getNamespacedData
4
+ } from "../chunk-UNG3FXYX.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,107 @@
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 { SSEClientTransport, SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
7
+ import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
8
+ import 'zod';
9
+ import '@modelcontextprotocol/sdk/client/index.js';
10
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
11
+ import '@modelcontextprotocol/sdk/types.js';
12
+ import 'ai';
13
+ import './do-oauth-client-provider.js';
14
+ import '@modelcontextprotocol/sdk/client/auth.js';
15
+ import '@modelcontextprotocol/sdk/shared/auth.js';
16
+
17
+ declare class SSEEdgeClientTransport extends SSEClientTransport {
18
+ private authProvider;
19
+ /**
20
+ * Creates a new EdgeSSEClientTransport, which overrides fetch to be compatible with the CF workers environment
21
+ */
22
+ constructor(url: URL, options: SSEClientTransportOptions);
23
+ authHeaders(): Promise<{
24
+ Authorization: string;
25
+ } | undefined>;
26
+ }
27
+
28
+ declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTransport {
29
+ private authProvider;
30
+ /**
31
+ * Creates a new StreamableHTTPEdgeClientTransport, which overrides fetch to be compatible with the CF workers environment
32
+ */
33
+ constructor(url: URL, options: StreamableHTTPClientTransportOptions);
34
+ authHeaders(): Promise<{
35
+ Authorization: string;
36
+ } | undefined>;
37
+ }
38
+
39
+ interface CORSOptions {
40
+ origin?: string;
41
+ methods?: string;
42
+ headers?: string;
43
+ maxAge?: number;
44
+ exposeHeaders?: string;
45
+ }
46
+ type MaybePromise<T> = T | Promise<T>;
47
+ declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends DurableObject<Env> {
48
+ private _status;
49
+ private _transport?;
50
+ private _transportType;
51
+ private _requestIdToConnectionId;
52
+ /**
53
+ * Since McpAgent's _aren't_ yet real "Agents", let's only expose a couple of the methods
54
+ * to the outer class: initialState/state/setState/onStateUpdate/sql
55
+ */
56
+ private _agent;
57
+ get mcp(): MCPClientManager;
58
+ protected constructor(ctx: DurableObjectState, env: Env);
59
+ /**
60
+ * Agents API allowlist
61
+ */
62
+ initialState: State;
63
+ get state(): State;
64
+ sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
65
+ setState(state: State): void;
66
+ onStateUpdate(state: State | undefined, source: Connection | "server"): void;
67
+ onStart(): Promise<void>;
68
+ /**
69
+ * McpAgent API
70
+ */
71
+ abstract server: MaybePromise<McpServer | Server>;
72
+ props: Props;
73
+ initRun: boolean;
74
+ abstract init(): Promise<void>;
75
+ _init(props: Props): Promise<void>;
76
+ setInitialized(): Promise<void>;
77
+ isInitialized(): Promise<boolean>;
78
+ private _initialize;
79
+ fetch(request: Request): Promise<Response>;
80
+ getWebSocket(): WebSocket | null;
81
+ getWebSocketForResponseID(id: string): WebSocket | null;
82
+ onMessage(connection: Connection, event: WSMessage): Promise<void>;
83
+ onSSEMcpMessage(_sessionId: string, request: Request): Promise<Error | null>;
84
+ webSocketMessage(ws: WebSocket, event: ArrayBuffer | string): Promise<void>;
85
+ webSocketError(ws: WebSocket, error: unknown): Promise<void>;
86
+ webSocketClose(ws: WebSocket, code: number, reason: string, wasClean: boolean): Promise<void>;
87
+ static mount(path: string, { binding, corsOptions }?: {
88
+ binding?: string;
89
+ corsOptions?: CORSOptions;
90
+ }): {
91
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
92
+ };
93
+ static serveSSE(path: string, { binding, corsOptions }?: {
94
+ binding?: string;
95
+ corsOptions?: CORSOptions;
96
+ }): {
97
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
98
+ };
99
+ static serve(path: string, { binding, corsOptions }?: {
100
+ binding?: string;
101
+ corsOptions?: CORSOptions;
102
+ }): {
103
+ fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
104
+ };
105
+ }
106
+
107
+ export { McpAgent, SSEEdgeClientTransport, StreamableHTTPEdgeClientTransport };