@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,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* @mention utilities for the Lark/Feishu channel plugin.
|
|
7
|
+
*
|
|
8
|
+
* All logic is based on `MentionInfo[]` from `MessageContext.mentions`.
|
|
9
|
+
* Provides:
|
|
10
|
+
* - Derive helpers: `mentionedBot()`, `nonBotMentions()`
|
|
11
|
+
* - Format helpers for outbound text and card messages.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.isMentionAll = isMentionAll;
|
|
15
|
+
exports.mentionedBot = mentionedBot;
|
|
16
|
+
exports.nonBotMentions = nonBotMentions;
|
|
17
|
+
exports.extractMessageBody = extractMessageBody;
|
|
18
|
+
exports.formatMentionForText = formatMentionForText;
|
|
19
|
+
exports.formatMentionAllForText = formatMentionAllForText;
|
|
20
|
+
exports.formatMentionForCard = formatMentionForCard;
|
|
21
|
+
exports.formatMentionAllForCard = formatMentionAllForCard;
|
|
22
|
+
exports.buildMentionedMessage = buildMentionedMessage;
|
|
23
|
+
exports.buildMentionedCardContent = buildMentionedCardContent;
|
|
24
|
+
const utils_1 = require("../converters/utils.js");
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// Derive helpers (work on MentionInfo[])
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
/**
|
|
29
|
+
* Detect whether a raw mention entry represents @all / @所有人.
|
|
30
|
+
*
|
|
31
|
+
* Feishu @all mentions have `key: "@_all"` and empty ID fields.
|
|
32
|
+
* We match on `key` as the primary signal (most stable across locales).
|
|
33
|
+
*/
|
|
34
|
+
function isMentionAll(mention) {
|
|
35
|
+
return mention.key === '@_all';
|
|
36
|
+
}
|
|
37
|
+
/** Whether the receiving bot itself was @-mentioned. */
|
|
38
|
+
function mentionedBot(ctx) {
|
|
39
|
+
return ctx.mentions.some((m) => m.isBot);
|
|
40
|
+
}
|
|
41
|
+
/** All mentions excluding the receiving bot itself. */
|
|
42
|
+
function nonBotMentions(ctx) {
|
|
43
|
+
return ctx.mentions.filter((m) => !m.isBot);
|
|
44
|
+
}
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// extractMessageBody
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
/**
|
|
49
|
+
* Remove all @mention placeholder keys from the message text.
|
|
50
|
+
*/
|
|
51
|
+
function extractMessageBody(text, allMentionKeys) {
|
|
52
|
+
let result = text;
|
|
53
|
+
for (const key of allMentionKeys) {
|
|
54
|
+
result = result.replace(new RegExp((0, utils_1.escapeRegExp)(key) + '\\s*', 'g'), '');
|
|
55
|
+
}
|
|
56
|
+
return result.trim();
|
|
57
|
+
}
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Format helpers -- text messages
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
/**
|
|
62
|
+
* Format a mention for a Feishu text / post message.
|
|
63
|
+
* @returns e.g. `<at user_id="ou_xxx">Alice</at>`
|
|
64
|
+
*/
|
|
65
|
+
function formatMentionForText(target) {
|
|
66
|
+
return `<at user_id="${target.openId}">${target.name}</at>`;
|
|
67
|
+
}
|
|
68
|
+
/** Format an @everyone mention for text / post. */
|
|
69
|
+
function formatMentionAllForText() {
|
|
70
|
+
return `<at user_id="all">Everyone</at>`;
|
|
71
|
+
}
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Format helpers -- interactive card messages
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
/**
|
|
76
|
+
* Format a mention for a Feishu Interactive Card.
|
|
77
|
+
* @returns e.g. `<at id=ou_xxx></at>`
|
|
78
|
+
*/
|
|
79
|
+
function formatMentionForCard(target) {
|
|
80
|
+
return `<at id=${target.openId}></at>`;
|
|
81
|
+
}
|
|
82
|
+
/** Format an @everyone mention for card. */
|
|
83
|
+
function formatMentionAllForCard() {
|
|
84
|
+
return `<at id=all></at>`;
|
|
85
|
+
}
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
// Build helpers (prepend mentions to message body)
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
/** Prepend @mention tags (text format) to a message body. */
|
|
90
|
+
function buildMentionedMessage(targets, message) {
|
|
91
|
+
if (targets.length === 0)
|
|
92
|
+
return message;
|
|
93
|
+
const mentionTags = targets.map(formatMentionForText).join(' ');
|
|
94
|
+
return `${mentionTags}\n${message}`;
|
|
95
|
+
}
|
|
96
|
+
/** Prepend @mention tags (card format) to card markdown content. */
|
|
97
|
+
function buildMentionedCardContent(targets, message) {
|
|
98
|
+
if (targets.length === 0)
|
|
99
|
+
return message;
|
|
100
|
+
const mentionTags = targets.map(formatMentionForCard).join(' ');
|
|
101
|
+
return `${mentionTags}\n${message}`;
|
|
102
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* I/O adapters for inbound message parsing.
|
|
6
|
+
*
|
|
7
|
+
* Contains API-calling functions that are used during the parse phase
|
|
8
|
+
* but separated from the pure parsing logic in parse.ts.
|
|
9
|
+
*/
|
|
10
|
+
import type { LarkClient as LarkClientType } from '../../core/lark-client';
|
|
11
|
+
import type { LarkAccount } from '../../core/types';
|
|
12
|
+
/** Shape of a single message item returned by the im/v1/messages API. */
|
|
13
|
+
export interface ApiMessageItem {
|
|
14
|
+
message_id?: string;
|
|
15
|
+
msg_type?: string;
|
|
16
|
+
body?: {
|
|
17
|
+
content?: string;
|
|
18
|
+
};
|
|
19
|
+
sender?: {
|
|
20
|
+
id?: string;
|
|
21
|
+
sender_type?: string;
|
|
22
|
+
};
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 对 interactive 消息,通过 TAT 调用 API 获取完整 v2 卡片内容。
|
|
27
|
+
* 事件推送的 content 可能不包含 json_card,API 调用可返回完整的 raw_card_content。
|
|
28
|
+
* 失败时返回 undefined,调用方 fallback 到原始 content。
|
|
29
|
+
*
|
|
30
|
+
* Note: `larkClient.sdk` 的类型定义不暴露 raw `request` 方法,
|
|
31
|
+
* 因此这里使用 `as any` 断言调用。
|
|
32
|
+
*/
|
|
33
|
+
export declare function fetchCardContent(messageId: string, larkClient: LarkClientType): Promise<string | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Create a `fetchSubMessages` callback for use in `ConvertContext`.
|
|
36
|
+
*
|
|
37
|
+
* The returned function calls the im/v1/messages API to fetch
|
|
38
|
+
* sub-messages of a merge_forward message.
|
|
39
|
+
*
|
|
40
|
+
* Note: `larkClient.sdk` 的类型定义不暴露 raw `request` 方法,
|
|
41
|
+
* 因此这里使用 `as any` 断言调用。
|
|
42
|
+
*/
|
|
43
|
+
export declare function createFetchSubMessages(larkClient: LarkClientType): (msgId: string) => Promise<ApiMessageItem[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Create a `batchResolveNames` callback for use in `ConvertContext`.
|
|
46
|
+
*
|
|
47
|
+
* Wraps `createBatchResolveNames` from user-name-cache.ts, providing
|
|
48
|
+
* the account and log function.
|
|
49
|
+
*/
|
|
50
|
+
export declare function createParseResolveNames(account: LarkAccount): (openIds: string[]) => Promise<void>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* I/O adapters for inbound message parsing.
|
|
7
|
+
*
|
|
8
|
+
* Contains API-calling functions that are used during the parse phase
|
|
9
|
+
* but separated from the pure parsing logic in parse.ts.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.fetchCardContent = fetchCardContent;
|
|
13
|
+
exports.createFetchSubMessages = createFetchSubMessages;
|
|
14
|
+
exports.createParseResolveNames = createParseResolveNames;
|
|
15
|
+
const lark_logger_1 = require("../../core/lark-logger.js");
|
|
16
|
+
const user_name_cache_1 = require("./user-name-cache.js");
|
|
17
|
+
const log = (0, lark_logger_1.larkLogger)('inbound/parse-io');
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Card content fetcher
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
/**
|
|
22
|
+
* 对 interactive 消息,通过 TAT 调用 API 获取完整 v2 卡片内容。
|
|
23
|
+
* 事件推送的 content 可能不包含 json_card,API 调用可返回完整的 raw_card_content。
|
|
24
|
+
* 失败时返回 undefined,调用方 fallback 到原始 content。
|
|
25
|
+
*
|
|
26
|
+
* Note: `larkClient.sdk` 的类型定义不暴露 raw `request` 方法,
|
|
27
|
+
* 因此这里使用 `as any` 断言调用。
|
|
28
|
+
*/
|
|
29
|
+
async function fetchCardContent(messageId, larkClient) {
|
|
30
|
+
try {
|
|
31
|
+
// SDK 类型不暴露 raw request 方法,需要 as any
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
const response = await larkClient.sdk.request({
|
|
34
|
+
method: 'GET',
|
|
35
|
+
url: `/open-apis/im/v1/messages/${messageId}`,
|
|
36
|
+
params: {
|
|
37
|
+
user_id_type: 'open_id',
|
|
38
|
+
card_msg_content_type: 'raw_card_content',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
return response?.data?.items?.[0]?.body?.content ?? undefined;
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
log.warn(`fetchCardContent failed for ${messageId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Sub-message fetcher (for merge_forward)
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
/**
|
|
52
|
+
* Create a `fetchSubMessages` callback for use in `ConvertContext`.
|
|
53
|
+
*
|
|
54
|
+
* The returned function calls the im/v1/messages API to fetch
|
|
55
|
+
* sub-messages of a merge_forward message.
|
|
56
|
+
*
|
|
57
|
+
* Note: `larkClient.sdk` 的类型定义不暴露 raw `request` 方法,
|
|
58
|
+
* 因此这里使用 `as any` 断言调用。
|
|
59
|
+
*/
|
|
60
|
+
function createFetchSubMessages(larkClient) {
|
|
61
|
+
return async (msgId) => {
|
|
62
|
+
// SDK 类型不暴露 raw request 方法,需要 as any
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
const response = await larkClient.sdk.request({
|
|
65
|
+
method: 'GET',
|
|
66
|
+
url: `/open-apis/im/v1/messages/${msgId}`,
|
|
67
|
+
params: { user_id_type: 'open_id', card_msg_content_type: 'raw_card_content' },
|
|
68
|
+
});
|
|
69
|
+
if (response?.code !== 0) {
|
|
70
|
+
throw new Error(`API error: code=${response?.code} msg=${response?.msg}`);
|
|
71
|
+
}
|
|
72
|
+
return response?.data?.items ?? [];
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// Batch resolve names callback factory
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
/**
|
|
79
|
+
* Create a `batchResolveNames` callback for use in `ConvertContext`.
|
|
80
|
+
*
|
|
81
|
+
* Wraps `createBatchResolveNames` from user-name-cache.ts, providing
|
|
82
|
+
* the account and log function.
|
|
83
|
+
*/
|
|
84
|
+
function createParseResolveNames(account) {
|
|
85
|
+
return (0, user_name_cache_1.createBatchResolveNames)(account, (...args) => log.info(args.map(String).join(' ')));
|
|
86
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Event parsing for inbound Feishu messages.
|
|
6
|
+
*
|
|
7
|
+
* Converts a raw FeishuMessageEvent into a normalised MessageContext.
|
|
8
|
+
* All mention information is captured in `mentions: MentionInfo[]`;
|
|
9
|
+
* downstream logic derives `mentionedBot` and non-bot targets from it.
|
|
10
|
+
*
|
|
11
|
+
* When `expandCtx` is provided, `cfg` and `accountId` are passed into
|
|
12
|
+
* the converter context so that async converters (e.g. merge_forward)
|
|
13
|
+
* can make API calls during parsing.
|
|
14
|
+
*/
|
|
15
|
+
import type { ClawdbotConfig } from 'openclaw/plugin-sdk';
|
|
16
|
+
import type { FeishuMessageEvent, MessageContext } from '../types';
|
|
17
|
+
/**
|
|
18
|
+
* Parse a raw Feishu message event into a normalised MessageContext.
|
|
19
|
+
*
|
|
20
|
+
* @param expandCtx When provided, cfg/accountId are used to create
|
|
21
|
+
* callbacks for async converters (e.g. merge_forward)
|
|
22
|
+
* to fetch sub-messages and resolve sender names.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseMessageEvent(event: FeishuMessageEvent, botOpenId?: string, expandCtx?: {
|
|
25
|
+
/** account 级别的 ClawdbotConfig(channels.feishu 已替换为 per-account 合并后的配置) */
|
|
26
|
+
cfg: ClawdbotConfig;
|
|
27
|
+
accountId?: string;
|
|
28
|
+
}): Promise<MessageContext>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Event parsing for inbound Feishu messages.
|
|
7
|
+
*
|
|
8
|
+
* Converts a raw FeishuMessageEvent into a normalised MessageContext.
|
|
9
|
+
* All mention information is captured in `mentions: MentionInfo[]`;
|
|
10
|
+
* downstream logic derives `mentionedBot` and non-bot targets from it.
|
|
11
|
+
*
|
|
12
|
+
* When `expandCtx` is provided, `cfg` and `accountId` are passed into
|
|
13
|
+
* the converter context so that async converters (e.g. merge_forward)
|
|
14
|
+
* can make API calls during parsing.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.parseMessageEvent = parseMessageEvent;
|
|
18
|
+
const content_converter_1 = require("../converters/content-converter.js");
|
|
19
|
+
const accounts_1 = require("../../core/accounts.js");
|
|
20
|
+
const lark_client_1 = require("../../core/lark-client.js");
|
|
21
|
+
const lark_logger_1 = require("../../core/lark-logger.js");
|
|
22
|
+
const mention_1 = require("./mention.js");
|
|
23
|
+
const user_name_cache_1 = require("./user-name-cache.js");
|
|
24
|
+
const parse_io_1 = require("./parse-io.js");
|
|
25
|
+
const log = (0, lark_logger_1.larkLogger)('inbound/parse');
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Public API
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
/**
|
|
30
|
+
* Parse a raw Feishu message event into a normalised MessageContext.
|
|
31
|
+
*
|
|
32
|
+
* @param expandCtx When provided, cfg/accountId are used to create
|
|
33
|
+
* callbacks for async converters (e.g. merge_forward)
|
|
34
|
+
* to fetch sub-messages and resolve sender names.
|
|
35
|
+
*/
|
|
36
|
+
async function parseMessageEvent(event, botOpenId, expandCtx) {
|
|
37
|
+
// 1. Build MentionInfo list from event mentions
|
|
38
|
+
const mentionMap = new Map();
|
|
39
|
+
const mentionList = [];
|
|
40
|
+
let mentionAll = false;
|
|
41
|
+
for (const m of event.message.mentions ?? []) {
|
|
42
|
+
// Detect @all / @所有人: add to mentionMap (for text replacement by
|
|
43
|
+
// resolveMentions) but not mentionList (not a user mention).
|
|
44
|
+
if ((0, mention_1.isMentionAll)(m)) {
|
|
45
|
+
mentionAll = true;
|
|
46
|
+
mentionMap.set(m.key, {
|
|
47
|
+
key: m.key,
|
|
48
|
+
openId: '',
|
|
49
|
+
name: m.name,
|
|
50
|
+
isBot: false,
|
|
51
|
+
});
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const openId = m.id?.open_id ?? '';
|
|
55
|
+
if (!openId)
|
|
56
|
+
continue;
|
|
57
|
+
const info = {
|
|
58
|
+
key: m.key,
|
|
59
|
+
openId,
|
|
60
|
+
name: m.name,
|
|
61
|
+
isBot: Boolean(botOpenId && openId === botOpenId),
|
|
62
|
+
};
|
|
63
|
+
mentionMap.set(m.key, info);
|
|
64
|
+
mentionList.push(info);
|
|
65
|
+
}
|
|
66
|
+
// Build reverse map for O(1) openId lookup
|
|
67
|
+
const mentionsByOpenId = new Map();
|
|
68
|
+
for (const info of mentionList) {
|
|
69
|
+
mentionsByOpenId.set(info.openId, info);
|
|
70
|
+
}
|
|
71
|
+
// 2. Convert content via registered converter
|
|
72
|
+
const acctId = expandCtx?.accountId;
|
|
73
|
+
// Create larkClient once when expandCtx is available (used for merge_forward & card fetch)
|
|
74
|
+
const larkClient = expandCtx ? lark_client_1.LarkClient.fromCfg(expandCtx.cfg, acctId) : undefined;
|
|
75
|
+
// Build merge_forward callbacks when expandCtx is provided
|
|
76
|
+
let fetchSubMessages;
|
|
77
|
+
let batchResolveNames;
|
|
78
|
+
if (expandCtx) {
|
|
79
|
+
const account = (0, accounts_1.getLarkAccount)(expandCtx.cfg, acctId);
|
|
80
|
+
fetchSubMessages = (0, parse_io_1.createFetchSubMessages)(larkClient);
|
|
81
|
+
batchResolveNames = (0, parse_io_1.createParseResolveNames)(account);
|
|
82
|
+
}
|
|
83
|
+
// For interactive messages, fetch full v2 card content via API
|
|
84
|
+
let effectiveContent = event.message.content;
|
|
85
|
+
if (event.message.message_type === 'interactive' && expandCtx) {
|
|
86
|
+
const fullContent = await (0, parse_io_1.fetchCardContent)(event.message.message_id, larkClient);
|
|
87
|
+
if (fullContent) {
|
|
88
|
+
effectiveContent = fullContent;
|
|
89
|
+
log.info('replaced interactive content with full v2 card data');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const convertCtx = {
|
|
93
|
+
mentions: mentionMap,
|
|
94
|
+
mentionsByOpenId,
|
|
95
|
+
messageId: event.message.message_id,
|
|
96
|
+
botOpenId,
|
|
97
|
+
cfg: expandCtx?.cfg,
|
|
98
|
+
accountId: acctId,
|
|
99
|
+
resolveUserName: acctId ? (openId) => (0, user_name_cache_1.getUserNameCache)(acctId).get(openId) : undefined,
|
|
100
|
+
fetchSubMessages,
|
|
101
|
+
batchResolveNames,
|
|
102
|
+
stripBotMentions: true,
|
|
103
|
+
};
|
|
104
|
+
const { content, resources } = await (0, content_converter_1.convertMessageContent)(effectiveContent, event.message.message_type, convertCtx);
|
|
105
|
+
const createTimeStr = event.message.create_time;
|
|
106
|
+
const createTime = createTimeStr ? parseInt(createTimeStr, 10) : undefined;
|
|
107
|
+
return {
|
|
108
|
+
chatId: event.message.chat_id,
|
|
109
|
+
messageId: event.message.message_id,
|
|
110
|
+
senderId: event.sender.sender_id.open_id || '',
|
|
111
|
+
chatType: event.message.chat_type,
|
|
112
|
+
rootId: event.message.root_id || undefined,
|
|
113
|
+
parentId: event.message.parent_id || undefined,
|
|
114
|
+
threadId: event.message.thread_id || undefined,
|
|
115
|
+
content,
|
|
116
|
+
contentType: event.message.message_type,
|
|
117
|
+
resources,
|
|
118
|
+
mentions: mentionList,
|
|
119
|
+
mentionAll,
|
|
120
|
+
// Per Feishu docs, im.message.receive_v1 sets sender_type to 'user' or
|
|
121
|
+
// 'bot'. We also accept 'app' defensively for any SDK/legacy variant that
|
|
122
|
+
// surfaces the older value.
|
|
123
|
+
senderIsBot: event.sender.sender_type === 'bot' || event.sender.sender_type === 'app',
|
|
124
|
+
createTime: Number.isNaN(createTime) ? undefined : createTime,
|
|
125
|
+
rawMessage: effectiveContent !== event.message.content ? { ...event.message, content: effectiveContent } : event.message,
|
|
126
|
+
rawSender: event.sender,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Permission error extraction and cooldown tracking for Feishu API calls.
|
|
6
|
+
*
|
|
7
|
+
* Extracted from bot.ts: PermissionError type, extractPermissionError,
|
|
8
|
+
* PERMISSION_ERROR_COOLDOWN_MS, permissionErrorNotifiedAt.
|
|
9
|
+
*/
|
|
10
|
+
export interface PermissionError {
|
|
11
|
+
code: number;
|
|
12
|
+
message: string;
|
|
13
|
+
grantUrl?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function extractPermissionError(err: unknown): PermissionError | null;
|
|
16
|
+
export declare const PERMISSION_ERROR_COOLDOWN_MS: number;
|
|
17
|
+
export declare const permissionErrorNotifiedAt: Map<string, number>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Permission error extraction and cooldown tracking for Feishu API calls.
|
|
7
|
+
*
|
|
8
|
+
* Extracted from bot.ts: PermissionError type, extractPermissionError,
|
|
9
|
+
* PERMISSION_ERROR_COOLDOWN_MS, permissionErrorNotifiedAt.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.permissionErrorNotifiedAt = exports.PERMISSION_ERROR_COOLDOWN_MS = void 0;
|
|
13
|
+
exports.extractPermissionError = extractPermissionError;
|
|
14
|
+
const permission_url_1 = require("../../core/permission-url.js");
|
|
15
|
+
const auth_errors_1 = require("../../core/auth-errors.js");
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Permission error extraction
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
function extractPermissionError(err) {
|
|
20
|
+
if (!err || typeof err !== 'object') {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const axiosErr = err;
|
|
24
|
+
const data = axiosErr.response?.data;
|
|
25
|
+
if (!data || typeof data !== 'object') {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const feishuErr = data;
|
|
29
|
+
// Feishu permission error code
|
|
30
|
+
if (feishuErr.code !== auth_errors_1.LARK_ERROR.APP_SCOPE_MISSING) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const msg = feishuErr.msg ?? '';
|
|
34
|
+
const grantUrl = (0, permission_url_1.extractPermissionGrantUrl)(msg);
|
|
35
|
+
if (!grantUrl) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return { code: feishuErr.code, message: msg, grantUrl };
|
|
39
|
+
}
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// Cooldown tracking
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
exports.PERMISSION_ERROR_COOLDOWN_MS = 5 * 60 * 1000; // 5 minutes
|
|
44
|
+
exports.permissionErrorNotifiedAt = new Map();
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Access control policies for the Lark/Feishu channel plugin.
|
|
6
|
+
*
|
|
7
|
+
* Provides allowlist matching, group configuration lookup, tool policy
|
|
8
|
+
* extraction, and group access checks.
|
|
9
|
+
*/
|
|
10
|
+
import type { ChannelGroupContext } from 'openclaw/plugin-sdk/channel-contract';
|
|
11
|
+
import type { GroupToolPolicyConfig } from 'openclaw/plugin-sdk/channel-policy';
|
|
12
|
+
import type { FeishuConfig, FeishuGroupConfig } from '../../core/types';
|
|
13
|
+
export interface FeishuAllowlistMatch {
|
|
14
|
+
allowed: boolean;
|
|
15
|
+
matchKey?: string;
|
|
16
|
+
matchSource?: 'wildcard' | 'id' | 'name';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Check whether a sender is permitted by a given allowlist.
|
|
20
|
+
*
|
|
21
|
+
* Entries are normalised to lowercase strings before comparison.
|
|
22
|
+
* A single "*" entry acts as a wildcard that matches everyone.
|
|
23
|
+
* When the allowlist is empty the result is `{ allowed: false }`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveFeishuAllowlistMatch(params: {
|
|
26
|
+
allowFrom: Array<string | number>;
|
|
27
|
+
senderId: string;
|
|
28
|
+
senderName?: string | null;
|
|
29
|
+
}): FeishuAllowlistMatch;
|
|
30
|
+
/**
|
|
31
|
+
* Look up the per-group configuration by group ID.
|
|
32
|
+
*
|
|
33
|
+
* Performs a case-insensitive lookup against the keys in `cfg.groups`.
|
|
34
|
+
* Returns `undefined` when no matching group entry is found.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveFeishuGroupConfig(params: {
|
|
37
|
+
cfg?: FeishuConfig;
|
|
38
|
+
groupId?: string | null;
|
|
39
|
+
}): FeishuGroupConfig | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Extract the tool policy configuration from the group config that
|
|
42
|
+
* corresponds to the given group context.
|
|
43
|
+
*
|
|
44
|
+
* ★ 多账号配置隔离:SDK 回调传入的 params.cfg 是顶层全局配置,
|
|
45
|
+
* cfg.channels.feishu 不包含 per-account 的覆盖值。
|
|
46
|
+
* 这里通过 getLarkAccount() 获取当前 account 合并后的配置,
|
|
47
|
+
* 确保每个账号的 groups / tool policy 配置独立生效。
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveFeishuGroupToolPolicy(params: ChannelGroupContext): GroupToolPolicyConfig | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Determine whether an inbound group message should be processed.
|
|
52
|
+
*
|
|
53
|
+
* - `disabled` --> always rejected
|
|
54
|
+
* - `open` --> always allowed
|
|
55
|
+
* - `allowlist` --> allowed only when the sender matches the allowlist
|
|
56
|
+
*/
|
|
57
|
+
export declare function isFeishuGroupAllowed(params: {
|
|
58
|
+
groupPolicy: 'open' | 'allowlist' | 'disabled';
|
|
59
|
+
allowFrom: Array<string | number>;
|
|
60
|
+
senderId: string;
|
|
61
|
+
senderName?: string | null;
|
|
62
|
+
}): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Split a raw `groupAllowFrom` array into legacy chat-ID entries
|
|
65
|
+
* (`oc_xxx`) and sender-level entries.
|
|
66
|
+
*
|
|
67
|
+
* Older Feishu configs used `groupAllowFrom` with `oc_xxx` chat IDs to
|
|
68
|
+
* control which groups are allowed. The correct semantic (aligned with
|
|
69
|
+
* Telegram) is sender IDs. This function separates the two concerns so
|
|
70
|
+
* both layers can work independently.
|
|
71
|
+
*/
|
|
72
|
+
export declare function splitLegacyGroupAllowFrom(rawGroupAllowFrom: Array<string | number>): {
|
|
73
|
+
legacyChatIds: string[];
|
|
74
|
+
senderAllowFrom: string[];
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Resolve the effective sender-level group policy and the merged
|
|
78
|
+
* `allowFrom` list for sender filtering within a group.
|
|
79
|
+
*
|
|
80
|
+
* The precedence chain for `senderPolicy` is:
|
|
81
|
+
* per-group `groupPolicy` > default ("*") group `groupPolicy` >
|
|
82
|
+
* global `groupPolicy` > "open" (default).
|
|
83
|
+
*
|
|
84
|
+
* The `senderAllowFrom` is the union of global (non-oc_) entries,
|
|
85
|
+
* per-group entries, and default ("*") entries (when no per-group config).
|
|
86
|
+
*/
|
|
87
|
+
export declare function resolveGroupSenderPolicyContext(params: {
|
|
88
|
+
groupConfig?: FeishuGroupConfig;
|
|
89
|
+
defaultConfig?: FeishuGroupConfig;
|
|
90
|
+
accountFeishuCfg?: FeishuConfig;
|
|
91
|
+
senderGroupAllowFrom: Array<string | number>;
|
|
92
|
+
}): {
|
|
93
|
+
senderPolicy: 'open' | 'allowlist' | 'disabled';
|
|
94
|
+
senderAllowFrom: Array<string | number>;
|
|
95
|
+
};
|