@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
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Session Module
|
|
2
|
+
|
|
3
|
+
`session/` 是单 Agent 会话执行内核。它不直接面向普通 SDK 用户;普通用户通过 `sdk/Session.ts` 使用 `session.run()`、`session.stream()`、`session.history()` 等 API。
|
|
4
|
+
|
|
5
|
+
## 核心概念
|
|
6
|
+
|
|
7
|
+
- `Session`:用户/SDK 面向的完整会话对象,负责模型配置、历史入口、运行入口和分叉能力。
|
|
8
|
+
- `Executor`:单个 session 的一轮 run 执行引擎,负责并发锁、run scope、Composer 编排、压缩重试、assistant step 持久化和 tool-loop 调用。
|
|
9
|
+
- `Composer`:执行前的材料组装协议,只负责把原材料组装成某一阶段输入,不直接执行模型,也没有公共运行时基类。
|
|
10
|
+
- `HistoryStore`:历史事实源,负责 JSONL 读写、meta、archive、lock、compact 与消息工厂。
|
|
11
|
+
- `HistoryComposer`:历史组装策略,只负责把 `HistoryStore` 中的历史组装成本轮模型输入。
|
|
12
|
+
- `CoreEngine`:Executor 内部的模型/tool-loop 核心机制,负责模型流、tool calls、续写和最终 assistant message 合并。
|
|
13
|
+
|
|
14
|
+
## 一轮 run 的调用链
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
sdk/Session.run({ query })
|
|
18
|
+
-> append user message
|
|
19
|
+
-> session/Executor.run({ query })
|
|
20
|
+
-> ContextComposer.compose()
|
|
21
|
+
-> SystemComposer.resolve()
|
|
22
|
+
-> CompactionComposer.run()
|
|
23
|
+
-> HistoryComposer.prepare()
|
|
24
|
+
-> Executor.runCoreEngine()
|
|
25
|
+
-> ai.streamText({ model, system, messages, tools })
|
|
26
|
+
-> return assistantMessage
|
|
27
|
+
-> append final assistant message
|
|
28
|
+
-> return SDK result
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Composer 分工
|
|
32
|
+
|
|
33
|
+
- `composer/system/`:组装本轮 system messages,例如 instruction、service system、plugin system 和 session context。
|
|
34
|
+
- `composer/history/`:只组装本轮 model messages,不负责历史落盘。
|
|
35
|
+
- `composer/context/`:组装 tools、step hooks、fallback assistant message 等运行上下文。
|
|
36
|
+
- `composer/compaction/`:判断上下文错误和压缩历史,必要时写入 summary 与 archive。
|
|
37
|
+
|
|
38
|
+
## Composer 的代码实现方式
|
|
39
|
+
|
|
40
|
+
Composer 在代码里是 TypeScript `interface`,不是抽象基类。每个 Composer 只声明当前阶段需要的最小协议,实现类用 `implements` 接上。
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
export interface SessionSystemComposer {
|
|
44
|
+
readonly name: string;
|
|
45
|
+
resolve(): Promise<SystemModelMessage[]>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class DefaultSessionSystemComposer implements SessionSystemComposer {
|
|
49
|
+
readonly name = "prompt_system";
|
|
50
|
+
|
|
51
|
+
async resolve() {
|
|
52
|
+
// 关键点(中文):只组装 system messages,不执行模型、不写历史。
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
当前四类协议分别回答四个问题:
|
|
58
|
+
|
|
59
|
+
- `SessionSystemComposer.resolve()`:这一轮 system messages 是什么?
|
|
60
|
+
- `SessionHistoryComposer.prepare()`:这一轮喂给模型的 history messages 是什么?
|
|
61
|
+
- `SessionContextComposer.compose()`:这一轮有哪些 tools 与 step hooks?
|
|
62
|
+
- `SessionCompactionComposer.run()`:是否需要压缩,以及压缩策略是什么?
|
|
63
|
+
|
|
64
|
+
`Executor.prepareExecuteInput()` 是 Composer 的唯一主装配点:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
Executor.prepareExecuteInput()
|
|
68
|
+
-> ContextComposer.compose()
|
|
69
|
+
-> SystemComposer.resolve()
|
|
70
|
+
-> CompactionComposer.run(historyStore)
|
|
71
|
+
-> HistoryComposer.prepare()
|
|
72
|
+
-> SessionExecuteInput
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
边界规则:
|
|
76
|
+
|
|
77
|
+
- Composer 不调用模型,模型调用只发生在 `Executor.runCoreEngine()`。
|
|
78
|
+
- Composer 不持有历史事实,历史事实由 `HistoryStore` 负责。
|
|
79
|
+
- Composer 不管理 session 生命周期,生命周期由 `Session` / `Executor` 管理。
|
|
80
|
+
- Composer 可以读取上下文并做策略判断,但输出应该是“本轮执行材料”。
|
|
81
|
+
|
|
82
|
+
## 当前目录结构
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
session/
|
|
86
|
+
├── Executor.ts
|
|
87
|
+
├── SessionRunScope.ts
|
|
88
|
+
├── composer/
|
|
89
|
+
│ ├── compaction/
|
|
90
|
+
│ ├── context/
|
|
91
|
+
│ ├── history/
|
|
92
|
+
│ └── system/
|
|
93
|
+
├── core-engine/
|
|
94
|
+
│ ├── CoreEngineMessageState.ts
|
|
95
|
+
│ ├── CoreEngineLoopDecision.ts
|
|
96
|
+
│ ├── CoreEngineSignals.ts
|
|
97
|
+
│ ├── CoreEngineError.ts
|
|
98
|
+
│ └── CoreEngineUiStreamCollector.ts
|
|
99
|
+
├── store/
|
|
100
|
+
│ └── history/
|
|
101
|
+
│ ├── SessionHistoryStore.ts
|
|
102
|
+
│ └── jsonl/JsonlSessionHistoryStore.ts
|
|
103
|
+
├── ids/
|
|
104
|
+
├── messages/
|
|
105
|
+
├── tools/
|
|
106
|
+
└── types/
|
|
107
|
+
```
|
|
@@ -3,21 +3,20 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 负责“何时压缩 + 压缩策略参数”决策。
|
|
6
|
-
* - 具体读写由
|
|
6
|
+
* - 具体读写由 SessionHistoryStore 执行(CompactionComposer 不直接落盘)。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { LanguageModel, SystemModelMessage } from "ai";
|
|
10
|
-
import {
|
|
11
|
-
import type { SessionHistoryComposer } from "@session/composer/history/SessionHistoryComposer.js";
|
|
10
|
+
import type { SessionHistoryStore } from "@/session/store/history/SessionHistoryStore.js";
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* compaction Composer 执行输入。
|
|
15
14
|
*/
|
|
16
15
|
export type SessionCompactionInput = {
|
|
17
16
|
/**
|
|
18
|
-
* 当前会话 history
|
|
17
|
+
* 当前会话 history Store。
|
|
19
18
|
*/
|
|
20
|
-
|
|
19
|
+
historyStore: SessionHistoryStore;
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* 当前模型实例。
|
|
@@ -30,24 +29,24 @@ export type SessionCompactionInput = {
|
|
|
30
29
|
system: SystemModelMessage[];
|
|
31
30
|
|
|
32
31
|
/**
|
|
33
|
-
* 当前重试次数(由
|
|
32
|
+
* 当前重试次数(由 Executor 递增)。
|
|
34
33
|
*/
|
|
35
34
|
retryCount: number;
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
|
-
* Compaction Composer
|
|
38
|
+
* Compaction Composer 协议。
|
|
40
39
|
*/
|
|
41
|
-
export
|
|
40
|
+
export interface SessionCompactionComposer {
|
|
42
41
|
/**
|
|
43
42
|
* Composer 名(由具体实现声明)。
|
|
44
43
|
*/
|
|
45
|
-
|
|
44
|
+
readonly name: string;
|
|
46
45
|
|
|
47
46
|
/**
|
|
48
47
|
* 执行 compact(best-effort)。
|
|
49
48
|
*/
|
|
50
|
-
|
|
49
|
+
run(input: SessionCompactionInput): Promise<{
|
|
51
50
|
compacted: boolean;
|
|
52
51
|
reason?: string;
|
|
53
52
|
}>;
|
|
@@ -57,12 +56,7 @@ export abstract class SessionCompactionComposer extends SessionComposer {
|
|
|
57
56
|
*
|
|
58
57
|
* 关键点(中文)
|
|
59
58
|
* - 由 compaction Composer 实现侧维护错误识别策略。
|
|
60
|
-
* -
|
|
59
|
+
* - Executor 不感知具体错误文案,只按该布尔结果决定是否重试。
|
|
61
60
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* 可选初始化钩子。
|
|
66
|
-
*/
|
|
67
|
-
// 生命周期沿用 SessionComposer 默认实现。
|
|
61
|
+
shouldCompactOnError(error: unknown): boolean;
|
|
68
62
|
}
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 只负责压缩参数策略(retry 越多,窗口越紧)。
|
|
6
|
-
* - 真正的读写与 compact 执行交由 history
|
|
6
|
+
* - 真正的读写与 compact 执行交由 history Store。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {
|
|
10
|
-
|
|
9
|
+
import type {
|
|
10
|
+
SessionCompactionComposer,
|
|
11
|
+
SessionCompactionInput,
|
|
12
|
+
} from "@session/composer/compaction/SessionCompactionComposer.js";
|
|
11
13
|
|
|
12
14
|
type JsonlSessionCompactionComposerOptions = {
|
|
13
15
|
keepLastMessages?: number;
|
|
@@ -19,12 +21,11 @@ type JsonlSessionCompactionComposerOptions = {
|
|
|
19
21
|
/**
|
|
20
22
|
* JsonlSessionCompactionComposer 默认实现。
|
|
21
23
|
*/
|
|
22
|
-
export class JsonlSessionCompactionComposer
|
|
24
|
+
export class JsonlSessionCompactionComposer implements SessionCompactionComposer {
|
|
23
25
|
readonly name = "summary_compaction_composer";
|
|
24
26
|
private readonly options: JsonlSessionCompactionComposerOptions;
|
|
25
27
|
|
|
26
28
|
constructor(options?: JsonlSessionCompactionComposerOptions) {
|
|
27
|
-
super();
|
|
28
29
|
this.options = options || {};
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -71,7 +72,7 @@ export class JsonlSessionCompactionComposer extends SessionCompactionComposer {
|
|
|
71
72
|
reason?: string;
|
|
72
73
|
}> {
|
|
73
74
|
const policy = this.resolvePolicy(input.retryCount);
|
|
74
|
-
return await input.
|
|
75
|
+
return await input.historyStore.compact({
|
|
75
76
|
model: input.model,
|
|
76
77
|
system: input.system,
|
|
77
78
|
keepLastMessages: policy.keepLastMessages,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* LocalSessionContextComposer:本地 session 运行时编排 Composer 实现。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 统一组装 tools。
|
|
6
|
-
* - step 边界回调从 SessionRunScope 读取,
|
|
6
|
+
* - step 边界回调从 SessionRunScope 读取,Executor 不直接管理来源。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { ModelMessage } from "ai";
|
|
@@ -12,15 +12,15 @@ import {
|
|
|
12
12
|
drainInjectedUserMessages,
|
|
13
13
|
getSessionRunScope,
|
|
14
14
|
} from "@session/SessionRunScope.js";
|
|
15
|
-
import { SessionExecutionComposer } from "@session/composer/execution/SessionExecutionComposer.js";
|
|
16
15
|
import type {
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
SessionContextComposer,
|
|
17
|
+
SessionContextComposeResult,
|
|
18
|
+
} from "@session/composer/context/SessionContextComposer.js";
|
|
19
19
|
import type { SessionMessageV1 } from "@/session/types/SessionMessages.js";
|
|
20
20
|
import type { SessionSystemMessage } from "@/session/types/SessionPrompts.js";
|
|
21
21
|
import type { Tool } from "ai";
|
|
22
22
|
|
|
23
|
-
type
|
|
23
|
+
type LocalSessionContextComposerOptions = {
|
|
24
24
|
/**
|
|
25
25
|
* 可选默认 session id。
|
|
26
26
|
*/
|
|
@@ -33,26 +33,25 @@ type LocalSessionExecutionComposerOptions = {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* LocalSessionContextComposer 默认 Composer 实现。
|
|
37
37
|
*/
|
|
38
|
-
export class
|
|
39
|
-
readonly name = "
|
|
38
|
+
export class LocalSessionContextComposer implements SessionContextComposer {
|
|
39
|
+
readonly name = "runtime_context_composer";
|
|
40
40
|
private readonly sessionId: string;
|
|
41
|
-
private readonly getTools:
|
|
41
|
+
private readonly getTools: LocalSessionContextComposerOptions["getTools"];
|
|
42
42
|
|
|
43
|
-
constructor(options:
|
|
44
|
-
super();
|
|
43
|
+
constructor(options: LocalSessionContextComposerOptions) {
|
|
45
44
|
this.sessionId = String(options.sessionId || "").trim();
|
|
46
45
|
this.getTools = options.getTools;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
async compose(): Promise<
|
|
48
|
+
async compose(): Promise<SessionContextComposeResult> {
|
|
50
49
|
const tools = this.getTools();
|
|
51
50
|
const ctx = getSessionRunScope();
|
|
52
51
|
const sessionId = String(ctx?.sessionId || this.sessionId || "").trim();
|
|
53
52
|
if (!sessionId) {
|
|
54
53
|
throw new Error(
|
|
55
|
-
"
|
|
54
|
+
"LocalSessionContextComposer.compose requires a sessionId from sessionRunScope or options.sessionId",
|
|
56
55
|
);
|
|
57
56
|
}
|
|
58
57
|
// 关键点(中文):sessionId 统一回填到请求上下文,后续组件直接读取。
|
|
@@ -150,7 +149,7 @@ export class LocalSessionExecutionComposer extends SessionExecutionComposer {
|
|
|
150
149
|
const sessionId = String(ctx?.sessionId || this.sessionId || "").trim();
|
|
151
150
|
if (!sessionId) {
|
|
152
151
|
throw new Error(
|
|
153
|
-
"
|
|
152
|
+
"LocalSessionContextComposer.buildFallbackAssistantMessage requires a sessionId from sessionRunScope or options.sessionId",
|
|
154
153
|
);
|
|
155
154
|
}
|
|
156
155
|
return {
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* SessionContextComposer:单次 Session run context 组装协议。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* - 负责 tools/
|
|
5
|
+
* - 负责 tools / prepareStep / onStepFinish / fallback message factory 等运行上下文组装。
|
|
6
6
|
* - 不负责历史读写,不负责 system 解析,不负责 compact。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { ModelMessage, Tool } from "ai";
|
|
10
10
|
import type { SessionMessageV1 } from "@/session/types/SessionMessages.js";
|
|
11
11
|
import type { SessionSystemMessage } from "@/session/types/SessionPrompts.js";
|
|
12
|
-
import { SessionComposer } from "@session/composer/SessionComposer.js";
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
14
|
+
* 本轮运行上下文组装输出。
|
|
16
15
|
*/
|
|
17
|
-
export type
|
|
16
|
+
export type SessionContextComposeResult = {
|
|
18
17
|
/**
|
|
19
18
|
* 本轮工具集合。
|
|
20
19
|
*/
|
|
@@ -22,23 +21,23 @@ export type SessionExecutionComposeResult = {
|
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
|
-
*
|
|
24
|
+
* 运行上下文 Composer 协议。
|
|
26
25
|
*/
|
|
27
|
-
export
|
|
26
|
+
export interface SessionContextComposer {
|
|
28
27
|
/**
|
|
29
28
|
* Composer 名(由具体实现声明)。
|
|
30
29
|
*/
|
|
31
|
-
|
|
30
|
+
readonly name: string;
|
|
32
31
|
|
|
33
32
|
/**
|
|
34
|
-
* 组装一次 run
|
|
33
|
+
* 组装一次 run 所需上下文。
|
|
35
34
|
*/
|
|
36
|
-
|
|
35
|
+
compose(): Promise<SessionContextComposeResult>;
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
* 构造 prepareStep 回调。
|
|
40
39
|
*/
|
|
41
|
-
|
|
40
|
+
createPrepareStepHandler(
|
|
42
41
|
input: {
|
|
43
42
|
/**
|
|
44
43
|
* 当前轮 system 消息。
|
|
@@ -59,13 +58,13 @@ export abstract class SessionExecutionComposer extends SessionComposer {
|
|
|
59
58
|
/**
|
|
60
59
|
* 构造 onStepFinish 回调。
|
|
61
60
|
*/
|
|
62
|
-
|
|
61
|
+
createOnStepFinishHandler(): (stepResult: unknown) => Promise<void>;
|
|
63
62
|
|
|
64
63
|
/**
|
|
65
64
|
* 构造 fallback assistant 消息。
|
|
66
65
|
*
|
|
67
66
|
* 关键点(中文)
|
|
68
|
-
|
|
67
|
+
* - fallback 消息构造由 ContextComposer 内部实现,Executor 不直接依赖 history Composer。
|
|
69
68
|
*/
|
|
70
|
-
|
|
69
|
+
buildFallbackAssistantMessage(text: string): SessionMessageV1;
|
|
71
70
|
}
|
|
@@ -2,17 +2,14 @@
|
|
|
2
2
|
* SessionHistoryComposer:会话历史 Composer 抽象。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* -
|
|
5
|
+
* - 负责把历史事实源组装成本轮模型输入消息。
|
|
6
|
+
* - 不负责 append / list / meta / archive 等落盘能力。
|
|
6
7
|
* - 不负责模型调用,不负责执行编排。
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
import type { LanguageModel, Tool } from "ai";
|
|
10
|
-
import type {
|
|
11
|
-
SessionMessageV1,
|
|
12
|
-
SessionMetadataV1,
|
|
13
|
-
} from "@/session/types/SessionMessages.js";
|
|
11
|
+
import type { SessionMessageV1 } from "@/session/types/SessionMessages.js";
|
|
14
12
|
import type { SessionSystemMessage } from "@/session/types/SessionPrompts.js";
|
|
15
|
-
import { SessionComposer } from "@session/composer/SessionComposer.js";
|
|
16
13
|
|
|
17
14
|
/**
|
|
18
15
|
* prepare 输入参数。
|
|
@@ -39,156 +36,27 @@ export type SessionHistoryPrepareInput = {
|
|
|
39
36
|
model: LanguageModel;
|
|
40
37
|
|
|
41
38
|
/**
|
|
42
|
-
* 当前重试次数(由
|
|
39
|
+
* 当前重试次数(由 Executor 递增)。
|
|
43
40
|
*/
|
|
44
41
|
retryCount: number;
|
|
45
42
|
};
|
|
46
43
|
|
|
47
44
|
/**
|
|
48
|
-
*
|
|
45
|
+
* SessionHistoryComposer 协议。
|
|
49
46
|
*/
|
|
50
|
-
export
|
|
51
|
-
/**
|
|
52
|
-
* 当前模型实例。
|
|
53
|
-
*/
|
|
54
|
-
model: LanguageModel;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 当前轮 system messages。
|
|
58
|
-
*/
|
|
59
|
-
system: SessionSystemMessage[];
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 保留最近消息条数。
|
|
63
|
-
*/
|
|
64
|
-
keepLastMessages: number;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 输入 token 近似上限。
|
|
68
|
-
*/
|
|
69
|
-
maxInputTokensApprox: number;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* compact 时是否归档旧消息。
|
|
73
|
-
*/
|
|
74
|
-
archiveOnCompact: boolean;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 前段压缩比例(0-1)。
|
|
78
|
-
*
|
|
79
|
-
* 关键点(中文)
|
|
80
|
-
* - 例如 0.5 表示“优先压缩最早 50% 的 UIMessage”。
|
|
81
|
-
* - 具体切分由 history Composer 实现侧做边界校正。
|
|
82
|
-
*/
|
|
83
|
-
compactRatio: number;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* SessionHistoryComposer 抽象类。
|
|
88
|
-
*/
|
|
89
|
-
export abstract class SessionHistoryComposer extends SessionComposer {
|
|
47
|
+
export interface SessionHistoryComposer {
|
|
90
48
|
/**
|
|
91
49
|
* Composer 名(由具体实现声明)。
|
|
92
50
|
*/
|
|
93
|
-
|
|
51
|
+
readonly name: string;
|
|
94
52
|
|
|
95
53
|
/**
|
|
96
54
|
* 当前会话 ID。
|
|
97
55
|
*/
|
|
98
|
-
|
|
56
|
+
readonly sessionId: string;
|
|
99
57
|
|
|
100
58
|
/**
|
|
101
59
|
* 为本轮 Session 执行准备模型输入消息。
|
|
102
60
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 执行一次 compact(best-effort)。
|
|
107
|
-
*/
|
|
108
|
-
abstract compact(input: SessionHistoryCompactInput): Promise<{
|
|
109
|
-
compacted: boolean;
|
|
110
|
-
reason?: string;
|
|
111
|
-
}>;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* 追加一条消息到历史。
|
|
115
|
-
*/
|
|
116
|
-
abstract append(message: SessionMessageV1): Promise<void>;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* 读取完整消息历史。
|
|
120
|
-
*/
|
|
121
|
-
abstract list(): Promise<SessionMessageV1[]>;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* 读取消息区间 [start, end)。
|
|
125
|
-
*/
|
|
126
|
-
abstract slice(start: number, end: number): Promise<SessionMessageV1[]>;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* 读取消息总条数。
|
|
130
|
-
*/
|
|
131
|
-
abstract size(): Promise<number>;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* 读取元信息。
|
|
135
|
-
*/
|
|
136
|
-
abstract meta(): Promise<Record<string, unknown>>;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* 构造 user 文本消息。
|
|
140
|
-
*/
|
|
141
|
-
abstract userText(input: {
|
|
142
|
-
/**
|
|
143
|
-
* 用户文本内容。
|
|
144
|
-
*/
|
|
145
|
-
text: string;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* 消息元信息(除 schema 字段)。
|
|
149
|
-
*/
|
|
150
|
-
metadata: Omit<SessionMetadataV1, "v" | "ts"> &
|
|
151
|
-
Partial<Pick<SessionMetadataV1, "ts">>;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* 可选消息 ID(默认自动生成)。
|
|
155
|
-
*/
|
|
156
|
-
id?: string;
|
|
157
|
-
}): SessionMessageV1;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* 构造 assistant 文本消息。
|
|
161
|
-
*/
|
|
162
|
-
abstract assistantText(input: {
|
|
163
|
-
/**
|
|
164
|
-
* 助手文本内容。
|
|
165
|
-
*/
|
|
166
|
-
text: string;
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* 消息元信息(除 schema 字段)。
|
|
170
|
-
*/
|
|
171
|
-
metadata: Omit<SessionMetadataV1, "v" | "ts"> &
|
|
172
|
-
Partial<Pick<SessionMetadataV1, "ts">>;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* 可选消息 ID(默认自动生成)。
|
|
176
|
-
*/
|
|
177
|
-
id?: string;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* 消息种类(普通/摘要)。
|
|
181
|
-
*/
|
|
182
|
-
kind?: "normal" | "summary";
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* 消息来源(egress/compact)。
|
|
186
|
-
*/
|
|
187
|
-
source?: "egress" | "compact";
|
|
188
|
-
}): SessionMessageV1;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* 可选初始化钩子。
|
|
192
|
-
*/
|
|
193
|
-
// 生命周期沿用 SessionComposer 默认实现。
|
|
61
|
+
prepare(input: SessionHistoryPrepareInput): Promise<SessionMessageV1[]>;
|
|
194
62
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 只负责当前 session 的 user / assistant 消息补写。
|
|
6
|
-
* - 只依赖当前 session 的 history
|
|
6
|
+
* - 只依赖当前 session 的 history Store,不感知其他 session。
|
|
7
7
|
* - 会话更新后的通知也收在这里,避免把写入细节散到 Session 主类里。
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
SessionMessageV1,
|
|
13
13
|
SessionMetadataV1,
|
|
14
14
|
} from "@/session/types/SessionMessages.js";
|
|
15
|
-
import type {
|
|
15
|
+
import type { SessionHistoryStore } from "@/session/store/history/SessionHistoryStore.js";
|
|
16
16
|
|
|
17
17
|
type SessionHistoryWriterOptions = {
|
|
18
18
|
/**
|
|
@@ -21,9 +21,9 @@ type SessionHistoryWriterOptions = {
|
|
|
21
21
|
sessionId: string;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* 获取当前 session 对应的 history
|
|
24
|
+
* 获取当前 session 对应的 history Store。
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
getHistoryStore: () => SessionHistoryStore;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* session 更新后的异步回调。
|
|
@@ -36,12 +36,12 @@ type SessionHistoryWriterOptions = {
|
|
|
36
36
|
*/
|
|
37
37
|
export class SessionHistoryWriter {
|
|
38
38
|
private readonly sessionId: string;
|
|
39
|
-
private readonly
|
|
39
|
+
private readonly getHistoryStore: SessionHistoryWriterOptions["getHistoryStore"];
|
|
40
40
|
private readonly runAfterSessionUpdated?: SessionHistoryWriterOptions["runAfterSessionUpdated"];
|
|
41
41
|
|
|
42
42
|
constructor(options: SessionHistoryWriterOptions) {
|
|
43
43
|
this.sessionId = String(options.sessionId || "").trim();
|
|
44
|
-
this.
|
|
44
|
+
this.getHistoryStore = options.getHistoryStore;
|
|
45
45
|
this.runAfterSessionUpdated = options.runAfterSessionUpdated;
|
|
46
46
|
if (!this.sessionId) {
|
|
47
47
|
throw new Error("SessionHistoryWriter requires a non-empty sessionId");
|
|
@@ -69,9 +69,9 @@ export class SessionHistoryWriter {
|
|
|
69
69
|
extra?: JsonObject;
|
|
70
70
|
}): Promise<void> {
|
|
71
71
|
try {
|
|
72
|
-
const
|
|
72
|
+
const historyStore = this.getHistoryStore();
|
|
73
73
|
if (params.message && typeof params.message === "object") {
|
|
74
|
-
await
|
|
74
|
+
await historyStore.append(params.message);
|
|
75
75
|
void this.afterSessionUpdatedAsync();
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
@@ -79,14 +79,14 @@ export class SessionHistoryWriter {
|
|
|
79
79
|
const fallbackText = String(params.text || "").trim();
|
|
80
80
|
if (!fallbackText) return;
|
|
81
81
|
|
|
82
|
-
const message =
|
|
82
|
+
const message = historyStore.userText({
|
|
83
83
|
text: fallbackText,
|
|
84
84
|
metadata: {
|
|
85
85
|
sessionId: this.sessionId,
|
|
86
86
|
extra: params.extra,
|
|
87
87
|
} as Omit<SessionMetadataV1, "v" | "ts">,
|
|
88
88
|
});
|
|
89
|
-
await
|
|
89
|
+
await historyStore.append(message);
|
|
90
90
|
void this.afterSessionUpdatedAsync();
|
|
91
91
|
} catch {
|
|
92
92
|
// ignore
|
|
@@ -102,9 +102,9 @@ export class SessionHistoryWriter {
|
|
|
102
102
|
extra?: JsonObject;
|
|
103
103
|
}): Promise<void> {
|
|
104
104
|
try {
|
|
105
|
-
const
|
|
105
|
+
const historyStore = this.getHistoryStore();
|
|
106
106
|
if (params.message && typeof params.message === "object") {
|
|
107
|
-
await
|
|
107
|
+
await historyStore.append(params.message);
|
|
108
108
|
void this.afterSessionUpdatedAsync();
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
@@ -112,8 +112,8 @@ export class SessionHistoryWriter {
|
|
|
112
112
|
const fallbackText = String(params.fallbackText || "").trim();
|
|
113
113
|
if (!fallbackText) return;
|
|
114
114
|
|
|
115
|
-
await
|
|
116
|
-
|
|
115
|
+
await historyStore.append(
|
|
116
|
+
historyStore.assistantText({
|
|
117
117
|
text: fallbackText,
|
|
118
118
|
metadata: {
|
|
119
119
|
sessionId: this.sessionId,
|