@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
|
@@ -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
|
}
|
|
@@ -14,15 +14,12 @@ import { getPlatformStoreDbPath } from "@/process/registry/CityPaths.js";
|
|
|
14
14
|
import { ensurePlatformStoreSchema } from "./StoreSchema.js";
|
|
15
15
|
import type { PlatformStoreContext } from "./StoreShared.js";
|
|
16
16
|
import type {
|
|
17
|
-
StoredAgentEnvEntry,
|
|
18
17
|
StoredChannelAccount,
|
|
19
18
|
StoredEnvEntry,
|
|
20
|
-
StoredEnvScope,
|
|
21
19
|
StoredGlobalEnvEntry,
|
|
22
20
|
StoredModel,
|
|
23
21
|
StoredModelProvider,
|
|
24
22
|
StoredProviderMeta,
|
|
25
|
-
UpsertAgentEnvEntryInput,
|
|
26
23
|
UpsertChannelAccountInput,
|
|
27
24
|
UpsertEnvEntryInput,
|
|
28
25
|
UpsertGlobalEnvEntryInput,
|
|
@@ -55,23 +52,15 @@ import {
|
|
|
55
52
|
setSecureSettingJsonSync,
|
|
56
53
|
} from "./StoreSecureSettings.js";
|
|
57
54
|
import {
|
|
58
|
-
clearAgentEnvEntries,
|
|
59
55
|
clearGlobalEnvEntries,
|
|
60
|
-
getAgentEnvMap,
|
|
61
|
-
getAgentEnvMapSync,
|
|
62
56
|
getGlobalEnvMap,
|
|
63
57
|
getGlobalEnvMapSync,
|
|
64
|
-
listAgentEnvEntries,
|
|
65
|
-
listAgentEnvEntriesSync,
|
|
66
|
-
listAllAgentEnvEntries,
|
|
67
58
|
listEnvEntries,
|
|
68
59
|
listEnvEntriesSync,
|
|
69
60
|
listGlobalEnvEntries,
|
|
70
61
|
listGlobalEnvEntriesSync,
|
|
71
|
-
removeAgentEnvEntry,
|
|
72
62
|
removeEnvEntry,
|
|
73
63
|
removeGlobalEnvEntry,
|
|
74
|
-
upsertAgentEnvEntry,
|
|
75
64
|
upsertEnvEntry,
|
|
76
65
|
upsertGlobalEnvEntry,
|
|
77
66
|
} from "./StoreEnvRepository.js";
|
|
@@ -204,8 +193,6 @@ export class PlatformStore {
|
|
|
204
193
|
clearStoredModelsAndProviders(this.context);
|
|
205
194
|
this.sqlite.exec("DELETE FROM platform_secure_settings;");
|
|
206
195
|
this.sqlite.exec("DELETE FROM env_entries;");
|
|
207
|
-
this.sqlite.exec("DELETE FROM global_env;");
|
|
208
|
-
this.sqlite.exec("DELETE FROM agent_env;");
|
|
209
196
|
this.sqlite.exec("DELETE FROM channel_accounts;");
|
|
210
197
|
}
|
|
211
198
|
|
|
@@ -299,15 +286,15 @@ export class PlatformStore {
|
|
|
299
286
|
/**
|
|
300
287
|
* 查询 env 条目(同步)。
|
|
301
288
|
*/
|
|
302
|
-
listEnvEntriesSync(
|
|
303
|
-
return listEnvEntriesSync(this.context
|
|
289
|
+
listEnvEntriesSync(): StoredEnvEntry[] {
|
|
290
|
+
return listEnvEntriesSync(this.context);
|
|
304
291
|
}
|
|
305
292
|
|
|
306
293
|
/**
|
|
307
294
|
* 查询 env 条目(异步)。
|
|
308
295
|
*/
|
|
309
|
-
async listEnvEntries(
|
|
310
|
-
return await listEnvEntries(this.context
|
|
296
|
+
async listEnvEntries(): Promise<StoredEnvEntry[]> {
|
|
297
|
+
return await listEnvEntries(this.context);
|
|
311
298
|
}
|
|
312
299
|
|
|
313
300
|
/**
|
|
@@ -320,8 +307,8 @@ export class PlatformStore {
|
|
|
320
307
|
/**
|
|
321
308
|
* 删除单个 env 条目。
|
|
322
309
|
*/
|
|
323
|
-
removeEnvEntry(
|
|
324
|
-
removeEnvEntry(this.context,
|
|
310
|
+
removeEnvEntry(keyInput: string): void {
|
|
311
|
+
removeEnvEntry(this.context, keyInput);
|
|
325
312
|
}
|
|
326
313
|
|
|
327
314
|
/**
|
|
@@ -332,23 +319,23 @@ export class PlatformStore {
|
|
|
332
319
|
}
|
|
333
320
|
|
|
334
321
|
/**
|
|
335
|
-
*
|
|
322
|
+
* 读取环境变量映射(同步解密)。
|
|
336
323
|
*/
|
|
337
|
-
|
|
324
|
+
getEnvMapSync(): Record<string, string> {
|
|
338
325
|
return getGlobalEnvMapSync(this.context);
|
|
339
326
|
}
|
|
340
327
|
|
|
341
328
|
/**
|
|
342
|
-
*
|
|
329
|
+
* 列出环境变量(解密后)。
|
|
343
330
|
*/
|
|
344
331
|
async listGlobalEnvEntries(): Promise<StoredGlobalEnvEntry[]> {
|
|
345
332
|
return await listGlobalEnvEntries(this.context);
|
|
346
333
|
}
|
|
347
334
|
|
|
348
335
|
/**
|
|
349
|
-
*
|
|
336
|
+
* 读取环境变量映射(解密后)。
|
|
350
337
|
*/
|
|
351
|
-
async
|
|
338
|
+
async getEnvMap(): Promise<Record<string, string>> {
|
|
352
339
|
return await getGlobalEnvMap(this.context);
|
|
353
340
|
}
|
|
354
341
|
|
|
@@ -373,62 +360,6 @@ export class PlatformStore {
|
|
|
373
360
|
clearGlobalEnvEntries(this.context);
|
|
374
361
|
}
|
|
375
362
|
|
|
376
|
-
/**
|
|
377
|
-
* 列出指定 agent 的私有环境变量(同步解密)。
|
|
378
|
-
*/
|
|
379
|
-
listAgentEnvEntriesSync(agentIdInput: string): StoredAgentEnvEntry[] {
|
|
380
|
-
return listAgentEnvEntriesSync(this.context, agentIdInput);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* 读取指定 agent 的私有环境变量映射(同步解密)。
|
|
385
|
-
*/
|
|
386
|
-
getAgentEnvMapSync(agentIdInput: string): Record<string, string> {
|
|
387
|
-
return getAgentEnvMapSync(this.context, agentIdInput);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* 列出指定 agent 的私有环境变量(解密后)。
|
|
392
|
-
*/
|
|
393
|
-
async listAgentEnvEntries(agentIdInput: string): Promise<StoredAgentEnvEntry[]> {
|
|
394
|
-
return await listAgentEnvEntries(this.context, agentIdInput);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* 列出全部 agent 私有环境变量(解密后)。
|
|
399
|
-
*/
|
|
400
|
-
async listAllAgentEnvEntries(): Promise<StoredAgentEnvEntry[]> {
|
|
401
|
-
return await listAllAgentEnvEntries(this.context);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* 读取指定 agent 的私有环境变量映射(解密后)。
|
|
406
|
-
*/
|
|
407
|
-
async getAgentEnvMap(agentIdInput: string): Promise<Record<string, string>> {
|
|
408
|
-
return await getAgentEnvMap(this.context, agentIdInput);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* 新增或更新 agent 私有环境变量。
|
|
413
|
-
*/
|
|
414
|
-
async upsertAgentEnvEntry(input: UpsertAgentEnvEntryInput): Promise<void> {
|
|
415
|
-
await upsertAgentEnvEntry(this.context, input);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* 删除指定 agent 的单个环境变量。
|
|
420
|
-
*/
|
|
421
|
-
removeAgentEnvEntry(agentIdInput: string, keyInput: string): void {
|
|
422
|
-
removeAgentEnvEntry(this.context, agentIdInput, keyInput);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* 清空指定 agent 的私有环境变量。
|
|
427
|
-
*/
|
|
428
|
-
clearAgentEnvEntries(agentIdInput: string): void {
|
|
429
|
-
clearAgentEnvEntries(this.context, agentIdInput);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
363
|
/**
|
|
433
364
|
* 列出 channel accounts(同步解密)。
|
|
434
365
|
*/
|