





















@@ -9,6 +9,8 @@ const TMUX_ATTACH_FORCE_VALUES = new Set(["1", "true", "yes", "on"]);
99const DEFAULT_PROFILE_NAME = "main";
1010const DEFAULT_BENCHMARK_PROFILE_DIR = ".artifacts/gateway-watch-profiles";
1111const RUN_NODE_CPU_PROF_DIR_ENV = "OPENCLAW_RUN_NODE_CPU_PROF_DIR";
12+const RUN_NODE_OUTPUT_LOG_ENV = "OPENCLAW_RUN_NODE_OUTPUT_LOG";
13+const RUN_NODE_FILTER_SYNC_IO_STDERR_ENV = "OPENCLAW_RUN_NODE_FILTER_SYNC_IO_STDERR";
1214const RAW_WATCH_SCRIPT = "scripts/watch-node.mjs";
1315const TMUX_CWD_ENV_KEY = "OPENCLAW_GATEWAY_WATCH_CWD";
1416const TMUX_CWD_OPTION_KEY = "@openclaw.gateway_watch.cwd";
@@ -19,6 +21,8 @@ const TMUX_CHILD_ENV_KEYS = [
1921"OPENCLAW_HOME",
2022"OPENCLAW_PROFILE",
2123RUN_NODE_CPU_PROF_DIR_ENV,
24+RUN_NODE_FILTER_SYNC_IO_STDERR_ENV,
25+RUN_NODE_OUTPUT_LOG_ENV,
2226"OPENCLAW_SKIP_CHANNELS",
2327"OPENCLAW_STATE_DIR",
2428"OPENCLAW_TRACE_SYNC_IO",
@@ -50,6 +54,11 @@ const readArgValue = (args, flag) => {
5054return null;
5155};
525657+const joinArtifactPath = (dir, basename) => {
58+const normalizedDir = String(dir || DEFAULT_BENCHMARK_PROFILE_DIR).replace(/[\\/]+$/g, "");
59+return `${normalizedDir || "."}/${basename}`;
60+};
61+5362const resolveGatewayWatchBenchmarkArgs = ({ args = [], env = process.env } = {}) => {
5463const passthroughArgs = [];
5564let benchmarkDir = null;
@@ -98,13 +107,24 @@ const resolveGatewayWatchBenchmarkArgs = ({ args = [], env = process.env } = {})
98107nextEnv[RUN_NODE_CPU_PROF_DIR_ENV] =
99108benchmarkDir || nextEnv[RUN_NODE_CPU_PROF_DIR_ENV] || DEFAULT_BENCHMARK_PROFILE_DIR;
100109nextEnv.OPENCLAW_TRACE_SYNC_IO ??= "0";
110+if (nextEnv.OPENCLAW_TRACE_SYNC_IO === "1") {
111+nextEnv[RUN_NODE_OUTPUT_LOG_ENV] ??= joinArtifactPath(
112+nextEnv[RUN_NODE_CPU_PROF_DIR_ENV],
113+"gateway-watch-output.log",
114+);
115+nextEnv[RUN_NODE_FILTER_SYNC_IO_STDERR_ENV] ??= "1";
116+}
101117}
102118return {
103119args: benchmarkNoForceSeen
104120 ? passthroughArgs.filter((arg) => arg !== "--force")
105121 : passthroughArgs,
106122benchmarkNoForce: benchmarkNoForceSeen,
107123benchmarkProfileDir: nextEnv[RUN_NODE_CPU_PROF_DIR_ENV] || null,
124+benchmarkTraceOutputLog:
125+nextEnv[RUN_NODE_FILTER_SYNC_IO_STDERR_ENV] === "1"
126+ ? nextEnv[RUN_NODE_OUTPUT_LOG_ENV] || null
127+ : null,
108128env: nextEnv,
109129};
110130};
@@ -250,6 +270,12 @@ export const runGatewayWatchTmuxMain = (params = {}) => {
250270if (resolvedArgs.benchmarkProfileDir) {
251271log(deps.stderr, `gateway:watch benchmark CPU profiles: ${resolvedArgs.benchmarkProfileDir}`);
252272}
273+if (resolvedArgs.benchmarkTraceOutputLog) {
274+log(
275+deps.stderr,
276+`gateway:watch benchmark trace output: ${resolvedArgs.benchmarkTraceOutputLog}`,
277+);
278+}
253279if (resolvedArgs.benchmarkNoForce) {
254280log(deps.stderr, "gateway:watch benchmark running without --force");
255281}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。