@zhin.js/core 1.1.35 → 1.1.37
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 +79 -193
- package/lib/built/ai-outbound/index.d.ts +0 -1
- package/lib/built/ai-outbound/index.js +0 -1
- package/lib/built/ai-outbound/types.d.ts +0 -9
- package/lib/built/ai-trigger.d.ts +0 -5
- package/lib/built/ai-trigger.js +1 -27
- package/lib/built/common-adapter-tools.d.ts +0 -2
- package/lib/built/common-adapter-tools.js +0 -4
- package/lib/built/html-segment-fallback.d.ts +2 -5
- package/lib/built/html-segment-fallback.js +0 -15
- 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 +0 -1
- package/lib/built/interactive-segments/resolve.js +0 -1
- package/lib/built/interactive-segments/types.d.ts +0 -5
- package/lib/built/login-assist.d.ts +1 -8
- package/lib/built/message-enrich.d.ts +2 -8
- package/lib/built/message-enrich.js +3 -11
- package/lib/built/segment-contract/validate.d.ts +2 -2
- package/lib/built/segment-contract/validate.js +1 -3
- package/lib/built/tool-access.d.ts +5 -0
- package/lib/built/tool-access.js +17 -0
- package/lib/built/user-interaction.js +0 -4
- package/lib/feature/handler.d.ts +1 -5
- package/lib/index.d.ts +4 -45
- package/lib/index.js +3 -39
- package/lib/message.d.ts +1 -2
- 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 +1 -2
- package/lib/plugin-runtime/im/conversation-runtime.d.ts +19 -0
- package/lib/plugin-runtime/im/conversation-runtime.js +312 -0
- package/lib/plugin-runtime/im/endpoint-runtime.d.ts +79 -0
- package/lib/plugin-runtime/im/endpoint-runtime.js +162 -0
- package/lib/plugin-runtime/im/im-runtime.d.ts +13 -106
- package/lib/plugin-runtime/im/im-runtime.js +58 -1061
- package/lib/plugin-runtime/im/inbound-runtime.d.ts +31 -0
- package/lib/plugin-runtime/im/inbound-runtime.js +252 -0
- package/lib/plugin-runtime/im/index.d.ts +4 -2
- package/lib/plugin-runtime/im/index.js +2 -2
- package/lib/plugin-runtime/im/ingress-route.d.ts +10 -0
- package/lib/plugin-runtime/im/ingress-route.js +10 -0
- package/lib/plugin-runtime/im/interaction-runtime.d.ts +23 -0
- package/lib/plugin-runtime/im/interaction-runtime.js +181 -0
- package/lib/plugin-runtime/im/interactive-router.d.ts +17 -0
- package/lib/plugin-runtime/im/interactive-router.js +98 -0
- package/lib/plugin-runtime/im/message-bus.d.ts +3 -3
- package/lib/plugin-runtime/im/message-bus.js +3 -3
- package/lib/plugin-runtime/im/message-events.d.ts +26 -0
- package/lib/plugin-runtime/im/message-events.js +61 -0
- package/lib/plugin-runtime/im/outbound-delivery-runtime.d.ts +19 -0
- package/lib/plugin-runtime/im/outbound-delivery-runtime.js +165 -0
- package/lib/plugin-runtime/im/outbound-segments.d.ts +2 -3
- package/lib/plugin-runtime/im/outbound-segments.js +3 -4
- package/lib/plugin-runtime/im/runtime-middleware.d.ts +3 -0
- package/lib/plugin-runtime/im/runtime-middleware.js +13 -0
- package/lib/request.d.ts +1 -2
- package/lib/side-event/base.d.ts +1 -2
- package/lib/side-event/normalize.d.ts +1 -5
- package/lib/side-event/normalize.js +1 -11
- package/lib/system-event.d.ts +1 -2
- package/lib/types.d.ts +9 -116
- package/lib/utils.d.ts +51 -24
- package/lib/utils.js +11 -23
- package/package.json +18 -28
- 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/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/endpoint-manager.js +0 -1
- 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/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/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/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/tool-zod.d.ts +0 -43
- package/lib/tool-zod.js +0 -184
package/lib/utils.d.ts
CHANGED
|
@@ -4,24 +4,20 @@
|
|
|
4
4
|
* Generic utilities are re-exported from @zhin.js/kernel.
|
|
5
5
|
* IM-specific utilities (compose, segment) remain here.
|
|
6
6
|
*/
|
|
7
|
-
export { evaluate, execute,
|
|
8
|
-
import {
|
|
7
|
+
export { evaluate, execute, getValueWithRuntime, compiler, remove, isEmpty, Time, supportedPluginExtensions, resolveEntry, sleep, } from '@zhin.js/kernel';
|
|
8
|
+
import { MessageMiddleware, SendContent } from "./types.js";
|
|
9
9
|
import { Message } from "./message.js";
|
|
10
|
-
import { HtmlSegment } from "./built/rich-segments/html-segment.js";
|
|
11
|
-
import { MarkdownSegment } from "./built/rich-segments/markdown-segment.js";
|
|
12
|
-
import { QrcodeSegment } from "./built/rich-segments/qrcode-segment.js";
|
|
13
|
-
import { TtsSegment } from "./built/rich-segments/tts-segment.js";
|
|
14
10
|
import { KeyboardSegment } from "./built/interactive-segments/keyboard-segment.js";
|
|
15
11
|
import { ButtonSpec, type KeyboardRowInput } from "./built/interactive-segments/button-spec.js";
|
|
16
|
-
import type { ButtonData, KeyboardFallback
|
|
12
|
+
import type { ButtonData, KeyboardFallback } from "./built/interactive-segments/types.js";
|
|
17
13
|
import type { MediaRef } from "./built/segment-contract/types.js";
|
|
18
14
|
/**
|
|
19
15
|
* 组合中间件,洋葱模型
|
|
20
16
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
17
|
+
* 空中间件列表时仍调用 terminal `next`,使调用方可以组合自己的
|
|
18
|
+
* generation-owned dispatch stage。
|
|
23
19
|
*/
|
|
24
|
-
export declare function compose
|
|
20
|
+
export declare function compose(middlewares: MessageMiddleware[]): (message: Message, next?: () => Promise<void>) => Promise<void>;
|
|
25
21
|
export declare function segment<T extends object>(type: string, data: T): {
|
|
26
22
|
type: string;
|
|
27
23
|
data: T;
|
|
@@ -62,43 +58,74 @@ export declare namespace segment {
|
|
|
62
58
|
text: string | undefined;
|
|
63
59
|
};
|
|
64
60
|
};
|
|
65
|
-
/** 出站 HTML
|
|
61
|
+
/** 出站 HTML 卡片段(统一出站链路决定渲染或文本降级)。 */
|
|
66
62
|
function htmlCard(options: {
|
|
67
63
|
html: string;
|
|
68
64
|
text?: string;
|
|
69
65
|
width?: number;
|
|
70
66
|
backgroundColor?: string;
|
|
71
67
|
fileName?: string;
|
|
72
|
-
}):
|
|
68
|
+
}): {
|
|
69
|
+
type: string;
|
|
70
|
+
data: {
|
|
71
|
+
html: string;
|
|
72
|
+
text?: string;
|
|
73
|
+
width?: number;
|
|
74
|
+
backgroundColor?: string;
|
|
75
|
+
fileName?: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
73
78
|
/** Short alias for {@link htmlCard}. */
|
|
74
79
|
const html: typeof htmlCard;
|
|
75
|
-
/** 出站 Markdown
|
|
76
|
-
function markdown(content: string, options?:
|
|
77
|
-
|
|
80
|
+
/** 出站 Markdown 段。 */
|
|
81
|
+
function markdown(content: string, options?: {
|
|
82
|
+
width?: number;
|
|
83
|
+
backgroundColor?: string;
|
|
84
|
+
fileName?: string;
|
|
85
|
+
}): {
|
|
86
|
+
type: string;
|
|
87
|
+
data: {
|
|
88
|
+
width?: number;
|
|
89
|
+
backgroundColor?: string;
|
|
90
|
+
fileName?: string;
|
|
91
|
+
content: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
/** 二维码出站段。 */
|
|
78
95
|
function qrcode(text: string, options?: {
|
|
79
96
|
width?: number;
|
|
80
97
|
margin?: number;
|
|
81
98
|
errorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H';
|
|
82
99
|
small?: boolean;
|
|
83
|
-
}):
|
|
84
|
-
|
|
100
|
+
}): {
|
|
101
|
+
type: string;
|
|
102
|
+
data: {
|
|
103
|
+
width?: number;
|
|
104
|
+
margin?: number;
|
|
105
|
+
errorCorrectionLevel?: "L" | "M" | "Q" | "H";
|
|
106
|
+
small?: boolean;
|
|
107
|
+
text: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
/** TTS 出站段。 */
|
|
85
111
|
function tts(options: {
|
|
86
112
|
text: string;
|
|
87
113
|
voice?: string;
|
|
88
114
|
provider?: string;
|
|
89
|
-
}):
|
|
115
|
+
}): {
|
|
116
|
+
type: string;
|
|
117
|
+
data: {
|
|
118
|
+
text: string;
|
|
119
|
+
voice?: string;
|
|
120
|
+
provider?: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
90
123
|
/** 键盘按钮单元(与 {@link keyboard} 组合布局) */
|
|
91
124
|
function button(data: ButtonData): ButtonSpec;
|
|
92
125
|
/** 键盘布局出站段(Adapter interactivePolicy 决定 native/text) */
|
|
93
126
|
function keyboard(rows: KeyboardRowInput[], options?: {
|
|
94
127
|
fallback?: KeyboardFallback;
|
|
95
128
|
}): KeyboardSegment;
|
|
96
|
-
/**
|
|
97
|
-
* @deprecated 使用 {@link keyboard} + {@link button};文本请用 `segment.text` 单独发送
|
|
98
|
-
*/
|
|
99
|
-
function interactive(data: KeyboardSegmentData & {
|
|
100
|
-
text?: SendContent;
|
|
101
|
-
}): KeyboardSegment;
|
|
102
129
|
function from(content: SendContent): SendContent;
|
|
103
130
|
function raw(content: SendContent): string;
|
|
104
131
|
function toString(content: SendContent): string;
|
package/lib/utils.js
CHANGED
|
@@ -7,19 +7,15 @@
|
|
|
7
7
|
import { getLogger } from '@zhin.js/logger';
|
|
8
8
|
const logger = getLogger('Middleware');
|
|
9
9
|
// ── Re-export generic utils from kernel ──
|
|
10
|
-
export { evaluate, execute,
|
|
10
|
+
export { evaluate, execute, getValueWithRuntime, compiler, remove, isEmpty, Time, supportedPluginExtensions, resolveEntry, sleep, } from '@zhin.js/kernel';
|
|
11
11
|
import { formatSegmentPreview } from "./built/segment-contract/preview.js";
|
|
12
|
-
import { HtmlSegment } from "./built/rich-segments/html-segment.js";
|
|
13
|
-
import { MarkdownSegment } from "./built/rich-segments/markdown-segment.js";
|
|
14
|
-
import { QrcodeSegment } from "./built/rich-segments/qrcode-segment.js";
|
|
15
|
-
import { TtsSegment } from "./built/rich-segments/tts-segment.js";
|
|
16
12
|
import { KeyboardSegment } from "./built/interactive-segments/keyboard-segment.js";
|
|
17
13
|
import { ButtonSpec, normalizeKeyboardRows } from "./built/interactive-segments/button-spec.js";
|
|
18
14
|
/**
|
|
19
15
|
* 组合中间件,洋葱模型
|
|
20
16
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
17
|
+
* 空中间件列表时仍调用 terminal `next`,使调用方可以组合自己的
|
|
18
|
+
* generation-owned dispatch stage。
|
|
23
19
|
*/
|
|
24
20
|
export function compose(middlewares) {
|
|
25
21
|
return function (message, next = () => Promise.resolve()) {
|
|
@@ -93,26 +89,26 @@ export function segment(type, data) {
|
|
|
93
89
|
return segment("face", { id, text });
|
|
94
90
|
}
|
|
95
91
|
segment.face = face;
|
|
96
|
-
/** 出站 HTML
|
|
92
|
+
/** 出站 HTML 卡片段(统一出站链路决定渲染或文本降级)。 */
|
|
97
93
|
function htmlCard(options) {
|
|
98
|
-
return
|
|
94
|
+
return segment("html", options);
|
|
99
95
|
}
|
|
100
96
|
segment.htmlCard = htmlCard;
|
|
101
97
|
/** Short alias for {@link htmlCard}. */
|
|
102
98
|
segment.html = htmlCard;
|
|
103
|
-
/** 出站 Markdown
|
|
99
|
+
/** 出站 Markdown 段。 */
|
|
104
100
|
function markdown(content, options = {}) {
|
|
105
|
-
return
|
|
101
|
+
return segment("markdown", { content, ...options });
|
|
106
102
|
}
|
|
107
103
|
segment.markdown = markdown;
|
|
108
|
-
/**
|
|
104
|
+
/** 二维码出站段。 */
|
|
109
105
|
function qrcode(text, options = {}) {
|
|
110
|
-
return
|
|
106
|
+
return segment("qrcode", { text, ...options });
|
|
111
107
|
}
|
|
112
108
|
segment.qrcode = qrcode;
|
|
113
|
-
/** TTS
|
|
109
|
+
/** TTS 出站段。 */
|
|
114
110
|
function tts(options) {
|
|
115
|
-
return
|
|
111
|
+
return segment("tts", options);
|
|
116
112
|
}
|
|
117
113
|
segment.tts = tts;
|
|
118
114
|
/** 键盘按钮单元(与 {@link keyboard} 组合布局) */
|
|
@@ -128,14 +124,6 @@ export function segment(type, data) {
|
|
|
128
124
|
});
|
|
129
125
|
}
|
|
130
126
|
segment.keyboard = keyboard;
|
|
131
|
-
/**
|
|
132
|
-
* @deprecated 使用 {@link keyboard} + {@link button};文本请用 `segment.text` 单独发送
|
|
133
|
-
*/
|
|
134
|
-
function interactive(data) {
|
|
135
|
-
const { text: _text, rows, fallback } = data;
|
|
136
|
-
return keyboard(rows, { fallback });
|
|
137
|
-
}
|
|
138
|
-
segment.interactive = interactive;
|
|
139
127
|
function from(content) {
|
|
140
128
|
if (!Array.isArray(content))
|
|
141
129
|
content = [content];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.37",
|
|
4
4
|
"description": "Zhin机器人核心框架",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -11,11 +11,6 @@
|
|
|
11
11
|
"development": "./src/index.ts",
|
|
12
12
|
"import": "./lib/index.js"
|
|
13
13
|
},
|
|
14
|
-
"./tool-zod": {
|
|
15
|
-
"types": "./lib/tool-zod.d.ts",
|
|
16
|
-
"development": "./src/tool-zod.ts",
|
|
17
|
-
"import": "./lib/tool-zod.js"
|
|
18
|
-
},
|
|
19
14
|
"./queue-im-field-contract": {
|
|
20
15
|
"types": "./lib/built/queue-im-field-contract.d.ts",
|
|
21
16
|
"development": "./src/built/queue-im-field-contract.ts",
|
|
@@ -73,36 +68,27 @@
|
|
|
73
68
|
"dependencies": {
|
|
74
69
|
"qrcode": "^1.5.4",
|
|
75
70
|
"segment-matcher": "^1.0.5",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"@zhin.js/
|
|
79
|
-
"@zhin.js/
|
|
80
|
-
"@zhin.js/
|
|
81
|
-
"@zhin.js/
|
|
82
|
-
"@zhin.js/handler": "1.1.0",
|
|
83
|
-
"@zhin.js/im-contract": "1.1.0",
|
|
71
|
+
"@zhin.js/adapter": "1.1.14",
|
|
72
|
+
"@zhin.js/command": "1.1.1",
|
|
73
|
+
"@zhin.js/component": "1.1.1",
|
|
74
|
+
"@zhin.js/database": "1.1.1",
|
|
75
|
+
"@zhin.js/handler": "1.1.1",
|
|
76
|
+
"@zhin.js/im-contract": "1.1.1",
|
|
84
77
|
"@zhin.js/interaction": "1.1.0",
|
|
85
|
-
"@zhin.js/kernel": "1.1.
|
|
86
|
-
"@zhin.js/logger": "1.1.
|
|
87
|
-
"@zhin.js/middleware": "1.1.
|
|
88
|
-
"@zhin.js/permission": "1.1.
|
|
89
|
-
"@zhin.js/plugin-runtime": "1.1.
|
|
78
|
+
"@zhin.js/kernel": "1.1.1",
|
|
79
|
+
"@zhin.js/logger": "1.1.1",
|
|
80
|
+
"@zhin.js/middleware": "1.1.1",
|
|
81
|
+
"@zhin.js/permission": "1.1.1",
|
|
82
|
+
"@zhin.js/plugin-runtime": "1.1.10",
|
|
83
|
+
"@zhin.js/schedule-feature": "1.1.1",
|
|
90
84
|
"@zhin.js/schema": "1.1.0"
|
|
91
85
|
},
|
|
92
|
-
"peerDependencies": {
|
|
93
|
-
"zod": "^4.0.0"
|
|
94
|
-
},
|
|
95
|
-
"peerDependenciesMeta": {
|
|
96
|
-
"zod": {
|
|
97
|
-
"optional": true
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
86
|
"devDependencies": {
|
|
101
87
|
"@types/node": "^26.1.2",
|
|
102
88
|
"@types/qrcode": "^1.5.6",
|
|
103
89
|
"ajv": "8.18.0",
|
|
104
90
|
"typescript": "^6.0.3",
|
|
105
|
-
"@zhin.js/ai": "1.1.
|
|
91
|
+
"@zhin.js/ai": "1.1.34"
|
|
106
92
|
},
|
|
107
93
|
"repository": {
|
|
108
94
|
"type": "git",
|
|
@@ -148,6 +134,10 @@
|
|
|
148
134
|
{
|
|
149
135
|
"package": "@zhin.js/handler",
|
|
150
136
|
"api": "^1.0.0"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"package": "@zhin.js/schedule-feature",
|
|
140
|
+
"api": "^1.0.0"
|
|
151
141
|
}
|
|
152
142
|
],
|
|
153
143
|
"plugins": []
|
package/lib/adapter.d.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { Endpoint } from "./endpoint.js";
|
|
2
|
-
import { DEFAULT_ENDPOINT_CAPABILITIES, type EndpointCapability } from "./endpoint-capabilities.js";
|
|
3
|
-
import type { EndpointManager } from "./built/endpoint-manager.js";
|
|
4
|
-
import { Plugin } from "./plugin.js";
|
|
5
|
-
import { EventEmitter } from "node:events";
|
|
6
|
-
import { Message } from "./message.js";
|
|
7
|
-
import { Notice } from "./notice.js";
|
|
8
|
-
import { Request } from "./request.js";
|
|
9
|
-
import { EditMessageOptions, SendOptions } from "./types.js";
|
|
10
|
-
import { type OutboundRichSegmentPolicy } from "./built/rich-segments/index.js";
|
|
11
|
-
import { type InteractivePolicy } from "./built/interactive-segments/index.js";
|
|
12
|
-
import { type AiOutboundCapabilities, type AiOutboundExtensionDefinition } from "./built/ai-outbound/index.js";
|
|
13
|
-
import type { Schema } from '@zhin.js/schema';
|
|
14
|
-
/**
|
|
15
|
-
* Adapter类:适配器抽象,管理多平台Bot实例。
|
|
16
|
-
* 负责根据配置启动/关闭各平台机器人,统一异常处理。
|
|
17
|
-
*
|
|
18
|
-
* 适配器可以提供 AI 工具,供 AI 服务调用。
|
|
19
|
-
*/
|
|
20
|
-
export declare abstract class Adapter<R extends Endpoint = Endpoint, const Caps extends readonly EndpointCapability[] = typeof DEFAULT_ENDPOINT_CAPABILITIES> extends EventEmitter<Adapter.Lifecycle> {
|
|
21
|
-
#private;
|
|
22
|
-
plugin: Plugin;
|
|
23
|
-
name: keyof Plugin.Contexts;
|
|
24
|
-
config: Adapter.EndpointConfig<R>[];
|
|
25
|
-
endpoints: Map<string, R>;
|
|
26
|
-
private recallMessageHandler;
|
|
27
|
-
/** Adapter 支持的能力上限(子类覆盖) */
|
|
28
|
-
static readonly capabilities: readonly EndpointCapability[];
|
|
29
|
-
/** 出站富媒体段渲染策略(子类 override static) */
|
|
30
|
-
static outboundRichSegmentPolicy: OutboundRichSegmentPolicy;
|
|
31
|
-
/** 交互段出站策略:native 保留按钮段,text 降级为编号文本 */
|
|
32
|
-
static interactivePolicy: InteractivePolicy;
|
|
33
|
-
/** AI 结构化出站能力声明(mentions / richSegments / interactive) */
|
|
34
|
-
static aiOutboundCapabilities: AiOutboundCapabilities;
|
|
35
|
-
/** 平台特有 extensions schema + 解析(对齐各 SDK 文档子集) */
|
|
36
|
-
static aiOutboundExtensions?: readonly AiOutboundExtensionDefinition[];
|
|
37
|
-
protected getInteractivePolicy(): InteractivePolicy;
|
|
38
|
-
/** 并发上限,0 表示不限制(默认) */
|
|
39
|
-
static DEFAULT_MAX_CONCURRENT_MESSAGES: number;
|
|
40
|
-
get maxConcurrentMessages(): number;
|
|
41
|
-
/** 当前正在处理的消息数 */
|
|
42
|
-
get pendingMessages(): number;
|
|
43
|
-
/**
|
|
44
|
-
* 创建一个适配器运行实例。
|
|
45
|
-
* @param plugin 拥有该适配器的插件实例
|
|
46
|
-
* @param name 适配器名称(如 'process'、'qq' 等)
|
|
47
|
-
* @param config Endpoint 配置列表
|
|
48
|
-
*/
|
|
49
|
-
constructor(plugin: Plugin, name: keyof Plugin.Contexts, config: Adapter.EndpointConfig<R>[]);
|
|
50
|
-
/** 入站消息管线(替代 emit override 的隐式管线) */
|
|
51
|
-
private inboundPipeline;
|
|
52
|
-
/**
|
|
53
|
-
* 重写 emit:拦截 message.receive/notice.receive/request.receive 事件,
|
|
54
|
-
* 将入站处理委托给 InboundMessagePipeline。
|
|
55
|
-
*/
|
|
56
|
-
emit: EventEmitter<Adapter.Lifecycle>['emit'];
|
|
57
|
-
abstract createEndpoint(config: Adapter.EndpointConfig<R>): R;
|
|
58
|
-
get logger(): import("@zhin.js/logger").Logger;
|
|
59
|
-
binding(plugin: Plugin): void;
|
|
60
|
-
/**
|
|
61
|
-
* 同步等待入站管线结束(middleware → dispatcher → 生命周期 → 观察者)。
|
|
62
|
-
* 用于 QQ 等需在被动回复完成后再 ack 交互的平台事件。
|
|
63
|
-
*/
|
|
64
|
-
receiveMessageAwait(message: Message): Promise<boolean>;
|
|
65
|
-
/** 运行时 Endpoint 管理(add/remove/edit/start/stop);未实现则 core 尝试 endpointConfigSchema 通用向导 */
|
|
66
|
-
getEndpointManager?(): EndpointManager | null;
|
|
67
|
-
/** 通用 schema 驱动 add/edit 时的字段定义 */
|
|
68
|
-
getEndpointConfigSchema?(): Schema | undefined;
|
|
69
|
-
/** 热连接失败时是否建议重启进程 */
|
|
70
|
-
getEndpointNeedsRestart?(): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* 出站富媒体能力(Publisher 按此过滤/降级;各 adapter 可覆盖)。
|
|
73
|
-
*/
|
|
74
|
-
getOutboundMediaCapabilities(): {
|
|
75
|
-
image?: boolean;
|
|
76
|
-
audio?: boolean;
|
|
77
|
-
video?: boolean;
|
|
78
|
-
file?: boolean;
|
|
79
|
-
maxAttachmentBytes?: number;
|
|
80
|
-
};
|
|
81
|
-
protected getOutboundRichSegmentPolicy(): OutboundRichSegmentPolicy;
|
|
82
|
-
/**
|
|
83
|
-
* 出站两阶段:
|
|
84
|
-
* 1. resolveRichSegments — 语义段 → 标准 IM 段(image/audio/text)
|
|
85
|
-
* 2. Endpoint materializeOutboundMedia — base64/本地路径 → 平台 URL(各 adapter 可选)
|
|
86
|
-
* @see docs/essentials/rich-segment-adapters.md
|
|
87
|
-
*/
|
|
88
|
-
protected renderSendMessage(options: SendOptions): Promise<SendOptions>;
|
|
89
|
-
sendMessage(options: SendOptions): Promise<string>;
|
|
90
|
-
/**
|
|
91
|
-
* `call.recallMessage` 事件链(prompt.ts 超时撤回等)的统一出口:
|
|
92
|
-
* 经 canonical `EndpointControl` 端口撤回。
|
|
93
|
-
*/
|
|
94
|
-
private recallEndpointMessage;
|
|
95
|
-
/**
|
|
96
|
-
* 编辑已发送的消息。
|
|
97
|
-
* - 如果 Endpoint 的 control 端口实现了 edit,调用平台编辑 API
|
|
98
|
-
* - 否则 fallback 到发送新消息
|
|
99
|
-
* @returns 消息 ID(编辑时返回原 ID,fallback 时返回新消息 ID)
|
|
100
|
-
*/
|
|
101
|
-
editMessage(options: EditMessageOptions): Promise<string>;
|
|
102
|
-
start(): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* 停止适配器,断开并移除所有 Endpoint 实例
|
|
105
|
-
*/
|
|
106
|
-
stop(): Promise<void>;
|
|
107
|
-
}
|
|
108
|
-
export interface Adapters {
|
|
109
|
-
}
|
|
110
|
-
/** Per-adapter live Endpoint class map for HandlerContext.$endpoint() typing. */
|
|
111
|
-
export interface AdapterEndpoints {
|
|
112
|
-
}
|
|
113
|
-
export declare namespace Adapter {
|
|
114
|
-
type Factory<R extends Adapter = Adapter> = {
|
|
115
|
-
new (plugin: Plugin, name: string, config: Adapter.EndpointConfig<Adapter.InferEndpoint<R>>[]): R;
|
|
116
|
-
};
|
|
117
|
-
interface Lifecycle {
|
|
118
|
-
'message.receive': [Message];
|
|
119
|
-
'message.private.receive': [Message];
|
|
120
|
-
'message.group.receive': [Message];
|
|
121
|
-
'message.channel.receive': [Message];
|
|
122
|
-
'notice.receive': [Notice];
|
|
123
|
-
'request.receive': [Request];
|
|
124
|
-
'call.recallMessage': [string, string];
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* 适配器工厂注册表
|
|
128
|
-
* 灵感来源于 zhinjs/next 的 Adapter.Registry
|
|
129
|
-
*/
|
|
130
|
-
const Registry: Map<string, Factory<Adapter<Endpoint, readonly EndpointCapability[]>>>;
|
|
131
|
-
type InferEndpoint<R extends Adapter = Adapter> = R extends Adapter<infer T> ? T : never;
|
|
132
|
-
type EndpointConfig<T extends Endpoint> = T extends Endpoint<infer R> ? R : never;
|
|
133
|
-
type EndpointMessage<T extends Endpoint> = T extends Endpoint<infer _L, infer R> ? R : never;
|
|
134
|
-
/**
|
|
135
|
-
* 注册适配器工厂
|
|
136
|
-
*
|
|
137
|
-
* @param name 适配器名称
|
|
138
|
-
* @param factory 适配器工厂函数
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* Adapter.register('icqq', IcqqAdapter);
|
|
142
|
-
* ```
|
|
143
|
-
*/
|
|
144
|
-
function register(name: string, factory: Factory): void;
|
|
145
|
-
}
|