@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,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Resolution logic for Feishu tool-use display.
|
|
6
|
+
*
|
|
7
|
+
* The source of truth is OpenClaw's effective verbose state:
|
|
8
|
+
* inline `/verbose` override > session store override > config default.
|
|
9
|
+
* Feishu channel config only retains UI-level detail (`showFullPaths`).
|
|
10
|
+
*/
|
|
11
|
+
import type { ClawdbotConfig } from 'openclaw/plugin-sdk';
|
|
12
|
+
import type { FeishuConfig } from '../core/types';
|
|
13
|
+
export type ToolUseMode = 'off' | 'on' | 'full';
|
|
14
|
+
export interface ToolUseDisplayConfig {
|
|
15
|
+
mode: ToolUseMode;
|
|
16
|
+
showToolUse: boolean;
|
|
17
|
+
showToolResultDetails: boolean;
|
|
18
|
+
showFullPaths: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function resolveToolUseDisplayConfig(params: {
|
|
21
|
+
cfg: ClawdbotConfig;
|
|
22
|
+
feishuCfg: FeishuConfig | undefined;
|
|
23
|
+
agentId: string;
|
|
24
|
+
sessionKey: string;
|
|
25
|
+
body?: string;
|
|
26
|
+
}): ToolUseDisplayConfig;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Resolution logic for Feishu tool-use display.
|
|
7
|
+
*
|
|
8
|
+
* The source of truth is OpenClaw's effective verbose state:
|
|
9
|
+
* inline `/verbose` override > session store override > config default.
|
|
10
|
+
* Feishu channel config only retains UI-level detail (`showFullPaths`).
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.resolveToolUseDisplayConfig = resolveToolUseDisplayConfig;
|
|
14
|
+
const agent_runtime_1 = require("openclaw/plugin-sdk/agent-runtime");
|
|
15
|
+
const config_runtime_1 = require("openclaw/plugin-sdk/config-runtime");
|
|
16
|
+
function resolveToolUseDisplayConfig(params) {
|
|
17
|
+
const mode = resolveEffectiveVerboseMode(params);
|
|
18
|
+
return {
|
|
19
|
+
mode,
|
|
20
|
+
showToolUse: mode !== 'off',
|
|
21
|
+
showToolResultDetails: mode === 'full',
|
|
22
|
+
showFullPaths: params.feishuCfg?.toolUseDisplay?.showFullPaths === true,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function resolveEffectiveVerboseMode(params) {
|
|
26
|
+
return (extractInlineVerboseMode(params.body) ??
|
|
27
|
+
resolveSessionVerboseMode(params.cfg, params.sessionKey, params.agentId) ??
|
|
28
|
+
normalizeToolUseMode(params.cfg.agents?.defaults?.verboseDefault) ??
|
|
29
|
+
'off');
|
|
30
|
+
}
|
|
31
|
+
function resolveSessionVerboseMode(cfg, sessionKey, agentId) {
|
|
32
|
+
try {
|
|
33
|
+
const cfgWithSession = cfg;
|
|
34
|
+
const sessionStorePath = cfgWithSession.session?.store ?? cfgWithSession.sessions?.store;
|
|
35
|
+
const storePath = (0, config_runtime_1.resolveStorePath)(sessionStorePath, { agentId });
|
|
36
|
+
const store = (0, config_runtime_1.loadSessionStore)(storePath);
|
|
37
|
+
const candidateKeys = resolveCandidateSessionKeys(cfg, sessionKey);
|
|
38
|
+
for (const candidateKey of candidateKeys) {
|
|
39
|
+
const resolved = (0, config_runtime_1.resolveSessionStoreEntry)({ store, sessionKey: candidateKey });
|
|
40
|
+
const mode = normalizeToolUseMode(resolved.existing?.verboseLevel);
|
|
41
|
+
if (mode)
|
|
42
|
+
return mode;
|
|
43
|
+
if (resolved.existing)
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function resolveCandidateSessionKeys(cfg, sessionKey) {
|
|
53
|
+
const key = sessionKey.trim().toLowerCase();
|
|
54
|
+
const defaultAgentId = (0, agent_runtime_1.resolveDefaultAgentId)(cfg);
|
|
55
|
+
const fallbackKey = key.replace(/^(agent):[^:]+:/, `$1:${defaultAgentId}:`);
|
|
56
|
+
return fallbackKey !== key ? [key, fallbackKey] : [key];
|
|
57
|
+
}
|
|
58
|
+
function extractInlineVerboseMode(body) {
|
|
59
|
+
if (!body)
|
|
60
|
+
return undefined;
|
|
61
|
+
const matches = body.matchAll(/(?:^|\s)\/(?:verbose|v)(?::|\s+)(on|off|full)\b/gi);
|
|
62
|
+
let last;
|
|
63
|
+
for (const match of matches) {
|
|
64
|
+
last = normalizeToolUseMode(match[1]);
|
|
65
|
+
}
|
|
66
|
+
return last;
|
|
67
|
+
}
|
|
68
|
+
function normalizeToolUseMode(value) {
|
|
69
|
+
if (typeof value !== 'string')
|
|
70
|
+
return undefined;
|
|
71
|
+
const normalized = value.trim().toLowerCase();
|
|
72
|
+
if (normalized === 'off' || normalized === 'on' || normalized === 'full') {
|
|
73
|
+
return normalized;
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Structured tool-use display for Lark/Feishu cards.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolUseTraceStep } from './tool-use-trace-store';
|
|
8
|
+
export type ToolUseStepStatus = ToolUseTraceStep['status'];
|
|
9
|
+
export interface ToolUseDisplayBlock {
|
|
10
|
+
language: 'json' | 'text';
|
|
11
|
+
content: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ToolUseDisplayStep {
|
|
14
|
+
title: string;
|
|
15
|
+
detail?: string;
|
|
16
|
+
iconToken: string;
|
|
17
|
+
status: ToolUseStepStatus;
|
|
18
|
+
resultBlock?: ToolUseDisplayBlock;
|
|
19
|
+
errorBlock?: ToolUseDisplayBlock;
|
|
20
|
+
}
|
|
21
|
+
export interface ToolUseDisplayResult {
|
|
22
|
+
content: string;
|
|
23
|
+
stepCount: number;
|
|
24
|
+
steps: ToolUseDisplayStep[];
|
|
25
|
+
}
|
|
26
|
+
export declare const EMPTY_TOOL_USE_PLACEHOLDER = "No tool steps available";
|
|
27
|
+
export declare function normalizeToolUseDisplay(params: {
|
|
28
|
+
traceSteps?: ToolUseTraceStep[];
|
|
29
|
+
showFullPaths?: boolean;
|
|
30
|
+
showResultDetails?: boolean;
|
|
31
|
+
}): ToolUseDisplayResult;
|
|
32
|
+
export declare function buildToolUseTitleSuffix(params: {
|
|
33
|
+
stepCount: number;
|
|
34
|
+
}): {
|
|
35
|
+
zh: string;
|
|
36
|
+
en: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*
|
|
6
|
+
* Structured tool-use display for Lark/Feishu cards.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.EMPTY_TOOL_USE_PLACEHOLDER = void 0;
|
|
10
|
+
exports.normalizeToolUseDisplay = normalizeToolUseDisplay;
|
|
11
|
+
exports.buildToolUseTitleSuffix = buildToolUseTitleSuffix;
|
|
12
|
+
const reasoning_utils_1 = require("./reasoning-utils.js");
|
|
13
|
+
exports.EMPTY_TOOL_USE_PLACEHOLDER = 'No tool steps available';
|
|
14
|
+
const DEFAULT_SUMMARY_PREFERENCE = ['matched', 'code', 'quoted', 'url', 'line'];
|
|
15
|
+
const TOOL_DESCRIPTORS = [
|
|
16
|
+
{
|
|
17
|
+
aliases: ['skill'],
|
|
18
|
+
iconToken: 'app-default_outlined',
|
|
19
|
+
title: 'Load skill',
|
|
20
|
+
sanitizer: 'skill',
|
|
21
|
+
paramKeys: ['skill', 'name'],
|
|
22
|
+
summaryPatterns: [/^(?:load|use)\s+skill\s+(.+)$/i],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
aliases: ['read', 'open'],
|
|
26
|
+
iconToken: 'file-link-text_outlined',
|
|
27
|
+
title: 'Read',
|
|
28
|
+
sanitizer: 'path',
|
|
29
|
+
paramKeys: ['file_path', 'path', 'file'],
|
|
30
|
+
summaryPatterns: [/^(?:read|open)\s+(?:file\s+)?(.+)$/i],
|
|
31
|
+
summaryPreference: ['code', 'quoted', 'matched', 'line'],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
aliases: ['write', 'edit'],
|
|
35
|
+
iconToken: 'edit_outlined',
|
|
36
|
+
title: 'Edit',
|
|
37
|
+
sanitizer: 'path',
|
|
38
|
+
paramKeys: ['file_path', 'path', 'file'],
|
|
39
|
+
summaryPatterns: [/^(?:edit|write)\s+(?:file\s+)?(.+)$/i],
|
|
40
|
+
summaryPreference: ['code', 'quoted', 'matched', 'line'],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
aliases: ['web_search', 'web-search', 'search'],
|
|
44
|
+
iconToken: 'search_outlined',
|
|
45
|
+
title: 'Search web',
|
|
46
|
+
sanitizer: 'search',
|
|
47
|
+
paramKeys: ['query', 'q'],
|
|
48
|
+
summaryPatterns: [/^(?:search\s+(?:web\s+)?(?:for|about)|query)\s+(.+)$/i],
|
|
49
|
+
summaryPreference: ['quoted', 'matched', 'line'],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
aliases: ['web_fetch', 'web-fetch', 'fetch'],
|
|
53
|
+
iconToken: 'language_outlined',
|
|
54
|
+
title: 'Fetch web page',
|
|
55
|
+
sanitizer: 'url',
|
|
56
|
+
paramKeys: ['url'],
|
|
57
|
+
summaryPatterns: [/^(?:fetch|open)\s+(?:web\s+page\s+)?(?:from\s+)?(.+)$/i],
|
|
58
|
+
summaryPreference: ['url', 'matched', 'quoted', 'line'],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
aliases: ['grep'],
|
|
62
|
+
iconToken: 'doc-search_outlined',
|
|
63
|
+
title: 'Search text',
|
|
64
|
+
sanitizer: 'generic',
|
|
65
|
+
detailFromParams: (params) => buildPatternDetail(params, { includeTarget: true }),
|
|
66
|
+
summaryPatterns: [/^(?:search\s+text(?:\s+by\s+pattern)?|grep)\s+(.+)$/i],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
aliases: ['glob'],
|
|
70
|
+
iconToken: 'folder_outlined',
|
|
71
|
+
title: 'Search files',
|
|
72
|
+
sanitizer: 'generic',
|
|
73
|
+
paramKeys: ['pattern'],
|
|
74
|
+
summaryPatterns: [/^(?:search\s+files(?:\s+by\s+pattern)?|glob)\s+(.+)$/i],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
aliases: ['exec', 'bash', 'command', 'run'],
|
|
78
|
+
iconToken: 'setting_outlined',
|
|
79
|
+
title: 'Run command',
|
|
80
|
+
sanitizer: 'command',
|
|
81
|
+
paramKeys: ['description', 'command', 'script'],
|
|
82
|
+
summaryPatterns: [/^(?:run|execute)\s+(?:command|script)?\s*(.+)$/i],
|
|
83
|
+
summaryPreference: ['code', 'quoted', 'matched', 'line'],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
aliases: ['browser', 'playwright', 'navigate'],
|
|
87
|
+
iconToken: 'browser-mac_outlined',
|
|
88
|
+
title: 'Browser',
|
|
89
|
+
sanitizer: 'url',
|
|
90
|
+
paramKeys: ['url'],
|
|
91
|
+
summaryPatterns: [/^(?:open|browse|visit|navigate\s+to)\s+(.+)$/i],
|
|
92
|
+
summaryPreference: ['url', 'quoted', 'matched', 'line'],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
aliases: ['agent', 'task', 'spawn'],
|
|
96
|
+
iconToken: 'robot_outlined',
|
|
97
|
+
title: 'Run sub-agent',
|
|
98
|
+
sanitizer: 'generic',
|
|
99
|
+
paramKeys: ['task', 'description', 'prompt'],
|
|
100
|
+
summaryPatterns: [/^(?:run\s+sub-?agent|spawn\s+agent)\s+(.+)$/i],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
aliases: ['check', 'determine', 'verify'],
|
|
104
|
+
iconToken: 'list-check_outlined',
|
|
105
|
+
title: 'Check',
|
|
106
|
+
sanitizer: 'generic',
|
|
107
|
+
paramKeys: ['target', 'subject', 'description'],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
aliases: ['summarize', 'analyze', 'prepare'],
|
|
111
|
+
iconToken: 'report_outlined',
|
|
112
|
+
title: 'Analyze',
|
|
113
|
+
sanitizer: 'generic',
|
|
114
|
+
paramKeys: ['target', 'subject', 'description'],
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
function normalizeToolUseDisplay(params) {
|
|
118
|
+
const traceSteps = params.traceSteps ?? [];
|
|
119
|
+
const showFullPaths = params.showFullPaths === true;
|
|
120
|
+
const showResultDetails = params.showResultDetails === true;
|
|
121
|
+
const sources = traceSteps.map(toTraceSource);
|
|
122
|
+
const steps = sources
|
|
123
|
+
.map((source) => formatToolStep(source, { showFullPaths, showResultDetails }))
|
|
124
|
+
.filter((step) => !!step);
|
|
125
|
+
return {
|
|
126
|
+
content: steps.map((step) => (step.detail ? `- ${step.title}: ${step.detail}` : `- ${step.title}`)).join('\n'),
|
|
127
|
+
stepCount: steps.length,
|
|
128
|
+
steps,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function buildToolUseTitleSuffix(params) {
|
|
132
|
+
const { stepCount } = params;
|
|
133
|
+
return {
|
|
134
|
+
zh: `查看 ${stepCount} 个步骤`,
|
|
135
|
+
en: `Show ${stepCount} step${stepCount === 1 ? '' : 's'}`,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function toTraceSource(step) {
|
|
139
|
+
return {
|
|
140
|
+
toolName: step.toolName,
|
|
141
|
+
params: step.params,
|
|
142
|
+
result: step.result,
|
|
143
|
+
error: step.error,
|
|
144
|
+
durationMs: step.durationMs,
|
|
145
|
+
status: step.status,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function formatToolStep(source, options) {
|
|
149
|
+
const descriptor = resolveToolDescriptor(source.toolName);
|
|
150
|
+
const rawDetail = (descriptor ? extractDetailFromParams(source.params, descriptor) : undefined) ??
|
|
151
|
+
(descriptor ? extractDetailFromSummary(source.summaryText, descriptor) : cleanupLine(source.summaryText ?? '')) ??
|
|
152
|
+
undefined;
|
|
153
|
+
const detail = rawDetail ? sanitizeToolDetail(descriptor?.sanitizer ?? 'generic', rawDetail, options) : undefined;
|
|
154
|
+
const title = buildToolTitle(source, descriptor, rawDetail);
|
|
155
|
+
const status = resolveStepStatus(source);
|
|
156
|
+
const errorBlock = source.error ? buildErrorBlock(source.error, descriptor) : undefined;
|
|
157
|
+
const resultBlock = !errorBlock && options.showResultDetails ? buildResultBlock(source, descriptor) : undefined;
|
|
158
|
+
return {
|
|
159
|
+
title,
|
|
160
|
+
detail,
|
|
161
|
+
iconToken: descriptor?.iconToken ?? 'setting-inter_outlined',
|
|
162
|
+
status,
|
|
163
|
+
resultBlock,
|
|
164
|
+
errorBlock,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
function buildToolTitle(source, descriptor, rawDetail) {
|
|
168
|
+
const baseTitle = descriptor?.title === 'Read' && rawDetail && isSkillPathValue(rawDetail)
|
|
169
|
+
? 'Skill Read'
|
|
170
|
+
: (descriptor?.title ?? humanizeToolName(source.toolName ?? 'tool'));
|
|
171
|
+
const durationLabel = source.durationMs != null ? formatDurationLabel(source.durationMs) : undefined;
|
|
172
|
+
return durationLabel ? `${baseTitle} (${durationLabel})` : baseTitle;
|
|
173
|
+
}
|
|
174
|
+
function resolveToolDescriptor(toolName) {
|
|
175
|
+
const normalizedName = (0, reasoning_utils_1.normalizeToolName)(toolName);
|
|
176
|
+
return TOOL_DESCRIPTORS.find((descriptor) => descriptor.aliases.some((alias) => normalizedName === alias || normalizedName.startsWith(`${alias}_`) || normalizedName.startsWith(`${alias}-`)));
|
|
177
|
+
}
|
|
178
|
+
function extractDetailFromParams(params, descriptor) {
|
|
179
|
+
if (!params)
|
|
180
|
+
return undefined;
|
|
181
|
+
if (descriptor.detailFromParams)
|
|
182
|
+
return descriptor.detailFromParams(params);
|
|
183
|
+
for (const key of descriptor.paramKeys ?? []) {
|
|
184
|
+
const value = params[key];
|
|
185
|
+
const text = extractScalarText(value);
|
|
186
|
+
if (text)
|
|
187
|
+
return text;
|
|
188
|
+
}
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
function extractDetailFromSummary(summaryText, descriptor) {
|
|
192
|
+
if (!summaryText)
|
|
193
|
+
return undefined;
|
|
194
|
+
const lines = summaryText
|
|
195
|
+
.replace(/\r\n/g, '\n')
|
|
196
|
+
.split('\n')
|
|
197
|
+
.map((line) => cleanupLine(stripMarkdown(line)))
|
|
198
|
+
.filter((line) => line && !isNoiseLine(line));
|
|
199
|
+
for (const line of lines) {
|
|
200
|
+
const signals = buildSummarySignals(line, descriptor.summaryPatterns ?? []);
|
|
201
|
+
const detail = pickSummaryDetail(signals, descriptor.summaryPreference ?? DEFAULT_SUMMARY_PREFERENCE);
|
|
202
|
+
if (detail)
|
|
203
|
+
return detail;
|
|
204
|
+
}
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
function buildSummarySignals(line, patterns) {
|
|
208
|
+
const matched = patterns
|
|
209
|
+
.map((pattern) => line.match(pattern)?.[1]?.trim())
|
|
210
|
+
.find((value) => Boolean(value));
|
|
211
|
+
return {
|
|
212
|
+
line,
|
|
213
|
+
matched,
|
|
214
|
+
code: extractFirstCodeSpan(line),
|
|
215
|
+
quoted: extractFirstQuotedText(line),
|
|
216
|
+
url: extractFirstUrl(line),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function pickSummaryDetail(signals, preference) {
|
|
220
|
+
for (const key of preference) {
|
|
221
|
+
const value = signals[key];
|
|
222
|
+
if (value)
|
|
223
|
+
return value;
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
function buildResultBlock(source, descriptor) {
|
|
228
|
+
if (source.result == null)
|
|
229
|
+
return undefined;
|
|
230
|
+
if (descriptor && ['Read', 'Edit', 'Fetch web page', 'Browser'].includes(descriptor.title)) {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
return buildDisplayBlock(sanitizeDisplayBlockValue(source.result, descriptor));
|
|
234
|
+
}
|
|
235
|
+
function buildErrorBlock(error, descriptor) {
|
|
236
|
+
return buildDisplayBlock(sanitizeDisplayBlockValue(error, descriptor), 'text');
|
|
237
|
+
}
|
|
238
|
+
function sanitizeDisplayBlockValue(value, descriptor) {
|
|
239
|
+
if (descriptor?.sanitizer === 'command' && typeof value === 'string') {
|
|
240
|
+
return (0, reasoning_utils_1.redactInlineSecrets)(value);
|
|
241
|
+
}
|
|
242
|
+
return value;
|
|
243
|
+
}
|
|
244
|
+
function buildPatternDetail(params, options) {
|
|
245
|
+
const pattern = extractScalarText(params.pattern);
|
|
246
|
+
const target = extractScalarText(params.glob ?? params.path ?? params.file_path);
|
|
247
|
+
if (pattern && target && options.includeTarget) {
|
|
248
|
+
return `${pattern} in ${target}`;
|
|
249
|
+
}
|
|
250
|
+
return pattern ?? target ?? undefined;
|
|
251
|
+
}
|
|
252
|
+
function extractScalarText(value) {
|
|
253
|
+
if (typeof value === 'string')
|
|
254
|
+
return value.trim() || undefined;
|
|
255
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
256
|
+
return String(value);
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
function sanitizeToolDetail(kind, value, options) {
|
|
260
|
+
if (kind === 'command') {
|
|
261
|
+
const cleaned = normalizeInlineDisplayText(value);
|
|
262
|
+
if (!cleaned)
|
|
263
|
+
return undefined;
|
|
264
|
+
return sanitizeCommandLike(cleaned, options);
|
|
265
|
+
}
|
|
266
|
+
const cleaned = sanitizeGenericText(value);
|
|
267
|
+
if (!cleaned)
|
|
268
|
+
return undefined;
|
|
269
|
+
switch (kind) {
|
|
270
|
+
case 'skill':
|
|
271
|
+
return (cleaned
|
|
272
|
+
.replace(/^skill\s+/i, '')
|
|
273
|
+
.replace(/[-_]+/g, ' ')
|
|
274
|
+
.trim() || 'skill');
|
|
275
|
+
case 'path':
|
|
276
|
+
return sanitizePathLike(cleaned, options);
|
|
277
|
+
case 'search':
|
|
278
|
+
return stripQuotes(cleaned);
|
|
279
|
+
case 'url':
|
|
280
|
+
return stripQuotes(cleaned).replace(/^from\s+/i, '');
|
|
281
|
+
case 'generic':
|
|
282
|
+
default:
|
|
283
|
+
return cleaned;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function normalizeInlineDisplayText(value) {
|
|
287
|
+
return value.replace(/\s+/g, ' ').trim();
|
|
288
|
+
}
|
|
289
|
+
function sanitizePathLike(value, options) {
|
|
290
|
+
const cleaned = sanitizeGenericText(value)
|
|
291
|
+
.replace(/^(?:from|file|path)\s+/i, '')
|
|
292
|
+
.trim();
|
|
293
|
+
if (options.showFullPaths)
|
|
294
|
+
return cleaned;
|
|
295
|
+
const skillMatch = cleaned.match(/(?:^|\/)skills\/([^/]+)\//i);
|
|
296
|
+
if (skillMatch?.[1]) {
|
|
297
|
+
return skillMatch[1].replace(/[-_]+/g, ' ').trim() || cleaned;
|
|
298
|
+
}
|
|
299
|
+
const segments = cleaned.split(/[\\/]/).filter(Boolean);
|
|
300
|
+
return segments.at(-1) ?? cleaned;
|
|
301
|
+
}
|
|
302
|
+
function sanitizeCommandLike(value, options) {
|
|
303
|
+
const cleaned = stripQuotes(value)
|
|
304
|
+
.replace(/^(?:command|script|description)\s+/i, '')
|
|
305
|
+
.replace(/^.*?\s+->\s+/i, '')
|
|
306
|
+
.trim();
|
|
307
|
+
if (!cleaned)
|
|
308
|
+
return 'command';
|
|
309
|
+
const redacted = (0, reasoning_utils_1.redactInlineSecrets)(cleaned);
|
|
310
|
+
return options.showFullPaths ? redacted : redactCommandPaths(redacted);
|
|
311
|
+
}
|
|
312
|
+
function resolveStepStatus(source) {
|
|
313
|
+
if (source.error)
|
|
314
|
+
return 'error';
|
|
315
|
+
if (source.status)
|
|
316
|
+
return source.status;
|
|
317
|
+
return 'success';
|
|
318
|
+
}
|
|
319
|
+
function buildDisplayBlock(value, fallbackLanguage = 'json') {
|
|
320
|
+
if (value == null)
|
|
321
|
+
return undefined;
|
|
322
|
+
if (typeof value === 'string') {
|
|
323
|
+
const normalized = value.replace(/\r\n/g, '\n').trim();
|
|
324
|
+
if (!normalized)
|
|
325
|
+
return undefined;
|
|
326
|
+
const parsed = tryParseJson(normalized);
|
|
327
|
+
if (parsed && typeof parsed === 'object') {
|
|
328
|
+
const prettyJson = stringifyJson(parsed);
|
|
329
|
+
if (prettyJson) {
|
|
330
|
+
return { language: 'json', content: prettyJson };
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return { language: fallbackLanguage === 'json' ? 'text' : fallbackLanguage, content: normalized };
|
|
334
|
+
}
|
|
335
|
+
if (typeof value === 'object') {
|
|
336
|
+
const prettyJson = stringifyJson(value);
|
|
337
|
+
if (prettyJson) {
|
|
338
|
+
return { language: 'json', content: prettyJson };
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const normalized = String(value).trim();
|
|
342
|
+
return normalized ? { language: 'text', content: normalized } : undefined;
|
|
343
|
+
}
|
|
344
|
+
function stringifyJson(value) {
|
|
345
|
+
try {
|
|
346
|
+
return JSON.stringify(value, null, 2);
|
|
347
|
+
}
|
|
348
|
+
catch {
|
|
349
|
+
return undefined;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function tryParseJson(value) {
|
|
353
|
+
const trimmed = value.trim();
|
|
354
|
+
if (!trimmed || !/^(?:\{|\[)/.test(trimmed)) {
|
|
355
|
+
return undefined;
|
|
356
|
+
}
|
|
357
|
+
try {
|
|
358
|
+
return JSON.parse(trimmed);
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
return undefined;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function redactCommandPaths(command) {
|
|
365
|
+
return command
|
|
366
|
+
.split(/(\s+)/)
|
|
367
|
+
.map((segment) => {
|
|
368
|
+
if (!segment || /^\s+$/.test(segment))
|
|
369
|
+
return segment;
|
|
370
|
+
return redactCommandToken(segment);
|
|
371
|
+
})
|
|
372
|
+
.join('');
|
|
373
|
+
}
|
|
374
|
+
function redactCommandToken(token) {
|
|
375
|
+
const match = token.match(/^([("'`]*)(.*?)([)"'`,;:]*)$/);
|
|
376
|
+
if (!match)
|
|
377
|
+
return token;
|
|
378
|
+
const [, prefix, rawCore, suffix] = match;
|
|
379
|
+
const core = redactPathAssignment(rawCore);
|
|
380
|
+
return `${prefix}${core}${suffix}`;
|
|
381
|
+
}
|
|
382
|
+
function redactPathAssignment(value) {
|
|
383
|
+
const equalsIndex = value.indexOf('=');
|
|
384
|
+
if (equalsIndex > 0) {
|
|
385
|
+
const left = value.slice(0, equalsIndex + 1);
|
|
386
|
+
const right = value.slice(equalsIndex + 1);
|
|
387
|
+
return `${left}${redactStandalonePath(right)}`;
|
|
388
|
+
}
|
|
389
|
+
return redactStandalonePath(value);
|
|
390
|
+
}
|
|
391
|
+
function redactStandalonePath(value) {
|
|
392
|
+
if (/^https?:\/\//i.test(value))
|
|
393
|
+
return sanitizeUrlForDisplay(value);
|
|
394
|
+
if (!looksLikePathToken(value))
|
|
395
|
+
return value;
|
|
396
|
+
return basenameFromPath(value);
|
|
397
|
+
}
|
|
398
|
+
function sanitizeUrlForDisplay(url) {
|
|
399
|
+
try {
|
|
400
|
+
const parsed = new URL(url);
|
|
401
|
+
parsed.username = '';
|
|
402
|
+
parsed.password = '';
|
|
403
|
+
for (const key of [...parsed.searchParams.keys()]) {
|
|
404
|
+
if (/(secret|token|password|key|credential|bearer|auth)/i.test(key)) {
|
|
405
|
+
parsed.searchParams.set(key, '[redacted]');
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
return parsed.toString();
|
|
409
|
+
}
|
|
410
|
+
catch {
|
|
411
|
+
return url;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function looksLikePathToken(value) {
|
|
415
|
+
return (value.startsWith('~/') ||
|
|
416
|
+
value.startsWith('./') ||
|
|
417
|
+
value.startsWith('../') ||
|
|
418
|
+
value.startsWith('/') ||
|
|
419
|
+
value.includes('/'));
|
|
420
|
+
}
|
|
421
|
+
function basenameFromPath(value) {
|
|
422
|
+
const cleaned = value.replace(/\\/g, '/').replace(/\/+$/, '');
|
|
423
|
+
const segments = cleaned.split('/').filter(Boolean);
|
|
424
|
+
return segments.at(-1) ?? value;
|
|
425
|
+
}
|
|
426
|
+
function isSkillPathValue(value) {
|
|
427
|
+
return /(?:^|\/)skills\/[^/]+\//i.test(value);
|
|
428
|
+
}
|
|
429
|
+
function sanitizeGenericText(value) {
|
|
430
|
+
return value
|
|
431
|
+
.replace(/<[^>]+>/g, '')
|
|
432
|
+
.replace(/\s+/g, ' ')
|
|
433
|
+
.trim();
|
|
434
|
+
}
|
|
435
|
+
function cleanupLine(line) {
|
|
436
|
+
return line
|
|
437
|
+
.replace(/^[-*•]\s*/, '')
|
|
438
|
+
.replace(/^\d+[.)]\s*/, '')
|
|
439
|
+
.replace(/\s+/g, ' ')
|
|
440
|
+
.trim();
|
|
441
|
+
}
|
|
442
|
+
function stripMarkdown(line) {
|
|
443
|
+
return line
|
|
444
|
+
.replace(/`([^`]+)`/g, '$1')
|
|
445
|
+
.replace(/\*\*([^*]+)\*\*/g, '$1')
|
|
446
|
+
.replace(/\*([^*]+)\*/g, '$1')
|
|
447
|
+
.replace(/^>\s*/, '')
|
|
448
|
+
.trim();
|
|
449
|
+
}
|
|
450
|
+
function isNoiseLine(line) {
|
|
451
|
+
return /^(?:completed|complete|done|success|succeeded|running|started|finished|ok)$/i.test(line);
|
|
452
|
+
}
|
|
453
|
+
function humanizeToolName(name) {
|
|
454
|
+
const cleaned = name.replace(/[-_]+/g, ' ').trim();
|
|
455
|
+
if (!cleaned)
|
|
456
|
+
return 'Tool';
|
|
457
|
+
return cleaned.charAt(0).toUpperCase() + cleaned.slice(1);
|
|
458
|
+
}
|
|
459
|
+
function formatDurationLabel(durationMs) {
|
|
460
|
+
return durationMs < 1000 ? `${durationMs} ms` : `${(durationMs / 1000).toFixed(1)} s`;
|
|
461
|
+
}
|
|
462
|
+
function stripQuotes(value) {
|
|
463
|
+
return value.replace(/^[`'"]+|[`'"]+$/g, '').trim();
|
|
464
|
+
}
|
|
465
|
+
function extractFirstCodeSpan(value) {
|
|
466
|
+
const match = value.match(/`([^`]+)`/);
|
|
467
|
+
return match?.[1]?.trim() || undefined;
|
|
468
|
+
}
|
|
469
|
+
function extractFirstQuotedText(value) {
|
|
470
|
+
const match = value.match(/["']([^"']+)["']/);
|
|
471
|
+
return match?.[1]?.trim() || undefined;
|
|
472
|
+
}
|
|
473
|
+
function extractFirstUrl(value) {
|
|
474
|
+
const match = value.match(/\bhttps?:\/\/[^\s"'`]+/i);
|
|
475
|
+
return match?.[0]?.trim() || undefined;
|
|
476
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*
|
|
5
|
+
* Runtime store for structured tool-use steps.
|
|
6
|
+
*
|
|
7
|
+
* The Feishu card renderer reads from this store by session key so it can
|
|
8
|
+
* render observable, replayable tool execution without relying purely on
|
|
9
|
+
* reply payload text.
|
|
10
|
+
*/
|
|
11
|
+
export interface ToolUseTraceStep {
|
|
12
|
+
id: string;
|
|
13
|
+
seq: number;
|
|
14
|
+
toolName: string;
|
|
15
|
+
toolCallId?: string;
|
|
16
|
+
runId?: string;
|
|
17
|
+
params?: Record<string, unknown>;
|
|
18
|
+
result?: unknown;
|
|
19
|
+
error?: string;
|
|
20
|
+
durationMs?: number;
|
|
21
|
+
status: 'running' | 'success' | 'error';
|
|
22
|
+
startedAt: number;
|
|
23
|
+
finishedAt?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function startToolUseTraceRun(sessionKey: string): void;
|
|
26
|
+
export declare function clearToolUseTraceRun(sessionKey: string): void;
|
|
27
|
+
export declare function hasToolUseTraceRun(sessionKey?: string): boolean;
|
|
28
|
+
export declare function recordToolUseStart(params: {
|
|
29
|
+
sessionKey?: string;
|
|
30
|
+
toolName: string;
|
|
31
|
+
toolParams?: Record<string, unknown>;
|
|
32
|
+
toolCallId?: string;
|
|
33
|
+
runId?: string;
|
|
34
|
+
}): void;
|
|
35
|
+
export declare function recordToolUseEnd(params: {
|
|
36
|
+
sessionKey?: string;
|
|
37
|
+
toolName: string;
|
|
38
|
+
toolParams?: Record<string, unknown>;
|
|
39
|
+
toolCallId?: string;
|
|
40
|
+
runId?: string;
|
|
41
|
+
result?: unknown;
|
|
42
|
+
error?: string;
|
|
43
|
+
durationMs?: number;
|
|
44
|
+
}): void;
|
|
45
|
+
export declare function getToolUseTraceSteps(sessionKey?: string): ToolUseTraceStep[];
|
|
46
|
+
export declare function sanitizeTraceValue(value: unknown, depth?: number, context?: {
|
|
47
|
+
source?: 'params' | 'result' | 'generic';
|
|
48
|
+
key?: string;
|
|
49
|
+
}): unknown;
|
|
50
|
+
/** @internal — test-only helper to reset module-level state between test cases. */
|
|
51
|
+
export declare function _resetForTesting(): void;
|