@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/README.md
CHANGED
|
@@ -2,29 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
`@downcity/agent` 是 Downcity 的单 Agent 运行时包。
|
|
4
4
|
|
|
5
|
-
它负责把一个 agent
|
|
5
|
+
它负责把一个 agent 项目目录装配成可执行运行时,包括:
|
|
6
|
+
|
|
7
|
+
- 本地 SDK:`Agent`、`Session`、`RemoteAgent`
|
|
8
|
+
- 会话执行内核:history、system、tool loop、stream
|
|
9
|
+
- Service 框架:生命周期、action、调度
|
|
10
|
+
- Plugin 框架:hook、action、内建插件
|
|
11
|
+
- 运行时实现:HTTP/RPC server、transport、sandbox、host
|
|
12
|
+
|
|
13
|
+
`@downcity/city` 负责多 Agent 管理、控制面网关、平台 CLI、模型池与 daemon 进程管理;`@downcity/agent` 只负责单 Agent 执行内核。
|
|
6
14
|
|
|
7
15
|
## 包定位
|
|
8
16
|
|
|
9
|
-
- 面向单个 Agent
|
|
10
|
-
- 对外通过 `@downcity/agent` 根入口暴露公共 API
|
|
11
|
-
- 负责 session、service、plugin、sandbox、HTTP/RPC server、SDK 本地 Agent
|
|
12
|
-
- 不负责多 Agent registry、control plane daemon、console UI
|
|
17
|
+
- 面向单个 Agent 项目的执行面
|
|
18
|
+
- 对外通过 `@downcity/agent` 根入口暴露公共 API
|
|
19
|
+
- 负责 session、service、plugin、sandbox、HTTP/RPC server、SDK 本地 Agent
|
|
20
|
+
- 不负责多 Agent registry、control plane daemon、console UI 聚合和平台级编排
|
|
13
21
|
|
|
14
22
|
## 与其他包的边界
|
|
15
23
|
|
|
16
24
|
- `@downcity/agent`
|
|
17
|
-
- 单 Agent runtime
|
|
18
|
-
- 单 Agent HTTP/RPC server
|
|
19
|
-
- session 执行、service 框架、plugin 框架、sandbox
|
|
20
|
-
- 本地 SDK facade
|
|
25
|
+
- 单 Agent runtime
|
|
26
|
+
- 单 Agent HTTP/RPC server
|
|
27
|
+
- session 执行、service 框架、plugin 框架、sandbox
|
|
28
|
+
- 本地 SDK facade
|
|
21
29
|
- `@downcity/city`
|
|
22
|
-
- 多 Agent registry
|
|
23
|
-
- control plane / gateway
|
|
24
|
-
- 平台 CLI
|
|
25
|
-
- agent daemon
|
|
30
|
+
- 多 Agent registry
|
|
31
|
+
- control plane / gateway
|
|
32
|
+
- 平台 CLI、模型池、模型工厂、全局 env、channel account store
|
|
33
|
+
- agent daemon 进程管理
|
|
26
34
|
- `@downcity/ui`
|
|
27
|
-
- React UI
|
|
35
|
+
- React UI 组件与展示层
|
|
28
36
|
|
|
29
37
|
## 根目录结构
|
|
30
38
|
|
|
@@ -41,659 +49,142 @@ packages/agent
|
|
|
41
49
|
## 当前源码结构
|
|
42
50
|
|
|
43
51
|
```text
|
|
44
|
-
src/
|
|
52
|
+
src/
|
|
45
53
|
├── index.ts # 包公开入口,集中导出外部可依赖的 API 与协议类型
|
|
46
|
-
├── config/ #
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
├──
|
|
51
|
-
├──
|
|
52
|
-
│ ├──
|
|
53
|
-
│ ├──
|
|
54
|
-
│ └──
|
|
55
|
-
├──
|
|
56
|
-
│ └──
|
|
57
|
-
├──
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
├──
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
│ ├── builtins/ # 内建 service 模块,提供 chat、contact、task、memory、shell 等用户可用服务
|
|
66
|
-
│ ├── core/ # Service 核心模块,负责 service 注册、实例管理、状态控制、action runner 与系统提示
|
|
67
|
-
│ ├── schedule/ # Service 调度模块,负责持久化 service action 的计划执行与 runtime store
|
|
68
|
-
│ └── types/ # Service 公共类型模块,定义 service、action、state、schedule 等协议
|
|
69
|
-
├── session/ # 会话执行模块,负责 Session 实例、模型输入组合、tool loop、history 与消息持久化
|
|
70
|
-
│ ├── composer/ # Session 组合模块,负责 history、system、execution、compaction 等上下文组合面
|
|
71
|
-
│ ├── executors/ # Session 执行器模块,负责 local executor、core runner、tool loop 与执行错误归一化
|
|
72
|
-
│ ├── ids/ # Session 标识模块,负责 session id / message id 等标识生成与解析
|
|
73
|
-
│ ├── messages/ # Session 消息模块,负责 UI/model/session 消息转换、附件映射与 step event 映射
|
|
74
|
-
│ ├── tools/ # Session 工具模块,负责 shell 等内置 tool 的定义、桥接与输出格式化
|
|
75
|
-
│ └── types/ # Session 公共类型模块,定义消息、执行输入、step event 等会话协议
|
|
76
|
-
├── transport/ # 调用端传输模块,负责 agent client 侧 transport 协议与连接选择
|
|
77
|
-
│ └── rpc/ # RPC transport 模块,提供 local RPC client、endpoint path 与 transport 实现
|
|
78
|
-
├── types/ # 跨模块共享类型模块,集中放置跨包、跨领域复用的稳定协议类型
|
|
79
|
-
│ ├── auth/ # 鉴权协议类型模块,定义 token、permission、route 与 auth control 共享结构
|
|
80
|
-
│ ├── common/ # 基础公共类型模块,定义 Json、Template 等无领域依赖的基础类型
|
|
81
|
-
│ ├── config/ # 配置协议类型模块,定义 DowncityConfig、LLM、model binding、start options 等结构
|
|
82
|
-
│ ├── daemon/ # Daemon 协议类型模块,定义 agent daemon API 与状态交换结构
|
|
83
|
-
│ ├── host/ # Host 协议类型模块,定义 AgentHost、store、plugin config runtime 等宿主能力
|
|
84
|
-
│ ├── http/ # HTTP 协议类型模块,定义 inline execute 等 HTTP API payload
|
|
85
|
-
│ ├── platform/ # 平台端口类型模块,定义 Platform、PlatformGateway 等 city/agent 注入协议
|
|
86
|
-
│ └── rpc/ # RPC 协议类型模块,定义 local RPC request/response 与 transport 载荷
|
|
87
|
-
└── utils/ # 包内通用工具模块,提供 CLI、日志、存储与模板等低层辅助能力
|
|
88
|
-
├── cli/ # CLI 辅助模块,负责命令行输出、交互与格式化工具
|
|
89
|
-
├── logger/ # 日志模块,负责结构化日志、请求/响应格式化与 fetch 日志封装
|
|
90
|
-
└── storage/ # 存储工具模块,负责本地 JSON/文件存储等通用落盘辅助
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## 目录职责
|
|
94
|
-
|
|
95
|
-
- `src/index.ts`
|
|
96
|
-
- 包的唯一公开入口。
|
|
97
|
-
- `city` 和外部调用方应从这里导入公共能力,避免依赖内部子路径。
|
|
98
|
-
|
|
99
|
-
- `src/runtime/`
|
|
100
|
-
- 单 Agent runtime 装配层。
|
|
101
|
-
- `AgentRuntime.ts` 负责初始化 config、model、session factory、services、plugins、hot reload。
|
|
102
|
-
- `AgentContext.ts` 负责从 `AgentRuntime` 派生统一能力面。
|
|
103
|
-
|
|
104
|
-
- `src/project/`
|
|
105
|
-
- 项目初始化与 execution binding。
|
|
106
|
-
- 负责 agent 项目骨架、默认文件、模型绑定与初始化结果类型。
|
|
54
|
+
├── config/ # 配置与项目初始化,负责 downcity.json、默认配置、execution binding 与脚手架
|
|
55
|
+
│ └── project/ # Agent 项目初始化与项目初始化类型
|
|
56
|
+
├── core/ # 单 Agent 运行时装配中心,负责 AgentCore / AgentContext
|
|
57
|
+
├── plugin/ # 插件系统,负责插件注册、hook、action、内建插件与插件类型
|
|
58
|
+
├── runtime/ # 运行时实现细节层,统一收纳 host / sandbox / server / transport
|
|
59
|
+
│ ├── host/ # 宿主注入能力与 daemon 协议
|
|
60
|
+
│ ├── sandbox/ # 命令沙箱与沙箱协议
|
|
61
|
+
│ ├── server/ # HTTP / RPC 服务端实现
|
|
62
|
+
│ └── transport/ # 调用端 transport 协议与 RPC client
|
|
63
|
+
├── sdk/ # 本地 SDK facade,提供 Agent / RemoteAgent / Session 等高层 API
|
|
64
|
+
│ └── session/ # SDK session 的 metadata、落盘路径、持久化与 service 端口适配
|
|
65
|
+
├── service/ # Service 系统,负责内建服务、生命周期、调度与 service 类型
|
|
66
|
+
│ └── core/ # Service 核心控制层,包含 schedule 基础设施
|
|
67
|
+
├── session/ # 会话执行内核,负责历史、system、tool loop、stream 与消息持久化
|
|
68
|
+
├── types/ # 跨模块共享协议类型,集中放置 common / config / runtime 等稳定契约
|
|
69
|
+
└── utils/ # 低层工具,负责 CLI、日志、存储与模板辅助
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 顶层目录职责
|
|
107
73
|
|
|
108
74
|
- `src/config/`
|
|
109
|
-
-
|
|
110
|
-
-
|
|
75
|
+
- 项目配置、项目级路径解析与项目初始化
|
|
76
|
+
- `project/` 收口 agent 项目脚手架与初始化结果类型
|
|
77
|
+
- 负责 `downcity.json`、项目 env、`.downcity/*` 路径规则与 execution binding
|
|
111
78
|
|
|
112
|
-
- `src/
|
|
113
|
-
- Agent
|
|
114
|
-
- `
|
|
115
|
-
- `
|
|
116
|
-
- daemon 进程启停、pid 清理、registry 同步等平台级管理职责属于 `@downcity/city`。
|
|
117
|
-
|
|
118
|
-
- `src/types/`
|
|
119
|
-
- 跨模块、跨包共享协议类型。
|
|
120
|
-
- `common/` 放 JSON、模板等基础类型。
|
|
121
|
-
- `config/` 放 `downcity.json`、execution binding、LLM、start options 等配置类型。
|
|
122
|
-
- `host/`、`platform/`、`daemon/`、`rpc/`、`auth/`、`http/` 放 city/agent 共享控制面协议。
|
|
123
|
-
- 领域内部类型仍保留在对应领域目录,例如 `service/types/`、`plugin/types/`、`session/types/`。
|
|
79
|
+
- `src/core/`
|
|
80
|
+
- 单 Agent 装配中心
|
|
81
|
+
- `AgentCore` 负责把 config、session、service、plugin、runtime 组装成一个实例级执行内核
|
|
82
|
+
- `AgentContext` 提供统一能力面,供 session / service / plugin 复用
|
|
124
83
|
|
|
125
84
|
- `src/sdk/`
|
|
126
|
-
- 本地 SDK facade
|
|
127
|
-
- 包括 `Agent`、`RemoteAgent`、`
|
|
128
|
-
- `Agent.ts`
|
|
129
|
-
- `
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
-
|
|
133
|
-
- `
|
|
134
|
-
- `
|
|
135
|
-
|
|
136
|
-
- `
|
|
137
|
-
-
|
|
138
|
-
- `http/` 是 HTTP server 与路由,包含 `control / execute / services / plugins / health / static`。
|
|
139
|
-
- `rpc/` 是本机 local RPC server。
|
|
140
|
-
|
|
141
|
-
- `src/transport/`
|
|
142
|
-
- agent 调用端 transport 协议。
|
|
143
|
-
- `rpc/` 放 local RPC client、endpoint path、transport 选择器与协议类型。
|
|
144
|
-
|
|
145
|
-
- `src/model/`
|
|
146
|
-
- 模型创建与模型运行辅助。
|
|
85
|
+
- 本地 SDK facade
|
|
86
|
+
- 包括 `Agent`、`RemoteAgent`、`Session` 与 `sdk/session/*`
|
|
87
|
+
- `Agent.ts` 通过 `start()/stop()` 统一收口长期运行生命周期
|
|
88
|
+
- `sdk/session/*` 负责 SDK session metadata、落盘路径、持久化与 service 端口适配
|
|
89
|
+
|
|
90
|
+
- `src/runtime/`
|
|
91
|
+
- 单 Agent 的运行时实现细节层
|
|
92
|
+
- `host/` 放宿主注入能力与 daemon 协议
|
|
93
|
+
- `sandbox/` 放命令执行隔离与沙箱协议
|
|
94
|
+
- `server/` 放 HTTP / RPC 服务端实现
|
|
95
|
+
- `transport/` 放 agent client 侧 transport 协议与 RPC client
|
|
96
|
+
- 模型实例解析不在 `agent` 包内完成,而由宿主先创建 `LanguageModel` 再通过 `session.set({ model })` 注入
|
|
147
97
|
|
|
148
98
|
- `src/plugin/`
|
|
149
|
-
-
|
|
150
|
-
- `core/` 负责注册、启用态、hook 调度、本地 action
|
|
151
|
-
- `builtins/` 放 `auth`、`skill`、`web`、`asr`、`tts`、`voice`、`workboard`
|
|
152
|
-
- `types/`
|
|
99
|
+
- 插件框架与内建插件
|
|
100
|
+
- `core/` 负责注册、启用态、hook 调度、本地 action
|
|
101
|
+
- `builtins/` 放 `auth`、`skill`、`web`、`asr`、`tts`、`voice`、`workboard` 等内建插件
|
|
102
|
+
- `types/` 放插件公共协议类型
|
|
153
103
|
|
|
154
104
|
- `src/service/`
|
|
155
|
-
- 单 Agent service
|
|
156
|
-
- `core/` 负责 service class 注册、状态控制、action
|
|
157
|
-
- `
|
|
158
|
-
- `
|
|
159
|
-
- `types/` 放 service
|
|
105
|
+
- 单 Agent service 域
|
|
106
|
+
- `core/` 负责 service class 注册、状态控制、action 调度与系统提示
|
|
107
|
+
- `core/schedule/` 负责持久化 service action 调度基础设施
|
|
108
|
+
- `builtins/` 放 `chat`、`contact`、`task`、`memory`、`shell` 等内建 service
|
|
109
|
+
- `types/` 放 service 公共协议类型
|
|
160
110
|
|
|
161
111
|
- `src/session/`
|
|
162
|
-
-
|
|
163
|
-
- `Session
|
|
164
|
-
-
|
|
165
|
-
- `
|
|
166
|
-
-
|
|
167
|
-
- `executors/local/SessionModelMessageState.ts` 维护 session/model 双消息基线。
|
|
168
|
-
- `executors/local/SessionUiStreamCollector.ts` 收敛 UI stream 最终 assistant 消息。
|
|
169
|
-
- `executors/local/SessionExecutionError.ts` 归一化 stream/provider 错误。
|
|
170
|
-
- `composer/` 负责 history、system、execution、compaction 的组合。
|
|
171
|
-
- `messages/` 负责消息编码、附件映射与 step event 映射。
|
|
172
|
-
- `tools/` 放 session 可用工具定义。
|
|
173
|
-
|
|
174
|
-
- `src/sandbox/`
|
|
175
|
-
- 命令执行沙箱。
|
|
176
|
-
- shell/task 等执行最终通过这里进入受限环境。
|
|
177
|
-
|
|
178
|
-
- `src/utils/`
|
|
179
|
-
- 包内通用工具、日志、CLI 输出、基础 JSON/Template 类型。
|
|
180
|
-
|
|
181
|
-
## 模块核心与调用逻辑
|
|
112
|
+
- 会话执行内核
|
|
113
|
+
- `Session` 是 SDK 用户面对的会话整体,`Executor` 是单轮 run 的执行引擎
|
|
114
|
+
- Store 负责 history 事实源落盘,Composer 是纯 interface 协议,负责组装 system / history / context / compaction
|
|
115
|
+
- `Executor.prepareExecuteInput()` 串起四类 Composer,`Executor.runCoreEngine()` 负责进入模型 tool loop
|
|
116
|
+
- 负责 history、system、context、CoreEngine、stream 与消息持久化
|
|
182
117
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
各模块的核心定位如下:
|
|
192
|
-
|
|
193
|
-
| 模块 | 核心 | 主要输入 | 主要输出 |
|
|
194
|
-
| --- | --- | --- | --- |
|
|
195
|
-
| `index.ts` | 公共 API 边界 | 包内稳定能力 | `@downcity/agent` 根入口导出 |
|
|
196
|
-
| `runtime/` | 单 Agent 装配中枢 | 项目路径、host 端口、config | `AgentRuntime`、`AgentContext`、session/service/plugin runtime |
|
|
197
|
-
| `project/` | 项目准备 | rootPath、execution binding | 项目骨架、默认配置、初始化结果 |
|
|
198
|
-
| `config/` | 项目配置解析 | `downcity.json`、env、默认值 | 标准化 config、项目路径能力 |
|
|
199
|
-
| `host/` | 宿主端口 | city/platform 注入能力 | platform gateway、store、plugin config runtime、daemon client |
|
|
200
|
-
| `server/` | 服务端入口 | HTTP/RPC 请求 | session/service/plugin/control 调用 |
|
|
201
|
-
| `transport/` | 调用端连接 | endpoint path、RPC 配置 | local RPC client / transport |
|
|
202
|
-
| `sdk/` | 用户侧 facade | 本地/远程 agent 目标 | `Agent`、`RemoteAgent`、`Session` API |
|
|
203
|
-
| `session/` | 对话执行内核 | 用户输入、system、history、tools | 模型响应、tool events、assistant history |
|
|
204
|
-
| `service/` | 长生命周期能力 | service action、schedule、外部事件 | chat/task/memory/contact/shell 等能力结果 |
|
|
205
|
-
| `plugin/` | 横切扩展点 | hooks、actions、project plugin config | system prompt、入站增强、工具/action 能力 |
|
|
206
|
-
| `model/` | 模型实例层 | model binding、provider config | AI SDK model / provider runtime |
|
|
207
|
-
| `sandbox/` | 命令执行隔离 | shell command、sandbox policy | 受限执行结果 |
|
|
208
|
-
| `types/` | 共享协议层 | 跨模块/跨包结构 | 稳定类型契约 |
|
|
209
|
-
| `utils/` | 基础工具层 | 日志、文件、CLI、模板输入 | 通用辅助能力 |
|
|
210
|
-
|
|
211
|
-
### 依赖方向图
|
|
212
|
-
|
|
213
|
-
```mermaid
|
|
214
|
-
flowchart TB
|
|
215
|
-
City["@downcity/city\n多 Agent 管理 / CLI / control plane"]
|
|
216
|
-
Public["@downcity/agent index.ts\n公共 API 边界"]
|
|
217
|
-
SDK["sdk/\n用户侧 facade"]
|
|
218
|
-
Server["server/\nHTTP / RPC server"]
|
|
219
|
-
Transport["transport/\nclient RPC transport"]
|
|
220
|
-
Runtime["runtime/\nAgentRuntime / AgentContext"]
|
|
221
|
-
Host["host/\n宿主端口 / daemon client"]
|
|
222
|
-
Project["project/\n项目初始化"]
|
|
223
|
-
Config["config/\n配置与路径"]
|
|
224
|
-
Session["session/\n会话执行内核"]
|
|
225
|
-
Service["service/\n内建服务与调度"]
|
|
226
|
-
Plugin["plugin/\n插件系统与 hooks"]
|
|
227
|
-
Model["model/\n模型创建与管理"]
|
|
228
|
-
Sandbox["sandbox/\n命令隔离执行"]
|
|
229
|
-
Types["types/\n共享协议类型"]
|
|
230
|
-
Utils["utils/\n日志 / 存储 / CLI"]
|
|
231
|
-
|
|
232
|
-
City --> Public
|
|
233
|
-
Public --> SDK
|
|
234
|
-
Public --> Runtime
|
|
235
|
-
Public --> Server
|
|
236
|
-
Public --> Types
|
|
237
|
-
|
|
238
|
-
SDK --> Transport
|
|
239
|
-
SDK --> Server
|
|
240
|
-
Transport --> Server
|
|
241
|
-
Server --> Runtime
|
|
242
|
-
|
|
243
|
-
Runtime --> Host
|
|
244
|
-
Runtime --> Project
|
|
245
|
-
Runtime --> Config
|
|
246
|
-
Runtime --> Session
|
|
247
|
-
Runtime --> Service
|
|
248
|
-
Runtime --> Plugin
|
|
249
|
-
Runtime --> Model
|
|
250
|
-
|
|
251
|
-
Session --> Model
|
|
252
|
-
Session --> Plugin
|
|
253
|
-
Session --> Sandbox
|
|
254
|
-
Service --> Session
|
|
255
|
-
Service --> Plugin
|
|
256
|
-
Service --> Sandbox
|
|
257
|
-
Plugin --> Service
|
|
258
|
-
|
|
259
|
-
Host --> Types
|
|
260
|
-
Server --> Types
|
|
261
|
-
Runtime --> Types
|
|
262
|
-
Session --> Types
|
|
263
|
-
Service --> Types
|
|
264
|
-
Plugin --> Types
|
|
265
|
-
|
|
266
|
-
Runtime --> Utils
|
|
267
|
-
Session --> Utils
|
|
268
|
-
Service --> Utils
|
|
269
|
-
Plugin --> Utils
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
方向约定:
|
|
273
|
-
|
|
274
|
-
- `city` 只能依赖 `@downcity/agent` 根入口,不直接导入 `src/*` 内部模块。
|
|
275
|
-
- `runtime` 是单 Agent 的装配中心,`server`、`sdk`、`service` 都通过它取得执行能力。
|
|
276
|
-
- `service` 是长生命周期业务能力,`plugin` 是横切扩展点,两者通过 `AgentContext` 协作。
|
|
277
|
-
- `session` 只关心一次会话执行,不直接承担 HTTP、daemon、registry、平台管理职责。
|
|
278
|
-
- `types` 只放跨模块共享协议;模块私有类型留在本模块 `types/` 下。
|
|
279
|
-
|
|
280
|
-
### Runtime 装配图
|
|
281
|
-
|
|
282
|
-
```mermaid
|
|
283
|
-
flowchart LR
|
|
284
|
-
Root["项目 rootPath"]
|
|
285
|
-
HostPorts["host ports\nplatform / store / plugin config"]
|
|
286
|
-
ConfigLoader["config/\nloadDowncityConfig"]
|
|
287
|
-
ProjectSetup["project/\nensureRuntimeProjectReady"]
|
|
288
|
-
ModelFactory["model/\ncreateModel"]
|
|
289
|
-
PluginManager["plugin/core\nPluginManager"]
|
|
290
|
-
ServiceManager["service/core\nServiceManager"]
|
|
291
|
-
SessionFactory["session/\nSession factory"]
|
|
292
|
-
Runtime["AgentRuntime"]
|
|
293
|
-
Context["AgentContext"]
|
|
294
|
-
|
|
295
|
-
Root --> ProjectSetup
|
|
296
|
-
Root --> ConfigLoader
|
|
297
|
-
HostPorts --> Runtime
|
|
298
|
-
ProjectSetup --> Runtime
|
|
299
|
-
ConfigLoader --> Runtime
|
|
300
|
-
ModelFactory --> Runtime
|
|
301
|
-
PluginManager --> Runtime
|
|
302
|
-
ServiceManager --> Runtime
|
|
303
|
-
SessionFactory --> Runtime
|
|
304
|
-
Runtime --> Context
|
|
305
|
-
|
|
306
|
-
Context -->|"invoke service"| ServiceManager
|
|
307
|
-
Context -->|"run plugin hooks"| PluginManager
|
|
308
|
-
Context -->|"get session"| SessionFactory
|
|
309
|
-
Context -->|"read config/model/rootPath"| Runtime
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
`AgentRuntime` 的核心是“装配与持有状态”,`AgentContext` 的核心是“给 session/service/plugin 提供统一能力面”。多数模块不直接互相 new 对方,而是通过 `AgentContext` 调用,避免形成隐式耦合。
|
|
313
|
-
|
|
314
|
-
### Agent 启动时序
|
|
315
|
-
|
|
316
|
-
```mermaid
|
|
317
|
-
sequenceDiagram
|
|
318
|
-
participant City as city CLI / daemon
|
|
319
|
-
participant Runtime as initAgentRuntime
|
|
320
|
-
participant Project as project/
|
|
321
|
-
participant Config as config/
|
|
322
|
-
participant Model as model/
|
|
323
|
-
participant Plugin as plugin/core
|
|
324
|
-
participant Service as service/core
|
|
325
|
-
participant Server as server/http + server/rpc
|
|
326
|
-
|
|
327
|
-
City->>Runtime: start agent(rootPath, host ports)
|
|
328
|
-
Runtime->>Project: ensureRuntimeProjectReady()
|
|
329
|
-
Project-->>Runtime: project ready
|
|
330
|
-
Runtime->>Config: loadDowncityConfig() + env
|
|
331
|
-
Config-->>Runtime: normalized config
|
|
332
|
-
Runtime->>Model: createModel()
|
|
333
|
-
Model-->>Runtime: model runtime
|
|
334
|
-
Runtime->>Plugin: initializePluginManager()
|
|
335
|
-
Plugin-->>Runtime: plugin hooks/actions ready
|
|
336
|
-
Runtime->>Service: createRegisteredServiceInstances()
|
|
337
|
-
Service-->>Runtime: service instances ready
|
|
338
|
-
Runtime->>Server: startServer() / startLocalRpcServer()
|
|
339
|
-
Server-->>City: HTTP/RPC endpoints ready
|
|
340
|
-
Runtime->>Service: startAllServices() + schedule runtime
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
### Session 执行时序
|
|
344
|
-
|
|
345
|
-
```mermaid
|
|
346
|
-
sequenceDiagram
|
|
347
|
-
participant Input as HTTP / RPC / SDK / Service
|
|
348
|
-
participant Runtime as AgentRuntime
|
|
349
|
-
participant Session as Session
|
|
350
|
-
participant Executor as LocalSessionExecutor
|
|
351
|
-
participant Core as LocalSessionCore
|
|
352
|
-
participant Composer as composer/
|
|
353
|
-
participant Runner as SessionToolLoopRunner
|
|
354
|
-
participant Model as model provider
|
|
355
|
-
participant Tools as session/tools + services
|
|
356
|
-
participant History as history writer
|
|
357
|
-
|
|
358
|
-
Input->>Runtime: getSession(sessionId)
|
|
359
|
-
Runtime-->>Input: Session
|
|
360
|
-
Input->>Session: run(user input)
|
|
361
|
-
Session->>Executor: execute()
|
|
362
|
-
Executor->>Core: run()
|
|
363
|
-
Core->>Composer: compose system/history/execution input
|
|
364
|
-
Composer-->>Core: model messages + tools + metadata
|
|
365
|
-
Core->>Runner: run tool loop
|
|
366
|
-
Runner->>Model: stream/generate response
|
|
367
|
-
Model-->>Runner: assistant text / tool calls / events
|
|
368
|
-
Runner->>Tools: execute tool calls
|
|
369
|
-
Tools-->>Runner: tool results
|
|
370
|
-
Runner->>Model: continue when needed
|
|
371
|
-
Runner-->>Core: final assistant message
|
|
372
|
-
Core->>History: append assistant step
|
|
373
|
-
History-->>Session: persisted
|
|
374
|
-
Session-->>Input: execution result / stream events
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
Session 这一层的核心拆分:
|
|
378
|
-
|
|
379
|
-
- `Session.ts`:单 session 外壳,负责并发保护、append assistant、executor 缓存。
|
|
380
|
-
- `LocalSessionExecutor.ts`:执行器装配,把 model/history/system/execution/compaction composer 接起来。
|
|
381
|
-
- `LocalSessionCore.ts`:一次 run 的协调层,负责准备输入、错误恢复、最终 assistant 收敛。
|
|
382
|
-
- `SessionToolLoopRunner.ts`:模型响应与 tool call 的循环执行。
|
|
383
|
-
- `SessionModelMessageState.ts`:维护 session 消息与 model 消息两份基线。
|
|
384
|
-
- `SessionUiStreamCollector.ts`:把 UI stream 中的 assistant 内容收敛为最终消息。
|
|
385
|
-
|
|
386
|
-
### Service 调用图
|
|
387
|
-
|
|
388
|
-
```mermaid
|
|
389
|
-
flowchart TB
|
|
390
|
-
Caller["调用方\nHTTP / RPC / Session tool / Plugin / SDK"]
|
|
391
|
-
Context["AgentContext.invoke"]
|
|
392
|
-
Runner["service/core/ServiceActionRunner"]
|
|
393
|
-
State["service/core/ServiceStateController"]
|
|
394
|
-
Manager["service/core/ServiceManager"]
|
|
395
|
-
Builtins["service/builtins/*\nchat / task / memory / contact / shell"]
|
|
396
|
-
Schedule["service/schedule\n持久化计划调度"]
|
|
397
|
-
Sandbox["sandbox/\n命令执行隔离"]
|
|
398
|
-
Session["session/\n需要 agent 回复时进入会话"]
|
|
399
|
-
|
|
400
|
-
Caller --> Context
|
|
401
|
-
Context --> Runner
|
|
402
|
-
Runner --> State
|
|
403
|
-
State --> Manager
|
|
404
|
-
Manager --> Builtins
|
|
405
|
-
Builtins --> Schedule
|
|
406
|
-
Builtins --> Sandbox
|
|
407
|
-
Builtins --> Session
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
Service 的核心是“长期存在的业务能力”。例如:
|
|
411
|
-
|
|
412
|
-
- `chat` 接 IM 渠道、入站队列、上下文映射与回复分发。
|
|
413
|
-
- `task` 接 cron / manual run,把任务执行转成 session 或 service action。
|
|
414
|
-
- `memory` 提供长期记忆读写。
|
|
415
|
-
- `shell` 提供命令执行 action,最终落到 `sandbox`。
|
|
416
|
-
- `contact` 提供联系人、分享与远程协作相关能力。
|
|
417
|
-
|
|
418
|
-
### Chat 入站执行图
|
|
419
|
-
|
|
420
|
-
```mermaid
|
|
421
|
-
flowchart TB
|
|
422
|
-
Channel["IM 平台\nTelegram / Feishu / QQ"]
|
|
423
|
-
Bot["channels/* 门面\n生命周期 / 发送 / 命令入口"]
|
|
424
|
-
Handler["*MessageHandler\n入站解析 / 授权 / 附件 / 入队"]
|
|
425
|
-
Base["BaseChatChannel\n授权 / audit / exec queue"]
|
|
426
|
-
Queue["chat/runtime queue\nlane / worker / store"]
|
|
427
|
-
Plugins["plugin hooks\n入站增强 / 权限 / system"]
|
|
428
|
-
Session["Session.run\nagent 执行"]
|
|
429
|
-
Reply["ReplyDispatch\n平台回复 / fallback"]
|
|
430
|
-
|
|
431
|
-
Channel --> Bot
|
|
432
|
-
Bot --> Handler
|
|
433
|
-
Handler --> Base
|
|
434
|
-
Base --> Queue
|
|
435
|
-
Queue --> Plugins
|
|
436
|
-
Queue --> Session
|
|
437
|
-
Session --> Reply
|
|
438
|
-
Reply --> Bot
|
|
439
|
-
Bot --> Channel
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
Chat 渠道的拆分原则:
|
|
443
|
-
|
|
444
|
-
- `Bot.ts` / `QQ.ts` / `Feishu.ts` 只做渠道门面:启动、停止、发送、命令入口、平台 client 装配。
|
|
445
|
-
- `*MessageHandler.ts` 做入站主流程:去重、授权、附件、reply context、执行入队。
|
|
446
|
-
- `*PlatformClient.ts` 做平台连接和 API:polling、WebSocket、token、上传下载、发送。
|
|
447
|
-
- `*Inbound.ts` / `*Support.ts` 做纯解析和归一化辅助。
|
|
448
|
-
|
|
449
|
-
### Plugin 调用图
|
|
450
|
-
|
|
451
|
-
```mermaid
|
|
452
|
-
flowchart LR
|
|
453
|
-
Runtime["AgentRuntime"]
|
|
454
|
-
Registry["plugin/core/PluginRegistry"]
|
|
455
|
-
Manager["plugin/core/PluginManager"]
|
|
456
|
-
Builtins["plugin/builtins/*"]
|
|
457
|
-
Hooks["hooks\nsystem / augmentInbound / auth / tool"]
|
|
458
|
-
Actions["actions\nCLI / HTTP / service action"]
|
|
459
|
-
Context["AgentContext.plugins"]
|
|
460
|
-
Session["session composer / execution"]
|
|
461
|
-
Service["service runtime"]
|
|
462
|
-
|
|
463
|
-
Runtime --> Registry
|
|
464
|
-
Registry --> Builtins
|
|
465
|
-
Runtime --> Manager
|
|
466
|
-
Manager --> Hooks
|
|
467
|
-
Manager --> Actions
|
|
468
|
-
Context --> Manager
|
|
469
|
-
Hooks --> Session
|
|
470
|
-
Hooks --> Service
|
|
471
|
-
Actions --> Service
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
Plugin 的核心是“横切扩展”。它不应该接管主流程,而是在稳定点位上增强:
|
|
475
|
-
|
|
476
|
-
- `system` hook:给 session system prompt 增加能力说明。
|
|
477
|
-
- `augmentInbound` hook:增强 chat 入站消息,例如 ASR 把音频转写成文本。
|
|
478
|
-
- auth / policy hook:参与权限判断。
|
|
479
|
-
- action:暴露给 CLI、HTTP 或 service 的可调用能力。
|
|
480
|
-
|
|
481
|
-
### Server / SDK / Transport 图
|
|
482
|
-
|
|
483
|
-
```mermaid
|
|
484
|
-
flowchart TB
|
|
485
|
-
User["用户代码 / CLI / city"]
|
|
486
|
-
SDK["sdk/\nAgent / RemoteAgent / Session"]
|
|
487
|
-
Transport["transport/rpc\nlocal RPC client"]
|
|
488
|
-
HTTP["server/http\nREST/control routes"]
|
|
489
|
-
RPC["server/rpc\nlocal RPC server"]
|
|
490
|
-
Runtime["AgentRuntime"]
|
|
491
|
-
Session["session"]
|
|
492
|
-
Service["service"]
|
|
493
|
-
Plugin["plugin"]
|
|
494
|
-
|
|
495
|
-
User --> SDK
|
|
496
|
-
User --> HTTP
|
|
497
|
-
SDK --> Transport
|
|
498
|
-
Transport --> RPC
|
|
499
|
-
HTTP --> Runtime
|
|
500
|
-
RPC --> Runtime
|
|
501
|
-
Runtime --> Session
|
|
502
|
-
Runtime --> Service
|
|
503
|
-
Runtime --> Plugin
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
这条链的边界是:
|
|
507
|
-
|
|
508
|
-
- SDK 是调用方友好的 facade,不承担 runtime 状态。
|
|
509
|
-
- transport 是 client 侧连接协议,不承担业务执行。
|
|
510
|
-
- server 是 agent 内部入口适配层,不直接放业务规则。
|
|
511
|
-
- 真正业务执行都回到 `AgentRuntime`、`Session`、`Service`、`Plugin`。
|
|
512
|
-
|
|
513
|
-
### SDK 本地 Session 图
|
|
514
|
-
|
|
515
|
-
```mermaid
|
|
516
|
-
flowchart TB
|
|
517
|
-
User["用户代码\nnew Agent().session()"]
|
|
518
|
-
Agent["sdk/Agent.ts\n本地 facade / runtime 装配"]
|
|
519
|
-
SdkSession["sdk/Session.ts\nset / run / stream / fork / history"]
|
|
520
|
-
Persistence["sdk/SessionPersistence.ts\nmeta / assistant 落盘"]
|
|
521
|
-
Stream["sdk/StreamEvents.ts\nUI chunk -> SDK event"]
|
|
522
|
-
ServicePort["sdk/SessionServicePort.ts\nSessionPort adapter"]
|
|
523
|
-
CoreSession["session/Session.ts\n核心 session 外壳"]
|
|
524
|
-
Executor["session/executors/local\nLocalSessionExecutor / Core"]
|
|
525
|
-
ChatService["service/builtins/chat\nqueue worker / channel reply"]
|
|
526
|
-
History["session/composer/history\nJSONL history"]
|
|
527
|
-
|
|
528
|
-
User --> Agent
|
|
529
|
-
Agent --> SdkSession
|
|
530
|
-
SdkSession --> CoreSession
|
|
531
|
-
CoreSession --> Executor
|
|
532
|
-
SdkSession --> Persistence
|
|
533
|
-
SdkSession --> Stream
|
|
534
|
-
SdkSession --> ServicePort
|
|
535
|
-
ServicePort --> ChatService
|
|
536
|
-
Persistence --> History
|
|
537
|
-
CoreSession --> History
|
|
538
|
-
```
|
|
539
|
-
|
|
540
|
-
本地 SDK 的核心是“对用户友好的 facade + 对内部 runtime 的轻量适配”:
|
|
541
|
-
|
|
542
|
-
- `Session.ts` 保持门面职责,负责参数校验、调用底层 session、产出 SDK 结果。
|
|
543
|
-
- `SessionPersistence.ts` 统一处理 meta 更新时间、模型标签与 assistant 最终消息持久化。
|
|
544
|
-
- `StreamEvents.ts` 统一处理 stream chunk 事件映射和 toolCallId 到 toolName 的短生命周期状态。
|
|
545
|
-
- `SessionServicePort.ts` 只做端口适配,让 chat service 复用底层 session 协议,不重复走 SDK `run()` 包装层。
|
|
546
|
-
|
|
547
|
-
### Sandbox 调用图
|
|
548
|
-
|
|
549
|
-
```mermaid
|
|
550
|
-
sequenceDiagram
|
|
551
|
-
participant Tool as shell tool / shell service / task
|
|
552
|
-
participant Resolver as SandboxConfigResolver
|
|
553
|
-
participant Runner as SandboxRunner
|
|
554
|
-
participant Seatbelt as MacOsSeatbeltSandbox
|
|
555
|
-
participant Process as child process
|
|
556
|
-
|
|
557
|
-
Tool->>Resolver: resolve sandbox policy
|
|
558
|
-
Resolver-->>Tool: command + cwd + env + restrictions
|
|
559
|
-
Tool->>Runner: run(command, policy)
|
|
560
|
-
Runner->>Seatbelt: wrap command when needed
|
|
561
|
-
Seatbelt-->>Runner: sandboxed command
|
|
562
|
-
Runner->>Process: spawn
|
|
563
|
-
Process-->>Runner: stdout / stderr / exit code
|
|
564
|
-
Runner-->>Tool: normalized result
|
|
565
|
-
```
|
|
118
|
+
- `src/types/`
|
|
119
|
+
- 跨模块、跨包共享协议类型
|
|
120
|
+
- `common/` 放 JSON、模板等无领域依赖的基础类型
|
|
121
|
+
- `config/` 放 `downcity.json`、LLM、execution binding、start options 等配置契约
|
|
122
|
+
- `runtime/` 放 auth、daemon、host、http、platform、rpc 等运行时与控制面共享协议
|
|
123
|
+
- 领域内部类型仍保留在对应领域目录,例如 `service/types/`、`plugin/types/`、`session/types/`
|
|
566
124
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
### 生命周期状态图
|
|
570
|
-
|
|
571
|
-
```mermaid
|
|
572
|
-
stateDiagram-v2
|
|
573
|
-
[*] --> ProjectReady: project/
|
|
574
|
-
ProjectReady --> ConfigLoaded: config/
|
|
575
|
-
ConfigLoaded --> RuntimeCreated: runtime/
|
|
576
|
-
RuntimeCreated --> PluginsReady: plugin/core
|
|
577
|
-
PluginsReady --> ServicesReady: service/core
|
|
578
|
-
ServicesReady --> ServersReady: server/http + server/rpc
|
|
579
|
-
ServersReady --> Running: start services + schedules
|
|
580
|
-
Running --> Running: session/service/plugin calls
|
|
581
|
-
Running --> Stopping: stop requested
|
|
582
|
-
Stopping --> [*]: stop services + close servers
|
|
583
|
-
```
|
|
125
|
+
- `src/utils/`
|
|
126
|
+
- 包内通用工具、日志、CLI 输出与存储辅助
|
|
584
127
|
|
|
585
|
-
##
|
|
128
|
+
## 模块核心与依赖方向
|
|
586
129
|
|
|
587
|
-
|
|
130
|
+
`@downcity/agent` 的核心是一条单 Agent 执行链:
|
|
588
131
|
|
|
589
132
|
```text
|
|
590
|
-
|
|
591
|
-
-> @downcity/city cli/agent/Run.ts
|
|
592
|
-
-> initAgentRuntime()
|
|
593
|
-
-> ensureRuntimeProjectReady()
|
|
594
|
-
-> loadDowncityConfig() / load env / load static prompts
|
|
595
|
-
-> createModel()
|
|
596
|
-
-> create session factory
|
|
597
|
-
-> createRegisteredServiceInstances()
|
|
598
|
-
-> initializePluginManager()
|
|
599
|
-
-> startServer() / startLocalRpcServer()
|
|
600
|
-
-> startAllServices() / startServiceScheduleRuntime()
|
|
133
|
+
入口协议 -> AgentCore -> AgentContext -> Session / Service / Plugin -> Runtime 子系统 -> History / Reply
|
|
601
134
|
```
|
|
602
135
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
- `src/runtime/AgentRuntime.ts`
|
|
606
|
-
- `src/runtime/AgentContext.ts`
|
|
607
|
-
- `src/server/http/Server.ts`
|
|
608
|
-
- `src/server/rpc/Server.ts`
|
|
136
|
+
其中:
|
|
609
137
|
|
|
610
|
-
|
|
138
|
+
- `sdk` 是用户 API 面
|
|
139
|
+
- `core` 是实例级装配中心
|
|
140
|
+
- `session / service / plugin` 是三大领域子系统
|
|
141
|
+
- `runtime` 是 server / transport / sandbox / host 这类实现细节的统一容器
|
|
142
|
+
- `types / utils` 提供横向公共支撑
|
|
611
143
|
|
|
612
|
-
|
|
613
|
-
外部输入
|
|
614
|
-
-> HTTP / RPC / service / SDK
|
|
615
|
-
-> AgentRuntime.getSession(sessionId)
|
|
616
|
-
-> Session.run()
|
|
617
|
-
-> LocalSessionExecutor
|
|
618
|
-
-> LocalSessionCore
|
|
619
|
-
-> model / tools / system / history / compaction
|
|
620
|
-
-> assistant message 持久化与回调
|
|
621
|
-
```
|
|
144
|
+
## 当前推荐启动方式
|
|
622
145
|
|
|
623
|
-
|
|
146
|
+
本地嵌入时:
|
|
624
147
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
-
|
|
628
|
-
- `src/session/executors/local/SessionToolLoopRunner.ts`
|
|
148
|
+
```ts
|
|
149
|
+
import { Agent } from "@downcity/agent";
|
|
150
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
629
151
|
|
|
630
|
-
|
|
152
|
+
const openai = createOpenAI({
|
|
153
|
+
apiKey: process.env.OPENAI_API_KEY!,
|
|
154
|
+
});
|
|
631
155
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
```
|
|
638
|
-
|
|
639
|
-
### Plugin 调用
|
|
640
|
-
|
|
641
|
-
```text
|
|
642
|
-
AgentContext.plugins
|
|
643
|
-
-> plugin/core/PluginManager.ts
|
|
644
|
-
-> plugin/core/PluginRegistry.ts
|
|
645
|
-
-> plugin/builtins/* 具体 plugin
|
|
646
|
-
```
|
|
156
|
+
const agent = new Agent({
|
|
157
|
+
id: "demo",
|
|
158
|
+
path: process.cwd(),
|
|
159
|
+
tools: {},
|
|
160
|
+
});
|
|
647
161
|
|
|
648
|
-
|
|
162
|
+
const session = await agent.session();
|
|
163
|
+
await session.set({
|
|
164
|
+
model: openai.responses("gpt-5"),
|
|
165
|
+
});
|
|
649
166
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
-> sandbox/SandboxRunner.ts
|
|
654
|
-
-> sandbox/MacOsSeatbeltSandbox.ts
|
|
167
|
+
const result = await session.run({
|
|
168
|
+
query: "总结一下当前仓库结构",
|
|
169
|
+
});
|
|
655
170
|
```
|
|
656
171
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
- 包外只从 `@downcity/agent` 根入口导入。
|
|
660
|
-
- `@downcity/agent/*` 子路径不是公共 API。
|
|
661
|
-
- `src/index.ts` 必须使用显式导出清单,不使用 `export *` 扩大公共面。
|
|
662
|
-
- 根入口只暴露 SDK、插件/服务作者 API、city 运行集成 API 与跨包协议类型。
|
|
663
|
-
- HTTP router、sandbox runner、内部 service runner 等实现细节不从根入口导出。
|
|
664
|
-
- 如果 `city` 需要新的 agent 能力,先补到 `src/index.ts`,再由 `city` 消费。
|
|
665
|
-
- `packages/city/scripts/lint-import-boundaries.mjs` 会检查 city 不直接依赖 agent 内部子路径。
|
|
666
|
-
|
|
667
|
-
## 后续整理方向
|
|
172
|
+
如果要把它暴露成长期运行实例:
|
|
668
173
|
|
|
669
|
-
|
|
174
|
+
```ts
|
|
175
|
+
const started = await agent.start({
|
|
176
|
+
http: {
|
|
177
|
+
host: "127.0.0.1",
|
|
178
|
+
port: 15314,
|
|
179
|
+
},
|
|
180
|
+
rpc: true,
|
|
181
|
+
});
|
|
670
182
|
|
|
671
|
-
|
|
672
|
-
src
|
|
673
|
-
├── runtime/ # AgentRuntime / AgentContext / runtime state
|
|
674
|
-
├── project/ # 初始化、execution binding、项目准备
|
|
675
|
-
├── server/ # http / rpc / auth / routes
|
|
676
|
-
├── transport/ # agent client transport 协议
|
|
677
|
-
├── sdk/ # SDK facade
|
|
678
|
-
├── session/
|
|
679
|
-
├── service/
|
|
680
|
-
├── plugin/
|
|
681
|
-
├── sandbox/
|
|
682
|
-
├── model/
|
|
683
|
-
├── config/
|
|
684
|
-
├── types/ # 跨模块共享类型
|
|
685
|
-
└── utils/
|
|
183
|
+
console.log(started.http?.baseUrl);
|
|
686
184
|
```
|
|
687
185
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
1. 将跨模块共享类型继续集中到 `src/types/`,模块私有类型保留在本模块 `types/` 下。
|
|
691
|
-
2. 大模块超过 800-1000 行时继续按职责拆分。
|
|
692
|
-
|
|
693
|
-
## 维护约定
|
|
186
|
+
也就是说:
|
|
694
187
|
|
|
695
|
-
-
|
|
696
|
-
-
|
|
697
|
-
- `
|
|
698
|
-
- `plugin/core` 和 `plugin/builtins` 必须保持边界清晰。
|
|
699
|
-
- `bin/` 是构建产物,不直接修改。
|
|
188
|
+
- 不调用 `start()`:library mode
|
|
189
|
+
- 调用 `start()`:long-lived runtime mode
|
|
190
|
+
- 模型由调用方创建并通过 `session.set({ model })` 注入,SDK 不提供默认模型策略
|