@bgicli/bgicli 2.3.6 → 2.3.8
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 +31 -13
- package/package.json +1 -1
package/dist/bgi.js
CHANGED
|
@@ -13855,7 +13855,7 @@ var TOOL_DEFINITIONS = [
|
|
|
13855
13855
|
},
|
|
13856
13856
|
timeout_ms: {
|
|
13857
13857
|
type: "number",
|
|
13858
|
-
description: "Timeout in milliseconds (default 300000 / 5 min
|
|
13858
|
+
description: "Timeout in milliseconds (default 300000 / 5 min). For downloads (wget/curl/aria2c) or long computations (STAR, HISAT2, etc.) ALWAYS use at least 3600000 (60 min). Never set a short timeout for downloads \u2014 slow networks are normal, be patient."
|
|
13859
13859
|
}
|
|
13860
13860
|
},
|
|
13861
13861
|
required: ["command"]
|
|
@@ -13959,13 +13959,15 @@ var TOOL_DEFINITIONS = [
|
|
|
13959
13959
|
async function executeTool(name, args, onStream) {
|
|
13960
13960
|
try {
|
|
13961
13961
|
switch (name) {
|
|
13962
|
-
case "bash":
|
|
13963
|
-
|
|
13964
|
-
|
|
13965
|
-
|
|
13966
|
-
|
|
13967
|
-
onStream
|
|
13968
|
-
|
|
13962
|
+
case "bash": {
|
|
13963
|
+
const cmd = args["command"];
|
|
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);
|
|
13968
|
+
}
|
|
13969
|
+
return await toolBash(cmd, args["workdir"], requestedTimeout, onStream);
|
|
13970
|
+
}
|
|
13969
13971
|
case "read_file":
|
|
13970
13972
|
return toolReadFile(
|
|
13971
13973
|
args["path"],
|
|
@@ -14015,7 +14017,7 @@ function injectProgressFlags(cmd) {
|
|
|
14015
14017
|
}
|
|
14016
14018
|
return cmd;
|
|
14017
14019
|
}
|
|
14018
|
-
async function toolBash(command, workdir, timeoutMs = 3e5, onStream) {
|
|
14020
|
+
async function toolBash(command, workdir, timeoutMs = 3e5, onStream, inactivityMs) {
|
|
14019
14021
|
const scan = scanCommand(command);
|
|
14020
14022
|
const criticals = scan.matches.filter((m2) => m2.pattern.level === "CRITICAL");
|
|
14021
14023
|
if (criticals.length > 0) {
|
|
@@ -14064,15 +14066,31 @@ async function toolBash(command, workdir, timeoutMs = 3e5, onStream) {
|
|
|
14064
14066
|
}
|
|
14065
14067
|
});
|
|
14066
14068
|
let timedOut = false;
|
|
14067
|
-
|
|
14069
|
+
let timedOutSecs = 0;
|
|
14070
|
+
const effectiveMs = inactivityMs ?? timeoutMs;
|
|
14071
|
+
let timer = setTimeout(() => {
|
|
14068
14072
|
timedOut = true;
|
|
14073
|
+
timedOutSecs = effectiveMs / 1e3;
|
|
14069
14074
|
child.kill();
|
|
14070
|
-
},
|
|
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
|
+
}
|
|
14071
14088
|
child.on("close", (code) => {
|
|
14072
14089
|
clearTimeout(timer);
|
|
14073
14090
|
const out = (decodeBuffer(Buffer.concat(outChunks)) + "\n" + decodeBuffer(Buffer.concat(errChunks))).trim();
|
|
14074
14091
|
if (timedOut) {
|
|
14075
|
-
|
|
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 });
|
|
14076
14094
|
} else if (code !== 0) {
|
|
14077
14095
|
resolve4({ output: out, error: `Command failed (exit ${code})` });
|
|
14078
14096
|
} else {
|
|
@@ -15961,7 +15979,7 @@ function clearCheckpoints(sessionId) {
|
|
|
15961
15979
|
|
|
15962
15980
|
// src/index.ts
|
|
15963
15981
|
var import_fs7 = require("fs");
|
|
15964
|
-
var VERSION2 = "2.3.
|
|
15982
|
+
var VERSION2 = "2.3.8";
|
|
15965
15983
|
var SKILLHUB_HUBS = {
|
|
15966
15984
|
bgi: { label: "BGI\u5185\u7F51", apiBase: "https://clawhub.ai", backend: "clawhub" },
|
|
15967
15985
|
clawhub: { label: "clawhub.ai", apiBase: "https://clawhub.ai", backend: "clawhub" },
|