@zhin.js/core 1.1.33 → 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 +140 -61
- package/lib/adapter.d.ts +72 -23
- package/lib/adapter.js +222 -58
- 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 +9 -0
- package/lib/built/html-segment-fallback.js +49 -0
- package/lib/built/html-to-text.d.ts +4 -1
- package/lib/built/html-to-text.js +47 -16
- 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 +67 -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 -21
- package/lib/index.js +53 -28
- 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 -85
- package/lib/types.js +0 -1
- package/lib/utils.d.ts +68 -1
- package/lib/utils.js +73 -11
- 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-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/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 -33
- package/lib/built/prepend-quote-context.d.ts.map +0 -1
- package/lib/built/prepend-quote-context.js +0 -129
- 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
package/README.md
CHANGED
|
@@ -1,71 +1,72 @@
|
|
|
1
1
|
# @zhin.js/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Plugin Runtime 子路径
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
新的 owner-aware IM 能力已经并入 Core,作为 Plugin Runtime 的正式领域接口:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- `@zhin.js/core/runtime`
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`@zhin.js/adapter`、`@zhin.js/command`、`@zhin.js/component` 与
|
|
10
|
+
`@zhin.js/middleware` 提供纯 definition、约定发现 provider 和 generation projection;
|
|
11
|
+
Core Runtime 只消费它们发布的 snapshot。
|
|
12
|
+
旧根入口的 `addCommand`、`addComponent`、`addMiddleware` 暂时作为作者兼容接口保留,后续
|
|
13
|
+
只向 RuntimeSnapshot 投影,不再维护第二套运行时权威。
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
Zhin.js **IM/多通道运行时**包:Plugin、Adapter、**Endpoint**、MessageDispatcher 与统一出站链。**AI 编排(ZhinAgent、工具安全、MCP)在 [`@zhin.js/agent`](../agent/README.md)**;本包仅 selective re-export `@zhin.js/ai` 的 Provider / Agent 原语供插件直接使用。
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
import { usePlugin, MessageCommand } from '@zhin.js/core'
|
|
15
|
-
|
|
16
|
-
const { addCommand, addTool, addCron, onMounted, onDispose } = usePlugin()
|
|
17
|
+
领域词汇见 [CONTEXT.md](./CONTEXT.md);入站/出站流程见 [消息如何流转](../../docs/essentials/message-flow.md)。
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
onDispose(() => console.log('插件已卸载'))
|
|
19
|
+
## 核心概念
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
new MessageCommand('hello <name:string>')
|
|
23
|
-
.desc('打招呼')
|
|
24
|
-
.action((_, result) => `Hello, ${result.params.name}!`)
|
|
25
|
-
)
|
|
26
|
-
```
|
|
21
|
+
### Plugin(插件)— Plugin Runtime
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
唯一启动路径:`zhin runtime start`。`plugin.ts` 必须 default-export `definePlugin()`;能力按约定目录发现。
|
|
29
24
|
|
|
30
25
|
```typescript
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// 方式 2: 使用 definePlugin 声明式 API
|
|
35
|
-
import { definePlugin } from '@zhin.js/core'
|
|
26
|
+
// plugin.ts
|
|
27
|
+
import { definePlugin } from '@zhin.js/plugin-runtime'
|
|
36
28
|
|
|
37
29
|
export default definePlugin({
|
|
38
|
-
name: '
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
name: 'hello-bot',
|
|
31
|
+
metadata: { displayName: 'Hello Bot' },
|
|
32
|
+
setup(context) {
|
|
33
|
+
context.lifecycle.add(() => { /* cleanup */ })
|
|
41
34
|
},
|
|
42
35
|
})
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// commands/hello/[name].ts
|
|
40
|
+
import { defineCommand } from '@zhin.js/command'
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
export default defineCommand({
|
|
43
|
+
description: '打招呼',
|
|
44
|
+
params: {
|
|
45
|
+
name: { type: 'string' },
|
|
46
|
+
},
|
|
47
|
+
execute({ params }) {
|
|
48
|
+
return `Hello, ${params.name}!`
|
|
49
|
+
},
|
|
50
|
+
})
|
|
47
51
|
```
|
|
48
52
|
|
|
53
|
+
> **已移除**:`usePlugin()` / `getPlugin()` / `bootstrapNode`(`zhin.js/node`)调用即 throw;唯一入口为 `definePlugin` + `zhin runtime start`。`MessageCommand` / `Plugin.addCommand` 仍 deprecated。见 [public-api-surface](../../docs/contributing/public-api-surface.md)。
|
|
54
|
+
|
|
55
|
+
本包仍提供 IM 运行时契约(Message / Adapter / Endpoint);创作面在 Feature 包与 `@zhin.js/plugin-runtime`。
|
|
56
|
+
|
|
49
57
|
### Feature(特性抽象)
|
|
50
58
|
|
|
51
|
-
Feature
|
|
59
|
+
约定式 Feature(Command / Middleware / Component / Adapter…)由独立包提供 definition + 约定发现;Core Runtime 消费 snapshot。
|
|
60
|
+
|
|
61
|
+
经典 `CommandFeature` / `addCommand` 等仍挂在 `Plugin.prototype`,**已 deprecated**,仅兼容 Agent init / game-kit:
|
|
52
62
|
|
|
53
63
|
```
|
|
54
|
-
Feature (抽象基类)
|
|
55
|
-
├── CommandFeature —
|
|
56
|
-
├── ToolFeature — AI
|
|
57
|
-
├──
|
|
58
|
-
├── CronFeature — 定时任务 addCron()
|
|
59
|
-
├── DatabaseFeature — 数据模型 defineModel()
|
|
60
|
-
├── ComponentFeature — 消息组件 addComponent()
|
|
61
|
-
├── ConfigFeature — 插件配置 addConfig()
|
|
62
|
-
└── PermissionFeature — 权限管理
|
|
64
|
+
Feature (抽象基类) — legacy 注册表仍在
|
|
65
|
+
├── CommandFeature — MessageCommand(→ defineCommand)
|
|
66
|
+
├── ToolFeature — AI 工具(→ defineAgentTool)
|
|
67
|
+
├── …
|
|
63
68
|
```
|
|
64
69
|
|
|
65
|
-
每个 Feature 都会在 `Plugin.prototype` 上注入对应的扩展方法(如 `addCommand`、`addTool`),插件通过 `usePlugin()` 获取这些方法。
|
|
66
|
-
|
|
67
|
-
Feature 支持变更事件监听,依赖方可实时响应 item 的增删:
|
|
68
|
-
|
|
69
70
|
```typescript
|
|
70
71
|
const toolFeature = plugin.inject('tool')
|
|
71
72
|
const off = toolFeature.on('add', (tool, pluginName) => {
|
|
@@ -76,6 +77,71 @@ toolFeature.on('remove', (tool) => {
|
|
|
76
77
|
})
|
|
77
78
|
```
|
|
78
79
|
|
|
80
|
+
### 出站消息段:`segment.html`
|
|
81
|
+
|
|
82
|
+
业务插件可返回 **`html` 消息段**,由出站链统一处理转图或文本回退:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { segment } from '@zhin.js/core'
|
|
86
|
+
|
|
87
|
+
return segment.html({
|
|
88
|
+
html: '<div>…</div>', // 必填:Satori 可渲染的 HTML
|
|
89
|
+
text: undefined, // 可选:显式回退文本(覆盖自动剥离)
|
|
90
|
+
width: 540,
|
|
91
|
+
backgroundColor: '#d8dce3',
|
|
92
|
+
fileName: 'card.png',
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
// Markdown 段(QQ 等平台 policy 为 origin 时透传)
|
|
96
|
+
return segment.markdown('# Title\n\nBody')
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
出站富媒体段(`qrcode` / `html` / `markdown`)在 **`Adapter.renderSendMessage` 首步** 按各 Adapter 的 **`outboundRichSegmentPolicy`** 统一渲染为 `image` / `text` / `origin`:
|
|
100
|
+
|
|
101
|
+
| 渲染模式 | 含义 |
|
|
102
|
+
|---------|------|
|
|
103
|
+
| `image` | 转为 `image` 段(qrcode 生成 PNG;html/markdown 经 `@zhin.js/html-renderer` 动态转图,未安装则降级 text) |
|
|
104
|
+
| `text` | 剥离为纯文本段 |
|
|
105
|
+
| `origin` | 原样透传,由 Endpoint 解释(如 QQ markdown、process 终端二维码) |
|
|
106
|
+
|
|
107
|
+
默认策略:`qrcode: image`,`html: text`,`markdown: text`。QQ / KOOK 等适配器 override static policy。
|
|
108
|
+
|
|
109
|
+
- 安装 **`@zhin.js/html-renderer`** 且 policy 为 `html: 'image'` 时,core 在首步动态 import 并转 PNG。
|
|
110
|
+
- policy 为 `html: 'text'` 时等价于 **`coerceHtmlSegmentsToText`** / **`htmlToFallbackText`**。
|
|
111
|
+
- 日志预览:`[html-card]`、`[qrcode]`、`[markdown]` + 摘要(前 80 字)。
|
|
112
|
+
|
|
113
|
+
#### 扩展新 Rich Segment(长期方案)
|
|
114
|
+
|
|
115
|
+
内置 kind 通过 **`richSegmentRegistry`** 注册;optional 能力通过 **`registerRichSegmentCapabilityLoader`** 注入(与 `@zhin.js/html-renderer` 同模式)。
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import {
|
|
119
|
+
RichSegment,
|
|
120
|
+
registerRichSegmentKind,
|
|
121
|
+
registerRichSegmentCapabilityLoader,
|
|
122
|
+
RICH_SEGMENT_MODE,
|
|
123
|
+
segment,
|
|
124
|
+
} from '@zhin.js/core';
|
|
125
|
+
|
|
126
|
+
// 1. 内置 capability:speech(@zhin.js/speech)已注册,tts kind 已内置
|
|
127
|
+
// 可选:注册 ffmpeg 等
|
|
128
|
+
registerRichSegmentCapabilityLoader('media-pipeline', async (opts) => {
|
|
129
|
+
const { createMediaPipeline } = await import('@zhin.js/media-pipeline');
|
|
130
|
+
return createMediaPipeline(opts.getConfig?.());
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// 2. 使用内置 segment.tts(Adapter policy 决定 audio/text/origin)
|
|
134
|
+
// segment.tts({ text: '你好' })
|
|
135
|
+
class MyAdapter extends Adapter {
|
|
136
|
+
static override outboundRichSegmentPolicy = {
|
|
137
|
+
tts: 'audio',
|
|
138
|
+
qrcode: 'image', // 其余 kind 用 registry 默认值
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**分工**:Rich Segment 负责「语义段 → 标准 IM 段」;Endpoint `materializeOutboundMedia` 负责「已有 audio/video/file → 平台上传」。
|
|
144
|
+
|
|
79
145
|
### Adapter(适配器)
|
|
80
146
|
|
|
81
147
|
适配器将不同聊天平台接入 Zhin.js,统一消息收发接口。
|
|
@@ -85,20 +151,20 @@ toolFeature.on('remove', (tool) => {
|
|
|
85
151
|
Adapter.register('my-platform', MyAdapter)
|
|
86
152
|
```
|
|
87
153
|
|
|
88
|
-
每个适配器可以通过 `addTool()` 注册平台特有工具,标准群管操作通过覆写 `
|
|
154
|
+
每个适配器可以通过 `addTool()` 注册平台特有工具,标准群管操作通过覆写 `ISceneManagement` 方法自动注册。
|
|
89
155
|
|
|
90
|
-
**群管理能力自动检测:** 适配器基类声明了 `
|
|
156
|
+
**群管理能力自动检测:** 适配器基类声明了 `ISceneManagement` 接口中的可选方法(`kickMember`、`muteMember`、`banMember` 等),子类只需覆写自己平台支持的方法,`start()` 会自动检测哪些方法已实现,生成对应的 Tool 并注册为"群聊管理"Skill。目前所有 9 个 IM 适配器(ICQQ、OneBot11、QQ 官方、Telegram、Discord、KOOK、Slack、钉钉、飞书)均已采用此模式:
|
|
91
157
|
|
|
92
158
|
```typescript
|
|
93
|
-
class IcqqAdapter extends Adapter<
|
|
159
|
+
class IcqqAdapter extends Adapter<IcqqEndpoint> {
|
|
94
160
|
// 覆写标准群管方法
|
|
95
|
-
async kickMember(
|
|
96
|
-
const
|
|
97
|
-
if (!
|
|
98
|
-
return
|
|
161
|
+
async kickMember(endpointId: string, sceneId: string, userId: string) {
|
|
162
|
+
const endpoint = this.endpoints.get(endpointId)
|
|
163
|
+
if (!endpoint) throw new Error(`Endpoint ${endpointId} 不存在`)
|
|
164
|
+
return endpoint.kickMember(Number(sceneId), Number(userId), false)
|
|
99
165
|
}
|
|
100
|
-
async muteMember(
|
|
101
|
-
async setAdmin(
|
|
166
|
+
async muteMember(endpointId: string, sceneId: string, userId: string, duration = 600) { /* ... */ }
|
|
167
|
+
async setAdmin(endpointId: string, sceneId: string, userId: string, enable = true) { /* ... */ }
|
|
102
168
|
// ...共覆写 7 个标准方法
|
|
103
169
|
|
|
104
170
|
async start() {
|
|
@@ -130,9 +196,9 @@ Core **不包含** ZhinAgent 实现。IM 侧的 AI 对话、工具收集、执
|
|
|
130
196
|
|
|
131
197
|
| 类别 | 示例导出 |
|
|
132
198
|
|------|----------|
|
|
133
|
-
| Provider | `
|
|
134
|
-
| Agent 原语 | `
|
|
135
|
-
| 会话 / 上下文 | `
|
|
199
|
+
| Provider | `AIProvider` 接口、`createSdkProviderAdapter`(AI SDK 传输) |
|
|
200
|
+
| Agent 原语 | `ModelRegistry`、`agentLoop` |
|
|
201
|
+
| 会话 / 上下文 | `ConversationEventStore`(IM 事实)与 Agent 的 `ContextRepository`(模型会话) |
|
|
136
202
|
| 压缩 / 限流 / 输出 | `compactSession`、`RateLimiter`、`parseOutput`、`CostTracker` |
|
|
137
203
|
|
|
138
204
|
完整 Agent 能力与配置见 [`@zhin.js/agent`](../agent/README.md) 与 [AI 模块](https://zhin.js.org/advanced/ai)。
|
|
@@ -143,22 +209,35 @@ Core **不包含** ZhinAgent 实现。IM 侧的 AI 对话、工具收集、执
|
|
|
143
209
|
|
|
144
210
|
```typescript
|
|
145
211
|
// 插件系统
|
|
146
|
-
export { Plugin, usePlugin, getPlugin, definePlugin } from './plugin.js'
|
|
212
|
+
export { Plugin, usePlugin, getPlugin, definePlugin } from './plugin.js' // usePlugin/getPlugin 为 throwing stub
|
|
147
213
|
|
|
148
214
|
// Feature 体系(Cron / Scheduler 来自 @zhin.js/kernel)
|
|
149
215
|
export { Feature, Cron, Scheduler } from '@zhin.js/kernel'
|
|
150
|
-
export { CommandFeature, ToolFeature, SkillFeature,
|
|
216
|
+
export { CommandFeature, ToolFeature, SkillFeature, ScheduleFeature, DatabaseFeature, ... } from './built/*.js'
|
|
151
217
|
|
|
152
218
|
// 消息路由
|
|
153
219
|
export { createMessageDispatcher } from './built/dispatcher.js'
|
|
154
220
|
|
|
155
|
-
//
|
|
156
|
-
export { Adapter, Message, MessageCommand,
|
|
221
|
+
// 适配器与消息(MessageCommand 已 deprecated)
|
|
222
|
+
export { Adapter, Message, MessageCommand, Endpoint, segment, ... } from './'
|
|
223
|
+
|
|
224
|
+
// 富媒体出站段
|
|
225
|
+
export {
|
|
226
|
+
resolveRichSegments,
|
|
227
|
+
DEFAULT_OUTBOUND_RICH_SEGMENT_POLICY,
|
|
228
|
+
QrcodeSegment,
|
|
229
|
+
HtmlSegment,
|
|
230
|
+
MarkdownSegment,
|
|
231
|
+
} from './built/rich-segments/index.js'
|
|
232
|
+
export type { RichSegmentKind, RichRenderMode, OutboundRichSegmentPolicy } from './built/rich-segments/types.js'
|
|
233
|
+
|
|
234
|
+
// HTML 出站回退(legacy;policy html:'text' 时等价)
|
|
235
|
+
export { htmlToFallbackText, coerceHtmlSegmentsToText, registerHtmlSegmentFallback } from './built/*.js'
|
|
157
236
|
|
|
158
237
|
// AI 原语(来自 @zhin.js/ai,非 ZhinAgent)
|
|
159
238
|
export {
|
|
160
|
-
|
|
161
|
-
|
|
239
|
+
AIProvider, createSdkProviderAdapter, ModelRegistry,
|
|
240
|
+
ContextRepository, ContextManager, compactSession, ...
|
|
162
241
|
} from '@zhin.js/ai'
|
|
163
242
|
```
|
|
164
243
|
|
package/lib/adapter.d.ts
CHANGED
|
@@ -1,44 +1,73 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Endpoint } from "./endpoint.js";
|
|
2
|
+
import { DEFAULT_ENDPOINT_CAPABILITIES, type EndpointCapability } from "./endpoint-capabilities.js";
|
|
3
|
+
import type { EndpointManager } from "./built/endpoint-manager.js";
|
|
2
4
|
import { Plugin } from "./plugin.js";
|
|
3
5
|
import { EventEmitter } from "node:events";
|
|
4
6
|
import { Message } from "./message.js";
|
|
5
7
|
import { Notice } from "./notice.js";
|
|
6
8
|
import { Request } from "./request.js";
|
|
7
|
-
import { SendOptions } from "./types.js";
|
|
9
|
+
import { EditMessageOptions, SendOptions } from "./types.js";
|
|
10
|
+
import { type OutboundRichSegmentPolicy } from "./built/rich-segments/index.js";
|
|
11
|
+
import { type InteractivePolicy } from "./built/interactive-segments/index.js";
|
|
12
|
+
import { type AiOutboundCapabilities, type AiOutboundExtensionDefinition } from "./built/ai-outbound/index.js";
|
|
13
|
+
import type { Schema } from '@zhin.js/schema';
|
|
8
14
|
/**
|
|
9
15
|
* Adapter类:适配器抽象,管理多平台Bot实例。
|
|
10
16
|
* 负责根据配置启动/关闭各平台机器人,统一异常处理。
|
|
11
17
|
*
|
|
12
18
|
* 适配器可以提供 AI 工具,供 AI 服务调用。
|
|
13
19
|
*/
|
|
14
|
-
export declare abstract class Adapter<R extends
|
|
20
|
+
export declare abstract class Adapter<R extends Endpoint = Endpoint, const Caps extends readonly EndpointCapability[] = typeof DEFAULT_ENDPOINT_CAPABILITIES> extends EventEmitter<Adapter.Lifecycle> {
|
|
15
21
|
#private;
|
|
16
22
|
plugin: Plugin;
|
|
17
23
|
name: keyof Plugin.Contexts;
|
|
18
|
-
config: Adapter.
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
config: Adapter.EndpointConfig<R>[];
|
|
25
|
+
endpoints: Map<string, R>;
|
|
26
|
+
private recallMessageHandler;
|
|
27
|
+
/** Adapter 支持的能力上限(子类覆盖) */
|
|
28
|
+
static readonly capabilities: readonly EndpointCapability[];
|
|
29
|
+
/** 出站富媒体段渲染策略(子类 override static) */
|
|
30
|
+
static outboundRichSegmentPolicy: OutboundRichSegmentPolicy;
|
|
31
|
+
/** 交互段出站策略:native 保留按钮段,text 降级为编号文本 */
|
|
32
|
+
static interactivePolicy: InteractivePolicy;
|
|
33
|
+
/** AI 结构化出站能力声明(mentions / richSegments / interactive) */
|
|
34
|
+
static aiOutboundCapabilities: AiOutboundCapabilities;
|
|
35
|
+
/** 平台特有 extensions schema + 解析(对齐各 SDK 文档子集) */
|
|
36
|
+
static aiOutboundExtensions?: readonly AiOutboundExtensionDefinition[];
|
|
37
|
+
protected getInteractivePolicy(): InteractivePolicy;
|
|
21
38
|
/** 并发上限,0 表示不限制(默认) */
|
|
22
39
|
static DEFAULT_MAX_CONCURRENT_MESSAGES: number;
|
|
23
40
|
get maxConcurrentMessages(): number;
|
|
24
41
|
/** 当前正在处理的消息数 */
|
|
25
42
|
get pendingMessages(): number;
|
|
26
43
|
/**
|
|
27
|
-
*
|
|
44
|
+
* 创建一个适配器运行实例。
|
|
45
|
+
* @param plugin 拥有该适配器的插件实例
|
|
28
46
|
* @param name 适配器名称(如 'process'、'qq' 等)
|
|
29
|
-
* @param
|
|
47
|
+
* @param config Endpoint 配置列表
|
|
30
48
|
*/
|
|
31
|
-
constructor(plugin: Plugin, name: keyof Plugin.Contexts, config: Adapter.
|
|
49
|
+
constructor(plugin: Plugin, name: keyof Plugin.Contexts, config: Adapter.EndpointConfig<R>[]);
|
|
50
|
+
/** 入站消息管线(替代 emit override 的隐式管线) */
|
|
51
|
+
private inboundPipeline;
|
|
32
52
|
/**
|
|
33
|
-
* 重写 emit:拦截 message.receive
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* 以属性 + `EventEmitter.prototype.emit` 调用满足 Node @types 25 对泛型 `emit` 的可赋值检查。
|
|
53
|
+
* 重写 emit:拦截 message.receive/notice.receive/request.receive 事件,
|
|
54
|
+
* 将入站处理委托给 InboundMessagePipeline。
|
|
37
55
|
*/
|
|
38
56
|
emit: EventEmitter<Adapter.Lifecycle>['emit'];
|
|
39
|
-
abstract
|
|
57
|
+
abstract createEndpoint(config: Adapter.EndpointConfig<R>): R;
|
|
40
58
|
get logger(): import("@zhin.js/logger").Logger;
|
|
41
59
|
binding(plugin: Plugin): void;
|
|
60
|
+
/**
|
|
61
|
+
* 同步等待入站管线结束(middleware → dispatcher → 生命周期 → 观察者)。
|
|
62
|
+
* 用于 QQ 等需在被动回复完成后再 ack 交互的平台事件。
|
|
63
|
+
*/
|
|
64
|
+
receiveMessageAwait(message: Message): Promise<boolean>;
|
|
65
|
+
/** 运行时 Endpoint 管理(add/remove/edit/start/stop);未实现则 core 尝试 endpointConfigSchema 通用向导 */
|
|
66
|
+
getEndpointManager?(): EndpointManager | null;
|
|
67
|
+
/** 通用 schema 驱动 add/edit 时的字段定义 */
|
|
68
|
+
getEndpointConfigSchema?(): Schema | undefined;
|
|
69
|
+
/** 热连接失败时是否建议重启进程 */
|
|
70
|
+
getEndpointNeedsRestart?(): boolean;
|
|
42
71
|
/**
|
|
43
72
|
* 出站富媒体能力(Publisher 按此过滤/降级;各 adapter 可覆盖)。
|
|
44
73
|
*/
|
|
@@ -49,20 +78,41 @@ export declare abstract class Adapter<R extends Bot = Bot> extends EventEmitter<
|
|
|
49
78
|
file?: boolean;
|
|
50
79
|
maxAttachmentBytes?: number;
|
|
51
80
|
};
|
|
52
|
-
|
|
81
|
+
protected getOutboundRichSegmentPolicy(): OutboundRichSegmentPolicy;
|
|
82
|
+
/**
|
|
83
|
+
* 出站两阶段:
|
|
84
|
+
* 1. resolveRichSegments — 语义段 → 标准 IM 段(image/audio/text)
|
|
85
|
+
* 2. Endpoint materializeOutboundMedia — base64/本地路径 → 平台 URL(各 adapter 可选)
|
|
86
|
+
* @see docs/essentials/rich-segment-adapters.md
|
|
87
|
+
*/
|
|
88
|
+
protected renderSendMessage(options: SendOptions): Promise<SendOptions>;
|
|
53
89
|
sendMessage(options: SendOptions): Promise<string>;
|
|
90
|
+
/**
|
|
91
|
+
* `call.recallMessage` 事件链(prompt.ts 超时撤回等)的统一出口:
|
|
92
|
+
* 经 canonical `EndpointControl` 端口撤回。
|
|
93
|
+
*/
|
|
94
|
+
private recallEndpointMessage;
|
|
95
|
+
/**
|
|
96
|
+
* 编辑已发送的消息。
|
|
97
|
+
* - 如果 Endpoint 的 control 端口实现了 edit,调用平台编辑 API
|
|
98
|
+
* - 否则 fallback 到发送新消息
|
|
99
|
+
* @returns 消息 ID(编辑时返回原 ID,fallback 时返回新消息 ID)
|
|
100
|
+
*/
|
|
101
|
+
editMessage(options: EditMessageOptions): Promise<string>;
|
|
54
102
|
start(): Promise<void>;
|
|
55
103
|
/**
|
|
56
|
-
* 停止适配器,断开并移除所有
|
|
57
|
-
* @param plugin 所属插件实例
|
|
104
|
+
* 停止适配器,断开并移除所有 Endpoint 实例
|
|
58
105
|
*/
|
|
59
106
|
stop(): Promise<void>;
|
|
60
107
|
}
|
|
61
108
|
export interface Adapters {
|
|
62
109
|
}
|
|
110
|
+
/** Per-adapter live Endpoint class map for HandlerContext.$endpoint() typing. */
|
|
111
|
+
export interface AdapterEndpoints {
|
|
112
|
+
}
|
|
63
113
|
export declare namespace Adapter {
|
|
64
114
|
type Factory<R extends Adapter = Adapter> = {
|
|
65
|
-
new (plugin: Plugin, name: string, config: Adapter.
|
|
115
|
+
new (plugin: Plugin, name: string, config: Adapter.EndpointConfig<Adapter.InferEndpoint<R>>[]): R;
|
|
66
116
|
};
|
|
67
117
|
interface Lifecycle {
|
|
68
118
|
'message.receive': [Message];
|
|
@@ -77,10 +127,10 @@ export declare namespace Adapter {
|
|
|
77
127
|
* 适配器工厂注册表
|
|
78
128
|
* 灵感来源于 zhinjs/next 的 Adapter.Registry
|
|
79
129
|
*/
|
|
80
|
-
const Registry: Map<string, Factory<Adapter<
|
|
81
|
-
type
|
|
82
|
-
type
|
|
83
|
-
type
|
|
130
|
+
const Registry: Map<string, Factory<Adapter<Endpoint, readonly EndpointCapability[]>>>;
|
|
131
|
+
type InferEndpoint<R extends Adapter = Adapter> = R extends Adapter<infer T> ? T : never;
|
|
132
|
+
type EndpointConfig<T extends Endpoint> = T extends Endpoint<infer R> ? R : never;
|
|
133
|
+
type EndpointMessage<T extends Endpoint> = T extends Endpoint<infer _L, infer R> ? R : never;
|
|
84
134
|
/**
|
|
85
135
|
* 注册适配器工厂
|
|
86
136
|
*
|
|
@@ -93,4 +143,3 @@ export declare namespace Adapter {
|
|
|
93
143
|
*/
|
|
94
144
|
function register(name: string, factory: Factory): void;
|
|
95
145
|
}
|
|
96
|
-
//# sourceMappingURL=adapter.d.ts.map
|