@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
@@ -16,6 +16,7 @@ import type { AgentContext } from "@/agent/AgentContextTypes.js";
16
16
  import type { AgentRuntime } from "@/agent/AgentRuntimeTypes.js";
17
17
  import type { DowncityConfig } from "@/shared/types/DowncityConfig.js";
18
18
  import type { JsonValue } from "@/shared/types/Json.js";
19
+ import type { AgentPlatformRuntime } from "@/shared/types/AgentHost.js";
19
20
  import type {
20
21
  Plugin,
21
22
  PluginAvailability,
@@ -43,6 +44,25 @@ import { HookRegistry } from "@/plugin/HookRegistry.js";
43
44
  import { PluginRegistry } from "@/plugin/PluginRegistry.js";
44
45
  import { isPluginEnabled } from "@/plugin/Activation.js";
45
46
 
47
+ const EMPTY_SDK_PLATFORM: AgentPlatformRuntime = {
48
+ getGlobalEnv: () => ({}),
49
+ getAgentEnv: () => ({}),
50
+ listModels: () => [],
51
+ listProviders: async () => [],
52
+ getModel: () => null,
53
+ getChannelAccount: () => null,
54
+ readChatAuthorizationConfig: () => ({
55
+ roles: {},
56
+ channels: {},
57
+ }),
58
+ writeChatAuthorizationConfig: async (_projectRoot, nextConfig) => nextConfig,
59
+ setChatAuthorizationUserRole: async () => ({
60
+ roles: {},
61
+ channels: {},
62
+ }),
63
+ isPluginEnabled: (pluginName) => pluginName === "auth",
64
+ };
65
+
46
66
  function createFallbackSdkConfig(agentId: string): DowncityConfig {
47
67
  return {
48
68
  name: agentId,
@@ -67,7 +87,9 @@ export class Agent {
67
87
  private readonly runtime: AgentRuntime;
68
88
  private readonly serviceContext: AgentContext;
69
89
  private readonly pluginRegistry: PluginRegistry;
90
+ private readonly pluginSystemProviders: Plugin[];
70
91
  private readonly config: DowncityConfig;
92
+ private readonly platform: AgentPlatformRuntime;
71
93
  private systems: string[];
72
94
  private servicesStartPromise: Promise<void> | null = null;
73
95
 
@@ -86,6 +108,7 @@ export class Agent {
86
108
 
87
109
  this.logger = new Logger();
88
110
  this.logger.bindProjectRoot(this.path);
111
+ this.platform = options.platform || EMPTY_SDK_PLATFORM;
89
112
  this.systems = loadStaticSystemPrompts(this.path);
90
113
  this.config = this.loadConfig();
91
114
  this.services = this.createServiceMap(options.services || []);
@@ -93,7 +116,10 @@ export class Agent {
93
116
  for (const service of this.services.values()) {
94
117
  service.bindAgent(this.runtime);
95
118
  }
96
- this.pluginRegistry = this.createPluginRegistry(options.plugins || []);
119
+ this.pluginSystemProviders = Array.isArray(options.plugins)
120
+ ? [...options.plugins]
121
+ : [];
122
+ this.pluginRegistry = this.createPluginRegistry(this.pluginSystemProviders);
97
123
  this.plugins = this.createPluginPort();
98
124
  this.serviceContext = this.createServiceContext();
99
125
  this.http = new SdkAgentHttpServer(this);
@@ -189,7 +215,7 @@ export class Agent {
189
215
  contextResolver: () => this.serviceContext,
190
216
  pluginEnabledChecker: (pluginName) => {
191
217
  const plugin = pluginRegistryRef?.get(pluginName);
192
- return plugin ? isPluginEnabled({ plugin }) : false;
218
+ return plugin ? isPluginEnabled({ plugin, context: this.serviceContext }) : false;
193
219
  },
194
220
  });
195
221
  const registry = new PluginRegistry({
@@ -226,6 +252,41 @@ export class Agent {
226
252
  };
227
253
  }
228
254
 
255
+ private async loadPluginSystemPrompts(): Promise<string[]> {
256
+ const out: string[] = [];
257
+ for (const plugin of this.pluginSystemProviders) {
258
+ if (typeof plugin.system !== "function") continue;
259
+ try {
260
+ if (!isPluginEnabled({ plugin, context: this.serviceContext })) continue;
261
+ if (typeof plugin.availability === "function") {
262
+ const availability = await plugin.availability(this.serviceContext);
263
+ if (!availability.available) continue;
264
+ }
265
+ const text = String(await plugin.system(this.serviceContext)).trim();
266
+ if (!text) continue;
267
+ out.push(text);
268
+ } catch {
269
+ // 单个 plugin system 失败不应阻断 SDK session 主链路。
270
+ }
271
+ }
272
+ return out;
273
+ }
274
+
275
+ private async loadServiceSystemPrompts(): Promise<string[]> {
276
+ const out: string[] = [];
277
+ for (const service of this.services.values()) {
278
+ if (typeof service.system !== "function") continue;
279
+ try {
280
+ const text = String(await service.system(this.serviceContext)).trim();
281
+ if (!text) continue;
282
+ out.push(text);
283
+ } catch {
284
+ // 单个 service system 失败不应阻断 SDK session 主链路。
285
+ }
286
+ }
287
+ return out;
288
+ }
289
+
229
290
  private createRuntime(): AgentRuntime {
230
291
  const runtime = {
231
292
  cwd: this.path,
@@ -237,6 +298,7 @@ export class Agent {
237
298
  systems: this.systems,
238
299
  paths: createAgentPathRuntime(this.path),
239
300
  pluginConfig: createAgentPluginConfigRuntime(this.path),
301
+ platform: this.platform,
240
302
  model: undefined,
241
303
  getSession: (sessionId: string) => {
242
304
  return this.getOrCreateSession(sessionId).getServicePort() as never;
@@ -267,6 +329,7 @@ export class Agent {
267
329
  systems: this.systems,
268
330
  paths: this.runtime.paths,
269
331
  pluginConfig: this.runtime.pluginConfig,
332
+ platform: this.platform,
270
333
  session: {
271
334
  get: (sessionId) => this.getOrCreateSession(sessionId).getServicePort(),
272
335
  listExecutingSessionIds: () => this.runtime.listExecutingSessionIds(),
@@ -347,6 +410,8 @@ export class Agent {
347
410
  tools: this.tools,
348
411
  logger: this.logger,
349
412
  getStaticSystemPrompts: () => this.systems,
413
+ getServiceSystemPrompts: () => this.loadServiceSystemPrompts(),
414
+ getPluginSystemPrompts: () => this.loadPluginSystemPrompts(),
350
415
  });
351
416
  this.sessionsById.set(resolvedSessionId, created);
352
417
  return created;
@@ -12,6 +12,7 @@ import type { BaseService } from "@/service/builtins/BaseService.js";
12
12
  import type { JsonValue } from "@/shared/types/Json.js";
13
13
  import type { Plugin } from "@/shared/types/Plugin.js";
14
14
  import type { SessionMessageV1 } from "@/types/session/SessionMessages.js";
15
+ import type { AgentPlatformRuntime } from "@/shared/types/AgentHost.js";
15
16
 
16
17
  /**
17
18
  * 本地 Agent 构造参数。
@@ -59,6 +60,15 @@ export interface AgentOptions {
59
60
  * - 同名 plugin 会直接报错,避免 action / hook / resolve 行为被静默覆盖。
60
61
  */
61
62
  plugins?: Plugin[];
63
+
64
+ /**
65
+ * 当前 agent 显式注入的平台能力集合。
66
+ *
67
+ * 关键点(中文)
68
+ * - SDK 侧若不提供,则使用最小空实现。
69
+ * - 推荐由宿主产品显式传入,避免 SDK 本地实例隐式依赖 city。
70
+ */
71
+ platform?: AgentPlatformRuntime;
62
72
  }
63
73
 
64
74
  /**
@@ -3,8 +3,7 @@
3
3
  *
4
4
  * 关键点(中文)
5
5
  * - 面向 `Agent` SDK 的本地会话执行场景。
6
- * - v1 先只注入静态 PROFILE / SOUL / core prompt 与运行时时钟上下文。
7
- * - 暂不把 service/plugin system 注入暴露到 SDK 主路径。
6
+ * - 注入静态 PROFILE / SOUL / core prompt、显式注入 service system、显式注册 plugin system 与运行时时钟上下文。
8
7
  */
9
8
 
10
9
  import { SessionSystemComposer } from "@session/composer/system/SessionSystemComposer.js";
@@ -22,6 +21,16 @@ type SdkSessionSystemComposerOptions = {
22
21
  * 读取当前生效的静态 system 文本集合。
23
22
  */
24
23
  getStaticSystemPrompts: () => string[];
24
+
25
+ /**
26
+ * 读取当前显式注册 plugin 的 system 文本集合。
27
+ */
28
+ getPluginSystemPrompts: () => Promise<string[]>;
29
+
30
+ /**
31
+ * 读取当前显式注入 service 的 system 文本集合。
32
+ */
33
+ getServiceSystemPrompts: () => Promise<string[]>;
25
34
  };
26
35
 
27
36
  /**
@@ -32,11 +41,15 @@ export class SdkSessionSystemComposer extends SessionSystemComposer {
32
41
 
33
42
  private readonly projectRoot: string;
34
43
  private readonly getStaticSystemPrompts: SdkSessionSystemComposerOptions["getStaticSystemPrompts"];
44
+ private readonly getServiceSystemPrompts: SdkSessionSystemComposerOptions["getServiceSystemPrompts"];
45
+ private readonly getPluginSystemPrompts: SdkSessionSystemComposerOptions["getPluginSystemPrompts"];
35
46
 
36
47
  constructor(options: SdkSessionSystemComposerOptions) {
37
48
  super();
38
49
  this.projectRoot = String(options.projectRoot || "").trim();
39
50
  this.getStaticSystemPrompts = options.getStaticSystemPrompts;
51
+ this.getServiceSystemPrompts = options.getServiceSystemPrompts;
52
+ this.getPluginSystemPrompts = options.getPluginSystemPrompts;
40
53
  if (!this.projectRoot) {
41
54
  throw new Error("SdkSessionSystemComposer requires a non-empty projectRoot");
42
55
  }
@@ -61,9 +74,33 @@ export class SdkSessionSystemComposer extends SessionSystemComposer {
61
74
  variableMode: "stable",
62
75
  },
63
76
  );
77
+ const servicePrompts = (await this.getServiceSystemPrompts()).filter((item) =>
78
+ String(item || "").trim(),
79
+ );
80
+ const serviceMessages = await transformPromptsIntoSystemMessages(
81
+ servicePrompts,
82
+ {
83
+ projectPath: this.projectRoot,
84
+ sessionId,
85
+ variableMode: "stable",
86
+ },
87
+ );
88
+ const pluginPrompts = (await this.getPluginSystemPrompts()).filter((item) =>
89
+ String(item || "").trim(),
90
+ );
91
+ const pluginMessages = await transformPromptsIntoSystemMessages(
92
+ pluginPrompts,
93
+ {
94
+ projectPath: this.projectRoot,
95
+ sessionId,
96
+ variableMode: "stable",
97
+ },
98
+ );
64
99
 
65
100
  return [
66
101
  ...staticMessages,
102
+ ...serviceMessages,
103
+ ...pluginMessages,
67
104
  {
68
105
  role: "system" as const,
69
106
  content: buildRuntimeClockSystemPrompt({
@@ -73,6 +73,16 @@ type SdkSessionOptions = {
73
73
  * 读取静态 system 文本集合。
74
74
  */
75
75
  getStaticSystemPrompts: () => string[];
76
+
77
+ /**
78
+ * 读取当前 agent 显式注入 service 的 system 文本集合。
79
+ */
80
+ getServiceSystemPrompts: () => Promise<string[]>;
81
+
82
+ /**
83
+ * 读取当前 agent 显式注册 plugin 的 system 文本集合。
84
+ */
85
+ getPluginSystemPrompts: () => Promise<string[]>;
76
86
  };
77
87
 
78
88
  /**
@@ -86,6 +96,8 @@ export class SdkSession {
86
96
  private readonly tools: Record<string, Tool>;
87
97
  private readonly logger: SdkSessionOptions["logger"];
88
98
  private readonly getStaticSystemPrompts: SdkSessionOptions["getStaticSystemPrompts"];
99
+ private readonly getServiceSystemPrompts: SdkSessionOptions["getServiceSystemPrompts"];
100
+ private readonly getPluginSystemPrompts: SdkSessionOptions["getPluginSystemPrompts"];
89
101
  private readonly historyComposer: JsonlSessionHistoryComposer;
90
102
  private readonly coreSession: CoreSession;
91
103
  private sessionConfig: AgentSessionConfigSnapshot = {};
@@ -99,6 +111,8 @@ export class SdkSession {
99
111
  this.tools = options.tools;
100
112
  this.logger = options.logger;
101
113
  this.getStaticSystemPrompts = options.getStaticSystemPrompts;
114
+ this.getServiceSystemPrompts = options.getServiceSystemPrompts;
115
+ this.getPluginSystemPrompts = options.getPluginSystemPrompts;
102
116
  if (!this.id) {
103
117
  throw new Error("SdkSession requires a non-empty sessionId");
104
118
  }
@@ -149,6 +163,8 @@ export class SdkSession {
149
163
  systemComposer: new SdkSessionSystemComposer({
150
164
  projectRoot: this.projectRoot,
151
165
  getStaticSystemPrompts: this.getStaticSystemPrompts,
166
+ getServiceSystemPrompts: this.getServiceSystemPrompts,
167
+ getPluginSystemPrompts: this.getPluginSystemPrompts,
152
168
  }),
153
169
  getTools: () => this.tools,
154
170
  });
@@ -356,6 +372,8 @@ export class SdkSession {
356
372
  tools: this.tools,
357
373
  logger: this.logger,
358
374
  getStaticSystemPrompts: this.getStaticSystemPrompts,
375
+ getServiceSystemPrompts: this.getServiceSystemPrompts,
376
+ getPluginSystemPrompts: this.getPluginSystemPrompts,
359
377
  });
360
378
  await forked.initialize();
361
379
  if (this.sessionConfig.model) {
@@ -21,12 +21,6 @@ import {
21
21
  import { pluginsRouter } from "@/http/plugins/plugins.js";
22
22
  import { staticRouter } from "@/http/static/static.js";
23
23
  import { controlRouter } from "@/http/control/ControlRouter.js";
24
- import { registerAuthRoutes } from "@/http/auth/AuthRoutes.js";
25
- import { AuthService } from "@/http/auth/AuthService.js";
26
- import {
27
- createRouteAuthGuardMiddleware,
28
- SERVER_AUTH_ROUTE_POLICIES,
29
- } from "@/http/auth/RoutePolicy.js";
30
24
  import {
31
25
  listBuiltinPluginRuntimeAuthPolicies,
32
26
  registerBuiltinPluginHttpRoutes,
@@ -60,11 +54,6 @@ export interface ServerInstance {
60
54
  */
61
55
  export function createServerApp(): Hono {
62
56
  const app = new Hono();
63
- const authService = new AuthService();
64
- const authPolicies = [
65
- ...SERVER_AUTH_ROUTE_POLICIES,
66
- ...listBuiltinPluginRuntimeAuthPolicies(),
67
- ];
68
57
 
69
58
  app.use("*", logger());
70
59
  app.use(
@@ -75,7 +64,6 @@ export function createServerApp(): Hono {
75
64
  allowHeaders: ["Content-Type", "Authorization"],
76
65
  }),
77
66
  );
78
- app.use("*", createRouteAuthGuardMiddleware(authService, authPolicies));
79
67
 
80
68
  // 关键点(中文):service action 路由在 runtime ready 后再注册,避免命令级 import 副作用。
81
69
  ensureServiceActionRoutesRegistered();
@@ -91,7 +79,6 @@ export function createServerApp(): Hono {
91
79
  app,
92
80
  getContext: getAgentContext,
93
81
  });
94
- registerAuthRoutes({ app, authService });
95
82
 
96
83
  return app;
97
84
  }
@@ -28,11 +28,6 @@ export function normalizeBearerToken(value: unknown): string | null {
28
28
 
29
29
  /**
30
30
  * 解析本次调用应使用的 token。
31
- *
32
- * 优先级(中文)
33
- * 1. 显式传入 token
34
- * 2. 用户显式覆盖环境变量 `DC_AUTH_TOKEN`
35
- * 3. 调用方传入的本地存储 token
36
31
  */
37
32
  export function resolveInvocationToken(params: {
38
33
  explicitToken?: string;
@@ -52,10 +47,6 @@ export function resolveInvocationToken(params: {
52
47
 
53
48
  /**
54
49
  * 从通用子进程环境中剥离 Bearer Token。
55
- *
56
- * 关键点(中文)
57
- * - shell / task script / ACP 等通用执行面不应默认继承任何 HTTP 鉴权信息。
58
- * - 这样可以强制这些链路优先走 RPC,而不是通过环境变量隐式改走本地 HTTP。
59
50
  */
60
51
  export function stripInvocationAuthEnv(targetEnv: NodeJS.ProcessEnv): void {
61
52
  delete targetEnv[CLI_AUTH_TOKEN_ENV_KEY];
@@ -24,10 +24,6 @@ export interface CliAuthStateStoreOptions {
24
24
 
25
25
  /**
26
26
  * 解析当前 CLI 应使用的 Bearer Token。
27
- *
28
- * 优先级(中文)
29
- * 1. 显式传入 token
30
- * 2. 环境变量 `DC_AUTH_TOKEN`
31
27
  */
32
28
  export function resolveCliAuthToken(params: {
33
29
  explicitToken?: string;
@@ -8,7 +8,6 @@
8
8
 
9
9
  import fs from "fs-extra";
10
10
  import { getDowncityJsonPath } from "@/config/Paths.js";
11
- import { PlatformStore } from "@shared/utils/store/index.js";
12
11
  import type { ControlRouteRegistrationParams } from "@/shared/types/ControlRoutes.js";
13
12
  import { buildControlRouteAliases } from "@/http/control/CommonHelpers.js";
14
13
 
@@ -25,9 +24,8 @@ export function registerControlModelRoutes(
25
24
  try {
26
25
  const agentState = params.getAgentRuntime();
27
26
  const agentPrimaryModelId = String(agentState.config.execution?.type === "api" ? agentState.config.execution.modelId || "" : "").trim();
28
- const store = new PlatformStore();
29
- const models = store.listModels();
30
- const providers = await store.listProviders();
27
+ const models = agentState.platform.listModels();
28
+ const providers = await agentState.platform.listProviders();
31
29
  const providerMap = new Map(providers.map((x) => [x.id, x] as const));
32
30
  const activeModel = agentPrimaryModelId
33
31
  ? models.find((x) => x.id === agentPrimaryModelId)
@@ -43,8 +41,6 @@ export function registerControlModelRoutes(
43
41
  providerType: String(providerConfig?.type || "").trim(),
44
42
  };
45
43
  });
46
- store.close();
47
-
48
44
  return c.json({
49
45
  success: true,
50
46
  model: {
@@ -74,9 +70,7 @@ export function registerControlModelRoutes(
74
70
  if (!nextPrimaryModelId) {
75
71
  return c.json({ success: false, error: "Missing primaryModelId" }, 400);
76
72
  }
77
- const store = new PlatformStore();
78
- const targetModel = store.getModel(nextPrimaryModelId);
79
- store.close();
73
+ const targetModel = agentState.platform.getModel(nextPrimaryModelId);
80
74
  if (!targetModel) {
81
75
  return c.json(
82
76
  { success: false, error: `Model not found: ${nextPrimaryModelId}` },
package/src/index.ts CHANGED
@@ -108,9 +108,8 @@ export {
108
108
  startServiceScheduleRuntime,
109
109
  stopServiceScheduleRuntime,
110
110
  } from './service/schedule/Runtime.js';
111
- export { runDueScheduledJobs } from "./service/schedule/Executor.js";
112
111
  export { ServiceScheduleStore } from "./service/schedule/Store.js";
113
- export { scheduledJobsTable } from "./service/schedule/Schema.js";
112
+ export { runDueScheduledJobs } from "./service/schedule/Executor.js";
114
113
  export {
115
114
  normalizeRunAtMsOrThrow,
116
115
  parseScheduledRunAtMsOrThrow,
@@ -121,15 +120,6 @@ export {
121
120
  resolveAssistantMessageForPersistence,
122
121
  } from "./service/builtins/chat/runtime/UserVisibleText.js";
123
122
  export { logger, getLogger, type Logger } from "./shared/utils/logger/Logger.js";
124
- export { PlatformStore, withPlatformStore } from "./shared/utils/store/index.js";
125
- export { ensurePlatformStoreSchema } from "./shared/utils/store/StoreSchema.js";
126
- export {
127
- nowIso,
128
- normalizeNonEmptyText,
129
- optionalTrimmedText,
130
- type PlatformDrizzleDb,
131
- type PlatformStoreContext,
132
- } from "./shared/utils/store/StoreShared.js";
133
123
 
134
124
  // 共享协议类型与控制面常量
135
125
  export * from "./shared/types/AgentHost.js";
@@ -157,6 +147,7 @@ export * from "./shared/types/ServiceSchedule.js";
157
147
  export * from "./shared/types/Services.js";
158
148
  export * from "./shared/types/Start.js";
159
149
  export * from "./shared/types/Store.js";
150
+ export * from "./shared/types/PluginLifecycle.js";
160
151
  export * from "./shared/types/auth/AuthPermission.js";
161
152
  export * from "./shared/types/auth/AuthRoute.js";
162
153
  export * from "./shared/types/auth/AuthToken.js";
@@ -209,7 +200,6 @@ export {
209
200
  listStaticPluginViews,
210
201
  toStaticPluginView,
211
202
  } from "./plugin/Catalog.js";
212
- export { setCityPluginEnabled, isCityPluginEnabled } from "./plugin/Lifecycle.js";
213
203
  export { runLocalPluginAction, listLocalPlugins, getLocalPluginAvailability } from "./plugin/LocalExecution.js";
214
204
  export { registerAllPluginsForCli } from "./plugin/PluginCommand.js";
215
205
  export { listBuiltinPluginRuntimeAuthPolicies } from "./plugin/HttpRoutes.js";
@@ -21,8 +21,8 @@ import { createLlmLoggingFetch } from "@shared/utils/logger/Fetch.js";
21
21
  import { getLogger } from "@shared/utils/logger/Logger.js";
22
22
  import type { DowncityConfig } from "@/shared/types/DowncityConfig.js";
23
23
  import type { LlmProviderType } from "@/shared/types/LlmConfig.js";
24
- import { PlatformStore } from "@shared/utils/store/index.js";
25
24
  import { readProjectExecutionBinding } from "@/agent/project/ProjectExecutionBinding.js";
25
+ import type { AgentPlatformRuntime } from "@/shared/types/AgentHost.js";
26
26
 
27
27
  type ModelLogContext = {
28
28
  sessionId?: string;
@@ -149,7 +149,7 @@ function normalizeProviderType(value: unknown): LlmProviderType | null {
149
149
  export async function createModel(input: {
150
150
  config: DowncityConfig;
151
151
  getSessionRunScope?: () => ModelLogContext | undefined;
152
- store?: PlatformStore;
152
+ platform?: AgentPlatformRuntime;
153
153
  projectRoot?: string;
154
154
  }): Promise<LanguageModel> {
155
155
  const logger = getLogger();
@@ -174,21 +174,23 @@ export async function createModel(input: {
174
174
 
175
175
  const primaryModelId = execution.modelId;
176
176
 
177
- const store = input.store || new PlatformStore();
178
- const resolved = await store.getResolvedModel(primaryModelId);
179
- if (!input.store) {
180
- store.close();
177
+ const platform = input.platform;
178
+ const modelConfig = platform?.getModel(primaryModelId) || null;
179
+ const providerConfigs = await (platform?.listProviders?.() || Promise.resolve([]));
180
+ const providerMap = new Map(providerConfigs.map((item) => [item.id, item] as const));
181
+ const providerConfig = modelConfig
182
+ ? providerMap.get(String(modelConfig.providerId || "").trim()) || null
183
+ : null;
184
+ if (!modelConfig || !providerConfig) {
185
+ await logger.log("warn", `LLM model config not found in platform runtime: ${primaryModelId}`);
186
+ throw Error(`LLM model config not found in platform runtime: ${primaryModelId}`);
181
187
  }
182
- if (!resolved) {
183
- await logger.log("warn", `LLM model config not found in sqlite store: ${primaryModelId}`);
184
- throw Error(`LLM model config not found in sqlite store: ${primaryModelId}`);
185
- }
186
- const selectedModelConfig = resolved.model;
187
- const selectedProviderConfig = resolved.provider;
188
+ const selectedModelConfig = modelConfig;
189
+ const selectedProviderConfig = providerConfig;
188
190
  if (selectedModelConfig.isPaused === true) {
189
191
  await logger.log(
190
192
  "warn",
191
- `LLM model is paused in sqlite store: ${primaryModelId}`,
193
+ `LLM model is paused in platform runtime: ${primaryModelId}`,
192
194
  );
193
195
  throw Error(`LLM model is paused: ${primaryModelId}`);
194
196
  }
@@ -7,16 +7,20 @@
7
7
  */
8
8
 
9
9
  import type { Plugin } from "@/shared/types/Plugin.js";
10
- import { isCityPluginEnabled } from "@/plugin/Lifecycle.js";
10
+ import type { AgentContext } from "@/agent/AgentContextTypes.js";
11
+ import type { AgentRuntimeBase } from "@/agent/AgentRuntimeTypes.js";
11
12
 
12
13
  /**
13
14
  * 读取当前 city 配置下的 plugin 启用态。
14
15
  */
15
16
  export function isPluginEnabled(params: {
16
17
  plugin: Plugin;
18
+ context?: Pick<AgentContext, "platform">;
19
+ runtime?: Pick<AgentRuntimeBase, "platform">;
17
20
  }): boolean {
18
21
  const pluginName = String(params.plugin.name || "").trim();
19
22
  if (!pluginName) return false;
20
23
  if (pluginName === "auth") return true;
21
- return isCityPluginEnabled(pluginName);
24
+ const platform = params.context?.platform || params.runtime?.platform;
25
+ return platform ? platform.isPluginEnabled(pluginName) : true;
22
26
  }
@@ -16,6 +16,7 @@ import {
16
16
  createAgentPathRuntime,
17
17
  createAgentPluginConfigRuntime,
18
18
  } from "@/host/runtime/AgentHostRuntime.js";
19
+ import { getAgentRuntimeBase } from "@/agent/AgentRuntimeState.js";
19
20
  import type { JsonValue } from "@/shared/types/Json.js";
20
21
  import type {
21
22
  PluginActionResult,
@@ -38,6 +39,26 @@ export function createLocalPluginCommandContext(projectRoot: string): PluginComm
38
39
 
39
40
  defaultLogger.bindProjectRoot(rootPath);
40
41
 
42
+ const platform = (() => {
43
+ try {
44
+ return getAgentRuntimeBase().platform;
45
+ } catch {
46
+ return {
47
+ getGlobalEnv: () => ({}),
48
+ getAgentEnv: () => ({}),
49
+ listModels: () => [],
50
+ listProviders: async () => [],
51
+ getModel: () => null,
52
+ getChannelAccount: () => null,
53
+ readChatAuthorizationConfig: () => ({ roles: {}, channels: {} }),
54
+ writeChatAuthorizationConfig: async (_projectRoot: string, nextConfig: unknown) =>
55
+ nextConfig as never,
56
+ setChatAuthorizationUserRole: async () => ({ roles: {}, channels: {} }),
57
+ isPluginEnabled: (pluginName: string) => pluginName === "auth",
58
+ };
59
+ }
60
+ })();
61
+
41
62
  return {
42
63
  cwd: rootPath,
43
64
  rootPath,
@@ -47,6 +68,7 @@ export function createLocalPluginCommandContext(projectRoot: string): PluginComm
47
68
  globalEnv,
48
69
  paths: createAgentPathRuntime(rootPath),
49
70
  pluginConfig: createAgentPluginConfigRuntime(rootPath),
71
+ platform,
50
72
  };
51
73
  }
52
74
 
@@ -78,7 +100,7 @@ export async function getLocalPluginAvailability(
78
100
  return await plugin.availability(context);
79
101
  }
80
102
 
81
- const enabled = isPluginEnabled({ plugin });
103
+ const enabled = isPluginEnabled({ plugin, context });
82
104
  if (!enabled) {
83
105
  return {
84
106
  enabled: false,
@@ -131,7 +153,7 @@ export async function runLocalPluginAction(params: {
131
153
  }
132
154
 
133
155
  const context = createLocalPluginCommandContext(params.projectRoot);
134
- const enabled = isPluginEnabled({ plugin });
156
+ const enabled = isPluginEnabled({ plugin, context });
135
157
  if (!enabled && action.allowWhenDisabled !== true) {
136
158
  return {
137
159
  success: false,
@@ -165,7 +165,7 @@ export class PluginRegistry {
165
165
  }
166
166
 
167
167
  const context = this.contextResolver();
168
- const enabled = isPluginEnabled({ plugin });
168
+ const enabled = isPluginEnabled({ plugin, context });
169
169
 
170
170
  if (!enabled) {
171
171
  return {
@@ -217,7 +217,7 @@ export class PluginRegistry {
217
217
  }
218
218
 
219
219
  const context = this.contextResolver();
220
- const enabled = isPluginEnabled({ plugin });
220
+ const enabled = isPluginEnabled({ plugin, context });
221
221
  if (!enabled && action.allowWhenDisabled !== true) {
222
222
  return {
223
223
  success: false,
@@ -14,7 +14,6 @@ import type { JsonObject, JsonValue } from "@/shared/types/Json.js";
14
14
  import type { AgentPluginConfigRuntime } from "@/shared/types/AgentHost.js";
15
15
  import { CHAT_PLUGIN_POINTS } from "@/service/builtins/chat/runtime/PluginPoints.js";
16
16
  import { isPluginEnabled } from "@/plugin/Activation.js";
17
- import { setCityPluginEnabled } from "@/plugin/Lifecycle.js";
18
17
  import {
19
18
  listVoiceModels,
20
19
  resolveVoicePluginModelId,
@@ -228,7 +227,7 @@ export const asrPlugin: Plugin = {
228
227
  statusAction: "status",
229
228
  },
230
229
  async availability(context) {
231
- if (!isPluginEnabled({ plugin: asrPlugin })) {
230
+ if (!isPluginEnabled({ plugin: asrPlugin, context })) {
232
231
  return {
233
232
  enabled: false,
234
233
  available: false,
@@ -432,7 +431,7 @@ export const asrPlugin: Plugin = {
432
431
  },
433
432
  },
434
433
  execute: async ({ context, payload }) => {
435
- setCityPluginEnabled("asr", true);
434
+ context.platform.setPluginEnabled?.("asr", true);
436
435
  const nextConfig = {
437
436
  ...readVoicePluginConfig(context),
438
437
  injectPrompt:
@@ -481,7 +480,7 @@ export const asrPlugin: Plugin = {
481
480
  },
482
481
  },
483
482
  execute: async ({ context }) => {
484
- setCityPluginEnabled("asr", false);
483
+ context.platform.setPluginEnabled?.("asr", false);
485
484
  return {
486
485
  success: true,
487
486
  data: {
@@ -629,7 +628,7 @@ export const asrPlugin: Plugin = {
629
628
  },
630
629
  system(context) {
631
630
  const config = readVoicePluginConfig(context);
632
- if (!isPluginEnabled({ plugin: asrPlugin }) || config.injectPrompt !== true) {
631
+ if (!isPluginEnabled({ plugin: asrPlugin, context }) || config.injectPrompt !== true) {
633
632
  return "";
634
633
  }
635
634
  return [
@@ -140,6 +140,7 @@ export const authPlugin: Plugin = {
140
140
  channel,
141
141
  userId: String(input.userId || "").trim(),
142
142
  rootPath: context.rootPath,
143
+ platform: context.platform,
143
144
  });
144
145
  return ((role || null) as unknown) as JsonValue;
145
146
  },