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
+27 -1
View File
@@ -2,10 +2,13 @@ import { createSdkMcpServer, tool, type McpSdkServerConfigWithInstance } from "@
import { z } from "zod";
import { sendFile, type FeishuRuntime } from "./client.js";
import { resolveDeliverableFile } from "./fileDelivery.js";
import { readFeishuContext } from "./read.js";
export interface FileDeliveryToolOptions {
readonly rt: FeishuRuntime;
readonly chatId: string;
readonly projectId: string;
readonly runId: string;
readonly workspaceDir: string;
readonly onDelivered?: (path: string) => void;
}
@@ -18,7 +21,8 @@ export function createFileDeliveryMcpServer(options: FileDeliveryToolOptions): M
instructions:
"Use send_file when the user asks to receive, resend, download, or attach a file. " +
"Do not claim a file was sent unless send_file returns success. " +
"If a generated file path is uncertain, list or inspect the workspace first, then call send_file with the actual path.",
"If a generated file path is uncertain, list or inspect the workspace first, then call send_file with the actual path. " +
"Use feishu_read_context when the trigger context contains a reply, thread, or message anchor and more Feishu context is needed.",
tools: [
tool(
"send_file",
@@ -51,6 +55,28 @@ export function createFileDeliveryMcpServer(options: FileDeliveryToolOptions): M
},
{ alwaysLoad: true },
),
tool(
"feishu_read_context",
"Read Feishu context for the current project's bound chat. Use anchor ids from the trigger context; this tool never reads arbitrary chats.",
{
anchor: z.enum(["trigger_message", "status_card", "reply", "thread"]).describe("Which kind of Feishu anchor to read."),
id: z.string().describe("The message/thread/status anchor id to read."),
},
async (args) => {
const result = await readFeishuContext(
{ chat_id: options.chatId, anchor: args.anchor, id: args.id },
{
runId: options.runId,
projectId: options.projectId,
boundChatId: options.chatId,
workspaceDir: options.workspaceDir,
},
options.rt,
);
return { content: [{ type: "text", text: result }] };
},
{ alwaysLoad: true },
),
],
});
}