agents 0.2.30 → 0.2.32
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 +121 -0
- package/dist/ai-chat-agent.d.ts +136 -9
- package/dist/ai-chat-agent.js +345 -39
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-react.d.ts +134 -11
- package/dist/ai-react.js +216 -53
- package/dist/ai-react.js.map +1 -1
- package/dist/{ai-types-CwgHzwUb.js → ai-types-DEtF_8Km.js} +5 -1
- package/dist/ai-types-DEtF_8Km.js.map +1 -0
- package/dist/{ai-types-D_hTbf25.d.ts → ai-types-U8lYA0o8.d.ts} +26 -2
- package/dist/ai-types.d.ts +1 -1
- package/dist/ai-types.js +1 -1
- package/dist/{client-DfIOsabL.d.ts → client-BZVYeBmf.d.ts} +7 -7
- package/dist/{client-CcyhkGfN.js → client-DjTPRM8-.js} +2 -2
- package/dist/{client-CcyhkGfN.js.map → client-DjTPRM8-.js.map} +1 -1
- package/dist/client.js +2 -2
- package/dist/codemode/ai.js +3 -3
- package/dist/{index-DPJ32qQn.d.ts → index-B6XHf8p0.d.ts} +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/mcp/client.d.ts +1 -1
- package/dist/mcp/index.d.ts +16 -7
- package/dist/mcp/index.js +21 -49
- package/dist/mcp/index.js.map +1 -1
- package/dist/observability/index.js +3 -3
- package/dist/{react-DTzwSLAh.d.ts → react-DYwejKBr.d.ts} +15 -21
- package/dist/react.d.ts +4 -4
- package/dist/react.js +50 -57
- package/dist/react.js.map +1 -1
- package/dist/{src-BmbDclOA.js → src-BZDh910Z.js} +3 -3
- package/dist/{src-BmbDclOA.js.map → src-BZDh910Z.js.map} +1 -1
- package/package.json +1 -1
- package/dist/ai-types-CwgHzwUb.js.map +0 -1
|
@@ -18,7 +18,11 @@ declare enum MessageType {
|
|
|
18
18
|
CF_AGENT_MCP_SERVERS = "cf_agent_mcp_servers",
|
|
19
19
|
CF_MCP_AGENT_EVENT = "cf_mcp_agent_event",
|
|
20
20
|
CF_AGENT_STATE = "cf_agent_state",
|
|
21
|
-
RPC = "rpc"
|
|
21
|
+
RPC = "rpc",
|
|
22
|
+
/** Client sends tool result to server (for client-side tools) */
|
|
23
|
+
CF_AGENT_TOOL_RESULT = "cf_agent_tool_result",
|
|
24
|
+
/** Server notifies client that a message was updated (e.g., tool result applied) */
|
|
25
|
+
CF_AGENT_MESSAGE_UPDATED = "cf_agent_message_updated"
|
|
22
26
|
}
|
|
23
27
|
/**
|
|
24
28
|
* Types of messages sent from the Agent to clients
|
|
@@ -45,12 +49,20 @@ type OutgoingMessage<ChatMessage extends UIMessage = UIMessage> =
|
|
|
45
49
|
done: boolean;
|
|
46
50
|
/** Whether this response contains an error */
|
|
47
51
|
error?: boolean;
|
|
52
|
+
/** Whether this is a continuation (append to last assistant message) */
|
|
53
|
+
continuation?: boolean;
|
|
48
54
|
}
|
|
49
55
|
| {
|
|
50
56
|
/** Indicates the server is resuming an active stream */
|
|
51
57
|
type: MessageType.CF_AGENT_STREAM_RESUMING;
|
|
52
58
|
/** The request ID of the stream being resumed */
|
|
53
59
|
id: string;
|
|
60
|
+
}
|
|
61
|
+
| {
|
|
62
|
+
/** Server notifies client that a message was updated (e.g., tool result applied) */
|
|
63
|
+
type: MessageType.CF_AGENT_MESSAGE_UPDATED;
|
|
64
|
+
/** The updated message */
|
|
65
|
+
message: ChatMessage;
|
|
54
66
|
};
|
|
55
67
|
/**
|
|
56
68
|
* Types of messages sent from clients to the Agent
|
|
@@ -97,7 +109,19 @@ type IncomingMessage<ChatMessage extends UIMessage = UIMessage> =
|
|
|
97
109
|
type: MessageType.CF_AGENT_STREAM_RESUME_ACK;
|
|
98
110
|
/** The request ID of the stream being resumed */
|
|
99
111
|
id: string;
|
|
112
|
+
}
|
|
113
|
+
| {
|
|
114
|
+
/** Client sends tool result to server (for client-side tools) */
|
|
115
|
+
type: MessageType.CF_AGENT_TOOL_RESULT;
|
|
116
|
+
/** The tool call ID this result is for */
|
|
117
|
+
toolCallId: string;
|
|
118
|
+
/** The name of the tool */
|
|
119
|
+
toolName: string;
|
|
120
|
+
/** The output from the tool execution */
|
|
121
|
+
output: unknown;
|
|
122
|
+
/** Whether server should auto-continue the conversation after applying result */
|
|
123
|
+
autoContinue?: boolean;
|
|
100
124
|
};
|
|
101
125
|
//#endregion
|
|
102
126
|
export { MessageType as n, OutgoingMessage as r, IncomingMessage as t };
|
|
103
|
-
//# sourceMappingURL=ai-types-
|
|
127
|
+
//# sourceMappingURL=ai-types-U8lYA0o8.d.ts.map
|
package/dist/ai-types.d.ts
CHANGED
package/dist/ai-types.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { t as MCPObservabilityEvent } from "./mcp-CzbSsLfc.js";
|
|
2
2
|
import { t as AgentsOAuthProvider } from "./do-oauth-client-provider-B-ryFIPr.js";
|
|
3
|
+
import * as ai0 from "ai";
|
|
4
|
+
import { ToolSet } from "ai";
|
|
3
5
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
4
6
|
import {
|
|
5
7
|
SSEClientTransport,
|
|
@@ -21,10 +23,8 @@ import {
|
|
|
21
23
|
Resource,
|
|
22
24
|
ResourceTemplate,
|
|
23
25
|
ServerCapabilities,
|
|
24
|
-
Tool
|
|
26
|
+
Tool as Tool$1
|
|
25
27
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
26
|
-
import * as ai0 from "ai";
|
|
27
|
-
import { ToolSet } from "ai";
|
|
28
28
|
import { RequestOptions } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
29
29
|
|
|
30
30
|
//#region src/core/events.d.ts
|
|
@@ -111,7 +111,7 @@ declare class MCPClientConnection {
|
|
|
111
111
|
connectionState: MCPConnectionState;
|
|
112
112
|
lastConnectedTransport: BaseTransportType | undefined;
|
|
113
113
|
instructions?: string;
|
|
114
|
-
tools: Tool[];
|
|
114
|
+
tools: Tool$1[];
|
|
115
115
|
prompts: Prompt[];
|
|
116
116
|
resources: Resource[];
|
|
117
117
|
resourceTemplates: ResourceTemplate[];
|
|
@@ -168,7 +168,7 @@ declare class MCPClientConnection {
|
|
|
168
168
|
* Notification handler registration for tools
|
|
169
169
|
* Should only be called if serverCapabilities.tools exists
|
|
170
170
|
*/
|
|
171
|
-
registerTools(): Promise<Tool[]>;
|
|
171
|
+
registerTools(): Promise<Tool$1[]>;
|
|
172
172
|
/**
|
|
173
173
|
* Notification handler registration for resources
|
|
174
174
|
* Should only be called if serverCapabilities.resources exists
|
|
@@ -796,7 +796,7 @@ declare class MCPClientManager {
|
|
|
796
796
|
}>;
|
|
797
797
|
}
|
|
798
798
|
type NamespacedData = {
|
|
799
|
-
tools: (Tool & {
|
|
799
|
+
tools: (Tool$1 & {
|
|
800
800
|
serverId: string;
|
|
801
801
|
})[];
|
|
802
802
|
prompts: (Prompt & {
|
|
@@ -831,4 +831,4 @@ export {
|
|
|
831
831
|
MCPClientManager as t,
|
|
832
832
|
MCPConnectionState as u
|
|
833
833
|
};
|
|
834
|
-
//# sourceMappingURL=client-
|
|
834
|
+
//# sourceMappingURL=client-BZVYeBmf.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as MessageType } from "./ai-types-
|
|
1
|
+
import { t as MessageType } from "./ai-types-DEtF_8Km.js";
|
|
2
2
|
import { PartySocket } from "partysocket";
|
|
3
3
|
|
|
4
4
|
//#region src/client.ts
|
|
@@ -114,4 +114,4 @@ function agentFetch(opts, init) {
|
|
|
114
114
|
|
|
115
115
|
//#endregion
|
|
116
116
|
export { agentFetch as n, camelCaseToKebabCase as r, AgentClient as t };
|
|
117
|
-
//# sourceMappingURL=client-
|
|
117
|
+
//# sourceMappingURL=client-DjTPRM8-.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-
|
|
1
|
+
{"version":3,"file":"client-DjTPRM8-.js","names":["parsedMessage: Record<string, unknown>","request: RPCRequest"],"sources":["../src/client.ts"],"sourcesContent":["import {\n type PartyFetchOptions,\n PartySocket,\n type PartySocketOptions\n} from \"partysocket\";\nimport type { RPCRequest, RPCResponse } from \"./\";\nimport type {\n SerializableReturnValue,\n SerializableValue\n} from \"./serializable\";\nimport { MessageType } from \"./ai-types\";\n\n/**\n * Options for creating an AgentClient\n */\nexport type AgentClientOptions<State = unknown> = Omit<\n PartySocketOptions,\n \"party\" | \"room\"\n> & {\n /** Name of the agent to connect to */\n agent: string;\n /** Name of the specific Agent instance */\n name?: string;\n /** Called when the Agent's state is updated */\n onStateUpdate?: (state: State, source: \"server\" | \"client\") => void;\n};\n\n/**\n * Options for streaming RPC calls\n */\nexport type StreamOptions = {\n /** Called when a chunk of data is received */\n onChunk?: (chunk: unknown) => void;\n /** Called when the stream ends */\n onDone?: (finalChunk: unknown) => void;\n /** Called when an error occurs */\n onError?: (error: string) => void;\n};\n\n/**\n * Options for the agentFetch function\n */\nexport type AgentClientFetchOptions = Omit<\n PartyFetchOptions,\n \"party\" | \"room\"\n> & {\n /** Name of the agent to connect to */\n agent: string;\n /** Name of the specific Agent instance */\n name?: string;\n};\n\n/**\n * Convert a camelCase string to a kebab-case string\n * @param str The string to convert\n * @returns The kebab-case string\n */\nexport function camelCaseToKebabCase(str: string): string {\n // If string is all uppercase, convert to lowercase\n if (str === str.toUpperCase() && str !== str.toLowerCase()) {\n return str.toLowerCase().replace(/_/g, \"-\");\n }\n\n // Otherwise handle camelCase to kebab-case\n let kebabified = str.replace(\n /[A-Z]/g,\n (letter) => `-${letter.toLowerCase()}`\n );\n kebabified = kebabified.startsWith(\"-\") ? kebabified.slice(1) : kebabified;\n // Convert any remaining underscores to hyphens and remove trailing -'s\n return kebabified.replace(/_/g, \"-\").replace(/-$/, \"\");\n}\n\n/**\n * WebSocket client for connecting to an Agent\n */\nexport class AgentClient<State = unknown> extends PartySocket {\n /**\n * @deprecated Use agentFetch instead\n */\n static fetch(_opts: PartyFetchOptions): Promise<Response> {\n throw new Error(\n \"AgentClient.fetch is not implemented, use agentFetch instead\"\n );\n }\n agent: string;\n name: string;\n private options: AgentClientOptions<State>;\n private _pendingCalls = new Map<\n string,\n {\n resolve: (value: unknown) => void;\n reject: (error: Error) => void;\n stream?: StreamOptions;\n type?: unknown;\n }\n >();\n\n constructor(options: AgentClientOptions<State>) {\n const agentNamespace = camelCaseToKebabCase(options.agent);\n super({\n party: agentNamespace,\n prefix: \"agents\",\n room: options.name || \"default\",\n ...options\n });\n this.agent = agentNamespace;\n this.name = options.name || \"default\";\n this.options = options;\n\n this.addEventListener(\"message\", (event) => {\n if (typeof event.data === \"string\") {\n let parsedMessage: Record<string, unknown>;\n try {\n parsedMessage = JSON.parse(event.data);\n } catch (_error) {\n // silently ignore invalid messages for now\n // TODO: log errors with log levels\n return;\n }\n if (parsedMessage.type === MessageType.CF_AGENT_STATE) {\n this.options.onStateUpdate?.(parsedMessage.state as State, \"server\");\n return;\n }\n if (parsedMessage.type === MessageType.RPC) {\n const response = parsedMessage as RPCResponse;\n const pending = this._pendingCalls.get(response.id);\n if (!pending) return;\n\n if (!response.success) {\n pending.reject(new Error(response.error));\n this._pendingCalls.delete(response.id);\n pending.stream?.onError?.(response.error);\n return;\n }\n\n // Handle streaming responses\n if (\"done\" in response) {\n if (response.done) {\n pending.resolve(response.result);\n this._pendingCalls.delete(response.id);\n pending.stream?.onDone?.(response.result);\n } else {\n pending.stream?.onChunk?.(response.result);\n }\n } else {\n // Non-streaming response\n pending.resolve(response.result);\n this._pendingCalls.delete(response.id);\n }\n }\n }\n });\n }\n\n setState(state: State) {\n this.send(JSON.stringify({ state, type: MessageType.CF_AGENT_STATE }));\n this.options.onStateUpdate?.(state, \"client\");\n }\n\n /**\n * Call a method on the Agent\n * @param method Name of the method to call\n * @param args Arguments to pass to the method\n * @param streamOptions Options for handling streaming responses\n * @returns Promise that resolves with the method's return value\n */\n call<T extends SerializableReturnValue>(\n method: string,\n args?: SerializableValue[],\n streamOptions?: StreamOptions\n ): Promise<T>;\n call<T = unknown>(\n method: string,\n args?: unknown[],\n streamOptions?: StreamOptions\n ): Promise<T>;\n async call<T>(\n method: string,\n args: unknown[] = [],\n streamOptions?: StreamOptions\n ): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const id = Math.random().toString(36).slice(2);\n this._pendingCalls.set(id, {\n reject,\n resolve: (value: unknown) => resolve(value as T),\n stream: streamOptions,\n type: null as T\n });\n\n const request: RPCRequest = {\n args,\n id,\n method,\n type: MessageType.RPC\n };\n\n this.send(JSON.stringify(request));\n });\n }\n}\n\n/**\n * Make an HTTP request to an Agent\n * @param opts Connection options\n * @param init Request initialization options\n * @returns Promise resolving to a Response\n */\nexport function agentFetch(opts: AgentClientFetchOptions, init?: RequestInit) {\n const agentNamespace = camelCaseToKebabCase(opts.agent);\n\n return PartySocket.fetch(\n {\n party: agentNamespace,\n prefix: \"agents\",\n room: opts.name || \"default\",\n ...opts\n },\n init\n );\n}\n"],"mappings":";;;;;;;;;AAyDA,SAAgB,qBAAqB,KAAqB;AAExD,KAAI,QAAQ,IAAI,aAAa,IAAI,QAAQ,IAAI,aAAa,CACxD,QAAO,IAAI,aAAa,CAAC,QAAQ,MAAM,IAAI;CAI7C,IAAI,aAAa,IAAI,QACnB,WACC,WAAW,IAAI,OAAO,aAAa,GACrC;AACD,cAAa,WAAW,WAAW,IAAI,GAAG,WAAW,MAAM,EAAE,GAAG;AAEhE,QAAO,WAAW,QAAQ,MAAM,IAAI,CAAC,QAAQ,MAAM,GAAG;;;;;AAMxD,IAAa,cAAb,cAAkD,YAAY;;;;CAI5D,OAAO,MAAM,OAA6C;AACxD,QAAM,IAAI,MACR,+DACD;;CAeH,YAAY,SAAoC;EAC9C,MAAM,iBAAiB,qBAAqB,QAAQ,MAAM;AAC1D,QAAM;GACJ,OAAO;GACP,QAAQ;GACR,MAAM,QAAQ,QAAQ;GACtB,GAAG;GACJ,CAAC;uCAjBoB,IAAI,KAQzB;AAUD,OAAK,QAAQ;AACb,OAAK,OAAO,QAAQ,QAAQ;AAC5B,OAAK,UAAU;AAEf,OAAK,iBAAiB,YAAY,UAAU;AAC1C,OAAI,OAAO,MAAM,SAAS,UAAU;IAClC,IAAIA;AACJ,QAAI;AACF,qBAAgB,KAAK,MAAM,MAAM,KAAK;aAC/B,QAAQ;AAGf;;AAEF,QAAI,cAAc,SAAS,YAAY,gBAAgB;AACrD,UAAK,QAAQ,gBAAgB,cAAc,OAAgB,SAAS;AACpE;;AAEF,QAAI,cAAc,SAAS,YAAY,KAAK;KAC1C,MAAM,WAAW;KACjB,MAAM,UAAU,KAAK,cAAc,IAAI,SAAS,GAAG;AACnD,SAAI,CAAC,QAAS;AAEd,SAAI,CAAC,SAAS,SAAS;AACrB,cAAQ,OAAO,IAAI,MAAM,SAAS,MAAM,CAAC;AACzC,WAAK,cAAc,OAAO,SAAS,GAAG;AACtC,cAAQ,QAAQ,UAAU,SAAS,MAAM;AACzC;;AAIF,SAAI,UAAU,SACZ,KAAI,SAAS,MAAM;AACjB,cAAQ,QAAQ,SAAS,OAAO;AAChC,WAAK,cAAc,OAAO,SAAS,GAAG;AACtC,cAAQ,QAAQ,SAAS,SAAS,OAAO;WAEzC,SAAQ,QAAQ,UAAU,SAAS,OAAO;UAEvC;AAEL,cAAQ,QAAQ,SAAS,OAAO;AAChC,WAAK,cAAc,OAAO,SAAS,GAAG;;;;IAI5C;;CAGJ,SAAS,OAAc;AACrB,OAAK,KAAK,KAAK,UAAU;GAAE;GAAO,MAAM,YAAY;GAAgB,CAAC,CAAC;AACtE,OAAK,QAAQ,gBAAgB,OAAO,SAAS;;CAoB/C,MAAM,KACJ,QACA,OAAkB,EAAE,EACpB,eACY;AACZ,SAAO,IAAI,SAAY,SAAS,WAAW;GACzC,MAAM,KAAK,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE;AAC9C,QAAK,cAAc,IAAI,IAAI;IACzB;IACA,UAAU,UAAmB,QAAQ,MAAW;IAChD,QAAQ;IACR,MAAM;IACP,CAAC;GAEF,MAAMC,UAAsB;IAC1B;IACA;IACA;IACA,MAAM,YAAY;IACnB;AAED,QAAK,KAAK,KAAK,UAAU,QAAQ,CAAC;IAClC;;;;;;;;;AAUN,SAAgB,WAAW,MAA+B,MAAoB;CAC5E,MAAM,iBAAiB,qBAAqB,KAAK,MAAM;AAEvD,QAAO,YAAY,MACjB;EACE,OAAO;EACP,QAAQ;EACR,MAAM,KAAK,QAAQ;EACnB,GAAG;EACJ,EACD,KACD"}
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./ai-types-
|
|
2
|
-
import { n as agentFetch, r as camelCaseToKebabCase, t as AgentClient } from "./client-
|
|
1
|
+
import "./ai-types-DEtF_8Km.js";
|
|
2
|
+
import { n as agentFetch, r as camelCaseToKebabCase, t as AgentClient } from "./client-DjTPRM8-.js";
|
|
3
3
|
|
|
4
4
|
export { AgentClient, agentFetch, camelCaseToKebabCase };
|
package/dist/codemode/ai.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "../context-BkKbAa1R.js";
|
|
2
|
-
import "../ai-types-
|
|
3
|
-
import "../client-
|
|
2
|
+
import "../ai-types-DEtF_8Km.js";
|
|
3
|
+
import "../client-DjTPRM8-.js";
|
|
4
4
|
import "../client-QZa2Rq0l.js";
|
|
5
5
|
import "../do-oauth-client-provider-B1fVIshX.js";
|
|
6
|
-
import { s as getAgentByName } from "../src-
|
|
6
|
+
import { s as getAgentByName } from "../src-BZDh910Z.js";
|
|
7
7
|
import { generateObject, tool } from "ai";
|
|
8
8
|
import { openai } from "@ai-sdk/openai";
|
|
9
9
|
import { z } from "zod/v3";
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
h as TransportType,
|
|
4
4
|
t as MCPClientManager,
|
|
5
5
|
u as MCPConnectionState
|
|
6
|
-
} from "./client-
|
|
6
|
+
} from "./client-BZVYeBmf.js";
|
|
7
7
|
import { t as Observability } from "./index-CyDpAVHZ.js";
|
|
8
|
-
import { n as MessageType } from "./ai-types-
|
|
8
|
+
import { n as MessageType } from "./ai-types-U8lYA0o8.js";
|
|
9
9
|
import {
|
|
10
10
|
Connection,
|
|
11
11
|
Connection as Connection$1,
|
|
@@ -574,4 +574,4 @@ export {
|
|
|
574
574
|
callable as x,
|
|
575
575
|
StreamingResponse as y
|
|
576
576
|
};
|
|
577
|
-
//# sourceMappingURL=index-
|
|
577
|
+
//# sourceMappingURL=index-B6XHf8p0.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as AgentEmail } from "./context-_sPQqJWv.js";
|
|
2
|
-
import { h as TransportType } from "./client-
|
|
2
|
+
import { h as TransportType } from "./client-BZVYeBmf.js";
|
|
3
3
|
import "./mcp-CzbSsLfc.js";
|
|
4
4
|
import "./do-oauth-client-provider-B-ryFIPr.js";
|
|
5
5
|
import "./index-CyDpAVHZ.js";
|
|
6
|
-
import "./ai-types-
|
|
6
|
+
import "./ai-types-U8lYA0o8.js";
|
|
7
7
|
import {
|
|
8
8
|
C as createCatchAllEmailResolver,
|
|
9
9
|
D as routeAgentEmail,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
w as createHeaderBasedEmailResolver,
|
|
35
35
|
x as callable,
|
|
36
36
|
y as StreamingResponse
|
|
37
|
-
} from "./index-
|
|
37
|
+
} from "./index-B6XHf8p0.js";
|
|
38
38
|
export {
|
|
39
39
|
Agent,
|
|
40
40
|
AgentContext,
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./context-BkKbAa1R.js";
|
|
2
|
-
import "./ai-types-
|
|
3
|
-
import "./client-
|
|
2
|
+
import "./ai-types-DEtF_8Km.js";
|
|
3
|
+
import "./client-DjTPRM8-.js";
|
|
4
4
|
import "./client-QZa2Rq0l.js";
|
|
5
5
|
import "./do-oauth-client-provider-B1fVIshX.js";
|
|
6
|
-
import { a as createCatchAllEmailResolver, c as getCurrentAgent, d as unstable_callable, i as createAddressBasedEmailResolver, l as routeAgentEmail, n as StreamingResponse, o as createHeaderBasedEmailResolver, r as callable, s as getAgentByName, t as Agent, u as routeAgentRequest } from "./src-
|
|
6
|
+
import { a as createCatchAllEmailResolver, c as getCurrentAgent, d as unstable_callable, i as createAddressBasedEmailResolver, l as routeAgentEmail, n as StreamingResponse, o as createHeaderBasedEmailResolver, r as callable, s as getAgentByName, t as Agent, u as routeAgentRequest } from "./src-BZDh910Z.js";
|
|
7
7
|
|
|
8
8
|
export { Agent, StreamingResponse, callable, createAddressBasedEmailResolver, createCatchAllEmailResolver, createHeaderBasedEmailResolver, getAgentByName, getCurrentAgent, routeAgentEmail, routeAgentRequest, unstable_callable };
|
package/dist/mcp/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as MCPConnectionResult, c as RegisterServerOptions, i as MCPClientOAuthResult, l as getNamespacedData, n as MCPClientManagerOptions, o as MCPDiscoverResult, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions, t as MCPClientManager } from "../client-
|
|
1
|
+
import { a as MCPConnectionResult, c as RegisterServerOptions, i as MCPClientOAuthResult, l as getNamespacedData, n as MCPClientManagerOptions, o as MCPDiscoverResult, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions, t as MCPClientManager } from "../client-BZVYeBmf.js";
|
|
2
2
|
import "../mcp-CzbSsLfc.js";
|
|
3
3
|
import "../do-oauth-client-provider-B-ryFIPr.js";
|
|
4
4
|
export { MCPClientManager, MCPClientManagerOptions, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MCPConnectionResult, MCPDiscoverResult, MCPServerOptions, RegisterServerOptions, getNamespacedData };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "../context-_sPQqJWv.js";
|
|
2
|
-
import { a as MCPConnectionResult, d as BaseTransportType, f as CORSOptions, i as MCPClientOAuthResult, m as ServeOptions, o as MCPDiscoverResult, p as MaybePromise, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions } from "../client-
|
|
2
|
+
import { a as MCPConnectionResult, d as BaseTransportType, f as CORSOptions, i as MCPClientOAuthResult, m as ServeOptions, o as MCPDiscoverResult, p as MaybePromise, r as MCPClientOAuthCallbackConfig, s as MCPServerOptions } from "../client-BZVYeBmf.js";
|
|
3
3
|
import "../mcp-CzbSsLfc.js";
|
|
4
4
|
import "../do-oauth-client-provider-B-ryFIPr.js";
|
|
5
5
|
import "../index-CyDpAVHZ.js";
|
|
6
|
-
import "../ai-types-
|
|
7
|
-
import { o as Connection, s as ConnectionContext, t as Agent } from "../index-
|
|
6
|
+
import "../ai-types-U8lYA0o8.js";
|
|
7
|
+
import { o as Connection, s as ConnectionContext, t as Agent } from "../index-B6XHf8p0.js";
|
|
8
8
|
import { SSEClientTransport, SSEClientTransportOptions } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
9
9
|
import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
10
10
|
import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage, MessageExtraInfo } from "@modelcontextprotocol/sdk/types.js";
|
|
@@ -27,8 +27,6 @@ declare class StreamableHTTPEdgeClientTransport extends StreamableHTTPClientTran
|
|
|
27
27
|
}
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/mcp/worker-transport.d.ts
|
|
30
|
-
declare const SUPPORTED_PROTOCOL_VERSIONS: readonly ["2025-03-26", "2025-06-18"];
|
|
31
|
-
type ProtocolVersion = (typeof SUPPORTED_PROTOCOL_VERSIONS)[number];
|
|
32
30
|
interface MCPStorageApi {
|
|
33
31
|
get(): Promise<TransportState | undefined> | TransportState | undefined;
|
|
34
32
|
set(state: TransportState): Promise<void> | void;
|
|
@@ -36,7 +34,6 @@ interface MCPStorageApi {
|
|
|
36
34
|
interface TransportState {
|
|
37
35
|
sessionId?: string;
|
|
38
36
|
initialized: boolean;
|
|
39
|
-
protocolVersion?: ProtocolVersion;
|
|
40
37
|
}
|
|
41
38
|
interface WorkerTransportOptions {
|
|
42
39
|
sessionIdGenerator?: () => string;
|
|
@@ -64,7 +61,6 @@ declare class WorkerTransport implements Transport {
|
|
|
64
61
|
private requestToStreamMapping;
|
|
65
62
|
private requestResponseMap;
|
|
66
63
|
private corsOptions?;
|
|
67
|
-
private protocolVersion?;
|
|
68
64
|
private storage?;
|
|
69
65
|
private stateRestored;
|
|
70
66
|
sessionId?: string;
|
|
@@ -82,6 +78,19 @@ declare class WorkerTransport implements Transport {
|
|
|
82
78
|
*/
|
|
83
79
|
private saveState;
|
|
84
80
|
start(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Validates the MCP-Protocol-Version header on incoming requests.
|
|
83
|
+
*
|
|
84
|
+
* This performs a simple check: if a version header is present, it must be
|
|
85
|
+
* in the SUPPORTED_PROTOCOL_VERSIONS list. We do not track the negotiated
|
|
86
|
+
* version or enforce version consistency across requests - the SDK handles
|
|
87
|
+
* version negotiation during initialization, and we simply reject any
|
|
88
|
+
* explicitly unsupported versions.
|
|
89
|
+
*
|
|
90
|
+
* - Header present and supported: Accept
|
|
91
|
+
* - Header present and unsupported: 400 Bad Request
|
|
92
|
+
* - Header missing: Accept (version validation is optional)
|
|
93
|
+
*/
|
|
85
94
|
private validateProtocolVersion;
|
|
86
95
|
private getHeaders;
|
|
87
96
|
handleRequest(request: Request, parsedBody?: unknown): Promise<Response>;
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "../context-BkKbAa1R.js";
|
|
2
|
-
import { t as MessageType } from "../ai-types-
|
|
3
|
-
import "../client-
|
|
2
|
+
import { t as MessageType } from "../ai-types-DEtF_8Km.js";
|
|
3
|
+
import "../client-DjTPRM8-.js";
|
|
4
4
|
import "../client-QZa2Rq0l.js";
|
|
5
5
|
import "../do-oauth-client-provider-B1fVIshX.js";
|
|
6
|
-
import { c as getCurrentAgent, s as getAgentByName, t as Agent } from "../src-
|
|
6
|
+
import { c as getCurrentAgent, s as getAgentByName, t as Agent } from "../src-BZDh910Z.js";
|
|
7
7
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
8
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
9
9
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
10
|
-
import { ElicitRequestSchema, InitializeRequestSchema, JSONRPCMessageSchema, isInitializeRequest, isJSONRPCError, isJSONRPCNotification, isJSONRPCRequest, isJSONRPCResponse } from "@modelcontextprotocol/sdk/types.js";
|
|
10
|
+
import { ElicitRequestSchema, InitializeRequestSchema, JSONRPCMessageSchema, SUPPORTED_PROTOCOL_VERSIONS, isInitializeRequest, isJSONRPCError, isJSONRPCNotification, isJSONRPCRequest, isJSONRPCResponse } from "@modelcontextprotocol/sdk/types.js";
|
|
11
11
|
|
|
12
12
|
//#region src/mcp/utils.ts
|
|
13
13
|
/**
|
|
@@ -694,8 +694,6 @@ var StreamableHTTPEdgeClientTransport = class extends StreamableHTTPClientTransp
|
|
|
694
694
|
|
|
695
695
|
//#endregion
|
|
696
696
|
//#region src/mcp/worker-transport.ts
|
|
697
|
-
const SUPPORTED_PROTOCOL_VERSIONS = ["2025-03-26", "2025-06-18"];
|
|
698
|
-
const DEFAULT_PROTOCOL_VERSION = "2025-03-26";
|
|
699
697
|
const MCP_PROTOCOL_VERSION_HEADER = "MCP-Protocol-Version";
|
|
700
698
|
var WorkerTransport = class {
|
|
701
699
|
constructor(options) {
|
|
@@ -723,7 +721,6 @@ var WorkerTransport = class {
|
|
|
723
721
|
if (state) {
|
|
724
722
|
this.sessionId = state.sessionId;
|
|
725
723
|
this.initialized = state.initialized;
|
|
726
|
-
this.protocolVersion = state.protocolVersion;
|
|
727
724
|
}
|
|
728
725
|
this.stateRestored = true;
|
|
729
726
|
}
|
|
@@ -734,8 +731,7 @@ var WorkerTransport = class {
|
|
|
734
731
|
if (!this.storage) return;
|
|
735
732
|
const state = {
|
|
736
733
|
sessionId: this.sessionId,
|
|
737
|
-
initialized: this.initialized
|
|
738
|
-
protocolVersion: this.protocolVersion
|
|
734
|
+
initialized: this.initialized
|
|
739
735
|
};
|
|
740
736
|
await Promise.resolve(this.storage.set(state));
|
|
741
737
|
}
|
|
@@ -743,44 +739,26 @@ var WorkerTransport = class {
|
|
|
743
739
|
if (this.started) throw new Error("Transport already started");
|
|
744
740
|
this.started = true;
|
|
745
741
|
}
|
|
742
|
+
/**
|
|
743
|
+
* Validates the MCP-Protocol-Version header on incoming requests.
|
|
744
|
+
*
|
|
745
|
+
* This performs a simple check: if a version header is present, it must be
|
|
746
|
+
* in the SUPPORTED_PROTOCOL_VERSIONS list. We do not track the negotiated
|
|
747
|
+
* version or enforce version consistency across requests - the SDK handles
|
|
748
|
+
* version negotiation during initialization, and we simply reject any
|
|
749
|
+
* explicitly unsupported versions.
|
|
750
|
+
*
|
|
751
|
+
* - Header present and supported: Accept
|
|
752
|
+
* - Header present and unsupported: 400 Bad Request
|
|
753
|
+
* - Header missing: Accept (version validation is optional)
|
|
754
|
+
*/
|
|
746
755
|
validateProtocolVersion(request) {
|
|
747
|
-
const
|
|
748
|
-
if (!
|
|
749
|
-
if (!this.protocolVersion || this.protocolVersion === DEFAULT_PROTOCOL_VERSION) return;
|
|
750
|
-
return new Response(JSON.stringify({
|
|
751
|
-
jsonrpc: "2.0",
|
|
752
|
-
error: {
|
|
753
|
-
code: -32e3,
|
|
754
|
-
message: `Bad Request: ${MCP_PROTOCOL_VERSION_HEADER} header is required`
|
|
755
|
-
},
|
|
756
|
-
id: null
|
|
757
|
-
}), {
|
|
758
|
-
status: 400,
|
|
759
|
-
headers: {
|
|
760
|
-
"Content-Type": "application/json",
|
|
761
|
-
...this.getHeaders()
|
|
762
|
-
}
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
if (!SUPPORTED_PROTOCOL_VERSIONS.includes(versionHeader)) return new Response(JSON.stringify({
|
|
766
|
-
jsonrpc: "2.0",
|
|
767
|
-
error: {
|
|
768
|
-
code: -32e3,
|
|
769
|
-
message: `Bad Request: Unsupported ${MCP_PROTOCOL_VERSION_HEADER}: ${versionHeader}. Supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")}`
|
|
770
|
-
},
|
|
771
|
-
id: null
|
|
772
|
-
}), {
|
|
773
|
-
status: 400,
|
|
774
|
-
headers: {
|
|
775
|
-
"Content-Type": "application/json",
|
|
776
|
-
...this.getHeaders()
|
|
777
|
-
}
|
|
778
|
-
});
|
|
779
|
-
if (this.protocolVersion && versionHeader !== this.protocolVersion) return new Response(JSON.stringify({
|
|
756
|
+
const protocolVersion = request.headers.get(MCP_PROTOCOL_VERSION_HEADER);
|
|
757
|
+
if (protocolVersion !== null && !SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) return new Response(JSON.stringify({
|
|
780
758
|
jsonrpc: "2.0",
|
|
781
759
|
error: {
|
|
782
760
|
code: -32e3,
|
|
783
|
-
message: `Bad Request:
|
|
761
|
+
message: `Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`
|
|
784
762
|
},
|
|
785
763
|
id: null
|
|
786
764
|
}), {
|
|
@@ -983,12 +961,6 @@ var WorkerTransport = class {
|
|
|
983
961
|
...this.getHeaders()
|
|
984
962
|
}
|
|
985
963
|
});
|
|
986
|
-
const initRequest = messages.find(isInitializeRequest);
|
|
987
|
-
if (initRequest?.params) {
|
|
988
|
-
const version = initRequest.params.protocolVersion;
|
|
989
|
-
if (version && SUPPORTED_PROTOCOL_VERSIONS.includes(version)) this.protocolVersion = version;
|
|
990
|
-
else this.protocolVersion = DEFAULT_PROTOCOL_VERSION;
|
|
991
|
-
}
|
|
992
964
|
this.sessionId = this.sessionIdGenerator?.();
|
|
993
965
|
this.initialized = true;
|
|
994
966
|
await this.saveState();
|