agents 0.0.0-f641104 → 0.0.0-f6c26e4
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.
- package/README.md +24 -28
- package/dist/ai-chat-agent.d.ts +51 -4
- package/dist/ai-chat-agent.js +179 -78
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-react.d.ts +18 -5
- package/dist/ai-react.js +62 -48
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types.d.ts +5 -0
- package/dist/chunk-5YIRLLUX.js +1264 -0
- package/dist/chunk-5YIRLLUX.js.map +1 -0
- package/dist/chunk-KUH345EY.js +116 -0
- package/dist/chunk-KUH345EY.js.map +1 -0
- package/dist/chunk-MW5BQ2FW.js +469 -0
- package/dist/chunk-MW5BQ2FW.js.map +1 -0
- package/dist/chunk-PVQZBKN7.js +106 -0
- package/dist/chunk-PVQZBKN7.js.map +1 -0
- package/dist/client.d.ts +16 -2
- package/dist/client.js +6 -133
- package/dist/client.js.map +1 -1
- package/dist/index-BIJvkfYt.d.ts +614 -0
- package/dist/index.d.ts +37 -300
- package/dist/index.js +12 -4
- package/dist/mcp/client.d.ts +1055 -0
- package/dist/mcp/client.js +9 -0
- package/dist/mcp/do-oauth-client-provider.d.ts +41 -0
- package/dist/mcp/do-oauth-client-provider.js +7 -0
- package/dist/mcp/do-oauth-client-provider.js.map +1 -0
- package/dist/mcp/index.d.ts +84 -0
- package/dist/mcp/index.js +783 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/observability/index.d.ts +12 -0
- package/dist/observability/index.js +10 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/react.d.ts +85 -5
- package/dist/react.js +50 -31
- package/dist/react.js.map +1 -1
- package/dist/schedule.d.ts +6 -6
- package/dist/schedule.js +4 -6
- package/dist/schedule.js.map +1 -1
- package/dist/serializable.d.ts +32 -0
- package/dist/serializable.js +1 -0
- package/dist/serializable.js.map +1 -0
- package/package.json +84 -52
- package/src/index.ts +1172 -182
- package/dist/chunk-HMLY7DHA.js +0 -16
- package/dist/chunk-X6BBKLSC.js +0 -568
- package/dist/chunk-X6BBKLSC.js.map +0 -1
- package/dist/mcp.d.ts +0 -58
- package/dist/mcp.js +0 -945
- package/dist/mcp.js.map +0 -1
- /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 @@
|
|
|
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 { 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';
|
|
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 };
|