@downcity/city 1.1.32 → 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 +10 -3
- 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.d.ts.map +1 -1
- package/bin/cli/agent/Init.js +17 -17
- 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 +44 -30
- 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.d.ts.map +1 -1
- package/bin/cli/control-plane/ControlPlaneProcess.js +7 -8
- 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/ChatAuth.d.ts.map +1 -1
- package/bin/cli/shared/ChatAuth.js +5 -7
- package/bin/cli/shared/ChatAuth.js.map +1 -1
- package/bin/cli/shared/ChatManager.d.ts.map +1 -1
- package/bin/cli/shared/ChatManager.js +2 -3
- package/bin/cli/shared/ChatManager.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 +2 -1
- package/bin/cli/shared/ManagedPluginActionCommands.d.ts.map +1 -1
- package/bin/cli/shared/ManagedPluginActionCommands.js +9 -7
- 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/PluginScheduleCommand.d.ts +3 -2
- package/bin/cli/shared/PluginScheduleCommand.d.ts.map +1 -1
- package/bin/cli/shared/PluginScheduleCommand.js +11 -10
- package/bin/cli/shared/PluginScheduleCommand.js.map +1 -1
- package/bin/cli/shared/PluginTargetSupport.d.ts +6 -6
- package/bin/cli/shared/PluginTargetSupport.d.ts.map +1 -1
- package/bin/cli/shared/PluginTargetSupport.js +23 -24
- package/bin/cli/shared/PluginTargetSupport.js.map +1 -1
- package/bin/cli/shared/Plugins.d.ts.map +1 -1
- package/bin/cli/shared/Plugins.js +22 -16
- 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/ChannelAccountApiRoutes.d.ts.map +1 -1
- package/bin/control/ChannelAccountApiRoutes.js +2 -3
- package/bin/control/ChannelAccountApiRoutes.js.map +1 -1
- package/bin/control/ControlGateway.d.ts.map +1 -1
- package/bin/control/ControlGateway.js +4 -3
- 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/PluginApiRoutes.d.ts.map +1 -1
- package/bin/control/PluginApiRoutes.js +33 -25
- package/bin/control/PluginApiRoutes.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 +23 -18
- 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 +6 -6
- package/bin/model/runtime/CreateRuntimeModel.d.ts.map +1 -1
- package/bin/model/runtime/CreateRuntimeModel.js +44 -53
- package/bin/model/runtime/CreateRuntimeModel.js.map +1 -1
- package/bin/model/runtime/ExecutionModelBinding.d.ts +46 -0
- package/bin/model/runtime/ExecutionModelBinding.d.ts.map +1 -0
- package/bin/model/runtime/ExecutionModelBinding.js +96 -0
- package/bin/model/runtime/ExecutionModelBinding.js.map +1 -0
- 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/process/registry/AgentHostRuntime.d.ts +1 -9
- package/bin/process/registry/AgentHostRuntime.d.ts.map +1 -1
- package/bin/process/registry/AgentHostRuntime.js +1 -155
- package/bin/process/registry/AgentHostRuntime.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 -2
- package/public/app.js +3 -3
- package/src/cli/Index.ts +13 -3
- 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 +22 -21
- package/src/cli/agent/Restart.ts +2 -2
- package/src/cli/agent/Run.ts +46 -30
- package/src/cli/agent/Start.ts +2 -2
- package/src/cli/agent/Stop.ts +2 -2
- package/src/cli/control-plane/ControlPlaneProcess.ts +7 -8
- 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/ChatAuth.ts +10 -11
- package/src/cli/shared/ChatManager.ts +2 -3
- 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 +15 -12
- package/src/cli/shared/ManagedPluginRemote.ts +4 -4
- package/src/cli/shared/PluginScheduleCommand.ts +11 -10
- package/src/cli/shared/PluginTargetSupport.ts +25 -26
- package/src/cli/shared/Plugins.ts +26 -20
- 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/ChannelAccountApiRoutes.ts +2 -3
- package/src/control/ControlGateway.ts +6 -5
- package/src/control/EnvApiRoutes.ts +7 -91
- package/src/control/PlatformApiRoutes.ts +6 -6
- package/src/control/PluginApiRoutes.ts +37 -27
- package/src/control/gateway/AgentActions.ts +26 -21
- 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 +51 -59
- package/src/model/runtime/ExecutionModelBinding.ts +120 -0
- 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/process/registry/AgentHostRuntime.ts +1 -163
- 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/tsconfig.json +2 -1
- package/bin/platform/chatAuthorization/Store.d.ts +0 -31
- package/bin/platform/chatAuthorization/Store.d.ts.map +0 -1
- package/bin/platform/chatAuthorization/Store.js +0 -145
- package/bin/platform/chatAuthorization/Store.js.map +0 -1
- 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/platform/chatAuthorization/Store.ts +0 -181
- package/src/process/rpc/Client.ts +0 -113
- package/src/process/rpc/Paths.ts +0 -43
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExecutionModelBinding:city 宿主侧执行模型绑定辅助。
|
|
3
|
+
*
|
|
4
|
+
* 职责说明(中文)
|
|
5
|
+
* - 统一承接平台模型池读取、模型候选列表构建与项目 execution.modelId 校验。
|
|
6
|
+
* - 保证 `Agent` 只接收最终 `LanguageModel`,不再承担模型池查询职责。
|
|
7
|
+
* - 让 CLI、control gateway、前台启动等宿主入口复用同一套模型绑定规则。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from "fs-extra";
|
|
11
|
+
import type { DowncityConfig, StoredModelProvider } from "@downcity/agent";
|
|
12
|
+
import { assertProjectExecutionTarget } from "@downcity/agent";
|
|
13
|
+
import { getDowncityJsonPath } from "@/config/Paths.js";
|
|
14
|
+
import { PlatformStore } from "@/platform/store/index.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 平台模型下拉候选项。
|
|
18
|
+
*/
|
|
19
|
+
export interface PlatformModelChoice {
|
|
20
|
+
/**
|
|
21
|
+
* 下拉展示文案。
|
|
22
|
+
*/
|
|
23
|
+
title: string;
|
|
24
|
+
/**
|
|
25
|
+
* 实际写入 `execution.modelId` 的模型 ID。
|
|
26
|
+
*/
|
|
27
|
+
value: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 读取平台模型候选列表。
|
|
32
|
+
*
|
|
33
|
+
* 关键点(中文)
|
|
34
|
+
* - 输出结果面向 CLI/Console 的模型选择界面。
|
|
35
|
+
* - provider 信息会拼到标题中,便于区分同名模型。
|
|
36
|
+
*/
|
|
37
|
+
export async function listPlatformModelChoices(): Promise<PlatformModelChoice[]> {
|
|
38
|
+
const store = new PlatformStore();
|
|
39
|
+
try {
|
|
40
|
+
const models = store.listModels();
|
|
41
|
+
const providers = await store.listProviders();
|
|
42
|
+
const providerMap = new Map(providers.map((item) => [item.id, item] as const));
|
|
43
|
+
return models
|
|
44
|
+
.map((item) => buildPlatformModelChoice(item.id, item.providerId, providerMap))
|
|
45
|
+
.filter((item): item is PlatformModelChoice => item !== null);
|
|
46
|
+
} finally {
|
|
47
|
+
store.close();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function buildPlatformModelChoice(
|
|
52
|
+
modelId: string,
|
|
53
|
+
providerId: string,
|
|
54
|
+
providerMap: Map<string, StoredModelProvider>,
|
|
55
|
+
): PlatformModelChoice | null {
|
|
56
|
+
const id = String(modelId || "").trim();
|
|
57
|
+
if (!id) return null;
|
|
58
|
+
const normalizedProviderId = String(providerId || "").trim();
|
|
59
|
+
const providerType = String(providerMap.get(normalizedProviderId)?.type || "").trim();
|
|
60
|
+
const providerLabel = normalizedProviderId
|
|
61
|
+
? providerType
|
|
62
|
+
? `${normalizedProviderId} (${providerType})`
|
|
63
|
+
: normalizedProviderId
|
|
64
|
+
: "-";
|
|
65
|
+
return {
|
|
66
|
+
title: `${id} · ${providerLabel}`,
|
|
67
|
+
value: id,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 断言指定平台模型可用于 agent execution。
|
|
73
|
+
*
|
|
74
|
+
* 关键点(中文)
|
|
75
|
+
* - 当前只校验“存在且未暂停”。
|
|
76
|
+
* - 供应商连通性与 API Key 可用性仍交给真正创建模型实例时再校验。
|
|
77
|
+
*/
|
|
78
|
+
export function assertPlatformModelReady(modelId: string): void {
|
|
79
|
+
const normalizedModelId = String(modelId || "").trim();
|
|
80
|
+
if (!normalizedModelId) {
|
|
81
|
+
throw new Error("execution.modelId is required");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const store = new PlatformStore();
|
|
85
|
+
try {
|
|
86
|
+
const model = store.getModel(normalizedModelId);
|
|
87
|
+
if (!model) {
|
|
88
|
+
throw new Error(`Model not found in platform model pool: ${normalizedModelId}`);
|
|
89
|
+
}
|
|
90
|
+
if (model.isPaused === true) {
|
|
91
|
+
throw new Error(`Model is paused: ${normalizedModelId}`);
|
|
92
|
+
}
|
|
93
|
+
} finally {
|
|
94
|
+
store.close();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 断言项目 execution 绑定已声明且目标模型可用。
|
|
100
|
+
*
|
|
101
|
+
* 关键点(中文)
|
|
102
|
+
* - 这里是 city 启动/控制面入口的宿主前置校验。
|
|
103
|
+
* - 失败时抛出稳定错误,交由 CLI 或 HTTP 层决定如何展示。
|
|
104
|
+
*/
|
|
105
|
+
export function assertProjectExecutionModelReady(projectRoot: string): void {
|
|
106
|
+
const config = readProjectDowncityConfig(projectRoot);
|
|
107
|
+
assertProjectExecutionTarget(config);
|
|
108
|
+
const primaryModelId = String(config.execution?.type === "api" ? config.execution.modelId || "" : "").trim();
|
|
109
|
+
if (!primaryModelId) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
'Invalid downcity.json: "execution" is required and must be { "type": "api", "modelId": "..." }',
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
assertPlatformModelReady(primaryModelId);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function readProjectDowncityConfig(projectRoot: string): DowncityConfig {
|
|
118
|
+
const shipJsonPath = getDowncityJsonPath(projectRoot);
|
|
119
|
+
return fs.readJsonSync(shipJsonPath) as DowncityConfig;
|
|
120
|
+
}
|
|
@@ -19,6 +19,7 @@ import { PlatformStore } from "@/platform/store/index.js";
|
|
|
19
19
|
import { listManagedAgentEntries } from "@/process/registry/CityRegistry.js";
|
|
20
20
|
import { discoverProviderModels } from "@/cli/model/ModelSupport.js";
|
|
21
21
|
import { createRuntimeModel } from "@/model/runtime/CreateRuntimeModel.js";
|
|
22
|
+
import { mergeProcessEnvWithPlatformGlobalEnv } from "@/env/ProcessEnv.js";
|
|
22
23
|
|
|
23
24
|
const SUPPORTED_PROVIDER_TYPES: readonly LlmProviderType[] = [
|
|
24
25
|
"anthropic",
|
|
@@ -77,11 +78,11 @@ function formatModelIds(modelIds: string[]): string {
|
|
|
77
78
|
function formatAgentReference(reference: {
|
|
78
79
|
projectRoot: string;
|
|
79
80
|
shipJsonPath: string;
|
|
80
|
-
|
|
81
|
+
agentId?: string;
|
|
81
82
|
}): string {
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
return `${
|
|
83
|
+
const agentId = String(reference.agentId || "").trim();
|
|
84
|
+
if (agentId) {
|
|
85
|
+
return `${agentId} (${reference.projectRoot})`;
|
|
85
86
|
}
|
|
86
87
|
return reference.projectRoot;
|
|
87
88
|
}
|
|
@@ -89,12 +90,12 @@ function formatAgentReference(reference: {
|
|
|
89
90
|
async function listModelReferences(modelId: string): Promise<Array<{
|
|
90
91
|
projectRoot: string;
|
|
91
92
|
shipJsonPath: string;
|
|
92
|
-
|
|
93
|
+
agentId?: string;
|
|
93
94
|
}>> {
|
|
94
95
|
const references: Array<{
|
|
95
96
|
projectRoot: string;
|
|
96
97
|
shipJsonPath: string;
|
|
97
|
-
|
|
98
|
+
agentId?: string;
|
|
98
99
|
}> = [];
|
|
99
100
|
const entries = await listManagedAgentEntries();
|
|
100
101
|
for (const entry of entries) {
|
|
@@ -104,7 +105,7 @@ async function listModelReferences(modelId: string): Promise<Array<{
|
|
|
104
105
|
if (!(await fs.pathExists(shipJsonPath))) continue;
|
|
105
106
|
try {
|
|
106
107
|
const raw = (await fs.readJson(shipJsonPath)) as {
|
|
107
|
-
|
|
108
|
+
id?: unknown;
|
|
108
109
|
execution?: {
|
|
109
110
|
type?: unknown;
|
|
110
111
|
modelId?: unknown;
|
|
@@ -113,11 +114,11 @@ async function listModelReferences(modelId: string): Promise<Array<{
|
|
|
113
114
|
const executionType = String(raw?.execution?.type || "").trim();
|
|
114
115
|
const candidateModelId = String(raw?.execution?.modelId || "").trim();
|
|
115
116
|
if (executionType !== "api" || candidateModelId !== modelId) continue;
|
|
116
|
-
const
|
|
117
|
+
const agentId = String(raw?.id || "").trim() || undefined;
|
|
117
118
|
references.push({
|
|
118
119
|
projectRoot,
|
|
119
120
|
shipJsonPath,
|
|
120
|
-
|
|
121
|
+
agentId,
|
|
121
122
|
});
|
|
122
123
|
} catch {
|
|
123
124
|
continue;
|
|
@@ -218,7 +219,7 @@ export class ModelPoolService {
|
|
|
218
219
|
references: Array<{
|
|
219
220
|
projectRoot: string;
|
|
220
221
|
shipJsonPath: string;
|
|
221
|
-
|
|
222
|
+
agentId?: string;
|
|
222
223
|
}>;
|
|
223
224
|
}> {
|
|
224
225
|
const id = String(modelId || "").trim();
|
|
@@ -507,10 +508,11 @@ export class ModelPoolService {
|
|
|
507
508
|
const actualPrompt = String(prompt || "").trim() || "Reply with exactly: OK";
|
|
508
509
|
const model = await createRuntimeModel({
|
|
509
510
|
config: {
|
|
510
|
-
|
|
511
|
+
id: "console_model_test",
|
|
511
512
|
version: "1.0.0",
|
|
512
513
|
execution: { type: "api", modelId: id },
|
|
513
514
|
},
|
|
515
|
+
env: mergeProcessEnvWithPlatformGlobalEnv(process.env),
|
|
514
516
|
});
|
|
515
517
|
const result = await generateText({
|
|
516
518
|
model,
|
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 统一管理 `env_entries` 单表。
|
|
6
|
-
* -
|
|
6
|
+
* - 当前版本只保留平台全局 env,不再区分 agent 私有层。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type {
|
|
10
|
-
StoredAgentEnvEntry,
|
|
11
10
|
StoredEnvEntry,
|
|
12
|
-
StoredEnvScope,
|
|
13
11
|
StoredGlobalEnvEntry,
|
|
14
|
-
UpsertAgentEnvEntryInput,
|
|
15
12
|
UpsertEnvEntryInput,
|
|
16
13
|
UpsertGlobalEnvEntryInput,
|
|
17
14
|
} from "@downcity/agent";
|
|
@@ -19,26 +16,6 @@ import { decryptText, decryptTextSync, encryptText } from "./crypto.js";
|
|
|
19
16
|
import type { PlatformStoreContext } from "./StoreShared.js";
|
|
20
17
|
import { normalizeNonEmptyText, nowIso } from "./StoreShared.js";
|
|
21
18
|
|
|
22
|
-
/**
|
|
23
|
-
* 规范化 env scope。
|
|
24
|
-
*/
|
|
25
|
-
export function normalizeEnvScope(input: string): StoredEnvScope {
|
|
26
|
-
const scope = String(input || "").trim().toLowerCase();
|
|
27
|
-
if (scope === "agent") return "agent";
|
|
28
|
-
return "global";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 规范化 env 的 agent 目标。
|
|
33
|
-
*/
|
|
34
|
-
export function normalizeEnvAgentTarget(
|
|
35
|
-
scope: StoredEnvScope,
|
|
36
|
-
agentIdInput?: string,
|
|
37
|
-
): string {
|
|
38
|
-
if (scope === "global") return "";
|
|
39
|
-
return normalizeNonEmptyText(agentIdInput || "", "agentId");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
19
|
/**
|
|
43
20
|
* 同步构造 env 条目。
|
|
44
21
|
*/
|
|
@@ -51,14 +28,12 @@ function buildEnvEntryFromRowSync(row: {
|
|
|
51
28
|
created_at?: unknown;
|
|
52
29
|
updated_at?: unknown;
|
|
53
30
|
}): StoredEnvEntry | null {
|
|
54
|
-
const scope = normalizeEnvScope(String(row.scope || ""));
|
|
55
|
-
const agentId = String(row.agent_id || "").trim();
|
|
56
31
|
const key = String(row.key || "").trim();
|
|
57
32
|
const encrypted = typeof row.value_encrypted === "string" ? row.value_encrypted : "";
|
|
33
|
+
if (String(row.scope || "").trim() !== "global") return null;
|
|
58
34
|
if (!key || !encrypted) return null;
|
|
59
35
|
return {
|
|
60
|
-
scope,
|
|
61
|
-
agentId: scope === "agent" ? agentId : undefined,
|
|
36
|
+
scope: "global",
|
|
62
37
|
key,
|
|
63
38
|
description: String(row.description || "").trim() || undefined,
|
|
64
39
|
value: decryptTextSync(encrypted),
|
|
@@ -79,14 +54,12 @@ async function buildEnvEntryFromRow(row: {
|
|
|
79
54
|
created_at?: unknown;
|
|
80
55
|
updated_at?: unknown;
|
|
81
56
|
}): Promise<StoredEnvEntry | null> {
|
|
82
|
-
const scope = normalizeEnvScope(String(row.scope || ""));
|
|
83
|
-
const agentId = String(row.agent_id || "").trim();
|
|
84
57
|
const key = String(row.key || "").trim();
|
|
85
58
|
const encrypted = typeof row.value_encrypted === "string" ? row.value_encrypted : "";
|
|
59
|
+
if (String(row.scope || "").trim() !== "global") return null;
|
|
86
60
|
if (!key || !encrypted) return null;
|
|
87
61
|
return {
|
|
88
|
-
scope,
|
|
89
|
-
agentId: scope === "agent" ? agentId : undefined,
|
|
62
|
+
scope: "global",
|
|
90
63
|
key,
|
|
91
64
|
description: String(row.description || "").trim() || undefined,
|
|
92
65
|
value: await decryptText(encrypted),
|
|
@@ -100,49 +73,15 @@ async function buildEnvEntryFromRow(row: {
|
|
|
100
73
|
*/
|
|
101
74
|
export function listEnvEntriesSync(
|
|
102
75
|
context: PlatformStoreContext,
|
|
103
|
-
scopeInput?: StoredEnvScope,
|
|
104
|
-
agentIdInput?: string,
|
|
105
76
|
): StoredEnvEntry[] {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
`
|
|
115
|
-
SELECT scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
116
|
-
FROM env_entries
|
|
117
|
-
WHERE scope = 'agent' AND agent_id = ?
|
|
118
|
-
ORDER BY key ASC;
|
|
119
|
-
`,
|
|
120
|
-
).all(agentId)
|
|
121
|
-
: scope === "agent"
|
|
122
|
-
? context.sqlite.prepare(
|
|
123
|
-
`
|
|
124
|
-
SELECT scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
125
|
-
FROM env_entries
|
|
126
|
-
WHERE scope = 'agent'
|
|
127
|
-
ORDER BY agent_id ASC, key ASC;
|
|
128
|
-
`,
|
|
129
|
-
).all()
|
|
130
|
-
: scope === "global"
|
|
131
|
-
? context.sqlite.prepare(
|
|
132
|
-
`
|
|
133
|
-
SELECT scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
134
|
-
FROM env_entries
|
|
135
|
-
WHERE scope = 'global'
|
|
136
|
-
ORDER BY key ASC;
|
|
137
|
-
`,
|
|
138
|
-
).all()
|
|
139
|
-
: context.sqlite.prepare(
|
|
140
|
-
`
|
|
141
|
-
SELECT scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
142
|
-
FROM env_entries
|
|
143
|
-
ORDER BY scope ASC, agent_id ASC, key ASC;
|
|
144
|
-
`,
|
|
145
|
-
).all();
|
|
77
|
+
const rows = context.sqlite.prepare(
|
|
78
|
+
`
|
|
79
|
+
SELECT scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
80
|
+
FROM env_entries
|
|
81
|
+
WHERE scope = 'global'
|
|
82
|
+
ORDER BY key ASC;
|
|
83
|
+
`,
|
|
84
|
+
).all();
|
|
146
85
|
const out: StoredEnvEntry[] = [];
|
|
147
86
|
for (const row of rows as Array<Record<string, unknown>>) {
|
|
148
87
|
const entry = buildEnvEntryFromRowSync(row);
|
|
@@ -156,49 +95,15 @@ export function listEnvEntriesSync(
|
|
|
156
95
|
*/
|
|
157
96
|
export async function listEnvEntries(
|
|
158
97
|
context: PlatformStoreContext,
|
|
159
|
-
scopeInput?: StoredEnvScope,
|
|
160
|
-
agentIdInput?: string,
|
|
161
98
|
): Promise<StoredEnvEntry[]> {
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
`
|
|
171
|
-
SELECT scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
172
|
-
FROM env_entries
|
|
173
|
-
WHERE scope = 'agent' AND agent_id = ?
|
|
174
|
-
ORDER BY key ASC;
|
|
175
|
-
`,
|
|
176
|
-
).all(agentId)
|
|
177
|
-
: scope === "agent"
|
|
178
|
-
? context.sqlite.prepare(
|
|
179
|
-
`
|
|
180
|
-
SELECT scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
181
|
-
FROM env_entries
|
|
182
|
-
WHERE scope = 'agent'
|
|
183
|
-
ORDER BY agent_id ASC, key ASC;
|
|
184
|
-
`,
|
|
185
|
-
).all()
|
|
186
|
-
: scope === "global"
|
|
187
|
-
? context.sqlite.prepare(
|
|
188
|
-
`
|
|
189
|
-
SELECT scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
190
|
-
FROM env_entries
|
|
191
|
-
WHERE scope = 'global'
|
|
192
|
-
ORDER BY key ASC;
|
|
193
|
-
`,
|
|
194
|
-
).all()
|
|
195
|
-
: context.sqlite.prepare(
|
|
196
|
-
`
|
|
197
|
-
SELECT scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
198
|
-
FROM env_entries
|
|
199
|
-
ORDER BY scope ASC, agent_id ASC, key ASC;
|
|
200
|
-
`,
|
|
201
|
-
).all();
|
|
99
|
+
const rows = context.sqlite.prepare(
|
|
100
|
+
`
|
|
101
|
+
SELECT scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
102
|
+
FROM env_entries
|
|
103
|
+
WHERE scope = 'global'
|
|
104
|
+
ORDER BY key ASC;
|
|
105
|
+
`,
|
|
106
|
+
).all();
|
|
202
107
|
const out: StoredEnvEntry[] = [];
|
|
203
108
|
for (const row of rows as Array<Record<string, unknown>>) {
|
|
204
109
|
const entry = await buildEnvEntryFromRow(row);
|
|
@@ -214,9 +119,9 @@ export async function upsertEnvEntry(
|
|
|
214
119
|
context: PlatformStoreContext,
|
|
215
120
|
input: UpsertEnvEntryInput,
|
|
216
121
|
): Promise<void> {
|
|
217
|
-
const scope =
|
|
218
|
-
const agentId =
|
|
219
|
-
const key = normalizeNonEmptyText(input.key,
|
|
122
|
+
const scope = "global";
|
|
123
|
+
const agentId = "";
|
|
124
|
+
const key = normalizeNonEmptyText(input.key, "global env key");
|
|
220
125
|
const description = String(input.description || "").trim();
|
|
221
126
|
const value = String(input.value ?? "");
|
|
222
127
|
const existing = context.sqlite
|
|
@@ -259,14 +164,12 @@ export async function upsertEnvEntry(
|
|
|
259
164
|
*/
|
|
260
165
|
export function removeEnvEntry(
|
|
261
166
|
context: PlatformStoreContext,
|
|
262
|
-
|
|
167
|
+
keyInput: string,
|
|
263
168
|
): void {
|
|
264
|
-
const
|
|
265
|
-
const agentId = normalizeEnvAgentTarget(scope, input.agentId);
|
|
266
|
-
const key = normalizeNonEmptyText(input.key, `${scope} env key`);
|
|
169
|
+
const key = normalizeNonEmptyText(keyInput, "global env key");
|
|
267
170
|
context.sqlite
|
|
268
171
|
.prepare("DELETE FROM env_entries WHERE scope = ? AND agent_id = ? AND key = ?;")
|
|
269
|
-
.run(
|
|
172
|
+
.run("global", "", key);
|
|
270
173
|
}
|
|
271
174
|
|
|
272
175
|
/**
|
|
@@ -275,7 +178,7 @@ export function removeEnvEntry(
|
|
|
275
178
|
export function listGlobalEnvEntriesSync(
|
|
276
179
|
context: PlatformStoreContext,
|
|
277
180
|
): StoredGlobalEnvEntry[] {
|
|
278
|
-
return listEnvEntriesSync(context
|
|
181
|
+
return listEnvEntriesSync(context);
|
|
279
182
|
}
|
|
280
183
|
|
|
281
184
|
/**
|
|
@@ -298,7 +201,7 @@ export function getGlobalEnvMapSync(
|
|
|
298
201
|
export async function listGlobalEnvEntries(
|
|
299
202
|
context: PlatformStoreContext,
|
|
300
203
|
): Promise<StoredGlobalEnvEntry[]> {
|
|
301
|
-
return listEnvEntries(context
|
|
204
|
+
return listEnvEntries(context);
|
|
302
205
|
}
|
|
303
206
|
|
|
304
207
|
/**
|
|
@@ -324,8 +227,7 @@ export async function upsertGlobalEnvEntry(
|
|
|
324
227
|
): Promise<void> {
|
|
325
228
|
await upsertEnvEntry(context, {
|
|
326
229
|
scope: "global",
|
|
327
|
-
|
|
328
|
-
value: input.value,
|
|
230
|
+
...input,
|
|
329
231
|
});
|
|
330
232
|
}
|
|
331
233
|
|
|
@@ -336,10 +238,7 @@ export function removeGlobalEnvEntry(
|
|
|
336
238
|
context: PlatformStoreContext,
|
|
337
239
|
keyInput: string,
|
|
338
240
|
): void {
|
|
339
|
-
removeEnvEntry(context,
|
|
340
|
-
scope: "global",
|
|
341
|
-
key: keyInput,
|
|
342
|
-
});
|
|
241
|
+
removeEnvEntry(context, keyInput);
|
|
343
242
|
}
|
|
344
243
|
|
|
345
244
|
/**
|
|
@@ -348,105 +247,3 @@ export function removeGlobalEnvEntry(
|
|
|
348
247
|
export function clearGlobalEnvEntries(context: PlatformStoreContext): void {
|
|
349
248
|
context.sqlite.prepare("DELETE FROM env_entries WHERE scope = 'global';").run();
|
|
350
249
|
}
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* 同步列出指定 agent 的私有环境变量。
|
|
354
|
-
*/
|
|
355
|
-
export function listAgentEnvEntriesSync(
|
|
356
|
-
context: PlatformStoreContext,
|
|
357
|
-
agentIdInput: string,
|
|
358
|
-
): StoredAgentEnvEntry[] {
|
|
359
|
-
return listEnvEntriesSync(context, "agent", agentIdInput);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* 同步读取 agent 环境变量映射。
|
|
364
|
-
*/
|
|
365
|
-
export function getAgentEnvMapSync(
|
|
366
|
-
context: PlatformStoreContext,
|
|
367
|
-
agentIdInput: string,
|
|
368
|
-
): Record<string, string> {
|
|
369
|
-
const entries = listAgentEnvEntriesSync(context, agentIdInput);
|
|
370
|
-
const map: Record<string, string> = {};
|
|
371
|
-
for (const item of entries) {
|
|
372
|
-
map[item.key] = item.value;
|
|
373
|
-
}
|
|
374
|
-
return map;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* 异步列出指定 agent 的私有环境变量。
|
|
379
|
-
*/
|
|
380
|
-
export async function listAgentEnvEntries(
|
|
381
|
-
context: PlatformStoreContext,
|
|
382
|
-
agentIdInput: string,
|
|
383
|
-
): Promise<StoredAgentEnvEntry[]> {
|
|
384
|
-
return listEnvEntries(context, "agent", agentIdInput);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* 异步列出全部 agent 私有环境变量。
|
|
389
|
-
*/
|
|
390
|
-
export async function listAllAgentEnvEntries(
|
|
391
|
-
context: PlatformStoreContext,
|
|
392
|
-
): Promise<StoredAgentEnvEntry[]> {
|
|
393
|
-
return listEnvEntries(context, "agent");
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* 异步读取 agent 环境变量映射。
|
|
398
|
-
*/
|
|
399
|
-
export async function getAgentEnvMap(
|
|
400
|
-
context: PlatformStoreContext,
|
|
401
|
-
agentIdInput: string,
|
|
402
|
-
): Promise<Record<string, string>> {
|
|
403
|
-
const entries = await listAgentEnvEntries(context, agentIdInput);
|
|
404
|
-
const map: Record<string, string> = {};
|
|
405
|
-
for (const item of entries) {
|
|
406
|
-
map[item.key] = item.value;
|
|
407
|
-
}
|
|
408
|
-
return map;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* 新增或更新 agent 私有环境变量。
|
|
413
|
-
*/
|
|
414
|
-
export async function upsertAgentEnvEntry(
|
|
415
|
-
context: PlatformStoreContext,
|
|
416
|
-
input: UpsertAgentEnvEntryInput,
|
|
417
|
-
): Promise<void> {
|
|
418
|
-
await upsertEnvEntry(context, {
|
|
419
|
-
scope: "agent",
|
|
420
|
-
agentId: input.agentId,
|
|
421
|
-
key: input.key,
|
|
422
|
-
value: input.value,
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* 删除指定 agent 的单个环境变量。
|
|
428
|
-
*/
|
|
429
|
-
export function removeAgentEnvEntry(
|
|
430
|
-
context: PlatformStoreContext,
|
|
431
|
-
agentIdInput: string,
|
|
432
|
-
keyInput: string,
|
|
433
|
-
): void {
|
|
434
|
-
removeEnvEntry(context, {
|
|
435
|
-
scope: "agent",
|
|
436
|
-
agentId: agentIdInput,
|
|
437
|
-
key: keyInput,
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* 清空指定 agent 的私有环境变量。
|
|
443
|
-
*/
|
|
444
|
-
export function clearAgentEnvEntries(
|
|
445
|
-
context: PlatformStoreContext,
|
|
446
|
-
agentIdInput: string,
|
|
447
|
-
): void {
|
|
448
|
-
const agentId = normalizeNonEmptyText(agentIdInput, "agentId");
|
|
449
|
-
context.sqlite
|
|
450
|
-
.prepare("DELETE FROM env_entries WHERE scope = 'agent' AND agent_id = ?;")
|
|
451
|
-
.run(agentId);
|
|
452
|
-
}
|
|
@@ -71,7 +71,7 @@ export function ensurePlatformStoreSchema(context: PlatformStoreContext): void {
|
|
|
71
71
|
CREATE INDEX IF NOT EXISTS env_entries_agent_id_idx
|
|
72
72
|
ON env_entries(agent_id);
|
|
73
73
|
`);
|
|
74
|
-
|
|
74
|
+
ensureEnvEntriesColumns(context);
|
|
75
75
|
context.sqlite.exec(`
|
|
76
76
|
CREATE TABLE IF NOT EXISTS channel_accounts (
|
|
77
77
|
id TEXT PRIMARY KEY NOT NULL,
|
|
@@ -283,9 +283,9 @@ function ensureChannelAccountsTableColumns(context: PlatformStoreContext): void
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
/**
|
|
286
|
-
*
|
|
286
|
+
* 补齐 env_entries 表的增量列。
|
|
287
287
|
*/
|
|
288
|
-
function
|
|
288
|
+
function ensureEnvEntriesColumns(context: PlatformStoreContext): void {
|
|
289
289
|
const envEntryColumns = context.sqlite
|
|
290
290
|
.prepare("PRAGMA table_info(env_entries)")
|
|
291
291
|
.all() as Array<{ name?: unknown }>;
|
|
@@ -295,50 +295,4 @@ function ensureEnvEntriesMigration(context: PlatformStoreContext): void {
|
|
|
295
295
|
if (!envEntryColumnNames.has("description")) {
|
|
296
296
|
context.sqlite.exec("ALTER TABLE env_entries ADD COLUMN description TEXT;");
|
|
297
297
|
}
|
|
298
|
-
|
|
299
|
-
const tableRows = context.sqlite
|
|
300
|
-
.prepare(
|
|
301
|
-
"SELECT name FROM sqlite_master WHERE type = 'table' AND name IN ('global_env', 'agent_env');",
|
|
302
|
-
)
|
|
303
|
-
.all() as Array<{ name?: unknown }>;
|
|
304
|
-
const tableNames = new Set(
|
|
305
|
-
tableRows.map((row) => String(row.name || "").trim()).filter(Boolean),
|
|
306
|
-
);
|
|
307
|
-
if (tableNames.has("global_env")) {
|
|
308
|
-
context.sqlite.exec(`
|
|
309
|
-
INSERT OR IGNORE INTO env_entries (
|
|
310
|
-
scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
311
|
-
)
|
|
312
|
-
SELECT
|
|
313
|
-
'global',
|
|
314
|
-
'',
|
|
315
|
-
key,
|
|
316
|
-
NULL,
|
|
317
|
-
value_encrypted,
|
|
318
|
-
created_at,
|
|
319
|
-
updated_at
|
|
320
|
-
FROM global_env;
|
|
321
|
-
`);
|
|
322
|
-
}
|
|
323
|
-
if (tableNames.has("agent_env")) {
|
|
324
|
-
context.sqlite.exec(`
|
|
325
|
-
INSERT OR IGNORE INTO env_entries (
|
|
326
|
-
scope, agent_id, key, description, value_encrypted, created_at, updated_at
|
|
327
|
-
)
|
|
328
|
-
SELECT
|
|
329
|
-
'agent',
|
|
330
|
-
agent_id,
|
|
331
|
-
key,
|
|
332
|
-
NULL,
|
|
333
|
-
value_encrypted,
|
|
334
|
-
created_at,
|
|
335
|
-
updated_at
|
|
336
|
-
FROM agent_env;
|
|
337
|
-
`);
|
|
338
|
-
context.sqlite.exec(`
|
|
339
|
-
UPDATE env_entries
|
|
340
|
-
SET agent_id = ''
|
|
341
|
-
WHERE scope = 'global' AND agent_id IS NULL;
|
|
342
|
-
`);
|
|
343
|
-
}
|
|
344
298
|
}
|