@hold-rein/cli 0.0.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 (420) hide show
  1. package/dist/cli.js +3 -0
  2. package/dist/cli.js.map +1 -0
  3. package/dist/index.js +139 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/runtime/api/app.d.ts +7 -0
  6. package/dist/runtime/api/app.d.ts.map +1 -0
  7. package/dist/runtime/api/app.js +41 -0
  8. package/dist/runtime/api/config/const.d.ts +8 -0
  9. package/dist/runtime/api/config/const.d.ts.map +1 -0
  10. package/dist/runtime/api/config/const.js +9 -0
  11. package/dist/runtime/api/config/env.d.ts +10 -0
  12. package/dist/runtime/api/config/env.d.ts.map +1 -0
  13. package/dist/runtime/api/config/env.js +32 -0
  14. package/dist/runtime/api/db/connection.d.ts +11 -0
  15. package/dist/runtime/api/db/connection.d.ts.map +1 -0
  16. package/dist/runtime/api/db/connection.js +21 -0
  17. package/dist/runtime/api/db/index.d.ts +4 -0
  18. package/dist/runtime/api/db/index.d.ts.map +1 -0
  19. package/dist/runtime/api/db/index.js +3 -0
  20. package/dist/runtime/api/db/migrate.d.ts +4 -0
  21. package/dist/runtime/api/db/migrate.d.ts.map +1 -0
  22. package/dist/runtime/api/db/migrate.js +308 -0
  23. package/dist/runtime/api/db/schema.d.ts +1610 -0
  24. package/dist/runtime/api/db/schema.d.ts.map +1 -0
  25. package/dist/runtime/api/db/schema.js +148 -0
  26. package/dist/runtime/api/middleware/error-middleware.d.ts +3 -0
  27. package/dist/runtime/api/middleware/error-middleware.d.ts.map +1 -0
  28. package/dist/runtime/api/middleware/error-middleware.js +5 -0
  29. package/dist/runtime/api/middleware/not-found-middleware.d.ts +3 -0
  30. package/dist/runtime/api/middleware/not-found-middleware.d.ts.map +1 -0
  31. package/dist/runtime/api/middleware/not-found-middleware.js +4 -0
  32. package/dist/runtime/api/modules/agents/active-task-run-registry.d.ts +10 -0
  33. package/dist/runtime/api/modules/agents/active-task-run-registry.d.ts.map +1 -0
  34. package/dist/runtime/api/modules/agents/active-task-run-registry.js +20 -0
  35. package/dist/runtime/api/modules/agents/agent-approval-store.d.ts +7 -0
  36. package/dist/runtime/api/modules/agents/agent-approval-store.d.ts.map +1 -0
  37. package/dist/runtime/api/modules/agents/agent-approval-store.js +23 -0
  38. package/dist/runtime/api/modules/agents/agent-event-bus.d.ts +8 -0
  39. package/dist/runtime/api/modules/agents/agent-event-bus.d.ts.map +1 -0
  40. package/dist/runtime/api/modules/agents/agent-event-bus.js +40 -0
  41. package/dist/runtime/api/modules/agents/agent-message-repository.d.ts +22 -0
  42. package/dist/runtime/api/modules/agents/agent-message-repository.d.ts.map +1 -0
  43. package/dist/runtime/api/modules/agents/agent-message-repository.js +60 -0
  44. package/dist/runtime/api/modules/agents/agent-message-storage.d.ts +4 -0
  45. package/dist/runtime/api/modules/agents/agent-message-storage.d.ts.map +1 -0
  46. package/dist/runtime/api/modules/agents/agent-message-storage.js +11 -0
  47. package/dist/runtime/api/modules/agents/agent-model-resolver.d.ts +4 -0
  48. package/dist/runtime/api/modules/agents/agent-model-resolver.d.ts.map +1 -0
  49. package/dist/runtime/api/modules/agents/agent-model-resolver.js +17 -0
  50. package/dist/runtime/api/modules/agents/agent-runtime-messages.d.ts +12 -0
  51. package/dist/runtime/api/modules/agents/agent-runtime-messages.d.ts.map +1 -0
  52. package/dist/runtime/api/modules/agents/agent-runtime-messages.js +19 -0
  53. package/dist/runtime/api/modules/agents/agent-runtime-support.d.ts +12 -0
  54. package/dist/runtime/api/modules/agents/agent-runtime-support.d.ts.map +1 -0
  55. package/dist/runtime/api/modules/agents/agent-runtime-support.js +38 -0
  56. package/dist/runtime/api/modules/agents/agent-runtime.d.ts +25 -0
  57. package/dist/runtime/api/modules/agents/agent-runtime.d.ts.map +1 -0
  58. package/dist/runtime/api/modules/agents/agent-runtime.js +371 -0
  59. package/dist/runtime/api/modules/agents/agent-subagents.d.ts +32 -0
  60. package/dist/runtime/api/modules/agents/agent-subagents.d.ts.map +1 -0
  61. package/dist/runtime/api/modules/agents/agent-subagents.js +65 -0
  62. package/dist/runtime/api/modules/agents/agent-task-actions.d.ts +9 -0
  63. package/dist/runtime/api/modules/agents/agent-task-actions.d.ts.map +1 -0
  64. package/dist/runtime/api/modules/agents/agent-task-actions.js +33 -0
  65. package/dist/runtime/api/modules/agents/agent-task-title-generator.d.ts +15 -0
  66. package/dist/runtime/api/modules/agents/agent-task-title-generator.d.ts.map +1 -0
  67. package/dist/runtime/api/modules/agents/agent-task-title-generator.js +61 -0
  68. package/dist/runtime/api/modules/agents/agent-tool-approval.d.ts +12 -0
  69. package/dist/runtime/api/modules/agents/agent-tool-approval.d.ts.map +1 -0
  70. package/dist/runtime/api/modules/agents/agent-tool-approval.js +40 -0
  71. package/dist/runtime/api/modules/agents/agent-types.d.ts +198 -0
  72. package/dist/runtime/api/modules/agents/agent-types.d.ts.map +1 -0
  73. package/dist/runtime/api/modules/agents/agent-types.js +1 -0
  74. package/dist/runtime/api/modules/agents/agents-router.d.ts +7 -0
  75. package/dist/runtime/api/modules/agents/agents-router.d.ts.map +1 -0
  76. package/dist/runtime/api/modules/agents/agents-router.js +210 -0
  77. package/dist/runtime/api/modules/agents/agents-service.d.ts +52 -0
  78. package/dist/runtime/api/modules/agents/agents-service.d.ts.map +1 -0
  79. package/dist/runtime/api/modules/agents/agents-service.js +282 -0
  80. package/dist/runtime/api/modules/agents/approval/store.d.ts +7 -0
  81. package/dist/runtime/api/modules/agents/approval/store.d.ts.map +1 -0
  82. package/dist/runtime/api/modules/agents/approval/store.js +23 -0
  83. package/dist/runtime/api/modules/agents/approval/tool-approval.d.ts +14 -0
  84. package/dist/runtime/api/modules/agents/approval/tool-approval.d.ts.map +1 -0
  85. package/dist/runtime/api/modules/agents/approval/tool-approval.js +43 -0
  86. package/dist/runtime/api/modules/agents/custom-agent-model.d.ts +16 -0
  87. package/dist/runtime/api/modules/agents/custom-agent-model.d.ts.map +1 -0
  88. package/dist/runtime/api/modules/agents/custom-agent-model.js +21 -0
  89. package/dist/runtime/api/modules/agents/default-agents-service.d.ts +3 -0
  90. package/dist/runtime/api/modules/agents/default-agents-service.d.ts.map +1 -0
  91. package/dist/runtime/api/modules/agents/default-agents-service.js +52 -0
  92. package/dist/runtime/api/modules/agents/event/event-bus.d.ts +8 -0
  93. package/dist/runtime/api/modules/agents/event/event-bus.d.ts.map +1 -0
  94. package/dist/runtime/api/modules/agents/event/event-bus.js +40 -0
  95. package/dist/runtime/api/modules/agents/index.d.ts +11 -0
  96. package/dist/runtime/api/modules/agents/index.d.ts.map +1 -0
  97. package/dist/runtime/api/modules/agents/index.js +9 -0
  98. package/dist/runtime/api/modules/agents/message/storage.d.ts +4 -0
  99. package/dist/runtime/api/modules/agents/message/storage.d.ts.map +1 -0
  100. package/dist/runtime/api/modules/agents/message/storage.js +11 -0
  101. package/dist/runtime/api/modules/agents/model/custom-model.d.ts +16 -0
  102. package/dist/runtime/api/modules/agents/model/custom-model.d.ts.map +1 -0
  103. package/dist/runtime/api/modules/agents/model/custom-model.js +21 -0
  104. package/dist/runtime/api/modules/agents/model/resolver.d.ts +4 -0
  105. package/dist/runtime/api/modules/agents/model/resolver.d.ts.map +1 -0
  106. package/dist/runtime/api/modules/agents/model/resolver.js +17 -0
  107. package/dist/runtime/api/modules/agents/router/browser-tool-result.d.ts +8 -0
  108. package/dist/runtime/api/modules/agents/router/browser-tool-result.d.ts.map +1 -0
  109. package/dist/runtime/api/modules/agents/router/browser-tool-result.js +35 -0
  110. package/dist/runtime/api/modules/agents/router/index.d.ts +10 -0
  111. package/dist/runtime/api/modules/agents/router/index.d.ts.map +1 -0
  112. package/dist/runtime/api/modules/agents/router/index.js +210 -0
  113. package/dist/runtime/api/modules/agents/router/request-parsing.d.ts +24 -0
  114. package/dist/runtime/api/modules/agents/router/request-parsing.d.ts.map +1 -0
  115. package/dist/runtime/api/modules/agents/router/request-parsing.js +78 -0
  116. package/dist/runtime/api/modules/agents/runtime/browser-runtime-contributions.d.ts +5 -0
  117. package/dist/runtime/api/modules/agents/runtime/browser-runtime-contributions.d.ts.map +1 -0
  118. package/dist/runtime/api/modules/agents/runtime/browser-runtime-contributions.js +115 -0
  119. package/dist/runtime/api/modules/agents/runtime/browser-runtime-tools.d.ts +13 -0
  120. package/dist/runtime/api/modules/agents/runtime/browser-runtime-tools.d.ts.map +1 -0
  121. package/dist/runtime/api/modules/agents/runtime/browser-runtime-tools.js +31 -0
  122. package/dist/runtime/api/modules/agents/runtime/browser-tool-call-store.d.ts +21 -0
  123. package/dist/runtime/api/modules/agents/runtime/browser-tool-call-store.d.ts.map +1 -0
  124. package/dist/runtime/api/modules/agents/runtime/browser-tool-call-store.js +69 -0
  125. package/dist/runtime/api/modules/agents/runtime/continuation-subagent.d.ts +26 -0
  126. package/dist/runtime/api/modules/agents/runtime/continuation-subagent.d.ts.map +1 -0
  127. package/dist/runtime/api/modules/agents/runtime/continuation-subagent.js +67 -0
  128. package/dist/runtime/api/modules/agents/runtime/index.d.ts +3 -0
  129. package/dist/runtime/api/modules/agents/runtime/index.d.ts.map +1 -0
  130. package/dist/runtime/api/modules/agents/runtime/index.js +432 -0
  131. package/dist/runtime/api/modules/agents/runtime/messages.d.ts +12 -0
  132. package/dist/runtime/api/modules/agents/runtime/messages.d.ts.map +1 -0
  133. package/dist/runtime/api/modules/agents/runtime/messages.js +19 -0
  134. package/dist/runtime/api/modules/agents/runtime/subagent-results.d.ts +22 -0
  135. package/dist/runtime/api/modules/agents/runtime/subagent-results.d.ts.map +1 -0
  136. package/dist/runtime/api/modules/agents/runtime/subagent-results.js +39 -0
  137. package/dist/runtime/api/modules/agents/runtime/subagent-tools.d.ts +49 -0
  138. package/dist/runtime/api/modules/agents/runtime/subagent-tools.d.ts.map +1 -0
  139. package/dist/runtime/api/modules/agents/runtime/subagent-tools.js +195 -0
  140. package/dist/runtime/api/modules/agents/runtime/support.d.ts +19 -0
  141. package/dist/runtime/api/modules/agents/runtime/support.d.ts.map +1 -0
  142. package/dist/runtime/api/modules/agents/runtime/support.js +106 -0
  143. package/dist/runtime/api/modules/agents/runtime/token-collection.d.ts +28 -0
  144. package/dist/runtime/api/modules/agents/runtime/token-collection.d.ts.map +1 -0
  145. package/dist/runtime/api/modules/agents/runtime/token-collection.js +131 -0
  146. package/dist/runtime/api/modules/agents/runtime/token-usage-sync.d.ts +15 -0
  147. package/dist/runtime/api/modules/agents/runtime/token-usage-sync.d.ts.map +1 -0
  148. package/dist/runtime/api/modules/agents/runtime/token-usage-sync.js +46 -0
  149. package/dist/runtime/api/modules/agents/runtime/type.d.ts +62 -0
  150. package/dist/runtime/api/modules/agents/runtime/type.d.ts.map +1 -0
  151. package/dist/runtime/api/modules/agents/runtime/type.js +1 -0
  152. package/dist/runtime/api/modules/agents/runtime/workspace-agent-instructions.d.ts +3 -0
  153. package/dist/runtime/api/modules/agents/runtime/workspace-agent-instructions.d.ts.map +1 -0
  154. package/dist/runtime/api/modules/agents/runtime/workspace-agent-instructions.js +31 -0
  155. package/dist/runtime/api/modules/agents/service/default.d.ts +3 -0
  156. package/dist/runtime/api/modules/agents/service/default.d.ts.map +1 -0
  157. package/dist/runtime/api/modules/agents/service/default.js +65 -0
  158. package/dist/runtime/api/modules/agents/service/index.d.ts +56 -0
  159. package/dist/runtime/api/modules/agents/service/index.d.ts.map +1 -0
  160. package/dist/runtime/api/modules/agents/service/index.js +296 -0
  161. package/dist/runtime/api/modules/agents/service/interrupt-task.d.ts +14 -0
  162. package/dist/runtime/api/modules/agents/service/interrupt-task.d.ts.map +1 -0
  163. package/dist/runtime/api/modules/agents/service/interrupt-task.js +34 -0
  164. package/dist/runtime/api/modules/agents/service/startup-recovery.d.ts +14 -0
  165. package/dist/runtime/api/modules/agents/service/startup-recovery.d.ts.map +1 -0
  166. package/dist/runtime/api/modules/agents/service/startup-recovery.js +15 -0
  167. package/dist/runtime/api/modules/agents/shell-command-risk.d.ts +3 -0
  168. package/dist/runtime/api/modules/agents/shell-command-risk.d.ts.map +1 -0
  169. package/dist/runtime/api/modules/agents/shell-command-risk.js +24 -0
  170. package/dist/runtime/api/modules/agents/shell-exec-tool.d.ts +4 -0
  171. package/dist/runtime/api/modules/agents/shell-exec-tool.d.ts.map +1 -0
  172. package/dist/runtime/api/modules/agents/shell-exec-tool.js +71 -0
  173. package/dist/runtime/api/modules/agents/subagent/index.d.ts +45 -0
  174. package/dist/runtime/api/modules/agents/subagent/index.d.ts.map +1 -0
  175. package/dist/runtime/api/modules/agents/subagent/index.js +143 -0
  176. package/dist/runtime/api/modules/agents/subagent/lifecycle.d.ts +13 -0
  177. package/dist/runtime/api/modules/agents/subagent/lifecycle.d.ts.map +1 -0
  178. package/dist/runtime/api/modules/agents/subagent/lifecycle.js +36 -0
  179. package/dist/runtime/api/modules/agents/subagent/repository.d.ts +12 -0
  180. package/dist/runtime/api/modules/agents/subagent/repository.d.ts.map +1 -0
  181. package/dist/runtime/api/modules/agents/subagent/repository.js +93 -0
  182. package/dist/runtime/api/modules/agents/subagent-repository.d.ts +11 -0
  183. package/dist/runtime/api/modules/agents/subagent-repository.d.ts.map +1 -0
  184. package/dist/runtime/api/modules/agents/subagent-repository.js +65 -0
  185. package/dist/runtime/api/modules/agents/task/actions.d.ts +10 -0
  186. package/dist/runtime/api/modules/agents/task/actions.d.ts.map +1 -0
  187. package/dist/runtime/api/modules/agents/task/actions.js +37 -0
  188. package/dist/runtime/api/modules/agents/task/active-run-registry.d.ts +10 -0
  189. package/dist/runtime/api/modules/agents/task/active-run-registry.d.ts.map +1 -0
  190. package/dist/runtime/api/modules/agents/task/active-run-registry.js +20 -0
  191. package/dist/runtime/api/modules/agents/task/run-monitor.d.ts +14 -0
  192. package/dist/runtime/api/modules/agents/task/run-monitor.d.ts.map +1 -0
  193. package/dist/runtime/api/modules/agents/task/run-monitor.js +42 -0
  194. package/dist/runtime/api/modules/agents/task/title-generator.d.ts +15 -0
  195. package/dist/runtime/api/modules/agents/task/title-generator.d.ts.map +1 -0
  196. package/dist/runtime/api/modules/agents/task/title-generator.js +61 -0
  197. package/dist/runtime/api/modules/agents/task-run-monitor.d.ts +14 -0
  198. package/dist/runtime/api/modules/agents/task-run-monitor.d.ts.map +1 -0
  199. package/dist/runtime/api/modules/agents/task-run-monitor.js +42 -0
  200. package/dist/runtime/api/modules/file-system/file-system-router.d.ts +6 -0
  201. package/dist/runtime/api/modules/file-system/file-system-router.d.ts.map +1 -0
  202. package/dist/runtime/api/modules/file-system/file-system-router.js +119 -0
  203. package/dist/runtime/api/modules/file-system/file-system-service.d.ts +30 -0
  204. package/dist/runtime/api/modules/file-system/file-system-service.d.ts.map +1 -0
  205. package/dist/runtime/api/modules/file-system/file-system-service.js +209 -0
  206. package/dist/runtime/api/modules/file-system/index.d.ts +4 -0
  207. package/dist/runtime/api/modules/file-system/index.d.ts.map +1 -0
  208. package/dist/runtime/api/modules/file-system/index.js +1 -0
  209. package/dist/runtime/api/modules/health/health-router.d.ts +3 -0
  210. package/dist/runtime/api/modules/health/health-router.d.ts.map +1 -0
  211. package/dist/runtime/api/modules/health/health-router.js +10 -0
  212. package/dist/runtime/api/modules/health/index.d.ts +2 -0
  213. package/dist/runtime/api/modules/health/index.d.ts.map +1 -0
  214. package/dist/runtime/api/modules/health/index.js +1 -0
  215. package/dist/runtime/api/modules/model-providers/default-model-provider-service.d.ts +3 -0
  216. package/dist/runtime/api/modules/model-providers/default-model-provider-service.d.ts.map +1 -0
  217. package/dist/runtime/api/modules/model-providers/default-model-provider-service.js +21 -0
  218. package/dist/runtime/api/modules/model-providers/index.d.ts +5 -0
  219. package/dist/runtime/api/modules/model-providers/index.d.ts.map +1 -0
  220. package/dist/runtime/api/modules/model-providers/index.js +4 -0
  221. package/dist/runtime/api/modules/model-providers/model-provider-api-key-crypto.d.ts +8 -0
  222. package/dist/runtime/api/modules/model-providers/model-provider-api-key-crypto.d.ts.map +1 -0
  223. package/dist/runtime/api/modules/model-providers/model-provider-api-key-crypto.js +35 -0
  224. package/dist/runtime/api/modules/model-providers/model-provider-repository.d.ts +51 -0
  225. package/dist/runtime/api/modules/model-providers/model-provider-repository.d.ts.map +1 -0
  226. package/dist/runtime/api/modules/model-providers/model-provider-repository.js +314 -0
  227. package/dist/runtime/api/modules/model-providers/model-providers-router.d.ts +9 -0
  228. package/dist/runtime/api/modules/model-providers/model-providers-router.d.ts.map +1 -0
  229. package/dist/runtime/api/modules/model-providers/model-providers-router.js +188 -0
  230. package/dist/runtime/api/modules/model-providers/model-providers-service.d.ts +52 -0
  231. package/dist/runtime/api/modules/model-providers/model-providers-service.d.ts.map +1 -0
  232. package/dist/runtime/api/modules/model-providers/model-providers-service.js +239 -0
  233. package/dist/runtime/api/modules/model-proxies/default-model-proxies-service.d.ts +3 -0
  234. package/dist/runtime/api/modules/model-proxies/default-model-proxies-service.d.ts.map +1 -0
  235. package/dist/runtime/api/modules/model-proxies/default-model-proxies-service.js +22 -0
  236. package/dist/runtime/api/modules/model-proxies/index.d.ts +5 -0
  237. package/dist/runtime/api/modules/model-proxies/index.d.ts.map +1 -0
  238. package/dist/runtime/api/modules/model-proxies/index.js +4 -0
  239. package/dist/runtime/api/modules/model-proxies/model-proxies-router.d.ts +7 -0
  240. package/dist/runtime/api/modules/model-proxies/model-proxies-router.d.ts.map +1 -0
  241. package/dist/runtime/api/modules/model-proxies/model-proxies-router.js +55 -0
  242. package/dist/runtime/api/modules/model-proxies/model-proxies-service.d.ts +26 -0
  243. package/dist/runtime/api/modules/model-proxies/model-proxies-service.d.ts.map +1 -0
  244. package/dist/runtime/api/modules/model-proxies/model-proxies-service.js +107 -0
  245. package/dist/runtime/api/modules/model-proxies/model-proxy-repository.d.ts +39 -0
  246. package/dist/runtime/api/modules/model-proxies/model-proxy-repository.d.ts.map +1 -0
  247. package/dist/runtime/api/modules/model-proxies/model-proxy-repository.js +146 -0
  248. package/dist/runtime/api/modules/model-proxies/model-proxy-runtime.d.ts +20 -0
  249. package/dist/runtime/api/modules/model-proxies/model-proxy-runtime.d.ts.map +1 -0
  250. package/dist/runtime/api/modules/model-proxies/model-proxy-runtime.js +45 -0
  251. package/dist/runtime/api/modules/plugins/plugins-router.d.ts +7 -0
  252. package/dist/runtime/api/modules/plugins/plugins-router.d.ts.map +1 -0
  253. package/dist/runtime/api/modules/plugins/plugins-router.js +11 -0
  254. package/dist/runtime/api/modules/skills/default-skills-service.d.ts +3 -0
  255. package/dist/runtime/api/modules/skills/default-skills-service.d.ts.map +1 -0
  256. package/dist/runtime/api/modules/skills/default-skills-service.js +9 -0
  257. package/dist/runtime/api/modules/skills/index.d.ts +5 -0
  258. package/dist/runtime/api/modules/skills/index.d.ts.map +1 -0
  259. package/dist/runtime/api/modules/skills/index.js +3 -0
  260. package/dist/runtime/api/modules/skills/skills-router.d.ts +7 -0
  261. package/dist/runtime/api/modules/skills/skills-router.d.ts.map +1 -0
  262. package/dist/runtime/api/modules/skills/skills-router.js +56 -0
  263. package/dist/runtime/api/modules/skills/skills-service.d.ts +7 -0
  264. package/dist/runtime/api/modules/skills/skills-service.d.ts.map +1 -0
  265. package/dist/runtime/api/modules/skills/skills-service.js +264 -0
  266. package/dist/runtime/api/modules/skills/skills-types.d.ts +22 -0
  267. package/dist/runtime/api/modules/skills/skills-types.d.ts.map +1 -0
  268. package/dist/runtime/api/modules/skills/skills-types.js +1 -0
  269. package/dist/runtime/api/modules/usage-stats/default-usage-stats-service.d.ts +3 -0
  270. package/dist/runtime/api/modules/usage-stats/default-usage-stats-service.d.ts.map +1 -0
  271. package/dist/runtime/api/modules/usage-stats/default-usage-stats-service.js +17 -0
  272. package/dist/runtime/api/modules/usage-stats/index.d.ts +4 -0
  273. package/dist/runtime/api/modules/usage-stats/index.d.ts.map +1 -0
  274. package/dist/runtime/api/modules/usage-stats/index.js +2 -0
  275. package/dist/runtime/api/modules/usage-stats/usage-stats-router.d.ts +7 -0
  276. package/dist/runtime/api/modules/usage-stats/usage-stats-router.d.ts.map +1 -0
  277. package/dist/runtime/api/modules/usage-stats/usage-stats-router.js +42 -0
  278. package/dist/runtime/api/modules/usage-stats/usage-stats-service.d.ts +40 -0
  279. package/dist/runtime/api/modules/usage-stats/usage-stats-service.d.ts.map +1 -0
  280. package/dist/runtime/api/modules/usage-stats/usage-stats-service.js +144 -0
  281. package/dist/runtime/api/modules/usage-stats/usage-stats-types.d.ts +39 -0
  282. package/dist/runtime/api/modules/usage-stats/usage-stats-types.d.ts.map +1 -0
  283. package/dist/runtime/api/modules/usage-stats/usage-stats-types.js +1 -0
  284. package/dist/runtime/api/modules/workspaces/default-workspaces-service.d.ts +3 -0
  285. package/dist/runtime/api/modules/workspaces/default-workspaces-service.d.ts.map +1 -0
  286. package/dist/runtime/api/modules/workspaces/default-workspaces-service.js +20 -0
  287. package/dist/runtime/api/modules/workspaces/index.d.ts +6 -0
  288. package/dist/runtime/api/modules/workspaces/index.d.ts.map +1 -0
  289. package/dist/runtime/api/modules/workspaces/index.js +5 -0
  290. package/dist/runtime/api/modules/workspaces/workspace-repository.d.ts +41 -0
  291. package/dist/runtime/api/modules/workspaces/workspace-repository.d.ts.map +1 -0
  292. package/dist/runtime/api/modules/workspaces/workspace-repository.js +326 -0
  293. package/dist/runtime/api/modules/workspaces/workspace-types.d.ts +33 -0
  294. package/dist/runtime/api/modules/workspaces/workspace-types.d.ts.map +1 -0
  295. package/dist/runtime/api/modules/workspaces/workspace-types.js +1 -0
  296. package/dist/runtime/api/modules/workspaces/workspaces-router.d.ts +7 -0
  297. package/dist/runtime/api/modules/workspaces/workspaces-router.d.ts.map +1 -0
  298. package/dist/runtime/api/modules/workspaces/workspaces-router.js +71 -0
  299. package/dist/runtime/api/modules/workspaces/workspaces-service.d.ts +24 -0
  300. package/dist/runtime/api/modules/workspaces/workspaces-service.d.ts.map +1 -0
  301. package/dist/runtime/api/modules/workspaces/workspaces-service.js +109 -0
  302. package/dist/runtime/api/plugin.d.ts +5 -0
  303. package/dist/runtime/api/plugin.d.ts.map +1 -0
  304. package/dist/runtime/api/plugin.js +48 -0
  305. package/dist/runtime/api/response/api-response.d.ts +11 -0
  306. package/dist/runtime/api/response/api-response.d.ts.map +1 -0
  307. package/dist/runtime/api/response/api-response.js +18 -0
  308. package/dist/runtime/api/response/index.d.ts +3 -0
  309. package/dist/runtime/api/response/index.d.ts.map +1 -0
  310. package/dist/runtime/api/response/index.js +2 -0
  311. package/dist/runtime/api/response/response-codes.d.ts +52 -0
  312. package/dist/runtime/api/response/response-codes.d.ts.map +1 -0
  313. package/dist/runtime/api/response/response-codes.js +44 -0
  314. package/dist/runtime/api/router/v1/index.d.ts +12 -0
  315. package/dist/runtime/api/router/v1/index.d.ts.map +1 -0
  316. package/dist/runtime/api/router/v1/index.js +26 -0
  317. package/dist/runtime/api/runtime.d.ts +15 -0
  318. package/dist/runtime/api/runtime.d.ts.map +1 -0
  319. package/dist/runtime/api/runtime.js +30 -0
  320. package/dist/runtime/api/server.d.ts +2 -0
  321. package/dist/runtime/api/server.d.ts.map +1 -0
  322. package/dist/runtime/api/server.js +14 -0
  323. package/dist/runtime/api/service/health-service.d.ts +7 -0
  324. package/dist/runtime/api/service/health-service.d.ts.map +1 -0
  325. package/dist/runtime/api/service/health-service.js +7 -0
  326. package/dist/runtime/web/assets/abap-DLDM7-KI.js +1 -0
  327. package/dist/runtime/web/assets/apex-DNDY2TF8.js +1 -0
  328. package/dist/runtime/web/assets/azcli-Y6nb8tq_.js +1 -0
  329. package/dist/runtime/web/assets/bat-BwHxbl9M.js +1 -0
  330. package/dist/runtime/web/assets/bicep-CFznDFnq.js +2 -0
  331. package/dist/runtime/web/assets/cameligo-Bf6VGUru.js +1 -0
  332. package/dist/runtime/web/assets/clojure-Dnu-v4kV.js +1 -0
  333. package/dist/runtime/web/assets/codicon-ngg6Pgfi.ttf +0 -0
  334. package/dist/runtime/web/assets/coffee-Bd8akH9Z.js +1 -0
  335. package/dist/runtime/web/assets/cpp-BbWJElDN.js +1 -0
  336. package/dist/runtime/web/assets/csharp-Co3qMtFm.js +1 -0
  337. package/dist/runtime/web/assets/csp-D-4FJmMZ.js +1 -0
  338. package/dist/runtime/web/assets/css-DdJfP1eB.js +3 -0
  339. package/dist/runtime/web/assets/css.worker-B4z49cGk.js +93 -0
  340. package/dist/runtime/web/assets/cssMode-w2xbbUEW.js +1 -0
  341. package/dist/runtime/web/assets/cypher-cTPe9QuQ.js +1 -0
  342. package/dist/runtime/web/assets/dart-BOtBlQCF.js +1 -0
  343. package/dist/runtime/web/assets/dockerfile-BG73LgW2.js +1 -0
  344. package/dist/runtime/web/assets/ecl-BEgZUVRK.js +1 -0
  345. package/dist/runtime/web/assets/elixir-BkW5O-1t.js +1 -0
  346. package/dist/runtime/web/assets/flow9-BeJ5waoc.js +1 -0
  347. package/dist/runtime/web/assets/freemarker2-mywz2bob.js +3 -0
  348. package/dist/runtime/web/assets/fsharp-PahG7c26.js +1 -0
  349. package/dist/runtime/web/assets/go-acbASCJo.js +1 -0
  350. package/dist/runtime/web/assets/graphql-BxJiqAUM.js +1 -0
  351. package/dist/runtime/web/assets/handlebars-Cy-2QN_R.js +1 -0
  352. package/dist/runtime/web/assets/hcl-DtV1sZF8.js +1 -0
  353. package/dist/runtime/web/assets/html-2WQMGvns.js +1 -0
  354. package/dist/runtime/web/assets/html.worker-DtiGdgqp.js +470 -0
  355. package/dist/runtime/web/assets/htmlMode-BznIdxOy.js +1 -0
  356. package/dist/runtime/web/assets/index-CQ_mZUpS.css +1 -0
  357. package/dist/runtime/web/assets/index-CtZcItCu.js +1512 -0
  358. package/dist/runtime/web/assets/ini-Kd9XrMLS.js +1 -0
  359. package/dist/runtime/web/assets/java-CXBNlu9o.js +1 -0
  360. package/dist/runtime/web/assets/javascript-BK6G_5BV.js +1 -0
  361. package/dist/runtime/web/assets/json.worker-leyajbqV.js +58 -0
  362. package/dist/runtime/web/assets/jsonMode-DI8_Cj0K.js +7 -0
  363. package/dist/runtime/web/assets/julia-cl7-CwDS.js +1 -0
  364. package/dist/runtime/web/assets/kotlin-s7OhZKlX.js +1 -0
  365. package/dist/runtime/web/assets/less-9HpZscsL.js +2 -0
  366. package/dist/runtime/web/assets/lexon-OrD6JF1K.js +1 -0
  367. package/dist/runtime/web/assets/liquid-CE7Qnc0w.js +1 -0
  368. package/dist/runtime/web/assets/lspLanguageFeatures-DKvGiYOU.js +4 -0
  369. package/dist/runtime/web/assets/lua-Cyyb5UIc.js +1 -0
  370. package/dist/runtime/web/assets/m3-B8OfTtLu.js +1 -0
  371. package/dist/runtime/web/assets/markdown-BFxVWTOG.js +1 -0
  372. package/dist/runtime/web/assets/mdx-Fk0ZjYeT.js +1 -0
  373. package/dist/runtime/web/assets/mips-CiqrrVzr.js +1 -0
  374. package/dist/runtime/web/assets/msdax-DmeGPVcC.js +1 -0
  375. package/dist/runtime/web/assets/mysql-C_tMU-Nz.js +1 -0
  376. package/dist/runtime/web/assets/objective-c-BDtDVThU.js +1 -0
  377. package/dist/runtime/web/assets/pascal-vHIfCaH5.js +1 -0
  378. package/dist/runtime/web/assets/pascaligo-DtZ0uQbO.js +1 -0
  379. package/dist/runtime/web/assets/perl-Ub6l9XKa.js +1 -0
  380. package/dist/runtime/web/assets/pgsql-BlNEE0v7.js +1 -0
  381. package/dist/runtime/web/assets/php-BBUBE1dy.js +1 -0
  382. package/dist/runtime/web/assets/pla-DSh2-awV.js +1 -0
  383. package/dist/runtime/web/assets/postiats-CocnycG-.js +1 -0
  384. package/dist/runtime/web/assets/powerquery-tScXyioY.js +1 -0
  385. package/dist/runtime/web/assets/powershell-COWaemsV.js +1 -0
  386. package/dist/runtime/web/assets/protobuf-Brw8urJB.js +2 -0
  387. package/dist/runtime/web/assets/pug-8SOpv6rk.js +1 -0
  388. package/dist/runtime/web/assets/python-xn7eKnQc.js +1 -0
  389. package/dist/runtime/web/assets/qsharp-Bw9ernYp.js +1 -0
  390. package/dist/runtime/web/assets/r-j7ic8hl3.js +1 -0
  391. package/dist/runtime/web/assets/razor-BjC5fot0.js +1 -0
  392. package/dist/runtime/web/assets/redis-Bu5POkcn.js +1 -0
  393. package/dist/runtime/web/assets/redshift-Bs9aos_-.js +1 -0
  394. package/dist/runtime/web/assets/restructuredtext-CqXO7rUv.js +1 -0
  395. package/dist/runtime/web/assets/ruby-zBfavPgS.js +1 -0
  396. package/dist/runtime/web/assets/rust-BzKRNQWT.js +1 -0
  397. package/dist/runtime/web/assets/sb-BBc9UKZt.js +1 -0
  398. package/dist/runtime/web/assets/scala-D9hQfWCl.js +1 -0
  399. package/dist/runtime/web/assets/scheme-BPhDTwHR.js +1 -0
  400. package/dist/runtime/web/assets/scss-CBJaRo0y.js +3 -0
  401. package/dist/runtime/web/assets/shell-DiJ1NA_G.js +1 -0
  402. package/dist/runtime/web/assets/solidity-Db0IVjzk.js +1 -0
  403. package/dist/runtime/web/assets/sophia-CnS9iZB_.js +1 -0
  404. package/dist/runtime/web/assets/sparql-CJmd_6j2.js +1 -0
  405. package/dist/runtime/web/assets/sql-ClhHkBeG.js +1 -0
  406. package/dist/runtime/web/assets/st-CHwy0fLd.js +1 -0
  407. package/dist/runtime/web/assets/swift-Bqt4WxQ4.js +3 -0
  408. package/dist/runtime/web/assets/systemverilog-Bs9z6M-B.js +1 -0
  409. package/dist/runtime/web/assets/tcl-Dm6ycUr_.js +1 -0
  410. package/dist/runtime/web/assets/ts.worker-59MjiAqk.js +67731 -0
  411. package/dist/runtime/web/assets/tsMode-8t6AIduV.js +11 -0
  412. package/dist/runtime/web/assets/twig-Csy3S7wG.js +1 -0
  413. package/dist/runtime/web/assets/typescript-DvPPogGC.js +1 -0
  414. package/dist/runtime/web/assets/typespec-Btyra-wh.js +1 -0
  415. package/dist/runtime/web/assets/vb-Db0cS2oM.js +1 -0
  416. package/dist/runtime/web/assets/wgsl-BTesnYfV.js +298 -0
  417. package/dist/runtime/web/assets/xml-CB8xdh8u.js +1 -0
  418. package/dist/runtime/web/assets/yaml-B4sXC4FA.js +1 -0
  419. package/dist/runtime/web/index.html +13 -0
  420. package/package.json +42 -0
@@ -0,0 +1,8 @@
1
+ export interface EncryptedApiKey {
2
+ ciphertext: string;
3
+ iv: string;
4
+ tag: string;
5
+ }
6
+ export declare function decryptProviderApiKey(encryptedApiKey: EncryptedApiKey, base64EncodedKey: string): string;
7
+ export declare function encryptProviderApiKey(apiKey: string, base64EncodedKey: string): EncryptedApiKey;
8
+ //# sourceMappingURL=model-provider-api-key-crypto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-provider-api-key-crypto.d.ts","sourceRoot":"","sources":["../../../src/modules/model-providers/model-provider-api-key-crypto.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,eAAe,EAChC,gBAAgB,EAAE,MAAM,GACvB,MAAM,CAgBR;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,GACvB,eAAe,CAcjB"}
@@ -0,0 +1,35 @@
1
+ import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
2
+ const ALGORITHM = "aes-256-gcm";
3
+ const IV_LENGTH = 12;
4
+ const KEY_LENGTH = 32;
5
+ export function decryptProviderApiKey(encryptedApiKey, base64EncodedKey) {
6
+ const key = decodeEncryptionKey(base64EncodedKey);
7
+ const decipher = createDecipheriv(ALGORITHM, key, Buffer.from(encryptedApiKey.iv, "base64"));
8
+ decipher.setAuthTag(Buffer.from(encryptedApiKey.tag, "base64"));
9
+ const plaintext = Buffer.concat([
10
+ decipher.update(Buffer.from(encryptedApiKey.ciphertext, "base64")),
11
+ decipher.final()
12
+ ]);
13
+ return plaintext.toString("utf8");
14
+ }
15
+ export function encryptProviderApiKey(apiKey, base64EncodedKey) {
16
+ const key = decodeEncryptionKey(base64EncodedKey);
17
+ const iv = randomBytes(IV_LENGTH);
18
+ const cipher = createCipheriv(ALGORITHM, key, iv);
19
+ const ciphertext = Buffer.concat([
20
+ cipher.update(apiKey, "utf8"),
21
+ cipher.final()
22
+ ]);
23
+ return {
24
+ ciphertext: ciphertext.toString("base64"),
25
+ iv: iv.toString("base64"),
26
+ tag: cipher.getAuthTag().toString("base64")
27
+ };
28
+ }
29
+ function decodeEncryptionKey(base64EncodedKey) {
30
+ const key = Buffer.from(base64EncodedKey, "base64");
31
+ if (key.length !== KEY_LENGTH) {
32
+ throw new Error("PROVIDER_API_KEY_ENCRYPTION_KEY must be a base64-encoded 32-byte key");
33
+ }
34
+ return key;
35
+ }
@@ -0,0 +1,51 @@
1
+ import type { AppDatabase } from "../../db";
2
+ import { type CustomModelProviderRow, type CustomProviderModelRow, type ProviderApiKeyRow } from "../../db";
3
+ export interface CreateCustomModelProviderInput {
4
+ baseUrl: string;
5
+ provider: string;
6
+ }
7
+ export interface CreateCustomProviderModelInput {
8
+ api: string;
9
+ contextWindow: number;
10
+ input: string[];
11
+ maxTokens: number;
12
+ modelId: string;
13
+ name: string;
14
+ providerId: string;
15
+ reasoning: boolean;
16
+ }
17
+ export interface UpdateCustomModelProviderInput {
18
+ baseUrl: string;
19
+ provider: string;
20
+ }
21
+ export interface UpdateCustomProviderModelInput {
22
+ api: string;
23
+ contextWindow: number;
24
+ input: string[];
25
+ maxTokens: number;
26
+ name: string;
27
+ reasoning: boolean;
28
+ }
29
+ export interface SaveProviderApiKeyInput {
30
+ apiKeyCiphertext: string;
31
+ apiKeyIv: string;
32
+ apiKeyTag: string;
33
+ provider: string;
34
+ }
35
+ export interface ModelProviderRepository {
36
+ createCustomModelProvider: (input: CreateCustomModelProviderInput) => CustomModelProviderRow;
37
+ createCustomProviderModel: (input: CreateCustomProviderModelInput) => CustomProviderModelRow;
38
+ deleteCustomModelProvider: (provider: string) => boolean;
39
+ deleteCustomProviderModel: (providerId: string, modelId: string) => boolean;
40
+ findCustomModelProviderByProvider: (provider: string) => CustomModelProviderRow | undefined;
41
+ findCustomProviderModel: (providerId: string, modelId: string) => CustomProviderModelRow | undefined;
42
+ findProviderApiKeyByProvider: (provider: string) => ProviderApiKeyRow | undefined;
43
+ listCustomModelProviders: () => CustomModelProviderRow[];
44
+ listCustomProviderModelsByProviderId: (providerId: string) => CustomProviderModelRow[];
45
+ saveProviderApiKey: (input: SaveProviderApiKeyInput) => ProviderApiKeyRow;
46
+ updateCustomModelProvider: (provider: string, input: UpdateCustomModelProviderInput) => CustomModelProviderRow | undefined;
47
+ updateCustomProviderModel: (providerId: string, modelId: string, input: UpdateCustomProviderModelInput) => CustomProviderModelRow | undefined;
48
+ }
49
+ export declare function createInMemoryModelProviderRepository(): ModelProviderRepository;
50
+ export declare function createSqliteModelProviderRepository(database: AppDatabase): ModelProviderRepository;
51
+ //# sourceMappingURL=model-provider-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-provider-repository.d.ts","sourceRoot":"","sources":["../../../src/modules/model-providers/model-provider-repository.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACvB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,8BAA8B;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,8BAA8B;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,uBAAuB;IACtC,yBAAyB,EAAE,CACzB,KAAK,EAAE,8BAA8B,KAClC,sBAAsB,CAAC;IAC5B,yBAAyB,EAAE,CACzB,KAAK,EAAE,8BAA8B,KAClC,sBAAsB,CAAC;IAC5B,yBAAyB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IACzD,yBAAyB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5E,iCAAiC,EAAE,CACjC,QAAQ,EAAE,MAAM,KACb,sBAAsB,GAAG,SAAS,CAAC;IACxC,uBAAuB,EAAE,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,KACZ,sBAAsB,GAAG,SAAS,CAAC;IACxC,4BAA4B,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAC;IAClF,wBAAwB,EAAE,MAAM,sBAAsB,EAAE,CAAC;IACzD,oCAAoC,EAAE,CACpC,UAAU,EAAE,MAAM,KACf,sBAAsB,EAAE,CAAC;IAC9B,kBAAkB,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,iBAAiB,CAAC;IAC1E,yBAAyB,EAAE,CACzB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,8BAA8B,KAClC,sBAAsB,GAAG,SAAS,CAAC;IACxC,yBAAyB,EAAE,CACzB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,8BAA8B,KAClC,sBAAsB,GAAG,SAAS,CAAC;CACzC;AAED,wBAAgB,qCAAqC,IAAI,uBAAuB,CA6I/E;AAED,wBAAgB,mCAAmC,CACjD,QAAQ,EAAE,WAAW,GACpB,uBAAuB,CAkNzB"}
@@ -0,0 +1,314 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { eq } from "drizzle-orm";
3
+ import { customModelProviders, customProviderModels, providerApiKeys } from "../../db/index.js";
4
+ export function createInMemoryModelProviderRepository() {
5
+ const customProviders = new Map();
6
+ const customModels = new Map();
7
+ const apiKeys = new Map();
8
+ return {
9
+ createCustomModelProvider: (input) => {
10
+ const now = new Date().toISOString();
11
+ const row = {
12
+ baseUrl: input.baseUrl,
13
+ createdAt: now,
14
+ id: randomUUID(),
15
+ provider: input.provider,
16
+ updatedAt: now
17
+ };
18
+ customProviders.set(row.provider, row);
19
+ return row;
20
+ },
21
+ createCustomProviderModel: (input) => {
22
+ const now = new Date().toISOString();
23
+ const row = {
24
+ api: input.api,
25
+ contextWindow: input.contextWindow,
26
+ createdAt: now,
27
+ id: randomUUID(),
28
+ input: JSON.stringify(input.input),
29
+ maxTokens: input.maxTokens,
30
+ modelId: input.modelId,
31
+ name: input.name,
32
+ providerId: input.providerId,
33
+ reasoning: input.reasoning,
34
+ updatedAt: now
35
+ };
36
+ const rows = customModels.get(row.providerId) ?? [];
37
+ rows.push(row);
38
+ customModels.set(row.providerId, rows);
39
+ return row;
40
+ },
41
+ deleteCustomModelProvider: (provider) => {
42
+ const existing = customProviders.get(provider);
43
+ if (!existing) {
44
+ return false;
45
+ }
46
+ customProviders.delete(provider);
47
+ customModels.delete(existing.id);
48
+ apiKeys.delete(provider);
49
+ return true;
50
+ },
51
+ deleteCustomProviderModel: (providerId, modelId) => {
52
+ const rows = customModels.get(providerId) ?? [];
53
+ const nextRows = rows.filter((model) => model.modelId !== modelId);
54
+ if (nextRows.length === rows.length) {
55
+ return false;
56
+ }
57
+ customModels.set(providerId, nextRows);
58
+ return true;
59
+ },
60
+ findCustomModelProviderByProvider: (provider) => customProviders.get(provider),
61
+ findCustomProviderModel: (providerId, modelId) => (customModels.get(providerId) ?? []).find((model) => model.modelId === modelId),
62
+ findProviderApiKeyByProvider: (provider) => apiKeys.get(provider),
63
+ listCustomModelProviders: () => Array.from(customProviders.values()),
64
+ listCustomProviderModelsByProviderId: (providerId) => customModels.get(providerId) ?? [],
65
+ saveProviderApiKey: (input) => {
66
+ const existing = apiKeys.get(input.provider);
67
+ const now = new Date().toISOString();
68
+ const row = {
69
+ apiKeyCiphertext: input.apiKeyCiphertext,
70
+ apiKeyIv: input.apiKeyIv,
71
+ apiKeyTag: input.apiKeyTag,
72
+ createdAt: existing?.createdAt ?? now,
73
+ id: existing?.id ?? randomUUID(),
74
+ provider: input.provider,
75
+ updatedAt: now
76
+ };
77
+ apiKeys.set(row.provider, row);
78
+ return row;
79
+ },
80
+ updateCustomModelProvider: (provider, input) => {
81
+ const existing = customProviders.get(provider);
82
+ if (!existing) {
83
+ return undefined;
84
+ }
85
+ const row = {
86
+ ...existing,
87
+ baseUrl: input.baseUrl,
88
+ provider: input.provider,
89
+ updatedAt: new Date().toISOString()
90
+ };
91
+ customProviders.delete(provider);
92
+ customProviders.set(row.provider, row);
93
+ const existingApiKey = apiKeys.get(provider);
94
+ if (existingApiKey) {
95
+ apiKeys.delete(provider);
96
+ apiKeys.set(row.provider, {
97
+ ...existingApiKey,
98
+ provider: row.provider,
99
+ updatedAt: row.updatedAt
100
+ });
101
+ }
102
+ return row;
103
+ },
104
+ updateCustomProviderModel: (providerId, modelId, input) => {
105
+ const rows = customModels.get(providerId) ?? [];
106
+ const index = rows.findIndex((model) => model.modelId === modelId);
107
+ const existingRow = rows[index];
108
+ if (index === -1 || !existingRow) {
109
+ return undefined;
110
+ }
111
+ const row = {
112
+ ...existingRow,
113
+ api: input.api,
114
+ contextWindow: input.contextWindow,
115
+ input: JSON.stringify(input.input),
116
+ maxTokens: input.maxTokens,
117
+ name: input.name,
118
+ reasoning: input.reasoning,
119
+ updatedAt: new Date().toISOString()
120
+ };
121
+ rows[index] = row;
122
+ customModels.set(providerId, rows);
123
+ return row;
124
+ }
125
+ };
126
+ }
127
+ export function createSqliteModelProviderRepository(database) {
128
+ return {
129
+ createCustomModelProvider: (input) => {
130
+ const now = new Date().toISOString();
131
+ const row = {
132
+ baseUrl: input.baseUrl,
133
+ createdAt: now,
134
+ id: randomUUID(),
135
+ provider: input.provider,
136
+ updatedAt: now
137
+ };
138
+ database.db.insert(customModelProviders).values(row).run();
139
+ return row;
140
+ },
141
+ createCustomProviderModel: (input) => {
142
+ const now = new Date().toISOString();
143
+ const row = {
144
+ api: input.api,
145
+ contextWindow: input.contextWindow,
146
+ createdAt: now,
147
+ id: randomUUID(),
148
+ input: JSON.stringify(input.input),
149
+ maxTokens: input.maxTokens,
150
+ modelId: input.modelId,
151
+ name: input.name,
152
+ providerId: input.providerId,
153
+ reasoning: input.reasoning,
154
+ updatedAt: now
155
+ };
156
+ database.db.insert(customProviderModels).values(row).run();
157
+ return row;
158
+ },
159
+ deleteCustomModelProvider: (provider) => {
160
+ const existing = database.db
161
+ .select()
162
+ .from(customModelProviders)
163
+ .where(eq(customModelProviders.provider, provider))
164
+ .get();
165
+ if (!existing) {
166
+ return false;
167
+ }
168
+ database.db
169
+ .delete(customProviderModels)
170
+ .where(eq(customProviderModels.providerId, existing.id))
171
+ .run();
172
+ database.db
173
+ .delete(providerApiKeys)
174
+ .where(eq(providerApiKeys.provider, provider))
175
+ .run();
176
+ database.db
177
+ .delete(customModelProviders)
178
+ .where(eq(customModelProviders.id, existing.id))
179
+ .run();
180
+ return true;
181
+ },
182
+ deleteCustomProviderModel: (providerId, modelId) => {
183
+ const existing = database.db
184
+ .select()
185
+ .from(customProviderModels)
186
+ .where(eq(customProviderModels.providerId, providerId))
187
+ .all()
188
+ .find((model) => model.modelId === modelId);
189
+ if (!existing) {
190
+ return false;
191
+ }
192
+ database.db
193
+ .delete(customProviderModels)
194
+ .where(eq(customProviderModels.id, existing.id))
195
+ .run();
196
+ return true;
197
+ },
198
+ findCustomModelProviderByProvider: (provider) => database.db
199
+ .select()
200
+ .from(customModelProviders)
201
+ .where(eq(customModelProviders.provider, provider))
202
+ .get(),
203
+ findCustomProviderModel: (providerId, modelId) => database.db
204
+ .select()
205
+ .from(customProviderModels)
206
+ .where(eq(customProviderModels.providerId, providerId))
207
+ .all()
208
+ .find((model) => model.modelId === modelId),
209
+ findProviderApiKeyByProvider: (provider) => database.db
210
+ .select()
211
+ .from(providerApiKeys)
212
+ .where(eq(providerApiKeys.provider, provider))
213
+ .get(),
214
+ listCustomModelProviders: () => database.db.select().from(customModelProviders).all(),
215
+ listCustomProviderModelsByProviderId: (providerId) => database.db
216
+ .select()
217
+ .from(customProviderModels)
218
+ .where(eq(customProviderModels.providerId, providerId))
219
+ .all(),
220
+ saveProviderApiKey: (input) => {
221
+ const existing = database.db
222
+ .select()
223
+ .from(providerApiKeys)
224
+ .where(eq(providerApiKeys.provider, input.provider))
225
+ .get();
226
+ const now = new Date().toISOString();
227
+ const row = {
228
+ apiKeyCiphertext: input.apiKeyCiphertext,
229
+ apiKeyIv: input.apiKeyIv,
230
+ apiKeyTag: input.apiKeyTag,
231
+ createdAt: existing?.createdAt ?? now,
232
+ id: existing?.id ?? randomUUID(),
233
+ provider: input.provider,
234
+ updatedAt: now
235
+ };
236
+ if (existing) {
237
+ database.db
238
+ .update(providerApiKeys)
239
+ .set(row)
240
+ .where(eq(providerApiKeys.id, existing.id))
241
+ .run();
242
+ }
243
+ else {
244
+ database.db.insert(providerApiKeys).values(row).run();
245
+ }
246
+ return row;
247
+ },
248
+ updateCustomModelProvider: (provider, input) => {
249
+ const existing = database.db
250
+ .select()
251
+ .from(customModelProviders)
252
+ .where(eq(customModelProviders.provider, provider))
253
+ .get();
254
+ if (!existing) {
255
+ return undefined;
256
+ }
257
+ const row = {
258
+ ...existing,
259
+ baseUrl: input.baseUrl,
260
+ provider: input.provider,
261
+ updatedAt: new Date().toISOString()
262
+ };
263
+ database.db
264
+ .update(customModelProviders)
265
+ .set(row)
266
+ .where(eq(customModelProviders.id, existing.id))
267
+ .run();
268
+ const existingApiKey = database.db
269
+ .select()
270
+ .from(providerApiKeys)
271
+ .where(eq(providerApiKeys.provider, provider))
272
+ .get();
273
+ if (existingApiKey) {
274
+ database.db
275
+ .update(providerApiKeys)
276
+ .set({
277
+ ...existingApiKey,
278
+ provider: row.provider,
279
+ updatedAt: row.updatedAt
280
+ })
281
+ .where(eq(providerApiKeys.id, existingApiKey.id))
282
+ .run();
283
+ }
284
+ return row;
285
+ },
286
+ updateCustomProviderModel: (providerId, modelId, input) => {
287
+ const existing = database.db
288
+ .select()
289
+ .from(customProviderModels)
290
+ .where(eq(customProviderModels.providerId, providerId))
291
+ .all()
292
+ .find((model) => model.modelId === modelId);
293
+ if (!existing) {
294
+ return undefined;
295
+ }
296
+ const row = {
297
+ ...existing,
298
+ api: input.api,
299
+ contextWindow: input.contextWindow,
300
+ input: JSON.stringify(input.input),
301
+ maxTokens: input.maxTokens,
302
+ name: input.name,
303
+ reasoning: input.reasoning,
304
+ updatedAt: new Date().toISOString()
305
+ };
306
+ database.db
307
+ .update(customProviderModels)
308
+ .set(row)
309
+ .where(eq(customProviderModels.id, existing.id))
310
+ .run();
311
+ return row;
312
+ }
313
+ };
314
+ }
@@ -0,0 +1,9 @@
1
+ import { Router } from "express";
2
+ import type { ModelProvidersService } from "./model-providers-service";
3
+ import type { ModelProxiesService } from "../model-proxies/model-proxies-service";
4
+ export interface CreateModelProvidersRouterOptions {
5
+ modelProxiesService?: ModelProxiesService;
6
+ service?: ModelProvidersService;
7
+ }
8
+ export declare function createModelProvidersRouter(options?: CreateModelProvidersRouterOptions): Router;
9
+ //# sourceMappingURL=model-providers-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-providers-router.d.ts","sourceRoot":"","sources":["../../../src/modules/model-providers/model-providers-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA+B,MAAM,SAAS,CAAC;AAK9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAElF,MAAM,WAAW,iCAAiC;IAChD,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,OAAO,CAAC,EAAE,qBAAqB,CAAC;CACjC;AAqBD,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,iCAAsC,GAC9C,MAAM,CA8TR"}
@@ -0,0 +1,188 @@
1
+ import { Router } from "express";
2
+ import { sendError, sendSuccess } from "../../response/index.js";
3
+ import { RESPONSE_CODE_DEFINITIONS } from "../../response/response-codes.js";
4
+ import { getDefaultModelProvidersService } from "./default-model-provider-service.js";
5
+ import { getDefaultModelProxiesService } from "../model-proxies/default-model-proxies-service.js";
6
+ export function createModelProvidersRouter(options = {}) {
7
+ const router = Router();
8
+ const getService = () => options.service ?? getDefaultModelProvidersService();
9
+ const getProxyService = () => options.modelProxiesService ??
10
+ (options.service ? undefined : getDefaultModelProxiesService());
11
+ router.get("/model-providers", (_request, response) => {
12
+ const providers = getService().listModelProviders();
13
+ const proxyCount = getProxyService()?.listProxies().length ?? 0;
14
+ sendSuccess(response, [
15
+ ...providers,
16
+ ...(proxyCount > 0 && !providers.some((provider) => provider.id === "local")
17
+ ? [
18
+ {
19
+ hasApiKey: true,
20
+ id: "local",
21
+ modelCount: proxyCount,
22
+ source: "proxy"
23
+ }
24
+ ]
25
+ : [])
26
+ ]);
27
+ });
28
+ router.post("/model-providers/custom", (request, response) => {
29
+ if (typeof request.body.provider !== "string" ||
30
+ typeof request.body.baseUrl !== "string") {
31
+ sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "provider and baseUrl must be strings");
32
+ return;
33
+ }
34
+ try {
35
+ sendSuccess(response, getService().createCustomModelProvider(request.body.provider, request.body.baseUrl));
36
+ }
37
+ catch (error) {
38
+ sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, error instanceof Error ? error.message : "Failed to create provider");
39
+ }
40
+ });
41
+ router.put("/model-providers/custom/:provider", (request, response) => {
42
+ if (typeof request.body.provider !== "string" ||
43
+ typeof request.body.baseUrl !== "string") {
44
+ sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "provider and baseUrl must be strings");
45
+ return;
46
+ }
47
+ try {
48
+ const updatedProvider = getService().updateCustomModelProvider(String(request.params.provider ?? ""), request.body.provider, request.body.baseUrl);
49
+ if (!updatedProvider) {
50
+ sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown custom provider");
51
+ return;
52
+ }
53
+ sendSuccess(response, updatedProvider);
54
+ }
55
+ catch (error) {
56
+ sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, error instanceof Error ? error.message : "Failed to update provider");
57
+ }
58
+ });
59
+ router.delete("/model-providers/custom/:provider", (request, response) => {
60
+ const provider = String(request.params.provider ?? "");
61
+ const deleted = getService().deleteCustomModelProvider(provider);
62
+ if (!deleted) {
63
+ sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown custom provider");
64
+ return;
65
+ }
66
+ sendSuccess(response, { provider });
67
+ });
68
+ router.get("/model-providers/:provider/models", (request, response) => {
69
+ const provider = String(request.params.provider ?? "");
70
+ const service = getService();
71
+ if (provider === "local") {
72
+ const proxyService = getProxyService();
73
+ if (proxyService) {
74
+ sendSuccess(response, proxyService.listProxyModels());
75
+ return;
76
+ }
77
+ if (!service.hasProvider(provider)) {
78
+ sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown provider");
79
+ return;
80
+ }
81
+ sendSuccess(response, service.listModelsForProvider(provider));
82
+ return;
83
+ }
84
+ if (!service.hasProvider(provider)) {
85
+ sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown provider");
86
+ return;
87
+ }
88
+ sendSuccess(response, service.listModelsForProvider(provider));
89
+ });
90
+ router.post("/model-providers/:provider/models", (request, response) => {
91
+ if (!isValidCreateModelBody(request.body)) {
92
+ sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "api, modelId, name, input, contextWindow, maxTokens and reasoning are required");
93
+ return;
94
+ }
95
+ try {
96
+ sendSuccess(response, getService().createCustomProviderModel(String(request.params.provider ?? ""), {
97
+ api: request.body.api,
98
+ contextWindow: request.body.contextWindow,
99
+ input: request.body.input,
100
+ maxTokens: request.body.maxTokens,
101
+ modelId: request.body.modelId,
102
+ name: request.body.name,
103
+ reasoning: request.body.reasoning
104
+ }));
105
+ }
106
+ catch (error) {
107
+ const message = error instanceof Error ? error.message : "Failed to create model";
108
+ const code = message === "Unknown custom provider"
109
+ ? RESPONSE_CODE_DEFINITIONS.notFound
110
+ : RESPONSE_CODE_DEFINITIONS.badRequest;
111
+ sendError(response, code, message);
112
+ }
113
+ });
114
+ router.put("/model-providers/:provider/models/:modelId", (request, response) => {
115
+ if (!isValidUpdateModelBody(request.body)) {
116
+ sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "api, name, input, contextWindow, maxTokens and reasoning are required");
117
+ return;
118
+ }
119
+ const updatedModel = getService().updateCustomProviderModel(String(request.params.provider ?? ""), String(request.params.modelId ?? ""), {
120
+ api: request.body.api,
121
+ contextWindow: request.body.contextWindow,
122
+ input: request.body.input,
123
+ maxTokens: request.body.maxTokens,
124
+ name: request.body.name,
125
+ reasoning: request.body.reasoning
126
+ });
127
+ if (!updatedModel) {
128
+ sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown custom model");
129
+ return;
130
+ }
131
+ sendSuccess(response, updatedModel);
132
+ });
133
+ router.delete("/model-providers/:provider/models/:modelId", (request, response) => {
134
+ const provider = String(request.params.provider ?? "");
135
+ const modelId = String(request.params.modelId ?? "");
136
+ const deleted = getService().deleteCustomProviderModel(provider, modelId);
137
+ if (!deleted) {
138
+ sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown custom model");
139
+ return;
140
+ }
141
+ sendSuccess(response, {
142
+ modelId,
143
+ provider
144
+ });
145
+ });
146
+ router.put("/model-providers/:provider/api-key", (request, response) => {
147
+ const provider = String(request.params.provider ?? "");
148
+ const service = getService();
149
+ if (!service.hasProvider(provider)) {
150
+ sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown provider");
151
+ return;
152
+ }
153
+ if (typeof request.body.apiKey !== "string") {
154
+ sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "apiKey must be a string");
155
+ return;
156
+ }
157
+ try {
158
+ const providerSummary = service.storeProviderApiKey(provider, request.body.apiKey);
159
+ sendSuccess(response, {
160
+ hasApiKey: providerSummary.hasApiKey,
161
+ provider: providerSummary.id
162
+ });
163
+ }
164
+ catch (error) {
165
+ sendError(response, RESPONSE_CODE_DEFINITIONS.internalError, error instanceof Error ? error.message : "Failed to store apiKey");
166
+ }
167
+ });
168
+ return router;
169
+ }
170
+ function isValidCreateModelBody(body) {
171
+ return (typeof body.api === "string" &&
172
+ typeof body.modelId === "string" &&
173
+ typeof body.name === "string" &&
174
+ Array.isArray(body.input) &&
175
+ body.input.every((item) => typeof item === "string") &&
176
+ typeof body.contextWindow === "number" &&
177
+ typeof body.maxTokens === "number" &&
178
+ typeof body.reasoning === "boolean");
179
+ }
180
+ function isValidUpdateModelBody(body) {
181
+ return (typeof body.api === "string" &&
182
+ typeof body.name === "string" &&
183
+ Array.isArray(body.input) &&
184
+ body.input.every((item) => typeof item === "string") &&
185
+ typeof body.contextWindow === "number" &&
186
+ typeof body.maxTokens === "number" &&
187
+ typeof body.reasoning === "boolean");
188
+ }
@@ -0,0 +1,52 @@
1
+ import type { ModelProviderRepository } from "./model-provider-repository";
2
+ import type { ModelProxiesService } from "../model-proxies/model-proxies-service";
3
+ export interface ModelProviderSummary {
4
+ baseUrl?: string;
5
+ hasApiKey: boolean;
6
+ id: string;
7
+ modelCount: number;
8
+ source: "builtin" | "custom" | "proxy";
9
+ }
10
+ export interface CustomModelProviderSummary {
11
+ baseUrl: string;
12
+ createdAt: string;
13
+ id: string;
14
+ provider: string;
15
+ updatedAt: string;
16
+ }
17
+ export interface ModelSummary {
18
+ api: string;
19
+ contextWindow: number;
20
+ id: string;
21
+ input: string[];
22
+ maxTokens: number;
23
+ name: string;
24
+ provider: string;
25
+ reasoning: boolean;
26
+ }
27
+ export interface ModelProvidersServiceOptions {
28
+ modelProxiesService?: ModelProxiesService;
29
+ providerApiKeyEncryptionKey: string;
30
+ repository: ModelProviderRepository;
31
+ }
32
+ export interface ModelProvidersService {
33
+ createCustomModelProvider: (provider: string, baseUrl: string) => CustomModelProviderSummary;
34
+ createCustomProviderModel: (provider: string, input: Omit<ModelSummary, "id" | "provider"> & {
35
+ modelId: string;
36
+ }) => ModelSummary;
37
+ deleteCustomModelProvider: (provider: string) => boolean;
38
+ deleteCustomProviderModel: (provider: string, modelId: string) => boolean;
39
+ getConfiguredModelForProvider: (provider: string, modelId: string) => {
40
+ apiKey?: string;
41
+ baseUrl: string;
42
+ model: ModelSummary;
43
+ } | null;
44
+ hasProvider: (provider: string) => boolean;
45
+ listModelsForProvider: (provider: string) => ModelSummary[];
46
+ listModelProviders: () => ModelProviderSummary[];
47
+ storeProviderApiKey: (provider: string, apiKey: string) => ModelProviderSummary;
48
+ updateCustomModelProvider: (provider: string, nextProvider: string, baseUrl: string) => CustomModelProviderSummary | null;
49
+ updateCustomProviderModel: (provider: string, modelId: string, input: Omit<ModelSummary, "id" | "provider">) => ModelSummary | null;
50
+ }
51
+ export declare function createModelProvidersService(options: ModelProvidersServiceOptions): ModelProvidersService;
52
+ //# sourceMappingURL=model-providers-service.d.ts.map