@downcity/city 1.1.39 → 1.1.47
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 +4 -9
- package/bin/cli/Index.js +2 -0
- package/bin/cli/Index.js.map +1 -1
- package/bin/cli/agent/AgentChat.d.ts +2 -1
- package/bin/cli/agent/AgentChat.d.ts.map +1 -1
- package/bin/cli/agent/AgentChat.js +93 -214
- package/bin/cli/agent/AgentChat.js.map +1 -1
- package/bin/cli/agent/AgentChatTypes.d.ts +8 -12
- package/bin/cli/agent/AgentChatTypes.d.ts.map +1 -1
- package/bin/cli/agent/AgentHistory.js +2 -2
- package/bin/cli/agent/AgentHistory.js.map +1 -1
- package/bin/cli/agent/AgentManager.d.ts.map +1 -1
- package/bin/cli/agent/AgentManager.js +26 -27
- package/bin/cli/agent/AgentManager.js.map +1 -1
- package/bin/cli/agent/AgentManagerTypes.d.ts +2 -2
- package/bin/cli/agent/AgentManagerTypes.d.ts.map +1 -1
- package/bin/cli/agent/AgentReset.js +4 -4
- package/bin/cli/agent/AgentReset.js.map +1 -1
- package/bin/cli/agent/AgentSelection.js +6 -6
- package/bin/cli/agent/AgentSelection.js.map +1 -1
- package/bin/cli/agent/AgentSelectionTypes.d.ts +1 -1
- package/bin/cli/agent/AgentSelectionTypes.d.ts.map +1 -1
- package/bin/cli/agent/Init.js +10 -10
- package/bin/cli/agent/Init.js.map +1 -1
- package/bin/cli/agent/Restart.js +2 -2
- package/bin/cli/agent/Restart.js.map +1 -1
- package/bin/cli/agent/Run.d.ts +1 -1
- package/bin/cli/agent/Run.d.ts.map +1 -1
- package/bin/cli/agent/Run.js +37 -17
- package/bin/cli/agent/Run.js.map +1 -1
- package/bin/cli/agent/Start.js +2 -2
- package/bin/cli/agent/Start.js.map +1 -1
- package/bin/cli/agent/Stop.js +2 -2
- package/bin/cli/agent/Stop.js.map +1 -1
- package/bin/cli/control-plane/ControlPlaneProcess.js +5 -5
- package/bin/cli/control-plane/ControlPlaneProcess.js.map +1 -1
- package/bin/cli/model/ModelCreateCommand.js +1 -1
- package/bin/cli/model/ModelCreateCommand.js.map +1 -1
- package/bin/cli/model/ModelManageCommand.d.ts.map +1 -1
- package/bin/cli/model/ModelManageCommand.js +5 -3
- package/bin/cli/model/ModelManageCommand.js.map +1 -1
- package/bin/cli/model/ModelManager.js +3 -3
- package/bin/cli/model/ModelManager.js.map +1 -1
- package/bin/cli/model/ModelSupport.d.ts +0 -1
- package/bin/cli/model/ModelSupport.d.ts.map +1 -1
- package/bin/cli/model/ModelSupport.js +2 -11
- package/bin/cli/model/ModelSupport.js.map +1 -1
- package/bin/cli/shared/CliReporterTypes.d.ts +1 -1
- package/bin/cli/shared/Config.js +2 -2
- package/bin/cli/shared/Config.js.map +1 -1
- package/bin/cli/shared/Env.d.ts +1 -1
- package/bin/cli/shared/Env.d.ts.map +1 -1
- package/bin/cli/shared/Env.js +18 -149
- package/bin/cli/shared/Env.js.map +1 -1
- package/bin/cli/shared/IndexAgentCommand.d.ts.map +1 -1
- package/bin/cli/shared/IndexAgentCommand.js +3 -3
- package/bin/cli/shared/IndexAgentCommand.js.map +1 -1
- package/bin/cli/shared/IndexSupport.d.ts +3 -3
- package/bin/cli/shared/IndexSupport.d.ts.map +1 -1
- package/bin/cli/shared/IndexSupport.js +14 -8
- package/bin/cli/shared/IndexSupport.js.map +1 -1
- package/bin/cli/shared/ManagedPluginActionCommands.d.ts.map +1 -1
- package/bin/cli/shared/ManagedPluginActionCommands.js +5 -4
- package/bin/cli/shared/ManagedPluginActionCommands.js.map +1 -1
- package/bin/cli/shared/ManagedPluginRemote.d.ts.map +1 -1
- package/bin/cli/shared/ManagedPluginRemote.js +4 -4
- package/bin/cli/shared/ManagedPluginRemote.js.map +1 -1
- package/bin/cli/shared/PluginTargetSupport.d.ts +2 -2
- package/bin/cli/shared/PluginTargetSupport.d.ts.map +1 -1
- package/bin/cli/shared/PluginTargetSupport.js +19 -19
- package/bin/cli/shared/PluginTargetSupport.js.map +1 -1
- package/bin/cli/shared/Plugins.js +10 -10
- package/bin/cli/shared/Plugins.js.map +1 -1
- package/bin/cli/shared/PublicHostEnv.d.ts +1 -1
- package/bin/cli/shared/PublicHostEnv.js +2 -2
- package/bin/cli/shared/PublicHostEnv.js.map +1 -1
- package/bin/cli/shared/Terminal.d.ts +13 -0
- package/bin/cli/shared/Terminal.d.ts.map +1 -0
- package/bin/cli/shared/Terminal.js +22 -0
- package/bin/cli/shared/Terminal.js.map +1 -0
- package/bin/config/DowncitySchema.d.ts.map +1 -1
- package/bin/config/DowncitySchema.js +3 -111
- package/bin/config/DowncitySchema.js.map +1 -1
- package/bin/config/Paths.d.ts +0 -56
- package/bin/config/Paths.d.ts.map +1 -1
- package/bin/config/Paths.js +9 -51
- package/bin/config/Paths.js.map +1 -1
- package/bin/control/ControlGateway.js +1 -1
- package/bin/control/ControlGateway.js.map +1 -1
- package/bin/control/EnvApiRoutes.d.ts +1 -1
- package/bin/control/EnvApiRoutes.d.ts.map +1 -1
- package/bin/control/EnvApiRoutes.js +7 -79
- package/bin/control/EnvApiRoutes.js.map +1 -1
- package/bin/control/PlatformApiRoutes.d.ts +2 -2
- package/bin/control/PlatformApiRoutes.d.ts.map +1 -1
- package/bin/control/PlatformApiRoutes.js +2 -2
- package/bin/control/PlatformApiRoutes.js.map +1 -1
- package/bin/control/gateway/AgentActions.d.ts +2 -2
- package/bin/control/gateway/AgentActions.d.ts.map +1 -1
- package/bin/control/gateway/AgentActions.js +7 -7
- package/bin/control/gateway/AgentActions.js.map +1 -1
- package/bin/control/gateway/AgentCatalog.d.ts +3 -6
- package/bin/control/gateway/AgentCatalog.d.ts.map +1 -1
- package/bin/control/gateway/AgentCatalog.js +16 -18
- package/bin/control/gateway/AgentCatalog.js.map +1 -1
- package/bin/control/instant/InstantSessionRunner.d.ts.map +1 -1
- package/bin/control/instant/InstantSessionRunner.js +3 -1
- package/bin/control/instant/InstantSessionRunner.js.map +1 -1
- package/bin/env/ProcessEnv.d.ts +24 -0
- package/bin/env/ProcessEnv.d.ts.map +1 -0
- package/bin/env/ProcessEnv.js +41 -0
- package/bin/env/ProcessEnv.js.map +1 -0
- package/bin/http/auth/AuthEnv.d.ts +1 -1
- package/bin/http/auth/AuthEnv.js +1 -1
- package/bin/model/runtime/CreateRuntimeModel.d.ts +8 -0
- package/bin/model/runtime/CreateRuntimeModel.d.ts.map +1 -1
- package/bin/model/runtime/CreateRuntimeModel.js +43 -37
- package/bin/model/runtime/CreateRuntimeModel.js.map +1 -1
- package/bin/model/service/ModelPoolService.d.ts +1 -1
- package/bin/model/service/ModelPoolService.d.ts.map +1 -1
- package/bin/model/service/ModelPoolService.js +8 -6
- package/bin/model/service/ModelPoolService.js.map +1 -1
- package/bin/platform/store/StoreEnvRepository.d.ts +5 -49
- package/bin/platform/store/StoreEnvRepository.d.ts.map +1 -1
- package/bin/platform/store/StoreEnvRepository.js +31 -178
- package/bin/platform/store/StoreEnvRepository.js.map +1 -1
- package/bin/platform/store/StoreSchema.js +3 -44
- package/bin/platform/store/StoreSchema.js.map +1 -1
- package/bin/platform/store/index.d.ts +9 -45
- package/bin/platform/store/index.d.ts.map +1 -1
- package/bin/platform/store/index.js +12 -62
- package/bin/platform/store/index.js.map +1 -1
- package/bin/platform/store/schema.d.ts +2 -2
- package/bin/platform/store/schema.js +2 -2
- package/bin/process/daemon/Api.d.ts +1 -1
- package/bin/process/daemon/CliArgs.d.ts +1 -0
- package/bin/process/daemon/CliArgs.d.ts.map +1 -1
- package/bin/process/daemon/CliArgs.js +20 -1
- package/bin/process/daemon/CliArgs.js.map +1 -1
- package/bin/process/daemon/Client.d.ts +18 -2
- package/bin/process/daemon/Client.d.ts.map +1 -1
- package/bin/process/daemon/Client.js +70 -20
- package/bin/process/daemon/Client.js.map +1 -1
- package/bin/process/daemon/Manager.d.ts.map +1 -1
- package/bin/process/daemon/Manager.js +2 -1
- package/bin/process/daemon/Manager.js.map +1 -1
- package/bin/terminal/admin/auth-error.d.ts +34 -0
- package/bin/terminal/admin/auth-error.d.ts.map +1 -0
- package/bin/terminal/admin/auth-error.js +51 -0
- package/bin/terminal/admin/auth-error.js.map +1 -0
- package/bin/terminal/admin/commands/accounts.d.ts +6 -0
- package/bin/terminal/admin/commands/accounts.d.ts.map +1 -0
- package/bin/terminal/admin/commands/accounts.js +44 -0
- package/bin/terminal/admin/commands/accounts.js.map +1 -0
- package/bin/terminal/admin/commands/balance.d.ts +6 -0
- package/bin/terminal/admin/commands/balance.d.ts.map +1 -0
- package/bin/terminal/admin/commands/balance.js +153 -0
- package/bin/terminal/admin/commands/balance.js.map +1 -0
- package/bin/terminal/admin/commands/config.d.ts +10 -0
- package/bin/terminal/admin/commands/config.d.ts.map +1 -0
- package/bin/terminal/admin/commands/config.js +11 -0
- package/bin/terminal/admin/commands/config.js.map +1 -0
- package/bin/terminal/admin/commands/custom.d.ts +6 -0
- package/bin/terminal/admin/commands/custom.d.ts.map +1 -0
- package/bin/terminal/admin/commands/custom.js +47 -0
- package/bin/terminal/admin/commands/custom.js.map +1 -0
- package/bin/terminal/admin/commands/instruction.d.ts +9 -0
- package/bin/terminal/admin/commands/instruction.d.ts.map +1 -0
- package/bin/terminal/admin/commands/instruction.js +10 -0
- package/bin/terminal/admin/commands/instruction.js.map +1 -0
- package/bin/terminal/admin/commands/models.d.ts +14 -0
- package/bin/terminal/admin/commands/models.d.ts.map +1 -0
- package/bin/terminal/admin/commands/models.js +61 -0
- package/bin/terminal/admin/commands/models.js.map +1 -0
- package/bin/terminal/admin/commands/payment.d.ts +6 -0
- package/bin/terminal/admin/commands/payment.d.ts.map +1 -0
- package/bin/terminal/admin/commands/payment.js +59 -0
- package/bin/terminal/admin/commands/payment.js.map +1 -0
- package/bin/terminal/admin/commands/products.d.ts +6 -0
- package/bin/terminal/admin/commands/products.d.ts.map +1 -0
- package/bin/terminal/admin/commands/products.js +80 -0
- package/bin/terminal/admin/commands/products.js.map +1 -0
- package/bin/terminal/admin/commands/service-env.d.ts +11 -0
- package/bin/terminal/admin/commands/service-env.d.ts.map +1 -0
- package/bin/terminal/admin/commands/service-env.js +248 -0
- package/bin/terminal/admin/commands/service-env.js.map +1 -0
- package/bin/terminal/admin/commands/usage.d.ts +6 -0
- package/bin/terminal/admin/commands/usage.d.ts.map +1 -0
- package/bin/terminal/admin/commands/usage.js +44 -0
- package/bin/terminal/admin/commands/usage.js.map +1 -0
- package/bin/terminal/admin/loop.d.ts +6 -0
- package/bin/terminal/admin/loop.d.ts.map +1 -0
- package/bin/terminal/admin/loop.js +70 -0
- package/bin/terminal/admin/loop.js.map +1 -0
- package/bin/terminal/agent/pi-agent.d.ts +15 -0
- package/bin/terminal/agent/pi-agent.d.ts.map +1 -0
- package/bin/terminal/agent/pi-agent.js +136 -0
- package/bin/terminal/agent/pi-agent.js.map +1 -0
- package/bin/terminal/app.d.ts +13 -0
- package/bin/terminal/app.d.ts.map +1 -0
- package/bin/terminal/app.js +123 -0
- package/bin/terminal/app.js.map +1 -0
- package/bin/terminal/auth/admin.d.ts +8 -0
- package/bin/terminal/auth/admin.d.ts.map +1 -0
- package/bin/terminal/auth/admin.js +18 -0
- package/bin/terminal/auth/admin.js.map +1 -0
- package/bin/terminal/auth/mode-select.d.ts +11 -0
- package/bin/terminal/auth/mode-select.d.ts.map +1 -0
- package/bin/terminal/auth/mode-select.js +33 -0
- package/bin/terminal/auth/mode-select.js.map +1 -0
- package/bin/terminal/auth/server-switch.d.ts +22 -0
- package/bin/terminal/auth/server-switch.d.ts.map +1 -0
- package/bin/terminal/auth/server-switch.js +241 -0
- package/bin/terminal/auth/server-switch.js.map +1 -0
- package/bin/terminal/auth/user.d.ts +19 -0
- package/bin/terminal/auth/user.d.ts.map +1 -0
- package/bin/terminal/auth/user.js +261 -0
- package/bin/terminal/auth/user.js.map +1 -0
- package/bin/terminal/core/browser.d.ts +12 -0
- package/bin/terminal/core/browser.d.ts.map +1 -0
- package/bin/terminal/core/browser.js +29 -0
- package/bin/terminal/core/browser.js.map +1 -0
- package/bin/terminal/core/env.d.ts +15 -0
- package/bin/terminal/core/env.d.ts.map +1 -0
- package/bin/terminal/core/env.js +67 -0
- package/bin/terminal/core/env.js.map +1 -0
- package/bin/terminal/core/session.d.ts +97 -0
- package/bin/terminal/core/session.d.ts.map +1 -0
- package/bin/terminal/core/session.js +342 -0
- package/bin/terminal/core/session.js.map +1 -0
- package/bin/terminal/core/stripe.d.ts +26 -0
- package/bin/terminal/core/stripe.d.ts.map +1 -0
- package/bin/terminal/core/stripe.js +22 -0
- package/bin/terminal/core/stripe.js.map +1 -0
- package/bin/terminal/core/ui.d.ts +29 -0
- package/bin/terminal/core/ui.d.ts.map +1 -0
- package/bin/terminal/core/ui.js +60 -0
- package/bin/terminal/core/ui.js.map +1 -0
- package/bin/terminal/core/update.d.ts +20 -0
- package/bin/terminal/core/update.d.ts.map +1 -0
- package/bin/terminal/core/update.js +193 -0
- package/bin/terminal/core/update.js.map +1 -0
- package/bin/terminal/user/balance.d.ts +31 -0
- package/bin/terminal/user/balance.d.ts.map +1 -0
- package/bin/terminal/user/balance.js +131 -0
- package/bin/terminal/user/balance.js.map +1 -0
- package/bin/terminal/user/chat.d.ts +12 -0
- package/bin/terminal/user/chat.d.ts.map +1 -0
- package/bin/terminal/user/chat.js +70 -0
- package/bin/terminal/user/chat.js.map +1 -0
- package/bin/terminal/user/loop.d.ts +13 -0
- package/bin/terminal/user/loop.d.ts.map +1 -0
- package/bin/terminal/user/loop.js +93 -0
- package/bin/terminal/user/loop.js.map +1 -0
- package/bin/terminal/user/models.d.ts +10 -0
- package/bin/terminal/user/models.d.ts.map +1 -0
- package/bin/terminal/user/models.js +39 -0
- package/bin/terminal/user/models.js.map +1 -0
- package/bin/utils/storage.d.ts +0 -1
- package/bin/utils/storage.d.ts.map +1 -1
- package/bin/utils/storage.js +0 -6
- package/bin/utils/storage.js.map +1 -1
- package/package.json +7 -3
- package/public/app.js +3 -3
- package/src/cli/Index.ts +2 -0
- package/src/cli/agent/AgentChat.ts +113 -289
- package/src/cli/agent/AgentChatTypes.ts +8 -12
- package/src/cli/agent/AgentHistory.ts +2 -2
- package/src/cli/agent/AgentManager.ts +27 -28
- package/src/cli/agent/AgentManagerTypes.ts +2 -2
- package/src/cli/agent/AgentReset.ts +4 -4
- package/src/cli/agent/AgentSelection.ts +6 -6
- package/src/cli/agent/AgentSelectionTypes.ts +1 -1
- package/src/cli/agent/Init.ts +13 -13
- package/src/cli/agent/Restart.ts +2 -2
- package/src/cli/agent/Run.ts +38 -17
- package/src/cli/agent/Start.ts +2 -2
- package/src/cli/agent/Stop.ts +2 -2
- package/src/cli/control-plane/ControlPlaneProcess.ts +5 -5
- package/src/cli/model/ModelCreateCommand.ts +1 -1
- package/src/cli/model/ModelManageCommand.ts +5 -3
- package/src/cli/model/ModelManager.ts +3 -3
- package/src/cli/model/ModelSupport.ts +2 -10
- package/src/cli/shared/CliReporterTypes.ts +1 -1
- package/src/cli/shared/Config.ts +2 -2
- package/src/cli/shared/Env.ts +22 -230
- package/src/cli/shared/IndexAgentCommand.ts +3 -4
- package/src/cli/shared/IndexSupport.ts +16 -10
- package/src/cli/shared/ManagedPluginActionCommands.ts +4 -4
- package/src/cli/shared/ManagedPluginRemote.ts +4 -4
- package/src/cli/shared/PluginTargetSupport.ts +19 -19
- package/src/cli/shared/Plugins.ts +10 -10
- package/src/cli/shared/PublicHostEnv.ts +2 -2
- package/src/cli/shared/Terminal.ts +24 -0
- package/src/config/DowncitySchema.ts +3 -113
- package/src/config/Paths.ts +9 -90
- package/src/control/ControlGateway.ts +3 -3
- package/src/control/EnvApiRoutes.ts +7 -91
- package/src/control/PlatformApiRoutes.ts +6 -6
- package/src/control/gateway/AgentActions.ts +10 -10
- package/src/control/gateway/AgentCatalog.ts +17 -21
- package/src/control/instant/InstantSessionRunner.ts +3 -1
- package/src/env/ProcessEnv.ts +43 -0
- package/src/http/auth/AuthEnv.ts +1 -1
- package/src/model/runtime/CreateRuntimeModel.ts +54 -37
- package/src/model/service/ModelPoolService.ts +13 -11
- package/src/platform/store/StoreEnvRepository.ts +31 -234
- package/src/platform/store/StoreSchema.ts +3 -49
- package/src/platform/store/index.ts +11 -80
- package/src/platform/store/schema.ts +2 -2
- package/src/process/daemon/Api.ts +1 -1
- package/src/process/daemon/CliArgs.ts +24 -1
- package/src/process/daemon/Client.ts +90 -22
- package/src/process/daemon/Manager.ts +2 -1
- package/src/terminal/admin/auth-error.ts +62 -0
- package/src/terminal/admin/commands/accounts.ts +44 -0
- package/src/terminal/admin/commands/balance.ts +160 -0
- package/src/terminal/admin/commands/config.ts +13 -0
- package/src/terminal/admin/commands/custom.ts +46 -0
- package/src/terminal/admin/commands/instruction.ts +12 -0
- package/src/terminal/admin/commands/models.ts +64 -0
- package/src/terminal/admin/commands/payment.ts +94 -0
- package/src/terminal/admin/commands/products.ts +72 -0
- package/src/terminal/admin/commands/service-env.ts +256 -0
- package/src/terminal/admin/commands/usage.ts +44 -0
- package/src/terminal/admin/loop.ts +69 -0
- package/src/terminal/agent/pi-agent.ts +180 -0
- package/src/terminal/app.ts +120 -0
- package/src/terminal/auth/admin.ts +21 -0
- package/src/terminal/auth/mode-select.ts +38 -0
- package/src/terminal/auth/server-switch.ts +275 -0
- package/src/terminal/auth/user.ts +351 -0
- package/src/terminal/core/browser.ts +31 -0
- package/src/terminal/core/env.ts +71 -0
- package/src/terminal/core/session.ts +450 -0
- package/src/terminal/core/stripe.ts +37 -0
- package/src/terminal/core/ui.ts +84 -0
- package/src/terminal/core/update.ts +230 -0
- package/src/terminal/user/balance.ts +215 -0
- package/src/terminal/user/chat.ts +80 -0
- package/src/terminal/user/loop.ts +112 -0
- package/src/terminal/user/models.ts +43 -0
- package/src/utils/storage.ts +0 -7
- package/bin/process/rpc/Client.d.ts +0 -13
- package/bin/process/rpc/Client.d.ts.map +0 -1
- package/bin/process/rpc/Client.js +0 -98
- package/bin/process/rpc/Client.js.map +0 -1
- package/bin/process/rpc/Paths.d.ts +0 -14
- package/bin/process/rpc/Paths.d.ts.map +0 -1
- package/bin/process/rpc/Paths.js +0 -36
- package/bin/process/rpc/Paths.js.map +0 -1
- package/src/process/rpc/Client.ts +0 -113
- package/src/process/rpc/Paths.ts +0 -43
|
@@ -15,18 +15,16 @@ export const AGENT_CHAT_DEFAULT_SESSION_ID = "local-cli-chat-main";
|
|
|
15
15
|
* `city agent chat` 命令选项。
|
|
16
16
|
*/
|
|
17
17
|
export interface AgentChatCliOptions {
|
|
18
|
-
/** 目标 agent
|
|
18
|
+
/** 目标 agent id。 */
|
|
19
19
|
to?: string;
|
|
20
20
|
/** 一次性发送的消息文本。 */
|
|
21
21
|
message?: string;
|
|
22
22
|
/** 是否输出 JSON。 */
|
|
23
23
|
json?: boolean;
|
|
24
|
-
/** 覆盖目标
|
|
24
|
+
/** 覆盖目标 RPC host。 */
|
|
25
25
|
host?: string;
|
|
26
|
-
/** 覆盖目标
|
|
26
|
+
/** 覆盖目标 RPC port。 */
|
|
27
27
|
port?: number;
|
|
28
|
-
/** 显式覆盖 Bearer Token。 */
|
|
29
|
-
token?: string;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
/**
|
|
@@ -45,7 +43,7 @@ export interface AgentChatExecuteResult {
|
|
|
45
43
|
* SDK prompt 响应体。
|
|
46
44
|
*/
|
|
47
45
|
export interface AgentChatExecuteResponse {
|
|
48
|
-
/**
|
|
46
|
+
/** 本轮 chat 执行是否成功。 */
|
|
49
47
|
success: boolean;
|
|
50
48
|
/** 实际执行使用的 sessionId。 */
|
|
51
49
|
sessionId?: string;
|
|
@@ -59,20 +57,18 @@ export interface AgentChatExecuteResponse {
|
|
|
59
57
|
* 复用 chat transport 时的基础选项。
|
|
60
58
|
*/
|
|
61
59
|
export interface AgentChatTransportOptions {
|
|
62
|
-
/** 覆盖目标
|
|
60
|
+
/** 覆盖目标 RPC host。 */
|
|
63
61
|
host?: string;
|
|
64
|
-
/** 覆盖目标
|
|
62
|
+
/** 覆盖目标 RPC port。 */
|
|
65
63
|
port?: number;
|
|
66
|
-
/** 显式覆盖 Bearer Token。 */
|
|
67
|
-
token?: string;
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
/**
|
|
71
67
|
* 单轮 chat 执行结果。
|
|
72
68
|
*/
|
|
73
69
|
export interface AgentChatExecutionOutcome {
|
|
74
|
-
/** 目标 agent
|
|
75
|
-
|
|
70
|
+
/** 目标 agent id。 */
|
|
71
|
+
agentId: string;
|
|
76
72
|
/** 目标 agent 项目根目录。 */
|
|
77
73
|
projectRoot?: string;
|
|
78
74
|
/** 实际执行使用的 sessionId。 */
|
|
@@ -23,7 +23,7 @@ import type {
|
|
|
23
23
|
} from "./AgentHistoryTypes.js";
|
|
24
24
|
import { emitCliBlock } from "../shared/CliReporter.js";
|
|
25
25
|
import { printResult } from "@/utils/cli/CliOutput.js";
|
|
26
|
-
import {
|
|
26
|
+
import { resolveAgentId } from "../shared/IndexSupport.js";
|
|
27
27
|
|
|
28
28
|
function normalizeText(input: unknown): string {
|
|
29
29
|
return String(input || "").trim();
|
|
@@ -149,7 +149,7 @@ export async function agentHistoryCleanCommand(
|
|
|
149
149
|
|
|
150
150
|
const sessionDir = getDowncitySessionDirPath(
|
|
151
151
|
projectRoot,
|
|
152
|
-
|
|
152
|
+
resolveAgentId(projectRoot),
|
|
153
153
|
sessionId,
|
|
154
154
|
);
|
|
155
155
|
const chatDir = getDowncityChatSessionDirPath(projectRoot, sessionId);
|
|
@@ -56,9 +56,8 @@ async function loadAgentSummaries(): Promise<AgentManagerAgentSummary[]> {
|
|
|
56
56
|
const agents = await listRegisteredAgentsForCli();
|
|
57
57
|
return agents.map((agent) => {
|
|
58
58
|
const config = readAgentConfig(agent.projectRoot);
|
|
59
|
-
const configuredName = String(config?.name || "").trim();
|
|
60
59
|
return {
|
|
61
|
-
|
|
60
|
+
id: String(config?.id || "").trim() || agent.id,
|
|
62
61
|
projectRoot: agent.projectRoot,
|
|
63
62
|
status: agent.status,
|
|
64
63
|
modelId: readAgentModelId(config),
|
|
@@ -149,7 +148,7 @@ async function emitAgentManagerList(): Promise<void> {
|
|
|
149
148
|
summary: `${agents.length} registered`,
|
|
150
149
|
items: agents.map((agent) => ({
|
|
151
150
|
tone: agent.status === "running" ? "success" : "info",
|
|
152
|
-
title: agent.
|
|
151
|
+
title: agent.id,
|
|
153
152
|
facts: [
|
|
154
153
|
{ label: "Status", value: agent.status },
|
|
155
154
|
{ label: "Model", value: agent.modelId || "not configured" },
|
|
@@ -219,7 +218,7 @@ async function promptAgentProjectRoot(): Promise<AgentManagerAgentSummary | null
|
|
|
219
218
|
name: "projectRoot",
|
|
220
219
|
message: "选择要管理的 Agent",
|
|
221
220
|
choices: agents.map((agent) => ({
|
|
222
|
-
title: agent.
|
|
221
|
+
title: agent.id,
|
|
223
222
|
description: `${formatAgentListDescription(agent)} · ${agent.projectRoot}`,
|
|
224
223
|
value: agent.projectRoot,
|
|
225
224
|
})),
|
|
@@ -237,7 +236,7 @@ async function promptAgentAction(
|
|
|
237
236
|
const response = (await prompts({
|
|
238
237
|
type: "select",
|
|
239
238
|
name: "action",
|
|
240
|
-
message: `管理 agent · ${agent.
|
|
239
|
+
message: `管理 agent · ${agent.id}`,
|
|
241
240
|
choices: [
|
|
242
241
|
{
|
|
243
242
|
title: "查看状态",
|
|
@@ -265,9 +264,9 @@ async function promptAgentAction(
|
|
|
265
264
|
value: "chat",
|
|
266
265
|
},
|
|
267
266
|
{
|
|
268
|
-
title: "
|
|
269
|
-
description: `当前:${agent.
|
|
270
|
-
value: "
|
|
267
|
+
title: "配置 ID",
|
|
268
|
+
description: `当前:${agent.id}`,
|
|
269
|
+
value: "configureId",
|
|
271
270
|
},
|
|
272
271
|
{
|
|
273
272
|
title: "配置模型",
|
|
@@ -363,50 +362,50 @@ async function runStartFlow(): Promise<void> {
|
|
|
363
362
|
await startAgentProject(projectRoot);
|
|
364
363
|
}
|
|
365
364
|
|
|
366
|
-
async function
|
|
365
|
+
async function configureAgentId(agent: AgentManagerAgentSummary): Promise<AgentManagerAgentSummary> {
|
|
367
366
|
const response = (await prompts({
|
|
368
367
|
type: "text",
|
|
369
|
-
name: "
|
|
370
|
-
message: "Agent
|
|
371
|
-
initial: agent.
|
|
368
|
+
name: "id",
|
|
369
|
+
message: "Agent ID",
|
|
370
|
+
initial: agent.id,
|
|
372
371
|
validate: (value) =>
|
|
373
|
-
String(value || "").trim().length > 0 ? true : "Agent
|
|
374
|
-
})) as {
|
|
372
|
+
String(value || "").trim().length > 0 ? true : "Agent ID 不能为空",
|
|
373
|
+
})) as { id?: string };
|
|
375
374
|
|
|
376
|
-
if (response.
|
|
375
|
+
if (response.id === undefined) {
|
|
377
376
|
emitCliBlock({
|
|
378
377
|
tone: "info",
|
|
379
|
-
title: "Agent
|
|
378
|
+
title: "Agent id unchanged",
|
|
380
379
|
});
|
|
381
380
|
return agent;
|
|
382
381
|
}
|
|
383
382
|
|
|
384
|
-
const
|
|
385
|
-
if (
|
|
383
|
+
const nextId = String(response.id || "").trim();
|
|
384
|
+
if (nextId === agent.id) {
|
|
386
385
|
emitCliBlock({
|
|
387
386
|
tone: "info",
|
|
388
|
-
title: "Agent
|
|
389
|
-
summary: agent.
|
|
387
|
+
title: "Agent id unchanged",
|
|
388
|
+
summary: agent.id,
|
|
390
389
|
});
|
|
391
390
|
return agent;
|
|
392
391
|
}
|
|
393
392
|
|
|
394
393
|
const shipJsonPath = getDowncityJsonPath(agent.projectRoot);
|
|
395
394
|
const raw = fs.readJsonSync(shipJsonPath) as DowncityConfig;
|
|
396
|
-
raw.
|
|
395
|
+
raw.id = nextId;
|
|
397
396
|
await fs.writeJson(shipJsonPath, raw, { spaces: 2 });
|
|
398
397
|
emitCliBlock({
|
|
399
398
|
tone: "success",
|
|
400
|
-
title: "Agent
|
|
399
|
+
title: "Agent id updated",
|
|
401
400
|
facts: [
|
|
402
|
-
{ label: "previous", value: agent.
|
|
403
|
-
{ label: "current", value:
|
|
401
|
+
{ label: "previous", value: agent.id },
|
|
402
|
+
{ label: "current", value: nextId },
|
|
404
403
|
{ label: "project", value: agent.projectRoot },
|
|
405
404
|
],
|
|
406
405
|
});
|
|
407
406
|
return {
|
|
408
407
|
...agent,
|
|
409
|
-
|
|
408
|
+
id: nextId,
|
|
410
409
|
};
|
|
411
410
|
}
|
|
412
411
|
|
|
@@ -595,11 +594,11 @@ async function runSelectedAgentManager(): Promise<void> {
|
|
|
595
594
|
continue;
|
|
596
595
|
}
|
|
597
596
|
if (action === "chat") {
|
|
598
|
-
await chatCommand({ to: agent.
|
|
597
|
+
await chatCommand({ to: agent.id });
|
|
599
598
|
continue;
|
|
600
599
|
}
|
|
601
|
-
if (action === "
|
|
602
|
-
agent = await
|
|
600
|
+
if (action === "configureId") {
|
|
601
|
+
agent = await configureAgentId(agent);
|
|
603
602
|
continue;
|
|
604
603
|
}
|
|
605
604
|
if (action === "configureModel") {
|
|
@@ -15,13 +15,13 @@ export type AgentManagerAgentAction =
|
|
|
15
15
|
| "stop"
|
|
16
16
|
| "restart"
|
|
17
17
|
| "chat"
|
|
18
|
-
| "
|
|
18
|
+
| "configureId"
|
|
19
19
|
| "configureModel"
|
|
20
20
|
| "connectChannels"
|
|
21
21
|
| "back";
|
|
22
22
|
|
|
23
23
|
export interface AgentManagerAgentSummary {
|
|
24
|
-
|
|
24
|
+
id: string;
|
|
25
25
|
projectRoot: string;
|
|
26
26
|
status: "running" | "stopped";
|
|
27
27
|
modelId?: string;
|
|
@@ -14,7 +14,7 @@ import { getDowncityJsonPath } from "@/config/Paths.js";
|
|
|
14
14
|
import { PlatformStore } from "@/platform/store/index.js";
|
|
15
15
|
import { emitCliBlock } from "../shared/CliReporter.js";
|
|
16
16
|
import { CliError } from "../shared/CliError.js";
|
|
17
|
-
import {
|
|
17
|
+
import { resolveAgentId } from "../shared/IndexSupport.js";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* 读取当前 agent 的 execution.modelId。
|
|
@@ -100,7 +100,7 @@ export async function agentResetCommand(cwd: string = "."): Promise<void> {
|
|
|
100
100
|
emitCliBlock({
|
|
101
101
|
tone: "info",
|
|
102
102
|
title: "Agent reset cancelled",
|
|
103
|
-
summary:
|
|
103
|
+
summary: resolveAgentId(projectRoot),
|
|
104
104
|
});
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
@@ -109,7 +109,7 @@ export async function agentResetCommand(cwd: string = "."): Promise<void> {
|
|
|
109
109
|
emitCliBlock({
|
|
110
110
|
tone: "info",
|
|
111
111
|
title: "Model unchanged",
|
|
112
|
-
summary:
|
|
112
|
+
summary: resolveAgentId(projectRoot),
|
|
113
113
|
facts: [
|
|
114
114
|
{ label: "modelId", value: current },
|
|
115
115
|
{ label: "project", value: projectRoot },
|
|
@@ -126,7 +126,7 @@ export async function agentResetCommand(cwd: string = "."): Promise<void> {
|
|
|
126
126
|
emitCliBlock({
|
|
127
127
|
tone: "success",
|
|
128
128
|
title: "Agent reconfigured",
|
|
129
|
-
summary:
|
|
129
|
+
summary: resolveAgentId(projectRoot),
|
|
130
130
|
facts: [
|
|
131
131
|
{ label: "previous", value: current || "(none)" },
|
|
132
132
|
{ label: "current", value: nextModelId },
|
|
@@ -22,7 +22,7 @@ import type {
|
|
|
22
22
|
import { emitCliBlock, emitCliList } from "../shared/CliReporter.js";
|
|
23
23
|
import { printResult } from "@/utils/cli/CliOutput.js";
|
|
24
24
|
import { CliError } from "../shared/CliError.js";
|
|
25
|
-
import {
|
|
25
|
+
import { resolveAgentId } from "../shared/IndexSupport.js";
|
|
26
26
|
import { resolveRunningManagedAgents } from "../control-plane/ControlPlaneProcess.js";
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -40,7 +40,7 @@ function toCliRegisteredAgentView(
|
|
|
40
40
|
): CliRegisteredAgentView {
|
|
41
41
|
const projectRoot = resolve(String(entry.projectRoot || "").trim() || ".");
|
|
42
42
|
return {
|
|
43
|
-
|
|
43
|
+
id: resolveAgentId(projectRoot),
|
|
44
44
|
projectRoot,
|
|
45
45
|
status: entry.status === "stopped" ? "stopped" : "running",
|
|
46
46
|
};
|
|
@@ -66,7 +66,7 @@ export async function listRegisteredAgentsForCli(): Promise<CliRegisteredAgentVi
|
|
|
66
66
|
} satisfies CliRegisteredAgentView;
|
|
67
67
|
})
|
|
68
68
|
.sort((left, right) =>
|
|
69
|
-
left.
|
|
69
|
+
left.id.localeCompare(right.id) || left.projectRoot.localeCompare(right.projectRoot),
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -77,7 +77,7 @@ export function buildCliAgentPromptChoices(
|
|
|
77
77
|
agents: CliRegisteredAgentView[],
|
|
78
78
|
): CliAgentPromptChoice[] {
|
|
79
79
|
return agents.map((agent) => ({
|
|
80
|
-
title: agent.
|
|
80
|
+
title: agent.id,
|
|
81
81
|
value: agent.projectRoot,
|
|
82
82
|
description: `${agent.status} · ${agent.projectRoot}`,
|
|
83
83
|
}));
|
|
@@ -165,7 +165,7 @@ export async function emitRegisteredAgentList(): Promise<void> {
|
|
|
165
165
|
summary: `${filteredAgents.length} registered`,
|
|
166
166
|
items: filteredAgents.map((agent) => ({
|
|
167
167
|
tone: agent.status === "running" ? "success" : "info",
|
|
168
|
-
title: agent.
|
|
168
|
+
title: agent.id,
|
|
169
169
|
facts: [
|
|
170
170
|
{
|
|
171
171
|
label: "Project",
|
|
@@ -232,7 +232,7 @@ export async function emitRegisteredAgentListWithOptions(options?: {
|
|
|
232
232
|
: `${agents.length} registered`,
|
|
233
233
|
items: agents.map((agent) => ({
|
|
234
234
|
tone: agent.status === "running" ? "success" : "info",
|
|
235
|
-
title: agent.
|
|
235
|
+
title: agent.id,
|
|
236
236
|
facts: [
|
|
237
237
|
{
|
|
238
238
|
label: "Project",
|
package/src/cli/agent/Init.ts
CHANGED
|
@@ -18,7 +18,7 @@ import fg from "fast-glob";
|
|
|
18
18
|
import { getProfileMdPath, getDowncityJsonPath, getSoulMdPath } from "@/config/Paths.js";
|
|
19
19
|
import {
|
|
20
20
|
initializeAgentProject,
|
|
21
|
-
|
|
21
|
+
normalizeDefaultAgentId,
|
|
22
22
|
} from "@downcity/agent";
|
|
23
23
|
import type { AgentProjectChannel } from "@downcity/agent";
|
|
24
24
|
import type { ExecutionBindingConfig } from "@downcity/agent";
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
} from "@/model/runtime/ExecutionModelBinding.js";
|
|
31
31
|
|
|
32
32
|
type InitPromptResponse = {
|
|
33
|
-
|
|
33
|
+
id?: string;
|
|
34
34
|
primaryModelId?: string;
|
|
35
35
|
channels?: string[];
|
|
36
36
|
};
|
|
@@ -51,8 +51,8 @@ export async function initCommand(
|
|
|
51
51
|
): Promise<void> {
|
|
52
52
|
const projectRoot = path.resolve(cwd);
|
|
53
53
|
const projectBaseName = path.basename(projectRoot);
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const default_agent_id =
|
|
55
|
+
normalizeDefaultAgentId(projectBaseName) || projectBaseName;
|
|
56
56
|
let allowOverwrite = Boolean(options.force);
|
|
57
57
|
|
|
58
58
|
emitCliBlock({
|
|
@@ -96,13 +96,13 @@ export async function initCommand(
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// Collect configuration information
|
|
99
|
-
// 交互采集(中文):agent
|
|
99
|
+
// 交互采集(中文):agent id + model + channels。
|
|
100
100
|
const response = (await prompts([
|
|
101
101
|
{
|
|
102
102
|
type: "text",
|
|
103
|
-
name: "
|
|
104
|
-
message: "Agent
|
|
105
|
-
initial:
|
|
103
|
+
name: "id",
|
|
104
|
+
message: "Agent id",
|
|
105
|
+
initial: default_agent_id,
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
type: "select",
|
|
@@ -124,9 +124,9 @@ export async function initCommand(
|
|
|
124
124
|
},
|
|
125
125
|
])) as InitPromptResponse;
|
|
126
126
|
|
|
127
|
-
// 关键点(中文):
|
|
128
|
-
const
|
|
129
|
-
String(response.
|
|
127
|
+
// 关键点(中文):agent_id 同时用于 `downcity.json.id` 与 init 模板变量渲染,避免两处来源不一致。
|
|
128
|
+
const agent_id =
|
|
129
|
+
String(response.id || "").trim() || default_agent_id;
|
|
130
130
|
const primaryModelId =
|
|
131
131
|
String(response.primaryModelId || "").trim() || "default";
|
|
132
132
|
if (modelChoiceIds.length === 0) {
|
|
@@ -147,7 +147,7 @@ export async function initCommand(
|
|
|
147
147
|
const initResult = await initializeAgentProject(
|
|
148
148
|
{
|
|
149
149
|
projectRoot,
|
|
150
|
-
|
|
150
|
+
id: agent_id,
|
|
151
151
|
execution,
|
|
152
152
|
channels: selectedChannels,
|
|
153
153
|
forceOverwriteShipJson: allowOverwrite,
|
|
@@ -172,7 +172,7 @@ export async function initCommand(
|
|
|
172
172
|
emitCliBlock({
|
|
173
173
|
tone: "success",
|
|
174
174
|
title: "Initialization complete",
|
|
175
|
-
summary:
|
|
175
|
+
summary: agent_id,
|
|
176
176
|
});
|
|
177
177
|
emitCliList({
|
|
178
178
|
tone: "accent",
|
package/src/cli/agent/Restart.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { buildRunArgsFromOptions } from "@/process/daemon/CliArgs.js";
|
|
|
13
13
|
import { startDaemonProcess, stopDaemonProcess } from "@/process/daemon/Manager.js";
|
|
14
14
|
import type { StartOptions } from "@downcity/agent";
|
|
15
15
|
import { emitCliBlock } from "../shared/CliReporter.js";
|
|
16
|
-
import {
|
|
16
|
+
import { resolveAgentId } from "../shared/IndexSupport.js";
|
|
17
17
|
import { checkAgentPreflight } from "../shared/PluginTargetSupport.js";
|
|
18
18
|
import { CliError } from "../shared/CliError.js";
|
|
19
19
|
|
|
@@ -51,7 +51,7 @@ export async function restartCommand(
|
|
|
51
51
|
emitCliBlock({
|
|
52
52
|
tone: "success",
|
|
53
53
|
title: "Agent daemon restarted",
|
|
54
|
-
summary:
|
|
54
|
+
summary: resolveAgentId(projectRoot),
|
|
55
55
|
facts: [
|
|
56
56
|
{
|
|
57
57
|
label: "Project",
|
package/src/cli/agent/Run.ts
CHANGED
|
@@ -16,13 +16,15 @@ import {
|
|
|
16
16
|
loadDowncityConfig,
|
|
17
17
|
loadStaticSystemPrompts,
|
|
18
18
|
shellTools,
|
|
19
|
+
startServer,
|
|
19
20
|
StaticPromptCatalog,
|
|
20
21
|
} from "@downcity/agent";
|
|
21
22
|
import { createBuiltinPlugins } from "@downcity/plugins";
|
|
22
23
|
import type { StartOptions } from "@downcity/agent";
|
|
23
24
|
import { CliError } from "../shared/CliError.js";
|
|
24
25
|
import { createRuntimeModel } from "@/model/runtime/CreateRuntimeModel.js";
|
|
25
|
-
import {
|
|
26
|
+
import { readPlatformGlobalEnv } from "@/env/ProcessEnv.js";
|
|
27
|
+
import { resolveAgentId } from "../shared/IndexSupport.js";
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* 前台启动入口(由 `agent start` 前台模式与内部 daemon 子进程复用)。
|
|
@@ -30,7 +32,7 @@ import { resolveAgentName } from "../shared/IndexSupport.js";
|
|
|
30
32
|
* 职责(中文)
|
|
31
33
|
* - 初始化 agent 状态(配置、日志、services 依赖)
|
|
32
34
|
* - 解析并合并启动参数(CLI > downcity.json > 默认值)
|
|
33
|
-
* -
|
|
35
|
+
* - 启动 agent 本机 RPC 与 city 托管的 HTTP gateway(双端口)
|
|
34
36
|
* - 启动 services(例如 task cron)
|
|
35
37
|
* - 统一处理进程信号并优雅停机
|
|
36
38
|
*/
|
|
@@ -39,6 +41,7 @@ export async function runCommand(
|
|
|
39
41
|
options: StartOptions,
|
|
40
42
|
): Promise<void> {
|
|
41
43
|
const projectRoot = path.resolve(cwd);
|
|
44
|
+
const hostEnv = readPlatformGlobalEnv();
|
|
42
45
|
// 端口解析(中文):允许 number / string;空值返回 undefined 以便走配置回退链。
|
|
43
46
|
const parsePort = (
|
|
44
47
|
value: string | number | undefined,
|
|
@@ -57,30 +60,41 @@ export async function runCommand(
|
|
|
57
60
|
};
|
|
58
61
|
// Resolve startup options: CLI flags override built-in defaults.
|
|
59
62
|
let port: number;
|
|
63
|
+
let rpc_port: number;
|
|
60
64
|
try {
|
|
61
65
|
port = parsePort(options.port, "port") ?? 5314;
|
|
66
|
+
rpc_port = parsePort(options.rpcPort, "rpcPort") ?? 15314;
|
|
62
67
|
} catch (error) {
|
|
63
68
|
throw new CliError({
|
|
64
69
|
title: "Invalid start options",
|
|
65
70
|
note: error instanceof Error ? error.message : String(error),
|
|
66
71
|
});
|
|
67
72
|
}
|
|
73
|
+
if (port === rpc_port) {
|
|
74
|
+
throw new CliError({
|
|
75
|
+
title: "Invalid start options",
|
|
76
|
+
note: "port and rpcPort must be different",
|
|
77
|
+
});
|
|
78
|
+
}
|
|
68
79
|
|
|
69
80
|
const host = (options.host ?? "0.0.0.0").trim();
|
|
70
|
-
const
|
|
81
|
+
const rpc_host = "127.0.0.1";
|
|
82
|
+
const agentId = resolveAgentId(projectRoot);
|
|
71
83
|
let currentSystems = loadStaticSystemPrompts(projectRoot);
|
|
72
84
|
const config = loadDowncityConfig(projectRoot);
|
|
73
85
|
const model = await createRuntimeModel({
|
|
74
86
|
config,
|
|
87
|
+
env: hostEnv,
|
|
75
88
|
});
|
|
76
89
|
|
|
77
90
|
const agent = new Agent({
|
|
78
|
-
id:
|
|
91
|
+
id: agentId,
|
|
79
92
|
path: projectRoot,
|
|
80
93
|
instruction: currentSystems,
|
|
81
94
|
tools: shellTools,
|
|
82
95
|
plugins: createBuiltinPlugins(),
|
|
83
96
|
model,
|
|
97
|
+
env: hostEnv,
|
|
84
98
|
});
|
|
85
99
|
|
|
86
100
|
const promptCatalog = new StaticPromptCatalog({
|
|
@@ -94,30 +108,36 @@ export async function runCommand(
|
|
|
94
108
|
});
|
|
95
109
|
promptCatalog.start();
|
|
96
110
|
|
|
97
|
-
process.env.
|
|
98
|
-
process.env.
|
|
111
|
+
process.env.DC_CITY_PORT = String(port);
|
|
112
|
+
process.env.DC_CITY_HOST = host;
|
|
113
|
+
process.env.DC_AGENT_RPC_PORT = String(rpc_port);
|
|
114
|
+
process.env.DC_AGENT_RPC_HOST = rpc_host;
|
|
115
|
+
process.env.DC_AGENT_ID = agentId;
|
|
99
116
|
process.env.DC_AGENT_PATH = projectRoot;
|
|
100
|
-
process.env.DC_AGENT_NAME = agentName;
|
|
101
117
|
|
|
102
118
|
const startResult = await agent.start({
|
|
103
|
-
|
|
104
|
-
port,
|
|
105
|
-
host,
|
|
119
|
+
rpc: {
|
|
120
|
+
port: rpc_port,
|
|
121
|
+
host: rpc_host,
|
|
106
122
|
},
|
|
107
|
-
rpc: true,
|
|
108
123
|
plugins: true,
|
|
109
124
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const localRpc = startResult.rpc?.server;
|
|
113
|
-
if (!server || !localRpc) {
|
|
114
|
-
throw new Error("Agent start did not return expected HTTP/RPC bindings");
|
|
125
|
+
if (!startResult.rpc?.server) {
|
|
126
|
+
throw new Error("Agent start did not return expected RPC binding");
|
|
115
127
|
}
|
|
116
128
|
|
|
129
|
+
const server = await startServer({
|
|
130
|
+
host,
|
|
131
|
+
port,
|
|
132
|
+
getAgentRuntime: () => agent.getRuntime(),
|
|
133
|
+
getAgentContext: () => agent.getContext(),
|
|
134
|
+
sessionCollection: agent.getSessionCollection(),
|
|
135
|
+
});
|
|
136
|
+
|
|
117
137
|
const agentLogger = agent.getLogger();
|
|
118
138
|
|
|
119
139
|
// 处理进程信号
|
|
120
|
-
// 停机顺序(中文):plugin runtimes
|
|
140
|
+
// 停机顺序(中文):HTTP gateway -> plugin runtimes / RPC server -> flush logs。
|
|
121
141
|
let isShuttingDown = false;
|
|
122
142
|
const shutdown = async (signal: string) => {
|
|
123
143
|
if (isShuttingDown) return;
|
|
@@ -126,6 +146,7 @@ export async function runCommand(
|
|
|
126
146
|
agentLogger.info(`Received ${signal} signal, shutting down...`);
|
|
127
147
|
promptCatalog.stop();
|
|
128
148
|
|
|
149
|
+
await server.stop();
|
|
129
150
|
await agent.stop();
|
|
130
151
|
|
|
131
152
|
// Save logs
|
package/src/cli/agent/Start.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { startDaemonProcess } from "@/process/daemon/Manager.js";
|
|
|
17
17
|
import { buildRunArgsFromOptions } from "@/process/daemon/CliArgs.js";
|
|
18
18
|
import type { StartOptions } from "@downcity/agent";
|
|
19
19
|
import { emitCliBlock } from "../shared/CliReporter.js";
|
|
20
|
-
import {
|
|
20
|
+
import { resolveAgentId } from "../shared/IndexSupport.js";
|
|
21
21
|
import { checkAgentPreflight } from "../shared/PluginTargetSupport.js";
|
|
22
22
|
import { CliError } from "../shared/CliError.js";
|
|
23
23
|
|
|
@@ -55,7 +55,7 @@ export async function startCommand(
|
|
|
55
55
|
emitCliBlock({
|
|
56
56
|
tone: "success",
|
|
57
57
|
title: "Agent daemon started",
|
|
58
|
-
summary:
|
|
58
|
+
summary: resolveAgentId(projectRoot),
|
|
59
59
|
facts: [
|
|
60
60
|
{
|
|
61
61
|
label: "Project",
|
package/src/cli/agent/Stop.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import path from "path";
|
|
11
11
|
import { stopDaemonProcess } from "@/process/daemon/Manager.js";
|
|
12
12
|
import { emitCliBlock } from "../shared/CliReporter.js";
|
|
13
|
-
import {
|
|
13
|
+
import { resolveAgentId } from "../shared/IndexSupport.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* stop 命令执行流程。
|
|
@@ -26,7 +26,7 @@ export async function stopCommand(cwd: string = "."): Promise<void> {
|
|
|
26
26
|
emitCliBlock({
|
|
27
27
|
tone: result.stopped ? "success" : "info",
|
|
28
28
|
title: result.stopped ? "Agent daemon stopped" : "Agent daemon not running",
|
|
29
|
-
summary:
|
|
29
|
+
summary: resolveAgentId(projectRoot),
|
|
30
30
|
facts: [
|
|
31
31
|
{
|
|
32
32
|
label: "Project",
|
|
@@ -42,7 +42,7 @@ import { startCommand } from "../agent/Start.js";
|
|
|
42
42
|
import type { StartOptions } from "@downcity/agent";
|
|
43
43
|
import {
|
|
44
44
|
injectAgentContext,
|
|
45
|
-
|
|
45
|
+
resolveAgentId,
|
|
46
46
|
sleep,
|
|
47
47
|
} from "../shared/IndexSupport.js";
|
|
48
48
|
import { buildRuntimePortFacts } from "../shared/PortHints.js";
|
|
@@ -202,11 +202,11 @@ export async function stopCityRuntimeCommand(params?: { timeoutMs?: number }): P
|
|
|
202
202
|
try {
|
|
203
203
|
const result = await runWithSpinner(
|
|
204
204
|
() => stopDaemonProcess({ projectRoot: item.projectRoot }),
|
|
205
|
-
{ text: `Stopping ${
|
|
205
|
+
{ text: `Stopping ${resolveAgentId(item.projectRoot)}...` },
|
|
206
206
|
);
|
|
207
207
|
emitCliBlock({
|
|
208
208
|
tone: result.stopped ? "success" : "info",
|
|
209
|
-
title:
|
|
209
|
+
title: resolveAgentId(item.projectRoot),
|
|
210
210
|
summary: result.stopped ? "stopped" : "already stopped",
|
|
211
211
|
facts: [{ label: "project", value: item.projectRoot }],
|
|
212
212
|
});
|
|
@@ -214,7 +214,7 @@ export async function stopCityRuntimeCommand(params?: { timeoutMs?: number }): P
|
|
|
214
214
|
} catch (error) {
|
|
215
215
|
emitCliBlock({
|
|
216
216
|
tone: "error",
|
|
217
|
-
title:
|
|
217
|
+
title: resolveAgentId(item.projectRoot),
|
|
218
218
|
summary: "failed",
|
|
219
219
|
facts: [
|
|
220
220
|
{ label: "project", value: item.projectRoot },
|
|
@@ -368,7 +368,7 @@ export async function restartManagedAgents(cliPath: string): Promise<void> {
|
|
|
368
368
|
emitCliBlock({
|
|
369
369
|
tone: "error",
|
|
370
370
|
title: "Managed agent restart failed",
|
|
371
|
-
summary:
|
|
371
|
+
summary: resolveAgentId(item.projectRoot),
|
|
372
372
|
facts: [
|
|
373
373
|
{
|
|
374
374
|
label: "Project",
|
|
@@ -102,7 +102,7 @@ async function runInteractiveProviderCreate(
|
|
|
102
102
|
{
|
|
103
103
|
type: "text",
|
|
104
104
|
name: "apiKey",
|
|
105
|
-
message: "API Key
|
|
105
|
+
message: "API Key",
|
|
106
106
|
validate: (value: string) =>
|
|
107
107
|
String(value || "").trim().length > 0 ? true : "apiKey 不能为空",
|
|
108
108
|
},
|