@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
|
@@ -147,7 +147,7 @@ export function normalizeContactEndpoint(endpoint: string): string {
|
|
|
147
147
|
* 保存 contact。
|
|
148
148
|
*/
|
|
149
149
|
export async function saveContact(
|
|
150
|
-
|
|
150
|
+
data_path: string,
|
|
151
151
|
contact: AgentContact,
|
|
152
152
|
): Promise<AgentContact> {
|
|
153
153
|
const normalized: AgentContact = {
|
|
@@ -171,11 +171,11 @@ export async function saveContact(
|
|
|
171
171
|
if (normalized.reachability !== "outbound" && !normalized.inboundTokenHash) {
|
|
172
172
|
throw new Error("contact inbound token hash is required for inbound contacts");
|
|
173
173
|
}
|
|
174
|
-
await fs.ensureDir(getContactDirectoryPath(
|
|
175
|
-
await fs.writeJson(getContactJsonPath(
|
|
174
|
+
await fs.ensureDir(getContactDirectoryPath(data_path, normalized.id));
|
|
175
|
+
await fs.writeJson(getContactJsonPath(data_path, normalized.id), normalized, {
|
|
176
176
|
spaces: 2,
|
|
177
177
|
});
|
|
178
|
-
await fs.ensureFile(getContactMessagesPath(
|
|
178
|
+
await fs.ensureFile(getContactMessagesPath(data_path, normalized.id));
|
|
179
179
|
return normalized;
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -183,10 +183,10 @@ export async function saveContact(
|
|
|
183
183
|
* 读取 contact。
|
|
184
184
|
*/
|
|
185
185
|
export async function readContact(
|
|
186
|
-
|
|
186
|
+
data_path: string,
|
|
187
187
|
contactId: string,
|
|
188
188
|
): Promise<AgentContact | null> {
|
|
189
|
-
const filePath = getContactJsonPath(
|
|
189
|
+
const filePath = getContactJsonPath(data_path, contactId);
|
|
190
190
|
if (!(await fs.pathExists(filePath))) return null;
|
|
191
191
|
const raw = await fs.readJson(filePath).catch(() => null);
|
|
192
192
|
// 关键点(中文):读取时归一化可恢复字段,避免一次局部写入让已收到的 contact 在列表中消失。
|
|
@@ -196,14 +196,14 @@ export async function readContact(
|
|
|
196
196
|
/**
|
|
197
197
|
* 列出全部 contact。
|
|
198
198
|
*/
|
|
199
|
-
export async function listContacts(
|
|
200
|
-
const root = getContactsRootPath(
|
|
199
|
+
export async function listContacts(data_path: string): Promise<AgentContact[]> {
|
|
200
|
+
const root = getContactsRootPath(data_path);
|
|
201
201
|
if (!(await fs.pathExists(root))) return [];
|
|
202
202
|
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
203
203
|
const contacts: AgentContact[] = [];
|
|
204
204
|
for (const entry of entries) {
|
|
205
205
|
if (!entry.isDirectory()) continue;
|
|
206
|
-
const contact = await readContact(
|
|
206
|
+
const contact = await readContact(data_path, entry.name);
|
|
207
207
|
if (contact) contacts.push(contact);
|
|
208
208
|
}
|
|
209
209
|
return contacts.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -213,12 +213,12 @@ export async function listContacts(project_root: string): Promise<AgentContact[]
|
|
|
213
213
|
* 按 id/name 查找 contact。
|
|
214
214
|
*/
|
|
215
215
|
export async function findContact(
|
|
216
|
-
|
|
216
|
+
data_path: string,
|
|
217
217
|
query: string,
|
|
218
218
|
): Promise<AgentContact | null> {
|
|
219
219
|
const value = String(query || "").trim();
|
|
220
220
|
if (!value) return null;
|
|
221
|
-
const contacts = await listContacts(
|
|
221
|
+
const contacts = await listContacts(data_path);
|
|
222
222
|
const lower = value.toLowerCase();
|
|
223
223
|
return (
|
|
224
224
|
contacts.find((item) => item.id.toLowerCase() === lower) ||
|
|
@@ -232,11 +232,11 @@ export async function findContact(
|
|
|
232
232
|
* 根据入站 token 查找 contact。
|
|
233
233
|
*/
|
|
234
234
|
export async function findContactByInboundToken(
|
|
235
|
-
|
|
235
|
+
data_path: string,
|
|
236
236
|
token: string,
|
|
237
237
|
): Promise<AgentContact | null> {
|
|
238
238
|
const token_hash = hashContactToken(token);
|
|
239
|
-
const contacts = await listContacts(
|
|
239
|
+
const contacts = await listContacts(data_path);
|
|
240
240
|
return contacts.find((item) => item.inboundTokenHash === token_hash) || null;
|
|
241
241
|
}
|
|
242
242
|
|
|
@@ -244,13 +244,13 @@ export async function findContactByInboundToken(
|
|
|
244
244
|
* 更新 contact 最近在线时间。
|
|
245
245
|
*/
|
|
246
246
|
export async function touchContactSeen(
|
|
247
|
-
|
|
247
|
+
data_path: string,
|
|
248
248
|
contactId: string,
|
|
249
249
|
seenAt: number = Date.now(),
|
|
250
250
|
): Promise<AgentContact | null> {
|
|
251
|
-
const contact = await readContact(
|
|
251
|
+
const contact = await readContact(data_path, contactId);
|
|
252
252
|
if (!contact) return null;
|
|
253
|
-
return await saveContact(
|
|
253
|
+
return await saveContact(data_path, {
|
|
254
254
|
...contact,
|
|
255
255
|
lastSeenAt: seenAt,
|
|
256
256
|
});
|
|
@@ -260,11 +260,11 @@ export async function touchContactSeen(
|
|
|
260
260
|
* 追加 contact chat 消息。
|
|
261
261
|
*/
|
|
262
262
|
export async function appendContactMessage(
|
|
263
|
-
|
|
263
|
+
data_path: string,
|
|
264
264
|
contactId: string,
|
|
265
265
|
message: ContactChatMessage,
|
|
266
266
|
): Promise<void> {
|
|
267
|
-
const filePath = getContactMessagesPath(
|
|
267
|
+
const filePath = getContactMessagesPath(data_path, contactId);
|
|
268
268
|
await fs.ensureDir(path.dirname(filePath));
|
|
269
269
|
await fs.appendFile(filePath, `${JSON.stringify(message)}\n`, "utf-8");
|
|
270
270
|
}
|
|
@@ -273,10 +273,10 @@ export async function appendContactMessage(
|
|
|
273
273
|
* 读取 contact chat 历史。
|
|
274
274
|
*/
|
|
275
275
|
export async function readContactMessages(
|
|
276
|
-
|
|
276
|
+
data_path: string,
|
|
277
277
|
contactId: string,
|
|
278
278
|
): Promise<ContactChatMessage[]> {
|
|
279
|
-
const filePath = getContactMessagesPath(
|
|
279
|
+
const filePath = getContactMessagesPath(data_path, contactId);
|
|
280
280
|
if (!(await fs.pathExists(filePath))) return [];
|
|
281
281
|
const text = await fs.readFile(filePath, "utf-8");
|
|
282
282
|
const out: ContactChatMessage[] = [];
|
|
@@ -60,7 +60,7 @@ export function buildContactLinkNotes(params: {
|
|
|
60
60
|
if (reachability === "loopback") {
|
|
61
61
|
return [
|
|
62
62
|
"This link endpoint is local-only. Only an agent on the same machine can approve it; a server agent cannot approve a link generated by this local agent.",
|
|
63
|
-
"Start
|
|
63
|
+
"Start City from a reachable environment before generating a new link; `city on` writes the public host used by contact links when it can detect one.",
|
|
64
64
|
];
|
|
65
65
|
}
|
|
66
66
|
if (reachability === "private") {
|
|
@@ -118,7 +118,7 @@ export function buildContactApproveNotes(params: {
|
|
|
118
118
|
);
|
|
119
119
|
} else {
|
|
120
120
|
notes.push(
|
|
121
|
-
"This contact is outbound-only from this side: this agent can call the peer, but the peer cannot call back unless
|
|
121
|
+
"This contact is outbound-only from this side: this agent can call the peer, but the peer cannot call back unless City is running with a reachable address.",
|
|
122
122
|
);
|
|
123
123
|
}
|
|
124
124
|
return notes;
|
|
@@ -52,11 +52,11 @@ function isMeta(input: unknown): input is ContactInboxShareMeta {
|
|
|
52
52
|
* 保存 inbox share。
|
|
53
53
|
*/
|
|
54
54
|
export async function saveContactInboxShare(
|
|
55
|
-
|
|
55
|
+
data_path: string,
|
|
56
56
|
input: SaveContactInboxShareInput,
|
|
57
57
|
): Promise<ContactInboxShareMeta> {
|
|
58
|
-
const inboxRoot = getContactInboxRootPath(
|
|
59
|
-
const sharePath = getContactInboxSharePath(
|
|
58
|
+
const inboxRoot = getContactInboxRootPath(data_path);
|
|
59
|
+
const sharePath = getContactInboxSharePath(data_path, input.meta.id);
|
|
60
60
|
const tempRoot = path.join(path.dirname(inboxRoot), ".inbox-tmp");
|
|
61
61
|
const tempPath = path.join(
|
|
62
62
|
tempRoot,
|
|
@@ -103,10 +103,10 @@ export async function saveContactInboxShare(
|
|
|
103
103
|
* 读取 inbox share meta。
|
|
104
104
|
*/
|
|
105
105
|
export async function readContactInboxShareMeta(
|
|
106
|
-
|
|
106
|
+
data_path: string,
|
|
107
107
|
shareId: string,
|
|
108
108
|
): Promise<ContactInboxShareMeta | null> {
|
|
109
|
-
const filePath = getContactInboxShareMetaPath(
|
|
109
|
+
const filePath = getContactInboxShareMetaPath(data_path, shareId);
|
|
110
110
|
if (!(await fs.pathExists(filePath))) return null;
|
|
111
111
|
const raw = await fs.readJson(filePath).catch(() => null);
|
|
112
112
|
return isMeta(raw) ? raw : null;
|
|
@@ -116,10 +116,10 @@ export async function readContactInboxShareMeta(
|
|
|
116
116
|
* 读取 inbox share payload。
|
|
117
117
|
*/
|
|
118
118
|
export async function readContactInboxSharePayload(
|
|
119
|
-
|
|
119
|
+
data_path: string,
|
|
120
120
|
shareId: string,
|
|
121
121
|
): Promise<ContactInboxSharePayload | null> {
|
|
122
|
-
const filePath = getContactInboxSharePayloadPath(
|
|
122
|
+
const filePath = getContactInboxSharePayloadPath(data_path, shareId);
|
|
123
123
|
if (!(await fs.pathExists(filePath))) return null;
|
|
124
124
|
const raw = await fs.readJson(filePath).catch(() => null);
|
|
125
125
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
@@ -131,15 +131,15 @@ export async function readContactInboxSharePayload(
|
|
|
131
131
|
* 列出 inbox share。
|
|
132
132
|
*/
|
|
133
133
|
export async function listContactInboxShares(
|
|
134
|
-
|
|
134
|
+
data_path: string,
|
|
135
135
|
): Promise<ContactInboxShareMeta[]> {
|
|
136
|
-
const root = getContactInboxRootPath(
|
|
136
|
+
const root = getContactInboxRootPath(data_path);
|
|
137
137
|
if (!(await fs.pathExists(root))) return [];
|
|
138
138
|
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
139
139
|
const shares: ContactInboxShareMeta[] = [];
|
|
140
140
|
for (const entry of entries) {
|
|
141
141
|
if (!entry.isDirectory()) continue;
|
|
142
|
-
const meta = await readContactInboxShareMeta(
|
|
142
|
+
const meta = await readContactInboxShareMeta(data_path, entry.name);
|
|
143
143
|
if (meta) shares.push(meta);
|
|
144
144
|
}
|
|
145
145
|
return shares.sort((a, b) => b.receivedAt - a.receivedAt);
|
|
@@ -149,22 +149,22 @@ export async function listContactInboxShares(
|
|
|
149
149
|
* 标记 share 已接收,并复制轻量状态到 received。
|
|
150
150
|
*/
|
|
151
151
|
export async function markContactInboxShareReceived(
|
|
152
|
-
|
|
152
|
+
data_path: string,
|
|
153
153
|
shareId: string,
|
|
154
154
|
): Promise<ContactInboxShareMeta> {
|
|
155
|
-
const meta = await readContactInboxShareMeta(
|
|
155
|
+
const meta = await readContactInboxShareMeta(data_path, shareId);
|
|
156
156
|
if (!meta) throw new Error(`Share not found: ${shareId}`);
|
|
157
157
|
const next: ContactInboxShareMeta = {
|
|
158
158
|
...meta,
|
|
159
159
|
status: "received",
|
|
160
160
|
};
|
|
161
|
-
const receivedPath = getContactReceivedSharePath(
|
|
161
|
+
const receivedPath = getContactReceivedSharePath(data_path, shareId);
|
|
162
162
|
await fs.ensureDir(receivedPath);
|
|
163
163
|
await fs.writeJson(path.join(receivedPath, "meta.json"), next, {
|
|
164
164
|
spaces: 2,
|
|
165
165
|
});
|
|
166
166
|
// received 区先完整写入,最后再更新 inbox meta,避免列表状态提前变成 received。
|
|
167
|
-
await fs.writeJson(getContactInboxShareMetaPath(
|
|
167
|
+
await fs.writeJson(getContactInboxShareMetaPath(data_path, shareId), next, {
|
|
168
168
|
spaces: 2,
|
|
169
169
|
});
|
|
170
170
|
return next;
|
|
@@ -173,6 +173,6 @@ export async function markContactInboxShareReceived(
|
|
|
173
173
|
/**
|
|
174
174
|
* 读取 share 文件根目录。
|
|
175
175
|
*/
|
|
176
|
-
export function getInboxShareFilesRoot(
|
|
177
|
-
return getContactInboxShareFilesPath(
|
|
176
|
+
export function getInboxShareFilesRoot(data_path: string, shareId: string): string {
|
|
177
|
+
return getContactInboxShareFilesPath(data_path, shareId);
|
|
178
178
|
}
|
|
@@ -99,31 +99,31 @@ function readCallbackCandidate(
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
async function findApprovedContact(params: {
|
|
102
|
-
|
|
102
|
+
data_path: string;
|
|
103
103
|
agentName: string;
|
|
104
104
|
}) {
|
|
105
105
|
const stable = await readContact(
|
|
106
|
-
params.
|
|
106
|
+
params.data_path,
|
|
107
107
|
createStableContactId(params.agentName),
|
|
108
108
|
);
|
|
109
109
|
if (stable) return stable;
|
|
110
|
-
const contacts = await listContacts(params.
|
|
110
|
+
const contacts = await listContacts(params.data_path);
|
|
111
111
|
const lower = params.agentName.trim().toLowerCase();
|
|
112
112
|
return contacts.find((item) => item.name.toLowerCase() === lower) || null;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
async function saveApprovedInboundContact(params: {
|
|
116
|
-
|
|
116
|
+
data_path: string;
|
|
117
117
|
agentName: string;
|
|
118
118
|
tokenForOwner: string;
|
|
119
119
|
nowMs: number;
|
|
120
120
|
}) {
|
|
121
121
|
const existing = await findApprovedContact({
|
|
122
|
-
|
|
122
|
+
data_path: params.data_path,
|
|
123
123
|
agentName: params.agentName,
|
|
124
124
|
});
|
|
125
125
|
const hasOutboundSide = Boolean(existing?.endpoint && existing?.outboundToken);
|
|
126
|
-
await saveContact(params.
|
|
126
|
+
await saveContact(params.data_path, {
|
|
127
127
|
id: existing?.id || createStableContactId(params.agentName),
|
|
128
128
|
name: existing?.name || params.agentName,
|
|
129
129
|
endpoint: existing?.endpoint || null,
|
|
@@ -143,7 +143,7 @@ export async function approveContactLinkRequest(
|
|
|
143
143
|
input: ApproveContactLinkRequestInput,
|
|
144
144
|
): Promise<ContactApproveLinkResponse> {
|
|
145
145
|
const nowMs = input.nowMs ?? Date.now();
|
|
146
|
-
const link = await readContactLinkRecord(input.
|
|
146
|
+
const link = await readContactLinkRecord(input.data_path, input.request.linkId);
|
|
147
147
|
if (!link) {
|
|
148
148
|
return failure({
|
|
149
149
|
ownerAgentName: input.ownerAgentName,
|
|
@@ -185,10 +185,10 @@ export async function approveContactLinkRequest(
|
|
|
185
185
|
tokenForRequester: callbackCandidate.token,
|
|
186
186
|
callbackReason: input.request.callbackReason || link.callbackReason || null,
|
|
187
187
|
};
|
|
188
|
-
await saveContactLinkRecord(input.
|
|
188
|
+
await saveContactLinkRecord(input.data_path, nextLink);
|
|
189
189
|
}
|
|
190
190
|
await saveApprovedInboundContact({
|
|
191
|
-
|
|
191
|
+
data_path: input.data_path,
|
|
192
192
|
agentName: input.request.agentName,
|
|
193
193
|
tokenForOwner: link.tokenForOwner,
|
|
194
194
|
nowMs,
|
|
@@ -219,9 +219,9 @@ export async function approveContactLinkRequest(
|
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
// 先消费 link,再派生 contact;重试时以 link 记录为来源修复 contact,避免孤儿 trusted contact。
|
|
222
|
-
await saveContactLinkRecord(input.
|
|
222
|
+
await saveContactLinkRecord(input.data_path, approvedLink);
|
|
223
223
|
await saveApprovedInboundContact({
|
|
224
|
-
|
|
224
|
+
data_path: input.data_path,
|
|
225
225
|
agentName: input.request.agentName,
|
|
226
226
|
tokenForOwner,
|
|
227
227
|
nowMs,
|
|
@@ -242,7 +242,7 @@ export async function confirmContactLinkRequest(
|
|
|
242
242
|
input: ConfirmContactLinkRequestInput,
|
|
243
243
|
): Promise<ContactConfirmResponse> {
|
|
244
244
|
const nowMs = input.nowMs ?? Date.now();
|
|
245
|
-
const link = await readContactLinkRecord(input.
|
|
245
|
+
const link = await readContactLinkRecord(input.data_path, input.request.linkId);
|
|
246
246
|
if (!link) {
|
|
247
247
|
return confirmFailure({
|
|
248
248
|
ownerAgentName: input.ownerAgentName,
|
|
@@ -309,7 +309,7 @@ export async function confirmContactLinkRequest(
|
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
311
|
const contact = await findApprovedContact({
|
|
312
|
-
|
|
312
|
+
data_path: input.data_path,
|
|
313
313
|
agentName: input.request.agentName,
|
|
314
314
|
});
|
|
315
315
|
if (!contact || contact.status !== "trusted") {
|
|
@@ -332,7 +332,7 @@ export async function confirmContactLinkRequest(
|
|
|
332
332
|
) {
|
|
333
333
|
if (!link.confirmedAt) {
|
|
334
334
|
// contact 已经完成双向升级时,重试 confirm 需要补齐 link 状态,避免最终状态分裂。
|
|
335
|
-
await saveContactLinkRecord(input.
|
|
335
|
+
await saveContactLinkRecord(input.data_path, {
|
|
336
336
|
...link,
|
|
337
337
|
approvedEndpoint: endpoint,
|
|
338
338
|
tokenForRequester: token,
|
|
@@ -363,7 +363,7 @@ export async function confirmContactLinkRequest(
|
|
|
363
363
|
};
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
await saveContact(input.
|
|
366
|
+
await saveContact(input.data_path, {
|
|
367
367
|
...contact,
|
|
368
368
|
endpoint,
|
|
369
369
|
reachability: "bidirectional",
|
|
@@ -371,7 +371,7 @@ export async function confirmContactLinkRequest(
|
|
|
371
371
|
inboundTokenHash: contact.inboundTokenHash,
|
|
372
372
|
lastSeenAt: nowMs,
|
|
373
373
|
});
|
|
374
|
-
await saveContactLinkRecord(input.
|
|
374
|
+
await saveContactLinkRecord(input.data_path, {
|
|
375
375
|
...link,
|
|
376
376
|
approvedEndpoint: endpoint,
|
|
377
377
|
tokenForRequester: token,
|
|
@@ -27,11 +27,11 @@ function isLinkRecord(input: unknown): input is ContactLinkRecord {
|
|
|
27
27
|
* 保存 link 记录。
|
|
28
28
|
*/
|
|
29
29
|
export async function saveContactLinkRecord(
|
|
30
|
-
|
|
30
|
+
data_path: string,
|
|
31
31
|
record: ContactLinkRecord,
|
|
32
32
|
): Promise<void> {
|
|
33
|
-
await fs.ensureDir(getContactLinksRootPath(
|
|
34
|
-
await fs.writeJson(getContactLinkPath(
|
|
33
|
+
await fs.ensureDir(getContactLinksRootPath(data_path));
|
|
34
|
+
await fs.writeJson(getContactLinkPath(data_path, record.id), record, {
|
|
35
35
|
spaces: 2,
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -40,10 +40,10 @@ export async function saveContactLinkRecord(
|
|
|
40
40
|
* 读取 link 记录。
|
|
41
41
|
*/
|
|
42
42
|
export async function readContactLinkRecord(
|
|
43
|
-
|
|
43
|
+
data_path: string,
|
|
44
44
|
linkId: string,
|
|
45
45
|
): Promise<ContactLinkRecord | null> {
|
|
46
|
-
const filePath = getContactLinkPath(
|
|
46
|
+
const filePath = getContactLinkPath(data_path, linkId);
|
|
47
47
|
if (!(await fs.pathExists(filePath))) return null;
|
|
48
48
|
const raw = await fs.readJson(filePath).catch(() => null);
|
|
49
49
|
return isLinkRecord(raw) ? raw : null;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* contact plugin runtime 路径规则。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* - 所有 contact 运行时状态都收敛在
|
|
5
|
+
* - 所有 contact 运行时状态都收敛在 Agent private runtime directory 私有 `contact` 目录。
|
|
6
6
|
* - 每个 contact 一个目录;每条 inbox share 一个目录。
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -22,118 +22,118 @@ function cleanSegment(input: string, label: string): string {
|
|
|
22
22
|
/**
|
|
23
23
|
* contact 根目录。
|
|
24
24
|
*/
|
|
25
|
-
export function getContactRootPath(
|
|
26
|
-
return path.join(
|
|
25
|
+
export function getContactRootPath(data_path: string): string {
|
|
26
|
+
return path.join(data_path, "contact");
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* contacts 根目录。
|
|
31
31
|
*/
|
|
32
|
-
export function getContactsRootPath(
|
|
33
|
-
return path.join(getContactRootPath(
|
|
32
|
+
export function getContactsRootPath(data_path: string): string {
|
|
33
|
+
return path.join(getContactRootPath(data_path), "contacts");
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* 单个 contact 目录。
|
|
38
38
|
*/
|
|
39
39
|
export function getContactDirectoryPath(
|
|
40
|
-
|
|
40
|
+
data_path: string,
|
|
41
41
|
contactId: string,
|
|
42
42
|
): string {
|
|
43
|
-
return path.join(getContactsRootPath(
|
|
43
|
+
return path.join(getContactsRootPath(data_path), cleanSegment(contactId, "contactId"));
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* 单个 contact 元信息文件。
|
|
48
48
|
*/
|
|
49
|
-
export function getContactJsonPath(
|
|
50
|
-
return path.join(getContactDirectoryPath(
|
|
49
|
+
export function getContactJsonPath(data_path: string, contactId: string): string {
|
|
50
|
+
return path.join(getContactDirectoryPath(data_path, contactId), "contact.json");
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* 单个 contact 的长期对话历史文件。
|
|
55
55
|
*/
|
|
56
56
|
export function getContactMessagesPath(
|
|
57
|
-
|
|
57
|
+
data_path: string,
|
|
58
58
|
contactId: string,
|
|
59
59
|
): string {
|
|
60
|
-
return path.join(getContactDirectoryPath(
|
|
60
|
+
return path.join(getContactDirectoryPath(data_path, contactId), "messages.jsonl");
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* link 根目录。
|
|
65
65
|
*/
|
|
66
|
-
export function getContactLinksRootPath(
|
|
67
|
-
return path.join(getContactRootPath(
|
|
66
|
+
export function getContactLinksRootPath(data_path: string): string {
|
|
67
|
+
return path.join(getContactRootPath(data_path), "links");
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* 单个 link 记录文件。
|
|
72
72
|
*/
|
|
73
|
-
export function getContactLinkPath(
|
|
74
|
-
return path.join(getContactLinksRootPath(
|
|
73
|
+
export function getContactLinkPath(data_path: string, linkId: string): string {
|
|
74
|
+
return path.join(getContactLinksRootPath(data_path), `${cleanSegment(linkId, "linkId")}.json`);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* inbox 根目录。
|
|
79
79
|
*/
|
|
80
|
-
export function getContactInboxRootPath(
|
|
81
|
-
return path.join(getContactRootPath(
|
|
80
|
+
export function getContactInboxRootPath(data_path: string): string {
|
|
81
|
+
return path.join(getContactRootPath(data_path), "inbox");
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
85
|
* 单个 inbox share 目录。
|
|
86
86
|
*/
|
|
87
87
|
export function getContactInboxSharePath(
|
|
88
|
-
|
|
88
|
+
data_path: string,
|
|
89
89
|
shareId: string,
|
|
90
90
|
): string {
|
|
91
|
-
return path.join(getContactInboxRootPath(
|
|
91
|
+
return path.join(getContactInboxRootPath(data_path), cleanSegment(shareId, "shareId"));
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
95
|
* 单个 inbox share 元信息文件。
|
|
96
96
|
*/
|
|
97
97
|
export function getContactInboxShareMetaPath(
|
|
98
|
-
|
|
98
|
+
data_path: string,
|
|
99
99
|
shareId: string,
|
|
100
100
|
): string {
|
|
101
|
-
return path.join(getContactInboxSharePath(
|
|
101
|
+
return path.join(getContactInboxSharePath(data_path, shareId), "meta.json");
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* 单个 inbox share payload 文件。
|
|
106
106
|
*/
|
|
107
107
|
export function getContactInboxSharePayloadPath(
|
|
108
|
-
|
|
108
|
+
data_path: string,
|
|
109
109
|
shareId: string,
|
|
110
110
|
): string {
|
|
111
|
-
return path.join(getContactInboxSharePath(
|
|
111
|
+
return path.join(getContactInboxSharePath(data_path, shareId), "payload.json");
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* 单个 inbox share 文件根目录。
|
|
116
116
|
*/
|
|
117
117
|
export function getContactInboxShareFilesPath(
|
|
118
|
-
|
|
118
|
+
data_path: string,
|
|
119
119
|
shareId: string,
|
|
120
120
|
): string {
|
|
121
|
-
return path.join(getContactInboxSharePath(
|
|
121
|
+
return path.join(getContactInboxSharePath(data_path, shareId), "files");
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* received 根目录。
|
|
126
126
|
*/
|
|
127
|
-
export function getContactReceivedRootPath(
|
|
128
|
-
return path.join(getContactRootPath(
|
|
127
|
+
export function getContactReceivedRootPath(data_path: string): string {
|
|
128
|
+
return path.join(getContactRootPath(data_path), "received");
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* 单个 received share 目录。
|
|
133
133
|
*/
|
|
134
134
|
export function getContactReceivedSharePath(
|
|
135
|
-
|
|
135
|
+
data_path: string,
|
|
136
136
|
shareId: string,
|
|
137
137
|
): string {
|
|
138
|
-
return path.join(getContactReceivedRootPath(
|
|
138
|
+
return path.join(getContactReceivedRootPath(data_path), cleanSegment(shareId, "shareId"));
|
|
139
139
|
}
|
|
@@ -235,7 +235,7 @@ export async function receiveShare(params: {
|
|
|
235
235
|
/**
|
|
236
236
|
* 项目根目录。
|
|
237
237
|
*/
|
|
238
|
-
|
|
238
|
+
data_path: string;
|
|
239
239
|
/**
|
|
240
240
|
* share id。
|
|
241
241
|
*/
|
|
@@ -250,22 +250,22 @@ export async function receiveShare(params: {
|
|
|
250
250
|
*/
|
|
251
251
|
receivedPath: string;
|
|
252
252
|
}> {
|
|
253
|
-
const payload = await readContactInboxSharePayload(params.
|
|
253
|
+
const payload = await readContactInboxSharePayload(params.data_path, params.shareId);
|
|
254
254
|
if (!payload) throw new Error(`Share payload not found: ${params.shareId}`);
|
|
255
255
|
if (payload.kind !== "share") throw new Error(`Unsupported share payload: ${payload.kind}`);
|
|
256
256
|
|
|
257
|
-
const receivedPath = getContactReceivedSharePath(params.
|
|
257
|
+
const receivedPath = getContactReceivedSharePath(params.data_path, params.shareId);
|
|
258
258
|
await fs.ensureDir(receivedPath);
|
|
259
259
|
await fs.writeJson(path.join(receivedPath, "payload.json"), payload, { spaces: 2 });
|
|
260
260
|
|
|
261
|
-
const filesRoot = getInboxShareFilesRoot(params.
|
|
261
|
+
const filesRoot = getInboxShareFilesRoot(params.data_path, params.shareId);
|
|
262
262
|
if (await fs.pathExists(filesRoot)) {
|
|
263
263
|
await fs.copy(filesRoot, path.join(receivedPath, "files"), {
|
|
264
264
|
overwrite: true,
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
await markContactInboxShareReceived(params.
|
|
268
|
+
await markContactInboxShareReceived(params.data_path, params.shareId);
|
|
269
269
|
return {
|
|
270
270
|
itemCount: payload.items.length,
|
|
271
271
|
receivedPath,
|
|
@@ -43,7 +43,7 @@ export interface ApproveContactLinkRequestInput {
|
|
|
43
43
|
/**
|
|
44
44
|
* 当前 agent 项目根目录,用于读取 link 记录并保存 contact。
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
data_path: string;
|
|
47
47
|
/**
|
|
48
48
|
* 当前 agent 名称,也就是 link 所属方名称。
|
|
49
49
|
*/
|
|
@@ -121,7 +121,7 @@ export interface ConfirmContactLinkRequestInput {
|
|
|
121
121
|
/**
|
|
122
122
|
* 当前 agent 项目根目录,用于读取 link 记录并更新 contact。
|
|
123
123
|
*/
|
|
124
|
-
|
|
124
|
+
data_path: string;
|
|
125
125
|
/**
|
|
126
126
|
* 当前 agent 名称,也就是 link 所属方名称。
|
|
127
127
|
*/
|