@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
|
@@ -6,29 +6,13 @@
|
|
|
6
6
|
* - 远端收到 chat 后运行本地 agent session,并返回 assistant 文本。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { PluginContext } from "@downcity/agent";
|
|
10
10
|
import type { ContactChatResponse } from "@/contact/types/ContactChat.js";
|
|
11
|
-
import type { SessionRecordV1 } from "@downcity/agent";
|
|
12
11
|
import {
|
|
13
12
|
appendContactMessage,
|
|
14
13
|
findContactByInboundToken,
|
|
15
14
|
} from "./ContactStore.js";
|
|
16
15
|
|
|
17
|
-
function extractMessageText(message: SessionRecordV1 | null | undefined): string {
|
|
18
|
-
const parts = Array.isArray((message as { parts?: unknown } | null)?.parts)
|
|
19
|
-
? ((message as { parts: unknown[] }).parts)
|
|
20
|
-
: [];
|
|
21
|
-
return parts
|
|
22
|
-
.map((part) => {
|
|
23
|
-
if (!part || typeof part !== "object") return "";
|
|
24
|
-
const item = part as { type?: unknown; text?: unknown };
|
|
25
|
-
return item.type === "text" ? String(item.text || "") : "";
|
|
26
|
-
})
|
|
27
|
-
.filter(Boolean)
|
|
28
|
-
.join("\n")
|
|
29
|
-
.trim();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
16
|
/**
|
|
33
17
|
* 处理远端 contact chat 消息。
|
|
34
18
|
*/
|
|
@@ -36,7 +20,7 @@ export async function receiveContactChatMessage(params: {
|
|
|
36
20
|
/**
|
|
37
21
|
* 当前 agent context。
|
|
38
22
|
*/
|
|
39
|
-
context:
|
|
23
|
+
context: PluginContext;
|
|
40
24
|
/**
|
|
41
25
|
* 入站 contact token。
|
|
42
26
|
*/
|
|
@@ -46,7 +30,7 @@ export async function receiveContactChatMessage(params: {
|
|
|
46
30
|
*/
|
|
47
31
|
message: string;
|
|
48
32
|
}): Promise<ContactChatResponse> {
|
|
49
|
-
const contact = await findContactByInboundToken(params.context.
|
|
33
|
+
const contact = await findContactByInboundToken(params.context.workspace_path, params.token);
|
|
50
34
|
if (!contact || contact.status !== "trusted") {
|
|
51
35
|
return {
|
|
52
36
|
success: false,
|
|
@@ -57,22 +41,22 @@ export async function receiveContactChatMessage(params: {
|
|
|
57
41
|
}
|
|
58
42
|
|
|
59
43
|
const now = Date.now();
|
|
60
|
-
await appendContactMessage(params.context.
|
|
44
|
+
await appendContactMessage(params.context.workspace_path, contact.id, {
|
|
61
45
|
role: "remote",
|
|
62
46
|
text: params.message,
|
|
63
|
-
|
|
47
|
+
created_at: now,
|
|
64
48
|
});
|
|
65
49
|
|
|
66
|
-
const
|
|
67
|
-
const turn = await params.context.sessions.runtime(
|
|
50
|
+
const session_id = `contact_${contact.id}`;
|
|
51
|
+
const turn = await params.context.sessions.runtime(session_id).prompt({
|
|
68
52
|
query: params.message,
|
|
69
53
|
});
|
|
70
54
|
const result = await turn.finished;
|
|
71
|
-
const reply =
|
|
72
|
-
await appendContactMessage(params.context.
|
|
55
|
+
const reply = result.text.trim();
|
|
56
|
+
await appendContactMessage(params.context.workspace_path, contact.id, {
|
|
73
57
|
role: "local",
|
|
74
58
|
text: reply,
|
|
75
|
-
|
|
59
|
+
created_at: Date.now(),
|
|
76
60
|
});
|
|
77
61
|
|
|
78
62
|
return {
|
|
@@ -110,7 +110,7 @@ function normalizeStoredContact(input: unknown): AgentContact | null {
|
|
|
110
110
|
status: isContactStatus(item.status) ? item.status : "trusted",
|
|
111
111
|
outboundToken,
|
|
112
112
|
inboundTokenHash,
|
|
113
|
-
|
|
113
|
+
created_at: normalizeOptionalTimestamp(item.created_at) ?? 0,
|
|
114
114
|
...(normalizeOptionalTimestamp(item.lastSeenAt) !== undefined
|
|
115
115
|
? { lastSeenAt: normalizeOptionalTimestamp(item.lastSeenAt) }
|
|
116
116
|
: {}),
|
|
@@ -147,7 +147,7 @@ export function normalizeContactEndpoint(endpoint: string): string {
|
|
|
147
147
|
* 保存 contact。
|
|
148
148
|
*/
|
|
149
149
|
export async function saveContact(
|
|
150
|
-
|
|
150
|
+
project_root: string,
|
|
151
151
|
contact: AgentContact,
|
|
152
152
|
): Promise<AgentContact> {
|
|
153
153
|
const normalized: AgentContact = {
|
|
@@ -159,7 +159,7 @@ export async function saveContact(
|
|
|
159
159
|
status: contact.status || "trusted",
|
|
160
160
|
outboundToken: contact.outboundToken || null,
|
|
161
161
|
inboundTokenHash: contact.inboundTokenHash || null,
|
|
162
|
-
|
|
162
|
+
created_at: contact.created_at || Date.now(),
|
|
163
163
|
};
|
|
164
164
|
if (!normalized.name) throw new Error("contact name is required");
|
|
165
165
|
if (normalized.reachability !== "inbound" && !normalized.endpoint) {
|
|
@@ -171,11 +171,11 @@ export async function saveContact(
|
|
|
171
171
|
if (normalized.reachability !== "outbound" && !normalized.inboundTokenHash) {
|
|
172
172
|
throw new Error("contact inbound token hash is required for inbound contacts");
|
|
173
173
|
}
|
|
174
|
-
await fs.ensureDir(getContactDirectoryPath(
|
|
175
|
-
await fs.writeJson(getContactJsonPath(
|
|
174
|
+
await fs.ensureDir(getContactDirectoryPath(project_root, normalized.id));
|
|
175
|
+
await fs.writeJson(getContactJsonPath(project_root, normalized.id), normalized, {
|
|
176
176
|
spaces: 2,
|
|
177
177
|
});
|
|
178
|
-
await fs.ensureFile(getContactMessagesPath(
|
|
178
|
+
await fs.ensureFile(getContactMessagesPath(project_root, normalized.id));
|
|
179
179
|
return normalized;
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -183,10 +183,10 @@ export async function saveContact(
|
|
|
183
183
|
* 读取 contact。
|
|
184
184
|
*/
|
|
185
185
|
export async function readContact(
|
|
186
|
-
|
|
186
|
+
project_root: string,
|
|
187
187
|
contactId: string,
|
|
188
188
|
): Promise<AgentContact | null> {
|
|
189
|
-
const filePath = getContactJsonPath(
|
|
189
|
+
const filePath = getContactJsonPath(project_root, contactId);
|
|
190
190
|
if (!(await fs.pathExists(filePath))) return null;
|
|
191
191
|
const raw = await fs.readJson(filePath).catch(() => null);
|
|
192
192
|
// 关键点(中文):读取时归一化可恢复字段,避免一次局部写入让已收到的 contact 在列表中消失。
|
|
@@ -196,14 +196,14 @@ export async function readContact(
|
|
|
196
196
|
/**
|
|
197
197
|
* 列出全部 contact。
|
|
198
198
|
*/
|
|
199
|
-
export async function listContacts(
|
|
200
|
-
const root = getContactsRootPath(
|
|
199
|
+
export async function listContacts(project_root: string): Promise<AgentContact[]> {
|
|
200
|
+
const root = getContactsRootPath(project_root);
|
|
201
201
|
if (!(await fs.pathExists(root))) return [];
|
|
202
202
|
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
203
203
|
const contacts: AgentContact[] = [];
|
|
204
204
|
for (const entry of entries) {
|
|
205
205
|
if (!entry.isDirectory()) continue;
|
|
206
|
-
const contact = await readContact(
|
|
206
|
+
const contact = await readContact(project_root, entry.name);
|
|
207
207
|
if (contact) contacts.push(contact);
|
|
208
208
|
}
|
|
209
209
|
return contacts.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -213,12 +213,12 @@ export async function listContacts(projectRoot: string): Promise<AgentContact[]>
|
|
|
213
213
|
* 按 id/name 查找 contact。
|
|
214
214
|
*/
|
|
215
215
|
export async function findContact(
|
|
216
|
-
|
|
216
|
+
project_root: string,
|
|
217
217
|
query: string,
|
|
218
218
|
): Promise<AgentContact | null> {
|
|
219
219
|
const value = String(query || "").trim();
|
|
220
220
|
if (!value) return null;
|
|
221
|
-
const contacts = await listContacts(
|
|
221
|
+
const contacts = await listContacts(project_root);
|
|
222
222
|
const lower = value.toLowerCase();
|
|
223
223
|
return (
|
|
224
224
|
contacts.find((item) => item.id.toLowerCase() === lower) ||
|
|
@@ -232,25 +232,25 @@ export async function findContact(
|
|
|
232
232
|
* 根据入站 token 查找 contact。
|
|
233
233
|
*/
|
|
234
234
|
export async function findContactByInboundToken(
|
|
235
|
-
|
|
235
|
+
project_root: string,
|
|
236
236
|
token: string,
|
|
237
237
|
): Promise<AgentContact | null> {
|
|
238
|
-
const
|
|
239
|
-
const contacts = await listContacts(
|
|
240
|
-
return contacts.find((item) => item.inboundTokenHash ===
|
|
238
|
+
const token_hash = hashContactToken(token);
|
|
239
|
+
const contacts = await listContacts(project_root);
|
|
240
|
+
return contacts.find((item) => item.inboundTokenHash === token_hash) || null;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
/**
|
|
244
244
|
* 更新 contact 最近在线时间。
|
|
245
245
|
*/
|
|
246
246
|
export async function touchContactSeen(
|
|
247
|
-
|
|
247
|
+
project_root: string,
|
|
248
248
|
contactId: string,
|
|
249
249
|
seenAt: number = Date.now(),
|
|
250
250
|
): Promise<AgentContact | null> {
|
|
251
|
-
const contact = await readContact(
|
|
251
|
+
const contact = await readContact(project_root, contactId);
|
|
252
252
|
if (!contact) return null;
|
|
253
|
-
return await saveContact(
|
|
253
|
+
return await saveContact(project_root, {
|
|
254
254
|
...contact,
|
|
255
255
|
lastSeenAt: seenAt,
|
|
256
256
|
});
|
|
@@ -260,11 +260,11 @@ export async function touchContactSeen(
|
|
|
260
260
|
* 追加 contact chat 消息。
|
|
261
261
|
*/
|
|
262
262
|
export async function appendContactMessage(
|
|
263
|
-
|
|
263
|
+
project_root: string,
|
|
264
264
|
contactId: string,
|
|
265
265
|
message: ContactChatMessage,
|
|
266
266
|
): Promise<void> {
|
|
267
|
-
const filePath = getContactMessagesPath(
|
|
267
|
+
const filePath = getContactMessagesPath(project_root, contactId);
|
|
268
268
|
await fs.ensureDir(path.dirname(filePath));
|
|
269
269
|
await fs.appendFile(filePath, `${JSON.stringify(message)}\n`, "utf-8");
|
|
270
270
|
}
|
|
@@ -273,10 +273,10 @@ export async function appendContactMessage(
|
|
|
273
273
|
* 读取 contact chat 历史。
|
|
274
274
|
*/
|
|
275
275
|
export async function readContactMessages(
|
|
276
|
-
|
|
276
|
+
project_root: string,
|
|
277
277
|
contactId: string,
|
|
278
278
|
): Promise<ContactChatMessage[]> {
|
|
279
|
-
const filePath = getContactMessagesPath(
|
|
279
|
+
const filePath = getContactMessagesPath(project_root, contactId);
|
|
280
280
|
if (!(await fs.pathExists(filePath))) return [];
|
|
281
281
|
const text = await fs.readFile(filePath, "utf-8");
|
|
282
282
|
const out: ContactChatMessage[] = [];
|
|
@@ -52,11 +52,11 @@ function isMeta(input: unknown): input is ContactInboxShareMeta {
|
|
|
52
52
|
* 保存 inbox share。
|
|
53
53
|
*/
|
|
54
54
|
export async function saveContactInboxShare(
|
|
55
|
-
|
|
55
|
+
project_root: string,
|
|
56
56
|
input: SaveContactInboxShareInput,
|
|
57
57
|
): Promise<ContactInboxShareMeta> {
|
|
58
|
-
const inboxRoot = getContactInboxRootPath(
|
|
59
|
-
const sharePath = getContactInboxSharePath(
|
|
58
|
+
const inboxRoot = getContactInboxRootPath(project_root);
|
|
59
|
+
const sharePath = getContactInboxSharePath(project_root, input.meta.id);
|
|
60
60
|
const tempRoot = path.join(path.dirname(inboxRoot), ".inbox-tmp");
|
|
61
61
|
const tempPath = path.join(
|
|
62
62
|
tempRoot,
|
|
@@ -103,10 +103,10 @@ export async function saveContactInboxShare(
|
|
|
103
103
|
* 读取 inbox share meta。
|
|
104
104
|
*/
|
|
105
105
|
export async function readContactInboxShareMeta(
|
|
106
|
-
|
|
106
|
+
project_root: string,
|
|
107
107
|
shareId: string,
|
|
108
108
|
): Promise<ContactInboxShareMeta | null> {
|
|
109
|
-
const filePath = getContactInboxShareMetaPath(
|
|
109
|
+
const filePath = getContactInboxShareMetaPath(project_root, shareId);
|
|
110
110
|
if (!(await fs.pathExists(filePath))) return null;
|
|
111
111
|
const raw = await fs.readJson(filePath).catch(() => null);
|
|
112
112
|
return isMeta(raw) ? raw : null;
|
|
@@ -116,10 +116,10 @@ export async function readContactInboxShareMeta(
|
|
|
116
116
|
* 读取 inbox share payload。
|
|
117
117
|
*/
|
|
118
118
|
export async function readContactInboxSharePayload(
|
|
119
|
-
|
|
119
|
+
project_root: string,
|
|
120
120
|
shareId: string,
|
|
121
121
|
): Promise<ContactInboxSharePayload | null> {
|
|
122
|
-
const filePath = getContactInboxSharePayloadPath(
|
|
122
|
+
const filePath = getContactInboxSharePayloadPath(project_root, shareId);
|
|
123
123
|
if (!(await fs.pathExists(filePath))) return null;
|
|
124
124
|
const raw = await fs.readJson(filePath).catch(() => null);
|
|
125
125
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
@@ -131,15 +131,15 @@ export async function readContactInboxSharePayload(
|
|
|
131
131
|
* 列出 inbox share。
|
|
132
132
|
*/
|
|
133
133
|
export async function listContactInboxShares(
|
|
134
|
-
|
|
134
|
+
project_root: string,
|
|
135
135
|
): Promise<ContactInboxShareMeta[]> {
|
|
136
|
-
const root = getContactInboxRootPath(
|
|
136
|
+
const root = getContactInboxRootPath(project_root);
|
|
137
137
|
if (!(await fs.pathExists(root))) return [];
|
|
138
138
|
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
139
139
|
const shares: ContactInboxShareMeta[] = [];
|
|
140
140
|
for (const entry of entries) {
|
|
141
141
|
if (!entry.isDirectory()) continue;
|
|
142
|
-
const meta = await readContactInboxShareMeta(
|
|
142
|
+
const meta = await readContactInboxShareMeta(project_root, entry.name);
|
|
143
143
|
if (meta) shares.push(meta);
|
|
144
144
|
}
|
|
145
145
|
return shares.sort((a, b) => b.receivedAt - a.receivedAt);
|
|
@@ -149,22 +149,22 @@ export async function listContactInboxShares(
|
|
|
149
149
|
* 标记 share 已接收,并复制轻量状态到 received。
|
|
150
150
|
*/
|
|
151
151
|
export async function markContactInboxShareReceived(
|
|
152
|
-
|
|
152
|
+
project_root: string,
|
|
153
153
|
shareId: string,
|
|
154
154
|
): Promise<ContactInboxShareMeta> {
|
|
155
|
-
const meta = await readContactInboxShareMeta(
|
|
155
|
+
const meta = await readContactInboxShareMeta(project_root, shareId);
|
|
156
156
|
if (!meta) throw new Error(`Share not found: ${shareId}`);
|
|
157
157
|
const next: ContactInboxShareMeta = {
|
|
158
158
|
...meta,
|
|
159
159
|
status: "received",
|
|
160
160
|
};
|
|
161
|
-
const receivedPath = getContactReceivedSharePath(
|
|
161
|
+
const receivedPath = getContactReceivedSharePath(project_root, shareId);
|
|
162
162
|
await fs.ensureDir(receivedPath);
|
|
163
163
|
await fs.writeJson(path.join(receivedPath, "meta.json"), next, {
|
|
164
164
|
spaces: 2,
|
|
165
165
|
});
|
|
166
166
|
// received 区先完整写入,最后再更新 inbox meta,避免列表状态提前变成 received。
|
|
167
|
-
await fs.writeJson(getContactInboxShareMetaPath(
|
|
167
|
+
await fs.writeJson(getContactInboxShareMetaPath(project_root, shareId), next, {
|
|
168
168
|
spaces: 2,
|
|
169
169
|
});
|
|
170
170
|
return next;
|
|
@@ -173,6 +173,6 @@ export async function markContactInboxShareReceived(
|
|
|
173
173
|
/**
|
|
174
174
|
* 读取 share 文件根目录。
|
|
175
175
|
*/
|
|
176
|
-
export function getInboxShareFilesRoot(
|
|
177
|
-
return getContactInboxShareFilesPath(
|
|
176
|
+
export function getInboxShareFilesRoot(project_root: string, shareId: string): string {
|
|
177
|
+
return getContactInboxShareFilesPath(project_root, shareId);
|
|
178
178
|
}
|
|
@@ -99,31 +99,31 @@ function readCallbackCandidate(
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
async function findApprovedContact(params: {
|
|
102
|
-
|
|
102
|
+
project_root: string;
|
|
103
103
|
agentName: string;
|
|
104
104
|
}) {
|
|
105
105
|
const stable = await readContact(
|
|
106
|
-
params.
|
|
106
|
+
params.project_root,
|
|
107
107
|
createStableContactId(params.agentName),
|
|
108
108
|
);
|
|
109
109
|
if (stable) return stable;
|
|
110
|
-
const contacts = await listContacts(params.
|
|
110
|
+
const contacts = await listContacts(params.project_root);
|
|
111
111
|
const lower = params.agentName.trim().toLowerCase();
|
|
112
112
|
return contacts.find((item) => item.name.toLowerCase() === lower) || null;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
async function saveApprovedInboundContact(params: {
|
|
116
|
-
|
|
116
|
+
project_root: string;
|
|
117
117
|
agentName: string;
|
|
118
118
|
tokenForOwner: string;
|
|
119
119
|
nowMs: number;
|
|
120
120
|
}) {
|
|
121
121
|
const existing = await findApprovedContact({
|
|
122
|
-
|
|
122
|
+
project_root: params.project_root,
|
|
123
123
|
agentName: params.agentName,
|
|
124
124
|
});
|
|
125
125
|
const hasOutboundSide = Boolean(existing?.endpoint && existing?.outboundToken);
|
|
126
|
-
await saveContact(params.
|
|
126
|
+
await saveContact(params.project_root, {
|
|
127
127
|
id: existing?.id || createStableContactId(params.agentName),
|
|
128
128
|
name: existing?.name || params.agentName,
|
|
129
129
|
endpoint: existing?.endpoint || null,
|
|
@@ -131,7 +131,7 @@ async function saveApprovedInboundContact(params: {
|
|
|
131
131
|
status: "trusted",
|
|
132
132
|
outboundToken: existing?.outboundToken || null,
|
|
133
133
|
inboundTokenHash: hashContactToken(params.tokenForOwner),
|
|
134
|
-
|
|
134
|
+
created_at: existing?.created_at || params.nowMs,
|
|
135
135
|
lastSeenAt: params.nowMs,
|
|
136
136
|
});
|
|
137
137
|
}
|
|
@@ -143,7 +143,7 @@ export async function approveContactLinkRequest(
|
|
|
143
143
|
input: ApproveContactLinkRequestInput,
|
|
144
144
|
): Promise<ContactApproveLinkResponse> {
|
|
145
145
|
const nowMs = input.nowMs ?? Date.now();
|
|
146
|
-
const link = await readContactLinkRecord(input.
|
|
146
|
+
const link = await readContactLinkRecord(input.project_root, input.request.linkId);
|
|
147
147
|
if (!link) {
|
|
148
148
|
return failure({
|
|
149
149
|
ownerAgentName: input.ownerAgentName,
|
|
@@ -151,7 +151,7 @@ export async function approveContactLinkRequest(
|
|
|
151
151
|
error: CONTACT_LINK_NOT_FOUND_ERROR,
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
|
-
if (link.
|
|
154
|
+
if (link.expires_at <= nowMs) {
|
|
155
155
|
return failure({
|
|
156
156
|
ownerAgentName: input.ownerAgentName,
|
|
157
157
|
endpoint: link.endpoint,
|
|
@@ -185,10 +185,10 @@ export async function approveContactLinkRequest(
|
|
|
185
185
|
tokenForRequester: callbackCandidate.token,
|
|
186
186
|
callbackReason: input.request.callbackReason || link.callbackReason || null,
|
|
187
187
|
};
|
|
188
|
-
await saveContactLinkRecord(input.
|
|
188
|
+
await saveContactLinkRecord(input.project_root, nextLink);
|
|
189
189
|
}
|
|
190
190
|
await saveApprovedInboundContact({
|
|
191
|
-
|
|
191
|
+
project_root: input.project_root,
|
|
192
192
|
agentName: input.request.agentName,
|
|
193
193
|
tokenForOwner: link.tokenForOwner,
|
|
194
194
|
nowMs,
|
|
@@ -219,9 +219,9 @@ export async function approveContactLinkRequest(
|
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
// 先消费 link,再派生 contact;重试时以 link 记录为来源修复 contact,避免孤儿 trusted contact。
|
|
222
|
-
await saveContactLinkRecord(input.
|
|
222
|
+
await saveContactLinkRecord(input.project_root, approvedLink);
|
|
223
223
|
await saveApprovedInboundContact({
|
|
224
|
-
|
|
224
|
+
project_root: input.project_root,
|
|
225
225
|
agentName: input.request.agentName,
|
|
226
226
|
tokenForOwner,
|
|
227
227
|
nowMs,
|
|
@@ -242,14 +242,14 @@ export async function confirmContactLinkRequest(
|
|
|
242
242
|
input: ConfirmContactLinkRequestInput,
|
|
243
243
|
): Promise<ContactConfirmResponse> {
|
|
244
244
|
const nowMs = input.nowMs ?? Date.now();
|
|
245
|
-
const link = await readContactLinkRecord(input.
|
|
245
|
+
const link = await readContactLinkRecord(input.project_root, input.request.linkId);
|
|
246
246
|
if (!link) {
|
|
247
247
|
return confirmFailure({
|
|
248
248
|
ownerAgentName: input.ownerAgentName,
|
|
249
249
|
error: CONTACT_LINK_NOT_FOUND_ERROR,
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
|
-
if (!link.usedAt && link.
|
|
252
|
+
if (!link.usedAt && link.expires_at <= nowMs) {
|
|
253
253
|
return confirmFailure({
|
|
254
254
|
ownerAgentName: input.ownerAgentName,
|
|
255
255
|
error: "Contact link expired",
|
|
@@ -309,7 +309,7 @@ export async function confirmContactLinkRequest(
|
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
311
|
const contact = await findApprovedContact({
|
|
312
|
-
|
|
312
|
+
project_root: input.project_root,
|
|
313
313
|
agentName: input.request.agentName,
|
|
314
314
|
});
|
|
315
315
|
if (!contact || contact.status !== "trusted") {
|
|
@@ -332,7 +332,7 @@ export async function confirmContactLinkRequest(
|
|
|
332
332
|
) {
|
|
333
333
|
if (!link.confirmedAt) {
|
|
334
334
|
// contact 已经完成双向升级时,重试 confirm 需要补齐 link 状态,避免最终状态分裂。
|
|
335
|
-
await saveContactLinkRecord(input.
|
|
335
|
+
await saveContactLinkRecord(input.project_root, {
|
|
336
336
|
...link,
|
|
337
337
|
approvedEndpoint: endpoint,
|
|
338
338
|
tokenForRequester: token,
|
|
@@ -363,7 +363,7 @@ export async function confirmContactLinkRequest(
|
|
|
363
363
|
};
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
await saveContact(input.
|
|
366
|
+
await saveContact(input.project_root, {
|
|
367
367
|
...contact,
|
|
368
368
|
endpoint,
|
|
369
369
|
reachability: "bidirectional",
|
|
@@ -371,7 +371,7 @@ export async function confirmContactLinkRequest(
|
|
|
371
371
|
inboundTokenHash: contact.inboundTokenHash,
|
|
372
372
|
lastSeenAt: nowMs,
|
|
373
373
|
});
|
|
374
|
-
await saveContactLinkRecord(input.
|
|
374
|
+
await saveContactLinkRecord(input.project_root, {
|
|
375
375
|
...link,
|
|
376
376
|
approvedEndpoint: endpoint,
|
|
377
377
|
tokenForRequester: token,
|
|
@@ -22,12 +22,12 @@ function decodeJson(input: string): ContactLinkCodePayload {
|
|
|
22
22
|
const agentName = String(parsed.agentName || "").trim();
|
|
23
23
|
const endpoint = String(parsed.endpoint || "").trim();
|
|
24
24
|
const secret = String(parsed.secret || "").trim();
|
|
25
|
-
const
|
|
26
|
-
const
|
|
25
|
+
const created_at = Number(parsed.created_at);
|
|
26
|
+
const expires_at = Number(parsed.expires_at);
|
|
27
27
|
if (!linkId || !agentName || !endpoint || !secret) {
|
|
28
28
|
throw new Error("Invalid contact link code");
|
|
29
29
|
}
|
|
30
|
-
if (!Number.isFinite(
|
|
30
|
+
if (!Number.isFinite(created_at) || !Number.isFinite(expires_at)) {
|
|
31
31
|
throw new Error("Invalid contact link timestamps");
|
|
32
32
|
}
|
|
33
33
|
return {
|
|
@@ -36,8 +36,8 @@ function decodeJson(input: string): ContactLinkCodePayload {
|
|
|
36
36
|
agentName,
|
|
37
37
|
endpoint,
|
|
38
38
|
secret,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
created_at,
|
|
40
|
+
expires_at,
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -63,8 +63,8 @@ export function parseContactLinkCode(code: string): ContactLinkCodePayload {
|
|
|
63
63
|
* 判断 link code 是否过期。
|
|
64
64
|
*/
|
|
65
65
|
export function isContactLinkExpired(
|
|
66
|
-
payload: Pick<ContactLinkCodePayload, "
|
|
66
|
+
payload: Pick<ContactLinkCodePayload, "expires_at">,
|
|
67
67
|
nowMs: number = Date.now(),
|
|
68
68
|
): boolean {
|
|
69
|
-
return Number(payload.
|
|
69
|
+
return Number(payload.expires_at) <= nowMs;
|
|
70
70
|
}
|
|
@@ -18,8 +18,8 @@ function isLinkRecord(input: unknown): input is ContactLinkRecord {
|
|
|
18
18
|
typeof item.agentName === "string" &&
|
|
19
19
|
typeof item.endpoint === "string" &&
|
|
20
20
|
typeof item.secretHash === "string" &&
|
|
21
|
-
typeof item.
|
|
22
|
-
typeof item.
|
|
21
|
+
typeof item.created_at === "number" &&
|
|
22
|
+
typeof item.expires_at === "number",
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -27,11 +27,11 @@ function isLinkRecord(input: unknown): input is ContactLinkRecord {
|
|
|
27
27
|
* 保存 link 记录。
|
|
28
28
|
*/
|
|
29
29
|
export async function saveContactLinkRecord(
|
|
30
|
-
|
|
30
|
+
project_root: string,
|
|
31
31
|
record: ContactLinkRecord,
|
|
32
32
|
): Promise<void> {
|
|
33
|
-
await fs.ensureDir(getContactLinksRootPath(
|
|
34
|
-
await fs.writeJson(getContactLinkPath(
|
|
33
|
+
await fs.ensureDir(getContactLinksRootPath(project_root));
|
|
34
|
+
await fs.writeJson(getContactLinkPath(project_root, record.id), record, {
|
|
35
35
|
spaces: 2,
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -40,10 +40,10 @@ export async function saveContactLinkRecord(
|
|
|
40
40
|
* 读取 link 记录。
|
|
41
41
|
*/
|
|
42
42
|
export async function readContactLinkRecord(
|
|
43
|
-
|
|
43
|
+
project_root: string,
|
|
44
44
|
linkId: string,
|
|
45
45
|
): Promise<ContactLinkRecord | null> {
|
|
46
|
-
const filePath = getContactLinkPath(
|
|
46
|
+
const filePath = getContactLinkPath(project_root, linkId);
|
|
47
47
|
if (!(await fs.pathExists(filePath))) return null;
|
|
48
48
|
const raw = await fs.readJson(filePath).catch(() => null);
|
|
49
49
|
return isLinkRecord(raw) ? raw : null;
|