diff --git a/extensions/feishu/src/bot.ts b/extensions/feishu/src/bot.ts index 7f990deb5a4..d9029d7de57 100644 --- a/extensions/feishu/src/bot.ts +++ b/extensions/feishu/src/bot.ts @@ -54,6 +54,8 @@ import { resolveFeishuReasoningPreviewEnabled } from "./reasoning-preview.js"; import { createFeishuReplyDispatcher } from "./reply-dispatcher.js"; import { getFeishuRuntime } from "./runtime.js"; import { getMessageFeishu, listFeishuThreadMessages, sendMessageFeishu } from "./send.js"; +export type { FeishuBotAddedEvent, FeishuMessageEvent } from "./event-types.js"; +import type { FeishuMessageEvent } from "./event-types.js"; import type { FeishuMessageContext, FeishuMessageInfo } from "./types.js"; import type { DynamicAgentCreationConfig } from "./types.js"; @@ -63,49 +65,6 @@ export { toMessageResourceType } from "./bot-content.js"; // Key: appId or "default", Value: timestamp of last notification const permissionErrorNotifiedAt = new Map(); const PERMISSION_ERROR_COOLDOWN_MS = 5 * 60 * 1000; // 5 minutes -export type FeishuMessageEvent = { - sender: { - sender_id: { - open_id?: string; - user_id?: string; - union_id?: string; - }; - sender_type?: string; - tenant_key?: string; - }; - message: { - message_id: string; - root_id?: string; - parent_id?: string; - thread_id?: string; - chat_id: string; - chat_type: "p2p" | "group" | "private"; - message_type: string; - content: string; - create_time?: string; - mentions?: Array<{ - key: string; - id: { - open_id?: string; - user_id?: string; - union_id?: string; - }; - name: string; - tenant_key?: string; - }>; - }; -}; - -export type FeishuBotAddedEvent = { - chat_id: string; - operator_id: { - open_id?: string; - user_id?: string; - union_id?: string; - }; - external: boolean; - operator_tenant_key?: string; -}; // --- Broadcast support --- // Resolve broadcast agent list for a given peer (group) ID. diff --git a/extensions/feishu/src/event-types.ts b/extensions/feishu/src/event-types.ts new file mode 100644 index 00000000000..37af2f7d601 --- /dev/null +++ b/extensions/feishu/src/event-types.ts @@ -0,0 +1,43 @@ +export type FeishuMessageEvent = { + sender: { + sender_id: { + open_id?: string; + user_id?: string; + union_id?: string; + }; + sender_type?: string; + tenant_key?: string; + }; + message: { + message_id: string; + root_id?: string; + parent_id?: string; + thread_id?: string; + chat_id: string; + chat_type: "p2p" | "group" | "private"; + message_type: string; + content: string; + create_time?: string; + mentions?: Array<{ + key: string; + id: { + open_id?: string; + user_id?: string; + union_id?: string; + }; + name: string; + tenant_key?: string; + }>; + }; +}; + +export type FeishuBotAddedEvent = { + chat_id: string; + operator_id: { + open_id?: string; + user_id?: string; + union_id?: string; + }; + external: boolean; + operator_tenant_key?: string; +}; diff --git a/extensions/feishu/src/mention-target.types.ts b/extensions/feishu/src/mention-target.types.ts new file mode 100644 index 00000000000..b87f8b09938 --- /dev/null +++ b/extensions/feishu/src/mention-target.types.ts @@ -0,0 +1,5 @@ +export type MentionTarget = { + openId: string; + name: string; + key: string; // Placeholder in original message, e.g. @_user_1 +}; diff --git a/extensions/feishu/src/mention.ts b/extensions/feishu/src/mention.ts index 9c0fd96e35f..f604d10a97d 100644 --- a/extensions/feishu/src/mention.ts +++ b/extensions/feishu/src/mention.ts @@ -1,4 +1,6 @@ -import type { FeishuMessageEvent } from "./bot.js"; +import type { FeishuMessageEvent } from "./event-types.js"; +export type { MentionTarget } from "./mention-target.types.js"; +import type { MentionTarget } from "./mention-target.types.js"; /** * Escape regex metacharacters so user-controlled mention fields are treated literally. @@ -7,15 +9,6 @@ export function escapeRegExp(input: string): string { return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } -/** - * Mention target user info - */ -export type MentionTarget = { - openId: string; - name: string; - key: string; // Placeholder in original message, e.g. @_user_1 -}; - /** * Extract mention targets from message event (excluding the bot itself) */ diff --git a/extensions/feishu/src/reply-dispatcher.ts b/extensions/feishu/src/reply-dispatcher.ts index 3c07e61404e..fc2e18eb07a 100644 --- a/extensions/feishu/src/reply-dispatcher.ts +++ b/extensions/feishu/src/reply-dispatcher.ts @@ -8,7 +8,7 @@ import { import { resolveFeishuRuntimeAccount } from "./accounts.js"; import { createFeishuClient } from "./client.js"; import { sendMediaFeishu } from "./media.js"; -import type { MentionTarget } from "./mention.js"; +import type { MentionTarget } from "./mention-target.types.js"; import { buildMentionedCardContent } from "./mention.js"; import { createReplyPrefixContext, diff --git a/extensions/feishu/src/send.ts b/extensions/feishu/src/send.ts index 3651db4ae19..9820f34d17b 100644 --- a/extensions/feishu/src/send.ts +++ b/extensions/feishu/src/send.ts @@ -7,7 +7,7 @@ import { import type { ClawdbotConfig } from "../runtime-api.js"; import { resolveFeishuRuntimeAccount } from "./accounts.js"; import { createFeishuClient } from "./client.js"; -import type { MentionTarget } from "./mention.js"; +import type { MentionTarget } from "./mention-target.types.js"; import { buildMentionedCardContent, buildMentionedMessage } from "./mention.js"; import { parsePostContent } from "./post.js"; import { assertFeishuMessageApiSuccess, toFeishuSendResult } from "./send-result.js"; diff --git a/extensions/feishu/src/types.ts b/extensions/feishu/src/types.ts index 4f365c3ae00..d24214516d1 100644 --- a/extensions/feishu/src/types.ts +++ b/extensions/feishu/src/types.ts @@ -1,11 +1,11 @@ -import type { BaseProbeResult } from "../runtime-api.js"; +import type { BaseProbeResult } from "openclaw/plugin-sdk/core"; import type { FeishuConfigSchema, FeishuGroupSchema, FeishuAccountConfigSchema, z, } from "./config-schema.js"; -import type { MentionTarget } from "./mention.js"; +import type { MentionTarget } from "./mention-target.types.js"; export type FeishuConfig = z.infer; export type FeishuGroupConfig = z.infer;