mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 11:50:45 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
93
openclaw/scripts/test-live.mjs
Normal file
93
openclaw/scripts/test-live.mjs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
import { spawnPnpmRunner } from "./pnpm-runner.mjs";
|
||||
|
||||
const forwardedArgs = [];
|
||||
let quietOverride;
|
||||
|
||||
for (const arg of process.argv.slice(2)) {
|
||||
if (arg === "--") {
|
||||
continue;
|
||||
}
|
||||
if (arg === "--quiet" || arg === "--quiet-live") {
|
||||
quietOverride = "1";
|
||||
continue;
|
||||
}
|
||||
if (arg === "--no-quiet" || arg === "--no-quiet-live") {
|
||||
quietOverride = "0";
|
||||
continue;
|
||||
}
|
||||
forwardedArgs.push(arg);
|
||||
}
|
||||
|
||||
const env = {
|
||||
...process.env,
|
||||
OPENCLAW_LIVE_TEST: process.env.OPENCLAW_LIVE_TEST || "1",
|
||||
OPENCLAW_LIVE_TEST_QUIET: quietOverride ?? process.env.OPENCLAW_LIVE_TEST_QUIET ?? "1",
|
||||
};
|
||||
|
||||
function parsePositiveInt(value, fallback) {
|
||||
if (!value) {
|
||||
return fallback;
|
||||
}
|
||||
const parsed = Number.parseInt(value, 10);
|
||||
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
||||
}
|
||||
|
||||
const heartbeatMs = parsePositiveInt(process.env.OPENCLAW_LIVE_WRAPPER_HEARTBEAT_MS, 20_000);
|
||||
const startedAt = Date.now();
|
||||
let lastOutputAt = startedAt;
|
||||
|
||||
const child = spawnPnpmRunner({
|
||||
stdio: ["inherit", "pipe", "pipe"],
|
||||
pnpmArgs: [
|
||||
"exec",
|
||||
"vitest",
|
||||
"run",
|
||||
"--config",
|
||||
"test/vitest/vitest.live.config.ts",
|
||||
...forwardedArgs,
|
||||
],
|
||||
env,
|
||||
});
|
||||
|
||||
const noteOutput = () => {
|
||||
lastOutputAt = Date.now();
|
||||
};
|
||||
|
||||
child.stdout?.on("data", (chunk) => {
|
||||
noteOutput();
|
||||
process.stdout.write(chunk);
|
||||
});
|
||||
|
||||
child.stderr?.on("data", (chunk) => {
|
||||
noteOutput();
|
||||
process.stderr.write(chunk);
|
||||
});
|
||||
|
||||
const heartbeat = setInterval(() => {
|
||||
const now = Date.now();
|
||||
if (now - lastOutputAt < heartbeatMs) {
|
||||
return;
|
||||
}
|
||||
const elapsedSec = Math.max(1, Math.round((now - startedAt) / 1_000));
|
||||
const quietSec = Math.max(1, Math.round((now - lastOutputAt) / 1_000));
|
||||
process.stderr.write(
|
||||
`[test:live] still running (${elapsedSec}s elapsed, ${quietSec}s since last output)\n`,
|
||||
);
|
||||
lastOutputAt = now;
|
||||
}, heartbeatMs);
|
||||
heartbeat.unref?.();
|
||||
|
||||
child.on("exit", (code, signal) => {
|
||||
clearInterval(heartbeat);
|
||||
if (signal) {
|
||||
process.kill(process.pid, signal);
|
||||
return;
|
||||
}
|
||||
process.exit(code ?? 1);
|
||||
});
|
||||
|
||||
child.on("error", (error) => {
|
||||
clearInterval(heartbeat);
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue