@zhin.js/core 1.5.16 → 1.6.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 +13 -11
- package/lib/built/login-assist.js +32 -26
- 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 +19 -48
- package/lib/index.js +14 -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 +89 -0
- package/lib/plugin-runtime/im/endpoint-runtime.js +381 -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 +114 -0
- package/lib/plugin-runtime/im/host/database-host-installer.d.ts +29 -0
- package/lib/plugin-runtime/im/host/database-host-installer.js +442 -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 +234 -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
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx } from '@zhin.js/jsx';
|
|
2
|
+
export function Text(props) {
|
|
3
|
+
return jsx('text', { ...props });
|
|
4
|
+
}
|
|
5
|
+
/** URLs and local paths are convenient sources; opaque platform IDs use MediaRef. */
|
|
6
|
+
export function Image({ src, alt }) {
|
|
7
|
+
let media;
|
|
8
|
+
if (typeof src !== 'string')
|
|
9
|
+
media = src;
|
|
10
|
+
else if (/^https?:\/\//i.test(src))
|
|
11
|
+
media = { kind: 'url', value: src };
|
|
12
|
+
else if (src.startsWith('base64://'))
|
|
13
|
+
media = { kind: 'base64', value: src.slice(9) };
|
|
14
|
+
else if (src.startsWith('data:')) {
|
|
15
|
+
const match = /^data:([^;,]+)(?:;[^;,]*)*;base64,([\s\S]+)$/i.exec(src);
|
|
16
|
+
if (!match)
|
|
17
|
+
throw new TypeError('Image data URI must contain base64 media');
|
|
18
|
+
media = { kind: 'base64', value: match[2], mime_type: match[1] };
|
|
19
|
+
}
|
|
20
|
+
else
|
|
21
|
+
media = { kind: 'path', value: src };
|
|
22
|
+
return jsx('image', { media, ...(alt === undefined ? {} : { alt }) });
|
|
23
|
+
}
|
|
24
|
+
export function Mention(props) { return jsx('mention', { ...props }); }
|
|
25
|
+
export function Face(props) { return jsx('face', { ...props }); }
|
|
26
|
+
export function Markdown(props) {
|
|
27
|
+
return jsx('markdown', { ...props });
|
|
28
|
+
}
|
|
29
|
+
export function Card({ data }) { return { type: 'card', data }; }
|
|
30
|
+
/** Event handlers are bound by the active IM operation, never serialized onto the wire. */
|
|
31
|
+
export function Button(props) { return jsx('button', { ...props }); }
|
|
32
|
+
function nativeTag(type) {
|
|
33
|
+
return (props) => jsx(type, { ...props });
|
|
34
|
+
}
|
|
35
|
+
export const Audio = nativeTag('audio');
|
|
36
|
+
export const Video = nativeTag('video');
|
|
37
|
+
export const File = nativeTag('file');
|
|
38
|
+
export const Reply = nativeTag('reply');
|
|
39
|
+
export const Forward = nativeTag('forward');
|
|
40
|
+
export const Share = nativeTag('share');
|
|
41
|
+
export const Dice = nativeTag('dice');
|
|
42
|
+
export const Rps = nativeTag('rps');
|
|
43
|
+
// Explicit annotations keep the emitted .d.ts on the leaf type module. Inferred, they
|
|
44
|
+
// print as import("../index.js"), dragging the whole core entry (and @zhin.js/ai,
|
|
45
|
+
// database drivers) into every packed consumer that only imports a feature subpath.
|
|
46
|
+
export const Keyboard = nativeTag('keyboard');
|
|
47
|
+
export const Action = nativeTag('action');
|
|
48
|
+
export const Link = nativeTag('link');
|
|
49
|
+
export const Qrcode = nativeTag('qrcode');
|
|
50
|
+
export const Tts = nativeTag('tts');
|
package/lib/jsx-dev-runtime.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
1
|
+
export { Fragment, jsxDEV } from '@zhin.js/jsx/jsx-dev-runtime';
|
|
2
|
+
export type { JSX } from './jsx/intrinsic-elements.js';
|
package/lib/jsx-dev-runtime.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { jsx as jsxDEV } from './jsx.js';
|
|
1
|
+
export { Fragment, jsxDEV } from '@zhin.js/jsx/jsx-dev-runtime';
|
package/lib/jsx-runtime.d.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export type { JSX } from './jsx.js';
|
|
4
|
-
declare const _default: {
|
|
5
|
-
jsx: typeof jsx;
|
|
6
|
-
jsxs: typeof jsxs;
|
|
7
|
-
Fragment: import("./component.js").Component<{
|
|
8
|
-
children?: import("./types.js").SendContent;
|
|
9
|
-
}>;
|
|
10
|
-
renderJSX: typeof renderJSX;
|
|
11
|
-
};
|
|
12
|
-
export default _default;
|
|
1
|
+
export { Fragment, jsx, jsxs } from '@zhin.js/jsx/jsx-runtime';
|
|
2
|
+
export type { JSX } from './jsx/intrinsic-elements.js';
|
package/lib/jsx-runtime.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx, jsxs, Fragment, renderJSX } from './jsx.js';
|
|
3
|
-
export { jsx, jsxs, Fragment, renderJSX };
|
|
4
|
-
// 默认导出 JSX 运行时
|
|
5
|
-
export default {
|
|
6
|
-
jsx,
|
|
7
|
-
jsxs,
|
|
8
|
-
Fragment,
|
|
9
|
-
renderJSX
|
|
10
|
-
};
|
|
1
|
+
export { Fragment, jsx, jsxs } from '@zhin.js/jsx/jsx-runtime';
|
package/lib/jsx.d.ts
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export type
|
|
6
|
-
export type
|
|
7
|
-
children?: JSXChildren;
|
|
8
|
-
};
|
|
9
|
-
export { Fragment } from './component.js';
|
|
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;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export declare function jsx(type: JSXElementType, data: JSXProps): MessageComponent<any>;
|
|
29
|
-
export declare function jsxs(type: JSXElementType, props: JSXProps): MessageElement;
|
|
30
|
-
export declare function renderJSX(element: MessageComponent<any>, context?: ComponentContext): Promise<SendContent>;
|
|
1
|
+
export * from '@zhin.js/jsx';
|
|
2
|
+
export { Image, Mention, Card, Button, Markdown, Face, Text, Audio, Video, File, Reply, Forward, Share, Dice, Rps, Keyboard, Action, Link, Qrcode, Tts } from './jsx/message-tags.js';
|
|
3
|
+
export type { ImageProps, MentionProps, CardProps, ButtonProps, ButtonClickHandler, ButtonClickResult, MarkdownProps, FaceProps, TextProps } from './jsx/message-tags.js';
|
|
4
|
+
export { renderToSegments } from './jsx/message-renderer.js';
|
|
5
|
+
export type { MessageRenderOptions } from './jsx/message-renderer.js';
|
|
6
|
+
export type { JSX, MessageTagProps } from './jsx/intrinsic-elements.js';
|
package/lib/jsx.js
CHANGED
|
@@ -1,93 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
return {
|
|
5
|
-
type,
|
|
6
|
-
data,
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
// JSX Fragment 支持
|
|
10
|
-
export function jsxs(type, props) {
|
|
11
|
-
return jsx(type, props);
|
|
12
|
-
}
|
|
13
|
-
// JSX 渲染函数
|
|
14
|
-
export async function renderJSX(element, context) {
|
|
15
|
-
try {
|
|
16
|
-
if (typeof element.type === 'string') {
|
|
17
|
-
if (element.type === 'Fragment') {
|
|
18
|
-
return await renderChildren(element.data.children, context);
|
|
19
|
-
}
|
|
20
|
-
// 其他内置组件处理
|
|
21
|
-
return await renderChildren(element.data.children, context);
|
|
22
|
-
}
|
|
23
|
-
else if (typeof element.type === 'function') {
|
|
24
|
-
// 函数组件
|
|
25
|
-
const component = element.type;
|
|
26
|
-
const result = await component(element.data, context || {});
|
|
27
|
-
// 如果组件返回 Promise,自动 await
|
|
28
|
-
if (result && typeof result === 'object' && 'then' in result) {
|
|
29
|
-
return await result;
|
|
30
|
-
}
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
// 类组件或其他类型
|
|
35
|
-
const component = element.type;
|
|
36
|
-
const result = await component(element.data, context || {});
|
|
37
|
-
// 如果组件返回 Promise,自动 await
|
|
38
|
-
if (result && typeof result === 'object' && 'then' in result) {
|
|
39
|
-
return await result;
|
|
40
|
-
}
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
// 渲染错误时返回错误信息
|
|
46
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
47
|
-
return `❌ 组件渲染失败: ${errorMessage}`;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// 渲染子元素
|
|
51
|
-
async function renderChildren(children, context) {
|
|
52
|
-
if (children == null)
|
|
53
|
-
return '';
|
|
54
|
-
if (typeof children === 'string' || typeof children === 'number' || typeof children === 'boolean') {
|
|
55
|
-
return String(children);
|
|
56
|
-
}
|
|
57
|
-
if (Array.isArray(children)) {
|
|
58
|
-
const results = await Promise.all(children.map(async (child) => {
|
|
59
|
-
if (typeof child === 'string' || typeof child === 'number' || typeof child === 'boolean') {
|
|
60
|
-
return String(child);
|
|
61
|
-
}
|
|
62
|
-
if (child && typeof child === 'object' && 'type' in child) {
|
|
63
|
-
return await renderJSX(child, context);
|
|
64
|
-
}
|
|
65
|
-
// 如果子元素是 Promise,自动 await
|
|
66
|
-
if (child && typeof child === 'object' && 'then' in child) {
|
|
67
|
-
try {
|
|
68
|
-
return await child;
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
72
|
-
return `❌ 组件渲染失败: ${errorMessage}`;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return '';
|
|
76
|
-
}));
|
|
77
|
-
return results.join('');
|
|
78
|
-
}
|
|
79
|
-
if (children && typeof children === 'object' && 'type' in children) {
|
|
80
|
-
return await renderJSX(children, context);
|
|
81
|
-
}
|
|
82
|
-
// 如果子元素是 Promise,自动 await
|
|
83
|
-
if (children && typeof children === 'object' && 'then' in children) {
|
|
84
|
-
try {
|
|
85
|
-
return await children;
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
89
|
-
return `❌ 组件渲染失败: ${errorMessage}`;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return '';
|
|
93
|
-
}
|
|
1
|
+
export * from '@zhin.js/jsx';
|
|
2
|
+
export { Image, Mention, Card, Button, Markdown, Face, Text, Audio, Video, File, Reply, Forward, Share, Dice, Rps, Keyboard, Action, Link, Qrcode, Tts } from './jsx/message-tags.js';
|
|
3
|
+
export { renderToSegments } from './jsx/message-renderer.js';
|
package/lib/message.d.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import type { MessageElement, MessageSender, SendContent } from "./types.js";
|
|
2
|
-
import { Component } from "./component.js";
|
|
3
|
-
import { Adapters } from "./adapter.js";
|
|
4
|
-
/**
|
|
5
|
-
* 消息组件类型:用于自定义消息结构
|
|
6
|
-
*/
|
|
7
|
-
export type MessageComponent<T extends object> = {
|
|
8
|
-
type: Component<T & {
|
|
9
|
-
children?: SendContent | Promise<SendContent>;
|
|
10
|
-
}>;
|
|
11
|
-
data: T;
|
|
12
|
-
};
|
|
13
1
|
/**
|
|
14
2
|
* 消息频道信息
|
|
15
3
|
*/
|
|
@@ -30,31 +18,3 @@ export interface MessageChannel {
|
|
|
30
18
|
* 消息类型枚举
|
|
31
19
|
*/
|
|
32
20
|
export type MessageType = 'group' | 'private' | 'channel';
|
|
33
|
-
/**
|
|
34
|
-
* 消息基础结构
|
|
35
|
-
*/
|
|
36
|
-
export interface MessageBase {
|
|
37
|
-
$id: string;
|
|
38
|
-
$adapter: keyof Adapters;
|
|
39
|
-
$endpoint: string;
|
|
40
|
-
$content: MessageElement[];
|
|
41
|
-
$sender: MessageSender;
|
|
42
|
-
$reply?(content: SendContent, quote?: boolean | string): Promise<string>;
|
|
43
|
-
$recall?(): Promise<void>;
|
|
44
|
-
$channel: MessageChannel;
|
|
45
|
-
$timestamp: number;
|
|
46
|
-
$raw: string;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* 完整消息类型,支持扩展
|
|
50
|
-
*/
|
|
51
|
-
export type Message<T extends object = {}> = MessageBase & T;
|
|
52
|
-
/** @internal Legacy static helpers; not part of Agent resource authoring. */
|
|
53
|
-
export declare namespace Message {
|
|
54
|
-
/**
|
|
55
|
-
* 工具方法:合并自定义字段与基础消息结构
|
|
56
|
-
*/
|
|
57
|
-
function from<T extends object>(input: T, format: MessageBase): Message<T>;
|
|
58
|
-
function actionPayload(message: Message<any>): string | undefined;
|
|
59
|
-
function isAction(message: Message<any>): boolean;
|
|
60
|
-
}
|
package/lib/message.js
CHANGED
|
@@ -1,27 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/** @internal Legacy static helpers; not part of Agent resource authoring. */
|
|
3
|
-
export var Message;
|
|
4
|
-
(function (Message) {
|
|
5
|
-
/**
|
|
6
|
-
* 工具方法:合并自定义字段与基础消息结构
|
|
7
|
-
*/
|
|
8
|
-
function from(input, format) {
|
|
9
|
-
return Object.assign({}, input, format);
|
|
10
|
-
}
|
|
11
|
-
Message.from = from;
|
|
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;
|
|
21
|
-
}
|
|
22
|
-
Message.actionPayload = actionPayload;
|
|
23
|
-
function isAction(message) {
|
|
24
|
-
return isActionMessageImpl(message);
|
|
25
|
-
}
|
|
26
|
-
Message.isAction = isAction;
|
|
27
|
-
})(Message || (Message = {}));
|
|
1
|
+
export {};
|
package/lib/models/system-log.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
id: { type: 'integer', autoIncrement: true, primary: true },
|
|
3
|
-
level: { type: 'text', nullable: false },
|
|
4
|
-
name: { type: 'text', nullable: false },
|
|
5
|
-
message: { type: 'text', nullable: false },
|
|
6
|
-
source: { type: 'text', nullable: false },
|
|
7
|
-
timestamp: { type: 'date', nullable: false }
|
|
8
|
-
};
|
|
1
|
+
export {};
|
package/lib/models/user.d.ts
CHANGED
package/lib/models/user.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
id: { type: "text", nullable: false },
|
|
3
|
-
name: { type: 'text', nullable: true },
|
|
4
|
-
password: { type: 'text', nullable: true },
|
|
5
|
-
third_part: { type: 'json', default: [] },
|
|
6
|
-
permissions: { type: 'json', default: [] }
|
|
7
|
-
};
|
|
1
|
+
export {};
|
package/lib/notice.d.ts
CHANGED
|
@@ -1,38 +1,43 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
3
|
-
import type { SideEventBase } from './side-event/base.js';
|
|
1
|
+
import type { ComposedNoticeName } from './side-event/types.js';
|
|
2
|
+
import { RuntimeSideEvent, type IncomingSideEvent, type SideEventBase, type EndpointEventContext } from './side-event/base.js';
|
|
4
3
|
export type { NoticeKind, ComposedNoticeName } from './side-event/types.js';
|
|
5
|
-
export type { SideEventBase } from './side-event/base.js';
|
|
6
|
-
export { composeSideEventName, formatSideEventName, matchesSideEventName, parseSideEventName,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* $sub_type: 'member_decrease',
|
|
20
|
-
* $actor: { id: operatorId, name: '管理员' },
|
|
21
|
-
* $target: { id: userId, name: '被踢者' },
|
|
22
|
-
* $timestamp: Date.now(),
|
|
23
|
-
* });
|
|
24
|
-
* // formatSideEventName(notice) === 'notice.group.member_decrease'
|
|
25
|
-
* this.adapter.emit('notice.receive', notice);
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
4
|
+
export type { SideEventBase, IncomingSideEvent } from './side-event/base.js';
|
|
5
|
+
export { composeSideEventName, formatSideEventName, matchesSideEventName, parseSideEventName, sideEventConversation, sideEventSendChannel } from './side-event/base.js';
|
|
6
|
+
export interface IncomingNotice extends IncomingSideEvent {
|
|
7
|
+
readonly type: 'notice';
|
|
8
|
+
readonly name: ComposedNoticeName;
|
|
9
|
+
readonly messageId?: string;
|
|
10
|
+
readonly reaction?: string;
|
|
11
|
+
readonly operation?: 'added' | 'removed';
|
|
12
|
+
readonly durationSeconds?: number;
|
|
13
|
+
readonly role?: string;
|
|
14
|
+
readonly enabled?: boolean;
|
|
15
|
+
/** Short new value of a card/title/remark change or a notice body (adapter-truncated, plain text). */
|
|
16
|
+
readonly value?: string;
|
|
17
|
+
}
|
|
28
18
|
export interface NoticeBase extends SideEventBase {
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
readonly type: 'notice';
|
|
20
|
+
readonly name: ComposedNoticeName;
|
|
21
|
+
readonly messageId?: string;
|
|
22
|
+
readonly reaction?: string;
|
|
23
|
+
readonly operation?: 'added' | 'removed';
|
|
24
|
+
readonly durationSeconds?: number;
|
|
25
|
+
readonly role?: string;
|
|
26
|
+
readonly enabled?: boolean;
|
|
27
|
+
readonly value?: string;
|
|
31
28
|
}
|
|
32
|
-
/**
|
|
33
|
-
* 完整通知类型,支持平台原始数据扩展
|
|
34
|
-
*/
|
|
35
29
|
export type Notice<T extends object = {}> = NoticeBase & T;
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
/** @internal Generation-scoped implementation of the public Notice contract. */
|
|
31
|
+
export declare class RuntimeNotice extends RuntimeSideEvent implements NoticeBase {
|
|
32
|
+
readonly type: 'notice';
|
|
33
|
+
readonly name: ComposedNoticeName;
|
|
34
|
+
readonly messageId?: string;
|
|
35
|
+
readonly reaction?: string;
|
|
36
|
+
readonly operation?: 'added' | 'removed';
|
|
37
|
+
readonly durationSeconds?: number;
|
|
38
|
+
readonly role?: string;
|
|
39
|
+
readonly enabled?: boolean;
|
|
40
|
+
readonly value?: string;
|
|
41
|
+
constructor(input: IncomingNotice, context: EndpointEventContext);
|
|
38
42
|
}
|
|
43
|
+
export declare const Notice: typeof RuntimeNotice;
|
package/lib/notice.js
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { RuntimeSideEvent } from './side-event/base.js';
|
|
2
|
+
export { composeSideEventName, formatSideEventName, matchesSideEventName, parseSideEventName, sideEventConversation, sideEventSendChannel } from './side-event/base.js';
|
|
3
|
+
/** @internal Generation-scoped implementation of the public Notice contract. */
|
|
4
|
+
export class RuntimeNotice extends RuntimeSideEvent {
|
|
5
|
+
messageId;
|
|
6
|
+
reaction;
|
|
7
|
+
operation;
|
|
8
|
+
durationSeconds;
|
|
9
|
+
role;
|
|
10
|
+
enabled;
|
|
11
|
+
value;
|
|
12
|
+
constructor(input, context) {
|
|
13
|
+
super(input, context);
|
|
14
|
+
this.messageId = input.messageId;
|
|
15
|
+
this.reaction = input.reaction;
|
|
16
|
+
this.operation = input.operation;
|
|
17
|
+
this.durationSeconds = input.durationSeconds;
|
|
18
|
+
this.role = input.role;
|
|
19
|
+
this.enabled = input.enabled;
|
|
20
|
+
this.value = input.value;
|
|
21
|
+
Object.freeze(this);
|
|
6
22
|
}
|
|
7
|
-
|
|
8
|
-
|
|
23
|
+
}
|
|
24
|
+
export const Notice = RuntimeNotice;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CommandDispatchResult, CommandExecutionLimit, CommandIndex, CommandMenuPage, CommandValidationIssue } from '@zhin.js/command';
|
|
2
|
+
import type { ConversationRef } from '@zhin.js/im-contract';
|
|
3
|
+
import { type Locale, type PluginId, type RuntimeSnapshot } from '@zhin.js/plugin-runtime';
|
|
4
|
+
import type { Message, MessageSenderRef, SendContent } from './contracts.js';
|
|
5
|
+
interface CommandFeedbackIdentity {
|
|
6
|
+
readonly command?: string;
|
|
7
|
+
/** The command's owner, not the author of the replacement reply. */
|
|
8
|
+
readonly owner?: PluginId;
|
|
9
|
+
}
|
|
10
|
+
/** Execution facts are read-only; formatting cannot change admission or permission decisions. */
|
|
11
|
+
export type CommandFeedback = CommandFeedbackIdentity & ({
|
|
12
|
+
readonly status: 'invalid';
|
|
13
|
+
readonly issues: readonly CommandValidationIssue[];
|
|
14
|
+
readonly help?: string;
|
|
15
|
+
} | {
|
|
16
|
+
readonly status: 'denied';
|
|
17
|
+
readonly permit?: string;
|
|
18
|
+
readonly reason?: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly status: 'limited';
|
|
21
|
+
readonly limit?: CommandExecutionLimit;
|
|
22
|
+
});
|
|
23
|
+
/** A presentation context deliberately without message bodies, sending methods or executors. */
|
|
24
|
+
export interface CommandFeedbackContext {
|
|
25
|
+
readonly locale: Locale;
|
|
26
|
+
readonly conversation: ConversationRef;
|
|
27
|
+
readonly sender?: MessageSenderRef;
|
|
28
|
+
readonly clientAdapter?: string;
|
|
29
|
+
readonly generation: number;
|
|
30
|
+
}
|
|
31
|
+
/** Return undefined to retain the built-in feedback. Exceptions also fall back to it. */
|
|
32
|
+
export type CommandFeedbackRenderer = (feedback: CommandFeedback, context: CommandFeedbackContext) => SendContent | undefined | Promise<SendContent | undefined>;
|
|
33
|
+
/** Explicitly provide this resource in Root setup; descendant bindings are not selected. */
|
|
34
|
+
export declare const commandFeedbackToken: import("@zhin.js/plugin-runtime").Token<CommandFeedbackRenderer>;
|
|
35
|
+
/** @internal Resolve once from the operation snapshot; never redispatch or send from here. */
|
|
36
|
+
export declare function renderCommandFeedback(result: CommandDispatchResult, message: Message, snapshot: RuntimeSnapshot): Promise<{
|
|
37
|
+
readonly content: SendContent;
|
|
38
|
+
readonly owner?: PluginId;
|
|
39
|
+
} | undefined>;
|
|
40
|
+
export interface CommandMenuPresentationInput {
|
|
41
|
+
readonly page: CommandMenuPage;
|
|
42
|
+
readonly conversation: ConversationRef;
|
|
43
|
+
readonly generation: number;
|
|
44
|
+
}
|
|
45
|
+
/** Root-selected menu content. `undefined` retains the built-in presentation. */
|
|
46
|
+
export type CommandMenuPresenter = (input: CommandMenuPresentationInput) => SendContent | undefined | Promise<SendContent | undefined>;
|
|
47
|
+
export declare const commandMenuPresentationToken: import("@zhin.js/plugin-runtime").Token<CommandMenuPresenter>;
|
|
48
|
+
/** The current Root owns both the selected presenter and the resulting content. */
|
|
49
|
+
export declare function presentCommandMenu(page: CommandMenuPage, fallback: SendContent, snapshot: RuntimeSnapshot, conversation: ConversationRef): Promise<SendContent>;
|
|
50
|
+
/** Rendering dependencies for one menu response; callbacks retain the same generation. */
|
|
51
|
+
export interface CommandMenuReplyContext {
|
|
52
|
+
readonly commands: CommandIndex;
|
|
53
|
+
readonly snapshot: RuntimeSnapshot;
|
|
54
|
+
readonly conversation: ConversationRef;
|
|
55
|
+
readonly prefix: string;
|
|
56
|
+
}
|
|
57
|
+
/** IM-only presentation: Command remains independent of JSX, adapters and callback registries. */
|
|
58
|
+
export declare function commandMenuReply(result: CommandDispatchResult, { commands, snapshot, conversation, prefix }: CommandMenuReplyContext): Promise<SendContent>;
|
|
59
|
+
export {};
|