@downcity/agent 1.1.7 → 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 (274) 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 +1 -0
  38. package/bin/host/sdk/Agent.d.ts.map +1 -1
  39. package/bin/host/sdk/Agent.js +24 -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/http/Server.d.ts.map +1 -1
  44. package/bin/http/Server.js +1 -11
  45. package/bin/http/Server.js.map +1 -1
  46. package/bin/http/auth/AuthEnv.d.ts +0 -9
  47. package/bin/http/auth/AuthEnv.d.ts.map +1 -1
  48. package/bin/http/auth/AuthEnv.js +0 -9
  49. package/bin/http/auth/AuthEnv.js.map +1 -1
  50. package/bin/http/auth/CliAuthStateStore.d.ts +0 -4
  51. package/bin/http/auth/CliAuthStateStore.d.ts.map +1 -1
  52. package/bin/http/auth/CliAuthStateStore.js +0 -4
  53. package/bin/http/auth/CliAuthStateStore.js.map +1 -1
  54. package/bin/http/control/ModelRoutes.d.ts.map +1 -1
  55. package/bin/http/control/ModelRoutes.js +3 -8
  56. package/bin/http/control/ModelRoutes.js.map +1 -1
  57. package/bin/index.d.ts +2 -6
  58. package/bin/index.d.ts.map +1 -1
  59. package/bin/index.js +2 -6
  60. package/bin/index.js.map +1 -1
  61. package/bin/model/CreateModel.d.ts +2 -2
  62. package/bin/model/CreateModel.d.ts.map +1 -1
  63. package/bin/model/CreateModel.js +13 -12
  64. package/bin/model/CreateModel.js.map +1 -1
  65. package/bin/plugin/Activation.d.ts +4 -0
  66. package/bin/plugin/Activation.d.ts.map +1 -1
  67. package/bin/plugin/Activation.js +2 -2
  68. package/bin/plugin/Activation.js.map +1 -1
  69. package/bin/plugin/LocalExecution.d.ts.map +1 -1
  70. package/bin/plugin/LocalExecution.js +23 -2
  71. package/bin/plugin/LocalExecution.js.map +1 -1
  72. package/bin/plugin/PluginRegistry.js +2 -2
  73. package/bin/plugin/PluginRegistry.js.map +1 -1
  74. package/bin/plugins/asr/Plugin.d.ts.map +1 -1
  75. package/bin/plugins/asr/Plugin.js +4 -5
  76. package/bin/plugins/asr/Plugin.js.map +1 -1
  77. package/bin/plugins/auth/Plugin.d.ts.map +1 -1
  78. package/bin/plugins/auth/Plugin.js +1 -0
  79. package/bin/plugins/auth/Plugin.js.map +1 -1
  80. package/bin/plugins/auth/runtime/AuthorizationConfig.d.ts +4 -4
  81. package/bin/plugins/auth/runtime/AuthorizationConfig.d.ts.map +1 -1
  82. package/bin/plugins/auth/runtime/AuthorizationConfig.js +28 -26
  83. package/bin/plugins/auth/runtime/AuthorizationConfig.js.map +1 -1
  84. package/bin/plugins/auth/runtime/AuthorizationPolicy.d.ts +2 -0
  85. package/bin/plugins/auth/runtime/AuthorizationPolicy.d.ts.map +1 -1
  86. package/bin/plugins/auth/runtime/AuthorizationPolicy.js +3 -2
  87. package/bin/plugins/auth/runtime/AuthorizationPolicy.js.map +1 -1
  88. package/bin/plugins/auth/runtime/AuthorizationStore.d.ts +1 -1
  89. package/bin/plugins/auth/runtime/AuthorizationStore.d.ts.map +1 -1
  90. package/bin/plugins/auth/runtime/AuthorizationStore.js +3 -4
  91. package/bin/plugins/auth/runtime/AuthorizationStore.js.map +1 -1
  92. package/bin/plugins/skill/Plugin.js +2 -2
  93. package/bin/plugins/skill/Plugin.js.map +1 -1
  94. package/bin/plugins/tts/Plugin.d.ts.map +1 -1
  95. package/bin/plugins/tts/Plugin.js +4 -5
  96. package/bin/plugins/tts/Plugin.js.map +1 -1
  97. package/bin/plugins/web/Plugin.d.ts.map +1 -1
  98. package/bin/plugins/web/Plugin.js +4 -5
  99. package/bin/plugins/web/Plugin.js.map +1 -1
  100. package/bin/plugins/workboard/Plugin.js +2 -2
  101. package/bin/plugins/workboard/Plugin.js.map +1 -1
  102. package/bin/service/builtins/chat/accounts/ChannelAccountService.d.ts +4 -1
  103. package/bin/service/builtins/chat/accounts/ChannelAccountService.d.ts.map +1 -1
  104. package/bin/service/builtins/chat/accounts/ChannelAccountService.js +64 -91
  105. package/bin/service/builtins/chat/accounts/ChannelAccountService.js.map +1 -1
  106. package/bin/service/builtins/chat/runtime/ChatChannelActions.d.ts.map +1 -1
  107. package/bin/service/builtins/chat/runtime/ChatChannelActions.js +11 -18
  108. package/bin/service/builtins/chat/runtime/ChatChannelActions.js.map +1 -1
  109. package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts +1 -1
  110. package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts.map +1 -1
  111. package/bin/service/builtins/chat/runtime/ChatChannelCore.js +9 -17
  112. package/bin/service/builtins/chat/runtime/ChatChannelCore.js.map +1 -1
  113. package/bin/service/builtins/memory/Action.d.ts +1 -5
  114. package/bin/service/builtins/memory/Action.d.ts.map +1 -1
  115. package/bin/service/builtins/memory/Action.js +4 -42
  116. package/bin/service/builtins/memory/Action.js.map +1 -1
  117. package/bin/service/builtins/memory/MemoryService.d.ts.map +1 -1
  118. package/bin/service/builtins/memory/MemoryService.js +2 -32
  119. package/bin/service/builtins/memory/MemoryService.js.map +1 -1
  120. package/bin/service/builtins/memory/runtime/Search.d.ts +7 -3
  121. package/bin/service/builtins/memory/runtime/Search.d.ts.map +1 -1
  122. package/bin/service/builtins/memory/runtime/Search.js +220 -16
  123. package/bin/service/builtins/memory/runtime/Search.js.map +1 -1
  124. package/bin/service/builtins/memory/runtime/Store.d.ts +9 -50
  125. package/bin/service/builtins/memory/runtime/Store.d.ts.map +1 -1
  126. package/bin/service/builtins/memory/runtime/Store.js +10 -130
  127. package/bin/service/builtins/memory/runtime/Store.js.map +1 -1
  128. package/bin/service/builtins/memory/runtime/Writer.d.ts.map +1 -1
  129. package/bin/service/builtins/memory/runtime/Writer.js +1 -2
  130. package/bin/service/builtins/memory/runtime/Writer.js.map +1 -1
  131. package/bin/service/builtins/memory/types/Memory.d.ts +3 -57
  132. package/bin/service/builtins/memory/types/Memory.d.ts.map +1 -1
  133. package/bin/service/schedule/Store.d.ts +22 -25
  134. package/bin/service/schedule/Store.d.ts.map +1 -1
  135. package/bin/service/schedule/Store.js +172 -154
  136. package/bin/service/schedule/Store.js.map +1 -1
  137. package/bin/session/composer/system/default/SystemDomain.d.ts.map +1 -1
  138. package/bin/session/composer/system/default/SystemDomain.js +1 -0
  139. package/bin/session/composer/system/default/SystemDomain.js.map +1 -1
  140. package/bin/shared/types/AgentHost.d.ts +120 -4
  141. package/bin/shared/types/AgentHost.d.ts.map +1 -1
  142. package/bin/shared/types/Plugin.d.ts +5 -1
  143. package/bin/shared/types/Plugin.d.ts.map +1 -1
  144. package/package.json +1 -4
  145. package/src/agent/AgentContext.ts +1 -0
  146. package/src/agent/AgentContextTypes.ts +5 -0
  147. package/src/agent/AgentRuntime.ts +32 -3
  148. package/src/agent/AgentRuntimeState.ts +66 -2
  149. package/src/agent/AgentRuntimeTypes.ts +5 -0
  150. package/src/agent/project/AgentInitializer.ts +40 -42
  151. package/src/config/Config.ts +2 -17
  152. package/src/config/Paths.ts +2 -9
  153. package/src/host/daemon/ProjectSetup.ts +19 -21
  154. package/src/host/runtime/AgentHostRuntime.ts +0 -2
  155. package/src/host/runtime/CityPaths.ts +0 -3
  156. package/src/host/sdk/Agent.ts +26 -2
  157. package/src/host/sdk/AgentSdkTypes.ts +10 -0
  158. package/src/http/Server.ts +0 -13
  159. package/src/http/auth/AuthEnv.ts +0 -9
  160. package/src/http/auth/CliAuthStateStore.ts +0 -4
  161. package/src/http/control/ModelRoutes.ts +3 -9
  162. package/src/index.ts +2 -12
  163. package/src/model/CreateModel.ts +15 -13
  164. package/src/plugin/Activation.ts +6 -2
  165. package/src/plugin/LocalExecution.ts +24 -2
  166. package/src/plugin/PluginRegistry.ts +2 -2
  167. package/src/plugins/asr/Plugin.ts +4 -5
  168. package/src/plugins/auth/Plugin.ts +1 -0
  169. package/src/plugins/auth/runtime/AuthorizationConfig.ts +47 -37
  170. package/src/plugins/auth/runtime/AuthorizationPolicy.ts +5 -2
  171. package/src/plugins/auth/runtime/AuthorizationStore.ts +6 -5
  172. package/src/plugins/skill/Plugin.ts +2 -2
  173. package/src/plugins/tts/Plugin.ts +4 -5
  174. package/src/plugins/web/Plugin.ts +4 -5
  175. package/src/plugins/workboard/Plugin.ts +2 -2
  176. package/src/service/builtins/chat/accounts/ChannelAccountService.ts +42 -62
  177. package/src/service/builtins/chat/runtime/ChatChannelActions.ts +12 -18
  178. package/src/service/builtins/chat/runtime/ChatChannelCore.ts +9 -14
  179. package/src/service/builtins/memory/Action.ts +6 -47
  180. package/src/service/builtins/memory/MemoryService.ts +1 -33
  181. package/src/service/builtins/memory/runtime/Search.ts +256 -16
  182. package/src/service/builtins/memory/runtime/Store.ts +13 -185
  183. package/src/service/builtins/memory/runtime/Writer.ts +1 -2
  184. package/src/service/builtins/memory/types/Memory.ts +2 -59
  185. package/src/service/schedule/Store.ts +215 -175
  186. package/src/session/composer/system/default/SystemDomain.ts +1 -0
  187. package/src/shared/types/AgentHost.ts +138 -4
  188. package/src/shared/types/Plugin.ts +5 -0
  189. package/tsconfig.tsbuildinfo +1 -1
  190. package/bin/http/auth/AuthMiddleware.d.ts +0 -36
  191. package/bin/http/auth/AuthMiddleware.d.ts.map +0 -1
  192. package/bin/http/auth/AuthMiddleware.js +0 -37
  193. package/bin/http/auth/AuthMiddleware.js.map +0 -1
  194. package/bin/http/auth/AuthRoutes.d.ts +0 -17
  195. package/bin/http/auth/AuthRoutes.d.ts.map +0 -1
  196. package/bin/http/auth/AuthRoutes.js +0 -78
  197. package/bin/http/auth/AuthRoutes.js.map +0 -1
  198. package/bin/http/auth/AuthService.d.ts +0 -119
  199. package/bin/http/auth/AuthService.d.ts.map +0 -1
  200. package/bin/http/auth/AuthService.js +0 -307
  201. package/bin/http/auth/AuthService.js.map +0 -1
  202. package/bin/http/auth/AuthStore.d.ts +0 -165
  203. package/bin/http/auth/AuthStore.d.ts.map +0 -1
  204. package/bin/http/auth/AuthStore.js +0 -442
  205. package/bin/http/auth/AuthStore.js.map +0 -1
  206. package/bin/http/auth/RoutePolicy.d.ts +0 -30
  207. package/bin/http/auth/RoutePolicy.d.ts.map +0 -1
  208. package/bin/http/auth/RoutePolicy.js +0 -229
  209. package/bin/http/auth/RoutePolicy.js.map +0 -1
  210. package/bin/plugin/Lifecycle.d.ts +0 -33
  211. package/bin/plugin/Lifecycle.d.ts.map +0 -1
  212. package/bin/plugin/Lifecycle.js +0 -102
  213. package/bin/plugin/Lifecycle.js.map +0 -1
  214. package/bin/service/builtins/memory/runtime/Indexer.d.ts +0 -71
  215. package/bin/service/builtins/memory/runtime/Indexer.d.ts.map +0 -1
  216. package/bin/service/builtins/memory/runtime/Indexer.js +0 -345
  217. package/bin/service/builtins/memory/runtime/Indexer.js.map +0 -1
  218. package/bin/service/schedule/Schema.d.ts +0 -171
  219. package/bin/service/schedule/Schema.d.ts.map +0 -1
  220. package/bin/service/schedule/Schema.js +0 -26
  221. package/bin/service/schedule/Schema.js.map +0 -1
  222. package/bin/shared/utils/store/StoreChannelAccountRepository.d.ts +0 -34
  223. package/bin/shared/utils/store/StoreChannelAccountRepository.d.ts.map +0 -1
  224. package/bin/shared/utils/store/StoreChannelAccountRepository.js +0 -198
  225. package/bin/shared/utils/store/StoreChannelAccountRepository.js.map +0 -1
  226. package/bin/shared/utils/store/StoreEnvRepository.d.ts +0 -98
  227. package/bin/shared/utils/store/StoreEnvRepository.d.ts.map +0 -1
  228. package/bin/shared/utils/store/StoreEnvRepository.js +0 -334
  229. package/bin/shared/utils/store/StoreEnvRepository.js.map +0 -1
  230. package/bin/shared/utils/store/StoreModelRepository.d.ts +0 -61
  231. package/bin/shared/utils/store/StoreModelRepository.d.ts.map +0 -1
  232. package/bin/shared/utils/store/StoreModelRepository.js +0 -278
  233. package/bin/shared/utils/store/StoreModelRepository.js.map +0 -1
  234. package/bin/shared/utils/store/StoreSchema.d.ts +0 -13
  235. package/bin/shared/utils/store/StoreSchema.d.ts.map +0 -1
  236. package/bin/shared/utils/store/StoreSchema.js +0 -319
  237. package/bin/shared/utils/store/StoreSchema.js.map +0 -1
  238. package/bin/shared/utils/store/StoreSecureSettings.d.ts +0 -33
  239. package/bin/shared/utils/store/StoreSecureSettings.d.ts.map +0 -1
  240. package/bin/shared/utils/store/StoreSecureSettings.js +0 -91
  241. package/bin/shared/utils/store/StoreSecureSettings.js.map +0 -1
  242. package/bin/shared/utils/store/StoreShared.d.ts +0 -44
  243. package/bin/shared/utils/store/StoreShared.d.ts.map +0 -1
  244. package/bin/shared/utils/store/StoreShared.js +0 -40
  245. package/bin/shared/utils/store/StoreShared.js.map +0 -1
  246. package/bin/shared/utils/store/crypto.d.ts +0 -24
  247. package/bin/shared/utils/store/crypto.d.ts.map +0 -1
  248. package/bin/shared/utils/store/crypto.js +0 -101
  249. package/bin/shared/utils/store/crypto.js.map +0 -1
  250. package/bin/shared/utils/store/index.d.ts +0 -230
  251. package/bin/shared/utils/store/index.d.ts.map +0 -1
  252. package/bin/shared/utils/store/index.js +0 -360
  253. package/bin/shared/utils/store/index.js.map +0 -1
  254. package/bin/shared/utils/store/schema.d.ts +0 -690
  255. package/bin/shared/utils/store/schema.d.ts.map +0 -1
  256. package/bin/shared/utils/store/schema.js +0 -81
  257. package/bin/shared/utils/store/schema.js.map +0 -1
  258. package/src/http/auth/AuthMiddleware.ts +0 -61
  259. package/src/http/auth/AuthRoutes.ts +0 -100
  260. package/src/http/auth/AuthService.ts +0 -367
  261. package/src/http/auth/AuthStore.ts +0 -572
  262. package/src/http/auth/RoutePolicy.ts +0 -255
  263. package/src/plugin/Lifecycle.ts +0 -116
  264. package/src/service/builtins/memory/runtime/Indexer.ts +0 -466
  265. package/src/service/schedule/Schema.ts +0 -34
  266. package/src/shared/utils/store/StoreChannelAccountRepository.ts +0 -269
  267. package/src/shared/utils/store/StoreEnvRepository.ts +0 -452
  268. package/src/shared/utils/store/StoreModelRepository.ts +0 -324
  269. package/src/shared/utils/store/StoreSchema.ts +0 -344
  270. package/src/shared/utils/store/StoreSecureSettings.ts +0 -126
  271. package/src/shared/utils/store/StoreShared.ts +0 -67
  272. package/src/shared/utils/store/crypto.ts +0 -112
  273. package/src/shared/utils/store/index.ts +0 -497
  274. package/src/shared/utils/store/schema.ts +0 -103
@@ -1,229 +0,0 @@
1
- /**
2
- * 统一账户路由策略与全局守卫。
3
- *
4
- * 关键点(中文)
5
- * - 这里负责把“哪些接口需要登录、需要什么权限”集中配置。
6
- * - 当系统还没有任何统一账户用户时,受保护接口默认放行,避免首次 bootstrap 被锁死。
7
- */
8
- import { isAuthError as isAuthDomainError } from "./AuthError.js";
9
- import { AUTH_PRINCIPAL_CONTEXT_KEY } from "./AuthMiddleware.js";
10
- /**
11
- * Server 侧路由权限矩阵。
12
- */
13
- export const SERVER_AUTH_ROUTE_POLICIES = [
14
- { path: "/api/auth/*", method: "*", requireAuth: false },
15
- { path: "/health", method: "GET", requireAuth: false },
16
- {
17
- path: "/api/execute",
18
- method: "POST",
19
- requireAuth: true,
20
- anyPermissions: ["agent.execute"],
21
- },
22
- {
23
- path: "/api/services/list",
24
- method: "GET",
25
- requireAuth: true,
26
- anyPermissions: ["service.read"],
27
- },
28
- {
29
- path: "/api/services/control",
30
- method: "POST",
31
- requireAuth: true,
32
- anyPermissions: ["service.write"],
33
- },
34
- {
35
- path: "/api/services/command",
36
- method: "POST",
37
- requireAuth: true,
38
- anyPermissions: ["service.write"],
39
- },
40
- {
41
- path: "/api/plugins/list",
42
- method: "GET",
43
- requireAuth: true,
44
- anyPermissions: ["plugin.read"],
45
- },
46
- {
47
- path: "/api/plugins/availability",
48
- method: "POST",
49
- requireAuth: true,
50
- anyPermissions: ["plugin.read"],
51
- },
52
- {
53
- path: "/api/plugins/action",
54
- method: "POST",
55
- requireAuth: true,
56
- anyPermissions: ["plugin.write"],
57
- },
58
- {
59
- path: "/api/control/authorization",
60
- method: "GET",
61
- requireAuth: true,
62
- anyPermissions: ["auth.read"],
63
- },
64
- {
65
- path: "/api/control/authorization/config",
66
- method: "POST",
67
- requireAuth: true,
68
- anyPermissions: ["auth.write"],
69
- },
70
- {
71
- path: "/api/control/authorization/action",
72
- method: "POST",
73
- requireAuth: true,
74
- anyPermissions: ["auth.write"],
75
- },
76
- {
77
- path: "/api/control/*",
78
- method: "*",
79
- requireAuth: true,
80
- },
81
- ];
82
- /**
83
- * 控制面网关侧路由权限矩阵。
84
- */
85
- export const CONTROL_PLANE_AUTH_ROUTE_POLICIES = [
86
- { path: "/api/auth/*", method: "*", requireAuth: false },
87
- { path: "/health", method: "GET", requireAuth: false },
88
- {
89
- path: "/api/ui/agents",
90
- method: "GET",
91
- requireAuth: true,
92
- anyPermissions: ["agent.read"],
93
- },
94
- {
95
- path: "/api/ui/agents/create",
96
- method: "POST",
97
- requireAuth: true,
98
- anyPermissions: ["agent.write"],
99
- },
100
- {
101
- path: "/api/ui/agents/start",
102
- method: "POST",
103
- requireAuth: true,
104
- anyPermissions: ["agent.write"],
105
- },
106
- {
107
- path: "/api/ui/agents/restart",
108
- method: "POST",
109
- requireAuth: true,
110
- anyPermissions: ["agent.write"],
111
- },
112
- {
113
- path: "/api/ui/agents/stop",
114
- method: "POST",
115
- requireAuth: true,
116
- anyPermissions: ["agent.write"],
117
- },
118
- {
119
- path: "/api/ui/model*",
120
- method: "*",
121
- requireAuth: true,
122
- anyPermissions: ["model.read"],
123
- },
124
- {
125
- path: "/api/ui/env*",
126
- method: "*",
127
- requireAuth: true,
128
- anyPermissions: ["env.read"],
129
- },
130
- {
131
- path: "/api/ui/channel*",
132
- method: "*",
133
- requireAuth: true,
134
- anyPermissions: ["channel.read"],
135
- },
136
- {
137
- path: "/api/ui/plugins*",
138
- method: "*",
139
- requireAuth: true,
140
- anyPermissions: ["plugin.read"],
141
- },
142
- {
143
- path: "/api/ui/*",
144
- method: "*",
145
- requireAuth: true,
146
- },
147
- ];
148
- /**
149
- * 根据路径与方法解析匹配的策略。
150
- */
151
- export function resolveAuthRoutePolicy(path, method, policies) {
152
- const normalizedPath = String(path || "").trim() || "/";
153
- const normalizedMethod = String(method || "GET").trim().toUpperCase();
154
- for (const policy of policies) {
155
- if (!matchesMethod(policy.method, normalizedMethod))
156
- continue;
157
- if (!matchesPath(policy.path, normalizedPath))
158
- continue;
159
- return policy;
160
- }
161
- return null;
162
- }
163
- /**
164
- * 创建全局路由鉴权中间件。
165
- */
166
- export function createRouteAuthGuardMiddleware(authService, policies = SERVER_AUTH_ROUTE_POLICIES) {
167
- return async (c, next) => {
168
- const policy = resolveAuthRoutePolicy(c.req.path, c.req.method, policies);
169
- if (!policy || policy.requireAuth !== true) {
170
- await next();
171
- return;
172
- }
173
- if (!authService.hasLocalCliAccess()) {
174
- await next();
175
- return;
176
- }
177
- try {
178
- const principal = authService.authenticateBearerHeader(c.req.header("authorization"));
179
- ensurePermissions(principal.permissions, policy.anyPermissions);
180
- c.set(AUTH_PRINCIPAL_CONTEXT_KEY, principal);
181
- await next();
182
- }
183
- catch (error) {
184
- if (isRouteGuardError(error)) {
185
- return c.json({ success: false, error: error.message }, error.status);
186
- }
187
- return c.json({ success: false, error: String(error) }, 500);
188
- }
189
- };
190
- }
191
- function matchesMethod(expectedMethod, actualMethod) {
192
- const expected = String(expectedMethod || "*").trim().toUpperCase();
193
- return expected === "*" || expected === actualMethod;
194
- }
195
- function matchesPath(patternInput, actualPath) {
196
- const pattern = String(patternInput || "").trim();
197
- if (!pattern)
198
- return false;
199
- if (pattern.endsWith("*")) {
200
- const prefix = pattern.slice(0, -1);
201
- return actualPath.startsWith(prefix);
202
- }
203
- return actualPath === pattern;
204
- }
205
- function ensurePermissions(userPermissions, anyPermissions) {
206
- if (!anyPermissions || anyPermissions.length === 0)
207
- return;
208
- if (anyPermissions.some((permission) => userPermissions.includes(permission)))
209
- return;
210
- throw new ErrorWithStatus("Permission denied", 403);
211
- }
212
- class ErrorWithStatus extends Error {
213
- status;
214
- constructor(message, status) {
215
- super(message);
216
- this.name = "AuthPermissionError";
217
- this.status = status;
218
- }
219
- }
220
- function isAuthErrorLike(error) {
221
- return (typeof error === "object" &&
222
- error !== null &&
223
- "status" in error &&
224
- typeof error.status === "number");
225
- }
226
- function isRouteGuardError(error) {
227
- return isAuthDomainError(error) || isAuthErrorLike(error);
228
- }
229
- //# sourceMappingURL=RoutePolicy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RoutePolicy.js","sourceRoot":"","sources":["../../../src/http/auth/RoutePolicy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAE,0BAA0B,EAAgC,MAAM,qBAAqB,CAAC;AAE/F;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAsB;IAC3D,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE;IACxD,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE;IACtD;QACE,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,MAAM;QACd,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,CAAC,eAAe,CAAC;KAClC;IACD;QACE,IAAI,EAAE,oBAAoB;QAC1B,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,CAAC,cAAc,CAAC;KACjC;IACD;QACE,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,MAAM;QACd,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,CAAC,eAAe,CAAC;KAClC;IACD;QACE,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,MAAM;QACd,WAAW,EAAE,IAAI;QACjB,cAAc,EAAE,CAAC,eAAe,CAAC;KAClC;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,MAAM,EAAE,K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AM,CAAS;IAExB,YAAY,OAAe,EAAE,MAAc;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,QAAQ,IAAI,KAAK;QACjB,OAAQ,KAA8B,CAAC,MAAM,KAAK,QAAQ,CAC3D,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,iBAAiB,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Plugin 生命周期配置模块。
3
- *
4
- * 关键点(中文)
5
- * - Plugin enable/disable 属于 city 级全局配置,不再写入 agent `downcity.json`。
6
- * - 当前实现把 lifecycle 配置存入 PlatformStore 的统一 JSON 设置。
7
- * - 默认策略:除显式关闭外,内建 plugin 视为启用。
8
- */
9
- import type { CityPluginLifecycleConfig, CityPluginLifecycleItem } from "../shared/types/PluginLifecycle.js";
10
- /**
11
- * 读取当前 city 级 plugin lifecycle 配置。
12
- */
13
- export declare function readCityPluginLifecycleConfig(): CityPluginLifecycleConfig;
14
- /**
15
- * 写入完整 city 级 plugin lifecycle 配置。
16
- */
17
- export declare function writeCityPluginLifecycleConfig(value: CityPluginLifecycleConfig): CityPluginLifecycleConfig;
18
- /**
19
- * 读取单个 plugin 的 city 级 lifecycle 状态。
20
- */
21
- export declare function readCityPluginLifecycleItem(pluginName: string): CityPluginLifecycleItem | null;
22
- /**
23
- * 读取单个 plugin 是否启用。
24
- *
25
- * 关键点(中文)
26
- * - 除显式关闭外,一律默认启用。
27
- */
28
- export declare function isCityPluginEnabled(pluginName: string): boolean;
29
- /**
30
- * 设置单个 plugin 的 city 级启用态。
31
- */
32
- export declare function setCityPluginEnabled(pluginName: string, enabled: boolean): CityPluginLifecycleConfig;
33
- //# sourceMappingURL=Lifecycle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Lifecycle.d.ts","sourceRoot":"","sources":["../../src/plugin/Lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,mCAAmC,CAAC;AA4B3C;;GAEG;AACH,wBAAgB,6BAA6B,IAAI,yBAAyB,CAWzE;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,yBAAyB,GAC/B,yBAAyB,CAS3B;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,GACjB,uBAAuB,GAAG,IAAI,CAIhC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAI/D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,GACf,yBAAyB,CAa3B"}
@@ -1,102 +0,0 @@
1
- /**
2
- * Plugin 生命周期配置模块。
3
- *
4
- * 关键点(中文)
5
- * - Plugin enable/disable 属于 city 级全局配置,不再写入 agent `downcity.json`。
6
- * - 当前实现把 lifecycle 配置存入 PlatformStore 的统一 JSON 设置。
7
- * - 默认策略:除显式关闭外,内建 plugin 视为启用。
8
- */
9
- import { PlatformStore } from "../shared/utils/store/index.js";
10
- const PLUGIN_LIFECYCLE_SETTING_KEY = "plugins.lifecycle";
11
- function normalizeLifecycleItem(input) {
12
- if (!input || typeof input !== "object" || Array.isArray(input))
13
- return null;
14
- const record = input;
15
- if (typeof record.enabled !== "boolean")
16
- return null;
17
- const updatedAt = String(record.updatedAt || "").trim() || new Date().toISOString();
18
- return {
19
- enabled: record.enabled,
20
- updatedAt,
21
- };
22
- }
23
- function normalizeLifecycleConfig(input) {
24
- if (!input || typeof input !== "object" || Array.isArray(input))
25
- return {};
26
- const out = {};
27
- for (const [pluginName, raw] of Object.entries(input)) {
28
- const key = String(pluginName || "").trim();
29
- if (!key)
30
- continue;
31
- const item = normalizeLifecycleItem(raw);
32
- if (!item)
33
- continue;
34
- out[key] = item;
35
- }
36
- return out;
37
- }
38
- /**
39
- * 读取当前 city 级 plugin lifecycle 配置。
40
- */
41
- export function readCityPluginLifecycleConfig() {
42
- const store = new PlatformStore();
43
- try {
44
- return normalizeLifecycleConfig(store.getSecureSettingJsonSync(PLUGIN_LIFECYCLE_SETTING_KEY));
45
- }
46
- finally {
47
- store.close();
48
- }
49
- }
50
- /**
51
- * 写入完整 city 级 plugin lifecycle 配置。
52
- */
53
- export function writeCityPluginLifecycleConfig(value) {
54
- const normalized = normalizeLifecycleConfig(value);
55
- const store = new PlatformStore();
56
- try {
57
- store.setSecureSettingJsonSync(PLUGIN_LIFECYCLE_SETTING_KEY, normalized);
58
- return normalized;
59
- }
60
- finally {
61
- store.close();
62
- }
63
- }
64
- /**
65
- * 读取单个 plugin 的 city 级 lifecycle 状态。
66
- */
67
- export function readCityPluginLifecycleItem(pluginName) {
68
- const key = String(pluginName || "").trim();
69
- if (!key)
70
- return null;
71
- return readCityPluginLifecycleConfig()[key] || null;
72
- }
73
- /**
74
- * 读取单个 plugin 是否启用。
75
- *
76
- * 关键点(中文)
77
- * - 除显式关闭外,一律默认启用。
78
- */
79
- export function isCityPluginEnabled(pluginName) {
80
- const item = readCityPluginLifecycleItem(pluginName);
81
- if (!item)
82
- return true;
83
- return item.enabled === true;
84
- }
85
- /**
86
- * 设置单个 plugin 的 city 级启用态。
87
- */
88
- export function setCityPluginEnabled(pluginName, enabled) {
89
- const key = String(pluginName || "").trim();
90
- if (!key) {
91
- throw new Error("pluginName is required");
92
- }
93
- const current = readCityPluginLifecycleConfig();
94
- return writeCityPluginLifecycleConfig({
95
- ...current,
96
- [key]: {
97
- enabled,
98
- updatedAt: new Date().toISOString(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UAAU,oBAAoB,CAClC,UAAkB,EAClB,OAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IACD,MAAM,OAAO,GAAG,6BAA6B,EAAE,CAAC;IAChD,OAAO,8BAA8B,CAAC;QACpC,GAAG,OAAO;QACV,CAAC,GAAG,CAAC,EAAE;YACL,OAAO;YACP,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1,71 +0,0 @@
1
- /**
2
- * Memory Indexer(SQLite FTS)。
3
- *
4
- * 关键点(中文)
5
- * - 使用 SQLite + FTS5 做本地检索加速。
6
- * - Markdown 仍是事实源,索引可重建。
7
- */
8
- import type { MemorySearchResultItem, MemorySourceStat } from "../../../../service/builtins/memory/types/Memory.js";
9
- import type { MemorySourceFile } from "./Store.js";
10
- export type MemoryIndexSyncResult = {
11
- /**
12
- * 扫描文件总数。
13
- */
14
- totalFiles: number;
15
- /**
16
- * 重建文件数。
17
- */
18
- reindexedFiles: number;
19
- /**
20
- * 删除失效文件数。
21
- */
22
- removedFiles: number;
23
- /**
24
- * 重建写入 chunk 总数。
25
- */
26
- totalChunks: number;
27
- };
28
- export type MemoryIndexStatus = {
29
- /**
30
- * 当前文件数。
31
- */
32
- files: number;
33
- /**
34
- * 当前 chunk 数。
35
- */
36
- chunks: number;
37
- /**
38
- * 按来源统计。
39
- */
40
- sourceCounts: MemorySourceStat[];
41
- };
42
- /**
43
- * 构建 FTS 查询表达式。
44
- */
45
- export declare function buildFtsQuery(raw: string): string | null;
46
- /**
47
- * MemoryIndexManager(单项目单实例)。
48
- */
49
- export declare class MemoryIndexer {
50
- private readonly rootPath;
51
- private readonly dbPath;
52
- private readonly db;
53
- constructor(rootPath: string);
54
- getRelativeDbPath(): string;
55
- close(): void;
56
- private ensureSchema;
57
- private listIndexedFiles;
58
- private deleteFileIndex;
59
- private writeFileChunks;
60
- sync(files: MemorySourceFile[], options?: {
61
- force?: boolean;
62
- }): Promise<MemoryIndexSyncResult>;
63
- search(params: {
64
- query: string;
65
- maxResults: number;
66
- minScore: number;
67
- maxInjectedChars: number;
68
- }): MemorySearchResultItem[];
69
- status(): MemoryIndexStatus;
70
- }
71
- //# sourceMappingURL=Indexer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Indexer.d.ts","sourceRoot":"","sources":["../../../../../src/service/builtins/memory/runtime/Indexer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,KAAK,EACV,sBAAsB,EAEtB,gBAAgB,EACjB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAmBnD,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,YAAY,EAAE,gBAAgB,EAAE,CAAC;CAClC,CAAC;AAcF;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAaxD;AAyED;;GAEG;AACH,qBAAa,aAAa;IAIZ,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAHrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;gBAEV,QAAQ,EAA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