@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,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* raw-request.ts — 飞书 Open API 裸 HTTP 请求工具。
|
|
7
|
+
*
|
|
8
|
+
* 从 tool-client.ts 提取,提供不依赖 SDK 的直接 API 调用能力。
|
|
9
|
+
* 用于 SDK 未覆盖的 API 或需要精细控制请求的场景。
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.resolveDomainUrl = resolveDomainUrl;
|
|
13
|
+
exports.rawLarkRequest = rawLarkRequest;
|
|
14
|
+
const node_url_1 = require("node:url");
|
|
15
|
+
const feishu_fetch_1 = require("./feishu-fetch.js");
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Domain URL resolution
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
/** 将 LarkBrand 映射为 API base URL。 */
|
|
20
|
+
function resolveDomainUrl(brand) {
|
|
21
|
+
const map = {
|
|
22
|
+
feishu: 'https://open.feishu.cn',
|
|
23
|
+
lark: 'https://open.larksuite.com',
|
|
24
|
+
};
|
|
25
|
+
return map[brand] ?? `https://${brand}`;
|
|
26
|
+
}
|
|
27
|
+
function isFormDataBody(body) {
|
|
28
|
+
return (typeof body === 'object' &&
|
|
29
|
+
body !== null &&
|
|
30
|
+
typeof body.append === 'function' &&
|
|
31
|
+
typeof body.entries === 'function');
|
|
32
|
+
}
|
|
33
|
+
function isBinaryBody(body) {
|
|
34
|
+
return body instanceof ArrayBuffer || ArrayBuffer.isView(body);
|
|
35
|
+
}
|
|
36
|
+
function buildRequestBody(body) {
|
|
37
|
+
if (typeof body === 'string' || body instanceof node_url_1.URLSearchParams || isFormDataBody(body) || isBinaryBody(body)) {
|
|
38
|
+
return { body: body };
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
headers: { 'Content-Type': 'application/json' },
|
|
42
|
+
body: JSON.stringify(body),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 发起 raw HTTP 请求到飞书 API,自动处理域名解析、header 注入和错误检测。
|
|
47
|
+
*
|
|
48
|
+
* 飞书 API 统一错误模式:返回 JSON 中 `code !== 0` 表示失败。
|
|
49
|
+
*/
|
|
50
|
+
async function rawLarkRequest(options) {
|
|
51
|
+
const baseUrl = resolveDomainUrl(options.brand);
|
|
52
|
+
const url = new URL(options.path, baseUrl);
|
|
53
|
+
if (options.query) {
|
|
54
|
+
for (const [k, v] of Object.entries(options.query)) {
|
|
55
|
+
url.searchParams.set(k, v);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const headers = {};
|
|
59
|
+
let requestBody;
|
|
60
|
+
if (options.accessToken) {
|
|
61
|
+
headers['Authorization'] = `Bearer ${options.accessToken}`;
|
|
62
|
+
}
|
|
63
|
+
if (options.body !== undefined) {
|
|
64
|
+
const prepared = buildRequestBody(options.body);
|
|
65
|
+
requestBody = prepared.body;
|
|
66
|
+
if (prepared.headers) {
|
|
67
|
+
Object.assign(headers, prepared.headers);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (options.headers) {
|
|
71
|
+
Object.assign(headers, options.headers);
|
|
72
|
+
}
|
|
73
|
+
const resp = await (0, feishu_fetch_1.feishuFetch)(url.toString(), {
|
|
74
|
+
method: options.method ?? 'GET',
|
|
75
|
+
headers,
|
|
76
|
+
...(requestBody !== undefined ? { body: requestBody } : {}),
|
|
77
|
+
});
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
const data = (await resp.json());
|
|
80
|
+
// 飞书 API 统一错误模式:code !== 0
|
|
81
|
+
if (data.code !== undefined && data.code !== 0) {
|
|
82
|
+
const err = new Error(data.msg ?? `Lark API error: code=${data.code}`);
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
err.code = data.code;
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
err.msg = data.msg;
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
return data;
|
|
90
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Shared runtime store for the Feishu plugin.
|
|
6
|
+
*
|
|
7
|
+
* Allows modules such as the logger to access the plugin runtime without
|
|
8
|
+
* importing LarkClient directly, which would otherwise create static cycles.
|
|
9
|
+
*/
|
|
10
|
+
import type { PluginRuntime } from 'openclaw/plugin-sdk';
|
|
11
|
+
export declare function setLarkRuntime(nextRuntime: PluginRuntime): void;
|
|
12
|
+
export declare function tryGetLarkRuntime(): PluginRuntime | null;
|
|
13
|
+
export declare function getLarkRuntime(): PluginRuntime;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Shared runtime store for the Feishu plugin.
|
|
7
|
+
*
|
|
8
|
+
* Allows modules such as the logger to access the plugin runtime without
|
|
9
|
+
* importing LarkClient directly, which would otherwise create static cycles.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.setLarkRuntime = setLarkRuntime;
|
|
13
|
+
exports.tryGetLarkRuntime = tryGetLarkRuntime;
|
|
14
|
+
exports.getLarkRuntime = getLarkRuntime;
|
|
15
|
+
const RUNTIME_NOT_INITIALIZED_ERROR = 'Feishu plugin runtime has not been initialised. ' +
|
|
16
|
+
'Ensure LarkClient.setRuntime() is called during plugin activation.';
|
|
17
|
+
let runtime = null;
|
|
18
|
+
function setLarkRuntime(nextRuntime) {
|
|
19
|
+
runtime = nextRuntime;
|
|
20
|
+
}
|
|
21
|
+
function tryGetLarkRuntime() {
|
|
22
|
+
return runtime;
|
|
23
|
+
}
|
|
24
|
+
function getLarkRuntime() {
|
|
25
|
+
if (!runtime) {
|
|
26
|
+
throw new Error(RUNTIME_NOT_INITIALIZED_ERROR);
|
|
27
|
+
}
|
|
28
|
+
return runtime;
|
|
29
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Scope 管理模块
|
|
6
|
+
*
|
|
7
|
+
* 为所有工具动作提供类型安全的 scope 查询和检查功能。
|
|
8
|
+
*
|
|
9
|
+
* ## 三个核心概念
|
|
10
|
+
*
|
|
11
|
+
* ### 1. Required Scopes(API 需要的权限)
|
|
12
|
+
* - 定义:每个 API 调用所需的飞书权限列表
|
|
13
|
+
* - 来源:tool-scopes.ts(手动维护的类型化配置)
|
|
14
|
+
* - 示例:`["calendar:calendar.event:create", "calendar:calendar.event:update"]`
|
|
15
|
+
* - 用途:判断应用和用户是否需要申请/授权权限
|
|
16
|
+
*
|
|
17
|
+
* ### 2. App Granted Scopes(应用已开通的权限)
|
|
18
|
+
* - 定义:应用在飞书开放平台配置并获得管理员批准的权限
|
|
19
|
+
* - 来源:通过 API 查询 `/open-apis/application/v6/applications`
|
|
20
|
+
* - 作用:应用级权限前置检查,避免无效的用户授权请求
|
|
21
|
+
* - 检查时机:在请求用户授权前
|
|
22
|
+
*
|
|
23
|
+
* ### 3. User Granted Scopes(用户授权的权限)
|
|
24
|
+
* - 定义:用户通过 OAuth 流程明确授权给应用的权限
|
|
25
|
+
* - 来源:OAuth token 中的 scope 字段
|
|
26
|
+
* - 作用:用户级权限检查,确保用户已授权所需权限
|
|
27
|
+
* - 检查时机:每次 API 调用前
|
|
28
|
+
*
|
|
29
|
+
* ## 权限检查流程
|
|
30
|
+
*
|
|
31
|
+
* ```
|
|
32
|
+
* 1. 获取 Required Scopes (API 需要什么权限?)
|
|
33
|
+
* ↓
|
|
34
|
+
* 2. 检查 App Granted Scopes (应用开通了吗?)
|
|
35
|
+
* ↓ 是
|
|
36
|
+
* 3. 检查 User Granted Scopes (用户授权了吗?)
|
|
37
|
+
* ↓ 是
|
|
38
|
+
* 4. 调用 API
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
import { TOOL_SCOPES, type ToolActionKey, type ToolScopeMapping } from './tool-scopes';
|
|
42
|
+
export type { ToolActionKey, ToolScopeMapping };
|
|
43
|
+
export { TOOL_SCOPES };
|
|
44
|
+
/**
|
|
45
|
+
* 获取单个工具动作所需的 scopes(Required Scopes)
|
|
46
|
+
*
|
|
47
|
+
* @param toolAction - 工具动作键(例如 "feishu_calendar_event.create")
|
|
48
|
+
* @returns API 需要的 scope 字符串数组
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const requiredScopes = getRequiredScopes("feishu_calendar_event.create");
|
|
53
|
+
* // 返回: ["calendar:calendar.event:create", "calendar:calendar.event:update"]
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function getRequiredScopes(toolAction: ToolActionKey): string[];
|
|
57
|
+
/**
|
|
58
|
+
* 获取多个工具动作的合并 Required Scopes(去重)
|
|
59
|
+
*
|
|
60
|
+
* @param toolActions - 工具动作键数组
|
|
61
|
+
* @returns 去重并排序后的 scope 字符串数组
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const requiredScopes = getRequiredScopesForActions([
|
|
66
|
+
* "feishu_calendar_event.create",
|
|
67
|
+
* "feishu_calendar_event.list"
|
|
68
|
+
* ]);
|
|
69
|
+
* // 返回两个动作的所有唯一 scopes
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function getRequiredScopesForActions(toolActions: ToolActionKey[]): string[];
|
|
73
|
+
/**
|
|
74
|
+
* 检查工具动作是否需要任何 scope
|
|
75
|
+
*
|
|
76
|
+
* @param toolAction - 工具动作键
|
|
77
|
+
* @returns 如果动作需要至少一个 scope 则返回 true
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* hasRequiredScopes("feishu_calendar_event.create"); // true
|
|
82
|
+
* hasRequiredScopes("feishu_sheets_spreadsheet.create"); // false (空数组)
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function hasRequiredScopes(toolAction: ToolActionKey): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* 获取需要特定 scope 的所有工具动作
|
|
88
|
+
*
|
|
89
|
+
* @param scope - Scope 字符串(例如 "calendar:calendar.event:create")
|
|
90
|
+
* @returns 需要此 scope 的工具动作键数组
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* const actions = getActionsForScope("calendar:calendar.event:create");
|
|
95
|
+
* // 返回: ["feishu_calendar_event.create"]
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function getActionsForScope(scope: string): ToolActionKey[];
|
|
99
|
+
/**
|
|
100
|
+
* 检查应用是否开通了工具动作所需的所有权限(App Granted Scopes)
|
|
101
|
+
*
|
|
102
|
+
* @param toolAction - 工具动作键
|
|
103
|
+
* @param appGrantedScopes - 应用已开通的 scope 集合(来自开放平台)
|
|
104
|
+
* @returns 如果应用已开通所有必需的 scopes 则返回 true
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const appScopes = new Set([
|
|
109
|
+
* "calendar:calendar.event:create",
|
|
110
|
+
* "calendar:calendar.event:update"
|
|
111
|
+
* ]);
|
|
112
|
+
* checkAppScopes("feishu_calendar_event.create", appScopes); // true
|
|
113
|
+
*
|
|
114
|
+
* const partialAppScopes = new Set(["calendar:calendar.event:create"]);
|
|
115
|
+
* checkAppScopes("feishu_calendar_event.create", partialAppScopes); // false
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare function checkAppScopes(toolAction: ToolActionKey, appGrantedScopes: Set<string> | string[]): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* 获取应用未开通的 scopes
|
|
121
|
+
*
|
|
122
|
+
* @param toolAction - 工具动作键
|
|
123
|
+
* @param appGrantedScopes - 应用已开通的 scope 集合
|
|
124
|
+
* @returns 应用未开通的 scope 字符串数组
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* const appScopes = new Set(["calendar:calendar.event:create"]);
|
|
129
|
+
* const missing = getMissingAppScopes("feishu_calendar_event.create", appScopes);
|
|
130
|
+
* // 返回: ["calendar:calendar.event:update"]
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function getMissingAppScopes(toolAction: ToolActionKey, appGrantedScopes: Set<string> | string[]): string[];
|
|
134
|
+
/**
|
|
135
|
+
* 检查用户是否授权了工具动作所需的所有权限(User Granted Scopes)
|
|
136
|
+
*
|
|
137
|
+
* @param toolAction - 工具动作键
|
|
138
|
+
* @param userGrantedScopes - 用户已授权的 scope 集合(来自 OAuth token)
|
|
139
|
+
* @returns 如果用户已授权所有必需的 scopes 则返回 true
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* const userScopes = new Set([
|
|
144
|
+
* "calendar:calendar.event:create",
|
|
145
|
+
* "calendar:calendar.event:update"
|
|
146
|
+
* ]);
|
|
147
|
+
* checkUserScopes("feishu_calendar_event.create", userScopes); // true
|
|
148
|
+
*
|
|
149
|
+
* const partialUserScopes = new Set(["calendar:calendar.event:create"]);
|
|
150
|
+
* checkUserScopes("feishu_calendar_event.create", partialUserScopes); // false
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare function checkUserScopes(toolAction: ToolActionKey, userGrantedScopes: Set<string> | string[]): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* 获取用户未授权的 scopes
|
|
156
|
+
*
|
|
157
|
+
* @param toolAction - 工具动作键
|
|
158
|
+
* @param userGrantedScopes - 用户已授权的 scope 集合
|
|
159
|
+
* @returns 用户未授权的 scope 字符串数组
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const userScopes = new Set(["calendar:calendar.event:create"]);
|
|
164
|
+
* const missing = getMissingUserScopes("feishu_calendar_event.create", userScopes);
|
|
165
|
+
* // 返回: ["calendar:calendar.event:update"]
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
export declare function getMissingUserScopes(toolAction: ToolActionKey, userGrantedScopes: Set<string> | string[]): string[];
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Scope 管理模块
|
|
7
|
+
*
|
|
8
|
+
* 为所有工具动作提供类型安全的 scope 查询和检查功能。
|
|
9
|
+
*
|
|
10
|
+
* ## 三个核心概念
|
|
11
|
+
*
|
|
12
|
+
* ### 1. Required Scopes(API 需要的权限)
|
|
13
|
+
* - 定义:每个 API 调用所需的飞书权限列表
|
|
14
|
+
* - 来源:tool-scopes.ts(手动维护的类型化配置)
|
|
15
|
+
* - 示例:`["calendar:calendar.event:create", "calendar:calendar.event:update"]`
|
|
16
|
+
* - 用途:判断应用和用户是否需要申请/授权权限
|
|
17
|
+
*
|
|
18
|
+
* ### 2. App Granted Scopes(应用已开通的权限)
|
|
19
|
+
* - 定义:应用在飞书开放平台配置并获得管理员批准的权限
|
|
20
|
+
* - 来源:通过 API 查询 `/open-apis/application/v6/applications`
|
|
21
|
+
* - 作用:应用级权限前置检查,避免无效的用户授权请求
|
|
22
|
+
* - 检查时机:在请求用户授权前
|
|
23
|
+
*
|
|
24
|
+
* ### 3. User Granted Scopes(用户授权的权限)
|
|
25
|
+
* - 定义:用户通过 OAuth 流程明确授权给应用的权限
|
|
26
|
+
* - 来源:OAuth token 中的 scope 字段
|
|
27
|
+
* - 作用:用户级权限检查,确保用户已授权所需权限
|
|
28
|
+
* - 检查时机:每次 API 调用前
|
|
29
|
+
*
|
|
30
|
+
* ## 权限检查流程
|
|
31
|
+
*
|
|
32
|
+
* ```
|
|
33
|
+
* 1. 获取 Required Scopes (API 需要什么权限?)
|
|
34
|
+
* ↓
|
|
35
|
+
* 2. 检查 App Granted Scopes (应用开通了吗?)
|
|
36
|
+
* ↓ 是
|
|
37
|
+
* 3. 检查 User Granted Scopes (用户授权了吗?)
|
|
38
|
+
* ↓ 是
|
|
39
|
+
* 4. 调用 API
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.TOOL_SCOPES = void 0;
|
|
44
|
+
exports.getRequiredScopes = getRequiredScopes;
|
|
45
|
+
exports.getRequiredScopesForActions = getRequiredScopesForActions;
|
|
46
|
+
exports.hasRequiredScopes = hasRequiredScopes;
|
|
47
|
+
exports.getActionsForScope = getActionsForScope;
|
|
48
|
+
exports.checkAppScopes = checkAppScopes;
|
|
49
|
+
exports.getMissingAppScopes = getMissingAppScopes;
|
|
50
|
+
exports.checkUserScopes = checkUserScopes;
|
|
51
|
+
exports.getMissingUserScopes = getMissingUserScopes;
|
|
52
|
+
const tool_scopes_1 = require("./tool-scopes.js");
|
|
53
|
+
Object.defineProperty(exports, "TOOL_SCOPES", { enumerable: true, get: function () { return tool_scopes_1.TOOL_SCOPES; } });
|
|
54
|
+
// ===== 函数:Required Scopes(API 需要的权限)=====
|
|
55
|
+
/**
|
|
56
|
+
* 获取单个工具动作所需的 scopes(Required Scopes)
|
|
57
|
+
*
|
|
58
|
+
* @param toolAction - 工具动作键(例如 "feishu_calendar_event.create")
|
|
59
|
+
* @returns API 需要的 scope 字符串数组
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const requiredScopes = getRequiredScopes("feishu_calendar_event.create");
|
|
64
|
+
* // 返回: ["calendar:calendar.event:create", "calendar:calendar.event:update"]
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
function getRequiredScopes(toolAction) {
|
|
68
|
+
return tool_scopes_1.TOOL_SCOPES[toolAction] ?? [];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 获取多个工具动作的合并 Required Scopes(去重)
|
|
72
|
+
*
|
|
73
|
+
* @param toolActions - 工具动作键数组
|
|
74
|
+
* @returns 去重并排序后的 scope 字符串数组
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const requiredScopes = getRequiredScopesForActions([
|
|
79
|
+
* "feishu_calendar_event.create",
|
|
80
|
+
* "feishu_calendar_event.list"
|
|
81
|
+
* ]);
|
|
82
|
+
* // 返回两个动作的所有唯一 scopes
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
function getRequiredScopesForActions(toolActions) {
|
|
86
|
+
const scopesSet = new Set();
|
|
87
|
+
for (const action of toolActions) {
|
|
88
|
+
const scopes = getRequiredScopes(action);
|
|
89
|
+
scopes.forEach((scope) => scopesSet.add(scope));
|
|
90
|
+
}
|
|
91
|
+
return Array.from(scopesSet).sort();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 检查工具动作是否需要任何 scope
|
|
95
|
+
*
|
|
96
|
+
* @param toolAction - 工具动作键
|
|
97
|
+
* @returns 如果动作需要至少一个 scope 则返回 true
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* hasRequiredScopes("feishu_calendar_event.create"); // true
|
|
102
|
+
* hasRequiredScopes("feishu_sheets_spreadsheet.create"); // false (空数组)
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
function hasRequiredScopes(toolAction) {
|
|
106
|
+
return getRequiredScopes(toolAction).length > 0;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 获取需要特定 scope 的所有工具动作
|
|
110
|
+
*
|
|
111
|
+
* @param scope - Scope 字符串(例如 "calendar:calendar.event:create")
|
|
112
|
+
* @returns 需要此 scope 的工具动作键数组
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* const actions = getActionsForScope("calendar:calendar.event:create");
|
|
117
|
+
* // 返回: ["feishu_calendar_event.create"]
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
function getActionsForScope(scope) {
|
|
121
|
+
const actions = [];
|
|
122
|
+
for (const [action, scopes] of Object.entries(tool_scopes_1.TOOL_SCOPES)) {
|
|
123
|
+
if (scopes.includes(scope)) {
|
|
124
|
+
actions.push(action);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return actions;
|
|
128
|
+
}
|
|
129
|
+
// ===== 函数:App Scope 检查 =====
|
|
130
|
+
/**
|
|
131
|
+
* 检查应用是否开通了工具动作所需的所有权限(App Granted Scopes)
|
|
132
|
+
*
|
|
133
|
+
* @param toolAction - 工具动作键
|
|
134
|
+
* @param appGrantedScopes - 应用已开通的 scope 集合(来自开放平台)
|
|
135
|
+
* @returns 如果应用已开通所有必需的 scopes 则返回 true
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const appScopes = new Set([
|
|
140
|
+
* "calendar:calendar.event:create",
|
|
141
|
+
* "calendar:calendar.event:update"
|
|
142
|
+
* ]);
|
|
143
|
+
* checkAppScopes("feishu_calendar_event.create", appScopes); // true
|
|
144
|
+
*
|
|
145
|
+
* const partialAppScopes = new Set(["calendar:calendar.event:create"]);
|
|
146
|
+
* checkAppScopes("feishu_calendar_event.create", partialAppScopes); // false
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
function checkAppScopes(toolAction, appGrantedScopes) {
|
|
150
|
+
const requiredScopes = getRequiredScopes(toolAction);
|
|
151
|
+
// 如果不需要任何 scope,则总是满足要求
|
|
152
|
+
if (requiredScopes.length === 0) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
const grantedSet = Array.isArray(appGrantedScopes) ? new Set(appGrantedScopes) : appGrantedScopes;
|
|
156
|
+
return requiredScopes.every((scope) => grantedSet.has(scope));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 获取应用未开通的 scopes
|
|
160
|
+
*
|
|
161
|
+
* @param toolAction - 工具动作键
|
|
162
|
+
* @param appGrantedScopes - 应用已开通的 scope 集合
|
|
163
|
+
* @returns 应用未开通的 scope 字符串数组
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* const appScopes = new Set(["calendar:calendar.event:create"]);
|
|
168
|
+
* const missing = getMissingAppScopes("feishu_calendar_event.create", appScopes);
|
|
169
|
+
* // 返回: ["calendar:calendar.event:update"]
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
function getMissingAppScopes(toolAction, appGrantedScopes) {
|
|
173
|
+
const requiredScopes = getRequiredScopes(toolAction);
|
|
174
|
+
const grantedSet = Array.isArray(appGrantedScopes) ? new Set(appGrantedScopes) : appGrantedScopes;
|
|
175
|
+
return requiredScopes.filter((scope) => !grantedSet.has(scope));
|
|
176
|
+
}
|
|
177
|
+
// ===== 函数:User Scope 检查 =====
|
|
178
|
+
/**
|
|
179
|
+
* 检查用户是否授权了工具动作所需的所有权限(User Granted Scopes)
|
|
180
|
+
*
|
|
181
|
+
* @param toolAction - 工具动作键
|
|
182
|
+
* @param userGrantedScopes - 用户已授权的 scope 集合(来自 OAuth token)
|
|
183
|
+
* @returns 如果用户已授权所有必需的 scopes 则返回 true
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* const userScopes = new Set([
|
|
188
|
+
* "calendar:calendar.event:create",
|
|
189
|
+
* "calendar:calendar.event:update"
|
|
190
|
+
* ]);
|
|
191
|
+
* checkUserScopes("feishu_calendar_event.create", userScopes); // true
|
|
192
|
+
*
|
|
193
|
+
* const partialUserScopes = new Set(["calendar:calendar.event:create"]);
|
|
194
|
+
* checkUserScopes("feishu_calendar_event.create", partialUserScopes); // false
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
function checkUserScopes(toolAction, userGrantedScopes) {
|
|
198
|
+
const requiredScopes = getRequiredScopes(toolAction);
|
|
199
|
+
// 如果不需要任何 scope,则总是满足要求
|
|
200
|
+
if (requiredScopes.length === 0) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
const grantedSet = Array.isArray(userGrantedScopes) ? new Set(userGrantedScopes) : userGrantedScopes;
|
|
204
|
+
return requiredScopes.every((scope) => grantedSet.has(scope));
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* 获取用户未授权的 scopes
|
|
208
|
+
*
|
|
209
|
+
* @param toolAction - 工具动作键
|
|
210
|
+
* @param userGrantedScopes - 用户已授权的 scope 集合
|
|
211
|
+
* @returns 用户未授权的 scope 字符串数组
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* const userScopes = new Set(["calendar:calendar.event:create"]);
|
|
216
|
+
* const missing = getMissingUserScopes("feishu_calendar_event.create", userScopes);
|
|
217
|
+
* // 返回: ["calendar:calendar.event:update"]
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
function getMissingUserScopes(toolAction, userGrantedScopes) {
|
|
221
|
+
const requiredScopes = getRequiredScopes(toolAction);
|
|
222
|
+
const grantedSet = Array.isArray(userGrantedScopes) ? new Set(userGrantedScopes) : userGrantedScopes;
|
|
223
|
+
return requiredScopes.filter((scope) => !grantedSet.has(scope));
|
|
224
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Local shim for readReactionParams whose SDK signature changed in
|
|
6
|
+
* 2026.3.14 (now requires a channel-specific config object).
|
|
7
|
+
* Re-exports jsonResult from the SDK directly.
|
|
8
|
+
*/
|
|
9
|
+
export { jsonResult } from 'openclaw/plugin-sdk/agent-runtime';
|
|
10
|
+
/**
|
|
11
|
+
* Extract reaction parameters from raw action params.
|
|
12
|
+
* Returns emoji, remove flag, and isEmpty indicator.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readReactionParams(params: Record<string, unknown>, opts?: {
|
|
15
|
+
removeErrorMessage?: string;
|
|
16
|
+
}): {
|
|
17
|
+
emoji: string;
|
|
18
|
+
remove: boolean;
|
|
19
|
+
isEmpty: boolean;
|
|
20
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Local shim for readReactionParams whose SDK signature changed in
|
|
7
|
+
* 2026.3.14 (now requires a channel-specific config object).
|
|
8
|
+
* Re-exports jsonResult from the SDK directly.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.jsonResult = void 0;
|
|
12
|
+
exports.readReactionParams = readReactionParams;
|
|
13
|
+
var agent_runtime_1 = require("openclaw/plugin-sdk/agent-runtime");
|
|
14
|
+
Object.defineProperty(exports, "jsonResult", { enumerable: true, get: function () { return agent_runtime_1.jsonResult; } });
|
|
15
|
+
/**
|
|
16
|
+
* Extract reaction parameters from raw action params.
|
|
17
|
+
* Returns emoji, remove flag, and isEmpty indicator.
|
|
18
|
+
*/
|
|
19
|
+
function readReactionParams(params, opts) {
|
|
20
|
+
const raw = params.emoji ?? params.reaction ?? params.type;
|
|
21
|
+
const emoji = typeof raw === 'string' ? raw.trim() : '';
|
|
22
|
+
const remove = Boolean(params.remove ?? params.unreact);
|
|
23
|
+
const isEmpty = !emoji && !remove;
|
|
24
|
+
if (remove && !emoji && opts?.removeErrorMessage) {
|
|
25
|
+
throw new Error(opts.removeErrorMessage);
|
|
26
|
+
}
|
|
27
|
+
return { emoji, remove, isEmpty };
|
|
28
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Multi-account isolation checks.
|
|
6
|
+
*
|
|
7
|
+
* Detects potentially unsafe configurations where multiple Feishu accounts
|
|
8
|
+
* belonging to different tenants (different appId) share the default agent
|
|
9
|
+
* without proper isolation via agents + bindings.
|
|
10
|
+
*/
|
|
11
|
+
import type { ClawdbotConfig } from 'openclaw/plugin-sdk';
|
|
12
|
+
import type { LarkAccount } from './types';
|
|
13
|
+
export type IsolationStatus =
|
|
14
|
+
/** Single account / same appId / no multi-tenant concern */
|
|
15
|
+
{
|
|
16
|
+
mode: 'not-applicable';
|
|
17
|
+
}
|
|
18
|
+
/** All accounts have bindings pointing to different agents */
|
|
19
|
+
| {
|
|
20
|
+
mode: 'isolated';
|
|
21
|
+
accounts: LarkAccount[];
|
|
22
|
+
}
|
|
23
|
+
/** All accounts have bindings but share the same agent (explicit choice) */
|
|
24
|
+
| {
|
|
25
|
+
mode: 'shared-explicit';
|
|
26
|
+
accounts: LarkAccount[];
|
|
27
|
+
sharedAgentId: string;
|
|
28
|
+
}
|
|
29
|
+
/** Some or all accounts have no bindings — implicit sharing, risky */
|
|
30
|
+
| {
|
|
31
|
+
mode: 'shared-implicit';
|
|
32
|
+
accounts: LarkAccount[];
|
|
33
|
+
unboundAccounts: LarkAccount[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Diagnose whether multiple enabled accounts from different tenants
|
|
37
|
+
* are properly isolated via agent bindings.
|
|
38
|
+
*/
|
|
39
|
+
export declare function checkMultiAccountIsolation(cfg: ClawdbotConfig): IsolationStatus;
|
|
40
|
+
/**
|
|
41
|
+
* Check whether `session.dmScope` is set to per-account isolation.
|
|
42
|
+
*
|
|
43
|
+
* Without this setting, different bots talking to the same user share
|
|
44
|
+
* the same session — even if agent bindings are configured.
|
|
45
|
+
*/
|
|
46
|
+
export declare function needsDmScopeFix(cfg: ClawdbotConfig): boolean;
|
|
47
|
+
/** Return the fix command string, or null if not needed. */
|
|
48
|
+
export declare function getDmScopeFixCommand(cfg: ClawdbotConfig): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Generate a combined warning block for doctor / start.
|
|
51
|
+
* Returns null when everything is fine.
|
|
52
|
+
*/
|
|
53
|
+
export declare function formatIsolationWarning(status: IsolationStatus, cfg?: ClawdbotConfig): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Generate `openclaw config set` commands for per-account isolation.
|
|
56
|
+
*/
|
|
57
|
+
export declare function generateIsolationFixCommands(cfg: ClawdbotConfig): {
|
|
58
|
+
commands: string[];
|
|
59
|
+
preview: string;
|
|
60
|
+
} | null;
|
|
61
|
+
/**
|
|
62
|
+
* Generate commands for explicitly sharing the same agent across accounts.
|
|
63
|
+
*/
|
|
64
|
+
export declare function generateSharedAgentCommands(cfg: ClawdbotConfig): {
|
|
65
|
+
commands: string[];
|
|
66
|
+
preview: string;
|
|
67
|
+
} | null;
|
|
68
|
+
export declare function collectIsolationWarnings(_cfg: ClawdbotConfig): string[];
|
|
69
|
+
export declare function emitSecurityWarnings(_cfg: ClawdbotConfig, _logger: {
|
|
70
|
+
warn?: (msg: string) => void;
|
|
71
|
+
info?: (msg: string) => void;
|
|
72
|
+
}): void;
|