@zhin.js/core 1.5.16 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -195
- package/lib/ai-completion-contract.d.ts +135 -0
- package/lib/ai-completion-contract.js +69 -0
- package/lib/built/ai-access.d.ts +2 -21
- package/lib/built/ai-access.js +1 -46
- package/lib/built/ai-outbound/index.d.ts +0 -2
- package/lib/built/ai-outbound/index.js +0 -2
- package/lib/built/ai-outbound/prompt.d.ts +2 -0
- package/lib/built/ai-outbound/prompt.js +2 -0
- package/lib/built/ai-outbound/types.d.ts +1 -10
- package/lib/built/ai-trigger.d.ts +39 -78
- package/lib/built/ai-trigger.js +3 -254
- package/lib/built/common-adapter-tools.d.ts +21 -6
- package/lib/built/common-adapter-tools.js +28 -17
- package/lib/built/generic-segment-mapper.js +4 -1
- package/lib/built/html-segment-fallback.d.ts +6 -7
- package/lib/built/html-segment-fallback.js +1 -16
- package/lib/built/html-to-text.d.ts +0 -3
- package/lib/built/html-to-text.js +131 -40
- package/lib/built/interaction-messages.d.ts +1 -0
- package/lib/built/interaction-messages.js +30 -0
- package/lib/built/interactive-segments/action.d.ts +3 -4
- package/lib/built/interactive-segments/action.js +2 -5
- package/lib/built/interactive-segments/index.d.ts +0 -2
- package/lib/built/interactive-segments/index.js +0 -2
- package/lib/built/interactive-segments/keyboard-segment.d.ts +0 -1
- package/lib/built/interactive-segments/keyboard-segment.js +0 -1
- package/lib/built/interactive-segments/onebot-keyboard.d.ts +0 -1
- package/lib/built/interactive-segments/onebot-keyboard.js +0 -2
- package/lib/built/interactive-segments/resolve.d.ts +2 -3
- package/lib/built/interactive-segments/resolve.js +21 -14
- package/lib/built/interactive-segments/types.d.ts +2 -7
- package/lib/built/interactive-segments/types.js +22 -2
- package/lib/built/login-assist.d.ts +330 -25
- package/lib/built/login-assist.js +1156 -75
- package/lib/built/login-captcha.d.ts +62 -0
- package/lib/built/login-captcha.js +107 -0
- package/lib/built/message-enrich.d.ts +24 -27
- package/lib/built/message-enrich.js +53 -49
- package/lib/built/outbound-content-arrays.d.ts +4 -0
- package/lib/built/outbound-content-arrays.js +32 -0
- package/lib/built/outbound-media-trust.d.ts +46 -0
- package/lib/built/outbound-media-trust.js +245 -0
- package/lib/built/outbound-media-utils.d.ts +5 -3
- package/lib/built/outbound-media-utils.js +5 -3
- package/lib/built/readable-link.d.ts +4 -0
- package/lib/built/readable-link.js +32 -0
- package/lib/built/rich-segments/markdown-to-text.d.ts +1 -2
- package/lib/built/rich-segments/markdown-to-text.js +141 -17
- package/lib/built/roles.d.ts +141 -12
- package/lib/built/roles.js +253 -52
- package/lib/built/segment-contract/assert.js +8 -2
- package/lib/built/segment-contract/delivery.js +1 -0
- package/lib/built/segment-contract/index.d.ts +3 -3
- package/lib/built/segment-contract/index.js +2 -2
- package/lib/built/segment-contract/json-schema.d.ts +39 -5
- package/lib/built/segment-contract/json-schema.js +207 -24
- package/lib/built/segment-contract/preview.js +8 -1
- package/lib/built/segment-contract/text.js +1 -1
- package/lib/built/segment-contract/types.d.ts +2 -2
- package/lib/built/segment-contract/validate.d.ts +1553 -224
- package/lib/built/segment-contract/validate.js +39 -3
- package/lib/built/tool-access.d.ts +5 -0
- package/lib/built/tool-access.js +17 -0
- package/lib/built/user-interaction.d.ts +5 -4
- package/lib/built/user-interaction.js +64 -52
- package/lib/errors.d.ts +1 -18
- package/lib/errors.js +1 -26
- package/lib/feature/command-public-api.d.ts +5 -0
- package/lib/feature/command-public-api.js +5 -0
- package/lib/feature/command.d.ts +2 -0
- package/lib/feature/command.js +1 -0
- package/lib/feature/component.d.ts +1 -0
- package/lib/feature/component.js +1 -0
- package/lib/feature/handler.d.ts +13 -7
- package/lib/feature/handler.js +2 -1
- package/lib/feature/middleware-public-api.d.ts +6 -0
- package/lib/feature/middleware-public-api.js +6 -0
- package/lib/feature/middleware.d.ts +22 -2
- package/lib/feature/middleware.js +7 -2
- package/lib/im-scene.d.ts +4 -3
- package/lib/im-scene.js +9 -9
- package/lib/im-session-id.d.ts +20 -12
- package/lib/im-session-id.js +8 -8
- package/lib/index.d.ts +20 -48
- package/lib/index.js +15 -41
- package/lib/jsx/intrinsic-elements.d.ts +83 -0
- package/lib/jsx/message-renderer.d.ts +13 -0
- package/lib/jsx/message-renderer.js +128 -0
- package/lib/jsx/message-tags.d.ts +133 -0
- package/lib/jsx/message-tags.js +50 -0
- package/lib/jsx-dev-runtime.d.ts +2 -2
- package/lib/jsx-dev-runtime.js +1 -2
- package/lib/jsx-runtime.d.ts +2 -12
- package/lib/jsx-runtime.js +1 -10
- package/lib/jsx.d.ts +6 -30
- package/lib/jsx.js +3 -93
- package/lib/message.d.ts +0 -40
- package/lib/message.js +1 -27
- package/lib/models/system-log.d.ts +0 -2
- package/lib/models/system-log.js +1 -8
- package/lib/models/user.d.ts +0 -2
- package/lib/models/user.js +1 -7
- package/lib/notice.d.ts +38 -33
- package/lib/notice.js +23 -7
- package/lib/plugin-runtime/im/command-feedback.d.ts +59 -0
- package/lib/plugin-runtime/im/command-feedback.js +148 -0
- package/lib/plugin-runtime/im/contracts.d.ts +217 -32
- package/lib/plugin-runtime/im/contracts.js +141 -23
- package/lib/plugin-runtime/im/conversation-runtime.d.ts +42 -0
- package/lib/plugin-runtime/im/conversation-runtime.js +451 -0
- package/lib/plugin-runtime/im/endpoint-runtime.d.ts +112 -0
- package/lib/plugin-runtime/im/endpoint-runtime.js +434 -0
- package/lib/plugin-runtime/im/feature-gate.d.ts +21 -0
- package/lib/plugin-runtime/im/feature-gate.js +88 -0
- package/lib/plugin-runtime/im/host/component-host-installer.d.ts +2 -0
- package/lib/plugin-runtime/im/host/component-host-installer.js +14 -0
- package/lib/plugin-runtime/im/host/conversation-migration.d.ts +5 -0
- package/lib/plugin-runtime/im/host/conversation-migration.js +75 -0
- package/lib/plugin-runtime/im/host/database-config.d.ts +10 -0
- package/lib/plugin-runtime/im/host/database-config.js +152 -0
- package/lib/plugin-runtime/im/host/database-console-schema.d.ts +79 -0
- package/lib/plugin-runtime/im/host/database-console-schema.js +477 -0
- package/lib/plugin-runtime/im/host/database-console-sql.d.ts +66 -0
- package/lib/plugin-runtime/im/host/database-console-sql.js +459 -0
- package/lib/plugin-runtime/im/host/database-host-installer.d.ts +60 -0
- package/lib/plugin-runtime/im/host/database-host-installer.js +1166 -0
- package/lib/plugin-runtime/im/host/database-state.d.ts +9 -0
- package/lib/plugin-runtime/im/host/database-state.js +91 -0
- package/lib/plugin-runtime/im/host/index.d.ts +8 -0
- package/lib/plugin-runtime/im/host/index.js +8 -0
- package/lib/plugin-runtime/im/host/locale-host-installer.d.ts +3 -0
- package/lib/plugin-runtime/im/host/locale-host-installer.js +60 -0
- package/lib/plugin-runtime/im/host/outbound-host-installer.d.ts +8 -0
- package/lib/plugin-runtime/im/host/outbound-host-installer.js +153 -0
- package/lib/plugin-runtime/im/host/sender-enrichment.d.ts +34 -0
- package/lib/plugin-runtime/im/host/sender-enrichment.js +82 -0
- package/lib/plugin-runtime/im/im-runtime.d.ts +40 -111
- package/lib/plugin-runtime/im/im-runtime.js +235 -1059
- package/lib/plugin-runtime/im/inbound-dedup.d.ts +84 -0
- package/lib/plugin-runtime/im/inbound-dedup.js +322 -0
- package/lib/plugin-runtime/im/inbound-origin.d.ts +150 -0
- package/lib/plugin-runtime/im/inbound-origin.js +183 -0
- package/lib/plugin-runtime/im/inbound-runtime.d.ts +59 -0
- package/lib/plugin-runtime/im/inbound-runtime.js +478 -0
- package/lib/plugin-runtime/im/inbound-spine.d.ts +196 -0
- package/lib/plugin-runtime/im/inbound-spine.js +335 -0
- package/lib/plugin-runtime/im/index.d.ts +15 -4
- package/lib/plugin-runtime/im/index.js +11 -4
- package/lib/plugin-runtime/im/interaction-runtime.d.ts +50 -0
- package/lib/plugin-runtime/im/interaction-runtime.js +390 -0
- package/lib/plugin-runtime/im/interactive-router.d.ts +81 -0
- package/lib/plugin-runtime/im/interactive-router.js +382 -0
- package/lib/plugin-runtime/im/message-diagnostics.d.ts +70 -0
- package/lib/plugin-runtime/im/message-diagnostics.js +182 -0
- package/lib/plugin-runtime/im/message-dispatcher.d.ts +18 -4
- package/lib/plugin-runtime/im/message-dispatcher.js +138 -20
- package/lib/plugin-runtime/im/message-events.d.ts +85 -0
- package/lib/plugin-runtime/im/message-events.js +113 -0
- package/lib/plugin-runtime/im/outbound-delivery-runtime.d.ts +39 -0
- package/lib/plugin-runtime/im/outbound-delivery-runtime.js +450 -0
- package/lib/plugin-runtime/im/outbound-renderer.d.ts +52 -3
- package/lib/plugin-runtime/im/outbound-renderer.js +188 -8
- package/lib/plugin-runtime/im/outbound-segments.d.ts +29 -5
- package/lib/plugin-runtime/im/outbound-segments.js +130 -36
- package/lib/plugin-runtime/im/progressive-reply.d.ts +58 -0
- package/lib/plugin-runtime/im/progressive-reply.js +501 -0
- package/lib/plugin-runtime/im/public-api.d.ts +1 -1
- package/lib/request.d.ts +27 -36
- package/lib/request.js +14 -6
- package/lib/side-event/base.d.ts +64 -44
- package/lib/side-event/base.js +72 -19
- package/lib/side-event/index.d.ts +1 -1
- package/lib/side-event/index.js +1 -1
- package/lib/side-event/normalize.d.ts +7 -38
- package/lib/side-event/normalize.js +4 -109
- package/lib/side-event/scene-events.d.ts +40 -0
- package/lib/side-event/scene-events.js +147 -0
- package/lib/side-event/types.d.ts +4 -13
- package/lib/side-event/types.js +1 -55
- package/lib/system-event.d.ts +17 -12
- package/lib/system-event.js +8 -6
- package/lib/types.d.ts +23 -167
- package/lib/utils.d.ts +50 -33
- package/lib/utils.js +12 -185
- package/lib/venue/contracts.d.ts +21 -0
- package/lib/venue/contracts.js +3 -0
- package/lib/venue/floor-controller.d.ts +11 -0
- package/lib/venue/floor-controller.js +63 -0
- package/lib/venue/index.d.ts +13 -0
- package/lib/venue/index.js +11 -0
- package/lib/venue/membership-port.d.ts +23 -0
- package/lib/venue/membership-port.js +141 -0
- package/lib/venue/projector.d.ts +38 -0
- package/lib/venue/projector.js +45 -0
- package/lib/venue/registry.d.ts +16 -0
- package/lib/venue/registry.js +63 -0
- package/lib/venue/router.d.ts +19 -0
- package/lib/venue/router.js +101 -0
- package/lib/venue/send-limiter.d.ts +17 -0
- package/lib/venue/send-limiter.js +73 -0
- package/lib/venue/validator.d.ts +6 -0
- package/lib/venue/validator.js +160 -0
- package/package.json +24 -50
- package/lib/adapter.d.ts +0 -145
- package/lib/adapter.js +0 -377
- package/lib/built/adapter-process.d.ts +0 -58
- package/lib/built/adapter-process.js +0 -128
- package/lib/built/agent-preset.d.ts +0 -64
- package/lib/built/agent-preset.js +0 -79
- package/lib/built/ai-outbound/adapter-access.d.ts +0 -3
- package/lib/built/ai-outbound/adapter-access.js +0 -9
- package/lib/built/ai-outbound/extensions/qq-message.d.ts +0 -3
- package/lib/built/ai-outbound/extensions/qq-message.js +0 -23
- package/lib/built/authorization.d.ts +0 -10
- package/lib/built/authorization.js +0 -76
- package/lib/built/command.d.ts +0 -72
- package/lib/built/command.js +0 -105
- package/lib/built/component.d.ts +0 -67
- package/lib/built/component.js +0 -97
- package/lib/built/config.d.ts +0 -98
- package/lib/built/config.js +0 -372
- package/lib/built/connect-endpoint-instance.d.ts +0 -17
- package/lib/built/connect-endpoint-instance.js +0 -42
- package/lib/built/database.d.ts +0 -68
- package/lib/built/database.js +0 -106
- package/lib/built/dispatcher.d.ts +0 -141
- package/lib/built/dispatcher.js +0 -383
- package/lib/built/endpoint-commands.d.ts +0 -3
- package/lib/built/endpoint-commands.js +0 -99
- package/lib/built/endpoint-lifecycle-service.d.ts +0 -28
- package/lib/built/endpoint-lifecycle-service.js +0 -242
- package/lib/built/endpoint-lifecycle.d.ts +0 -27
- package/lib/built/endpoint-lifecycle.js +0 -36
- package/lib/built/endpoint-manager.d.ts +0 -34
- package/lib/built/html-renderer-loader.d.ts +0 -13
- package/lib/built/html-renderer-loader.js +0 -33
- package/lib/built/inbound-pipeline.d.ts +0 -37
- package/lib/built/inbound-pipeline.js +0 -63
- package/lib/built/inbound-runner.d.ts +0 -22
- package/lib/built/inbound-runner.js +0 -34
- package/lib/built/interactive-segment-contract.d.ts +0 -6
- package/lib/built/interactive-segment-contract.js +0 -9
- package/lib/built/interactive-segments/fallback-store.d.ts +0 -29
- package/lib/built/interactive-segments/fallback-store.js +0 -63
- package/lib/built/interactive-segments/handlers.d.ts +0 -16
- package/lib/built/interactive-segments/handlers.js +0 -74
- package/lib/built/introspection-format.d.ts +0 -10
- package/lib/built/introspection-format.js +0 -28
- package/lib/built/management-command-guard.d.ts +0 -15
- package/lib/built/management-command-guard.js +0 -25
- package/lib/built/message-filter.d.ts +0 -176
- package/lib/built/message-filter.js +0 -239
- package/lib/built/optional-peer-import.d.ts +0 -3
- package/lib/built/optional-peer-import.js +0 -33
- package/lib/built/outbound-media-contract.d.ts +0 -22
- package/lib/built/outbound-media-contract.js +0 -10
- package/lib/built/permission.d.ts +0 -51
- package/lib/built/permission.js +0 -99
- package/lib/built/permit-check.d.ts +0 -7
- package/lib/built/permit-check.js +0 -35
- package/lib/built/permit-parse.d.ts +0 -16
- package/lib/built/permit-parse.js +0 -32
- package/lib/built/platform-permit.d.ts +0 -20
- package/lib/built/platform-permit.js +0 -91
- package/lib/built/queue-im-field-contract.d.ts +0 -32
- package/lib/built/queue-im-field-contract.js +0 -67
- package/lib/built/rich-segments/adapter-policies.d.ts +0 -9
- package/lib/built/rich-segments/adapter-policies.js +0 -27
- package/lib/built/rich-segments/base.d.ts +0 -11
- package/lib/built/rich-segments/base.js +0 -24
- package/lib/built/rich-segments/builtins.d.ts +0 -4
- package/lib/built/rich-segments/builtins.js +0 -40
- package/lib/built/rich-segments/capabilities.d.ts +0 -6
- package/lib/built/rich-segments/capabilities.js +0 -38
- package/lib/built/rich-segments/html-segment.d.ts +0 -15
- package/lib/built/rich-segments/html-segment.js +0 -62
- package/lib/built/rich-segments/index.d.ts +0 -13
- package/lib/built/rich-segments/index.js +0 -13
- package/lib/built/rich-segments/markdown-segment.d.ts +0 -14
- package/lib/built/rich-segments/markdown-segment.js +0 -58
- package/lib/built/rich-segments/qrcode-segment.d.ts +0 -18
- package/lib/built/rich-segments/qrcode-segment.js +0 -73
- package/lib/built/rich-segments/registry.d.ts +0 -16
- package/lib/built/rich-segments/registry.js +0 -52
- package/lib/built/rich-segments/resolve.d.ts +0 -5
- package/lib/built/rich-segments/resolve.js +0 -87
- package/lib/built/rich-segments/tts-segment.d.ts +0 -13
- package/lib/built/rich-segments/tts-segment.js +0 -51
- package/lib/built/rich-segments/types.d.ts +0 -79
- package/lib/built/rich-segments/types.js +0 -17
- package/lib/built/runtime-io.d.ts +0 -9
- package/lib/built/runtime-io.js +0 -67
- package/lib/built/schedule.d.ts +0 -54
- package/lib/built/schedule.js +0 -112
- package/lib/built/schema-endpoint-manager.d.ts +0 -17
- package/lib/built/schema-endpoint-manager.js +0 -73
- package/lib/built/schema-feature.d.ts +0 -77
- package/lib/built/schema-feature.js +0 -130
- package/lib/built/skill.d.ts +0 -120
- package/lib/built/skill.js +0 -151
- package/lib/built/speech-loader.d.ts +0 -14
- package/lib/built/speech-loader.js +0 -32
- package/lib/built/tool.d.ts +0 -151
- package/lib/built/tool.js +0 -388
- package/lib/command.d.ts +0 -50
- package/lib/command.js +0 -106
- package/lib/component.d.ts +0 -26
- package/lib/component.js +0 -583
- package/lib/endpoint-capabilities.d.ts +0 -46
- package/lib/endpoint-capabilities.js +0 -55
- package/lib/endpoint.d.ts +0 -19
- package/lib/endpoint.js +0 -3
- package/lib/host-plugin-registry.d.ts +0 -8
- package/lib/host-plugin-registry.js +0 -12
- package/lib/plugin-context.d.ts +0 -27
- package/lib/plugin-context.js +0 -64
- package/lib/plugin-runtime/im/interactive.d.ts +0 -26
- package/lib/plugin-runtime/im/interactive.js +0 -46
- package/lib/plugin-runtime/im/login-assist-host.d.ts +0 -6
- package/lib/plugin-runtime/im/login-assist-host.js +0 -6
- package/lib/plugin-runtime/im/message-bus.d.ts +0 -38
- package/lib/plugin-runtime/im/message-bus.js +0 -40
- package/lib/plugin-runtime/im/service-tokens.d.ts +0 -18
- package/lib/plugin-runtime/im/service-tokens.js +0 -13
- package/lib/plugin.d.ts +0 -268
- package/lib/plugin.js +0 -583
- package/lib/schema-interaction.d.ts +0 -117
- package/lib/schema-interaction.js +0 -247
- package/lib/side-event/dispatch.d.ts +0 -15
- package/lib/side-event/dispatch.js +0 -140
- package/lib/tool-zod.d.ts +0 -43
- package/lib/tool-zod.js +0 -184
- /package/lib/{built/endpoint-manager.js → jsx/intrinsic-elements.js} +0 -0
package/lib/endpoint.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Adapters, Adapter } from './adapter.js';
|
|
2
|
-
import type { EndpointCapabilitiesConfig, FullEndpoint } from './endpoint-capabilities.js';
|
|
3
|
-
import type { EndpointWithControl, EndpointWithManagement } from '@zhin.js/adapter';
|
|
4
|
-
export type { EndpointChannel, EndpointChannelParent, EndpointFriend, EndpointGroup, EndpointManagement, EndpointWithManagement, EndpointManagementCapability, } from '@zhin.js/adapter';
|
|
5
|
-
export { endpointManagementCapabilityIds, listEndpointManagementCapabilities, resolveEndpointManagement, } from '@zhin.js/adapter';
|
|
6
|
-
export type { EndpointControl, EndpointWithControl } from '@zhin.js/adapter';
|
|
7
|
-
export { endpointControlOf } from '@zhin.js/adapter';
|
|
8
|
-
export type { EndpointCapability, EndpointCapabilitiesConfig, InboundEndpoint, OutboundEndpoint, FullEndpoint, CapableEndpoint, } from './endpoint-capabilities.js';
|
|
9
|
-
export { DEFAULT_ENDPOINT_CAPABILITIES, OutboundNotSupportedError, InboundNotSupportedError, resolveEndpointCapabilities, registerEndpointCapabilities, getEndpointCapabilities, getAdapterCapabilities, hasInbound, hasOutbound, assertInbound, assertOutbound, } from './endpoint-capabilities.js';
|
|
10
|
-
/**
|
|
11
|
-
* Endpoint 接口:全双工平台机器人(入站 + 出站)。
|
|
12
|
-
* 纯入站 / 纯出站请实现 InboundEndpoint / OutboundEndpoint。
|
|
13
|
-
*/
|
|
14
|
-
export type Endpoint<Config extends object = object, Event extends object = object> = FullEndpoint<Config, Event> & EndpointWithManagement & EndpointWithControl;
|
|
15
|
-
export declare namespace Endpoint {
|
|
16
|
-
type Config<K extends keyof Adapters = keyof Adapters> = Adapter.EndpointConfig<Adapter.InferEndpoint<Adapters[K]>> & EndpointCapabilitiesConfig & {
|
|
17
|
-
context: K;
|
|
18
|
-
};
|
|
19
|
-
}
|
package/lib/endpoint.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { endpointManagementCapabilityIds, listEndpointManagementCapabilities, resolveEndpointManagement, } from '@zhin.js/adapter';
|
|
2
|
-
export { endpointControlOf } from '@zhin.js/adapter';
|
|
3
|
-
export { DEFAULT_ENDPOINT_CAPABILITIES, OutboundNotSupportedError, InboundNotSupportedError, resolveEndpointCapabilities, registerEndpointCapabilities, getEndpointCapabilities, getAdapterCapabilities, hasInbound, hasOutbound, assertInbound, assertOutbound, } from './endpoint-capabilities.js';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated **已删除**。全局根插件注册表已移除;服务通过 Scope+Token 提供。
|
|
3
|
-
* 保留 no-op 签名供编译期过渡。
|
|
4
|
-
*/
|
|
5
|
-
/** @deprecated 已删除——不做任何事。 */
|
|
6
|
-
export declare function setHostRootPlugin(_plugin: unknown): void;
|
|
7
|
-
/** @deprecated 已删除——总是返回 null。 */
|
|
8
|
-
export declare function getHostRootPlugin(): null;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated **已删除**。全局根插件注册表已移除;服务通过 Scope+Token 提供。
|
|
3
|
-
* 保留 no-op 签名供编译期过渡。
|
|
4
|
-
*/
|
|
5
|
-
/** @deprecated 已删除——不做任何事。 */
|
|
6
|
-
export function setHostRootPlugin(_plugin) {
|
|
7
|
-
// no-op: legacy host root plugin registry has been removed
|
|
8
|
-
}
|
|
9
|
-
/** @deprecated 已删除——总是返回 null。 */
|
|
10
|
-
export function getHostRootPlugin() {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
package/lib/plugin-context.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin 上下文管理 — AsyncLocalStorage + getPlugin
|
|
3
|
-
*
|
|
4
|
-
* 从 plugin.ts 提取的独立关注点,消除与 Plugin 类的循环依赖。
|
|
5
|
-
* usePlugin() 保留在 plugin.ts(需要 Plugin 构造函数)。
|
|
6
|
-
*/
|
|
7
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
|
-
import type { Plugin } from "./plugin.js";
|
|
9
|
-
export declare const storage: AsyncLocalStorage<Plugin>;
|
|
10
|
-
/**
|
|
11
|
-
* Plugin Runtime (`zhin runtime start`) 启动时调用。
|
|
12
|
-
* 标记后 getPlugin()/usePlugin() 在 ALS 为空时抛出更明确的迁移提示,
|
|
13
|
-
* 而非通用的 "must be called within a plugin context"。
|
|
14
|
-
*/
|
|
15
|
-
export declare function markPluginRuntimeActive(): void;
|
|
16
|
-
export declare function isPluginRuntimeActive(): boolean;
|
|
17
|
-
/** 测试重置 */
|
|
18
|
-
export declare function resetPluginRuntimeFlag(): void;
|
|
19
|
-
/**
|
|
20
|
-
* 获取当前文件路径(调用者)
|
|
21
|
-
*/
|
|
22
|
-
export declare function getCurrentFile(metaUrl?: string): string;
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated **已删除**。请使用 `definePlugin` + 约定目录;运行时通过 Scope+Token 访问服务。
|
|
25
|
-
* @throws 总是抛出——仅保留签名供编译期过渡。
|
|
26
|
-
*/
|
|
27
|
-
export declare function getPlugin(): Plugin;
|
package/lib/plugin-context.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin 上下文管理 — AsyncLocalStorage + getPlugin
|
|
3
|
-
*
|
|
4
|
-
* 从 plugin.ts 提取的独立关注点,消除与 Plugin 类的循环依赖。
|
|
5
|
-
* usePlugin() 保留在 plugin.ts(需要 Plugin 构造函数)。
|
|
6
|
-
*/
|
|
7
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
|
-
import * as path from "node:path";
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
-
// ============================================================================
|
|
11
|
-
// AsyncLocalStorage 上下文
|
|
12
|
-
// ============================================================================
|
|
13
|
-
export const storage = new AsyncLocalStorage();
|
|
14
|
-
let _pluginRuntimeActive = false;
|
|
15
|
-
/**
|
|
16
|
-
* Plugin Runtime (`zhin runtime start`) 启动时调用。
|
|
17
|
-
* 标记后 getPlugin()/usePlugin() 在 ALS 为空时抛出更明确的迁移提示,
|
|
18
|
-
* 而非通用的 "must be called within a plugin context"。
|
|
19
|
-
*/
|
|
20
|
-
export function markPluginRuntimeActive() {
|
|
21
|
-
_pluginRuntimeActive = true;
|
|
22
|
-
}
|
|
23
|
-
export function isPluginRuntimeActive() {
|
|
24
|
-
return _pluginRuntimeActive;
|
|
25
|
-
}
|
|
26
|
-
/** 测试重置 */
|
|
27
|
-
export function resetPluginRuntimeFlag() {
|
|
28
|
-
_pluginRuntimeActive = false;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* 获取当前文件路径(调用者)
|
|
32
|
-
*/
|
|
33
|
-
export function getCurrentFile(metaUrl = import.meta.url) {
|
|
34
|
-
if (typeof metaUrl !== "string" || metaUrl.length === 0) {
|
|
35
|
-
return path.join(process.cwd(), "__zhin_edge_bootstrap__.mjs");
|
|
36
|
-
}
|
|
37
|
-
const previousPrepareStackTrace = Error.prepareStackTrace;
|
|
38
|
-
Error.prepareStackTrace = function (_, stack) {
|
|
39
|
-
return stack;
|
|
40
|
-
};
|
|
41
|
-
const stack = new Error().stack;
|
|
42
|
-
Error.prepareStackTrace = previousPrepareStackTrace;
|
|
43
|
-
const stackFiles = Array.from(new Set(stack.map((site) => site.getFileName())));
|
|
44
|
-
const idx = stackFiles.findIndex((f) => (metaUrl.startsWith('file://') ? f === fileURLToPath(metaUrl) : false) || f === metaUrl);
|
|
45
|
-
const result = stackFiles[idx + 1];
|
|
46
|
-
if (!result) {
|
|
47
|
-
return path.join(process.cwd(), "__zhin_edge_bootstrap__.mjs");
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
return fileURLToPath(result);
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated **已删除**。请使用 `definePlugin` + 约定目录;运行时通过 Scope+Token 访问服务。
|
|
58
|
-
* @throws 总是抛出——仅保留签名供编译期过渡。
|
|
59
|
-
*/
|
|
60
|
-
export function getPlugin() {
|
|
61
|
-
throw new Error('getPlugin() has been removed. Use `definePlugin` + convention directories, '
|
|
62
|
-
+ 'and access services via Scope+Token. '
|
|
63
|
-
+ 'See docs/contributing/public-api-surface.md');
|
|
64
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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;
|
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
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>;
|
|
@@ -1,38 +0,0 @@
|
|
|
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>;
|
|
@@ -1,40 +0,0 @@
|
|
|
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');
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core service tokens — typed Token 替代 legacy string-based inject('x')。
|
|
3
|
-
*
|
|
4
|
-
* Slice 2:Token 指向当前 Feature 实例(双写窗口)。
|
|
5
|
-
* Slice 4:Feature 删除后,Token 类型改为 Runtime projection 接口。
|
|
6
|
-
*/
|
|
7
|
-
import type { CommandFeature } from '../../built/command.js';
|
|
8
|
-
import type { ComponentFeature } from '../../built/component.js';
|
|
9
|
-
import type { ScheduleFeature } from '../../built/schedule.js';
|
|
10
|
-
import type { ConfigFeature } from '../../built/config.js';
|
|
11
|
-
import type { SchemaFeature } from '../../built/schema-feature.js';
|
|
12
|
-
import type { MessageDispatcherService } from '../../built/dispatcher.js';
|
|
13
|
-
export declare const commandServiceToken: import("@zhin.js/plugin-runtime").Token<CommandFeature>;
|
|
14
|
-
export declare const componentServiceToken: import("@zhin.js/plugin-runtime").Token<ComponentFeature>;
|
|
15
|
-
export declare const schedulerServiceToken: import("@zhin.js/plugin-runtime").Token<ScheduleFeature>;
|
|
16
|
-
export declare const configServiceToken: import("@zhin.js/plugin-runtime").Token<ConfigFeature>;
|
|
17
|
-
export declare const schemaServiceToken: import("@zhin.js/plugin-runtime").Token<SchemaFeature>;
|
|
18
|
-
export declare const dispatcherServiceToken: import("@zhin.js/plugin-runtime").Token<MessageDispatcherService>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core service tokens — typed Token 替代 legacy string-based inject('x')。
|
|
3
|
-
*
|
|
4
|
-
* Slice 2:Token 指向当前 Feature 实例(双写窗口)。
|
|
5
|
-
* Slice 4:Feature 删除后,Token 类型改为 Runtime projection 接口。
|
|
6
|
-
*/
|
|
7
|
-
import { createToken } from '@zhin.js/plugin-runtime';
|
|
8
|
-
export const commandServiceToken = createToken('zhin.im.command-service');
|
|
9
|
-
export const componentServiceToken = createToken('zhin.im.component-service');
|
|
10
|
-
export const schedulerServiceToken = createToken('zhin.im.scheduler-service');
|
|
11
|
-
export const configServiceToken = createToken('zhin.im.config-service');
|
|
12
|
-
export const schemaServiceToken = createToken('zhin.im.schema-service');
|
|
13
|
-
export const dispatcherServiceToken = createToken('zhin.im.dispatcher-service');
|
package/lib/plugin.d.ts
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin 类 — IM 特化插件,继承 PluginBase
|
|
3
|
-
*
|
|
4
|
-
* 在 PluginBase 的 DI/生命周期/事件基础上增加:
|
|
5
|
-
* - Context 类型安全(Plugin.Contexts 映射)
|
|
6
|
-
* - 生命周期事件类型安全(Plugin.Lifecycle)
|
|
7
|
-
* - 中间件系统、适配器管理、useContext 等
|
|
8
|
-
*/
|
|
9
|
-
import { MessageMiddleware, RegisteredAdapter, MaybePromise, ArrayItem, SendOptions, MessageSendPayload, type PluginManifest } from './types.js';
|
|
10
|
-
import type { InteractiveHandler } from "./built/interactive-segments/types.js";
|
|
11
|
-
import { Adapter, Adapters } from "./adapter.js";
|
|
12
|
-
import { PluginBase, PluginBaseLifecycle, type PluginLike } from '@zhin.js/kernel';
|
|
13
|
-
export { getPlugin, markPluginRuntimeActive, isPluginRuntimeActive, resetPluginRuntimeFlag } from "./plugin-context.js";
|
|
14
|
-
export { storage, getCurrentFile } from "./plugin-context.js";
|
|
15
|
-
export { setHostRootPlugin, getHostRootPlugin } from "./host-plugin-registry.js";
|
|
16
|
-
declare const contextsKey: unique symbol;
|
|
17
|
-
export type SideEffect<A extends (keyof Plugin.Contexts)[]> = {
|
|
18
|
-
(...args: ContextList<A>): MaybePromise<void | DisposeFn<ContextList<A>>>;
|
|
19
|
-
finished?: boolean;
|
|
20
|
-
};
|
|
21
|
-
export type DisposeFn<A> = (context: ArrayItem<A>) => MaybePromise<void>;
|
|
22
|
-
export type ContextList<CS extends (keyof Plugin.Contexts)[]> = CS extends [infer L, ...infer R] ? R extends (keyof Plugin.Contexts)[] ? [ContextItem<L>, ...ContextList<R>] : never[] : never[];
|
|
23
|
-
type ContextItem<L> = L extends keyof Plugin.Contexts ? Plugin.Contexts[L] : never;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated **已删除**。请使用 `definePlugin` + 约定目录(`zhin runtime start`)。
|
|
26
|
-
* @throws 总是抛出——仅保留签名供编译期过渡。
|
|
27
|
-
*/
|
|
28
|
-
export declare function usePlugin(): Plugin;
|
|
29
|
-
export interface Plugin extends Plugin.Extensions {
|
|
30
|
-
on<K extends keyof Plugin.Lifecycle>(name: K, listener: (...args: Plugin.Lifecycle[K]) => void): this;
|
|
31
|
-
on(name: string | symbol, listener: (...args: any[]) => void): this;
|
|
32
|
-
off<K extends keyof Plugin.Lifecycle>(name: K, listener: (...args: Plugin.Lifecycle[K]) => void): this;
|
|
33
|
-
off(name: string | symbol, listener: (...args: any[]) => void): this;
|
|
34
|
-
once<K extends keyof Plugin.Lifecycle>(name: K, listener: (...args: Plugin.Lifecycle[K]) => void): this;
|
|
35
|
-
once(name: string | symbol, listener: (...args: any[]) => void): this;
|
|
36
|
-
emit<K extends keyof Plugin.Lifecycle>(name: K, ...args: Plugin.Lifecycle[K]): boolean;
|
|
37
|
-
emit(name: string | symbol, ...args: any[]): boolean;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Plugin 类 - IM 特化插件,继承 PluginBase
|
|
41
|
-
*
|
|
42
|
-
* 类型窄化:
|
|
43
|
-
* - children: Plugin[] (而非 PluginBase[])
|
|
44
|
-
* - parent: Plugin | undefined
|
|
45
|
-
* - root: Plugin
|
|
46
|
-
* - $contexts: Map<string, Context<any>>
|
|
47
|
-
* - dispatch/broadcast: Plugin.Lifecycle 类型安全
|
|
48
|
-
*/
|
|
49
|
-
export declare class Plugin extends PluginBase implements PluginLike {
|
|
50
|
-
#private;
|
|
51
|
-
static [contextsKey]: string[];
|
|
52
|
-
adapters: (keyof Plugin.Contexts)[];
|
|
53
|
-
started: boolean;
|
|
54
|
-
get root(): Plugin;
|
|
55
|
-
get middleware(): MessageMiddleware<RegisteredAdapter>;
|
|
56
|
-
/**
|
|
57
|
-
* 构造函数
|
|
58
|
-
*/
|
|
59
|
-
constructor(filePath?: string, parent?: Plugin);
|
|
60
|
-
/**
|
|
61
|
-
* 添加中间件
|
|
62
|
-
* 中间件用于处理消息流转
|
|
63
|
-
*/
|
|
64
|
-
addMiddleware<T extends RegisteredAdapter>(middleware: MessageMiddleware<T>, name?: string): () => void;
|
|
65
|
-
/**
|
|
66
|
-
* 注册交互式 action 回调处理器(自动安装根中间件,优先于 Dispatcher)
|
|
67
|
-
*/
|
|
68
|
-
registerInteractiveHandler(prefix: string, handler: InteractiveHandler): () => void;
|
|
69
|
-
/**
|
|
70
|
-
* 插件名称
|
|
71
|
-
*/
|
|
72
|
-
get name(): string;
|
|
73
|
-
/**
|
|
74
|
-
* 插件清单(从 plugin.yml 或 package.json 延迟读取)
|
|
75
|
-
*/
|
|
76
|
-
get manifest(): PluginManifest | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* 上下文收集 — 使用类型窄化的 inject 替代直接 Map 访问
|
|
79
|
-
*/
|
|
80
|
-
useContext<T extends (keyof Plugin.Contexts)[]>(...args: [...T, SideEffect<T>]): void;
|
|
81
|
-
inject<T extends keyof Plugin.Contexts>(name: T): Plugin.Contexts[T] | undefined;
|
|
82
|
-
inject(name: string): unknown;
|
|
83
|
-
injectAdapter(name: string): Adapter | undefined;
|
|
84
|
-
contextIsReady<T extends keyof Plugin.Contexts>(name: T): boolean;
|
|
85
|
-
/**
|
|
86
|
-
* 启动插件
|
|
87
|
-
* 覆盖 PluginBase.start() 以支持 Context 挂载失败回滚
|
|
88
|
-
*/
|
|
89
|
-
start(t?: number): Promise<void>;
|
|
90
|
-
/**
|
|
91
|
-
* 覆盖 mountAllContexts:支持部分失败回滚
|
|
92
|
-
*/
|
|
93
|
-
protected mountAllContexts(): Promise<void>;
|
|
94
|
-
/**
|
|
95
|
-
* 获取插件提供的功能
|
|
96
|
-
* 从各个服务中获取数据
|
|
97
|
-
*/
|
|
98
|
-
get features(): Plugin.Features;
|
|
99
|
-
/**
|
|
100
|
-
* 获取插件功能摘要(数组形式)
|
|
101
|
-
* 返回各功能类型的名称和数量
|
|
102
|
-
*/
|
|
103
|
-
getFeatures(): Array<{
|
|
104
|
-
name: string;
|
|
105
|
-
count: number;
|
|
106
|
-
}>;
|
|
107
|
-
info(): Record<string, any>;
|
|
108
|
-
/**
|
|
109
|
-
* 停止插件
|
|
110
|
-
* 委托 PluginBase.stop() 处理通用清理,仅补充 IM 特化逻辑
|
|
111
|
-
*/
|
|
112
|
-
stop(): Promise<void>;
|
|
113
|
-
onMounted(callback: () => void | Promise<void>): void;
|
|
114
|
-
/**
|
|
115
|
-
* dispatch - 向上冒泡到父插件,或者在根节点广播(类型安全版本)
|
|
116
|
-
*/
|
|
117
|
-
dispatch<K extends keyof Plugin.Lifecycle>(name: K, ...args: Plugin.Lifecycle[K]): Promise<void>;
|
|
118
|
-
/**
|
|
119
|
-
* broadcast - 向下广播到所有子插件(类型安全版本)
|
|
120
|
-
*/
|
|
121
|
-
broadcast<K extends keyof Plugin.Lifecycle>(name: K, ...args: Plugin.Lifecycle[K]): Promise<void>;
|
|
122
|
-
/**
|
|
123
|
-
* 注册上下文(类型安全版本)
|
|
124
|
-
*/
|
|
125
|
-
provide(target: any): this;
|
|
126
|
-
/**
|
|
127
|
-
* 导入插件(Plugin 类型窄化版本)
|
|
128
|
-
*/
|
|
129
|
-
import(entry: string, t?: number): Promise<Plugin>;
|
|
130
|
-
/**
|
|
131
|
-
* 重载插件(Plugin 类型窄化版本)
|
|
132
|
-
*/
|
|
133
|
-
reload(plugin?: PluginBase): Promise<void>;
|
|
134
|
-
/**
|
|
135
|
-
* 监听文件变化(Plugin 类型窄化版本)
|
|
136
|
-
*/
|
|
137
|
-
watch(callback: (p: PluginBase) => void | Promise<void>, recursive?: boolean): void;
|
|
138
|
-
/**
|
|
139
|
-
* 自动绑定核心方法(只在构造函数中调用一次)
|
|
140
|
-
*/
|
|
141
|
-
$bindMethods(): void;
|
|
142
|
-
/**
|
|
143
|
-
* 创建插件实例(异步加载)
|
|
144
|
-
*/
|
|
145
|
-
static create(entry: string, parent?: Plugin): Promise<Plugin>;
|
|
146
|
-
}
|
|
147
|
-
export declare function defineContext<T extends keyof Plugin.Contexts, E extends Partial<Plugin.Extensions> = {}>(options: Context<T, E>): Context<T, E>;
|
|
148
|
-
export interface Context<T extends keyof Plugin.Contexts = keyof Plugin.Contexts, E extends Partial<Plugin.Extensions> = {}> {
|
|
149
|
-
name: T;
|
|
150
|
-
description: string;
|
|
151
|
-
value?: Plugin.Contexts[T];
|
|
152
|
-
mounted?: (parent: Plugin) => Plugin.Contexts[T] | Promise<Plugin.Contexts[T]>;
|
|
153
|
-
dispose?: (value: Plugin.Contexts[T]) => void;
|
|
154
|
-
/** 扩展方法,会自动挂载到 Plugin.prototype 上 */
|
|
155
|
-
extensions?: E;
|
|
156
|
-
}
|
|
157
|
-
export declare namespace Plugin {
|
|
158
|
-
/**
|
|
159
|
-
* 插件提供的功能
|
|
160
|
-
*/
|
|
161
|
-
interface Features {
|
|
162
|
-
commands: string[];
|
|
163
|
-
components: string[];
|
|
164
|
-
schedules: string[];
|
|
165
|
-
middlewares: string[];
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* 生命周期事件
|
|
169
|
-
*
|
|
170
|
-
* 必须包含索引签名以满足 PluginBaseLifecycle 结构子类型约束。
|
|
171
|
-
*/
|
|
172
|
-
interface Lifecycle extends PluginBaseLifecycle {
|
|
173
|
-
"before-mount": [Plugin];
|
|
174
|
-
"before-dispose": [Plugin];
|
|
175
|
-
"context.mounted": [keyof Plugin.Contexts];
|
|
176
|
-
"context.dispose": [keyof Plugin.Contexts];
|
|
177
|
-
"call.recallMessage": [string, string, string];
|
|
178
|
-
'before.sendMessage': [SendOptions];
|
|
179
|
-
'message.send': [MessageSendPayload];
|
|
180
|
-
"message.receive": [import('./message.js').Message];
|
|
181
|
-
"endpoint.login.pending": [import('./built/login-assist.js').PendingLoginTask];
|
|
182
|
-
"endpoint.login.expired": [import('./built/login-assist.js').PendingLoginTask];
|
|
183
|
-
'endpoint.connect': [import('./built/endpoint-lifecycle.js').EndpointLifecyclePayload];
|
|
184
|
-
'endpoint.disconnect': [import('./built/endpoint-lifecycle.js').EndpointLifecyclePayload];
|
|
185
|
-
'endpoint.error': [import('./built/endpoint-lifecycle.js').EndpointLifecyclePayload];
|
|
186
|
-
"request.receive": [import('./request.js').Request];
|
|
187
|
-
"notice.receive": [import('./notice.js').Notice];
|
|
188
|
-
"system.receive": [import('./system-event.js').SystemEvent];
|
|
189
|
-
"ai.processing.start": [Plugin.AIEventPayload];
|
|
190
|
-
"ai.processing.finish": [Plugin.AIEventPayload];
|
|
191
|
-
"ai.processing.error": [Plugin.AIEventPayload];
|
|
192
|
-
"ai.agent.start": [Plugin.AIEventPayload];
|
|
193
|
-
"ai.agent.finish": [Plugin.AIEventPayload];
|
|
194
|
-
"ai.thinking": [Plugin.AIEventPayload];
|
|
195
|
-
"ai.tool.call": [Plugin.AIEventPayload];
|
|
196
|
-
"ai.tool.result": [Plugin.AIEventPayload];
|
|
197
|
-
"ai.response": [Plugin.AIEventPayload];
|
|
198
|
-
"ai.typing.start": [Plugin.AIEventPayload];
|
|
199
|
-
"ai.typing.stop": [Plugin.AIEventPayload];
|
|
200
|
-
"ai.activity.queued.start": [Plugin.AIEventPayload];
|
|
201
|
-
"ai.activity.queued.clear": [Plugin.AIEventPayload];
|
|
202
|
-
"ai.subagent.spawn": [Plugin.AIEventPayload];
|
|
203
|
-
"ai.subagent.start": [Plugin.AIEventPayload];
|
|
204
|
-
"ai.subagent.finish": [Plugin.AIEventPayload];
|
|
205
|
-
"ai.deferred.start": [Plugin.AIEventPayload];
|
|
206
|
-
"ai.deferred.finish": [Plugin.AIEventPayload];
|
|
207
|
-
"ai.mcp.connect.start": [Plugin.AIEventPayload];
|
|
208
|
-
"ai.mcp.connect.finish": [Plugin.AIEventPayload];
|
|
209
|
-
"ai.mcp.connect.error": [Plugin.AIEventPayload];
|
|
210
|
-
"ai.session.new": [Plugin.AIEventPayload];
|
|
211
|
-
"ai.session.compact": [Plugin.AIEventPayload];
|
|
212
|
-
"ai.hook": [Plugin.AIEventPayload];
|
|
213
|
-
"schedule.start": [Plugin.AIEventPayload];
|
|
214
|
-
"schedule.finish": [Plugin.AIEventPayload];
|
|
215
|
-
"schedule.error": [Plugin.AIEventPayload];
|
|
216
|
-
}
|
|
217
|
-
interface AIEventPayload {
|
|
218
|
-
sessionId: string;
|
|
219
|
-
source: 'zhin-agent' | 'subagent' | 'ai-hook' | 'orchestrator-hook';
|
|
220
|
-
mode?: 'text' | 'multimodal';
|
|
221
|
-
path?: 'chat' | 'fast' | 'agent' | 'multimodal' | 'rate_limited';
|
|
222
|
-
userId?: string;
|
|
223
|
-
platform?: string;
|
|
224
|
-
endpointKey?: string;
|
|
225
|
-
sceneId?: string;
|
|
226
|
-
messageId?: string;
|
|
227
|
-
scope?: string;
|
|
228
|
-
content?: string;
|
|
229
|
-
reply?: string;
|
|
230
|
-
thinking?: string;
|
|
231
|
-
toolName?: string;
|
|
232
|
-
args?: Record<string, unknown>;
|
|
233
|
-
result?: unknown;
|
|
234
|
-
error?: string;
|
|
235
|
-
model?: string;
|
|
236
|
-
iterations?: number;
|
|
237
|
-
reason?: string;
|
|
238
|
-
taskId?: string;
|
|
239
|
-
label?: string;
|
|
240
|
-
status?: 'ok' | 'partial' | 'error';
|
|
241
|
-
serverName?: string;
|
|
242
|
-
loadedToolNames?: string[];
|
|
243
|
-
hookType?: string;
|
|
244
|
-
hookAction?: string;
|
|
245
|
-
hookContext?: Record<string, unknown>;
|
|
246
|
-
messages?: string[];
|
|
247
|
-
agentId?: string;
|
|
248
|
-
compactedCount?: number;
|
|
249
|
-
savedTokens?: number;
|
|
250
|
-
totalTokensBefore?: number;
|
|
251
|
-
totalTokensAfter?: number;
|
|
252
|
-
/** 为 true 时 processing.finish 不撤回 typing(route 子 agent → 主 agent 摘要续接) */
|
|
253
|
-
keepTyping?: boolean;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* 服务类型扩展点
|
|
257
|
-
* 各个 Context 通过 declare module 扩展此接口
|
|
258
|
-
*/
|
|
259
|
-
interface Contexts extends Adapters {
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Service 扩展方法类型
|
|
263
|
-
* 这些方法由各个 Context 的 extensions 提供
|
|
264
|
-
* 在 Plugin.start() 时自动注册到 Plugin.prototype
|
|
265
|
-
*/
|
|
266
|
-
interface Extensions {
|
|
267
|
-
}
|
|
268
|
-
}
|