@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
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runner:本地 Session 执行内核。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 这个类只做“流程编排”,不承载业务策略。
|
|
6
|
-
* - 业务策略由各 Composer 实现(ExecutionComposer / SystemComposer / HistoryComposer / CompactionComposer)。
|
|
7
|
-
* - 本文件追求“看注释即可理解执行路径”。
|
|
8
|
-
*
|
|
9
|
-
* 主流程(中文)
|
|
10
|
-
* 1) `run`:入口,做并发保护与状态初始化。
|
|
11
|
-
* 2) `runWithRetry`:做“可压缩错误”的重试。
|
|
12
|
-
* 3) `prepareExecuteInput`:从各组件装配 system / tools / messages。
|
|
13
|
-
* 4) `executePreparedRun`:执行 streamText tool-loop。
|
|
14
|
-
* 5) `collectFinalAssistantMessage`:收敛最终 assistant 消息。
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import type { LanguageModel } from "ai";
|
|
18
|
-
import type { Logger } from "@/utils/logger/Logger.js";
|
|
19
|
-
import { SessionCompactionComposer } from "@session/composer/compaction/SessionCompactionComposer.js";
|
|
20
|
-
import { SessionExecutionComposer } from "@session/composer/execution/SessionExecutionComposer.js";
|
|
21
|
-
import { SessionHistoryComposer } from "@session/composer/history/SessionHistoryComposer.js";
|
|
22
|
-
import { SessionSystemComposer } from "@session/composer/system/SessionSystemComposer.js";
|
|
23
|
-
import type {
|
|
24
|
-
SessionExecuteInput,
|
|
25
|
-
SessionRunResult,
|
|
26
|
-
SessionRunInput,
|
|
27
|
-
} from "@/session/types/SessionRun.js";
|
|
28
|
-
import { SessionToolLoopRunner } from "@session/executors/local/SessionToolLoopRunner.js";
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 可压缩错误的最大重试次数。
|
|
32
|
-
*/
|
|
33
|
-
const MAX_COMPACTION_RETRY_ATTEMPTS = 3;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Runner 构造参数。
|
|
37
|
-
*/
|
|
38
|
-
type RunnerOptions = {
|
|
39
|
-
/** 当前模型实例。 */
|
|
40
|
-
model: LanguageModel;
|
|
41
|
-
|
|
42
|
-
/** 统一日志器。 */
|
|
43
|
-
logger: Logger;
|
|
44
|
-
|
|
45
|
-
/** 当前会话历史存储。 */
|
|
46
|
-
historyComposer: SessionHistoryComposer;
|
|
47
|
-
|
|
48
|
-
/** 当前会话压缩组件。 */
|
|
49
|
-
compactionComposer: SessionCompactionComposer;
|
|
50
|
-
|
|
51
|
-
/** 当前轮运行编排 Composer。 */
|
|
52
|
-
executionComposer: SessionExecutionComposer;
|
|
53
|
-
|
|
54
|
-
/** 当前轮 system 解析器。 */
|
|
55
|
-
systemComposer: SessionSystemComposer;
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Runner 主类。
|
|
61
|
-
*/
|
|
62
|
-
export class Runner {
|
|
63
|
-
/** 模型实例:用于真正执行 streamText。 */
|
|
64
|
-
private readonly model: LanguageModel;
|
|
65
|
-
|
|
66
|
-
/** 日志实例:用于输出运行过程与错误。 */
|
|
67
|
-
private readonly logger: Logger;
|
|
68
|
-
|
|
69
|
-
/** 历史存储:用于读写会话消息。 */
|
|
70
|
-
private readonly historyComposer: SessionHistoryComposer;
|
|
71
|
-
|
|
72
|
-
/** 压缩 Composer:用于在上下文过长前执行 compact。 */
|
|
73
|
-
private readonly compactionComposer: SessionCompactionComposer;
|
|
74
|
-
|
|
75
|
-
/** 编排 Composer:用于提供 tools 与 step 回调。 */
|
|
76
|
-
private readonly executionComposer: SessionExecutionComposer;
|
|
77
|
-
|
|
78
|
-
/** system 解析器:用于解析 system messages。 */
|
|
79
|
-
private readonly systemComposer: SessionSystemComposer;
|
|
80
|
-
|
|
81
|
-
/** 运行互斥锁:防止同一个 Runner 实例并发 run。 */
|
|
82
|
-
private isRunning = false;
|
|
83
|
-
|
|
84
|
-
/** context-length 重试计数。 */
|
|
85
|
-
private retryCount = 0;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* 构造函数。
|
|
89
|
-
*/
|
|
90
|
-
constructor(options: RunnerOptions) {
|
|
91
|
-
// 注入模型。
|
|
92
|
-
this.model = options.model;
|
|
93
|
-
|
|
94
|
-
// 注入日志。
|
|
95
|
-
this.logger = options.logger;
|
|
96
|
-
|
|
97
|
-
// 注入 history Composer。
|
|
98
|
-
this.historyComposer = options.historyComposer;
|
|
99
|
-
|
|
100
|
-
// 注入 compaction Composer。
|
|
101
|
-
this.compactionComposer = options.compactionComposer;
|
|
102
|
-
|
|
103
|
-
// 注入 execution Composer。
|
|
104
|
-
this.executionComposer = options.executionComposer;
|
|
105
|
-
|
|
106
|
-
// 注入 system 解析器。
|
|
107
|
-
this.systemComposer = options.systemComposer;
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* 执行一次 Runner run。
|
|
113
|
-
*
|
|
114
|
-
* 关键点(中文)
|
|
115
|
-
* - 这里只做入口控制,不直接做模型调用。
|
|
116
|
-
* - 保证同实例串行运行,避免 `retryCount` 等状态串线。
|
|
117
|
-
*/
|
|
118
|
-
async run(input: SessionRunInput): Promise<SessionRunResult> {
|
|
119
|
-
// 如果当前实例已经在运行,则直接拒绝并发调用。
|
|
120
|
-
if (this.isRunning) {
|
|
121
|
-
throw new Error("Runner.run does not support concurrent execution");
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// 标记运行中。
|
|
125
|
-
this.isRunning = true;
|
|
126
|
-
|
|
127
|
-
// 每次新 run 先清理状态。
|
|
128
|
-
this.resetRunState();
|
|
129
|
-
|
|
130
|
-
try {
|
|
131
|
-
// 真正执行带重试的 run。
|
|
132
|
-
return await this.runWithRetry(input);
|
|
133
|
-
} finally {
|
|
134
|
-
// 无论成功失败都清理状态,避免污染下一轮。
|
|
135
|
-
this.resetRunState();
|
|
136
|
-
|
|
137
|
-
// 释放运行锁。
|
|
138
|
-
this.isRunning = false;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* 执行一次 Runner run(带可压缩错误重试)。
|
|
144
|
-
*
|
|
145
|
-
* 关键点(中文)
|
|
146
|
-
* - 正常:准备输入 -> 执行。
|
|
147
|
-
* - 异常:
|
|
148
|
-
* - 可压缩错误:压缩重试(是否可压缩由 compaction Composer 决定)。
|
|
149
|
-
* - 其他错误:返回失败消息。
|
|
150
|
-
*/
|
|
151
|
-
private async runWithRetry(input: SessionRunInput): Promise<SessionRunResult> {
|
|
152
|
-
try {
|
|
153
|
-
// 清理并规整 query,避免把 undefined / null 传入后续组件。
|
|
154
|
-
const query = String(input.query || "").trim();
|
|
155
|
-
|
|
156
|
-
// 组装本轮运行所需输入(system/messages/tools)。
|
|
157
|
-
const prepared = await this.prepareExecuteInput(query);
|
|
158
|
-
|
|
159
|
-
// 执行组装好的运行输入。
|
|
160
|
-
return await this.executePreparedRun(prepared);
|
|
161
|
-
} catch (error) {
|
|
162
|
-
// 是否应压缩重试由 compaction Composer 决策,Runner 只消费布尔结果。
|
|
163
|
-
if (this.compactionComposer.shouldCompactOnError(error)) {
|
|
164
|
-
// 记录压缩重试日志,便于观测问题频率。
|
|
165
|
-
await this.logger.log("info", "[agent] compacting", {
|
|
166
|
-
retryCount: this.retryCount,
|
|
167
|
-
error: String(error),
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
// 若未超过上限,则增加计数并递归重试。
|
|
171
|
-
if (this.retryCount < MAX_COMPACTION_RETRY_ATTEMPTS) {
|
|
172
|
-
this.retryCount += 1;
|
|
173
|
-
return this.runWithRetry(input);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// 达到上限后返回可读失败消息,避免死循环。
|
|
177
|
-
return {
|
|
178
|
-
success: false,
|
|
179
|
-
error: "Context length exceeded and retries failed. Please resend your question.",
|
|
180
|
-
assistantMessage: this.executionComposer.buildFallbackAssistantMessage(
|
|
181
|
-
"Context length exceeded and retries failed. Please resend your question.",
|
|
182
|
-
),
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// 非“可压缩错误”走统一失败返回。
|
|
187
|
-
const errorMsg = String(error);
|
|
188
|
-
|
|
189
|
-
// 记录错误日志。
|
|
190
|
-
await this.logger.log("error", "Runner execution failed", {
|
|
191
|
-
error: errorMsg,
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
// 返回失败 assistant 消息。
|
|
195
|
-
return {
|
|
196
|
-
success: false,
|
|
197
|
-
error: errorMsg,
|
|
198
|
-
assistantMessage: this.executionComposer.buildFallbackAssistantMessage(
|
|
199
|
-
`Execution failed: ${errorMsg}`,
|
|
200
|
-
),
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* 调用核心组件组装当前轮执行输入。
|
|
207
|
-
*
|
|
208
|
-
* 关键点(中文)
|
|
209
|
-
* - execution Composer 提供 tools 与运行上下文。
|
|
210
|
-
* - system 提供本轮 system messages。
|
|
211
|
-
* - compaction Composer 先尝试压缩,再由 history Composer 产出消息基线。
|
|
212
|
-
*/
|
|
213
|
-
private async prepareExecuteInput(query: string): Promise<SessionExecuteInput> {
|
|
214
|
-
// 基础安全检查:historyComposer 必须携带 sessionId。
|
|
215
|
-
if (!String(this.historyComposer.sessionId || "").trim()) {
|
|
216
|
-
throw new Error("Runner.run requires historyComposer.sessionId");
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// 让 execution Composer 组装运行上下文(例如 tools 与 request 作用域)。
|
|
220
|
-
const runContext = await this.executionComposer.compose();
|
|
221
|
-
|
|
222
|
-
// 拿到本轮工具集合。
|
|
223
|
-
const tools = runContext.tools;
|
|
224
|
-
|
|
225
|
-
// 解析本轮 system messages。
|
|
226
|
-
const baseSystem = await this.systemComposer.resolve();
|
|
227
|
-
const system = baseSystem;
|
|
228
|
-
|
|
229
|
-
try {
|
|
230
|
-
// 只有在重试场景下才记录额外 compacting 日志。
|
|
231
|
-
if (this.retryCount > 0) {
|
|
232
|
-
await this.logger.log("info", "[agent] compacting", {
|
|
233
|
-
retryCount: this.retryCount,
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// 尝试执行压缩(best-effort,失败不阻断主流程)。
|
|
238
|
-
await this.compactionComposer.run({
|
|
239
|
-
historyComposer: this.historyComposer,
|
|
240
|
-
model: this.model,
|
|
241
|
-
system,
|
|
242
|
-
retryCount: this.retryCount,
|
|
243
|
-
});
|
|
244
|
-
} catch {
|
|
245
|
-
// 压缩失败忽略,继续使用当前历史消息执行。
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// 让 history Composer 按当前 query/system/tools 生成消息基线。
|
|
249
|
-
const messages = await this.historyComposer.prepare({
|
|
250
|
-
query,
|
|
251
|
-
tools,
|
|
252
|
-
system,
|
|
253
|
-
model: this.model,
|
|
254
|
-
retryCount: this.retryCount,
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// 返回最终可执行输入。
|
|
258
|
-
return {
|
|
259
|
-
query,
|
|
260
|
-
system,
|
|
261
|
-
messages,
|
|
262
|
-
tools,
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* 执行一次已装配完成的运行材料。
|
|
268
|
-
*
|
|
269
|
-
* 关键点(中文)
|
|
270
|
-
* - 这里只关心执行,不关心 request / context 参数怎么来的。
|
|
271
|
-
* - 增量并入逻辑用来支持 step 间新增 user 消息。
|
|
272
|
-
*/
|
|
273
|
-
private async executePreparedRun(
|
|
274
|
-
input: SessionExecuteInput,
|
|
275
|
-
): Promise<SessionRunResult> {
|
|
276
|
-
const runner = new SessionToolLoopRunner({
|
|
277
|
-
model: this.model,
|
|
278
|
-
logger: this.logger,
|
|
279
|
-
historyComposer: this.historyComposer,
|
|
280
|
-
executionComposer: this.executionComposer,
|
|
281
|
-
shouldCompactOnError: (error) =>
|
|
282
|
-
this.compactionComposer.shouldCompactOnError(error),
|
|
283
|
-
});
|
|
284
|
-
return await runner.execute(input);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* 重置当前 run 状态。
|
|
289
|
-
*
|
|
290
|
-
* 关键点(中文)
|
|
291
|
-
* - 统一收口 run 级状态,避免散落在多个位置。
|
|
292
|
-
*/
|
|
293
|
-
private resetRunState(): void {
|
|
294
|
-
// 当前仅维护 retryCount,重置为 0。
|
|
295
|
-
this.retryCount = 0;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session tool-loop runner。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 这里只负责已准备好的 `SessionExecuteInput` 如何进入 `streamText` 循环。
|
|
6
|
-
* - Runner 保留入口、重试与输入准备职责,本模块负责 step 循环、续写、恢复和最终日志。
|
|
7
|
-
* - 运行过程中同时维护 UI assistant 消息、模型消息基线和 step 统计。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { streamText, type LanguageModel } from "ai";
|
|
11
|
-
import type { Logger } from "@/utils/logger/Logger.js";
|
|
12
|
-
import type {
|
|
13
|
-
SessionExecuteInput,
|
|
14
|
-
SessionRunResult,
|
|
15
|
-
} from "@/session/types/SessionRun.js";
|
|
16
|
-
import type { SessionMessageV1 } from "@/session/types/SessionMessages.js";
|
|
17
|
-
import { SessionHistoryComposer } from "@session/composer/history/SessionHistoryComposer.js";
|
|
18
|
-
import { SessionExecutionComposer } from "@session/composer/execution/SessionExecutionComposer.js";
|
|
19
|
-
import {
|
|
20
|
-
buildOpenAIResponsesProviderOptions,
|
|
21
|
-
} from "@session/messages/SessionMessageCodec.js";
|
|
22
|
-
import { logAssistantMessageNow } from "@session/messages/SessionMessageLog.js";
|
|
23
|
-
import {
|
|
24
|
-
MAX_INCOMPLETE_RESPONSE_RECOVERIES,
|
|
25
|
-
MAX_TEXT_ONLY_CONTINUATIONS,
|
|
26
|
-
MAX_TOOL_LOOP_STEPS,
|
|
27
|
-
buildIncompleteResponseRecoveryNudge,
|
|
28
|
-
buildTextOnlyContinuationNudge,
|
|
29
|
-
detectIncompleteResponse,
|
|
30
|
-
detectTextOnlyContinuationReason,
|
|
31
|
-
mergeAssistantUiMessages,
|
|
32
|
-
summarizeStepForDebug,
|
|
33
|
-
summarizeUiMessageForDebug,
|
|
34
|
-
toInlinePreview,
|
|
35
|
-
} from "@session/executors/local/SessionSignals.js";
|
|
36
|
-
import {
|
|
37
|
-
evaluateSessionLoopDecision,
|
|
38
|
-
shouldContinueForTailMergedUserMessages,
|
|
39
|
-
} from "@session/executors/local/SessionLoopDecision.js";
|
|
40
|
-
import {
|
|
41
|
-
resolveEffectiveExecutionError,
|
|
42
|
-
summarizeStreamError,
|
|
43
|
-
} from "@session/executors/local/SessionExecutionError.js";
|
|
44
|
-
import { collectFinalAssistantMessageFromUiStream } from "@session/executors/local/SessionUiStreamCollector.js";
|
|
45
|
-
import { SessionModelMessageState } from "@session/executors/local/SessionModelMessageState.js";
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* SessionToolLoopRunner 构造参数。
|
|
49
|
-
*/
|
|
50
|
-
export type SessionToolLoopRunnerOptions = {
|
|
51
|
-
/** 当前模型实例。 */
|
|
52
|
-
model: LanguageModel;
|
|
53
|
-
/** 统一日志器。 */
|
|
54
|
-
logger: Logger;
|
|
55
|
-
/** 当前会话历史存储。 */
|
|
56
|
-
historyComposer: SessionHistoryComposer;
|
|
57
|
-
/** 当前轮运行编排 Composer。 */
|
|
58
|
-
executionComposer: SessionExecutionComposer;
|
|
59
|
-
/** 判断错误是否应交给上层 compaction retry。 */
|
|
60
|
-
shouldCompactOnError: (error: unknown) => boolean;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 已准备输入的模型/tool-loop 执行器。
|
|
65
|
-
*/
|
|
66
|
-
export class SessionToolLoopRunner {
|
|
67
|
-
private readonly model: LanguageModel;
|
|
68
|
-
private readonly logger: Logger;
|
|
69
|
-
private readonly historyComposer: SessionHistoryComposer;
|
|
70
|
-
private readonly executionComposer: SessionExecutionComposer;
|
|
71
|
-
private readonly shouldCompactOnError: (error: unknown) => boolean;
|
|
72
|
-
|
|
73
|
-
constructor(options: SessionToolLoopRunnerOptions) {
|
|
74
|
-
this.model = options.model;
|
|
75
|
-
this.logger = options.logger;
|
|
76
|
-
this.historyComposer = options.historyComposer;
|
|
77
|
-
this.executionComposer = options.executionComposer;
|
|
78
|
-
this.shouldCompactOnError = options.shouldCompactOnError;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* 执行一次已装配完成的运行材料。
|
|
83
|
-
*/
|
|
84
|
-
async execute(input: SessionExecuteInput): Promise<SessionRunResult> {
|
|
85
|
-
const startTime = Date.now();
|
|
86
|
-
const sessionId = String(this.historyComposer.sessionId || "").trim();
|
|
87
|
-
const system = Array.isArray(input.system) ? input.system : [];
|
|
88
|
-
const tools = input.tools;
|
|
89
|
-
let lastObservedStreamError: unknown = undefined;
|
|
90
|
-
|
|
91
|
-
try {
|
|
92
|
-
const messageState = await SessionModelMessageState.create({
|
|
93
|
-
messages: input.messages,
|
|
94
|
-
tools,
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const appendMergedUserMessages = (messages: SessionMessageV1[]) =>
|
|
98
|
-
messageState.appendMergedUserMessages(messages);
|
|
99
|
-
|
|
100
|
-
const executionComposerOnStepFinish =
|
|
101
|
-
this.executionComposer.createOnStepFinishHandler();
|
|
102
|
-
let stepCount = 0;
|
|
103
|
-
let totalToolCallCount = 0;
|
|
104
|
-
let totalToolResultCount = 0;
|
|
105
|
-
const onStepFinish = async (stepResult: unknown): Promise<void> => {
|
|
106
|
-
stepCount += 1;
|
|
107
|
-
const summary = summarizeStepForDebug(stepResult);
|
|
108
|
-
totalToolCallCount +=
|
|
109
|
-
typeof summary.toolCallCount === "number" ? summary.toolCallCount : 0;
|
|
110
|
-
totalToolResultCount +=
|
|
111
|
-
typeof summary.toolResultCount === "number"
|
|
112
|
-
? summary.toolResultCount
|
|
113
|
-
: 0;
|
|
114
|
-
await this.logger.log("info", "[agent] step.finish", {
|
|
115
|
-
sessionId,
|
|
116
|
-
stepIndex: stepCount,
|
|
117
|
-
...summary,
|
|
118
|
-
});
|
|
119
|
-
await executionComposerOnStepFinish(stepResult);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const prepareStep = this.executionComposer.createPrepareStepHandler({
|
|
123
|
-
system,
|
|
124
|
-
appendMergedUserMessages,
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
let finalAssistantUiMessage: SessionMessageV1 | null = null;
|
|
128
|
-
let textOnlyContinuationCount = 0;
|
|
129
|
-
let incompleteResponseRecoveryCount = 0;
|
|
130
|
-
|
|
131
|
-
while (stepCount < MAX_TOOL_LOOP_STEPS) {
|
|
132
|
-
const result = streamText({
|
|
133
|
-
model: this.model,
|
|
134
|
-
system,
|
|
135
|
-
onStepFinish,
|
|
136
|
-
prepareStep,
|
|
137
|
-
messages: messageState.modelMessages,
|
|
138
|
-
tools,
|
|
139
|
-
providerOptions: buildOpenAIResponsesProviderOptions(),
|
|
140
|
-
onError: async ({ error }) => {
|
|
141
|
-
lastObservedStreamError = error;
|
|
142
|
-
await this.logger.log("error", "[agent] stream.error", {
|
|
143
|
-
sessionId,
|
|
144
|
-
...summarizeStreamError(error),
|
|
145
|
-
});
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
const stepAssistantUiMessage = await collectFinalAssistantMessageFromUiStream({
|
|
150
|
-
result,
|
|
151
|
-
sessionId,
|
|
152
|
-
logger: this.logger,
|
|
153
|
-
buildFallbackAssistantMessage: (text) =>
|
|
154
|
-
this.executionComposer.buildFallbackAssistantMessage(text),
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
const executedSteps = await result.steps;
|
|
158
|
-
const lastStep = executedSteps[executedSteps.length - 1];
|
|
159
|
-
if (!lastStep) break;
|
|
160
|
-
|
|
161
|
-
const incompleteResponse = detectIncompleteResponse({
|
|
162
|
-
stepResult: lastStep,
|
|
163
|
-
assistantMessage: stepAssistantUiMessage,
|
|
164
|
-
});
|
|
165
|
-
const textOnlyContinuationReason =
|
|
166
|
-
detectTextOnlyContinuationReason(lastStep);
|
|
167
|
-
const loopDecision = evaluateSessionLoopDecision({
|
|
168
|
-
hasIncompleteResponse: incompleteResponse !== null,
|
|
169
|
-
incompleteRecoveryCount: incompleteResponseRecoveryCount,
|
|
170
|
-
maxIncompleteRecoveries: MAX_INCOMPLETE_RESPONSE_RECOVERIES,
|
|
171
|
-
textOnlyContinuationReason,
|
|
172
|
-
textOnlyContinuationCount,
|
|
173
|
-
maxTextOnlyContinuations: MAX_TEXT_ONLY_CONTINUATIONS,
|
|
174
|
-
hasTools: Object.keys(tools).length > 0,
|
|
175
|
-
toolCallCount: lastStep.toolCalls.length,
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
await this.logger.log("info", "[agent] loop.decision", {
|
|
179
|
-
sessionId,
|
|
180
|
-
stepIndex: stepCount,
|
|
181
|
-
continueForToolCalls: loopDecision.continueForToolCalls,
|
|
182
|
-
continueForTextOnly: loopDecision.continueForTextOnly,
|
|
183
|
-
continueForIncompleteRecovery:
|
|
184
|
-
loopDecision.continueForIncompleteRecovery,
|
|
185
|
-
decisionKind: loopDecision.kind,
|
|
186
|
-
textOnlyContinuationReason,
|
|
187
|
-
textOnlyContinuationCount,
|
|
188
|
-
incompleteResponseReason: incompleteResponse?.reason ?? null,
|
|
189
|
-
incompleteResponseRecoveryCount,
|
|
190
|
-
toolCallCount: lastStep.toolCalls.length,
|
|
191
|
-
toolResultCount: lastStep.toolResults.length,
|
|
192
|
-
finishReason: lastStep.finishReason,
|
|
193
|
-
textPreview: toInlinePreview(lastStep.text),
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
if (loopDecision.continueForIncompleteRecovery && incompleteResponse) {
|
|
197
|
-
incompleteResponseRecoveryCount += 1;
|
|
198
|
-
await this.logger.log("warn", "[agent] incomplete_response.recover", {
|
|
199
|
-
sessionId,
|
|
200
|
-
stepIndex: stepCount,
|
|
201
|
-
recoveryCount: incompleteResponseRecoveryCount,
|
|
202
|
-
reason: incompleteResponse.reason,
|
|
203
|
-
...incompleteResponse.details,
|
|
204
|
-
});
|
|
205
|
-
const recoveryMessage = this.historyComposer.userText({
|
|
206
|
-
text: buildIncompleteResponseRecoveryNudge(
|
|
207
|
-
incompleteResponseRecoveryCount,
|
|
208
|
-
),
|
|
209
|
-
metadata: {
|
|
210
|
-
sessionId,
|
|
211
|
-
extra: {
|
|
212
|
-
internal: "agent_incomplete_response_recover",
|
|
213
|
-
reason: incompleteResponse.reason,
|
|
214
|
-
stepIndex: stepCount,
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
await messageState.appendUserTextMessage(recoveryMessage);
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (incompleteResponse) {
|
|
223
|
-
await this.logger.log("error", "[agent] incomplete_response", {
|
|
224
|
-
sessionId,
|
|
225
|
-
stepIndex: stepCount,
|
|
226
|
-
reason: incompleteResponse.reason,
|
|
227
|
-
recoveryCount: incompleteResponseRecoveryCount,
|
|
228
|
-
...incompleteResponse.details,
|
|
229
|
-
});
|
|
230
|
-
throw new Error(
|
|
231
|
-
`Agent received incomplete response (${incompleteResponse.reason})`,
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const responseMessages = Array.isArray(lastStep.response?.messages)
|
|
236
|
-
? lastStep.response.messages
|
|
237
|
-
: [];
|
|
238
|
-
messageState.appendModelMessages(responseMessages);
|
|
239
|
-
|
|
240
|
-
finalAssistantUiMessage = mergeAssistantUiMessages(
|
|
241
|
-
finalAssistantUiMessage,
|
|
242
|
-
stepAssistantUiMessage,
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
// 关键点(中文):把本 step 的 assistant UI 消息并入运行时上下文,保证后续全量重算不丢历史。
|
|
246
|
-
messageState.appendRuntimeSessionMessage(stepAssistantUiMessage);
|
|
247
|
-
|
|
248
|
-
if (loopDecision.continueForToolCalls) {
|
|
249
|
-
textOnlyContinuationCount = 0;
|
|
250
|
-
incompleteResponseRecoveryCount = 0;
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (loopDecision.continueForTextOnly) {
|
|
255
|
-
textOnlyContinuationCount += 1;
|
|
256
|
-
incompleteResponseRecoveryCount = 0;
|
|
257
|
-
const continuationMessage = this.historyComposer.userText({
|
|
258
|
-
text: buildTextOnlyContinuationNudge(textOnlyContinuationCount),
|
|
259
|
-
metadata: {
|
|
260
|
-
sessionId,
|
|
261
|
-
extra: {
|
|
262
|
-
internal: "agent_loop_auto_continue",
|
|
263
|
-
reason: textOnlyContinuationReason,
|
|
264
|
-
stepIndex: stepCount,
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
});
|
|
268
|
-
await messageState.appendUserTextMessage(continuationMessage);
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// 关键点(中文):stop 前做 tail merge,覆盖最后一个 step 后才入队的新 user 消息。
|
|
273
|
-
const tailPrepared = await prepareStep({ messages: [] });
|
|
274
|
-
const tailMergedMessageCount = Array.isArray(tailPrepared.messages)
|
|
275
|
-
? tailPrepared.messages.length
|
|
276
|
-
: 0;
|
|
277
|
-
if (
|
|
278
|
-
shouldContinueForTailMergedUserMessages({
|
|
279
|
-
mergedUserMessageCount: tailMergedMessageCount,
|
|
280
|
-
})
|
|
281
|
-
) {
|
|
282
|
-
textOnlyContinuationCount = 0;
|
|
283
|
-
incompleteResponseRecoveryCount = 0;
|
|
284
|
-
await this.logger.log("info", "[agent] loop.tail_merge_continue", {
|
|
285
|
-
sessionId,
|
|
286
|
-
stepIndex: stepCount,
|
|
287
|
-
mergedUserMessageCount: tailMergedMessageCount,
|
|
288
|
-
});
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (stepCount >= MAX_TOOL_LOOP_STEPS) {
|
|
296
|
-
await this.logger.log("warn", "[agent] loop.max_steps_reached", {
|
|
297
|
-
sessionId,
|
|
298
|
-
stepCount,
|
|
299
|
-
totalToolCallCount,
|
|
300
|
-
totalToolResultCount,
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const finalMessage =
|
|
305
|
-
finalAssistantUiMessage ||
|
|
306
|
-
this.executionComposer.buildFallbackAssistantMessage("Execution completed");
|
|
307
|
-
|
|
308
|
-
await this.logger.log("info", "[agent] final.message", {
|
|
309
|
-
sessionId,
|
|
310
|
-
...summarizeUiMessageForDebug(finalMessage),
|
|
311
|
-
});
|
|
312
|
-
await logAssistantMessageNow(this.logger, finalMessage);
|
|
313
|
-
|
|
314
|
-
const duration = Date.now() - startTime;
|
|
315
|
-
await this.logger.log("info", "[agent] finish", {
|
|
316
|
-
sessionId,
|
|
317
|
-
duration,
|
|
318
|
-
stepCount,
|
|
319
|
-
totalToolCallCount,
|
|
320
|
-
totalToolResultCount,
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
return {
|
|
324
|
-
success: true,
|
|
325
|
-
assistantMessage: finalMessage,
|
|
326
|
-
};
|
|
327
|
-
} catch (error) {
|
|
328
|
-
if (this.shouldCompactOnError(error)) {
|
|
329
|
-
throw error;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
const errorMsg = resolveEffectiveExecutionError({
|
|
333
|
-
error,
|
|
334
|
-
streamError: lastObservedStreamError,
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
await this.logger.log("error", "Runner execution failed", {
|
|
338
|
-
error: errorMsg,
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
return {
|
|
342
|
-
success: false,
|
|
343
|
-
error: errorMsg,
|
|
344
|
-
assistantMessage: this.executionComposer.buildFallbackAssistantMessage(
|
|
345
|
-
`Execution failed: ${errorMsg}`,
|
|
346
|
-
),
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|