agents 0.0.0-1eac06e → 0.0.0-1f8c517
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 +32 -7
- package/dist/ai-chat-agent.d.ts +9 -8
- package/dist/ai-chat-agent.js +142 -59
- 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-chat-v5-migration.js.map +1 -0
- package/dist/ai-react.d.ts +59 -70
- package/dist/ai-react.js +144 -37
- package/dist/ai-react.js.map +1 -1
- package/dist/ai-types.d.ts +36 -19
- 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-PVQZBKN7.js → chunk-LL2AFX7V.js} +5 -2
- package/dist/chunk-LL2AFX7V.js.map +1 -0
- package/dist/{chunk-XJR75HO7.js → chunk-MH46VMM4.js} +91 -27
- package/dist/chunk-MH46VMM4.js.map +1 -0
- package/dist/{chunk-KUH345EY.js → chunk-QEVM4BVL.js} +5 -5
- 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-2DJ6XAU6.js → chunk-YDUDMOL6.js} +115 -89
- package/dist/chunk-YDUDMOL6.js.map +1 -0
- package/dist/client-CvaJdLQA.d.ts +5015 -0
- package/dist/client.js +2 -1
- package/dist/index.d.ts +555 -32
- package/dist/index.js +7 -4
- package/dist/mcp/client.d.ts +9 -1057
- package/dist/mcp/client.js +1 -1
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -0
- package/dist/mcp/do-oauth-client-provider.js +1 -1
- package/dist/mcp/index.d.ts +63 -88
- package/dist/mcp/index.js +813 -692
- package/dist/mcp/index.js.map +1 -1
- package/dist/observability/index.d.ts +46 -14
- package/dist/observability/index.js +5 -4
- package/dist/react.d.ts +4 -2
- package/dist/react.js +7 -5
- package/dist/react.js.map +1 -1
- package/dist/schedule.d.ts +79 -5
- package/dist/schedule.js +15 -2
- package/dist/schedule.js.map +1 -1
- package/package.json +19 -8
- package/src/index.ts +152 -100
- package/dist/chunk-2DJ6XAU6.js.map +0 -1
- package/dist/chunk-KUH345EY.js.map +0 -1
- package/dist/chunk-PVQZBKN7.js.map +0 -1
- package/dist/chunk-XJR75HO7.js.map +0 -1
- package/dist/index-CLW1aEBr.d.ts +0 -615
package/dist/mcp/client.js
CHANGED
|
@@ -15,6 +15,7 @@ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
|
|
|
15
15
|
private _clientId_;
|
|
16
16
|
constructor(storage: DurableObjectStorage, clientName: string, baseRedirectUrl: string);
|
|
17
17
|
get clientMetadata(): OAuthClientMetadata;
|
|
18
|
+
get clientUri(): string;
|
|
18
19
|
get redirectUrl(): string;
|
|
19
20
|
get clientId(): string;
|
|
20
21
|
set clientId(clientId_: string);
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,42 +1,25 @@
|
|
|
1
|
-
import { MCPClientManager } from './client.js';
|
|
2
|
-
import { DurableObject } from 'cloudflare:workers';
|
|
3
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
3
|
import { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
6
4
|
export { ElicitRequest, ElicitRequestSchema, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import '
|
|
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';
|
|
11
9
|
import '@modelcontextprotocol/sdk/client/index.js';
|
|
12
|
-
import '
|
|
10
|
+
import '../observability/index.js';
|
|
11
|
+
import '../ai-types.js';
|
|
13
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';
|
|
14
17
|
import './do-oauth-client-provider.js';
|
|
15
18
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
16
19
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new EdgeSSEClientTransport, which overrides fetch to be compatible with the CF workers environment
|
|
22
|
-
*/
|
|
23
|
-
constructor(url: URL, options: SSEClientTransportOptions);
|
|
24
|
-
authHeaders(): Promise<{
|
|
25
|
-
Authorization: string;
|
|
26
|
-
} | undefined>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTransport {
|
|
30
|
-
private authProvider;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new StreamableHTTPEdgeClientTransport, which overrides fetch to be compatible with the CF workers environment
|
|
33
|
-
*/
|
|
34
|
-
constructor(url: URL, options: StreamableHTTPClientTransportOptions);
|
|
35
|
-
authHeaders(): Promise<{
|
|
36
|
-
Authorization: string;
|
|
37
|
-
} | undefined>;
|
|
38
|
-
}
|
|
39
|
-
|
|
21
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
22
|
+
type TransportType = "sse" | "streamable-http";
|
|
40
23
|
interface CORSOptions {
|
|
41
24
|
origin?: string;
|
|
42
25
|
methods?: string;
|
|
@@ -44,79 +27,71 @@ interface CORSOptions {
|
|
|
44
27
|
maxAge?: number;
|
|
45
28
|
exposeHeaders?: string;
|
|
46
29
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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> {
|
|
50
37
|
private _transport?;
|
|
51
|
-
private _transportType;
|
|
52
38
|
private _requestIdToConnectionId;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* to the outer class: initialState/state/setState/onStateUpdate/sql
|
|
56
|
-
*/
|
|
57
|
-
private _agent;
|
|
58
|
-
get mcp(): MCPClientManager;
|
|
59
|
-
protected constructor(ctx: DurableObjectState, env: Env);
|
|
60
|
-
/**
|
|
61
|
-
* Agents API allowlist
|
|
62
|
-
*/
|
|
63
|
-
initialState: State;
|
|
64
|
-
get state(): State;
|
|
65
|
-
sql<T = Record<string, string | number | boolean | null>>(strings: TemplateStringsArray, ...values: (string | number | boolean | null)[]): T[];
|
|
66
|
-
setState(state: State): void;
|
|
67
|
-
/**
|
|
68
|
-
* Elicit user input with a message and schema
|
|
69
|
-
*/
|
|
70
|
-
elicitInput(params: {
|
|
71
|
-
message: string;
|
|
72
|
-
requestedSchema: unknown;
|
|
73
|
-
}): Promise<ElicitResult>;
|
|
74
|
-
onStateUpdate(state: State | undefined, source: Connection | "server"): void;
|
|
75
|
-
onStart(): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* McpAgent API
|
|
78
|
-
*/
|
|
39
|
+
private _standaloneSseConnectionId?;
|
|
40
|
+
props?: Props;
|
|
79
41
|
abstract server: MaybePromise<McpServer | Server>;
|
|
80
|
-
props: Props;
|
|
81
|
-
initRun: boolean;
|
|
82
42
|
abstract init(): Promise<void>;
|
|
83
|
-
|
|
43
|
+
constructor(ctx: AgentContext, env: Env);
|
|
84
44
|
setInitialized(): Promise<void>;
|
|
85
45
|
isInitialized(): Promise<boolean>;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
getWebSocketForResponseID(id: string): WebSocket | null;
|
|
90
|
-
onMessage(connection: Connection, event: WSMessage): Promise<void>;
|
|
91
|
-
/**
|
|
92
|
-
* Wait for elicitation response through storage polling
|
|
46
|
+
/** Read the transport type for this agent.
|
|
47
|
+
* This relies on the naming scheme being `sse:${sessionId}`
|
|
48
|
+
* or `streamable-http:${sessionId}`.
|
|
93
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 */
|
|
94
77
|
private _waitForElicitationResponse;
|
|
95
|
-
/**
|
|
96
|
-
* Handle elicitation responses */
|
|
78
|
+
/** Handle elicitation responses */
|
|
97
79
|
private _handleElicitationResponse;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
static mount(path: string, { binding, corsOptions }?: {
|
|
103
|
-
binding?: string;
|
|
104
|
-
corsOptions?: CORSOptions;
|
|
105
|
-
}): {
|
|
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): {
|
|
106
84
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
107
85
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Legacy api
|
|
88
|
+
**/
|
|
89
|
+
static mount(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
112
90
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
113
91
|
};
|
|
114
|
-
static
|
|
115
|
-
binding?: string;
|
|
116
|
-
corsOptions?: CORSOptions;
|
|
117
|
-
}): {
|
|
92
|
+
static serveSSE(path: string, opts?: Omit<ServeOptions, "transport">): {
|
|
118
93
|
fetch<Env>(this: void, request: Request, env: Env, ctx: ExecutionContext): Promise<Response>;
|
|
119
94
|
};
|
|
120
95
|
}
|
|
121
96
|
|
|
122
|
-
export { McpAgent
|
|
97
|
+
export { McpAgent };
|