@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,326 @@
1
+ import { desc, eq, sql } from "drizzle-orm";
2
+ import { modelTokenUsageHourly, tasks, workspaces } from "../../db/index.js";
3
+ export function createInMemoryWorkspaceRepository(seed = { tasks: [], workspaces: [] }) {
4
+ const workspaceRows = seed.workspaces.map((workspace) => workspace);
5
+ const taskRows = seed.tasks.map(toTaskRow);
6
+ const modelTokenUsageHourlyRows = [];
7
+ return {
8
+ addModelTokenUsageHourly: (usage) => {
9
+ const hour = normalizeUsageHour(usage.hour);
10
+ const existingIndex = modelTokenUsageHourlyRows.findIndex((row) => row.provider === usage.provider &&
11
+ row.modelName === usage.modelName &&
12
+ row.hour === hour);
13
+ const existingUsage = modelTokenUsageHourlyRows[existingIndex];
14
+ const nextUsage = {
15
+ hour,
16
+ inputToken: (existingUsage?.inputToken ?? 0) + (usage.inputToken ?? 0),
17
+ modelName: usage.modelName,
18
+ outputToken: (existingUsage?.outputToken ?? 0) + (usage.outputToken ?? 0),
19
+ provider: usage.provider
20
+ };
21
+ if (existingIndex >= 0) {
22
+ modelTokenUsageHourlyRows[existingIndex] = nextUsage;
23
+ }
24
+ else {
25
+ modelTokenUsageHourlyRows.push(nextUsage);
26
+ }
27
+ return nextUsage;
28
+ },
29
+ addTaskTokenUsage: (taskId, usage) => {
30
+ const taskIndex = taskRows.findIndex((task) => task.id === taskId);
31
+ const existingTask = taskRows[taskIndex];
32
+ if (!existingTask)
33
+ return undefined;
34
+ const nextTask = {
35
+ ...existingTask,
36
+ inputToken: existingTask.inputToken + usage.inputToken,
37
+ outputToken: existingTask.outputToken + usage.outputToken
38
+ };
39
+ taskRows[taskIndex] = nextTask;
40
+ return nextTask;
41
+ },
42
+ createTask: (task) => {
43
+ const row = toTaskRow(task);
44
+ taskRows.push(row);
45
+ return row;
46
+ },
47
+ createWorkspace: (workspace) => {
48
+ workspaceRows.push(workspace);
49
+ return workspace;
50
+ },
51
+ deleteTaskById: (taskId) => {
52
+ const taskIndex = taskRows.findIndex((task) => task.id === taskId);
53
+ if (taskIndex >= 0) {
54
+ taskRows.splice(taskIndex, 1);
55
+ }
56
+ },
57
+ deleteTasksByWorkspaceId: (workspaceId) => {
58
+ for (let index = taskRows.length - 1; index >= 0; index -= 1) {
59
+ if (taskRows[index]?.workspaceId === workspaceId) {
60
+ taskRows.splice(index, 1);
61
+ }
62
+ }
63
+ },
64
+ deleteWorkspaceById: (workspaceId) => {
65
+ const workspaceIndex = workspaceRows.findIndex((workspace) => workspace.id === workspaceId);
66
+ if (workspaceIndex >= 0) {
67
+ workspaceRows.splice(workspaceIndex, 1);
68
+ }
69
+ },
70
+ findTaskById: (taskId) => taskRows.find((task) => task.id === taskId),
71
+ findWorkspaceById: (workspaceId) => workspaceRows.find((workspace) => workspace.id === workspaceId),
72
+ findWorkspaceByPath: (workspacePath) => workspaceRows.find((workspace) => workspace.path === workspacePath),
73
+ listTasksAfterLastContinuedAt: ({ afterLastContinuedAt, limit, workspaceId }) => sortTasksDescending(taskRows.filter((task) => task.workspaceId === workspaceId &&
74
+ task.lastContinuedAt !== null &&
75
+ task.lastContinuedAt < afterLastContinuedAt)).slice(0, limit),
76
+ listAllTasksByWorkspaceId: (workspaceId) => taskRows.filter((task) => task.workspaceId === workspaceId),
77
+ listTasksByWorkspaceId: ({ limit, workspaceId }) => sortTasksDescending(taskRows.filter((task) => task.workspaceId === workspaceId && task.lastContinuedAt !== null)).slice(0, limit),
78
+ listWorkspaces: () => [...workspaceRows].sort((left, right) => left.name.localeCompare(right.name)),
79
+ updateTaskTitle: (taskId, title, updatedAt) => {
80
+ const taskIndex = taskRows.findIndex((task) => task.id === taskId);
81
+ const existingTask = taskRows.find((task) => task.id === taskId);
82
+ if (taskIndex === -1 || !existingTask) {
83
+ return undefined;
84
+ }
85
+ const nextTask = { ...existingTask, title, updatedAt };
86
+ taskRows[taskIndex] = nextTask;
87
+ return nextTask;
88
+ },
89
+ updateTaskContinuedAt: (taskId, continuedAt) => {
90
+ const taskIndex = taskRows.findIndex((task) => task.id === taskId);
91
+ const existingTask = taskRows[taskIndex];
92
+ if (!existingTask)
93
+ return undefined;
94
+ const nextTask = {
95
+ ...existingTask,
96
+ lastContinuedAt: continuedAt,
97
+ updatedAt: continuedAt
98
+ };
99
+ taskRows[taskIndex] = nextTask;
100
+ return nextTask;
101
+ },
102
+ updateTaskModel: (taskId, model, updatedAt) => {
103
+ const taskIndex = taskRows.findIndex((task) => task.id === taskId);
104
+ const existingTask = taskRows[taskIndex];
105
+ if (!existingTask)
106
+ return undefined;
107
+ const nextTask = { ...existingTask, ...model, updatedAt };
108
+ taskRows[taskIndex] = nextTask;
109
+ return nextTask;
110
+ },
111
+ updateTaskOptions: (taskId, options, updatedAt) => {
112
+ const taskIndex = taskRows.findIndex((task) => task.id === taskId);
113
+ const existingTask = taskRows[taskIndex];
114
+ if (!existingTask)
115
+ return undefined;
116
+ const nextTask = { ...existingTask, ...options, updatedAt };
117
+ taskRows[taskIndex] = nextTask;
118
+ return nextTask;
119
+ },
120
+ updateTaskSession: (taskId, session) => {
121
+ const taskIndex = taskRows.findIndex((task) => task.id === taskId);
122
+ const existingTask = taskRows[taskIndex];
123
+ if (!existingTask)
124
+ return undefined;
125
+ const nextTask = {
126
+ ...existingTask,
127
+ sessionCreatedAt: session.createdAt,
128
+ sessionId: session.id,
129
+ sessionPath: session.path
130
+ };
131
+ taskRows[taskIndex] = nextTask;
132
+ return nextTask;
133
+ },
134
+ updateTaskStatus: (taskId, status, updatedAt) => {
135
+ const taskIndex = taskRows.findIndex((task) => task.id === taskId);
136
+ const existingTask = taskRows[taskIndex];
137
+ if (!existingTask)
138
+ return undefined;
139
+ const nextTask = { ...existingTask, status, updatedAt };
140
+ taskRows[taskIndex] = nextTask;
141
+ return nextTask;
142
+ }
143
+ };
144
+ }
145
+ export function createSqliteWorkspaceRepository(database) {
146
+ return {
147
+ addModelTokenUsageHourly: (usage) => {
148
+ const row = {
149
+ ...usage,
150
+ hour: normalizeUsageHour(usage.hour),
151
+ inputToken: usage.inputToken ?? 0,
152
+ outputToken: usage.outputToken ?? 0
153
+ };
154
+ database.db
155
+ .insert(modelTokenUsageHourly)
156
+ .values(row)
157
+ .onConflictDoUpdate({
158
+ set: {
159
+ inputToken: sql `${modelTokenUsageHourly.inputToken} + ${row.inputToken}`,
160
+ outputToken: sql `${modelTokenUsageHourly.outputToken} + ${row.outputToken}`
161
+ },
162
+ target: [
163
+ modelTokenUsageHourly.provider,
164
+ modelTokenUsageHourly.modelName,
165
+ modelTokenUsageHourly.hour
166
+ ]
167
+ })
168
+ .run();
169
+ return database.db
170
+ .select()
171
+ .from(modelTokenUsageHourly)
172
+ .where(sql `
173
+ ${modelTokenUsageHourly.provider} = ${row.provider}
174
+ AND ${modelTokenUsageHourly.modelName} = ${row.modelName}
175
+ AND ${modelTokenUsageHourly.hour} = ${row.hour}
176
+ `)
177
+ .get();
178
+ },
179
+ addTaskTokenUsage: (taskId, usage) => {
180
+ database.db
181
+ .update(tasks)
182
+ .set({
183
+ inputToken: sql `${tasks.inputToken} + ${usage.inputToken}`,
184
+ outputToken: sql `${tasks.outputToken} + ${usage.outputToken}`
185
+ })
186
+ .where(eq(tasks.id, taskId))
187
+ .run();
188
+ return database.db.select().from(tasks).where(eq(tasks.id, taskId)).get();
189
+ },
190
+ createTask: (task) => {
191
+ const row = toTaskRow(task);
192
+ database.db.insert(tasks).values(row).run();
193
+ return row;
194
+ },
195
+ createWorkspace: (workspace) => {
196
+ database.db.insert(workspaces).values(workspace).run();
197
+ return workspace;
198
+ },
199
+ deleteTaskById: (taskId) => {
200
+ database.db.delete(tasks).where(eq(tasks.id, taskId)).run();
201
+ },
202
+ deleteTasksByWorkspaceId: (workspaceId) => {
203
+ database.db.delete(tasks).where(eq(tasks.workspaceId, workspaceId)).run();
204
+ },
205
+ deleteWorkspaceById: (workspaceId) => {
206
+ database.db.delete(workspaces).where(eq(workspaces.id, workspaceId)).run();
207
+ },
208
+ findTaskById: (taskId) => database.db
209
+ .select()
210
+ .from(tasks)
211
+ .where(eq(tasks.id, taskId))
212
+ .get(),
213
+ findWorkspaceById: (workspaceId) => database.db
214
+ .select()
215
+ .from(workspaces)
216
+ .where(eq(workspaces.id, workspaceId))
217
+ .get(),
218
+ findWorkspaceByPath: (workspacePath) => database.db
219
+ .select()
220
+ .from(workspaces)
221
+ .where(eq(workspaces.path, workspacePath))
222
+ .get(),
223
+ listTasksAfterLastContinuedAt: ({ afterLastContinuedAt, limit, workspaceId }) => database.db
224
+ .select()
225
+ .from(tasks)
226
+ .where(eq(tasks.workspaceId, workspaceId))
227
+ .orderBy(desc(tasks.lastContinuedAt))
228
+ .all()
229
+ .filter((task) => task.lastContinuedAt !== null &&
230
+ task.lastContinuedAt < afterLastContinuedAt)
231
+ .slice(0, limit),
232
+ listAllTasksByWorkspaceId: (workspaceId) => database.db
233
+ .select()
234
+ .from(tasks)
235
+ .where(eq(tasks.workspaceId, workspaceId))
236
+ .all(),
237
+ listTasksByWorkspaceId: ({ limit, workspaceId }) => database.db
238
+ .select()
239
+ .from(tasks)
240
+ .where(eq(tasks.workspaceId, workspaceId))
241
+ .orderBy(desc(tasks.lastContinuedAt))
242
+ .all()
243
+ .filter((task) => task.lastContinuedAt !== null)
244
+ .slice(0, limit),
245
+ listWorkspaces: () => database.db.select().from(workspaces).all(),
246
+ updateTaskTitle: (taskId, title, updatedAt) => {
247
+ database.db
248
+ .update(tasks)
249
+ .set({ title, updatedAt })
250
+ .where(eq(tasks.id, taskId))
251
+ .run();
252
+ return database.db
253
+ .select()
254
+ .from(tasks)
255
+ .where(eq(tasks.id, taskId))
256
+ .get();
257
+ },
258
+ updateTaskContinuedAt: (taskId, continuedAt) => {
259
+ database.db
260
+ .update(tasks)
261
+ .set({ lastContinuedAt: continuedAt, updatedAt: continuedAt })
262
+ .where(eq(tasks.id, taskId))
263
+ .run();
264
+ return database.db.select().from(tasks).where(eq(tasks.id, taskId)).get();
265
+ },
266
+ updateTaskModel: (taskId, model, updatedAt) => {
267
+ database.db
268
+ .update(tasks)
269
+ .set({ ...model, updatedAt })
270
+ .where(eq(tasks.id, taskId))
271
+ .run();
272
+ return database.db.select().from(tasks).where(eq(tasks.id, taskId)).get();
273
+ },
274
+ updateTaskOptions: (taskId, options, updatedAt) => {
275
+ database.db
276
+ .update(tasks)
277
+ .set({ ...options, updatedAt })
278
+ .where(eq(tasks.id, taskId))
279
+ .run();
280
+ return database.db.select().from(tasks).where(eq(tasks.id, taskId)).get();
281
+ },
282
+ updateTaskSession: (taskId, session) => {
283
+ database.db
284
+ .update(tasks)
285
+ .set({
286
+ sessionCreatedAt: session.createdAt,
287
+ sessionId: session.id,
288
+ sessionPath: session.path
289
+ })
290
+ .where(eq(tasks.id, taskId))
291
+ .run();
292
+ return database.db.select().from(tasks).where(eq(tasks.id, taskId)).get();
293
+ },
294
+ updateTaskStatus: (taskId, status, updatedAt) => {
295
+ database.db
296
+ .update(tasks)
297
+ .set({ status, updatedAt })
298
+ .where(eq(tasks.id, taskId))
299
+ .run();
300
+ return database.db.select().from(tasks).where(eq(tasks.id, taskId)).get();
301
+ }
302
+ };
303
+ }
304
+ function sortTasksDescending(taskRows) {
305
+ return [...taskRows].sort((left, right) => String(right.lastContinuedAt).localeCompare(String(left.lastContinuedAt)));
306
+ }
307
+ function normalizeUsageHour(hour) {
308
+ const date = new Date(hour);
309
+ date.setUTCMinutes(0, 0, 0);
310
+ return date.toISOString();
311
+ }
312
+ function toTaskRow(task) {
313
+ return {
314
+ ...task,
315
+ approvalPolicy: task.approvalPolicy ?? "approval",
316
+ lastContinuedAt: task.lastContinuedAt ?? null,
317
+ lastModelId: task.lastModelId ?? null,
318
+ inputToken: task.inputToken ?? 0,
319
+ outputToken: task.outputToken ?? 0,
320
+ sessionCreatedAt: task.sessionCreatedAt ?? null,
321
+ sessionId: task.sessionId ?? null,
322
+ sessionPath: task.sessionPath ?? null,
323
+ status: task.status ?? "completed",
324
+ thinkingLevel: task.thinkingLevel ?? "medium"
325
+ };
326
+ }
@@ -0,0 +1,33 @@
1
+ import type { TaskRow, WorkspaceRow } from "../../db";
2
+ export interface WorkspaceTaskSummary {
3
+ activeAgentId?: string;
4
+ approvalPolicy: TaskRow["approvalPolicy"];
5
+ id: string;
6
+ initialUserMessage: string;
7
+ lastContinuedAt: string;
8
+ lastModelId: TaskRow["lastModelId"];
9
+ lastModelName: string;
10
+ lastModelProvider: string;
11
+ lastModelProviderSource: TaskRow["lastModelProviderSource"];
12
+ status: TaskRow["status"];
13
+ thinkingLevel: TaskRow["thinkingLevel"];
14
+ title: string;
15
+ }
16
+ export interface WorkspaceWithTasksSummary {
17
+ hasMore: boolean;
18
+ id: string;
19
+ name: string;
20
+ path: string;
21
+ tasks: WorkspaceTaskSummary[];
22
+ }
23
+ export interface RecentWorkspaceTasksResult {
24
+ workspaces: WorkspaceWithTasksSummary[];
25
+ }
26
+ export interface WorkspaceTaskPageResult {
27
+ hasMore: boolean;
28
+ tasks: WorkspaceTaskSummary[];
29
+ workspaceId: string;
30
+ }
31
+ export type WorkspaceNavigationRow = WorkspaceRow;
32
+ export type WorkspaceNavigationTaskRow = TaskRow;
33
+ //# sourceMappingURL=workspace-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-types.d.ts","sourceRoot":"","sources":["../../../src/modules/workspaces/workspace-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uBAAuB,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC5D,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,oBAAoB,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,yBAAyB,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAAC;AAClD,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Router } from "express";
2
+ import type { WorkspacesService } from "./workspaces-service";
3
+ export interface CreateWorkspacesRouterOptions {
4
+ workspacesService?: WorkspacesService;
5
+ }
6
+ export declare function createWorkspacesRouter(options?: CreateWorkspacesRouterOptions): Router;
7
+ //# sourceMappingURL=workspaces-router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces-router.d.ts","sourceRoot":"","sources":["../../../src/modules/workspaces/workspaces-router.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EAIP,MAAM,SAAS,CAAC;AAKjB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,WAAW,6BAA6B;IAC5C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAKD,wBAAgB,sBAAsB,CACpC,OAAO,GAAE,6BAAkC,GAC1C,MAAM,CAgGR"}
@@ -0,0 +1,71 @@
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 { getDefaultWorkspacesService } from "./default-workspaces-service.js";
5
+ const DEFAULT_TASK_PAGE_LIMIT = 20;
6
+ const MAX_TASK_PAGE_LIMIT = 100;
7
+ export function createWorkspacesRouter(options = {}) {
8
+ const router = Router();
9
+ const getService = () => options.workspacesService ?? getDefaultWorkspacesService();
10
+ router.get("/workspaces/recent-tasks", (_request, response) => {
11
+ sendSuccess(response, getService().listRecentWorkspaceTasks());
12
+ });
13
+ router.delete("/workspaces/:workspaceId", async (request, response, next) => {
14
+ try {
15
+ const result = await getService().deleteWorkspace(request.params.workspaceId);
16
+ if (result.status === "not_found") {
17
+ sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown workspace");
18
+ return;
19
+ }
20
+ if (result.status === "has_running_tasks") {
21
+ sendError(response, RESPONSE_CODE_DEFINITIONS.conflict, "Workspace has running tasks");
22
+ return;
23
+ }
24
+ sendSuccess(response, { workspaceId: result.workspaceId });
25
+ }
26
+ catch (error) {
27
+ next(error);
28
+ }
29
+ });
30
+ router.get("/workspaces/:workspaceId/tasks", (request, response) => {
31
+ const afterLastContinuedAt = getStringQuery(request.query.afterLastContinuedAt);
32
+ if (afterLastContinuedAt === null || !isIsoDateString(afterLastContinuedAt)) {
33
+ sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, "afterLastContinuedAt must be an ISO date string");
34
+ return;
35
+ }
36
+ const limit = getLimit(request.query.limit);
37
+ if (limit === null) {
38
+ sendError(response, RESPONSE_CODE_DEFINITIONS.badRequest, `limit must be an integer from 1 to ${MAX_TASK_PAGE_LIMIT}`);
39
+ return;
40
+ }
41
+ const result = getService().listWorkspaceTasksAfter({
42
+ afterLastContinuedAt,
43
+ limit,
44
+ workspaceId: request.params.workspaceId
45
+ });
46
+ if (!result) {
47
+ sendError(response, RESPONSE_CODE_DEFINITIONS.notFound, "Unknown workspace");
48
+ return;
49
+ }
50
+ sendSuccess(response, result);
51
+ });
52
+ return router;
53
+ }
54
+ function getStringQuery(value) {
55
+ return typeof value === "string" ? value : null;
56
+ }
57
+ function getLimit(value) {
58
+ if (value === undefined) {
59
+ return DEFAULT_TASK_PAGE_LIMIT;
60
+ }
61
+ if (typeof value !== "string" || !/^\d+$/.test(value)) {
62
+ return null;
63
+ }
64
+ const parsedLimit = Number(value);
65
+ return parsedLimit >= 1 && parsedLimit <= MAX_TASK_PAGE_LIMIT
66
+ ? parsedLimit
67
+ : null;
68
+ }
69
+ function isIsoDateString(value) {
70
+ return !Number.isNaN(Date.parse(value));
71
+ }
@@ -0,0 +1,24 @@
1
+ import type { ActiveTaskRunRegistry } from "../agents/task/active-run-registry";
2
+ import type { RecentWorkspaceTasksResult, WorkspaceTaskPageResult } from "./workspace-types";
3
+ import type { WorkspaceRepository } from "./workspace-repository";
4
+ export interface CreateWorkspacesServiceOptions {
5
+ activeTaskRuns?: ActiveTaskRunRegistry;
6
+ now?: () => Date;
7
+ repository: WorkspaceRepository;
8
+ }
9
+ export interface ListWorkspaceTasksAfterOptions {
10
+ afterLastContinuedAt: string;
11
+ limit: number;
12
+ workspaceId: string;
13
+ }
14
+ export interface WorkspacesService {
15
+ deleteWorkspace: (workspaceId: string) => Promise<DeleteWorkspaceResult>;
16
+ listRecentWorkspaceTasks: () => RecentWorkspaceTasksResult;
17
+ listWorkspaceTasksAfter: (options: ListWorkspaceTasksAfterOptions) => WorkspaceTaskPageResult | undefined;
18
+ }
19
+ export interface DeleteWorkspaceResult {
20
+ status: "deleted" | "has_running_tasks" | "not_found";
21
+ workspaceId: string;
22
+ }
23
+ export declare function createWorkspacesService({ activeTaskRuns, now, repository }: CreateWorkspacesServiceOptions): WorkspacesService;
24
+ //# sourceMappingURL=workspaces-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces-service.d.ts","sourceRoot":"","sources":["../../../src/modules/workspaces/workspaces-service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EACV,0BAA0B,EAE1B,uBAAuB,EAGxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE,MAAM,WAAW,8BAA8B;IAC7C,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,UAAU,EAAE,mBAAmB,CAAC;CACjC;AAED,MAAM,WAAW,8BAA8B;IAC7C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACzE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;IAC3D,uBAAuB,EAAE,CACvB,OAAO,EAAE,8BAA8B,KACpC,uBAAuB,GAAG,SAAS,CAAC;CAC1C;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,SAAS,GAAG,mBAAmB,GAAG,WAAW,CAAC;IACtD,WAAW,EAAE,MAAM,CAAC;CACrB;AAKD,wBAAgB,uBAAuB,CAAC,EACtC,cAAc,EACd,GAAsB,EACtB,UAAU,EACX,EAAE,8BAA8B,GAAG,iBAAiB,CAqFpD"}
@@ -0,0 +1,109 @@
1
+ import { unlink } from "node:fs/promises";
2
+ const RECENT_TASK_WINDOW_MS = 7 * 24 * 60 * 60 * 1000;
3
+ const RECENT_TASK_FETCH_LIMIT = 500;
4
+ export function createWorkspacesService({ activeTaskRuns, now = () => new Date(), repository }) {
5
+ return {
6
+ deleteWorkspace: async (workspaceId) => {
7
+ if (!repository.findWorkspaceById(workspaceId)) {
8
+ return { status: "not_found", workspaceId };
9
+ }
10
+ const workspaceTasks = repository.listAllTasksByWorkspaceId(workspaceId);
11
+ if (workspaceTasks.some((task) => task.status === "running")) {
12
+ return { status: "has_running_tasks", workspaceId };
13
+ }
14
+ await Promise.all(workspaceTasks
15
+ .map((task) => task.sessionPath)
16
+ .filter((sessionPath) => Boolean(sessionPath))
17
+ .map(deleteSessionFile));
18
+ repository.deleteTasksByWorkspaceId(workspaceId);
19
+ repository.deleteWorkspaceById(workspaceId);
20
+ return { status: "deleted", workspaceId };
21
+ },
22
+ listRecentWorkspaceTasks: () => {
23
+ const cutoff = new Date(now().getTime() - RECENT_TASK_WINDOW_MS).toISOString();
24
+ const workspaceSummaries = sortWorkspacesByCreatedAtDescending(repository.listWorkspaces()).map((workspace) => {
25
+ const tasks = repository.listTasksByWorkspaceId({
26
+ limit: RECENT_TASK_FETCH_LIMIT,
27
+ workspaceId: workspace.id
28
+ });
29
+ const recentTasks = sortTasksByCreatedAtDescending(tasks.filter((task) => task.lastContinuedAt !== null && task.lastContinuedAt >= cutoff));
30
+ const summary = {
31
+ hasMore: tasks.some((task) => task.lastContinuedAt !== null && task.lastContinuedAt < cutoff),
32
+ id: workspace.id,
33
+ name: workspace.name,
34
+ path: workspace.path,
35
+ tasks: recentTasks.map((task) => toTaskSummary(resolveTaskStatus(task, activeTaskRuns, repository, now), activeTaskRuns))
36
+ };
37
+ return summary;
38
+ });
39
+ return { workspaces: workspaceSummaries };
40
+ },
41
+ listWorkspaceTasksAfter: ({ afterLastContinuedAt, limit, workspaceId }) => {
42
+ if (!repository.findWorkspaceById(workspaceId)) {
43
+ return undefined;
44
+ }
45
+ const tasks = repository.listTasksAfterLastContinuedAt({
46
+ afterLastContinuedAt,
47
+ limit: limit + 1,
48
+ workspaceId
49
+ });
50
+ return {
51
+ hasMore: tasks.length > limit,
52
+ tasks: tasks
53
+ .slice(0, limit)
54
+ .map((task) => toTaskSummary(resolveTaskStatus(task, activeTaskRuns, repository, now), activeTaskRuns)),
55
+ workspaceId
56
+ };
57
+ }
58
+ };
59
+ }
60
+ async function deleteSessionFile(sessionPath) {
61
+ try {
62
+ await unlink(sessionPath);
63
+ }
64
+ catch (error) {
65
+ if (isMissingFileError(error)) {
66
+ return;
67
+ }
68
+ throw error;
69
+ }
70
+ }
71
+ function isMissingFileError(error) {
72
+ return (error instanceof Error &&
73
+ "code" in error &&
74
+ error.code === "ENOENT");
75
+ }
76
+ function resolveTaskStatus(task, activeTaskRuns, repository, now) {
77
+ if (task.status !== "running" ||
78
+ !activeTaskRuns ||
79
+ activeTaskRuns.hasTask(task.id)) {
80
+ return task;
81
+ }
82
+ return repository.updateTaskStatus(task.id, "error", now().toISOString()) ?? task;
83
+ }
84
+ function toTaskSummary(task, activeTaskRuns) {
85
+ if (task.lastContinuedAt === null) {
86
+ throw new Error("Task summary requires lastContinuedAt");
87
+ }
88
+ const activeAgentId = activeTaskRuns?.getAgentId(task.id);
89
+ return {
90
+ ...(activeAgentId ? { activeAgentId } : {}),
91
+ approvalPolicy: task.approvalPolicy,
92
+ id: task.id,
93
+ initialUserMessage: task.initialUserMessage,
94
+ lastContinuedAt: task.lastContinuedAt,
95
+ lastModelId: task.lastModelId,
96
+ lastModelName: task.lastModelName,
97
+ lastModelProvider: task.lastModelProvider,
98
+ lastModelProviderSource: task.lastModelProviderSource,
99
+ status: task.status,
100
+ thinkingLevel: task.thinkingLevel,
101
+ title: task.title
102
+ };
103
+ }
104
+ function sortTasksByCreatedAtDescending(tasks) {
105
+ return [...tasks].sort((left, right) => right.createdAt.localeCompare(left.createdAt));
106
+ }
107
+ function sortWorkspacesByCreatedAtDescending(workspaces) {
108
+ return [...workspaces].sort((left, right) => right.createdAt.localeCompare(left.createdAt));
109
+ }
@@ -0,0 +1,5 @@
1
+ import { type RuntimePluginManifest } from "@hold-rein/plugin-server";
2
+ export declare const pluginRegistry: import("@hold-rein/plugin-server").ServerPluginRegistry;
3
+ export declare function bootstrapServerPlugins(pluginRoot: string): Promise<void>;
4
+ export declare function getRuntimeWebPlugins(): readonly RuntimePluginManifest[];
5
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,cAAc,yDAA+B,CAAC;AAK3D,wBAAsB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAY9E;AAED,wBAAgB,oBAAoB,IAAI,SAAS,qBAAqB,EAAE,CAEvE"}
@@ -0,0 +1,48 @@
1
+ import { readFileSync, realpathSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { createServerPluginRegistry, loadInstalledServerPlugins } from "@hold-rein/plugin-server";
5
+ export const pluginRegistry = createServerPluginRegistry();
6
+ let runtimeWebPlugins = [];
7
+ const apiPackageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
8
+ export async function bootstrapServerPlugins(pluginRoot) {
9
+ const loaded = await loadInstalledServerPlugins({
10
+ hostNodeModules: join(process.cwd(), "node_modules"),
11
+ pluginRoot,
12
+ resolvePackageTarget: resolveRuntimePackageTarget
13
+ });
14
+ for (const plugin of loaded.plugins) {
15
+ registerPluginIfMissing(plugin);
16
+ }
17
+ runtimeWebPlugins = loaded.webPlugins;
18
+ }
19
+ export function getRuntimeWebPlugins() {
20
+ return runtimeWebPlugins;
21
+ }
22
+ function registerPluginIfMissing(plugin) {
23
+ if (!pluginRegistry.has(plugin.id)) {
24
+ pluginRegistry.register(plugin);
25
+ }
26
+ }
27
+ function resolveRuntimePackageTarget(packageName) {
28
+ let directory = realpathSync(join(apiPackageRoot, "node_modules", ...packageName.split("/")));
29
+ while (true) {
30
+ if (hasPackageName(directory, packageName)) {
31
+ return directory;
32
+ }
33
+ const parent = dirname(directory);
34
+ if (parent === directory) {
35
+ throw new Error(`Unable to resolve package root for "${packageName}".`);
36
+ }
37
+ directory = parent;
38
+ }
39
+ }
40
+ function hasPackageName(directory, packageName) {
41
+ try {
42
+ const packageJson = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
43
+ return packageJson.name === packageName;
44
+ }
45
+ catch {
46
+ return false;
47
+ }
48
+ }
@@ -0,0 +1,11 @@
1
+ import type { Response } from "express";
2
+ import { type ResponseCodeDefinition } from "./response-codes";
3
+ export interface ApiResponse<T> {
4
+ code: number;
5
+ msg: string;
6
+ data: T;
7
+ }
8
+ export declare function createApiResponse<T>(definition: ResponseCodeDefinition, data: T, message?: string): ApiResponse<T>;
9
+ export declare function sendSuccess<T>(response: Response, data: T, message?: string): void;
10
+ export declare function sendError(response: Response, definition: ResponseCodeDefinition, message?: string): void;
11
+ //# sourceMappingURL=api-response.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-response.d.ts","sourceRoot":"","sources":["../../src/response/api-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,CAAC,CAAC;CACT;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,UAAU,EAAE,sBAAsB,EAClC,IAAI,EAAE,CAAC,EACP,OAAO,SAA4B,GAClC,WAAW,CAAC,CAAC,CAAC,CAMhB;AAED,wBAAgB,WAAW,CAAC,CAAC,EAC3B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAIN;AAED,wBAAgB,SAAS,CACvB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,sBAAsB,EAClC,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAIN"}