@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,282 @@
1
+ /* eslint-disable max-lines */
2
+ import { randomUUID } from "node:crypto";
3
+ import { basename } from "node:path";
4
+ import { deleteTask, renameTask } from "./agent-task-actions.js";
5
+ import { startTaskRun } from "./task-run-monitor.js";
6
+ import { createInMemorySubagentRepository } from "./subagent-repository.js";
7
+ export function createAgentsService(options) {
8
+ const titleJobs = new Map();
9
+ const now = options.now ?? (() => new Date());
10
+ const subagentRepository = options.subagentRepository ?? createInMemorySubagentRepository();
11
+ return {
12
+ approveAgentAction: async (input) => {
13
+ if (!options.approvalStore.decide(input)) {
14
+ throw new Error("Unknown approval request");
15
+ }
16
+ return input;
17
+ },
18
+ deleteTask: ({ taskId }) => deleteTask(options.repository, taskId),
19
+ getTaskTitle: async ({ taskId }) => {
20
+ const task = options.repository.findTaskById(taskId);
21
+ if (!task) {
22
+ return null;
23
+ }
24
+ if (task.title.trim().length > 0) {
25
+ return { id: task.id, title: task.title };
26
+ }
27
+ const titleJob = titleJobs.get(task.id);
28
+ if (titleJob) {
29
+ return titleJob;
30
+ }
31
+ startTitleJob({
32
+ input: {
33
+ modelId: task.lastModelId ?? task.lastModelName,
34
+ prompt: task.initialUserMessage,
35
+ provider: task.lastModelProvider,
36
+ workspacePath: ""
37
+ },
38
+ now,
39
+ repository: options.repository,
40
+ task,
41
+ titleGenerator: options.titleGenerator,
42
+ titleJobs
43
+ });
44
+ return titleJobs.get(task.id) ?? { id: task.id, title: task.title };
45
+ },
46
+ interruptTask: async ({ taskId }) => {
47
+ const task = options.repository.findTaskById(taskId);
48
+ if (!task) {
49
+ return { status: "not_found", taskId };
50
+ }
51
+ const agentId = options.activeTaskRuns?.getAgentId(taskId);
52
+ if (task.status !== "running" || !agentId) {
53
+ return { status: "not_running", taskId };
54
+ }
55
+ const interrupted = await options.runtime.interrupt(agentId);
56
+ if (!interrupted) {
57
+ options.activeTaskRuns?.remove(taskId);
58
+ return { status: "not_running", taskId };
59
+ }
60
+ options.repository.updateTaskStatus(taskId, "error", now().toISOString());
61
+ options.activeTaskRuns?.remove(taskId);
62
+ return { agentId, status: "interrupted", taskId };
63
+ },
64
+ continueTask: async (input) => {
65
+ const { prompt, taskId } = input;
66
+ const task = options.repository.findTaskById(taskId);
67
+ if (!task)
68
+ return null;
69
+ const workspace = options.repository.findWorkspaceById(task.workspaceId);
70
+ if (!workspace)
71
+ return null;
72
+ const session = getTaskSession(task);
73
+ const selectedModel = input.modelId !== undefined && input.provider !== undefined
74
+ ? getTaskModelMetadata(input.provider, input.modelId, options.modelProvidersService)
75
+ : null;
76
+ options.repository.updateTaskStatus(taskId, "running", now().toISOString());
77
+ const run = await startTaskRun({
78
+ ...(options.activeTaskRuns
79
+ ? { activeTaskRuns: options.activeTaskRuns }
80
+ : {}),
81
+ eventBus: options.eventBus,
82
+ now,
83
+ repository: options.repository,
84
+ runtime: options.runtime,
85
+ runtimeInput: {
86
+ modelId: selectedModel?.lastModelId ?? task.lastModelId ?? task.lastModelName,
87
+ prompt,
88
+ provider: selectedModel?.lastModelProvider ?? task.lastModelProvider,
89
+ ...(session ? { session } : {}),
90
+ taskId,
91
+ workspacePath: workspace.path
92
+ },
93
+ taskId
94
+ });
95
+ options.repository.updateTaskSession(taskId, run.session);
96
+ const continuedAt = now().toISOString();
97
+ if (selectedModel) {
98
+ options.repository.updateTaskModel(taskId, selectedModel, continuedAt);
99
+ }
100
+ const updatedTask = options.repository.updateTaskContinuedAt(taskId, continuedAt) ?? task;
101
+ return toStartAgentResult(run, updatedTask, workspace);
102
+ },
103
+ listTaskMessages: async ({ taskId }) => {
104
+ const task = options.repository.findTaskById(taskId);
105
+ if (!task)
106
+ return emptyTaskMessageHistory();
107
+ const workspace = options.repository.findWorkspaceById(task.workspaceId);
108
+ const session = getTaskSession(task);
109
+ if (!workspace || !session)
110
+ return emptyTaskMessageHistory();
111
+ const messages = await options.runtime.listMessages({
112
+ session,
113
+ workspacePath: workspace.path
114
+ });
115
+ const subagents = await Promise.all(subagentRepository.findByTaskId(taskId).map(async (subagent) => ({
116
+ agentId: subagent.agentId,
117
+ messages: await loadSubagentMessages({
118
+ runtime: options.runtime,
119
+ subagent,
120
+ workspacePath: workspace.path
121
+ }),
122
+ parentAgentId: subagent.parentAgentId,
123
+ status: subagent.status
124
+ })));
125
+ return { messages, subagents };
126
+ },
127
+ renameTask: async ({ taskId, title }) => renameTask(options.repository, taskId, title, now().toISOString()),
128
+ startAgent: async (input) => {
129
+ const createdAt = now().toISOString();
130
+ const workspace = ensureWorkspace({
131
+ createdAt,
132
+ repository: options.repository,
133
+ workspacePath: input.workspacePath
134
+ });
135
+ const configuredModel = options.modelProvidersService?.getConfiguredModelForProvider(input.provider, input.modelId) ?? null;
136
+ const taskModel = getTaskModelMetadata(input.provider, input.modelId, options.modelProvidersService);
137
+ const task = options.repository.createTask({
138
+ createdAt,
139
+ id: `task_${randomUUID()}`,
140
+ initialUserMessage: input.prompt,
141
+ lastContinuedAt: createdAt,
142
+ ...taskModel,
143
+ sessionCreatedAt: null,
144
+ sessionId: null,
145
+ sessionPath: null,
146
+ status: "running",
147
+ title: "",
148
+ updatedAt: createdAt,
149
+ workspaceId: workspace.id
150
+ });
151
+ startTitleJob({
152
+ ...(configuredModel?.apiKey ? { apiKey: configuredModel.apiKey } : {}),
153
+ input,
154
+ now,
155
+ repository: options.repository,
156
+ task,
157
+ titleGenerator: options.titleGenerator,
158
+ titleJobs
159
+ });
160
+ const run = await startTaskRun({
161
+ ...(options.activeTaskRuns
162
+ ? { activeTaskRuns: options.activeTaskRuns }
163
+ : {}),
164
+ eventBus: options.eventBus,
165
+ now,
166
+ repository: options.repository,
167
+ runtime: options.runtime,
168
+ runtimeInput: { ...input, taskId: task.id },
169
+ taskId: task.id
170
+ });
171
+ const updatedTask = options.repository.updateTaskSession(task.id, run.session) ?? task;
172
+ return toStartAgentResult(run, updatedTask, workspace);
173
+ },
174
+ subscribeToAgentEvents: (input, listener) => options.eventBus.subscribe(input, listener)
175
+ };
176
+ }
177
+ function emptyTaskMessageHistory() {
178
+ return { messages: [], subagents: [] };
179
+ }
180
+ async function loadSubagentMessages(input) {
181
+ const session = getSubagentSession(input.subagent);
182
+ if (!session)
183
+ return [];
184
+ try {
185
+ return await input.runtime.listMessages({
186
+ session,
187
+ workspacePath: input.workspacePath
188
+ });
189
+ }
190
+ catch {
191
+ return [];
192
+ }
193
+ }
194
+ function getSubagentSession(subagent) {
195
+ if (!subagent.sessionCreatedAt ||
196
+ !subagent.sessionId ||
197
+ !subagent.sessionPath) {
198
+ return undefined;
199
+ }
200
+ return {
201
+ createdAt: subagent.sessionCreatedAt,
202
+ id: subagent.sessionId,
203
+ path: subagent.sessionPath
204
+ };
205
+ }
206
+ function getTaskSession(task) {
207
+ if (!task.sessionId || !task.sessionPath || !task.sessionCreatedAt) {
208
+ return undefined;
209
+ }
210
+ return {
211
+ createdAt: task.sessionCreatedAt,
212
+ id: task.sessionId,
213
+ path: task.sessionPath
214
+ };
215
+ }
216
+ function toStartAgentResult(run, task, workspace) {
217
+ return {
218
+ agentId: run.agentId,
219
+ sessionId: run.session.id,
220
+ status: run.status,
221
+ task,
222
+ workspace
223
+ };
224
+ }
225
+ function ensureWorkspace(input) {
226
+ const existingWorkspace = input.repository.findWorkspaceByPath(input.workspacePath);
227
+ if (existingWorkspace) {
228
+ return existingWorkspace;
229
+ }
230
+ const name = basename(input.workspacePath) || input.workspacePath;
231
+ return input.repository.createWorkspace({
232
+ createdAt: input.createdAt,
233
+ id: `workspace_${randomUUID()}`,
234
+ name,
235
+ path: input.workspacePath,
236
+ updatedAt: input.createdAt
237
+ });
238
+ }
239
+ function getProviderSource(provider, modelProvidersService) {
240
+ const summary = modelProvidersService
241
+ .listModelProviders()
242
+ .find((item) => item.id === provider);
243
+ return summary?.source === "custom" ? "custom" : "built_in";
244
+ }
245
+ function getTaskModelMetadata(provider, modelId, modelProvidersService) {
246
+ const configuredModel = modelProvidersService?.getConfiguredModelForProvider(provider, modelId) ?? null;
247
+ return {
248
+ lastModelId: modelId,
249
+ lastModelName: configuredModel?.model.name ?? modelId,
250
+ lastModelProvider: provider,
251
+ lastModelProviderSource: modelProvidersService?.hasProvider(provider)
252
+ ? getProviderSource(provider, modelProvidersService)
253
+ : "built_in"
254
+ };
255
+ }
256
+ function startTitleJob(input) {
257
+ const titleJob = input.titleGenerator
258
+ .generateTitle({
259
+ ...(input.apiKey ? { apiKey: input.apiKey } : {}),
260
+ modelId: input.input.modelId,
261
+ prompt: input.input.prompt,
262
+ provider: input.input.provider
263
+ })
264
+ .then((title) => {
265
+ const currentTask = input.repository.findTaskById(input.task.id);
266
+ if (!currentTask || currentTask.title.trim().length > 0) {
267
+ return {
268
+ id: input.task.id,
269
+ title: currentTask?.title ?? title
270
+ };
271
+ }
272
+ const updatedTask = input.repository.updateTaskTitle(input.task.id, title, input.now().toISOString());
273
+ return {
274
+ id: input.task.id,
275
+ title: updatedTask?.title ?? title
276
+ };
277
+ })
278
+ .finally(() => {
279
+ input.titleJobs.delete(input.task.id);
280
+ });
281
+ input.titleJobs.set(input.task.id, titleJob);
282
+ }
@@ -0,0 +1,7 @@
1
+ import type { ApprovalDecision, ApprovalDecisionInput, ToolApprovalRequest } from "../agent-types";
2
+ export interface AgentApprovalStore {
3
+ decide: (input: ApprovalDecisionInput) => boolean;
4
+ request: (request: ToolApprovalRequest) => Promise<ApprovalDecision>;
5
+ }
6
+ export declare function createAgentApprovalStore(): AgentApprovalStore;
7
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/approval/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,OAAO,CAAC;IAClD,OAAO,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACtE;AAOD,wBAAgB,wBAAwB,IAAI,kBAAkB,CA2B7D"}
@@ -0,0 +1,23 @@
1
+ export function createAgentApprovalStore() {
2
+ const pendingApprovals = new Map();
3
+ return {
4
+ decide: (input) => {
5
+ const pending = pendingApprovals.get(input.approvalId);
6
+ if (!pending || pending.agentId !== input.agentId) {
7
+ return false;
8
+ }
9
+ pendingApprovals.delete(input.approvalId);
10
+ pending.resolve({
11
+ approved: input.approved,
12
+ ...(input.reason === undefined ? {} : { reason: input.reason })
13
+ });
14
+ return true;
15
+ },
16
+ request: (request) => new Promise((resolve) => {
17
+ pendingApprovals.set(request.approvalId, {
18
+ agentId: request.agentId,
19
+ resolve
20
+ });
21
+ })
22
+ };
23
+ }
@@ -0,0 +1,14 @@
1
+ import type { ServerPlugin } from "@hold-rein/plugin-server";
2
+ import type { AgentApprovalStore } from "./store";
3
+ import type { AgentEventBus } from "../event/event-bus";
4
+ import type { ApprovalPolicy } from "../agent-types";
5
+ export declare function runToolBeforeExecute(input: {
6
+ agentId: string;
7
+ approvalStore: AgentApprovalStore;
8
+ approvalPolicy: ApprovalPolicy;
9
+ event: ServerPlugin.ToolBeforeExecuteOptions["event"];
10
+ eventBus: AgentEventBus;
11
+ tool: ServerPlugin.PluginTool;
12
+ workspacePath: string;
13
+ }): Promise<ServerPlugin.ToolBeforeExecuteResult>;
14
+ //# sourceMappingURL=tool-approval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-approval.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/approval/tool-approval.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,gBAAgB,CAAC;AAE1E,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,kBAAkB,CAAC;IAClC,cAAc,EAAE,cAAc,CAAC;IAC/B,KAAK,EAAE,YAAY,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACtD,QAAQ,EAAE,aAAa,CAAC;IACxB,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;CACvB,iDA4CA"}
@@ -0,0 +1,43 @@
1
+ import { randomUUID } from "node:crypto";
2
+ export async function runToolBeforeExecute(input) {
3
+ if (!input.tool.beforeExecute)
4
+ return undefined;
5
+ return input.tool.beforeExecute({
6
+ workspacePath: input.workspacePath,
7
+ event: input.event,
8
+ requestApproval: async (title) => {
9
+ if (input.approvalPolicy === "run_all") {
10
+ return undefined;
11
+ }
12
+ const approvalId = `approval_${randomUUID()}`;
13
+ const approvalRequest = {
14
+ agentId: input.agentId,
15
+ approvalId,
16
+ ...(title === undefined ? {} : { title }),
17
+ tool: {
18
+ name: input.tool.name,
19
+ input: input.event.input,
20
+ ...(input.tool.description === undefined
21
+ ? {}
22
+ : { description: input.tool.description }),
23
+ ...(input.tool.label === undefined ? {} : { label: input.tool.label }),
24
+ toolCallId: input.event.toolCallId
25
+ }
26
+ };
27
+ const approval = input.approvalStore.request(approvalRequest);
28
+ input.eventBus.emit({
29
+ agentId: input.agentId,
30
+ payload: approvalRequest,
31
+ type: "approval_requested"
32
+ });
33
+ const decision = await approval;
34
+ return decision.approved
35
+ ? undefined
36
+ : {
37
+ block: true,
38
+ reason: decision.reason?.trim() ||
39
+ `User denied execute tool: ${input.tool.name}`
40
+ };
41
+ }
42
+ });
43
+ }
@@ -0,0 +1,16 @@
1
+ import type { Api, Model } from "@earendil-works/pi-ai";
2
+ export interface CustomAgentModelConfig {
3
+ baseUrl: string;
4
+ model: {
5
+ api: string;
6
+ contextWindow: number;
7
+ id: string;
8
+ input: string[];
9
+ maxTokens: number;
10
+ name: string;
11
+ provider: string;
12
+ reasoning: boolean;
13
+ };
14
+ }
15
+ export declare function toCustomAgentModel(configured: CustomAgentModelConfig): Model<Api>;
16
+ //# sourceMappingURL=custom-agent-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-agent-model.d.ts","sourceRoot":"","sources":["../../../src/modules/agents/custom-agent-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAC;QACZ,aAAa,EAAE,MAAM,CAAC;QACtB,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC;CACH;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,sBAAsB,GAAG,KAAK,CAAC,GAAG,CAAC,CAsBjF"}
@@ -0,0 +1,21 @@
1
+ export function toCustomAgentModel(configured) {
2
+ return {
3
+ ...configured.model,
4
+ api: configured.model.api,
5
+ baseUrl: configured.baseUrl,
6
+ ...(configured.model.api === "openai-completions"
7
+ ? {
8
+ compat: {
9
+ supportsDeveloperRole: false
10
+ }
11
+ }
12
+ : {}),
13
+ cost: {
14
+ cacheRead: 0,
15
+ cacheWrite: 0,
16
+ input: 0,
17
+ output: 0
18
+ },
19
+ input: configured.model.input.filter((input) => input === "text" || input === "image")
20
+ };
21
+ }
@@ -0,0 +1,3 @@
1
+ import { type AgentsService } from "./agents-service";
2
+ export declare function getDefaultAgentsService(): AgentsService;
3
+ //# sourceMappingURL=default-agents-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-agents-service.d.ts","sourceRoot":"","sources":["../../../src/modules/agents/default-agents-service.ts"],"names":[],"mappings":"AAUA,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAO3E,wBAAgB,uBAAuB,IAAI,aAAa,CAsCvD"}
@@ -0,0 +1,52 @@
1
+ import { loadApiEnv } from "../../config/env.js";
2
+ import { DB_FILE } from "../../config/const.js";
3
+ import { createDatabase, migrateDatabase } from "../../db/index.js";
4
+ import { createSqliteWorkspaceRepository } from "../workspaces/index.js";
5
+ import { createAgentApprovalStore } from "./agent-approval-store.js";
6
+ import { getDefaultActiveTaskRunRegistry } from "./active-task-run-registry.js";
7
+ import { createAgentEventBus } from "./agent-event-bus.js";
8
+ import { createAgentRuntime } from "./agent-runtime.js";
9
+ import { createDefaultTaskTitleGenerator } from "./agent-task-title-generator.js";
10
+ import { createAgentsService } from "./agents-service.js";
11
+ import { toCustomAgentModel } from "./custom-agent-model.js";
12
+ import { createSqliteSubagentRepository } from "./subagent-repository.js";
13
+ import { getDefaultModelProvidersService } from "../model-providers/index.js";
14
+ let service;
15
+ export function getDefaultAgentsService() {
16
+ if (!service) {
17
+ loadApiEnv();
18
+ const database = createDatabase(process.env.SQLITE_DB_PATH ?? DB_FILE);
19
+ const approvalStore = createAgentApprovalStore();
20
+ const eventBus = createAgentEventBus();
21
+ const modelProvidersService = getDefaultModelProvidersService();
22
+ const getCustomModel = createCustomModelLookup(modelProvidersService);
23
+ migrateDatabase(database.sqlite);
24
+ const repository = createSqliteWorkspaceRepository(database);
25
+ const subagentRepository = createSqliteSubagentRepository(database);
26
+ const runtime = createAgentRuntime({
27
+ approvalStore,
28
+ eventBus,
29
+ getApiKey: async (provider, modelId) => modelProvidersService.getConfiguredModelForProvider(provider, modelId)
30
+ ?.apiKey,
31
+ getCustomModel,
32
+ subagentRepository
33
+ });
34
+ service = createAgentsService({
35
+ activeTaskRuns: getDefaultActiveTaskRunRegistry(),
36
+ approvalStore,
37
+ eventBus,
38
+ modelProvidersService,
39
+ repository,
40
+ runtime,
41
+ subagentRepository,
42
+ titleGenerator: createDefaultTaskTitleGenerator({ getCustomModel })
43
+ });
44
+ }
45
+ return service;
46
+ }
47
+ function createCustomModelLookup(modelProvidersService) {
48
+ return (provider, modelId) => {
49
+ const configuredModel = modelProvidersService.getConfiguredModelForProvider(provider, modelId);
50
+ return configuredModel ? toCustomAgentModel(configuredModel) : null;
51
+ };
52
+ }
@@ -0,0 +1,8 @@
1
+ import type { AgentEventEnvelope, AgentEventSubscription, SubscribeAgentEventsInput } from "../agent-types";
2
+ export type AgentEventListener = (event: AgentEventEnvelope) => void;
3
+ export interface AgentEventBus {
4
+ emit: (event: Omit<AgentEventEnvelope, "sequence" | "timestamp">) => void;
5
+ subscribe: (input: SubscribeAgentEventsInput, listener: AgentEventListener) => AgentEventSubscription;
6
+ }
7
+ export declare function createAgentEventBus(): AgentEventBus;
8
+ //# sourceMappingURL=event-bus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-bus.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/event/event-bus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAErE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,WAAW,CAAC,KAAK,IAAI,CAAC;IAC1E,SAAS,EAAE,CACT,KAAK,EAAE,yBAAyB,EAChC,QAAQ,EAAE,kBAAkB,KACzB,sBAAsB,CAAC;CAC7B;AAED,wBAAgB,mBAAmB,IAAI,aAAa,CA6CnD"}
@@ -0,0 +1,40 @@
1
+ export function createAgentEventBus() {
2
+ const listeners = new Map();
3
+ const events = new Map();
4
+ const sequences = new Map();
5
+ return {
6
+ emit: (event) => {
7
+ const sequence = (sequences.get(event.agentId) ?? 0) + 1;
8
+ sequences.set(event.agentId, sequence);
9
+ const envelope = {
10
+ ...event,
11
+ sequence,
12
+ timestamp: new Date().toISOString()
13
+ };
14
+ const agentEvents = events.get(event.agentId) ?? [];
15
+ agentEvents.push(envelope);
16
+ events.set(event.agentId, agentEvents);
17
+ for (const listener of listeners.get(event.agentId) ?? []) {
18
+ listener(envelope);
19
+ }
20
+ },
21
+ subscribe: (input, listener) => {
22
+ for (const event of events.get(input.agentId) ?? []) {
23
+ if (event.sequence > (input.afterSequence ?? 0)) {
24
+ listener(event);
25
+ }
26
+ }
27
+ const agentListeners = listeners.get(input.agentId) ?? new Set();
28
+ agentListeners.add(listener);
29
+ listeners.set(input.agentId, agentListeners);
30
+ return {
31
+ unsubscribe: () => {
32
+ agentListeners.delete(listener);
33
+ if (agentListeners.size === 0) {
34
+ listeners.delete(input.agentId);
35
+ }
36
+ }
37
+ };
38
+ }
39
+ };
40
+ }
@@ -0,0 +1,11 @@
1
+ export { createActiveTaskRunRegistry, getDefaultActiveTaskRunRegistry, type ActiveTaskRunRegistry } from "./task/active-run-registry";
2
+ export { createAgentApprovalStore, type AgentApprovalStore } from "./approval/store";
3
+ export { createAgentEventBus, type AgentEventBus } from "./event/event-bus";
4
+ export { createAgentRuntime } from "./runtime";
5
+ export { type AgentRuntime } from './runtime/type';
6
+ export { createTokenCollection, type TokenCollection, type TokenUsageStorageTarget } from "./runtime/token-collection";
7
+ export { createAgentsRouter, type CreateAgentsRouterOptions } from "./router";
8
+ export { createAgentsService, type AgentsService } from "./service";
9
+ export { getDefaultAgentsService } from "./service/default";
10
+ export type { AgentEventEnvelope, AgentEventSubscription, ApprovalDecisionInput, ApprovalDecisionResult, StartAgentInput, StartAgentResult, SubscribeAgentEventsInput, ToolApprovalRequest } from "./agent-types";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/agents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,KAAK,qBAAqB,EAC3B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,wBAAwB,EACxB,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACL,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,EAC/B,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,mBAAmB,EACnB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ export { createActiveTaskRunRegistry, getDefaultActiveTaskRunRegistry } from "./task/active-run-registry.js";
2
+ export { createAgentApprovalStore } from "./approval/store.js";
3
+ export { createAgentEventBus } from "./event/event-bus.js";
4
+ export { createAgentRuntime } from "./runtime/index.js";
5
+ export {} from './runtime/type.js';
6
+ export { createTokenCollection } from "./runtime/token-collection.js";
7
+ export { createAgentsRouter } from "./router/index.js";
8
+ export { createAgentsService } from "./service/index.js";
9
+ export { getDefaultAgentsService } from "./service/default.js";
@@ -0,0 +1,4 @@
1
+ import type { StoredAgentMessage } from "../agent-types";
2
+ import type { AgentMessage } from "@earendil-works/pi-agent-core";
3
+ export declare function toStoredAgentMessage(id: string, message: AgentMessage): StoredAgentMessage;
4
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/message/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,YAAY,GACpB,kBAAkB,CAYpB"}
@@ -0,0 +1,11 @@
1
+ export function toStoredAgentMessage(id, message) {
2
+ const stored = { ...message, id };
3
+ if (stored.role !== "custom") {
4
+ delete stored.details;
5
+ }
6
+ delete stored.diagnostics;
7
+ delete stored.responseId;
8
+ delete stored.responseModel;
9
+ delete stored.usage;
10
+ return stored;
11
+ }
@@ -0,0 +1,16 @@
1
+ import type { Api, Model } from "@earendil-works/pi-ai";
2
+ export interface CustomAgentModelConfig {
3
+ baseUrl: string;
4
+ model: {
5
+ api: string;
6
+ contextWindow: number;
7
+ id: string;
8
+ input: string[];
9
+ maxTokens: number;
10
+ name: string;
11
+ provider: string;
12
+ reasoning: boolean;
13
+ };
14
+ }
15
+ export declare function toCustomAgentModel(configured: CustomAgentModelConfig): Model<Api>;
16
+ //# sourceMappingURL=custom-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-model.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/model/custom-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QACL,GAAG,EAAE,MAAM,CAAC;QACZ,aAAa,EAAE,MAAM,CAAC;QACtB,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC;CACH;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,sBAAsB,GAAG,KAAK,CAAC,GAAG,CAAC,CAsBjF"}
@@ -0,0 +1,21 @@
1
+ export function toCustomAgentModel(configured) {
2
+ return {
3
+ ...configured.model,
4
+ api: configured.model.api,
5
+ baseUrl: configured.baseUrl,
6
+ ...(configured.model.api === "openai-completions"
7
+ ? {
8
+ compat: {
9
+ supportsDeveloperRole: false
10
+ }
11
+ }
12
+ : {}),
13
+ cost: {
14
+ cacheRead: 0,
15
+ cacheWrite: 0,
16
+ input: 0,
17
+ output: 0
18
+ },
19
+ input: configured.model.input.filter((input) => input === "text" || input === "image")
20
+ };
21
+ }
@@ -0,0 +1,4 @@
1
+ import { type Api, type Model } from "@earendil-works/pi-ai";
2
+ export type AgentModelLookup = (provider: string, modelId: string) => Model<Api> | null | Promise<Model<Api> | null>;
3
+ export declare function resolveAgentModel(provider: string, modelId: string, getCustomModel?: AgentModelLookup): Promise<Model<Api> | null>;
4
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../../src/modules/agents/model/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,GAAG,EAER,KAAK,KAAK,EACX,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,gBAAgB,GAAG,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,KACZ,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AAEpD,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,cAAc,CAAC,EAAE,gBAAgB,GAChC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAQ5B"}