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
@@ -2,7 +2,7 @@ import { join } from 'node:path';
2
2
  import { createBlobStorage } from './blob/blob-storage-factory.js';
3
3
  import { AgentEventBus, SessionEventBus } from './events/event-emitter.js';
4
4
  import { FileSystemService } from './file-system/file-system-service.js';
5
- import { ByteRoverLlmGrpcService } from './grpc/internal-llm-grpc-service.js';
5
+ import { ByteRoverLlmHttpService } from './http/internal-llm-http-service.js';
6
6
  import { ByteRoverContentGenerator, LoggingContentGenerator, RetryableContentGenerator } from './llm/generators/index.js';
7
7
  import { ByteRoverLLMService } from './llm/internal-llm-service.js';
8
8
  import { OpenRouterLLMService } from './llm/openrouter-llm-service.js';
@@ -11,6 +11,10 @@ import { EventBasedLogger } from './logger/event-based-logger.js';
11
11
  import { MemoryManager } from './memory/memory-manager.js';
12
12
  import { ProcessService } from './process/process-service.js';
13
13
  import { BlobHistoryStorage } from './storage/blob-history-storage.js';
14
+ import { DualFormatHistoryStorage } from './storage/dual-format-history-storage.js';
15
+ import { GranularHistoryStorage } from './storage/granular-history-storage.js';
16
+ import { MessageStorageService } from './storage/message-storage-service.js';
17
+ import { SqliteKeyStorage } from './storage/sqlite-key-storage.js';
14
18
  import { SimplePromptFactory } from './system-prompt/simple-prompt-factory.js';
15
19
  import { CoreToolScheduler } from './tools/core-tool-scheduler.js';
16
20
  import { DEFAULT_POLICY_RULES } from './tools/default-policy-rules.js';
@@ -82,7 +86,27 @@ export async function createCipherAgentServices(llmConfig) {
82
86
  const toolManager = new ToolManager(toolProvider, toolScheduler);
83
87
  await toolManager.initialize();
84
88
  // 11. History storage (depends on BlobStorage) - SHARED across sessions
85
- const historyStorage = new BlobHistoryStorage(blobStorage);
89
+ // Use DualFormatHistoryStorage when granular storage is enabled
90
+ let historyStorage;
91
+ if (llmConfig.useGranularStorage) {
92
+ // Create granular storage infrastructure
93
+ const keyStorage = new SqliteKeyStorage({
94
+ storageDir: join(workingDirectory, '.brv'),
95
+ });
96
+ await keyStorage.initialize();
97
+ const messageStorage = new MessageStorageService(keyStorage);
98
+ const granularStorage = new GranularHistoryStorage(messageStorage);
99
+ const blobHistoryStorage = new BlobHistoryStorage(blobStorage);
100
+ // DualFormatHistoryStorage routes between formats:
101
+ // - New sessions → GranularHistoryStorage
102
+ // - Existing sessions → BlobHistoryStorage (no migration)
103
+ historyStorage = new DualFormatHistoryStorage(blobHistoryStorage, granularStorage);
104
+ logger.info('Granular history storage enabled for new sessions');
105
+ }
106
+ else {
107
+ // Default: use blob storage for all sessions
108
+ historyStorage = new BlobHistoryStorage(blobStorage);
109
+ }
86
110
  // Log successful initialization
87
111
  logger.info('CipherAgent services initialized successfully', {
88
112
  model: llmConfig.model,
@@ -116,7 +140,7 @@ export async function createCipherAgentServices(llmConfig) {
116
140
  *
117
141
  * @param sessionId - Unique session identifier
118
142
  * @param sharedServices - Shared services from agent
119
- * @param grpcConfig - gRPC configuration
143
+ * @param httpConfig - HTTP configuration
120
144
  * @param llmConfig - LLM service configuration
121
145
  * @param llmConfig.openRouterApiKey - Optional OpenRouter API key for OpenRouter service
122
146
  * @param llmConfig.httpReferer - Optional HTTP Referer for OpenRouter rankings
@@ -128,7 +152,7 @@ export async function createCipherAgentServices(llmConfig) {
128
152
  * @param llmConfig.verbose - Enable verbose debug output
129
153
  * @returns Initialized session services
130
154
  */
131
- export function createSessionServices(sessionId, sharedServices, grpcConfig, llmConfig) {
155
+ export function createSessionServices(sessionId, sharedServices, httpConfig, llmConfig) {
132
156
  // 1. Create session-specific event bus
133
157
  const sessionEventBus = new SessionEventBus();
134
158
  // 2. Create session-scoped logger
@@ -157,20 +181,20 @@ export function createSessionServices(sessionId, sharedServices, grpcConfig, llm
157
181
  });
158
182
  }
159
183
  else {
160
- // Use gRPC backend service (default) with new generator pattern
161
- // Step 1: Create gRPC service
162
- const grpcService = new ByteRoverLlmGrpcService({
163
- accessToken: grpcConfig.accessToken,
164
- grpcEndpoint: grpcConfig.grpcEndpoint,
165
- projectId: grpcConfig.projectId,
166
- region: grpcConfig.region,
167
- sessionKey: grpcConfig.sessionKey,
168
- spaceId: grpcConfig.spaceId,
169
- teamId: grpcConfig.teamId,
170
- timeout: grpcConfig.timeout,
184
+ // Use HTTP backend service (default) with new generator pattern
185
+ // Step 1: Create HTTP service
186
+ const httpService = new ByteRoverLlmHttpService({
187
+ accessToken: httpConfig.accessToken,
188
+ apiBaseUrl: httpConfig.apiBaseUrl,
189
+ projectId: httpConfig.projectId,
190
+ region: httpConfig.region,
191
+ sessionKey: httpConfig.sessionKey,
192
+ spaceId: httpConfig.spaceId,
193
+ teamId: httpConfig.teamId,
194
+ timeout: httpConfig.timeout,
171
195
  });
172
196
  // Step 2: Create base content generator
173
- let generator = new ByteRoverContentGenerator(grpcService, {
197
+ let generator = new ByteRoverContentGenerator(httpService, {
174
198
  maxTokens: llmConfig.maxTokens ?? 8192,
175
199
  model: llmConfig.model ?? 'gemini-2.5-pro',
176
200
  temperature: llmConfig.temperature ?? 0.7,
@@ -209,10 +209,10 @@ export class CipherAgent {
209
209
  // No need for upfront validation - let services handle their own setup
210
210
  // Create SHARED services only (following Dexto's pattern)
211
211
  const sharedServices = await createCipherAgentServices(this.llmConfig);
212
- // Extract gRPC config from llmConfig
213
- const grpcConfig = {
212
+ // Extract HTTP config from llmConfig
213
+ const httpConfig = {
214
214
  accessToken: this.llmConfig.accessToken,
215
- grpcEndpoint: this.llmConfig.grpcEndpoint,
215
+ apiBaseUrl: this.llmConfig.apiBaseUrl,
216
216
  projectId: this.llmConfig.projectId,
217
217
  region: this.llmConfig.region,
218
218
  sessionKey: this.llmConfig.sessionKey,
@@ -231,7 +231,7 @@ export class CipherAgent {
231
231
  verbose: this.llmConfig.verbose,
232
232
  };
233
233
  // Create SessionManager with shared services
234
- const sessionManager = new SessionManager(sharedServices, grpcConfig, sessionLLMConfig, {
234
+ const sessionManager = new SessionManager(sharedServices, httpConfig, sessionLLMConfig, {
235
235
  config: {
236
236
  maxSessions: 100,
237
237
  sessionTTL: 3_600_000, // 1 hour
@@ -0,0 +1,20 @@
1
+ /**
2
+ * DB-based consumer lock utilities
3
+ *
4
+ * The actual locking is now handled by AgentStorage methods:
5
+ * - acquireConsumerLock(consumerId)
6
+ * - releaseConsumerLock(consumerId)
7
+ * - hasActiveConsumer(timeoutMs)
8
+ *
9
+ * These utility functions provide a simple interface for checking consumer status.
10
+ */
11
+ /**
12
+ * Check if a consumer is currently running (has active heartbeat in DB)
13
+ * Auto-detects .brv/blobs path from cwd
14
+ */
15
+ export declare function isConsumerRunning(): Promise<boolean>;
16
+ /**
17
+ * Check if a consumer is currently running (sync version)
18
+ * Assumes storage is already initialized
19
+ */
20
+ export declare function isConsumerRunningSync(): boolean;
@@ -0,0 +1,40 @@
1
+ import { getAgentStorage, getAgentStorageSync } from '../storage/agent-storage.js';
2
+ // Consumer is considered stale after 30 seconds without heartbeat
3
+ const STALE_TIMEOUT_MS = 30_000;
4
+ /**
5
+ * DB-based consumer lock utilities
6
+ *
7
+ * The actual locking is now handled by AgentStorage methods:
8
+ * - acquireConsumerLock(consumerId)
9
+ * - releaseConsumerLock(consumerId)
10
+ * - hasActiveConsumer(timeoutMs)
11
+ *
12
+ * These utility functions provide a simple interface for checking consumer status.
13
+ */
14
+ /**
15
+ * Check if a consumer is currently running (has active heartbeat in DB)
16
+ * Auto-detects .brv/blobs path from cwd
17
+ */
18
+ export async function isConsumerRunning() {
19
+ try {
20
+ const storage = await getAgentStorage();
21
+ return storage.hasActiveConsumer(STALE_TIMEOUT_MS);
22
+ }
23
+ catch {
24
+ // If we can't check, assume not running
25
+ return false;
26
+ }
27
+ }
28
+ /**
29
+ * Check if a consumer is currently running (sync version)
30
+ * Assumes storage is already initialized
31
+ */
32
+ export function isConsumerRunningSync() {
33
+ try {
34
+ const storage = getAgentStorageSync();
35
+ return storage.hasActiveConsumer(STALE_TIMEOUT_MS);
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ }
@@ -0,0 +1,99 @@
1
+ export interface ConsumerServiceOptions {
2
+ /** Max concurrent jobs (default: 5) */
3
+ concurrency?: number;
4
+ /** Poll interval in ms (default: 1000) */
5
+ pollInterval?: number;
6
+ }
7
+ /**
8
+ * ConsumerService - Singleton background worker that processes the execution queue
9
+ *
10
+ * Architecture:
11
+ * ```
12
+ * ┌─────────────────┐
13
+ * │ ConsumerService │ ← Singleton, start once in main
14
+ * │ (process jobs) │
15
+ * └────────┬────────┘
16
+ * │ writes
17
+ * ▼
18
+ * ┌─────────────────┐
19
+ * │ AgentStorage │ ← SQLite DB (source of truth)
20
+ * │ (agent.db) │
21
+ * └────────┬────────┘
22
+ * │ polls
23
+ * ▼
24
+ * ┌─────────────────┐
25
+ * │QueuePollingServ │ ← UI subscribes here for updates
26
+ * └─────────────────┘
27
+ * ```
28
+ *
29
+ * Usage:
30
+ * ```typescript
31
+ * // Main - start consumer singleton (once)
32
+ * const consumer = getConsumerService({ concurrency: 5 })
33
+ * await consumer.start()
34
+ *
35
+ * // UI components - use QueuePollingService for monitoring
36
+ * import { getQueuePollingService } from './queue-polling-service'
37
+ * const poller = getQueuePollingService({ pollInterval: 500 })
38
+ * poller.on('snapshot', (snapshot) => renderUI(snapshot))
39
+ * await poller.start()
40
+ *
41
+ * // Cleanup
42
+ * consumer.dispose()
43
+ * ```
44
+ *
45
+ * Features:
46
+ * - Auto-loads auth token from Keychain
47
+ * - Auto-loads project config from .brv/config.json
48
+ * - Handles lock acquisition/release
49
+ * - Single dispose() for full cleanup
50
+ */
51
+ export declare class ConsumerService {
52
+ private consumer;
53
+ private readonly options;
54
+ private running;
55
+ constructor(options?: ConsumerServiceOptions);
56
+ /**
57
+ * Stop the consumer and cleanup all resources
58
+ */
59
+ dispose(): void;
60
+ /**
61
+ * Get the consumer ID (unique per session)
62
+ * Returns null if consumer hasn't started yet
63
+ */
64
+ getConsumerId(): null | string;
65
+ /**
66
+ * Check if consumer is running
67
+ */
68
+ isRunning(): boolean;
69
+ /**
70
+ * Start the consumer
71
+ *
72
+ * - Loads auth token from Keychain
73
+ * - Loads project config from .brv/config.json
74
+ * - Acquires consumer lock
75
+ * - Starts processing queue
76
+ *
77
+ * @throws Error if not authenticated
78
+ * @throws Error if another consumer is already running
79
+ */
80
+ start(): Promise<void>;
81
+ stop(): void;
82
+ private setupSignalHandlers;
83
+ }
84
+ /**
85
+ * Get or create singleton ConsumerService
86
+ *
87
+ * Usage:
88
+ * ```typescript
89
+ * const consumer = getConsumerService()
90
+ * await consumer.start()
91
+ * // later...
92
+ * consumer.dispose()
93
+ * ```
94
+ */
95
+ export declare function getConsumerService(options?: ConsumerServiceOptions): ConsumerService;
96
+ /**
97
+ * Dispose singleton and clear reference
98
+ */
99
+ export declare function disposeConsumerService(): void;
@@ -0,0 +1,165 @@
1
+ import { ProjectConfigStore } from '../../config/file-config-store.js';
2
+ import { KeychainTokenStore } from '../../storage/keychain-token-store.js';
3
+ import { closeAgentStorage } from '../storage/agent-storage.js';
4
+ import { createExecutionConsumer } from './execution-consumer.js';
5
+ // ==================== SERVICE ====================
6
+ /**
7
+ * ConsumerService - Singleton background worker that processes the execution queue
8
+ *
9
+ * Architecture:
10
+ * ```
11
+ * ┌─────────────────┐
12
+ * │ ConsumerService │ ← Singleton, start once in main
13
+ * │ (process jobs) │
14
+ * └────────┬────────┘
15
+ * │ writes
16
+ * ▼
17
+ * ┌─────────────────┐
18
+ * │ AgentStorage │ ← SQLite DB (source of truth)
19
+ * │ (agent.db) │
20
+ * └────────┬────────┘
21
+ * │ polls
22
+ * ▼
23
+ * ┌─────────────────┐
24
+ * │QueuePollingServ │ ← UI subscribes here for updates
25
+ * └─────────────────┘
26
+ * ```
27
+ *
28
+ * Usage:
29
+ * ```typescript
30
+ * // Main - start consumer singleton (once)
31
+ * const consumer = getConsumerService({ concurrency: 5 })
32
+ * await consumer.start()
33
+ *
34
+ * // UI components - use QueuePollingService for monitoring
35
+ * import { getQueuePollingService } from './queue-polling-service'
36
+ * const poller = getQueuePollingService({ pollInterval: 500 })
37
+ * poller.on('snapshot', (snapshot) => renderUI(snapshot))
38
+ * await poller.start()
39
+ *
40
+ * // Cleanup
41
+ * consumer.dispose()
42
+ * ```
43
+ *
44
+ * Features:
45
+ * - Auto-loads auth token from Keychain
46
+ * - Auto-loads project config from .brv/config.json
47
+ * - Handles lock acquisition/release
48
+ * - Single dispose() for full cleanup
49
+ */
50
+ export class ConsumerService {
51
+ consumer = null;
52
+ options;
53
+ running = false;
54
+ constructor(options) {
55
+ this.options = options ?? {};
56
+ }
57
+ /**
58
+ * Stop the consumer and cleanup all resources
59
+ */
60
+ dispose() {
61
+ if (!this.running)
62
+ return;
63
+ this.running = false;
64
+ if (this.consumer) {
65
+ this.consumer.stop();
66
+ this.consumer = null;
67
+ }
68
+ closeAgentStorage();
69
+ }
70
+ /**
71
+ * Get the consumer ID (unique per session)
72
+ * Returns null if consumer hasn't started yet
73
+ */
74
+ getConsumerId() {
75
+ return this.consumer?.getConsumerId() ?? null;
76
+ }
77
+ /**
78
+ * Check if consumer is running
79
+ */
80
+ isRunning() {
81
+ return this.running && this.consumer !== null;
82
+ }
83
+ /**
84
+ * Start the consumer
85
+ *
86
+ * - Loads auth token from Keychain
87
+ * - Loads project config from .brv/config.json
88
+ * - Acquires consumer lock
89
+ * - Starts processing queue
90
+ *
91
+ * @throws Error if not authenticated
92
+ * @throws Error if another consumer is already running
93
+ */
94
+ async start() {
95
+ if (this.running) {
96
+ throw new Error('Consumer already running');
97
+ }
98
+ // Load auth token
99
+ const tokenStore = new KeychainTokenStore();
100
+ const token = await tokenStore.load();
101
+ if (!token) {
102
+ throw new Error('Not authenticated. Please run "brv login" first.');
103
+ }
104
+ // Load project config (optional)
105
+ const configStore = new ProjectConfigStore();
106
+ const brvConfig = await configStore.read();
107
+ // Create consumer (auto-detects .brv/blobs from cwd)
108
+ this.consumer = createExecutionConsumer({
109
+ authToken: { accessToken: token.accessToken, sessionKey: token.sessionKey },
110
+ brvConfig: brvConfig ?? undefined,
111
+ maxConcurrency: this.options.concurrency ?? 5,
112
+ pollInterval: this.options.pollInterval ?? 1000,
113
+ });
114
+ // Start consumer
115
+ const started = await this.consumer.start();
116
+ if (!started) {
117
+ this.consumer = null;
118
+ throw new Error('Another consumer is already running in this directory');
119
+ }
120
+ this.running = true;
121
+ this.setupSignalHandlers();
122
+ }
123
+ // Alias for dispose
124
+ stop() {
125
+ this.dispose();
126
+ }
127
+ // ==================== PRIVATE ====================
128
+ setupSignalHandlers() {
129
+ // eslint-disable-next-line unicorn/consistent-function-scoping -- needs 'this' context
130
+ const cleanup = () => {
131
+ this.dispose();
132
+ };
133
+ process.on('SIGTERM', cleanup);
134
+ process.on('SIGINT', cleanup);
135
+ process.on('exit', cleanup);
136
+ }
137
+ }
138
+ // ==================== SINGLETON HELPER ====================
139
+ let instance = null;
140
+ /**
141
+ * Get or create singleton ConsumerService
142
+ *
143
+ * Usage:
144
+ * ```typescript
145
+ * const consumer = getConsumerService()
146
+ * await consumer.start()
147
+ * // later...
148
+ * consumer.dispose()
149
+ * ```
150
+ */
151
+ export function getConsumerService(options) {
152
+ if (!instance) {
153
+ instance = new ConsumerService(options);
154
+ }
155
+ return instance;
156
+ }
157
+ /**
158
+ * Dispose singleton and clear reference
159
+ */
160
+ export function disposeConsumerService() {
161
+ if (instance) {
162
+ instance.dispose();
163
+ instance = null;
164
+ }
165
+ }
@@ -0,0 +1,121 @@
1
+ import type { BrvConfig } from '../../../core/domain/entities/brv-config.js';
2
+ /**
3
+ * ExecutionConsumer - Polls queue and executes jobs in parallel
4
+ *
5
+ * Features:
6
+ * - DB-based lock with heartbeat (detects dead consumers)
7
+ * - Poll loop every 1 second
8
+ * - Parallel processing with configurable concurrency (default 5)
9
+ * - Process curate executions
10
+ * - Track tool calls to database
11
+ * - Cleanup old executions periodically
12
+ */
13
+ export declare class ExecutionConsumer {
14
+ private readonly activeJobs;
15
+ private authToken?;
16
+ private readonly brvConfig?;
17
+ private readonly consumerId;
18
+ private heartbeatInterval?;
19
+ private readonly maxConcurrency;
20
+ private readonly pollInterval;
21
+ private running;
22
+ constructor(options?: {
23
+ authToken?: {
24
+ accessToken: string;
25
+ sessionKey: string;
26
+ };
27
+ brvConfig?: BrvConfig;
28
+ maxConcurrency?: number;
29
+ pollInterval?: number;
30
+ });
31
+ /**
32
+ * Get the unique consumer ID for this instance
33
+ */
34
+ getConsumerId(): string;
35
+ /**
36
+ * Check if consumer is running
37
+ */
38
+ isRunning(): boolean;
39
+ /**
40
+ * Set auth token (can be set after construction)
41
+ */
42
+ setAuthToken(token: {
43
+ accessToken: string;
44
+ sessionKey: string;
45
+ }): void;
46
+ /**
47
+ * Start the consumer
48
+ * @returns true if started successfully, false if another consumer is running
49
+ */
50
+ start(): Promise<boolean>;
51
+ /**
52
+ * Stop the consumer
53
+ * Idempotent - safe to call multiple times (only runs cleanup once)
54
+ */
55
+ stop(): void;
56
+ /**
57
+ * Execute a curate job
58
+ */
59
+ private executeCurate;
60
+ /**
61
+ * Log execution start (extracted to reduce nesting depth)
62
+ */
63
+ private logExecutionStart;
64
+ /**
65
+ * Main poll loop - dequeues and processes jobs in parallel up to maxConcurrency
66
+ */
67
+ private poll;
68
+ /**
69
+ * Process a single execution
70
+ */
71
+ private processExecution;
72
+ /**
73
+ * Process execution asynchronously (fire and forget with tracking)
74
+ */
75
+ private processExecutionAsync;
76
+ /**
77
+ * Setup tool call tracking via event listeners
78
+ */
79
+ private setupToolCallTracking;
80
+ /**
81
+ * Try to pick up queued jobs (called after job completion)
82
+ */
83
+ private tryPickupJobs;
84
+ /**
85
+ * Try to recover lock after error (extracted to reduce nesting depth)
86
+ */
87
+ private tryRecoverLock;
88
+ }
89
+ /**
90
+ * Create a new ExecutionConsumer instance
91
+ */
92
+ export declare function createExecutionConsumer(options?: {
93
+ authToken?: {
94
+ accessToken: string;
95
+ sessionKey: string;
96
+ };
97
+ brvConfig?: BrvConfig;
98
+ maxConcurrency?: number;
99
+ pollInterval?: number;
100
+ }): ExecutionConsumer;
101
+ /**
102
+ * Try to start a consumer (singleton pattern)
103
+ * Returns the consumer instance if started, null if already running
104
+ */
105
+ export declare function tryStartConsumer(options?: {
106
+ authToken?: {
107
+ accessToken: string;
108
+ sessionKey: string;
109
+ };
110
+ brvConfig?: BrvConfig;
111
+ maxConcurrency?: number;
112
+ pollInterval?: number;
113
+ }): Promise<ExecutionConsumer | null>;
114
+ /**
115
+ * Get the current consumer instance (if running)
116
+ */
117
+ export declare function getConsumer(): ExecutionConsumer | null;
118
+ /**
119
+ * Stop the current consumer
120
+ */
121
+ export declare function stopConsumer(): void;