@downcity/plugins 1.0.253 → 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/Action.d.ts +27 -36
- package/bin/memory/Action.d.ts.map +1 -1
- package/bin/memory/Action.js +71 -311
- package/bin/memory/Action.js.map +1 -1
- package/bin/memory/MemoryPlugin.d.ts +20 -37
- package/bin/memory/MemoryPlugin.d.ts.map +1 -1
- package/bin/memory/MemoryPlugin.js +241 -233
- package/bin/memory/MemoryPlugin.js.map +1 -1
- package/bin/memory/adapters/FileMemoryStorageAdapter.d.ts +43 -0
- package/bin/memory/adapters/FileMemoryStorageAdapter.d.ts.map +1 -0
- package/bin/memory/adapters/FileMemoryStorageAdapter.js +163 -0
- package/bin/memory/adapters/FileMemoryStorageAdapter.js.map +1 -0
- package/bin/memory/providers/BuiltinMemoryProvider.d.ts +63 -0
- package/bin/memory/providers/BuiltinMemoryProvider.d.ts.map +1 -0
- package/bin/memory/providers/BuiltinMemoryProvider.js +772 -0
- package/bin/memory/providers/BuiltinMemoryProvider.js.map +1 -0
- package/bin/memory/runtime/SystemProvider.d.ts +7 -12
- package/bin/memory/runtime/SystemProvider.d.ts.map +1 -1
- package/bin/memory/runtime/SystemProvider.js +30 -89
- package/bin/memory/runtime/SystemProvider.js.map +1 -1
- package/bin/memory/types/BuiltinMemoryProvider.d.ts +88 -0
- package/bin/memory/types/BuiltinMemoryProvider.d.ts.map +1 -0
- package/bin/memory/types/BuiltinMemoryProvider.js +9 -0
- package/bin/memory/types/BuiltinMemoryProvider.js.map +1 -0
- package/bin/memory/types/Memory.d.ts +255 -408
- package/bin/memory/types/Memory.d.ts.map +1 -1
- package/bin/memory/types/Memory.js +4 -4
- package/bin/memory/types/MemoryStorage.d.ts +35 -0
- package/bin/memory/types/MemoryStorage.d.ts.map +1 -0
- package/bin/memory/types/MemoryStorage.js +10 -0
- package/bin/memory/types/MemoryStorage.js.map +1 -0
- package/bin/memory.d.ts +6 -2
- package/bin/memory.d.ts.map +1 -1
- package/bin/memory.js +3 -1
- package/bin/memory.js.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 -19
- 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 +204 -0
- package/scripts/playwright-browser-provider.test.mjs +260 -0
- package/scripts/plugin-main.test.mjs +101 -0
- package/scripts/plugin-subpaths.test.mjs +36 -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/Action.ts +106 -377
- package/src/memory/MemoryPlugin.ts +266 -246
- package/src/memory/adapters/FileMemoryStorageAdapter.ts +197 -0
- package/src/memory/providers/BuiltinMemoryProvider.ts +905 -0
- package/src/memory/runtime/SystemProvider.ts +32 -95
- package/src/memory/types/BuiltinMemoryProvider.ts +121 -0
- package/src/memory/types/Memory.ts +329 -456
- package/src/memory/types/MemoryStorage.ts +44 -0
- package/src/memory.ts +49 -24
- 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 -9
- package/bin/memory/Index.d.ts.map +0 -1
- package/bin/memory/Index.js +0 -9
- package/bin/memory/Index.js.map +0 -1
- package/bin/memory/runtime/Search.d.ts +0 -19
- package/bin/memory/runtime/Search.d.ts.map +0 -1
- package/bin/memory/runtime/Search.js +0 -262
- package/bin/memory/runtime/Search.js.map +0 -1
- package/bin/memory/runtime/Store.d.ts +0 -42
- package/bin/memory/runtime/Store.d.ts.map +0 -1
- package/bin/memory/runtime/Store.js +0 -94
- package/bin/memory/runtime/Store.js.map +0 -1
- package/bin/memory/runtime/Writer.d.ts +0 -61
- package/bin/memory/runtime/Writer.d.ts.map +0 -1
- package/bin/memory/runtime/Writer.js +0 -274
- package/bin/memory/runtime/Writer.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 -9
- package/src/memory/runtime/Search.ts +0 -327
- package/src/memory/runtime/Store.ts +0 -158
- package/src/memory/runtime/Writer.ts +0 -351
- package/src/skill/Command.ts +0 -58
- package/src/task/Index.ts +0 -8
package/src/memory/Action.ts
CHANGED
|
@@ -1,432 +1,161 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Memory Plugin action
|
|
2
|
+
* Memory Plugin action 适配层。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
5
|
+
* - Action 只把 Agent/Session 上下文映射为 MemoryProvider 的领域输入。
|
|
6
|
+
* - 物理存储、检索实现和提炼策略全部属于 Provider。
|
|
7
|
+
* - 所有 Provider 异常都转换为稳定 PluginActionResult,不伪造成功。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
11
|
-
import { isTextUIPart } from "ai";
|
|
12
|
-
import type { PluginActionResult } from "@downcity/agent";
|
|
13
|
-
import type { PluginContext } from "@downcity/agent";
|
|
10
|
+
import type { PluginActionResult, PluginContext, SessionMessage } from "@downcity/agent";
|
|
14
11
|
import type { JsonValue } from "@downcity/agent";
|
|
15
|
-
import type { SessionMessage } from "@downcity/agent";
|
|
16
12
|
import type {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
MemoryReviseResponse,
|
|
25
|
-
MemorySearchPayload,
|
|
13
|
+
MemoryForgetInput,
|
|
14
|
+
MemoryProvider,
|
|
15
|
+
MemoryReadInput,
|
|
16
|
+
MemoryRecallInput,
|
|
17
|
+
MemoryRememberInput,
|
|
18
|
+
MemoryReviseInput,
|
|
19
|
+
MemoryScope,
|
|
26
20
|
} from "@/memory/types/Memory.js";
|
|
27
|
-
import {
|
|
28
|
-
collectMemoryStatus,
|
|
29
|
-
searchMemory,
|
|
30
|
-
} from "./runtime/Search.js";
|
|
31
|
-
import {
|
|
32
|
-
MEMORY_DEFAULTS,
|
|
33
|
-
type MemoryRuntimeState,
|
|
34
|
-
} from "./runtime/Store.js";
|
|
35
|
-
import {
|
|
36
|
-
appendManualSource,
|
|
37
|
-
appendMemoryRevision,
|
|
38
|
-
appendWikiPage,
|
|
39
|
-
readMemory,
|
|
40
|
-
readWikiIndex,
|
|
41
|
-
writeSessionSource,
|
|
42
|
-
writeWikiPage,
|
|
43
|
-
} from "./runtime/Writer.js";
|
|
44
21
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const candidate = message as { role?: unknown } | null | undefined;
|
|
56
|
-
const raw_role = String(candidate?.role || "").toLowerCase();
|
|
57
|
-
if (raw_role !== "user" && raw_role !== "assistant") return "";
|
|
58
|
-
const role = raw_role === "user" ? "User" : "Assistant";
|
|
59
|
-
const text = toUiParts(message)
|
|
60
|
-
.filter(isTextUIPart)
|
|
61
|
-
.map((part) => String(part.text || "").trim())
|
|
62
|
-
.filter(Boolean)
|
|
63
|
-
.join("\n")
|
|
64
|
-
.trim();
|
|
65
|
-
if (!text) {
|
|
66
|
-
return "";
|
|
67
|
-
}
|
|
68
|
-
return `${role}: ${text}`;
|
|
22
|
+
/** 从 PluginContext 构造当前 Runtime 的默认 Memory scope。 */
|
|
23
|
+
export function create_memory_scope(
|
|
24
|
+
context: PluginContext,
|
|
25
|
+
session_id?: string,
|
|
26
|
+
): MemoryScope {
|
|
27
|
+
return {
|
|
28
|
+
agent_id: context.agent_id,
|
|
29
|
+
workspace_id: context.workspace_path,
|
|
30
|
+
...(session_id ? { session_id } : {}),
|
|
31
|
+
};
|
|
69
32
|
}
|
|
70
33
|
|
|
71
|
-
/** 从 canonical Session Message
|
|
34
|
+
/** 从 canonical Session Message 提取可供 Provider 提炼的文本。 */
|
|
72
35
|
function extract_session_message_line(message: SessionMessage): string {
|
|
73
36
|
if (message.type !== "user" && message.type !== "assistant") return "";
|
|
74
37
|
const role = message.type === "user" ? "User" : "Assistant";
|
|
75
38
|
const text = message.parts
|
|
76
|
-
.flatMap((part) =>
|
|
77
|
-
part.type === "text" ? [String(part.text || "").trim()] : [],
|
|
78
|
-
)
|
|
39
|
+
.flatMap((part) => part.type === "text" ? [String(part.text || "").trim()] : [])
|
|
79
40
|
.filter(Boolean)
|
|
80
41
|
.join("\n")
|
|
81
42
|
.trim();
|
|
82
43
|
return text ? `${role}: ${text}` : "";
|
|
83
44
|
}
|
|
84
45
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
} {
|
|
89
|
-
if (typeof result === "string") {
|
|
90
|
-
return {
|
|
91
|
-
pages: [{ title: "Memory Digest", content: result, tags: ["memory", "digest"] }],
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
pages: result.pages,
|
|
96
|
-
summary: result.summary,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function readReviseResult(
|
|
101
|
-
result: Awaited<ReturnType<NonNullable<MemoryPluginOptions["revise"]>>>,
|
|
102
|
-
fallbackPath: string,
|
|
103
|
-
): { path: string; content: string; summary?: string } {
|
|
104
|
-
if (typeof result === "string") {
|
|
105
|
-
return {
|
|
106
|
-
path: fallbackPath,
|
|
107
|
-
content: result,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
path: result.path || fallbackPath,
|
|
112
|
-
content: result.content,
|
|
113
|
-
summary: result.summary,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function slugify(value: string): string {
|
|
118
|
-
const text = String(value || "")
|
|
119
|
-
.trim()
|
|
120
|
-
.toLowerCase()
|
|
121
|
-
.replace(/[^\p{L}\p{N}]+/gu, "-")
|
|
122
|
-
.replace(/^-+|-+$/g, "")
|
|
123
|
-
.slice(0, 80);
|
|
124
|
-
return text || "inbox";
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function toWikiMemoryPath(value: string): string {
|
|
128
|
-
const clean = String(value || "").replace(/\\/g, "/").replace(/^\/+/, "").trim();
|
|
129
|
-
if (!clean) return ".downcity/memory/wiki/inbox.md";
|
|
130
|
-
if (clean.startsWith(".downcity/memory/wiki/")) {
|
|
131
|
-
return clean.toLowerCase().endsWith(".md") ? clean : `${clean}.md`;
|
|
132
|
-
}
|
|
133
|
-
const withoutPrefix = clean.replace(/^wiki\//, "");
|
|
134
|
-
const withExt = withoutPrefix.toLowerCase().endsWith(".md")
|
|
135
|
-
? withoutPrefix
|
|
136
|
-
: `${withoutPrefix}.md`;
|
|
137
|
-
return `.downcity/memory/wiki/${withExt}`;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* status action。
|
|
142
|
-
*/
|
|
143
|
-
export async function statusMemoryAction(
|
|
144
|
-
context: PluginContext,
|
|
145
|
-
state: MemoryRuntimeState,
|
|
46
|
+
/** 执行 Provider 调用并统一失败语义。 */
|
|
47
|
+
async function run_provider_action(
|
|
48
|
+
action: () => Promise<JsonValue>,
|
|
146
49
|
): Promise<PluginActionResult<JsonValue>> {
|
|
147
50
|
try {
|
|
148
|
-
|
|
149
|
-
return {
|
|
150
|
-
success: true,
|
|
151
|
-
data: stats as unknown as JsonValue,
|
|
152
|
-
};
|
|
51
|
+
return { success: true, data: await action() };
|
|
153
52
|
} catch (error) {
|
|
154
53
|
return {
|
|
155
54
|
success: false,
|
|
156
|
-
error: String(error),
|
|
55
|
+
error: error instanceof Error ? error.message : String(error),
|
|
157
56
|
};
|
|
158
57
|
}
|
|
159
58
|
}
|
|
160
59
|
|
|
161
|
-
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
export async function searchMemoryAction(
|
|
165
|
-
context: PluginContext,
|
|
166
|
-
state: MemoryRuntimeState,
|
|
167
|
-
payload: MemorySearchPayload,
|
|
60
|
+
/** status action。 */
|
|
61
|
+
export async function status_memory_action(
|
|
62
|
+
provider: MemoryProvider,
|
|
168
63
|
): Promise<PluginActionResult<JsonValue>> {
|
|
169
|
-
|
|
170
|
-
const response = await searchMemory(context, state, payload);
|
|
171
|
-
return {
|
|
172
|
-
success: true,
|
|
173
|
-
data: response as unknown as JsonValue,
|
|
174
|
-
};
|
|
175
|
-
} catch (error) {
|
|
176
|
-
return {
|
|
177
|
-
success: false,
|
|
178
|
-
error: String(error),
|
|
179
|
-
};
|
|
180
|
-
}
|
|
64
|
+
return await run_provider_action(async () => await provider.status() as unknown as JsonValue);
|
|
181
65
|
}
|
|
182
66
|
|
|
183
|
-
/**
|
|
184
|
-
|
|
185
|
-
*/
|
|
186
|
-
export async function readMemoryAction(
|
|
67
|
+
/** search action,内部委托 Provider recall。 */
|
|
68
|
+
export async function search_memory_action(
|
|
187
69
|
context: PluginContext,
|
|
188
|
-
|
|
70
|
+
provider: MemoryProvider,
|
|
71
|
+
input: Omit<MemoryRecallInput, "scope">,
|
|
189
72
|
): Promise<PluginActionResult<JsonValue>> {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
return {
|
|
195
|
-
success: false,
|
|
196
|
-
error: String(error),
|
|
197
|
-
};
|
|
198
|
-
}
|
|
73
|
+
return await run_provider_action(async () => await provider.recall({
|
|
74
|
+
...input,
|
|
75
|
+
scope: create_memory_scope(context),
|
|
76
|
+
}) as unknown as JsonValue);
|
|
199
77
|
}
|
|
200
78
|
|
|
201
|
-
/**
|
|
202
|
-
|
|
203
|
-
*/
|
|
204
|
-
export async function rememberMemoryAction(
|
|
79
|
+
/** read action。 */
|
|
80
|
+
export async function read_memory_action(
|
|
205
81
|
context: PluginContext,
|
|
206
|
-
|
|
207
|
-
|
|
82
|
+
provider: MemoryProvider,
|
|
83
|
+
input: Omit<MemoryReadInput, "scope">,
|
|
208
84
|
): Promise<PluginActionResult<JsonValue>> {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const source = await appendManualSource(context, content, payload.source);
|
|
215
|
-
const targetPath = toWikiMemoryPath(payload.path || slugify(payload.topic || "inbox"));
|
|
216
|
-
|
|
217
|
-
if (options.revise) {
|
|
218
|
-
const current = await readMemory(context, { path: targetPath }).catch(() => ({
|
|
219
|
-
path: targetPath,
|
|
220
|
-
text: "",
|
|
221
|
-
}));
|
|
222
|
-
const revised = readReviseResult(
|
|
223
|
-
await options.revise({
|
|
224
|
-
rootPath: context.workspace_path,
|
|
225
|
-
path: targetPath,
|
|
226
|
-
currentContent: current.text,
|
|
227
|
-
instruction: "Integrate this new memory into the wiki page. Deduplicate and keep it concise.",
|
|
228
|
-
evidence: `${content}\n\nSource: ${source.path}`,
|
|
229
|
-
}),
|
|
230
|
-
targetPath,
|
|
231
|
-
);
|
|
232
|
-
const written = await writeWikiPage(context, {
|
|
233
|
-
path: revised.path,
|
|
234
|
-
title: payload.topic,
|
|
235
|
-
content: revised.content,
|
|
236
|
-
tags: ["memory"],
|
|
237
|
-
});
|
|
238
|
-
const response: MemoryRememberResponse = {
|
|
239
|
-
sourcePath: source.path,
|
|
240
|
-
wikiPath: written.path,
|
|
241
|
-
mode: "revised",
|
|
242
|
-
writtenChars: written.writtenChars,
|
|
243
|
-
summary: revised.summary,
|
|
244
|
-
};
|
|
245
|
-
return { success: true, data: response as unknown as JsonValue };
|
|
246
|
-
}
|
|
85
|
+
return await run_provider_action(async () => await provider.read({
|
|
86
|
+
...input,
|
|
87
|
+
scope: create_memory_scope(context),
|
|
88
|
+
}) as unknown as JsonValue);
|
|
89
|
+
}
|
|
247
90
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
writtenChars: written.writtenChars,
|
|
259
|
-
};
|
|
260
|
-
return { success: true, data: response as unknown as JsonValue };
|
|
261
|
-
} catch (error) {
|
|
262
|
-
return {
|
|
263
|
-
success: false,
|
|
264
|
-
error: String(error),
|
|
265
|
-
};
|
|
266
|
-
}
|
|
91
|
+
/** remember action。 */
|
|
92
|
+
export async function remember_memory_action(
|
|
93
|
+
context: PluginContext,
|
|
94
|
+
provider: MemoryProvider,
|
|
95
|
+
input: Omit<MemoryRememberInput, "scope">,
|
|
96
|
+
): Promise<PluginActionResult<JsonValue>> {
|
|
97
|
+
return await run_provider_action(async () => await provider.remember({
|
|
98
|
+
...input,
|
|
99
|
+
scope: create_memory_scope(context),
|
|
100
|
+
}) as unknown as JsonValue);
|
|
267
101
|
}
|
|
268
102
|
|
|
269
|
-
/**
|
|
270
|
-
|
|
271
|
-
*/
|
|
272
|
-
export async function digestMemoryAction(
|
|
103
|
+
/** digest action:Session 消息读取属于 Plugin 编排,长期记忆语义属于 Provider。 */
|
|
104
|
+
export async function digest_memory_action(
|
|
273
105
|
context: PluginContext,
|
|
274
|
-
|
|
275
|
-
|
|
106
|
+
provider: MemoryProvider,
|
|
107
|
+
input: {
|
|
108
|
+
/** 需要提炼的 Session 标识。 */
|
|
109
|
+
session_id: string;
|
|
110
|
+
/** 可选最大消息提取条数。 */
|
|
111
|
+
max_messages?: number;
|
|
112
|
+
},
|
|
276
113
|
): Promise<PluginActionResult<JsonValue>> {
|
|
277
|
-
|
|
278
|
-
const session_id = String(
|
|
279
|
-
if (!session_id)
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const maxMessages = Number.isFinite(payload.maxMessages)
|
|
283
|
-
? Math.max(1, Math.floor(payload.maxMessages as number))
|
|
114
|
+
return await run_provider_action(async () => {
|
|
115
|
+
const session_id = String(input.session_id || "").trim();
|
|
116
|
+
if (!session_id) throw new Error("session_id is required");
|
|
117
|
+
const max_messages = Number.isFinite(input.max_messages)
|
|
118
|
+
? Math.max(1, Math.floor(input.max_messages as number))
|
|
284
119
|
: 30;
|
|
285
120
|
const snapshot = await context.sessions.runtime(session_id).context();
|
|
286
|
-
const
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
lines.length > 0
|
|
294
|
-
? lines.join("\n\n")
|
|
295
|
-
: "本次 digest 未找到可写入的用户/助手文本内容。";
|
|
296
|
-
const sourceText = [
|
|
297
|
-
`Window: ${start}-${Math.max(start, total - 1)}`,
|
|
298
|
-
"",
|
|
299
|
-
transcript,
|
|
300
|
-
].join("\n");
|
|
301
|
-
const source = await writeSessionSource(context, session_id, sourceText);
|
|
302
|
-
|
|
303
|
-
if (options.digest) {
|
|
304
|
-
const wikiIndex = await readWikiIndex(context);
|
|
305
|
-
const digested = readDigestPages(
|
|
306
|
-
await options.digest({
|
|
307
|
-
rootPath: context.workspace_path,
|
|
308
|
-
sourceText,
|
|
309
|
-
sourcePath: source.path,
|
|
310
|
-
session_id,
|
|
311
|
-
wikiIndex,
|
|
312
|
-
}),
|
|
313
|
-
);
|
|
314
|
-
const wikiPaths: string[] = [];
|
|
315
|
-
for (const page of digested.pages) {
|
|
316
|
-
const written = await writeWikiPage(context, page);
|
|
317
|
-
wikiPaths.push(written.path);
|
|
318
|
-
}
|
|
319
|
-
const response: MemoryDigestResponse = {
|
|
320
|
-
sourcePath: source.path,
|
|
321
|
-
wikiPaths,
|
|
322
|
-
message_count: lines.length,
|
|
323
|
-
mode: "digested",
|
|
324
|
-
summary: digested.summary,
|
|
325
|
-
};
|
|
326
|
-
return { success: true, data: response as unknown as JsonValue };
|
|
121
|
+
const start_index = Math.max(0, snapshot.messages.length - max_messages);
|
|
122
|
+
const lines = snapshot.messages
|
|
123
|
+
.slice(start_index)
|
|
124
|
+
.map(extract_session_message_line)
|
|
125
|
+
.filter(Boolean);
|
|
126
|
+
if (lines.length === 0) {
|
|
127
|
+
throw new Error("Session has no user or assistant text to digest");
|
|
327
128
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
sourcePath: source.path,
|
|
334
|
-
});
|
|
335
|
-
const response: MemoryDigestResponse = {
|
|
336
|
-
sourcePath: source.path,
|
|
337
|
-
wikiPaths: [written.path],
|
|
129
|
+
const transcript = lines.join("\n\n");
|
|
130
|
+
return await provider.digest({
|
|
131
|
+
session_id,
|
|
132
|
+
scope: create_memory_scope(context, session_id),
|
|
133
|
+
transcript,
|
|
338
134
|
message_count: lines.length,
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
return { success: true, data: response as unknown as JsonValue };
|
|
342
|
-
} catch (error) {
|
|
343
|
-
return {
|
|
344
|
-
success: false,
|
|
345
|
-
error: String(error),
|
|
346
|
-
};
|
|
347
|
-
}
|
|
135
|
+
}) as unknown as JsonValue;
|
|
136
|
+
});
|
|
348
137
|
}
|
|
349
138
|
|
|
350
|
-
/**
|
|
351
|
-
|
|
352
|
-
*/
|
|
353
|
-
export async function reviseMemoryAction(
|
|
139
|
+
/** revise action。 */
|
|
140
|
+
export async function revise_memory_action(
|
|
354
141
|
context: PluginContext,
|
|
355
|
-
|
|
356
|
-
|
|
142
|
+
provider: MemoryProvider,
|
|
143
|
+
input: Omit<MemoryReviseInput, "scope">,
|
|
357
144
|
): Promise<PluginActionResult<JsonValue>> {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
const instruction = String(payload.instruction || "").trim();
|
|
364
|
-
if (!instruction) {
|
|
365
|
-
throw new Error("instruction is required");
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
if (options.revise) {
|
|
369
|
-
const current = await readMemory(context, { path: targetPath }).catch(() => ({
|
|
370
|
-
path: targetPath,
|
|
371
|
-
text: "",
|
|
372
|
-
}));
|
|
373
|
-
const revised = readReviseResult(
|
|
374
|
-
await options.revise({
|
|
375
|
-
rootPath: context.workspace_path,
|
|
376
|
-
path: targetPath,
|
|
377
|
-
currentContent: current.text,
|
|
378
|
-
instruction,
|
|
379
|
-
evidence: String(payload.evidence || ""),
|
|
380
|
-
}),
|
|
381
|
-
targetPath,
|
|
382
|
-
);
|
|
383
|
-
const written = await writeWikiPage(context, {
|
|
384
|
-
path: revised.path,
|
|
385
|
-
content: revised.content,
|
|
386
|
-
tags: ["memory"],
|
|
387
|
-
});
|
|
388
|
-
const response: MemoryReviseResponse = {
|
|
389
|
-
path: written.path,
|
|
390
|
-
mode: "revised",
|
|
391
|
-
writtenChars: written.writtenChars,
|
|
392
|
-
summary: revised.summary,
|
|
393
|
-
};
|
|
394
|
-
return { success: true, data: response as unknown as JsonValue };
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
const response = await appendMemoryRevision(context, payload);
|
|
398
|
-
return { success: true, data: response as unknown as JsonValue };
|
|
399
|
-
} catch (error) {
|
|
400
|
-
return {
|
|
401
|
-
success: false,
|
|
402
|
-
error: String(error),
|
|
403
|
-
};
|
|
404
|
-
}
|
|
145
|
+
return await run_provider_action(async () => await provider.revise({
|
|
146
|
+
...input,
|
|
147
|
+
scope: create_memory_scope(context),
|
|
148
|
+
}) as unknown as JsonValue);
|
|
405
149
|
}
|
|
406
150
|
|
|
407
|
-
/**
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
? Number(input.maxResults)
|
|
418
|
-
: MEMORY_DEFAULTS.maxResults,
|
|
419
|
-
minScore:
|
|
420
|
-
typeof input.minScore === "number"
|
|
421
|
-
? input.minScore
|
|
422
|
-
: typeof input.minScore === "string"
|
|
423
|
-
? Number(input.minScore)
|
|
424
|
-
: MEMORY_DEFAULTS.minScore,
|
|
425
|
-
includeSources:
|
|
426
|
-
typeof input.includeSources === "boolean"
|
|
427
|
-
? input.includeSources
|
|
428
|
-
: typeof input.includeSources === "string"
|
|
429
|
-
? input.includeSources === "true"
|
|
430
|
-
: undefined,
|
|
431
|
-
};
|
|
151
|
+
/** forget action。 */
|
|
152
|
+
export async function forget_memory_action(
|
|
153
|
+
context: PluginContext,
|
|
154
|
+
provider: MemoryProvider,
|
|
155
|
+
input: Omit<MemoryForgetInput, "scope">,
|
|
156
|
+
): Promise<PluginActionResult<JsonValue>> {
|
|
157
|
+
return await run_provider_action(async () => await provider.forget({
|
|
158
|
+
...input,
|
|
159
|
+
scope: create_memory_scope(context),
|
|
160
|
+
}) as unknown as JsonValue);
|
|
432
161
|
}
|