@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
package/lib/index.d.ts
CHANGED
|
@@ -1,26 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Canonical IM messages, Endpoints, rendering, and plugin-facing core types.
|
|
3
|
+
* @module @zhin.js/core
|
|
4
|
+
*/
|
|
5
|
+
export * from './endpoint.js';
|
|
6
|
+
export * from './endpoint-capabilities.js';
|
|
2
7
|
export * from './plugin.js';
|
|
3
8
|
export * from './command.js';
|
|
4
9
|
export * from './component.js';
|
|
5
10
|
export * from './adapter.js';
|
|
6
11
|
export * from './message.js';
|
|
7
|
-
export
|
|
8
|
-
export { htmlToPlainText, htmlToPlainTextWithBlockBreaks, htmlToFallbackText } from './built/html-to-text.js';
|
|
9
|
-
export { registerHtmlSegmentFallback, coerceHtmlSegmentsToText } from './built/html-segment-fallback.js';
|
|
10
|
-
export { AGENT_MESH_TOOL_NAMES, setAgentMeshToolsRegistrar, applyAgentMeshTools, } from './built/mcp-mesh-registrar.js';
|
|
11
|
-
export { prependQuoteContext, resolveQuotedMessagePayload, resolveQuoteContextBlock, buildUserTurnWithQuoteContext, formatQuoteContextBlock, QUOTED_MESSAGE_CONTEXT_MARKER, CURRENT_USER_MESSAGE_MARKER, QUOTE_CONTEXT_SYSTEM_HINT, QUOTE_CONTEXT_SYSTEM_EXTRA_KEY, QUOTE_CONTEXT_BLOCK_EXTRA_KEY, QUOTED_CONTENT_UNTRUSTED_NOTE, sanitizeQuotedBodyForPrompt, } from './built/prepend-quote-context.js';
|
|
12
|
+
export * from './im-scene.js';
|
|
12
13
|
export * from './notice.js';
|
|
13
14
|
export * from './request.js';
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
15
|
+
export * from './system-event.js';
|
|
16
|
+
export * from './side-event/index.js';
|
|
17
|
+
export * from './schema-interaction.js';
|
|
18
|
+
export type * from '@zhin.js/interaction';
|
|
19
|
+
export * from './types.js';
|
|
20
|
+
export * from './utils.js';
|
|
21
|
+
export * from './errors.js';
|
|
17
22
|
export * from './built/config.js';
|
|
18
23
|
export * from './built/command.js';
|
|
19
|
-
export * from './built/
|
|
20
|
-
export
|
|
21
|
-
export * from './
|
|
22
|
-
export
|
|
23
|
-
export * from './built/
|
|
24
|
+
export * from './built/schedule.js';
|
|
25
|
+
export type { ScheduleDescriptor, ScheduleHandle, ScheduleContextExtensions } from './built/schedule.js';
|
|
26
|
+
export * from './models/system-log.js';
|
|
27
|
+
export * from './models/user.js';
|
|
28
|
+
export * from './built/permit-parse.js';
|
|
29
|
+
export * from './built/permit-check.js';
|
|
30
|
+
export * from './built/platform-permit.js';
|
|
31
|
+
export * from './built/authorization.js';
|
|
32
|
+
export * from './built/message-enrich.js';
|
|
33
|
+
export type { AgentTurnMessage, SyntheticMessageInput } from './built/message-enrich.js';
|
|
34
|
+
export * from './built/runtime-io.js';
|
|
24
35
|
export * from './built/database.js';
|
|
25
36
|
export * from './built/message-filter.js';
|
|
26
37
|
export * from './built/tool.js';
|
|
@@ -28,22 +39,45 @@ export * from './built/skill.js';
|
|
|
28
39
|
export * from './built/agent-preset.js';
|
|
29
40
|
export * from './built/common-adapter-tools.js';
|
|
30
41
|
export * from './built/roles.js';
|
|
42
|
+
export * from './im-session-id.js';
|
|
31
43
|
export * from './built/ai-trigger.js';
|
|
44
|
+
export * from './built/ai-access.js';
|
|
32
45
|
export * from './built/dispatcher.js';
|
|
33
|
-
export { runInboundMessage } from './built/inbound-runner.js';
|
|
34
|
-
export type { RunInboundMessageOptions, InboundRunResult } from './built/inbound-runner.js';
|
|
35
46
|
export * from './built/schema-feature.js';
|
|
36
47
|
export * from './built/login-assist.js';
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export * from './
|
|
40
|
-
export * from './
|
|
41
|
-
export * from './
|
|
42
|
-
export
|
|
48
|
+
export * from './built/generated-qrcode.js';
|
|
49
|
+
export * from './built/rich-segments/index.js';
|
|
50
|
+
export * from './built/interactive-segments/index.js';
|
|
51
|
+
export * from './built/user-interaction.js';
|
|
52
|
+
export * from './built/ai-outbound/index.js';
|
|
53
|
+
export { loadHtmlRenderer, seedHtmlRenderer, HTML_RENDERER_PACKAGE } from './built/html-renderer-loader.js';
|
|
54
|
+
export { loadSpeechPipeline, seedSpeechPipeline, SPEECH_PACKAGE } from './built/speech-loader.js';
|
|
55
|
+
export * from './built/outbound-media-utils.js';
|
|
56
|
+
export * from './built/outbound-media-contract.js';
|
|
57
|
+
export * from './built/interactive-segment-contract.js';
|
|
58
|
+
export * from './built/segment-contract/index.js';
|
|
59
|
+
export type { SegmentMediaRef } from './built/segment-contract/media.js';
|
|
60
|
+
export * from './built/generic-segment-mapper.js';
|
|
61
|
+
export * from './built/adapter-process.js';
|
|
62
|
+
export * from './built/component.js';
|
|
63
|
+
export * from './built/inbound-runner.js';
|
|
64
|
+
export type { RunInboundMessageOptions, InboundRunResult } from './built/inbound-runner.js';
|
|
65
|
+
export * from './built/connect-endpoint-instance.js';
|
|
66
|
+
export type { ConnectEndpointInstanceOptions } from './built/connect-endpoint-instance.js';
|
|
67
|
+
export * from './built/endpoint-lifecycle.js';
|
|
68
|
+
export type { EndpointLifecycleKind, EndpointLifecyclePayload } from './built/endpoint-lifecycle.js';
|
|
69
|
+
export * from './built/endpoint-manager.js';
|
|
70
|
+
export type { EndpointConfigRecord, EndpointManager, ProvisionContext } from './built/endpoint-manager.js';
|
|
71
|
+
export * from './built/endpoint-lifecycle-service.js';
|
|
72
|
+
export * from './built/schema-endpoint-manager.js';
|
|
73
|
+
export * from './built/endpoint-commands.js';
|
|
74
|
+
export * from './built/introspection-format.js';
|
|
75
|
+
export * from './built/management-command-guard.js';
|
|
76
|
+
export * from './built/html-to-text.js';
|
|
77
|
+
export * from './built/html-segment-fallback.js';
|
|
43
78
|
export * from '@zhin.js/database';
|
|
44
79
|
export * from '@zhin.js/logger';
|
|
45
80
|
export { Schema } from '@zhin.js/schema';
|
|
46
81
|
export type { PluginLike } from '@zhin.js/kernel';
|
|
47
|
-
export { Feature,
|
|
48
|
-
export type { FeatureJSON, FeatureListener, Schedule, JobPayload, JobState, ScheduledJob, JobStore, JobCallback, AddJobOptions, IScheduler, SchedulerOptions, } from '@zhin.js/kernel';
|
|
49
|
-
//# sourceMappingURL=index.d.ts.map
|
|
82
|
+
export { Feature, ScheduleEngine, getScheduleEngine, setScheduleEngine, Scheduler, getScheduler, setScheduler, } from '@zhin.js/kernel';
|
|
83
|
+
export type { FeatureJSON, FeatureListener, Schedule, JobPayload, JobState, ScheduledJob, JobStore, JobCallback, AddJobOptions, IScheduler, SchedulerOptions, ScheduleFireCallback, MemoryScheduleRegistration, ScheduleEngineOptions, JobContext, ResolvedJob, ScheduleKind, } from '@zhin.js/kernel';
|
package/lib/index.js
CHANGED
|
@@ -1,55 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Canonical IM messages, Endpoints, rendering, and plugin-facing core types.
|
|
3
|
+
* @module @zhin.js/core
|
|
4
|
+
*/
|
|
5
|
+
// ── Core 类模块 ──────────────────────────────────────────────────────
|
|
6
|
+
export * from './endpoint.js';
|
|
7
|
+
export * from './endpoint-capabilities.js';
|
|
3
8
|
export * from './plugin.js';
|
|
4
9
|
export * from './command.js';
|
|
5
10
|
export * from './component.js';
|
|
6
11
|
export * from './adapter.js';
|
|
7
12
|
export * from './message.js';
|
|
8
|
-
export
|
|
9
|
-
export { htmlToPlainText, htmlToPlainTextWithBlockBreaks, htmlToFallbackText } from './built/html-to-text.js';
|
|
10
|
-
export { registerHtmlSegmentFallback, coerceHtmlSegmentsToText } from './built/html-segment-fallback.js';
|
|
11
|
-
export { AGENT_MESH_TOOL_NAMES, setAgentMeshToolsRegistrar, applyAgentMeshTools, } from './built/mcp-mesh-registrar.js';
|
|
12
|
-
export { prependQuoteContext, resolveQuotedMessagePayload, resolveQuoteContextBlock, buildUserTurnWithQuoteContext, formatQuoteContextBlock, QUOTED_MESSAGE_CONTEXT_MARKER, CURRENT_USER_MESSAGE_MARKER, QUOTE_CONTEXT_SYSTEM_HINT, QUOTE_CONTEXT_SYSTEM_EXTRA_KEY, QUOTE_CONTEXT_BLOCK_EXTRA_KEY, QUOTED_CONTENT_UNTRUSTED_NOTE, sanitizeQuotedBodyForPrompt, } from './built/prepend-quote-context.js';
|
|
13
|
+
export * from './im-scene.js';
|
|
13
14
|
export * from './notice.js';
|
|
14
15
|
export * from './request.js';
|
|
15
|
-
export * from './
|
|
16
|
+
export * from './system-event.js';
|
|
17
|
+
export * from './side-event/index.js';
|
|
18
|
+
export * from './schema-interaction.js';
|
|
19
|
+
export * from './types.js';
|
|
20
|
+
export * from './utils.js';
|
|
21
|
+
export * from './errors.js';
|
|
22
|
+
// ── Built 模块 ──────────────────────────────────────────────────────
|
|
23
|
+
export * from './built/config.js';
|
|
24
|
+
export * from './built/command.js';
|
|
25
|
+
export * from './built/schedule.js';
|
|
16
26
|
// Models
|
|
17
27
|
export * from './models/system-log.js';
|
|
18
28
|
export * from './models/user.js';
|
|
19
|
-
|
|
20
|
-
export * from './built/
|
|
21
|
-
export * from './built/
|
|
22
|
-
export * from './built/
|
|
23
|
-
export * from './built/
|
|
24
|
-
export * from './built/
|
|
25
|
-
export { isDenoDeploy, isInteractiveStdin, shouldBindProcessStdin, runtimePid, runtimeUser, } from './built/runtime-io.js';
|
|
26
|
-
export * from './built/component.js';
|
|
29
|
+
export * from './built/permit-parse.js';
|
|
30
|
+
export * from './built/permit-check.js';
|
|
31
|
+
export * from './built/platform-permit.js';
|
|
32
|
+
export * from './built/authorization.js';
|
|
33
|
+
export * from './built/message-enrich.js';
|
|
34
|
+
export * from './built/runtime-io.js';
|
|
27
35
|
export * from './built/database.js';
|
|
28
36
|
export * from './built/message-filter.js';
|
|
29
|
-
// Tool/Skill/AgentPreset Features (backward-compat; canonical source is @zhin.js/agent)
|
|
30
37
|
export * from './built/tool.js';
|
|
31
38
|
export * from './built/skill.js';
|
|
32
39
|
export * from './built/agent-preset.js';
|
|
33
40
|
export * from './built/common-adapter-tools.js';
|
|
34
|
-
// AI Trigger Service (纯工具,无副作用)
|
|
35
41
|
export * from './built/roles.js';
|
|
42
|
+
export * from './im-session-id.js';
|
|
36
43
|
export * from './built/ai-trigger.js';
|
|
37
|
-
|
|
44
|
+
export * from './built/ai-access.js';
|
|
38
45
|
export * from './built/dispatcher.js';
|
|
39
|
-
export { runInboundMessage } from './built/inbound-runner.js';
|
|
40
|
-
// Schema 注册表 (插件配置声明)
|
|
41
46
|
export * from './built/schema-feature.js';
|
|
42
|
-
// Login assist (producer-consumer for QR / SMS / slider etc.)
|
|
43
47
|
export * from './built/login-assist.js';
|
|
44
|
-
|
|
45
|
-
export
|
|
46
|
-
export * from './
|
|
47
|
-
export * from './
|
|
48
|
-
export * from './
|
|
49
|
-
export
|
|
48
|
+
export * from './built/generated-qrcode.js';
|
|
49
|
+
export * from './built/rich-segments/index.js';
|
|
50
|
+
export * from './built/interactive-segments/index.js';
|
|
51
|
+
export * from './built/user-interaction.js';
|
|
52
|
+
export * from './built/ai-outbound/index.js';
|
|
53
|
+
export { loadHtmlRenderer, seedHtmlRenderer, HTML_RENDERER_PACKAGE } from './built/html-renderer-loader.js';
|
|
54
|
+
export { loadSpeechPipeline, seedSpeechPipeline, SPEECH_PACKAGE } from './built/speech-loader.js';
|
|
55
|
+
export * from './built/outbound-media-utils.js';
|
|
56
|
+
export * from './built/outbound-media-contract.js';
|
|
57
|
+
export * from './built/interactive-segment-contract.js';
|
|
58
|
+
export * from './built/segment-contract/index.js';
|
|
59
|
+
export * from './built/generic-segment-mapper.js';
|
|
60
|
+
export * from './built/adapter-process.js';
|
|
61
|
+
export * from './built/component.js';
|
|
62
|
+
export * from './built/inbound-runner.js';
|
|
63
|
+
export * from './built/connect-endpoint-instance.js';
|
|
64
|
+
export * from './built/endpoint-lifecycle.js';
|
|
65
|
+
export * from './built/endpoint-manager.js';
|
|
66
|
+
export * from './built/endpoint-lifecycle-service.js';
|
|
67
|
+
export * from './built/schema-endpoint-manager.js';
|
|
68
|
+
export * from './built/endpoint-commands.js';
|
|
69
|
+
export * from './built/introspection-format.js';
|
|
70
|
+
export * from './built/management-command-guard.js';
|
|
71
|
+
export * from './built/html-to-text.js';
|
|
72
|
+
export * from './built/html-segment-fallback.js';
|
|
73
|
+
// ── 外部库 re-export ──────────────────────────────────────────────────
|
|
50
74
|
export * from '@zhin.js/database';
|
|
51
75
|
export * from '@zhin.js/logger';
|
|
52
|
-
// 只导出 Schema 类,避免与 utils.js 的 isEmpty 冲突
|
|
53
76
|
export { Schema } from '@zhin.js/schema';
|
|
54
|
-
export { Feature,
|
|
55
|
-
//# sourceMappingURL=index.js.map
|
|
77
|
+
export { Feature, ScheduleEngine, getScheduleEngine, setScheduleEngine, Scheduler, getScheduler, setScheduler, } from '@zhin.js/kernel';
|
package/lib/jsx-dev-runtime.d.ts
CHANGED
package/lib/jsx-dev-runtime.js
CHANGED
package/lib/jsx-runtime.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment, renderJSX } from './jsx.js';
|
|
2
2
|
export { jsx, jsxs, Fragment, renderJSX };
|
|
3
|
+
export type { JSX } from './jsx.js';
|
|
3
4
|
declare const _default: {
|
|
4
5
|
jsx: typeof jsx;
|
|
5
6
|
jsxs: typeof jsxs;
|
|
@@ -9,4 +10,3 @@ declare const _default: {
|
|
|
9
10
|
renderJSX: typeof renderJSX;
|
|
10
11
|
};
|
|
11
12
|
export default _default;
|
|
12
|
-
//# sourceMappingURL=jsx-runtime.d.ts.map
|
package/lib/jsx-runtime.js
CHANGED
package/lib/jsx.d.ts
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
import { SendContent, MessageElement } from './types.js';
|
|
2
|
-
import { MessageComponent } from './message.js';
|
|
3
|
-
import { Component, ComponentContext } from './component.js';
|
|
1
|
+
import type { SendContent, MessageElement } from './types.js';
|
|
2
|
+
import type { MessageComponent } from './message.js';
|
|
3
|
+
import type { Component, ComponentContext } from './component.js';
|
|
4
4
|
export type JSXChildren = MessageElement | string | number | boolean | null | undefined | JSXChildren[];
|
|
5
5
|
export type JSXElementType = string | Component<any>;
|
|
6
6
|
export type JSXProps = Record<string, any> & {
|
|
7
7
|
children?: JSXChildren;
|
|
8
8
|
};
|
|
9
9
|
export { Fragment } from './component.js';
|
|
10
|
-
declare
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
key?: string | number;
|
|
27
|
-
}
|
|
10
|
+
export declare namespace JSX {
|
|
11
|
+
type Element = SendContent | Promise<SendContent>;
|
|
12
|
+
interface ElementClass {
|
|
13
|
+
render(props: any, context?: ComponentContext): Element;
|
|
14
|
+
}
|
|
15
|
+
interface ElementAttributesProperty {
|
|
16
|
+
data: {};
|
|
17
|
+
}
|
|
18
|
+
interface ElementChildrenAttribute {
|
|
19
|
+
children: {};
|
|
20
|
+
}
|
|
21
|
+
interface IntrinsicElements {
|
|
22
|
+
[elemName: string]: any;
|
|
23
|
+
}
|
|
24
|
+
interface IntrinsicAttributes {
|
|
25
|
+
key?: string | number;
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
export declare function jsx(type: JSXElementType, data: JSXProps): MessageComponent<any>;
|
|
31
29
|
export declare function jsxs(type: JSXElementType, props: JSXProps): MessageElement;
|
|
32
30
|
export declare function renderJSX(element: MessageComponent<any>, context?: ComponentContext): Promise<SendContent>;
|
|
33
|
-
//# sourceMappingURL=jsx.d.ts.map
|
package/lib/jsx.js
CHANGED
package/lib/message.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MessageElement, MessageSender, SendContent } from "./types";
|
|
1
|
+
import type { MessageElement, MessageSender, SendContent } from "./types.js";
|
|
2
2
|
import { Component } from "./component.js";
|
|
3
3
|
import { Adapters } from "./adapter.js";
|
|
4
4
|
/**
|
|
@@ -16,6 +16,15 @@ export type MessageComponent<T extends object> = {
|
|
|
16
16
|
export interface MessageChannel {
|
|
17
17
|
id: string;
|
|
18
18
|
type: MessageType;
|
|
19
|
+
/**
|
|
20
|
+
* 私聊/子频道消息的来源场景:
|
|
21
|
+
* - 群临时会话:type=private + parent.group
|
|
22
|
+
* - QQ 子频道:type=channel + parent.guild
|
|
23
|
+
*/
|
|
24
|
+
parent?: {
|
|
25
|
+
type: 'group' | 'channel' | 'guild';
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
19
28
|
}
|
|
20
29
|
/**
|
|
21
30
|
* 消息类型枚举
|
|
@@ -27,28 +36,25 @@ export type MessageType = 'group' | 'private' | 'channel';
|
|
|
27
36
|
export interface MessageBase {
|
|
28
37
|
$id: string;
|
|
29
38
|
$adapter: keyof Adapters;
|
|
30
|
-
$
|
|
39
|
+
$endpoint: string;
|
|
31
40
|
$content: MessageElement[];
|
|
32
41
|
$sender: MessageSender;
|
|
33
|
-
$reply(content: SendContent, quote?: boolean | string): Promise<string>;
|
|
34
|
-
$recall(): Promise<void>;
|
|
42
|
+
$reply?(content: SendContent, quote?: boolean | string): Promise<string>;
|
|
43
|
+
$recall?(): Promise<void>;
|
|
35
44
|
$channel: MessageChannel;
|
|
36
45
|
$timestamp: number;
|
|
37
46
|
$raw: string;
|
|
38
|
-
/** 本条消息引用的上游 message_id(平台原样字符串) */
|
|
39
|
-
$quote_id?: string;
|
|
40
47
|
}
|
|
41
48
|
/**
|
|
42
49
|
* 完整消息类型,支持扩展
|
|
43
50
|
*/
|
|
44
51
|
export type Message<T extends object = {}> = MessageBase & T;
|
|
52
|
+
/** @internal Legacy static helpers; not part of Agent resource authoring. */
|
|
45
53
|
export declare namespace Message {
|
|
46
54
|
/**
|
|
47
55
|
* 工具方法:合并自定义字段与基础消息结构
|
|
48
56
|
*/
|
|
49
57
|
function from<T extends object>(input: T, format: MessageBase): Message<T>;
|
|
50
|
-
function
|
|
51
|
-
function
|
|
52
|
-
function alignReplySegments(content: MessageElement[], quoteId?: string): void;
|
|
58
|
+
function actionPayload(message: Message<any>): string | undefined;
|
|
59
|
+
function isAction(message: Message<any>): boolean;
|
|
53
60
|
}
|
|
54
|
-
//# sourceMappingURL=message.d.ts.map
|
package/lib/message.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isActionMessage as isActionMessageImpl } from "./built/interactive-segments/action.js";
|
|
2
|
+
/** @internal Legacy static helpers; not part of Agent resource authoring. */
|
|
2
3
|
export var Message;
|
|
3
4
|
(function (Message) {
|
|
4
5
|
/**
|
|
5
6
|
* 工具方法:合并自定义字段与基础消息结构
|
|
6
7
|
*/
|
|
7
8
|
function from(input, format) {
|
|
8
|
-
return Object.assign(input, format);
|
|
9
|
+
return Object.assign({}, input, format);
|
|
9
10
|
}
|
|
10
11
|
Message.from = from;
|
|
11
|
-
function
|
|
12
|
-
|
|
12
|
+
function actionPayload(message) {
|
|
13
|
+
for (const item of message.$content ?? []) {
|
|
14
|
+
if (typeof item === 'string')
|
|
15
|
+
continue;
|
|
16
|
+
if (item.type === 'action' && item.data?.payload) {
|
|
17
|
+
return String(item.data.payload);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
13
21
|
}
|
|
14
|
-
Message.
|
|
15
|
-
function
|
|
16
|
-
|
|
22
|
+
Message.actionPayload = actionPayload;
|
|
23
|
+
function isAction(message) {
|
|
24
|
+
return isActionMessageImpl(message);
|
|
17
25
|
}
|
|
18
|
-
Message.
|
|
19
|
-
function alignReplySegments(content, quoteId) {
|
|
20
|
-
alignReplySegmentsImpl(content, quoteId);
|
|
21
|
-
}
|
|
22
|
-
Message.alignReplySegments = alignReplySegments;
|
|
26
|
+
Message.isAction = isAction;
|
|
23
27
|
})(Message || (Message = {}));
|
|
24
|
-
//# sourceMappingURL=message.js.map
|
package/lib/models/system-log.js
CHANGED
package/lib/models/user.d.ts
CHANGED
package/lib/models/user.js
CHANGED
package/lib/notice.d.ts
CHANGED
|
@@ -1,81 +1,38 @@
|
|
|
1
|
-
import { Adapters } from './adapter.js';
|
|
2
|
-
import type {
|
|
1
|
+
import type { Adapters } from './adapter.js';
|
|
2
|
+
import type { NoticeKind } from './side-event/types.js';
|
|
3
|
+
import type { SideEventBase } from './side-event/base.js';
|
|
4
|
+
export type { NoticeKind, ComposedNoticeName } from './side-event/types.js';
|
|
5
|
+
export type { SideEventBase } from './side-event/base.js';
|
|
6
|
+
export { composeSideEventName, formatSideEventName, matchesSideEventName, parseSideEventName, sideEventSendChannel, } from './side-event/base.js';
|
|
3
7
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* 常见 IM 通知事件分类:
|
|
7
|
-
* - group_member_increase: 群成员增加(入群)
|
|
8
|
-
* - group_member_decrease: 群成员减少(退群/被踢)
|
|
9
|
-
* - group_admin_change: 群管理员变动
|
|
10
|
-
* - group_ban: 群禁言
|
|
11
|
-
* - group_recall: 群消息撤回
|
|
12
|
-
* - friend_recall: 好友消息撤回
|
|
13
|
-
* - friend_add: 新增好友
|
|
14
|
-
* - group_poke: 群戳一戳
|
|
15
|
-
* - friend_poke: 好友戳一戳
|
|
16
|
-
* - group_transfer: 群转让
|
|
17
|
-
*
|
|
18
|
-
* 适配器可自行扩展更多子类型
|
|
19
|
-
*/
|
|
20
|
-
export type NoticeType = 'group_member_increase' | 'group_member_decrease' | 'group_admin_change' | 'group_ban' | 'group_recall' | 'friend_recall' | 'friend_add' | 'group_poke' | 'friend_poke' | 'group_transfer' | (string & {});
|
|
21
|
-
/**
|
|
22
|
-
* 通知频道信息
|
|
23
|
-
*/
|
|
24
|
-
export interface NoticeChannel {
|
|
25
|
-
id: string;
|
|
26
|
-
type: 'group' | 'private' | 'channel';
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 通知基础结构
|
|
30
|
-
*
|
|
31
|
-
* 与 MessageBase 同构设计,所有通知共享以下字段。
|
|
32
|
-
* 适配器通过 `Notice.from(raw, base)` 合并平台原始数据和标准字段。
|
|
8
|
+
* 通知基础结构 — 继承 SideEventBase。
|
|
33
9
|
*
|
|
34
10
|
* @example
|
|
35
11
|
* ```typescript
|
|
36
|
-
* // 适配器中格式化通知
|
|
37
12
|
* const notice = Notice.from(rawEvent, {
|
|
38
13
|
* $id: rawEvent.id,
|
|
39
14
|
* $adapter: 'icqq',
|
|
40
|
-
* $
|
|
41
|
-
* $type: '
|
|
42
|
-
* $
|
|
43
|
-
* $
|
|
44
|
-
* $
|
|
15
|
+
* $endpoint: endpointKey,
|
|
16
|
+
* $type: 'notice',
|
|
17
|
+
* $scene_id: groupId,
|
|
18
|
+
* $scene_type: 'group',
|
|
19
|
+
* $sub_type: 'member_decrease',
|
|
20
|
+
* $actor: { id: operatorId, name: '管理员' },
|
|
45
21
|
* $target: { id: userId, name: '被踢者' },
|
|
46
22
|
* $timestamp: Date.now(),
|
|
47
23
|
* });
|
|
24
|
+
* // formatSideEventName(notice) === 'notice.group.member_decrease'
|
|
48
25
|
* this.adapter.emit('notice.receive', notice);
|
|
49
26
|
* ```
|
|
50
27
|
*/
|
|
51
|
-
export interface NoticeBase {
|
|
52
|
-
/** 通知唯一 ID(平台提供或自生成) */
|
|
53
|
-
$id: string;
|
|
54
|
-
/** 适配器名称 */
|
|
28
|
+
export interface NoticeBase extends SideEventBase {
|
|
55
29
|
$adapter: keyof Adapters;
|
|
56
|
-
|
|
57
|
-
$bot: string;
|
|
58
|
-
/** 通知类型 */
|
|
59
|
-
$type: NoticeType;
|
|
60
|
-
/** 通知子类型(如 leave/kick、set/unset) */
|
|
61
|
-
$subType?: string;
|
|
62
|
-
/** 通知发生的频道/群/会话 */
|
|
63
|
-
$channel: NoticeChannel;
|
|
64
|
-
/** 操作者信息(如管理员) */
|
|
65
|
-
$operator?: MessageSender;
|
|
66
|
-
/** 被操作目标信息(如被踢的成员) */
|
|
67
|
-
$target?: MessageSender;
|
|
68
|
-
/** 通知时间戳 */
|
|
69
|
-
$timestamp: number;
|
|
30
|
+
$type: NoticeKind;
|
|
70
31
|
}
|
|
71
32
|
/**
|
|
72
33
|
* 完整通知类型,支持平台原始数据扩展
|
|
73
34
|
*/
|
|
74
35
|
export type Notice<T extends object = {}> = NoticeBase & T;
|
|
75
36
|
export declare namespace Notice {
|
|
76
|
-
/**
|
|
77
|
-
* 工具方法:合并自定义字段与基础通知结构
|
|
78
|
-
*/
|
|
79
37
|
function from<T extends object>(input: T, format: NoticeBase): Notice<T>;
|
|
80
38
|
}
|
|
81
|
-
//# sourceMappingURL=notice.d.ts.map
|
package/lib/notice.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
+
export { composeSideEventName, formatSideEventName, matchesSideEventName, parseSideEventName, sideEventSendChannel, } from './side-event/base.js';
|
|
1
2
|
export var Notice;
|
|
2
3
|
(function (Notice) {
|
|
3
|
-
/**
|
|
4
|
-
* 工具方法:合并自定义字段与基础通知结构
|
|
5
|
-
*/
|
|
6
4
|
function from(input, format) {
|
|
7
5
|
return Object.assign(input, format);
|
|
8
6
|
}
|
|
9
7
|
Notice.from = from;
|
|
10
8
|
})(Notice || (Notice = {}));
|
|
11
|
-
//# sourceMappingURL=notice.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
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;
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
}
|