@downcity/plugins 1.0.174 → 1.0.194
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 +4 -9
- package/bin/BuiltinPlugins.d.ts.map +1 -1
- package/bin/BuiltinPlugins.js +4 -8
- package/bin/BuiltinPlugins.js.map +1 -1
- package/bin/chat/Action.d.ts +8 -2
- package/bin/chat/Action.d.ts.map +1 -1
- package/bin/chat/Action.js +9 -5
- package/bin/chat/Action.js.map +1 -1
- package/bin/chat/ChatPlugin.d.ts +2 -22
- package/bin/chat/ChatPlugin.d.ts.map +1 -1
- package/bin/chat/ChatPlugin.js +2 -21
- package/bin/chat/ChatPlugin.js.map +1 -1
- package/bin/chat/Index.d.ts +1 -1
- package/bin/chat/Index.d.ts.map +1 -1
- package/bin/chat/channels/BaseChatChannel.js +1 -1
- package/bin/chat/channels/BaseChatChannel.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 +2 -3
- package/bin/chat/channels/RuntimeChannel.d.ts.map +1 -1
- package/bin/chat/channels/RuntimeChannel.js +0 -8
- package/bin/chat/channels/RuntimeChannel.js.map +1 -1
- package/bin/chat/channels/feishu/Feishu.d.ts.map +1 -1
- package/bin/chat/channels/feishu/Feishu.js +2 -1
- package/bin/chat/channels/feishu/Feishu.js.map +1 -1
- package/bin/chat/runtime/ChannelContextStore.d.ts.map +1 -1
- package/bin/chat/runtime/ChannelContextStore.js +13 -12
- package/bin/chat/runtime/ChannelContextStore.js.map +1 -1
- package/bin/chat/runtime/ChatActionExecution.d.ts +26 -1
- package/bin/chat/runtime/ChatActionExecution.d.ts.map +1 -1
- package/bin/chat/runtime/ChatActionExecution.js +31 -3
- package/bin/chat/runtime/ChatActionExecution.js.map +1 -1
- package/bin/chat/runtime/ChatActionInput.d.ts +1 -2
- package/bin/chat/runtime/ChatActionInput.d.ts.map +1 -1
- package/bin/chat/runtime/ChatActionInput.js +1 -27
- package/bin/chat/runtime/ChatActionInput.js.map +1 -1
- package/bin/chat/runtime/ChatChannelActions.d.ts +2 -66
- package/bin/chat/runtime/ChatChannelActions.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelActions.js +3 -195
- package/bin/chat/runtime/ChatChannelActions.js.map +1 -1
- package/bin/chat/runtime/ChatChannelConfig.d.ts +2 -23
- package/bin/chat/runtime/ChatChannelConfig.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelConfig.js +3 -116
- package/bin/chat/runtime/ChatChannelConfig.js.map +1 -1
- package/bin/chat/runtime/ChatChannelCore.d.ts +0 -14
- package/bin/chat/runtime/ChatChannelCore.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelCore.js +1 -1
- package/bin/chat/runtime/ChatChannelCore.js.map +1 -1
- package/bin/chat/runtime/ChatChannelFacade.d.ts +1 -1
- package/bin/chat/runtime/ChatChannelFacade.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelFacade.js +1 -1
- package/bin/chat/runtime/ChatChannelFacade.js.map +1 -1
- package/bin/chat/runtime/ChatHistoryStore.d.ts.map +1 -1
- package/bin/chat/runtime/ChatHistoryStore.js +4 -3
- package/bin/chat/runtime/ChatHistoryStore.js.map +1 -1
- package/bin/chat/runtime/ChatPluginActionRegistry.d.ts.map +1 -1
- package/bin/chat/runtime/ChatPluginActionRegistry.js +27 -89
- package/bin/chat/runtime/ChatPluginActionRegistry.js.map +1 -1
- package/bin/chat/runtime/ChatPluginSystem.d.ts +3 -2
- package/bin/chat/runtime/ChatPluginSystem.d.ts.map +1 -1
- package/bin/chat/runtime/ChatPluginSystem.js +5 -5
- package/bin/chat/runtime/ChatPluginSystem.js.map +1 -1
- package/bin/chat/runtime/ChatQueueStore.d.ts +1 -1
- package/bin/chat/runtime/ChatQueueStore.js +2 -2
- package/bin/chat/runtime/ChatQueueStore.js.map +1 -1
- package/bin/chat/runtime/ChatQueueWorker.js +1 -1
- package/bin/chat/runtime/ChatQueueWorker.js.map +1 -1
- package/bin/chat/runtime/ChatSessionDelete.d.ts.map +1 -1
- package/bin/chat/runtime/ChatSessionDelete.js +11 -20
- package/bin/chat/runtime/ChatSessionDelete.js.map +1 -1
- package/bin/chat/runtime/ChatStorage.d.ts +32 -0
- package/bin/chat/runtime/ChatStorage.d.ts.map +1 -0
- package/bin/chat/runtime/ChatStorage.js +158 -0
- package/bin/chat/runtime/ChatStorage.js.map +1 -0
- package/bin/chat/runtime/SystemPrompt.d.ts +3 -2
- package/bin/chat/runtime/SystemPrompt.d.ts.map +1 -1
- package/bin/chat/runtime/SystemPrompt.js +4 -5
- package/bin/chat/runtime/SystemPrompt.js.map +1 -1
- package/bin/chat/types/ChannelConfiguration.d.ts +2 -2
- package/bin/chat/types/ChatPluginActionPayload.d.ts +7 -45
- package/bin/chat/types/ChatPluginActionPayload.d.ts.map +1 -1
- package/bin/chat/types/ChatPluginOptions.d.ts +0 -21
- package/bin/chat/types/ChatPluginOptions.d.ts.map +1 -1
- package/bin/chat/types/ChatStorage.d.ts +36 -0
- package/bin/chat/types/ChatStorage.d.ts.map +1 -0
- package/bin/chat/types/ChatStorage.js +9 -0
- package/bin/chat/types/ChatStorage.js.map +1 -0
- package/bin/contact/Action.d.ts +3 -2
- package/bin/contact/Action.d.ts.map +1 -1
- package/bin/contact/Action.js +2 -2
- package/bin/contact/Action.js.map +1 -1
- package/bin/contact/ContactPlugin.d.ts.map +1 -1
- package/bin/contact/ContactPlugin.js +17 -14
- package/bin/contact/ContactPlugin.js.map +1 -1
- package/bin/contact/runtime/ChatRuntime.js +1 -1
- package/bin/contact/runtime/ChatRuntime.js.map +1 -1
- package/bin/contact/types/ContactPluginOptions.d.ts +4 -0
- package/bin/contact/types/ContactPluginOptions.d.ts.map +1 -1
- package/bin/index.d.ts +5 -5
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +2 -2
- package/bin/index.js.map +1 -1
- package/bin/memory/Action.d.ts.map +1 -1
- package/bin/memory/Action.js +16 -4
- package/bin/memory/Action.js.map +1 -1
- package/bin/memory/runtime/Store.d.ts.map +1 -1
- package/bin/memory/runtime/Store.js +0 -22
- package/bin/memory/runtime/Store.js.map +1 -1
- package/bin/memory/runtime/Writer.d.ts +1 -1
- package/bin/memory/runtime/Writer.d.ts.map +1 -1
- package/bin/memory/runtime/Writer.js +2 -4
- package/bin/memory/runtime/Writer.js.map +1 -1
- package/bin/skill/Command.d.ts +3 -11
- package/bin/skill/Command.d.ts.map +1 -1
- package/bin/skill/Command.js +3 -31
- package/bin/skill/Command.js.map +1 -1
- package/bin/skill/PROMPT.d.ts +1 -1
- package/bin/skill/PROMPT.d.ts.map +1 -1
- package/bin/skill/PROMPT.js +1 -1
- package/bin/skill/PROMPT.js.map +1 -1
- package/bin/skill/Plugin.d.ts +3 -2
- package/bin/skill/Plugin.d.ts.map +1 -1
- package/bin/skill/Plugin.js +37 -129
- package/bin/skill/Plugin.js.map +1 -1
- package/bin/skill/runtime/Prompt.d.ts +11 -2
- package/bin/skill/runtime/Prompt.d.ts.map +1 -1
- package/bin/skill/runtime/Prompt.js +93 -8
- package/bin/skill/runtime/Prompt.js.map +1 -1
- package/bin/skill/runtime/SystemProvider.d.ts +2 -1
- package/bin/skill/runtime/SystemProvider.d.ts.map +1 -1
- package/bin/skill/runtime/SystemProvider.js +4 -9
- package/bin/skill/runtime/SystemProvider.js.map +1 -1
- package/bin/skill/types/SkillPlugin.d.ts +6 -18
- package/bin/skill/types/SkillPlugin.d.ts.map +1 -1
- package/bin/skill/types/SkillPlugin.js +2 -2
- package/bin/sound/Plugin.d.ts +69 -0
- package/bin/sound/Plugin.d.ts.map +1 -0
- package/bin/sound/Plugin.js +623 -0
- package/bin/sound/Plugin.js.map +1 -0
- package/bin/sound/types/SoundPlugin.d.ts +150 -0
- package/bin/sound/types/SoundPlugin.d.ts.map +1 -0
- package/bin/sound/types/SoundPlugin.js +10 -0
- package/bin/sound/types/SoundPlugin.js.map +1 -0
- package/bin/task/Action.d.ts +2 -0
- package/bin/task/Action.d.ts.map +1 -1
- package/bin/task/Action.js +6 -0
- package/bin/task/Action.js.map +1 -1
- package/bin/task/runtime/Runner.d.ts +4 -0
- package/bin/task/runtime/Runner.d.ts.map +1 -1
- package/bin/task/runtime/Runner.js +15 -11
- package/bin/task/runtime/Runner.js.map +1 -1
- package/bin/task/runtime/TaskActionExecution.d.ts +2 -0
- package/bin/task/runtime/TaskActionExecution.d.ts.map +1 -1
- package/bin/task/runtime/TaskActionExecution.js +1 -0
- package/bin/task/runtime/TaskActionExecution.js.map +1 -1
- package/bin/task/runtime/TaskPluginActionRegistry.d.ts.map +1 -1
- package/bin/task/runtime/TaskPluginActionRegistry.js +1 -0
- package/bin/task/runtime/TaskPluginActionRegistry.js.map +1 -1
- package/bin/task/runtime/TaskRunChatDispatch.js +1 -1
- package/bin/task/runtime/TaskRunChatDispatch.js.map +1 -1
- package/bin/task/runtime/TaskRunnerRound.d.ts.map +1 -1
- package/bin/task/runtime/TaskRunnerRound.js +19 -26
- package/bin/task/runtime/TaskRunnerRound.js.map +1 -1
- package/bin/task/runtime/TaskRunnerSession.d.ts +6 -2
- package/bin/task/runtime/TaskRunnerSession.d.ts.map +1 -1
- package/bin/task/runtime/TaskRunnerSession.js +93 -72
- package/bin/task/runtime/TaskRunnerSession.js.map +1 -1
- package/bin/task/runtime/TaskRunnerTypes.d.ts +4 -4
- package/bin/task/runtime/TaskRunnerTypes.d.ts.map +1 -1
- package/bin/task/types/TaskPluginOptions.d.ts.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 +2 -2
- package/bin/web/PROMPT.js.map +1 -1
- package/bin/web/Plugin.d.ts +1 -21
- package/bin/web/Plugin.d.ts.map +1 -1
- package/bin/web/Plugin.js +14 -79
- package/bin/web/Plugin.js.map +1 -1
- package/bin/web/runtime/Prompt.d.ts +14 -0
- package/bin/web/runtime/Prompt.d.ts.map +1 -0
- package/bin/web/runtime/Prompt.js +77 -0
- package/bin/web/runtime/Prompt.js.map +1 -0
- package/bin/web/types/WebPlugin.d.ts +40 -29
- package/bin/web/types/WebPlugin.d.ts.map +1 -1
- package/bin/web/types/WebPlugin.js +11 -3
- package/bin/web/types/WebPlugin.js.map +1 -1
- package/bin/workboard/runtime/Collector.js +1 -1
- package/bin/workboard/runtime/Collector.js.map +1 -1
- package/bin/workboard/runtime/Normalizer.js +1 -1
- package/bin/workboard/runtime/Normalizer.js.map +1 -1
- package/bin/workboard/runtime/SessionSummary.d.ts.map +1 -1
- package/bin/workboard/runtime/SessionSummary.js +11 -38
- package/bin/workboard/runtime/SessionSummary.js.map +1 -1
- package/package.json +8 -4
- package/scripts/chat-access.test.mjs +1 -1
- package/scripts/chat-channel-config.test.mjs +15 -64
- package/scripts/chat-storage.test.mjs +92 -0
- package/scripts/skill-plugin.test.mjs +93 -0
- package/scripts/sound-plugin.test.mjs +250 -0
- package/scripts/web-plugin.test.mjs +85 -0
- package/src/BuiltinPlugins.ts +7 -17
- package/src/chat/Action.ts +16 -5
- package/src/chat/ChatPlugin.ts +6 -35
- package/src/chat/Index.ts +0 -1
- package/src/chat/channels/BaseChatChannel.ts +1 -1
- package/src/chat/channels/Configuration.ts +1 -1
- package/src/chat/channels/RuntimeChannel.ts +2 -14
- package/src/chat/channels/feishu/Feishu.ts +2 -1
- package/src/chat/runtime/ChannelContextStore.ts +16 -12
- package/src/chat/runtime/ChatActionExecution.ts +48 -3
- package/src/chat/runtime/ChatActionInput.ts +0 -31
- package/src/chat/runtime/ChatChannelActions.ts +3 -254
- package/src/chat/runtime/ChatChannelConfig.ts +4 -133
- package/src/chat/runtime/ChatChannelCore.ts +1 -15
- package/src/chat/runtime/ChatChannelFacade.ts +0 -4
- package/src/chat/runtime/ChatHistoryStore.ts +4 -3
- package/src/chat/runtime/ChatPluginActionRegistry.ts +26 -98
- package/src/chat/runtime/ChatPluginSystem.ts +9 -3
- package/src/chat/runtime/ChatQueueStore.ts +2 -2
- package/src/chat/runtime/ChatQueueWorker.ts +1 -1
- package/src/chat/runtime/ChatSessionDelete.ts +11 -21
- package/src/chat/runtime/ChatStorage.ts +203 -0
- package/src/chat/runtime/SystemPrompt.ts +8 -3
- package/src/chat/types/ChannelConfiguration.ts +2 -2
- package/src/chat/types/ChatPluginActionPayload.ts +8 -49
- package/src/chat/types/ChatPluginOptions.ts +0 -22
- package/src/chat/types/ChatStorage.ts +37 -0
- package/src/contact/Action.ts +9 -1
- package/src/contact/ContactPlugin.ts +38 -14
- package/src/contact/runtime/ChatRuntime.ts +1 -1
- package/src/contact/types/ContactPluginOptions.ts +6 -0
- package/src/index.ts +16 -14
- package/src/memory/Action.ts +19 -4
- package/src/memory/runtime/Store.ts +0 -27
- package/src/memory/runtime/Writer.ts +2 -5
- package/src/skill/Command.ts +3 -33
- package/src/skill/PROMPT.ts +1 -1
- package/src/skill/PROMPT.ts.txt +5 -1
- package/src/skill/Plugin.ts +49 -156
- package/src/skill/runtime/Prompt.ts +109 -9
- package/src/skill/runtime/SystemProvider.ts +5 -9
- package/src/skill/types/SkillPlugin.ts +6 -18
- package/src/sound/Plugin.ts +699 -0
- package/src/sound/types/SoundPlugin.ts +163 -0
- package/src/task/Action.ts +8 -0
- package/src/task/runtime/Runner.ts +19 -13
- package/src/task/runtime/TaskActionExecution.ts +3 -0
- package/src/task/runtime/TaskPluginActionRegistry.ts +1 -0
- package/src/task/runtime/TaskRunChatDispatch.ts +1 -1
- package/src/task/runtime/TaskRunnerRound.ts +20 -38
- package/src/task/runtime/TaskRunnerSession.ts +108 -72
- package/src/task/runtime/TaskRunnerTypes.ts +4 -4
- package/src/task/types/TaskPluginOptions.ts +1 -0
- package/src/web/PROMPT.ts +2 -2
- package/src/web/PROMPT.ts.txt +4 -2
- package/src/web/Plugin.ts +20 -90
- package/src/web/runtime/Prompt.ts +99 -0
- package/src/web/types/WebPlugin.ts +42 -29
- package/src/workboard/runtime/Collector.ts +1 -1
- package/src/workboard/runtime/Normalizer.ts +1 -1
- package/src/workboard/runtime/SessionSummary.ts +11 -42
- package/bin/asr/Plugin.d.ts +0 -63
- package/bin/asr/Plugin.d.ts.map +0 -1
- package/bin/asr/Plugin.js +0 -280
- package/bin/asr/Plugin.js.map +0 -1
- package/bin/asr/types/AsrPlugin.d.ts +0 -114
- package/bin/asr/types/AsrPlugin.d.ts.map +0 -1
- package/bin/asr/types/AsrPlugin.js +0 -10
- package/bin/asr/types/AsrPlugin.js.map +0 -1
- package/bin/chat/runtime/ChatSession.d.ts +0 -97
- package/bin/chat/runtime/ChatSession.d.ts.map +0 -1
- package/bin/chat/runtime/ChatSession.js +0 -91
- package/bin/chat/runtime/ChatSession.js.map +0 -1
- package/bin/chat/runtime/ChatSessionContextComposer.d.ts +0 -45
- package/bin/chat/runtime/ChatSessionContextComposer.d.ts.map +0 -1
- package/bin/chat/runtime/ChatSessionContextComposer.js +0 -60
- package/bin/chat/runtime/ChatSessionContextComposer.js.map +0 -1
- package/bin/chat/runtime/ChatSessionTypes.d.ts +0 -30
- package/bin/chat/runtime/ChatSessionTypes.d.ts.map +0 -1
- package/bin/chat/runtime/ChatSessionTypes.js +0 -9
- package/bin/chat/runtime/ChatSessionTypes.js.map +0 -1
- package/bin/tts/Plugin.d.ts +0 -49
- package/bin/tts/Plugin.d.ts.map +0 -1
- package/bin/tts/Plugin.js +0 -247
- package/bin/tts/Plugin.js.map +0 -1
- package/bin/tts/types/TtsPlugin.d.ts +0 -122
- package/bin/tts/types/TtsPlugin.d.ts.map +0 -1
- package/bin/tts/types/TtsPlugin.js +0 -10
- package/bin/tts/types/TtsPlugin.js.map +0 -1
- package/bin/web/runtime/Install.d.ts +0 -19
- package/bin/web/runtime/Install.d.ts.map +0 -1
- package/bin/web/runtime/Install.js +0 -178
- package/bin/web/runtime/Install.js.map +0 -1
- package/src/asr/Plugin.ts +0 -322
- package/src/asr/types/AsrPlugin.ts +0 -118
- package/src/chat/runtime/ChatSession.ts +0 -168
- package/src/chat/runtime/ChatSessionContextComposer.ts +0 -106
- package/src/chat/runtime/ChatSessionTypes.ts +0 -32
- package/src/tts/Plugin.ts +0 -284
- package/src/tts/types/TtsPlugin.ts +0 -129
- package/src/web/runtime/Install.ts +0 -241
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TtsPlugin 类型定义。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - TTS plugin 只定义 agent 侧协议,不绑定本地模型、Python 或 City 具体实现。
|
|
6
|
-
* - 真实语音合成能力通过 constructor 的 `tts` 函数注入,推荐传入 `city.ai.tts`。
|
|
7
|
-
* - action 最终统一返回 AI SDK UIMessage,便于 agent 统一处理音频 file part。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { UIMessage } from "ai";
|
|
11
|
-
import type { JsonObject, JsonValue } from "@downcity/agent";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* TTS 输入。
|
|
15
|
-
*/
|
|
16
|
-
export interface TtsPluginInput {
|
|
17
|
-
/**
|
|
18
|
-
* 需要合成为语音的文本。
|
|
19
|
-
*/
|
|
20
|
-
text: string;
|
|
21
|
-
/**
|
|
22
|
-
* 语言提示,例如 `auto`、`zh`、`en`。
|
|
23
|
-
*/
|
|
24
|
-
language?: string;
|
|
25
|
-
/**
|
|
26
|
-
* 音色提示或上游 provider 的 voice id。
|
|
27
|
-
*/
|
|
28
|
-
voice?: string;
|
|
29
|
-
/**
|
|
30
|
-
* 输出格式提示,例如 `wav`、`mp3`、`ogg`。
|
|
31
|
-
*/
|
|
32
|
-
format?: string;
|
|
33
|
-
/**
|
|
34
|
-
* 语速倍率。
|
|
35
|
-
*/
|
|
36
|
-
speed?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Provider 私有参数。
|
|
39
|
-
*/
|
|
40
|
-
provider_options?: JsonObject;
|
|
41
|
-
/**
|
|
42
|
-
* 允许外部 tts 函数接收其他 JSON 可序列化参数。
|
|
43
|
-
*/
|
|
44
|
-
[key: string]: JsonValue | undefined;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* TTS 返回的标准 UIMessage。
|
|
49
|
-
*/
|
|
50
|
-
export type TtsPluginUiMessageResult = UIMessage;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* TTS 返回的简单音频结果。
|
|
54
|
-
*/
|
|
55
|
-
export interface TtsPluginSimpleAudioResult {
|
|
56
|
-
/**
|
|
57
|
-
* 音频 URL,可为远程 URL、本地路径或 data URL。
|
|
58
|
-
*/
|
|
59
|
-
url?: string;
|
|
60
|
-
/**
|
|
61
|
-
* data URL 音频内容。
|
|
62
|
-
*/
|
|
63
|
-
data_url?: string;
|
|
64
|
-
/**
|
|
65
|
-
* 本地音频文件路径。
|
|
66
|
-
*/
|
|
67
|
-
audio_path?: string;
|
|
68
|
-
/**
|
|
69
|
-
* 音频 MIME 类型,例如 `audio/wav`。
|
|
70
|
-
*/
|
|
71
|
-
media_type?: string;
|
|
72
|
-
/**
|
|
73
|
-
* 建议文件名。
|
|
74
|
-
*/
|
|
75
|
-
filename?: string;
|
|
76
|
-
/**
|
|
77
|
-
* 可选说明文本。
|
|
78
|
-
*/
|
|
79
|
-
text?: string;
|
|
80
|
-
/**
|
|
81
|
-
* 允许外部 tts 函数返回其他 JSON 可序列化字段。
|
|
82
|
-
*/
|
|
83
|
-
[key: string]: JsonValue | undefined;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* TTS 输出。
|
|
88
|
-
*/
|
|
89
|
-
export type TtsPluginResult =
|
|
90
|
-
| TtsPluginUiMessageResult
|
|
91
|
-
| TtsPluginSimpleAudioResult;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* TtsPlugin 构造参数。
|
|
95
|
-
*/
|
|
96
|
-
export interface TtsPluginOptions {
|
|
97
|
-
/**
|
|
98
|
-
* Plugin 稳定名称,默认 `tts`。
|
|
99
|
-
*/
|
|
100
|
-
name?: string;
|
|
101
|
-
/**
|
|
102
|
-
* Plugin 展示标题,默认 `TTS`。
|
|
103
|
-
*/
|
|
104
|
-
title?: string;
|
|
105
|
-
/**
|
|
106
|
-
* Plugin 用途说明。
|
|
107
|
-
*/
|
|
108
|
-
description?: string;
|
|
109
|
-
/**
|
|
110
|
-
* 真实 TTS 能力函数。
|
|
111
|
-
*
|
|
112
|
-
* 说明(中文)
|
|
113
|
-
* - 推荐传入 `(input) => city.ai.tts(input)`。
|
|
114
|
-
* - plugin 只负责调用该函数,不关心模型、provider、鉴权或运行依赖。
|
|
115
|
-
*/
|
|
116
|
-
tts: (input: TtsPluginInput) => Promise<TtsPluginResult> | TtsPluginResult;
|
|
117
|
-
/**
|
|
118
|
-
* 默认语言提示。
|
|
119
|
-
*/
|
|
120
|
-
language?: string;
|
|
121
|
-
/**
|
|
122
|
-
* 默认音色提示。
|
|
123
|
-
*/
|
|
124
|
-
voice?: string;
|
|
125
|
-
/**
|
|
126
|
-
* 默认输出格式提示。
|
|
127
|
-
*/
|
|
128
|
-
format?: string;
|
|
129
|
-
}
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebPlugin 安装器。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - install 只负责准备联网相关 skill / CLI 依赖,不写 provider 配置。
|
|
6
|
-
* - skill 安装复用 SkillPlugin 的 `npx skills` 通道,避免 web 自建 registry。
|
|
7
|
-
* - agent-browser 额外准备 npm CLI 包,因为其 skill 需要 `agent-browser` 命令可用。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { execa } from "execa";
|
|
11
|
-
import fs from "node:fs";
|
|
12
|
-
import path from "node:path";
|
|
13
|
-
import type {
|
|
14
|
-
JsonObject,
|
|
15
|
-
JsonValue,
|
|
16
|
-
} from "@downcity/agent";
|
|
17
|
-
import type { AgentContext } from "@downcity/agent";
|
|
18
|
-
import { skillInstallCommand } from "@/skill/Command.js";
|
|
19
|
-
import type {
|
|
20
|
-
WebPluginInstallPayload,
|
|
21
|
-
WebPluginInstallScope,
|
|
22
|
-
WebPluginInstallTarget,
|
|
23
|
-
} from "@/web/types/WebPlugin.js";
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 单个安装步骤结果。
|
|
27
|
-
*/
|
|
28
|
-
interface WebPluginInstallStep {
|
|
29
|
-
/**
|
|
30
|
-
* 步骤名称。
|
|
31
|
-
*/
|
|
32
|
-
name: string;
|
|
33
|
-
/**
|
|
34
|
-
* 步骤是否成功。
|
|
35
|
-
*/
|
|
36
|
-
success: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* 人类可读说明。
|
|
39
|
-
*/
|
|
40
|
-
message: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* 读取字符串字段。
|
|
45
|
-
*/
|
|
46
|
-
function read_string(value: JsonValue | undefined): string | undefined {
|
|
47
|
-
if (typeof value !== "string") return undefined;
|
|
48
|
-
const trimmed = value.trim();
|
|
49
|
-
return trimmed || undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 读取布尔字段。
|
|
54
|
-
*/
|
|
55
|
-
function read_boolean(value: JsonValue | undefined): boolean | undefined {
|
|
56
|
-
return typeof value === "boolean" ? value : undefined;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 归一化安装目标。
|
|
61
|
-
*/
|
|
62
|
-
function resolve_install_target(value: JsonValue | undefined): WebPluginInstallTarget {
|
|
63
|
-
const target = read_string(value);
|
|
64
|
-
if (target === "web-access" || target === "agent-browser" || target === "all") {
|
|
65
|
-
return target;
|
|
66
|
-
}
|
|
67
|
-
return "web-access";
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 归一化安装作用域。
|
|
72
|
-
*/
|
|
73
|
-
function resolve_install_scope(value: JsonValue | undefined): WebPluginInstallScope {
|
|
74
|
-
const scope = read_string(value);
|
|
75
|
-
return scope === "project" ? "project" : "user";
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 判断命令是否已经可用。
|
|
80
|
-
*/
|
|
81
|
-
async function command_exists(command: string): Promise<boolean> {
|
|
82
|
-
try {
|
|
83
|
-
const result = await execa(command, ["--help"], {
|
|
84
|
-
reject: false,
|
|
85
|
-
timeout: 15_000,
|
|
86
|
-
});
|
|
87
|
-
return (result.exitCode ?? 1) === 0;
|
|
88
|
-
} catch {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 执行 npm 包安装。
|
|
95
|
-
*/
|
|
96
|
-
async function install_npm_package(params: {
|
|
97
|
-
root_path: string;
|
|
98
|
-
package_name: string;
|
|
99
|
-
scope: WebPluginInstallScope;
|
|
100
|
-
}): Promise<void> {
|
|
101
|
-
if (params.scope === "project") {
|
|
102
|
-
const package_manager = resolve_project_package_manager(params.root_path);
|
|
103
|
-
const args =
|
|
104
|
-
package_manager === "pnpm"
|
|
105
|
-
? ["add", "-D", params.package_name]
|
|
106
|
-
: package_manager === "yarn"
|
|
107
|
-
? ["add", "-D", params.package_name]
|
|
108
|
-
: ["install", "--save-dev", params.package_name];
|
|
109
|
-
await execa(package_manager, args, {
|
|
110
|
-
cwd: params.root_path,
|
|
111
|
-
stdio: "inherit",
|
|
112
|
-
});
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
await execa("npm", ["install", "-g", params.package_name], {
|
|
117
|
-
stdio: "inherit",
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* 根据锁文件推断项目包管理器。
|
|
123
|
-
*/
|
|
124
|
-
function resolve_project_package_manager(root_path: string): "pnpm" | "yarn" | "npm" {
|
|
125
|
-
if (fs.existsSync(path.join(root_path, "pnpm-lock.yaml"))) return "pnpm";
|
|
126
|
-
if (fs.existsSync(path.join(root_path, "yarn.lock"))) return "yarn";
|
|
127
|
-
return "npm";
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* 将步骤列表转成 JSON。
|
|
132
|
-
*/
|
|
133
|
-
function serialize_steps(steps: WebPluginInstallStep[]): JsonValue[] {
|
|
134
|
-
return steps.map((step) => ({
|
|
135
|
-
name: step.name,
|
|
136
|
-
success: step.success,
|
|
137
|
-
message: step.message,
|
|
138
|
-
}));
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* 安装 skill。
|
|
143
|
-
*/
|
|
144
|
-
async function install_skill(params: {
|
|
145
|
-
spec: string;
|
|
146
|
-
scope: WebPluginInstallScope;
|
|
147
|
-
yes: boolean;
|
|
148
|
-
agent?: string;
|
|
149
|
-
steps: WebPluginInstallStep[];
|
|
150
|
-
}): Promise<void> {
|
|
151
|
-
await skillInstallCommand(params.spec, {
|
|
152
|
-
global: params.scope === "user",
|
|
153
|
-
yes: params.yes,
|
|
154
|
-
agent: params.agent,
|
|
155
|
-
});
|
|
156
|
-
params.steps.push({
|
|
157
|
-
name: `${params.spec}:skill`,
|
|
158
|
-
success: true,
|
|
159
|
-
message:
|
|
160
|
-
params.scope === "user"
|
|
161
|
-
? `Installed ${params.spec} skill in user scope.`
|
|
162
|
-
: `Installed ${params.spec} skill in project scope.`,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* 准备 agent-browser CLI。
|
|
168
|
-
*/
|
|
169
|
-
async function install_agent_browser_cli(params: {
|
|
170
|
-
context: AgentContext;
|
|
171
|
-
scope: WebPluginInstallScope;
|
|
172
|
-
steps: WebPluginInstallStep[];
|
|
173
|
-
}): Promise<void> {
|
|
174
|
-
if (await command_exists("agent-browser")) {
|
|
175
|
-
params.steps.push({
|
|
176
|
-
name: "agent-browser:cli",
|
|
177
|
-
success: true,
|
|
178
|
-
message: "agent-browser CLI is already available.",
|
|
179
|
-
});
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
await install_npm_package({
|
|
184
|
-
root_path: params.context.rootPath,
|
|
185
|
-
package_name: "agent-browser",
|
|
186
|
-
scope: params.scope,
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
params.steps.push({
|
|
190
|
-
name: "agent-browser:cli",
|
|
191
|
-
success: true,
|
|
192
|
-
message:
|
|
193
|
-
params.scope === "user"
|
|
194
|
-
? "Installed agent-browser CLI globally with npm."
|
|
195
|
-
: "Installed agent-browser as a project devDependency.",
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* 执行 WebPlugin install action。
|
|
201
|
-
*/
|
|
202
|
-
export async function installWebPluginTargets(params: {
|
|
203
|
-
context: AgentContext;
|
|
204
|
-
payload?: WebPluginInstallPayload | null;
|
|
205
|
-
}): Promise<JsonObject> {
|
|
206
|
-
const payload = params.payload || {};
|
|
207
|
-
const target = resolve_install_target(payload.target);
|
|
208
|
-
const scope = resolve_install_scope(payload.scope);
|
|
209
|
-
const yes = read_boolean(payload.yes) ?? true;
|
|
210
|
-
const agent = read_string(payload.agent);
|
|
211
|
-
const targets =
|
|
212
|
-
target === "all" ? (["web-access", "agent-browser"] as const) : ([target] as const);
|
|
213
|
-
const steps: WebPluginInstallStep[] = [];
|
|
214
|
-
|
|
215
|
-
for (const item of targets) {
|
|
216
|
-
await install_skill({
|
|
217
|
-
spec: item,
|
|
218
|
-
scope,
|
|
219
|
-
yes,
|
|
220
|
-
agent,
|
|
221
|
-
steps,
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
if (item === "agent-browser") {
|
|
225
|
-
await install_agent_browser_cli({
|
|
226
|
-
context: params.context,
|
|
227
|
-
scope,
|
|
228
|
-
steps,
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
return {
|
|
234
|
-
target,
|
|
235
|
-
scope,
|
|
236
|
-
...(agent ? { agent } : {}),
|
|
237
|
-
steps: serialize_steps(steps),
|
|
238
|
-
nextAction:
|
|
239
|
-
"Use SkillPlugin lookup/list to inspect installed skills, then let the agent choose the concrete web path during task execution.",
|
|
240
|
-
};
|
|
241
|
-
}
|