@downcity/city 1.1.7 → 1.1.9

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.
Files changed (153) hide show
  1. package/bin/cli/agent/AgentManager.js +1 -1
  2. package/bin/cli/agent/AgentManager.js.map +1 -1
  3. package/bin/cli/agent/AgentReset.js +1 -1
  4. package/bin/cli/agent/AgentReset.js.map +1 -1
  5. package/bin/cli/agent/Init.d.ts.map +1 -1
  6. package/bin/cli/agent/Init.js +4 -2
  7. package/bin/cli/agent/Init.js.map +1 -1
  8. package/bin/cli/agent/Run.d.ts.map +1 -1
  9. package/bin/cli/agent/Run.js +4 -1
  10. package/bin/cli/agent/Run.js.map +1 -1
  11. package/bin/cli/control-plane/ControlPlaneInit.js +1 -1
  12. package/bin/cli/control-plane/ControlPlaneInit.js.map +1 -1
  13. package/bin/cli/control-plane/ControlPlaneProcess.d.ts.map +1 -1
  14. package/bin/cli/control-plane/ControlPlaneProcess.js +2 -1
  15. package/bin/cli/control-plane/ControlPlaneProcess.js.map +1 -1
  16. package/bin/cli/model/ModelCommandShared.d.ts +1 -1
  17. package/bin/cli/model/ModelCommandShared.d.ts.map +1 -1
  18. package/bin/cli/model/ModelCommandShared.js +1 -1
  19. package/bin/cli/model/ModelCommandShared.js.map +1 -1
  20. package/bin/cli/model/ModelCreateCommand.js +1 -1
  21. package/bin/cli/model/ModelCreateCommand.js.map +1 -1
  22. package/bin/cli/model/ModelManager.js +1 -1
  23. package/bin/cli/model/ModelManager.js.map +1 -1
  24. package/bin/cli/model/ModelReadCommand.js +1 -1
  25. package/bin/cli/model/ModelReadCommand.js.map +1 -1
  26. package/bin/cli/service/ServiceCommandSupport.d.ts.map +1 -1
  27. package/bin/cli/service/ServiceCommandSupport.js +2 -1
  28. package/bin/cli/service/ServiceCommandSupport.js.map +1 -1
  29. package/bin/cli/shared/ChatAuth.d.ts.map +1 -1
  30. package/bin/cli/shared/ChatAuth.js +6 -5
  31. package/bin/cli/shared/ChatAuth.js.map +1 -1
  32. package/bin/cli/shared/ChatManager.d.ts.map +1 -1
  33. package/bin/cli/shared/ChatManager.js +11 -7
  34. package/bin/cli/shared/ChatManager.js.map +1 -1
  35. package/bin/cli/shared/Env.js +1 -1
  36. package/bin/cli/shared/Env.js.map +1 -1
  37. package/bin/cli/shared/Plugins.js +2 -1
  38. package/bin/cli/shared/Plugins.js.map +1 -1
  39. package/bin/cli/shared/PublicHostEnv.js +1 -1
  40. package/bin/cli/shared/PublicHostEnv.js.map +1 -1
  41. package/bin/config/Paths.d.ts +1 -5
  42. package/bin/config/Paths.d.ts.map +1 -1
  43. package/bin/config/Paths.js +2 -8
  44. package/bin/config/Paths.js.map +1 -1
  45. package/bin/control/ChannelAccountApiRoutes.d.ts.map +1 -1
  46. package/bin/control/ChannelAccountApiRoutes.js +2 -1
  47. package/bin/control/ChannelAccountApiRoutes.js.map +1 -1
  48. package/bin/control/EnvApiRoutes.js +1 -1
  49. package/bin/control/EnvApiRoutes.js.map +1 -1
  50. package/bin/control/ModelApiRoutes.js +1 -1
  51. package/bin/control/ModelApiRoutes.js.map +1 -1
  52. package/bin/control/ModelPoolService.js +1 -1
  53. package/bin/control/ModelPoolService.js.map +1 -1
  54. package/bin/control/PluginApiRoutes.d.ts.map +1 -1
  55. package/bin/control/PluginApiRoutes.js +2 -1
  56. package/bin/control/PluginApiRoutes.js.map +1 -1
  57. package/bin/control/gateway/AgentActions.d.ts.map +1 -1
  58. package/bin/control/gateway/AgentActions.js +4 -3
  59. package/bin/control/gateway/AgentActions.js.map +1 -1
  60. package/bin/control/gateway/AgentCatalog.js +4 -4
  61. package/bin/control/gateway/AgentCatalog.js.map +1 -1
  62. package/bin/http/auth/AuthService.d.ts.map +1 -1
  63. package/bin/http/auth/AuthService.js +1 -1
  64. package/bin/http/auth/AuthService.js.map +1 -1
  65. package/bin/http/auth/AuthStore.js +2 -2
  66. package/bin/http/auth/AuthStore.js.map +1 -1
  67. package/bin/platform/PluginLifecycle.d.ts +51 -0
  68. package/bin/platform/PluginLifecycle.d.ts.map +1 -0
  69. package/bin/platform/PluginLifecycle.js +98 -0
  70. package/bin/platform/PluginLifecycle.js.map +1 -0
  71. package/bin/platform/chatAuthorization/Store.d.ts +31 -0
  72. package/bin/platform/chatAuthorization/Store.d.ts.map +1 -0
  73. package/bin/platform/chatAuthorization/Store.js +145 -0
  74. package/bin/platform/chatAuthorization/Store.js.map +1 -0
  75. package/bin/platform/store/StoreChannelAccountRepository.d.ts +34 -0
  76. package/bin/platform/store/StoreChannelAccountRepository.d.ts.map +1 -0
  77. package/bin/platform/store/StoreChannelAccountRepository.js +198 -0
  78. package/bin/platform/store/StoreChannelAccountRepository.js.map +1 -0
  79. package/bin/platform/store/StoreEnvRepository.d.ts +98 -0
  80. package/bin/platform/store/StoreEnvRepository.d.ts.map +1 -0
  81. package/bin/platform/store/StoreEnvRepository.js +334 -0
  82. package/bin/platform/store/StoreEnvRepository.js.map +1 -0
  83. package/bin/platform/store/StoreModelRepository.d.ts +61 -0
  84. package/bin/platform/store/StoreModelRepository.d.ts.map +1 -0
  85. package/bin/platform/store/StoreModelRepository.js +278 -0
  86. package/bin/platform/store/StoreModelRepository.js.map +1 -0
  87. package/bin/platform/store/StoreSchema.d.ts +13 -0
  88. package/bin/platform/store/StoreSchema.d.ts.map +1 -0
  89. package/bin/platform/store/StoreSchema.js +319 -0
  90. package/bin/platform/store/StoreSchema.js.map +1 -0
  91. package/bin/platform/store/StoreSecureSettings.d.ts +33 -0
  92. package/bin/platform/store/StoreSecureSettings.d.ts.map +1 -0
  93. package/bin/platform/store/StoreSecureSettings.js +91 -0
  94. package/bin/platform/store/StoreSecureSettings.js.map +1 -0
  95. package/bin/platform/store/StoreShared.d.ts +44 -0
  96. package/bin/platform/store/StoreShared.d.ts.map +1 -0
  97. package/bin/platform/store/StoreShared.js +40 -0
  98. package/bin/platform/store/StoreShared.js.map +1 -0
  99. package/bin/platform/store/crypto.d.ts +24 -0
  100. package/bin/platform/store/crypto.d.ts.map +1 -0
  101. package/bin/platform/store/crypto.js +101 -0
  102. package/bin/platform/store/crypto.js.map +1 -0
  103. package/bin/platform/store/index.d.ts +230 -0
  104. package/bin/platform/store/index.d.ts.map +1 -0
  105. package/bin/platform/store/index.js +360 -0
  106. package/bin/platform/store/index.js.map +1 -0
  107. package/bin/platform/store/schema.d.ts +690 -0
  108. package/bin/platform/store/schema.d.ts.map +1 -0
  109. package/bin/platform/store/schema.js +81 -0
  110. package/bin/platform/store/schema.js.map +1 -0
  111. package/bin/process/registry/AgentHostRuntime.d.ts +9 -1
  112. package/bin/process/registry/AgentHostRuntime.d.ts.map +1 -1
  113. package/bin/process/registry/AgentHostRuntime.js +77 -3
  114. package/bin/process/registry/AgentHostRuntime.js.map +1 -1
  115. package/package.json +2 -2
  116. package/src/cli/agent/AgentManager.ts +1 -1
  117. package/src/cli/agent/AgentReset.ts +1 -1
  118. package/src/cli/agent/Init.ts +13 -8
  119. package/src/cli/agent/Run.ts +4 -1
  120. package/src/cli/control-plane/ControlPlaneInit.ts +1 -1
  121. package/src/cli/control-plane/ControlPlaneProcess.ts +2 -1
  122. package/src/cli/model/ModelCommandShared.ts +1 -1
  123. package/src/cli/model/ModelCreateCommand.ts +1 -1
  124. package/src/cli/model/ModelManager.ts +1 -1
  125. package/src/cli/model/ModelReadCommand.ts +1 -1
  126. package/src/cli/service/ServiceCommandSupport.ts +2 -1
  127. package/src/cli/shared/ChatAuth.ts +5 -6
  128. package/src/cli/shared/ChatManager.ts +12 -7
  129. package/src/cli/shared/Env.ts +1 -1
  130. package/src/cli/shared/Plugins.ts +1 -1
  131. package/src/cli/shared/PublicHostEnv.ts +1 -1
  132. package/src/config/Paths.ts +2 -9
  133. package/src/control/ChannelAccountApiRoutes.ts +2 -1
  134. package/src/control/EnvApiRoutes.ts +1 -1
  135. package/src/control/ModelApiRoutes.ts +1 -1
  136. package/src/control/ModelPoolService.ts +1 -1
  137. package/src/control/PluginApiRoutes.ts +4 -2
  138. package/src/control/gateway/AgentActions.ts +24 -17
  139. package/src/control/gateway/AgentCatalog.ts +4 -4
  140. package/src/http/auth/AuthService.ts +1 -1
  141. package/src/http/auth/AuthStore.ts +2 -2
  142. package/src/platform/PluginLifecycle.ts +132 -0
  143. package/src/platform/chatAuthorization/Store.ts +181 -0
  144. package/src/platform/store/StoreChannelAccountRepository.ts +269 -0
  145. package/src/platform/store/StoreEnvRepository.ts +452 -0
  146. package/src/platform/store/StoreModelRepository.ts +324 -0
  147. package/src/platform/store/StoreSchema.ts +344 -0
  148. package/src/platform/store/StoreSecureSettings.ts +126 -0
  149. package/src/platform/store/StoreShared.ts +67 -0
  150. package/src/platform/store/crypto.ts +112 -0
  151. package/src/platform/store/index.ts +497 -0
  152. package/src/platform/store/schema.ts +103 -0
  153. package/src/process/registry/AgentHostRuntime.ts +79 -3
@@ -0,0 +1,101 @@
1
+ /**
2
+ * 模型存储加密工具。
3
+ *
4
+ * 关键点(中文)
5
+ * - 使用 AES-256-GCM 对敏感字段(apiKey)做加密落盘。
6
+ * - 默认从 `~/.downcity/main/model-db.key` 加载或自动生成密钥。
7
+ */
8
+ import crypto from "node:crypto";
9
+ import fs from "fs-extra";
10
+ import path from "node:path";
11
+ import { getPlatformStoreKeyPath } from "../../process/registry/CityPaths.js";
12
+ const MODEL_DB_KEY_PATH = "model-db.key";
13
+ const ENCRYPTION_ALGO = "aes-256-gcm";
14
+ let cachedKey = null;
15
+ /**
16
+ * 重置缓存密钥。
17
+ *
18
+ * 关键点(中文)
19
+ * - 仅在迁移阶段替换 key 文件后调用,确保后续解密重新从磁盘加载最新 key。
20
+ */
21
+ export function resetModelDbKeyCache() {
22
+ cachedKey = null;
23
+ }
24
+ function resolveKeyFilePathSync() {
25
+ const keyPath = getPlatformStoreKeyPath();
26
+ fs.ensureDirSync(path.dirname(keyPath));
27
+ return keyPath;
28
+ }
29
+ async function resolveKeyFilePath() {
30
+ return resolveKeyFilePathSync();
31
+ }
32
+ function loadOrCreateKeySync() {
33
+ if (cachedKey)
34
+ return cachedKey;
35
+ const envKey = String(process.env.DC_MODEL_DB_KEY || "").trim();
36
+ if (envKey) {
37
+ cachedKey = crypto.createHash("sha256").update(envKey, "utf8").digest();
38
+ return cachedKey;
39
+ }
40
+ const keyPath = resolveKeyFilePathSync();
41
+ if (fs.existsSync(keyPath)) {
42
+ const raw = String(fs.readFileSync(keyPath, "utf8")).trim();
43
+ if (raw) {
44
+ const parsed = Buffer.from(raw, "base64");
45
+ if (parsed.length === 32) {
46
+ cachedKey = parsed;
47
+ return cachedKey;
48
+ }
49
+ }
50
+ }
51
+ const next = crypto.randomBytes(32);
52
+ fs.writeFileSync(keyPath, next.toString("base64"), { mode: 0o600 });
53
+ cachedKey = next;
54
+ return cachedKey;
55
+ }
56
+ async function loadOrCreateKey() {
57
+ return loadOrCreateKeySync();
58
+ }
59
+ /**
60
+ * 同步加密字符串(用于同步配置读取链路)。
61
+ */
62
+ export function encryptTextSync(plainText) {
63
+ const key = loadOrCreateKeySync();
64
+ const iv = crypto.randomBytes(12);
65
+ const cipher = crypto.createCipheriv(ENCRYPTION_ALGO, key, iv);
66
+ const encrypted = Buffer.concat([cipher.update(plainText, "utf8"), cipher.final()]);
67
+ const tag = cipher.getAuthTag();
68
+ return Buffer.concat([iv, tag, encrypted]).toString("base64");
69
+ }
70
+ /**
71
+ * 同步解密字符串(用于同步配置读取链路)。
72
+ */
73
+ export function decryptTextSync(cipherText) {
74
+ const key = loadOrCreateKeySync();
75
+ const packed = Buffer.from(cipherText, "base64");
76
+ if (packed.length < 28) {
77
+ throw new Error("Invalid encrypted payload");
78
+ }
79
+ const iv = packed.subarray(0, 12);
80
+ const tag = packed.subarray(12, 28);
81
+ const body = packed.subarray(28);
82
+ const decipher = crypto.createDecipheriv(ENCRYPTION_ALGO, key, iv);
83
+ decipher.setAuthTag(tag);
84
+ const plain = Buffer.concat([decipher.update(body), decipher.final()]);
85
+ return plain.toString("utf8");
86
+ }
87
+ /**
88
+ * 加密字符串。
89
+ */
90
+ export async function encryptText(plainText) {
91
+ await loadOrCreateKey();
92
+ return encryptTextSync(plainText);
93
+ }
94
+ /**
95
+ * 解密字符串。
96
+ */
97
+ export async function decryptText(cipherText) {
98
+ await loadOrCreateKey();
99
+ return decryptTextSync(cipherText);
100
+ }
101
+ //# sourceMappingURL=crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/platform/store/crypto.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,MAAM,iBAAiB,GAAG,cAAc,CAAC;AACzC,MAAM,eAAe,GAAG,aAAa,CAAC;AAEtC,IAAI,SAAS,GAAkB,IAAI,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAClC,SAAS,GAAG,IAAI,CAAC;AACnB,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,OAAO,GAAG,uBAAuB,EAAE,CAAC;IAC1C,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACxC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,KAAK,UAAU,kBAAkB;IAC/B,OAAO,sBAAsB,EAAE,CAAC;AAClC,CAAC;AAED,SAAS,mBAAmB;IAC1B,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC;IAChC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAChE,IAAI,MAAM,EAAE,CAAC;QACX,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,EA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ACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,UAAkB;IAClD,MAAM,eAAe,EAAE,CAAC;IACxB,OAAO,eAAe,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,230 @@
1
+ /**
2
+ * PlatformStore 门面。
3
+ *
4
+ * 关键点(中文)
5
+ * - 对外仍然只暴露一个 `PlatformStore` 类,保持调用入口稳定。
6
+ * - 内部已经按职责拆成 schema、model/provider、secure settings、env、channel accounts 多个模块。
7
+ * - 这样既能保持外部 API 简洁,也能把通用存储层控制在可维护的模块粒度内。
8
+ */
9
+ import type { PlatformStoreContext } from "./StoreShared.js";
10
+ import type { StoredAgentEnvEntry, StoredChannelAccount, StoredEnvEntry, StoredEnvScope, StoredGlobalEnvEntry, StoredModel, StoredModelProvider, StoredProviderMeta, UpsertAgentEnvEntryInput, UpsertChannelAccountInput, UpsertEnvEntryInput, UpsertGlobalEnvEntryInput, UpsertModelInput, UpsertModelProviderInput } from "@downcity/agent";
11
+ /**
12
+ * 平台控制面全局存储门面。
13
+ */
14
+ export declare class PlatformStore {
15
+ private readonly sqlite;
16
+ private readonly db;
17
+ constructor(dbPath?: string);
18
+ /**
19
+ * 暴露给内部 helper 的只读上下文视图。
20
+ */
21
+ private get context();
22
+ /**
23
+ * 关闭连接。
24
+ */
25
+ close(): void;
26
+ /**
27
+ * 列出 providers。
28
+ */
29
+ listProviders(): Promise<StoredModelProvider[]>;
30
+ /**
31
+ * 获取单个 provider。
32
+ */
33
+ getProvider(providerId: string): Promise<StoredModelProvider | null>;
34
+ /**
35
+ * 新增或更新 provider。
36
+ */
37
+ upsertProvider(input: UpsertModelProviderInput): Promise<void>;
38
+ /**
39
+ * 删除 provider。
40
+ */
41
+ removeProvider(providerId: string): void;
42
+ /**
43
+ * 列出 models。
44
+ */
45
+ listModels(): StoredModel[];
46
+ /**
47
+ * 同步列出 provider 元信息(不含 API Key)。
48
+ */
49
+ listProvidersSync(): StoredProviderMeta[];
50
+ /**
51
+ * 获取单个 model。
52
+ */
53
+ getModel(modelId: string): StoredModel | null;
54
+ /**
55
+ * 新增或更新 model。
56
+ */
57
+ upsertModel(input: UpsertModelInput): void;
58
+ /**
59
+ * 切换模型暂停状态。
60
+ */
61
+ setModelPaused(modelId: string, paused: boolean): void;
62
+ /**
63
+ * 删除 model。
64
+ */
65
+ removeModel(modelId: string): void;
66
+ /**
67
+ * 获取 model + provider 聚合信息。
68
+ */
69
+ getResolvedModel(modelId: string): Promise<{
70
+ model: StoredModel;
71
+ provider: StoredModelProvider;
72
+ } | null>;
73
+ /**
74
+ * 清空所有存储数据。
75
+ */
76
+ clearAll(): void;
77
+ /**
78
+ * 同步读取 console 加密配置项(JSON)。
79
+ */
80
+ getSecureSettingJsonSync<T>(key: string): T | null;
81
+ /**
82
+ * 同步写入 console 加密配置项(JSON)。
83
+ */
84
+ setSecureSettingJsonSync(key: string, value: unknown): void;
85
+ /**
86
+ * 删除 console 加密配置项。
87
+ */
88
+ removeSecureSetting(key: string): void;
89
+ /**
90
+ * 异步读取 console 加密配置项(JSON)。
91
+ */
92
+ getSecureSettingJson<T>(key: string): Promise<T | null>;
93
+ /**
94
+ * 异步写入 console 加密配置项(JSON)。
95
+ */
96
+ setSecureSettingJson(key: string, value: unknown): Promise<void>;
97
+ /**
98
+ * 同步读取 agent 加密配置项(JSON)。
99
+ */
100
+ getAgentSecureSettingJsonSync<T>(agentIdInput: string, keyInput: string): T | null;
101
+ /**
102
+ * 同步写入 agent 加密配置项(JSON)。
103
+ */
104
+ setAgentSecureSettingJsonSync(agentIdInput: string, keyInput: string, value: unknown): void;
105
+ /**
106
+ * 删除 agent 加密配置项。
107
+ */
108
+ removeAgentSecureSetting(agentIdInput: string, keyInput: string): void;
109
+ /**
110
+ * 异步读取 agent 加密配置项(JSON)。
111
+ */
112
+ getAgentSecureSettingJson<T>(agentIdInput: string, keyInput: string): Promise<T | null>;
113
+ /**
114
+ * 异步写入 agent 加密配置项(JSON)。
115
+ */
116
+ setAgentSecureSettingJson(agentIdInput: string, keyInput: string, value: unknown): Promise<void>;
117
+ /**
118
+ * 查询 env 条目(同步)。
119
+ */
120
+ listEnvEntriesSync(scopeInput?: StoredEnvScope, agentIdInput?: string): StoredEnvEntry[];
121
+ /**
122
+ * 查询 env 条目(异步)。
123
+ */
124
+ listEnvEntries(scopeInput?: StoredEnvScope, agentIdInput?: string): Promise<StoredEnvEntry[]>;
125
+ /**
126
+ * 新增或更新 env 条目。
127
+ */
128
+ upsertEnvEntry(input: UpsertEnvEntryInput): Promise<void>;
129
+ /**
130
+ * 删除单个 env 条目。
131
+ */
132
+ removeEnvEntry(input: {
133
+ scope: StoredEnvScope;
134
+ agentId?: string;
135
+ key: string;
136
+ }): void;
137
+ /**
138
+ * 列出全局环境变量(同步解密)。
139
+ */
140
+ listGlobalEnvEntriesSync(): StoredGlobalEnvEntry[];
141
+ /**
142
+ * 读取全局环境变量映射(同步解密)。
143
+ */
144
+ getGlobalEnvMapSync(): Record<string, string>;
145
+ /**
146
+ * 列出全局环境变量(解密后)。
147
+ */
148
+ listGlobalEnvEntries(): Promise<StoredGlobalEnvEntry[]>;
149
+ /**
150
+ * 读取全局环境变量映射(解密后)。
151
+ */
152
+ getGlobalEnvMap(): Promise<Record<string, string>>;
153
+ /**
154
+ * 新增或更新全局环境变量。
155
+ */
156
+ upsertGlobalEnvEntry(input: UpsertGlobalEnvEntryInput): Promise<void>;
157
+ /**
158
+ * 删除单个全局环境变量。
159
+ */
160
+ removeGlobalEnvEntry(keyInput: string): void;
161
+ /**
162
+ * 清空全局环境变量。
163
+ */
164
+ clearGlobalEnvEntries(): void;
165
+ /**
166
+ * 列出指定 agent 的私有环境变量(同步解密)。
167
+ */
168
+ listAgentEnvEntriesSync(agentIdInput: string): StoredAgentEnvEntry[];
169
+ /**
170
+ * 读取指定 agent 的私有环境变量映射(同步解密)。
171
+ */
172
+ getAgentEnvMapSync(agentIdInput: string): Record<string, string>;
173
+ /**
174
+ * 列出指定 agent 的私有环境变量(解密后)。
175
+ */
176
+ listAgentEnvEntries(agentIdInput: string): Promise<StoredAgentEnvEntry[]>;
177
+ /**
178
+ * 列出全部 agent 私有环境变量(解密后)。
179
+ */
180
+ listAllAgentEnvEntries(): Promise<StoredAgentEnvEntry[]>;
181
+ /**
182
+ * 读取指定 agent 的私有环境变量映射(解密后)。
183
+ */
184
+ getAgentEnvMap(agentIdInput: string): Promise<Record<string, string>>;
185
+ /**
186
+ * 新增或更新 agent 私有环境变量。
187
+ */
188
+ upsertAgentEnvEntry(input: UpsertAgentEnvEntryInput): Promise<void>;
189
+ /**
190
+ * 删除指定 agent 的单个环境变量。
191
+ */
192
+ removeAgentEnvEntry(agentIdInput: string, keyInput: string): void;
193
+ /**
194
+ * 清空指定 agent 的私有环境变量。
195
+ */
196
+ clearAgentEnvEntries(agentIdInput: string): void;
197
+ /**
198
+ * 列出 channel accounts(同步解密)。
199
+ */
200
+ listChannelAccountsSync(channelInput?: string): StoredChannelAccount[];
201
+ /**
202
+ * 按 ID 获取 channel account(同步解密)。
203
+ */
204
+ getChannelAccountSync(accountIdInput: string): StoredChannelAccount | null;
205
+ /**
206
+ * 列出 channel accounts(解密后)。
207
+ */
208
+ listChannelAccounts(channelInput?: string): Promise<StoredChannelAccount[]>;
209
+ /**
210
+ * 按 ID 获取 channel account(解密后)。
211
+ */
212
+ getChannelAccount(accountIdInput: string): Promise<StoredChannelAccount | null>;
213
+ /**
214
+ * 新增或更新 channel account。
215
+ */
216
+ upsertChannelAccount(input: UpsertChannelAccountInput): Promise<void>;
217
+ /**
218
+ * 删除 channel account。
219
+ */
220
+ removeChannelAccount(accountIdInput: string): void;
221
+ }
222
+ /**
223
+ * 在 PlatformStore 上下文中执行操作。
224
+ *
225
+ * 关键点(中文)
226
+ * - 用于一次性数据库操作,无需手动管理 PlatformStore 实例生命周期。
227
+ * - 自动处理数据库连接和关闭。
228
+ */
229
+ export declare function withPlatformStore<T>(callback: (context: PlatformStoreContext) => T): T;
230
+ //# sourceMappingURL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