@downcity/agent 1.1.13 → 1.1.14
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/{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/runtime/PluginRuntime.d.ts +1 -1
- package/bin/host/runtime/PluginRuntime.d.ts.map +1 -1
- package/bin/index.d.ts +6 -8
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +2 -5
- package/bin/index.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/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 +25 -23
- package/bin/sdk/Agent.d.ts.map +1 -1
- package/bin/sdk/Agent.js +86 -365
- 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/HttpServer.d.ts +9 -19
- package/bin/sdk/HttpServer.d.ts.map +1 -1
- package/bin/sdk/HttpServer.js +26 -156
- package/bin/sdk/HttpServer.js.map +1 -1
- package/bin/sdk/RpcServer.d.ts +9 -10
- package/bin/sdk/RpcServer.d.ts.map +1 -1
- package/bin/sdk/RpcServer.js +22 -178
- package/bin/sdk/RpcServer.js.map +1 -1
- package/bin/sdk/Session.d.ts +2 -2
- package/bin/sdk/Session.d.ts.map +1 -1
- package/bin/sdk/Session.js +7 -1
- package/bin/sdk/Session.js.map +1 -1
- package/bin/sdk/SessionServicePort.d.ts +1 -1
- package/bin/sdk/SessionServicePort.d.ts.map +1 -1
- 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 +3 -1
- 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/ServiceManager.d.ts +1 -1
- package/bin/service/core/ServiceManager.d.ts.map +1 -1
- 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/Executor.d.ts +1 -1
- package/bin/service/schedule/Executor.d.ts.map +1 -1
- package/bin/service/types/Service.d.ts +1 -23
- package/bin/service/types/Service.d.ts.map +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/{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/runtime/PluginRuntime.ts +1 -1
- package/src/index.ts +24 -21
- 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/sandbox/SandboxConfigResolver.ts +1 -1
- package/src/sandbox/SandboxRunner.ts +1 -1
- package/src/sdk/Agent.ts +99 -393
- package/src/sdk/AgentSdkTypes.ts +158 -0
- package/src/sdk/HttpServer.ts +27 -192
- package/src/sdk/RpcServer.ts +24 -211
- package/src/sdk/Session.ts +12 -2
- package/src/sdk/SessionServicePort.ts +1 -1
- 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 +4 -2
- package/src/service/core/ServiceClassRegistry.ts +1 -1
- package/src/service/core/ServiceCommandRequest.ts +93 -0
- package/src/service/core/ServiceManager.ts +0 -1
- 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/Executor.ts +1 -1
- package/src/service/types/Service.ts +1 -24
- 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/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/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/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/src/runtime/AgentContext.ts +0 -182
- package/src/runtime/AgentRuntime.ts +0 -366
- package/src/runtime/AgentRuntimeState.ts +0 -213
- package/src/service/core/ServiceActionApi.ts +0 -304
- package/src/service/schedule/Runtime.ts +0 -78
package/src/sdk/Session.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 面向 `new Agent(...)` 的本地会话使用场景。
|
|
6
|
-
* -
|
|
6
|
+
* - 统一收口消息落盘、session 级模型配置、run/stream/fork 等高层 API。
|
|
7
7
|
* - 内部继续复用 `Executor` / `JsonlSessionHistoryComposer` / `Runner`。
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
getSdkAgentSessionDirPath,
|
|
41
41
|
} from "@/sdk/Paths.js";
|
|
42
42
|
import { AsyncQueue } from "@/sdk/AsyncQueue.js";
|
|
43
|
-
import type { SessionPort } from "@/
|
|
43
|
+
import type { SessionPort } from "@/core/AgentContextTypes.js";
|
|
44
44
|
import { pushUiMessageChunkAsSdkEvent } from "@/sdk/StreamEvents.js";
|
|
45
45
|
import {
|
|
46
46
|
persistSdkAssistantResult,
|
|
@@ -332,6 +332,11 @@ export class Session {
|
|
|
332
332
|
if (!query) {
|
|
333
333
|
throw new Error("session.run requires a non-empty query");
|
|
334
334
|
}
|
|
335
|
+
if (!this.sessionConfig.model) {
|
|
336
|
+
throw new Error(
|
|
337
|
+
`Session "${this.id}" requires a configured model. Call session.set({ model }) first or let the host configure the session during creation.`,
|
|
338
|
+
);
|
|
339
|
+
}
|
|
335
340
|
await this.appendUserMessage({ text: query });
|
|
336
341
|
const result = await this.executor.run({
|
|
337
342
|
query,
|
|
@@ -355,6 +360,11 @@ export class Session {
|
|
|
355
360
|
if (!query) {
|
|
356
361
|
throw new Error("session.stream requires a non-empty query");
|
|
357
362
|
}
|
|
363
|
+
if (!this.sessionConfig.model) {
|
|
364
|
+
throw new Error(
|
|
365
|
+
`Session "${this.id}" requires a configured model. Call session.set({ model }) first or let the host configure the session during creation.`,
|
|
366
|
+
);
|
|
367
|
+
}
|
|
358
368
|
const queue = new AsyncQueue<AgentSessionStreamEvent>();
|
|
359
369
|
const toolNameByCallId = new Map<string, string>();
|
|
360
370
|
await this.appendUserMessage({ text: query });
|
|
@@ -12,20 +12,20 @@ import { cors } from "hono/cors";
|
|
|
12
12
|
import { logger } from "hono/logger";
|
|
13
13
|
import http from "node:http";
|
|
14
14
|
import { logger as serverLogger } from "@/utils/logger/Logger.js";
|
|
15
|
-
import {
|
|
15
|
+
import { createExecuteRouter } from "@/server/http/execute/execute.js";
|
|
16
16
|
import { healthRouter } from "@/server/http/health/health.js";
|
|
17
17
|
import {
|
|
18
|
-
|
|
19
|
-
servicesRouter,
|
|
18
|
+
createServicesRouter,
|
|
20
19
|
} from "@/server/http/services/services.js";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
20
|
+
import { createPluginsRouter } from "@/server/http/plugins/plugins.js";
|
|
21
|
+
import { createStaticRouter } from "@/server/http/static/static.js";
|
|
22
|
+
import { createControlRouter } from "@/server/http/control/ControlRouter.js";
|
|
24
23
|
import {
|
|
25
|
-
listBuiltinPluginRuntimeAuthPolicies,
|
|
26
24
|
registerBuiltinPluginHttpRoutes,
|
|
27
25
|
} from "@/plugin/core/HttpRoutes.js";
|
|
28
|
-
import {
|
|
26
|
+
import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
|
|
27
|
+
import type { AgentContext } from "@/core/AgentContextTypes.js";
|
|
28
|
+
import type { AgentCore } from "@/core/AgentCore.js";
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Server 启动参数。
|
|
@@ -35,6 +35,12 @@ export interface ServerStartOptions {
|
|
|
35
35
|
port: number;
|
|
36
36
|
/** HTTP 服务监听主机。 */
|
|
37
37
|
host: string;
|
|
38
|
+
/** 可选实例级 agent core。 */
|
|
39
|
+
core?: Pick<AgentCore, "getContext" | "getRuntime">;
|
|
40
|
+
/** 可选实例级 runtime 读取函数。 */
|
|
41
|
+
getAgentRuntime?: () => AgentRuntime;
|
|
42
|
+
/** 可选实例级 context 读取函数。 */
|
|
43
|
+
getAgentContext?: () => AgentContext;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
46
|
/**
|
|
@@ -49,11 +55,41 @@ export interface ServerInstance {
|
|
|
49
55
|
stop(): Promise<void>;
|
|
50
56
|
}
|
|
51
57
|
|
|
58
|
+
type AgentServerBindings = {
|
|
59
|
+
getAgentRuntime: () => AgentRuntime;
|
|
60
|
+
getAgentContext: () => AgentContext;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
function resolveServerBindings(options: Pick<
|
|
64
|
+
ServerStartOptions,
|
|
65
|
+
"core" | "getAgentRuntime" | "getAgentContext"
|
|
66
|
+
>): AgentServerBindings {
|
|
67
|
+
const core = options.core;
|
|
68
|
+
if (core) {
|
|
69
|
+
return {
|
|
70
|
+
getAgentRuntime: () => core.getRuntime(),
|
|
71
|
+
getAgentContext: () => core.getContext(),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (options.getAgentRuntime && options.getAgentContext) {
|
|
75
|
+
return {
|
|
76
|
+
getAgentRuntime: options.getAgentRuntime,
|
|
77
|
+
getAgentContext: options.getAgentContext,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
throw new Error(
|
|
81
|
+
"createServerApp/startServer requires either core or both getAgentRuntime/getAgentContext",
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
52
85
|
/**
|
|
53
86
|
* 创建主 Hono 应用。
|
|
54
87
|
*/
|
|
55
|
-
export function createServerApp(
|
|
88
|
+
export function createServerApp(
|
|
89
|
+
options: Pick<ServerStartOptions, "core" | "getAgentRuntime" | "getAgentContext">,
|
|
90
|
+
): Hono {
|
|
56
91
|
const app = new Hono();
|
|
92
|
+
const bindings = resolveServerBindings(options);
|
|
57
93
|
|
|
58
94
|
app.use("*", logger());
|
|
59
95
|
app.use(
|
|
@@ -65,19 +101,28 @@ export function createServerApp(): Hono {
|
|
|
65
101
|
}),
|
|
66
102
|
);
|
|
67
103
|
|
|
68
|
-
// 关键点(中文):service action 路由在 runtime ready 后再注册,避免命令级 import 副作用。
|
|
69
|
-
ensureServiceActionRoutesRegistered();
|
|
70
|
-
|
|
71
104
|
// 关键点(中文):按路由域挂载,server 模块只保留装配职责。
|
|
72
|
-
app.route("/",
|
|
105
|
+
app.route("/", createStaticRouter({
|
|
106
|
+
getAgentRuntime: bindings.getAgentRuntime,
|
|
107
|
+
}));
|
|
73
108
|
app.route("/", healthRouter);
|
|
109
|
+
const servicesRouter = createServicesRouter({
|
|
110
|
+
getAgentContext: bindings.getAgentContext,
|
|
111
|
+
});
|
|
74
112
|
app.route("/", servicesRouter);
|
|
75
|
-
app.route("/",
|
|
76
|
-
|
|
77
|
-
|
|
113
|
+
app.route("/", createPluginsRouter({
|
|
114
|
+
getAgentContext: bindings.getAgentContext,
|
|
115
|
+
}));
|
|
116
|
+
app.route("/", createExecuteRouter({
|
|
117
|
+
getAgentRuntime: bindings.getAgentRuntime,
|
|
118
|
+
}));
|
|
119
|
+
app.route("/", createControlRouter({
|
|
120
|
+
getAgentRuntime: bindings.getAgentRuntime,
|
|
121
|
+
getAgentContext: bindings.getAgentContext,
|
|
122
|
+
}));
|
|
78
123
|
registerBuiltinPluginHttpRoutes({
|
|
79
124
|
app,
|
|
80
|
-
getContext: getAgentContext,
|
|
125
|
+
getContext: bindings.getAgentContext,
|
|
81
126
|
});
|
|
82
127
|
|
|
83
128
|
return app;
|
|
@@ -89,7 +134,7 @@ export function createServerApp(): Hono {
|
|
|
89
134
|
export async function startServer(
|
|
90
135
|
options: ServerStartOptions,
|
|
91
136
|
): Promise<ServerInstance> {
|
|
92
|
-
const app = createServerApp();
|
|
137
|
+
const app = createServerApp(options);
|
|
93
138
|
const server = createNodeServer(app, options);
|
|
94
139
|
|
|
95
140
|
await new Promise<void>((resolve) => {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - 这样调用方不需要知道 plugin action 名称,也不需要依赖 `plugin/builtins/auth/*` 目录。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { AgentContext } from "@/
|
|
10
|
+
import type { AgentContext } from "@/core/AgentContextTypes.js";
|
|
11
11
|
import type { JsonObject } from "@/types/common/Json.js";
|
|
12
12
|
import type { AuthControlPayload } from "@/server/http/control/types/AuthControl.js";
|
|
13
13
|
import type {
|
|
@@ -13,19 +13,35 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { Hono } from "hono";
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
getAgentContext,
|
|
19
|
-
} from "@/runtime/AgentRuntime.js";
|
|
16
|
+
import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
|
|
17
|
+
import type { AgentContext } from "@/core/AgentContextTypes.js";
|
|
20
18
|
import { registerControlApiRoutes } from "@/server/http/control/ControlApiRoutes.js";
|
|
21
19
|
|
|
22
20
|
/**
|
|
23
|
-
*
|
|
21
|
+
* control router 参数。
|
|
24
22
|
*/
|
|
25
|
-
|
|
23
|
+
type ControlRouterOptions = {
|
|
24
|
+
/**
|
|
25
|
+
* 读取当前 agent runtime。
|
|
26
|
+
*/
|
|
27
|
+
getAgentRuntime: () => AgentRuntime;
|
|
28
|
+
/**
|
|
29
|
+
* 读取当前 agent 执行上下文。
|
|
30
|
+
*/
|
|
31
|
+
getAgentContext: () => AgentContext;
|
|
32
|
+
};
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
/**
|
|
35
|
+
* 创建单 agent control API 专用路由。
|
|
36
|
+
*/
|
|
37
|
+
export function createControlRouter(
|
|
38
|
+
options: ControlRouterOptions,
|
|
39
|
+
): Hono {
|
|
40
|
+
const router = new Hono();
|
|
41
|
+
registerControlApiRoutes({
|
|
42
|
+
app: router,
|
|
43
|
+
getAgentRuntime: options.getAgentRuntime,
|
|
44
|
+
getAgentContext: options.getAgentContext,
|
|
45
|
+
});
|
|
46
|
+
return router;
|
|
47
|
+
}
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* - 非 chat session 保留原有直接执行语义。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { AgentRuntime } from "@/
|
|
10
|
-
import type { AgentContext } from "@/
|
|
9
|
+
import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
|
|
10
|
+
import type { AgentContext } from "@/core/AgentContextTypes.js";
|
|
11
11
|
import type { JsonObject } from "@/types/common/Json.js";
|
|
12
12
|
import type { ControlSessionExecuteAttachmentInput } from "@/server/http/control/types/ControlSessionExecute.js";
|
|
13
13
|
import { drainDeferredPersistedUserMessages } from "@session/SessionRunScope.js";
|
|
@@ -54,7 +54,9 @@ export function registerControlOverviewRoutes(
|
|
|
54
54
|
executionContext: params.getAgentContext(),
|
|
55
55
|
limit: sessionLimit,
|
|
56
56
|
});
|
|
57
|
-
const services = listServiceStates(
|
|
57
|
+
const services = listServiceStates({
|
|
58
|
+
context: params.getAgentContext(),
|
|
59
|
+
});
|
|
58
60
|
const taskResult = await listTaskDefinitions({
|
|
59
61
|
projectRoot: runtime.rootPath,
|
|
60
62
|
});
|
|
@@ -99,7 +101,9 @@ export function registerControlOverviewRoutes(
|
|
|
99
101
|
app.get(routePath, (c) => {
|
|
100
102
|
return c.json({
|
|
101
103
|
success: true,
|
|
102
|
-
services: listServiceStates(
|
|
104
|
+
services: listServiceStates({
|
|
105
|
+
context: params.getAgentContext(),
|
|
106
|
+
}),
|
|
103
107
|
});
|
|
104
108
|
});
|
|
105
109
|
}
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { Hono } from "hono";
|
|
10
|
-
import type { AgentRuntime } from "@/
|
|
11
|
-
import type { AgentContext } from "@/
|
|
10
|
+
import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
|
|
11
|
+
import type { AgentContext } from "@/core/AgentContextTypes.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Control 路由注册入参。
|
|
@@ -9,112 +9,128 @@
|
|
|
9
9
|
|
|
10
10
|
import { Hono } from "hono";
|
|
11
11
|
import { drainDeferredPersistedUserMessages } from "@session/SessionRunScope.js";
|
|
12
|
-
import {
|
|
12
|
+
import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
|
|
13
13
|
import {
|
|
14
14
|
pickLastSuccessfulChatSendText,
|
|
15
15
|
resolveAssistantMessageForPersistence,
|
|
16
16
|
} from "@/service/builtins/chat/runtime/UserVisibleText.js";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* 执行入口路由参数。
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
type ExecuteRouterOptions = {
|
|
22
|
+
/**
|
|
23
|
+
* 读取当前 agent runtime。
|
|
24
|
+
*/
|
|
25
|
+
getAgentRuntime: () => AgentRuntime;
|
|
26
|
+
};
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
400,
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!bodyText) {
|
|
35
|
-
return c.json({ success: false, message: "Request body is empty" }, 400);
|
|
36
|
-
}
|
|
28
|
+
/**
|
|
29
|
+
* 创建执行入口路由。
|
|
30
|
+
*/
|
|
31
|
+
export function createExecuteRouter(
|
|
32
|
+
options: ExecuteRouterOptions,
|
|
33
|
+
): Hono {
|
|
34
|
+
const router = new Hono();
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return c.json(
|
|
49
|
-
{
|
|
50
|
-
success: false,
|
|
51
|
-
message: `JSON parse failed: ${bodyText.substring(0, 50)}...`,
|
|
52
|
-
},
|
|
53
|
-
400,
|
|
54
|
-
);
|
|
55
|
-
}
|
|
36
|
+
router.post("/api/execute", async (c) => {
|
|
37
|
+
let bodyText = "";
|
|
38
|
+
try {
|
|
39
|
+
bodyText = await c.req.text();
|
|
40
|
+
} catch {
|
|
41
|
+
return c.json(
|
|
42
|
+
{ success: false, message: "Unable to read request body" },
|
|
43
|
+
400,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
56
46
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
? body.chatId.trim()
|
|
61
|
-
: "default";
|
|
62
|
-
const actorId =
|
|
63
|
-
typeof body?.userId === "string" && body.userId.trim()
|
|
64
|
-
? body.userId.trim()
|
|
65
|
-
: typeof body?.actorId === "string" && body.actorId.trim()
|
|
66
|
-
? body.actorId.trim()
|
|
67
|
-
: "api";
|
|
47
|
+
if (!bodyText) {
|
|
48
|
+
return c.json({ success: false, message: "Request body is empty" }, 400);
|
|
49
|
+
}
|
|
68
50
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
51
|
+
let body: {
|
|
52
|
+
instructions?: string;
|
|
53
|
+
chatId?: string;
|
|
54
|
+
userId?: string;
|
|
55
|
+
actorId?: string;
|
|
56
|
+
messageId?: string;
|
|
57
|
+
};
|
|
58
|
+
try {
|
|
59
|
+
body = JSON.parse(bodyText) as typeof body;
|
|
60
|
+
} catch {
|
|
61
|
+
return c.json(
|
|
62
|
+
{
|
|
63
|
+
success: false,
|
|
64
|
+
message: `JSON parse failed: ${bodyText.substring(0, 50)}...`,
|
|
65
|
+
},
|
|
66
|
+
400,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
75
69
|
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
const instructions = body?.instructions;
|
|
71
|
+
const chatId =
|
|
72
|
+
typeof body?.chatId === "string" && body.chatId.trim()
|
|
73
|
+
? body.chatId.trim()
|
|
74
|
+
: "default";
|
|
75
|
+
const actorId =
|
|
76
|
+
typeof body?.userId === "string" && body.userId.trim()
|
|
77
|
+
? body.userId.trim()
|
|
78
|
+
: typeof body?.actorId === "string" && body.actorId.trim()
|
|
79
|
+
? body.actorId.trim()
|
|
80
|
+
: "api";
|
|
83
81
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
if (!instructions) {
|
|
83
|
+
return c.json(
|
|
84
|
+
{ success: false, message: "Missing instructions field" },
|
|
85
|
+
400,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
87
88
|
|
|
88
|
-
const userVisible = pickLastSuccessfulChatSendText(result.assistantMessage);
|
|
89
89
|
try {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
90
|
+
const sessionId = `api:chat:${chatId}`;
|
|
91
|
+
const agentState = options.getAgentRuntime();
|
|
92
|
+
const session = agentState.getSession(sessionId);
|
|
93
|
+
await session.appendUserMessage({
|
|
94
|
+
text: String(instructions),
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const result = await session.run({
|
|
98
|
+
query: String(instructions),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const userVisible = pickLastSuccessfulChatSendText(result.assistantMessage);
|
|
102
|
+
try {
|
|
103
|
+
const messageForPersistence = resolveAssistantMessageForPersistence(
|
|
104
|
+
result.assistantMessage,
|
|
105
|
+
);
|
|
106
|
+
if (messageForPersistence) {
|
|
107
|
+
await session.appendAssistantMessage({
|
|
108
|
+
message: messageForPersistence,
|
|
109
|
+
fallbackText: userVisible,
|
|
110
|
+
extra: {
|
|
111
|
+
via: "api_execute",
|
|
112
|
+
note: "assistant_message_missing",
|
|
113
|
+
actorId,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const deferredInjectedMessages = drainDeferredPersistedUserMessages(
|
|
118
|
+
sessionId,
|
|
119
|
+
);
|
|
120
|
+
for (const message of deferredInjectedMessages) {
|
|
121
|
+
await session.appendUserMessage({
|
|
122
|
+
message,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
} catch {
|
|
126
|
+
// ignore
|
|
111
127
|
}
|
|
112
|
-
|
|
113
|
-
|
|
128
|
+
|
|
129
|
+
return c.json(result);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
return c.json({ success: false, message: String(error) }, 500);
|
|
114
132
|
}
|
|
133
|
+
});
|
|
115
134
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return c.json({ success: false, message: String(error) }, 500);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
135
|
+
return router;
|
|
136
|
+
}
|
|
@@ -8,60 +8,76 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { Hono } from "hono";
|
|
11
|
-
import {
|
|
11
|
+
import type { AgentContext } from "@/core/AgentContextTypes.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Plugin
|
|
14
|
+
* Plugin 路由参数。
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
type PluginsRouterOptions = {
|
|
17
|
+
/**
|
|
18
|
+
* 读取当前 agent 执行上下文。
|
|
19
|
+
*/
|
|
20
|
+
getAgentContext: () => AgentContext;
|
|
21
|
+
};
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
/**
|
|
24
|
+
* 创建 plugin 路由。
|
|
25
|
+
*/
|
|
26
|
+
export function createPluginsRouter(
|
|
27
|
+
options: PluginsRouterOptions,
|
|
28
|
+
): Hono {
|
|
29
|
+
const router = new Hono();
|
|
30
|
+
|
|
31
|
+
router.get("/api/plugins/list", (c) => {
|
|
32
|
+
return c.json({
|
|
33
|
+
success: true,
|
|
34
|
+
plugins: options.getAgentContext().plugins.list(),
|
|
35
|
+
});
|
|
22
36
|
});
|
|
23
|
-
});
|
|
24
37
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
router.post("/api/plugins/availability", async (c) => {
|
|
39
|
+
const body = await c.req.json().catch(() => null);
|
|
40
|
+
const pluginName = String(body?.pluginName || "").trim();
|
|
28
41
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
if (!pluginName) {
|
|
43
|
+
return c.json({ success: false, error: "pluginName is required" }, 400);
|
|
44
|
+
}
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
const availability =
|
|
47
|
+
await options.getAgentContext().plugins.availability(pluginName);
|
|
48
|
+
return c.json({
|
|
49
|
+
success: true,
|
|
50
|
+
pluginName,
|
|
51
|
+
availability,
|
|
52
|
+
});
|
|
39
53
|
});
|
|
40
|
-
});
|
|
41
54
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
router.post("/api/plugins/action", async (c) => {
|
|
56
|
+
const body = await c.req.json().catch(() => null);
|
|
57
|
+
const pluginName = String(body?.pluginName || "").trim();
|
|
58
|
+
const actionName = String(body?.actionName || "").trim();
|
|
46
59
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
if (!pluginName) {
|
|
61
|
+
return c.json({ success: false, error: "pluginName is required" }, 400);
|
|
62
|
+
}
|
|
63
|
+
if (!actionName) {
|
|
64
|
+
return c.json({ success: false, error: "actionName is required" }, 400);
|
|
65
|
+
}
|
|
53
66
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
const result = await options.getAgentContext().plugins.runAction({
|
|
68
|
+
plugin: pluginName,
|
|
69
|
+
action: actionName,
|
|
70
|
+
payload: body?.payload,
|
|
71
|
+
});
|
|
72
|
+
return c.json(
|
|
73
|
+
{
|
|
74
|
+
...result,
|
|
75
|
+
pluginName,
|
|
76
|
+
actionName,
|
|
77
|
+
},
|
|
78
|
+
result.success ? 200 : 400,
|
|
79
|
+
);
|
|
58
80
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
pluginName,
|
|
63
|
-
actionName,
|
|
64
|
-
},
|
|
65
|
-
result.success ? 200 : 400,
|
|
66
|
-
);
|
|
67
|
-
});
|
|
81
|
+
|
|
82
|
+
return router;
|
|
83
|
+
}
|