@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.
Files changed (329) hide show
  1. package/bin/BuiltinPlugins.d.ts +2 -3
  2. package/bin/BuiltinPlugins.d.ts.map +1 -1
  3. package/bin/BuiltinPlugins.js +2 -6
  4. package/bin/BuiltinPlugins.js.map +1 -1
  5. package/bin/asr/Plugin.d.ts +67 -8
  6. package/bin/asr/Plugin.d.ts.map +1 -1
  7. package/bin/asr/Plugin.js +229 -461
  8. package/bin/asr/Plugin.js.map +1 -1
  9. package/bin/asr/types/AsrPlugin.d.ts +114 -0
  10. package/bin/asr/types/AsrPlugin.d.ts.map +1 -0
  11. package/bin/asr/types/AsrPlugin.js +10 -0
  12. package/bin/asr/types/AsrPlugin.js.map +1 -0
  13. package/bin/auth/Plugin.d.ts +1 -2
  14. package/bin/auth/Plugin.d.ts.map +1 -1
  15. package/bin/auth/Plugin.js +2 -2
  16. package/bin/auth/Plugin.js.map +1 -1
  17. package/bin/chat/ChatPlugin.d.ts +1 -2
  18. package/bin/chat/ChatPlugin.d.ts.map +1 -1
  19. package/bin/chat/ChatPlugin.js +3 -12
  20. package/bin/chat/ChatPlugin.js.map +1 -1
  21. package/bin/chat/PROMPT.direct.d.ts +1 -1
  22. package/bin/chat/PROMPT.direct.d.ts.map +1 -1
  23. package/bin/chat/PROMPT.direct.js +1 -1
  24. package/bin/chat/PROMPT.direct.js.map +1 -1
  25. package/bin/chat/channels/qq/PROMPT.direct.d.ts +1 -1
  26. package/bin/chat/channels/qq/PROMPT.direct.d.ts.map +1 -1
  27. package/bin/chat/channels/qq/PROMPT.direct.js +1 -1
  28. package/bin/chat/channels/qq/PROMPT.direct.js.map +1 -1
  29. package/bin/chat/channels/telegram/Bot.d.ts +6 -0
  30. package/bin/chat/channels/telegram/Bot.d.ts.map +1 -1
  31. package/bin/chat/channels/telegram/Bot.js +24 -0
  32. package/bin/chat/channels/telegram/Bot.js.map +1 -1
  33. package/bin/chat/channels/telegram/TelegramPlatformClient.d.ts +14 -0
  34. package/bin/chat/channels/telegram/TelegramPlatformClient.d.ts.map +1 -1
  35. package/bin/chat/channels/telegram/TelegramPlatformClient.js +39 -5
  36. package/bin/chat/channels/telegram/TelegramPlatformClient.js.map +1 -1
  37. package/bin/contact/ContactPlugin.d.ts +1 -2
  38. package/bin/contact/ContactPlugin.d.ts.map +1 -1
  39. package/bin/contact/ContactPlugin.js +2 -2
  40. package/bin/contact/ContactPlugin.js.map +1 -1
  41. package/bin/contact/PROMPT.d.ts +1 -1
  42. package/bin/contact/PROMPT.d.ts.map +1 -1
  43. package/bin/contact/PROMPT.js +1 -1
  44. package/bin/contact/PROMPT.js.map +1 -1
  45. package/bin/image/ImagePlugin.d.ts +61 -0
  46. package/bin/image/ImagePlugin.d.ts.map +1 -0
  47. package/bin/image/ImagePlugin.js +207 -0
  48. package/bin/image/ImagePlugin.js.map +1 -0
  49. package/bin/image/types/ImagePlugin.d.ts +136 -0
  50. package/bin/image/types/ImagePlugin.d.ts.map +1 -0
  51. package/bin/image/types/ImagePlugin.js +10 -0
  52. package/bin/image/types/ImagePlugin.js.map +1 -0
  53. package/bin/index.d.ts +4 -0
  54. package/bin/index.d.ts.map +1 -1
  55. package/bin/index.js +1 -0
  56. package/bin/index.js.map +1 -1
  57. package/bin/shell/ShellPlugin.d.ts +1 -2
  58. package/bin/shell/ShellPlugin.d.ts.map +1 -1
  59. package/bin/shell/ShellPlugin.js +2 -2
  60. package/bin/shell/ShellPlugin.js.map +1 -1
  61. package/bin/skill/Action.d.ts +8 -3
  62. package/bin/skill/Action.d.ts.map +1 -1
  63. package/bin/skill/Action.js +9 -11
  64. package/bin/skill/Action.js.map +1 -1
  65. package/bin/skill/Command.d.ts +1 -1
  66. package/bin/skill/Command.d.ts.map +1 -1
  67. package/bin/skill/Command.js +3 -10
  68. package/bin/skill/Command.js.map +1 -1
  69. package/bin/skill/Config.d.ts +9 -9
  70. package/bin/skill/Config.d.ts.map +1 -1
  71. package/bin/skill/Config.js +36 -24
  72. package/bin/skill/Config.js.map +1 -1
  73. package/bin/skill/PROMPT.d.ts +1 -1
  74. package/bin/skill/PROMPT.d.ts.map +1 -1
  75. package/bin/skill/PROMPT.js +1 -1
  76. package/bin/skill/PROMPT.js.map +1 -1
  77. package/bin/skill/Plugin.d.ts +2 -2
  78. package/bin/skill/Plugin.d.ts.map +1 -1
  79. package/bin/skill/Plugin.js +20 -37
  80. package/bin/skill/Plugin.js.map +1 -1
  81. package/bin/skill/runtime/Discovery.d.ts +3 -3
  82. package/bin/skill/runtime/Discovery.d.ts.map +1 -1
  83. package/bin/skill/runtime/Discovery.js +37 -14
  84. package/bin/skill/runtime/Discovery.js.map +1 -1
  85. package/bin/skill/runtime/Paths.d.ts +5 -5
  86. package/bin/skill/runtime/Paths.d.ts.map +1 -1
  87. package/bin/skill/runtime/Paths.js +23 -33
  88. package/bin/skill/runtime/Paths.js.map +1 -1
  89. package/bin/skill/runtime/Prompt.d.ts +2 -2
  90. package/bin/skill/runtime/Prompt.d.ts.map +1 -1
  91. package/bin/skill/runtime/Prompt.js +3 -8
  92. package/bin/skill/runtime/Prompt.js.map +1 -1
  93. package/bin/skill/runtime/SystemProvider.d.ts +2 -2
  94. package/bin/skill/runtime/SystemProvider.d.ts.map +1 -1
  95. package/bin/skill/runtime/SystemProvider.js +2 -2
  96. package/bin/skill/runtime/SystemProvider.js.map +1 -1
  97. package/bin/skill/types/SkillPlugin.d.ts +34 -12
  98. package/bin/skill/types/SkillPlugin.d.ts.map +1 -1
  99. package/bin/skill/types/SkillPlugin.js +2 -1
  100. package/bin/skill/types/SkillPlugin.js.map +1 -1
  101. package/bin/skill/types/SkillRoot.d.ts +1 -1
  102. package/bin/task/Action.js +2 -2
  103. package/bin/task/Action.js.map +1 -1
  104. package/bin/task/PROMPT.d.ts +1 -1
  105. package/bin/task/PROMPT.d.ts.map +1 -1
  106. package/bin/task/PROMPT.js +1 -1
  107. package/bin/task/PROMPT.js.map +1 -1
  108. package/bin/task/TaskPlugin.d.ts +1 -2
  109. package/bin/task/TaskPlugin.d.ts.map +1 -1
  110. package/bin/task/TaskPlugin.js +2 -2
  111. package/bin/task/TaskPlugin.js.map +1 -1
  112. package/bin/tts/Plugin.d.ts +53 -7
  113. package/bin/tts/Plugin.d.ts.map +1 -1
  114. package/bin/tts/Plugin.js +197 -474
  115. package/bin/tts/Plugin.js.map +1 -1
  116. package/bin/tts/types/TtsPlugin.d.ts +63 -102
  117. package/bin/tts/types/TtsPlugin.d.ts.map +1 -1
  118. package/bin/tts/types/TtsPlugin.js +4 -3
  119. package/bin/tts/types/TtsPlugin.js.map +1 -1
  120. package/bin/web/PROMPT.d.ts +1 -1
  121. package/bin/web/PROMPT.d.ts.map +1 -1
  122. package/bin/web/PROMPT.js +1 -1
  123. package/bin/web/PROMPT.js.map +1 -1
  124. package/bin/web/Plugin.d.ts +66 -6
  125. package/bin/web/Plugin.d.ts.map +1 -1
  126. package/bin/web/Plugin.js +130 -447
  127. package/bin/web/Plugin.js.map +1 -1
  128. package/bin/web/WebPromptAssets.d.ts +1 -9
  129. package/bin/web/WebPromptAssets.d.ts.map +1 -1
  130. package/bin/web/WebPromptAssets.js +1 -11
  131. package/bin/web/WebPromptAssets.js.map +1 -1
  132. package/bin/web/runtime/Install.d.ts +19 -0
  133. package/bin/web/runtime/Install.d.ts.map +1 -0
  134. package/bin/web/runtime/Install.js +178 -0
  135. package/bin/web/runtime/Install.js.map +1 -0
  136. package/bin/web/types/WebPlugin.d.ts +37 -109
  137. package/bin/web/types/WebPlugin.d.ts.map +1 -1
  138. package/bin/web/types/WebPlugin.js +5 -7
  139. package/bin/web/types/WebPlugin.js.map +1 -1
  140. package/bin/workboard/Plugin.d.ts +1 -2
  141. package/bin/workboard/Plugin.d.ts.map +1 -1
  142. package/bin/workboard/Plugin.js +2 -2
  143. package/bin/workboard/Plugin.js.map +1 -1
  144. package/package.json +2 -2
  145. package/src/BuiltinPlugins.ts +3 -10
  146. package/src/asr/Plugin.ts +264 -484
  147. package/src/asr/types/AsrPlugin.ts +118 -0
  148. package/src/auth/Plugin.ts +2 -3
  149. package/src/chat/ChatPlugin.ts +3 -14
  150. package/src/chat/PROMPT.direct.ts +1 -1
  151. package/src/chat/PROMPT.direct.ts.txt +5 -7
  152. package/src/chat/channels/qq/PROMPT.direct.ts +1 -1
  153. package/src/chat/channels/qq/PROMPT.direct.ts.txt +1 -1
  154. package/src/chat/channels/telegram/Bot.ts +22 -0
  155. package/src/chat/channels/telegram/TelegramPlatformClient.ts +42 -6
  156. package/src/contact/ContactPlugin.ts +2 -3
  157. package/src/contact/PROMPT.ts +1 -1
  158. package/src/contact/PROMPT.ts.txt +12 -12
  159. package/src/image/ImagePlugin.ts +268 -0
  160. package/src/image/types/ImagePlugin.ts +157 -0
  161. package/src/index.ts +25 -0
  162. package/src/shell/ShellPlugin.ts +2 -3
  163. package/src/skill/Action.ts +20 -9
  164. package/src/skill/Command.ts +3 -13
  165. package/src/skill/Config.ts +41 -34
  166. package/src/skill/PROMPT.ts +1 -1
  167. package/src/skill/PROMPT.ts.txt +14 -2
  168. package/src/skill/Plugin.ts +205 -214
  169. package/src/skill/runtime/Discovery.ts +43 -17
  170. package/src/skill/runtime/Paths.ts +24 -35
  171. package/src/skill/runtime/Prompt.ts +4 -10
  172. package/src/skill/runtime/SystemProvider.ts +4 -4
  173. package/src/skill/types/SkillPlugin.ts +39 -12
  174. package/src/skill/types/SkillRoot.ts +1 -1
  175. package/src/task/Action.ts +2 -2
  176. package/src/task/PROMPT.ts +1 -1
  177. package/src/task/PROMPT.ts.txt +10 -10
  178. package/src/task/TaskPlugin.ts +2 -3
  179. package/src/tts/Plugin.ts +225 -493
  180. package/src/tts/types/TtsPlugin.ts +67 -102
  181. package/src/web/PROMPT.ts +1 -1
  182. package/src/web/PROMPT.ts.txt +32 -6
  183. package/src/web/Plugin.ts +119 -454
  184. package/src/web/WebPromptAssets.ts +1 -13
  185. package/src/web/runtime/Install.ts +241 -0
  186. package/src/web/types/WebPlugin.ts +37 -113
  187. package/src/workboard/Plugin.ts +2 -3
  188. package/bin/asr/Config.d.ts +0 -43
  189. package/bin/asr/Config.d.ts.map +0 -1
  190. package/bin/asr/Config.js +0 -107
  191. package/bin/asr/Config.js.map +0 -1
  192. package/bin/asr/Dependency.d.ts +0 -77
  193. package/bin/asr/Dependency.d.ts.map +0 -1
  194. package/bin/asr/Dependency.js +0 -238
  195. package/bin/asr/Dependency.js.map +0 -1
  196. package/bin/asr/InboundAugment.d.ts +0 -17
  197. package/bin/asr/InboundAugment.d.ts.map +0 -1
  198. package/bin/asr/InboundAugment.js +0 -47
  199. package/bin/asr/InboundAugment.js.map +0 -1
  200. package/bin/asr/ModelCatalog.d.ts +0 -29
  201. package/bin/asr/ModelCatalog.d.ts.map +0 -1
  202. package/bin/asr/ModelCatalog.js +0 -25
  203. package/bin/asr/ModelCatalog.js.map +0 -1
  204. package/bin/tts/Dependency.d.ts +0 -90
  205. package/bin/tts/Dependency.d.ts.map +0 -1
  206. package/bin/tts/Dependency.js +0 -344
  207. package/bin/tts/Dependency.js.map +0 -1
  208. package/bin/tts/PluginSupport.d.ts +0 -25
  209. package/bin/tts/PluginSupport.d.ts.map +0 -1
  210. package/bin/tts/PluginSupport.js +0 -72
  211. package/bin/tts/PluginSupport.js.map +0 -1
  212. package/bin/tts/runtime/Catalog.d.ts +0 -21
  213. package/bin/tts/runtime/Catalog.d.ts.map +0 -1
  214. package/bin/tts/runtime/Catalog.js +0 -90
  215. package/bin/tts/runtime/Catalog.js.map +0 -1
  216. package/bin/tts/runtime/DependencyInstaller.d.ts +0 -143
  217. package/bin/tts/runtime/DependencyInstaller.d.ts.map +0 -1
  218. package/bin/tts/runtime/DependencyInstaller.js +0 -261
  219. package/bin/tts/runtime/DependencyInstaller.js.map +0 -1
  220. package/bin/tts/runtime/Installer.d.ts +0 -89
  221. package/bin/tts/runtime/Installer.d.ts.map +0 -1
  222. package/bin/tts/runtime/Installer.js +0 -188
  223. package/bin/tts/runtime/Installer.js.map +0 -1
  224. package/bin/tts/runtime/Paths.d.ts +0 -20
  225. package/bin/tts/runtime/Paths.d.ts.map +0 -1
  226. package/bin/tts/runtime/Paths.js +0 -32
  227. package/bin/tts/runtime/Paths.js.map +0 -1
  228. package/bin/tts/runtime/Synthesizer.d.ts +0 -44
  229. package/bin/tts/runtime/Synthesizer.d.ts.map +0 -1
  230. package/bin/tts/runtime/Synthesizer.js +0 -363
  231. package/bin/tts/runtime/Synthesizer.js.map +0 -1
  232. package/bin/tts/types/Tts.d.ts +0 -91
  233. package/bin/tts/types/Tts.d.ts.map +0 -1
  234. package/bin/tts/types/Tts.js +0 -9
  235. package/bin/tts/types/Tts.js.map +0 -1
  236. package/bin/voice/Config.d.ts +0 -43
  237. package/bin/voice/Config.d.ts.map +0 -1
  238. package/bin/voice/Config.js +0 -104
  239. package/bin/voice/Config.js.map +0 -1
  240. package/bin/voice/Dependency.d.ts +0 -77
  241. package/bin/voice/Dependency.d.ts.map +0 -1
  242. package/bin/voice/Dependency.js +0 -237
  243. package/bin/voice/Dependency.js.map +0 -1
  244. package/bin/voice/InboundAugment.d.ts +0 -17
  245. package/bin/voice/InboundAugment.d.ts.map +0 -1
  246. package/bin/voice/InboundAugment.js +0 -47
  247. package/bin/voice/InboundAugment.js.map +0 -1
  248. package/bin/voice/ModelCatalog.d.ts +0 -29
  249. package/bin/voice/ModelCatalog.d.ts.map +0 -1
  250. package/bin/voice/ModelCatalog.js +0 -25
  251. package/bin/voice/ModelCatalog.js.map +0 -1
  252. package/bin/voice/runtime/Catalog.d.ts +0 -18
  253. package/bin/voice/runtime/Catalog.d.ts.map +0 -1
  254. package/bin/voice/runtime/Catalog.js +0 -61
  255. package/bin/voice/runtime/Catalog.js.map +0 -1
  256. package/bin/voice/runtime/DependencyInstaller.d.ts +0 -145
  257. package/bin/voice/runtime/DependencyInstaller.d.ts.map +0 -1
  258. package/bin/voice/runtime/DependencyInstaller.js +0 -309
  259. package/bin/voice/runtime/DependencyInstaller.js.map +0 -1
  260. package/bin/voice/runtime/Installer.d.ts +0 -94
  261. package/bin/voice/runtime/Installer.d.ts.map +0 -1
  262. package/bin/voice/runtime/Installer.js +0 -200
  263. package/bin/voice/runtime/Installer.js.map +0 -1
  264. package/bin/voice/runtime/Paths.d.ts +0 -8
  265. package/bin/voice/runtime/Paths.d.ts.map +0 -1
  266. package/bin/voice/runtime/Paths.js +0 -26
  267. package/bin/voice/runtime/Paths.js.map +0 -1
  268. package/bin/voice/runtime/Transcriber.d.ts +0 -57
  269. package/bin/voice/runtime/Transcriber.d.ts.map +0 -1
  270. package/bin/voice/runtime/Transcriber.js +0 -329
  271. package/bin/voice/runtime/Transcriber.js.map +0 -1
  272. package/bin/voice/types/Voice.d.ts +0 -58
  273. package/bin/voice/types/Voice.d.ts.map +0 -1
  274. package/bin/voice/types/Voice.js +0 -9
  275. package/bin/voice/types/Voice.js.map +0 -1
  276. package/bin/voice/types/VoicePlugin.d.ts +0 -190
  277. package/bin/voice/types/VoicePlugin.d.ts.map +0 -1
  278. package/bin/voice/types/VoicePlugin.js +0 -9
  279. package/bin/voice/types/VoicePlugin.js.map +0 -1
  280. package/bin/web/Dependency.d.ts +0 -10
  281. package/bin/web/Dependency.d.ts.map +0 -1
  282. package/bin/web/Dependency.js +0 -10
  283. package/bin/web/Dependency.js.map +0 -1
  284. package/bin/web/PROMPT.agent-browser.d.ts +0 -7
  285. package/bin/web/PROMPT.agent-browser.d.ts.map +0 -1
  286. package/bin/web/PROMPT.agent-browser.js +0 -8
  287. package/bin/web/PROMPT.agent-browser.js.map +0 -1
  288. package/bin/web/PROMPT.web-access.d.ts +0 -7
  289. package/bin/web/PROMPT.web-access.d.ts.map +0 -1
  290. package/bin/web/PROMPT.web-access.js +0 -8
  291. package/bin/web/PROMPT.web-access.js.map +0 -1
  292. package/bin/web/runtime/Config.d.ts +0 -21
  293. package/bin/web/runtime/Config.d.ts.map +0 -1
  294. package/bin/web/runtime/Config.js +0 -79
  295. package/bin/web/runtime/Config.js.map +0 -1
  296. package/bin/web/runtime/Source.d.ts +0 -29
  297. package/bin/web/runtime/Source.d.ts.map +0 -1
  298. package/bin/web/runtime/Source.js +0 -209
  299. package/bin/web/runtime/Source.js.map +0 -1
  300. package/src/asr/Config.ts +0 -138
  301. package/src/asr/Dependency.ts +0 -336
  302. package/src/asr/InboundAugment.ts +0 -59
  303. package/src/asr/ModelCatalog.ts +0 -43
  304. package/src/tts/Dependency.ts +0 -473
  305. package/src/tts/PluginSupport.ts +0 -85
  306. package/src/tts/runtime/Catalog.ts +0 -97
  307. package/src/tts/runtime/DependencyInstaller.ts +0 -436
  308. package/src/tts/runtime/Installer.ts +0 -297
  309. package/src/tts/runtime/Paths.ts +0 -39
  310. package/src/tts/runtime/Synthesizer.ts +0 -480
  311. package/src/tts/types/Tts.ts +0 -99
  312. package/src/voice/Config.ts +0 -135
  313. package/src/voice/Dependency.ts +0 -329
  314. package/src/voice/InboundAugment.ts +0 -59
  315. package/src/voice/ModelCatalog.ts +0 -43
  316. package/src/voice/runtime/Catalog.ts +0 -68
  317. package/src/voice/runtime/DependencyInstaller.ts +0 -505
  318. package/src/voice/runtime/Installer.ts +0 -324
  319. package/src/voice/runtime/Paths.ts +0 -26
  320. package/src/voice/runtime/Transcriber.ts +0 -467
  321. package/src/voice/types/Voice.ts +0 -68
  322. package/src/voice/types/VoicePlugin.ts +0 -194
  323. package/src/web/Dependency.ts +0 -17
  324. package/src/web/PROMPT.agent-browser.ts +0 -9
  325. package/src/web/PROMPT.agent-browser.ts.txt +0 -17
  326. package/src/web/PROMPT.web-access.ts +0 -9
  327. package/src/web/PROMPT.web-access.ts.txt +0 -13
  328. package/src/web/runtime/Config.ts +0 -105
  329. package/src/web/runtime/Source.ts +0 -257
package/src/web/Plugin.ts CHANGED
@@ -1,48 +1,27 @@
1
1
  /**
2
- * Web Plugin。
2
+ * WebPlugin:联网方法论注入插件。
3
3
  *
4
4
  * 关键点(中文)
5
- * - `web` plugin 不再自实现联网与浏览器能力,只负责 provider 选择、状态检查与提示词注入。
6
- * - 真正的联网逻辑直接交给外部实现:`web-access` `agent-browser`。
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
- function toJsonObject(input: Record<string, unknown> | null | undefined): JsonObject {
30
- const out: JsonObject = {};
31
- if (!input) return out;
32
- for (const [key, value] of Object.entries(input)) {
33
- if (
34
- value === null ||
35
- typeof value === "string" ||
36
- typeof value === "number" ||
37
- typeof value === "boolean"
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
- function getStringOpt(
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
- function getBooleanOpt(
34
+ /**
35
+ * 读取布尔选项。
36
+ */
37
+ function get_boolean_opt(
56
38
  opts: Record<string, JsonValue>,
57
39
  key: string,
58
- defaultValue: boolean,
59
- ): boolean {
40
+ ): boolean | undefined {
60
41
  const value = opts[key];
61
- if (typeof value === "boolean") return value;
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
- function getWebProviderOpt(
45
+ /**
46
+ * 读取安装目标。
47
+ */
48
+ function get_install_target_opt(
71
49
  opts: Record<string, JsonValue>,
72
- key: string,
73
- ): "web-access" | "agent-browser" | undefined {
74
- const value = getStringOpt(opts, key);
75
- if (value === "web-access" || value === "agent-browser") return value;
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
- function getInstallScopeOpt(
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 = getStringOpt(opts, key);
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
- function createWebPluginDefinition(plugin: Plugin): Plugin {
89
- return {
90
- name: "web",
91
- title: "Web Access",
92
- description:
93
- "Connects the agent to either web-access or agent-browser, checks provider readiness, and injects the matching guidance into the runtime prompt.",
94
- config: {
95
- plugin: "web",
96
- scope: "project",
97
- defaultValue: {
98
- provider: "web-access",
99
- injectPrompt: true,
100
- repositoryUrl: WEB_PLUGIN_DEFAULT_REPOSITORY_URL,
101
- sourceVersion: "2.4.1",
102
- browserCommand: "agent-browser",
103
- installScope: "user",
104
- },
105
- },
106
- setup: {
107
- mode: "install-configure",
108
- title: "安装联网 Provider",
109
- description: "把 provider 安装到统一 skill 目录,并同步当前配置。",
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: "provider",
113
- label: "联网方法",
114
- type: "select",
99
+ key: "target",
100
+ label: "联网能力",
101
+ type: "select" as const,
115
102
  required: true,
116
- sourceAction: "providers",
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: "installScope",
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: "~/.agents/skills" },
125
- { label: "项目目录", value: "project", hint: "PROJECT/.agents/skills" },
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
- statusAction: "status",
136
- },
137
- usage: {
138
- title: "配置联网方式",
139
- description: "选择当前 agent 默认使用的联网 provider 与提示词注入策略。",
140
- fields: [
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: "安装当前 provider 对应的 skill,并写入配置",
142
+ description: "安装联网相关 skill / CLI 依赖",
274
143
  configure(command) {
275
144
  command
276
- .option("--provider <provider>", "web-access 或 agent-browser")
277
- .option("--repo <url>", "记录来源仓库地址")
278
- .option("--version <version>", "记录来源版本")
279
- .option("--browser-command <command>", "agent-browser 命令名")
145
+ .option("--target <target>", "web-access、agent-browserall")
280
146
  .option("--scope <scope>", "安装位置:user 或 project")
281
- .option("--no-inject-prompt", "关闭 provider 提示词注入");
147
+ .option("-y, --yes", "跳过确认(默认 true)", true)
148
+ .option("--agent <agent>", "skill installer 目标 agent", "claude-code");
282
149
  },
283
- mapInput({ opts }): JsonValue {
150
+ mapInput({ opts }): JsonObject {
284
151
  return {
285
- ...(getWebProviderOpt(opts, "provider")
286
- ? { provider: getWebProviderOpt(opts, "provider") }
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
- ...(getStringOpt(opts, "browserCommand")
295
- ? { browserCommand: getStringOpt(opts, "browserCommand") }
155
+ ...(get_install_scope_opt(opts)
156
+ ? { scope: get_install_scope_opt(opts) }
296
157
  : {}),
297
- ...(getInstallScopeOpt(opts, "scope")
298
- ? { installScope: getInstallScopeOpt(opts, "scope") }
158
+ ...(typeof get_boolean_opt(opts, "yes") === "boolean"
159
+ ? { yes: get_boolean_opt(opts, "yes") }
299
160
  : {}),
300
- injectPrompt: getBooleanOpt(opts, "injectPrompt", true),
301
- } as JsonObject;
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 result = await installWebPluginDependency({
166
+ const data = await installWebPluginTargets({
306
167
  context,
307
- input:
168
+ payload:
308
169
  payload && typeof payload === "object" && !Array.isArray(payload)
309
- ? (payload as WebPluginInstallInput)
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
- availability: {
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
- constructor(agent: AgentRuntime | null = null) {
520
- super(agent);
521
- Object.assign(this, createWebPluginDefinition(this));
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
- * - `agent-browser` prompt 仍会被安装流程复用为默认 SKILL.md 内容。
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();