@zhin.js/core 1.1.34 → 1.1.35
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 +121 -65
- package/lib/adapter.d.ts +72 -23
- package/lib/adapter.js +222 -62
- package/lib/built/adapter-process.d.ts +20 -5
- package/lib/built/adapter-process.js +54 -7
- package/lib/built/agent-preset.d.ts +1 -2
- package/lib/built/agent-preset.js +1 -2
- 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 +104 -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 +6 -0
- package/lib/built/ai-outbound/types.d.ts +58 -0
- package/lib/built/ai-outbound/types.js +5 -0
- package/lib/built/ai-trigger.d.ts +17 -17
- package/lib/built/ai-trigger.js +65 -70
- package/lib/built/authorization.d.ts +10 -0
- package/lib/built/authorization.js +76 -0
- package/lib/built/command.d.ts +9 -5
- package/lib/built/command.js +20 -7
- package/lib/built/common-adapter-tools.d.ts +35 -29
- package/lib/built/common-adapter-tools.js +83 -67
- package/lib/built/component.d.ts +1 -3
- package/lib/built/component.js +2 -4
- package/lib/built/config.d.ts +4 -5
- package/lib/built/config.js +26 -9
- package/lib/built/connect-endpoint-instance.d.ts +17 -0
- package/lib/built/connect-endpoint-instance.js +42 -0
- package/lib/built/database.d.ts +5 -3
- package/lib/built/database.js +10 -4
- package/lib/built/dispatcher.d.ts +10 -8
- package/lib/built/dispatcher.js +31 -9
- package/lib/built/endpoint-commands.d.ts +3 -0
- package/lib/built/endpoint-commands.js +99 -0
- package/lib/built/endpoint-lifecycle-service.d.ts +28 -0
- package/lib/built/endpoint-lifecycle-service.js +242 -0
- package/lib/built/endpoint-lifecycle.d.ts +27 -0
- package/lib/built/endpoint-lifecycle.js +36 -0
- package/lib/built/endpoint-manager.d.ts +34 -0
- package/lib/built/endpoint-manager.js +1 -0
- package/lib/built/generated-qrcode.d.ts +24 -0
- package/lib/built/generated-qrcode.js +45 -0
- package/lib/built/generic-segment-mapper.d.ts +4 -0
- package/lib/built/generic-segment-mapper.js +190 -0
- package/lib/built/html-renderer-loader.d.ts +13 -0
- package/lib/built/html-renderer-loader.js +33 -0
- package/lib/built/html-segment-fallback.d.ts +2 -2
- 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 +37 -0
- package/lib/built/inbound-pipeline.js +63 -0
- package/lib/built/inbound-runner.d.ts +0 -1
- package/lib/built/inbound-runner.js +0 -3
- 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/fallback-store.d.ts +29 -0
- package/lib/built/interactive-segments/fallback-store.js +63 -0
- package/lib/built/interactive-segments/handlers.d.ts +16 -0
- package/lib/built/interactive-segments/handlers.js +74 -0
- package/lib/built/interactive-segments/index.d.ts +8 -0
- package/lib/built/interactive-segments/index.js +8 -0
- package/lib/built/interactive-segments/keyboard-segment.d.ts +11 -0
- package/lib/built/interactive-segments/keyboard-segment.js +12 -0
- package/lib/built/interactive-segments/onebot-keyboard.d.ts +7 -0
- package/lib/built/interactive-segments/onebot-keyboard.js +51 -0
- package/lib/built/interactive-segments/resolve.d.ts +15 -0
- package/lib/built/interactive-segments/resolve.js +110 -0
- package/lib/built/interactive-segments/types.d.ts +50 -0
- package/lib/built/interactive-segments/types.js +9 -0
- package/lib/built/introspection-format.d.ts +10 -0
- package/lib/built/introspection-format.js +28 -0
- package/lib/built/login-assist.d.ts +43 -9
- package/lib/built/login-assist.js +113 -11
- package/lib/built/management-command-guard.d.ts +15 -0
- package/lib/built/management-command-guard.js +25 -0
- package/lib/built/message-enrich.d.ts +38 -0
- package/lib/built/message-enrich.js +75 -0
- package/lib/built/message-filter.d.ts +4 -5
- package/lib/built/message-filter.js +5 -7
- 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 +22 -0
- package/lib/built/outbound-media-contract.js +10 -0
- package/lib/built/outbound-media-utils.d.ts +9 -0
- package/lib/built/outbound-media-utils.js +62 -0
- package/lib/built/permission.d.ts +3 -7
- package/lib/built/permission.js +39 -52
- package/lib/built/permit-check.d.ts +7 -0
- package/lib/built/permit-check.js +35 -0
- package/lib/built/permit-parse.d.ts +16 -0
- package/lib/built/permit-parse.js +32 -0
- package/lib/built/platform-permit.d.ts +20 -0
- package/lib/built/platform-permit.js +91 -0
- package/lib/built/queue-im-field-contract.d.ts +7 -2
- package/lib/built/queue-im-field-contract.js +13 -4
- package/lib/built/rich-segments/adapter-policies.d.ts +9 -0
- package/lib/built/rich-segments/adapter-policies.js +27 -0
- package/lib/built/rich-segments/base.d.ts +11 -0
- package/lib/built/rich-segments/base.js +24 -0
- package/lib/built/rich-segments/builtins.d.ts +4 -0
- package/lib/built/rich-segments/builtins.js +40 -0
- package/lib/built/rich-segments/capabilities.d.ts +6 -0
- package/lib/built/rich-segments/capabilities.js +38 -0
- package/lib/built/rich-segments/html-segment.d.ts +15 -0
- package/lib/built/rich-segments/html-segment.js +62 -0
- package/lib/built/rich-segments/index.d.ts +13 -0
- package/lib/built/rich-segments/index.js +13 -0
- package/lib/built/rich-segments/markdown-segment.d.ts +14 -0
- package/lib/built/rich-segments/markdown-segment.js +58 -0
- package/lib/built/rich-segments/markdown-to-text.d.ts +3 -0
- package/lib/built/rich-segments/markdown-to-text.js +27 -0
- package/lib/built/rich-segments/qrcode-segment.d.ts +18 -0
- package/lib/built/rich-segments/qrcode-segment.js +73 -0
- package/lib/built/rich-segments/registry.d.ts +16 -0
- package/lib/built/rich-segments/registry.js +52 -0
- package/lib/built/rich-segments/resolve.d.ts +5 -0
- package/lib/built/rich-segments/resolve.js +87 -0
- package/lib/built/rich-segments/tts-segment.d.ts +13 -0
- package/lib/built/rich-segments/tts-segment.js +51 -0
- package/lib/built/rich-segments/types.d.ts +79 -0
- package/lib/built/rich-segments/types.js +17 -0
- package/lib/built/roles.d.ts +4 -5
- package/lib/built/roles.js +4 -5
- 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 +17 -0
- package/lib/built/schema-endpoint-manager.js +73 -0
- 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 +7 -0
- package/lib/built/segment-contract/assert.js +39 -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 +10 -0
- package/lib/built/segment-contract/index.js +9 -0
- package/lib/built/segment-contract/json-schema.d.ts +28 -0
- package/lib/built/segment-contract/json-schema.js +128 -0
- package/lib/built/segment-contract/media.d.ts +12 -0
- package/lib/built/segment-contract/media.js +22 -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/text.d.ts +7 -0
- package/lib/built/segment-contract/text.js +34 -0
- package/lib/built/segment-contract/types.d.ts +58 -0
- package/lib/built/segment-contract/types.js +1 -0
- package/lib/built/segment-contract/validate.d.ts +229 -0
- package/lib/built/segment-contract/validate.js +174 -0
- package/lib/built/skill.d.ts +0 -1
- package/lib/built/skill.js +0 -1
- package/lib/built/speech-loader.d.ts +14 -0
- package/lib/built/speech-loader.js +32 -0
- package/lib/built/tool.d.ts +14 -13
- package/lib/built/tool.js +30 -25
- package/lib/built/user-interaction.d.ts +30 -0
- package/lib/built/user-interaction.js +248 -0
- package/lib/command.d.ts +19 -11
- package/lib/command.js +42 -11
- package/lib/component.d.ts +0 -1
- package/lib/component.js +30 -14
- package/lib/endpoint-capabilities.d.ts +46 -0
- package/lib/endpoint-capabilities.js +55 -0
- package/lib/endpoint.d.ts +19 -0
- package/lib/endpoint.js +3 -0
- package/lib/errors.d.ts +2 -3
- package/lib/errors.js +4 -5
- package/lib/feature/adapter.d.ts +2 -0
- package/lib/feature/adapter.js +2 -0
- package/lib/feature/command.d.ts +2 -0
- package/lib/feature/command.js +2 -0
- package/lib/feature/component.d.ts +2 -0
- package/lib/feature/component.js +2 -0
- package/lib/feature/handler.d.ts +52 -0
- package/lib/feature/handler.js +26 -0
- package/lib/feature/middleware.d.ts +2 -0
- package/lib/feature/middleware.js +2 -0
- package/lib/host-plugin-registry.d.ts +8 -0
- package/lib/host-plugin-registry.js +12 -0
- package/lib/im-scene.d.ts +29 -0
- package/lib/im-scene.js +75 -0
- package/lib/im-session-id.d.ts +39 -0
- package/lib/im-session-id.js +47 -0
- package/lib/index.d.ts +59 -25
- package/lib/index.js +53 -31
- package/lib/jsx-dev-runtime.d.ts +0 -1
- package/lib/jsx-dev-runtime.js +0 -1
- package/lib/jsx-runtime.d.ts +1 -1
- package/lib/jsx-runtime.js +0 -1
- package/lib/jsx.d.ts +19 -22
- package/lib/jsx.js +0 -1
- package/lib/message.d.ts +16 -10
- package/lib/message.js +16 -13
- 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 +16 -59
- package/lib/notice.js +1 -4
- package/lib/plugin-context.d.ts +27 -0
- package/lib/plugin-context.js +64 -0
- package/lib/plugin-runtime/im/contracts.d.ts +191 -0
- package/lib/plugin-runtime/im/contracts.js +169 -0
- package/lib/plugin-runtime/im/im-runtime.d.ts +177 -0
- package/lib/plugin-runtime/im/im-runtime.js +1204 -0
- package/lib/plugin-runtime/im/index.d.ts +9 -0
- package/lib/plugin-runtime/im/index.js +9 -0
- package/lib/plugin-runtime/im/interactive.d.ts +26 -0
- package/lib/plugin-runtime/im/interactive.js +46 -0
- package/lib/plugin-runtime/im/login-assist-host.d.ts +6 -0
- package/lib/plugin-runtime/im/login-assist-host.js +6 -0
- package/lib/plugin-runtime/im/message-bus.d.ts +38 -0
- package/lib/plugin-runtime/im/message-bus.js +40 -0
- package/lib/plugin-runtime/im/message-dispatcher.d.ts +18 -0
- package/lib/plugin-runtime/im/message-dispatcher.js +107 -0
- package/lib/plugin-runtime/im/outbound-renderer.d.ts +7 -0
- package/lib/plugin-runtime/im/outbound-renderer.js +70 -0
- package/lib/plugin-runtime/im/outbound-segments.d.ts +72 -0
- package/lib/plugin-runtime/im/outbound-segments.js +220 -0
- package/lib/plugin-runtime/im/public-api.d.ts +6 -0
- package/lib/plugin-runtime/im/public-api.js +6 -0
- package/lib/plugin-runtime/im/service-tokens.d.ts +18 -0
- package/lib/plugin-runtime/im/service-tokens.js +13 -0
- package/lib/plugin.d.ts +34 -24
- package/lib/plugin.js +119 -224
- package/lib/request.d.ts +17 -61
- package/lib/request.js +0 -4
- package/lib/{prompt.d.ts → schema-interaction.d.ts} +6 -7
- package/lib/{prompt.js → schema-interaction.js} +20 -17
- package/lib/side-event/base.d.ts +52 -0
- package/lib/side-event/base.js +30 -0
- package/lib/side-event/dispatch.d.ts +15 -0
- package/lib/side-event/dispatch.js +140 -0
- package/lib/side-event/index.d.ts +4 -0
- package/lib/side-event/index.js +4 -0
- package/lib/side-event/normalize.d.ts +42 -0
- package/lib/side-event/normalize.js +121 -0
- package/lib/side-event/types.d.ts +23 -0
- package/lib/side-event/types.js +55 -0
- package/lib/system-event.d.ts +15 -0
- package/lib/system-event.js +7 -0
- package/lib/tool-zod.d.ts +18 -3
- package/lib/tool-zod.js +140 -54
- package/lib/types.d.ts +44 -95
- package/lib/types.js +0 -1
- package/lib/utils.d.ts +61 -13
- package/lib/utils.js +66 -25
- package/package.json +98 -10
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js.map +0 -1
- package/lib/agent-prompt.d.ts +0 -37
- package/lib/agent-prompt.d.ts.map +0 -1
- package/lib/agent-prompt.js +0 -2
- package/lib/agent-prompt.js.map +0 -1
- package/lib/bot.d.ts +0 -38
- package/lib/bot.d.ts.map +0 -1
- package/lib/bot.js +0 -2
- package/lib/bot.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/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/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/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-runner.d.ts.map +0 -1
- package/lib/built/inbound-runner.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/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-filter.d.ts.map +0 -1
- package/lib/built/message-filter.js.map +0 -1
- package/lib/built/permission.d.ts.map +0 -1
- package/lib/built/permission.js.map +0 -1
- package/lib/built/prepend-quote-context.d.ts +0 -35
- package/lib/built/prepend-quote-context.d.ts.map +0 -1
- package/lib/built/prepend-quote-context.js +0 -131
- package/lib/built/prepend-quote-context.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/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-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/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/errors.d.ts.map +0 -1
- package/lib/errors.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 +0 -11
- package/lib/message-quote.d.ts.map +0 -1
- package/lib/message-quote.js +0 -91
- 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.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 +0 -6
- package/lib/types-generator.d.ts.map +0 -1
- package/lib/types-generator.js +0 -72
- 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,9 @@
|
|
|
1
|
+
export * from './contracts.js';
|
|
2
|
+
export * from './im-runtime.js';
|
|
3
|
+
export * from './interactive.js';
|
|
4
|
+
export * from './login-assist-host.js';
|
|
5
|
+
export * from './message-bus.js';
|
|
6
|
+
export * from './message-dispatcher.js';
|
|
7
|
+
export * from './outbound-renderer.js';
|
|
8
|
+
export * from './outbound-segments.js';
|
|
9
|
+
export * from './service-tokens.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './contracts.js';
|
|
2
|
+
export * from './im-runtime.js';
|
|
3
|
+
export * from './interactive.js';
|
|
4
|
+
export * from './login-assist-host.js';
|
|
5
|
+
export * from './message-bus.js';
|
|
6
|
+
export * from './message-dispatcher.js';
|
|
7
|
+
export * from './outbound-renderer.js';
|
|
8
|
+
export * from './outbound-segments.js';
|
|
9
|
+
export * from './service-tokens.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ConversationRef } from '@zhin.js/im-contract';
|
|
2
|
+
import type { Message } from './contracts.js';
|
|
3
|
+
/**
|
|
4
|
+
* Plugin Runtime IM 管线的 interactive action 回跳(旧轨
|
|
5
|
+
* `built/interactive-segments/handlers.ts` 的等价物):
|
|
6
|
+
* - 平台 callback 以 canonical action 段入站(telegram / discord,Wave 1 C 约定
|
|
7
|
+
* `{type:'action', data:{id, payload, sourceMessageId?}}`);
|
|
8
|
+
* - 'text' 端点的数字回跳:出站降级写入中央 fallback 存储的映射在此解析回 payload;
|
|
9
|
+
* - QQ 指令预填等直出 `prefix:session:id` 文本同样识别。
|
|
10
|
+
* payload 按 prefix 最长匹配路由给 `ImRuntime.registerInteractiveHandler`
|
|
11
|
+
* 注册的 handler。
|
|
12
|
+
*/
|
|
13
|
+
export type RuntimeInteractiveHandler = (message: Message) => Promise<boolean> | boolean;
|
|
14
|
+
export interface RegisteredRuntimeInteractiveHandler {
|
|
15
|
+
readonly prefix: string;
|
|
16
|
+
readonly handler: RuntimeInteractiveHandler;
|
|
17
|
+
}
|
|
18
|
+
/** 频道键:出站降级写入与入站回跳读取共用(由 ConversationRef 派生,稳定即可)。 */
|
|
19
|
+
export declare function runtimeInteractiveConversationKey(conversation: ConversationRef): string;
|
|
20
|
+
/** prefix 最长匹配(与旧轨 findHandler 一致)。 */
|
|
21
|
+
export declare function findRuntimeInteractiveHandler(handlers: readonly RegisteredRuntimeInteractiveHandler[], payload: string): RuntimeInteractiveHandler | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* 从入站消息解析 interactive payload:
|
|
24
|
+
* action 段 → 中央 fallback map(裸数字)→ 指令预填直出 payload。
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveRuntimeInteractivePayload(message: Message): string | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { resolvePayloadFromText } from '../../built/interactive-segments/action.js';
|
|
2
|
+
import { keyboardFallbackStore } from '../../built/interactive-segments/fallback-store.js';
|
|
3
|
+
/** 频道键:出站降级写入与入站回跳读取共用(由 ConversationRef 派生,稳定即可)。 */
|
|
4
|
+
export function runtimeInteractiveConversationKey(conversation) {
|
|
5
|
+
const base = `${String(conversation.endpoint.id)}~${conversation.kind}:${conversation.id}`;
|
|
6
|
+
const parent = conversation.parent
|
|
7
|
+
? `@${conversation.parent.kind}:${conversation.parent.id}`
|
|
8
|
+
: '';
|
|
9
|
+
const thread = conversation.threadId ? `#${conversation.threadId}` : '';
|
|
10
|
+
return `${base}${parent}${thread}`;
|
|
11
|
+
}
|
|
12
|
+
/** prefix 最长匹配(与旧轨 findHandler 一致)。 */
|
|
13
|
+
export function findRuntimeInteractiveHandler(handlers, payload) {
|
|
14
|
+
let match;
|
|
15
|
+
for (const entry of handlers) {
|
|
16
|
+
if (payload.startsWith(entry.prefix)) {
|
|
17
|
+
if (!match || entry.prefix.length > match.prefix.length) {
|
|
18
|
+
match = entry;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return match?.handler;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 从入站消息解析 interactive payload:
|
|
26
|
+
* action 段 → 中央 fallback map(裸数字)→ 指令预填直出 payload。
|
|
27
|
+
*/
|
|
28
|
+
export function resolveRuntimeInteractivePayload(message) {
|
|
29
|
+
const fromSegments = actionPayloadFromSegments(message.segments);
|
|
30
|
+
if (fromSegments)
|
|
31
|
+
return fromSegments;
|
|
32
|
+
const raw = message.content.trim();
|
|
33
|
+
if (!raw)
|
|
34
|
+
return undefined;
|
|
35
|
+
return resolvePayloadFromText(raw, keyboardFallbackStore.mapFor(runtimeInteractiveConversationKey(message.conversation)));
|
|
36
|
+
}
|
|
37
|
+
function actionPayloadFromSegments(segments) {
|
|
38
|
+
for (const seg of segments ?? []) {
|
|
39
|
+
if (seg.type !== 'action')
|
|
40
|
+
continue;
|
|
41
|
+
const payload = seg.data?.payload;
|
|
42
|
+
if (typeof payload === 'string' && payload)
|
|
43
|
+
return payload;
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LoginAssist } from '../../built/login-assist.js';
|
|
2
|
+
/**
|
|
3
|
+
* Plugin Runtime login-assist port(与出站消息服务并列)。
|
|
4
|
+
* 适配器 waitForInput;Console / stdin 经 listPending + submit 消费。
|
|
5
|
+
*/
|
|
6
|
+
export declare const loginAssistToken: import("@zhin.js/plugin-runtime").Token<LoginAssist>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MessageBus — 独立于 Plugin 的 IM 生命周期事件总线。
|
|
3
|
+
*
|
|
4
|
+
* 覆盖 Plugin.Lifecycle 中关键 IM 事件,供 Scope+Token 路径消费。
|
|
5
|
+
* 遗留 Plugin.emit 通过短暂双写桥接(迁移窗口)。
|
|
6
|
+
*/
|
|
7
|
+
import type { DeliveryReceipt } from '@zhin.js/im-contract';
|
|
8
|
+
import type { Message, OutboundEnvelope, SendContent } from './contracts.js';
|
|
9
|
+
export interface EndpointEvent {
|
|
10
|
+
readonly adapter: string;
|
|
11
|
+
readonly endpointKey: string;
|
|
12
|
+
readonly error?: Error;
|
|
13
|
+
}
|
|
14
|
+
export interface MessageBusEventMap {
|
|
15
|
+
'message.receive': [message: Message];
|
|
16
|
+
'before.sendMessage': [envelope: OutboundEnvelope];
|
|
17
|
+
'message.send': [payload: {
|
|
18
|
+
adapter: string;
|
|
19
|
+
endpointKey: string;
|
|
20
|
+
content: SendContent;
|
|
21
|
+
receipt: DeliveryReceipt;
|
|
22
|
+
}];
|
|
23
|
+
'endpoint.connect': [event: EndpointEvent];
|
|
24
|
+
'endpoint.disconnect': [event: EndpointEvent];
|
|
25
|
+
'endpoint.error': [event: EndpointEvent];
|
|
26
|
+
}
|
|
27
|
+
export type MessageBusEventName = keyof MessageBusEventMap;
|
|
28
|
+
export declare class MessageBus {
|
|
29
|
+
private readonly emitter;
|
|
30
|
+
constructor();
|
|
31
|
+
on<E extends MessageBusEventName>(event: E, listener: (...args: MessageBusEventMap[E]) => void): () => void;
|
|
32
|
+
once<E extends MessageBusEventName>(event: E, listener: (...args: MessageBusEventMap[E]) => void): () => void;
|
|
33
|
+
emit<E extends MessageBusEventName>(event: E, ...args: MessageBusEventMap[E]): void;
|
|
34
|
+
off<E extends MessageBusEventName>(event: E, listener: (...args: MessageBusEventMap[E]) => void): void;
|
|
35
|
+
listenerCount(event: MessageBusEventName): number;
|
|
36
|
+
removeAllListeners(event?: MessageBusEventName): void;
|
|
37
|
+
}
|
|
38
|
+
export declare const messageBusToken: import("@zhin.js/plugin-runtime").Token<MessageBus>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MessageBus — 独立于 Plugin 的 IM 生命周期事件总线。
|
|
3
|
+
*
|
|
4
|
+
* 覆盖 Plugin.Lifecycle 中关键 IM 事件,供 Scope+Token 路径消费。
|
|
5
|
+
* 遗留 Plugin.emit 通过短暂双写桥接(迁移窗口)。
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from 'node:events';
|
|
8
|
+
import { createToken } from '@zhin.js/plugin-runtime';
|
|
9
|
+
export class MessageBus {
|
|
10
|
+
emitter = new EventEmitter();
|
|
11
|
+
constructor() {
|
|
12
|
+
this.emitter.setMaxListeners(50);
|
|
13
|
+
}
|
|
14
|
+
on(event, listener) {
|
|
15
|
+
this.emitter.on(event, listener);
|
|
16
|
+
return () => this.emitter.off(event, listener);
|
|
17
|
+
}
|
|
18
|
+
once(event, listener) {
|
|
19
|
+
this.emitter.once(event, listener);
|
|
20
|
+
return () => this.emitter.off(event, listener);
|
|
21
|
+
}
|
|
22
|
+
emit(event, ...args) {
|
|
23
|
+
this.emitter.emit(event, ...args);
|
|
24
|
+
}
|
|
25
|
+
off(event, listener) {
|
|
26
|
+
this.emitter.off(event, listener);
|
|
27
|
+
}
|
|
28
|
+
listenerCount(event) {
|
|
29
|
+
return this.emitter.listenerCount(event);
|
|
30
|
+
}
|
|
31
|
+
removeAllListeners(event) {
|
|
32
|
+
if (event) {
|
|
33
|
+
this.emitter.removeAllListeners(event);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.emitter.removeAllListeners();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const messageBusToken = createToken('zhin.im.message-bus');
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { UserInteractionFactory } from '@zhin.js/interaction';
|
|
2
|
+
import type { RuntimeSnapshot } from '@zhin.js/plugin-runtime';
|
|
3
|
+
import type { Message, MessageDispatchResult } from './contracts.js';
|
|
4
|
+
/**
|
|
5
|
+
* 命令前缀解析器:返回该消息要求的命令前缀。
|
|
6
|
+
* `''` 表示无前缀(任意文本都尝试按命令匹配)。
|
|
7
|
+
*/
|
|
8
|
+
export type CommandPrefixResolver = (message: Message, snapshot: RuntimeSnapshot) => string;
|
|
9
|
+
/**
|
|
10
|
+
* 默认解析:读消息所属适配器实例 config 的 `commandPrefix`(默认 `''`);
|
|
11
|
+
* 实例声明 `endpoints` 数组时,按消息 endpoint 名找 entry,`entry.commandPrefix` 覆盖顶层。
|
|
12
|
+
*/
|
|
13
|
+
export declare const defaultCommandPrefixResolver: CommandPrefixResolver;
|
|
14
|
+
export declare class MessageDispatcher {
|
|
15
|
+
private readonly resolvePrefix;
|
|
16
|
+
constructor(resolvePrefix?: CommandPrefixResolver);
|
|
17
|
+
dispatch(message: Message, snapshot: RuntimeSnapshot, interactionFactory?: UserInteractionFactory): Promise<MessageDispatchResult>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { commandFeatureId, isCommandIndex, } from '@zhin.js/command';
|
|
2
|
+
import { formatCompact, getLogger, truncatePreview } from '@zhin.js/logger';
|
|
3
|
+
const logger = getLogger('command');
|
|
4
|
+
function ownerOfMessage(message) {
|
|
5
|
+
return message.conversation.endpoint.adapter;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 默认解析:读消息所属适配器实例 config 的 `commandPrefix`(默认 `''`);
|
|
9
|
+
* 实例声明 `endpoints` 数组时,按消息 endpoint 名找 entry,`entry.commandPrefix` 覆盖顶层。
|
|
10
|
+
*/
|
|
11
|
+
export const defaultCommandPrefixResolver = (message, snapshot) => {
|
|
12
|
+
const config = snapshot.config.get(ownerOfMessage(message));
|
|
13
|
+
if (!config)
|
|
14
|
+
return '';
|
|
15
|
+
const endpointId = message.endpointId;
|
|
16
|
+
if (endpointId && Array.isArray(config.endpoints)) {
|
|
17
|
+
const entry = config.endpoints.find((item) => !!item && typeof item === 'object'
|
|
18
|
+
&& item.id === endpointId);
|
|
19
|
+
if (typeof entry?.commandPrefix === 'string')
|
|
20
|
+
return entry.commandPrefix;
|
|
21
|
+
}
|
|
22
|
+
return typeof config.commandPrefix === 'string' ? config.commandPrefix : '';
|
|
23
|
+
};
|
|
24
|
+
export class MessageDispatcher {
|
|
25
|
+
resolvePrefix;
|
|
26
|
+
constructor(resolvePrefix = defaultCommandPrefixResolver) {
|
|
27
|
+
this.resolvePrefix = resolvePrefix;
|
|
28
|
+
}
|
|
29
|
+
async dispatch(message, snapshot, interactionFactory) {
|
|
30
|
+
const prefix = this.resolvePrefix(message, snapshot);
|
|
31
|
+
let input = message.content.trim();
|
|
32
|
+
if (prefix && !input.startsWith(prefix)) {
|
|
33
|
+
return Object.freeze({ matched: false });
|
|
34
|
+
}
|
|
35
|
+
if (prefix)
|
|
36
|
+
input = input.slice(prefix.length).trim();
|
|
37
|
+
if (!input)
|
|
38
|
+
return Object.freeze({ matched: false });
|
|
39
|
+
const commands = snapshot.projections.get(commandFeatureId);
|
|
40
|
+
if (!isCommandIndex(commands))
|
|
41
|
+
return Object.freeze({ matched: false });
|
|
42
|
+
const structuredInput = message.segments
|
|
43
|
+
? stripCommandPrefix(message.segments, prefix)
|
|
44
|
+
: undefined;
|
|
45
|
+
const matchInput = structuredInput ?? input;
|
|
46
|
+
const result = await commands.dispatch(matchInput, message, interactionFactory, prefix);
|
|
47
|
+
if (result.matched && result.value !== undefined) {
|
|
48
|
+
if (!result.owner)
|
|
49
|
+
throw new Error('Matched Command is missing its owner');
|
|
50
|
+
logger.debug(formatCompact({
|
|
51
|
+
op: 'dispatch_hit',
|
|
52
|
+
command: result.command,
|
|
53
|
+
owner: result.owner,
|
|
54
|
+
}));
|
|
55
|
+
await message.$replyFrom(result.owner, result.value);
|
|
56
|
+
}
|
|
57
|
+
else if (!result.matched) {
|
|
58
|
+
logger.debug(formatCompact({
|
|
59
|
+
op: 'dispatch_miss',
|
|
60
|
+
preview: truncatePreview(input),
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Keep the text and structured views aligned. Falling back to `content` is
|
|
68
|
+
* intentional when an adapter supplies inconsistent segment data.
|
|
69
|
+
*/
|
|
70
|
+
function stripCommandPrefix(segments, prefix) {
|
|
71
|
+
let pendingPrefix = prefix;
|
|
72
|
+
let atStart = true;
|
|
73
|
+
const result = [];
|
|
74
|
+
for (const segment of segments) {
|
|
75
|
+
if (!atStart) {
|
|
76
|
+
result.push(segment);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (segment.type !== 'text' || typeof segment.data.text !== 'string') {
|
|
80
|
+
if (pendingPrefix)
|
|
81
|
+
return undefined;
|
|
82
|
+
atStart = false;
|
|
83
|
+
result.push(segment);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
let text = segment.data.text;
|
|
87
|
+
if (pendingPrefix) {
|
|
88
|
+
if (text.startsWith(pendingPrefix)) {
|
|
89
|
+
text = text.slice(pendingPrefix.length);
|
|
90
|
+
pendingPrefix = '';
|
|
91
|
+
}
|
|
92
|
+
else if (pendingPrefix.startsWith(text)) {
|
|
93
|
+
pendingPrefix = pendingPrefix.slice(text.length);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
text = text.trimStart();
|
|
101
|
+
if (!text)
|
|
102
|
+
continue;
|
|
103
|
+
atStart = false;
|
|
104
|
+
result.push({ ...segment, data: { ...segment.data, text } });
|
|
105
|
+
}
|
|
106
|
+
return pendingPrefix ? undefined : result;
|
|
107
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PluginId, RuntimeSnapshot } from '@zhin.js/plugin-runtime';
|
|
2
|
+
import type { ConversationRef } from '@zhin.js/im-contract';
|
|
3
|
+
import { type IncomingContext, type SendContent } from './contracts.js';
|
|
4
|
+
export declare class OutboundRenderer {
|
|
5
|
+
#private;
|
|
6
|
+
render(content: SendContent, requester: PluginId, snapshot: RuntimeSnapshot, conversation?: ConversationRef, incoming?: IncomingContext): Promise<unknown>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { componentHostToken } from '@zhin.js/plugin-runtime';
|
|
2
|
+
import { componentFeatureId, isComponentIndex, } from '@zhin.js/component';
|
|
3
|
+
import { isComponentCall, isRawContent, isSegmentContent, } from './contracts.js';
|
|
4
|
+
const maxComponentDepth = 32;
|
|
5
|
+
const TEMPLATE_MARKER = '${';
|
|
6
|
+
export class OutboundRenderer {
|
|
7
|
+
async render(content, requester, snapshot, conversation, incoming) {
|
|
8
|
+
const host = resolveComponentHost(snapshot);
|
|
9
|
+
const ctx = conversation ? buildTemplateContext(conversation, incoming) : undefined;
|
|
10
|
+
return this.#render(content, requester, snapshot, host, ctx, 0);
|
|
11
|
+
}
|
|
12
|
+
async #render(content, requester, snapshot, host, ctx, depth) {
|
|
13
|
+
if (depth > maxComponentDepth)
|
|
14
|
+
throw new Error('Component render depth exceeded 32');
|
|
15
|
+
if (typeof content === 'string')
|
|
16
|
+
return compileText(content, host, ctx);
|
|
17
|
+
if (Array.isArray(content)) {
|
|
18
|
+
return Promise.all(content.map((item) => this.#render(item, requester, snapshot, host, ctx, depth)));
|
|
19
|
+
}
|
|
20
|
+
if (isRawContent(content))
|
|
21
|
+
return content.payload;
|
|
22
|
+
if (isSegmentContent(content)) {
|
|
23
|
+
if (content.type === 'text') {
|
|
24
|
+
const text = content.data?.text;
|
|
25
|
+
if (typeof text === 'string' && text.includes(TEMPLATE_MARKER) && host && ctx) {
|
|
26
|
+
return { ...content, data: { ...content.data, text: host.compileTemplate(text, ctx) } };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return content;
|
|
30
|
+
}
|
|
31
|
+
if (isComponentCall(content)) {
|
|
32
|
+
const rendered = await requireComponents(snapshot).render(requester, content.name, content.props);
|
|
33
|
+
return this.#render(rendered, requester, snapshot, host, ctx, depth + 1);
|
|
34
|
+
}
|
|
35
|
+
throw new TypeError('Unsupported SendContent');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function compileText(text, host, ctx) {
|
|
39
|
+
if (!host || !ctx || !text.includes(TEMPLATE_MARKER))
|
|
40
|
+
return text;
|
|
41
|
+
return host.compileTemplate(text, ctx);
|
|
42
|
+
}
|
|
43
|
+
function buildTemplateContext(conversation, incoming) {
|
|
44
|
+
return {
|
|
45
|
+
adapter: conversation.endpoint.adapter,
|
|
46
|
+
endpoint: conversation.endpoint.id,
|
|
47
|
+
kind: conversation.kind,
|
|
48
|
+
conversationId: conversation.id,
|
|
49
|
+
sender: incoming?.sender,
|
|
50
|
+
content: incoming?.content,
|
|
51
|
+
segments: incoming?.segments,
|
|
52
|
+
messageId: incoming?.messageId,
|
|
53
|
+
timestamp: incoming?.timestamp,
|
|
54
|
+
endpointId: incoming?.endpointId,
|
|
55
|
+
mentioned: incoming?.mentioned,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function resolveComponentHost(snapshot) {
|
|
59
|
+
const host = snapshot.resources.get(snapshot.root)?.get(componentHostToken.id);
|
|
60
|
+
return host && typeof host.compileTemplate === 'function'
|
|
61
|
+
? host
|
|
62
|
+
: undefined;
|
|
63
|
+
}
|
|
64
|
+
function requireComponents(snapshot) {
|
|
65
|
+
const projection = snapshot.projections.get(componentFeatureId);
|
|
66
|
+
if (!isComponentIndex(projection)) {
|
|
67
|
+
throw new Error('Component Feature projection is not installed');
|
|
68
|
+
}
|
|
69
|
+
return projection;
|
|
70
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { CapabilityId, HtmlRendererHost, RuntimeSnapshot } from '@zhin.js/plugin-runtime';
|
|
2
|
+
import { type InteractivePolicy } from '../../built/interactive-segments/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Outbound payload normalization for the Plugin Runtime IM pipeline.
|
|
5
|
+
*
|
|
6
|
+
* `raw()` payloads reach adapters as-is; adapters only understand wire
|
|
7
|
+
* segments (`{ type, data }` arrays). A single segment object (non-array)
|
|
8
|
+
* would otherwise fall through to `String(payload)` → '[object Object]'.
|
|
9
|
+
*
|
|
10
|
+
* Segment payloads are normalized to the canonical Segment SSOT
|
|
11
|
+
* (`built/segment-contract`,复用 `toCanonicalSegments`:at→mention、
|
|
12
|
+
* 旧 wire 字段 `{url,file,base64}`→MediaRef)。`html` segments additionally
|
|
13
|
+
* need a Host renderer: image when `@zhin.js/html-renderer` is installed,
|
|
14
|
+
* plain-text fallback otherwise. 渲染产出的 base64 图片按端点声明的媒体
|
|
15
|
+
* 能力(`resolveOutboundMediaPolicy`)协商降级。
|
|
16
|
+
*/
|
|
17
|
+
export interface OutboundSegment {
|
|
18
|
+
readonly type: string;
|
|
19
|
+
readonly data?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 出站媒体能力策略(html→image 渲染产物与 base64/path 媒体段的投递方式):
|
|
23
|
+
* - `base64`:平台接受 base64 直发;
|
|
24
|
+
* - `url-or-text`:平台仅接受 URL 媒体;本层无上传通道,base64/path → 文本降级;
|
|
25
|
+
* - `passthrough`:adapter 自行物化媒体,本层不动。
|
|
26
|
+
*/
|
|
27
|
+
export type OutboundMediaPolicy = 'base64' | 'url-or-text' | 'passthrough';
|
|
28
|
+
/**
|
|
29
|
+
* adapter definition 的 segments policy 声明(必选能力面)。
|
|
30
|
+
* `outboundMedia` 为端点可消费的媒体来源形式数组
|
|
31
|
+
* ('url' | 'path' | 'base64' | 'upload'),映射到投递策略:
|
|
32
|
+
* base64 可直发;无 base64 但端点可自行物化(upload/path)→ passthrough;
|
|
33
|
+
* 仅 url → 非 URL 媒体文本降级。未声明的 adapter 按 ['url'] 兜底。
|
|
34
|
+
*/
|
|
35
|
+
export interface OutboundSegmentsPolicy {
|
|
36
|
+
readonly outboundMedia: readonly ('url' | 'path' | 'base64' | 'upload')[];
|
|
37
|
+
readonly interactive?: InteractivePolicy;
|
|
38
|
+
readonly markdown?: 'native' | 'text';
|
|
39
|
+
}
|
|
40
|
+
export interface NormalizeOutboundOptions {
|
|
41
|
+
/** 缺省 `url-or-text`(未声明 adapter 的保守兜底:仅 URL 媒体可达)。 */
|
|
42
|
+
readonly mediaPolicy?: OutboundMediaPolicy;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 解析端点的出站媒体策略:读 adapter definition 声明的 `segments.outboundMedia`
|
|
46
|
+
* (多 endpoint 展开的 `slot~entry` id 回退到 slot id 查声明);
|
|
47
|
+
* 未声明回退 `url-or-text`(仅 URL 媒体可达,其余文本降级)。
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveOutboundMediaPolicy(adapter: CapabilityId, snapshot: RuntimeSnapshot): OutboundMediaPolicy;
|
|
50
|
+
export declare function isOutboundSegment(value: unknown): value is OutboundSegment;
|
|
51
|
+
/**
|
|
52
|
+
* 解析端点的出站 interactive 策略:优先读 adapter definition 上声明的
|
|
53
|
+
* `segments.interactive`,否则按平台名查内置表,未知平台回退 'text'。
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveOutboundInteractivePolicy(adapter: CapabilityId, snapshot: RuntimeSnapshot): InteractivePolicy;
|
|
56
|
+
/** Preserve semantic Markdown only when the endpoint explicitly declares native consumption. */
|
|
57
|
+
export declare function resolveOutboundMarkdownPolicy(adapter: CapabilityId, snapshot: RuntimeSnapshot): 'native' | 'text';
|
|
58
|
+
export declare function applyOutboundMarkdownPolicy(payload: unknown, policy: 'native' | 'text'): unknown;
|
|
59
|
+
/**
|
|
60
|
+
* keyboard 段中央降级:'text' 端点把 keyboard 渲染为编号文本(复用旧轨
|
|
61
|
+
* `renderKeyboardAsText`),并把有效 fallback 映射经 `remember` 回调写入
|
|
62
|
+
* 中央存储(供入站数字回跳解析);'native' 端点透传 keyboard。
|
|
63
|
+
*/
|
|
64
|
+
export declare function applyOutboundInteractivePolicy(payload: unknown, policy: InteractivePolicy, remember?: (map: Record<string, string>) => void): unknown;
|
|
65
|
+
/**
|
|
66
|
+
* Normalize a rendered outbound payload toward canonical wire segments:
|
|
67
|
+
* - segment arrays stay arrays (html segments converted per element,
|
|
68
|
+
* 其余段经 `toCanonicalSegments` 归一为 canonical Segment);
|
|
69
|
+
* - a single segment object is wrapped into a one-element array;
|
|
70
|
+
* - anything else (plain strings, legacy `{ text }` shorthands) passes through.
|
|
71
|
+
*/
|
|
72
|
+
export declare function normalizeOutboundPayload(payload: unknown, renderer?: HtmlRendererHost, options?: NormalizeOutboundOptions): Promise<unknown>;
|