@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,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* UAT 用户名解析模块
|
|
7
|
+
*
|
|
8
|
+
* 独立于 messaging/inbound 层的 TAT UserNameCache,
|
|
9
|
+
* 用于工具层以用户身份(UAT)批量解析用户显示名。
|
|
10
|
+
*
|
|
11
|
+
* 设计动机:TAT 调用 contact/v3/users/batch 缺少权限导致返回的用户
|
|
12
|
+
* 条目不含 name 字段,而工具层搜索消息等场景运行在 UAT 上下文中,
|
|
13
|
+
* 用户 token 可以读取其他用户的名称。
|
|
14
|
+
*
|
|
15
|
+
* 底层使用 contact/v3/users/basic_batch 接口(scope: contact:user.basic_profile:readonly),
|
|
16
|
+
* 每次最多查询 10 个用户。
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.getUATUserName = getUATUserName;
|
|
20
|
+
exports.setUATUserNames = setUATUserNames;
|
|
21
|
+
exports.batchResolveUserNamesAsUser = batchResolveUserNamesAsUser;
|
|
22
|
+
const helpers_1 = require("../helpers.js");
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// 独立缓存:accountId → Map<openId, { name, expireAt }>
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
const UAT_MAX_SIZE = 500;
|
|
27
|
+
const UAT_TTL_MS = 30 * 60 * 1000; // 30 分钟
|
|
28
|
+
const uatRegistry = new Map();
|
|
29
|
+
function getOrCreateCache(accountId) {
|
|
30
|
+
let cache = uatRegistry.get(accountId);
|
|
31
|
+
if (!cache) {
|
|
32
|
+
cache = new Map();
|
|
33
|
+
uatRegistry.set(accountId, cache);
|
|
34
|
+
}
|
|
35
|
+
return cache;
|
|
36
|
+
}
|
|
37
|
+
function evict(cache) {
|
|
38
|
+
while (cache.size > UAT_MAX_SIZE) {
|
|
39
|
+
const oldest = cache.keys().next().value;
|
|
40
|
+
if (oldest !== undefined)
|
|
41
|
+
cache.delete(oldest);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** 从 UAT 缓存中获取用户名 */
|
|
45
|
+
function getUATUserName(accountId, openId) {
|
|
46
|
+
const cache = uatRegistry.get(accountId);
|
|
47
|
+
if (!cache)
|
|
48
|
+
return undefined;
|
|
49
|
+
const entry = cache.get(openId);
|
|
50
|
+
if (!entry)
|
|
51
|
+
return undefined;
|
|
52
|
+
if (entry.expireAt <= Date.now()) {
|
|
53
|
+
cache.delete(openId);
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
// LRU refresh
|
|
57
|
+
cache.delete(openId);
|
|
58
|
+
cache.set(openId, entry);
|
|
59
|
+
return entry.name;
|
|
60
|
+
}
|
|
61
|
+
/** 批量写入 UAT 缓存 */
|
|
62
|
+
function setUATUserNames(accountId, entries) {
|
|
63
|
+
const cache = getOrCreateCache(accountId);
|
|
64
|
+
const now = Date.now();
|
|
65
|
+
for (const [openId, name] of entries) {
|
|
66
|
+
cache.delete(openId);
|
|
67
|
+
cache.set(openId, { name, expireAt: now + UAT_TTL_MS });
|
|
68
|
+
}
|
|
69
|
+
evict(cache);
|
|
70
|
+
}
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
// 以 UAT 身份批量解析用户名
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
const BATCH_SIZE = 10; // basic_batch API 限制每次最多 10 个
|
|
75
|
+
async function batchResolveUserNamesAsUser(params) {
|
|
76
|
+
const { client, openIds, log } = params;
|
|
77
|
+
if (openIds.length === 0)
|
|
78
|
+
return new Map();
|
|
79
|
+
const accountId = client.account.accountId;
|
|
80
|
+
const cache = getOrCreateCache(accountId);
|
|
81
|
+
const result = new Map();
|
|
82
|
+
const now = Date.now();
|
|
83
|
+
// 1. 从缓存读取已有的
|
|
84
|
+
const missing = [];
|
|
85
|
+
for (const id of openIds) {
|
|
86
|
+
const entry = cache.get(id);
|
|
87
|
+
if (entry && entry.expireAt > now) {
|
|
88
|
+
result.set(id, entry.name);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
if (entry)
|
|
92
|
+
cache.delete(id);
|
|
93
|
+
missing.push(id);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// 去重
|
|
97
|
+
const uniqueMissing = [...new Set(missing)];
|
|
98
|
+
if (uniqueMissing.length === 0)
|
|
99
|
+
return result;
|
|
100
|
+
// 2. 分批通过 SDK 调用 contact/v3/users/basic_batch(UAT)
|
|
101
|
+
const totalBatches = Math.ceil(uniqueMissing.length / BATCH_SIZE);
|
|
102
|
+
log(`batchResolveUserNamesAsUser: resolving ${uniqueMissing.length} user(s) in ${totalBatches} batch(es), ${result.size} cache hit(s)`);
|
|
103
|
+
for (let i = 0; i < uniqueMissing.length; i += BATCH_SIZE) {
|
|
104
|
+
const chunk = uniqueMissing.slice(i, i + BATCH_SIZE);
|
|
105
|
+
const batchIndex = Math.floor(i / BATCH_SIZE) + 1;
|
|
106
|
+
try {
|
|
107
|
+
const res = await client.invoke('feishu_get_user.basic_batch', (sdk, opts) => sdk.request({
|
|
108
|
+
method: 'POST',
|
|
109
|
+
url: '/open-apis/contact/v3/users/basic_batch',
|
|
110
|
+
data: { user_ids: chunk },
|
|
111
|
+
params: { user_id_type: 'open_id' },
|
|
112
|
+
}, opts), {
|
|
113
|
+
as: 'user',
|
|
114
|
+
});
|
|
115
|
+
const users = res?.data?.users ?? [];
|
|
116
|
+
let resolved = 0;
|
|
117
|
+
for (const user of users) {
|
|
118
|
+
const openId = user.user_id;
|
|
119
|
+
// 实际返回 name 为字符串,兼容文档中 name.value 的对象结构
|
|
120
|
+
const rawName = user.name;
|
|
121
|
+
const name = typeof rawName === 'string' ? rawName : rawName?.value;
|
|
122
|
+
if (openId && name) {
|
|
123
|
+
cache.delete(openId);
|
|
124
|
+
cache.set(openId, { name, expireAt: Date.now() + UAT_TTL_MS });
|
|
125
|
+
result.set(openId, name);
|
|
126
|
+
resolved++;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const unresolvedCount = chunk.length - resolved;
|
|
130
|
+
if (unresolvedCount > 0) {
|
|
131
|
+
log(`batchResolveUserNamesAsUser: batch ${batchIndex}/${totalBatches}: ${resolved} resolved, ${unresolvedCount} missing name`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
// 授权/权限错误向上冒泡,由上层 handleInvokeErrorWithAutoAuth 处理自动授权
|
|
136
|
+
if ((0, helpers_1.isInvokeError)(err))
|
|
137
|
+
throw err;
|
|
138
|
+
log(`batchResolveUserNamesAsUser: failed: ${String(err)}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
evict(cache);
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* OAPI Tools Index
|
|
6
|
+
*
|
|
7
|
+
* This module registers all tools that directly use Feishu Open API (OAPI).
|
|
8
|
+
* These tools are placed here to distinguish them from MCP-based tools.
|
|
9
|
+
*/
|
|
10
|
+
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk';
|
|
11
|
+
export declare function registerOapiTools(api: OpenClawPluginApi): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* OAPI Tools Index
|
|
7
|
+
*
|
|
8
|
+
* This module registers all tools that directly use Feishu Open API (OAPI).
|
|
9
|
+
* These tools are placed here to distinguish them from MCP-based tools.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.registerOapiTools = registerOapiTools;
|
|
13
|
+
const index_1 = require("../tat/im/index.js");
|
|
14
|
+
const index_2 = require("./calendar/index.js");
|
|
15
|
+
const index_3 = require("./task/index.js");
|
|
16
|
+
const index_4 = require("./bitable/index.js");
|
|
17
|
+
const index_5 = require("./common/index.js");
|
|
18
|
+
// import { registerFeishuMailTools } from "./mail/index";
|
|
19
|
+
const index_6 = require("./search/index.js");
|
|
20
|
+
const index_7 = require("./drive/index.js");
|
|
21
|
+
const index_8 = require("./wiki/index.js");
|
|
22
|
+
const index_9 = require("./sheets/index.js");
|
|
23
|
+
// import { registerFeishuOkrTools } from "./okr/index";
|
|
24
|
+
const index_10 = require("./chat/index.js");
|
|
25
|
+
const index_11 = require("./im/index.js");
|
|
26
|
+
function registerOapiTools(api) {
|
|
27
|
+
// Common tools
|
|
28
|
+
(0, index_5.registerGetUserTool)(api);
|
|
29
|
+
(0, index_5.registerSearchUserTool)(api);
|
|
30
|
+
// Chat tools
|
|
31
|
+
(0, index_10.registerFeishuChatTools)(api);
|
|
32
|
+
// IM tools (user identity)
|
|
33
|
+
(0, index_11.registerFeishuImTools)(api);
|
|
34
|
+
// Calendar tools
|
|
35
|
+
(0, index_2.registerFeishuCalendarCalendarTool)(api);
|
|
36
|
+
(0, index_2.registerFeishuCalendarEventTool)(api);
|
|
37
|
+
(0, index_2.registerFeishuCalendarEventAttendeeTool)(api);
|
|
38
|
+
(0, index_2.registerFeishuCalendarFreebusyTool)(api);
|
|
39
|
+
// Task tools
|
|
40
|
+
(0, index_3.registerFeishuTaskTaskTool)(api);
|
|
41
|
+
(0, index_3.registerFeishuTaskTasklistTool)(api);
|
|
42
|
+
(0, index_3.registerFeishuTaskAttachmentTool)(api);
|
|
43
|
+
(0, index_3.registerFeishuTaskSectionTool)(api);
|
|
44
|
+
(0, index_3.registerFeishuTaskCommentTool)(api);
|
|
45
|
+
(0, index_3.registerFeishuTaskSubtaskTool)(api);
|
|
46
|
+
(0, index_3.registerFeishuTaskAgentTool)(api);
|
|
47
|
+
// Bitable tools
|
|
48
|
+
(0, index_4.registerFeishuBitableAppTool)(api);
|
|
49
|
+
(0, index_4.registerFeishuBitableAppTableTool)(api);
|
|
50
|
+
(0, index_4.registerFeishuBitableAppTableRecordTool)(api);
|
|
51
|
+
(0, index_4.registerFeishuBitableAppTableFieldTool)(api);
|
|
52
|
+
(0, index_4.registerFeishuBitableAppTableViewTool)(api);
|
|
53
|
+
// Search tools
|
|
54
|
+
(0, index_6.registerFeishuSearchTools)(api);
|
|
55
|
+
// Drive tools
|
|
56
|
+
(0, index_7.registerFeishuDriveTools)(api);
|
|
57
|
+
// Wiki tools
|
|
58
|
+
(0, index_8.registerFeishuWikiTools)(api);
|
|
59
|
+
// Sheets tools
|
|
60
|
+
(0, index_9.registerFeishuSheetsTools)(api);
|
|
61
|
+
// IM tools (bot identity)
|
|
62
|
+
(0, index_1.registerFeishuImTools)(api);
|
|
63
|
+
api.logger.debug?.('Registered all OAPI tools (calendar, task, bitable, search, drive, wiki, sheets, im)');
|
|
64
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Common response type helpers for Lark SDK.
|
|
6
|
+
*
|
|
7
|
+
* The Lark Node SDK's generic response types often lack specific field
|
|
8
|
+
* definitions for `data`, requiring `as any` casts. These lightweight
|
|
9
|
+
* interfaces let us replace `(res.data as any)?.items` with a single typed
|
|
10
|
+
* assertion at the top of each block.
|
|
11
|
+
*/
|
|
12
|
+
/** Standard paginated list response (items / has_more / page_token). */
|
|
13
|
+
export interface PaginatedData<T = unknown> {
|
|
14
|
+
items?: T[];
|
|
15
|
+
has_more?: boolean;
|
|
16
|
+
page_token?: string;
|
|
17
|
+
total?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Calendar-specific list response that uses `calendar_list` key. */
|
|
20
|
+
export interface CalendarListData {
|
|
21
|
+
calendar_list?: unknown[];
|
|
22
|
+
has_more?: boolean;
|
|
23
|
+
page_token?: string;
|
|
24
|
+
}
|
|
25
|
+
/** Calendar primary response. */
|
|
26
|
+
export interface CalendarPrimaryData {
|
|
27
|
+
calendars?: Array<{
|
|
28
|
+
calendar?: {
|
|
29
|
+
calendar_id?: string;
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
/** Freebusy response. */
|
|
34
|
+
export interface FreebusyData {
|
|
35
|
+
freebusy_lists?: unknown[];
|
|
36
|
+
}
|
|
37
|
+
/** Drive file list response (uses `files` key). */
|
|
38
|
+
export interface DriveFileListData {
|
|
39
|
+
files?: unknown[];
|
|
40
|
+
has_more?: boolean;
|
|
41
|
+
next_page_token?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Drive file copy / create response. */
|
|
44
|
+
export interface DriveFileData {
|
|
45
|
+
file?: {
|
|
46
|
+
token?: string;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Drive async task response (move / delete). */
|
|
51
|
+
export interface DriveTaskData {
|
|
52
|
+
task_id?: string;
|
|
53
|
+
}
|
|
54
|
+
/** Bitable app list response (uses `files` key from drive search). */
|
|
55
|
+
export interface BitableAppListData {
|
|
56
|
+
files?: unknown[];
|
|
57
|
+
has_more?: boolean;
|
|
58
|
+
page_token?: string;
|
|
59
|
+
}
|
|
60
|
+
/** Field create / update response. */
|
|
61
|
+
export interface FieldData {
|
|
62
|
+
field?: {
|
|
63
|
+
field_id?: string;
|
|
64
|
+
[key: string]: unknown;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Chat member list response. */
|
|
68
|
+
export interface ChatMemberListData {
|
|
69
|
+
items?: unknown[];
|
|
70
|
+
member_total?: number;
|
|
71
|
+
has_more?: boolean;
|
|
72
|
+
page_token?: string;
|
|
73
|
+
}
|
|
74
|
+
/** Search user response. */
|
|
75
|
+
export interface SearchUserData {
|
|
76
|
+
users?: unknown[];
|
|
77
|
+
has_more?: boolean;
|
|
78
|
+
page_token?: string;
|
|
79
|
+
}
|
|
80
|
+
/** Task create response. */
|
|
81
|
+
export interface TaskCreateData {
|
|
82
|
+
task?: {
|
|
83
|
+
guid?: string;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/** Calendar get response. */
|
|
88
|
+
export interface CalendarGetData {
|
|
89
|
+
calendar?: unknown;
|
|
90
|
+
}
|
|
91
|
+
/** Comment list reply response. */
|
|
92
|
+
export interface CommentReplyListData {
|
|
93
|
+
items?: unknown[];
|
|
94
|
+
has_more?: boolean;
|
|
95
|
+
page_token?: string;
|
|
96
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Common response type helpers for Lark SDK.
|
|
7
|
+
*
|
|
8
|
+
* The Lark Node SDK's generic response types often lack specific field
|
|
9
|
+
* definitions for `data`, requiring `as any` casts. These lightweight
|
|
10
|
+
* interfaces let us replace `(res.data as any)?.items` with a single typed
|
|
11
|
+
* assertion at the top of each block.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* feishu_search_doc_wiki tool -- Search Feishu documents and wikis.
|
|
6
|
+
*
|
|
7
|
+
* Actions: search
|
|
8
|
+
*
|
|
9
|
+
* Uses the Feishu Search API:
|
|
10
|
+
* - search: POST /open-apis/search/v2/doc_wiki/search
|
|
11
|
+
*/
|
|
12
|
+
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk';
|
|
13
|
+
export declare function registerFeishuSearchDocWikiTool(api: OpenClawPluginApi): boolean;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* feishu_search_doc_wiki tool -- Search Feishu documents and wikis.
|
|
7
|
+
*
|
|
8
|
+
* Actions: search
|
|
9
|
+
*
|
|
10
|
+
* Uses the Feishu Search API:
|
|
11
|
+
* - search: POST /open-apis/search/v2/doc_wiki/search
|
|
12
|
+
*/
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.registerFeishuSearchDocWikiTool = registerFeishuSearchDocWikiTool;
|
|
16
|
+
const typebox_1 = require("@sinclair/typebox");
|
|
17
|
+
const helpers_1 = require("../helpers.js");
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Schema - Helper types
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
const TimeRangeSchema = typebox_1.Type.Object({
|
|
22
|
+
start: typebox_1.Type.Optional(typebox_1.Type.String({
|
|
23
|
+
description: "时间范围的起始时间,ISO 8601 / RFC 3339 格式(包含时区),例如 '2024-01-01T00:00:00+08:00'",
|
|
24
|
+
})),
|
|
25
|
+
end: typebox_1.Type.Optional(typebox_1.Type.String({
|
|
26
|
+
description: "时间范围的截止时间,ISO 8601 / RFC 3339 格式(包含时区),例如 '2024-01-01T00:00:00+08:00'",
|
|
27
|
+
})),
|
|
28
|
+
});
|
|
29
|
+
const DocTypeEnum = (0, helpers_1.StringEnum)([
|
|
30
|
+
'DOC',
|
|
31
|
+
'SHEET',
|
|
32
|
+
'BITABLE',
|
|
33
|
+
'MINDNOTE',
|
|
34
|
+
'FILE',
|
|
35
|
+
'WIKI',
|
|
36
|
+
'DOCX',
|
|
37
|
+
'FOLDER',
|
|
38
|
+
'CATALOG',
|
|
39
|
+
'SLIDES',
|
|
40
|
+
'SHORTCUT',
|
|
41
|
+
]);
|
|
42
|
+
const SortTypeEnum = (0, helpers_1.StringEnum)(['DEFAULT_TYPE', 'OPEN_TIME', 'EDIT_TIME', 'EDIT_TIME_ASC', 'CREATE_TIME'], {
|
|
43
|
+
description: '排序方式。EDIT_TIME=编辑时间降序(最新文档在前,推荐),EDIT_TIME_ASC=编辑时间升序,CREATE_TIME=按文档创建时间排序,OPEN_TIME=打开时间,DEFAULT_TYPE=默认排序',
|
|
44
|
+
});
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
// Schema - Main
|
|
47
|
+
// ---------------------------------------------------------------------------
|
|
48
|
+
const FeishuSearchDocWikiSchema = typebox_1.Type.Object({
|
|
49
|
+
action: typebox_1.Type.Literal('search'),
|
|
50
|
+
query: typebox_1.Type.Optional(typebox_1.Type.String({
|
|
51
|
+
description: '搜索关键词(可选)。不传或传空字符串表示空搜,也可以支持排序规则与筛选,默认根据最近浏览时间返回结果',
|
|
52
|
+
maxLength: 50,
|
|
53
|
+
})),
|
|
54
|
+
filter: typebox_1.Type.Optional(typebox_1.Type.Object({
|
|
55
|
+
creator_ids: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.String(), {
|
|
56
|
+
description: '创建者 OpenID 列表(最多 20 个)',
|
|
57
|
+
maxItems: 20,
|
|
58
|
+
})),
|
|
59
|
+
doc_types: typebox_1.Type.Optional(typebox_1.Type.Array(DocTypeEnum, {
|
|
60
|
+
description: '文档类型列表:DOC(文档)、SHEET(表格)、BITABLE(多维表格)、MINDNOTE(思维导图)、FILE(文件)、WIKI(维基)、DOCX(新版文档)、FOLDER(space文件夹)、CATALOG(wiki2.0文件夹)、SLIDES(新版幻灯片)、SHORTCUT(快捷方式)',
|
|
61
|
+
maxItems: 10,
|
|
62
|
+
})),
|
|
63
|
+
only_title: typebox_1.Type.Optional(typebox_1.Type.Boolean({
|
|
64
|
+
description: '仅搜索标题(默认 false,搜索标题和正文)',
|
|
65
|
+
})),
|
|
66
|
+
open_time: typebox_1.Type.Optional(TimeRangeSchema),
|
|
67
|
+
sort_type: typebox_1.Type.Optional(SortTypeEnum),
|
|
68
|
+
create_time: typebox_1.Type.Optional(TimeRangeSchema),
|
|
69
|
+
}, {
|
|
70
|
+
description: '搜索过滤条件(可选)。不传则搜索所有文档和 Wiki;传了则同时对文档和 Wiki 应用相同的过滤条件。',
|
|
71
|
+
})),
|
|
72
|
+
page_token: typebox_1.Type.Optional(typebox_1.Type.String({
|
|
73
|
+
description: '分页标记。首次请求不填;当返回结果中 has_more 为 true 时,可传入返回的 page_token 继续请求下一页',
|
|
74
|
+
})),
|
|
75
|
+
page_size: typebox_1.Type.Optional(typebox_1.Type.Integer({
|
|
76
|
+
description: '分页大小(默认 15,最大 20)',
|
|
77
|
+
minimum: 0,
|
|
78
|
+
maximum: 20,
|
|
79
|
+
})),
|
|
80
|
+
});
|
|
81
|
+
function normalizeSearchResultTimeFields(value, converted) {
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
return value.map((item) => normalizeSearchResultTimeFields(item, converted));
|
|
84
|
+
}
|
|
85
|
+
if (!value || typeof value !== 'object') {
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
const source = value;
|
|
89
|
+
const normalized = {};
|
|
90
|
+
for (const [key, item] of Object.entries(source)) {
|
|
91
|
+
if (key.endsWith('_time')) {
|
|
92
|
+
const iso = (0, helpers_1.unixTimestampToISO8601)(item);
|
|
93
|
+
if (iso) {
|
|
94
|
+
normalized[key] = iso;
|
|
95
|
+
converted.count += 1;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
normalized[key] = normalizeSearchResultTimeFields(item, converted);
|
|
100
|
+
}
|
|
101
|
+
return normalized;
|
|
102
|
+
}
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
// Registration
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
function registerFeishuSearchDocWikiTool(api) {
|
|
107
|
+
if (!api.config)
|
|
108
|
+
return false;
|
|
109
|
+
const cfg = api.config;
|
|
110
|
+
const { toolClient, log } = (0, helpers_1.createToolContext)(api, 'feishu_search_doc_wiki');
|
|
111
|
+
return (0, helpers_1.registerTool)(api, {
|
|
112
|
+
name: 'feishu_search_doc_wiki',
|
|
113
|
+
label: 'Feishu Document & Wiki Search',
|
|
114
|
+
description: '【以用户身份】飞书文档与 Wiki 统一搜索工具。同时搜索云空间文档和知识库 Wiki。Actions: search。' +
|
|
115
|
+
'【重要】query 参数是搜索关键词(必填),filter 参数可选。' +
|
|
116
|
+
'【重要】filter 不传时,搜索所有文档和 Wiki;传了则同时对文档和 Wiki 应用相同的过滤条件。' +
|
|
117
|
+
'【重要】支持按文档类型、创建者、创建时间、打开时间等多维度筛选。' +
|
|
118
|
+
'【重要】返回结果包含标题和摘要高亮(<h>标签包裹匹配关键词)。',
|
|
119
|
+
parameters: FeishuSearchDocWikiSchema,
|
|
120
|
+
async execute(_toolCallId, params) {
|
|
121
|
+
const p = params;
|
|
122
|
+
try {
|
|
123
|
+
const client = toolClient();
|
|
124
|
+
switch (p.action) {
|
|
125
|
+
// -----------------------------------------------------------------
|
|
126
|
+
// SEARCH DOCUMENTS AND WIKIS
|
|
127
|
+
// -----------------------------------------------------------------
|
|
128
|
+
case 'search': {
|
|
129
|
+
// query 为可选参数,默认使用空字符串(表示空搜)
|
|
130
|
+
const query = p.query ?? '';
|
|
131
|
+
log.info(`search: query="${query}", has_filter=${!!p.filter}, page_size=${p.page_size ?? 15}`);
|
|
132
|
+
// 构建请求体
|
|
133
|
+
const requestData = {
|
|
134
|
+
query: query,
|
|
135
|
+
page_size: p.page_size,
|
|
136
|
+
page_token: p.page_token,
|
|
137
|
+
};
|
|
138
|
+
// 必须传递 doc_filter 和 wiki_filter,即使为空对象(API 要求)
|
|
139
|
+
if (p.filter) {
|
|
140
|
+
const filter = { ...p.filter };
|
|
141
|
+
// 处理时间字段转换
|
|
142
|
+
if (filter.open_time) {
|
|
143
|
+
filter.open_time = (0, helpers_1.convertTimeRange)(filter.open_time);
|
|
144
|
+
}
|
|
145
|
+
if (filter.create_time) {
|
|
146
|
+
filter.create_time = (0, helpers_1.convertTimeRange)(filter.create_time);
|
|
147
|
+
}
|
|
148
|
+
// 同时设置 doc_filter 和 wiki_filter(内容相同)
|
|
149
|
+
requestData.doc_filter = { ...filter };
|
|
150
|
+
requestData.wiki_filter = { ...filter };
|
|
151
|
+
log.info(`search: applying filter to both doc and wiki: doc_types=${filter.doc_types?.join(',') || 'all'}, only_title=${filter.only_title ?? false}`);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
// 即使没有筛选条件,也必须传空对象(否则 API 不返回内容)
|
|
155
|
+
requestData.doc_filter = {};
|
|
156
|
+
requestData.wiki_filter = {};
|
|
157
|
+
log.info(`search: no filter provided, using empty filters (required by API)`);
|
|
158
|
+
}
|
|
159
|
+
// 使用 client.invoke 统一封装底层 request 调用
|
|
160
|
+
const res = await client.invoke('feishu_search_doc_wiki.search', async (sdk, _opts, uat) => {
|
|
161
|
+
return sdk.request({
|
|
162
|
+
method: 'POST',
|
|
163
|
+
url: '/open-apis/search/v2/doc_wiki/search',
|
|
164
|
+
data: requestData,
|
|
165
|
+
headers: {
|
|
166
|
+
Authorization: `Bearer ${uat}`,
|
|
167
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
168
|
+
},
|
|
169
|
+
}, _opts);
|
|
170
|
+
}, { as: 'user' });
|
|
171
|
+
// 检查响应
|
|
172
|
+
if (res.code !== 0) {
|
|
173
|
+
throw new Error(`API Error: code=${res.code}, msg=${res.msg}`);
|
|
174
|
+
}
|
|
175
|
+
const data = res.data || {};
|
|
176
|
+
log.info(`search: found ${data.res_units?.length ?? 0} results, total=${data.total ?? 0}, has_more=${data.has_more ?? false}`);
|
|
177
|
+
const converted = { count: 0 };
|
|
178
|
+
const normalizedResults = normalizeSearchResultTimeFields(data.res_units, converted);
|
|
179
|
+
log.info(`search: normalized ${converted.count} timestamp fields to ISO8601`);
|
|
180
|
+
return (0, helpers_1.json)({
|
|
181
|
+
total: data.total,
|
|
182
|
+
has_more: data.has_more,
|
|
183
|
+
results: normalizedResults,
|
|
184
|
+
page_token: data.page_token,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
return await (0, helpers_1.handleInvokeErrorWithAutoAuth)(err, cfg);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
}, { name: 'feishu_search_doc_wiki' });
|
|
194
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Search 工具集
|
|
6
|
+
* 统一导出所有搜索相关工具的注册函数
|
|
7
|
+
*/
|
|
8
|
+
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk';
|
|
9
|
+
/**
|
|
10
|
+
* 注册所有 Search 工具
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerFeishuSearchTools(api: OpenClawPluginApi): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Search 工具集
|
|
7
|
+
* 统一导出所有搜索相关工具的注册函数
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.registerFeishuSearchTools = registerFeishuSearchTools;
|
|
11
|
+
const accounts_1 = require("../../../core/accounts.js");
|
|
12
|
+
const tools_config_1 = require("../../../core/tools-config.js");
|
|
13
|
+
const doc_search_1 = require("./doc-search.js");
|
|
14
|
+
/**
|
|
15
|
+
* 注册所有 Search 工具
|
|
16
|
+
*/
|
|
17
|
+
function registerFeishuSearchTools(api) {
|
|
18
|
+
if (!api.config) {
|
|
19
|
+
api.logger.debug?.('feishu_search: No config available, skipping');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const accounts = (0, accounts_1.getEnabledLarkAccounts)(api.config);
|
|
23
|
+
if (accounts.length === 0) {
|
|
24
|
+
api.logger.debug?.('feishu_search: No Feishu accounts configured, skipping');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// search 工具使用 doc 配置项控制,因为搜索是文档相关功能
|
|
28
|
+
const toolsCfg = (0, tools_config_1.resolveAnyEnabledToolsConfig)(accounts);
|
|
29
|
+
if (!toolsCfg.doc) {
|
|
30
|
+
api.logger.debug?.('feishu_search: search tool disabled in all accounts (controlled by doc config)');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// 注册所有工具
|
|
34
|
+
if ((0, doc_search_1.registerFeishuSearchDocWikiTool)(api)) {
|
|
35
|
+
api.logger.debug?.('feishu_search: Registered feishu_search_doc_wiki');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Sheets 工具集
|
|
6
|
+
* 注册飞书电子表格工具
|
|
7
|
+
*/
|
|
8
|
+
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk';
|
|
9
|
+
/**
|
|
10
|
+
* 注册 Sheets 工具
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerFeishuSheetsTools(api: OpenClawPluginApi): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Sheets 工具集
|
|
7
|
+
* 注册飞书电子表格工具
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.registerFeishuSheetsTools = registerFeishuSheetsTools;
|
|
11
|
+
const accounts_1 = require("../../../core/accounts.js");
|
|
12
|
+
const tools_config_1 = require("../../../core/tools-config.js");
|
|
13
|
+
const sheet_1 = require("./sheet.js");
|
|
14
|
+
/**
|
|
15
|
+
* 注册 Sheets 工具
|
|
16
|
+
*/
|
|
17
|
+
function registerFeishuSheetsTools(api) {
|
|
18
|
+
if (!api.config) {
|
|
19
|
+
api.logger.debug?.('feishu_sheets: No config available, skipping');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const accounts = (0, accounts_1.getEnabledLarkAccounts)(api.config);
|
|
23
|
+
if (accounts.length === 0) {
|
|
24
|
+
api.logger.debug?.('feishu_sheets: No Feishu accounts configured, skipping');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const toolsCfg = (0, tools_config_1.resolveAnyEnabledToolsConfig)(accounts);
|
|
28
|
+
if (!toolsCfg.sheets) {
|
|
29
|
+
api.logger.debug?.('feishu_sheets: sheets tool disabled in all accounts');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if ((0, sheet_1.registerFeishuSheetTool)(api)) {
|
|
33
|
+
api.logger.debug?.('feishu_sheets: Registered feishu_sheet');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* feishu_sheet — 飞书电子表格统一工具。
|
|
6
|
+
*
|
|
7
|
+
* Actions: info, read, write, append, find, create, export
|
|
8
|
+
*
|
|
9
|
+
* 设计原则:
|
|
10
|
+
* - 接受 URL 或 spreadsheet_token(工具层自动解析)
|
|
11
|
+
* - read 不指定 range 时自动读取第一个工作表全部数据
|
|
12
|
+
* - create 支持带表头和初始数据一步创建
|
|
13
|
+
* - info 一次返回表格信息 + 全部工作表列表
|
|
14
|
+
*/
|
|
15
|
+
import type { OpenClawPluginApi } from 'openclaw/plugin-sdk';
|
|
16
|
+
export declare function registerFeishuSheetTool(api: OpenClawPluginApi): boolean;
|