@downcity/agent 1.1.6 → 1.1.8

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 (284) hide show
  1. package/bin/agent/AgentContext.d.ts.map +1 -1
  2. package/bin/agent/AgentContext.js +1 -0
  3. package/bin/agent/AgentContext.js.map +1 -1
  4. package/bin/agent/AgentContextTypes.d.ts +5 -1
  5. package/bin/agent/AgentContextTypes.d.ts.map +1 -1
  6. package/bin/agent/AgentRuntime.d.ts +6 -1
  7. package/bin/agent/AgentRuntime.d.ts.map +1 -1
  8. package/bin/agent/AgentRuntime.js +22 -3
  9. package/bin/agent/AgentRuntime.js.map +1 -1
  10. package/bin/agent/AgentRuntimeState.d.ts.map +1 -1
  11. package/bin/agent/AgentRuntimeState.js +58 -2
  12. package/bin/agent/AgentRuntimeState.js.map +1 -1
  13. package/bin/agent/AgentRuntimeTypes.d.ts +5 -1
  14. package/bin/agent/AgentRuntimeTypes.d.ts.map +1 -1
  15. package/bin/agent/project/AgentInitializer.d.ts +3 -2
  16. package/bin/agent/project/AgentInitializer.d.ts.map +1 -1
  17. package/bin/agent/project/AgentInitializer.js +34 -44
  18. package/bin/agent/project/AgentInitializer.js.map +1 -1
  19. package/bin/config/Config.d.ts.map +1 -1
  20. package/bin/config/Config.js +2 -21
  21. package/bin/config/Config.js.map +1 -1
  22. package/bin/config/Paths.d.ts +1 -5
  23. package/bin/config/Paths.d.ts.map +1 -1
  24. package/bin/config/Paths.js +2 -8
  25. package/bin/config/Paths.js.map +1 -1
  26. package/bin/host/daemon/ProjectSetup.d.ts +2 -1
  27. package/bin/host/daemon/ProjectSetup.d.ts.map +1 -1
  28. package/bin/host/daemon/ProjectSetup.js +14 -21
  29. package/bin/host/daemon/ProjectSetup.js.map +1 -1
  30. package/bin/host/runtime/AgentHostRuntime.d.ts.map +1 -1
  31. package/bin/host/runtime/AgentHostRuntime.js +1 -2
  32. package/bin/host/runtime/AgentHostRuntime.js.map +1 -1
  33. package/bin/host/runtime/CityPaths.d.ts +0 -3
  34. package/bin/host/runtime/CityPaths.d.ts.map +1 -1
  35. package/bin/host/runtime/CityPaths.js +0 -3
  36. package/bin/host/runtime/CityPaths.js.map +1 -1
  37. package/bin/host/sdk/Agent.d.ts +4 -0
  38. package/bin/host/sdk/Agent.d.ts.map +1 -1
  39. package/bin/host/sdk/Agent.js +71 -2
  40. package/bin/host/sdk/Agent.js.map +1 -1
  41. package/bin/host/sdk/AgentSdkTypes.d.ts +9 -0
  42. package/bin/host/sdk/AgentSdkTypes.d.ts.map +1 -1
  43. package/bin/host/sdk/SdkSessionSystemComposer.d.ts +11 -2
  44. package/bin/host/sdk/SdkSessionSystemComposer.d.ts.map +1 -1
  45. package/bin/host/sdk/SdkSessionSystemComposer.js +19 -2
  46. package/bin/host/sdk/SdkSessionSystemComposer.js.map +1 -1
  47. package/bin/host/sdk/Session.d.ts +10 -0
  48. package/bin/host/sdk/Session.d.ts.map +1 -1
  49. package/bin/host/sdk/Session.js +8 -0
  50. package/bin/host/sdk/Session.js.map +1 -1
  51. package/bin/http/Server.d.ts.map +1 -1
  52. package/bin/http/Server.js +1 -11
  53. package/bin/http/Server.js.map +1 -1
  54. package/bin/http/auth/AuthEnv.d.ts +0 -9
  55. package/bin/http/auth/AuthEnv.d.ts.map +1 -1
  56. package/bin/http/auth/AuthEnv.js +0 -9
  57. package/bin/http/auth/AuthEnv.js.map +1 -1
  58. package/bin/http/auth/CliAuthStateStore.d.ts +0 -4
  59. package/bin/http/auth/CliAuthStateStore.d.ts.map +1 -1
  60. package/bin/http/auth/CliAuthStateStore.js +0 -4
  61. package/bin/http/auth/CliAuthStateStore.js.map +1 -1
  62. package/bin/http/control/ModelRoutes.d.ts.map +1 -1
  63. package/bin/http/control/ModelRoutes.js +3 -8
  64. package/bin/http/control/ModelRoutes.js.map +1 -1
  65. package/bin/index.d.ts +2 -6
  66. package/bin/index.d.ts.map +1 -1
  67. package/bin/index.js +2 -6
  68. package/bin/index.js.map +1 -1
  69. package/bin/model/CreateModel.d.ts +2 -2
  70. package/bin/model/CreateModel.d.ts.map +1 -1
  71. package/bin/model/CreateModel.js +13 -12
  72. package/bin/model/CreateModel.js.map +1 -1
  73. package/bin/plugin/Activation.d.ts +4 -0
  74. package/bin/plugin/Activation.d.ts.map +1 -1
  75. package/bin/plugin/Activation.js +2 -2
  76. package/bin/plugin/Activation.js.map +1 -1
  77. package/bin/plugin/LocalExecution.d.ts.map +1 -1
  78. package/bin/plugin/LocalExecution.js +23 -2
  79. package/bin/plugin/LocalExecution.js.map +1 -1
  80. package/bin/plugin/PluginRegistry.js +2 -2
  81. package/bin/plugin/PluginRegistry.js.map +1 -1
  82. package/bin/plugins/asr/Plugin.d.ts.map +1 -1
  83. package/bin/plugins/asr/Plugin.js +4 -5
  84. package/bin/plugins/asr/Plugin.js.map +1 -1
  85. package/bin/plugins/auth/Plugin.d.ts.map +1 -1
  86. package/bin/plugins/auth/Plugin.js +1 -0
  87. package/bin/plugins/auth/Plugin.js.map +1 -1
  88. package/bin/plugins/auth/runtime/AuthorizationConfig.d.ts +4 -4
  89. package/bin/plugins/auth/runtime/AuthorizationConfig.d.ts.map +1 -1
  90. package/bin/plugins/auth/runtime/AuthorizationConfig.js +28 -26
  91. package/bin/plugins/auth/runtime/AuthorizationConfig.js.map +1 -1
  92. package/bin/plugins/auth/runtime/AuthorizationPolicy.d.ts +2 -0
  93. package/bin/plugins/auth/runtime/AuthorizationPolicy.d.ts.map +1 -1
  94. package/bin/plugins/auth/runtime/AuthorizationPolicy.js +3 -2
  95. package/bin/plugins/auth/runtime/AuthorizationPolicy.js.map +1 -1
  96. package/bin/plugins/auth/runtime/AuthorizationStore.d.ts +1 -1
  97. package/bin/plugins/auth/runtime/AuthorizationStore.d.ts.map +1 -1
  98. package/bin/plugins/auth/runtime/AuthorizationStore.js +3 -4
  99. package/bin/plugins/auth/runtime/AuthorizationStore.js.map +1 -1
  100. package/bin/plugins/skill/Plugin.js +2 -2
  101. package/bin/plugins/skill/Plugin.js.map +1 -1
  102. package/bin/plugins/tts/Plugin.d.ts.map +1 -1
  103. package/bin/plugins/tts/Plugin.js +4 -5
  104. package/bin/plugins/tts/Plugin.js.map +1 -1
  105. package/bin/plugins/web/Plugin.d.ts.map +1 -1
  106. package/bin/plugins/web/Plugin.js +4 -5
  107. package/bin/plugins/web/Plugin.js.map +1 -1
  108. package/bin/plugins/workboard/Plugin.js +2 -2
  109. package/bin/plugins/workboard/Plugin.js.map +1 -1
  110. package/bin/service/builtins/chat/accounts/ChannelAccountService.d.ts +4 -1
  111. package/bin/service/builtins/chat/accounts/ChannelAccountService.d.ts.map +1 -1
  112. package/bin/service/builtins/chat/accounts/ChannelAccountService.js +64 -91
  113. package/bin/service/builtins/chat/accounts/ChannelAccountService.js.map +1 -1
  114. package/bin/service/builtins/chat/runtime/ChatChannelActions.d.ts.map +1 -1
  115. package/bin/service/builtins/chat/runtime/ChatChannelActions.js +11 -18
  116. package/bin/service/builtins/chat/runtime/ChatChannelActions.js.map +1 -1
  117. package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts +1 -1
  118. package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts.map +1 -1
  119. package/bin/service/builtins/chat/runtime/ChatChannelCore.js +9 -17
  120. package/bin/service/builtins/chat/runtime/ChatChannelCore.js.map +1 -1
  121. package/bin/service/builtins/memory/Action.d.ts +1 -5
  122. package/bin/service/builtins/memory/Action.d.ts.map +1 -1
  123. package/bin/service/builtins/memory/Action.js +4 -42
  124. package/bin/service/builtins/memory/Action.js.map +1 -1
  125. package/bin/service/builtins/memory/MemoryService.d.ts.map +1 -1
  126. package/bin/service/builtins/memory/MemoryService.js +2 -32
  127. package/bin/service/builtins/memory/MemoryService.js.map +1 -1
  128. package/bin/service/builtins/memory/runtime/Search.d.ts +7 -3
  129. package/bin/service/builtins/memory/runtime/Search.d.ts.map +1 -1
  130. package/bin/service/builtins/memory/runtime/Search.js +220 -16
  131. package/bin/service/builtins/memory/runtime/Search.js.map +1 -1
  132. package/bin/service/builtins/memory/runtime/Store.d.ts +9 -50
  133. package/bin/service/builtins/memory/runtime/Store.d.ts.map +1 -1
  134. package/bin/service/builtins/memory/runtime/Store.js +10 -130
  135. package/bin/service/builtins/memory/runtime/Store.js.map +1 -1
  136. package/bin/service/builtins/memory/runtime/Writer.d.ts.map +1 -1
  137. package/bin/service/builtins/memory/runtime/Writer.js +1 -2
  138. package/bin/service/builtins/memory/runtime/Writer.js.map +1 -1
  139. package/bin/service/builtins/memory/types/Memory.d.ts +3 -57
  140. package/bin/service/builtins/memory/types/Memory.d.ts.map +1 -1
  141. package/bin/service/schedule/Store.d.ts +22 -25
  142. package/bin/service/schedule/Store.d.ts.map +1 -1
  143. package/bin/service/schedule/Store.js +172 -154
  144. package/bin/service/schedule/Store.js.map +1 -1
  145. package/bin/session/composer/system/default/SystemDomain.d.ts.map +1 -1
  146. package/bin/session/composer/system/default/SystemDomain.js +1 -0
  147. package/bin/session/composer/system/default/SystemDomain.js.map +1 -1
  148. package/bin/shared/types/AgentHost.d.ts +120 -4
  149. package/bin/shared/types/AgentHost.d.ts.map +1 -1
  150. package/bin/shared/types/Plugin.d.ts +5 -1
  151. package/bin/shared/types/Plugin.d.ts.map +1 -1
  152. package/package.json +1 -4
  153. package/src/agent/AgentContext.ts +1 -0
  154. package/src/agent/AgentContextTypes.ts +5 -0
  155. package/src/agent/AgentRuntime.ts +32 -3
  156. package/src/agent/AgentRuntimeState.ts +66 -2
  157. package/src/agent/AgentRuntimeTypes.ts +5 -0
  158. package/src/agent/project/AgentInitializer.ts +40 -42
  159. package/src/config/Config.ts +2 -17
  160. package/src/config/Paths.ts +2 -9
  161. package/src/host/daemon/ProjectSetup.ts +19 -21
  162. package/src/host/runtime/AgentHostRuntime.ts +0 -2
  163. package/src/host/runtime/CityPaths.ts +0 -3
  164. package/src/host/sdk/Agent.ts +67 -2
  165. package/src/host/sdk/AgentSdkTypes.ts +10 -0
  166. package/src/host/sdk/SdkSessionSystemComposer.ts +39 -2
  167. package/src/host/sdk/Session.ts +18 -0
  168. package/src/http/Server.ts +0 -13
  169. package/src/http/auth/AuthEnv.ts +0 -9
  170. package/src/http/auth/CliAuthStateStore.ts +0 -4
  171. package/src/http/control/ModelRoutes.ts +3 -9
  172. package/src/index.ts +2 -12
  173. package/src/model/CreateModel.ts +15 -13
  174. package/src/plugin/Activation.ts +6 -2
  175. package/src/plugin/LocalExecution.ts +24 -2
  176. package/src/plugin/PluginRegistry.ts +2 -2
  177. package/src/plugins/asr/Plugin.ts +4 -5
  178. package/src/plugins/auth/Plugin.ts +1 -0
  179. package/src/plugins/auth/runtime/AuthorizationConfig.ts +47 -37
  180. package/src/plugins/auth/runtime/AuthorizationPolicy.ts +5 -2
  181. package/src/plugins/auth/runtime/AuthorizationStore.ts +6 -5
  182. package/src/plugins/skill/Plugin.ts +2 -2
  183. package/src/plugins/tts/Plugin.ts +4 -5
  184. package/src/plugins/web/Plugin.ts +4 -5
  185. package/src/plugins/workboard/Plugin.ts +2 -2
  186. package/src/service/builtins/chat/accounts/ChannelAccountService.ts +42 -62
  187. package/src/service/builtins/chat/runtime/ChatChannelActions.ts +12 -18
  188. package/src/service/builtins/chat/runtime/ChatChannelCore.ts +9 -14
  189. package/src/service/builtins/memory/Action.ts +6 -47
  190. package/src/service/builtins/memory/MemoryService.ts +1 -33
  191. package/src/service/builtins/memory/runtime/Search.ts +256 -16
  192. package/src/service/builtins/memory/runtime/Store.ts +13 -185
  193. package/src/service/builtins/memory/runtime/Writer.ts +1 -2
  194. package/src/service/builtins/memory/types/Memory.ts +2 -59
  195. package/src/service/schedule/Store.ts +215 -175
  196. package/src/session/composer/system/default/SystemDomain.ts +1 -0
  197. package/src/shared/types/AgentHost.ts +138 -4
  198. package/src/shared/types/Plugin.ts +5 -0
  199. package/tsconfig.tsbuildinfo +1 -1
  200. package/bin/http/auth/AuthMiddleware.d.ts +0 -36
  201. package/bin/http/auth/AuthMiddleware.d.ts.map +0 -1
  202. package/bin/http/auth/AuthMiddleware.js +0 -37
  203. package/bin/http/auth/AuthMiddleware.js.map +0 -1
  204. package/bin/http/auth/AuthRoutes.d.ts +0 -17
  205. package/bin/http/auth/AuthRoutes.d.ts.map +0 -1
  206. package/bin/http/auth/AuthRoutes.js +0 -78
  207. package/bin/http/auth/AuthRoutes.js.map +0 -1
  208. package/bin/http/auth/AuthService.d.ts +0 -119
  209. package/bin/http/auth/AuthService.d.ts.map +0 -1
  210. package/bin/http/auth/AuthService.js +0 -307
  211. package/bin/http/auth/AuthService.js.map +0 -1
  212. package/bin/http/auth/AuthStore.d.ts +0 -165
  213. package/bin/http/auth/AuthStore.d.ts.map +0 -1
  214. package/bin/http/auth/AuthStore.js +0 -442
  215. package/bin/http/auth/AuthStore.js.map +0 -1
  216. package/bin/http/auth/RoutePolicy.d.ts +0 -30
  217. package/bin/http/auth/RoutePolicy.d.ts.map +0 -1
  218. package/bin/http/auth/RoutePolicy.js +0 -229
  219. package/bin/http/auth/RoutePolicy.js.map +0 -1
  220. package/bin/plugin/Lifecycle.d.ts +0 -33
  221. package/bin/plugin/Lifecycle.d.ts.map +0 -1
  222. package/bin/plugin/Lifecycle.js +0 -102
  223. package/bin/plugin/Lifecycle.js.map +0 -1
  224. package/bin/service/builtins/memory/runtime/Indexer.d.ts +0 -71
  225. package/bin/service/builtins/memory/runtime/Indexer.d.ts.map +0 -1
  226. package/bin/service/builtins/memory/runtime/Indexer.js +0 -345
  227. package/bin/service/builtins/memory/runtime/Indexer.js.map +0 -1
  228. package/bin/service/schedule/Schema.d.ts +0 -171
  229. package/bin/service/schedule/Schema.d.ts.map +0 -1
  230. package/bin/service/schedule/Schema.js +0 -26
  231. package/bin/service/schedule/Schema.js.map +0 -1
  232. package/bin/shared/utils/store/StoreChannelAccountRepository.d.ts +0 -34
  233. package/bin/shared/utils/store/StoreChannelAccountRepository.d.ts.map +0 -1
  234. package/bin/shared/utils/store/StoreChannelAccountRepository.js +0 -198
  235. package/bin/shared/utils/store/StoreChannelAccountRepository.js.map +0 -1
  236. package/bin/shared/utils/store/StoreEnvRepository.d.ts +0 -98
  237. package/bin/shared/utils/store/StoreEnvRepository.d.ts.map +0 -1
  238. package/bin/shared/utils/store/StoreEnvRepository.js +0 -334
  239. package/bin/shared/utils/store/StoreEnvRepository.js.map +0 -1
  240. package/bin/shared/utils/store/StoreModelRepository.d.ts +0 -61
  241. package/bin/shared/utils/store/StoreModelRepository.d.ts.map +0 -1
  242. package/bin/shared/utils/store/StoreModelRepository.js +0 -278
  243. package/bin/shared/utils/store/StoreModelRepository.js.map +0 -1
  244. package/bin/shared/utils/store/StoreSchema.d.ts +0 -13
  245. package/bin/shared/utils/store/StoreSchema.d.ts.map +0 -1
  246. package/bin/shared/utils/store/StoreSchema.js +0 -319
  247. package/bin/shared/utils/store/StoreSchema.js.map +0 -1
  248. package/bin/shared/utils/store/StoreSecureSettings.d.ts +0 -33
  249. package/bin/shared/utils/store/StoreSecureSettings.d.ts.map +0 -1
  250. package/bin/shared/utils/store/StoreSecureSettings.js +0 -91
  251. package/bin/shared/utils/store/StoreSecureSettings.js.map +0 -1
  252. package/bin/shared/utils/store/StoreShared.d.ts +0 -44
  253. package/bin/shared/utils/store/StoreShared.d.ts.map +0 -1
  254. package/bin/shared/utils/store/StoreShared.js +0 -40
  255. package/bin/shared/utils/store/StoreShared.js.map +0 -1
  256. package/bin/shared/utils/store/crypto.d.ts +0 -24
  257. package/bin/shared/utils/store/crypto.d.ts.map +0 -1
  258. package/bin/shared/utils/store/crypto.js +0 -101
  259. package/bin/shared/utils/store/crypto.js.map +0 -1
  260. package/bin/shared/utils/store/index.d.ts +0 -230
  261. package/bin/shared/utils/store/index.d.ts.map +0 -1
  262. package/bin/shared/utils/store/index.js +0 -360
  263. package/bin/shared/utils/store/index.js.map +0 -1
  264. package/bin/shared/utils/store/schema.d.ts +0 -690
  265. package/bin/shared/utils/store/schema.d.ts.map +0 -1
  266. package/bin/shared/utils/store/schema.js +0 -81
  267. package/bin/shared/utils/store/schema.js.map +0 -1
  268. package/src/http/auth/AuthMiddleware.ts +0 -61
  269. package/src/http/auth/AuthRoutes.ts +0 -100
  270. package/src/http/auth/AuthService.ts +0 -367
  271. package/src/http/auth/AuthStore.ts +0 -572
  272. package/src/http/auth/RoutePolicy.ts +0 -255
  273. package/src/plugin/Lifecycle.ts +0 -116
  274. package/src/service/builtins/memory/runtime/Indexer.ts +0 -466
  275. package/src/service/schedule/Schema.ts +0 -34
  276. package/src/shared/utils/store/StoreChannelAccountRepository.ts +0 -269
  277. package/src/shared/utils/store/StoreEnvRepository.ts +0 -452
  278. package/src/shared/utils/store/StoreModelRepository.ts +0 -324
  279. package/src/shared/utils/store/StoreSchema.ts +0 -344
  280. package/src/shared/utils/store/StoreSecureSettings.ts +0 -126
  281. package/src/shared/utils/store/StoreShared.ts +0 -67
  282. package/src/shared/utils/store/crypto.ts +0 -112
  283. package/src/shared/utils/store/index.ts +0 -497
  284. package/src/shared/utils/store/schema.ts +0 -103
@@ -2,7 +2,7 @@
2
2
  * Auth 授权配置读写工具。
3
3
  *
4
4
  * 关键点(中文)
5
- * - 静态授权规则统一写入 console `~/.downcity/downcity.db`。
5
+ * - 静态授权规则通过宿主注入的平台能力读写。
6
6
  * - 授权核心模型为 role / permission / binding。
7
7
  */
8
8
 
@@ -19,9 +19,7 @@ import {
19
19
  CHAT_AUTHORIZATION_PERMISSIONS,
20
20
  createDefaultChatAuthorizationRoles,
21
21
  } from "@/shared/types/AuthPlugin.js";
22
- import { PlatformStore } from "@/shared/utils/store/index.js";
23
22
 
24
- const CHAT_AUTHORIZATION_STORE_KEY = "chat_authorization";
25
23
  const CHANNELS: ChatAuthorizationChannel[] = [...CHAT_AUTHORIZATION_CHANNELS];
26
24
 
27
25
  export const DEFAULT_CHAT_AUTHORIZATION_PERMISSIONS: ChatAuthorizationPermission[] = [
@@ -139,40 +137,41 @@ function cloneAuthorizationConfig(
139
137
  return normalizeAuthorizationConfig(input ? JSON.parse(JSON.stringify(input)) : {});
140
138
  }
141
139
 
142
- function readAuthorizationConfigFromStoreSync(projectRoot: string): ChatAuthorizationConfig {
143
- const normalizedProjectRoot = normalizeText(projectRoot);
140
+ function readAuthorizationConfigFromPlatformSync(params: {
141
+ projectRoot: string;
142
+ readConfig: (projectRoot: string) => ChatAuthorizationConfig;
143
+ }): ChatAuthorizationConfig {
144
+ const normalizedProjectRoot = normalizeText(params.projectRoot);
144
145
  if (!normalizedProjectRoot) return normalizeAuthorizationConfig({});
145
- const store = new PlatformStore();
146
146
  try {
147
- return normalizeAuthorizationConfig(
148
- store.getAgentSecureSettingJsonSync<ChatAuthorizationConfig>(
149
- normalizedProjectRoot,
150
- CHAT_AUTHORIZATION_STORE_KEY,
151
- ) || {},
152
- );
147
+ return normalizeAuthorizationConfig(params.readConfig(normalizedProjectRoot) || {});
153
148
  } catch {
154
149
  return normalizeAuthorizationConfig({});
155
- } finally {
156
- store.close();
157
150
  }
158
151
  }
159
152
 
160
- async function writeAuthorizationConfigToStore(params: {
153
+ function readAuthorizationConfigFromProjectRoot(projectRoot: string): ChatAuthorizationConfig {
154
+ const normalizedProjectRoot = normalizeText(projectRoot);
155
+ if (!normalizedProjectRoot) return normalizeAuthorizationConfig({});
156
+ throw new Error(
157
+ `Platform authorization runtime is not available for project: ${normalizedProjectRoot}`,
158
+ );
159
+ }
160
+
161
+ async function writeAuthorizationConfigToPlatform(params: {
161
162
  projectRoot: string;
162
163
  nextConfig: ChatAuthorizationConfig;
164
+ writeConfig: (
165
+ projectRoot: string,
166
+ nextConfig: ChatAuthorizationConfig,
167
+ ) => Promise<ChatAuthorizationConfig>;
163
168
  }): Promise<void> {
164
169
  const normalizedProjectRoot = normalizeText(params.projectRoot);
165
170
  if (!normalizedProjectRoot) throw new Error("projectRoot is required");
166
- const store = new PlatformStore();
167
- try {
168
- await store.setAgentSecureSettingJson(
169
- normalizedProjectRoot,
170
- CHAT_AUTHORIZATION_STORE_KEY,
171
- normalizeAuthorizationConfig(params.nextConfig),
172
- );
173
- } finally {
174
- store.close();
175
- }
171
+ await params.writeConfig(
172
+ normalizedProjectRoot,
173
+ normalizeAuthorizationConfig(params.nextConfig),
174
+ );
176
175
  }
177
176
 
178
177
  function ensureChannelConfig(
@@ -189,32 +188,37 @@ function ensureChannelConfig(
189
188
  * 同步读取当前 agent 的授权配置。
190
189
  */
191
190
  export function readChatAuthorizationConfigSync(projectRoot: string): ChatAuthorizationConfig {
192
- return readAuthorizationConfigFromStoreSync(projectRoot);
191
+ return readAuthorizationConfigFromProjectRoot(projectRoot);
193
192
  }
194
193
 
195
194
  /**
196
195
  * 读取当前 agent 的授权配置。
197
196
  */
198
197
  export function readChatAuthorizationConfig(
199
- contextOrProjectRoot: Pick<AgentContext, "rootPath"> | string,
198
+ contextOrProjectRoot: Pick<AgentContext, "rootPath" | "platform"> | string,
200
199
  ): ChatAuthorizationConfig {
201
- const projectRoot =
202
- typeof contextOrProjectRoot === "string"
203
- ? contextOrProjectRoot
204
- : contextOrProjectRoot.rootPath;
205
- return readAuthorizationConfigFromStoreSync(projectRoot);
200
+ if (typeof contextOrProjectRoot === "string") {
201
+ return readAuthorizationConfigFromProjectRoot(contextOrProjectRoot);
202
+ }
203
+ return readAuthorizationConfigFromPlatformSync({
204
+ projectRoot: contextOrProjectRoot.rootPath,
205
+ readConfig: (projectRoot) =>
206
+ contextOrProjectRoot.platform.readChatAuthorizationConfig(projectRoot),
207
+ });
206
208
  }
207
209
 
208
210
  /**
209
211
  * 覆盖写入整份授权配置。
210
212
  */
211
213
  export async function writeChatAuthorizationConfig(params: {
212
- context: Pick<AgentContext, "rootPath">;
214
+ context: Pick<AgentContext, "rootPath" | "platform">;
213
215
  nextConfig: ChatAuthorizationConfig;
214
216
  }): Promise<void> {
215
- await writeAuthorizationConfigToStore({
217
+ await writeAuthorizationConfigToPlatform({
216
218
  projectRoot: params.context.rootPath,
217
219
  nextConfig: params.nextConfig,
220
+ writeConfig: (projectRoot, nextConfig) =>
221
+ params.context.platform.writeChatAuthorizationConfig(projectRoot, nextConfig),
218
222
  });
219
223
  }
220
224
 
@@ -232,7 +236,7 @@ export function listChatAuthorizationRoles(params: {
232
236
  * 设置用户角色。
233
237
  */
234
238
  export async function setChatAuthorizationUserRole(params: {
235
- context: Pick<AgentContext, "rootPath">;
239
+ context: Pick<AgentContext, "rootPath" | "platform">;
236
240
  channel: ChatAuthorizationChannel;
237
241
  userId: string;
238
242
  roleId: string;
@@ -241,15 +245,21 @@ export async function setChatAuthorizationUserRole(params: {
241
245
  const roleId = normalizeText(params.roleId);
242
246
  if (!userId || !roleId) throw new Error("userId and roleId are required");
243
247
  const authorization = cloneAuthorizationConfig(
244
- readAuthorizationConfigFromStoreSync(params.context.rootPath),
248
+ readAuthorizationConfigFromPlatformSync({
249
+ projectRoot: params.context.rootPath,
250
+ readConfig: (projectRoot) =>
251
+ params.context.platform.readChatAuthorizationConfig(projectRoot),
252
+ }),
245
253
  );
246
254
  authorization.roles = normalizeRoleMap(authorization.roles);
247
255
  const channelConfig = ensureChannelConfig(authorization, params.channel);
248
256
  if (!authorization.roles?.[roleId]) throw new Error(`Unknown roleId: ${roleId}`);
249
257
  channelConfig.userRoles ??= {};
250
258
  channelConfig.userRoles[userId] = roleId;
251
- await writeAuthorizationConfigToStore({
259
+ await writeAuthorizationConfigToPlatform({
252
260
  projectRoot: params.context.rootPath,
253
261
  nextConfig: authorization,
262
+ writeConfig: (projectRoot, nextConfig) =>
263
+ params.context.platform.writeChatAuthorizationConfig(projectRoot, nextConfig),
254
264
  });
255
265
  }
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { DowncityConfig } from "@/shared/types/DowncityConfig.js";
10
+ import type { AgentPlatformRuntime } from "@/shared/types/AgentHost.js";
10
11
  import type {
11
12
  ChatAuthorizationConfig,
12
13
  ChatAuthorizationChannel,
@@ -17,7 +18,6 @@ import type {
17
18
  ChatChannelAuthorizationConfig,
18
19
  } from "@/shared/types/AuthPlugin.js";
19
20
  import { createDefaultChatAuthorizationRoles } from "@/shared/types/AuthPlugin.js";
20
- import { readChatAuthorizationConfigSync } from "@/plugins/auth/runtime/AuthorizationConfig.js";
21
21
 
22
22
  function normalizeText(value: unknown): string | undefined {
23
23
  const text = String(value || "").trim();
@@ -92,12 +92,15 @@ export function resolveAuthorizedUserRole(params: {
92
92
  userId?: string;
93
93
  authorizationConfig?: ChatAuthorizationConfig;
94
94
  rootPath?: string;
95
+ platform?: Pick<AgentPlatformRuntime, "readChatAuthorizationConfig">;
95
96
  }): ChatAuthorizationRole | undefined {
96
97
  const userId = normalizeText(params.userId);
97
98
  if (!userId) return undefined;
98
99
  const authorizationConfig =
99
100
  params.authorizationConfig ||
100
- (params.rootPath ? readChatAuthorizationConfigSync(params.rootPath) : undefined);
101
+ (params.rootPath && params.platform
102
+ ? params.platform.readChatAuthorizationConfig(params.rootPath)
103
+ : undefined);
101
104
  const roles = resolveAuthorizationRoles(authorizationConfig);
102
105
  const channelConfig = resolveChannelAuthorizationConfig(params.channel, authorizationConfig);
103
106
  return resolveUserRole({
@@ -16,7 +16,6 @@ import type {
16
16
  } from "@/shared/types/AuthPlugin.js";
17
17
  import type { AgentContext } from "@/agent/AgentContextTypes.js";
18
18
  import type { ChatDispatchChannel } from "@/service/builtins/chat/types/ChatDispatcher.js";
19
- import { readChatAuthorizationConfigSync } from "@/plugins/auth/runtime/AuthorizationConfig.js";
20
19
 
21
20
  function getAuthorizationStatePath(rootPath: string): string {
22
21
  return path.join(rootPath, ".downcity", "chat", "authorization", "state.json");
@@ -145,8 +144,10 @@ async function writeState(rootPath: string, state: ChatAuthorizationStateFile):
145
144
  await fs.writeJson(file, state, { spaces: 2 });
146
145
  }
147
146
 
148
- function readAuthorizationConfig(projectRoot: string): ChatAuthorizationSnapshot["config"] {
149
- return readChatAuthorizationConfigSync(projectRoot);
147
+ function readAuthorizationConfig(
148
+ context: Pick<AgentContext, "rootPath" | "platform">,
149
+ ): ChatAuthorizationSnapshot["config"] {
150
+ return context.platform.readChatAuthorizationConfig(context.rootPath);
150
151
  }
151
152
 
152
153
  /**
@@ -207,11 +208,11 @@ export async function recordObservedAuthorizationPrincipal(params: {
207
208
  * 读取授权快照(配置 + 动态状态)。
208
209
  */
209
210
  export async function readAuthorizationSnapshot(params: {
210
- context: Pick<AgentContext, "rootPath">;
211
+ context: Pick<AgentContext, "rootPath" | "platform">;
211
212
  }): Promise<ChatAuthorizationSnapshot> {
212
213
  const state = await readState(params.context.rootPath);
213
214
  return {
214
- config: readAuthorizationConfig(params.context.rootPath),
215
+ config: readAuthorizationConfig(params.context),
215
216
  users: Object.values(state.usersByKey).sort((a, b) => b.lastSeenAt - a.lastSeenAt),
216
217
  chats: Object.values(state.chatsByKey).sort((a, b) => b.lastSeenAt - a.lastSeenAt),
217
218
  };
@@ -126,8 +126,8 @@ export const skillPlugin: Plugin = {
126
126
  ...DEFAULT_SKILL_PLUGIN_CONFIG,
127
127
  },
128
128
  },
129
- availability() {
130
- if (!isPluginEnabled({ plugin: skillPlugin })) {
129
+ availability(context) {
130
+ if (!isPluginEnabled({ plugin: skillPlugin, context })) {
131
131
  return {
132
132
  enabled: false,
133
133
  available: false,
@@ -14,7 +14,6 @@ import type {
14
14
  TtsSynthesizeInput,
15
15
  } from "@/shared/types/TtsPlugin.js";
16
16
  import { isPluginEnabled } from "@/plugin/Activation.js";
17
- import { setCityPluginEnabled } from "@/plugin/Lifecycle.js";
18
17
  import {
19
18
  checkTtsSynthesizer,
20
19
  installTtsSynthesizer,
@@ -176,7 +175,7 @@ export const ttsPlugin: Plugin = {
176
175
  statusAction: "status",
177
176
  },
178
177
  async availability(context) {
179
- if (!isPluginEnabled({ plugin: ttsPlugin })) {
178
+ if (!isPluginEnabled({ plugin: ttsPlugin, context })) {
180
179
  return {
181
180
  enabled: false,
182
181
  available: false,
@@ -378,7 +377,7 @@ export const ttsPlugin: Plugin = {
378
377
  },
379
378
  },
380
379
  execute: async ({ context, payload }) => {
381
- setCityPluginEnabled("tts", true);
380
+ context.platform.setPluginEnabled?.("tts", true);
382
381
  if ((payload as { install?: unknown }).install !== false) {
383
382
  const installResult = await installTtsSynthesizer({
384
383
  context,
@@ -411,7 +410,7 @@ export const ttsPlugin: Plugin = {
411
410
  },
412
411
  },
413
412
  execute: async ({ context }) => {
414
- setCityPluginEnabled("tts", false);
413
+ context.platform.setPluginEnabled?.("tts", false);
415
414
  return {
416
415
  success: true,
417
416
  data: {
@@ -535,7 +534,7 @@ export const ttsPlugin: Plugin = {
535
534
  },
536
535
  },
537
536
  system(context) {
538
- if (!isPluginEnabled({ plugin: ttsPlugin })) {
537
+ if (!isPluginEnabled({ plugin: ttsPlugin, context })) {
539
538
  return "";
540
539
  }
541
540
  return [
@@ -12,7 +12,6 @@ import type { JsonObject, JsonValue } from "@/shared/types/Json.js";
12
12
  import type { WebPluginConfig, WebPluginInstallInput } from "@/shared/types/WebPlugin.js";
13
13
  import { WEB_PLUGIN_DEFAULT_REPOSITORY_URL } from "@/shared/types/WebPlugin.js";
14
14
  import { isPluginEnabled } from "@/plugin/Activation.js";
15
- import { setCityPluginEnabled } from "@/plugin/Lifecycle.js";
16
15
  import {
17
16
  doctorWebPluginDependency,
18
17
  inspectWebPluginDependency,
@@ -179,7 +178,7 @@ export const webPlugin: Plugin = {
179
178
  statusAction: "status",
180
179
  },
181
180
  async availability(context) {
182
- if (!isPluginEnabled({ plugin: webPlugin })) {
181
+ if (!isPluginEnabled({ plugin: webPlugin, context })) {
183
182
  return {
184
183
  enabled: false,
185
184
  available: false,
@@ -361,7 +360,7 @@ export const webPlugin: Plugin = {
361
360
  },
362
361
  },
363
362
  execute: async ({ context, payload }) => {
364
- setCityPluginEnabled("web", true);
363
+ context.platform.setPluginEnabled?.("web", true);
365
364
  const providerRaw = String((payload as { provider?: unknown }).provider || "").trim();
366
365
  const provider =
367
366
  providerRaw === "web-access" || providerRaw === "agent-browser"
@@ -403,7 +402,7 @@ export const webPlugin: Plugin = {
403
402
  },
404
403
  },
405
404
  execute: async ({ context }) => {
406
- setCityPluginEnabled("web", false);
405
+ context.platform.setPluginEnabled?.("web", false);
407
406
  return {
408
407
  success: true,
409
408
  data: {
@@ -497,7 +496,7 @@ export const webPlugin: Plugin = {
497
496
  },
498
497
  system(context) {
499
498
  const config = readWebPluginConfig(context);
500
- if (!isPluginEnabled({ plugin: webPlugin }) || !config.injectPrompt) {
499
+ if (!isPluginEnabled({ plugin: webPlugin, context }) || !config.injectPrompt) {
501
500
  return "";
502
501
  }
503
502
  const providerPrompt =
@@ -19,8 +19,8 @@ export const workboardPlugin: Plugin = {
19
19
  title: "Workboard Snapshot",
20
20
  description:
21
21
  "Collects structured runtime activity snapshots so console surfaces can show what the current agent is doing now and what it recently worked on.",
22
- availability() {
23
- if (!isPluginEnabled({ plugin: workboardPlugin })) {
22
+ availability(context) {
23
+ if (!isPluginEnabled({ plugin: workboardPlugin, context })) {
24
24
  return {
25
25
  enabled: false,
26
26
  available: false,
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import crypto from "node:crypto";
11
- import { PlatformStore } from "@/shared/utils/store/index.js";
11
+ import type { AgentPlatformRuntime } from "@/shared/types/AgentHost.js";
12
12
  import type { StoredChannelAccountChannel } from "@/shared/types/Store.js";
13
13
  import { resolveChatChannelBotInfo } from "@/service/builtins/chat/channels/BotInfoProvider.js";
14
14
  import type {
@@ -69,6 +69,12 @@ function pickFirstNonEmpty(inputs: unknown[]): string {
69
69
  * ChatChannelAccountService。
70
70
  */
71
71
  export class ChatChannelAccountService {
72
+ private readonly platform: AgentPlatformRuntime;
73
+
74
+ constructor(platform: AgentPlatformRuntime) {
75
+ this.platform = platform;
76
+ }
77
+
72
78
  /**
73
79
  * 生成唯一 channel account id。
74
80
  *
@@ -82,18 +88,13 @@ export class ChatChannelAccountService {
82
88
  }): Promise<string> {
83
89
  const seed = normalizeChannelAccountIdToken(params.seed || "");
84
90
  const prefix = `${params.channel}-${seed}`.slice(0, 36);
85
- const store = new PlatformStore();
86
- try {
87
- for (let index = 0; index < 8; index += 1) {
88
- const suffix = crypto.randomBytes(3).toString("hex");
89
- const candidate = `${prefix}-${suffix}`.slice(0, 64);
90
- const existing = await store.getChannelAccount(candidate);
91
- if (!existing) return candidate;
92
- }
93
- return `${params.channel}-${Date.now().toString(36)}`;
94
- } finally {
95
- store.close();
91
+ for (let index = 0; index < 8; index += 1) {
92
+ const suffix = crypto.randomBytes(3).toString("hex");
93
+ const candidate = `${prefix}-${suffix}`.slice(0, 64);
94
+ const existing = this.platform.getChannelAccount(candidate);
95
+ if (!existing) return candidate;
96
96
  }
97
+ return `${params.channel}-${Date.now().toString(36)}`;
97
98
  }
98
99
 
99
100
  /**
@@ -205,32 +206,13 @@ export class ChatChannelAccountService {
205
206
  * 列出账户池(脱敏)。
206
207
  */
207
208
  async list(): Promise<ChatChannelAccountListResult> {
208
- const store = new PlatformStore();
209
- try {
210
- const rows = await store.listChannelAccounts();
211
- return {
212
- items: rows.map((item) => ({
213
- id: item.id,
214
- channel: item.channel,
215
- name: item.name,
216
- identity: item.identity,
217
- owner: item.owner,
218
- creator: item.creator,
219
- domain: item.domain,
220
- sandbox: item.sandbox === true,
221
- hasBotToken: !!String(item.botToken || "").trim(),
222
- hasAppId: !!String(item.appId || "").trim(),
223
- hasAppSecret: !!String(item.appSecret || "").trim(),
224
- botTokenMasked: item.botToken ? maskSecret(item.botToken) : undefined,
225
- appIdMasked: item.appId ? maskSecret(item.appId) : undefined,
226
- appSecretMasked: item.appSecret ? maskSecret(item.appSecret) : undefined,
227
- createdAt: item.createdAt,
228
- updatedAt: item.updatedAt,
229
- })),
230
- };
231
- } finally {
232
- store.close();
209
+ const list = this.platform.listChannelAccounts;
210
+ if (!list) {
211
+ throw new Error("Channel account listing is not available in this runtime");
233
212
  }
213
+ return {
214
+ items: await list(),
215
+ };
234
216
  }
235
217
 
236
218
  /**
@@ -254,9 +236,7 @@ export class ChatChannelAccountService {
254
236
  throw new Error("appSecret and clearAppSecret cannot be used together");
255
237
  }
256
238
 
257
- const store = new PlatformStore();
258
- try {
259
- const current = await store.getChannelAccount(id);
239
+ const current = this.platform.getChannelAccount(id);
260
240
  const nextBotToken = input.clearBotToken
261
241
  ? undefined
262
242
  : input.botToken !== undefined
@@ -282,36 +262,36 @@ export class ChatChannelAccountService {
282
262
  ? normalizeOptionalText(input.creator)
283
263
  : current?.creator;
284
264
 
285
- await store.upsertChannelAccount({
286
- id,
287
- channel,
288
- name,
289
- identity: nextIdentity,
290
- owner: nextOwner,
291
- creator: nextCreator,
292
- botToken: nextBotToken,
293
- appId: nextAppId,
294
- appSecret: nextAppSecret,
295
- domain: normalizeOptionalText(input.domain),
296
- sandbox: input.sandbox === true,
297
- });
298
- return { id };
299
- } finally {
300
- store.close();
265
+ const updateChannelAccount = this.platform.updateChannelAccount;
266
+ if (!updateChannelAccount) {
267
+ throw new Error("Channel account update is not available in this runtime");
301
268
  }
269
+ await updateChannelAccount({
270
+ id,
271
+ channel,
272
+ name,
273
+ identity: nextIdentity,
274
+ owner: nextOwner,
275
+ creator: nextCreator,
276
+ botToken: nextBotToken,
277
+ appId: nextAppId,
278
+ appSecret: nextAppSecret,
279
+ domain: normalizeOptionalText(input.domain),
280
+ sandbox: input.sandbox === true,
281
+ });
282
+ return { id };
302
283
  }
303
284
 
304
285
  /**
305
286
  * 删除账号。
306
287
  */
307
- remove(idInput: string): void {
288
+ async remove(idInput: string): Promise<void> {
308
289
  const id = String(idInput || "").trim();
309
290
  if (!id) throw new Error("channel account id cannot be empty");
310
- const store = new PlatformStore();
311
- try {
312
- store.removeChannelAccount(id);
313
- } finally {
314
- store.close();
291
+ const removeChannelAccount = this.platform.removeChannelAccount;
292
+ if (!removeChannelAccount) {
293
+ throw new Error("Channel account removal is not available in this runtime");
315
294
  }
295
+ await removeChannelAccount(id);
316
296
  }
317
297
  }
@@ -7,7 +7,6 @@
7
7
  * - 对外只暴露 action 级入口,供 ChatServiceActions 装配使用。
8
8
  */
9
9
 
10
- import { PlatformStore } from "@/shared/utils/store/index.js";
11
10
  import type { AgentContext } from "@/agent/AgentContextTypes.js";
12
11
  import type { ChatChannelState } from "@/shared/types/ChatRuntime.js";
13
12
  import type {
@@ -264,23 +263,18 @@ export async function executeChatConfigureAction(params: {
264
263
  if (Object.prototype.hasOwnProperty.call(patch, "channelAccountId")) {
265
264
  const channelAccountId = String(patch.channelAccountId || "").trim();
266
265
  if (channelAccountId) {
267
- const store = new PlatformStore();
268
- try {
269
- const account = store.getChannelAccountSync(channelAccountId);
270
- if (!account) {
271
- return {
272
- success: false,
273
- error: `Bot account not found: ${channelAccountId}`,
274
- };
275
- }
276
- if (account.channel !== channel) {
277
- return {
278
- success: false,
279
- error: `Bot account channel mismatch: expected ${channel}, got ${account.channel}`,
280
- };
281
- }
282
- } finally {
283
- store.close();
266
+ const account = params.context.platform.getChannelAccount(channelAccountId);
267
+ if (!account) {
268
+ return {
269
+ success: false,
270
+ error: `Bot account not found: ${channelAccountId}`,
271
+ };
272
+ }
273
+ if (account.channel !== channel) {
274
+ return {
275
+ success: false,
276
+ error: `Bot account channel mismatch: expected ${channel}, got ${account.channel}`,
277
+ };
284
278
  }
285
279
  }
286
280
  }
@@ -7,7 +7,6 @@
7
7
  * - 目标是让 chat channel 子模块共享同一套最小公共基元。
8
8
  */
9
9
 
10
- import { PlatformStore } from "@/shared/utils/store/index.js";
11
10
  import type { AgentContext } from "@/agent/AgentContextTypes.js";
12
11
  import type { StoredChannelAccount } from "@/shared/types/Store.js";
13
12
  import type { ChatChannelName } from "@/service/builtins/chat/types/ChannelStatus.js";
@@ -85,7 +84,7 @@ export function resolveChannelAccountId(
85
84
  }
86
85
 
87
86
  /**
88
- * PlatformStore 中解析渠道 account。
87
+ * 从宿主平台能力中解析渠道 account。
89
88
  */
90
89
  export function resolveChannelAccount(
91
90
  context: AgentContext,
@@ -95,18 +94,14 @@ export function resolveChannelAccount(
95
94
  const explicit = service?.resolveChannelAccount?.(context, channel);
96
95
  if (explicit) return explicit;
97
96
  const channelAccountId = resolveChannelAccountId(context, channel);
98
- if (!channelAccountId) return null;
99
- const store = new PlatformStore();
100
- try {
101
- const account = store.getChannelAccountSync(channelAccountId);
102
- if (!account) return null;
103
- if (account.channel !== channel) return null;
104
- return account;
105
- } catch {
106
- return null;
107
- } finally {
108
- store.close();
109
- }
97
+ const account = context.platform.resolveChannelAccount?.({
98
+ projectRoot: context.rootPath,
99
+ channel,
100
+ ...(channelAccountId ? { channelAccountId } : {}),
101
+ }) || (channelAccountId ? context.platform.getChannelAccount(channelAccountId) : null);
102
+ if (!account) return null;
103
+ if (account.channel !== channel) return null;
104
+ return account;
110
105
  }
111
106
 
112
107
  /**
@@ -12,15 +12,16 @@ import type { JsonValue } from "@/shared/types/Json.js";
12
12
  import type {
13
13
  MemoryFlushPayload,
14
14
  MemoryGetPayload,
15
- MemoryIndexPayload,
16
15
  MemorySearchPayload,
17
16
  MemoryStorePayload,
18
17
  } from "@/service/builtins/memory/types/Memory.js";
19
18
  import { flushMemory } from "./runtime/Flush.js";
20
- import { searchMemory } from "./runtime/Search.js";
19
+ import {
20
+ collectMemoryStatus,
21
+ searchMemory,
22
+ } from "./runtime/Search.js";
21
23
  import {
22
24
  MEMORY_DEFAULTS,
23
- ensureMemoryIndexed,
24
25
  type MemoryRuntimeState,
25
26
  } from "./runtime/Store.js";
26
27
  import { getMemory, storeMemory } from "./runtime/Writer.js";
@@ -33,23 +34,10 @@ export async function statusMemoryAction(
33
34
  state: MemoryRuntimeState,
34
35
  ): Promise<ServiceActionResult<JsonValue>> {
35
36
  try {
36
- const stats = state.indexer.status();
37
+ const stats = await collectMemoryStatus(context, state);
37
38
  return {
38
39
  success: true,
39
- data: {
40
- enabled: state.enabled,
41
- backend: "builtin",
42
- mode: "fts",
43
- dbPath: state.indexer.getRelativeDbPath(),
44
- dirty: state.dirty,
45
- files: stats.files,
46
- chunks: stats.chunks,
47
- sourceCounts: stats.sourceCounts,
48
- ...(typeof state.lastSyncAt === "number"
49
- ? { lastSyncAt: state.lastSyncAt }
50
- : {}),
51
- ...(state.lastError ? { lastError: state.lastError } : {}),
52
- } as unknown as JsonValue,
40
+ data: stats as unknown as JsonValue,
53
41
  };
54
42
  } catch (error) {
55
43
  return {
@@ -59,35 +47,6 @@ export async function statusMemoryAction(
59
47
  }
60
48
  }
61
49
 
62
- /**
63
- * index action。
64
- */
65
- export async function indexMemoryAction(
66
- context: AgentContext,
67
- state: MemoryRuntimeState,
68
- payload: MemoryIndexPayload,
69
- ): Promise<ServiceActionResult<JsonValue>> {
70
- try {
71
- const result = await ensureMemoryIndexed(context, state, {
72
- force: payload.force === true,
73
- reason: payload.force ? "manual-force" : "manual",
74
- });
75
- const status = state.indexer.status();
76
- const data = {
77
- totalFiles: result?.totalFiles ?? status.files,
78
- reindexedFiles: result?.reindexedFiles ?? 0,
79
- removedFiles: result?.removedFiles ?? 0,
80
- totalChunks: result?.totalChunks ?? 0,
81
- };
82
- return { success: true, data: data as unknown as JsonValue };
83
- } catch (error) {
84
- return {
85
- success: false,
86
- error: String(error),
87
- };
88
- }
89
- }
90
-
91
50
  /**
92
51
  * search action。
93
52
  */