agents 0.0.0-cebd0de → 0.0.0-ced3b22
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 +157 -27
- package/dist/ai-chat-agent.d.ts +56 -7
- package/dist/ai-chat-agent.js +276 -93
- 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 -67
- package/dist/ai-react.js +180 -66
- 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 -126
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +282 -26
- package/dist/index.js +17 -8
- package/dist/mcp/client.d.ts +11 -714
- package/dist/mcp/client.js +3 -465
- package/dist/mcp/client.js.map +1 -1
- 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 +83 -30
- package/dist/mcp/index.js +949 -260
- package/dist/mcp/index.js.map +1 -1
- 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 +40 -26
- 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 +88 -52
- package/src/index.ts +1184 -156
- package/dist/chunk-HMLY7DHA.js +0 -16
- package/dist/chunk-YMUU7QHV.js +0 -595
- package/dist/chunk-YMUU7QHV.js.map +0 -1
- /package/dist/{chunk-HMLY7DHA.js.map → ai-chat-v5-migration.js.map} +0 -0
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,43 +1,96 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
import {
|
|
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';
|
|
4
20
|
|
|
21
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
22
|
+
type TransportType = "sse" | "streamable-http";
|
|
5
23
|
interface CORSOptions {
|
|
6
24
|
origin?: string;
|
|
7
25
|
methods?: string;
|
|
8
26
|
headers?: string;
|
|
9
27
|
maxAge?: number;
|
|
28
|
+
exposeHeaders?: string;
|
|
10
29
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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}`.
|
|
15
49
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
24
82
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
static mount(path: string, { binding, corsOptions, }?: {
|
|
37
|
-
binding?: string;
|
|
38
|
-
corsOptions?: CORSOptions;
|
|
39
|
-
}): {
|
|
40
|
-
fetch: (request: Request, env: Record<string, DurableObjectNamespace<McpAgent>>, ctx: ExecutionContext) => Promise<Response | undefined>;
|
|
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>;
|
|
41
94
|
};
|
|
42
95
|
}
|
|
43
96
|
|