@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,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Dispatch context construction for the inbound agent dispatch pipeline.
|
|
6
|
+
*
|
|
7
|
+
* Derives all shared values needed by downstream dispatch helpers:
|
|
8
|
+
* logging, addressing, route resolution, thread session, and system
|
|
9
|
+
* event emission.
|
|
10
|
+
*/
|
|
11
|
+
import type { ClawdbotConfig, RuntimeEnv } from 'openclaw/plugin-sdk';
|
|
12
|
+
import type { MessageContext } from '../types';
|
|
13
|
+
import type { LarkAccount } from '../../core/types';
|
|
14
|
+
import { LarkClient } from '../../core/lark-client';
|
|
15
|
+
export interface DispatchContext {
|
|
16
|
+
ctx: MessageContext;
|
|
17
|
+
/** account 级别的 ClawdbotConfig(channels.feishu 已替换为 per-account 合并后的配置) */
|
|
18
|
+
accountScopedCfg: ClawdbotConfig;
|
|
19
|
+
account: LarkAccount;
|
|
20
|
+
runtime: RuntimeEnv;
|
|
21
|
+
log: (...args: unknown[]) => void;
|
|
22
|
+
error: (...args: unknown[]) => void;
|
|
23
|
+
core: typeof LarkClient.runtime;
|
|
24
|
+
isGroup: boolean;
|
|
25
|
+
isThread: boolean;
|
|
26
|
+
feishuFrom: string;
|
|
27
|
+
feishuTo: string;
|
|
28
|
+
envelopeFrom: string;
|
|
29
|
+
envelopeOptions: ReturnType<typeof LarkClient.runtime.channel.reply.resolveEnvelopeFormatOptions>;
|
|
30
|
+
route: ReturnType<typeof LarkClient.runtime.channel.routing.resolveAgentRoute>;
|
|
31
|
+
threadSessionKey?: string;
|
|
32
|
+
commandAuthorized?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Provide a safe RuntimeEnv fallback when the caller did not supply one.
|
|
36
|
+
* Replaces the previous unsafe `runtime as RuntimeEnv` casts.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ensureRuntime(runtime: RuntimeEnv | undefined): RuntimeEnv;
|
|
39
|
+
/**
|
|
40
|
+
* Derive all shared values needed by downstream helpers:
|
|
41
|
+
* logging, addressing, route resolution, and system event emission.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildDispatchContext(params: {
|
|
44
|
+
ctx: MessageContext;
|
|
45
|
+
account: LarkAccount;
|
|
46
|
+
accountScopedCfg: ClawdbotConfig;
|
|
47
|
+
runtime?: RuntimeEnv;
|
|
48
|
+
commandAuthorized?: boolean;
|
|
49
|
+
}): DispatchContext;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve thread session key for thread-capable groups.
|
|
52
|
+
*
|
|
53
|
+
* Returns a thread-scoped session key when ALL conditions are met:
|
|
54
|
+
* 1. `threadSession` config is enabled on the account
|
|
55
|
+
* 2. The group is a topic group (chat_mode=topic) or uses thread
|
|
56
|
+
* message mode (group_message_type=thread)
|
|
57
|
+
*
|
|
58
|
+
* The group info is fetched via `im.chat.get` with a 1-hour LRU cache
|
|
59
|
+
* to minimise OAPI calls.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveThreadSessionKey(params: {
|
|
62
|
+
accountScopedCfg: ClawdbotConfig;
|
|
63
|
+
account: LarkAccount;
|
|
64
|
+
chatId: string;
|
|
65
|
+
threadId: string;
|
|
66
|
+
baseSessionKey: string;
|
|
67
|
+
}): Promise<string | undefined>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Dispatch context construction for the inbound agent dispatch pipeline.
|
|
7
|
+
*
|
|
8
|
+
* Derives all shared values needed by downstream dispatch helpers:
|
|
9
|
+
* logging, addressing, route resolution, thread session, and system
|
|
10
|
+
* event emission.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.ensureRuntime = ensureRuntime;
|
|
14
|
+
exports.buildDispatchContext = buildDispatchContext;
|
|
15
|
+
exports.resolveThreadSessionKey = resolveThreadSessionKey;
|
|
16
|
+
const routing_1 = require("openclaw/plugin-sdk/routing");
|
|
17
|
+
const lark_client_1 = require("../../core/lark-client.js");
|
|
18
|
+
const lark_logger_1 = require("../../core/lark-logger.js");
|
|
19
|
+
const chat_info_cache_1 = require("../../core/chat-info-cache.js");
|
|
20
|
+
const comment_target_1 = require("../../core/comment-target.js");
|
|
21
|
+
const log = (0, lark_logger_1.larkLogger)('inbound/dispatch-context');
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// RuntimeEnv fallback
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
/**
|
|
26
|
+
* Provide a safe RuntimeEnv fallback when the caller did not supply one.
|
|
27
|
+
* Replaces the previous unsafe `runtime as RuntimeEnv` casts.
|
|
28
|
+
*/
|
|
29
|
+
function ensureRuntime(runtime) {
|
|
30
|
+
if (runtime)
|
|
31
|
+
return runtime;
|
|
32
|
+
return {
|
|
33
|
+
log: (...args) => log.info(args.map(String).join(' ')),
|
|
34
|
+
error: (...args) => log.error(args.map(String).join(' ')),
|
|
35
|
+
exit: (code) => process.exit(code),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Context construction
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
/**
|
|
42
|
+
* Derive all shared values needed by downstream helpers:
|
|
43
|
+
* logging, addressing, route resolution, and system event emission.
|
|
44
|
+
*/
|
|
45
|
+
function buildDispatchContext(params) {
|
|
46
|
+
const { ctx, account, accountScopedCfg } = params;
|
|
47
|
+
const runtime = ensureRuntime(params.runtime);
|
|
48
|
+
const log = runtime.log;
|
|
49
|
+
const error = runtime.error;
|
|
50
|
+
const isComment = (0, comment_target_1.isCommentTarget)(ctx.chatId);
|
|
51
|
+
const isGroup = !isComment && ctx.chatType === 'group';
|
|
52
|
+
const isThread = isGroup && Boolean(ctx.threadId);
|
|
53
|
+
const core = lark_client_1.LarkClient.runtime;
|
|
54
|
+
const feishuFrom = `feishu:${ctx.senderId}`;
|
|
55
|
+
// Comment targets use the comment target string directly as the "To"
|
|
56
|
+
// so the outbound routing layer can detect it and route through Drive API.
|
|
57
|
+
const feishuTo = isComment
|
|
58
|
+
? ctx.chatId
|
|
59
|
+
: isGroup
|
|
60
|
+
? `chat:${ctx.chatId}`
|
|
61
|
+
: `user:${ctx.senderId}`;
|
|
62
|
+
const envelopeFrom = isGroup ? `${ctx.chatId}:${ctx.senderId}` : ctx.senderId;
|
|
63
|
+
const envelopeOptions = core.channel.reply.resolveEnvelopeFormatOptions(accountScopedCfg);
|
|
64
|
+
// ---- Route resolution ----
|
|
65
|
+
// Comment targets use the comment target as the peer ID so each
|
|
66
|
+
// comment thread gets its own session key.
|
|
67
|
+
const route = core.channel.routing.resolveAgentRoute({
|
|
68
|
+
cfg: accountScopedCfg,
|
|
69
|
+
channel: 'feishu',
|
|
70
|
+
accountId: account.accountId,
|
|
71
|
+
peer: isComment
|
|
72
|
+
? { kind: 'direct', id: ctx.chatId }
|
|
73
|
+
: {
|
|
74
|
+
kind: isGroup ? 'group' : 'direct',
|
|
75
|
+
id: isGroup ? ctx.chatId : ctx.senderId,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
// ---- System event ----
|
|
79
|
+
const sender = ctx.senderName ? `${ctx.senderName} (${ctx.senderId})` : ctx.senderId;
|
|
80
|
+
const location = isComment ? `comment ${ctx.chatId}` : isGroup ? `group ${ctx.chatId}` : 'DM';
|
|
81
|
+
const tags = [];
|
|
82
|
+
tags.push(`msg:${ctx.messageId}`);
|
|
83
|
+
if (ctx.parentId)
|
|
84
|
+
tags.push(`reply_to:${ctx.parentId}`);
|
|
85
|
+
if (ctx.contentType !== 'text')
|
|
86
|
+
tags.push(ctx.contentType);
|
|
87
|
+
if (ctx.mentions.some((m) => m.isBot))
|
|
88
|
+
tags.push('@bot');
|
|
89
|
+
if (ctx.threadId)
|
|
90
|
+
tags.push(`thread:${ctx.threadId}`);
|
|
91
|
+
if (ctx.resources.length > 0) {
|
|
92
|
+
tags.push(`${ctx.resources.length} attachment(s)`);
|
|
93
|
+
}
|
|
94
|
+
const tagStr = tags.length > 0 ? ` [${tags.join(', ')}]` : '';
|
|
95
|
+
core.system.enqueueSystemEvent(`Feishu[${account.accountId}] ${location} | ${sender}${tagStr}`, {
|
|
96
|
+
sessionKey: route.sessionKey,
|
|
97
|
+
contextKey: `feishu:message:${ctx.chatId}:${ctx.messageId}`,
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
ctx,
|
|
101
|
+
accountScopedCfg,
|
|
102
|
+
account,
|
|
103
|
+
runtime,
|
|
104
|
+
log,
|
|
105
|
+
error,
|
|
106
|
+
core,
|
|
107
|
+
isGroup,
|
|
108
|
+
isThread,
|
|
109
|
+
feishuFrom,
|
|
110
|
+
feishuTo,
|
|
111
|
+
envelopeFrom,
|
|
112
|
+
envelopeOptions,
|
|
113
|
+
route,
|
|
114
|
+
threadSessionKey: undefined,
|
|
115
|
+
commandAuthorized: params.commandAuthorized,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// Thread session resolution
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
/**
|
|
122
|
+
* Resolve thread session key for thread-capable groups.
|
|
123
|
+
*
|
|
124
|
+
* Returns a thread-scoped session key when ALL conditions are met:
|
|
125
|
+
* 1. `threadSession` config is enabled on the account
|
|
126
|
+
* 2. The group is a topic group (chat_mode=topic) or uses thread
|
|
127
|
+
* message mode (group_message_type=thread)
|
|
128
|
+
*
|
|
129
|
+
* The group info is fetched via `im.chat.get` with a 1-hour LRU cache
|
|
130
|
+
* to minimise OAPI calls.
|
|
131
|
+
*/
|
|
132
|
+
async function resolveThreadSessionKey(params) {
|
|
133
|
+
const { accountScopedCfg, account, chatId, threadId, baseSessionKey } = params;
|
|
134
|
+
if (account.config?.threadSession !== true)
|
|
135
|
+
return undefined;
|
|
136
|
+
const threadCapable = await (0, chat_info_cache_1.isThreadCapableGroup)({
|
|
137
|
+
cfg: accountScopedCfg,
|
|
138
|
+
chatId,
|
|
139
|
+
accountId: account.accountId,
|
|
140
|
+
});
|
|
141
|
+
if (!threadCapable) {
|
|
142
|
+
log.info(`thread session skipped: group ${chatId} is not topic/thread mode`);
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
// 使用 SDK 标准函数,保证分隔符格式与 resolveThreadParentSessionKey 兼容
|
|
146
|
+
const { sessionKey } = (0, routing_1.resolveThreadSessionKeys)({
|
|
147
|
+
baseSessionKey,
|
|
148
|
+
threadId,
|
|
149
|
+
parentSessionKey: baseSessionKey,
|
|
150
|
+
normalizeThreadId: (id) => id, // 飞书 thread ID (omt_xxx) 区分大小写,不做 lowercase
|
|
151
|
+
});
|
|
152
|
+
return sessionKey;
|
|
153
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Agent dispatch for inbound Feishu messages.
|
|
6
|
+
*
|
|
7
|
+
* Builds the agent envelope, prepends chat history context, and
|
|
8
|
+
* dispatches through the appropriate reply path (system command
|
|
9
|
+
* vs. normal streaming/static flow).
|
|
10
|
+
*
|
|
11
|
+
* Implementation details are split across focused modules:
|
|
12
|
+
* - dispatch-context.ts — DispatchContext type, route/session/event
|
|
13
|
+
* - dispatch-builders.ts — pure payload/body/envelope construction
|
|
14
|
+
* - dispatch-commands.ts — system command & permission notification
|
|
15
|
+
*/
|
|
16
|
+
import type { ClawdbotConfig, RuntimeEnv } from 'openclaw/plugin-sdk';
|
|
17
|
+
import type { HistoryEntry } from 'openclaw/plugin-sdk/reply-history';
|
|
18
|
+
import type { MessageContext } from '../types';
|
|
19
|
+
import type { FeishuGroupConfig, LarkAccount } from '../../core/types';
|
|
20
|
+
import type { PermissionError } from './permission';
|
|
21
|
+
export declare function dispatchToAgent(params: {
|
|
22
|
+
ctx: MessageContext;
|
|
23
|
+
permissionError?: PermissionError;
|
|
24
|
+
mediaPayload: Record<string, unknown>;
|
|
25
|
+
/** Additional structured metadata for synthetic or event-driven inbound flows. */
|
|
26
|
+
extraInboundFields?: Record<string, unknown>;
|
|
27
|
+
quotedContent?: string;
|
|
28
|
+
account: LarkAccount;
|
|
29
|
+
/** account 级别的 ClawdbotConfig(channels.feishu 已替换为 per-account 合并后的配置) */
|
|
30
|
+
accountScopedCfg: ClawdbotConfig;
|
|
31
|
+
runtime?: RuntimeEnv;
|
|
32
|
+
chatHistories?: Map<string, HistoryEntry[]>;
|
|
33
|
+
historyLimit: number;
|
|
34
|
+
/** Override the message ID used for reply threading. When set, the
|
|
35
|
+
* reply-dispatcher uses this ID for typing indicators and card replies
|
|
36
|
+
* instead of ctx.messageId (which may be a synthetic ID). */
|
|
37
|
+
replyToMessageId?: string;
|
|
38
|
+
/** When set, controls whether the sender is authorized to execute
|
|
39
|
+
* control commands. Computed by the handler via the SDK's access
|
|
40
|
+
* group command gating system. */
|
|
41
|
+
commandAuthorized?: boolean;
|
|
42
|
+
/** Per-group configuration for skills, systemPrompt, etc. */
|
|
43
|
+
groupConfig?: FeishuGroupConfig;
|
|
44
|
+
/** Default group configuration from the "*" wildcard entry. */
|
|
45
|
+
defaultGroupConfig?: FeishuGroupConfig;
|
|
46
|
+
/** When true, the reply dispatcher skips typing indicators. */
|
|
47
|
+
skipTyping?: boolean;
|
|
48
|
+
/** The receiving bot's own open_id, used for self-identity injection. */
|
|
49
|
+
botOpenId?: string;
|
|
50
|
+
}): Promise<void>;
|