agents 0.2.32 → 0.2.35
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-CxZRDFxS.d.ts} +14 -14
- 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 +1 -1
- package/dist/schedule.js +1 -1
- package/dist/schedule.js.map +1 -1
- 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
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"durable objects"
|
|
10
10
|
],
|
|
11
11
|
"type": "module",
|
|
12
|
-
"version": "0.2.
|
|
12
|
+
"version": "0.2.35",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"repository": {
|
|
15
15
|
"directory": "packages/agents",
|
|
@@ -24,39 +24,54 @@
|
|
|
24
24
|
"url": "https://github.com/cloudflare/agents/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@ai-sdk/openai": "2.0.73",
|
|
28
27
|
"@cfworker/json-schema": "^4.1.1",
|
|
29
|
-
"@modelcontextprotocol/sdk": "
|
|
30
|
-
"ai": "5.0.103",
|
|
28
|
+
"@modelcontextprotocol/sdk": "1.23.0",
|
|
31
29
|
"cron-schedule": "^6.0.0",
|
|
32
30
|
"json-schema": "^0.4.0",
|
|
33
31
|
"json-schema-to-typescript": "^15.0.4",
|
|
34
32
|
"mimetext": "^3.0.27",
|
|
35
33
|
"nanoid": "^5.1.6",
|
|
36
|
-
"partyserver": "^0.0
|
|
37
|
-
"partysocket": "1.1.
|
|
34
|
+
"partyserver": "^0.1.0",
|
|
35
|
+
"partysocket": "1.1.10",
|
|
38
36
|
"yargs": "^18.0.0",
|
|
39
|
-
"zod": "^3.25.76",
|
|
40
37
|
"zod-to-ts": "^2.0.0"
|
|
41
38
|
},
|
|
42
39
|
"devDependencies": {
|
|
43
|
-
"@
|
|
40
|
+
"@ai-sdk/openai": "2.0.88",
|
|
41
|
+
"@ai-sdk/react": "2.0.118",
|
|
42
|
+
"@cloudflare/workers-oauth-provider": "^0.2.2",
|
|
43
|
+
"@types/react": "^19.2.7",
|
|
44
44
|
"@types/yargs": "^17.0.35",
|
|
45
|
-
"
|
|
45
|
+
"ai": "5.0.116",
|
|
46
|
+
"react": "^19.2.3",
|
|
46
47
|
"vitest-browser-react": "^1.0.1",
|
|
47
|
-
"x402": "^0.
|
|
48
|
+
"x402": "^1.0.1",
|
|
49
|
+
"zod": "^4.1.8"
|
|
48
50
|
},
|
|
49
51
|
"peerDependencies": {
|
|
50
|
-
"
|
|
52
|
+
"@ai-sdk/openai": ">=2.0.0",
|
|
53
|
+
"@ai-sdk/react": ">=1.0.0",
|
|
54
|
+
"ai": ">=5.0.0",
|
|
55
|
+
"react": "^19.0.0",
|
|
51
56
|
"viem": ">=2.0.0",
|
|
52
|
-
"x402": "^0.7.1"
|
|
57
|
+
"x402": "^0.7.1",
|
|
58
|
+
"zod": "^3.25.0 || ^4.0.0"
|
|
53
59
|
},
|
|
54
60
|
"peerDependenciesMeta": {
|
|
55
|
-
"
|
|
61
|
+
"@ai-sdk/openai": {
|
|
62
|
+
"optional": true
|
|
63
|
+
},
|
|
64
|
+
"@ai-sdk/react": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"ai": {
|
|
56
68
|
"optional": true
|
|
57
69
|
},
|
|
58
70
|
"viem": {
|
|
59
71
|
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"x402": {
|
|
74
|
+
"optional": true
|
|
60
75
|
}
|
|
61
76
|
},
|
|
62
77
|
"types": "dist/index.d.ts",
|
|
@@ -1,155 +0,0 @@
|
|
|
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
|
-
}
|
|
152
|
-
|
|
153
|
-
//#endregion
|
|
154
|
-
export { migrateMessagesToUIFormat as a, isUIMessage as i, autoTransformMessage as n, migrateToUIMessage as o, autoTransformMessages as r, needsMigration as s, analyzeCorruption as t };
|
|
155
|
-
//# sourceMappingURL=ai-chat-v5-migration-DguhuLKF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ai-chat-v5-migration-DguhuLKF.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":"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"}
|
package/dist/react-DYwejKBr.d.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { p as MCPServersState, t as Agent } from "./index-B6XHf8p0.js";
|
|
2
|
-
import { n as RPCMethod, t as Method } from "./serializable-C4GLimgv.js";
|
|
3
|
-
import { i as StreamOptions } from "./client-ClORm6f0.js";
|
|
4
|
-
import { PartySocket } from "partysocket";
|
|
5
|
-
import { usePartySocket } from "partysocket/react";
|
|
6
|
-
|
|
7
|
-
//#region src/react.d.ts
|
|
8
|
-
type QueryObject = Record<string, string | null>;
|
|
9
|
-
interface CacheEntry {
|
|
10
|
-
promise: Promise<QueryObject>;
|
|
11
|
-
expiresAt: number;
|
|
12
|
-
}
|
|
13
|
-
declare function getCacheEntry(key: string): CacheEntry | undefined;
|
|
14
|
-
declare function setCacheEntry(
|
|
15
|
-
key: string,
|
|
16
|
-
promise: Promise<QueryObject>,
|
|
17
|
-
cacheTtl: number
|
|
18
|
-
): CacheEntry;
|
|
19
|
-
declare function deleteCacheEntry(key: string): void;
|
|
20
|
-
declare const _testUtils: {
|
|
21
|
-
queryCache: Map<string, CacheEntry>;
|
|
22
|
-
setCacheEntry: typeof setCacheEntry;
|
|
23
|
-
getCacheEntry: typeof getCacheEntry;
|
|
24
|
-
deleteCacheEntry: typeof deleteCacheEntry;
|
|
25
|
-
clearCache: () => void;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Options for the useAgent hook
|
|
29
|
-
* @template State Type of the Agent's state
|
|
30
|
-
*/
|
|
31
|
-
type UseAgentOptions<State = unknown> = Omit<
|
|
32
|
-
Parameters<typeof usePartySocket>[0],
|
|
33
|
-
"party" | "room" | "query"
|
|
34
|
-
> & {
|
|
35
|
-
/** Name of the agent to connect to */
|
|
36
|
-
agent: string;
|
|
37
|
-
/** Name of the specific Agent instance */
|
|
38
|
-
name?: string;
|
|
39
|
-
/** Query parameters - can be static object or async function */
|
|
40
|
-
query?: QueryObject | (() => Promise<QueryObject>);
|
|
41
|
-
/** Dependencies for async query caching */
|
|
42
|
-
queryDeps?: unknown[];
|
|
43
|
-
/** Cache TTL in milliseconds for auth tokens/time-sensitive data */
|
|
44
|
-
cacheTtl?: number;
|
|
45
|
-
/** Called when the Agent's state is updated */
|
|
46
|
-
onStateUpdate?: (state: State, source: "server" | "client") => void;
|
|
47
|
-
/** Called when MCP server state is updated */
|
|
48
|
-
onMcpUpdate?: (mcpServers: MCPServersState) => void;
|
|
49
|
-
};
|
|
50
|
-
type AllOptional<T> = T extends [infer A, ...infer R]
|
|
51
|
-
? undefined extends A
|
|
52
|
-
? AllOptional<R>
|
|
53
|
-
: false
|
|
54
|
-
: true;
|
|
55
|
-
type RPCMethods<T> = {
|
|
56
|
-
[K in keyof T as T[K] extends RPCMethod<T[K]> ? K : never]: RPCMethod<T[K]>;
|
|
57
|
-
};
|
|
58
|
-
type OptionalParametersMethod<T extends RPCMethod> =
|
|
59
|
-
AllOptional<Parameters<T>> extends true ? T : never;
|
|
60
|
-
type AgentMethods<T> = Omit<RPCMethods<T>, keyof Agent<any, any>>;
|
|
61
|
-
type OptionalAgentMethods<T> = {
|
|
62
|
-
[K in keyof AgentMethods<T> as AgentMethods<T>[K] extends OptionalParametersMethod<
|
|
63
|
-
AgentMethods<T>[K]
|
|
64
|
-
>
|
|
65
|
-
? K
|
|
66
|
-
: never]: OptionalParametersMethod<AgentMethods<T>[K]>;
|
|
67
|
-
};
|
|
68
|
-
type RequiredAgentMethods<T> = Omit<
|
|
69
|
-
AgentMethods<T>,
|
|
70
|
-
keyof OptionalAgentMethods<T>
|
|
71
|
-
>;
|
|
72
|
-
type AgentPromiseReturnType<T, K$1 extends keyof AgentMethods<T>> =
|
|
73
|
-
ReturnType<AgentMethods<T>[K$1]> extends Promise<any>
|
|
74
|
-
? ReturnType<AgentMethods<T>[K$1]>
|
|
75
|
-
: Promise<ReturnType<AgentMethods<T>[K$1]>>;
|
|
76
|
-
type OptionalArgsAgentMethodCall<AgentT> = <
|
|
77
|
-
K$1 extends keyof OptionalAgentMethods<AgentT>
|
|
78
|
-
>(
|
|
79
|
-
method: K$1,
|
|
80
|
-
args?: Parameters<OptionalAgentMethods<AgentT>[K$1]>,
|
|
81
|
-
streamOptions?: StreamOptions
|
|
82
|
-
) => AgentPromiseReturnType<AgentT, K$1>;
|
|
83
|
-
type RequiredArgsAgentMethodCall<AgentT> = <
|
|
84
|
-
K$1 extends keyof RequiredAgentMethods<AgentT>
|
|
85
|
-
>(
|
|
86
|
-
method: K$1,
|
|
87
|
-
args: Parameters<RequiredAgentMethods<AgentT>[K$1]>,
|
|
88
|
-
streamOptions?: StreamOptions
|
|
89
|
-
) => AgentPromiseReturnType<AgentT, K$1>;
|
|
90
|
-
type AgentMethodCall<AgentT> = OptionalArgsAgentMethodCall<AgentT> &
|
|
91
|
-
RequiredArgsAgentMethodCall<AgentT>;
|
|
92
|
-
type UntypedAgentMethodCall = <T = unknown>(
|
|
93
|
-
method: string,
|
|
94
|
-
args?: unknown[],
|
|
95
|
-
streamOptions?: StreamOptions
|
|
96
|
-
) => Promise<T>;
|
|
97
|
-
type AgentStub<T> = {
|
|
98
|
-
[K in keyof AgentMethods<T>]: (
|
|
99
|
-
...args: Parameters<AgentMethods<T>[K]>
|
|
100
|
-
) => AgentPromiseReturnType<AgentMethods<T>, K>;
|
|
101
|
-
};
|
|
102
|
-
type UntypedAgentStub = Record<string, Method>;
|
|
103
|
-
/**
|
|
104
|
-
* React hook for connecting to an Agent
|
|
105
|
-
*/
|
|
106
|
-
declare function useAgent<State = unknown>(
|
|
107
|
-
options: UseAgentOptions<State>
|
|
108
|
-
): PartySocket & {
|
|
109
|
-
agent: string;
|
|
110
|
-
name: string;
|
|
111
|
-
setState: (state: State) => void;
|
|
112
|
-
call: UntypedAgentMethodCall;
|
|
113
|
-
stub: UntypedAgentStub;
|
|
114
|
-
};
|
|
115
|
-
declare function useAgent<
|
|
116
|
-
AgentT extends {
|
|
117
|
-
get state(): State;
|
|
118
|
-
},
|
|
119
|
-
State
|
|
120
|
-
>(
|
|
121
|
-
options: UseAgentOptions<State>
|
|
122
|
-
): PartySocket & {
|
|
123
|
-
agent: string;
|
|
124
|
-
name: string;
|
|
125
|
-
setState: (state: State) => void;
|
|
126
|
-
call: AgentMethodCall<AgentT>;
|
|
127
|
-
stub: AgentStub<AgentT>;
|
|
128
|
-
};
|
|
129
|
-
//#endregion
|
|
130
|
-
export { _testUtils as n, useAgent as r, UseAgentOptions as t };
|
|
131
|
-
//# sourceMappingURL=react-DYwejKBr.d.ts.map
|