agents 0.0.0-f913299 → 0.0.0-fac1fe8
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 +159 -33
- package/dist/ai-chat-agent.d.ts +56 -6
- package/dist/ai-chat-agent.js +286 -97
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-chat-v5-migration.d.ts +152 -0
- package/dist/ai-chat-v5-migration.js +19 -0
- package/dist/ai-react.d.ts +71 -65
- package/dist/ai-react.js +193 -72
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types.d.ts +40 -18
- package/dist/ai-types.js +6 -0
- package/dist/chunk-AVYJQSLW.js +17 -0
- package/dist/chunk-AVYJQSLW.js.map +1 -0
- package/dist/chunk-LL2AFX7V.js +109 -0
- package/dist/chunk-LL2AFX7V.js.map +1 -0
- package/dist/chunk-MH46VMM4.js +612 -0
- package/dist/chunk-MH46VMM4.js.map +1 -0
- package/dist/chunk-QEVM4BVL.js +116 -0
- package/dist/chunk-QEVM4BVL.js.map +1 -0
- package/dist/chunk-UJVEAURM.js +150 -0
- package/dist/chunk-UJVEAURM.js.map +1 -0
- package/dist/chunk-YDUDMOL6.js +1296 -0
- package/dist/chunk-YDUDMOL6.js.map +1 -0
- package/dist/client-CvaJdLQA.d.ts +5015 -0
- package/dist/client.d.ts +16 -2
- package/dist/client.js +7 -133
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +284 -22
- package/dist/index.js +15 -4
- package/dist/mcp/client.d.ts +11 -0
- package/dist/mcp/client.js +9 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/do-oauth-client-provider.d.ts +42 -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 +97 -0
- package/dist/mcp/index.js +1025 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/observability/index.d.ts +46 -0
- package/dist/observability/index.js +11 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/react.d.ts +89 -5
- package/dist/react.js +53 -32
- package/dist/react.js.map +1 -1
- package/dist/schedule.d.ts +81 -7
- package/dist/schedule.js +19 -8
- 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 +95 -43
- package/src/index.ts +1243 -184
- package/dist/chunk-HMLY7DHA.js +0 -16
- package/dist/chunk-X6BBKLSC.js +0 -568
- package/dist/chunk-X6BBKLSC.js.map +0 -1
- /package/dist/{chunk-HMLY7DHA.js.map → ai-chat-v5-migration.js.map} +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import 'zod';
|
|
2
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
|
3
|
+
import '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
4
|
+
import '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import 'ai';
|
|
6
|
+
export { M as MCPClientManager, g as getNamespacedData } from '../client-CvaJdLQA.js';
|
|
7
|
+
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
8
|
+
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
9
|
+
import './do-oauth-client-provider.js';
|
|
10
|
+
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
11
|
+
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 clientUri(): string;
|
|
19
|
+
get redirectUrl(): string;
|
|
20
|
+
get clientId(): string;
|
|
21
|
+
set clientId(clientId_: string);
|
|
22
|
+
get serverId(): string;
|
|
23
|
+
set serverId(serverId_: string);
|
|
24
|
+
keyPrefix(clientId: string): string;
|
|
25
|
+
clientInfoKey(clientId: string): string;
|
|
26
|
+
clientInformation(): Promise<OAuthClientInformation | undefined>;
|
|
27
|
+
saveClientInformation(clientInformation: OAuthClientInformationFull): Promise<void>;
|
|
28
|
+
tokenKey(clientId: string): string;
|
|
29
|
+
tokens(): Promise<OAuthTokens | undefined>;
|
|
30
|
+
saveTokens(tokens: OAuthTokens): Promise<void>;
|
|
31
|
+
get authUrl(): string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Because this operates on the server side (but we need browser auth), we send this url back to the user
|
|
34
|
+
* and require user interact to initiate the redirect flow
|
|
35
|
+
*/
|
|
36
|
+
redirectToAuthorization(authUrl: URL): Promise<void>;
|
|
37
|
+
codeVerifierKey(clientId: string): string;
|
|
38
|
+
saveCodeVerifier(verifier: string): Promise<void>;
|
|
39
|
+
codeVerifier(): Promise<string>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { type AgentsOAuthProvider, DurableObjectOAuthClientProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
export { ElicitRequest, ElicitRequestSchema, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { Agent, AgentContext } from '../index.js';
|
|
6
|
+
export { S as SSEEdgeClientTransport, a as StreamableHTTPEdgeClientTransport } from '../client-CvaJdLQA.js';
|
|
7
|
+
import { Connection, ConnectionContext, WSMessage } from 'partyserver';
|
|
8
|
+
import 'cloudflare:workers';
|
|
9
|
+
import '@modelcontextprotocol/sdk/client/index.js';
|
|
10
|
+
import '../observability/index.js';
|
|
11
|
+
import '../ai-types.js';
|
|
12
|
+
import 'ai';
|
|
13
|
+
import 'zod';
|
|
14
|
+
import '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
15
|
+
import '@modelcontextprotocol/sdk/client/sse.js';
|
|
16
|
+
import '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
17
|
+
import './do-oauth-client-provider.js';
|
|
18
|
+
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
19
|
+
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
20
|
+
|
|
21
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
22
|
+
type TransportType = "sse" | "streamable-http";
|
|
23
|
+
interface CORSOptions {
|
|
24
|
+
origin?: string;
|
|
25
|
+
methods?: string;
|
|
26
|
+
headers?: string;
|
|
27
|
+
maxAge?: number;
|
|
28
|
+
exposeHeaders?: string;
|
|
29
|
+
}
|
|
30
|
+
interface ServeOptions {
|
|
31
|
+
binding?: string;
|
|
32
|
+
corsOptions?: CORSOptions;
|
|
33
|
+
transport?: TransportType;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare abstract class McpAgent<Env = unknown, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
|
|
37
|
+
private _transport?;
|
|
38
|
+
private _requestIdToConnectionId;
|
|
39
|
+
private _standaloneSseConnectionId?;
|
|
40
|
+
props?: Props;
|
|
41
|
+
abstract server: MaybePromise<McpServer | Server>;
|
|
42
|
+
abstract init(): Promise<void>;
|
|
43
|
+
constructor(ctx: AgentContext, env: Env);
|
|
44
|
+
setInitialized(): Promise<void>;
|
|
45
|
+
isInitialized(): Promise<boolean>;
|
|
46
|
+
/** Read the transport type for this agent.
|
|
47
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
48
|
+
* or `streamable-http:${sessionId}`.
|
|
49
|
+
*/
|
|
50
|
+
getTransportType(): TransportType;
|
|
51
|
+
/** Get the WebSocket for the standalone SSE if any. Streamable HTTP only. */
|
|
52
|
+
private getWebSocketForStandaloneSse;
|
|
53
|
+
/** Get the unique WebSocket. SSE transport only. */
|
|
54
|
+
private getWebSocket;
|
|
55
|
+
/** Get the corresponding WebSocket for a responseId. Streamable HTTP only. */
|
|
56
|
+
private getWebSocketForResponseID;
|
|
57
|
+
/** Returns a new transport matching the type of the Agent. */
|
|
58
|
+
private initTransport;
|
|
59
|
+
/** Update and store the props */
|
|
60
|
+
updateProps(props?: Props): Promise<void>;
|
|
61
|
+
/** Sets up the MCP transport and server every time the Agent is started.*/
|
|
62
|
+
onStart(props?: Props): Promise<void>;
|
|
63
|
+
/** Validates new WebSocket connections. */
|
|
64
|
+
onConnect(conn: Connection, _: ConnectionContext): Promise<void>;
|
|
65
|
+
/** Handles MCP Messages for Streamable HTTP. */
|
|
66
|
+
onMessage(connection: Connection, event: WSMessage): Promise<void>;
|
|
67
|
+
/** Remove clients from our cache when they disconnect */
|
|
68
|
+
onClose(conn: Connection, _code: number, _reason: string, _wasClean: boolean): Promise<void>;
|
|
69
|
+
/** Handles MCP Messages for the legacy SSE transport. */
|
|
70
|
+
onSSEMcpMessage(_sessionId: string, messageBody: unknown): Promise<Error | null>;
|
|
71
|
+
/** Elicit user input with a message and schema */
|
|
72
|
+
elicitInput(params: {
|
|
73
|
+
message: string;
|
|
74
|
+
requestedSchema: unknown;
|
|
75
|
+
}): Promise<ElicitResult>;
|
|
76
|
+
/** Wait for elicitation response through storage polling */
|
|
77
|
+
private _waitForElicitationResponse;
|
|
78
|
+
/** Handle elicitation responses */
|
|
79
|
+
private _handleElicitationResponse;
|
|
80
|
+
/** Return a handler for the given path for this MCP.
|
|
81
|
+
* Defaults to Streamable HTTP transport.
|
|
82
|
+
*/
|
|
83
|
+
static serve(path: string, { binding, corsOptions, transport }?: ServeOptions): {
|
|
84
|
+
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Legacy api
|
|
88
|
+
**/
|
|
89
|
+
static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
90
|
+
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
91
|
+
};
|
|
92
|
+
static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
93
|
+
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { McpAgent };
|