@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
package/src/voice/Dependency.ts
DELETED
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Voice Plugin Dependency Helper。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - voice 的转写依赖现在内聚在 plugin 内部,不再暴露独立依赖端口心智。
|
|
6
|
-
* - 这里统一管理检查、安装、配置读写与转写句柄解析。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { execFile as execFileCb } from "node:child_process";
|
|
10
|
-
import { promisify } from "node:util";
|
|
11
|
-
import type { JsonObject, JsonValue } from "@downcity/agent/internal/types/common/Json.js";
|
|
12
|
-
import type { PluginCommandContext } from "@downcity/agent/internal/plugin/types/Plugin.js";
|
|
13
|
-
import type {
|
|
14
|
-
VoicePluginConfig,
|
|
15
|
-
VoiceTranscriberConfig,
|
|
16
|
-
VoiceTranscriberInstallInput,
|
|
17
|
-
VoiceTranscriberHandle,
|
|
18
|
-
} from "@/voice/types/VoicePlugin.js";
|
|
19
|
-
import { transcribeVoiceAudio } from "@/voice/runtime/Transcriber.js";
|
|
20
|
-
import {
|
|
21
|
-
VOICE_MODEL_CATALOG,
|
|
22
|
-
resolveVoiceModelId,
|
|
23
|
-
} from "@/voice/runtime/Catalog.js";
|
|
24
|
-
import {
|
|
25
|
-
detectLocalVoiceModelInstallState,
|
|
26
|
-
installVoiceModelFromHuggingFace,
|
|
27
|
-
} from "@/voice/runtime/Installer.js";
|
|
28
|
-
import {
|
|
29
|
-
installVoiceTranscribeDependencies,
|
|
30
|
-
resolveVoiceRunnersByModels,
|
|
31
|
-
resolveVoiceStrategyByModel,
|
|
32
|
-
} from "@/voice/runtime/DependencyInstaller.js";
|
|
33
|
-
import { resolveVoiceModelsRootDir } from "@/voice/runtime/Paths.js";
|
|
34
|
-
import type { VoiceModelId } from "@/voice/types/Voice.js";
|
|
35
|
-
|
|
36
|
-
const execFileAsync = promisify(execFileCb);
|
|
37
|
-
|
|
38
|
-
export interface VoiceDependencyCheckResult {
|
|
39
|
-
/**
|
|
40
|
-
* 当前依赖是否可用。
|
|
41
|
-
*/
|
|
42
|
-
available: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* 不可用原因列表。
|
|
45
|
-
*/
|
|
46
|
-
reasons: string[];
|
|
47
|
-
/**
|
|
48
|
-
* 结构化附加数据(可选)。
|
|
49
|
-
*/
|
|
50
|
-
details?: JsonValue;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface VoiceDependencyInstallResult {
|
|
54
|
-
/**
|
|
55
|
-
* 安装是否成功。
|
|
56
|
-
*/
|
|
57
|
-
success: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* 人类可读消息(可选)。
|
|
60
|
-
*/
|
|
61
|
-
message?: string;
|
|
62
|
-
/**
|
|
63
|
-
* 结构化附加数据(可选)。
|
|
64
|
-
*/
|
|
65
|
-
details?: JsonValue;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function readVoicePluginRecord(context: PluginCommandContext): Record<string, unknown> {
|
|
69
|
-
const current = context.config.plugins?.voice;
|
|
70
|
-
if (!current || typeof current !== "object" || Array.isArray(current)) {
|
|
71
|
-
return {};
|
|
72
|
-
}
|
|
73
|
-
return current as Record<string, unknown>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function toJsonObject(input: Record<string, unknown> | null | undefined): JsonObject {
|
|
77
|
-
const out: JsonObject = {};
|
|
78
|
-
if (!input) return out;
|
|
79
|
-
for (const [key, value] of Object.entries(input)) {
|
|
80
|
-
if (value === undefined) continue;
|
|
81
|
-
if (
|
|
82
|
-
value === null ||
|
|
83
|
-
typeof value === "string" ||
|
|
84
|
-
typeof value === "number" ||
|
|
85
|
-
typeof value === "boolean"
|
|
86
|
-
) {
|
|
87
|
-
out[key] = value;
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (Array.isArray(value)) {
|
|
91
|
-
out[key] = value
|
|
92
|
-
.filter((item) => item !== undefined)
|
|
93
|
-
.map((item) => item as JsonValue);
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if (typeof value === "object") {
|
|
97
|
-
out[key] = toJsonObject(value as Record<string, unknown>);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return out;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* 读取 voice 转写依赖配置。
|
|
105
|
-
*/
|
|
106
|
-
export function readVoiceTranscriberConfig(
|
|
107
|
-
context: PluginCommandContext,
|
|
108
|
-
): VoiceTranscriberConfig {
|
|
109
|
-
const current = readVoicePluginRecord(context);
|
|
110
|
-
return {
|
|
111
|
-
provider: "local",
|
|
112
|
-
...(current as VoiceTranscriberConfig),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* 写入 voice 转写依赖配置。
|
|
118
|
-
*/
|
|
119
|
-
export async function writeVoiceTranscriberConfig(params: {
|
|
120
|
-
context: PluginCommandContext;
|
|
121
|
-
value: Partial<VoiceTranscriberConfig>;
|
|
122
|
-
}): Promise<VoicePluginConfig> {
|
|
123
|
-
if (!params.context.config.plugins) {
|
|
124
|
-
params.context.config.plugins = {};
|
|
125
|
-
}
|
|
126
|
-
const current = readVoicePluginRecord(params.context);
|
|
127
|
-
const next = {
|
|
128
|
-
...current,
|
|
129
|
-
...params.value,
|
|
130
|
-
};
|
|
131
|
-
params.context.config.plugins.voice = toJsonObject(next);
|
|
132
|
-
await params.context.pluginConfig.persistProjectPlugins(params.context.config.plugins);
|
|
133
|
-
return params.context.config.plugins.voice as VoicePluginConfig;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async function checkLocalProviderAvailability(
|
|
137
|
-
context: PluginCommandContext,
|
|
138
|
-
config: VoiceTranscriberConfig,
|
|
139
|
-
): Promise<VoiceDependencyCheckResult> {
|
|
140
|
-
const reasons: string[] = [];
|
|
141
|
-
const modelId = resolveVoiceModelId(String(config.modelId || ""));
|
|
142
|
-
if (!modelId) {
|
|
143
|
-
reasons.push("voice transcriber modelId is missing");
|
|
144
|
-
return {
|
|
145
|
-
available: false,
|
|
146
|
-
reasons,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const modelsRootDir = resolveVoiceModelsRootDir({
|
|
151
|
-
projectRoot: context.rootPath,
|
|
152
|
-
modelsDir: config.modelsDir,
|
|
153
|
-
});
|
|
154
|
-
const installState = await detectLocalVoiceModelInstallState({
|
|
155
|
-
modelId,
|
|
156
|
-
modelsRootDir,
|
|
157
|
-
});
|
|
158
|
-
if (!installState.installed) {
|
|
159
|
-
reasons.push(`voice model is not installed: ${modelId}`);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const pythonBin = String(config.pythonBin || "").trim() || "python3";
|
|
163
|
-
try {
|
|
164
|
-
await execFileAsync(pythonBin, ["--version"], {
|
|
165
|
-
timeout: 15_000,
|
|
166
|
-
maxBuffer: 1024 * 1024,
|
|
167
|
-
});
|
|
168
|
-
} catch (error) {
|
|
169
|
-
reasons.push(`python runtime missing: ${String(error)}`);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return {
|
|
173
|
-
available: reasons.length === 0,
|
|
174
|
-
reasons,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* 检查 voice 转写依赖可用性。
|
|
180
|
-
*/
|
|
181
|
-
export async function checkVoiceTranscriber(
|
|
182
|
-
context: PluginCommandContext,
|
|
183
|
-
): Promise<VoiceDependencyCheckResult> {
|
|
184
|
-
const config = readVoiceTranscriberConfig(context);
|
|
185
|
-
if (config.provider === "command") {
|
|
186
|
-
const command = String(config.command || "").trim();
|
|
187
|
-
return {
|
|
188
|
-
available: Boolean(command),
|
|
189
|
-
reasons: command ? [] : ["voice transcriber command is missing"],
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
return checkLocalProviderAvailability(context, config);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* 安装或修复 voice 转写依赖。
|
|
197
|
-
*/
|
|
198
|
-
export async function installVoiceTranscriber(params: {
|
|
199
|
-
context: PluginCommandContext;
|
|
200
|
-
input?: VoiceTranscriberInstallInput;
|
|
201
|
-
}): Promise<VoiceDependencyInstallResult> {
|
|
202
|
-
const context = params.context;
|
|
203
|
-
const input = params.input;
|
|
204
|
-
const config = readVoiceTranscriberConfig(context);
|
|
205
|
-
if (config.provider === "command") {
|
|
206
|
-
return {
|
|
207
|
-
success: true,
|
|
208
|
-
message: "voice command provider does not require install",
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const requestedModelIds =
|
|
213
|
-
(Array.isArray(input?.modelIds) ? input?.modelIds : [])
|
|
214
|
-
.map((item) => resolveVoiceModelId(String(item || "").trim()))
|
|
215
|
-
.filter((item): item is VoiceModelId => Boolean(item));
|
|
216
|
-
const selectedModelIds: VoiceModelId[] =
|
|
217
|
-
requestedModelIds.length > 0
|
|
218
|
-
? requestedModelIds
|
|
219
|
-
: [resolveVoiceModelId(String(config.modelId || "SenseVoiceSmall")) || "SenseVoiceSmall"];
|
|
220
|
-
|
|
221
|
-
const modelsRootDir = resolveVoiceModelsRootDir({
|
|
222
|
-
projectRoot: context.rootPath,
|
|
223
|
-
modelsDir: input?.modelsDir || config.modelsDir,
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
for (const modelId of selectedModelIds) {
|
|
227
|
-
const model = VOICE_MODEL_CATALOG.find((item) => item.id === modelId);
|
|
228
|
-
if (!model) {
|
|
229
|
-
throw new Error(`Unsupported voice model: ${modelId}`);
|
|
230
|
-
}
|
|
231
|
-
const installState = await detectLocalVoiceModelInstallState({
|
|
232
|
-
modelId,
|
|
233
|
-
modelsRootDir,
|
|
234
|
-
});
|
|
235
|
-
if (!installState.installed || input?.force === true) {
|
|
236
|
-
await installVoiceModelFromHuggingFace({
|
|
237
|
-
model,
|
|
238
|
-
modelsRootDir,
|
|
239
|
-
force: input?.force === true,
|
|
240
|
-
hfToken: input?.hfToken,
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (input?.installDeps !== false) {
|
|
246
|
-
await installVoiceTranscribeDependencies({
|
|
247
|
-
pythonBin:
|
|
248
|
-
String(input?.pythonBin || config.pythonBin || "").trim() || "python3",
|
|
249
|
-
runners: resolveVoiceRunnersByModels(selectedModelIds),
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const activeModelId =
|
|
254
|
-
resolveVoiceModelId(String(input?.activeModel || "")) ||
|
|
255
|
-
selectedModelIds[0];
|
|
256
|
-
|
|
257
|
-
const nextConfig: VoiceTranscriberConfig = {
|
|
258
|
-
...config,
|
|
259
|
-
provider: "local",
|
|
260
|
-
modelId: activeModelId,
|
|
261
|
-
modelsDir: modelsRootDir,
|
|
262
|
-
pythonBin:
|
|
263
|
-
String(input?.pythonBin || config.pythonBin || "").trim() || undefined,
|
|
264
|
-
...(config.command ? { command: config.command } : {}),
|
|
265
|
-
language:
|
|
266
|
-
typeof config.language === "string" && config.language.trim()
|
|
267
|
-
? config.language.trim()
|
|
268
|
-
: undefined,
|
|
269
|
-
strategy: resolveVoiceStrategyByModel(activeModelId),
|
|
270
|
-
installedModels: selectedModelIds,
|
|
271
|
-
};
|
|
272
|
-
await writeVoiceTranscriberConfig({
|
|
273
|
-
context,
|
|
274
|
-
value: nextConfig,
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
return {
|
|
278
|
-
success: true,
|
|
279
|
-
message: "voice transcriber installed",
|
|
280
|
-
details: {
|
|
281
|
-
modelIds: selectedModelIds,
|
|
282
|
-
activeModel: activeModelId,
|
|
283
|
-
modelsRootDir,
|
|
284
|
-
},
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* 解析 voice 转写句柄。
|
|
290
|
-
*/
|
|
291
|
-
export async function resolveVoiceTranscriber(
|
|
292
|
-
context: PluginCommandContext,
|
|
293
|
-
): Promise<VoiceTranscriberHandle> {
|
|
294
|
-
return {
|
|
295
|
-
async transcribe(input) {
|
|
296
|
-
try {
|
|
297
|
-
const result = await transcribeVoiceAudio({
|
|
298
|
-
context,
|
|
299
|
-
audioPath: input.audioPath,
|
|
300
|
-
language: input.language,
|
|
301
|
-
});
|
|
302
|
-
return {
|
|
303
|
-
success: true,
|
|
304
|
-
text: result.text,
|
|
305
|
-
};
|
|
306
|
-
} catch (error) {
|
|
307
|
-
return {
|
|
308
|
-
success: false,
|
|
309
|
-
error: String(error),
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* 执行一次 voice 转写。
|
|
318
|
-
*/
|
|
319
|
-
export async function transcribeWithVoiceDependency(params: {
|
|
320
|
-
context: PluginCommandContext;
|
|
321
|
-
audioPath: string;
|
|
322
|
-
language?: string;
|
|
323
|
-
}): Promise<{ success: boolean; text?: string; error?: string }> {
|
|
324
|
-
const transcriber = await resolveVoiceTranscriber(params.context);
|
|
325
|
-
return transcriber.transcribe({
|
|
326
|
-
audioPath: params.audioPath,
|
|
327
|
-
...(params.language ? { language: params.language } : {}),
|
|
328
|
-
});
|
|
329
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Voice 入站消息增强 hook。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 只处理 voice/audio 附件,转写结果作为 plugin section 注入。
|
|
6
|
-
* - 转写失败不阻塞主链路,保持 best-effort。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { AgentContext } from "@downcity/agent/internal/types/runtime/agent/AgentContext.js";
|
|
10
|
-
import type { ChatInboundAugmentInput } from "@/chat/types/ChatPlugin.js";
|
|
11
|
-
import type { JsonValue } from "@downcity/agent/internal/types/common/Json.js";
|
|
12
|
-
import { transcribeWithVoiceDependency } from "@/voice/Dependency.js";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 自动转写入站语音附件。
|
|
16
|
-
*/
|
|
17
|
-
export async function augmentVoiceInboundMessage(params: {
|
|
18
|
-
context: AgentContext;
|
|
19
|
-
value: JsonValue;
|
|
20
|
-
}): Promise<JsonValue> {
|
|
21
|
-
const input = params.value as unknown as ChatInboundAugmentInput;
|
|
22
|
-
const voiceAttachments = (Array.isArray(input.attachments) ? input.attachments : []).filter(
|
|
23
|
-
(item) =>
|
|
24
|
-
(item.kind === "voice" || item.kind === "audio") &&
|
|
25
|
-
typeof item.path === "string" &&
|
|
26
|
-
item.path.trim(),
|
|
27
|
-
);
|
|
28
|
-
if (voiceAttachments.length === 0) {
|
|
29
|
-
return input as unknown as JsonValue;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const pluginSections = Array.isArray(input.pluginSections)
|
|
33
|
-
? [...input.pluginSections]
|
|
34
|
-
: [];
|
|
35
|
-
|
|
36
|
-
for (const attachment of voiceAttachments) {
|
|
37
|
-
try {
|
|
38
|
-
const result = await transcribeWithVoiceDependency({
|
|
39
|
-
context: params.context,
|
|
40
|
-
audioPath: String(attachment.path || "").trim(),
|
|
41
|
-
});
|
|
42
|
-
const text = typeof result.text === "string" ? result.text.trim() : "";
|
|
43
|
-
if (!text) continue;
|
|
44
|
-
|
|
45
|
-
const absPath = String(attachment.path || "").trim();
|
|
46
|
-
const rel = absPath.startsWith(`${params.context.rootPath}/`)
|
|
47
|
-
? absPath.slice(params.context.rootPath.length + 1)
|
|
48
|
-
: absPath;
|
|
49
|
-
pluginSections.push(`【语音转写 ${attachment.kind}: ${rel}】\n${text}`);
|
|
50
|
-
} catch {
|
|
51
|
-
// 关键点(中文):转写失败不阻塞主链路,保持 best-effort。
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
...input,
|
|
57
|
-
pluginSections,
|
|
58
|
-
} as unknown as JsonValue;
|
|
59
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Voice 插件模型目录封装。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 对 plugin 层暴露稳定的 voice 领域接口。
|
|
6
|
-
* - plugin 不直接依赖底层 runtime 文件布局,只依赖这里的领域封装。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
VOICE_MODEL_CATALOG,
|
|
11
|
-
resolveVoiceModelId,
|
|
12
|
-
} from "@/voice/runtime/Catalog.js";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 列出内置 voice 模型目录。
|
|
16
|
-
*/
|
|
17
|
-
export function listVoiceModels(): Array<{
|
|
18
|
-
/**
|
|
19
|
-
* 稳定模型 ID。
|
|
20
|
-
*/
|
|
21
|
-
id: string;
|
|
22
|
-
/**
|
|
23
|
-
* 用户可读标签。
|
|
24
|
-
*/
|
|
25
|
-
label: string;
|
|
26
|
-
/**
|
|
27
|
-
* 用户可读说明。
|
|
28
|
-
*/
|
|
29
|
-
description: string;
|
|
30
|
-
}> {
|
|
31
|
-
return VOICE_MODEL_CATALOG.map((item) => ({
|
|
32
|
-
id: item.id,
|
|
33
|
-
label: item.label,
|
|
34
|
-
description: item.description,
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 解析用户输入的 voice 模型 ID。
|
|
40
|
-
*/
|
|
41
|
-
export function resolveVoicePluginModelId(input: string): string | null {
|
|
42
|
-
return resolveVoiceModelId(input);
|
|
43
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { VoiceModelCatalogItem, VoiceModelId } from "@/voice/types/Voice.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Voice 内置模型目录。
|
|
5
|
-
*
|
|
6
|
-
* 关键点(中文)
|
|
7
|
-
* - 统一维护 CLI 展示、下载源与配置落盘 ID。
|
|
8
|
-
* - 只保留“稳定字段”,避免目录频繁变动影响外部调用。
|
|
9
|
-
*/
|
|
10
|
-
export const VOICE_MODEL_CATALOG: readonly VoiceModelCatalogItem[] = [
|
|
11
|
-
{
|
|
12
|
-
id: "SenseVoiceSmall",
|
|
13
|
-
label: "SenseVoiceSmall",
|
|
14
|
-
description: "中文优先,体积较小,推荐默认选择。",
|
|
15
|
-
huggingfaceRepo: "FunAudioLLM/SenseVoiceSmall",
|
|
16
|
-
revision: "main",
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
id: "paraformer-zh-streaming",
|
|
20
|
-
label: "paraformer-zh-streaming",
|
|
21
|
-
description: "中文流式场景友好,低延迟。",
|
|
22
|
-
huggingfaceRepo: "funasr/paraformer-zh-streaming",
|
|
23
|
-
revision: "main",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
id: "whisper-large-v3-turbo",
|
|
27
|
-
label: "whisper-large-v3-turbo",
|
|
28
|
-
description: "多语言能力稳定,泛化较强。",
|
|
29
|
-
huggingfaceRepo: "openai/whisper-large-v3-turbo",
|
|
30
|
-
revision: "main",
|
|
31
|
-
},
|
|
32
|
-
] as const;
|
|
33
|
-
|
|
34
|
-
const VOICE_MODEL_ALIAS_MAP: Record<string, VoiceModelId> = {
|
|
35
|
-
sensevoicesmall: "SenseVoiceSmall",
|
|
36
|
-
"sensevoice-small": "SenseVoiceSmall",
|
|
37
|
-
"paraformer-zh-streaming": "paraformer-zh-streaming",
|
|
38
|
-
paraformer_zh_streaming: "paraformer-zh-streaming",
|
|
39
|
-
"whisper-large-v3-turbo": "whisper-large-v3-turbo",
|
|
40
|
-
whisper_large_v3_turbo: "whisper-large-v3-turbo",
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const CATALOG_BY_ID: Record<VoiceModelId, VoiceModelCatalogItem> =
|
|
44
|
-
VOICE_MODEL_CATALOG.reduce(
|
|
45
|
-
(acc, item) => {
|
|
46
|
-
acc[item.id] = item;
|
|
47
|
-
return acc;
|
|
48
|
-
},
|
|
49
|
-
{} as Record<VoiceModelId, VoiceModelCatalogItem>,
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 解析用户输入为稳定模型 ID(支持别名与大小写)。
|
|
54
|
-
*/
|
|
55
|
-
export function resolveVoiceModelId(input: string): VoiceModelId | null {
|
|
56
|
-
const raw = String(input || "").trim();
|
|
57
|
-
if (!raw) return null;
|
|
58
|
-
const exact = VOICE_MODEL_CATALOG.find((item) => item.id === raw);
|
|
59
|
-
if (exact) return exact.id;
|
|
60
|
-
return VOICE_MODEL_ALIAS_MAP[raw.toLowerCase()] || null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 读取目录项;不存在返回 null。
|
|
65
|
-
*/
|
|
66
|
-
export function getVoiceModelCatalogItem(id: VoiceModelId): VoiceModelCatalogItem | null {
|
|
67
|
-
return CATALOG_BY_ID[id] || null;
|
|
68
|
-
}
|