@bgicli/bgicli 2.3.7 → 2.3.9
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/bgi.js +29 -10
- package/package.json +1 -1
package/dist/bgi.js
CHANGED
|
@@ -13961,11 +13961,12 @@ async function executeTool(name, args, onStream) {
|
|
|
13961
13961
|
switch (name) {
|
|
13962
13962
|
case "bash": {
|
|
13963
13963
|
const cmd = args["command"];
|
|
13964
|
-
|
|
13965
|
-
|
|
13966
|
-
|
|
13964
|
+
const requestedTimeout = args["timeout_ms"] ?? 3e5;
|
|
13965
|
+
const isDownload = /\b(wget|curl|aria2c|axel|rsync)\b/.test(cmd);
|
|
13966
|
+
if (isDownload) {
|
|
13967
|
+
return await toolBash(cmd, args["workdir"], 0, onStream, 6e5);
|
|
13967
13968
|
}
|
|
13968
|
-
return await toolBash(cmd, args["workdir"],
|
|
13969
|
+
return await toolBash(cmd, args["workdir"], requestedTimeout, onStream);
|
|
13969
13970
|
}
|
|
13970
13971
|
case "read_file":
|
|
13971
13972
|
return toolReadFile(
|
|
@@ -14016,7 +14017,7 @@ function injectProgressFlags(cmd) {
|
|
|
14016
14017
|
}
|
|
14017
14018
|
return cmd;
|
|
14018
14019
|
}
|
|
14019
|
-
async function toolBash(command, workdir, timeoutMs = 3e5, onStream) {
|
|
14020
|
+
async function toolBash(command, workdir, timeoutMs = 3e5, onStream, inactivityMs) {
|
|
14020
14021
|
const scan = scanCommand(command);
|
|
14021
14022
|
const criticals = scan.matches.filter((m2) => m2.pattern.level === "CRITICAL");
|
|
14022
14023
|
if (criticals.length > 0) {
|
|
@@ -14065,15 +14066,31 @@ async function toolBash(command, workdir, timeoutMs = 3e5, onStream) {
|
|
|
14065
14066
|
}
|
|
14066
14067
|
});
|
|
14067
14068
|
let timedOut = false;
|
|
14068
|
-
|
|
14069
|
+
let timedOutSecs = 0;
|
|
14070
|
+
const effectiveMs = inactivityMs ?? timeoutMs;
|
|
14071
|
+
let timer = setTimeout(() => {
|
|
14069
14072
|
timedOut = true;
|
|
14073
|
+
timedOutSecs = effectiveMs / 1e3;
|
|
14070
14074
|
child.kill();
|
|
14071
|
-
},
|
|
14075
|
+
}, effectiveMs);
|
|
14076
|
+
const resetTimer = inactivityMs ? () => {
|
|
14077
|
+
clearTimeout(timer);
|
|
14078
|
+
timer = setTimeout(() => {
|
|
14079
|
+
timedOut = true;
|
|
14080
|
+
timedOutSecs = inactivityMs / 1e3;
|
|
14081
|
+
child.kill();
|
|
14082
|
+
}, inactivityMs);
|
|
14083
|
+
} : null;
|
|
14084
|
+
if (resetTimer) {
|
|
14085
|
+
child.stdout?.on("data", resetTimer);
|
|
14086
|
+
child.stderr?.on("data", resetTimer);
|
|
14087
|
+
}
|
|
14072
14088
|
child.on("close", (code) => {
|
|
14073
14089
|
clearTimeout(timer);
|
|
14074
14090
|
const out = (decodeBuffer(Buffer.concat(outChunks)) + "\n" + decodeBuffer(Buffer.concat(errChunks))).trim();
|
|
14075
14091
|
if (timedOut) {
|
|
14076
|
-
|
|
14092
|
+
const msg = inactivityMs ? `\u4E0B\u8F7D\u505C\u6EDE \u2014 \u8D85\u8FC7 ${timedOutSecs}s \u65E0\u4EFB\u4F55\u8F93\u51FA\uFF08\u8FDE\u63A5\u53EF\u80FD\u5DF2\u65AD\u5F00\uFF09` : `Command timed out after ${timedOutSecs}s`;
|
|
14093
|
+
resolve4({ output: out, error: msg });
|
|
14077
14094
|
} else if (code !== 0) {
|
|
14078
14095
|
resolve4({ output: out, error: `Command failed (exit ${code})` });
|
|
14079
14096
|
} else {
|
|
@@ -14299,6 +14316,7 @@ ${label} `);
|
|
|
14299
14316
|
let lastLineWasEmpty = false;
|
|
14300
14317
|
let spinnerCleared = false;
|
|
14301
14318
|
let partialLine = "";
|
|
14319
|
+
let outputStarted = false;
|
|
14302
14320
|
const MAX_STREAM_LINES = 200;
|
|
14303
14321
|
let frame = 0;
|
|
14304
14322
|
const spin = setInterval(() => {
|
|
@@ -14318,7 +14336,8 @@ ${label} `);
|
|
|
14318
14336
|
let heartbeat = null;
|
|
14319
14337
|
const onStream = isBash ? (chunk) => {
|
|
14320
14338
|
lastChunkTime = Date.now();
|
|
14321
|
-
if (
|
|
14339
|
+
if (!outputStarted) {
|
|
14340
|
+
outputStarted = true;
|
|
14322
14341
|
clearSpinner();
|
|
14323
14342
|
process.stdout.write(`${label}
|
|
14324
14343
|
`);
|
|
@@ -15962,7 +15981,7 @@ function clearCheckpoints(sessionId) {
|
|
|
15962
15981
|
|
|
15963
15982
|
// src/index.ts
|
|
15964
15983
|
var import_fs7 = require("fs");
|
|
15965
|
-
var VERSION2 = "2.3.
|
|
15984
|
+
var VERSION2 = "2.3.9";
|
|
15966
15985
|
var SKILLHUB_HUBS = {
|
|
15967
15986
|
bgi: { label: "BGI\u5185\u7F51", apiBase: "https://clawhub.ai", backend: "clawhub" },
|
|
15968
15987
|
clawhub: { label: "clawhub.ai", apiBase: "https://clawhub.ai", backend: "clawhub" },
|