fix(hub): 保留飞书回复上下文

This commit is contained in:
2026-07-08 16:03:52 +08:00
parent a025d23af8
commit a00e4f9871
7 changed files with 311 additions and 10 deletions
+49
View File
@@ -0,0 +1,49 @@
import { describe, expect, it } from "vitest";
import { readFeishuContext } from "../../src/feishu/read.js";
import type { FeishuRuntime } from "../../src/feishu/client.js";
describe("readFeishuContext", () => {
it("compacts Feishu message.get replies with parent_id, thread_id, and body.content", async () => {
const rt = {
client: {
im: {
v1: {
message: {
get: async () => ({
data: {
items: [
{
message_id: "m-child",
root_id: "m-root",
parent_id: "m-parent",
thread_id: "thread-1",
msg_type: "text",
body: { content: JSON.stringify({ text: "parent text" }) },
},
],
},
}),
list: async () => ({ data: { items: [] } }),
},
},
},
},
logger: { warn() {}, info() {}, error() {}, debug() {} },
} as unknown as FeishuRuntime;
const raw = await readFeishuContext(
{ chat_id: "chat-1", anchor: "reply", id: "m-child" },
{ runId: "run-1", projectId: "proj-1", boundChatId: "chat-1", workspaceDir: "/tmp/proj-1" },
rt,
);
expect(JSON.parse(raw)).toMatchObject({
message_id: "m-child",
content: JSON.stringify({ text: "parent text" }),
parent_id: "m-parent",
parent_message_id: "m-parent",
root_id: "m-root",
thread_id: "thread-1",
});
});
});