From 58c100f66f0a86d32fdedc3f8fe176ac6a712aad Mon Sep 17 00:00:00 2001 From: root Date: Thu, 26 Feb 2026 08:52:41 +0000 Subject: [PATCH] fix(feishu): remove hook registration, fix docx getClient call --- extensions/feishu/index.ts | 7 ------ extensions/feishu/src/docx.ts | 2 +- extensions/feishu/src/tool-context.ts | 34 --------------------------- 3 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 extensions/feishu/src/tool-context.ts diff --git a/extensions/feishu/index.ts b/extensions/feishu/index.ts index e3ce8f21ea2..46733295561 100644 --- a/extensions/feishu/index.ts +++ b/extensions/feishu/index.ts @@ -6,7 +6,6 @@ import { registerFeishuDocTools } from "./src/docx.js"; import { registerFeishuDriveTools } from "./src/drive.js"; import { registerFeishuPermTools } from "./src/perm.js"; import { setFeishuRuntime } from "./src/runtime.js"; -import { resolveFeishuAccountForToolContext } from "./src/tool-context.js"; import { registerFeishuWikiTools } from "./src/wiki.js"; export { monitorFeishuProvider } from "./src/monitor.js"; @@ -54,12 +53,6 @@ const plugin = { setFeishuRuntime(api.runtime); api.registerChannel({ plugin: feishuPlugin }); - // Ensure Feishu tool registration uses the calling agent's account / outbound identity. - api.registerHook(["before_tool_call"], resolveFeishuAccountForToolContext, { - name: "feishu:resolve-account", - description: "Resolve Feishu accountId for Feishu tools based on the calling agent", - }); - registerFeishuDocTools(api); registerFeishuWikiTools(api); registerFeishuDriveTools(api); diff --git a/extensions/feishu/src/docx.ts b/extensions/feishu/src/docx.ts index df9297704d3..ae96b753171 100644 --- a/extensions/feishu/src/docx.ts +++ b/extensions/feishu/src/docx.ts @@ -524,7 +524,7 @@ export function registerFeishuDocTools(api: OpenClawPluginApi) { parameters: Type.Object({}), async execute() { try { - const result = await listAppScopes(getClient({ action: "read", doc_token: "" } as any)); + const result = await listAppScopes(getClient({ action: "create", title: "" } as any)); return json(result); } catch (err) { return json({ error: err instanceof Error ? err.message : String(err) }); diff --git a/extensions/feishu/src/tool-context.ts b/extensions/feishu/src/tool-context.ts deleted file mode 100644 index f0ae3b4fbbf..00000000000 --- a/extensions/feishu/src/tool-context.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id"; - -/** - * If the calling agent has an account id, copy it into tool params as accountId - * (unless the caller already provided one). - * - * This allows Feishu tools that are registered at startup (and therefore can't - * capture a per-agent client) to select the right Feishu account at execution - * time. - */ -export const resolveFeishuAccountForToolContext = async (ctx: { - toolName: string; - params: Record; - agentId?: string; - sessionKey?: string; -}) => { - const toolName = ctx.toolName; - if (typeof toolName !== "string" || !toolName.startsWith("feishu_")) { - return { blocked: false, params: ctx.params }; - } - - // If caller already specified an accountId, keep it. - const existing = (ctx.params as Record | undefined)?.accountId; - if (typeof existing === "string" && existing.trim()) { - return { blocked: false, params: ctx.params }; - } - - // NOTE: Plugin hook context does not currently expose agentAccountId. - // We still keep a safe fallback: inject default accountId unless caller already provided one. - return { - blocked: false, - params: { ...(ctx.params ?? {}), accountId: DEFAULT_ACCOUNT_ID }, - }; -};