@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
@@ -1,165 +0,0 @@
1
- /**
2
- * 统一账户存储层。
3
- *
4
- * 关键点(中文)
5
- * - 该模块只负责 `auth_*` 表的读写,不处理密码校验与 HTTP 语义。
6
- * - 数据仍落在控制面全局 SQLite 中,与现有平台配置共享底层存储。
7
- */
8
- import type { AuthIssuedToken, AuthTokenSummary } from "../../shared/types/auth/AuthToken.js";
9
- import { type AuthDefaultRoleName, type AuthPermissionKey } from "../../shared/types/auth/AuthPermission.js";
10
- import type { AuthAuditLog, AuthTokenRecord, AuthUser } from "../../shared/types/auth/AuthTypes.js";
11
- /**
12
- * AuthStore 构造参数。
13
- */
14
- export interface AuthStoreOptions {
15
- /**
16
- * SQLite 数据库路径。
17
- */
18
- dbPath?: string;
19
- }
20
- /**
21
- * AuthStore 门面。
22
- */
23
- export declare class AuthStore {
24
- private readonly sqlite;
25
- private readonly context;
26
- constructor(options?: AuthStoreOptions);
27
- /**
28
- * 关闭数据库连接。
29
- */
30
- close(): void;
31
- /**
32
- * 返回当前用户数量。
33
- */
34
- countUsers(): number;
35
- /**
36
- * 幂等写入默认角色与权限目录。
37
- */
38
- ensureDefaultCatalog(): void;
39
- /**
40
- * 创建用户。
41
- */
42
- createUser(input: {
43
- username: string;
44
- passwordHash: string;
45
- displayName?: string;
46
- status?: "active" | "disabled";
47
- }): AuthUser;
48
- /**
49
- * 根据用户名读取用户。
50
- */
51
- findUserByUsername(usernameInput: string): AuthUser | null;
52
- /**
53
- * 根据用户 ID 读取用户。
54
- */
55
- getUserById(userIdInput: string): AuthUser | null;
56
- /**
57
- * 读取全部用户列表。
58
- */
59
- listUsers(): AuthUser[];
60
- /**
61
- * 更新用户基础资料。
62
- */
63
- updateUser(params: {
64
- userId: string;
65
- displayName?: string;
66
- status?: "active" | "disabled";
67
- }): AuthUser | null;
68
- /**
69
- * 更新用户密码哈希。
70
- */
71
- updateUserPasswordHash(params: {
72
- userId: string;
73
- passwordHash: string;
74
- }): AuthUser | null;
75
- /**
76
- * 给用户绑定角色。
77
- */
78
- assignRoleToUser(params: {
79
- userId: string;
80
- roleName: AuthDefaultRoleName | string;
81
- }): void;
82
- /**
83
- * 读取用户角色名列表。
84
- */
85
- listRoleNamesByUserId(userIdInput: string): string[];
86
- /**
87
- * 清空用户当前绑定的全部角色。
88
- */
89
- clearRolesByUserId(userIdInput: string): void;
90
- /**
91
- * 用新的角色集合覆盖用户角色绑定。
92
- */
93
- replaceRolesByUserId(params: {
94
- userId: string;
95
- roleNames: string[];
96
- }): string[];
97
- /**
98
- * 统计拥有指定角色且处于 active 状态的用户数量。
99
- */
100
- countActiveUsersByRole(roleNameInput: string): number;
101
- /**
102
- * 读取用户权限 key 列表。
103
- */
104
- listPermissionKeysByUserId(userIdInput: string): AuthPermissionKey[];
105
- /**
106
- * 创建 token 记录。
107
- */
108
- createToken(input: {
109
- userId: string;
110
- name: string;
111
- tokenHash: string;
112
- expiresAt?: string;
113
- }): AuthTokenRecord;
114
- /**
115
- * 根据 token 哈希读取记录。
116
- */
117
- findTokenByHash(tokenHashInput: string): AuthTokenRecord | null;
118
- /**
119
- * 根据 token ID 读取记录。
120
- */
121
- getTokenById(tokenIdInput: string): AuthTokenRecord | null;
122
- /**
123
- * 读取用户 token 列表。
124
- */
125
- listTokensByUserId(userIdInput: string): AuthTokenRecord[];
126
- /**
127
- * 更新 token 最后使用时间。
128
- */
129
- touchToken(tokenIdInput: string): void;
130
- /**
131
- * 吊销 token。
132
- */
133
- revokeToken(tokenIdInput: string): AuthTokenRecord | null;
134
- /**
135
- * 删除 token。
136
- */
137
- deleteToken(tokenIdInput: string): boolean;
138
- /**
139
- * 写入审计日志。
140
- */
141
- insertAuditLog(input: {
142
- actorUserId?: string;
143
- actorTokenId?: string;
144
- resourceType: string;
145
- resourceId?: string;
146
- action: string;
147
- result: string;
148
- requestId?: string;
149
- ip?: string;
150
- userAgent?: string;
151
- metaJson?: string;
152
- }): AuthAuditLog;
153
- /**
154
- * 将 token 记录转换为对外摘要。
155
- */
156
- toTokenSummary(record: AuthTokenRecord): AuthTokenSummary;
157
- /**
158
- * 将 token 记录与明文 token 合成为一次性返回体。
159
- */
160
- toIssuedToken(record: AuthTokenRecord, token: string): AuthIssuedToken;
161
- private toAuthUser;
162
- private toAuthToken;
163
- private _unused;
164
- }
165
- //# sourceMappingURL=AuthStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthStore.d.ts","sourceRoot":"","sources":["../../../src/http/auth/AuthStore.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EACV,YAAY,EAGZ,eAAe,EACf,QAAQ,EACT,MAAM,kCAAkC,CAAC;AAS1C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,C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,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,YAAY;IAsChB;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,gBAAgB;IAWzD;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,eAAe;IAOtE,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,OAAO;CAGhB"}
@@ -1,442 +0,0 @@
1
- /**
2
- * 统一账户存储层。
3
- *
4
- * 关键点(中文)
5
- * - 该模块只负责 `auth_*` 表的读写,不处理密码校验与 HTTP 语义。
6
- * - 数据仍落在控制面全局 SQLite 中,与现有平台配置共享底层存储。
7
- */
8
- import fs from "fs-extra";
9
- import path from "node:path";
10
- import Database from "better-sqlite3";
11
- import { drizzle } from "drizzle-orm/better-sqlite3";
12
- import { nanoid } from "nanoid";
13
- import { getPlatformStoreDbPath } from "../../host/runtime/CityPaths.js";
14
- import { AUTH_DEFAULT_ROLES, AUTH_PERMISSION_DESCRIPTIONS, AUTH_PERMISSION_KEYS, } from "../../shared/types/auth/AuthPermission.js";
15
- import { ensurePlatformStoreSchema } from "../../shared/utils/store/StoreSchema.js";
16
- import { nowIso, normalizeNonEmptyText, optionalTrimmedText, } from "../../shared/utils/store/StoreShared.js";
17
- /**
18
- * AuthStore 门面。
19
- */
20
- export class AuthStore {
21
- sqlite;
22
- context;
23
- constructor(options = {}) {
24
- const dbPath = path.resolve(options.dbPath || getPlatformStoreDbPath());
25
- fs.ensureDirSync(path.dirname(dbPath));
26
- this.sqlite = new Database(dbPath);
27
- this.sqlite.pragma("journal_mode = WAL");
28
- this.context = {
29
- sqlite: this.sqlite,
30
- db: drizzle(this.sqlite),
31
- };
32
- ensurePlatformStoreSchema(this.context);
33
- }
34
- /**
35
- * 关闭数据库连接。
36
- */
37
- close() {
38
- this.sqlite.close();
39
- }
40
- /**
41
- * 返回当前用户数量。
42
- */
43
- countUsers() {
44
- const row = this.sqlite.prepare("SELECT COUNT(*) as count FROM auth_users").get();
45
- return Number(row?.count || 0);
46
- }
47
- /**
48
- * 幂等写入默认角色与权限目录。
49
- */
50
- ensureDefaultCatalog() {
51
- const now = nowIso();
52
- const tx = this.sqlite.transaction(() => {
53
- const roleIds = new Map();
54
- for (const role of AUTH_DEFAULT_ROLES) {
55
- const existing = this.sqlite
56
- .prepare("SELECT id FROM auth_roles WHERE name = ?")
57
- .get(role.name);
58
- if (existing?.id) {
59
- this.sqlite
60
- .prepare("UPDATE auth_roles SET description = ?, updated_at = ? WHERE id = ?")
61
- .run(role.description, now, String(existing.id));
62
- roleIds.set(role.name, String(existing.id));
63
- }
64
- else {
65
- const id = nanoid();
66
- this.sqlite
67
- .prepare("INSERT INTO auth_roles (id, name, description, created_at, updated_at) VALUES (?, ?, ?, ?, ?)")
68
- .run(id, role.name, role.description, now, now);
69
- roleIds.set(role.name, id);
70
- }
71
- }
72
- const permissionIds = new Map();
73
- for (const permission of AUTH_PERMISSION_KEYS) {
74
- const description = AUTH_PERMISSION_DESCRIPTIONS[permission];
75
- const existing = this.sqlite
76
- .prepare("SELECT id FROM auth_permissions WHERE key = ?")
77
- .get(permission);
78
- if (existing?.id) {
79
- this.sqlite
80
- .prepare("UPDATE auth_permissions SET description = ?, updated_at = ? WHERE id = ?")
81
- .run(description, now, String(existing.id));
82
- permissionIds.set(permission, String(existing.id));
83
- }
84
- else {
85
- const id = nanoid();
86
- this.sqlite
87
- .prepare("INSERT INTO auth_permissions (id, key, description, created_at, updated_at) VALUES (?, ?, ?, ?, ?)")
88
- .run(id, permission, description, now, now);
89
- permissionIds.set(permission, id);
90
- }
91
- }
92
- for (const role of AUTH_DEFAULT_ROLES) {
93
- const roleId = roleIds.get(role.name);
94
- if (!roleId)
95
- continue;
96
- for (const permission of role.permissions) {
97
- const permissionId = permissionIds.get(permission);
98
- if (!permissionId)
99
- continue;
100
- this.sqlite
101
- .prepare("INSERT OR IGNORE INTO auth_role_permissions (id, role_id, permission_id, created_at) VALUES (?, ?, ?, ?)")
102
- .run(nanoid(), roleId, permissionId, now);
103
- }
104
- }
105
- });
106
- tx();
107
- }
108
- /**
109
- * 创建用户。
110
- */
111
- createUser(input) {
112
- const id = nanoid();
113
- const now = nowIso();
114
- const username = normalizeNonEmptyText(input.username, "username");
115
- const passwordHash = normalizeNonEmptyText(input.passwordHash, "passwordHash");
116
- const displayName = optionalTrimmedText(input.displayName);
117
- const status = input.status === "disabled" ? "disabled" : "active";
118
- this.sqlite
119
- .prepare("INSERT INTO auth_users (id, username, password_hash, display_name, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)")
120
- .run(id, username, passwordHash, displayName || null, status, now, now);
121
- return {
122
- id,
123
- username,
124
- passwordHash,
125
- displayName,
126
- status,
127
- createdAt: now,
128
- updatedAt: now,
129
- };
130
- }
131
- /**
132
- * 根据用户名读取用户。
133
- */
134
- findUserByUsername(usernameInput) {
135
- const username = normalizeNonEmptyText(usernameInput, "username");
136
- const row = this.sqlite
137
- .prepare("SELECT * FROM auth_users WHERE username = ?")
138
- .get(username);
139
- return row ? this.toAuthUser(row) : null;
140
- }
141
- /**
142
- * 根据用户 ID 读取用户。
143
- */
144
- getUserById(userIdInput) {
145
- const userId = normalizeNonEmptyText(userIdInput, "userId");
146
- const row = this.sqlite
147
- .prepare("SELECT * FROM auth_users WHERE id = ?")
148
- .get(userId);
149
- return row ? this.toAuthUser(row) : null;
150
- }
151
- /**
152
- * 读取全部用户列表。
153
- */
154
- listUsers() {
155
- const rows = this.sqlite
156
- .prepare("SELECT * FROM auth_users ORDER BY username ASC")
157
- .all();
158
- return rows.map((row) => this.toAuthUser(row));
159
- }
160
- /**
161
- * 更新用户基础资料。
162
- */
163
- updateUser(params) {
164
- const userId = normalizeNonEmptyText(params.userId, "userId");
165
- const current = this.getUserById(userId);
166
- if (!current)
167
- return null;
168
- const nextDisplayName = optionalTrimmedText(params.displayName);
169
- const nextStatus = params.status === "disabled" ? "disabled" : "active";
170
- const updatedAt = nowIso();
171
- this.sqlite
172
- .prepare("UPDATE auth_users SET display_name = ?, status = ?, updated_at = ? WHERE id = ?")
173
- .run(nextDisplayName || null, nextStatus, updatedAt, userId);
174
- return this.getUserById(userId);
175
- }
176
- /**
177
- * 更新用户密码哈希。
178
- */
179
- updateUserPasswordHash(params) {
180
- const userId = normalizeNonEmptyText(params.userId, "userId");
181
- const passwordHash = normalizeNonEmptyText(params.passwordHash, "passwordHash");
182
- const current = this.getUserById(userId);
183
- if (!current)
184
- return null;
185
- const updatedAt = nowIso();
186
- this.sqlite
187
- .prepare("UPDATE auth_users SET password_hash = ?, updated_at = ? WHERE id = ?")
188
- .run(passwordHash, updatedAt, userId);
189
- return this.getUserById(userId);
190
- }
191
- /**
192
- * 给用户绑定角色。
193
- */
194
- assignRoleToUser(params) {
195
- const userId = normalizeNonEmptyText(params.userId, "userId");
196
- const role = this.sqlite
197
- .prepare("SELECT id FROM auth_roles WHERE name = ?")
198
- .get(normalizeNonEmptyText(params.roleName, "roleName"));
199
- if (!role?.id)
200
- throw new Error(`Unknown role: ${params.roleName}`);
201
- this.sqlite
202
- .prepare("INSERT OR IGNORE INTO auth_user_roles (id, user_id, role_id, created_at) VALUES (?, ?, ?, ?)")
203
- .run(nanoid(), userId, String(role.id), nowIso());
204
- }
205
- /**
206
- * 读取用户角色名列表。
207
- */
208
- listRoleNamesByUserId(userIdInput) {
209
- const userId = normalizeNonEmptyText(userIdInput, "userId");
210
- const rows = this.sqlite
211
- .prepare(`
212
- SELECT DISTINCT roles.name as name
213
- FROM auth_roles roles
214
- INNER JOIN auth_user_roles links ON links.role_id = roles.id
215
- WHERE links.user_id = ?
216
- ORDER BY roles.name ASC
217
- `)
218
- .all(userId);
219
- return rows.map((row) => String(row.name || "").trim()).filter(Boolean);
220
- }
221
- /**
222
- * 清空用户当前绑定的全部角色。
223
- */
224
- clearRolesByUserId(userIdInput) {
225
- const userId = normalizeNonEmptyText(userIdInput, "userId");
226
- this.sqlite
227
- .prepare("DELETE FROM auth_user_roles WHERE user_id = ?")
228
- .run(userId);
229
- }
230
- /**
231
- * 用新的角色集合覆盖用户角色绑定。
232
- */
233
- replaceRolesByUserId(params) {
234
- const userId = normalizeNonEmptyText(params.userId, "userId");
235
- const roleNames = [...new Set(params.roleNames.map((item) => String(item || "").trim()).filter(Boolean))];
236
- const tx = this.sqlite.transaction(() => {
237
- this.clearRolesByUserId(userId);
238
- for (const roleName of roleNames) {
239
- this.assignRoleToUser({
240
- userId,
241
- roleName,
242
- });
243
- }
244
- });
245
- tx();
246
- return this.listRoleNamesByUserId(userId);
247
- }
248
- /**
249
- * 统计拥有指定角色且处于 active 状态的用户数量。
250
- */
251
- countActiveUsersByRole(roleNameInput) {
252
- const roleName = normalizeNonEmptyText(roleNameInput, "roleName");
253
- const row = this.sqlite
254
- .prepare(`
255
- SELECT COUNT(DISTINCT users.id) as count
256
- FROM auth_users users
257
- INNER JOIN auth_user_roles user_roles ON user_roles.user_id = users.id
258
- INNER JOIN auth_roles roles ON roles.id = user_roles.role_id
259
- WHERE users.status = 'active' AND roles.name = ?
260
- `)
261
- .get(roleName);
262
- return Number(row?.count || 0);
263
- }
264
- /**
265
- * 读取用户权限 key 列表。
266
- */
267
- listPermissionKeysByUserId(userIdInput) {
268
- const userId = normalizeNonEmptyText(userIdInput, "userId");
269
- const rows = this.sqlite
270
- .prepare(`
271
- SELECT DISTINCT perms.key as key
272
- FROM auth_permissions perms
273
- INNER JOIN auth_role_permissions rp ON rp.permission_id = perms.id
274
- INNER JOIN auth_user_roles ur ON ur.role_id = rp.role_id
275
- WHERE ur.user_id = ?
276
- ORDER BY perms.key ASC
277
- `)
278
- .all(userId);
279
- return rows
280
- .map((row) => String(row.key || "").trim())
281
- .filter(Boolean);
282
- }
283
- /**
284
- * 创建 token 记录。
285
- */
286
- createToken(input) {
287
- const id = nanoid();
288
- const now = nowIso();
289
- const userId = normalizeNonEmptyText(input.userId, "userId");
290
- const name = normalizeNonEmptyText(input.name, "name");
291
- const tokenHash = normalizeNonEmptyText(input.tokenHash, "tokenHash");
292
- const expiresAt = optionalTrimmedText(input.expiresAt);
293
- this.sqlite
294
- .prepare("INSERT INTO auth_tokens (id, user_id, name, token_hash, expires_at, revoked_at, last_used_at, created_at, updated_at) VALUES (?, ?, ?, ?, ?, NULL, NULL, ?, ?)")
295
- .run(id, userId, name, tokenHash, expiresAt || null, now, now);
296
- return {
297
- id,
298
- userId,
299
- name,
300
- tokenHash,
301
- expiresAt,
302
- createdAt: now,
303
- updatedAt: now,
304
- };
305
- }
306
- /**
307
- * 根据 token 哈希读取记录。
308
- */
309
- findTokenByHash(tokenHashInput) {
310
- const tokenHash = normalizeNonEmptyText(tokenHashInput, "tokenHash");
311
- const row = this.sqlite
312
- .prepare("SELECT * FROM auth_tokens WHERE token_hash = ?")
313
- .get(tokenHash);
314
- return row ? this.toAuthToken(row) : null;
315
- }
316
- /**
317
- * 根据 token ID 读取记录。
318
- */
319
- getTokenById(tokenIdInput) {
320
- const tokenId = normalizeNonEmptyText(tokenIdInput, "tokenId");
321
- const row = this.sqlite
322
- .prepare("SELECT * FROM auth_tokens WHERE id = ?")
323
- .get(tokenId);
324
- return row ? this.toAuthToken(row) : null;
325
- }
326
- /**
327
- * 读取用户 token 列表。
328
- */
329
- listTokensByUserId(userIdInput) {
330
- const userId = normalizeNonEmptyText(userIdInput, "userId");
331
- const rows = this.sqlite
332
- .prepare("SELECT * FROM auth_tokens WHERE user_id = ? ORDER BY created_at DESC")
333
- .all(userId);
334
- return rows.map((row) => this.toAuthToken(row));
335
- }
336
- /**
337
- * 更新 token 最后使用时间。
338
- */
339
- touchToken(tokenIdInput) {
340
- const tokenId = normalizeNonEmptyText(tokenIdInput, "tokenId");
341
- const now = nowIso();
342
- this.sqlite
343
- .prepare("UPDATE auth_tokens SET last_used_at = ?, updated_at = ? WHERE id = ?")
344
- .run(now, now, tokenId);
345
- }
346
- /**
347
- * 吊销 token。
348
- */
349
- revokeToken(tokenIdInput) {
350
- const tokenId = normalizeNonEmptyText(tokenIdInput, "tokenId");
351
- const now = nowIso();
352
- this.sqlite
353
- .prepare("UPDATE auth_tokens SET revoked_at = ?, updated_at = ? WHERE id = ?")
354
- .run(now, now, tokenId);
355
- return this.getTokenById(tokenId);
356
- }
357
- /**
358
- * 删除 token。
359
- */
360
- deleteToken(tokenIdInput) {
361
- const tokenId = normalizeNonEmptyText(tokenIdInput, "tokenId");
362
- const result = this.sqlite
363
- .prepare("DELETE FROM auth_tokens WHERE id = ?")
364
- .run(tokenId);
365
- return result.changes > 0;
366
- }
367
- /**
368
- * 写入审计日志。
369
- */
370
- insertAuditLog(input) {
371
- const id = nanoid();
372
- const createdAt = nowIso();
373
- const row = {
374
- id,
375
- actorUserId: optionalTrimmedText(input.actorUserId),
376
- actorTokenId: optionalTrimmedText(input.actorTokenId),
377
- resourceType: normalizeNonEmptyText(input.resourceType, "resourceType"),
378
- resourceId: optionalTrimmedText(input.resourceId),
379
- action: normalizeNonEmptyText(input.action, "action"),
380
- result: normalizeNonEmptyText(input.result, "result"),
381
- requestId: optionalTrimmedText(input.requestId),
382
- ip: optionalTrimmedText(input.ip),
383
- userAgent: optionalTrimmedText(input.userAgent),
384
- metaJson: optionalTrimmedText(input.metaJson),
385
- createdAt,
386
- };
387
- this.sqlite
388
- .prepare("INSERT INTO auth_audit_logs (id, actor_user_id, actor_token_id, resource_type, resource_id, action, result, request_id, ip, user_agent, meta_json, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
389
- .run(row.id, row.actorUserId || null, row.actorTokenId || null, row.resourceType, row.resourceId || null, row.action, row.result, row.requestId || null, row.ip || null, row.userAgent || null, row.metaJson || null, row.createdAt);
390
- return row;
391
- }
392
- /**
393
- * 将 token 记录转换为对外摘要。
394
- */
395
- toTokenSummary(record) {
396
- return {
397
- id: record.id,
398
- name: record.name,
399
- expiresAt: record.expiresAt,
400
- lastUsedAt: record.lastUsedAt,
401
- createdAt: record.createdAt,
402
- updatedAt: record.updatedAt,
403
- };
404
- }
405
- /**
406
- * 将 token 记录与明文 token 合成为一次性返回体。
407
- */
408
- toIssuedToken(record, token) {
409
- return {
410
- ...this.toTokenSummary(record),
411
- token,
412
- };
413
- }
414
- toAuthUser(row) {
415
- return {
416
- id: String(row.id || ""),
417
- username: String(row.username || ""),
418
- passwordHash: String(row.password_hash || ""),
419
- displayName: optionalTrimmedText(String(row.display_name || "")),
420
- status: String(row.status || "active") === "disabled" ? "disabled" : "active",
421
- createdAt: String(row.created_at || ""),
422
- updatedAt: String(row.updated_at || ""),
423
- };
424
- }
425
- toAuthToken(row) {
426
- return {
427
- id: String(row.id || ""),
428
- userId: String(row.user_id || ""),
429
- name: String(row.name || ""),
430
- tokenHash: String(row.token_hash || ""),
431
- expiresAt: optionalTrimmedText(String(row.expires_at || "")),
432
- revokedAt: optionalTrimmedText(String(row.revoked_at || "")),
433
- lastUsedAt: optionalTrimmedText(String(row.last_used_at || "")),
434
- createdAt: String(row.created_at || ""),
435
- updatedAt: String(row.updated_at || ""),
436
- };
437
- }
438
- _unused(_row) {
439
- throw new Error("unused");
440
- }
441
- }
442
- //# sourceMappingURL=AuthStore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthStore.js","sourceRoot":"","sources":["../../../src/http/auth/AuthStore.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,oBAAoB,GAGrB,MAAM,uCAAu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2
- * 统一账户路由策略与全局守卫。
3
- *
4
- * 关键点(中文)
5
- * - 这里负责把“哪些接口需要登录、需要什么权限”集中配置。
6
- * - 当系统还没有任何统一账户用户时,受保护接口默认放行,避免首次 bootstrap 被锁死。
7
- */
8
- import type { MiddlewareHandler } from "hono";
9
- import type { AuthRoutePolicy } from "../../shared/types/auth/AuthRoute.js";
10
- import type { AuthService } from "./AuthService.js";
11
- import { type AuthMiddlewareVariables } from "./AuthMiddleware.js";
12
- /**
13
- * Server 侧路由权限矩阵。
14
- */
15
- export declare const SERVER_AUTH_ROUTE_POLICIES: AuthRoutePolicy[];
16
- /**
17
- * 控制面网关侧路由权限矩阵。
18
- */
19
- export declare const CONTROL_PLANE_AUTH_ROUTE_POLICIES: AuthRoutePolicy[];
20
- /**
21
- * 根据路径与方法解析匹配的策略。
22
- */
23
- export declare function resolveAuthRoutePolicy(path: string, method: string, policies: AuthRoutePolicy[]): AuthRoutePolicy | null;
24
- /**
25
- * 创建全局路由鉴权中间件。
26
- */
27
- export declare function createRouteAuthGuardMiddleware(authService: AuthService, policies?: AuthRoutePolicy[]): MiddlewareHandler<{
28
- Variables: AuthMiddlewareVariables;
29
- }>;
30
- //# sourceMappingURL=RoutePolicy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RoutePolicy.d.ts","sourceRoot":"","sources":["../../../src/http/auth/RoutePolicy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAA8B,KAAK,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE/F;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,eAAe,EAoEvD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,EAAE,eAAe,EA8D9D,CAAC;AAEF;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,eAAe,EAAE,GAC1B,eAAe,GAAG,IAAI,CASxB;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,WAAW,EACxB,QAAQ,GAAE,eAAe,EAA+B,GACvD,iBAAiB,CAAC;IAAE,SAAS,EAAE,uBAAuB,CAAA;CAAE,CAAC,CA4B3D"}