@downcity/plugins 1.0.56 → 1.0.59

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