

















@@ -6,9 +6,9 @@
66import fs from "node:fs";
77import os from "node:os";
88import path from "node:path";
9-import { createSessionStatusTool } from "../../src/agents/tools/session-status-tool.ts";
1091110const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-session-status-proof-"));
11+const configPath = path.join(tmpRoot, "openclaw.json");
1212const storePath = path.join(tmpRoot, "sessions.json");
1313const store = {
1414"agent:main:telegram:default:direct:1234": {
@@ -24,13 +24,32 @@ const store = {
2424thinkingLevel: "high",
2525},
2626};
27+fs.writeFileSync(configPath, "{}\n");
2728fs.writeFileSync(storePath, `${JSON.stringify(store, null, 2)}\n`);
29+process.env.OPENCLAW_CONFIG_PATH = configPath;
30+process.env.OPENCLAW_DISABLE_BUNDLED_PLUGINS = "1";
31+32+const originalStderrWrite = process.stderr.write.bind(process.stderr);
33+process.stderr.write = (chunk, encoding, callback) => {
34+const text = String(chunk);
35+if (text.includes("gateway connect failed:")) {
36+if (typeof encoding === "function") {
37+encoding();
38+} else if (typeof callback === "function") {
39+callback();
40+}
41+return true;
42+}
43+return originalStderrWrite(chunk, encoding, callback);
44+};
45+46+const { createSessionStatusTool } = await import("../../src/agents/tools/session-status-tool.ts");
28472948const config = {
3049session: { mainKey: "main", scope: "per-sender", store: storePath },
3150agents: {
3251defaults: {
33-model: { primary: "openai/gpt-5.4" },
52+model: { primary: "proof/gpt-5.4" },
3453models: {},
3554},
3655},
@@ -39,22 +58,37 @@ const config = {
3958},
4059};
416042-const tool = createSessionStatusTool({
43-agentSessionKey: "agent:main:telegram:default:direct:1234",
44-runSessionKey: "agent:main:main",
45- config,
46-});
47-48-const result = await tool.execute("live-proof-implicit-run-session", {});
49-const text = typeof result === "string" ? result : JSON.stringify(result);
50-const thinkingMatch = text.match(/think(?:ing)?[:\s]+(\w+)/i);
51-52-console.log(
53-"implicit session_status resolved thinkingLevel from store =",
54-store["agent:main:main"].thinkingLevel,
55-);
56-console.log("status text mentions thinking:", thinkingMatch?.[1] ?? "(see full status below)");
57-console.log("--- status excerpt ---");
58-console.log(text.split("\n").slice(0, 12).join("\n"));
59-60-fs.rmSync(tmpRoot, { recursive: true, force: true });
61+try {
62+const tool = createSessionStatusTool({
63+agentSessionKey: "agent:main:telegram:default:direct:1234",
64+runSessionKey: "agent:main:main",
65+ config,
66+});
67+68+const result = await tool.execute("live-proof-implicit-run-session", {});
69+const text =
70+typeof result === "string"
71+ ? result
72+ : (result.content.find((item) => item.type === "text")?.text ?? result.details.statusText);
73+const thinkingMatch = text.match(/\bThink:\s+(\w+)/i);
74+const sessionKey = typeof result === "string" ? undefined : result.details.sessionKey;
75+76+if (sessionKey !== "agent:main:main") {
77+throw new Error(`expected details.sessionKey agent:main:main, got ${String(sessionKey)}`);
78+}
79+if (thinkingMatch?.[1] !== "high") {
80+throw new Error(`expected status text to mention Think: high, got ${thinkingMatch?.[1]}`);
81+}
82+83+console.log(
84+"implicit session_status resolved thinkingLevel from store =",
85+store["agent:main:main"].thinkingLevel,
86+);
87+console.log("status text mentions thinking:", thinkingMatch[1]);
88+console.log("details.sessionKey =", sessionKey);
89+console.log("--- status excerpt ---");
90+console.log(text.split("\n").slice(0, 8).join("\n"));
91+} finally {
92+process.stderr.write = originalStderrWrite;
93+fs.rmSync(tmpRoot, { recursive: true, force: true });
94+}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。