@lazyingart/agintiflow 0.20.134 → 0.20.136
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.
|
|
3
|
+
"version": "0.20.136",
|
|
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",
|
|
@@ -671,6 +671,16 @@ try {
|
|
|
671
671
|
assert(sanitizedSmallRead.content === longSmallFile, "small read_file result did not keep full content for the model");
|
|
672
672
|
assert(sanitizedSmallRead.contentTruncated === false, "small read_file result should not be marked truncated");
|
|
673
673
|
assert(!("contentPreview" in sanitizedSmallRead), "small read_file result should not replace full content with preview");
|
|
674
|
+
const limitedReadResult = await executeWorkspaceTool(
|
|
675
|
+
"read_file",
|
|
676
|
+
{ path: "small-read-smoke.md", startLine: 2, lineLimit: 3 },
|
|
677
|
+
{
|
|
678
|
+
commandCwd: workspace,
|
|
679
|
+
allowFileTools: true,
|
|
680
|
+
}
|
|
681
|
+
);
|
|
682
|
+
assert(limitedReadResult.content === "line 001\nline 002\nline 003", "read_file lineLimit did not return the requested line slice");
|
|
683
|
+
assert(limitedReadResult.contentTruncatedByLines === true, "read_file lineLimit should report remaining lines");
|
|
674
684
|
const inspected = await executeWorkspaceTool(
|
|
675
685
|
"inspect_project",
|
|
676
686
|
{ path: ".", maxDepth: 4, limit: 200 },
|
|
@@ -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
|
{
|
package/src/model-client.js
CHANGED
|
@@ -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
|
|
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(/"/g, '"')
|
|
274
|
+
.replace(/'/g, "'")
|
|
275
|
+
.replace(/</g, "<")
|
|
276
|
+
.replace(/>/g, ">")
|
|
277
|
+
.replace(/&/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
|
}
|
|
@@ -1107,6 +1153,9 @@ export async function requestNextStep(client, config, messages) {
|
|
|
1107
1153
|
type: "object",
|
|
1108
1154
|
properties: {
|
|
1109
1155
|
path: { type: "string", description: "Workspace-relative file path." },
|
|
1156
|
+
startLine: { type: "integer", description: "Optional 1-based first line to read." },
|
|
1157
|
+
lineLimit: { type: "integer", description: "Optional maximum number of lines to read; use this for large source files." },
|
|
1158
|
+
limit: { type: "integer", description: "Alias for lineLimit for compatibility with older prompts." },
|
|
1110
1159
|
},
|
|
1111
1160
|
required: ["path"],
|
|
1112
1161
|
additionalProperties: false,
|
package/src/workspace-tools.js
CHANGED
|
@@ -407,13 +407,23 @@ async function readTextFile(target) {
|
|
|
407
407
|
async function readFile(config, args) {
|
|
408
408
|
const target = resolveWorkspacePath(config, args.path);
|
|
409
409
|
const { stat, content, hash } = await readTextFile(target);
|
|
410
|
+
const lines = content.split(/\r?\n/);
|
|
411
|
+
const startLine = Math.min(Math.max(Number(args.startLine) || 1, 1), Math.max(lines.length, 1));
|
|
412
|
+
const requestedLineLimit = Number(args.lineLimit || args.limit || 0);
|
|
413
|
+
const lineLimit = Number.isFinite(requestedLineLimit) && requestedLineLimit > 0 ? Math.min(requestedLineLimit, 1000) : 0;
|
|
414
|
+
const selectedLines = lineLimit > 0 ? lines.slice(startLine - 1, startLine - 1 + lineLimit) : lines;
|
|
415
|
+
const selectedContent = selectedLines.join("\n");
|
|
410
416
|
return {
|
|
411
417
|
ok: true,
|
|
412
418
|
toolName: "read_file",
|
|
413
419
|
path: target.relativePath,
|
|
414
420
|
bytes: stat.size,
|
|
415
421
|
sha256: hash,
|
|
416
|
-
content: redactSensitiveText(
|
|
422
|
+
content: redactSensitiveText(selectedContent),
|
|
423
|
+
startLine,
|
|
424
|
+
lineLimit: lineLimit || null,
|
|
425
|
+
lineCount: lines.length,
|
|
426
|
+
contentTruncatedByLines: lineLimit > 0 && startLine - 1 + lineLimit < lines.length,
|
|
417
427
|
};
|
|
418
428
|
}
|
|
419
429
|
|