byterover-cli 0.3.4 → 0.4.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 (346) 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 +5 -0
  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/update-notifier.js +1 -5
  80. package/dist/hooks/init/welcome.js +1 -2
  81. package/dist/infra/cipher/agent-service-factory.d.ts +13 -6
  82. package/dist/infra/cipher/agent-service-factory.js +40 -16
  83. package/dist/infra/cipher/cipher-agent.js +4 -4
  84. package/dist/infra/cipher/consumer/consumer-lock.d.ts +20 -0
  85. package/dist/infra/cipher/consumer/consumer-lock.js +40 -0
  86. package/dist/infra/cipher/consumer/consumer-service.d.ts +99 -0
  87. package/dist/infra/cipher/consumer/consumer-service.js +165 -0
  88. package/dist/infra/cipher/consumer/execution-consumer.d.ts +121 -0
  89. package/dist/infra/cipher/consumer/execution-consumer.js +523 -0
  90. package/dist/infra/cipher/consumer/index.d.ts +33 -0
  91. package/dist/infra/cipher/consumer/index.js +33 -0
  92. package/dist/infra/cipher/consumer/queue-polling-service.d.ts +120 -0
  93. package/dist/infra/cipher/consumer/queue-polling-service.js +248 -0
  94. package/dist/infra/cipher/http/internal-llm-http-service.d.ts +94 -0
  95. package/dist/infra/cipher/http/internal-llm-http-service.js +118 -0
  96. package/dist/infra/cipher/llm/context/compaction/compaction-service.d.ts +106 -0
  97. package/dist/infra/cipher/llm/context/compaction/compaction-service.js +132 -0
  98. package/dist/infra/cipher/llm/context/compaction/index.d.ts +9 -0
  99. package/dist/infra/cipher/llm/context/compaction/index.js +9 -0
  100. package/dist/infra/cipher/llm/context/context-manager.d.ts +46 -2
  101. package/dist/infra/cipher/llm/context/context-manager.js +68 -4
  102. package/dist/infra/cipher/llm/context/rw-lock.d.ts +72 -0
  103. package/dist/infra/cipher/llm/context/rw-lock.js +145 -0
  104. package/dist/infra/cipher/llm/generators/byterover-content-generator.d.ts +7 -7
  105. package/dist/infra/cipher/llm/generators/byterover-content-generator.js +8 -8
  106. package/dist/infra/cipher/llm/internal-llm-service.js +2 -0
  107. package/dist/infra/cipher/session/session-manager.d.ts +4 -4
  108. package/dist/infra/cipher/session/session-manager.js +5 -5
  109. package/dist/infra/cipher/storage/agent-storage.d.ts +246 -0
  110. package/dist/infra/cipher/storage/agent-storage.js +956 -0
  111. package/dist/infra/cipher/storage/dual-format-history-storage.d.ts +77 -0
  112. package/dist/infra/cipher/storage/dual-format-history-storage.js +149 -0
  113. package/dist/infra/cipher/storage/granular-history-storage.d.ts +65 -0
  114. package/dist/infra/cipher/storage/granular-history-storage.js +118 -0
  115. package/dist/infra/cipher/storage/message-storage-service.d.ts +108 -0
  116. package/dist/infra/cipher/storage/message-storage-service.js +529 -0
  117. package/dist/infra/cipher/storage/process-utils.d.ts +16 -0
  118. package/dist/infra/cipher/storage/process-utils.js +43 -0
  119. package/dist/infra/cipher/storage/sqlite-key-storage.d.ts +105 -0
  120. package/dist/infra/cipher/storage/sqlite-key-storage.js +404 -0
  121. package/dist/infra/cipher/system-prompt/simple-prompt-factory.d.ts +1 -0
  122. package/dist/infra/cipher/system-prompt/simple-prompt-factory.js +7 -0
  123. package/dist/infra/cipher/tools/default-policy-rules.js +1 -1
  124. package/dist/infra/cipher/tools/implementations/curate-tool.d.ts +10 -0
  125. package/dist/infra/cipher/tools/implementations/curate-tool.js +371 -0
  126. package/dist/infra/cipher/tools/implementations/find-knowledge-topics-tool.js +11 -8
  127. package/dist/infra/cipher/tools/tool-manager.d.ts +8 -2
  128. package/dist/infra/cipher/tools/tool-manager.js +29 -2
  129. package/dist/infra/cipher/tools/tool-registry.js +7 -0
  130. package/dist/infra/http/authenticated-http-client.d.ts +21 -0
  131. package/dist/infra/http/authenticated-http-client.js +38 -0
  132. package/dist/infra/repl/commands/arg-parser.d.ts +97 -0
  133. package/dist/infra/repl/commands/arg-parser.js +129 -0
  134. package/dist/infra/repl/commands/clear-command.d.ts +5 -0
  135. package/dist/infra/repl/commands/clear-command.js +61 -0
  136. package/dist/infra/repl/commands/curate-command.d.ts +9 -0
  137. package/dist/infra/repl/commands/curate-command.js +88 -0
  138. package/dist/infra/repl/commands/gen-rules-command.d.ts +7 -0
  139. package/dist/infra/repl/commands/gen-rules-command.js +38 -0
  140. package/dist/infra/repl/commands/index.d.ts +8 -0
  141. package/dist/infra/repl/commands/index.js +36 -0
  142. package/dist/infra/repl/commands/init-command.d.ts +7 -0
  143. package/dist/infra/repl/commands/init-command.js +83 -0
  144. package/dist/infra/repl/commands/login-command.d.ts +7 -0
  145. package/dist/infra/repl/commands/login-command.js +50 -0
  146. package/dist/infra/repl/commands/logout-command.d.ts +5 -0
  147. package/dist/infra/repl/commands/logout-command.js +48 -0
  148. package/dist/infra/repl/commands/pull-command.d.ts +5 -0
  149. package/dist/infra/repl/commands/pull-command.js +61 -0
  150. package/dist/infra/repl/commands/push-command.d.ts +5 -0
  151. package/dist/infra/repl/commands/push-command.js +66 -0
  152. package/dist/infra/repl/commands/query-command.d.ts +5 -0
  153. package/dist/infra/repl/commands/query-command.js +66 -0
  154. package/dist/infra/repl/commands/space/index.d.ts +5 -0
  155. package/dist/infra/repl/commands/space/index.js +14 -0
  156. package/dist/infra/repl/commands/space/list-command.d.ts +5 -0
  157. package/dist/infra/repl/commands/space/list-command.js +70 -0
  158. package/dist/infra/repl/commands/space/switch-command.d.ts +5 -0
  159. package/dist/infra/repl/commands/space/switch-command.js +37 -0
  160. package/dist/infra/repl/commands/status-command.d.ts +5 -0
  161. package/dist/infra/repl/commands/status-command.js +39 -0
  162. package/dist/infra/repl/repl-startup.d.ts +18 -0
  163. package/dist/infra/repl/repl-startup.js +26 -0
  164. package/dist/infra/storage/file-global-config-store.d.ts +22 -0
  165. package/dist/infra/storage/file-global-config-store.js +65 -0
  166. package/dist/infra/storage/file-onboarding-preference-store.d.ts +10 -0
  167. package/dist/infra/storage/file-onboarding-preference-store.js +46 -0
  168. package/dist/infra/terminal/oclif-terminal.d.ts +19 -0
  169. package/dist/infra/terminal/oclif-terminal.js +60 -0
  170. package/dist/infra/terminal/repl-terminal.d.ts +31 -0
  171. package/dist/infra/terminal/repl-terminal.js +116 -0
  172. package/dist/infra/tracking/mixpanel-tracking-service.d.ts +11 -1
  173. package/dist/infra/tracking/mixpanel-tracking-service.js +18 -13
  174. package/dist/infra/usecase/clear-use-case.d.ts +20 -0
  175. package/dist/infra/usecase/clear-use-case.js +58 -0
  176. package/dist/infra/usecase/curate-use-case.d.ts +66 -0
  177. package/dist/infra/usecase/curate-use-case.js +283 -0
  178. package/dist/{commands/gen-rules.d.ts → infra/usecase/generate-rules-use-case.d.ts} +14 -20
  179. package/dist/{commands/gen-rules.js → infra/usecase/generate-rules-use-case.js} +59 -78
  180. package/dist/infra/usecase/init-use-case.d.ts +139 -0
  181. package/dist/{commands/init.js → infra/usecase/init-use-case.js} +184 -230
  182. package/dist/infra/usecase/login-use-case.d.ts +28 -0
  183. package/dist/infra/usecase/login-use-case.js +88 -0
  184. package/dist/infra/usecase/logout-use-case.d.ts +22 -0
  185. package/dist/infra/usecase/logout-use-case.js +51 -0
  186. package/dist/infra/usecase/pull-use-case.d.ts +35 -0
  187. package/dist/infra/usecase/pull-use-case.js +89 -0
  188. package/dist/infra/usecase/push-use-case.d.ts +37 -0
  189. package/dist/infra/usecase/push-use-case.js +124 -0
  190. package/dist/infra/usecase/query-use-case.d.ts +78 -0
  191. package/dist/infra/usecase/query-use-case.js +401 -0
  192. package/dist/infra/usecase/space-list-use-case.d.ts +27 -0
  193. package/dist/infra/usecase/space-list-use-case.js +64 -0
  194. package/dist/infra/usecase/space-switch-use-case.d.ts +36 -0
  195. package/dist/infra/usecase/space-switch-use-case.js +140 -0
  196. package/dist/infra/usecase/status-use-case.d.ts +27 -0
  197. package/dist/infra/usecase/status-use-case.js +97 -0
  198. package/dist/infra/workspace/workspace-detector-service.d.ts +3 -6
  199. package/dist/resources/prompts/curate-context-tree-curation.yml +23 -11
  200. package/dist/resources/prompts/query-context-tree-retrieval.yml +3 -4
  201. package/dist/resources/prompts/system-prompt.yml +1 -1
  202. package/dist/resources/prompts/tool-outputs.yml +4 -3
  203. package/dist/templates/sections/command-reference.md +12 -0
  204. package/dist/templates/sections/workflow.md +10 -1
  205. package/dist/tui/app.d.ts +9 -0
  206. package/dist/tui/app.js +26 -0
  207. package/dist/tui/components/enter-prompt.d.ts +13 -0
  208. package/dist/tui/components/enter-prompt.js +15 -0
  209. package/dist/tui/components/execution/execution-changes.d.ts +14 -0
  210. package/dist/tui/components/execution/execution-changes.js +15 -0
  211. package/dist/tui/components/execution/execution-content.d.ts +25 -0
  212. package/dist/tui/components/execution/execution-content.js +67 -0
  213. package/dist/tui/components/execution/execution-input.d.ts +12 -0
  214. package/dist/tui/components/execution/execution-input.js +16 -0
  215. package/dist/tui/components/execution/execution-progress.d.ts +21 -0
  216. package/dist/tui/components/execution/execution-progress.js +21 -0
  217. package/dist/tui/components/execution/execution-status.d.ts +13 -0
  218. package/dist/tui/components/execution/execution-status.js +19 -0
  219. package/dist/tui/components/execution/index.d.ts +11 -0
  220. package/dist/tui/components/execution/index.js +11 -0
  221. package/dist/tui/components/execution/log-item.d.ts +17 -0
  222. package/dist/tui/components/execution/log-item.js +25 -0
  223. package/dist/tui/components/footer.d.ts +5 -0
  224. package/dist/tui/components/footer.js +12 -0
  225. package/dist/tui/components/header.d.ts +18 -0
  226. package/dist/tui/components/header.js +18 -0
  227. package/dist/tui/components/index.d.ts +17 -0
  228. package/dist/tui/components/index.js +14 -0
  229. package/dist/tui/components/inline-prompts/index.d.ts +15 -0
  230. package/dist/tui/components/inline-prompts/index.js +10 -0
  231. package/dist/tui/components/inline-prompts/inline-confirm.d.ts +17 -0
  232. package/dist/tui/components/inline-prompts/inline-confirm.js +32 -0
  233. package/dist/tui/components/inline-prompts/inline-file-selector.d.ts +43 -0
  234. package/dist/tui/components/inline-prompts/inline-file-selector.js +185 -0
  235. package/dist/tui/components/inline-prompts/inline-input.d.ts +19 -0
  236. package/dist/tui/components/inline-prompts/inline-input.js +32 -0
  237. package/dist/tui/components/inline-prompts/inline-search.d.ts +20 -0
  238. package/dist/tui/components/inline-prompts/inline-search.js +50 -0
  239. package/dist/tui/components/inline-prompts/inline-select.d.ts +20 -0
  240. package/dist/tui/components/inline-prompts/inline-select.js +34 -0
  241. package/dist/tui/components/logo.d.ts +43 -0
  242. package/dist/tui/components/logo.js +103 -0
  243. package/dist/tui/components/message-item.d.ts +12 -0
  244. package/dist/tui/components/message-item.js +12 -0
  245. package/dist/tui/components/onboarding/copyable-prompt.d.ts +15 -0
  246. package/dist/tui/components/onboarding/copyable-prompt.js +65 -0
  247. package/dist/tui/components/onboarding/index.d.ts +7 -0
  248. package/dist/tui/components/onboarding/index.js +6 -0
  249. package/dist/tui/components/onboarding/onboarding-flow.d.ts +13 -0
  250. package/dist/tui/components/onboarding/onboarding-flow.js +304 -0
  251. package/dist/tui/components/onboarding/onboarding-step.d.ts +23 -0
  252. package/dist/tui/components/onboarding/onboarding-step.js +12 -0
  253. package/dist/tui/components/output-log.d.ts +14 -0
  254. package/dist/tui/components/output-log.js +13 -0
  255. package/dist/tui/components/scrollable-list.d.ts +30 -0
  256. package/dist/tui/components/scrollable-list.js +121 -0
  257. package/dist/tui/components/suggestions.d.ts +16 -0
  258. package/dist/tui/components/suggestions.js +162 -0
  259. package/dist/tui/components/tab-bar.d.ts +10 -0
  260. package/dist/tui/components/tab-bar.js +12 -0
  261. package/dist/tui/constants.d.ts +11 -0
  262. package/dist/tui/constants.js +13 -0
  263. package/dist/tui/contexts/auth-context.d.ts +30 -0
  264. package/dist/tui/contexts/auth-context.js +153 -0
  265. package/dist/tui/contexts/consumer.d.ts +31 -0
  266. package/dist/tui/contexts/consumer.js +56 -0
  267. package/dist/tui/contexts/index.d.ts +6 -0
  268. package/dist/tui/contexts/index.js +6 -0
  269. package/dist/tui/contexts/onboarding-context.d.ts +43 -0
  270. package/dist/tui/contexts/onboarding-context.js +181 -0
  271. package/dist/tui/contexts/services-context.d.ts +29 -0
  272. package/dist/tui/contexts/services-context.js +20 -0
  273. package/dist/tui/contexts/use-commands.d.ts +29 -0
  274. package/dist/tui/contexts/use-commands.js +53 -0
  275. package/dist/tui/contexts/use-mode.d.ts +43 -0
  276. package/dist/tui/contexts/use-mode.js +76 -0
  277. package/dist/tui/contexts/use-theme.d.ts +53 -0
  278. package/dist/tui/contexts/use-theme.js +60 -0
  279. package/dist/tui/hooks/index.d.ts +17 -0
  280. package/dist/tui/hooks/index.js +14 -0
  281. package/dist/tui/hooks/use-activity-logs.d.ts +26 -0
  282. package/dist/tui/hooks/use-activity-logs.js +90 -0
  283. package/dist/tui/hooks/use-consumer.d.ts +12 -0
  284. package/dist/tui/hooks/use-consumer.js +50 -0
  285. package/dist/tui/hooks/use-onboarding.d.ts +7 -0
  286. package/dist/tui/hooks/use-onboarding.js +6 -0
  287. package/dist/tui/hooks/use-queue-polling.d.ts +31 -0
  288. package/dist/tui/hooks/use-queue-polling.js +90 -0
  289. package/dist/tui/hooks/use-slash-command-processor.d.ts +16 -0
  290. package/dist/tui/hooks/use-slash-command-processor.js +132 -0
  291. package/dist/tui/hooks/use-slash-completion.d.ts +30 -0
  292. package/dist/tui/hooks/use-slash-completion.js +230 -0
  293. package/dist/tui/hooks/use-tab-navigation.d.ts +10 -0
  294. package/dist/tui/hooks/use-tab-navigation.js +35 -0
  295. package/dist/tui/hooks/use-visible-window.d.ts +22 -0
  296. package/dist/tui/hooks/use-visible-window.js +37 -0
  297. package/dist/tui/index.d.ts +1 -0
  298. package/dist/tui/index.js +1 -0
  299. package/dist/tui/providers/app-providers.d.ts +25 -0
  300. package/dist/tui/providers/app-providers.js +9 -0
  301. package/dist/tui/types/commands.d.ts +252 -0
  302. package/dist/tui/types/commands.js +16 -0
  303. package/dist/tui/types/dialogs.d.ts +37 -0
  304. package/dist/tui/types/dialogs.js +4 -0
  305. package/dist/tui/types/index.d.ts +11 -0
  306. package/dist/tui/types/index.js +7 -0
  307. package/dist/tui/types/messages.d.ts +55 -0
  308. package/dist/tui/types/messages.js +4 -0
  309. package/dist/tui/types/prompts.d.ts +100 -0
  310. package/dist/tui/types/prompts.js +4 -0
  311. package/dist/tui/types/ui.d.ts +14 -0
  312. package/dist/tui/types/ui.js +4 -0
  313. package/dist/tui/types.d.ts +1 -0
  314. package/dist/tui/types.js +1 -0
  315. package/dist/tui/views/command-view.d.ts +12 -0
  316. package/dist/tui/views/command-view.js +451 -0
  317. package/dist/tui/views/index.d.ts +6 -0
  318. package/dist/tui/views/index.js +6 -0
  319. package/dist/tui/views/login-view.d.ts +10 -0
  320. package/dist/tui/views/login-view.js +30 -0
  321. package/dist/tui/views/logs-view.d.ts +11 -0
  322. package/dist/tui/views/logs-view.js +73 -0
  323. package/dist/utils/file-validator.d.ts +16 -0
  324. package/dist/utils/file-validator.js +81 -0
  325. package/dist/utils/global-config-path.d.ts +15 -0
  326. package/dist/utils/global-config-path.js +38 -0
  327. package/oclif.manifest.json +29 -315
  328. package/package.json +11 -4
  329. package/dist/commands/clear.d.ts +0 -19
  330. package/dist/commands/clear.js +0 -78
  331. package/dist/commands/init.d.ts +0 -130
  332. package/dist/commands/login.d.ts +0 -22
  333. package/dist/commands/login.js +0 -108
  334. package/dist/commands/logout.d.ts +0 -16
  335. package/dist/commands/logout.js +0 -61
  336. package/dist/commands/pull.d.ts +0 -33
  337. package/dist/commands/pull.js +0 -115
  338. package/dist/commands/push.d.ts +0 -35
  339. package/dist/commands/push.js +0 -160
  340. package/dist/commands/space/list.d.ts +0 -25
  341. package/dist/commands/space/list.js +0 -114
  342. package/dist/commands/space/switch.d.ts +0 -36
  343. package/dist/commands/space/switch.js +0 -160
  344. package/dist/infra/cipher/grpc/internal-llm-grpc-service.d.ts +0 -149
  345. package/dist/infra/cipher/grpc/internal-llm-grpc-service.js +0 -364
  346. package/dist/infra/cipher/grpc/internal-llm-grpc.proto +0 -94
@@ -1,160 +0,0 @@
1
- import { confirm } from '@inquirer/prompts';
2
- import { Command, Flags, ux } from '@oclif/core';
3
- import { getCurrentConfig } from '../config/environment.js';
4
- import { DEFAULT_BRANCH } from '../constants.js';
5
- import { ExitCode, ExitError, exitWithCode } from '../infra/cipher/exit-codes.js';
6
- import { WorkspaceNotInitializedError } from '../infra/cipher/validation/workspace-validator.js';
7
- import { mapToPushContexts } from '../infra/cogit/context-tree-to-push-context-mapper.js';
8
- import { HttpCogitPushService } from '../infra/cogit/http-cogit-push-service.js';
9
- import { ProjectConfigStore } from '../infra/config/file-config-store.js';
10
- import { FileContextFileReader } from '../infra/context-tree/file-context-file-reader.js';
11
- import { FileContextTreeSnapshotService } from '../infra/context-tree/file-context-tree-snapshot-service.js';
12
- import { KeychainTokenStore } from '../infra/storage/keychain-token-store.js';
13
- import { MixpanelTrackingService } from '../infra/tracking/mixpanel-tracking-service.js';
14
- export default class Push extends Command {
15
- static description = 'Push context tree to ByteRover memory storage';
16
- static examples = [
17
- '<%= config.bin %> <%= command.id %>',
18
- '<%= config.bin %> <%= command.id %> --branch develop',
19
- '<%= config.bin %> <%= command.id %> -b feature-auth',
20
- ];
21
- static flags = {
22
- branch: Flags.string({
23
- // Can pass either --branch or -b
24
- char: 'b',
25
- default: DEFAULT_BRANCH,
26
- description: 'ByteRover branch name (not Git branch)',
27
- }),
28
- yes: Flags.boolean({
29
- char: 'y',
30
- default: false,
31
- description: 'Skip confirmation prompt',
32
- }),
33
- };
34
- buildSpaceUrl(webAppUrl, teamName, spaceName) {
35
- return `${webAppUrl}/${teamName}/${spaceName}`;
36
- }
37
- // Override catch to prevent oclif from logging errors that were already displayed
38
- async catch(error) {
39
- // Check if error is ExitError (message already displayed by exitWithCode)
40
- if (error instanceof ExitError) {
41
- return;
42
- }
43
- // Backwards compatibility: also check oclif.exit property
44
- if (error.oclif?.exit !== undefined) {
45
- // Error already displayed by exitWithCode, silently exit
46
- return;
47
- }
48
- // For other errors, re-throw to let oclif handle them
49
- throw error;
50
- }
51
- async checkProjectInit(projectConfigStore) {
52
- const projectConfig = await projectConfigStore.read();
53
- if (projectConfig === undefined) {
54
- throw new WorkspaceNotInitializedError('Project not initialized. Please run "brv init" to select your team and workspace.', '.brv');
55
- }
56
- return projectConfig;
57
- }
58
- async confirmPush(projectConfig, branch) {
59
- this.log('\nYou are about to push to ByteRover memory storage:');
60
- this.log(` Space: ${projectConfig.spaceName}`);
61
- this.log(` Branch: ${branch}`);
62
- return confirm({
63
- default: false,
64
- message: 'Push to ByteRover?',
65
- });
66
- }
67
- createServices() {
68
- const envConfig = getCurrentConfig();
69
- const tokenStore = new KeychainTokenStore();
70
- const trackingService = new MixpanelTrackingService(tokenStore);
71
- return {
72
- cogitPushService: new HttpCogitPushService({
73
- apiBaseUrl: envConfig.cogitApiBaseUrl,
74
- }),
75
- contextFileReader: new FileContextFileReader(),
76
- contextTreeSnapshotService: new FileContextTreeSnapshotService(),
77
- projectConfigStore: new ProjectConfigStore(),
78
- tokenStore,
79
- trackingService,
80
- };
81
- }
82
- async run() {
83
- const { flags } = await this.parse(Push);
84
- try {
85
- const { cogitPushService, contextFileReader, contextTreeSnapshotService, projectConfigStore, tokenStore, trackingService, } = this.createServices();
86
- await trackingService.track('mem:push');
87
- const token = await this.validateAuth(tokenStore);
88
- const projectConfig = await this.checkProjectInit(projectConfigStore);
89
- // Check for changes
90
- ux.action.start('Checking for Context Tree changes');
91
- const contextTreeChanges = await contextTreeSnapshotService.getChanges();
92
- ux.action.stop();
93
- if (contextTreeChanges.added.length === 0 &&
94
- contextTreeChanges.modified.length === 0 &&
95
- contextTreeChanges.deleted.length === 0) {
96
- this.log('No context changes to push.');
97
- return;
98
- }
99
- // Prompt for confirmation unless --yes flag is provided
100
- if (!flags.yes) {
101
- const confirmed = await this.confirmPush(projectConfig, flags.branch);
102
- if (!confirmed) {
103
- this.log('Push cancelled.');
104
- return;
105
- }
106
- }
107
- // Read and prepare files
108
- ux.action.start('Reading context files');
109
- const [addedFiles, modifiedFiles] = await Promise.all([
110
- contextFileReader.readMany(contextTreeChanges.added),
111
- contextFileReader.readMany(contextTreeChanges.modified),
112
- ]);
113
- ux.action.stop();
114
- const pushContexts = mapToPushContexts({
115
- addedFiles,
116
- deletedPaths: contextTreeChanges.deleted,
117
- modifiedFiles,
118
- });
119
- if (pushContexts.length === 0) {
120
- this.log('\nNo valid context files to push.');
121
- return;
122
- }
123
- // Push to CoGit (with two-request SHA flow)
124
- this.log('Pushing to ByteRover...');
125
- await cogitPushService.push({
126
- accessToken: token.accessToken,
127
- branch: flags.branch,
128
- contexts: pushContexts,
129
- sessionKey: token.sessionKey,
130
- spaceId: projectConfig.spaceId,
131
- teamId: projectConfig.teamId,
132
- });
133
- // Update snapshot ONLY after successful push
134
- await contextTreeSnapshotService.saveSnapshot();
135
- // Success message
136
- this.log('\n✓ Successfully pushed context tree to ByteRover memory storage!');
137
- this.log(` Branch: ${flags.branch}`);
138
- this.log(` Added: ${addedFiles.length}, Edited: ${modifiedFiles.length}, Deleted: ${contextTreeChanges.deleted.length}`);
139
- this.log(` View: ${this.buildSpaceUrl(getCurrentConfig().webAppUrl, projectConfig.teamName, projectConfig.spaceName)}`);
140
- }
141
- catch (error) {
142
- if (error instanceof WorkspaceNotInitializedError) {
143
- exitWithCode(ExitCode.VALIDATION_ERROR, 'Project not initialized. Please run "brv init" to select your team and workspace.');
144
- }
145
- // For other errors, use exitWithCode to properly display error before exit
146
- const message = error instanceof Error ? error.message : 'Push failed';
147
- exitWithCode(ExitCode.RUNTIME_ERROR, `Failed to push: ${message}`);
148
- }
149
- }
150
- async validateAuth(tokenStore) {
151
- const token = await tokenStore.load();
152
- if (token === undefined) {
153
- this.error('Not authenticated. Run "brv login" first.');
154
- }
155
- if (!token.isValid()) {
156
- this.error('Authentication token expired. Run "brv login" again.');
157
- }
158
- return token;
159
- }
160
- }
@@ -1,25 +0,0 @@
1
- import { Command } from '@oclif/core';
2
- import type { IProjectConfigStore } from '../../core/interfaces/i-project-config-store.js';
3
- import type { ISpaceService } from '../../core/interfaces/i-space-service.js';
4
- import type { ITokenStore } from '../../core/interfaces/i-token-store.js';
5
- export default class SpaceList extends Command {
6
- static description: string;
7
- static examples: string[];
8
- static flags: {
9
- all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
- json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
- limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
12
- offset: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
13
- };
14
- catch(error: Error & {
15
- oclif?: {
16
- exit: number;
17
- };
18
- }): Promise<void>;
19
- protected createServices(): {
20
- projectConfigStore: IProjectConfigStore;
21
- spaceService: ISpaceService;
22
- tokenStore: ITokenStore;
23
- };
24
- run(): Promise<void>;
25
- }
@@ -1,114 +0,0 @@
1
- import { Command, Flags, ux } from '@oclif/core';
2
- import { getCurrentConfig } from '../../config/environment.js';
3
- import { ExitCode, ExitError, exitWithCode } from '../../infra/cipher/exit-codes.js';
4
- import { ProjectConfigStore } from '../../infra/config/file-config-store.js';
5
- import { HttpSpaceService } from '../../infra/space/http-space-service.js';
6
- import { KeychainTokenStore } from '../../infra/storage/keychain-token-store.js';
7
- const DEFAULT_LIMIT = 50;
8
- const DEFAULT_OFFSET = 0;
9
- export default class SpaceList extends Command {
10
- static description = 'List all spaces for the current team (requires project initialization)';
11
- static examples = [
12
- '<%= config.bin %> <%= command.id %>',
13
- '<%= config.bin %> <%= command.id %> --all',
14
- '<%= config.bin %> <%= command.id %> --limit 10',
15
- '<%= config.bin %> <%= command.id %> --limit 10 --offset 20',
16
- '<%= config.bin %> <%= command.id %> --json',
17
- ];
18
- static flags = {
19
- all: Flags.boolean({
20
- char: 'a',
21
- default: false,
22
- description: 'Fetch all spaces (may be slow for large teams)',
23
- }),
24
- json: Flags.boolean({
25
- char: 'j',
26
- default: false,
27
- description: 'Output in JSON format',
28
- }),
29
- limit: Flags.integer({
30
- char: 'l',
31
- default: DEFAULT_LIMIT,
32
- description: 'Maximum number of spaces to fetch',
33
- }),
34
- offset: Flags.integer({
35
- char: 'o',
36
- default: DEFAULT_OFFSET,
37
- description: 'Number of spaces to skip',
38
- }),
39
- };
40
- async catch(error) {
41
- // Check if error is ExitError (message already displayed)
42
- if (error instanceof ExitError) {
43
- return;
44
- }
45
- // Backwards compatibility: also check oclif.exit property
46
- if (error.oclif?.exit !== undefined) {
47
- return;
48
- }
49
- // For unexpected errors, show the message
50
- this.error(error instanceof Error ? error.message : 'Failed to list spaces');
51
- }
52
- createServices() {
53
- const envConfig = getCurrentConfig();
54
- return {
55
- projectConfigStore: new ProjectConfigStore(),
56
- spaceService: new HttpSpaceService({ apiBaseUrl: envConfig.apiBaseUrl }),
57
- tokenStore: new KeychainTokenStore(),
58
- };
59
- }
60
- async run() {
61
- const { flags } = await this.parse(SpaceList);
62
- const { projectConfigStore, spaceService, tokenStore } = this.createServices();
63
- // Check project initialization
64
- const projectConfig = await projectConfigStore.read();
65
- if (!projectConfig) {
66
- exitWithCode(ExitCode.VALIDATION_ERROR, 'Project not initialized. Please run "brv init" first.');
67
- }
68
- const token = await tokenStore.load();
69
- if (!token) {
70
- exitWithCode(ExitCode.VALIDATION_ERROR, 'Not authenticated. Please run "brv login" first.');
71
- }
72
- if (!token.isValid()) {
73
- exitWithCode(ExitCode.VALIDATION_ERROR, 'Authentication token expired. Please run "brv login" again.');
74
- }
75
- // Fetch spaces for the team from project config
76
- ux.action.start(`Fetching spaces for ${projectConfig.teamName}`);
77
- let result;
78
- try {
79
- result = await spaceService.getSpaces(token.accessToken, token.sessionKey, projectConfig.teamId, flags.all ? { fetchAll: true } : { limit: flags.limit, offset: flags.offset });
80
- }
81
- finally {
82
- ux.action.stop();
83
- }
84
- // Handle empty results
85
- if (result.spaces.length === 0) {
86
- this.log(`No spaces found in team "${projectConfig.teamName}".`);
87
- return;
88
- }
89
- // Display results based on format
90
- if (flags.json) {
91
- this.log(JSON.stringify({
92
- showing: result.spaces.length,
93
- spaces: result.spaces.map((s) => s.toJson()),
94
- team: { id: projectConfig.teamId, name: projectConfig.teamName },
95
- total: result.total,
96
- }, null, 2));
97
- return;
98
- }
99
- // Human-readable format
100
- this.log(`\nSpaces in team "${projectConfig.teamName}":\n`);
101
- this.log(`Found ${result.spaces.length} space(s):\n`);
102
- for (const [index, space] of result.spaces.entries()) {
103
- this.log(` ${index + 1}. ${space.getDisplayName()}`);
104
- }
105
- // Pagination warning
106
- if (!flags.all && result.spaces.length < result.total) {
107
- const remaining = result.total - result.spaces.length - flags.offset;
108
- this.log(`\nShowing ${result.spaces.length} of ${result.total} spaces.`);
109
- if (remaining > 0) {
110
- this.log('Use --all to fetch all spaces, or use --limit and --offset for pagination.');
111
- }
112
- }
113
- }
114
- }
@@ -1,36 +0,0 @@
1
- import { Command } from '@oclif/core';
2
- import type { Space } from '../../core/domain/entities/space.js';
3
- import type { Team } from '../../core/domain/entities/team.js';
4
- import type { IProjectConfigStore } from '../../core/interfaces/i-project-config-store.js';
5
- import type { ISpaceService } from '../../core/interfaces/i-space-service.js';
6
- import type { ITeamService } from '../../core/interfaces/i-team-service.js';
7
- import type { ITokenStore } from '../../core/interfaces/i-token-store.js';
8
- import { Agent } from '../../core/domain/entities/agent.js';
9
- export default class SpaceSwitch extends Command {
10
- static description: string;
11
- static examples: string[];
12
- catch(error: Error & {
13
- oclif?: {
14
- exit: number;
15
- };
16
- }): Promise<void>;
17
- protected createServices(): {
18
- projectConfigStore: IProjectConfigStore;
19
- spaceService: ISpaceService;
20
- teamService: ITeamService;
21
- tokenStore: ITokenStore;
22
- };
23
- protected detectWorkspacesForAgent(agent: Agent): {
24
- chatLogPath: string;
25
- cwd: string;
26
- };
27
- /**
28
- * Prompts the user to select an agent.
29
- * This method is protected to allow test overrides.
30
- * @returns The selected agent
31
- */
32
- protected promptForAgentSelection(): Promise<Agent>;
33
- protected promptForSpaceSelection(spaces: Space[]): Promise<Space>;
34
- protected promptForTeamSelection(teams: Team[]): Promise<Team>;
35
- run(): Promise<void>;
36
- }
@@ -1,160 +0,0 @@
1
- import { search, select } from '@inquirer/prompts';
2
- import { Command, ux } from '@oclif/core';
3
- import { getCurrentConfig } from '../../config/environment.js';
4
- import { BRV_DIR, PROJECT_CONFIG_FILE } from '../../constants.js';
5
- import { AGENT_VALUES } from '../../core/domain/entities/agent.js';
6
- import { BrvConfig } from '../../core/domain/entities/brv-config.js';
7
- import { ExitCode, ExitError, exitWithCode } from '../../infra/cipher/exit-codes.js';
8
- import { ProjectConfigStore } from '../../infra/config/file-config-store.js';
9
- import { HttpSpaceService } from '../../infra/space/http-space-service.js';
10
- import { KeychainTokenStore } from '../../infra/storage/keychain-token-store.js';
11
- import { HttpTeamService } from '../../infra/team/http-team-service.js';
12
- import { WorkspaceDetectorService } from '../../infra/workspace/workspace-detector-service.js';
13
- export default class SpaceSwitch extends Command {
14
- static description = `Switch to a different team or space (updates ${BRV_DIR}/${PROJECT_CONFIG_FILE})`;
15
- static examples = [
16
- '<%= config.bin %> <%= command.id %>',
17
- '# Shows current configuration, then prompts for new team/space selection',
18
- ];
19
- async catch(error) {
20
- // Check if error is ExitError (message already displayed)
21
- if (error instanceof ExitError) {
22
- return;
23
- }
24
- // Backwards compatibility: also check oclif.exit property
25
- if (error.oclif?.exit !== undefined) {
26
- return;
27
- }
28
- // For unexpected errors, show the message
29
- this.error(error instanceof Error ? error.message : 'Switch failed');
30
- }
31
- createServices() {
32
- const envConfig = getCurrentConfig();
33
- return {
34
- projectConfigStore: new ProjectConfigStore(),
35
- spaceService: new HttpSpaceService({
36
- apiBaseUrl: envConfig.apiBaseUrl,
37
- }),
38
- teamService: new HttpTeamService({
39
- apiBaseUrl: envConfig.apiBaseUrl,
40
- }),
41
- tokenStore: new KeychainTokenStore(),
42
- };
43
- }
44
- detectWorkspacesForAgent(agent) {
45
- const detector = new WorkspaceDetectorService();
46
- const result = detector.detectWorkspaces(agent);
47
- return {
48
- chatLogPath: result.chatLogPath,
49
- cwd: result.cwd,
50
- };
51
- }
52
- /**
53
- * Prompts the user to select an agent.
54
- * This method is protected to allow test overrides.
55
- * @returns The selected agent
56
- */
57
- async promptForAgentSelection() {
58
- const AGENTS = AGENT_VALUES.map((agent) => ({
59
- name: agent,
60
- value: agent,
61
- }));
62
- const answer = await search({
63
- message: 'Which agent you are using (type to search):',
64
- async source(input) {
65
- if (!input)
66
- return AGENTS;
67
- return AGENTS.filter((agent) => agent.name.toLowerCase().includes(input.toLowerCase()) ||
68
- agent.value.toLowerCase().includes(input.toLowerCase()));
69
- },
70
- });
71
- return answer;
72
- }
73
- async promptForSpaceSelection(spaces) {
74
- const selectedSpaceId = await select({
75
- choices: spaces.map((space) => ({
76
- name: space.getDisplayName(),
77
- value: space.id,
78
- })),
79
- message: 'Select a space',
80
- });
81
- const selectedSpace = spaces.find((space) => space.id === selectedSpaceId);
82
- if (!selectedSpace) {
83
- exitWithCode(ExitCode.VALIDATION_ERROR, 'Space selection failed');
84
- }
85
- return selectedSpace;
86
- }
87
- async promptForTeamSelection(teams) {
88
- const selectedTeamId = await select({
89
- choices: teams.map((team) => ({
90
- name: team.name,
91
- value: team.id,
92
- })),
93
- message: 'Select a team',
94
- });
95
- const selectedTeam = teams.find((team) => team.id === selectedTeamId);
96
- if (!selectedTeam) {
97
- exitWithCode(ExitCode.VALIDATION_ERROR, 'Team selection failed');
98
- }
99
- return selectedTeam;
100
- }
101
- async run() {
102
- const { projectConfigStore, spaceService, teamService, tokenStore } = this.createServices();
103
- // Check project initialization (MUST exist for switch)
104
- const currentConfig = await projectConfigStore.read();
105
- if (!currentConfig) {
106
- exitWithCode(ExitCode.VALIDATION_ERROR, 'Project not initialized. Please run "brv init" first.');
107
- }
108
- // Show current configuration
109
- this.log('Current configuration:');
110
- this.log(` Team: ${currentConfig.teamName}`);
111
- this.log(` Space: ${currentConfig.spaceName}`);
112
- this.log();
113
- // Validate authentication
114
- const token = await tokenStore.load();
115
- if (!token) {
116
- exitWithCode(ExitCode.VALIDATION_ERROR, 'Not authenticated. Please run "brv login" first.');
117
- }
118
- if (!token.isValid()) {
119
- exitWithCode(ExitCode.VALIDATION_ERROR, 'Authentication token expired. Please run "brv login" again.');
120
- }
121
- // Fetch all teams
122
- ux.action.start('Fetching all teams');
123
- const teamResult = await teamService.getTeams(token.accessToken, token.sessionKey, { fetchAll: true });
124
- ux.action.stop();
125
- if (teamResult.teams.length === 0) {
126
- exitWithCode(ExitCode.VALIDATION_ERROR, 'No teams found. Please create a team in the ByteRover dashboard first.');
127
- }
128
- // Prompt for team selection
129
- this.log();
130
- const selectedTeam = await this.promptForTeamSelection(teamResult.teams);
131
- // Fetch spaces for selected team
132
- ux.action.start('Fetching all spaces');
133
- const spaceResult = await spaceService.getSpaces(token.accessToken, token.sessionKey, selectedTeam.id, {
134
- fetchAll: true,
135
- });
136
- ux.action.stop();
137
- if (spaceResult.spaces.length === 0) {
138
- exitWithCode(ExitCode.VALIDATION_ERROR, `No spaces found in team "${selectedTeam.getDisplayName()}". Please create a space in the ByteRover dashboard first.`);
139
- }
140
- // Prompt for space selection
141
- this.log();
142
- const selectedSpace = await this.promptForSpaceSelection(spaceResult.spaces);
143
- // Prompt for agent selection
144
- this.log();
145
- const selectedAgent = await this.promptForAgentSelection();
146
- this.log();
147
- const { chatLogPath, cwd } = this.detectWorkspacesForAgent(selectedAgent);
148
- // Update configuration
149
- const newConfig = BrvConfig.fromSpace({
150
- chatLogPath,
151
- cwd,
152
- ide: selectedAgent,
153
- space: selectedSpace,
154
- });
155
- await projectConfigStore.write(newConfig);
156
- // Display success
157
- this.log(`\n✓ Successfully switched to space: ${selectedSpace.getDisplayName()}`);
158
- this.log(`✓ Configuration updated in: ${BRV_DIR}/${PROJECT_CONFIG_FILE}`);
159
- }
160
- }
@@ -1,149 +0,0 @@
1
- import type { RequestOptions } from '@anthropic-ai/sdk/internal/request-options';
2
- import type { MessageCreateParamsNonStreaming } from '@anthropic-ai/sdk/resources/messages.js';
3
- import type { Content, GenerateContentConfig, GenerateContentResponse } from '@google/genai';
4
- /**
5
- * ByteRover gRPC LLM provider configuration.
6
- */
7
- export interface ByteRoverGrpcConfig {
8
- accessToken: string;
9
- grpcEndpoint: string;
10
- projectId?: string;
11
- region?: string;
12
- sessionKey: string;
13
- spaceId: string;
14
- teamId: string;
15
- timeout?: number;
16
- }
17
- /**
18
- * ByteRover gRPC LLM API client.
19
- *
20
- * Simple wrapper around ByteRover gRPC LLM service.
21
- * Delegates prompt building and formatting to service layer.
22
- *
23
- * Responsibilities:
24
- * - Call the remote gRPC service
25
- * - Stream and collect responses
26
- * - Convert to GenerateContentResponse format
27
- *
28
- * Does NOT:
29
- * - Build prompts or format inputs
30
- * - Parse or manipulate response content
31
- * - Handle tool call parsing from text
32
- */
33
- export declare class ByteRoverLlmGrpcService {
34
- private client;
35
- private readonly config;
36
- private credentials;
37
- /**
38
- * Initialize a new ByteRover gRPC LLM service client.
39
- *
40
- * Sets up configuration with sensible defaults:
41
- * - projectId defaults to 'byterover'
42
- * - region defaults to 'us-east1' (can be overridden per request)
43
- * - timeout defaults to 30 seconds
44
- *
45
- * Determines whether to use secure (TLS) or insecure connections based on
46
- * the endpoint hostname. The actual gRPC client is lazily initialized on first use.
47
- *
48
- * @param config - gRPC client configuration (accessToken, grpcEndpoint, sessionKey, optional: projectId, region, timeout)
49
- */
50
- constructor(config: ByteRoverGrpcConfig);
51
- /**
52
- * Close the gRPC connection and cleanup resources.
53
- *
54
- * Safely closes the underlying gRPC client connection if it exists.
55
- * Can be called multiple times without error.
56
- */
57
- close(): void;
58
- /**
59
- * Call ByteRover gRPC LLM service to generate content.
60
- *
61
- * Simple forward to remote gRPC service - delegates all formatting to backend.
62
- * Supports both Gemini and Claude formats - the correct format is determined
63
- * automatically based on the model name.
64
- *
65
- * Parameter structure differs by provider:
66
- * - Gemini: contents = Content[], config = GenerateContentConfig
67
- * - Claude: contents = MessageCreateParamsNonStreaming (complete body), config = RequestOptions (HTTP options)
68
- *
69
- * @param contents - For Gemini: Content[]. For Claude: MessageCreateParamsNonStreaming (complete body)
70
- * @param config - For Gemini: GenerateContentConfig. For Claude: RequestOptions (optional HTTP options)
71
- * @param model - Model to use (detects provider from model name)
72
- * @param executionMetadata - Optional execution metadata (mode, executionContext)
73
- * @returns Response in GenerateContentResponse format
74
- */
75
- generateContent(contents: Content[] | MessageCreateParamsNonStreaming, config: GenerateContentConfig | RequestOptions, model: string, executionMetadata?: Record<string, unknown>): Promise<GenerateContentResponse>;
76
- /**
77
- * Call the ByteRover gRPC Generate endpoint and collect streaming response.
78
- *
79
- * Handles authentication headers, streaming response collection, timeouts,
80
- * and error handling. Uses a timeout mechanism to prevent hanging when the
81
- * server closes the connection without proper cleanup.
82
- *
83
- * @param request - The gRPC generate request with model, provider, region, and params
84
- * @returns Promise resolving to the complete LLM response
85
- * @throws Error if client is not initialized, timeout occurs, or stream error happens
86
- */
87
- private callGrpcGenerate;
88
- /**
89
- * Check if error message contains any of the given keywords
90
- */
91
- private containsAny;
92
- /**
93
- * Detect LLM provider from model identifier.
94
- *
95
- * Determines which provider (Claude or Gemini) to use based on the model name.
96
- * Defaults to Gemini if the model doesn't match Claude patterns.
97
- *
98
- * @param model - Model identifier (e.g., 'claude-3-5-sonnet', 'gemini-2.5-flash')
99
- * @returns Provider name: 'claude' or 'gemini'
100
- */
101
- private detectProviderFromModel;
102
- /**
103
- * Detect appropriate GCP region from model identifier.
104
- *
105
- * Routes Claude models to us-east5 and Gemini models to us-east1.
106
- * This ensures compatibility with the provider's available regions on Vertex AI.
107
- *
108
- * @param model - Model identifier (e.g., 'claude-3-5-sonnet', 'gemini-2.5-flash')
109
- * @returns GCP region identifier ('us-east5' or 'us-east1')
110
- */
111
- private detectRegionFromModel;
112
- /**
113
- * Initialize the gRPC client on first use (lazy loading).
114
- *
115
- * Loads the protobuf definition, constructs the gRPC service client,
116
- * and caches it for reuse. Only called once - subsequent calls return immediately.
117
- *
118
- * Uses the proto file at runtime to support dynamic loading and avoid bundling
119
- * proto files into the compiled JavaScript.
120
- *
121
- * @throws Error if proto file cannot be found or parsed
122
- */
123
- private initializeClient;
124
- /**
125
- * Parse gRPC error to extract user-friendly error message.
126
- *
127
- * Handles common gRPC error patterns and extracts meaningful messages:
128
- * - RESOURCE_EXHAUSTED: Billing/quota issues
129
- * - UNAUTHENTICATED: Authentication failures
130
- * - PERMISSION_DENIED: Authorization issues
131
- * - UNAVAILABLE: Service unavailability
132
- * - Other errors: Generic failure message
133
- *
134
- * @param error - gRPC error object
135
- * @returns User-friendly error message
136
- */
137
- private parseGrpcError;
138
- /**
139
- * Parse gRPC status error to extract user-friendly error message.
140
- *
141
- * @param status - gRPC status object
142
- * @returns User-friendly error message
143
- */
144
- private parseGrpcStatusError;
145
- /**
146
- * Parse resource exhausted errors (billing/quota)
147
- */
148
- private parseResourceExhaustedError;
149
- }