agents 0.0.0-a73eac5 → 0.0.0-ac0e999
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 +2 -6
- package/dist/ai-chat-agent.d.ts +49 -3
- package/dist/ai-chat-agent.js +130 -69
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-react.d.ts +17 -3
- package/dist/ai-react.js +39 -23
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types.d.ts +5 -0
- package/dist/chunk-25YDMV4H.js +464 -0
- package/dist/chunk-25YDMV4H.js.map +1 -0
- package/dist/chunk-D6UOOELW.js +106 -0
- package/dist/chunk-D6UOOELW.js.map +1 -0
- package/dist/{chunk-X6BBKLSC.js → chunk-DMJ7L3FI.js} +372 -167
- package/dist/chunk-DMJ7L3FI.js.map +1 -0
- package/dist/{chunk-HMLY7DHA.js → chunk-NOUFNU2O.js} +1 -5
- package/dist/chunk-ZKIVUOTQ.js +123 -0
- package/dist/chunk-ZKIVUOTQ.js.map +1 -0
- package/dist/client.d.ts +9 -1
- package/dist/client.js +7 -133
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +85 -12
- package/dist/index.js +7 -4
- package/dist/mcp/client.d.ts +783 -0
- package/dist/mcp/client.js +10 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/do-oauth-client-provider.d.ts +41 -0
- package/dist/mcp/do-oauth-client-provider.js +8 -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 +780 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/react.d.ts +14 -0
- package/dist/react.js +39 -28
- package/dist/react.js.map +1 -1
- package/dist/schedule.js +1 -1
- package/package.json +41 -5
- package/src/index.ts +481 -126
- package/dist/chunk-X6BBKLSC.js.map +0 -1
- /package/dist/{chunk-HMLY7DHA.js.map → chunk-NOUFNU2O.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -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 { 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 };
|