@bgicli/bgicli 2.3.7 → 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.
Files changed (2) hide show
  1. package/dist/bgi.js +26 -9
  2. 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
- let timeoutMs = args["timeout_ms"] ?? 3e5;
13965
- if (/\b(wget|curl|aria2c|axel|rsync)\b/.test(cmd) && timeoutMs < 36e5) {
13966
- timeoutMs = 36e5;
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"], timeoutMs, onStream);
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
- const timer = setTimeout(() => {
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
- }, timeoutMs);
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
- resolve4({ output: out, error: `Command timed out after ${timeoutMs / 1e3}s` });
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 {
@@ -15962,7 +15979,7 @@ function clearCheckpoints(sessionId) {
15962
15979
 
15963
15980
  // src/index.ts
15964
15981
  var import_fs7 = require("fs");
15965
- var VERSION2 = "2.3.7";
15982
+ var VERSION2 = "2.3.8";
15966
15983
  var SKILLHUB_HUBS = {
15967
15984
  bgi: { label: "BGI\u5185\u7F51", apiBase: "https://clawhub.ai", backend: "clawhub" },
15968
15985
  clawhub: { label: "clawhub.ai", apiBase: "https://clawhub.ai", backend: "clawhub" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgicli/bgicli",
3
- "version": "2.3.7",
3
+ "version": "2.3.8",
4
4
  "description": "BGI CLI — Bioinformatics AI terminal for Chinese researchers (百炼/DeepSeek/Kimi/Qwen)",
5
5
  "bin": {
6
6
  "bgi": "dist/bgi.js"