@downcity/plugins 1.0.216 → 1.0.233
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/chat/Action.d.ts +51 -51
- package/bin/chat/Action.d.ts.map +1 -1
- package/bin/chat/Action.js +109 -108
- package/bin/chat/Action.js.map +1 -1
- package/bin/chat/ChatPlugin.d.ts +7 -7
- package/bin/chat/ChatPlugin.d.ts.map +1 -1
- package/bin/chat/ChatPlugin.js +4 -4
- package/bin/chat/ChatPlugin.js.map +1 -1
- package/bin/chat/Index.d.ts +3 -0
- package/bin/chat/Index.d.ts.map +1 -1
- package/bin/chat/Index.js +1 -0
- package/bin/chat/Index.js.map +1 -1
- package/bin/chat/PROMPT.direct.d.ts +1 -1
- package/bin/chat/PROMPT.direct.d.ts.map +1 -1
- package/bin/chat/PROMPT.direct.js +1 -1
- package/bin/chat/PROMPT.direct.js.map +1 -1
- package/bin/chat/access/ChatAccessActions.js +6 -6
- package/bin/chat/access/ChatAccessActions.js.map +1 -1
- package/bin/chat/access/ChatAccessRuntime.d.ts +4 -4
- package/bin/chat/access/ChatAccessRuntime.d.ts.map +1 -1
- package/bin/chat/access/ChatAccessRuntime.js +1 -1
- package/bin/chat/access/ChatAccessRuntime.js.map +1 -1
- package/bin/chat/access/ChatAccessStore.js +5 -5
- package/bin/chat/access/ChatAccessStore.js.map +1 -1
- package/bin/chat/channels/BaseChatChannel.d.ts +17 -17
- package/bin/chat/channels/BaseChatChannel.d.ts.map +1 -1
- package/bin/chat/channels/BaseChatChannel.js +19 -19
- package/bin/chat/channels/BaseChatChannel.js.map +1 -1
- package/bin/chat/channels/BaseChatChannelQueue.d.ts +6 -6
- package/bin/chat/channels/BaseChatChannelQueue.d.ts.map +1 -1
- package/bin/chat/channels/BaseChatChannelQueue.js +32 -32
- package/bin/chat/channels/BaseChatChannelQueue.js.map +1 -1
- package/bin/chat/channels/BaseChatChannelSupport.d.ts +14 -14
- package/bin/chat/channels/BaseChatChannelSupport.d.ts.map +1 -1
- package/bin/chat/channels/BaseChatChannelSupport.js +13 -13
- package/bin/chat/channels/BaseChatChannelSupport.js.map +1 -1
- package/bin/chat/channels/RuntimeChannel.d.ts +23 -28
- package/bin/chat/channels/RuntimeChannel.d.ts.map +1 -1
- package/bin/chat/channels/RuntimeChannel.js +39 -57
- package/bin/chat/channels/RuntimeChannel.js.map +1 -1
- package/bin/chat/channels/feishu/Feishu.d.ts +7 -7
- package/bin/chat/channels/feishu/Feishu.d.ts.map +1 -1
- package/bin/chat/channels/feishu/Feishu.js +31 -31
- package/bin/chat/channels/feishu/Feishu.js.map +1 -1
- package/bin/chat/channels/feishu/FeishuInbound.js +3 -3
- package/bin/chat/channels/feishu/FeishuInbound.js.map +1 -1
- package/bin/chat/channels/feishu/FeishuMessageHandler.d.ts +10 -10
- package/bin/chat/channels/feishu/FeishuMessageHandler.d.ts.map +1 -1
- package/bin/chat/channels/feishu/FeishuMessageHandler.js +17 -17
- package/bin/chat/channels/feishu/FeishuMessageHandler.js.map +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformClient.d.ts +6 -6
- package/bin/chat/channels/feishu/FeishuPlatformClient.d.ts.map +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformClient.js +9 -9
- package/bin/chat/channels/feishu/FeishuPlatformClient.js.map +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformLookup.d.ts +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformLookup.d.ts.map +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformLookup.js +6 -6
- package/bin/chat/channels/feishu/FeishuPlatformLookup.js.map +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformMessaging.d.ts +2 -2
- package/bin/chat/channels/feishu/FeishuPlatformMessaging.d.ts.map +1 -1
- package/bin/chat/channels/feishu/FeishuPlatformMessaging.js +7 -7
- package/bin/chat/channels/feishu/FeishuPlatformMessaging.js.map +1 -1
- package/bin/chat/channels/feishu/InboundAttachment.d.ts +1 -1
- package/bin/chat/channels/feishu/InboundAttachment.d.ts.map +1 -1
- package/bin/chat/channels/feishu/InboundAttachment.js +5 -5
- package/bin/chat/channels/feishu/InboundAttachment.js.map +1 -1
- package/bin/chat/channels/feishu/PostMessage.js +8 -8
- package/bin/chat/channels/feishu/PostMessage.js.map +1 -1
- package/bin/chat/channels/feishu/ReplyContext.d.ts +1 -1
- package/bin/chat/channels/feishu/ReplyContext.d.ts.map +1 -1
- package/bin/chat/channels/feishu/ReplyContext.js +2 -2
- package/bin/chat/channels/feishu/ReplyContext.js.map +1 -1
- package/bin/chat/channels/feishu/Shared.js +3 -3
- package/bin/chat/channels/feishu/Shared.js.map +1 -1
- package/bin/chat/channels/qq/PROMPT.direct.d.ts +1 -1
- package/bin/chat/channels/qq/PROMPT.direct.d.ts.map +1 -1
- package/bin/chat/channels/qq/PROMPT.direct.js +1 -1
- package/bin/chat/channels/qq/PROMPT.direct.js.map +1 -1
- package/bin/chat/channels/qq/QQ.d.ts +3 -3
- package/bin/chat/channels/qq/QQ.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQ.js +20 -20
- 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/QQGatewayAuth.d.ts +1 -1
- package/bin/chat/channels/qq/QQGatewayAuth.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQGatewayClient.d.ts +2 -2
- package/bin/chat/channels/qq/QQGatewayClient.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQGatewayClient.js +11 -11
- package/bin/chat/channels/qq/QQGatewayClient.js.map +1 -1
- package/bin/chat/channels/qq/QQGatewayConnection.d.ts +1 -1
- package/bin/chat/channels/qq/QQGatewayConnection.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQGatewaySend.d.ts +2 -2
- package/bin/chat/channels/qq/QQGatewaySend.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQGatewaySend.js +3 -3
- package/bin/chat/channels/qq/QQGatewaySend.js.map +1 -1
- package/bin/chat/channels/qq/QQInbound.js +5 -5
- package/bin/chat/channels/qq/QQInbound.js.map +1 -1
- package/bin/chat/channels/qq/QQInboundDedupe.d.ts +2 -2
- package/bin/chat/channels/qq/QQInboundDedupe.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQInboundDedupe.js +5 -5
- package/bin/chat/channels/qq/QQInboundDedupe.js.map +1 -1
- package/bin/chat/channels/qq/QQMessageHandler.d.ts +9 -9
- package/bin/chat/channels/qq/QQMessageHandler.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQMessageHandler.js +34 -34
- package/bin/chat/channels/qq/QQMessageHandler.js.map +1 -1
- package/bin/chat/channels/qq/QQSendSupport.js +2 -2
- package/bin/chat/channels/qq/QQSendSupport.js.map +1 -1
- package/bin/chat/channels/qq/QQSupport.d.ts +5 -5
- package/bin/chat/channels/qq/QQSupport.d.ts.map +1 -1
- package/bin/chat/channels/qq/QQSupport.js +5 -5
- package/bin/chat/channels/qq/QQSupport.js.map +1 -1
- package/bin/chat/channels/qq/types/QqChannel.d.ts +1 -1
- package/bin/chat/channels/qq/types/QqChannel.d.ts.map +1 -1
- package/bin/chat/channels/telegram/ApiClient.d.ts +2 -2
- package/bin/chat/channels/telegram/ApiClient.d.ts.map +1 -1
- package/bin/chat/channels/telegram/ApiClient.js +6 -6
- package/bin/chat/channels/telegram/ApiClient.js.map +1 -1
- package/bin/chat/channels/telegram/Bot.d.ts +4 -4
- package/bin/chat/channels/telegram/Bot.d.ts.map +1 -1
- package/bin/chat/channels/telegram/Bot.js +14 -14
- package/bin/chat/channels/telegram/Bot.js.map +1 -1
- package/bin/chat/channels/telegram/BotInfo.js +1 -1
- package/bin/chat/channels/telegram/BotInfo.js.map +1 -1
- package/bin/chat/channels/telegram/ReplyContext.js +3 -3
- package/bin/chat/channels/telegram/ReplyContext.js.map +1 -1
- package/bin/chat/channels/telegram/Shared.js +3 -3
- package/bin/chat/channels/telegram/Shared.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/TelegramInbound.d.ts +3 -3
- package/bin/chat/channels/telegram/TelegramInbound.d.ts.map +1 -1
- package/bin/chat/channels/telegram/TelegramInbound.js +4 -4
- package/bin/chat/channels/telegram/TelegramInbound.js.map +1 -1
- package/bin/chat/channels/telegram/TelegramMessageHandler.d.ts +8 -8
- package/bin/chat/channels/telegram/TelegramMessageHandler.d.ts.map +1 -1
- package/bin/chat/channels/telegram/TelegramMessageHandler.js +25 -25
- package/bin/chat/channels/telegram/TelegramMessageHandler.js.map +1 -1
- package/bin/chat/channels/telegram/TelegramPendingUpdates.d.ts +2 -2
- package/bin/chat/channels/telegram/TelegramPendingUpdates.d.ts.map +1 -1
- package/bin/chat/channels/telegram/TelegramPendingUpdates.js +7 -7
- package/bin/chat/channels/telegram/TelegramPendingUpdates.js.map +1 -1
- package/bin/chat/channels/telegram/TelegramPlatformClient.d.ts +4 -4
- package/bin/chat/channels/telegram/TelegramPlatformClient.d.ts.map +1 -1
- package/bin/chat/channels/telegram/TelegramPlatformClient.js +7 -7
- package/bin/chat/channels/telegram/TelegramPlatformClient.js.map +1 -1
- package/bin/chat/config/ChatPluginConfig.d.ts +67 -0
- package/bin/chat/config/ChatPluginConfig.d.ts.map +1 -0
- package/bin/chat/config/ChatPluginConfig.js +237 -0
- package/bin/chat/config/ChatPluginConfig.js.map +1 -0
- package/bin/chat/runtime/ChannelContextStore.d.ts +21 -21
- package/bin/chat/runtime/ChannelContextStore.d.ts.map +1 -1
- package/bin/chat/runtime/ChannelContextStore.js +74 -74
- package/bin/chat/runtime/ChannelContextStore.js.map +1 -1
- package/bin/chat/runtime/ChatActionExecution.d.ts +23 -23
- package/bin/chat/runtime/ChatActionExecution.d.ts.map +1 -1
- package/bin/chat/runtime/ChatActionExecution.js +70 -70
- package/bin/chat/runtime/ChatActionExecution.js.map +1 -1
- package/bin/chat/runtime/ChatActionInput.js +19 -19
- package/bin/chat/runtime/ChatActionInput.js.map +1 -1
- package/bin/chat/runtime/ChatChannelActions.d.ts +4 -4
- package/bin/chat/runtime/ChatChannelActions.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelConfig.d.ts +4 -4
- package/bin/chat/runtime/ChatChannelConfig.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelConfig.js +9 -9
- package/bin/chat/runtime/ChatChannelConfig.js.map +1 -1
- package/bin/chat/runtime/ChatChannelCore.d.ts +11 -12
- package/bin/chat/runtime/ChatChannelCore.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelCore.js +5 -17
- package/bin/chat/runtime/ChatChannelCore.js.map +1 -1
- package/bin/chat/runtime/ChatChannelLifecycle.d.ts +3 -3
- package/bin/chat/runtime/ChatChannelLifecycle.d.ts.map +1 -1
- package/bin/chat/runtime/ChatChannelLifecycle.js +5 -5
- package/bin/chat/runtime/ChatChannelLifecycle.js.map +1 -1
- package/bin/chat/runtime/ChatHistoryStore.d.ts +11 -11
- package/bin/chat/runtime/ChatHistoryStore.d.ts.map +1 -1
- package/bin/chat/runtime/ChatHistoryStore.js +26 -26
- package/bin/chat/runtime/ChatHistoryStore.js.map +1 -1
- package/bin/chat/runtime/ChatIngressStore.d.ts +4 -4
- package/bin/chat/runtime/ChatIngressStore.d.ts.map +1 -1
- package/bin/chat/runtime/ChatIngressStore.js +2 -2
- package/bin/chat/runtime/ChatIngressStore.js.map +1 -1
- package/bin/chat/runtime/ChatMetaStore.d.ts +19 -19
- package/bin/chat/runtime/ChatMetaStore.d.ts.map +1 -1
- package/bin/chat/runtime/ChatMetaStore.js +27 -27
- package/bin/chat/runtime/ChatMetaStore.js.map +1 -1
- package/bin/chat/runtime/ChatPluginActionRegistry.d.ts.map +1 -1
- package/bin/chat/runtime/ChatPluginActionRegistry.js +53 -59
- package/bin/chat/runtime/ChatPluginActionRegistry.js.map +1 -1
- package/bin/chat/runtime/ChatPluginSystem.d.ts +4 -4
- package/bin/chat/runtime/ChatPluginSystem.d.ts.map +1 -1
- package/bin/chat/runtime/ChatPluginSystem.js +5 -5
- package/bin/chat/runtime/ChatPluginSystem.js.map +1 -1
- package/bin/chat/runtime/ChatQueueReplyDispatch.d.ts +6 -6
- package/bin/chat/runtime/ChatQueueReplyDispatch.d.ts.map +1 -1
- package/bin/chat/runtime/ChatQueueReplyDispatch.js +41 -41
- package/bin/chat/runtime/ChatQueueReplyDispatch.js.map +1 -1
- package/bin/chat/runtime/ChatQueueStore.d.ts +3 -3
- package/bin/chat/runtime/ChatQueueStore.d.ts.map +1 -1
- package/bin/chat/runtime/ChatQueueStore.js +2 -2
- package/bin/chat/runtime/ChatQueueStore.js.map +1 -1
- package/bin/chat/runtime/ChatQueueWorker.d.ts +2 -2
- package/bin/chat/runtime/ChatQueueWorker.d.ts.map +1 -1
- package/bin/chat/runtime/ChatQueueWorker.js +30 -32
- package/bin/chat/runtime/ChatQueueWorker.js.map +1 -1
- package/bin/chat/runtime/ChatQueueWorkerSupport.d.ts +1 -1
- package/bin/chat/runtime/ChatQueueWorkerSupport.js +15 -15
- package/bin/chat/runtime/ChatQueueWorkerSupport.js.map +1 -1
- package/bin/chat/runtime/ChatSendActionInput.js +51 -51
- package/bin/chat/runtime/ChatSendActionInput.js.map +1 -1
- package/bin/chat/runtime/ChatSendMetadata.d.ts +1 -1
- package/bin/chat/runtime/ChatSendMetadata.js +12 -12
- package/bin/chat/runtime/ChatSendMetadata.js.map +1 -1
- package/bin/chat/runtime/ChatSendRegistry.d.ts +1 -1
- package/bin/chat/runtime/ChatSessionDelete.d.ts +7 -7
- package/bin/chat/runtime/ChatSessionDelete.d.ts.map +1 -1
- package/bin/chat/runtime/ChatSessionDelete.js +15 -15
- package/bin/chat/runtime/ChatSessionDelete.js.map +1 -1
- package/bin/chat/runtime/ChatStorage.d.ts +1 -1
- package/bin/chat/runtime/ChatStorage.js +3 -3
- package/bin/chat/runtime/ChatStorage.js.map +1 -1
- package/bin/chat/runtime/ChatkeySend.d.ts +21 -21
- package/bin/chat/runtime/ChatkeySend.d.ts.map +1 -1
- package/bin/chat/runtime/ChatkeySend.js +33 -33
- package/bin/chat/runtime/ChatkeySend.js.map +1 -1
- package/bin/chat/runtime/DirectDispatchParser.d.ts +2 -2
- package/bin/chat/runtime/DirectDispatchParser.js +20 -20
- package/bin/chat/runtime/DirectDispatchParser.js.map +1 -1
- package/bin/chat/runtime/EnqueueDispatch.d.ts +3 -3
- package/bin/chat/runtime/EnqueueDispatch.d.ts.map +1 -1
- package/bin/chat/runtime/InboundAugment.d.ts +3 -3
- package/bin/chat/runtime/InboundAugment.d.ts.map +1 -1
- package/bin/chat/runtime/InboundAugment.js +6 -6
- package/bin/chat/runtime/InboundAugment.js.map +1 -1
- package/bin/chat/runtime/QueuedUserMessage.js +5 -5
- package/bin/chat/runtime/QueuedUserMessage.js.map +1 -1
- package/bin/chat/runtime/ReplyContextFormatter.js +7 -7
- package/bin/chat/runtime/ReplyContextFormatter.js.map +1 -1
- package/bin/chat/runtime/ReplyDispatch.d.ts +7 -7
- package/bin/chat/runtime/ReplyDispatch.d.ts.map +1 -1
- package/bin/chat/runtime/ReplyDispatch.js +3 -3
- package/bin/chat/runtime/ReplyDispatch.js.map +1 -1
- package/bin/chat/runtime/SystemPrompt.d.ts +4 -4
- package/bin/chat/runtime/SystemPrompt.d.ts.map +1 -1
- package/bin/chat/runtime/SystemPrompt.js +10 -10
- package/bin/chat/runtime/SystemPrompt.js.map +1 -1
- package/bin/chat/types/ChannelContext.d.ts +11 -11
- package/bin/chat/types/ChannelContext.d.ts.map +1 -1
- package/bin/chat/types/ChannelContext.js +2 -2
- package/bin/chat/types/ChatCommand.d.ts +31 -31
- package/bin/chat/types/ChatCommand.d.ts.map +1 -1
- package/bin/chat/types/ChatDispatcher.d.ts +3 -3
- package/bin/chat/types/ChatDispatcher.d.ts.map +1 -1
- package/bin/chat/types/ChatHistory.d.ts +2 -2
- package/bin/chat/types/ChatHistory.d.ts.map +1 -1
- package/bin/chat/types/ChatMeta.d.ts +4 -4
- package/bin/chat/types/ChatMeta.d.ts.map +1 -1
- package/bin/chat/types/ChatMeta.js +1 -1
- package/bin/chat/types/ChatPlugin.d.ts +9 -9
- package/bin/chat/types/ChatPlugin.d.ts.map +1 -1
- package/bin/chat/types/ChatPluginActionPayload.d.ts +13 -13
- package/bin/chat/types/ChatPluginActionPayload.d.ts.map +1 -1
- package/bin/chat/types/ChatPluginOptions.d.ts +6 -6
- package/bin/chat/types/ChatPluginOptions.d.ts.map +1 -1
- package/bin/chat/types/ChatPluginResource.d.ts +68 -0
- package/bin/chat/types/ChatPluginResource.d.ts.map +1 -0
- package/bin/chat/types/ChatPluginResource.js +10 -0
- package/bin/chat/types/ChatPluginResource.js.map +1 -0
- package/bin/chat/types/ChatPromptContext.d.ts +8 -8
- package/bin/chat/types/ChatPromptContext.d.ts.map +1 -1
- package/bin/chat/types/ChatQueue.d.ts +2 -2
- package/bin/chat/types/ChatQueue.d.ts.map +1 -1
- package/bin/chat/types/ChatQueueWorker.d.ts +3 -3
- package/bin/chat/types/ChatQueueWorker.d.ts.map +1 -1
- package/bin/chat/types/ChatRuntimeAccount.d.ts +39 -0
- package/bin/chat/types/ChatRuntimeAccount.d.ts.map +1 -0
- package/bin/chat/types/ChatRuntimeAccount.js +10 -0
- package/bin/chat/types/ChatRuntimeAccount.js.map +1 -0
- package/bin/chat/types/DirectDispatch.d.ts +13 -13
- package/bin/chat/types/DirectDispatch.d.ts.map +1 -1
- package/bin/chat/types/DirectDispatch.js +1 -1
- package/bin/chat/types/FeishuInboundAttachment.d.ts +1 -1
- package/bin/chat/types/FeishuInboundAttachment.d.ts.map +1 -1
- package/bin/chat/types/QqInboundDedupe.d.ts +1 -1
- package/bin/chat/types/QqInboundDedupe.d.ts.map +1 -1
- package/bin/chat/types/ReplyContext.d.ts +1 -1
- package/bin/chat/types/ReplyContext.d.ts.map +1 -1
- package/bin/chat.d.ts +4 -3
- package/bin/chat.d.ts.map +1 -1
- package/bin/chat.js +2 -2
- package/bin/chat.js.map +1 -1
- package/bin/contact/Action.d.ts +11 -11
- package/bin/contact/Action.d.ts.map +1 -1
- package/bin/contact/Action.js +27 -27
- package/bin/contact/Action.js.map +1 -1
- package/bin/contact/ContactPlugin.js +33 -33
- package/bin/contact/ContactPlugin.js.map +1 -1
- package/bin/contact/runtime/ChatRuntime.d.ts +2 -2
- package/bin/contact/runtime/ChatRuntime.d.ts.map +1 -1
- package/bin/contact/runtime/ChatRuntime.js +8 -23
- 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 +24 -24
- package/bin/contact/runtime/ContactStore.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 +17 -17
- package/bin/contact/runtime/LinkApproval.js.map +1 -1
- package/bin/contact/runtime/LinkCode.d.ts +1 -1
- package/bin/contact/runtime/LinkCode.d.ts.map +1 -1
- package/bin/contact/runtime/LinkCode.js +6 -6
- package/bin/contact/runtime/LinkCode.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 +7 -7
- package/bin/contact/runtime/LinkStore.js.map +1 -1
- package/bin/contact/runtime/Paths.d.ts +14 -14
- package/bin/contact/runtime/Paths.d.ts.map +1 -1
- package/bin/contact/runtime/Paths.js +28 -28
- package/bin/contact/runtime/Paths.js.map +1 -1
- package/bin/contact/runtime/RemoteClient.d.ts +1 -1
- package/bin/contact/runtime/RemoteClient.js +18 -18
- package/bin/contact/runtime/RemoteClient.js.map +1 -1
- package/bin/contact/runtime/ShareBundle.d.ts +3 -3
- package/bin/contact/runtime/ShareBundle.d.ts.map +1 -1
- package/bin/contact/runtime/ShareBundle.js +5 -5
- package/bin/contact/runtime/ShareBundle.js.map +1 -1
- package/bin/contact/types/Contact.d.ts +2 -2
- package/bin/contact/types/Contact.d.ts.map +1 -1
- package/bin/contact/types/ContactApproval.d.ts +2 -2
- package/bin/contact/types/ContactApproval.d.ts.map +1 -1
- package/bin/contact/types/ContactChat.d.ts +1 -1
- package/bin/contact/types/ContactChat.d.ts.map +1 -1
- package/bin/contact/types/ContactLink.d.ts +4 -4
- package/bin/contact/types/ContactLink.d.ts.map +1 -1
- package/bin/image/ImagePlugin.d.ts +3 -3
- package/bin/image/ImagePlugin.d.ts.map +1 -1
- package/bin/image/ImagePlugin.js +25 -10
- package/bin/image/ImagePlugin.js.map +1 -1
- package/bin/image/types/ImagePlugin.d.ts +3 -3
- package/bin/image/types/ImagePlugin.d.ts.map +1 -1
- package/bin/image/types/ImagePlugin.js +1 -1
- package/bin/memory/Action.d.ts +7 -7
- package/bin/memory/Action.d.ts.map +1 -1
- package/bin/memory/Action.js +11 -11
- package/bin/memory/Action.js.map +1 -1
- package/bin/memory/MemoryPlugin.d.ts +3 -3
- package/bin/memory/MemoryPlugin.d.ts.map +1 -1
- package/bin/memory/MemoryPlugin.js +21 -21
- package/bin/memory/MemoryPlugin.js.map +1 -1
- package/bin/memory/runtime/Search.d.ts +3 -3
- package/bin/memory/runtime/Search.d.ts.map +1 -1
- package/bin/memory/runtime/Search.js +2 -2
- package/bin/memory/runtime/Search.js.map +1 -1
- package/bin/memory/runtime/Store.d.ts +2 -2
- package/bin/memory/runtime/Store.d.ts.map +1 -1
- package/bin/memory/runtime/Store.js +1 -1
- package/bin/memory/runtime/Store.js.map +1 -1
- package/bin/memory/runtime/SystemProvider.d.ts +3 -3
- package/bin/memory/runtime/SystemProvider.d.ts.map +1 -1
- package/bin/memory/runtime/SystemProvider.js +1 -1
- package/bin/memory/runtime/SystemProvider.js.map +1 -1
- package/bin/memory/runtime/Writer.d.ts +8 -8
- package/bin/memory/runtime/Writer.d.ts.map +1 -1
- package/bin/memory/runtime/Writer.js +14 -14
- package/bin/memory/runtime/Writer.js.map +1 -1
- package/bin/memory/types/Memory.d.ts +3 -3
- package/bin/memory/types/Memory.d.ts.map +1 -1
- package/bin/skill/Action.d.ts +4 -4
- package/bin/skill/Action.d.ts.map +1 -1
- package/bin/skill/Action.js +9 -9
- package/bin/skill/Action.js.map +1 -1
- package/bin/skill/Plugin.js +16 -16
- package/bin/skill/Plugin.js.map +1 -1
- package/bin/skill/runtime/Discovery.d.ts +2 -2
- package/bin/skill/runtime/Discovery.d.ts.map +1 -1
- package/bin/skill/runtime/Discovery.js +3 -3
- package/bin/skill/runtime/Discovery.js.map +1 -1
- package/bin/skill/runtime/Paths.d.ts +1 -1
- package/bin/skill/runtime/Paths.d.ts.map +1 -1
- package/bin/skill/runtime/Paths.js +6 -6
- package/bin/skill/runtime/Paths.js.map +1 -1
- package/bin/skill/runtime/Store.d.ts +3 -3
- package/bin/skill/runtime/Store.d.ts.map +1 -1
- package/bin/skill/runtime/Store.js +19 -19
- package/bin/skill/runtime/Store.js.map +1 -1
- package/bin/skill/runtime/SystemProvider.d.ts +2 -2
- package/bin/skill/runtime/SystemProvider.d.ts.map +1 -1
- package/bin/skill/runtime/SystemProvider.js +4 -4
- package/bin/skill/runtime/SystemProvider.js.map +1 -1
- package/bin/skill/runtime/Types.d.ts +3 -3
- package/bin/skill/runtime/Types.d.ts.map +1 -1
- package/bin/sound/Plugin.d.ts +5 -5
- package/bin/sound/Plugin.d.ts.map +1 -1
- package/bin/sound/Plugin.js +23 -11
- package/bin/sound/Plugin.js.map +1 -1
- package/bin/task/Action.d.ts +10 -10
- package/bin/task/Action.d.ts.map +1 -1
- package/bin/task/Action.js +31 -31
- 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.d.ts +2 -2
- package/bin/task/Scheduler.d.ts.map +1 -1
- package/bin/task/Scheduler.js +8 -8
- package/bin/task/Scheduler.js.map +1 -1
- package/bin/task/TaskPlugin.d.ts +3 -3
- package/bin/task/TaskPlugin.d.ts.map +1 -1
- package/bin/task/TaskPlugin.js +23 -20
- package/bin/task/TaskPlugin.js.map +1 -1
- package/bin/task/runtime/Model.d.ts +2 -2
- package/bin/task/runtime/Model.d.ts.map +1 -1
- package/bin/task/runtime/Model.js +11 -11
- package/bin/task/runtime/Model.js.map +1 -1
- package/bin/task/runtime/Paths.d.ts +6 -6
- 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 +4 -4
- package/bin/task/runtime/Runner.d.ts.map +1 -1
- package/bin/task/runtime/Runner.js +17 -17
- package/bin/task/runtime/Runner.js.map +1 -1
- package/bin/task/runtime/Store.d.ts +7 -7
- package/bin/task/runtime/Store.d.ts.map +1 -1
- package/bin/task/runtime/Store.js +15 -15
- package/bin/task/runtime/Store.js.map +1 -1
- package/bin/task/runtime/TaskActionExecution.d.ts +12 -12
- package/bin/task/runtime/TaskActionExecution.d.ts.map +1 -1
- package/bin/task/runtime/TaskActionExecution.js +7 -7
- package/bin/task/runtime/TaskActionExecution.js.map +1 -1
- package/bin/task/runtime/TaskActionInput.js +10 -10
- package/bin/task/runtime/TaskActionInput.js.map +1 -1
- package/bin/task/runtime/TaskPluginActionRegistry.js +26 -26
- package/bin/task/runtime/TaskPluginActionRegistry.js.map +1 -1
- package/bin/task/runtime/TaskRunArtifacts.js +4 -4
- package/bin/task/runtime/TaskRunArtifacts.js.map +1 -1
- package/bin/task/runtime/TaskRunChatDispatch.d.ts +2 -2
- package/bin/task/runtime/TaskRunChatDispatch.d.ts.map +1 -1
- package/bin/task/runtime/TaskRunChatDispatch.js +7 -7
- package/bin/task/runtime/TaskRunChatDispatch.js.map +1 -1
- package/bin/task/runtime/TaskRunnerProgress.js +1 -1
- package/bin/task/runtime/TaskRunnerProgress.js.map +1 -1
- package/bin/task/runtime/TaskRunnerRound.d.ts +7 -7
- package/bin/task/runtime/TaskRunnerRound.d.ts.map +1 -1
- package/bin/task/runtime/TaskRunnerRound.js +34 -38
- package/bin/task/runtime/TaskRunnerRound.js.map +1 -1
- package/bin/task/runtime/TaskRunnerScript.d.ts +4 -4
- package/bin/task/runtime/TaskRunnerScript.d.ts.map +1 -1
- package/bin/task/runtime/TaskRunnerScript.js +1 -1
- package/bin/task/runtime/TaskRunnerScript.js.map +1 -1
- package/bin/task/runtime/TaskRunnerSession.d.ts +8 -8
- package/bin/task/runtime/TaskRunnerSession.d.ts.map +1 -1
- package/bin/task/runtime/TaskRunnerSession.js +52 -39
- package/bin/task/runtime/TaskRunnerSession.js.map +1 -1
- package/bin/task/runtime/TaskRunnerTypes.d.ts +5 -5
- package/bin/task/runtime/TaskRunnerTypes.d.ts.map +1 -1
- package/bin/task/types/Task.d.ts +4 -4
- package/bin/task/types/Task.d.ts.map +1 -1
- package/bin/task/types/TaskCommand.d.ts +3 -3
- package/bin/task/types/TaskCommand.d.ts.map +1 -1
- package/bin/web/Plugin.d.ts +2 -2
- package/bin/web/Plugin.d.ts.map +1 -1
- package/bin/web/Plugin.js +3 -3
- package/bin/web/Plugin.js.map +1 -1
- package/bin/workboard/Plugin.d.ts.map +1 -1
- package/bin/workboard/Plugin.js +6 -7
- package/bin/workboard/Plugin.js.map +1 -1
- package/bin/workboard/runtime/Collector.d.ts +2 -2
- package/bin/workboard/runtime/Collector.d.ts.map +1 -1
- package/bin/workboard/runtime/Collector.js +4 -4
- package/bin/workboard/runtime/Collector.js.map +1 -1
- package/bin/workboard/runtime/Normalizer.d.ts +3 -3
- package/bin/workboard/runtime/Normalizer.d.ts.map +1 -1
- package/bin/workboard/runtime/Normalizer.js +11 -11
- package/bin/workboard/runtime/Normalizer.js.map +1 -1
- package/bin/workboard/runtime/SessionSummary.d.ts +5 -5
- package/bin/workboard/runtime/SessionSummary.d.ts.map +1 -1
- package/bin/workboard/runtime/SessionSummary.js +4 -4
- package/bin/workboard/runtime/SessionSummary.js.map +1 -1
- package/bin/workboard/runtime/Store.d.ts +5 -5
- package/bin/workboard/runtime/Store.d.ts.map +1 -1
- package/bin/workboard/runtime/Store.js.map +1 -1
- package/bin/workboard/types/Workboard.d.ts +2 -2
- package/bin/workboard/types/Workboard.d.ts.map +1 -1
- package/bin/workboard/types/Workboard.js +1 -1
- package/package.json +3 -3
- package/scripts/chat-access.test.mjs +2 -2
- package/scripts/chat-channel-config.test.mjs +25 -3
- package/scripts/chat-storage.test.mjs +7 -7
- package/scripts/skill-plugin.test.mjs +4 -4
- package/scripts/sound-plugin.test.mjs +12 -8
- package/scripts/web-plugin.test.mjs +4 -4
- package/src/chat/Action.ts +154 -153
- package/src/chat/ChatPlugin.ts +12 -12
- package/src/chat/Index.ts +12 -0
- package/src/chat/PROMPT.direct.ts +1 -1
- package/src/chat/access/ChatAccessActions.ts +6 -6
- package/src/chat/access/ChatAccessRuntime.ts +5 -5
- package/src/chat/access/ChatAccessStore.ts +5 -5
- package/src/chat/channels/BaseChatChannel.ts +32 -32
- package/src/chat/channels/BaseChatChannelQueue.ts +38 -38
- package/src/chat/channels/BaseChatChannelSupport.ts +25 -25
- package/src/chat/channels/RuntimeChannel.ts +53 -74
- package/src/chat/channels/feishu/Feishu.ts +35 -35
- package/src/chat/channels/feishu/FeishuInbound.ts +3 -3
- package/src/chat/channels/feishu/FeishuMessageHandler.ts +29 -29
- package/src/chat/channels/feishu/FeishuPlatformClient.ts +15 -15
- package/src/chat/channels/feishu/FeishuPlatformLookup.ts +7 -7
- package/src/chat/channels/feishu/FeishuPlatformMessaging.ts +7 -7
- package/src/chat/channels/feishu/InboundAttachment.ts +6 -6
- package/src/chat/channels/feishu/PostMessage.ts +8 -8
- package/src/chat/channels/feishu/ReplyContext.ts +3 -3
- package/src/chat/channels/feishu/Shared.ts +3 -3
- package/src/chat/channels/qq/PROMPT.direct.ts +1 -1
- package/src/chat/channels/qq/QQ.ts +26 -26
- package/src/chat/channels/qq/QQEventCapture.ts +3 -3
- package/src/chat/channels/qq/QQGatewayAuth.ts +1 -1
- package/src/chat/channels/qq/QQGatewayClient.ts +12 -12
- package/src/chat/channels/qq/QQGatewayConnection.ts +1 -1
- package/src/chat/channels/qq/QQGatewaySend.ts +6 -6
- package/src/chat/channels/qq/QQInbound.ts +5 -5
- package/src/chat/channels/qq/QQInboundDedupe.ts +6 -6
- package/src/chat/channels/qq/QQMessageHandler.ts +43 -43
- package/src/chat/channels/qq/QQSendSupport.ts +2 -2
- package/src/chat/channels/qq/QQSupport.ts +10 -10
- package/src/chat/channels/qq/types/QqChannel.ts +1 -1
- package/src/chat/channels/telegram/ApiClient.ts +7 -7
- package/src/chat/channels/telegram/Bot.ts +17 -17
- package/src/chat/channels/telegram/BotInfo.ts +1 -1
- package/src/chat/channels/telegram/ReplyContext.ts +3 -3
- package/src/chat/channels/telegram/Shared.ts +3 -3
- package/src/chat/channels/telegram/StateStore.ts +2 -2
- package/src/chat/channels/telegram/TelegramInbound.ts +4 -4
- package/src/chat/channels/telegram/TelegramMessageHandler.ts +35 -35
- package/src/chat/channels/telegram/TelegramPendingUpdates.ts +9 -9
- package/src/chat/channels/telegram/TelegramPlatformClient.ts +11 -11
- package/src/chat/config/ChatPluginConfig.ts +266 -0
- package/src/chat/runtime/ChannelContextStore.ts +88 -88
- package/src/chat/runtime/ChatActionExecution.ts +87 -87
- package/src/chat/runtime/ChatActionInput.ts +19 -19
- package/src/chat/runtime/ChatChannelActions.ts +4 -4
- package/src/chat/runtime/ChatChannelConfig.ts +14 -14
- package/src/chat/runtime/ChatChannelCore.ts +17 -26
- package/src/chat/runtime/ChatChannelLifecycle.ts +12 -12
- package/src/chat/runtime/ChatHistoryStore.ts +39 -39
- package/src/chat/runtime/ChatIngressStore.ts +6 -6
- package/src/chat/runtime/ChatMetaStore.ts +37 -37
- package/src/chat/runtime/ChatPluginActionRegistry.ts +56 -62
- package/src/chat/runtime/ChatPluginSystem.ts +9 -9
- package/src/chat/runtime/ChatQueueReplyDispatch.ts +47 -47
- package/src/chat/runtime/ChatQueueStore.ts +4 -4
- package/src/chat/runtime/ChatQueueWorker.ts +38 -44
- package/src/chat/runtime/ChatQueueWorkerSupport.ts +18 -18
- package/src/chat/runtime/ChatSendActionInput.ts +53 -53
- package/src/chat/runtime/ChatSendMetadata.ts +15 -15
- package/src/chat/runtime/ChatSendRegistry.ts +1 -1
- package/src/chat/runtime/ChatSessionDelete.ts +19 -19
- package/src/chat/runtime/ChatStorage.ts +3 -3
- package/src/chat/runtime/ChatkeySend.ts +43 -43
- package/src/chat/runtime/DirectDispatchParser.ts +21 -21
- package/src/chat/runtime/EnqueueDispatch.ts +3 -3
- package/src/chat/runtime/InboundAugment.ts +8 -8
- package/src/chat/runtime/QueuedUserMessage.ts +6 -6
- package/src/chat/runtime/ReplyContextFormatter.ts +6 -6
- package/src/chat/runtime/ReplyDispatch.ts +9 -9
- package/src/chat/runtime/SystemPrompt.ts +14 -14
- package/src/chat/types/ChannelContext.ts +11 -11
- package/src/chat/types/ChatCommand.ts +31 -31
- package/src/chat/types/ChatDispatcher.ts +3 -3
- package/src/chat/types/ChatHistory.ts +2 -2
- package/src/chat/types/ChatMeta.ts +4 -4
- package/src/chat/types/ChatPlugin.ts +9 -9
- package/src/chat/types/ChatPluginActionPayload.ts +13 -13
- package/src/chat/types/ChatPluginOptions.ts +6 -6
- package/src/chat/types/ChatPluginResource.ts +95 -0
- package/src/chat/types/ChatPromptContext.ts +8 -8
- package/src/chat/types/ChatQueue.ts +2 -2
- package/src/chat/types/ChatQueueWorker.ts +3 -3
- package/src/chat/types/ChatRuntimeAccount.ts +52 -0
- package/src/chat/types/DirectDispatch.ts +13 -13
- package/src/chat/types/FeishuInboundAttachment.ts +1 -1
- package/src/chat/types/QqInboundDedupe.ts +1 -1
- package/src/chat/types/ReplyContext.ts +1 -1
- package/src/chat.ts +13 -3
- package/src/contact/Action.ts +40 -40
- package/src/contact/ContactPlugin.ts +49 -49
- package/src/contact/runtime/ChatRuntime.ts +10 -26
- package/src/contact/runtime/ContactStore.ts +24 -24
- package/src/contact/runtime/InboxStore.ts +16 -16
- package/src/contact/runtime/LinkApproval.ts +19 -19
- package/src/contact/runtime/LinkCode.ts +7 -7
- package/src/contact/runtime/LinkStore.ts +7 -7
- package/src/contact/runtime/Paths.ts +28 -28
- package/src/contact/runtime/RemoteClient.ts +19 -19
- package/src/contact/runtime/ShareBundle.ts +8 -8
- package/src/contact/types/Contact.ts +2 -2
- package/src/contact/types/ContactApproval.ts +2 -2
- package/src/contact/types/ContactChat.ts +1 -1
- package/src/contact/types/ContactLink.ts +4 -4
- package/src/image/ImagePlugin.ts +32 -16
- package/src/image/types/ImagePlugin.ts +3 -3
- package/src/memory/Action.ts +18 -18
- package/src/memory/MemoryPlugin.ts +25 -25
- package/src/memory/runtime/Search.ts +6 -6
- package/src/memory/runtime/Store.ts +3 -3
- package/src/memory/runtime/SystemProvider.ts +4 -4
- package/src/memory/runtime/Writer.ts +24 -24
- package/src/memory/types/Memory.ts +3 -3
- package/src/skill/Action.ts +10 -10
- package/src/skill/Plugin.ts +16 -16
- package/src/skill/runtime/Discovery.ts +3 -3
- package/src/skill/runtime/Paths.ts +6 -6
- package/src/skill/runtime/Store.ts +19 -19
- package/src/skill/runtime/SystemProvider.ts +5 -5
- package/src/skill/runtime/Types.ts +3 -3
- package/src/sound/Plugin.ts +31 -18
- package/src/task/Action.ts +40 -40
- package/src/task/PROMPT.ts +1 -1
- package/src/task/Scheduler.ts +10 -10
- package/src/task/TaskPlugin.ts +32 -30
- package/src/task/runtime/Model.ts +12 -12
- package/src/task/runtime/Paths.ts +11 -11
- package/src/task/runtime/Runner.ts +21 -21
- package/src/task/runtime/Store.ts +21 -21
- package/src/task/runtime/TaskActionExecution.ts +19 -19
- package/src/task/runtime/TaskActionInput.ts +10 -10
- package/src/task/runtime/TaskPluginActionRegistry.ts +27 -27
- package/src/task/runtime/TaskRunArtifacts.ts +4 -4
- package/src/task/runtime/TaskRunChatDispatch.ts +9 -9
- package/src/task/runtime/TaskRunnerProgress.ts +1 -1
- package/src/task/runtime/TaskRunnerRound.ts +47 -42
- package/src/task/runtime/TaskRunnerScript.ts +5 -5
- package/src/task/runtime/TaskRunnerSession.ts +58 -46
- package/src/task/runtime/TaskRunnerTypes.ts +5 -5
- package/src/task/types/Task.ts +4 -4
- package/src/task/types/TaskCommand.ts +3 -3
- package/src/web/Plugin.ts +5 -5
- package/src/workboard/Plugin.ts +8 -9
- package/src/workboard/runtime/Collector.ts +6 -6
- package/src/workboard/runtime/Normalizer.ts +14 -14
- package/src/workboard/runtime/SessionSummary.ts +9 -9
- package/src/workboard/runtime/Store.ts +6 -6
- package/src/workboard/types/Workboard.ts +2 -2
- package/bin/chat/accounts/ChannelAccountManager.d.ts +0 -61
- package/bin/chat/accounts/ChannelAccountManager.d.ts.map +0 -1
- package/bin/chat/accounts/ChannelAccountManager.js +0 -264
- package/bin/chat/accounts/ChannelAccountManager.js.map +0 -1
- package/bin/chat/accounts/Crypto.d.ts +0 -20
- package/bin/chat/accounts/Crypto.d.ts.map +0 -1
- package/bin/chat/accounts/Crypto.js +0 -75
- package/bin/chat/accounts/Crypto.js.map +0 -1
- package/bin/chat/accounts/Store.d.ts +0 -38
- package/bin/chat/accounts/Store.d.ts.map +0 -1
- package/bin/chat/accounts/Store.js +0 -220
- package/bin/chat/accounts/Store.js.map +0 -1
- package/bin/chat/channels/Configuration.d.ts +0 -27
- package/bin/chat/channels/Configuration.d.ts.map +0 -1
- package/bin/chat/channels/Configuration.js +0 -19
- package/bin/chat/channels/Configuration.js.map +0 -1
- package/bin/chat/channels/ConfigurationRegistry.d.ts +0 -18
- package/bin/chat/channels/ConfigurationRegistry.d.ts.map +0 -1
- package/bin/chat/channels/ConfigurationRegistry.js +0 -31
- package/bin/chat/channels/ConfigurationRegistry.js.map +0 -1
- package/bin/chat/channels/feishu/Configuration.d.ts +0 -17
- package/bin/chat/channels/feishu/Configuration.d.ts.map +0 -1
- package/bin/chat/channels/feishu/Configuration.js +0 -59
- package/bin/chat/channels/feishu/Configuration.js.map +0 -1
- package/bin/chat/channels/qq/Configuration.d.ts +0 -17
- package/bin/chat/channels/qq/Configuration.d.ts.map +0 -1
- package/bin/chat/channels/qq/Configuration.js +0 -59
- package/bin/chat/channels/qq/Configuration.js.map +0 -1
- package/bin/chat/channels/telegram/Configuration.d.ts +0 -17
- package/bin/chat/channels/telegram/Configuration.d.ts.map +0 -1
- package/bin/chat/channels/telegram/Configuration.js +0 -59
- package/bin/chat/channels/telegram/Configuration.js.map +0 -1
- package/bin/chat/types/ChannelAccount.d.ts +0 -226
- package/bin/chat/types/ChannelAccount.d.ts.map +0 -1
- package/bin/chat/types/ChannelAccount.js +0 -9
- package/bin/chat/types/ChannelAccount.js.map +0 -1
- package/bin/chat/types/ChannelConfiguration.d.ts +0 -146
- package/bin/chat/types/ChannelConfiguration.d.ts.map +0 -1
- package/bin/chat/types/ChannelConfiguration.js +0 -9
- package/bin/chat/types/ChannelConfiguration.js.map +0 -1
- package/src/chat/accounts/ChannelAccountManager.ts +0 -314
- package/src/chat/accounts/Crypto.ts +0 -83
- package/src/chat/accounts/Store.ts +0 -287
- package/src/chat/channels/Configuration.ts +0 -35
- package/src/chat/channels/ConfigurationRegistry.ts +0 -43
- package/src/chat/channels/feishu/Configuration.ts +0 -65
- package/src/chat/channels/qq/Configuration.ts +0 -64
- package/src/chat/channels/telegram/Configuration.ts +0 -65
- package/src/chat/types/ChannelAccount.ts +0 -232
- package/src/chat/types/ChannelConfiguration.ts +0 -160
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chat account 管理器。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 统一封装 agent 运行时下 chat account 的 CRUD 与探测。
|
|
6
|
-
* - 账号凭据只在写入路径接收明文;列表与读取路径返回脱敏结果。
|
|
7
|
-
* - city / vibecape 等上层产品都应直接复用这个实现,而不是各自维护副本。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import crypto from "node:crypto";
|
|
11
|
-
import type { StoredChannelAccountChannel } from "@downcity/agent";
|
|
12
|
-
import { resolveChatChannelBotInfo } from "@/chat/channels/BotInfoProvider.js";
|
|
13
|
-
import {
|
|
14
|
-
getStoredChannelAccountSync,
|
|
15
|
-
listStoredChannelAccountsSync,
|
|
16
|
-
normalizeChannelAccountChannel,
|
|
17
|
-
removeStoredChannelAccount,
|
|
18
|
-
upsertStoredChannelAccount,
|
|
19
|
-
} from "./Store.js";
|
|
20
|
-
import type {
|
|
21
|
-
ChatChannelAccountCreateInput,
|
|
22
|
-
ChatChannelAccountListItem,
|
|
23
|
-
ChatChannelAccountListResult,
|
|
24
|
-
ChatChannelAccountProbeResult,
|
|
25
|
-
ChatChannelAccountUpsertInput,
|
|
26
|
-
} from "@/chat/types/ChannelAccount.js";
|
|
27
|
-
import type { StoredChannelAccount } from "@downcity/agent";
|
|
28
|
-
|
|
29
|
-
const SUPPORTED_CHANNELS: readonly StoredChannelAccountChannel[] = [
|
|
30
|
-
"telegram",
|
|
31
|
-
"feishu",
|
|
32
|
-
"qq",
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
function maskSecret(value: string | undefined): string {
|
|
36
|
-
const raw = String(value || "").trim();
|
|
37
|
-
if (!raw) return "";
|
|
38
|
-
if (raw.length <= 8) return "***";
|
|
39
|
-
return `${raw.slice(0, 4)}***${raw.slice(-4)}`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function assertChannel(input: string): StoredChannelAccountChannel {
|
|
43
|
-
const channel = String(input || "").trim().toLowerCase() as StoredChannelAccountChannel;
|
|
44
|
-
if (!SUPPORTED_CHANNELS.includes(channel)) {
|
|
45
|
-
throw new Error(
|
|
46
|
-
`Unsupported channel: ${input}. Supported: ${SUPPORTED_CHANNELS.join(", ")}`,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return channel;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function normalizeOptionalText(value: unknown): string | undefined {
|
|
53
|
-
const text = String(value || "").trim();
|
|
54
|
-
return text || undefined;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function normalizeChannelAccountIdToken(value: string): string {
|
|
58
|
-
const token = String(value || "")
|
|
59
|
-
.trim()
|
|
60
|
-
.toLowerCase()
|
|
61
|
-
.replace(/[^a-z0-9_-]+/g, "-")
|
|
62
|
-
.replace(/-+/g, "-")
|
|
63
|
-
.replace(/^-+/, "")
|
|
64
|
-
.replace(/-+$/, "");
|
|
65
|
-
return token || "bot";
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function pickFirstNonEmpty(inputs: unknown[]): string {
|
|
69
|
-
for (const input of inputs) {
|
|
70
|
-
const text = String(input || "").trim();
|
|
71
|
-
if (text) return text;
|
|
72
|
-
}
|
|
73
|
-
return "";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* ChatChannelAccountManager。
|
|
78
|
-
*/
|
|
79
|
-
export class ChatChannelAccountManager {
|
|
80
|
-
constructor() {}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 生成唯一 chat account id。
|
|
84
|
-
*
|
|
85
|
-
* 关键点(中文)
|
|
86
|
-
* - 账号 id 统一由系统生成,避免用户手填导致冲突或命名不一致。
|
|
87
|
-
* - 若碰撞则自动追加随机后缀重试。
|
|
88
|
-
*/
|
|
89
|
-
private async generateUniqueAccountId(params: {
|
|
90
|
-
channel: StoredChannelAccountChannel;
|
|
91
|
-
seed?: string;
|
|
92
|
-
}): Promise<string> {
|
|
93
|
-
const seed = normalizeChannelAccountIdToken(params.seed || "");
|
|
94
|
-
const prefix = `${params.channel}-${seed}`.slice(0, 36);
|
|
95
|
-
for (let index = 0; index < 8; index += 1) {
|
|
96
|
-
const suffix = crypto.randomBytes(3).toString("hex");
|
|
97
|
-
const candidate = `${prefix}-${suffix}`.slice(0, 64);
|
|
98
|
-
const existing = getStoredChannelAccountSync(candidate);
|
|
99
|
-
if (!existing) return candidate;
|
|
100
|
-
}
|
|
101
|
-
return `${params.channel}-${Date.now().toString(36)}`;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* 探测 bot 凭据并返回自动填充信息。
|
|
106
|
-
*/
|
|
107
|
-
async probe(input: {
|
|
108
|
-
channel: string;
|
|
109
|
-
botToken?: string;
|
|
110
|
-
appId?: string;
|
|
111
|
-
appSecret?: string;
|
|
112
|
-
domain?: string;
|
|
113
|
-
sandbox?: boolean;
|
|
114
|
-
}): Promise<ChatChannelAccountProbeResult> {
|
|
115
|
-
const channel = assertChannel(input.channel);
|
|
116
|
-
const botInfo = await resolveChatChannelBotInfo({
|
|
117
|
-
channel,
|
|
118
|
-
credentials: {
|
|
119
|
-
botToken: normalizeOptionalText(input.botToken),
|
|
120
|
-
appId: normalizeOptionalText(input.appId),
|
|
121
|
-
appSecret: normalizeOptionalText(input.appSecret),
|
|
122
|
-
domain: normalizeOptionalText(input.domain),
|
|
123
|
-
sandbox: input.sandbox === true,
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
const accountId = await this.generateUniqueAccountId({
|
|
127
|
-
channel,
|
|
128
|
-
seed: pickFirstNonEmpty([
|
|
129
|
-
botInfo.idSeed,
|
|
130
|
-
botInfo.botUserId,
|
|
131
|
-
botInfo.identity,
|
|
132
|
-
botInfo.name,
|
|
133
|
-
"bot",
|
|
134
|
-
]),
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
channel,
|
|
139
|
-
accountId,
|
|
140
|
-
name: botInfo.name,
|
|
141
|
-
identity: botInfo.identity,
|
|
142
|
-
owner: botInfo.owner,
|
|
143
|
-
creator: botInfo.creator,
|
|
144
|
-
botUserId: botInfo.botUserId,
|
|
145
|
-
message: botInfo.message,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* 使用凭据创建账号。
|
|
151
|
-
*
|
|
152
|
-
* 关键点(中文)
|
|
153
|
-
* - 默认先尝试探测 bot 信息,成功时自动填充名称与身份。
|
|
154
|
-
* - 探测失败但用户提供了名称时,仍允许先保存,便于后续排障。
|
|
155
|
-
*/
|
|
156
|
-
async create(input: ChatChannelAccountCreateInput): Promise<{
|
|
157
|
-
id: string;
|
|
158
|
-
probed: boolean;
|
|
159
|
-
message?: string;
|
|
160
|
-
}> {
|
|
161
|
-
const channel = assertChannel(input.channel);
|
|
162
|
-
let probeResult: ChatChannelAccountProbeResult | null = null;
|
|
163
|
-
if (input.probe !== false) {
|
|
164
|
-
try {
|
|
165
|
-
probeResult = await this.probe({
|
|
166
|
-
channel,
|
|
167
|
-
botToken: input.botToken,
|
|
168
|
-
appId: input.appId,
|
|
169
|
-
appSecret: input.appSecret,
|
|
170
|
-
domain: input.domain,
|
|
171
|
-
sandbox: input.sandbox,
|
|
172
|
-
});
|
|
173
|
-
} catch (error) {
|
|
174
|
-
if (!normalizeOptionalText(input.name)) {
|
|
175
|
-
throw error;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const id =
|
|
181
|
-
probeResult?.accountId ||
|
|
182
|
-
(await this.generateUniqueAccountId({
|
|
183
|
-
channel,
|
|
184
|
-
seed: pickFirstNonEmpty([input.name, input.appId, "bot"]),
|
|
185
|
-
}));
|
|
186
|
-
const name = normalizeOptionalText(input.name) || probeResult?.name || `${channel} bot`;
|
|
187
|
-
|
|
188
|
-
await this.upsert({
|
|
189
|
-
id,
|
|
190
|
-
channel,
|
|
191
|
-
name,
|
|
192
|
-
identity: probeResult?.identity,
|
|
193
|
-
owner: probeResult?.owner,
|
|
194
|
-
creator: probeResult?.creator,
|
|
195
|
-
botToken: input.botToken,
|
|
196
|
-
appId: input.appId,
|
|
197
|
-
appSecret: input.appSecret,
|
|
198
|
-
domain: input.domain,
|
|
199
|
-
sandbox: input.sandbox,
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
return {
|
|
203
|
-
id,
|
|
204
|
-
probed: Boolean(probeResult),
|
|
205
|
-
message: probeResult?.message,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* 列出账户池(脱敏)。
|
|
211
|
-
*/
|
|
212
|
-
async list(): Promise<ChatChannelAccountListResult> {
|
|
213
|
-
return {
|
|
214
|
-
items: listStoredChannelAccountsSync().map((account) =>
|
|
215
|
-
toChannelAccountListItem(account),
|
|
216
|
-
),
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* 新增或更新账号。
|
|
222
|
-
*/
|
|
223
|
-
async upsert(input: ChatChannelAccountUpsertInput): Promise<{ id: string }> {
|
|
224
|
-
const id = String(input.id || "").trim();
|
|
225
|
-
if (!id) throw new Error("chat account id cannot be empty");
|
|
226
|
-
const name = String(input.name || "").trim();
|
|
227
|
-
if (!name) throw new Error("chat account name cannot be empty");
|
|
228
|
-
|
|
229
|
-
const channel = normalizeChannelAccountChannel(input.channel);
|
|
230
|
-
|
|
231
|
-
if (input.botToken !== undefined && input.clearBotToken === true) {
|
|
232
|
-
throw new Error("botToken and clearBotToken cannot be used together");
|
|
233
|
-
}
|
|
234
|
-
if (input.appId !== undefined && input.clearAppId === true) {
|
|
235
|
-
throw new Error("appId and clearAppId cannot be used together");
|
|
236
|
-
}
|
|
237
|
-
if (input.appSecret !== undefined && input.clearAppSecret === true) {
|
|
238
|
-
throw new Error("appSecret and clearAppSecret cannot be used together");
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const current = getStoredChannelAccountSync(id);
|
|
242
|
-
const nextBotToken = input.clearBotToken
|
|
243
|
-
? undefined
|
|
244
|
-
: input.botToken !== undefined
|
|
245
|
-
? normalizeOptionalText(input.botToken)
|
|
246
|
-
: current?.botToken;
|
|
247
|
-
const nextAppId = input.clearAppId
|
|
248
|
-
? undefined
|
|
249
|
-
: input.appId !== undefined
|
|
250
|
-
? normalizeOptionalText(input.appId)
|
|
251
|
-
: current?.appId;
|
|
252
|
-
const nextAppSecret = input.clearAppSecret
|
|
253
|
-
? undefined
|
|
254
|
-
: input.appSecret !== undefined
|
|
255
|
-
? normalizeOptionalText(input.appSecret)
|
|
256
|
-
: current?.appSecret;
|
|
257
|
-
const nextIdentity = Object.prototype.hasOwnProperty.call(input, "identity")
|
|
258
|
-
? normalizeOptionalText(input.identity)
|
|
259
|
-
: current?.identity;
|
|
260
|
-
const nextOwner = Object.prototype.hasOwnProperty.call(input, "owner")
|
|
261
|
-
? normalizeOptionalText(input.owner)
|
|
262
|
-
: current?.owner;
|
|
263
|
-
const nextCreator = Object.prototype.hasOwnProperty.call(input, "creator")
|
|
264
|
-
? normalizeOptionalText(input.creator)
|
|
265
|
-
: current?.creator;
|
|
266
|
-
|
|
267
|
-
await upsertStoredChannelAccount({
|
|
268
|
-
id,
|
|
269
|
-
channel,
|
|
270
|
-
name,
|
|
271
|
-
identity: nextIdentity,
|
|
272
|
-
owner: nextOwner,
|
|
273
|
-
creator: nextCreator,
|
|
274
|
-
botToken: nextBotToken,
|
|
275
|
-
appId: nextAppId,
|
|
276
|
-
appSecret: nextAppSecret,
|
|
277
|
-
domain: normalizeOptionalText(input.domain),
|
|
278
|
-
sandbox: input.sandbox === true,
|
|
279
|
-
});
|
|
280
|
-
return { id };
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* 删除账号。
|
|
285
|
-
*/
|
|
286
|
-
async remove(idInput: string): Promise<void> {
|
|
287
|
-
const id = String(idInput || "").trim();
|
|
288
|
-
if (!id) throw new Error("chat account id cannot be empty");
|
|
289
|
-
await removeStoredChannelAccount(id);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function toChannelAccountListItem(
|
|
294
|
-
account: StoredChannelAccount,
|
|
295
|
-
): ChatChannelAccountListItem {
|
|
296
|
-
return {
|
|
297
|
-
id: account.id,
|
|
298
|
-
channel: account.channel,
|
|
299
|
-
name: account.name,
|
|
300
|
-
identity: account.identity,
|
|
301
|
-
owner: account.owner,
|
|
302
|
-
creator: account.creator,
|
|
303
|
-
domain: account.domain,
|
|
304
|
-
sandbox: account.sandbox === true,
|
|
305
|
-
hasBotToken: !!String(account.botToken || "").trim(),
|
|
306
|
-
hasAppId: !!String(account.appId || "").trim(),
|
|
307
|
-
hasAppSecret: !!String(account.appSecret || "").trim(),
|
|
308
|
-
botTokenMasked: maskSecret(account.botToken),
|
|
309
|
-
appIdMasked: maskSecret(account.appId),
|
|
310
|
-
appSecretMasked: maskSecret(account.appSecret),
|
|
311
|
-
createdAt: account.createdAt,
|
|
312
|
-
updatedAt: account.updatedAt,
|
|
313
|
-
};
|
|
314
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Channel account 默认存储加密工具。
|
|
3
|
-
*
|
|
4
|
-
* 职责说明(中文)
|
|
5
|
-
* - 负责默认 chat account 存储中的敏感字段加解密。
|
|
6
|
-
* - 复用 `DC_PLATFORM_ROOT` 下的平台级 `model-db.key`。
|
|
7
|
-
*
|
|
8
|
-
* 边界说明(中文)
|
|
9
|
-
* - 这里只处理“字符串 <-> 密文”的转换,不负责数据库读写。
|
|
10
|
-
* - 加密算法与密钥文件路径属于默认实现细节,上层不直接感知。
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import crypto from "node:crypto";
|
|
14
|
-
import fs from "fs-extra";
|
|
15
|
-
import path from "node:path";
|
|
16
|
-
import { getPlatformStoreKeyPath } from "@downcity/agent";
|
|
17
|
-
|
|
18
|
-
const ENCRYPTION_ALGO = "aes-256-gcm";
|
|
19
|
-
|
|
20
|
-
let cachedKey: Buffer | null = null;
|
|
21
|
-
|
|
22
|
-
function resolveKeyFilePathSync(): string {
|
|
23
|
-
const keyPath = getPlatformStoreKeyPath();
|
|
24
|
-
fs.ensureDirSync(path.dirname(keyPath));
|
|
25
|
-
return keyPath;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function loadOrCreateKeySync(): Buffer {
|
|
29
|
-
if (cachedKey) return cachedKey;
|
|
30
|
-
|
|
31
|
-
const envKey = String(process.env.DC_MODEL_DB_KEY || "").trim();
|
|
32
|
-
if (envKey) {
|
|
33
|
-
cachedKey = crypto.createHash("sha256").update(envKey, "utf8").digest();
|
|
34
|
-
return cachedKey;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const keyPath = resolveKeyFilePathSync();
|
|
38
|
-
if (fs.existsSync(keyPath)) {
|
|
39
|
-
const raw = String(fs.readFileSync(keyPath, "utf8")).trim();
|
|
40
|
-
if (raw) {
|
|
41
|
-
const parsed = Buffer.from(raw, "base64");
|
|
42
|
-
if (parsed.length === 32) {
|
|
43
|
-
cachedKey = parsed;
|
|
44
|
-
return cachedKey;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const next = crypto.randomBytes(32);
|
|
50
|
-
fs.writeFileSync(keyPath, next.toString("base64"), { mode: 0o600 });
|
|
51
|
-
cachedKey = next;
|
|
52
|
-
return cachedKey;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 同步加密字符串。
|
|
57
|
-
*/
|
|
58
|
-
export function encryptTextSync(plainText: string): string {
|
|
59
|
-
const key = loadOrCreateKeySync();
|
|
60
|
-
const iv = crypto.randomBytes(12);
|
|
61
|
-
const cipher = crypto.createCipheriv(ENCRYPTION_ALGO, key, iv);
|
|
62
|
-
const encrypted = Buffer.concat([cipher.update(plainText, "utf8"), cipher.final()]);
|
|
63
|
-
const tag = cipher.getAuthTag();
|
|
64
|
-
return Buffer.concat([iv, tag, encrypted]).toString("base64");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 同步解密字符串。
|
|
69
|
-
*/
|
|
70
|
-
export function decryptTextSync(cipherText: string): string {
|
|
71
|
-
const key = loadOrCreateKeySync();
|
|
72
|
-
const packed = Buffer.from(cipherText, "base64");
|
|
73
|
-
if (packed.length < 28) {
|
|
74
|
-
throw new Error("Invalid encrypted payload");
|
|
75
|
-
}
|
|
76
|
-
const iv = packed.subarray(0, 12);
|
|
77
|
-
const tag = packed.subarray(12, 28);
|
|
78
|
-
const body = packed.subarray(28);
|
|
79
|
-
const decipher = crypto.createDecipheriv(ENCRYPTION_ALGO, key, iv);
|
|
80
|
-
decipher.setAuthTag(tag);
|
|
81
|
-
const plain = Buffer.concat([decipher.update(body), decipher.final()]);
|
|
82
|
-
return plain.toString("utf8");
|
|
83
|
-
}
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chat account 默认存储实现。
|
|
3
|
-
*
|
|
4
|
-
* 职责说明(中文)
|
|
5
|
-
* - 提供 `chat` plugin 默认使用的全局 chat account 读写能力。
|
|
6
|
-
* - 直接操作 `DC_PLATFORM_ROOT` 下 `downcity.db` 的 `channel_accounts` 表。
|
|
7
|
-
* - 对 `city` 而言,这里也是统一的默认账号池实现来源。
|
|
8
|
-
*
|
|
9
|
-
* 边界说明(中文)
|
|
10
|
-
* - 这里只负责 chat account 这一个表,不扩展成通用平台数据库门面。
|
|
11
|
-
* - 模型池、env、其他平台级配置仍由各自模块独立管理。
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import Database from "better-sqlite3";
|
|
15
|
-
import fs from "fs-extra";
|
|
16
|
-
import path from "node:path";
|
|
17
|
-
import { getPlatformStoreDbPath } from "@downcity/agent";
|
|
18
|
-
import { decryptTextSync, encryptTextSync } from "./Crypto.js";
|
|
19
|
-
import type {
|
|
20
|
-
StoredChannelAccount,
|
|
21
|
-
StoredChannelAccountChannel,
|
|
22
|
-
UpsertChannelAccountInput,
|
|
23
|
-
} from "@downcity/agent";
|
|
24
|
-
|
|
25
|
-
function nowIso(): string {
|
|
26
|
-
return new Date().toISOString();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function normalizeNonEmptyText(value: string, fieldName: string): string {
|
|
30
|
-
const normalized = String(value || "").trim();
|
|
31
|
-
if (!normalized) {
|
|
32
|
-
throw new Error(`${fieldName} cannot be empty`);
|
|
33
|
-
}
|
|
34
|
-
return normalized;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function optionalTrimmedText(value: string | undefined): string | undefined {
|
|
38
|
-
const normalized = String(value || "").trim();
|
|
39
|
-
return normalized || undefined;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 规范化 chat platform 类型。
|
|
44
|
-
*/
|
|
45
|
-
export function normalizeChannelAccountChannel(
|
|
46
|
-
input: string,
|
|
47
|
-
): StoredChannelAccountChannel {
|
|
48
|
-
const channel = String(input || "").trim().toLowerCase();
|
|
49
|
-
if (channel === "telegram" || channel === "feishu" || channel === "qq") {
|
|
50
|
-
return channel;
|
|
51
|
-
}
|
|
52
|
-
throw new Error(`Unsupported chat account platform: ${input}`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function ensureChannelAccountSchema(database: Database.Database): void {
|
|
56
|
-
database.exec(`
|
|
57
|
-
CREATE TABLE IF NOT EXISTS channel_accounts (
|
|
58
|
-
id TEXT PRIMARY KEY NOT NULL,
|
|
59
|
-
channel TEXT NOT NULL,
|
|
60
|
-
name TEXT NOT NULL,
|
|
61
|
-
identity TEXT,
|
|
62
|
-
owner TEXT,
|
|
63
|
-
creator TEXT,
|
|
64
|
-
bot_token_encrypted TEXT,
|
|
65
|
-
app_id_encrypted TEXT,
|
|
66
|
-
app_secret_encrypted TEXT,
|
|
67
|
-
domain TEXT,
|
|
68
|
-
sandbox INTEGER,
|
|
69
|
-
created_at TEXT NOT NULL,
|
|
70
|
-
updated_at TEXT NOT NULL
|
|
71
|
-
);
|
|
72
|
-
`);
|
|
73
|
-
database.exec(`
|
|
74
|
-
CREATE INDEX IF NOT EXISTS channel_accounts_channel_idx
|
|
75
|
-
ON channel_accounts(channel);
|
|
76
|
-
`);
|
|
77
|
-
|
|
78
|
-
const rows = database
|
|
79
|
-
.prepare("PRAGMA table_info(channel_accounts)")
|
|
80
|
-
.all() as Array<{ name?: unknown }>;
|
|
81
|
-
const columns = new Set(
|
|
82
|
-
rows.map((row) => String(row.name || "").trim()).filter(Boolean),
|
|
83
|
-
);
|
|
84
|
-
if (!columns.has("owner")) {
|
|
85
|
-
database.exec("ALTER TABLE channel_accounts ADD COLUMN owner TEXT;");
|
|
86
|
-
}
|
|
87
|
-
if (!columns.has("creator")) {
|
|
88
|
-
database.exec("ALTER TABLE channel_accounts ADD COLUMN creator TEXT;");
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function withChannelAccountDb<T>(callback: (database: Database.Database) => T): T {
|
|
93
|
-
const dbPath = getPlatformStoreDbPath();
|
|
94
|
-
fs.ensureDirSync(path.dirname(dbPath));
|
|
95
|
-
const database = new Database(dbPath);
|
|
96
|
-
try {
|
|
97
|
-
database.pragma("journal_mode = WAL");
|
|
98
|
-
ensureChannelAccountSchema(database);
|
|
99
|
-
return callback(database);
|
|
100
|
-
} finally {
|
|
101
|
-
database.close();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function buildChannelAccountFromRow(
|
|
106
|
-
row: Record<string, unknown>,
|
|
107
|
-
): StoredChannelAccount | null {
|
|
108
|
-
const id = String(row.id || "").trim();
|
|
109
|
-
if (!id) return null;
|
|
110
|
-
const botTokenEncrypted =
|
|
111
|
-
typeof row.bot_token_encrypted === "string" ? row.bot_token_encrypted : "";
|
|
112
|
-
const appIdEncrypted =
|
|
113
|
-
typeof row.app_id_encrypted === "string" ? row.app_id_encrypted : "";
|
|
114
|
-
const appSecretEncrypted =
|
|
115
|
-
typeof row.app_secret_encrypted === "string" ? row.app_secret_encrypted : "";
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
id,
|
|
119
|
-
channel: normalizeChannelAccountChannel(String(row.channel || "")),
|
|
120
|
-
name: String(row.name || "").trim() || id,
|
|
121
|
-
identity: optionalTrimmedText(String(row.identity || "")),
|
|
122
|
-
owner: optionalTrimmedText(String(row.owner || "")),
|
|
123
|
-
creator: optionalTrimmedText(String(row.creator || "")),
|
|
124
|
-
botToken: optionalTrimmedText(
|
|
125
|
-
botTokenEncrypted ? decryptTextSync(botTokenEncrypted) : undefined,
|
|
126
|
-
),
|
|
127
|
-
appId: optionalTrimmedText(
|
|
128
|
-
appIdEncrypted ? decryptTextSync(appIdEncrypted) : undefined,
|
|
129
|
-
),
|
|
130
|
-
appSecret: optionalTrimmedText(
|
|
131
|
-
appSecretEncrypted ? decryptTextSync(appSecretEncrypted) : undefined,
|
|
132
|
-
),
|
|
133
|
-
domain: optionalTrimmedText(String(row.domain || "")),
|
|
134
|
-
sandbox: Number(row.sandbox || 0) === 1,
|
|
135
|
-
createdAt: String(row.created_at || ""),
|
|
136
|
-
updatedAt: String(row.updated_at || ""),
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* 同步列出全部 chat account。
|
|
142
|
-
*/
|
|
143
|
-
export function listStoredChannelAccountsSync(
|
|
144
|
-
channelInput?: string,
|
|
145
|
-
): StoredChannelAccount[] {
|
|
146
|
-
return withChannelAccountDb((database) => {
|
|
147
|
-
const maybeChannel = optionalTrimmedText(channelInput);
|
|
148
|
-
const rows = maybeChannel
|
|
149
|
-
? database.prepare(
|
|
150
|
-
`
|
|
151
|
-
SELECT
|
|
152
|
-
id, channel, name, identity, owner, creator,
|
|
153
|
-
bot_token_encrypted, app_id_encrypted, app_secret_encrypted,
|
|
154
|
-
domain, sandbox, created_at, updated_at
|
|
155
|
-
FROM channel_accounts
|
|
156
|
-
WHERE channel = ?
|
|
157
|
-
ORDER BY name ASC, id ASC;
|
|
158
|
-
`,
|
|
159
|
-
).all(maybeChannel)
|
|
160
|
-
: database.prepare(
|
|
161
|
-
`
|
|
162
|
-
SELECT
|
|
163
|
-
id, channel, name, identity, owner, creator,
|
|
164
|
-
bot_token_encrypted, app_id_encrypted, app_secret_encrypted,
|
|
165
|
-
domain, sandbox, created_at, updated_at
|
|
166
|
-
FROM channel_accounts
|
|
167
|
-
ORDER BY channel ASC, name ASC, id ASC;
|
|
168
|
-
`,
|
|
169
|
-
).all();
|
|
170
|
-
|
|
171
|
-
const out: StoredChannelAccount[] = [];
|
|
172
|
-
for (const row of rows as Array<Record<string, unknown>>) {
|
|
173
|
-
const item = buildChannelAccountFromRow(row);
|
|
174
|
-
if (item) out.push(item);
|
|
175
|
-
}
|
|
176
|
-
return out;
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* 同步按 ID 读取单个 chat account。
|
|
182
|
-
*/
|
|
183
|
-
export function getStoredChannelAccountSync(
|
|
184
|
-
accountIdInput: string,
|
|
185
|
-
): StoredChannelAccount | null {
|
|
186
|
-
const accountId = normalizeNonEmptyText(accountIdInput, "chat account id");
|
|
187
|
-
return withChannelAccountDb((database) => {
|
|
188
|
-
const row = database.prepare(
|
|
189
|
-
`
|
|
190
|
-
SELECT
|
|
191
|
-
id, channel, name, identity, owner, creator,
|
|
192
|
-
bot_token_encrypted, app_id_encrypted, app_secret_encrypted,
|
|
193
|
-
domain, sandbox, created_at, updated_at
|
|
194
|
-
FROM channel_accounts
|
|
195
|
-
WHERE id = ?
|
|
196
|
-
LIMIT 1;
|
|
197
|
-
`,
|
|
198
|
-
).get(accountId) as Record<string, unknown> | undefined;
|
|
199
|
-
return row ? buildChannelAccountFromRow(row) : null;
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* 新增或更新 chat account。
|
|
205
|
-
*
|
|
206
|
-
* 关键点(中文)
|
|
207
|
-
* - 这里保留和现有平台库一致的落盘结构,避免默认实现切换后出现数据断层。
|
|
208
|
-
* - 未显式传入的敏感字段会保留旧值,便于 CLI 局部更新。
|
|
209
|
-
*/
|
|
210
|
-
export async function upsertStoredChannelAccount(
|
|
211
|
-
input: UpsertChannelAccountInput,
|
|
212
|
-
): Promise<void> {
|
|
213
|
-
const id = normalizeNonEmptyText(input.id, "chat account id");
|
|
214
|
-
const channel = normalizeChannelAccountChannel(input.channel);
|
|
215
|
-
const name = normalizeNonEmptyText(input.name, "chat account name");
|
|
216
|
-
const existing = getStoredChannelAccountSync(id);
|
|
217
|
-
const createdAt = existing?.createdAt || nowIso();
|
|
218
|
-
const updatedAt = nowIso();
|
|
219
|
-
|
|
220
|
-
const nextBotToken =
|
|
221
|
-
Object.prototype.hasOwnProperty.call(input, "botToken")
|
|
222
|
-
? optionalTrimmedText(input.botToken)
|
|
223
|
-
: existing?.botToken;
|
|
224
|
-
const nextAppId =
|
|
225
|
-
Object.prototype.hasOwnProperty.call(input, "appId")
|
|
226
|
-
? optionalTrimmedText(input.appId)
|
|
227
|
-
: existing?.appId;
|
|
228
|
-
const nextAppSecret =
|
|
229
|
-
Object.prototype.hasOwnProperty.call(input, "appSecret")
|
|
230
|
-
? optionalTrimmedText(input.appSecret)
|
|
231
|
-
: existing?.appSecret;
|
|
232
|
-
|
|
233
|
-
const botTokenEncrypted = nextBotToken ? encryptTextSync(nextBotToken) : null;
|
|
234
|
-
const appIdEncrypted = nextAppId ? encryptTextSync(nextAppId) : null;
|
|
235
|
-
const appSecretEncrypted = nextAppSecret ? encryptTextSync(nextAppSecret) : null;
|
|
236
|
-
|
|
237
|
-
withChannelAccountDb((database) => {
|
|
238
|
-
database.prepare(
|
|
239
|
-
`
|
|
240
|
-
INSERT INTO channel_accounts (
|
|
241
|
-
id, channel, name, identity, owner, creator,
|
|
242
|
-
bot_token_encrypted, app_id_encrypted, app_secret_encrypted,
|
|
243
|
-
domain, sandbox, created_at, updated_at
|
|
244
|
-
)
|
|
245
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
246
|
-
ON CONFLICT(id) DO UPDATE SET
|
|
247
|
-
channel = excluded.channel,
|
|
248
|
-
name = excluded.name,
|
|
249
|
-
identity = excluded.identity,
|
|
250
|
-
owner = excluded.owner,
|
|
251
|
-
creator = excluded.creator,
|
|
252
|
-
bot_token_encrypted = excluded.bot_token_encrypted,
|
|
253
|
-
app_id_encrypted = excluded.app_id_encrypted,
|
|
254
|
-
app_secret_encrypted = excluded.app_secret_encrypted,
|
|
255
|
-
domain = excluded.domain,
|
|
256
|
-
sandbox = excluded.sandbox,
|
|
257
|
-
updated_at = excluded.updated_at;
|
|
258
|
-
`,
|
|
259
|
-
).run(
|
|
260
|
-
id,
|
|
261
|
-
channel,
|
|
262
|
-
name,
|
|
263
|
-
optionalTrimmedText(input.identity) || null,
|
|
264
|
-
optionalTrimmedText(input.owner) || null,
|
|
265
|
-
optionalTrimmedText(input.creator) || null,
|
|
266
|
-
botTokenEncrypted,
|
|
267
|
-
appIdEncrypted,
|
|
268
|
-
appSecretEncrypted,
|
|
269
|
-
optionalTrimmedText(input.domain) || null,
|
|
270
|
-
input.sandbox === true ? 1 : 0,
|
|
271
|
-
createdAt,
|
|
272
|
-
updatedAt,
|
|
273
|
-
);
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* 删除单个 chat account。
|
|
279
|
-
*/
|
|
280
|
-
export async function removeStoredChannelAccount(
|
|
281
|
-
accountIdInput: string,
|
|
282
|
-
): Promise<void> {
|
|
283
|
-
const accountId = normalizeNonEmptyText(accountIdInput, "chat account id");
|
|
284
|
-
withChannelAccountDb((database) => {
|
|
285
|
-
database.prepare("DELETE FROM channel_accounts WHERE id = ?;").run(accountId);
|
|
286
|
-
});
|
|
287
|
-
}
|