@downcity/agent 1.1.15 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -635
- package/bin/{project → config/project}/AgentInitializer.d.ts +2 -2
- package/bin/config/project/AgentInitializer.d.ts.map +1 -0
- package/bin/{project → config/project}/AgentInitializer.js +7 -7
- package/bin/config/project/AgentInitializer.js.map +1 -0
- package/bin/{project → config/project}/types/AgentProject.d.ts +2 -2
- package/bin/config/project/types/AgentProject.d.ts.map +1 -0
- package/bin/config/project/types/AgentProject.js.map +1 -0
- package/bin/core/AgentContextTypes.d.ts +9 -71
- package/bin/core/AgentContextTypes.d.ts.map +1 -1
- package/bin/core/AgentCore.d.ts.map +1 -1
- package/bin/core/AgentCore.js +5 -2
- package/bin/core/AgentCore.js.map +1 -1
- package/bin/core/AgentCoreTypes.d.ts +1 -6
- package/bin/core/AgentCoreTypes.d.ts.map +1 -1
- package/bin/index.d.ts +22 -22
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +9 -10
- package/bin/index.js.map +1 -1
- package/bin/plugin/builtins/asr/Config.d.ts +1 -1
- package/bin/plugin/builtins/asr/Config.d.ts.map +1 -1
- package/bin/plugin/builtins/auth/runtime/AuthorizationPolicy.d.ts +1 -1
- package/bin/plugin/builtins/auth/runtime/AuthorizationPolicy.d.ts.map +1 -1
- package/bin/plugin/builtins/voice/Config.d.ts +1 -1
- package/bin/plugin/builtins/voice/Config.d.ts.map +1 -1
- package/bin/plugin/builtins/workboard/runtime/Collector.js +1 -1
- package/bin/plugin/builtins/workboard/runtime/Collector.js.map +1 -1
- package/bin/plugin/builtins/workboard/runtime/Normalizer.d.ts +1 -1
- package/bin/plugin/builtins/workboard/runtime/Normalizer.d.ts.map +1 -1
- package/bin/plugin/core/HttpRoutes.d.ts +1 -1
- package/bin/plugin/core/HttpRoutes.d.ts.map +1 -1
- package/bin/plugin/core/LocalExecution.js +1 -1
- package/bin/plugin/core/PluginManager.js +1 -1
- package/bin/plugin/types/Plugin.d.ts +2 -2
- package/bin/plugin/types/Plugin.d.ts.map +1 -1
- package/bin/{host/runtime → runtime/host}/AgentHostRuntime.d.ts +1 -1
- package/bin/{host/runtime → runtime/host}/AgentHostRuntime.d.ts.map +1 -1
- package/bin/{host/runtime → runtime/host}/AgentHostRuntime.js.map +1 -1
- package/bin/{host/runtime → runtime/host}/PluginRuntime.d.ts.map +1 -1
- package/bin/{host/runtime → runtime/host}/PluginRuntime.js.map +1 -1
- package/bin/{host → runtime/host}/daemon/Api.d.ts +1 -1
- package/bin/runtime/host/daemon/Api.d.ts.map +1 -0
- package/bin/runtime/host/daemon/Api.js.map +1 -0
- package/bin/runtime/host/daemon/Client.d.ts.map +1 -0
- package/bin/{host → runtime/host}/daemon/Client.js +2 -2
- package/bin/runtime/host/daemon/Client.js.map +1 -0
- package/bin/runtime/host/daemon/Paths.d.ts.map +1 -0
- package/bin/{host → runtime/host}/daemon/Paths.js +2 -2
- package/bin/runtime/host/daemon/Paths.js.map +1 -0
- package/bin/{host → runtime/host}/daemon/ProjectSetup.d.ts +1 -1
- package/bin/runtime/host/daemon/ProjectSetup.d.ts.map +1 -0
- package/bin/{host → runtime/host}/daemon/ProjectSetup.js +3 -3
- package/bin/runtime/host/daemon/ProjectSetup.js.map +1 -0
- package/bin/{sandbox → runtime/sandbox}/MacOsSeatbeltSandbox.d.ts +1 -1
- package/bin/runtime/sandbox/MacOsSeatbeltSandbox.d.ts.map +1 -0
- package/bin/runtime/sandbox/MacOsSeatbeltSandbox.js.map +1 -0
- package/bin/{sandbox → runtime/sandbox}/SandboxConfigResolver.d.ts +2 -2
- package/bin/runtime/sandbox/SandboxConfigResolver.d.ts.map +1 -0
- package/bin/runtime/sandbox/SandboxConfigResolver.js.map +1 -0
- package/bin/{sandbox → runtime/sandbox}/SandboxRunner.d.ts +2 -2
- package/bin/runtime/sandbox/SandboxRunner.d.ts.map +1 -0
- package/bin/{sandbox → runtime/sandbox}/SandboxRunner.js +2 -2
- package/bin/runtime/sandbox/SandboxRunner.js.map +1 -0
- package/bin/runtime/sandbox/types/Sandbox.d.ts.map +1 -0
- package/bin/runtime/sandbox/types/Sandbox.js.map +1 -0
- package/bin/{sandbox → runtime/sandbox}/types/SandboxRuntime.d.ts +2 -2
- package/bin/runtime/sandbox/types/SandboxRuntime.d.ts.map +1 -0
- package/bin/runtime/sandbox/types/SandboxRuntime.js.map +1 -0
- package/bin/{server → runtime/server}/http/Server.d.ts +3 -3
- package/bin/runtime/server/http/Server.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/Server.js +8 -8
- package/bin/runtime/server/http/Server.js.map +1 -0
- package/bin/runtime/server/http/auth/AuthEnv.d.ts.map +1 -0
- package/bin/runtime/server/http/auth/AuthEnv.js.map +1 -0
- package/bin/runtime/server/http/auth/AuthError.d.ts.map +1 -0
- package/bin/runtime/server/http/auth/AuthError.js.map +1 -0
- package/bin/runtime/server/http/auth/CliAuthStateStore.d.ts.map +1 -0
- package/bin/runtime/server/http/auth/CliAuthStateStore.js.map +1 -0
- package/bin/runtime/server/http/auth/PasswordHasher.d.ts.map +1 -0
- package/bin/runtime/server/http/auth/PasswordHasher.js.map +1 -0
- package/bin/runtime/server/http/auth/TokenService.d.ts.map +1 -0
- package/bin/runtime/server/http/auth/TokenService.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/AuthControlService.d.ts +3 -3
- package/bin/runtime/server/http/control/AuthControlService.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/AuthControlService.js +1 -1
- package/bin/runtime/server/http/control/AuthControlService.js.map +1 -0
- package/bin/runtime/server/http/control/CommonHelpers.d.ts.map +1 -0
- package/bin/runtime/server/http/control/CommonHelpers.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlApiRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/ControlApiRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlApiRoutes.js +5 -5
- package/bin/runtime/server/http/control/ControlApiRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlAuthorizationRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/ControlAuthorizationRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlAuthorizationRoutes.js +3 -3
- package/bin/runtime/server/http/control/ControlAuthorizationRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlRouter.d.ts +2 -2
- package/bin/runtime/server/http/control/ControlRouter.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ControlRouter.js +1 -1
- package/bin/runtime/server/http/control/ControlRouter.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ExecuteBySession.d.ts +4 -4
- package/bin/runtime/server/http/control/ExecuteBySession.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ExecuteBySession.js +6 -6
- package/bin/runtime/server/http/control/ExecuteBySession.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ExecuteInput.d.ts +1 -1
- package/bin/runtime/server/http/control/ExecuteInput.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ExecuteInput.js +2 -2
- package/bin/runtime/server/http/control/ExecuteInput.js.map +1 -0
- package/bin/runtime/server/http/control/Helpers.d.ts.map +1 -0
- package/bin/runtime/server/http/control/Helpers.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/MessageTimeline.d.ts +2 -2
- package/bin/runtime/server/http/control/MessageTimeline.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/MessageTimeline.js +2 -2
- package/bin/runtime/server/http/control/MessageTimeline.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/ModelRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/ModelRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/ModelRoutes.js +2 -2
- package/bin/runtime/server/http/control/ModelRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/OverviewRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/OverviewRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/OverviewRoutes.js +2 -2
- package/bin/runtime/server/http/control/OverviewRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/SessionRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/SessionRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/SessionRoutes.js +2 -2
- package/bin/runtime/server/http/control/SessionRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/SessionSummaryStore.d.ts +2 -2
- package/bin/runtime/server/http/control/SessionSummaryStore.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/SessionSummaryStore.js +2 -2
- package/bin/runtime/server/http/control/SessionSummaryStore.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/TaskRoutes.d.ts +1 -1
- package/bin/runtime/server/http/control/TaskRoutes.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/TaskRoutes.js +4 -4
- package/bin/runtime/server/http/control/TaskRoutes.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/TaskStore.d.ts +1 -1
- package/bin/runtime/server/http/control/TaskStore.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/control/TaskStore.js +2 -2
- package/bin/runtime/server/http/control/TaskStore.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/types/AuthControl.d.ts +1 -1
- package/bin/runtime/server/http/control/types/AuthControl.d.ts.map +1 -0
- package/bin/runtime/server/http/control/types/AuthControl.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/types/ControlRoutes.d.ts +2 -2
- package/bin/runtime/server/http/control/types/ControlRoutes.d.ts.map +1 -0
- package/bin/runtime/server/http/control/types/ControlRoutes.js.map +1 -0
- package/bin/runtime/server/http/control/types/ControlSessionExecute.d.ts.map +1 -0
- package/bin/runtime/server/http/control/types/ControlSessionExecute.js.map +1 -0
- package/bin/{server → runtime/server}/http/control/types/ControlViewData.d.ts +1 -1
- package/bin/runtime/server/http/control/types/ControlViewData.d.ts.map +1 -0
- package/bin/runtime/server/http/control/types/ControlViewData.js.map +1 -0
- package/bin/{server → runtime/server}/http/execute/execute.d.ts +1 -1
- package/bin/runtime/server/http/execute/execute.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/execute/execute.js +2 -2
- package/bin/runtime/server/http/execute/execute.js.map +1 -0
- package/bin/runtime/server/http/health/health.d.ts.map +1 -0
- package/bin/runtime/server/http/health/health.js.map +1 -0
- package/bin/{server → runtime/server}/http/plugins/plugins.d.ts +1 -1
- package/bin/runtime/server/http/plugins/plugins.d.ts.map +1 -0
- package/bin/runtime/server/http/plugins/plugins.js.map +1 -0
- package/bin/{server → runtime/server}/http/services/services.d.ts +1 -1
- package/bin/runtime/server/http/services/services.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/services/services.js +2 -2
- package/bin/runtime/server/http/services/services.js.map +1 -0
- package/bin/{server → runtime/server}/http/static/static.d.ts +1 -1
- package/bin/runtime/server/http/static/static.d.ts.map +1 -0
- package/bin/{server → runtime/server}/http/static/static.js +1 -1
- package/bin/runtime/server/http/static/static.js.map +1 -0
- package/bin/{server → runtime/server}/rpc/Server.d.ts +4 -4
- package/bin/runtime/server/rpc/Server.d.ts.map +1 -0
- package/bin/{server → runtime/server}/rpc/Server.js +5 -5
- package/bin/runtime/server/rpc/Server.js.map +1 -0
- package/bin/{transport → runtime/transport}/rpc/Client.d.ts +1 -1
- package/bin/runtime/transport/rpc/Client.d.ts.map +1 -0
- package/bin/runtime/transport/rpc/Client.js.map +1 -0
- package/bin/runtime/transport/rpc/Paths.d.ts.map +1 -0
- package/bin/runtime/transport/rpc/Paths.js.map +1 -0
- package/bin/{transport → runtime/transport}/rpc/Transport.d.ts +1 -1
- package/bin/runtime/transport/rpc/Transport.d.ts.map +1 -0
- package/bin/{transport → runtime/transport}/rpc/Transport.js +1 -1
- package/bin/runtime/transport/rpc/Transport.js.map +1 -0
- package/bin/sdk/Agent.js +2 -2
- package/bin/sdk/Agent.js.map +1 -1
- package/bin/sdk/AgentSdkTypes.d.ts +3 -3
- package/bin/sdk/AgentSdkTypes.d.ts.map +1 -1
- package/bin/sdk/Session.d.ts +2 -1
- package/bin/sdk/Session.d.ts.map +1 -1
- package/bin/sdk/Session.js +13 -7
- package/bin/sdk/Session.js.map +1 -1
- package/bin/sdk/SessionSystemBuilder.d.ts +2 -2
- package/bin/sdk/SessionSystemBuilder.d.ts.map +1 -1
- package/bin/sdk/SessionSystemBuilder.js +1 -3
- package/bin/sdk/SessionSystemBuilder.js.map +1 -1
- package/bin/sdk/session/ServicePort.d.ts +3 -2
- package/bin/sdk/session/ServicePort.d.ts.map +1 -1
- package/bin/sdk/session/ServicePort.js +1 -1
- package/bin/sdk/session/ServicePort.js.map +1 -1
- package/bin/service/builtins/chat/ChatService.d.ts +1 -1
- package/bin/service/builtins/chat/ChatService.d.ts.map +1 -1
- package/bin/service/builtins/chat/ChatServiceTypes.d.ts +1 -1
- package/bin/service/builtins/chat/ChatServiceTypes.d.ts.map +1 -1
- package/bin/service/builtins/chat/accounts/ChannelAccountService.d.ts +1 -1
- package/bin/service/builtins/chat/accounts/ChannelAccountService.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelConfig.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelConfig.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts +1 -1
- package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatSession.d.ts +10 -5
- package/bin/service/builtins/chat/runtime/ChatSession.d.ts.map +1 -1
- package/bin/service/builtins/chat/runtime/ChatSession.js +6 -5
- package/bin/service/builtins/chat/runtime/ChatSession.js.map +1 -1
- package/bin/service/builtins/chat/runtime/{ChatSessionExecutionComposer.d.ts → ChatSessionContextComposer.d.ts} +7 -7
- package/bin/service/builtins/chat/runtime/ChatSessionContextComposer.d.ts.map +1 -0
- package/bin/service/builtins/chat/runtime/{ChatSessionExecutionComposer.js → ChatSessionContextComposer.js} +5 -5
- package/bin/service/builtins/chat/runtime/ChatSessionContextComposer.js.map +1 -0
- package/bin/service/builtins/chat/types/ChannelAccount.d.ts +1 -1
- package/bin/service/builtins/chat/types/ChannelAccount.d.ts.map +1 -1
- package/bin/service/builtins/memory/runtime/Flush.js +3 -3
- package/bin/service/builtins/memory/runtime/Flush.js.map +1 -1
- package/bin/service/builtins/shell/runtime/ShellActionRuntime.js +1 -1
- package/bin/service/builtins/shell/runtime/ShellActionRuntime.js.map +1 -1
- package/bin/service/builtins/shell/runtime/ShellRuntimeEnvironment.js +1 -1
- package/bin/service/builtins/shell/runtime/ShellRuntimeEnvironment.js.map +1 -1
- package/bin/service/builtins/task/runtime/Runner.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/Runner.js +5 -0
- package/bin/service/builtins/task/runtime/Runner.js.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerRound.js +2 -2
- package/bin/service/builtins/task/runtime/TaskRunnerRound.js.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerSession.d.ts +7 -4
- package/bin/service/builtins/task/runtime/TaskRunnerSession.d.ts.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerSession.js +39 -24
- package/bin/service/builtins/task/runtime/TaskRunnerSession.js.map +1 -1
- package/bin/service/builtins/task/runtime/TaskRunnerTypes.d.ts +4 -4
- package/bin/service/builtins/task/runtime/TaskRunnerTypes.d.ts.map +1 -1
- package/bin/session/Executor.d.ts +50 -17
- package/bin/session/Executor.d.ts.map +1 -1
- package/bin/session/Executor.js +366 -44
- package/bin/session/Executor.js.map +1 -1
- package/bin/session/composer/compaction/SessionCompactionComposer.d.ts +11 -12
- package/bin/session/composer/compaction/SessionCompactionComposer.d.ts.map +1 -1
- package/bin/session/composer/compaction/SessionCompactionComposer.js +2 -7
- package/bin/session/composer/compaction/SessionCompactionComposer.js.map +1 -1
- package/bin/session/composer/compaction/jsonl/JsonlSessionCompactionComposer.d.ts +3 -4
- package/bin/session/composer/compaction/jsonl/JsonlSessionCompactionComposer.d.ts.map +1 -1
- package/bin/session/composer/compaction/jsonl/JsonlSessionCompactionComposer.js +3 -5
- package/bin/session/composer/compaction/jsonl/JsonlSessionCompactionComposer.js.map +1 -1
- package/bin/session/composer/{execution/LocalSessionExecutionComposer.d.ts → context/LocalSessionContextComposer.d.ts} +10 -11
- package/bin/session/composer/context/LocalSessionContextComposer.d.ts.map +1 -0
- package/bin/session/composer/{execution/LocalSessionExecutionComposer.js → context/LocalSessionContextComposer.js} +8 -10
- package/bin/session/composer/context/LocalSessionContextComposer.js.map +1 -0
- package/bin/session/composer/{execution/SessionExecutionComposer.d.ts → context/SessionContextComposer.d.ts} +14 -15
- package/bin/session/composer/context/SessionContextComposer.d.ts.map +1 -0
- package/bin/session/composer/context/SessionContextComposer.js +9 -0
- package/bin/session/composer/context/SessionContextComposer.js.map +1 -0
- package/bin/session/composer/history/SessionHistoryComposer.d.ts +9 -111
- package/bin/session/composer/history/SessionHistoryComposer.d.ts.map +1 -1
- package/bin/session/composer/history/SessionHistoryComposer.js +3 -7
- package/bin/session/composer/history/SessionHistoryComposer.js.map +1 -1
- package/bin/session/composer/history/SessionHistoryWriter.d.ts +5 -5
- package/bin/session/composer/history/SessionHistoryWriter.d.ts.map +1 -1
- package/bin/session/composer/history/SessionHistoryWriter.js +10 -10
- package/bin/session/composer/history/SessionHistoryWriter.js.map +1 -1
- package/bin/session/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts +21 -54
- package/bin/session/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts.map +1 -1
- package/bin/session/composer/history/jsonl/JsonlSessionHistoryComposer.js +16 -367
- package/bin/session/composer/history/jsonl/JsonlSessionHistoryComposer.js.map +1 -1
- package/bin/session/composer/system/SessionSystemComposer.d.ts +5 -6
- package/bin/session/composer/system/SessionSystemComposer.d.ts.map +1 -1
- package/bin/session/composer/system/SessionSystemComposer.js +2 -7
- package/bin/session/composer/system/SessionSystemComposer.js.map +1 -1
- package/bin/session/composer/system/default/DefaultSessionSystemComposer.d.ts +2 -2
- package/bin/session/composer/system/default/DefaultSessionSystemComposer.d.ts.map +1 -1
- package/bin/session/composer/system/default/DefaultSessionSystemComposer.js +1 -3
- package/bin/session/composer/system/default/DefaultSessionSystemComposer.js.map +1 -1
- package/bin/session/{executors/local/SessionExecutionError.d.ts → core-engine/CoreEngineError.d.ts} +5 -5
- package/bin/session/core-engine/CoreEngineError.d.ts.map +1 -0
- package/bin/session/{executors/local/SessionExecutionError.js → core-engine/CoreEngineError.js} +4 -4
- package/bin/session/core-engine/CoreEngineError.js.map +1 -0
- package/bin/session/{executors/local/SessionLoopDecision.d.ts → core-engine/CoreEngineLoopDecision.d.ts} +6 -6
- package/bin/session/core-engine/CoreEngineLoopDecision.d.ts.map +1 -0
- package/bin/session/{executors/local/SessionLoopDecision.js → core-engine/CoreEngineLoopDecision.js} +5 -5
- package/bin/session/core-engine/CoreEngineLoopDecision.js.map +1 -0
- package/bin/session/{executors/local/SessionModelMessageState.d.ts → core-engine/CoreEngineMessageState.d.ts} +7 -7
- package/bin/session/core-engine/CoreEngineMessageState.d.ts.map +1 -0
- package/bin/session/{executors/local/SessionModelMessageState.js → core-engine/CoreEngineMessageState.js} +7 -7
- package/bin/session/core-engine/CoreEngineMessageState.js.map +1 -0
- package/bin/session/{executors/local/SessionSignals.d.ts → core-engine/CoreEngineSignals.d.ts} +6 -6
- package/bin/session/core-engine/CoreEngineSignals.d.ts.map +1 -0
- package/bin/session/{executors/local/SessionSignals.js → core-engine/CoreEngineSignals.js} +4 -4
- package/bin/session/core-engine/CoreEngineSignals.js.map +1 -0
- package/bin/session/{executors/local/SessionUiStreamCollector.d.ts → core-engine/CoreEngineUiStreamCollector.d.ts} +3 -3
- package/bin/session/core-engine/CoreEngineUiStreamCollector.d.ts.map +1 -0
- package/bin/session/{executors/local/SessionUiStreamCollector.js → core-engine/CoreEngineUiStreamCollector.js} +3 -3
- package/bin/session/core-engine/CoreEngineUiStreamCollector.js.map +1 -0
- package/bin/session/store/history/SessionHistoryStore.d.ts +119 -0
- package/bin/session/store/history/SessionHistoryStore.d.ts.map +1 -0
- package/bin/session/store/history/SessionHistoryStore.js +10 -0
- package/bin/session/store/history/SessionHistoryStore.js.map +1 -0
- package/bin/session/store/history/jsonl/JsonlSessionHistoryStore.d.ts +76 -0
- package/bin/session/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -0
- package/bin/session/store/history/jsonl/JsonlSessionHistoryStore.js +374 -0
- package/bin/session/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -0
- package/bin/session/tools/shell/ShellToolFormatting.js +1 -1
- package/bin/session/tools/shell/ShellToolFormatting.js.map +1 -1
- package/bin/session/types/SessionHistoryPaths.d.ts +2 -2
- package/bin/session/types/SessionLoop.d.ts +1 -1
- package/bin/session/types/SessionLoop.js +1 -1
- package/bin/session/types/SessionMessages.d.ts +1 -1
- package/bin/session/types/SessionMessages.js +1 -1
- package/bin/session/types/SessionRun.d.ts +2 -2
- package/bin/session/types/SessionRun.js +1 -1
- package/bin/types/config/DowncityConfig.d.ts +4 -3
- package/bin/types/config/DowncityConfig.d.ts.map +1 -1
- package/bin/types/runtime/auth/AuthPermission.d.ts.map +1 -0
- package/bin/types/runtime/auth/AuthPermission.js.map +1 -0
- package/bin/types/runtime/auth/AuthRoute.d.ts.map +1 -0
- package/bin/types/runtime/auth/AuthRoute.js.map +1 -0
- package/bin/types/runtime/auth/AuthToken.d.ts.map +1 -0
- package/bin/types/runtime/auth/AuthToken.js.map +1 -0
- package/bin/types/runtime/auth/AuthTypes.d.ts.map +1 -0
- package/bin/types/runtime/auth/AuthTypes.js.map +1 -0
- package/bin/types/runtime/daemon/Daemon.d.ts.map +1 -0
- package/bin/types/runtime/daemon/Daemon.js.map +1 -0
- package/bin/types/{host → runtime/host}/AgentHost.d.ts +7 -7
- package/bin/types/runtime/host/AgentHost.d.ts.map +1 -0
- package/bin/types/runtime/host/AgentHost.js.map +1 -0
- package/bin/types/{host → runtime/host}/Store.d.ts +1 -1
- package/bin/types/runtime/host/Store.d.ts.map +1 -0
- package/bin/types/runtime/host/Store.js.map +1 -0
- package/bin/types/runtime/http/InlineInstant.d.ts.map +1 -0
- package/bin/types/runtime/http/InlineInstant.js.map +1 -0
- package/bin/types/runtime/platform/Platform.d.ts.map +1 -0
- package/bin/types/runtime/platform/Platform.js.map +1 -0
- package/bin/types/runtime/platform/PlatformGateway.d.ts.map +1 -0
- package/bin/types/runtime/platform/PlatformGateway.js.map +1 -0
- package/bin/types/{rpc → runtime/rpc}/LocalRpc.d.ts +2 -2
- package/bin/types/runtime/rpc/LocalRpc.d.ts.map +1 -0
- package/bin/types/runtime/rpc/LocalRpc.js.map +1 -0
- package/bin/utils/logger/FormatRequest.js +1 -1
- package/bin/utils/logger/FormatRequest.js.map +1 -1
- package/package.json +1 -1
- package/src/{project → config/project}/AgentInitializer.ts +2 -2
- package/src/core/AgentContextTypes.ts +9 -74
- package/src/core/AgentCore.ts +6 -3
- package/src/core/AgentCoreTypes.ts +1 -6
- package/src/index.ts +26 -23
- package/src/plugin/builtins/asr/Config.ts +1 -1
- package/src/plugin/builtins/auth/runtime/AuthorizationPolicy.ts +1 -1
- package/src/plugin/builtins/voice/Config.ts +1 -1
- package/src/plugin/builtins/workboard/runtime/Collector.ts +1 -1
- package/src/plugin/builtins/workboard/runtime/Normalizer.ts +1 -1
- package/src/plugin/core/HttpRoutes.ts +1 -1
- package/src/plugin/core/LocalExecution.ts +2 -2
- package/src/plugin/core/PluginManager.ts +1 -1
- package/src/plugin/types/Plugin.ts +2 -2
- package/src/{host/runtime → runtime/host}/AgentHostRuntime.ts +1 -1
- package/src/{host → runtime/host}/daemon/Client.ts +2 -2
- package/src/{host → runtime/host}/daemon/Paths.ts +1 -1
- package/src/{host → runtime/host}/daemon/ProjectSetup.ts +1 -1
- package/src/{sandbox → runtime/sandbox}/MacOsSeatbeltSandbox.ts +1 -1
- package/src/{sandbox → runtime/sandbox}/SandboxConfigResolver.ts +1 -1
- package/src/{sandbox → runtime/sandbox}/SandboxRunner.ts +3 -3
- package/src/{sandbox → runtime/sandbox}/types/SandboxRuntime.ts +2 -2
- package/src/{server → runtime/server}/http/Server.ts +6 -6
- package/src/{server → runtime/server}/http/control/AuthControlService.ts +1 -1
- package/src/{server → runtime/server}/http/control/ControlApiRoutes.ts +6 -6
- package/src/{server → runtime/server}/http/control/ControlAuthorizationRoutes.ts +2 -2
- package/src/{server → runtime/server}/http/control/ControlRouter.ts +1 -1
- package/src/{server → runtime/server}/http/control/ExecuteBySession.ts +1 -1
- package/src/{server → runtime/server}/http/control/ExecuteInput.ts +1 -1
- package/src/{server → runtime/server}/http/control/MessageTimeline.ts +1 -1
- package/src/{server → runtime/server}/http/control/ModelRoutes.ts +2 -2
- package/src/{server → runtime/server}/http/control/OverviewRoutes.ts +1 -1
- package/src/{server → runtime/server}/http/control/SessionRoutes.ts +2 -2
- package/src/{server → runtime/server}/http/control/SessionSummaryStore.ts +1 -1
- package/src/{server → runtime/server}/http/control/TaskRoutes.ts +1 -1
- package/src/{server → runtime/server}/http/control/TaskStore.ts +1 -1
- package/src/{server → runtime/server}/rpc/Server.ts +4 -4
- package/src/{transport → runtime/transport}/rpc/Client.ts +2 -2
- package/src/{transport → runtime/transport}/rpc/Transport.ts +2 -2
- package/src/sdk/Agent.ts +2 -2
- package/src/sdk/AgentSdkTypes.ts +3 -3
- package/src/sdk/Session.ts +13 -7
- package/src/sdk/SessionSystemBuilder.ts +2 -3
- package/src/sdk/session/ServicePort.ts +4 -3
- package/src/service/builtins/chat/ChatService.ts +1 -1
- package/src/service/builtins/chat/ChatServiceTypes.ts +1 -1
- package/src/service/builtins/chat/accounts/ChannelAccountService.ts +2 -2
- package/src/service/builtins/chat/runtime/ChatChannelConfig.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatChannelCore.ts +1 -1
- package/src/service/builtins/chat/runtime/ChatSession.ts +15 -8
- package/src/service/builtins/chat/runtime/{ChatSessionExecutionComposer.ts → ChatSessionContextComposer.ts} +7 -7
- package/src/service/builtins/chat/types/ChannelAccount.ts +1 -1
- package/src/service/builtins/memory/runtime/Flush.ts +3 -3
- package/src/service/builtins/shell/runtime/ShellActionRuntime.ts +1 -1
- package/src/service/builtins/shell/runtime/ShellRuntimeEnvironment.ts +1 -1
- package/src/service/builtins/task/runtime/Runner.ts +7 -0
- package/src/service/builtins/task/runtime/TaskRunnerRound.ts +2 -2
- package/src/service/builtins/task/runtime/TaskRunnerSession.ts +48 -25
- package/src/service/builtins/task/runtime/TaskRunnerTypes.ts +4 -4
- package/src/session/Executor.ts +473 -52
- package/src/session/README.md +107 -0
- package/src/session/composer/compaction/SessionCompactionComposer.ts +11 -17
- package/src/session/composer/compaction/jsonl/JsonlSessionCompactionComposer.ts +7 -6
- package/src/session/composer/{execution/LocalSessionExecutionComposer.ts → context/LocalSessionContextComposer.ts} +14 -15
- package/src/session/composer/{execution/SessionExecutionComposer.ts → context/SessionContextComposer.ts} +13 -14
- package/src/session/composer/history/SessionHistoryComposer.ts +9 -141
- package/src/session/composer/history/SessionHistoryWriter.ts +14 -14
- package/src/session/composer/history/jsonl/JsonlSessionHistoryComposer.ts +28 -443
- package/src/session/composer/system/SessionSystemComposer.ts +5 -6
- package/src/session/composer/system/default/DefaultSessionSystemComposer.ts +2 -3
- package/src/session/{executors/local/SessionExecutionError.ts → core-engine/CoreEngineError.ts} +3 -3
- package/src/session/{executors/local/SessionLoopDecision.ts → core-engine/CoreEngineLoopDecision.ts} +4 -4
- package/src/session/{executors/local/SessionModelMessageState.ts → core-engine/CoreEngineMessageState.ts} +6 -6
- package/src/session/{executors/local/SessionSignals.ts → core-engine/CoreEngineSignals.ts} +3 -3
- package/src/session/{executors/local/SessionUiStreamCollector.ts → core-engine/CoreEngineUiStreamCollector.ts} +1 -1
- package/src/session/store/history/SessionHistoryStore.ts +145 -0
- package/src/session/store/history/jsonl/JsonlSessionHistoryStore.ts +465 -0
- package/src/session/tools/shell/ShellToolFormatting.ts +1 -1
- package/src/session/types/SessionHistoryPaths.ts +2 -2
- package/src/session/types/SessionLoop.ts +1 -1
- package/src/session/types/SessionMessages.ts +1 -1
- package/src/session/types/SessionRun.ts +2 -2
- package/src/types/config/DowncityConfig.ts +4 -3
- package/src/types/{host → runtime/host}/AgentHost.ts +3 -3
- package/src/types/{rpc → runtime/rpc}/LocalRpc.ts +1 -1
- package/src/utils/logger/FormatRequest.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/host/daemon/Api.d.ts.map +0 -1
- package/bin/host/daemon/Api.js.map +0 -1
- package/bin/host/daemon/Client.d.ts.map +0 -1
- package/bin/host/daemon/Client.js.map +0 -1
- package/bin/host/daemon/Paths.d.ts.map +0 -1
- package/bin/host/daemon/Paths.js.map +0 -1
- package/bin/host/daemon/ProjectSetup.d.ts.map +0 -1
- package/bin/host/daemon/ProjectSetup.js.map +0 -1
- package/bin/model/CreateModel.d.ts +0 -30
- package/bin/model/CreateModel.d.ts.map +0 -1
- package/bin/model/CreateModel.js +0 -311
- package/bin/model/CreateModel.js.map +0 -1
- package/bin/model/ModelManager.d.ts +0 -71
- package/bin/model/ModelManager.d.ts.map +0 -1
- package/bin/model/ModelManager.js +0 -187
- package/bin/model/ModelManager.js.map +0 -1
- package/bin/project/AgentInitializer.d.ts.map +0 -1
- package/bin/project/AgentInitializer.js.map +0 -1
- package/bin/project/types/AgentProject.d.ts.map +0 -1
- package/bin/project/types/AgentProject.js.map +0 -1
- package/bin/sandbox/MacOsSeatbeltSandbox.d.ts.map +0 -1
- package/bin/sandbox/MacOsSeatbeltSandbox.js.map +0 -1
- package/bin/sandbox/SandboxConfigResolver.d.ts.map +0 -1
- package/bin/sandbox/SandboxConfigResolver.js.map +0 -1
- package/bin/sandbox/SandboxRunner.d.ts.map +0 -1
- package/bin/sandbox/SandboxRunner.js.map +0 -1
- package/bin/sandbox/types/Sandbox.d.ts.map +0 -1
- package/bin/sandbox/types/Sandbox.js.map +0 -1
- package/bin/sandbox/types/SandboxRuntime.d.ts.map +0 -1
- package/bin/sandbox/types/SandboxRuntime.js.map +0 -1
- package/bin/server/http/Server.d.ts.map +0 -1
- package/bin/server/http/Server.js.map +0 -1
- package/bin/server/http/auth/AuthEnv.d.ts.map +0 -1
- package/bin/server/http/auth/AuthEnv.js.map +0 -1
- package/bin/server/http/auth/AuthError.d.ts.map +0 -1
- package/bin/server/http/auth/AuthError.js.map +0 -1
- package/bin/server/http/auth/CliAuthStateStore.d.ts.map +0 -1
- package/bin/server/http/auth/CliAuthStateStore.js.map +0 -1
- package/bin/server/http/auth/PasswordHasher.d.ts.map +0 -1
- package/bin/server/http/auth/PasswordHasher.js.map +0 -1
- package/bin/server/http/auth/TokenService.d.ts.map +0 -1
- package/bin/server/http/auth/TokenService.js.map +0 -1
- package/bin/server/http/control/AuthControlService.d.ts.map +0 -1
- package/bin/server/http/control/AuthControlService.js.map +0 -1
- package/bin/server/http/control/CommonHelpers.d.ts.map +0 -1
- package/bin/server/http/control/CommonHelpers.js.map +0 -1
- package/bin/server/http/control/ControlApiRoutes.d.ts.map +0 -1
- package/bin/server/http/control/ControlApiRoutes.js.map +0 -1
- package/bin/server/http/control/ControlAuthorizationRoutes.d.ts.map +0 -1
- package/bin/server/http/control/ControlAuthorizationRoutes.js.map +0 -1
- package/bin/server/http/control/ControlRouter.d.ts.map +0 -1
- package/bin/server/http/control/ControlRouter.js.map +0 -1
- package/bin/server/http/control/ExecuteBySession.d.ts.map +0 -1
- package/bin/server/http/control/ExecuteBySession.js.map +0 -1
- package/bin/server/http/control/ExecuteInput.d.ts.map +0 -1
- package/bin/server/http/control/ExecuteInput.js.map +0 -1
- package/bin/server/http/control/Helpers.d.ts.map +0 -1
- package/bin/server/http/control/Helpers.js.map +0 -1
- package/bin/server/http/control/MessageTimeline.d.ts.map +0 -1
- package/bin/server/http/control/MessageTimeline.js.map +0 -1
- package/bin/server/http/control/ModelRoutes.d.ts.map +0 -1
- package/bin/server/http/control/ModelRoutes.js.map +0 -1
- package/bin/server/http/control/OverviewRoutes.d.ts.map +0 -1
- package/bin/server/http/control/OverviewRoutes.js.map +0 -1
- package/bin/server/http/control/SessionRoutes.d.ts.map +0 -1
- package/bin/server/http/control/SessionRoutes.js.map +0 -1
- package/bin/server/http/control/SessionSummaryStore.d.ts.map +0 -1
- package/bin/server/http/control/SessionSummaryStore.js.map +0 -1
- package/bin/server/http/control/TaskRoutes.d.ts.map +0 -1
- package/bin/server/http/control/TaskRoutes.js.map +0 -1
- package/bin/server/http/control/TaskStore.d.ts.map +0 -1
- package/bin/server/http/control/TaskStore.js.map +0 -1
- package/bin/server/http/control/types/AuthControl.d.ts.map +0 -1
- package/bin/server/http/control/types/AuthControl.js.map +0 -1
- package/bin/server/http/control/types/ControlRoutes.d.ts.map +0 -1
- package/bin/server/http/control/types/ControlRoutes.js.map +0 -1
- package/bin/server/http/control/types/ControlSessionExecute.d.ts.map +0 -1
- package/bin/server/http/control/types/ControlSessionExecute.js.map +0 -1
- package/bin/server/http/control/types/ControlViewData.d.ts.map +0 -1
- package/bin/server/http/control/types/ControlViewData.js.map +0 -1
- package/bin/server/http/execute/execute.d.ts.map +0 -1
- package/bin/server/http/execute/execute.js.map +0 -1
- package/bin/server/http/health/health.d.ts.map +0 -1
- package/bin/server/http/health/health.js.map +0 -1
- package/bin/server/http/plugins/plugins.d.ts.map +0 -1
- package/bin/server/http/plugins/plugins.js.map +0 -1
- package/bin/server/http/services/services.d.ts.map +0 -1
- package/bin/server/http/services/services.js.map +0 -1
- package/bin/server/http/static/static.d.ts.map +0 -1
- package/bin/server/http/static/static.js.map +0 -1
- package/bin/server/rpc/Server.d.ts.map +0 -1
- package/bin/server/rpc/Server.js.map +0 -1
- package/bin/service/builtins/chat/runtime/ChatSessionExecutionComposer.d.ts.map +0 -1
- package/bin/service/builtins/chat/runtime/ChatSessionExecutionComposer.js.map +0 -1
- package/bin/session/composer/SessionComposer.d.ts +0 -29
- package/bin/session/composer/SessionComposer.d.ts.map +0 -1
- package/bin/session/composer/SessionComposer.js +0 -29
- package/bin/session/composer/SessionComposer.js.map +0 -1
- package/bin/session/composer/execution/LocalSessionExecutionComposer.d.ts.map +0 -1
- package/bin/session/composer/execution/LocalSessionExecutionComposer.js.map +0 -1
- package/bin/session/composer/execution/SessionExecutionComposer.d.ts.map +0 -1
- package/bin/session/composer/execution/SessionExecutionComposer.js +0 -14
- package/bin/session/composer/execution/SessionExecutionComposer.js.map +0 -1
- package/bin/session/executors/local/Runner.d.ts +0 -108
- package/bin/session/executors/local/Runner.d.ts.map +0 -1
- package/bin/session/executors/local/Runner.js +0 -219
- package/bin/session/executors/local/Runner.js.map +0 -1
- package/bin/session/executors/local/SessionExecutionError.d.ts.map +0 -1
- package/bin/session/executors/local/SessionExecutionError.js.map +0 -1
- package/bin/session/executors/local/SessionLoopDecision.d.ts.map +0 -1
- package/bin/session/executors/local/SessionLoopDecision.js.map +0 -1
- package/bin/session/executors/local/SessionModelMessageState.d.ts.map +0 -1
- package/bin/session/executors/local/SessionModelMessageState.js.map +0 -1
- package/bin/session/executors/local/SessionSignals.d.ts.map +0 -1
- package/bin/session/executors/local/SessionSignals.js.map +0 -1
- package/bin/session/executors/local/SessionToolLoopRunner.d.ts +0 -44
- package/bin/session/executors/local/SessionToolLoopRunner.d.ts.map +0 -1
- package/bin/session/executors/local/SessionToolLoopRunner.js +0 -261
- package/bin/session/executors/local/SessionToolLoopRunner.js.map +0 -1
- package/bin/session/executors/local/SessionUiStreamCollector.d.ts.map +0 -1
- package/bin/session/executors/local/SessionUiStreamCollector.js.map +0 -1
- package/bin/transport/rpc/Client.d.ts.map +0 -1
- package/bin/transport/rpc/Client.js.map +0 -1
- package/bin/transport/rpc/Paths.d.ts.map +0 -1
- package/bin/transport/rpc/Paths.js.map +0 -1
- package/bin/transport/rpc/Transport.d.ts.map +0 -1
- package/bin/transport/rpc/Transport.js.map +0 -1
- package/bin/types/auth/AuthPermission.d.ts.map +0 -1
- package/bin/types/auth/AuthPermission.js.map +0 -1
- package/bin/types/auth/AuthRoute.d.ts.map +0 -1
- package/bin/types/auth/AuthRoute.js.map +0 -1
- package/bin/types/auth/AuthToken.d.ts.map +0 -1
- package/bin/types/auth/AuthToken.js.map +0 -1
- package/bin/types/auth/AuthTypes.d.ts.map +0 -1
- package/bin/types/auth/AuthTypes.js.map +0 -1
- package/bin/types/daemon/Daemon.d.ts.map +0 -1
- package/bin/types/daemon/Daemon.js.map +0 -1
- package/bin/types/host/AgentHost.d.ts.map +0 -1
- package/bin/types/host/AgentHost.js.map +0 -1
- package/bin/types/host/Store.d.ts.map +0 -1
- package/bin/types/host/Store.js.map +0 -1
- package/bin/types/http/InlineInstant.d.ts.map +0 -1
- package/bin/types/http/InlineInstant.js.map +0 -1
- package/bin/types/platform/Platform.d.ts.map +0 -1
- package/bin/types/platform/Platform.js.map +0 -1
- package/bin/types/platform/PlatformGateway.d.ts.map +0 -1
- package/bin/types/platform/PlatformGateway.js.map +0 -1
- package/bin/types/rpc/LocalRpc.d.ts.map +0 -1
- package/bin/types/rpc/LocalRpc.js.map +0 -1
- package/src/model/CreateModel.ts +0 -350
- package/src/model/ModelManager.ts +0 -242
- package/src/session/composer/SessionComposer.ts +0 -34
- package/src/session/executors/local/Runner.ts +0 -297
- package/src/session/executors/local/SessionToolLoopRunner.ts +0 -350
- /package/bin/{project → config/project}/types/AgentProject.js +0 -0
- /package/bin/{host/runtime → runtime/host}/AgentHostRuntime.js +0 -0
- /package/bin/{host/runtime → runtime/host}/PluginRuntime.d.ts +0 -0
- /package/bin/{host/runtime → runtime/host}/PluginRuntime.js +0 -0
- /package/bin/{host → runtime/host}/daemon/Api.js +0 -0
- /package/bin/{host → runtime/host}/daemon/Client.d.ts +0 -0
- /package/bin/{host → runtime/host}/daemon/Paths.d.ts +0 -0
- /package/bin/{sandbox → runtime/sandbox}/MacOsSeatbeltSandbox.js +0 -0
- /package/bin/{sandbox → runtime/sandbox}/SandboxConfigResolver.js +0 -0
- /package/bin/{sandbox → runtime/sandbox}/types/Sandbox.d.ts +0 -0
- /package/bin/{sandbox → runtime/sandbox}/types/Sandbox.js +0 -0
- /package/bin/{sandbox → runtime/sandbox}/types/SandboxRuntime.js +0 -0
- /package/bin/{server → runtime/server}/http/auth/AuthEnv.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/auth/AuthEnv.js +0 -0
- /package/bin/{server → runtime/server}/http/auth/AuthError.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/auth/AuthError.js +0 -0
- /package/bin/{server → runtime/server}/http/auth/CliAuthStateStore.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/auth/CliAuthStateStore.js +0 -0
- /package/bin/{server → runtime/server}/http/auth/PasswordHasher.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/auth/PasswordHasher.js +0 -0
- /package/bin/{server → runtime/server}/http/auth/TokenService.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/auth/TokenService.js +0 -0
- /package/bin/{server → runtime/server}/http/control/CommonHelpers.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/control/CommonHelpers.js +0 -0
- /package/bin/{server → runtime/server}/http/control/Helpers.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/control/Helpers.js +0 -0
- /package/bin/{server → runtime/server}/http/control/types/AuthControl.js +0 -0
- /package/bin/{server → runtime/server}/http/control/types/ControlRoutes.js +0 -0
- /package/bin/{server → runtime/server}/http/control/types/ControlSessionExecute.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/control/types/ControlSessionExecute.js +0 -0
- /package/bin/{server → runtime/server}/http/control/types/ControlViewData.js +0 -0
- /package/bin/{server → runtime/server}/http/health/health.d.ts +0 -0
- /package/bin/{server → runtime/server}/http/health/health.js +0 -0
- /package/bin/{server → runtime/server}/http/plugins/plugins.js +0 -0
- /package/bin/{transport → runtime/transport}/rpc/Client.js +0 -0
- /package/bin/{transport → runtime/transport}/rpc/Paths.d.ts +0 -0
- /package/bin/{transport → runtime/transport}/rpc/Paths.js +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthPermission.d.ts +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthPermission.js +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthRoute.d.ts +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthRoute.js +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthToken.d.ts +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthToken.js +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthTypes.d.ts +0 -0
- /package/bin/types/{auth → runtime/auth}/AuthTypes.js +0 -0
- /package/bin/types/{daemon → runtime/daemon}/Daemon.d.ts +0 -0
- /package/bin/types/{daemon → runtime/daemon}/Daemon.js +0 -0
- /package/bin/types/{host → runtime/host}/AgentHost.js +0 -0
- /package/bin/types/{host → runtime/host}/Store.js +0 -0
- /package/bin/types/{http → runtime/http}/InlineInstant.d.ts +0 -0
- /package/bin/types/{http → runtime/http}/InlineInstant.js +0 -0
- /package/bin/types/{platform → runtime/platform}/Platform.d.ts +0 -0
- /package/bin/types/{platform → runtime/platform}/Platform.js +0 -0
- /package/bin/types/{platform → runtime/platform}/PlatformGateway.d.ts +0 -0
- /package/bin/types/{platform → runtime/platform}/PlatformGateway.js +0 -0
- /package/bin/types/{rpc → runtime/rpc}/LocalRpc.js +0 -0
- /package/src/{project → config/project}/types/AgentProject.ts +0 -0
- /package/src/{host/runtime → runtime/host}/PluginRuntime.ts +0 -0
- /package/src/{host → runtime/host}/daemon/Api.ts +0 -0
- /package/src/{sandbox → runtime/sandbox}/types/Sandbox.ts +0 -0
- /package/src/{server → runtime/server}/http/auth/AuthEnv.ts +0 -0
- /package/src/{server → runtime/server}/http/auth/AuthError.ts +0 -0
- /package/src/{server → runtime/server}/http/auth/CliAuthStateStore.ts +0 -0
- /package/src/{server → runtime/server}/http/auth/PasswordHasher.ts +0 -0
- /package/src/{server → runtime/server}/http/auth/TokenService.ts +0 -0
- /package/src/{server → runtime/server}/http/control/CommonHelpers.ts +0 -0
- /package/src/{server → runtime/server}/http/control/Helpers.ts +0 -0
- /package/src/{server → runtime/server}/http/control/types/AuthControl.ts +0 -0
- /package/src/{server → runtime/server}/http/control/types/ControlRoutes.ts +0 -0
- /package/src/{server → runtime/server}/http/control/types/ControlSessionExecute.ts +0 -0
- /package/src/{server → runtime/server}/http/control/types/ControlViewData.ts +0 -0
- /package/src/{server → runtime/server}/http/execute/execute.ts +0 -0
- /package/src/{server → runtime/server}/http/health/health.ts +0 -0
- /package/src/{server → runtime/server}/http/plugins/plugins.ts +0 -0
- /package/src/{server → runtime/server}/http/services/services.ts +0 -0
- /package/src/{server → runtime/server}/http/static/static.ts +0 -0
- /package/src/{transport → runtime/transport}/rpc/Paths.ts +0 -0
- /package/src/types/{auth → runtime/auth}/AuthPermission.ts +0 -0
- /package/src/types/{auth → runtime/auth}/AuthRoute.ts +0 -0
- /package/src/types/{auth → runtime/auth}/AuthToken.ts +0 -0
- /package/src/types/{auth → runtime/auth}/AuthTypes.ts +0 -0
- /package/src/types/{daemon → runtime/daemon}/Daemon.ts +0 -0
- /package/src/types/{host → runtime/host}/Store.ts +0 -0
- /package/src/types/{http → runtime/http}/InlineInstant.ts +0 -0
- /package/src/types/{platform → runtime/platform}/Platform.ts +0 -0
- /package/src/types/{platform → runtime/platform}/PlatformGateway.ts +0 -0
package/src/model/CreateModel.ts
DELETED
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM provider/model factory.
|
|
3
|
-
*
|
|
4
|
-
* 设计目标(中文,关键点)
|
|
5
|
-
* - 这是“核心能力”,不应该依赖 server/RuntimeContext(避免隐式初始化时序)。
|
|
6
|
-
* - `execution.type=api` 时,从平台全局 `llm.models` / `llm.providers` 解析最终模型。
|
|
7
|
-
* - 当前只有 `api` 执行模式。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
11
|
-
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
12
|
-
import { createHuggingFace } from "@ai-sdk/huggingface";
|
|
13
|
-
import { createMoonshotAI } from "@ai-sdk/moonshotai";
|
|
14
|
-
import { createOpenResponses } from "@ai-sdk/open-responses";
|
|
15
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
16
|
-
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
17
|
-
import { createXai } from "@ai-sdk/xai";
|
|
18
|
-
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
|
19
|
-
import { type LanguageModel } from "ai";
|
|
20
|
-
import { createLlmLoggingFetch } from "@/utils/logger/Fetch.js";
|
|
21
|
-
import { getLogger } from "@/utils/logger/Logger.js";
|
|
22
|
-
import type { DowncityConfig } from "@/types/config/DowncityConfig.js";
|
|
23
|
-
import type { LlmProviderType } from "@/types/config/LlmConfig.js";
|
|
24
|
-
import { readProjectExecutionBinding } from "@/config/ExecutionBinding.js";
|
|
25
|
-
import type { AgentPlatformRuntime } from "@/types/host/AgentHost.js";
|
|
26
|
-
|
|
27
|
-
type ModelLogContext = {
|
|
28
|
-
sessionId?: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
function buildResponsesUrl(baseUrl?: string): string {
|
|
32
|
-
const trimmed = String(baseUrl || "")
|
|
33
|
-
.trim()
|
|
34
|
-
.replace(/\/+$/, "");
|
|
35
|
-
if (!trimmed) return "https://api.openai.com/v1/responses";
|
|
36
|
-
if (trimmed.endsWith("/responses")) return trimmed;
|
|
37
|
-
return `${trimmed}/responses`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function normalizeOptionalBaseUrl(value: string | undefined): string | undefined {
|
|
41
|
-
const trimmed = String(value || "")
|
|
42
|
-
.trim()
|
|
43
|
-
.replace(/\/+$/, "");
|
|
44
|
-
return trimmed || undefined;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* provider 默认 baseUrl。
|
|
49
|
-
*
|
|
50
|
-
* 关键点(中文)
|
|
51
|
-
* - 当 `downcity.json.llm.providers.<id>.baseUrl` 省略时,按 provider type 自动补全。
|
|
52
|
-
* - 保持“只配置 provider type + apiKey + modelName”也能跑通常见 provider。
|
|
53
|
-
*/
|
|
54
|
-
function resolveProviderDefaultBaseUrl(
|
|
55
|
-
providerType: LlmProviderType,
|
|
56
|
-
): string | undefined {
|
|
57
|
-
if (providerType === "deepseek") return "https://api.deepseek.com/v1";
|
|
58
|
-
if (providerType === "moonshot-cn") return "https://api.moonshot.cn/v1";
|
|
59
|
-
if (providerType === "moonshot-ai") return "https://api.moonshot.ai/v1";
|
|
60
|
-
if (providerType === "kimi-code") return "https://api.kimi.com/coding/v1";
|
|
61
|
-
if (providerType === "xai") return "https://api.x.ai/v1";
|
|
62
|
-
if (providerType === "openrouter") return "https://openrouter.ai/api/v1";
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function resolveEnvPlaceholder(value: string | undefined): string | undefined {
|
|
67
|
-
if (!value) return value;
|
|
68
|
-
if (value.startsWith("${") && value.endsWith("}")) {
|
|
69
|
-
const envVar = value.slice(2, -1);
|
|
70
|
-
return process.env[envVar];
|
|
71
|
-
}
|
|
72
|
-
return value;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function resolveApiKeyFallback(providerType: LlmProviderType): string | undefined {
|
|
76
|
-
if (providerType === "gemini") {
|
|
77
|
-
return (
|
|
78
|
-
process.env.GEMINI_API_KEY ||
|
|
79
|
-
process.env.GOOGLE_API_KEY ||
|
|
80
|
-
process.env.GOOGLE_GENERATIVE_AI_API_KEY ||
|
|
81
|
-
process.env.API_KEY
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
if (providerType === "anthropic") {
|
|
85
|
-
return process.env.ANTHROPIC_API_KEY || process.env.API_KEY;
|
|
86
|
-
}
|
|
87
|
-
if (providerType === "deepseek") {
|
|
88
|
-
return (
|
|
89
|
-
process.env.DEEPSEEK_API_KEY ||
|
|
90
|
-
process.env.OPENAI_API_KEY ||
|
|
91
|
-
process.env.API_KEY
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
if (providerType === "xai") {
|
|
95
|
-
return process.env.XAI_API_KEY || process.env.API_KEY;
|
|
96
|
-
}
|
|
97
|
-
if (providerType === "huggingface") {
|
|
98
|
-
return (
|
|
99
|
-
process.env.HUGGINGFACE_API_KEY ||
|
|
100
|
-
process.env.HF_TOKEN ||
|
|
101
|
-
process.env.API_KEY
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
if (providerType === "openrouter") {
|
|
105
|
-
return process.env.OPENROUTER_API_KEY || process.env.API_KEY;
|
|
106
|
-
}
|
|
107
|
-
if (providerType === "moonshot-cn" || providerType === "moonshot-ai") {
|
|
108
|
-
return (
|
|
109
|
-
process.env.MOONSHOT_API_KEY ||
|
|
110
|
-
process.env.KIMI_API_KEY ||
|
|
111
|
-
process.env.API_KEY
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
if (providerType === "kimi-code") {
|
|
115
|
-
return (
|
|
116
|
-
process.env.KIMI_CODE_API_KEY ||
|
|
117
|
-
process.env.KIMI_API_KEY ||
|
|
118
|
-
process.env.MOONSHOT_API_KEY ||
|
|
119
|
-
process.env.API_KEY
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
return process.env.OPENAI_API_KEY || process.env.API_KEY;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function normalizeProviderType(value: unknown): LlmProviderType | null {
|
|
126
|
-
if (value === "anthropic") return value;
|
|
127
|
-
if (value === "openai") return value;
|
|
128
|
-
if (value === "deepseek") return value;
|
|
129
|
-
if (value === "gemini") return value;
|
|
130
|
-
if (value === "open-compatible") return value;
|
|
131
|
-
if (value === "open-responses") return value;
|
|
132
|
-
if (value === "moonshot-cn") return value;
|
|
133
|
-
if (value === "moonshot-ai") return value;
|
|
134
|
-
if (value === "kimi-code") return value;
|
|
135
|
-
if (value === "xai") return value;
|
|
136
|
-
if (value === "huggingface") return value;
|
|
137
|
-
if (value === "openrouter") return value;
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* 创建 LanguageModel 实例。
|
|
143
|
-
*
|
|
144
|
-
* 解析策略(中文)
|
|
145
|
-
* 1) 读取 `execution`,确认是 `api` 模式。
|
|
146
|
-
* `api`:定位平台全局 `llm.models[modelId]` 与 `llm.providers[providerKey]`。
|
|
147
|
-
* 创建带日志拦截的 fetch,并按 provider type 分发到 SDK 工厂。
|
|
148
|
-
*/
|
|
149
|
-
export async function createModel(input: {
|
|
150
|
-
config: DowncityConfig;
|
|
151
|
-
getSessionRunScope?: () => ModelLogContext | undefined;
|
|
152
|
-
platform?: AgentPlatformRuntime;
|
|
153
|
-
projectRoot?: string;
|
|
154
|
-
}): Promise<LanguageModel> {
|
|
155
|
-
const logger = getLogger();
|
|
156
|
-
const execution = readProjectExecutionBinding(input.config);
|
|
157
|
-
if (!execution) {
|
|
158
|
-
await logger.log("warn", "No agent execution configured");
|
|
159
|
-
throw Error("No agent execution configured");
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// 日志策略(中文):默认开启 LLM 请求日志;可通过 llm.logMessages 关闭。
|
|
163
|
-
const configLog = input.config.llm?.logMessages;
|
|
164
|
-
const logLlmMessages = typeof configLog === "boolean" ? configLog : true;
|
|
165
|
-
const loggingFetch = createLlmLoggingFetch({
|
|
166
|
-
logger,
|
|
167
|
-
enabled: logLlmMessages,
|
|
168
|
-
getSessionRunScope: input.getSessionRunScope,
|
|
169
|
-
});
|
|
170
|
-
if (!execution || execution.type !== "api") {
|
|
171
|
-
await logger.log("warn", `Unsupported agent execution for createModel: ${execution.type}`);
|
|
172
|
-
throw Error(`Unsupported agent execution for createModel: ${execution.type}`);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const primaryModelId = execution.modelId;
|
|
176
|
-
|
|
177
|
-
const platform = input.platform;
|
|
178
|
-
const modelConfig = platform?.getModel(primaryModelId) || null;
|
|
179
|
-
const providerConfigs = await (platform?.listProviders?.() || Promise.resolve([]));
|
|
180
|
-
const providerMap = new Map(providerConfigs.map((item) => [item.id, item] as const));
|
|
181
|
-
const providerConfig = modelConfig
|
|
182
|
-
? providerMap.get(String(modelConfig.providerId || "").trim()) || null
|
|
183
|
-
: null;
|
|
184
|
-
if (!modelConfig || !providerConfig) {
|
|
185
|
-
await logger.log("warn", `LLM model config not found in platform runtime: ${primaryModelId}`);
|
|
186
|
-
throw Error(`LLM model config not found in platform runtime: ${primaryModelId}`);
|
|
187
|
-
}
|
|
188
|
-
const selectedModelConfig = modelConfig;
|
|
189
|
-
const selectedProviderConfig = providerConfig;
|
|
190
|
-
if (selectedModelConfig.isPaused === true) {
|
|
191
|
-
await logger.log(
|
|
192
|
-
"warn",
|
|
193
|
-
`LLM model is paused in platform runtime: ${primaryModelId}`,
|
|
194
|
-
);
|
|
195
|
-
throw Error(`LLM model is paused: ${primaryModelId}`);
|
|
196
|
-
}
|
|
197
|
-
const providerKey = selectedProviderConfig.id;
|
|
198
|
-
|
|
199
|
-
const providerType = normalizeProviderType(selectedProviderConfig.type);
|
|
200
|
-
if (!providerType) {
|
|
201
|
-
await logger.log("warn", `Unsupported LLM provider type: ${selectedProviderConfig.type}`);
|
|
202
|
-
throw Error(`Unsupported LLM provider type: ${selectedProviderConfig.type}`);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const resolvedModel = resolveEnvPlaceholder(selectedModelConfig.name);
|
|
206
|
-
if (!resolvedModel || resolvedModel === "${}") {
|
|
207
|
-
await logger.log("warn", "No LLM model name configured");
|
|
208
|
-
throw Error("No LLM model name configured");
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const resolvedBaseUrl = normalizeOptionalBaseUrl(
|
|
212
|
-
resolveEnvPlaceholder(selectedProviderConfig.baseUrl) ||
|
|
213
|
-
resolveProviderDefaultBaseUrl(providerType),
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
let resolvedApiKey = resolveEnvPlaceholder(selectedProviderConfig.apiKey);
|
|
217
|
-
if (!resolvedApiKey) {
|
|
218
|
-
resolvedApiKey = resolveApiKeyFallback(providerType);
|
|
219
|
-
}
|
|
220
|
-
if (!resolvedApiKey) {
|
|
221
|
-
await logger.log("warn", "No API Key configured, will use simulation mode");
|
|
222
|
-
throw Error("No API Key configured, will use simulation mode");
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// 关键点(中文):启动阶段只打印一次当前生效模型状态,便于快速确认路由是否正确。
|
|
226
|
-
await logger.log(
|
|
227
|
-
"info",
|
|
228
|
-
`[main] model primary=${primaryModelId} provider=${providerType}/${providerKey} name=${resolvedModel}${resolvedBaseUrl ? ` baseUrl=${resolvedBaseUrl}` : ""}`,
|
|
229
|
-
{
|
|
230
|
-
kind: "llm_model_ready",
|
|
231
|
-
primaryModel: primaryModelId,
|
|
232
|
-
providerType,
|
|
233
|
-
providerKey,
|
|
234
|
-
model: resolvedModel,
|
|
235
|
-
...(resolvedBaseUrl ? { baseUrl: resolvedBaseUrl } : {}),
|
|
236
|
-
logMessages: logLlmMessages,
|
|
237
|
-
},
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
if (providerType === "anthropic") {
|
|
241
|
-
const anthropicProvider = createAnthropic({
|
|
242
|
-
apiKey: resolvedApiKey,
|
|
243
|
-
baseURL: resolvedBaseUrl,
|
|
244
|
-
fetch: loggingFetch as typeof fetch,
|
|
245
|
-
});
|
|
246
|
-
return anthropicProvider(resolvedModel);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (providerType === "gemini") {
|
|
250
|
-
const googleProvider = createGoogleGenerativeAI({
|
|
251
|
-
apiKey: resolvedApiKey,
|
|
252
|
-
baseURL: resolvedBaseUrl,
|
|
253
|
-
fetch: loggingFetch as typeof fetch,
|
|
254
|
-
});
|
|
255
|
-
return googleProvider(resolvedModel);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (providerType === "open-responses") {
|
|
259
|
-
const responsesProvider = createOpenResponses({
|
|
260
|
-
url: buildResponsesUrl(resolvedBaseUrl),
|
|
261
|
-
name: providerKey,
|
|
262
|
-
apiKey: resolvedApiKey,
|
|
263
|
-
fetch: loggingFetch as typeof fetch,
|
|
264
|
-
});
|
|
265
|
-
return responsesProvider(resolvedModel);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (providerType === "open-compatible") {
|
|
269
|
-
const compatibleBaseUrl = resolvedBaseUrl || "https://api.openai.com/v1";
|
|
270
|
-
const compatibleProvider = createOpenAICompatible({
|
|
271
|
-
name: providerKey,
|
|
272
|
-
baseURL: compatibleBaseUrl,
|
|
273
|
-
apiKey: resolvedApiKey,
|
|
274
|
-
fetch: loggingFetch as typeof fetch,
|
|
275
|
-
});
|
|
276
|
-
return compatibleProvider(resolvedModel);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (providerType === "kimi-code") {
|
|
280
|
-
const compatibleBaseUrl = resolvedBaseUrl || "https://api.kimi.com/coding/v1";
|
|
281
|
-
const compatibleProvider = createOpenAICompatible({
|
|
282
|
-
name: providerKey,
|
|
283
|
-
baseURL: compatibleBaseUrl,
|
|
284
|
-
apiKey: resolvedApiKey,
|
|
285
|
-
fetch: loggingFetch as typeof fetch,
|
|
286
|
-
});
|
|
287
|
-
return compatibleProvider(resolvedModel);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (providerType === "moonshot-cn" || providerType === "moonshot-ai") {
|
|
291
|
-
const moonshotProvider = createMoonshotAI({
|
|
292
|
-
baseURL: resolvedBaseUrl,
|
|
293
|
-
apiKey: resolvedApiKey,
|
|
294
|
-
fetch: loggingFetch as typeof fetch,
|
|
295
|
-
});
|
|
296
|
-
return moonshotProvider(resolvedModel);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (providerType === "xai") {
|
|
300
|
-
const xaiProvider = createXai({
|
|
301
|
-
baseURL: resolvedBaseUrl,
|
|
302
|
-
apiKey: resolvedApiKey,
|
|
303
|
-
fetch: loggingFetch as typeof fetch,
|
|
304
|
-
});
|
|
305
|
-
return xaiProvider(resolvedModel);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (providerType === "huggingface") {
|
|
309
|
-
const huggingFaceProvider = createHuggingFace({
|
|
310
|
-
baseURL: resolvedBaseUrl,
|
|
311
|
-
apiKey: resolvedApiKey,
|
|
312
|
-
fetch: loggingFetch as typeof fetch,
|
|
313
|
-
});
|
|
314
|
-
return huggingFaceProvider(resolvedModel);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if (providerType === "openrouter") {
|
|
318
|
-
const openRouterProvider = createOpenRouter({
|
|
319
|
-
baseURL: resolvedBaseUrl,
|
|
320
|
-
apiKey: resolvedApiKey,
|
|
321
|
-
fetch: loggingFetch as typeof fetch,
|
|
322
|
-
});
|
|
323
|
-
return openRouterProvider(resolvedModel);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if (providerType === "deepseek") {
|
|
327
|
-
// 关键点(中文):
|
|
328
|
-
// - DeepSeek 提供的是 OpenAI-compatible chat/completions 接口,不支持
|
|
329
|
-
// `createOpenAI()` 默认语言模型走的 `/responses` 路径。
|
|
330
|
-
// - 若继续使用 `createOpenAI()`,请求会落到
|
|
331
|
-
// `https://api.deepseek.com/v1/responses` 并直接返回 404。
|
|
332
|
-
const deepseekCompatibleProvider = createOpenAICompatible({
|
|
333
|
-
name: providerKey,
|
|
334
|
-
baseURL: resolvedBaseUrl || "https://api.deepseek.com/v1",
|
|
335
|
-
apiKey: resolvedApiKey,
|
|
336
|
-
fetch: loggingFetch as typeof fetch,
|
|
337
|
-
});
|
|
338
|
-
return deepseekCompatibleProvider(resolvedModel);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// OpenAI 官方 provider(中文):
|
|
342
|
-
// - 只在真正的 OpenAI provider 下使用 `createOpenAI()`。
|
|
343
|
-
// - 该 SDK 默认语言模型使用 Responses API,适配官方 OpenAI 路径。
|
|
344
|
-
const openaiProvider = createOpenAI({
|
|
345
|
-
apiKey: resolvedApiKey,
|
|
346
|
-
baseURL: resolvedBaseUrl,
|
|
347
|
-
fetch: loggingFetch as typeof fetch,
|
|
348
|
-
});
|
|
349
|
-
return openaiProvider(resolvedModel);
|
|
350
|
-
}
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ModelManager:LLM 模型预设管理器。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 统一管理 init 场景的“模型预设清单 + providerType 映射 + 自定义模型标记”。
|
|
6
|
-
* - 避免命令层直接依赖硬编码常量,提升可维护性与一致性。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { LlmProviderType } from "@/types/config/LlmConfig.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 单个模型预设定义。
|
|
13
|
-
*/
|
|
14
|
-
export type ModelPreset = {
|
|
15
|
-
/**
|
|
16
|
-
* 预设 ID(同时作为模型名称写入 `llm.models.<active>.name`,除自定义模型外)。
|
|
17
|
-
*/
|
|
18
|
-
id: string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 预设标题(用于 CLI 交互显示)。
|
|
22
|
-
*/
|
|
23
|
-
title: string;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 对应 provider 类型(用于生成 `llm.providers.<id>.type`)。
|
|
27
|
-
*/
|
|
28
|
-
providerTypes: readonly LlmProviderType[];
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 是否属于“模型名由环境变量注入”的自定义模型类型。
|
|
32
|
-
*/
|
|
33
|
-
useCustomModelName: boolean;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const CUSTOM_MODEL_IDS = new Set<string>(["open-compatible", "open-responses"]);
|
|
37
|
-
|
|
38
|
-
const MODEL_PRESETS: ModelPreset[] = [
|
|
39
|
-
// Claude 系列
|
|
40
|
-
{
|
|
41
|
-
id: "claude-sonnet-4-5",
|
|
42
|
-
title: "Claude Sonnet 4",
|
|
43
|
-
providerTypes: ["anthropic"],
|
|
44
|
-
useCustomModelName: false,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
id: "claude-haiku",
|
|
48
|
-
title: "Claude Haiku",
|
|
49
|
-
providerTypes: ["anthropic"],
|
|
50
|
-
useCustomModelName: false,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
id: "claude-3-5-sonnet-20241022",
|
|
54
|
-
title: "Claude 3.5 Sonnet",
|
|
55
|
-
providerTypes: ["anthropic"],
|
|
56
|
-
useCustomModelName: false,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
id: "claude-3-opus-20240229",
|
|
60
|
-
title: "Claude 3 Opus",
|
|
61
|
-
providerTypes: ["anthropic"],
|
|
62
|
-
useCustomModelName: false,
|
|
63
|
-
},
|
|
64
|
-
// OpenAI GPT 系列
|
|
65
|
-
{
|
|
66
|
-
id: "gpt-4",
|
|
67
|
-
title: "GPT-4",
|
|
68
|
-
providerTypes: ["openai"],
|
|
69
|
-
useCustomModelName: false,
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
id: "gpt-4-turbo",
|
|
73
|
-
title: "GPT-4 Turbo",
|
|
74
|
-
providerTypes: ["openai"],
|
|
75
|
-
useCustomModelName: false,
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
id: "gpt-4o",
|
|
79
|
-
title: "GPT-4o",
|
|
80
|
-
providerTypes: ["openai"],
|
|
81
|
-
useCustomModelName: false,
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: "gpt-3.5-turbo",
|
|
85
|
-
title: "GPT-3.5 Turbo",
|
|
86
|
-
providerTypes: ["openai"],
|
|
87
|
-
useCustomModelName: false,
|
|
88
|
-
},
|
|
89
|
-
// DeepSeek
|
|
90
|
-
{
|
|
91
|
-
id: "deepseek-chat",
|
|
92
|
-
title: "DeepSeek Chat",
|
|
93
|
-
providerTypes: ["deepseek"],
|
|
94
|
-
useCustomModelName: false,
|
|
95
|
-
},
|
|
96
|
-
// Gemini
|
|
97
|
-
{
|
|
98
|
-
id: "gemini-2.5-pro",
|
|
99
|
-
title: "Gemini 2.5 Pro",
|
|
100
|
-
providerTypes: ["gemini"],
|
|
101
|
-
useCustomModelName: false,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
id: "gemini-2.5-flash",
|
|
105
|
-
title: "Gemini 2.5 Flash",
|
|
106
|
-
providerTypes: ["gemini"],
|
|
107
|
-
useCustomModelName: false,
|
|
108
|
-
},
|
|
109
|
-
// xAI
|
|
110
|
-
{
|
|
111
|
-
id: "grok-3",
|
|
112
|
-
title: "xAI Grok 3",
|
|
113
|
-
providerTypes: ["xai"],
|
|
114
|
-
useCustomModelName: false,
|
|
115
|
-
},
|
|
116
|
-
// HuggingFace Router
|
|
117
|
-
{
|
|
118
|
-
id: "meta-llama/Llama-3.1-8B-Instruct",
|
|
119
|
-
title: "HF Llama 3.1 8B",
|
|
120
|
-
providerTypes: ["huggingface"],
|
|
121
|
-
useCustomModelName: false,
|
|
122
|
-
},
|
|
123
|
-
// OpenRouter
|
|
124
|
-
{
|
|
125
|
-
id: "openrouter/auto",
|
|
126
|
-
title: "OpenRouter Auto",
|
|
127
|
-
providerTypes: ["openrouter"],
|
|
128
|
-
useCustomModelName: false,
|
|
129
|
-
},
|
|
130
|
-
// Moonshot(Kimi)
|
|
131
|
-
{
|
|
132
|
-
id: "kimi-k2.5",
|
|
133
|
-
title: "Kimi K2.5",
|
|
134
|
-
providerTypes: ["moonshot-cn", "moonshot-ai"],
|
|
135
|
-
useCustomModelName: false,
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
id: "kimi-for-coding",
|
|
139
|
-
title: "Kimi For Coding",
|
|
140
|
-
providerTypes: ["kimi-code"],
|
|
141
|
-
useCustomModelName: false,
|
|
142
|
-
},
|
|
143
|
-
// OpenAI-compatible(Chat Completions)
|
|
144
|
-
{
|
|
145
|
-
id: "open-compatible",
|
|
146
|
-
title: "Open-compatible model",
|
|
147
|
-
providerTypes: ["open-compatible"],
|
|
148
|
-
useCustomModelName: true,
|
|
149
|
-
},
|
|
150
|
-
// OpenAI-compatible(Responses)
|
|
151
|
-
{
|
|
152
|
-
id: "open-responses",
|
|
153
|
-
title: "Open-responses model",
|
|
154
|
-
providerTypes: ["open-responses"],
|
|
155
|
-
useCustomModelName: true,
|
|
156
|
-
},
|
|
157
|
-
];
|
|
158
|
-
|
|
159
|
-
const DEFAULT_MODEL_PRESET_ID = "claude-sonnet-4-5";
|
|
160
|
-
const FALLBACK_MODEL_PRESET_ID = "open-compatible";
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* init 模型选择解析结果。
|
|
164
|
-
*/
|
|
165
|
-
export type ResolvedInitModelPreset = {
|
|
166
|
-
/**
|
|
167
|
-
* 规范化后的模型预设 ID。
|
|
168
|
-
*/
|
|
169
|
-
selectedModelId: string;
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* 选中的模型预设。
|
|
173
|
-
*/
|
|
174
|
-
preset: ModelPreset;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* 模型预设管理器。
|
|
179
|
-
*/
|
|
180
|
-
export class ModelManager {
|
|
181
|
-
private readonly presets: ModelPreset[];
|
|
182
|
-
private readonly presetsById: Map<string, ModelPreset>;
|
|
183
|
-
|
|
184
|
-
constructor() {
|
|
185
|
-
this.presets = [...MODEL_PRESETS];
|
|
186
|
-
this.presetsById = new Map(
|
|
187
|
-
this.presets.map((preset) => [preset.id, preset] as const),
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* 列出所有可选模型预设(按定义顺序)。
|
|
193
|
-
*/
|
|
194
|
-
listPresets(): ModelPreset[] {
|
|
195
|
-
return [...this.presets];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* 根据预设 ID 获取模型预设。
|
|
200
|
-
*/
|
|
201
|
-
getPreset(id: string): ModelPreset | undefined {
|
|
202
|
-
const key = String(id || "").trim();
|
|
203
|
-
if (!key) return undefined;
|
|
204
|
-
return this.presetsById.get(key);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* 判断预设是否支持指定 provider 类型。
|
|
209
|
-
*/
|
|
210
|
-
supportsProviderType(preset: ModelPreset, providerType: LlmProviderType): boolean {
|
|
211
|
-
return preset.providerTypes.includes(providerType);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* 获取默认模型预设。
|
|
216
|
-
*/
|
|
217
|
-
getDefaultPreset(): ModelPreset {
|
|
218
|
-
return (
|
|
219
|
-
this.getPreset(DEFAULT_MODEL_PRESET_ID) ||
|
|
220
|
-
this.getPreset(FALLBACK_MODEL_PRESET_ID) ||
|
|
221
|
-
this.presets[0]
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* 解析 init 输入的模型选择,并返回稳定的预设结果。
|
|
227
|
-
*/
|
|
228
|
-
resolveInitPreset(input?: string): ResolvedInitModelPreset {
|
|
229
|
-
const selectedModelId = String(input || "").trim();
|
|
230
|
-
const preset =
|
|
231
|
-
this.getPreset(selectedModelId) ||
|
|
232
|
-
this.getPreset(FALLBACK_MODEL_PRESET_ID) ||
|
|
233
|
-
this.getDefaultPreset();
|
|
234
|
-
return {
|
|
235
|
-
selectedModelId: selectedModelId || preset.id,
|
|
236
|
-
preset: {
|
|
237
|
-
...preset,
|
|
238
|
-
useCustomModelName: CUSTOM_MODEL_IDS.has(preset.id),
|
|
239
|
-
},
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SessionComposer:Session Composer 层的最小公共基类。
|
|
3
|
-
*
|
|
4
|
-
* 关键点(中文)
|
|
5
|
-
* - 这里只提供统一的生命周期壳,不承载具体业务语义。
|
|
6
|
-
* - 具体职责必须由子类自己表达,例如 HistoryStore / CompactionPolicy / SystemResolver / ExecutionComposer。
|
|
7
|
-
*/
|
|
8
|
-
export abstract class SessionComposer {
|
|
9
|
-
/**
|
|
10
|
-
* Composer 名称(用于日志与诊断)。
|
|
11
|
-
*/
|
|
12
|
-
abstract readonly name: string;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 可选初始化钩子。
|
|
16
|
-
*
|
|
17
|
-
* 关键点(中文)
|
|
18
|
-
* - Executor / Runner 启动时可统一调用。
|
|
19
|
-
* - 无需初始化的 Composer 可不实现。
|
|
20
|
-
*/
|
|
21
|
-
async init(): Promise<void> {
|
|
22
|
-
// no-op
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 可选释放钩子。
|
|
27
|
-
*
|
|
28
|
-
* 关键点(中文)
|
|
29
|
-
* - Session 运行时关停时统一释放资源(连接、句柄、缓存等)。
|
|
30
|
-
*/
|
|
31
|
-
async dispose(): Promise<void> {
|
|
32
|
-
// no-op
|
|
33
|
-
}
|
|
34
|
-
}
|