@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
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Store(文件枚举与轻量运行态)。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - MemoryPlugin 使用 LLM Wiki 结构:`wiki/` 是知识层,`sources/` 是证据层。
|
|
6
|
-
* - 当前实现不维护后台索引,扫描 Markdown 即可工作。
|
|
7
|
-
* - 运行态只保存 rootPath,避免伪装成有后台 worker 的复杂 runtime。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { Dirent } from "node:fs";
|
|
11
|
-
import fsp from "node:fs/promises";
|
|
12
|
-
import path from "node:path";
|
|
13
|
-
import type { PluginContext } from "@downcity/agent";
|
|
14
|
-
import type {
|
|
15
|
-
MemoryDefaults,
|
|
16
|
-
MemorySourceType,
|
|
17
|
-
} from "@/memory/types/Memory.js";
|
|
18
|
-
|
|
19
|
-
export const MEMORY_DEFAULTS: MemoryDefaults = {
|
|
20
|
-
maxResults: 6,
|
|
21
|
-
minScore: 0.35,
|
|
22
|
-
maxInjectedChars: 4000,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type MemorySourceFile = {
|
|
26
|
-
/**
|
|
27
|
-
* 来源分类。
|
|
28
|
-
*/
|
|
29
|
-
source: MemorySourceType;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 绝对路径。
|
|
33
|
-
*/
|
|
34
|
-
absPath: string;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 相对项目根目录路径。
|
|
38
|
-
*/
|
|
39
|
-
relPath: string;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type MemoryRuntimeState = {
|
|
43
|
-
/**
|
|
44
|
-
* 项目根目录。
|
|
45
|
-
*/
|
|
46
|
-
rootPath: string;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
function normalizeRelPath(rootPath: string, absPath: string): string {
|
|
50
|
-
return path.relative(rootPath, absPath).replace(/\\/g, "/");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function isMarkdownPath(filePath: string): boolean {
|
|
54
|
-
return filePath.toLowerCase().endsWith(".md");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async function pathExists(absPath: string): Promise<boolean> {
|
|
58
|
-
try {
|
|
59
|
-
await fsp.access(absPath);
|
|
60
|
-
return true;
|
|
61
|
-
} catch {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
async function listMarkdownFilesRecursively(dirPath: string): Promise<string[]> {
|
|
67
|
-
const out: string[] = [];
|
|
68
|
-
let entries: Dirent[] = [];
|
|
69
|
-
try {
|
|
70
|
-
entries = await fsp.readdir(dirPath, { withFileTypes: true });
|
|
71
|
-
} catch {
|
|
72
|
-
return out;
|
|
73
|
-
}
|
|
74
|
-
for (const entry of entries) {
|
|
75
|
-
const abs = path.join(dirPath, entry.name);
|
|
76
|
-
if (entry.isSymbolicLink()) {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (entry.isDirectory()) {
|
|
80
|
-
out.push(...(await listMarkdownFilesRecursively(abs)));
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
if (!entry.isFile() || !isMarkdownPath(abs)) {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
out.push(abs);
|
|
87
|
-
}
|
|
88
|
-
return out;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async function pushMarkdownTree(
|
|
92
|
-
out: MemorySourceFile[],
|
|
93
|
-
rootPath: string,
|
|
94
|
-
dirPath: string,
|
|
95
|
-
source: MemorySourceType,
|
|
96
|
-
): Promise<void> {
|
|
97
|
-
for (const absPath of await listMarkdownFilesRecursively(dirPath)) {
|
|
98
|
-
out.push({
|
|
99
|
-
source,
|
|
100
|
-
absPath,
|
|
101
|
-
relPath: normalizeRelPath(rootPath, absPath),
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* 枚举 memory Markdown 文件。
|
|
108
|
-
*/
|
|
109
|
-
export async function listMemorySourceFiles(
|
|
110
|
-
rootPath: string,
|
|
111
|
-
options: { includeSources?: boolean } = {},
|
|
112
|
-
): Promise<MemorySourceFile[]> {
|
|
113
|
-
const out: MemorySourceFile[] = [];
|
|
114
|
-
await pushMarkdownTree(
|
|
115
|
-
out,
|
|
116
|
-
rootPath,
|
|
117
|
-
path.join(rootPath, ".downcity", "memory", "wiki"),
|
|
118
|
-
"wiki",
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
if (options.includeSources) {
|
|
122
|
-
await pushMarkdownTree(
|
|
123
|
-
out,
|
|
124
|
-
rootPath,
|
|
125
|
-
path.join(rootPath, ".downcity", "memory", "sources"),
|
|
126
|
-
"source",
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
// 旧版 daily / MEMORY.md 被当作 source 层读取,避免已有文件突然不可检索。
|
|
130
|
-
const longterm = path.join(rootPath, ".downcity", "memory", "MEMORY.md");
|
|
131
|
-
if (await pathExists(longterm)) {
|
|
132
|
-
out.push({
|
|
133
|
-
source: "source",
|
|
134
|
-
absPath: longterm,
|
|
135
|
-
relPath: normalizeRelPath(rootPath, longterm),
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
await pushMarkdownTree(
|
|
139
|
-
out,
|
|
140
|
-
rootPath,
|
|
141
|
-
path.join(rootPath, ".downcity", "memory", "daily"),
|
|
142
|
-
"source",
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return out;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* 创建一个新的 memory plugin state。
|
|
151
|
-
*/
|
|
152
|
-
export function createMemoryRuntimeState(
|
|
153
|
-
context: PluginContext,
|
|
154
|
-
): MemoryRuntimeState {
|
|
155
|
-
return {
|
|
156
|
-
rootPath: context.workspace_path,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
@@ -1,351 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Writer(LLM Wiki 文件读写与路径安全)。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - `sources/` 保存原始证据,`wiki/` 保存整理后的长期记忆。
|
|
6
|
-
* - 所有外部传入路径都必须限制在 Memory Plugin 自己的 `.downcity/memory` 目录内。
|
|
7
|
-
* - 无 LLM 注入时使用 append fallback,保证 MemoryPlugin 仍然可用。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import fs from "node:fs/promises";
|
|
11
|
-
import path from "node:path";
|
|
12
|
-
import type { PluginContext } from "@downcity/agent";
|
|
13
|
-
import type {
|
|
14
|
-
MemoryReadPayload,
|
|
15
|
-
MemoryReadResponse,
|
|
16
|
-
MemoryRevisePayload,
|
|
17
|
-
MemoryReviseResponse,
|
|
18
|
-
MemoryWikiPageDraft,
|
|
19
|
-
} from "@/memory/types/Memory.js";
|
|
20
|
-
|
|
21
|
-
function nowIso(): string {
|
|
22
|
-
return new Date().toISOString();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function dateStamp(now: Date = new Date()): string {
|
|
26
|
-
return now.toISOString().slice(0, 10);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function toRelPath(rootPath: string, absPath: string): string {
|
|
30
|
-
return path.relative(rootPath, absPath).replace(/\\/g, "/");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function isWithin(parentPath: string, childPath: string): boolean {
|
|
34
|
-
const parent = path.resolve(parentPath);
|
|
35
|
-
const child = path.resolve(childPath);
|
|
36
|
-
if (parent === child) return true;
|
|
37
|
-
return child.startsWith(`${parent}${path.sep}`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function slugify(value: string): string {
|
|
41
|
-
const text = String(value || "")
|
|
42
|
-
.trim()
|
|
43
|
-
.toLowerCase()
|
|
44
|
-
.replace(/[^\p{L}\p{N}]+/gu, "-")
|
|
45
|
-
.replace(/^-+|-+$/g, "")
|
|
46
|
-
.slice(0, 80);
|
|
47
|
-
return text || "inbox";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function normalizeMarkdownPath(value: string): string {
|
|
51
|
-
const clean = String(value || "")
|
|
52
|
-
.replace(/\\/g, "/")
|
|
53
|
-
.replace(/^\/+/, "")
|
|
54
|
-
.trim();
|
|
55
|
-
if (!clean) return "";
|
|
56
|
-
return clean.toLowerCase().endsWith(".md") ? clean : `${clean}.md`;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function resolveWikiPath(context: PluginContext, requestedPath?: string, title?: string): {
|
|
60
|
-
absPath: string;
|
|
61
|
-
relPath: string;
|
|
62
|
-
} {
|
|
63
|
-
const memoryRoot = path.join(context.workspace_path, ".downcity", "memory");
|
|
64
|
-
const wikiRoot = path.join(memoryRoot, "wiki");
|
|
65
|
-
const normalized = normalizeMarkdownPath(requestedPath || slugify(title || "inbox"));
|
|
66
|
-
const withoutPrefix = normalized
|
|
67
|
-
.replace(/^\.downcity\/memory\/wiki\//, "")
|
|
68
|
-
.replace(/^wiki\//, "");
|
|
69
|
-
const absPath = path.resolve(wikiRoot, withoutPrefix);
|
|
70
|
-
if (!isWithin(wikiRoot, absPath)) {
|
|
71
|
-
throw new Error("wiki path is not allowed");
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
absPath,
|
|
75
|
-
relPath: toRelPath(context.workspace_path, absPath),
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function resolveAllowedReadPath(context: PluginContext, relPath: string): string {
|
|
80
|
-
const normalized = relPath.replace(/\\/g, "/").replace(/^\/+/, "").trim();
|
|
81
|
-
if (!normalized) {
|
|
82
|
-
throw new Error("path is required");
|
|
83
|
-
}
|
|
84
|
-
const absPath = path.resolve(context.workspace_path, normalized);
|
|
85
|
-
const memoryRoot = path.resolve(path.join(context.workspace_path, ".downcity", "memory"));
|
|
86
|
-
const isMemoryPath = isWithin(memoryRoot, absPath);
|
|
87
|
-
if (!isMemoryPath) {
|
|
88
|
-
throw new Error("path is not allowed");
|
|
89
|
-
}
|
|
90
|
-
if (!normalized.toLowerCase().endsWith(".md")) {
|
|
91
|
-
throw new Error("path must be markdown");
|
|
92
|
-
}
|
|
93
|
-
return absPath;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function buildSourceEntry(content: string, source?: string): string {
|
|
97
|
-
const clean = String(content || "").trim();
|
|
98
|
-
const sourceText = source ? `Source: ${source}\n\n` : "";
|
|
99
|
-
return `## ${nowIso()}\n\n${sourceText}${clean}\n`;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function buildFallbackWikiEntry(payload: {
|
|
103
|
-
content: string;
|
|
104
|
-
sourcePath?: string;
|
|
105
|
-
instruction?: string;
|
|
106
|
-
}): string {
|
|
107
|
-
const lines = [
|
|
108
|
-
`## ${nowIso()}`,
|
|
109
|
-
"",
|
|
110
|
-
...(payload.instruction ? [`Instruction: ${payload.instruction}`, ""] : []),
|
|
111
|
-
payload.content.trim(),
|
|
112
|
-
"",
|
|
113
|
-
...(payload.sourcePath ? [`Source: ${payload.sourcePath}`, ""] : []),
|
|
114
|
-
];
|
|
115
|
-
return lines.join("\n");
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function ensureFrontmatter(draft: MemoryWikiPageDraft): string {
|
|
119
|
-
const content = String(draft.content || "").trim();
|
|
120
|
-
if (content.startsWith("---")) {
|
|
121
|
-
return `${content}\n`;
|
|
122
|
-
}
|
|
123
|
-
const title = String(draft.title || "Memory Page").trim();
|
|
124
|
-
const tags = draft.tags && draft.tags.length > 0
|
|
125
|
-
? draft.tags.map((tag) => String(tag).trim()).filter(Boolean)
|
|
126
|
-
: ["memory"];
|
|
127
|
-
return [
|
|
128
|
-
"---",
|
|
129
|
-
`title: ${JSON.stringify(title)}`,
|
|
130
|
-
`date: ${dateStamp()}`,
|
|
131
|
-
`tags: [${tags.map((tag) => JSON.stringify(tag)).join(", ")}]`,
|
|
132
|
-
"---",
|
|
133
|
-
"",
|
|
134
|
-
content,
|
|
135
|
-
"",
|
|
136
|
-
].join("\n");
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
async function readTextIfExists(absPath: string): Promise<string> {
|
|
140
|
-
try {
|
|
141
|
-
return String(await fs.readFile(absPath, "utf-8"));
|
|
142
|
-
} catch {
|
|
143
|
-
return "";
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* 初始化 memory wiki 目录结构(幂等)。
|
|
149
|
-
*/
|
|
150
|
-
export async function ensureMemoryDirectories(rootPath: string): Promise<void> {
|
|
151
|
-
const memoryRoot = path.join(rootPath, ".downcity", "memory");
|
|
152
|
-
await fs.mkdir(path.join(memoryRoot, "wiki"), { recursive: true });
|
|
153
|
-
await fs.mkdir(path.join(memoryRoot, "sources", "manual"), { recursive: true });
|
|
154
|
-
await fs.mkdir(path.join(memoryRoot, "sources", "sessions"), { recursive: true });
|
|
155
|
-
|
|
156
|
-
const indexPath = path.join(memoryRoot, "wiki", "index.md");
|
|
157
|
-
const exists = await fs
|
|
158
|
-
.access(indexPath)
|
|
159
|
-
.then(() => true)
|
|
160
|
-
.catch(() => false);
|
|
161
|
-
if (!exists) {
|
|
162
|
-
await fs.writeFile(
|
|
163
|
-
indexPath,
|
|
164
|
-
[
|
|
165
|
-
"---",
|
|
166
|
-
'title: "Memory Index"',
|
|
167
|
-
`date: ${dateStamp()}`,
|
|
168
|
-
'tags: ["memory", "index"]',
|
|
169
|
-
"---",
|
|
170
|
-
"",
|
|
171
|
-
"This is the root index for the agent-maintained LLM Wiki memory.",
|
|
172
|
-
"",
|
|
173
|
-
].join("\n"),
|
|
174
|
-
"utf-8",
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* 读取指定记忆文件(支持行区间)。
|
|
181
|
-
*/
|
|
182
|
-
export async function readMemory(
|
|
183
|
-
context: PluginContext,
|
|
184
|
-
payload: MemoryReadPayload,
|
|
185
|
-
): Promise<MemoryReadResponse> {
|
|
186
|
-
const requestedPath = String(payload.path || "").trim();
|
|
187
|
-
if (!requestedPath) {
|
|
188
|
-
throw new Error("path is required");
|
|
189
|
-
}
|
|
190
|
-
const absPath = resolveAllowedReadPath(context, requestedPath);
|
|
191
|
-
const relPath = toRelPath(context.workspace_path, absPath);
|
|
192
|
-
const exists = await fs
|
|
193
|
-
.access(absPath)
|
|
194
|
-
.then(() => true)
|
|
195
|
-
.catch(() => false);
|
|
196
|
-
if (!exists) {
|
|
197
|
-
return { path: relPath, text: "", missing: true };
|
|
198
|
-
}
|
|
199
|
-
const content = String(await fs.readFile(absPath, "utf-8"));
|
|
200
|
-
const from = payload.from ? Math.max(1, Math.floor(payload.from)) : undefined;
|
|
201
|
-
const lines = payload.lines ? Math.max(1, Math.floor(payload.lines)) : undefined;
|
|
202
|
-
if (!from && !lines) {
|
|
203
|
-
return { path: relPath, text: content };
|
|
204
|
-
}
|
|
205
|
-
const rows = content.split("\n");
|
|
206
|
-
const start = from ?? 1;
|
|
207
|
-
const size = lines ?? rows.length;
|
|
208
|
-
const slice = rows.slice(start - 1, start - 1 + size).join("\n");
|
|
209
|
-
return { path: relPath, text: slice };
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* 读取 wiki index 内容。
|
|
214
|
-
*/
|
|
215
|
-
export async function readWikiIndex(context: PluginContext): Promise<string> {
|
|
216
|
-
const indexPath = path.join(context.workspace_path, ".downcity", "memory", "wiki", "index.md");
|
|
217
|
-
return await readTextIfExists(indexPath);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* 归档手动 source。
|
|
222
|
-
*/
|
|
223
|
-
export async function appendManualSource(
|
|
224
|
-
context: PluginContext,
|
|
225
|
-
content: string,
|
|
226
|
-
source?: string,
|
|
227
|
-
): Promise<{ path: string; writtenChars: number }> {
|
|
228
|
-
const absPath = path.join(
|
|
229
|
-
context.workspace_path,
|
|
230
|
-
".downcity",
|
|
231
|
-
"memory",
|
|
232
|
-
"sources",
|
|
233
|
-
"manual",
|
|
234
|
-
`${dateStamp()}.md`,
|
|
235
|
-
);
|
|
236
|
-
await fs.mkdir(path.dirname(absPath), { recursive: true });
|
|
237
|
-
const entry = buildSourceEntry(content, source);
|
|
238
|
-
await fs.appendFile(absPath, `\n${entry}`, "utf-8");
|
|
239
|
-
return {
|
|
240
|
-
path: toRelPath(context.workspace_path, absPath),
|
|
241
|
-
writtenChars: entry.length,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* 写入 session source。
|
|
247
|
-
*/
|
|
248
|
-
export async function writeSessionSource(
|
|
249
|
-
context: PluginContext,
|
|
250
|
-
session_id: string,
|
|
251
|
-
content: string,
|
|
252
|
-
): Promise<{ path: string; writtenChars: number }> {
|
|
253
|
-
const safeSessionId = slugify(session_id);
|
|
254
|
-
const absPath = path.join(
|
|
255
|
-
context.workspace_path,
|
|
256
|
-
".downcity",
|
|
257
|
-
"memory",
|
|
258
|
-
"sources",
|
|
259
|
-
"sessions",
|
|
260
|
-
`${safeSessionId}.md`,
|
|
261
|
-
);
|
|
262
|
-
const text = [
|
|
263
|
-
"---",
|
|
264
|
-
`title: ${JSON.stringify(`Session ${session_id}`)}`,
|
|
265
|
-
`date: ${dateStamp()}`,
|
|
266
|
-
'tags: ["memory-source", "session"]',
|
|
267
|
-
"---",
|
|
268
|
-
"",
|
|
269
|
-
`# Session ${session_id}`,
|
|
270
|
-
"",
|
|
271
|
-
content.trim(),
|
|
272
|
-
"",
|
|
273
|
-
].join("\n");
|
|
274
|
-
await fs.mkdir(path.dirname(absPath), { recursive: true });
|
|
275
|
-
await fs.writeFile(absPath, text, "utf-8");
|
|
276
|
-
return {
|
|
277
|
-
path: toRelPath(context.workspace_path, absPath),
|
|
278
|
-
writtenChars: text.length,
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* 写入完整 wiki page。
|
|
284
|
-
*/
|
|
285
|
-
export async function writeWikiPage(
|
|
286
|
-
context: PluginContext,
|
|
287
|
-
draft: MemoryWikiPageDraft,
|
|
288
|
-
): Promise<{ path: string; writtenChars: number }> {
|
|
289
|
-
const resolved = resolveWikiPath(context, draft.path, draft.title);
|
|
290
|
-
const content = ensureFrontmatter(draft);
|
|
291
|
-
await fs.mkdir(path.dirname(resolved.absPath), { recursive: true });
|
|
292
|
-
await fs.writeFile(resolved.absPath, content, "utf-8");
|
|
293
|
-
return {
|
|
294
|
-
path: resolved.relPath,
|
|
295
|
-
writtenChars: content.length,
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* 追加写入 wiki page。
|
|
301
|
-
*/
|
|
302
|
-
export async function appendWikiPage(
|
|
303
|
-
context: PluginContext,
|
|
304
|
-
payload: {
|
|
305
|
-
path?: string;
|
|
306
|
-
title?: string;
|
|
307
|
-
content: string;
|
|
308
|
-
sourcePath?: string;
|
|
309
|
-
instruction?: string;
|
|
310
|
-
},
|
|
311
|
-
): Promise<{ path: string; writtenChars: number }> {
|
|
312
|
-
const resolved = resolveWikiPath(context, payload.path, payload.title);
|
|
313
|
-
await fs.mkdir(path.dirname(resolved.absPath), { recursive: true });
|
|
314
|
-
const exists = await fs
|
|
315
|
-
.access(resolved.absPath)
|
|
316
|
-
.then(() => true)
|
|
317
|
-
.catch(() => false);
|
|
318
|
-
if (!exists) {
|
|
319
|
-
await writeWikiPage(context, {
|
|
320
|
-
path: resolved.relPath,
|
|
321
|
-
title: payload.title || "Memory Inbox",
|
|
322
|
-
content: "This page is maintained by MemoryPlugin fallback writes.",
|
|
323
|
-
tags: ["memory"],
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
const entry = buildFallbackWikiEntry(payload);
|
|
327
|
-
await fs.appendFile(resolved.absPath, `\n${entry}`, "utf-8");
|
|
328
|
-
return {
|
|
329
|
-
path: resolved.relPath,
|
|
330
|
-
writtenChars: entry.length,
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* 使用 fallback 方式修订 wiki page。
|
|
336
|
-
*/
|
|
337
|
-
export async function appendMemoryRevision(
|
|
338
|
-
context: PluginContext,
|
|
339
|
-
payload: MemoryRevisePayload,
|
|
340
|
-
): Promise<MemoryReviseResponse> {
|
|
341
|
-
const written = await appendWikiPage(context, {
|
|
342
|
-
path: payload.path,
|
|
343
|
-
content: String(payload.evidence || "").trim() || "(no evidence)",
|
|
344
|
-
instruction: payload.instruction,
|
|
345
|
-
});
|
|
346
|
-
return {
|
|
347
|
-
path: written.path,
|
|
348
|
-
mode: "appended",
|
|
349
|
-
writtenChars: written.writtenChars,
|
|
350
|
-
};
|
|
351
|
-
}
|
package/src/skill/Command.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Skill 安装命令 helper。
|
|
3
|
-
*
|
|
4
|
-
* 设计目标(中文)
|
|
5
|
-
* - 不自建 registry,直接复用社区的 `npx skills` 安装生态。
|
|
6
|
-
* - 当前 helper 由需要准备 skill 依赖的其他 plugin 复用,不作为 SkillPlugin action 暴露。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { execa } from "execa";
|
|
10
|
-
|
|
11
|
-
async function runNpxSkills(args: string[], opts?: { yes?: boolean }): Promise<number> {
|
|
12
|
-
const yes = opts?.yes !== false;
|
|
13
|
-
const result = await execa("npx", [yes ? "-y" : "", "skills", ...args].filter(Boolean), {
|
|
14
|
-
stdio: "inherit",
|
|
15
|
-
});
|
|
16
|
-
return result.exitCode ?? 0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* skill 安装选项。
|
|
21
|
-
*/
|
|
22
|
-
export interface SkillInstallOptions {
|
|
23
|
-
/**
|
|
24
|
-
* 是否执行全局安装。
|
|
25
|
-
*/
|
|
26
|
-
global?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* 是否跳过交互确认。
|
|
29
|
-
*/
|
|
30
|
-
yes?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* 安装目标 agent 名称。
|
|
33
|
-
*/
|
|
34
|
-
agent?: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 安装指定 skill。
|
|
39
|
-
*/
|
|
40
|
-
export async function skillInstallCommand(
|
|
41
|
-
spec: string,
|
|
42
|
-
options: SkillInstallOptions = {},
|
|
43
|
-
): Promise<void> {
|
|
44
|
-
const s = String(spec || "").trim();
|
|
45
|
-
if (!s) throw new Error("Missing spec");
|
|
46
|
-
|
|
47
|
-
const args: string[] = ["add", s];
|
|
48
|
-
const agent = String(options.agent || "").trim();
|
|
49
|
-
if (agent) args.push("--agent", agent);
|
|
50
|
-
|
|
51
|
-
const yes = options.yes !== false;
|
|
52
|
-
if (yes) args.push("-y");
|
|
53
|
-
|
|
54
|
-
const globalInstall = options.global !== false;
|
|
55
|
-
if (globalInstall) args.push("-g");
|
|
56
|
-
|
|
57
|
-
await runNpxSkills(args, { yes });
|
|
58
|
-
}
|