@downcity/plugins 1.0.56 → 1.0.59
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/bin/BuiltinPlugins.d.ts.map +1 -1
- package/bin/BuiltinPlugins.js +0 -6
- package/bin/BuiltinPlugins.js.map +1 -1
- package/bin/asr/Plugin.d.ts +67 -7
- package/bin/asr/Plugin.d.ts.map +1 -1
- package/bin/asr/Plugin.js +229 -461
- package/bin/asr/Plugin.js.map +1 -1
- package/bin/asr/types/AsrPlugin.d.ts +114 -0
- package/bin/asr/types/AsrPlugin.d.ts.map +1 -0
- package/bin/asr/types/AsrPlugin.js +10 -0
- package/bin/asr/types/AsrPlugin.js.map +1 -0
- package/bin/auth/types/AuthPlugin.d.ts +12 -16
- package/bin/auth/types/AuthPlugin.d.ts.map +1 -1
- package/bin/auth/types/AuthPlugin.js +9 -13
- package/bin/auth/types/AuthPlugin.js.map +1 -1
- package/bin/chat/ChatPlugin.d.ts +37 -6
- package/bin/chat/ChatPlugin.d.ts.map +1 -1
- package/bin/chat/ChatPlugin.js +58 -80
- package/bin/chat/ChatPlugin.js.map +1 -1
- package/bin/chat/Index.d.ts +4 -1
- package/bin/chat/Index.d.ts.map +1 -1
- package/bin/chat/Index.js +2 -1
- package/bin/chat/Index.js.map +1 -1
- package/bin/chat/channels/Configuration.d.ts +1 -1
- package/bin/chat/channels/Configuration.js +1 -1
- package/bin/chat/channels/RuntimeChannel.d.ts +145 -0
- package/bin/chat/channels/RuntimeChannel.d.ts.map +1 -0
- package/bin/chat/channels/RuntimeChannel.js +148 -0
- package/bin/chat/channels/RuntimeChannel.js.map +1 -0
- package/bin/chat/runtime/ChatAuthorizationRuntime.d.ts +22 -0
- package/bin/chat/runtime/ChatAuthorizationRuntime.d.ts.map +1 -0
- package/bin/chat/runtime/ChatAuthorizationRuntime.js +189 -0
- package/bin/chat/runtime/ChatAuthorizationRuntime.js.map +1 -0
- package/bin/chat/runtime/ChatChannelActions.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelActions.js +19 -9
- package/bin/chat/runtime/ChatChannelActions.js.map +1 -1
- package/bin/chat/runtime/ChatChannelConfig.d.ts +2 -18
- package/bin/chat/runtime/ChatChannelConfig.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelConfig.js +2 -73
- package/bin/chat/runtime/ChatChannelConfig.js.map +1 -1
- package/bin/chat/runtime/ChatChannelCore.d.ts +22 -1
- package/bin/chat/runtime/ChatChannelCore.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelCore.js +5 -5
- package/bin/chat/runtime/ChatChannelCore.js.map +1 -1
- package/bin/chat/runtime/ChatPluginActionRegistry.js +1 -1
- package/bin/chat/runtime/ChatPluginActionRegistry.js.map +1 -1
- package/bin/chat/runtime/PluginPoints.d.ts +3 -3
- package/bin/chat/runtime/PluginPoints.js +3 -3
- package/bin/chat/types/ChannelStatus.d.ts +1 -1
- package/bin/chat/types/ChatPluginOptions.d.ts +76 -0
- package/bin/chat/types/ChatPluginOptions.d.ts.map +1 -0
- package/bin/chat/types/ChatPluginOptions.js +10 -0
- package/bin/chat/types/ChatPluginOptions.js.map +1 -0
- package/bin/image/ImagePlugin.d.ts +1 -1
- package/bin/image/ImagePlugin.d.ts.map +1 -1
- package/bin/image/ImagePlugin.js +23 -5
- package/bin/image/ImagePlugin.js.map +1 -1
- package/bin/index.d.ts +6 -3
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +2 -2
- package/bin/index.js.map +1 -1
- package/bin/skill/Action.d.ts.map +1 -1
- package/bin/skill/Action.js +2 -2
- package/bin/skill/Action.js.map +1 -1
- package/bin/skill/Command.js +5 -5
- package/bin/skill/Command.js.map +1 -1
- package/bin/skill/Plugin.js +1 -1
- package/bin/skill/Plugin.js.map +1 -1
- package/bin/skill/runtime/Discovery.d.ts +4 -4
- package/bin/skill/runtime/Discovery.d.ts.map +1 -1
- package/bin/skill/runtime/Discovery.js +5 -5
- package/bin/skill/runtime/Discovery.js.map +1 -1
- package/bin/skill/runtime/Paths.d.ts +1 -5
- package/bin/skill/runtime/Paths.d.ts.map +1 -1
- package/bin/skill/runtime/Paths.js +1 -9
- package/bin/skill/runtime/Paths.js.map +1 -1
- package/bin/skill/runtime/Prompt.d.ts +2 -2
- package/bin/skill/runtime/Prompt.d.ts.map +1 -1
- package/bin/skill/runtime/Prompt.js +3 -3
- package/bin/skill/runtime/Prompt.js.map +1 -1
- package/bin/skill/runtime/Store.d.ts +2 -2
- package/bin/skill/runtime/Store.d.ts.map +1 -1
- package/bin/skill/runtime/Store.js.map +1 -1
- package/bin/skill/runtime/SystemProvider.js +4 -4
- package/bin/skill/runtime/SystemProvider.js.map +1 -1
- package/bin/skill/runtime/Types.d.ts +3 -3
- package/bin/skill/runtime/Types.d.ts.map +1 -1
- package/bin/skill/types/{ClaudeSkill.d.ts → SkillDefinition.d.ts} +4 -4
- package/bin/skill/types/SkillDefinition.d.ts.map +1 -0
- package/bin/skill/types/{ClaudeSkill.js → SkillDefinition.js} +2 -2
- package/bin/skill/types/SkillDefinition.js.map +1 -0
- package/bin/skill/types/SkillPlugin.d.ts +2 -2
- package/bin/skill/types/SkillPlugin.d.ts.map +1 -1
- package/bin/tts/Plugin.d.ts +53 -6
- package/bin/tts/Plugin.d.ts.map +1 -1
- package/bin/tts/Plugin.js +197 -474
- package/bin/tts/Plugin.js.map +1 -1
- package/bin/tts/types/TtsPlugin.d.ts +63 -102
- package/bin/tts/types/TtsPlugin.d.ts.map +1 -1
- package/bin/tts/types/TtsPlugin.js +4 -3
- package/bin/tts/types/TtsPlugin.js.map +1 -1
- package/bin/web/PROMPT.d.ts +1 -1
- package/bin/web/PROMPT.d.ts.map +1 -1
- package/bin/web/PROMPT.js +1 -1
- package/bin/web/PROMPT.js.map +1 -1
- package/bin/web/Plugin.d.ts +66 -5
- package/bin/web/Plugin.d.ts.map +1 -1
- package/bin/web/Plugin.js +126 -450
- package/bin/web/Plugin.js.map +1 -1
- package/bin/web/WebPromptAssets.d.ts +1 -9
- package/bin/web/WebPromptAssets.d.ts.map +1 -1
- package/bin/web/WebPromptAssets.js +1 -11
- package/bin/web/WebPromptAssets.js.map +1 -1
- package/bin/web/runtime/Install.d.ts +19 -0
- package/bin/web/runtime/Install.d.ts.map +1 -0
- package/bin/web/runtime/Install.js +178 -0
- package/bin/web/runtime/Install.js.map +1 -0
- package/bin/web/types/WebPlugin.d.ts +38 -109
- package/bin/web/types/WebPlugin.d.ts.map +1 -1
- package/bin/web/types/WebPlugin.js +5 -7
- package/bin/web/types/WebPlugin.js.map +1 -1
- package/bin/workboard/Plugin.d.ts +23 -3
- package/bin/workboard/Plugin.d.ts.map +1 -1
- package/bin/workboard/Plugin.js +66 -85
- package/bin/workboard/Plugin.js.map +1 -1
- package/package.json +2 -2
- package/src/BuiltinPlugins.ts +0 -6
- package/src/asr/Plugin.ts +264 -483
- package/src/asr/types/AsrPlugin.ts +118 -0
- package/src/auth/types/AuthPlugin.ts +12 -17
- package/src/chat/ChatPlugin.ts +92 -89
- package/src/chat/Index.ts +18 -1
- package/src/chat/channels/Configuration.ts +1 -1
- package/src/chat/channels/RuntimeChannel.ts +264 -0
- package/src/chat/runtime/ChatAuthorizationRuntime.ts +229 -0
- package/src/chat/runtime/ChatChannelActions.ts +24 -9
- package/src/chat/runtime/ChatChannelConfig.ts +2 -100
- package/src/chat/runtime/ChatChannelCore.ts +20 -8
- package/src/chat/runtime/ChatPluginActionRegistry.ts +1 -1
- package/src/chat/runtime/PluginPoints.ts +3 -3
- package/src/chat/types/ChannelStatus.ts +1 -1
- package/src/chat/types/ChatPluginOptions.ts +79 -0
- package/src/image/ImagePlugin.ts +23 -5
- package/src/index.ts +29 -6
- package/src/skill/Action.ts +10 -7
- package/src/skill/Command.ts +5 -5
- package/src/skill/Plugin.ts +1 -1
- package/src/skill/runtime/Discovery.ts +14 -11
- package/src/skill/runtime/Paths.ts +1 -13
- package/src/skill/runtime/Prompt.ts +5 -5
- package/src/skill/runtime/Store.ts +6 -3
- package/src/skill/runtime/SystemProvider.ts +4 -4
- package/src/skill/runtime/Types.ts +3 -3
- package/src/skill/types/{ClaudeSkill.ts → SkillDefinition.ts} +3 -3
- package/src/skill/types/SkillPlugin.ts +2 -2
- package/src/tts/Plugin.ts +225 -492
- package/src/tts/types/TtsPlugin.ts +67 -102
- package/src/web/PROMPT.ts +1 -1
- package/src/web/PROMPT.ts.txt +32 -6
- package/src/web/Plugin.ts +119 -453
- package/src/web/WebPromptAssets.ts +1 -13
- package/src/web/runtime/Install.ts +241 -0
- package/src/web/types/WebPlugin.ts +38 -114
- package/src/workboard/Plugin.ts +80 -95
- package/bin/asr/Config.d.ts +0 -43
- package/bin/asr/Config.d.ts.map +0 -1
- package/bin/asr/Config.js +0 -107
- package/bin/asr/Config.js.map +0 -1
- package/bin/asr/Dependency.d.ts +0 -77
- package/bin/asr/Dependency.d.ts.map +0 -1
- package/bin/asr/Dependency.js +0 -238
- package/bin/asr/Dependency.js.map +0 -1
- package/bin/asr/InboundAugment.d.ts +0 -17
- package/bin/asr/InboundAugment.d.ts.map +0 -1
- package/bin/asr/InboundAugment.js +0 -47
- package/bin/asr/InboundAugment.js.map +0 -1
- package/bin/asr/ModelCatalog.d.ts +0 -29
- package/bin/asr/ModelCatalog.d.ts.map +0 -1
- package/bin/asr/ModelCatalog.js +0 -25
- package/bin/asr/ModelCatalog.js.map +0 -1
- package/bin/auth/Plugin.d.ts +0 -17
- package/bin/auth/Plugin.d.ts.map +0 -1
- package/bin/auth/Plugin.js +0 -199
- package/bin/auth/Plugin.js.map +0 -1
- package/bin/chat/ChatPluginTypes.d.ts +0 -122
- package/bin/chat/ChatPluginTypes.d.ts.map +0 -1
- package/bin/chat/ChatPluginTypes.js +0 -10
- package/bin/chat/ChatPluginTypes.js.map +0 -1
- package/bin/skill/types/ClaudeSkill.d.ts.map +0 -1
- package/bin/skill/types/ClaudeSkill.js.map +0 -1
- package/bin/tts/Dependency.d.ts +0 -90
- package/bin/tts/Dependency.d.ts.map +0 -1
- package/bin/tts/Dependency.js +0 -344
- package/bin/tts/Dependency.js.map +0 -1
- package/bin/tts/PluginSupport.d.ts +0 -25
- package/bin/tts/PluginSupport.d.ts.map +0 -1
- package/bin/tts/PluginSupport.js +0 -72
- package/bin/tts/PluginSupport.js.map +0 -1
- package/bin/tts/runtime/Catalog.d.ts +0 -21
- package/bin/tts/runtime/Catalog.d.ts.map +0 -1
- package/bin/tts/runtime/Catalog.js +0 -90
- package/bin/tts/runtime/Catalog.js.map +0 -1
- package/bin/tts/runtime/DependencyInstaller.d.ts +0 -143
- package/bin/tts/runtime/DependencyInstaller.d.ts.map +0 -1
- package/bin/tts/runtime/DependencyInstaller.js +0 -261
- package/bin/tts/runtime/DependencyInstaller.js.map +0 -1
- package/bin/tts/runtime/Installer.d.ts +0 -89
- package/bin/tts/runtime/Installer.d.ts.map +0 -1
- package/bin/tts/runtime/Installer.js +0 -188
- package/bin/tts/runtime/Installer.js.map +0 -1
- package/bin/tts/runtime/Paths.d.ts +0 -20
- package/bin/tts/runtime/Paths.d.ts.map +0 -1
- package/bin/tts/runtime/Paths.js +0 -32
- package/bin/tts/runtime/Paths.js.map +0 -1
- package/bin/tts/runtime/Synthesizer.d.ts +0 -44
- package/bin/tts/runtime/Synthesizer.d.ts.map +0 -1
- package/bin/tts/runtime/Synthesizer.js +0 -363
- package/bin/tts/runtime/Synthesizer.js.map +0 -1
- package/bin/tts/types/Tts.d.ts +0 -91
- package/bin/tts/types/Tts.d.ts.map +0 -1
- package/bin/tts/types/Tts.js +0 -9
- package/bin/tts/types/Tts.js.map +0 -1
- package/bin/voice/Config.d.ts +0 -43
- package/bin/voice/Config.d.ts.map +0 -1
- package/bin/voice/Config.js +0 -104
- package/bin/voice/Config.js.map +0 -1
- package/bin/voice/Dependency.d.ts +0 -77
- package/bin/voice/Dependency.d.ts.map +0 -1
- package/bin/voice/Dependency.js +0 -237
- package/bin/voice/Dependency.js.map +0 -1
- package/bin/voice/InboundAugment.d.ts +0 -17
- package/bin/voice/InboundAugment.d.ts.map +0 -1
- package/bin/voice/InboundAugment.js +0 -47
- package/bin/voice/InboundAugment.js.map +0 -1
- package/bin/voice/ModelCatalog.d.ts +0 -29
- package/bin/voice/ModelCatalog.d.ts.map +0 -1
- package/bin/voice/ModelCatalog.js +0 -25
- package/bin/voice/ModelCatalog.js.map +0 -1
- package/bin/voice/runtime/Catalog.d.ts +0 -18
- package/bin/voice/runtime/Catalog.d.ts.map +0 -1
- package/bin/voice/runtime/Catalog.js +0 -61
- package/bin/voice/runtime/Catalog.js.map +0 -1
- package/bin/voice/runtime/DependencyInstaller.d.ts +0 -145
- package/bin/voice/runtime/DependencyInstaller.d.ts.map +0 -1
- package/bin/voice/runtime/DependencyInstaller.js +0 -309
- package/bin/voice/runtime/DependencyInstaller.js.map +0 -1
- package/bin/voice/runtime/Installer.d.ts +0 -94
- package/bin/voice/runtime/Installer.d.ts.map +0 -1
- package/bin/voice/runtime/Installer.js +0 -200
- package/bin/voice/runtime/Installer.js.map +0 -1
- package/bin/voice/runtime/Paths.d.ts +0 -8
- package/bin/voice/runtime/Paths.d.ts.map +0 -1
- package/bin/voice/runtime/Paths.js +0 -26
- package/bin/voice/runtime/Paths.js.map +0 -1
- package/bin/voice/runtime/Transcriber.d.ts +0 -57
- package/bin/voice/runtime/Transcriber.d.ts.map +0 -1
- package/bin/voice/runtime/Transcriber.js +0 -329
- package/bin/voice/runtime/Transcriber.js.map +0 -1
- package/bin/voice/types/Voice.d.ts +0 -58
- package/bin/voice/types/Voice.d.ts.map +0 -1
- package/bin/voice/types/Voice.js +0 -9
- package/bin/voice/types/Voice.js.map +0 -1
- package/bin/voice/types/VoicePlugin.d.ts +0 -190
- package/bin/voice/types/VoicePlugin.d.ts.map +0 -1
- package/bin/voice/types/VoicePlugin.js +0 -9
- package/bin/voice/types/VoicePlugin.js.map +0 -1
- package/bin/web/Dependency.d.ts +0 -10
- package/bin/web/Dependency.d.ts.map +0 -1
- package/bin/web/Dependency.js +0 -10
- package/bin/web/Dependency.js.map +0 -1
- package/bin/web/PROMPT.agent-browser.d.ts +0 -7
- package/bin/web/PROMPT.agent-browser.d.ts.map +0 -1
- package/bin/web/PROMPT.agent-browser.js +0 -8
- package/bin/web/PROMPT.agent-browser.js.map +0 -1
- package/bin/web/PROMPT.web-access.d.ts +0 -7
- package/bin/web/PROMPT.web-access.d.ts.map +0 -1
- package/bin/web/PROMPT.web-access.js +0 -8
- package/bin/web/PROMPT.web-access.js.map +0 -1
- package/bin/web/runtime/Config.d.ts +0 -21
- package/bin/web/runtime/Config.d.ts.map +0 -1
- package/bin/web/runtime/Config.js +0 -79
- package/bin/web/runtime/Config.js.map +0 -1
- package/bin/web/runtime/Source.d.ts +0 -29
- package/bin/web/runtime/Source.d.ts.map +0 -1
- package/bin/web/runtime/Source.js +0 -209
- package/bin/web/runtime/Source.js.map +0 -1
- package/src/asr/Config.ts +0 -138
- package/src/asr/Dependency.ts +0 -336
- package/src/asr/InboundAugment.ts +0 -59
- package/src/asr/ModelCatalog.ts +0 -43
- package/src/auth/Plugin.ts +0 -237
- package/src/chat/ChatPluginTypes.ts +0 -126
- package/src/tts/Dependency.ts +0 -473
- package/src/tts/PluginSupport.ts +0 -85
- package/src/tts/runtime/Catalog.ts +0 -97
- package/src/tts/runtime/DependencyInstaller.ts +0 -436
- package/src/tts/runtime/Installer.ts +0 -297
- package/src/tts/runtime/Paths.ts +0 -39
- package/src/tts/runtime/Synthesizer.ts +0 -480
- package/src/tts/types/Tts.ts +0 -99
- package/src/voice/Config.ts +0 -135
- package/src/voice/Dependency.ts +0 -329
- package/src/voice/InboundAugment.ts +0 -59
- package/src/voice/ModelCatalog.ts +0 -43
- package/src/voice/runtime/Catalog.ts +0 -68
- package/src/voice/runtime/DependencyInstaller.ts +0 -505
- package/src/voice/runtime/Installer.ts +0 -324
- package/src/voice/runtime/Paths.ts +0 -26
- package/src/voice/runtime/Transcriber.ts +0 -467
- package/src/voice/types/Voice.ts +0 -68
- package/src/voice/types/VoicePlugin.ts +0 -194
- package/src/web/Dependency.ts +0 -17
- package/src/web/PROMPT.agent-browser.ts +0 -9
- package/src/web/PROMPT.agent-browser.ts.txt +0 -17
- package/src/web/PROMPT.web-access.ts +0 -9
- package/src/web/PROMPT.web-access.ts.txt +0 -13
- package/src/web/runtime/Config.ts +0 -105
- package/src/web/runtime/Source.ts +0 -257
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AsrPlugin 类型定义。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - ASR plugin 只定义 agent 侧协议,不绑定本地模型、Python 或 City 具体实现。
|
|
6
|
+
* - 真实转写能力通过 constructor 的 `asr` 函数注入,推荐传入 `city.ai.asr`。
|
|
7
|
+
* - `auto` 只表示是否在 chat 入站时自动转写语音附件。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { JsonObject, JsonValue } from "@downcity/agent/internal/types/common/Json.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ASR 输入。
|
|
14
|
+
*/
|
|
15
|
+
export interface AsrPluginInput {
|
|
16
|
+
/**
|
|
17
|
+
* 本地音频文件路径。
|
|
18
|
+
*
|
|
19
|
+
* 说明(中文)
|
|
20
|
+
* - chat runtime 下载附件后会传入本地路径。
|
|
21
|
+
* - 显式 action 调用时也优先使用该字段。
|
|
22
|
+
*/
|
|
23
|
+
audio_path?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 远程音频 URL。
|
|
26
|
+
*/
|
|
27
|
+
url?: string;
|
|
28
|
+
/**
|
|
29
|
+
* data URL 音频内容。
|
|
30
|
+
*/
|
|
31
|
+
data_url?: string;
|
|
32
|
+
/**
|
|
33
|
+
* 语言提示,例如 `auto`、`zh`、`en`。
|
|
34
|
+
*/
|
|
35
|
+
language?: string;
|
|
36
|
+
/**
|
|
37
|
+
* 音频 MIME 类型,例如 `audio/ogg`。
|
|
38
|
+
*/
|
|
39
|
+
media_type?: string;
|
|
40
|
+
/**
|
|
41
|
+
* 原始文件名。
|
|
42
|
+
*/
|
|
43
|
+
file_name?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Provider 私有参数。
|
|
46
|
+
*/
|
|
47
|
+
provider_options?: JsonObject;
|
|
48
|
+
/**
|
|
49
|
+
* 允许外部 asr 函数接收其他 JSON 可序列化参数。
|
|
50
|
+
*/
|
|
51
|
+
[key: string]: JsonValue | undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* ASR 输出。
|
|
56
|
+
*/
|
|
57
|
+
export interface AsrPluginResult {
|
|
58
|
+
/**
|
|
59
|
+
* 转写文本。
|
|
60
|
+
*/
|
|
61
|
+
text: string;
|
|
62
|
+
/**
|
|
63
|
+
* 识别到的语言(可选)。
|
|
64
|
+
*/
|
|
65
|
+
language?: string;
|
|
66
|
+
/**
|
|
67
|
+
* 结果置信度(可选)。
|
|
68
|
+
*/
|
|
69
|
+
confidence?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Provider 原始元信息(可选)。
|
|
72
|
+
*/
|
|
73
|
+
metadata?: JsonObject;
|
|
74
|
+
/**
|
|
75
|
+
* 允许外部 asr 函数返回其他 JSON 可序列化字段。
|
|
76
|
+
*/
|
|
77
|
+
[key: string]: JsonValue | undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* AsrPlugin 构造参数。
|
|
82
|
+
*/
|
|
83
|
+
export interface AsrPluginOptions {
|
|
84
|
+
/**
|
|
85
|
+
* Plugin 稳定名称,默认 `asr`。
|
|
86
|
+
*/
|
|
87
|
+
name?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Plugin 展示标题,默认 `ASR`。
|
|
90
|
+
*/
|
|
91
|
+
title?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Plugin 用途说明。
|
|
94
|
+
*/
|
|
95
|
+
description?: string;
|
|
96
|
+
/**
|
|
97
|
+
* 真实 ASR 能力函数。
|
|
98
|
+
*
|
|
99
|
+
* 说明(中文)
|
|
100
|
+
* - 推荐传入 `(input) => city.ai.asr(input)`。
|
|
101
|
+
* - plugin 只负责调用该函数,不关心模型、provider、鉴权或运行依赖。
|
|
102
|
+
*/
|
|
103
|
+
asr: (input: AsrPluginInput) => Promise<AsrPluginResult> | AsrPluginResult;
|
|
104
|
+
/**
|
|
105
|
+
* 是否自动转写 chat 入站语音附件。
|
|
106
|
+
*
|
|
107
|
+
* 说明(中文)
|
|
108
|
+
* - `true`:遇到 voice/audio 附件时自动调用 `asr`。
|
|
109
|
+
* - `false`:仅保留显式 `transcribe` action。
|
|
110
|
+
* - 默认 `false`,避免 agent 隐式调用外部 ASR 成本。
|
|
111
|
+
*/
|
|
112
|
+
auto?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* 默认语言提示。
|
|
115
|
+
*/
|
|
116
|
+
language?: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ChatAuthorization 类型与契约定义。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* -
|
|
6
|
-
* - 业务层不应散落硬编码字符串,如 `chat.authorizeIncoming`、`set-user-role`。
|
|
7
|
-
* - chat / console / plugin 执行链路都从这里共享同一份边界定义。
|
|
5
|
+
* - 统一维护 ChatPlugin 内置授权能力的领域类型、扩展点/action 名称、payload 契约。
|
|
6
|
+
* - 业务层不应散落硬编码字符串,如 `chat.authorizeIncoming`、`authorization-set-user-role`。
|
|
7
|
+
* - chat / console / plugin action 执行链路都从这里共享同一份边界定义。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { ChatDispatchChannel } from "@/chat/types/ChatDispatcher.js";
|
|
11
11
|
import { CHAT_PLUGIN_POINTS } from "@/chat/runtime/PluginPoints.js";
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* 聊天授权 plugin 稳定名称。
|
|
15
|
-
*/
|
|
16
|
-
export const CHAT_AUTHORIZATION_PLUGIN_NAME = "chat-authorization";
|
|
17
|
-
|
|
18
13
|
/**
|
|
19
14
|
* 聊天授权支持的渠道目录。
|
|
20
15
|
*/
|
|
@@ -28,7 +23,7 @@ export type ChatAuthorizationChannel = (typeof CHAT_AUTHORIZATION_CHANNELS)[numb
|
|
|
28
23
|
/**
|
|
29
24
|
* 聊天授权扩展点名称集合。
|
|
30
25
|
*/
|
|
31
|
-
export const
|
|
26
|
+
export const CHAT_AUTHORIZATION_POINTS = {
|
|
32
27
|
observePrincipal: CHAT_PLUGIN_POINTS.observePrincipal,
|
|
33
28
|
authorizeIncoming: CHAT_PLUGIN_POINTS.authorizeIncoming,
|
|
34
29
|
resolveUserRole: CHAT_PLUGIN_POINTS.resolveUserRole,
|
|
@@ -38,10 +33,10 @@ export const CHAT_AUTHORIZATION_PLUGIN_POINTS = {
|
|
|
38
33
|
* 聊天授权 action 名称集合。
|
|
39
34
|
*/
|
|
40
35
|
export const CHAT_AUTHORIZATION_ACTIONS = {
|
|
41
|
-
snapshot: "snapshot",
|
|
42
|
-
readConfig: "read-config",
|
|
43
|
-
writeConfig: "write-config",
|
|
44
|
-
setUserRole: "set-user-role",
|
|
36
|
+
snapshot: "authorization-snapshot",
|
|
37
|
+
readConfig: "authorization-read-config",
|
|
38
|
+
writeConfig: "authorization-write-config",
|
|
39
|
+
setUserRole: "authorization-set-user-role",
|
|
45
40
|
} as const;
|
|
46
41
|
|
|
47
42
|
/**
|
|
@@ -463,7 +458,7 @@ export interface ChatAuthorizationStateFile {
|
|
|
463
458
|
}
|
|
464
459
|
|
|
465
460
|
/**
|
|
466
|
-
*
|
|
461
|
+
* ChatPlugin effect 输入:记录观测主体。
|
|
467
462
|
*/
|
|
468
463
|
export interface ChatAuthorizationObservePrincipalPayload {
|
|
469
464
|
/**
|
|
@@ -493,7 +488,7 @@ export interface ChatAuthorizationObservePrincipalPayload {
|
|
|
493
488
|
}
|
|
494
489
|
|
|
495
490
|
/**
|
|
496
|
-
*
|
|
491
|
+
* ChatPlugin effect 输出:记录观测主体结果。
|
|
497
492
|
*/
|
|
498
493
|
export interface ChatAuthorizationObservePrincipalResult {
|
|
499
494
|
/**
|
|
@@ -503,7 +498,7 @@ export interface ChatAuthorizationObservePrincipalResult {
|
|
|
503
498
|
}
|
|
504
499
|
|
|
505
500
|
/**
|
|
506
|
-
*
|
|
501
|
+
* ChatPlugin resolve 输入:查询用户角色。
|
|
507
502
|
*/
|
|
508
503
|
export interface ChatAuthorizationResolveUserRolePayload {
|
|
509
504
|
/**
|
package/src/chat/ChatPlugin.ts
CHANGED
|
@@ -9,29 +9,47 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { BasePlugin } from "@downcity/agent/internal/plugin/core/BasePlugin.js";
|
|
12
|
-
import type {
|
|
12
|
+
import type {
|
|
13
|
+
PluginActions,
|
|
14
|
+
PluginHooks,
|
|
15
|
+
PluginResolves,
|
|
16
|
+
} from "@downcity/agent/internal/plugin/types/Plugin.js";
|
|
13
17
|
import type { AgentContext } from "@downcity/agent/internal/types/runtime/agent/AgentContext.js";
|
|
14
18
|
import type { ChatChannelState } from "@/chat/types/ChatRuntime.js";
|
|
15
|
-
import type { StoredChannelAccount } from "@downcity/agent/internal/types/platform/Store.js";
|
|
16
19
|
import type { ChatQueueWorkerConfig } from "@/chat/types/ChatQueueWorker.js";
|
|
17
20
|
import type {
|
|
18
|
-
|
|
21
|
+
ChatChannel,
|
|
19
22
|
ChatPluginOptions,
|
|
20
|
-
|
|
21
|
-
ChatPluginTelegramOptions,
|
|
22
|
-
} from "@/chat/ChatPluginTypes.js";
|
|
23
|
+
} from "@/chat/types/ChatPluginOptions.js";
|
|
23
24
|
import type { ChatChannelName } from "@/chat/types/ChannelStatus.js";
|
|
25
|
+
import {
|
|
26
|
+
FeishuChannel,
|
|
27
|
+
QqChannel,
|
|
28
|
+
TelegramChannel,
|
|
29
|
+
} from "@/chat/channels/RuntimeChannel.js";
|
|
24
30
|
import {
|
|
25
31
|
createChatChannelState,
|
|
26
32
|
startChatChannels,
|
|
27
33
|
stopChatChannels,
|
|
28
34
|
} from "./runtime/ChatChannelFacade.js";
|
|
29
|
-
import { getStoredChannelAccountSync } from "./accounts/Store.js";
|
|
30
35
|
import { createChatPluginActions } from "./runtime/ChatPluginActions.js";
|
|
36
|
+
import {
|
|
37
|
+
createChatAuthorizationActions,
|
|
38
|
+
createChatAuthorizationHooks,
|
|
39
|
+
createChatAuthorizationResolves,
|
|
40
|
+
} from "./runtime/ChatAuthorizationRuntime.js";
|
|
31
41
|
import { ChatQueueWorker } from "./runtime/ChatQueueWorker.js";
|
|
32
42
|
import { buildChatPluginSystem } from "./runtime/ChatPluginSystem.js";
|
|
33
43
|
import { ChatQueueStore } from "./runtime/ChatQueueStore.js";
|
|
34
44
|
|
|
45
|
+
function createDefaultChannels(): ChatChannel[] {
|
|
46
|
+
return [
|
|
47
|
+
new TelegramChannel({ enabled: false }),
|
|
48
|
+
new FeishuChannel({ enabled: false }),
|
|
49
|
+
new QqChannel({ enabled: false }),
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
|
|
35
53
|
/**
|
|
36
54
|
* Chat plugin 类实现。
|
|
37
55
|
*/
|
|
@@ -69,6 +87,11 @@ export class ChatPlugin extends BasePlugin {
|
|
|
69
87
|
*/
|
|
70
88
|
public readonly options: ChatPluginOptions;
|
|
71
89
|
|
|
90
|
+
/**
|
|
91
|
+
* 当前实例持有的 chat channels。
|
|
92
|
+
*/
|
|
93
|
+
public readonly channels: ChatChannel[];
|
|
94
|
+
|
|
72
95
|
/**
|
|
73
96
|
* 当前 plugin 的 system 文本构建器。
|
|
74
97
|
*/
|
|
@@ -81,6 +104,16 @@ export class ChatPlugin extends BasePlugin {
|
|
|
81
104
|
*/
|
|
82
105
|
readonly actions: PluginActions;
|
|
83
106
|
|
|
107
|
+
/**
|
|
108
|
+
* 当前 plugin 的 hook 定义表。
|
|
109
|
+
*/
|
|
110
|
+
readonly hooks: PluginHooks;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 当前 plugin 的 resolve 定义表。
|
|
114
|
+
*/
|
|
115
|
+
readonly resolves: PluginResolves;
|
|
116
|
+
|
|
84
117
|
/**
|
|
85
118
|
* 启动当前实例的 queue worker。
|
|
86
119
|
*/
|
|
@@ -109,9 +142,17 @@ export class ChatPlugin extends BasePlugin {
|
|
|
109
142
|
constructor(options?: ChatPluginOptions) {
|
|
110
143
|
super();
|
|
111
144
|
this.options = options || {};
|
|
112
|
-
this.
|
|
113
|
-
|
|
114
|
-
|
|
145
|
+
this.channels = Array.isArray(this.options.channels)
|
|
146
|
+
? [...this.options.channels]
|
|
147
|
+
: createDefaultChannels();
|
|
148
|
+
this.actions = {
|
|
149
|
+
...createChatPluginActions({
|
|
150
|
+
channelState: this.channelState,
|
|
151
|
+
}),
|
|
152
|
+
...createChatAuthorizationActions(),
|
|
153
|
+
};
|
|
154
|
+
this.hooks = createChatAuthorizationHooks();
|
|
155
|
+
this.resolves = createChatAuthorizationResolves();
|
|
115
156
|
this.lifecycle = {
|
|
116
157
|
start: async (context) => {
|
|
117
158
|
this.startQueueWorker(context);
|
|
@@ -130,18 +171,15 @@ export class ChatPlugin extends BasePlugin {
|
|
|
130
171
|
getQueueWorkerConfig(
|
|
131
172
|
context: AgentContext,
|
|
132
173
|
): Partial<ChatQueueWorkerConfig> | undefined {
|
|
133
|
-
|
|
174
|
+
void context;
|
|
175
|
+
return this.options.queue;
|
|
134
176
|
}
|
|
135
177
|
|
|
136
178
|
/**
|
|
137
179
|
* 判断指定渠道是否启用。
|
|
138
180
|
*/
|
|
139
181
|
isChannelEnabled(context: AgentContext, channel: ChatChannelName): boolean {
|
|
140
|
-
|
|
141
|
-
if (explicit) {
|
|
142
|
-
return explicit.enabled !== false;
|
|
143
|
-
}
|
|
144
|
-
return context.config.plugins?.chat?.channels?.[channel]?.enabled === true;
|
|
182
|
+
return this.getChannel(channel)?.isEnabled(context) === true;
|
|
145
183
|
}
|
|
146
184
|
|
|
147
185
|
/**
|
|
@@ -151,13 +189,40 @@ export class ChatPlugin extends BasePlugin {
|
|
|
151
189
|
context: AgentContext,
|
|
152
190
|
channel: ChatChannelName,
|
|
153
191
|
): string {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
192
|
+
return String(this.getChannel(channel)?.getChannelAccountId(context) || "").trim();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 更新当前实例的渠道运行态配置。
|
|
197
|
+
*
|
|
198
|
+
* 关键点(中文)
|
|
199
|
+
* - chat.open/close/configure 只修改当前 plugin 实例,不写 downcity.json。
|
|
200
|
+
* - 当前运行态只允许更新 `enabled` 与 `channelAccountId`,密钥仍来自 constructor 或账号池。
|
|
201
|
+
*/
|
|
202
|
+
applyChannelRuntimePatch(params: {
|
|
203
|
+
/**
|
|
204
|
+
* 目标渠道。
|
|
205
|
+
*/
|
|
206
|
+
channel: ChatChannelName;
|
|
207
|
+
/**
|
|
208
|
+
* 是否启用该渠道。
|
|
209
|
+
*/
|
|
210
|
+
enabled?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* 绑定的账号池记录 ID;传入 null 表示清空绑定。
|
|
213
|
+
*/
|
|
214
|
+
channelAccountId?: string | null;
|
|
215
|
+
}): void {
|
|
216
|
+
const channel = this.getChannel(params.channel);
|
|
217
|
+
if (!channel) {
|
|
218
|
+
throw new Error(`Chat channel is not registered: ${params.channel}`);
|
|
219
|
+
}
|
|
220
|
+
channel.applyRuntimePatch({
|
|
221
|
+
...(typeof params.enabled === "boolean" ? { enabled: params.enabled } : {}),
|
|
222
|
+
...(Object.prototype.hasOwnProperty.call(params, "channelAccountId")
|
|
223
|
+
? { channelAccountId: params.channelAccountId ?? null }
|
|
224
|
+
: {}),
|
|
225
|
+
});
|
|
161
226
|
}
|
|
162
227
|
|
|
163
228
|
/**
|
|
@@ -166,73 +231,11 @@ export class ChatPlugin extends BasePlugin {
|
|
|
166
231
|
resolveChannelAccount(
|
|
167
232
|
context: AgentContext,
|
|
168
233
|
channel: ChatChannelName,
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
if (explicit) return explicit;
|
|
172
|
-
const channelAccountId = this.getChannelAccountId(context, channel);
|
|
173
|
-
if (!channelAccountId) return null;
|
|
174
|
-
return getStoredChannelAccountSync(channelAccountId);
|
|
234
|
+
) {
|
|
235
|
+
return this.getChannel(channel)?.getAccount(context) || null;
|
|
175
236
|
}
|
|
176
237
|
|
|
177
|
-
private
|
|
178
|
-
channel
|
|
179
|
-
): ChatPluginTelegramOptions | ChatPluginFeishuOptions | ChatPluginQqOptions | undefined {
|
|
180
|
-
if (channel === "telegram") return this.options.telegram;
|
|
181
|
-
if (channel === "feishu") return this.options.feishu;
|
|
182
|
-
return this.options.qq;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
private buildExplicitChannelAccount(
|
|
186
|
-
channel: ChatChannelName,
|
|
187
|
-
): StoredChannelAccount | null {
|
|
188
|
-
const now = new Date().toISOString();
|
|
189
|
-
|
|
190
|
-
if (channel === "telegram") {
|
|
191
|
-
const config = this.options.telegram;
|
|
192
|
-
const botToken = String(config?.botToken || "").trim();
|
|
193
|
-
if (!botToken) return null;
|
|
194
|
-
return {
|
|
195
|
-
id: String(config?.channelAccountId || `chat-sdk-${channel}`).trim(),
|
|
196
|
-
channel,
|
|
197
|
-
name: String(config?.name || "telegram").trim() || "telegram",
|
|
198
|
-
botToken,
|
|
199
|
-
createdAt: now,
|
|
200
|
-
updatedAt: now,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (channel === "feishu") {
|
|
205
|
-
const config = this.options.feishu;
|
|
206
|
-
const appId = String(config?.appId || "").trim();
|
|
207
|
-
const appSecret = String(config?.appSecret || "").trim();
|
|
208
|
-
if (!appId || !appSecret) return null;
|
|
209
|
-
return {
|
|
210
|
-
id: String(config?.channelAccountId || `chat-sdk-${channel}`).trim(),
|
|
211
|
-
channel,
|
|
212
|
-
name: String(config?.name || "feishu").trim() || "feishu",
|
|
213
|
-
appId,
|
|
214
|
-
appSecret,
|
|
215
|
-
...(String(config?.domain || "").trim()
|
|
216
|
-
? { domain: String(config?.domain || "").trim() }
|
|
217
|
-
: {}),
|
|
218
|
-
createdAt: now,
|
|
219
|
-
updatedAt: now,
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const config = this.options.qq;
|
|
224
|
-
const appId = String(config?.appId || "").trim();
|
|
225
|
-
const appSecret = String(config?.appSecret || "").trim();
|
|
226
|
-
if (!appId || !appSecret) return null;
|
|
227
|
-
return {
|
|
228
|
-
id: String(config?.channelAccountId || `chat-sdk-${channel}`).trim(),
|
|
229
|
-
channel,
|
|
230
|
-
name: String(config?.name || "qq").trim() || "qq",
|
|
231
|
-
appId,
|
|
232
|
-
appSecret,
|
|
233
|
-
...(config?.sandbox === true ? { sandbox: true } : {}),
|
|
234
|
-
createdAt: now,
|
|
235
|
-
updatedAt: now,
|
|
236
|
-
};
|
|
238
|
+
private getChannel(channel: ChatChannelName): ChatChannel | null {
|
|
239
|
+
return this.channels.find((item) => item.name === channel) || null;
|
|
237
240
|
}
|
|
238
241
|
}
|
package/src/chat/Index.ts
CHANGED
|
@@ -2,7 +2,24 @@
|
|
|
2
2
|
* Chat Plugin 导出入口。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* - Index
|
|
5
|
+
* - Index 只负责导出类实现与 channel SDK 对象。
|
|
6
6
|
* - 真正的类实现位于 `ChatPlugin.ts`。
|
|
7
7
|
*/
|
|
8
8
|
export { ChatPlugin } from "./ChatPlugin.js";
|
|
9
|
+
export {
|
|
10
|
+
FeishuChannel,
|
|
11
|
+
QqChannel,
|
|
12
|
+
TelegramChannel,
|
|
13
|
+
} from "./channels/RuntimeChannel.js";
|
|
14
|
+
export type {
|
|
15
|
+
BaseChatChannelOptions,
|
|
16
|
+
ChatChannelEnv,
|
|
17
|
+
FeishuChannelOptions,
|
|
18
|
+
QqChannelOptions,
|
|
19
|
+
TelegramChannelOptions,
|
|
20
|
+
} from "./channels/RuntimeChannel.js";
|
|
21
|
+
export type {
|
|
22
|
+
ChatChannel,
|
|
23
|
+
ChatChannelRuntimePatch,
|
|
24
|
+
ChatPluginOptions,
|
|
25
|
+
} from "./types/ChatPluginOptions.js";
|
|
@@ -27,7 +27,7 @@ export abstract class ChatChannelConfiguration {
|
|
|
27
27
|
abstract describe(): ChatChannelConfigurationDescriptor;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* 返回可通过 `chat.configure`
|
|
30
|
+
* 返回可通过 `chat.configure` 更新的运行态字段定义。
|
|
31
31
|
*/
|
|
32
32
|
getWritableShipFields(): ChatChannelConfigurationField[] {
|
|
33
33
|
return this.describe().fields.ship.filter((field) => field.writable);
|