open-agents-ai 0.95.1 → 0.96.1
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/index.js +125 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1467,6 +1467,30 @@ ${stderr}` : ""),
|
|
|
1467
1467
|
// packages/execution/dist/tools/file-read.js
|
|
1468
1468
|
import { readFile } from "node:fs/promises";
|
|
1469
1469
|
import { resolve } from "node:path";
|
|
1470
|
+
function extractPath(args) {
|
|
1471
|
+
if (typeof args["path"] === "string" && args["path"].trim()) {
|
|
1472
|
+
return args["path"].trim();
|
|
1473
|
+
}
|
|
1474
|
+
for (const key of ["file", "file_path", "filename", "filepath", "filePath"]) {
|
|
1475
|
+
if (typeof args[key] === "string" && args[key].trim()) {
|
|
1476
|
+
return args[key].trim();
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
if (typeof args["_raw"] === "string") {
|
|
1480
|
+
const raw = args["_raw"].trim();
|
|
1481
|
+
const match = raw.match(/["']?(?:path|file|filename)["']?\s*[:=]\s*["']([^"'\s}]+)["']/i);
|
|
1482
|
+
if (match?.[1])
|
|
1483
|
+
return match[1];
|
|
1484
|
+
if (raw && !raw.includes("{") && !raw.includes(":") && raw.length < 500) {
|
|
1485
|
+
return raw;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
const stringVals = Object.values(args).filter((v) => typeof v === "string" && v.trim().length > 0 && v.length < 500);
|
|
1489
|
+
if (stringVals.length === 1 && /[./]/.test(stringVals[0])) {
|
|
1490
|
+
return stringVals[0].trim();
|
|
1491
|
+
}
|
|
1492
|
+
return null;
|
|
1493
|
+
}
|
|
1470
1494
|
var FileReadTool;
|
|
1471
1495
|
var init_file_read = __esm({
|
|
1472
1496
|
"packages/execution/dist/tools/file-read.js"() {
|
|
@@ -1493,10 +1517,18 @@ var init_file_read = __esm({
|
|
|
1493
1517
|
this._contextWindowSize = size;
|
|
1494
1518
|
}
|
|
1495
1519
|
async execute(args) {
|
|
1496
|
-
const filePath = args
|
|
1520
|
+
const filePath = extractPath(args);
|
|
1497
1521
|
const offset = args["offset"];
|
|
1498
1522
|
const limit = args["limit"];
|
|
1499
1523
|
const start = performance.now();
|
|
1524
|
+
if (!filePath) {
|
|
1525
|
+
return {
|
|
1526
|
+
success: false,
|
|
1527
|
+
output: "",
|
|
1528
|
+
error: `file_read requires "path" parameter. Call: file_read({"path": "src/example.ts"})`,
|
|
1529
|
+
durationMs: performance.now() - start
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1500
1532
|
try {
|
|
1501
1533
|
const fullPath = resolve(this.workingDir, filePath);
|
|
1502
1534
|
const content = await readFile(fullPath, "utf-8");
|
|
@@ -1541,6 +1573,14 @@ var init_file_read = __esm({
|
|
|
1541
1573
|
// packages/execution/dist/tools/file-write.js
|
|
1542
1574
|
import { writeFile, mkdir } from "node:fs/promises";
|
|
1543
1575
|
import { resolve as resolve2, dirname } from "node:path";
|
|
1576
|
+
function extractWritePath(args) {
|
|
1577
|
+
for (const key of ["path", "file", "file_path", "filename", "filepath", "filePath"]) {
|
|
1578
|
+
if (typeof args[key] === "string" && args[key].trim()) {
|
|
1579
|
+
return args[key].trim();
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
return null;
|
|
1583
|
+
}
|
|
1544
1584
|
var FileWriteTool;
|
|
1545
1585
|
var init_file_write = __esm({
|
|
1546
1586
|
"packages/execution/dist/tools/file-write.js"() {
|
|
@@ -1561,9 +1601,25 @@ var init_file_write = __esm({
|
|
|
1561
1601
|
this.workingDir = workingDir;
|
|
1562
1602
|
}
|
|
1563
1603
|
async execute(args) {
|
|
1564
|
-
const filePath = args
|
|
1565
|
-
const content = args["content"];
|
|
1604
|
+
const filePath = extractWritePath(args);
|
|
1605
|
+
const content = args["content"] ?? args["text"] ?? args["data"];
|
|
1566
1606
|
const start = performance.now();
|
|
1607
|
+
if (!filePath) {
|
|
1608
|
+
return {
|
|
1609
|
+
success: false,
|
|
1610
|
+
output: "",
|
|
1611
|
+
error: `file_write requires "path" parameter. Call: file_write({"path": "src/file.ts", "content": "..."})`,
|
|
1612
|
+
durationMs: performance.now() - start
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
if (content === void 0 || content === null || typeof content !== "string") {
|
|
1616
|
+
return {
|
|
1617
|
+
success: false,
|
|
1618
|
+
output: "",
|
|
1619
|
+
error: `file_write requires "content" parameter. Call: file_write({"path": "${filePath}", "content": "..."})`,
|
|
1620
|
+
durationMs: performance.now() - start
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1567
1623
|
try {
|
|
1568
1624
|
const fullPath = resolve2(this.workingDir, filePath);
|
|
1569
1625
|
await mkdir(dirname(fullPath), { recursive: true });
|
|
@@ -2401,6 +2457,14 @@ Meta: ${metaKeys.map((k) => `${k}="${meta[k]?.slice(0, 80)}"`).join(", ")}`);
|
|
|
2401
2457
|
// packages/execution/dist/tools/file-edit.js
|
|
2402
2458
|
import { readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
2403
2459
|
import { resolve as resolve5 } from "node:path";
|
|
2460
|
+
function extractEditPath(args) {
|
|
2461
|
+
for (const key of ["path", "file", "file_path", "filename", "filepath", "filePath"]) {
|
|
2462
|
+
if (typeof args[key] === "string" && args[key].trim()) {
|
|
2463
|
+
return args[key].trim();
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
return null;
|
|
2467
|
+
}
|
|
2404
2468
|
function countOccurrences(haystack, needle) {
|
|
2405
2469
|
let count = 0;
|
|
2406
2470
|
let pos = 0;
|
|
@@ -2454,11 +2518,35 @@ var init_file_edit = __esm({
|
|
|
2454
2518
|
this.workingDir = workingDir;
|
|
2455
2519
|
}
|
|
2456
2520
|
async execute(args) {
|
|
2457
|
-
const filePath = args
|
|
2458
|
-
const oldString = args["old_string"];
|
|
2459
|
-
const newString = args["new_string"];
|
|
2460
|
-
const replaceAll = args["replace_all"] === true;
|
|
2521
|
+
const filePath = extractEditPath(args);
|
|
2522
|
+
const oldString = args["old_string"] ?? args["oldString"] ?? args["search"] ?? args["find"];
|
|
2523
|
+
const newString = args["new_string"] ?? args["newString"] ?? args["replace"] ?? args["replacement"];
|
|
2524
|
+
const replaceAll = args["replace_all"] === true || args["replaceAll"] === true;
|
|
2461
2525
|
const start = performance.now();
|
|
2526
|
+
if (!filePath) {
|
|
2527
|
+
return {
|
|
2528
|
+
success: false,
|
|
2529
|
+
output: "",
|
|
2530
|
+
error: `file_edit requires "path" parameter. Call: file_edit({"path": "src/file.ts", "old_string": "...", "new_string": "..."})`,
|
|
2531
|
+
durationMs: performance.now() - start
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
if (!oldString || typeof oldString !== "string") {
|
|
2535
|
+
return {
|
|
2536
|
+
success: false,
|
|
2537
|
+
output: "",
|
|
2538
|
+
error: `file_edit requires "old_string" parameter. Call: file_edit({"path": "${filePath}", "old_string": "text to find", "new_string": "replacement"})`,
|
|
2539
|
+
durationMs: performance.now() - start
|
|
2540
|
+
};
|
|
2541
|
+
}
|
|
2542
|
+
if (newString === void 0 || newString === null || typeof newString !== "string") {
|
|
2543
|
+
return {
|
|
2544
|
+
success: false,
|
|
2545
|
+
output: "",
|
|
2546
|
+
error: `file_edit requires "new_string" parameter. Call: file_edit({"path": "${filePath}", "old_string": "...", "new_string": "replacement text"})`,
|
|
2547
|
+
durationMs: performance.now() - start
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2462
2550
|
try {
|
|
2463
2551
|
const fullPath = resolve5(this.workingDir, filePath);
|
|
2464
2552
|
const content = await readFile2(fullPath, "utf-8");
|
|
@@ -3121,7 +3209,8 @@ var init_list_directory = __esm({
|
|
|
3121
3209
|
this.workingDir = workingDir;
|
|
3122
3210
|
}
|
|
3123
3211
|
async execute(args) {
|
|
3124
|
-
const
|
|
3212
|
+
const rawPath = args["path"];
|
|
3213
|
+
const dirPath = typeof rawPath === "string" && rawPath.trim() ? rawPath : ".";
|
|
3125
3214
|
const start = performance.now();
|
|
3126
3215
|
try {
|
|
3127
3216
|
const fullPath = resolve9(this.workingDir, dirPath);
|
|
@@ -23647,6 +23736,29 @@ function ansi2(code, text) {
|
|
|
23647
23736
|
function fg256(code, text) {
|
|
23648
23737
|
return isTTY2 ? `\x1B[38;5;${code}m${text}\x1B[0m` : text;
|
|
23649
23738
|
}
|
|
23739
|
+
function hyperlink(url, text) {
|
|
23740
|
+
if (!isTTY2)
|
|
23741
|
+
return text;
|
|
23742
|
+
return `\x1B]8;;${url}\x07${text}\x1B]8;;\x07`;
|
|
23743
|
+
}
|
|
23744
|
+
function fileLink(filePath) {
|
|
23745
|
+
if (!isTTY2)
|
|
23746
|
+
return filePath;
|
|
23747
|
+
if (filePath.startsWith("/") || filePath.startsWith("~")) {
|
|
23748
|
+
const absPath = filePath.startsWith("~") ? filePath.replace("~", process.env["HOME"] ?? "") : filePath;
|
|
23749
|
+
return hyperlink(`file://${absPath}`, filePath);
|
|
23750
|
+
}
|
|
23751
|
+
return filePath;
|
|
23752
|
+
}
|
|
23753
|
+
function linkifyPaths(text) {
|
|
23754
|
+
if (!isTTY2)
|
|
23755
|
+
return text;
|
|
23756
|
+
return text.replace(/(\/[\w./\-@+]+)/g, (match) => {
|
|
23757
|
+
if (match.length < 3 || match.endsWith("/"))
|
|
23758
|
+
return match;
|
|
23759
|
+
return hyperlink(`file://${match}`, match);
|
|
23760
|
+
});
|
|
23761
|
+
}
|
|
23650
23762
|
function setEmojisEnabled(enabled) {
|
|
23651
23763
|
_emojisEnabled = enabled;
|
|
23652
23764
|
}
|
|
@@ -23786,7 +23898,7 @@ function renderToolResult(toolName, success, output, verbose) {
|
|
|
23786
23898
|
case "file_write": {
|
|
23787
23899
|
const summary = extractFirstLine(output, maxW);
|
|
23788
23900
|
if (success) {
|
|
23789
|
-
process.stdout.write(`${prefix}${c2.dim(summary)}
|
|
23901
|
+
process.stdout.write(`${prefix}${c2.dim(linkifyPaths(summary))}
|
|
23790
23902
|
`);
|
|
23791
23903
|
} else {
|
|
23792
23904
|
process.stdout.write(`${prefix}${c2.red(summary)}
|
|
@@ -23797,7 +23909,7 @@ function renderToolResult(toolName, success, output, verbose) {
|
|
|
23797
23909
|
case "file_edit": {
|
|
23798
23910
|
const summary = extractFirstLine(output, maxW);
|
|
23799
23911
|
if (success) {
|
|
23800
|
-
process.stdout.write(`${prefix}${c2.dim(summary)}
|
|
23912
|
+
process.stdout.write(`${prefix}${c2.dim(linkifyPaths(summary))}
|
|
23801
23913
|
`);
|
|
23802
23914
|
} else {
|
|
23803
23915
|
process.stdout.write(`${prefix}${c2.red(summary)}
|
|
@@ -24230,17 +24342,17 @@ function formatToolArgs(toolName, args, verbose) {
|
|
|
24230
24342
|
case "file_read":
|
|
24231
24343
|
case "file_write":
|
|
24232
24344
|
case "file_edit":
|
|
24233
|
-
return String(args["path"] ?? "");
|
|
24345
|
+
return fileLink(String(args["path"] ?? ""));
|
|
24234
24346
|
case "shell": {
|
|
24235
24347
|
const cmd = truncStr(String(args["command"] ?? ""), maxArg);
|
|
24236
24348
|
return args["stdin"] ? `${cmd} ${c2.dim("(with stdin)")}` : cmd;
|
|
24237
24349
|
}
|
|
24238
24350
|
case "grep_search":
|
|
24239
|
-
return `${c2.yellow(String(args["pattern"] ?? ""))}${args["path"] ? ` in ${args["path"]}` : ""}`;
|
|
24351
|
+
return `${c2.yellow(String(args["pattern"] ?? ""))}${args["path"] ? ` in ${fileLink(String(args["path"]))}` : ""}`;
|
|
24240
24352
|
case "find_files":
|
|
24241
24353
|
return String(args["pattern"] ?? "");
|
|
24242
24354
|
case "list_directory":
|
|
24243
|
-
return String(args["path"] ?? ".");
|
|
24355
|
+
return fileLink(String(args["path"] ?? "."));
|
|
24244
24356
|
case "web_search":
|
|
24245
24357
|
return `"${truncStr(String(args["query"] ?? ""), maxArg - 2)}"`;
|
|
24246
24358
|
case "web_fetch":
|
package/package.json
CHANGED