centaurus-cli 2.5.2 → 2.5.3

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 (246) hide show
  1. package/AUTH_FLOW.md +138 -0
  2. package/CONFIG_GUIDE.md +249 -0
  3. package/dist/config/models.d.ts +1 -1
  4. package/dist/config/models.d.ts.map +1 -1
  5. package/dist/config/models.js +2 -0
  6. package/dist/config/models.js.map +1 -1
  7. package/dist/ui/components/App.d.ts.map +1 -1
  8. package/dist/ui/components/App.js +104 -62
  9. package/dist/ui/components/App.js.map +1 -1
  10. package/dist/ui/components/FontRecommendation.d.ts +1 -0
  11. package/dist/ui/components/FontRecommendation.d.ts.map +1 -0
  12. package/dist/ui/components/FontRecommendation.js +1 -0
  13. package/dist/ui/components/FontRecommendation.js.map +1 -0
  14. package/dist/ui/components/InputBox.d.ts.map +1 -1
  15. package/dist/ui/components/InputBox.js +3 -2
  16. package/dist/ui/components/InputBox.js.map +1 -1
  17. package/dist/ui/components/MarkdownRenderer.d.ts.map +1 -1
  18. package/dist/ui/components/MarkdownRenderer.js +34 -9
  19. package/dist/ui/components/MarkdownRenderer.js.map +1 -1
  20. package/dist/ui/components/MessageDisplay.js +2 -2
  21. package/dist/ui/components/StreamingMessageDisplay.d.ts.map +1 -1
  22. package/dist/ui/components/StreamingMessageDisplay.js +3 -3
  23. package/dist/ui/components/StreamingMessageDisplay.js.map +1 -1
  24. package/dist/ui/components/ThinkingDisplay.d.ts +13 -0
  25. package/dist/ui/components/ThinkingDisplay.d.ts.map +1 -0
  26. package/dist/ui/components/ThinkingDisplay.js +41 -0
  27. package/dist/ui/components/ThinkingDisplay.js.map +1 -0
  28. package/dist/utils/version-checker.d.ts.map +1 -1
  29. package/dist/utils/version-checker.js +3 -31
  30. package/dist/utils/version-checker.js.map +1 -1
  31. package/package.json +5 -5
  32. package/dist/ai/provider-factory.d.ts +0 -6
  33. package/dist/ai/provider-factory.d.ts.map +0 -1
  34. package/dist/ai/provider-factory.js +0 -27
  35. package/dist/ai/provider-factory.js.map +0 -1
  36. package/dist/ai/providers/base.d.ts +0 -25
  37. package/dist/ai/providers/base.d.ts.map +0 -1
  38. package/dist/ai/providers/base.js +0 -9
  39. package/dist/ai/providers/base.js.map +0 -1
  40. package/dist/ai/providers/gemini.d.ts +0 -34
  41. package/dist/ai/providers/gemini.d.ts.map +0 -1
  42. package/dist/ai/providers/gemini.js +0 -146
  43. package/dist/ai/providers/gemini.js.map +0 -1
  44. package/dist/commands/view-duplication-logs.d.ts +0 -5
  45. package/dist/commands/view-duplication-logs.d.ts.map +0 -1
  46. package/dist/commands/view-duplication-logs.js +0 -14
  47. package/dist/commands/view-duplication-logs.js.map +0 -1
  48. package/dist/context/__tests__/command-detector.test.d.ts +0 -14
  49. package/dist/context/__tests__/command-detector.test.d.ts.map +0 -1
  50. package/dist/context/__tests__/command-detector.test.js +0 -318
  51. package/dist/context/__tests__/command-detector.test.js.map +0 -1
  52. package/dist/context/__tests__/context-manager.test.d.ts +0 -16
  53. package/dist/context/__tests__/context-manager.test.d.ts.map +0 -1
  54. package/dist/context/__tests__/context-manager.test.js +0 -375
  55. package/dist/context/__tests__/context-manager.test.js.map +0 -1
  56. package/dist/context/__tests__/error-handling.test.d.ts +0 -15
  57. package/dist/context/__tests__/error-handling.test.d.ts.map +0 -1
  58. package/dist/context/__tests__/error-handling.test.js +0 -447
  59. package/dist/context/__tests__/error-handling.test.js.map +0 -1
  60. package/dist/context/handlers/__tests__/docker-handler.test.d.ts +0 -13
  61. package/dist/context/handlers/__tests__/docker-handler.test.d.ts.map +0 -1
  62. package/dist/context/handlers/__tests__/docker-handler.test.js +0 -285
  63. package/dist/context/handlers/__tests__/docker-handler.test.js.map +0 -1
  64. package/dist/context/handlers/__tests__/ssh-handler.test.d.ts +0 -13
  65. package/dist/context/handlers/__tests__/ssh-handler.test.d.ts.map +0 -1
  66. package/dist/context/handlers/__tests__/ssh-handler.test.js +0 -251
  67. package/dist/context/handlers/__tests__/ssh-handler.test.js.map +0 -1
  68. package/dist/context/handlers/__tests__/wsl-handler.test.d.ts +0 -7
  69. package/dist/context/handlers/__tests__/wsl-handler.test.d.ts.map +0 -1
  70. package/dist/context/handlers/__tests__/wsl-handler.test.js +0 -331
  71. package/dist/context/handlers/__tests__/wsl-handler.test.js.map +0 -1
  72. package/dist/index-custom.d.ts +0 -3
  73. package/dist/index-custom.d.ts.map +0 -1
  74. package/dist/index-custom.js +0 -65
  75. package/dist/index-custom.js.map +0 -1
  76. package/dist/prompts/system-prompt.d.ts +0 -47
  77. package/dist/prompts/system-prompt.d.ts.map +0 -1
  78. package/dist/prompts/system-prompt.js +0 -377
  79. package/dist/prompts/system-prompt.js.map +0 -1
  80. package/dist/providers/GoogleProvider.d.ts +0 -26
  81. package/dist/providers/GoogleProvider.d.ts.map +0 -1
  82. package/dist/providers/GoogleProvider.js +0 -313
  83. package/dist/providers/GoogleProvider.js.map +0 -1
  84. package/dist/providers/Provider.d.ts +0 -114
  85. package/dist/providers/Provider.d.ts.map +0 -1
  86. package/dist/providers/Provider.js +0 -44
  87. package/dist/providers/Provider.js.map +0 -1
  88. package/dist/services/__tests__/ai-context-injector.test.d.ts +0 -15
  89. package/dist/services/__tests__/ai-context-injector.test.d.ts.map +0 -1
  90. package/dist/services/__tests__/ai-context-injector.test.js +0 -326
  91. package/dist/services/__tests__/ai-context-injector.test.js.map +0 -1
  92. package/dist/src/context/types.js +0 -27
  93. package/dist/src/services/ai-context-injector.js +0 -96
  94. package/dist/src/services/ai-service-client.js +0 -270
  95. package/dist/src/services/api-client.js +0 -349
  96. package/dist/src/tools/types.js +0 -1
  97. package/dist/src/types/index.js +0 -1
  98. package/dist/test/context/types.js +0 -27
  99. package/dist/test/services/__tests__/ai-context-injector.test.js +0 -325
  100. package/dist/test/services/ai-context-injector.js +0 -96
  101. package/dist/test/services/ai-service-client.js +0 -270
  102. package/dist/test/services/api-client.js +0 -349
  103. package/dist/test/tools/types.js +0 -1
  104. package/dist/test/types/index.js +0 -1
  105. package/dist/test-ai-context-injector.js +0 -97
  106. package/dist/tests/automated-verification.d.ts +0 -27
  107. package/dist/tests/automated-verification.d.ts.map +0 -1
  108. package/dist/tests/automated-verification.js +0 -359
  109. package/dist/tests/automated-verification.js.map +0 -1
  110. package/dist/tests/integration-tests.d.ts +0 -50
  111. package/dist/tests/integration-tests.d.ts.map +0 -1
  112. package/dist/tests/integration-tests.js +0 -648
  113. package/dist/tests/integration-tests.js.map +0 -1
  114. package/dist/tools/file-ops-test.d.ts +0 -6
  115. package/dist/tools/file-ops-test.d.ts.map +0 -1
  116. package/dist/tools/file-ops-test.js +0 -197
  117. package/dist/tools/file-ops-test.js.map +0 -1
  118. package/dist/ui/DisplayHistory.d.ts +0 -53
  119. package/dist/ui/DisplayHistory.d.ts.map +0 -1
  120. package/dist/ui/DisplayHistory.js +0 -82
  121. package/dist/ui/DisplayHistory.js.map +0 -1
  122. package/dist/ui/clack-ui.d.ts +0 -83
  123. package/dist/ui/clack-ui.d.ts.map +0 -1
  124. package/dist/ui/clack-ui.js +0 -304
  125. package/dist/ui/clack-ui.js.map +0 -1
  126. package/dist/ui/components/DisplayItemRenderer.d.ts +0 -18
  127. package/dist/ui/components/DisplayItemRenderer.d.ts.map +0 -1
  128. package/dist/ui/components/DisplayItemRenderer.js +0 -53
  129. package/dist/ui/components/DisplayItemRenderer.js.map +0 -1
  130. package/dist/ui/components/DynamicMessage.d.ts +0 -13
  131. package/dist/ui/components/DynamicMessage.d.ts.map +0 -1
  132. package/dist/ui/components/DynamicMessage.js +0 -27
  133. package/dist/ui/components/DynamicMessage.js.map +0 -1
  134. package/dist/ui/components/FileViewerScreen.d.ts +0 -14
  135. package/dist/ui/components/FileViewerScreen.d.ts.map +0 -1
  136. package/dist/ui/components/FileViewerScreen.js +0 -74
  137. package/dist/ui/components/FileViewerScreen.js.map +0 -1
  138. package/dist/ui/components/ScrollableContent.d.ts +0 -7
  139. package/dist/ui/components/ScrollableContent.d.ts.map +0 -1
  140. package/dist/ui/components/ScrollableContent.js +0 -6
  141. package/dist/ui/components/ScrollableContent.js.map +0 -1
  142. package/dist/ui/components/ScrollableMessageList.d.ts +0 -10
  143. package/dist/ui/components/ScrollableMessageList.d.ts.map +0 -1
  144. package/dist/ui/components/ScrollableMessageList.js +0 -133
  145. package/dist/ui/components/ScrollableMessageList.js.map +0 -1
  146. package/dist/ui/components/ScrollableScreen.d.ts +0 -9
  147. package/dist/ui/components/ScrollableScreen.d.ts.map +0 -1
  148. package/dist/ui/components/ScrollableScreen.js +0 -22
  149. package/dist/ui/components/ScrollableScreen.js.map +0 -1
  150. package/dist/ui/components/StaticMessageHistory.d.ts +0 -14
  151. package/dist/ui/components/StaticMessageHistory.d.ts.map +0 -1
  152. package/dist/ui/components/StaticMessageHistory.js +0 -19
  153. package/dist/ui/components/StaticMessageHistory.js.map +0 -1
  154. package/dist/ui/components/code-block.d.ts +0 -10
  155. package/dist/ui/components/code-block.d.ts.map +0 -1
  156. package/dist/ui/components/code-block.js +0 -74
  157. package/dist/ui/components/code-block.js.map +0 -1
  158. package/dist/ui/components/confirm-prompt.d.ts +0 -12
  159. package/dist/ui/components/confirm-prompt.d.ts.map +0 -1
  160. package/dist/ui/components/confirm-prompt.js +0 -104
  161. package/dist/ui/components/confirm-prompt.js.map +0 -1
  162. package/dist/ui/components/diff-viewer.d.ts +0 -9
  163. package/dist/ui/components/diff-viewer.d.ts.map +0 -1
  164. package/dist/ui/components/diff-viewer.js +0 -57
  165. package/dist/ui/components/diff-viewer.js.map +0 -1
  166. package/dist/ui/components/input-box.d.ts +0 -18
  167. package/dist/ui/components/input-box.d.ts.map +0 -1
  168. package/dist/ui/components/input-box.js +0 -157
  169. package/dist/ui/components/input-box.js.map +0 -1
  170. package/dist/ui/components/keyboard-help.d.ts +0 -7
  171. package/dist/ui/components/keyboard-help.d.ts.map +0 -1
  172. package/dist/ui/components/keyboard-help.js +0 -43
  173. package/dist/ui/components/keyboard-help.js.map +0 -1
  174. package/dist/ui/components/loading-indicator.d.ts +0 -3
  175. package/dist/ui/components/loading-indicator.d.ts.map +0 -1
  176. package/dist/ui/components/loading-indicator.js +0 -42
  177. package/dist/ui/components/loading-indicator.js.map +0 -1
  178. package/dist/ui/components/message-display.d.ts +0 -7
  179. package/dist/ui/components/message-display.d.ts.map +0 -1
  180. package/dist/ui/components/message-display.js +0 -104
  181. package/dist/ui/components/message-display.js.map +0 -1
  182. package/dist/ui/components/misc.d.ts +0 -28
  183. package/dist/ui/components/misc.d.ts.map +0 -1
  184. package/dist/ui/components/misc.js +0 -128
  185. package/dist/ui/components/misc.js.map +0 -1
  186. package/dist/ui/components/select-prompt.d.ts +0 -13
  187. package/dist/ui/components/select-prompt.d.ts.map +0 -1
  188. package/dist/ui/components/select-prompt.js +0 -42
  189. package/dist/ui/components/select-prompt.js.map +0 -1
  190. package/dist/ui/components/status-bar.d.ts +0 -11
  191. package/dist/ui/components/status-bar.d.ts.map +0 -1
  192. package/dist/ui/components/status-bar.js +0 -47
  193. package/dist/ui/components/status-bar.js.map +0 -1
  194. package/dist/ui/components/tool-execution.d.ts +0 -3
  195. package/dist/ui/components/tool-execution.d.ts.map +0 -1
  196. package/dist/ui/components/tool-execution.js +0 -374
  197. package/dist/ui/components/tool-execution.js.map +0 -1
  198. package/dist/ui/components/tool-result.d.ts +0 -11
  199. package/dist/ui/components/tool-result.d.ts.map +0 -1
  200. package/dist/ui/components/tool-result.js +0 -58
  201. package/dist/ui/components/tool-result.js.map +0 -1
  202. package/dist/ui/components/welcome-banner.d.ts +0 -3
  203. package/dist/ui/components/welcome-banner.d.ts.map +0 -1
  204. package/dist/ui/components/welcome-banner.js +0 -46
  205. package/dist/ui/components/welcome-banner.js.map +0 -1
  206. package/dist/ui/hooks/useDisplayHistory.d.ts +0 -13
  207. package/dist/ui/hooks/useDisplayHistory.d.ts.map +0 -1
  208. package/dist/ui/hooks/useDisplayHistory.js +0 -45
  209. package/dist/ui/hooks/useDisplayHistory.js.map +0 -1
  210. package/dist/ui/render-engine.d.ts +0 -69
  211. package/dist/ui/render-engine.d.ts.map +0 -1
  212. package/dist/ui/render-engine.js +0 -197
  213. package/dist/ui/render-engine.js.map +0 -1
  214. package/dist/ui/terminal/TerminalRenderer.d.ts +0 -84
  215. package/dist/ui/terminal/TerminalRenderer.d.ts.map +0 -1
  216. package/dist/ui/terminal/TerminalRenderer.js +0 -154
  217. package/dist/ui/terminal/TerminalRenderer.js.map +0 -1
  218. package/dist/ui/terminal/TerminalUI.d.ts +0 -139
  219. package/dist/ui/terminal/TerminalUI.d.ts.map +0 -1
  220. package/dist/ui/terminal/TerminalUI.js +0 -430
  221. package/dist/ui/terminal/TerminalUI.js.map +0 -1
  222. package/dist/ui/terminal/VirtualChatBuffer.d.ts +0 -32
  223. package/dist/ui/terminal/VirtualChatBuffer.d.ts.map +0 -1
  224. package/dist/ui/terminal/VirtualChatBuffer.js +0 -37
  225. package/dist/ui/terminal/VirtualChatBuffer.js.map +0 -1
  226. package/dist/ui/terminal-kit-base.d.ts +0 -117
  227. package/dist/ui/terminal-kit-base.d.ts.map +0 -1
  228. package/dist/ui/terminal-kit-base.js +0 -188
  229. package/dist/ui/terminal-kit-base.js.map +0 -1
  230. package/dist/ui/utils/duplication-detector.d.ts +0 -32
  231. package/dist/ui/utils/duplication-detector.d.ts.map +0 -1
  232. package/dist/ui/utils/duplication-detector.js +0 -227
  233. package/dist/ui/utils/duplication-detector.js.map +0 -1
  234. package/dist/ui/utils/duplication-logger.d.ts +0 -21
  235. package/dist/ui/utils/duplication-logger.d.ts.map +0 -1
  236. package/dist/ui/utils/duplication-logger.js +0 -85
  237. package/dist/ui/utils/duplication-logger.js.map +0 -1
  238. package/dist/ui/utils/terminal-scanner.d.ts +0 -19
  239. package/dist/ui/utils/terminal-scanner.d.ts.map +0 -1
  240. package/dist/ui/utils/terminal-scanner.js +0 -217
  241. package/dist/ui/utils/terminal-scanner.js.map +0 -1
  242. package/dist/version.d.ts +0 -2
  243. package/dist/version.d.ts.map +0 -1
  244. package/dist/version.js +0 -3
  245. package/dist/version.js.map +0 -1
  246. package/scripts/generate-version.js +0 -25
@@ -1,313 +0,0 @@
1
- /**
2
- * Google AI Provider (Gemini Models)
3
- * Supports Gemini 2.5 Flash and Pro models with function calling
4
- */
5
- import { GoogleGenerativeAI, FunctionCallingMode } from '@google/generative-ai';
6
- import { AIProvider } from './Provider.js';
7
- const GEMINI_MODELS = [
8
- {
9
- id: 'gemini-2.0-flash-exp',
10
- name: 'Gemini 2.0 Flash (Experimental)',
11
- description: 'Fastest model, best for real-time tasks and code generation',
12
- contextWindow: 1048576,
13
- supportsFunctions: true,
14
- supportsStreaming: true,
15
- costPer1kInput: 0.00015,
16
- costPer1kOutput: 0.0006
17
- },
18
- {
19
- id: 'gemini-1.5-flash',
20
- name: 'Gemini 1.5 Flash',
21
- description: 'Fast and efficient for most tasks',
22
- contextWindow: 1048576,
23
- supportsFunctions: true,
24
- supportsStreaming: true,
25
- costPer1kInput: 0.00035,
26
- costPer1kOutput: 0.0014
27
- },
28
- {
29
- id: 'gemini-1.5-pro',
30
- name: 'Gemini 1.5 Pro',
31
- description: 'Most capable model for complex tasks',
32
- contextWindow: 2097152,
33
- supportsFunctions: true,
34
- supportsStreaming: true,
35
- costPer1kInput: 0.00125,
36
- costPer1kOutput: 0.005
37
- }
38
- ];
39
- export class GoogleProvider extends AIProvider {
40
- client = null;
41
- model = null;
42
- retryCount = 0;
43
- maxRetries = 3;
44
- constructor(config) {
45
- super(config);
46
- this.maxRetries = config.maxRetries || 3;
47
- }
48
- async initialize() {
49
- if (!this.config.apiKey) {
50
- throw new Error('Google API key is required');
51
- }
52
- this.client = new GoogleGenerativeAI(this.config.apiKey);
53
- this.model = this.client.getGenerativeModel({
54
- model: this.currentModel,
55
- });
56
- }
57
- listModels() {
58
- return GEMINI_MODELS;
59
- }
60
- getDefaultModel() {
61
- return 'gemini-2.0-flash-exp';
62
- }
63
- async validateConnection() {
64
- try {
65
- if (!this.model) {
66
- await this.initialize();
67
- }
68
- // Test with a simple prompt
69
- const result = await this.model.generateContent('Say "OK" if you are working.');
70
- const response = result.response;
71
- return response.text().toLowerCase().includes('ok');
72
- }
73
- catch (error) {
74
- console.error('Connection validation failed:', error);
75
- return false;
76
- }
77
- }
78
- convertToGeminiContent(messages) {
79
- return messages.map(msg => {
80
- if (msg.role === 'tool') {
81
- return {
82
- role: 'function',
83
- parts: [{
84
- functionResponse: {
85
- name: msg.toolCallId || 'tool',
86
- response: { result: msg.content }
87
- }
88
- }]
89
- };
90
- }
91
- return {
92
- role: msg.role === 'user' ? 'user' : 'model',
93
- parts: [{ text: msg.content }]
94
- };
95
- });
96
- }
97
- convertToolsToGemini(tools) {
98
- if (!tools || tools.length === 0)
99
- return undefined;
100
- return [{
101
- functionDeclarations: tools.map(tool => ({
102
- name: tool.function.name,
103
- description: tool.function.description,
104
- parameters: tool.function.parameters || {
105
- type: 'object',
106
- properties: {}
107
- }
108
- }))
109
- }];
110
- }
111
- extractFunctionCalls(response) {
112
- const functionCalls = [];
113
- for (const candidate of response.candidates || []) {
114
- for (const part of candidate.content.parts) {
115
- if ('functionCall' in part && part.functionCall) {
116
- functionCalls.push({
117
- name: part.functionCall.name,
118
- arguments: part.functionCall.args
119
- });
120
- }
121
- }
122
- }
123
- return functionCalls.length > 0 ? functionCalls : undefined;
124
- }
125
- async generate(messages, options = {}) {
126
- if (!this.model) {
127
- await this.initialize();
128
- }
129
- // Apply system prompt if provided
130
- let finalMessages = messages;
131
- if (options.systemPrompt) {
132
- finalMessages = [
133
- { role: 'system', content: options.systemPrompt },
134
- ...messages
135
- ];
136
- }
137
- const geminiContent = this.convertToGeminiContent(finalMessages);
138
- const geminiTools = this.convertToolsToGemini(options.tools);
139
- // Configure generation parameters
140
- const generationConfig = {
141
- temperature: options.temperature || 0.7,
142
- topK: options.topK || 40,
143
- topP: options.topP || 0.95,
144
- maxOutputTokens: options.maxTokens || 8192,
145
- stopSequences: options.stopSequences
146
- };
147
- // Configure the model with tools if provided
148
- let model = this.model;
149
- if (geminiTools) {
150
- model = this.client.getGenerativeModel({
151
- model: this.currentModel,
152
- tools: geminiTools,
153
- toolConfig: {
154
- functionCallingConfig: {
155
- mode: FunctionCallingMode.AUTO
156
- }
157
- }
158
- });
159
- }
160
- try {
161
- const result = await this.retryWithExponentialBackoff(async () => {
162
- return await model.generateContent({
163
- contents: geminiContent,
164
- generationConfig
165
- });
166
- });
167
- const response = result.response;
168
- const text = response.text();
169
- const functionCalls = this.extractFunctionCalls(response);
170
- return {
171
- text,
172
- functionCalls,
173
- usage: response.usageMetadata ? {
174
- promptTokens: response.usageMetadata.promptTokenCount || 0,
175
- completionTokens: response.usageMetadata.candidatesTokenCount || 0,
176
- totalTokens: response.usageMetadata.totalTokenCount || 0
177
- } : undefined,
178
- finishReason: response.candidates?.[0]?.finishReason
179
- };
180
- }
181
- catch (error) {
182
- throw this.handleError(error);
183
- }
184
- }
185
- async streamGenerate(messages, onChunk, options = {}) {
186
- if (!this.model) {
187
- await this.initialize();
188
- }
189
- // Apply system prompt if provided
190
- let finalMessages = messages;
191
- if (options.systemPrompt) {
192
- finalMessages = [
193
- { role: 'system', content: options.systemPrompt },
194
- ...messages
195
- ];
196
- }
197
- const geminiContent = this.convertToGeminiContent(finalMessages);
198
- const geminiTools = this.convertToolsToGemini(options.tools);
199
- // Configure generation parameters
200
- const generationConfig = {
201
- temperature: options.temperature || 0.7,
202
- topK: options.topK || 40,
203
- topP: options.topP || 0.95,
204
- maxOutputTokens: options.maxTokens || 8192,
205
- stopSequences: options.stopSequences
206
- };
207
- // Configure the model with tools if provided
208
- let model = this.model;
209
- if (geminiTools) {
210
- model = this.client.getGenerativeModel({
211
- model: this.currentModel,
212
- tools: geminiTools,
213
- toolConfig: {
214
- functionCallingConfig: {
215
- mode: FunctionCallingMode.AUTO
216
- }
217
- }
218
- });
219
- }
220
- try {
221
- const result = await this.retryWithExponentialBackoff(async () => {
222
- return await model.generateContentStream({
223
- contents: geminiContent,
224
- generationConfig
225
- });
226
- });
227
- let fullText = '';
228
- let functionCalls;
229
- let usage;
230
- for await (const chunk of result.stream) {
231
- const chunkText = chunk.text();
232
- fullText += chunkText;
233
- // Check for function calls in this chunk
234
- const chunkFunctionCalls = this.extractFunctionCalls(chunk);
235
- if (chunkFunctionCalls) {
236
- functionCalls = chunkFunctionCalls;
237
- }
238
- onChunk({
239
- text: chunkText,
240
- isComplete: false,
241
- functionCall: chunkFunctionCalls?.[0]
242
- });
243
- }
244
- // Get final response for metadata
245
- const response = await result.response;
246
- // Send final chunk
247
- onChunk({
248
- text: '',
249
- isComplete: true
250
- });
251
- return {
252
- text: fullText,
253
- functionCalls,
254
- usage: response.usageMetadata ? {
255
- promptTokens: response.usageMetadata.promptTokenCount || 0,
256
- completionTokens: response.usageMetadata.candidatesTokenCount || 0,
257
- totalTokens: response.usageMetadata.totalTokenCount || 0
258
- } : undefined,
259
- finishReason: response.candidates?.[0]?.finishReason
260
- };
261
- }
262
- catch (error) {
263
- throw this.handleError(error);
264
- }
265
- }
266
- async retryWithExponentialBackoff(fn, retries = this.maxRetries) {
267
- try {
268
- this.retryCount = 0;
269
- return await fn();
270
- }
271
- catch (error) {
272
- if (this.retryCount >= retries) {
273
- throw error;
274
- }
275
- // Check if error is retryable
276
- if (this.isRetryableError(error)) {
277
- this.retryCount++;
278
- const delay = Math.min(1000 * Math.pow(2, this.retryCount), 10000);
279
- await new Promise(resolve => setTimeout(resolve, delay));
280
- return this.retryWithExponentialBackoff(fn, retries);
281
- }
282
- throw error;
283
- }
284
- }
285
- isRetryableError(error) {
286
- // Retry on rate limit or temporary errors
287
- if (error.status === 429 || error.status === 503) {
288
- return true;
289
- }
290
- // Retry on network errors
291
- if (error.code === 'ECONNRESET' || error.code === 'ETIMEDOUT') {
292
- return true;
293
- }
294
- return false;
295
- }
296
- handleError(error) {
297
- if (error.status === 401) {
298
- return new Error('Invalid API key. Please check your Google AI Studio API key.');
299
- }
300
- if (error.status === 429) {
301
- return new Error('Rate limit exceeded. Please try again later.');
302
- }
303
- if (error.status === 400) {
304
- return new Error(`Bad request: ${error.message || 'Invalid parameters'}`);
305
- }
306
- if (error.message) {
307
- return new Error(`Google AI Error: ${error.message}`);
308
- }
309
- return new Error('An unexpected error occurred with the Google AI provider');
310
- }
311
- }
312
- export default GoogleProvider;
313
- //# sourceMappingURL=GoogleProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GoogleProvider.js","sourceRoot":"","sources":["../../src/providers/GoogleProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,kBAAkB,EAGlB,mBAAmB,EAIpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,UAAU,EASX,MAAM,eAAe,CAAC;AAEvB,MAAM,aAAa,GAAgB;IACjC;QACE,EAAE,EAAE,sBAAsB;QAC1B,IAAI,EAAE,iCAAiC;QACvC,WAAW,EAAE,6DAA6D;QAC1E,aAAa,EAAE,OAAO;QACtB,iBAAiB,EAAE,IAAI;QACvB,iBAAiB,EAAE,IAAI;QACvB,cAAc,EAAE,OAAO;QACvB,eAAe,EAAE,MAAM;KACxB;IACD;QACE,EAAE,EAAE,kBAAkB;QACtB,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,mCAAmC;QAChD,aAAa,EAAE,OAAO;QACtB,iBAAiB,EAAE,IAAI;QACvB,iBAAiB,EAAE,IAAI;QACvB,cAAc,EAAE,OAAO;QACvB,eAAe,EAAE,MAAM;KACxB;IACD;QACE,EAAE,EAAE,gBAAgB;QACpB,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,sCAAsC;QACnD,aAAa,EAAE,OAAO;QACtB,iBAAiB,EAAE,IAAI;QACvB,iBAAiB,EAAE,IAAI;QACvB,cAAc,EAAE,OAAO;QACvB,eAAe,EAAE,KAAK;KACvB;CACF,CAAC;AAEF,MAAM,OAAO,cAAe,SAAQ,UAAU;IACpC,MAAM,GAA8B,IAAI,CAAC;IACzC,KAAK,GAA2B,IAAI,CAAC;IACrC,UA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AI,KAAK,WAAW,EAAE,CAAC;YAC9D,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,WAAW,CAAC,KAAU;QAC5B,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACzB,OAAO,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QACnF,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACzB,OAAO,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACzB,OAAO,IAAI,KAAK,CAAC,gBAAgB,KAAK,CAAC,OAAO,IAAI,oBAAoB,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,IAAI,KAAK,CAAC,oBAAoB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC/E,CAAC;CACF;AAED,eAAe,cAAc,CAAC"}
@@ -1,114 +0,0 @@
1
- /**
2
- * Base Provider Interface
3
- * Defines the contract for all AI providers (Google, OpenAI, Anthropic, etc.)
4
- */
5
- export interface ModelInfo {
6
- id: string;
7
- name: string;
8
- description: string;
9
- contextWindow: number;
10
- supportsFunctions: boolean;
11
- supportsStreaming: boolean;
12
- costPer1kInput?: number;
13
- costPer1kOutput?: number;
14
- }
15
- export interface ProviderConfig {
16
- apiKey: string;
17
- baseUrl?: string;
18
- maxRetries?: number;
19
- timeout?: number;
20
- headers?: Record<string, string>;
21
- }
22
- export interface StreamChunk {
23
- text: string;
24
- isComplete: boolean;
25
- functionCall?: FunctionCall;
26
- }
27
- export interface FunctionCall {
28
- name: string;
29
- arguments: Record<string, any>;
30
- }
31
- export interface Tool {
32
- type: 'function';
33
- function: {
34
- name: string;
35
- description: string;
36
- parameters?: {
37
- type: string;
38
- properties: Record<string, any>;
39
- required?: string[];
40
- };
41
- };
42
- }
43
- export interface Message {
44
- role: 'user' | 'assistant' | 'system' | 'tool';
45
- content: string;
46
- toolCallId?: string;
47
- toolCalls?: FunctionCall[];
48
- }
49
- export interface GenerateOptions {
50
- model?: string;
51
- temperature?: number;
52
- maxTokens?: number;
53
- topP?: number;
54
- topK?: number;
55
- stopSequences?: string[];
56
- systemPrompt?: string;
57
- tools?: Tool[];
58
- stream?: boolean;
59
- }
60
- export interface GenerateResponse {
61
- text: string;
62
- functionCalls?: FunctionCall[];
63
- usage?: {
64
- promptTokens: number;
65
- completionTokens: number;
66
- totalTokens: number;
67
- };
68
- finishReason?: string;
69
- }
70
- /**
71
- * Abstract base class for AI providers
72
- */
73
- export declare abstract class AIProvider {
74
- protected config: ProviderConfig;
75
- protected currentModel: string;
76
- constructor(config: ProviderConfig);
77
- /**
78
- * Initialize the provider connection
79
- */
80
- abstract initialize(): Promise<void>;
81
- /**
82
- * List available models for this provider
83
- */
84
- abstract listModels(): ModelInfo[];
85
- /**
86
- * Get the default model for this provider
87
- */
88
- abstract getDefaultModel(): string;
89
- /**
90
- * Generate a response from the AI
91
- */
92
- abstract generate(messages: Message[], options?: GenerateOptions): Promise<GenerateResponse>;
93
- /**
94
- * Stream a response from the AI
95
- */
96
- abstract streamGenerate(messages: Message[], onChunk: (chunk: StreamChunk) => void, options?: GenerateOptions): Promise<GenerateResponse>;
97
- /**
98
- * Validate the API key and connection
99
- */
100
- abstract validateConnection(): Promise<boolean>;
101
- /**
102
- * Get the current model
103
- */
104
- getCurrentModel(): string;
105
- /**
106
- * Set the current model
107
- */
108
- setCurrentModel(model: string): void;
109
- /**
110
- * Calculate cost for token usage
111
- */
112
- calculateCost(inputTokens: number, outputTokens: number, model?: string): number;
113
- }
114
- //# sourceMappingURL=Provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/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OAAO,EAAE,EACnB,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,EACrC,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,gBAAgB,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAE/C;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;OAEG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQpC;;OAEG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM;CAWjF"}
@@ -1,44 +0,0 @@
1
- /**
2
- * Base Provider Interface
3
- * Defines the contract for all AI providers (Google, OpenAI, Anthropic, etc.)
4
- */
5
- /**
6
- * Abstract base class for AI providers
7
- */
8
- export class AIProvider {
9
- config;
10
- currentModel;
11
- constructor(config) {
12
- this.config = config;
13
- this.currentModel = this.getDefaultModel();
14
- }
15
- /**
16
- * Get the current model
17
- */
18
- getCurrentModel() {
19
- return this.currentModel;
20
- }
21
- /**
22
- * Set the current model
23
- */
24
- setCurrentModel(model) {
25
- const availableModels = this.listModels();
26
- if (!availableModels.find(m => m.id === model)) {
27
- throw new Error(`Model ${model} not available for this provider`);
28
- }
29
- this.currentModel = model;
30
- }
31
- /**
32
- * Calculate cost for token usage
33
- */
34
- calculateCost(inputTokens, outputTokens, model) {
35
- const modelId = model || this.currentModel;
36
- const modelInfo = this.listModels().find(m => m.id === modelId);
37
- if (!modelInfo || !modelInfo.costPer1kInput || !modelInfo.costPer1kOutput) {
38
- return 0;
39
- }
40
- return (inputTokens / 1000) * modelInfo.costPer1kInput +
41
- (outputTokens / 1000) * modelInfo.costPer1kOutput;
42
- }
43
- }
44
- //# sourceMappingURL=Provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../src/providers/Provider.ts"],"names":[],"mapp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*
4
- * These tests verify:
5
- * - Context message format
6
- * - Context injection into message history
7
- * - Local context (no injection)
8
- * - Different subshell types (SSH, WSL, Docker)
9
- */
10
- /**
11
- * Run all tests
12
- */
13
- declare function runTests(): Promise<void>;
14
- export { runTests };
15
- //# sourceMappingURL=ai-context-injector.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ai-context-injector.test.d.ts","sourceRoot":"","sources":["../../../src/services/__tests__/ai-context-injector.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAqWH;;GAEG;AACH,iBAAe,QAAQ,kBAiBtB;AAOD,OAAO,EAAE,QAAQ,EAAE,CAAC"}