@zhin.js/core 1.3.2 → 1.3.3
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 +71 -1
- 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 +94 -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 +0 -1
- package/lib/built/component.js +1 -3
- 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 +0 -1
- package/lib/built/database.js +1 -3
- package/lib/built/dispatcher.d.ts +6 -6
- 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 +25 -3
- package/lib/built/endpoint-lifecycle.d.ts +0 -1
- package/lib/built/endpoint-lifecycle.js +0 -1
- 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 +0 -1
- package/lib/built/inbound-pipeline.d.ts +0 -1
- package/lib/built/inbound-pipeline.js +0 -1
- 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 +54 -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 +0 -1
- 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 +0 -1
- 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 +55 -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 +0 -1
- 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 +13 -7
- package/lib/index.js +11 -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 +0 -1
- package/lib/notice.js +0 -1
- package/lib/plugin-context.d.ts +0 -1
- package/lib/plugin-context.js +0 -1
- package/lib/plugin.d.ts +11 -2
- package/lib/plugin.js +19 -7
- package/lib/prompt.d.ts +0 -1
- package/lib/prompt.js +0 -1
- package/lib/request.d.ts +0 -1
- package/lib/request.js +0 -1
- 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,138 @@
|
|
|
1
|
+
import { Schema } from '@zhin.js/schema';
|
|
2
|
+
import type { MediaRef, Segment } from './types.js';
|
|
3
|
+
export declare const mediaRefSchema: Schema<{
|
|
4
|
+
kind?: any;
|
|
5
|
+
value?: string | undefined;
|
|
6
|
+
mime_type?: string | undefined;
|
|
7
|
+
}, {
|
|
8
|
+
kind?: any;
|
|
9
|
+
value?: string | undefined;
|
|
10
|
+
mime_type?: string | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const textSegmentSchema: Schema<{
|
|
13
|
+
type?: "text" | undefined;
|
|
14
|
+
data?: {
|
|
15
|
+
text?: string | undefined;
|
|
16
|
+
} | undefined;
|
|
17
|
+
platform?: Record<string, any> | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
type?: "text" | undefined;
|
|
20
|
+
data?: {
|
|
21
|
+
text?: string | undefined;
|
|
22
|
+
} | undefined;
|
|
23
|
+
platform?: Record<string, any> | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const mentionSegmentSchema: Schema<{
|
|
26
|
+
type?: "mention" | undefined;
|
|
27
|
+
data?: {
|
|
28
|
+
target?: string | undefined;
|
|
29
|
+
name?: string | undefined;
|
|
30
|
+
} | undefined;
|
|
31
|
+
platform?: Record<string, any> | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
type?: "mention" | undefined;
|
|
34
|
+
data?: {
|
|
35
|
+
target?: string | undefined;
|
|
36
|
+
name?: string | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
platform?: Record<string, any> | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const imageSegmentSchema: Schema<{
|
|
41
|
+
type?: "image" | undefined;
|
|
42
|
+
data?: {
|
|
43
|
+
media?: {
|
|
44
|
+
kind?: any;
|
|
45
|
+
value?: string | undefined;
|
|
46
|
+
mime_type?: string | undefined;
|
|
47
|
+
} | undefined;
|
|
48
|
+
alt?: string | undefined;
|
|
49
|
+
} | undefined;
|
|
50
|
+
platform?: Record<string, any> | undefined;
|
|
51
|
+
}, {
|
|
52
|
+
type?: "image" | undefined;
|
|
53
|
+
data?: {
|
|
54
|
+
media?: {
|
|
55
|
+
kind?: any;
|
|
56
|
+
value?: string | undefined;
|
|
57
|
+
mime_type?: string | undefined;
|
|
58
|
+
} | undefined;
|
|
59
|
+
alt?: string | undefined;
|
|
60
|
+
} | undefined;
|
|
61
|
+
platform?: Record<string, any> | undefined;
|
|
62
|
+
}>;
|
|
63
|
+
export declare const replySegmentSchema: Schema<{
|
|
64
|
+
type?: "reply" | undefined;
|
|
65
|
+
data?: {
|
|
66
|
+
message_id?: string | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
platform?: Record<string, any> | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
type?: "reply" | undefined;
|
|
71
|
+
data?: {
|
|
72
|
+
message_id?: string | undefined;
|
|
73
|
+
} | undefined;
|
|
74
|
+
platform?: Record<string, any> | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
export declare const forwardSegmentSchema: Schema<{
|
|
77
|
+
type?: "forward" | undefined;
|
|
78
|
+
data?: {
|
|
79
|
+
forward_id?: string | undefined;
|
|
80
|
+
title?: string | undefined;
|
|
81
|
+
messages?: any[][] | undefined;
|
|
82
|
+
} | undefined;
|
|
83
|
+
platform?: Record<string, any> | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
type?: "forward" | undefined;
|
|
86
|
+
data?: {
|
|
87
|
+
forward_id?: string | undefined;
|
|
88
|
+
title?: string | undefined;
|
|
89
|
+
messages?: any[][] | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
platform?: Record<string, any> | undefined;
|
|
92
|
+
}>;
|
|
93
|
+
export declare const faceSegmentSchema: Schema<{
|
|
94
|
+
type?: "face" | undefined;
|
|
95
|
+
data?: {
|
|
96
|
+
id?: any;
|
|
97
|
+
name?: string | undefined;
|
|
98
|
+
} | undefined;
|
|
99
|
+
platform?: Record<string, any> | undefined;
|
|
100
|
+
}, {
|
|
101
|
+
type?: "face" | undefined;
|
|
102
|
+
data?: {
|
|
103
|
+
id?: any;
|
|
104
|
+
name?: string | undefined;
|
|
105
|
+
} | undefined;
|
|
106
|
+
platform?: Record<string, any> | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
export declare const diceSegmentSchema: Schema<{
|
|
109
|
+
type?: "dice" | undefined;
|
|
110
|
+
data?: {
|
|
111
|
+
result?: number | undefined;
|
|
112
|
+
} | undefined;
|
|
113
|
+
platform?: Record<string, any> | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
type?: "dice" | undefined;
|
|
116
|
+
data?: {
|
|
117
|
+
result?: number | undefined;
|
|
118
|
+
} | undefined;
|
|
119
|
+
platform?: Record<string, any> | undefined;
|
|
120
|
+
}>;
|
|
121
|
+
export declare const rpsSegmentSchema: Schema<{
|
|
122
|
+
type?: "rps" | undefined;
|
|
123
|
+
data?: {
|
|
124
|
+
result?: number | undefined;
|
|
125
|
+
} | undefined;
|
|
126
|
+
platform?: Record<string, any> | undefined;
|
|
127
|
+
}, {
|
|
128
|
+
type?: "rps" | undefined;
|
|
129
|
+
data?: {
|
|
130
|
+
result?: number | undefined;
|
|
131
|
+
} | undefined;
|
|
132
|
+
platform?: Record<string, any> | undefined;
|
|
133
|
+
}>;
|
|
134
|
+
export declare const canonicalSegmentSchema: Schema<any, any>;
|
|
135
|
+
export declare const segmentArraySchema: Schema<any[], any[]>;
|
|
136
|
+
export declare function isMediaRef(value: unknown): value is MediaRef;
|
|
137
|
+
/** 严格 canonical 段校验(@zhin.js/schema validate-only) */
|
|
138
|
+
export declare function isStrictCanonicalSegment(value: unknown): value is Segment;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Schema } from '@zhin.js/schema';
|
|
2
|
+
const platformSchema = Schema.dict(Schema.any());
|
|
3
|
+
const mediaKindSchema = Schema.union([
|
|
4
|
+
Schema.const('url'),
|
|
5
|
+
Schema.const('path'),
|
|
6
|
+
Schema.const('base64'),
|
|
7
|
+
]);
|
|
8
|
+
export const mediaRefSchema = Schema.object({
|
|
9
|
+
kind: mediaKindSchema.required(),
|
|
10
|
+
value: Schema.string().required(),
|
|
11
|
+
mime_type: Schema.string(),
|
|
12
|
+
});
|
|
13
|
+
export const textSegmentSchema = Schema.object({
|
|
14
|
+
type: Schema.const('text'),
|
|
15
|
+
data: Schema.object({ text: Schema.string().required() }).required(),
|
|
16
|
+
platform: platformSchema,
|
|
17
|
+
});
|
|
18
|
+
export const mentionSegmentSchema = Schema.object({
|
|
19
|
+
type: Schema.const('mention'),
|
|
20
|
+
data: Schema.object({
|
|
21
|
+
target: Schema.string().required(),
|
|
22
|
+
name: Schema.string(),
|
|
23
|
+
}).required(),
|
|
24
|
+
platform: platformSchema,
|
|
25
|
+
});
|
|
26
|
+
export const imageSegmentSchema = Schema.object({
|
|
27
|
+
type: Schema.const('image'),
|
|
28
|
+
data: Schema.object({
|
|
29
|
+
media: mediaRefSchema.required(),
|
|
30
|
+
alt: Schema.string(),
|
|
31
|
+
}).required(),
|
|
32
|
+
platform: platformSchema,
|
|
33
|
+
});
|
|
34
|
+
export const replySegmentSchema = Schema.object({
|
|
35
|
+
type: Schema.const('reply'),
|
|
36
|
+
data: Schema.object({ message_id: Schema.string().required() }).required(),
|
|
37
|
+
platform: platformSchema,
|
|
38
|
+
});
|
|
39
|
+
export const forwardSegmentSchema = Schema.object({
|
|
40
|
+
type: Schema.const('forward'),
|
|
41
|
+
data: Schema.object({
|
|
42
|
+
forward_id: Schema.string().required(),
|
|
43
|
+
title: Schema.string(),
|
|
44
|
+
messages: Schema.list(Schema.list(Schema.any())),
|
|
45
|
+
}).required(),
|
|
46
|
+
platform: platformSchema,
|
|
47
|
+
});
|
|
48
|
+
const stringOrNumberSchema = Schema.union([
|
|
49
|
+
Schema.string(),
|
|
50
|
+
Schema.number(),
|
|
51
|
+
]);
|
|
52
|
+
export const faceSegmentSchema = Schema.object({
|
|
53
|
+
type: Schema.const('face'),
|
|
54
|
+
data: Schema.object({
|
|
55
|
+
id: stringOrNumberSchema.required(),
|
|
56
|
+
name: Schema.string(),
|
|
57
|
+
}).required(),
|
|
58
|
+
platform: platformSchema,
|
|
59
|
+
});
|
|
60
|
+
export const diceSegmentSchema = Schema.object({
|
|
61
|
+
type: Schema.const('dice'),
|
|
62
|
+
data: Schema.object({ result: Schema.number() }).required(),
|
|
63
|
+
platform: platformSchema,
|
|
64
|
+
});
|
|
65
|
+
export const rpsSegmentSchema = Schema.object({
|
|
66
|
+
type: Schema.const('rps'),
|
|
67
|
+
data: Schema.object({ result: Schema.number() }).required(),
|
|
68
|
+
platform: platformSchema,
|
|
69
|
+
});
|
|
70
|
+
export const canonicalSegmentSchema = Schema.discriminatedUnion('type', {
|
|
71
|
+
text: {
|
|
72
|
+
data: Schema.object({ text: Schema.string().required() }).required(),
|
|
73
|
+
platform: platformSchema,
|
|
74
|
+
},
|
|
75
|
+
mention: {
|
|
76
|
+
data: Schema.object({
|
|
77
|
+
target: Schema.string().required(),
|
|
78
|
+
name: Schema.string(),
|
|
79
|
+
}).required(),
|
|
80
|
+
platform: platformSchema,
|
|
81
|
+
},
|
|
82
|
+
image: {
|
|
83
|
+
data: Schema.object({
|
|
84
|
+
media: mediaRefSchema.required(),
|
|
85
|
+
alt: Schema.string(),
|
|
86
|
+
}).required(),
|
|
87
|
+
platform: platformSchema,
|
|
88
|
+
},
|
|
89
|
+
reply: {
|
|
90
|
+
data: Schema.object({ message_id: Schema.string().required() }).required(),
|
|
91
|
+
platform: platformSchema,
|
|
92
|
+
},
|
|
93
|
+
forward: {
|
|
94
|
+
data: Schema.object({
|
|
95
|
+
forward_id: Schema.string().required(),
|
|
96
|
+
title: Schema.string(),
|
|
97
|
+
messages: Schema.list(Schema.list(Schema.any())),
|
|
98
|
+
}).required(),
|
|
99
|
+
platform: platformSchema,
|
|
100
|
+
},
|
|
101
|
+
face: {
|
|
102
|
+
data: Schema.object({
|
|
103
|
+
id: stringOrNumberSchema.required(),
|
|
104
|
+
name: Schema.string(),
|
|
105
|
+
}).required(),
|
|
106
|
+
platform: platformSchema,
|
|
107
|
+
},
|
|
108
|
+
dice: {
|
|
109
|
+
data: Schema.object({ result: Schema.number() }).required(),
|
|
110
|
+
platform: platformSchema,
|
|
111
|
+
},
|
|
112
|
+
rps: {
|
|
113
|
+
data: Schema.object({ result: Schema.number() }).required(),
|
|
114
|
+
platform: platformSchema,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
export const segmentArraySchema = Schema.list(canonicalSegmentSchema);
|
|
118
|
+
export function isMediaRef(value) {
|
|
119
|
+
return mediaRefSchema.safeParse(value).success;
|
|
120
|
+
}
|
|
121
|
+
/** 严格 canonical 段校验(@zhin.js/schema validate-only) */
|
|
122
|
+
export function isStrictCanonicalSegment(value) {
|
|
123
|
+
return canonicalSegmentSchema.safeParse(value).success;
|
|
124
|
+
}
|
package/lib/built/skill.d.ts
CHANGED
package/lib/built/skill.js
CHANGED
|
@@ -5,9 +5,10 @@ export interface LoadSpeechPipelineOptions {
|
|
|
5
5
|
getConfig?: () => Record<string, unknown> | undefined;
|
|
6
6
|
warn?: (message: string) => void;
|
|
7
7
|
}
|
|
8
|
+
/** zhin 启动时已创建 pipeline 时注入 */
|
|
9
|
+
export declare function seedSpeechPipeline(pipeline: SpeechPipelineForRichSegment): void;
|
|
8
10
|
/** 动态加载 @zhin.js/speech;未安装时 warn 一次并返回 undefined */
|
|
9
11
|
export declare function loadSpeechPipeline(opts?: LoadSpeechPipelineOptions): Promise<SpeechPipelineForRichSegment | undefined>;
|
|
10
12
|
/** 测试用:重置加载缓存 */
|
|
11
13
|
export declare function resetSpeechLoaderForTests(): void;
|
|
12
14
|
export type { SpeechPipelineForRichSegment };
|
|
13
|
-
//# sourceMappingURL=speech-loader.d.ts.map
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { createWarnOnce, resetWarnOnceForTests } from '@zhin.js/logger';
|
|
2
|
+
import { importOptionalPeerPackage } from './optional-peer-import.js';
|
|
2
3
|
/** 动态 import 时使用的包名(与 @zhin.js/speech package.json 一致) */
|
|
3
4
|
export const SPEECH_PACKAGE = '@zhin.js/speech';
|
|
4
5
|
let cached;
|
|
5
6
|
const speechPeerWarnOnce = createWarnOnce('speech');
|
|
7
|
+
/** zhin 启动时已创建 pipeline 时注入 */
|
|
8
|
+
export function seedSpeechPipeline(pipeline) {
|
|
9
|
+
cached = pipeline;
|
|
10
|
+
}
|
|
6
11
|
/** 动态加载 @zhin.js/speech;未安装时 warn 一次并返回 undefined */
|
|
7
12
|
export async function loadSpeechPipeline(opts) {
|
|
8
13
|
if (cached !== undefined) {
|
|
9
14
|
return cached ?? undefined;
|
|
10
15
|
}
|
|
11
16
|
try {
|
|
12
|
-
const mod = await
|
|
17
|
+
const mod = await importOptionalPeerPackage(SPEECH_PACKAGE);
|
|
13
18
|
const speechConfig = opts?.getConfig?.()?.speech;
|
|
14
19
|
cached = mod.createSpeechPipeline(speechConfig);
|
|
15
20
|
return cached;
|
|
@@ -25,4 +30,3 @@ export function resetSpeechLoaderForTests() {
|
|
|
25
30
|
cached = undefined;
|
|
26
31
|
resetWarnOnceForTests('speech');
|
|
27
32
|
}
|
|
28
|
-
//# sourceMappingURL=speech-loader.js.map
|
package/lib/built/tool.d.ts
CHANGED
package/lib/built/tool.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* 工具仅面向 AI(通过 MCP 注册),不再与 Command 互转
|
|
4
4
|
*/
|
|
5
5
|
import { Feature } from "@zhin.js/kernel";
|
|
6
|
-
import { getPlugin } from "../plugin.js";
|
|
7
6
|
import { isBuiltinPermit, isPlatformPermit } from './permit-parse.js';
|
|
8
7
|
import { checkBuiltinPermit } from './permit-check.js';
|
|
9
8
|
import { checkPlatformPermit } from './platform-permit.js';
|
|
@@ -386,7 +385,7 @@ export class ToolFeature extends Feature {
|
|
|
386
385
|
const feature = this;
|
|
387
386
|
return {
|
|
388
387
|
addTool(tool) {
|
|
389
|
-
const plugin =
|
|
388
|
+
const plugin = this;
|
|
390
389
|
const toolObj = isZhinTool(tool) ? tool.toTool() : tool;
|
|
391
390
|
const dispose = feature.addTool(tool, plugin.name);
|
|
392
391
|
plugin.recordFeatureContribution(feature.name, toolObj.name);
|
|
@@ -396,4 +395,3 @@ export class ToolFeature extends Feature {
|
|
|
396
395
|
};
|
|
397
396
|
}
|
|
398
397
|
}
|
|
399
|
-
//# sourceMappingURL=tool.js.map
|
package/lib/command.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { MatchResult, SegmentMatcher } from
|
|
2
|
-
import { AdapterMessage, SendContent } from
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { MatchResult, SegmentMatcher } from 'segment-matcher';
|
|
2
|
+
import { AdapterMessage, SendContent, RegisteredAdapter, MaybePromise } from './types.js';
|
|
3
|
+
import type { Message } from './message.js';
|
|
4
|
+
import { Plugin } from './plugin.js';
|
|
5
|
+
type ConstructFirstParam<T extends new (...args: any[]) => any> = T extends new (...args: [infer U, ...any[]]) => any ? U : never;
|
|
6
|
+
type ConstructSecondParam<T extends new (...args: any[]) => any> = T extends new (...args: [any, infer V, ...any[]]) => any ? V : never;
|
|
7
7
|
/**
|
|
8
8
|
* MessageCommand类:命令系统核心,基于segment-matcher实现。
|
|
9
9
|
* 支持多平台命令注册、作用域限制、参数解析、异步处理等。
|
|
@@ -11,6 +11,7 @@ import { Plugin } from "./plugin.js";
|
|
|
11
11
|
export declare class MessageCommand<T extends RegisteredAdapter = RegisteredAdapter> extends SegmentMatcher {
|
|
12
12
|
#private;
|
|
13
13
|
get helpInfo(): MessageCommand.HelpInfo;
|
|
14
|
+
constructor(C: ConstructFirstParam<typeof SegmentMatcher>, P?: ConstructSecondParam<typeof SegmentMatcher>);
|
|
14
15
|
get help(): string;
|
|
15
16
|
desc(...desc: string[]): MessageCommand<T>;
|
|
16
17
|
usage(...usage: string[]): MessageCommand<T>;
|
|
@@ -21,6 +22,10 @@ export declare class MessageCommand<T extends RegisteredAdapter = RegisteredAdap
|
|
|
21
22
|
*/
|
|
22
23
|
action(callback: MessageCommand.Callback<T>): MessageCommand<T>;
|
|
23
24
|
permit(...permissions: string[]): MessageCommand<T>;
|
|
25
|
+
/** 命令要求的 permit 列表(空表示所有人可用) */
|
|
26
|
+
get requiredPermits(): readonly string[];
|
|
27
|
+
/** 与 handle 一致的 permit 校验,供帮助菜单等场景过滤不可见命令 */
|
|
28
|
+
checkPermits(message: Message<AdapterMessage<T>>, plugin: Plugin): Promise<boolean>;
|
|
24
29
|
/**
|
|
25
30
|
* 处理消息,自动匹配命令并执行回调
|
|
26
31
|
* @param message 消息对象
|
|
@@ -39,4 +44,4 @@ export declare namespace MessageCommand {
|
|
|
39
44
|
examples: string[];
|
|
40
45
|
};
|
|
41
46
|
}
|
|
42
|
-
|
|
47
|
+
export {};
|
package/lib/command.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { SegmentMatcher } from
|
|
2
|
-
import logger, { formatCompact } from "@zhin.js/logger";
|
|
1
|
+
import { SegmentMatcher } from 'segment-matcher';
|
|
3
2
|
/**
|
|
4
3
|
* MessageCommand类:命令系统核心,基于segment-matcher实现。
|
|
5
4
|
* 支持多平台命令注册、作用域限制、参数解析、异步处理等。
|
|
@@ -18,6 +17,24 @@ export class MessageCommand extends SegmentMatcher {
|
|
|
18
17
|
examples: this.#examples
|
|
19
18
|
};
|
|
20
19
|
}
|
|
20
|
+
constructor(C, P = {}) {
|
|
21
|
+
super(C, {
|
|
22
|
+
at: ['qq', 'user_id'],
|
|
23
|
+
face: ['id'],
|
|
24
|
+
mention: ['qq', 'user_id'],
|
|
25
|
+
html: ['content'],
|
|
26
|
+
markdown: ['content'],
|
|
27
|
+
image: ['file', 'src', 'url'],
|
|
28
|
+
video: ['file', 'src', 'url'],
|
|
29
|
+
audio: ['file', 'src', 'url'],
|
|
30
|
+
file: ['file', 'src', 'url'],
|
|
31
|
+
reply: ['id', 'reply_id', 'message_id'],
|
|
32
|
+
quote: ['id', 'reply_id', 'message_id'],
|
|
33
|
+
forward: ['id', 'res_id', 'message_id'],
|
|
34
|
+
location: ['latitude', 'longitude'],
|
|
35
|
+
...P,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
21
38
|
get help() {
|
|
22
39
|
return [
|
|
23
40
|
this.pattern,
|
|
@@ -50,6 +67,23 @@ export class MessageCommand extends SegmentMatcher {
|
|
|
50
67
|
this.#permissions.push(...permissions);
|
|
51
68
|
return this;
|
|
52
69
|
}
|
|
70
|
+
/** 命令要求的 permit 列表(空表示所有人可用) */
|
|
71
|
+
get requiredPermits() {
|
|
72
|
+
return this.#permissions;
|
|
73
|
+
}
|
|
74
|
+
/** 与 handle 一致的 permit 校验,供帮助菜单等场景过滤不可见命令 */
|
|
75
|
+
async checkPermits(message, plugin) {
|
|
76
|
+
if (!this.#permissions.length)
|
|
77
|
+
return true;
|
|
78
|
+
const auth = plugin.contextIsReady('permission') ? plugin.inject('permission') : null;
|
|
79
|
+
if (!auth)
|
|
80
|
+
return false;
|
|
81
|
+
for (const permit of this.#permissions) {
|
|
82
|
+
if (!(await auth.check(permit, message)))
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
53
87
|
/**
|
|
54
88
|
* 处理消息,自动匹配命令并执行回调
|
|
55
89
|
* @param message 消息对象
|
|
@@ -57,19 +91,8 @@ export class MessageCommand extends SegmentMatcher {
|
|
|
57
91
|
* @returns 命令返回内容或undefined
|
|
58
92
|
*/
|
|
59
93
|
async handle(message, plugin) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const passed = auth ? await auth.check(permit, message) : false;
|
|
63
|
-
if (!passed) {
|
|
64
|
-
logger.debug(formatCompact({
|
|
65
|
-
op: 'permit_denied',
|
|
66
|
-
permit,
|
|
67
|
-
senderId: message.$sender.id,
|
|
68
|
-
adapter: message.$adapter,
|
|
69
|
-
endpoint: message.$endpoint,
|
|
70
|
-
}));
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
94
|
+
if (!(await this.checkPermits(message, plugin))) {
|
|
95
|
+
return;
|
|
73
96
|
}
|
|
74
97
|
const matched = this.match(message.$content);
|
|
75
98
|
if (!matched)
|
|
@@ -81,4 +104,3 @@ export class MessageCommand extends SegmentMatcher {
|
|
|
81
104
|
}
|
|
82
105
|
}
|
|
83
106
|
}
|
|
84
|
-
//# sourceMappingURL=command.js.map
|
package/lib/component.d.ts
CHANGED
package/lib/component.js
CHANGED
|
@@ -564,4 +564,3 @@ export const Fragment = defineComponent(async (props, context) => {
|
|
|
564
564
|
export const Fetch = defineComponent(async ({ url }) => {
|
|
565
565
|
return await fetch(url, { signal: AbortSignal.timeout(30_000) }).then((r) => r.text());
|
|
566
566
|
}, 'fetch');
|
|
567
|
-
//# sourceMappingURL=component.js.map
|
|
@@ -2,6 +2,7 @@ import type { Message } from './message.js';
|
|
|
2
2
|
import type { Notice } from './notice.js';
|
|
3
3
|
import type { Request } from './request.js';
|
|
4
4
|
import type { SendOptions } from './types.js';
|
|
5
|
+
import type { AIAccessScopeConfig } from './built/ai-access.js';
|
|
5
6
|
export type EndpointCapability = 'inbound' | 'outbound';
|
|
6
7
|
export declare const DEFAULT_ENDPOINT_CAPABILITIES: readonly EndpointCapability[];
|
|
7
8
|
/** 入站能力:含连接生命周期 */
|
|
@@ -41,5 +42,6 @@ export declare function assertInbound(endpoint: InboundEndpoint | OutboundEndpoi
|
|
|
41
42
|
export declare function assertOutbound(endpoint: InboundEndpoint | OutboundEndpoint): asserts endpoint is OutboundEndpoint;
|
|
42
43
|
export interface EndpointCapabilitiesConfig {
|
|
43
44
|
capabilities?: EndpointCapability[];
|
|
45
|
+
/** 本 Endpoint 的 AI 访问控制(覆盖 ai.access 全局默认) */
|
|
46
|
+
aiAccess?: AIAccessScopeConfig;
|
|
44
47
|
}
|
|
45
|
-
//# sourceMappingURL=endpoint-capabilities.d.ts.map
|
package/lib/endpoint.d.ts
CHANGED
package/lib/endpoint.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
1
|
export { DEFAULT_ENDPOINT_CAPABILITIES, OutboundNotSupportedError, InboundNotSupportedError, resolveEndpointCapabilities, registerEndpointCapabilities, getEndpointCapabilities, getAdapterCapabilities, hasInbound, hasOutbound, assertInbound, assertOutbound, } from './endpoint-capabilities.js';
|
|
2
|
-
//# sourceMappingURL=endpoint.js.map
|
package/lib/errors.d.ts
CHANGED
package/lib/errors.js
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Message, MessageType } from './message.js';
|
|
2
|
+
import type { SendContent, SendOptions } from './types.js';
|
|
3
|
+
export type IMSceneKind = MessageType;
|
|
4
|
+
/** Parent scene kind (distinct from sub-channel MessageType.channel). */
|
|
5
|
+
export type IMSceneParentKind = 'group' | 'guild';
|
|
6
|
+
export interface IMSceneParentRef {
|
|
7
|
+
kind: IMSceneParentKind;
|
|
8
|
+
sceneId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IMSceneRef {
|
|
11
|
+
platform: string;
|
|
12
|
+
endpointId: string;
|
|
13
|
+
sceneId: string;
|
|
14
|
+
kind: IMSceneKind;
|
|
15
|
+
senderId?: string;
|
|
16
|
+
parent?: IMSceneParentRef;
|
|
17
|
+
}
|
|
18
|
+
export interface IMDeliveryTarget {
|
|
19
|
+
channel: 'im';
|
|
20
|
+
scene: IMSceneRef;
|
|
21
|
+
threadId?: string;
|
|
22
|
+
quoteId?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Normalize legacy parent.type channel → guild. */
|
|
25
|
+
export declare function normalizeIMSceneParentKind(value: unknown): IMSceneParentKind | undefined;
|
|
26
|
+
export declare function sceneRefFromMessage(message: Partial<Message<any>>): IMSceneRef | undefined;
|
|
27
|
+
export declare function sceneRefToSendOptions(target: IMDeliveryTarget, content: SendContent): SendOptions;
|
|
28
|
+
export declare function resolveIMSceneSessionId(scene: IMSceneRef): string;
|
|
29
|
+
export declare function messageToIMDeliveryTarget(message: Partial<Message<any>>): IMDeliveryTarget | undefined;
|
package/lib/im-scene.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { resolveIMSceneSessionId as resolveIMSceneSessionIdKernel, } from '@zhin.js/kernel';
|
|
2
|
+
function nonEmptyString(value) {
|
|
3
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
4
|
+
}
|
|
5
|
+
/** Normalize legacy parent.type channel → guild. */
|
|
6
|
+
export function normalizeIMSceneParentKind(value) {
|
|
7
|
+
if (value === 'group' || value === 'guild')
|
|
8
|
+
return value;
|
|
9
|
+
if (value === 'channel')
|
|
10
|
+
return 'guild';
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
export function sceneRefFromMessage(message) {
|
|
14
|
+
const platform = nonEmptyString(message.$adapter);
|
|
15
|
+
const endpointId = nonEmptyString(message.$endpoint);
|
|
16
|
+
const kind = message.$channel?.type;
|
|
17
|
+
if (!platform || !endpointId || !kind)
|
|
18
|
+
return undefined;
|
|
19
|
+
const senderId = nonEmptyString(message.$sender?.id);
|
|
20
|
+
const channelId = nonEmptyString(message.$channel?.id);
|
|
21
|
+
const sceneId = kind === 'private'
|
|
22
|
+
? senderId ?? channelId
|
|
23
|
+
: channelId ?? senderId;
|
|
24
|
+
if (!sceneId)
|
|
25
|
+
return undefined;
|
|
26
|
+
const parentKind = message.$channel?.parent
|
|
27
|
+
? normalizeIMSceneParentKind(message.$channel.parent.type)
|
|
28
|
+
: undefined;
|
|
29
|
+
const parent = parentKind && message.$channel?.parent
|
|
30
|
+
? {
|
|
31
|
+
kind: parentKind,
|
|
32
|
+
sceneId: String(message.$channel.parent.id),
|
|
33
|
+
}
|
|
34
|
+
: undefined;
|
|
35
|
+
return {
|
|
36
|
+
platform,
|
|
37
|
+
endpointId,
|
|
38
|
+
sceneId,
|
|
39
|
+
kind,
|
|
40
|
+
...(senderId ? { senderId } : {}),
|
|
41
|
+
...(parent ? { parent } : {}),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function sceneRefToSendOptions(target, content) {
|
|
45
|
+
const { scene } = target;
|
|
46
|
+
return {
|
|
47
|
+
context: scene.platform,
|
|
48
|
+
endpoint: scene.endpointId,
|
|
49
|
+
id: scene.sceneId,
|
|
50
|
+
type: scene.kind,
|
|
51
|
+
parent: scene.parent
|
|
52
|
+
? { type: scene.parent.kind, id: scene.parent.sceneId }
|
|
53
|
+
: undefined,
|
|
54
|
+
content,
|
|
55
|
+
...(target.quoteId ? { quoteId: target.quoteId } : {}),
|
|
56
|
+
...(target.threadId ? { threadId: target.threadId } : {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export function resolveIMSceneSessionId(scene) {
|
|
60
|
+
return resolveIMSceneSessionIdKernel({
|
|
61
|
+
platform: scene.platform,
|
|
62
|
+
endpointId: scene.endpointId,
|
|
63
|
+
sceneId: scene.sceneId,
|
|
64
|
+
kind: scene.kind,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export function messageToIMDeliveryTarget(message) {
|
|
68
|
+
const scene = sceneRefFromMessage(message);
|
|
69
|
+
if (!scene)
|
|
70
|
+
return undefined;
|
|
71
|
+
const quoteId = nonEmptyString(message.$quote_id);
|
|
72
|
+
return {
|
|
73
|
+
channel: 'im',
|
|
74
|
+
scene,
|
|
75
|
+
...(quoteId ? { quoteId } : {}),
|
|
76
|
+
};
|
|
77
|
+
}
|