@downcity/agent 1.1.13 → 1.1.15
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/config/Config.js +1 -1
- package/bin/config/Config.js.map +1 -1
- package/bin/config/Defaults.d.ts +13 -0
- package/bin/config/Defaults.d.ts.map +1 -0
- package/bin/config/{DowncityDefault.js → Defaults.js} +11 -1
- package/bin/config/Defaults.js.map +1 -0
- package/bin/{project/ProjectExecutionBinding.d.ts → config/ExecutionBinding.d.ts} +2 -2
- package/bin/config/ExecutionBinding.d.ts.map +1 -0
- package/bin/{project/ProjectExecutionBinding.js → config/ExecutionBinding.js} +2 -2
- package/bin/config/ExecutionBinding.js.map +1 -0
- package/bin/{runtime → core}/AgentContextTypes.d.ts +6 -6
- package/bin/core/AgentContextTypes.d.ts.map +1 -0
- package/bin/{runtime → core}/AgentContextTypes.js +2 -2
- package/bin/core/AgentContextTypes.js.map +1 -0
- package/bin/core/AgentCore.d.ts +87 -0
- package/bin/core/AgentCore.d.ts.map +1 -0
- package/bin/core/AgentCore.js +467 -0
- package/bin/core/AgentCore.js.map +1 -0
- package/bin/{runtime/AgentRuntimeTypes.d.ts → core/AgentCoreTypes.d.ts} +7 -7
- package/bin/core/AgentCoreTypes.d.ts.map +1 -0
- package/bin/core/AgentCoreTypes.js +10 -0
- package/bin/core/AgentCoreTypes.js.map +1 -0
- package/bin/host/daemon/ProjectSetup.d.ts.map +1 -1
- package/bin/host/daemon/ProjectSetup.js +1 -1
- package/bin/host/daemon/ProjectSetup.js.map +1 -1
- package/bin/host/runtime/PluginRuntime.d.ts +1 -1
- package/bin/host/runtime/PluginRuntime.d.ts.map +1 -1
- package/bin/index.d.ts +9 -11
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +5 -8
- package/bin/index.js.map +1 -1
- package/bin/model/CreateModel.js +1 -1
- package/bin/model/CreateModel.js.map +1 -1
- package/bin/plugin/builtins/asr/InboundAugment.d.ts +1 -1
- package/bin/plugin/builtins/asr/InboundAugment.d.ts.map +1 -1
- package/bin/plugin/builtins/auth/runtime/AuthorizationConfig.d.ts +1 -1
- package/bin/plugin/builtins/auth/runtime/AuthorizationConfig.d.ts.map +1 -1
- package/bin/plugin/builtins/auth/runtime/AuthorizationStore.d.ts +1 -1
- package/bin/plugin/builtins/auth/runtime/AuthorizationStore.d.ts.map +1 -1
- package/bin/plugin/builtins/voice/InboundAugment.d.ts +1 -1
- package/bin/plugin/builtins/voice/InboundAugment.d.ts.map +1 -1
- package/bin/plugin/builtins/workboard/runtime/Collector.d.ts +1 -1
- package/bin/plugin/builtins/workboard/runtime/Collector.d.ts.map +1 -1
- package/bin/plugin/builtins/workboard/runtime/Collector.js +1 -1
- package/bin/plugin/builtins/workboard/runtime/Collector.js.map +1 -1
- package/bin/plugin/builtins/workboard/runtime/Normalizer.d.ts +1 -1
- package/bin/plugin/builtins/workboard/runtime/Normalizer.d.ts.map +1 -1
- package/bin/plugin/builtins/workboard/runtime/Store.d.ts +1 -1
- package/bin/plugin/builtins/workboard/runtime/Store.d.ts.map +1 -1
- package/bin/plugin/core/Activation.d.ts +2 -2
- package/bin/plugin/core/Activation.d.ts.map +1 -1
- package/bin/plugin/core/HookRegistry.d.ts +1 -1
- package/bin/plugin/core/HookRegistry.d.ts.map +1 -1
- package/bin/plugin/core/HttpRoutes.d.ts +1 -1
- package/bin/plugin/core/HttpRoutes.d.ts.map +1 -1
- package/bin/plugin/core/LocalExecution.d.ts.map +1 -1
- package/bin/plugin/core/LocalExecution.js +18 -20
- package/bin/plugin/core/LocalExecution.js.map +1 -1
- package/bin/plugin/core/PluginRegistry.d.ts +1 -1
- package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
- package/bin/plugin/types/Plugin.d.ts +1 -1
- package/bin/plugin/types/Plugin.d.ts.map +1 -1
- package/bin/project/AgentInitializer.js +2 -2
- package/bin/project/AgentInitializer.js.map +1 -1
- package/bin/sandbox/SandboxConfigResolver.d.ts +1 -1
- package/bin/sandbox/SandboxConfigResolver.d.ts.map +1 -1
- package/bin/sandbox/SandboxRunner.d.ts +1 -1
- package/bin/sandbox/SandboxRunner.d.ts.map +1 -1
- package/bin/sdk/Agent.d.ts +43 -27
- package/bin/sdk/Agent.d.ts.map +1 -1
- package/bin/sdk/Agent.js +143 -364
- package/bin/sdk/Agent.js.map +1 -1
- package/bin/sdk/AgentSdkTypes.d.ts +138 -0
- package/bin/sdk/AgentSdkTypes.d.ts.map +1 -1
- package/bin/sdk/RemoteAgent.d.ts +1 -1
- package/bin/sdk/RemoteAgent.js +1 -1
- package/bin/sdk/Session.d.ts +2 -2
- package/bin/sdk/Session.d.ts.map +1 -1
- package/bin/sdk/Session.js +11 -5
- package/bin/sdk/Session.js.map +1 -1
- package/bin/sdk/{SessionMetadata.d.ts → session/Metadata.d.ts} +2 -2
- package/bin/sdk/session/Metadata.d.ts.map +1 -0
- package/bin/sdk/{SessionMetadata.js → session/Metadata.js} +2 -2
- package/bin/sdk/session/Metadata.js.map +1 -0
- package/bin/sdk/{Paths.d.ts → session/Paths.d.ts} +1 -1
- package/bin/sdk/session/Paths.d.ts.map +1 -0
- package/bin/sdk/{Paths.js → session/Paths.js} +1 -1
- package/bin/sdk/session/Paths.js.map +1 -0
- package/bin/sdk/{SessionPersistence.d.ts → session/Persistence.d.ts} +3 -3
- package/bin/sdk/session/Persistence.d.ts.map +1 -0
- package/bin/sdk/{SessionPersistence.js → session/Persistence.js} +4 -4
- package/bin/sdk/session/Persistence.js.map +1 -0
- package/bin/sdk/{SessionServicePort.d.ts → session/ServicePort.d.ts} +2 -2
- package/bin/sdk/session/ServicePort.d.ts.map +1 -0
- package/bin/sdk/{SessionServicePort.js → session/ServicePort.js} +1 -1
- package/bin/sdk/session/ServicePort.js.map +1 -0
- package/bin/sdk/session/index.d.ts +12 -0
- package/bin/sdk/session/index.d.ts.map +1 -0
- package/bin/sdk/session/index.js +12 -0
- package/bin/sdk/session/index.js.map +1 -0
- package/bin/server/http/Server.d.ts +10 -1
- package/bin/server/http/Server.d.ts.map +1 -1
- package/bin/server/http/Server.js +41 -15
- package/bin/server/http/Server.js.map +1 -1
- package/bin/server/http/control/AuthControlService.d.ts +1 -1
- package/bin/server/http/control/AuthControlService.d.ts.map +1 -1
- package/bin/server/http/control/ControlAuthorizationRoutes.d.ts +1 -1
- package/bin/server/http/control/ControlAuthorizationRoutes.d.ts.map +1 -1
- package/bin/server/http/control/ControlRouter.d.ts +18 -2
- package/bin/server/http/control/ControlRouter.d.ts.map +1 -1
- package/bin/server/http/control/ControlRouter.js +10 -8
- package/bin/server/http/control/ControlRouter.js.map +1 -1
- package/bin/server/http/control/ExecuteBySession.d.ts +2 -2
- package/bin/server/http/control/ExecuteBySession.d.ts.map +1 -1
- package/bin/server/http/control/OverviewRoutes.d.ts.map +1 -1
- package/bin/server/http/control/OverviewRoutes.js +6 -2
- package/bin/server/http/control/OverviewRoutes.js.map +1 -1
- package/bin/server/http/control/SessionSummaryStore.d.ts +1 -1
- package/bin/server/http/control/SessionSummaryStore.d.ts.map +1 -1
- package/bin/server/http/control/types/ControlRoutes.d.ts +2 -2
- package/bin/server/http/control/types/ControlRoutes.d.ts.map +1 -1
- package/bin/server/http/execute/execute.d.ts +13 -2
- package/bin/server/http/execute/execute.d.ts.map +1 -1
- package/bin/server/http/execute/execute.js +73 -71
- package/bin/server/http/execute/execute.js.map +1 -1
- package/bin/server/http/plugins/plugins.d.ts +13 -2
- package/bin/server/http/plugins/plugins.d.ts.map +1 -1
- package/bin/server/http/plugins/plugins.js +42 -40
- package/bin/server/http/plugins/plugins.js.map +1 -1
- package/bin/server/http/services/services.d.ts +12 -8
- package/bin/server/http/services/services.d.ts.map +1 -1
- package/bin/server/http/services/services.js +57 -64
- package/bin/server/http/services/services.js.map +1 -1
- package/bin/server/http/static/static.d.ts +13 -2
- package/bin/server/http/static/static.d.ts.map +1 -1
- package/bin/server/http/static/static.js +81 -79
- package/bin/server/http/static/static.js.map +1 -1
- package/bin/server/rpc/Server.d.ts +5 -3
- package/bin/server/rpc/Server.d.ts.map +1 -1
- package/bin/server/rpc/Server.js +22 -12
- package/bin/server/rpc/Server.js.map +1 -1
- package/bin/service/builtins/BaseService.d.ts +2 -2
- package/bin/service/builtins/BaseService.d.ts.map +1 -1
- package/bin/service/builtins/chat/Action.d.ts +1 -1
- package/bin/service/builtins/chat/Action.d.ts.map +1 -1
- package/bin/service/builtins/chat/ChatService.d.ts +2 -2
- package/bin/service/builtins/chat/ChatService.d.ts.map +1 -1
- package/bin/service/builtins/chat/ChatServiceTypes.d.ts +1 -1
- package/bin/service/builtins/chat/ChatServiceTypes.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/BaseChatChannel.d.ts +1 -1
- package/bin/service/builtins/chat/channels/BaseChatChannel.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/BaseChatChannelQueue.d.ts +1 -1
- package/bin/service/builtins/chat/channels/BaseChatChannelQueue.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/BaseChatChannelSupport.d.ts +1 -1
- package/bin/service/builtins/chat/channels/BaseChatChannelSupport.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/feishu/Feishu.d.ts +1 -1
- package/bin/service/builtins/chat/channels/feishu/Feishu.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/feishu/FeishuMessageHandler.d.ts +1 -1
- package/bin/service/builtins/chat/channels/feishu/FeishuMessageHandler.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/feishu/FeishuPlatformClient.d.ts +1 -1
- package/bin/service/builtins/chat/channels/feishu/FeishuPlatformClient.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/qq/QQ.d.ts +1 -1
- package/bin/service/builtins/chat/channels/qq/QQ.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/qq/QQMessageHandler.d.ts +1 -1
- package/bin/service/builtins/chat/channels/qq/QQMessageHandler.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/qq/QQSupport.d.ts +1 -1
- package/bin/service/builtins/chat/channels/qq/QQSupport.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/telegram/Bot.d.ts +1 -1
- package/bin/service/builtins/chat/channels/telegram/Bot.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/telegram/TelegramMessageHandler.d.ts +1 -1
- package/bin/service/builtins/chat/channels/telegram/TelegramMessageHandler.d.ts.map +1 -1
- package/bin/service/builtins/chat/channels/telegram/TelegramPlatformClient.d.ts +1 -1
- package/bin/service/builtins/chat/channels/telegram/TelegramPlatformClient.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChannelContextStore.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChannelContextStore.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatActionExecution.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatActionExecution.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatActionInput.d.ts +3 -36
- package/bin/service/builtins/chat/runtime/ChatActionInput.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatActionInput.js +3 -118
- package/bin/service/builtins/chat/runtime/ChatActionInput.js.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelActions.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelActions.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelConfig.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelConfig.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelLifecycle.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelLifecycle.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatHistoryStore.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatHistoryStore.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatIngressStore.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatIngressStore.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatMetaStore.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatMetaStore.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatQueueReplyDispatch.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatQueueReplyDispatch.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatQueueSessionBridge.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatQueueSessionBridge.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatQueueStore.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatQueueStore.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatQueueWorker.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatQueueWorker.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatServiceActions.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatServiceActions.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatServiceActions.js +2 -109
- package/bin/service/builtins/chat/runtime/ChatServiceActions.js.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatServiceSystem.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatServiceSystem.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatSessionDelete.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatSessionDelete.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatkeySend.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatkeySend.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/EnqueueDispatch.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/EnqueueDispatch.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/InboundAugment.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/InboundAugment.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/PluginDispatch.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/PluginDispatch.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ReplyDispatch.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ReplyDispatch.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/SystemPrompt.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/SystemPrompt.d.ts.map +1 -1
- package/bin/service/builtins/contact/Action.d.ts +2 -2
- package/bin/service/builtins/contact/Action.d.ts.map +1 -1
- package/bin/service/builtins/contact/Action.js +2 -58
- package/bin/service/builtins/contact/Action.js.map +1 -1
- package/bin/service/builtins/contact/ContactService.d.ts +1 -1
- package/bin/service/builtins/contact/ContactService.d.ts.map +1 -1
- package/bin/service/builtins/contact/runtime/ChatRuntime.d.ts +1 -1
- package/bin/service/builtins/contact/runtime/ChatRuntime.d.ts.map +1 -1
- package/bin/service/builtins/contact/runtime/ContactPayload.d.ts +0 -7
- package/bin/service/builtins/contact/runtime/ContactPayload.d.ts.map +1 -1
- package/bin/service/builtins/contact/runtime/ContactPayload.js +0 -9
- package/bin/service/builtins/contact/runtime/ContactPayload.js.map +1 -1
- package/bin/service/builtins/contact/runtime/RemoteClient.d.ts +1 -1
- package/bin/service/builtins/contact/runtime/RemoteClient.d.ts.map +1 -1
- package/bin/service/builtins/contact/runtime/RemoteClient.js +37 -19
- package/bin/service/builtins/contact/runtime/RemoteClient.js.map +1 -1
- package/bin/service/builtins/contact/runtime/ShareBundle.d.ts +1 -1
- package/bin/service/builtins/contact/runtime/ShareBundle.d.ts.map +1 -1
- package/bin/service/builtins/memory/Action.d.ts +1 -1
- package/bin/service/builtins/memory/Action.d.ts.map +1 -1
- package/bin/service/builtins/memory/MemoryService.d.ts +1 -1
- package/bin/service/builtins/memory/MemoryService.d.ts.map +1 -1
- package/bin/service/builtins/memory/MemoryService.js +0 -27
- package/bin/service/builtins/memory/MemoryService.js.map +1 -1
- package/bin/service/builtins/memory/runtime/Flush.d.ts +1 -1
- package/bin/service/builtins/memory/runtime/Flush.d.ts.map +1 -1
- package/bin/service/builtins/memory/runtime/Search.d.ts +1 -1
- package/bin/service/builtins/memory/runtime/Search.d.ts.map +1 -1
- package/bin/service/builtins/memory/runtime/Store.d.ts +1 -1
- package/bin/service/builtins/memory/runtime/Store.d.ts.map +1 -1
- package/bin/service/builtins/memory/runtime/SystemProvider.d.ts +1 -1
- package/bin/service/builtins/memory/runtime/SystemProvider.d.ts.map +1 -1
- package/bin/service/builtins/memory/runtime/Writer.d.ts +1 -1
- package/bin/service/builtins/memory/runtime/Writer.d.ts.map +1 -1
- package/bin/service/builtins/schedule/ScheduleService.d.ts +39 -0
- package/bin/service/builtins/schedule/ScheduleService.d.ts.map +1 -0
- package/bin/service/builtins/schedule/ScheduleService.js +106 -0
- package/bin/service/builtins/schedule/ScheduleService.js.map +1 -0
- package/bin/service/builtins/shell/ShellRuntimeTypes.d.ts +1 -1
- package/bin/service/builtins/shell/ShellRuntimeTypes.d.ts.map +1 -1
- package/bin/service/builtins/shell/ShellService.d.ts +2 -2
- package/bin/service/builtins/shell/ShellService.d.ts.map +1 -1
- package/bin/service/builtins/shell/runtime/ShellActionResponse.d.ts +1 -1
- package/bin/service/builtins/shell/runtime/ShellActionResponse.d.ts.map +1 -1
- package/bin/service/builtins/shell/runtime/ShellActionRuntime.d.ts +1 -1
- package/bin/service/builtins/shell/runtime/ShellActionRuntime.d.ts.map +1 -1
- package/bin/service/builtins/shell/runtime/ShellActionRuntimeSupport.d.ts +1 -1
- package/bin/service/builtins/shell/runtime/ShellActionRuntimeSupport.d.ts.map +1 -1
- package/bin/service/builtins/shell/runtime/ShellRuntimeEnvironment.d.ts +1 -1
- package/bin/service/builtins/shell/runtime/ShellRuntimeEnvironment.d.ts.map +1 -1
- package/bin/service/builtins/task/Action.d.ts +1 -1
- package/bin/service/builtins/task/Action.d.ts.map +1 -1
- package/bin/service/builtins/task/Scheduler.d.ts +1 -1
- package/bin/service/builtins/task/Scheduler.d.ts.map +1 -1
- package/bin/service/builtins/task/TaskService.d.ts +2 -2
- package/bin/service/builtins/task/TaskService.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/CronRuntime.d.ts +1 -1
- package/bin/service/builtins/task/runtime/CronRuntime.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/Runner.d.ts +1 -1
- package/bin/service/builtins/task/runtime/Runner.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/TaskActionExecution.d.ts +1 -1
- package/bin/service/builtins/task/runtime/TaskActionExecution.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/TaskActionInput.d.ts +2 -31
- package/bin/service/builtins/task/runtime/TaskActionInput.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/TaskActionInput.js +2 -141
- package/bin/service/builtins/task/runtime/TaskActionInput.js.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunChatDispatch.d.ts +1 -1
- package/bin/service/builtins/task/runtime/TaskRunChatDispatch.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerRound.d.ts +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerRound.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerScript.d.ts +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerScript.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerSession.d.ts +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerSession.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/TaskServiceActions.d.ts +1 -1
- package/bin/service/builtins/task/runtime/TaskServiceActions.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/TaskServiceActions.js +2 -30
- package/bin/service/builtins/task/runtime/TaskServiceActions.js.map +1 -1
- package/bin/service/core/Manager.d.ts +0 -1
- package/bin/service/core/Manager.d.ts.map +1 -1
- package/bin/service/core/Manager.js +0 -1
- package/bin/service/core/Manager.js.map +1 -1
- package/bin/service/core/ServiceActionRunner.d.ts +1 -1
- package/bin/service/core/ServiceActionRunner.d.ts.map +1 -1
- package/bin/service/core/ServiceActionRunner.js +5 -3
- package/bin/service/core/ServiceActionRunner.js.map +1 -1
- package/bin/service/core/ServiceClassRegistry.d.ts +1 -1
- package/bin/service/core/ServiceClassRegistry.d.ts.map +1 -1
- package/bin/service/core/ServiceCommandRequest.d.ts +36 -0
- package/bin/service/core/ServiceCommandRequest.d.ts.map +1 -0
- package/bin/service/core/ServiceCommandRequest.js +53 -0
- package/bin/service/core/ServiceCommandRequest.js.map +1 -0
- package/bin/service/core/ServiceStateController.d.ts +20 -7
- package/bin/service/core/ServiceStateController.d.ts.map +1 -1
- package/bin/service/core/ServiceStateController.js +23 -20
- package/bin/service/core/ServiceStateController.js.map +1 -1
- package/bin/service/core/ServiceSystemProviders.d.ts +1 -1
- package/bin/service/core/ServiceSystemProviders.d.ts.map +1 -1
- package/bin/service/core/Services.d.ts +1 -1
- package/bin/service/core/Services.d.ts.map +1 -1
- package/bin/service/core/Services.js +2 -0
- package/bin/service/core/Services.js.map +1 -1
- package/bin/service/{schedule → core/schedule}/Executor.d.ts +2 -2
- package/bin/service/core/schedule/Executor.d.ts.map +1 -0
- package/bin/service/{schedule → core/schedule}/Executor.js +1 -1
- package/bin/service/core/schedule/Executor.js.map +1 -0
- package/bin/service/{schedule → core/schedule}/Store.d.ts +1 -1
- package/bin/service/core/schedule/Store.d.ts.map +1 -0
- package/bin/service/{schedule → core/schedule}/Store.js +2 -2
- package/bin/service/core/schedule/Store.js.map +1 -0
- package/bin/service/core/schedule/Time.d.ts.map +1 -0
- package/bin/service/core/schedule/Time.js.map +1 -0
- package/bin/service/types/Service.d.ts +2 -24
- package/bin/service/types/Service.d.ts.map +1 -1
- package/bin/service/types/Service.js +1 -1
- package/bin/session/composer/system/default/DefaultSessionSystemComposer.d.ts +1 -1
- package/bin/session/composer/system/default/DefaultSessionSystemComposer.d.ts.map +1 -1
- package/bin/session/composer/system/default/SystemDomain.d.ts +1 -1
- package/bin/session/composer/system/default/SystemDomain.d.ts.map +1 -1
- package/bin/session/tools/shell/ShellToolBridge.d.ts +1 -1
- package/bin/session/tools/shell/ShellToolBridge.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/config/Config.ts +1 -1
- package/src/config/{DowncityDefault.ts → Defaults.ts} +11 -0
- package/src/{project/ProjectExecutionBinding.ts → config/ExecutionBinding.ts} +1 -1
- package/src/{runtime → core}/AgentContextTypes.ts +6 -7
- package/src/core/AgentCore.ts +527 -0
- package/src/{runtime/AgentRuntimeTypes.ts → core/AgentCoreTypes.ts} +6 -6
- package/src/host/daemon/ProjectSetup.ts +2 -3
- package/src/host/runtime/PluginRuntime.ts +1 -1
- package/src/index.ts +27 -24
- package/src/model/CreateModel.ts +1 -1
- package/src/plugin/builtins/asr/InboundAugment.ts +1 -1
- package/src/plugin/builtins/auth/runtime/AuthorizationConfig.ts +1 -1
- package/src/plugin/builtins/auth/runtime/AuthorizationStore.ts +1 -1
- package/src/plugin/builtins/voice/InboundAugment.ts +1 -1
- package/src/plugin/builtins/workboard/runtime/Collector.ts +2 -2
- package/src/plugin/builtins/workboard/runtime/Normalizer.ts +1 -1
- package/src/plugin/builtins/workboard/runtime/Store.ts +1 -1
- package/src/plugin/core/Activation.ts +2 -2
- package/src/plugin/core/HookRegistry.ts +1 -1
- package/src/plugin/core/HttpRoutes.ts +1 -1
- package/src/plugin/core/LocalExecution.ts +21 -20
- package/src/plugin/core/PluginRegistry.ts +1 -1
- package/src/plugin/types/Plugin.ts +1 -1
- package/src/project/AgentInitializer.ts +2 -2
- package/src/sandbox/SandboxConfigResolver.ts +1 -1
- package/src/sandbox/SandboxRunner.ts +1 -1
- package/src/sdk/Agent.ts +163 -391
- package/src/sdk/AgentSdkTypes.ts +158 -0
- package/src/sdk/RemoteAgent.ts +1 -1
- package/src/sdk/Session.ts +16 -6
- package/src/sdk/{SessionMetadata.ts → session/Metadata.ts} +1 -1
- package/src/sdk/{Paths.ts → session/Paths.ts} +1 -1
- package/src/sdk/{SessionPersistence.ts → session/Persistence.ts} +1 -1
- package/src/sdk/{SessionServicePort.ts → session/ServicePort.ts} +1 -1
- package/src/sdk/session/index.ts +34 -0
- package/src/server/http/Server.ts +63 -18
- package/src/server/http/control/AuthControlService.ts +1 -1
- package/src/server/http/control/ControlAuthorizationRoutes.ts +1 -1
- package/src/server/http/control/ControlRouter.ts +27 -11
- package/src/server/http/control/ExecuteBySession.ts +2 -2
- package/src/server/http/control/OverviewRoutes.ts +6 -2
- package/src/server/http/control/SessionSummaryStore.ts +1 -1
- package/src/server/http/control/types/ControlRoutes.ts +2 -2
- package/src/server/http/execute/execute.ts +107 -91
- package/src/server/http/plugins/plugins.ts +60 -44
- package/src/server/http/services/services.ts +68 -64
- package/src/server/http/static/static.ts +95 -79
- package/src/server/rpc/Server.ts +26 -15
- package/src/service/builtins/BaseService.ts +2 -2
- package/src/service/builtins/chat/Action.ts +1 -1
- package/src/service/builtins/chat/ChatService.ts +2 -2
- package/src/service/builtins/chat/ChatServiceTypes.ts +1 -1
- package/src/service/builtins/chat/channels/BaseChatChannel.ts +1 -1
- package/src/service/builtins/chat/channels/BaseChatChannelQueue.ts +1 -1
- package/src/service/builtins/chat/channels/BaseChatChannelSupport.ts +1 -1
- package/src/service/builtins/chat/channels/feishu/Feishu.ts +1 -1
- package/src/service/builtins/chat/channels/feishu/FeishuMessageHandler.ts +1 -1
- package/src/service/builtins/chat/channels/feishu/FeishuPlatformClient.ts +1 -1
- package/src/service/builtins/chat/channels/qq/QQ.ts +1 -1
- package/src/service/builtins/chat/channels/qq/QQMessageHandler.ts +1 -1
- package/src/service/builtins/chat/channels/qq/QQSupport.ts +1 -1
- package/src/service/builtins/chat/channels/telegram/Bot.ts +1 -1
- package/src/service/builtins/chat/channels/telegram/TelegramMessageHandler.ts +1 -1
- package/src/service/builtins/chat/channels/telegram/TelegramPlatformClient.ts +1 -1
- package/src/service/builtins/chat/runtime/ChannelContextStore.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatActionExecution.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatActionInput.ts +2 -158
- package/src/service/builtins/chat/runtime/ChatChannelActions.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatChannelConfig.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatChannelCore.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatChannelLifecycle.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatHistoryStore.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatIngressStore.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatMetaStore.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatQueueReplyDispatch.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatQueueSessionBridge.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatQueueStore.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatQueueWorker.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatServiceActions.ts +1 -118
- package/src/service/builtins/chat/runtime/ChatServiceSystem.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatSessionDelete.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatkeySend.ts +1 -1
- package/src/service/builtins/chat/runtime/EnqueueDispatch.ts +1 -1
- package/src/service/builtins/chat/runtime/InboundAugment.ts +1 -1
- package/src/service/builtins/chat/runtime/PluginDispatch.ts +1 -1
- package/src/service/builtins/chat/runtime/ReplyDispatch.ts +1 -1
- package/src/service/builtins/chat/runtime/SystemPrompt.ts +1 -1
- package/src/service/builtins/contact/Action.ts +2 -59
- package/src/service/builtins/contact/ContactService.ts +2 -2
- package/src/service/builtins/contact/runtime/ChatRuntime.ts +1 -1
- package/src/service/builtins/contact/runtime/ContactPayload.ts +0 -12
- package/src/service/builtins/contact/runtime/RemoteClient.ts +40 -19
- package/src/service/builtins/contact/runtime/ShareBundle.ts +1 -1
- package/src/service/builtins/memory/Action.ts +1 -1
- package/src/service/builtins/memory/MemoryService.ts +1 -28
- package/src/service/builtins/memory/runtime/Flush.ts +1 -1
- package/src/service/builtins/memory/runtime/Search.ts +1 -1
- package/src/service/builtins/memory/runtime/Store.ts +1 -1
- package/src/service/builtins/memory/runtime/SystemProvider.ts +1 -1
- package/src/service/builtins/memory/runtime/Writer.ts +1 -1
- package/src/service/builtins/schedule/ScheduleService.ts +131 -0
- package/src/service/builtins/shell/ShellRuntimeTypes.ts +1 -1
- package/src/service/builtins/shell/ShellService.ts +2 -2
- package/src/service/builtins/shell/runtime/ShellActionResponse.ts +1 -1
- package/src/service/builtins/shell/runtime/ShellActionRuntime.ts +1 -1
- package/src/service/builtins/shell/runtime/ShellActionRuntimeSupport.ts +1 -1
- package/src/service/builtins/shell/runtime/ShellRuntimeEnvironment.ts +1 -1
- package/src/service/builtins/task/Action.ts +1 -1
- package/src/service/builtins/task/Scheduler.ts +1 -1
- package/src/service/builtins/task/TaskService.ts +2 -2
- package/src/service/builtins/task/runtime/CronRuntime.ts +1 -1
- package/src/service/builtins/task/runtime/Runner.ts +1 -1
- package/src/service/builtins/task/runtime/TaskActionExecution.ts +1 -1
- package/src/service/builtins/task/runtime/TaskActionInput.ts +3 -185
- package/src/service/builtins/task/runtime/TaskRunChatDispatch.ts +1 -1
- package/src/service/builtins/task/runtime/TaskRunnerRound.ts +1 -1
- package/src/service/builtins/task/runtime/TaskRunnerScript.ts +1 -1
- package/src/service/builtins/task/runtime/TaskRunnerSession.ts +1 -1
- package/src/service/builtins/task/runtime/TaskServiceActions.ts +1 -35
- package/src/service/core/Manager.ts +0 -1
- package/src/service/core/ServiceActionRunner.ts +6 -4
- package/src/service/core/ServiceClassRegistry.ts +1 -1
- package/src/service/core/ServiceCommandRequest.ts +93 -0
- package/src/service/core/ServiceStateController.ts +45 -20
- package/src/service/core/ServiceSystemProviders.ts +1 -1
- package/src/service/core/Services.ts +3 -1
- package/src/service/{schedule → core/schedule}/Executor.ts +2 -2
- package/src/service/{schedule → core/schedule}/Store.ts +4 -2
- package/src/service/types/Service.ts +2 -25
- package/src/session/composer/system/default/DefaultSessionSystemComposer.ts +1 -1
- package/src/session/composer/system/default/SystemDomain.ts +1 -1
- package/src/session/tools/shell/ShellToolBridge.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/config/DowncityDefault.d.ts +0 -3
- package/bin/config/DowncityDefault.d.ts.map +0 -1
- package/bin/config/DowncityDefault.js.map +0 -1
- package/bin/project/ProjectExecutionBinding.d.ts.map +0 -1
- package/bin/project/ProjectExecutionBinding.js.map +0 -1
- package/bin/runtime/AgentContext.d.ts +0 -23
- package/bin/runtime/AgentContext.d.ts.map +0 -1
- package/bin/runtime/AgentContext.js +0 -149
- package/bin/runtime/AgentContext.js.map +0 -1
- package/bin/runtime/AgentContextTypes.d.ts.map +0 -1
- package/bin/runtime/AgentContextTypes.js.map +0 -1
- package/bin/runtime/AgentRuntime.d.ts +0 -37
- package/bin/runtime/AgentRuntime.d.ts.map +0 -1
- package/bin/runtime/AgentRuntime.js +0 -291
- package/bin/runtime/AgentRuntime.js.map +0 -1
- package/bin/runtime/AgentRuntimeState.d.ts +0 -42
- package/bin/runtime/AgentRuntimeState.d.ts.map +0 -1
- package/bin/runtime/AgentRuntimeState.js +0 -172
- package/bin/runtime/AgentRuntimeState.js.map +0 -1
- package/bin/runtime/AgentRuntimeTypes.d.ts.map +0 -1
- package/bin/runtime/AgentRuntimeTypes.js +0 -10
- package/bin/runtime/AgentRuntimeTypes.js.map +0 -1
- package/bin/sdk/HttpServer.d.ts +0 -40
- package/bin/sdk/HttpServer.d.ts.map +0 -1
- package/bin/sdk/HttpServer.js +0 -189
- package/bin/sdk/HttpServer.js.map +0 -1
- package/bin/sdk/Paths.d.ts.map +0 -1
- package/bin/sdk/Paths.js.map +0 -1
- package/bin/sdk/RpcServer.d.ts +0 -31
- package/bin/sdk/RpcServer.d.ts.map +0 -1
- package/bin/sdk/RpcServer.js +0 -207
- package/bin/sdk/RpcServer.js.map +0 -1
- package/bin/sdk/SessionMetadata.d.ts.map +0 -1
- package/bin/sdk/SessionMetadata.js.map +0 -1
- package/bin/sdk/SessionPersistence.d.ts.map +0 -1
- package/bin/sdk/SessionPersistence.js.map +0 -1
- package/bin/sdk/SessionServicePort.d.ts.map +0 -1
- package/bin/sdk/SessionServicePort.js.map +0 -1
- package/bin/service/core/ServiceActionApi.d.ts +0 -15
- package/bin/service/core/ServiceActionApi.d.ts.map +0 -1
- package/bin/service/core/ServiceActionApi.js +0 -234
- package/bin/service/core/ServiceActionApi.js.map +0 -1
- package/bin/service/core/ServiceManager.d.ts +0 -9
- package/bin/service/core/ServiceManager.d.ts.map +0 -1
- package/bin/service/core/ServiceManager.js +0 -9
- package/bin/service/core/ServiceManager.js.map +0 -1
- package/bin/service/schedule/Executor.d.ts.map +0 -1
- package/bin/service/schedule/Executor.js.map +0 -1
- package/bin/service/schedule/Runtime.d.ts +0 -17
- package/bin/service/schedule/Runtime.d.ts.map +0 -1
- package/bin/service/schedule/Runtime.js +0 -64
- package/bin/service/schedule/Runtime.js.map +0 -1
- package/bin/service/schedule/Store.d.ts.map +0 -1
- package/bin/service/schedule/Store.js.map +0 -1
- package/bin/service/schedule/Time.d.ts.map +0 -1
- package/bin/service/schedule/Time.js.map +0 -1
- package/src/runtime/AgentContext.ts +0 -182
- package/src/runtime/AgentRuntime.ts +0 -366
- package/src/runtime/AgentRuntimeState.ts +0 -213
- package/src/sdk/HttpServer.ts +0 -231
- package/src/sdk/RpcServer.ts +0 -244
- package/src/service/core/ServiceActionApi.ts +0 -304
- package/src/service/core/ServiceManager.ts +0 -20
- package/src/service/schedule/Runtime.ts +0 -78
- /package/bin/service/{schedule → core/schedule}/Time.d.ts +0 -0
- /package/bin/service/{schedule → core/schedule}/Time.js +0 -0
- /package/src/service/{schedule → core/schedule}/Time.ts +0 -0
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AgentRuntime 进程级状态读写模块。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 这里统一维护当前进程中的 base / ready 两阶段状态。
|
|
6
|
-
* - `AgentRuntimeBase` 只表示启动早期已经可用的基础配置;`AgentRuntime` 才表示完整运行态。
|
|
7
|
-
* - 该模块只负责状态持有与读写,不负责装配具体依赖对象。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { LanguageModel } from "ai";
|
|
11
|
-
import type {
|
|
12
|
-
AgentRuntime,
|
|
13
|
-
AgentRuntimeBase,
|
|
14
|
-
} from "@/runtime/AgentRuntimeTypes.js";
|
|
15
|
-
import type { DowncityConfig } from "@/types/config/DowncityConfig.js";
|
|
16
|
-
import type {
|
|
17
|
-
AgentPathRuntime,
|
|
18
|
-
AgentPlatformRuntime,
|
|
19
|
-
AgentPluginConfigRuntime,
|
|
20
|
-
} from "@/types/host/AgentHost.js";
|
|
21
|
-
import type { ChatChannelName } from "@/service/builtins/chat/types/ChannelStatus.js";
|
|
22
|
-
export type { AgentRuntime, AgentRuntimeBase } from "@/runtime/AgentRuntimeTypes.js";
|
|
23
|
-
|
|
24
|
-
let baseState: AgentRuntimeBase | null = null;
|
|
25
|
-
let readyState: AgentRuntime | null = null;
|
|
26
|
-
|
|
27
|
-
const EMPTY_PATHS: AgentPathRuntime = {
|
|
28
|
-
projectRoot: ".",
|
|
29
|
-
getDowncityDirPath: () => ".downcity",
|
|
30
|
-
getCacheDirPath: () => ".downcity/.cache",
|
|
31
|
-
getDowncityChannelDirPath: () => ".downcity/channel",
|
|
32
|
-
getDowncityChannelMetaPath: () => ".downcity/channel/meta.json",
|
|
33
|
-
getDowncityChatHistoryPath: (sessionId) => `.downcity/chat/${sessionId}/history.jsonl`,
|
|
34
|
-
getDowncityMemoryLongTermPath: () => ".downcity/memory/MEMORY.md",
|
|
35
|
-
getDowncityMemoryDailyDirPath: () => ".downcity/memory/daily",
|
|
36
|
-
getDowncityMemoryDailyPath: (date) => `.downcity/memory/daily/${date}.md`,
|
|
37
|
-
getDowncitySessionRootDirPath: () => ".downcity/session",
|
|
38
|
-
getDowncitySessionDirPath: (sessionId) => `.downcity/session/${sessionId}`,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const EMPTY_PLUGIN_CONFIG: AgentPluginConfigRuntime = {
|
|
42
|
-
async persistProjectPlugins() {
|
|
43
|
-
return "";
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const EMPTY_PLATFORM: AgentPlatformRuntime = {
|
|
48
|
-
getGlobalEnv: () => ({}),
|
|
49
|
-
getAgentEnv: () => ({}),
|
|
50
|
-
listModels: () => [],
|
|
51
|
-
listProviders: async () => [],
|
|
52
|
-
getModel: () => null,
|
|
53
|
-
getChannelAccount: () => null,
|
|
54
|
-
listChannelAccounts: async () => [],
|
|
55
|
-
probeChannelAccount: async () => {
|
|
56
|
-
throw new Error("Channel account probing is not available in this runtime");
|
|
57
|
-
},
|
|
58
|
-
createChannelAccount: async () => {
|
|
59
|
-
throw new Error("Channel account creation is not available in this runtime");
|
|
60
|
-
},
|
|
61
|
-
updateChannelAccount: async () => {
|
|
62
|
-
throw new Error("Channel account update is not available in this runtime");
|
|
63
|
-
},
|
|
64
|
-
removeChannelAccount: async () => {
|
|
65
|
-
throw new Error("Channel account removal is not available in this runtime");
|
|
66
|
-
},
|
|
67
|
-
resolveChannelAccount: (_params: {
|
|
68
|
-
projectRoot: string;
|
|
69
|
-
channel: ChatChannelName;
|
|
70
|
-
channelAccountId?: string;
|
|
71
|
-
}) => null,
|
|
72
|
-
readChatAuthorizationConfig: () => ({
|
|
73
|
-
roles: {},
|
|
74
|
-
channels: {},
|
|
75
|
-
}),
|
|
76
|
-
writeChatAuthorizationConfig: async (_projectRoot, nextConfig) => nextConfig,
|
|
77
|
-
setChatAuthorizationUserRole: async () => ({
|
|
78
|
-
roles: {},
|
|
79
|
-
channels: {},
|
|
80
|
-
}),
|
|
81
|
-
isPluginEnabled: (pluginName) => pluginName === "auth",
|
|
82
|
-
setPluginEnabled: () => {
|
|
83
|
-
throw new Error("Plugin lifecycle management is not available in this runtime");
|
|
84
|
-
},
|
|
85
|
-
listPlatformModelChoices: async () => [],
|
|
86
|
-
initializeAgentProject: async () => {
|
|
87
|
-
throw new Error("Agent project initialization is not available in this runtime");
|
|
88
|
-
},
|
|
89
|
-
ensureRuntimeExecutionBindingReady: () => {
|
|
90
|
-
throw new Error("Execution binding validation is not available in this runtime");
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
function normalizeReadyState(input: AgentRuntime): AgentRuntime {
|
|
95
|
-
if (typeof input.getSession !== "function") {
|
|
96
|
-
throw new Error("AgentRuntime requires getSession");
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
cwd: input.cwd,
|
|
101
|
-
rootPath: input.rootPath,
|
|
102
|
-
logger: input.logger,
|
|
103
|
-
config: input.config,
|
|
104
|
-
env: input.env,
|
|
105
|
-
globalEnv: input.globalEnv,
|
|
106
|
-
systems: input.systems,
|
|
107
|
-
paths: input.paths || EMPTY_PATHS,
|
|
108
|
-
pluginConfig: input.pluginConfig || EMPTY_PLUGIN_CONFIG,
|
|
109
|
-
platform: input.platform || EMPTY_PLATFORM,
|
|
110
|
-
model: input.model,
|
|
111
|
-
getSession: input.getSession,
|
|
112
|
-
listExecutingSessionIds:
|
|
113
|
-
input.listExecutingSessionIds || (() => []),
|
|
114
|
-
getExecutingSessionCount:
|
|
115
|
-
input.getExecutingSessionCount || (() => 0),
|
|
116
|
-
services: input.services || new Map(),
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function normalizeBaseState(input: AgentRuntimeBase): AgentRuntimeBase {
|
|
121
|
-
return {
|
|
122
|
-
cwd: input.cwd,
|
|
123
|
-
rootPath: input.rootPath,
|
|
124
|
-
logger: input.logger,
|
|
125
|
-
config: input.config,
|
|
126
|
-
env: input.env,
|
|
127
|
-
globalEnv: input.globalEnv,
|
|
128
|
-
systems: input.systems,
|
|
129
|
-
paths: input.paths || EMPTY_PATHS,
|
|
130
|
-
pluginConfig: input.pluginConfig || EMPTY_PLUGIN_CONFIG,
|
|
131
|
-
platform: input.platform || EMPTY_PLATFORM,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* 设置 agent 基础状态。
|
|
137
|
-
*/
|
|
138
|
-
export function setAgentRuntimeBase(next: AgentRuntimeBase): void {
|
|
139
|
-
baseState = normalizeBaseState(next);
|
|
140
|
-
readyState = null;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* 设置完整 agent 状态。
|
|
145
|
-
*/
|
|
146
|
-
export function setAgentRuntime(next: AgentRuntime): void {
|
|
147
|
-
const normalized = normalizeReadyState(next);
|
|
148
|
-
baseState = normalized;
|
|
149
|
-
readyState = normalized;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* 仅更新当前 agent 的项目配置快照。
|
|
154
|
-
*
|
|
155
|
-
* 关键点(中文)
|
|
156
|
-
* - 运行中 agent 可能在不重启进程的情况下收到 downcity.json 变更。
|
|
157
|
-
* - 这里仅替换 `config`,不重建 model / service / session 等长期对象。
|
|
158
|
-
* - 目标是让 plugin 启用态、system 注入等直接依赖配置快照的能力及时生效。
|
|
159
|
-
*/
|
|
160
|
-
export function updateAgentRuntimeConfig(nextConfig: DowncityConfig): void {
|
|
161
|
-
if (!baseState) {
|
|
162
|
-
throw new Error(
|
|
163
|
-
"Agent state is not initialized. Call initAgentRuntime() during startup.",
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
baseState = {
|
|
168
|
-
...baseState,
|
|
169
|
-
config: nextConfig,
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
if (readyState) {
|
|
173
|
-
readyState = {
|
|
174
|
-
...readyState,
|
|
175
|
-
config: nextConfig,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* 获取 agent 基础状态。
|
|
182
|
-
*/
|
|
183
|
-
export function getAgentRuntimeBase(): AgentRuntimeBase {
|
|
184
|
-
if (baseState) return baseState;
|
|
185
|
-
throw new Error(
|
|
186
|
-
"Agent state (base) is not initialized. Call initAgentRuntime() during startup.",
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* 获取完整 agent 状态。
|
|
192
|
-
*/
|
|
193
|
-
export function getAgentRuntime(): AgentRuntime {
|
|
194
|
-
if (readyState) return readyState;
|
|
195
|
-
if (!baseState) {
|
|
196
|
-
throw new Error(
|
|
197
|
-
"Agent state is not initialized. Call initAgentRuntime() during startup.",
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
throw new Error(
|
|
201
|
-
"Agent state is not ready yet. Ensure session is initialized before access.",
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* 读取当前 agent 模型实例(必填)。
|
|
207
|
-
*/
|
|
208
|
-
export function requireAgentModel(): LanguageModel {
|
|
209
|
-
if (readyState?.model) return readyState.model;
|
|
210
|
-
throw new Error(
|
|
211
|
-
"Agent model is not initialized. Ensure initAgentRuntime() completed successfully.",
|
|
212
|
-
);
|
|
213
|
-
}
|
package/src/sdk/HttpServer.ts
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SDK HTTP Server。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 面向 `RemoteAgent` 暴露最小 session 能力集合。
|
|
6
|
-
* - v1 先聚焦 session 创建、列表、history、run、stream、fork。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import http from "node:http";
|
|
10
|
-
import { Hono } from "hono";
|
|
11
|
-
import { cors } from "hono/cors";
|
|
12
|
-
import type { Agent } from "@/sdk/Agent.js";
|
|
13
|
-
|
|
14
|
-
type SdkHttpStartOptions = {
|
|
15
|
-
/**
|
|
16
|
-
* 监听主机。
|
|
17
|
-
*/
|
|
18
|
-
host?: string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 监听端口。
|
|
22
|
-
*/
|
|
23
|
-
port?: number;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* SDK HTTP Server 管理器。
|
|
28
|
-
*/
|
|
29
|
-
export class SdkAgentHttpServer {
|
|
30
|
-
private readonly agent: Agent;
|
|
31
|
-
private server: http.Server | null = null;
|
|
32
|
-
private baseUrlValue: string | null = null;
|
|
33
|
-
|
|
34
|
-
constructor(agent: Agent) {
|
|
35
|
-
this.agent = agent;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 启动 HTTP Server。
|
|
40
|
-
*/
|
|
41
|
-
async start(options?: SdkHttpStartOptions): Promise<{ baseUrl: string }> {
|
|
42
|
-
if (this.server && this.baseUrlValue) {
|
|
43
|
-
return { baseUrl: this.baseUrlValue };
|
|
44
|
-
}
|
|
45
|
-
await this.agent.ensureServicesStarted();
|
|
46
|
-
const host = String(options?.host || "127.0.0.1").trim() || "127.0.0.1";
|
|
47
|
-
const port =
|
|
48
|
-
typeof options?.port === "number" && Number.isInteger(options.port)
|
|
49
|
-
? options.port
|
|
50
|
-
: 15314;
|
|
51
|
-
|
|
52
|
-
const app = new Hono();
|
|
53
|
-
app.use(
|
|
54
|
-
"*",
|
|
55
|
-
cors({
|
|
56
|
-
origin: "*",
|
|
57
|
-
allowMethods: ["GET", "POST", "OPTIONS"],
|
|
58
|
-
allowHeaders: ["Content-Type"],
|
|
59
|
-
}),
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
app.get("/api/sdk/sessions", async (c) => {
|
|
63
|
-
return c.json({
|
|
64
|
-
success: true,
|
|
65
|
-
sessions: await this.agent.sessions(),
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
app.post("/api/sdk/sessions", async (c) => {
|
|
70
|
-
const body = await c.req.json().catch(() => ({}));
|
|
71
|
-
const session = await this.agent.session(
|
|
72
|
-
typeof body?.sessionId === "string" ? body.sessionId : undefined,
|
|
73
|
-
);
|
|
74
|
-
return c.json({
|
|
75
|
-
success: true,
|
|
76
|
-
session: await session.toMetadata(),
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
app.get("/api/sdk/sessions/:sessionId/messages", async (c) => {
|
|
81
|
-
const session = await this.agent.session(String(c.req.param("sessionId") || ""));
|
|
82
|
-
return c.json({
|
|
83
|
-
success: true,
|
|
84
|
-
sessionId: session.id,
|
|
85
|
-
messages: await session.history(),
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
app.get("/api/sdk/sessions/:sessionId/system", async (c) => {
|
|
90
|
-
const session = await this.agent.session(String(c.req.param("sessionId") || ""));
|
|
91
|
-
return c.json({
|
|
92
|
-
success: true,
|
|
93
|
-
sessionId: session.id,
|
|
94
|
-
system: await session.system(),
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
app.post("/api/sdk/sessions/:sessionId/run", async (c) => {
|
|
99
|
-
const session = await this.agent.session(String(c.req.param("sessionId") || ""));
|
|
100
|
-
const body = await c.req.json().catch(() => ({}));
|
|
101
|
-
const query = String(body?.query || "").trim();
|
|
102
|
-
if (!query) {
|
|
103
|
-
return c.json({ success: false, error: "query is required" }, 400);
|
|
104
|
-
}
|
|
105
|
-
const result = await session.run({ query });
|
|
106
|
-
return c.json({
|
|
107
|
-
success: true,
|
|
108
|
-
sessionId: session.id,
|
|
109
|
-
result,
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
app.post("/api/sdk/sessions/:sessionId/fork", async (c) => {
|
|
114
|
-
const session = await this.agent.session(String(c.req.param("sessionId") || ""));
|
|
115
|
-
const body = await c.req.json().catch(() => ({}));
|
|
116
|
-
const forked = await session.fork(
|
|
117
|
-
typeof body?.messageId === "string" ? body.messageId : undefined,
|
|
118
|
-
);
|
|
119
|
-
return c.json({
|
|
120
|
-
success: true,
|
|
121
|
-
session: await forked.toMetadata(),
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
app.post("/api/sdk/sessions/:sessionId/stream", async (c) => {
|
|
126
|
-
const session = await this.agent.session(String(c.req.param("sessionId") || ""));
|
|
127
|
-
const body = await c.req.json().catch(() => ({}));
|
|
128
|
-
const query = String(body?.query || "").trim();
|
|
129
|
-
if (!query) {
|
|
130
|
-
return c.json({ success: false, error: "query is required" }, 400);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const encoder = new TextEncoder();
|
|
134
|
-
const stream = new ReadableStream<Uint8Array>({
|
|
135
|
-
start: async (controller) => {
|
|
136
|
-
try {
|
|
137
|
-
for await (const event of session.stream({ query })) {
|
|
138
|
-
controller.enqueue(
|
|
139
|
-
encoder.encode(`${JSON.stringify(event)}\n`),
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
controller.close();
|
|
143
|
-
} catch (error) {
|
|
144
|
-
controller.enqueue(
|
|
145
|
-
encoder.encode(
|
|
146
|
-
`${JSON.stringify({
|
|
147
|
-
type: "error",
|
|
148
|
-
error: error instanceof Error ? error.message : String(error),
|
|
149
|
-
})}\n`,
|
|
150
|
-
),
|
|
151
|
-
);
|
|
152
|
-
controller.close();
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
return new Response(stream, {
|
|
158
|
-
headers: {
|
|
159
|
-
"Content-Type": "application/x-ndjson; charset=utf-8",
|
|
160
|
-
"Cache-Control": "no-cache, no-transform",
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
const server = http.createServer(async (req, res) => {
|
|
166
|
-
try {
|
|
167
|
-
const url = new URL(req.url || "/", `http://${host}:${port}`);
|
|
168
|
-
const method = req.method || "GET";
|
|
169
|
-
const bodyBuffer = await this.readRequestBody(req);
|
|
170
|
-
const request = new Request(url.toString(), {
|
|
171
|
-
method,
|
|
172
|
-
headers: new Headers(req.headers as Record<string, string>),
|
|
173
|
-
body: bodyBuffer.length > 0 ? bodyBuffer : undefined,
|
|
174
|
-
});
|
|
175
|
-
const response = await app.fetch(request);
|
|
176
|
-
res.statusCode = response.status;
|
|
177
|
-
response.headers.forEach((value, key) => {
|
|
178
|
-
res.setHeader(key, value);
|
|
179
|
-
});
|
|
180
|
-
if (!response.body) {
|
|
181
|
-
res.end();
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
const reader = response.body.getReader();
|
|
185
|
-
while (true) {
|
|
186
|
-
const { done, value } = await reader.read();
|
|
187
|
-
if (done) break;
|
|
188
|
-
if (value) res.write(Buffer.from(value));
|
|
189
|
-
}
|
|
190
|
-
res.end();
|
|
191
|
-
} catch (error) {
|
|
192
|
-
res.statusCode = 500;
|
|
193
|
-
res.end(String(error));
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
await new Promise<void>((resolve) => {
|
|
198
|
-
server.listen(port, host, () => resolve());
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
this.server = server;
|
|
202
|
-
this.baseUrlValue = `http://${host}:${port}`;
|
|
203
|
-
return {
|
|
204
|
-
baseUrl: this.baseUrlValue,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* 停止 HTTP Server。
|
|
210
|
-
*/
|
|
211
|
-
async stop(): Promise<void> {
|
|
212
|
-
if (!this.server) return;
|
|
213
|
-
const current = this.server;
|
|
214
|
-
this.server = null;
|
|
215
|
-
this.baseUrlValue = null;
|
|
216
|
-
await new Promise<void>((resolve) => {
|
|
217
|
-
current.close(() => resolve());
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
private async readRequestBody(
|
|
222
|
-
req: http.IncomingMessage,
|
|
223
|
-
): Promise<Buffer> {
|
|
224
|
-
return await new Promise<Buffer>((resolve, reject) => {
|
|
225
|
-
const chunks: Buffer[] = [];
|
|
226
|
-
req.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
|
|
227
|
-
req.on("end", () => resolve(Buffer.concat(chunks)));
|
|
228
|
-
req.on("error", reject);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
}
|
package/src/sdk/RpcServer.ts
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SDK 本地 RPC Server。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 面向同机受信任进程提供最小 session JSON RPC 能力。
|
|
6
|
-
* - v1 先支持 session 列表、加载、run、history、fork。
|
|
7
|
-
* - stream 仍建议优先走 HTTP NDJSON。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import fs from "fs-extra";
|
|
11
|
-
import net, { type Server } from "node:net";
|
|
12
|
-
import path from "node:path";
|
|
13
|
-
import type { Agent } from "@/sdk/Agent.js";
|
|
14
|
-
import type {
|
|
15
|
-
LocalRpcRequest,
|
|
16
|
-
LocalRpcResponse,
|
|
17
|
-
} from "@/types/rpc/LocalRpc.js";
|
|
18
|
-
import { getSdkAgentRpcEndpointPath } from "@/sdk/Paths.js";
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* SDK RPC Server 管理器。
|
|
22
|
-
*/
|
|
23
|
-
export class SdkAgentRpcServer {
|
|
24
|
-
private readonly agent: Agent;
|
|
25
|
-
private server: Server | null = null;
|
|
26
|
-
private endpoint: string | null = null;
|
|
27
|
-
|
|
28
|
-
constructor(agent: Agent) {
|
|
29
|
-
this.agent = agent;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 启动本地 RPC server。
|
|
34
|
-
*/
|
|
35
|
-
async start(): Promise<{ endpoint: string }> {
|
|
36
|
-
if (this.server && this.endpoint) {
|
|
37
|
-
return { endpoint: this.endpoint };
|
|
38
|
-
}
|
|
39
|
-
await this.agent.ensureServicesStarted();
|
|
40
|
-
|
|
41
|
-
const endpoint = getSdkAgentRpcEndpointPath(this.agent.path, this.agent.id);
|
|
42
|
-
await fs.ensureDir(path.dirname(endpoint));
|
|
43
|
-
await fs.remove(endpoint).catch(() => undefined);
|
|
44
|
-
|
|
45
|
-
const server = net.createServer((socket) => {
|
|
46
|
-
let buffered = "";
|
|
47
|
-
socket.setEncoding("utf8");
|
|
48
|
-
socket.on("data", (chunk) => {
|
|
49
|
-
buffered += String(chunk || "");
|
|
50
|
-
const newlineIndex = buffered.indexOf("\n");
|
|
51
|
-
if (newlineIndex < 0) return;
|
|
52
|
-
const raw = buffered.slice(0, newlineIndex).trim();
|
|
53
|
-
buffered = buffered.slice(newlineIndex + 1);
|
|
54
|
-
void this.respond(raw, socket);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
await new Promise<void>((resolve, reject) => {
|
|
59
|
-
server.once("error", reject);
|
|
60
|
-
server.listen(endpoint, () => {
|
|
61
|
-
server.off("error", reject);
|
|
62
|
-
resolve();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
this.server = server;
|
|
67
|
-
this.endpoint = endpoint;
|
|
68
|
-
return { endpoint };
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 停止本地 RPC server。
|
|
73
|
-
*/
|
|
74
|
-
async stop(): Promise<void> {
|
|
75
|
-
if (!this.server) return;
|
|
76
|
-
const current = this.server;
|
|
77
|
-
const endpoint = this.endpoint;
|
|
78
|
-
this.server = null;
|
|
79
|
-
this.endpoint = null;
|
|
80
|
-
await new Promise<void>((resolve) => current.close(() => resolve()));
|
|
81
|
-
if (endpoint) {
|
|
82
|
-
await fs.remove(endpoint).catch(() => undefined);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private async respond(raw: string, socket: net.Socket): Promise<void> {
|
|
87
|
-
let request: LocalRpcRequest | null = null;
|
|
88
|
-
try {
|
|
89
|
-
request = JSON.parse(raw) as LocalRpcRequest;
|
|
90
|
-
} catch {
|
|
91
|
-
socket.write(
|
|
92
|
-
`${JSON.stringify({
|
|
93
|
-
requestId: "unknown",
|
|
94
|
-
status: 400,
|
|
95
|
-
success: false,
|
|
96
|
-
error: "Invalid RPC JSON payload",
|
|
97
|
-
} satisfies LocalRpcResponse)}\n`,
|
|
98
|
-
);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const response = await this.dispatch(request);
|
|
103
|
-
socket.write(`${JSON.stringify(response)}\n`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
private async dispatch(request: LocalRpcRequest): Promise<LocalRpcResponse> {
|
|
107
|
-
const requestId = String(request.requestId || "").trim() || "unknown";
|
|
108
|
-
try {
|
|
109
|
-
if (request.method === "GET" && request.path === "/api/sdk/sessions") {
|
|
110
|
-
return {
|
|
111
|
-
requestId,
|
|
112
|
-
status: 200,
|
|
113
|
-
success: true,
|
|
114
|
-
data: {
|
|
115
|
-
success: true,
|
|
116
|
-
sessions: await this.agent.sessions(),
|
|
117
|
-
} as unknown as LocalRpcResponse["data"],
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (request.method === "POST" && request.path === "/api/sdk/sessions") {
|
|
122
|
-
const body =
|
|
123
|
-
request.body && typeof request.body === "object" && !Array.isArray(request.body)
|
|
124
|
-
? request.body
|
|
125
|
-
: {};
|
|
126
|
-
const session = await this.agent.session(
|
|
127
|
-
typeof body.sessionId === "string" ? body.sessionId : undefined,
|
|
128
|
-
);
|
|
129
|
-
return {
|
|
130
|
-
requestId,
|
|
131
|
-
status: 200,
|
|
132
|
-
success: true,
|
|
133
|
-
data: {
|
|
134
|
-
success: true,
|
|
135
|
-
session: await session.toMetadata(),
|
|
136
|
-
} as unknown as LocalRpcResponse["data"],
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const runMatch = /^\/api\/sdk\/sessions\/([^/]+)\/run$/.exec(request.path);
|
|
141
|
-
if (request.method === "POST" && runMatch) {
|
|
142
|
-
const session = await this.agent.session(
|
|
143
|
-
decodeURIComponent(runMatch[1] || ""),
|
|
144
|
-
);
|
|
145
|
-
const body =
|
|
146
|
-
request.body && typeof request.body === "object" && !Array.isArray(request.body)
|
|
147
|
-
? request.body
|
|
148
|
-
: {};
|
|
149
|
-
const query = String(body.query || "").trim();
|
|
150
|
-
if (!query) {
|
|
151
|
-
return {
|
|
152
|
-
requestId,
|
|
153
|
-
status: 400,
|
|
154
|
-
success: false,
|
|
155
|
-
error: "query is required",
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
requestId,
|
|
160
|
-
status: 200,
|
|
161
|
-
success: true,
|
|
162
|
-
data: {
|
|
163
|
-
success: true,
|
|
164
|
-
sessionId: session.id,
|
|
165
|
-
result: await session.run({ query }),
|
|
166
|
-
} as unknown as LocalRpcResponse["data"],
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const forkMatch = /^\/api\/sdk\/sessions\/([^/]+)\/fork$/.exec(request.path);
|
|
171
|
-
if (request.method === "POST" && forkMatch) {
|
|
172
|
-
const session = await this.agent.session(
|
|
173
|
-
decodeURIComponent(forkMatch[1] || ""),
|
|
174
|
-
);
|
|
175
|
-
const body =
|
|
176
|
-
request.body && typeof request.body === "object" && !Array.isArray(request.body)
|
|
177
|
-
? request.body
|
|
178
|
-
: {};
|
|
179
|
-
const forked = await session.fork(
|
|
180
|
-
typeof body.messageId === "string" ? body.messageId : undefined,
|
|
181
|
-
);
|
|
182
|
-
return {
|
|
183
|
-
requestId,
|
|
184
|
-
status: 200,
|
|
185
|
-
success: true,
|
|
186
|
-
data: {
|
|
187
|
-
success: true,
|
|
188
|
-
session: await forked.toMetadata(),
|
|
189
|
-
} as unknown as LocalRpcResponse["data"],
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const messagesMatch =
|
|
194
|
-
/^\/api\/sdk\/sessions\/([^/]+)\/messages$/.exec(request.path);
|
|
195
|
-
if (request.method === "GET" && messagesMatch) {
|
|
196
|
-
const session = await this.agent.session(
|
|
197
|
-
decodeURIComponent(messagesMatch[1] || ""),
|
|
198
|
-
);
|
|
199
|
-
return {
|
|
200
|
-
requestId,
|
|
201
|
-
status: 200,
|
|
202
|
-
success: true,
|
|
203
|
-
data: {
|
|
204
|
-
success: true,
|
|
205
|
-
sessionId: session.id,
|
|
206
|
-
messages: await session.history(),
|
|
207
|
-
} as unknown as LocalRpcResponse["data"],
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const systemMatch =
|
|
212
|
-
/^\/api\/sdk\/sessions\/([^/]+)\/system$/.exec(request.path);
|
|
213
|
-
if (request.method === "GET" && systemMatch) {
|
|
214
|
-
const session = await this.agent.session(
|
|
215
|
-
decodeURIComponent(systemMatch[1] || ""),
|
|
216
|
-
);
|
|
217
|
-
return {
|
|
218
|
-
requestId,
|
|
219
|
-
status: 200,
|
|
220
|
-
success: true,
|
|
221
|
-
data: {
|
|
222
|
-
success: true,
|
|
223
|
-
sessionId: session.id,
|
|
224
|
-
system: await session.system(),
|
|
225
|
-
} as unknown as LocalRpcResponse["data"],
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return {
|
|
230
|
-
requestId,
|
|
231
|
-
status: 404,
|
|
232
|
-
success: false,
|
|
233
|
-
error: `Unknown RPC path: ${request.method} ${request.path}`,
|
|
234
|
-
};
|
|
235
|
-
} catch (error) {
|
|
236
|
-
return {
|
|
237
|
-
requestId,
|
|
238
|
-
status: 500,
|
|
239
|
-
success: false,
|
|
240
|
-
error: error instanceof Error ? error.message : String(error),
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|