@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,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Shared helper for dispatching synthetic inbound text messages.
|
|
7
|
+
*
|
|
8
|
+
* Synthetic messages are used to resume the normal inbound pipeline after
|
|
9
|
+
* card actions or OAuth flows complete.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.dispatchSyntheticTextMessage = dispatchSyntheticTextMessage;
|
|
13
|
+
const chat_queue_1 = require("../../channel/chat-queue.js");
|
|
14
|
+
const lark_ticket_1 = require("../../core/lark-ticket.js");
|
|
15
|
+
const handler_registry_1 = require("./handler-registry.js");
|
|
16
|
+
async function dispatchSyntheticTextMessage(params) {
|
|
17
|
+
const handleFeishuMessage = (0, handler_registry_1.getInboundHandler)();
|
|
18
|
+
const { cfg, accountId, chatId, senderOpenId, text, syntheticMessageId, replyToMessageId, chatType, threadId, runtime, forceMention = true, } = params;
|
|
19
|
+
const syntheticEvent = {
|
|
20
|
+
sender: {
|
|
21
|
+
sender_id: { open_id: senderOpenId },
|
|
22
|
+
},
|
|
23
|
+
message: {
|
|
24
|
+
message_id: syntheticMessageId,
|
|
25
|
+
chat_id: chatId,
|
|
26
|
+
chat_type: chatType ?? 'p2p',
|
|
27
|
+
message_type: 'text',
|
|
28
|
+
content: JSON.stringify({ text }),
|
|
29
|
+
thread_id: threadId,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const { status, promise } = (0, chat_queue_1.enqueueFeishuChatTask)({
|
|
33
|
+
accountId,
|
|
34
|
+
chatId,
|
|
35
|
+
threadId,
|
|
36
|
+
task: async () => {
|
|
37
|
+
await (0, lark_ticket_1.withTicket)({
|
|
38
|
+
messageId: syntheticMessageId,
|
|
39
|
+
chatId,
|
|
40
|
+
accountId,
|
|
41
|
+
startTime: Date.now(),
|
|
42
|
+
senderOpenId,
|
|
43
|
+
chatType,
|
|
44
|
+
threadId,
|
|
45
|
+
}, () => handleFeishuMessage({
|
|
46
|
+
cfg,
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
event: syntheticEvent,
|
|
49
|
+
accountId,
|
|
50
|
+
forceMention,
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
runtime: runtime,
|
|
53
|
+
replyToMessageId,
|
|
54
|
+
}));
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
await promise;
|
|
58
|
+
return status;
|
|
59
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Account-scoped cache registry for Feishu user display names.
|
|
6
|
+
*
|
|
7
|
+
* Stores forward (openId → name + kind) and reverse (normalizedName → Set<openId>)
|
|
8
|
+
* indexes for mention resolution. Per-account, LRU + TTL.
|
|
9
|
+
*/
|
|
10
|
+
export type PrincipalKind = 'user' | 'bot';
|
|
11
|
+
export interface MentionMatch {
|
|
12
|
+
openId: string;
|
|
13
|
+
name: string;
|
|
14
|
+
kind?: PrincipalKind;
|
|
15
|
+
}
|
|
16
|
+
export interface ChatMember {
|
|
17
|
+
openId: string;
|
|
18
|
+
name: string;
|
|
19
|
+
kind: PrincipalKind;
|
|
20
|
+
}
|
|
21
|
+
export interface ChatMembersEntry {
|
|
22
|
+
members: ChatMember[];
|
|
23
|
+
expireAt: number;
|
|
24
|
+
}
|
|
25
|
+
export declare class UserNameCache {
|
|
26
|
+
private nameByOpenId;
|
|
27
|
+
private openIdsByName;
|
|
28
|
+
private maxSize;
|
|
29
|
+
private ttlMs;
|
|
30
|
+
private chatBots;
|
|
31
|
+
private chatMembers;
|
|
32
|
+
private inFlight;
|
|
33
|
+
private maxChats;
|
|
34
|
+
constructor(maxSize?: number, ttlMs?: number, maxChats?: number);
|
|
35
|
+
has(openId: string): boolean;
|
|
36
|
+
get(openId: string): string | undefined;
|
|
37
|
+
set(openId: string, name: string): void;
|
|
38
|
+
setWithKind(openId: string, name: string, kind: PrincipalKind): void;
|
|
39
|
+
lookupByName(name: string): MentionMatch[];
|
|
40
|
+
setMany(entries: Iterable<[string, string]>): void;
|
|
41
|
+
filterMissing(openIds: string[]): string[];
|
|
42
|
+
getMany(openIds: string[]): Map<string, string>;
|
|
43
|
+
recordChatBots(chatId: string, members: Array<{
|
|
44
|
+
openId: string;
|
|
45
|
+
name: string;
|
|
46
|
+
}>): void;
|
|
47
|
+
recordChatMembers(chatId: string, members: ChatMember[]): void;
|
|
48
|
+
getChatBots(chatId: string): ChatMembersEntry | null;
|
|
49
|
+
getChatMembers(chatId: string): ChatMembersEntry | null;
|
|
50
|
+
getInflight(key: string): Promise<void> | undefined;
|
|
51
|
+
setInflight(key: string, promise: Promise<void>): void;
|
|
52
|
+
clearInflight(key: string): void;
|
|
53
|
+
clear(): void;
|
|
54
|
+
private writeEntry;
|
|
55
|
+
private writeEntryNoEvict;
|
|
56
|
+
private deleteOpenId;
|
|
57
|
+
private removeFromReverse;
|
|
58
|
+
private evictChats;
|
|
59
|
+
private evict;
|
|
60
|
+
}
|
|
61
|
+
export declare function getUserNameCache(accountId: string): UserNameCache;
|
|
62
|
+
export declare function clearUserNameCache(accountId?: string): void;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Account-scoped cache registry for Feishu user display names.
|
|
7
|
+
*
|
|
8
|
+
* Stores forward (openId → name + kind) and reverse (normalizedName → Set<openId>)
|
|
9
|
+
* indexes for mention resolution. Per-account, LRU + TTL.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UserNameCache = void 0;
|
|
13
|
+
exports.getUserNameCache = getUserNameCache;
|
|
14
|
+
exports.clearUserNameCache = clearUserNameCache;
|
|
15
|
+
const DEFAULT_MAX_SIZE = 500;
|
|
16
|
+
const DEFAULT_TTL_MS = 30 * 60 * 1000; // 30 minutes
|
|
17
|
+
const DEFAULT_MAX_CHATS = 200;
|
|
18
|
+
function normalizeName(name) {
|
|
19
|
+
return name.trim().toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
class UserNameCache {
|
|
22
|
+
nameByOpenId = new Map();
|
|
23
|
+
openIdsByName = new Map();
|
|
24
|
+
maxSize;
|
|
25
|
+
ttlMs;
|
|
26
|
+
chatBots = new Map();
|
|
27
|
+
chatMembers = new Map();
|
|
28
|
+
inFlight = new Map();
|
|
29
|
+
maxChats;
|
|
30
|
+
constructor(maxSize = DEFAULT_MAX_SIZE, ttlMs = DEFAULT_TTL_MS, maxChats = DEFAULT_MAX_CHATS) {
|
|
31
|
+
this.maxSize = maxSize;
|
|
32
|
+
this.ttlMs = ttlMs;
|
|
33
|
+
this.maxChats = maxChats;
|
|
34
|
+
}
|
|
35
|
+
has(openId) {
|
|
36
|
+
const entry = this.nameByOpenId.get(openId);
|
|
37
|
+
if (!entry)
|
|
38
|
+
return false;
|
|
39
|
+
if (entry.expireAt <= Date.now()) {
|
|
40
|
+
this.deleteOpenId(openId);
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
get(openId) {
|
|
46
|
+
const entry = this.nameByOpenId.get(openId);
|
|
47
|
+
if (!entry)
|
|
48
|
+
return undefined;
|
|
49
|
+
if (entry.expireAt <= Date.now()) {
|
|
50
|
+
this.deleteOpenId(openId);
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
// LRU bump
|
|
54
|
+
this.nameByOpenId.delete(openId);
|
|
55
|
+
this.nameByOpenId.set(openId, entry);
|
|
56
|
+
return entry.name;
|
|
57
|
+
}
|
|
58
|
+
set(openId, name) {
|
|
59
|
+
this.writeEntry(openId, name, undefined);
|
|
60
|
+
}
|
|
61
|
+
setWithKind(openId, name, kind) {
|
|
62
|
+
this.writeEntry(openId, name, kind);
|
|
63
|
+
}
|
|
64
|
+
lookupByName(name) {
|
|
65
|
+
const key = normalizeName(name);
|
|
66
|
+
const ids = this.openIdsByName.get(key);
|
|
67
|
+
if (!ids || ids.size === 0)
|
|
68
|
+
return [];
|
|
69
|
+
const matches = [];
|
|
70
|
+
for (const openId of ids) {
|
|
71
|
+
const entry = this.nameByOpenId.get(openId);
|
|
72
|
+
if (!entry)
|
|
73
|
+
continue;
|
|
74
|
+
if (entry.expireAt <= Date.now()) {
|
|
75
|
+
this.deleteOpenId(openId);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
matches.push({ openId, name: entry.name, kind: entry.kind });
|
|
79
|
+
}
|
|
80
|
+
return matches;
|
|
81
|
+
}
|
|
82
|
+
setMany(entries) {
|
|
83
|
+
for (const [openId, name] of entries) {
|
|
84
|
+
this.writeEntryNoEvict(openId, name, undefined);
|
|
85
|
+
}
|
|
86
|
+
this.evict();
|
|
87
|
+
}
|
|
88
|
+
filterMissing(openIds) {
|
|
89
|
+
return openIds.filter((id) => !this.has(id));
|
|
90
|
+
}
|
|
91
|
+
getMany(openIds) {
|
|
92
|
+
const result = new Map();
|
|
93
|
+
for (const id of openIds) {
|
|
94
|
+
if (this.has(id)) {
|
|
95
|
+
result.set(id, this.get(id) ?? '');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
recordChatBots(chatId, members) {
|
|
101
|
+
const enriched = members.map((m) => ({ ...m, kind: 'bot' }));
|
|
102
|
+
this.chatBots.delete(chatId);
|
|
103
|
+
this.chatBots.set(chatId, { members: enriched, expireAt: Date.now() + this.ttlMs });
|
|
104
|
+
this.evictChats(this.chatBots);
|
|
105
|
+
for (const m of enriched) {
|
|
106
|
+
if (m.openId)
|
|
107
|
+
this.writeEntryNoEvict(m.openId, m.name, 'bot');
|
|
108
|
+
}
|
|
109
|
+
this.evict();
|
|
110
|
+
}
|
|
111
|
+
recordChatMembers(chatId, members) {
|
|
112
|
+
const enriched = members.slice();
|
|
113
|
+
this.chatMembers.delete(chatId);
|
|
114
|
+
this.chatMembers.set(chatId, { members: enriched, expireAt: Date.now() + this.ttlMs });
|
|
115
|
+
this.evictChats(this.chatMembers);
|
|
116
|
+
for (const m of enriched) {
|
|
117
|
+
if (m.openId)
|
|
118
|
+
this.writeEntryNoEvict(m.openId, m.name, m.kind);
|
|
119
|
+
}
|
|
120
|
+
this.evict();
|
|
121
|
+
}
|
|
122
|
+
getChatBots(chatId) {
|
|
123
|
+
const entry = this.chatBots.get(chatId);
|
|
124
|
+
if (!entry)
|
|
125
|
+
return null;
|
|
126
|
+
if (entry.expireAt <= Date.now()) {
|
|
127
|
+
this.chatBots.delete(chatId);
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return entry;
|
|
131
|
+
}
|
|
132
|
+
getChatMembers(chatId) {
|
|
133
|
+
const entry = this.chatMembers.get(chatId);
|
|
134
|
+
if (!entry)
|
|
135
|
+
return null;
|
|
136
|
+
if (entry.expireAt <= Date.now()) {
|
|
137
|
+
this.chatMembers.delete(chatId);
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return entry;
|
|
141
|
+
}
|
|
142
|
+
getInflight(key) {
|
|
143
|
+
return this.inFlight.get(key);
|
|
144
|
+
}
|
|
145
|
+
setInflight(key, promise) {
|
|
146
|
+
this.inFlight.set(key, promise);
|
|
147
|
+
}
|
|
148
|
+
clearInflight(key) {
|
|
149
|
+
this.inFlight.delete(key);
|
|
150
|
+
}
|
|
151
|
+
clear() {
|
|
152
|
+
this.nameByOpenId.clear();
|
|
153
|
+
this.openIdsByName.clear();
|
|
154
|
+
this.chatBots.clear();
|
|
155
|
+
this.chatMembers.clear();
|
|
156
|
+
this.inFlight.clear();
|
|
157
|
+
}
|
|
158
|
+
// ----- private helpers -----
|
|
159
|
+
writeEntry(openId, name, kind) {
|
|
160
|
+
this.writeEntryNoEvict(openId, name, kind);
|
|
161
|
+
this.evict();
|
|
162
|
+
}
|
|
163
|
+
writeEntryNoEvict(openId, name, kind) {
|
|
164
|
+
// remove from old reverse bucket if name changed
|
|
165
|
+
const old = this.nameByOpenId.get(openId);
|
|
166
|
+
if (old) {
|
|
167
|
+
const oldKey = normalizeName(old.name);
|
|
168
|
+
const newKey = normalizeName(name);
|
|
169
|
+
if (oldKey !== newKey) {
|
|
170
|
+
this.removeFromReverse(oldKey, openId);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
this.nameByOpenId.delete(openId);
|
|
174
|
+
this.nameByOpenId.set(openId, { name, kind, expireAt: Date.now() + this.ttlMs });
|
|
175
|
+
const key = normalizeName(name);
|
|
176
|
+
let bucket = this.openIdsByName.get(key);
|
|
177
|
+
if (!bucket) {
|
|
178
|
+
bucket = new Set();
|
|
179
|
+
this.openIdsByName.set(key, bucket);
|
|
180
|
+
}
|
|
181
|
+
bucket.add(openId);
|
|
182
|
+
}
|
|
183
|
+
deleteOpenId(openId) {
|
|
184
|
+
const entry = this.nameByOpenId.get(openId);
|
|
185
|
+
if (!entry)
|
|
186
|
+
return;
|
|
187
|
+
this.nameByOpenId.delete(openId);
|
|
188
|
+
this.removeFromReverse(normalizeName(entry.name), openId);
|
|
189
|
+
}
|
|
190
|
+
removeFromReverse(key, openId) {
|
|
191
|
+
const bucket = this.openIdsByName.get(key);
|
|
192
|
+
if (!bucket)
|
|
193
|
+
return;
|
|
194
|
+
bucket.delete(openId);
|
|
195
|
+
if (bucket.size === 0) {
|
|
196
|
+
this.openIdsByName.delete(key);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
evictChats(map) {
|
|
200
|
+
while (map.size > this.maxChats) {
|
|
201
|
+
const oldest = map.keys().next().value;
|
|
202
|
+
if (oldest === undefined)
|
|
203
|
+
break;
|
|
204
|
+
map.delete(oldest);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
evict() {
|
|
208
|
+
while (this.nameByOpenId.size > this.maxSize) {
|
|
209
|
+
const oldest = this.nameByOpenId.keys().next().value;
|
|
210
|
+
if (oldest === undefined)
|
|
211
|
+
break;
|
|
212
|
+
this.deleteOpenId(oldest);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
exports.UserNameCache = UserNameCache;
|
|
217
|
+
const registry = new Map();
|
|
218
|
+
function getUserNameCache(accountId) {
|
|
219
|
+
let c = registry.get(accountId);
|
|
220
|
+
if (!c) {
|
|
221
|
+
c = new UserNameCache();
|
|
222
|
+
registry.set(accountId, c);
|
|
223
|
+
}
|
|
224
|
+
return c;
|
|
225
|
+
}
|
|
226
|
+
function clearUserNameCache(accountId) {
|
|
227
|
+
if (accountId !== undefined) {
|
|
228
|
+
registry.get(accountId)?.clear();
|
|
229
|
+
registry.delete(accountId);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
for (const c of registry.values())
|
|
233
|
+
c.clear();
|
|
234
|
+
registry.clear();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Account-scoped LRU cache for Feishu user display names.
|
|
6
|
+
*
|
|
7
|
+
* Provides:
|
|
8
|
+
* - `UserNameCache` — per-account LRU Map with TTL
|
|
9
|
+
* - `getUserNameCache(accountId)` — singleton registry
|
|
10
|
+
* - `batchResolveUserNames()` — batch API via `contact/v3/users/batch`
|
|
11
|
+
* - `resolveUserName()` — single-user fallback via `contact.user.get`
|
|
12
|
+
* - `clearUserNameCache()` — teardown hook (called from LarkClient.clearCache)
|
|
13
|
+
*/
|
|
14
|
+
import type { LarkAccount } from '../../core/types';
|
|
15
|
+
import { type PermissionError } from './permission';
|
|
16
|
+
export { UserNameCache, clearUserNameCache, getUserNameCache } from './user-name-cache-store';
|
|
17
|
+
/**
|
|
18
|
+
* Batch-resolve user display names.
|
|
19
|
+
*
|
|
20
|
+
* 1. Check cache → collect misses
|
|
21
|
+
* 2. Deduplicate
|
|
22
|
+
* 3. Call `GET /open-apis/contact/v3/users/batch` in chunks of 50
|
|
23
|
+
* 4. Write results back to cache
|
|
24
|
+
* 5. Return full Map<openId, name> (cache hits + API results)
|
|
25
|
+
*
|
|
26
|
+
* Best-effort: API errors are logged but never thrown.
|
|
27
|
+
*/
|
|
28
|
+
export declare function batchResolveUserNames(params: {
|
|
29
|
+
account: LarkAccount;
|
|
30
|
+
openIds: string[];
|
|
31
|
+
log: (...args: unknown[]) => void;
|
|
32
|
+
}): Promise<Map<string, string>>;
|
|
33
|
+
/**
|
|
34
|
+
* Create a `batchResolveNames` callback for use in `ConvertContext`.
|
|
35
|
+
*
|
|
36
|
+
* The returned function calls `batchResolveUserNames` with the given
|
|
37
|
+
* account and log function, populating the TAT user-name cache.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createBatchResolveNames(account: LarkAccount, log: (...args: unknown[]) => void): (openIds: string[]) => Promise<void>;
|
|
40
|
+
export interface ResolveUserNameResult {
|
|
41
|
+
name?: string;
|
|
42
|
+
permissionError?: PermissionError;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Resolve a single bot's display name via `/open-apis/bot/v3/bots/basic_batch`.
|
|
46
|
+
*
|
|
47
|
+
* Bots are not returned by the contact API, so they have their own endpoint.
|
|
48
|
+
* Names share the same account-scoped cache (keyed by openId) since both
|
|
49
|
+
* bots and users have `ou_` prefixed openIds and a single display name.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveBotName(params: {
|
|
52
|
+
account: LarkAccount;
|
|
53
|
+
openId: string;
|
|
54
|
+
log: (...args: unknown[]) => void;
|
|
55
|
+
}): Promise<ResolveUserNameResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Fetches the bot members of a chat via
|
|
58
|
+
* `GET /open-apis/im/v1/chats/{chat_id}/members/bots` and writes them
|
|
59
|
+
* to the per-account cache.
|
|
60
|
+
*/
|
|
61
|
+
export declare function prefetchChatBots(account: LarkAccount, chatId: string, log: (...args: unknown[]) => void): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Fetches the human members of a chat via
|
|
64
|
+
* `GET /open-apis/im/v1/chats/{chat_id}/members` and writes them to
|
|
65
|
+
* the per-account cache.
|
|
66
|
+
*/
|
|
67
|
+
export declare function prefetchChatMembers(account: LarkAccount, chatId: string, log: (...args: unknown[]) => void): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Resolve a single user's display name.
|
|
70
|
+
*
|
|
71
|
+
* Checks the account-scoped cache first, then falls back to the
|
|
72
|
+
* `contact.user.get` API (same as the old `resolveFeishuSenderName`).
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveUserName(params: {
|
|
75
|
+
account: LarkAccount;
|
|
76
|
+
openId: string;
|
|
77
|
+
log: (...args: unknown[]) => void;
|
|
78
|
+
}): Promise<ResolveUserNameResult>;
|