@downcity/agent 1.1.15 → 1.1.17
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/README.md +126 -635
- package/bin/{project → config/project}/AgentInitializer.d.ts +2 -2
- package/bin/config/project/AgentInitializer.d.ts.map +1 -0
- package/bin/{project → config/project}/AgentInitializer.js +7 -7
- package/bin/config/project/AgentInitializer.js.map +1 -0
- package/bin/{project → config/project}/types/AgentProject.d.ts +2 -2
- package/bin/config/project/types/AgentProject.d.ts.map +1 -0
- package/bin/config/project/types/AgentProject.js.map +1 -0
- package/bin/core/AgentContextTypes.d.ts +9 -71
- package/bin/core/AgentContextTypes.d.ts.map +1 -1
- package/bin/core/AgentCore.d.ts.map +1 -1
- package/bin/core/AgentCore.js +5 -2
- package/bin/core/AgentCore.js.map +1 -1
- package/bin/core/AgentCoreTypes.d.ts +1 -6
- package/bin/core/AgentCoreTypes.d.ts.map +1 -1
- package/bin/index.d.ts +22 -22
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +9 -10
- package/bin/index.js.map +1 -1
- package/bin/plugin/builtins/asr/Config.d.ts +1 -1
- package/bin/plugin/builtins/asr/Config.d.ts.map +1 -1
- package/bin/plugin/builtins/auth/runtime/AuthorizationPolicy.d.ts +1 -1
- package/bin/plugin/builtins/auth/runtime/AuthorizationPolicy.d.ts.map +1 -1
- package/bin/plugin/builtins/voice/Config.d.ts +1 -1
- package/bin/plugin/builtins/voice/Config.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/core/HttpRoutes.d.ts +1 -1
- package/bin/plugin/core/HttpRoutes.d.ts.map +1 -1
- package/bin/plugin/core/LocalExecution.js +1 -1
- package/bin/plugin/core/PluginManager.js +1 -1
- package/bin/plugin/types/Plugin.d.ts +2 -2
- package/bin/plugin/types/Plugin.d.ts.map +1 -1
- package/bin/{host/runtime → runtime/host}/AgentHostRuntime.d.ts +1 -1
- package/bin/{host/runtime → runtime/host}/AgentHostRuntime.d.ts.map +1 -1
- package/bin/{host/runtime → runtime/host}/AgentHostRuntime.js.map +1 -1
- package/bin/{host/runtime → runtime/host}/PluginRuntime.d.ts.map +1 -1
- package/bin/{host/runtime → runtime/host}/PluginRuntime.js.map +1 -1
- package/bin/{host → runtime/host}/daemon/Api.d.ts +1 -1
- package/bin/runtime/host/daemon/Api.d.ts.map +1 -0
- package/bin/runtime/host/daemon/Api.js.map +1 -0
- package/bin/runtime/host/daemon/Client.d.ts.map +1 -0
- package/bin/{host → runtime/host}/daemon/Client.js +2 -2
- package/bin/runtime/host/daemon/Client.js.map +1 -0
- package/bin/runtime/host/daemon/Paths.d.ts.map +1 -0
- package/bin/{host → runtime/host}/daemon/Paths.js +2 -2
- package/bin/runtime/host/daemon/Paths.js.map +1 -0
- package/bin/{host → runtime/host}/daemon/ProjectSetup.d.ts +1 -1
- package/bin/runtime/host/daemon/ProjectSetup.d.ts.map +1 -0
- package/bin/{host → runtime/host}/daemon/ProjectSetup.js +3 -3
- package/bin/runtime/host/daemon/ProjectSetup.js.map +1 -0
- package/bin/{sandbox → runtime/sandbox}/MacOsSeatbeltSandbox.d.ts +1 -1
- package/bin/runtime/sandbox/MacOsSeatbeltSandbox.d.ts.map +1 -0
- package/bin/runtime/sandbox/MacOsSeatbeltSandbox.js.map +1 -0
- package/bin/{sandbox → runtime/sandbox}/SandboxConfigResolver.d.ts +2 -2
- package/bin/runtime/sandbox/SandboxConfigResolver.d.ts.map +1 -0
- package/bin/runtime/sandbox/SandboxConfigResolver.js.map +1 -0
- package/bin/{sandbox → runtime/sandbox}/SandboxRunner.d.ts +2 -2
- package/bin/runtime/sandbox/SandboxRunner.d.ts.map +1 -0
- package/bin/{sandbox → runtime/sandbox}/SandboxRunner.js +2 -2
- package/bin/runtime/sandbox/SandboxRunner.js.map +1 -0
- package/bin/runtime/sandbox/types/Sandbox.d.ts.map +1 -0
- package/bin/runtime/sandbox/types/Sandbox.js.map +1 -0
- package/bin/{sandbox → runtime/sandbox}/types/SandboxRuntime.d.ts +2 -2
- package/bin/runtime/sandbox/types/SandboxRuntime.d.ts.map +1 -0
- package/bin/runtime/sandbox/types/SandboxRuntime.js.map +1 -0
- package/bin/{server → runtime/server}/http/Server.d.ts +3 -3
- package/bin/runtime/server/http/Server.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/Server.js +8 -8
- package/bin/runtime/server/http/Server.js.map +1 -0
- package/bin/runtime/server/http/auth/AuthEnv.d.ts.map +1 -0
- package/bin/runtime/server/http/auth/AuthEnv.js.map +1 -0
- package/bin/runtime/server/http/auth/AuthError.d.ts.map +1 -0
- package/bin/runtime/server/http/auth/AuthError.js.map +1 -0
- package/bin/runtime/server/http/auth/CliAuthStateStore.d.ts.map +1 -0
- package/bin/runtime/server/http/auth/CliAuthStateStore.js.map +1 -0
- package/bin/runtime/server/http/auth/PasswordHasher.d.ts.map +1 -0
- package/bin/runtime/server/http/auth/PasswordHasher.js.map +1 -0
- package/bin/runtime/server/http/auth/TokenService.d.ts.map +1 -0
- package/bin/runtime/server/http/auth/TokenService.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/AuthControlService.d.ts +3 -3
- package/bin/runtime/server/http/control/AuthControlService.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/AuthControlService.js +1 -1
- package/bin/runtime/server/http/control/AuthControlService.js.map +1 -0
- package/bin/runtime/server/http/control/CommonHelpers.d.ts.map +1 -0
- package/bin/runtime/server/http/control/CommonHelpers.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlApiRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/ControlApiRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlApiRoutes.js +5 -5
- package/bin/runtime/server/http/control/ControlApiRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlAuthorizationRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/ControlAuthorizationRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlAuthorizationRoutes.js +3 -3
- package/bin/runtime/server/http/control/ControlAuthorizationRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlRouter.d.ts +2 -2
- package/bin/runtime/server/http/control/ControlRouter.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlRouter.js +1 -1
- package/bin/runtime/server/http/control/ControlRouter.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ExecuteBySession.d.ts +4 -4
- package/bin/runtime/server/http/control/ExecuteBySession.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ExecuteBySession.js +6 -6
- package/bin/runtime/server/http/control/ExecuteBySession.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ExecuteInput.d.ts +1 -1
- package/bin/runtime/server/http/control/ExecuteInput.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ExecuteInput.js +2 -2
- package/bin/runtime/server/http/control/ExecuteInput.js.map +1 -0
- package/bin/runtime/server/http/control/Helpers.d.ts.map +1 -0
- package/bin/runtime/server/http/control/Helpers.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/MessageTimeline.d.ts +2 -2
- package/bin/runtime/server/http/control/MessageTimeline.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/MessageTimeline.js +2 -2
- package/bin/runtime/server/http/control/MessageTimeline.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ModelRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/ModelRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ModelRoutes.js +2 -2
- package/bin/runtime/server/http/control/ModelRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/OverviewRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/OverviewRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/OverviewRoutes.js +2 -2
- package/bin/runtime/server/http/control/OverviewRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/SessionRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/SessionRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/SessionRoutes.js +2 -2
- package/bin/runtime/server/http/control/SessionRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/SessionSummaryStore.d.ts +2 -2
- package/bin/runtime/server/http/control/SessionSummaryStore.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/SessionSummaryStore.js +2 -2
- package/bin/runtime/server/http/control/SessionSummaryStore.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/TaskRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/TaskRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/TaskRoutes.js +4 -4
- package/bin/runtime/server/http/control/TaskRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/TaskStore.d.ts +1 -1
- package/bin/runtime/server/http/control/TaskStore.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/TaskStore.js +2 -2
- package/bin/runtime/server/http/control/TaskStore.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/types/AuthControl.d.ts +1 -1
- package/bin/runtime/server/http/control/types/AuthControl.d.ts.map +1 -0
- package/bin/runtime/server/http/control/types/AuthControl.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/types/ControlRoutes.d.ts +2 -2
- package/bin/runtime/server/http/control/types/ControlRoutes.d.ts.map +1 -0
- package/bin/runtime/server/http/control/types/ControlRoutes.js.map +1 -0
- package/bin/runtime/server/http/control/types/ControlSessionExecute.d.ts.map +1 -0
- package/bin/runtime/server/http/control/types/ControlSessionExecute.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/types/ControlViewData.d.ts +1 -1
- package/bin/runtime/server/http/control/types/ControlViewData.d.ts.map +1 -0
- package/bin/runtime/server/http/control/types/ControlViewData.js.map +1 -0
- package/bin/{server → runtime/server}/http/execute/execute.d.ts +1 -1
- package/bin/runtime/server/http/execute/execute.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/execute/execute.js +2 -2
- package/bin/runtime/server/http/execute/execute.js.map +1 -0
- package/bin/runtime/server/http/health/health.d.ts.map +1 -0
- package/bin/runtime/server/http/health/health.js.map +1 -0
- package/bin/{server → runtime/server}/http/plugins/plugins.d.ts +1 -1
- package/bin/runtime/server/http/plugins/plugins.d.ts.map +1 -0
- package/bin/runtime/server/http/plugins/plugins.js.map +1 -0
- package/bin/{server → runtime/server}/http/services/services.d.ts +1 -1
- package/bin/runtime/server/http/services/services.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/services/services.js +2 -2
- package/bin/runtime/server/http/services/services.js.map +1 -0
- package/bin/{server → runtime/server}/http/static/static.d.ts +1 -1
- package/bin/runtime/server/http/static/static.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/static/static.js +1 -1
- package/bin/runtime/server/http/static/static.js.map +1 -0
- package/bin/{server → runtime/server}/rpc/Server.d.ts +4 -4
- package/bin/runtime/server/rpc/Server.d.ts.map +1 -0
- package/bin/{server → runtime/server}/rpc/Server.js +5 -5
- package/bin/runtime/server/rpc/Server.js.map +1 -0
- package/bin/{transport → runtime/transport}/rpc/Client.d.ts +1 -1
- package/bin/runtime/transport/rpc/Client.d.ts.map +1 -0
- package/bin/runtime/transport/rpc/Client.js.map +1 -0
- package/bin/runtime/transport/rpc/Paths.d.ts.map +1 -0
- package/bin/runtime/transport/rpc/Paths.js.map +1 -0
- package/bin/{transport → runtime/transport}/rpc/Transport.d.ts +1 -1
- package/bin/runtime/transport/rpc/Transport.d.ts.map +1 -0
- package/bin/{transport → runtime/transport}/rpc/Transport.js +1 -1
- package/bin/runtime/transport/rpc/Transport.js.map +1 -0
- package/bin/sdk/Agent.js +2 -2
- package/bin/sdk/Agent.js.map +1 -1
- package/bin/sdk/AgentSdkTypes.d.ts +3 -3
- package/bin/sdk/AgentSdkTypes.d.ts.map +1 -1
- package/bin/sdk/Session.d.ts +2 -1
- package/bin/sdk/Session.d.ts.map +1 -1
- package/bin/sdk/Session.js +13 -7
- package/bin/sdk/Session.js.map +1 -1
- package/bin/sdk/SessionSystemBuilder.d.ts +2 -2
- package/bin/sdk/SessionSystemBuilder.d.ts.map +1 -1
- package/bin/sdk/SessionSystemBuilder.js +1 -3
- package/bin/sdk/SessionSystemBuilder.js.map +1 -1
- package/bin/sdk/session/ServicePort.d.ts +3 -2
- package/bin/sdk/session/ServicePort.d.ts.map +1 -1
- package/bin/sdk/session/ServicePort.js +1 -1
- package/bin/sdk/session/ServicePort.js.map +1 -1
- package/bin/service/builtins/chat/ChatService.d.ts +1 -1
- 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/accounts/ChannelAccountService.d.ts +1 -1
- package/bin/service/builtins/chat/accounts/ChannelAccountService.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/ChatSession.d.ts +10 -5
- package/bin/service/builtins/chat/runtime/ChatSession.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatSession.js +6 -5
- package/bin/service/builtins/chat/runtime/ChatSession.js.map +1 -1
- package/bin/service/builtins/chat/runtime/{ChatSessionExecutionComposer.d.ts → ChatSessionContextComposer.d.ts} +7 -7
- package/bin/service/builtins/chat/runtime/ChatSessionContextComposer.d.ts.map +1 -0
- package/bin/service/builtins/chat/runtime/{ChatSessionExecutionComposer.js → ChatSessionContextComposer.js} +5 -5
- package/bin/service/builtins/chat/runtime/ChatSessionContextComposer.js.map +1 -0
- package/bin/service/builtins/chat/types/ChannelAccount.d.ts +1 -1
- package/bin/service/builtins/chat/types/ChannelAccount.d.ts.map +1 -1
- package/bin/service/builtins/memory/runtime/Flush.js +3 -3
- package/bin/service/builtins/memory/runtime/Flush.js.map +1 -1
- package/bin/service/builtins/shell/runtime/ShellActionRuntime.js +1 -1
- package/bin/service/builtins/shell/runtime/ShellActionRuntime.js.map +1 -1
- package/bin/service/builtins/shell/runtime/ShellRuntimeEnvironment.js +1 -1
- package/bin/service/builtins/shell/runtime/ShellRuntimeEnvironment.js.map +1 -1
- package/bin/service/builtins/task/runtime/Runner.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/Runner.js +5 -0
- package/bin/service/builtins/task/runtime/Runner.js.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerRound.js +2 -2
- package/bin/service/builtins/task/runtime/TaskRunnerRound.js.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerSession.d.ts +7 -4
- package/bin/service/builtins/task/runtime/TaskRunnerSession.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerSession.js +39 -24
- package/bin/service/builtins/task/runtime/TaskRunnerSession.js.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerTypes.d.ts +4 -4
- package/bin/service/builtins/task/runtime/TaskRunnerTypes.d.ts.map +1 -1
- package/bin/session/Executor.d.ts +50 -17
- package/bin/session/Executor.d.ts.map +1 -1
- package/bin/session/Executor.js +366 -44
- package/bin/session/Executor.js.map +1 -1
- package/bin/session/composer/compaction/SessionCompactionComposer.d.ts +11 -12
- package/bin/session/composer/compaction/SessionCompactionComposer.d.ts.map +1 -1
- package/bin/session/composer/compaction/SessionCompactionComposer.js +2 -7
- package/bin/session/composer/compaction/SessionCompactionComposer.js.map +1 -1
- package/bin/session/composer/compaction/jsonl/JsonlSessionCompactionComposer.d.ts +3 -4
- package/bin/session/composer/compaction/jsonl/JsonlSessionCompactionComposer.d.ts.map +1 -1
- package/bin/session/composer/compaction/jsonl/JsonlSessionCompactionComposer.js +3 -5
- package/bin/session/composer/compaction/jsonl/JsonlSessionCompactionComposer.js.map +1 -1
- package/bin/session/composer/{execution/LocalSessionExecutionComposer.d.ts → context/LocalSessionContextComposer.d.ts} +10 -11
- package/bin/session/composer/context/LocalSessionContextComposer.d.ts.map +1 -0
- package/bin/session/composer/{execution/LocalSessionExecutionComposer.js → context/LocalSessionContextComposer.js} +8 -10
- package/bin/session/composer/context/LocalSessionContextComposer.js.map +1 -0
- package/bin/session/composer/{execution/SessionExecutionComposer.d.ts → context/SessionContextComposer.d.ts} +14 -15
- package/bin/session/composer/context/SessionContextComposer.d.ts.map +1 -0
- package/bin/session/composer/context/SessionContextComposer.js +9 -0
- package/bin/session/composer/context/SessionContextComposer.js.map +1 -0
- package/bin/session/composer/history/SessionHistoryComposer.d.ts +9 -111
- package/bin/session/composer/history/SessionHistoryComposer.d.ts.map +1 -1
- package/bin/session/composer/history/SessionHistoryComposer.js +3 -7
- package/bin/session/composer/history/SessionHistoryComposer.js.map +1 -1
- package/bin/session/composer/history/SessionHistoryWriter.d.ts +5 -5
- package/bin/session/composer/history/SessionHistoryWriter.d.ts.map +1 -1
- package/bin/session/composer/history/SessionHistoryWriter.js +10 -10
- package/bin/session/composer/history/SessionHistoryWriter.js.map +1 -1
- package/bin/session/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts +21 -54
- package/bin/session/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts.map +1 -1
- package/bin/session/composer/history/jsonl/JsonlSessionHistoryComposer.js +16 -367
- package/bin/session/composer/history/jsonl/JsonlSessionHistoryComposer.js.map +1 -1
- package/bin/session/composer/system/SessionSystemComposer.d.ts +5 -6
- package/bin/session/composer/system/SessionSystemComposer.d.ts.map +1 -1
- package/bin/session/composer/system/SessionSystemComposer.js +2 -7
- package/bin/session/composer/system/SessionSystemComposer.js.map +1 -1
- package/bin/session/composer/system/default/DefaultSessionSystemComposer.d.ts +2 -2
- package/bin/session/composer/system/default/DefaultSessionSystemComposer.d.ts.map +1 -1
- package/bin/session/composer/system/default/DefaultSessionSystemComposer.js +1 -3
- package/bin/session/composer/system/default/DefaultSessionSystemComposer.js.map +1 -1
- package/bin/session/{executors/local/SessionExecutionError.d.ts → core-engine/CoreEngineError.d.ts} +5 -5
- package/bin/session/core-engine/CoreEngineError.d.ts.map +1 -0
- package/bin/session/{executors/local/SessionExecutionError.js → core-engine/CoreEngineError.js} +4 -4
- package/bin/session/core-engine/CoreEngineError.js.map +1 -0
- package/bin/session/{executors/local/SessionLoopDecision.d.ts → core-engine/CoreEngineLoopDecision.d.ts} +6 -6
- package/bin/session/core-engine/CoreEngineLoopDecision.d.ts.map +1 -0
- package/bin/session/{executors/local/SessionLoopDecision.js → core-engine/CoreEngineLoopDecision.js} +5 -5
- package/bin/session/core-engine/CoreEngineLoopDecision.js.map +1 -0
- package/bin/session/{executors/local/SessionModelMessageState.d.ts → core-engine/CoreEngineMessageState.d.ts} +7 -7
- package/bin/session/core-engine/CoreEngineMessageState.d.ts.map +1 -0
- package/bin/session/{executors/local/SessionModelMessageState.js → core-engine/CoreEngineMessageState.js} +7 -7
- package/bin/session/core-engine/CoreEngineMessageState.js.map +1 -0
- package/bin/session/{executors/local/SessionSignals.d.ts → core-engine/CoreEngineSignals.d.ts} +6 -6
- package/bin/session/core-engine/CoreEngineSignals.d.ts.map +1 -0
- package/bin/session/{executors/local/SessionSignals.js → core-engine/CoreEngineSignals.js} +4 -4
- package/bin/session/core-engine/CoreEngineSignals.js.map +1 -0
- package/bin/session/{executors/local/SessionUiStreamCollector.d.ts → core-engine/CoreEngineUiStreamCollector.d.ts} +3 -3
- package/bin/session/core-engine/CoreEngineUiStreamCollector.d.ts.map +1 -0
- package/bin/session/{executors/local/SessionUiStreamCollector.js → core-engine/CoreEngineUiStreamCollector.js} +3 -3
- package/bin/session/core-engine/CoreEngineUiStreamCollector.js.map +1 -0
- package/bin/session/store/history/SessionHistoryStore.d.ts +119 -0
- package/bin/session/store/history/SessionHistoryStore.d.ts.map +1 -0
- package/bin/session/store/history/SessionHistoryStore.js +10 -0
- package/bin/session/store/history/SessionHistoryStore.js.map +1 -0
- package/bin/session/store/history/jsonl/JsonlSessionHistoryStore.d.ts +76 -0
- package/bin/session/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -0
- package/bin/session/store/history/jsonl/JsonlSessionHistoryStore.js +374 -0
- package/bin/session/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -0
- package/bin/session/tools/shell/ShellToolFormatting.js +1 -1
- package/bin/session/tools/shell/ShellToolFormatting.js.map +1 -1
- package/bin/session/types/SessionHistoryPaths.d.ts +2 -2
- package/bin/session/types/SessionLoop.d.ts +1 -1
- package/bin/session/types/SessionLoop.js +1 -1
- package/bin/session/types/SessionMessages.d.ts +1 -1
- package/bin/session/types/SessionMessages.js +1 -1
- package/bin/session/types/SessionRun.d.ts +2 -2
- package/bin/session/types/SessionRun.js +1 -1
- package/bin/types/config/DowncityConfig.d.ts +4 -3
- package/bin/types/config/DowncityConfig.d.ts.map +1 -1
- package/bin/types/runtime/auth/AuthPermission.d.ts.map +1 -0
- package/bin/types/runtime/auth/AuthPermission.js.map +1 -0
- package/bin/types/runtime/auth/AuthRoute.d.ts.map +1 -0
- package/bin/types/runtime/auth/AuthRoute.js.map +1 -0
- package/bin/types/runtime/auth/AuthToken.d.ts.map +1 -0
- package/bin/types/runtime/auth/AuthToken.js.map +1 -0
- package/bin/types/runtime/auth/AuthTypes.d.ts.map +1 -0
- package/bin/types/runtime/auth/AuthTypes.js.map +1 -0
- package/bin/types/runtime/daemon/Daemon.d.ts.map +1 -0
- package/bin/types/runtime/daemon/Daemon.js.map +1 -0
- package/bin/types/{host → runtime/host}/AgentHost.d.ts +7 -7
- package/bin/types/runtime/host/AgentHost.d.ts.map +1 -0
- package/bin/types/runtime/host/AgentHost.js.map +1 -0
- package/bin/types/{host → runtime/host}/Store.d.ts +1 -1
- package/bin/types/runtime/host/Store.d.ts.map +1 -0
- package/bin/types/runtime/host/Store.js.map +1 -0
- package/bin/types/runtime/http/InlineInstant.d.ts.map +1 -0
- package/bin/types/runtime/http/InlineInstant.js.map +1 -0
- package/bin/types/runtime/platform/Platform.d.ts.map +1 -0
- package/bin/types/runtime/platform/Platform.js.map +1 -0
- package/bin/types/runtime/platform/PlatformGateway.d.ts.map +1 -0
- package/bin/types/runtime/platform/PlatformGateway.js.map +1 -0
- package/bin/types/{rpc → runtime/rpc}/LocalRpc.d.ts +2 -2
- package/bin/types/runtime/rpc/LocalRpc.d.ts.map +1 -0
- package/bin/types/runtime/rpc/LocalRpc.js.map +1 -0
- package/bin/utils/logger/FormatRequest.js +1 -1
- package/bin/utils/logger/FormatRequest.js.map +1 -1
- package/package.json +1 -1
- package/src/{project → config/project}/AgentInitializer.ts +2 -2
- package/src/core/AgentContextTypes.ts +9 -74
- package/src/core/AgentCore.ts +6 -3
- package/src/core/AgentCoreTypes.ts +1 -6
- package/src/index.ts +26 -23
- package/src/plugin/builtins/asr/Config.ts +1 -1
- package/src/plugin/builtins/auth/runtime/AuthorizationPolicy.ts +1 -1
- package/src/plugin/builtins/voice/Config.ts +1 -1
- package/src/plugin/builtins/workboard/runtime/Collector.ts +1 -1
- package/src/plugin/builtins/workboard/runtime/Normalizer.ts +1 -1
- package/src/plugin/core/HttpRoutes.ts +1 -1
- package/src/plugin/core/LocalExecution.ts +2 -2
- package/src/plugin/core/PluginManager.ts +1 -1
- package/src/plugin/types/Plugin.ts +2 -2
- package/src/{host/runtime → runtime/host}/AgentHostRuntime.ts +1 -1
- package/src/{host → runtime/host}/daemon/Client.ts +2 -2
- package/src/{host → runtime/host}/daemon/Paths.ts +1 -1
- package/src/{host → runtime/host}/daemon/ProjectSetup.ts +1 -1
- package/src/{sandbox → runtime/sandbox}/MacOsSeatbeltSandbox.ts +1 -1
- package/src/{sandbox → runtime/sandbox}/SandboxConfigResolver.ts +1 -1
- package/src/{sandbox → runtime/sandbox}/SandboxRunner.ts +3 -3
- package/src/{sandbox → runtime/sandbox}/types/SandboxRuntime.ts +2 -2
- package/src/{server → runtime/server}/http/Server.ts +6 -6
- package/src/{server → runtime/server}/http/control/AuthControlService.ts +1 -1
- package/src/{server → runtime/server}/http/control/ControlApiRoutes.ts +6 -6
- package/src/{server → runtime/server}/http/control/ControlAuthorizationRoutes.ts +2 -2
- package/src/{server → runtime/server}/http/control/ControlRouter.ts +1 -1
- package/src/{server → runtime/server}/http/control/ExecuteBySession.ts +1 -1
- package/src/{server → runtime/server}/http/control/ExecuteInput.ts +1 -1
- package/src/{server → runtime/server}/http/control/MessageTimeline.ts +1 -1
- package/src/{server → runtime/server}/http/control/ModelRoutes.ts +2 -2
- package/src/{server → runtime/server}/http/control/OverviewRoutes.ts +1 -1
- package/src/{server → runtime/server}/http/control/SessionRoutes.ts +2 -2
- package/src/{server → runtime/server}/http/control/SessionSummaryStore.ts +1 -1
- package/src/{server → runtime/server}/http/control/TaskRoutes.ts +1 -1
- package/src/{server → runtime/server}/http/control/TaskStore.ts +1 -1
- package/src/{server → runtime/server}/rpc/Server.ts +4 -4
- package/src/{transport → runtime/transport}/rpc/Client.ts +2 -2
- package/src/{transport → runtime/transport}/rpc/Transport.ts +2 -2
- package/src/sdk/Agent.ts +2 -2
- package/src/sdk/AgentSdkTypes.ts +3 -3
- package/src/sdk/Session.ts +13 -7
- package/src/sdk/SessionSystemBuilder.ts +2 -3
- package/src/sdk/session/ServicePort.ts +4 -3
- package/src/service/builtins/chat/ChatService.ts +1 -1
- package/src/service/builtins/chat/ChatServiceTypes.ts +1 -1
- package/src/service/builtins/chat/accounts/ChannelAccountService.ts +2 -2
- 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/ChatSession.ts +15 -8
- package/src/service/builtins/chat/runtime/{ChatSessionExecutionComposer.ts → ChatSessionContextComposer.ts} +7 -7
- package/src/service/builtins/chat/types/ChannelAccount.ts +1 -1
- package/src/service/builtins/memory/runtime/Flush.ts +3 -3
- package/src/service/builtins/shell/runtime/ShellActionRuntime.ts +1 -1
- package/src/service/builtins/shell/runtime/ShellRuntimeEnvironment.ts +1 -1
- package/src/service/builtins/task/runtime/Runner.ts +7 -0
- package/src/service/builtins/task/runtime/TaskRunnerRound.ts +2 -2
- package/src/service/builtins/task/runtime/TaskRunnerSession.ts +48 -25
- package/src/service/builtins/task/runtime/TaskRunnerTypes.ts +4 -4
- package/src/session/Executor.ts +473 -52
- package/src/session/README.md +107 -0
- package/src/session/composer/compaction/SessionCompactionComposer.ts +11 -17
- package/src/session/composer/compaction/jsonl/JsonlSessionCompactionComposer.ts +7 -6
- package/src/session/composer/{execution/LocalSessionExecutionComposer.ts → context/LocalSessionContextComposer.ts} +14 -15
- package/src/session/composer/{execution/SessionExecutionComposer.ts → context/SessionContextComposer.ts} +13 -14
- package/src/session/composer/history/SessionHistoryComposer.ts +9 -141
- package/src/session/composer/history/SessionHistoryWriter.ts +14 -14
- package/src/session/composer/history/jsonl/JsonlSessionHistoryComposer.ts +28 -443
- package/src/session/composer/system/SessionSystemComposer.ts +5 -6
- package/src/session/composer/system/default/DefaultSessionSystemComposer.ts +2 -3
- package/src/session/{executors/local/SessionExecutionError.ts → core-engine/CoreEngineError.ts} +3 -3
- package/src/session/{executors/local/SessionLoopDecision.ts → core-engine/CoreEngineLoopDecision.ts} +4 -4
- package/src/session/{executors/local/SessionModelMessageState.ts → core-engine/CoreEngineMessageState.ts} +6 -6
- package/src/session/{executors/local/SessionSignals.ts → core-engine/CoreEngineSignals.ts} +3 -3
- package/src/session/{executors/local/SessionUiStreamCollector.ts → core-engine/CoreEngineUiStreamCollector.ts} +1 -1
- package/src/session/store/history/SessionHistoryStore.ts +145 -0
- package/src/session/store/history/jsonl/JsonlSessionHistoryStore.ts +465 -0
- package/src/session/tools/shell/ShellToolFormatting.ts +1 -1
- package/src/session/types/SessionHistoryPaths.ts +2 -2
- package/src/session/types/SessionLoop.ts +1 -1
- package/src/session/types/SessionMessages.ts +1 -1
- package/src/session/types/SessionRun.ts +2 -2
- package/src/types/config/DowncityConfig.ts +4 -3
- package/src/types/{host → runtime/host}/AgentHost.ts +3 -3
- package/src/types/{rpc → runtime/rpc}/LocalRpc.ts +1 -1
- package/src/utils/logger/FormatRequest.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/host/daemon/Api.d.ts.map +0 -1
- package/bin/host/daemon/Api.js.map +0 -1
- package/bin/host/daemon/Client.d.ts.map +0 -1
- package/bin/host/daemon/Client.js.map +0 -1
- package/bin/host/daemon/Paths.d.ts.map +0 -1
- package/bin/host/daemon/Paths.js.map +0 -1
- package/bin/host/daemon/ProjectSetup.d.ts.map +0 -1
- package/bin/host/daemon/ProjectSetup.js.map +0 -1
- package/bin/model/CreateModel.d.ts +0 -30
- package/bin/model/CreateModel.d.ts.map +0 -1
- package/bin/model/CreateModel.js +0 -311
- package/bin/model/CreateModel.js.map +0 -1
- package/bin/model/ModelManager.d.ts +0 -71
- package/bin/model/ModelManager.d.ts.map +0 -1
- package/bin/model/ModelManager.js +0 -187
- package/bin/model/ModelManager.js.map +0 -1
- package/bin/project/AgentInitializer.d.ts.map +0 -1
- package/bin/project/AgentInitializer.js.map +0 -1
- package/bin/project/types/AgentProject.d.ts.map +0 -1
- package/bin/project/types/AgentProject.js.map +0 -1
- package/bin/sandbox/MacOsSeatbeltSandbox.d.ts.map +0 -1
- package/bin/sandbox/MacOsSeatbeltSandbox.js.map +0 -1
- package/bin/sandbox/SandboxConfigResolver.d.ts.map +0 -1
- package/bin/sandbox/SandboxConfigResolver.js.map +0 -1
- package/bin/sandbox/SandboxRunner.d.ts.map +0 -1
- package/bin/sandbox/SandboxRunner.js.map +0 -1
- package/bin/sandbox/types/Sandbox.d.ts.map +0 -1
- package/bin/sandbox/types/Sandbox.js.map +0 -1
- package/bin/sandbox/types/SandboxRuntime.d.ts.map +0 -1
- package/bin/sandbox/types/SandboxRuntime.js.map +0 -1
- package/bin/server/http/Server.d.ts.map +0 -1
- package/bin/server/http/Server.js.map +0 -1
- package/bin/server/http/auth/AuthEnv.d.ts.map +0 -1
- package/bin/server/http/auth/AuthEnv.js.map +0 -1
- package/bin/server/http/auth/AuthError.d.ts.map +0 -1
- package/bin/server/http/auth/AuthError.js.map +0 -1
- package/bin/server/http/auth/CliAuthStateStore.d.ts.map +0 -1
- package/bin/server/http/auth/CliAuthStateStore.js.map +0 -1
- package/bin/server/http/auth/PasswordHasher.d.ts.map +0 -1
- package/bin/server/http/auth/PasswordHasher.js.map +0 -1
- package/bin/server/http/auth/TokenService.d.ts.map +0 -1
- package/bin/server/http/auth/TokenService.js.map +0 -1
- package/bin/server/http/control/AuthControlService.d.ts.map +0 -1
- package/bin/server/http/control/AuthControlService.js.map +0 -1
- package/bin/server/http/control/CommonHelpers.d.ts.map +0 -1
- package/bin/server/http/control/CommonHelpers.js.map +0 -1
- package/bin/server/http/control/ControlApiRoutes.d.ts.map +0 -1
- package/bin/server/http/control/ControlApiRoutes.js.map +0 -1
- package/bin/server/http/control/ControlAuthorizationRoutes.d.ts.map +0 -1
- package/bin/server/http/control/ControlAuthorizationRoutes.js.map +0 -1
- package/bin/server/http/control/ControlRouter.d.ts.map +0 -1
- package/bin/server/http/control/ControlRouter.js.map +0 -1
- package/bin/server/http/control/ExecuteBySession.d.ts.map +0 -1
- package/bin/server/http/control/ExecuteBySession.js.map +0 -1
- package/bin/server/http/control/ExecuteInput.d.ts.map +0 -1
- package/bin/server/http/control/ExecuteInput.js.map +0 -1
- package/bin/server/http/control/Helpers.d.ts.map +0 -1
- package/bin/server/http/control/Helpers.js.map +0 -1
- package/bin/server/http/control/MessageTimeline.d.ts.map +0 -1
- package/bin/server/http/control/MessageTimeline.js.map +0 -1
- package/bin/server/http/control/ModelRoutes.d.ts.map +0 -1
- package/bin/server/http/control/ModelRoutes.js.map +0 -1
- package/bin/server/http/control/OverviewRoutes.d.ts.map +0 -1
- package/bin/server/http/control/OverviewRoutes.js.map +0 -1
- package/bin/server/http/control/SessionRoutes.d.ts.map +0 -1
- package/bin/server/http/control/SessionRoutes.js.map +0 -1
- package/bin/server/http/control/SessionSummaryStore.d.ts.map +0 -1
- package/bin/server/http/control/SessionSummaryStore.js.map +0 -1
- package/bin/server/http/control/TaskRoutes.d.ts.map +0 -1
- package/bin/server/http/control/TaskRoutes.js.map +0 -1
- package/bin/server/http/control/TaskStore.d.ts.map +0 -1
- package/bin/server/http/control/TaskStore.js.map +0 -1
- package/bin/server/http/control/types/AuthControl.d.ts.map +0 -1
- package/bin/server/http/control/types/AuthControl.js.map +0 -1
- package/bin/server/http/control/types/ControlRoutes.d.ts.map +0 -1
- package/bin/server/http/control/types/ControlRoutes.js.map +0 -1
- package/bin/server/http/control/types/ControlSessionExecute.d.ts.map +0 -1
- package/bin/server/http/control/types/ControlSessionExecute.js.map +0 -1
- package/bin/server/http/control/types/ControlViewData.d.ts.map +0 -1
- package/bin/server/http/control/types/ControlViewData.js.map +0 -1
- package/bin/server/http/execute/execute.d.ts.map +0 -1
- package/bin/server/http/execute/execute.js.map +0 -1
- package/bin/server/http/health/health.d.ts.map +0 -1
- package/bin/server/http/health/health.js.map +0 -1
- package/bin/server/http/plugins/plugins.d.ts.map +0 -1
- package/bin/server/http/plugins/plugins.js.map +0 -1
- package/bin/server/http/services/services.d.ts.map +0 -1
- package/bin/server/http/services/services.js.map +0 -1
- package/bin/server/http/static/static.d.ts.map +0 -1
- package/bin/server/http/static/static.js.map +0 -1
- package/bin/server/rpc/Server.d.ts.map +0 -1
- package/bin/server/rpc/Server.js.map +0 -1
- package/bin/service/builtins/chat/runtime/ChatSessionExecutionComposer.d.ts.map +0 -1
- package/bin/service/builtins/chat/runtime/ChatSessionExecutionComposer.js.map +0 -1
- package/bin/session/composer/SessionComposer.d.ts +0 -29
- package/bin/session/composer/SessionComposer.d.ts.map +0 -1
- package/bin/session/composer/SessionComposer.js +0 -29
- package/bin/session/composer/SessionComposer.js.map +0 -1
- package/bin/session/composer/execution/LocalSessionExecutionComposer.d.ts.map +0 -1
- package/bin/session/composer/execution/LocalSessionExecutionComposer.js.map +0 -1
- package/bin/session/composer/execution/SessionExecutionComposer.d.ts.map +0 -1
- package/bin/session/composer/execution/SessionExecutionComposer.js +0 -14
- package/bin/session/composer/execution/SessionExecutionComposer.js.map +0 -1
- package/bin/session/executors/local/Runner.d.ts +0 -108
- package/bin/session/executors/local/Runner.d.ts.map +0 -1
- package/bin/session/executors/local/Runner.js +0 -219
- package/bin/session/executors/local/Runner.js.map +0 -1
- package/bin/session/executors/local/SessionExecutionError.d.ts.map +0 -1
- package/bin/session/executors/local/SessionExecutionError.js.map +0 -1
- package/bin/session/executors/local/SessionLoopDecision.d.ts.map +0 -1
- package/bin/session/executors/local/SessionLoopDecision.js.map +0 -1
- package/bin/session/executors/local/SessionModelMessageState.d.ts.map +0 -1
- package/bin/session/executors/local/SessionModelMessageState.js.map +0 -1
- package/bin/session/executors/local/SessionSignals.d.ts.map +0 -1
- package/bin/session/executors/local/SessionSignals.js.map +0 -1
- package/bin/session/executors/local/SessionToolLoopRunner.d.ts +0 -44
- package/bin/session/executors/local/SessionToolLoopRunner.d.ts.map +0 -1
- package/bin/session/executors/local/SessionToolLoopRunner.js +0 -261
- package/bin/session/executors/local/SessionToolLoopRunner.js.map +0 -1
- package/bin/session/executors/local/SessionUiStreamCollector.d.ts.map +0 -1
- package/bin/session/executors/local/SessionUiStreamCollector.js.map +0 -1
- package/bin/transport/rpc/Client.d.ts.map +0 -1
- package/bin/transport/rpc/Client.js.map +0 -1
- package/bin/transport/rpc/Paths.d.ts.map +0 -1
- package/bin/transport/rpc/Paths.js.map +0 -1
- package/bin/transport/rpc/Transport.d.ts.map +0 -1
- package/bin/transport/rpc/Transport.js.map +0 -1
- package/bin/types/auth/AuthPermission.d.ts.map +0 -1
- package/bin/types/auth/AuthPermission.js.map +0 -1
- package/bin/types/auth/AuthRoute.d.ts.map +0 -1
- package/bin/types/auth/AuthRoute.js.map +0 -1
- package/bin/types/auth/AuthToken.d.ts.map +0 -1
- package/bin/types/auth/AuthToken.js.map +0 -1
- package/bin/types/auth/AuthTypes.d.ts.map +0 -1
- package/bin/types/auth/AuthTypes.js.map +0 -1
- package/bin/types/daemon/Daemon.d.ts.map +0 -1
- package/bin/types/daemon/Daemon.js.map +0 -1
- package/bin/types/host/AgentHost.d.ts.map +0 -1
- package/bin/types/host/AgentHost.js.map +0 -1
- package/bin/types/host/Store.d.ts.map +0 -1
- package/bin/types/host/Store.js.map +0 -1
- package/bin/types/http/InlineInstant.d.ts.map +0 -1
- package/bin/types/http/InlineInstant.js.map +0 -1
- package/bin/types/platform/Platform.d.ts.map +0 -1
- package/bin/types/platform/Platform.js.map +0 -1
- package/bin/types/platform/PlatformGateway.d.ts.map +0 -1
- package/bin/types/platform/PlatformGateway.js.map +0 -1
- package/bin/types/rpc/LocalRpc.d.ts.map +0 -1
- package/bin/types/rpc/LocalRpc.js.map +0 -1
- package/src/model/CreateModel.ts +0 -350
- package/src/model/ModelManager.ts +0 -242
- package/src/session/composer/SessionComposer.ts +0 -34
- package/src/session/executors/local/Runner.ts +0 -297
- package/src/session/executors/local/SessionToolLoopRunner.ts +0 -350
- /package/bin/{project → config/project}/types/AgentProject.js +0 -0
- /package/bin/{host/runtime → runtime/host}/AgentHostRuntime.js +0 -0
- /package/bin/{host/runtime → runtime/host}/PluginRuntime.d.ts +0 -0
- /package/bin/{host/runtime → runtime/host}/PluginRuntime.js +0 -0
- /package/bin/{host → runtime/host}/daemon/Api.js +0 -0
- /package/bin/{host → runtime/host}/daemon/Client.d.ts +0 -0
- /package/bin/{host → runtime/host}/daemon/Paths.d.ts +0 -0
- /package/bin/{sandbox → runtime/sandbox}/MacOsSeatbeltSandbox.js +0 -0
- /package/bin/{sandbox → runtime/sandbox}/SandboxConfigResolver.js +0 -0
- /package/bin/{sandbox → runtime/sandbox}/types/Sandbox.d.ts +0 -0
- /package/bin/{sandbox → runtime/sandbox}/types/Sandbox.js +0 -0
- /package/bin/{sandbox → runtime/sandbox}/types/SandboxRuntime.js +0 -0
- /package/bin/{server → runtime/server}/http/auth/AuthEnv.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/auth/AuthEnv.js +0 -0
- /package/bin/{server → runtime/server}/http/auth/AuthError.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/auth/AuthError.js +0 -0
- /package/bin/{server → runtime/server}/http/auth/CliAuthStateStore.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/auth/CliAuthStateStore.js +0 -0
- /package/bin/{server → runtime/server}/http/auth/PasswordHasher.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/auth/PasswordHasher.js +0 -0
- /package/bin/{server → runtime/server}/http/auth/TokenService.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/auth/TokenService.js +0 -0
- /package/bin/{server → runtime/server}/http/control/CommonHelpers.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/control/CommonHelpers.js +0 -0
- /package/bin/{server → runtime/server}/http/control/Helpers.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/control/Helpers.js +0 -0
- /package/bin/{server → runtime/server}/http/control/types/AuthControl.js +0 -0
- /package/bin/{server → runtime/server}/http/control/types/ControlRoutes.js +0 -0
- /package/bin/{server → runtime/server}/http/control/types/ControlSessionExecute.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/control/types/ControlSessionExecute.js +0 -0
- /package/bin/{server → runtime/server}/http/control/types/ControlViewData.js +0 -0
- /package/bin/{server → runtime/server}/http/health/health.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/health/health.js +0 -0
- /package/bin/{server → runtime/server}/http/plugins/plugins.js +0 -0
- /package/bin/{transport → runtime/transport}/rpc/Client.js +0 -0
- /package/bin/{transport → runtime/transport}/rpc/Paths.d.ts +0 -0
- /package/bin/{transport → runtime/transport}/rpc/Paths.js +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthPermission.d.ts +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthPermission.js +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthRoute.d.ts +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthRoute.js +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthToken.d.ts +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthToken.js +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthTypes.d.ts +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthTypes.js +0 -0
- /package/bin/types/{daemon → runtime/daemon}/Daemon.d.ts +0 -0
- /package/bin/types/{daemon → runtime/daemon}/Daemon.js +0 -0
- /package/bin/types/{host → runtime/host}/AgentHost.js +0 -0
- /package/bin/types/{host → runtime/host}/Store.js +0 -0
- /package/bin/types/{http → runtime/http}/InlineInstant.d.ts +0 -0
- /package/bin/types/{http → runtime/http}/InlineInstant.js +0 -0
- /package/bin/types/{platform → runtime/platform}/Platform.d.ts +0 -0
- /package/bin/types/{platform → runtime/platform}/Platform.js +0 -0
- /package/bin/types/{platform → runtime/platform}/PlatformGateway.d.ts +0 -0
- /package/bin/types/{platform → runtime/platform}/PlatformGateway.js +0 -0
- /package/bin/types/{rpc → runtime/rpc}/LocalRpc.js +0 -0
- /package/src/{project → config/project}/types/AgentProject.ts +0 -0
- /package/src/{host/runtime → runtime/host}/PluginRuntime.ts +0 -0
- /package/src/{host → runtime/host}/daemon/Api.ts +0 -0
- /package/src/{sandbox → runtime/sandbox}/types/Sandbox.ts +0 -0
- /package/src/{server → runtime/server}/http/auth/AuthEnv.ts +0 -0
- /package/src/{server → runtime/server}/http/auth/AuthError.ts +0 -0
- /package/src/{server → runtime/server}/http/auth/CliAuthStateStore.ts +0 -0
- /package/src/{server → runtime/server}/http/auth/PasswordHasher.ts +0 -0
- /package/src/{server → runtime/server}/http/auth/TokenService.ts +0 -0
- /package/src/{server → runtime/server}/http/control/CommonHelpers.ts +0 -0
- /package/src/{server → runtime/server}/http/control/Helpers.ts +0 -0
- /package/src/{server → runtime/server}/http/control/types/AuthControl.ts +0 -0
- /package/src/{server → runtime/server}/http/control/types/ControlRoutes.ts +0 -0
- /package/src/{server → runtime/server}/http/control/types/ControlSessionExecute.ts +0 -0
- /package/src/{server → runtime/server}/http/control/types/ControlViewData.ts +0 -0
- /package/src/{server → runtime/server}/http/execute/execute.ts +0 -0
- /package/src/{server → runtime/server}/http/health/health.ts +0 -0
- /package/src/{server → runtime/server}/http/plugins/plugins.ts +0 -0
- /package/src/{server → runtime/server}/http/services/services.ts +0 -0
- /package/src/{server → runtime/server}/http/static/static.ts +0 -0
- /package/src/{transport → runtime/transport}/rpc/Paths.ts +0 -0
- /package/src/types/{auth → runtime/auth}/AuthPermission.ts +0 -0
- /package/src/types/{auth → runtime/auth}/AuthRoute.ts +0 -0
- /package/src/types/{auth → runtime/auth}/AuthToken.ts +0 -0
- /package/src/types/{auth → runtime/auth}/AuthTypes.ts +0 -0
- /package/src/types/{daemon → runtime/daemon}/Daemon.ts +0 -0
- /package/src/types/{host → runtime/host}/Store.ts +0 -0
- /package/src/types/{http → runtime/http}/InlineInstant.ts +0 -0
- /package/src/types/{platform → runtime/platform}/Platform.ts +0 -0
- /package/src/types/{platform → runtime/platform}/PlatformGateway.ts +0 -0
package/src/session/Executor.ts
CHANGED
|
@@ -4,26 +4,62 @@
|
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - SDK 对外对象叫 `Session`,这里是内部执行层。
|
|
6
6
|
* - 一个 Executor 只对应一个固定的 `sessionId`。
|
|
7
|
-
* - 负责 history 写入、run scope、executing
|
|
7
|
+
* - 负责 history 写入、run scope、executing 状态、Composer 编排与 tool-loop 执行。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type
|
|
10
|
+
import { streamText, type LanguageModel, type Tool } from "ai";
|
|
11
11
|
import { SessionHistoryWriter } from "@session/composer/history/SessionHistoryWriter.js";
|
|
12
12
|
import type { SessionHistoryComposer } from "@session/composer/history/SessionHistoryComposer.js";
|
|
13
|
+
import type { SessionHistoryStore } from "@/session/store/history/SessionHistoryStore.js";
|
|
13
14
|
import { withSessionRunScope } from "@session/SessionRunScope.js";
|
|
14
15
|
import type { SessionRunScope } from "@session/SessionRunScope.js";
|
|
15
16
|
import { buildSessionStepEventMessages } from "@session/messages/SessionStepEventMapper.js";
|
|
16
17
|
import { JsonlSessionCompactionComposer } from "@session/composer/compaction/jsonl/JsonlSessionCompactionComposer.js";
|
|
17
|
-
import {
|
|
18
|
+
import { LocalSessionContextComposer } from "@session/composer/context/LocalSessionContextComposer.js";
|
|
18
19
|
import type { SessionCompactionComposer } from "@session/composer/compaction/SessionCompactionComposer.js";
|
|
19
|
-
import type {
|
|
20
|
+
import type { SessionContextComposer } from "@session/composer/context/SessionContextComposer.js";
|
|
20
21
|
import type { SessionSystemComposer } from "@session/composer/system/SessionSystemComposer.js";
|
|
21
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
MAX_INCOMPLETE_RESPONSE_RECOVERIES,
|
|
24
|
+
MAX_TEXT_ONLY_CONTINUATIONS,
|
|
25
|
+
MAX_TOOL_LOOP_STEPS,
|
|
26
|
+
buildIncompleteResponseRecoveryNudge,
|
|
27
|
+
buildTextOnlyContinuationNudge,
|
|
28
|
+
detectIncompleteResponse,
|
|
29
|
+
detectTextOnlyContinuationReason,
|
|
30
|
+
mergeAssistantUiMessages,
|
|
31
|
+
summarizeStepForDebug,
|
|
32
|
+
summarizeUiMessageForDebug,
|
|
33
|
+
toInlinePreview,
|
|
34
|
+
} from "@session/core-engine/CoreEngineSignals.js";
|
|
35
|
+
import {
|
|
36
|
+
evaluateCoreEngineLoopDecision,
|
|
37
|
+
shouldContinueForTailMergedUserMessages,
|
|
38
|
+
} from "@session/core-engine/CoreEngineLoopDecision.js";
|
|
39
|
+
import {
|
|
40
|
+
resolveEffectiveCoreEngineError,
|
|
41
|
+
summarizeStreamError,
|
|
42
|
+
} from "@session/core-engine/CoreEngineError.js";
|
|
43
|
+
import { collectFinalAssistantMessageFromUiStream } from "@session/core-engine/CoreEngineUiStreamCollector.js";
|
|
44
|
+
import { CoreEngineMessageState } from "@session/core-engine/CoreEngineMessageState.js";
|
|
45
|
+
import {
|
|
46
|
+
buildOpenAIResponsesProviderOptions,
|
|
47
|
+
} from "@session/messages/SessionMessageCodec.js";
|
|
48
|
+
import { logAssistantMessageNow } from "@session/messages/SessionMessageLog.js";
|
|
22
49
|
import type { Logger } from "@/utils/logger/Logger.js";
|
|
23
50
|
import type { JsonObject } from "@/types/common/Json.js";
|
|
24
51
|
import type { SessionMessageV1 } from "@/session/types/SessionMessages.js";
|
|
25
52
|
import type { SessionExecutor } from "@/session/types/SessionExecutor.js";
|
|
26
|
-
import type {
|
|
53
|
+
import type {
|
|
54
|
+
SessionExecuteInput,
|
|
55
|
+
SessionRunInput,
|
|
56
|
+
SessionRunResult,
|
|
57
|
+
} from "@/session/types/SessionRun.js";
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 可压缩错误的最大重试次数。
|
|
61
|
+
*/
|
|
62
|
+
const MAX_COMPACTION_RETRY_ATTEMPTS = 3;
|
|
27
63
|
|
|
28
64
|
type ExecutorOptions = {
|
|
29
65
|
/**
|
|
@@ -31,8 +67,16 @@ type ExecutorOptions = {
|
|
|
31
67
|
*/
|
|
32
68
|
sessionId: string;
|
|
33
69
|
|
|
70
|
+
/**
|
|
71
|
+
* 当前 session 对应的 history 事实源。
|
|
72
|
+
*/
|
|
73
|
+
historyStore: SessionHistoryStore;
|
|
74
|
+
|
|
34
75
|
/**
|
|
35
76
|
* 当前 session 对应的 history Composer。
|
|
77
|
+
*
|
|
78
|
+
* 关键点(中文)
|
|
79
|
+
* - Composer 只负责组装本轮 messages,不负责落盘。
|
|
36
80
|
*/
|
|
37
81
|
historyComposer: SessionHistoryComposer;
|
|
38
82
|
|
|
@@ -62,9 +106,9 @@ type ExecutorOptions = {
|
|
|
62
106
|
getTools: () => Record<string, Tool>;
|
|
63
107
|
|
|
64
108
|
/**
|
|
65
|
-
* 可选自定义
|
|
109
|
+
* 可选自定义 context Composer。
|
|
66
110
|
*/
|
|
67
|
-
|
|
111
|
+
contextComposer?: SessionContextComposer;
|
|
68
112
|
|
|
69
113
|
/**
|
|
70
114
|
* session 更新后的异步回调。
|
|
@@ -82,16 +126,16 @@ export class Executor implements SessionExecutor {
|
|
|
82
126
|
readonly sessionId: string;
|
|
83
127
|
|
|
84
128
|
private readonly historyComposer: SessionHistoryComposer;
|
|
129
|
+
private readonly historyStore: SessionHistoryStore;
|
|
85
130
|
private readonly getModel: ExecutorOptions["getModel"];
|
|
86
131
|
private readonly logger: Logger;
|
|
87
132
|
private readonly compactionComposer: SessionCompactionComposer;
|
|
88
133
|
private readonly systemComposer: SessionSystemComposer;
|
|
89
|
-
|
|
90
|
-
private readonly runnerExecutionComposer?: SessionExecutionComposer;
|
|
134
|
+
protected readonly contextComposer: SessionContextComposer;
|
|
91
135
|
private readonly historyWriter: SessionHistoryWriter;
|
|
92
136
|
|
|
93
|
-
private runner: Runner | null = null;
|
|
94
137
|
private executing = false;
|
|
138
|
+
private retryCount = 0;
|
|
95
139
|
|
|
96
140
|
constructor(options: ExecutorOptions) {
|
|
97
141
|
const sessionId = String(options.sessionId || "").trim();
|
|
@@ -100,17 +144,22 @@ export class Executor implements SessionExecutor {
|
|
|
100
144
|
}
|
|
101
145
|
|
|
102
146
|
this.sessionId = sessionId;
|
|
147
|
+
this.historyStore = options.historyStore;
|
|
103
148
|
this.historyComposer = options.historyComposer;
|
|
104
149
|
this.getModel = options.getModel;
|
|
105
150
|
this.logger = options.logger;
|
|
106
151
|
this.compactionComposer =
|
|
107
152
|
options.compactionComposer || new JsonlSessionCompactionComposer();
|
|
108
153
|
this.systemComposer = options.systemComposer;
|
|
109
|
-
this.
|
|
110
|
-
|
|
154
|
+
this.contextComposer =
|
|
155
|
+
options.contextComposer ||
|
|
156
|
+
new LocalSessionContextComposer({
|
|
157
|
+
sessionId: this.sessionId,
|
|
158
|
+
getTools: options.getTools,
|
|
159
|
+
});
|
|
111
160
|
this.historyWriter = new SessionHistoryWriter({
|
|
112
161
|
sessionId,
|
|
113
|
-
|
|
162
|
+
getHistoryStore: () => this.getHistoryStore(),
|
|
114
163
|
runAfterSessionUpdated: options.runAfterSessionUpdated,
|
|
115
164
|
});
|
|
116
165
|
}
|
|
@@ -123,10 +172,10 @@ export class Executor implements SessionExecutor {
|
|
|
123
172
|
}
|
|
124
173
|
|
|
125
174
|
/**
|
|
126
|
-
* 获取当前 session 的 history
|
|
175
|
+
* 获取当前 session 的 history 事实源。
|
|
127
176
|
*/
|
|
128
|
-
|
|
129
|
-
return this.
|
|
177
|
+
getHistoryStore(): SessionHistoryStore {
|
|
178
|
+
return this.historyStore;
|
|
130
179
|
}
|
|
131
180
|
|
|
132
181
|
/**
|
|
@@ -140,43 +189,13 @@ export class Executor implements SessionExecutor {
|
|
|
140
189
|
}
|
|
141
190
|
|
|
142
191
|
/**
|
|
143
|
-
*
|
|
144
|
-
*/
|
|
145
|
-
private getRunner(): Runner {
|
|
146
|
-
if (this.runner) return this.runner;
|
|
147
|
-
const model = this.getModel();
|
|
148
|
-
if (!model) {
|
|
149
|
-
throw new Error(
|
|
150
|
-
`Executor for session "${this.sessionId}" requires a configured model`,
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
const created = new Runner({
|
|
154
|
-
model,
|
|
155
|
-
logger: this.logger,
|
|
156
|
-
historyComposer: this.getHistoryComposer(),
|
|
157
|
-
compactionComposer: this.compactionComposer,
|
|
158
|
-
systemComposer: this.systemComposer,
|
|
159
|
-
executionComposer:
|
|
160
|
-
this.runnerExecutionComposer ||
|
|
161
|
-
new LocalSessionExecutionComposer({
|
|
162
|
-
sessionId: this.sessionId,
|
|
163
|
-
getTools: this.getTools,
|
|
164
|
-
}),
|
|
165
|
-
});
|
|
166
|
-
this.runner = created;
|
|
167
|
-
return created;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* 清理当前 session 的 Runner 缓存。
|
|
192
|
+
* 清理当前 session 的执行器运行态。
|
|
172
193
|
*
|
|
173
194
|
* 关键点(中文)
|
|
174
|
-
* -
|
|
175
|
-
* - history
|
|
195
|
+
* - 当前 Executor 不缓存模型实例,模型每轮 run 都从 `getModel()` 读取。
|
|
196
|
+
* - history 是事实源,不应随着执行态一起丢失。
|
|
176
197
|
*/
|
|
177
|
-
clearExecutor(): void {
|
|
178
|
-
this.runner = null;
|
|
179
|
-
}
|
|
198
|
+
clearExecutor(): void {}
|
|
180
199
|
|
|
181
200
|
/**
|
|
182
201
|
* 触发 session 更新后的异步回调。
|
|
@@ -269,6 +288,7 @@ export class Executor implements SessionExecutor {
|
|
|
269
288
|
};
|
|
270
289
|
|
|
271
290
|
this.executing = true;
|
|
291
|
+
this.resetRunState();
|
|
272
292
|
try {
|
|
273
293
|
const result = await withSessionRunScope(
|
|
274
294
|
{
|
|
@@ -276,7 +296,7 @@ export class Executor implements SessionExecutor {
|
|
|
276
296
|
...sessionRunScope,
|
|
277
297
|
onAssistantStepCallback: wrappedOnAssistantStepCallback,
|
|
278
298
|
},
|
|
279
|
-
() => this.
|
|
299
|
+
() => this.runWithRetry({ query }),
|
|
280
300
|
);
|
|
281
301
|
if (persistedAssistantStepCount <= 0) return result;
|
|
282
302
|
|
|
@@ -305,7 +325,408 @@ export class Executor implements SessionExecutor {
|
|
|
305
325
|
},
|
|
306
326
|
};
|
|
307
327
|
} finally {
|
|
328
|
+
this.resetRunState();
|
|
308
329
|
this.executing = false;
|
|
309
330
|
}
|
|
310
331
|
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* 执行一次 session run(带可压缩错误重试)。
|
|
335
|
+
*/
|
|
336
|
+
private async runWithRetry(input: SessionRunInput): Promise<SessionRunResult> {
|
|
337
|
+
const model = this.resolveModelOrThrow();
|
|
338
|
+
try {
|
|
339
|
+
const query = String(input.query || "").trim();
|
|
340
|
+
const prepared = await this.prepareExecuteInput(query, model);
|
|
341
|
+
return await this.executePreparedRun(prepared, model);
|
|
342
|
+
} catch (error) {
|
|
343
|
+
if (this.compactionComposer.shouldCompactOnError(error)) {
|
|
344
|
+
await this.logger.log("info", "[agent] compacting", {
|
|
345
|
+
retryCount: this.retryCount,
|
|
346
|
+
error: String(error),
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
if (this.retryCount < MAX_COMPACTION_RETRY_ATTEMPTS) {
|
|
350
|
+
this.retryCount += 1;
|
|
351
|
+
return this.runWithRetry(input);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return {
|
|
355
|
+
success: false,
|
|
356
|
+
error: "Context length exceeded and retries failed. Please resend your question.",
|
|
357
|
+
assistantMessage: this.contextComposer.buildFallbackAssistantMessage(
|
|
358
|
+
"Context length exceeded and retries failed. Please resend your question.",
|
|
359
|
+
),
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const errorMsg = String(error);
|
|
364
|
+
await this.logger.log("error", "Executor execution failed", {
|
|
365
|
+
error: errorMsg,
|
|
366
|
+
});
|
|
367
|
+
return {
|
|
368
|
+
success: false,
|
|
369
|
+
error: errorMsg,
|
|
370
|
+
assistantMessage: this.contextComposer.buildFallbackAssistantMessage(
|
|
371
|
+
`Execution failed: ${errorMsg}`,
|
|
372
|
+
),
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* 调用 Composer 组装当前轮执行输入。
|
|
379
|
+
*/
|
|
380
|
+
private async prepareExecuteInput(
|
|
381
|
+
query: string,
|
|
382
|
+
model: LanguageModel,
|
|
383
|
+
): Promise<SessionExecuteInput> {
|
|
384
|
+
if (!String(this.historyComposer.sessionId || "").trim()) {
|
|
385
|
+
throw new Error("Executor.run requires historyComposer.sessionId");
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const runContext = await this.contextComposer.compose();
|
|
389
|
+
const tools = runContext.tools;
|
|
390
|
+
const system = await this.systemComposer.resolve();
|
|
391
|
+
|
|
392
|
+
try {
|
|
393
|
+
if (this.retryCount > 0) {
|
|
394
|
+
await this.logger.log("info", "[agent] compacting", {
|
|
395
|
+
retryCount: this.retryCount,
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
await this.compactionComposer.run({
|
|
400
|
+
historyStore: this.historyStore,
|
|
401
|
+
model,
|
|
402
|
+
system,
|
|
403
|
+
retryCount: this.retryCount,
|
|
404
|
+
});
|
|
405
|
+
} catch {
|
|
406
|
+
// 压缩失败不阻断主流程,继续使用当前历史消息执行。
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const messages = await this.historyComposer.prepare({
|
|
410
|
+
query,
|
|
411
|
+
tools,
|
|
412
|
+
system,
|
|
413
|
+
model,
|
|
414
|
+
retryCount: this.retryCount,
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
return {
|
|
418
|
+
query,
|
|
419
|
+
system,
|
|
420
|
+
messages,
|
|
421
|
+
tools,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* 执行一次已装配完成的运行材料。
|
|
427
|
+
*/
|
|
428
|
+
private async executePreparedRun(
|
|
429
|
+
input: SessionExecuteInput,
|
|
430
|
+
model: LanguageModel,
|
|
431
|
+
): Promise<SessionRunResult> {
|
|
432
|
+
return await this.runCoreEngine(input, model);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* 运行模型/tool-loop 核心。
|
|
437
|
+
*
|
|
438
|
+
* 关键点(中文)
|
|
439
|
+
* - CoreEngine 是 Executor 内部机制,不是第二个 Executor 实例。
|
|
440
|
+
* - 这里只返回最终 assistant message;是否写入长期 history 由外层 Session/Service 决定。
|
|
441
|
+
* - 运行中生成的内部续写 user message 只进入本轮内存态,不直接落盘。
|
|
442
|
+
*/
|
|
443
|
+
private async runCoreEngine(
|
|
444
|
+
input: SessionExecuteInput,
|
|
445
|
+
model: LanguageModel,
|
|
446
|
+
): Promise<SessionRunResult> {
|
|
447
|
+
const startTime = Date.now();
|
|
448
|
+
const sessionId = String(this.historyStore.sessionId || "").trim();
|
|
449
|
+
const system = Array.isArray(input.system) ? input.system : [];
|
|
450
|
+
const tools = input.tools;
|
|
451
|
+
let lastObservedStreamError: unknown = undefined;
|
|
452
|
+
|
|
453
|
+
try {
|
|
454
|
+
const messageState = await CoreEngineMessageState.create({
|
|
455
|
+
messages: input.messages,
|
|
456
|
+
tools,
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
const appendMergedUserMessages = (messages: SessionMessageV1[]) =>
|
|
460
|
+
messageState.appendMergedUserMessages(messages);
|
|
461
|
+
|
|
462
|
+
const contextComposerOnStepFinish =
|
|
463
|
+
this.contextComposer.createOnStepFinishHandler();
|
|
464
|
+
let stepCount = 0;
|
|
465
|
+
let totalToolCallCount = 0;
|
|
466
|
+
let totalToolResultCount = 0;
|
|
467
|
+
const onStepFinish = async (stepResult: unknown): Promise<void> => {
|
|
468
|
+
stepCount += 1;
|
|
469
|
+
const summary = summarizeStepForDebug(stepResult);
|
|
470
|
+
totalToolCallCount +=
|
|
471
|
+
typeof summary.toolCallCount === "number" ? summary.toolCallCount : 0;
|
|
472
|
+
totalToolResultCount +=
|
|
473
|
+
typeof summary.toolResultCount === "number"
|
|
474
|
+
? summary.toolResultCount
|
|
475
|
+
: 0;
|
|
476
|
+
await this.logger.log("info", "[agent] step.finish", {
|
|
477
|
+
sessionId,
|
|
478
|
+
stepIndex: stepCount,
|
|
479
|
+
...summary,
|
|
480
|
+
});
|
|
481
|
+
await contextComposerOnStepFinish(stepResult);
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
const prepareStep = this.contextComposer.createPrepareStepHandler({
|
|
485
|
+
system,
|
|
486
|
+
appendMergedUserMessages,
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
let finalAssistantUiMessage: SessionMessageV1 | null = null;
|
|
490
|
+
let textOnlyContinuationCount = 0;
|
|
491
|
+
let incompleteResponseRecoveryCount = 0;
|
|
492
|
+
|
|
493
|
+
while (stepCount < MAX_TOOL_LOOP_STEPS) {
|
|
494
|
+
const result = streamText({
|
|
495
|
+
model,
|
|
496
|
+
system,
|
|
497
|
+
onStepFinish,
|
|
498
|
+
prepareStep,
|
|
499
|
+
messages: messageState.modelMessages,
|
|
500
|
+
tools,
|
|
501
|
+
providerOptions: buildOpenAIResponsesProviderOptions(),
|
|
502
|
+
onError: async ({ error }) => {
|
|
503
|
+
lastObservedStreamError = error;
|
|
504
|
+
await this.logger.log("error", "[agent] stream.error", {
|
|
505
|
+
sessionId,
|
|
506
|
+
...summarizeStreamError(error),
|
|
507
|
+
});
|
|
508
|
+
},
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
const stepAssistantUiMessage = await collectFinalAssistantMessageFromUiStream({
|
|
512
|
+
result,
|
|
513
|
+
sessionId,
|
|
514
|
+
logger: this.logger,
|
|
515
|
+
buildFallbackAssistantMessage: (text) =>
|
|
516
|
+
this.contextComposer.buildFallbackAssistantMessage(text),
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
const executedSteps = await result.steps;
|
|
520
|
+
const lastStep = executedSteps[executedSteps.length - 1];
|
|
521
|
+
if (!lastStep) break;
|
|
522
|
+
|
|
523
|
+
const incompleteResponse = detectIncompleteResponse({
|
|
524
|
+
stepResult: lastStep,
|
|
525
|
+
assistantMessage: stepAssistantUiMessage,
|
|
526
|
+
});
|
|
527
|
+
const textOnlyContinuationReason =
|
|
528
|
+
detectTextOnlyContinuationReason(lastStep);
|
|
529
|
+
const loopDecision = evaluateCoreEngineLoopDecision({
|
|
530
|
+
hasIncompleteResponse: incompleteResponse !== null,
|
|
531
|
+
incompleteRecoveryCount: incompleteResponseRecoveryCount,
|
|
532
|
+
maxIncompleteRecoveries: MAX_INCOMPLETE_RESPONSE_RECOVERIES,
|
|
533
|
+
textOnlyContinuationReason,
|
|
534
|
+
textOnlyContinuationCount,
|
|
535
|
+
maxTextOnlyContinuations: MAX_TEXT_ONLY_CONTINUATIONS,
|
|
536
|
+
hasTools: Object.keys(tools).length > 0,
|
|
537
|
+
toolCallCount: lastStep.toolCalls.length,
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
await this.logger.log("info", "[agent] loop.decision", {
|
|
541
|
+
sessionId,
|
|
542
|
+
stepIndex: stepCount,
|
|
543
|
+
continueForToolCalls: loopDecision.continueForToolCalls,
|
|
544
|
+
continueForTextOnly: loopDecision.continueForTextOnly,
|
|
545
|
+
continueForIncompleteRecovery:
|
|
546
|
+
loopDecision.continueForIncompleteRecovery,
|
|
547
|
+
decisionKind: loopDecision.kind,
|
|
548
|
+
textOnlyContinuationReason,
|
|
549
|
+
textOnlyContinuationCount,
|
|
550
|
+
incompleteResponseReason: incompleteResponse?.reason ?? null,
|
|
551
|
+
incompleteResponseRecoveryCount,
|
|
552
|
+
toolCallCount: lastStep.toolCalls.length,
|
|
553
|
+
toolResultCount: lastStep.toolResults.length,
|
|
554
|
+
finishReason: lastStep.finishReason,
|
|
555
|
+
textPreview: toInlinePreview(lastStep.text),
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
if (loopDecision.continueForIncompleteRecovery && incompleteResponse) {
|
|
559
|
+
incompleteResponseRecoveryCount += 1;
|
|
560
|
+
await this.logger.log("warn", "[agent] incomplete_response.recover", {
|
|
561
|
+
sessionId,
|
|
562
|
+
stepIndex: stepCount,
|
|
563
|
+
recoveryCount: incompleteResponseRecoveryCount,
|
|
564
|
+
reason: incompleteResponse.reason,
|
|
565
|
+
...incompleteResponse.details,
|
|
566
|
+
});
|
|
567
|
+
const recoveryMessage = this.historyStore.userText({
|
|
568
|
+
text: buildIncompleteResponseRecoveryNudge(
|
|
569
|
+
incompleteResponseRecoveryCount,
|
|
570
|
+
),
|
|
571
|
+
metadata: {
|
|
572
|
+
sessionId,
|
|
573
|
+
extra: {
|
|
574
|
+
internal: "agent_incomplete_response_recover",
|
|
575
|
+
reason: incompleteResponse.reason,
|
|
576
|
+
stepIndex: stepCount,
|
|
577
|
+
},
|
|
578
|
+
},
|
|
579
|
+
});
|
|
580
|
+
await messageState.appendUserTextMessage(recoveryMessage);
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
if (incompleteResponse) {
|
|
585
|
+
await this.logger.log("error", "[agent] incomplete_response", {
|
|
586
|
+
sessionId,
|
|
587
|
+
stepIndex: stepCount,
|
|
588
|
+
reason: incompleteResponse.reason,
|
|
589
|
+
recoveryCount: incompleteResponseRecoveryCount,
|
|
590
|
+
...incompleteResponse.details,
|
|
591
|
+
});
|
|
592
|
+
throw new Error(
|
|
593
|
+
`Agent received incomplete response (${incompleteResponse.reason})`,
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
const responseMessages = Array.isArray(lastStep.response?.messages)
|
|
598
|
+
? lastStep.response.messages
|
|
599
|
+
: [];
|
|
600
|
+
messageState.appendModelMessages(responseMessages);
|
|
601
|
+
|
|
602
|
+
finalAssistantUiMessage = mergeAssistantUiMessages(
|
|
603
|
+
finalAssistantUiMessage,
|
|
604
|
+
stepAssistantUiMessage,
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
// 关键点(中文):把本 step 的 assistant UI 消息并入运行时上下文,保证后续全量重算不丢历史。
|
|
608
|
+
messageState.appendRuntimeSessionMessage(stepAssistantUiMessage);
|
|
609
|
+
|
|
610
|
+
if (loopDecision.continueForToolCalls) {
|
|
611
|
+
textOnlyContinuationCount = 0;
|
|
612
|
+
incompleteResponseRecoveryCount = 0;
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
if (loopDecision.continueForTextOnly) {
|
|
617
|
+
textOnlyContinuationCount += 1;
|
|
618
|
+
incompleteResponseRecoveryCount = 0;
|
|
619
|
+
const continuationMessage = this.historyStore.userText({
|
|
620
|
+
text: buildTextOnlyContinuationNudge(textOnlyContinuationCount),
|
|
621
|
+
metadata: {
|
|
622
|
+
sessionId,
|
|
623
|
+
extra: {
|
|
624
|
+
internal: "agent_loop_auto_continue",
|
|
625
|
+
reason: textOnlyContinuationReason,
|
|
626
|
+
stepIndex: stepCount,
|
|
627
|
+
},
|
|
628
|
+
},
|
|
629
|
+
});
|
|
630
|
+
await messageState.appendUserTextMessage(continuationMessage);
|
|
631
|
+
continue;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// 关键点(中文):stop 前做 tail merge,覆盖最后一个 step 后才入队的新 user 消息。
|
|
635
|
+
const tailPrepared = await prepareStep({ messages: [] });
|
|
636
|
+
const tailMergedMessageCount = Array.isArray(tailPrepared.messages)
|
|
637
|
+
? tailPrepared.messages.length
|
|
638
|
+
: 0;
|
|
639
|
+
if (
|
|
640
|
+
shouldContinueForTailMergedUserMessages({
|
|
641
|
+
mergedUserMessageCount: tailMergedMessageCount,
|
|
642
|
+
})
|
|
643
|
+
) {
|
|
644
|
+
textOnlyContinuationCount = 0;
|
|
645
|
+
incompleteResponseRecoveryCount = 0;
|
|
646
|
+
await this.logger.log("info", "[agent] loop.tail_merge_continue", {
|
|
647
|
+
sessionId,
|
|
648
|
+
stepIndex: stepCount,
|
|
649
|
+
mergedUserMessageCount: tailMergedMessageCount,
|
|
650
|
+
});
|
|
651
|
+
continue;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
break;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
if (stepCount >= MAX_TOOL_LOOP_STEPS) {
|
|
658
|
+
await this.logger.log("warn", "[agent] loop.max_steps_reached", {
|
|
659
|
+
sessionId,
|
|
660
|
+
stepCount,
|
|
661
|
+
totalToolCallCount,
|
|
662
|
+
totalToolResultCount,
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
const finalMessage =
|
|
667
|
+
finalAssistantUiMessage ||
|
|
668
|
+
this.contextComposer.buildFallbackAssistantMessage("Execution completed");
|
|
669
|
+
|
|
670
|
+
await this.logger.log("info", "[agent] final.message", {
|
|
671
|
+
sessionId,
|
|
672
|
+
...summarizeUiMessageForDebug(finalMessage),
|
|
673
|
+
});
|
|
674
|
+
await logAssistantMessageNow(this.logger, finalMessage);
|
|
675
|
+
|
|
676
|
+
const duration = Date.now() - startTime;
|
|
677
|
+
await this.logger.log("info", "[agent] finish", {
|
|
678
|
+
sessionId,
|
|
679
|
+
duration,
|
|
680
|
+
stepCount,
|
|
681
|
+
totalToolCallCount,
|
|
682
|
+
totalToolResultCount,
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
return {
|
|
686
|
+
success: true,
|
|
687
|
+
assistantMessage: finalMessage,
|
|
688
|
+
};
|
|
689
|
+
} catch (error) {
|
|
690
|
+
if (this.compactionComposer.shouldCompactOnError(error)) {
|
|
691
|
+
throw error;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
const errorMsg = resolveEffectiveCoreEngineError({
|
|
695
|
+
error,
|
|
696
|
+
streamError: lastObservedStreamError,
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
await this.logger.log("error", "CoreEngine execution failed", {
|
|
700
|
+
error: errorMsg,
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
return {
|
|
704
|
+
success: false,
|
|
705
|
+
error: errorMsg,
|
|
706
|
+
assistantMessage: this.contextComposer.buildFallbackAssistantMessage(
|
|
707
|
+
`Execution failed: ${errorMsg}`,
|
|
708
|
+
),
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* 读取当前 session 模型。
|
|
715
|
+
*/
|
|
716
|
+
private resolveModelOrThrow(): LanguageModel {
|
|
717
|
+
const model = this.getModel();
|
|
718
|
+
if (!model) {
|
|
719
|
+
throw new Error(
|
|
720
|
+
`Executor for session "${this.sessionId}" requires a configured model`,
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
return model;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* 重置当前 run 级状态。
|
|
728
|
+
*/
|
|
729
|
+
private resetRunState(): void {
|
|
730
|
+
this.retryCount = 0;
|
|
731
|
+
}
|
|
311
732
|
}
|