agents 0.0.0-fb4d0a6 → 0.0.0-fb503ba

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 (43) hide show
  1. package/README.md +2 -6
  2. package/dist/ai-chat-agent.d.ts +49 -3
  3. package/dist/ai-chat-agent.js +129 -69
  4. package/dist/ai-chat-agent.js.map +1 -1
  5. package/dist/ai-react.d.ts +18 -3
  6. package/dist/ai-react.js +38 -24
  7. package/dist/ai-react.js.map +1 -1
  8. package/dist/ai-types.d.ts +5 -0
  9. package/dist/chunk-BZXOAZUX.js +106 -0
  10. package/dist/chunk-BZXOAZUX.js.map +1 -0
  11. package/dist/chunk-MXJNY43J.js +785 -0
  12. package/dist/chunk-MXJNY43J.js.map +1 -0
  13. package/dist/chunk-OYJXQRRH.js +465 -0
  14. package/dist/chunk-OYJXQRRH.js.map +1 -0
  15. package/dist/chunk-VCSB47AK.js +116 -0
  16. package/dist/chunk-VCSB47AK.js.map +1 -0
  17. package/dist/client.d.ts +15 -1
  18. package/dist/client.js +6 -133
  19. package/dist/client.js.map +1 -1
  20. package/dist/index.d.ts +122 -13
  21. package/dist/index.js +6 -4
  22. package/dist/mcp/client.d.ts +783 -0
  23. package/dist/mcp/client.js +9 -0
  24. package/dist/mcp/do-oauth-client-provider.d.ts +41 -0
  25. package/dist/mcp/do-oauth-client-provider.js +7 -0
  26. package/dist/mcp/do-oauth-client-provider.js.map +1 -0
  27. package/dist/mcp/index.d.ts +84 -0
  28. package/dist/mcp/index.js +782 -0
  29. package/dist/mcp/index.js.map +1 -0
  30. package/dist/react.d.ts +85 -5
  31. package/dist/react.js +48 -29
  32. package/dist/react.js.map +1 -1
  33. package/dist/schedule.js +0 -2
  34. package/dist/schedule.js.map +1 -1
  35. package/dist/serializable.d.ts +32 -0
  36. package/dist/serializable.js +1 -0
  37. package/dist/serializable.js.map +1 -0
  38. package/package.json +41 -5
  39. package/src/index.ts +492 -126
  40. package/dist/chunk-HMLY7DHA.js +0 -16
  41. package/dist/chunk-X6BBKLSC.js +0 -568
  42. package/dist/chunk-X6BBKLSC.js.map +0 -1
  43. /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-OYJXQRRH.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-BZXOAZUX.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,84 @@
1
+ import { MCPClientManager } from './client.js';
2
+ import { DurableObject } from 'cloudflare:workers';
3
+ import { Connection, WSMessage } from 'partyserver';
4
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
+ import 'zod';
7
+ import '@modelcontextprotocol/sdk/types.js';
8
+ import '@modelcontextprotocol/sdk/client/index.js';
9
+ import '@modelcontextprotocol/sdk/client/sse.js';
10
+ import './do-oauth-client-provider.js';
11
+ import '@modelcontextprotocol/sdk/client/auth.js';
12
+ import '@modelcontextprotocol/sdk/shared/auth.js';
13
+ import '@modelcontextprotocol/sdk/shared/protocol.js';
14
+ import 'ai';
15
+
16
+ interface CORSOptions {
17
+ origin?: string;
18
+ methods?: string;
19
+ headers?: string;
20
+ maxAge?: number;
21
+ exposeHeaders?: string;
22
+ }
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 };