@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ChannelContextStore:渠道目标与 session_id 映射存储。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* -
|
|
5
|
+
* - 映射文件位于当前 Agent private runtime directory 数据目录的 `channel/meta.json`。
|
|
6
6
|
* - session_id 由服务端随机生成并持久化,不依赖字符串拼接规则。
|
|
7
7
|
* - 统一提供“按目标找 session_id / 按 session_id 找目标”能力。
|
|
8
8
|
*/
|
|
@@ -169,11 +169,11 @@ export async function readChannelSessionRouteBySessionId(params: {
|
|
|
169
169
|
context: PluginContext;
|
|
170
170
|
session_id: string;
|
|
171
171
|
}): Promise<ChannelContextRouteV1 | null> {
|
|
172
|
-
const rootPath = String(params.context.
|
|
172
|
+
const rootPath = String(params.context.data_path || "").trim();
|
|
173
173
|
const session_id = toOptionalTrimmedString(params.session_id);
|
|
174
174
|
if (!rootPath || !session_id) return null;
|
|
175
175
|
const file = await readMetaFile({
|
|
176
|
-
filePath: get_chat_channel_meta_path(params.context.
|
|
176
|
+
filePath: get_chat_channel_meta_path(params.context.data_path),
|
|
177
177
|
});
|
|
178
178
|
return normalizeRoute(file.routesBySessionId[session_id]);
|
|
179
179
|
}
|
|
@@ -182,7 +182,7 @@ export async function readChannelSessionRouteBySessionId(params: {
|
|
|
182
182
|
* 列出当前 agent 已记录的所有渠道路由条目。
|
|
183
183
|
*
|
|
184
184
|
* 关键点(中文)
|
|
185
|
-
* -
|
|
185
|
+
* - 数据源为当前 Agent private runtime directory 数据目录下 `channel/meta.json` 的 `routesBySessionId`。
|
|
186
186
|
* - 默认按 `updated_at` 倒序返回,便于展示“最近活跃”会话。
|
|
187
187
|
*/
|
|
188
188
|
export async function listChannelSessionRoutes(params: {
|
|
@@ -191,7 +191,7 @@ export async function listChannelSessionRoutes(params: {
|
|
|
191
191
|
updated_at: number;
|
|
192
192
|
routes: ChannelContextRouteV1[];
|
|
193
193
|
}> {
|
|
194
|
-
const rootPath = String(params.context.
|
|
194
|
+
const rootPath = String(params.context.data_path || "").trim();
|
|
195
195
|
if (!rootPath) {
|
|
196
196
|
return {
|
|
197
197
|
updated_at: Date.now(),
|
|
@@ -199,7 +199,7 @@ export async function listChannelSessionRoutes(params: {
|
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
201
|
const file = await readMetaFile({
|
|
202
|
-
filePath: get_chat_channel_meta_path(params.context.
|
|
202
|
+
filePath: get_chat_channel_meta_path(params.context.data_path),
|
|
203
203
|
});
|
|
204
204
|
const routes = Object.values(file.routesBySessionId)
|
|
205
205
|
.map((route) => normalizeRoute(route))
|
|
@@ -218,12 +218,12 @@ export async function resolveChannelSessionIdByTarget(params: {
|
|
|
218
218
|
context: PluginContext;
|
|
219
219
|
target: ChannelContextTarget;
|
|
220
220
|
}): Promise<string | null> {
|
|
221
|
-
const rootPath = String(params.context.
|
|
221
|
+
const rootPath = String(params.context.data_path || "").trim();
|
|
222
222
|
if (!rootPath) return null;
|
|
223
223
|
const targetKey = buildChannelTargetKey(params.target);
|
|
224
224
|
if (!targetKey) return null;
|
|
225
225
|
const file = await readMetaFile({
|
|
226
|
-
filePath: get_chat_channel_meta_path(params.context.
|
|
226
|
+
filePath: get_chat_channel_meta_path(params.context.data_path),
|
|
227
227
|
});
|
|
228
228
|
const session_id = toOptionalTrimmedString(file.sessionIdByTargetKey[targetKey]);
|
|
229
229
|
if (!session_id) return null;
|
|
@@ -237,7 +237,7 @@ export async function resolveOrCreateChannelSessionIdByTarget(params: {
|
|
|
237
237
|
context: PluginContext;
|
|
238
238
|
target: ChannelContextTarget;
|
|
239
239
|
}): Promise<string | null> {
|
|
240
|
-
const rootPath = String(params.context.
|
|
240
|
+
const rootPath = String(params.context.data_path || "").trim();
|
|
241
241
|
if (!rootPath) return null;
|
|
242
242
|
const normalizedTarget = normalizeTarget(params.target);
|
|
243
243
|
if (!normalizedTarget) return null;
|
|
@@ -245,7 +245,7 @@ export async function resolveOrCreateChannelSessionIdByTarget(params: {
|
|
|
245
245
|
if (!targetKey) return null;
|
|
246
246
|
|
|
247
247
|
const file = await readMetaFile({
|
|
248
|
-
filePath: get_chat_channel_meta_path(params.context.
|
|
248
|
+
filePath: get_chat_channel_meta_path(params.context.data_path),
|
|
249
249
|
});
|
|
250
250
|
const existingSessionId = toOptionalTrimmedString(file.sessionIdByTargetKey[targetKey]);
|
|
251
251
|
if (
|
|
@@ -271,8 +271,8 @@ export async function resolveOrCreateChannelSessionIdByTarget(params: {
|
|
|
271
271
|
};
|
|
272
272
|
file.updated_at = Date.now();
|
|
273
273
|
await writeMetaFile({
|
|
274
|
-
dirPath: get_chat_channel_dir_path(params.context.
|
|
275
|
-
filePath: get_chat_channel_meta_path(params.context.
|
|
274
|
+
dirPath: get_chat_channel_dir_path(params.context.data_path),
|
|
275
|
+
filePath: get_chat_channel_meta_path(params.context.data_path),
|
|
276
276
|
file,
|
|
277
277
|
});
|
|
278
278
|
return nextSessionId;
|
|
@@ -290,7 +290,7 @@ export async function upsertChannelSessionRouteBySessionId(params: {
|
|
|
290
290
|
actorName?: string;
|
|
291
291
|
chatTitle?: string;
|
|
292
292
|
}): Promise<void> {
|
|
293
|
-
const rootPath = String(params.context.
|
|
293
|
+
const rootPath = String(params.context.data_path || "").trim();
|
|
294
294
|
const session_id = toOptionalTrimmedString(params.session_id);
|
|
295
295
|
const normalizedTarget = normalizeTarget(params.target);
|
|
296
296
|
if (!rootPath || !session_id || !normalizedTarget) return;
|
|
@@ -298,7 +298,7 @@ export async function upsertChannelSessionRouteBySessionId(params: {
|
|
|
298
298
|
if (!targetKey) return;
|
|
299
299
|
|
|
300
300
|
const file = await readMetaFile({
|
|
301
|
-
filePath: get_chat_channel_meta_path(params.context.
|
|
301
|
+
filePath: get_chat_channel_meta_path(params.context.data_path),
|
|
302
302
|
});
|
|
303
303
|
const prev = normalizeRoute(file.routesBySessionId[session_id]);
|
|
304
304
|
const nextRoute: ChannelContextRouteV1 = {
|
|
@@ -337,8 +337,8 @@ export async function upsertChannelSessionRouteBySessionId(params: {
|
|
|
337
337
|
file.sessionIdByTargetKey[targetKey] = session_id;
|
|
338
338
|
file.updated_at = Date.now();
|
|
339
339
|
await writeMetaFile({
|
|
340
|
-
dirPath: get_chat_channel_dir_path(params.context.
|
|
341
|
-
filePath: get_chat_channel_meta_path(params.context.
|
|
340
|
+
dirPath: get_chat_channel_dir_path(params.context.data_path),
|
|
341
|
+
filePath: get_chat_channel_meta_path(params.context.data_path),
|
|
342
342
|
file,
|
|
343
343
|
});
|
|
344
344
|
}
|
|
@@ -357,7 +357,7 @@ export async function removeChannelSessionRouteBySessionId(params: {
|
|
|
357
357
|
removed: boolean;
|
|
358
358
|
route: ChannelContextRouteV1 | null;
|
|
359
359
|
}> {
|
|
360
|
-
const rootPath = String(params.context.
|
|
360
|
+
const rootPath = String(params.context.data_path || "").trim();
|
|
361
361
|
const session_id = toOptionalTrimmedString(params.session_id);
|
|
362
362
|
if (!rootPath || !session_id) {
|
|
363
363
|
return {
|
|
@@ -367,7 +367,7 @@ export async function removeChannelSessionRouteBySessionId(params: {
|
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
const file = await readMetaFile({
|
|
370
|
-
filePath: get_chat_channel_meta_path(params.context.
|
|
370
|
+
filePath: get_chat_channel_meta_path(params.context.data_path),
|
|
371
371
|
});
|
|
372
372
|
const route = normalizeRoute(file.routesBySessionId[session_id]);
|
|
373
373
|
if (!route) {
|
|
@@ -388,8 +388,8 @@ export async function removeChannelSessionRouteBySessionId(params: {
|
|
|
388
388
|
|
|
389
389
|
file.updated_at = Date.now();
|
|
390
390
|
await writeMetaFile({
|
|
391
|
-
dirPath: get_chat_channel_dir_path(params.context.
|
|
392
|
-
filePath: get_chat_channel_meta_path(params.context.
|
|
391
|
+
dirPath: get_chat_channel_dir_path(params.context.data_path),
|
|
392
|
+
filePath: get_chat_channel_meta_path(params.context.data_path),
|
|
393
393
|
file,
|
|
394
394
|
});
|
|
395
395
|
return {
|
|
@@ -55,7 +55,7 @@ export async function execute_chat_history_clear_action(params: {
|
|
|
55
55
|
error: "Missing session_id",
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
const cleared = await clear_chat_history(params.context.
|
|
58
|
+
const cleared = await clear_chat_history(params.context.data_path, session_id);
|
|
59
59
|
return {
|
|
60
60
|
success: true,
|
|
61
61
|
data: {
|
|
@@ -193,16 +193,16 @@ export async function executeChatInfoAction(params: {
|
|
|
193
193
|
});
|
|
194
194
|
|
|
195
195
|
const toPosixRelativePath = (absPath: string): string =>
|
|
196
|
-
path.relative(params.context.
|
|
196
|
+
path.relative(params.context.data_path, absPath).split(path.sep).join("/");
|
|
197
197
|
|
|
198
198
|
const channelMetaPath = toPosixRelativePath(
|
|
199
|
-
get_chat_channel_meta_path(params.context.
|
|
199
|
+
get_chat_channel_meta_path(params.context.data_path),
|
|
200
200
|
);
|
|
201
201
|
const chatDirPath = toPosixRelativePath(
|
|
202
|
-
get_chat_session_dir_path(params.context.
|
|
202
|
+
get_chat_session_dir_path(params.context.data_path, session_id),
|
|
203
203
|
);
|
|
204
204
|
const historyPath = toPosixRelativePath(
|
|
205
|
-
get_chat_history_path(params.context.
|
|
205
|
+
get_chat_history_path(params.context.data_path, session_id),
|
|
206
206
|
);
|
|
207
207
|
|
|
208
208
|
return {
|
|
@@ -259,7 +259,7 @@ export async function executeChatHistoryAction(params: {
|
|
|
259
259
|
afterTs: payload.afterTs,
|
|
260
260
|
});
|
|
261
261
|
const historyPath = historyResult.historyPath
|
|
262
|
-
.replace(`${params.context.
|
|
262
|
+
.replace(`${params.context.data_path}/`, "")
|
|
263
263
|
.split("\\")
|
|
264
264
|
.join("/");
|
|
265
265
|
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* - Plugin 只读取宿主构造时传入的 channel 配置,不负责修改或持久化。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { JsonObject } from "@downcity/agent";
|
|
10
9
|
import type { PluginContext } from "@downcity/agent";
|
|
11
10
|
import type { ChatRuntimeAccount } from "@/chat/types/ChatRuntimeAccount.js";
|
|
12
11
|
import type {
|
|
@@ -14,7 +13,6 @@ import type {
|
|
|
14
13
|
ChatChannelStateSnapshot,
|
|
15
14
|
} from "@/chat/types/ChannelStatus.js";
|
|
16
15
|
import type { ChatChannelState } from "@/chat/types/ChatRuntime.js";
|
|
17
|
-
import { get_chat_plugin_resource_json_schema } from "@/chat/config/ChatPluginConfig.js";
|
|
18
16
|
import {
|
|
19
17
|
getChatChannelBot,
|
|
20
18
|
isChatChannelEnabled,
|
|
@@ -23,10 +21,6 @@ import {
|
|
|
23
21
|
resolveChannelAccountId,
|
|
24
22
|
} from "./ChatChannelCore.js";
|
|
25
23
|
|
|
26
|
-
function toJsonObject(input: unknown): JsonObject {
|
|
27
|
-
return JSON.parse(JSON.stringify(input)) as JsonObject;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
24
|
/**
|
|
31
25
|
* 生成可安全暴露给 UI 的渠道配置摘要。
|
|
32
26
|
*
|
|
@@ -40,26 +34,26 @@ export function buildChatChannelConfigSummary(
|
|
|
40
34
|
accountInput?: ChatRuntimeAccount | null,
|
|
41
35
|
): Record<string, string | number | boolean | null> {
|
|
42
36
|
const account = accountInput ?? resolveChannelAccount(context, channel);
|
|
43
|
-
const
|
|
37
|
+
const channel_id = resolveChannelAccountId(context, channel);
|
|
44
38
|
const configured = isChannelAccountConfigured(channel, account);
|
|
45
39
|
if (channel === "telegram") {
|
|
46
40
|
return {
|
|
47
41
|
enabled: isChatChannelEnabled(context, channel),
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
channel_id: channel_id || null,
|
|
43
|
+
channel_configured: configured,
|
|
50
44
|
};
|
|
51
45
|
}
|
|
52
46
|
if (channel === "feishu") {
|
|
53
47
|
return {
|
|
54
48
|
enabled: isChatChannelEnabled(context, channel),
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
channel_id: channel_id || null,
|
|
50
|
+
channel_configured: configured,
|
|
57
51
|
};
|
|
58
52
|
}
|
|
59
53
|
return {
|
|
60
54
|
enabled: isChatChannelEnabled(context, channel),
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
channel_id: channel_id || null,
|
|
56
|
+
channel_configured: configured,
|
|
63
57
|
};
|
|
64
58
|
}
|
|
65
59
|
|
|
@@ -97,7 +91,6 @@ export function getChatChannelStatus(
|
|
|
97
91
|
detail: {
|
|
98
92
|
...(runtime?.detail || {}),
|
|
99
93
|
config: buildChatChannelConfigSummary(context, channel, channelAccount),
|
|
100
|
-
resource_schema: toJsonObject(get_chat_plugin_resource_json_schema(channel)),
|
|
101
94
|
},
|
|
102
95
|
};
|
|
103
96
|
}
|
|
@@ -14,8 +14,8 @@ import type { ChatChannelState } from "@/chat/types/ChatRuntime.js";
|
|
|
14
14
|
|
|
15
15
|
const CHAT_CHANNEL_NAMES: ChatChannelName[] = ["telegram", "feishu", "qq"];
|
|
16
16
|
|
|
17
|
-
export type
|
|
18
|
-
|
|
17
|
+
export type ChatPluginRuntimeApi = {
|
|
18
|
+
get_channel_id?(context: PluginContext, channel: ChatChannelName): string;
|
|
19
19
|
resolveChannelAccount?(
|
|
20
20
|
context: PluginContext,
|
|
21
21
|
channel: ChatChannelName,
|
|
@@ -23,11 +23,11 @@ export type ChatRuntimeBindings = {
|
|
|
23
23
|
isChannelEnabled?(context: PluginContext, channel: ChatChannelName): boolean;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export function
|
|
26
|
+
export function resolveChatPluginRuntimeApi(
|
|
27
27
|
context: PluginContext,
|
|
28
|
-
):
|
|
28
|
+
): ChatPluginRuntimeApi | null {
|
|
29
29
|
const candidate = context.plugins.get("chat") as
|
|
30
|
-
|
|
|
30
|
+
| ChatPluginRuntimeApi
|
|
31
31
|
| undefined;
|
|
32
32
|
return candidate || null;
|
|
33
33
|
}
|
|
@@ -74,8 +74,8 @@ export function resolveChannelAccountId(
|
|
|
74
74
|
context: PluginContext,
|
|
75
75
|
channel: ChatChannelName,
|
|
76
76
|
): string {
|
|
77
|
-
const plugin =
|
|
78
|
-
const explicit = String(plugin?.
|
|
77
|
+
const plugin = resolveChatPluginRuntimeApi(context);
|
|
78
|
+
const explicit = String(plugin?.get_channel_id?.(context, channel) || "").trim();
|
|
79
79
|
if (explicit) return explicit;
|
|
80
80
|
return "";
|
|
81
81
|
}
|
|
@@ -91,7 +91,7 @@ export function resolveChannelAccount(
|
|
|
91
91
|
context: PluginContext,
|
|
92
92
|
channel: ChatChannelName,
|
|
93
93
|
): ChatRuntimeAccount | null {
|
|
94
|
-
const plugin =
|
|
94
|
+
const plugin = resolveChatPluginRuntimeApi(context);
|
|
95
95
|
const explicit = plugin?.resolveChannelAccount?.(context, channel);
|
|
96
96
|
return explicit?.channel === channel ? explicit : null;
|
|
97
97
|
}
|
|
@@ -117,7 +117,7 @@ export function isChatChannelEnabled(
|
|
|
117
117
|
context: PluginContext,
|
|
118
118
|
channel: ChatChannelName,
|
|
119
119
|
): boolean {
|
|
120
|
-
const plugin =
|
|
120
|
+
const plugin = resolveChatPluginRuntimeApi(context);
|
|
121
121
|
if (typeof plugin?.isChannelEnabled === "function") {
|
|
122
122
|
return plugin.isChannelEnabled(context, channel);
|
|
123
123
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ChatHistoryStore:聊天事件流持久化。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* - 写入
|
|
5
|
+
* - 写入 Agent private runtime directory 数据目录的 `chat/<session_id>/history.jsonl`(append-only)。
|
|
6
6
|
* - 记录 inbound(audit/exec)与 outbound 事件。
|
|
7
7
|
* - 与 session message history 分离,避免审计噪声进入模型上下文。
|
|
8
8
|
*/
|
|
@@ -145,7 +145,7 @@ export async function appendInboundChatHistory(params: {
|
|
|
145
145
|
actorName?: string;
|
|
146
146
|
extra?: JsonObject;
|
|
147
147
|
}): Promise<void> {
|
|
148
|
-
const rootPath = normalizeTrimmedString(params.context.
|
|
148
|
+
const rootPath = normalizeTrimmedString(params.context.data_path);
|
|
149
149
|
const session_id = normalizeTrimmedString(params.session_id);
|
|
150
150
|
const chatId = normalizeTrimmedString(params.chatId);
|
|
151
151
|
if (!rootPath || !session_id || !chatId) return;
|
|
@@ -164,7 +164,7 @@ export async function appendInboundChatHistory(params: {
|
|
|
164
164
|
extra: toOptionalObject(params.extra),
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
-
const file = get_chat_history_path(params.context.
|
|
167
|
+
const file = get_chat_history_path(params.context.data_path, session_id);
|
|
168
168
|
await fs.ensureDir(path.dirname(file));
|
|
169
169
|
await fs.appendFile(file, JSON.stringify(event) + "\n", "utf8");
|
|
170
170
|
}
|
|
@@ -189,7 +189,7 @@ export async function appendOutboundChatHistory(params: {
|
|
|
189
189
|
actorName?: string;
|
|
190
190
|
extra?: JsonObject;
|
|
191
191
|
}): Promise<void> {
|
|
192
|
-
const rootPath = normalizeTrimmedString(params.context.
|
|
192
|
+
const rootPath = normalizeTrimmedString(params.context.data_path);
|
|
193
193
|
const session_id = normalizeTrimmedString(params.session_id);
|
|
194
194
|
const chatId = normalizeTrimmedString(params.chatId);
|
|
195
195
|
if (!rootPath || !session_id || !chatId) return;
|
|
@@ -207,7 +207,7 @@ export async function appendOutboundChatHistory(params: {
|
|
|
207
207
|
extra: toOptionalObject(params.extra),
|
|
208
208
|
});
|
|
209
209
|
|
|
210
|
-
const file = get_chat_history_path(params.context.
|
|
210
|
+
const file = get_chat_history_path(params.context.data_path, session_id);
|
|
211
211
|
await fs.ensureDir(path.dirname(file));
|
|
212
212
|
await fs.appendFile(file, JSON.stringify(event) + "\n", "utf8");
|
|
213
213
|
}
|
|
@@ -227,9 +227,9 @@ export async function readChatHistory(params: {
|
|
|
227
227
|
beforeTs?: number;
|
|
228
228
|
afterTs?: number;
|
|
229
229
|
}): Promise<{ historyPath: string; events: ChatHistoryEventV1[] }> {
|
|
230
|
-
const rootPath = normalizeTrimmedString(params.context.
|
|
230
|
+
const rootPath = normalizeTrimmedString(params.context.data_path);
|
|
231
231
|
const session_id = normalizeTrimmedString(params.session_id);
|
|
232
|
-
const historyPath = get_chat_history_path(params.context.
|
|
232
|
+
const historyPath = get_chat_history_path(params.context.data_path, session_id);
|
|
233
233
|
if (!rootPath || !session_id) {
|
|
234
234
|
return {
|
|
235
235
|
historyPath,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 入站消息到达时由 chat plugin runtime 写入
|
|
6
6
|
* - 出站按 session_id/chat_key 发送时由 chat plugin runtime 读取
|
|
7
|
-
* - 底层数据落在
|
|
7
|
+
* - 底层数据落在 Agent private runtime directory 数据目录的 `channel/meta.json`,由 ChannelContextStore 统一维护
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { PluginContext } from "@downcity/agent";
|
|
@@ -87,7 +87,7 @@ function attachCommandHelpText(command: Command, text: string): void {
|
|
|
87
87
|
* 创建 chat plugin runtime 的 action 定义表。
|
|
88
88
|
*/
|
|
89
89
|
export function createChatPluginActions(params: {
|
|
90
|
-
|
|
90
|
+
resolve_channel_state: (context: import("@downcity/agent").PluginContext) => ChatChannelState;
|
|
91
91
|
}): PluginActions {
|
|
92
92
|
return {
|
|
93
93
|
status: create_action({
|
|
@@ -105,7 +105,7 @@ export function createChatPluginActions(params: {
|
|
|
105
105
|
},
|
|
106
106
|
execute: async (actionParams) => {
|
|
107
107
|
return executeChatStatusAction({
|
|
108
|
-
state: params.
|
|
108
|
+
state: params.resolve_channel_state(actionParams.context),
|
|
109
109
|
context: actionParams.context,
|
|
110
110
|
payload: actionParams.input as ChatStatusActionPayload,
|
|
111
111
|
});
|
|
@@ -126,7 +126,7 @@ export function createChatPluginActions(params: {
|
|
|
126
126
|
},
|
|
127
127
|
execute: async (actionParams) => {
|
|
128
128
|
return executeChatTestAction({
|
|
129
|
-
state: params.
|
|
129
|
+
state: params.resolve_channel_state(actionParams.context),
|
|
130
130
|
context: actionParams.context,
|
|
131
131
|
payload: actionParams.input as ChatTestActionPayload,
|
|
132
132
|
});
|
|
@@ -147,7 +147,7 @@ export function createChatPluginActions(params: {
|
|
|
147
147
|
},
|
|
148
148
|
execute: async (actionParams) => {
|
|
149
149
|
return executeChatReconnectAction({
|
|
150
|
-
state: params.
|
|
150
|
+
state: params.resolve_channel_state(actionParams.context),
|
|
151
151
|
context: actionParams.context,
|
|
152
152
|
payload: actionParams.input as ChatReconnectActionPayload,
|
|
153
153
|
});
|
|
@@ -195,7 +195,7 @@ export function createChatPluginActions(params: {
|
|
|
195
195
|
return executeChatInfoAction({
|
|
196
196
|
context: actionParams.context,
|
|
197
197
|
payload: actionParams.input as ChatInfoActionPayload,
|
|
198
|
-
execution_context: actionParams.
|
|
198
|
+
execution_context: actionParams.execution.snapshot,
|
|
199
199
|
});
|
|
200
200
|
},
|
|
201
201
|
}),
|
|
@@ -226,7 +226,7 @@ export function createChatPluginActions(params: {
|
|
|
226
226
|
return executeChatSendAction({
|
|
227
227
|
context: actionParams.context,
|
|
228
228
|
payload: actionParams.input as ChatSendActionPayload,
|
|
229
|
-
execution_context: actionParams.
|
|
229
|
+
execution_context: actionParams.execution.snapshot,
|
|
230
230
|
});
|
|
231
231
|
},
|
|
232
232
|
}),
|
|
@@ -255,7 +255,7 @@ export function createChatPluginActions(params: {
|
|
|
255
255
|
return executeChatReactAction({
|
|
256
256
|
context: actionParams.context,
|
|
257
257
|
payload: actionParams.input as ChatReactActionPayload,
|
|
258
|
-
execution_context: actionParams.
|
|
258
|
+
execution_context: actionParams.execution.snapshot,
|
|
259
259
|
});
|
|
260
260
|
},
|
|
261
261
|
}),
|
|
@@ -282,7 +282,7 @@ export function createChatPluginActions(params: {
|
|
|
282
282
|
return executeChatContextAction({
|
|
283
283
|
context: actionParams.context,
|
|
284
284
|
payload: actionParams.input as ChatSessionActionPayload,
|
|
285
|
-
execution_context: actionParams.
|
|
285
|
+
execution_context: actionParams.execution.snapshot,
|
|
286
286
|
});
|
|
287
287
|
},
|
|
288
288
|
}),
|
|
@@ -305,7 +305,7 @@ export function createChatPluginActions(params: {
|
|
|
305
305
|
return executeChatDeleteAction({
|
|
306
306
|
context: actionParams.context,
|
|
307
307
|
payload: actionParams.input as ChatDeleteActionPayload,
|
|
308
|
-
execution_context: actionParams.
|
|
308
|
+
execution_context: actionParams.execution.snapshot,
|
|
309
309
|
});
|
|
310
310
|
},
|
|
311
311
|
}),
|
|
@@ -335,7 +335,7 @@ export function createChatPluginActions(params: {
|
|
|
335
335
|
return executeChatHistoryAction({
|
|
336
336
|
context: actionParams.context,
|
|
337
337
|
payload: actionParams.input as ChatHistoryActionPayload,
|
|
338
|
-
execution_context: actionParams.
|
|
338
|
+
execution_context: actionParams.execution.snapshot,
|
|
339
339
|
});
|
|
340
340
|
},
|
|
341
341
|
}),
|
|
@@ -1,77 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ChatQueue 共享门面。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 迁移阶段保留旧函数式 API,内部委托给共享 `ChatQueueStore`。
|
|
6
|
-
* - 新代码应优先通过 `ChatQueueStore` 实例或 `resolveChatQueueStore(runtime)` 使用队列。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type {
|
|
10
|
-
ChatQueueEnqueueParams,
|
|
11
|
-
ChatQueueEnqueueResult,
|
|
12
|
-
ChatQueueItem,
|
|
13
|
-
} from "@/chat/types/ChatQueue.js";
|
|
1
|
+
/** Chat Queue 对外类型与显式运行时解析入口。 */
|
|
14
2
|
import {
|
|
15
3
|
ChatQueueStore,
|
|
16
|
-
getSharedChatQueueStore,
|
|
17
4
|
resolveChatQueueStore,
|
|
18
5
|
type ChatQueueEnqueueListener,
|
|
19
6
|
type ChatQueueStorePort,
|
|
20
7
|
} from "./ChatQueueStore.js";
|
|
21
8
|
|
|
22
|
-
export { ChatQueueStore,
|
|
9
|
+
export { ChatQueueStore, resolveChatQueueStore };
|
|
23
10
|
export type { ChatQueueEnqueueListener, ChatQueueStorePort };
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 订阅共享 queue 的入队事件。
|
|
27
|
-
*/
|
|
28
|
-
export function onChatQueueEnqueue(listener: ChatQueueEnqueueListener): () => void {
|
|
29
|
-
return getSharedChatQueueStore().onEnqueue(listener);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 向共享 queue 入队。
|
|
34
|
-
*/
|
|
35
|
-
export function enqueueChatQueue(
|
|
36
|
-
params: ChatQueueEnqueueParams,
|
|
37
|
-
): ChatQueueEnqueueResult {
|
|
38
|
-
return getSharedChatQueueStore().enqueue(params);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 从共享 queue 弹出一条消息。
|
|
43
|
-
*/
|
|
44
|
-
export function shiftChatQueueItem(laneKey: string): ChatQueueItem | null {
|
|
45
|
-
return getSharedChatQueueStore().shift(laneKey);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 从共享 queue drain 某个 lane。
|
|
50
|
-
*/
|
|
51
|
-
export function drainChatQueueLane(
|
|
52
|
-
laneKey: string,
|
|
53
|
-
maxItems?: number,
|
|
54
|
-
): ChatQueueItem[] {
|
|
55
|
-
return getSharedChatQueueStore().drain(laneKey, maxItems);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 列出共享 queue 当前积压的 lane keys。
|
|
60
|
-
*/
|
|
61
|
-
export function listChatQueueLanes(): string[] {
|
|
62
|
-
return getSharedChatQueueStore().listLanes();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 查询共享 queue 某个 lane 的长度。
|
|
67
|
-
*/
|
|
68
|
-
export function getChatQueueLaneSize(laneKey: string): number {
|
|
69
|
-
return getSharedChatQueueStore().getLaneSize(laneKey);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 清空共享 queue 某个 lane。
|
|
74
|
-
*/
|
|
75
|
-
export function clearChatQueueLane(laneKey: string): void {
|
|
76
|
-
getSharedChatQueueStore().clear(laneKey);
|
|
77
|
-
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 这是 chat queue 的实例级状态容器。
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
6
|
+
* - `ChatPlugin` 为每个 Workspace Context 持有独立 queue store。
|
|
7
|
+
* - 队列必须通过显式 Context 解析,不允许模块级共享状态。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { PluginContext } from "@downcity/agent";
|
|
@@ -53,13 +53,6 @@ export interface ChatQueueStorePort {
|
|
|
53
53
|
clear(laneKey: string): void;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
/**
|
|
57
|
-
* 共享 queue store。
|
|
58
|
-
*
|
|
59
|
-
* 关键点(中文)
|
|
60
|
-
* - 迁移阶段仍保留一份共享实例,避免一次性改动所有旧入口。
|
|
61
|
-
* - 新代码应优先通过 `PluginContext.agent` 解析显式 queue store。
|
|
62
|
-
*/
|
|
63
56
|
/**
|
|
64
57
|
* Chat queue 实例级存储。
|
|
65
58
|
*/
|
|
@@ -158,28 +151,19 @@ export class ChatQueueStore implements ChatQueueStorePort {
|
|
|
158
151
|
}
|
|
159
152
|
}
|
|
160
153
|
|
|
161
|
-
const sharedChatQueueStore = new ChatQueueStore();
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* 读取共享 chat queue store。
|
|
165
|
-
*/
|
|
166
|
-
export function getSharedChatQueueStore(): ChatQueueStore {
|
|
167
|
-
return sharedChatQueueStore;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
154
|
/**
|
|
171
155
|
* 从运行时解析 chat queue store。
|
|
172
156
|
*
|
|
173
157
|
* 关键点(中文)
|
|
174
|
-
* -
|
|
175
|
-
* -
|
|
158
|
+
* - 只读取当前 Agent 注册的 ChatPlugin 实例。
|
|
159
|
+
* - 缺少 Context 或对应 Workspace runtime 时立即失败,避免跨 Agent/Workspace 串队列。
|
|
176
160
|
*/
|
|
177
|
-
export function resolveChatQueueStore(context
|
|
178
|
-
const chatService = context
|
|
179
|
-
| {
|
|
161
|
+
export function resolveChatQueueStore(context: PluginContext): ChatQueueStorePort {
|
|
162
|
+
const chatService = context.plugins.get("chat") as
|
|
163
|
+
| { queue_store?: (context: PluginContext) => ChatQueueStorePort }
|
|
180
164
|
| undefined;
|
|
181
|
-
if (chatService?.
|
|
182
|
-
|
|
165
|
+
if (!chatService?.queue_store) {
|
|
166
|
+
throw new Error("Chat queue requires an active ChatPlugin for the current Workspace");
|
|
183
167
|
}
|
|
184
|
-
return
|
|
168
|
+
return chatService.queue_store(context);
|
|
185
169
|
}
|
|
@@ -13,9 +13,6 @@ import type { ChatQueueWorkerConfig } from "@/chat/types/ChatQueueWorker.js";
|
|
|
13
13
|
import type { ChatQueueItem } from "@/chat/types/ChatQueue.js";
|
|
14
14
|
import type { SessionMutation } from "@downcity/agent";
|
|
15
15
|
import type { AgentSessionTurnResult } from "@downcity/agent";
|
|
16
|
-
import {
|
|
17
|
-
getSharedChatQueueStore,
|
|
18
|
-
} from "./ChatQueue.js";
|
|
19
16
|
import { getChatSender } from "./ChatSendRegistry.js";
|
|
20
17
|
import {
|
|
21
18
|
buildChannelErrorText,
|
|
@@ -61,13 +58,13 @@ export class ChatQueueWorker {
|
|
|
61
58
|
constructor(params: {
|
|
62
59
|
logger: Logger;
|
|
63
60
|
context: PluginContext;
|
|
64
|
-
queueStore
|
|
61
|
+
queueStore: ChatQueueStorePort;
|
|
65
62
|
config?: Partial<ChatQueueWorkerConfig>;
|
|
66
63
|
}) {
|
|
67
64
|
this.logger = params.logger;
|
|
68
65
|
this.context = params.context;
|
|
69
66
|
this.config = normalizeChatQueueWorkerConfig(params.config);
|
|
70
|
-
this.queueStore = params.queueStore
|
|
67
|
+
this.queueStore = params.queueStore;
|
|
71
68
|
}
|
|
72
69
|
|
|
73
70
|
/**
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* ChatSessionDelete:按 session_id 彻底删除 chat 会话数据。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* -
|
|
6
|
-
* - 删除 chat
|
|
7
|
-
* - 删除 core session
|
|
5
|
+
* - 删除路由映射(Agent private runtime directory 数据目录的 `channel/meta.json`)
|
|
6
|
+
* - 删除 chat 审计目录(Agent private runtime directory 数据目录的 `chat/<session_id>/`)
|
|
7
|
+
* - 删除 core session 目录(Agent private runtime directory 数据目录的 `sessions/<session_id>/`)
|
|
8
8
|
* - 清理运行中 agent 与队列,避免残留任务继续执行
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -52,7 +52,7 @@ export async function deleteChatSessionById(params: {
|
|
|
52
52
|
resolveChatQueueStore(params.context).clear(session_id);
|
|
53
53
|
|
|
54
54
|
const chat_result = await clean_chat_storage({
|
|
55
|
-
|
|
55
|
+
data_path: params.context.data_path,
|
|
56
56
|
session_id: session_id,
|
|
57
57
|
});
|
|
58
58
|
const removed_session_dir = await params.context.sessions.remove(session_id);
|