@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,322 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JsonlSessionHistoryComposer:基于 JSONL 的
|
|
2
|
+
* JsonlSessionHistoryComposer:基于 JSONL store 的 history 组装器。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* -
|
|
6
|
-
* - append
|
|
7
|
-
* -
|
|
5
|
+
* - 只负责 `prepare()`,把 history store 中的消息组装成本轮模型输入。
|
|
6
|
+
* - 不负责 append / list / meta / compact 等落盘能力。
|
|
7
|
+
* - JSONL 文件事实源由 `JsonlSessionHistoryStore` 承担。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
readFile as readFileNative,
|
|
14
|
-
stat as statNative,
|
|
15
|
-
} from "node:fs/promises";
|
|
16
|
-
import path from "node:path";
|
|
17
|
-
import {
|
|
18
|
-
type Tool,
|
|
19
|
-
} from "ai";
|
|
20
|
-
import { generateId } from "@/utils/Id.js";
|
|
21
|
-
import { getLogger } from "@/utils/logger/Logger.js";
|
|
22
|
-
import { compactSessionMessagesIfNeeded } from "@session/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js";
|
|
10
|
+
import type { Tool } from "ai";
|
|
11
|
+
import type { SessionMessageV1 } from "@/session/types/SessionMessages.js";
|
|
12
|
+
import type { SessionHistoryStore } from "@/session/store/history/SessionHistoryStore.js";
|
|
23
13
|
import type {
|
|
24
|
-
SessionMessageV1,
|
|
25
|
-
SessionMetadataV1,
|
|
26
|
-
} from "@/session/types/SessionMessages.js";
|
|
27
|
-
import type { SessionSystemMessage } from "@/session/types/SessionPrompts.js";
|
|
28
|
-
import type { SessionHistoryMetaV1 } from "@/session/types/SessionHistoryMeta.js";
|
|
29
|
-
import type { SessionHistoryPathOverrides } from "@/session/types/SessionHistoryPaths.js";
|
|
30
|
-
import {
|
|
31
14
|
SessionHistoryComposer,
|
|
32
|
-
|
|
33
|
-
type SessionHistoryPrepareInput,
|
|
15
|
+
SessionHistoryPrepareInput,
|
|
34
16
|
} from "@session/composer/history/SessionHistoryComposer.js";
|
|
35
17
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
18
|
+
/**
|
|
19
|
+
* JSONL history composer 构造参数。
|
|
20
|
+
*/
|
|
21
|
+
export type JsonlSessionHistoryComposerOptions = {
|
|
22
|
+
/**
|
|
23
|
+
* 当前 history 事实源。
|
|
24
|
+
*/
|
|
25
|
+
store: SessionHistoryStore;
|
|
40
26
|
};
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return path.join(getDowncityDirPath(rootPath), "session");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function getDowncitySessionDirPath(rootPath: string, sessionId: string): string {
|
|
51
|
-
return path.join(
|
|
52
|
-
getDowncitySessionRootDirPath(rootPath),
|
|
53
|
-
encodeURIComponent(sessionId),
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function getDowncitySessionMessagesDirPath(
|
|
58
|
-
rootPath: string,
|
|
59
|
-
sessionId: string,
|
|
60
|
-
): string {
|
|
61
|
-
return path.join(getDowncitySessionDirPath(rootPath, sessionId), "messages");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export class JsonlSessionHistoryComposer extends SessionHistoryComposer {
|
|
65
|
-
readonly name = "jsonl_history_store";
|
|
28
|
+
/**
|
|
29
|
+
* JSONL history composer。
|
|
30
|
+
*/
|
|
31
|
+
export class JsonlSessionHistoryComposer implements SessionHistoryComposer {
|
|
32
|
+
readonly name = "jsonl_history_composer";
|
|
66
33
|
readonly sessionId: string;
|
|
67
34
|
|
|
68
|
-
private readonly
|
|
69
|
-
private readonly overrideSessionDirPath?: string;
|
|
70
|
-
private readonly overrideMessagesDirPath?: string;
|
|
71
|
-
private readonly overrideMessagesFilePath?: string;
|
|
72
|
-
private readonly overrideMetaFilePath?: string;
|
|
73
|
-
private readonly overrideArchiveDirPath?: string;
|
|
35
|
+
private readonly store: SessionHistoryStore;
|
|
74
36
|
|
|
75
37
|
constructor(options: JsonlSessionHistoryComposerOptions) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (!
|
|
79
|
-
throw new Error("JsonlSessionHistoryComposer requires a non-empty rootPath");
|
|
80
|
-
}
|
|
81
|
-
const sessionId = String(options.sessionId || "").trim();
|
|
82
|
-
if (!sessionId) {
|
|
38
|
+
this.store = options.store;
|
|
39
|
+
this.sessionId = String(options.store?.sessionId || "").trim();
|
|
40
|
+
if (!this.sessionId) {
|
|
83
41
|
throw new Error("JsonlSessionHistoryComposer requires a non-empty sessionId");
|
|
84
42
|
}
|
|
85
|
-
|
|
86
|
-
this.rootPath = rootPath;
|
|
87
|
-
this.sessionId = sessionId;
|
|
88
|
-
this.overrideSessionDirPath = this.readOptionalPath(
|
|
89
|
-
options.paths?.sessionDirPath,
|
|
90
|
-
);
|
|
91
|
-
this.overrideMessagesDirPath = this.readOptionalPath(
|
|
92
|
-
options.paths?.messagesDirPath,
|
|
93
|
-
);
|
|
94
|
-
this.overrideMessagesFilePath = this.readOptionalPath(
|
|
95
|
-
options.paths?.messagesFilePath,
|
|
96
|
-
);
|
|
97
|
-
this.overrideMetaFilePath = this.readOptionalPath(
|
|
98
|
-
options.paths?.metaFilePath,
|
|
99
|
-
);
|
|
100
|
-
this.overrideArchiveDirPath = this.readOptionalPath(
|
|
101
|
-
options.paths?.archiveDirPath,
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
private readOptionalPath(value: string | undefined): string | undefined {
|
|
106
|
-
const out = String(value || "").trim();
|
|
107
|
-
return out || undefined;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private getMessagesDirPath(): string {
|
|
111
|
-
if (this.overrideMessagesDirPath) return this.overrideMessagesDirPath;
|
|
112
|
-
if (this.overrideSessionDirPath) {
|
|
113
|
-
return path.join(this.overrideSessionDirPath, "messages");
|
|
114
|
-
}
|
|
115
|
-
return getDowncitySessionMessagesDirPath(this.rootPath, this.sessionId);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private getMessagesFilePath(): string {
|
|
119
|
-
if (this.overrideMessagesFilePath) return this.overrideMessagesFilePath;
|
|
120
|
-
if (this.overrideMessagesDirPath) {
|
|
121
|
-
return path.join(this.overrideMessagesDirPath, "messages.jsonl");
|
|
122
|
-
}
|
|
123
|
-
return path.join(this.getMessagesDirPath(), "messages.jsonl");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
private getMetaFilePath(): string {
|
|
127
|
-
if (this.overrideMetaFilePath) return this.overrideMetaFilePath;
|
|
128
|
-
if (this.overrideMessagesDirPath) {
|
|
129
|
-
return path.join(this.overrideMessagesDirPath, "meta.json");
|
|
130
|
-
}
|
|
131
|
-
return path.join(this.getMessagesDirPath(), "meta.json");
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
private getArchiveDirPath(): string {
|
|
135
|
-
if (this.overrideArchiveDirPath) return this.overrideArchiveDirPath;
|
|
136
|
-
if (this.overrideMessagesDirPath) {
|
|
137
|
-
return path.join(this.overrideMessagesDirPath, "archive");
|
|
138
|
-
}
|
|
139
|
-
return path.join(this.getMessagesDirPath(), "archive");
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
private getLockFilePath(): string {
|
|
143
|
-
return path.join(this.getMessagesDirPath(), ".session.lock");
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
private async ensureLayout(): Promise<void> {
|
|
147
|
-
// 关键点(中文):以 messages 目录为最小落盘单元,统一保证 messages/meta/archive 可写。
|
|
148
|
-
await fs.ensureDir(this.getMessagesDirPath());
|
|
149
|
-
await fs.ensureDir(this.getArchiveDirPath());
|
|
150
|
-
await fs.ensureFile(this.getMessagesFilePath());
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
private normalizePinnedSkillIds(input: string[] | undefined): string[] {
|
|
154
|
-
if (!Array.isArray(input)) return [];
|
|
155
|
-
const out: string[] = [];
|
|
156
|
-
for (const raw of input) {
|
|
157
|
-
const id = typeof raw === "string" ? raw.trim() : "";
|
|
158
|
-
if (!id) continue;
|
|
159
|
-
out.push(id);
|
|
160
|
-
}
|
|
161
|
-
return Array.from(new Set(out)).slice(0, 2000);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
private normalizeSdkConfig(
|
|
165
|
-
input: SessionHistoryMetaV1["sdkConfig"],
|
|
166
|
-
): SessionHistoryMetaV1["sdkConfig"] {
|
|
167
|
-
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
168
|
-
return undefined;
|
|
169
|
-
}
|
|
170
|
-
const modelLabel =
|
|
171
|
-
typeof input.modelLabel === "string" ? input.modelLabel.trim() : "";
|
|
172
|
-
if (!modelLabel) return undefined;
|
|
173
|
-
return {
|
|
174
|
-
modelLabel,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
private async readMetaUnsafe(): Promise<SessionHistoryMetaV1> {
|
|
179
|
-
const file = this.getMetaFilePath();
|
|
180
|
-
try {
|
|
181
|
-
const raw = (await fs.readJson(
|
|
182
|
-
file,
|
|
183
|
-
)) as Partial<SessionHistoryMetaV1> | null;
|
|
184
|
-
if (!raw || typeof raw !== "object") throw new Error("invalid_meta");
|
|
185
|
-
return {
|
|
186
|
-
v: 1,
|
|
187
|
-
sessionId: this.sessionId,
|
|
188
|
-
...(typeof raw.agentId === "string" && raw.agentId.trim()
|
|
189
|
-
? { agentId: raw.agentId.trim() }
|
|
190
|
-
: {}),
|
|
191
|
-
...(typeof raw.createdAt === "number" && Number.isFinite(raw.createdAt)
|
|
192
|
-
? { createdAt: raw.createdAt }
|
|
193
|
-
: {}),
|
|
194
|
-
updatedAt: typeof raw.updatedAt === "number" ? raw.updatedAt : 0,
|
|
195
|
-
pinnedSkillIds: this.normalizePinnedSkillIds(raw.pinnedSkillIds),
|
|
196
|
-
...(typeof raw.lastArchiveId === "string" && raw.lastArchiveId.trim()
|
|
197
|
-
? { lastArchiveId: raw.lastArchiveId.trim() }
|
|
198
|
-
: {}),
|
|
199
|
-
...(typeof raw.keepLastMessages === "number" &&
|
|
200
|
-
Number.isFinite(raw.keepLastMessages)
|
|
201
|
-
? { keepLastMessages: raw.keepLastMessages }
|
|
202
|
-
: {}),
|
|
203
|
-
...(typeof raw.maxInputTokensApprox === "number" &&
|
|
204
|
-
Number.isFinite(raw.maxInputTokensApprox)
|
|
205
|
-
? { maxInputTokensApprox: raw.maxInputTokensApprox }
|
|
206
|
-
: {}),
|
|
207
|
-
...(typeof raw.compactRatio === "number" &&
|
|
208
|
-
Number.isFinite(raw.compactRatio)
|
|
209
|
-
? { compactRatio: raw.compactRatio }
|
|
210
|
-
: {}),
|
|
211
|
-
...(this.normalizeSdkConfig(raw.sdkConfig)
|
|
212
|
-
? { sdkConfig: this.normalizeSdkConfig(raw.sdkConfig) }
|
|
213
|
-
: {}),
|
|
214
|
-
};
|
|
215
|
-
} catch {
|
|
216
|
-
return {
|
|
217
|
-
v: 1,
|
|
218
|
-
sessionId: this.sessionId,
|
|
219
|
-
createdAt: Date.now(),
|
|
220
|
-
updatedAt: 0,
|
|
221
|
-
pinnedSkillIds: [],
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
private async writeMetaUnsafe(
|
|
227
|
-
next: SessionHistoryMetaV1,
|
|
228
|
-
): Promise<void> {
|
|
229
|
-
const normalized: SessionHistoryMetaV1 = {
|
|
230
|
-
v: 1,
|
|
231
|
-
sessionId: this.sessionId,
|
|
232
|
-
...(typeof next.agentId === "string" && next.agentId.trim()
|
|
233
|
-
? { agentId: next.agentId.trim() }
|
|
234
|
-
: {}),
|
|
235
|
-
...(typeof next.createdAt === "number" && Number.isFinite(next.createdAt)
|
|
236
|
-
? { createdAt: next.createdAt }
|
|
237
|
-
: {}),
|
|
238
|
-
updatedAt:
|
|
239
|
-
typeof next.updatedAt === "number" ? next.updatedAt : Date.now(),
|
|
240
|
-
pinnedSkillIds: this.normalizePinnedSkillIds(next.pinnedSkillIds),
|
|
241
|
-
...(typeof next.lastArchiveId === "string" && next.lastArchiveId.trim()
|
|
242
|
-
? { lastArchiveId: next.lastArchiveId.trim() }
|
|
243
|
-
: {}),
|
|
244
|
-
...(typeof next.keepLastMessages === "number" &&
|
|
245
|
-
Number.isFinite(next.keepLastMessages)
|
|
246
|
-
? { keepLastMessages: next.keepLastMessages }
|
|
247
|
-
: {}),
|
|
248
|
-
...(typeof next.maxInputTokensApprox === "number" &&
|
|
249
|
-
Number.isFinite(next.maxInputTokensApprox)
|
|
250
|
-
? { maxInputTokensApprox: next.maxInputTokensApprox }
|
|
251
|
-
: {}),
|
|
252
|
-
...(typeof next.compactRatio === "number" &&
|
|
253
|
-
Number.isFinite(next.compactRatio)
|
|
254
|
-
? { compactRatio: next.compactRatio }
|
|
255
|
-
: {}),
|
|
256
|
-
...(this.normalizeSdkConfig(next.sdkConfig)
|
|
257
|
-
? { sdkConfig: this.normalizeSdkConfig(next.sdkConfig) }
|
|
258
|
-
: {}),
|
|
259
|
-
};
|
|
260
|
-
await fs.writeJson(this.getMetaFilePath(), normalized, { spaces: 2 });
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
private async withWriteLock<T>(fn: () => Promise<T>): Promise<T> {
|
|
264
|
-
await this.ensureLayout();
|
|
265
|
-
const lockPath = this.getLockFilePath();
|
|
266
|
-
const token = `${process.pid}:${Date.now()}:${generateId()}`;
|
|
267
|
-
const logger = getLogger(this.rootPath, "info");
|
|
268
|
-
|
|
269
|
-
// 关键点(中文):append 与 compact 共用同一把文件锁,防止 rewrite 覆盖 append。
|
|
270
|
-
const staleMs = 30_000;
|
|
271
|
-
const start = Date.now();
|
|
272
|
-
while (true) {
|
|
273
|
-
try {
|
|
274
|
-
const fh = await openFile(lockPath, "wx");
|
|
275
|
-
await fh.writeFile(token, "utf8");
|
|
276
|
-
await fh.close();
|
|
277
|
-
break;
|
|
278
|
-
} catch (error) {
|
|
279
|
-
const err = error as NodeJS.ErrnoException;
|
|
280
|
-
if (err.code !== "EEXIST") throw err;
|
|
281
|
-
try {
|
|
282
|
-
const stat = await statNative(lockPath);
|
|
283
|
-
const age = Date.now() - stat.mtimeMs;
|
|
284
|
-
if (age > staleMs) {
|
|
285
|
-
await fs.remove(lockPath);
|
|
286
|
-
await logger.log("warn", "Removed stale session lock", {
|
|
287
|
-
sessionId: this.sessionId,
|
|
288
|
-
lockPath,
|
|
289
|
-
ageMs: age,
|
|
290
|
-
});
|
|
291
|
-
continue;
|
|
292
|
-
}
|
|
293
|
-
} catch {
|
|
294
|
-
// ignore
|
|
295
|
-
}
|
|
296
|
-
if (Date.now() - start > staleMs * 2) {
|
|
297
|
-
throw new Error(`Context lock timeout: ${lockPath}`);
|
|
298
|
-
}
|
|
299
|
-
await new Promise((resolve) => setTimeout(resolve, 60));
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
try {
|
|
304
|
-
return await fn();
|
|
305
|
-
} finally {
|
|
306
|
-
try {
|
|
307
|
-
const current = await readFileNative(lockPath, "utf8");
|
|
308
|
-
if (String(current || "").trim() === token) {
|
|
309
|
-
await fs.remove(lockPath);
|
|
310
|
-
}
|
|
311
|
-
} catch {
|
|
312
|
-
// ignore
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
private normalizeSystem(system: SessionSystemMessage[]): SessionSystemMessage[] {
|
|
318
|
-
if (!Array.isArray(system)) return [];
|
|
319
|
-
return system.filter((item) => item && typeof item === "object");
|
|
320
43
|
}
|
|
321
44
|
|
|
322
45
|
private normalizeTools(tools: Record<string, Tool>): Record<string, Tool> {
|
|
@@ -371,54 +94,15 @@ export class JsonlSessionHistoryComposer extends SessionHistoryComposer {
|
|
|
371
94
|
.filter((message) => Array.isArray(message.parts) && message.parts.length > 0);
|
|
372
95
|
}
|
|
373
96
|
|
|
374
|
-
async compact(input: SessionHistoryCompactInput): Promise<{
|
|
375
|
-
compacted: boolean;
|
|
376
|
-
reason?: string;
|
|
377
|
-
}> {
|
|
378
|
-
return await compactSessionMessagesIfNeeded(
|
|
379
|
-
{
|
|
380
|
-
rootPath: this.rootPath,
|
|
381
|
-
sessionId: this.sessionId,
|
|
382
|
-
withWriteLock: (fn) => this.withWriteLock(fn),
|
|
383
|
-
loadAll: () => this.list(),
|
|
384
|
-
createSummaryMessage: ({ text, sourceRange }) => ({
|
|
385
|
-
id: `a:${this.sessionId}:${generateId()}`,
|
|
386
|
-
role: "assistant",
|
|
387
|
-
metadata: {
|
|
388
|
-
v: 1,
|
|
389
|
-
ts: Date.now(),
|
|
390
|
-
sessionId: this.sessionId,
|
|
391
|
-
source: "compact",
|
|
392
|
-
kind: "summary",
|
|
393
|
-
...(sourceRange ? { sourceRange } : {}),
|
|
394
|
-
},
|
|
395
|
-
parts: [{ type: "text", text: String(text ?? "") }],
|
|
396
|
-
}),
|
|
397
|
-
getArchiveDirPath: () => this.getArchiveDirPath(),
|
|
398
|
-
getMessagesFilePath: () => this.getMessagesFilePath(),
|
|
399
|
-
readMetaUnsafe: () => this.readMetaUnsafe(),
|
|
400
|
-
writeMetaUnsafe: (next) => this.writeMetaUnsafe(next),
|
|
401
|
-
},
|
|
402
|
-
{
|
|
403
|
-
model: input.model,
|
|
404
|
-
system: this.normalizeSystem(input.system),
|
|
405
|
-
keepLastMessages: input.keepLastMessages,
|
|
406
|
-
maxInputTokensApprox: input.maxInputTokensApprox,
|
|
407
|
-
archiveOnCompact: input.archiveOnCompact,
|
|
408
|
-
compactRatio: input.compactRatio,
|
|
409
|
-
},
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
97
|
async prepare(input: SessionHistoryPrepareInput): Promise<SessionMessageV1[]> {
|
|
414
98
|
const query = String(input.query || "").trim();
|
|
415
99
|
const tools = this.normalizeTools(input.tools);
|
|
416
100
|
void tools;
|
|
417
101
|
|
|
418
|
-
let baseMessages = this.sanitizeMessages(await this.list());
|
|
102
|
+
let baseMessages = this.sanitizeMessages(await this.store.list());
|
|
419
103
|
if ((!Array.isArray(baseMessages) || baseMessages.length === 0) && query) {
|
|
420
104
|
baseMessages = [
|
|
421
|
-
this.userText({
|
|
105
|
+
this.store.userText({
|
|
422
106
|
text: query,
|
|
423
107
|
metadata: {
|
|
424
108
|
sessionId: this.sessionId,
|
|
@@ -429,7 +113,7 @@ export class JsonlSessionHistoryComposer extends SessionHistoryComposer {
|
|
|
429
113
|
if (query && !this.hasTrailingUserQuery(baseMessages, query)) {
|
|
430
114
|
baseMessages = [
|
|
431
115
|
...baseMessages,
|
|
432
|
-
this.userText({
|
|
116
|
+
this.store.userText({
|
|
433
117
|
text: query,
|
|
434
118
|
metadata: {
|
|
435
119
|
sessionId: this.sessionId,
|
|
@@ -439,103 +123,4 @@ export class JsonlSessionHistoryComposer extends SessionHistoryComposer {
|
|
|
439
123
|
}
|
|
440
124
|
return baseMessages;
|
|
441
125
|
}
|
|
442
|
-
|
|
443
|
-
async append(message: SessionMessageV1): Promise<void> {
|
|
444
|
-
await this.withWriteLock(async () => {
|
|
445
|
-
await fs.appendFile(
|
|
446
|
-
this.getMessagesFilePath(),
|
|
447
|
-
JSON.stringify(message) + "\n",
|
|
448
|
-
"utf8",
|
|
449
|
-
);
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
async list(): Promise<SessionMessageV1[]> {
|
|
454
|
-
await this.ensureLayout();
|
|
455
|
-
const file = this.getMessagesFilePath();
|
|
456
|
-
const raw = await fs.readFile(file, "utf8");
|
|
457
|
-
const lines = raw.split("\n").filter(Boolean);
|
|
458
|
-
const out: SessionMessageV1[] = [];
|
|
459
|
-
for (const line of lines) {
|
|
460
|
-
try {
|
|
461
|
-
const obj = JSON.parse(line) as Partial<SessionMessageV1>;
|
|
462
|
-
if (!obj || typeof obj !== "object") continue;
|
|
463
|
-
const role = String(obj.role || "");
|
|
464
|
-
if (role !== "user" && role !== "assistant") continue;
|
|
465
|
-
if (!Array.isArray(obj.parts)) continue;
|
|
466
|
-
out.push(obj as SessionMessageV1);
|
|
467
|
-
} catch {
|
|
468
|
-
// ignore invalid lines
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
return out;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
async slice(start: number, end: number): Promise<SessionMessageV1[]> {
|
|
475
|
-
const msgs = await this.list();
|
|
476
|
-
const startIndex = Math.max(0, Math.floor(start));
|
|
477
|
-
const endIndex = Math.max(startIndex, Math.floor(end));
|
|
478
|
-
return msgs.slice(startIndex, endIndex);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
async size(): Promise<number> {
|
|
482
|
-
const msgs = await this.list();
|
|
483
|
-
return msgs.length;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
async meta(): Promise<Record<string, unknown>> {
|
|
487
|
-
await this.ensureLayout();
|
|
488
|
-
const metadata = await this.readMetaUnsafe();
|
|
489
|
-
return (
|
|
490
|
-
metadata && typeof metadata === "object" ? { ...metadata } : {}
|
|
491
|
-
) as Record<string, unknown>;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
userText(input: {
|
|
495
|
-
text: string;
|
|
496
|
-
metadata: Omit<SessionMetadataV1, "v" | "ts"> &
|
|
497
|
-
Partial<Pick<SessionMetadataV1, "ts">>;
|
|
498
|
-
id?: string;
|
|
499
|
-
}): SessionMessageV1 {
|
|
500
|
-
const { ts, ...metadata } = input.metadata;
|
|
501
|
-
const md: SessionMetadataV1 = {
|
|
502
|
-
v: 1,
|
|
503
|
-
ts: typeof ts === "number" ? ts : Date.now(),
|
|
504
|
-
...metadata,
|
|
505
|
-
source: "ingress",
|
|
506
|
-
kind: "normal",
|
|
507
|
-
};
|
|
508
|
-
const id = input.id || `u:${this.sessionId}:${generateId()}`;
|
|
509
|
-
return {
|
|
510
|
-
id,
|
|
511
|
-
role: "user",
|
|
512
|
-
metadata: md,
|
|
513
|
-
parts: [{ type: "text", text: String(input.text ?? "") }],
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
assistantText(input: {
|
|
518
|
-
text: string;
|
|
519
|
-
metadata: Omit<SessionMetadataV1, "v" | "ts"> &
|
|
520
|
-
Partial<Pick<SessionMetadataV1, "ts">>;
|
|
521
|
-
id?: string;
|
|
522
|
-
kind?: "normal" | "summary";
|
|
523
|
-
source?: "egress" | "compact";
|
|
524
|
-
}): SessionMessageV1 {
|
|
525
|
-
const { ts, ...metadata } = input.metadata;
|
|
526
|
-
const md: SessionMetadataV1 = {
|
|
527
|
-
v: 1,
|
|
528
|
-
ts: typeof ts === "number" ? ts : Date.now(),
|
|
529
|
-
...metadata,
|
|
530
|
-
source: input.source || "egress",
|
|
531
|
-
kind: input.kind || "normal",
|
|
532
|
-
};
|
|
533
|
-
const id = input.id || `a:${this.sessionId}:${generateId()}`;
|
|
534
|
-
return {
|
|
535
|
-
id,
|
|
536
|
-
role: "assistant",
|
|
537
|
-
metadata: md,
|
|
538
|
-
parts: [{ type: "text", text: String(input.text ?? "") }],
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
126
|
}
|
|
@@ -3,23 +3,22 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 专职负责“会话上下文 -> system messages”解析。
|
|
6
|
-
* - 与 tools / step 编排解耦,避免
|
|
6
|
+
* - 与 tools / step 编排解耦,避免 Executor 过载。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { SystemModelMessage } from "ai";
|
|
10
|
-
import { SessionComposer } from "@session/composer/SessionComposer.js";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
|
-
* Session system Composer
|
|
12
|
+
* Session system Composer 协议。
|
|
14
13
|
*/
|
|
15
|
-
export
|
|
14
|
+
export interface SessionSystemComposer {
|
|
16
15
|
/**
|
|
17
16
|
* 解析器名称(由具体实现声明)。
|
|
18
17
|
*/
|
|
19
|
-
|
|
18
|
+
readonly name: string;
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* 解析本轮 system messages。
|
|
23
22
|
*/
|
|
24
|
-
|
|
23
|
+
resolve(): Promise<SystemModelMessage[]>;
|
|
25
24
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - 具体“解析 / 加载 / 组装”下沉到 SystemDomain,保持类本身轻量。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import type {
|
|
10
10
|
SessionSystemComposer,
|
|
11
11
|
} from "@session/composer/system/SessionSystemComposer.js";
|
|
12
12
|
import { getSessionRunScope } from "@session/SessionRunScope.js";
|
|
@@ -41,7 +41,7 @@ type DefaultSessionSystemComposerOptions = {
|
|
|
41
41
|
/**
|
|
42
42
|
* SessionSystemComposer 默认实现。
|
|
43
43
|
*/
|
|
44
|
-
export class DefaultSessionSystemComposer
|
|
44
|
+
export class DefaultSessionSystemComposer implements SessionSystemComposer {
|
|
45
45
|
readonly name = "prompt_system";
|
|
46
46
|
|
|
47
47
|
private readonly projectRoot: string;
|
|
@@ -50,7 +50,6 @@ export class DefaultSessionSystemComposer extends SessionSystemComposer {
|
|
|
50
50
|
private readonly profile: SystemProfile;
|
|
51
51
|
|
|
52
52
|
constructor(options: DefaultSessionSystemComposerOptions) {
|
|
53
|
-
super();
|
|
54
53
|
const projectRoot = String(options.projectRoot || "").trim();
|
|
55
54
|
if (!projectRoot) {
|
|
56
55
|
throw new Error("DefaultSessionSystemComposer requires a non-empty projectRoot");
|
package/src/session/{executors/local/SessionExecutionError.ts → core-engine/CoreEngineError.ts}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* CoreEngine 执行错误归一化工具。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - AI SDK 的最终错误有时只是兜底包装,底层 provider 错误会先从 stream `onError` 暴露。
|
|
6
|
-
* -
|
|
6
|
+
* - Executor 内部 CoreEngine 流程只需要消费这里输出的日志字段与最终错误文本。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { JsonObject } from "@/types/common/Json.js";
|
|
@@ -28,7 +28,7 @@ export function summarizeStreamError(error: unknown): JsonObject {
|
|
|
28
28
|
/**
|
|
29
29
|
* 提取实际应返回给上层的错误文本。
|
|
30
30
|
*/
|
|
31
|
-
export function
|
|
31
|
+
export function resolveEffectiveCoreEngineError(params: {
|
|
32
32
|
/**
|
|
33
33
|
* 外层捕获到的执行错误。
|
|
34
34
|
*/
|
package/src/session/{executors/local/SessionLoopDecision.ts → core-engine/CoreEngineLoopDecision.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* CoreEngineLoopDecision:模型/tool-loop 核心循环的纯决策模块。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* - 把 “是否继续下一轮” 的分支优先级从
|
|
5
|
+
* - 把 “是否继续下一轮” 的分支优先级从 CoreEngine 主流程中拆出。
|
|
6
6
|
* - 保持纯函数,不依赖模型、持久化或 logger,便于直接测试。
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
} from "@/session/types/SessionLoop.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* 评估当前 step 完成后,
|
|
16
|
+
* 评估当前 step 完成后,tool-loop 是否应继续下一轮。
|
|
17
17
|
*
|
|
18
18
|
* 优先级(中文)
|
|
19
19
|
* 1. 不完整响应恢复
|
|
@@ -21,7 +21,7 @@ import type {
|
|
|
21
21
|
* 3. text-only 自动续跑
|
|
22
22
|
* 4. 停止
|
|
23
23
|
*/
|
|
24
|
-
export function
|
|
24
|
+
export function evaluateCoreEngineLoopDecision(
|
|
25
25
|
input: SessionLoopDecisionInput,
|
|
26
26
|
): SessionLoopDecision {
|
|
27
27
|
if (
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* CoreEngine 模型消息运行态。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* -
|
|
5
|
+
* - CoreEngine 同时维护 session 语义消息与模型消息。
|
|
6
6
|
* - 新增 user 消息可优先做增量转换,失败时再回退为全量重算。
|
|
7
7
|
* - assistant UI 消息只需要进入 session 语义基线;模型侧使用 SDK 返回的 response messages。
|
|
8
8
|
*/
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
} from "@session/messages/SessionMessageCodec.js";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* CoreEngine 单轮执行期间的消息基线。
|
|
19
19
|
*/
|
|
20
|
-
export class
|
|
20
|
+
export class CoreEngineMessageState {
|
|
21
21
|
/**
|
|
22
22
|
* 当前运行时 session 语义消息。
|
|
23
23
|
*/
|
|
@@ -64,11 +64,11 @@ export class SessionModelMessageState {
|
|
|
64
64
|
* 当前轮可用工具集合。
|
|
65
65
|
*/
|
|
66
66
|
tools: Record<string, Tool>;
|
|
67
|
-
}): Promise<
|
|
67
|
+
}): Promise<CoreEngineMessageState> {
|
|
68
68
|
const sessionMessages = Array.isArray(params.messages)
|
|
69
69
|
? [...params.messages]
|
|
70
70
|
: [];
|
|
71
|
-
return new
|
|
71
|
+
return new CoreEngineMessageState({
|
|
72
72
|
sessionMessages,
|
|
73
73
|
modelMessages: await toModelMessages(sessionMessages, params.tools),
|
|
74
74
|
tools: params.tools,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SessionLoopSignals:
|
|
2
|
+
* SessionLoopSignals:tool-loop 执行循环的信号判断与调试摘要工具。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 这里只放“如何判断继续执行 / 如何输出调试摘要”的纯函数。
|
|
6
|
-
* - 不放
|
|
7
|
-
* - 目标是让
|
|
6
|
+
* - 不放 tool-loop 主流程,避免执行内核被大量辅助细节淹没。
|
|
7
|
+
* - 目标是让 tool-loop 保持“只看主链路就能理解”的结构。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import {
|
|
@@ -15,7 +15,7 @@ import { getSessionRunScope } from "@session/SessionRunScope.js";
|
|
|
15
15
|
import {
|
|
16
16
|
summarizeUiMessageForDebug,
|
|
17
17
|
toInlinePreview,
|
|
18
|
-
} from "@session/
|
|
18
|
+
} from "@session/core-engine/CoreEngineSignals.js";
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* 收敛 UI stream 中的最终 assistant 消息。
|