@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.
- package/bin/builtin/BuiltinPluginReadmes.d.ts +14 -0
- package/bin/builtin/BuiltinPluginReadmes.d.ts.map +1 -0
- package/bin/builtin/BuiltinPluginReadmes.js +58 -0
- package/bin/builtin/BuiltinPluginReadmes.js.map +1 -0
- package/bin/builtin/BuiltinPluginTypes.d.ts +48 -0
- package/bin/builtin/BuiltinPluginTypes.d.ts.map +1 -0
- package/bin/builtin/BuiltinPluginTypes.js +161 -0
- package/bin/builtin/BuiltinPluginTypes.js.map +1 -0
- package/bin/builtin/PluginSettingsDefinitions.d.ts +9 -0
- package/bin/builtin/PluginSettingsDefinitions.d.ts.map +1 -0
- package/bin/builtin/PluginSettingsDefinitions.js +41 -0
- package/bin/builtin/PluginSettingsDefinitions.js.map +1 -0
- package/bin/builtin/main/PluginSettingsMain.d.ts +6 -0
- package/bin/builtin/main/PluginSettingsMain.d.ts.map +1 -0
- package/bin/builtin/main/PluginSettingsMain.js +65 -0
- package/bin/builtin/main/PluginSettingsMain.js.map +1 -0
- package/bin/builtin/renderer/PluginSettingsRenderer.d.ts +6 -0
- package/bin/builtin/renderer/PluginSettingsRenderer.d.ts.map +1 -0
- package/bin/builtin/renderer/PluginSettingsRenderer.js +76 -0
- package/bin/builtin/renderer/PluginSettingsRenderer.js.map +1 -0
- package/bin/builtin/types/PluginSettings.d.ts +35 -0
- package/bin/builtin/types/PluginSettings.d.ts.map +1 -0
- package/bin/builtin/types/PluginSettings.js +3 -0
- package/bin/builtin/types/PluginSettings.js.map +1 -0
- package/bin/chat/ChatPlugin.d.ts +12 -28
- package/bin/chat/ChatPlugin.d.ts.map +1 -1
- package/bin/chat/ChatPlugin.js +97 -49
- package/bin/chat/ChatPlugin.js.map +1 -1
- package/bin/chat/access/ChatAccessRuntime.js +1 -1
- package/bin/chat/access/ChatAccessRuntime.js.map +1 -1
- package/bin/chat/access/ChatAccessSchema.d.ts +2 -2
- package/bin/chat/access/ChatAccessSchema.d.ts.map +1 -1
- package/bin/chat/access/ChatAccessSchema.js +3 -3
- package/bin/chat/access/ChatAccessSchema.js.map +1 -1
- package/bin/chat/access/ChatAccessService.d.ts +2 -2
- package/bin/chat/access/ChatAccessService.d.ts.map +1 -1
- package/bin/chat/access/ChatAccessService.js +4 -4
- package/bin/chat/access/ChatAccessService.js.map +1 -1
- package/bin/chat/access/ChatAccessStore.d.ts +3 -3
- package/bin/chat/access/ChatAccessStore.d.ts.map +1 -1
- package/bin/chat/access/ChatAccessStore.js +17 -8
- package/bin/chat/access/ChatAccessStore.js.map +1 -1
- package/bin/chat/channels/BaseChatChannel.d.ts +1 -0
- package/bin/chat/channels/BaseChatChannel.d.ts.map +1 -1
- package/bin/chat/channels/BaseChatChannel.js +2 -0
- package/bin/chat/channels/BaseChatChannel.js.map +1 -1
- package/bin/chat/channels/RuntimeChannel.d.ts +4 -4
- package/bin/chat/channels/RuntimeChannel.d.ts.map +1 -1
- package/bin/chat/channels/RuntimeChannel.js +8 -8
- package/bin/chat/channels/RuntimeChannel.js.map +1 -1
- package/bin/chat/channels/feishu/Feishu.js +1 -1
- package/bin/chat/channels/feishu/Feishu.js.map +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformClient.d.ts +1 -0
- package/bin/chat/channels/feishu/FeishuPlatformClient.d.ts.map +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformClient.js +3 -0
- package/bin/chat/channels/feishu/FeishuPlatformClient.js.map +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformLookup.d.ts +2 -0
- package/bin/chat/channels/feishu/FeishuPlatformLookup.d.ts.map +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformLookup.js +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformLookup.js.map +1 -1
- package/bin/chat/channels/qq/QQ.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQ.js +3 -2
- package/bin/chat/channels/qq/QQ.js.map +1 -1
- package/bin/chat/channels/qq/QQEventCapture.d.ts +1 -1
- package/bin/chat/channels/qq/QQEventCapture.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQEventCapture.js +3 -3
- package/bin/chat/channels/qq/QQEventCapture.js.map +1 -1
- package/bin/chat/channels/qq/QQInboundDedupe.d.ts +1 -1
- package/bin/chat/channels/qq/QQInboundDedupe.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQInboundDedupe.js +1 -1
- package/bin/chat/channels/qq/QQInboundDedupe.js.map +1 -1
- package/bin/chat/channels/qq/QQMessageHandler.d.ts +4 -0
- package/bin/chat/channels/qq/QQMessageHandler.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQMessageHandler.js +2 -0
- package/bin/chat/channels/qq/QQMessageHandler.js.map +1 -1
- package/bin/chat/channels/qq/QQSupport.d.ts +4 -0
- package/bin/chat/channels/qq/QQSupport.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQSupport.js +1 -0
- package/bin/chat/channels/qq/QQSupport.js.map +1 -1
- package/bin/chat/channels/qq/VoiceInput.d.ts +3 -0
- package/bin/chat/channels/qq/VoiceInput.d.ts.map +1 -1
- package/bin/chat/channels/qq/VoiceInput.js +1 -1
- package/bin/chat/channels/qq/VoiceInput.js.map +1 -1
- package/bin/chat/channels/telegram/ApiClient.d.ts +3 -1
- package/bin/chat/channels/telegram/ApiClient.d.ts.map +1 -1
- package/bin/chat/channels/telegram/ApiClient.js +4 -2
- package/bin/chat/channels/telegram/ApiClient.js.map +1 -1
- package/bin/chat/channels/telegram/StateStore.d.ts +1 -1
- package/bin/chat/channels/telegram/StateStore.d.ts.map +1 -1
- package/bin/chat/channels/telegram/StateStore.js +2 -2
- package/bin/chat/channels/telegram/StateStore.js.map +1 -1
- package/bin/chat/channels/telegram/TelegramPlatformClient.d.ts.map +1 -1
- package/bin/chat/channels/telegram/TelegramPlatformClient.js +2 -1
- package/bin/chat/channels/telegram/TelegramPlatformClient.js.map +1 -1
- package/bin/chat/main/ChatPluginMain.d.ts +4 -0
- package/bin/chat/main/ChatPluginMain.d.ts.map +1 -0
- package/bin/chat/main/ChatPluginMain.js +137 -0
- package/bin/chat/main/ChatPluginMain.js.map +1 -0
- package/bin/chat/renderer/ChatPluginRenderer.d.ts +4 -0
- package/bin/chat/renderer/ChatPluginRenderer.d.ts.map +1 -0
- package/bin/chat/renderer/ChatPluginRenderer.js +105 -0
- package/bin/chat/renderer/ChatPluginRenderer.js.map +1 -0
- package/bin/chat/runtime/ChannelContextStore.d.ts +2 -2
- package/bin/chat/runtime/ChannelContextStore.js +20 -20
- package/bin/chat/runtime/ChannelContextStore.js.map +1 -1
- package/bin/chat/runtime/ChatActionExecution.js +6 -6
- package/bin/chat/runtime/ChatActionExecution.js.map +1 -1
- package/bin/chat/runtime/ChatChannelConfig.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelConfig.js +7 -12
- package/bin/chat/runtime/ChatChannelConfig.js.map +1 -1
- package/bin/chat/runtime/ChatChannelCore.d.ts +3 -3
- package/bin/chat/runtime/ChatChannelCore.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelCore.js +5 -5
- package/bin/chat/runtime/ChatChannelCore.js.map +1 -1
- package/bin/chat/runtime/ChatHistoryStore.d.ts +1 -1
- package/bin/chat/runtime/ChatHistoryStore.js +7 -7
- package/bin/chat/runtime/ChatHistoryStore.js.map +1 -1
- package/bin/chat/runtime/ChatMetaStore.d.ts +1 -1
- package/bin/chat/runtime/ChatMetaStore.js +1 -1
- package/bin/chat/runtime/ChatPluginActionRegistry.d.ts +1 -1
- package/bin/chat/runtime/ChatPluginActionRegistry.d.ts.map +1 -1
- package/bin/chat/runtime/ChatPluginActionRegistry.js +9 -9
- package/bin/chat/runtime/ChatPluginActionRegistry.js.map +1 -1
- package/bin/chat/runtime/ChatQueue.d.ts +3 -38
- package/bin/chat/runtime/ChatQueue.d.ts.map +1 -1
- package/bin/chat/runtime/ChatQueue.js +3 -51
- package/bin/chat/runtime/ChatQueue.js.map +1 -1
- package/bin/chat/runtime/ChatQueueStore.d.ts +5 -16
- package/bin/chat/runtime/ChatQueueStore.d.ts.map +1 -1
- package/bin/chat/runtime/ChatQueueStore.js +8 -22
- package/bin/chat/runtime/ChatQueueStore.js.map +1 -1
- package/bin/chat/runtime/ChatQueueWorker.d.ts +1 -1
- package/bin/chat/runtime/ChatQueueWorker.d.ts.map +1 -1
- package/bin/chat/runtime/ChatQueueWorker.js +1 -2
- package/bin/chat/runtime/ChatQueueWorker.js.map +1 -1
- package/bin/chat/runtime/ChatSessionDelete.d.ts +3 -3
- package/bin/chat/runtime/ChatSessionDelete.js +4 -4
- package/bin/chat/runtime/ChatSessionDelete.js.map +1 -1
- package/bin/chat/runtime/ChatStorage.d.ts +7 -7
- package/bin/chat/runtime/ChatStorage.js +24 -24
- package/bin/chat/runtime/ChatStorage.js.map +1 -1
- package/bin/chat/types/ChatAccess.d.ts +2 -2
- package/bin/chat/types/ChatAccess.d.ts.map +1 -1
- package/bin/chat/types/ChatCommand.d.ts +1 -1
- package/bin/chat/types/ChatPluginChannelConfig.d.ts +57 -0
- package/bin/chat/types/ChatPluginChannelConfig.d.ts.map +1 -0
- package/bin/chat/types/ChatPluginChannelConfig.js +3 -0
- package/bin/chat/types/ChatPluginChannelConfig.js.map +1 -0
- package/bin/chat/types/ChatPluginConfig.d.ts +19 -0
- package/bin/chat/types/ChatPluginConfig.d.ts.map +1 -0
- package/bin/chat/types/ChatPluginConfig.js +3 -0
- package/bin/chat/types/ChatPluginConfig.js.map +1 -0
- package/bin/chat/types/ChatPluginOptions.d.ts +4 -4
- package/bin/chat/types/ChatPluginOptions.d.ts.map +1 -1
- package/bin/chat/types/ChatPluginOptions.js +1 -1
- package/bin/chat/types/ChatPluginProfile.d.ts +39 -0
- package/bin/chat/types/ChatPluginProfile.d.ts.map +1 -0
- package/bin/chat/types/ChatPluginProfile.js +3 -0
- package/bin/chat/types/ChatPluginProfile.js.map +1 -0
- package/bin/chat/types/ChatPluginRenderer.d.ts +17 -0
- package/bin/chat/types/ChatPluginRenderer.d.ts.map +1 -0
- package/bin/chat/types/ChatPluginRenderer.js +3 -0
- package/bin/chat/types/ChatPluginRenderer.js.map +1 -0
- package/bin/chat/types/ChatRuntime.d.ts +11 -0
- package/bin/chat/types/ChatRuntime.d.ts.map +1 -1
- package/bin/chat/types/ChatRuntimeAccount.d.ts +3 -3
- package/bin/chat/types/ChatRuntimeAccount.d.ts.map +1 -1
- package/bin/chat/types/ChatRuntimeAccount.js +2 -2
- package/bin/chat/types/ChatStorage.d.ts +2 -2
- package/bin/chat/types/ChatStorage.d.ts.map +1 -1
- package/bin/chat.d.ts +3 -4
- package/bin/chat.d.ts.map +1 -1
- package/bin/chat.js +1 -2
- package/bin/chat.js.map +1 -1
- package/bin/contact/Action.js +5 -5
- package/bin/contact/Action.js.map +1 -1
- package/bin/contact/ContactPlugin.js +15 -15
- package/bin/contact/ContactPlugin.js.map +1 -1
- package/bin/contact/runtime/ChatRuntime.js +3 -3
- package/bin/contact/runtime/ChatRuntime.js.map +1 -1
- package/bin/contact/runtime/ContactStore.d.ts +8 -8
- package/bin/contact/runtime/ContactStore.d.ts.map +1 -1
- package/bin/contact/runtime/ContactStore.js +20 -20
- package/bin/contact/runtime/ContactStore.js.map +1 -1
- package/bin/contact/runtime/EndpointNotice.js +2 -2
- package/bin/contact/runtime/EndpointNotice.js.map +1 -1
- package/bin/contact/runtime/InboxStore.d.ts +6 -6
- package/bin/contact/runtime/InboxStore.d.ts.map +1 -1
- package/bin/contact/runtime/InboxStore.js +16 -16
- package/bin/contact/runtime/InboxStore.js.map +1 -1
- package/bin/contact/runtime/LinkApproval.js +14 -14
- package/bin/contact/runtime/LinkApproval.js.map +1 -1
- package/bin/contact/runtime/LinkStore.d.ts +2 -2
- package/bin/contact/runtime/LinkStore.d.ts.map +1 -1
- package/bin/contact/runtime/LinkStore.js +5 -5
- package/bin/contact/runtime/LinkStore.js.map +1 -1
- package/bin/contact/runtime/Paths.d.ts +15 -15
- package/bin/contact/runtime/Paths.d.ts.map +1 -1
- package/bin/contact/runtime/Paths.js +29 -29
- package/bin/contact/runtime/Paths.js.map +1 -1
- package/bin/contact/runtime/ShareBundle.d.ts +1 -1
- package/bin/contact/runtime/ShareBundle.d.ts.map +1 -1
- package/bin/contact/runtime/ShareBundle.js +4 -4
- package/bin/contact/runtime/ShareBundle.js.map +1 -1
- package/bin/contact/types/ContactApproval.d.ts +2 -2
- package/bin/contact/types/ContactApproval.d.ts.map +1 -1
- package/bin/image/ImagePlugin.d.ts +1 -4
- package/bin/image/ImagePlugin.d.ts.map +1 -1
- package/bin/image/ImagePlugin.js +26 -34
- package/bin/image/ImagePlugin.js.map +1 -1
- package/bin/image/runtime/ImageResultStorage.d.ts +2 -2
- package/bin/image/runtime/ImageResultStorage.d.ts.map +1 -1
- package/bin/image/runtime/ImageResultStorage.js +15 -38
- package/bin/image/runtime/ImageResultStorage.js.map +1 -1
- package/bin/image/types/ImagePlugin.d.ts +23 -16
- package/bin/image/types/ImagePlugin.d.ts.map +1 -1
- package/bin/image/types/ImagePlugin.js +1 -1
- package/bin/image.d.ts +1 -1
- package/bin/image.d.ts.map +1 -1
- package/bin/index.d.ts +2 -0
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +1 -0
- package/bin/index.js.map +1 -1
- package/bin/memory/MemoryPlugin.d.ts +1 -1
- package/bin/memory/MemoryPlugin.d.ts.map +1 -1
- package/bin/memory/MemoryPlugin.js +17 -7
- package/bin/memory/MemoryPlugin.js.map +1 -1
- package/bin/memory/types/Memory.d.ts +10 -4
- package/bin/memory/types/Memory.d.ts.map +1 -1
- package/bin/memory.d.ts +1 -1
- package/bin/memory.d.ts.map +1 -1
- package/bin/renderers.d.ts +5 -0
- package/bin/renderers.d.ts.map +1 -0
- package/bin/renderers.js +12 -0
- package/bin/renderers.js.map +1 -0
- package/bin/sound/Plugin.d.ts +2 -5
- package/bin/sound/Plugin.d.ts.map +1 -1
- package/bin/sound/Plugin.js +27 -31
- package/bin/sound/Plugin.js.map +1 -1
- package/bin/sound/types/SoundPlugin.d.ts +22 -15
- package/bin/sound/types/SoundPlugin.d.ts.map +1 -1
- package/bin/sound/types/SoundPlugin.js +2 -2
- package/bin/sound.d.ts +1 -1
- package/bin/sound.d.ts.map +1 -1
- package/bin/task/Action.d.ts +6 -6
- package/bin/task/Action.d.ts.map +1 -1
- package/bin/task/Action.js +21 -21
- package/bin/task/Action.js.map +1 -1
- package/bin/task/PROMPT.d.ts +1 -1
- package/bin/task/PROMPT.d.ts.map +1 -1
- package/bin/task/PROMPT.js +1 -1
- package/bin/task/PROMPT.js.map +1 -1
- package/bin/task/Scheduler.js +8 -8
- package/bin/task/Scheduler.js.map +1 -1
- package/bin/task/TaskPlugin.d.ts +7 -14
- package/bin/task/TaskPlugin.d.ts.map +1 -1
- package/bin/task/TaskPlugin.js +54 -43
- package/bin/task/TaskPlugin.js.map +1 -1
- package/bin/task/runtime/Model.d.ts +1 -5
- package/bin/task/runtime/Model.d.ts.map +1 -1
- package/bin/task/runtime/Model.js +2 -13
- package/bin/task/runtime/Model.js.map +1 -1
- package/bin/task/runtime/Paths.d.ts +7 -7
- package/bin/task/runtime/Paths.d.ts.map +1 -1
- package/bin/task/runtime/Paths.js +11 -11
- package/bin/task/runtime/Paths.js.map +1 -1
- package/bin/task/runtime/Runner.d.ts +1 -1
- package/bin/task/runtime/Runner.d.ts.map +1 -1
- package/bin/task/runtime/Runner.js +4 -5
- package/bin/task/runtime/Runner.js.map +1 -1
- package/bin/task/runtime/Store.d.ts +9 -9
- package/bin/task/runtime/Store.d.ts.map +1 -1
- package/bin/task/runtime/Store.js +17 -17
- package/bin/task/runtime/Store.js.map +1 -1
- package/bin/task/runtime/TaskActionExecution.js +6 -6
- package/bin/task/runtime/TaskActionExecution.js.map +1 -1
- package/bin/task/runtime/TaskPluginActionRegistry.js +1 -1
- package/bin/task/runtime/TaskPluginActionRegistry.js.map +1 -1
- package/bin/task/runtime/TaskRunnerRound.d.ts +0 -1
- package/bin/task/runtime/TaskRunnerRound.d.ts.map +1 -1
- package/bin/task/runtime/TaskRunnerRound.js +8 -3
- package/bin/task/runtime/TaskRunnerRound.js.map +1 -1
- package/bin/task/runtime/TaskRunnerScript.d.ts +0 -4
- package/bin/task/runtime/TaskRunnerScript.d.ts.map +1 -1
- package/bin/task/runtime/TaskRunnerScript.js +0 -1
- package/bin/task/runtime/TaskRunnerScript.js.map +1 -1
- package/bin/task/runtime/TaskRunnerSession.d.ts +2 -3
- package/bin/task/runtime/TaskRunnerSession.d.ts.map +1 -1
- package/bin/task/runtime/TaskRunnerSession.js +2 -4
- package/bin/task/runtime/TaskRunnerSession.js.map +1 -1
- package/bin/task/types/TaskWorkspaceRuntime.d.ts +10 -0
- package/bin/task/types/TaskWorkspaceRuntime.d.ts.map +1 -0
- package/bin/task/types/TaskWorkspaceRuntime.js +3 -0
- package/bin/task/types/TaskWorkspaceRuntime.js.map +1 -0
- package/bin/web/Plugin.d.ts +2 -6
- package/bin/web/Plugin.d.ts.map +1 -1
- package/bin/web/Plugin.js +21 -17
- package/bin/web/Plugin.js.map +1 -1
- package/bin/web/providers/PlaywrightBrowserProvider.d.ts.map +1 -1
- package/bin/web/providers/PlaywrightBrowserProvider.js +59 -14
- package/bin/web/providers/PlaywrightBrowserProvider.js.map +1 -1
- package/bin/web/types/WebPlugin.d.ts +15 -9
- package/bin/web/types/WebPlugin.d.ts.map +1 -1
- package/bin/web.d.ts +1 -1
- package/bin/web.d.ts.map +1 -1
- package/bin/workboard/runtime/Collector.js +1 -1
- package/bin/workboard/runtime/Collector.js.map +1 -1
- package/package.json +29 -20
- package/scripts/chat-access.test.mjs +3 -2
- package/scripts/chat-channel-config.test.mjs +3 -3
- package/scripts/chat-storage.test.mjs +10 -14
- package/scripts/memory-plugin.test.mjs +9 -32
- package/scripts/playwright-browser-provider.test.mjs +260 -0
- package/scripts/plugin-main.test.mjs +101 -0
- package/scripts/plugin-subpaths.test.mjs +28 -0
- package/scripts/sound-plugin.test.mjs +21 -9
- package/scripts/unrestricted-sandbox-approval.test.mjs +1 -1
- package/scripts/web-plugin.test.mjs +43 -186
- package/src/builtin/BuiltinPluginReadmes.ts +58 -0
- package/src/builtin/BuiltinPluginTypes.ts +260 -0
- package/src/builtin/PluginSettingsDefinitions.ts +45 -0
- package/src/builtin/main/PluginSettingsMain.ts +75 -0
- package/src/builtin/renderer/PluginSettingsRenderer.tsx +110 -0
- package/src/builtin/types/PluginSettings.ts +46 -0
- package/src/chat/ChatPlugin.ts +99 -51
- package/src/chat/access/ChatAccessRuntime.ts +1 -1
- package/src/chat/access/ChatAccessSchema.ts +5 -5
- package/src/chat/access/ChatAccessService.ts +4 -4
- package/src/chat/access/ChatAccessStore.ts +17 -9
- package/src/chat/channels/BaseChatChannel.ts +2 -0
- package/src/chat/channels/RuntimeChannel.ts +9 -9
- package/src/chat/channels/feishu/Feishu.ts +1 -1
- package/src/chat/channels/feishu/FeishuPlatformClient.ts +3 -0
- package/src/chat/channels/feishu/FeishuPlatformLookup.ts +3 -1
- package/src/chat/channels/qq/QQ.ts +3 -2
- package/src/chat/channels/qq/QQEventCapture.ts +3 -3
- package/src/chat/channels/qq/QQInboundDedupe.ts +2 -3
- package/src/chat/channels/qq/QQMessageHandler.ts +6 -0
- package/src/chat/channels/qq/QQSupport.ts +5 -0
- package/src/chat/channels/qq/VoiceInput.ts +5 -1
- package/src/chat/channels/telegram/ApiClient.ts +10 -3
- package/src/chat/channels/telegram/StateStore.ts +2 -2
- package/src/chat/channels/telegram/TelegramPlatformClient.ts +2 -1
- package/src/chat/main/ChatPluginMain.ts +163 -0
- package/src/chat/renderer/ChatPluginRenderer.tsx +149 -0
- package/src/chat/runtime/ChannelContextStore.ts +20 -20
- package/src/chat/runtime/ChatActionExecution.ts +6 -6
- package/src/chat/runtime/ChatChannelConfig.ts +7 -14
- package/src/chat/runtime/ChatChannelCore.ts +9 -9
- package/src/chat/runtime/ChatHistoryStore.ts +7 -7
- package/src/chat/runtime/ChatMetaStore.ts +1 -1
- package/src/chat/runtime/ChatPluginActionRegistry.ts +10 -10
- package/src/chat/runtime/ChatQueue.ts +2 -69
- package/src/chat/runtime/ChatQueueStore.ts +10 -26
- package/src/chat/runtime/ChatQueueWorker.ts +2 -5
- package/src/chat/runtime/ChatSessionDelete.ts +4 -4
- package/src/chat/runtime/ChatStorage.ts +24 -24
- package/src/chat/types/ChatAccess.ts +2 -2
- package/src/chat/types/ChatCommand.ts +1 -1
- package/src/chat/types/ChatPluginChannelConfig.ts +63 -0
- package/src/chat/types/ChatPluginConfig.ts +21 -0
- package/src/chat/types/ChatPluginOptions.ts +4 -4
- package/src/chat/types/ChatPluginProfile.ts +52 -0
- package/src/chat/types/ChatPluginRenderer.ts +25 -0
- package/src/chat/types/ChatRuntime.ts +14 -0
- package/src/chat/types/ChatRuntimeAccount.ts +3 -3
- package/src/chat/types/ChatStorage.ts +2 -2
- package/src/chat.ts +6 -14
- package/src/contact/Action.ts +5 -5
- package/src/contact/ContactPlugin.ts +15 -15
- package/src/contact/runtime/ChatRuntime.ts +3 -3
- package/src/contact/runtime/ContactStore.ts +20 -20
- package/src/contact/runtime/EndpointNotice.ts +2 -2
- package/src/contact/runtime/InboxStore.ts +16 -16
- package/src/contact/runtime/LinkApproval.ts +16 -16
- package/src/contact/runtime/LinkStore.ts +5 -5
- package/src/contact/runtime/Paths.ts +29 -29
- package/src/contact/runtime/ShareBundle.ts +5 -5
- package/src/contact/types/ContactApproval.ts +2 -2
- package/src/image/ImagePlugin.ts +30 -33
- package/src/image/runtime/ImageResultStorage.ts +36 -62
- package/src/image/types/ImagePlugin.ts +25 -19
- package/src/image.ts +2 -0
- package/src/index.ts +8 -0
- package/src/memory/MemoryPlugin.ts +17 -5
- package/src/memory/types/Memory.ts +11 -4
- package/src/memory.ts +1 -0
- package/src/renderers.ts +18 -0
- package/src/sound/Plugin.ts +34 -33
- package/src/sound/types/SoundPlugin.ts +24 -19
- package/src/sound.ts +2 -0
- package/src/task/Action.ts +27 -27
- package/src/task/PROMPT.ts +1 -1
- package/src/task/PROMPT.ts.txt +5 -6
- package/src/task/Scheduler.ts +8 -8
- package/src/task/TaskPlugin.ts +55 -46
- package/src/task/runtime/Model.ts +3 -13
- package/src/task/runtime/Paths.ts +11 -11
- package/src/task/runtime/Runner.ts +5 -6
- package/src/task/runtime/Store.ts +22 -22
- package/src/task/runtime/TaskActionExecution.ts +6 -6
- package/src/task/runtime/TaskPluginActionRegistry.ts +1 -1
- package/src/task/runtime/TaskRunnerRound.ts +13 -4
- package/src/task/runtime/TaskRunnerScript.ts +0 -5
- package/src/task/runtime/TaskRunnerSession.ts +10 -8
- package/src/task/types/TaskWorkspaceRuntime.ts +12 -0
- package/src/web/Plugin.ts +23 -22
- package/src/web/providers/PlaywrightBrowserProvider.ts +93 -17
- package/src/web/types/WebPlugin.ts +16 -13
- package/src/web.ts +1 -0
- package/src/workboard/runtime/Collector.ts +1 -1
- package/tsconfig.json +4 -1
- package/LICENSE +0 -183
- package/bin/chat/Index.d.ts +0 -15
- package/bin/chat/Index.d.ts.map +0 -1
- package/bin/chat/Index.js +0 -11
- package/bin/chat/Index.js.map +0 -1
- package/bin/chat/config/ChatPluginConfig.d.ts +0 -67
- package/bin/chat/config/ChatPluginConfig.d.ts.map +0 -1
- package/bin/chat/config/ChatPluginConfig.js +0 -237
- package/bin/chat/config/ChatPluginConfig.js.map +0 -1
- package/bin/chat/types/ChatPluginResource.d.ts +0 -68
- package/bin/chat/types/ChatPluginResource.d.ts.map +0 -1
- package/bin/chat/types/ChatPluginResource.js +0 -10
- package/bin/chat/types/ChatPluginResource.js.map +0 -1
- package/bin/contact/Index.d.ts +0 -8
- package/bin/contact/Index.d.ts.map +0 -1
- package/bin/contact/Index.js +0 -8
- package/bin/contact/Index.js.map +0 -1
- package/bin/memory/Index.d.ts +0 -11
- package/bin/memory/Index.d.ts.map +0 -1
- package/bin/memory/Index.js +0 -11
- package/bin/memory/Index.js.map +0 -1
- package/bin/skill/Command.d.ts +0 -29
- package/bin/skill/Command.d.ts.map +0 -1
- package/bin/skill/Command.js +0 -35
- package/bin/skill/Command.js.map +0 -1
- package/bin/task/Index.d.ts +0 -9
- package/bin/task/Index.d.ts.map +0 -1
- package/bin/task/Index.js +0 -9
- package/bin/task/Index.js.map +0 -1
- package/src/chat/Index.ts +0 -36
- package/src/chat/config/ChatPluginConfig.ts +0 -266
- package/src/chat/types/ChatPluginResource.ts +0 -95
- package/src/contact/Index.ts +0 -8
- package/src/memory/Index.ts +0 -14
- package/src/skill/Command.ts +0 -58
- package/src/task/Index.ts +0 -8
package/src/image/ImagePlugin.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 对 Agent 暴露 `image_create` / `image_result` 两步式任务 action。
|
|
6
|
-
* -
|
|
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 函数返回的
|
|
401
|
+
* 校验 image 函数返回的 Downcity Session 消息。
|
|
390
402
|
*
|
|
391
|
-
* 本函数只校验 provider / City 返回的
|
|
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
|
|
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(
|
|
612
|
-
|
|
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
|
-
|
|
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
|
|
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,
|
|
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:
|
|
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 返回的远程图片先落到当前
|
|
6
|
-
* - File Part 的 `url`
|
|
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
|
-
/** 下载一张远程图片并返回
|
|
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:
|
|
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 =
|
|
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.
|
|
148
|
-
if (!(await input.context.
|
|
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.
|
|
151
|
-
await input.context.
|
|
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
|
|
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(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
* - 图片成功结果使用
|
|
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 =
|
|
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
|
|
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 路径的
|
|
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
|
-
/** 成功时返回的
|
|
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
|
|
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
|
-
/**
|
|
295
|
-
default_model?:
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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(
|
|
113
|
+
constructor(profile: MemoryPluginOptions = {}) {
|
|
110
114
|
super();
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
|
390
|
-
export interface
|
|
391
|
-
/**
|
|
392
|
-
provider
|
|
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
package/src/renderers.ts
ADDED
|
@@ -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
|
+
};
|