@downcity/plugins 1.0.52 → 1.0.57
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 +2 -3
- package/bin/BuiltinPlugins.d.ts.map +1 -1
- package/bin/BuiltinPlugins.js +2 -6
- package/bin/BuiltinPlugins.js.map +1 -1
- package/bin/asr/Plugin.d.ts +67 -8
- 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/Plugin.d.ts +1 -2
- package/bin/auth/Plugin.d.ts.map +1 -1
- package/bin/auth/Plugin.js +2 -2
- package/bin/auth/Plugin.js.map +1 -1
- package/bin/chat/ChatPlugin.d.ts +1 -2
- package/bin/chat/ChatPlugin.d.ts.map +1 -1
- package/bin/chat/ChatPlugin.js +3 -12
- package/bin/chat/ChatPlugin.js.map +1 -1
- package/bin/chat/PROMPT.direct.d.ts +1 -1
- package/bin/chat/PROMPT.direct.d.ts.map +1 -1
- package/bin/chat/PROMPT.direct.js +1 -1
- package/bin/chat/PROMPT.direct.js.map +1 -1
- package/bin/chat/channels/qq/PROMPT.direct.d.ts +1 -1
- package/bin/chat/channels/qq/PROMPT.direct.d.ts.map +1 -1
- package/bin/chat/channels/qq/PROMPT.direct.js +1 -1
- package/bin/chat/channels/qq/PROMPT.direct.js.map +1 -1
- package/bin/chat/channels/telegram/Bot.d.ts +6 -0
- package/bin/chat/channels/telegram/Bot.d.ts.map +1 -1
- package/bin/chat/channels/telegram/Bot.js +24 -0
- package/bin/chat/channels/telegram/Bot.js.map +1 -1
- package/bin/chat/channels/telegram/TelegramPlatformClient.d.ts +14 -0
- package/bin/chat/channels/telegram/TelegramPlatformClient.d.ts.map +1 -1
- package/bin/chat/channels/telegram/TelegramPlatformClient.js +39 -5
- package/bin/chat/channels/telegram/TelegramPlatformClient.js.map +1 -1
- package/bin/contact/ContactPlugin.d.ts +1 -2
- package/bin/contact/ContactPlugin.d.ts.map +1 -1
- package/bin/contact/ContactPlugin.js +2 -2
- package/bin/contact/ContactPlugin.js.map +1 -1
- package/bin/contact/PROMPT.d.ts +1 -1
- package/bin/contact/PROMPT.d.ts.map +1 -1
- package/bin/contact/PROMPT.js +1 -1
- package/bin/contact/PROMPT.js.map +1 -1
- package/bin/image/ImagePlugin.d.ts +61 -0
- package/bin/image/ImagePlugin.d.ts.map +1 -0
- package/bin/image/ImagePlugin.js +207 -0
- package/bin/image/ImagePlugin.js.map +1 -0
- package/bin/image/types/ImagePlugin.d.ts +136 -0
- package/bin/image/types/ImagePlugin.d.ts.map +1 -0
- package/bin/image/types/ImagePlugin.js +10 -0
- package/bin/image/types/ImagePlugin.js.map +1 -0
- package/bin/index.d.ts +4 -0
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +1 -0
- package/bin/index.js.map +1 -1
- package/bin/shell/ShellPlugin.d.ts +1 -2
- package/bin/shell/ShellPlugin.d.ts.map +1 -1
- package/bin/shell/ShellPlugin.js +2 -2
- package/bin/shell/ShellPlugin.js.map +1 -1
- package/bin/skill/Action.d.ts +8 -3
- package/bin/skill/Action.d.ts.map +1 -1
- package/bin/skill/Action.js +9 -11
- package/bin/skill/Action.js.map +1 -1
- package/bin/skill/Command.d.ts +1 -1
- package/bin/skill/Command.d.ts.map +1 -1
- package/bin/skill/Command.js +3 -10
- package/bin/skill/Command.js.map +1 -1
- package/bin/skill/Config.d.ts +9 -9
- package/bin/skill/Config.d.ts.map +1 -1
- package/bin/skill/Config.js +36 -24
- package/bin/skill/Config.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 +2 -2
- package/bin/skill/Plugin.d.ts.map +1 -1
- package/bin/skill/Plugin.js +20 -37
- package/bin/skill/Plugin.js.map +1 -1
- package/bin/skill/runtime/Discovery.d.ts +3 -3
- package/bin/skill/runtime/Discovery.d.ts.map +1 -1
- package/bin/skill/runtime/Discovery.js +37 -14
- package/bin/skill/runtime/Discovery.js.map +1 -1
- package/bin/skill/runtime/Paths.d.ts +5 -5
- package/bin/skill/runtime/Paths.d.ts.map +1 -1
- package/bin/skill/runtime/Paths.js +23 -33
- 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 -8
- package/bin/skill/runtime/Prompt.js.map +1 -1
- package/bin/skill/runtime/SystemProvider.d.ts +2 -2
- package/bin/skill/runtime/SystemProvider.d.ts.map +1 -1
- package/bin/skill/runtime/SystemProvider.js +2 -2
- package/bin/skill/runtime/SystemProvider.js.map +1 -1
- package/bin/skill/types/SkillPlugin.d.ts +34 -12
- package/bin/skill/types/SkillPlugin.d.ts.map +1 -1
- package/bin/skill/types/SkillPlugin.js +2 -1
- package/bin/skill/types/SkillPlugin.js.map +1 -1
- package/bin/skill/types/SkillRoot.d.ts +1 -1
- package/bin/task/Action.js +2 -2
- package/bin/task/Action.js.map +1 -1
- package/bin/task/PROMPT.d.ts +1 -1
- package/bin/task/PROMPT.d.ts.map +1 -1
- package/bin/task/PROMPT.js +1 -1
- package/bin/task/PROMPT.js.map +1 -1
- package/bin/task/TaskPlugin.d.ts +1 -2
- package/bin/task/TaskPlugin.d.ts.map +1 -1
- package/bin/task/TaskPlugin.js +2 -2
- package/bin/task/TaskPlugin.js.map +1 -1
- package/bin/tts/Plugin.d.ts +53 -7
- 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 -6
- package/bin/web/Plugin.d.ts.map +1 -1
- package/bin/web/Plugin.js +130 -447
- 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 +37 -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 +1 -2
- package/bin/workboard/Plugin.d.ts.map +1 -1
- package/bin/workboard/Plugin.js +2 -2
- package/bin/workboard/Plugin.js.map +1 -1
- package/package.json +2 -2
- package/src/BuiltinPlugins.ts +3 -10
- package/src/asr/Plugin.ts +264 -484
- package/src/asr/types/AsrPlugin.ts +118 -0
- package/src/auth/Plugin.ts +2 -3
- package/src/chat/ChatPlugin.ts +3 -14
- package/src/chat/PROMPT.direct.ts +1 -1
- package/src/chat/PROMPT.direct.ts.txt +5 -7
- package/src/chat/channels/qq/PROMPT.direct.ts +1 -1
- package/src/chat/channels/qq/PROMPT.direct.ts.txt +1 -1
- package/src/chat/channels/telegram/Bot.ts +22 -0
- package/src/chat/channels/telegram/TelegramPlatformClient.ts +42 -6
- package/src/contact/ContactPlugin.ts +2 -3
- package/src/contact/PROMPT.ts +1 -1
- package/src/contact/PROMPT.ts.txt +12 -12
- package/src/image/ImagePlugin.ts +268 -0
- package/src/image/types/ImagePlugin.ts +157 -0
- package/src/index.ts +25 -0
- package/src/shell/ShellPlugin.ts +2 -3
- package/src/skill/Action.ts +20 -9
- package/src/skill/Command.ts +3 -13
- package/src/skill/Config.ts +41 -34
- package/src/skill/PROMPT.ts +1 -1
- package/src/skill/PROMPT.ts.txt +14 -2
- package/src/skill/Plugin.ts +205 -214
- package/src/skill/runtime/Discovery.ts +43 -17
- package/src/skill/runtime/Paths.ts +24 -35
- package/src/skill/runtime/Prompt.ts +4 -10
- package/src/skill/runtime/SystemProvider.ts +4 -4
- package/src/skill/types/SkillPlugin.ts +39 -12
- package/src/skill/types/SkillRoot.ts +1 -1
- package/src/task/Action.ts +2 -2
- package/src/task/PROMPT.ts +1 -1
- package/src/task/PROMPT.ts.txt +10 -10
- package/src/task/TaskPlugin.ts +2 -3
- package/src/tts/Plugin.ts +225 -493
- 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 -454
- package/src/web/WebPromptAssets.ts +1 -13
- package/src/web/runtime/Install.ts +241 -0
- package/src/web/types/WebPlugin.ts +37 -113
- package/src/workboard/Plugin.ts +2 -3
- 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/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/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/web/Plugin.ts
CHANGED
|
@@ -1,48 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* WebPlugin:联网方法论注入插件。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
5
|
+
* - web plugin 不选择 provider,也不持久化 provider 运行态。
|
|
6
|
+
* - install action 只负责准备联网相关 skill / CLI 依赖。
|
|
7
|
+
* - 它只通过 `system()` 注入联网研究与浏览器使用方法论。
|
|
8
|
+
* - 具体执行能力由当前 agent 已注册的 tools、skills 或外部 plugin 决定。
|
|
7
9
|
*/
|
|
8
|
-
import type { AgentRuntime } from "@downcity/agent/internal/types/runtime/agent/AgentRuntime.js";
|
|
9
|
-
import { BasePlugin } from "@downcity/agent/internal/plugin/core/BasePlugin.js";
|
|
10
|
-
import type { Plugin } from "@downcity/agent/internal/plugin/types/Plugin.js";
|
|
11
|
-
import type { JsonObject, JsonValue } from "@downcity/agent/internal/types/common/Json.js";
|
|
12
|
-
import type { WebPluginConfig, WebPluginInstallInput } from "@/web/types/WebPlugin.js";
|
|
13
|
-
import { WEB_PLUGIN_DEFAULT_REPOSITORY_URL } from "@/web/types/WebPlugin.js";
|
|
14
|
-
import { isPluginEnabled } from "@downcity/agent/internal/plugin/core/Activation.js";
|
|
15
|
-
import { writeProjectPluginEnabled } from "@downcity/agent/internal/plugin/core/ProjectConfigStore.js";
|
|
16
|
-
import {
|
|
17
|
-
doctorWebPluginDependency,
|
|
18
|
-
inspectWebPluginDependency,
|
|
19
|
-
installWebPluginDependency,
|
|
20
|
-
readWebPluginConfig,
|
|
21
|
-
writeWebPluginConfig,
|
|
22
|
-
} from "@/web/Dependency.js";
|
|
23
|
-
import {
|
|
24
|
-
AGENT_BROWSER_PROMPT,
|
|
25
|
-
WEB_ACCESS_PROMPT,
|
|
26
|
-
WEB_PLUGIN_PROMPT,
|
|
27
|
-
} from "@/web/WebPromptAssets.js";
|
|
28
10
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
) {
|
|
39
|
-
out[key] = value;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return out;
|
|
43
|
-
}
|
|
11
|
+
import { BasePlugin } from "@downcity/agent/internal/plugin/core/BasePlugin.js";
|
|
12
|
+
import type { AgentContext } from "@downcity/agent/internal/types/runtime/agent/AgentContext.js";
|
|
13
|
+
import type {
|
|
14
|
+
JsonObject,
|
|
15
|
+
JsonValue,
|
|
16
|
+
} from "@downcity/agent/internal/types/common/Json.js";
|
|
17
|
+
import { WEB_PLUGIN_PROMPT } from "@/web/WebPromptAssets.js";
|
|
18
|
+
import { installWebPluginTargets } from "@/web/runtime/Install.js";
|
|
19
|
+
import type { WebPluginInstallPayload } from "@/web/types/WebPlugin.js";
|
|
44
20
|
|
|
45
|
-
|
|
21
|
+
/**
|
|
22
|
+
* 读取字符串选项。
|
|
23
|
+
*/
|
|
24
|
+
function get_string_opt(
|
|
46
25
|
opts: Record<string, JsonValue>,
|
|
47
26
|
key: string,
|
|
48
27
|
): string | undefined {
|
|
@@ -52,472 +31,158 @@ function getStringOpt(
|
|
|
52
31
|
return trimmed || undefined;
|
|
53
32
|
}
|
|
54
33
|
|
|
55
|
-
|
|
34
|
+
/**
|
|
35
|
+
* 读取布尔选项。
|
|
36
|
+
*/
|
|
37
|
+
function get_boolean_opt(
|
|
56
38
|
opts: Record<string, JsonValue>,
|
|
57
39
|
key: string,
|
|
58
|
-
|
|
59
|
-
): boolean {
|
|
40
|
+
): boolean | undefined {
|
|
60
41
|
const value = opts[key];
|
|
61
|
-
|
|
62
|
-
if (typeof value === "string") {
|
|
63
|
-
const normalized = value.trim().toLowerCase();
|
|
64
|
-
if (["1", "true", "yes", "y", "on"].includes(normalized)) return true;
|
|
65
|
-
if (["0", "false", "no", "n", "off"].includes(normalized)) return false;
|
|
66
|
-
}
|
|
67
|
-
return defaultValue;
|
|
42
|
+
return typeof value === "boolean" ? value : undefined;
|
|
68
43
|
}
|
|
69
44
|
|
|
70
|
-
|
|
45
|
+
/**
|
|
46
|
+
* 读取安装目标。
|
|
47
|
+
*/
|
|
48
|
+
function get_install_target_opt(
|
|
71
49
|
opts: Record<string, JsonValue>,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
): "web-access" | "agent-browser" | "all" | undefined {
|
|
51
|
+
const value = get_string_opt(opts, "target");
|
|
52
|
+
if (value === "web-access" || value === "agent-browser" || value === "all") {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
76
55
|
return undefined;
|
|
77
56
|
}
|
|
78
57
|
|
|
79
|
-
|
|
58
|
+
/**
|
|
59
|
+
* 读取安装作用域。
|
|
60
|
+
*/
|
|
61
|
+
function get_install_scope_opt(
|
|
80
62
|
opts: Record<string, JsonValue>,
|
|
81
|
-
key: string,
|
|
82
63
|
): "user" | "project" | undefined {
|
|
83
|
-
const value =
|
|
64
|
+
const value = get_string_opt(opts, "scope");
|
|
84
65
|
if (value === "user" || value === "project") return value;
|
|
85
66
|
return undefined;
|
|
86
67
|
}
|
|
87
68
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
69
|
+
/**
|
|
70
|
+
* WebPlugin:为 agent 注入联网任务的方法论。
|
|
71
|
+
*/
|
|
72
|
+
export class WebPlugin extends BasePlugin {
|
|
73
|
+
/**
|
|
74
|
+
* 当前 plugin 稳定名称。
|
|
75
|
+
*/
|
|
76
|
+
readonly name = "web";
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 插件标题。
|
|
80
|
+
*/
|
|
81
|
+
readonly title = "Web Methodology";
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 插件说明。
|
|
85
|
+
*/
|
|
86
|
+
readonly description =
|
|
87
|
+
"Injects web research and browser-use methodology for agents.";
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* setup 面板:只准备联网相关依赖,不做 provider 配置。
|
|
91
|
+
*/
|
|
92
|
+
readonly setup = {
|
|
93
|
+
mode: "install" as const,
|
|
94
|
+
title: "安装联网能力",
|
|
95
|
+
description:
|
|
96
|
+
"安装 web-access、agent-browser 等联网相关 skill / CLI 依赖;不改变 agent 的运行时默认选择。",
|
|
110
97
|
fields: [
|
|
111
98
|
{
|
|
112
|
-
key: "
|
|
113
|
-
label: "
|
|
114
|
-
type: "select",
|
|
99
|
+
key: "target",
|
|
100
|
+
label: "联网能力",
|
|
101
|
+
type: "select" as const,
|
|
115
102
|
required: true,
|
|
116
|
-
|
|
103
|
+
options: [
|
|
104
|
+
{
|
|
105
|
+
label: "web-access",
|
|
106
|
+
value: "web-access",
|
|
107
|
+
hint: "通用搜索、抓取与资料核实 skill",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
label: "agent-browser",
|
|
111
|
+
value: "agent-browser",
|
|
112
|
+
hint: "浏览器自动化 skill,并准备 agent-browser CLI",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
label: "全部",
|
|
116
|
+
value: "all",
|
|
117
|
+
hint: "同时准备 web-access 和 agent-browser",
|
|
118
|
+
},
|
|
119
|
+
],
|
|
117
120
|
},
|
|
118
121
|
{
|
|
119
|
-
key: "
|
|
122
|
+
key: "scope",
|
|
120
123
|
label: "安装位置",
|
|
121
|
-
type: "select",
|
|
124
|
+
type: "select" as const,
|
|
122
125
|
required: true,
|
|
123
126
|
options: [
|
|
124
|
-
{ label: "用户目录", value: "user", hint: "
|
|
125
|
-
{ label: "项目目录", value: "project", hint: "
|
|
127
|
+
{ label: "用户目录", value: "user", hint: "用户级 skill / 全局 CLI" },
|
|
128
|
+
{ label: "项目目录", value: "project", hint: "项目级 skill / devDependency" },
|
|
126
129
|
],
|
|
127
130
|
},
|
|
128
|
-
{
|
|
129
|
-
key: "injectPrompt",
|
|
130
|
-
label: "注入 provider 提示词",
|
|
131
|
-
type: "checkbox",
|
|
132
|
-
},
|
|
133
131
|
],
|
|
134
132
|
primaryAction: "install",
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
{
|
|
142
|
-
key: "provider",
|
|
143
|
-
label: "当前 Provider",
|
|
144
|
-
type: "select",
|
|
145
|
-
required: true,
|
|
146
|
-
sourceAction: "providers",
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
key: "injectPrompt",
|
|
150
|
-
label: "注入 Provider 提示词",
|
|
151
|
-
type: "boolean",
|
|
152
|
-
trueLabel: "开启",
|
|
153
|
-
falseLabel: "关闭",
|
|
154
|
-
description: "开启后,agent system prompt 会自动注入当前 provider 的使用约束。",
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
key: "browserCommand",
|
|
158
|
-
label: "Browser 命令",
|
|
159
|
-
type: "string",
|
|
160
|
-
placeholder: "agent-browser",
|
|
161
|
-
description: "仅在 provider 为 agent-browser 时生效。",
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
saveAction: "configure",
|
|
165
|
-
statusAction: "status",
|
|
166
|
-
},
|
|
167
|
-
async availability(context) {
|
|
168
|
-
if (!isPluginEnabled({ plugin, context })) {
|
|
169
|
-
return {
|
|
170
|
-
enabled: false,
|
|
171
|
-
available: false,
|
|
172
|
-
reasons: ["web plugin disabled in project config"],
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
const dependency = await inspectWebPluginDependency(context);
|
|
176
|
-
return {
|
|
177
|
-
enabled: true,
|
|
178
|
-
available: dependency.available,
|
|
179
|
-
reasons: dependency.reasons,
|
|
180
|
-
};
|
|
181
|
-
},
|
|
182
|
-
actions: {
|
|
183
|
-
status: {
|
|
184
|
-
allowWhenDisabled: true,
|
|
185
|
-
command: {
|
|
186
|
-
description: "查看 web plugin 当前状态",
|
|
187
|
-
mapInput() {
|
|
188
|
-
return {};
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
execute: async ({ context }) => {
|
|
192
|
-
const config = readWebPluginConfig(context);
|
|
193
|
-
const availability = await plugin.availability!(context);
|
|
194
|
-
const source = await inspectWebPluginDependency(context);
|
|
195
|
-
return {
|
|
196
|
-
success: true,
|
|
197
|
-
data: {
|
|
198
|
-
plugin: toJsonObject(config as unknown as Record<string, unknown>),
|
|
199
|
-
availability: {
|
|
200
|
-
enabled: availability.enabled,
|
|
201
|
-
available: availability.available,
|
|
202
|
-
reasons: availability.reasons,
|
|
203
|
-
},
|
|
204
|
-
provider: source.details || null,
|
|
205
|
-
},
|
|
206
|
-
};
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
providers: {
|
|
210
|
-
allowWhenDisabled: true,
|
|
211
|
-
command: {
|
|
212
|
-
description: "列出 web plugin 支持的 provider",
|
|
213
|
-
mapInput() {
|
|
214
|
-
return {};
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
execute: async () => {
|
|
218
|
-
return {
|
|
219
|
-
success: true,
|
|
220
|
-
data: {
|
|
221
|
-
options: [
|
|
222
|
-
{
|
|
223
|
-
value: "web-access",
|
|
224
|
-
title: "web-access",
|
|
225
|
-
description: "适合网页搜索、信息查证与策略型联网任务",
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
value: "agent-browser",
|
|
229
|
-
title: "agent-browser",
|
|
230
|
-
description: "适合动态页面、登录态页面与真实浏览器操作",
|
|
231
|
-
},
|
|
232
|
-
],
|
|
233
|
-
providers: [
|
|
234
|
-
{
|
|
235
|
-
value: "web-access",
|
|
236
|
-
title: "web-access",
|
|
237
|
-
description: "适合网页搜索、信息查证与策略型联网任务",
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
value: "agent-browser",
|
|
241
|
-
title: "agent-browser",
|
|
242
|
-
description: "适合动态页面、登录态页面与真实浏览器操作",
|
|
243
|
-
},
|
|
244
|
-
],
|
|
245
|
-
},
|
|
246
|
-
};
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
configure: {
|
|
250
|
-
allowWhenDisabled: true,
|
|
251
|
-
execute: async ({ context, payload }) => {
|
|
252
|
-
const payloadObject =
|
|
253
|
-
payload && typeof payload === "object" && !Array.isArray(payload)
|
|
254
|
-
? (payload as Record<string, unknown>)
|
|
255
|
-
: {};
|
|
256
|
-
const { enabled: _ignoredEnabled, enable: _ignoredEnable, ...patch } =
|
|
257
|
-
payloadObject;
|
|
258
|
-
const nextConfig = await writeWebPluginConfig({
|
|
259
|
-
context,
|
|
260
|
-
value: patch as Partial<WebPluginConfig>,
|
|
261
|
-
});
|
|
262
|
-
return {
|
|
263
|
-
success: true,
|
|
264
|
-
data: {
|
|
265
|
-
plugin: toJsonObject(nextConfig as unknown as Record<string, unknown>),
|
|
266
|
-
},
|
|
267
|
-
};
|
|
268
|
-
},
|
|
269
|
-
},
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* WebPlugin 对外 action。
|
|
137
|
+
*/
|
|
138
|
+
readonly actions = {
|
|
270
139
|
install: {
|
|
271
140
|
allowWhenDisabled: true,
|
|
272
141
|
command: {
|
|
273
|
-
description: "
|
|
142
|
+
description: "安装联网相关 skill / CLI 依赖",
|
|
274
143
|
configure(command) {
|
|
275
144
|
command
|
|
276
|
-
.option("--
|
|
277
|
-
.option("--repo <url>", "记录来源仓库地址")
|
|
278
|
-
.option("--version <version>", "记录来源版本")
|
|
279
|
-
.option("--browser-command <command>", "agent-browser 命令名")
|
|
145
|
+
.option("--target <target>", "web-access、agent-browser 或 all")
|
|
280
146
|
.option("--scope <scope>", "安装位置:user 或 project")
|
|
281
|
-
.option("--
|
|
147
|
+
.option("-y, --yes", "跳过确认(默认 true)", true)
|
|
148
|
+
.option("--agent <agent>", "skill installer 目标 agent", "claude-code");
|
|
282
149
|
},
|
|
283
|
-
mapInput({ opts }):
|
|
150
|
+
mapInput({ opts }): JsonObject {
|
|
284
151
|
return {
|
|
285
|
-
...(
|
|
286
|
-
? {
|
|
287
|
-
: {}),
|
|
288
|
-
...(getStringOpt(opts, "repo")
|
|
289
|
-
? { repositoryUrl: getStringOpt(opts, "repo") }
|
|
290
|
-
: {}),
|
|
291
|
-
...(getStringOpt(opts, "version")
|
|
292
|
-
? { sourceVersion: getStringOpt(opts, "version") }
|
|
152
|
+
...(get_install_target_opt(opts)
|
|
153
|
+
? { target: get_install_target_opt(opts) }
|
|
293
154
|
: {}),
|
|
294
|
-
...(
|
|
295
|
-
? {
|
|
155
|
+
...(get_install_scope_opt(opts)
|
|
156
|
+
? { scope: get_install_scope_opt(opts) }
|
|
296
157
|
: {}),
|
|
297
|
-
...(
|
|
298
|
-
? {
|
|
158
|
+
...(typeof get_boolean_opt(opts, "yes") === "boolean"
|
|
159
|
+
? { yes: get_boolean_opt(opts, "yes") }
|
|
299
160
|
: {}),
|
|
300
|
-
|
|
301
|
-
}
|
|
161
|
+
...(get_string_opt(opts, "agent") ? { agent: get_string_opt(opts, "agent") } : {}),
|
|
162
|
+
} satisfies JsonObject;
|
|
302
163
|
},
|
|
303
164
|
},
|
|
304
165
|
execute: async ({ context, payload }) => {
|
|
305
|
-
const
|
|
166
|
+
const data = await installWebPluginTargets({
|
|
306
167
|
context,
|
|
307
|
-
|
|
168
|
+
payload:
|
|
308
169
|
payload && typeof payload === "object" && !Array.isArray(payload)
|
|
309
|
-
? (payload as
|
|
170
|
+
? (payload as WebPluginInstallPayload)
|
|
310
171
|
: undefined,
|
|
311
172
|
});
|
|
312
|
-
return {
|
|
313
|
-
success: result.success,
|
|
314
|
-
...(result.details ? { data: result.details } : {}),
|
|
315
|
-
...(result.message ? { message: result.message } : {}),
|
|
316
|
-
};
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
on: {
|
|
320
|
-
allowWhenDisabled: true,
|
|
321
|
-
command: {
|
|
322
|
-
description: "启用 web plugin,并可选设置 provider",
|
|
323
|
-
configure(command) {
|
|
324
|
-
command
|
|
325
|
-
.option("--provider <provider>", "web-access 或 agent-browser")
|
|
326
|
-
.option("--repo <url>", "记录来源仓库地址")
|
|
327
|
-
.option("--version <version>", "记录来源版本")
|
|
328
|
-
.option("--browser-command <command>", "agent-browser 命令名")
|
|
329
|
-
.option("--no-inject-prompt", "关闭 provider 提示词注入");
|
|
330
|
-
},
|
|
331
|
-
mapInput({ opts }): JsonValue {
|
|
332
|
-
return {
|
|
333
|
-
...(getWebProviderOpt(opts, "provider")
|
|
334
|
-
? { provider: getWebProviderOpt(opts, "provider") }
|
|
335
|
-
: {}),
|
|
336
|
-
...(getStringOpt(opts, "repo")
|
|
337
|
-
? { repositoryUrl: getStringOpt(opts, "repo") }
|
|
338
|
-
: {}),
|
|
339
|
-
...(getStringOpt(opts, "version")
|
|
340
|
-
? { sourceVersion: getStringOpt(opts, "version") }
|
|
341
|
-
: {}),
|
|
342
|
-
...(getStringOpt(opts, "browserCommand")
|
|
343
|
-
? { browserCommand: getStringOpt(opts, "browserCommand") }
|
|
344
|
-
: {}),
|
|
345
|
-
injectPrompt: getBooleanOpt(opts, "injectPrompt", true),
|
|
346
|
-
} as JsonObject;
|
|
347
|
-
},
|
|
348
|
-
},
|
|
349
|
-
execute: async ({ context, payload }) => {
|
|
350
|
-
await writeProjectPluginEnabled({
|
|
351
|
-
pluginName: "web",
|
|
352
|
-
enabled: true,
|
|
353
|
-
context,
|
|
354
|
-
});
|
|
355
|
-
const providerRaw = String((payload as { provider?: unknown }).provider || "").trim();
|
|
356
|
-
const provider =
|
|
357
|
-
providerRaw === "web-access" || providerRaw === "agent-browser"
|
|
358
|
-
? providerRaw
|
|
359
|
-
: undefined;
|
|
360
|
-
const nextConfig = await writeWebPluginConfig({
|
|
361
|
-
context,
|
|
362
|
-
value: {
|
|
363
|
-
...readWebPluginConfig(context),
|
|
364
|
-
...(provider ? { provider } : {}),
|
|
365
|
-
injectPrompt:
|
|
366
|
-
typeof (payload as { injectPrompt?: unknown }).injectPrompt === "boolean"
|
|
367
|
-
? Boolean((payload as { injectPrompt?: unknown }).injectPrompt)
|
|
368
|
-
: true,
|
|
369
|
-
...(typeof (payload as { repositoryUrl?: unknown }).repositoryUrl === "string"
|
|
370
|
-
? { repositoryUrl: String((payload as { repositoryUrl?: unknown }).repositoryUrl) }
|
|
371
|
-
: {}),
|
|
372
|
-
...(typeof (payload as { sourceVersion?: unknown }).sourceVersion === "string"
|
|
373
|
-
? { sourceVersion: String((payload as { sourceVersion?: unknown }).sourceVersion) }
|
|
374
|
-
: {}),
|
|
375
|
-
...(typeof (payload as { browserCommand?: unknown }).browserCommand === "string"
|
|
376
|
-
? { browserCommand: String((payload as { browserCommand?: unknown }).browserCommand) }
|
|
377
|
-
: {}),
|
|
378
|
-
},
|
|
379
|
-
});
|
|
380
|
-
return {
|
|
381
|
-
success: true,
|
|
382
|
-
data: {
|
|
383
|
-
plugin: toJsonObject(nextConfig as unknown as Record<string, unknown>),
|
|
384
|
-
},
|
|
385
|
-
};
|
|
386
|
-
},
|
|
387
|
-
},
|
|
388
|
-
off: {
|
|
389
|
-
command: {
|
|
390
|
-
description: "关闭 web plugin",
|
|
391
|
-
mapInput() {
|
|
392
|
-
return {};
|
|
393
|
-
},
|
|
394
|
-
},
|
|
395
|
-
execute: async ({ context }) => {
|
|
396
|
-
await writeProjectPluginEnabled({
|
|
397
|
-
pluginName: "web",
|
|
398
|
-
enabled: false,
|
|
399
|
-
context,
|
|
400
|
-
});
|
|
401
|
-
return {
|
|
402
|
-
success: true,
|
|
403
|
-
data: {
|
|
404
|
-
plugin: toJsonObject(
|
|
405
|
-
readWebPluginConfig(context) as unknown as Record<string, unknown>,
|
|
406
|
-
),
|
|
407
|
-
},
|
|
408
|
-
};
|
|
409
|
-
},
|
|
410
|
-
},
|
|
411
|
-
use: {
|
|
412
|
-
allowWhenDisabled: true,
|
|
413
|
-
command: {
|
|
414
|
-
description: "切换 web plugin 当前 provider",
|
|
415
|
-
configure(command) {
|
|
416
|
-
command
|
|
417
|
-
.argument("<provider>")
|
|
418
|
-
.option("--browser-command <command>", "agent-browser 命令名")
|
|
419
|
-
.option("--no-inject-prompt", "关闭 provider 提示词注入");
|
|
420
|
-
},
|
|
421
|
-
mapInput({ args, opts }): JsonValue {
|
|
422
|
-
const provider = String(args[0] || "").trim();
|
|
423
|
-
if (!provider) throw new Error("provider is required");
|
|
424
|
-
return {
|
|
425
|
-
provider,
|
|
426
|
-
...(getStringOpt(opts, "browserCommand")
|
|
427
|
-
? { browserCommand: getStringOpt(opts, "browserCommand") }
|
|
428
|
-
: {}),
|
|
429
|
-
injectPrompt: getBooleanOpt(opts, "injectPrompt", true),
|
|
430
|
-
} as JsonObject;
|
|
431
|
-
},
|
|
432
|
-
},
|
|
433
|
-
execute: async ({ context, payload }) => {
|
|
434
|
-
const provider = String((payload as { provider?: unknown }).provider || "").trim();
|
|
435
|
-
if (provider !== "web-access" && provider !== "agent-browser") {
|
|
436
|
-
return {
|
|
437
|
-
success: false,
|
|
438
|
-
error: `Unsupported web provider: ${provider}`,
|
|
439
|
-
message: `Unsupported web provider: ${provider}`,
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
const nextConfig = await writeWebPluginConfig({
|
|
443
|
-
context,
|
|
444
|
-
value: {
|
|
445
|
-
...readWebPluginConfig(context),
|
|
446
|
-
provider,
|
|
447
|
-
injectPrompt:
|
|
448
|
-
typeof (payload as { injectPrompt?: unknown }).injectPrompt === "boolean"
|
|
449
|
-
? Boolean((payload as { injectPrompt?: unknown }).injectPrompt)
|
|
450
|
-
: true,
|
|
451
|
-
...(typeof (payload as { browserCommand?: unknown }).browserCommand === "string"
|
|
452
|
-
? { browserCommand: String((payload as { browserCommand?: unknown }).browserCommand) }
|
|
453
|
-
: {}),
|
|
454
|
-
},
|
|
455
|
-
});
|
|
456
|
-
return {
|
|
457
|
-
success: true,
|
|
458
|
-
data: {
|
|
459
|
-
plugin: toJsonObject(nextConfig as unknown as Record<string, unknown>),
|
|
460
|
-
},
|
|
461
|
-
};
|
|
462
|
-
},
|
|
463
|
-
},
|
|
464
|
-
doctor: {
|
|
465
|
-
allowWhenDisabled: true,
|
|
466
|
-
command: {
|
|
467
|
-
description: "检查当前 provider 是否已就绪",
|
|
468
|
-
mapInput() {
|
|
469
|
-
return {};
|
|
470
|
-
},
|
|
471
|
-
},
|
|
472
|
-
execute: async ({ context }) => {
|
|
473
|
-
const availability = await plugin.availability!(context);
|
|
474
|
-
const dependency = await doctorWebPluginDependency(context);
|
|
475
173
|
return {
|
|
476
174
|
success: true,
|
|
477
|
-
data
|
|
478
|
-
|
|
479
|
-
enabled: availability.enabled,
|
|
480
|
-
available: availability.available,
|
|
481
|
-
reasons: availability.reasons,
|
|
482
|
-
},
|
|
483
|
-
provider: dependency.details || null,
|
|
484
|
-
},
|
|
485
|
-
message: dependency.available
|
|
486
|
-
? "web provider is available"
|
|
487
|
-
: dependency.reasons.join("; ") || "web provider is not available",
|
|
175
|
+
data,
|
|
176
|
+
message: "web dependencies installed",
|
|
488
177
|
};
|
|
489
178
|
},
|
|
490
179
|
},
|
|
491
|
-
},
|
|
492
|
-
system(context) {
|
|
493
|
-
const config = readWebPluginConfig(context);
|
|
494
|
-
if (!isPluginEnabled({ plugin, context }) || !config.injectPrompt) {
|
|
495
|
-
return "";
|
|
496
|
-
}
|
|
497
|
-
const providerPrompt =
|
|
498
|
-
config.provider === "agent-browser" ? AGENT_BROWSER_PROMPT : WEB_ACCESS_PROMPT;
|
|
499
|
-
return [
|
|
500
|
-
`Current web provider: ${config.provider}`,
|
|
501
|
-
config.provider === "agent-browser"
|
|
502
|
-
? `Use external CLI command: ${config.browserCommand}`
|
|
503
|
-
: "Use the installed external web-access skill/project.",
|
|
504
|
-
"",
|
|
505
|
-
WEB_PLUGIN_PROMPT,
|
|
506
|
-
"",
|
|
507
|
-
providerPrompt,
|
|
508
|
-
].join("\n");
|
|
509
|
-
},
|
|
510
180
|
};
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* WebPlugin:provider 选择器与提示词适配层。
|
|
515
|
-
*/
|
|
516
|
-
export class WebPlugin extends BasePlugin {
|
|
517
|
-
readonly name = "web";
|
|
518
181
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
182
|
+
/**
|
|
183
|
+
* 注入联网方法论提示词。
|
|
184
|
+
*/
|
|
185
|
+
system(_context: AgentContext): string {
|
|
186
|
+
return WEB_PLUGIN_PROMPT;
|
|
522
187
|
}
|
|
523
188
|
}
|
|
@@ -3,24 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - prompt 文本真实来源是 `*.ts.txt` 文本文件。
|
|
6
|
-
* -
|
|
6
|
+
* - web plugin 只保留通用联网方法论,不再维护 provider 专属提示词。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import agentBrowserPromptText from "@/web/PROMPT.agent-browser.js";
|
|
10
9
|
import webPluginPromptText from "@/web/PROMPT.js";
|
|
11
|
-
import webAccessPromptText from "@/web/PROMPT.web-access.js";
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* web plugin 基础 prompt。
|
|
15
13
|
*/
|
|
16
14
|
export const WEB_PLUGIN_PROMPT = webPluginPromptText.trim();
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* web-access provider prompt。
|
|
20
|
-
*/
|
|
21
|
-
export const WEB_ACCESS_PROMPT = webAccessPromptText.trim();
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* agent-browser provider prompt。
|
|
25
|
-
*/
|
|
26
|
-
export const AGENT_BROWSER_PROMPT = agentBrowserPromptText.trim();
|