centaurus-cli 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTH_FLOW.md +138 -0
- package/CONFIG_GUIDE.md +255 -0
- package/LICENSE +21 -0
- package/README.md +346 -0
- package/dist/ai/provider-factory.d.ts +6 -0
- package/dist/ai/provider-factory.d.ts.map +1 -0
- package/dist/ai/provider-factory.js +27 -0
- package/dist/ai/provider-factory.js.map +1 -0
- package/dist/ai/providers/base.d.ts +25 -0
- package/dist/ai/providers/base.d.ts.map +1 -0
- package/dist/ai/providers/base.js +9 -0
- package/dist/ai/providers/base.js.map +1 -0
- package/dist/ai/providers/gemini.d.ts +34 -0
- package/dist/ai/providers/gemini.d.ts.map +1 -0
- package/dist/ai/providers/gemini.js +146 -0
- package/dist/ai/providers/gemini.js.map +1 -0
- package/dist/ai/types.d.ts +20 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/types.js +2 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/cli-adapter.d.ts +78 -0
- package/dist/cli-adapter.d.ts.map +1 -0
- package/dist/cli-adapter.js +605 -0
- package/dist/cli-adapter.js.map +1 -0
- package/dist/commands/CommandParser.d.ts +27 -0
- package/dist/commands/CommandParser.d.ts.map +1 -0
- package/dist/commands/CommandParser.js +238 -0
- package/dist/commands/CommandParser.js.map +1 -0
- package/dist/config/ConfigManager.d.ts +59 -0
- package/dist/config/ConfigManager.d.ts.map +1 -0
- package/dist/config/ConfigManager.js +332 -0
- package/dist/config/ConfigManager.js.map +1 -0
- package/dist/config/defaultConfig.d.ts +82 -0
- package/dist/config/defaultConfig.d.ts.map +1 -0
- package/dist/config/defaultConfig.js +88 -0
- package/dist/config/defaultConfig.js.map +1 -0
- package/dist/config/manager.d.ts +60 -0
- package/dist/config/manager.d.ts.map +1 -0
- package/dist/config/manager.js +162 -0
- package/dist/config/manager.js.map +1 -0
- package/dist/config/types.d.ts +9 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +6 -0
- package/dist/config/types.js.map +1 -0
- package/dist/index-custom.d.ts +3 -0
- package/dist/index-custom.d.ts.map +1 -0
- package/dist/index-custom.js +65 -0
- package/dist/index-custom.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/system-prompt.d.ts +47 -0
- package/dist/prompts/system-prompt.d.ts.map +1 -0
- package/dist/prompts/system-prompt.js +378 -0
- package/dist/prompts/system-prompt.js.map +1 -0
- package/dist/providers/GoogleProvider.d.ts +26 -0
- package/dist/providers/GoogleProvider.d.ts.map +1 -0
- package/dist/providers/GoogleProvider.js +313 -0
- package/dist/providers/GoogleProvider.js.map +1 -0
- package/dist/providers/Provider.d.ts +114 -0
- package/dist/providers/Provider.d.ts.map +1 -0
- package/dist/providers/Provider.js +44 -0
- package/dist/providers/Provider.js.map +1 -0
- package/dist/services/api-client.d.ts +282 -0
- package/dist/services/api-client.d.ts.map +1 -0
- package/dist/services/api-client.js +339 -0
- package/dist/services/api-client.js.map +1 -0
- package/dist/services/auth-handler.d.ts +30 -0
- package/dist/services/auth-handler.d.ts.map +1 -0
- package/dist/services/auth-handler.js +210 -0
- package/dist/services/auth-handler.js.map +1 -0
- package/dist/services/conversation-manager.d.ts +73 -0
- package/dist/services/conversation-manager.d.ts.map +1 -0
- package/dist/services/conversation-manager.js +128 -0
- package/dist/services/conversation-manager.js.map +1 -0
- package/dist/tests/automated-verification.d.ts +27 -0
- package/dist/tests/automated-verification.d.ts.map +1 -0
- package/dist/tests/automated-verification.js +359 -0
- package/dist/tests/automated-verification.js.map +1 -0
- package/dist/tests/integration-tests.d.ts +50 -0
- package/dist/tests/integration-tests.d.ts.map +1 -0
- package/dist/tests/integration-tests.js +648 -0
- package/dist/tests/integration-tests.js.map +1 -0
- package/dist/tools/ToolRegistry.d.ts +44 -0
- package/dist/tools/ToolRegistry.d.ts.map +1 -0
- package/dist/tools/ToolRegistry.js +494 -0
- package/dist/tools/ToolRegistry.js.map +1 -0
- package/dist/tools/command.d.ts +4 -0
- package/dist/tools/command.d.ts.map +1 -0
- package/dist/tools/command.js +117 -0
- package/dist/tools/command.js.map +1 -0
- package/dist/tools/file-ops-test.d.ts +6 -0
- package/dist/tools/file-ops-test.d.ts.map +1 -0
- package/dist/tools/file-ops-test.js +197 -0
- package/dist/tools/file-ops-test.js.map +1 -0
- package/dist/tools/file-ops.d.ts +6 -0
- package/dist/tools/file-ops.d.ts.map +1 -0
- package/dist/tools/file-ops.js +189 -0
- package/dist/tools/file-ops.js.map +1 -0
- package/dist/tools/plan-mode.d.ts +53 -0
- package/dist/tools/plan-mode.d.ts.map +1 -0
- package/dist/tools/plan-mode.js +202 -0
- package/dist/tools/plan-mode.js.map +1 -0
- package/dist/tools/registry.d.ts +30 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +67 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/types.d.ts +34 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/web-search.d.ts +24 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +194 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/DisplayHistory.d.ts +53 -0
- package/dist/ui/DisplayHistory.d.ts.map +1 -0
- package/dist/ui/DisplayHistory.js +82 -0
- package/dist/ui/DisplayHistory.js.map +1 -0
- package/dist/ui/clack-ui.d.ts +83 -0
- package/dist/ui/clack-ui.d.ts.map +1 -0
- package/dist/ui/clack-ui.js +304 -0
- package/dist/ui/clack-ui.js.map +1 -0
- package/dist/ui/components/App.d.ts +47 -0
- package/dist/ui/components/App.d.ts.map +1 -0
- package/dist/ui/components/App.js +389 -0
- package/dist/ui/components/App.js.map +1 -0
- package/dist/ui/components/AuthScreen.d.ts +8 -0
- package/dist/ui/components/AuthScreen.d.ts.map +1 -0
- package/dist/ui/components/AuthScreen.js +37 -0
- package/dist/ui/components/AuthScreen.js.map +1 -0
- package/dist/ui/components/AuthWelcomeScreen.d.ts +8 -0
- package/dist/ui/components/AuthWelcomeScreen.d.ts.map +1 -0
- package/dist/ui/components/AuthWelcomeScreen.js +34 -0
- package/dist/ui/components/AuthWelcomeScreen.js.map +1 -0
- package/dist/ui/components/CodeBlock.d.ts +9 -0
- package/dist/ui/components/CodeBlock.d.ts.map +1 -0
- package/dist/ui/components/CodeBlock.js +22 -0
- package/dist/ui/components/CodeBlock.js.map +1 -0
- package/dist/ui/components/ConfigViewer.d.ts +11 -0
- package/dist/ui/components/ConfigViewer.d.ts.map +1 -0
- package/dist/ui/components/ConfigViewer.js +27 -0
- package/dist/ui/components/ConfigViewer.js.map +1 -0
- package/dist/ui/components/ConfirmPrompt.d.ts +11 -0
- package/dist/ui/components/ConfirmPrompt.d.ts.map +1 -0
- package/dist/ui/components/ConfirmPrompt.js +55 -0
- package/dist/ui/components/ConfirmPrompt.js.map +1 -0
- package/dist/ui/components/DiffViewer.d.ts +8 -0
- package/dist/ui/components/DiffViewer.d.ts.map +1 -0
- package/dist/ui/components/DiffViewer.js +63 -0
- package/dist/ui/components/DiffViewer.js.map +1 -0
- package/dist/ui/components/DisplayItemRenderer.d.ts +18 -0
- package/dist/ui/components/DisplayItemRenderer.d.ts.map +1 -0
- package/dist/ui/components/DisplayItemRenderer.js +53 -0
- package/dist/ui/components/DisplayItemRenderer.js.map +1 -0
- package/dist/ui/components/DynamicMessage.d.ts +13 -0
- package/dist/ui/components/DynamicMessage.d.ts.map +1 -0
- package/dist/ui/components/DynamicMessage.js +27 -0
- package/dist/ui/components/DynamicMessage.js.map +1 -0
- package/dist/ui/components/ErrorBoundary.d.ts +16 -0
- package/dist/ui/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/ui/components/ErrorBoundary.js +25 -0
- package/dist/ui/components/ErrorBoundary.js.map +1 -0
- package/dist/ui/components/FileOperation.d.ts +10 -0
- package/dist/ui/components/FileOperation.d.ts.map +1 -0
- package/dist/ui/components/FileOperation.js +31 -0
- package/dist/ui/components/FileOperation.js.map +1 -0
- package/dist/ui/components/InputBox.d.ts +12 -0
- package/dist/ui/components/InputBox.d.ts.map +1 -0
- package/dist/ui/components/InputBox.js +50 -0
- package/dist/ui/components/InputBox.js.map +1 -0
- package/dist/ui/components/KeyboardHelp.d.ts +7 -0
- package/dist/ui/components/KeyboardHelp.d.ts.map +1 -0
- package/dist/ui/components/KeyboardHelp.js +25 -0
- package/dist/ui/components/KeyboardHelp.js.map +1 -0
- package/dist/ui/components/LoadingIndicator.d.ts +3 -0
- package/dist/ui/components/LoadingIndicator.d.ts.map +1 -0
- package/dist/ui/components/LoadingIndicator.js +25 -0
- package/dist/ui/components/LoadingIndicator.js.map +1 -0
- package/dist/ui/components/MarkdownRenderer.d.ts +8 -0
- package/dist/ui/components/MarkdownRenderer.d.ts.map +1 -0
- package/dist/ui/components/MarkdownRenderer.js +96 -0
- package/dist/ui/components/MarkdownRenderer.js.map +1 -0
- package/dist/ui/components/MessageBox.d.ts +10 -0
- package/dist/ui/components/MessageBox.d.ts.map +1 -0
- package/dist/ui/components/MessageBox.js +50 -0
- package/dist/ui/components/MessageBox.js.map +1 -0
- package/dist/ui/components/MessageDisplay.d.ts +8 -0
- package/dist/ui/components/MessageDisplay.d.ts.map +1 -0
- package/dist/ui/components/MessageDisplay.js +43 -0
- package/dist/ui/components/MessageDisplay.js.map +1 -0
- package/dist/ui/components/ScrollableContent.d.ts +7 -0
- package/dist/ui/components/ScrollableContent.d.ts.map +1 -0
- package/dist/ui/components/ScrollableContent.js +6 -0
- package/dist/ui/components/ScrollableContent.js.map +1 -0
- package/dist/ui/components/ScrollableMessageList.d.ts +10 -0
- package/dist/ui/components/ScrollableMessageList.d.ts.map +1 -0
- package/dist/ui/components/ScrollableMessageList.js +133 -0
- package/dist/ui/components/ScrollableMessageList.js.map +1 -0
- package/dist/ui/components/ScrollableScreen.d.ts +9 -0
- package/dist/ui/components/ScrollableScreen.d.ts.map +1 -0
- package/dist/ui/components/ScrollableScreen.js +22 -0
- package/dist/ui/components/ScrollableScreen.js.map +1 -0
- package/dist/ui/components/SelectPrompt.d.ts +12 -0
- package/dist/ui/components/SelectPrompt.d.ts.map +1 -0
- package/dist/ui/components/SelectPrompt.js +10 -0
- package/dist/ui/components/SelectPrompt.js.map +1 -0
- package/dist/ui/components/StaticMessageHistory.d.ts +14 -0
- package/dist/ui/components/StaticMessageHistory.d.ts.map +1 -0
- package/dist/ui/components/StaticMessageHistory.js +19 -0
- package/dist/ui/components/StaticMessageHistory.js.map +1 -0
- package/dist/ui/components/StatusBar.d.ts +10 -0
- package/dist/ui/components/StatusBar.d.ts.map +1 -0
- package/dist/ui/components/StatusBar.js +20 -0
- package/dist/ui/components/StatusBar.js.map +1 -0
- package/dist/ui/components/StreamingMessageDisplay.d.ts +13 -0
- package/dist/ui/components/StreamingMessageDisplay.d.ts.map +1 -0
- package/dist/ui/components/StreamingMessageDisplay.js +26 -0
- package/dist/ui/components/StreamingMessageDisplay.js.map +1 -0
- package/dist/ui/components/ToolExecutionMessage.d.ts +8 -0
- package/dist/ui/components/ToolExecutionMessage.d.ts.map +1 -0
- package/dist/ui/components/ToolExecutionMessage.js +189 -0
- package/dist/ui/components/ToolExecutionMessage.js.map +1 -0
- package/dist/ui/components/ToolExecutionStatus.d.ts +10 -0
- package/dist/ui/components/ToolExecutionStatus.d.ts.map +1 -0
- package/dist/ui/components/ToolExecutionStatus.js +65 -0
- package/dist/ui/components/ToolExecutionStatus.js.map +1 -0
- package/dist/ui/components/ToolResult.d.ts +10 -0
- package/dist/ui/components/ToolResult.d.ts.map +1 -0
- package/dist/ui/components/ToolResult.js +17 -0
- package/dist/ui/components/ToolResult.js.map +1 -0
- package/dist/ui/components/WelcomeBanner.d.ts +3 -0
- package/dist/ui/components/WelcomeBanner.d.ts.map +1 -0
- package/dist/ui/components/WelcomeBanner.js +28 -0
- package/dist/ui/components/WelcomeBanner.js.map +1 -0
- package/dist/ui/components/code-block.d.ts +10 -0
- package/dist/ui/components/code-block.d.ts.map +1 -0
- package/dist/ui/components/code-block.js +74 -0
- package/dist/ui/components/code-block.js.map +1 -0
- package/dist/ui/components/confirm-prompt.d.ts +12 -0
- package/dist/ui/components/confirm-prompt.d.ts.map +1 -0
- package/dist/ui/components/confirm-prompt.js +104 -0
- package/dist/ui/components/confirm-prompt.js.map +1 -0
- package/dist/ui/components/diff-viewer.d.ts +9 -0
- package/dist/ui/components/diff-viewer.d.ts.map +1 -0
- package/dist/ui/components/diff-viewer.js +57 -0
- package/dist/ui/components/diff-viewer.js.map +1 -0
- package/dist/ui/components/input-box.d.ts +18 -0
- package/dist/ui/components/input-box.d.ts.map +1 -0
- package/dist/ui/components/input-box.js +157 -0
- package/dist/ui/components/input-box.js.map +1 -0
- package/dist/ui/components/keyboard-help.d.ts +7 -0
- package/dist/ui/components/keyboard-help.d.ts.map +1 -0
- package/dist/ui/components/keyboard-help.js +43 -0
- package/dist/ui/components/keyboard-help.js.map +1 -0
- package/dist/ui/components/loading-indicator.d.ts +3 -0
- package/dist/ui/components/loading-indicator.d.ts.map +1 -0
- package/dist/ui/components/loading-indicator.js +42 -0
- package/dist/ui/components/loading-indicator.js.map +1 -0
- package/dist/ui/components/message-display.d.ts +7 -0
- package/dist/ui/components/message-display.d.ts.map +1 -0
- package/dist/ui/components/message-display.js +104 -0
- package/dist/ui/components/message-display.js.map +1 -0
- package/dist/ui/components/misc.d.ts +28 -0
- package/dist/ui/components/misc.d.ts.map +1 -0
- package/dist/ui/components/misc.js +128 -0
- package/dist/ui/components/misc.js.map +1 -0
- package/dist/ui/components/select-prompt.d.ts +13 -0
- package/dist/ui/components/select-prompt.d.ts.map +1 -0
- package/dist/ui/components/select-prompt.js +42 -0
- package/dist/ui/components/select-prompt.js.map +1 -0
- package/dist/ui/components/status-bar.d.ts +11 -0
- package/dist/ui/components/status-bar.d.ts.map +1 -0
- package/dist/ui/components/status-bar.js +47 -0
- package/dist/ui/components/status-bar.js.map +1 -0
- package/dist/ui/components/tool-execution.d.ts +3 -0
- package/dist/ui/components/tool-execution.d.ts.map +1 -0
- package/dist/ui/components/tool-execution.js +374 -0
- package/dist/ui/components/tool-execution.js.map +1 -0
- package/dist/ui/components/tool-result.d.ts +11 -0
- package/dist/ui/components/tool-result.d.ts.map +1 -0
- package/dist/ui/components/tool-result.js +58 -0
- package/dist/ui/components/tool-result.js.map +1 -0
- package/dist/ui/components/welcome-banner.d.ts +3 -0
- package/dist/ui/components/welcome-banner.d.ts.map +1 -0
- package/dist/ui/components/welcome-banner.js +46 -0
- package/dist/ui/components/welcome-banner.js.map +1 -0
- package/dist/ui/hooks/useDisplayHistory.d.ts +13 -0
- package/dist/ui/hooks/useDisplayHistory.d.ts.map +1 -0
- package/dist/ui/hooks/useDisplayHistory.js +45 -0
- package/dist/ui/hooks/useDisplayHistory.js.map +1 -0
- package/dist/ui/render-engine.d.ts +69 -0
- package/dist/ui/render-engine.d.ts.map +1 -0
- package/dist/ui/render-engine.js +197 -0
- package/dist/ui/render-engine.js.map +1 -0
- package/dist/ui/terminal/TerminalRenderer.d.ts +84 -0
- package/dist/ui/terminal/TerminalRenderer.d.ts.map +1 -0
- package/dist/ui/terminal/TerminalRenderer.js +154 -0
- package/dist/ui/terminal/TerminalRenderer.js.map +1 -0
- package/dist/ui/terminal/TerminalUI.d.ts +139 -0
- package/dist/ui/terminal/TerminalUI.d.ts.map +1 -0
- package/dist/ui/terminal/TerminalUI.js +430 -0
- package/dist/ui/terminal/TerminalUI.js.map +1 -0
- package/dist/ui/terminal/VirtualChatBuffer.d.ts +32 -0
- package/dist/ui/terminal/VirtualChatBuffer.d.ts.map +1 -0
- package/dist/ui/terminal/VirtualChatBuffer.js +37 -0
- package/dist/ui/terminal/VirtualChatBuffer.js.map +1 -0
- package/dist/ui/terminal-kit-base.d.ts +117 -0
- package/dist/ui/terminal-kit-base.d.ts.map +1 -0
- package/dist/ui/terminal-kit-base.js +188 -0
- package/dist/ui/terminal-kit-base.js.map +1 -0
- package/dist/utils/file.d.ts +21 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +68 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/logger.d.ts +17 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +57 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/markdown-parser.d.ts +56 -0
- package/dist/utils/markdown-parser.d.ts.map +1 -0
- package/dist/utils/markdown-parser.js +307 -0
- package/dist/utils/markdown-parser.js.map +1 -0
- package/dist/utils/shell.d.ts +7 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +62 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/state.d.ts +13 -0
- package/dist/utils/state.d.ts.map +1 -0
- package/dist/utils/state.js +25 -0
- package/dist/utils/state.js.map +1 -0
- package/package.json +81 -0
- package/postinstall.js +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# Centaurus CLI
|
|
2
|
+
|
|
3
|
+
> A powerful command-line AI coding assistant with Google Gemini and OpenRouter support
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/centaurus-cli)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
✨ **AI-Powered Coding Assistant**
|
|
12
|
+
- Support for Google Gemini (2.5 Flash, 2.5 Pro, 2.0 Flash, and more)
|
|
13
|
+
- OpenRouter integration for access to multiple AI models
|
|
14
|
+
- Intelligent code generation and editing
|
|
15
|
+
- Context-aware file operations
|
|
16
|
+
|
|
17
|
+
🔧 **Developer Tools**
|
|
18
|
+
- Read, write, and edit files with AI assistance
|
|
19
|
+
- Execute shell commands safely
|
|
20
|
+
- Search codebases with grep
|
|
21
|
+
- Web search capabilities (requires authentication)
|
|
22
|
+
- Diff viewer for code changes
|
|
23
|
+
|
|
24
|
+
🎨 **Beautiful Terminal UI**
|
|
25
|
+
- Built with Ink (React for CLIs)
|
|
26
|
+
- Syntax highlighting for code blocks
|
|
27
|
+
- Interactive pickers and prompts
|
|
28
|
+
- Real-time streaming responses
|
|
29
|
+
- Markdown rendering
|
|
30
|
+
|
|
31
|
+
☁️ **Cloud Sync** (Optional)
|
|
32
|
+
- Conversation history across devices
|
|
33
|
+
- Settings synchronization
|
|
34
|
+
- Encrypted API key storage
|
|
35
|
+
- Seamless authentication with Google
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### Global Installation (Recommended)
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g centaurus-cli
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
After installation, you can run Centaurus from any directory:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
centaurus
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Local Installation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install centaurus-cli
|
|
55
|
+
npx centaurus
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
### 1. First Launch
|
|
61
|
+
|
|
62
|
+
When you first run Centaurus, you'll see a beautiful welcome screen:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
centaurus
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
You'll be prompted to sign in with Google for cloud sync features, or you can exit and configure manually.
|
|
69
|
+
|
|
70
|
+
### 2. Configure API Keys
|
|
71
|
+
|
|
72
|
+
Set up your AI provider API keys using slash commands:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# For Google Gemini
|
|
76
|
+
/config set googleApiKey YOUR_GOOGLE_API_KEY
|
|
77
|
+
|
|
78
|
+
# For OpenRouter
|
|
79
|
+
/config set openrouterApiKey YOUR_OPENROUTER_API_KEY
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Get API Keys:**
|
|
83
|
+
- Google AI Studio: https://makersuite.google.com/app/apikey
|
|
84
|
+
- OpenRouter: https://openrouter.ai/keys
|
|
85
|
+
|
|
86
|
+
### 3. Start Chatting
|
|
87
|
+
|
|
88
|
+
Just type your message and press Enter:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
> Create a React component for a todo list
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The AI will help you with code generation, file operations, and more!
|
|
95
|
+
|
|
96
|
+
## Configuration
|
|
97
|
+
|
|
98
|
+
### Environment Setup
|
|
99
|
+
|
|
100
|
+
Create a `.env` file in your project or use the global config:
|
|
101
|
+
|
|
102
|
+
```env
|
|
103
|
+
# Backend API URL (for cloud sync and web search)
|
|
104
|
+
BACKEND_API_URL=http://localhost:3000/api
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### User Configuration
|
|
108
|
+
|
|
109
|
+
Your settings are stored in `~/.centaurus/config.json`:
|
|
110
|
+
- API keys (encrypted)
|
|
111
|
+
- Preferred model and provider
|
|
112
|
+
- Theme settings
|
|
113
|
+
- Auto-accept preferences
|
|
114
|
+
|
|
115
|
+
## Commands
|
|
116
|
+
|
|
117
|
+
### Slash Commands
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
/help # Show all commands
|
|
121
|
+
/config # View current configuration
|
|
122
|
+
/config set <key> <value> # Set configuration value
|
|
123
|
+
/model # Select AI model
|
|
124
|
+
/provider # Select AI provider
|
|
125
|
+
/plan # Toggle plan mode
|
|
126
|
+
/clear # Clear conversation history
|
|
127
|
+
/logout # Sign out and exit
|
|
128
|
+
/exit # Exit the application
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Examples
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Set API key
|
|
135
|
+
/config set googleApiKey AIzaSy...
|
|
136
|
+
|
|
137
|
+
# Change model
|
|
138
|
+
/model gemini-2.5-flash
|
|
139
|
+
|
|
140
|
+
# Switch provider
|
|
141
|
+
/provider openrouter
|
|
142
|
+
|
|
143
|
+
# Enable plan mode for complex tasks
|
|
144
|
+
/plan
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Features in Detail
|
|
148
|
+
|
|
149
|
+
### File Operations
|
|
150
|
+
|
|
151
|
+
Centaurus can read, write, and edit files in your project:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
> Read the package.json file
|
|
155
|
+
> Create a new file called utils.ts with helper functions
|
|
156
|
+
> Edit the README.md to add installation instructions
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Code Generation
|
|
160
|
+
|
|
161
|
+
Generate code in any language:
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
> Create a Python script to parse CSV files
|
|
165
|
+
> Write a TypeScript interface for a user object
|
|
166
|
+
> Generate a SQL query to find duplicate records
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Web Search
|
|
170
|
+
|
|
171
|
+
Search the web for documentation and solutions (requires authentication):
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
> Search for the latest React hooks best practices
|
|
175
|
+
> Find documentation for the Axios library
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Command Execution
|
|
179
|
+
|
|
180
|
+
Execute shell commands safely:
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
> Run npm install
|
|
184
|
+
> List all files in the current directory
|
|
185
|
+
> Check the git status
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Plan Mode
|
|
189
|
+
|
|
190
|
+
For complex tasks, enable plan mode to see the implementation plan before execution:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
/plan
|
|
194
|
+
> Build a REST API with Express and TypeScript
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The AI will create a detailed plan and ask for approval before implementing.
|
|
198
|
+
|
|
199
|
+
## Cloud Sync
|
|
200
|
+
|
|
201
|
+
### Sign In
|
|
202
|
+
|
|
203
|
+
Sign in with Google to enable cloud features:
|
|
204
|
+
|
|
205
|
+
1. Start Centaurus
|
|
206
|
+
2. Select "Sign in with Google"
|
|
207
|
+
3. Complete authentication in browser
|
|
208
|
+
4. Enjoy cloud sync!
|
|
209
|
+
|
|
210
|
+
### Features
|
|
211
|
+
|
|
212
|
+
- **Conversation History**: Access your chats from any device
|
|
213
|
+
- **Settings Sync**: Your preferences follow you everywhere
|
|
214
|
+
- **API Key Storage**: Encrypted storage in the cloud
|
|
215
|
+
- **Web Search**: Powered by backend API
|
|
216
|
+
|
|
217
|
+
### Offline Mode
|
|
218
|
+
|
|
219
|
+
You can use Centaurus without signing in:
|
|
220
|
+
- All AI features work offline
|
|
221
|
+
- Local conversation history
|
|
222
|
+
- No web search (requires backend)
|
|
223
|
+
|
|
224
|
+
## Advanced Usage
|
|
225
|
+
|
|
226
|
+
### Multiple API Keys
|
|
227
|
+
|
|
228
|
+
Configure multiple API keys for automatic rotation:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
/config set googleApiKey key1,key2,key3
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Custom Backend
|
|
235
|
+
|
|
236
|
+
Set up your own backend for cloud sync:
|
|
237
|
+
|
|
238
|
+
```env
|
|
239
|
+
BACKEND_API_URL=https://your-backend.com/api
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Keyboard Shortcuts
|
|
243
|
+
|
|
244
|
+
- `Ctrl+C` - Cancel current operation
|
|
245
|
+
- `Ctrl+D` - Exit (when input is empty)
|
|
246
|
+
- `Arrow Keys` - Navigate pickers
|
|
247
|
+
- `Enter` - Confirm selection
|
|
248
|
+
|
|
249
|
+
## Troubleshooting
|
|
250
|
+
|
|
251
|
+
### "API key not set"
|
|
252
|
+
|
|
253
|
+
Configure your API key:
|
|
254
|
+
```bash
|
|
255
|
+
/config set googleApiKey YOUR_KEY
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### "Authentication required" for web search
|
|
259
|
+
|
|
260
|
+
Sign in with Google or restart the CLI and choose "Sign in".
|
|
261
|
+
|
|
262
|
+
### "Backend API is not reachable"
|
|
263
|
+
|
|
264
|
+
Check your `.env` file and ensure the backend is running:
|
|
265
|
+
```bash
|
|
266
|
+
cd backend
|
|
267
|
+
npm start
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Reset Configuration
|
|
271
|
+
|
|
272
|
+
Delete the config file to start fresh:
|
|
273
|
+
|
|
274
|
+
**Windows:**
|
|
275
|
+
```cmd
|
|
276
|
+
del %USERPROFILE%\.centaurus\config.json
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**macOS/Linux:**
|
|
280
|
+
```bash
|
|
281
|
+
rm ~/.centaurus/config.json
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Requirements
|
|
285
|
+
|
|
286
|
+
- Node.js >= 18.0.0
|
|
287
|
+
- npm or yarn
|
|
288
|
+
- Terminal with color support
|
|
289
|
+
|
|
290
|
+
## Development
|
|
291
|
+
|
|
292
|
+
### Clone and Build
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
git clone https://github.com/yourusername/centaurus-cli.git
|
|
296
|
+
cd centaurus-cli
|
|
297
|
+
npm install
|
|
298
|
+
npm run build
|
|
299
|
+
npm start
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Project Structure
|
|
303
|
+
|
|
304
|
+
```
|
|
305
|
+
centaurus-cli/
|
|
306
|
+
├── src/
|
|
307
|
+
│ ├── ai/ # AI provider implementations
|
|
308
|
+
│ ├── commands/ # Command parser
|
|
309
|
+
│ ├── config/ # Configuration management
|
|
310
|
+
│ ├── services/ # API client and services
|
|
311
|
+
│ ├── tools/ # Tool implementations
|
|
312
|
+
│ ├── ui/ # Ink UI components
|
|
313
|
+
│ └── index.ts # Entry point
|
|
314
|
+
├── dist/ # Compiled JavaScript
|
|
315
|
+
└── package.json
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Contributing
|
|
319
|
+
|
|
320
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
321
|
+
|
|
322
|
+
1. Fork the repository
|
|
323
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
324
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
325
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
326
|
+
5. Open a Pull Request
|
|
327
|
+
|
|
328
|
+
## License
|
|
329
|
+
|
|
330
|
+
MIT © [Your Name]
|
|
331
|
+
|
|
332
|
+
## Support
|
|
333
|
+
|
|
334
|
+
- 📖 [Documentation](./CONFIG_GUIDE.md)
|
|
335
|
+
- 🐛 [Report Issues](https://github.com/yourusername/centaurus-cli/issues)
|
|
336
|
+
- 💬 [Discussions](https://github.com/yourusername/centaurus-cli/discussions)
|
|
337
|
+
|
|
338
|
+
## Acknowledgments
|
|
339
|
+
|
|
340
|
+
- Built with [Ink](https://github.com/vadimdemedes/ink) - React for CLIs
|
|
341
|
+
- Powered by [Google Gemini](https://ai.google.dev/) and [OpenRouter](https://openrouter.ai/)
|
|
342
|
+
- Inspired by modern AI coding assistants
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
Made with ❤️ by developers, for developers
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-factory.d.ts","sourceRoot":"","sources":["../../src/ai/provider-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,qBAAa,eAAe;IAC1B,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;CAuBlD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GeminiProvider } from './providers/gemini.js';
|
|
2
|
+
export class ProviderFactory {
|
|
3
|
+
static createProvider(config) {
|
|
4
|
+
if (config.provider === 'google') {
|
|
5
|
+
if (!config.googleApiKey) {
|
|
6
|
+
throw new Error('Google API key not configured. Please set it using: /config set googleApiKey YOUR_API_KEY');
|
|
7
|
+
}
|
|
8
|
+
// Parse comma-separated keys to validate
|
|
9
|
+
const keys = config.googleApiKey.split(',').map(k => k.trim()).filter(k => k.length > 0);
|
|
10
|
+
if (keys.length === 0) {
|
|
11
|
+
throw new Error('No valid Google API keys provided');
|
|
12
|
+
}
|
|
13
|
+
return new GeminiProvider(config.googleApiKey, config.model);
|
|
14
|
+
}
|
|
15
|
+
else if (config.provider === 'openrouter') {
|
|
16
|
+
if (!config.openrouterApiKey) {
|
|
17
|
+
throw new Error('OpenRouter API key not configured. Please set it using: /config set openrouterApiKey YOUR_API_KEY');
|
|
18
|
+
}
|
|
19
|
+
// OpenRouter provider will be implemented later for full version
|
|
20
|
+
throw new Error('OpenRouter provider not yet implemented in MVP. Use Google provider for now.');
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw new Error(`Unknown provider: ${config.provider}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=provider-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-factory.js","sourceRoot":"","sources":["../../src/ai/provider-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,MAAM,OAAO,eAAe;IAC1B,MAAM,CAAC,cAAc,CAAC,MAAc;QAClC,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,2FAA2F,CAAC,CAAC;YAC/G,CAAC;YAED,yCAAyC;YACzC,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACzF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,CAAC;YAED,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/D,CAAC;aAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;YAC5C,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CAAC,mGAAmG,CAAC,CAAC;YACvH,CAAC;YACD,iEAAiE;YACjE,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;QAClG,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Message, StreamChunk } from '../types.js';
|
|
2
|
+
export interface Tool {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface ChatOptions {
|
|
8
|
+
messages: Message[];
|
|
9
|
+
tools?: Tool[] | any[];
|
|
10
|
+
temperature?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class AIProvider {
|
|
13
|
+
protected apiKey: string;
|
|
14
|
+
protected model: string;
|
|
15
|
+
constructor(apiKey: string, model: string);
|
|
16
|
+
/**
|
|
17
|
+
* Send a chat request and stream the response
|
|
18
|
+
*/
|
|
19
|
+
abstract stream(options: ChatOptions): AsyncGenerator<StreamChunk, void, unknown>;
|
|
20
|
+
/**
|
|
21
|
+
* List available models
|
|
22
|
+
*/
|
|
23
|
+
abstract listModels(): Promise<string[]>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/ai/providers/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,WAAW,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,8BAAsB,UAAU;IAC9B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAKzC;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC;IAEjF;;OAEG;IACH,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/ai/providers/base.ts"],"names":[],"mappings":"AAcA,MAAM,OAAgB,UAAU;IACpB,MAAM,CAAS;IACf,KAAK,CAAS;IAExB,YAAY,MAAc,EAAE,KAAa;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CAWF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AIProvider, ChatOptions } from './base.js';
|
|
2
|
+
import { StreamChunk } from '../types.js';
|
|
3
|
+
export declare class GeminiProvider extends AIProvider {
|
|
4
|
+
private apiKeys;
|
|
5
|
+
private currentKeyIndex;
|
|
6
|
+
private genAI;
|
|
7
|
+
private generativeModel;
|
|
8
|
+
constructor(apiKey: string, model?: string);
|
|
9
|
+
/**
|
|
10
|
+
* Rotate to the next API key
|
|
11
|
+
*/
|
|
12
|
+
private rotateApiKey;
|
|
13
|
+
/**
|
|
14
|
+
* Convert our Message format to Gemini Content format
|
|
15
|
+
*/
|
|
16
|
+
private convertMessagesToContents;
|
|
17
|
+
/**
|
|
18
|
+
* Convert our Tool format to Gemini Function Declaration format
|
|
19
|
+
*/
|
|
20
|
+
private convertToolsToFunctions;
|
|
21
|
+
/**
|
|
22
|
+
* Get or create the generative model
|
|
23
|
+
*/
|
|
24
|
+
private getModel;
|
|
25
|
+
/**
|
|
26
|
+
* Stream chat response
|
|
27
|
+
*/
|
|
28
|
+
stream(options: ChatOptions): AsyncGenerator<StreamChunk, void, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* List available models
|
|
31
|
+
*/
|
|
32
|
+
listModels(): Promise<string[]>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=gemini.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini.d.ts","sourceRoot":"","sources":["../../../src/ai/providers/gemini.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAQ,WAAW,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAW,WAAW,EAAY,MAAM,aAAa,CAAC;AAE7D,qBAAa,cAAe,SAAQ,UAAU;IAC5C,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,eAAe,CAAgC;gBAE3C,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAA+B;IAalE;;OAEG;IACH,OAAO,CAAC,YAAY;IAMpB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAkBjC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAiB/B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAchB;;OAEG;IACI,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC;IAgE/E;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAYtC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { GoogleGenerativeAI, SchemaType } from '@google/generative-ai';
|
|
2
|
+
import { AIProvider } from './base.js';
|
|
3
|
+
export class GeminiProvider extends AIProvider {
|
|
4
|
+
apiKeys;
|
|
5
|
+
currentKeyIndex = 0;
|
|
6
|
+
genAI;
|
|
7
|
+
generativeModel = null;
|
|
8
|
+
constructor(apiKey, model = 'gemini-2.0-flash-exp') {
|
|
9
|
+
super(apiKey, model);
|
|
10
|
+
// Parse comma-separated keys
|
|
11
|
+
this.apiKeys = apiKey.split(',').map(key => key.trim()).filter(key => key.length > 0);
|
|
12
|
+
if (this.apiKeys.length === 0) {
|
|
13
|
+
throw new Error('No valid API keys provided');
|
|
14
|
+
}
|
|
15
|
+
// Initialize with first key
|
|
16
|
+
this.genAI = new GoogleGenerativeAI(this.apiKeys[0]);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Rotate to the next API key
|
|
20
|
+
*/
|
|
21
|
+
rotateApiKey() {
|
|
22
|
+
this.currentKeyIndex = (this.currentKeyIndex + 1) % this.apiKeys.length;
|
|
23
|
+
const currentKey = this.apiKeys[this.currentKeyIndex];
|
|
24
|
+
this.genAI = new GoogleGenerativeAI(currentKey);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert our Message format to Gemini Content format
|
|
28
|
+
*/
|
|
29
|
+
convertMessagesToContents(messages) {
|
|
30
|
+
const contents = [];
|
|
31
|
+
for (const message of messages) {
|
|
32
|
+
if (message.role === 'system') {
|
|
33
|
+
// System messages are handled separately in Gemini
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
contents.push({
|
|
37
|
+
role: message.role === 'assistant' ? 'model' : 'user',
|
|
38
|
+
parts: [{ text: message.content }],
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return contents;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Convert our Tool format to Gemini Function Declaration format
|
|
45
|
+
*/
|
|
46
|
+
convertToolsToFunctions(tools) {
|
|
47
|
+
return tools.map(tool => {
|
|
48
|
+
// Handle both formats: direct tool schema or wrapped in schema property
|
|
49
|
+
const schema = tool.schema || tool;
|
|
50
|
+
return {
|
|
51
|
+
name: schema.name,
|
|
52
|
+
description: schema.description,
|
|
53
|
+
parameters: {
|
|
54
|
+
type: SchemaType.OBJECT,
|
|
55
|
+
properties: schema.parameters?.properties || {},
|
|
56
|
+
required: schema.parameters?.required || [],
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get or create the generative model
|
|
63
|
+
*/
|
|
64
|
+
getModel(tools) {
|
|
65
|
+
const modelConfig = {
|
|
66
|
+
model: this.model,
|
|
67
|
+
};
|
|
68
|
+
if (tools && tools.length > 0) {
|
|
69
|
+
modelConfig.tools = [{
|
|
70
|
+
functionDeclarations: this.convertToolsToFunctions(tools),
|
|
71
|
+
}];
|
|
72
|
+
}
|
|
73
|
+
return this.genAI.getGenerativeModel(modelConfig);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Stream chat response
|
|
77
|
+
*/
|
|
78
|
+
async *stream(options) {
|
|
79
|
+
// Rotate API key before each request
|
|
80
|
+
this.rotateApiKey();
|
|
81
|
+
try {
|
|
82
|
+
const model = this.getModel(options.tools);
|
|
83
|
+
const contents = this.convertMessagesToContents(options.messages);
|
|
84
|
+
// Find system message for system instruction
|
|
85
|
+
const systemMessage = options.messages.find(m => m.role === 'system');
|
|
86
|
+
// Create chat with history
|
|
87
|
+
// Gemini uses a simplified system instruction - just pass the text
|
|
88
|
+
const chatConfig = {
|
|
89
|
+
history: contents.slice(0, -1), // All messages except the last one
|
|
90
|
+
};
|
|
91
|
+
if (systemMessage) {
|
|
92
|
+
chatConfig.systemInstruction = {
|
|
93
|
+
role: 'user',
|
|
94
|
+
parts: [{ text: systemMessage.content }],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const chat = model.startChat(chatConfig);
|
|
98
|
+
// Get the last user message
|
|
99
|
+
const lastMessage = contents[contents.length - 1];
|
|
100
|
+
const lastMessageText = lastMessage.parts[0].text || '';
|
|
101
|
+
// Stream the response
|
|
102
|
+
const result = await chat.sendMessageStream(lastMessageText);
|
|
103
|
+
for await (const chunk of result.stream) {
|
|
104
|
+
const chunkText = chunk.text();
|
|
105
|
+
const functionCalls = chunk.functionCalls();
|
|
106
|
+
if (chunkText) {
|
|
107
|
+
yield {
|
|
108
|
+
text: chunkText,
|
|
109
|
+
done: false,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (functionCalls && functionCalls.length > 0) {
|
|
113
|
+
const toolCalls = functionCalls.map((fc, index) => ({
|
|
114
|
+
id: `call_${Date.now()}_${index}`,
|
|
115
|
+
name: fc.name,
|
|
116
|
+
arguments: fc.args,
|
|
117
|
+
}));
|
|
118
|
+
yield {
|
|
119
|
+
toolCalls,
|
|
120
|
+
done: false,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
yield { done: true };
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
throw new Error(`Gemini API Error: ${error.message || error}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* List available models
|
|
132
|
+
*/
|
|
133
|
+
async listModels() {
|
|
134
|
+
// Gemini doesn't provide a public API to list models easily
|
|
135
|
+
// Return commonly available models
|
|
136
|
+
return [
|
|
137
|
+
'gemini-2.5-flash',
|
|
138
|
+
'gemini-2.5-pro',
|
|
139
|
+
'gemini-2.0-flash-exp',
|
|
140
|
+
'gemini-2.0-flash-thinking-exp',
|
|
141
|
+
'gemini-1.5-pro',
|
|
142
|
+
'gemini-1.5-flash',
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=gemini.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../src/ai/providers/gemini.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAkC,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACvG,OAAO,EAAE,UAAU,EAAqB,MAAM,WAAW,CAAC;AAG1D,MAAM,OAAO,cAAe,SAAQ,UAAU;IACpC,OAAO,CAAW;IAClB,eAAe,GAAW,CAAC,CAAC;IAC5B,KAAK,CAAqB;IAC1B,eAAe,GAA2B,IAAI,CAAC;IAEvD,YAAY,MAAc,EAAE,QAAgB,sBAAsB;QAChE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACrB,6BAA6B;QAC7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAEtF,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QAED,4BA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KAAU,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,qBAAqB,KAAK,CAAC,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,4DAA4D;QAC5D,mCAAmC;QACnC,OAAO;YACL,kBAAkB;YAClB,gBAAgB;YAChB,sBAAsB;YACtB,+BAA+B;YAC/B,gBAAgB;YAChB,kBAAkB;SACnB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface Message {
|
|
2
|
+
role: 'user' | 'assistant' | 'system';
|
|
3
|
+
content: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ToolCall {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
arguments: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
export interface ToolResult {
|
|
11
|
+
toolCallId: string;
|
|
12
|
+
result: string;
|
|
13
|
+
isError?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface StreamChunk {
|
|
16
|
+
text?: string;
|
|
17
|
+
toolCalls?: ToolCall[];
|
|
18
|
+
done: boolean;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,IAAI,EAAE,OAAO,CAAC;CACf"}
|
package/dist/ai/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":""}
|