agents 0.2.32 → 0.2.34
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/dist/ai-chat-agent.d.ts +9 -11
- package/dist/ai-chat-agent.js +1 -1
- package/dist/ai-chat-agent.js.map +1 -1
- package/dist/ai-chat-v5-migration.js +154 -2
- package/dist/ai-chat-v5-migration.js.map +1 -0
- package/dist/ai-react.d.ts +6 -10
- package/dist/{ai-types-U8lYA0o8.d.ts → ai-types-0OnT3FHg.d.ts} +1 -1
- package/dist/ai-types.d.ts +1 -1
- package/dist/{client-BZVYeBmf.d.ts → client-BINtT7y-.d.ts} +3 -3
- package/dist/{client-ClORm6f0.d.ts → client-CdM5I962.d.ts} +2 -2
- package/dist/client.d.ts +1 -2
- package/dist/client.js +0 -1
- package/dist/codemode/ai.js +1 -2
- package/dist/codemode/ai.js.map +1 -1
- package/dist/{context-_sPQqJWv.d.ts → context-DcbQ8o7k.d.ts} +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/{do-oauth-client-provider-B-ryFIPr.d.ts → do-oauth-client-provider--To1Tsjj.d.ts} +1 -1
- package/dist/{index-B6XHf8p0.d.ts → index-CfZ2mfMI.d.ts} +12 -13
- package/dist/{index-CyDpAVHZ.d.ts → index-DLuxm_9W.d.ts} +2 -2
- package/dist/index.d.ts +4 -7
- package/dist/index.js +0 -1
- package/dist/mcp/client.d.ts +1 -3
- package/dist/mcp/do-oauth-client-provider.d.ts +1 -1
- package/dist/mcp/index.d.ts +5 -8
- package/dist/mcp/index.js.map +1 -1
- package/dist/{mcp-CzbSsLfc.d.ts → mcp-CPSfGUgd.d.ts} +1 -1
- package/dist/observability/index.d.ts +1 -2
- package/dist/observability/index.js +0 -1
- package/dist/react.d.ts +133 -14
- package/dist/schedule.d.ts +18 -72
- package/dist/{serializable-C4GLimgv.d.ts → serializable-Crsj26mx.d.ts} +1 -1
- package/dist/serializable.d.ts +1 -1
- package/dist/src-BZDh910Z.js.map +1 -1
- package/package.json +28 -13
- package/dist/ai-chat-v5-migration-DguhuLKF.js +0 -155
- package/dist/ai-chat-v5-migration-DguhuLKF.js.map +0 -1
- package/dist/react-DYwejKBr.d.ts +0 -131
|
@@ -1,3 +1,155 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/ai-chat-v5-migration.ts
|
|
2
|
+
/**
|
|
3
|
+
* Tool call state mapping for v4 to v5 migration
|
|
4
|
+
*/
|
|
5
|
+
const STATE_MAP = {
|
|
6
|
+
"partial-call": "input-streaming",
|
|
7
|
+
call: "input-available",
|
|
8
|
+
result: "output-available",
|
|
9
|
+
error: "output-error"
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Checks if a message is already in the UIMessage format (has parts array)
|
|
13
|
+
*/
|
|
14
|
+
function isUIMessage(message) {
|
|
15
|
+
return typeof message === "object" && message !== null && "parts" in message && Array.isArray(message.parts);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if a message is in legacy format (content as string)
|
|
19
|
+
*/
|
|
20
|
+
function isLegacyMessage(message) {
|
|
21
|
+
return typeof message === "object" && message !== null && "role" in message && "content" in message && typeof message.role === "string" && typeof message.content === "string";
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Type guard to check if a message has corrupted array content format
|
|
25
|
+
* Detects: {role: "user", content: [{type: "text", text: "..."}]}
|
|
26
|
+
*/
|
|
27
|
+
function isCorruptArrayMessage(message) {
|
|
28
|
+
return typeof message === "object" && message !== null && "role" in message && "content" in message && typeof message.role === "string" && Array.isArray(message.content) && !("parts" in message);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Automatic message transformer following the blog post pattern
|
|
32
|
+
* Handles comprehensive migration from AI SDK v4 to v5 format
|
|
33
|
+
* @param message - Message in any legacy format
|
|
34
|
+
* @param index - Index for ID generation fallback
|
|
35
|
+
* @returns UIMessage in v5 format
|
|
36
|
+
*/
|
|
37
|
+
function autoTransformMessage(message, index = 0) {
|
|
38
|
+
if (isUIMessage(message)) return message;
|
|
39
|
+
const parts = [];
|
|
40
|
+
if (message.reasoning) parts.push({
|
|
41
|
+
type: "reasoning",
|
|
42
|
+
text: message.reasoning
|
|
43
|
+
});
|
|
44
|
+
if (message.toolInvocations && Array.isArray(message.toolInvocations)) message.toolInvocations.forEach((inv) => {
|
|
45
|
+
if (typeof inv === "object" && inv !== null && "toolName" in inv) {
|
|
46
|
+
const invObj = inv;
|
|
47
|
+
parts.push({
|
|
48
|
+
type: `tool-${invObj.toolName}`,
|
|
49
|
+
toolCallId: invObj.toolCallId,
|
|
50
|
+
state: STATE_MAP[invObj.state] || "input-available",
|
|
51
|
+
input: invObj.args,
|
|
52
|
+
output: invObj.result !== void 0 ? invObj.result : null
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
if (message.parts && Array.isArray(message.parts)) message.parts.forEach((part) => {
|
|
57
|
+
if (typeof part === "object" && part !== null && "type" in part) {
|
|
58
|
+
const partObj = part;
|
|
59
|
+
if (partObj.type === "file") parts.push({
|
|
60
|
+
type: "file",
|
|
61
|
+
url: partObj.url || (partObj.data ? `data:${partObj.mimeType || partObj.mediaType};base64,${partObj.data}` : void 0),
|
|
62
|
+
mediaType: partObj.mediaType || partObj.mimeType,
|
|
63
|
+
filename: partObj.filename
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (Array.isArray(message.content)) message.content.forEach((item) => {
|
|
68
|
+
if (typeof item === "object" && item !== null && "text" in item) {
|
|
69
|
+
const itemObj = item;
|
|
70
|
+
parts.push({
|
|
71
|
+
type: itemObj.type || "text",
|
|
72
|
+
text: itemObj.text || ""
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
if (!parts.length && message.content !== void 0) parts.push({
|
|
77
|
+
type: "text",
|
|
78
|
+
text: typeof message.content === "string" ? message.content : JSON.stringify(message.content)
|
|
79
|
+
});
|
|
80
|
+
if (!parts.length) parts.push({
|
|
81
|
+
type: "text",
|
|
82
|
+
text: typeof message === "string" ? message : JSON.stringify(message)
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
id: message.id || `msg-${index}`,
|
|
86
|
+
role: message.role === "data" ? "system" : message.role || "user",
|
|
87
|
+
parts
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Legacy single message migration for backward compatibility
|
|
92
|
+
*/
|
|
93
|
+
function migrateToUIMessage(message) {
|
|
94
|
+
return autoTransformMessage(message);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Automatic message transformer for arrays following the blog post pattern
|
|
98
|
+
* @param messages - Array of messages in any format
|
|
99
|
+
* @returns Array of UIMessages in v5 format
|
|
100
|
+
*/
|
|
101
|
+
function autoTransformMessages(messages) {
|
|
102
|
+
return messages.map((msg, i) => autoTransformMessage(msg, i));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Migrates an array of messages to UIMessage format (legacy compatibility)
|
|
106
|
+
* @param messages - Array of messages in old or new format
|
|
107
|
+
* @returns Array of UIMessages in the new format
|
|
108
|
+
*/
|
|
109
|
+
function migrateMessagesToUIFormat(messages) {
|
|
110
|
+
return autoTransformMessages(messages);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Checks if any messages in an array need migration
|
|
114
|
+
* @param messages - Array of messages to check
|
|
115
|
+
* @returns true if any messages are not in proper UIMessage format
|
|
116
|
+
*/
|
|
117
|
+
function needsMigration(messages) {
|
|
118
|
+
return messages.some((message) => {
|
|
119
|
+
if (isUIMessage(message)) return false;
|
|
120
|
+
if (isCorruptArrayMessage(message)) return true;
|
|
121
|
+
if (isLegacyMessage(message)) return true;
|
|
122
|
+
return true;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Analyzes the corruption types in a message array for debugging
|
|
127
|
+
* @param messages - Array of messages to analyze
|
|
128
|
+
* @returns Statistics about corruption types found
|
|
129
|
+
*/
|
|
130
|
+
function analyzeCorruption(messages) {
|
|
131
|
+
const stats = {
|
|
132
|
+
total: messages.length,
|
|
133
|
+
clean: 0,
|
|
134
|
+
legacyString: 0,
|
|
135
|
+
corruptArray: 0,
|
|
136
|
+
unknown: 0,
|
|
137
|
+
examples: {}
|
|
138
|
+
};
|
|
139
|
+
for (const message of messages) if (isUIMessage(message)) stats.clean++;
|
|
140
|
+
else if (isCorruptArrayMessage(message)) {
|
|
141
|
+
stats.corruptArray++;
|
|
142
|
+
if (!stats.examples.corruptArray) stats.examples.corruptArray = message;
|
|
143
|
+
} else if (isLegacyMessage(message)) {
|
|
144
|
+
stats.legacyString++;
|
|
145
|
+
if (!stats.examples.legacyString) stats.examples.legacyString = message;
|
|
146
|
+
} else {
|
|
147
|
+
stats.unknown++;
|
|
148
|
+
if (!stats.examples.unknown) stats.examples.unknown = message;
|
|
149
|
+
}
|
|
150
|
+
return stats;
|
|
151
|
+
}
|
|
2
152
|
|
|
3
|
-
|
|
153
|
+
//#endregion
|
|
154
|
+
export { analyzeCorruption, autoTransformMessage, autoTransformMessages, isUIMessage, migrateMessagesToUIFormat, migrateToUIMessage, needsMigration };
|
|
155
|
+
//# sourceMappingURL=ai-chat-v5-migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-chat-v5-migration.js","names":["parts: TransformMessagePart[]"],"sources":["../src/ai-chat-v5-migration.ts"],"sourcesContent":["import type { UIMessage } from \"ai\";\n\n/**\n * AI SDK v5 Migration following https://jhak.im/blog/ai-sdk-migration-handling-previously-saved-messages\n * Using exact types from the official AI SDK documentation\n */\n\n/**\n * AI SDK v5 Message Part types reference (from official AI SDK documentation)\n *\n * The migration logic below transforms legacy messages to match these official AI SDK v5 formats:\n * - TextUIPart: { type: \"text\", text: string, state?: \"streaming\" | \"done\" }\n * - ReasoningUIPart: { type: \"reasoning\", text: string, state?: \"streaming\" | \"done\", providerMetadata?: Record<string, unknown> }\n * - FileUIPart: { type: \"file\", mediaType: string, filename?: string, url: string }\n * - ToolUIPart: { type: `tool-${string}`, toolCallId: string, state: \"input-streaming\" | \"input-available\" | \"output-available\" | \"output-error\", input?: Record<string, unknown>, output?: unknown, errorText?: string, providerExecuted?: boolean }\n */\n\n/**\n * Tool invocation from v4 format\n */\ntype ToolInvocation = {\n toolCallId: string;\n toolName: string;\n args: Record<string, unknown>;\n result?: unknown;\n state: \"partial-call\" | \"call\" | \"result\" | \"error\";\n};\n\n/**\n * Legacy part from v4 format\n */\ntype LegacyPart = {\n type: string;\n text?: string;\n url?: string;\n data?: string;\n mimeType?: string;\n mediaType?: string;\n filename?: string;\n};\n\n/**\n * Legacy message format from AI SDK v4\n */\nexport type LegacyMessage = {\n id?: string;\n role: string;\n content: string;\n reasoning?: string;\n toolInvocations?: ToolInvocation[];\n parts?: LegacyPart[];\n [key: string]: unknown;\n};\n\n/**\n * Corrupt content item\n */\ntype CorruptContentItem = {\n type: string;\n text: string;\n};\n\n/**\n * Corrupted message format - has content as array instead of parts\n */\nexport type CorruptArrayMessage = {\n id?: string;\n role: string;\n content: CorruptContentItem[];\n reasoning?: string;\n toolInvocations?: ToolInvocation[];\n [key: string]: unknown;\n};\n\n/**\n * Union type for messages that could be in any format\n */\nexport type MigratableMessage = LegacyMessage | CorruptArrayMessage | UIMessage;\n\n/**\n * Tool call state mapping for v4 to v5 migration\n */\nconst STATE_MAP = {\n \"partial-call\": \"input-streaming\",\n call: \"input-available\",\n result: \"output-available\",\n error: \"output-error\"\n} as const;\n\n/**\n * Checks if a message is already in the UIMessage format (has parts array)\n */\nexport function isUIMessage(message: unknown): message is UIMessage {\n return (\n typeof message === \"object\" &&\n message !== null &&\n \"parts\" in message &&\n Array.isArray((message as { parts: unknown }).parts)\n );\n}\n\n/**\n * Type guard to check if a message is in legacy format (content as string)\n */\nfunction isLegacyMessage(message: unknown): message is LegacyMessage {\n return (\n typeof message === \"object\" &&\n message !== null &&\n \"role\" in message &&\n \"content\" in message &&\n typeof (message as { role: unknown }).role === \"string\" &&\n typeof (message as { content: unknown }).content === \"string\"\n );\n}\n\n/**\n * Type guard to check if a message has corrupted array content format\n * Detects: {role: \"user\", content: [{type: \"text\", text: \"...\"}]}\n */\nfunction isCorruptArrayMessage(\n message: unknown\n): message is CorruptArrayMessage {\n return (\n typeof message === \"object\" &&\n message !== null &&\n \"role\" in message &&\n \"content\" in message &&\n typeof (message as { role: unknown }).role === \"string\" &&\n Array.isArray((message as { content: unknown }).content) &&\n !(\"parts\" in message) // Ensure it's not already a UIMessage\n );\n}\n\n/**\n * Internal message part type for transformation\n */\ntype TransformMessagePart = {\n type: string;\n text?: string;\n toolCallId?: string;\n state?: string;\n input?: Record<string, unknown>;\n output?: unknown;\n url?: string;\n mediaType?: string;\n errorText?: string;\n filename?: string;\n};\n\n/**\n * Input message that could be in any format - using unknown for flexibility\n */\ntype InputMessage = {\n id?: string;\n role?: string;\n content?: unknown;\n reasoning?: string;\n toolInvocations?: unknown[];\n parts?: unknown[];\n [key: string]: unknown;\n};\n\n/**\n * Automatic message transformer following the blog post pattern\n * Handles comprehensive migration from AI SDK v4 to v5 format\n * @param message - Message in any legacy format\n * @param index - Index for ID generation fallback\n * @returns UIMessage in v5 format\n */\nexport function autoTransformMessage(\n message: InputMessage,\n index = 0\n): UIMessage {\n // Already in v5 format\n if (isUIMessage(message)) {\n return message;\n }\n\n const parts: TransformMessagePart[] = [];\n\n // Handle reasoning transformation\n if (message.reasoning) {\n parts.push({\n type: \"reasoning\",\n text: message.reasoning\n });\n }\n\n // Handle tool invocations transformation\n if (message.toolInvocations && Array.isArray(message.toolInvocations)) {\n message.toolInvocations.forEach((inv: unknown) => {\n if (typeof inv === \"object\" && inv !== null && \"toolName\" in inv) {\n const invObj = inv as ToolInvocation;\n parts.push({\n type: `tool-${invObj.toolName}`,\n toolCallId: invObj.toolCallId,\n state:\n STATE_MAP[invObj.state as keyof typeof STATE_MAP] ||\n \"input-available\",\n input: invObj.args,\n output: invObj.result !== undefined ? invObj.result : null\n });\n }\n });\n }\n\n // Handle file parts transformation\n if (message.parts && Array.isArray(message.parts)) {\n message.parts.forEach((part: unknown) => {\n if (typeof part === \"object\" && part !== null && \"type\" in part) {\n const partObj = part as LegacyPart;\n if (partObj.type === \"file\") {\n parts.push({\n type: \"file\",\n url:\n partObj.url ||\n (partObj.data\n ? `data:${partObj.mimeType || partObj.mediaType};base64,${partObj.data}`\n : undefined),\n mediaType: partObj.mediaType || partObj.mimeType,\n filename: partObj.filename\n });\n }\n }\n });\n }\n\n // Handle corrupt array format: {role: \"user\", content: [{type: \"text\", text: \"...\"}]}\n if (Array.isArray(message.content)) {\n message.content.forEach((item: unknown) => {\n if (typeof item === \"object\" && item !== null && \"text\" in item) {\n const itemObj = item as CorruptContentItem;\n parts.push({\n type: itemObj.type || \"text\",\n text: itemObj.text || \"\"\n });\n }\n });\n }\n\n // Fallback: convert plain content to text part\n if (!parts.length && message.content !== undefined) {\n parts.push({\n type: \"text\",\n text:\n typeof message.content === \"string\"\n ? message.content\n : JSON.stringify(message.content)\n });\n }\n\n // If still no parts, create a default text part\n if (!parts.length) {\n parts.push({\n type: \"text\",\n text: typeof message === \"string\" ? message : JSON.stringify(message)\n });\n }\n\n return {\n id: message.id || `msg-${index}`,\n role:\n message.role === \"data\"\n ? \"system\"\n : (message.role as \"user\" | \"assistant\" | \"system\") || \"user\",\n parts: parts as UIMessage[\"parts\"]\n };\n}\n\n/**\n * Legacy single message migration for backward compatibility\n */\nexport function migrateToUIMessage(message: MigratableMessage): UIMessage {\n return autoTransformMessage(message as InputMessage);\n}\n\n/**\n * Automatic message transformer for arrays following the blog post pattern\n * @param messages - Array of messages in any format\n * @returns Array of UIMessages in v5 format\n */\nexport function autoTransformMessages(messages: unknown[]): UIMessage[] {\n return messages.map((msg, i) => autoTransformMessage(msg as InputMessage, i));\n}\n\n/**\n * Migrates an array of messages to UIMessage format (legacy compatibility)\n * @param messages - Array of messages in old or new format\n * @returns Array of UIMessages in the new format\n */\nexport function migrateMessagesToUIFormat(\n messages: MigratableMessage[]\n): UIMessage[] {\n return autoTransformMessages(messages as InputMessage[]);\n}\n\n/**\n * Checks if any messages in an array need migration\n * @param messages - Array of messages to check\n * @returns true if any messages are not in proper UIMessage format\n */\nexport function needsMigration(messages: unknown[]): boolean {\n return messages.some((message) => {\n // If it's already a UIMessage, no migration needed\n if (isUIMessage(message)) {\n return false;\n }\n\n // Check for corrupt array format specifically\n if (isCorruptArrayMessage(message)) {\n return true;\n }\n\n // Check for legacy string format\n if (isLegacyMessage(message)) {\n return true;\n }\n\n // Any other format needs migration\n return true;\n });\n}\n\n/**\n * Analyzes the corruption types in a message array for debugging\n * @param messages - Array of messages to analyze\n * @returns Statistics about corruption types found\n */\nexport function analyzeCorruption(messages: unknown[]): {\n total: number;\n clean: number;\n legacyString: number;\n corruptArray: number;\n unknown: number;\n examples: {\n legacyString?: unknown;\n corruptArray?: unknown;\n unknown?: unknown;\n };\n} {\n const stats = {\n total: messages.length,\n clean: 0,\n legacyString: 0,\n corruptArray: 0,\n unknown: 0,\n examples: {} as {\n legacyString?: unknown;\n corruptArray?: unknown;\n unknown?: unknown;\n }\n };\n\n for (const message of messages) {\n if (isUIMessage(message)) {\n stats.clean++;\n } else if (isCorruptArrayMessage(message)) {\n stats.corruptArray++;\n if (!stats.examples.corruptArray) {\n stats.examples.corruptArray = message;\n }\n } else if (isLegacyMessage(message)) {\n stats.legacyString++;\n if (!stats.examples.legacyString) {\n stats.examples.legacyString = message;\n }\n } else {\n stats.unknown++;\n if (!stats.examples.unknown) {\n stats.examples.unknown = message;\n }\n }\n }\n\n return stats;\n}\n"],"mappings":";;;;AAkFA,MAAM,YAAY;CAChB,gBAAgB;CAChB,MAAM;CACN,QAAQ;CACR,OAAO;CACR;;;;AAKD,SAAgB,YAAY,SAAwC;AAClE,QACE,OAAO,YAAY,YACnB,YAAY,QACZ,WAAW,WACX,MAAM,QAAS,QAA+B,MAAM;;;;;AAOxD,SAAS,gBAAgB,SA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ACN,MAAI,CAAC,MAAM,SAAS,aAClB,OAAM,SAAS,eAAe;YAEvB,gBAAgB,QAAQ,EAAE;AACnC,QAAM;AACN,MAAI,CAAC,MAAM,SAAS,aAClB,OAAM,SAAS,eAAe;QAE3B;AACL,QAAM;AACN,MAAI,CAAC,MAAM,SAAS,QAClB,OAAM,SAAS,UAAU;;AAK/B,QAAO"}
|
package/dist/ai-react.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import "./context-
|
|
2
|
-
import "./client-
|
|
3
|
-
import "./
|
|
4
|
-
import "./
|
|
5
|
-
import "./
|
|
6
|
-
import "./
|
|
7
|
-
import "./index-B6XHf8p0.js";
|
|
8
|
-
import "./serializable-C4GLimgv.js";
|
|
9
|
-
import "./client-ClORm6f0.js";
|
|
10
|
-
import { r as useAgent } from "./react-DYwejKBr.js";
|
|
1
|
+
import "./context-DcbQ8o7k.js";
|
|
2
|
+
import "./client-BINtT7y-.js";
|
|
3
|
+
import "./ai-types-0OnT3FHg.js";
|
|
4
|
+
import "./index-CfZ2mfMI.js";
|
|
5
|
+
import "./client-CdM5I962.js";
|
|
6
|
+
import { useAgent } from "./react.js";
|
|
11
7
|
import { ChatInit, JSONSchema7, Tool, UIMessage } from "ai";
|
|
12
8
|
import { UseChatOptions, useChat } from "@ai-sdk/react";
|
|
13
9
|
|
|
@@ -124,4 +124,4 @@ type IncomingMessage<ChatMessage extends UIMessage = UIMessage> =
|
|
|
124
124
|
};
|
|
125
125
|
//#endregion
|
|
126
126
|
export { MessageType as n, OutgoingMessage as r, IncomingMessage as t };
|
|
127
|
-
//# sourceMappingURL=ai-types-
|
|
127
|
+
//# sourceMappingURL=ai-types-0OnT3FHg.d.ts.map
|
package/dist/ai-types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as MCPObservabilityEvent } from "./mcp-
|
|
2
|
-
import { t as AgentsOAuthProvider } from "./do-oauth-client-provider
|
|
1
|
+
import { t as MCPObservabilityEvent } from "./mcp-CPSfGUgd.js";
|
|
2
|
+
import { t as AgentsOAuthProvider } from "./do-oauth-client-provider--To1Tsjj.js";
|
|
3
3
|
import * as ai0 from "ai";
|
|
4
4
|
import { ToolSet } from "ai";
|
|
5
5
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
@@ -831,4 +831,4 @@ export {
|
|
|
831
831
|
MCPClientManager as t,
|
|
832
832
|
MCPConnectionState as u
|
|
833
833
|
};
|
|
834
|
-
//# sourceMappingURL=client-
|
|
834
|
+
//# sourceMappingURL=client-BINtT7y-.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
i as SerializableValue,
|
|
3
3
|
r as SerializableReturnValue
|
|
4
|
-
} from "./serializable-
|
|
4
|
+
} from "./serializable-Crsj26mx.js";
|
|
5
5
|
import {
|
|
6
6
|
PartyFetchOptions,
|
|
7
7
|
PartySocket,
|
|
@@ -101,4 +101,4 @@ export {
|
|
|
101
101
|
AgentClientOptions as r,
|
|
102
102
|
AgentClient as t
|
|
103
103
|
};
|
|
104
|
-
//# sourceMappingURL=client-
|
|
104
|
+
//# sourceMappingURL=client-CdM5I962.d.ts.map
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "./serializable-C4GLimgv.js";
|
|
2
1
|
import {
|
|
3
2
|
a as agentFetch,
|
|
4
3
|
i as StreamOptions,
|
|
@@ -6,7 +5,7 @@ import {
|
|
|
6
5
|
o as camelCaseToKebabCase,
|
|
7
6
|
r as AgentClientOptions,
|
|
8
7
|
t as AgentClient
|
|
9
|
-
} from "./client-
|
|
8
|
+
} from "./client-CdM5I962.js";
|
|
10
9
|
export {
|
|
11
10
|
AgentClient,
|
|
12
11
|
AgentClientFetchOptions,
|
package/dist/client.js
CHANGED
package/dist/codemode/ai.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import "../context-BkKbAa1R.js";
|
|
2
|
-
import "../ai-types-DEtF_8Km.js";
|
|
3
2
|
import "../client-DjTPRM8-.js";
|
|
4
3
|
import "../client-QZa2Rq0l.js";
|
|
5
4
|
import "../do-oauth-client-provider-B1fVIshX.js";
|
|
6
5
|
import { s as getAgentByName } from "../src-BZDh910Z.js";
|
|
7
6
|
import { generateObject, tool } from "ai";
|
|
7
|
+
import { z } from "zod";
|
|
8
8
|
import { openai } from "@ai-sdk/openai";
|
|
9
|
-
import { z } from "zod/v3";
|
|
10
9
|
import { compile } from "json-schema-to-typescript";
|
|
11
10
|
import { createTypeAlias, printNode, zodToTs } from "zod-to-ts";
|
|
12
11
|
import { WorkerEntrypoint, env } from "cloudflare:workers";
|
package/dist/codemode/ai.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.js","names":["tool","compileJsonSchemaToTs","printNodeZodToTs"],"sources":["../../src/codemode/ai.ts"],"sourcesContent":["import { generateObject, tool, type ToolSet } from \"ai\";\nimport { openai } from \"@ai-sdk/openai\";\nimport { z } from \"zod
|
|
1
|
+
{"version":3,"file":"ai.js","names":["tool","compileJsonSchemaToTs","printNodeZodToTs"],"sources":["../../src/codemode/ai.ts"],"sourcesContent":["import { generateObject, tool, type ToolSet } from \"ai\";\nimport { openai } from \"@ai-sdk/openai\";\nimport { z } from \"zod\";\nimport { compile as compileJsonSchemaToTs } from \"json-schema-to-typescript\";\nimport {\n zodToTs,\n printNode as printNodeZodToTs,\n createTypeAlias\n} from \"zod-to-ts\";\nimport { getAgentByName } from \"..\";\nimport { env, WorkerEntrypoint } from \"cloudflare:workers\";\n\nfunction toCamelCase(str: string) {\n return str\n .replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())\n .replace(/^[a-z]/, (letter) => letter.toUpperCase());\n}\n\nexport class CodeModeProxy extends WorkerEntrypoint<\n Cloudflare.Env,\n {\n binding: string;\n name: string;\n callback: string;\n }\n> {\n async callFunction(options: { functionName: string; args: unknown[] }) {\n const stub = (await getAgentByName(\n // @ts-expect-error\n env[this.ctx.props.binding] as AgentNamespace<T>,\n this.ctx.props.name\n )) as DurableObjectStub;\n // @ts-expect-error\n return stub[this.ctx.props.callback](options.functionName, options.args);\n }\n}\n\nexport async function experimental_codemode(options: {\n tools: ToolSet;\n prompt: string;\n globalOutbound: Fetcher;\n loader: WorkerLoader;\n proxy: Fetcher<CodeModeProxy>;\n}): Promise<{\n prompt: string;\n tools: ToolSet;\n}> {\n const generatedTypes = await generateTypes(options.tools);\n const prompt = `You are a helpful assistant. You have access to the \"codemode\" tool that can do different things: \n \n ${getToolDescriptions(options.tools)} \n \n If the user asks to do anything that be achieveable by the codemode tool, then simply pass over control to it by giving it a simple function description. Don't be too verbose.\n \n `;\n\n const codemodeTool = tool({\n description: \"codemode: a tool that can generate code to achieve a goal\",\n inputSchema: z.object({\n functionDescription: z.string()\n }),\n outputSchema: z.object({\n code: z.string(),\n result: z.any()\n }),\n execute: async ({ functionDescription }) => {\n try {\n const response = await generateObject({\n model: openai(\"gpt-4.1\"),\n schema: z.object({\n code: z.string()\n }),\n prompt: `You are a code generating machine.\n\n In addition to regular javascript, you can also use the following functions:\n\n ${generatedTypes} \n\n Respond only with the code, nothing else. Output javascript code.\n\n Generate an async function that achieves the goal. This async function doesn't accept any arguments.\n\n Here is user input: ${functionDescription}` // insert ts types for the tools here\n });\n\n // console.log(\"args\", response.object.args);\n const evaluator = createEvaluator(response.object.code, {\n proxy: options.proxy,\n loader: options.loader\n });\n const result = await evaluator();\n return { code: response.object.code, result: result };\n } catch (error) {\n console.error(\"error\", error);\n throw error;\n // return { code: \"\", result: error };\n }\n }\n });\n\n return { prompt, tools: { codemode: codemodeTool } };\n}\n\nfunction createEvaluator(\n code: string,\n options: {\n loader: WorkerLoader;\n proxy: Fetcher<CodeModeProxy>;\n }\n) {\n return async () => {\n const worker = options.loader.get(`code-${Math.random()}`, () => {\n return {\n compatibilityDate: \"2025-06-01\",\n compatibilityFlags: [\"nodejs_compat\"],\n mainModule: \"foo.js\",\n modules: {\n \"foo.js\": `\nimport { env, WorkerEntrypoint } from \"cloudflare:workers\";\n\nexport default class CodeModeWorker extends WorkerEntrypoint {\n async evaluate() {\n try {\n const { CodeModeProxy } = env;\n const codemode = new Proxy(\n {},\n {\n get: (target, prop) => {\n return (args) => {\n return CodeModeProxy.callFunction({\n functionName: prop,\n args: args, \n });\n };\n }\n }\n );\n\n return await ${code}();\n } catch (err) {\n return {\n err: err.message,\n stack: err.stack\n };\n }\n }\n}\n \n `\n },\n env: {\n // insert keys and bindings to tools/ts functions here\n CodeModeProxy: options.proxy\n },\n globalOutbound: null\n };\n });\n\n // @ts-expect-error TODO: fix this\n return await worker.getEntrypoint().evaluate();\n };\n}\n\nasync function generateTypes(tools: ToolSet) {\n let availableTools = \"\";\n let availableTypes = \"\";\n\n for (const [toolName, tool] of Object.entries(tools)) {\n // @ts-expect-error TODO: fix this\n const inputJsonType = tool.inputSchema.jsonSchema\n ? await compileJsonSchemaToTs(\n // @ts-expect-error TODO: fix this\n tool.inputSchema.jsonSchema,\n `${toCamelCase(toolName)}Input`,\n {\n format: false,\n bannerComment: \" \"\n }\n )\n : printNodeZodToTs(\n createTypeAlias(\n zodToTs(\n // @ts-expect-error TODO: fix this\n tool.inputSchema,\n `${toCamelCase(toolName)}Input`\n ).node,\n `${toCamelCase(toolName)}Input`\n )\n );\n\n const outputJsonType =\n // @ts-expect-error TODO: fix this\n tool.outputSchema?.jsonSchema\n ? await compileJsonSchemaToTs(\n // @ts-expect-error TODO: fix this\n tool.outputSchema?.jsonSchema,\n `${toCamelCase(toolName)}Output`,\n {\n format: false,\n bannerComment: \" \"\n }\n )\n : tool.outputSchema\n ? printNodeZodToTs(\n createTypeAlias(\n zodToTs(\n // @ts-expect-error TODO: fix this\n tool.outputSchema,\n `${toCamelCase(toolName)}Output`\n ).node,\n `${toCamelCase(toolName)}Output`\n )\n )\n : `interface ${toCamelCase(toolName)}Output { [key: string]: any }`;\n\n const InputType = inputJsonType\n .trim()\n .replace(\"export interface\", \"interface\");\n\n const OutputType = outputJsonType\n .trim()\n .replace(\"export interface\", \"interface\");\n\n availableTypes += `\\n${InputType}`;\n availableTypes += `\\n${OutputType}`;\n availableTools += `\\n\\t/*\\n\\t${tool.description?.trim()}\\n\\t*/`;\n availableTools += `\\n\\t${toolName}: (input: ${toCamelCase(toolName)}Input) => Promise<${toCamelCase(toolName)}Output>;`;\n availableTools += \"\\n\";\n }\n\n availableTools = `\\ndeclare const codemode: {${availableTools}}`;\n\n return `\n${availableTypes}\n${availableTools}\n `;\n}\n\nfunction getToolDescriptions(tools: ToolSet) {\n return Object.entries(tools)\n .map(([_toolName, tool]) => {\n return `\\n- ${tool.description?.trim()}`;\n })\n .join(\"\");\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAS,YAAY,KAAa;AAChC,QAAO,IACJ,QAAQ,cAAc,GAAG,WAAW,OAAO,aAAa,CAAC,CACzD,QAAQ,WAAW,WAAW,OAAO,aAAa,CAAC;;AAGxD,IAAa,gBAAb,cAAmC,iBAOjC;CACA,MAAM,aAAa,SAAoD;AAOrE,UANc,MAAM,eAElB,IAAI,KAAK,IAAI,MAAM,UACnB,KAAK,IAAI,MAAM,KAChB,EAEW,KAAK,IAAI,MAAM,UAAU,QAAQ,cAAc,QAAQ,KAAK;;;AAI5E,eAAsB,sBAAsB,SASzC;CACD,MAAM,iBAAiB,MAAM,cAAc,QAAQ,MAAM;AAqDzD,QAAO;EAAE,QApDM;;IAEb,oBAAoB,QAAQ,MAAM,CAAC;;;;;EAkDpB,OAAO,EAAE,UA5CL,KAAK;GACxB,aAAa;GACb,aAAa,EAAE,OAAO,EACpB,qBAAqB,EAAE,QAAQ,EAChC,CAAC;GACF,cAAc,EAAE,OAAO;IACrB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,KAAK;IAChB,CAAC;GACF,SAAS,OAAO,EAAE,0BAA0B;AAC1C,QAAI;KACF,MAAM,WAAW,MAAM,eAAe;MACpC,OAAO,OAAO,UAAU;MACxB,QAAQ,EAAE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,QAEEF,OAAK,cACL,GAAG,YAAY,SAAS,CAAC,QAC1B,CAAC,MACF,GAAG,YAAY,SAAS,CAAC,QAC1B,CACF,GACD,aAAa,YAAY,SAAS,CAAC;EAE3C,MAAM,YAAY,cACf,MAAM,CACN,QAAQ,oBAAoB,YAAY;EAE3C,MAAM,aAAa,eAChB,MAAM,CACN,QAAQ,oBAAoB,YAAY;AAE3C,oBAAkB,KAAK;AACvB,oBAAkB,KAAK;AACvB,oBAAkB,aAAaA,OAAK,aAAa,MAAM,CAAC;AACxD,oBAAkB,OAAO,SAAS,YAAY,YAAY,SAAS,CAAC,oBAAoB,YAAY,SAAS,CAAC;AAC9G,oBAAkB;;AAGpB,kBAAiB,8BAA8B,eAAe;AAE9D,QAAO;EACP,eAAe;EACf,eAAe;;;AAIjB,SAAS,oBAAoB,OAAgB;AAC3C,QAAO,OAAO,QAAQ,MAAM,CACzB,KAAK,CAAC,WAAWA,YAAU;AAC1B,SAAO,OAAOA,OAAK,aAAa,MAAM;GACtC,CACD,KAAK,GAAG"}
|
|
@@ -21,4 +21,4 @@ type AgentContextStore = {
|
|
|
21
21
|
declare const agentContext: AsyncLocalStorage<AgentContextStore>;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { AgentEmail as n, agentContext as r, AgentContextStore as t };
|
|
24
|
-
//# sourceMappingURL=context-
|
|
24
|
+
//# sourceMappingURL=context-DcbQ8o7k.d.ts.map
|
package/dist/context.d.ts
CHANGED
package/dist/{do-oauth-client-provider-B-ryFIPr.d.ts → do-oauth-client-provider--To1Tsjj.d.ts}
RENAMED
|
@@ -67,4 +67,4 @@ declare class DurableObjectOAuthClientProvider implements AgentsOAuthProvider {
|
|
|
67
67
|
}
|
|
68
68
|
//#endregion
|
|
69
69
|
export { DurableObjectOAuthClientProvider as n, AgentsOAuthProvider as t };
|
|
70
|
-
//# sourceMappingURL=do-oauth-client-provider
|
|
70
|
+
//# sourceMappingURL=do-oauth-client-provider--To1Tsjj.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { n as AgentEmail } from "./context-
|
|
1
|
+
import { n as AgentEmail } from "./context-DcbQ8o7k.js";
|
|
2
2
|
import {
|
|
3
3
|
h as TransportType,
|
|
4
4
|
t as MCPClientManager,
|
|
5
5
|
u as MCPConnectionState
|
|
6
|
-
} from "./client-
|
|
7
|
-
import { t as Observability } from "./index-
|
|
8
|
-
import { n as MessageType } from "./ai-types-
|
|
6
|
+
} from "./client-BINtT7y-.js";
|
|
7
|
+
import { t as Observability } from "./index-DLuxm_9W.js";
|
|
8
|
+
import { n as MessageType } from "./ai-types-0OnT3FHg.js";
|
|
9
9
|
import {
|
|
10
10
|
Connection,
|
|
11
11
|
Connection as Connection$1,
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
ServerCapabilities,
|
|
22
22
|
Tool
|
|
23
23
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
24
|
-
import { env } from "cloudflare:workers";
|
|
25
24
|
|
|
26
25
|
//#region src/index.d.ts
|
|
27
26
|
|
|
@@ -91,7 +90,7 @@ declare const unstable_callable: (metadata?: CallableMetadata) => void;
|
|
|
91
90
|
type QueueItem<T = string> = {
|
|
92
91
|
id: string;
|
|
93
92
|
payload: T;
|
|
94
|
-
callback: keyof Agent<
|
|
93
|
+
callback: keyof Agent<Cloudflare.Env>;
|
|
95
94
|
created_at: number;
|
|
96
95
|
};
|
|
97
96
|
/**
|
|
@@ -159,7 +158,7 @@ type MCPServer = {
|
|
|
159
158
|
capabilities: ServerCapabilities | null;
|
|
160
159
|
};
|
|
161
160
|
declare function getCurrentAgent<
|
|
162
|
-
T extends Agent<
|
|
161
|
+
T extends Agent<Cloudflare.Env> = Agent<Cloudflare.Env>
|
|
163
162
|
>(): {
|
|
164
163
|
agent: T | undefined;
|
|
165
164
|
connection: Connection | undefined;
|
|
@@ -172,7 +171,7 @@ declare function getCurrentAgent<
|
|
|
172
171
|
* @template State State type to store within the Agent
|
|
173
172
|
*/
|
|
174
173
|
declare class Agent<
|
|
175
|
-
Env =
|
|
174
|
+
Env extends Cloudflare.Env = Cloudflare.Env,
|
|
176
175
|
State = unknown,
|
|
177
176
|
Props extends Record<string, unknown> = Record<string, unknown>
|
|
178
177
|
> extends Server<Env, Props> {
|
|
@@ -418,7 +417,7 @@ declare class Agent<
|
|
|
418
417
|
* Namespace for creating Agent instances
|
|
419
418
|
* @template Agentic Type of the Agent class
|
|
420
419
|
*/
|
|
421
|
-
type AgentNamespace<Agentic extends Agent<
|
|
420
|
+
type AgentNamespace<Agentic extends Agent<Cloudflare.Env>> =
|
|
422
421
|
DurableObjectNamespace<Agentic>;
|
|
423
422
|
/**
|
|
424
423
|
* Agent's durable context
|
|
@@ -485,7 +484,7 @@ type EmailRoutingOptions<Env> = AgentOptions<Env> & {
|
|
|
485
484
|
* @param options The options for routing the email
|
|
486
485
|
* @returns A promise that resolves when the email has been routed
|
|
487
486
|
*/
|
|
488
|
-
declare function routeAgentEmail<Env>(
|
|
487
|
+
declare function routeAgentEmail<Env extends Cloudflare.Env = Cloudflare.Env>(
|
|
489
488
|
email: ForwardableEmailMessage,
|
|
490
489
|
env: Env,
|
|
491
490
|
options: EmailRoutingOptions<Env>
|
|
@@ -511,8 +510,8 @@ type EmailSendOptions = {
|
|
|
511
510
|
* @returns Promise resolving to an Agent instance stub
|
|
512
511
|
*/
|
|
513
512
|
declare function getAgentByName<
|
|
514
|
-
Env,
|
|
515
|
-
T extends Agent<Env>,
|
|
513
|
+
Env extends Cloudflare.Env = Cloudflare.Env,
|
|
514
|
+
T extends Agent<Env> = Agent<Env>,
|
|
516
515
|
Props extends Record<string, unknown> = Record<string, unknown>
|
|
517
516
|
>(
|
|
518
517
|
namespace: AgentNamespace<T>,
|
|
@@ -574,4 +573,4 @@ export {
|
|
|
574
573
|
callable as x,
|
|
575
574
|
StreamingResponse as y
|
|
576
575
|
};
|
|
577
|
-
//# sourceMappingURL=index-
|
|
576
|
+
//# sourceMappingURL=index-CfZ2mfMI.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as BaseEvent, t as MCPObservabilityEvent } from "./mcp-
|
|
1
|
+
import { n as BaseEvent, t as MCPObservabilityEvent } from "./mcp-CPSfGUgd.js";
|
|
2
2
|
|
|
3
3
|
//#region src/observability/agent.d.ts
|
|
4
4
|
|
|
@@ -55,4 +55,4 @@ export {
|
|
|
55
55
|
genericObservability as r,
|
|
56
56
|
Observability as t
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=index-
|
|
58
|
+
//# sourceMappingURL=index-DLuxm_9W.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { n as AgentEmail } from "./context-
|
|
2
|
-
import { h as TransportType } from "./client-
|
|
3
|
-
import "./
|
|
4
|
-
import "./do-oauth-client-provider-B-ryFIPr.js";
|
|
5
|
-
import "./index-CyDpAVHZ.js";
|
|
6
|
-
import "./ai-types-U8lYA0o8.js";
|
|
1
|
+
import { n as AgentEmail } from "./context-DcbQ8o7k.js";
|
|
2
|
+
import { h as TransportType } from "./client-BINtT7y-.js";
|
|
3
|
+
import "./ai-types-0OnT3FHg.js";
|
|
7
4
|
import {
|
|
8
5
|
C as createCatchAllEmailResolver,
|
|
9
6
|
D as routeAgentEmail,
|
|
@@ -34,7 +31,7 @@ import {
|
|
|
34
31
|
w as createHeaderBasedEmailResolver,
|
|
35
32
|
x as callable,
|
|
36
33
|
y as StreamingResponse
|
|
37
|
-
} from "./index-
|
|
34
|
+
} from "./index-CfZ2mfMI.js";
|
|
38
35
|
export {
|
|
39
36
|
Agent,
|
|
40
37
|
AgentContext,
|
package/dist/index.js
CHANGED
package/dist/mcp/client.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
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-
|
|
2
|
-
import "../mcp-CzbSsLfc.js";
|
|
3
|
-
import "../do-oauth-client-provider-B-ryFIPr.js";
|
|
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-BINtT7y-.js";
|
|
4
2
|
export { MCPClientManager, MCPClientManagerOptions, MCPClientOAuthCallbackConfig, MCPClientOAuthResult, MCPConnectionResult, MCPDiscoverResult, MCPServerOptions, RegisterServerOptions, getNamespacedData };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider
|
|
1
|
+
import { n as DurableObjectOAuthClientProvider, t as AgentsOAuthProvider } from "../do-oauth-client-provider--To1Tsjj.js";
|
|
2
2
|
export { AgentsOAuthProvider, DurableObjectOAuthClientProvider };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import "../context-
|
|
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-
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
import "../index-CyDpAVHZ.js";
|
|
6
|
-
import "../ai-types-U8lYA0o8.js";
|
|
7
|
-
import { o as Connection, s as ConnectionContext, t as Agent } from "../index-B6XHf8p0.js";
|
|
1
|
+
import "../context-DcbQ8o7k.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-BINtT7y-.js";
|
|
3
|
+
import "../ai-types-0OnT3FHg.js";
|
|
4
|
+
import { o as Connection, s as ConnectionContext, t as Agent } from "../index-CfZ2mfMI.js";
|
|
8
5
|
import { SSEClientTransport, SSEClientTransportOptions } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
9
6
|
import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
10
7
|
import { ElicitRequest, ElicitRequestSchema, ElicitResult, ElicitResult as ElicitResult$1, JSONRPCMessage, MessageExtraInfo } from "@modelcontextprotocol/sdk/types.js";
|
|
@@ -136,7 +133,7 @@ declare function createMcpHandler(server: McpServer | Server, options?: CreateMc
|
|
|
136
133
|
declare function experimental_createMcpHandler(server: McpServer | Server, options?: CreateMcpHandlerOptions): (request: Request, env: unknown, ctx: ExecutionContext) => Promise<Response>;
|
|
137
134
|
//#endregion
|
|
138
135
|
//#region src/mcp/index.d.ts
|
|
139
|
-
declare abstract class McpAgent<Env =
|
|
136
|
+
declare abstract class McpAgent<Env extends Cloudflare.Env = Cloudflare.Env, State = unknown, Props extends Record<string, unknown> = Record<string, unknown>> extends Agent<Env, State, Props> {
|
|
140
137
|
private _transport?;
|
|
141
138
|
props?: Props;
|
|
142
139
|
abstract server: MaybePromise<McpServer | Server>;
|