@downcity/plugins 1.0.215 → 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
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import path from "path";
|
|
11
11
|
import type { Logger } from "@downcity/agent";
|
|
12
|
-
import type {
|
|
12
|
+
import type { PluginContext } from "@downcity/agent";
|
|
13
13
|
import type { JsonObject } from "@downcity/agent";
|
|
14
14
|
import type {
|
|
15
15
|
IncomingChatAccessParams,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
augmentChatInboundInput,
|
|
25
25
|
buildChatInboundText,
|
|
26
26
|
} from "@/chat/runtime/InboundAugment.js";
|
|
27
|
-
import {
|
|
27
|
+
import { render_chat_message_file_tag } from "@downcity/agent";
|
|
28
28
|
import { extractTelegramReplyContext } from "./ReplyContext.js";
|
|
29
29
|
import {
|
|
30
30
|
getActorName,
|
|
@@ -58,7 +58,7 @@ export interface TelegramMessagePlatform {
|
|
|
58
58
|
*/
|
|
59
59
|
sendInboundAckReaction(params: {
|
|
60
60
|
chatId: string;
|
|
61
|
-
|
|
61
|
+
message_id?: number;
|
|
62
62
|
emoji: string;
|
|
63
63
|
}): Promise<void>;
|
|
64
64
|
/**
|
|
@@ -72,8 +72,8 @@ export interface TelegramMessagePlatform {
|
|
|
72
72
|
*/
|
|
73
73
|
export type TelegramMessageAuditWriter = (params: {
|
|
74
74
|
chatId: string;
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
message_id?: string;
|
|
76
|
+
user_id?: string;
|
|
77
77
|
text: string;
|
|
78
78
|
meta?: ChannelUserMessageMeta;
|
|
79
79
|
}) => Promise<void>;
|
|
@@ -86,7 +86,7 @@ export type TelegramMessageExecutor = (params: {
|
|
|
86
86
|
instructions: string;
|
|
87
87
|
from?: TelegramUser;
|
|
88
88
|
chatTitle?: string;
|
|
89
|
-
|
|
89
|
+
message_id?: string;
|
|
90
90
|
chatType?: NonNullable<TelegramUpdate["message"]>["chat"]["type"];
|
|
91
91
|
messageThreadId?: number;
|
|
92
92
|
receivedAt?: string;
|
|
@@ -110,7 +110,7 @@ export interface TelegramMessageHandlerOptions {
|
|
|
110
110
|
/**
|
|
111
111
|
* 当前 agent context。
|
|
112
112
|
*/
|
|
113
|
-
context:
|
|
113
|
+
context: PluginContext;
|
|
114
114
|
/**
|
|
115
115
|
* 项目根目录。
|
|
116
116
|
*/
|
|
@@ -149,9 +149,9 @@ export interface TelegramMessageHandlerOptions {
|
|
|
149
149
|
*/
|
|
150
150
|
enqueueAuditMessage: TelegramMessageAuditWriter;
|
|
151
151
|
/**
|
|
152
|
-
* 按
|
|
152
|
+
* 按 chat_key 串行执行。
|
|
153
153
|
*/
|
|
154
|
-
runInChat(
|
|
154
|
+
runInChat(chat_key: string, fn: () => Promise<void>): Promise<void>;
|
|
155
155
|
/**
|
|
156
156
|
* 命令处理。
|
|
157
157
|
*/
|
|
@@ -180,7 +180,7 @@ export async function handleTelegramMessage(
|
|
|
180
180
|
: "";
|
|
181
181
|
const entities = message.entities || message.caption_entities;
|
|
182
182
|
const hasIncomingAttachment = hasTelegramIncomingAttachment(message);
|
|
183
|
-
const
|
|
183
|
+
const message_id =
|
|
184
184
|
typeof message.message_id === "number" ? String(message.message_id) : undefined;
|
|
185
185
|
const receivedAt =
|
|
186
186
|
typeof message.date === "number" && Number.isFinite(message.date)
|
|
@@ -198,13 +198,13 @@ export async function handleTelegramMessage(
|
|
|
198
198
|
const actorName = getActorName(from);
|
|
199
199
|
const chatTitle = getTelegramChatTitle(message.chat);
|
|
200
200
|
const isGroup = isTelegramGroupChat(message.chat.type);
|
|
201
|
-
const
|
|
201
|
+
const chat_key = buildTelegramChatKey(chatId, messageThreadId);
|
|
202
202
|
|
|
203
203
|
if (!actorId) {
|
|
204
|
-
options.logger.warn("Telegram 消息缺少发送者
|
|
204
|
+
options.logger.warn("Telegram 消息缺少发送者 user_id,已忽略", {
|
|
205
205
|
chatId,
|
|
206
206
|
chatType: message.chat.type,
|
|
207
|
-
|
|
207
|
+
message_id,
|
|
208
208
|
messageThreadId,
|
|
209
209
|
hasFrom: !!from,
|
|
210
210
|
});
|
|
@@ -215,7 +215,7 @@ export async function handleTelegramMessage(
|
|
|
215
215
|
chatId,
|
|
216
216
|
chatType: message.chat.type,
|
|
217
217
|
chatTitle,
|
|
218
|
-
|
|
218
|
+
user_id: actorId,
|
|
219
219
|
username: actorName,
|
|
220
220
|
});
|
|
221
221
|
if (!access_result.allowed) {
|
|
@@ -237,8 +237,8 @@ export async function handleTelegramMessage(
|
|
|
237
237
|
if (!isGroup) return;
|
|
238
238
|
await options.enqueueAuditMessage({
|
|
239
239
|
chatId,
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
message_id,
|
|
241
|
+
user_id: actorId,
|
|
242
242
|
text: buildTelegramAuditText({ rawText, hasIncomingAttachment, message }),
|
|
243
243
|
meta: {
|
|
244
244
|
chatType: message.chat.type,
|
|
@@ -258,14 +258,14 @@ export async function handleTelegramMessage(
|
|
|
258
258
|
options.logger.debug("Ignored bot-originated message", {
|
|
259
259
|
chatId,
|
|
260
260
|
chatType: message.chat.type,
|
|
261
|
-
|
|
262
|
-
|
|
261
|
+
message_id,
|
|
262
|
+
from_id: from?.id,
|
|
263
263
|
fromUsername: from?.username,
|
|
264
264
|
});
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
await options.runInChat(
|
|
268
|
+
await options.runInChat(chat_key, async () => {
|
|
269
269
|
options.logger.debug("Telegram message received", {
|
|
270
270
|
chatId,
|
|
271
271
|
chatType: message.chat.type,
|
|
@@ -273,9 +273,9 @@ export async function handleTelegramMessage(
|
|
|
273
273
|
actorId,
|
|
274
274
|
actorUsername: from?.username,
|
|
275
275
|
actorName,
|
|
276
|
-
|
|
276
|
+
message_id,
|
|
277
277
|
messageThreadId,
|
|
278
|
-
|
|
278
|
+
chat_key,
|
|
279
279
|
hasIncomingAttachment,
|
|
280
280
|
textPreview: rawText.length > 240 ? `${rawText.slice(0, 240)}…` : rawText,
|
|
281
281
|
entityTypes: (entities || []).map((entity) => entity.type),
|
|
@@ -290,15 +290,15 @@ export async function handleTelegramMessage(
|
|
|
290
290
|
|
|
291
291
|
await options.platform.sendInboundAckReaction({
|
|
292
292
|
chatId,
|
|
293
|
-
|
|
293
|
+
message_id: parseTelegramMessageId(message_id),
|
|
294
294
|
emoji: options.inboundAckEmoji,
|
|
295
295
|
});
|
|
296
296
|
|
|
297
297
|
if (rawText.startsWith("/")) {
|
|
298
298
|
await options.enqueueAuditMessage({
|
|
299
299
|
chatId,
|
|
300
|
-
|
|
301
|
-
|
|
300
|
+
message_id,
|
|
301
|
+
user_id: actorId,
|
|
302
302
|
text: buildTelegramAuditText({ rawText, hasIncomingAttachment, message }),
|
|
303
303
|
meta: {
|
|
304
304
|
chatType: message.chat.type,
|
|
@@ -330,8 +330,8 @@ export async function handleTelegramMessage(
|
|
|
330
330
|
options,
|
|
331
331
|
message,
|
|
332
332
|
chatId,
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
message_id,
|
|
334
|
+
chat_key,
|
|
335
335
|
});
|
|
336
336
|
const replyContext = extractTelegramReplyContext(message);
|
|
337
337
|
|
|
@@ -344,12 +344,12 @@ export async function handleTelegramMessage(
|
|
|
344
344
|
channel: "telegram",
|
|
345
345
|
chatId,
|
|
346
346
|
chatType: message.chat.type,
|
|
347
|
-
|
|
348
|
-
|
|
347
|
+
chat_key,
|
|
348
|
+
message_id,
|
|
349
349
|
rootPath: options.rootPath,
|
|
350
350
|
attachmentText:
|
|
351
351
|
attachmentLines.length > 0 ? attachmentLines.join("\n") : undefined,
|
|
352
|
-
|
|
352
|
+
body_text: cleaned ? cleaned.trim() : undefined,
|
|
353
353
|
attachments: incomingAttachments.map((attachment) => ({
|
|
354
354
|
channel: "telegram" as const,
|
|
355
355
|
kind: attachment.type,
|
|
@@ -372,7 +372,7 @@ export async function handleTelegramMessage(
|
|
|
372
372
|
instructions,
|
|
373
373
|
from,
|
|
374
374
|
chatTitle,
|
|
375
|
-
|
|
375
|
+
message_id,
|
|
376
376
|
chatType: message.chat.type,
|
|
377
377
|
messageThreadId,
|
|
378
378
|
receivedAt,
|
|
@@ -422,8 +422,8 @@ async function collectIncomingAttachments(params: {
|
|
|
422
422
|
options: TelegramMessageHandlerOptions;
|
|
423
423
|
message: TelegramUpdate["message"];
|
|
424
424
|
chatId: string;
|
|
425
|
-
|
|
426
|
-
|
|
425
|
+
message_id?: string;
|
|
426
|
+
chat_key: string;
|
|
427
427
|
}): Promise<{
|
|
428
428
|
attachmentLines: string[];
|
|
429
429
|
incomingAttachments: Array<{
|
|
@@ -447,7 +447,7 @@ async function collectIncomingAttachments(params: {
|
|
|
447
447
|
for (const attachment of incomingAttachments) {
|
|
448
448
|
const rel = path.relative(params.options.rootPath, attachment.path);
|
|
449
449
|
attachmentLines.push(
|
|
450
|
-
|
|
450
|
+
render_chat_message_file_tag({
|
|
451
451
|
type: attachment.type,
|
|
452
452
|
path: rel,
|
|
453
453
|
...(attachment.desc ? { caption: attachment.desc } : {}),
|
|
@@ -458,8 +458,8 @@ async function collectIncomingAttachments(params: {
|
|
|
458
458
|
params.options.logger.warn("Failed to save incoming Telegram attachment(s)", {
|
|
459
459
|
error: String(error),
|
|
460
460
|
chatId: params.chatId,
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
message_id: params.message_id,
|
|
462
|
+
chat_key: params.chat_key,
|
|
463
463
|
});
|
|
464
464
|
}
|
|
465
465
|
|
|
@@ -50,8 +50,8 @@ export interface TelegramPendingUpdatePlatform {
|
|
|
50
50
|
*/
|
|
51
51
|
export type TelegramPendingAuditWriter = (params: {
|
|
52
52
|
chatId: string;
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
message_id?: string;
|
|
54
|
+
user_id?: string;
|
|
55
55
|
text: string;
|
|
56
56
|
meta?: ChannelUserMessageMeta;
|
|
57
57
|
}) => Promise<void>;
|
|
@@ -120,7 +120,7 @@ async function enqueuePendingMessage(params: {
|
|
|
120
120
|
typeof message.message_thread_id === "number"
|
|
121
121
|
? message.message_thread_id
|
|
122
122
|
: undefined;
|
|
123
|
-
const
|
|
123
|
+
const chat_key = buildTelegramChatKey(chatId, messageThreadId);
|
|
124
124
|
const from = message.from;
|
|
125
125
|
const chatTitle = getTelegramChatTitle(message.chat);
|
|
126
126
|
const botId = params.platform.getBotId();
|
|
@@ -147,14 +147,14 @@ async function enqueuePendingMessage(params: {
|
|
|
147
147
|
!!message.audio ||
|
|
148
148
|
!!message.video;
|
|
149
149
|
|
|
150
|
-
const
|
|
150
|
+
const message_id =
|
|
151
151
|
typeof message.message_id === "number" ? String(message.message_id) : undefined;
|
|
152
152
|
const actorId = from?.id ? String(from.id) : undefined;
|
|
153
153
|
|
|
154
154
|
await params.enqueueAuditMessage({
|
|
155
155
|
chatId,
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
message_id,
|
|
157
|
+
user_id: actorId,
|
|
158
158
|
text: buildTelegramAuditText({ rawText, hasIncomingAttachment, message }),
|
|
159
159
|
meta: {
|
|
160
160
|
kind: "pending",
|
|
@@ -165,7 +165,7 @@ async function enqueuePendingMessage(params: {
|
|
|
165
165
|
messageThreadId,
|
|
166
166
|
username: from?.username,
|
|
167
167
|
fromIsBot,
|
|
168
|
-
|
|
168
|
+
chat_key,
|
|
169
169
|
},
|
|
170
170
|
});
|
|
171
171
|
}
|
|
@@ -190,8 +190,8 @@ async function enqueuePendingCallbackQuery(params: {
|
|
|
190
190
|
: undefined;
|
|
191
191
|
await params.enqueueAuditMessage({
|
|
192
192
|
chatId,
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
message_id: undefined,
|
|
194
|
+
user_id: query.from?.id ? String(query.from.id) : undefined,
|
|
195
195
|
text: `[callback_query] ${String(query.data || "").slice(0, 1000)}`.trim(),
|
|
196
196
|
meta: {
|
|
197
197
|
kind: "pending",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - `TelegramBot` 只保留入站授权、命令分发、消息入队等业务编排。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { PluginContext } from "@downcity/agent";
|
|
11
11
|
import type { ChatChannelTestResult } from "@/chat/types/ChannelStatus.js";
|
|
12
12
|
import { TelegramApiClient } from "./ApiClient.js";
|
|
13
13
|
import { TelegramStateStore } from "./StateStore.js";
|
|
@@ -23,7 +23,7 @@ export interface TelegramPlatformClientOptions {
|
|
|
23
23
|
/**
|
|
24
24
|
* 当前执行上下文。
|
|
25
25
|
*/
|
|
26
|
-
context:
|
|
26
|
+
context: PluginContext;
|
|
27
27
|
/**
|
|
28
28
|
* Telegram bot token。
|
|
29
29
|
*/
|
|
@@ -48,7 +48,7 @@ export interface TelegramPlatformClientOptions {
|
|
|
48
48
|
* Telegram 平台运行时。
|
|
49
49
|
*/
|
|
50
50
|
export class TelegramPlatformClient {
|
|
51
|
-
private readonly logger:
|
|
51
|
+
private readonly logger: PluginContext["logger"];
|
|
52
52
|
private readonly api: TelegramApiClient;
|
|
53
53
|
private readonly stateStore: TelegramStateStore;
|
|
54
54
|
private readonly onMessage: TelegramPlatformClientOptions["onMessage"];
|
|
@@ -74,10 +74,10 @@ export class TelegramPlatformClient {
|
|
|
74
74
|
this.botToken = options.botToken;
|
|
75
75
|
this.api = new TelegramApiClient({
|
|
76
76
|
botToken: options.botToken,
|
|
77
|
-
|
|
77
|
+
project_root: options.context.workspace_path,
|
|
78
78
|
logger: options.context.logger,
|
|
79
79
|
});
|
|
80
|
-
this.stateStore = new TelegramStateStore(options.context.
|
|
80
|
+
this.stateStore = new TelegramStateStore(options.context.workspace_path);
|
|
81
81
|
this.onMessage = options.onMessage;
|
|
82
82
|
this.onCallbackQuery = options.onCallbackQuery;
|
|
83
83
|
this.onWebhookConflictResolved = options.onWebhookConflictResolved;
|
|
@@ -298,18 +298,18 @@ export class TelegramPlatformClient {
|
|
|
298
298
|
*/
|
|
299
299
|
async sendInboundAckReaction(params: {
|
|
300
300
|
chatId: string;
|
|
301
|
-
|
|
301
|
+
message_id?: number;
|
|
302
302
|
emoji: string;
|
|
303
303
|
}): Promise<void> {
|
|
304
|
-
if (!params.
|
|
304
|
+
if (!params.message_id) return;
|
|
305
305
|
try {
|
|
306
|
-
await this.api.setMessageReaction(params.chatId, params.
|
|
306
|
+
await this.api.setMessageReaction(params.chatId, params.message_id, {
|
|
307
307
|
emoji: params.emoji,
|
|
308
308
|
});
|
|
309
309
|
} catch (error) {
|
|
310
310
|
this.logger.warn("Telegram 入站 ack reaction 失败,继续处理消息", {
|
|
311
311
|
chatId: params.chatId,
|
|
312
|
-
|
|
312
|
+
message_id: params.message_id,
|
|
313
313
|
error: String(error),
|
|
314
314
|
});
|
|
315
315
|
}
|
|
@@ -354,10 +354,10 @@ export class TelegramPlatformClient {
|
|
|
354
354
|
*/
|
|
355
355
|
async setMessageReaction(
|
|
356
356
|
chatId: string,
|
|
357
|
-
|
|
357
|
+
message_id: number,
|
|
358
358
|
opts?: { emoji?: string; isBig?: boolean },
|
|
359
359
|
): Promise<void> {
|
|
360
|
-
await this.api.setMessageReaction(chatId,
|
|
360
|
+
await this.api.setMessageReaction(chatId, message_id, opts);
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
/**
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Plugin 的结构化配置协议。
|
|
3
|
+
*
|
|
4
|
+
* 关键点(中文)
|
|
5
|
+
* - Zod Schema 是内建 Chat 行为配置与 Resource 配置的唯一源码。
|
|
6
|
+
* - Plugin config 只描述 queue 行为,完整渠道配置由独立 Resource Item 承载。
|
|
7
|
+
* - `readOnly` 字段由 Resource Resolver 写入,`writeOnly` 字段由 CLI 安全采集和脱敏。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { JsonObject } from "@downcity/agent";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { resolveChatChannelBotInfo } from "@/chat/channels/BotInfoProvider.js";
|
|
13
|
+
import type { ChatPluginResource } from "@/chat/types/ChatPluginResource.js";
|
|
14
|
+
|
|
15
|
+
const resource_id_schema = z.string()
|
|
16
|
+
.trim()
|
|
17
|
+
.min(1)
|
|
18
|
+
.max(80)
|
|
19
|
+
.regex(/^[a-z0-9][a-z0-9_-]*$/u)
|
|
20
|
+
.meta({
|
|
21
|
+
title: "Resource ID",
|
|
22
|
+
description: "Stable Resource ID generated by City.",
|
|
23
|
+
readOnly: true,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const resource_name_schema = z.string()
|
|
27
|
+
.trim()
|
|
28
|
+
.min(1)
|
|
29
|
+
.meta({
|
|
30
|
+
title: "Name",
|
|
31
|
+
description: "Display name written by the Resource Resolver.",
|
|
32
|
+
readOnly: true,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const secret_schema = z.string()
|
|
36
|
+
.trim()
|
|
37
|
+
.min(1)
|
|
38
|
+
.meta({ writeOnly: true });
|
|
39
|
+
|
|
40
|
+
/** Telegram Resource 完整配置 Schema。 */
|
|
41
|
+
const telegram_resource_schema = z.object({
|
|
42
|
+
id: resource_id_schema,
|
|
43
|
+
type: z.literal("telegram").meta({ title: "Type" }),
|
|
44
|
+
name: resource_name_schema,
|
|
45
|
+
bot_token: secret_schema.meta({
|
|
46
|
+
title: "Bot Token",
|
|
47
|
+
description: "Telegram Bot API Token.",
|
|
48
|
+
writeOnly: true,
|
|
49
|
+
}),
|
|
50
|
+
username: z.string().trim().min(1).optional().meta({
|
|
51
|
+
title: "Username",
|
|
52
|
+
description: "Telegram username written by the Resource Resolver.",
|
|
53
|
+
readOnly: true,
|
|
54
|
+
}),
|
|
55
|
+
bot_user_id: z.string().trim().min(1).optional().meta({
|
|
56
|
+
title: "Bot User ID",
|
|
57
|
+
description: "Telegram Bot user ID written by the Resource Resolver.",
|
|
58
|
+
readOnly: true,
|
|
59
|
+
}),
|
|
60
|
+
}).strict().meta({
|
|
61
|
+
title: "Telegram",
|
|
62
|
+
description: "Telegram Bot Resource.",
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
/** Feishu / Lark Resource 完整配置 Schema。 */
|
|
66
|
+
const feishu_resource_schema = z.object({
|
|
67
|
+
id: resource_id_schema,
|
|
68
|
+
type: z.literal("feishu").meta({ title: "Type" }),
|
|
69
|
+
name: resource_name_schema,
|
|
70
|
+
app_id: z.string().trim().min(1).meta({
|
|
71
|
+
title: "App ID",
|
|
72
|
+
description: "Feishu or Lark App ID.",
|
|
73
|
+
}),
|
|
74
|
+
app_secret: secret_schema.meta({
|
|
75
|
+
title: "App Secret",
|
|
76
|
+
description: "Feishu or Lark App Secret.",
|
|
77
|
+
writeOnly: true,
|
|
78
|
+
}),
|
|
79
|
+
domain: z.url().optional().meta({
|
|
80
|
+
title: "Open API Domain",
|
|
81
|
+
description: "Optional Feishu or Lark Open API domain.",
|
|
82
|
+
}),
|
|
83
|
+
identity: z.string().trim().min(1).optional().meta({
|
|
84
|
+
title: "Identity",
|
|
85
|
+
readOnly: true,
|
|
86
|
+
}),
|
|
87
|
+
owner: z.string().trim().min(1).optional().meta({
|
|
88
|
+
title: "Owner",
|
|
89
|
+
readOnly: true,
|
|
90
|
+
}),
|
|
91
|
+
creator: z.string().trim().min(1).optional().meta({
|
|
92
|
+
title: "Creator",
|
|
93
|
+
readOnly: true,
|
|
94
|
+
}),
|
|
95
|
+
bot_user_id: z.string().trim().min(1).optional().meta({
|
|
96
|
+
title: "Bot User ID",
|
|
97
|
+
readOnly: true,
|
|
98
|
+
}),
|
|
99
|
+
}).strict().meta({
|
|
100
|
+
title: "Feishu / Lark",
|
|
101
|
+
description: "Feishu or Lark Bot Resource.",
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
/** QQ Resource 完整配置 Schema。 */
|
|
105
|
+
const qq_resource_schema = z.object({
|
|
106
|
+
id: resource_id_schema,
|
|
107
|
+
type: z.literal("qq").meta({ title: "Type" }),
|
|
108
|
+
name: resource_name_schema,
|
|
109
|
+
app_id: z.string().trim().min(1).meta({
|
|
110
|
+
title: "App ID",
|
|
111
|
+
description: "QQ Bot App ID.",
|
|
112
|
+
}),
|
|
113
|
+
app_secret: secret_schema.meta({
|
|
114
|
+
title: "App Secret",
|
|
115
|
+
description: "QQ Bot App Secret.",
|
|
116
|
+
writeOnly: true,
|
|
117
|
+
}),
|
|
118
|
+
sandbox: z.boolean().optional().meta({
|
|
119
|
+
title: "Sandbox",
|
|
120
|
+
description: "Whether to use the QQ sandbox environment.",
|
|
121
|
+
default: false,
|
|
122
|
+
}),
|
|
123
|
+
identity: z.string().trim().min(1).optional().meta({
|
|
124
|
+
title: "Identity",
|
|
125
|
+
readOnly: true,
|
|
126
|
+
}),
|
|
127
|
+
bot_user_id: z.string().trim().min(1).optional().meta({
|
|
128
|
+
title: "Bot User ID",
|
|
129
|
+
readOnly: true,
|
|
130
|
+
}),
|
|
131
|
+
}).strict().meta({
|
|
132
|
+
title: "QQ",
|
|
133
|
+
description: "QQ Bot Resource.",
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
/** Chat Plugin 单个完整 Resource Item Schema。 */
|
|
137
|
+
export const chat_plugin_resource_schema = z.discriminatedUnion("type", [
|
|
138
|
+
telegram_resource_schema,
|
|
139
|
+
feishu_resource_schema,
|
|
140
|
+
qq_resource_schema,
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
/** Chat Plugin 完整配置 Schema。 */
|
|
144
|
+
export const chat_plugin_config_schema = z.object({
|
|
145
|
+
queue: z.object({
|
|
146
|
+
max_concurrency: z.number()
|
|
147
|
+
.int()
|
|
148
|
+
.min(1)
|
|
149
|
+
.max(32)
|
|
150
|
+
.optional()
|
|
151
|
+
.meta({
|
|
152
|
+
title: "Maximum concurrency",
|
|
153
|
+
description: "Maximum number of chat lanes executed concurrently.",
|
|
154
|
+
}),
|
|
155
|
+
merge_debounce_ms: z.number()
|
|
156
|
+
.int()
|
|
157
|
+
.min(0)
|
|
158
|
+
.max(60_000)
|
|
159
|
+
.optional()
|
|
160
|
+
.meta({
|
|
161
|
+
title: "Merge debounce",
|
|
162
|
+
description: "Debounce window used to merge consecutive inbound messages.",
|
|
163
|
+
}),
|
|
164
|
+
merge_max_wait_ms: z.number()
|
|
165
|
+
.int()
|
|
166
|
+
.min(0)
|
|
167
|
+
.max(120_000)
|
|
168
|
+
.optional()
|
|
169
|
+
.meta({
|
|
170
|
+
title: "Maximum merge wait",
|
|
171
|
+
description: "Maximum time to wait before executing a merged inbound burst.",
|
|
172
|
+
}),
|
|
173
|
+
}).strict().optional().meta({
|
|
174
|
+
title: "Queue",
|
|
175
|
+
description: "Chat queue scheduling and inbound message merge behavior.",
|
|
176
|
+
}),
|
|
177
|
+
}).strict().meta({
|
|
178
|
+
title: "Chat Plugin",
|
|
179
|
+
description: "Chat queue behavior. Messaging channels are Plugin Resources.",
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
/** Chat Plugin 完整结构化配置。 */
|
|
183
|
+
export type ChatPluginConfig = z.infer<typeof chat_plugin_config_schema>;
|
|
184
|
+
|
|
185
|
+
/** 供 City Plugin Catalog 使用的标准 JSON Schema。 */
|
|
186
|
+
export const CHAT_PLUGIN_CONFIG_JSON_SCHEMA = z.toJSONSchema(
|
|
187
|
+
chat_plugin_config_schema,
|
|
188
|
+
{ target: "draft-2020-12" },
|
|
189
|
+
) as JsonObject;
|
|
190
|
+
|
|
191
|
+
/** 供 City Plugin Catalog 使用的完整 Resource Item JSON Schema。 */
|
|
192
|
+
export const CHAT_PLUGIN_RESOURCE_JSON_SCHEMA = z.toJSONSchema(
|
|
193
|
+
chat_plugin_resource_schema,
|
|
194
|
+
{ target: "draft-2020-12" },
|
|
195
|
+
) as JsonObject;
|
|
196
|
+
|
|
197
|
+
/** 在运行时装配边界解析并收窄 Chat Plugin 配置。 */
|
|
198
|
+
export function parse_chat_plugin_config(input: unknown): ChatPluginConfig {
|
|
199
|
+
return chat_plugin_config_schema.parse(input);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** 解析一个完整 Chat Plugin Resource Item。 */
|
|
203
|
+
export function parse_chat_plugin_resource(input: unknown): ChatPluginResource {
|
|
204
|
+
return chat_plugin_resource_schema.parse(input);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** 读取一个 Chat Resource 类型分支的标准 JSON Schema。 */
|
|
208
|
+
export function get_chat_plugin_resource_json_schema(
|
|
209
|
+
resource_type: ChatPluginResource["type"],
|
|
210
|
+
): JsonObject {
|
|
211
|
+
const variants = Array.isArray(CHAT_PLUGIN_RESOURCE_JSON_SCHEMA.oneOf)
|
|
212
|
+
? CHAT_PLUGIN_RESOURCE_JSON_SCHEMA.oneOf
|
|
213
|
+
: [];
|
|
214
|
+
for (const value of variants) {
|
|
215
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) continue;
|
|
216
|
+
const variant = value as JsonObject;
|
|
217
|
+
const properties = variant.properties;
|
|
218
|
+
if (!properties || typeof properties !== "object" || Array.isArray(properties)) continue;
|
|
219
|
+
const type_schema = (properties as JsonObject).type;
|
|
220
|
+
if (
|
|
221
|
+
type_schema
|
|
222
|
+
&& typeof type_schema === "object"
|
|
223
|
+
&& !Array.isArray(type_schema)
|
|
224
|
+
&& (type_schema as JsonObject).const === resource_type
|
|
225
|
+
) {
|
|
226
|
+
return JSON.parse(JSON.stringify(variant)) as JsonObject;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
throw new Error(`Missing Chat Resource schema: ${resource_type}`);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 根据用户字段解析并返回 Resolver 可写的动态字段。
|
|
234
|
+
*
|
|
235
|
+
* 关键点(中文):返回值不包含 `id`、`type` 和凭据,字段所有权由 City 按 Schema 校验。
|
|
236
|
+
*/
|
|
237
|
+
export async function resolve_chat_plugin_resource(
|
|
238
|
+
input: JsonObject,
|
|
239
|
+
): Promise<JsonObject> {
|
|
240
|
+
const type = String(input.type || "").trim();
|
|
241
|
+
if (type !== "telegram" && type !== "feishu" && type !== "qq") {
|
|
242
|
+
throw new Error(`Unsupported Chat Resource type: ${type}`);
|
|
243
|
+
}
|
|
244
|
+
const result = await resolveChatChannelBotInfo({
|
|
245
|
+
channel: type,
|
|
246
|
+
credentials: {
|
|
247
|
+
botToken: typeof input.bot_token === "string" ? input.bot_token : undefined,
|
|
248
|
+
appId: typeof input.app_id === "string" ? input.app_id : undefined,
|
|
249
|
+
appSecret: typeof input.app_secret === "string" ? input.app_secret : undefined,
|
|
250
|
+
domain: typeof input.domain === "string" ? input.domain : undefined,
|
|
251
|
+
sandbox: input.sandbox === true,
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
const identity = String(result.identity || "").trim();
|
|
255
|
+
const bot_user_id = String(result.botUserId || "").trim();
|
|
256
|
+
const owner = String(result.owner || "").trim();
|
|
257
|
+
const creator = String(result.creator || "").trim();
|
|
258
|
+
return {
|
|
259
|
+
name: result.name,
|
|
260
|
+
...(type === "telegram" && identity ? { username: identity } : {}),
|
|
261
|
+
...(type !== "telegram" && identity ? { identity } : {}),
|
|
262
|
+
...(bot_user_id ? { bot_user_id } : {}),
|
|
263
|
+
...(type === "feishu" && owner ? { owner } : {}),
|
|
264
|
+
...(type === "feishu" && creator ? { creator } : {}),
|
|
265
|
+
};
|
|
266
|
+
}
|