@ai-sdk-tool/parser 4.0.0 → 4.1.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/README.md +109 -20
- package/dist/{chunk-2KK5BDZF.js → chunk-GMTE7BY5.js} +23 -6
- package/dist/chunk-GMTE7BY5.js.map +1 -0
- package/dist/{chunk-CXWS24JX.js → chunk-MHZC45AC.js} +5 -2
- package/dist/{chunk-CXWS24JX.js.map → chunk-MHZC45AC.js.map} +1 -1
- package/dist/{chunk-ERJKQKCR.js → chunk-O6NWVXQD.js} +2578 -379
- package/dist/chunk-O6NWVXQD.js.map +1 -0
- package/dist/{chunk-IX4FJELL.js → chunk-QBZNMO5C.js} +1 -1
- package/dist/chunk-QBZNMO5C.js.map +1 -0
- package/dist/community.cjs +7873 -5545
- package/dist/community.cjs.map +1 -1
- package/dist/community.d.cts +7 -1
- package/dist/community.d.ts +7 -1
- package/dist/community.js +128 -8
- package/dist/community.js.map +1 -1
- package/dist/index.cjs +2600 -384
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -24
- package/dist/index.d.ts +33 -24
- package/dist/index.js +22 -14
- package/dist/rjson.cjs.map +1 -1
- package/dist/rjson.d.cts +15 -15
- package/dist/rjson.d.ts +15 -15
- package/dist/rjson.js +1 -1
- package/dist/rxml.cjs +22 -5
- package/dist/rxml.cjs.map +1 -1
- package/dist/rxml.d.cts +23 -23
- package/dist/rxml.d.ts +23 -23
- package/dist/rxml.js +2 -2
- package/dist/schema-coerce.cjs +22 -5
- package/dist/schema-coerce.cjs.map +1 -1
- package/dist/schema-coerce.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-2KK5BDZF.js.map +0 -1
- package/dist/chunk-ERJKQKCR.js.map +0 -1
- package/dist/chunk-IX4FJELL.js.map +0 -1
package/dist/community.d.cts
CHANGED
|
@@ -3,4 +3,10 @@ import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
|
3
3
|
declare const sijawaraDetailedXmlToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
4
4
|
declare const sijawaraConciseXmlToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* UI-TARS middleware using a custom protocol that handles <function=name> syntax (qwen3CoderProtocol)
|
|
8
|
+
* This is a modified version of https://github.com/julien-blanchon/silo/blob/6ebbc24e9dcf21e502b65b07b86a1e76169d4e8c/src/lib/middleware/uiTars.ts
|
|
9
|
+
*/
|
|
10
|
+
declare const uiTarsToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
11
|
+
|
|
12
|
+
export { sijawaraConciseXmlToolMiddleware, sijawaraDetailedXmlToolMiddleware, uiTarsToolMiddleware };
|
package/dist/community.d.ts
CHANGED
|
@@ -3,4 +3,10 @@ import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
|
3
3
|
declare const sijawaraDetailedXmlToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
4
4
|
declare const sijawaraConciseXmlToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* UI-TARS middleware using a custom protocol that handles <function=name> syntax (qwen3CoderProtocol)
|
|
8
|
+
* This is a modified version of https://github.com/julien-blanchon/silo/blob/6ebbc24e9dcf21e502b65b07b86a1e76169d4e8c/src/lib/middleware/uiTars.ts
|
|
9
|
+
*/
|
|
10
|
+
declare const uiTarsToolMiddleware: _ai_sdk_provider.LanguageModelV3Middleware;
|
|
11
|
+
|
|
12
|
+
export { sijawaraConciseXmlToolMiddleware, sijawaraDetailedXmlToolMiddleware, uiTarsToolMiddleware };
|
package/dist/community.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createToolMiddleware,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import "./chunk-
|
|
3
|
+
morphFormatToolResponseAsXml,
|
|
4
|
+
morphXmlProtocol,
|
|
5
|
+
uiTarsXmlProtocol
|
|
6
|
+
} from "./chunk-O6NWVXQD.js";
|
|
7
|
+
import "./chunk-MHZC45AC.js";
|
|
8
|
+
import "./chunk-QBZNMO5C.js";
|
|
9
|
+
import "./chunk-GMTE7BY5.js";
|
|
8
10
|
|
|
9
11
|
// src/community/sijawara.ts
|
|
10
12
|
var sijawaraDetailedXmlToolMiddleware = createToolMiddleware({
|
|
11
|
-
protocol:
|
|
13
|
+
protocol: morphXmlProtocol,
|
|
14
|
+
toolResponsePromptTemplate: morphFormatToolResponseAsXml,
|
|
12
15
|
toolSystemPromptTemplate(tools) {
|
|
13
16
|
const toolsJson = JSON.stringify(tools);
|
|
14
17
|
return `You have access to callable functions (tools).
|
|
@@ -65,7 +68,8 @@ var sijawaraDetailedXmlToolMiddleware = createToolMiddleware({
|
|
|
65
68
|
}
|
|
66
69
|
});
|
|
67
70
|
var sijawaraConciseXmlToolMiddleware = createToolMiddleware({
|
|
68
|
-
protocol:
|
|
71
|
+
protocol: morphXmlProtocol,
|
|
72
|
+
toolResponsePromptTemplate: morphFormatToolResponseAsXml,
|
|
69
73
|
toolSystemPromptTemplate(tools) {
|
|
70
74
|
const toolsJson = JSON.stringify(tools);
|
|
71
75
|
return `You have access to callable functions (tools).
|
|
@@ -96,8 +100,124 @@ var sijawaraConciseXmlToolMiddleware = createToolMiddleware({
|
|
|
96
100
|
</get_weather>`;
|
|
97
101
|
}
|
|
98
102
|
});
|
|
103
|
+
|
|
104
|
+
// src/community/ui-tars.ts
|
|
105
|
+
var uiTarsToolMiddleware = createToolMiddleware({
|
|
106
|
+
protocol: uiTarsXmlProtocol,
|
|
107
|
+
toolResponsePromptTemplate: morphFormatToolResponseAsXml,
|
|
108
|
+
toolSystemPromptTemplate(tools) {
|
|
109
|
+
const toolsJson = JSON.stringify(tools);
|
|
110
|
+
return `You have access to callable functions (tools).
|
|
111
|
+
Tool list/context:
|
|
112
|
+
${toolsJson}
|
|
113
|
+
|
|
114
|
+
===============================
|
|
115
|
+
UI-TARS FUNCTION CALLING FORMAT
|
|
116
|
+
===============================
|
|
117
|
+
You MUST use the EXACT format below for ALL function calls:
|
|
118
|
+
|
|
119
|
+
<tool_call>
|
|
120
|
+
<function=tool_name>
|
|
121
|
+
<parameter=parameter_name>
|
|
122
|
+
value
|
|
123
|
+
</parameter>
|
|
124
|
+
<parameter=another_parameter>
|
|
125
|
+
value
|
|
126
|
+
</parameter>
|
|
127
|
+
</function>
|
|
128
|
+
</tool_call>
|
|
129
|
+
|
|
130
|
+
===============================
|
|
131
|
+
CRITICAL SYNTAX RULES
|
|
132
|
+
===============================
|
|
133
|
+
1. Start with <tool_call>
|
|
134
|
+
2. Next line must be <function=TOOL_NAME> (use the exact tool name from the list above)
|
|
135
|
+
3. Each parameter MUST use opening/closing tags:
|
|
136
|
+
<parameter=PARAM_NAME>
|
|
137
|
+
VALUE
|
|
138
|
+
</parameter>
|
|
139
|
+
4. End the function with </function>
|
|
140
|
+
5. End the tool call with </tool_call>
|
|
141
|
+
6. NO quotes around tool names or parameter names
|
|
142
|
+
7. NO extra spaces or characters
|
|
143
|
+
8. NO JSON format - only use this XML-like format
|
|
144
|
+
|
|
145
|
+
===============================
|
|
146
|
+
CORRECT EXAMPLES
|
|
147
|
+
===============================
|
|
148
|
+
Screenshot:
|
|
149
|
+
<tool_call>
|
|
150
|
+
<function=computer>
|
|
151
|
+
<parameter=action>
|
|
152
|
+
screenshot
|
|
153
|
+
</parameter>
|
|
154
|
+
</function>
|
|
155
|
+
</tool_call>
|
|
156
|
+
|
|
157
|
+
Click at coordinates:
|
|
158
|
+
<tool_call>
|
|
159
|
+
<function=computer>
|
|
160
|
+
<parameter=action>
|
|
161
|
+
left_click
|
|
162
|
+
</parameter>
|
|
163
|
+
<parameter=coordinate>
|
|
164
|
+
[100, 200]
|
|
165
|
+
</parameter>
|
|
166
|
+
</function>
|
|
167
|
+
</tool_call>
|
|
168
|
+
|
|
169
|
+
Type text:
|
|
170
|
+
<tool_call>
|
|
171
|
+
<function=computer>
|
|
172
|
+
<parameter=action>
|
|
173
|
+
type
|
|
174
|
+
</parameter>
|
|
175
|
+
<parameter=text>
|
|
176
|
+
Hello World
|
|
177
|
+
</parameter>
|
|
178
|
+
</function>
|
|
179
|
+
</tool_call>
|
|
180
|
+
|
|
181
|
+
Scroll:
|
|
182
|
+
<tool_call>
|
|
183
|
+
<function=computer>
|
|
184
|
+
<parameter=action>
|
|
185
|
+
scroll
|
|
186
|
+
</parameter>
|
|
187
|
+
<parameter=coordinate>
|
|
188
|
+
[500, 400]
|
|
189
|
+
</parameter>
|
|
190
|
+
<parameter=scroll_direction>
|
|
191
|
+
down
|
|
192
|
+
</parameter>
|
|
193
|
+
<parameter=scroll_amount>
|
|
194
|
+
3
|
|
195
|
+
</parameter>
|
|
196
|
+
</function>
|
|
197
|
+
</tool_call>
|
|
198
|
+
|
|
199
|
+
===============================
|
|
200
|
+
WRONG FORMATS (DO NOT USE)
|
|
201
|
+
===============================
|
|
202
|
+
\u274C Missing <tool_call>...</tool_call> wrapper
|
|
203
|
+
\u274C <function=function='screenshot'> (no quotes or extra text)
|
|
204
|
+
\u274C <parameter=parameters> (must use actual parameter name)
|
|
205
|
+
\u274C JSON format like {"action": "screenshot"}
|
|
206
|
+
\u274C Any format other than the exact XML-like format above
|
|
207
|
+
|
|
208
|
+
===============================
|
|
209
|
+
EXECUTION RULES
|
|
210
|
+
===============================
|
|
211
|
+
- Use ONLY the tool names listed above
|
|
212
|
+
- Include ALL required parameters for each tool
|
|
213
|
+
- If you don't know a parameter value, ask the user
|
|
214
|
+
- After calling a function, STOP and wait for the result
|
|
215
|
+
- Do NOT add extra text before or after tool calls`;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
99
218
|
export {
|
|
100
219
|
sijawaraConciseXmlToolMiddleware,
|
|
101
|
-
sijawaraDetailedXmlToolMiddleware
|
|
220
|
+
sijawaraDetailedXmlToolMiddleware,
|
|
221
|
+
uiTarsToolMiddleware
|
|
102
222
|
};
|
|
103
223
|
//# sourceMappingURL=community.js.map
|
package/dist/community.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/community/sijawara.ts"],"sourcesContent":["import type { LanguageModelV3FunctionTool } from \"@ai-sdk/provider\";\nimport { createToolMiddleware,
|
|
1
|
+
{"version":3,"sources":["../src/community/sijawara.ts","../src/community/ui-tars.ts"],"sourcesContent":["import type { LanguageModelV3FunctionTool } from \"@ai-sdk/provider\";\nimport { morphFormatToolResponseAsXml } from \"../core/prompts/morph-xml-prompt\";\nimport { createToolMiddleware, morphXmlProtocol } from \"../index\";\n\nexport const sijawaraDetailedXmlToolMiddleware = createToolMiddleware({\n protocol: morphXmlProtocol,\n toolResponsePromptTemplate: morphFormatToolResponseAsXml,\n toolSystemPromptTemplate(tools: LanguageModelV3FunctionTool[]) {\n const toolsJson = JSON.stringify(tools);\n return `You have access to callable functions (tools).\n Tool list/context:\n ${toolsJson}\n\n ===============================\n TOOL CALLING FORMAT\n ===============================\n - Use the XML-like format for tool calls:\n <tool_name>\n <parameter_name>\n value\n </parameter_name>\n ...\n </tool_name>\n\n ===============================\n ARRAY PARAMETERS\n ===============================\n - For array/multiple values, repeat the parameter for each value.\n - Example:\n <send_messages>\n <recipient>\n alice@example.com\n </recipient>\n <recipient>\n bob@example.com\n </recipient>\n <message>\n Hello!\n </message>\n </send_messages>\n\n ===============================\n SINGLE VALUE PARAMETERS\n ===============================\n - For single values, use one parameter block.\n - Example:\n <get_weather>\n <location>\n San Francisco\n </location>\n </get_weather>\n\n ===============================\n GENERAL RULES\n ===============================\n - First line: tool (function) name in angle brackets.\n - Parameters: each on their own line, in angle brackets, with name and value.\n - Include all required parameters. If info is missing, ask the user.\n - Do NOT use JSON—use only the specified XML-like format for tool calls.\n - If no call is needed, reply without a tool call.`;\n },\n});\n\nexport const sijawaraConciseXmlToolMiddleware = createToolMiddleware({\n protocol: morphXmlProtocol,\n toolResponsePromptTemplate: morphFormatToolResponseAsXml,\n toolSystemPromptTemplate(tools: LanguageModelV3FunctionTool[]) {\n const toolsJson = JSON.stringify(tools);\n return `You have access to callable functions (tools).\n Tool list/context:\n ${toolsJson}\n\n STRICT CALLING RULES:\n - Use the XML-like format for tool calls:\n\n <tool_name>\n <parameter_name>\n value\n </parameter_name>\n ...\n </tool_name>\n\n - First line: the tool (function) name in angle brackets.\n - Parameters: each in their own angle brackets with name and value.\n - Include all required parameters. If info is missing, ask the user.\n - Do NOT use JSON. Use only the specified XML-like format.\n - If no call is needed, reply without a tool call.\n\n Example:\n <get_weather>\n <location>\n San Francisco\n </location>\n </get_weather>`;\n },\n});\n","import type { LanguageModelV3FunctionTool } from \"@ai-sdk/provider\";\nimport { morphFormatToolResponseAsXml } from \"../core/prompts/morph-xml-prompt\";\nimport { createToolMiddleware, uiTarsXmlProtocol } from \"../index\";\n\n/**\n * UI-TARS middleware using a custom protocol that handles <function=name> syntax (qwen3CoderProtocol)\n * This is a modified version of https://github.com/julien-blanchon/silo/blob/6ebbc24e9dcf21e502b65b07b86a1e76169d4e8c/src/lib/middleware/uiTars.ts\n */\nexport const uiTarsToolMiddleware = createToolMiddleware({\n protocol: uiTarsXmlProtocol,\n toolResponsePromptTemplate: morphFormatToolResponseAsXml,\n toolSystemPromptTemplate(tools: LanguageModelV3FunctionTool[]) {\n const toolsJson = JSON.stringify(tools);\n return `You have access to callable functions (tools).\nTool list/context:\n${toolsJson}\n\n===============================\nUI-TARS FUNCTION CALLING FORMAT\n===============================\nYou MUST use the EXACT format below for ALL function calls:\n\n<tool_call>\n<function=tool_name>\n<parameter=parameter_name>\nvalue\n</parameter>\n<parameter=another_parameter>\nvalue\n</parameter>\n</function>\n</tool_call>\n\n===============================\nCRITICAL SYNTAX RULES\n===============================\n1. Start with <tool_call>\n2. Next line must be <function=TOOL_NAME> (use the exact tool name from the list above)\n3. Each parameter MUST use opening/closing tags:\n <parameter=PARAM_NAME>\n VALUE\n </parameter>\n4. End the function with </function>\n5. End the tool call with </tool_call>\n6. NO quotes around tool names or parameter names\n7. NO extra spaces or characters\n8. NO JSON format - only use this XML-like format\n\n===============================\nCORRECT EXAMPLES\n===============================\nScreenshot:\n<tool_call>\n<function=computer>\n<parameter=action>\nscreenshot\n</parameter>\n</function>\n</tool_call>\n\nClick at coordinates:\n<tool_call>\n<function=computer>\n<parameter=action>\nleft_click\n</parameter>\n<parameter=coordinate>\n[100, 200]\n</parameter>\n</function>\n</tool_call>\n\nType text:\n<tool_call>\n<function=computer>\n<parameter=action>\ntype\n</parameter>\n<parameter=text>\nHello World\n</parameter>\n</function>\n</tool_call>\n\nScroll:\n<tool_call>\n<function=computer>\n<parameter=action>\nscroll\n</parameter>\n<parameter=coordinate>\n[500, 400]\n</parameter>\n<parameter=scroll_direction>\ndown\n</parameter>\n<parameter=scroll_amount>\n3\n</parameter>\n</function>\n</tool_call>\n\n===============================\nWRONG FORMATS (DO NOT USE)\n===============================\n❌ Missing <tool_call>...</tool_call> wrapper\n❌ <function=function='screenshot'> (no quotes or extra text)\n❌ <parameter=parameters> (must use actual parameter name)\n❌ JSON format like {\"action\": \"screenshot\"}\n❌ Any format other than the exact XML-like format above\n\n===============================\nEXECUTION RULES\n===============================\n- Use ONLY the tool names listed above\n- Include ALL required parameters for each tool\n- If you don't know a parameter value, ask the user\n- After calling a function, STOP and wait for the result\n- Do NOT add extra text before or after tool calls`;\n },\n});\n"],"mappings":";;;;;;;;;;;AAIO,IAAM,oCAAoC,qBAAqB;AAAA,EACpE,UAAU;AAAA,EACV,4BAA4B;AAAA,EAC5B,yBAAyB,OAAsC;AAC7D,UAAM,YAAY,KAAK,UAAU,KAAK;AACtC,WAAO;AAAA;AAAA,MAEL,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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