@larksuite/openclaw-lark 2025.7.15-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/bin/openclaw-lark.js +39 -0
- package/index.d.ts +36 -0
- package/index.js +188 -0
- package/openclaw.plugin.json +64 -0
- package/package.json +63 -0
- package/secret-contract-api.d.ts +15 -0
- package/secret-contract-api.js +78 -0
- package/skills/feishu-bitable/SKILL.md +248 -0
- package/skills/feishu-bitable/references/examples.md +813 -0
- package/skills/feishu-bitable/references/field-properties.md +763 -0
- package/skills/feishu-bitable/references/record-values.md +911 -0
- package/skills/feishu-calendar/SKILL.md +242 -0
- package/skills/feishu-channel-rules/SKILL.md +18 -0
- package/skills/feishu-channel-rules/references/markdown-syntax.md +138 -0
- package/skills/feishu-create-doc/SKILL.md +719 -0
- package/skills/feishu-fetch-doc/SKILL.md +93 -0
- package/skills/feishu-im-read/SKILL.md +163 -0
- package/skills/feishu-task/SKILL.md +340 -0
- package/skills/feishu-troubleshoot/SKILL.md +70 -0
- package/skills/feishu-update-doc/SKILL.md +285 -0
- package/src/card/builder.d.ts +152 -0
- package/src/card/builder.js +794 -0
- package/src/card/card-error.d.ts +91 -0
- package/src/card/card-error.js +206 -0
- package/src/card/cardkit.d.ts +90 -0
- package/src/card/cardkit.js +203 -0
- package/src/card/flush-controller.d.ts +45 -0
- package/src/card/flush-controller.js +138 -0
- package/src/card/image-resolver.d.ts +45 -0
- package/src/card/image-resolver.js +116 -0
- package/src/card/markdown-style.d.ts +16 -0
- package/src/card/markdown-style.js +106 -0
- package/src/card/reasoning-utils.d.ts +14 -0
- package/src/card/reasoning-utils.js +64 -0
- package/src/card/reply-dispatcher-types.d.ts +132 -0
- package/src/card/reply-dispatcher-types.js +61 -0
- package/src/card/reply-dispatcher.d.ts +15 -0
- package/src/card/reply-dispatcher.js +447 -0
- package/src/card/reply-mode.d.ts +41 -0
- package/src/card/reply-mode.js +70 -0
- package/src/card/streaming-card-controller.d.ts +118 -0
- package/src/card/streaming-card-controller.js +1045 -0
- package/src/card/tool-use-config.d.ts +26 -0
- package/src/card/tool-use-config.js +76 -0
- package/src/card/tool-use-display.d.ts +37 -0
- package/src/card/tool-use-display.js +476 -0
- package/src/card/tool-use-trace-store.d.ts +51 -0
- package/src/card/tool-use-trace-store.js +271 -0
- package/src/card/unavailable-guard.d.ts +35 -0
- package/src/card/unavailable-guard.js +87 -0
- package/src/channel/abort-detect.d.ts +47 -0
- package/src/channel/abort-detect.js +219 -0
- package/src/channel/chat-queue.d.ts +41 -0
- package/src/channel/chat-queue.js +68 -0
- package/src/channel/config-adapter.d.ts +23 -0
- package/src/channel/config-adapter.js +107 -0
- package/src/channel/directory.d.ts +57 -0
- package/src/channel/directory.js +197 -0
- package/src/channel/event-handlers.d.ts +17 -0
- package/src/channel/event-handlers.js +380 -0
- package/src/channel/interactive-dispatch.d.ts +59 -0
- package/src/channel/interactive-dispatch.js +195 -0
- package/src/channel/monitor.d.ts +17 -0
- package/src/channel/monitor.js +140 -0
- package/src/channel/onboarding-config.d.ts +18 -0
- package/src/channel/onboarding-config.js +96 -0
- package/src/channel/onboarding-migrate.d.ts +25 -0
- package/src/channel/onboarding-migrate.js +70 -0
- package/src/channel/onboarding.d.ts +12 -0
- package/src/channel/onboarding.js +300 -0
- package/src/channel/plugin.d.ts +13 -0
- package/src/channel/plugin.js +310 -0
- package/src/channel/probe.d.ts +14 -0
- package/src/channel/probe.js +24 -0
- package/src/channel/types.d.ts +37 -0
- package/src/channel/types.js +8 -0
- package/src/commands/auth.d.ts +21 -0
- package/src/commands/auth.js +165 -0
- package/src/commands/diagnose.d.ts +69 -0
- package/src/commands/diagnose.js +848 -0
- package/src/commands/doctor.d.ts +27 -0
- package/src/commands/doctor.js +588 -0
- package/src/commands/index.d.ts +25 -0
- package/src/commands/index.js +219 -0
- package/src/commands/locale.d.ts +7 -0
- package/src/commands/locale.js +8 -0
- package/src/core/accounts.d.ts +51 -0
- package/src/core/accounts.js +219 -0
- package/src/core/agent-config.d.ts +100 -0
- package/src/core/agent-config.js +148 -0
- package/src/core/api-error.d.ts +48 -0
- package/src/core/api-error.js +117 -0
- package/src/core/app-owner-fallback.d.ts +22 -0
- package/src/core/app-owner-fallback.js +39 -0
- package/src/core/app-scope-checker.d.ts +87 -0
- package/src/core/app-scope-checker.js +198 -0
- package/src/core/auth-errors.d.ts +144 -0
- package/src/core/auth-errors.js +160 -0
- package/src/core/card-action-operator.d.ts +33 -0
- package/src/core/card-action-operator.js +30 -0
- package/src/core/chat-info-cache.d.ts +67 -0
- package/src/core/chat-info-cache.js +165 -0
- package/src/core/comment-target.d.ts +65 -0
- package/src/core/comment-target.js +100 -0
- package/src/core/config-schema.d.ts +490 -0
- package/src/core/config-schema.js +223 -0
- package/src/core/device-flow.d.ts +77 -0
- package/src/core/device-flow.js +217 -0
- package/src/core/domains.d.ts +18 -0
- package/src/core/domains.js +34 -0
- package/src/core/feishu-fetch.d.ts +18 -0
- package/src/core/feishu-fetch.js +28 -0
- package/src/core/footer-config.d.ts +24 -0
- package/src/core/footer-config.js +51 -0
- package/src/core/lark-client.d.ts +125 -0
- package/src/core/lark-client.js +468 -0
- package/src/core/lark-logger.d.ts +23 -0
- package/src/core/lark-logger.js +160 -0
- package/src/core/lark-ticket.d.ts +29 -0
- package/src/core/lark-ticket.js +40 -0
- package/src/core/message-unavailable.d.ts +53 -0
- package/src/core/message-unavailable.js +142 -0
- package/src/core/owner-policy.d.ts +32 -0
- package/src/core/owner-policy.js +55 -0
- package/src/core/permission-url.d.ts +22 -0
- package/src/core/permission-url.js +76 -0
- package/src/core/raw-request.d.ts +27 -0
- package/src/core/raw-request.js +90 -0
- package/src/core/runtime-store.d.ts +13 -0
- package/src/core/runtime-store.js +29 -0
- package/src/core/scope-manager.d.ts +168 -0
- package/src/core/scope-manager.js +224 -0
- package/src/core/sdk-compat.d.ts +20 -0
- package/src/core/sdk-compat.js +28 -0
- package/src/core/security-check.d.ts +72 -0
- package/src/core/security-check.js +184 -0
- package/src/core/shutdown-hooks.d.ts +22 -0
- package/src/core/shutdown-hooks.js +61 -0
- package/src/core/synthetic-target.d.ts +33 -0
- package/src/core/synthetic-target.js +40 -0
- package/src/core/targets.d.ts +60 -0
- package/src/core/targets.js +173 -0
- package/src/core/token-store.d.ts +54 -0
- package/src/core/token-store.js +326 -0
- package/src/core/tool-client.d.ts +176 -0
- package/src/core/tool-client.js +426 -0
- package/src/core/tool-scopes.d.ts +156 -0
- package/src/core/tool-scopes.js +344 -0
- package/src/core/tools-config.d.ts +55 -0
- package/src/core/tools-config.js +143 -0
- package/src/core/types.d.ts +91 -0
- package/src/core/types.js +12 -0
- package/src/core/uat-client.d.ts +46 -0
- package/src/core/uat-client.js +192 -0
- package/src/core/version.d.ts +31 -0
- package/src/core/version.js +69 -0
- package/src/messaging/converters/audio.d.ts +8 -0
- package/src/messaging/converters/audio.js +24 -0
- package/src/messaging/converters/calendar.d.ts +13 -0
- package/src/messaging/converters/calendar.js +56 -0
- package/src/messaging/converters/content-converter-helpers.d.ts +30 -0
- package/src/messaging/converters/content-converter-helpers.js +82 -0
- package/src/messaging/converters/content-converter.d.ts +24 -0
- package/src/messaging/converters/content-converter.js +40 -0
- package/src/messaging/converters/file.d.ts +8 -0
- package/src/messaging/converters/file.js +24 -0
- package/src/messaging/converters/folder.d.ts +8 -0
- package/src/messaging/converters/folder.js +24 -0
- package/src/messaging/converters/hongbao.d.ts +8 -0
- package/src/messaging/converters/hongbao.js +20 -0
- package/src/messaging/converters/image.d.ts +8 -0
- package/src/messaging/converters/image.js +22 -0
- package/src/messaging/converters/index.d.ts +8 -0
- package/src/messaging/converters/index.js +53 -0
- package/src/messaging/converters/interactive/card-converter.d.ts +76 -0
- package/src/messaging/converters/interactive/card-converter.js +1177 -0
- package/src/messaging/converters/interactive/card-utils.d.ts +9 -0
- package/src/messaging/converters/interactive/card-utils.js +47 -0
- package/src/messaging/converters/interactive/index.d.ts +8 -0
- package/src/messaging/converters/interactive/index.js +25 -0
- package/src/messaging/converters/interactive/legacy.d.ts +11 -0
- package/src/messaging/converters/interactive/legacy.js +60 -0
- package/src/messaging/converters/interactive/types.d.ts +23 -0
- package/src/messaging/converters/interactive/types.js +27 -0
- package/src/messaging/converters/location.d.ts +8 -0
- package/src/messaging/converters/location.js +23 -0
- package/src/messaging/converters/merge-forward.d.ts +32 -0
- package/src/messaging/converters/merge-forward.js +235 -0
- package/src/messaging/converters/post.d.ts +11 -0
- package/src/messaging/converters/post.js +235 -0
- package/src/messaging/converters/share.d.ts +9 -0
- package/src/messaging/converters/share.js +28 -0
- package/src/messaging/converters/sticker.d.ts +8 -0
- package/src/messaging/converters/sticker.js +22 -0
- package/src/messaging/converters/system.d.ts +12 -0
- package/src/messaging/converters/system.js +36 -0
- package/src/messaging/converters/text.d.ts +8 -0
- package/src/messaging/converters/text.js +18 -0
- package/src/messaging/converters/todo.d.ts +8 -0
- package/src/messaging/converters/todo.js +45 -0
- package/src/messaging/converters/types.d.ts +114 -0
- package/src/messaging/converters/types.js +8 -0
- package/src/messaging/converters/unknown.d.ts +8 -0
- package/src/messaging/converters/unknown.js +20 -0
- package/src/messaging/converters/utils.d.ts +22 -0
- package/src/messaging/converters/utils.js +57 -0
- package/src/messaging/converters/video-chat.d.ts +8 -0
- package/src/messaging/converters/video-chat.js +31 -0
- package/src/messaging/converters/video.d.ts +8 -0
- package/src/messaging/converters/video.js +35 -0
- package/src/messaging/converters/vote.d.ts +8 -0
- package/src/messaging/converters/vote.js +28 -0
- package/src/messaging/inbound/bot-content.d.ts +84 -0
- package/src/messaging/inbound/bot-content.js +117 -0
- package/src/messaging/inbound/bot-loop-guard.d.ts +48 -0
- package/src/messaging/inbound/bot-loop-guard.js +89 -0
- package/src/messaging/inbound/comment-context.d.ts +82 -0
- package/src/messaging/inbound/comment-context.js +353 -0
- package/src/messaging/inbound/comment-handler.d.ts +30 -0
- package/src/messaging/inbound/comment-handler.js +269 -0
- package/src/messaging/inbound/dedup.d.ts +59 -0
- package/src/messaging/inbound/dedup.js +121 -0
- package/src/messaging/inbound/dispatch-builders.d.ts +104 -0
- package/src/messaging/inbound/dispatch-builders.js +241 -0
- package/src/messaging/inbound/dispatch-commands.d.ts +22 -0
- package/src/messaging/inbound/dispatch-commands.js +131 -0
- package/src/messaging/inbound/dispatch-context.d.ts +67 -0
- package/src/messaging/inbound/dispatch-context.js +153 -0
- package/src/messaging/inbound/dispatch.d.ts +50 -0
- package/src/messaging/inbound/dispatch.js +477 -0
- package/src/messaging/inbound/enrich.d.ts +102 -0
- package/src/messaging/inbound/enrich.js +236 -0
- package/src/messaging/inbound/gate-effects.d.ts +23 -0
- package/src/messaging/inbound/gate-effects.js +46 -0
- package/src/messaging/inbound/gate.d.ts +91 -0
- package/src/messaging/inbound/gate.js +342 -0
- package/src/messaging/inbound/handler-registry.d.ts +25 -0
- package/src/messaging/inbound/handler-registry.js +23 -0
- package/src/messaging/inbound/handler.d.ts +37 -0
- package/src/messaging/inbound/handler.js +286 -0
- package/src/messaging/inbound/media-resolver.d.ts +32 -0
- package/src/messaging/inbound/media-resolver.js +91 -0
- package/src/messaging/inbound/mention-registry.d.ts +59 -0
- package/src/messaging/inbound/mention-registry.js +115 -0
- package/src/messaging/inbound/mention.d.ts +48 -0
- package/src/messaging/inbound/mention.js +102 -0
- package/src/messaging/inbound/parse-io.d.ts +50 -0
- package/src/messaging/inbound/parse-io.js +86 -0
- package/src/messaging/inbound/parse.d.ts +28 -0
- package/src/messaging/inbound/parse.js +128 -0
- package/src/messaging/inbound/permission.d.ts +17 -0
- package/src/messaging/inbound/permission.js +44 -0
- package/src/messaging/inbound/policy.d.ts +95 -0
- package/src/messaging/inbound/policy.js +168 -0
- package/src/messaging/inbound/reaction-handler.d.ts +62 -0
- package/src/messaging/inbound/reaction-handler.js +259 -0
- package/src/messaging/inbound/sentinel-store.d.ts +37 -0
- package/src/messaging/inbound/sentinel-store.js +98 -0
- package/src/messaging/inbound/synthetic-message.d.ts +26 -0
- package/src/messaging/inbound/synthetic-message.js +59 -0
- package/src/messaging/inbound/user-name-cache-store.d.ts +62 -0
- package/src/messaging/inbound/user-name-cache-store.js +236 -0
- package/src/messaging/inbound/user-name-cache.d.ts +78 -0
- package/src/messaging/inbound/user-name-cache.js +306 -0
- package/src/messaging/inbound/vc-meeting-invited-handler.d.ts +20 -0
- package/src/messaging/inbound/vc-meeting-invited-handler.js +236 -0
- package/src/messaging/inbound/vc-sender.d.ts +41 -0
- package/src/messaging/inbound/vc-sender.js +53 -0
- package/src/messaging/outbound/actions.d.ts +16 -0
- package/src/messaging/outbound/actions.js +329 -0
- package/src/messaging/outbound/bot-peer-context.d.ts +42 -0
- package/src/messaging/outbound/bot-peer-context.js +40 -0
- package/src/messaging/outbound/chat-manage.d.ts +64 -0
- package/src/messaging/outbound/chat-manage.js +117 -0
- package/src/messaging/outbound/deliver.d.ts +186 -0
- package/src/messaging/outbound/deliver.js +410 -0
- package/src/messaging/outbound/fetch.d.ts +12 -0
- package/src/messaging/outbound/fetch.js +17 -0
- package/src/messaging/outbound/forward.d.ts +26 -0
- package/src/messaging/outbound/forward.js +51 -0
- package/src/messaging/outbound/media-url-utils.d.ts +29 -0
- package/src/messaging/outbound/media-url-utils.js +172 -0
- package/src/messaging/outbound/media.d.ts +260 -0
- package/src/messaging/outbound/media.js +865 -0
- package/src/messaging/outbound/normalize-mentions.d.ts +50 -0
- package/src/messaging/outbound/normalize-mentions.js +166 -0
- package/src/messaging/outbound/outbound-mention.d.ts +41 -0
- package/src/messaging/outbound/outbound-mention.js +112 -0
- package/src/messaging/outbound/outbound.d.ts +79 -0
- package/src/messaging/outbound/outbound.js +195 -0
- package/src/messaging/outbound/reactions.d.ts +124 -0
- package/src/messaging/outbound/reactions.js +384 -0
- package/src/messaging/outbound/send.d.ts +153 -0
- package/src/messaging/outbound/send.js +417 -0
- package/src/messaging/outbound/typing.d.ts +60 -0
- package/src/messaging/outbound/typing.js +139 -0
- package/src/messaging/shared/message-lookup.d.ts +54 -0
- package/src/messaging/shared/message-lookup.js +120 -0
- package/src/messaging/types.d.ts +316 -0
- package/src/messaging/types.js +11 -0
- package/src/tools/ask-user-question.d.ts +32 -0
- package/src/tools/ask-user-question.js +922 -0
- package/src/tools/auto-auth.d.ts +57 -0
- package/src/tools/auto-auth.js +904 -0
- package/src/tools/helpers.d.ts +264 -0
- package/src/tools/helpers.js +389 -0
- package/src/tools/mcp/doc/create.d.ts +12 -0
- package/src/tools/mcp/doc/create.js +47 -0
- package/src/tools/mcp/doc/fetch.d.ts +12 -0
- package/src/tools/mcp/doc/fetch.js +39 -0
- package/src/tools/mcp/doc/index.d.ts +12 -0
- package/src/tools/mcp/doc/index.js +50 -0
- package/src/tools/mcp/doc/update.d.ts +12 -0
- package/src/tools/mcp/doc/update.js +64 -0
- package/src/tools/mcp/shared.d.ts +59 -0
- package/src/tools/mcp/shared.js +239 -0
- package/src/tools/oapi/bitable/app-table-field.d.ts +16 -0
- package/src/tools/oapi/bitable/app-table-field.js +225 -0
- package/src/tools/oapi/bitable/app-table-record.d.ts +20 -0
- package/src/tools/oapi/bitable/app-table-record.js +439 -0
- package/src/tools/oapi/bitable/app-table-view.d.ts +16 -0
- package/src/tools/oapi/bitable/app-table-view.js +172 -0
- package/src/tools/oapi/bitable/app-table.d.ts +17 -0
- package/src/tools/oapi/bitable/app-table.js +195 -0
- package/src/tools/oapi/bitable/app.d.ts +18 -0
- package/src/tools/oapi/bitable/app.js +189 -0
- package/src/tools/oapi/bitable/index.d.ts +9 -0
- package/src/tools/oapi/bitable/index.js +17 -0
- package/src/tools/oapi/calendar/calendar.d.ts +15 -0
- package/src/tools/oapi/calendar/calendar.js +125 -0
- package/src/tools/oapi/calendar/event-attendee.d.ts +14 -0
- package/src/tools/oapi/calendar/event-attendee.js +161 -0
- package/src/tools/oapi/calendar/event.d.ts +16 -0
- package/src/tools/oapi/calendar/event.js +712 -0
- package/src/tools/oapi/calendar/freebusy.d.ts +13 -0
- package/src/tools/oapi/calendar/freebusy.js +114 -0
- package/src/tools/oapi/calendar/index.d.ts +8 -0
- package/src/tools/oapi/calendar/index.js +15 -0
- package/src/tools/oapi/chat/chat.d.ts +16 -0
- package/src/tools/oapi/chat/chat.js +127 -0
- package/src/tools/oapi/chat/index.d.ts +10 -0
- package/src/tools/oapi/chat/index.js +23 -0
- package/src/tools/oapi/chat/members.d.ts +11 -0
- package/src/tools/oapi/chat/members.js +84 -0
- package/src/tools/oapi/common/get-user.d.ts +12 -0
- package/src/tools/oapi/common/get-user.js +109 -0
- package/src/tools/oapi/common/index.d.ts +6 -0
- package/src/tools/oapi/common/index.js +11 -0
- package/src/tools/oapi/common/search-user.d.ts +11 -0
- package/src/tools/oapi/common/search-user.js +76 -0
- package/src/tools/oapi/drive/doc-comments.d.ts +15 -0
- package/src/tools/oapi/drive/doc-comments.js +351 -0
- package/src/tools/oapi/drive/doc-media.d.ts +19 -0
- package/src/tools/oapi/drive/doc-media.js +371 -0
- package/src/tools/oapi/drive/file.d.ts +19 -0
- package/src/tools/oapi/drive/file.js +519 -0
- package/src/tools/oapi/drive/index.d.ts +12 -0
- package/src/tools/oapi/drive/index.js +45 -0
- package/src/tools/oapi/helpers.d.ts +183 -0
- package/src/tools/oapi/helpers.js +385 -0
- package/src/tools/oapi/im/format-messages.d.ts +50 -0
- package/src/tools/oapi/im/format-messages.js +169 -0
- package/src/tools/oapi/im/index.d.ts +10 -0
- package/src/tools/oapi/im/index.js +25 -0
- package/src/tools/oapi/im/message-read.d.ts +13 -0
- package/src/tools/oapi/im/message-read.js +419 -0
- package/src/tools/oapi/im/message.d.ts +16 -0
- package/src/tools/oapi/im/message.js +152 -0
- package/src/tools/oapi/im/resource.d.ts +13 -0
- package/src/tools/oapi/im/resource.js +186 -0
- package/src/tools/oapi/im/time-utils.d.ts +46 -0
- package/src/tools/oapi/im/time-utils.js +212 -0
- package/src/tools/oapi/im/user-name-uat.d.ts +26 -0
- package/src/tools/oapi/im/user-name-uat.js +143 -0
- package/src/tools/oapi/index.d.ts +11 -0
- package/src/tools/oapi/index.js +64 -0
- package/src/tools/oapi/sdk-types.d.ts +96 -0
- package/src/tools/oapi/sdk-types.js +13 -0
- package/src/tools/oapi/search/doc-search.d.ts +13 -0
- package/src/tools/oapi/search/doc-search.js +194 -0
- package/src/tools/oapi/search/index.d.ts +12 -0
- package/src/tools/oapi/search/index.js +37 -0
- package/src/tools/oapi/sheets/index.d.ts +12 -0
- package/src/tools/oapi/sheets/index.js +35 -0
- package/src/tools/oapi/sheets/sheet.d.ts +16 -0
- package/src/tools/oapi/sheets/sheet.js +688 -0
- package/src/tools/oapi/task/attachment.d.ts +18 -0
- package/src/tools/oapi/task/attachment.js +107 -0
- package/src/tools/oapi/task/comment.d.ts +15 -0
- package/src/tools/oapi/task/comment.js +149 -0
- package/src/tools/oapi/task/index.d.ts +11 -0
- package/src/tools/oapi/task/index.js +21 -0
- package/src/tools/oapi/task/section.d.ts +17 -0
- package/src/tools/oapi/task/section.js +293 -0
- package/src/tools/oapi/task/subtask.d.ts +14 -0
- package/src/tools/oapi/task/subtask.js +171 -0
- package/src/tools/oapi/task/task.d.ts +19 -0
- package/src/tools/oapi/task/task.js +512 -0
- package/src/tools/oapi/task/task_agent.d.ts +14 -0
- package/src/tools/oapi/task/task_agent.js +108 -0
- package/src/tools/oapi/task/tasklist.d.ts +19 -0
- package/src/tools/oapi/task/tasklist.js +276 -0
- package/src/tools/oapi/wiki/index.d.ts +12 -0
- package/src/tools/oapi/wiki/index.js +42 -0
- package/src/tools/oapi/wiki/space-node.d.ts +17 -0
- package/src/tools/oapi/wiki/space-node.js +233 -0
- package/src/tools/oapi/wiki/space.d.ts +15 -0
- package/src/tools/oapi/wiki/space.js +133 -0
- package/src/tools/oauth-batch-auth.d.ts +11 -0
- package/src/tools/oauth-batch-auth.js +150 -0
- package/src/tools/oauth-cards.d.ts +39 -0
- package/src/tools/oauth-cards.js +324 -0
- package/src/tools/oauth.d.ts +47 -0
- package/src/tools/oauth.js +592 -0
- package/src/tools/onboarding-auth.d.ts +27 -0
- package/src/tools/onboarding-auth.js +133 -0
- package/src/tools/tat/im/index.d.ts +15 -0
- package/src/tools/tat/im/index.js +22 -0
- package/src/tools/tat/im/resource.d.ts +15 -0
- package/src/tools/tat/im/resource.js +192 -0
- package/tsdown.config.d.ts +2 -0
- package/tsdown.config.js +25 -0
- package/vitest.config.d.ts +2 -0
- package/vitest.config.js +12 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Policy gate for inbound Feishu messages.
|
|
7
|
+
*
|
|
8
|
+
* Determines whether a parsed message should be processed or rejected
|
|
9
|
+
* based on group/DM access policies, sender allowlists, and mention
|
|
10
|
+
* requirements.
|
|
11
|
+
*
|
|
12
|
+
* Group access follows the same two-layer model as Telegram:
|
|
13
|
+
*
|
|
14
|
+
* Layer 1 – Which GROUPS are allowed (SDK `resolveGroupPolicy`):
|
|
15
|
+
* - No `groups` configured + `groupPolicy: "open"` → any group passes
|
|
16
|
+
* - `groupPolicy: "allowlist"` or `groups` configured → acts as allowlist
|
|
17
|
+
* (explicit group IDs or `"*"` wildcard)
|
|
18
|
+
* - `groupPolicy: "disabled"` → all groups blocked
|
|
19
|
+
*
|
|
20
|
+
* Layer 2 – Which SENDERS are allowed within a group:
|
|
21
|
+
* - Per-group `groupPolicy` overrides global for sender filtering
|
|
22
|
+
* - `groupAllowFrom` (global) + per-group `allowFrom` are merged
|
|
23
|
+
* - `"open"` → any sender; `"allowlist"` → check merged list;
|
|
24
|
+
* `"disabled"` → block all senders
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.resolveRespondToMentionAll = resolveRespondToMentionAll;
|
|
28
|
+
exports.resolveAllowBots = resolveAllowBots;
|
|
29
|
+
exports.readFeishuAllowFromStore = readAllowFromStore;
|
|
30
|
+
exports.checkMessageGate = checkMessageGate;
|
|
31
|
+
const lark_client_1 = require("../../core/lark-client.js");
|
|
32
|
+
const policy_1 = require("./policy.js");
|
|
33
|
+
const mention_1 = require("./mention.js");
|
|
34
|
+
const gate_effects_1 = require("./gate-effects.js");
|
|
35
|
+
/**
|
|
36
|
+
* Resolve the effective `respondToMentionAll` setting.
|
|
37
|
+
*
|
|
38
|
+
* Precedence: per-group > default ("*") group > global account config > false.
|
|
39
|
+
*/
|
|
40
|
+
function resolveRespondToMentionAll(params) {
|
|
41
|
+
return (params.groupConfig?.respondToMentionAll ??
|
|
42
|
+
params.defaultConfig?.respondToMentionAll ??
|
|
43
|
+
params.accountFeishuCfg?.respondToMentionAll ??
|
|
44
|
+
false);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the effective allowBots setting.
|
|
48
|
+
*
|
|
49
|
+
* Precedence: per-group > default ("*") > account > 'mentions'.
|
|
50
|
+
*
|
|
51
|
+
* The `'mentions'` default lets bot-to-bot interaction work out of the box
|
|
52
|
+
* while still requiring an explicit @-mention in groups; DMs treat it as
|
|
53
|
+
* pass-through. Operators can opt into fully-open (`true`) or fully-closed
|
|
54
|
+
* (`false`) explicitly.
|
|
55
|
+
*/
|
|
56
|
+
function resolveAllowBots(params) {
|
|
57
|
+
return (params.groupConfig?.allowBots ??
|
|
58
|
+
params.defaultConfig?.allowBots ??
|
|
59
|
+
params.accountFeishuCfg?.allowBots ??
|
|
60
|
+
'mentions');
|
|
61
|
+
}
|
|
62
|
+
/** Prevent spamming the legacy groupAllowFrom migration warning. */
|
|
63
|
+
let legacyGroupAllowFromWarned = false;
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// Helpers
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
/**
|
|
68
|
+
* Read the pairing allowFrom store for the Feishu channel via the SDK runtime.
|
|
69
|
+
*/
|
|
70
|
+
async function readAllowFromStore(accountId) {
|
|
71
|
+
const core = lark_client_1.LarkClient.runtime;
|
|
72
|
+
return await core.channel.pairing.readAllowFromStore({
|
|
73
|
+
channel: 'feishu',
|
|
74
|
+
accountId,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Check whether an inbound message passes all access-control gates.
|
|
79
|
+
*
|
|
80
|
+
* The DM gate is async because it may read from the pairing store
|
|
81
|
+
* and send pairing request messages.
|
|
82
|
+
*/
|
|
83
|
+
async function checkMessageGate(params) {
|
|
84
|
+
const { ctx } = params;
|
|
85
|
+
if (ctx.senderIsBot) {
|
|
86
|
+
return checkBotSenderGate(params);
|
|
87
|
+
}
|
|
88
|
+
const isGroup = ctx.chatType === 'group';
|
|
89
|
+
if (isGroup) {
|
|
90
|
+
return checkGroupGate(params);
|
|
91
|
+
}
|
|
92
|
+
return checkDmGate(params);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Layer 1 group-level admission check, shared between human and bot sender paths.
|
|
96
|
+
*
|
|
97
|
+
* Computes:
|
|
98
|
+
* - `groupPolicy` access via SDK (`resolveGroupPolicy`)
|
|
99
|
+
* - Legacy chat-id-in-`groupAllowFrom` compat
|
|
100
|
+
* - Per-group `enabled === false` kill switch
|
|
101
|
+
*
|
|
102
|
+
* Returns `rejected` non-null when the caller should reject with that result;
|
|
103
|
+
* otherwise the resolved per-group config is returned for downstream use.
|
|
104
|
+
*
|
|
105
|
+
* Bot senders go through the same Layer 1 as humans — `allowBots` only governs
|
|
106
|
+
* sender-axis admission, not which groups the account responds in.
|
|
107
|
+
*/
|
|
108
|
+
function resolveFeishuGroupAccess(params) {
|
|
109
|
+
const { ctx, accountFeishuCfg, account, accountScopedCfg, log } = params;
|
|
110
|
+
const core = lark_client_1.LarkClient.runtime;
|
|
111
|
+
// Legacy compat: groupAllowFrom with chat_id entries.
|
|
112
|
+
const rawGroupAllowFrom = accountFeishuCfg?.groupAllowFrom ?? [];
|
|
113
|
+
const { legacyChatIds, senderAllowFrom: senderGroupAllowFrom } = (0, policy_1.splitLegacyGroupAllowFrom)(rawGroupAllowFrom);
|
|
114
|
+
if (legacyChatIds.length > 0 && !legacyGroupAllowFromWarned) {
|
|
115
|
+
legacyGroupAllowFromWarned = true;
|
|
116
|
+
log(`feishu[${account.accountId}]: ⚠️ groupAllowFrom contains chat_id entries ` +
|
|
117
|
+
`(${legacyChatIds.join(', ')}). groupAllowFrom is for SENDER filtering ` +
|
|
118
|
+
`(open_ids like ou_xxx). Please move chat_ids to "groups" config instead:\n` +
|
|
119
|
+
` channels.feishu.groups: {\n` +
|
|
120
|
+
legacyChatIds.map((id) => ` "${id}": {},`).join('\n') +
|
|
121
|
+
`\n }`);
|
|
122
|
+
}
|
|
123
|
+
const groupConfig = (0, policy_1.resolveFeishuGroupConfig)({ cfg: accountFeishuCfg, groupId: ctx.chatId });
|
|
124
|
+
const defaultConfig = accountFeishuCfg?.groups?.['*'];
|
|
125
|
+
// SDK group-level policy (groupPolicy disabled / allowlist / open).
|
|
126
|
+
const groupAccess = core.channel.groups.resolveGroupPolicy({
|
|
127
|
+
cfg: accountScopedCfg ?? {},
|
|
128
|
+
channel: 'feishu',
|
|
129
|
+
groupId: ctx.chatId,
|
|
130
|
+
accountId: account.accountId,
|
|
131
|
+
groupIdCaseInsensitive: true,
|
|
132
|
+
hasGroupAllowFrom: senderGroupAllowFrom.length > 0,
|
|
133
|
+
});
|
|
134
|
+
let legacyGroupAdmit = false;
|
|
135
|
+
if (!groupAccess.allowed) {
|
|
136
|
+
const chatIdLower = ctx.chatId.toLowerCase();
|
|
137
|
+
const legacyMatch = legacyChatIds.some((id) => String(id).toLowerCase() === chatIdLower);
|
|
138
|
+
if (!legacyMatch) {
|
|
139
|
+
log(`feishu[${account.accountId}]: group ${ctx.chatId} blocked by group-level policy`);
|
|
140
|
+
return {
|
|
141
|
+
rejected: { allowed: false, reason: 'group_not_allowed' },
|
|
142
|
+
legacyGroupAdmit: false,
|
|
143
|
+
senderGroupAllowFrom,
|
|
144
|
+
groupConfig,
|
|
145
|
+
defaultConfig,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
legacyGroupAdmit = true;
|
|
149
|
+
}
|
|
150
|
+
const enabled = groupConfig?.enabled ?? defaultConfig?.enabled;
|
|
151
|
+
if (enabled === false) {
|
|
152
|
+
log(`feishu[${account.accountId}]: group ${ctx.chatId} disabled by per-group config`);
|
|
153
|
+
return {
|
|
154
|
+
rejected: { allowed: false, reason: 'group_disabled' },
|
|
155
|
+
legacyGroupAdmit,
|
|
156
|
+
senderGroupAllowFrom,
|
|
157
|
+
groupConfig,
|
|
158
|
+
defaultConfig,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
return { rejected: null, legacyGroupAdmit, senderGroupAllowFrom, groupConfig, defaultConfig };
|
|
162
|
+
}
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
// Internal: bot sender gate
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
function checkBotSenderGate(params) {
|
|
167
|
+
const { ctx, accountFeishuCfg, account, log } = params;
|
|
168
|
+
const isGroup = ctx.chatType === 'group';
|
|
169
|
+
// 1. Layer 1 group access — bot senders are subject to the same group-level
|
|
170
|
+
// admission as humans. `allowBots` is a sender-axis filter, not a group-axis
|
|
171
|
+
// filter; an account configured to ignore a group must ignore bots there too.
|
|
172
|
+
let groupConfig;
|
|
173
|
+
let defaultConfig;
|
|
174
|
+
if (isGroup) {
|
|
175
|
+
const access = resolveFeishuGroupAccess(params);
|
|
176
|
+
if (access.rejected)
|
|
177
|
+
return access.rejected;
|
|
178
|
+
groupConfig = access.groupConfig;
|
|
179
|
+
defaultConfig = access.defaultConfig;
|
|
180
|
+
}
|
|
181
|
+
// 2. Resolve allowBots (per-group > default > account > 'mentions')
|
|
182
|
+
const allowBots = resolveAllowBots({ groupConfig, defaultConfig, accountFeishuCfg });
|
|
183
|
+
// 3. allowBots === false → drop
|
|
184
|
+
if (allowBots === false) {
|
|
185
|
+
log(`feishu[${account.accountId}]: drop bot sender ${ctx.senderId} in ${ctx.chatId} (allowBots=false)`);
|
|
186
|
+
return { allowed: false, reason: 'bot_sender_disabled' };
|
|
187
|
+
}
|
|
188
|
+
// 4. allowBots === 'mentions' + bot not mentioned → drop (group only;
|
|
189
|
+
// DMs have no @-mention concept, so mention-mode is a pass-through there).
|
|
190
|
+
if (isGroup && allowBots === 'mentions' && !(0, mention_1.mentionedBot)(ctx)) {
|
|
191
|
+
log(`feishu[${account.accountId}]: drop bot sender ${ctx.senderId} in ${ctx.chatId} (allowBots=mentions, not mentioned)`);
|
|
192
|
+
return { allowed: false, reason: 'bot_sender_not_mentioned' };
|
|
193
|
+
}
|
|
194
|
+
// 5. Group requireMention check — redundant with allowBots='mentions' but
|
|
195
|
+
// necessary for the explicit `allowBots=true + requireMention=true` combo.
|
|
196
|
+
//
|
|
197
|
+
// NOTE: this intentionally diverges from the human-sender path (checkGroupGate),
|
|
198
|
+
// which delegates to SDK's resolveRequireMention that defaults to true.
|
|
199
|
+
// For bot senders, `requireMention` must be explicitly set to true — the
|
|
200
|
+
// rationale being: if the operator opts into `allowBots=true`, they want
|
|
201
|
+
// bot traffic through by default. Holding bots to a true-default mention
|
|
202
|
+
// requirement would silently negate `allowBots=true` in most configs.
|
|
203
|
+
if (isGroup) {
|
|
204
|
+
const requireMention = groupConfig?.requireMention ??
|
|
205
|
+
defaultConfig?.requireMention ??
|
|
206
|
+
accountFeishuCfg?.requireMention;
|
|
207
|
+
if (requireMention === true && !(0, mention_1.mentionedBot)(ctx)) {
|
|
208
|
+
log(`feishu[${account.accountId}]: drop bot sender ${ctx.senderId} (no_mention)`);
|
|
209
|
+
// Intentionally NO historyEntry — bot messages never enter chat history.
|
|
210
|
+
return { allowed: false, reason: 'no_mention' };
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return { allowed: true };
|
|
214
|
+
}
|
|
215
|
+
// ---------------------------------------------------------------------------
|
|
216
|
+
// Internal: group gate
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
function checkGroupGate(params) {
|
|
219
|
+
const { ctx, accountFeishuCfg, account, accountScopedCfg, log } = params;
|
|
220
|
+
const core = lark_client_1.LarkClient.runtime;
|
|
221
|
+
// ---- Layer 1: Group-level admission (shared with bot path) ----
|
|
222
|
+
const access = resolveFeishuGroupAccess(params);
|
|
223
|
+
if (access.rejected)
|
|
224
|
+
return access.rejected;
|
|
225
|
+
const { legacyGroupAdmit, senderGroupAllowFrom, groupConfig, defaultConfig } = access;
|
|
226
|
+
// ---- Layer 2: Sender-level access ----
|
|
227
|
+
// Per-group groupPolicy overrides the global groupPolicy for sender filtering.
|
|
228
|
+
// senderGroupAllowFrom (global, oc_ entries excluded) + per-group allowFrom.
|
|
229
|
+
//
|
|
230
|
+
// Legacy compat: when a group was admitted via old-style chat_id in
|
|
231
|
+
// groupAllowFrom AND there is no explicit per-group sender config,
|
|
232
|
+
// skip sender filtering (old semantic = "group allowed, any sender").
|
|
233
|
+
const hasExplicitSenderConfig = senderGroupAllowFrom.length > 0 || (groupConfig?.allowFrom ?? []).length > 0 || groupConfig?.groupPolicy != null;
|
|
234
|
+
if (!(legacyGroupAdmit && !hasExplicitSenderConfig)) {
|
|
235
|
+
const { senderPolicy, senderAllowFrom } = (0, policy_1.resolveGroupSenderPolicyContext)({
|
|
236
|
+
groupConfig,
|
|
237
|
+
defaultConfig,
|
|
238
|
+
accountFeishuCfg,
|
|
239
|
+
senderGroupAllowFrom,
|
|
240
|
+
});
|
|
241
|
+
const senderAllowed = (0, policy_1.isFeishuGroupAllowed)({
|
|
242
|
+
groupPolicy: senderPolicy,
|
|
243
|
+
allowFrom: senderAllowFrom,
|
|
244
|
+
senderId: ctx.senderId,
|
|
245
|
+
senderName: ctx.senderName,
|
|
246
|
+
});
|
|
247
|
+
if (!senderAllowed) {
|
|
248
|
+
log(`feishu[${account.accountId}]: sender ${ctx.senderId} not allowed in group ${ctx.chatId}`);
|
|
249
|
+
return { allowed: false, reason: 'sender_not_allowed' };
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// ---- Mention requirement (SDK) ----
|
|
253
|
+
// SDK precedence: per-group > default ("*") > requireMentionOverride > true
|
|
254
|
+
const requireMention = core.channel.groups.resolveRequireMention({
|
|
255
|
+
cfg: accountScopedCfg ?? {},
|
|
256
|
+
channel: 'feishu',
|
|
257
|
+
groupId: ctx.chatId,
|
|
258
|
+
accountId: account.accountId,
|
|
259
|
+
groupIdCaseInsensitive: true,
|
|
260
|
+
requireMentionOverride: accountFeishuCfg?.requireMention,
|
|
261
|
+
});
|
|
262
|
+
if (requireMention && !(0, mention_1.mentionedBot)(ctx)) {
|
|
263
|
+
// Check if @all mention should bypass the mention requirement
|
|
264
|
+
if (ctx.mentionAll) {
|
|
265
|
+
const respondToAll = resolveRespondToMentionAll({
|
|
266
|
+
groupConfig,
|
|
267
|
+
defaultConfig,
|
|
268
|
+
accountFeishuCfg,
|
|
269
|
+
});
|
|
270
|
+
if (respondToAll) {
|
|
271
|
+
log(`feishu[${account.accountId}]: @all mention detected in group ${ctx.chatId}, allowing due to respondToMentionAll`);
|
|
272
|
+
return { allowed: true };
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
log(`feishu[${account.accountId}]: message in group ${ctx.chatId} did not mention bot, recording to history`);
|
|
276
|
+
return {
|
|
277
|
+
allowed: false,
|
|
278
|
+
reason: 'no_mention',
|
|
279
|
+
historyEntry: {
|
|
280
|
+
sender: ctx.senderId,
|
|
281
|
+
body: `${ctx.senderName ?? ctx.senderId}: ${ctx.content}`,
|
|
282
|
+
timestamp: ctx.createTime ?? Date.now(),
|
|
283
|
+
messageId: ctx.messageId,
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
return { allowed: true };
|
|
288
|
+
}
|
|
289
|
+
// ---------------------------------------------------------------------------
|
|
290
|
+
// Internal: DM gate
|
|
291
|
+
// ---------------------------------------------------------------------------
|
|
292
|
+
async function checkDmGate(params) {
|
|
293
|
+
const { ctx, accountFeishuCfg, account, accountScopedCfg, log } = params;
|
|
294
|
+
const dmPolicy = accountFeishuCfg?.dmPolicy ?? 'pairing';
|
|
295
|
+
const configAllowFrom = accountFeishuCfg?.allowFrom ?? [];
|
|
296
|
+
if (dmPolicy === 'disabled') {
|
|
297
|
+
log(`feishu[${account.accountId}]: DM disabled by policy, rejecting sender ${ctx.senderId}`);
|
|
298
|
+
return { allowed: false, reason: 'dm_disabled' };
|
|
299
|
+
}
|
|
300
|
+
if (dmPolicy === 'open') {
|
|
301
|
+
return { allowed: true };
|
|
302
|
+
}
|
|
303
|
+
if (dmPolicy === 'allowlist') {
|
|
304
|
+
const storeAllowFrom = await readAllowFromStore(account.accountId).catch(() => []);
|
|
305
|
+
const combinedAllowFrom = [...configAllowFrom, ...storeAllowFrom];
|
|
306
|
+
const match = (0, policy_1.resolveFeishuAllowlistMatch)({
|
|
307
|
+
allowFrom: combinedAllowFrom,
|
|
308
|
+
senderId: ctx.senderId,
|
|
309
|
+
senderName: ctx.senderName,
|
|
310
|
+
});
|
|
311
|
+
if (!match.allowed) {
|
|
312
|
+
log(`feishu[${account.accountId}]: sender ${ctx.senderId} not in DM allowlist`);
|
|
313
|
+
return { allowed: false, reason: 'dm_not_allowed' };
|
|
314
|
+
}
|
|
315
|
+
return { allowed: true };
|
|
316
|
+
}
|
|
317
|
+
// dmPolicy === "pairing"
|
|
318
|
+
const storeAllowFrom = await readAllowFromStore(account.accountId).catch(() => []);
|
|
319
|
+
const combinedAllowFrom = [...configAllowFrom, ...storeAllowFrom];
|
|
320
|
+
const match = (0, policy_1.resolveFeishuAllowlistMatch)({
|
|
321
|
+
allowFrom: combinedAllowFrom,
|
|
322
|
+
senderId: ctx.senderId,
|
|
323
|
+
senderName: ctx.senderName,
|
|
324
|
+
});
|
|
325
|
+
if (match.allowed) {
|
|
326
|
+
return { allowed: true };
|
|
327
|
+
}
|
|
328
|
+
// Sender not yet paired — create a pairing request and notify them
|
|
329
|
+
log(`feishu[${account.accountId}]: sender ${ctx.senderId} not paired, creating pairing request`);
|
|
330
|
+
try {
|
|
331
|
+
await (0, gate_effects_1.sendPairingReply)({
|
|
332
|
+
senderId: ctx.senderId,
|
|
333
|
+
chatId: ctx.chatId,
|
|
334
|
+
accountId: account.accountId,
|
|
335
|
+
accountScopedCfg,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
catch (err) {
|
|
339
|
+
log(`feishu[${account.accountId}]: failed to create pairing request for ${ctx.senderId}: ${String(err)}`);
|
|
340
|
+
}
|
|
341
|
+
return { allowed: false, reason: 'pairing_pending' };
|
|
342
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Shared registry for the inbound message handler.
|
|
6
|
+
*
|
|
7
|
+
* Synthetic message helpers depend on this registry instead of importing
|
|
8
|
+
* `handler.ts` directly, which keeps the static import graph acyclic.
|
|
9
|
+
*/
|
|
10
|
+
import type { ClawdbotConfig, RuntimeEnv } from 'openclaw/plugin-sdk';
|
|
11
|
+
import type { FeishuMessageEvent } from '../types';
|
|
12
|
+
export interface InboundHandlerParams {
|
|
13
|
+
cfg: ClawdbotConfig;
|
|
14
|
+
event: FeishuMessageEvent;
|
|
15
|
+
botOpenId?: string;
|
|
16
|
+
runtime?: RuntimeEnv;
|
|
17
|
+
accountId?: string;
|
|
18
|
+
replyToMessageId?: string;
|
|
19
|
+
forceMention?: boolean;
|
|
20
|
+
skipTyping?: boolean;
|
|
21
|
+
}
|
|
22
|
+
type InboundHandler = (params: InboundHandlerParams) => Promise<void>;
|
|
23
|
+
export declare function injectInboundHandler(handler: InboundHandler): void;
|
|
24
|
+
export declare function getInboundHandler(): InboundHandler;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Shared registry for the inbound message handler.
|
|
7
|
+
*
|
|
8
|
+
* Synthetic message helpers depend on this registry instead of importing
|
|
9
|
+
* `handler.ts` directly, which keeps the static import graph acyclic.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.injectInboundHandler = injectInboundHandler;
|
|
13
|
+
exports.getInboundHandler = getInboundHandler;
|
|
14
|
+
let inboundHandler = null;
|
|
15
|
+
function injectInboundHandler(handler) {
|
|
16
|
+
inboundHandler = handler;
|
|
17
|
+
}
|
|
18
|
+
function getInboundHandler() {
|
|
19
|
+
if (!inboundHandler) {
|
|
20
|
+
throw new Error('Feishu inbound handler has not been initialised.');
|
|
21
|
+
}
|
|
22
|
+
return inboundHandler;
|
|
23
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Inbound message handling pipeline for the Lark/Feishu channel plugin.
|
|
6
|
+
*
|
|
7
|
+
* Orchestrates a nine-stage pipeline:
|
|
8
|
+
* 1. Account resolution
|
|
9
|
+
* 2. Event parsing → parse.ts (merge_forward expanded in-place)
|
|
10
|
+
* 3. Empty-message guard → early return for text-less, media-less messages
|
|
11
|
+
* 4. Sender enrichment → enrich.ts (lightweight, before gate)
|
|
12
|
+
* 5. Policy gate → gate.ts
|
|
13
|
+
* 6. User name prefetch → enrich.ts (batch cache warm-up)
|
|
14
|
+
* 7. Content resolution → enrich.ts (media / quote, parallel)
|
|
15
|
+
* 8. Command authorization → plugin-sdk/command-auth
|
|
16
|
+
* 9. Agent dispatch → dispatch.ts
|
|
17
|
+
*/
|
|
18
|
+
import type { ClawdbotConfig, RuntimeEnv } from 'openclaw/plugin-sdk';
|
|
19
|
+
import type { HistoryEntry } from 'openclaw/plugin-sdk/reply-history';
|
|
20
|
+
import type { FeishuMessageEvent } from '../types';
|
|
21
|
+
export declare function handleFeishuMessage(params: {
|
|
22
|
+
cfg: ClawdbotConfig;
|
|
23
|
+
event: FeishuMessageEvent;
|
|
24
|
+
botOpenId?: string;
|
|
25
|
+
runtime?: RuntimeEnv;
|
|
26
|
+
chatHistories?: Map<string, HistoryEntry[]>;
|
|
27
|
+
accountId?: string;
|
|
28
|
+
/** Override the message ID used for reply threading (typing indicators,
|
|
29
|
+
* card replies, etc.). Useful for synthetic messages whose message_id
|
|
30
|
+
* is not a real Feishu message ID. */
|
|
31
|
+
replyToMessageId?: string;
|
|
32
|
+
/** When true, skip the policy gate (mention requirement, allowlist).
|
|
33
|
+
* Used for synthetic messages that are not real user messages. */
|
|
34
|
+
forceMention?: boolean;
|
|
35
|
+
/** When true, skip the typing indicator for this dispatch (e.g. reactions). */
|
|
36
|
+
skipTyping?: boolean;
|
|
37
|
+
}): Promise<void>;
|