@zhin.js/core 1.5.16 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -195
- package/lib/ai-completion-contract.d.ts +135 -0
- package/lib/ai-completion-contract.js +69 -0
- package/lib/built/ai-access.d.ts +2 -21
- package/lib/built/ai-access.js +1 -46
- package/lib/built/ai-outbound/index.d.ts +0 -2
- package/lib/built/ai-outbound/index.js +0 -2
- package/lib/built/ai-outbound/prompt.d.ts +2 -0
- package/lib/built/ai-outbound/prompt.js +2 -0
- package/lib/built/ai-outbound/types.d.ts +1 -10
- package/lib/built/ai-trigger.d.ts +39 -78
- package/lib/built/ai-trigger.js +3 -254
- package/lib/built/common-adapter-tools.d.ts +21 -6
- package/lib/built/common-adapter-tools.js +28 -17
- package/lib/built/generic-segment-mapper.js +4 -1
- package/lib/built/html-segment-fallback.d.ts +6 -7
- package/lib/built/html-segment-fallback.js +1 -16
- package/lib/built/html-to-text.d.ts +0 -3
- package/lib/built/html-to-text.js +131 -40
- package/lib/built/interaction-messages.d.ts +1 -0
- package/lib/built/interaction-messages.js +30 -0
- package/lib/built/interactive-segments/action.d.ts +3 -4
- package/lib/built/interactive-segments/action.js +2 -5
- package/lib/built/interactive-segments/index.d.ts +0 -2
- package/lib/built/interactive-segments/index.js +0 -2
- package/lib/built/interactive-segments/keyboard-segment.d.ts +0 -1
- package/lib/built/interactive-segments/keyboard-segment.js +0 -1
- package/lib/built/interactive-segments/onebot-keyboard.d.ts +0 -1
- package/lib/built/interactive-segments/onebot-keyboard.js +0 -2
- package/lib/built/interactive-segments/resolve.d.ts +2 -3
- package/lib/built/interactive-segments/resolve.js +21 -14
- package/lib/built/interactive-segments/types.d.ts +2 -7
- package/lib/built/interactive-segments/types.js +22 -2
- package/lib/built/login-assist.d.ts +330 -25
- package/lib/built/login-assist.js +1156 -75
- package/lib/built/login-captcha.d.ts +62 -0
- package/lib/built/login-captcha.js +107 -0
- package/lib/built/message-enrich.d.ts +24 -27
- package/lib/built/message-enrich.js +53 -49
- package/lib/built/outbound-content-arrays.d.ts +4 -0
- package/lib/built/outbound-content-arrays.js +32 -0
- package/lib/built/outbound-media-trust.d.ts +46 -0
- package/lib/built/outbound-media-trust.js +245 -0
- package/lib/built/outbound-media-utils.d.ts +5 -3
- package/lib/built/outbound-media-utils.js +5 -3
- package/lib/built/readable-link.d.ts +4 -0
- package/lib/built/readable-link.js +32 -0
- package/lib/built/rich-segments/markdown-to-text.d.ts +1 -2
- package/lib/built/rich-segments/markdown-to-text.js +141 -17
- package/lib/built/roles.d.ts +141 -12
- package/lib/built/roles.js +253 -52
- package/lib/built/segment-contract/assert.js +8 -2
- package/lib/built/segment-contract/delivery.js +1 -0
- package/lib/built/segment-contract/index.d.ts +3 -3
- package/lib/built/segment-contract/index.js +2 -2
- package/lib/built/segment-contract/json-schema.d.ts +39 -5
- package/lib/built/segment-contract/json-schema.js +207 -24
- package/lib/built/segment-contract/preview.js +8 -1
- package/lib/built/segment-contract/text.js +1 -1
- package/lib/built/segment-contract/types.d.ts +2 -2
- package/lib/built/segment-contract/validate.d.ts +1553 -224
- package/lib/built/segment-contract/validate.js +39 -3
- package/lib/built/tool-access.d.ts +5 -0
- package/lib/built/tool-access.js +17 -0
- package/lib/built/user-interaction.d.ts +5 -4
- package/lib/built/user-interaction.js +64 -52
- package/lib/errors.d.ts +1 -18
- package/lib/errors.js +1 -26
- package/lib/feature/command-public-api.d.ts +5 -0
- package/lib/feature/command-public-api.js +5 -0
- package/lib/feature/command.d.ts +2 -0
- package/lib/feature/command.js +1 -0
- package/lib/feature/component.d.ts +1 -0
- package/lib/feature/component.js +1 -0
- package/lib/feature/handler.d.ts +13 -7
- package/lib/feature/handler.js +2 -1
- package/lib/feature/middleware-public-api.d.ts +6 -0
- package/lib/feature/middleware-public-api.js +6 -0
- package/lib/feature/middleware.d.ts +22 -2
- package/lib/feature/middleware.js +7 -2
- package/lib/im-scene.d.ts +4 -3
- package/lib/im-scene.js +9 -9
- package/lib/im-session-id.d.ts +20 -12
- package/lib/im-session-id.js +8 -8
- package/lib/index.d.ts +20 -48
- package/lib/index.js +15 -41
- package/lib/jsx/intrinsic-elements.d.ts +83 -0
- package/lib/jsx/message-renderer.d.ts +13 -0
- package/lib/jsx/message-renderer.js +128 -0
- package/lib/jsx/message-tags.d.ts +133 -0
- package/lib/jsx/message-tags.js +50 -0
- package/lib/jsx-dev-runtime.d.ts +2 -2
- package/lib/jsx-dev-runtime.js +1 -2
- package/lib/jsx-runtime.d.ts +2 -12
- package/lib/jsx-runtime.js +1 -10
- package/lib/jsx.d.ts +6 -30
- package/lib/jsx.js +3 -93
- package/lib/message.d.ts +0 -40
- package/lib/message.js +1 -27
- package/lib/models/system-log.d.ts +0 -2
- package/lib/models/system-log.js +1 -8
- package/lib/models/user.d.ts +0 -2
- package/lib/models/user.js +1 -7
- package/lib/notice.d.ts +38 -33
- package/lib/notice.js +23 -7
- package/lib/plugin-runtime/im/command-feedback.d.ts +59 -0
- package/lib/plugin-runtime/im/command-feedback.js +148 -0
- package/lib/plugin-runtime/im/contracts.d.ts +217 -32
- package/lib/plugin-runtime/im/contracts.js +141 -23
- package/lib/plugin-runtime/im/conversation-runtime.d.ts +42 -0
- package/lib/plugin-runtime/im/conversation-runtime.js +451 -0
- package/lib/plugin-runtime/im/endpoint-runtime.d.ts +112 -0
- package/lib/plugin-runtime/im/endpoint-runtime.js +434 -0
- package/lib/plugin-runtime/im/feature-gate.d.ts +21 -0
- package/lib/plugin-runtime/im/feature-gate.js +88 -0
- package/lib/plugin-runtime/im/host/component-host-installer.d.ts +2 -0
- package/lib/plugin-runtime/im/host/component-host-installer.js +14 -0
- package/lib/plugin-runtime/im/host/conversation-migration.d.ts +5 -0
- package/lib/plugin-runtime/im/host/conversation-migration.js +75 -0
- package/lib/plugin-runtime/im/host/database-config.d.ts +10 -0
- package/lib/plugin-runtime/im/host/database-config.js +152 -0
- package/lib/plugin-runtime/im/host/database-console-schema.d.ts +79 -0
- package/lib/plugin-runtime/im/host/database-console-schema.js +477 -0
- package/lib/plugin-runtime/im/host/database-console-sql.d.ts +66 -0
- package/lib/plugin-runtime/im/host/database-console-sql.js +459 -0
- package/lib/plugin-runtime/im/host/database-host-installer.d.ts +60 -0
- package/lib/plugin-runtime/im/host/database-host-installer.js +1166 -0
- package/lib/plugin-runtime/im/host/database-state.d.ts +9 -0
- package/lib/plugin-runtime/im/host/database-state.js +91 -0
- package/lib/plugin-runtime/im/host/index.d.ts +8 -0
- package/lib/plugin-runtime/im/host/index.js +8 -0
- package/lib/plugin-runtime/im/host/locale-host-installer.d.ts +3 -0
- package/lib/plugin-runtime/im/host/locale-host-installer.js +60 -0
- package/lib/plugin-runtime/im/host/outbound-host-installer.d.ts +8 -0
- package/lib/plugin-runtime/im/host/outbound-host-installer.js +153 -0
- package/lib/plugin-runtime/im/host/sender-enrichment.d.ts +34 -0
- package/lib/plugin-runtime/im/host/sender-enrichment.js +82 -0
- package/lib/plugin-runtime/im/im-runtime.d.ts +40 -111
- package/lib/plugin-runtime/im/im-runtime.js +235 -1059
- package/lib/plugin-runtime/im/inbound-dedup.d.ts +84 -0
- package/lib/plugin-runtime/im/inbound-dedup.js +322 -0
- package/lib/plugin-runtime/im/inbound-origin.d.ts +150 -0
- package/lib/plugin-runtime/im/inbound-origin.js +183 -0
- package/lib/plugin-runtime/im/inbound-runtime.d.ts +59 -0
- package/lib/plugin-runtime/im/inbound-runtime.js +478 -0
- package/lib/plugin-runtime/im/inbound-spine.d.ts +196 -0
- package/lib/plugin-runtime/im/inbound-spine.js +335 -0
- package/lib/plugin-runtime/im/index.d.ts +15 -4
- package/lib/plugin-runtime/im/index.js +11 -4
- package/lib/plugin-runtime/im/interaction-runtime.d.ts +50 -0
- package/lib/plugin-runtime/im/interaction-runtime.js +390 -0
- package/lib/plugin-runtime/im/interactive-router.d.ts +81 -0
- package/lib/plugin-runtime/im/interactive-router.js +382 -0
- package/lib/plugin-runtime/im/message-diagnostics.d.ts +70 -0
- package/lib/plugin-runtime/im/message-diagnostics.js +182 -0
- package/lib/plugin-runtime/im/message-dispatcher.d.ts +18 -4
- package/lib/plugin-runtime/im/message-dispatcher.js +138 -20
- package/lib/plugin-runtime/im/message-events.d.ts +85 -0
- package/lib/plugin-runtime/im/message-events.js +113 -0
- package/lib/plugin-runtime/im/outbound-delivery-runtime.d.ts +39 -0
- package/lib/plugin-runtime/im/outbound-delivery-runtime.js +450 -0
- package/lib/plugin-runtime/im/outbound-renderer.d.ts +52 -3
- package/lib/plugin-runtime/im/outbound-renderer.js +188 -8
- package/lib/plugin-runtime/im/outbound-segments.d.ts +29 -5
- package/lib/plugin-runtime/im/outbound-segments.js +130 -36
- package/lib/plugin-runtime/im/progressive-reply.d.ts +58 -0
- package/lib/plugin-runtime/im/progressive-reply.js +501 -0
- package/lib/plugin-runtime/im/public-api.d.ts +1 -1
- package/lib/request.d.ts +27 -36
- package/lib/request.js +14 -6
- package/lib/side-event/base.d.ts +64 -44
- package/lib/side-event/base.js +72 -19
- package/lib/side-event/index.d.ts +1 -1
- package/lib/side-event/index.js +1 -1
- package/lib/side-event/normalize.d.ts +7 -38
- package/lib/side-event/normalize.js +4 -109
- package/lib/side-event/scene-events.d.ts +40 -0
- package/lib/side-event/scene-events.js +147 -0
- package/lib/side-event/types.d.ts +4 -13
- package/lib/side-event/types.js +1 -55
- package/lib/system-event.d.ts +17 -12
- package/lib/system-event.js +8 -6
- package/lib/types.d.ts +23 -167
- package/lib/utils.d.ts +50 -33
- package/lib/utils.js +12 -185
- package/lib/venue/contracts.d.ts +21 -0
- package/lib/venue/contracts.js +3 -0
- package/lib/venue/floor-controller.d.ts +11 -0
- package/lib/venue/floor-controller.js +63 -0
- package/lib/venue/index.d.ts +13 -0
- package/lib/venue/index.js +11 -0
- package/lib/venue/membership-port.d.ts +23 -0
- package/lib/venue/membership-port.js +141 -0
- package/lib/venue/projector.d.ts +38 -0
- package/lib/venue/projector.js +45 -0
- package/lib/venue/registry.d.ts +16 -0
- package/lib/venue/registry.js +63 -0
- package/lib/venue/router.d.ts +19 -0
- package/lib/venue/router.js +101 -0
- package/lib/venue/send-limiter.d.ts +17 -0
- package/lib/venue/send-limiter.js +73 -0
- package/lib/venue/validator.d.ts +6 -0
- package/lib/venue/validator.js +160 -0
- package/package.json +24 -50
- package/lib/adapter.d.ts +0 -145
- package/lib/adapter.js +0 -377
- package/lib/built/adapter-process.d.ts +0 -58
- package/lib/built/adapter-process.js +0 -128
- package/lib/built/agent-preset.d.ts +0 -64
- package/lib/built/agent-preset.js +0 -79
- package/lib/built/ai-outbound/adapter-access.d.ts +0 -3
- package/lib/built/ai-outbound/adapter-access.js +0 -9
- package/lib/built/ai-outbound/extensions/qq-message.d.ts +0 -3
- package/lib/built/ai-outbound/extensions/qq-message.js +0 -23
- package/lib/built/authorization.d.ts +0 -10
- package/lib/built/authorization.js +0 -76
- package/lib/built/command.d.ts +0 -72
- package/lib/built/command.js +0 -105
- package/lib/built/component.d.ts +0 -67
- package/lib/built/component.js +0 -97
- package/lib/built/config.d.ts +0 -98
- package/lib/built/config.js +0 -372
- package/lib/built/connect-endpoint-instance.d.ts +0 -17
- package/lib/built/connect-endpoint-instance.js +0 -42
- package/lib/built/database.d.ts +0 -68
- package/lib/built/database.js +0 -106
- package/lib/built/dispatcher.d.ts +0 -141
- package/lib/built/dispatcher.js +0 -383
- package/lib/built/endpoint-commands.d.ts +0 -3
- package/lib/built/endpoint-commands.js +0 -99
- package/lib/built/endpoint-lifecycle-service.d.ts +0 -28
- package/lib/built/endpoint-lifecycle-service.js +0 -242
- package/lib/built/endpoint-lifecycle.d.ts +0 -27
- package/lib/built/endpoint-lifecycle.js +0 -36
- package/lib/built/endpoint-manager.d.ts +0 -34
- package/lib/built/html-renderer-loader.d.ts +0 -13
- package/lib/built/html-renderer-loader.js +0 -33
- package/lib/built/inbound-pipeline.d.ts +0 -37
- package/lib/built/inbound-pipeline.js +0 -63
- package/lib/built/inbound-runner.d.ts +0 -22
- package/lib/built/inbound-runner.js +0 -34
- package/lib/built/interactive-segment-contract.d.ts +0 -6
- package/lib/built/interactive-segment-contract.js +0 -9
- package/lib/built/interactive-segments/fallback-store.d.ts +0 -29
- package/lib/built/interactive-segments/fallback-store.js +0 -63
- package/lib/built/interactive-segments/handlers.d.ts +0 -16
- package/lib/built/interactive-segments/handlers.js +0 -74
- package/lib/built/introspection-format.d.ts +0 -10
- package/lib/built/introspection-format.js +0 -28
- package/lib/built/management-command-guard.d.ts +0 -15
- package/lib/built/management-command-guard.js +0 -25
- package/lib/built/message-filter.d.ts +0 -176
- package/lib/built/message-filter.js +0 -239
- package/lib/built/optional-peer-import.d.ts +0 -3
- package/lib/built/optional-peer-import.js +0 -33
- package/lib/built/outbound-media-contract.d.ts +0 -22
- package/lib/built/outbound-media-contract.js +0 -10
- package/lib/built/permission.d.ts +0 -51
- package/lib/built/permission.js +0 -99
- package/lib/built/permit-check.d.ts +0 -7
- package/lib/built/permit-check.js +0 -35
- package/lib/built/permit-parse.d.ts +0 -16
- package/lib/built/permit-parse.js +0 -32
- package/lib/built/platform-permit.d.ts +0 -20
- package/lib/built/platform-permit.js +0 -91
- package/lib/built/queue-im-field-contract.d.ts +0 -32
- package/lib/built/queue-im-field-contract.js +0 -67
- package/lib/built/rich-segments/adapter-policies.d.ts +0 -9
- package/lib/built/rich-segments/adapter-policies.js +0 -27
- package/lib/built/rich-segments/base.d.ts +0 -11
- package/lib/built/rich-segments/base.js +0 -24
- package/lib/built/rich-segments/builtins.d.ts +0 -4
- package/lib/built/rich-segments/builtins.js +0 -40
- package/lib/built/rich-segments/capabilities.d.ts +0 -6
- package/lib/built/rich-segments/capabilities.js +0 -38
- package/lib/built/rich-segments/html-segment.d.ts +0 -15
- package/lib/built/rich-segments/html-segment.js +0 -62
- package/lib/built/rich-segments/index.d.ts +0 -13
- package/lib/built/rich-segments/index.js +0 -13
- package/lib/built/rich-segments/markdown-segment.d.ts +0 -14
- package/lib/built/rich-segments/markdown-segment.js +0 -58
- package/lib/built/rich-segments/qrcode-segment.d.ts +0 -18
- package/lib/built/rich-segments/qrcode-segment.js +0 -73
- package/lib/built/rich-segments/registry.d.ts +0 -16
- package/lib/built/rich-segments/registry.js +0 -52
- package/lib/built/rich-segments/resolve.d.ts +0 -5
- package/lib/built/rich-segments/resolve.js +0 -87
- package/lib/built/rich-segments/tts-segment.d.ts +0 -13
- package/lib/built/rich-segments/tts-segment.js +0 -51
- package/lib/built/rich-segments/types.d.ts +0 -79
- package/lib/built/rich-segments/types.js +0 -17
- package/lib/built/runtime-io.d.ts +0 -9
- package/lib/built/runtime-io.js +0 -67
- package/lib/built/schedule.d.ts +0 -54
- package/lib/built/schedule.js +0 -112
- package/lib/built/schema-endpoint-manager.d.ts +0 -17
- package/lib/built/schema-endpoint-manager.js +0 -73
- package/lib/built/schema-feature.d.ts +0 -77
- package/lib/built/schema-feature.js +0 -130
- package/lib/built/skill.d.ts +0 -120
- package/lib/built/skill.js +0 -151
- package/lib/built/speech-loader.d.ts +0 -14
- package/lib/built/speech-loader.js +0 -32
- package/lib/built/tool.d.ts +0 -151
- package/lib/built/tool.js +0 -388
- package/lib/command.d.ts +0 -50
- package/lib/command.js +0 -106
- package/lib/component.d.ts +0 -26
- package/lib/component.js +0 -583
- package/lib/endpoint-capabilities.d.ts +0 -46
- package/lib/endpoint-capabilities.js +0 -55
- package/lib/endpoint.d.ts +0 -19
- package/lib/endpoint.js +0 -3
- package/lib/host-plugin-registry.d.ts +0 -8
- package/lib/host-plugin-registry.js +0 -12
- package/lib/plugin-context.d.ts +0 -27
- package/lib/plugin-context.js +0 -64
- package/lib/plugin-runtime/im/interactive.d.ts +0 -26
- package/lib/plugin-runtime/im/interactive.js +0 -46
- package/lib/plugin-runtime/im/login-assist-host.d.ts +0 -6
- package/lib/plugin-runtime/im/login-assist-host.js +0 -6
- package/lib/plugin-runtime/im/message-bus.d.ts +0 -38
- package/lib/plugin-runtime/im/message-bus.js +0 -40
- package/lib/plugin-runtime/im/service-tokens.d.ts +0 -18
- package/lib/plugin-runtime/im/service-tokens.js +0 -13
- package/lib/plugin.d.ts +0 -268
- package/lib/plugin.js +0 -583
- package/lib/schema-interaction.d.ts +0 -117
- package/lib/schema-interaction.js +0 -247
- package/lib/side-event/dispatch.d.ts +0 -15
- package/lib/side-event/dispatch.js +0 -140
- package/lib/tool-zod.d.ts +0 -43
- package/lib/tool-zod.js +0 -184
- /package/lib/{built/endpoint-manager.js → jsx/intrinsic-elements.js} +0 -0
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SchemaFeature — 插件配置 Schema 注册表
|
|
3
|
-
*
|
|
4
|
-
* 插件通过 declareConfig(key, schema) 声明配置项及其 Schema,
|
|
5
|
-
* SchemaFeature 全局收集后供 Web 控制台渲染配置编辑表单。
|
|
6
|
-
*
|
|
7
|
-
* 与 ConfigFeature 协作:
|
|
8
|
-
* - declareConfig 内部调用 addConfig(key, defaults) 写入默认值
|
|
9
|
-
* - Schema.toJSON() 传给前端驱动 PluginConfigForm
|
|
10
|
-
* - reloadable 标记决定保存后是否自动重载插件
|
|
11
|
-
*/
|
|
12
|
-
import { Feature } from '@zhin.js/kernel';
|
|
13
|
-
// ============================================================================
|
|
14
|
-
// SchemaFeature
|
|
15
|
-
// ============================================================================
|
|
16
|
-
export class SchemaFeature extends Feature {
|
|
17
|
-
name = 'schema';
|
|
18
|
-
icon = 'FileCode';
|
|
19
|
-
desc = '配置模型';
|
|
20
|
-
/**
|
|
21
|
-
* 按配置 key 查找 Schema
|
|
22
|
-
*/
|
|
23
|
-
getByKey(key) {
|
|
24
|
-
return this.items.find(r => r.key === key) ?? null;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* 获取指定插件名注册的 Schema
|
|
28
|
-
*/
|
|
29
|
-
getByPluginName(pluginName) {
|
|
30
|
-
const list = this.getByPlugin(pluginName);
|
|
31
|
-
return list.length > 0 ? list[0] : null;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 获取某个 key 的 Schema 实例(WebSocket handler 使用)
|
|
35
|
-
*/
|
|
36
|
-
get(keyOrPlugin) {
|
|
37
|
-
const byKey = this.getByKey(keyOrPlugin);
|
|
38
|
-
if (byKey)
|
|
39
|
-
return byKey.schema;
|
|
40
|
-
const byPlugin = this.getByPluginName(keyOrPlugin);
|
|
41
|
-
return byPlugin?.schema ?? null;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 判断某个 key 对应的插件是否支持热重载
|
|
45
|
-
*/
|
|
46
|
-
isReloadable(keyOrPlugin) {
|
|
47
|
-
const byKey = this.getByKey(keyOrPlugin);
|
|
48
|
-
if (byKey)
|
|
49
|
-
return byKey.reloadable;
|
|
50
|
-
const byPlugin = this.getByPluginName(keyOrPlugin);
|
|
51
|
-
return byPlugin?.reloadable ?? true;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* 通过 pluginName 获取对应的 config key
|
|
55
|
-
*/
|
|
56
|
-
resolveConfigKey(pluginName) {
|
|
57
|
-
const byKey = this.getByKey(pluginName);
|
|
58
|
-
if (byKey)
|
|
59
|
-
return byKey.key;
|
|
60
|
-
const byPlugin = this.getByPluginName(pluginName);
|
|
61
|
-
return byPlugin?.key ?? null;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* 返回 pluginName → configKey 的映射
|
|
65
|
-
*/
|
|
66
|
-
getPluginKeyMap() {
|
|
67
|
-
const map = new Map();
|
|
68
|
-
for (const [pluginName, records] of this.pluginItems) {
|
|
69
|
-
if (records.length > 0) {
|
|
70
|
-
map.set(pluginName, records[0].key);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return map;
|
|
74
|
-
}
|
|
75
|
-
toJSON(pluginName) {
|
|
76
|
-
const list = pluginName ? this.getByPlugin(pluginName) : this.items;
|
|
77
|
-
return {
|
|
78
|
-
name: this.name,
|
|
79
|
-
icon: this.icon,
|
|
80
|
-
desc: this.desc,
|
|
81
|
-
count: list.length,
|
|
82
|
-
items: list.map(r => ({
|
|
83
|
-
name: r.key,
|
|
84
|
-
reloadable: r.reloadable,
|
|
85
|
-
schema: r.schema.toJSON(),
|
|
86
|
-
})),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
get extensions() {
|
|
90
|
-
const feature = this;
|
|
91
|
-
return {
|
|
92
|
-
declareConfig(key, schema, options) {
|
|
93
|
-
const plugin = this;
|
|
94
|
-
const reloadable = options?.reloadable ?? true;
|
|
95
|
-
// 从 Schema 提取默认值
|
|
96
|
-
const defaults = extractDefaults(schema);
|
|
97
|
-
// 注册到 ConfigFeature(写入 config.yml 的默认值)
|
|
98
|
-
if (typeof plugin.addConfig === 'function') {
|
|
99
|
-
plugin.addConfig(key, defaults);
|
|
100
|
-
}
|
|
101
|
-
// 注册到 SchemaFeature
|
|
102
|
-
const record = { key, schema, reloadable };
|
|
103
|
-
const dispose = feature.add(record, plugin.name);
|
|
104
|
-
plugin.recordFeatureContribution(feature.name, key);
|
|
105
|
-
plugin.onDispose(dispose);
|
|
106
|
-
// 读取当前配置并与默认值合并
|
|
107
|
-
const root = plugin.root ?? plugin;
|
|
108
|
-
const configService = root.inject('config');
|
|
109
|
-
const appConfig = configService?.getPrimary?.() ?? {};
|
|
110
|
-
const current = appConfig[key] ?? {};
|
|
111
|
-
return { ...defaults, ...current };
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// ============================================================================
|
|
117
|
-
// 辅助:从 Schema 提取默认值
|
|
118
|
-
// ============================================================================
|
|
119
|
-
function extractDefaults(schema) {
|
|
120
|
-
const json = schema.toJSON();
|
|
121
|
-
const result = {};
|
|
122
|
-
const fields = json.object || json.properties || json.dict || {};
|
|
123
|
-
for (const [fieldKey, fieldSchema] of Object.entries(fields)) {
|
|
124
|
-
const field = fieldSchema;
|
|
125
|
-
if (field.default !== undefined) {
|
|
126
|
-
result[fieldKey] = field.default;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return result;
|
|
130
|
-
}
|
package/lib/built/skill.d.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SkillFeature — AI 可见能力描述层
|
|
3
|
-
*
|
|
4
|
-
* 核心概念:
|
|
5
|
-
* Plugin = 运行时容器(生命周期、服务注册、中间件)
|
|
6
|
-
* Skill = AI 可见的能力接口(名称、描述、工具列表)
|
|
7
|
-
*
|
|
8
|
-
* Skill 记录由运行时注入(如 Agent 从磁盘 SKILL.md 同步),供 Agent 粗筛与工具关联。
|
|
9
|
-
*
|
|
10
|
-
* SkillFeature 全局收集所有 Skill,供 Agent 进行两级过滤:
|
|
11
|
-
* 1. 粗筛:根据用户消息选择相关 Skill
|
|
12
|
-
* 2. 细筛:从选中 Skill 内选择具体 Tool
|
|
13
|
-
*/
|
|
14
|
-
import { Feature, FeatureJSON } from '@zhin.js/kernel';
|
|
15
|
-
import type { Tool } from '../types.js';
|
|
16
|
-
/**
|
|
17
|
-
* Skill — AI 可见的能力描述
|
|
18
|
-
*/
|
|
19
|
-
export interface Skill {
|
|
20
|
-
/** 技能名称(通常与插件名一致) */
|
|
21
|
-
name: string;
|
|
22
|
-
/** 技能描述(AI 用来理解这个 Skill 的用途) */
|
|
23
|
-
description: string;
|
|
24
|
-
/** 该 Skill 提供的工具列表 */
|
|
25
|
-
tools: Tool[];
|
|
26
|
-
/**
|
|
27
|
-
* 支持的平台列表
|
|
28
|
-
* 例如:['icqq', 'discord']
|
|
29
|
-
* 不填则为通用 Skill(所有平台可用)
|
|
30
|
-
*/
|
|
31
|
-
platforms?: string[];
|
|
32
|
-
/**
|
|
33
|
-
* 触发关键词
|
|
34
|
-
* 当用户消息包含这些关键词时,优先选择此 Skill
|
|
35
|
-
*/
|
|
36
|
-
keywords?: string[];
|
|
37
|
-
/**
|
|
38
|
-
* 分类标签
|
|
39
|
-
* 用于按领域分组(如 'news', 'weather', 'entertainment')
|
|
40
|
-
*/
|
|
41
|
-
tags?: string[];
|
|
42
|
-
/** 来源插件名 */
|
|
43
|
-
pluginName: string;
|
|
44
|
-
/**
|
|
45
|
-
* SKILL.md 文件的绝对路径
|
|
46
|
-
* 存在时 activate_skill 可按需加载完整指令内容
|
|
47
|
-
*/
|
|
48
|
-
filePath?: string;
|
|
49
|
-
/**
|
|
50
|
-
* 是否常驻注入 system prompt
|
|
51
|
-
* 仅在 filePath 存在时有效
|
|
52
|
-
*/
|
|
53
|
-
always?: boolean;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* SKILL.md frontmatter 常见字段(类型提示;运行时由 Agent 等同步到 SkillFeature)
|
|
57
|
-
*/
|
|
58
|
-
export interface SkillMetadata {
|
|
59
|
-
/** 技能描述(必填) */
|
|
60
|
-
description: string;
|
|
61
|
-
/** 触发关键词(可选) */
|
|
62
|
-
keywords?: string[];
|
|
63
|
-
/** 分类标签(可选) */
|
|
64
|
-
tags?: string[];
|
|
65
|
-
}
|
|
66
|
-
declare module '../plugin.js' {
|
|
67
|
-
namespace Plugin {
|
|
68
|
-
interface Contexts {
|
|
69
|
-
skill: SkillFeature;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
export declare class SkillFeature extends Feature<Skill> {
|
|
74
|
-
#private;
|
|
75
|
-
readonly name: "skill";
|
|
76
|
-
readonly icon = "Brain";
|
|
77
|
-
readonly desc = "\u6280\u80FD";
|
|
78
|
-
/** 按名称索引 */
|
|
79
|
-
readonly byName: Map<string, Skill>;
|
|
80
|
-
/**
|
|
81
|
-
* 添加 Skill
|
|
82
|
-
*/
|
|
83
|
-
add(skill: Skill, pluginName: string): () => void;
|
|
84
|
-
/**
|
|
85
|
-
* 移除 Skill
|
|
86
|
-
*/
|
|
87
|
-
remove(skill: Skill): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* 按名称获取 Skill
|
|
90
|
-
*/
|
|
91
|
-
get(name: string): Skill | undefined;
|
|
92
|
-
/**
|
|
93
|
-
* 清理所有 Skill 注册(热重载时由 Plugin.stop() 调用)
|
|
94
|
-
*/
|
|
95
|
-
dispose(): void;
|
|
96
|
-
/**
|
|
97
|
-
* 获取所有已注册 Skill
|
|
98
|
-
*/
|
|
99
|
-
getAll(): Skill[];
|
|
100
|
-
/**
|
|
101
|
-
* 按关键词/标签搜索相关 Skill
|
|
102
|
-
* 返回按相关性排序的 Skill 列表
|
|
103
|
-
*/
|
|
104
|
-
search(query: string, options?: {
|
|
105
|
-
maxResults?: number;
|
|
106
|
-
platform?: string;
|
|
107
|
-
}): Skill[];
|
|
108
|
-
/**
|
|
109
|
-
* 获取所有 Skill 的工具(扁平化)
|
|
110
|
-
*/
|
|
111
|
-
collectAllTools(): Tool[];
|
|
112
|
-
/**
|
|
113
|
-
* 已注册 Skill 数量
|
|
114
|
-
*/
|
|
115
|
-
get size(): number;
|
|
116
|
-
/**
|
|
117
|
-
* 序列化为 JSON
|
|
118
|
-
*/
|
|
119
|
-
toJSON(pluginName?: string): FeatureJSON;
|
|
120
|
-
}
|
package/lib/built/skill.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SkillFeature — AI 可见能力描述层
|
|
3
|
-
*
|
|
4
|
-
* 核心概念:
|
|
5
|
-
* Plugin = 运行时容器(生命周期、服务注册、中间件)
|
|
6
|
-
* Skill = AI 可见的能力接口(名称、描述、工具列表)
|
|
7
|
-
*
|
|
8
|
-
* Skill 记录由运行时注入(如 Agent 从磁盘 SKILL.md 同步),供 Agent 粗筛与工具关联。
|
|
9
|
-
*
|
|
10
|
-
* SkillFeature 全局收集所有 Skill,供 Agent 进行两级过滤:
|
|
11
|
-
* 1. 粗筛:根据用户消息选择相关 Skill
|
|
12
|
-
* 2. 细筛:从选中 Skill 内选择具体 Tool
|
|
13
|
-
*/
|
|
14
|
-
import { Feature } from '@zhin.js/kernel';
|
|
15
|
-
// ============================================================================
|
|
16
|
-
// SkillFeature 实现
|
|
17
|
-
// ============================================================================
|
|
18
|
-
export class SkillFeature extends Feature {
|
|
19
|
-
name = 'skill';
|
|
20
|
-
icon = 'Brain';
|
|
21
|
-
desc = '技能';
|
|
22
|
-
/** 按名称索引 */
|
|
23
|
-
byName = new Map();
|
|
24
|
-
/**
|
|
25
|
-
* 添加 Skill
|
|
26
|
-
*/
|
|
27
|
-
add(skill, pluginName) {
|
|
28
|
-
this.byName.set(skill.name, skill);
|
|
29
|
-
return super.add(skill, pluginName);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* 移除 Skill
|
|
33
|
-
*/
|
|
34
|
-
remove(skill) {
|
|
35
|
-
this.byName.delete(skill.name);
|
|
36
|
-
return super.remove(skill);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* 按名称获取 Skill
|
|
40
|
-
*/
|
|
41
|
-
get(name) {
|
|
42
|
-
return this.byName.get(name);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* 清理所有 Skill 注册(热重载时由 Plugin.stop() 调用)
|
|
46
|
-
*/
|
|
47
|
-
dispose() {
|
|
48
|
-
this.byName.clear();
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* 获取所有已注册 Skill
|
|
52
|
-
*/
|
|
53
|
-
getAll() {
|
|
54
|
-
return [...this.items];
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* 按关键词/标签搜索相关 Skill
|
|
58
|
-
* 返回按相关性排序的 Skill 列表
|
|
59
|
-
*/
|
|
60
|
-
search(query, options) {
|
|
61
|
-
const maxResults = options?.maxResults ?? 5;
|
|
62
|
-
const platform = options?.platform;
|
|
63
|
-
const scored = this.items
|
|
64
|
-
.filter(skill => {
|
|
65
|
-
// 平台过滤:有 platforms 限制的 skill 必须匹配当前平台
|
|
66
|
-
if (platform && skill.platforms?.length) {
|
|
67
|
-
return skill.platforms.includes(platform);
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
})
|
|
71
|
-
.map(skill => ({ skill, score: this.#scoreSkill(skill, query) }))
|
|
72
|
-
.filter(({ score }) => score > 0)
|
|
73
|
-
.sort((a, b) => b.score - a.score)
|
|
74
|
-
.slice(0, maxResults);
|
|
75
|
-
return scored.map(({ skill }) => skill);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* 获取所有 Skill 的工具(扁平化)
|
|
79
|
-
*/
|
|
80
|
-
collectAllTools() {
|
|
81
|
-
const tools = [];
|
|
82
|
-
for (const skill of this.items) {
|
|
83
|
-
tools.push(...skill.tools);
|
|
84
|
-
}
|
|
85
|
-
return tools;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* 已注册 Skill 数量
|
|
89
|
-
*/
|
|
90
|
-
get size() {
|
|
91
|
-
return this.items.length;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* 简单的关键词匹配评分
|
|
95
|
-
*/
|
|
96
|
-
#scoreSkill(skill, query) {
|
|
97
|
-
const lowerQuery = query.toLowerCase();
|
|
98
|
-
let score = 0;
|
|
99
|
-
// 关键词精确匹配
|
|
100
|
-
if (skill.keywords) {
|
|
101
|
-
for (const kw of skill.keywords) {
|
|
102
|
-
if (lowerQuery.includes(kw.toLowerCase()))
|
|
103
|
-
score += 1.0;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// 标签匹配
|
|
107
|
-
if (skill.tags) {
|
|
108
|
-
for (const tag of skill.tags) {
|
|
109
|
-
if (lowerQuery.includes(tag.toLowerCase()))
|
|
110
|
-
score += 0.5;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
// 名称匹配
|
|
114
|
-
if (lowerQuery.includes(skill.name.toLowerCase()))
|
|
115
|
-
score += 0.3;
|
|
116
|
-
// 描述匹配(双向)
|
|
117
|
-
const lowerDesc = skill.description.toLowerCase();
|
|
118
|
-
if (lowerDesc.includes(lowerQuery))
|
|
119
|
-
score += 0.2;
|
|
120
|
-
if (lowerQuery.includes(lowerDesc))
|
|
121
|
-
score += 0.15;
|
|
122
|
-
// 工具名/描述匹配
|
|
123
|
-
for (const tool of skill.tools) {
|
|
124
|
-
if (lowerQuery.includes(tool.name.toLowerCase()))
|
|
125
|
-
score += 0.4;
|
|
126
|
-
if (tool.description && lowerQuery.includes(tool.description.toLowerCase().slice(0, 10))) {
|
|
127
|
-
score += 0.1;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return score;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* 序列化为 JSON
|
|
134
|
-
*/
|
|
135
|
-
toJSON(pluginName) {
|
|
136
|
-
const list = pluginName ? this.getByPlugin(pluginName) : this.items;
|
|
137
|
-
return {
|
|
138
|
-
name: this.name,
|
|
139
|
-
icon: this.icon,
|
|
140
|
-
desc: this.desc,
|
|
141
|
-
count: list.length,
|
|
142
|
-
items: list.map(s => ({
|
|
143
|
-
name: s.name,
|
|
144
|
-
desc: s.description,
|
|
145
|
-
toolCount: s.tools.length,
|
|
146
|
-
keywords: s.keywords,
|
|
147
|
-
tags: s.tags,
|
|
148
|
-
})),
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { SpeechPipelineForRichSegment } from './rich-segments/types.js';
|
|
2
|
-
/** 动态 import 时使用的包名(与 @zhin.js/speech package.json 一致) */
|
|
3
|
-
export declare const SPEECH_PACKAGE = "@zhin.js/speech";
|
|
4
|
-
export interface LoadSpeechPipelineOptions {
|
|
5
|
-
getConfig?: () => Record<string, unknown> | undefined;
|
|
6
|
-
warn?: (message: string) => void;
|
|
7
|
-
}
|
|
8
|
-
/** zhin 启动时已创建 pipeline 时注入 */
|
|
9
|
-
export declare function seedSpeechPipeline(pipeline: SpeechPipelineForRichSegment): void;
|
|
10
|
-
/** 动态加载 @zhin.js/speech;未安装时 warn 一次并返回 undefined */
|
|
11
|
-
export declare function loadSpeechPipeline(opts?: LoadSpeechPipelineOptions): Promise<SpeechPipelineForRichSegment | undefined>;
|
|
12
|
-
/** 测试用:重置加载缓存 */
|
|
13
|
-
export declare function resetSpeechLoaderForTests(): void;
|
|
14
|
-
export type { SpeechPipelineForRichSegment };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createWarnOnce, resetWarnOnceForTests } from '@zhin.js/logger';
|
|
2
|
-
import { importOptionalPeerPackage } from './optional-peer-import.js';
|
|
3
|
-
/** 动态 import 时使用的包名(与 @zhin.js/speech package.json 一致) */
|
|
4
|
-
export const SPEECH_PACKAGE = '@zhin.js/speech';
|
|
5
|
-
let cached;
|
|
6
|
-
const speechPeerWarnOnce = createWarnOnce('speech');
|
|
7
|
-
/** zhin 启动时已创建 pipeline 时注入 */
|
|
8
|
-
export function seedSpeechPipeline(pipeline) {
|
|
9
|
-
cached = pipeline;
|
|
10
|
-
}
|
|
11
|
-
/** 动态加载 @zhin.js/speech;未安装时 warn 一次并返回 undefined */
|
|
12
|
-
export async function loadSpeechPipeline(opts) {
|
|
13
|
-
if (cached !== undefined) {
|
|
14
|
-
return cached ?? undefined;
|
|
15
|
-
}
|
|
16
|
-
try {
|
|
17
|
-
const mod = await importOptionalPeerPackage(SPEECH_PACKAGE);
|
|
18
|
-
const speechConfig = opts?.getConfig?.()?.speech;
|
|
19
|
-
cached = mod.createSpeechPipeline(speechConfig);
|
|
20
|
-
return cached;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
speechPeerWarnOnce(opts?.warn, `未安装 ${SPEECH_PACKAGE},STT/TTS 已降级。安装: pnpm add ${SPEECH_PACKAGE}`);
|
|
24
|
-
cached = null;
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/** 测试用:重置加载缓存 */
|
|
29
|
-
export function resetSpeechLoaderForTests() {
|
|
30
|
-
cached = undefined;
|
|
31
|
-
resetWarnOnceForTests('speech');
|
|
32
|
-
}
|
package/lib/built/tool.d.ts
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ToolFeature — 统一的工具管理服务
|
|
3
|
-
* 工具仅面向 AI(通过 MCP 注册),不再与 Command 互转
|
|
4
|
-
*/
|
|
5
|
-
import { Feature, FeatureJSON } from "@zhin.js/kernel";
|
|
6
|
-
import type { Tool, ToolJsonSchema, ToolParametersSchema, PropertySchema, MaybePromise, ToolScope } from "../types.js";
|
|
7
|
-
import type { Message } from "../message.js";
|
|
8
|
-
import { type PermissionHost } from '@zhin.js/permission';
|
|
9
|
-
/**
|
|
10
|
-
* 检查工具是否可被当前 Message 通讯上下文访问。
|
|
11
|
-
* `host` 为 PermissionHost 实例;无 host 且有 permissions → deny。
|
|
12
|
-
*/
|
|
13
|
-
export declare function canAccessTool(tool: Tool, message?: Message<any>, host?: PermissionHost | null): Promise<boolean>;
|
|
14
|
-
/**
|
|
15
|
-
* 从参数定义中提取参数信息
|
|
16
|
-
*/
|
|
17
|
-
export declare function extractParamInfo(parameters: ToolJsonSchema): Tool.ParamInfo[];
|
|
18
|
-
/**
|
|
19
|
-
* 定义工具的辅助函数(提供类型推断)
|
|
20
|
-
*/
|
|
21
|
-
export declare function defineTool<TArgs extends Record<string, any> = Record<string, any>>(tool: Tool<TArgs>): Tool;
|
|
22
|
-
/**
|
|
23
|
-
* 参数定义(带顺序)
|
|
24
|
-
*/
|
|
25
|
-
interface ParamDef {
|
|
26
|
-
name: string;
|
|
27
|
-
schema: PropertySchema;
|
|
28
|
-
required: boolean;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* ZhinTool 类
|
|
32
|
-
* 提供链式调用风格来定义工具
|
|
33
|
-
*/
|
|
34
|
-
export declare class ZhinTool {
|
|
35
|
-
#private;
|
|
36
|
-
constructor(name: string);
|
|
37
|
-
get name(): string;
|
|
38
|
-
get description(): string;
|
|
39
|
-
get params(): ParamDef[];
|
|
40
|
-
desc(description: string): this;
|
|
41
|
-
param(name: string, schema: PropertySchema, required?: boolean): this;
|
|
42
|
-
platform(...platforms: string[]): this;
|
|
43
|
-
scope(...scopes: ToolScope[]): this;
|
|
44
|
-
permit(...permissions: string[]): this;
|
|
45
|
-
tag(...tags: string[]): this;
|
|
46
|
-
keyword(...keywords: string[]): this;
|
|
47
|
-
hidden(value?: boolean): this;
|
|
48
|
-
/**
|
|
49
|
-
* 标记此工具允许被预执行(opt-in)。
|
|
50
|
-
* 仅适用于无副作用的只读工具(如获取系统状态、读取配置等)。
|
|
51
|
-
* 默认为 false,即不预执行。
|
|
52
|
-
*/
|
|
53
|
-
preExec(value?: boolean): this;
|
|
54
|
-
/** 设置工具分类(如 file / shell / web),用于展示与 TOOLS.md 协同 */
|
|
55
|
-
kind(value: string): this;
|
|
56
|
-
execute(callback: (args: Record<string, any>, message?: Message<any>) => MaybePromise<any>): this;
|
|
57
|
-
toTool(): Tool;
|
|
58
|
-
toJSON(): {
|
|
59
|
-
name: string;
|
|
60
|
-
description: string;
|
|
61
|
-
parameters: ToolParametersSchema;
|
|
62
|
-
platforms?: string[];
|
|
63
|
-
scopes?: ToolScope[];
|
|
64
|
-
permissions?: string[];
|
|
65
|
-
tags?: string[];
|
|
66
|
-
};
|
|
67
|
-
get help(): string;
|
|
68
|
-
toString(): string;
|
|
69
|
-
}
|
|
70
|
-
export declare function isZhinTool(obj: any): obj is ZhinTool;
|
|
71
|
-
/**
|
|
72
|
-
* 工具输入类型(支持 Tool 对象或 ZhinTool 实例)
|
|
73
|
-
*/
|
|
74
|
-
export type ToolInput = Tool | ZhinTool;
|
|
75
|
-
/**
|
|
76
|
-
* Message 工具扩展方法类型
|
|
77
|
-
*/
|
|
78
|
-
export interface MessageToolExtensions {
|
|
79
|
-
/** 添加工具 */
|
|
80
|
-
addTool(tool: ToolInput): () => void;
|
|
81
|
-
}
|
|
82
|
-
declare module "../plugin.js" {
|
|
83
|
-
namespace Plugin {
|
|
84
|
-
interface Extensions extends MessageToolExtensions {
|
|
85
|
-
}
|
|
86
|
-
interface Contexts {
|
|
87
|
-
tool: ToolFeature;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
export declare class ToolFeature extends Feature<Tool> {
|
|
92
|
-
#private;
|
|
93
|
-
readonly name: "tool";
|
|
94
|
-
readonly icon = "Wrench";
|
|
95
|
-
readonly desc = "\u5DE5\u5177";
|
|
96
|
-
/** 按名称索引 */
|
|
97
|
-
readonly byName: Map<string, Tool<Record<string, any>>>;
|
|
98
|
-
/**
|
|
99
|
-
* 添加工具(仅注册到 ToolFeature,不再生成 Command)
|
|
100
|
-
* @param toolInput 工具或 ZhinTool 实例
|
|
101
|
-
* @param pluginName 注册插件名
|
|
102
|
-
*/
|
|
103
|
-
addTool(toolInput: ToolInput, pluginName: string): () => void;
|
|
104
|
-
/**
|
|
105
|
-
* 移除工具
|
|
106
|
-
*/
|
|
107
|
-
removeTool(name: string): boolean;
|
|
108
|
-
/**
|
|
109
|
-
* 获取工具
|
|
110
|
-
*/
|
|
111
|
-
get(name: string): Tool | undefined;
|
|
112
|
-
/**
|
|
113
|
-
* 获取所有工具
|
|
114
|
-
*/
|
|
115
|
-
getAll(): Tool[];
|
|
116
|
-
/**
|
|
117
|
-
* 根据标签过滤工具
|
|
118
|
-
*/
|
|
119
|
-
getByTags(tags: string[]): Tool[];
|
|
120
|
-
/**
|
|
121
|
-
* 执行工具
|
|
122
|
-
*/
|
|
123
|
-
execute(name: string, args: Record<string, any>, message?: Message<any>): Promise<any>;
|
|
124
|
-
/**
|
|
125
|
-
* 根据 Message 通讯上下文过滤工具
|
|
126
|
-
*/
|
|
127
|
-
filterByContext(tools: Tool[], message?: Message<any>, host?: PermissionHost | null): Promise<Tool[]>;
|
|
128
|
-
/**
|
|
129
|
-
* 按插件名获取工具
|
|
130
|
-
*/
|
|
131
|
-
getToolsByPlugin(pluginName: string): Tool[];
|
|
132
|
-
/**
|
|
133
|
-
* 生命周期: 销毁时清理所有工具
|
|
134
|
-
*/
|
|
135
|
-
dispose(): void;
|
|
136
|
-
/**
|
|
137
|
-
* 兼容旧接口:tools Map
|
|
138
|
-
*/
|
|
139
|
-
get tools(): Map<string, Tool>;
|
|
140
|
-
/**
|
|
141
|
-
* 序列化为 JSON
|
|
142
|
-
*/
|
|
143
|
-
toJSON(pluginName?: string): FeatureJSON;
|
|
144
|
-
/**
|
|
145
|
-
* 提供给 Plugin.prototype 的扩展方法
|
|
146
|
-
*/
|
|
147
|
-
get extensions(): {
|
|
148
|
-
addTool(tool: ToolInput): () => void;
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
export {};
|