@zhin.js/core 1.3.2 → 1.3.4
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/README.md +7 -7
- package/lib/adapter.d.ts +22 -2
- package/lib/adapter.js +72 -2
- package/lib/agent-prompt.d.ts +0 -1
- package/lib/agent-prompt.js +0 -1
- package/lib/built/adapter-process.d.ts +0 -1
- package/lib/built/adapter-process.js +0 -1
- package/lib/built/agent-preset.d.ts +0 -1
- package/lib/built/agent-preset.js +0 -1
- package/lib/built/ai-access.d.ts +36 -0
- package/lib/built/ai-access.js +46 -0
- package/lib/built/ai-outbound/adapter-access.d.ts +3 -0
- package/lib/built/ai-outbound/adapter-access.js +9 -0
- package/lib/built/ai-outbound/extensions/onebot-keyboard.d.ts +2 -0
- package/lib/built/ai-outbound/extensions/onebot-keyboard.js +67 -0
- package/lib/built/ai-outbound/extensions/qq-message.d.ts +3 -0
- package/lib/built/ai-outbound/extensions/qq-message.js +23 -0
- package/lib/built/ai-outbound/index.d.ts +9 -0
- package/lib/built/ai-outbound/index.js +9 -0
- package/lib/built/ai-outbound/parse.d.ts +13 -0
- package/lib/built/ai-outbound/parse.js +108 -0
- package/lib/built/ai-outbound/plain-mention-rewrite.d.ts +6 -0
- package/lib/built/ai-outbound/plain-mention-rewrite.js +37 -0
- package/lib/built/ai-outbound/prompt.d.ts +11 -0
- package/lib/built/ai-outbound/prompt.js +44 -0
- package/lib/built/ai-outbound/resolve.d.ts +4 -0
- package/lib/built/ai-outbound/resolve.js +64 -0
- package/lib/built/ai-outbound/structured-detect.d.ts +3 -0
- package/lib/built/ai-outbound/structured-detect.js +7 -0
- package/lib/built/ai-outbound/types.d.ts +60 -0
- package/lib/built/ai-outbound/types.js +5 -0
- package/lib/built/ai-trigger.d.ts +5 -1
- package/lib/built/ai-trigger.js +3 -7
- package/lib/built/authorization.d.ts +0 -1
- package/lib/built/authorization.js +0 -1
- package/lib/built/command.d.ts +0 -1
- package/lib/built/command.js +1 -3
- package/lib/built/common-adapter-tools.d.ts +25 -26
- package/lib/built/common-adapter-tools.js +48 -49
- package/lib/built/component.d.ts +1 -3
- package/lib/built/component.js +2 -4
- package/lib/built/config.d.ts +4 -1
- package/lib/built/config.js +26 -5
- package/lib/built/connect-endpoint-instance.d.ts +0 -1
- package/lib/built/connect-endpoint-instance.js +3 -2
- package/lib/built/database.d.ts +1 -3
- package/lib/built/database.js +2 -4
- package/lib/built/dispatcher.d.ts +7 -7
- package/lib/built/dispatcher.js +20 -8
- package/lib/built/endpoint-commands.d.ts +0 -1
- package/lib/built/endpoint-commands.js +6 -9
- package/lib/built/endpoint-lifecycle-service.d.ts +2 -1
- package/lib/built/endpoint-lifecycle-service.js +26 -3
- package/lib/built/endpoint-lifecycle.d.ts +0 -1
- package/lib/built/endpoint-lifecycle.js +4 -4
- package/lib/built/endpoint-manager.d.ts +0 -1
- package/lib/built/endpoint-manager.js +0 -1
- package/lib/built/generated-qrcode.d.ts +0 -1
- package/lib/built/generated-qrcode.js +0 -1
- package/lib/built/generic-segment-mapper.d.ts +6 -0
- package/lib/built/generic-segment-mapper.js +232 -0
- package/lib/built/html-renderer-loader.d.ts +2 -1
- package/lib/built/html-renderer-loader.js +6 -2
- package/lib/built/html-segment-fallback.d.ts +0 -1
- package/lib/built/html-segment-fallback.js +0 -1
- package/lib/built/html-to-text.d.ts +0 -1
- package/lib/built/html-to-text.js +15 -15
- package/lib/built/inbound-pipeline.d.ts +1 -2
- package/lib/built/inbound-pipeline.js +1 -2
- package/lib/built/inbound-runner.d.ts +0 -1
- package/lib/built/inbound-runner.js +0 -1
- package/lib/built/interactive-segment-contract.d.ts +6 -0
- package/lib/built/interactive-segment-contract.js +9 -0
- package/lib/built/interactive-segments/action.d.ts +17 -0
- package/lib/built/interactive-segments/action.js +69 -0
- package/lib/built/interactive-segments/button-spec.d.ts +10 -0
- package/lib/built/interactive-segments/button-spec.js +21 -0
- package/lib/built/interactive-segments/handlers.d.ts +9 -0
- package/lib/built/interactive-segments/handlers.js +58 -0
- package/lib/built/interactive-segments/index.d.ts +7 -0
- package/lib/built/interactive-segments/index.js +7 -0
- package/lib/built/interactive-segments/keyboard-segment.d.ts +12 -0
- package/lib/built/interactive-segments/keyboard-segment.js +13 -0
- package/lib/built/interactive-segments/onebot-keyboard.d.ts +10 -0
- package/lib/built/interactive-segments/onebot-keyboard.js +53 -0
- package/lib/built/interactive-segments/resolve.d.ts +9 -0
- package/lib/built/interactive-segments/resolve.js +84 -0
- package/lib/built/interactive-segments/types.d.ts +62 -0
- package/lib/built/interactive-segments/types.js +13 -0
- package/lib/built/introspection-format.d.ts +0 -1
- package/lib/built/introspection-format.js +1 -1
- package/lib/built/login-assist.d.ts +0 -1
- package/lib/built/login-assist.js +0 -1
- package/lib/built/management-command-guard.d.ts +5 -1
- package/lib/built/management-command-guard.js +5 -1
- package/lib/built/message-enrich.d.ts +1 -2
- package/lib/built/message-enrich.js +0 -1
- package/lib/built/message-filter.d.ts +0 -1
- package/lib/built/message-filter.js +1 -3
- package/lib/built/optional-peer-import.d.ts +3 -0
- package/lib/built/optional-peer-import.js +33 -0
- package/lib/built/outbound-media-contract.d.ts +0 -1
- package/lib/built/outbound-media-contract.js +0 -1
- package/lib/built/outbound-media-utils.d.ts +0 -1
- package/lib/built/outbound-media-utils.js +0 -1
- package/lib/built/permission.d.ts +0 -1
- package/lib/built/permission.js +1 -3
- package/lib/built/permit-check.d.ts +1 -2
- package/lib/built/permit-check.js +0 -1
- package/lib/built/permit-parse.d.ts +0 -1
- package/lib/built/permit-parse.js +0 -1
- package/lib/built/platform-permit.d.ts +5 -6
- package/lib/built/platform-permit.js +11 -12
- package/lib/built/prepend-quote-context.d.ts +0 -1
- package/lib/built/prepend-quote-context.js +0 -1
- package/lib/built/qrcode-segment.d.ts +0 -1
- package/lib/built/qrcode-segment.js +0 -1
- package/lib/built/queue-im-field-contract.d.ts +6 -1
- package/lib/built/queue-im-field-contract.js +10 -1
- package/lib/built/rich-segments/adapter-policies.d.ts +1 -2
- package/lib/built/rich-segments/adapter-policies.js +0 -1
- package/lib/built/rich-segments/base.d.ts +0 -1
- package/lib/built/rich-segments/base.js +0 -1
- package/lib/built/rich-segments/builtins.d.ts +0 -1
- package/lib/built/rich-segments/builtins.js +0 -1
- package/lib/built/rich-segments/capabilities.d.ts +0 -1
- package/lib/built/rich-segments/capabilities.js +0 -1
- package/lib/built/rich-segments/html-segment.d.ts +1 -2
- package/lib/built/rich-segments/html-segment.js +0 -1
- package/lib/built/rich-segments/index.d.ts +0 -1
- package/lib/built/rich-segments/index.js +0 -1
- package/lib/built/rich-segments/markdown-segment.d.ts +1 -2
- package/lib/built/rich-segments/markdown-segment.js +0 -1
- package/lib/built/rich-segments/markdown-to-text.d.ts +0 -1
- package/lib/built/rich-segments/markdown-to-text.js +0 -1
- package/lib/built/rich-segments/qrcode-segment.d.ts +1 -2
- package/lib/built/rich-segments/qrcode-segment.js +0 -1
- package/lib/built/rich-segments/registry.d.ts +0 -1
- package/lib/built/rich-segments/registry.js +0 -1
- package/lib/built/rich-segments/resolve.d.ts +1 -2
- package/lib/built/rich-segments/resolve.js +0 -1
- package/lib/built/rich-segments/tts-segment.d.ts +1 -2
- package/lib/built/rich-segments/tts-segment.js +0 -1
- package/lib/built/rich-segments/types.d.ts +0 -1
- package/lib/built/rich-segments/types.js +0 -1
- package/lib/built/roles.d.ts +0 -1
- package/lib/built/roles.js +0 -1
- package/lib/built/runtime-io.d.ts +0 -1
- package/lib/built/runtime-io.js +0 -1
- package/lib/built/schedule.d.ts +54 -0
- package/lib/built/schedule.js +112 -0
- package/lib/built/schema-endpoint-manager.d.ts +0 -1
- package/lib/built/schema-endpoint-manager.js +0 -1
- package/lib/built/schema-feature.d.ts +0 -1
- package/lib/built/schema-feature.js +1 -3
- package/lib/built/segment-contract/assert.d.ts +4 -0
- package/lib/built/segment-contract/assert.js +30 -0
- package/lib/built/segment-contract/delivery.d.ts +5 -0
- package/lib/built/segment-contract/delivery.js +40 -0
- package/lib/built/segment-contract/image.d.ts +5 -0
- package/lib/built/segment-contract/image.js +10 -0
- package/lib/built/segment-contract/index.d.ts +8 -0
- package/lib/built/segment-contract/index.js +7 -0
- package/lib/built/segment-contract/media.d.ts +8 -0
- package/lib/built/segment-contract/media.js +39 -0
- package/lib/built/segment-contract/mention.d.ts +10 -0
- package/lib/built/segment-contract/mention.js +26 -0
- package/lib/built/segment-contract/preview.d.ts +3 -0
- package/lib/built/segment-contract/preview.js +159 -0
- package/lib/built/segment-contract/types.d.ts +70 -0
- package/lib/built/segment-contract/types.js +5 -0
- package/lib/built/segment-contract/validate.d.ts +138 -0
- package/lib/built/segment-contract/validate.js +124 -0
- package/lib/built/skill.d.ts +0 -1
- package/lib/built/skill.js +0 -1
- package/lib/built/speech-loader.d.ts +2 -1
- package/lib/built/speech-loader.js +6 -2
- package/lib/built/tool.d.ts +0 -1
- package/lib/built/tool.js +1 -3
- package/lib/command.d.ts +12 -7
- package/lib/command.js +38 -16
- package/lib/component.d.ts +0 -1
- package/lib/component.js +28 -12
- package/lib/endpoint-capabilities.d.ts +3 -1
- package/lib/endpoint-capabilities.js +0 -1
- package/lib/endpoint.d.ts +0 -1
- package/lib/endpoint.js +0 -1
- package/lib/errors.d.ts +0 -1
- package/lib/errors.js +0 -1
- package/lib/host-plugin-registry.d.ts +0 -1
- package/lib/host-plugin-registry.js +0 -1
- package/lib/im-scene.d.ts +29 -0
- package/lib/im-scene.js +77 -0
- package/lib/im-session-id.d.ts +25 -12
- package/lib/im-session-id.js +35 -17
- package/lib/index.d.ts +14 -7
- package/lib/index.js +12 -6
- package/lib/jsx-dev-runtime.d.ts +0 -1
- package/lib/jsx-dev-runtime.js +0 -1
- package/lib/jsx-runtime.d.ts +0 -1
- package/lib/jsx-runtime.js +0 -1
- package/lib/jsx.d.ts +0 -1
- package/lib/jsx.js +0 -1
- package/lib/message-quote.d.ts +1 -2
- package/lib/message-quote.js +2 -3
- package/lib/message.d.ts +7 -5
- package/lib/message.js +16 -1
- package/lib/models/system-log.d.ts +0 -1
- package/lib/models/system-log.js +0 -1
- package/lib/models/user.d.ts +0 -1
- package/lib/models/user.js +0 -1
- package/lib/notice.d.ts +15 -59
- package/lib/notice.js +1 -4
- package/lib/plugin-context.d.ts +0 -1
- package/lib/plugin-context.js +0 -1
- package/lib/plugin.d.ts +13 -6
- package/lib/plugin.js +31 -15
- package/lib/prompt.d.ts +0 -1
- package/lib/prompt.js +0 -1
- package/lib/request.d.ts +16 -60
- package/lib/request.js +0 -4
- package/lib/side-event/base.d.ts +45 -0
- package/lib/side-event/base.js +30 -0
- package/lib/side-event/index.d.ts +3 -0
- package/lib/side-event/index.js +3 -0
- package/lib/side-event/normalize.d.ts +40 -0
- package/lib/side-event/normalize.js +117 -0
- package/lib/side-event/types.d.ts +25 -0
- package/lib/side-event/types.js +55 -0
- package/lib/tool-zod.d.ts +0 -1
- package/lib/tool-zod.js +0 -1
- package/lib/types-generator.d.ts +0 -1
- package/lib/types-generator.js +0 -1
- package/lib/types.d.ts +30 -11
- package/lib/types.js +0 -1
- package/lib/utils.d.ts +36 -1
- package/lib/utils.js +33 -25
- package/package.json +15 -8
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js.map +0 -1
- package/lib/agent-prompt.d.ts.map +0 -1
- package/lib/agent-prompt.js.map +0 -1
- package/lib/built/adapter-process.d.ts.map +0 -1
- package/lib/built/adapter-process.js.map +0 -1
- package/lib/built/agent-preset.d.ts.map +0 -1
- package/lib/built/agent-preset.js.map +0 -1
- package/lib/built/ai-trigger.d.ts.map +0 -1
- package/lib/built/ai-trigger.js.map +0 -1
- package/lib/built/authorization.d.ts.map +0 -1
- package/lib/built/authorization.js.map +0 -1
- package/lib/built/command.d.ts.map +0 -1
- package/lib/built/command.js.map +0 -1
- package/lib/built/common-adapter-tools.d.ts.map +0 -1
- package/lib/built/common-adapter-tools.js.map +0 -1
- package/lib/built/component.d.ts.map +0 -1
- package/lib/built/component.js.map +0 -1
- package/lib/built/config.d.ts.map +0 -1
- package/lib/built/config.js.map +0 -1
- package/lib/built/connect-endpoint-instance.d.ts.map +0 -1
- package/lib/built/connect-endpoint-instance.js.map +0 -1
- package/lib/built/cron.d.ts +0 -75
- package/lib/built/cron.d.ts.map +0 -1
- package/lib/built/cron.js +0 -122
- package/lib/built/cron.js.map +0 -1
- package/lib/built/database.d.ts.map +0 -1
- package/lib/built/database.js.map +0 -1
- package/lib/built/dispatcher.d.ts.map +0 -1
- package/lib/built/dispatcher.js.map +0 -1
- package/lib/built/endpoint-commands.d.ts.map +0 -1
- package/lib/built/endpoint-commands.js.map +0 -1
- package/lib/built/endpoint-lifecycle-service.d.ts.map +0 -1
- package/lib/built/endpoint-lifecycle-service.js.map +0 -1
- package/lib/built/endpoint-lifecycle.d.ts.map +0 -1
- package/lib/built/endpoint-lifecycle.js.map +0 -1
- package/lib/built/endpoint-manager.d.ts.map +0 -1
- package/lib/built/endpoint-manager.js.map +0 -1
- package/lib/built/generated-qrcode.d.ts.map +0 -1
- package/lib/built/generated-qrcode.js.map +0 -1
- package/lib/built/html-renderer-loader.d.ts.map +0 -1
- package/lib/built/html-renderer-loader.js.map +0 -1
- package/lib/built/html-segment-fallback.d.ts.map +0 -1
- package/lib/built/html-segment-fallback.js.map +0 -1
- package/lib/built/html-to-text.d.ts.map +0 -1
- package/lib/built/html-to-text.js.map +0 -1
- package/lib/built/inbound-pipeline.d.ts.map +0 -1
- package/lib/built/inbound-pipeline.js.map +0 -1
- package/lib/built/inbound-runner.d.ts.map +0 -1
- package/lib/built/inbound-runner.js.map +0 -1
- package/lib/built/introspection-format.d.ts.map +0 -1
- package/lib/built/introspection-format.js.map +0 -1
- package/lib/built/login-assist.d.ts.map +0 -1
- package/lib/built/login-assist.js.map +0 -1
- package/lib/built/management-command-guard.d.ts.map +0 -1
- package/lib/built/management-command-guard.js.map +0 -1
- package/lib/built/mcp-mesh-registrar.d.ts +0 -9
- package/lib/built/mcp-mesh-registrar.d.ts.map +0 -1
- package/lib/built/mcp-mesh-registrar.js +0 -17
- package/lib/built/mcp-mesh-registrar.js.map +0 -1
- package/lib/built/message-enrich.d.ts.map +0 -1
- package/lib/built/message-enrich.js.map +0 -1
- package/lib/built/message-filter.d.ts.map +0 -1
- package/lib/built/message-filter.js.map +0 -1
- package/lib/built/outbound-media-contract.d.ts.map +0 -1
- package/lib/built/outbound-media-contract.js.map +0 -1
- package/lib/built/outbound-media-utils.d.ts.map +0 -1
- package/lib/built/outbound-media-utils.js.map +0 -1
- package/lib/built/permission.d.ts.map +0 -1
- package/lib/built/permission.js.map +0 -1
- package/lib/built/permit-check.d.ts.map +0 -1
- package/lib/built/permit-check.js.map +0 -1
- package/lib/built/permit-parse.d.ts.map +0 -1
- package/lib/built/permit-parse.js.map +0 -1
- package/lib/built/platform-permit.d.ts.map +0 -1
- package/lib/built/platform-permit.js.map +0 -1
- package/lib/built/prepend-quote-context.d.ts.map +0 -1
- package/lib/built/prepend-quote-context.js.map +0 -1
- package/lib/built/qrcode-segment.d.ts.map +0 -1
- package/lib/built/qrcode-segment.js.map +0 -1
- package/lib/built/queue-im-field-contract.d.ts.map +0 -1
- package/lib/built/queue-im-field-contract.js.map +0 -1
- package/lib/built/rich-segments/adapter-policies.d.ts.map +0 -1
- package/lib/built/rich-segments/adapter-policies.js.map +0 -1
- package/lib/built/rich-segments/base.d.ts.map +0 -1
- package/lib/built/rich-segments/base.js.map +0 -1
- package/lib/built/rich-segments/builtins.d.ts.map +0 -1
- package/lib/built/rich-segments/builtins.js.map +0 -1
- package/lib/built/rich-segments/capabilities.d.ts.map +0 -1
- package/lib/built/rich-segments/capabilities.js.map +0 -1
- package/lib/built/rich-segments/html-segment.d.ts.map +0 -1
- package/lib/built/rich-segments/html-segment.js.map +0 -1
- package/lib/built/rich-segments/index.d.ts.map +0 -1
- package/lib/built/rich-segments/index.js.map +0 -1
- package/lib/built/rich-segments/markdown-segment.d.ts.map +0 -1
- package/lib/built/rich-segments/markdown-segment.js.map +0 -1
- package/lib/built/rich-segments/markdown-to-text.d.ts.map +0 -1
- package/lib/built/rich-segments/markdown-to-text.js.map +0 -1
- package/lib/built/rich-segments/qrcode-segment.d.ts.map +0 -1
- package/lib/built/rich-segments/qrcode-segment.js.map +0 -1
- package/lib/built/rich-segments/registry.d.ts.map +0 -1
- package/lib/built/rich-segments/registry.js.map +0 -1
- package/lib/built/rich-segments/resolve.d.ts.map +0 -1
- package/lib/built/rich-segments/resolve.js.map +0 -1
- package/lib/built/rich-segments/tts-segment.d.ts.map +0 -1
- package/lib/built/rich-segments/tts-segment.js.map +0 -1
- package/lib/built/rich-segments/types.d.ts.map +0 -1
- package/lib/built/rich-segments/types.js.map +0 -1
- package/lib/built/roles.d.ts.map +0 -1
- package/lib/built/roles.js.map +0 -1
- package/lib/built/runtime-io.d.ts.map +0 -1
- package/lib/built/runtime-io.js.map +0 -1
- package/lib/built/schema-endpoint-manager.d.ts.map +0 -1
- package/lib/built/schema-endpoint-manager.js.map +0 -1
- package/lib/built/schema-feature.d.ts.map +0 -1
- package/lib/built/schema-feature.js.map +0 -1
- package/lib/built/skill.d.ts.map +0 -1
- package/lib/built/skill.js.map +0 -1
- package/lib/built/speech-loader.d.ts.map +0 -1
- package/lib/built/speech-loader.js.map +0 -1
- package/lib/built/tool.d.ts.map +0 -1
- package/lib/built/tool.js.map +0 -1
- package/lib/command.d.ts.map +0 -1
- package/lib/command.js.map +0 -1
- package/lib/component.d.ts.map +0 -1
- package/lib/component.js.map +0 -1
- package/lib/endpoint-capabilities.d.ts.map +0 -1
- package/lib/endpoint-capabilities.js.map +0 -1
- package/lib/endpoint.d.ts.map +0 -1
- package/lib/endpoint.js.map +0 -1
- package/lib/errors.d.ts.map +0 -1
- package/lib/errors.js.map +0 -1
- package/lib/host-plugin-registry.d.ts.map +0 -1
- package/lib/host-plugin-registry.js.map +0 -1
- package/lib/im-session-id.d.ts.map +0 -1
- package/lib/im-session-id.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/jsx-dev-runtime.d.ts.map +0 -1
- package/lib/jsx-dev-runtime.js.map +0 -1
- package/lib/jsx-runtime.d.ts.map +0 -1
- package/lib/jsx-runtime.js.map +0 -1
- package/lib/jsx.d.ts.map +0 -1
- package/lib/jsx.js.map +0 -1
- package/lib/message-quote.d.ts.map +0 -1
- package/lib/message-quote.js.map +0 -1
- package/lib/message.d.ts.map +0 -1
- package/lib/message.js.map +0 -1
- package/lib/models/system-log.d.ts.map +0 -1
- package/lib/models/system-log.js.map +0 -1
- package/lib/models/user.d.ts.map +0 -1
- package/lib/models/user.js.map +0 -1
- package/lib/notice.d.ts.map +0 -1
- package/lib/notice.js.map +0 -1
- package/lib/plugin-context.d.ts.map +0 -1
- package/lib/plugin-context.js.map +0 -1
- package/lib/plugin.d.ts.map +0 -1
- package/lib/plugin.js.map +0 -1
- package/lib/prompt.d.ts.map +0 -1
- package/lib/prompt.js.map +0 -1
- package/lib/request.d.ts.map +0 -1
- package/lib/request.js.map +0 -1
- package/lib/scheduler/scheduler.d.ts +0 -49
- package/lib/scheduler/scheduler.d.ts.map +0 -1
- package/lib/scheduler/scheduler.js +0 -352
- package/lib/scheduler/scheduler.js.map +0 -1
- package/lib/scheduler/types.d.ts +0 -71
- package/lib/scheduler/types.d.ts.map +0 -1
- package/lib/scheduler/types.js +0 -8
- package/lib/scheduler/types.js.map +0 -1
- package/lib/tool-zod.d.ts.map +0 -1
- package/lib/tool-zod.js.map +0 -1
- package/lib/types-generator.d.ts.map +0 -1
- package/lib/types-generator.js.map +0 -1
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js.map +0 -1
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js.map +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isKeyboardSegment } from './types.js';
|
|
2
|
+
import { KeyboardSegment } from './keyboard-segment.js';
|
|
3
|
+
/** OneBot / QQ 系 keyboard 段(各 adapter 在 $sendMessage 中识别) */
|
|
4
|
+
export function keyboardToOneBotSegment(data) {
|
|
5
|
+
return {
|
|
6
|
+
type: 'keyboard',
|
|
7
|
+
data: {
|
|
8
|
+
rows: data.rows.map((row) => row.map((btn) => ({
|
|
9
|
+
label: btn.label,
|
|
10
|
+
data: btn.payload,
|
|
11
|
+
enter: false,
|
|
12
|
+
action_type: 'callback',
|
|
13
|
+
disable: !!btn.disabled,
|
|
14
|
+
}))),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** @deprecated 使用 {@link keyboardToOneBotSegment} */
|
|
19
|
+
export const interactiveToKeyboardSegment = keyboardToOneBotSegment;
|
|
20
|
+
function asKeyboardData(item) {
|
|
21
|
+
if (item instanceof KeyboardSegment)
|
|
22
|
+
return item.data;
|
|
23
|
+
if (isKeyboardSegment(item))
|
|
24
|
+
return item.data;
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
/** 出站前将 core keyboard 段展开为 OneBot keyboard(保留前置 text 等段) */
|
|
28
|
+
export function expandKeyboardSegmentsInContent(content) {
|
|
29
|
+
const items = Array.isArray(content) ? content : [content];
|
|
30
|
+
const out = [];
|
|
31
|
+
for (const item of items) {
|
|
32
|
+
if (typeof item === 'string') {
|
|
33
|
+
out.push(item);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (typeof item.type !== 'string') {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const data = asKeyboardData(item);
|
|
40
|
+
if (data) {
|
|
41
|
+
out.push(keyboardToOneBotSegment(data));
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
out.push(item);
|
|
45
|
+
}
|
|
46
|
+
if (out.length === 0)
|
|
47
|
+
return { type: 'text', data: { text: '' } };
|
|
48
|
+
if (out.length === 1)
|
|
49
|
+
return out[0];
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
/** @deprecated 使用 {@link expandKeyboardSegmentsInContent} */
|
|
53
|
+
export const expandInteractiveSegmentsInContent = expandKeyboardSegmentsInContent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SendContent } from '../../types.js';
|
|
2
|
+
import { type InteractivePolicy } from './types.js';
|
|
3
|
+
export declare function hasKeyboardSegment(content: SendContent | undefined): boolean;
|
|
4
|
+
/** @deprecated 使用 {@link hasKeyboardSegment} */
|
|
5
|
+
export declare const hasInteractiveSegment: typeof hasKeyboardSegment;
|
|
6
|
+
/** 按 Adapter interactivePolicy 将 keyboard 段转为 native 保留或文本降级 */
|
|
7
|
+
export declare function resolveKeyboardSegments(content: SendContent, policy: InteractivePolicy): SendContent;
|
|
8
|
+
/** @deprecated 使用 {@link resolveKeyboardSegments} */
|
|
9
|
+
export declare const resolveInteractiveSegments: typeof resolveKeyboardSegments;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { segment } from '../../utils.js';
|
|
2
|
+
import { KeyboardSegment } from './keyboard-segment.js';
|
|
3
|
+
import { KEYBOARD_SEGMENT_TYPE, isKeyboardSegment, } from './types.js';
|
|
4
|
+
function asKeyboardData(item) {
|
|
5
|
+
if (item instanceof KeyboardSegment)
|
|
6
|
+
return item.data;
|
|
7
|
+
if (isKeyboardSegment(item))
|
|
8
|
+
return item.data;
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
function toKeyboardElement(data) {
|
|
12
|
+
return { type: KEYBOARD_SEGMENT_TYPE, data };
|
|
13
|
+
}
|
|
14
|
+
function asArray(content) {
|
|
15
|
+
return Array.isArray(content) ? content : [content];
|
|
16
|
+
}
|
|
17
|
+
function packSegments(out) {
|
|
18
|
+
if (out.length === 0)
|
|
19
|
+
return { type: 'text', data: { text: '' } };
|
|
20
|
+
if (out.length === 1)
|
|
21
|
+
return out[0];
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
function renderKeyboardAsText(data) {
|
|
25
|
+
const lines = [];
|
|
26
|
+
const flat = data.rows.flat();
|
|
27
|
+
if (data.fallback?.hint) {
|
|
28
|
+
lines.push(data.fallback.hint);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
lines.push('请选择(回复数字):');
|
|
32
|
+
}
|
|
33
|
+
const map = data.fallback?.map ?? {};
|
|
34
|
+
const entries = Object.keys(map).length > 0
|
|
35
|
+
? Object.entries(map).sort(([a], [b]) => Number(a) - Number(b))
|
|
36
|
+
: flat.map((btn, idx) => [String(idx + 1), btn.payload]);
|
|
37
|
+
for (const [key, payload] of entries) {
|
|
38
|
+
const btn = flat.find((b) => b.payload === payload);
|
|
39
|
+
const label = btn?.label ?? '·';
|
|
40
|
+
lines.push(`${key}. ${label}${btn?.disabled ? ' (不可用)' : ''}`);
|
|
41
|
+
}
|
|
42
|
+
return lines.join('\n');
|
|
43
|
+
}
|
|
44
|
+
export function hasKeyboardSegment(content) {
|
|
45
|
+
if (content == null)
|
|
46
|
+
return false;
|
|
47
|
+
return asArray(content).some((item) => {
|
|
48
|
+
if (typeof item === 'string')
|
|
49
|
+
return false;
|
|
50
|
+
return item instanceof KeyboardSegment || isKeyboardSegment(item);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/** @deprecated 使用 {@link hasKeyboardSegment} */
|
|
54
|
+
export const hasInteractiveSegment = hasKeyboardSegment;
|
|
55
|
+
/** 按 Adapter interactivePolicy 将 keyboard 段转为 native 保留或文本降级 */
|
|
56
|
+
export function resolveKeyboardSegments(content, policy) {
|
|
57
|
+
if (!hasKeyboardSegment(content))
|
|
58
|
+
return content;
|
|
59
|
+
const items = asArray(content);
|
|
60
|
+
const out = [];
|
|
61
|
+
for (const item of items) {
|
|
62
|
+
if (typeof item === 'string') {
|
|
63
|
+
out.push(item);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const data = item instanceof KeyboardSegment
|
|
67
|
+
? item.data
|
|
68
|
+
: isKeyboardSegment(item)
|
|
69
|
+
? item.data
|
|
70
|
+
: null;
|
|
71
|
+
if (!data) {
|
|
72
|
+
out.push(item);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (policy === 'native') {
|
|
76
|
+
out.push(toKeyboardElement(data));
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
out.push(segment.text(renderKeyboardAsText(data)));
|
|
80
|
+
}
|
|
81
|
+
return packSegments(out);
|
|
82
|
+
}
|
|
83
|
+
/** @deprecated 使用 {@link resolveKeyboardSegments} */
|
|
84
|
+
export const resolveInteractiveSegments = resolveKeyboardSegments;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { MessageElement } from '../../types.js';
|
|
2
|
+
export declare const KEYBOARD_SEGMENT_TYPE: "keyboard";
|
|
3
|
+
/** @deprecated 使用 {@link KEYBOARD_SEGMENT_TYPE} */
|
|
4
|
+
export declare const INTERACTIVE_SEGMENT_TYPE: "keyboard";
|
|
5
|
+
export declare const ACTION_SEGMENT_TYPE: "action";
|
|
6
|
+
export type ButtonStyle = 'primary' | 'danger' | 'secondary';
|
|
7
|
+
/** @deprecated 使用 {@link ButtonStyle} */
|
|
8
|
+
export type InteractiveButtonStyle = ButtonStyle;
|
|
9
|
+
/** callback:平台回调 action 入站;command:QQ 指令预填后文本入站 */
|
|
10
|
+
export type ButtonInteractionMode = 'callback' | 'command';
|
|
11
|
+
export interface ButtonCommandOptions {
|
|
12
|
+
/** QQ action.enter — 仅单聊;预填后自动发送 */
|
|
13
|
+
enter?: boolean;
|
|
14
|
+
/** QQ action.reply — 预填时引用原消息 */
|
|
15
|
+
reply?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface ButtonData {
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
payload: string;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
style?: ButtonStyle;
|
|
23
|
+
/** 默认 callback */
|
|
24
|
+
mode?: ButtonInteractionMode;
|
|
25
|
+
command?: ButtonCommandOptions;
|
|
26
|
+
}
|
|
27
|
+
/** @deprecated 使用 {@link ButtonData} */
|
|
28
|
+
export type InteractiveButton = ButtonData;
|
|
29
|
+
export interface KeyboardFallback {
|
|
30
|
+
hint: string;
|
|
31
|
+
map: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
/** @deprecated 使用 {@link KeyboardFallback} */
|
|
34
|
+
export type InteractiveFallback = KeyboardFallback;
|
|
35
|
+
export interface KeyboardSegmentData {
|
|
36
|
+
rows: ButtonData[][];
|
|
37
|
+
fallback?: KeyboardFallback;
|
|
38
|
+
}
|
|
39
|
+
/** @deprecated 使用 {@link KeyboardSegmentData} */
|
|
40
|
+
export type InteractiveSegmentData = KeyboardSegmentData;
|
|
41
|
+
export interface ActionSegmentData {
|
|
42
|
+
id: string;
|
|
43
|
+
payload: string;
|
|
44
|
+
sourceMessageId?: string;
|
|
45
|
+
}
|
|
46
|
+
export type InteractivePolicy = 'native' | 'text';
|
|
47
|
+
export declare const DEFAULT_INTERACTIVE_POLICY: InteractivePolicy;
|
|
48
|
+
export type InteractiveHandler = (message: import('../../message.js').Message<any>) => Promise<boolean> | boolean;
|
|
49
|
+
export interface RegisteredInteractiveHandler {
|
|
50
|
+
prefix: string;
|
|
51
|
+
handler: InteractiveHandler;
|
|
52
|
+
}
|
|
53
|
+
export declare function isKeyboardSegment(item: MessageElement): item is MessageElement & {
|
|
54
|
+
type: typeof KEYBOARD_SEGMENT_TYPE;
|
|
55
|
+
data: KeyboardSegmentData;
|
|
56
|
+
};
|
|
57
|
+
/** @deprecated 使用 {@link isKeyboardSegment} */
|
|
58
|
+
export declare const isInteractiveSegment: typeof isKeyboardSegment;
|
|
59
|
+
export declare function isActionSegment(item: MessageElement): item is MessageElement & {
|
|
60
|
+
type: typeof ACTION_SEGMENT_TYPE;
|
|
61
|
+
data: ActionSegmentData;
|
|
62
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const KEYBOARD_SEGMENT_TYPE = 'keyboard';
|
|
2
|
+
/** @deprecated 使用 {@link KEYBOARD_SEGMENT_TYPE} */
|
|
3
|
+
export const INTERACTIVE_SEGMENT_TYPE = KEYBOARD_SEGMENT_TYPE;
|
|
4
|
+
export const ACTION_SEGMENT_TYPE = 'action';
|
|
5
|
+
export const DEFAULT_INTERACTIVE_POLICY = 'text';
|
|
6
|
+
export function isKeyboardSegment(item) {
|
|
7
|
+
return item != null && typeof item === 'object' && 'type' in item && item.type === KEYBOARD_SEGMENT_TYPE;
|
|
8
|
+
}
|
|
9
|
+
/** @deprecated 使用 {@link isKeyboardSegment} */
|
|
10
|
+
export const isInteractiveSegment = isKeyboardSegment;
|
|
11
|
+
export function isActionSegment(item) {
|
|
12
|
+
return item != null && typeof item === 'object' && 'type' in item && item.type === ACTION_SEGMENT_TYPE;
|
|
13
|
+
}
|
|
@@ -21,8 +21,8 @@ export function endpointHelpText() {
|
|
|
21
21
|
' /endpoint start <adapter> <name>',
|
|
22
22
|
' /endpoint stop <adapter> <name>',
|
|
23
23
|
' /endpoint cancel — 取消进行中的添加/绑定',
|
|
24
|
+
' /endpoint sync — 将内存 endpoint 写回 zhin.config',
|
|
24
25
|
' /endpoint help',
|
|
25
26
|
' /endpoints — 查看运行时在线状态',
|
|
26
27
|
].join('\n');
|
|
27
28
|
}
|
|
28
|
-
//# sourceMappingURL=introspection-format.js.map
|
|
@@ -5,7 +5,11 @@ import { resolveSenderRoles, type AITriggerConfig } from './ai-trigger.js';
|
|
|
5
5
|
import type { Message } from '../message.js';
|
|
6
6
|
import type { Plugin } from '../plugin.js';
|
|
7
7
|
export declare const MANAGEMENT_COMMAND_DENIED = "\u26A0\uFE0F \u8BE5\u547D\u4EE4\u4EC5 Endpoint Owner\uFF08master\uFF09\u6216 trusted \u64CD\u4F5C\u5458\u53EF\u7528\u3002";
|
|
8
|
+
/** 运维 / 内省 / Endpoint 管理命令:仅 master 或 trusted 可执行与展示 */
|
|
9
|
+
export declare const MANAGEMENT_OPERATOR_PERMIT: "role(master,trusted)";
|
|
10
|
+
/** Endpoint Owner 私聊专用命令(如 /approve) */
|
|
11
|
+
export declare const OWNER_OPERATOR_PERMIT: "role(master)";
|
|
12
|
+
export declare const OWNER_PRIVATE_PERMITS: readonly ["role(master)", "private(*)"];
|
|
8
13
|
export declare function resolveManagementCommandRoles(message: Message, root: Plugin, triggerConfig?: AITriggerConfig): ReturnType<typeof resolveSenderRoles>['roles'];
|
|
9
14
|
/** 通过返回 null;拒绝返回用户可见提示文案 */
|
|
10
15
|
export declare function rejectUnlessManagementOperator(message: Message, root: Plugin, triggerConfig?: AITriggerConfig): string | null;
|
|
11
|
-
//# sourceMappingURL=management-command-guard.d.ts.map
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
import { mergeAITriggerConfig, resolveSenderRoles, } from './ai-trigger.js';
|
|
5
5
|
import { hasSenderRole } from './roles.js';
|
|
6
6
|
export const MANAGEMENT_COMMAND_DENIED = '⚠️ 该命令仅 Endpoint Owner(master)或 trusted 操作员可用。';
|
|
7
|
+
/** 运维 / 内省 / Endpoint 管理命令:仅 master 或 trusted 可执行与展示 */
|
|
8
|
+
export const MANAGEMENT_OPERATOR_PERMIT = 'role(master,trusted)';
|
|
9
|
+
/** Endpoint Owner 私聊专用命令(如 /approve) */
|
|
10
|
+
export const OWNER_OPERATOR_PERMIT = 'role(master)';
|
|
11
|
+
export const OWNER_PRIVATE_PERMITS = [OWNER_OPERATOR_PERMIT, 'private(*)'];
|
|
7
12
|
export function resolveManagementCommandRoles(message, root, triggerConfig) {
|
|
8
13
|
const cfg = mergeAITriggerConfig(triggerConfig ?? {});
|
|
9
14
|
const adapterInstance = root.inject(message.$adapter);
|
|
@@ -18,4 +23,3 @@ export function rejectUnlessManagementOperator(message, root, triggerConfig) {
|
|
|
18
23
|
}
|
|
19
24
|
return MANAGEMENT_COMMAND_DENIED;
|
|
20
25
|
}
|
|
21
|
-
//# sourceMappingURL=management-command-guard.js.map
|
|
@@ -5,7 +5,7 @@ import type { Plugin } from '../plugin.js';
|
|
|
5
5
|
import { Message, type MessageChannel } from '../message.js';
|
|
6
6
|
import type { Adapters } from '../adapter.js';
|
|
7
7
|
import type { SendContent } from '../types.js';
|
|
8
|
-
import type
|
|
8
|
+
import { type SenderRole } from './roles.js';
|
|
9
9
|
/** Agent turn 可挂载在 Message 扩展字段上的元数据 */
|
|
10
10
|
export type AgentTurnMessage = Message<{
|
|
11
11
|
extra?: Record<string, unknown>;
|
|
@@ -37,4 +37,3 @@ export declare function createSyntheticMessage(input: SyntheticMessageInput): Ag
|
|
|
37
37
|
export declare function commMessageFromHookContext(context: Record<string, unknown>): Message<any> | undefined;
|
|
38
38
|
/** 兼容 tool parameters 上的 contextKey(endpointId / sceneId / scope 等) */
|
|
39
39
|
export declare function resolveContextKey(message: Message<any>, key: string): unknown;
|
|
40
|
-
//# sourceMappingURL=message-enrich.d.ts.map
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* - 插件通过 `addFilterRule()` 动态注册规则,卸载时自动清理
|
|
14
14
|
*/
|
|
15
15
|
import { Feature } from '@zhin.js/kernel';
|
|
16
|
-
import { getPlugin } from '../plugin.js';
|
|
17
16
|
// ============================================================================
|
|
18
17
|
// 规则工厂
|
|
19
18
|
// ============================================================================
|
|
@@ -155,7 +154,7 @@ export class MessageFilterFeature extends Feature {
|
|
|
155
154
|
const feature = this;
|
|
156
155
|
return {
|
|
157
156
|
addFilterRule(rule) {
|
|
158
|
-
const plugin =
|
|
157
|
+
const plugin = this;
|
|
159
158
|
const dispose = feature.add(rule, plugin.name);
|
|
160
159
|
plugin.recordFeatureContribution(feature.name, rule.name);
|
|
161
160
|
plugin.onDispose(dispose);
|
|
@@ -238,4 +237,3 @@ export class MessageFilterFeature extends Feature {
|
|
|
238
237
|
});
|
|
239
238
|
}
|
|
240
239
|
}
|
|
241
|
-
//# sourceMappingURL=message-filter.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** 从应用根(ZHIN_PROJECT_ROOT / cwd)解析 optional peer,避免 core 包目录下 dynamic import 失败 */
|
|
2
|
+
export declare function resolveOptionalPeerPackage(packageName: string): string | undefined;
|
|
3
|
+
export declare function importOptionalPeerPackage<T = Record<string, unknown>>(packageName: string): Promise<T>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
/** 从应用根(ZHIN_PROJECT_ROOT / cwd)解析 optional peer,避免 core 包目录下 dynamic import 失败 */
|
|
5
|
+
export function resolveOptionalPeerPackage(packageName) {
|
|
6
|
+
const roots = new Set();
|
|
7
|
+
const envRoot = process.env.ZHIN_PROJECT_ROOT?.trim();
|
|
8
|
+
if (envRoot)
|
|
9
|
+
roots.add(path.resolve(envRoot));
|
|
10
|
+
roots.add(process.cwd());
|
|
11
|
+
for (const root of roots) {
|
|
12
|
+
try {
|
|
13
|
+
const req = createRequire(path.join(root, 'package.json'));
|
|
14
|
+
return req.resolve(packageName);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// try next root
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
return createRequire(import.meta.url).resolve(packageName);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function importOptionalPeerPackage(packageName) {
|
|
28
|
+
const resolved = resolveOptionalPeerPackage(packageName);
|
|
29
|
+
if (resolved) {
|
|
30
|
+
return import(pathToFileURL(resolved).href);
|
|
31
|
+
}
|
|
32
|
+
return import(packageName);
|
|
33
|
+
}
|
|
@@ -20,4 +20,3 @@ export type OutboundMediaMaterializer = (content: SendContent, ctx: OutboundMedi
|
|
|
20
20
|
export declare function assertAdapterDeclaresRichSegmentPolicy(adapterClass: {
|
|
21
21
|
outboundRichSegmentPolicy?: Record<string, string>;
|
|
22
22
|
}): void;
|
|
23
|
-
//# sourceMappingURL=outbound-media-contract.d.ts.map
|
|
@@ -7,4 +7,3 @@ export declare function resolveLocalMediaPath(data: Record<string, unknown>): st
|
|
|
7
7
|
export declare function asMessageElements(content: SendContent): MessageElement[];
|
|
8
8
|
export declare function isMediaSegmentType(type: string): boolean;
|
|
9
9
|
export declare function collectOutboundMediaKinds(content: SendContent | undefined): string[];
|
|
10
|
-
//# sourceMappingURL=outbound-media-utils.d.ts.map
|
package/lib/built/permission.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Feature } from "@zhin.js/kernel";
|
|
6
6
|
import logger, { formatCompact } from "@zhin.js/logger";
|
|
7
|
-
import { getPlugin } from "../plugin.js";
|
|
8
7
|
import { isBuiltinPermit, parsePermitName } from "./permit-parse.js";
|
|
9
8
|
import { checkBuiltinPermit } from "./permit-check.js";
|
|
10
9
|
import { senderRolesFromMessage } from "./message-enrich.js";
|
|
@@ -81,7 +80,7 @@ export class PermissionFeature extends Feature {
|
|
|
81
80
|
const feature = this;
|
|
82
81
|
return {
|
|
83
82
|
addPermission(permission) {
|
|
84
|
-
const plugin =
|
|
83
|
+
const plugin = this;
|
|
85
84
|
const dispose = feature.add(permission, plugin.name);
|
|
86
85
|
const permName = permission.name instanceof RegExp ? permission.name.source : permission.name;
|
|
87
86
|
plugin.recordFeatureContribution(feature.name, permName);
|
|
@@ -102,4 +101,3 @@ export var Permissions;
|
|
|
102
101
|
* @deprecated Use PermissionFeature instead
|
|
103
102
|
*/
|
|
104
103
|
export const PermissionService = PermissionFeature;
|
|
105
|
-
//# sourceMappingURL=permission.js.map
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* 内置 permit 同步校验(adapter/group/private/channel/user/role)
|
|
3
3
|
*/
|
|
4
4
|
import type { Message } from '../message.js';
|
|
5
|
-
import type
|
|
5
|
+
import { type SenderRole } from './roles.js';
|
|
6
6
|
export declare function checkBuiltinPermit(name: string, message: Message<any>, roles: readonly SenderRole[]): boolean;
|
|
7
7
|
export declare function checkBuiltinPermitList(permits: readonly string[], message: Message<any>, roles: readonly SenderRole[]): boolean;
|
|
8
|
-
//# sourceMappingURL=permit-check.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Platform permit —
|
|
2
|
+
* Platform permit — 适配器注册的平台级权限校验(场景治理、频道身份等)
|
|
3
3
|
*/
|
|
4
4
|
import type { Message } from '../message.js';
|
|
5
5
|
export type PlatformPermitChecker = (perm: string, message: Message<any>) => boolean;
|
|
@@ -14,8 +14,7 @@ export declare function applyQqSenderRoleToMessageSender(sender: {
|
|
|
14
14
|
role?: string;
|
|
15
15
|
permissions?: string[];
|
|
16
16
|
}, role?: string): void;
|
|
17
|
-
/** 常见 IM
|
|
18
|
-
export declare function
|
|
19
|
-
/**
|
|
20
|
-
export declare function
|
|
21
|
-
//# sourceMappingURL=platform-permit.d.ts.map
|
|
17
|
+
/** 常见 IM 平台场景身份:$sender.role 为 owner / admin */
|
|
18
|
+
export declare function createSceneRolePlatformChecker(): PlatformPermitChecker;
|
|
19
|
+
/** 为适配器注册默认场景治理 platform checker(幂等) */
|
|
20
|
+
export declare function registerDefaultScenePlatformPermitChecker(adapter: string): () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parsePlatformPermitName, isPlatformPermit } from './permit-parse.js';
|
|
2
2
|
const checkers = new Map();
|
|
3
|
-
const
|
|
3
|
+
const registeredDefaultSceneCheckers = new Set();
|
|
4
4
|
export function registerPlatformPermitChecker(adapter, checker) {
|
|
5
5
|
const key = String(adapter);
|
|
6
6
|
checkers.set(key, checker);
|
|
@@ -12,7 +12,7 @@ export function registerPlatformPermitChecker(adapter, checker) {
|
|
|
12
12
|
}
|
|
13
13
|
export function clearPlatformPermitCheckers() {
|
|
14
14
|
checkers.clear();
|
|
15
|
-
|
|
15
|
+
registeredDefaultSceneCheckers.clear();
|
|
16
16
|
}
|
|
17
17
|
export function checkPlatformPermit(name, message) {
|
|
18
18
|
const parsed = parsePlatformPermitName(name);
|
|
@@ -44,24 +44,23 @@ export function applyQqSenderRoleToMessageSender(sender, role) {
|
|
|
44
44
|
sender.role = normalized;
|
|
45
45
|
sender.permissions = [normalized];
|
|
46
46
|
}
|
|
47
|
-
/** 常见 IM
|
|
48
|
-
export function
|
|
47
|
+
/** 常见 IM 平台场景身份:$sender.role 为 owner / admin */
|
|
48
|
+
export function createSceneRolePlatformChecker() {
|
|
49
49
|
return (perm, message) => {
|
|
50
50
|
const role = message.$sender?.role;
|
|
51
|
-
if (perm === '
|
|
51
|
+
if (perm === 'scene_admin')
|
|
52
52
|
return role === 'admin' || role === 'owner';
|
|
53
|
-
if (perm === '
|
|
53
|
+
if (perm === 'scene_owner')
|
|
54
54
|
return role === 'owner';
|
|
55
55
|
return false;
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
/**
|
|
59
|
-
export function
|
|
58
|
+
/** 为适配器注册默认场景治理 platform checker(幂等) */
|
|
59
|
+
export function registerDefaultScenePlatformPermitChecker(adapter) {
|
|
60
60
|
const key = String(adapter);
|
|
61
|
-
if (
|
|
61
|
+
if (registeredDefaultSceneCheckers.has(key)) {
|
|
62
62
|
return () => { };
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
return registerPlatformPermitChecker(key,
|
|
64
|
+
registeredDefaultSceneCheckers.add(key);
|
|
65
|
+
return registerPlatformPermitChecker(key, createSceneRolePlatformChecker());
|
|
66
66
|
}
|
|
67
|
-
//# sourceMappingURL=platform-permit.js.map
|
|
@@ -32,4 +32,3 @@ export declare function resolveQuoteContextBlock(message: Message<any>, root: Pl
|
|
|
32
32
|
export declare function prependQuoteContext(message: Message<any>, root: Plugin, userText: string, options?: {
|
|
33
33
|
enabled?: boolean;
|
|
34
34
|
}): Promise<string>;
|
|
35
|
-
//# sourceMappingURL=prepend-quote-context.d.ts.map
|
|
@@ -128,4 +128,3 @@ export async function prependQuoteContext(message, root, userText, options) {
|
|
|
128
128
|
const quoteBlock = await resolveQuoteContextBlock(message, root, options);
|
|
129
129
|
return buildUserTurnWithQuoteContext(userText, quoteBlock);
|
|
130
130
|
}
|
|
131
|
-
//# sourceMappingURL=prepend-quote-context.js.map
|
|
@@ -16,4 +16,3 @@ export declare function resolveQrcodeSegmentsToImages(content: SendContent | und
|
|
|
16
16
|
export declare function resolveQrcodeSegmentsToTerminal(content: SendContent | undefined): Promise<SendContent | undefined>;
|
|
17
17
|
/** 不支持图片的平台:仅输出链接文本 */
|
|
18
18
|
export declare function coerceQrcodeSegmentsToText(content: SendContent): SendContent;
|
|
19
|
-
//# sourceMappingURL=qrcode-segment.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MessageType } from '../message.js';
|
|
2
2
|
import type { SendContent, SendOptions } from '../types.js';
|
|
3
|
+
import { type IMDeliveryTarget } from '../im-scene.js';
|
|
3
4
|
export interface QueueEnvelope<TDetail extends Record<string, unknown> = Record<string, unknown>> {
|
|
4
5
|
kind: string;
|
|
5
6
|
type: string;
|
|
@@ -23,5 +24,9 @@ export declare function isMessageType(value: unknown): value is MessageType;
|
|
|
23
24
|
/** Normalize queue outbound detail into the canonical queue-IM shape. */
|
|
24
25
|
export declare function normalizeQueueOutboundDetail(record: Record<string, unknown>): NormalizedQueueOutboundDetail;
|
|
25
26
|
export declare function toSendOptions(detail: NormalizedQueueOutboundDetail): SendOptions;
|
|
27
|
+
export interface QueueIMSceneTargetDetail {
|
|
28
|
+
target: IMDeliveryTarget;
|
|
29
|
+
content: SendContent;
|
|
30
|
+
}
|
|
31
|
+
export declare function sceneTargetToSendOptions(detail: QueueIMSceneTargetDetail): SendOptions;
|
|
26
32
|
export declare function normalizeRecordToSendOptions(record: Record<string, unknown>): SendOptions;
|
|
27
|
-
//# sourceMappingURL=queue-im-field-contract.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sceneRefToSendOptions } from '../im-scene.js';
|
|
1
2
|
export class QueueIMFieldContractError extends Error {
|
|
2
3
|
code;
|
|
3
4
|
field;
|
|
@@ -52,7 +53,15 @@ export function toSendOptions(detail) {
|
|
|
52
53
|
content: detail.content,
|
|
53
54
|
};
|
|
54
55
|
}
|
|
56
|
+
export function sceneTargetToSendOptions(detail) {
|
|
57
|
+
return sceneRefToSendOptions(detail.target, detail.content);
|
|
58
|
+
}
|
|
55
59
|
export function normalizeRecordToSendOptions(record) {
|
|
60
|
+
if (record.target && typeof record.target === 'object') {
|
|
61
|
+
return sceneTargetToSendOptions({
|
|
62
|
+
target: record.target,
|
|
63
|
+
content: requireContent(record.content),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
56
66
|
return toSendOptions(normalizeQueueOutboundDetail(record));
|
|
57
67
|
}
|
|
58
|
-
//# sourceMappingURL=queue-im-field-contract.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type OutboundRichSegmentPolicy } from './types.js';
|
|
2
2
|
/** 全功能 IM:html/markdown/qrcode→image,tts→audio */
|
|
3
3
|
export declare const OUTBOUND_RICH_SEGMENT_POLICY_IM_FULL: OutboundRichSegmentPolicy;
|
|
4
4
|
/** 仅文本降级(无富媒体出站能力) */
|
|
@@ -7,4 +7,3 @@ export declare const OUTBOUND_RICH_SEGMENT_POLICY_TEXT_ONLY: OutboundRichSegment
|
|
|
7
7
|
export declare const OUTBOUND_RICH_SEGMENT_POLICY_IM_DEFAULT: OutboundRichSegmentPolicy;
|
|
8
8
|
/** 无音频出站(tts 降级 text) */
|
|
9
9
|
export declare const OUTBOUND_RICH_SEGMENT_POLICY_NO_AUDIO: OutboundRichSegmentPolicy;
|
|
10
|
-
//# sourceMappingURL=adapter-policies.d.ts.map
|