@zhin.js/core 1.1.34 → 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 +84 -142
- package/lib/built/ai-access.d.ts +36 -0
- package/lib/built/ai-access.js +46 -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 +8 -0
- package/lib/built/ai-outbound/index.js +8 -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 +49 -0
- package/lib/built/ai-outbound/types.js +5 -0
- package/lib/built/ai-trigger.d.ts +12 -17
- package/lib/built/ai-trigger.js +39 -70
- package/lib/built/common-adapter-tools.d.ts +33 -29
- package/lib/built/common-adapter-tools.js +79 -67
- 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-segment-fallback.d.ts +2 -5
- package/lib/built/html-segment-fallback.js +0 -16
- package/lib/built/html-to-text.d.ts +0 -1
- package/lib/built/html-to-text.js +15 -15
- 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/index.d.ts +6 -0
- package/lib/built/interactive-segments/index.js +6 -0
- package/lib/built/interactive-segments/keyboard-segment.d.ts +10 -0
- package/lib/built/interactive-segments/keyboard-segment.js +11 -0
- package/lib/built/interactive-segments/onebot-keyboard.d.ts +6 -0
- package/lib/built/interactive-segments/onebot-keyboard.js +49 -0
- package/lib/built/interactive-segments/resolve.d.ts +14 -0
- package/lib/built/interactive-segments/resolve.js +109 -0
- package/lib/built/interactive-segments/types.d.ts +45 -0
- package/lib/built/interactive-segments/types.js +9 -0
- package/lib/built/login-assist.d.ts +43 -16
- package/lib/built/login-assist.js +113 -11
- package/lib/built/message-enrich.d.ts +32 -0
- package/lib/built/message-enrich.js +67 -0
- package/lib/built/outbound-media-utils.d.ts +9 -0
- package/lib/built/outbound-media-utils.js +62 -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/markdown-to-text.d.ts +3 -0
- package/lib/built/rich-segments/markdown-to-text.js +27 -0
- package/lib/built/roles.d.ts +4 -5
- package/lib/built/roles.js +4 -5
- 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 +172 -0
- package/lib/built/tool-access.d.ts +5 -0
- package/lib/built/tool-access.js +17 -0
- package/lib/built/user-interaction.d.ts +30 -0
- package/lib/built/user-interaction.js +244 -0
- package/lib/component.d.ts +0 -1
- package/lib/component.js +30 -14
- 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 +48 -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/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 +29 -36
- package/lib/index.js +27 -41
- 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 +17 -12
- package/lib/message.js +16 -13
- package/lib/models/system-log.d.ts +0 -3
- package/lib/models/system-log.js +1 -9
- package/lib/models/user.d.ts +0 -3
- package/lib/models/user.js +1 -8
- package/lib/notice.d.ts +16 -60
- package/lib/notice.js +1 -4
- package/lib/plugin-runtime/im/contracts.d.ts +191 -0
- package/lib/plugin-runtime/im/contracts.js +169 -0
- 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 +84 -0
- package/lib/plugin-runtime/im/im-runtime.js +201 -0
- 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 +11 -0
- package/lib/plugin-runtime/im/index.js +9 -0
- 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/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/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-renderer.d.ts +7 -0
- package/lib/plugin-runtime/im/outbound-renderer.js +70 -0
- package/lib/plugin-runtime/im/outbound-segments.d.ts +71 -0
- package/lib/plugin-runtime/im/outbound-segments.js +219 -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/runtime-middleware.d.ts +3 -0
- package/lib/plugin-runtime/im/runtime-middleware.js +13 -0
- package/lib/request.d.ts +17 -62
- package/lib/request.js +0 -4
- package/lib/side-event/base.d.ts +51 -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 +38 -0
- package/lib/side-event/normalize.js +111 -0
- package/lib/side-event/types.d.ts +23 -0
- package/lib/side-event/types.js +55 -0
- package/lib/system-event.d.ts +14 -0
- package/lib/system-event.js +7 -0
- package/lib/types.d.ts +35 -193
- package/lib/types.js +0 -1
- package/lib/utils.d.ts +81 -6
- package/lib/utils.js +54 -25
- package/package.json +94 -16
- package/lib/adapter.d.ts +0 -96
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js +0 -217
- 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 +0 -43
- package/lib/built/adapter-process.d.ts.map +0 -1
- package/lib/built/adapter-process.js +0 -81
- package/lib/built/adapter-process.js.map +0 -1
- package/lib/built/agent-preset.d.ts +0 -65
- package/lib/built/agent-preset.d.ts.map +0 -1
- package/lib/built/agent-preset.js +0 -80
- 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 +0 -68
- package/lib/built/command.d.ts.map +0 -1
- package/lib/built/command.js +0 -92
- 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 +0 -69
- package/lib/built/component.d.ts.map +0 -1
- package/lib/built/component.js +0 -99
- package/lib/built/component.js.map +0 -1
- package/lib/built/config.d.ts +0 -99
- package/lib/built/config.d.ts.map +0 -1
- package/lib/built/config.js +0 -355
- 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 +0 -66
- package/lib/built/database.d.ts.map +0 -1
- package/lib/built/database.js +0 -100
- package/lib/built/database.js.map +0 -1
- package/lib/built/dispatcher.d.ts +0 -139
- package/lib/built/dispatcher.d.ts.map +0 -1
- package/lib/built/dispatcher.js +0 -361
- 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 +0 -23
- package/lib/built/inbound-runner.d.ts.map +0 -1
- package/lib/built/inbound-runner.js +0 -37
- 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 +0 -177
- package/lib/built/message-filter.d.ts.map +0 -1
- package/lib/built/message-filter.js +0 -241
- package/lib/built/message-filter.js.map +0 -1
- package/lib/built/permission.d.ts +0 -55
- package/lib/built/permission.d.ts.map +0 -1
- package/lib/built/permission.js +0 -112
- 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 +0 -10
- package/lib/built/runtime-io.d.ts.map +0 -1
- package/lib/built/runtime-io.js +0 -68
- package/lib/built/runtime-io.js.map +0 -1
- package/lib/built/schema-feature.d.ts +0 -78
- package/lib/built/schema-feature.d.ts.map +0 -1
- package/lib/built/schema-feature.js +0 -132
- package/lib/built/schema-feature.js.map +0 -1
- package/lib/built/skill.d.ts +0 -121
- package/lib/built/skill.d.ts.map +0 -1
- package/lib/built/skill.js +0 -152
- package/lib/built/skill.js.map +0 -1
- package/lib/built/tool.d.ts +0 -150
- package/lib/built/tool.d.ts.map +0 -1
- package/lib/built/tool.js +0 -383
- package/lib/built/tool.js.map +0 -1
- package/lib/command.d.ts +0 -42
- package/lib/command.d.ts.map +0 -1
- package/lib/command.js +0 -75
- 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 +0 -258
- package/lib/plugin.d.ts.map +0 -1
- package/lib/plugin.js +0 -688
- package/lib/plugin.js.map +0 -1
- package/lib/prompt.d.ts +0 -118
- package/lib/prompt.d.ts.map +0 -1
- package/lib/prompt.js +0 -244
- 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 +0 -28
- package/lib/tool-zod.d.ts.map +0 -1
- package/lib/tool-zod.js +0 -98
- 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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AiOutboundCapabilities, AiOutboundExtensionDefinition } from './types.js';
|
|
2
|
+
export declare const AI_OUTBOUND_JSON_EXAMPLE = "{\"mentions\":[\"researcher\",\"210723495\"],\"text\":\"\u6B63\u6587\"}";
|
|
3
|
+
export declare function buildCoreAiOutboundPromptHint(capabilities?: AiOutboundCapabilities): string;
|
|
4
|
+
export declare function buildAiOutboundPromptHint(input: {
|
|
5
|
+
capabilities?: AiOutboundCapabilities;
|
|
6
|
+
extensions?: readonly AiOutboundExtensionDefinition[];
|
|
7
|
+
rosterLines?: string[];
|
|
8
|
+
forceJsonOnly?: boolean;
|
|
9
|
+
}): string;
|
|
10
|
+
/** Detect whether inbound text explicitly requests a structured handoff. */
|
|
11
|
+
export declare function detectInboundHandoffIntent(content: string): boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export const AI_OUTBOUND_JSON_EXAMPLE = '{"mentions":["researcher","210723495"],"text":"正文"}';
|
|
2
|
+
export function buildCoreAiOutboundPromptHint(capabilities) {
|
|
3
|
+
const lines = [
|
|
4
|
+
'When your reply must @ peers, send rich media, buttons, or delegate — output JSON only (no Markdown wrapper):',
|
|
5
|
+
AI_OUTBOUND_JSON_EXAMPLE,
|
|
6
|
+
'mentions: peer endpoint ID or pipelineRole; text: message body.',
|
|
7
|
+
'Do NOT write "@researcher" in plain text — the framework converts JSON mentions to real platform @ segments.',
|
|
8
|
+
];
|
|
9
|
+
if (capabilities?.richSegments?.length) {
|
|
10
|
+
lines.push(`Rich segments (optional "segments" array): ${capabilities.richSegments.join(', ')}.`);
|
|
11
|
+
}
|
|
12
|
+
if (capabilities?.interactive === 'native') {
|
|
13
|
+
lines.push('Interactive buttons: use extensions field per adapter schema.');
|
|
14
|
+
}
|
|
15
|
+
return lines.join('\n');
|
|
16
|
+
}
|
|
17
|
+
export function buildAiOutboundPromptHint(input) {
|
|
18
|
+
const lines = [];
|
|
19
|
+
if (input.rosterLines?.length) {
|
|
20
|
+
lines.push(...input.rosterLines);
|
|
21
|
+
}
|
|
22
|
+
lines.push(buildCoreAiOutboundPromptHint(input.capabilities));
|
|
23
|
+
if (input.extensions?.length) {
|
|
24
|
+
lines.push('Adapter extensions (optional "extensions" object):');
|
|
25
|
+
for (const ext of input.extensions) {
|
|
26
|
+
lines.push(`- ${ext.key}: see platform schema`);
|
|
27
|
+
if (ext.examples[0])
|
|
28
|
+
lines.push(` example: ${ext.examples[0]}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (input.forceJsonOnly) {
|
|
32
|
+
lines.push('MUST reply with JSON only when @ peers or handoff — no Markdown body with plain "@role" text.');
|
|
33
|
+
}
|
|
34
|
+
return lines.join('\n');
|
|
35
|
+
}
|
|
36
|
+
/** Detect whether inbound text explicitly requests a structured handoff. */
|
|
37
|
+
export function detectInboundHandoffIntent(content) {
|
|
38
|
+
const t = content.trim();
|
|
39
|
+
if (!t)
|
|
40
|
+
return false;
|
|
41
|
+
if (t.includes('@'))
|
|
42
|
+
return true;
|
|
43
|
+
return /依次|自我介绍|叫大家|请各位|handoff|delegate/i.test(t);
|
|
44
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MessageElement } from '../../types.js';
|
|
2
|
+
import type { AiOutboundParseContext, ZhinAiOutboundPayload } from './types.js';
|
|
3
|
+
/** 将 ZhinAiOutboundPayload 转为 MessageElement[](canonical segments + extensions)。 */
|
|
4
|
+
export declare function resolveAiOutboundToMessageElements(payload: ZhinAiOutboundPayload, ctx: AiOutboundParseContext): Promise<MessageElement[] | null>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { segmentsForImDelivery } from '../segment-contract/delivery.js';
|
|
2
|
+
function buildMentionSegments(endpointKeys, text, ctx) {
|
|
3
|
+
const segments = [];
|
|
4
|
+
for (const endpointKey of endpointKeys) {
|
|
5
|
+
const target = ctx.atIdResolver?.(endpointKey) ?? endpointKey;
|
|
6
|
+
segments.push({ type: 'mention', data: { target } });
|
|
7
|
+
}
|
|
8
|
+
const body = text.trim();
|
|
9
|
+
segments.push({
|
|
10
|
+
type: 'text',
|
|
11
|
+
data: { text: body.startsWith(' ') ? body : ` ${body}` },
|
|
12
|
+
});
|
|
13
|
+
return segments;
|
|
14
|
+
}
|
|
15
|
+
function resolveMentionEndpointIds(mentions, ctx) {
|
|
16
|
+
if (!mentions?.length) {
|
|
17
|
+
return { ok: false, error: 'mentions 不能为空' };
|
|
18
|
+
}
|
|
19
|
+
if (!ctx.mentionResolver) {
|
|
20
|
+
return { ok: false, error: 'mentionResolver 未配置' };
|
|
21
|
+
}
|
|
22
|
+
const endpointKeys = [];
|
|
23
|
+
for (const ref of mentions) {
|
|
24
|
+
const resolved = ctx.mentionResolver(ref);
|
|
25
|
+
if (!resolved) {
|
|
26
|
+
return { ok: false, error: `未知 peer "${ref}"` };
|
|
27
|
+
}
|
|
28
|
+
if (!endpointKeys.includes(resolved))
|
|
29
|
+
endpointKeys.push(resolved);
|
|
30
|
+
}
|
|
31
|
+
return { ok: true, endpointKeys };
|
|
32
|
+
}
|
|
33
|
+
/** 将 ZhinAiOutboundPayload 转为 MessageElement[](canonical segments + extensions)。 */
|
|
34
|
+
export async function resolveAiOutboundToMessageElements(payload, ctx) {
|
|
35
|
+
const segments = [];
|
|
36
|
+
if (payload.mentions?.length) {
|
|
37
|
+
const resolved = resolveMentionEndpointIds(payload.mentions, ctx);
|
|
38
|
+
if (!resolved.ok)
|
|
39
|
+
return null;
|
|
40
|
+
const text = payload.text?.trim() ?? '';
|
|
41
|
+
if (!text)
|
|
42
|
+
return null;
|
|
43
|
+
segments.push(...buildMentionSegments(resolved.endpointKeys, text, ctx));
|
|
44
|
+
}
|
|
45
|
+
else if (payload.text?.trim()) {
|
|
46
|
+
segments.push({ type: 'text', data: { text: payload.text.trim() } });
|
|
47
|
+
}
|
|
48
|
+
if (payload.segments?.length) {
|
|
49
|
+
segments.push(...payload.segments);
|
|
50
|
+
}
|
|
51
|
+
const parts = segments.length
|
|
52
|
+
? segmentsForImDelivery(segments)
|
|
53
|
+
: [];
|
|
54
|
+
if (payload.extensions && ctx.extensions?.length) {
|
|
55
|
+
for (const def of ctx.extensions) {
|
|
56
|
+
const ext = payload.extensions[def.key];
|
|
57
|
+
if (ext == null || !def.toMessageElements)
|
|
58
|
+
continue;
|
|
59
|
+
const extSegments = await def.toMessageElements(ext, ctx);
|
|
60
|
+
parts.push(...(Array.isArray(extSegments) ? extSegments : [extSegments]));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return parts.length ? parts : null;
|
|
64
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Message } from '../../message.js';
|
|
2
|
+
import type { MessageElement } from '../../types.js';
|
|
3
|
+
import type { InteractivePolicy } from '../interactive-segments/types.js';
|
|
4
|
+
import type { Segment } from '../segment-contract/types.js';
|
|
5
|
+
/** AI 结构化出站 payload — 平台无关 DSL(Adapter extensions 承载平台特有段)。 */
|
|
6
|
+
export interface ZhinAiOutboundPayload {
|
|
7
|
+
text?: string;
|
|
8
|
+
mentions?: string[];
|
|
9
|
+
segments?: Segment[];
|
|
10
|
+
extensions?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export interface AiOutboundCapabilities {
|
|
13
|
+
mentions?: boolean;
|
|
14
|
+
richSegments?: readonly string[];
|
|
15
|
+
interactive?: InteractivePolicy;
|
|
16
|
+
}
|
|
17
|
+
export interface AiOutboundExtensionDefinition {
|
|
18
|
+
/** 平台扩展字段名,如 qq.ark / onebot.keyboard */
|
|
19
|
+
key: string;
|
|
20
|
+
/** JSON Schema 子集,对齐平台 SDK 文档 */
|
|
21
|
+
schema: Record<string, unknown>;
|
|
22
|
+
examples: readonly string[];
|
|
23
|
+
toMessageElements?: (ext: unknown, ctx: AiOutboundParseContext) => MessageElement[] | Promise<MessageElement[]>;
|
|
24
|
+
}
|
|
25
|
+
export interface AiOutboundMentionResolver {
|
|
26
|
+
(ref: string): string | undefined;
|
|
27
|
+
}
|
|
28
|
+
export interface AiOutboundAtIdResolver {
|
|
29
|
+
(endpointKey: string): string;
|
|
30
|
+
}
|
|
31
|
+
/** 解析 AI 出站 JSON 时的上下文。 */
|
|
32
|
+
export interface AiOutboundParseContext {
|
|
33
|
+
message: Message;
|
|
34
|
+
/** 将 peer ref(role/endpoint/primary)解析为 endpointKey */
|
|
35
|
+
mentionResolver?: AiOutboundMentionResolver;
|
|
36
|
+
/** 将 endpointKey 解析为 platform @ id */
|
|
37
|
+
atIdResolver?: AiOutboundAtIdResolver;
|
|
38
|
+
/** Adapter 声明的 extensions(运行时从 Adapter 静态属性注入) */
|
|
39
|
+
extensions?: readonly AiOutboundExtensionDefinition[];
|
|
40
|
+
}
|
|
41
|
+
export interface StructuredOutboundDetectInput {
|
|
42
|
+
/** 工具链要求结构化出站。 */
|
|
43
|
+
toolRequiresStructured?: boolean;
|
|
44
|
+
/** 用户入站含 handoff / @ 意图 */
|
|
45
|
+
inboundHandoffIntent?: boolean;
|
|
46
|
+
/** Adapter 声明 extensions 且非空 */
|
|
47
|
+
adapterHasExtensions?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare const DEFAULT_AI_OUTBOUND_CAPABILITIES: AiOutboundCapabilities;
|
|
@@ -37,8 +37,6 @@ export interface AITriggerConfig {
|
|
|
37
37
|
masters?: string[];
|
|
38
38
|
/** 全局 trusted(trigger 级) */
|
|
39
39
|
trusted?: string[];
|
|
40
|
-
/** 是否在 AI 入参前拉取 $quote_id 对应消息正文(默认 true) */
|
|
41
|
-
resolveQuotedMessages?: boolean;
|
|
42
40
|
}
|
|
43
41
|
/**
|
|
44
42
|
* AI 触发检查结果
|
|
@@ -49,8 +47,8 @@ export interface AITriggerResult {
|
|
|
49
47
|
}
|
|
50
48
|
/** shouldTriggerAI 可选参数(如适配器提供的平台 @ ID) */
|
|
51
49
|
export interface AITriggerOptions {
|
|
52
|
-
/** 用于 @ 匹配的
|
|
53
|
-
|
|
50
|
+
/** 用于 @ 匹配的 Endpoint 标识符(默认仅 message.$endpoint) */
|
|
51
|
+
endpointAtIds?: string[];
|
|
54
52
|
}
|
|
55
53
|
/** 发送者角色解析结果 */
|
|
56
54
|
export interface SenderRolesResult {
|
|
@@ -59,13 +57,13 @@ export interface SenderRolesResult {
|
|
|
59
57
|
}
|
|
60
58
|
export declare const DEFAULT_AI_TRIGGER_CONFIG: Required<AITriggerConfig>;
|
|
61
59
|
/**
|
|
62
|
-
* 收集用于 @ 匹配的
|
|
60
|
+
* 收集用于 @ 匹配的 Endpoint 标识符
|
|
63
61
|
*/
|
|
64
|
-
export declare function
|
|
62
|
+
export declare function collectEndpointAtIds<T extends object>(message: Message<T>, extraIds?: string[]): string[];
|
|
65
63
|
/**
|
|
66
|
-
* 检查消息是否 @
|
|
64
|
+
* 检查消息是否 @ 了 Endpoint
|
|
67
65
|
*/
|
|
68
|
-
export declare function
|
|
66
|
+
export declare function isAtEndpoint<T extends object>(message: Message<T>, endpointAtIds?: string[]): boolean;
|
|
69
67
|
/**
|
|
70
68
|
* 提取消息文本内容(保留富媒体信息)
|
|
71
69
|
* 使用 segment.toString 将 MessageElement 转为 XML 格式
|
|
@@ -77,20 +75,18 @@ export declare function extractTextContent<T extends object>(message: Message<T>
|
|
|
77
75
|
*/
|
|
78
76
|
export declare function parseRichMediaContent(content: string): MessageElement[];
|
|
79
77
|
/**
|
|
80
|
-
* 移除 @
|
|
78
|
+
* 移除 @ Endpoint 的部分
|
|
81
79
|
*/
|
|
82
|
-
export declare function
|
|
83
|
-
/**
|
|
84
|
-
export interface
|
|
80
|
+
export declare function removeAtEndpoint<T extends object>(message: Message<T>, endpointAtIds?: string[]): MessageElement[];
|
|
81
|
+
/** Endpoint 配置(adapter endpoints[].$config) */
|
|
82
|
+
export interface EndpointConfigRoles {
|
|
85
83
|
master?: unknown;
|
|
86
84
|
trusted?: unknown;
|
|
87
85
|
}
|
|
88
86
|
/**
|
|
89
|
-
* 解析发送者角色集合(IM 群角色 + trigger +
|
|
87
|
+
* 解析发送者角色集合(IM 群角色 + trigger + endpoints[].$config)
|
|
90
88
|
*/
|
|
91
|
-
export declare function resolveSenderRoles<T extends object>(message: Message<T>, config: AITriggerConfig,
|
|
92
|
-
/** 从 IM 消息生成 sessionId(platform:botId:type:sceneId) */
|
|
93
|
-
export declare function resolveIMSessionIdFromMessage<T extends object>(message: Message<T>): string;
|
|
89
|
+
export declare function resolveSenderRoles<T extends object>(message: Message<T>, config: AITriggerConfig, endpointConfig?: EndpointConfigRoles | Record<string, unknown> | null): SenderRolesResult;
|
|
94
90
|
/**
|
|
95
91
|
* 检查消息是否应该触发 AI
|
|
96
92
|
*/
|
|
@@ -99,4 +95,3 @@ export declare function shouldTriggerAI<T extends object>(message: Message<T>, c
|
|
|
99
95
|
* 合并配置
|
|
100
96
|
*/
|
|
101
97
|
export declare function mergeAITriggerConfig(config: AITriggerConfig): Required<AITriggerConfig>;
|
|
102
|
-
//# sourceMappingURL=ai-trigger.d.ts.map
|
package/lib/built/ai-trigger.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* 4. 关键词触发 - 非群/频道场景下匹配关键词时触发
|
|
10
10
|
*/
|
|
11
11
|
import { segment } from "../utils.js";
|
|
12
|
-
import {
|
|
12
|
+
import { readMentionSegmentTarget } from './segment-contract/mention.js';
|
|
13
13
|
import { normalizeSenderRoles, } from './roles.js';
|
|
14
14
|
// ============================================================================
|
|
15
15
|
// 默认配置
|
|
@@ -26,50 +26,44 @@ export const DEFAULT_AI_TRIGGER_CONFIG = {
|
|
|
26
26
|
errorTemplate: '❌ AI 处理失败: {error}',
|
|
27
27
|
masters: [],
|
|
28
28
|
trusted: [],
|
|
29
|
-
resolveQuotedMessages: true,
|
|
30
29
|
};
|
|
31
30
|
// ============================================================================
|
|
32
31
|
// 工具函数
|
|
33
32
|
// ============================================================================
|
|
34
|
-
function normalizeAtIds(
|
|
35
|
-
const ids =
|
|
33
|
+
function normalizeAtIds(endpointAtIds) {
|
|
34
|
+
const ids = endpointAtIds?.length ? endpointAtIds : [];
|
|
36
35
|
return [...new Set(ids.map((id) => String(id)).filter(Boolean))];
|
|
37
36
|
}
|
|
38
37
|
function segmentAtUserId(seg) {
|
|
39
|
-
|
|
40
|
-
if (!data || typeof data !== 'object')
|
|
41
|
-
return '';
|
|
42
|
-
const record = data;
|
|
43
|
-
const raw = record.user_id ?? record.qq ?? record.id;
|
|
44
|
-
return raw == null ? '' : String(raw);
|
|
38
|
+
return readMentionSegmentTarget(seg);
|
|
45
39
|
}
|
|
46
|
-
function
|
|
40
|
+
function isAtSegmentForEndpoint(seg, endpointKeys) {
|
|
47
41
|
if (seg.type !== 'at' && seg.type !== 'mention')
|
|
48
42
|
return false;
|
|
49
43
|
const uid = segmentAtUserId(seg);
|
|
50
|
-
return uid !== '' &&
|
|
44
|
+
return uid !== '' && endpointKeys.includes(uid);
|
|
51
45
|
}
|
|
52
|
-
function
|
|
53
|
-
for (const id of
|
|
46
|
+
function textMentionsEndpoint(text, endpointKeys) {
|
|
47
|
+
for (const id of endpointKeys) {
|
|
54
48
|
const re = new RegExp(`@${id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?:\\s|$|[\\u200b\\uFEFF])`);
|
|
55
49
|
if (re.test(text))
|
|
56
50
|
return true;
|
|
57
51
|
}
|
|
58
52
|
return false;
|
|
59
53
|
}
|
|
60
|
-
function
|
|
54
|
+
function stripTextAtEndpoint(text, endpointKeys) {
|
|
61
55
|
let result = text;
|
|
62
|
-
for (const id of
|
|
56
|
+
for (const id of endpointKeys) {
|
|
63
57
|
const re = new RegExp(`@${id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?:\\s|[\\u200b\\uFEFF])?`, 'g');
|
|
64
58
|
result = result.replace(re, '');
|
|
65
59
|
}
|
|
66
60
|
return result;
|
|
67
61
|
}
|
|
68
62
|
/**
|
|
69
|
-
* 收集用于 @ 匹配的
|
|
63
|
+
* 收集用于 @ 匹配的 Endpoint 标识符
|
|
70
64
|
*/
|
|
71
|
-
export function
|
|
72
|
-
const ids = new Set([String(message.$
|
|
65
|
+
export function collectEndpointAtIds(message, extraIds) {
|
|
66
|
+
const ids = new Set([String(message.$endpoint)]);
|
|
73
67
|
for (const id of extraIds ?? []) {
|
|
74
68
|
if (id)
|
|
75
69
|
ids.add(String(id));
|
|
@@ -77,15 +71,15 @@ export function collectBotAtIds(message, extraIds) {
|
|
|
77
71
|
return [...ids];
|
|
78
72
|
}
|
|
79
73
|
/**
|
|
80
|
-
* 检查消息是否 @
|
|
74
|
+
* 检查消息是否 @ 了 Endpoint
|
|
81
75
|
*/
|
|
82
|
-
export function
|
|
83
|
-
const
|
|
84
|
-
if (message.$content.some((seg) =>
|
|
76
|
+
export function isAtEndpoint(message, endpointAtIds) {
|
|
77
|
+
const endpointKeys = normalizeAtIds(endpointAtIds?.length ? endpointAtIds : collectEndpointAtIds(message));
|
|
78
|
+
if (message.$content.some((seg) => isAtSegmentForEndpoint(seg, endpointKeys))) {
|
|
85
79
|
return true;
|
|
86
80
|
}
|
|
87
81
|
for (const seg of message.$content) {
|
|
88
|
-
if (seg.type === 'text' && seg.data?.text &&
|
|
82
|
+
if (seg.type === 'text' && seg.data?.text && textMentionsEndpoint(seg.data.text, endpointKeys)) {
|
|
89
83
|
return true;
|
|
90
84
|
}
|
|
91
85
|
}
|
|
@@ -118,23 +112,23 @@ export function parseRichMediaContent(content) {
|
|
|
118
112
|
}
|
|
119
113
|
}
|
|
120
114
|
/**
|
|
121
|
-
* 移除 @
|
|
115
|
+
* 移除 @ Endpoint 的部分
|
|
122
116
|
*/
|
|
123
|
-
export function
|
|
124
|
-
const
|
|
117
|
+
export function removeAtEndpoint(message, endpointAtIds) {
|
|
118
|
+
const endpointKeys = normalizeAtIds(endpointAtIds?.length ? endpointAtIds : collectEndpointAtIds(message));
|
|
125
119
|
return message.$content
|
|
126
|
-
.filter((seg) => !
|
|
120
|
+
.filter((seg) => !isAtSegmentForEndpoint(seg, endpointKeys))
|
|
127
121
|
.map((seg) => {
|
|
128
122
|
if (seg.type !== 'text' || !seg.data?.text)
|
|
129
123
|
return seg;
|
|
130
|
-
const stripped =
|
|
124
|
+
const stripped = stripTextAtEndpoint(seg.data.text, endpointKeys).trim();
|
|
131
125
|
if (!stripped)
|
|
132
126
|
return null;
|
|
133
127
|
return { ...seg, data: { ...seg.data, text: stripped } };
|
|
134
128
|
})
|
|
135
129
|
.filter((seg) => seg != null);
|
|
136
130
|
}
|
|
137
|
-
function
|
|
131
|
+
function normalizeEndpointIdList(input) {
|
|
138
132
|
if (Array.isArray(input))
|
|
139
133
|
return input.map((v) => String(v)).filter(Boolean);
|
|
140
134
|
if (typeof input === 'string') {
|
|
@@ -142,15 +136,15 @@ function normalizeBotIdList(input) {
|
|
|
142
136
|
}
|
|
143
137
|
return [];
|
|
144
138
|
}
|
|
145
|
-
function
|
|
146
|
-
if (!
|
|
139
|
+
function collectEndpointTrustedIds(endpointConfig) {
|
|
140
|
+
if (!endpointConfig)
|
|
147
141
|
return [];
|
|
148
|
-
return
|
|
142
|
+
return normalizeEndpointIdList(endpointConfig.trusted);
|
|
149
143
|
}
|
|
150
144
|
/**
|
|
151
|
-
* 解析发送者角色集合(IM 群角色 + trigger +
|
|
145
|
+
* 解析发送者角色集合(IM 群角色 + trigger + endpoints[].$config)
|
|
152
146
|
*/
|
|
153
|
-
export function resolveSenderRoles(message, config,
|
|
147
|
+
export function resolveSenderRoles(message, config, endpointConfig) {
|
|
154
148
|
const scope = message.$channel?.type || 'private';
|
|
155
149
|
// process 适配器(stdin/本机 CLI):操作者即宿主用户,恒为 master
|
|
156
150
|
if (message.$adapter === 'process') {
|
|
@@ -160,54 +154,29 @@ export function resolveSenderRoles(message, config, botConfig) {
|
|
|
160
154
|
};
|
|
161
155
|
}
|
|
162
156
|
const senderId = String(message.$sender.id);
|
|
163
|
-
const senderPermissions = message.$sender.permissions || [];
|
|
164
157
|
const roles = [];
|
|
165
158
|
const masters = config.masters || [];
|
|
166
159
|
const globalTrusted = config.trusted || [];
|
|
167
|
-
const cfg =
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
if (masters.includes(senderId) || (
|
|
160
|
+
const cfg = endpointConfig;
|
|
161
|
+
const endpointMaster = cfg?.master != null ? String(cfg.master) : undefined;
|
|
162
|
+
const endpointTrustedIds = collectEndpointTrustedIds(cfg);
|
|
163
|
+
if (masters.includes(senderId) || (endpointMaster != null && senderId === endpointMaster)) {
|
|
171
164
|
roles.push('master');
|
|
172
165
|
}
|
|
173
|
-
else if (globalTrusted.includes(senderId) ||
|
|
166
|
+
else if (globalTrusted.includes(senderId) || endpointTrustedIds.includes(senderId)) {
|
|
174
167
|
roles.push('trusted');
|
|
175
168
|
}
|
|
176
|
-
const isGroupOwner = senderPermissions.includes('owner')
|
|
177
|
-
|| senderPermissions.includes('group_owner')
|
|
178
|
-
|| message.$sender?.role === 'owner';
|
|
179
|
-
const isGroupAdmin = isGroupOwner
|
|
180
|
-
|| senderPermissions.includes('admin')
|
|
181
|
-
|| senderPermissions.includes('group_admin')
|
|
182
|
-
|| message.$sender?.role === 'admin';
|
|
183
|
-
if (isGroupOwner)
|
|
184
|
-
roles.push('group_owner');
|
|
185
|
-
else if (isGroupAdmin)
|
|
186
|
-
roles.push('group_admin');
|
|
187
169
|
return {
|
|
188
170
|
scope,
|
|
189
171
|
roles: normalizeSenderRoles(roles),
|
|
190
172
|
};
|
|
191
173
|
}
|
|
192
|
-
/** 从 IM 消息生成 sessionId(platform:botId:type:sceneId) */
|
|
193
|
-
export function resolveIMSessionIdFromMessage(message) {
|
|
194
|
-
const scope = (message.$channel?.type || 'private');
|
|
195
|
-
const sceneId = scope === 'private'
|
|
196
|
-
? String(message.$sender.id)
|
|
197
|
-
: String(message.$channel?.id || message.$sender.id);
|
|
198
|
-
return resolveIMSessionId({
|
|
199
|
-
platform: message.$adapter,
|
|
200
|
-
botId: message.$bot,
|
|
201
|
-
scope,
|
|
202
|
-
sceneId,
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
174
|
/**
|
|
206
175
|
* 检查消息是否应该触发 AI
|
|
207
176
|
*/
|
|
208
177
|
export function shouldTriggerAI(message, config, options) {
|
|
209
178
|
const fullConfig = { ...DEFAULT_AI_TRIGGER_CONFIG, ...config };
|
|
210
|
-
const
|
|
179
|
+
const endpointAtIds = collectEndpointAtIds(message, options?.endpointAtIds);
|
|
211
180
|
if (!fullConfig.enabled) {
|
|
212
181
|
return { triggered: false, content: '' };
|
|
213
182
|
}
|
|
@@ -229,11 +198,12 @@ export function shouldTriggerAI(message, config, options) {
|
|
|
229
198
|
}
|
|
230
199
|
}
|
|
231
200
|
// 2. 检查 @ 触发(群/频道主路径;仅 @ 无正文时也触发,由 Agent 处理空输入)
|
|
232
|
-
if (fullConfig.respondToAt &&
|
|
233
|
-
const content =
|
|
201
|
+
if (fullConfig.respondToAt && isAtEndpoint(message, endpointAtIds)) {
|
|
202
|
+
const content = removeAtEndpoint(message, endpointAtIds);
|
|
203
|
+
const body = content.length ? segment.toString(content).trim() : '';
|
|
234
204
|
return {
|
|
235
205
|
triggered: true,
|
|
236
|
-
content:
|
|
206
|
+
content: body,
|
|
237
207
|
};
|
|
238
208
|
}
|
|
239
209
|
// 3. 检查私聊触发
|
|
@@ -259,4 +229,3 @@ export function shouldTriggerAI(message, config, options) {
|
|
|
259
229
|
export function mergeAITriggerConfig(config) {
|
|
260
230
|
return { ...DEFAULT_AI_TRIGGER_CONFIG, ...config };
|
|
261
231
|
}
|
|
262
|
-
//# sourceMappingURL=ai-trigger.js.map
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Scene Management — 方法规范与 Tool 工厂
|
|
3
3
|
*
|
|
4
4
|
* 设计理念:
|
|
5
|
-
* 各 IM
|
|
5
|
+
* 各 IM 平台在适配器内自行实现场景治理方法(removeMember、muteMember 等),
|
|
6
6
|
* 并自行注册 Tool;平台说明使用包内 `skills/<adapter>/SKILL.md`。
|
|
7
7
|
*
|
|
8
8
|
* 使用方式(在各适配器 start 或注册方法中):
|
|
9
9
|
*
|
|
10
|
-
* import {
|
|
11
|
-
* const tools =
|
|
10
|
+
* import { createSceneManagementTools, SCENE_MANAGEMENT_SKILL_KEYWORDS, SCENE_MANAGEMENT_SKILL_TAGS } from 'zhin.js';
|
|
11
|
+
* const tools = createSceneManagementTools(this, this.name);
|
|
12
12
|
* tools.forEach(t => this.addTool(t));
|
|
13
13
|
* // 另:包内 skills/<name>/SKILL.md 供 Agent 发现
|
|
14
14
|
*/
|
|
15
|
-
import type { Tool
|
|
15
|
+
import type { Tool } from '../types.js';
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* 场景治理能力接口。
|
|
18
18
|
* Adapter 基类通过此接口声明方法签名,子类选择性覆写。
|
|
19
19
|
*/
|
|
20
|
-
export interface
|
|
21
|
-
|
|
22
|
-
muteMember?(
|
|
23
|
-
setMemberNickname?(
|
|
24
|
-
|
|
25
|
-
listMembers?(
|
|
26
|
-
banMember?(
|
|
27
|
-
unbanMember?(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
export interface ISceneManagement {
|
|
21
|
+
removeMember?(endpointKey: string, sceneId: string, userId: string): Promise<any>;
|
|
22
|
+
muteMember?(endpointKey: string, sceneId: string, userId: string, duration?: number): Promise<any>;
|
|
23
|
+
setMemberNickname?(endpointKey: string, sceneId: string, userId: string, nickname: string): Promise<any>;
|
|
24
|
+
setModerator?(endpointKey: string, sceneId: string, userId: string, enable?: boolean): Promise<any>;
|
|
25
|
+
listMembers?(endpointKey: string, sceneId: string): Promise<any>;
|
|
26
|
+
banMember?(endpointKey: string, sceneId: string, userId: string, reason?: string): Promise<any>;
|
|
27
|
+
unbanMember?(endpointKey: string, sceneId: string, userId: string): Promise<any>;
|
|
28
|
+
renameScene?(endpointKey: string, sceneId: string, name: string): Promise<any>;
|
|
29
|
+
setSceneMuted?(endpointKey: string, sceneId: string, enable?: boolean): Promise<any>;
|
|
30
|
+
getSceneInfo?(endpointKey: string, sceneId: string): Promise<any>;
|
|
31
31
|
}
|
|
32
|
-
export interface
|
|
33
|
-
method: keyof
|
|
32
|
+
export interface SceneManagementMethodSpec {
|
|
33
|
+
method: keyof ISceneManagement;
|
|
34
34
|
toolSuffix: string;
|
|
35
35
|
description: string;
|
|
36
36
|
keywords: string[];
|
|
37
|
-
|
|
37
|
+
permit?: string;
|
|
38
38
|
extraParams: Record<string, {
|
|
39
39
|
type: string;
|
|
40
40
|
description: string;
|
|
@@ -43,13 +43,17 @@ export interface GroupMethodSpec {
|
|
|
43
43
|
extraRequired?: string[];
|
|
44
44
|
preExecutable?: boolean;
|
|
45
45
|
}
|
|
46
|
-
export declare const
|
|
47
|
-
export declare const
|
|
48
|
-
export declare const
|
|
49
|
-
export interface
|
|
50
|
-
(spec:
|
|
46
|
+
export declare const SCENE_MANAGEMENT_METHOD_SPECS: SceneManagementMethodSpec[];
|
|
47
|
+
export declare const SCENE_MANAGEMENT_SKILL_TAGS: string[];
|
|
48
|
+
export declare const SCENE_MANAGEMENT_SKILL_KEYWORDS: string[];
|
|
49
|
+
export interface SceneManagementToolFactory<T> {
|
|
50
|
+
(spec: SceneManagementMethodSpec, prefix: string, execute: (args: Record<string, any>) => Promise<any>): T;
|
|
51
51
|
}
|
|
52
|
-
export declare function
|
|
53
|
-
export
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
export declare function defaultScenePermitResolver(adapterPrefix: string): (logicalPerm: string) => string;
|
|
53
|
+
export interface CreateSceneManagementToolsOptions {
|
|
54
|
+
/** 将 SCENE_MANAGEMENT_METHOD_SPECS 逻辑 perm(scene_admin/scene_owner)映射为 platform(...) 字符串 */
|
|
55
|
+
permitResolver?: (logicalPerm: string) => string | undefined;
|
|
56
|
+
}
|
|
57
|
+
export declare function createSceneManagementTools(adapter: ISceneManagement, prefix: string, options?: CreateSceneManagementToolsOptions): Tool[];
|
|
58
|
+
export declare function createSceneManagementToolsRaw<T>(adapter: ISceneManagement, prefix: string, factory: SceneManagementToolFactory<T>): T[];
|
|
59
|
+
export declare function buildSceneMethodArgs(method: keyof ISceneManagement, endpointKey: string, sceneId: string, rest: Record<string, any>): any[];
|