byterover-cli 1.8.0 → 2.1.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 (1362) hide show
  1. package/README.md +19 -594
  2. package/bin/kill-daemon.js +78 -0
  3. package/bin/run.js +2 -2
  4. package/dist/agent/core/domain/blob/types.d.ts +8 -2
  5. package/dist/agent/core/domain/llm/index.d.ts +2 -2
  6. package/dist/agent/core/domain/llm/index.js +2 -2
  7. package/dist/agent/core/domain/llm/registry.d.ts +8 -0
  8. package/dist/agent/core/domain/llm/registry.js +387 -14
  9. package/dist/agent/core/domain/llm/schemas.d.ts +13 -13
  10. package/dist/agent/core/domain/llm/schemas.js +3 -3
  11. package/dist/agent/core/domain/llm/types.d.ts +15 -5
  12. package/dist/agent/core/domain/llm/types.js +8 -2
  13. package/dist/agent/core/domain/sandbox/types.d.ts +8 -0
  14. package/dist/agent/core/domain/session/session-metadata.d.ts +7 -2
  15. package/dist/agent/core/domain/session/session-metadata.js +14 -4
  16. package/dist/agent/core/domain/streaming/types.d.ts +2 -0
  17. package/dist/agent/core/domain/tools/constants.d.ts +3 -0
  18. package/dist/agent/core/domain/tools/constants.js +3 -0
  19. package/dist/agent/core/domain/tools/types.d.ts +2 -0
  20. package/dist/agent/core/interfaces/cipher-services.d.ts +2 -4
  21. package/dist/agent/core/interfaces/i-chat-session.d.ts +1 -1
  22. package/dist/agent/core/interfaces/i-cipher-agent.d.ts +70 -0
  23. package/dist/agent/core/interfaces/i-curate-service.d.ts +23 -8
  24. package/dist/agent/core/interfaces/i-history-storage.d.ts +8 -0
  25. package/dist/agent/core/interfaces/i-key-storage.d.ts +11 -0
  26. package/dist/agent/core/interfaces/i-llm-service.d.ts +1 -1
  27. package/dist/agent/core/interfaces/i-sandbox-service.d.ts +34 -0
  28. package/dist/agent/core/interfaces/i-session-persistence.d.ts +3 -36
  29. package/dist/agent/core/interfaces/i-session-persistence.js +1 -1
  30. package/dist/agent/core/interfaces/i-tool-provider.d.ts +10 -0
  31. package/dist/agent/core/interfaces/i-tool-scheduler.d.ts +9 -0
  32. package/dist/agent/infra/agent/agent-schemas.d.ts +20 -8
  33. package/dist/agent/infra/agent/agent-schemas.js +8 -4
  34. package/dist/agent/infra/agent/cipher-agent.d.ts +111 -2
  35. package/dist/agent/infra/agent/cipher-agent.js +322 -20
  36. package/dist/agent/infra/agent/interactive-loop.js +1 -5
  37. package/dist/agent/infra/agent/provider-update-config.d.ts +17 -0
  38. package/dist/agent/infra/agent/service-initializer.d.ts +24 -7
  39. package/dist/agent/infra/agent/service-initializer.js +85 -92
  40. package/dist/agent/infra/blob/blob-storage-factory.d.ts +3 -3
  41. package/dist/agent/infra/blob/blob-storage-factory.js +5 -5
  42. package/dist/agent/infra/blob/file-blob-storage.d.ts +96 -0
  43. package/dist/agent/infra/blob/file-blob-storage.js +454 -0
  44. package/dist/agent/infra/blob/index.d.ts +2 -3
  45. package/dist/agent/infra/blob/index.js +4 -6
  46. package/dist/agent/infra/file-system/file-system-service.js +6 -3
  47. package/dist/agent/infra/http/internal-llm-http-service.d.ts +9 -5
  48. package/dist/agent/infra/http/internal-llm-http-service.js +12 -7
  49. package/dist/agent/infra/llm/agent-llm-service.d.ts +423 -0
  50. package/dist/agent/infra/llm/agent-llm-service.js +1273 -0
  51. package/dist/agent/infra/llm/context/compaction/compaction-service.d.ts +14 -12
  52. package/dist/agent/infra/llm/context/compaction/compaction-service.js +26 -9
  53. package/dist/agent/infra/llm/context/compression/compression-helpers.d.ts +35 -0
  54. package/dist/agent/infra/llm/context/compression/compression-helpers.js +124 -0
  55. package/dist/agent/infra/llm/context/compression/escalated-compression.d.ts +62 -0
  56. package/dist/agent/infra/llm/context/compression/escalated-compression.js +144 -0
  57. package/dist/agent/infra/llm/context/compression/index.d.ts +3 -0
  58. package/dist/agent/infra/llm/context/compression/index.js +3 -0
  59. package/dist/agent/infra/llm/context/compression/reactive-overflow.d.ts +0 -27
  60. package/dist/agent/infra/llm/context/compression/reactive-overflow.js +5 -113
  61. package/dist/agent/infra/llm/context/context-manager.d.ts +64 -4
  62. package/dist/agent/infra/llm/context/context-manager.js +239 -104
  63. package/dist/agent/infra/llm/context/deferred-effects.d.ts +30 -0
  64. package/dist/agent/infra/llm/context/deferred-effects.js +40 -0
  65. package/dist/agent/infra/llm/formatters/gemini-formatter.d.ts +1 -1
  66. package/dist/agent/infra/llm/formatters/gemini-formatter.js +14 -10
  67. package/dist/agent/infra/llm/generators/ai-sdk-content-generator.d.ts +33 -0
  68. package/dist/agent/infra/llm/generators/ai-sdk-content-generator.js +166 -0
  69. package/dist/agent/infra/llm/generators/ai-sdk-message-converter.d.ts +20 -0
  70. package/dist/agent/infra/llm/generators/ai-sdk-message-converter.js +182 -0
  71. package/dist/agent/infra/llm/generators/index.d.ts +3 -3
  72. package/dist/agent/infra/llm/generators/index.js +3 -3
  73. package/dist/agent/infra/llm/generators/retryable-content-generator.d.ts +7 -0
  74. package/dist/agent/infra/llm/generators/retryable-content-generator.js +29 -5
  75. package/dist/agent/infra/llm/index.d.ts +1 -2
  76. package/dist/agent/infra/llm/index.js +2 -3
  77. package/dist/agent/infra/llm/model-capabilities.d.ts +1 -0
  78. package/dist/agent/infra/llm/model-capabilities.js +31 -0
  79. package/dist/agent/infra/llm/providers/anthropic.d.ts +7 -0
  80. package/dist/agent/infra/llm/providers/anthropic.js +27 -0
  81. package/dist/agent/infra/llm/providers/byterover.d.ts +9 -0
  82. package/dist/agent/infra/llm/providers/byterover.js +37 -0
  83. package/dist/agent/infra/llm/providers/cerebras.d.ts +7 -0
  84. package/dist/agent/infra/llm/providers/cerebras.js +31 -0
  85. package/dist/agent/infra/llm/providers/cohere.d.ts +7 -0
  86. package/dist/agent/infra/llm/providers/cohere.js +26 -0
  87. package/dist/agent/infra/llm/providers/deepinfra.d.ts +7 -0
  88. package/dist/agent/infra/llm/providers/deepinfra.js +26 -0
  89. package/dist/agent/infra/llm/providers/glm.d.ts +7 -0
  90. package/dist/agent/infra/llm/providers/glm.js +30 -0
  91. package/dist/agent/infra/llm/providers/google.d.ts +7 -0
  92. package/dist/agent/infra/llm/providers/google.js +25 -0
  93. package/dist/agent/infra/llm/providers/groq.d.ts +7 -0
  94. package/dist/agent/infra/llm/providers/groq.js +26 -0
  95. package/dist/agent/infra/llm/providers/index.d.ts +24 -0
  96. package/dist/agent/infra/llm/providers/index.js +73 -0
  97. package/dist/agent/infra/llm/providers/minimax.d.ts +7 -0
  98. package/dist/agent/infra/llm/providers/minimax.js +30 -0
  99. package/dist/agent/infra/llm/providers/mistral.d.ts +7 -0
  100. package/dist/agent/infra/llm/providers/mistral.js +26 -0
  101. package/dist/agent/infra/llm/providers/moonshot.d.ts +7 -0
  102. package/dist/agent/infra/llm/providers/moonshot.js +30 -0
  103. package/dist/agent/infra/llm/providers/openai-compatible.d.ts +9 -0
  104. package/dist/agent/infra/llm/providers/openai-compatible.js +30 -0
  105. package/dist/agent/infra/llm/providers/openai.d.ts +7 -0
  106. package/dist/agent/infra/llm/providers/openai.js +26 -0
  107. package/dist/agent/infra/llm/providers/openrouter.d.ts +7 -0
  108. package/dist/agent/infra/llm/providers/openrouter.js +26 -0
  109. package/dist/agent/infra/llm/providers/perplexity.d.ts +7 -0
  110. package/dist/agent/infra/llm/providers/perplexity.js +26 -0
  111. package/dist/agent/infra/llm/providers/togetherai.d.ts +7 -0
  112. package/dist/agent/infra/llm/providers/togetherai.js +26 -0
  113. package/dist/agent/infra/llm/providers/types.d.ts +77 -0
  114. package/dist/agent/infra/llm/providers/types.js +7 -0
  115. package/dist/agent/infra/llm/providers/vercel.d.ts +7 -0
  116. package/dist/agent/infra/llm/providers/vercel.js +32 -0
  117. package/dist/agent/infra/llm/providers/xai.d.ts +7 -0
  118. package/dist/agent/infra/llm/providers/xai.js +26 -0
  119. package/dist/agent/infra/llm/retry/retry-policy.d.ts +13 -0
  120. package/dist/agent/infra/llm/retry/retry-policy.js +207 -0
  121. package/dist/agent/infra/llm/tokenizers/openrouter-tokenizer.js +1 -1
  122. package/dist/agent/infra/llm/tool-output-processor.d.ts +16 -4
  123. package/dist/agent/infra/llm/tool-output-processor.js +61 -16
  124. package/dist/agent/infra/map/agentic-map-service.d.ts +97 -0
  125. package/dist/agent/infra/map/agentic-map-service.js +309 -0
  126. package/dist/agent/infra/map/context-tree-store.d.ts +94 -0
  127. package/dist/agent/infra/map/context-tree-store.js +278 -0
  128. package/dist/agent/infra/map/index.d.ts +4 -0
  129. package/dist/agent/infra/map/index.js +4 -0
  130. package/dist/agent/infra/map/llm-map-memory.d.ts +59 -0
  131. package/dist/agent/infra/map/llm-map-memory.js +187 -0
  132. package/dist/agent/infra/map/llm-map-service.d.ts +36 -0
  133. package/dist/agent/infra/map/llm-map-service.js +118 -0
  134. package/dist/agent/infra/map/map-shared.d.ts +140 -0
  135. package/dist/agent/infra/map/map-shared.js +325 -0
  136. package/dist/agent/infra/map/worker-pool.d.ts +45 -0
  137. package/dist/agent/infra/map/worker-pool.js +73 -0
  138. package/dist/agent/infra/sandbox/curate-result-collector.d.ts +30 -0
  139. package/dist/agent/infra/sandbox/curate-result-collector.js +39 -0
  140. package/dist/agent/infra/sandbox/curate-service.d.ts +4 -1
  141. package/dist/agent/infra/sandbox/curate-service.js +12 -3
  142. package/dist/agent/infra/sandbox/curation-helpers.d.ts +62 -0
  143. package/dist/agent/infra/sandbox/curation-helpers.js +219 -0
  144. package/dist/agent/infra/sandbox/local-sandbox.d.ts +13 -0
  145. package/dist/agent/infra/sandbox/local-sandbox.js +41 -4
  146. package/dist/agent/infra/sandbox/sandbox-service.d.ts +52 -5
  147. package/dist/agent/infra/sandbox/sandbox-service.js +133 -18
  148. package/dist/agent/infra/sandbox/tools-sdk.d.ts +89 -4
  149. package/dist/agent/infra/sandbox/tools-sdk.js +80 -4
  150. package/dist/agent/infra/session/chat-session.d.ts +1 -1
  151. package/dist/agent/infra/session/chat-session.js +2 -2
  152. package/dist/agent/infra/session/session-event-forwarder.js +6 -3
  153. package/dist/agent/infra/session/session-manager.d.ts +20 -3
  154. package/dist/agent/infra/session/session-manager.js +49 -12
  155. package/dist/agent/infra/session/session-metadata-store.d.ts +17 -10
  156. package/dist/agent/infra/session/session-metadata-store.js +12 -87
  157. package/dist/agent/infra/storage/file-key-storage.d.ts +142 -0
  158. package/dist/agent/infra/storage/file-key-storage.js +572 -0
  159. package/dist/agent/infra/storage/granular-history-storage.d.ts +1 -1
  160. package/dist/agent/infra/storage/granular-history-storage.js +1 -1
  161. package/dist/agent/infra/storage/message-storage-service.js +134 -22
  162. package/dist/agent/infra/system-prompt/contributors/context-tree-structure-contributor.d.ts +4 -0
  163. package/dist/agent/infra/system-prompt/contributors/context-tree-structure-contributor.js +44 -16
  164. package/dist/agent/infra/system-prompt/contributors/map-selection-contributor.d.ts +16 -0
  165. package/dist/agent/infra/system-prompt/contributors/map-selection-contributor.js +47 -0
  166. package/dist/agent/infra/tools/core-tool-scheduler.js +3 -1
  167. package/dist/agent/infra/tools/implementations/agentic-map-tool.d.ts +35 -0
  168. package/dist/agent/infra/tools/implementations/agentic-map-tool.js +156 -0
  169. package/dist/agent/infra/tools/implementations/code-exec-tool.js +44 -2
  170. package/dist/agent/infra/tools/implementations/curate-tool.d.ts +98 -32
  171. package/dist/agent/infra/tools/implementations/curate-tool.js +86 -23
  172. package/dist/agent/infra/tools/implementations/expand-knowledge-tool.d.ts +18 -0
  173. package/dist/agent/infra/tools/implementations/expand-knowledge-tool.js +43 -0
  174. package/dist/agent/infra/tools/implementations/llm-map-tool.d.ts +24 -0
  175. package/dist/agent/infra/tools/implementations/llm-map-tool.js +87 -0
  176. package/dist/agent/infra/tools/implementations/memory-path-matcher.d.ts +48 -0
  177. package/dist/agent/infra/tools/implementations/memory-path-matcher.js +217 -0
  178. package/dist/agent/infra/tools/implementations/memory-symbol-tree.d.ts +128 -0
  179. package/dist/agent/infra/tools/implementations/memory-symbol-tree.js +283 -0
  180. package/dist/agent/infra/tools/implementations/search-knowledge-service.d.ts +49 -6
  181. package/dist/agent/infra/tools/implementations/search-knowledge-service.js +393 -46
  182. package/dist/agent/infra/tools/implementations/search-knowledge-tool.d.ts +2 -1
  183. package/dist/agent/infra/tools/implementations/search-knowledge-tool.js +50 -6
  184. package/dist/agent/infra/tools/tool-manager.js +6 -0
  185. package/dist/agent/infra/tools/tool-provider.d.ts +12 -0
  186. package/dist/agent/infra/tools/tool-provider.js +78 -0
  187. package/dist/agent/infra/tools/tool-registry.d.ts +14 -0
  188. package/dist/agent/infra/tools/tool-registry.js +34 -2
  189. package/dist/agent/infra/transport/transport-event-bridge.d.ts +42 -0
  190. package/dist/agent/infra/transport/transport-event-bridge.js +90 -0
  191. package/dist/agent/infra/validation/workspace-validator.d.ts +3 -3
  192. package/dist/agent/infra/validation/workspace-validator.js +3 -8
  193. package/dist/agent/resources/prompts/curate-detail-preservation.yml +29 -1
  194. package/dist/agent/resources/prompts/system-prompt.yml +320 -102
  195. package/dist/agent/resources/tools/code_exec.txt +97 -0
  196. package/dist/agent/resources/tools/curate.txt +25 -13
  197. package/dist/agent/resources/tools/detect_domains.txt +4 -3
  198. package/dist/agent/resources/tools/expand_knowledge.txt +20 -0
  199. package/dist/oclif/commands/connectors/index.d.ts +12 -0
  200. package/dist/oclif/commands/connectors/index.js +53 -0
  201. package/dist/oclif/commands/connectors/install.d.ts +31 -0
  202. package/dist/oclif/commands/connectors/install.js +148 -0
  203. package/dist/oclif/commands/connectors/list.d.ts +5 -0
  204. package/dist/oclif/commands/connectors/list.js +8 -0
  205. package/dist/oclif/commands/curate/index.d.ts +25 -0
  206. package/dist/oclif/commands/curate/index.js +255 -0
  207. package/dist/oclif/commands/curate/view.d.ts +18 -0
  208. package/dist/oclif/commands/curate/view.js +104 -0
  209. package/dist/oclif/commands/debug.d.ts +35 -0
  210. package/dist/oclif/commands/debug.js +436 -0
  211. package/dist/oclif/commands/hub/index.d.ts +5 -0
  212. package/dist/oclif/commands/hub/index.js +7 -0
  213. package/dist/oclif/commands/hub/install.d.ts +23 -0
  214. package/dist/oclif/commands/hub/install.js +74 -0
  215. package/dist/oclif/commands/hub/list.d.ts +13 -0
  216. package/dist/oclif/commands/hub/list.js +65 -0
  217. package/dist/oclif/commands/hub/registry/add.d.ts +19 -0
  218. package/dist/oclif/commands/hub/registry/add.js +74 -0
  219. package/dist/oclif/commands/hub/registry/index.d.ts +5 -0
  220. package/dist/oclif/commands/hub/registry/index.js +7 -0
  221. package/dist/oclif/commands/hub/registry/list.d.ts +12 -0
  222. package/dist/oclif/commands/hub/registry/list.js +49 -0
  223. package/dist/oclif/commands/hub/registry/remove.d.ts +15 -0
  224. package/dist/oclif/commands/hub/registry/remove.js +46 -0
  225. package/dist/oclif/commands/login.d.ts +4 -0
  226. package/dist/oclif/commands/login.js +51 -31
  227. package/dist/oclif/commands/main.d.ts +3 -17
  228. package/dist/oclif/commands/main.js +16 -96
  229. package/dist/oclif/commands/mcp.js +24 -5
  230. package/dist/oclif/commands/model/index.d.ts +15 -0
  231. package/dist/oclif/commands/model/index.js +59 -0
  232. package/dist/oclif/commands/model/list.d.ts +17 -0
  233. package/dist/oclif/commands/model/list.js +89 -0
  234. package/dist/oclif/commands/model/switch.d.ts +21 -0
  235. package/dist/oclif/commands/model/switch.js +81 -0
  236. package/dist/oclif/commands/providers/connect.d.ts +26 -0
  237. package/dist/oclif/commands/providers/connect.js +119 -0
  238. package/dist/oclif/commands/providers/disconnect.d.ts +14 -0
  239. package/dist/oclif/commands/providers/disconnect.js +61 -0
  240. package/dist/oclif/commands/providers/index.d.ts +15 -0
  241. package/dist/oclif/commands/providers/index.js +59 -0
  242. package/dist/oclif/commands/providers/list.d.ts +12 -0
  243. package/dist/oclif/commands/providers/list.js +45 -0
  244. package/dist/oclif/commands/providers/switch.d.ts +17 -0
  245. package/dist/oclif/commands/providers/switch.js +61 -0
  246. package/dist/oclif/commands/pull.d.ts +1 -6
  247. package/dist/oclif/commands/pull.js +46 -49
  248. package/dist/oclif/commands/push.d.ts +1 -7
  249. package/dist/oclif/commands/push.js +66 -59
  250. package/dist/oclif/commands/query.d.ts +5 -7
  251. package/dist/oclif/commands/query.js +141 -43
  252. package/dist/oclif/commands/restart.d.ts +95 -0
  253. package/dist/oclif/commands/restart.js +333 -0
  254. package/dist/oclif/commands/space/list.d.ts +12 -0
  255. package/dist/oclif/commands/space/list.js +66 -0
  256. package/dist/oclif/commands/space/switch.d.ts +17 -0
  257. package/dist/oclif/commands/space/switch.js +87 -0
  258. package/dist/oclif/commands/status.d.ts +4 -9
  259. package/dist/oclif/commands/status.js +94 -49
  260. package/dist/oclif/hooks/prerun/validate-brv-config-version.d.ts +16 -11
  261. package/dist/oclif/hooks/prerun/validate-brv-config-version.js +67 -24
  262. package/dist/oclif/lib/daemon-client.d.ts +40 -0
  263. package/dist/oclif/lib/daemon-client.js +142 -0
  264. package/dist/oclif/lib/json-response.d.ts +9 -0
  265. package/dist/oclif/lib/json-response.js +10 -0
  266. package/dist/oclif/lib/task-client.d.ts +68 -0
  267. package/dist/oclif/lib/task-client.js +227 -0
  268. package/dist/server/config/environment.d.ts +1 -1
  269. package/dist/server/config/environment.js +2 -2
  270. package/dist/server/constants.d.ts +37 -1
  271. package/dist/server/constants.js +51 -2
  272. package/dist/server/core/domain/client/client-info.d.ts +82 -0
  273. package/dist/server/core/domain/client/client-info.js +87 -0
  274. package/dist/server/core/domain/entities/agent.d.ts +3 -6
  275. package/dist/server/core/domain/entities/agent.js +49 -54
  276. package/dist/server/core/domain/entities/brv-config.d.ts +31 -10
  277. package/dist/server/core/domain/entities/brv-config.js +68 -39
  278. package/dist/server/core/domain/entities/connector-type.d.ts +1 -11
  279. package/dist/server/core/domain/entities/connector-type.js +1 -10
  280. package/dist/server/core/domain/entities/context-tree-snapshot.d.ts +2 -11
  281. package/dist/server/core/domain/entities/curate-log-entry.d.ts +41 -0
  282. package/dist/server/core/domain/entities/curation-status.d.ts +28 -0
  283. package/dist/server/core/domain/entities/provider-config.d.ts +14 -1
  284. package/dist/server/core/domain/entities/provider-config.js +17 -6
  285. package/dist/server/core/domain/entities/provider-registry.d.ts +3 -1
  286. package/dist/server/core/domain/entities/provider-registry.js +216 -10
  287. package/dist/server/core/domain/errors/task-error.d.ts +17 -4
  288. package/dist/server/core/domain/errors/task-error.js +35 -10
  289. package/dist/server/core/domain/knowledge/markdown-writer.d.ts +58 -1
  290. package/dist/server/core/domain/knowledge/markdown-writer.js +288 -30
  291. package/dist/server/core/domain/knowledge/memory-scoring.d.ts +118 -0
  292. package/dist/server/core/domain/knowledge/memory-scoring.js +217 -0
  293. package/dist/server/core/domain/knowledge/relation-parser.d.ts +16 -0
  294. package/dist/server/core/domain/knowledge/relation-parser.js +21 -8
  295. package/dist/server/core/domain/knowledge/summary-types.d.ts +126 -0
  296. package/dist/server/core/domain/knowledge/summary-types.js +7 -0
  297. package/dist/server/core/domain/project/project-info.d.ts +54 -0
  298. package/dist/server/core/domain/project/project-info.js +62 -0
  299. package/dist/server/core/domain/transport/schemas.d.ts +93 -19
  300. package/dist/server/core/domain/transport/schemas.js +40 -1
  301. package/dist/server/core/domain/transport/task-info.d.ts +21 -0
  302. package/dist/server/core/interfaces/agent/i-agent-pool.d.ts +88 -0
  303. package/dist/server/core/interfaces/client/i-client-manager.d.ts +117 -0
  304. package/dist/server/core/interfaces/context-tree/i-context-file-reader.d.ts +5 -1
  305. package/dist/server/core/interfaces/context-tree/i-context-tree-archive-service.d.ts +30 -0
  306. package/dist/server/core/interfaces/context-tree/i-context-tree-manifest-service.d.ts +30 -0
  307. package/dist/server/core/interfaces/context-tree/i-context-tree-merger.d.ts +80 -0
  308. package/dist/server/core/interfaces/context-tree/i-context-tree-service.d.ts +5 -0
  309. package/dist/server/core/interfaces/context-tree/i-context-tree-snapshot-service.d.ts +15 -0
  310. package/dist/server/core/interfaces/context-tree/i-context-tree-summary-service.d.ts +29 -0
  311. package/dist/server/core/interfaces/daemon/i-agent-idle-timeout-policy.d.ts +39 -0
  312. package/dist/server/core/interfaces/daemon/i-daemon-resilience.d.ts +24 -0
  313. package/dist/server/core/interfaces/daemon/i-heartbeat-writer.d.ts +28 -0
  314. package/dist/server/core/interfaces/daemon/i-idle-timeout-policy.d.ts +34 -0
  315. package/dist/server/core/interfaces/daemon/i-shutdown-handler.d.ts +20 -0
  316. package/dist/server/core/interfaces/daemon/index.d.ts +4 -0
  317. package/dist/server/core/interfaces/daemon/index.js +2 -0
  318. package/dist/server/core/interfaces/executor/i-curate-executor.d.ts +2 -2
  319. package/dist/server/core/interfaces/executor/i-query-executor.d.ts +2 -2
  320. package/dist/server/core/interfaces/hub/i-hub-install-service.d.ts +45 -0
  321. package/dist/server/core/interfaces/hub/i-hub-install-service.js +1 -0
  322. package/dist/server/core/interfaces/hub/i-hub-keychain-store.d.ts +27 -0
  323. package/dist/server/core/interfaces/hub/i-hub-keychain-store.js +1 -0
  324. package/dist/server/core/interfaces/hub/i-hub-registry-config-store.d.ts +27 -0
  325. package/dist/server/core/interfaces/hub/i-hub-registry-config-store.js +1 -0
  326. package/dist/server/core/interfaces/hub/i-hub-registry-service.d.ts +30 -0
  327. package/dist/server/core/interfaces/hub/i-hub-registry-service.js +1 -0
  328. package/dist/server/core/interfaces/i-provider-config-store.d.ts +3 -1
  329. package/dist/server/core/interfaces/i-provider-model-fetcher.d.ts +59 -0
  330. package/dist/server/core/interfaces/i-provider-model-fetcher.js +7 -0
  331. package/dist/server/core/interfaces/process/i-task-lifecycle-hook.d.ts +27 -0
  332. package/dist/server/core/interfaces/process/i-task-lifecycle-hook.js +1 -0
  333. package/dist/server/core/interfaces/project/i-project-registry.d.ts +46 -0
  334. package/dist/server/core/interfaces/project/i-project-registry.js +1 -0
  335. package/dist/server/core/interfaces/routing/i-project-router.d.ts +45 -0
  336. package/dist/server/core/interfaces/routing/i-project-router.js +1 -0
  337. package/dist/server/core/interfaces/routing/index.d.ts +1 -0
  338. package/dist/server/core/interfaces/routing/index.js +1 -0
  339. package/dist/server/core/interfaces/session/i-session-reader.d.ts +13 -0
  340. package/dist/server/core/interfaces/session/i-session-reader.js +1 -0
  341. package/dist/server/core/interfaces/state/i-auth-state-store.d.ts +68 -0
  342. package/dist/server/core/interfaces/state/i-auth-state-store.js +1 -0
  343. package/dist/server/core/interfaces/state/i-project-state-loader.d.ts +110 -0
  344. package/dist/server/core/interfaces/state/i-project-state-loader.js +1 -0
  345. package/dist/server/core/interfaces/storage/i-curate-log-store.d.ts +20 -0
  346. package/dist/server/core/interfaces/storage/i-curate-log-store.js +1 -0
  347. package/dist/server/core/interfaces/storage/i-global-config-store.d.ts +1 -15
  348. package/dist/server/core/interfaces/storage/i-mcp-config-writer.d.ts +5 -1
  349. package/dist/server/core/interfaces/storage/i-project-config-store.d.ts +6 -1
  350. package/dist/server/core/interfaces/transport/i-transport-server.d.ts +12 -2
  351. package/dist/server/core/interfaces/usecase/i-curate-log-use-case.d.ts +12 -0
  352. package/dist/server/core/interfaces/usecase/i-curate-log-use-case.js +1 -0
  353. package/dist/server/infra/client/client-manager.d.ts +51 -0
  354. package/dist/server/infra/client/client-manager.js +144 -0
  355. package/dist/server/infra/cogit/context-tree-to-push-context-mapper.js +12 -5
  356. package/dist/server/infra/config/auto-init.d.ts +14 -0
  357. package/dist/server/infra/config/auto-init.js +18 -0
  358. package/dist/server/infra/config/file-config-store.d.ts +1 -0
  359. package/dist/server/infra/config/file-config-store.js +15 -7
  360. package/dist/server/infra/connectors/mcp/json-mcp-config-writer.d.ts +1 -2
  361. package/dist/server/infra/connectors/mcp/json-mcp-config-writer.js +9 -8
  362. package/dist/server/infra/connectors/mcp/mcp-connector-config.d.ts +29 -6
  363. package/dist/server/infra/connectors/mcp/mcp-connector-config.js +28 -1
  364. package/dist/server/infra/connectors/mcp/mcp-connector.js +5 -5
  365. package/dist/server/infra/connectors/mcp/toml-mcp-config-writer.d.ts +1 -2
  366. package/dist/server/infra/connectors/rules/rules-connector-config.d.ts +8 -0
  367. package/dist/server/infra/connectors/rules/rules-connector-config.js +8 -0
  368. package/dist/server/infra/connectors/rules/rules-connector.js +34 -7
  369. package/dist/server/infra/connectors/shared/constants.d.ts +5 -0
  370. package/dist/server/infra/connectors/shared/constants.js +12 -0
  371. package/dist/server/infra/connectors/shared/rule-segment-patcher.d.ts +29 -0
  372. package/dist/server/infra/connectors/shared/rule-segment-patcher.js +208 -0
  373. package/dist/server/infra/connectors/skill/skill-connector-config.d.ts +79 -20
  374. package/dist/server/infra/connectors/skill/skill-connector-config.js +74 -10
  375. package/dist/server/infra/connectors/skill/skill-connector.d.ts +35 -4
  376. package/dist/server/infra/connectors/skill/skill-connector.js +140 -39
  377. package/dist/server/infra/context-tree/children-hash.d.ts +20 -0
  378. package/dist/server/infra/context-tree/children-hash.js +22 -0
  379. package/dist/server/infra/context-tree/derived-artifact.d.ts +28 -0
  380. package/dist/server/infra/context-tree/derived-artifact.js +48 -0
  381. package/dist/server/infra/context-tree/file-context-file-reader.js +6 -2
  382. package/dist/server/infra/context-tree/file-context-tree-archive-service.d.ts +37 -0
  383. package/dist/server/infra/context-tree/file-context-tree-archive-service.js +219 -0
  384. package/dist/server/infra/context-tree/file-context-tree-manifest-service.d.ts +50 -0
  385. package/dist/server/infra/context-tree/file-context-tree-manifest-service.js +278 -0
  386. package/dist/server/infra/context-tree/file-context-tree-merger.d.ts +51 -0
  387. package/dist/server/infra/context-tree/file-context-tree-merger.js +265 -0
  388. package/dist/server/infra/context-tree/file-context-tree-service.d.ts +1 -0
  389. package/dist/server/infra/context-tree/file-context-tree-service.js +6 -1
  390. package/dist/server/infra/context-tree/file-context-tree-snapshot-service.d.ts +2 -4
  391. package/dist/server/infra/context-tree/file-context-tree-snapshot-service.js +31 -13
  392. package/dist/server/infra/context-tree/file-context-tree-summary-service.d.ts +44 -0
  393. package/dist/server/infra/context-tree/file-context-tree-summary-service.js +313 -0
  394. package/dist/server/infra/context-tree/file-context-tree-writer-service.js +5 -0
  395. package/dist/server/infra/context-tree/hash-utils.d.ts +6 -0
  396. package/dist/server/infra/context-tree/hash-utils.js +9 -0
  397. package/dist/server/infra/context-tree/prompts/summary-generation.d.ts +22 -0
  398. package/dist/server/infra/context-tree/prompts/summary-generation.js +45 -0
  399. package/dist/server/infra/context-tree/snapshot-diff.d.ts +19 -0
  400. package/dist/server/infra/context-tree/snapshot-diff.js +39 -0
  401. package/dist/server/infra/context-tree/summary-frontmatter.d.ts +24 -0
  402. package/dist/server/infra/context-tree/summary-frontmatter.js +111 -0
  403. package/dist/server/infra/daemon/agent-idle-timeout-policy.d.ts +36 -0
  404. package/dist/server/infra/daemon/agent-idle-timeout-policy.js +89 -0
  405. package/dist/server/infra/daemon/agent-logger.d.ts +10 -0
  406. package/dist/server/infra/daemon/agent-logger.js +22 -0
  407. package/dist/server/infra/daemon/agent-pool.d.ts +112 -0
  408. package/dist/server/infra/daemon/agent-pool.js +335 -0
  409. package/dist/server/infra/daemon/agent-process.d.ts +21 -0
  410. package/dist/server/infra/daemon/agent-process.js +598 -0
  411. package/dist/server/infra/daemon/brv-server.d.ts +23 -0
  412. package/dist/server/infra/daemon/brv-server.js +405 -0
  413. package/dist/server/infra/daemon/daemon-resilience.d.ts +34 -0
  414. package/dist/server/infra/daemon/daemon-resilience.js +100 -0
  415. package/dist/server/infra/daemon/heartbeat.d.ts +28 -0
  416. package/dist/server/infra/daemon/heartbeat.js +81 -0
  417. package/dist/server/infra/daemon/idle-timeout-policy.d.ts +38 -0
  418. package/dist/server/infra/daemon/idle-timeout-policy.js +91 -0
  419. package/dist/server/infra/daemon/index.d.ts +5 -0
  420. package/dist/server/infra/daemon/index.js +11 -0
  421. package/dist/server/infra/daemon/port-selector.d.ts +28 -0
  422. package/dist/server/infra/daemon/port-selector.js +45 -0
  423. package/dist/server/infra/daemon/project-task-queue.d.ts +54 -0
  424. package/dist/server/infra/daemon/project-task-queue.js +103 -0
  425. package/dist/server/infra/daemon/session-resolver.d.ts +26 -0
  426. package/dist/server/infra/daemon/session-resolver.js +88 -0
  427. package/dist/server/infra/daemon/shutdown-handler.d.ts +42 -0
  428. package/dist/server/infra/daemon/shutdown-handler.js +101 -0
  429. package/dist/server/infra/executor/curate-executor.d.ts +11 -2
  430. package/dist/server/infra/executor/curate-executor.js +135 -13
  431. package/dist/server/infra/executor/direct-search-responder.d.ts +11 -8
  432. package/dist/server/infra/executor/direct-search-responder.js +16 -14
  433. package/dist/server/infra/executor/folder-pack-executor.js +58 -17
  434. package/dist/server/infra/executor/pre-compaction/compaction-escalation.d.ts +6 -0
  435. package/dist/server/infra/executor/pre-compaction/compaction-escalation.js +6 -0
  436. package/dist/server/infra/executor/pre-compaction/index.d.ts +3 -0
  437. package/dist/server/infra/executor/pre-compaction/index.js +1 -0
  438. package/dist/server/infra/executor/pre-compaction/pre-compaction-service.d.ts +59 -0
  439. package/dist/server/infra/executor/pre-compaction/pre-compaction-service.js +124 -0
  440. package/dist/server/infra/executor/pre-compaction/prompts.d.ts +24 -0
  441. package/dist/server/infra/executor/pre-compaction/prompts.js +47 -0
  442. package/dist/server/infra/executor/query-executor.d.ts +26 -6
  443. package/dist/server/infra/executor/query-executor.js +181 -40
  444. package/dist/server/infra/http/authenticated-http-client.js +4 -0
  445. package/dist/server/infra/http/provider-model-fetcher-registry.d.ts +31 -0
  446. package/dist/server/infra/http/provider-model-fetcher-registry.js +117 -0
  447. package/dist/server/infra/http/provider-model-fetchers.d.ts +94 -0
  448. package/dist/server/infra/http/provider-model-fetchers.js +450 -0
  449. package/dist/server/infra/hub/composite-hub-registry-service.d.ts +17 -0
  450. package/dist/server/infra/hub/composite-hub-registry-service.js +54 -0
  451. package/dist/server/infra/hub/hub-auth-headers.d.ts +11 -0
  452. package/dist/server/infra/hub/hub-auth-headers.js +29 -0
  453. package/dist/server/infra/hub/hub-install-service.d.ts +22 -0
  454. package/dist/server/infra/hub/hub-install-service.js +99 -0
  455. package/dist/server/infra/hub/hub-keychain-store.d.ts +29 -0
  456. package/dist/server/infra/hub/hub-keychain-store.js +98 -0
  457. package/dist/server/infra/hub/hub-registry-config-store.d.ts +24 -0
  458. package/dist/server/infra/hub/hub-registry-config-store.js +92 -0
  459. package/dist/server/infra/hub/hub-registry-service.d.ts +33 -0
  460. package/dist/server/infra/hub/hub-registry-service.js +109 -0
  461. package/dist/server/infra/mcp/mcp-mode-detector.d.ts +21 -0
  462. package/dist/server/infra/mcp/mcp-mode-detector.js +25 -0
  463. package/dist/server/infra/mcp/mcp-server.d.ts +15 -9
  464. package/dist/server/infra/mcp/mcp-server.js +84 -98
  465. package/dist/server/infra/mcp/tools/brv-curate-tool.d.ts +5 -10
  466. package/dist/server/infra/mcp/tools/brv-curate-tool.js +47 -17
  467. package/dist/server/infra/mcp/tools/brv-query-tool.d.ts +4 -1
  468. package/dist/server/infra/mcp/tools/brv-query-tool.js +39 -12
  469. package/dist/server/infra/mcp/tools/index.d.ts +1 -0
  470. package/dist/server/infra/mcp/tools/index.js +1 -0
  471. package/dist/server/infra/mcp/tools/resolve-client-cwd.d.ts +17 -0
  472. package/dist/server/infra/mcp/tools/resolve-client-cwd.js +27 -0
  473. package/dist/server/infra/mcp/tools/task-result-waiter.js +6 -5
  474. package/dist/server/infra/process/broadcast-utils.d.ts +16 -0
  475. package/dist/server/infra/process/broadcast-utils.js +22 -0
  476. package/dist/server/infra/process/connection-coordinator.d.ts +85 -0
  477. package/dist/server/infra/process/connection-coordinator.js +333 -0
  478. package/dist/server/infra/process/curate-log-handler.d.ts +35 -0
  479. package/dist/server/infra/process/curate-log-handler.js +179 -0
  480. package/dist/server/infra/process/feature-handlers.d.ts +25 -0
  481. package/dist/server/infra/process/feature-handlers.js +165 -0
  482. package/dist/server/infra/process/index.d.ts +6 -7
  483. package/dist/server/infra/process/index.js +5 -6
  484. package/dist/server/infra/process/task-router.d.ts +139 -0
  485. package/dist/server/infra/process/task-router.js +503 -0
  486. package/dist/server/infra/process/transport-handlers.d.ts +55 -117
  487. package/dist/server/infra/process/transport-handlers.js +50 -437
  488. package/dist/server/infra/process/types.d.ts +5 -0
  489. package/dist/server/infra/process/types.js +1 -0
  490. package/dist/server/infra/project/project-registry.d.ts +37 -0
  491. package/dist/server/infra/project/project-registry.js +147 -0
  492. package/dist/server/infra/provider/env-provider-detector.d.ts +33 -0
  493. package/dist/server/infra/provider/env-provider-detector.js +52 -0
  494. package/dist/server/infra/provider/provider-config-resolver.d.ts +30 -0
  495. package/dist/server/infra/provider/provider-config-resolver.js +112 -0
  496. package/dist/server/infra/routing/project-router.d.ts +35 -0
  497. package/dist/server/infra/routing/project-router.js +60 -0
  498. package/dist/server/infra/session/session-reader.d.ts +18 -0
  499. package/dist/server/infra/session/session-reader.js +17 -0
  500. package/dist/server/infra/state/auth-state-store.d.ts +55 -0
  501. package/dist/server/infra/state/auth-state-store.js +111 -0
  502. package/dist/server/infra/state/project-state-loader.d.ts +69 -0
  503. package/dist/server/infra/state/project-state-loader.js +154 -0
  504. package/dist/server/infra/storage/file-curate-log-store.d.ts +61 -0
  505. package/dist/server/infra/storage/file-curate-log-store.js +198 -0
  506. package/dist/server/infra/storage/file-global-config-store.d.ts +0 -2
  507. package/dist/server/infra/storage/file-global-config-store.js +0 -19
  508. package/dist/server/infra/storage/file-onboarding-preference-store.d.ts +1 -1
  509. package/dist/server/infra/storage/file-onboarding-preference-store.js +7 -8
  510. package/dist/server/infra/storage/file-provider-config-store.d.ts +3 -2
  511. package/dist/server/infra/storage/file-provider-config-store.js +3 -3
  512. package/dist/server/infra/storage/file-provider-keychain-store.d.ts +31 -0
  513. package/dist/server/infra/storage/file-provider-keychain-store.js +110 -0
  514. package/dist/server/infra/storage/file-token-store.d.ts +2 -5
  515. package/dist/server/infra/storage/file-token-store.js +2 -5
  516. package/dist/server/infra/storage/provider-keychain-store.d.ts +2 -33
  517. package/dist/server/infra/storage/provider-keychain-store.js +4 -71
  518. package/dist/server/infra/storage/token-store.d.ts +3 -8
  519. package/dist/server/infra/storage/token-store.js +4 -11
  520. package/dist/server/infra/transport/agent-instance-discovery.d.ts +20 -0
  521. package/dist/server/infra/transport/agent-instance-discovery.js +32 -0
  522. package/dist/server/infra/transport/handlers/agent-dto-mapper.d.ts +6 -0
  523. package/dist/server/infra/transport/handlers/agent-dto-mapper.js +16 -0
  524. package/dist/server/infra/transport/handlers/auth-handler.d.ts +60 -0
  525. package/dist/server/infra/transport/handlers/auth-handler.js +257 -0
  526. package/dist/server/infra/transport/handlers/config-handler.d.ts +13 -0
  527. package/dist/server/infra/transport/handlers/config-handler.js +22 -0
  528. package/dist/server/infra/transport/handlers/connectors-handler.d.ts +23 -0
  529. package/dist/server/infra/transport/handlers/connectors-handler.js +73 -0
  530. package/dist/server/infra/transport/handlers/handler-types.d.ts +23 -0
  531. package/dist/server/infra/transport/handlers/handler-types.js +21 -0
  532. package/dist/server/infra/transport/handlers/hub-handler.d.ts +34 -0
  533. package/dist/server/infra/transport/handlers/hub-handler.js +218 -0
  534. package/dist/server/infra/transport/handlers/index.d.ts +26 -0
  535. package/dist/server/infra/transport/handlers/index.js +13 -0
  536. package/dist/server/infra/transport/handlers/init-handler.d.ts +50 -0
  537. package/dist/server/infra/transport/handlers/init-handler.js +157 -0
  538. package/dist/server/infra/transport/handlers/model-handler.d.ts +22 -0
  539. package/dist/server/infra/transport/handlers/model-handler.js +107 -0
  540. package/dist/server/infra/transport/handlers/provider-handler.d.ts +25 -0
  541. package/dist/server/infra/transport/handlers/provider-handler.js +101 -0
  542. package/dist/server/infra/transport/handlers/pull-handler.d.ts +35 -0
  543. package/dist/server/infra/transport/handlers/pull-handler.js +87 -0
  544. package/dist/server/infra/transport/handlers/push-handler.d.ts +37 -0
  545. package/dist/server/infra/transport/handlers/push-handler.js +109 -0
  546. package/dist/server/infra/transport/handlers/reset-handler.d.ts +23 -0
  547. package/dist/server/infra/transport/handlers/reset-handler.js +33 -0
  548. package/dist/server/infra/transport/handlers/space-handler.d.ts +44 -0
  549. package/dist/server/infra/transport/handlers/space-handler.js +206 -0
  550. package/dist/server/infra/transport/handlers/status-handler.d.ts +29 -0
  551. package/dist/server/infra/transport/handlers/status-handler.js +99 -0
  552. package/dist/server/infra/transport/index.d.ts +1 -1
  553. package/dist/server/infra/transport/index.js +0 -1
  554. package/dist/server/infra/transport/port-utils.d.ts +0 -35
  555. package/dist/server/infra/transport/port-utils.js +0 -62
  556. package/dist/server/infra/transport/socket-io-transport-server.d.ts +6 -1
  557. package/dist/server/infra/transport/socket-io-transport-server.js +30 -10
  558. package/dist/server/infra/transport/transport-connector.d.ts +13 -0
  559. package/dist/server/infra/transport/transport-connector.js +18 -0
  560. package/dist/server/infra/usecase/curate-log-use-case.d.ts +32 -0
  561. package/dist/server/infra/usecase/curate-log-use-case.js +142 -0
  562. package/dist/server/templates/sections/brv-instructions.md +8 -0
  563. package/dist/server/templates/sections/command-reference.md +5 -2
  564. package/dist/server/templates/sections/workflow.md +2 -0
  565. package/dist/server/templates/skill/SKILL.md +138 -59
  566. package/dist/server/utils/config-xdg-sync.d.ts +13 -0
  567. package/dist/server/utils/config-xdg-sync.js +25 -0
  568. package/dist/server/utils/curate-result-parser.d.ts +121 -0
  569. package/dist/server/utils/curate-result-parser.js +120 -0
  570. package/dist/server/utils/global-config-path.d.ts +1 -1
  571. package/dist/server/utils/global-config-path.js +5 -2
  572. package/dist/server/utils/global-data-path.d.ts +2 -2
  573. package/dist/server/utils/global-data-path.js +8 -3
  574. package/dist/server/utils/path-utils.d.ts +38 -0
  575. package/dist/server/utils/path-utils.js +92 -0
  576. package/dist/server/utils/process-logger.js +1 -1
  577. package/dist/server/utils/server-main-resolver.d.ts +9 -0
  578. package/dist/server/utils/server-main-resolver.js +17 -0
  579. package/dist/shared/constants/curation.d.ts +6 -0
  580. package/dist/shared/constants/curation.js +6 -0
  581. package/dist/shared/transport/events/agent-events.d.ts +16 -0
  582. package/dist/shared/transport/events/agent-events.js +10 -0
  583. package/dist/shared/transport/events/auth-events.d.ts +45 -0
  584. package/dist/shared/transport/events/auth-events.js +11 -0
  585. package/dist/shared/transport/events/config-events.d.ts +18 -0
  586. package/dist/shared/transport/events/config-events.js +5 -0
  587. package/dist/shared/transport/events/connector-events.d.ts +35 -0
  588. package/dist/shared/transport/events/connector-events.js +6 -0
  589. package/dist/shared/transport/events/hub-events.d.ts +62 -0
  590. package/dist/shared/transport/events/hub-events.js +10 -0
  591. package/dist/shared/transport/events/index.d.ts +123 -0
  592. package/dist/shared/transport/events/index.js +73 -0
  593. package/dist/shared/transport/events/init-events.d.ts +41 -0
  594. package/dist/shared/transport/events/init-events.js +8 -0
  595. package/dist/shared/transport/events/llm-events.d.ts +13 -0
  596. package/dist/shared/transport/events/llm-events.js +13 -0
  597. package/dist/shared/transport/events/model-events.d.ts +30 -0
  598. package/dist/shared/transport/events/model-events.js +5 -0
  599. package/dist/shared/transport/events/onboarding-events.d.ts +18 -0
  600. package/dist/shared/transport/events/onboarding-events.js +5 -0
  601. package/dist/shared/transport/events/provider-events.d.ts +44 -0
  602. package/dist/shared/transport/events/provider-events.js +8 -0
  603. package/dist/shared/transport/events/pull-events.d.ts +26 -0
  604. package/dist/shared/transport/events/pull-events.js +5 -0
  605. package/dist/shared/transport/events/push-events.d.ts +27 -0
  606. package/dist/shared/transport/events/push-events.js +5 -0
  607. package/dist/shared/transport/events/reset-events.d.ts +6 -0
  608. package/dist/shared/transport/events/reset-events.js +3 -0
  609. package/dist/shared/transport/events/session-events.d.ts +3 -0
  610. package/dist/shared/transport/events/session-events.js +3 -0
  611. package/dist/shared/transport/events/space-events.d.ts +30 -0
  612. package/dist/shared/transport/events/space-events.js +4 -0
  613. package/dist/shared/transport/events/status-events.d.ts +7 -0
  614. package/dist/shared/transport/events/status-events.js +3 -0
  615. package/dist/shared/transport/events/task-events.d.ts +19 -0
  616. package/dist/shared/transport/events/task-events.js +9 -0
  617. package/dist/shared/transport/types/auth-scheme.d.ts +1 -0
  618. package/dist/shared/transport/types/auth-scheme.js +1 -0
  619. package/dist/shared/transport/types/dto.d.ts +112 -0
  620. package/dist/shared/transport/types/dto.js +6 -0
  621. package/dist/shared/transport/types/index.d.ts +1 -0
  622. package/dist/shared/transport/types/index.js +1 -0
  623. package/dist/shared/types/agent.d.ts +5 -0
  624. package/dist/shared/types/agent.js +27 -0
  625. package/dist/shared/types/connector-type.d.ts +18 -0
  626. package/dist/shared/types/connector-type.js +26 -0
  627. package/dist/shared/types/context-tree-changes.d.ts +11 -0
  628. package/dist/shared/types/context-tree-changes.js +1 -0
  629. package/dist/shared/types/index.d.ts +3 -0
  630. package/dist/shared/types/index.js +2 -0
  631. package/dist/shared/utils/escalation-utils.d.ts +59 -0
  632. package/dist/shared/utils/escalation-utils.js +141 -0
  633. package/dist/tui/app/index.d.ts +9 -0
  634. package/dist/tui/app/index.js +4 -0
  635. package/dist/tui/app/layouts/main-layout.d.ts +14 -0
  636. package/dist/tui/app/layouts/main-layout.js +19 -0
  637. package/dist/tui/app/pages/config-provider-page.d.ts +8 -0
  638. package/dist/tui/app/pages/config-provider-page.js +19 -0
  639. package/dist/tui/app/pages/home-page.d.ts +8 -0
  640. package/dist/tui/app/pages/home-page.js +85 -0
  641. package/dist/tui/app/pages/login-page.d.ts +12 -0
  642. package/dist/tui/app/pages/login-page.js +87 -0
  643. package/dist/tui/app/pages/protected-routes.d.ts +8 -0
  644. package/dist/tui/app/pages/protected-routes.js +14 -0
  645. package/dist/tui/app/router.d.ts +11 -0
  646. package/dist/tui/app/router.js +21 -0
  647. package/dist/tui/components/command/command-output.d.ts +1 -1
  648. package/dist/tui/components/command/command-output.js +5 -7
  649. package/dist/tui/components/command/expanded-command-view.d.ts +1 -1
  650. package/dist/tui/components/command/expanded-command-view.js +5 -6
  651. package/dist/tui/components/command/live-streaming-output.d.ts +2 -4
  652. package/dist/tui/components/command/live-streaming-output.js +5 -19
  653. package/dist/tui/components/command-details.d.ts +1 -1
  654. package/dist/tui/components/command-details.js +3 -3
  655. package/dist/tui/components/command-input.js +84 -171
  656. package/dist/tui/components/command-item.d.ts +1 -1
  657. package/dist/tui/components/command-item.js +6 -7
  658. package/dist/tui/components/execution/execution-status.d.ts +1 -1
  659. package/dist/tui/components/execution/execution-tool.d.ts +1 -1
  660. package/dist/tui/components/execution/expanded-log-view.d.ts +1 -1
  661. package/dist/tui/components/execution/expanded-log-view.js +1 -1
  662. package/dist/tui/components/execution/log-item.d.ts +1 -1
  663. package/dist/tui/components/execution/log-item.js +1 -1
  664. package/dist/tui/components/footer.js +6 -4
  665. package/dist/tui/components/header.js +2 -2
  666. package/dist/tui/components/index.d.ts +0 -2
  667. package/dist/tui/components/index.js +0 -2
  668. package/dist/tui/components/init.d.ts +1 -1
  669. package/dist/tui/components/init.js +26 -32
  670. package/dist/tui/components/inline-prompts/inline-confirm.js +6 -1
  671. package/dist/tui/components/inline-prompts/inline-file-selector.d.ts +1 -1
  672. package/dist/tui/components/inline-prompts/inline-input.d.ts +6 -0
  673. package/dist/tui/components/inline-prompts/inline-input.js +53 -16
  674. package/dist/tui/components/inline-prompts/inline-search.d.ts +2 -2
  675. package/dist/tui/components/inline-prompts/inline-search.js +1 -1
  676. package/dist/tui/components/inline-prompts/inline-select.d.ts +1 -1
  677. package/dist/tui/components/inline-prompts/inline-select.js +1 -1
  678. package/dist/tui/components/message-item.d.ts +1 -1
  679. package/dist/tui/components/message-item.js +2 -2
  680. package/dist/tui/components/onboarding/welcome-box.d.ts +1 -8
  681. package/dist/tui/components/onboarding/welcome-box.js +11 -12
  682. package/dist/tui/components/onboarding-item.d.ts +1 -1
  683. package/dist/tui/components/selectable-list.d.ts +3 -1
  684. package/dist/tui/components/selectable-list.js +7 -15
  685. package/dist/tui/components/status-badge.js +1 -1
  686. package/dist/tui/components/suggestions.js +5 -18
  687. package/dist/tui/features/activity/hooks/index.d.ts +2 -0
  688. package/dist/tui/features/activity/hooks/index.js +2 -0
  689. package/dist/tui/features/activity/hooks/use-activity-logs.d.ts +18 -0
  690. package/dist/tui/features/activity/hooks/use-activity-logs.js +208 -0
  691. package/dist/tui/features/activity/hooks/use-feed-navigation.d.ts +24 -0
  692. package/dist/tui/features/activity/hooks/use-feed-navigation.js +43 -0
  693. package/dist/tui/features/activity/index.d.ts +1 -0
  694. package/dist/tui/features/activity/index.js +1 -0
  695. package/dist/tui/features/auth/api/get-auth-state.d.ts +16 -0
  696. package/dist/tui/features/auth/api/get-auth-state.js +21 -0
  697. package/dist/tui/features/auth/api/login.d.ts +3 -0
  698. package/dist/tui/features/auth/api/login.js +14 -0
  699. package/dist/tui/features/auth/api/logout.d.ts +8 -0
  700. package/dist/tui/features/auth/api/logout.js +24 -0
  701. package/dist/tui/features/auth/api/refresh-auth.d.ts +8 -0
  702. package/dist/tui/features/auth/api/refresh-auth.js +24 -0
  703. package/dist/tui/features/auth/components/auth-initializer.d.ts +10 -0
  704. package/dist/tui/features/auth/components/auth-initializer.js +82 -0
  705. package/dist/tui/features/auth/components/login-flow.d.ts +8 -0
  706. package/dist/tui/features/auth/components/login-flow.js +62 -0
  707. package/dist/tui/features/auth/components/logout-flow.d.ts +12 -0
  708. package/dist/tui/features/auth/components/logout-flow.js +81 -0
  709. package/dist/tui/features/auth/guards/auth-guard.d.ts +2 -0
  710. package/dist/tui/features/auth/guards/auth-guard.js +11 -0
  711. package/dist/tui/features/auth/stores/auth-store.d.ts +27 -0
  712. package/dist/tui/features/auth/stores/auth-store.js +29 -0
  713. package/dist/tui/features/commands/components/command-view.d.ts +17 -0
  714. package/dist/tui/features/commands/components/command-view.js +34 -0
  715. package/dist/tui/features/commands/definitions/connectors.d.ts +2 -0
  716. package/dist/tui/features/commands/definitions/connectors.js +9 -0
  717. package/dist/tui/features/commands/definitions/curate.d.ts +2 -0
  718. package/dist/tui/features/commands/definitions/curate.js +53 -0
  719. package/dist/tui/features/commands/definitions/exit.d.ts +2 -0
  720. package/dist/tui/features/commands/definitions/exit.js +9 -0
  721. package/dist/tui/features/commands/definitions/hub-list.d.ts +2 -0
  722. package/dist/tui/features/commands/definitions/hub-list.js +9 -0
  723. package/dist/tui/features/commands/definitions/hub-registry-add.d.ts +2 -0
  724. package/dist/tui/features/commands/definitions/hub-registry-add.js +36 -0
  725. package/dist/tui/features/commands/definitions/hub-registry-list.d.ts +2 -0
  726. package/dist/tui/features/commands/definitions/hub-registry-list.js +9 -0
  727. package/dist/tui/features/commands/definitions/hub-registry-remove.d.ts +2 -0
  728. package/dist/tui/features/commands/definitions/hub-registry-remove.js +25 -0
  729. package/dist/tui/features/commands/definitions/hub-registry.d.ts +2 -0
  730. package/dist/tui/features/commands/definitions/hub-registry.js +8 -0
  731. package/dist/tui/features/commands/definitions/hub.d.ts +2 -0
  732. package/dist/tui/features/commands/definitions/hub.js +7 -0
  733. package/dist/tui/features/commands/definitions/index.d.ts +8 -0
  734. package/dist/tui/features/commands/definitions/index.js +48 -0
  735. package/dist/tui/features/commands/definitions/login.d.ts +2 -0
  736. package/dist/tui/features/commands/definitions/login.js +12 -0
  737. package/dist/tui/features/commands/definitions/logout.d.ts +2 -0
  738. package/dist/tui/features/commands/definitions/logout.js +26 -0
  739. package/dist/tui/features/commands/definitions/model.d.ts +2 -0
  740. package/dist/tui/features/commands/definitions/model.js +9 -0
  741. package/dist/tui/features/commands/definitions/new.d.ts +2 -0
  742. package/dist/tui/features/commands/definitions/new.js +27 -0
  743. package/dist/tui/features/commands/definitions/providers.d.ts +2 -0
  744. package/dist/tui/features/commands/definitions/providers.js +9 -0
  745. package/dist/tui/features/commands/definitions/pull.d.ts +2 -0
  746. package/dist/tui/features/commands/definitions/pull.js +23 -0
  747. package/dist/tui/features/commands/definitions/push.d.ts +2 -0
  748. package/dist/tui/features/commands/definitions/push.js +29 -0
  749. package/dist/tui/features/commands/definitions/query.d.ts +2 -0
  750. package/dist/tui/features/commands/definitions/query.js +36 -0
  751. package/dist/tui/features/commands/definitions/reset.d.ts +2 -0
  752. package/dist/tui/features/commands/definitions/reset.js +22 -0
  753. package/dist/tui/features/commands/definitions/space-list.d.ts +2 -0
  754. package/dist/tui/features/commands/definitions/space-list.js +22 -0
  755. package/dist/tui/features/commands/definitions/space-switch.d.ts +2 -0
  756. package/dist/tui/features/commands/definitions/space-switch.js +9 -0
  757. package/dist/tui/features/commands/definitions/space.d.ts +2 -0
  758. package/dist/tui/features/commands/definitions/space.js +7 -0
  759. package/dist/tui/features/commands/definitions/status.d.ts +2 -0
  760. package/dist/tui/features/commands/definitions/status.js +11 -0
  761. package/dist/tui/features/commands/hooks/use-commands-controller.d.ts +38 -0
  762. package/dist/tui/features/commands/hooks/use-commands-controller.js +43 -0
  763. package/dist/tui/features/commands/hooks/use-slash-command-processor.d.ts +16 -0
  764. package/dist/tui/features/commands/hooks/use-slash-command-processor.js +134 -0
  765. package/dist/tui/features/commands/hooks/use-slash-completion.d.ts +30 -0
  766. package/dist/tui/features/commands/hooks/use-slash-completion.js +256 -0
  767. package/dist/tui/features/commands/stores/commands-store.d.ts +32 -0
  768. package/dist/tui/features/commands/stores/commands-store.js +23 -0
  769. package/dist/tui/features/commands/utils/arg-parser.d.ts +102 -0
  770. package/dist/tui/features/connectors/api/get-agent-config-paths.d.ts +18 -0
  771. package/dist/tui/features/connectors/api/get-agent-config-paths.js +17 -0
  772. package/dist/tui/features/connectors/api/get-agents.d.ts +16 -0
  773. package/dist/tui/features/connectors/api/get-agents.js +19 -0
  774. package/dist/tui/features/connectors/api/get-connectors.d.ts +16 -0
  775. package/dist/tui/features/connectors/api/get-connectors.js +17 -0
  776. package/dist/tui/features/connectors/api/install-connector.d.ts +14 -0
  777. package/dist/tui/features/connectors/api/install-connector.js +27 -0
  778. package/dist/tui/features/connectors/components/agent-search-step.d.ts +9 -0
  779. package/dist/tui/features/connectors/components/agent-search-step.js +18 -0
  780. package/dist/tui/features/connectors/components/confirm-switch-step.d.ts +10 -0
  781. package/dist/tui/features/connectors/components/confirm-switch-step.js +13 -0
  782. package/dist/tui/features/connectors/components/connector-list-step.d.ts +11 -0
  783. package/dist/tui/features/connectors/components/connector-list-step.js +29 -0
  784. package/dist/tui/features/connectors/components/connector-type-step.d.ts +13 -0
  785. package/dist/tui/features/connectors/components/connector-type-step.js +23 -0
  786. package/dist/tui/features/connectors/components/connectors-flow.d.ts +17 -0
  787. package/dist/tui/features/connectors/components/connectors-flow.js +179 -0
  788. package/dist/tui/features/connectors/utils/get-connector-name.d.ts +3 -0
  789. package/dist/tui/features/connectors/utils/get-connector-name.js +33 -0
  790. package/dist/tui/features/curate/api/create-curate-task.d.ts +22 -0
  791. package/dist/tui/features/curate/api/create-curate-task.js +40 -0
  792. package/dist/tui/features/curate/components/curate-flow.d.ts +20 -0
  793. package/dist/tui/features/curate/components/curate-flow.js +41 -0
  794. package/dist/tui/features/exit/components/exit-flow.d.ts +10 -0
  795. package/dist/tui/features/exit/components/exit-flow.js +19 -0
  796. package/dist/tui/features/hub/api/add-hub-registry.d.ts +15 -0
  797. package/dist/tui/features/hub/api/add-hub-registry.js +30 -0
  798. package/dist/tui/features/hub/api/get-hub-entries.d.ts +16 -0
  799. package/dist/tui/features/hub/api/get-hub-entries.js +17 -0
  800. package/dist/tui/features/hub/api/install-hub-entry.d.ts +14 -0
  801. package/dist/tui/features/hub/api/install-hub-entry.js +24 -0
  802. package/dist/tui/features/hub/api/list-hub-registries.d.ts +16 -0
  803. package/dist/tui/features/hub/api/list-hub-registries.js +17 -0
  804. package/dist/tui/features/hub/api/remove-hub-registry.d.ts +11 -0
  805. package/dist/tui/features/hub/api/remove-hub-registry.js +24 -0
  806. package/dist/tui/features/hub/components/hub-agent-step.d.ts +8 -0
  807. package/dist/tui/features/hub/components/hub-agent-step.js +14 -0
  808. package/dist/tui/features/hub/components/hub-detail-step.d.ts +10 -0
  809. package/dist/tui/features/hub/components/hub-detail-step.js +25 -0
  810. package/dist/tui/features/hub/components/hub-flow.d.ts +7 -0
  811. package/dist/tui/features/hub/components/hub-flow.js +90 -0
  812. package/dist/tui/features/hub/components/hub-list-step.d.ts +10 -0
  813. package/dist/tui/features/hub/components/hub-list-step.js +34 -0
  814. package/dist/tui/features/hub/components/hub-registry-add-view.d.ts +12 -0
  815. package/dist/tui/features/hub/components/hub-registry-add-view.js +36 -0
  816. package/dist/tui/features/hub/components/hub-registry-list-view.d.ts +7 -0
  817. package/dist/tui/features/hub/components/hub-registry-list-view.js +38 -0
  818. package/dist/tui/features/hub/components/hub-registry-remove-view.d.ts +8 -0
  819. package/dist/tui/features/hub/components/hub-registry-remove-view.js +17 -0
  820. package/dist/tui/features/model/api/get-models-by-providers.d.ts +20 -0
  821. package/dist/tui/features/model/api/get-models-by-providers.js +17 -0
  822. package/dist/tui/features/model/api/get-models.d.ts +20 -0
  823. package/dist/tui/features/model/api/get-models.js +17 -0
  824. package/dist/tui/features/model/api/set-active-model.d.ts +13 -0
  825. package/dist/tui/features/model/api/set-active-model.js +13 -0
  826. package/dist/tui/features/model/components/model-dialog.d.ts +67 -0
  827. package/dist/tui/features/model/components/model-dialog.js +96 -0
  828. package/dist/tui/features/model/components/model-flow.d.ts +17 -0
  829. package/dist/tui/features/model/components/model-flow.js +108 -0
  830. package/dist/tui/features/model/stores/model-store.d.ts +35 -0
  831. package/dist/tui/features/model/stores/model-store.js +26 -0
  832. package/dist/tui/features/onboarding/api/auto-setup-onboarding.d.ts +8 -0
  833. package/dist/tui/features/onboarding/api/auto-setup-onboarding.js +24 -0
  834. package/dist/tui/features/onboarding/api/complete-onboarding.d.ts +11 -0
  835. package/dist/tui/features/onboarding/api/complete-onboarding.js +24 -0
  836. package/dist/tui/features/onboarding/api/get-onboarding-state.d.ts +16 -0
  837. package/dist/tui/features/onboarding/api/get-onboarding-state.js +17 -0
  838. package/dist/tui/features/onboarding/hooks/use-app-view-mode.d.ts +27 -0
  839. package/dist/tui/features/onboarding/hooks/use-app-view-mode.js +36 -0
  840. package/dist/tui/features/onboarding/types.d.ts +7 -0
  841. package/dist/tui/features/onboarding/types.js +4 -0
  842. package/dist/tui/features/onboarding/utils.d.ts +28 -0
  843. package/dist/tui/features/onboarding/utils.js +76 -0
  844. package/dist/tui/features/provider/api/connect-provider.d.ts +13 -0
  845. package/dist/tui/features/provider/api/connect-provider.js +28 -0
  846. package/dist/tui/features/provider/api/disconnect-provider.d.ts +11 -0
  847. package/dist/tui/features/provider/api/disconnect-provider.js +26 -0
  848. package/dist/tui/features/provider/api/get-active-provider-config.d.ts +16 -0
  849. package/dist/tui/features/provider/api/get-active-provider-config.js +17 -0
  850. package/dist/tui/features/provider/api/get-providers.d.ts +16 -0
  851. package/dist/tui/features/provider/api/get-providers.js +17 -0
  852. package/dist/tui/features/provider/api/set-active-provider.d.ts +11 -0
  853. package/dist/tui/features/provider/api/set-active-provider.js +24 -0
  854. package/dist/tui/features/provider/api/validate-api-key.d.ts +12 -0
  855. package/dist/tui/features/provider/api/validate-api-key.js +13 -0
  856. package/dist/tui/features/provider/components/api-key-dialog.d.ts +41 -0
  857. package/dist/tui/features/provider/components/api-key-dialog.js +126 -0
  858. package/dist/tui/features/provider/components/base-url-dialog.d.ts +24 -0
  859. package/dist/tui/features/provider/components/base-url-dialog.js +77 -0
  860. package/dist/tui/features/provider/components/model-select-step.d.ts +20 -0
  861. package/dist/tui/features/provider/components/model-select-step.js +73 -0
  862. package/dist/tui/features/provider/components/provider-dialog.d.ts +29 -0
  863. package/dist/tui/features/provider/components/provider-dialog.js +20 -0
  864. package/dist/tui/features/provider/components/provider-flow.d.ts +25 -0
  865. package/dist/tui/features/provider/components/provider-flow.js +257 -0
  866. package/dist/tui/features/provider/stores/provider-store.d.ts +28 -0
  867. package/dist/tui/features/provider/stores/provider-store.js +22 -0
  868. package/dist/tui/features/pull/api/execute-pull.d.ts +11 -0
  869. package/dist/tui/features/pull/api/execute-pull.js +13 -0
  870. package/dist/tui/features/pull/api/prepare-pull.d.ts +20 -0
  871. package/dist/tui/features/pull/api/prepare-pull.js +17 -0
  872. package/dist/tui/features/pull/components/pull-flow.d.ts +12 -0
  873. package/dist/tui/features/pull/components/pull-flow.js +70 -0
  874. package/dist/tui/features/push/api/execute-push.d.ts +11 -0
  875. package/dist/tui/features/push/api/execute-push.js +13 -0
  876. package/dist/tui/features/push/api/prepare-push.d.ts +20 -0
  877. package/dist/tui/features/push/api/prepare-push.js +17 -0
  878. package/dist/tui/features/push/components/push-flow.d.ts +13 -0
  879. package/dist/tui/features/push/components/push-flow.js +86 -0
  880. package/dist/tui/features/query/api/create-query-task.d.ts +17 -0
  881. package/dist/tui/features/query/api/create-query-task.js +27 -0
  882. package/dist/tui/features/query/components/query-flow.d.ts +18 -0
  883. package/dist/tui/features/query/components/query-flow.js +36 -0
  884. package/dist/tui/features/reset/api/execute-reset.d.ts +8 -0
  885. package/dist/tui/features/reset/api/execute-reset.js +13 -0
  886. package/dist/tui/features/reset/components/reset-flow.d.ts +12 -0
  887. package/dist/tui/features/reset/components/reset-flow.js +44 -0
  888. package/dist/tui/features/session/components/new-session-flow.d.ts +12 -0
  889. package/dist/tui/features/session/components/new-session-flow.js +28 -0
  890. package/dist/tui/features/space/api/get-spaces.d.ts +16 -0
  891. package/dist/tui/features/space/api/get-spaces.js +17 -0
  892. package/dist/tui/features/space/api/switch-space.d.ts +11 -0
  893. package/dist/tui/features/space/api/switch-space.js +24 -0
  894. package/dist/tui/features/space/components/space-list-view.d.ts +12 -0
  895. package/dist/tui/features/space/components/space-list-view.js +56 -0
  896. package/dist/tui/features/space/components/space-switch-flow.d.ts +13 -0
  897. package/dist/tui/features/space/components/space-switch-flow.js +97 -0
  898. package/dist/tui/features/status/api/get-status.d.ts +16 -0
  899. package/dist/tui/features/status/api/get-status.js +17 -0
  900. package/dist/tui/features/status/components/status-view.d.ts +12 -0
  901. package/dist/tui/features/status/components/status-view.js +26 -0
  902. package/dist/tui/features/status/utils/format-status.d.ts +5 -0
  903. package/dist/tui/features/status/utils/format-status.js +62 -0
  904. package/dist/tui/features/tasks/components/task-subscription-initializer.d.ts +5 -0
  905. package/dist/tui/features/tasks/components/task-subscription-initializer.js +9 -0
  906. package/dist/tui/features/tasks/hooks/use-task-subscriptions.d.ts +5 -0
  907. package/dist/tui/features/tasks/hooks/use-task-subscriptions.js +74 -0
  908. package/dist/tui/features/tasks/stores/tasks-store.d.ts +92 -0
  909. package/dist/tui/features/tasks/stores/tasks-store.js +262 -0
  910. package/dist/tui/features/transport/components/transport-initializer.d.ts +13 -0
  911. package/dist/tui/features/transport/components/transport-initializer.js +107 -0
  912. package/dist/tui/features/transport/hooks/use-transport.d.ts +19 -0
  913. package/dist/tui/features/transport/hooks/use-transport.js +16 -0
  914. package/dist/tui/hooks/index.d.ts +14 -13
  915. package/dist/tui/hooks/index.js +15 -9
  916. package/dist/tui/hooks/use-terminal-breakpoint.js +3 -2
  917. package/dist/tui/lib/api-client.d.ts +20 -0
  918. package/dist/tui/lib/api-client.js +29 -0
  919. package/dist/tui/lib/environment.d.ts +18 -0
  920. package/dist/tui/lib/environment.js +18 -0
  921. package/dist/tui/lib/react-query.d.ts +17 -0
  922. package/dist/tui/lib/react-query.js +17 -0
  923. package/dist/tui/lib/transport-logger.d.ts +13 -0
  924. package/dist/tui/lib/transport-logger.js +40 -0
  925. package/dist/tui/providers/app-providers.d.ts +1 -16
  926. package/dist/tui/providers/app-providers.js +26 -4
  927. package/dist/tui/repl-startup.d.ts +1 -12
  928. package/dist/tui/repl-startup.js +6 -24
  929. package/dist/tui/stores/mode-store.d.ts +25 -0
  930. package/dist/tui/stores/mode-store.js +49 -0
  931. package/dist/tui/stores/theme-store.d.ts +43 -0
  932. package/dist/tui/stores/theme-store.js +39 -0
  933. package/dist/tui/stores/transport-store.d.ts +40 -0
  934. package/dist/tui/stores/transport-store.js +40 -0
  935. package/dist/tui/types/commands.d.ts +23 -91
  936. package/dist/tui/types/commands.js +1 -13
  937. package/dist/tui/types/index.d.ts +3 -4
  938. package/dist/tui/types/index.js +0 -2
  939. package/dist/tui/types/messages.d.ts +8 -1
  940. package/dist/tui/types/ui.d.ts +0 -5
  941. package/dist/tui/utils/error-messages.d.ts +22 -0
  942. package/dist/tui/utils/error-messages.js +45 -0
  943. package/dist/tui/utils/index.d.ts +2 -0
  944. package/dist/tui/utils/index.js +2 -0
  945. package/dist/tui/utils/input.d.ts +14 -0
  946. package/dist/tui/utils/input.js +17 -0
  947. package/dist/tui/utils/log.d.ts +1 -1
  948. package/node_modules/@campfirein/brv-transport-client/README.md +79 -338
  949. package/node_modules/@campfirein/brv-transport-client/dist/constants.d.ts +18 -3
  950. package/node_modules/@campfirein/brv-transport-client/dist/constants.d.ts.map +1 -1
  951. package/node_modules/@campfirein/brv-transport-client/dist/constants.js +25 -4
  952. package/node_modules/@campfirein/brv-transport-client/dist/constants.js.map +1 -1
  953. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/entities/instance-info.d.ts +4 -9
  954. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/entities/instance-info.d.ts.map +1 -1
  955. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/entities/instance-info.js +9 -24
  956. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/entities/instance-info.js.map +1 -1
  957. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/errors/connection-error.d.ts +20 -0
  958. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/errors/connection-error.d.ts.map +1 -1
  959. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/errors/connection-error.js +30 -0
  960. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/errors/connection-error.js.map +1 -1
  961. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/errors/transport-error.d.ts +3 -1
  962. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/errors/transport-error.d.ts.map +1 -1
  963. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/errors/transport-error.js +4 -1
  964. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/errors/transport-error.js.map +1 -1
  965. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/events/event-names.d.ts +10 -1
  966. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/events/event-names.d.ts.map +1 -1
  967. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/events/event-names.js +10 -0
  968. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/events/event-names.js.map +1 -1
  969. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/events/index.d.ts +1 -1
  970. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/events/index.d.ts.map +1 -1
  971. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/events/index.js +1 -1
  972. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/events/index.js.map +1 -1
  973. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/types.d.ts +9 -0
  974. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/types.d.ts.map +1 -1
  975. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/types.js +8 -1
  976. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/types.js.map +1 -1
  977. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/validators/common.d.ts.map +1 -1
  978. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/validators/common.js.map +1 -1
  979. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/validators/event-name-validator.d.ts.map +1 -1
  980. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/validators/event-name-validator.js.map +1 -1
  981. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/validators/index.d.ts.map +1 -1
  982. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/validators/index.js.map +1 -1
  983. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/validators/room-name-validator.d.ts.map +1 -1
  984. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/validators/room-name-validator.js.map +1 -1
  985. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/validators/url-validator.d.ts.map +1 -1
  986. package/node_modules/@campfirein/brv-transport-client/dist/core/domain/validators/url-validator.js.map +1 -1
  987. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-client-factory-config.d.ts +150 -0
  988. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-client-factory-config.d.ts.map +1 -0
  989. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-client-factory-config.js +8 -0
  990. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-client-factory-config.js.map +1 -0
  991. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-client-factory.d.ts +9 -4
  992. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-client-factory.d.ts.map +1 -1
  993. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-client-factory.js.map +1 -1
  994. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-client-logger.d.ts.map +1 -1
  995. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-client-logger.js.map +1 -1
  996. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-client.d.ts.map +1 -1
  997. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-client.js.map +1 -1
  998. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-connection-state.d.ts.map +1 -1
  999. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-connection-state.js.map +1 -1
  1000. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-event-dispatcher.d.ts.map +1 -1
  1001. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-event-dispatcher.js.map +1 -1
  1002. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-force-reconnect-manager.d.ts.map +1 -1
  1003. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-force-reconnect-manager.js.map +1 -1
  1004. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-instance-discovery.d.ts +9 -22
  1005. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-instance-discovery.d.ts.map +1 -1
  1006. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-instance-discovery.js.map +1 -1
  1007. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-instance-manager.d.ts +46 -0
  1008. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-instance-manager.d.ts.map +1 -0
  1009. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-instance-manager.js +2 -0
  1010. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-instance-manager.js.map +1 -0
  1011. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-reconnection-strategy.d.ts.map +1 -1
  1012. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-reconnection-strategy.js.map +1 -1
  1013. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-room-manager.d.ts.map +1 -1
  1014. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-room-manager.js.map +1 -1
  1015. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-socket-provider.d.ts.map +1 -1
  1016. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-socket-provider.js.map +1 -1
  1017. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-socket.d.ts.map +1 -1
  1018. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-socket.js.map +1 -1
  1019. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-spawn-lock.d.ts +27 -0
  1020. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-spawn-lock.d.ts.map +1 -0
  1021. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-spawn-lock.js +2 -0
  1022. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-spawn-lock.js.map +1 -0
  1023. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-wake-detector.d.ts.map +1 -1
  1024. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-wake-detector.js.map +1 -1
  1025. package/node_modules/@campfirein/brv-transport-client/dist/index.d.ts +26 -16
  1026. package/node_modules/@campfirein/brv-transport-client/dist/index.d.ts.map +1 -1
  1027. package/node_modules/@campfirein/brv-transport-client/dist/index.js +28 -18
  1028. package/node_modules/@campfirein/brv-transport-client/dist/index.js.map +1 -1
  1029. package/node_modules/@campfirein/brv-transport-client/dist/infra/client-factory.d.ts +49 -167
  1030. package/node_modules/@campfirein/brv-transport-client/dist/infra/client-factory.d.ts.map +1 -1
  1031. package/node_modules/@campfirein/brv-transport-client/dist/infra/client-factory.js +161 -260
  1032. package/node_modules/@campfirein/brv-transport-client/dist/infra/client-factory.js.map +1 -1
  1033. package/node_modules/@campfirein/brv-transport-client/dist/infra/connection-state-manager.d.ts.map +1 -1
  1034. package/node_modules/@campfirein/brv-transport-client/dist/infra/connection-state-manager.js.map +1 -1
  1035. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-connector.d.ts +46 -0
  1036. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-connector.d.ts.map +1 -0
  1037. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-connector.js +47 -0
  1038. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-connector.js.map +1 -0
  1039. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-discovery-sync.d.ts +41 -0
  1040. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-discovery-sync.d.ts.map +1 -0
  1041. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-discovery-sync.js +48 -0
  1042. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-discovery-sync.js.map +1 -0
  1043. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-health.d.ts +37 -0
  1044. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-health.d.ts.map +1 -0
  1045. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-health.js +35 -0
  1046. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-health.js.map +1 -0
  1047. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-instance-discovery.d.ts +22 -0
  1048. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-instance-discovery.d.ts.map +1 -0
  1049. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-instance-discovery.js +83 -0
  1050. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-instance-discovery.js.map +1 -0
  1051. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-reconnector.d.ts +60 -0
  1052. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-reconnector.d.ts.map +1 -0
  1053. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-reconnector.js +101 -0
  1054. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-reconnector.js.map +1 -0
  1055. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-spawner.d.ts +33 -0
  1056. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-spawner.d.ts.map +1 -0
  1057. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-spawner.js +161 -0
  1058. package/node_modules/@campfirein/brv-transport-client/dist/infra/daemon-spawner.js.map +1 -0
  1059. package/node_modules/@campfirein/brv-transport-client/dist/infra/event-dispatcher.d.ts.map +1 -1
  1060. package/node_modules/@campfirein/brv-transport-client/dist/infra/event-dispatcher.js.map +1 -1
  1061. package/node_modules/@campfirein/brv-transport-client/dist/infra/find-project-root.d.ts +11 -0
  1062. package/node_modules/@campfirein/brv-transport-client/dist/infra/find-project-root.d.ts.map +1 -0
  1063. package/node_modules/@campfirein/brv-transport-client/dist/infra/find-project-root.js +31 -0
  1064. package/node_modules/@campfirein/brv-transport-client/dist/infra/find-project-root.js.map +1 -0
  1065. package/node_modules/@campfirein/brv-transport-client/dist/infra/force-reconnect-manager.d.ts +1 -0
  1066. package/node_modules/@campfirein/brv-transport-client/dist/infra/force-reconnect-manager.d.ts.map +1 -1
  1067. package/node_modules/@campfirein/brv-transport-client/dist/infra/force-reconnect-manager.js +4 -0
  1068. package/node_modules/@campfirein/brv-transport-client/dist/infra/force-reconnect-manager.js.map +1 -1
  1069. package/node_modules/@campfirein/brv-transport-client/dist/infra/global-data-path.d.ts +12 -0
  1070. package/node_modules/@campfirein/brv-transport-client/dist/infra/global-data-path.d.ts.map +1 -0
  1071. package/node_modules/@campfirein/brv-transport-client/dist/infra/global-data-path.js +38 -0
  1072. package/node_modules/@campfirein/brv-transport-client/dist/infra/global-data-path.js.map +1 -0
  1073. package/node_modules/@campfirein/brv-transport-client/dist/infra/global-instance-manager.d.ts +37 -0
  1074. package/node_modules/@campfirein/brv-transport-client/dist/infra/global-instance-manager.d.ts.map +1 -0
  1075. package/node_modules/@campfirein/brv-transport-client/dist/infra/global-instance-manager.js +100 -0
  1076. package/node_modules/@campfirein/brv-transport-client/dist/infra/global-instance-manager.js.map +1 -0
  1077. package/node_modules/@campfirein/brv-transport-client/dist/infra/heartbeat-utils.d.ts +12 -0
  1078. package/node_modules/@campfirein/brv-transport-client/dist/infra/heartbeat-utils.d.ts.map +1 -0
  1079. package/node_modules/@campfirein/brv-transport-client/dist/infra/heartbeat-utils.js +29 -0
  1080. package/node_modules/@campfirein/brv-transport-client/dist/infra/heartbeat-utils.js.map +1 -0
  1081. package/node_modules/@campfirein/brv-transport-client/dist/infra/no-op-client-logger.d.ts.map +1 -1
  1082. package/node_modules/@campfirein/brv-transport-client/dist/infra/no-op-client-logger.js.map +1 -1
  1083. package/node_modules/@campfirein/brv-transport-client/dist/infra/process-utils.d.ts.map +1 -1
  1084. package/node_modules/@campfirein/brv-transport-client/dist/infra/process-utils.js.map +1 -1
  1085. package/node_modules/@campfirein/brv-transport-client/dist/infra/reconnection-strategy.d.ts.map +1 -1
  1086. package/node_modules/@campfirein/brv-transport-client/dist/infra/reconnection-strategy.js.map +1 -1
  1087. package/node_modules/@campfirein/brv-transport-client/dist/infra/resolve-server-path.d.ts +12 -0
  1088. package/node_modules/@campfirein/brv-transport-client/dist/infra/resolve-server-path.d.ts.map +1 -0
  1089. package/node_modules/@campfirein/brv-transport-client/dist/infra/resolve-server-path.js +52 -0
  1090. package/node_modules/@campfirein/brv-transport-client/dist/infra/resolve-server-path.js.map +1 -0
  1091. package/node_modules/@campfirein/brv-transport-client/dist/infra/room-manager.d.ts.map +1 -1
  1092. package/node_modules/@campfirein/brv-transport-client/dist/infra/room-manager.js.map +1 -1
  1093. package/node_modules/@campfirein/brv-transport-client/dist/infra/schemas/index.d.ts +2 -2
  1094. package/node_modules/@campfirein/brv-transport-client/dist/infra/schemas/index.d.ts.map +1 -1
  1095. package/node_modules/@campfirein/brv-transport-client/dist/infra/schemas/index.js +4 -2
  1096. package/node_modules/@campfirein/brv-transport-client/dist/infra/schemas/index.js.map +1 -1
  1097. package/node_modules/@campfirein/brv-transport-client/dist/infra/schemas/schemas.d.ts +65 -3
  1098. package/node_modules/@campfirein/brv-transport-client/dist/infra/schemas/schemas.d.ts.map +1 -1
  1099. package/node_modules/@campfirein/brv-transport-client/dist/infra/schemas/schemas.js +44 -1
  1100. package/node_modules/@campfirein/brv-transport-client/dist/infra/schemas/schemas.js.map +1 -1
  1101. package/node_modules/@campfirein/brv-transport-client/dist/infra/schemas/types.d.ts +11 -1
  1102. package/node_modules/@campfirein/brv-transport-client/dist/infra/schemas/types.d.ts.map +1 -1
  1103. package/node_modules/@campfirein/brv-transport-client/dist/infra/schemas/types.js.map +1 -1
  1104. package/node_modules/@campfirein/brv-transport-client/dist/infra/socket-io-client.d.ts +32 -61
  1105. package/node_modules/@campfirein/brv-transport-client/dist/infra/socket-io-client.d.ts.map +1 -1
  1106. package/node_modules/@campfirein/brv-transport-client/dist/infra/socket-io-client.js +133 -37
  1107. package/node_modules/@campfirein/brv-transport-client/dist/infra/socket-io-client.js.map +1 -1
  1108. package/node_modules/@campfirein/brv-transport-client/dist/infra/spawn-lock.d.ts +27 -0
  1109. package/node_modules/@campfirein/brv-transport-client/dist/infra/spawn-lock.d.ts.map +1 -0
  1110. package/node_modules/@campfirein/brv-transport-client/dist/infra/spawn-lock.js +124 -0
  1111. package/node_modules/@campfirein/brv-transport-client/dist/infra/spawn-lock.js.map +1 -0
  1112. package/node_modules/@campfirein/brv-transport-client/dist/infra/utils/deep-freeze.d.ts.map +1 -1
  1113. package/node_modules/@campfirein/brv-transport-client/dist/infra/utils/deep-freeze.js.map +1 -1
  1114. package/node_modules/@campfirein/brv-transport-client/dist/infra/wait-for-connected-client.d.ts +13 -0
  1115. package/node_modules/@campfirein/brv-transport-client/dist/infra/wait-for-connected-client.d.ts.map +1 -0
  1116. package/node_modules/@campfirein/brv-transport-client/dist/infra/wait-for-connected-client.js +33 -0
  1117. package/node_modules/@campfirein/brv-transport-client/dist/infra/wait-for-connected-client.js.map +1 -0
  1118. package/node_modules/@campfirein/brv-transport-client/dist/infra/wake-detector.d.ts.map +1 -1
  1119. package/node_modules/@campfirein/brv-transport-client/dist/infra/wake-detector.js.map +1 -1
  1120. package/node_modules/@campfirein/brv-transport-client/package.json +3 -12
  1121. package/oclif.manifest.json +1215 -180
  1122. package/package.json +56 -10
  1123. package/dist/agent/infra/blob/migrations.d.ts +0 -63
  1124. package/dist/agent/infra/blob/migrations.js +0 -148
  1125. package/dist/agent/infra/blob/sqlite-blob-storage.d.ts +0 -82
  1126. package/dist/agent/infra/blob/sqlite-blob-storage.js +0 -304
  1127. package/dist/agent/infra/llm/generators/openrouter-content-generator.d.ts +0 -94
  1128. package/dist/agent/infra/llm/generators/openrouter-content-generator.js +0 -280
  1129. package/dist/agent/infra/llm/internal-llm-service.d.ts +0 -375
  1130. package/dist/agent/infra/llm/internal-llm-service.js +0 -1079
  1131. package/dist/agent/infra/llm/openrouter-llm-service.d.ts +0 -215
  1132. package/dist/agent/infra/llm/openrouter-llm-service.js +0 -572
  1133. package/dist/agent/infra/llm/stream-processor.d.ts +0 -178
  1134. package/dist/agent/infra/llm/stream-processor.js +0 -350
  1135. package/dist/agent/infra/llm/transformers/openrouter-stream-transformer.d.ts +0 -49
  1136. package/dist/agent/infra/llm/transformers/openrouter-stream-transformer.js +0 -270
  1137. package/dist/agent/infra/storage/blob-history-storage.d.ts +0 -76
  1138. package/dist/agent/infra/storage/blob-history-storage.js +0 -178
  1139. package/dist/agent/infra/storage/dual-format-history-storage.d.ts +0 -77
  1140. package/dist/agent/infra/storage/dual-format-history-storage.js +0 -149
  1141. package/dist/agent/infra/storage/sqlite-key-storage.d.ts +0 -105
  1142. package/dist/agent/infra/storage/sqlite-key-storage.js +0 -404
  1143. package/dist/oclif/commands/curate.d.ts +0 -21
  1144. package/dist/oclif/commands/curate.js +0 -96
  1145. package/dist/oclif/commands/init.d.ts +0 -18
  1146. package/dist/oclif/commands/init.js +0 -129
  1147. package/dist/server/core/domain/entities/context-tree-index.d.ts +0 -26
  1148. package/dist/server/core/domain/entities/context-tree-index.js +0 -27
  1149. package/dist/server/core/domain/entities/event.d.ts +0 -8
  1150. package/dist/server/core/domain/entities/event.js +0 -25
  1151. package/dist/server/core/domain/errors/ace-error.d.ts +0 -34
  1152. package/dist/server/core/domain/errors/ace-error.js +0 -53
  1153. package/dist/server/core/domain/errors/brv-config-version-error.d.ts +0 -16
  1154. package/dist/server/core/domain/errors/brv-config-version-error.js +0 -21
  1155. package/dist/server/core/domain/errors/core-process-error.d.ts +0 -27
  1156. package/dist/server/core/domain/errors/core-process-error.js +0 -43
  1157. package/dist/server/core/domain/instance/index.d.ts +0 -1
  1158. package/dist/server/core/domain/instance/index.js +0 -1
  1159. package/dist/server/core/domain/instance/types.d.ts +0 -57
  1160. package/dist/server/core/domain/instance/types.js +0 -72
  1161. package/dist/server/core/interfaces/instance/i-instance-discovery.d.ts +0 -45
  1162. package/dist/server/core/interfaces/instance/i-instance-manager.d.ts +0 -58
  1163. package/dist/server/core/interfaces/instance/index.d.ts +0 -2
  1164. package/dist/server/core/interfaces/instance/index.js +0 -2
  1165. package/dist/server/core/interfaces/noop-implementations.d.ts +0 -53
  1166. package/dist/server/core/interfaces/noop-implementations.js +0 -62
  1167. package/dist/server/core/interfaces/services/i-tracking-service.d.ts +0 -21
  1168. package/dist/server/core/interfaces/usecase/i-connectors-use-case.d.ts +0 -3
  1169. package/dist/server/core/interfaces/usecase/i-curate-use-case.d.ts +0 -14
  1170. package/dist/server/core/interfaces/usecase/i-init-use-case.d.ts +0 -11
  1171. package/dist/server/core/interfaces/usecase/i-login-use-case.d.ts +0 -6
  1172. package/dist/server/core/interfaces/usecase/i-logout-use-case.d.ts +0 -5
  1173. package/dist/server/core/interfaces/usecase/i-pull-use-case.d.ts +0 -7
  1174. package/dist/server/core/interfaces/usecase/i-push-use-case.d.ts +0 -8
  1175. package/dist/server/core/interfaces/usecase/i-query-use-case.d.ts +0 -11
  1176. package/dist/server/core/interfaces/usecase/i-reset-use-case.d.ts +0 -6
  1177. package/dist/server/core/interfaces/usecase/i-space-list-use-case.d.ts +0 -3
  1178. package/dist/server/core/interfaces/usecase/i-space-switch-use-case.d.ts +0 -3
  1179. package/dist/server/core/interfaces/usecase/i-status-use-case.d.ts +0 -6
  1180. package/dist/server/infra/executor/task-processor.d.ts +0 -89
  1181. package/dist/server/infra/executor/task-processor.js +0 -133
  1182. package/dist/server/infra/instance/file-instance-discovery.d.ts +0 -31
  1183. package/dist/server/infra/instance/file-instance-discovery.js +0 -84
  1184. package/dist/server/infra/instance/file-instance-manager.d.ts +0 -46
  1185. package/dist/server/infra/instance/file-instance-manager.js +0 -123
  1186. package/dist/server/infra/instance/index.d.ts +0 -3
  1187. package/dist/server/infra/instance/index.js +0 -3
  1188. package/dist/server/infra/instance/process-utils.d.ts +0 -14
  1189. package/dist/server/infra/instance/process-utils.js +0 -39
  1190. package/dist/server/infra/process/agent-worker.d.ts +0 -20
  1191. package/dist/server/infra/process/agent-worker.js +0 -1399
  1192. package/dist/server/infra/process/inline-agent-executor.d.ts +0 -32
  1193. package/dist/server/infra/process/inline-agent-executor.js +0 -278
  1194. package/dist/server/infra/process/ipc-types.d.ts +0 -68
  1195. package/dist/server/infra/process/ipc-types.js +0 -12
  1196. package/dist/server/infra/process/parent-heartbeat.d.ts +0 -47
  1197. package/dist/server/infra/process/parent-heartbeat.js +0 -118
  1198. package/dist/server/infra/process/process-manager.d.ts +0 -242
  1199. package/dist/server/infra/process/process-manager.js +0 -765
  1200. package/dist/server/infra/process/task-queue-manager.d.ts +0 -125
  1201. package/dist/server/infra/process/task-queue-manager.js +0 -185
  1202. package/dist/server/infra/process/transport-worker.d.ts +0 -20
  1203. package/dist/server/infra/process/transport-worker.js +0 -196
  1204. package/dist/server/infra/storage/keychain-token-store.d.ts +0 -13
  1205. package/dist/server/infra/storage/keychain-token-store.js +0 -42
  1206. package/dist/server/infra/terminal/oclif-terminal.d.ts +0 -19
  1207. package/dist/server/infra/terminal/oclif-terminal.js +0 -60
  1208. package/dist/server/infra/terminal/repl-terminal.d.ts +0 -31
  1209. package/dist/server/infra/terminal/repl-terminal.js +0 -116
  1210. package/dist/server/infra/tracking/mixpanel-tracking-service.d.ts +0 -24
  1211. package/dist/server/infra/tracking/mixpanel-tracking-service.js +0 -49
  1212. package/dist/server/infra/transport/transport-factory.d.ts +0 -17
  1213. package/dist/server/infra/transport/transport-factory.js +0 -31
  1214. package/dist/server/infra/usecase/connectors-use-case.d.ts +0 -63
  1215. package/dist/server/infra/usecase/connectors-use-case.js +0 -234
  1216. package/dist/server/infra/usecase/curate-use-case.d.ts +0 -59
  1217. package/dist/server/infra/usecase/curate-use-case.js +0 -274
  1218. package/dist/server/infra/usecase/init-use-case.d.ts +0 -126
  1219. package/dist/server/infra/usecase/init-use-case.js +0 -538
  1220. package/dist/server/infra/usecase/login-use-case.d.ts +0 -30
  1221. package/dist/server/infra/usecase/login-use-case.js +0 -127
  1222. package/dist/server/infra/usecase/logout-use-case.d.ts +0 -19
  1223. package/dist/server/infra/usecase/logout-use-case.js +0 -48
  1224. package/dist/server/infra/usecase/pull-use-case.d.ts +0 -49
  1225. package/dist/server/infra/usecase/pull-use-case.js +0 -147
  1226. package/dist/server/infra/usecase/push-use-case.d.ts +0 -50
  1227. package/dist/server/infra/usecase/push-use-case.js +0 -191
  1228. package/dist/server/infra/usecase/query-use-case.d.ts +0 -73
  1229. package/dist/server/infra/usecase/query-use-case.js +0 -420
  1230. package/dist/server/infra/usecase/reset-use-case.d.ts +0 -21
  1231. package/dist/server/infra/usecase/reset-use-case.js +0 -60
  1232. package/dist/server/infra/usecase/space-list-use-case.d.ts +0 -27
  1233. package/dist/server/infra/usecase/space-list-use-case.js +0 -64
  1234. package/dist/server/infra/usecase/space-switch-use-case.d.ts +0 -26
  1235. package/dist/server/infra/usecase/space-switch-use-case.js +0 -110
  1236. package/dist/server/infra/usecase/status-use-case.d.ts +0 -75
  1237. package/dist/server/infra/usecase/status-use-case.js +0 -268
  1238. package/dist/server/templates/skill/TROUBLESHOOTING.md +0 -50
  1239. package/dist/server/templates/skill/WORKFLOWS.md +0 -229
  1240. package/dist/server/utils/environment-detector.d.ts +0 -20
  1241. package/dist/server/utils/environment-detector.js +0 -92
  1242. package/dist/tui/app.d.ts +0 -9
  1243. package/dist/tui/app.js +0 -28
  1244. package/dist/tui/commands/arg-parser.d.ts +0 -102
  1245. package/dist/tui/commands/connectors-command.d.ts +0 -8
  1246. package/dist/tui/commands/connectors-command.js +0 -49
  1247. package/dist/tui/commands/curate-command.d.ts +0 -9
  1248. package/dist/tui/commands/curate-command.js +0 -80
  1249. package/dist/tui/commands/index.d.ts +0 -8
  1250. package/dist/tui/commands/index.js +0 -45
  1251. package/dist/tui/commands/init-command.d.ts +0 -7
  1252. package/dist/tui/commands/init-command.js +0 -87
  1253. package/dist/tui/commands/login-command.d.ts +0 -7
  1254. package/dist/tui/commands/login-command.js +0 -50
  1255. package/dist/tui/commands/logout-command.d.ts +0 -5
  1256. package/dist/tui/commands/logout-command.js +0 -46
  1257. package/dist/tui/commands/model-command.d.ts +0 -13
  1258. package/dist/tui/commands/model-command.js +0 -212
  1259. package/dist/tui/commands/new-command.d.ts +0 -14
  1260. package/dist/tui/commands/new-command.js +0 -61
  1261. package/dist/tui/commands/provider-command.d.ts +0 -13
  1262. package/dist/tui/commands/provider-command.js +0 -181
  1263. package/dist/tui/commands/pull-command.d.ts +0 -5
  1264. package/dist/tui/commands/pull-command.js +0 -61
  1265. package/dist/tui/commands/push-command.d.ts +0 -5
  1266. package/dist/tui/commands/push-command.js +0 -66
  1267. package/dist/tui/commands/query-command.d.ts +0 -5
  1268. package/dist/tui/commands/query-command.js +0 -63
  1269. package/dist/tui/commands/reset-command.d.ts +0 -5
  1270. package/dist/tui/commands/reset-command.js +0 -61
  1271. package/dist/tui/commands/space/index.d.ts +0 -5
  1272. package/dist/tui/commands/space/index.js +0 -14
  1273. package/dist/tui/commands/space/list-command.d.ts +0 -5
  1274. package/dist/tui/commands/space/list-command.js +0 -70
  1275. package/dist/tui/commands/space/switch-command.d.ts +0 -5
  1276. package/dist/tui/commands/space/switch-command.js +0 -35
  1277. package/dist/tui/commands/status-command.d.ts +0 -5
  1278. package/dist/tui/commands/status-command.js +0 -39
  1279. package/dist/tui/components/api-key-dialog.d.ts +0 -39
  1280. package/dist/tui/components/api-key-dialog.js +0 -94
  1281. package/dist/tui/components/message-list.d.ts +0 -16
  1282. package/dist/tui/components/message-list.js +0 -120
  1283. package/dist/tui/components/model-dialog.d.ts +0 -63
  1284. package/dist/tui/components/model-dialog.js +0 -89
  1285. package/dist/tui/components/provider-dialog.d.ts +0 -27
  1286. package/dist/tui/components/provider-dialog.js +0 -31
  1287. package/dist/tui/components/tab-bar.d.ts +0 -11
  1288. package/dist/tui/components/tab-bar.js +0 -11
  1289. package/dist/tui/constants.d.ts +0 -6
  1290. package/dist/tui/constants.js +0 -8
  1291. package/dist/tui/contexts/auth-context.d.ts +0 -33
  1292. package/dist/tui/contexts/auth-context.js +0 -193
  1293. package/dist/tui/contexts/commands-context.d.ts +0 -37
  1294. package/dist/tui/contexts/commands-context.js +0 -65
  1295. package/dist/tui/contexts/index.d.ts +0 -11
  1296. package/dist/tui/contexts/index.js +0 -11
  1297. package/dist/tui/contexts/mode-context.d.ts +0 -43
  1298. package/dist/tui/contexts/mode-context.js +0 -70
  1299. package/dist/tui/contexts/onboarding-context.d.ts +0 -49
  1300. package/dist/tui/contexts/onboarding-context.js +0 -193
  1301. package/dist/tui/contexts/services-context.d.ts +0 -32
  1302. package/dist/tui/contexts/services-context.js +0 -27
  1303. package/dist/tui/contexts/tasks-context.d.ts +0 -101
  1304. package/dist/tui/contexts/tasks-context.js +0 -422
  1305. package/dist/tui/contexts/theme-context.d.ts +0 -55
  1306. package/dist/tui/contexts/theme-context.js +0 -62
  1307. package/dist/tui/contexts/transport-context.d.ts +0 -29
  1308. package/dist/tui/contexts/transport-context.js +0 -81
  1309. package/dist/tui/hooks/use-activity-logs.d.ts +0 -18
  1310. package/dist/tui/hooks/use-activity-logs.js +0 -207
  1311. package/dist/tui/hooks/use-auth-polling.d.ts +0 -27
  1312. package/dist/tui/hooks/use-auth-polling.js +0 -118
  1313. package/dist/tui/hooks/use-onboarding-logs.d.ts +0 -17
  1314. package/dist/tui/hooks/use-onboarding-logs.js +0 -26
  1315. package/dist/tui/hooks/use-onboarding.d.ts +0 -7
  1316. package/dist/tui/hooks/use-onboarding.js +0 -6
  1317. package/dist/tui/hooks/use-slash-command-processor.d.ts +0 -16
  1318. package/dist/tui/hooks/use-slash-command-processor.js +0 -132
  1319. package/dist/tui/hooks/use-slash-completion.d.ts +0 -30
  1320. package/dist/tui/hooks/use-slash-completion.js +0 -251
  1321. package/dist/tui/index.d.ts +0 -1
  1322. package/dist/tui/index.js +0 -1
  1323. package/dist/tui/types.d.ts +0 -1
  1324. package/dist/tui/types.js +0 -1
  1325. package/dist/tui/utils/transport-client-helper.d.ts +0 -9
  1326. package/dist/tui/utils/transport-client-helper.js +0 -99
  1327. package/dist/tui/views/index.d.ts +0 -5
  1328. package/dist/tui/views/index.js +0 -5
  1329. package/dist/tui/views/init-view.d.ts +0 -15
  1330. package/dist/tui/views/init-view.js +0 -41
  1331. package/dist/tui/views/login-view.d.ts +0 -10
  1332. package/dist/tui/views/login-view.js +0 -33
  1333. package/dist/tui/views/main-view.d.ts +0 -12
  1334. package/dist/tui/views/main-view.js +0 -20
  1335. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-instance-reader.d.ts +0 -19
  1336. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-instance-reader.d.ts.map +0 -1
  1337. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-instance-reader.js +0 -2
  1338. package/node_modules/@campfirein/brv-transport-client/dist/core/interfaces/i-instance-reader.js.map +0 -1
  1339. package/node_modules/@campfirein/brv-transport-client/dist/infra/file-instance-discovery.d.ts +0 -32
  1340. package/node_modules/@campfirein/brv-transport-client/dist/infra/file-instance-discovery.d.ts.map +0 -1
  1341. package/node_modules/@campfirein/brv-transport-client/dist/infra/file-instance-discovery.js +0 -85
  1342. package/node_modules/@campfirein/brv-transport-client/dist/infra/file-instance-discovery.js.map +0 -1
  1343. package/node_modules/@campfirein/brv-transport-client/dist/infra/file-instance-reader.d.ts +0 -16
  1344. package/node_modules/@campfirein/brv-transport-client/dist/infra/file-instance-reader.d.ts.map +0 -1
  1345. package/node_modules/@campfirein/brv-transport-client/dist/infra/file-instance-reader.js +0 -47
  1346. package/node_modules/@campfirein/brv-transport-client/dist/infra/file-instance-reader.js.map +0 -1
  1347. /package/dist/{server/core/interfaces/instance/i-instance-discovery.js → agent/infra/agent/provider-update-config.js} +0 -0
  1348. /package/dist/server/core/{interfaces/instance/i-instance-manager.js → domain/entities/curate-log-entry.js} +0 -0
  1349. /package/dist/server/core/{interfaces/services/i-tracking-service.js → domain/entities/curation-status.js} +0 -0
  1350. /package/dist/server/core/{interfaces/usecase/i-connectors-use-case.js → domain/transport/task-info.js} +0 -0
  1351. /package/dist/server/core/interfaces/{usecase/i-curate-use-case.js → agent/i-agent-pool.js} +0 -0
  1352. /package/dist/server/core/interfaces/{usecase/i-init-use-case.js → client/i-client-manager.js} +0 -0
  1353. /package/dist/server/core/interfaces/{usecase/i-login-use-case.js → context-tree/i-context-tree-archive-service.js} +0 -0
  1354. /package/dist/server/core/interfaces/{usecase/i-logout-use-case.js → context-tree/i-context-tree-manifest-service.js} +0 -0
  1355. /package/dist/server/core/interfaces/{usecase/i-pull-use-case.js → context-tree/i-context-tree-merger.js} +0 -0
  1356. /package/dist/server/core/interfaces/{usecase/i-push-use-case.js → context-tree/i-context-tree-summary-service.js} +0 -0
  1357. /package/dist/server/core/interfaces/{usecase/i-query-use-case.js → daemon/i-agent-idle-timeout-policy.js} +0 -0
  1358. /package/dist/server/core/interfaces/{usecase/i-reset-use-case.js → daemon/i-daemon-resilience.js} +0 -0
  1359. /package/dist/server/core/interfaces/{usecase/i-space-list-use-case.js → daemon/i-heartbeat-writer.js} +0 -0
  1360. /package/dist/server/core/interfaces/{usecase/i-space-switch-use-case.js → daemon/i-idle-timeout-policy.js} +0 -0
  1361. /package/dist/server/core/interfaces/{usecase/i-status-use-case.js → daemon/i-shutdown-handler.js} +0 -0
  1362. /package/dist/tui/{commands → features/commands/utils}/arg-parser.js +0 -0
@@ -1,1079 +0,0 @@
1
- import { getErrorMessage } from '../../../server/utils/error-helpers.js';
2
- import { AgentStateMachine } from '../../core/domain/agent/agent-state-machine.js';
3
- import { AgentState, TerminationReason } from '../../core/domain/agent/agent-state.js';
4
- import { LlmGenerationError, LlmMaxIterationsError, LlmResponseParsingError } from '../../core/domain/errors/llm-error.js';
5
- import { getEffectiveMaxInputTokens, getMaxInputTokensForModel, getProviderFromModel, isValidProviderModel, safeParseLLMConfig, } from '../../core/domain/llm/index.js';
6
- import { StreamChunkType, } from '../../core/interfaces/i-content-generator.js';
7
- import { NoOpLogger } from '../../core/interfaces/i-logger.js';
8
- import { EnvironmentContextBuilder } from '../environment/environment-context-builder.js';
9
- import { ToolMetadataHandler } from '../tools/streaming/metadata-handler.js';
10
- import { AsyncMutex } from './context/async-mutex.js';
11
- import { ContextManager } from './context/context-manager.js';
12
- import { LoopDetector } from './context/loop-detector.js';
13
- import { ClaudeMessageFormatter } from './formatters/claude-formatter.js';
14
- import { GeminiMessageFormatter } from './formatters/gemini-formatter.js';
15
- import { ThoughtParser } from './thought-parser.js';
16
- import { ClaudeTokenizer } from './tokenizers/claude-tokenizer.js';
17
- import { GeminiTokenizer } from './tokenizers/gemini-tokenizer.js';
18
- import { ToolOutputProcessor } from './tool-output-processor.js';
19
- /** Target utilization ratio for message tokens (leaves headroom for response) */
20
- const TARGET_MESSAGE_TOKEN_UTILIZATION = 0.7;
21
- /**
22
- * ByteRover LLM Service.
23
- *
24
- * Orchestrates the agentic loop using IContentGenerator for LLM calls.
25
- * Responsibilities:
26
- * - Manage conversation context via ContextManager
27
- * - Execute agentic loop (call LLM → execute tools → repeat)
28
- * - Delegate tool execution to ToolManager
29
- * - Delegate LLM calls to IContentGenerator
30
- * - Handle errors and iteration limits
31
- *
32
- * Does NOT:
33
- * - Execute tools directly (uses ToolManager)
34
- * - Store persistent history (uses in-memory ContextManager)
35
- * - Format messages for specific providers (handled by generators)
36
- * - Handle retry logic (handled by RetryableContentGenerator decorator)
37
- */
38
- export class ByteRoverLLMService {
39
- /** Cached base system prompt (everything built by SystemPromptManager) for reuse across iterations */
40
- cachedBasePrompt = null;
41
- compactionService;
42
- config;
43
- contextManager;
44
- environmentBuilder;
45
- formatter;
46
- generator;
47
- logger;
48
- loopDetector;
49
- /** Flag indicating memory was modified by tools during this task, requiring prompt rebuild */
50
- memoryDirtyFlag = false;
51
- memoryManager;
52
- metadataHandler;
53
- mutex = new AsyncMutex();
54
- outputProcessor;
55
- providerType;
56
- sessionEventBus;
57
- sessionId;
58
- systemPromptManager;
59
- tokenizer;
60
- toolManager;
61
- workingDirectory;
62
- /**
63
- * Initialize a new ByteRover LLM service instance.
64
- *
65
- * Sets up the service with all required dependencies and initializes:
66
- * - Context manager for conversation history
67
- * - Message formatter (Gemini or Claude format based on model)
68
- * - Token counter/tokenizer for the selected model
69
- * - Configuration with sensible defaults
70
- *
71
- * Each service instance maintains isolated conversation context,
72
- * allowing multiple concurrent sessions with separate histories.
73
- *
74
- * @param sessionId - Unique identifier for this session
75
- * @param generator - Content generator for LLM calls (with decorators pre-applied)
76
- * @param config - LLM service configuration (model, tokens, temperature)
77
- * @param options - Service dependencies
78
- * @param options.toolManager - Tool manager for executing agent tools
79
- * @param options.systemPromptManager - System prompt manager for building system prompts
80
- * @param options.memoryManager - Memory manager for agent memories
81
- * @param options.sessionEventBus - Event bus for session lifecycle events
82
- * @param options.compactionService - Optional compaction service for context overflow management
83
- * @param options.historyStorage - Optional history storage for persistence
84
- * @param options.logger - Optional logger for structured logging
85
- */
86
- constructor(sessionId, generator, config, options) {
87
- this.sessionId = sessionId;
88
- this.generator = generator;
89
- this.compactionService = options.compactionService;
90
- this.toolManager = options.toolManager;
91
- this.systemPromptManager = options.systemPromptManager;
92
- this.memoryManager = options.memoryManager;
93
- this.sessionEventBus = options.sessionEventBus;
94
- this.logger = options.logger ?? new NoOpLogger();
95
- this.outputProcessor = new ToolOutputProcessor(config.truncationConfig);
96
- this.loopDetector = new LoopDetector();
97
- this.environmentBuilder = new EnvironmentContextBuilder();
98
- this.metadataHandler = new ToolMetadataHandler(this.sessionEventBus);
99
- this.workingDirectory = process.cwd();
100
- // Detect provider type from model name (needed for validation)
101
- const modelName = config.model ?? 'claude-haiku-4-5@20251001';
102
- this.providerType = this.detectProviderType(modelName);
103
- // Validate core LLM config using Zod schema (logs warning if invalid)
104
- this.validateConfig(modelName, config.maxInputTokens);
105
- // Get effective max input tokens from registry (respects model limits)
106
- const effectiveMaxInputTokens = getEffectiveMaxInputTokens(this.providerType, modelName, config.maxInputTokens);
107
- this.config = {
108
- maxInputTokens: effectiveMaxInputTokens,
109
- maxIterations: config.maxIterations ?? 50,
110
- maxTokens: config.maxTokens ?? 8192,
111
- model: modelName,
112
- temperature: config.temperature ?? 0.7,
113
- thinkingConfig: config.thinkingConfig,
114
- timeout: config.timeout,
115
- verbose: config.verbose ?? false,
116
- };
117
- // Initialize formatter and tokenizer based on provider type
118
- if (this.providerType === 'claude') {
119
- this.formatter = new ClaudeMessageFormatter();
120
- this.tokenizer = new ClaudeTokenizer(this.config.model);
121
- }
122
- else {
123
- this.formatter = new GeminiMessageFormatter();
124
- this.tokenizer = new GeminiTokenizer(this.config.model);
125
- }
126
- // Initialize context manager with optional history storage
127
- this.contextManager = new ContextManager({
128
- formatter: this.formatter,
129
- historyStorage: options.historyStorage,
130
- maxInputTokens: this.config.maxInputTokens,
131
- sessionId,
132
- tokenizer: this.tokenizer,
133
- });
134
- }
135
- /**
136
- * Complete a task with tool calling support.
137
- *
138
- * This is the main entry point for the agentic loop.
139
- * It handles:
140
- * 1. Adding user message to context
141
- * 2. Looping: call LLM → check for tool calls → execute tools
142
- * 3. Returning final response when no more tool calls
143
- *
144
- * @param textInput - User input text
145
- * @param options - Execution options
146
- * @param options.executionContext - Optional execution context
147
- * @param options.signal - Optional abort signal for cancellation
148
- * @param options.imageData - Optional image data
149
- * @param options.fileData - Optional file data
150
- * @param options.stream - Whether to stream response (not implemented yet)
151
- * @param options.taskId - Task ID from usecase for billing tracking
152
- * @returns Final assistant response
153
- */
154
- async completeTask(textInput, options) {
155
- // Reset per-task prompt cache (each task gets a fresh prompt on its first iteration)
156
- this.cachedBasePrompt = null;
157
- this.memoryDirtyFlag = false;
158
- // Extract options with defaults
159
- const { executionContext, fileData, imageData, signal, stream, taskId } = options ?? {};
160
- // Get filtered tools based on command type (e.g., only read-only tools for 'query')
161
- const toolSet = this.toolManager.getToolsForCommand(options?.executionContext?.commandType);
162
- // Create state machine with configured limits (per-invocation overrides via ExecutionContext)
163
- const effectiveMaxIterations = executionContext?.maxIterations ?? this.config.maxIterations;
164
- const maxTimeMs = this.config.timeout ?? 600_000; // 10 min default
165
- const stateMachine = new AgentStateMachine(effectiveMaxIterations, maxTimeMs);
166
- stateMachine.transition(AgentState.EXECUTING);
167
- // Agentic loop with state machine
168
- while (!stateMachine.isTerminal()) {
169
- // Check termination conditions (timeout, max turns)
170
- const terminationReason = stateMachine.shouldTerminate();
171
- if (terminationReason) {
172
- return this.handleTermination(terminationReason, stateMachine, taskId);
173
- }
174
- // Check if aborted via signal
175
- if (signal?.aborted) {
176
- stateMachine.abort();
177
- throw new Error('Operation aborted');
178
- }
179
- try {
180
- // eslint-disable-next-line no-await-in-loop -- Sequential iterations required for agentic loop
181
- const result = await this.executeAgenticIteration({
182
- executionContext,
183
- fileData,
184
- imageData,
185
- iterationCount: stateMachine.getContext().turnCount,
186
- stream,
187
- taskId,
188
- textInput,
189
- tools: toolSet,
190
- });
191
- if (result !== null) {
192
- // Task complete - no tool calls
193
- stateMachine.complete();
194
- return result;
195
- }
196
- // Tool calls were executed, continue loop
197
- stateMachine.incrementTurn();
198
- }
199
- catch (error) {
200
- stateMachine.fail(error);
201
- this.handleLLMError(error, taskId);
202
- }
203
- }
204
- // Should not reach here - state machine should exit via terminal states
205
- throw new Error('Agent loop terminated unexpectedly');
206
- }
207
- /**
208
- * Get all available tools for the agent.
209
- *
210
- * Retrieves the current set of tools that can be used during task execution.
211
- * These tools are passed to the LLM to enable function calling capabilities.
212
- *
213
- * @returns Promise resolving to a map of tool names to their schemas
214
- */
215
- async getAllTools() {
216
- return this.toolManager.getAllTools();
217
- }
218
- /**
219
- * Get the service's runtime configuration.
220
- *
221
- * Returns metadata about the service including:
222
- * - Configured and model-specific token limits
223
- * - Selected LLM model
224
- * - Provider name (always 'byterover')
225
- * - Router type (always 'in-built')
226
- *
227
- * This is useful for introspecting service capabilities and limits
228
- * without needing access to the internal config object.
229
- *
230
- * @returns Service configuration object with model info and constraints
231
- */
232
- getConfig() {
233
- // Get model's actual max tokens from registry
234
- const modelMaxTokens = getMaxInputTokensForModel(this.providerType, this.config.model);
235
- return {
236
- configuredMaxInputTokens: this.config.maxInputTokens,
237
- model: this.config.model,
238
- modelMaxInputTokens: modelMaxTokens,
239
- provider: 'byterover',
240
- router: 'in-built',
241
- };
242
- }
243
- /**
244
- * Get access to the conversation context manager.
245
- *
246
- * Provides access to the ContextManager instance that maintains:
247
- * - Conversation history (messages and responses)
248
- * - Token counting and compression
249
- * - Message formatting for the selected model
250
- *
251
- * Useful for:
252
- * - Inspecting conversation state
253
- * - Retrieving formatted messages
254
- * - Managing context during multi-turn interactions
255
- *
256
- * @returns The ContextManager instance managing conversation state
257
- */
258
- getContextManager() {
259
- return this.contextManager;
260
- }
261
- /**
262
- * Initialize the LLM service by loading persisted history.
263
- * Should be called after construction to restore previous conversation.
264
- *
265
- * @returns True if history was loaded, false otherwise
266
- */
267
- async initialize() {
268
- return this.contextManager.initialize();
269
- }
270
- /**
271
- * Add a parallel tool result to the context.
272
- * Called sequentially after parallel execution to preserve message order.
273
- *
274
- * @param result - Parallel tool result to add
275
- */
276
- async addParallelToolResultToContext(result) {
277
- const { toolCall, toolResult } = result;
278
- if (!toolResult) {
279
- // This shouldn't happen, but handle gracefully
280
- await this.contextManager.addToolResult(toolCall.id, toolCall.function.name, 'Error: No tool result available', {
281
- errorType: 'NO_RESULT',
282
- success: false,
283
- });
284
- return;
285
- }
286
- await this.contextManager.addToolResult(toolCall.id, toolCall.function.name, toolResult.processedOutput.content, {
287
- errorType: toolResult.errorType,
288
- metadata: toolResult.metadata,
289
- success: toolResult.success,
290
- }, toolResult.processedOutput.attachments);
291
- }
292
- /**
293
- * Build generation request for the IContentGenerator.
294
- *
295
- * Converts internal context to the standardized GenerateContentRequest format.
296
- *
297
- * @param options - Request options
298
- * @param options.systemPrompt - System prompt text
299
- * @param options.tools - Available tools for function calling
300
- * @param options.executionContext - Optional execution context
301
- * @returns GenerateContentRequest for the generator
302
- */
303
- buildGenerateContentRequest(options) {
304
- // Get internal messages from context manager
305
- const messages = this.contextManager.getMessages();
306
- // Apply per-invocation overrides from ExecutionContext (e.g., query-optimized config)
307
- const effectiveMaxTokens = options.executionContext?.maxTokens ?? this.config.maxTokens;
308
- const effectiveTemperature = options.executionContext?.temperature ?? this.config.temperature;
309
- return {
310
- config: {
311
- maxTokens: effectiveMaxTokens,
312
- temperature: effectiveTemperature,
313
- },
314
- contents: messages,
315
- executionContext: options.executionContext,
316
- model: this.config.model,
317
- systemPrompt: options.systemPrompt,
318
- taskId: options.taskId ?? '',
319
- tools: options.tools,
320
- };
321
- }
322
- /**
323
- * Call LLM via generator and process the response.
324
- *
325
- * Uses the IContentGenerator interface which already has:
326
- * - Retry logic (via RetryableContentGenerator decorator)
327
- * - Logging (via LoggingContentGenerator decorator)
328
- *
329
- * @param request - Generation request
330
- * @returns Parsed internal message from response
331
- */
332
- async callLLMAndParseResponse(request) {
333
- try {
334
- const response = await this.generator.generateContent(request);
335
- // Convert response to InternalMessage format
336
- const message = {
337
- content: response.content,
338
- role: 'assistant',
339
- toolCalls: response.toolCalls,
340
- };
341
- // Validate the message has content or tool calls
342
- if (!message.content && (!message.toolCalls || message.toolCalls.length === 0)) {
343
- throw new LlmResponseParsingError('Response has neither content nor tool calls', 'byterover', this.config.model);
344
- }
345
- return message;
346
- }
347
- catch (error) {
348
- // Re-throw LLM errors as-is
349
- if (error instanceof LlmResponseParsingError || error instanceof LlmGenerationError) {
350
- throw error;
351
- }
352
- // Wrap other errors
353
- throw new LlmGenerationError(error instanceof Error ? error.message : String(error), 'byterover', this.config.model);
354
- }
355
- }
356
- /**
357
- * Streaming variant of callLLMAndParseResponse that:
358
- * - Uses generateContentStream for real-time chunk delivery
359
- * - Accumulates content and tool calls from chunks
360
- * - Emits llmservice:chunk events for thinking/reasoning chunks
361
- * - Returns complete InternalMessage when stream ends
362
- *
363
- * @param request - Generation request
364
- * @param taskId - Task ID for event emission
365
- * @returns Parsed internal message from accumulated stream
366
- */
367
- async callLLMAndParseResponseStreaming(request, taskId) {
368
- try {
369
- let accumulatedContent = '';
370
- let accumulatedToolCalls = [];
371
- // Stream chunks and accumulate content
372
- for await (const chunk of this.generator.generateContentStream(request)) {
373
- // Emit thinking/reasoning chunks as events for TUI display
374
- if (chunk.type === StreamChunkType.THINKING && chunk.reasoning) {
375
- this.sessionEventBus.emit('llmservice:chunk', {
376
- content: chunk.reasoning,
377
- isComplete: chunk.isComplete,
378
- taskId,
379
- type: 'reasoning', // Convert THINKING to 'reasoning' for TUI compatibility
380
- });
381
- }
382
- // Accumulate text content (skip thinking chunks from accumulated content)
383
- if (chunk.content && chunk.type !== StreamChunkType.THINKING) {
384
- accumulatedContent += chunk.content;
385
- // Emit text chunks for TUI display
386
- this.sessionEventBus.emit('llmservice:chunk', {
387
- content: chunk.content,
388
- isComplete: chunk.isComplete,
389
- taskId,
390
- type: 'text',
391
- });
392
- }
393
- // Accumulate tool calls
394
- if (chunk.toolCalls) {
395
- accumulatedToolCalls = chunk.toolCalls;
396
- }
397
- }
398
- // Convert accumulated response to InternalMessage format
399
- const message = {
400
- content: accumulatedContent || null,
401
- role: 'assistant',
402
- toolCalls: accumulatedToolCalls.length > 0 ? accumulatedToolCalls : undefined,
403
- };
404
- // Validate the message has content or tool calls
405
- if (!message.content && (!message.toolCalls || message.toolCalls.length === 0)) {
406
- throw new LlmResponseParsingError('Response has neither content nor tool calls', 'byterover', this.config.model);
407
- }
408
- return message;
409
- }
410
- catch (error) {
411
- // Re-throw LLM errors as-is
412
- if (error instanceof LlmResponseParsingError || error instanceof LlmGenerationError) {
413
- throw error;
414
- }
415
- // Wrap other errors
416
- throw new LlmGenerationError(error instanceof Error ? error.message : String(error), 'byterover', this.config.model);
417
- }
418
- }
419
- /**
420
- * Check for context overflow and trigger compaction if needed.
421
- * Called after each assistant response and after tool execution batches.
422
- *
423
- * Follows OpenCode's compaction patterns:
424
- * - First tries pruning tool outputs (if overflow > 85%)
425
- * - Then tries full compaction with LLM summary (if overflow > 95%)
426
- *
427
- * @param taskId - Task ID from usecase for billing tracking (passed from caller)
428
- */
429
- async checkAndTriggerCompaction(taskId) {
430
- if (!this.compactionService)
431
- return;
432
- // Calculate current token usage
433
- const messages = this.contextManager.getMessages();
434
- const messagesTokens = messages.reduce((total, msg) => total +
435
- this.generator.estimateTokensSync(typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content)), 0);
436
- // Estimate system prompt tokens (rough estimate since we don't have full context here)
437
- // Using a conservative estimate of 2000 tokens for system prompt
438
- const estimatedSystemPromptTokens = 2000;
439
- const currentTokens = estimatedSystemPromptTokens + messagesTokens;
440
- // Check overflow
441
- const overflowResult = this.compactionService.checkOverflow(currentTokens, this.config.maxInputTokens);
442
- if (!overflowResult.isOverflow)
443
- return;
444
- // Emit context overflow event
445
- const utilizationPercent = Math.round((currentTokens / this.config.maxInputTokens) * 100);
446
- this.sessionEventBus.emit('llmservice:contextOverflow', {
447
- currentTokens,
448
- maxTokens: this.config.maxInputTokens,
449
- taskId: taskId || undefined,
450
- utilizationPercent,
451
- });
452
- if (overflowResult.recommendation === 'prune') {
453
- // Try pruning tool outputs first
454
- const pruneResult = await this.compactionService.pruneToolOutputs(this.sessionId);
455
- // Emit context pruned event
456
- if (pruneResult.compactedCount > 0) {
457
- this.sessionEventBus.emit('llmservice:contextPruned', {
458
- pruneCount: pruneResult.compactedCount,
459
- reason: 'overflow',
460
- taskId: taskId || undefined,
461
- tokensSaved: pruneResult.tokensSaved,
462
- });
463
- // Also emit warning for backward compatibility
464
- this.sessionEventBus.emit('llmservice:warning', {
465
- message: `Context compaction: pruned ${pruneResult.compactedCount} old tool outputs (~${pruneResult.tokensSaved} tokens)`,
466
- taskId: taskId || undefined,
467
- });
468
- }
469
- }
470
- else if (overflowResult.recommendation === 'compact') {
471
- const originalTokens = currentTokens;
472
- // Full compaction needed - generate LLM summary
473
- // Use the same taskId from caller for billing tracking
474
- const summary = await this.compactionService.generateSummary(this.generator, messages, taskId, this.config.model);
475
- await this.compactionService.createCompactionBoundary(this.sessionId, summary);
476
- // Emit context compressed event
477
- // Estimate compressed tokens (summary is much smaller than original)
478
- const compressedTokens = this.generator.estimateTokensSync(summary);
479
- this.sessionEventBus.emit('llmservice:contextCompressed', {
480
- compressedTokens,
481
- originalTokens,
482
- strategy: 'summary',
483
- taskId: taskId || undefined,
484
- });
485
- // Also emit warning for backward compatibility
486
- this.sessionEventBus.emit('llmservice:warning', {
487
- message: 'Context compaction: created summary boundary for conversation history',
488
- taskId: taskId || undefined,
489
- });
490
- }
491
- }
492
- /**
493
- * Detect provider type from model name using the LLM registry.
494
- *
495
- * Uses the centralized registry to determine provider from model name.
496
- * Falls back to string prefix matching if model is not in registry.
497
- *
498
- * @param model - Model identifier
499
- * @returns Provider type ('claude' or 'gemini')
500
- */
501
- detectProviderType(model) {
502
- // Use registry to detect provider
503
- const registryProvider = getProviderFromModel(model);
504
- if (registryProvider === 'claude' || registryProvider === 'gemini') {
505
- return registryProvider;
506
- }
507
- // Fallback to string prefix matching for unknown models
508
- return model.toLowerCase().startsWith('claude') ? 'claude' : 'gemini';
509
- }
510
- /**
511
- * Determine which reflection prompt to add based on hierarchical priority.
512
- * Only the highest priority eligible reflection is returned.
513
- *
514
- * Priority (highest to lowest):
515
- * 1. final_iteration - query only, at the last iteration
516
- * 2. near_max_iterations - general, at 80% threshold
517
- * 3. mid_point_check - query only, at 50% threshold
518
- * 4. completion_check - general, periodic every 3 iterations
519
- *
520
- * @param iterationCount - Current iteration count (0-indexed)
521
- * @param commandType - Command type ('query' or 'curate')
522
- * @returns Reflection type to add, or undefined if none eligible
523
- */
524
- determineReflectionType(iterationCount, commandType) {
525
- const isQuery = commandType === 'query';
526
- const isLastIteration = iterationCount === this.config.maxIterations - 1;
527
- const midPoint = Math.floor(this.config.maxIterations / 2);
528
- const isAtMidPoint = iterationCount === midPoint;
529
- const isNearMax = iterationCount >= Math.floor(this.config.maxIterations * 0.8);
530
- const isPeriodicCheck = iterationCount > 0 && iterationCount % 3 === 0;
531
- // Priority 1: final_iteration (query only, last iteration) - highest priority
532
- if (isQuery && isLastIteration) {
533
- return 'final_iteration';
534
- }
535
- // Priority 2: near_max_iterations (general, 80% threshold)
536
- if (isNearMax) {
537
- return 'near_max_iterations';
538
- }
539
- // Priority 3: mid_point_check (query only, 50% threshold)
540
- if (isQuery && isAtMidPoint) {
541
- return 'mid_point_check';
542
- }
543
- // Priority 4: completion_check (general, periodic every 3 iterations) - lowest priority
544
- if (isPeriodicCheck) {
545
- return 'completion_check';
546
- }
547
- return undefined;
548
- }
549
- /**
550
- * Execute a single iteration of the agentic loop.
551
- *
552
- * @param options - Iteration options
553
- * @param options.executionContext - Optional execution context
554
- * @param options.fileData - Optional file data (only used on first iteration)
555
- * @param options.imageData - Optional image data (only used on first iteration)
556
- * @param options.iterationCount - Current iteration number
557
- * @param options.stream - Whether to stream response and emit thinking chunks
558
- * @param options.taskId - Task ID from usecase for billing tracking
559
- * @param options.textInput - User input text (only used on first iteration)
560
- * @param options.tools - Available tools for this iteration
561
- * @returns Final response string if complete, null if more iterations needed
562
- */
563
- async executeAgenticIteration(options) {
564
- const { executionContext, fileData, imageData, iterationCount, stream, taskId, textInput, tools } = options;
565
- // Build system prompt using SystemPromptManager (before compression for correct token accounting)
566
- // Use filtered tool names based on command type (e.g., only read-only tools for 'query')
567
- const availableTools = this.toolManager.getToolNamesForCommand(executionContext?.commandType);
568
- const markersSet = this.toolManager.getAvailableMarkers();
569
- // Convert Set to Record for prompt factory
570
- const availableMarkers = {};
571
- for (const marker of markersSet) {
572
- availableMarkers[marker] = marker;
573
- }
574
- // Build base system prompt (cached across iterations within the same task)
575
- const needsFullRebuild = iterationCount === 0 || this.cachedBasePrompt === null || this.memoryDirtyFlag;
576
- let basePrompt;
577
- if (needsFullRebuild) {
578
- // Full rebuild: first iteration, no cache, or memory was modified by tools
579
- const environmentContext = await this.environmentBuilder.build({
580
- includeBrvStructure: true,
581
- includeFileTree: true,
582
- maxFileTreeDepth: 3,
583
- maxFileTreeEntries: 100,
584
- workingDirectory: this.workingDirectory,
585
- });
586
- basePrompt = await this.systemPromptManager.build({
587
- availableMarkers,
588
- availableTools,
589
- commandType: executionContext?.commandType,
590
- conversationMetadata: executionContext?.conversationMetadata,
591
- environmentContext,
592
- fileReferenceInstructions: executionContext?.fileReferenceInstructions,
593
- memoryManager: this.memoryManager,
594
- });
595
- this.cachedBasePrompt = basePrompt;
596
- this.memoryDirtyFlag = false;
597
- }
598
- else {
599
- // Cache hit: reuse base prompt, only refresh the DateTime section
600
- basePrompt = this.refreshDateTime(this.cachedBasePrompt);
601
- }
602
- let systemPrompt = basePrompt;
603
- // Determine which reflection prompt to add (only highest priority is chosen)
604
- const reflectionType = this.determineReflectionType(iterationCount, executionContext?.commandType);
605
- // Add reflection prompt if eligible (hierarchical: only one reflection per iteration)
606
- if (reflectionType) {
607
- const reflectionPrompt = this.systemPromptManager.buildReflectionPrompt({
608
- currentIteration: iterationCount + 1,
609
- maxIterations: this.config.maxIterations,
610
- type: reflectionType,
611
- });
612
- systemPrompt = systemPrompt + '\n\n' + reflectionPrompt;
613
- }
614
- // Verbose debug: Show complete system prompt
615
- if (this.config.verbose) {
616
- this.logger.debug('System prompt details', {
617
- first500Chars: systemPrompt.slice(0, 500),
618
- iteration: iterationCount + 1,
619
- last500Chars: systemPrompt.slice(-500),
620
- length: systemPrompt.length,
621
- lines: systemPrompt.split('\n').length,
622
- reflectionType,
623
- });
624
- }
625
- // Final iteration optimization for query: strip tools (reflection already added above)
626
- let toolsForThisIteration = tools;
627
- if (executionContext?.commandType === 'query' && iterationCount === this.config.maxIterations - 1) {
628
- toolsForThisIteration = {}; // Empty toolset forces text response
629
- }
630
- // Get token count for logging (using system prompt for token accounting)
631
- const systemPromptTokens = this.generator.estimateTokensSync(systemPrompt);
632
- // Add user message and compress context within mutex lock
633
- return this.mutex.withLock(async () => {
634
- // Add user message to context only on the first iteration
635
- if (iterationCount === 0) {
636
- await this.contextManager.addUserMessage(textInput, imageData, fileData);
637
- }
638
- const messages = this.contextManager.getMessages();
639
- const messageTokenCounts = messages.map((msg) => this.generator.estimateTokensSync(typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content)));
640
- const maxMessageTokens = this.config.maxInputTokens - systemPromptTokens;
641
- // Target utilization to leave headroom for response
642
- const targetMessageTokens = Math.floor(maxMessageTokens * TARGET_MESSAGE_TOKEN_UTILIZATION);
643
- this.contextManager.compressMessage(targetMessageTokens, messageTokenCounts);
644
- // Build generation request
645
- const request = this.buildGenerateContentRequest({
646
- executionContext,
647
- systemPrompt,
648
- taskId,
649
- tools: toolsForThisIteration,
650
- });
651
- // Call LLM via generator (retry + logging handled by decorators)
652
- // Use streaming variant if enabled to emit thinking/reasoning chunks
653
- const lastMessage = stream
654
- ? await this.callLLMAndParseResponseStreaming(request, taskId)
655
- : await this.callLLMAndParseResponse(request);
656
- // Check if there are tool calls
657
- if (!lastMessage.toolCalls || lastMessage.toolCalls.length === 0) {
658
- const response = await this.handleFinalResponse(lastMessage, taskId);
659
- // Auto-compaction check after assistant response
660
- await this.checkAndTriggerCompaction(taskId ?? '');
661
- return response;
662
- }
663
- // Has tool calls - handle them (pass taskId for subagent billing)
664
- await this.handleToolCalls(lastMessage, taskId);
665
- // Auto-compaction check after tool execution batch
666
- await this.checkAndTriggerCompaction(taskId ?? '');
667
- return null;
668
- });
669
- }
670
- /**
671
- * Execute a single tool call in parallel (without adding to context).
672
- * Returns all information needed to add the result to context later.
673
- *
674
- * @param toolCall - Tool call to execute
675
- * @param taskId - Task ID from usecase for billing tracking (passed to subagents)
676
- * @returns Parallel tool result with all execution data
677
- */
678
- async executeToolCallParallel(toolCall, taskId) {
679
- const toolName = toolCall.function.name;
680
- const toolArgs = JSON.parse(toolCall.function.arguments);
681
- try {
682
- // Check for loops before execution (mutex-protected)
683
- const loopResult = await this.loopDetector.recordAndCheck(toolName, toolArgs);
684
- if (loopResult.isLoop) {
685
- // Emit dedicated doom loop event for observability
686
- this.sessionEventBus.emit('llmservice:doomLoopDetected', {
687
- args: toolArgs,
688
- loopType: loopResult.loopType,
689
- repeatCount: loopResult.repeatCount ?? 0,
690
- taskId: taskId || undefined,
691
- toolName,
692
- });
693
- // Also emit warning event for backward compatibility
694
- this.sessionEventBus.emit('llmservice:warning', {
695
- message: `Doom loop detected: ${loopResult.loopType} - tool "${toolName}" repeated ${loopResult.repeatCount} times. Auto-denying to prevent infinite loop.`,
696
- taskId: taskId || undefined,
697
- });
698
- return {
699
- toolCall,
700
- toolResult: {
701
- errorType: 'LOOP_DETECTED',
702
- metadata: {
703
- loopType: loopResult.loopType,
704
- repeatCount: loopResult.repeatCount,
705
- },
706
- processedOutput: {
707
- content: `⚠️ DOOM LOOP DETECTED: ${loopResult.suggestion}\n\nThe tool call has been automatically rejected to prevent an infinite loop. Please try a different approach to accomplish your goal.`,
708
- },
709
- success: false,
710
- },
711
- };
712
- }
713
- // Emit tool call event
714
- this.sessionEventBus.emit('llmservice:toolCall', {
715
- args: toolArgs,
716
- callId: toolCall.id,
717
- taskId: taskId || undefined,
718
- toolName,
719
- });
720
- // Create metadata callback for streaming tool output
721
- const metadataCallback = this.metadataHandler.createCallback(toolCall.id, toolName);
722
- // Execute tool via ToolManager (returns structured result)
723
- // Pass taskId in context for subagent billing tracking
724
- const result = await this.toolManager.executeTool(toolName, toolArgs, this.sessionId, {
725
- metadata: metadataCallback,
726
- taskId,
727
- });
728
- // Process output (truncation and file saving if needed)
729
- const processedOutput = await this.outputProcessor.processStructuredOutput(toolName, result.content);
730
- // Emit truncation event if output was truncated
731
- if (processedOutput.metadata?.truncated) {
732
- this.sessionEventBus.emit('llmservice:outputTruncated', {
733
- originalLength: processedOutput.metadata.originalLength,
734
- savedToFile: processedOutput.metadata.savedToFile,
735
- taskId: taskId || undefined,
736
- toolName,
737
- });
738
- }
739
- // Emit tool result event with success/error info
740
- this.sessionEventBus.emit('llmservice:toolResult', {
741
- callId: toolCall.id,
742
- error: result.errorMessage,
743
- errorType: result.errorType,
744
- metadata: {
745
- ...result.metadata,
746
- ...processedOutput.metadata,
747
- },
748
- result: processedOutput.content,
749
- success: result.success,
750
- taskId: taskId || undefined,
751
- toolName,
752
- });
753
- return {
754
- toolCall,
755
- toolResult: {
756
- errorType: result.errorType,
757
- metadata: {
758
- ...result.metadata,
759
- ...processedOutput.metadata,
760
- },
761
- processedOutput,
762
- success: result.success,
763
- },
764
- };
765
- }
766
- catch (error) {
767
- // Catch any unexpected errors during execution
768
- const errorMessage = getErrorMessage(error);
769
- this.logger.error('Error executing tool in parallel', { error, toolCallId: toolCall.id, toolName });
770
- return {
771
- error: errorMessage,
772
- toolCall,
773
- toolResult: {
774
- errorType: 'EXECUTION_ERROR',
775
- metadata: {},
776
- processedOutput: { content: `Error executing tool: ${errorMessage}` },
777
- success: false,
778
- },
779
- };
780
- }
781
- }
782
- /**
783
- * Extract text content from an internal message.
784
- *
785
- * @param message - Internal message
786
- * @returns Text content as string
787
- */
788
- extractTextContent(message) {
789
- if (typeof message.content === 'string') {
790
- return message.content;
791
- }
792
- if (Array.isArray(message.content)) {
793
- return message.content
794
- .filter((part) => part.type === 'text')
795
- .map((part) => (part.type === 'text' ? part.text : ''))
796
- .join('');
797
- }
798
- return '';
799
- }
800
- /**
801
- * Extract partial response from conversation history when max iterations reached.
802
- * Returns the last assistant message or accumulated tool outputs.
803
- *
804
- * @returns Partial response string
805
- */
806
- async getPartialResponse() {
807
- const history = this.contextManager.getMessages();
808
- // Find last assistant message
809
- for (let i = history.length - 1; i >= 0; i--) {
810
- const msg = history[i];
811
- if (msg && msg.role === 'assistant') {
812
- return this.extractTextContent(msg);
813
- }
814
- }
815
- return '';
816
- }
817
- /**
818
- * Handle final response when there are no tool calls.
819
- *
820
- * @param lastMessage - Last message from LLM
821
- * @param taskId - Optional task ID for concurrent task isolation
822
- * @returns Final response content
823
- */
824
- async handleFinalResponse(lastMessage, taskId) {
825
- const content = this.extractTextContent(lastMessage);
826
- // Emit response event
827
- this.sessionEventBus.emit('llmservice:response', {
828
- content,
829
- model: this.config.model,
830
- provider: 'byterover',
831
- taskId: taskId || undefined,
832
- });
833
- // Add assistant message to context
834
- await this.contextManager.addAssistantMessage(content);
835
- return content;
836
- }
837
- /**
838
- * Handle LLM errors and re-throw or wrap appropriately.
839
- *
840
- * @param error - Error to handle
841
- * @param taskId - Optional task ID for concurrent task isolation
842
- */
843
- handleLLMError(error, taskId) {
844
- // Emit error event
845
- const errorMessage = error instanceof Error ? error.message : String(error);
846
- this.sessionEventBus.emit('llmservice:error', {
847
- error: errorMessage,
848
- taskId: taskId || undefined,
849
- });
850
- // Re-throw LLM errors as-is
851
- if (error instanceof LlmResponseParsingError ||
852
- error instanceof LlmGenerationError ||
853
- error instanceof LlmMaxIterationsError) {
854
- throw error;
855
- }
856
- // Wrap other errors
857
- if (error && typeof error === 'object' && 'message' in error) {
858
- throw new LlmGenerationError(getErrorMessage(error), 'byterover', this.config.model);
859
- }
860
- throw new LlmGenerationError(String(error), 'byterover', this.config.model);
861
- }
862
- /**
863
- * Handle agent termination due to timeout or max turns.
864
- *
865
- * Emits appropriate events and returns a partial response.
866
- *
867
- * @param reason - Why the agent is terminating
868
- * @param stateMachine - The state machine for context
869
- * @param taskId - Optional task ID for concurrent task isolation
870
- * @returns Partial response or fallback message
871
- */
872
- async handleTermination(reason, stateMachine, taskId) {
873
- const context = stateMachine.getContext();
874
- const durationMs = Date.now() - context.startTime.getTime();
875
- this.logger.warn('Agent execution terminated', {
876
- durationMs,
877
- reason,
878
- toolCallsExecuted: context.toolCallsExecuted,
879
- turnCount: context.turnCount,
880
- });
881
- // Emit termination event
882
- this.sessionEventBus.emit('llmservice:warning', {
883
- message: `Agent terminated: ${reason} after ${context.turnCount} turns`,
884
- model: this.config.model,
885
- provider: 'byterover',
886
- taskId: taskId || undefined,
887
- });
888
- // Get accumulated response from context
889
- const partialResponse = await this.getPartialResponse();
890
- this.sessionEventBus.emit('llmservice:response', {
891
- content: partialResponse,
892
- model: this.config.model,
893
- partial: true,
894
- provider: 'byterover',
895
- taskId: taskId || undefined,
896
- });
897
- if (reason === TerminationReason.MAX_TURNS) {
898
- return (partialResponse ||
899
- 'Maximum iterations reached without completing the task. Please try breaking down the task into smaller steps.');
900
- }
901
- if (reason === TerminationReason.TIMEOUT) {
902
- return partialResponse || 'Execution timed out. Please try a simpler task or increase the timeout.';
903
- }
904
- return partialResponse || 'Agent execution terminated unexpectedly.';
905
- }
906
- /**
907
- * Handle thoughts from LLM response (Gemini only).
908
- *
909
- * Extracts and emits thought events if present.
910
- *
911
- * @param message - Message potentially containing thoughts
912
- * @param taskId - Optional task ID for concurrent task isolation
913
- */
914
- handleThoughts(message, taskId) {
915
- // Only process thoughts for Gemini models
916
- if (this.providerType !== 'gemini') {
917
- return;
918
- }
919
- // Check if message has thought content
920
- if (message.thought) {
921
- // Parse thought if not already parsed
922
- if (!message.thoughtSummary) {
923
- message.thoughtSummary = ThoughtParser.parse(message.thought);
924
- }
925
- // Emit thought event
926
- this.sessionEventBus.emit('llmservice:thought', {
927
- description: message.thoughtSummary.description,
928
- subject: message.thoughtSummary.subject,
929
- taskId: taskId || undefined,
930
- });
931
- }
932
- }
933
- /**
934
- * Handle tool calls from LLM response.
935
- * Uses tool parts with state machine: pending → running → completed/error.
936
- * Executes tools in parallel for performance, but updates state in order.
937
- *
938
- * @param lastMessage - Last message containing tool calls
939
- * @param taskId - Task ID from usecase for billing tracking (passed to subagents)
940
- */
941
- async handleToolCalls(lastMessage, taskId) {
942
- if (!lastMessage.toolCalls || lastMessage.toolCalls.length === 0) {
943
- return;
944
- }
945
- // Emit thought events if present
946
- this.handleThoughts(lastMessage, taskId);
947
- // Has tool calls - add assistant message with tool calls
948
- const assistantContent = this.extractTextContent(lastMessage);
949
- await this.contextManager.addAssistantMessage(assistantContent, lastMessage.toolCalls);
950
- // Step 1: Create pending tool parts for all tool calls
951
- for (const toolCall of lastMessage.toolCalls) {
952
- const toolArgs = JSON.parse(toolCall.function.arguments);
953
- this.contextManager.addToolCallPending(toolCall.id, toolCall.function.name, toolArgs);
954
- }
955
- // Step 2: Transition all to running state
956
- const startTime = Date.now();
957
- for (const toolCall of lastMessage.toolCalls) {
958
- const runningState = {
959
- input: JSON.parse(toolCall.function.arguments),
960
- startedAt: startTime,
961
- status: 'running',
962
- };
963
- this.contextManager.updateToolCallState(toolCall.id, runningState);
964
- }
965
- // Check if any memory-modifying tools are being called (invalidates cached system prompt)
966
- const memoryModifyingTools = new Set(['delete_memory', 'edit_memory', 'write_memory']);
967
- if (lastMessage.toolCalls.some((tc) => memoryModifyingTools.has(tc.function.name))) {
968
- this.memoryDirtyFlag = true;
969
- }
970
- // Step 3: Execute all tool calls in parallel (pass taskId for subagent billing)
971
- const parallelResults = await Promise.allSettled(lastMessage.toolCalls.map((toolCall) => this.executeToolCallParallel(toolCall, taskId)));
972
- // Step 4: Update tool part states with results (in order)
973
- const endTime = Date.now();
974
- // eslint-disable-next-line unicorn/no-for-loop -- Need index to access both parallelResults and toolCalls in parallel
975
- for (let i = 0; i < parallelResults.length; i++) {
976
- const settledResult = parallelResults[i];
977
- const toolCall = lastMessage.toolCalls[i];
978
- const toolArgs = JSON.parse(toolCall.function.arguments);
979
- if (settledResult.status === 'fulfilled') {
980
- const result = settledResult.value;
981
- if (result.toolResult?.success) {
982
- // Transition to completed state
983
- const completedState = {
984
- attachments: result.toolResult.processedOutput.attachments,
985
- input: toolArgs,
986
- metadata: result.toolResult.metadata,
987
- output: result.toolResult.processedOutput.content,
988
- status: 'completed',
989
- time: { end: endTime, start: startTime },
990
- title: result.toolResult.processedOutput.title,
991
- };
992
- this.contextManager.updateToolCallState(toolCall.id, completedState);
993
- }
994
- else {
995
- // Transition to error state
996
- const errorState = {
997
- error: result.toolResult?.processedOutput.content ?? result.error ?? 'Unknown error',
998
- input: toolArgs,
999
- status: 'error',
1000
- time: { end: endTime, start: startTime },
1001
- };
1002
- this.contextManager.updateToolCallState(toolCall.id, errorState);
1003
- }
1004
- // Also add to context as tool result message (for backward compatibility)
1005
- // eslint-disable-next-line no-await-in-loop -- Must add results in order
1006
- await this.addParallelToolResultToContext(result);
1007
- }
1008
- else {
1009
- // Handle unexpected Promise rejection
1010
- const errorMessage = getErrorMessage(settledResult.reason);
1011
- this.logger.error('Unexpected error in parallel tool execution', {
1012
- error: settledResult.reason,
1013
- toolCallId: toolCall.id,
1014
- toolName: toolCall.function.name,
1015
- });
1016
- // Transition to error state
1017
- const errorState = {
1018
- error: errorMessage,
1019
- input: toolArgs,
1020
- status: 'error',
1021
- time: { end: endTime, start: startTime },
1022
- };
1023
- this.contextManager.updateToolCallState(toolCall.id, errorState);
1024
- // Also add to context as tool result message (for backward compatibility)
1025
- // eslint-disable-next-line no-await-in-loop -- Must add results in order
1026
- await this.contextManager.addToolResult(toolCall.id, toolCall.function.name, `Error: ${errorMessage}`, {
1027
- errorType: 'UNEXPECTED_ERROR',
1028
- success: false,
1029
- });
1030
- }
1031
- }
1032
- }
1033
- /**
1034
- * Replace the DateTime section in a cached system prompt with a fresh timestamp.
1035
- * DateTimeContributor wraps its output in <dateTime>...</dateTime> XML tags,
1036
- * enabling reliable regex replacement without rebuilding the entire prompt.
1037
- *
1038
- * @param cachedPrompt - Previously cached system prompt
1039
- * @returns Updated prompt with fresh DateTime
1040
- */
1041
- refreshDateTime(cachedPrompt) {
1042
- const freshDateTime = `<dateTime>Current date and time: ${new Date().toISOString()}</dateTime>`;
1043
- return cachedPrompt.replace(/<dateTime>[\S\s]*?<\/dateTime>/, freshDateTime);
1044
- }
1045
- /**
1046
- * Validate LLM configuration using Zod schema.
1047
- *
1048
- * Performs validation against the centralized LLM config schema.
1049
- * Logs warnings for invalid configurations but doesn't throw to maintain
1050
- * backward compatibility with existing code.
1051
- *
1052
- * @param model - Model name to validate
1053
- * @param maxInputTokens - Optional max input tokens to validate
1054
- */
1055
- validateConfig(model, maxInputTokens) {
1056
- const result = safeParseLLMConfig({
1057
- maxInputTokens,
1058
- maxIterations: this.config?.maxIterations ?? 50,
1059
- model,
1060
- provider: this.providerType,
1061
- });
1062
- if (!result.success) {
1063
- // Log validation warnings but don't throw (backward compatibility)
1064
- const issues = result.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`).join('; ');
1065
- this.logger.warn('LLM config validation warning', {
1066
- issues,
1067
- model,
1068
- provider: this.providerType,
1069
- });
1070
- // Also check if model is valid in registry
1071
- if (!isValidProviderModel(this.providerType, model)) {
1072
- this.logger.info('Model not in registry, using fallback defaults', {
1073
- model,
1074
- provider: this.providerType,
1075
- });
1076
- }
1077
- }
1078
- }
1079
- }