@lark-apaas/openclaw-scripts-diagnose-cli 0.1.15-alpha.7 → 0.1.15-alpha.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.
Files changed (2) hide show
  1. package/dist/index.cjs +19 -7
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -52,7 +52,7 @@ node_assert = __toESM(node_assert);
52
52
  * it terse and parseable.
53
53
  */
54
54
  function getVersion() {
55
- return "0.1.15-alpha.7";
55
+ return "0.1.15-alpha.9";
56
56
  }
57
57
  //#endregion
58
58
  //#region src/rule-engine/base.ts
@@ -10602,7 +10602,7 @@ async function reportCliRun(opts) {
10602
10602
  //#region src/help.ts
10603
10603
  const BIN = "mclaw-diagnose";
10604
10604
  function versionBanner() {
10605
- return `v0.1.15-alpha.7`;
10605
+ return `v0.1.15-alpha.9`;
10606
10606
  }
10607
10607
  const COMMANDS = [
10608
10608
  {
@@ -11196,13 +11196,23 @@ const LOG_PREFIX_RE = /^\[\d{4}-\d{2}-\d{2}T[\d:.]+Z\](?:\s+\[run=[^\]]+\])?\s*/
11196
11196
  * 日志头部为固定 banner,有价值的内容集中在末尾,从尾部截取。
11197
11197
  */
11198
11198
  function readLogFileTail(filePath, maxBytes = 4e3) {
11199
+ let fd = -1;
11199
11200
  try {
11200
- const buf = node_fs.default.readFileSync(filePath);
11201
- let start = buf.length > maxBytes ? buf.length - maxBytes : 0;
11201
+ fd = node_fs.default.openSync(filePath, "r");
11202
+ const { size } = node_fs.default.fstatSync(fd);
11203
+ const readOffset = size > maxBytes ? size - maxBytes : 0;
11204
+ const readSize = size - readOffset;
11205
+ const buf = Buffer.allocUnsafe(readSize);
11206
+ node_fs.default.readSync(fd, buf, 0, readSize, readOffset);
11207
+ let start = 0;
11202
11208
  while (start < buf.length && buf[start] !== 10) start++;
11203
- return buf.subarray(start > 0 ? start + 1 : 0).toString("utf-8").split("\n").map((line) => line.replace(LOG_PREFIX_RE, "")).filter((line) => !/^=+$/.test(line.trim())).join("\n").trim();
11209
+ return (start < buf.length ? buf.subarray(start + 1).toString("utf-8") : buf.toString("utf-8")).split("\n").map((line) => line.replace(LOG_PREFIX_RE, "")).filter((line) => !/^=+$/.test(line.trim())).join("\n").trim();
11204
11210
  } catch {
11205
11211
  return "";
11212
+ } finally {
11213
+ if (fd !== -1) try {
11214
+ node_fs.default.closeSync(fd);
11215
+ } catch {}
11206
11216
  }
11207
11217
  }
11208
11218
  /**
@@ -11602,7 +11612,7 @@ function runUpgradeLark(opts) {
11602
11612
  timing.postProbeMs = Date.now() - t_postProbeStart;
11603
11613
  log(` feishu config invalid after: ${afterChannels.feishuConfigInvalid}`);
11604
11614
  const stillNeedsUpgrade = (afterVersionIncompatible || afterChannels.feishuConfigInvalid) && !afterChannels.anyAccountWorking;
11605
- const isNewDefaultOnly = !beforeChannels.anyAccountWorking && isDefaultOnlyState(afterChannels);
11615
+ const isNewDefaultOnly = !beforeChannels.anyAccountWorking && isDefaultOnlyState(afterChannels) && !afterVersionIncompatible;
11606
11616
  log(` post-check: stillNeedsUpgrade=${stillNeedsUpgrade} (version=${afterVersionIncompatible}, feishuConfig=${afterChannels.feishuConfigInvalid}, channelsWorking=${afterChannels.anyAccountWorking}) isNewDefaultOnly=${isNewDefaultOnly}`);
11607
11617
  if (stillNeedsUpgrade && !isNewDefaultOnly) return doRollback(`post-install diagnosis still shows anomaly: versionIncompatible=${afterVersionIncompatible}, feishuConfigInvalid=${afterChannels.feishuConfigInvalid}, anyAccountWorking=${afterChannels.anyAccountWorking}`);
11608
11618
  if (isNewDefaultOnly) log(" post-install diagnosis: ok (new default account — plugin installed, awaiting configuration)");
@@ -12198,7 +12208,9 @@ async function main() {
12198
12208
  break;
12199
12209
  }
12200
12210
  case "channels-probe": {
12201
- const result = runChannelsProbe(getFlag(args, "timeout") ? Number(getFlag(args, "timeout")) : void 0);
12211
+ const timeoutRaw = getFlag(args, "timeout");
12212
+ const parsed = timeoutRaw != null ? Number(timeoutRaw) : NaN;
12213
+ const result = runChannelsProbe(timeoutRaw != null ? Number.isNaN(parsed) ? 6e4 : Math.max(1e3, parsed) : void 0);
12202
12214
  console.log(JSON.stringify(result));
12203
12215
  break;
12204
12216
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/openclaw-scripts-diagnose-cli",
3
- "version": "0.1.15-alpha.7",
3
+ "version": "0.1.15-alpha.9",
4
4
  "description": "CLI for OpenClaw config diagnose and repair with JSON5 support",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {