downcity 1.1.228 → 1.1.237
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/bin/city/agent/AgentChat.d.ts +1 -1
- package/bin/city/agent/AgentChat.js +4 -4
- package/bin/city/agent/AgentChatHelpers.d.ts +2 -2
- package/bin/city/agent/AgentChatHelpers.js +7 -7
- package/bin/city/agent/AgentChatInteractiveRenderer.d.ts +1 -1
- package/bin/city/agent/AgentChatInteractiveRenderer.js +2 -2
- package/bin/city/agent/AgentChatRemote.d.ts +1 -1
- package/bin/city/agent/AgentChatRemote.js +3 -3
- package/bin/city/agent/AgentChatToolFormatter.d.ts +1 -1
- package/bin/city/agent/AgentChatTui.d.ts +2 -2
- package/bin/city/agent/AgentChatTui.js +1 -1
- package/bin/city/agent/AgentHistory.d.ts +1 -1
- package/bin/city/agent/AgentHistory.js +5 -5
- package/bin/city/agent/AgentHttpGateway.js +6 -6
- package/bin/city/agent/AgentManager.d.ts.map +1 -1
- package/bin/city/agent/AgentManager.js +17 -13
- package/bin/city/agent/AgentManager.js.map +1 -1
- package/bin/city/agent/AgentManagerHelpers.d.ts +3 -3
- package/bin/city/agent/AgentManagerHelpers.d.ts.map +1 -1
- package/bin/city/agent/AgentManagerHelpers.js +101 -46
- package/bin/city/agent/AgentManagerHelpers.js.map +1 -1
- package/bin/city/agent/AgentReset.d.ts.map +1 -1
- package/bin/city/agent/AgentReset.js +8 -22
- package/bin/city/agent/AgentReset.js.map +1 -1
- package/bin/city/agent/AgentSelection.d.ts +1 -1
- package/bin/city/agent/AgentSelection.js +8 -8
- package/bin/city/agent/Init.js +6 -6
- package/bin/city/agent/Init.js.map +1 -1
- package/bin/city/agent/Restart.d.ts +1 -1
- package/bin/city/agent/Restart.js +8 -8
- package/bin/city/agent/Restart.js.map +1 -1
- package/bin/city/agent/Run.d.ts +1 -1
- package/bin/city/agent/Run.js +6 -6
- package/bin/city/agent/Start.d.ts +2 -2
- package/bin/city/agent/Start.js +7 -7
- package/bin/city/agent/Status.js +3 -3
- package/bin/city/agent/Stop.js +3 -3
- package/bin/city/agent/control/ExecuteBySession.d.ts +1 -1
- package/bin/city/agent/control/ExecuteBySession.js +1 -1
- package/bin/city/agent/control/ExecuteInput.d.ts +1 -1
- package/bin/city/agent/control/ExecuteInput.js +1 -1
- package/bin/city/agent/control/Helpers.d.ts +5 -5
- package/bin/city/agent/control/Helpers.js +5 -5
- package/bin/city/agent/control/MessageTimeline.d.ts +1 -1
- package/bin/city/agent/control/MessageTimeline.js +1 -1
- package/bin/city/agent/control/SessionSummaryStore.d.ts +1 -1
- package/bin/city/agent/control/SessionSummaryStore.js +3 -3
- package/bin/city/agent/control/TaskStore.d.ts +1 -1
- package/bin/city/agent/control/TaskStore.js +3 -3
- package/bin/city/agent/http/control/ControlApiRoutes.d.ts +1 -1
- package/bin/city/agent/http/control/ControlApiRoutes.js +4 -4
- package/bin/city/agent/http/control/ControlAuthorizationRoutes.js +1 -1
- package/bin/city/agent/http/control/ControlRouter.js +1 -1
- package/bin/city/agent/http/control/OverviewRoutes.d.ts +1 -1
- package/bin/city/agent/http/control/OverviewRoutes.js +2 -2
- package/bin/city/agent/http/control/SessionRoutes.d.ts +1 -1
- package/bin/city/agent/http/control/SessionRoutes.js +4 -4
- package/bin/city/agent/http/control/TaskRoutes.d.ts +1 -1
- package/bin/city/agent/http/control/TaskRoutes.js +3 -3
- package/bin/city/agent/http/static/static.js +1 -1
- package/bin/city/agent/tui/AgentChatTuiCoordinator.d.ts +2 -2
- package/bin/city/agent/tui/AgentChatTuiCoordinator.js +5 -5
- package/bin/city/agent/tui/PiTuiChatRenderer.d.ts +2 -2
- package/bin/city/agent/tui/PiTuiChatRenderer.js +1 -1
- package/bin/city/agent/tui/commands/dispatch.d.ts +2 -2
- package/bin/city/agent/tui/commands/index.d.ts +6 -6
- package/bin/city/agent/tui/commands/index.js +4 -4
- package/bin/city/agent/tui/commands/parse.d.ts +1 -1
- package/bin/city/agent/tui/commands/registry.d.ts +1 -1
- package/bin/city/agent/tui/commands/resolve.d.ts +1 -1
- package/bin/city/agent/tui/commands/resolve.js +1 -1
- package/bin/city/agent/tui/components/AssistantMessage.js +4 -4
- package/bin/city/agent/tui/components/ChatEditor.js +5 -5
- package/bin/city/agent/tui/components/MessageList.d.ts +1 -1
- package/bin/city/agent/tui/components/MessageList.js +7 -7
- package/bin/city/agent/tui/components/NoticeMessage.js +1 -1
- package/bin/city/agent/tui/components/StatusLine.d.ts +1 -1
- package/bin/city/agent/tui/components/StatusLine.js +2 -2
- package/bin/city/agent/tui/components/StatusMessage.d.ts +1 -1
- package/bin/city/agent/tui/components/StatusMessage.js +1 -1
- package/bin/city/agent/tui/components/ToolCallBlock.d.ts +1 -1
- package/bin/city/agent/tui/components/ToolCallBlock.js +3 -3
- package/bin/city/agent/tui/components/UserMessage.js +2 -2
- package/bin/city/agent/tui/components/editor/FileMentionProvider.d.ts +1 -1
- package/bin/city/agent/tui/components/editor/WrappingSelectList.js +1 -1
- package/bin/city/agent/tui/components/index.d.ts +6 -6
- package/bin/city/agent/tui/components/index.js +6 -6
- package/bin/city/agent/tui/controllers/StreamingUI.d.ts +1 -1
- package/bin/city/agent/tui/controllers/StreamingUI.js +3 -3
- package/bin/city/agent/tui/dialogs/SessionPicker.d.ts +1 -1
- package/bin/city/agent/tui/dialogs/SessionPicker.js +7 -7
- package/bin/city/agent/tui/index.d.ts +3 -3
- package/bin/city/agent/tui/index.js +2 -2
- package/bin/city/agent/tui/theme/index.d.ts +4 -4
- package/bin/city/agent/tui/theme/index.js +2 -2
- package/bin/city/agent/tui/theme/pi-tui-theme.js +1 -1
- package/bin/city/agent/tui/theme/theme.d.ts +1 -1
- package/bin/city/agent/tui/theme/theme.js +1 -1
- package/bin/city/command/AgentCommand.js +16 -16
- package/bin/city/command/ChatAuthCommand.js +4 -4
- package/bin/city/command/ChatCommand.js +3 -3
- package/bin/city/command/ConfigCommand.js +5 -5
- package/bin/city/command/EnvCommand.js +5 -5
- package/bin/city/command/FederationCommand.js +4 -4
- package/bin/city/command/GatewayCommand.d.ts +6 -9
- package/bin/city/command/GatewayCommand.d.ts.map +1 -1
- package/bin/city/command/GatewayCommand.js +15 -66
- package/bin/city/command/GatewayCommand.js.map +1 -1
- package/bin/city/command/ManagedPluginActionCommand.js +4 -4
- package/bin/city/command/PluginCommand.js +7 -7
- package/bin/city/command/PluginScheduleCommand.js +4 -4
- package/bin/city/command/TokenCommand.js +3 -3
- package/bin/city/command/plugin/PluginHelpers.d.ts.map +1 -1
- package/bin/city/command/plugin/PluginHelpers.js +13 -23
- package/bin/city/command/plugin/PluginHelpers.js.map +1 -1
- package/bin/city/command/token/TokenActions.js +3 -3
- package/bin/city/command/token/TokenPrompts.js +3 -3
- package/bin/city/command/token/TokenRender.js +2 -2
- package/bin/city/env/ProcessEnv.d.ts +7 -1
- package/bin/city/env/ProcessEnv.d.ts.map +1 -1
- package/bin/city/env/ProcessEnv.js +30 -3
- package/bin/city/env/ProcessEnv.js.map +1 -1
- package/bin/city/index.d.ts +1 -1
- package/bin/city/index.d.ts.map +1 -1
- package/bin/city/index.js +13 -14
- package/bin/city/index.js.map +1 -1
- package/bin/city/process/daemon/CliArgs.d.ts +1 -1
- package/bin/city/process/daemon/CliArgs.js +1 -1
- package/bin/city/process/daemon/Client.d.ts +1 -1
- package/bin/city/process/daemon/Client.js +2 -2
- package/bin/city/process/daemon/Manager.d.ts +1 -1
- package/bin/city/process/daemon/Manager.js +5 -5
- package/bin/city/process/registry/AgentHostRuntime.js +1 -1
- package/bin/city/process/registry/CityPaths.d.ts +4 -4
- package/bin/city/process/registry/CityPaths.js +4 -4
- package/bin/city/process/registry/CityRegistry.d.ts +1 -1
- package/bin/city/process/registry/CityRegistry.d.ts.map +1 -1
- package/bin/city/process/registry/CityRegistry.js +2 -7
- package/bin/city/process/registry/CityRegistry.js.map +1 -1
- package/bin/city/runtime/auth/AuthMiddleware.d.ts +1 -1
- package/bin/city/runtime/auth/AuthMiddleware.js +1 -1
- package/bin/city/runtime/auth/AuthRoutes.d.ts +1 -1
- package/bin/city/runtime/auth/AuthRoutes.js +3 -3
- package/bin/city/runtime/auth/AuthService.d.ts +1 -1
- package/bin/city/runtime/auth/AuthService.js +4 -4
- package/bin/city/runtime/auth/AuthStore.js +3 -3
- package/bin/city/runtime/auth/CliAuthStateStore.js +1 -1
- package/bin/city/runtime/auth/RoutePolicy.d.ts +2 -2
- package/bin/city/runtime/auth/RoutePolicy.js +2 -2
- package/bin/city/runtime/city-model/CityAiServiceBinding.js +1 -1
- package/bin/city/runtime/city-model/CreateRuntimeModel.js +1 -1
- package/bin/city/runtime/city-model/ExecutionModelBinding.d.ts +1 -1
- package/bin/city/runtime/city-model/ExecutionModelBinding.js +3 -3
- package/bin/city/runtime/gateway/runtime/GatewayInit.d.ts +1 -1
- package/bin/city/runtime/gateway/runtime/GatewayInit.js +5 -5
- package/bin/city/runtime/plugins/CityBuiltinPlugins.js +2 -2
- package/bin/city/runtime/store/StoreChannelAccountRepository.d.ts +1 -1
- package/bin/city/runtime/store/StoreChannelAccountRepository.js +2 -2
- package/bin/city/runtime/store/StoreEnvRepository.d.ts +1 -1
- package/bin/city/runtime/store/StoreEnvRepository.js +2 -2
- package/bin/city/runtime/store/StoreSchema.d.ts +1 -1
- package/bin/city/runtime/store/StoreSecureSettings.d.ts +1 -1
- package/bin/city/runtime/store/StoreSecureSettings.js +2 -2
- package/bin/city/runtime/store/crypto.js +1 -1
- package/bin/city/runtime/store/index.d.ts +1 -1
- package/bin/city/runtime/store/index.js +6 -6
- package/bin/city/shared/Alias.js +1 -1
- package/bin/city/shared/ChatManager.js +4 -4
- package/bin/city/shared/CityAgentRuntime.d.ts +2 -3
- package/bin/city/shared/CityAgentRuntime.d.ts.map +1 -1
- package/bin/city/shared/CityAgentRuntime.js +8 -16
- package/bin/city/shared/CityAgentRuntime.js.map +1 -1
- package/bin/city/shared/CityBalance.d.ts +1 -1
- package/bin/city/shared/CityBalance.js +2 -2
- package/bin/city/shared/CityManager.d.ts +1 -4
- package/bin/city/shared/CityManager.d.ts.map +1 -1
- package/bin/city/shared/CityManager.js +8 -16
- package/bin/city/shared/CityManager.js.map +1 -1
- package/bin/city/shared/CityStateStore.d.ts +4 -4
- package/bin/city/shared/CityStateStore.js +1 -1
- package/bin/city/shared/CityUserLogin.d.ts +1 -1
- package/bin/city/shared/CityUserLogin.js +2 -2
- package/bin/city/shared/CityUserManager.d.ts +1 -1
- package/bin/city/shared/CityUserManager.js +1 -1
- package/bin/city/shared/FederationConnection.d.ts +1 -1
- package/bin/city/shared/FederationConnection.js +7 -7
- package/bin/city/shared/InteractiveLocale.d.ts +1 -1
- package/bin/city/shared/InteractiveLocale.js +4 -4
- package/bin/city/shared/ManagedPluginRemote.js +3 -3
- package/bin/city/shared/PluginTargetSupport.d.ts +2 -3
- package/bin/city/shared/PluginTargetSupport.d.ts.map +1 -1
- package/bin/city/shared/PluginTargetSupport.js +7 -15
- package/bin/city/shared/PluginTargetSupport.js.map +1 -1
- package/bin/city/shared/Update.js +4 -4
- package/bin/city/shared/Update.js.map +1 -1
- package/bin/city/tui/CityDashboard.d.ts +4 -3
- package/bin/city/tui/CityDashboard.d.ts.map +1 -1
- package/bin/city/tui/CityDashboard.js +11 -44
- package/bin/city/tui/CityDashboard.js.map +1 -1
- package/bin/city/tui/FederationManagerFormat.d.ts +5 -5
- package/bin/city/tui/FederationManagerFormat.js +4 -4
- package/bin/city/tui/FederationManagerFormat.js.map +1 -1
- package/bin/city/tui/FederationManagerPrompts.d.ts +1 -1
- package/bin/city/tui/FederationManagerPrompts.js +3 -3
- package/bin/city/tui/FederationManagerState.d.ts +5 -5
- package/bin/city/tui/FederationManagerState.d.ts.map +1 -1
- package/bin/city/tui/FederationManagerState.js +8 -8
- package/bin/city/tui/FederationManagerTui.d.ts.map +1 -1
- package/bin/city/tui/FederationManagerTui.js +57 -34
- package/bin/city/tui/FederationManagerTui.js.map +1 -1
- package/bin/city/tui/Prompts.d.ts +2 -0
- package/bin/city/tui/Prompts.d.ts.map +1 -1
- package/bin/city/tui/Prompts.js +42 -15
- package/bin/city/tui/Prompts.js.map +1 -1
- package/bin/city/types/CityState.d.ts +2 -2
- package/bin/city/utils/cli/CliOutput.d.ts +1 -1
- package/bin/city/utils/cli/CliOutput.js +1 -1
- package/bin/downcity.d.ts +11 -0
- package/bin/downcity.d.ts.map +1 -0
- package/bin/downcity.js +25 -0
- package/bin/downcity.js.map +1 -0
- package/bin/downfed.d.ts +11 -0
- package/bin/downfed.d.ts.map +1 -0
- package/bin/downfed.js +25 -0
- package/bin/downfed.js.map +1 -0
- package/bin/federation/admin/commands/accounts.d.ts +1 -1
- package/bin/federation/admin/commands/accounts.js +2 -2
- package/bin/federation/admin/commands/balance.d.ts +1 -1
- package/bin/federation/admin/commands/balance.js +2 -2
- package/bin/federation/admin/commands/cities.d.ts +1 -1
- package/bin/federation/admin/commands/cities.js +2 -2
- package/bin/federation/admin/commands/config.d.ts +1 -1
- package/bin/federation/admin/commands/custom.d.ts +1 -1
- package/bin/federation/admin/commands/custom.js +2 -2
- package/bin/federation/admin/commands/instruction.d.ts +1 -1
- package/bin/federation/admin/commands/instruction.js +1 -1
- package/bin/federation/admin/commands/models.d.ts +1 -1
- package/bin/federation/admin/commands/models.js +2 -2
- package/bin/federation/admin/commands/payment.d.ts +1 -1
- package/bin/federation/admin/commands/payment.js +3 -3
- package/bin/federation/admin/commands/service-env.d.ts +1 -1
- package/bin/federation/admin/commands/service-env.js +2 -2
- package/bin/federation/admin/commands/usage.d.ts +1 -1
- package/bin/federation/admin/commands/usage.js +2 -2
- package/bin/federation/admin/loop.d.ts +2 -2
- package/bin/federation/admin/loop.js +12 -12
- package/bin/federation/app.js +11 -11
- package/bin/federation/auth/admin.d.ts +1 -1
- package/bin/federation/auth/admin.js +2 -2
- package/bin/federation/core/session.d.ts +1 -1
- package/bin/federation/core/session.js +1 -1
- package/bin/federation/core/stripe.js +1 -1
- package/bin/federation/core/ui.d.ts +1 -1
- package/bin/federation/core/ui.js +1 -1
- package/bin/federation/create/commands/create.js +4 -4
- package/bin/federation/deploy/commands/deploy.js +5 -5
- package/bin/federation/deploy/config/FederationDeployTargetResolver.d.ts +1 -1
- package/bin/federation/deploy/config/FederationDeployTargetResolver.js +1 -1
- package/bin/federation/deploy/config/FederationProjectConfigReader.d.ts +1 -1
- package/bin/federation/deploy/config/FederationProjectConfigReader.js +1 -1
- package/bin/federation/deploy/config/FederationProjectEnvLoader.d.ts +1 -1
- package/bin/federation/deploy/runtime/CloudflareAccountResolver.d.ts +1 -1
- package/bin/federation/deploy/runtime/CloudflareAccountResolver.js +5 -5
- package/bin/federation/deploy/runtime/CloudflareWorkersDeployer.d.ts +1 -1
- package/bin/federation/deploy/runtime/CloudflareWorkersDeployer.js +10 -10
- package/bin/federation/deploy/runtime/CommandRunner.js +1 -1
- package/bin/federation/deploy/runtime/D1DatabaseResolver.d.ts +1 -1
- package/bin/federation/deploy/runtime/D1DatabaseResolver.js +4 -4
- package/bin/federation/deploy/runtime/PackageScriptRunner.js +2 -2
- package/bin/federation/deploy/runtime/WranglerConfigWriter.d.ts +1 -1
- package/bin/federation/index.js +10 -10
- package/bin/federation/server/FederationServerManager.d.ts +1 -1
- package/bin/federation/server/FederationServerManager.js +4 -4
- package/bin/federation/server/FederationServerWorkspace.js +6 -6
- package/bin/federation/tui/AdminTuiRuntime.d.ts +1 -1
- package/bin/federation/tui/AdminTuiRuntime.js +1 -1
- package/bin/federation/tui/FederationDashboard.d.ts +2 -2
- package/bin/federation/tui/FederationDashboard.js +3 -3
- package/bin/federation/tui/Prompts.d.ts.map +1 -1
- package/bin/federation/tui/Prompts.js +20 -10
- package/bin/federation/tui/Prompts.js.map +1 -1
- package/bin/index.js +3 -3
- package/bin/shared/CliLocale.d.ts +1 -1
- package/bin/shared/CliReporter.d.ts +1 -1
- package/bin/shared/IndexSupport.js +2 -2
- package/bin/shared/tui/ManagedTuiRuntime.d.ts +2 -1
- package/bin/shared/tui/ManagedTuiRuntime.d.ts.map +1 -1
- package/bin/shared/tui/ManagedTuiRuntime.js +8 -2
- package/bin/shared/tui/ManagedTuiRuntime.js.map +1 -1
- package/bin/shared/tui/TuiComponents.d.ts +13 -11
- package/bin/shared/tui/TuiComponents.d.ts.map +1 -1
- package/bin/shared/tui/TuiComponents.js +142 -102
- package/bin/shared/tui/TuiComponents.js.map +1 -1
- package/bin/shared/tui/TuiText.d.ts +8 -0
- package/bin/shared/tui/TuiText.d.ts.map +1 -1
- package/bin/shared/tui/TuiText.js +12 -0
- package/bin/shared/tui/TuiText.js.map +1 -1
- package/bin/shared/types/TuiPrompt.d.ts +2 -2
- package/bin/shared/types/TuiPrompt.d.ts.map +1 -1
- package/package.json +7 -7
- package/bin/city/process/registry/CityRuntime.d.ts +0 -21
- package/bin/city/process/registry/CityRuntime.d.ts.map +0 -1
- package/bin/city/process/registry/CityRuntime.js +0 -45
- package/bin/city/process/registry/CityRuntime.js.map +0 -1
- package/bin/city/runtime/gateway/runtime/GatewayAuthBootstrap.d.ts +0 -25
- package/bin/city/runtime/gateway/runtime/GatewayAuthBootstrap.d.ts.map +0 -1
- package/bin/city/runtime/gateway/runtime/GatewayAuthBootstrap.js +0 -56
- package/bin/city/runtime/gateway/runtime/GatewayAuthBootstrap.js.map +0 -1
- package/bin/city/runtime/gateway/runtime/GatewayProcess.d.ts +0 -62
- package/bin/city/runtime/gateway/runtime/GatewayProcess.d.ts.map +0 -1
- package/bin/city/runtime/gateway/runtime/GatewayProcess.js +0 -433
- package/bin/city/runtime/gateway/runtime/GatewayProcess.js.map +0 -1
- package/bin/city/runtime/gateway/runtime/GatewayStatus.d.ts +0 -18
- package/bin/city/runtime/gateway/runtime/GatewayStatus.d.ts.map +0 -1
- package/bin/city/runtime/gateway/runtime/GatewayStatus.js +0 -135
- package/bin/city/runtime/gateway/runtime/GatewayStatus.js.map +0 -1
- package/bin/city/shared/PortHints.d.ts +0 -35
- package/bin/city/shared/PortHints.d.ts.map +0 -1
- package/bin/city/shared/PortHints.js +0 -58
- package/bin/city/shared/PortHints.js.map +0 -1
- package/bin/city/shared/PublicHostEnv.d.ts +0 -14
- package/bin/city/shared/PublicHostEnv.d.ts.map +0 -1
- package/bin/city/shared/PublicHostEnv.js +0 -104
- package/bin/city/shared/PublicHostEnv.js.map +0 -1
- package/bin/city/shared/PublicHostEnvTypes.d.ts +0 -35
- package/bin/city/shared/PublicHostEnvTypes.d.ts.map +0 -1
- package/bin/city/shared/PublicHostEnvTypes.js +0 -5
- package/bin/city/shared/PublicHostEnvTypes.js.map +0 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - 远程访问统一走 `RemoteAgent({ url })`,不再在 CLI 侧维护第二套 HTTP SDK transport。
|
|
9
9
|
* - 远程连接、session 创建/列表等操作委托给 `AgentChatRemote.ts`。
|
|
10
10
|
*/
|
|
11
|
-
import type { AgentChatCliOptions } from "
|
|
11
|
+
import type { AgentChatCliOptions } from "./AgentChatTypes.js";
|
|
12
12
|
/**
|
|
13
13
|
* `city agent chat` 统一入口。
|
|
14
14
|
*/
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* - 远程访问统一走 `RemoteAgent({ url })`,不再在 CLI 侧维护第二套 HTTP SDK transport。
|
|
9
9
|
* - 远程连接、session 创建/列表等操作委托给 `AgentChatRemote.ts`。
|
|
10
10
|
*/
|
|
11
|
-
import { emitCliBlock } from "
|
|
12
|
-
import { createRemoteChatSession, listRemoteChatSessions, } from "
|
|
13
|
-
import { run_agent_chat_tui } from "
|
|
14
|
-
import { normalizeChatMessage, resolveAgentChatSessionOptions, resolveChatTargetAgentId, resolveInteractiveChatSession, runOneShotChat, runSdkPromptTurn, } from "
|
|
11
|
+
import { emitCliBlock } from "../../shared/CliReporter.js";
|
|
12
|
+
import { createRemoteChatSession, listRemoteChatSessions, } from "./AgentChatRemote.js";
|
|
13
|
+
import { run_agent_chat_tui } from "./AgentChatTui.js";
|
|
14
|
+
import { normalizeChatMessage, resolveAgentChatSessionOptions, resolveChatTargetAgentId, resolveInteractiveChatSession, runOneShotChat, runSdkPromptTurn, } from "./AgentChatHelpers.js";
|
|
15
15
|
/**
|
|
16
16
|
* `city agent chat` 统一入口。
|
|
17
17
|
*/
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* - 远程连接、session 创建/列表等操作委托给 `AgentChatRemote.ts`。
|
|
10
10
|
*/
|
|
11
11
|
import { RemoteAgent } from "@downcity/agent";
|
|
12
|
-
import type { AgentChatCliOptions, AgentChatExecutionOutcome, AgentChatSessionOptions } from "
|
|
13
|
-
import type { AgentChatInteractiveRendererPort } from "
|
|
12
|
+
import type { AgentChatCliOptions, AgentChatExecutionOutcome, AgentChatSessionOptions } from "./AgentChatTypes.js";
|
|
13
|
+
import type { AgentChatInteractiveRendererPort } from "../types/AgentChatInteractive.js";
|
|
14
14
|
export type ResolvedAgentChatTarget = {
|
|
15
15
|
/** 目标 agent id。 */
|
|
16
16
|
agentId: string;
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* - 远程访问统一走 `RemoteAgent({ url })`,不再在 CLI 侧维护第二套 HTTP SDK transport。
|
|
9
9
|
* - 远程连接、session 创建/列表等操作委托给 `AgentChatRemote.ts`。
|
|
10
10
|
*/
|
|
11
|
-
import prompts from "
|
|
12
|
-
import { emitCliBlock } from "
|
|
13
|
-
import { printResult } from "
|
|
14
|
-
import { resolveProjectRootByAgentId, validateAgentProjectRoot, } from "
|
|
15
|
-
import { listRegisteredAgentsForCli } from "
|
|
16
|
-
import { createAgentChatSessionId, createRemoteAgent, createRemoteChatSession, getOrCreateRemoteSession, buildAgentChatFailureText, listRemoteChatSessions, } from "
|
|
17
|
-
import { AGENT_CHAT_DEFAULT_SESSION_ID, } from "
|
|
11
|
+
import prompts from "../tui/Prompts.js";
|
|
12
|
+
import { emitCliBlock } from "../../shared/CliReporter.js";
|
|
13
|
+
import { printResult } from "../utils/cli/CliOutput.js";
|
|
14
|
+
import { resolveProjectRootByAgentId, validateAgentProjectRoot, } from "../shared/PluginTargetSupport.js";
|
|
15
|
+
import { listRegisteredAgentsForCli } from "./AgentSelection.js";
|
|
16
|
+
import { createAgentChatSessionId, createRemoteAgent, createRemoteChatSession, getOrCreateRemoteSession, buildAgentChatFailureText, listRemoteChatSessions, } from "./AgentChatRemote.js";
|
|
17
|
+
import { AGENT_CHAT_DEFAULT_SESSION_ID, } from "./AgentChatTypes.js";
|
|
18
18
|
export function normalizeChatMessage(input) {
|
|
19
19
|
return String(input || "").trim();
|
|
20
20
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - 把“终端展示状态机”从主命令流程中拆出,降低 `AgentChat.ts` 复杂度。
|
|
8
8
|
*/
|
|
9
9
|
import type { AgentSessionEvent } from "@downcity/agent";
|
|
10
|
-
import type { AgentChatInteractiveRenderSnapshot, AgentChatInteractiveRendererPort } from "
|
|
10
|
+
import type { AgentChatInteractiveRenderSnapshot, AgentChatInteractiveRendererPort } from "../types/AgentChatInteractive.js";
|
|
11
11
|
/**
|
|
12
12
|
* 交互式单轮渲染器。
|
|
13
13
|
*/
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* - 把“终端展示状态机”从主命令流程中拆出,降低 `AgentChat.ts` 复杂度。
|
|
8
8
|
*/
|
|
9
9
|
import chalk from "chalk";
|
|
10
|
-
import { createSpinner, shouldRenderSpinner, } from "
|
|
11
|
-
import { format_tool_call_block, format_tool_result_block, } from "
|
|
10
|
+
import { createSpinner, shouldRenderSpinner, } from "../utils/cli/Spinner.js";
|
|
11
|
+
import { format_tool_call_block, format_tool_result_block, } from "./AgentChatToolFormatter.js";
|
|
12
12
|
function format_approval_request_block(event) {
|
|
13
13
|
const operation = event.operation || (event.toolName === "shell_write" ? "write" : "exec");
|
|
14
14
|
const command_label = operation === "write" ? "input_preview" : "cmd";
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - 不处理命令行交互与本地 agent 解析,只负责与 daemon RPC 的通信侧逻辑。
|
|
7
7
|
*/
|
|
8
8
|
import { RemoteAgent, type AgentSessionSummary, type AgentSession } from "@downcity/agent";
|
|
9
|
-
import { type AgentChatSessionSummaryView, type AgentChatTransportOptions } from "
|
|
9
|
+
import { type AgentChatSessionSummaryView, type AgentChatTransportOptions } from "./AgentChatTypes.js";
|
|
10
10
|
/**
|
|
11
11
|
* 远端访问目标。
|
|
12
12
|
*/
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* - 封装 `RemoteAgent` 创建、session 列表、session 创建/获取等远程操作。
|
|
6
6
|
* - 不处理命令行交互与本地 agent 解析,只负责与 daemon RPC 的通信侧逻辑。
|
|
7
7
|
*/
|
|
8
|
-
import { generateId } from "
|
|
8
|
+
import { generateId } from "../utils/Id.js";
|
|
9
9
|
import { RemoteAgent, } from "@downcity/agent";
|
|
10
|
-
import { resolveDaemonRpcEndpoint } from "
|
|
11
|
-
import { AGENT_CHAT_DEFAULT_SESSION_ID, AGENT_CHAT_NEW_SESSION_ID_PREFIX, } from "
|
|
10
|
+
import { resolveDaemonRpcEndpoint } from "../process/daemon/Client.js";
|
|
11
|
+
import { AGENT_CHAT_DEFAULT_SESSION_ID, AGENT_CHAT_NEW_SESSION_ID_PREFIX, } from "./AgentChatTypes.js";
|
|
12
12
|
/**
|
|
13
13
|
* 生成 CLI chat 专用的新 sessionId。
|
|
14
14
|
*/
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - 为后续继续贴近 Codex CLI / Claude Code 风格保留独立演进边界。
|
|
8
8
|
*/
|
|
9
9
|
import type { JsonValue } from "@downcity/agent";
|
|
10
|
-
import type { AgentChatToolDisplayBlock } from "
|
|
10
|
+
import type { AgentChatToolDisplayBlock } from "../types/AgentChatInteractive.js";
|
|
11
11
|
/**
|
|
12
12
|
* 格式化 tool 开始事件。
|
|
13
13
|
*/
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* - 该模块只做协调器创建与生命周期对接,不再直接持有 UI 状态。
|
|
6
6
|
* - 真实的渲染、输入、布局逻辑在 `tui/AgentChatTuiCoordinator` 中。
|
|
7
7
|
*/
|
|
8
|
-
import type { AgentChatInteractiveRendererPort } from "
|
|
9
|
-
import type { AgentChatSessionSummaryView } from "
|
|
8
|
+
import type { AgentChatInteractiveRendererPort } from "../types/AgentChatInteractive.js";
|
|
9
|
+
import type { AgentChatSessionSummaryView } from "./AgentChatTypes.js";
|
|
10
10
|
/**
|
|
11
11
|
* 启动 city agent chat 的交互式 TUI。
|
|
12
12
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* - 该模块只做协调器创建与生命周期对接,不再直接持有 UI 状态。
|
|
6
6
|
* - 真实的渲染、输入、布局逻辑在 `tui/AgentChatTuiCoordinator` 中。
|
|
7
7
|
*/
|
|
8
|
-
import { AgentChatTuiCoordinator } from "
|
|
8
|
+
import { AgentChatTuiCoordinator } from "./tui/AgentChatTuiCoordinator.js";
|
|
9
9
|
/**
|
|
10
10
|
* 启动 city agent chat 的交互式 TUI。
|
|
11
11
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* - 清理范围固定为 session messages、chat audit、channel route 三处。
|
|
7
7
|
* - 命令必须显式传 `--hard`,避免误删运行时历史。
|
|
8
8
|
*/
|
|
9
|
-
import type { AgentHistoryCleanOptions, AgentHistoryCleanResult } from "
|
|
9
|
+
import type { AgentHistoryCleanOptions, AgentHistoryCleanResult } from "./AgentHistoryTypes.js";
|
|
10
10
|
/**
|
|
11
11
|
* 执行 `city agent history clean`。
|
|
12
12
|
*/
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import fs from "fs-extra";
|
|
10
10
|
import path from "node:path";
|
|
11
|
-
import { getDowncityChannelDirPath, getDowncityChannelMetaPath, getDowncityChatSessionDirPath, getDowncitySessionDirPath, } from "
|
|
12
|
-
import { CliError } from "
|
|
13
|
-
import { emitCliBlock } from "
|
|
14
|
-
import { printResult } from "
|
|
15
|
-
import { resolveAgentId } from "
|
|
11
|
+
import { getDowncityChannelDirPath, getDowncityChannelMetaPath, getDowncityChatSessionDirPath, getDowncitySessionDirPath, } from "../config/Paths.js";
|
|
12
|
+
import { CliError } from "../../shared/CliError.js";
|
|
13
|
+
import { emitCliBlock } from "../../shared/CliReporter.js";
|
|
14
|
+
import { printResult } from "../utils/cli/CliOutput.js";
|
|
15
|
+
import { resolveAgentId } from "../../shared/IndexSupport.js";
|
|
16
16
|
function normalizeText(input) {
|
|
17
17
|
return String(input || "").trim();
|
|
18
18
|
}
|
|
@@ -13,12 +13,12 @@ import http from "node:http";
|
|
|
13
13
|
import { Readable } from "node:stream";
|
|
14
14
|
import { finished } from "node:stream/promises";
|
|
15
15
|
import { logger as serverLogger } from "@downcity/agent/internal/utils/logger/Logger.js";
|
|
16
|
-
import { createExecuteRouter } from "
|
|
17
|
-
import { healthRouter } from "
|
|
18
|
-
import { createPluginsRouter } from "
|
|
19
|
-
import { createStaticRouter } from "
|
|
20
|
-
import { createControlRouter } from "
|
|
21
|
-
import { createShellRouter } from "
|
|
16
|
+
import { createExecuteRouter } from "./http/execute/execute.js";
|
|
17
|
+
import { healthRouter } from "./http/health/health.js";
|
|
18
|
+
import { createPluginsRouter } from "./http/plugins/plugins.js";
|
|
19
|
+
import { createStaticRouter } from "./http/static/static.js";
|
|
20
|
+
import { createControlRouter } from "./http/control/ControlRouter.js";
|
|
21
|
+
import { createShellRouter } from "./http/shell/shell.js";
|
|
22
22
|
/**
|
|
23
23
|
* 创建 Agent HTTP 网关 Hono 应用。
|
|
24
24
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentManager.d.ts","sourceRoot":"","sources":["../../../src/city/agent/AgentManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH;;GAEG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"AgentManager.d.ts","sourceRoot":"","sources":["../../../src/city/agent/AgentManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH;;GAEG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC,CAmChE"}
|
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
* - 裸 `city agent` 在交互式终端里进入这里,而不是只输出静态 help。
|
|
6
6
|
* - 保留原有脚本化子命令不变,只把高频的人类操作收敛成轻量 manager。
|
|
7
7
|
*/
|
|
8
|
-
import { emitCliBlock } from "
|
|
9
|
-
import { isInteractiveTerminal, loadAgentSummaries, promptAgentListSelection, runCreateFlow, runSelectedAgentManager, } from "
|
|
8
|
+
import { emitCliBlock } from "../../shared/CliReporter.js";
|
|
9
|
+
import { isInteractiveTerminal, loadAgentSummaries, promptAgentListSelection, runCreateFlow, runSelectedAgentManager, } from "./AgentManagerHelpers.js";
|
|
10
10
|
/**
|
|
11
11
|
* 运行 `city agent` 交互式管理器。
|
|
12
12
|
*/
|
|
13
13
|
export async function runInteractiveAgentManager() {
|
|
14
14
|
if (!isInteractiveTerminal())
|
|
15
15
|
return;
|
|
16
|
+
let last_message = "";
|
|
16
17
|
while (true) {
|
|
17
|
-
const selection = await promptAgentListSelection();
|
|
18
|
+
const selection = await promptAgentListSelection(last_message);
|
|
19
|
+
last_message = "";
|
|
18
20
|
if (!selection || selection.type === "exit") {
|
|
19
21
|
emitCliBlock({
|
|
20
22
|
tone: "info",
|
|
@@ -25,29 +27,31 @@ export async function runInteractiveAgentManager() {
|
|
|
25
27
|
try {
|
|
26
28
|
if (selection.type === "create") {
|
|
27
29
|
await runCreateFlow();
|
|
30
|
+
last_message = "Agent 创建流程已结束";
|
|
28
31
|
continue;
|
|
29
32
|
}
|
|
30
33
|
if (selection.type === "agent") {
|
|
31
34
|
const agents = await loadAgentSummaries();
|
|
32
35
|
const agent = agents.find((item) => item.projectRoot === selection.project_root);
|
|
33
36
|
if (!agent) {
|
|
34
|
-
|
|
35
|
-
tone: "info",
|
|
36
|
-
title: "Agent not found",
|
|
37
|
-
note: selection.project_root,
|
|
38
|
-
});
|
|
37
|
+
last_message = `Agent 不存在:${selection.project_root}`;
|
|
39
38
|
continue;
|
|
40
39
|
}
|
|
41
40
|
await runSelectedAgentManager(agent);
|
|
41
|
+
last_message = `已返回 Agent 列表`;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
catch (error) {
|
|
45
|
-
|
|
46
|
-
tone: "error",
|
|
47
|
-
title: "Agent manager action failed",
|
|
48
|
-
note: error instanceof Error ? error.message : String(error),
|
|
49
|
-
});
|
|
45
|
+
last_message = `操作失败:${format_agent_manager_error(error)}`;
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
48
|
}
|
|
49
|
+
function format_agent_manager_error(error) {
|
|
50
|
+
if (error && typeof error === "object" && "note" in error) {
|
|
51
|
+
const note = String(error.note ?? "").trim();
|
|
52
|
+
if (note)
|
|
53
|
+
return note;
|
|
54
|
+
}
|
|
55
|
+
return error instanceof Error ? error.message : String(error);
|
|
56
|
+
}
|
|
53
57
|
//# sourceMappingURL=AgentManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentManager.js","sourceRoot":"","sources":["../../../src/city/agent/AgentManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,aAAa,EACb,uBAAuB,GACxB,MAAM,qCAAqC,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,IAAI,CAAC,qBAAqB,EAAE;QAAE,OAAO;IAErC,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,MAAM,wBAAwB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"AgentManager.js","sourceRoot":"","sources":["../../../src/city/agent/AgentManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;A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AK,CAAC,EAAE,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAc;IAChD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;QAC1D,MAAM,IAAI,GAAG,MAAM,CAAE,KAA4B,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACrE,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;IACxB,CAAC;IACD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { DowncityConfig } from "@downcity/agent";
|
|
9
9
|
import type { StoredChannelAccount, StoredChannelAccountChannel } from "@downcity/agent";
|
|
10
|
-
import type { AgentManagerAgentAction, AgentManagerConfigAction, AgentManagerListSelection, AgentManagerAgentSummary } from "
|
|
10
|
+
import type { AgentManagerAgentAction, AgentManagerConfigAction, AgentManagerListSelection, AgentManagerAgentSummary } from "./AgentManagerTypes.js";
|
|
11
11
|
type DanglingChannelAccount = {
|
|
12
12
|
/**
|
|
13
13
|
* 出现悬空引用的聊天渠道。
|
|
@@ -34,8 +34,8 @@ export declare function findDanglingChannelAccounts(config: DowncityConfig | nul
|
|
|
34
34
|
export declare function loadChannelAccounts(channel?: StoredChannelAccountChannel): StoredChannelAccount[];
|
|
35
35
|
export declare function loadChannelAccountMap(): Map<string, StoredChannelAccount>;
|
|
36
36
|
export declare function formatAgentDetail(agent: AgentManagerAgentSummary): string;
|
|
37
|
-
export declare function promptAgentListSelection(): Promise<AgentManagerListSelection | null>;
|
|
38
|
-
export declare function promptAgentAction(agent: AgentManagerAgentSummary): Promise<AgentManagerAgentAction | null>;
|
|
37
|
+
export declare function promptAgentListSelection(lastMessage?: string): Promise<AgentManagerListSelection | null>;
|
|
38
|
+
export declare function promptAgentAction(agent: AgentManagerAgentSummary, lastMessage?: string): Promise<AgentManagerAgentAction | null>;
|
|
39
39
|
export declare function formatAgentConfigPanelDescription(agent: AgentManagerAgentSummary): string;
|
|
40
40
|
export declare function startActionChoices(agent: AgentManagerAgentSummary): Array<{
|
|
41
41
|
title: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentManagerHelpers.d.ts","sourceRoot":"","sources":["../../../src/city/agent/AgentManagerHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkBH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,mCAAmC,CAAC;AAI3C,KAAK,sBAAsB,GAAG;IAC5B;;OAEG;IACH,OAAO,EAAE,2BAA2B,CAAC;IACrC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAY9E;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,wBAAwB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CAGnC;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAM1E;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,MAAM,CAE/E;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,MAAM,EAAE,CAkBjF;AAED,wBAAgB,2BAA2B,CAAC,M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AAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ1E;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAUnD;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CA+CzG;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAGvE;AAED,wBAAsB,sBAAsB,CAAC,MAAM,EAAE;IACnD,OAAO,EAAE,2BAA2B,CAAC;IACrC,gBAAgB,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAkCrC;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,wBAAwB,CAAC,CA4GnC;AAED,wBAAsB,uBAAuB,CAAC,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiFlG"}
|
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
* - 负责 Agent 列表加载、配置读取、账号绑定、prompts 与运行时操作封装。
|
|
6
6
|
* - 交互式 manager 不能长期持有旧快照,启动/停止后需要重新加载摘要。
|
|
7
7
|
*/
|
|
8
|
-
import prompts from "
|
|
8
|
+
import prompts from "../tui/Prompts.js";
|
|
9
9
|
import fs from "fs-extra";
|
|
10
|
-
import { initCommand } from "
|
|
11
|
-
import { runCommand } from "
|
|
12
|
-
import { startCommand } from "
|
|
13
|
-
import { stopCommand } from "
|
|
14
|
-
import { restartCommand } from "
|
|
15
|
-
import { chatCommand } from "
|
|
16
|
-
import { listRegisteredAgentsForCli } from "
|
|
17
|
-
import { emitCliBlock, emitCliList } from "
|
|
18
|
-
import { injectAgentContext } from "
|
|
19
|
-
import { prepareForegroundAgent } from "
|
|
20
|
-
import { getDowncityJsonPath } from "
|
|
21
|
-
import { PlatformStore } from "
|
|
22
|
-
import { t } from "
|
|
10
|
+
import { initCommand } from "./Init.js";
|
|
11
|
+
import { runCommand } from "./Run.js";
|
|
12
|
+
import { startCommand } from "./Start.js";
|
|
13
|
+
import { stopCommand } from "./Stop.js";
|
|
14
|
+
import { restartCommand } from "./Restart.js";
|
|
15
|
+
import { chatCommand } from "./AgentChat.js";
|
|
16
|
+
import { listRegisteredAgentsForCli } from "./AgentSelection.js";
|
|
17
|
+
import { emitCliBlock, emitCliList } from "../../shared/CliReporter.js";
|
|
18
|
+
import { injectAgentContext } from "../../shared/IndexSupport.js";
|
|
19
|
+
import { prepareForegroundAgent } from "../shared/CityAgentRuntime.js";
|
|
20
|
+
import { getDowncityJsonPath } from "../config/Paths.js";
|
|
21
|
+
import { PlatformStore } from "../runtime/store/index.js";
|
|
22
|
+
import { t } from "../../shared/CliLocale.js";
|
|
23
23
|
const CHAT_CHANNELS = ["telegram", "feishu", "qq"];
|
|
24
24
|
export function isInteractiveTerminal() {
|
|
25
25
|
return process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
@@ -110,33 +110,28 @@ export function formatAgentDetail(agent) {
|
|
|
110
110
|
en: "not configured",
|
|
111
111
|
});
|
|
112
112
|
const channels = agent.channels.length > 0
|
|
113
|
-
? agent.channels.
|
|
113
|
+
? agent.channels.length === 1
|
|
114
|
+
? agent.channels[0]
|
|
115
|
+
: t({ zh: `${agent.channels.length} 个账号`, en: `${agent.channels.length} accounts` })
|
|
114
116
|
: t({ zh: "未连接", en: "not connected" });
|
|
115
117
|
return t({
|
|
116
118
|
zh: [
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
`Chat 账号:${channels}`,
|
|
120
|
-
`项目路径:${agent.projectRoot}`,
|
|
121
|
-
"",
|
|
122
|
-
"Enter 进入该 Agent 的管理面板。运行控制在“状态”里,侧边栏只保留聊天和配置入口。",
|
|
119
|
+
`状态 ${agent.status === "running" ? "运行中" : "已停止"} · 模型 ${execution_binding} · Chat ${channels}`,
|
|
120
|
+
"Enter 进入管理面板。",
|
|
123
121
|
].join("\n"),
|
|
124
122
|
en: [
|
|
125
|
-
`Status
|
|
126
|
-
|
|
127
|
-
`Chat accounts: ${channels}`,
|
|
128
|
-
`Project: ${agent.projectRoot}`,
|
|
129
|
-
"",
|
|
130
|
-
"Press Enter to open this agent's management panel. Runtime controls live under Status; the sidebar keeps Chat and Config as separate entries.",
|
|
123
|
+
`Status ${agent.status} · Model ${execution_binding} · Chat ${channels}`,
|
|
124
|
+
"Press Enter to manage this agent.",
|
|
131
125
|
].join("\n"),
|
|
132
126
|
});
|
|
133
127
|
}
|
|
134
|
-
export async function promptAgentListSelection() {
|
|
128
|
+
export async function promptAgentListSelection(lastMessage) {
|
|
135
129
|
const agents = await loadAgentSummaries();
|
|
136
130
|
const response = (await prompts({
|
|
137
131
|
type: "select",
|
|
138
132
|
name: "selection",
|
|
139
133
|
message: t({ zh: "Agent 管理", en: "Agent management" }),
|
|
134
|
+
subtitle: lastMessage,
|
|
140
135
|
choices: [
|
|
141
136
|
{
|
|
142
137
|
title: t({ zh: "Agent 列表", en: "Agents" }),
|
|
@@ -189,7 +184,7 @@ export async function promptAgentListSelection() {
|
|
|
189
184
|
}));
|
|
190
185
|
return response.selection || null;
|
|
191
186
|
}
|
|
192
|
-
export async function promptAgentAction(agent) {
|
|
187
|
+
export async function promptAgentAction(agent, lastMessage) {
|
|
193
188
|
const response = (await prompts({
|
|
194
189
|
type: "select",
|
|
195
190
|
name: "action",
|
|
@@ -197,6 +192,7 @@ export async function promptAgentAction(agent) {
|
|
|
197
192
|
zh: `管理 Agent · ${agent.id}`,
|
|
198
193
|
en: `Manage agent · ${agent.id}`,
|
|
199
194
|
}),
|
|
195
|
+
subtitle: lastMessage,
|
|
200
196
|
choices: [
|
|
201
197
|
{
|
|
202
198
|
title: t({ zh: "Agent", en: "Agent" }),
|
|
@@ -237,16 +233,12 @@ export async function promptAgentAction(agent) {
|
|
|
237
233
|
export function formatAgentConfigPanelDescription(agent) {
|
|
238
234
|
return t({
|
|
239
235
|
zh: [
|
|
240
|
-
`Agent
|
|
241
|
-
|
|
242
|
-
"",
|
|
243
|
-
"Enter 后配置 Agent ID 或连接 City 全局 Chat 账号。",
|
|
236
|
+
`Agent ${agent.id} · Chat ${agent.channels.length > 0 ? agent.channels.length : "未连接"}`,
|
|
237
|
+
"配置 Agent ID 或连接 City 全局 Chat 账号。",
|
|
244
238
|
].join("\n"),
|
|
245
239
|
en: [
|
|
246
|
-
`Agent
|
|
247
|
-
|
|
248
|
-
"",
|
|
249
|
-
"Press Enter to configure the Agent ID or bind City-level Chat accounts.",
|
|
240
|
+
`Agent ${agent.id} · Chat ${agent.channels.length > 0 ? agent.channels.length : "not connected"}`,
|
|
241
|
+
"Configure the Agent ID or bind City-level Chat accounts.",
|
|
250
242
|
].join("\n"),
|
|
251
243
|
});
|
|
252
244
|
}
|
|
@@ -553,9 +545,11 @@ export async function connectAgentChannels(agent) {
|
|
|
553
545
|
}
|
|
554
546
|
export async function runSelectedAgentManager(agent_input) {
|
|
555
547
|
let agent = agent_input;
|
|
548
|
+
let last_message = "";
|
|
556
549
|
while (true) {
|
|
557
550
|
agent = await reloadAgentSummary(agent.projectRoot, agent);
|
|
558
|
-
const action = await promptAgentAction(agent);
|
|
551
|
+
const action = await promptAgentAction(agent, last_message);
|
|
552
|
+
last_message = "";
|
|
559
553
|
if (!action) {
|
|
560
554
|
emitCliBlock({
|
|
561
555
|
tone: "info",
|
|
@@ -568,27 +562,32 @@ export async function runSelectedAgentManager(agent_input) {
|
|
|
568
562
|
try {
|
|
569
563
|
if (action === "start") {
|
|
570
564
|
await startAgentProject(agent.projectRoot);
|
|
565
|
+
const previous_agent = agent;
|
|
571
566
|
agent = await reloadAgentSummary(agent.projectRoot, agent);
|
|
567
|
+
last_message = format_agent_start_result(previous_agent, agent);
|
|
572
568
|
continue;
|
|
573
569
|
}
|
|
574
570
|
if (action === "stop") {
|
|
571
|
+
const previous_agent = agent;
|
|
575
572
|
await stopCommand(agent.projectRoot);
|
|
576
573
|
agent = await reloadAgentSummary(agent.projectRoot, agent);
|
|
574
|
+
last_message = format_agent_stop_result(previous_agent, agent);
|
|
577
575
|
continue;
|
|
578
576
|
}
|
|
579
577
|
if (action === "restart") {
|
|
578
|
+
const previous_agent = agent;
|
|
580
579
|
injectAgentContext(agent.projectRoot);
|
|
581
580
|
await restartCommand(agent.projectRoot, {});
|
|
582
581
|
agent = await reloadAgentSummary(agent.projectRoot, agent);
|
|
582
|
+
last_message = format_agent_restart_result(previous_agent, agent);
|
|
583
583
|
continue;
|
|
584
584
|
}
|
|
585
585
|
if (action === "chat") {
|
|
586
586
|
agent = await reloadAgentSummary(agent.projectRoot, agent);
|
|
587
587
|
if (agent.status !== "running") {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
note: "请先启动当前 agent,再进入聊天。",
|
|
588
|
+
last_message = t({
|
|
589
|
+
zh: "无法聊天:请先启动当前 Agent",
|
|
590
|
+
en: "Cannot chat: start this agent first",
|
|
592
591
|
});
|
|
593
592
|
continue;
|
|
594
593
|
}
|
|
@@ -603,21 +602,77 @@ export async function runSelectedAgentManager(agent_input) {
|
|
|
603
602
|
}
|
|
604
603
|
if (config_action === "configureId") {
|
|
605
604
|
agent = await configureAgentId(agent);
|
|
605
|
+
last_message = t({
|
|
606
|
+
zh: `配置已更新:${agent.id}`,
|
|
607
|
+
en: `Config updated: ${agent.id}`,
|
|
608
|
+
});
|
|
606
609
|
continue;
|
|
607
610
|
}
|
|
608
611
|
if (config_action === "connectChatAccounts") {
|
|
609
612
|
agent = await connectAgentChannels(agent);
|
|
613
|
+
last_message = t({
|
|
614
|
+
zh: "Chat 账号连接已更新",
|
|
615
|
+
en: "Chat account bindings updated",
|
|
616
|
+
});
|
|
610
617
|
continue;
|
|
611
618
|
}
|
|
612
619
|
}
|
|
613
620
|
}
|
|
614
621
|
catch (error) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
note: error instanceof Error ? error.message : String(error),
|
|
622
|
+
last_message = t({
|
|
623
|
+
zh: `操作失败:${format_agent_action_error(error)}`,
|
|
624
|
+
en: `Action failed: ${format_agent_action_error(error)}`,
|
|
619
625
|
});
|
|
620
626
|
}
|
|
621
627
|
}
|
|
622
628
|
}
|
|
629
|
+
function format_agent_action_error(error) {
|
|
630
|
+
if (error && typeof error === "object" && "note" in error) {
|
|
631
|
+
const note = String(error.note ?? "").trim();
|
|
632
|
+
if (note)
|
|
633
|
+
return note;
|
|
634
|
+
}
|
|
635
|
+
return error instanceof Error ? error.message : String(error);
|
|
636
|
+
}
|
|
637
|
+
function format_agent_start_result(_previous_agent, next_agent) {
|
|
638
|
+
if (next_agent.status === "running") {
|
|
639
|
+
return t({
|
|
640
|
+
zh: `已启动 ${next_agent.id}`,
|
|
641
|
+
en: `Started ${next_agent.id}`,
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
return t({
|
|
645
|
+
zh: `启动未生效:${next_agent.id} 仍是已停止`,
|
|
646
|
+
en: `Start did not take effect: ${next_agent.id} is still stopped`,
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
function format_agent_stop_result(previous_agent, next_agent) {
|
|
650
|
+
if (next_agent.status === "stopped") {
|
|
651
|
+
return previous_agent.status === "running"
|
|
652
|
+
? t({
|
|
653
|
+
zh: `已停止 ${next_agent.id}`,
|
|
654
|
+
en: `Stopped ${next_agent.id}`,
|
|
655
|
+
})
|
|
656
|
+
: t({
|
|
657
|
+
zh: `${next_agent.id} 本来就是已停止`,
|
|
658
|
+
en: `${next_agent.id} was already stopped`,
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
return t({
|
|
662
|
+
zh: `停止未生效:${next_agent.id} 仍在运行`,
|
|
663
|
+
en: `Stop did not take effect: ${next_agent.id} is still running`,
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
function format_agent_restart_result(_previous_agent, next_agent) {
|
|
667
|
+
if (next_agent.status === "running") {
|
|
668
|
+
return t({
|
|
669
|
+
zh: `已重启 ${next_agent.id}`,
|
|
670
|
+
en: `Restarted ${next_agent.id}`,
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
return t({
|
|
674
|
+
zh: `重启未生效:${next_agent.id} 当前已停止`,
|
|
675
|
+
en: `Restart did not take effect: ${next_agent.id} is stopped`,
|
|
676
|
+
});
|
|
677
|
+
}
|
|
623
678
|
//# sourceMappingURL=AgentManagerHelpers.js.map
|