@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/task/TaskPlugin.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { BasePlugin, create_action } from "@downcity/agent";
|
|
11
|
+
import type { AgentPluginContext } from "@downcity/agent";
|
|
11
12
|
import type { PluginActions } from "@downcity/agent";
|
|
12
13
|
import type { PluginContext } from "@downcity/agent";
|
|
13
14
|
import type {
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
} from "@/task/runtime/TaskActionExecution.js";
|
|
26
27
|
import { TASK_PLUGIN_PROMPT } from "@/task/runtime/TaskPluginSystem.js";
|
|
27
28
|
import { resolve_runtime_timezone } from "@downcity/agent";
|
|
29
|
+
import type { TaskWorkspaceRuntime } from "@/task/types/TaskWorkspaceRuntime.js";
|
|
28
30
|
|
|
29
31
|
const TASK_LOG_PREFIX = "[TASK]";
|
|
30
32
|
|
|
@@ -44,7 +46,10 @@ export class TaskPlugin extends BasePlugin {
|
|
|
44
46
|
/**
|
|
45
47
|
* task plugin 的 system 文本提供器。
|
|
46
48
|
*/
|
|
47
|
-
readonly system = (): string =>
|
|
49
|
+
readonly system = async (context: PluginContext): Promise<string> => {
|
|
50
|
+
await this.start_cron_runtime(context);
|
|
51
|
+
return TASK_PLUGIN_PROMPT;
|
|
52
|
+
};
|
|
48
53
|
|
|
49
54
|
/**
|
|
50
55
|
* task plugin 的 action 定义表。
|
|
@@ -63,16 +68,10 @@ export class TaskPlugin extends BasePlugin {
|
|
|
63
68
|
* - 这是 per-plugin-instance 的长期运行态。
|
|
64
69
|
* - 不再复用 module-global 单例。
|
|
65
70
|
*/
|
|
66
|
-
|
|
71
|
+
private readonly runtimes_by_workspace = new Map<string, TaskWorkspaceRuntime>();
|
|
67
72
|
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
*
|
|
71
|
-
* 关键点(中文)
|
|
72
|
-
* - scheduler reload 会替换 cron engine。
|
|
73
|
-
* - 锁必须挂在 plugin 实例上,避免 reload 后同一 task 被新旧调度器并发触发。
|
|
74
|
-
*/
|
|
75
|
-
private readonly runningTaskIds = new Set<string>();
|
|
73
|
+
/** 各 Workspace 当前唯一的 cron 启动流程。 */
|
|
74
|
+
private readonly starts_by_workspace = new Map<string, Promise<TaskCronRegisterResult | null>>();
|
|
76
75
|
|
|
77
76
|
constructor(options?: TaskPluginOptions) {
|
|
78
77
|
super();
|
|
@@ -86,7 +85,7 @@ export class TaskPlugin extends BasePlugin {
|
|
|
86
85
|
reload: create_action({
|
|
87
86
|
description: "Reload the task scheduler from persisted tasks.",
|
|
88
87
|
execute: async ({ context }) => {
|
|
89
|
-
const result = await this.
|
|
88
|
+
const result = await this.restart_cron_runtime(context);
|
|
90
89
|
context.logger.info(
|
|
91
90
|
formatTaskLogMessage(
|
|
92
91
|
`Task cron trigger reloaded (tasks=${result.tasksFound}, jobs=${result.jobsScheduled})`,
|
|
@@ -105,19 +104,13 @@ export class TaskPlugin extends BasePlugin {
|
|
|
105
104
|
};
|
|
106
105
|
|
|
107
106
|
this.lifecycle = {
|
|
108
|
-
start: async (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
);
|
|
116
|
-
},
|
|
117
|
-
stop: async (context) => {
|
|
118
|
-
const stopped = await this.stopCronRuntime();
|
|
119
|
-
if (!stopped) return;
|
|
120
|
-
context.logger.info(formatTaskLogMessage("Task cron trigger stopped"));
|
|
107
|
+
start: async (_context: AgentPluginContext) => {},
|
|
108
|
+
stop: async (_context: AgentPluginContext) => {
|
|
109
|
+
await Promise.allSettled([...this.starts_by_workspace.values()]);
|
|
110
|
+
await Promise.all([...this.runtimes_by_workspace.keys()].map(async (workspace_id) => {
|
|
111
|
+
await this.stop_cron_runtime(workspace_id);
|
|
112
|
+
}));
|
|
113
|
+
this.starts_by_workspace.clear();
|
|
121
114
|
},
|
|
122
115
|
};
|
|
123
116
|
}
|
|
@@ -125,42 +118,58 @@ export class TaskPlugin extends BasePlugin {
|
|
|
125
118
|
/**
|
|
126
119
|
* 启动当前实例的 cron runtime。
|
|
127
120
|
*/
|
|
128
|
-
async
|
|
121
|
+
async start_cron_runtime(
|
|
129
122
|
context: PluginContext,
|
|
130
123
|
): Promise<TaskCronRegisterResult | null> {
|
|
131
|
-
if (this.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
engine
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
124
|
+
if (this.runtimes_by_workspace.has(context.workspace_id)) return null;
|
|
125
|
+
const started = this.starts_by_workspace.get(context.workspace_id);
|
|
126
|
+
if (started) return await started;
|
|
127
|
+
|
|
128
|
+
const start_promise = (async () => {
|
|
129
|
+
const engine = new TaskCronTriggerEngine();
|
|
130
|
+
const running_task_ids = new Set<string>();
|
|
131
|
+
const register_result = await registerTaskCronJobs({
|
|
132
|
+
context,
|
|
133
|
+
engine,
|
|
134
|
+
timezone: this.resolveTimezone(),
|
|
135
|
+
runningTaskIds: running_task_ids,
|
|
136
|
+
});
|
|
137
|
+
await engine.start();
|
|
138
|
+
this.runtimes_by_workspace.set(context.workspace_id, {
|
|
139
|
+
cron_engine: engine,
|
|
140
|
+
running_task_ids,
|
|
141
|
+
});
|
|
142
|
+
return register_result;
|
|
143
|
+
})();
|
|
144
|
+
this.starts_by_workspace.set(context.workspace_id, start_promise);
|
|
145
|
+
try {
|
|
146
|
+
return await start_promise;
|
|
147
|
+
} finally {
|
|
148
|
+
if (this.starts_by_workspace.get(context.workspace_id) === start_promise) {
|
|
149
|
+
this.starts_by_workspace.delete(context.workspace_id);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
143
152
|
}
|
|
144
153
|
|
|
145
154
|
/**
|
|
146
155
|
* 停止当前实例的 cron runtime。
|
|
147
156
|
*/
|
|
148
|
-
async
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.
|
|
152
|
-
await
|
|
157
|
+
async stop_cron_runtime(workspace_id: string): Promise<boolean> {
|
|
158
|
+
const runtime = this.runtimes_by_workspace.get(workspace_id);
|
|
159
|
+
if (!runtime) return false;
|
|
160
|
+
this.runtimes_by_workspace.delete(workspace_id);
|
|
161
|
+
await runtime.cron_engine.stop();
|
|
153
162
|
return true;
|
|
154
163
|
}
|
|
155
164
|
|
|
156
165
|
/**
|
|
157
166
|
* 重启当前实例的 cron runtime。
|
|
158
167
|
*/
|
|
159
|
-
async
|
|
168
|
+
async restart_cron_runtime(
|
|
160
169
|
context: PluginContext,
|
|
161
170
|
): Promise<TaskCronRegisterResult> {
|
|
162
|
-
await this.
|
|
163
|
-
const started = await this.
|
|
171
|
+
await this.stop_cron_runtime(context.workspace_id);
|
|
172
|
+
const started = await this.start_cron_runtime(context);
|
|
164
173
|
return (
|
|
165
174
|
started || {
|
|
166
175
|
tasksFound: 0,
|
|
@@ -181,7 +190,7 @@ export class TaskPlugin extends BasePlugin {
|
|
|
181
190
|
context: params.context,
|
|
182
191
|
action: params.action,
|
|
183
192
|
title: params.title,
|
|
184
|
-
reloadScheduler: async (context) => this.
|
|
193
|
+
reloadScheduler: async (context) => this.restart_cron_runtime(context),
|
|
185
194
|
});
|
|
186
195
|
}
|
|
187
196
|
|
|
@@ -142,16 +142,6 @@ export function normalizeTaskWhen(
|
|
|
142
142
|
return { ok: true, value: canonical };
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
/**
|
|
146
|
-
* 兼容旧调用名:返回 cron 表达式或 `@manual`。
|
|
147
|
-
*/
|
|
148
|
-
export function normalizeTaskCronExpression(raw: string): string | null {
|
|
149
|
-
const when = normalizeTaskWhen(raw);
|
|
150
|
-
if (!when.ok) return null;
|
|
151
|
-
if (isTaskWhenOneShot(when.value)) return null;
|
|
152
|
-
return normalizeCronExpression(when.value);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
145
|
export function isTaskWhenManual(input: string): boolean {
|
|
156
146
|
const when = String(input || "").trim().toLowerCase();
|
|
157
147
|
return when === "@manual";
|
|
@@ -213,9 +203,9 @@ export function parseTaskMarkdown(params: {
|
|
|
213
203
|
taskId: string;
|
|
214
204
|
markdown: string;
|
|
215
205
|
taskMdPath: string;
|
|
216
|
-
|
|
206
|
+
data_path: string;
|
|
217
207
|
}): { ok: true; task: ShipTaskDefinitionV1 } | { ok: false; error: string } {
|
|
218
|
-
const { taskId, markdown, taskMdPath,
|
|
208
|
+
const { taskId, markdown, taskMdPath, data_path } = params;
|
|
219
209
|
const text = String(markdown ?? "");
|
|
220
210
|
const { frontMatterYaml, body } = parseFrontMatter(text);
|
|
221
211
|
|
|
@@ -293,7 +283,7 @@ export function parseTaskMarkdown(params: {
|
|
|
293
283
|
};
|
|
294
284
|
|
|
295
285
|
const relTaskMdPath = path
|
|
296
|
-
.relative(
|
|
286
|
+
.relative(data_path, taskMdPath)
|
|
297
287
|
.split(path.sep)
|
|
298
288
|
.join("/");
|
|
299
289
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Task System paths and identifiers.
|
|
3
3
|
*
|
|
4
4
|
* 约定(中文)
|
|
5
|
-
* - task root:
|
|
6
|
-
* - definition:
|
|
7
|
-
* - run dir:
|
|
5
|
+
* - task root: `<Agent data>/task/`
|
|
6
|
+
* - definition: `<Agent data>/task/<taskId>/task.md`
|
|
7
|
+
* - run dir: `<Agent data>/task/<taskId>/<timestamp>/`
|
|
8
8
|
*
|
|
9
9
|
* 同时定义“task run session_id”格式,用于把 Agent 的 session 映射到 run 目录:
|
|
10
10
|
* - `task-run:<taskId>:<timestamp>`
|
|
@@ -59,16 +59,16 @@ export function normalizeTaskId(input: string): string {
|
|
|
59
59
|
return id;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export function getTaskRootDir(
|
|
63
|
-
return path.join(String(
|
|
62
|
+
export function getTaskRootDir(data_path: string): string {
|
|
63
|
+
return path.join(String(data_path || "").trim(), "task");
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export function getTaskDir(
|
|
67
|
-
return path.join(getTaskRootDir(
|
|
66
|
+
export function getTaskDir(data_path: string, taskId: string): string {
|
|
67
|
+
return path.join(getTaskRootDir(data_path), normalizeTaskId(taskId));
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export function getTaskMdPath(
|
|
71
|
-
return path.join(getTaskDir(
|
|
70
|
+
export function getTaskMdPath(data_path: string, taskId: string): string {
|
|
71
|
+
return path.join(getTaskDir(data_path, taskId), "task.md");
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export function formatTaskRunTimestamp(date: Date = new Date()): string {
|
|
@@ -85,13 +85,13 @@ export function formatTaskRunTimestamp(date: Date = new Date()): string {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export function getTaskRunDir(
|
|
88
|
-
|
|
88
|
+
data_path: string,
|
|
89
89
|
taskId: string,
|
|
90
90
|
timestamp: string,
|
|
91
91
|
): string {
|
|
92
92
|
const ts = String(timestamp || "").trim();
|
|
93
93
|
if (!ts) throw new Error("timestamp is required");
|
|
94
|
-
return path.join(getTaskDir(
|
|
94
|
+
return path.join(getTaskDir(data_path, taskId), ts);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
export function createTaskRunSessionId(taskId: string, timestamp: string): string {
|
|
@@ -79,7 +79,7 @@ export async function runTaskNow(params: {
|
|
|
79
79
|
taskId: string;
|
|
80
80
|
trigger: ShipTaskRunTriggerV1;
|
|
81
81
|
executionId?: string;
|
|
82
|
-
|
|
82
|
+
data_path?: string;
|
|
83
83
|
/** 发起该任务的 Session step 已提交生效的 env 快照。 */
|
|
84
84
|
workspace_env?: Readonly<Record<string, string>>;
|
|
85
85
|
/** 发起该任务的 Session step 已提交生效的 instruction 快照。 */
|
|
@@ -102,19 +102,19 @@ export async function runTaskNow(params: {
|
|
|
102
102
|
runDirRel: string;
|
|
103
103
|
}> {
|
|
104
104
|
const context = params.context;
|
|
105
|
-
const root = String(params.
|
|
106
|
-
if (!root) throw new Error("
|
|
105
|
+
const root = String(params.data_path || context.data_path || "").trim();
|
|
106
|
+
if (!root) throw new Error("data_path is required");
|
|
107
107
|
|
|
108
108
|
const startedAt = Date.now();
|
|
109
109
|
const timestamp = formatTaskRunTimestamp(new Date(startedAt));
|
|
110
110
|
const executionId = String(params.executionId || `${params.taskId}:${timestamp}`).trim();
|
|
111
111
|
|
|
112
|
-
const task = await readTask({ taskId: params.taskId,
|
|
112
|
+
const task = await readTask({ taskId: params.taskId, data_path: root });
|
|
113
113
|
const runDirAbs = getTaskRunDir(root, task.taskId, timestamp);
|
|
114
114
|
const { runDirRel } = await ensureRunDir({
|
|
115
115
|
taskId: task.taskId,
|
|
116
116
|
timestamp,
|
|
117
|
-
|
|
117
|
+
data_path: root,
|
|
118
118
|
});
|
|
119
119
|
const filePaths = createTaskRunFilePaths(runDirAbs);
|
|
120
120
|
|
|
@@ -170,7 +170,6 @@ export async function runTaskNow(params: {
|
|
|
170
170
|
if (taskKind === "script") {
|
|
171
171
|
const scriptResult = await runScriptTaskBranch({
|
|
172
172
|
context,
|
|
173
|
-
runDirAbs,
|
|
174
173
|
session_id: task.frontmatter.session_id,
|
|
175
174
|
scriptBody: task.body,
|
|
176
175
|
runProgress,
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Task storage (disk-backed).
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* - Task 的“唯一来源”是
|
|
5
|
+
* - Task 的“唯一来源”是 Agent 私有目录中的 `task/<taskId>/task.md`
|
|
6
6
|
* - list/read/write 都只围绕 markdown 文件与目录结构,不引入数据库
|
|
7
|
-
* -
|
|
7
|
+
* - 运行产物目录:Agent 私有目录中的 `task/<taskId>/<timestamp>/...`
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import fs from "fs-extra";
|
|
@@ -52,11 +52,11 @@ function isDirectoryNameTimestamp(name: string): boolean {
|
|
|
52
52
|
* 列出全部任务。
|
|
53
53
|
*
|
|
54
54
|
* 算法(中文)
|
|
55
|
-
* - 遍历
|
|
55
|
+
* - 遍历 Agent 的 `task/*` 目录并解析每个 `task.md`。
|
|
56
56
|
* - 通过子目录时间戳推断 `lastRunTimestamp`。
|
|
57
57
|
*/
|
|
58
|
-
export async function listTasks(
|
|
59
|
-
const root = String(
|
|
58
|
+
export async function listTasks(data_path: string): Promise<TaskListItem[]> {
|
|
59
|
+
const root = String(data_path || "").trim();
|
|
60
60
|
if (!root) return [];
|
|
61
61
|
|
|
62
62
|
const dir = getTaskRootDir(root);
|
|
@@ -88,7 +88,7 @@ export async function listTasks(project_root: string): Promise<TaskListItem[]> {
|
|
|
88
88
|
taskId,
|
|
89
89
|
markdown: raw,
|
|
90
90
|
taskMdPath,
|
|
91
|
-
|
|
91
|
+
data_path: root,
|
|
92
92
|
});
|
|
93
93
|
if (!parsed.ok) continue;
|
|
94
94
|
|
|
@@ -136,11 +136,11 @@ export async function listTasks(project_root: string): Promise<TaskListItem[]> {
|
|
|
136
136
|
* - 若磁盘中存在同 title 多定义,会拒绝并提示冲突。
|
|
137
137
|
*/
|
|
138
138
|
export async function resolveTaskIdByTitle(params: {
|
|
139
|
-
|
|
139
|
+
data_path: string;
|
|
140
140
|
title: string;
|
|
141
141
|
}): Promise<string> {
|
|
142
|
-
const root = String(params.
|
|
143
|
-
if (!root) throw new Error("
|
|
142
|
+
const root = String(params.data_path || "").trim();
|
|
143
|
+
if (!root) throw new Error("data_path is required");
|
|
144
144
|
const title = String(params.title || "").trim();
|
|
145
145
|
if (!title) throw new Error("title is required");
|
|
146
146
|
|
|
@@ -156,9 +156,9 @@ export async function resolveTaskIdByTitle(params: {
|
|
|
156
156
|
/**
|
|
157
157
|
* 读取单个任务定义。
|
|
158
158
|
*/
|
|
159
|
-
export async function readTask(params: { taskId: string;
|
|
160
|
-
const root = String(params.
|
|
161
|
-
if (!root) throw new Error("
|
|
159
|
+
export async function readTask(params: { taskId: string; data_path: string }): Promise<ShipTaskDefinitionV1> {
|
|
160
|
+
const root = String(params.data_path || "").trim();
|
|
161
|
+
if (!root) throw new Error("data_path is required");
|
|
162
162
|
const taskId = normalizeTaskId(params.taskId);
|
|
163
163
|
|
|
164
164
|
const taskMdPath = getTaskMdPath(root, taskId);
|
|
@@ -167,7 +167,7 @@ export async function readTask(params: { taskId: string; project_root: string })
|
|
|
167
167
|
taskId,
|
|
168
168
|
markdown: raw,
|
|
169
169
|
taskMdPath,
|
|
170
|
-
|
|
170
|
+
data_path: root,
|
|
171
171
|
});
|
|
172
172
|
if (!parsed.ok) throw new Error(parsed.error);
|
|
173
173
|
return parsed.task;
|
|
@@ -178,10 +178,10 @@ export async function readTask(params: { taskId: string; project_root: string })
|
|
|
178
178
|
*/
|
|
179
179
|
export async function deleteTask(params: {
|
|
180
180
|
taskId: string;
|
|
181
|
-
|
|
181
|
+
data_path: string;
|
|
182
182
|
}): Promise<{ taskId: string; taskDirPath: string }> {
|
|
183
|
-
const root = String(params.
|
|
184
|
-
if (!root) throw new Error("
|
|
183
|
+
const root = String(params.data_path || "").trim();
|
|
184
|
+
if (!root) throw new Error("data_path is required");
|
|
185
185
|
const taskId = normalizeTaskId(params.taskId);
|
|
186
186
|
|
|
187
187
|
const taskMdPath = getTaskMdPath(root, taskId);
|
|
@@ -208,11 +208,11 @@ export async function writeTask(params: {
|
|
|
208
208
|
taskId: string;
|
|
209
209
|
frontmatter: ShipTaskFrontmatterV1;
|
|
210
210
|
body: string;
|
|
211
|
-
|
|
211
|
+
data_path: string;
|
|
212
212
|
overwrite?: boolean;
|
|
213
213
|
}): Promise<{ taskId: string; taskMdPath: string }> {
|
|
214
|
-
const root = String(params.
|
|
215
|
-
if (!root) throw new Error("
|
|
214
|
+
const root = String(params.data_path || "").trim();
|
|
215
|
+
if (!root) throw new Error("data_path is required");
|
|
216
216
|
const taskId = normalizeTaskId(params.taskId);
|
|
217
217
|
|
|
218
218
|
const dir = getTaskDir(root, taskId);
|
|
@@ -239,10 +239,10 @@ export async function writeTask(params: {
|
|
|
239
239
|
export async function ensureRunDir(params: {
|
|
240
240
|
taskId: string;
|
|
241
241
|
timestamp: string;
|
|
242
|
-
|
|
242
|
+
data_path: string;
|
|
243
243
|
}): Promise<{ runDir: string; runDirRel: string }> {
|
|
244
|
-
const root = String(params.
|
|
245
|
-
if (!root) throw new Error("
|
|
244
|
+
const root = String(params.data_path || "").trim();
|
|
245
|
+
if (!root) throw new Error("data_path is required");
|
|
246
246
|
const taskId = normalizeTaskId(params.taskId);
|
|
247
247
|
const runDir = getTaskRunDir(root, taskId, params.timestamp);
|
|
248
248
|
await fs.ensureDir(runDir);
|
|
@@ -114,7 +114,7 @@ export async function executeTaskListAction(params: {
|
|
|
114
114
|
return {
|
|
115
115
|
success: true,
|
|
116
116
|
data: await listTaskDefinitions({
|
|
117
|
-
|
|
117
|
+
data_path: params.context.data_path,
|
|
118
118
|
...(params.payload.status ? { status: params.payload.status } : {}),
|
|
119
119
|
}),
|
|
120
120
|
};
|
|
@@ -130,7 +130,7 @@ export async function executeTaskCreateAction(params: {
|
|
|
130
130
|
}) {
|
|
131
131
|
const payload = params.payload;
|
|
132
132
|
const result = await createTaskDefinition({
|
|
133
|
-
|
|
133
|
+
data_path: params.context.data_path,
|
|
134
134
|
request: payload,
|
|
135
135
|
});
|
|
136
136
|
if (!result.success) {
|
|
@@ -163,7 +163,7 @@ export async function executeTaskRunAction(params: {
|
|
|
163
163
|
}) {
|
|
164
164
|
const result = await runTaskDefinition({
|
|
165
165
|
context: params.context,
|
|
166
|
-
|
|
166
|
+
data_path: params.context.data_path,
|
|
167
167
|
request: params.payload,
|
|
168
168
|
execution_context: params.execution_context,
|
|
169
169
|
});
|
|
@@ -189,7 +189,7 @@ export async function executeTaskDeleteAction(params: {
|
|
|
189
189
|
}) {
|
|
190
190
|
const payload = params.payload;
|
|
191
191
|
const result = await deleteTaskDefinition({
|
|
192
|
-
|
|
192
|
+
data_path: params.context.data_path,
|
|
193
193
|
request: payload,
|
|
194
194
|
});
|
|
195
195
|
if (!result.success) {
|
|
@@ -222,7 +222,7 @@ export async function executeTaskUpdateAction(params: {
|
|
|
222
222
|
}) {
|
|
223
223
|
const payload = params.payload;
|
|
224
224
|
const result = await updateTaskDefinition({
|
|
225
|
-
|
|
225
|
+
data_path: params.context.data_path,
|
|
226
226
|
request: payload,
|
|
227
227
|
});
|
|
228
228
|
if (!result.success) {
|
|
@@ -255,7 +255,7 @@ export async function executeTaskStatusAction(params: {
|
|
|
255
255
|
}) {
|
|
256
256
|
const payload = params.payload;
|
|
257
257
|
const result = await setTaskStatus({
|
|
258
|
-
|
|
258
|
+
data_path: params.context.data_path,
|
|
259
259
|
request: payload,
|
|
260
260
|
});
|
|
261
261
|
if (!result.success) {
|
|
@@ -222,7 +222,7 @@ export function createTaskPluginActions(params: {
|
|
|
222
222
|
return executeTaskRunAction({
|
|
223
223
|
context: actionParams.context,
|
|
224
224
|
payload: actionParams.input as TaskRunRequest,
|
|
225
|
-
execution_context: actionParams.
|
|
225
|
+
execution_context: actionParams.execution.snapshot,
|
|
226
226
|
});
|
|
227
227
|
},
|
|
228
228
|
}),
|
|
@@ -273,14 +273,23 @@ export async function runAgentRound(params: {
|
|
|
273
273
|
*/
|
|
274
274
|
export async function runScriptTask(params: {
|
|
275
275
|
context: PluginContext;
|
|
276
|
-
runDirAbs: string;
|
|
277
276
|
session_id: string;
|
|
278
277
|
scriptBody: string;
|
|
279
278
|
}): Promise<ScriptExecutionResult> {
|
|
280
279
|
const body = String(params.scriptBody || "");
|
|
281
280
|
if (!body.trim()) throw new Error("script task body cannot be empty");
|
|
282
281
|
|
|
283
|
-
const
|
|
282
|
+
const session_segment = String(params.session_id || "task")
|
|
283
|
+
.replace(/[^a-zA-Z0-9._-]+/g, "-")
|
|
284
|
+
.replace(/^-+|-+$/g, "") || "task";
|
|
285
|
+
const execution_dir = path.join(
|
|
286
|
+
params.context.data_path,
|
|
287
|
+
"sandbox",
|
|
288
|
+
"task-scripts",
|
|
289
|
+
session_segment,
|
|
290
|
+
);
|
|
291
|
+
await fs.ensureDir(execution_dir);
|
|
292
|
+
const scriptAbs = path.join(execution_dir, "task-script.sh");
|
|
284
293
|
await fs.writeFile(scriptAbs, body.endsWith("\n") ? body : `${body}\n`, "utf-8");
|
|
285
294
|
|
|
286
295
|
const childEnv: NodeJS.ProcessEnv = {
|
|
@@ -294,9 +303,9 @@ export async function runScriptTask(params: {
|
|
|
294
303
|
}
|
|
295
304
|
const execResult = await shell.run_safe_command({
|
|
296
305
|
execution_id: `task-script:${params.session_id}`,
|
|
297
|
-
execution_dir
|
|
306
|
+
execution_dir,
|
|
298
307
|
cmd: `sh "${scriptAbs.replace(/(["\\$`])/g, "\\$1")}"`,
|
|
299
|
-
cwd: params.
|
|
308
|
+
cwd: params.context.workspace_path,
|
|
300
309
|
shell_path: "/bin/sh",
|
|
301
310
|
login: false,
|
|
302
311
|
base_env: childEnv,
|
|
@@ -24,10 +24,6 @@ export interface RunScriptTaskBranchParams {
|
|
|
24
24
|
* 当前 Agent 执行上下文。
|
|
25
25
|
*/
|
|
26
26
|
context: PluginContext;
|
|
27
|
-
/**
|
|
28
|
-
* 当前 run 目录绝对路径。
|
|
29
|
-
*/
|
|
30
|
-
runDirAbs: string;
|
|
31
27
|
/**
|
|
32
28
|
* script 任务绑定的 session_id。
|
|
33
29
|
*/
|
|
@@ -110,7 +106,6 @@ export async function runScriptTaskBranch(
|
|
|
110
106
|
try {
|
|
111
107
|
const scriptResult = await runScriptTask({
|
|
112
108
|
context: params.context,
|
|
113
|
-
runDirAbs: params.runDirAbs,
|
|
114
109
|
session_id: params.session_id,
|
|
115
110
|
scriptBody: params.scriptBody,
|
|
116
111
|
});
|
|
@@ -9,8 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import path from "node:path";
|
|
12
|
-
import type {
|
|
13
|
-
|
|
12
|
+
import type {
|
|
13
|
+
AgentModel,
|
|
14
|
+
AgentOptions,
|
|
15
|
+
PluginContext,
|
|
16
|
+
SessionAttachmentStore,
|
|
17
|
+
} from "@downcity/agent";
|
|
14
18
|
import { Executor } from "@downcity/agent";
|
|
15
19
|
import type { SessionTurnExecutionResult } from "@downcity/agent";
|
|
16
20
|
import type { TaskSessionRuntimePort } from "@/task/runtime/TaskRunnerTypes.js";
|
|
@@ -62,7 +66,7 @@ export async function appendTaskRoundUserMessage(params: {
|
|
|
62
66
|
*/
|
|
63
67
|
export function createTaskSessionRuntimePort(params: {
|
|
64
68
|
context: PluginContext;
|
|
65
|
-
model:
|
|
69
|
+
model: AgentModel;
|
|
66
70
|
runDirAbs: string;
|
|
67
71
|
runSessionId: string;
|
|
68
72
|
userSimulatorSessionId: string;
|
|
@@ -97,7 +101,7 @@ export function createTaskSessionRuntimePort(params: {
|
|
|
97
101
|
if (!shell) {
|
|
98
102
|
throw new Error("Task agent execution requires Agent to be configured with a Shell.");
|
|
99
103
|
}
|
|
100
|
-
const shell_tools = shell.tools as
|
|
104
|
+
const shell_tools = shell.tools as NonNullable<AgentOptions["tools"]>;
|
|
101
105
|
/**
|
|
102
106
|
* Task runtime 当前只接收已经规范化的文本消息,不支持通过 Prompt 传入 Data URL 附件。
|
|
103
107
|
* 显式提供适配器,避免把 Task 的临时 run 目录错误地当成普通 Session 附件目录。
|
|
@@ -127,7 +131,7 @@ export function createTaskSessionRuntimePort(params: {
|
|
|
127
131
|
const created = new SessionMessages({
|
|
128
132
|
session_id: key,
|
|
129
133
|
store: create_session_message_store({
|
|
130
|
-
files: context.
|
|
134
|
+
files: context.data_files,
|
|
131
135
|
session_id: key,
|
|
132
136
|
file_path: path.join(messages_dir_path, "active.jsonl"),
|
|
133
137
|
assistant_message_file_path: path.join(
|
|
@@ -242,7 +246,5 @@ export async function appendTaskDeferredMessages(params: {
|
|
|
242
246
|
const { taskSessionRuntime, session_id, rawResult } = params;
|
|
243
247
|
const messages = taskSessionRuntime.get_messages(session_id);
|
|
244
248
|
const deferredUserMessages = rawResult.deferred_persisted_user_messages || [];
|
|
245
|
-
|
|
246
|
-
await messages.append_record(deferred);
|
|
247
|
-
}
|
|
249
|
+
await messages.append_deferred_user_messages(deferredUserMessages);
|
|
248
250
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** TaskPlugin 在单个 Workspace 中持有的运行态类型。 */
|
|
2
|
+
|
|
3
|
+
import type { TaskCronTriggerEngine } from "@/task/runtime/CronTrigger.js";
|
|
4
|
+
|
|
5
|
+
/** 单个 Workspace 独立拥有的 Task 调度资源。 */
|
|
6
|
+
export interface TaskWorkspaceRuntime {
|
|
7
|
+
/** 当前 Workspace 的 cron 触发引擎。 */
|
|
8
|
+
readonly cron_engine: TaskCronTriggerEngine;
|
|
9
|
+
|
|
10
|
+
/** 当前 Workspace 正在执行的任务 ID,用于阻止同一任务并发触发。 */
|
|
11
|
+
readonly running_task_ids: Set<string>;
|
|
12
|
+
}
|