@lazyingart/agintiflow 0.20.134 → 0.20.135

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyingart/agintiflow",
3
- "version": "0.20.134",
3
+ "version": "0.20.135",
4
4
  "type": "module",
5
5
  "description": "AgInTiFlow is a project-aware agent workspace for hybrid wet-dry R&D, hardware-aware intelligence, software automation, and industrial workflows.",
6
6
  "license": "Apache-2.0",
@@ -179,6 +179,12 @@ const multipleRequestedToolCalls = parseTextToolCalls(
179
179
  );
180
180
  assert(multipleRequestedToolCalls.length === 2, "Requested tools parser did not detect multiple function-call texts");
181
181
  assert(multipleRequestedToolCalls[1].function.name === "inspect_project", "Requested tools parser returned wrong second requested tool");
182
+ const xmlTextToolCalls = parseTextToolCalls(
183
+ '<tool_calls>\n<tool_call name="inspect_project">{"project_path":"/workspace"}</tool_call>\n<tool_call name="list_files">{"path":".","depth":2}</tool_call>\n</tool_calls>'
184
+ );
185
+ assert(xmlTextToolCalls.length === 2, "XML text tool-call parser did not detect multiple calls");
186
+ assert(xmlTextToolCalls[0].function.name === "inspect_project", "XML text tool-call parser returned wrong first tool");
187
+ assert(xmlTextToolCalls[1].function.arguments.includes('"depth":2'), "XML text tool-call parser returned wrong arguments");
182
188
  const malformedRequestedToolResponse = normalizeTextToolCallResponse({
183
189
  choices: [
184
190
  {
@@ -204,6 +204,7 @@ export function parseTextToolCalls(content = "") {
204
204
 
205
205
  const calls = [];
206
206
  for (const call of parseRequestedToolCalls(text)) calls.push(call);
207
+ for (const call of parseXmlToolCalls(text, calls.length)) calls.push(call);
207
208
  const jsonBlock = text.match(/TOOL_CALLS\s*:\s*```(?:json)?\s*([\s\S]*?)```/i);
208
209
  if (jsonBlock?.[1]) {
209
210
  try {
@@ -258,7 +259,51 @@ export function parseTextToolCalls(content = "") {
258
259
 
259
260
  function hasTextToolCallMarker(content = "") {
260
261
  const text = String(content || "");
261
- return text.includes("[TOOL_CALLS]") || /TOOL_CALLS\s*:/i.test(text) || /Requested tools?\s*:/i.test(text);
262
+ return (
263
+ text.includes("[TOOL_CALLS]") ||
264
+ /TOOL_CALLS\s*:/i.test(text) ||
265
+ /Requested tools?\s*:/i.test(text) ||
266
+ /<tool_calls?>/i.test(text)
267
+ );
268
+ }
269
+
270
+ function decodeXmlToolArgs(value = "") {
271
+ return String(value || "")
272
+ .trim()
273
+ .replace(/&quot;/g, '"')
274
+ .replace(/&apos;/g, "'")
275
+ .replace(/&lt;/g, "<")
276
+ .replace(/&gt;/g, ">")
277
+ .replace(/&amp;/g, "&");
278
+ }
279
+
280
+ function parseXmlToolCalls(content = "", offset = 0) {
281
+ const text = String(content || "");
282
+ const calls = [];
283
+ const pattern = /<tool_call\b([^>]*)>([\s\S]*?)<\/tool_call>/gi;
284
+ let match;
285
+ while ((match = pattern.exec(text))) {
286
+ const attrs = match[1] || "";
287
+ const name =
288
+ attrs.match(/\bname\s*=\s*"([^"]+)"/i)?.[1]?.trim() ||
289
+ attrs.match(/\bname\s*=\s*'([^']+)'/i)?.[1]?.trim();
290
+ if (!name) continue;
291
+ const rawArgs = decodeXmlToolArgs(match[2]);
292
+ try {
293
+ JSON.parse(rawArgs || "{}");
294
+ } catch {
295
+ continue;
296
+ }
297
+ calls.push({
298
+ id: `text-tool-${offset + calls.length + 1}`,
299
+ type: "function",
300
+ function: {
301
+ name,
302
+ arguments: rawArgs || "{}",
303
+ },
304
+ });
305
+ }
306
+ return calls;
262
307
  }
263
308
 
264
309
  function findMatchingParen(text = "", openIndex = 0) {
@@ -330,6 +375,7 @@ function textBeforeToolCallMarker(content = "") {
330
375
  .split("[TOOL_CALLS]")[0]
331
376
  .split("TOOL_CALLS:")[0]
332
377
  .split(/Requested tools?\s*:/i)[0]
378
+ .split(/<tool_calls?>/i)[0]
333
379
  .split("<|tool_call>")[0]
334
380
  .trim();
335
381
  }