@downcity/plugins 1.0.254 → 1.0.280

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 (448) hide show
  1. package/bin/builtin/BuiltinPluginReadmes.d.ts +14 -0
  2. package/bin/builtin/BuiltinPluginReadmes.d.ts.map +1 -0
  3. package/bin/builtin/BuiltinPluginReadmes.js +58 -0
  4. package/bin/builtin/BuiltinPluginReadmes.js.map +1 -0
  5. package/bin/builtin/BuiltinPluginTypes.d.ts +48 -0
  6. package/bin/builtin/BuiltinPluginTypes.d.ts.map +1 -0
  7. package/bin/builtin/BuiltinPluginTypes.js +161 -0
  8. package/bin/builtin/BuiltinPluginTypes.js.map +1 -0
  9. package/bin/builtin/PluginSettingsDefinitions.d.ts +9 -0
  10. package/bin/builtin/PluginSettingsDefinitions.d.ts.map +1 -0
  11. package/bin/builtin/PluginSettingsDefinitions.js +41 -0
  12. package/bin/builtin/PluginSettingsDefinitions.js.map +1 -0
  13. package/bin/builtin/main/PluginSettingsMain.d.ts +6 -0
  14. package/bin/builtin/main/PluginSettingsMain.d.ts.map +1 -0
  15. package/bin/builtin/main/PluginSettingsMain.js +65 -0
  16. package/bin/builtin/main/PluginSettingsMain.js.map +1 -0
  17. package/bin/builtin/renderer/PluginSettingsRenderer.d.ts +6 -0
  18. package/bin/builtin/renderer/PluginSettingsRenderer.d.ts.map +1 -0
  19. package/bin/builtin/renderer/PluginSettingsRenderer.js +76 -0
  20. package/bin/builtin/renderer/PluginSettingsRenderer.js.map +1 -0
  21. package/bin/builtin/types/PluginSettings.d.ts +35 -0
  22. package/bin/builtin/types/PluginSettings.d.ts.map +1 -0
  23. package/bin/builtin/types/PluginSettings.js +3 -0
  24. package/bin/builtin/types/PluginSettings.js.map +1 -0
  25. package/bin/chat/ChatPlugin.d.ts +12 -28
  26. package/bin/chat/ChatPlugin.d.ts.map +1 -1
  27. package/bin/chat/ChatPlugin.js +97 -49
  28. package/bin/chat/ChatPlugin.js.map +1 -1
  29. package/bin/chat/access/ChatAccessRuntime.js +1 -1
  30. package/bin/chat/access/ChatAccessRuntime.js.map +1 -1
  31. package/bin/chat/access/ChatAccessSchema.d.ts +2 -2
  32. package/bin/chat/access/ChatAccessSchema.d.ts.map +1 -1
  33. package/bin/chat/access/ChatAccessSchema.js +3 -3
  34. package/bin/chat/access/ChatAccessSchema.js.map +1 -1
  35. package/bin/chat/access/ChatAccessService.d.ts +2 -2
  36. package/bin/chat/access/ChatAccessService.d.ts.map +1 -1
  37. package/bin/chat/access/ChatAccessService.js +4 -4
  38. package/bin/chat/access/ChatAccessService.js.map +1 -1
  39. package/bin/chat/access/ChatAccessStore.d.ts +3 -3
  40. package/bin/chat/access/ChatAccessStore.d.ts.map +1 -1
  41. package/bin/chat/access/ChatAccessStore.js +17 -8
  42. package/bin/chat/access/ChatAccessStore.js.map +1 -1
  43. package/bin/chat/channels/BaseChatChannel.d.ts +1 -0
  44. package/bin/chat/channels/BaseChatChannel.d.ts.map +1 -1
  45. package/bin/chat/channels/BaseChatChannel.js +2 -0
  46. package/bin/chat/channels/BaseChatChannel.js.map +1 -1
  47. package/bin/chat/channels/RuntimeChannel.d.ts +4 -4
  48. package/bin/chat/channels/RuntimeChannel.d.ts.map +1 -1
  49. package/bin/chat/channels/RuntimeChannel.js +8 -8
  50. package/bin/chat/channels/RuntimeChannel.js.map +1 -1
  51. package/bin/chat/channels/feishu/Feishu.js +1 -1
  52. package/bin/chat/channels/feishu/Feishu.js.map +1 -1
  53. package/bin/chat/channels/feishu/FeishuPlatformClient.d.ts +1 -0
  54. package/bin/chat/channels/feishu/FeishuPlatformClient.d.ts.map +1 -1
  55. package/bin/chat/channels/feishu/FeishuPlatformClient.js +3 -0
  56. package/bin/chat/channels/feishu/FeishuPlatformClient.js.map +1 -1
  57. package/bin/chat/channels/feishu/FeishuPlatformLookup.d.ts +2 -0
  58. package/bin/chat/channels/feishu/FeishuPlatformLookup.d.ts.map +1 -1
  59. package/bin/chat/channels/feishu/FeishuPlatformLookup.js +1 -1
  60. package/bin/chat/channels/feishu/FeishuPlatformLookup.js.map +1 -1
  61. package/bin/chat/channels/qq/QQ.d.ts.map +1 -1
  62. package/bin/chat/channels/qq/QQ.js +3 -2
  63. package/bin/chat/channels/qq/QQ.js.map +1 -1
  64. package/bin/chat/channels/qq/QQEventCapture.d.ts +1 -1
  65. package/bin/chat/channels/qq/QQEventCapture.d.ts.map +1 -1
  66. package/bin/chat/channels/qq/QQEventCapture.js +3 -3
  67. package/bin/chat/channels/qq/QQEventCapture.js.map +1 -1
  68. package/bin/chat/channels/qq/QQInboundDedupe.d.ts +1 -1
  69. package/bin/chat/channels/qq/QQInboundDedupe.d.ts.map +1 -1
  70. package/bin/chat/channels/qq/QQInboundDedupe.js +1 -1
  71. package/bin/chat/channels/qq/QQInboundDedupe.js.map +1 -1
  72. package/bin/chat/channels/qq/QQMessageHandler.d.ts +4 -0
  73. package/bin/chat/channels/qq/QQMessageHandler.d.ts.map +1 -1
  74. package/bin/chat/channels/qq/QQMessageHandler.js +2 -0
  75. package/bin/chat/channels/qq/QQMessageHandler.js.map +1 -1
  76. package/bin/chat/channels/qq/QQSupport.d.ts +4 -0
  77. package/bin/chat/channels/qq/QQSupport.d.ts.map +1 -1
  78. package/bin/chat/channels/qq/QQSupport.js +1 -0
  79. package/bin/chat/channels/qq/QQSupport.js.map +1 -1
  80. package/bin/chat/channels/qq/VoiceInput.d.ts +3 -0
  81. package/bin/chat/channels/qq/VoiceInput.d.ts.map +1 -1
  82. package/bin/chat/channels/qq/VoiceInput.js +1 -1
  83. package/bin/chat/channels/qq/VoiceInput.js.map +1 -1
  84. package/bin/chat/channels/telegram/ApiClient.d.ts +3 -1
  85. package/bin/chat/channels/telegram/ApiClient.d.ts.map +1 -1
  86. package/bin/chat/channels/telegram/ApiClient.js +4 -2
  87. package/bin/chat/channels/telegram/ApiClient.js.map +1 -1
  88. package/bin/chat/channels/telegram/StateStore.d.ts +1 -1
  89. package/bin/chat/channels/telegram/StateStore.d.ts.map +1 -1
  90. package/bin/chat/channels/telegram/StateStore.js +2 -2
  91. package/bin/chat/channels/telegram/StateStore.js.map +1 -1
  92. package/bin/chat/channels/telegram/TelegramPlatformClient.d.ts.map +1 -1
  93. package/bin/chat/channels/telegram/TelegramPlatformClient.js +2 -1
  94. package/bin/chat/channels/telegram/TelegramPlatformClient.js.map +1 -1
  95. package/bin/chat/main/ChatPluginMain.d.ts +4 -0
  96. package/bin/chat/main/ChatPluginMain.d.ts.map +1 -0
  97. package/bin/chat/main/ChatPluginMain.js +137 -0
  98. package/bin/chat/main/ChatPluginMain.js.map +1 -0
  99. package/bin/chat/renderer/ChatPluginRenderer.d.ts +4 -0
  100. package/bin/chat/renderer/ChatPluginRenderer.d.ts.map +1 -0
  101. package/bin/chat/renderer/ChatPluginRenderer.js +105 -0
  102. package/bin/chat/renderer/ChatPluginRenderer.js.map +1 -0
  103. package/bin/chat/runtime/ChannelContextStore.d.ts +2 -2
  104. package/bin/chat/runtime/ChannelContextStore.js +20 -20
  105. package/bin/chat/runtime/ChannelContextStore.js.map +1 -1
  106. package/bin/chat/runtime/ChatActionExecution.js +6 -6
  107. package/bin/chat/runtime/ChatActionExecution.js.map +1 -1
  108. package/bin/chat/runtime/ChatChannelConfig.d.ts.map +1 -1
  109. package/bin/chat/runtime/ChatChannelConfig.js +7 -12
  110. package/bin/chat/runtime/ChatChannelConfig.js.map +1 -1
  111. package/bin/chat/runtime/ChatChannelCore.d.ts +3 -3
  112. package/bin/chat/runtime/ChatChannelCore.d.ts.map +1 -1
  113. package/bin/chat/runtime/ChatChannelCore.js +5 -5
  114. package/bin/chat/runtime/ChatChannelCore.js.map +1 -1
  115. package/bin/chat/runtime/ChatHistoryStore.d.ts +1 -1
  116. package/bin/chat/runtime/ChatHistoryStore.js +7 -7
  117. package/bin/chat/runtime/ChatHistoryStore.js.map +1 -1
  118. package/bin/chat/runtime/ChatMetaStore.d.ts +1 -1
  119. package/bin/chat/runtime/ChatMetaStore.js +1 -1
  120. package/bin/chat/runtime/ChatPluginActionRegistry.d.ts +1 -1
  121. package/bin/chat/runtime/ChatPluginActionRegistry.d.ts.map +1 -1
  122. package/bin/chat/runtime/ChatPluginActionRegistry.js +9 -9
  123. package/bin/chat/runtime/ChatPluginActionRegistry.js.map +1 -1
  124. package/bin/chat/runtime/ChatQueue.d.ts +3 -38
  125. package/bin/chat/runtime/ChatQueue.d.ts.map +1 -1
  126. package/bin/chat/runtime/ChatQueue.js +3 -51
  127. package/bin/chat/runtime/ChatQueue.js.map +1 -1
  128. package/bin/chat/runtime/ChatQueueStore.d.ts +5 -16
  129. package/bin/chat/runtime/ChatQueueStore.d.ts.map +1 -1
  130. package/bin/chat/runtime/ChatQueueStore.js +8 -22
  131. package/bin/chat/runtime/ChatQueueStore.js.map +1 -1
  132. package/bin/chat/runtime/ChatQueueWorker.d.ts +1 -1
  133. package/bin/chat/runtime/ChatQueueWorker.d.ts.map +1 -1
  134. package/bin/chat/runtime/ChatQueueWorker.js +1 -2
  135. package/bin/chat/runtime/ChatQueueWorker.js.map +1 -1
  136. package/bin/chat/runtime/ChatSessionDelete.d.ts +3 -3
  137. package/bin/chat/runtime/ChatSessionDelete.js +4 -4
  138. package/bin/chat/runtime/ChatSessionDelete.js.map +1 -1
  139. package/bin/chat/runtime/ChatStorage.d.ts +7 -7
  140. package/bin/chat/runtime/ChatStorage.js +24 -24
  141. package/bin/chat/runtime/ChatStorage.js.map +1 -1
  142. package/bin/chat/types/ChatAccess.d.ts +2 -2
  143. package/bin/chat/types/ChatAccess.d.ts.map +1 -1
  144. package/bin/chat/types/ChatCommand.d.ts +1 -1
  145. package/bin/chat/types/ChatPluginChannelConfig.d.ts +57 -0
  146. package/bin/chat/types/ChatPluginChannelConfig.d.ts.map +1 -0
  147. package/bin/chat/types/ChatPluginChannelConfig.js +3 -0
  148. package/bin/chat/types/ChatPluginChannelConfig.js.map +1 -0
  149. package/bin/chat/types/ChatPluginConfig.d.ts +19 -0
  150. package/bin/chat/types/ChatPluginConfig.d.ts.map +1 -0
  151. package/bin/chat/types/ChatPluginConfig.js +3 -0
  152. package/bin/chat/types/ChatPluginConfig.js.map +1 -0
  153. package/bin/chat/types/ChatPluginOptions.d.ts +4 -4
  154. package/bin/chat/types/ChatPluginOptions.d.ts.map +1 -1
  155. package/bin/chat/types/ChatPluginOptions.js +1 -1
  156. package/bin/chat/types/ChatPluginProfile.d.ts +39 -0
  157. package/bin/chat/types/ChatPluginProfile.d.ts.map +1 -0
  158. package/bin/chat/types/ChatPluginProfile.js +3 -0
  159. package/bin/chat/types/ChatPluginProfile.js.map +1 -0
  160. package/bin/chat/types/ChatPluginRenderer.d.ts +17 -0
  161. package/bin/chat/types/ChatPluginRenderer.d.ts.map +1 -0
  162. package/bin/chat/types/ChatPluginRenderer.js +3 -0
  163. package/bin/chat/types/ChatPluginRenderer.js.map +1 -0
  164. package/bin/chat/types/ChatRuntime.d.ts +11 -0
  165. package/bin/chat/types/ChatRuntime.d.ts.map +1 -1
  166. package/bin/chat/types/ChatRuntimeAccount.d.ts +3 -3
  167. package/bin/chat/types/ChatRuntimeAccount.d.ts.map +1 -1
  168. package/bin/chat/types/ChatRuntimeAccount.js +2 -2
  169. package/bin/chat/types/ChatStorage.d.ts +2 -2
  170. package/bin/chat/types/ChatStorage.d.ts.map +1 -1
  171. package/bin/chat.d.ts +3 -4
  172. package/bin/chat.d.ts.map +1 -1
  173. package/bin/chat.js +1 -2
  174. package/bin/chat.js.map +1 -1
  175. package/bin/contact/Action.js +5 -5
  176. package/bin/contact/Action.js.map +1 -1
  177. package/bin/contact/ContactPlugin.js +15 -15
  178. package/bin/contact/ContactPlugin.js.map +1 -1
  179. package/bin/contact/runtime/ChatRuntime.js +3 -3
  180. package/bin/contact/runtime/ChatRuntime.js.map +1 -1
  181. package/bin/contact/runtime/ContactStore.d.ts +8 -8
  182. package/bin/contact/runtime/ContactStore.d.ts.map +1 -1
  183. package/bin/contact/runtime/ContactStore.js +20 -20
  184. package/bin/contact/runtime/ContactStore.js.map +1 -1
  185. package/bin/contact/runtime/EndpointNotice.js +2 -2
  186. package/bin/contact/runtime/EndpointNotice.js.map +1 -1
  187. package/bin/contact/runtime/InboxStore.d.ts +6 -6
  188. package/bin/contact/runtime/InboxStore.d.ts.map +1 -1
  189. package/bin/contact/runtime/InboxStore.js +16 -16
  190. package/bin/contact/runtime/InboxStore.js.map +1 -1
  191. package/bin/contact/runtime/LinkApproval.js +14 -14
  192. package/bin/contact/runtime/LinkApproval.js.map +1 -1
  193. package/bin/contact/runtime/LinkStore.d.ts +2 -2
  194. package/bin/contact/runtime/LinkStore.d.ts.map +1 -1
  195. package/bin/contact/runtime/LinkStore.js +5 -5
  196. package/bin/contact/runtime/LinkStore.js.map +1 -1
  197. package/bin/contact/runtime/Paths.d.ts +15 -15
  198. package/bin/contact/runtime/Paths.d.ts.map +1 -1
  199. package/bin/contact/runtime/Paths.js +29 -29
  200. package/bin/contact/runtime/Paths.js.map +1 -1
  201. package/bin/contact/runtime/ShareBundle.d.ts +1 -1
  202. package/bin/contact/runtime/ShareBundle.d.ts.map +1 -1
  203. package/bin/contact/runtime/ShareBundle.js +4 -4
  204. package/bin/contact/runtime/ShareBundle.js.map +1 -1
  205. package/bin/contact/types/ContactApproval.d.ts +2 -2
  206. package/bin/contact/types/ContactApproval.d.ts.map +1 -1
  207. package/bin/image/ImagePlugin.d.ts +1 -4
  208. package/bin/image/ImagePlugin.d.ts.map +1 -1
  209. package/bin/image/ImagePlugin.js +26 -34
  210. package/bin/image/ImagePlugin.js.map +1 -1
  211. package/bin/image/runtime/ImageResultStorage.d.ts +2 -2
  212. package/bin/image/runtime/ImageResultStorage.d.ts.map +1 -1
  213. package/bin/image/runtime/ImageResultStorage.js +15 -38
  214. package/bin/image/runtime/ImageResultStorage.js.map +1 -1
  215. package/bin/image/types/ImagePlugin.d.ts +23 -16
  216. package/bin/image/types/ImagePlugin.d.ts.map +1 -1
  217. package/bin/image/types/ImagePlugin.js +1 -1
  218. package/bin/image.d.ts +1 -1
  219. package/bin/image.d.ts.map +1 -1
  220. package/bin/index.d.ts +2 -0
  221. package/bin/index.d.ts.map +1 -1
  222. package/bin/index.js +1 -0
  223. package/bin/index.js.map +1 -1
  224. package/bin/memory/MemoryPlugin.d.ts +1 -1
  225. package/bin/memory/MemoryPlugin.d.ts.map +1 -1
  226. package/bin/memory/MemoryPlugin.js +17 -7
  227. package/bin/memory/MemoryPlugin.js.map +1 -1
  228. package/bin/memory/types/Memory.d.ts +10 -4
  229. package/bin/memory/types/Memory.d.ts.map +1 -1
  230. package/bin/memory.d.ts +1 -1
  231. package/bin/memory.d.ts.map +1 -1
  232. package/bin/renderers.d.ts +5 -0
  233. package/bin/renderers.d.ts.map +1 -0
  234. package/bin/renderers.js +12 -0
  235. package/bin/renderers.js.map +1 -0
  236. package/bin/sound/Plugin.d.ts +2 -5
  237. package/bin/sound/Plugin.d.ts.map +1 -1
  238. package/bin/sound/Plugin.js +27 -31
  239. package/bin/sound/Plugin.js.map +1 -1
  240. package/bin/sound/types/SoundPlugin.d.ts +22 -15
  241. package/bin/sound/types/SoundPlugin.d.ts.map +1 -1
  242. package/bin/sound/types/SoundPlugin.js +2 -2
  243. package/bin/sound.d.ts +1 -1
  244. package/bin/sound.d.ts.map +1 -1
  245. package/bin/task/Action.d.ts +6 -6
  246. package/bin/task/Action.d.ts.map +1 -1
  247. package/bin/task/Action.js +21 -21
  248. package/bin/task/Action.js.map +1 -1
  249. package/bin/task/PROMPT.d.ts +1 -1
  250. package/bin/task/PROMPT.d.ts.map +1 -1
  251. package/bin/task/PROMPT.js +1 -1
  252. package/bin/task/PROMPT.js.map +1 -1
  253. package/bin/task/Scheduler.js +8 -8
  254. package/bin/task/Scheduler.js.map +1 -1
  255. package/bin/task/TaskPlugin.d.ts +7 -14
  256. package/bin/task/TaskPlugin.d.ts.map +1 -1
  257. package/bin/task/TaskPlugin.js +54 -43
  258. package/bin/task/TaskPlugin.js.map +1 -1
  259. package/bin/task/runtime/Model.d.ts +1 -5
  260. package/bin/task/runtime/Model.d.ts.map +1 -1
  261. package/bin/task/runtime/Model.js +2 -13
  262. package/bin/task/runtime/Model.js.map +1 -1
  263. package/bin/task/runtime/Paths.d.ts +7 -7
  264. package/bin/task/runtime/Paths.d.ts.map +1 -1
  265. package/bin/task/runtime/Paths.js +11 -11
  266. package/bin/task/runtime/Paths.js.map +1 -1
  267. package/bin/task/runtime/Runner.d.ts +1 -1
  268. package/bin/task/runtime/Runner.d.ts.map +1 -1
  269. package/bin/task/runtime/Runner.js +4 -5
  270. package/bin/task/runtime/Runner.js.map +1 -1
  271. package/bin/task/runtime/Store.d.ts +9 -9
  272. package/bin/task/runtime/Store.d.ts.map +1 -1
  273. package/bin/task/runtime/Store.js +17 -17
  274. package/bin/task/runtime/Store.js.map +1 -1
  275. package/bin/task/runtime/TaskActionExecution.js +6 -6
  276. package/bin/task/runtime/TaskActionExecution.js.map +1 -1
  277. package/bin/task/runtime/TaskPluginActionRegistry.js +1 -1
  278. package/bin/task/runtime/TaskPluginActionRegistry.js.map +1 -1
  279. package/bin/task/runtime/TaskRunnerRound.d.ts +0 -1
  280. package/bin/task/runtime/TaskRunnerRound.d.ts.map +1 -1
  281. package/bin/task/runtime/TaskRunnerRound.js +8 -3
  282. package/bin/task/runtime/TaskRunnerRound.js.map +1 -1
  283. package/bin/task/runtime/TaskRunnerScript.d.ts +0 -4
  284. package/bin/task/runtime/TaskRunnerScript.d.ts.map +1 -1
  285. package/bin/task/runtime/TaskRunnerScript.js +0 -1
  286. package/bin/task/runtime/TaskRunnerScript.js.map +1 -1
  287. package/bin/task/runtime/TaskRunnerSession.d.ts +2 -3
  288. package/bin/task/runtime/TaskRunnerSession.d.ts.map +1 -1
  289. package/bin/task/runtime/TaskRunnerSession.js +2 -4
  290. package/bin/task/runtime/TaskRunnerSession.js.map +1 -1
  291. package/bin/task/types/TaskWorkspaceRuntime.d.ts +10 -0
  292. package/bin/task/types/TaskWorkspaceRuntime.d.ts.map +1 -0
  293. package/bin/task/types/TaskWorkspaceRuntime.js +3 -0
  294. package/bin/task/types/TaskWorkspaceRuntime.js.map +1 -0
  295. package/bin/web/Plugin.d.ts +2 -6
  296. package/bin/web/Plugin.d.ts.map +1 -1
  297. package/bin/web/Plugin.js +21 -17
  298. package/bin/web/Plugin.js.map +1 -1
  299. package/bin/web/providers/PlaywrightBrowserProvider.d.ts.map +1 -1
  300. package/bin/web/providers/PlaywrightBrowserProvider.js +59 -14
  301. package/bin/web/providers/PlaywrightBrowserProvider.js.map +1 -1
  302. package/bin/web/types/WebPlugin.d.ts +15 -9
  303. package/bin/web/types/WebPlugin.d.ts.map +1 -1
  304. package/bin/web.d.ts +1 -1
  305. package/bin/web.d.ts.map +1 -1
  306. package/bin/workboard/runtime/Collector.js +1 -1
  307. package/bin/workboard/runtime/Collector.js.map +1 -1
  308. package/package.json +29 -20
  309. package/scripts/chat-access.test.mjs +3 -2
  310. package/scripts/chat-channel-config.test.mjs +3 -3
  311. package/scripts/chat-storage.test.mjs +10 -14
  312. package/scripts/memory-plugin.test.mjs +9 -32
  313. package/scripts/playwright-browser-provider.test.mjs +260 -0
  314. package/scripts/plugin-main.test.mjs +101 -0
  315. package/scripts/plugin-subpaths.test.mjs +28 -0
  316. package/scripts/sound-plugin.test.mjs +21 -9
  317. package/scripts/unrestricted-sandbox-approval.test.mjs +1 -1
  318. package/scripts/web-plugin.test.mjs +43 -186
  319. package/src/builtin/BuiltinPluginReadmes.ts +58 -0
  320. package/src/builtin/BuiltinPluginTypes.ts +260 -0
  321. package/src/builtin/PluginSettingsDefinitions.ts +45 -0
  322. package/src/builtin/main/PluginSettingsMain.ts +75 -0
  323. package/src/builtin/renderer/PluginSettingsRenderer.tsx +110 -0
  324. package/src/builtin/types/PluginSettings.ts +46 -0
  325. package/src/chat/ChatPlugin.ts +99 -51
  326. package/src/chat/access/ChatAccessRuntime.ts +1 -1
  327. package/src/chat/access/ChatAccessSchema.ts +5 -5
  328. package/src/chat/access/ChatAccessService.ts +4 -4
  329. package/src/chat/access/ChatAccessStore.ts +17 -9
  330. package/src/chat/channels/BaseChatChannel.ts +2 -0
  331. package/src/chat/channels/RuntimeChannel.ts +9 -9
  332. package/src/chat/channels/feishu/Feishu.ts +1 -1
  333. package/src/chat/channels/feishu/FeishuPlatformClient.ts +3 -0
  334. package/src/chat/channels/feishu/FeishuPlatformLookup.ts +3 -1
  335. package/src/chat/channels/qq/QQ.ts +3 -2
  336. package/src/chat/channels/qq/QQEventCapture.ts +3 -3
  337. package/src/chat/channels/qq/QQInboundDedupe.ts +2 -3
  338. package/src/chat/channels/qq/QQMessageHandler.ts +6 -0
  339. package/src/chat/channels/qq/QQSupport.ts +5 -0
  340. package/src/chat/channels/qq/VoiceInput.ts +5 -1
  341. package/src/chat/channels/telegram/ApiClient.ts +10 -3
  342. package/src/chat/channels/telegram/StateStore.ts +2 -2
  343. package/src/chat/channels/telegram/TelegramPlatformClient.ts +2 -1
  344. package/src/chat/main/ChatPluginMain.ts +163 -0
  345. package/src/chat/renderer/ChatPluginRenderer.tsx +149 -0
  346. package/src/chat/runtime/ChannelContextStore.ts +20 -20
  347. package/src/chat/runtime/ChatActionExecution.ts +6 -6
  348. package/src/chat/runtime/ChatChannelConfig.ts +7 -14
  349. package/src/chat/runtime/ChatChannelCore.ts +9 -9
  350. package/src/chat/runtime/ChatHistoryStore.ts +7 -7
  351. package/src/chat/runtime/ChatMetaStore.ts +1 -1
  352. package/src/chat/runtime/ChatPluginActionRegistry.ts +10 -10
  353. package/src/chat/runtime/ChatQueue.ts +2 -69
  354. package/src/chat/runtime/ChatQueueStore.ts +10 -26
  355. package/src/chat/runtime/ChatQueueWorker.ts +2 -5
  356. package/src/chat/runtime/ChatSessionDelete.ts +4 -4
  357. package/src/chat/runtime/ChatStorage.ts +24 -24
  358. package/src/chat/types/ChatAccess.ts +2 -2
  359. package/src/chat/types/ChatCommand.ts +1 -1
  360. package/src/chat/types/ChatPluginChannelConfig.ts +63 -0
  361. package/src/chat/types/ChatPluginConfig.ts +21 -0
  362. package/src/chat/types/ChatPluginOptions.ts +4 -4
  363. package/src/chat/types/ChatPluginProfile.ts +52 -0
  364. package/src/chat/types/ChatPluginRenderer.ts +25 -0
  365. package/src/chat/types/ChatRuntime.ts +14 -0
  366. package/src/chat/types/ChatRuntimeAccount.ts +3 -3
  367. package/src/chat/types/ChatStorage.ts +2 -2
  368. package/src/chat.ts +6 -14
  369. package/src/contact/Action.ts +5 -5
  370. package/src/contact/ContactPlugin.ts +15 -15
  371. package/src/contact/runtime/ChatRuntime.ts +3 -3
  372. package/src/contact/runtime/ContactStore.ts +20 -20
  373. package/src/contact/runtime/EndpointNotice.ts +2 -2
  374. package/src/contact/runtime/InboxStore.ts +16 -16
  375. package/src/contact/runtime/LinkApproval.ts +16 -16
  376. package/src/contact/runtime/LinkStore.ts +5 -5
  377. package/src/contact/runtime/Paths.ts +29 -29
  378. package/src/contact/runtime/ShareBundle.ts +5 -5
  379. package/src/contact/types/ContactApproval.ts +2 -2
  380. package/src/image/ImagePlugin.ts +30 -33
  381. package/src/image/runtime/ImageResultStorage.ts +36 -62
  382. package/src/image/types/ImagePlugin.ts +25 -19
  383. package/src/image.ts +2 -0
  384. package/src/index.ts +8 -0
  385. package/src/memory/MemoryPlugin.ts +17 -5
  386. package/src/memory/types/Memory.ts +11 -4
  387. package/src/memory.ts +1 -0
  388. package/src/renderers.ts +18 -0
  389. package/src/sound/Plugin.ts +34 -33
  390. package/src/sound/types/SoundPlugin.ts +24 -19
  391. package/src/sound.ts +2 -0
  392. package/src/task/Action.ts +27 -27
  393. package/src/task/PROMPT.ts +1 -1
  394. package/src/task/PROMPT.ts.txt +5 -6
  395. package/src/task/Scheduler.ts +8 -8
  396. package/src/task/TaskPlugin.ts +55 -46
  397. package/src/task/runtime/Model.ts +3 -13
  398. package/src/task/runtime/Paths.ts +11 -11
  399. package/src/task/runtime/Runner.ts +5 -6
  400. package/src/task/runtime/Store.ts +22 -22
  401. package/src/task/runtime/TaskActionExecution.ts +6 -6
  402. package/src/task/runtime/TaskPluginActionRegistry.ts +1 -1
  403. package/src/task/runtime/TaskRunnerRound.ts +13 -4
  404. package/src/task/runtime/TaskRunnerScript.ts +0 -5
  405. package/src/task/runtime/TaskRunnerSession.ts +10 -8
  406. package/src/task/types/TaskWorkspaceRuntime.ts +12 -0
  407. package/src/web/Plugin.ts +23 -22
  408. package/src/web/providers/PlaywrightBrowserProvider.ts +93 -17
  409. package/src/web/types/WebPlugin.ts +16 -13
  410. package/src/web.ts +1 -0
  411. package/src/workboard/runtime/Collector.ts +1 -1
  412. package/tsconfig.json +4 -1
  413. package/LICENSE +0 -183
  414. package/bin/chat/Index.d.ts +0 -15
  415. package/bin/chat/Index.d.ts.map +0 -1
  416. package/bin/chat/Index.js +0 -11
  417. package/bin/chat/Index.js.map +0 -1
  418. package/bin/chat/config/ChatPluginConfig.d.ts +0 -67
  419. package/bin/chat/config/ChatPluginConfig.d.ts.map +0 -1
  420. package/bin/chat/config/ChatPluginConfig.js +0 -237
  421. package/bin/chat/config/ChatPluginConfig.js.map +0 -1
  422. package/bin/chat/types/ChatPluginResource.d.ts +0 -68
  423. package/bin/chat/types/ChatPluginResource.d.ts.map +0 -1
  424. package/bin/chat/types/ChatPluginResource.js +0 -10
  425. package/bin/chat/types/ChatPluginResource.js.map +0 -1
  426. package/bin/contact/Index.d.ts +0 -8
  427. package/bin/contact/Index.d.ts.map +0 -1
  428. package/bin/contact/Index.js +0 -8
  429. package/bin/contact/Index.js.map +0 -1
  430. package/bin/memory/Index.d.ts +0 -11
  431. package/bin/memory/Index.d.ts.map +0 -1
  432. package/bin/memory/Index.js +0 -11
  433. package/bin/memory/Index.js.map +0 -1
  434. package/bin/skill/Command.d.ts +0 -29
  435. package/bin/skill/Command.d.ts.map +0 -1
  436. package/bin/skill/Command.js +0 -35
  437. package/bin/skill/Command.js.map +0 -1
  438. package/bin/task/Index.d.ts +0 -9
  439. package/bin/task/Index.d.ts.map +0 -1
  440. package/bin/task/Index.js +0 -9
  441. package/bin/task/Index.js.map +0 -1
  442. package/src/chat/Index.ts +0 -36
  443. package/src/chat/config/ChatPluginConfig.ts +0 -266
  444. package/src/chat/types/ChatPluginResource.ts +0 -95
  445. package/src/contact/Index.ts +0 -8
  446. package/src/memory/Index.ts +0 -14
  447. package/src/skill/Command.ts +0 -58
  448. package/src/task/Index.ts +0 -8
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * 关键点(中文)
5
5
  * - 对 Agent 暴露 `image_create` / `image_result` 两步式任务 action。
6
- * - City / provider 的图片能力通过 image_create / image_result 任务函数注入。
6
+ * - 图片 AI 从运行时 Context Embassy 能力读取;Workspace 文件能力由运行时 Context 提供。
7
7
  * - 成功结果中的远程图片会写入 Workspace,并同时保留本地引用与在线来源地址。
8
8
  */
9
9
 
@@ -19,6 +19,7 @@ import type {
19
19
  } from "@downcity/agent";
20
20
  import type {
21
21
  ImagePluginInput,
22
+ ImageAiService,
22
23
  ImagePluginJobCreateResult,
23
24
  ImagePluginJobResult,
24
25
  ImagePluginJobResultInput,
@@ -51,6 +52,17 @@ const DEFAULT_IMAGE_WAIT_MS = 60_000;
51
52
  const DEFAULT_IMAGE_POLL_MS = 1_500;
52
53
  const MAX_IMAGE_WAIT_MS = 10 * 60_000;
53
54
 
55
+ /** 从 City 注入的 Embassy 获取图片 AI 服务。 */
56
+ function require_image_ai(context: PluginContext): ImageAiService {
57
+ const service = context.embassy?.user.ai;
58
+ if (!service) throw new Error("ImagePlugin requires a City Embassy user AI service");
59
+ return {
60
+ catalog: async () => await service.catalog(),
61
+ image_create: async (input) => await service.image_create(input as never),
62
+ image_result: async (input) => await service.image_result(input as never),
63
+ };
64
+ }
65
+
54
66
  /**
55
67
  * 判断任务状态是否已到达终态。
56
68
  */
@@ -386,15 +398,15 @@ function normalize_image_result_payload(
386
398
  }
387
399
 
388
400
  /**
389
- * 校验 image 函数返回的 UIMessage。
401
+ * 校验 image 函数返回的 Downcity Session 消息。
390
402
  *
391
- * 本函数只校验 provider / City 返回的 UIMessage 结构;
403
+ * 本函数只校验 provider / City 返回的 Session 消息结构;
392
404
  * 远程资源下载由 action 成功分支中的 ImageResultStorage 统一处理。
393
405
  */
394
406
  function normalize_image_result(result: ImagePluginResult): ImagePluginResult {
395
407
  const record = to_record(result);
396
408
  if (!record || !Array.isArray(record.parts)) {
397
- throw new TypeError("ImagePlugin image provider must return an AI SDK UIMessage");
409
+ throw new TypeError("ImagePlugin image provider must return a Downcity Session message");
398
410
  }
399
411
  for (const part of record.parts) {
400
412
  const part_record = to_record(part);
@@ -504,9 +516,6 @@ export class ImagePlugin extends BasePlugin {
504
516
  */
505
517
  readonly description: string;
506
518
 
507
- private readonly image_create: NonNullable<ImagePluginOptions["image_create"]>;
508
- private readonly image_result: NonNullable<ImagePluginOptions["image_result"]>;
509
- private readonly list_models?: ImagePluginOptions["list_models"];
510
519
  private readonly default_model?: ImagePluginDefaultModel;
511
520
 
512
521
  constructor(options: ImagePluginOptions) {
@@ -515,20 +524,11 @@ export class ImagePlugin extends BasePlugin {
515
524
  if (!name) {
516
525
  throw new Error("ImagePlugin requires a non-empty name");
517
526
  }
518
- if (typeof options.image_create !== "function") {
519
- throw new Error("ImagePlugin requires an image_create function");
520
- }
521
- if (typeof options.image_result !== "function") {
522
- throw new Error("ImagePlugin requires an image_result function");
523
- }
524
527
  this.name = name;
525
528
  this.title = String(options.title || DEFAULT_IMAGE_PLUGIN_TITLE).trim();
526
529
  this.description = String(
527
530
  options.description || DEFAULT_IMAGE_PLUGIN_DESCRIPTION,
528
531
  ).trim();
529
- this.image_create = options.image_create;
530
- this.image_result = options.image_result;
531
- this.list_models = options.list_models;
532
532
  this.default_model = normalize_default_image_model(options.default_model);
533
533
  }
534
534
 
@@ -578,8 +578,9 @@ export class ImagePlugin extends BasePlugin {
578
578
  */
579
579
  private async read_image_result(
580
580
  input: ImagePluginJobResultInput,
581
+ context: PluginContext,
581
582
  ): Promise<ImagePluginJobResult> {
582
- const first = await this.fetch_job_once(input.job_id);
583
+ const first = await this.fetch_job_once(input.job_id, context);
583
584
  if (!input.until_done) return first;
584
585
  if (is_terminal_status(first.status)) return first;
585
586
 
@@ -599,7 +600,7 @@ export class ImagePlugin extends BasePlugin {
599
600
  const sleep_ms = Math.min(wait_ms, remaining);
600
601
  if (sleep_ms === 0) break;
601
602
  await delay_ms(sleep_ms);
602
- current = await this.fetch_job_once(input.job_id);
603
+ current = await this.fetch_job_once(input.job_id, context);
603
604
  if (is_terminal_status(current.status)) return current;
604
605
  }
605
606
  return current;
@@ -608,8 +609,11 @@ export class ImagePlugin extends BasePlugin {
608
609
  /**
609
610
  * 拉取一次任务状态并校验。
610
611
  */
611
- private async fetch_job_once(job_id: string): Promise<ImagePluginJobResult> {
612
- const current = await this.image_result({ job_id });
612
+ private async fetch_job_once(
613
+ job_id: string,
614
+ context: PluginContext,
615
+ ): Promise<ImagePluginJobResult> {
616
+ const current = await require_image_ai(context).image_result({ job_id }) as unknown as ImagePluginJobResult;
613
617
  validate_job_result(current);
614
618
  if (current.status === "succeeded" && current.result) {
615
619
  normalize_image_result(current.result);
@@ -624,16 +628,9 @@ export class ImagePlugin extends BasePlugin {
624
628
  models: create_action({
625
629
  description: "List image-capable models available to ImagePlugin.",
626
630
  input_schema: z.object({}).passthrough(),
627
- execute: async () => {
631
+ execute: async ({ context }) => {
628
632
  try {
629
- if (!this.list_models) {
630
- return {
631
- success: false,
632
- error: "ImagePlugin list_models is not configured",
633
- message: "ImagePlugin list_models is not configured",
634
- };
635
- }
636
- const models = await this.list_models();
633
+ const models = await require_image_ai(context).catalog().then((catalog) => catalog.all()) as unknown as ImagePluginModel[];
637
634
  const result = normalize_image_models(models);
638
635
  return {
639
636
  success: true,
@@ -729,7 +726,7 @@ export class ImagePlugin extends BasePlugin {
729
726
  await normalize_image_create_input(context, normalized_payload),
730
727
  this.default_model,
731
728
  );
732
- const created = await this.image_create(normalized_input);
729
+ const created = await require_image_ai(context).image_create(normalized_input as unknown as JsonObject) as unknown as ImagePluginJobCreateResult;
733
730
  validate_created_job(created);
734
731
  return {
735
732
  success: true,
@@ -792,10 +789,10 @@ export class ImagePlugin extends BasePlugin {
792
789
  },
793
790
  },
794
791
  ],
795
- execute: async ({ context, execution_context, input }) => {
792
+ execute: async ({ context, execution, input }) => {
796
793
  try {
797
794
  const normalized_input = normalize_image_result_payload(input);
798
- const current = await this.read_image_result(normalized_input);
795
+ const current = await this.read_image_result(normalized_input, context);
799
796
  if (current.status === "failed") {
800
797
  return {
801
798
  success: false,
@@ -809,7 +806,7 @@ export class ImagePlugin extends BasePlugin {
809
806
  context,
810
807
  job_id: current.job_id,
811
808
  result: current.result,
812
- abort_signal: execution_context?.abort_signal,
809
+ abort_signal: execution.abort_signal,
813
810
  })
814
811
  : undefined;
815
812
  const output = localized
@@ -2,8 +2,8 @@
2
2
  * ImagePlugin 生成结果本地化。
3
3
  *
4
4
  * 关键点(中文)
5
- * - City / provider 返回的远程图片先落到当前 Workspace,再交给 Agent Session。
6
- * - File Part 的 `url` 使用稳定的本地相对路径,原始在线地址写入 provider metadata。
5
+ * - City / provider 返回的远程图片先落到当前 Agent private runtime directory 私有目录,再交给 Agent Session。
6
+ * - File Part 的 `url` 使用稳定的本地绝对路径。
7
7
  * - 单张图片下载失败时保留远程地址,并返回可观察错误,不丢弃已经生成成功的结果。
8
8
  */
9
9
 
@@ -12,6 +12,7 @@ import type {
12
12
  ImagePluginResultStorageInput,
13
13
  ImagePluginResultStorageResult,
14
14
  } from "@/image/types/ImagePlugin.js";
15
+ import type { SessionAssistantResultPart } from "@downcity/agent";
15
16
 
16
17
  const HTTP_URL_RE = /^https?:\/\//i;
17
18
  const MAX_IMAGE_RESULT_BYTES = 50 * 1024 * 1024;
@@ -25,12 +26,6 @@ const MEDIA_TYPE_EXTENSIONS: Record<string, string> = {
25
26
  "image/webp": ".webp",
26
27
  };
27
28
 
28
- /** 判断未知值是否为普通对象。 */
29
- function to_record(value: unknown): Record<string, unknown> | null {
30
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
31
- return value as Record<string, unknown>;
32
- }
33
-
34
29
  /** 把外部标识压缩为单个安全路径片段。 */
35
30
  function to_safe_segment(value: string, fallback: string): string {
36
31
  const normalized = String(value || "")
@@ -64,27 +59,6 @@ function resolve_extension(input: {
64
59
  return extension_from_url(input.source_url) || ".bin";
65
60
  }
66
61
 
67
- /** 给 File Part 合并 Downcity 来源元数据。 */
68
- function with_source_metadata(
69
- part: Record<string, unknown>,
70
- source_url: string,
71
- localization_error?: string,
72
- ): Record<string, unknown> {
73
- const provider_metadata = to_record(part.providerMetadata) ?? {};
74
- const downcity_metadata = to_record(provider_metadata.downcity) ?? {};
75
- return {
76
- ...part,
77
- providerMetadata: {
78
- ...provider_metadata,
79
- downcity: {
80
- ...downcity_metadata,
81
- source_url,
82
- ...(localization_error ? { localization_error } : {}),
83
- },
84
- },
85
- };
86
- }
87
-
88
62
  /** 受大小上限保护地读取远程响应。 */
89
63
  async function read_response_bytes(response: Response): Promise<Buffer> {
90
64
  const declared_length = Number(response.headers.get("content-length") || 0);
@@ -109,11 +83,11 @@ async function read_response_bytes(response: Response): Promise<Buffer> {
109
83
  return Buffer.concat(chunks.map((chunk) => Buffer.from(chunk)), total_bytes);
110
84
  }
111
85
 
112
- /** 下载一张远程图片并返回 Workspace 相对路径。 */
86
+ /** 下载一张远程图片并返回 Agent private runtime directory 私有目录中的绝对路径。 */
113
87
  async function persist_remote_image(input: {
114
88
  context: ImagePluginResultStorageInput["context"];
115
89
  job_id: string;
116
- part: Record<string, unknown>;
90
+ part: Extract<SessionAssistantResultPart, { type: "file" }>;
117
91
  source_url: string;
118
92
  part_index: number;
119
93
  abort_signal?: AbortSignal;
@@ -125,7 +99,7 @@ async function persist_remote_image(input: {
125
99
  throw new Error(`image download failed with HTTP ${response.status}`);
126
100
  }
127
101
 
128
- const declared_media_type = String(input.part.mediaType || "").trim();
102
+ const declared_media_type = input.part.media_type.trim();
129
103
  const response_media_type = String(response.headers.get("content-type") || "")
130
104
  .split(";", 1)[0]
131
105
  .trim();
@@ -138,21 +112,20 @@ async function persist_remote_image(input: {
138
112
  const job_segment = to_safe_segment(input.job_id, "job");
139
113
  const filename = `image_${String(input.part_index + 1).padStart(2, "0")}${extension}`;
140
114
  const relative_path = path.posix.join(
141
- ".downcity",
142
115
  "image",
143
116
  "results",
144
117
  job_segment,
145
118
  filename,
146
119
  );
147
- const absolute_path = input.context.files.resolve_path(...relative_path.split("/"));
148
- if (!(await input.context.files.path_exists(absolute_path))) {
120
+ const absolute_path = input.context.data_files.resolve_path(...relative_path.split("/"));
121
+ if (!(await input.context.data_files.path_exists(absolute_path))) {
149
122
  const bytes = await read_response_bytes(response);
150
- await input.context.files.ensure_directory(path.dirname(absolute_path));
151
- await input.context.files.write_file_atomically(absolute_path, bytes);
123
+ await input.context.data_files.ensure_directory(path.dirname(absolute_path));
124
+ await input.context.data_files.write_file_atomically(absolute_path, bytes);
152
125
  } else {
153
126
  await response.body?.cancel();
154
127
  }
155
- return relative_path;
128
+ return absolute_path;
156
129
  }
157
130
 
158
131
  /**
@@ -162,31 +135,32 @@ export async function localize_image_result(
162
135
  input: ImagePluginResultStorageInput,
163
136
  ): Promise<ImagePluginResultStorageResult> {
164
137
  const errors: string[] = [];
165
- const parts = await Promise.all(input.result.parts.map(async (part, part_index) => {
166
- const record = to_record(part);
167
- if (record?.type !== "file") return part;
168
- const source_url = String(record.url || "").trim();
169
- if (!HTTP_URL_RE.test(source_url)) return part;
138
+ const parts: SessionAssistantResultPart[] = await Promise.all(
139
+ input.result.parts.map(async (part, part_index): Promise<SessionAssistantResultPart> => {
140
+ if (part.type !== "file") return part;
141
+ const source_url = part.url.trim();
142
+ if (!HTTP_URL_RE.test(source_url)) return part;
170
143
 
171
- try {
172
- const local_url = await persist_remote_image({
173
- context: input.context,
174
- job_id: input.job_id,
175
- part: record,
176
- source_url,
177
- part_index,
178
- abort_signal: input.abort_signal,
179
- });
180
- return {
181
- ...with_source_metadata(record, source_url),
182
- url: local_url,
183
- } as typeof part;
184
- } catch (error) {
185
- const message = error instanceof Error ? error.message : String(error);
186
- errors.push(`part ${part_index + 1}: ${message}`);
187
- return with_source_metadata(record, source_url, message) as typeof part;
188
- }
189
- }));
144
+ try {
145
+ const local_url = await persist_remote_image({
146
+ context: input.context,
147
+ job_id: input.job_id,
148
+ part,
149
+ source_url,
150
+ part_index,
151
+ abort_signal: input.abort_signal,
152
+ });
153
+ return {
154
+ ...part,
155
+ url: local_url,
156
+ };
157
+ } catch (error) {
158
+ const message = error instanceof Error ? error.message : String(error);
159
+ errors.push(`part ${part_index + 1}: ${message}`);
160
+ return part;
161
+ }
162
+ }),
163
+ );
190
164
 
191
165
  return {
192
166
  result: {
@@ -3,17 +3,29 @@
3
3
  *
4
4
  * 关键点(中文)
5
5
  * - 这里仅定义图片 plugin 对图片能力的最低层协议,不绑定 city 或任意上游 provider。
6
- * - 图片成功结果使用 AI SDK UIMessage,保证 session 落盘格式与现有消息系统一致。
6
+ * - 图片成功结果使用 Downcity Session 消息,保证结果可直接写入会话时间线。
7
7
  * - 字段保持 JSON 可序列化,便于通过 Plugin Action 与 Tool 传递。
8
8
  */
9
9
 
10
- import type { UIMessage } from "ai";
11
10
  import type {
11
+ ActionResultMessage,
12
12
  JsonObject,
13
13
  JsonValue,
14
14
  } from "@downcity/agent";
15
15
  import type { PluginContext } from "@downcity/agent";
16
16
 
17
+ /** ImagePlugin 使用的最小图片 AI 服务协议。 */
18
+ export interface ImageAiService {
19
+ /** 读取当前可用的图片模型目录。 */
20
+ catalog(): Promise<{ all(): readonly unknown[] }>;
21
+
22
+ /** 创建图片生成任务。 */
23
+ image_create(input: JsonObject): Promise<unknown>;
24
+
25
+ /** 查询图片生成任务。 */
26
+ image_result(input: JsonObject): Promise<unknown>;
27
+ }
28
+
17
29
  /**
18
30
  * 图片生成文本内容片段。
19
31
  */
@@ -139,7 +151,7 @@ export interface ImagePluginResolvedInput {
139
151
  /**
140
152
  * ImagePlugin 图片成功结果。
141
153
  */
142
- export type ImagePluginResult = UIMessage;
154
+ export type ImagePluginResult = ActionResultMessage;
143
155
 
144
156
  /**
145
157
  * 图片结果本地存储输入。
@@ -149,7 +161,7 @@ export interface ImagePluginResultStorageInput {
149
161
  context: PluginContext;
150
162
  /** 当前图片任务 ID,用于划分稳定的本地结果目录。 */
151
163
  job_id: string;
152
- /** City 或 provider 返回的原始图片 UIMessage。 */
164
+ /** City 或 provider 返回的原始 Downcity Session 消息。 */
153
165
  result: ImagePluginResult;
154
166
  /** 当前 Session Turn 的可选取消信号。 */
155
167
  abort_signal?: AbortSignal;
@@ -159,7 +171,7 @@ export interface ImagePluginResultStorageInput {
159
171
  * 图片结果本地存储输出。
160
172
  */
161
173
  export interface ImagePluginResultStorageResult {
162
- /** 已将可下载远程图片替换为本地 Workspace 路径的 UIMessage。 */
174
+ /** 已将可下载远程图片替换为本地 Workspace 路径的 Downcity Session 消息。 */
163
175
  result: ImagePluginResult;
164
176
  /** 未能完成本地化的图片错误;对应 File Part 会保留远程 URL。 */
165
177
  errors: string[];
@@ -194,7 +206,7 @@ export interface ImagePluginJobResult {
194
206
  job_id: string;
195
207
  /** 当前任务状态。 */
196
208
  status: ImagePluginJobStatus;
197
- /** 成功时返回的 AI SDK UIMessage。 */
209
+ /** 成功时返回的 Downcity Session 消息。 */
198
210
  result?: ImagePluginResult;
199
211
  /** 失败时返回的错误消息。 */
200
212
  error?: string;
@@ -284,23 +296,17 @@ export type ImagePluginDefaultModel =
284
296
  /**
285
297
  * ImagePlugin 构造参数。
286
298
  */
287
- export interface ImagePluginOptions {
299
+ export interface ImagePluginProfile {
288
300
  /** Plugin 稳定名称,默认 `image`。 */
289
301
  name?: string;
290
302
  /** Plugin 展示标题,默认 `Image`。 */
291
303
  title?: string;
292
304
  /** Plugin 用途说明。 */
293
305
  description?: string;
294
- /** 默认图片模型配置。Agent 调用 `image_create` 未传 `model` 时会自动使用字符串值或函数返回值。 */
295
- default_model?: ImagePluginDefaultModel;
296
- /** 创建图片生成任务,通常传入 `(input) => city.ai.image_create(input)`。 */
297
- image_create?: (
298
- input: ImagePluginResolvedInput,
299
- ) => Promise<ImagePluginJobCreateResult> | ImagePluginJobCreateResult;
300
- /** 查询图片生成任务,通常传入 `(input) => city.ai.image_result(input)`。 */
301
- image_result?: (
302
- input: ImagePluginJobResultInput,
303
- ) => Promise<ImagePluginJobResult> | ImagePluginJobResult;
304
- /** 列出可用图片模型,通常传入 `async () => city.ai.catalog().then((catalog) => catalog.forModality("image"))`。 */
305
- list_models?: () => Promise<ImagePluginModel[]> | ImagePluginModel[];
306
+ /** 默认图片模型 ID。 */
307
+ default_model?: string;
308
+ }
309
+
310
+ /** ImagePlugin 构造参数。 */
311
+ export interface ImagePluginOptions extends ImagePluginProfile {
306
312
  }
package/src/image.ts CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  export { ImagePlugin } from "./image/ImagePlugin.js";
8
8
  export type {
9
+ ImageAiService,
9
10
  ImagePluginContent,
10
11
  ImagePluginDefaultModel,
11
12
  ImagePluginDefaultModelResolverInput,
@@ -18,6 +19,7 @@ export type {
18
19
  ImagePluginModel,
19
20
  ImagePluginModelsResult,
20
21
  ImagePluginOptions,
22
+ ImagePluginProfile,
21
23
  ImagePluginResolvedContent,
22
24
  ImagePluginResolvedInput,
23
25
  ImagePluginResolvedMessage,
package/src/index.ts CHANGED
@@ -16,3 +16,11 @@ export * from "./sound.js";
16
16
  export * from "./task.js";
17
17
  export * from "./web.js";
18
18
  export * from "./workboard.js";
19
+ export {
20
+ create_builtin_plugin_registrations,
21
+ } from "./builtin/BuiltinPluginTypes.js";
22
+ export type {
23
+ BuiltinPluginDefinition,
24
+ BuiltinPluginRegistration,
25
+ BuiltinPluginRegistrationsOptions,
26
+ } from "./builtin/BuiltinPluginTypes.js";
@@ -13,6 +13,8 @@
13
13
  */
14
14
 
15
15
  import type { Command } from "commander";
16
+ import os from "node:os";
17
+ import path from "node:path";
16
18
  import { BasePlugin, create_action } from "@downcity/agent";
17
19
  import type {
18
20
  JsonObject,
@@ -31,6 +33,8 @@ import {
31
33
  status_memory_action,
32
34
  } from "@/memory/Action.js";
33
35
  import { build_memory_plugin_system_text } from "@/memory/runtime/SystemProvider.js";
36
+ import { BuiltinMemoryProvider } from "@/memory/providers/BuiltinMemoryProvider.js";
37
+ import { FileMemoryStorageAdapter, get_default_file_memory_root_path } from "@/memory/adapters/FileMemoryStorageAdapter.js";
34
38
  import type {
35
39
  MemoryPluginOptions,
36
40
  MemoryProvider,
@@ -106,12 +110,20 @@ export class MemoryPlugin extends BasePlugin {
106
110
  /** 当前 Plugin 唯一绑定的 Memory Provider。 */
107
111
  readonly provider: MemoryProvider;
108
112
 
109
- constructor(options: MemoryPluginOptions) {
113
+ constructor(profile: MemoryPluginOptions = {}) {
110
114
  super();
111
- if (!options?.provider) throw new Error("MemoryPlugin requires provider");
112
- const provider_name = String(options.provider.name || "").trim();
113
- if (!provider_name) throw new Error("MemoryPlugin provider requires name");
114
- this.provider = options.provider;
115
+ const root_path = profile.root_path?.trim();
116
+ if (root_path && !path.isAbsolute(root_path)) {
117
+ throw new Error("MemoryPlugin root_path must be absolute");
118
+ }
119
+ this.provider = new BuiltinMemoryProvider({
120
+ create_storage: ({ agent_id }) => new FileMemoryStorageAdapter({
121
+ root_path: root_path || get_default_file_memory_root_path({
122
+ platform_root_path: process.env.DC_PLATFORM_ROOT || path.join(os.homedir(), ".downcity"),
123
+ agent_id,
124
+ }),
125
+ }),
126
+ });
115
127
  }
116
128
 
117
129
  /** 构建 provider-neutral Memory system 内容。 */
@@ -386,12 +386,19 @@ export interface MemoryProvider {
386
386
  dispose(): Promise<void>;
387
387
  }
388
388
 
389
- /** MemoryPlugin constructor 参数。 */
390
- export interface MemoryPluginOptions {
391
- /** 当前 Plugin 唯一使用的主 Memory Provider。 */
392
- provider: MemoryProvider;
389
+ /** MemoryPlugin profile。 */
390
+ export interface MemoryPluginProfile {
391
+ /** 当前启用的 Memory Provider。 */
392
+ provider?: "builtin";
393
+ /** 当前启用的 Memory Storage。 */
394
+ storage?: "file";
395
+ /** 可选的绝对存储目录。 */
396
+ root_path?: string;
393
397
  }
394
398
 
399
+ /** MemoryPlugin profile 的兼容名称别名。 */
400
+ export type MemoryPluginOptions = MemoryPluginProfile;
401
+
395
402
  /** Memory action 可以接受的公开 JSON payload 联合。 */
396
403
  export type MemoryActionPayload =
397
404
  | Omit<MemoryRecallInput, "scope">
package/src/memory.ts CHANGED
@@ -17,6 +17,7 @@ export type {
17
17
  MemoryForgetInput,
18
18
  MemoryForgetResult,
19
19
  MemoryPluginOptions,
20
+ MemoryPluginProfile,
20
21
  MemoryProvider,
21
22
  MemoryProviderCapabilities,
22
23
  MemoryProviderInitializeInput,
@@ -0,0 +1,18 @@
1
+ /** Downcity 官方 Plugin Mainview 的 Renderer 专用注册表。 */
2
+
3
+ import type { PluginRendererComponent } from "@downcity/plugin/react";
4
+ import { CHAT_PLUGIN_RENDERER } from "@/chat/renderer/ChatPluginRenderer.js";
5
+ import {
6
+ IMAGE_PLUGIN_SETTINGS,
7
+ SOUND_PLUGIN_SETTINGS,
8
+ WEB_PLUGIN_SETTINGS,
9
+ } from "@/builtin/PluginSettingsDefinitions.js";
10
+ import { create_plugin_settings_renderer } from "@/builtin/renderer/PluginSettingsRenderer.js";
11
+
12
+ /** 官方 Plugin ID 到唯一 Mainview 组件的稳定映射。 */
13
+ export const BUILTIN_PLUGIN_RENDERERS: Readonly<Record<string, PluginRendererComponent>> = {
14
+ chat: CHAT_PLUGIN_RENDERER,
15
+ web: create_plugin_settings_renderer(WEB_PLUGIN_SETTINGS),
16
+ image: create_plugin_settings_renderer(IMAGE_PLUGIN_SETTINGS),
17
+ sound: create_plugin_settings_renderer(SOUND_PLUGIN_SETTINGS),
18
+ };