@oxecli/oxe 1.0.105 → 1.0.106
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 +4 -0
- package/dist/engine.js +3 -3
- package/dist/tools.js +21 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/engine.js
CHANGED
|
@@ -82,7 +82,7 @@ export class InferenceEngine {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
async runTool(name, argumentsJson) {
|
|
85
|
+
async runTool(name, argumentsJson, signal) {
|
|
86
86
|
let args = {};
|
|
87
87
|
try {
|
|
88
88
|
args = argumentsJson ? JSON.parse(argumentsJson) : {};
|
|
@@ -103,7 +103,7 @@ export class InferenceEngine {
|
|
|
103
103
|
result = toolEditFile(args.path, args.old_string, args.new_string, args.replace_all);
|
|
104
104
|
break;
|
|
105
105
|
case "bash":
|
|
106
|
-
result = await toolBash(args.command, args.timeout, args.cwd);
|
|
106
|
+
result = await toolBash(args.command, args.timeout, args.cwd, signal);
|
|
107
107
|
break;
|
|
108
108
|
case "glob":
|
|
109
109
|
result = toolGlob(args.pattern, args.path, args.limit, args.depth);
|
|
@@ -591,7 +591,7 @@ export class InferenceEngine {
|
|
|
591
591
|
dockTransientStart("flush");
|
|
592
592
|
const toolSpinner = new Spinner();
|
|
593
593
|
toolSpinner.startDots("\x1b[90m╰─\x1b[0m Working");
|
|
594
|
-
const rawResult = await this.runTool(c.name, c.arguments);
|
|
594
|
+
const rawResult = await this.runTool(c.name, c.arguments, this.activeAbort?.signal);
|
|
595
595
|
// A tool call was made, which interrupts any current working phase,
|
|
596
596
|
// so the next agent iteration may commit a fresh "Worked for …" block.
|
|
597
597
|
this.workedCommitted = false;
|
package/dist/tools.js
CHANGED
|
@@ -586,7 +586,7 @@ function terminateProcessTree(proc) {
|
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
|
-
export function toolBash(command, timeout = 60, cwd) {
|
|
589
|
+
export function toolBash(command, timeout = 60, cwd, signal) {
|
|
590
590
|
try {
|
|
591
591
|
let t = typeof timeout === "number" ? timeout : parseInt(String(timeout), 10);
|
|
592
592
|
if (Number.isNaN(t))
|
|
@@ -597,6 +597,10 @@ export function toolBash(command, timeout = 60, cwd) {
|
|
|
597
597
|
return Promise.resolve(`Error: working directory not found: ${cwd}`);
|
|
598
598
|
}
|
|
599
599
|
return new Promise((resolve) => {
|
|
600
|
+
if (signal && signal.aborted) {
|
|
601
|
+
resolve("Error: command aborted");
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
600
604
|
let child;
|
|
601
605
|
try {
|
|
602
606
|
if (process.platform === "win32") {
|
|
@@ -621,6 +625,18 @@ export function toolBash(command, timeout = 60, cwd) {
|
|
|
621
625
|
let stdout = "";
|
|
622
626
|
let stderr = "";
|
|
623
627
|
let finished = false;
|
|
628
|
+
const onAbort = () => {
|
|
629
|
+
if (finished)
|
|
630
|
+
return;
|
|
631
|
+
terminateProcessTree({
|
|
632
|
+
pid: child.pid,
|
|
633
|
+
kill: (sig) => child.kill(sig),
|
|
634
|
+
});
|
|
635
|
+
finished = true;
|
|
636
|
+
clearTimeout(timer);
|
|
637
|
+
resolve("Error: command aborted");
|
|
638
|
+
};
|
|
639
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
624
640
|
const timer = setTimeout(() => {
|
|
625
641
|
if (finished)
|
|
626
642
|
return;
|
|
@@ -633,6 +649,8 @@ export function toolBash(command, timeout = 60, cwd) {
|
|
|
633
649
|
if (output)
|
|
634
650
|
msg += `\n${output}`;
|
|
635
651
|
finished = true;
|
|
652
|
+
clearTimeout(timer);
|
|
653
|
+
signal?.removeEventListener("abort", onAbort);
|
|
636
654
|
resolve(msg);
|
|
637
655
|
}, t * 1000);
|
|
638
656
|
child.stdout?.on("data", (d) => (stdout += d.toString("utf-8")));
|
|
@@ -642,6 +660,7 @@ export function toolBash(command, timeout = 60, cwd) {
|
|
|
642
660
|
return;
|
|
643
661
|
finished = true;
|
|
644
662
|
clearTimeout(timer);
|
|
663
|
+
signal?.removeEventListener("abort", onAbort);
|
|
645
664
|
resolve(`Error: ${err}`);
|
|
646
665
|
});
|
|
647
666
|
child.on("close", (code) => {
|
|
@@ -649,6 +668,7 @@ export function toolBash(command, timeout = 60, cwd) {
|
|
|
649
668
|
return;
|
|
650
669
|
finished = true;
|
|
651
670
|
clearTimeout(timer);
|
|
671
|
+
signal?.removeEventListener("abort", onAbort);
|
|
652
672
|
const output = (stdout + stderr).trim() || "(no output)";
|
|
653
673
|
resolve(`exit code: ${code}\n${output}`);
|
|
654
674
|
});
|