byterover-cli 0.3.5 → 0.4.1

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 (345) hide show
  1. package/README.md +119 -63
  2. package/bin/dev.js +8 -1
  3. package/bin/run.js +7 -0
  4. package/dist/commands/cipher-agent/run.d.ts +30 -0
  5. package/dist/commands/cipher-agent/run.js +123 -61
  6. package/dist/commands/cipher-agent/set-prompt.d.ts +2 -0
  7. package/dist/commands/cipher-agent/set-prompt.js +13 -8
  8. package/dist/commands/cipher-agent/show-prompt.d.ts +2 -0
  9. package/dist/commands/cipher-agent/show-prompt.js +17 -12
  10. package/dist/commands/curate.d.ts +3 -60
  11. package/dist/commands/curate.js +45 -341
  12. package/dist/commands/foo.d.ts +4 -2
  13. package/dist/commands/foo.js +21 -16
  14. package/dist/commands/main.d.ts +9 -0
  15. package/dist/commands/main.js +34 -0
  16. package/dist/commands/query.d.ts +2 -48
  17. package/dist/commands/query.js +19 -287
  18. package/dist/commands/status.d.ts +2 -13
  19. package/dist/commands/status.js +12 -91
  20. package/dist/commands/watch.d.ts +2 -0
  21. package/dist/commands/watch.js +23 -19
  22. package/dist/config/environment.d.ts +1 -1
  23. package/dist/config/environment.js +2 -2
  24. package/dist/constants.d.ts +4 -5
  25. package/dist/constants.js +5 -5
  26. package/dist/core/domain/cipher/errors/storage-error.d.ts +89 -0
  27. package/dist/core/domain/cipher/errors/storage-error.js +130 -0
  28. package/dist/core/domain/cipher/queue/types.d.ts +71 -0
  29. package/dist/core/domain/cipher/queue/types.js +9 -0
  30. package/dist/core/domain/cipher/storage/message-storage-types.d.ts +218 -0
  31. package/dist/core/domain/cipher/storage/message-storage-types.js +18 -0
  32. package/dist/core/domain/cipher/tools/constants.d.ts +1 -0
  33. package/dist/core/domain/cipher/tools/constants.js +1 -0
  34. package/dist/core/domain/entities/event.d.ts +1 -1
  35. package/dist/core/domain/entities/event.js +8 -1
  36. package/dist/core/domain/entities/global-config.d.ts +36 -0
  37. package/dist/core/domain/entities/global-config.js +66 -0
  38. package/dist/core/domain/knowledge/directory-manager.d.ts +10 -0
  39. package/dist/core/domain/knowledge/directory-manager.js +18 -0
  40. package/dist/core/domain/knowledge/markdown-writer.d.ts +9 -0
  41. package/dist/core/domain/knowledge/markdown-writer.js +51 -1
  42. package/dist/core/interfaces/cipher/i-agent-storage.d.ts +152 -0
  43. package/dist/core/interfaces/cipher/i-agent-storage.js +1 -0
  44. package/dist/core/interfaces/cipher/i-cipher-agent.d.ts +2 -0
  45. package/dist/core/interfaces/cipher/i-key-storage.d.ts +91 -0
  46. package/dist/core/interfaces/cipher/i-key-storage.js +1 -0
  47. package/dist/core/interfaces/i-global-config-store.d.ts +34 -0
  48. package/dist/core/interfaces/i-global-config-store.js +1 -0
  49. package/dist/core/interfaces/i-onboarding-preference-store.d.ts +20 -0
  50. package/dist/core/interfaces/i-onboarding-preference-store.js +1 -0
  51. package/dist/core/interfaces/i-terminal.d.ts +146 -0
  52. package/dist/core/interfaces/i-terminal.js +1 -0
  53. package/dist/core/interfaces/i-workspace-detector-service.d.ts +8 -0
  54. package/dist/core/interfaces/i-workspace-detector-service.js +1 -0
  55. package/dist/core/interfaces/usecase/i-clear-use-case.d.ts +6 -0
  56. package/dist/core/interfaces/usecase/i-clear-use-case.js +1 -0
  57. package/dist/core/interfaces/usecase/i-curate-use-case.d.ts +10 -0
  58. package/dist/core/interfaces/usecase/i-curate-use-case.js +1 -0
  59. package/dist/core/interfaces/usecase/i-generate-rules-use-case.d.ts +3 -0
  60. package/dist/core/interfaces/usecase/i-generate-rules-use-case.js +1 -0
  61. package/dist/core/interfaces/usecase/i-init-use-case.d.ts +5 -0
  62. package/dist/core/interfaces/usecase/i-init-use-case.js +1 -0
  63. package/dist/core/interfaces/usecase/i-login-use-case.d.ts +3 -0
  64. package/dist/core/interfaces/usecase/i-login-use-case.js +1 -0
  65. package/dist/core/interfaces/usecase/i-logout-use-case.d.ts +5 -0
  66. package/dist/core/interfaces/usecase/i-logout-use-case.js +1 -0
  67. package/dist/core/interfaces/usecase/i-pull-use-case.d.ts +5 -0
  68. package/dist/core/interfaces/usecase/i-pull-use-case.js +1 -0
  69. package/dist/core/interfaces/usecase/i-push-use-case.d.ts +6 -0
  70. package/dist/core/interfaces/usecase/i-push-use-case.js +1 -0
  71. package/dist/core/interfaces/usecase/i-query-use-case.d.ts +9 -0
  72. package/dist/core/interfaces/usecase/i-query-use-case.js +1 -0
  73. package/dist/core/interfaces/usecase/i-space-list-use-case.d.ts +3 -0
  74. package/dist/core/interfaces/usecase/i-space-list-use-case.js +1 -0
  75. package/dist/core/interfaces/usecase/i-space-switch-use-case.d.ts +3 -0
  76. package/dist/core/interfaces/usecase/i-space-switch-use-case.js +1 -0
  77. package/dist/core/interfaces/usecase/i-status-use-case.d.ts +5 -0
  78. package/dist/core/interfaces/usecase/i-status-use-case.js +1 -0
  79. package/dist/hooks/init/welcome.js +10 -26
  80. package/dist/infra/cipher/agent-service-factory.d.ts +13 -6
  81. package/dist/infra/cipher/agent-service-factory.js +40 -16
  82. package/dist/infra/cipher/cipher-agent.js +4 -4
  83. package/dist/infra/cipher/consumer/consumer-lock.d.ts +20 -0
  84. package/dist/infra/cipher/consumer/consumer-lock.js +40 -0
  85. package/dist/infra/cipher/consumer/consumer-service.d.ts +99 -0
  86. package/dist/infra/cipher/consumer/consumer-service.js +165 -0
  87. package/dist/infra/cipher/consumer/execution-consumer.d.ts +121 -0
  88. package/dist/infra/cipher/consumer/execution-consumer.js +523 -0
  89. package/dist/infra/cipher/consumer/index.d.ts +33 -0
  90. package/dist/infra/cipher/consumer/index.js +33 -0
  91. package/dist/infra/cipher/consumer/queue-polling-service.d.ts +120 -0
  92. package/dist/infra/cipher/consumer/queue-polling-service.js +248 -0
  93. package/dist/infra/cipher/http/internal-llm-http-service.d.ts +94 -0
  94. package/dist/infra/cipher/http/internal-llm-http-service.js +118 -0
  95. package/dist/infra/cipher/llm/context/compaction/compaction-service.d.ts +106 -0
  96. package/dist/infra/cipher/llm/context/compaction/compaction-service.js +132 -0
  97. package/dist/infra/cipher/llm/context/compaction/index.d.ts +9 -0
  98. package/dist/infra/cipher/llm/context/compaction/index.js +9 -0
  99. package/dist/infra/cipher/llm/context/context-manager.d.ts +46 -2
  100. package/dist/infra/cipher/llm/context/context-manager.js +68 -4
  101. package/dist/infra/cipher/llm/context/rw-lock.d.ts +72 -0
  102. package/dist/infra/cipher/llm/context/rw-lock.js +145 -0
  103. package/dist/infra/cipher/llm/generators/byterover-content-generator.d.ts +7 -7
  104. package/dist/infra/cipher/llm/generators/byterover-content-generator.js +8 -8
  105. package/dist/infra/cipher/llm/internal-llm-service.js +2 -0
  106. package/dist/infra/cipher/session/session-manager.d.ts +4 -4
  107. package/dist/infra/cipher/session/session-manager.js +5 -5
  108. package/dist/infra/cipher/storage/agent-storage.d.ts +246 -0
  109. package/dist/infra/cipher/storage/agent-storage.js +956 -0
  110. package/dist/infra/cipher/storage/dual-format-history-storage.d.ts +77 -0
  111. package/dist/infra/cipher/storage/dual-format-history-storage.js +149 -0
  112. package/dist/infra/cipher/storage/granular-history-storage.d.ts +65 -0
  113. package/dist/infra/cipher/storage/granular-history-storage.js +118 -0
  114. package/dist/infra/cipher/storage/message-storage-service.d.ts +108 -0
  115. package/dist/infra/cipher/storage/message-storage-service.js +529 -0
  116. package/dist/infra/cipher/storage/process-utils.d.ts +16 -0
  117. package/dist/infra/cipher/storage/process-utils.js +43 -0
  118. package/dist/infra/cipher/storage/sqlite-key-storage.d.ts +105 -0
  119. package/dist/infra/cipher/storage/sqlite-key-storage.js +404 -0
  120. package/dist/infra/cipher/system-prompt/simple-prompt-factory.d.ts +1 -0
  121. package/dist/infra/cipher/system-prompt/simple-prompt-factory.js +7 -0
  122. package/dist/infra/cipher/tools/default-policy-rules.js +1 -1
  123. package/dist/infra/cipher/tools/implementations/curate-tool.d.ts +10 -0
  124. package/dist/infra/cipher/tools/implementations/curate-tool.js +371 -0
  125. package/dist/infra/cipher/tools/implementations/find-knowledge-topics-tool.js +11 -8
  126. package/dist/infra/cipher/tools/tool-manager.d.ts +8 -2
  127. package/dist/infra/cipher/tools/tool-manager.js +29 -2
  128. package/dist/infra/cipher/tools/tool-registry.js +7 -0
  129. package/dist/infra/http/authenticated-http-client.d.ts +21 -0
  130. package/dist/infra/http/authenticated-http-client.js +38 -0
  131. package/dist/infra/repl/commands/arg-parser.d.ts +97 -0
  132. package/dist/infra/repl/commands/arg-parser.js +129 -0
  133. package/dist/infra/repl/commands/clear-command.d.ts +5 -0
  134. package/dist/infra/repl/commands/clear-command.js +61 -0
  135. package/dist/infra/repl/commands/curate-command.d.ts +9 -0
  136. package/dist/infra/repl/commands/curate-command.js +88 -0
  137. package/dist/infra/repl/commands/gen-rules-command.d.ts +7 -0
  138. package/dist/infra/repl/commands/gen-rules-command.js +38 -0
  139. package/dist/infra/repl/commands/index.d.ts +8 -0
  140. package/dist/infra/repl/commands/index.js +36 -0
  141. package/dist/infra/repl/commands/init-command.d.ts +7 -0
  142. package/dist/infra/repl/commands/init-command.js +83 -0
  143. package/dist/infra/repl/commands/login-command.d.ts +7 -0
  144. package/dist/infra/repl/commands/login-command.js +50 -0
  145. package/dist/infra/repl/commands/logout-command.d.ts +5 -0
  146. package/dist/infra/repl/commands/logout-command.js +48 -0
  147. package/dist/infra/repl/commands/pull-command.d.ts +5 -0
  148. package/dist/infra/repl/commands/pull-command.js +61 -0
  149. package/dist/infra/repl/commands/push-command.d.ts +5 -0
  150. package/dist/infra/repl/commands/push-command.js +66 -0
  151. package/dist/infra/repl/commands/query-command.d.ts +5 -0
  152. package/dist/infra/repl/commands/query-command.js +66 -0
  153. package/dist/infra/repl/commands/space/index.d.ts +5 -0
  154. package/dist/infra/repl/commands/space/index.js +14 -0
  155. package/dist/infra/repl/commands/space/list-command.d.ts +5 -0
  156. package/dist/infra/repl/commands/space/list-command.js +70 -0
  157. package/dist/infra/repl/commands/space/switch-command.d.ts +5 -0
  158. package/dist/infra/repl/commands/space/switch-command.js +37 -0
  159. package/dist/infra/repl/commands/status-command.d.ts +5 -0
  160. package/dist/infra/repl/commands/status-command.js +39 -0
  161. package/dist/infra/repl/repl-startup.d.ts +18 -0
  162. package/dist/infra/repl/repl-startup.js +28 -0
  163. package/dist/infra/storage/file-global-config-store.d.ts +22 -0
  164. package/dist/infra/storage/file-global-config-store.js +65 -0
  165. package/dist/infra/storage/file-onboarding-preference-store.d.ts +10 -0
  166. package/dist/infra/storage/file-onboarding-preference-store.js +46 -0
  167. package/dist/infra/terminal/oclif-terminal.d.ts +19 -0
  168. package/dist/infra/terminal/oclif-terminal.js +60 -0
  169. package/dist/infra/terminal/repl-terminal.d.ts +31 -0
  170. package/dist/infra/terminal/repl-terminal.js +116 -0
  171. package/dist/infra/tracking/mixpanel-tracking-service.d.ts +11 -1
  172. package/dist/infra/tracking/mixpanel-tracking-service.js +18 -13
  173. package/dist/infra/usecase/clear-use-case.d.ts +20 -0
  174. package/dist/infra/usecase/clear-use-case.js +58 -0
  175. package/dist/infra/usecase/curate-use-case.d.ts +66 -0
  176. package/dist/infra/usecase/curate-use-case.js +288 -0
  177. package/dist/{commands/gen-rules.d.ts → infra/usecase/generate-rules-use-case.d.ts} +14 -20
  178. package/dist/{commands/gen-rules.js → infra/usecase/generate-rules-use-case.js} +59 -78
  179. package/dist/infra/usecase/init-use-case.d.ts +139 -0
  180. package/dist/{commands/init.js → infra/usecase/init-use-case.js} +197 -233
  181. package/dist/infra/usecase/login-use-case.d.ts +28 -0
  182. package/dist/infra/usecase/login-use-case.js +94 -0
  183. package/dist/infra/usecase/logout-use-case.d.ts +22 -0
  184. package/dist/infra/usecase/logout-use-case.js +51 -0
  185. package/dist/infra/usecase/pull-use-case.d.ts +35 -0
  186. package/dist/infra/usecase/pull-use-case.js +89 -0
  187. package/dist/infra/usecase/push-use-case.d.ts +37 -0
  188. package/dist/infra/usecase/push-use-case.js +124 -0
  189. package/dist/infra/usecase/query-use-case.d.ts +78 -0
  190. package/dist/infra/usecase/query-use-case.js +402 -0
  191. package/dist/infra/usecase/space-list-use-case.d.ts +27 -0
  192. package/dist/infra/usecase/space-list-use-case.js +64 -0
  193. package/dist/infra/usecase/space-switch-use-case.d.ts +36 -0
  194. package/dist/infra/usecase/space-switch-use-case.js +140 -0
  195. package/dist/infra/usecase/status-use-case.d.ts +27 -0
  196. package/dist/infra/usecase/status-use-case.js +97 -0
  197. package/dist/infra/workspace/workspace-detector-service.d.ts +3 -6
  198. package/dist/resources/prompts/curate-context-tree-curation.yml +23 -11
  199. package/dist/resources/prompts/query-context-tree-retrieval.yml +3 -4
  200. package/dist/resources/prompts/system-prompt.yml +1 -1
  201. package/dist/resources/prompts/tool-outputs.yml +4 -3
  202. package/dist/templates/sections/command-reference.md +12 -0
  203. package/dist/templates/sections/workflow.md +10 -1
  204. package/dist/tui/app.d.ts +9 -0
  205. package/dist/tui/app.js +26 -0
  206. package/dist/tui/components/enter-prompt.d.ts +13 -0
  207. package/dist/tui/components/enter-prompt.js +15 -0
  208. package/dist/tui/components/execution/execution-changes.d.ts +14 -0
  209. package/dist/tui/components/execution/execution-changes.js +15 -0
  210. package/dist/tui/components/execution/execution-content.d.ts +25 -0
  211. package/dist/tui/components/execution/execution-content.js +67 -0
  212. package/dist/tui/components/execution/execution-input.d.ts +12 -0
  213. package/dist/tui/components/execution/execution-input.js +16 -0
  214. package/dist/tui/components/execution/execution-progress.d.ts +21 -0
  215. package/dist/tui/components/execution/execution-progress.js +21 -0
  216. package/dist/tui/components/execution/execution-status.d.ts +13 -0
  217. package/dist/tui/components/execution/execution-status.js +19 -0
  218. package/dist/tui/components/execution/index.d.ts +11 -0
  219. package/dist/tui/components/execution/index.js +11 -0
  220. package/dist/tui/components/execution/log-item.d.ts +17 -0
  221. package/dist/tui/components/execution/log-item.js +25 -0
  222. package/dist/tui/components/footer.d.ts +5 -0
  223. package/dist/tui/components/footer.js +12 -0
  224. package/dist/tui/components/header.d.ts +18 -0
  225. package/dist/tui/components/header.js +18 -0
  226. package/dist/tui/components/index.d.ts +17 -0
  227. package/dist/tui/components/index.js +14 -0
  228. package/dist/tui/components/inline-prompts/index.d.ts +15 -0
  229. package/dist/tui/components/inline-prompts/index.js +10 -0
  230. package/dist/tui/components/inline-prompts/inline-confirm.d.ts +17 -0
  231. package/dist/tui/components/inline-prompts/inline-confirm.js +32 -0
  232. package/dist/tui/components/inline-prompts/inline-file-selector.d.ts +43 -0
  233. package/dist/tui/components/inline-prompts/inline-file-selector.js +185 -0
  234. package/dist/tui/components/inline-prompts/inline-input.d.ts +19 -0
  235. package/dist/tui/components/inline-prompts/inline-input.js +32 -0
  236. package/dist/tui/components/inline-prompts/inline-search.d.ts +20 -0
  237. package/dist/tui/components/inline-prompts/inline-search.js +50 -0
  238. package/dist/tui/components/inline-prompts/inline-select.d.ts +20 -0
  239. package/dist/tui/components/inline-prompts/inline-select.js +34 -0
  240. package/dist/tui/components/logo.d.ts +43 -0
  241. package/dist/tui/components/logo.js +103 -0
  242. package/dist/tui/components/message-item.d.ts +12 -0
  243. package/dist/tui/components/message-item.js +12 -0
  244. package/dist/tui/components/onboarding/copyable-prompt.d.ts +15 -0
  245. package/dist/tui/components/onboarding/copyable-prompt.js +65 -0
  246. package/dist/tui/components/onboarding/index.d.ts +7 -0
  247. package/dist/tui/components/onboarding/index.js +6 -0
  248. package/dist/tui/components/onboarding/onboarding-flow.d.ts +13 -0
  249. package/dist/tui/components/onboarding/onboarding-flow.js +304 -0
  250. package/dist/tui/components/onboarding/onboarding-step.d.ts +23 -0
  251. package/dist/tui/components/onboarding/onboarding-step.js +12 -0
  252. package/dist/tui/components/output-log.d.ts +14 -0
  253. package/dist/tui/components/output-log.js +13 -0
  254. package/dist/tui/components/scrollable-list.d.ts +30 -0
  255. package/dist/tui/components/scrollable-list.js +121 -0
  256. package/dist/tui/components/suggestions.d.ts +16 -0
  257. package/dist/tui/components/suggestions.js +162 -0
  258. package/dist/tui/components/tab-bar.d.ts +10 -0
  259. package/dist/tui/components/tab-bar.js +12 -0
  260. package/dist/tui/constants.d.ts +11 -0
  261. package/dist/tui/constants.js +13 -0
  262. package/dist/tui/contexts/auth-context.d.ts +30 -0
  263. package/dist/tui/contexts/auth-context.js +153 -0
  264. package/dist/tui/contexts/consumer.d.ts +31 -0
  265. package/dist/tui/contexts/consumer.js +56 -0
  266. package/dist/tui/contexts/index.d.ts +6 -0
  267. package/dist/tui/contexts/index.js +6 -0
  268. package/dist/tui/contexts/onboarding-context.d.ts +43 -0
  269. package/dist/tui/contexts/onboarding-context.js +181 -0
  270. package/dist/tui/contexts/services-context.d.ts +29 -0
  271. package/dist/tui/contexts/services-context.js +20 -0
  272. package/dist/tui/contexts/use-commands.d.ts +29 -0
  273. package/dist/tui/contexts/use-commands.js +54 -0
  274. package/dist/tui/contexts/use-mode.d.ts +43 -0
  275. package/dist/tui/contexts/use-mode.js +76 -0
  276. package/dist/tui/contexts/use-theme.d.ts +53 -0
  277. package/dist/tui/contexts/use-theme.js +60 -0
  278. package/dist/tui/hooks/index.d.ts +17 -0
  279. package/dist/tui/hooks/index.js +14 -0
  280. package/dist/tui/hooks/use-activity-logs.d.ts +26 -0
  281. package/dist/tui/hooks/use-activity-logs.js +90 -0
  282. package/dist/tui/hooks/use-consumer.d.ts +12 -0
  283. package/dist/tui/hooks/use-consumer.js +50 -0
  284. package/dist/tui/hooks/use-onboarding.d.ts +7 -0
  285. package/dist/tui/hooks/use-onboarding.js +6 -0
  286. package/dist/tui/hooks/use-queue-polling.d.ts +31 -0
  287. package/dist/tui/hooks/use-queue-polling.js +90 -0
  288. package/dist/tui/hooks/use-slash-command-processor.d.ts +16 -0
  289. package/dist/tui/hooks/use-slash-command-processor.js +132 -0
  290. package/dist/tui/hooks/use-slash-completion.d.ts +30 -0
  291. package/dist/tui/hooks/use-slash-completion.js +230 -0
  292. package/dist/tui/hooks/use-tab-navigation.d.ts +10 -0
  293. package/dist/tui/hooks/use-tab-navigation.js +35 -0
  294. package/dist/tui/hooks/use-visible-window.d.ts +22 -0
  295. package/dist/tui/hooks/use-visible-window.js +37 -0
  296. package/dist/tui/index.d.ts +1 -0
  297. package/dist/tui/index.js +1 -0
  298. package/dist/tui/providers/app-providers.d.ts +25 -0
  299. package/dist/tui/providers/app-providers.js +9 -0
  300. package/dist/tui/types/commands.d.ts +252 -0
  301. package/dist/tui/types/commands.js +16 -0
  302. package/dist/tui/types/dialogs.d.ts +37 -0
  303. package/dist/tui/types/dialogs.js +4 -0
  304. package/dist/tui/types/index.d.ts +11 -0
  305. package/dist/tui/types/index.js +7 -0
  306. package/dist/tui/types/messages.d.ts +55 -0
  307. package/dist/tui/types/messages.js +4 -0
  308. package/dist/tui/types/prompts.d.ts +100 -0
  309. package/dist/tui/types/prompts.js +4 -0
  310. package/dist/tui/types/ui.d.ts +14 -0
  311. package/dist/tui/types/ui.js +4 -0
  312. package/dist/tui/types.d.ts +1 -0
  313. package/dist/tui/types.js +1 -0
  314. package/dist/tui/views/command-view.d.ts +12 -0
  315. package/dist/tui/views/command-view.js +451 -0
  316. package/dist/tui/views/index.d.ts +6 -0
  317. package/dist/tui/views/index.js +6 -0
  318. package/dist/tui/views/login-view.d.ts +10 -0
  319. package/dist/tui/views/login-view.js +30 -0
  320. package/dist/tui/views/logs-view.d.ts +11 -0
  321. package/dist/tui/views/logs-view.js +73 -0
  322. package/dist/utils/file-validator.d.ts +16 -0
  323. package/dist/utils/file-validator.js +81 -0
  324. package/dist/utils/global-config-path.d.ts +15 -0
  325. package/dist/utils/global-config-path.js +38 -0
  326. package/oclif.manifest.json +29 -315
  327. package/package.json +11 -4
  328. package/dist/commands/clear.d.ts +0 -19
  329. package/dist/commands/clear.js +0 -78
  330. package/dist/commands/init.d.ts +0 -130
  331. package/dist/commands/login.d.ts +0 -22
  332. package/dist/commands/login.js +0 -108
  333. package/dist/commands/logout.d.ts +0 -16
  334. package/dist/commands/logout.js +0 -61
  335. package/dist/commands/pull.d.ts +0 -33
  336. package/dist/commands/pull.js +0 -115
  337. package/dist/commands/push.d.ts +0 -35
  338. package/dist/commands/push.js +0 -160
  339. package/dist/commands/space/list.d.ts +0 -25
  340. package/dist/commands/space/list.js +0 -114
  341. package/dist/commands/space/switch.d.ts +0 -36
  342. package/dist/commands/space/switch.js +0 -160
  343. package/dist/infra/cipher/grpc/internal-llm-grpc-service.d.ts +0 -149
  344. package/dist/infra/cipher/grpc/internal-llm-grpc-service.js +0 -364
  345. package/dist/infra/cipher/grpc/internal-llm-grpc.proto +0 -94
@@ -1,6 +1,6 @@
1
1
  import type { CipherAgentServices, SessionManagerConfig } from '../../../core/interfaces/cipher/cipher-services.js';
2
2
  import type { IChatSession } from '../../../core/interfaces/cipher/i-chat-session.js';
3
- import type { ByteRoverGrpcConfig } from '../agent-service-factory.js';
3
+ import type { ByteRoverHttpConfig } from '../agent-service-factory.js';
4
4
  /**
5
5
  * Options for SessionManager constructor
6
6
  */
@@ -18,7 +18,7 @@ export interface SessionManagerOptions {
18
18
  */
19
19
  export declare class SessionManager {
20
20
  private readonly config;
21
- private readonly grpcConfig;
21
+ private readonly httpConfig;
22
22
  private readonly llmConfig;
23
23
  private pendingCreations;
24
24
  private readonly sessions;
@@ -27,7 +27,7 @@ export declare class SessionManager {
27
27
  * Creates a new session manager
28
28
  *
29
29
  * @param sharedServices - Shared services from CipherAgent (ToolManager, SystemPromptManager, etc.)
30
- * @param grpcConfig - gRPC client configuration
30
+ * @param httpConfig - HTTP client configuration
31
31
  * @param llmConfig - LLM service configuration
32
32
  * @param llmConfig.openRouterApiKey - Optional OpenRouter API key for direct service
33
33
  * @param llmConfig.httpReferer - Optional HTTP Referer for OpenRouter rankings
@@ -39,7 +39,7 @@ export declare class SessionManager {
39
39
  * @param options - Optional session manager options
40
40
  * @param options.config - Session manager configuration
41
41
  */
42
- constructor(sharedServices: CipherAgentServices, grpcConfig: ByteRoverGrpcConfig, llmConfig: {
42
+ constructor(sharedServices: CipherAgentServices, httpConfig: ByteRoverHttpConfig, llmConfig: {
43
43
  httpReferer?: string;
44
44
  maxIterations?: number;
45
45
  maxTokens?: number;
@@ -12,7 +12,7 @@ import { ChatSession } from './chat-session.js';
12
12
  */
13
13
  export class SessionManager {
14
14
  config;
15
- grpcConfig;
15
+ httpConfig;
16
16
  llmConfig;
17
17
  pendingCreations = new Map();
18
18
  sessions = new Map();
@@ -21,7 +21,7 @@ export class SessionManager {
21
21
  * Creates a new session manager
22
22
  *
23
23
  * @param sharedServices - Shared services from CipherAgent (ToolManager, SystemPromptManager, etc.)
24
- * @param grpcConfig - gRPC client configuration
24
+ * @param httpConfig - HTTP client configuration
25
25
  * @param llmConfig - LLM service configuration
26
26
  * @param llmConfig.openRouterApiKey - Optional OpenRouter API key for direct service
27
27
  * @param llmConfig.httpReferer - Optional HTTP Referer for OpenRouter rankings
@@ -33,9 +33,9 @@ export class SessionManager {
33
33
  * @param options - Optional session manager options
34
34
  * @param options.config - Session manager configuration
35
35
  */
36
- constructor(sharedServices, grpcConfig, llmConfig, options) {
36
+ constructor(sharedServices, httpConfig, llmConfig, options) {
37
37
  this.sharedServices = sharedServices;
38
- this.grpcConfig = grpcConfig;
38
+ this.httpConfig = httpConfig;
39
39
  this.llmConfig = llmConfig;
40
40
  this.config = {
41
41
  maxSessions: options?.config?.maxSessions ?? 100,
@@ -157,7 +157,7 @@ export class SessionManager {
157
157
  */
158
158
  async createSessionInternal(id) {
159
159
  // Create session-specific services using factory
160
- const sessionServices = createSessionServices(id, this.sharedServices, this.grpcConfig, this.llmConfig);
160
+ const sessionServices = createSessionServices(id, this.sharedServices, this.httpConfig, this.llmConfig);
161
161
  // Create session with both shared and session services
162
162
  const session = new ChatSession(id, this.sharedServices, sessionServices);
163
163
  // Initialize LLM service to load persisted history from blob storage
@@ -0,0 +1,246 @@
1
+ import type { Execution, ExecutionStatus, ExecutionType, ToolCall, ToolCallInfo, ToolCallStatus, ToolCallUpdateOptions } from '../../../core/domain/cipher/queue/types.js';
2
+ import type { IAgentStorage } from '../../../core/interfaces/cipher/i-agent-storage.js';
3
+ export type { ConsumerLock, Execution, ExecutionStatus, ExecutionType, ToolCall, ToolCallInfo, ToolCallStatus, ToolCallUpdateOptions, } from '../../../core/domain/cipher/queue/types.js';
4
+ /**
5
+ * AgentStorage - SQLite-based storage for execution queue and tool calls
6
+ *
7
+ * Features:
8
+ * - Single database file at .brv/blobs/agent.db
9
+ * - Job queue via executions.status = 'queued'
10
+ * - Tool call tracking for UI polling
11
+ * - Prepared statement caching (no memory leak)
12
+ * - WAL mode for concurrent read/write
13
+ * - Orphan cleanup on startup
14
+ * - Old execution cleanup (max 100)
15
+ */
16
+ export declare class AgentStorage implements IAgentStorage {
17
+ initialized: boolean;
18
+ private db;
19
+ private dbFileInode;
20
+ private readonly dbPath;
21
+ private readonly inMemory;
22
+ private stmtAddToolCall;
23
+ private stmtCleanupOrphans;
24
+ private stmtCountCompletedFailed;
25
+ private stmtCreateExecution;
26
+ private stmtDeleteConsumerLock;
27
+ private stmtDeleteOldExecutions;
28
+ private stmtDequeueBatchSelect;
29
+ private stmtDequeueSelect;
30
+ private stmtFailQuery;
31
+ private stmtGetExecution;
32
+ private stmtGetExecutionsSince;
33
+ private stmtGetQueuedExecutions;
34
+ private stmtGetRecentExecutions;
35
+ private stmtGetRunningExecutions;
36
+ private stmtGetToolCalls;
37
+ private stmtOrphanFromConsumer;
38
+ private stmtOrphanMissingConsumer;
39
+ private stmtOrphanNullConsumer;
40
+ private stmtUpdateStatus;
41
+ private stmtUpdateToolCall;
42
+ private readonly storageDir;
43
+ constructor(config?: {
44
+ inMemory?: boolean;
45
+ storageDir?: string;
46
+ });
47
+ /**
48
+ * Acquire consumer lock (register this consumer)
49
+ * Only ONE consumer can run at a time - checks for any active consumer first
50
+ * @returns true if lock acquired, false if another consumer is already running
51
+ */
52
+ acquireConsumerLock(consumerId: string): boolean;
53
+ /**
54
+ * Add a tool call record
55
+ * @returns tool call id
56
+ */
57
+ addToolCall(executionId: string, info: ToolCallInfo): string;
58
+ /**
59
+ * Cleanup old executions, keep only maxKeep most recent completed/failed
60
+ */
61
+ cleanupOldExecutions(maxKeep?: number): number;
62
+ /**
63
+ * Cleanup orphaned executions (status='running') from previous session crash
64
+ * Should be called on startup
65
+ */
66
+ cleanupOrphanedExecutions(): number;
67
+ /**
68
+ * Cleanup stale consumers and orphan their executions
69
+ * A consumer is stale if its heartbeat is older than timeoutMs
70
+ * @param timeoutMs - heartbeat timeout (default 30 seconds)
71
+ * @returns number of orphaned executions
72
+ */
73
+ cleanupStaleConsumers(timeoutMs?: number): number;
74
+ /**
75
+ * Close database connection
76
+ */
77
+ close(): void;
78
+ /**
79
+ * Create a new execution
80
+ * @param type - 'curate' or 'query'
81
+ * @param input - content (curate) or query string (query)
82
+ * @returns execution id
83
+ */
84
+ createExecution(type: ExecutionType, input: string): string;
85
+ /**
86
+ * Dequeue multiple executions at once (atomic batch SELECT + UPDATE)
87
+ * This is more efficient than calling dequeueExecution() multiple times
88
+ * and ensures all queued items are seen in a single transaction snapshot
89
+ * @param limit - max number of executions to dequeue
90
+ * @param consumerId - ID of the consumer claiming these executions
91
+ * @returns array of executions (may be empty if queue is empty)
92
+ */
93
+ dequeueBatch(limit: number, consumerId?: string): Execution[];
94
+ /**
95
+ * Dequeue next queued execution (atomic SELECT + UPDATE)
96
+ * @param consumerId - ID of the consumer claiming this execution
97
+ * @returns execution or null if queue is empty
98
+ */
99
+ dequeueExecution(consumerId?: string): Execution | null;
100
+ /**
101
+ * Get execution by id
102
+ */
103
+ getExecution(id: string): Execution | null;
104
+ /**
105
+ * Get executions updated since timestamp (for incremental polling)
106
+ */
107
+ getExecutionsSince(timestamp: number): Execution[];
108
+ /**
109
+ * Get execution with all its tool calls (for UI display)
110
+ */
111
+ getExecutionWithToolCalls(id: string): null | {
112
+ execution: Execution;
113
+ toolCalls: ToolCall[];
114
+ };
115
+ /**
116
+ * Get all queued executions
117
+ */
118
+ getQueuedExecutions(): Execution[];
119
+ /**
120
+ * Get recent executions (for UI display)
121
+ */
122
+ getRecentExecutions(limit?: number): Execution[];
123
+ /**
124
+ * Get all running executions
125
+ */
126
+ getRunningExecutions(): Execution[];
127
+ /**
128
+ * Get all executions belonging to a specific consumer session.
129
+ * Returns executions ordered by created_at ASC (oldest first, newest last).
130
+ * Includes:
131
+ * - Curate executions with matching consumer_id
132
+ * - Query executions created after consumer started (no consumer_id)
133
+ */
134
+ getSessionExecutions(consumerId: string): Execution[];
135
+ /**
136
+ * Get queue statistics (queries DB directly for accurate counts)
137
+ */
138
+ getStats(): {
139
+ completed: number;
140
+ failed: number;
141
+ queued: number;
142
+ running: number;
143
+ total: number;
144
+ };
145
+ /**
146
+ * Get all tool calls for an execution
147
+ */
148
+ getToolCalls(executionId: string): ToolCall[];
149
+ /**
150
+ * Check if any consumer is currently active (has recent heartbeat)
151
+ * @param timeoutMs - heartbeat timeout (default 30 seconds)
152
+ */
153
+ hasActiveConsumer(timeoutMs?: number): boolean;
154
+ /**
155
+ * Check if a specific consumer lock exists in the database
156
+ * Used by Consumer to verify its lock is still valid after DB reconnection
157
+ */
158
+ hasConsumerLock(consumerId: string): boolean;
159
+ /**
160
+ * Initialize storage - create tables, enable WAL
161
+ * @param options - Initialization options
162
+ * @param options.cleanupOrphans - If true, cleanup orphaned executions (only Consumer should set this)
163
+ */
164
+ initialize(options?: {
165
+ cleanupOrphans?: boolean;
166
+ }): Promise<void>;
167
+ /**
168
+ * Check if the DB file has been replaced (different inode)
169
+ * Returns true if DB needs reconnection
170
+ */
171
+ isDbFileChanged(): boolean;
172
+ /**
173
+ * Reconnect to the database (close and reinitialize)
174
+ * Use when DB file has been replaced by another process (e.g., brv init)
175
+ */
176
+ reconnect(): Promise<void>;
177
+ /**
178
+ * Release consumer lock (unregister this consumer)
179
+ */
180
+ releaseConsumerLock(consumerId: string): void;
181
+ /**
182
+ * Update consumer heartbeat
183
+ */
184
+ updateConsumerHeartbeat(consumerId: string): void;
185
+ /**
186
+ * Update execution status
187
+ */
188
+ updateExecutionStatus(id: string, status: ExecutionStatus, result?: string, error?: string): void;
189
+ /**
190
+ * Update tool call status and result
191
+ */
192
+ updateToolCall(id: string, status: ToolCallStatus, options?: ToolCallUpdateOptions): void;
193
+ /**
194
+ * Ensure storage has been initialized
195
+ */
196
+ private ensureInitialized;
197
+ /**
198
+ * Get database instance with type safety (throws if not initialized)
199
+ * Use this instead of this.getDb() for proper type narrowing
200
+ */
201
+ private getDb;
202
+ /**
203
+ * Convert database row to Execution object
204
+ */
205
+ private rowToExecution;
206
+ /**
207
+ * Convert database row to ToolCall object
208
+ */
209
+ private rowToToolCall;
210
+ }
211
+ /**
212
+ * Get the singleton AgentStorage instance (auto-initializes if needed)
213
+ *
214
+ * This is the PRIMARY API - just call this and it handles everything.
215
+ * First call will initialize with provided config, subsequent calls return cached instance.
216
+ *
217
+ * @param config - Configuration options
218
+ * @param config.cleanupOrphans - Cleanup orphaned executions (only Consumer should set this)
219
+ * @param config.inMemory - Use in-memory database (for testing)
220
+ * @param config.storageDir - Directory for agent.db (default: .brv/blobs)
221
+ */
222
+ export declare function getAgentStorage(config?: {
223
+ cleanupOrphans?: boolean;
224
+ inMemory?: boolean;
225
+ storageDir?: string;
226
+ }): Promise<AgentStorage>;
227
+ /**
228
+ * Get the singleton AgentStorage instance (sync version)
229
+ * THROWS if not initialized - use getAgentStorage() instead for auto-init
230
+ *
231
+ * Use this only when you KNOW storage is already initialized (e.g., in Consumer after start)
232
+ */
233
+ export declare function getAgentStorageSync(): AgentStorage;
234
+ /**
235
+ * Initialize the singleton AgentStorage instance
236
+ * @deprecated Use getAgentStorage() directly - it auto-initializes
237
+ */
238
+ export declare function initializeAgentStorage(config?: {
239
+ cleanupOrphans?: boolean;
240
+ inMemory?: boolean;
241
+ storageDir?: string;
242
+ }): Promise<AgentStorage>;
243
+ /**
244
+ * Close and clear the singleton AgentStorage instance
245
+ */
246
+ export declare function closeAgentStorage(): void;