@didim365/agent-cli-core 0.1.0 → 0.1.2

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 (1076) hide show
  1. package/package.json +6 -2
  2. package/dist/docs/00_project/ai_adapter/01-overview.md +0 -172
  3. package/dist/docs/00_project/ai_adapter/02-architecture.md +0 -448
  4. package/dist/docs/00_project/ai_adapter/03-technical-design.md +0 -1470
  5. package/dist/docs/00_project/ai_adapter/04-integration-design.md +0 -1934
  6. package/dist/docs/00_project/ai_adapter/05-implementation-plan.md +0 -336
  7. package/dist/docs/00_project/ai_adapter/06-didiaistudio-plan.md +0 -559
  8. package/dist/docs/00_project/ai_adapter/README.md +0 -145
  9. package/dist/docs/00_project/ai_adapter/agent_service_openapi.json +0 -1
  10. package/dist/docs/00_project/ai_adapter/didimStudi-AISTUDIO /341/204/213/341/205/254/341/204/207/341/205/256 /341/204/211/341/205/245/341/204/207/341/205/265/341/204/211/341/205/263 /341/204/221/341/205/263/341/206/257/341/204/205/341/205/251/341/204/213/341/205/256 /341/204/213/341/205/247/341/206/253/341/204/200/341/205/247/341/206/257 /341/204/207/341/205/241/341/206/274/341/204/211/341/205/265/341/206/250-100226-093925.pdf +0 -0
  11. package/dist/docs/00_project/ai_adapter/event-mapping-matrix.md +0 -148
  12. package/dist/docs/00_project/ai_adapter/migration-plan.md +0 -205
  13. package/dist/docs/00_project/ai_adapter/template/00_vibecoding_workflow.md +0 -627
  14. package/dist/docs/00_project/ai_adapter/template/01_todolist_performance_template.md +0 -436
  15. package/dist/docs/00_project/ai_adapter/template/02_code_review_template.md +0 -248
  16. package/dist/docs/00_project/ai_adapter/template/03_work_result_report_template.md +0 -133
  17. package/dist/docs/00_project/ai_adapter/template/100_Python_Performance_Guide.md +0 -472
  18. package/dist/docs/00_project/ai_adapter/template/99_TDD_plan.md +0 -123
  19. package/dist/docs/00_project/ai_adapter/todolist/00_master_implementation_plan.md +0 -433
  20. package/dist/docs/00_project/ai_adapter/todolist/phase1_foundation_todolist.md +0 -726
  21. package/dist/docs/00_project/ai_adapter/todolist/phase2_core_refactoring_todolist.md +0 -974
  22. package/dist/docs/00_project/ai_adapter/todolist/phase3_handoff.md +0 -203
  23. package/dist/docs/00_project/ai_adapter/todolist/phase3_provider_extension_todolist.md +0 -1382
  24. package/dist/docs/00_project/ai_adapter/utility-migration.md +0 -237
  25. package/dist/docs/00_project/ai_adapter/working_history/.gitkeep +0 -0
  26. package/dist/docs/00_project/ai_adapter/working_history/Phase1_M1.0_/354/275/224/353/223/234/354/235/270/353/262/244/355/206/240/353/246/254_20260201.md +0 -197
  27. package/dist/docs/00_project/ai_adapter/working_history/Phase1_M1.1_/355/203/200/354/236/205/354/204/244/352/263/204_20260201.md +0 -185
  28. package/dist/docs/00_project/ai_adapter/working_history/Phase1_M1.2_Adapter/354/235/270/355/224/204/353/235/274_20260203.md +0 -378
  29. package/dist/docs/00_project/ai_adapter/working_history/Phase1_M1.3_Provider/354/204/240/355/203/235_20260206.md +0 -269
  30. package/dist/docs/00_project/ai_adapter/working_history/Phase1_M1.4_/354/234/240/355/213/270/353/246/254/355/213/260/353/247/210/354/235/264/352/267/270/353/240/210/354/235/264/354/205/230_20260206.md +0 -86
  31. package/dist/docs/00_project/ai_adapter/working_history/Phase2_ETC_/354/227/260/352/270/260/354/236/221/354/227/205/354/240/225/353/246/254_20260208.md +0 -157
  32. package/dist/docs/00_project/ai_adapter/working_history/Phase2_M2.0_/353/224/224/353/240/211/355/206/240/353/246/254/354/236/254/352/265/254/354/204/261_20260207.md +0 -107
  33. package/dist/docs/00_project/ai_adapter/working_history/Phase2_M2.1_ContentGenerator/354/235/270/355/204/260/355/216/230/354/235/264/354/212/244/354/236/254/354/240/225/354/235/230_20260207.md +0 -630
  34. package/dist/docs/00_project/ai_adapter/working_history/Phase2_M2.2_EventMapper/352/265/254/355/230/204_20260207.md +0 -372
  35. package/dist/docs/00_project/ai_adapter/working_history/Phase2_M2.3_GeminiAdapter/352/265/254/355/230/204_20260208.md +0 -205
  36. package/dist/docs/00_project/ai_adapter/working_history/Phase2_M2.4_ModelConfigService/355/230/270/355/231/230/353/240/210/354/235/264/354/226/264_20260208.md +0 -275
  37. package/dist/docs/00_project/ai_adapter/working_history/Phase2_M2.5_/354/234/240/355/213/270/353/246/254/355/213/260/353/240/210/354/235/264/354/226/264/353/246/254/355/214/251/355/206/240/353/247/201_20260208.md +0 -239
  38. package/dist/docs/00_project/ai_adapter/working_history/Phase2_M2.6_/353/235/274/354/232/260/355/214/205/353/240/210/354/235/264/354/226/264/355/203/200/354/236/205/353/217/205/353/246/275/355/231/224_20260208.md +0 -228
  39. package/dist/docs/00_project/ai_adapter/working_history/Phase3_ETC_/352/270/260/353/263/270/354/273/250/355/205/215/354/212/244/355/212/270/355/214/214/354/235/274/353/252/205AGENTS/354/240/204/355/231/230_20260211.md +0 -470
  40. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.0.1_Gemini/354/240/204/354/232/251/355/214/214/354/235/274/353/254/274/353/246/254/354/240/201/354/235/264/353/217/231_20260209.md +0 -271
  41. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.0.2_messageInspectors/353/247/210/354/235/264/352/267/270/353/240/210/354/235/264/354/205/230_20260209.md +0 -330
  42. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.0.3_/355/205/224/353/240/210/353/251/224/355/212/270/353/246/254Agent/353/217/205/353/246/275/355/231/224_20260209.md +0 -251
  43. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.0.4_/353/263/200/355/231/230/353/270/214/353/246/277/354/247/200/354/240/225/353/246/254_20260209.md +0 -136
  44. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.0.5_/353/237/260/355/203/200/354/236/204/354/213/244/355/226/211/352/262/275/353/241/234/354/227/260/352/262/260_20260209.md +0 -232
  45. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.1.0_Claude/354/202/254/354/240/204/354/244/200/353/271/204_20260209.md +0 -191
  46. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.1.1_ClaudeAdapter/352/265/254/355/230/204_20260209.md +0 -225
  47. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.1.2_ClaudeConverter/352/263/240/353/217/204/355/231/224_20260209.md +0 -171
  48. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.1.3_ClaudeStreamError/352/263/240/353/217/204/355/231/224_20260209.md +0 -198
  49. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.1.4_ClaudeErrorMapping_20260209.md +0 -98
  50. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.2.A_OpenAIAdapterCore_20260210.md +0 -264
  51. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.2.B_OpenAIStreamConverter_20260210.md +0 -204
  52. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.3.2_/353/252/250/353/215/270/355/205/234/355/224/214/353/246/277/355/233/205/353/263/264/354/231/204_20260211.md +0 -106
  53. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.3_OpenAICompatibleAdapter_20260211.md +0 -251
  54. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.4.2_E2E/355/205/214/354/212/244/355/212/270/354/213/234/353/202/230/353/246/254/354/230/244_20260210.md +0 -264
  55. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.4.3_/354/204/261/353/212/245/355/232/214/352/267/200/355/205/214/354/212/244/355/212/270_20260211.md +0 -176
  56. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.4.5_/354/225/210/354/240/225/355/231/224/354/236/221/354/227/205_20260211.md +0 -204
  57. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.4.A_CLI/355/206/265/355/225/251_3Provider/355/206/265/355/225/251/355/205/214/354/212/244/355/212/270_20260210.md +0 -316
  58. package/dist/docs/00_project/ai_adapter/working_history/Phase3_M3.4.A_UI/354/203/201/355/203/234/353/260/224/354/210/230/354/240/225_20260210.md +0 -262
  59. package/dist/docs/00_project/ai_adapter/working_history/phase2_tradeoff_EventType/354/240/204/355/231/230_20260208.md +0 -286
  60. package/dist/docs/00_project/white_labeling/template/00_vibecoding_workflow.md +0 -627
  61. package/dist/docs/00_project/white_labeling/template/01_todolist_performance_template.md +0 -400
  62. package/dist/docs/00_project/white_labeling/template/02_code_review_template.md +0 -248
  63. package/dist/docs/00_project/white_labeling/template/03_work_result_report_template.md +0 -133
  64. package/dist/docs/00_project/white_labeling/template/100_Python_Performance_Guide.md +0 -472
  65. package/dist/docs/00_project/white_labeling/template/99_TDD_plan.md +0 -123
  66. package/dist/docs/00_project/white_labeling/todolist/Phase_CLI/355/214/250/355/202/244/354/247/200/353/252/205/353/263/200/352/262/275_todolist.md +0 -431
  67. package/dist/docs/00_project/white_labeling/working_history/Phase_CLI/355/214/250/355/202/244/354/247/200/353/252/205/353/263/200/352/262/275_20260214.md +0 -238
  68. package/dist/docs/00_project/white_labeling//354/225/261/352/265/254/354/241/260.md +0 -310
  69. package/dist/docs/CONTRIBUTING.md +0 -554
  70. package/dist/docs/ai_adapter/01-overview.md +0 -155
  71. package/dist/docs/ai_adapter/02-architecture.md +0 -452
  72. package/dist/docs/ai_adapter/03-technical-design.md +0 -1470
  73. package/dist/docs/ai_adapter/04-integration-design.md +0 -1904
  74. package/dist/docs/ai_adapter/05-implementation-plan.md +0 -312
  75. package/dist/docs/ai_adapter/06-didiaistudio-plan.md +0 -559
  76. package/dist/docs/ai_adapter/README.md +0 -118
  77. package/dist/docs/ai_adapter/agent_service_openapi.json +0 -1
  78. package/dist/docs/ai_adapter/didimStudi-AISTUDIO /341/204/213/341/205/254/341/204/207/341/205/256 /341/204/211/341/205/245/341/204/207/341/205/265/341/204/211/341/205/263 /341/204/221/341/205/263/341/206/257/341/204/205/341/205/251/341/204/213/341/205/256 /341/204/213/341/205/247/341/206/253/341/204/200/341/205/247/341/206/257 /341/204/207/341/205/241/341/206/274/341/204/211/341/205/265/341/206/250-100226-093925.pdf +0 -0
  79. package/dist/docs/ai_adapter/event-mapping-matrix.md +0 -140
  80. package/dist/docs/ai_adapter/migration-plan.md +0 -205
  81. package/dist/docs/ai_adapter/template/00_vibecoding_workflow.md +0 -636
  82. package/dist/docs/ai_adapter/template/01_todolist_performance_template.md +0 -372
  83. package/dist/docs/ai_adapter/template/02_code_review_template.md +0 -220
  84. package/dist/docs/ai_adapter/template/03_work_result_report_template.md +0 -120
  85. package/dist/docs/ai_adapter/template/100_Python_Performance_Guide.md +0 -453
  86. package/dist/docs/ai_adapter/template/99_TDD_plan.md +0 -111
  87. package/dist/docs/ai_adapter/todolist/00_master_implementation_plan.md +0 -433
  88. package/dist/docs/ai_adapter/todolist/phase1_foundation_todolist.md +0 -726
  89. package/dist/docs/ai_adapter/todolist/phase2_core_refactoring_todolist.md +0 -974
  90. package/dist/docs/ai_adapter/todolist/phase3_handoff.md +0 -203
  91. package/dist/docs/ai_adapter/todolist/phase3_provider_extension_todolist.md +0 -1382
  92. package/dist/docs/ai_adapter/utility-migration.md +0 -237
  93. package/dist/docs/ai_adapter/working_history/.gitkeep +0 -0
  94. package/dist/docs/ai_adapter/working_history/Phase1_M1.0_/354/275/224/353/223/234/354/235/270/353/262/244/355/206/240/353/246/254_20260201.md +0 -185
  95. package/dist/docs/ai_adapter/working_history/Phase1_M1.1_/355/203/200/354/236/205/354/204/244/352/263/204_20260201.md +0 -185
  96. package/dist/docs/ai_adapter/working_history/Phase1_M1.2_Adapter/354/235/270/355/224/204/353/235/274_20260203.md +0 -378
  97. package/dist/docs/ai_adapter/working_history/Phase1_M1.3_Provider/354/204/240/355/203/235_20260206.md +0 -269
  98. package/dist/docs/ai_adapter/working_history/Phase1_M1.4_/354/234/240/355/213/270/353/246/254/355/213/260/353/247/210/354/235/264/352/267/270/353/240/210/354/235/264/354/205/230_20260206.md +0 -86
  99. package/dist/docs/ai_adapter/working_history/Phase2_ETC_/354/227/260/352/270/260/354/236/221/354/227/205/354/240/225/353/246/254_20260208.md +0 -157
  100. package/dist/docs/ai_adapter/working_history/Phase2_M2.0_/353/224/224/353/240/211/355/206/240/353/246/254/354/236/254/352/265/254/354/204/261_20260207.md +0 -107
  101. package/dist/docs/ai_adapter/working_history/Phase2_M2.1_ContentGenerator/354/235/270/355/204/260/355/216/230/354/235/264/354/212/244/354/236/254/354/240/225/354/235/230_20260207.md +0 -630
  102. package/dist/docs/ai_adapter/working_history/Phase2_M2.2_EventMapper/352/265/254/355/230/204_20260207.md +0 -372
  103. package/dist/docs/ai_adapter/working_history/Phase2_M2.3_GeminiAdapter/352/265/254/355/230/204_20260208.md +0 -205
  104. package/dist/docs/ai_adapter/working_history/Phase2_M2.4_ModelConfigService/355/230/270/355/231/230/353/240/210/354/235/264/354/226/264_20260208.md +0 -275
  105. package/dist/docs/ai_adapter/working_history/Phase2_M2.5_/354/234/240/355/213/270/353/246/254/355/213/260/353/240/210/354/235/264/354/226/264/353/246/254/355/214/251/355/206/240/353/247/201_20260208.md +0 -239
  106. package/dist/docs/ai_adapter/working_history/Phase2_M2.6_/353/235/274/354/232/260/355/214/205/353/240/210/354/235/264/354/226/264/355/203/200/354/236/205/353/217/205/353/246/275/355/231/224_20260208.md +0 -228
  107. package/dist/docs/ai_adapter/working_history/Phase3_ETC_/352/270/260/353/263/270/354/273/250/355/205/215/354/212/244/355/212/270/355/214/214/354/235/274/353/252/205AGENTS/354/240/204/355/231/230_20260211.md +0 -367
  108. package/dist/docs/ai_adapter/working_history/Phase3_M3.0.1_Gemini/354/240/204/354/232/251/355/214/214/354/235/274/353/254/274/353/246/254/354/240/201/354/235/264/353/217/231_20260209.md +0 -271
  109. package/dist/docs/ai_adapter/working_history/Phase3_M3.0.2_messageInspectors/353/247/210/354/235/264/352/267/270/353/240/210/354/235/264/354/205/230_20260209.md +0 -330
  110. package/dist/docs/ai_adapter/working_history/Phase3_M3.0.3_/355/205/224/353/240/210/353/251/224/355/212/270/353/246/254Agent/353/217/205/353/246/275/355/231/224_20260209.md +0 -251
  111. package/dist/docs/ai_adapter/working_history/Phase3_M3.0.4_/353/263/200/355/231/230/353/270/214/353/246/277/354/247/200/354/240/225/353/246/254_20260209.md +0 -136
  112. package/dist/docs/ai_adapter/working_history/Phase3_M3.0.5_/353/237/260/355/203/200/354/236/204/354/213/244/355/226/211/352/262/275/353/241/234/354/227/260/352/262/260_20260209.md +0 -232
  113. package/dist/docs/ai_adapter/working_history/Phase3_M3.1.0_Claude/354/202/254/354/240/204/354/244/200/353/271/204_20260209.md +0 -191
  114. package/dist/docs/ai_adapter/working_history/Phase3_M3.1.1_ClaudeAdapter/352/265/254/355/230/204_20260209.md +0 -225
  115. package/dist/docs/ai_adapter/working_history/Phase3_M3.1.2_ClaudeConverter/352/263/240/353/217/204/355/231/224_20260209.md +0 -171
  116. package/dist/docs/ai_adapter/working_history/Phase3_M3.1.3_ClaudeStreamError/352/263/240/353/217/204/355/231/224_20260209.md +0 -198
  117. package/dist/docs/ai_adapter/working_history/Phase3_M3.1.4_ClaudeErrorMapping_20260209.md +0 -98
  118. package/dist/docs/ai_adapter/working_history/Phase3_M3.2.A_OpenAIAdapterCore_20260210.md +0 -264
  119. package/dist/docs/ai_adapter/working_history/Phase3_M3.2.B_OpenAIStreamConverter_20260210.md +0 -204
  120. package/dist/docs/ai_adapter/working_history/Phase3_M3.3.2_/353/252/250/353/215/270/355/205/234/355/224/214/353/246/277/355/233/205/353/263/264/354/231/204_20260211.md +0 -106
  121. package/dist/docs/ai_adapter/working_history/Phase3_M3.3_OpenAICompatibleAdapter_20260211.md +0 -251
  122. package/dist/docs/ai_adapter/working_history/Phase3_M3.4.2_E2E/355/205/214/354/212/244/355/212/270/354/213/234/353/202/230/353/246/254/354/230/244_20260210.md +0 -264
  123. package/dist/docs/ai_adapter/working_history/Phase3_M3.4.3_/354/204/261/353/212/245/355/232/214/352/267/200/355/205/214/354/212/244/355/212/270_20260211.md +0 -176
  124. package/dist/docs/ai_adapter/working_history/Phase3_M3.4.5_/354/225/210/354/240/225/355/231/224/354/236/221/354/227/205_20260211.md +0 -204
  125. package/dist/docs/ai_adapter/working_history/Phase3_M3.4.A_CLI/355/206/265/355/225/251_3Provider/355/206/265/355/225/251/355/205/214/354/212/244/355/212/270_20260210.md +0 -316
  126. package/dist/docs/ai_adapter/working_history/Phase3_M3.4.A_UI/354/203/201/355/203/234/353/260/224/354/210/230/354/240/225_20260210.md +0 -262
  127. package/dist/docs/ai_adapter/working_history/phase2_tradeoff_EventType/354/240/204/355/231/230_20260208.md +0 -286
  128. package/dist/docs/api/index.md +0 -5
  129. package/dist/docs/api/providers.md +0 -56
  130. package/dist/docs/architecture.md +0 -80
  131. package/dist/docs/assets/connected_devtools.png +0 -0
  132. package/dist/docs/assets/gemini-screenshot.png +0 -0
  133. package/dist/docs/assets/monitoring-dashboard-logs.png +0 -0
  134. package/dist/docs/assets/monitoring-dashboard-metrics.png +0 -0
  135. package/dist/docs/assets/monitoring-dashboard-overview.png +0 -0
  136. package/dist/docs/assets/release_patch.png +0 -0
  137. package/dist/docs/assets/theme-ansi-light.png +0 -0
  138. package/dist/docs/assets/theme-ansi.png +0 -0
  139. package/dist/docs/assets/theme-atom-one.png +0 -0
  140. package/dist/docs/assets/theme-ayu-light.png +0 -0
  141. package/dist/docs/assets/theme-ayu.png +0 -0
  142. package/dist/docs/assets/theme-custom.png +0 -0
  143. package/dist/docs/assets/theme-default-light.png +0 -0
  144. package/dist/docs/assets/theme-default.png +0 -0
  145. package/dist/docs/assets/theme-dracula.png +0 -0
  146. package/dist/docs/assets/theme-github-light.png +0 -0
  147. package/dist/docs/assets/theme-github.png +0 -0
  148. package/dist/docs/assets/theme-google-light.png +0 -0
  149. package/dist/docs/assets/theme-xcode-light.png +0 -0
  150. package/dist/docs/change_model/model_command_multi_provider_plan.md +0 -221
  151. package/dist/docs/change_model/model_command_multi_provider_todolist.md +0 -206
  152. package/dist/docs/changelogs/index.md +0 -726
  153. package/dist/docs/changelogs/latest.md +0 -370
  154. package/dist/docs/changelogs/preview.md +0 -332
  155. package/dist/docs/cli/authentication.md +0 -3
  156. package/dist/docs/cli/checkpointing.md +0 -94
  157. package/dist/docs/cli/commands.md +0 -375
  158. package/dist/docs/cli/custom-commands.md +0 -315
  159. package/dist/docs/cli/enterprise.md +0 -565
  160. package/dist/docs/cli/gemini-ignore.md +0 -71
  161. package/dist/docs/cli/gemini-md.md +0 -108
  162. package/dist/docs/cli/generation-settings.md +0 -210
  163. package/dist/docs/cli/headless.md +0 -388
  164. package/dist/docs/cli/index.md +0 -65
  165. package/dist/docs/cli/keyboard-shortcuts.md +0 -129
  166. package/dist/docs/cli/model-routing.md +0 -42
  167. package/dist/docs/cli/model.md +0 -62
  168. package/dist/docs/cli/sandbox.md +0 -171
  169. package/dist/docs/cli/session-management.md +0 -158
  170. package/dist/docs/cli/settings.md +0 -130
  171. package/dist/docs/cli/skills.md +0 -188
  172. package/dist/docs/cli/system-prompt.md +0 -125
  173. package/dist/docs/cli/telemetry.md +0 -826
  174. package/dist/docs/cli/themes.md +0 -235
  175. package/dist/docs/cli/token-caching.md +0 -20
  176. package/dist/docs/cli/trusted-folders.md +0 -95
  177. package/dist/docs/cli/tutorials/skills-getting-started.md +0 -124
  178. package/dist/docs/cli/tutorials.md +0 -87
  179. package/dist/docs/cli/uninstall.md +0 -65
  180. package/dist/docs/configuration.md +0 -108
  181. package/dist/docs/core/index.md +0 -105
  182. package/dist/docs/core/long-term-memory-design.md +0 -254
  183. package/dist/docs/core/long-term-memory-proposal.md +0 -112
  184. package/dist/docs/core/memport.md +0 -246
  185. package/dist/docs/core/policy-engine.md +0 -300
  186. package/dist/docs/core/tools-api.md +0 -131
  187. package/dist/docs/examples/proxy-script.md +0 -83
  188. package/dist/docs/extensions/best-practices.md +0 -139
  189. package/dist/docs/extensions/index.md +0 -44
  190. package/dist/docs/extensions/reference.md +0 -312
  191. package/dist/docs/extensions/releasing.md +0 -183
  192. package/dist/docs/extensions/writing-extensions.md +0 -283
  193. package/dist/docs/faq.md +0 -154
  194. package/dist/docs/get-started/authentication.md +0 -321
  195. package/dist/docs/get-started/configuration-v1.md +0 -888
  196. package/dist/docs/get-started/configuration.md +0 -1567
  197. package/dist/docs/get-started/examples.md +0 -219
  198. package/dist/docs/get-started/gemini-3.md +0 -101
  199. package/dist/docs/get-started/index.md +0 -71
  200. package/dist/docs/get-started/installation.md +0 -141
  201. package/dist/docs/hooks/best-practices.md +0 -677
  202. package/dist/docs/hooks/index.md +0 -178
  203. package/dist/docs/hooks/reference.md +0 -322
  204. package/dist/docs/hooks/writing-hooks.md +0 -450
  205. package/dist/docs/ide-integration/ide-companion-spec.md +0 -267
  206. package/dist/docs/ide-integration/index.md +0 -202
  207. package/dist/docs/index.md +0 -153
  208. package/dist/docs/integration-tests.md +0 -211
  209. package/dist/docs/issue-and-pr-automation.md +0 -134
  210. package/dist/docs/local-development.md +0 -128
  211. package/dist/docs/mermaid/context.mmd +0 -103
  212. package/dist/docs/mermaid/render-path.mmd +0 -64
  213. package/dist/docs/migration.md +0 -78
  214. package/dist/docs/npm.md +0 -62
  215. package/dist/docs/providers.md +0 -136
  216. package/dist/docs/quota-and-pricing.md +0 -158
  217. package/dist/docs/release-confidence.md +0 -164
  218. package/dist/docs/releases.md +0 -539
  219. package/dist/docs/sidebar.json +0 -140
  220. package/dist/docs/tools/file-system.md +0 -217
  221. package/dist/docs/tools/index.md +0 -98
  222. package/dist/docs/tools/mcp-server.md +0 -1068
  223. package/dist/docs/tools/memory.md +0 -54
  224. package/dist/docs/tools/shell.md +0 -260
  225. package/dist/docs/tools/todos.md +0 -57
  226. package/dist/docs/tools/web-fetch.md +0 -59
  227. package/dist/docs/tools/web-search.md +0 -42
  228. package/dist/docs/tos-privacy.md +0 -96
  229. package/dist/docs/troubleshooting.md +0 -173
  230. package/dist/src/agents/a2a-client-manager.test.d.ts +0 -6
  231. package/dist/src/agents/a2a-client-manager.test.js +0 -220
  232. package/dist/src/agents/a2a-client-manager.test.js.map +0 -1
  233. package/dist/src/agents/a2aUtils.test.d.ts +0 -6
  234. package/dist/src/agents/a2aUtils.test.js +0 -147
  235. package/dist/src/agents/a2aUtils.test.js.map +0 -1
  236. package/dist/src/agents/acknowledgedAgents.test.d.ts +0 -6
  237. package/dist/src/agents/acknowledgedAgents.test.js +0 -70
  238. package/dist/src/agents/acknowledgedAgents.test.js.map +0 -1
  239. package/dist/src/agents/agent-scheduler.test.d.ts +0 -6
  240. package/dist/src/agents/agent-scheduler.test.js +0 -56
  241. package/dist/src/agents/agent-scheduler.test.js.map +0 -1
  242. package/dist/src/agents/agentLoader.test.d.ts +0 -6
  243. package/dist/src/agents/agentLoader.test.js +0 -304
  244. package/dist/src/agents/agentLoader.test.js.map +0 -1
  245. package/dist/src/agents/cli-help-agent.test.d.ts +0 -6
  246. package/dist/src/agents/cli-help-agent.test.js +0 -67
  247. package/dist/src/agents/cli-help-agent.test.js.map +0 -1
  248. package/dist/src/agents/codebase-investigator.test.d.ts +0 -6
  249. package/dist/src/agents/codebase-investigator.test.js +0 -42
  250. package/dist/src/agents/codebase-investigator.test.js.map +0 -1
  251. package/dist/src/agents/generalist-agent.test.d.ts +0 -6
  252. package/dist/src/agents/generalist-agent.test.js +0 -31
  253. package/dist/src/agents/generalist-agent.test.js.map +0 -1
  254. package/dist/src/agents/local-executor.test.d.ts +0 -6
  255. package/dist/src/agents/local-executor.test.js +0 -1577
  256. package/dist/src/agents/local-executor.test.js.map +0 -1
  257. package/dist/src/agents/local-invocation.test.d.ts +0 -6
  258. package/dist/src/agents/local-invocation.test.js +0 -228
  259. package/dist/src/agents/local-invocation.test.js.map +0 -1
  260. package/dist/src/agents/registry.test.d.ts +0 -6
  261. package/dist/src/agents/registry.test.js +0 -773
  262. package/dist/src/agents/registry.test.js.map +0 -1
  263. package/dist/src/agents/registry_acknowledgement.test.d.ts +0 -6
  264. package/dist/src/agents/registry_acknowledgement.test.js +0 -130
  265. package/dist/src/agents/registry_acknowledgement.test.js.map +0 -1
  266. package/dist/src/agents/remote-invocation.test.d.ts +0 -6
  267. package/dist/src/agents/remote-invocation.test.js +0 -213
  268. package/dist/src/agents/remote-invocation.test.js.map +0 -1
  269. package/dist/src/agents/subagent-tool-wrapper.test.d.ts +0 -6
  270. package/dist/src/agents/subagent-tool-wrapper.test.js +0 -109
  271. package/dist/src/agents/subagent-tool-wrapper.test.js.map +0 -1
  272. package/dist/src/agents/utils.test.d.ts +0 -6
  273. package/dist/src/agents/utils.test.js +0 -87
  274. package/dist/src/agents/utils.test.js.map +0 -1
  275. package/dist/src/availability/fallbackIntegration.test.d.ts +0 -6
  276. package/dist/src/availability/fallbackIntegration.test.js +0 -58
  277. package/dist/src/availability/fallbackIntegration.test.js.map +0 -1
  278. package/dist/src/availability/modelAvailabilityService.test.d.ts +0 -6
  279. package/dist/src/availability/modelAvailabilityService.test.js +0 -140
  280. package/dist/src/availability/modelAvailabilityService.test.js.map +0 -1
  281. package/dist/src/availability/policyCatalog.test.d.ts +0 -6
  282. package/dist/src/availability/policyCatalog.test.js +0 -70
  283. package/dist/src/availability/policyCatalog.test.js.map +0 -1
  284. package/dist/src/availability/policyHelpers.test.d.ts +0 -6
  285. package/dist/src/availability/policyHelpers.test.js +0 -220
  286. package/dist/src/availability/policyHelpers.test.js.map +0 -1
  287. package/dist/src/code_assist/admin/admin_controls.test.d.ts +0 -6
  288. package/dist/src/code_assist/admin/admin_controls.test.js +0 -200
  289. package/dist/src/code_assist/admin/admin_controls.test.js.map +0 -1
  290. package/dist/src/code_assist/codeAssist.test.d.ts +0 -6
  291. package/dist/src/code_assist/codeAssist.test.js +0 -102
  292. package/dist/src/code_assist/codeAssist.test.js.map +0 -1
  293. package/dist/src/code_assist/converter.test.d.ts +0 -6
  294. package/dist/src/code_assist/converter.test.js +0 -391
  295. package/dist/src/code_assist/converter.test.js.map +0 -1
  296. package/dist/src/code_assist/experiments/client_metadata.test.d.ts +0 -6
  297. package/dist/src/code_assist/experiments/client_metadata.test.js +0 -96
  298. package/dist/src/code_assist/experiments/client_metadata.test.js.map +0 -1
  299. package/dist/src/code_assist/experiments/experiments.test.d.ts +0 -6
  300. package/dist/src/code_assist/experiments/experiments.test.js +0 -93
  301. package/dist/src/code_assist/experiments/experiments.test.js.map +0 -1
  302. package/dist/src/code_assist/experiments/experiments_local.test.d.ts +0 -6
  303. package/dist/src/code_assist/experiments/experiments_local.test.js +0 -115
  304. package/dist/src/code_assist/experiments/experiments_local.test.js.map +0 -1
  305. package/dist/src/code_assist/oauth-credential-storage.test.d.ts +0 -6
  306. package/dist/src/code_assist/oauth-credential-storage.test.js +0 -198
  307. package/dist/src/code_assist/oauth-credential-storage.test.js.map +0 -1
  308. package/dist/src/code_assist/oauth2.test.d.ts +0 -6
  309. package/dist/src/code_assist/oauth2.test.js +0 -1065
  310. package/dist/src/code_assist/oauth2.test.js.map +0 -1
  311. package/dist/src/code_assist/server.test.d.ts +0 -6
  312. package/dist/src/code_assist/server.test.js +0 -453
  313. package/dist/src/code_assist/server.test.js.map +0 -1
  314. package/dist/src/code_assist/setup.test.d.ts +0 -6
  315. package/dist/src/code_assist/setup.test.js +0 -517
  316. package/dist/src/code_assist/setup.test.js.map +0 -1
  317. package/dist/src/code_assist/telemetry.test.d.ts +0 -6
  318. package/dist/src/code_assist/telemetry.test.js +0 -301
  319. package/dist/src/code_assist/telemetry.test.js.map +0 -1
  320. package/dist/src/commands/extensions.test.d.ts +0 -6
  321. package/dist/src/commands/extensions.test.js +0 -19
  322. package/dist/src/commands/extensions.test.js.map +0 -1
  323. package/dist/src/commands/init.test.d.ts +0 -6
  324. package/dist/src/commands/init.test.js +0 -25
  325. package/dist/src/commands/init.test.js.map +0 -1
  326. package/dist/src/commands/memory.test.d.ts +0 -6
  327. package/dist/src/commands/memory.test.js +0 -182
  328. package/dist/src/commands/memory.test.js.map +0 -1
  329. package/dist/src/commands/restore.test.d.ts +0 -6
  330. package/dist/src/commands/restore.test.js +0 -137
  331. package/dist/src/commands/restore.test.js.map +0 -1
  332. package/dist/src/config/config.test.d.ts +0 -6
  333. package/dist/src/config/config.test.js +0 -1811
  334. package/dist/src/config/config.test.js.map +0 -1
  335. package/dist/src/config/flashFallback.test.d.ts +0 -6
  336. package/dist/src/config/flashFallback.test.js +0 -63
  337. package/dist/src/config/flashFallback.test.js.map +0 -1
  338. package/dist/src/config/models.test.d.ts +0 -6
  339. package/dist/src/config/models.test.js +0 -146
  340. package/dist/src/config/models.test.js.map +0 -1
  341. package/dist/src/config/storage.test.d.ts +0 -6
  342. package/dist/src/config/storage.test.js +0 -115
  343. package/dist/src/config/storage.test.js.map +0 -1
  344. package/dist/src/confirmation-bus/message-bus.test.d.ts +0 -6
  345. package/dist/src/confirmation-bus/message-bus.test.js +0 -170
  346. package/dist/src/confirmation-bus/message-bus.test.js.map +0 -1
  347. package/dist/src/core/apiKeyCredentialStorage.test.d.ts +0 -6
  348. package/dist/src/core/apiKeyCredentialStorage.test.js +0 -71
  349. package/dist/src/core/apiKeyCredentialStorage.test.js.map +0 -1
  350. package/dist/src/core/baseLlmClient.test.d.ts +0 -6
  351. package/dist/src/core/baseLlmClient.test.js +0 -569
  352. package/dist/src/core/baseLlmClient.test.js.map +0 -1
  353. package/dist/src/core/baseLlmClient_new_types.test.d.ts +0 -1
  354. package/dist/src/core/baseLlmClient_new_types.test.js +0 -387
  355. package/dist/src/core/baseLlmClient_new_types.test.js.map +0 -1
  356. package/dist/src/core/client.test.d.ts +0 -6
  357. package/dist/src/core/client.test.js +0 -2654
  358. package/dist/src/core/client.test.js.map +0 -1
  359. package/dist/src/core/contentGenerator.multiProvider.test.d.ts +0 -6
  360. package/dist/src/core/contentGenerator.multiProvider.test.js +0 -314
  361. package/dist/src/core/contentGenerator.multiProvider.test.js.map +0 -1
  362. package/dist/src/core/contentGenerator.test.d.ts +0 -6
  363. package/dist/src/core/contentGenerator.test.js +0 -299
  364. package/dist/src/core/contentGenerator.test.js.map +0 -1
  365. package/dist/src/core/contentGenerator_new_types.test.d.ts +0 -6
  366. package/dist/src/core/contentGenerator_new_types.test.js +0 -292
  367. package/dist/src/core/contentGenerator_new_types.test.js.map +0 -1
  368. package/dist/src/core/coreToolHookTriggers.test.d.ts +0 -6
  369. package/dist/src/core/coreToolHookTriggers.test.js +0 -159
  370. package/dist/src/core/coreToolHookTriggers.test.js.map +0 -1
  371. package/dist/src/core/coreToolScheduler.test.d.ts +0 -6
  372. package/dist/src/core/coreToolScheduler.test.js +0 -1684
  373. package/dist/src/core/coreToolScheduler.test.js.map +0 -1
  374. package/dist/src/core/fakeContentGenerator.test.d.ts +0 -6
  375. package/dist/src/core/fakeContentGenerator.test.js +0 -127
  376. package/dist/src/core/fakeContentGenerator.test.js.map +0 -1
  377. package/dist/src/core/geminiChat.test.d.ts +0 -6
  378. package/dist/src/core/geminiChat.test.js +0 -1773
  379. package/dist/src/core/geminiChat.test.js.map +0 -1
  380. package/dist/src/core/geminiChat_network_retry.test.d.ts +0 -6
  381. package/dist/src/core/geminiChat_network_retry.test.js +0 -201
  382. package/dist/src/core/geminiChat_network_retry.test.js.map +0 -1
  383. package/dist/src/core/logger.test.d.ts +0 -6
  384. package/dist/src/core/logger.test.js +0 -550
  385. package/dist/src/core/logger.test.js.map +0 -1
  386. package/dist/src/core/loggingContentGenerator.test.d.ts +0 -6
  387. package/dist/src/core/loggingContentGenerator.test.js +0 -221
  388. package/dist/src/core/loggingContentGenerator.test.js.map +0 -1
  389. package/dist/src/core/prompts-substitution.test.d.ts +0 -6
  390. package/dist/src/core/prompts-substitution.test.js +0 -101
  391. package/dist/src/core/prompts-substitution.test.js.map +0 -1
  392. package/dist/src/core/prompts.test.d.ts +0 -6
  393. package/dist/src/core/prompts.test.js +0 -391
  394. package/dist/src/core/prompts.test.js.map +0 -1
  395. package/dist/src/core/recordingContentGenerator.test.d.ts +0 -6
  396. package/dist/src/core/recordingContentGenerator.test.js +0 -101
  397. package/dist/src/core/recordingContentGenerator.test.js.map +0 -1
  398. package/dist/src/core/tokenLimits.test.d.ts +0 -6
  399. package/dist/src/core/tokenLimits.test.js +0 -30
  400. package/dist/src/core/tokenLimits.test.js.map +0 -1
  401. package/dist/src/core/turn.test.d.ts +0 -6
  402. package/dist/src/core/turn.test.js +0 -739
  403. package/dist/src/core/turn.test.js.map +0 -1
  404. package/dist/src/fallback/handler.test.d.ts +0 -6
  405. package/dist/src/fallback/handler.test.js +0 -242
  406. package/dist/src/fallback/handler.test.js.map +0 -1
  407. package/dist/src/hooks/hookAggregator.test.d.ts +0 -6
  408. package/dist/src/hooks/hookAggregator.test.js +0 -387
  409. package/dist/src/hooks/hookAggregator.test.js.map +0 -1
  410. package/dist/src/hooks/hookEventHandler.test.d.ts +0 -6
  411. package/dist/src/hooks/hookEventHandler.test.js +0 -603
  412. package/dist/src/hooks/hookEventHandler.test.js.map +0 -1
  413. package/dist/src/hooks/hookPlanner.test.d.ts +0 -6
  414. package/dist/src/hooks/hookPlanner.test.js +0 -315
  415. package/dist/src/hooks/hookPlanner.test.js.map +0 -1
  416. package/dist/src/hooks/hookRegistry.test.d.ts +0 -6
  417. package/dist/src/hooks/hookRegistry.test.js +0 -529
  418. package/dist/src/hooks/hookRegistry.test.js.map +0 -1
  419. package/dist/src/hooks/hookRunner.test.d.ts +0 -6
  420. package/dist/src/hooks/hookRunner.test.js +0 -606
  421. package/dist/src/hooks/hookRunner.test.js.map +0 -1
  422. package/dist/src/hooks/hookSystem.test.d.ts +0 -6
  423. package/dist/src/hooks/hookSystem.test.js +0 -330
  424. package/dist/src/hooks/hookSystem.test.js.map +0 -1
  425. package/dist/src/hooks/hookSystem_new_types.test.d.ts +0 -6
  426. package/dist/src/hooks/hookSystem_new_types.test.js +0 -243
  427. package/dist/src/hooks/hookSystem_new_types.test.js.map +0 -1
  428. package/dist/src/hooks/hookTranslator.test.d.ts +0 -6
  429. package/dist/src/hooks/hookTranslator.test.js +0 -192
  430. package/dist/src/hooks/hookTranslator.test.js.map +0 -1
  431. package/dist/src/hooks/trustedHooks.test.d.ts +0 -6
  432. package/dist/src/hooks/trustedHooks.test.js +0 -154
  433. package/dist/src/hooks/trustedHooks.test.js.map +0 -1
  434. package/dist/src/hooks/types.test.d.ts +0 -6
  435. package/dist/src/hooks/types.test.js +0 -278
  436. package/dist/src/hooks/types.test.js.map +0 -1
  437. package/dist/src/ide/detect-ide.test.d.ts +0 -6
  438. package/dist/src/ide/detect-ide.test.js +0 -195
  439. package/dist/src/ide/detect-ide.test.js.map +0 -1
  440. package/dist/src/ide/ide-client.test.d.ts +0 -6
  441. package/dist/src/ide/ide-client.test.js +0 -753
  442. package/dist/src/ide/ide-client.test.js.map +0 -1
  443. package/dist/src/ide/ide-installer.test.d.ts +0 -6
  444. package/dist/src/ide/ide-installer.test.js +0 -193
  445. package/dist/src/ide/ide-installer.test.js.map +0 -1
  446. package/dist/src/ide/ideContext.test.d.ts +0 -6
  447. package/dist/src/ide/ideContext.test.js +0 -393
  448. package/dist/src/ide/ideContext.test.js.map +0 -1
  449. package/dist/src/ide/process-utils.test.d.ts +0 -6
  450. package/dist/src/ide/process-utils.test.js +0 -151
  451. package/dist/src/ide/process-utils.test.js.map +0 -1
  452. package/dist/src/index.test.d.ts +0 -6
  453. package/dist/src/index.test.js +0 -53
  454. package/dist/src/index.test.js.map +0 -1
  455. package/dist/src/mcp/google-auth-provider.test.d.ts +0 -6
  456. package/dist/src/mcp/google-auth-provider.test.js +0 -167
  457. package/dist/src/mcp/google-auth-provider.test.js.map +0 -1
  458. package/dist/src/mcp/oauth-provider.test.d.ts +0 -6
  459. package/dist/src/mcp/oauth-provider.test.js +0 -1355
  460. package/dist/src/mcp/oauth-provider.test.js.map +0 -1
  461. package/dist/src/mcp/oauth-token-storage.test.d.ts +0 -6
  462. package/dist/src/mcp/oauth-token-storage.test.js +0 -305
  463. package/dist/src/mcp/oauth-token-storage.test.js.map +0 -1
  464. package/dist/src/mcp/oauth-utils.test.d.ts +0 -6
  465. package/dist/src/mcp/oauth-utils.test.js +0 -289
  466. package/dist/src/mcp/oauth-utils.test.js.map +0 -1
  467. package/dist/src/mcp/sa-impersonation-provider.test.d.ts +0 -6
  468. package/dist/src/mcp/sa-impersonation-provider.test.js +0 -117
  469. package/dist/src/mcp/sa-impersonation-provider.test.js.map +0 -1
  470. package/dist/src/mcp/token-storage/base-token-storage.test.d.ts +0 -6
  471. package/dist/src/mcp/token-storage/base-token-storage.test.js +0 -151
  472. package/dist/src/mcp/token-storage/base-token-storage.test.js.map +0 -1
  473. package/dist/src/mcp/token-storage/file-token-storage.test.d.ts +0 -6
  474. package/dist/src/mcp/token-storage/file-token-storage.test.js +0 -238
  475. package/dist/src/mcp/token-storage/file-token-storage.test.js.map +0 -1
  476. package/dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +0 -6
  477. package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +0 -193
  478. package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +0 -1
  479. package/dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +0 -6
  480. package/dist/src/mcp/token-storage/keychain-token-storage.test.js +0 -305
  481. package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +0 -1
  482. package/dist/src/output/json-formatter.test.d.ts +0 -6
  483. package/dist/src/output/json-formatter.test.js +0 -294
  484. package/dist/src/output/json-formatter.test.js.map +0 -1
  485. package/dist/src/output/stream-json-formatter.test.d.ts +0 -6
  486. package/dist/src/output/stream-json-formatter.test.js +0 -477
  487. package/dist/src/output/stream-json-formatter.test.js.map +0 -1
  488. package/dist/src/policy/config.test.d.ts +0 -6
  489. package/dist/src/policy/config.test.js +0 -598
  490. package/dist/src/policy/config.test.js.map +0 -1
  491. package/dist/src/policy/persistence.test.d.ts +0 -6
  492. package/dist/src/policy/persistence.test.js +0 -154
  493. package/dist/src/policy/persistence.test.js.map +0 -1
  494. package/dist/src/policy/policy-engine.test.d.ts +0 -6
  495. package/dist/src/policy/policy-engine.test.js +0 -1299
  496. package/dist/src/policy/policy-engine.test.js.map +0 -1
  497. package/dist/src/policy/policy-updater.test.d.ts +0 -6
  498. package/dist/src/policy/policy-updater.test.js +0 -116
  499. package/dist/src/policy/policy-updater.test.js.map +0 -1
  500. package/dist/src/policy/shell-safety.test.d.ts +0 -6
  501. package/dist/src/policy/shell-safety.test.js +0 -438
  502. package/dist/src/policy/shell-safety.test.js.map +0 -1
  503. package/dist/src/policy/toml-loader.test.d.ts +0 -6
  504. package/dist/src/policy/toml-loader.test.js +0 -409
  505. package/dist/src/policy/toml-loader.test.js.map +0 -1
  506. package/dist/src/policy/utils.test.d.ts +0 -6
  507. package/dist/src/policy/utils.test.js +0 -92
  508. package/dist/src/policy/utils.test.js.map +0 -1
  509. package/dist/src/prompts/mcp-prompts.test.d.ts +0 -6
  510. package/dist/src/prompts/mcp-prompts.test.js +0 -39
  511. package/dist/src/prompts/mcp-prompts.test.js.map +0 -1
  512. package/dist/src/prompts/prompt-registry.test.d.ts +0 -6
  513. package/dist/src/prompts/prompt-registry.test.js +0 -96
  514. package/dist/src/prompts/prompt-registry.test.js.map +0 -1
  515. package/dist/src/providers/__tests__/bundleSize.test.d.ts +0 -6
  516. package/dist/src/providers/__tests__/bundleSize.test.js +0 -75
  517. package/dist/src/providers/__tests__/bundleSize.test.js.map +0 -1
  518. package/dist/src/providers/__tests__/errorHandling.integration.test.d.ts +0 -6
  519. package/dist/src/providers/__tests__/errorHandling.integration.test.js +0 -339
  520. package/dist/src/providers/__tests__/errorHandling.integration.test.js.map +0 -1
  521. package/dist/src/providers/__tests__/multiProvider.integration.test.d.ts +0 -6
  522. package/dist/src/providers/__tests__/multiProvider.integration.test.js +0 -419
  523. package/dist/src/providers/__tests__/multiProvider.integration.test.js.map +0 -1
  524. package/dist/src/providers/__tests__/performance.test.d.ts +0 -6
  525. package/dist/src/providers/__tests__/performance.test.js +0 -270
  526. package/dist/src/providers/__tests__/performance.test.js.map +0 -1
  527. package/dist/src/providers/__tests__/providerConfigIntegration.test.d.ts +0 -6
  528. package/dist/src/providers/__tests__/providerConfigIntegration.test.js +0 -245
  529. package/dist/src/providers/__tests__/providerConfigIntegration.test.js.map +0 -1
  530. package/dist/src/providers/baseAdapter.test.d.ts +0 -1
  531. package/dist/src/providers/baseAdapter.test.js +0 -142
  532. package/dist/src/providers/baseAdapter.test.js.map +0 -1
  533. package/dist/src/providers/claude/adapter.test.d.ts +0 -6
  534. package/dist/src/providers/claude/adapter.test.js +0 -628
  535. package/dist/src/providers/claude/adapter.test.js.map +0 -1
  536. package/dist/src/providers/claude/bootstrap.test.d.ts +0 -6
  537. package/dist/src/providers/claude/bootstrap.test.js +0 -74
  538. package/dist/src/providers/claude/bootstrap.test.js.map +0 -1
  539. package/dist/src/providers/claude/converter.test.d.ts +0 -6
  540. package/dist/src/providers/claude/converter.test.js +0 -1002
  541. package/dist/src/providers/claude/converter.test.js.map +0 -1
  542. package/dist/src/providers/claude/exports.test.d.ts +0 -6
  543. package/dist/src/providers/claude/exports.test.js +0 -40
  544. package/dist/src/providers/claude/exports.test.js.map +0 -1
  545. package/dist/src/providers/configAdapter.test.d.ts +0 -1
  546. package/dist/src/providers/configAdapter.test.js +0 -150
  547. package/dist/src/providers/configAdapter.test.js.map +0 -1
  548. package/dist/src/providers/contentResolver.test.d.ts +0 -1
  549. package/dist/src/providers/contentResolver.test.js +0 -89
  550. package/dist/src/providers/contentResolver.test.js.map +0 -1
  551. package/dist/src/providers/factory.test.d.ts +0 -1
  552. package/dist/src/providers/factory.test.js +0 -151
  553. package/dist/src/providers/factory.test.js.map +0 -1
  554. package/dist/src/providers/gemini/adapterBridge.test.d.ts +0 -6
  555. package/dist/src/providers/gemini/adapterBridge.test.js +0 -164
  556. package/dist/src/providers/gemini/adapterBridge.test.js.map +0 -1
  557. package/dist/src/providers/gemini/bootstrap.test.d.ts +0 -6
  558. package/dist/src/providers/gemini/bootstrap.test.js +0 -72
  559. package/dist/src/providers/gemini/bootstrap.test.js.map +0 -1
  560. package/dist/src/providers/gemini/configConverter.test.d.ts +0 -6
  561. package/dist/src/providers/gemini/configConverter.test.js +0 -218
  562. package/dist/src/providers/gemini/configConverter.test.js.map +0 -1
  563. package/dist/src/providers/gemini/errorClassifier.test.d.ts +0 -6
  564. package/dist/src/providers/gemini/errorClassifier.test.js +0 -83
  565. package/dist/src/providers/gemini/errorClassifier.test.js.map +0 -1
  566. package/dist/src/providers/gemini/eventMapper.test.d.ts +0 -6
  567. package/dist/src/providers/gemini/eventMapper.test.js +0 -502
  568. package/dist/src/providers/gemini/eventMapper.test.js.map +0 -1
  569. package/dist/src/providers/gemini/exports.test.d.ts +0 -6
  570. package/dist/src/providers/gemini/exports.test.js +0 -90
  571. package/dist/src/providers/gemini/exports.test.js.map +0 -1
  572. package/dist/src/providers/gemini/featureFlag.test.d.ts +0 -6
  573. package/dist/src/providers/gemini/featureFlag.test.js +0 -139
  574. package/dist/src/providers/gemini/featureFlag.test.js.map +0 -1
  575. package/dist/src/providers/gemini/geminiAdapter.test.d.ts +0 -6
  576. package/dist/src/providers/gemini/geminiAdapter.test.js +0 -279
  577. package/dist/src/providers/gemini/geminiAdapter.test.js.map +0 -1
  578. package/dist/src/providers/gemini/geminiConverter.test.d.ts +0 -6
  579. package/dist/src/providers/gemini/geminiConverter.test.js +0 -474
  580. package/dist/src/providers/gemini/geminiConverter.test.js.map +0 -1
  581. package/dist/src/providers/gemini/geminiParity.test.d.ts +0 -6
  582. package/dist/src/providers/gemini/geminiParity.test.js +0 -754
  583. package/dist/src/providers/gemini/geminiParity.test.js.map +0 -1
  584. package/dist/src/providers/gemini/geminiStream.test.d.ts +0 -6
  585. package/dist/src/providers/gemini/geminiStream.test.js +0 -391
  586. package/dist/src/providers/gemini/geminiStream.test.js.map +0 -1
  587. package/dist/src/providers/gemini/historyBuilder.test.d.ts +0 -6
  588. package/dist/src/providers/gemini/historyBuilder.test.js +0 -207
  589. package/dist/src/providers/gemini/historyBuilder.test.js.map +0 -1
  590. package/dist/src/providers/gemini/requestBuilder.test.d.ts +0 -6
  591. package/dist/src/providers/gemini/requestBuilder.test.js +0 -358
  592. package/dist/src/providers/gemini/requestBuilder.test.js.map +0 -1
  593. package/dist/src/providers/gemini/streamConverter.test.d.ts +0 -6
  594. package/dist/src/providers/gemini/streamConverter.test.js +0 -131
  595. package/dist/src/providers/gemini/streamConverter.test.js.map +0 -1
  596. package/dist/src/providers/modelSpec.test.d.ts +0 -1
  597. package/dist/src/providers/modelSpec.test.js +0 -119
  598. package/dist/src/providers/modelSpec.test.js.map +0 -1
  599. package/dist/src/providers/openai/adapter.test.d.ts +0 -6
  600. package/dist/src/providers/openai/adapter.test.js +0 -274
  601. package/dist/src/providers/openai/adapter.test.js.map +0 -1
  602. package/dist/src/providers/openai/bootstrap.test.d.ts +0 -6
  603. package/dist/src/providers/openai/bootstrap.test.js +0 -76
  604. package/dist/src/providers/openai/bootstrap.test.js.map +0 -1
  605. package/dist/src/providers/openai/converter.test.d.ts +0 -6
  606. package/dist/src/providers/openai/converter.test.js +0 -1133
  607. package/dist/src/providers/openai/converter.test.js.map +0 -1
  608. package/dist/src/providers/openai-compatible/__tests__/compatibility.test.d.ts +0 -6
  609. package/dist/src/providers/openai-compatible/__tests__/compatibility.test.js +0 -356
  610. package/dist/src/providers/openai-compatible/__tests__/compatibility.test.js.map +0 -1
  611. package/dist/src/providers/openai-compatible/adapter.test.d.ts +0 -6
  612. package/dist/src/providers/openai-compatible/adapter.test.js +0 -240
  613. package/dist/src/providers/openai-compatible/adapter.test.js.map +0 -1
  614. package/dist/src/providers/openai-compatible/bootstrap.test.d.ts +0 -6
  615. package/dist/src/providers/openai-compatible/bootstrap.test.js +0 -145
  616. package/dist/src/providers/openai-compatible/bootstrap.test.js.map +0 -1
  617. package/dist/src/providers/openai-compatible/promptBuilder.test.d.ts +0 -6
  618. package/dist/src/providers/openai-compatible/promptBuilder.test.js +0 -154
  619. package/dist/src/providers/openai-compatible/promptBuilder.test.js.map +0 -1
  620. package/dist/src/providers/providerConfig.test.d.ts +0 -1
  621. package/dist/src/providers/providerConfig.test.js +0 -145
  622. package/dist/src/providers/providerConfig.test.js.map +0 -1
  623. package/dist/src/providers/providerConfigIntegration.test.d.ts +0 -6
  624. package/dist/src/providers/providerConfigIntegration.test.js +0 -187
  625. package/dist/src/providers/providerConfigIntegration.test.js.map +0 -1
  626. package/dist/src/providers/providerSelector.test.d.ts +0 -1
  627. package/dist/src/providers/providerSelector.test.js +0 -199
  628. package/dist/src/providers/providerSelector.test.js.map +0 -1
  629. package/dist/src/providers/providerTypes.test.d.ts +0 -1
  630. package/dist/src/providers/providerTypes.test.js +0 -95
  631. package/dist/src/providers/providerTypes.test.js.map +0 -1
  632. package/dist/src/providers/registry.test.d.ts +0 -1
  633. package/dist/src/providers/registry.test.js +0 -207
  634. package/dist/src/providers/registry.test.js.map +0 -1
  635. package/dist/src/providers/streamAssembler.test.d.ts +0 -1
  636. package/dist/src/providers/streamAssembler.test.js +0 -247
  637. package/dist/src/providers/streamAssembler.test.js.map +0 -1
  638. package/dist/src/providers/telemetryBridge.test.d.ts +0 -6
  639. package/dist/src/providers/telemetryBridge.test.js +0 -235
  640. package/dist/src/providers/telemetryBridge.test.js.map +0 -1
  641. package/dist/src/providers/types.test.d.ts +0 -6
  642. package/dist/src/providers/types.test.js +0 -253
  643. package/dist/src/providers/types.test.js.map +0 -1
  644. package/dist/src/resources/resource-registry.test.d.ts +0 -6
  645. package/dist/src/resources/resource-registry.test.js +0 -54
  646. package/dist/src/resources/resource-registry.test.js.map +0 -1
  647. package/dist/src/routing/modelRouterService.test.d.ts +0 -6
  648. package/dist/src/routing/modelRouterService.test.js +0 -106
  649. package/dist/src/routing/modelRouterService.test.js.map +0 -1
  650. package/dist/src/routing/strategies/classifierStrategy.test.d.ts +0 -6
  651. package/dist/src/routing/strategies/classifierStrategy.test.js +0 -249
  652. package/dist/src/routing/strategies/classifierStrategy.test.js.map +0 -1
  653. package/dist/src/routing/strategies/compositeStrategy.test.d.ts +0 -6
  654. package/dist/src/routing/strategies/compositeStrategy.test.js +0 -124
  655. package/dist/src/routing/strategies/compositeStrategy.test.js.map +0 -1
  656. package/dist/src/routing/strategies/defaultStrategy.test.d.ts +0 -6
  657. package/dist/src/routing/strategies/defaultStrategy.test.js +0 -102
  658. package/dist/src/routing/strategies/defaultStrategy.test.js.map +0 -1
  659. package/dist/src/routing/strategies/fallbackStrategy.test.d.ts +0 -6
  660. package/dist/src/routing/strategies/fallbackStrategy.test.js +0 -96
  661. package/dist/src/routing/strategies/fallbackStrategy.test.js.map +0 -1
  662. package/dist/src/routing/strategies/numericalClassifierStrategy.test.d.ts +0 -6
  663. package/dist/src/routing/strategies/numericalClassifierStrategy.test.js +0 -367
  664. package/dist/src/routing/strategies/numericalClassifierStrategy.test.js.map +0 -1
  665. package/dist/src/routing/strategies/overrideStrategy.test.d.ts +0 -6
  666. package/dist/src/routing/strategies/overrideStrategy.test.js +0 -59
  667. package/dist/src/routing/strategies/overrideStrategy.test.js.map +0 -1
  668. package/dist/src/safety/built-in.test.d.ts +0 -6
  669. package/dist/src/safety/built-in.test.js +0 -199
  670. package/dist/src/safety/built-in.test.js.map +0 -1
  671. package/dist/src/safety/checker-runner.test.d.ts +0 -6
  672. package/dist/src/safety/checker-runner.test.js +0 -238
  673. package/dist/src/safety/checker-runner.test.js.map +0 -1
  674. package/dist/src/safety/context-builder.test.d.ts +0 -6
  675. package/dist/src/safety/context-builder.test.js +0 -49
  676. package/dist/src/safety/context-builder.test.js.map +0 -1
  677. package/dist/src/safety/registry.test.d.ts +0 -6
  678. package/dist/src/safety/registry.test.js +0 -31
  679. package/dist/src/safety/registry.test.js.map +0 -1
  680. package/dist/src/scheduler/confirmation.test.d.ts +0 -6
  681. package/dist/src/scheduler/confirmation.test.js +0 -325
  682. package/dist/src/scheduler/confirmation.test.js.map +0 -1
  683. package/dist/src/scheduler/policy.test.d.ts +0 -6
  684. package/dist/src/scheduler/policy.test.js +0 -299
  685. package/dist/src/scheduler/policy.test.js.map +0 -1
  686. package/dist/src/scheduler/scheduler.test.d.ts +0 -6
  687. package/dist/src/scheduler/scheduler.test.js +0 -822
  688. package/dist/src/scheduler/scheduler.test.js.map +0 -1
  689. package/dist/src/scheduler/state-manager.test.d.ts +0 -6
  690. package/dist/src/scheduler/state-manager.test.js +0 -429
  691. package/dist/src/scheduler/state-manager.test.js.map +0 -1
  692. package/dist/src/scheduler/tool-executor.test.d.ts +0 -6
  693. package/dist/src/scheduler/tool-executor.test.js +0 -232
  694. package/dist/src/scheduler/tool-executor.test.js.map +0 -1
  695. package/dist/src/scheduler/tool-modifier.test.d.ts +0 -6
  696. package/dist/src/scheduler/tool-modifier.test.js +0 -159
  697. package/dist/src/scheduler/tool-modifier.test.js.map +0 -1
  698. package/dist/src/services/chatCompressionService.test.d.ts +0 -6
  699. package/dist/src/services/chatCompressionService.test.js +0 -573
  700. package/dist/src/services/chatCompressionService.test.js.map +0 -1
  701. package/dist/src/services/chatRecordingService.test.d.ts +0 -6
  702. package/dist/src/services/chatRecordingService.test.js +0 -486
  703. package/dist/src/services/chatRecordingService.test.js.map +0 -1
  704. package/dist/src/services/contextManager.test.d.ts +0 -6
  705. package/dist/src/services/contextManager.test.js +0 -104
  706. package/dist/src/services/contextManager.test.js.map +0 -1
  707. package/dist/src/services/environmentSanitization.test.d.ts +0 -6
  708. package/dist/src/services/environmentSanitization.test.js +0 -284
  709. package/dist/src/services/environmentSanitization.test.js.map +0 -1
  710. package/dist/src/services/fileDiscoveryService.test.d.ts +0 -6
  711. package/dist/src/services/fileDiscoveryService.test.js +0 -223
  712. package/dist/src/services/fileDiscoveryService.test.js.map +0 -1
  713. package/dist/src/services/fileSystemService.test.d.ts +0 -6
  714. package/dist/src/services/fileSystemService.test.js +0 -41
  715. package/dist/src/services/fileSystemService.test.js.map +0 -1
  716. package/dist/src/services/gitService.test.d.ts +0 -6
  717. package/dist/src/services/gitService.test.js +0 -264
  718. package/dist/src/services/gitService.test.js.map +0 -1
  719. package/dist/src/services/loopDetectionService.test.d.ts +0 -6
  720. package/dist/src/services/loopDetectionService.test.js +0 -881
  721. package/dist/src/services/loopDetectionService.test.js.map +0 -1
  722. package/dist/src/services/modelConfig.golden.test.d.ts +0 -6
  723. package/dist/src/services/modelConfig.golden.test.js +0 -74
  724. package/dist/src/services/modelConfig.golden.test.js.map +0 -1
  725. package/dist/src/services/modelConfig.integration.test.d.ts +0 -6
  726. package/dist/src/services/modelConfig.integration.test.js +0 -247
  727. package/dist/src/services/modelConfig.integration.test.js.map +0 -1
  728. package/dist/src/services/modelConfigBridge.test.d.ts +0 -6
  729. package/dist/src/services/modelConfigBridge.test.js +0 -410
  730. package/dist/src/services/modelConfigBridge.test.js.map +0 -1
  731. package/dist/src/services/modelConfigService.test.d.ts +0 -6
  732. package/dist/src/services/modelConfigService.test.js +0 -868
  733. package/dist/src/services/modelConfigService.test.js.map +0 -1
  734. package/dist/src/services/sessionSummaryService.test.d.ts +0 -6
  735. package/dist/src/services/sessionSummaryService.test.js +0 -785
  736. package/dist/src/services/sessionSummaryService.test.js.map +0 -1
  737. package/dist/src/services/sessionSummaryUtils.test.d.ts +0 -6
  738. package/dist/src/services/sessionSummaryUtils.test.js +0 -160
  739. package/dist/src/services/sessionSummaryUtils.test.js.map +0 -1
  740. package/dist/src/services/shellExecutionService.test.d.ts +0 -6
  741. package/dist/src/services/shellExecutionService.test.js +0 -1080
  742. package/dist/src/services/shellExecutionService.test.js.map +0 -1
  743. package/dist/src/skills/skillLoader.test.d.ts +0 -6
  744. package/dist/src/skills/skillLoader.test.js +0 -185
  745. package/dist/src/skills/skillLoader.test.js.map +0 -1
  746. package/dist/src/skills/skillManager.test.d.ts +0 -6
  747. package/dist/src/skills/skillManager.test.js +0 -297
  748. package/dist/src/skills/skillManager.test.js.map +0 -1
  749. package/dist/src/telemetry/activity-detector.test.d.ts +0 -6
  750. package/dist/src/telemetry/activity-detector.test.js +0 -136
  751. package/dist/src/telemetry/activity-detector.test.js.map +0 -1
  752. package/dist/src/telemetry/activity-monitor.test.d.ts +0 -6
  753. package/dist/src/telemetry/activity-monitor.test.js +0 -251
  754. package/dist/src/telemetry/activity-monitor.test.js.map +0 -1
  755. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +0 -19
  756. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +0 -964
  757. package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +0 -1
  758. package/dist/src/telemetry/config.test.d.ts +0 -6
  759. package/dist/src/telemetry/config.test.js +0 -149
  760. package/dist/src/telemetry/config.test.js.map +0 -1
  761. package/dist/src/telemetry/gcp-exporters.test.d.ts +0 -6
  762. package/dist/src/telemetry/gcp-exporters.test.js +0 -318
  763. package/dist/src/telemetry/gcp-exporters.test.js.map +0 -1
  764. package/dist/src/telemetry/high-water-mark-tracker.test.d.ts +0 -6
  765. package/dist/src/telemetry/high-water-mark-tracker.test.js +0 -152
  766. package/dist/src/telemetry/high-water-mark-tracker.test.js.map +0 -1
  767. package/dist/src/telemetry/integration.test.circular.d.ts +0 -6
  768. package/dist/src/telemetry/integration.test.circular.js +0 -54
  769. package/dist/src/telemetry/integration.test.circular.js.map +0 -1
  770. package/dist/src/telemetry/loggers.test.circular.d.ts +0 -6
  771. package/dist/src/telemetry/loggers.test.circular.js +0 -107
  772. package/dist/src/telemetry/loggers.test.circular.js.map +0 -1
  773. package/dist/src/telemetry/loggers.test.d.ts +0 -6
  774. package/dist/src/telemetry/loggers.test.js +0 -1618
  775. package/dist/src/telemetry/loggers.test.js.map +0 -1
  776. package/dist/src/telemetry/memory-monitor.test.d.ts +0 -6
  777. package/dist/src/telemetry/memory-monitor.test.js +0 -472
  778. package/dist/src/telemetry/memory-monitor.test.js.map +0 -1
  779. package/dist/src/telemetry/metrics.test.d.ts +0 -6
  780. package/dist/src/telemetry/metrics.test.js +0 -1176
  781. package/dist/src/telemetry/metrics.test.js.map +0 -1
  782. package/dist/src/telemetry/rate-limiter.test.d.ts +0 -6
  783. package/dist/src/telemetry/rate-limiter.test.js +0 -207
  784. package/dist/src/telemetry/rate-limiter.test.js.map +0 -1
  785. package/dist/src/telemetry/sanitize.test.d.ts +0 -6
  786. package/dist/src/telemetry/sanitize.test.js +0 -279
  787. package/dist/src/telemetry/sanitize.test.js.map +0 -1
  788. package/dist/src/telemetry/sdk.test.d.ts +0 -6
  789. package/dist/src/telemetry/sdk.test.js +0 -360
  790. package/dist/src/telemetry/sdk.test.js.map +0 -1
  791. package/dist/src/telemetry/semantic.test.d.ts +0 -6
  792. package/dist/src/telemetry/semantic.test.js +0 -387
  793. package/dist/src/telemetry/semantic.test.js.map +0 -1
  794. package/dist/src/telemetry/semantic.truncation.test.d.ts +0 -1
  795. package/dist/src/telemetry/semantic.truncation.test.js +0 -92
  796. package/dist/src/telemetry/semantic.truncation.test.js.map +0 -1
  797. package/dist/src/telemetry/startupProfiler.test.d.ts +0 -6
  798. package/dist/src/telemetry/startupProfiler.test.js +0 -285
  799. package/dist/src/telemetry/startupProfiler.test.js.map +0 -1
  800. package/dist/src/telemetry/telemetry-utils.test.d.ts +0 -6
  801. package/dist/src/telemetry/telemetry-utils.test.js +0 -41
  802. package/dist/src/telemetry/telemetry-utils.test.js.map +0 -1
  803. package/dist/src/telemetry/telemetry.test.d.ts +0 -6
  804. package/dist/src/telemetry/telemetry.test.js +0 -57
  805. package/dist/src/telemetry/telemetry.test.js.map +0 -1
  806. package/dist/src/telemetry/uiTelemetry.test.d.ts +0 -6
  807. package/dist/src/telemetry/uiTelemetry.test.js +0 -584
  808. package/dist/src/telemetry/uiTelemetry.test.js.map +0 -1
  809. package/dist/src/tools/activate-skill.test.d.ts +0 -6
  810. package/dist/src/tools/activate-skill.test.js +0 -113
  811. package/dist/src/tools/activate-skill.test.js.map +0 -1
  812. package/dist/src/tools/ask-user.test.d.ts +0 -6
  813. package/dist/src/tools/ask-user.test.js +0 -187
  814. package/dist/src/tools/ask-user.test.js.map +0 -1
  815. package/dist/src/tools/base-tool-invocation.test.d.ts +0 -6
  816. package/dist/src/tools/base-tool-invocation.test.js +0 -85
  817. package/dist/src/tools/base-tool-invocation.test.js.map +0 -1
  818. package/dist/src/tools/confirmation-policy.test.d.ts +0 -6
  819. package/dist/src/tools/confirmation-policy.test.js +0 -143
  820. package/dist/src/tools/confirmation-policy.test.js.map +0 -1
  821. package/dist/src/tools/diffOptions.test.d.ts +0 -6
  822. package/dist/src/tools/diffOptions.test.js +0 -172
  823. package/dist/src/tools/diffOptions.test.js.map +0 -1
  824. package/dist/src/tools/edit.test.d.ts +0 -6
  825. package/dist/src/tools/edit.test.js +0 -729
  826. package/dist/src/tools/edit.test.js.map +0 -1
  827. package/dist/src/tools/get-internal-docs.test.d.ts +0 -6
  828. package/dist/src/tools/get-internal-docs.test.js +0 -57
  829. package/dist/src/tools/get-internal-docs.test.js.map +0 -1
  830. package/dist/src/tools/glob.test.d.ts +0 -6
  831. package/dist/src/tools/glob.test.js +0 -433
  832. package/dist/src/tools/glob.test.js.map +0 -1
  833. package/dist/src/tools/grep.test.d.ts +0 -6
  834. package/dist/src/tools/grep.test.js +0 -328
  835. package/dist/src/tools/grep.test.js.map +0 -1
  836. package/dist/src/tools/ls.test.d.ts +0 -6
  837. package/dist/src/tools/ls.test.js +0 -242
  838. package/dist/src/tools/ls.test.js.map +0 -1
  839. package/dist/src/tools/mcp-client-manager.test.d.ts +0 -6
  840. package/dist/src/tools/mcp-client-manager.test.js +0 -251
  841. package/dist/src/tools/mcp-client-manager.test.js.map +0 -1
  842. package/dist/src/tools/mcp-client.test.d.ts +0 -6
  843. package/dist/src/tools/mcp-client.test.js +0 -1346
  844. package/dist/src/tools/mcp-client.test.js.map +0 -1
  845. package/dist/src/tools/mcp-tool.test.d.ts +0 -6
  846. package/dist/src/tools/mcp-tool.test.js +0 -657
  847. package/dist/src/tools/mcp-tool.test.js.map +0 -1
  848. package/dist/src/tools/memoryTool.test.d.ts +0 -6
  849. package/dist/src/tools/memoryTool.test.js +0 -302
  850. package/dist/src/tools/memoryTool.test.js.map +0 -1
  851. package/dist/src/tools/message-bus-integration.test.d.ts +0 -6
  852. package/dist/src/tools/message-bus-integration.test.js +0 -169
  853. package/dist/src/tools/message-bus-integration.test.js.map +0 -1
  854. package/dist/src/tools/modifiable-tool.test.d.ts +0 -6
  855. package/dist/src/tools/modifiable-tool.test.js +0 -237
  856. package/dist/src/tools/modifiable-tool.test.js.map +0 -1
  857. package/dist/src/tools/read-file.test.d.ts +0 -6
  858. package/dist/src/tools/read-file.test.js +0 -376
  859. package/dist/src/tools/read-file.test.js.map +0 -1
  860. package/dist/src/tools/read-many-files.test.d.ts +0 -6
  861. package/dist/src/tools/read-many-files.test.js +0 -567
  862. package/dist/src/tools/read-many-files.test.js.map +0 -1
  863. package/dist/src/tools/ripGrep.test.d.ts +0 -6
  864. package/dist/src/tools/ripGrep.test.js +0 -1139
  865. package/dist/src/tools/ripGrep.test.js.map +0 -1
  866. package/dist/src/tools/shell.test.d.ts +0 -6
  867. package/dist/src/tools/shell.test.js +0 -526
  868. package/dist/src/tools/shell.test.js.map +0 -1
  869. package/dist/src/tools/tool-names.test.d.ts +0 -6
  870. package/dist/src/tools/tool-names.test.js +0 -43
  871. package/dist/src/tools/tool-names.test.js.map +0 -1
  872. package/dist/src/tools/tool-registry.test.d.ts +0 -6
  873. package/dist/src/tools/tool-registry.test.js +0 -461
  874. package/dist/src/tools/tool-registry.test.js.map +0 -1
  875. package/dist/src/tools/tools.test.d.ts +0 -6
  876. package/dist/src/tools/tools.test.js +0 -207
  877. package/dist/src/tools/tools.test.js.map +0 -1
  878. package/dist/src/tools/web-fetch.test.d.ts +0 -6
  879. package/dist/src/tools/web-fetch.test.js +0 -442
  880. package/dist/src/tools/web-fetch.test.js.map +0 -1
  881. package/dist/src/tools/web-search.test.d.ts +0 -6
  882. package/dist/src/tools/web-search.test.js +0 -214
  883. package/dist/src/tools/web-search.test.js.map +0 -1
  884. package/dist/src/tools/write-file.test.d.ts +0 -6
  885. package/dist/src/tools/write-file.test.js +0 -681
  886. package/dist/src/tools/write-file.test.js.map +0 -1
  887. package/dist/src/tools/write-todos.test.d.ts +0 -6
  888. package/dist/src/tools/write-todos.test.js +0 -90
  889. package/dist/src/tools/write-todos.test.js.map +0 -1
  890. package/dist/src/utils/apiConversionUtils.test.d.ts +0 -6
  891. package/dist/src/utils/apiConversionUtils.test.js +0 -150
  892. package/dist/src/utils/apiConversionUtils.test.js.map +0 -1
  893. package/dist/src/utils/bfsFileSearch.test.d.ts +0 -6
  894. package/dist/src/utils/bfsFileSearch.test.js +0 -227
  895. package/dist/src/utils/bfsFileSearch.test.js.map +0 -1
  896. package/dist/src/utils/channel.test.d.ts +0 -6
  897. package/dist/src/utils/channel.test.js +0 -170
  898. package/dist/src/utils/channel.test.js.map +0 -1
  899. package/dist/src/utils/checkpointUtils.test.d.ts +0 -6
  900. package/dist/src/utils/checkpointUtils.test.js +0 -229
  901. package/dist/src/utils/checkpointUtils.test.js.map +0 -1
  902. package/dist/src/utils/customHeaderUtils.test.d.ts +0 -6
  903. package/dist/src/utils/customHeaderUtils.test.js +0 -77
  904. package/dist/src/utils/customHeaderUtils.test.js.map +0 -1
  905. package/dist/src/utils/debugLogger.test.d.ts +0 -6
  906. package/dist/src/utils/debugLogger.test.js +0 -69
  907. package/dist/src/utils/debugLogger.test.js.map +0 -1
  908. package/dist/src/utils/delay.test.d.ts +0 -6
  909. package/dist/src/utils/delay.test.js +0 -88
  910. package/dist/src/utils/delay.test.js.map +0 -1
  911. package/dist/src/utils/editCorrector.test.d.ts +0 -6
  912. package/dist/src/utils/editCorrector.test.js +0 -533
  913. package/dist/src/utils/editCorrector.test.js.map +0 -1
  914. package/dist/src/utils/editor.test.d.ts +0 -6
  915. package/dist/src/utils/editor.test.js +0 -429
  916. package/dist/src/utils/editor.test.js.map +0 -1
  917. package/dist/src/utils/environmentContext.test.d.ts +0 -6
  918. package/dist/src/utils/environmentContext.test.js +0 -114
  919. package/dist/src/utils/environmentContext.test.js.map +0 -1
  920. package/dist/src/utils/errorParsing.test.d.ts +0 -6
  921. package/dist/src/utils/errorParsing.test.js +0 -84
  922. package/dist/src/utils/errorParsing.test.js.map +0 -1
  923. package/dist/src/utils/errorReporting.test.d.ts +0 -6
  924. package/dist/src/utils/errorReporting.test.js +0 -133
  925. package/dist/src/utils/errorReporting.test.js.map +0 -1
  926. package/dist/src/utils/errors.test.d.ts +0 -6
  927. package/dist/src/utils/errors.test.js +0 -155
  928. package/dist/src/utils/errors.test.js.map +0 -1
  929. package/dist/src/utils/events.test.d.ts +0 -6
  930. package/dist/src/utils/events.test.js +0 -237
  931. package/dist/src/utils/events.test.js.map +0 -1
  932. package/dist/src/utils/extensionLoader.test.d.ts +0 -6
  933. package/dist/src/utils/extensionLoader.test.js +0 -176
  934. package/dist/src/utils/extensionLoader.test.js.map +0 -1
  935. package/dist/src/utils/fileDiffUtils.test.d.ts +0 -6
  936. package/dist/src/utils/fileDiffUtils.test.js +0 -84
  937. package/dist/src/utils/fileDiffUtils.test.js.map +0 -1
  938. package/dist/src/utils/fileUtils.test.d.ts +0 -6
  939. package/dist/src/utils/fileUtils.test.js +0 -780
  940. package/dist/src/utils/fileUtils.test.js.map +0 -1
  941. package/dist/src/utils/filesearch/crawlCache.test.d.ts +0 -6
  942. package/dist/src/utils/filesearch/crawlCache.test.js +0 -103
  943. package/dist/src/utils/filesearch/crawlCache.test.js.map +0 -1
  944. package/dist/src/utils/filesearch/crawler.test.d.ts +0 -6
  945. package/dist/src/utils/filesearch/crawler.test.js +0 -495
  946. package/dist/src/utils/filesearch/crawler.test.js.map +0 -1
  947. package/dist/src/utils/filesearch/fileSearch.test.d.ts +0 -6
  948. package/dist/src/utils/filesearch/fileSearch.test.js +0 -663
  949. package/dist/src/utils/filesearch/fileSearch.test.js.map +0 -1
  950. package/dist/src/utils/filesearch/ignore.test.d.ts +0 -6
  951. package/dist/src/utils/filesearch/ignore.test.js +0 -144
  952. package/dist/src/utils/filesearch/ignore.test.js.map +0 -1
  953. package/dist/src/utils/filesearch/result-cache.test.d.ts +0 -6
  954. package/dist/src/utils/filesearch/result-cache.test.js +0 -46
  955. package/dist/src/utils/filesearch/result-cache.test.js.map +0 -1
  956. package/dist/src/utils/flashFallback.test.d.ts +0 -6
  957. package/dist/src/utils/flashFallback.test.js +0 -103
  958. package/dist/src/utils/flashFallback.test.js.map +0 -1
  959. package/dist/src/utils/formatters.test.d.ts +0 -6
  960. package/dist/src/utils/formatters.test.js +0 -26
  961. package/dist/src/utils/formatters.test.js.map +0 -1
  962. package/dist/src/utils/geminiIgnoreParser.test.d.ts +0 -6
  963. package/dist/src/utils/geminiIgnoreParser.test.js +0 -98
  964. package/dist/src/utils/geminiIgnoreParser.test.js.map +0 -1
  965. package/dist/src/utils/geminiTypeConversion.test.d.ts +0 -6
  966. package/dist/src/utils/geminiTypeConversion.test.js +0 -310
  967. package/dist/src/utils/geminiTypeConversion.test.js.map +0 -1
  968. package/dist/src/utils/generateContentResponseUtilities.test.d.ts +0 -6
  969. package/dist/src/utils/generateContentResponseUtilities.test.js +0 -512
  970. package/dist/src/utils/generateContentResponseUtilities.test.js.map +0 -1
  971. package/dist/src/utils/getFolderStructure.test.d.ts +0 -6
  972. package/dist/src/utils/getFolderStructure.test.js +0 -283
  973. package/dist/src/utils/getFolderStructure.test.js.map +0 -1
  974. package/dist/src/utils/gitIgnoreParser.test.d.ts +0 -6
  975. package/dist/src/utils/gitIgnoreParser.test.js +0 -243
  976. package/dist/src/utils/gitIgnoreParser.test.js.map +0 -1
  977. package/dist/src/utils/googleErrors.test.d.ts +0 -6
  978. package/dist/src/utils/googleErrors.test.js +0 -309
  979. package/dist/src/utils/googleErrors.test.js.map +0 -1
  980. package/dist/src/utils/googleQuotaErrors.test.d.ts +0 -6
  981. package/dist/src/utils/googleQuotaErrors.test.js +0 -548
  982. package/dist/src/utils/googleQuotaErrors.test.js.map +0 -1
  983. package/dist/src/utils/ignorePatterns.test.d.ts +0 -6
  984. package/dist/src/utils/ignorePatterns.test.js +0 -246
  985. package/dist/src/utils/ignorePatterns.test.js.map +0 -1
  986. package/dist/src/utils/installationManager.test.d.ts +0 -6
  987. package/dist/src/utils/installationManager.test.js +0 -93
  988. package/dist/src/utils/installationManager.test.js.map +0 -1
  989. package/dist/src/utils/llm-edit-fixer.test.d.ts +0 -6
  990. package/dist/src/utils/llm-edit-fixer.test.js +0 -223
  991. package/dist/src/utils/llm-edit-fixer.test.js.map +0 -1
  992. package/dist/src/utils/llmUtils.test.d.ts +0 -6
  993. package/dist/src/utils/llmUtils.test.js +0 -196
  994. package/dist/src/utils/llmUtils.test.js.map +0 -1
  995. package/dist/src/utils/memoryDiscovery.test.d.ts +0 -6
  996. package/dist/src/utils/memoryDiscovery.test.js +0 -542
  997. package/dist/src/utils/memoryDiscovery.test.js.map +0 -1
  998. package/dist/src/utils/memoryImportProcessor.test.d.ts +0 -6
  999. package/dist/src/utils/memoryImportProcessor.test.js +0 -581
  1000. package/dist/src/utils/memoryImportProcessor.test.js.map +0 -1
  1001. package/dist/src/utils/nextSpeakerChecker.test.d.ts +0 -6
  1002. package/dist/src/utils/nextSpeakerChecker.test.js +0 -191
  1003. package/dist/src/utils/nextSpeakerChecker.test.js.map +0 -1
  1004. package/dist/src/utils/partUtils.test.d.ts +0 -6
  1005. package/dist/src/utils/partUtils.test.js +0 -397
  1006. package/dist/src/utils/partUtils.test.js.map +0 -1
  1007. package/dist/src/utils/pathCorrector.test.d.ts +0 -6
  1008. package/dist/src/utils/pathCorrector.test.js +0 -87
  1009. package/dist/src/utils/pathCorrector.test.js.map +0 -1
  1010. package/dist/src/utils/pathReader.test.d.ts +0 -6
  1011. package/dist/src/utils/pathReader.test.js +0 -406
  1012. package/dist/src/utils/pathReader.test.js.map +0 -1
  1013. package/dist/src/utils/paths.test.d.ts +0 -6
  1014. package/dist/src/utils/paths.test.js +0 -402
  1015. package/dist/src/utils/paths.test.js.map +0 -1
  1016. package/dist/src/utils/retry.test.d.ts +0 -6
  1017. package/dist/src/utils/retry.test.js +0 -548
  1018. package/dist/src/utils/retry.test.js.map +0 -1
  1019. package/dist/src/utils/retry_llm_error.test.d.ts +0 -6
  1020. package/dist/src/utils/retry_llm_error.test.js +0 -280
  1021. package/dist/src/utils/retry_llm_error.test.js.map +0 -1
  1022. package/dist/src/utils/safeJsonStringify.test.d.ts +0 -6
  1023. package/dist/src/utils/safeJsonStringify.test.js +0 -61
  1024. package/dist/src/utils/safeJsonStringify.test.js.map +0 -1
  1025. package/dist/src/utils/schemaValidator.test.d.ts +0 -6
  1026. package/dist/src/utils/schemaValidator.test.js +0 -113
  1027. package/dist/src/utils/schemaValidator.test.js.map +0 -1
  1028. package/dist/src/utils/secure-browser-launcher.test.d.ts +0 -6
  1029. package/dist/src/utils/secure-browser-launcher.test.js +0 -149
  1030. package/dist/src/utils/secure-browser-launcher.test.js.map +0 -1
  1031. package/dist/src/utils/security.test.d.ts +0 -1
  1032. package/dist/src/utils/security.test.js +0 -121
  1033. package/dist/src/utils/security.test.js.map +0 -1
  1034. package/dist/src/utils/shell-utils.integration.test.d.ts +0 -1
  1035. package/dist/src/utils/shell-utils.integration.test.js +0 -58
  1036. package/dist/src/utils/shell-utils.integration.test.js.map +0 -1
  1037. package/dist/src/utils/shell-utils.test.d.ts +0 -6
  1038. package/dist/src/utils/shell-utils.test.js +0 -437
  1039. package/dist/src/utils/shell-utils.test.js.map +0 -1
  1040. package/dist/src/utils/stdio.test.d.ts +0 -6
  1041. package/dist/src/utils/stdio.test.js +0 -47
  1042. package/dist/src/utils/stdio.test.js.map +0 -1
  1043. package/dist/src/utils/summarizer.test.d.ts +0 -6
  1044. package/dist/src/utils/summarizer.test.js +0 -152
  1045. package/dist/src/utils/summarizer.test.js.map +0 -1
  1046. package/dist/src/utils/systemEncoding.test.d.ts +0 -6
  1047. package/dist/src/utils/systemEncoding.test.js +0 -369
  1048. package/dist/src/utils/systemEncoding.test.js.map +0 -1
  1049. package/dist/src/utils/terminalSerializer.test.d.ts +0 -6
  1050. package/dist/src/utils/terminalSerializer.test.js +0 -193
  1051. package/dist/src/utils/terminalSerializer.test.js.map +0 -1
  1052. package/dist/src/utils/textUtils.test.d.ts +0 -6
  1053. package/dist/src/utils/textUtils.test.js +0 -76
  1054. package/dist/src/utils/textUtils.test.js.map +0 -1
  1055. package/dist/src/utils/thoughtUtils.test.d.ts +0 -6
  1056. package/dist/src/utils/thoughtUtils.test.js +0 -78
  1057. package/dist/src/utils/thoughtUtils.test.js.map +0 -1
  1058. package/dist/src/utils/tokenCalculation.test.d.ts +0 -6
  1059. package/dist/src/utils/tokenCalculation.test.js +0 -184
  1060. package/dist/src/utils/tokenCalculation.test.js.map +0 -1
  1061. package/dist/src/utils/tool-utils.test.d.ts +0 -6
  1062. package/dist/src/utils/tool-utils.test.js +0 -84
  1063. package/dist/src/utils/tool-utils.test.js.map +0 -1
  1064. package/dist/src/utils/toolCallContext.test.d.ts +0 -6
  1065. package/dist/src/utils/toolCallContext.test.js +0 -68
  1066. package/dist/src/utils/toolCallContext.test.js.map +0 -1
  1067. package/dist/src/utils/userAccountManager.test.d.ts +0 -6
  1068. package/dist/src/utils/userAccountManager.test.js +0 -225
  1069. package/dist/src/utils/userAccountManager.test.js.map +0 -1
  1070. package/dist/src/utils/version.test.d.ts +0 -6
  1071. package/dist/src/utils/version.test.js +0 -39
  1072. package/dist/src/utils/version.test.js.map +0 -1
  1073. package/dist/src/utils/workspaceContext.test.d.ts +0 -6
  1074. package/dist/src/utils/workspaceContext.test.js +0 -374
  1075. package/dist/src/utils/workspaceContext.test.js.map +0 -1
  1076. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,1773 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
7
- import { ApiError, ThinkingLevel } from '@google/genai';
8
- import { GeminiChat, InvalidStreamError, StreamEventType, SYNTHETIC_THOUGHT_SIGNATURE, } from './geminiChat.js';
9
- import { setSimulate429 } from '../utils/testUtils.js';
10
- import { DEFAULT_THINKING_MODE } from '../config/models.js';
11
- import { AuthType } from './contentGenerator.js';
12
- import { TerminalQuotaError } from '../utils/googleQuotaErrors.js';
13
- import {} from '../utils/retry.js';
14
- import { uiTelemetryService } from '../telemetry/uiTelemetry.js';
15
- import { createMockMessageBus } from '../test-utils/mock-message-bus.js';
16
- import { createAvailabilityServiceMock } from '../availability/testUtils.js';
17
- import * as policyHelpers from '../availability/policyHelpers.js';
18
- import { makeResolvedModelConfig } from '../services/modelConfigServiceTestUtils.js';
19
- // Mock fs module to prevent actual file system operations during tests
20
- const mockFileSystem = new Map();
21
- vi.mock('node:fs', () => {
22
- const fsModule = {
23
- mkdirSync: vi.fn(),
24
- writeFileSync: vi.fn((path, data) => {
25
- mockFileSystem.set(path, data);
26
- }),
27
- readFileSync: vi.fn((path) => {
28
- if (mockFileSystem.has(path)) {
29
- return mockFileSystem.get(path);
30
- }
31
- throw Object.assign(new Error('ENOENT: no such file or directory'), {
32
- code: 'ENOENT',
33
- });
34
- }),
35
- existsSync: vi.fn((path) => mockFileSystem.has(path)),
36
- createWriteStream: vi.fn(() => ({
37
- write: vi.fn(),
38
- on: vi.fn(),
39
- })),
40
- };
41
- return {
42
- default: fsModule,
43
- ...fsModule,
44
- };
45
- });
46
- const { mockHandleFallback } = vi.hoisted(() => ({
47
- mockHandleFallback: vi.fn(),
48
- }));
49
- // Add mock for the retry utility
50
- const { mockRetryWithBackoff } = vi.hoisted(() => ({
51
- mockRetryWithBackoff: vi.fn(),
52
- }));
53
- vi.mock('../utils/retry.js', async (importOriginal) => {
54
- const actual = await importOriginal();
55
- return {
56
- ...actual,
57
- retryWithBackoff: mockRetryWithBackoff,
58
- };
59
- });
60
- vi.mock('../fallback/handler.js', () => ({
61
- handleFallback: mockHandleFallback,
62
- }));
63
- const { mockLogContentRetry, mockLogContentRetryFailure } = vi.hoisted(() => ({
64
- mockLogContentRetry: vi.fn(),
65
- mockLogContentRetryFailure: vi.fn(),
66
- }));
67
- vi.mock('../telemetry/loggers.js', () => ({
68
- logContentRetry: mockLogContentRetry,
69
- logContentRetryFailure: mockLogContentRetryFailure,
70
- }));
71
- vi.mock('../telemetry/uiTelemetry.js', () => ({
72
- uiTelemetryService: {
73
- setLastPromptTokenCount: vi.fn(),
74
- },
75
- }));
76
- describe('GeminiChat', () => {
77
- let mockContentGenerator;
78
- let chat;
79
- let mockConfig;
80
- beforeEach(() => {
81
- vi.clearAllMocks();
82
- vi.mocked(uiTelemetryService.setLastPromptTokenCount).mockClear();
83
- mockContentGenerator = {
84
- generateContent: vi.fn(),
85
- generateContentStream: vi.fn(),
86
- countTokens: vi.fn(),
87
- embedContent: vi.fn(),
88
- batchEmbedContents: vi.fn(),
89
- };
90
- mockHandleFallback.mockClear();
91
- // Default mock implementation for tests that don't care about retry logic
92
- mockRetryWithBackoff.mockImplementation(async (apiCall, options) => {
93
- const result = await apiCall();
94
- const context = options?.getAvailabilityContext?.();
95
- if (context) {
96
- context.service.markHealthy(context.policy.model);
97
- }
98
- return result;
99
- });
100
- let currentModel = 'gemini-pro';
101
- let currentActiveModel = 'gemini-pro';
102
- mockConfig = {
103
- getSessionId: () => 'test-session-id',
104
- getTelemetryLogPromptsEnabled: () => true,
105
- getUsageStatisticsEnabled: () => true,
106
- getDebugMode: () => false,
107
- getPreviewFeatures: () => false,
108
- getContentGeneratorConfig: vi.fn().mockImplementation(() => ({
109
- authType: 'oauth-personal',
110
- model: currentModel,
111
- })),
112
- getModel: vi.fn().mockImplementation(() => currentModel),
113
- setModel: vi.fn().mockImplementation((m) => {
114
- currentModel = m;
115
- // When model is explicitly set, active model usually resets or updates to it
116
- currentActiveModel = m;
117
- }),
118
- getQuotaErrorOccurred: vi.fn().mockReturnValue(false),
119
- setQuotaErrorOccurred: vi.fn(),
120
- flashFallbackHandler: undefined,
121
- getProjectRoot: vi.fn().mockReturnValue('/test/project/root'),
122
- storage: {
123
- getProjectTempDir: vi.fn().mockReturnValue('/test/temp'),
124
- },
125
- getToolRegistry: vi.fn().mockReturnValue({
126
- getTool: vi.fn(),
127
- }),
128
- getContentGenerator: vi.fn().mockReturnValue(mockContentGenerator),
129
- getRetryFetchErrors: vi.fn().mockReturnValue(false),
130
- getUserTier: vi.fn().mockReturnValue(undefined),
131
- modelConfigService: {
132
- getResolvedConfig: vi.fn().mockImplementation((modelConfigKey) => {
133
- const model = modelConfigKey.model ?? mockConfig.getModel();
134
- const thinkingConfig = model.startsWith('gemini-3')
135
- ? {
136
- thinkingLevel: ThinkingLevel.HIGH,
137
- }
138
- : {
139
- thinkingBudget: DEFAULT_THINKING_MODE,
140
- };
141
- return {
142
- model,
143
- generateContentConfig: {
144
- temperature: modelConfigKey.isRetry ? 1 : 0,
145
- thinkingConfig,
146
- },
147
- };
148
- }),
149
- },
150
- isInteractive: vi.fn().mockReturnValue(false),
151
- getEnableHooks: vi.fn().mockReturnValue(false),
152
- getActiveModel: vi.fn().mockImplementation(() => currentActiveModel),
153
- setActiveModel: vi
154
- .fn()
155
- .mockImplementation((m) => (currentActiveModel = m)),
156
- getModelAvailabilityService: vi
157
- .fn()
158
- .mockReturnValue(createAvailabilityServiceMock()),
159
- };
160
- // Use proper MessageBus mocking for Phase 3 preparation
161
- const mockMessageBus = createMockMessageBus();
162
- mockConfig.getMessageBus = vi.fn().mockReturnValue(mockMessageBus);
163
- // Disable 429 simulation for tests
164
- setSimulate429(false);
165
- // Reset history for each test by creating a new instance
166
- chat = new GeminiChat(mockConfig);
167
- mockConfig.getHookSystem = vi.fn().mockReturnValue(undefined);
168
- });
169
- afterEach(() => {
170
- vi.restoreAllMocks();
171
- vi.resetAllMocks();
172
- });
173
- describe('constructor', () => {
174
- it('should initialize lastPromptTokenCount based on history size', () => {
175
- const history = [
176
- { role: 'user', parts: [{ text: 'Hello' }] },
177
- { role: 'model', parts: [{ text: 'Hi there' }] },
178
- ];
179
- const chatWithHistory = new GeminiChat(mockConfig, '', [], history);
180
- // 'Hello': 5 chars * 0.25 = 1.25
181
- // 'Hi there': 8 chars * 0.25 = 2.0
182
- // Total: 3.25 -> floor(3.25) = 3
183
- expect(chatWithHistory.getLastPromptTokenCount()).toBe(3);
184
- });
185
- it('should initialize lastPromptTokenCount for empty history', () => {
186
- const chatEmpty = new GeminiChat(mockConfig);
187
- expect(chatEmpty.getLastPromptTokenCount()).toBe(0);
188
- });
189
- });
190
- describe('setHistory', () => {
191
- it('should recalculate lastPromptTokenCount when history is updated', () => {
192
- const initialHistory = [
193
- { role: 'user', parts: [{ text: 'Hello' }] },
194
- ];
195
- const chatWithHistory = new GeminiChat(mockConfig, '', [], initialHistory);
196
- const initialCount = chatWithHistory.getLastPromptTokenCount();
197
- const newHistory = [
198
- {
199
- role: 'user',
200
- parts: [
201
- {
202
- text: 'This is a much longer history item that should result in more tokens than just hello.',
203
- },
204
- ],
205
- },
206
- ];
207
- chatWithHistory.setHistory(newHistory);
208
- expect(chatWithHistory.getLastPromptTokenCount()).toBeGreaterThan(initialCount);
209
- });
210
- });
211
- describe('sendMessageStream', () => {
212
- it('should succeed if a tool call is followed by an empty part', async () => {
213
- // 1. Mock a stream that contains a tool call, then an invalid (empty) part.
214
- const streamWithToolCall = (async function* () {
215
- yield {
216
- candidates: [
217
- {
218
- content: {
219
- role: 'model',
220
- parts: [{ functionCall: { name: 'test_tool', args: {} } }],
221
- },
222
- },
223
- ],
224
- };
225
- // This second chunk is invalid according to isValidResponse
226
- yield {
227
- candidates: [
228
- {
229
- content: {
230
- role: 'model',
231
- parts: [{ text: '' }],
232
- },
233
- },
234
- ],
235
- };
236
- })();
237
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(streamWithToolCall);
238
- // 2. Action & Assert: The stream processing should complete without throwing an error
239
- // because the presence of a tool call makes the empty final chunk acceptable.
240
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'test message', 'prompt-id-tool-call-empty-end', new AbortController().signal);
241
- await expect((async () => {
242
- for await (const _ of stream) {
243
- /* consume stream */
244
- }
245
- })()).resolves.not.toThrow();
246
- // 3. Verify history was recorded correctly
247
- const history = chat.getHistory();
248
- expect(history.length).toBe(2); // user turn + model turn
249
- const modelTurn = history[1];
250
- expect(modelTurn?.parts?.length).toBe(1); // The empty part is discarded
251
- expect(modelTurn?.parts[0].functionCall).toBeDefined();
252
- });
253
- it('should fail if the stream ends with an empty part and has no finishReason', async () => {
254
- // 1. Mock a stream that ends with an invalid part and has no finish reason.
255
- const streamWithNoFinish = (async function* () {
256
- yield {
257
- candidates: [
258
- {
259
- content: {
260
- role: 'model',
261
- parts: [{ text: 'Initial content...' }],
262
- },
263
- },
264
- ],
265
- };
266
- // This second chunk is invalid and has no finishReason, so it should fail.
267
- yield {
268
- candidates: [
269
- {
270
- content: {
271
- role: 'model',
272
- parts: [{ text: '' }],
273
- },
274
- },
275
- ],
276
- };
277
- })();
278
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(streamWithNoFinish);
279
- // 2. Action & Assert: The stream should fail because there's no finish reason.
280
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'test message', 'prompt-id-no-finish-empty-end', new AbortController().signal);
281
- await expect((async () => {
282
- for await (const _ of stream) {
283
- /* consume stream */
284
- }
285
- })()).rejects.toThrow(InvalidStreamError);
286
- });
287
- it('should succeed if the stream ends with an invalid part but has a finishReason and contained a valid part', async () => {
288
- // 1. Mock a stream that sends a valid chunk, then an invalid one, but has a finish reason.
289
- const streamWithInvalidEnd = (async function* () {
290
- yield {
291
- candidates: [
292
- {
293
- content: {
294
- role: 'model',
295
- parts: [{ text: 'Initial valid content...' }],
296
- },
297
- },
298
- ],
299
- };
300
- // This second chunk is invalid, but the response has a finishReason.
301
- yield {
302
- candidates: [
303
- {
304
- content: {
305
- role: 'model',
306
- parts: [{ text: '' }], // Invalid part
307
- },
308
- finishReason: 'STOP',
309
- },
310
- ],
311
- };
312
- })();
313
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(streamWithInvalidEnd);
314
- // 2. Action & Assert: The stream should complete without throwing an error.
315
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'test message', 'prompt-id-valid-then-invalid-end', new AbortController().signal);
316
- await expect((async () => {
317
- for await (const _ of stream) {
318
- /* consume stream */
319
- }
320
- })()).resolves.not.toThrow();
321
- // 3. Verify history was recorded correctly with only the valid part.
322
- const history = chat.getHistory();
323
- expect(history.length).toBe(2); // user turn + model turn
324
- const modelTurn = history[1];
325
- expect(modelTurn?.parts?.length).toBe(1);
326
- expect(modelTurn?.parts[0].text).toBe('Initial valid content...');
327
- });
328
- it('should consolidate subsequent text chunks after receiving an empty text chunk', async () => {
329
- // 1. Mock the API to return a stream where one chunk is just an empty text part.
330
- const multiChunkStream = (async function* () {
331
- yield {
332
- candidates: [
333
- { content: { role: 'model', parts: [{ text: 'Hello' }] } },
334
- ],
335
- };
336
- // FIX: The original test used { text: '' }, which is invalid.
337
- // A chunk can be empty but still valid. This chunk is now removed
338
- // as the important part is consolidating what comes after.
339
- yield {
340
- candidates: [
341
- {
342
- content: { role: 'model', parts: [{ text: ' World!' }] },
343
- finishReason: 'STOP',
344
- },
345
- ],
346
- };
347
- })();
348
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(multiChunkStream);
349
- // 2. Action: Send a message and consume the stream.
350
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'test message', 'prompt-id-empty-chunk-consolidation', new AbortController().signal);
351
- for await (const _ of stream) {
352
- // Consume the stream
353
- }
354
- // 3. Assert: Check that the final history was correctly consolidated.
355
- const history = chat.getHistory();
356
- expect(history.length).toBe(2);
357
- const modelTurn = history[1];
358
- expect(modelTurn?.parts?.length).toBe(1);
359
- expect(modelTurn?.parts[0].text).toBe('Hello World!');
360
- });
361
- it('should consolidate adjacent text parts that arrive in separate stream chunks', async () => {
362
- // 1. Mock the API to return a stream of multiple, adjacent text chunks.
363
- const multiChunkStream = (async function* () {
364
- yield {
365
- candidates: [
366
- { content: { role: 'model', parts: [{ text: 'This is the ' }] } },
367
- ],
368
- };
369
- yield {
370
- candidates: [
371
- { content: { role: 'model', parts: [{ text: 'first part.' }] } },
372
- ],
373
- };
374
- // This function call should break the consolidation.
375
- yield {
376
- candidates: [
377
- {
378
- content: {
379
- role: 'model',
380
- parts: [{ functionCall: { name: 'do_stuff', args: {} } }],
381
- },
382
- },
383
- ],
384
- };
385
- yield {
386
- candidates: [
387
- {
388
- content: {
389
- role: 'model',
390
- parts: [{ text: 'This is the second part.' }],
391
- },
392
- },
393
- ],
394
- };
395
- })();
396
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(multiChunkStream);
397
- // 2. Action: Send a message and consume the stream.
398
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'test message', 'prompt-id-multi-chunk', new AbortController().signal);
399
- for await (const _ of stream) {
400
- // Consume the stream to trigger history recording.
401
- }
402
- // 3. Assert: Check that the final history was correctly consolidated.
403
- const history = chat.getHistory();
404
- // The history should contain the user's turn and ONE consolidated model turn.
405
- expect(history.length).toBe(2);
406
- const modelTurn = history[1];
407
- expect(modelTurn.role).toBe('model');
408
- // The model turn should have 3 distinct parts: the merged text, the function call, and the final text.
409
- expect(modelTurn?.parts?.length).toBe(3);
410
- expect(modelTurn?.parts[0].text).toBe('This is the first part.');
411
- expect(modelTurn.parts[1].functionCall).toBeDefined();
412
- expect(modelTurn.parts[2].text).toBe('This is the second part.');
413
- });
414
- it('should preserve text parts that stream in the same chunk as a thought', async () => {
415
- // 1. Mock the API to return a single chunk containing both a thought and visible text.
416
- const mixedContentStream = (async function* () {
417
- yield {
418
- candidates: [
419
- {
420
- content: {
421
- role: 'model',
422
- parts: [
423
- { thought: 'This is a thought.' },
424
- { text: 'This is the visible text that should not be lost.' },
425
- ],
426
- },
427
- finishReason: 'STOP',
428
- },
429
- ],
430
- };
431
- })();
432
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(mixedContentStream);
433
- // 2. Action: Send a message and fully consume the stream to trigger history recording.
434
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'test message', 'prompt-id-mixed-chunk', new AbortController().signal);
435
- for await (const _ of stream) {
436
- // This loop consumes the stream.
437
- }
438
- // 3. Assert: Check the final state of the history.
439
- const history = chat.getHistory();
440
- // The history should contain two turns: the user's message and the model's response.
441
- expect(history.length).toBe(2);
442
- const modelTurn = history[1];
443
- expect(modelTurn.role).toBe('model');
444
- // CRUCIAL ASSERTION:
445
- // The buggy code would fail here, resulting in parts.length being 0.
446
- // The corrected code will pass, preserving the single visible text part.
447
- expect(modelTurn?.parts?.length).toBe(1);
448
- expect(modelTurn?.parts[0].text).toBe('This is the visible text that should not be lost.');
449
- });
450
- it('should throw an error when a tool call is followed by an empty stream response', async () => {
451
- // 1. Setup: A history where the model has just made a function call.
452
- const initialHistory = [
453
- {
454
- role: 'user',
455
- parts: [{ text: 'Find a good Italian restaurant for me.' }],
456
- },
457
- {
458
- role: 'model',
459
- parts: [
460
- {
461
- functionCall: {
462
- name: 'find_restaurant',
463
- args: { cuisine: 'Italian' },
464
- },
465
- },
466
- ],
467
- },
468
- ];
469
- chat.setHistory(initialHistory);
470
- // 2. Mock the API to return an empty/thought-only stream.
471
- const emptyStreamResponse = (async function* () {
472
- yield {
473
- candidates: [
474
- {
475
- content: { role: 'model', parts: [{ thought: true }] },
476
- finishReason: 'STOP',
477
- },
478
- ],
479
- };
480
- })();
481
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(emptyStreamResponse);
482
- // 3. Action: Send the function response back to the model and consume the stream.
483
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, {
484
- functionResponse: {
485
- name: 'find_restaurant',
486
- response: { name: 'Vesuvio' },
487
- },
488
- }, 'prompt-id-stream-1', new AbortController().signal);
489
- // 4. Assert: The stream processing should throw an InvalidStreamError.
490
- await expect((async () => {
491
- for await (const _ of stream) {
492
- // This loop consumes the stream to trigger the internal logic.
493
- }
494
- })()).rejects.toThrow(InvalidStreamError);
495
- });
496
- it('should succeed when there is a tool call without finish reason', async () => {
497
- // Setup: Stream with tool call but no finish reason
498
- const streamWithToolCall = (async function* () {
499
- yield {
500
- candidates: [
501
- {
502
- content: {
503
- role: 'model',
504
- parts: [
505
- {
506
- functionCall: {
507
- name: 'test_function',
508
- args: { param: 'value' },
509
- },
510
- },
511
- ],
512
- },
513
- // No finishReason
514
- },
515
- ],
516
- };
517
- })();
518
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(streamWithToolCall);
519
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'test message', 'prompt-id-1', new AbortController().signal);
520
- // Should not throw an error
521
- await expect((async () => {
522
- for await (const _ of stream) {
523
- // consume stream
524
- }
525
- })()).resolves.not.toThrow();
526
- });
527
- it('should throw InvalidStreamError when no tool call and no finish reason', async () => {
528
- // Setup: Stream with text but no finish reason and no tool call
529
- const streamWithoutFinishReason = (async function* () {
530
- yield {
531
- candidates: [
532
- {
533
- content: {
534
- role: 'model',
535
- parts: [{ text: 'some response' }],
536
- },
537
- // No finishReason
538
- },
539
- ],
540
- };
541
- })();
542
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(streamWithoutFinishReason);
543
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'test message', 'prompt-id-1', new AbortController().signal);
544
- await expect((async () => {
545
- for await (const _ of stream) {
546
- // consume stream
547
- }
548
- })()).rejects.toThrow(InvalidStreamError);
549
- });
550
- it('should throw InvalidStreamError when no tool call and empty response text', async () => {
551
- // Setup: Stream with finish reason but empty response (only thoughts)
552
- const streamWithEmptyResponse = (async function* () {
553
- yield {
554
- candidates: [
555
- {
556
- content: {
557
- role: 'model',
558
- parts: [{ thought: 'thinking...' }],
559
- },
560
- finishReason: 'STOP',
561
- },
562
- ],
563
- };
564
- })();
565
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(streamWithEmptyResponse);
566
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'test message', 'prompt-id-1', new AbortController().signal);
567
- await expect((async () => {
568
- for await (const _ of stream) {
569
- // consume stream
570
- }
571
- })()).rejects.toThrow(InvalidStreamError);
572
- });
573
- it('should succeed when there is finish reason and response text', async () => {
574
- // Setup: Stream with both finish reason and text content
575
- const validStream = (async function* () {
576
- yield {
577
- candidates: [
578
- {
579
- content: {
580
- role: 'model',
581
- parts: [{ text: 'valid response' }],
582
- },
583
- finishReason: 'STOP',
584
- },
585
- ],
586
- };
587
- })();
588
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(validStream);
589
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'test message', 'prompt-id-1', new AbortController().signal);
590
- // Should not throw an error
591
- await expect((async () => {
592
- for await (const _ of stream) {
593
- // consume stream
594
- }
595
- })()).resolves.not.toThrow();
596
- });
597
- it('should throw InvalidStreamError when finishReason is MALFORMED_FUNCTION_CALL', async () => {
598
- // Setup: Stream with MALFORMED_FUNCTION_CALL finish reason and empty response
599
- const streamWithMalformedFunctionCall = (async function* () {
600
- yield {
601
- candidates: [
602
- {
603
- content: {
604
- role: 'model',
605
- parts: [], // Empty parts
606
- },
607
- finishReason: 'MALFORMED_FUNCTION_CALL',
608
- },
609
- ],
610
- };
611
- })();
612
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(streamWithMalformedFunctionCall);
613
- const stream = await chat.sendMessageStream({ model: 'gemini-2.5-pro' }, 'test', 'prompt-id-malformed', new AbortController().signal);
614
- // Should throw an error
615
- await expect((async () => {
616
- for await (const _ of stream) {
617
- // consume stream
618
- }
619
- })()).rejects.toThrow(InvalidStreamError);
620
- });
621
- it('should retry when finishReason is MALFORMED_FUNCTION_CALL', async () => {
622
- // 1. Mock the API to fail once with MALFORMED_FUNCTION_CALL, then succeed.
623
- vi.mocked(mockContentGenerator.generateContentStream)
624
- .mockImplementationOnce(async () => (async function* () {
625
- yield {
626
- candidates: [
627
- {
628
- content: { parts: [], role: 'model' },
629
- finishReason: 'MALFORMED_FUNCTION_CALL',
630
- },
631
- ],
632
- };
633
- })())
634
- .mockImplementationOnce(async () =>
635
- // Second attempt succeeds
636
- (async function* () {
637
- yield {
638
- candidates: [
639
- {
640
- content: { parts: [{ text: 'Success after retry' }] },
641
- finishReason: 'STOP',
642
- },
643
- ],
644
- };
645
- })());
646
- // 2. Send a message
647
- const stream = await chat.sendMessageStream({ model: 'gemini-2.5-pro' }, 'test retry', 'prompt-id-retry-malformed', new AbortController().signal);
648
- const events = [];
649
- for await (const event of stream) {
650
- events.push(event);
651
- }
652
- // 3. Assertions
653
- // Should be called twice (initial + retry)
654
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(2);
655
- // Check for a retry event
656
- expect(events.some((e) => e.type === StreamEventType.RETRY)).toBe(true);
657
- // Check for the successful content chunk
658
- expect(events.some((e) => e.type === StreamEventType.CHUNK &&
659
- e.value.candidates?.[0]?.content?.parts?.[0]?.text ===
660
- 'Success after retry')).toBe(true);
661
- });
662
- it('should call generateContentStream with the correct parameters', async () => {
663
- const response = (async function* () {
664
- yield {
665
- candidates: [
666
- {
667
- content: {
668
- parts: [{ text: 'response' }],
669
- role: 'model',
670
- },
671
- finishReason: 'STOP',
672
- index: 0,
673
- safetyRatings: [],
674
- },
675
- ],
676
- text: () => 'response',
677
- usageMetadata: {
678
- promptTokenCount: 42,
679
- candidatesTokenCount: 15,
680
- totalTokenCount: 57,
681
- },
682
- };
683
- })();
684
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(response);
685
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'hello', 'prompt-id-1', new AbortController().signal);
686
- for await (const _ of stream) {
687
- // consume stream
688
- }
689
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledWith({
690
- model: 'test-model',
691
- contents: [
692
- {
693
- role: 'user',
694
- parts: [{ text: 'hello' }],
695
- },
696
- ],
697
- config: {
698
- systemInstruction: '',
699
- tools: [],
700
- temperature: 0,
701
- thinkingConfig: {
702
- thinkingBudget: DEFAULT_THINKING_MODE,
703
- },
704
- abortSignal: expect.any(AbortSignal),
705
- },
706
- }, 'prompt-id-1');
707
- });
708
- it('should use thinkingLevel and remove thinkingBudget for gemini-3 models', async () => {
709
- const response = (async function* () {
710
- yield {
711
- candidates: [
712
- {
713
- content: { parts: [{ text: 'response' }], role: 'model' },
714
- finishReason: 'STOP',
715
- },
716
- ],
717
- };
718
- })();
719
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(response);
720
- const stream = await chat.sendMessageStream({ model: 'gemini-3-test-only-model-string-for-testing' }, 'hello', 'prompt-id-thinking-level', new AbortController().signal);
721
- for await (const _ of stream) {
722
- // consume stream
723
- }
724
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledWith(expect.objectContaining({
725
- model: 'gemini-3-test-only-model-string-for-testing',
726
- config: expect.objectContaining({
727
- thinkingConfig: {
728
- thinkingBudget: undefined,
729
- thinkingLevel: ThinkingLevel.HIGH,
730
- },
731
- }),
732
- }), 'prompt-id-thinking-level');
733
- });
734
- it('should use thinkingBudget and remove thinkingLevel for non-gemini-3 models', async () => {
735
- const response = (async function* () {
736
- yield {
737
- candidates: [
738
- {
739
- content: { parts: [{ text: 'response' }], role: 'model' },
740
- finishReason: 'STOP',
741
- },
742
- ],
743
- };
744
- })();
745
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue(response);
746
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'hello', 'prompt-id-thinking-budget', new AbortController().signal);
747
- for await (const _ of stream) {
748
- // consume stream
749
- }
750
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledWith(expect.objectContaining({
751
- model: 'gemini-2.0-flash',
752
- config: expect.objectContaining({
753
- thinkingConfig: {
754
- thinkingBudget: DEFAULT_THINKING_MODE,
755
- thinkingLevel: undefined,
756
- },
757
- }),
758
- }), 'prompt-id-thinking-budget');
759
- });
760
- });
761
- describe('addHistory', () => {
762
- it('should add a new content item to the history', () => {
763
- const newContent = {
764
- role: 'user',
765
- parts: [{ text: 'A new message' }],
766
- };
767
- chat.addHistory(newContent);
768
- const history = chat.getHistory();
769
- expect(history.length).toBe(1);
770
- expect(history[0]).toEqual(newContent);
771
- });
772
- it('should add multiple items correctly', () => {
773
- const content1 = {
774
- role: 'user',
775
- parts: [{ text: 'Message 1' }],
776
- };
777
- const content2 = {
778
- role: 'model',
779
- parts: [{ text: 'Message 2' }],
780
- };
781
- chat.addHistory(content1);
782
- chat.addHistory(content2);
783
- const history = chat.getHistory();
784
- expect(history.length).toBe(2);
785
- expect(history[0]).toEqual(content1);
786
- expect(history[1]).toEqual(content2);
787
- });
788
- });
789
- describe('sendMessageStream with retries', () => {
790
- it('should not retry on invalid content if model does not start with gemini-2', async () => {
791
- // Mock the stream to fail.
792
- vi.mocked(mockContentGenerator.generateContentStream).mockImplementation(async () => (async function* () {
793
- yield {
794
- candidates: [{ content: { parts: [{ text: '' }] } }],
795
- };
796
- })());
797
- const stream = await chat.sendMessageStream({ model: 'gemini-1.5-pro' }, 'test', 'prompt-id-no-retry', new AbortController().signal);
798
- await expect((async () => {
799
- for await (const _ of stream) {
800
- // Must loop to trigger the internal logic that throws.
801
- }
802
- })()).rejects.toThrow(InvalidStreamError);
803
- // Should be called only 1 time (no retry)
804
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(1);
805
- expect(mockLogContentRetry).not.toHaveBeenCalled();
806
- });
807
- it('should yield a RETRY event when an invalid stream is encountered', async () => {
808
- // ARRANGE: Mock the stream to fail once, then succeed.
809
- vi.mocked(mockContentGenerator.generateContentStream)
810
- .mockImplementationOnce(async () =>
811
- // First attempt: An invalid stream with an empty text part.
812
- (async function* () {
813
- yield {
814
- candidates: [{ content: { parts: [{ text: '' }] } }],
815
- };
816
- })())
817
- .mockImplementationOnce(async () =>
818
- // Second attempt (the retry): A minimal valid stream.
819
- (async function* () {
820
- yield {
821
- candidates: [
822
- {
823
- content: { parts: [{ text: 'Success' }] },
824
- finishReason: 'STOP',
825
- },
826
- ],
827
- };
828
- })());
829
- // ACT: Send a message and collect all events from the stream.
830
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'test message', 'prompt-id-yield-retry', new AbortController().signal);
831
- const events = [];
832
- for await (const event of stream) {
833
- events.push(event);
834
- }
835
- // ASSERT: Check that a RETRY event was present in the stream's output.
836
- const retryEvent = events.find((e) => e.type === StreamEventType.RETRY);
837
- expect(retryEvent).toBeDefined();
838
- expect(retryEvent?.type).toBe(StreamEventType.RETRY);
839
- });
840
- it('should retry on invalid content, succeed, and report metrics', async () => {
841
- // Use mockImplementationOnce to provide a fresh, promise-wrapped generator for each attempt.
842
- vi.mocked(mockContentGenerator.generateContentStream)
843
- .mockImplementationOnce(async () =>
844
- // First call returns an invalid stream
845
- (async function* () {
846
- yield {
847
- candidates: [{ content: { parts: [{ text: '' }] } }], // Invalid empty text part
848
- };
849
- })())
850
- .mockImplementationOnce(async () =>
851
- // Second call returns a valid stream
852
- (async function* () {
853
- yield {
854
- candidates: [
855
- {
856
- content: { parts: [{ text: 'Successful response' }] },
857
- finishReason: 'STOP',
858
- },
859
- ],
860
- };
861
- })());
862
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'test', 'prompt-id-retry-success', new AbortController().signal);
863
- const chunks = [];
864
- for await (const chunk of stream) {
865
- chunks.push(chunk);
866
- }
867
- // Assertions
868
- expect(mockLogContentRetry).toHaveBeenCalledTimes(1);
869
- expect(mockLogContentRetryFailure).not.toHaveBeenCalled();
870
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(2);
871
- // Check for a retry event
872
- expect(chunks.some((c) => c.type === StreamEventType.RETRY)).toBe(true);
873
- // Check for the successful content chunk
874
- expect(chunks.some((c) => c.type === StreamEventType.CHUNK &&
875
- c.value.candidates?.[0]?.content?.parts?.[0]?.text ===
876
- 'Successful response')).toBe(true);
877
- // Check that history was recorded correctly once, with no duplicates.
878
- const history = chat.getHistory();
879
- expect(history.length).toBe(2);
880
- expect(history[0]).toEqual({
881
- role: 'user',
882
- parts: [{ text: 'test' }],
883
- });
884
- expect(history[1]).toEqual({
885
- role: 'model',
886
- parts: [{ text: 'Successful response' }],
887
- });
888
- // Verify that token counting is not called when usageMetadata is missing
889
- expect(uiTelemetryService.setLastPromptTokenCount).not.toHaveBeenCalled();
890
- });
891
- it('should set temperature to 1 on retry', async () => {
892
- // Use mockImplementationOnce to provide a fresh, promise-wrapped generator for each attempt.
893
- vi.mocked(mockContentGenerator.generateContentStream)
894
- .mockImplementationOnce(async () =>
895
- // First call returns an invalid stream
896
- (async function* () {
897
- yield {
898
- candidates: [{ content: { parts: [{ text: '' }] } }], // Invalid empty text part
899
- };
900
- })())
901
- .mockImplementationOnce(async () =>
902
- // Second call returns a valid stream
903
- (async function* () {
904
- yield {
905
- candidates: [
906
- {
907
- content: { parts: [{ text: 'Successful response' }] },
908
- finishReason: 'STOP',
909
- },
910
- ],
911
- };
912
- })());
913
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'test message', 'prompt-id-retry-temperature', new AbortController().signal);
914
- for await (const _ of stream) {
915
- // consume stream
916
- }
917
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(2);
918
- // First call should have original temperature
919
- expect(mockContentGenerator.generateContentStream).toHaveBeenNthCalledWith(1, expect.objectContaining({
920
- config: expect.objectContaining({
921
- temperature: 0,
922
- }),
923
- }), 'prompt-id-retry-temperature');
924
- // Second call (retry) should have temperature 1
925
- expect(mockContentGenerator.generateContentStream).toHaveBeenNthCalledWith(2, expect.objectContaining({
926
- config: expect.objectContaining({
927
- temperature: 1,
928
- }),
929
- }), 'prompt-id-retry-temperature');
930
- });
931
- it('should fail after all retries on persistent invalid content and report metrics', async () => {
932
- vi.mocked(mockContentGenerator.generateContentStream).mockImplementation(async () => (async function* () {
933
- yield {
934
- candidates: [
935
- {
936
- content: {
937
- parts: [{ text: '' }],
938
- role: 'model',
939
- },
940
- },
941
- ],
942
- };
943
- })());
944
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'test', 'prompt-id-retry-fail', new AbortController().signal);
945
- await expect(async () => {
946
- for await (const _ of stream) {
947
- // Must loop to trigger the internal logic that throws.
948
- }
949
- }).rejects.toThrow(InvalidStreamError);
950
- // Should be called 2 times (initial + 1 retry)
951
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(2);
952
- expect(mockLogContentRetry).toHaveBeenCalledTimes(1);
953
- expect(mockLogContentRetryFailure).toHaveBeenCalledTimes(1);
954
- // History should still contain the user message.
955
- const history = chat.getHistory();
956
- expect(history.length).toBe(1);
957
- expect(history[0]).toEqual({
958
- role: 'user',
959
- parts: [{ text: 'test' }],
960
- });
961
- });
962
- describe('API error retry behavior', () => {
963
- beforeEach(() => {
964
- // Use a more direct mock for retry testing
965
- mockRetryWithBackoff.mockImplementation(async (apiCall) => {
966
- try {
967
- return await apiCall();
968
- }
969
- catch (error) {
970
- // Simulate the logic of defaultShouldRetry for ApiError
971
- let shouldRetry = false;
972
- if (error instanceof ApiError && error.message) {
973
- if (error.status === 429 ||
974
- (error.status >= 500 && error.status < 600)) {
975
- shouldRetry = true;
976
- }
977
- // Explicitly don't retry on these
978
- if (error.status === 400) {
979
- shouldRetry = false;
980
- }
981
- }
982
- if (shouldRetry) {
983
- // Try again
984
- return await apiCall();
985
- }
986
- throw error;
987
- }
988
- });
989
- });
990
- it('should not retry on 400 Bad Request errors', async () => {
991
- const error400 = new ApiError({ message: 'Bad Request', status: 400 });
992
- vi.mocked(mockContentGenerator.generateContentStream).mockRejectedValue(error400);
993
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'test message', 'prompt-id-400', new AbortController().signal);
994
- await expect((async () => {
995
- for await (const _ of stream) {
996
- /* consume stream */
997
- }
998
- })()).rejects.toThrow(error400);
999
- // Should only be called once (no retry)
1000
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(1);
1001
- });
1002
- it('should retry on 429 Rate Limit errors', async () => {
1003
- const error429 = new ApiError({ message: 'Rate Limited', status: 429 });
1004
- vi.mocked(mockContentGenerator.generateContentStream)
1005
- .mockRejectedValueOnce(error429)
1006
- .mockResolvedValueOnce((async function* () {
1007
- yield {
1008
- candidates: [
1009
- {
1010
- content: { parts: [{ text: 'Success after retry' }] },
1011
- finishReason: 'STOP',
1012
- },
1013
- ],
1014
- };
1015
- })());
1016
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'test message', 'prompt-id-429-retry', new AbortController().signal);
1017
- const events = [];
1018
- for await (const event of stream) {
1019
- events.push(event);
1020
- }
1021
- // Should be called twice (initial + retry)
1022
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(2);
1023
- // Should have successful content
1024
- expect(events.some((e) => e.type === StreamEventType.CHUNK &&
1025
- e.value.candidates?.[0]?.content?.parts?.[0]?.text ===
1026
- 'Success after retry')).toBe(true);
1027
- });
1028
- it('should retry on 5xx server errors', async () => {
1029
- const error500 = new ApiError({
1030
- message: 'Internal Server Error 500',
1031
- status: 500,
1032
- });
1033
- vi.mocked(mockContentGenerator.generateContentStream)
1034
- .mockRejectedValueOnce(error500)
1035
- .mockResolvedValueOnce((async function* () {
1036
- yield {
1037
- candidates: [
1038
- {
1039
- content: { parts: [{ text: 'Recovered from 500' }] },
1040
- finishReason: 'STOP',
1041
- },
1042
- ],
1043
- };
1044
- })());
1045
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'test message', 'prompt-id-500-retry', new AbortController().signal);
1046
- const events = [];
1047
- for await (const event of stream) {
1048
- events.push(event);
1049
- }
1050
- // Should be called twice (initial + retry)
1051
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(2);
1052
- });
1053
- it('should retry on specific fetch errors when configured', async () => {
1054
- vi.mocked(mockConfig.getRetryFetchErrors).mockReturnValue(true);
1055
- const fetchError = new Error('exception TypeError: fetch failed sending request');
1056
- vi.mocked(mockContentGenerator.generateContentStream)
1057
- .mockRejectedValueOnce(fetchError)
1058
- .mockResolvedValueOnce((async function* () {
1059
- yield {
1060
- candidates: [
1061
- {
1062
- content: { parts: [{ text: 'Success after fetch error' }] },
1063
- finishReason: 'STOP',
1064
- },
1065
- ],
1066
- };
1067
- })());
1068
- mockRetryWithBackoff.mockImplementation(async (apiCall, options) => {
1069
- try {
1070
- return await apiCall();
1071
- }
1072
- catch (error) {
1073
- if (options?.retryFetchErrors &&
1074
- error instanceof Error &&
1075
- error.message.includes('exception TypeError: fetch failed sending request')) {
1076
- return await apiCall();
1077
- }
1078
- throw error;
1079
- }
1080
- });
1081
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'test message', 'prompt-id-fetch-error-retry', new AbortController().signal);
1082
- const events = [];
1083
- for await (const event of stream) {
1084
- events.push(event);
1085
- }
1086
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(2);
1087
- expect(events.some((e) => e.type === StreamEventType.CHUNK &&
1088
- e.value.candidates?.[0]?.content?.parts?.[0]?.text ===
1089
- 'Success after fetch error')).toBe(true);
1090
- });
1091
- afterEach(() => {
1092
- // Reset to default behavior
1093
- mockRetryWithBackoff.mockImplementation(async (apiCall) => apiCall());
1094
- });
1095
- });
1096
- });
1097
- it('should correctly retry and append to an existing history mid-conversation', async () => {
1098
- // 1. Setup
1099
- const initialHistory = [
1100
- { role: 'user', parts: [{ text: 'First question' }] },
1101
- { role: 'model', parts: [{ text: 'First answer' }] },
1102
- ];
1103
- chat.setHistory(initialHistory);
1104
- // 2. Mock the API to fail once with an empty stream, then succeed.
1105
- vi.mocked(mockContentGenerator.generateContentStream)
1106
- .mockImplementationOnce(async () => (async function* () {
1107
- yield {
1108
- candidates: [{ content: { parts: [{ text: '' }] } }],
1109
- };
1110
- })())
1111
- .mockImplementationOnce(async () =>
1112
- // Second attempt succeeds
1113
- (async function* () {
1114
- yield {
1115
- candidates: [
1116
- {
1117
- content: { parts: [{ text: 'Second answer' }] },
1118
- finishReason: 'STOP',
1119
- },
1120
- ],
1121
- };
1122
- })());
1123
- // 3. Send a new message
1124
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'Second question', 'prompt-id-retry-existing', new AbortController().signal);
1125
- for await (const _ of stream) {
1126
- // consume stream
1127
- }
1128
- // 4. Assert the final history and metrics
1129
- const history = chat.getHistory();
1130
- expect(history.length).toBe(4);
1131
- // Assert that the correct metrics were reported for one empty-stream retry
1132
- expect(mockLogContentRetry).toHaveBeenCalledTimes(1);
1133
- // Explicitly verify the structure of each part to satisfy TypeScript
1134
- const turn1 = history[0];
1135
- if (!turn1?.parts?.[0] || !('text' in turn1.parts[0])) {
1136
- throw new Error('Test setup error: First turn is not a valid text part.');
1137
- }
1138
- expect(turn1.parts[0].text).toBe('First question');
1139
- const turn2 = history[1];
1140
- if (!turn2?.parts?.[0] || !('text' in turn2.parts[0])) {
1141
- throw new Error('Test setup error: Second turn is not a valid text part.');
1142
- }
1143
- expect(turn2.parts[0].text).toBe('First answer');
1144
- const turn3 = history[2];
1145
- if (!turn3?.parts?.[0] || !('text' in turn3.parts[0])) {
1146
- throw new Error('Test setup error: Third turn is not a valid text part.');
1147
- }
1148
- expect(turn3.parts[0].text).toBe('Second question');
1149
- const turn4 = history[3];
1150
- if (!turn4?.parts?.[0] || !('text' in turn4.parts[0])) {
1151
- throw new Error('Test setup error: Fourth turn is not a valid text part.');
1152
- }
1153
- expect(turn4.parts[0].text).toBe('Second answer');
1154
- });
1155
- it('should retry if the model returns a completely empty stream (no chunks)', async () => {
1156
- // 1. Mock the API to return an empty stream first, then a valid one.
1157
- vi.mocked(mockContentGenerator.generateContentStream)
1158
- .mockImplementationOnce(
1159
- // First call resolves to an async generator that yields nothing.
1160
- async () => (async function* () { })())
1161
- .mockImplementationOnce(
1162
- // Second call returns a valid stream.
1163
- async () => (async function* () {
1164
- yield {
1165
- candidates: [
1166
- {
1167
- content: {
1168
- parts: [{ text: 'Successful response after empty' }],
1169
- },
1170
- finishReason: 'STOP',
1171
- },
1172
- ],
1173
- };
1174
- })());
1175
- // 2. Call the method and consume the stream.
1176
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'test empty stream', 'prompt-id-empty-stream', new AbortController().signal);
1177
- const chunks = [];
1178
- for await (const chunk of stream) {
1179
- chunks.push(chunk);
1180
- }
1181
- // 3. Assert the results.
1182
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(2);
1183
- expect(chunks.some((c) => c.type === StreamEventType.CHUNK &&
1184
- c.value.candidates?.[0]?.content?.parts?.[0]?.text ===
1185
- 'Successful response after empty')).toBe(true);
1186
- const history = chat.getHistory();
1187
- expect(history.length).toBe(2);
1188
- // Explicitly verify the structure of each part to satisfy TypeScript
1189
- const turn1 = history[0];
1190
- if (!turn1?.parts?.[0] || !('text' in turn1.parts[0])) {
1191
- throw new Error('Test setup error: First turn is not a valid text part.');
1192
- }
1193
- expect(turn1.parts[0].text).toBe('test empty stream');
1194
- const turn2 = history[1];
1195
- if (!turn2?.parts?.[0] || !('text' in turn2.parts[0])) {
1196
- throw new Error('Test setup error: Second turn is not a valid text part.');
1197
- }
1198
- expect(turn2.parts[0].text).toBe('Successful response after empty');
1199
- });
1200
- it('should queue a subsequent sendMessageStream call until the first stream is fully consumed', async () => {
1201
- // 1. Create a promise to manually control the stream's lifecycle
1202
- let continueFirstStream;
1203
- const firstStreamContinuePromise = new Promise((resolve) => {
1204
- continueFirstStream = resolve;
1205
- });
1206
- // 2. Mock the API to return controllable async generators
1207
- const firstStreamGenerator = (async function* () {
1208
- yield {
1209
- candidates: [
1210
- { content: { parts: [{ text: 'first response part 1' }] } },
1211
- ],
1212
- };
1213
- await firstStreamContinuePromise; // Pause the stream
1214
- yield {
1215
- candidates: [
1216
- {
1217
- content: { parts: [{ text: ' part 2' }] },
1218
- finishReason: 'STOP',
1219
- },
1220
- ],
1221
- };
1222
- })();
1223
- const secondStreamGenerator = (async function* () {
1224
- yield {
1225
- candidates: [
1226
- {
1227
- content: { parts: [{ text: 'second response' }] },
1228
- finishReason: 'STOP',
1229
- },
1230
- ],
1231
- };
1232
- })();
1233
- vi.mocked(mockContentGenerator.generateContentStream)
1234
- .mockResolvedValueOnce(firstStreamGenerator)
1235
- .mockResolvedValueOnce(secondStreamGenerator);
1236
- // 3. Start the first stream and consume only the first chunk to pause it
1237
- const firstStream = await chat.sendMessageStream({ model: 'test-model' }, 'first', 'prompt-1', new AbortController().signal);
1238
- const firstStreamIterator = firstStream[Symbol.asyncIterator]();
1239
- await firstStreamIterator.next();
1240
- // 4. While the first stream is paused, start the second call. It will block.
1241
- const secondStreamPromise = chat.sendMessageStream({ model: 'test-model' }, 'second', 'prompt-2', new AbortController().signal);
1242
- // 5. Assert that only one API call has been made so far.
1243
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(1);
1244
- // 6. Unblock and fully consume the first stream to completion.
1245
- continueFirstStream();
1246
- await firstStreamIterator.next(); // Consume the rest of the stream
1247
- await firstStreamIterator.next(); // Finish the iterator
1248
- // 7. Now that the first stream is done, await the second promise to get its generator.
1249
- const secondStream = await secondStreamPromise;
1250
- // 8. Start consuming the second stream, which triggers its internal API call.
1251
- const secondStreamIterator = secondStream[Symbol.asyncIterator]();
1252
- await secondStreamIterator.next();
1253
- // 9. The second API call should now have been made.
1254
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(2);
1255
- // 10. FIX: Fully consume the second stream to ensure recordHistory is called.
1256
- await secondStreamIterator.next(); // This finishes the iterator.
1257
- // 11. Final check on history.
1258
- const history = chat.getHistory();
1259
- expect(history.length).toBe(4);
1260
- const turn4 = history[3];
1261
- if (!turn4?.parts?.[0] || !('text' in turn4.parts[0])) {
1262
- throw new Error('Test setup error: Fourth turn is not a valid text part.');
1263
- }
1264
- expect(turn4.parts[0].text).toBe('second response');
1265
- });
1266
- describe('Fallback Integration (Retries)', () => {
1267
- const error429 = new ApiError({
1268
- message: 'API Error 429: Quota exceeded',
1269
- status: 429,
1270
- });
1271
- // Define the simulated behavior for retryWithBackoff for these tests.
1272
- // This simulation tries the apiCall, if it fails, it calls the callback,
1273
- // and then tries the apiCall again if the callback returns true.
1274
- const simulateRetryBehavior = async (apiCall, options) => {
1275
- try {
1276
- return await apiCall();
1277
- }
1278
- catch (error) {
1279
- if (options.onPersistent429) {
1280
- // We simulate the "persistent" trigger here for simplicity.
1281
- const shouldRetry = await options.onPersistent429(options.authType, error);
1282
- if (shouldRetry) {
1283
- return apiCall();
1284
- }
1285
- }
1286
- throw error; // Stop if callback returns false/null or doesn't exist
1287
- }
1288
- };
1289
- beforeEach(() => {
1290
- mockRetryWithBackoff.mockImplementation(simulateRetryBehavior);
1291
- });
1292
- afterEach(() => {
1293
- mockRetryWithBackoff.mockImplementation(async (apiCall) => apiCall());
1294
- });
1295
- it('should call handleFallback with the specific failed model and retry if handler returns true', async () => {
1296
- const authType = AuthType.LOGIN_WITH_GOOGLE;
1297
- vi.mocked(mockConfig.getContentGeneratorConfig).mockReturnValue({
1298
- authType,
1299
- });
1300
- vi.mocked(mockContentGenerator.generateContentStream)
1301
- .mockRejectedValueOnce(error429) // Attempt 1 fails
1302
- .mockResolvedValueOnce(
1303
- // Attempt 2 succeeds
1304
- (async function* () {
1305
- yield {
1306
- candidates: [
1307
- {
1308
- content: { parts: [{ text: 'Success on retry' }] },
1309
- finishReason: 'STOP',
1310
- },
1311
- ],
1312
- };
1313
- })());
1314
- mockHandleFallback.mockImplementation(async () => true);
1315
- const stream = await chat.sendMessageStream({ model: 'test-model' }, 'trigger 429', 'prompt-id-fb1', new AbortController().signal);
1316
- // Consume stream to trigger logic
1317
- for await (const _ of stream) {
1318
- // no-op
1319
- }
1320
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(2);
1321
- expect(mockHandleFallback).toHaveBeenCalledTimes(1);
1322
- expect(mockHandleFallback).toHaveBeenCalledWith(mockConfig, 'test-model', authType, error429);
1323
- const history = chat.getHistory();
1324
- const modelTurn = history[1];
1325
- expect(modelTurn.parts[0].text).toBe('Success on retry');
1326
- });
1327
- });
1328
- it('should discard valid partial content from a failed attempt upon retry', async () => {
1329
- // Mock the stream to fail on the first attempt after yielding some valid content.
1330
- vi.mocked(mockContentGenerator.generateContentStream)
1331
- .mockImplementationOnce(async () =>
1332
- // First attempt: yields one valid chunk, then one invalid chunk
1333
- (async function* () {
1334
- yield {
1335
- candidates: [
1336
- {
1337
- content: {
1338
- parts: [{ text: 'This valid part should be discarded' }],
1339
- },
1340
- },
1341
- ],
1342
- };
1343
- yield {
1344
- candidates: [{ content: { parts: [{ text: '' }] } }], // Invalid chunk triggers retry
1345
- };
1346
- })())
1347
- .mockImplementationOnce(async () =>
1348
- // Second attempt (the retry): succeeds
1349
- (async function* () {
1350
- yield {
1351
- candidates: [
1352
- {
1353
- content: {
1354
- parts: [{ text: 'Successful final response' }],
1355
- },
1356
- finishReason: 'STOP',
1357
- },
1358
- ],
1359
- };
1360
- })());
1361
- // Send a message and consume the stream
1362
- const stream = await chat.sendMessageStream({ model: 'gemini-2.0-flash' }, 'test message', 'prompt-id-discard-test', new AbortController().signal);
1363
- const events = [];
1364
- for await (const event of stream) {
1365
- events.push(event);
1366
- }
1367
- // Check that a retry happened
1368
- expect(mockContentGenerator.generateContentStream).toHaveBeenCalledTimes(2);
1369
- expect(events.some((e) => e.type === StreamEventType.RETRY)).toBe(true);
1370
- // Check the final recorded history
1371
- const history = chat.getHistory();
1372
- expect(history.length).toBe(2); // user turn + final model turn
1373
- const modelTurn = history[1];
1374
- // The model turn should only contain the text from the successful attempt
1375
- expect(modelTurn.parts[0].text).toBe('Successful final response');
1376
- // It should NOT contain any text from the failed attempt
1377
- expect(modelTurn.parts[0].text).not.toContain('This valid part should be discarded');
1378
- });
1379
- describe('stripThoughtsFromHistory', () => {
1380
- it('should strip thought signatures', () => {
1381
- chat.setHistory([
1382
- {
1383
- role: 'user',
1384
- parts: [{ text: 'hello' }],
1385
- },
1386
- {
1387
- role: 'model',
1388
- parts: [
1389
- { text: 'thinking...', thoughtSignature: 'thought-123' },
1390
- {
1391
- functionCall: { name: 'test', args: {} },
1392
- thoughtSignature: 'thought-456',
1393
- },
1394
- ],
1395
- },
1396
- ]);
1397
- chat.stripThoughtsFromHistory();
1398
- expect(chat.getHistory()).toEqual([
1399
- {
1400
- role: 'user',
1401
- parts: [{ text: 'hello' }],
1402
- },
1403
- {
1404
- role: 'model',
1405
- parts: [
1406
- { text: 'thinking...' },
1407
- { functionCall: { name: 'test', args: {} } },
1408
- ],
1409
- },
1410
- ]);
1411
- });
1412
- });
1413
- describe('ensureActiveLoopHasThoughtSignatures', () => {
1414
- it('should add thoughtSignature to the first functionCall in each model turn of the active loop', () => {
1415
- const chat = new GeminiChat(mockConfig, '', [], []);
1416
- const history = [
1417
- { role: 'user', parts: [{ text: 'Old message' }] },
1418
- {
1419
- role: 'model',
1420
- parts: [{ functionCall: { name: 'old_tool', args: {} } }],
1421
- },
1422
- { role: 'user', parts: [{ text: 'Find a restaurant' }] }, // active loop starts here
1423
- {
1424
- role: 'model',
1425
- parts: [
1426
- { functionCall: { name: 'find_restaurant', args: {} } }, // This one gets a signature
1427
- { functionCall: { name: 'find_restaurant_2', args: {} } }, // This one does NOT
1428
- ],
1429
- },
1430
- {
1431
- role: 'user',
1432
- parts: [
1433
- { functionResponse: { name: 'find_restaurant', response: {} } },
1434
- ],
1435
- },
1436
- {
1437
- role: 'model',
1438
- parts: [
1439
- {
1440
- functionCall: { name: 'tool_with_sig', args: {} },
1441
- thoughtSignature: 'existing-sig',
1442
- },
1443
- { functionCall: { name: 'another_tool', args: {} } }, // This one does NOT get a signature
1444
- ],
1445
- },
1446
- ];
1447
- const newContents = chat.ensureActiveLoopHasThoughtSignatures(history);
1448
- // Outside active loop - unchanged
1449
- expect(newContents[1]?.parts?.[0]).not.toHaveProperty('thoughtSignature');
1450
- // Inside active loop, first model turn
1451
- // First function call gets a signature
1452
- expect(newContents[3]?.parts?.[0]?.thoughtSignature).toBe(SYNTHETIC_THOUGHT_SIGNATURE);
1453
- // Second function call does NOT
1454
- expect(newContents[3]?.parts?.[1]).not.toHaveProperty('thoughtSignature');
1455
- // User functionResponse part - unchanged (this is not a model turn)
1456
- expect(newContents[4]?.parts?.[0]).not.toHaveProperty('thoughtSignature');
1457
- // Inside active loop, second model turn
1458
- // First function call already has a signature, so nothing changes
1459
- expect(newContents[5]?.parts?.[0]?.thoughtSignature).toBe('existing-sig');
1460
- // Second function call does NOT get a signature
1461
- expect(newContents[5]?.parts?.[1]).not.toHaveProperty('thoughtSignature');
1462
- });
1463
- it('should not modify contents if there is no user text message', () => {
1464
- const chat = new GeminiChat(mockConfig, '', [], []);
1465
- const history = [
1466
- {
1467
- role: 'user',
1468
- parts: [{ functionResponse: { name: 'tool1', response: {} } }],
1469
- },
1470
- {
1471
- role: 'model',
1472
- parts: [{ functionCall: { name: 'tool2', args: {} } }],
1473
- },
1474
- ];
1475
- const newContents = chat.ensureActiveLoopHasThoughtSignatures(history);
1476
- expect(newContents).toEqual(history);
1477
- expect(newContents[1]?.parts?.[0]).not.toHaveProperty('thoughtSignature');
1478
- });
1479
- it('should handle an empty history', () => {
1480
- const chat = new GeminiChat(mockConfig, '', []);
1481
- const history = [];
1482
- const newContents = chat.ensureActiveLoopHasThoughtSignatures(history);
1483
- expect(newContents).toEqual([]);
1484
- });
1485
- it('should handle history with only a user message', () => {
1486
- const chat = new GeminiChat(mockConfig, '', []);
1487
- const history = [{ role: 'user', parts: [{ text: 'Hello' }] }];
1488
- const newContents = chat.ensureActiveLoopHasThoughtSignatures(history);
1489
- expect(newContents).toEqual(history);
1490
- });
1491
- });
1492
- describe('Availability Service Integration', () => {
1493
- let mockAvailabilityService;
1494
- beforeEach(async () => {
1495
- mockAvailabilityService = createAvailabilityServiceMock();
1496
- vi.mocked(mockConfig.getModelAvailabilityService).mockReturnValue(mockAvailabilityService);
1497
- // Stateful mock for activeModel
1498
- let activeModel = 'model-a';
1499
- vi.mocked(mockConfig.getActiveModel).mockImplementation(() => activeModel);
1500
- vi.mocked(mockConfig.setActiveModel).mockImplementation((model) => {
1501
- activeModel = model;
1502
- });
1503
- vi.spyOn(policyHelpers, 'resolvePolicyChain').mockReturnValue([
1504
- {
1505
- model: 'model-a',
1506
- isLastResort: false,
1507
- actions: {},
1508
- stateTransitions: {},
1509
- },
1510
- {
1511
- model: 'model-b',
1512
- isLastResort: false,
1513
- actions: {},
1514
- stateTransitions: {},
1515
- },
1516
- {
1517
- model: 'model-c',
1518
- isLastResort: true,
1519
- actions: {},
1520
- stateTransitions: {},
1521
- },
1522
- ]);
1523
- });
1524
- it('should mark healthy on successful stream', async () => {
1525
- vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
1526
- selectedModel: 'model-b',
1527
- skipped: [],
1528
- });
1529
- // Simulate selection happening upstream
1530
- mockConfig.setActiveModel('model-b');
1531
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue((async function* () {
1532
- yield {
1533
- candidates: [
1534
- {
1535
- content: { parts: [{ text: 'Response' }], role: 'model' },
1536
- finishReason: 'STOP',
1537
- },
1538
- ],
1539
- };
1540
- })());
1541
- const stream = await chat.sendMessageStream({ model: 'gemini-pro' }, 'test', 'prompt-healthy', new AbortController().signal);
1542
- for await (const _ of stream) {
1543
- // consume
1544
- }
1545
- expect(mockAvailabilityService.markHealthy).toHaveBeenCalledWith('model-b');
1546
- });
1547
- it('caps retries to a single attempt when selection is sticky', async () => {
1548
- vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
1549
- selectedModel: 'model-a',
1550
- attempts: 1,
1551
- skipped: [],
1552
- });
1553
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue((async function* () {
1554
- yield {
1555
- candidates: [
1556
- {
1557
- content: { parts: [{ text: 'Response' }], role: 'model' },
1558
- finishReason: 'STOP',
1559
- },
1560
- ],
1561
- };
1562
- })());
1563
- const stream = await chat.sendMessageStream({ model: 'gemini-pro' }, 'test', 'prompt-sticky-once', new AbortController().signal);
1564
- for await (const _ of stream) {
1565
- // consume
1566
- }
1567
- expect(mockRetryWithBackoff).toHaveBeenCalledWith(expect.any(Function), expect.objectContaining({ maxAttempts: 1 }));
1568
- expect(mockAvailabilityService.consumeStickyAttempt).toHaveBeenCalledWith('model-a');
1569
- });
1570
- it('should pass attempted model to onPersistent429 callback which calls handleFallback', async () => {
1571
- vi.mocked(mockAvailabilityService.selectFirstAvailable).mockReturnValue({
1572
- selectedModel: 'model-a',
1573
- skipped: [],
1574
- });
1575
- // Simulate selection happening upstream
1576
- mockConfig.setActiveModel('model-a');
1577
- // Simulate retry logic behavior: catch error, call onPersistent429
1578
- const error = new TerminalQuotaError('Quota', {
1579
- code: 429,
1580
- message: 'quota',
1581
- details: [],
1582
- });
1583
- vi.mocked(mockContentGenerator.generateContentStream).mockRejectedValue(error);
1584
- // We need retryWithBackoff to trigger the callback
1585
- mockRetryWithBackoff.mockImplementation(async (apiCall, options) => {
1586
- try {
1587
- await apiCall();
1588
- }
1589
- catch (e) {
1590
- if (options?.onPersistent429) {
1591
- await options.onPersistent429(AuthType.LOGIN_WITH_GOOGLE, e);
1592
- }
1593
- throw e; // throw anyway to end test
1594
- }
1595
- });
1596
- const consume = async () => {
1597
- const stream = await chat.sendMessageStream({ model: 'gemini-pro' }, 'test', 'prompt-fallback-arg', new AbortController().signal);
1598
- for await (const _ of stream) {
1599
- // consume
1600
- }
1601
- };
1602
- await expect(consume()).rejects.toThrow();
1603
- // handleFallback is called with the ATTEMPTED model (model-a), not the requested one (gemini-pro)
1604
- expect(mockHandleFallback).toHaveBeenCalledWith(expect.anything(), 'model-a', expect.anything(), error);
1605
- });
1606
- it('re-resolves generateContentConfig when active model changes between retries', async () => {
1607
- // Availability enabled with stateful active model
1608
- let activeModel = 'model-a';
1609
- vi.mocked(mockConfig.getActiveModel).mockImplementation(() => activeModel);
1610
- vi.mocked(mockConfig.setActiveModel).mockImplementation((model) => {
1611
- activeModel = model;
1612
- });
1613
- // Different configs per model
1614
- vi.mocked(mockConfig.modelConfigService.getResolvedConfig).mockImplementation((key) => {
1615
- if (key.model === 'model-a') {
1616
- return makeResolvedModelConfig('model-a', { temperature: 0.1 });
1617
- }
1618
- if (key.model === 'model-b') {
1619
- return makeResolvedModelConfig('model-b', { temperature: 0.9 });
1620
- }
1621
- // Default for the initial requested model in this test
1622
- return makeResolvedModelConfig('model-a', { temperature: 0.1 });
1623
- });
1624
- // First attempt uses model-a, then simulate availability switching to model-b
1625
- mockRetryWithBackoff.mockImplementation(async (apiCall) => {
1626
- await apiCall(); // first attempt
1627
- activeModel = 'model-b'; // simulate switch before retry
1628
- return apiCall(); // second attempt
1629
- });
1630
- // Generators for each attempt
1631
- const firstResponse = (async function* () {
1632
- yield {
1633
- candidates: [
1634
- {
1635
- content: { parts: [{ text: 'first' }], role: 'model' },
1636
- finishReason: 'STOP',
1637
- },
1638
- ],
1639
- };
1640
- })();
1641
- const secondResponse = (async function* () {
1642
- yield {
1643
- candidates: [
1644
- {
1645
- content: { parts: [{ text: 'second' }], role: 'model' },
1646
- finishReason: 'STOP',
1647
- },
1648
- ],
1649
- };
1650
- })();
1651
- vi.mocked(mockContentGenerator.generateContentStream)
1652
- .mockResolvedValueOnce(firstResponse)
1653
- .mockResolvedValueOnce(secondResponse);
1654
- const stream = await chat.sendMessageStream({ model: 'gemini-pro' }, 'test', 'prompt-config-refresh', new AbortController().signal);
1655
- // Consume to drive both attempts
1656
- for await (const _ of stream) {
1657
- // consume
1658
- }
1659
- expect(mockContentGenerator.generateContentStream).toHaveBeenNthCalledWith(1, expect.objectContaining({
1660
- model: 'model-a',
1661
- config: expect.objectContaining({ temperature: 0.1 }),
1662
- }), expect.any(String));
1663
- expect(mockContentGenerator.generateContentStream).toHaveBeenNthCalledWith(2, expect.objectContaining({
1664
- model: 'model-b',
1665
- config: expect.objectContaining({ temperature: 0.9 }),
1666
- }), expect.any(String));
1667
- });
1668
- });
1669
- describe('Hook execution control', () => {
1670
- let mockHookSystem;
1671
- beforeEach(() => {
1672
- vi.mocked(mockConfig.getEnableHooks).mockReturnValue(true);
1673
- mockHookSystem = {
1674
- fireBeforeModelEvent: vi.fn().mockResolvedValue({ blocked: false }),
1675
- fireAfterModelEvent: vi.fn().mockResolvedValue({ response: {} }),
1676
- fireBeforeToolSelectionEvent: vi.fn().mockResolvedValue({}),
1677
- };
1678
- mockConfig.getHookSystem = vi.fn().mockReturnValue(mockHookSystem);
1679
- });
1680
- it('should yield AGENT_EXECUTION_STOPPED when BeforeModel hook stops execution', async () => {
1681
- vi.mocked(mockHookSystem.fireBeforeModelEvent).mockResolvedValue({
1682
- blocked: true,
1683
- stopped: true,
1684
- reason: 'stopped by hook',
1685
- });
1686
- const stream = await chat.sendMessageStream({ model: 'gemini-pro' }, 'test', 'prompt-id', new AbortController().signal);
1687
- const events = [];
1688
- for await (const event of stream) {
1689
- events.push(event);
1690
- }
1691
- expect(events).toHaveLength(1);
1692
- expect(events[0]).toEqual({
1693
- type: StreamEventType.AGENT_EXECUTION_STOPPED,
1694
- reason: 'stopped by hook',
1695
- });
1696
- });
1697
- it('should yield AGENT_EXECUTION_BLOCKED and synthetic response when BeforeModel hook blocks execution', async () => {
1698
- const syntheticResponse = {
1699
- candidates: [{ content: { parts: [{ text: 'blocked' }] } }],
1700
- };
1701
- vi.mocked(mockHookSystem.fireBeforeModelEvent).mockResolvedValue({
1702
- blocked: true,
1703
- reason: 'blocked by hook',
1704
- syntheticResponse,
1705
- });
1706
- const stream = await chat.sendMessageStream({ model: 'gemini-pro' }, 'test', 'prompt-id', new AbortController().signal);
1707
- const events = [];
1708
- for await (const event of stream) {
1709
- events.push(event);
1710
- }
1711
- expect(events).toHaveLength(2);
1712
- expect(events[0]).toEqual({
1713
- type: StreamEventType.AGENT_EXECUTION_BLOCKED,
1714
- reason: 'blocked by hook',
1715
- });
1716
- expect(events[1]).toEqual({
1717
- type: StreamEventType.CHUNK,
1718
- value: syntheticResponse,
1719
- });
1720
- });
1721
- it('should yield AGENT_EXECUTION_STOPPED when AfterModel hook stops execution', async () => {
1722
- // Mock content generator to return a stream
1723
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue((async function* () {
1724
- yield {
1725
- candidates: [{ content: { parts: [{ text: 'response' }] } }],
1726
- };
1727
- })());
1728
- vi.mocked(mockHookSystem.fireAfterModelEvent).mockResolvedValue({
1729
- response: {},
1730
- stopped: true,
1731
- reason: 'stopped by after hook',
1732
- });
1733
- const stream = await chat.sendMessageStream({ model: 'gemini-pro' }, 'test', 'prompt-id', new AbortController().signal);
1734
- const events = [];
1735
- for await (const event of stream) {
1736
- events.push(event);
1737
- }
1738
- expect(events).toContainEqual({
1739
- type: StreamEventType.AGENT_EXECUTION_STOPPED,
1740
- reason: 'stopped by after hook',
1741
- });
1742
- });
1743
- it('should yield AGENT_EXECUTION_BLOCKED and response when AfterModel hook blocks execution', async () => {
1744
- const response = {
1745
- candidates: [{ content: { parts: [{ text: 'response' }] } }],
1746
- };
1747
- // Mock content generator to return a stream
1748
- vi.mocked(mockContentGenerator.generateContentStream).mockResolvedValue((async function* () {
1749
- yield response;
1750
- })());
1751
- vi.mocked(mockHookSystem.fireAfterModelEvent).mockResolvedValue({
1752
- response,
1753
- blocked: true,
1754
- reason: 'blocked by after hook',
1755
- });
1756
- const stream = await chat.sendMessageStream({ model: 'gemini-pro' }, 'test', 'prompt-id', new AbortController().signal);
1757
- const events = [];
1758
- for await (const event of stream) {
1759
- events.push(event);
1760
- }
1761
- expect(events).toContainEqual({
1762
- type: StreamEventType.AGENT_EXECUTION_BLOCKED,
1763
- reason: 'blocked by after hook',
1764
- });
1765
- // Should also contain the chunk (hook response)
1766
- expect(events).toContainEqual({
1767
- type: StreamEventType.CHUNK,
1768
- value: response,
1769
- });
1770
- });
1771
- });
1772
- });
1773
- //# sourceMappingURL=geminiChat.test.js.map