@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxConfigResolver.d.ts","sourceRoot":"","sources":["../../src/sandbox/SandboxConfigResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SandboxConfigResolver.d.ts","sourceRoot":"","sources":["../../src/sandbox/SandboxConfigResolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AA0B/E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAM9E;AAwCD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,qBAAqB,CAqBjF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,YAAY,CAAC;CACvB,GAAG,MAAM,CAUT"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - 当前版本只接入 macOS seatbelt backend。
|
|
7
7
|
* - shell 命令不再允许回退到宿主机普通子进程执行。
|
|
8
8
|
*/
|
|
9
|
-
import type { AgentContext } from "../
|
|
9
|
+
import type { AgentContext } from "../core/AgentContextTypes.js";
|
|
10
10
|
import type { SandboxSpawnResult } from "../sandbox/types/SandboxRuntime.js";
|
|
11
11
|
/**
|
|
12
12
|
* 启动 shell 子进程。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxRunner.d.ts","sourceRoot":"","sources":["../../src/sandbox/SandboxRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SandboxRunner.d.ts","sourceRoot":"","sources":["../../src/sandbox/SandboxRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAI5E;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE;IAC9C,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC;CAC5B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkB9B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE;IAC9C,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,UAAU,CAAC;CAC5B,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,kBAAkB,CAAC;CAC3B,CAAC,CAiCD"}
|
package/bin/sdk/Agent.d.ts
CHANGED
|
@@ -2,21 +2,25 @@
|
|
|
2
2
|
* Agent SDK 本地入口。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* - `
|
|
5
|
+
* - `Agent` 现在是实例外观层,长期运行状态下沉到 `AgentCore`。
|
|
6
6
|
* - session、HTTP、RPC、service lifecycle 都按需异步初始化。
|
|
7
|
-
* -
|
|
7
|
+
* - `start/stop` 负责统一收口当前 agent 实例的生命周期。
|
|
8
8
|
*/
|
|
9
9
|
import type { Tool } from "ai";
|
|
10
10
|
import type { BaseService } from "../service/builtins/BaseService.js";
|
|
11
|
+
import type { AgentContext } from "../core/AgentContextTypes.js";
|
|
12
|
+
import type { AgentRuntime } from "../core/AgentCoreTypes.js";
|
|
11
13
|
import type { PluginPort } from "../plugin/types/Plugin.js";
|
|
12
|
-
import type { AgentOptions, AgentSessionMetadata } from "../sdk/AgentSdkTypes.js";
|
|
14
|
+
import type { AgentOptions, AgentStartOptions, AgentStartResult, AgentStopResult, AgentSessionMetadata } from "../sdk/AgentSdkTypes.js";
|
|
13
15
|
import { Session } from "../sdk/Session.js";
|
|
14
16
|
import { SdkAgentHttpServer } from "../sdk/HttpServer.js";
|
|
15
17
|
import { SdkAgentRpcServer } from "../sdk/RpcServer.js";
|
|
18
|
+
import { AgentCore } from "../core/AgentCore.js";
|
|
16
19
|
/**
|
|
17
20
|
* SDK 本地 Agent。
|
|
18
21
|
*/
|
|
19
22
|
export declare class Agent {
|
|
23
|
+
readonly core: AgentCore;
|
|
20
24
|
readonly id: string;
|
|
21
25
|
readonly path: string;
|
|
22
26
|
readonly tools: Record<string, Tool>;
|
|
@@ -24,16 +28,8 @@ export declare class Agent {
|
|
|
24
28
|
readonly rpc: SdkAgentRpcServer;
|
|
25
29
|
readonly services: Map<string, BaseService>;
|
|
26
30
|
readonly plugins: PluginPort;
|
|
27
|
-
private
|
|
28
|
-
private
|
|
29
|
-
private readonly runtime;
|
|
30
|
-
private readonly serviceContext;
|
|
31
|
-
private readonly pluginRegistry;
|
|
32
|
-
private readonly pluginSystemProviders;
|
|
33
|
-
private readonly config;
|
|
34
|
-
private readonly platform;
|
|
35
|
-
private instruction;
|
|
36
|
-
private servicesStartPromise;
|
|
31
|
+
private servicesStarted;
|
|
32
|
+
private startPromise;
|
|
37
33
|
constructor(options: AgentOptions);
|
|
38
34
|
/**
|
|
39
35
|
* 获取或创建一个 session。
|
|
@@ -47,6 +43,14 @@ export declare class Agent {
|
|
|
47
43
|
* 确保显式注入的 services 已启动。
|
|
48
44
|
*/
|
|
49
45
|
ensureServicesStarted(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* 启动当前 agent 实例的长期运行能力。
|
|
48
|
+
*/
|
|
49
|
+
start(options?: AgentStartOptions): Promise<AgentStartResult>;
|
|
50
|
+
/**
|
|
51
|
+
* 停止当前 agent 实例的长期运行能力。
|
|
52
|
+
*/
|
|
53
|
+
stop(): Promise<AgentStopResult>;
|
|
50
54
|
/**
|
|
51
55
|
* 更新当前 SDK Agent 的静态基础指令。
|
|
52
56
|
*
|
|
@@ -55,15 +59,13 @@ export declare class Agent {
|
|
|
55
59
|
* - 已创建的 session 后续 run 会读取最新 instruction blocks。
|
|
56
60
|
*/
|
|
57
61
|
setInstruction(input: string | string[]): void;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
private createServiceContext;
|
|
67
|
-
private getOrCreateSession;
|
|
62
|
+
/**
|
|
63
|
+
* 返回实例级 runtime 视图。
|
|
64
|
+
*/
|
|
65
|
+
getRuntime(): AgentRuntime;
|
|
66
|
+
/**
|
|
67
|
+
* 返回实例级执行上下文。
|
|
68
|
+
*/
|
|
69
|
+
getContext(): AgentContext;
|
|
68
70
|
}
|
|
69
71
|
//# sourceMappingURL=Agent.d.ts.map
|
package/bin/sdk/Agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../src/sdk/Agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../src/sdk/Agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACV,UAAU,EACX,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD;;GAEG;AACH,qBAAa,KAAK;IAChB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,YAAY,CAA0C;gBAElD,OAAO,EAAE,YAAY;IAWjC;;OAEG;IACG,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAIjD;;OAEG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAa5C;;OAEG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkCnE;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC;IA2BtC;;;;;;OAMG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAI9C;;OAEG;IACH,UAAU,IAAI,YAAY;IAI1B;;OAEG;IACH,UAAU,IAAI,YAAY;CAG3B"}
|
package/bin/sdk/Agent.js
CHANGED
|
@@ -2,83 +2,19 @@
|
|
|
2
2
|
* Agent SDK 本地入口。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* - `
|
|
5
|
+
* - `Agent` 现在是实例外观层,长期运行状态下沉到 `AgentCore`。
|
|
6
6
|
* - session、HTTP、RPC、service lifecycle 都按需异步初始化。
|
|
7
|
-
* -
|
|
7
|
+
* - `start/stop` 负责统一收口当前 agent 实例的生命周期。
|
|
8
8
|
*/
|
|
9
|
-
import fs from "fs-extra";
|
|
10
|
-
import { nanoid } from "nanoid";
|
|
11
|
-
import { Logger } from "../utils/logger/Logger.js";
|
|
12
|
-
import { Session } from "../sdk/Session.js";
|
|
13
|
-
import { DEFAULT_SHIP_PROMPTS } from "../session/composer/system/default/SystemDomain.js";
|
|
14
|
-
import { getSdkAgentSessionsRootDirPath } from "../sdk/Paths.js";
|
|
15
9
|
import { SdkAgentHttpServer } from "../sdk/HttpServer.js";
|
|
16
10
|
import { SdkAgentRpcServer } from "../sdk/RpcServer.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { appendExecSessionMessage } from "../service/builtins/chat/runtime/ChatIngressStore.js";
|
|
20
|
-
import { readChatMetaBySessionId } from "../service/builtins/chat/runtime/ChatMetaStore.js";
|
|
21
|
-
import { resolveChatQueueStore } from "../service/builtins/chat/runtime/ChatQueueStore.js";
|
|
22
|
-
import { HookRegistry } from "../plugin/core/HookRegistry.js";
|
|
23
|
-
import { PluginRegistry } from "../plugin/core/PluginRegistry.js";
|
|
24
|
-
import { isPluginEnabled } from "../plugin/core/Activation.js";
|
|
25
|
-
const EMPTY_SDK_PLATFORM = {
|
|
26
|
-
getGlobalEnv: () => ({}),
|
|
27
|
-
getAgentEnv: () => ({}),
|
|
28
|
-
listModels: () => [],
|
|
29
|
-
listProviders: async () => [],
|
|
30
|
-
getModel: () => null,
|
|
31
|
-
getChannelAccount: () => null,
|
|
32
|
-
readChatAuthorizationConfig: () => ({
|
|
33
|
-
roles: {},
|
|
34
|
-
channels: {},
|
|
35
|
-
}),
|
|
36
|
-
writeChatAuthorizationConfig: async (_projectRoot, nextConfig) => nextConfig,
|
|
37
|
-
setChatAuthorizationUserRole: async () => ({
|
|
38
|
-
roles: {},
|
|
39
|
-
channels: {},
|
|
40
|
-
}),
|
|
41
|
-
isPluginEnabled: (pluginName) => pluginName === "auth",
|
|
42
|
-
};
|
|
43
|
-
function createFallbackSdkConfig(agentId) {
|
|
44
|
-
return {
|
|
45
|
-
name: agentId,
|
|
46
|
-
version: "0.0.0",
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function normalizeInstructionInput(input) {
|
|
50
|
-
const items = Array.isArray(input) ? input : typeof input === "string" ? [input] : [];
|
|
51
|
-
return items
|
|
52
|
-
.map((item) => String(item || "").trim())
|
|
53
|
-
.filter((item) => item.length > 0);
|
|
54
|
-
}
|
|
55
|
-
function createCoreInstructionContent(projectRoot) {
|
|
56
|
-
const currentYear = String(new Date().getFullYear());
|
|
57
|
-
return DEFAULT_SHIP_PROMPTS
|
|
58
|
-
.replaceAll("{{project_path}}", projectRoot)
|
|
59
|
-
.replaceAll("{{project_root}}", projectRoot)
|
|
60
|
-
.replaceAll("{{current_year}}", currentYear);
|
|
61
|
-
}
|
|
62
|
-
function createInstructionSystemBlocks(instruction, projectRoot) {
|
|
63
|
-
if (instruction.length === 0) {
|
|
64
|
-
return [
|
|
65
|
-
{
|
|
66
|
-
source: "core",
|
|
67
|
-
name: "default",
|
|
68
|
-
content: createCoreInstructionContent(projectRoot),
|
|
69
|
-
},
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
return instruction.map((content, index) => ({
|
|
73
|
-
source: "instruction",
|
|
74
|
-
name: instruction.length === 1 ? "agent" : `agent:${index + 1}`,
|
|
75
|
-
content,
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
11
|
+
import { AgentCore } from "../core/AgentCore.js";
|
|
12
|
+
import { startAllServices, stopAllServices } from "../service/core/Manager.js";
|
|
78
13
|
/**
|
|
79
14
|
* SDK 本地 Agent。
|
|
80
15
|
*/
|
|
81
16
|
export class Agent {
|
|
17
|
+
core;
|
|
82
18
|
id;
|
|
83
19
|
path;
|
|
84
20
|
tools;
|
|
@@ -86,44 +22,15 @@ export class Agent {
|
|
|
86
22
|
rpc;
|
|
87
23
|
services;
|
|
88
24
|
plugins;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
runtime;
|
|
92
|
-
serviceContext;
|
|
93
|
-
pluginRegistry;
|
|
94
|
-
pluginSystemProviders;
|
|
95
|
-
config;
|
|
96
|
-
platform;
|
|
97
|
-
instruction;
|
|
98
|
-
servicesStartPromise = null;
|
|
25
|
+
servicesStarted = false;
|
|
26
|
+
startPromise = null;
|
|
99
27
|
constructor(options) {
|
|
100
|
-
this.
|
|
101
|
-
this.
|
|
102
|
-
this.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
throw new Error("Agent requires a non-empty id");
|
|
107
|
-
}
|
|
108
|
-
if (!this.path) {
|
|
109
|
-
throw new Error("Agent requires a non-empty path");
|
|
110
|
-
}
|
|
111
|
-
this.logger = new Logger();
|
|
112
|
-
this.logger.bindProjectRoot(this.path);
|
|
113
|
-
this.platform = options.platform || EMPTY_SDK_PLATFORM;
|
|
114
|
-
this.instruction = normalizeInstructionInput(options.instruction);
|
|
115
|
-
this.config = this.loadConfig();
|
|
116
|
-
this.services = this.createServiceMap(options.services || []);
|
|
117
|
-
this.runtime = this.createRuntime();
|
|
118
|
-
for (const service of this.services.values()) {
|
|
119
|
-
service.bindAgent(this.runtime);
|
|
120
|
-
}
|
|
121
|
-
this.pluginSystemProviders = Array.isArray(options.plugins)
|
|
122
|
-
? [...options.plugins]
|
|
123
|
-
: [];
|
|
124
|
-
this.pluginRegistry = this.createPluginRegistry(this.pluginSystemProviders);
|
|
125
|
-
this.plugins = this.createPluginPort();
|
|
126
|
-
this.serviceContext = this.createServiceContext();
|
|
28
|
+
this.core = new AgentCore(options);
|
|
29
|
+
this.id = this.core.id;
|
|
30
|
+
this.path = this.core.path;
|
|
31
|
+
this.tools = this.core.tools;
|
|
32
|
+
this.services = this.core.services;
|
|
33
|
+
this.plugins = this.core.plugins;
|
|
127
34
|
this.http = new SdkAgentHttpServer(this);
|
|
128
35
|
this.rpc = new SdkAgentRpcServer(this);
|
|
129
36
|
}
|
|
@@ -131,291 +38,105 @@ export class Agent {
|
|
|
131
38
|
* 获取或创建一个 session。
|
|
132
39
|
*/
|
|
133
40
|
async session(sessionId) {
|
|
134
|
-
|
|
135
|
-
await session.initialize();
|
|
136
|
-
return session;
|
|
41
|
+
return await this.core.session(sessionId);
|
|
137
42
|
}
|
|
138
43
|
/**
|
|
139
44
|
* 列出当前 agent 的全部 session 元数据。
|
|
140
45
|
*/
|
|
141
46
|
async sessions() {
|
|
142
|
-
|
|
143
|
-
if (!(await fs.pathExists(rootDir)))
|
|
144
|
-
return [];
|
|
145
|
-
const entries = await fs.readdir(rootDir, { withFileTypes: true });
|
|
146
|
-
const items = [];
|
|
147
|
-
for (const entry of entries) {
|
|
148
|
-
if (!entry.isDirectory())
|
|
149
|
-
continue;
|
|
150
|
-
let sessionId = "";
|
|
151
|
-
try {
|
|
152
|
-
sessionId = decodeURIComponent(entry.name);
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
sessionId = entry.name;
|
|
156
|
-
}
|
|
157
|
-
if (!sessionId)
|
|
158
|
-
continue;
|
|
159
|
-
const session = await this.session(sessionId);
|
|
160
|
-
items.push(await session.toMetadata());
|
|
161
|
-
}
|
|
162
|
-
items.sort((a, b) => (b.updatedAt || 0) - (a.updatedAt || 0));
|
|
163
|
-
return items;
|
|
47
|
+
return await this.core.sessions();
|
|
164
48
|
}
|
|
165
49
|
/**
|
|
166
50
|
* 确保显式注入的 services 已启动。
|
|
167
51
|
*/
|
|
168
52
|
async ensureServicesStarted() {
|
|
169
|
-
if (this.
|
|
170
|
-
await this.servicesStartPromise;
|
|
53
|
+
if (this.servicesStarted)
|
|
171
54
|
return;
|
|
172
|
-
|
|
173
|
-
this.
|
|
174
|
-
|
|
175
|
-
|
|
55
|
+
const lifecycle = await startAllServices(this.getContext());
|
|
56
|
+
this.servicesStarted = true;
|
|
57
|
+
for (const item of lifecycle.results) {
|
|
58
|
+
if (!item.success) {
|
|
59
|
+
this.getRuntime().logger.error(`Service start failed: ${item.service?.name || "unknown"} - ${item.error || "unknown error"}`);
|
|
176
60
|
}
|
|
177
|
-
}
|
|
178
|
-
await this.servicesStartPromise;
|
|
61
|
+
}
|
|
179
62
|
}
|
|
180
63
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* 关键点(中文)
|
|
184
|
-
* - instruction 不做动态变量替换。
|
|
185
|
-
* - 已创建的 session 后续 run 会读取最新 instruction blocks。
|
|
64
|
+
* 启动当前 agent 实例的长期运行能力。
|
|
186
65
|
*/
|
|
187
|
-
|
|
188
|
-
this.
|
|
189
|
-
|
|
190
|
-
|
|
66
|
+
async start(options) {
|
|
67
|
+
if (this.startPromise) {
|
|
68
|
+
return await this.startPromise;
|
|
69
|
+
}
|
|
70
|
+
this.startPromise = (async () => {
|
|
71
|
+
const shouldStartServices = options?.services !== false;
|
|
72
|
+
if (shouldStartServices) {
|
|
73
|
+
await this.ensureServicesStarted();
|
|
74
|
+
}
|
|
75
|
+
const httpBinding = options?.http === false || options?.http === undefined
|
|
76
|
+
? undefined
|
|
77
|
+
: await this.http.start(options.http);
|
|
78
|
+
const rpcBinding = options?.rpc === true
|
|
79
|
+
? await this.rpc.start()
|
|
80
|
+
: undefined;
|
|
81
|
+
return {
|
|
82
|
+
...(httpBinding ? { http: httpBinding } : {}),
|
|
83
|
+
...(rpcBinding ? { rpc: rpcBinding } : {}),
|
|
84
|
+
servicesStarted: this.servicesStarted,
|
|
85
|
+
};
|
|
86
|
+
})();
|
|
191
87
|
try {
|
|
192
|
-
return
|
|
193
|
-
projectEnv: {},
|
|
194
|
-
agentEnv: {},
|
|
195
|
-
globalEnv: {},
|
|
196
|
-
});
|
|
88
|
+
return await this.startPromise;
|
|
197
89
|
}
|
|
198
|
-
catch {
|
|
199
|
-
|
|
90
|
+
catch (error) {
|
|
91
|
+
this.startPromise = null;
|
|
92
|
+
throw error;
|
|
200
93
|
}
|
|
201
94
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
services.set(name, service);
|
|
95
|
+
/**
|
|
96
|
+
* 停止当前 agent 实例的长期运行能力。
|
|
97
|
+
*/
|
|
98
|
+
async stop() {
|
|
99
|
+
const servicesStarted = this.servicesStarted;
|
|
100
|
+
const rpcStarted = this.rpc.isStarted();
|
|
101
|
+
const httpStarted = this.http.isStarted();
|
|
102
|
+
if (servicesStarted) {
|
|
103
|
+
await stopAllServices(this.getContext());
|
|
104
|
+
this.servicesStarted = false;
|
|
213
105
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
createPluginRegistry(input) {
|
|
217
|
-
let pluginRegistryRef = null;
|
|
218
|
-
const hookRegistry = new HookRegistry({
|
|
219
|
-
contextResolver: () => this.serviceContext,
|
|
220
|
-
pluginEnabledChecker: (pluginName) => {
|
|
221
|
-
const plugin = pluginRegistryRef?.get(pluginName);
|
|
222
|
-
return plugin ? isPluginEnabled({ plugin, context: this.serviceContext }) : false;
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
const registry = new PluginRegistry({
|
|
226
|
-
contextResolver: () => this.serviceContext,
|
|
227
|
-
hookRegistry,
|
|
228
|
-
});
|
|
229
|
-
pluginRegistryRef = registry;
|
|
230
|
-
for (const plugin of input) {
|
|
231
|
-
registry.register(plugin);
|
|
106
|
+
if (rpcStarted) {
|
|
107
|
+
await this.rpc.stop();
|
|
232
108
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
109
|
+
if (httpStarted) {
|
|
110
|
+
await this.http.stop();
|
|
111
|
+
}
|
|
112
|
+
this.startPromise = null;
|
|
236
113
|
return {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
pipeline: async (pointName, value) => await this.pluginRegistry.pipeline(pointName, value),
|
|
241
|
-
guard: async (pointName, value) => {
|
|
242
|
-
await this.pluginRegistry.guard(pointName, value);
|
|
243
|
-
},
|
|
244
|
-
effect: async (pointName, value) => {
|
|
245
|
-
await this.pluginRegistry.effect(pointName, value);
|
|
246
|
-
},
|
|
247
|
-
resolve: async (pointName, value) => await this.pluginRegistry.resolve(pointName, value),
|
|
114
|
+
httpStopped: httpStarted,
|
|
115
|
+
rpcStopped: rpcStarted,
|
|
116
|
+
servicesStopped: servicesStarted,
|
|
248
117
|
};
|
|
249
118
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (!isPluginEnabled({ plugin, context: this.serviceContext }))
|
|
260
|
-
continue;
|
|
261
|
-
if (typeof plugin.availability === "function") {
|
|
262
|
-
const availability = await plugin.availability(this.serviceContext);
|
|
263
|
-
if (!availability.available)
|
|
264
|
-
continue;
|
|
265
|
-
}
|
|
266
|
-
const text = String(await plugin.system(this.serviceContext)).trim();
|
|
267
|
-
if (!text)
|
|
268
|
-
continue;
|
|
269
|
-
out.push({
|
|
270
|
-
source: "plugin",
|
|
271
|
-
name: plugin.name,
|
|
272
|
-
content: text,
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
catch {
|
|
276
|
-
// 单个 plugin system 失败不应阻断 SDK session 主链路。
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return out;
|
|
280
|
-
}
|
|
281
|
-
async loadServiceSystemBlocks() {
|
|
282
|
-
const out = [];
|
|
283
|
-
for (const service of this.services.values()) {
|
|
284
|
-
if (typeof service.system !== "function")
|
|
285
|
-
continue;
|
|
286
|
-
try {
|
|
287
|
-
const text = String(await service.system(this.serviceContext)).trim();
|
|
288
|
-
if (!text)
|
|
289
|
-
continue;
|
|
290
|
-
out.push({
|
|
291
|
-
source: "service",
|
|
292
|
-
name: service.name,
|
|
293
|
-
content: text,
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
catch {
|
|
297
|
-
// 单个 service system 失败不应阻断 SDK session 主链路。
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return out;
|
|
301
|
-
}
|
|
302
|
-
createRuntime() {
|
|
303
|
-
const runtime = {
|
|
304
|
-
cwd: this.path,
|
|
305
|
-
rootPath: this.path,
|
|
306
|
-
logger: this.logger,
|
|
307
|
-
config: this.config,
|
|
308
|
-
env: {},
|
|
309
|
-
globalEnv: {},
|
|
310
|
-
systems: this.instruction,
|
|
311
|
-
paths: createAgentPathRuntime(this.path),
|
|
312
|
-
pluginConfig: createAgentPluginConfigRuntime(this.path),
|
|
313
|
-
platform: this.platform,
|
|
314
|
-
model: undefined,
|
|
315
|
-
getSession: (sessionId) => {
|
|
316
|
-
return this.getOrCreateSession(sessionId).getServicePort();
|
|
317
|
-
},
|
|
318
|
-
listExecutingSessionIds: () => [...this.sessionsById.values()]
|
|
319
|
-
.filter((session) => session.isExecuting())
|
|
320
|
-
.map((session) => session.id),
|
|
321
|
-
getExecutingSessionCount: () => [...this.sessionsById.values()].filter((session) => session.isExecuting()).length,
|
|
322
|
-
services: this.services,
|
|
323
|
-
};
|
|
324
|
-
return runtime;
|
|
119
|
+
/**
|
|
120
|
+
* 更新当前 SDK Agent 的静态基础指令。
|
|
121
|
+
*
|
|
122
|
+
* 关键点(中文)
|
|
123
|
+
* - instruction 不做动态变量替换。
|
|
124
|
+
* - 已创建的 session 后续 run 会读取最新 instruction blocks。
|
|
125
|
+
*/
|
|
126
|
+
setInstruction(input) {
|
|
127
|
+
this.core.setInstruction(input);
|
|
325
128
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
rootPath: this.path,
|
|
332
|
-
logger: this.logger,
|
|
333
|
-
config: this.config,
|
|
334
|
-
env: {},
|
|
335
|
-
globalEnv: {},
|
|
336
|
-
systems: this.instruction,
|
|
337
|
-
paths: this.runtime.paths,
|
|
338
|
-
pluginConfig: this.runtime.pluginConfig,
|
|
339
|
-
platform: this.platform,
|
|
340
|
-
session: {
|
|
341
|
-
get: (sessionId) => this.getOrCreateSession(sessionId).getServicePort(),
|
|
342
|
-
listExecutingSessionIds: () => this.runtime.listExecutingSessionIds(),
|
|
343
|
-
getExecutingSessionCount: () => this.runtime.getExecutingSessionCount(),
|
|
344
|
-
},
|
|
345
|
-
invoke: {
|
|
346
|
-
invoke: async (params) => {
|
|
347
|
-
const serviceName = String(params.service || "").trim();
|
|
348
|
-
const actionName = String(params.action || "").trim();
|
|
349
|
-
const service = this.services.get(serviceName);
|
|
350
|
-
if (!service) {
|
|
351
|
-
return {
|
|
352
|
-
success: false,
|
|
353
|
-
error: `Unknown service: ${serviceName}`,
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
const action = service.actions[actionName];
|
|
357
|
-
if (!action) {
|
|
358
|
-
return {
|
|
359
|
-
success: false,
|
|
360
|
-
error: `Unknown action: ${serviceName}.${actionName}`,
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
const result = await action.execute({
|
|
364
|
-
context,
|
|
365
|
-
payload: params.payload ?? null,
|
|
366
|
-
serviceName,
|
|
367
|
-
actionName,
|
|
368
|
-
});
|
|
369
|
-
if (!result.success) {
|
|
370
|
-
return {
|
|
371
|
-
success: false,
|
|
372
|
-
...(result.error ? { error: result.error } : {}),
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
return {
|
|
376
|
-
success: true,
|
|
377
|
-
...(result.data !== undefined ? { data: result.data } : {}),
|
|
378
|
-
};
|
|
379
|
-
},
|
|
380
|
-
},
|
|
381
|
-
chat: {
|
|
382
|
-
readMetaBySessionId: async (sessionId) => {
|
|
383
|
-
return await readChatMetaBySessionId({
|
|
384
|
-
context,
|
|
385
|
-
sessionId,
|
|
386
|
-
});
|
|
387
|
-
},
|
|
388
|
-
appendExecSessionMessage: async (params) => {
|
|
389
|
-
await appendExecSessionMessage({
|
|
390
|
-
context,
|
|
391
|
-
sessionId: params.sessionId,
|
|
392
|
-
text: params.text,
|
|
393
|
-
extra: params.extra,
|
|
394
|
-
});
|
|
395
|
-
},
|
|
396
|
-
enqueue: (params) => resolveChatQueueStore(context).enqueue(params),
|
|
397
|
-
},
|
|
398
|
-
plugins: this.plugins,
|
|
399
|
-
};
|
|
400
|
-
return context;
|
|
129
|
+
/**
|
|
130
|
+
* 返回实例级 runtime 视图。
|
|
131
|
+
*/
|
|
132
|
+
getRuntime() {
|
|
133
|
+
return this.core.getRuntime();
|
|
401
134
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
const created = new Session({
|
|
408
|
-
agentId: this.id,
|
|
409
|
-
projectRoot: this.path,
|
|
410
|
-
sessionId: resolvedSessionId,
|
|
411
|
-
tools: this.tools,
|
|
412
|
-
logger: this.logger,
|
|
413
|
-
getInstructionSystemBlocks: () => this.loadInstructionSystemBlocks(),
|
|
414
|
-
getServiceSystemBlocks: () => this.loadServiceSystemBlocks(),
|
|
415
|
-
getPluginSystemBlocks: () => this.loadPluginSystemBlocks(),
|
|
416
|
-
});
|
|
417
|
-
this.sessionsById.set(resolvedSessionId, created);
|
|
418
|
-
return created;
|
|
135
|
+
/**
|
|
136
|
+
* 返回实例级执行上下文。
|
|
137
|
+
*/
|
|
138
|
+
getContext() {
|
|
139
|
+
return this.core.getContext();
|
|
419
140
|
}
|
|
420
141
|
}
|
|
421
142
|
//# sourceMappingURL=Agent.js.map
|