@ai-sdk-tool/parser 3.0.0-canary.2 → 3.0.0

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/v5.js ADDED
@@ -0,0 +1,476 @@
1
+ import {
2
+ createDynamicIfThenElseSchema,
3
+ extractOnErrorOption,
4
+ generateId,
5
+ isProtocolFactory,
6
+ isToolCallContent,
7
+ jsonMixProtocol,
8
+ morphXmlProtocol,
9
+ originalToolsSchema
10
+ } from "./chunk-NOYHOQOL.js";
11
+
12
+ // src/v5/generate-handler.ts
13
+ import { coerceBySchema } from "@ai-sdk-tool/rxml";
14
+ function parseContent(content, protocol, tools, providerOptions) {
15
+ const parsed = content.flatMap((contentItem) => {
16
+ if (contentItem.type !== "text") {
17
+ return [contentItem];
18
+ }
19
+ return protocol.parseGeneratedText({
20
+ text: contentItem.text,
21
+ tools,
22
+ options: {
23
+ ...extractOnErrorOption(providerOptions),
24
+ ...(providerOptions == null ? void 0 : providerOptions.toolCallMiddleware) || {}
25
+ }
26
+ });
27
+ });
28
+ return parsed.map((part) => {
29
+ var _a, _b;
30
+ if (part.type !== "tool-call") {
31
+ return part;
32
+ }
33
+ const tc = part;
34
+ let args = {};
35
+ if (typeof tc.input === "string") {
36
+ try {
37
+ args = JSON.parse(tc.input);
38
+ } catch (e) {
39
+ return part;
40
+ }
41
+ } else {
42
+ args = (_a = tc.input) != null ? _a : {};
43
+ }
44
+ const schema = (_b = tools.find(
45
+ (t) => t.name === tc.toolName
46
+ )) == null ? void 0 : _b.inputSchema;
47
+ const coerced = coerceBySchema(args, schema);
48
+ return {
49
+ ...part,
50
+ input: coerced != null ? coerced : {}
51
+ };
52
+ });
53
+ }
54
+ async function wrapGenerateV5({
55
+ protocol,
56
+ doGenerate,
57
+ params
58
+ }) {
59
+ var _a, _b;
60
+ const tools = originalToolsSchema.decode(
61
+ (_b = (_a = params.providerOptions) == null ? void 0 : _a.toolCallMiddleware) == null ? void 0 : _b.originalTools
62
+ );
63
+ const result = await doGenerate();
64
+ if (!result.content || result.content.length === 0) {
65
+ return result;
66
+ }
67
+ const newContent = parseContent(
68
+ result.content,
69
+ protocol,
70
+ tools,
71
+ params.providerOptions
72
+ );
73
+ return {
74
+ ...result,
75
+ content: newContent
76
+ };
77
+ }
78
+
79
+ // src/v5/stream-handler.ts
80
+ function processPartToV2(p, state, controller) {
81
+ const partAny = p;
82
+ const partId = partAny.id || partAny.toolCallId || generateId();
83
+ switch (p.type) {
84
+ case "text-delta": {
85
+ if (!state.textStarted.has(partId)) {
86
+ controller.enqueue({ type: "text-start", id: partId });
87
+ state.textStarted.add(partId);
88
+ }
89
+ controller.enqueue({
90
+ type: "text-delta",
91
+ id: partId,
92
+ delta: p.textDelta
93
+ });
94
+ break;
95
+ }
96
+ case "tool-call": {
97
+ const v2Id = p.toolCallId || `call-${state.callCount++}`;
98
+ if (!state.toolStarted.has(v2Id)) {
99
+ controller.enqueue({
100
+ type: "tool-input-start",
101
+ id: v2Id,
102
+ toolName: p.toolName
103
+ });
104
+ state.toolStarted.add(v2Id);
105
+ }
106
+ controller.enqueue({
107
+ type: "tool-call",
108
+ toolCallId: v2Id,
109
+ toolName: p.toolName,
110
+ input: typeof p.input === "string" ? JSON.parse(p.input) : p.input
111
+ });
112
+ break;
113
+ }
114
+ case "finish": {
115
+ for (const id of state.textStarted) {
116
+ controller.enqueue({ type: "text-end", id });
117
+ }
118
+ state.textStarted.clear();
119
+ controller.enqueue(p);
120
+ break;
121
+ }
122
+ default: {
123
+ controller.enqueue(p);
124
+ }
125
+ }
126
+ }
127
+ function createV5Transformer() {
128
+ const state = {
129
+ textStarted: /* @__PURE__ */ new Set(),
130
+ toolStarted: /* @__PURE__ */ new Set(),
131
+ callCount: 0
132
+ };
133
+ return new TransformStream({
134
+ transform(part, controller) {
135
+ processPartToV2(part, state, controller);
136
+ }
137
+ });
138
+ }
139
+ async function wrapStreamV5({
140
+ protocol,
141
+ doStream,
142
+ params
143
+ }) {
144
+ var _a, _b, _c;
145
+ const tools = originalToolsSchema.decode(
146
+ (_b = (_a = params.providerOptions) == null ? void 0 : _a.toolCallMiddleware) == null ? void 0 : _b.originalTools
147
+ );
148
+ const options = ((_c = params.providerOptions) == null ? void 0 : _c.toolCallMiddleware) || {};
149
+ const { stream } = await doStream();
150
+ const coreInput = stream.pipeThrough(
151
+ new TransformStream({
152
+ transform(part, controller) {
153
+ const p = part;
154
+ if (p.type === "text-delta") {
155
+ controller.enqueue({
156
+ type: "text-delta",
157
+ id: p.id,
158
+ textDelta: p.delta || p.textDelta || ""
159
+ });
160
+ } else {
161
+ controller.enqueue(p);
162
+ }
163
+ }
164
+ })
165
+ );
166
+ const parsedStream = coreInput.pipeThrough(
167
+ protocol.createStreamParser({
168
+ tools,
169
+ options
170
+ })
171
+ );
172
+ return {
173
+ stream: parsedStream.pipeThrough(createV5Transformer())
174
+ };
175
+ }
176
+
177
+ // src/v5/transform-handler.ts
178
+ function buildFinalPrompt(systemPrompt, processedPrompt, placement) {
179
+ const systemIndex = processedPrompt.findIndex((m) => m.role === "system");
180
+ if (systemIndex !== -1) {
181
+ const existing = processedPrompt[systemIndex].content;
182
+ let existingText = "";
183
+ if (typeof existing === "string") {
184
+ existingText = existing;
185
+ } else if (Array.isArray(existing)) {
186
+ existingText = existing.map((p) => {
187
+ var _a;
188
+ return (p == null ? void 0 : p.type) === "text" ? (_a = p.text) != null ? _a : "" : "";
189
+ }).filter(Boolean).join("\n");
190
+ } else {
191
+ existingText = String(existing != null ? existing : "");
192
+ }
193
+ const mergedContent = placement === "first" ? `${systemPrompt}
194
+
195
+ ${existingText}` : `${existingText}
196
+
197
+ ${systemPrompt}`;
198
+ return processedPrompt.map(
199
+ (m, idx) => idx === systemIndex ? {
200
+ ...m,
201
+ content: mergedContent
202
+ } : m
203
+ );
204
+ }
205
+ if (placement === "first") {
206
+ return [
207
+ {
208
+ role: "system",
209
+ content: systemPrompt
210
+ },
211
+ ...processedPrompt
212
+ ];
213
+ }
214
+ return [
215
+ ...processedPrompt,
216
+ {
217
+ role: "system",
218
+ content: systemPrompt
219
+ }
220
+ ];
221
+ }
222
+ function processAssistantContent(content, resolvedProtocol, providerOptions) {
223
+ var _a;
224
+ const newContent = [];
225
+ for (const item of content) {
226
+ if (isToolCallContent(item)) {
227
+ newContent.push({
228
+ type: "text",
229
+ text: resolvedProtocol.formatToolCall(item)
230
+ });
231
+ } else if (item.type === "text") {
232
+ newContent.push(item);
233
+ } else if (item.type === "reasoning") {
234
+ newContent.push(item);
235
+ } else {
236
+ const options = extractOnErrorOption(providerOptions);
237
+ (_a = options == null ? void 0 : options.onError) == null ? void 0 : _a.call(
238
+ options,
239
+ "tool-call-middleware: unknown assistant content; stringifying for provider compatibility",
240
+ { content: item }
241
+ );
242
+ newContent.push({
243
+ type: "text",
244
+ text: JSON.stringify(item)
245
+ });
246
+ }
247
+ }
248
+ const onlyText = newContent.every((c) => c.type === "text");
249
+ return onlyText ? [
250
+ {
251
+ type: "text",
252
+ text: newContent.map((c) => c.text).join("\n")
253
+ }
254
+ ] : newContent;
255
+ }
256
+ function processMessage(message, resolvedProtocol, providerOptions) {
257
+ if (message.role === "assistant") {
258
+ const content = Array.isArray(message.content) ? message.content : [{ type: "text", text: message.content }];
259
+ const condensedContent = processAssistantContent(
260
+ content,
261
+ resolvedProtocol,
262
+ providerOptions
263
+ );
264
+ return {
265
+ ...message,
266
+ content: condensedContent
267
+ };
268
+ }
269
+ if (message.role === "tool") {
270
+ const toolResultParts = message.content.filter(
271
+ (part) => part.type === "tool-result"
272
+ );
273
+ return {
274
+ role: "user",
275
+ content: [
276
+ {
277
+ type: "text",
278
+ text: toolResultParts.map(
279
+ (toolResult) => {
280
+ var _a, _b;
281
+ return resolvedProtocol.formatToolResponse({
282
+ ...toolResult,
283
+ result: (_b = (_a = toolResult.result) != null ? _a : toolResult.content) != null ? _b : toolResult.output
284
+ });
285
+ }
286
+ ).join("\n")
287
+ }
288
+ ]
289
+ };
290
+ }
291
+ return message;
292
+ }
293
+ function transformParamsV5({
294
+ params,
295
+ protocol,
296
+ toolSystemPromptTemplate,
297
+ placement = "first"
298
+ }) {
299
+ var _a, _b, _c, _d, _e;
300
+ const resolvedProtocol = isProtocolFactory(protocol) ? protocol() : protocol;
301
+ const functionTools = ((_a = params.tools) != null ? _a : []).filter(
302
+ (t) => t.type === "function"
303
+ );
304
+ const systemPrompt = resolvedProtocol.formatTools({
305
+ tools: functionTools,
306
+ toolSystemPromptTemplate
307
+ });
308
+ const prompt = (_b = params.prompt) != null ? _b : [];
309
+ const processedPrompt = prompt.map(
310
+ (message) => processMessage(
311
+ message,
312
+ resolvedProtocol,
313
+ extractOnErrorOption(params.providerOptions)
314
+ )
315
+ );
316
+ const finalPrompt = buildFinalPrompt(
317
+ systemPrompt,
318
+ processedPrompt,
319
+ placement
320
+ );
321
+ const baseReturnParams = {
322
+ ...params,
323
+ prompt: finalPrompt,
324
+ tools: [],
325
+ toolChoice: void 0,
326
+ providerOptions: {
327
+ ...params.providerOptions || {},
328
+ toolCallMiddleware: {
329
+ ...((_c = params.providerOptions) == null ? void 0 : _c.toolCallMiddleware) || {},
330
+ originalTools: originalToolsSchema.encode(functionTools)
331
+ }
332
+ }
333
+ };
334
+ if (((_d = params.toolChoice) == null ? void 0 : _d.type) === "tool") {
335
+ const selectedToolName = params.toolChoice.toolName;
336
+ const selectedTool = functionTools.find(
337
+ (t) => t.name === selectedToolName
338
+ );
339
+ if (selectedTool) {
340
+ return {
341
+ ...baseReturnParams,
342
+ responseFormat: {
343
+ type: "json",
344
+ schema: {
345
+ type: "object",
346
+ properties: {
347
+ name: { const: selectedTool.name },
348
+ arguments: selectedTool.inputSchema
349
+ },
350
+ required: ["name", "arguments"]
351
+ }
352
+ },
353
+ providerOptions: {
354
+ ...baseReturnParams.providerOptions,
355
+ toolCallMiddleware: {
356
+ ...baseReturnParams.providerOptions.toolCallMiddleware,
357
+ toolChoice: params.toolChoice
358
+ }
359
+ }
360
+ };
361
+ }
362
+ }
363
+ if (((_e = params.toolChoice) == null ? void 0 : _e.type) === "required") {
364
+ return {
365
+ ...baseReturnParams,
366
+ responseFormat: {
367
+ type: "json",
368
+ schema: createDynamicIfThenElseSchema(functionTools)
369
+ },
370
+ providerOptions: {
371
+ ...baseReturnParams.providerOptions,
372
+ toolCallMiddleware: {
373
+ ...baseReturnParams.providerOptions.toolCallMiddleware,
374
+ toolChoice: { type: "required" }
375
+ }
376
+ }
377
+ };
378
+ }
379
+ return baseReturnParams;
380
+ }
381
+
382
+ // src/v5/tool-call-middleware.ts
383
+ function createToolMiddlewareV5({
384
+ protocol,
385
+ toolSystemPromptTemplate,
386
+ placement = "last"
387
+ }) {
388
+ const resolvedProtocol = isProtocolFactory(protocol) ? protocol() : protocol;
389
+ return {
390
+ middlewareVersion: "v2",
391
+ wrapStream: (args) => wrapStreamV5({
392
+ protocol: resolvedProtocol,
393
+ doStream: args.doStream,
394
+ params: args.params
395
+ }),
396
+ wrapGenerate: (args) => wrapGenerateV5({
397
+ protocol: resolvedProtocol,
398
+ doGenerate: args.doGenerate,
399
+ params: args.params
400
+ }),
401
+ transformParams: (args) => transformParamsV5({
402
+ params: args.params,
403
+ protocol: resolvedProtocol,
404
+ toolSystemPromptTemplate,
405
+ placement
406
+ })
407
+ };
408
+ }
409
+
410
+ // src/v5/index.ts
411
+ var gemmaToolMiddleware = createToolMiddlewareV5({
412
+ protocol: jsonMixProtocol({
413
+ toolCallStart: "```tool_call\n",
414
+ toolCallEnd: "\n```",
415
+ toolResponseStart: "```tool_response\n",
416
+ toolResponseEnd: "\n```"
417
+ }),
418
+ toolSystemPromptTemplate(tools) {
419
+ return `You have access to functions. If you decide to invoke any of the function(s),
420
+ you MUST put it in the format of markdown code fence block with the language name of tool_call , e.g.
421
+ \`\`\`tool_call
422
+ {'name': <function-name>, 'arguments': <args-dict>}
423
+ \`\`\`
424
+ You SHOULD NOT include any other text in the response if you call a function
425
+ ${tools}`;
426
+ }
427
+ });
428
+ var hermesToolMiddleware = createToolMiddlewareV5({
429
+ protocol: jsonMixProtocol,
430
+ toolSystemPromptTemplate(tools) {
431
+ return `You are a function calling AI model.
432
+ You are provided with function signatures within <tools></tools> XML tags.
433
+ You may call one or more functions to assist with the user query.
434
+ Don't make assumptions about what values to plug into functions.
435
+ Here are the available tools: <tools>${tools}</tools>
436
+ Use the following pydantic model json schema for each tool call you will make: {"title": "FunctionCall", "type": "object", "properties": {"arguments": {"title": "Arguments", "type": "object"}, "name": {"title": "Name", "type": "string"}}, "required": ["arguments", "name"]}
437
+ For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
438
+ <tool_call>
439
+ {"name": "<function-name>", "arguments": <args-dict>}
440
+ </tool_call>`;
441
+ }
442
+ });
443
+ var morphXmlToolMiddleware = createToolMiddlewareV5({
444
+ protocol: morphXmlProtocol,
445
+ placement: "last",
446
+ toolSystemPromptTemplate(tools) {
447
+ return `# Tools
448
+
449
+ You may call one or more functions to assist with the user query.
450
+
451
+ You are provided with function signatures within <tools></tools> XML tags:
452
+ <tools>${tools}</tools>
453
+
454
+ # Rules
455
+ - Use exactly one XML element whose tag name is the function name.
456
+ - Put each parameter as a child element.
457
+ - Values must follow the schema exactly (numbers, arrays, objects, enums \u2192 copy as-is).
458
+ - Do not add or remove functions or parameters.
459
+ - Each required parameter must appear once.
460
+ - Output nothing before or after the function call.
461
+ - After calling a tool, you will receive a response in the format: <tool_response><tool_name>NAME</tool_name><result>RESULT</result></tool_response>. Use this result to answer the user.
462
+
463
+ # Example
464
+ <get_weather>
465
+ <location>New York</location>
466
+ <unit>celsius</unit>
467
+ </get_weather>`;
468
+ }
469
+ });
470
+ export {
471
+ createToolMiddlewareV5 as createToolMiddleware,
472
+ gemmaToolMiddleware,
473
+ hermesToolMiddleware,
474
+ morphXmlToolMiddleware
475
+ };
476
+ //# sourceMappingURL=v5.js.map
package/dist/v5.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/v5/generate-handler.ts","../src/v5/stream-handler.ts","../src/v5/transform-handler.ts","../src/v5/tool-call-middleware.ts","../src/v5/index.ts"],"sourcesContent":["import { coerceBySchema } from \"@ai-sdk-tool/rxml\";\nimport type { ToolCallProtocol } from \"../core/protocols/tool-call-protocol\";\nimport { extractOnErrorOption } from \"../core/utils/on-error\";\nimport { originalToolsSchema } from \"../core/utils/provider-options\";\n\n// biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 content items have different shape than internal types\ntype V5ContentItem = any;\n\nfunction parseContent(\n content: V5ContentItem[],\n protocol: ToolCallProtocol,\n // biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 tool schema compatibility\n tools: any[],\n // biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 provider options\n providerOptions?: any\n): V5ContentItem[] {\n const parsed = content.flatMap((contentItem: V5ContentItem) => {\n if (contentItem.type !== \"text\") {\n return [contentItem];\n }\n return protocol.parseGeneratedText({\n text: contentItem.text,\n tools,\n options: {\n ...extractOnErrorOption(providerOptions),\n ...(providerOptions?.toolCallMiddleware || {}),\n },\n });\n });\n\n return parsed.map((part: V5ContentItem) => {\n if (part.type !== \"tool-call\") {\n return part;\n }\n const tc = part as { toolName: string; input: unknown };\n let args: Record<string, unknown> = {};\n if (typeof tc.input === \"string\") {\n try {\n args = JSON.parse(tc.input) as Record<string, unknown>;\n } catch {\n return part;\n }\n } else {\n args = (tc.input ?? {}) as Record<string, unknown>;\n }\n const schema = tools.find(\n (t: { name: string }) => t.name === tc.toolName\n )?.inputSchema;\n const coerced = coerceBySchema(args, schema);\n return {\n ...part,\n input: coerced ?? {},\n };\n });\n}\n\nexport async function wrapGenerateV5({\n protocol,\n doGenerate,\n params,\n}: {\n protocol: ToolCallProtocol;\n // biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 generate result\n doGenerate: () => Promise<any>;\n // biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 params structure\n params: any;\n}) {\n const tools = originalToolsSchema.decode(\n params.providerOptions?.toolCallMiddleware?.originalTools\n );\n\n const result = await doGenerate();\n\n if (!result.content || result.content.length === 0) {\n return result;\n }\n\n const newContent = parseContent(\n result.content,\n protocol,\n tools,\n params.providerOptions\n );\n\n return {\n ...result,\n content: newContent,\n };\n}\n","import type { ToolCallProtocol } from \"../core/protocols/tool-call-protocol\";\nimport type { TCMCoreFunctionTool, TCMCoreStreamPart } from \"../core/types\";\nimport { generateId } from \"../core/utils/id\";\nimport { originalToolsSchema } from \"../core/utils/provider-options\";\n\ninterface V5TransformerState {\n textStarted: Set<string>;\n toolStarted: Set<string>;\n callCount: number;\n}\n\nfunction processPartToV2(\n p: TCMCoreStreamPart,\n state: V5TransformerState,\n controller: TransformStreamDefaultController<unknown>\n) {\n // biome-ignore lint/suspicious/noExplicitAny: mapping for v2 provider compatibility\n const partAny = p as any;\n const partId = partAny.id || partAny.toolCallId || generateId();\n\n switch (p.type) {\n case \"text-delta\": {\n if (!state.textStarted.has(partId)) {\n controller.enqueue({ type: \"text-start\", id: partId });\n state.textStarted.add(partId);\n }\n controller.enqueue({\n type: \"text-delta\",\n id: partId,\n delta: p.textDelta,\n });\n break;\n }\n case \"tool-call\": {\n const v2Id = p.toolCallId || `call-${state.callCount++}`;\n if (!state.toolStarted.has(v2Id)) {\n controller.enqueue({\n type: \"tool-input-start\",\n id: v2Id,\n toolName: p.toolName,\n });\n state.toolStarted.add(v2Id);\n }\n controller.enqueue({\n type: \"tool-call\",\n toolCallId: v2Id,\n toolName: p.toolName,\n input: typeof p.input === \"string\" ? JSON.parse(p.input) : p.input,\n });\n break;\n }\n case \"finish\": {\n for (const id of state.textStarted) {\n controller.enqueue({ type: \"text-end\", id });\n }\n state.textStarted.clear();\n controller.enqueue(p);\n break;\n }\n default: {\n controller.enqueue(p);\n }\n }\n}\n\nexport function createV5Transformer(): TransformStream<\n TCMCoreStreamPart,\n unknown\n> {\n const state: V5TransformerState = {\n textStarted: new Set(),\n toolStarted: new Set(),\n callCount: 0,\n };\n\n return new TransformStream<TCMCoreStreamPart, unknown>({\n transform(part, controller) {\n processPartToV2(part, state, controller);\n },\n });\n}\n\nexport async function wrapStreamV5({\n protocol,\n doStream,\n params,\n}: {\n protocol: ToolCallProtocol;\n doStream: () => Promise<{ stream: unknown }>;\n // biome-ignore lint/suspicious/noExplicitAny: complex provider options mapping\n params: { providerOptions?: { toolCallMiddleware?: any } };\n}) {\n const tools = originalToolsSchema.decode(\n params.providerOptions?.toolCallMiddleware?.originalTools\n ) as TCMCoreFunctionTool[];\n const options = params.providerOptions?.toolCallMiddleware || {};\n\n const { stream } = await doStream();\n\n const coreInput = (stream as ReadableStream<unknown>).pipeThrough(\n new TransformStream<unknown, TCMCoreStreamPart>({\n transform(part, controller) {\n // biome-ignore lint/suspicious/noExplicitAny: complex stream part mapping\n const p = part as any;\n if (p.type === \"text-delta\") {\n controller.enqueue({\n type: \"text-delta\",\n id: p.id,\n textDelta: p.delta || p.textDelta || \"\",\n });\n } else {\n controller.enqueue(p);\n }\n },\n })\n );\n\n const parsedStream = coreInput.pipeThrough(\n protocol.createStreamParser({\n tools,\n options,\n })\n );\n\n return {\n stream: parsedStream.pipeThrough(createV5Transformer()),\n };\n}\n","import {\n isProtocolFactory,\n type ToolCallProtocol,\n} from \"../core/protocols/tool-call-protocol\";\nimport { createDynamicIfThenElseSchema } from \"../core/utils/dynamic-tool-schema\";\nimport { extractOnErrorOption } from \"../core/utils/on-error\";\nimport { originalToolsSchema } from \"../core/utils/provider-options\";\nimport { isToolCallContent } from \"../core/utils/type-guards\";\n\n// biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 prompt message types\ntype V5Message = any;\n\nfunction buildFinalPrompt(\n systemPrompt: string,\n processedPrompt: V5Message[],\n placement: \"first\" | \"last\"\n): V5Message[] {\n const systemIndex = processedPrompt.findIndex((m) => m.role === \"system\");\n if (systemIndex !== -1) {\n const existing = processedPrompt[systemIndex].content;\n let existingText = \"\";\n if (typeof existing === \"string\") {\n existingText = existing;\n } else if (Array.isArray(existing)) {\n existingText = (existing as { type?: string; text?: string }[])\n .map((p) => (p?.type === \"text\" ? (p.text ?? \"\") : \"\"))\n .filter(Boolean)\n .join(\"\\n\");\n } else {\n existingText = String(existing ?? \"\");\n }\n\n const mergedContent =\n placement === \"first\"\n ? `${systemPrompt}\\n\\n${existingText}`\n : `${existingText}\\n\\n${systemPrompt}`;\n\n return processedPrompt.map((m, idx) =>\n idx === systemIndex\n ? {\n ...m,\n content: mergedContent,\n }\n : m\n );\n }\n\n if (placement === \"first\") {\n return [\n {\n role: \"system\",\n content: systemPrompt,\n },\n ...processedPrompt,\n ];\n }\n\n return [\n ...processedPrompt,\n {\n role: \"system\",\n content: systemPrompt,\n },\n ];\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 content item types\ntype V5ContentItem = any;\n\nfunction processAssistantContent(\n content: V5ContentItem[],\n resolvedProtocol: ToolCallProtocol,\n providerOptions?: {\n onError?: (message: string, metadata?: Record<string, unknown>) => void;\n }\n): V5ContentItem[] {\n const newContent: V5ContentItem[] = [];\n for (const item of content) {\n if (isToolCallContent(item)) {\n newContent.push({\n type: \"text\",\n text: resolvedProtocol.formatToolCall(item as V5ContentItem),\n });\n } else if (item.type === \"text\") {\n newContent.push(item);\n } else if (item.type === \"reasoning\") {\n newContent.push(item);\n } else {\n const options = extractOnErrorOption(providerOptions);\n options?.onError?.(\n \"tool-call-middleware: unknown assistant content; stringifying for provider compatibility\",\n { content: item }\n );\n newContent.push({\n type: \"text\",\n text: JSON.stringify(item),\n });\n }\n }\n\n const onlyText = newContent.every((c) => c.type === \"text\");\n return onlyText\n ? [\n {\n type: \"text\",\n text: newContent.map((c) => c.text).join(\"\\n\"),\n },\n ]\n : newContent;\n}\n\nfunction processMessage(\n message: V5Message,\n resolvedProtocol: ToolCallProtocol,\n // biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 provider options\n providerOptions?: any\n): V5Message {\n if (message.role === \"assistant\") {\n const content = Array.isArray(message.content)\n ? message.content\n : [{ type: \"text\", text: message.content }];\n const condensedContent = processAssistantContent(\n content,\n resolvedProtocol,\n providerOptions\n );\n return {\n ...message,\n content: condensedContent,\n };\n }\n if (message.role === \"tool\") {\n const toolResultParts = message.content.filter(\n (part: V5ContentItem) => part.type === \"tool-result\"\n );\n return {\n role: \"user\",\n content: [\n {\n type: \"text\",\n text: toolResultParts\n .map((toolResult: V5ContentItem) =>\n resolvedProtocol.formatToolResponse({\n ...toolResult,\n result:\n toolResult.result ?? toolResult.content ?? toolResult.output,\n })\n )\n .join(\"\\n\"),\n },\n ],\n };\n }\n return message;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 params structure\ntype V5Params = any;\n\n// biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 tool definition\ntype V5Tool = any;\n\nexport function transformParamsV5({\n params,\n protocol,\n toolSystemPromptTemplate,\n placement = \"first\",\n}: {\n params: V5Params;\n protocol: ToolCallProtocol | (() => ToolCallProtocol);\n toolSystemPromptTemplate: (tools: string) => string;\n placement?: \"first\" | \"last\";\n}) {\n const resolvedProtocol = isProtocolFactory(protocol) ? protocol() : protocol;\n\n const functionTools = (params.tools ?? []).filter(\n (t: V5Tool) => t.type === \"function\"\n );\n\n const systemPrompt = resolvedProtocol.formatTools({\n tools: functionTools,\n toolSystemPromptTemplate,\n });\n\n const prompt = params.prompt ?? [];\n const processedPrompt = prompt.map((message: V5Message) =>\n processMessage(\n message,\n resolvedProtocol,\n extractOnErrorOption(params.providerOptions)\n )\n );\n\n const finalPrompt = buildFinalPrompt(\n systemPrompt,\n processedPrompt,\n placement\n );\n\n const baseReturnParams = {\n ...params,\n prompt: finalPrompt,\n tools: [],\n toolChoice: undefined,\n providerOptions: {\n ...(params.providerOptions || {}),\n toolCallMiddleware: {\n ...(params.providerOptions?.toolCallMiddleware || {}),\n originalTools: originalToolsSchema.encode(functionTools),\n },\n },\n };\n\n if (params.toolChoice?.type === \"tool\") {\n const selectedToolName = params.toolChoice.toolName;\n const selectedTool = functionTools.find(\n (t: V5Tool) => t.name === selectedToolName\n );\n if (selectedTool) {\n return {\n ...baseReturnParams,\n responseFormat: {\n type: \"json\",\n schema: {\n type: \"object\",\n properties: {\n name: { const: selectedTool.name },\n arguments: selectedTool.inputSchema,\n },\n required: [\"name\", \"arguments\"],\n },\n },\n providerOptions: {\n ...baseReturnParams.providerOptions,\n toolCallMiddleware: {\n ...baseReturnParams.providerOptions.toolCallMiddleware,\n toolChoice: params.toolChoice,\n },\n },\n };\n }\n }\n\n if (params.toolChoice?.type === \"required\") {\n return {\n ...baseReturnParams,\n responseFormat: {\n type: \"json\",\n schema: createDynamicIfThenElseSchema(functionTools),\n },\n providerOptions: {\n ...baseReturnParams.providerOptions,\n toolCallMiddleware: {\n ...baseReturnParams.providerOptions.toolCallMiddleware,\n toolChoice: { type: \"required\" },\n },\n },\n };\n }\n\n return baseReturnParams;\n}\n","import {\n isProtocolFactory,\n type ToolCallProtocol,\n} from \"../core/protocols/tool-call-protocol\";\nimport { wrapGenerateV5 } from \"./generate-handler\";\nimport { wrapStreamV5 } from \"./stream-handler\";\nimport { transformParamsV5 } from \"./transform-handler\";\n\n// biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 middleware interface requires dynamic types\ntype V5MiddlewareArgs = any;\n\n// biome-ignore lint/suspicious/noExplicitAny: AI SDK v5 middleware interface requires dynamic return type\ntype V5Middleware = any;\n\nexport function createToolMiddlewareV5({\n protocol,\n toolSystemPromptTemplate,\n placement = \"last\",\n}: {\n protocol: ToolCallProtocol | (() => ToolCallProtocol);\n toolSystemPromptTemplate: (tools: string) => string;\n placement?: \"first\" | \"last\";\n}): V5Middleware {\n const resolvedProtocol = isProtocolFactory(protocol) ? protocol() : protocol;\n\n return {\n middlewareVersion: \"v2\",\n wrapStream: (args: V5MiddlewareArgs) =>\n wrapStreamV5({\n protocol: resolvedProtocol,\n doStream: args.doStream,\n params: args.params,\n }),\n wrapGenerate: (args: V5MiddlewareArgs) =>\n wrapGenerateV5({\n protocol: resolvedProtocol,\n doGenerate: args.doGenerate,\n params: args.params,\n }),\n transformParams: (args: V5MiddlewareArgs) =>\n transformParamsV5({\n params: args.params,\n protocol: resolvedProtocol,\n toolSystemPromptTemplate,\n placement,\n }),\n };\n}\n","// biome-ignore-all lint/performance/noBarrelFile: intentional public API surface\nimport { jsonMixProtocol } from \"../core/protocols/json-mix-protocol\";\nimport { morphXmlProtocol } from \"../core/protocols/morph-xml-protocol\";\nimport { createToolMiddlewareV5 } from \"./tool-call-middleware\";\n\nexport const gemmaToolMiddleware = createToolMiddlewareV5({\n protocol: jsonMixProtocol({\n toolCallStart: \"```tool_call\\n\",\n toolCallEnd: \"\\n```\",\n toolResponseStart: \"```tool_response\\n\",\n toolResponseEnd: \"\\n```\",\n }),\n toolSystemPromptTemplate(tools) {\n return `You have access to functions. If you decide to invoke any of the function(s),\nyou MUST put it in the format of markdown code fence block with the language name of tool_call , e.g.\n\\`\\`\\`tool_call\n{'name': <function-name>, 'arguments': <args-dict>}\n\\`\\`\\`\nYou SHOULD NOT include any other text in the response if you call a function\n${tools}`;\n },\n});\n\nexport const hermesToolMiddleware = createToolMiddlewareV5({\n protocol: jsonMixProtocol,\n toolSystemPromptTemplate(tools) {\n return `You are a function calling AI model.\nYou are provided with function signatures within <tools></tools> XML tags.\nYou may call one or more functions to assist with the user query.\nDon't make assumptions about what values to plug into functions.\nHere are the available tools: <tools>${tools}</tools>\nUse the following pydantic model json schema for each tool call you will make: {\"title\": \"FunctionCall\", \"type\": \"object\", \"properties\": {\"arguments\": {\"title\": \"Arguments\", \"type\": \"object\"}, \"name\": {\"title\": \"Name\", \"type\": \"string\"}}, \"required\": [\"arguments\", \"name\"]}\nFor each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:\n<tool_call>\n{\"name\": \"<function-name>\", \"arguments\": <args-dict>}\n</tool_call>`;\n },\n});\n\nexport const morphXmlToolMiddleware = createToolMiddlewareV5({\n protocol: morphXmlProtocol,\n placement: \"last\",\n toolSystemPromptTemplate(tools: string) {\n return `# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>${tools}</tools>\n\n# Rules\n- Use exactly one XML element whose tag name is the function name.\n- Put each parameter as a child element.\n- Values must follow the schema exactly (numbers, arrays, objects, enums → copy as-is).\n- Do not add or remove functions or parameters.\n- Each required parameter must appear once.\n- Output nothing before or after the function call.\n- After calling a tool, you will receive a response in the format: <tool_response><tool_name>NAME</tool_name><result>RESULT</result></tool_response>. Use this result to answer the user.\n\n# Example\n<get_weather>\n <location>New York</location>\n <unit>celsius</unit>\n</get_weather>`;\n },\n});\n\nexport { createToolMiddlewareV5 as createToolMiddleware } from \"./tool-call-middleware\";\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,sBAAsB;AAQ/B,SAAS,aACP,SACA,UAEA,OAEA,iBACiB;AACjB,QAAM,SAAS,QAAQ,QAAQ,CAAC,gBAA+B;AAC7D,QAAI,YAAY,SAAS,QAAQ;AAC/B,aAAO,CAAC,WAAW;AAAA,IACrB;AACA,WAAO,SAAS,mBAAmB;AAAA,MACjC,MAAM,YAAY;AAAA,MAClB;AAAA,MACA,SAAS;AAAA,QACP,GAAG,qBAAqB,eAAe;AAAA,QACvC,IAAI,mDAAiB,uBAAsB,CAAC;AAAA,MAC9C;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,SAAO,OAAO,IAAI,CAAC,SAAwB;AA9B7C;AA+BI,QAAI,KAAK,SAAS,aAAa;AAC7B,aAAO;AAAA,IACT;AACA,UAAM,KAAK;AACX,QAAI,OAAgC,CAAC;AACrC,QAAI,OAAO,GAAG,UAAU,UAAU;AAChC,UAAI;AACF,eAAO,KAAK,MAAM,GAAG,KAAK;AAAA,MAC5B,SAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF,OAAO;AACL,cAAQ,QAAG,UAAH,YAAY,CAAC;AAAA,IACvB;AACA,UAAM,UAAS,WAAM;AAAA,MACnB,CAAC,MAAwB,EAAE,SAAS,GAAG;AAAA,IACzC,MAFe,mBAEZ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