
























@@ -1,4 +1,5 @@
11import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";
2+import type { ClawdbotConfig } from "./bot-runtime-api.js";
23import { resolveFeishuReasoningPreviewEnabled } from "./reasoning-preview.js";
3445const { loadSessionStoreMock } = vi.hoisted(() => ({
@@ -20,6 +21,8 @@ afterAll(() => {
2021});
21222223describe("resolveFeishuReasoningPreviewEnabled", () => {
24+const emptyCfg: ClawdbotConfig = {};
25+2326beforeEach(() => {
2427vi.clearAllMocks();
2528});
@@ -32,12 +35,16 @@ describe("resolveFeishuReasoningPreviewEnabled", () => {
32353336expect(
3437resolveFeishuReasoningPreviewEnabled({
38+cfg: emptyCfg,
39+agentId: "main",
3540storePath: "/tmp/feishu-sessions.json",
3641sessionKey: "agent:main:feishu:dm:ou_sender_1",
3742}),
3843).toBe(true);
3944expect(
4045resolveFeishuReasoningPreviewEnabled({
46+cfg: emptyCfg,
47+agentId: "main",
4148storePath: "/tmp/feishu-sessions.json",
4249sessionKey: "agent:main:feishu:dm:ou_sender_2",
4350}),
@@ -51,13 +58,55 @@ describe("resolveFeishuReasoningPreviewEnabled", () => {
51585259expect(
5360resolveFeishuReasoningPreviewEnabled({
61+cfg: emptyCfg,
62+agentId: "main",
63+storePath: "/tmp/feishu-sessions.json",
64+sessionKey: "agent:main:feishu:dm:ou_sender_1",
65+}),
66+).toBe(false);
67+expect(
68+resolveFeishuReasoningPreviewEnabled({
69+cfg: emptyCfg,
70+agentId: "main",
71+storePath: "/tmp/feishu-sessions.json",
72+}),
73+).toBe(false);
74+});
75+76+it("falls back to configured stream defaults", () => {
77+loadSessionStoreMock.mockReturnValue({
78+"agent:main:feishu:dm:ou_sender_1": {},
79+"agent:main:feishu:dm:ou_sender_2": { reasoningLevel: "off" },
80+});
81+82+const cfg: ClawdbotConfig = {
83+agents: {
84+defaults: { reasoningDefault: "stream" },
85+list: [{ id: "Ops", reasoningDefault: "off" }],
86+},
87+};
88+89+expect(
90+resolveFeishuReasoningPreviewEnabled({
91+ cfg,
92+agentId: "main",
5493storePath: "/tmp/feishu-sessions.json",
5594sessionKey: "agent:main:feishu:dm:ou_sender_1",
5695}),
96+).toBe(true);
97+expect(
98+resolveFeishuReasoningPreviewEnabled({
99+ cfg,
100+agentId: "ops",
101+storePath: "/tmp/feishu-sessions.json",
102+}),
57103).toBe(false);
58104expect(
59105resolveFeishuReasoningPreviewEnabled({
106+ cfg,
107+agentId: "main",
60108storePath: "/tmp/feishu-sessions.json",
109+sessionKey: "agent:main:feishu:dm:ou_sender_2",
61110}),
62111).toBe(false);
63112});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。