@lobu/gateway 2.8.0

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 (533) hide show
  1. package/dist/api/index.d.ts +2 -0
  2. package/dist/api/index.d.ts.map +1 -0
  3. package/dist/api/index.js +6 -0
  4. package/dist/api/index.js.map +1 -0
  5. package/dist/api/platform.d.ts +92 -0
  6. package/dist/api/platform.d.ts.map +1 -0
  7. package/dist/api/platform.js +236 -0
  8. package/dist/api/platform.js.map +1 -0
  9. package/dist/api/response-renderer.d.ts +44 -0
  10. package/dist/api/response-renderer.d.ts.map +1 -0
  11. package/dist/api/response-renderer.js +123 -0
  12. package/dist/api/response-renderer.js.map +1 -0
  13. package/dist/auth/agent-metadata-store.d.ts +64 -0
  14. package/dist/auth/agent-metadata-store.d.ts.map +1 -0
  15. package/dist/auth/agent-metadata-store.js +115 -0
  16. package/dist/auth/agent-metadata-store.js.map +1 -0
  17. package/dist/auth/api-auth-middleware.d.ts +19 -0
  18. package/dist/auth/api-auth-middleware.d.ts.map +1 -0
  19. package/dist/auth/api-auth-middleware.js +61 -0
  20. package/dist/auth/api-auth-middleware.js.map +1 -0
  21. package/dist/auth/api-key-provider-module.d.ts +60 -0
  22. package/dist/auth/api-key-provider-module.d.ts.map +1 -0
  23. package/dist/auth/api-key-provider-module.js +148 -0
  24. package/dist/auth/api-key-provider-module.js.map +1 -0
  25. package/dist/auth/base-provider-module.d.ts +70 -0
  26. package/dist/auth/base-provider-module.d.ts.map +1 -0
  27. package/dist/auth/base-provider-module.js +118 -0
  28. package/dist/auth/base-provider-module.js.map +1 -0
  29. package/dist/auth/chatgpt/chatgpt-oauth-module.d.ts +34 -0
  30. package/dist/auth/chatgpt/chatgpt-oauth-module.d.ts.map +1 -0
  31. package/dist/auth/chatgpt/chatgpt-oauth-module.js +136 -0
  32. package/dist/auth/chatgpt/chatgpt-oauth-module.js.map +1 -0
  33. package/dist/auth/chatgpt/device-code-client.d.ts +40 -0
  34. package/dist/auth/chatgpt/device-code-client.d.ts.map +1 -0
  35. package/dist/auth/chatgpt/device-code-client.js +165 -0
  36. package/dist/auth/chatgpt/device-code-client.js.map +1 -0
  37. package/dist/auth/chatgpt/index.d.ts +2 -0
  38. package/dist/auth/chatgpt/index.d.ts.map +1 -0
  39. package/dist/auth/chatgpt/index.js +6 -0
  40. package/dist/auth/chatgpt/index.js.map +1 -0
  41. package/dist/auth/claude/oauth-module.d.ts +29 -0
  42. package/dist/auth/claude/oauth-module.d.ts.map +1 -0
  43. package/dist/auth/claude/oauth-module.js +201 -0
  44. package/dist/auth/claude/oauth-module.js.map +1 -0
  45. package/dist/auth/cli/token-service.d.ts +35 -0
  46. package/dist/auth/cli/token-service.d.ts.map +1 -0
  47. package/dist/auth/cli/token-service.js +171 -0
  48. package/dist/auth/cli/token-service.js.map +1 -0
  49. package/dist/auth/external/client.d.ts +65 -0
  50. package/dist/auth/external/client.d.ts.map +1 -0
  51. package/dist/auth/external/client.js +348 -0
  52. package/dist/auth/external/client.js.map +1 -0
  53. package/dist/auth/external/device-code-client.d.ts +41 -0
  54. package/dist/auth/external/device-code-client.d.ts.map +1 -0
  55. package/dist/auth/external/device-code-client.js +128 -0
  56. package/dist/auth/external/device-code-client.js.map +1 -0
  57. package/dist/auth/mcp/config-service.d.ts +70 -0
  58. package/dist/auth/mcp/config-service.d.ts.map +1 -0
  59. package/dist/auth/mcp/config-service.js +269 -0
  60. package/dist/auth/mcp/config-service.js.map +1 -0
  61. package/dist/auth/mcp/proxy.d.ts +68 -0
  62. package/dist/auth/mcp/proxy.d.ts.map +1 -0
  63. package/dist/auth/mcp/proxy.js +783 -0
  64. package/dist/auth/mcp/proxy.js.map +1 -0
  65. package/dist/auth/mcp/string-substitution.d.ts +11 -0
  66. package/dist/auth/mcp/string-substitution.d.ts.map +1 -0
  67. package/dist/auth/mcp/string-substitution.js +21 -0
  68. package/dist/auth/mcp/string-substitution.js.map +1 -0
  69. package/dist/auth/mcp/tool-cache.d.ts +26 -0
  70. package/dist/auth/mcp/tool-cache.d.ts.map +1 -0
  71. package/dist/auth/mcp/tool-cache.js +58 -0
  72. package/dist/auth/mcp/tool-cache.js.map +1 -0
  73. package/dist/auth/oauth/base-client.d.ts +54 -0
  74. package/dist/auth/oauth/base-client.d.ts.map +1 -0
  75. package/dist/auth/oauth/base-client.js +191 -0
  76. package/dist/auth/oauth/base-client.js.map +1 -0
  77. package/dist/auth/oauth/client.d.ts +35 -0
  78. package/dist/auth/oauth/client.d.ts.map +1 -0
  79. package/dist/auth/oauth/client.js +96 -0
  80. package/dist/auth/oauth/client.js.map +1 -0
  81. package/dist/auth/oauth/credentials.d.ts +8 -0
  82. package/dist/auth/oauth/credentials.d.ts.map +1 -0
  83. package/dist/auth/oauth/credentials.js +3 -0
  84. package/dist/auth/oauth/credentials.js.map +1 -0
  85. package/dist/auth/oauth/providers.d.ts +44 -0
  86. package/dist/auth/oauth/providers.d.ts.map +1 -0
  87. package/dist/auth/oauth/providers.js +37 -0
  88. package/dist/auth/oauth/providers.js.map +1 -0
  89. package/dist/auth/oauth/state-store.d.ts +62 -0
  90. package/dist/auth/oauth/state-store.d.ts.map +1 -0
  91. package/dist/auth/oauth/state-store.js +84 -0
  92. package/dist/auth/oauth/state-store.js.map +1 -0
  93. package/dist/auth/oauth-templates.d.ts +15 -0
  94. package/dist/auth/oauth-templates.d.ts.map +1 -0
  95. package/dist/auth/oauth-templates.js +161 -0
  96. package/dist/auth/oauth-templates.js.map +1 -0
  97. package/dist/auth/provider-catalog.d.ts +52 -0
  98. package/dist/auth/provider-catalog.d.ts.map +1 -0
  99. package/dist/auth/provider-catalog.js +155 -0
  100. package/dist/auth/provider-catalog.js.map +1 -0
  101. package/dist/auth/provider-model-options.d.ts +3 -0
  102. package/dist/auth/provider-model-options.d.ts.map +1 -0
  103. package/dist/auth/provider-model-options.js +29 -0
  104. package/dist/auth/provider-model-options.js.map +1 -0
  105. package/dist/auth/settings/agent-settings-store.d.ts +112 -0
  106. package/dist/auth/settings/agent-settings-store.d.ts.map +1 -0
  107. package/dist/auth/settings/agent-settings-store.js +376 -0
  108. package/dist/auth/settings/agent-settings-store.js.map +1 -0
  109. package/dist/auth/settings/auth-profiles-manager.d.ts +26 -0
  110. package/dist/auth/settings/auth-profiles-manager.d.ts.map +1 -0
  111. package/dist/auth/settings/auth-profiles-manager.js +146 -0
  112. package/dist/auth/settings/auth-profiles-manager.js.map +1 -0
  113. package/dist/auth/settings/index.d.ts +4 -0
  114. package/dist/auth/settings/index.d.ts.map +1 -0
  115. package/dist/auth/settings/index.js +9 -0
  116. package/dist/auth/settings/index.js.map +1 -0
  117. package/dist/auth/settings/model-preference-store.d.ts +25 -0
  118. package/dist/auth/settings/model-preference-store.d.ts.map +1 -0
  119. package/dist/auth/settings/model-preference-store.js +50 -0
  120. package/dist/auth/settings/model-preference-store.js.map +1 -0
  121. package/dist/auth/settings/model-selection.d.ts +11 -0
  122. package/dist/auth/settings/model-selection.d.ts.map +1 -0
  123. package/dist/auth/settings/model-selection.js +83 -0
  124. package/dist/auth/settings/model-selection.js.map +1 -0
  125. package/dist/auth/settings/resolved-settings-view.d.ts +45 -0
  126. package/dist/auth/settings/resolved-settings-view.d.ts.map +1 -0
  127. package/dist/auth/settings/resolved-settings-view.js +152 -0
  128. package/dist/auth/settings/resolved-settings-view.js.map +1 -0
  129. package/dist/auth/settings/template-utils.d.ts +3 -0
  130. package/dist/auth/settings/template-utils.d.ts.map +1 -0
  131. package/dist/auth/settings/template-utils.js +43 -0
  132. package/dist/auth/settings/template-utils.js.map +1 -0
  133. package/dist/auth/settings/token-service.d.ts +86 -0
  134. package/dist/auth/settings/token-service.d.ts.map +1 -0
  135. package/dist/auth/settings/token-service.js +3 -0
  136. package/dist/auth/settings/token-service.js.map +1 -0
  137. package/dist/auth/system-env-store.d.ts +26 -0
  138. package/dist/auth/system-env-store.d.ts.map +1 -0
  139. package/dist/auth/system-env-store.js +92 -0
  140. package/dist/auth/system-env-store.js.map +1 -0
  141. package/dist/auth/user-agents-store.d.ts +31 -0
  142. package/dist/auth/user-agents-store.d.ts.map +1 -0
  143. package/dist/auth/user-agents-store.js +54 -0
  144. package/dist/auth/user-agents-store.js.map +1 -0
  145. package/dist/channels/binding-service.d.ts +69 -0
  146. package/dist/channels/binding-service.d.ts.map +1 -0
  147. package/dist/channels/binding-service.js +144 -0
  148. package/dist/channels/binding-service.js.map +1 -0
  149. package/dist/channels/index.d.ts +2 -0
  150. package/dist/channels/index.d.ts.map +1 -0
  151. package/dist/channels/index.js +6 -0
  152. package/dist/channels/index.js.map +1 -0
  153. package/dist/cli/gateway.d.ts +31 -0
  154. package/dist/cli/gateway.d.ts.map +1 -0
  155. package/dist/cli/gateway.js +1062 -0
  156. package/dist/cli/gateway.js.map +1 -0
  157. package/dist/cli/index.d.ts +3 -0
  158. package/dist/cli/index.d.ts.map +1 -0
  159. package/dist/cli/index.js +56 -0
  160. package/dist/cli/index.js.map +1 -0
  161. package/dist/commands/built-in-commands.d.ts +10 -0
  162. package/dist/commands/built-in-commands.d.ts.map +1 -0
  163. package/dist/commands/built-in-commands.js +63 -0
  164. package/dist/commands/built-in-commands.js.map +1 -0
  165. package/dist/commands/command-dispatcher.d.ts +25 -0
  166. package/dist/commands/command-dispatcher.d.ts.map +1 -0
  167. package/dist/commands/command-dispatcher.js +50 -0
  168. package/dist/commands/command-dispatcher.js.map +1 -0
  169. package/dist/commands/command-reply-adapters.d.ts +3 -0
  170. package/dist/commands/command-reply-adapters.d.ts.map +1 -0
  171. package/dist/commands/command-reply-adapters.js +60 -0
  172. package/dist/commands/command-reply-adapters.js.map +1 -0
  173. package/dist/config/file-loader.d.ts +23 -0
  174. package/dist/config/file-loader.d.ts.map +1 -0
  175. package/dist/config/file-loader.js +495 -0
  176. package/dist/config/file-loader.js.map +1 -0
  177. package/dist/config/index.d.ts +96 -0
  178. package/dist/config/index.d.ts.map +1 -0
  179. package/dist/config/index.js +357 -0
  180. package/dist/config/index.js.map +1 -0
  181. package/dist/config/network-allowlist.d.ts +18 -0
  182. package/dist/config/network-allowlist.d.ts.map +1 -0
  183. package/dist/config/network-allowlist.js +60 -0
  184. package/dist/config/network-allowlist.js.map +1 -0
  185. package/dist/connections/chat-instance-manager.d.ts +107 -0
  186. package/dist/connections/chat-instance-manager.d.ts.map +1 -0
  187. package/dist/connections/chat-instance-manager.js +886 -0
  188. package/dist/connections/chat-instance-manager.js.map +1 -0
  189. package/dist/connections/chat-response-bridge.d.ts +31 -0
  190. package/dist/connections/chat-response-bridge.d.ts.map +1 -0
  191. package/dist/connections/chat-response-bridge.js +465 -0
  192. package/dist/connections/chat-response-bridge.js.map +1 -0
  193. package/dist/connections/index.d.ts +4 -0
  194. package/dist/connections/index.d.ts.map +1 -0
  195. package/dist/connections/index.js +8 -0
  196. package/dist/connections/index.js.map +1 -0
  197. package/dist/connections/interaction-bridge.d.ts +7 -0
  198. package/dist/connections/interaction-bridge.d.ts.map +1 -0
  199. package/dist/connections/interaction-bridge.js +593 -0
  200. package/dist/connections/interaction-bridge.js.map +1 -0
  201. package/dist/connections/message-handler-bridge.d.ts +21 -0
  202. package/dist/connections/message-handler-bridge.d.ts.map +1 -0
  203. package/dist/connections/message-handler-bridge.js +314 -0
  204. package/dist/connections/message-handler-bridge.js.map +1 -0
  205. package/dist/connections/platform-auth-methods.d.ts +5 -0
  206. package/dist/connections/platform-auth-methods.d.ts.map +1 -0
  207. package/dist/connections/platform-auth-methods.js +13 -0
  208. package/dist/connections/platform-auth-methods.js.map +1 -0
  209. package/dist/connections/types.d.ts +52 -0
  210. package/dist/connections/types.d.ts.map +1 -0
  211. package/dist/connections/types.js +20 -0
  212. package/dist/connections/types.js.map +1 -0
  213. package/dist/gateway/connection-manager.d.ts +87 -0
  214. package/dist/gateway/connection-manager.d.ts.map +1 -0
  215. package/dist/gateway/connection-manager.js +216 -0
  216. package/dist/gateway/connection-manager.js.map +1 -0
  217. package/dist/gateway/index.d.ts +71 -0
  218. package/dist/gateway/index.d.ts.map +1 -0
  219. package/dist/gateway/index.js +509 -0
  220. package/dist/gateway/index.js.map +1 -0
  221. package/dist/gateway/job-router.d.ts +60 -0
  222. package/dist/gateway/job-router.d.ts.map +1 -0
  223. package/dist/gateway/job-router.js +148 -0
  224. package/dist/gateway/job-router.js.map +1 -0
  225. package/dist/gateway-main.d.ts +81 -0
  226. package/dist/gateway-main.d.ts.map +1 -0
  227. package/dist/gateway-main.js +143 -0
  228. package/dist/gateway-main.js.map +1 -0
  229. package/dist/index.d.ts +16 -0
  230. package/dist/index.d.ts.map +1 -0
  231. package/dist/index.js +64 -0
  232. package/dist/index.js.map +1 -0
  233. package/dist/infrastructure/queue/index.d.ts +8 -0
  234. package/dist/infrastructure/queue/index.d.ts.map +1 -0
  235. package/dist/infrastructure/queue/index.js +12 -0
  236. package/dist/infrastructure/queue/index.js.map +1 -0
  237. package/dist/infrastructure/queue/queue-producer.d.ts +68 -0
  238. package/dist/infrastructure/queue/queue-producer.d.ts.map +1 -0
  239. package/dist/infrastructure/queue/queue-producer.js +72 -0
  240. package/dist/infrastructure/queue/queue-producer.js.map +1 -0
  241. package/dist/infrastructure/queue/redis-queue.d.ts +45 -0
  242. package/dist/infrastructure/queue/redis-queue.d.ts.map +1 -0
  243. package/dist/infrastructure/queue/redis-queue.js +273 -0
  244. package/dist/infrastructure/queue/redis-queue.js.map +1 -0
  245. package/dist/infrastructure/queue/types.d.ts +107 -0
  246. package/dist/infrastructure/queue/types.d.ts.map +1 -0
  247. package/dist/infrastructure/queue/types.js +7 -0
  248. package/dist/infrastructure/queue/types.js.map +1 -0
  249. package/dist/infrastructure/redis/system-message-limiter.d.ts +35 -0
  250. package/dist/infrastructure/redis/system-message-limiter.d.ts.map +1 -0
  251. package/dist/infrastructure/redis/system-message-limiter.js +61 -0
  252. package/dist/infrastructure/redis/system-message-limiter.js.map +1 -0
  253. package/dist/interactions/config-request-store.d.ts +41 -0
  254. package/dist/interactions/config-request-store.d.ts.map +1 -0
  255. package/dist/interactions/config-request-store.js +103 -0
  256. package/dist/interactions/config-request-store.js.map +1 -0
  257. package/dist/interactions.d.ts +134 -0
  258. package/dist/interactions.d.ts.map +1 -0
  259. package/dist/interactions.js +175 -0
  260. package/dist/interactions.js.map +1 -0
  261. package/dist/lobu.d.ts +78 -0
  262. package/dist/lobu.d.ts.map +1 -0
  263. package/dist/lobu.js +248 -0
  264. package/dist/lobu.js.map +1 -0
  265. package/dist/metrics/prometheus.d.ts +6 -0
  266. package/dist/metrics/prometheus.d.ts.map +1 -0
  267. package/dist/metrics/prometheus.js +78 -0
  268. package/dist/metrics/prometheus.js.map +1 -0
  269. package/dist/modules/module-system.d.ts +82 -0
  270. package/dist/modules/module-system.d.ts.map +1 -0
  271. package/dist/modules/module-system.js +53 -0
  272. package/dist/modules/module-system.js.map +1 -0
  273. package/dist/orchestration/base-deployment-manager.d.ts +173 -0
  274. package/dist/orchestration/base-deployment-manager.d.ts.map +1 -0
  275. package/dist/orchestration/base-deployment-manager.js +553 -0
  276. package/dist/orchestration/base-deployment-manager.js.map +1 -0
  277. package/dist/orchestration/deployment-utils.d.ts +25 -0
  278. package/dist/orchestration/deployment-utils.d.ts.map +1 -0
  279. package/dist/orchestration/deployment-utils.js +65 -0
  280. package/dist/orchestration/deployment-utils.js.map +1 -0
  281. package/dist/orchestration/impl/docker-deployment.d.ts +43 -0
  282. package/dist/orchestration/impl/docker-deployment.d.ts.map +1 -0
  283. package/dist/orchestration/impl/docker-deployment.js +480 -0
  284. package/dist/orchestration/impl/docker-deployment.js.map +1 -0
  285. package/dist/orchestration/impl/embedded-deployment.d.ts +16 -0
  286. package/dist/orchestration/impl/embedded-deployment.d.ts.map +1 -0
  287. package/dist/orchestration/impl/embedded-deployment.js +195 -0
  288. package/dist/orchestration/impl/embedded-deployment.js.map +1 -0
  289. package/dist/orchestration/impl/index.d.ts +8 -0
  290. package/dist/orchestration/impl/index.d.ts.map +1 -0
  291. package/dist/orchestration/impl/index.js +14 -0
  292. package/dist/orchestration/impl/index.js.map +1 -0
  293. package/dist/orchestration/impl/k8s/deployment.d.ts +204 -0
  294. package/dist/orchestration/impl/k8s/deployment.d.ts.map +1 -0
  295. package/dist/orchestration/impl/k8s/deployment.js +620 -0
  296. package/dist/orchestration/impl/k8s/deployment.js.map +1 -0
  297. package/dist/orchestration/impl/k8s/helpers.d.ts +34 -0
  298. package/dist/orchestration/impl/k8s/helpers.d.ts.map +1 -0
  299. package/dist/orchestration/impl/k8s/helpers.js +377 -0
  300. package/dist/orchestration/impl/k8s/helpers.js.map +1 -0
  301. package/dist/orchestration/impl/k8s/index.d.ts +2 -0
  302. package/dist/orchestration/impl/k8s/index.d.ts.map +1 -0
  303. package/dist/orchestration/impl/k8s/index.js +6 -0
  304. package/dist/orchestration/impl/k8s/index.js.map +1 -0
  305. package/dist/orchestration/index.d.ts +53 -0
  306. package/dist/orchestration/index.d.ts.map +1 -0
  307. package/dist/orchestration/index.js +257 -0
  308. package/dist/orchestration/index.js.map +1 -0
  309. package/dist/orchestration/message-consumer.d.ts +49 -0
  310. package/dist/orchestration/message-consumer.d.ts.map +1 -0
  311. package/dist/orchestration/message-consumer.js +406 -0
  312. package/dist/orchestration/message-consumer.js.map +1 -0
  313. package/dist/orchestration/scheduled-wakeup.d.ts +110 -0
  314. package/dist/orchestration/scheduled-wakeup.d.ts.map +1 -0
  315. package/dist/orchestration/scheduled-wakeup.js +500 -0
  316. package/dist/orchestration/scheduled-wakeup.js.map +1 -0
  317. package/dist/permissions/approval-policy.d.ts +28 -0
  318. package/dist/permissions/approval-policy.d.ts.map +1 -0
  319. package/dist/permissions/approval-policy.js +33 -0
  320. package/dist/permissions/approval-policy.js.map +1 -0
  321. package/dist/permissions/grant-store.d.ts +52 -0
  322. package/dist/permissions/grant-store.d.ts.map +1 -0
  323. package/dist/permissions/grant-store.js +192 -0
  324. package/dist/permissions/grant-store.js.map +1 -0
  325. package/dist/platform/file-handler.d.ts +51 -0
  326. package/dist/platform/file-handler.d.ts.map +1 -0
  327. package/dist/platform/file-handler.js +6 -0
  328. package/dist/platform/file-handler.js.map +1 -0
  329. package/dist/platform/link-buttons.d.ts +21 -0
  330. package/dist/platform/link-buttons.d.ts.map +1 -0
  331. package/dist/platform/link-buttons.js +43 -0
  332. package/dist/platform/link-buttons.js.map +1 -0
  333. package/dist/platform/renderer-utils.d.ts +10 -0
  334. package/dist/platform/renderer-utils.d.ts.map +1 -0
  335. package/dist/platform/renderer-utils.js +42 -0
  336. package/dist/platform/renderer-utils.js.map +1 -0
  337. package/dist/platform/response-renderer.d.ts +66 -0
  338. package/dist/platform/response-renderer.d.ts.map +1 -0
  339. package/dist/platform/response-renderer.js +8 -0
  340. package/dist/platform/response-renderer.js.map +1 -0
  341. package/dist/platform/unified-thread-consumer.d.ts +41 -0
  342. package/dist/platform/unified-thread-consumer.d.ts.map +1 -0
  343. package/dist/platform/unified-thread-consumer.js +143 -0
  344. package/dist/platform/unified-thread-consumer.js.map +1 -0
  345. package/dist/platform.d.ts +255 -0
  346. package/dist/platform.d.ts.map +1 -0
  347. package/dist/platform.js +40 -0
  348. package/dist/platform.js.map +1 -0
  349. package/dist/proxy/http-proxy.d.ts +32 -0
  350. package/dist/proxy/http-proxy.d.ts.map +1 -0
  351. package/dist/proxy/http-proxy.js +636 -0
  352. package/dist/proxy/http-proxy.js.map +1 -0
  353. package/dist/proxy/proxy-manager.d.ts +13 -0
  354. package/dist/proxy/proxy-manager.d.ts.map +1 -0
  355. package/dist/proxy/proxy-manager.js +68 -0
  356. package/dist/proxy/proxy-manager.js.map +1 -0
  357. package/dist/proxy/secret-proxy.d.ts +78 -0
  358. package/dist/proxy/secret-proxy.d.ts.map +1 -0
  359. package/dist/proxy/secret-proxy.js +309 -0
  360. package/dist/proxy/secret-proxy.js.map +1 -0
  361. package/dist/proxy/token-refresh-job.d.ts +29 -0
  362. package/dist/proxy/token-refresh-job.d.ts.map +1 -0
  363. package/dist/proxy/token-refresh-job.js +104 -0
  364. package/dist/proxy/token-refresh-job.js.map +1 -0
  365. package/dist/routes/internal/audio.d.ts +14 -0
  366. package/dist/routes/internal/audio.d.ts.map +1 -0
  367. package/dist/routes/internal/audio.js +118 -0
  368. package/dist/routes/internal/audio.js.map +1 -0
  369. package/dist/routes/internal/device-auth.d.ts +42 -0
  370. package/dist/routes/internal/device-auth.d.ts.map +1 -0
  371. package/dist/routes/internal/device-auth.js +397 -0
  372. package/dist/routes/internal/device-auth.js.map +1 -0
  373. package/dist/routes/internal/files.d.ts +9 -0
  374. package/dist/routes/internal/files.d.ts.map +1 -0
  375. package/dist/routes/internal/files.js +175 -0
  376. package/dist/routes/internal/files.js.map +1 -0
  377. package/dist/routes/internal/history.d.ts +9 -0
  378. package/dist/routes/internal/history.d.ts.map +1 -0
  379. package/dist/routes/internal/history.js +55 -0
  380. package/dist/routes/internal/history.js.map +1 -0
  381. package/dist/routes/internal/images.d.ts +10 -0
  382. package/dist/routes/internal/images.d.ts.map +1 -0
  383. package/dist/routes/internal/images.js +101 -0
  384. package/dist/routes/internal/images.js.map +1 -0
  385. package/dist/routes/internal/interactions.d.ts +9 -0
  386. package/dist/routes/internal/interactions.d.ts.map +1 -0
  387. package/dist/routes/internal/interactions.js +53 -0
  388. package/dist/routes/internal/interactions.js.map +1 -0
  389. package/dist/routes/internal/middleware.d.ts +7 -0
  390. package/dist/routes/internal/middleware.d.ts.map +1 -0
  391. package/dist/routes/internal/middleware.js +24 -0
  392. package/dist/routes/internal/middleware.js.map +1 -0
  393. package/dist/routes/internal/schedule.d.ts +14 -0
  394. package/dist/routes/internal/schedule.d.ts.map +1 -0
  395. package/dist/routes/internal/schedule.js +169 -0
  396. package/dist/routes/internal/schedule.js.map +1 -0
  397. package/dist/routes/internal/types.d.ts +22 -0
  398. package/dist/routes/internal/types.d.ts.map +1 -0
  399. package/dist/routes/internal/types.js +6 -0
  400. package/dist/routes/internal/types.js.map +1 -0
  401. package/dist/routes/openapi-auto.d.ts +8 -0
  402. package/dist/routes/openapi-auto.d.ts.map +1 -0
  403. package/dist/routes/openapi-auto.js +196 -0
  404. package/dist/routes/openapi-auto.js.map +1 -0
  405. package/dist/routes/public/agent-access.d.ts +11 -0
  406. package/dist/routes/public/agent-access.d.ts.map +1 -0
  407. package/dist/routes/public/agent-access.js +11 -0
  408. package/dist/routes/public/agent-access.js.map +1 -0
  409. package/dist/routes/public/agent-config.d.ts +42 -0
  410. package/dist/routes/public/agent-config.d.ts.map +1 -0
  411. package/dist/routes/public/agent-config.js +415 -0
  412. package/dist/routes/public/agent-config.js.map +1 -0
  413. package/dist/routes/public/agent-history.d.ts +17 -0
  414. package/dist/routes/public/agent-history.d.ts.map +1 -0
  415. package/dist/routes/public/agent-history.js +335 -0
  416. package/dist/routes/public/agent-history.js.map +1 -0
  417. package/dist/routes/public/agent-schedules.d.ts +18 -0
  418. package/dist/routes/public/agent-schedules.d.ts.map +1 -0
  419. package/dist/routes/public/agent-schedules.js +242 -0
  420. package/dist/routes/public/agent-schedules.js.map +1 -0
  421. package/dist/routes/public/agent.d.ts +23 -0
  422. package/dist/routes/public/agent.d.ts.map +1 -0
  423. package/dist/routes/public/agent.js +864 -0
  424. package/dist/routes/public/agent.js.map +1 -0
  425. package/dist/routes/public/agents.d.ts +22 -0
  426. package/dist/routes/public/agents.d.ts.map +1 -0
  427. package/dist/routes/public/agents.js +257 -0
  428. package/dist/routes/public/agents.js.map +1 -0
  429. package/dist/routes/public/channels.d.ts +23 -0
  430. package/dist/routes/public/channels.d.ts.map +1 -0
  431. package/dist/routes/public/channels.js +131 -0
  432. package/dist/routes/public/channels.js.map +1 -0
  433. package/dist/routes/public/cli-auth.d.ts +12 -0
  434. package/dist/routes/public/cli-auth.d.ts.map +1 -0
  435. package/dist/routes/public/cli-auth.js +552 -0
  436. package/dist/routes/public/cli-auth.js.map +1 -0
  437. package/dist/routes/public/connections.d.ts +20 -0
  438. package/dist/routes/public/connections.d.ts.map +1 -0
  439. package/dist/routes/public/connections.js +464 -0
  440. package/dist/routes/public/connections.js.map +1 -0
  441. package/dist/routes/public/landing.d.ts +3 -0
  442. package/dist/routes/public/landing.d.ts.map +1 -0
  443. package/dist/routes/public/landing.js +17 -0
  444. package/dist/routes/public/landing.js.map +1 -0
  445. package/dist/routes/public/oauth.d.ts +24 -0
  446. package/dist/routes/public/oauth.d.ts.map +1 -0
  447. package/dist/routes/public/oauth.js +108 -0
  448. package/dist/routes/public/oauth.js.map +1 -0
  449. package/dist/routes/public/settings-auth.d.ts +28 -0
  450. package/dist/routes/public/settings-auth.d.ts.map +1 -0
  451. package/dist/routes/public/settings-auth.js +90 -0
  452. package/dist/routes/public/settings-auth.js.map +1 -0
  453. package/dist/routes/public/slack.d.ts +4 -0
  454. package/dist/routes/public/slack.d.ts.map +1 -0
  455. package/dist/routes/public/slack.js +119 -0
  456. package/dist/routes/public/slack.js.map +1 -0
  457. package/dist/routes/shared/agent-ownership.d.ts +15 -0
  458. package/dist/routes/shared/agent-ownership.d.ts.map +1 -0
  459. package/dist/routes/shared/agent-ownership.js +61 -0
  460. package/dist/routes/shared/agent-ownership.js.map +1 -0
  461. package/dist/routes/shared/token-verifier.d.ts +21 -0
  462. package/dist/routes/shared/token-verifier.d.ts.map +1 -0
  463. package/dist/routes/shared/token-verifier.js +25 -0
  464. package/dist/routes/shared/token-verifier.js.map +1 -0
  465. package/dist/services/core-services.d.ts +133 -0
  466. package/dist/services/core-services.d.ts.map +1 -0
  467. package/dist/services/core-services.js +728 -0
  468. package/dist/services/core-services.js.map +1 -0
  469. package/dist/services/image-generation-service.d.ts +38 -0
  470. package/dist/services/image-generation-service.d.ts.map +1 -0
  471. package/dist/services/image-generation-service.js +167 -0
  472. package/dist/services/image-generation-service.js.map +1 -0
  473. package/dist/services/instruction-service.d.ts +41 -0
  474. package/dist/services/instruction-service.d.ts.map +1 -0
  475. package/dist/services/instruction-service.js +252 -0
  476. package/dist/services/instruction-service.js.map +1 -0
  477. package/dist/services/mcp-registry.d.ts +31 -0
  478. package/dist/services/mcp-registry.d.ts.map +1 -0
  479. package/dist/services/mcp-registry.js +69 -0
  480. package/dist/services/mcp-registry.js.map +1 -0
  481. package/dist/services/platform-helpers.d.ts +47 -0
  482. package/dist/services/platform-helpers.d.ts.map +1 -0
  483. package/dist/services/platform-helpers.js +200 -0
  484. package/dist/services/platform-helpers.js.map +1 -0
  485. package/dist/services/session-manager.d.ts +72 -0
  486. package/dist/services/session-manager.d.ts.map +1 -0
  487. package/dist/services/session-manager.js +199 -0
  488. package/dist/services/session-manager.js.map +1 -0
  489. package/dist/services/settings-resolver.d.ts +25 -0
  490. package/dist/services/settings-resolver.d.ts.map +1 -0
  491. package/dist/services/settings-resolver.js +55 -0
  492. package/dist/services/settings-resolver.js.map +1 -0
  493. package/dist/services/system-config-resolver.d.ts +25 -0
  494. package/dist/services/system-config-resolver.d.ts.map +1 -0
  495. package/dist/services/system-config-resolver.js +73 -0
  496. package/dist/services/system-config-resolver.js.map +1 -0
  497. package/dist/services/system-skills-service.d.ts +38 -0
  498. package/dist/services/system-skills-service.d.ts.map +1 -0
  499. package/dist/services/system-skills-service.js +186 -0
  500. package/dist/services/system-skills-service.js.map +1 -0
  501. package/dist/services/transcription-service.d.ts +91 -0
  502. package/dist/services/transcription-service.d.ts.map +1 -0
  503. package/dist/services/transcription-service.js +465 -0
  504. package/dist/services/transcription-service.js.map +1 -0
  505. package/dist/session.d.ts +75 -0
  506. package/dist/session.d.ts.map +1 -0
  507. package/dist/session.js +19 -0
  508. package/dist/session.js.map +1 -0
  509. package/dist/spaces/index.d.ts +2 -0
  510. package/dist/spaces/index.d.ts.map +1 -0
  511. package/dist/spaces/index.js +18 -0
  512. package/dist/spaces/index.js.map +1 -0
  513. package/dist/spaces/space-resolver.d.ts +10 -0
  514. package/dist/spaces/space-resolver.d.ts.map +1 -0
  515. package/dist/spaces/space-resolver.js +17 -0
  516. package/dist/spaces/space-resolver.js.map +1 -0
  517. package/dist/stores/in-memory-agent-store.d.ts +57 -0
  518. package/dist/stores/in-memory-agent-store.d.ts.map +1 -0
  519. package/dist/stores/in-memory-agent-store.js +304 -0
  520. package/dist/stores/in-memory-agent-store.js.map +1 -0
  521. package/dist/stores/redis-agent-store.d.ts +57 -0
  522. package/dist/stores/redis-agent-store.d.ts.map +1 -0
  523. package/dist/stores/redis-agent-store.js +163 -0
  524. package/dist/stores/redis-agent-store.js.map +1 -0
  525. package/dist/utils/public-url.d.ts +6 -0
  526. package/dist/utils/public-url.d.ts.map +1 -0
  527. package/dist/utils/public-url.js +33 -0
  528. package/dist/utils/public-url.js.map +1 -0
  529. package/dist/utils/rate-limiter.d.ts +32 -0
  530. package/dist/utils/rate-limiter.d.ts.map +1 -0
  531. package/dist/utils/rate-limiter.js +56 -0
  532. package/dist/utils/rate-limiter.js.map +1 -0
  533. package/package.json +63 -0
@@ -0,0 +1,728 @@
1
+ #!/usr/bin/env bun
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.CoreServices = void 0;
38
+ const core_1 = require("@lobu/core");
39
+ const agent_metadata_store_1 = require("../auth/agent-metadata-store");
40
+ const api_key_provider_module_1 = require("../auth/api-key-provider-module");
41
+ const chatgpt_1 = require("../auth/chatgpt");
42
+ const oauth_module_1 = require("../auth/claude/oauth-module");
43
+ const client_1 = require("../auth/external/client");
44
+ const config_service_1 = require("../auth/mcp/config-service");
45
+ const proxy_1 = require("../auth/mcp/proxy");
46
+ const tool_cache_1 = require("../auth/mcp/tool-cache");
47
+ const client_2 = require("../auth/oauth/client");
48
+ const providers_1 = require("../auth/oauth/providers");
49
+ const state_store_1 = require("../auth/oauth/state-store");
50
+ const provider_catalog_1 = require("../auth/provider-catalog");
51
+ const settings_1 = require("../auth/settings");
52
+ const model_preference_store_1 = require("../auth/settings/model-preference-store");
53
+ const user_agents_store_1 = require("../auth/user-agents-store");
54
+ const channels_1 = require("../channels");
55
+ const built_in_commands_1 = require("../commands/built-in-commands");
56
+ const file_loader_1 = require("../config/file-loader");
57
+ const gateway_1 = require("../gateway");
58
+ const queue_1 = require("../infrastructure/queue");
59
+ const interactions_1 = require("../interactions");
60
+ const module_system_1 = require("../modules/module-system");
61
+ const scheduled_wakeup_1 = require("../orchestration/scheduled-wakeup");
62
+ const grant_store_1 = require("../permissions/grant-store");
63
+ const secret_proxy_1 = require("../proxy/secret-proxy");
64
+ const token_refresh_job_1 = require("../proxy/token-refresh-job");
65
+ const in_memory_agent_store_1 = require("../stores/in-memory-agent-store");
66
+ const redis_agent_store_1 = require("../stores/redis-agent-store");
67
+ const image_generation_service_1 = require("./image-generation-service");
68
+ const instruction_service_1 = require("./instruction-service");
69
+ const session_manager_1 = require("./session-manager");
70
+ const settings_resolver_1 = require("./settings-resolver");
71
+ const system_config_resolver_1 = require("./system-config-resolver");
72
+ const system_skills_service_1 = require("./system-skills-service");
73
+ const transcription_service_1 = require("./transcription-service");
74
+ const logger = (0, core_1.createLogger)("core-services");
75
+ /**
76
+ * Core Services - Centralized service initialization and lifecycle management
77
+ */
78
+ class CoreServices {
79
+ constructor(config, options) {
80
+ this.config = config;
81
+ // File-first architecture state
82
+ this.fileLoadedAgents = [];
83
+ this.projectPath = null;
84
+ this.configAgents = [];
85
+ this.options = options;
86
+ if (options === null || options === void 0 ? void 0 : options.configStore)
87
+ this.configStore = options.configStore;
88
+ if (options === null || options === void 0 ? void 0 : options.connectionStore)
89
+ this.connectionStore = options.connectionStore;
90
+ if (options === null || options === void 0 ? void 0 : options.accessStore)
91
+ this.accessStore = options.accessStore;
92
+ }
93
+ getConfigStore() {
94
+ return this.configStore;
95
+ }
96
+ getConnectionStore() {
97
+ return this.connectionStore;
98
+ }
99
+ getAccessStore() {
100
+ return this.accessStore;
101
+ }
102
+ getSettingsResolver() {
103
+ return this.settingsResolver;
104
+ }
105
+ /**
106
+ * Initialize all core services in dependency order
107
+ */
108
+ async initialize() {
109
+ logger.debug("Initializing core services...");
110
+ // 1. Queue (foundation for everything else)
111
+ await this.initializeQueue();
112
+ logger.debug("Queue initialized");
113
+ // 2. Session management
114
+ await this.initializeSessionServices();
115
+ logger.debug("Session services initialized");
116
+ // 3. Auth & provider services
117
+ await this.initializeClaudeServices();
118
+ logger.debug("Auth & provider services initialized");
119
+ // 4. MCP ecosystem (depends on queue and Claude services)
120
+ await this.initializeMcpServices();
121
+ logger.debug("MCP services initialized");
122
+ // 5. Queue producer (depends on queue being ready)
123
+ await this.initializeQueueProducer();
124
+ logger.debug("Queue producer initialized");
125
+ // 6. Scheduled wakeup service (depends on queue)
126
+ await this.initializeScheduledWakeupService();
127
+ logger.debug("Scheduled wakeup service initialized");
128
+ // 7. Command registry (depends on agent settings store)
129
+ this.initializeCommandRegistry();
130
+ logger.debug("Command registry initialized");
131
+ logger.info("Core services initialized successfully");
132
+ }
133
+ // ============================================================================
134
+ // 1. Queue Services Initialization
135
+ // ============================================================================
136
+ async initializeQueue() {
137
+ var _a;
138
+ if (!((_a = this.config.queues) === null || _a === void 0 ? void 0 : _a.connectionString)) {
139
+ throw new Error("Queue connection string is required");
140
+ }
141
+ const url = new URL(this.config.queues.connectionString);
142
+ if (url.protocol !== "redis:") {
143
+ throw new Error(`Unsupported queue protocol: ${url.protocol}. Only redis:// is supported.`);
144
+ }
145
+ const config = {
146
+ host: url.hostname,
147
+ port: Number.parseInt(url.port, 10) || 6379,
148
+ password: url.password || undefined,
149
+ db: url.pathname ? Number.parseInt(url.pathname.slice(1), 10) : 0,
150
+ maxRetriesPerRequest: 3,
151
+ };
152
+ this.queue = new queue_1.RedisQueue(config);
153
+ await this.queue.start();
154
+ logger.debug("Queue connection established");
155
+ }
156
+ async initializeQueueProducer() {
157
+ if (!this.queue) {
158
+ throw new Error("Queue must be initialized before queue producer");
159
+ }
160
+ this.queueProducer = new queue_1.QueueProducer(this.queue);
161
+ await this.queueProducer.start();
162
+ logger.debug("Queue producer initialized");
163
+ }
164
+ // ============================================================================
165
+ // Scheduled Wakeup Service Initialization
166
+ // ============================================================================
167
+ async initializeScheduledWakeupService() {
168
+ if (!this.queue) {
169
+ throw new Error("Queue must be initialized before scheduled wakeup service");
170
+ }
171
+ this.scheduledWakeupService = new scheduled_wakeup_1.ScheduledWakeupService(this.queue);
172
+ await this.scheduledWakeupService.start();
173
+ // Set global reference for BaseDeploymentManager cleanup
174
+ (0, scheduled_wakeup_1.setScheduledWakeupService)(this.scheduledWakeupService);
175
+ logger.debug("Scheduled wakeup service initialized");
176
+ }
177
+ // ============================================================================
178
+ // 2. Session Services Initialization
179
+ // ============================================================================
180
+ async initializeSessionServices() {
181
+ var _a, _b, _c;
182
+ if (!this.queue) {
183
+ throw new Error("Queue must be initialized before session services");
184
+ }
185
+ const redisClient = this.queue.getRedisClient();
186
+ const sessionStore = new session_manager_1.RedisSessionStore(this.queue);
187
+ this.sessionManager = new session_manager_1.SessionManager(sessionStore);
188
+ logger.debug("Session manager initialized");
189
+ this.interactionService = new interactions_1.InteractionService();
190
+ logger.debug("Interaction service initialized");
191
+ // Initialize grant store for unified permissions
192
+ this.grantStore = new grant_store_1.GrantStore(redisClient);
193
+ logger.debug("Grant store initialized");
194
+ // Initialize agent configuration stores
195
+ this.agentSettingsStore = new settings_1.AgentSettingsStore(redisClient);
196
+ this.channelBindingService = new channels_1.ChannelBindingService(redisClient);
197
+ this.userAgentsStore = new user_agents_store_1.UserAgentsStore(redisClient);
198
+ this.agentMetadataStore = new agent_metadata_store_1.AgentMetadataStore(redisClient);
199
+ logger.debug("Agent settings, channel binding, user agents & metadata stores initialized");
200
+ // Initialize agent sub-stores
201
+ if (!this.configStore || !this.connectionStore || !this.accessStore) {
202
+ if ((_a = this.config.agents) === null || _a === void 0 ? void 0 : _a.length) {
203
+ const inMemoryStore = new in_memory_agent_store_1.InMemoryAgentStore();
204
+ if (!this.configStore)
205
+ this.configStore = inMemoryStore;
206
+ if (!this.connectionStore)
207
+ this.connectionStore = inMemoryStore;
208
+ if (!this.accessStore)
209
+ this.accessStore = inMemoryStore;
210
+ await this.populateStoreFromAgentConfigs(inMemoryStore, this.config.agents);
211
+ logger.debug(`Agent sub-stores initialized (in-memory, ${this.config.agents.length} agent(s) from config)`);
212
+ }
213
+ else {
214
+ // Check if lobu.toml exists (file-first dev mode)
215
+ const { existsSync } = await Promise.resolve().then(() => __importStar(require("node:fs")));
216
+ const { resolve } = await Promise.resolve().then(() => __importStar(require("node:path")));
217
+ const workspaceRoot = (_b = process.env.LOBU_WORKSPACE_ROOT) === null || _b === void 0 ? void 0 : _b.trim();
218
+ const candidatePaths = [
219
+ ...(workspaceRoot ? [resolve(workspaceRoot, "lobu.toml")] : []),
220
+ resolve(process.cwd(), "lobu.toml"),
221
+ resolve("/app/lobu.toml"),
222
+ ];
223
+ const tomlPath = candidatePaths.find((p) => existsSync(p));
224
+ if (tomlPath) {
225
+ const inMemoryStore = new in_memory_agent_store_1.InMemoryAgentStore();
226
+ if (!this.configStore)
227
+ this.configStore = inMemoryStore;
228
+ if (!this.connectionStore)
229
+ this.connectionStore = inMemoryStore;
230
+ if (!this.accessStore)
231
+ this.accessStore = inMemoryStore;
232
+ // File-first dev mode: use InMemoryAgentStore populated from files
233
+ this.projectPath = resolve(tomlPath, "..");
234
+ // Load agents from files and populate store
235
+ this.fileLoadedAgents = await (0, file_loader_1.loadAgentConfigFromFiles)(this.projectPath);
236
+ await this.populateStoreFromFiles(inMemoryStore, this.fileLoadedAgents);
237
+ logger.debug(`Agent sub-stores initialized (in-memory, ${this.fileLoadedAgents.length} agent(s) from files)`);
238
+ }
239
+ else {
240
+ if (!this.configStore) {
241
+ this.configStore = new redis_agent_store_1.RedisAgentConfigStore(this.agentSettingsStore, this.agentMetadataStore);
242
+ }
243
+ if (!this.connectionStore) {
244
+ this.connectionStore = new redis_agent_store_1.RedisAgentConnectionStore(redisClient, this.channelBindingService);
245
+ }
246
+ if (!this.accessStore) {
247
+ this.accessStore = new redis_agent_store_1.RedisAgentAccessStore(this.grantStore, this.userAgentsStore);
248
+ }
249
+ logger.debug("Agent sub-stores initialized (Redis-backed defaults)");
250
+ }
251
+ }
252
+ }
253
+ else {
254
+ logger.debug("Using host-provided agent sub-stores (embedded mode)");
255
+ }
256
+ // Create settings resolver (template fallback logic)
257
+ this.settingsResolver = new settings_resolver_1.SettingsResolver(this.configStore, this.connectionStore);
258
+ // Initialize external OAuth client if configured
259
+ this.externalAuthClient =
260
+ (_c = client_1.ExternalAuthClient.fromEnv(this.config.mcp.publicGatewayUrl, {
261
+ get: (key) => redisClient.get(key),
262
+ set: (key, value, ttlSeconds) => redisClient.setex(key, ttlSeconds, value),
263
+ })) !== null && _c !== void 0 ? _c : undefined;
264
+ if (this.externalAuthClient) {
265
+ logger.debug("External OAuth client initialized");
266
+ }
267
+ }
268
+ // ============================================================================
269
+ // 3. Auth & Provider Services Initialization
270
+ // ============================================================================
271
+ async initializeClaudeServices() {
272
+ var _a, _b, _c;
273
+ if (!this.queue) {
274
+ throw new Error("Queue must be initialized before auth services");
275
+ }
276
+ const redisClient = this.queue.getRedisClient();
277
+ if (!this.agentSettingsStore) {
278
+ throw new Error("Agent settings store must be initialized before auth services");
279
+ }
280
+ if (this.fileLoadedAgents.length > 0) {
281
+ for (const agent of this.fileLoadedAgents) {
282
+ await this.syncAgentSettingsToRuntimeStore(agent.agentId, agent.settings);
283
+ }
284
+ logger.debug(`Synced settings for ${this.fileLoadedAgents.length} file-loaded agent(s)`);
285
+ }
286
+ if (this.configAgents.length > 0) {
287
+ for (const agent of this.configAgents) {
288
+ await this.syncAgentSettingsToRuntimeStore(agent.id, this.buildSettingsFromAgentConfig(agent));
289
+ }
290
+ logger.debug(`Synced settings for ${this.configAgents.length} config agent(s)`);
291
+ }
292
+ // Initialize auth profile and preference stores
293
+ this.authProfilesManager = new settings_1.AuthProfilesManager(this.agentSettingsStore);
294
+ this.transcriptionService = new transcription_service_1.TranscriptionService(this.authProfilesManager);
295
+ this.imageGenerationService = new image_generation_service_1.ImageGenerationService(this.authProfilesManager);
296
+ this.modelPreferenceStore = new model_preference_store_1.ModelPreferenceStore(redisClient, "claude");
297
+ // Seed provider credentials from file-loaded agents
298
+ if (this.authProfilesManager && this.fileLoadedAgents.length > 0) {
299
+ for (const agent of this.fileLoadedAgents) {
300
+ for (const cred of agent.credentials) {
301
+ await this.authProfilesManager.upsertProfile({
302
+ agentId: agent.agentId,
303
+ provider: cred.provider,
304
+ credential: cred.key,
305
+ authType: "api-key",
306
+ label: `${cred.provider} (from lobu.toml)`,
307
+ makePrimary: true,
308
+ });
309
+ }
310
+ }
311
+ logger.debug(`Seeded credentials for ${this.fileLoadedAgents.length} file-loaded agent(s)`);
312
+ }
313
+ // Seed provider credentials from config agents (embedded mode)
314
+ if (this.authProfilesManager && this.configAgents.length > 0) {
315
+ for (const agent of this.configAgents) {
316
+ for (const provider of agent.providers || []) {
317
+ if (!provider.key)
318
+ continue;
319
+ await this.authProfilesManager.upsertProfile({
320
+ agentId: agent.id,
321
+ provider: provider.id,
322
+ credential: provider.key,
323
+ authType: "api-key",
324
+ label: `${provider.id} (from config)`,
325
+ makePrimary: true,
326
+ });
327
+ }
328
+ }
329
+ logger.debug(`Seeded credentials for ${this.configAgents.length} config agent(s)`);
330
+ }
331
+ logger.debug("Auth profile, model preference, transcription, and image generation services initialized");
332
+ // Initialize secret injection proxy (will be finalized after provider modules are registered)
333
+ this.secretProxy = new secret_proxy_1.SecretProxy({
334
+ defaultUpstreamUrl: this.config.anthropicProxy.anthropicBaseUrl ||
335
+ "https://api.anthropic.com",
336
+ });
337
+ this.secretProxy.initialize(redisClient);
338
+ logger.debug(`Secret proxy initialized (upstream: ${this.config.anthropicProxy.anthropicBaseUrl || "https://api.anthropic.com"})`);
339
+ // Start background token refresh job
340
+ if (!this.authProfilesManager) {
341
+ throw new Error("Auth profiles manager must be initialized before token refresh job");
342
+ }
343
+ this.tokenRefreshJob = new token_refresh_job_1.TokenRefreshJob(this.authProfilesManager, redisClient, [{ providerId: "claude", oauthClient: new client_2.OAuthClient(providers_1.CLAUDE_PROVIDER) }]);
344
+ this.tokenRefreshJob.start();
345
+ logger.debug("Token refresh job started");
346
+ // Register Claude OAuth module
347
+ this.oauthStateStore = (0, state_store_1.createOAuthStateStore)("claude", redisClient);
348
+ const claudeOAuthModule = new oauth_module_1.ClaudeOAuthModule(this.authProfilesManager, this.modelPreferenceStore);
349
+ core_1.moduleRegistry.register(claudeOAuthModule);
350
+ logger.debug(`Claude OAuth module registered (system token: ${claudeOAuthModule.hasSystemKey() ? "available" : "not available"})`);
351
+ // Register ChatGPT OAuth module
352
+ const chatgptOAuthModule = new chatgpt_1.ChatGPTOAuthModule(this.agentSettingsStore);
353
+ core_1.moduleRegistry.register(chatgptOAuthModule);
354
+ logger.debug(`ChatGPT OAuth module registered (system token: ${chatgptOAuthModule.hasSystemKey() ? "available" : "not available"})`);
355
+ // Initialize system skills — use injected skills if provided, else load from file
356
+ if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.systemSkills) {
357
+ this.systemSkillsService = new system_skills_service_1.SystemSkillsService(undefined, this.options.systemSkills);
358
+ }
359
+ else {
360
+ this.systemSkillsService = new system_skills_service_1.SystemSkillsService("config/system-skills.json");
361
+ }
362
+ this.systemConfigResolver = new system_config_resolver_1.SystemConfigResolver(this.systemSkillsService);
363
+ logger.debug("System skills service initialized");
364
+ (_b = this.transcriptionService) === null || _b === void 0 ? void 0 : _b.setProviderConfigSource(() => this.systemConfigResolver
365
+ ? this.systemConfigResolver.getProviderConfigs()
366
+ : Promise.resolve({}));
367
+ // Register config-driven providers from system skills
368
+ const configProviders = await this.systemConfigResolver.getProviderConfigs();
369
+ const registeredIds = new Set((0, module_system_1.getModelProviderModules)().map((m) => m.providerId));
370
+ for (const [id, entry] of Object.entries(configProviders)) {
371
+ if (registeredIds.has(id)) {
372
+ logger.info(`Skipping config-driven provider "${id}" — already registered`);
373
+ continue;
374
+ }
375
+ const module = new api_key_provider_module_1.ApiKeyProviderModule({
376
+ providerId: id,
377
+ providerDisplayName: entry.displayName,
378
+ providerIconUrl: entry.iconUrl,
379
+ envVarName: entry.envVarName,
380
+ slug: id,
381
+ upstreamBaseUrl: entry.upstreamBaseUrl,
382
+ modelsEndpoint: entry.modelsEndpoint,
383
+ sdkCompat: entry.sdkCompat,
384
+ defaultModel: entry.defaultModel,
385
+ registryAlias: entry.registryAlias,
386
+ apiKeyInstructions: entry.apiKeyInstructions,
387
+ apiKeyPlaceholder: entry.apiKeyPlaceholder,
388
+ agentSettingsStore: this.agentSettingsStore,
389
+ });
390
+ core_1.moduleRegistry.register(module);
391
+ registeredIds.add(id);
392
+ logger.debug(`Registered config-driven provider: ${id} (system key: ${module.hasSystemKey() ? "available" : "not available"})`);
393
+ }
394
+ // Initialize provider catalog service
395
+ this.providerCatalogService = new provider_catalog_1.ProviderCatalogService(this.agentSettingsStore, this.authProfilesManager);
396
+ logger.debug("Provider catalog service initialized");
397
+ // Register provider upstream configs with the secret proxy for path-based routing
398
+ if (this.secretProxy) {
399
+ this.secretProxy.setAuthProfilesManager(this.authProfilesManager);
400
+ for (const provider of (0, module_system_1.getModelProviderModules)()) {
401
+ const upstream = (_c = provider.getUpstreamConfig) === null || _c === void 0 ? void 0 : _c.call(provider);
402
+ if (upstream) {
403
+ this.secretProxy.registerUpstream(upstream, provider.providerId);
404
+ }
405
+ }
406
+ // Register system key resolver for fallback when no per-agent auth profile exists
407
+ const modules = (0, module_system_1.getModelProviderModules)();
408
+ this.secretProxy.setSystemKeyResolver((providerId) => {
409
+ const mod = modules.find((m) => m.providerId === providerId);
410
+ if (!mod)
411
+ return undefined;
412
+ // Use the module's injectSystemKeyFallback to resolve the system key.
413
+ // The fallback may inject into a different env var than credentialEnvVarName
414
+ // (e.g., Claude injects ANTHROPIC_API_KEY, not CLAUDE_CODE_OAUTH_TOKEN),
415
+ // so check all secret env var names.
416
+ const testEnv = {};
417
+ mod.injectSystemKeyFallback(testEnv);
418
+ for (const varName of mod.getSecretEnvVarNames()) {
419
+ if (testEnv[varName])
420
+ return testEnv[varName];
421
+ }
422
+ return testEnv[mod.getCredentialEnvVarName()] || undefined;
423
+ });
424
+ logger.debug("Provider upstreams registered with secret proxy");
425
+ }
426
+ }
427
+ // ============================================================================
428
+ // 4. MCP Services Initialization
429
+ // ============================================================================
430
+ async initializeMcpServices() {
431
+ if (!this.queue) {
432
+ throw new Error("Queue must be initialized before MCP services");
433
+ }
434
+ const redisClient = this.queue.getRedisClient();
435
+ // Initialize simplified MCP config service (no OAuth discovery)
436
+ this.mcpConfigService = new config_service_1.McpConfigService({
437
+ agentSettingsStore: this.agentSettingsStore,
438
+ configResolver: this.systemConfigResolver,
439
+ });
440
+ // Initialize instruction service (needed by WorkerGateway)
441
+ this.instructionService = new instruction_service_1.InstructionService(this.mcpConfigService, this.agentSettingsStore);
442
+ logger.debug("Instruction service initialized");
443
+ // Initialize MCP tool cache and proxy
444
+ const mcpToolCache = new tool_cache_1.McpToolCache(redisClient);
445
+ this.mcpProxy = new proxy_1.McpProxy(this.mcpConfigService, this.queue, mcpToolCache, this.grantStore);
446
+ logger.debug("MCP proxy initialized");
447
+ // Initialize worker gateway
448
+ if (!this.sessionManager) {
449
+ throw new Error("Session manager must be initialized before worker gateway");
450
+ }
451
+ this.workerGateway = new gateway_1.WorkerGateway(this.queue, this.config.mcp.publicGatewayUrl, this.sessionManager, this.mcpConfigService, this.instructionService, this.mcpProxy, this.providerCatalogService, this.settingsResolver, this.systemSkillsService);
452
+ logger.debug("Worker gateway initialized");
453
+ // Discover and initialize all available modules
454
+ await core_1.moduleRegistry.registerAvailableModules();
455
+ await core_1.moduleRegistry.initAll();
456
+ logger.debug("Modules initialized");
457
+ }
458
+ // ============================================================================
459
+ // 7. Command Registry Initialization
460
+ // ============================================================================
461
+ initializeCommandRegistry() {
462
+ if (!this.agentSettingsStore) {
463
+ throw new Error("Agent settings store must be initialized before command registry");
464
+ }
465
+ this.commandRegistry = new core_1.CommandRegistry();
466
+ (0, built_in_commands_1.registerBuiltInCommands)(this.commandRegistry, {
467
+ agentSettingsStore: this.agentSettingsStore,
468
+ });
469
+ logger.debug("Command registry initialized with built-in commands");
470
+ }
471
+ // ============================================================================
472
+ // File-First Helpers
473
+ // ============================================================================
474
+ async populateStoreFromFiles(store, agents) {
475
+ for (const agent of agents) {
476
+ await store.saveMetadata(agent.agentId, {
477
+ agentId: agent.agentId,
478
+ name: agent.name,
479
+ description: agent.description,
480
+ owner: { platform: "system", userId: "manifest" },
481
+ createdAt: Date.now(),
482
+ });
483
+ await store.saveSettings(agent.agentId, Object.assign(Object.assign({}, agent.settings), { updatedAt: Date.now() }));
484
+ }
485
+ }
486
+ buildSettingsFromAgentConfig(agent) {
487
+ var _a, _b, _c;
488
+ const settings = {};
489
+ if (agent.identityMd)
490
+ settings.identityMd = agent.identityMd;
491
+ if (agent.soulMd)
492
+ settings.soulMd = agent.soulMd;
493
+ if (agent.userMd)
494
+ settings.userMd = agent.userMd;
495
+ if ((_a = agent.providers) === null || _a === void 0 ? void 0 : _a.length) {
496
+ settings.installedProviders = agent.providers.map((p) => ({
497
+ providerId: p.id,
498
+ installedAt: Date.now(),
499
+ }));
500
+ settings.modelSelection = { mode: "auto" };
501
+ const providerModelPreferences = Object.fromEntries(agent.providers
502
+ .filter((p) => { var _a; return !!((_a = p.model) === null || _a === void 0 ? void 0 : _a.trim()); })
503
+ .map((p) => [p.id, p.model.trim()]));
504
+ if (Object.keys(providerModelPreferences).length > 0) {
505
+ settings.providerModelPreferences = providerModelPreferences;
506
+ }
507
+ }
508
+ if ((_b = agent.skills) === null || _b === void 0 ? void 0 : _b.mcp) {
509
+ settings.mcpServers = agent.skills.mcp;
510
+ }
511
+ if (agent.network) {
512
+ settings.networkConfig = {
513
+ allowedDomains: agent.network.allowed,
514
+ deniedDomains: agent.network.denied,
515
+ };
516
+ }
517
+ if ((_c = agent.nixPackages) === null || _c === void 0 ? void 0 : _c.length) {
518
+ settings.nixConfig = { packages: agent.nixPackages };
519
+ }
520
+ return settings;
521
+ }
522
+ async syncAgentSettingsToRuntimeStore(agentId, settings) {
523
+ if (!this.agentSettingsStore) {
524
+ throw new Error("Agent settings store must be initialized");
525
+ }
526
+ const existing = await this.agentSettingsStore.getSettings(agentId);
527
+ await this.agentSettingsStore.saveSettings(agentId, Object.assign(Object.assign({}, settings), { authProfiles: existing === null || existing === void 0 ? void 0 : existing.authProfiles, mcpInstallNotified: existing === null || existing === void 0 ? void 0 : existing.mcpInstallNotified }));
528
+ }
529
+ async populateStoreFromAgentConfigs(store, agents) {
530
+ for (const agent of agents) {
531
+ await store.saveMetadata(agent.id, {
532
+ agentId: agent.id,
533
+ name: agent.name,
534
+ description: agent.description,
535
+ owner: { platform: "system", userId: "config" },
536
+ createdAt: Date.now(),
537
+ });
538
+ await store.saveSettings(agent.id, Object.assign(Object.assign({}, this.buildSettingsFromAgentConfig(agent)), { updatedAt: Date.now() }));
539
+ }
540
+ // Store agent configs for credential seeding and connection seeding later
541
+ this.configAgents = agents;
542
+ }
543
+ /**
544
+ * Reload agent config from files (dev mode only).
545
+ * Re-reads lobu.toml + markdown, clears and re-populates the in-memory store.
546
+ */
547
+ async reloadFromFiles() {
548
+ var _a, _b;
549
+ if (!this.projectPath) {
550
+ return { reloaded: false, agents: [] };
551
+ }
552
+ // Re-load from disk
553
+ this.fileLoadedAgents = await (0, file_loader_1.loadAgentConfigFromFiles)(this.projectPath);
554
+ // Re-populate the in-memory store (clear existing data first)
555
+ if (this.configStore instanceof in_memory_agent_store_1.InMemoryAgentStore) {
556
+ const store = this.configStore;
557
+ // Clear existing agents by loading fresh
558
+ const existing = await store.listAgents();
559
+ for (const meta of existing) {
560
+ // Only clear file-managed agents (owner: system/manifest)
561
+ if (((_a = meta.owner) === null || _a === void 0 ? void 0 : _a.platform) === "system" &&
562
+ ((_b = meta.owner) === null || _b === void 0 ? void 0 : _b.userId) === "manifest") {
563
+ await store.deleteSettings(meta.agentId);
564
+ await store.deleteMetadata(meta.agentId);
565
+ }
566
+ }
567
+ await this.populateStoreFromFiles(store, this.fileLoadedAgents);
568
+ }
569
+ if (this.agentSettingsStore) {
570
+ for (const agent of this.fileLoadedAgents) {
571
+ await this.syncAgentSettingsToRuntimeStore(agent.agentId, agent.settings);
572
+ }
573
+ }
574
+ // Re-seed credentials
575
+ if (this.authProfilesManager) {
576
+ for (const agent of this.fileLoadedAgents) {
577
+ for (const cred of agent.credentials) {
578
+ await this.authProfilesManager.upsertProfile({
579
+ agentId: agent.agentId,
580
+ provider: cred.provider,
581
+ credential: cred.key,
582
+ authType: "api-key",
583
+ label: `${cred.provider} (from lobu.toml)`,
584
+ makePrimary: true,
585
+ });
586
+ }
587
+ }
588
+ }
589
+ const agentIds = this.fileLoadedAgents.map((a) => a.agentId);
590
+ logger.info(`Reloaded ${agentIds.length} agent(s) from files`);
591
+ return { reloaded: true, agents: agentIds };
592
+ }
593
+ getFileLoadedAgents() {
594
+ return this.fileLoadedAgents;
595
+ }
596
+ getConfigAgents() {
597
+ return this.configAgents;
598
+ }
599
+ getProjectPath() {
600
+ return this.projectPath;
601
+ }
602
+ isFileFirstMode() {
603
+ return this.projectPath !== null;
604
+ }
605
+ // ============================================================================
606
+ // Shutdown
607
+ // ============================================================================
608
+ async shutdown() {
609
+ logger.info("Shutting down core services...");
610
+ if (this.tokenRefreshJob) {
611
+ this.tokenRefreshJob.stop();
612
+ }
613
+ if (this.queueProducer) {
614
+ await this.queueProducer.stop();
615
+ }
616
+ if (this.workerGateway) {
617
+ this.workerGateway.shutdown();
618
+ logger.info("Worker gateway shutdown complete");
619
+ }
620
+ if (this.queue) {
621
+ await this.queue.stop();
622
+ }
623
+ logger.info("Core services shutdown complete");
624
+ }
625
+ // ============================================================================
626
+ // Service Accessors (implements ICoreServices interface)
627
+ // ============================================================================
628
+ getQueue() {
629
+ if (!this.queue)
630
+ throw new Error("Queue not initialized");
631
+ return this.queue;
632
+ }
633
+ getQueueProducer() {
634
+ if (!this.queueProducer)
635
+ throw new Error("Queue producer not initialized");
636
+ return this.queueProducer;
637
+ }
638
+ getSecretProxy() {
639
+ return this.secretProxy;
640
+ }
641
+ getWorkerGateway() {
642
+ return this.workerGateway;
643
+ }
644
+ getMcpProxy() {
645
+ return this.mcpProxy;
646
+ }
647
+ getMcpConfigService() {
648
+ return this.mcpConfigService;
649
+ }
650
+ getModelPreferenceStore() {
651
+ return this.modelPreferenceStore;
652
+ }
653
+ getOAuthStateStore() {
654
+ return this.oauthStateStore;
655
+ }
656
+ getPublicGatewayUrl() {
657
+ return this.config.mcp.publicGatewayUrl;
658
+ }
659
+ getSessionManager() {
660
+ if (!this.sessionManager)
661
+ throw new Error("Session manager not initialized");
662
+ return this.sessionManager;
663
+ }
664
+ getInstructionService() {
665
+ return this.instructionService;
666
+ }
667
+ getInteractionService() {
668
+ if (!this.interactionService)
669
+ throw new Error("Interaction service not initialized");
670
+ return this.interactionService;
671
+ }
672
+ getAgentSettingsStore() {
673
+ if (!this.agentSettingsStore)
674
+ throw new Error("Agent settings store not initialized");
675
+ return this.agentSettingsStore;
676
+ }
677
+ getChannelBindingService() {
678
+ if (!this.channelBindingService)
679
+ throw new Error("Channel binding service not initialized");
680
+ return this.channelBindingService;
681
+ }
682
+ getScheduledWakeupService() {
683
+ return this.scheduledWakeupService;
684
+ }
685
+ getTranscriptionService() {
686
+ return this.transcriptionService;
687
+ }
688
+ getImageGenerationService() {
689
+ return this.imageGenerationService;
690
+ }
691
+ getUserAgentsStore() {
692
+ if (!this.userAgentsStore)
693
+ throw new Error("User agents store not initialized");
694
+ return this.userAgentsStore;
695
+ }
696
+ getAgentMetadataStore() {
697
+ if (!this.agentMetadataStore)
698
+ throw new Error("Agent metadata store not initialized");
699
+ return this.agentMetadataStore;
700
+ }
701
+ getCommandRegistry() {
702
+ if (!this.commandRegistry)
703
+ throw new Error("Command registry not initialized");
704
+ return this.commandRegistry;
705
+ }
706
+ getProviderCatalogService() {
707
+ if (!this.providerCatalogService)
708
+ throw new Error("Provider catalog service not initialized");
709
+ return this.providerCatalogService;
710
+ }
711
+ getAuthProfilesManager() {
712
+ return this.authProfilesManager;
713
+ }
714
+ getGrantStore() {
715
+ return this.grantStore;
716
+ }
717
+ getSystemSkillsService() {
718
+ return this.systemSkillsService;
719
+ }
720
+ getSystemConfigResolver() {
721
+ return this.systemConfigResolver;
722
+ }
723
+ getExternalAuthClient() {
724
+ return this.externalAuthClient;
725
+ }
726
+ }
727
+ exports.CoreServices = CoreServices;
728
+ //# sourceMappingURL=core-services.js.map