codex-linux 1.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/.claude/settings.local.json +10 -0
- package/.eslintrc.json +27 -0
- package/.github/workflows/ci.yml +156 -0
- package/.huskyrc +7 -0
- package/.lintstagedrc +13 -0
- package/.prettierrc +12 -0
- package/CLAUDE.md +163 -0
- package/DESIGN_SUPERIOR.md +73 -0
- package/Dockerfile +64 -0
- package/INSTALLATION.md +152 -0
- package/LICENSE +21 -0
- package/README.md +245 -0
- package/assets/skills/code-review/instructions.md +102 -0
- package/assets/skills/code-review/skill.yaml +15 -0
- package/assets/skills/refactoring/instructions.md +149 -0
- package/assets/skills/refactoring/skill.yaml +15 -0
- package/assets/skills/testing/skill.yaml +15 -0
- package/commitlint.config.js +23 -0
- package/dist/main/DatabaseManager.js +763 -0
- package/dist/main/DatabaseManager.js.map +1 -0
- package/dist/main/SettingsManager.js +61 -0
- package/dist/main/SettingsManager.js.map +1 -0
- package/dist/main/agents/AgentOrchestrator.js +787 -0
- package/dist/main/agents/AgentOrchestrator.js.map +1 -0
- package/dist/main/agents/AgentSDK.js +219 -0
- package/dist/main/agents/AgentSDK.js.map +1 -0
- package/dist/main/agents/AgentTools.js +348 -0
- package/dist/main/agents/AgentTools.js.map +1 -0
- package/dist/main/agents/CodeIndex.js +233 -0
- package/dist/main/agents/CodeIndex.js.map +1 -0
- package/dist/main/agents/EmbeddingService.js +80 -0
- package/dist/main/agents/EmbeddingService.js.map +1 -0
- package/dist/main/agents/NativeToolCalling.js +206 -0
- package/dist/main/agents/NativeToolCalling.js.map +1 -0
- package/dist/main/api/APIServer.js +278 -0
- package/dist/main/api/APIServer.js.map +1 -0
- package/dist/main/api/RateLimiter.js +138 -0
- package/dist/main/api/RateLimiter.js.map +1 -0
- package/dist/main/api/WebSocketManager.js +300 -0
- package/dist/main/api/WebSocketManager.js.map +1 -0
- package/dist/main/assistant/ContextOptimizer.js +192 -0
- package/dist/main/assistant/ContextOptimizer.js.map +1 -0
- package/dist/main/assistant/PredictedOutputManager.js +172 -0
- package/dist/main/assistant/PredictedOutputManager.js.map +1 -0
- package/dist/main/assistant/PromptCacheManager.js +193 -0
- package/dist/main/assistant/PromptCacheManager.js.map +1 -0
- package/dist/main/assistant/PromptOptimizer.js +626 -0
- package/dist/main/assistant/PromptOptimizer.js.map +1 -0
- package/dist/main/assistant/SmartCodeAssistant.js +224 -0
- package/dist/main/assistant/SmartCodeAssistant.js.map +1 -0
- package/dist/main/auth/SessionManager.js +300 -0
- package/dist/main/auth/SessionManager.js.map +1 -0
- package/dist/main/automations/AdvancedWebhookSystem.js +212 -0
- package/dist/main/automations/AdvancedWebhookSystem.js.map +1 -0
- package/dist/main/automations/AutomationScheduler.js +269 -0
- package/dist/main/automations/AutomationScheduler.js.map +1 -0
- package/dist/main/automations/BatchProcessingSystem.js +159 -0
- package/dist/main/automations/BatchProcessingSystem.js.map +1 -0
- package/dist/main/automations/BrowserAutomationManager.js +195 -0
- package/dist/main/automations/BrowserAutomationManager.js.map +1 -0
- package/dist/main/automations/GitHubActionsManager.js +129 -0
- package/dist/main/automations/GitHubActionsManager.js.map +1 -0
- package/dist/main/automations/GitLabCIManager.js +122 -0
- package/dist/main/automations/GitLabCIManager.js.map +1 -0
- package/dist/main/automations/PriorityQueueManager.js +240 -0
- package/dist/main/automations/PriorityQueueManager.js.map +1 -0
- package/dist/main/background/BackgroundModeManager.js +117 -0
- package/dist/main/background/BackgroundModeManager.js.map +1 -0
- package/dist/main/backup/BackupManager.js +254 -0
- package/dist/main/backup/BackupManager.js.map +1 -0
- package/dist/main/backup/MigrationManager.js +114 -0
- package/dist/main/backup/MigrationManager.js.map +1 -0
- package/dist/main/commands/SlashCommandManager.js +399 -0
- package/dist/main/commands/SlashCommandManager.js.map +1 -0
- package/dist/main/config/ClaudeMdParser.js +519 -0
- package/dist/main/config/ClaudeMdParser.js.map +1 -0
- package/dist/main/config/CustomizationManager.js +381 -0
- package/dist/main/config/CustomizationManager.js.map +1 -0
- package/dist/main/config/LaunchConfigManager.js +211 -0
- package/dist/main/config/LaunchConfigManager.js.map +1 -0
- package/dist/main/config/SettingsManager.js +166 -0
- package/dist/main/config/SettingsManager.js.map +1 -0
- package/dist/main/connectors/ConnectorManager.js +151 -0
- package/dist/main/connectors/ConnectorManager.js.map +1 -0
- package/dist/main/connectors/DatabaseConnector.js +222 -0
- package/dist/main/connectors/DatabaseConnector.js.map +1 -0
- package/dist/main/cowork/CoworkManager.js +324 -0
- package/dist/main/cowork/CoworkManager.js.map +1 -0
- package/dist/main/evals/AgentEvalFramework.js +538 -0
- package/dist/main/evals/AgentEvalFramework.js.map +1 -0
- package/dist/main/evals/GraderManager.js +285 -0
- package/dist/main/evals/GraderManager.js.map +1 -0
- package/dist/main/git/GitWorktreeManager.js +214 -0
- package/dist/main/git/GitWorktreeManager.js.map +1 -0
- package/dist/main/github/GitHubPRMonitor.js +244 -0
- package/dist/main/github/GitHubPRMonitor.js.map +1 -0
- package/dist/main/ide/ContinueInManager.js +181 -0
- package/dist/main/ide/ContinueInManager.js.map +1 -0
- package/dist/main/ide/IDEIntegration.js +277 -0
- package/dist/main/ide/IDEIntegration.js.map +1 -0
- package/dist/main/integrations/LinearManager.js +252 -0
- package/dist/main/integrations/LinearManager.js.map +1 -0
- package/dist/main/integrations/SlackBotManager.js +247 -0
- package/dist/main/integrations/SlackBotManager.js.map +1 -0
- package/dist/main/lsp/LSPManager.js +394 -0
- package/dist/main/lsp/LSPManager.js.map +1 -0
- package/dist/main/main.js +1087 -0
- package/dist/main/main.js.map +1 -0
- package/dist/main/mcp/MCPConfigurationManager.js +281 -0
- package/dist/main/mcp/MCPConfigurationManager.js.map +1 -0
- package/dist/main/mcp/MCPManager.js +710 -0
- package/dist/main/mcp/MCPManager.js.map +1 -0
- package/dist/main/mcp/MCPRegistry.js +272 -0
- package/dist/main/mcp/MCPRegistry.js.map +1 -0
- package/dist/main/monitoring/ErrorRecoveryManager.js +268 -0
- package/dist/main/monitoring/ErrorRecoveryManager.js.map +1 -0
- package/dist/main/monitoring/ErrorTracker.js +57 -0
- package/dist/main/monitoring/ErrorTracker.js.map +1 -0
- package/dist/main/monitoring/MetricsCollector.js +155 -0
- package/dist/main/monitoring/MetricsCollector.js.map +1 -0
- package/dist/main/monitoring/TraceGradingSystem.js +148 -0
- package/dist/main/monitoring/TraceGradingSystem.js.map +1 -0
- package/dist/main/notifications/NotificationManager.js +67 -0
- package/dist/main/notifications/NotificationManager.js.map +1 -0
- package/dist/main/pair/AIPairProgramming.js +200 -0
- package/dist/main/pair/AIPairProgramming.js.map +1 -0
- package/dist/main/plugins/PluginManager.js +222 -0
- package/dist/main/plugins/PluginManager.js.map +1 -0
- package/dist/main/plugins/PluginMarketplace.js +237 -0
- package/dist/main/plugins/PluginMarketplace.js.map +1 -0
- package/dist/main/preload.js +189 -0
- package/dist/main/preload.js.map +1 -0
- package/dist/main/preview/PreviewSessionManager.js +170 -0
- package/dist/main/preview/PreviewSessionManager.js.map +1 -0
- package/dist/main/providers/AIProviderManager.js +327 -0
- package/dist/main/providers/AIProviderManager.js.map +1 -0
- package/dist/main/providers/FineTuningManager.js +276 -0
- package/dist/main/providers/FineTuningManager.js.map +1 -0
- package/dist/main/providers/FreeModelsProvider.js +1104 -0
- package/dist/main/providers/FreeModelsProvider.js.map +1 -0
- package/dist/main/realtime/RealtimeManager.js +116 -0
- package/dist/main/realtime/RealtimeManager.js.map +1 -0
- package/dist/main/remote/CloudEnvironmentManager.js +232 -0
- package/dist/main/remote/CloudEnvironmentManager.js.map +1 -0
- package/dist/main/remote/RemoteSessionManager.js +255 -0
- package/dist/main/remote/RemoteSessionManager.js.map +1 -0
- package/dist/main/search/DeepResearchManager.js +335 -0
- package/dist/main/search/DeepResearchManager.js.map +1 -0
- package/dist/main/search/WebSearchIntegration.js +147 -0
- package/dist/main/search/WebSearchIntegration.js.map +1 -0
- package/dist/main/security/AdminConsoleManager.js +223 -0
- package/dist/main/security/AdminConsoleManager.js.map +1 -0
- package/dist/main/security/AuditLogger.js +136 -0
- package/dist/main/security/AuditLogger.js.map +1 -0
- package/dist/main/security/PermissionManager.js +144 -0
- package/dist/main/security/PermissionManager.js.map +1 -0
- package/dist/main/security/SSOManager.js +173 -0
- package/dist/main/security/SSOManager.js.map +1 -0
- package/dist/main/security/SecurityManager.js +152 -0
- package/dist/main/security/SecurityManager.js.map +1 -0
- package/dist/main/skills/SkillsManager.js +223 -0
- package/dist/main/skills/SkillsManager.js.map +1 -0
- package/dist/main/ssh/SSHManager.js +65 -0
- package/dist/main/ssh/SSHManager.js.map +1 -0
- package/dist/main/streaming/StreamingManager.js +225 -0
- package/dist/main/streaming/StreamingManager.js.map +1 -0
- package/dist/main/sync/CloudSyncManager.js +422 -0
- package/dist/main/sync/CloudSyncManager.js.map +1 -0
- package/dist/main/types.js +28 -0
- package/dist/main/types.js.map +1 -0
- package/dist/main/verification/AutoVerifyManager.js +235 -0
- package/dist/main/verification/AutoVerifyManager.js.map +1 -0
- package/dist/main/vision/ComputerUseManager.js +376 -0
- package/dist/main/vision/ComputerUseManager.js.map +1 -0
- package/dist/main/vision/ImageVideoGenerationManager.js +401 -0
- package/dist/main/vision/ImageVideoGenerationManager.js.map +1 -0
- package/dist/main/vision/VisionManager.js +172 -0
- package/dist/main/vision/VisionManager.js.map +1 -0
- package/dist/renderer/assets/main-DJlZQBCA.js +304 -0
- package/dist/renderer/assets/main-N33ZXEr8.css +1 -0
- package/dist/renderer/index.html +21 -0
- package/dist/renderer/manifest.json +42 -0
- package/dist/renderer/sw.ts +109 -0
- package/dist/shared/types.js +35 -0
- package/dist/shared/types.js.map +1 -0
- package/docker-compose.yml +65 -0
- package/docs/API.md +307 -0
- package/docs/USER_GUIDE.md +476 -0
- package/examples/plugins/sample-plugin/package.json +41 -0
- package/examples/plugins/sample-plugin/src/index.ts +75 -0
- package/index.html +20 -0
- package/jest.config.js +39 -0
- package/package.json +180 -0
- package/packages/cli/package.json +29 -0
- package/packages/cli/src/commands/agents.ts +199 -0
- package/packages/cli/src/commands/tasks.ts +61 -0
- package/packages/cli/src/index.ts +91 -0
- package/packages/cli/src/utils/api.ts +45 -0
- package/packages/cli/src/utils/config.ts +61 -0
- package/packages/npm-installer/bin/codex-linux +126 -0
- package/packages/npm-installer/lib/download.js +273 -0
- package/packages/npm-installer/package.json +42 -0
- package/packages/vscode-extension/package.json +167 -0
- package/packages/vscode-extension/src/api.ts +68 -0
- package/packages/vscode-extension/src/extension.ts +161 -0
- package/packages/vscode-extension/src/panels/chatPanel.ts +265 -0
- package/packages/vscode-extension/src/panels/createAgentPanel.ts +227 -0
- package/packages/vscode-extension/src/providers/agentsProvider.ts +80 -0
- package/postcss.config.js +6 -0
- package/public/manifest.json +42 -0
- package/public/sw.ts +109 -0
- package/scripts/install-dev.sh +103 -0
- package/scripts/install.sh +275 -0
- package/src/main/DatabaseManager.ts +950 -0
- package/src/main/SettingsManager.ts +63 -0
- package/src/main/agents/AgentOrchestrator.ts +930 -0
- package/src/main/agents/AgentSDK.ts +269 -0
- package/src/main/agents/AgentTools.ts +380 -0
- package/src/main/agents/CodeIndex.ts +240 -0
- package/src/main/agents/EmbeddingService.ts +88 -0
- package/src/main/agents/NativeToolCalling.ts +245 -0
- package/src/main/api/APIServer.ts +316 -0
- package/src/main/api/RateLimiter.ts +165 -0
- package/src/main/api/WebSocketManager.ts +398 -0
- package/src/main/assistant/ContextOptimizer.ts +214 -0
- package/src/main/assistant/PredictedOutputManager.ts +265 -0
- package/src/main/assistant/PromptCacheManager.ts +280 -0
- package/src/main/assistant/PromptOptimizer.ts +746 -0
- package/src/main/assistant/SmartCodeAssistant.ts +234 -0
- package/src/main/auth/SessionManager.ts +415 -0
- package/src/main/automations/AdvancedWebhookSystem.ts +281 -0
- package/src/main/automations/AutomationScheduler.ts +272 -0
- package/src/main/automations/BatchProcessingSystem.ts +207 -0
- package/src/main/automations/BrowserAutomationManager.ts +203 -0
- package/src/main/automations/GitHubActionsManager.ts +151 -0
- package/src/main/automations/GitLabCIManager.ts +206 -0
- package/src/main/automations/PriorityQueueManager.ts +328 -0
- package/src/main/background/BackgroundModeManager.ts +130 -0
- package/src/main/backup/BackupManager.ts +287 -0
- package/src/main/backup/MigrationManager.ts +132 -0
- package/src/main/commands/SlashCommandManager.ts +407 -0
- package/src/main/config/ClaudeMdParser.ts +539 -0
- package/src/main/config/CustomizationManager.ts +493 -0
- package/src/main/config/LaunchConfigManager.ts +212 -0
- package/src/main/config/SettingsManager.ts +163 -0
- package/src/main/connectors/ConnectorManager.ts +175 -0
- package/src/main/connectors/DatabaseConnector.ts +212 -0
- package/src/main/cowork/CoworkManager.ts +431 -0
- package/src/main/evals/AgentEvalFramework.ts +665 -0
- package/src/main/evals/GraderManager.ts +417 -0
- package/src/main/git/GitWorktreeManager.ts +211 -0
- package/src/main/github/GitHubPRMonitor.ts +317 -0
- package/src/main/ide/ContinueInManager.ts +180 -0
- package/src/main/ide/IDEIntegration.ts +288 -0
- package/src/main/integrations/LinearManager.ts +327 -0
- package/src/main/integrations/SlackBotManager.ts +312 -0
- package/src/main/lsp/LSPManager.ts +445 -0
- package/src/main/main.ts +1221 -0
- package/src/main/mcp/MCPConfigurationManager.ts +281 -0
- package/src/main/mcp/MCPManager.ts +799 -0
- package/src/main/mcp/MCPRegistry.ts +273 -0
- package/src/main/monitoring/ErrorRecoveryManager.ts +359 -0
- package/src/main/monitoring/ErrorTracker.ts +60 -0
- package/src/main/monitoring/MetricsCollector.ts +196 -0
- package/src/main/monitoring/TraceGradingSystem.ts +196 -0
- package/src/main/notifications/NotificationManager.ts +96 -0
- package/src/main/pair/AIPairProgramming.ts +290 -0
- package/src/main/plugins/PluginManager.ts +266 -0
- package/src/main/plugins/PluginMarketplace.ts +318 -0
- package/src/main/preload.ts +215 -0
- package/src/main/preview/PreviewSessionManager.ts +186 -0
- package/src/main/providers/AIProviderManager.ts +394 -0
- package/src/main/providers/FineTuningManager.ts +390 -0
- package/src/main/providers/FreeModelsProvider.ts +1156 -0
- package/src/main/realtime/RealtimeManager.ts +147 -0
- package/src/main/remote/CloudEnvironmentManager.ts +253 -0
- package/src/main/remote/RemoteSessionManager.ts +323 -0
- package/src/main/search/DeepResearchManager.ts +458 -0
- package/src/main/search/WebSearchIntegration.ts +203 -0
- package/src/main/security/AdminConsoleManager.ts +244 -0
- package/src/main/security/AuditLogger.ts +143 -0
- package/src/main/security/PermissionManager.ts +184 -0
- package/src/main/security/SSOManager.ts +241 -0
- package/src/main/security/SecurityManager.ts +139 -0
- package/src/main/skills/SkillsManager.ts +218 -0
- package/src/main/ssh/SSHManager.ts +86 -0
- package/src/main/streaming/StreamingManager.ts +306 -0
- package/src/main/sync/CloudSyncManager.ts +532 -0
- package/src/main/verification/AutoVerifyManager.ts +285 -0
- package/src/main/vision/ComputerUseManager.ts +475 -0
- package/src/main/vision/ImageVideoGenerationManager.ts +526 -0
- package/src/main/vision/VisionManager.ts +186 -0
- package/src/renderer/App.tsx +314 -0
- package/src/renderer/components/AdvancedSettingsPanel.tsx +225 -0
- package/src/renderer/components/AgentPanel.tsx +760 -0
- package/src/renderer/components/AppPreview.tsx +220 -0
- package/src/renderer/components/AuditTrailPanel.tsx +148 -0
- package/src/renderer/components/AutomationPanel.tsx +220 -0
- package/src/renderer/components/ChatInterface.tsx +595 -0
- package/src/renderer/components/ChatTab.tsx +296 -0
- package/src/renderer/components/CodeEditor.tsx +257 -0
- package/src/renderer/components/CodeReviewPanel.tsx +256 -0
- package/src/renderer/components/CodeWorkspace.tsx +192 -0
- package/src/renderer/components/CodebaseDashboard.tsx +295 -0
- package/src/renderer/components/ComputerUsePanel.tsx +262 -0
- package/src/renderer/components/ConnectorsPanel.tsx +471 -0
- package/src/renderer/components/ContextMenu.tsx +155 -0
- package/src/renderer/components/ContextUsageDisplay.tsx +248 -0
- package/src/renderer/components/CoworkPanel.tsx +415 -0
- package/src/renderer/components/DiffViewer.tsx +452 -0
- package/src/renderer/components/ErrorBoundary.tsx +273 -0
- package/src/renderer/components/ExtendedThinkingToggle.tsx +244 -0
- package/src/renderer/components/FileAttachments.tsx +247 -0
- package/src/renderer/components/FileExplorer.tsx +242 -0
- package/src/renderer/components/FileExplorerPanel.tsx +302 -0
- package/src/renderer/components/GitPanel.tsx +154 -0
- package/src/renderer/components/Header.tsx +113 -0
- package/src/renderer/components/MCPPanel.tsx +326 -0
- package/src/renderer/components/MentionAutocomplete.tsx +239 -0
- package/src/renderer/components/PermissionPanel.tsx +159 -0
- package/src/renderer/components/PermissionSelector.tsx +203 -0
- package/src/renderer/components/PluginMarketplace.tsx +325 -0
- package/src/renderer/components/PromptOptimizerPanel.tsx +399 -0
- package/src/renderer/components/SearchPanel.tsx +173 -0
- package/src/renderer/components/SearchReplace.tsx +284 -0
- package/src/renderer/components/SessionSidebar.tsx +367 -0
- package/src/renderer/components/SettingsPanel.tsx +426 -0
- package/src/renderer/components/Sidebar.tsx +100 -0
- package/src/renderer/components/SkillsPanel.tsx +245 -0
- package/src/renderer/components/SplitPane.tsx +173 -0
- package/src/renderer/components/Terminal.tsx +190 -0
- package/src/renderer/components/VoiceCommand.tsx +129 -0
- package/src/renderer/components/WorktreePanel.tsx +163 -0
- package/src/renderer/components/ui/AriaComponents.tsx +193 -0
- package/src/renderer/components/ui/Button.tsx +68 -0
- package/src/renderer/components/ui/Card.tsx +102 -0
- package/src/renderer/components/ui/Input.tsx +44 -0
- package/src/renderer/components/ui/Skeleton.tsx +55 -0
- package/src/renderer/components/ui/VirtualList.tsx +196 -0
- package/src/renderer/i18n/I18nProvider.tsx +101 -0
- package/src/renderer/i18n/de.ts +161 -0
- package/src/renderer/i18n/en.ts +163 -0
- package/src/renderer/i18n/es.ts +161 -0
- package/src/renderer/i18n/fr.ts +161 -0
- package/src/renderer/i18n/index.ts +44 -0
- package/src/renderer/index.css +129 -0
- package/src/renderer/lib/accessibility.tsx +287 -0
- package/src/renderer/lib/hooks.ts +304 -0
- package/src/renderer/lib/utils.ts +6 -0
- package/src/renderer/main.tsx +25 -0
- package/src/renderer/styles/minimalist.css +539 -0
- package/src/renderer/sw.ts +180 -0
- package/src/renderer/types.d.ts +138 -0
- package/src/shared/types.ts +813 -0
- package/supabase/schema.sql +234 -0
- package/tailwind.config.js +78 -0
- package/tests/e2e/package.json +15 -0
- package/tests/e2e/playwright.config.ts +31 -0
- package/tests/e2e/specs/app.spec.ts +194 -0
- package/tests/setup.ts +99 -0
- package/tests/unit/AgentOrchestrator.test.ts +274 -0
- package/tests/unit/DatabaseManager.test.ts +262 -0
- package/tests/unit/GitWorktreeManager.test.ts +150 -0
- package/tests/unit/SecurityManager.test.ts +110 -0
- package/tsconfig.main.json +22 -0
- package/tsconfig.renderer.json +27 -0
- package/vite.config.ts +28 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import crypto from 'crypto';
|
|
4
|
+
import log from 'electron-log';
|
|
5
|
+
import { EmbeddingService } from './EmbeddingService';
|
|
6
|
+
|
|
7
|
+
interface CodeIndexEntry {
|
|
8
|
+
id: string;
|
|
9
|
+
filePath: string;
|
|
10
|
+
content: string;
|
|
11
|
+
chunkStart: number;
|
|
12
|
+
chunkEnd: number;
|
|
13
|
+
embedding?: number[];
|
|
14
|
+
lastModified: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface SearchResult {
|
|
18
|
+
filePath: string;
|
|
19
|
+
chunkStart: number;
|
|
20
|
+
chunkEnd: number;
|
|
21
|
+
content: string;
|
|
22
|
+
similarity: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class CodeIndex {
|
|
26
|
+
private indexPath: string;
|
|
27
|
+
private entries: Map<string, CodeIndexEntry> = new Map();
|
|
28
|
+
private worktreePath: string;
|
|
29
|
+
private embeddingService: EmbeddingService | null = null;
|
|
30
|
+
|
|
31
|
+
constructor(worktreePath: string, indexDir: string = '.codex/index', apiKey?: string) {
|
|
32
|
+
this.worktreePath = worktreePath;
|
|
33
|
+
this.indexPath = path.join(worktreePath, indexDir, 'code-index.json');
|
|
34
|
+
if (apiKey) {
|
|
35
|
+
this.embeddingService = new EmbeddingService(apiKey);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async initialize(): Promise<void> {
|
|
40
|
+
try {
|
|
41
|
+
await fs.mkdir(path.dirname(this.indexPath), { recursive: true });
|
|
42
|
+
const content = await fs.readFile(this.indexPath, 'utf-8');
|
|
43
|
+
const data = JSON.parse(content);
|
|
44
|
+
for (const entry of data.entries || []) {
|
|
45
|
+
this.entries.set(entry.id, entry);
|
|
46
|
+
}
|
|
47
|
+
log.info(`Loaded code index with ${this.entries.size} entries`);
|
|
48
|
+
} catch {
|
|
49
|
+
log.info('No existing code index, starting fresh');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async save(): Promise<void> {
|
|
54
|
+
const data = {
|
|
55
|
+
entries: Array.from(this.entries.values()),
|
|
56
|
+
updatedAt: Date.now()
|
|
57
|
+
};
|
|
58
|
+
await fs.writeFile(this.indexPath, JSON.stringify(data, null, 2), 'utf-8');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async indexFile(filePath: string): Promise<void> {
|
|
62
|
+
const fullPath = path.join(this.worktreePath, filePath);
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const stats = await fs.stat(fullPath);
|
|
66
|
+
const content = await fs.readFile(fullPath, 'utf-8');
|
|
67
|
+
|
|
68
|
+
// Split into chunks of ~100 lines
|
|
69
|
+
const lines = content.split('\n');
|
|
70
|
+
const chunkSize = 100;
|
|
71
|
+
|
|
72
|
+
for (let i = 0; i < lines.length; i += chunkSize) {
|
|
73
|
+
const chunkStart = i;
|
|
74
|
+
const chunkEnd = Math.min(i + chunkSize, lines.length);
|
|
75
|
+
const chunkContent = lines.slice(chunkStart, chunkEnd).join('\n');
|
|
76
|
+
|
|
77
|
+
const id = crypto.createHash('md5').update(`${filePath}:${chunkStart}`).digest('hex');
|
|
78
|
+
|
|
79
|
+
// Use real OpenAI embeddings if available, otherwise fallback to simple
|
|
80
|
+
let embedding: number[];
|
|
81
|
+
if (this.embeddingService?.isAvailable()) {
|
|
82
|
+
try {
|
|
83
|
+
embedding = await this.embeddingService.createEmbedding(chunkContent);
|
|
84
|
+
} catch {
|
|
85
|
+
// Fallback to simple embedding if OpenAI fails
|
|
86
|
+
embedding = this.computeSimpleEmbedding(chunkContent);
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
embedding = this.computeSimpleEmbedding(chunkContent);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.entries.set(id, {
|
|
93
|
+
id,
|
|
94
|
+
filePath,
|
|
95
|
+
content: chunkContent,
|
|
96
|
+
chunkStart,
|
|
97
|
+
chunkEnd,
|
|
98
|
+
embedding,
|
|
99
|
+
lastModified: stats.mtimeMs
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
log.info(`Indexed ${filePath}: ${Math.ceil(lines.length / chunkSize)} chunks`);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
log.warn(`Failed to index ${filePath}:`, error);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private computeSimpleEmbedding(content: string): number[] {
|
|
110
|
+
// Simple feature extraction for similarity
|
|
111
|
+
// In production, you'd use a real embedding model like OpenAI's text-embedding-3-small
|
|
112
|
+
const features: number[] = [];
|
|
113
|
+
|
|
114
|
+
// Length feature
|
|
115
|
+
features.push(content.length / 1000);
|
|
116
|
+
|
|
117
|
+
// Character distribution (simplified)
|
|
118
|
+
const chars = content.toLowerCase();
|
|
119
|
+
const total = chars.length || 1;
|
|
120
|
+
|
|
121
|
+
// Code-specific features
|
|
122
|
+
features.push((chars.match(/function|def|class|const|let|var/g) || []).length / total * 10);
|
|
123
|
+
features.push((chars.match(/import|require|from/g) || []).length / total * 10);
|
|
124
|
+
features.push((chars.match(/return|await|async/g) || []).length / total * 10);
|
|
125
|
+
features.push((chars.match(/if|for|while|switch/g) || []).length / total * 10);
|
|
126
|
+
|
|
127
|
+
// Comment density
|
|
128
|
+
features.push((chars.match(/\/\/|\/\*|#/g) || []).length / total * 10);
|
|
129
|
+
|
|
130
|
+
// Pad to fixed size
|
|
131
|
+
while (features.length < 8) features.push(0);
|
|
132
|
+
|
|
133
|
+
return features.slice(0, 8);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private cosineSimilarity(a: number[], b: number[]): number {
|
|
137
|
+
// Use EmbeddingService's implementation for consistency
|
|
138
|
+
return EmbeddingService.cosineSimilarity(a, b);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async search(query: string, limit: number = 5): Promise<SearchResult[]> {
|
|
142
|
+
// Compute query embedding
|
|
143
|
+
let queryEmbedding: number[];
|
|
144
|
+
if (this.embeddingService?.isAvailable()) {
|
|
145
|
+
try {
|
|
146
|
+
queryEmbedding = await this.embeddingService.createEmbedding(query);
|
|
147
|
+
} catch {
|
|
148
|
+
queryEmbedding = this.computeSimpleEmbedding(query);
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
queryEmbedding = this.computeSimpleEmbedding(query);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Score all entries
|
|
155
|
+
const scored: SearchResult[] = [];
|
|
156
|
+
|
|
157
|
+
for (const entry of this.entries.values()) {
|
|
158
|
+
if (!entry.embedding) continue;
|
|
159
|
+
|
|
160
|
+
const similarity = EmbeddingService.cosineSimilarity(queryEmbedding, entry.embedding);
|
|
161
|
+
|
|
162
|
+
// Boost for exact keyword matches
|
|
163
|
+
const keywords = query.toLowerCase().split(/\s+/);
|
|
164
|
+
const contentLower = entry.content.toLowerCase();
|
|
165
|
+
const keywordMatches = keywords.filter(kw => contentLower.includes(kw)).length;
|
|
166
|
+
const boostedSimilarity = similarity + (keywordMatches / keywords.length) * 0.3;
|
|
167
|
+
|
|
168
|
+
if (boostedSimilarity > 0.1) {
|
|
169
|
+
scored.push({
|
|
170
|
+
filePath: entry.filePath,
|
|
171
|
+
chunkStart: entry.chunkStart,
|
|
172
|
+
chunkEnd: entry.chunkEnd,
|
|
173
|
+
content: entry.content,
|
|
174
|
+
similarity: boostedSimilarity
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Sort by similarity and return top results
|
|
180
|
+
scored.sort((a, b) => b.similarity - a.similarity);
|
|
181
|
+
|
|
182
|
+
return scored.slice(0, limit);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async indexProject(): Promise<void> {
|
|
186
|
+
log.info('Starting project indexing...');
|
|
187
|
+
|
|
188
|
+
const extensions = ['.ts', '.tsx', '.js', '.jsx', '.py', '.java', '.go', '.rs', '.md'];
|
|
189
|
+
|
|
190
|
+
async function walk(dir: string): Promise<string[]> {
|
|
191
|
+
const files: string[] = [];
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
195
|
+
|
|
196
|
+
for (const entry of entries) {
|
|
197
|
+
const fullPath = path.join(dir, entry.name);
|
|
198
|
+
const relativePath = path.relative(worktreePath, fullPath);
|
|
199
|
+
|
|
200
|
+
if (entry.isDirectory()) {
|
|
201
|
+
if (!entry.name.startsWith('.') &&
|
|
202
|
+
entry.name !== 'node_modules' &&
|
|
203
|
+
entry.name !== 'dist' &&
|
|
204
|
+
entry.name !== 'build') {
|
|
205
|
+
files.push(...await walk(fullPath));
|
|
206
|
+
}
|
|
207
|
+
} else if (entry.isFile()) {
|
|
208
|
+
if (extensions.some(ext => entry.name.endsWith(ext))) {
|
|
209
|
+
files.push(relativePath);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} catch (error) {
|
|
214
|
+
// Skip inaccessible directories
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return files;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const worktreePath = this.worktreePath;
|
|
221
|
+
const allFiles = await walk(worktreePath);
|
|
222
|
+
|
|
223
|
+
log.info(`Found ${allFiles.length} files to index`);
|
|
224
|
+
|
|
225
|
+
for (const file of allFiles.slice(0, 100)) { // Limit to 100 files for now
|
|
226
|
+
await this.indexFile(file);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
await this.save();
|
|
230
|
+
log.info(`Indexed ${this.entries.size} chunks`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
getIndexedFiles(): string[] {
|
|
234
|
+
const files = new Set<string>();
|
|
235
|
+
for (const entry of this.entries.values()) {
|
|
236
|
+
files.add(entry.filePath);
|
|
237
|
+
}
|
|
238
|
+
return Array.from(files);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
|
+
import log from 'electron-log';
|
|
3
|
+
|
|
4
|
+
export interface EmbeddingResult {
|
|
5
|
+
embedding: number[];
|
|
6
|
+
index: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class EmbeddingService {
|
|
10
|
+
private client: OpenAI | null = null;
|
|
11
|
+
private model: string = 'text-embedding-3-small';
|
|
12
|
+
|
|
13
|
+
constructor(apiKey?: string) {
|
|
14
|
+
if (apiKey) {
|
|
15
|
+
this.client = new OpenAI({
|
|
16
|
+
apiKey,
|
|
17
|
+
timeout: 30000,
|
|
18
|
+
maxRetries: 3
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async createEmbedding(text: string): Promise<number[]> {
|
|
24
|
+
if (!this.client) {
|
|
25
|
+
throw new Error('OpenAI client not initialized - no API key');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
// Truncate if too long (max ~8000 tokens for embedding-3)
|
|
30
|
+
const truncatedText = text.length > 30000 ? text.slice(0, 30000) : text;
|
|
31
|
+
|
|
32
|
+
const response = await this.client.embeddings.create({
|
|
33
|
+
model: this.model,
|
|
34
|
+
input: truncatedText,
|
|
35
|
+
encoding_format: 'float'
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return response.data[0].embedding;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
log.error('Failed to create embedding:', error);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async createEmbeddings(texts: string[]): Promise<EmbeddingResult[]> {
|
|
46
|
+
if (!this.client) {
|
|
47
|
+
throw new Error('OpenAI client not initialized - no API key');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
// Truncate texts if too long
|
|
52
|
+
const truncatedTexts = texts.map(t => t.length > 30000 ? t.slice(0, 30000) : t);
|
|
53
|
+
|
|
54
|
+
const response = await this.client.embeddings.create({
|
|
55
|
+
model: this.model,
|
|
56
|
+
input: truncatedTexts,
|
|
57
|
+
encoding_format: 'float'
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return response.data.map(d => ({
|
|
61
|
+
embedding: d.embedding,
|
|
62
|
+
index: d.index
|
|
63
|
+
}));
|
|
64
|
+
} catch (error) {
|
|
65
|
+
log.error('Failed to create embeddings:', error);
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static cosineSimilarity(a: number[], b: number[]): number {
|
|
71
|
+
let dotProduct = 0;
|
|
72
|
+
let normA = 0;
|
|
73
|
+
let normB = 0;
|
|
74
|
+
|
|
75
|
+
for (let i = 0; i < a.length; i++) {
|
|
76
|
+
dotProduct += a[i] * b[i];
|
|
77
|
+
normA += a[i] * a[i];
|
|
78
|
+
normB += b[i] * b[i];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (normA === 0 || normB === 0) return 0;
|
|
82
|
+
return dotProduct / (Math.sqrt(normA) * Math.sqrt(normB));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
isAvailable(): boolean {
|
|
86
|
+
return this.client !== null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import OpenAI from 'openai';
|
|
2
|
+
import log from 'electron-log';
|
|
3
|
+
import { AgentTools, ToolResult } from './AgentTools';
|
|
4
|
+
|
|
5
|
+
interface ToolCall {
|
|
6
|
+
id: string;
|
|
7
|
+
type: 'function';
|
|
8
|
+
function: {
|
|
9
|
+
name: string;
|
|
10
|
+
arguments: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface ToolDefinition {
|
|
15
|
+
type: 'function';
|
|
16
|
+
function: {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
parameters: {
|
|
20
|
+
type: 'object';
|
|
21
|
+
properties: Record<string, any>;
|
|
22
|
+
required?: string[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class NativeToolCalling {
|
|
28
|
+
private client: OpenAI | null = null;
|
|
29
|
+
private tools: AgentTools;
|
|
30
|
+
private toolDefinitions: ToolDefinition[];
|
|
31
|
+
|
|
32
|
+
constructor(apiKey: string | undefined, worktreePath: string) {
|
|
33
|
+
if (apiKey) {
|
|
34
|
+
this.client = new OpenAI({
|
|
35
|
+
apiKey,
|
|
36
|
+
timeout: 60000,
|
|
37
|
+
maxRetries: 3
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
this.tools = new AgentTools(worktreePath);
|
|
41
|
+
this.toolDefinitions = this.buildToolDefinitions();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private buildToolDefinitions(): ToolDefinition[] {
|
|
45
|
+
return [
|
|
46
|
+
{
|
|
47
|
+
type: 'function',
|
|
48
|
+
function: {
|
|
49
|
+
name: 'view',
|
|
50
|
+
description: 'View the contents of a file. Use offset and limit for large files.',
|
|
51
|
+
parameters: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
file_path: { type: 'string', description: 'Path to the file' },
|
|
55
|
+
offset: { type: 'number', description: 'Start line number (1-based)' },
|
|
56
|
+
limit: { type: 'number', description: 'Number of lines to show (max 200)' }
|
|
57
|
+
},
|
|
58
|
+
required: ['file_path']
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'function',
|
|
64
|
+
function: {
|
|
65
|
+
name: 'edit',
|
|
66
|
+
description: 'Edit a file by replacing a specific string. The old_string must match exactly and uniquely.',
|
|
67
|
+
parameters: {
|
|
68
|
+
type: 'object',
|
|
69
|
+
properties: {
|
|
70
|
+
file_path: { type: 'string', description: 'Path to the file' },
|
|
71
|
+
old_string: { type: 'string', description: 'Exact string to replace' },
|
|
72
|
+
new_string: { type: 'string', description: 'Replacement string' }
|
|
73
|
+
},
|
|
74
|
+
required: ['file_path', 'old_string', 'new_string']
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'function',
|
|
80
|
+
function: {
|
|
81
|
+
name: 'bash',
|
|
82
|
+
description: 'Execute a bash command in the worktree. Use for running tests, builds, git commands, etc.',
|
|
83
|
+
parameters: {
|
|
84
|
+
type: 'object',
|
|
85
|
+
properties: {
|
|
86
|
+
command: { type: 'string', description: 'Command to execute' },
|
|
87
|
+
timeout: { type: 'number', description: 'Timeout in milliseconds (default 120000)' }
|
|
88
|
+
},
|
|
89
|
+
required: ['command']
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: 'function',
|
|
95
|
+
function: {
|
|
96
|
+
name: 'glob',
|
|
97
|
+
description: 'Find files matching a glob pattern (e.g., "**/*.ts").',
|
|
98
|
+
parameters: {
|
|
99
|
+
type: 'object',
|
|
100
|
+
properties: {
|
|
101
|
+
pattern: { type: 'string', description: 'Glob pattern' },
|
|
102
|
+
path: { type: 'string', description: 'Directory to search in' }
|
|
103
|
+
},
|
|
104
|
+
required: ['pattern']
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'function',
|
|
110
|
+
function: {
|
|
111
|
+
name: 'grep',
|
|
112
|
+
description: 'Search for a pattern in file contents using grep.',
|
|
113
|
+
parameters: {
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: {
|
|
116
|
+
pattern: { type: 'string', description: 'Search pattern' },
|
|
117
|
+
path: { type: 'string', description: 'Directory to search in' },
|
|
118
|
+
include: { type: 'string', description: 'File pattern to include (e.g., "*.ts")' }
|
|
119
|
+
},
|
|
120
|
+
required: ['pattern']
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
type: 'function',
|
|
126
|
+
function: {
|
|
127
|
+
name: 'ls',
|
|
128
|
+
description: 'List the contents of a directory.',
|
|
129
|
+
parameters: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: {
|
|
132
|
+
path: { type: 'string', description: 'Directory path' }
|
|
133
|
+
},
|
|
134
|
+
required: ['path']
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
isAvailable(): boolean {
|
|
142
|
+
return this.client !== null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async executeWithTools(
|
|
146
|
+
model: string,
|
|
147
|
+
systemPrompt: string,
|
|
148
|
+
userPrompt: string,
|
|
149
|
+
onToolCall?: (toolCall: ToolCall, result: ToolResult) => void
|
|
150
|
+
): Promise<string> {
|
|
151
|
+
if (!this.client) {
|
|
152
|
+
throw new Error('OpenAI client not initialized');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const messages: any[] = [
|
|
156
|
+
{ role: 'system', content: systemPrompt },
|
|
157
|
+
{ role: 'user', content: userPrompt }
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
let iterations = 0;
|
|
161
|
+
const maxIterations = 20;
|
|
162
|
+
|
|
163
|
+
while (iterations < maxIterations) {
|
|
164
|
+
iterations++;
|
|
165
|
+
|
|
166
|
+
log.info(`Tool calling iteration ${iterations}`);
|
|
167
|
+
|
|
168
|
+
const response = await this.client.chat.completions.create({
|
|
169
|
+
model,
|
|
170
|
+
messages,
|
|
171
|
+
tools: this.toolDefinitions,
|
|
172
|
+
tool_choice: 'auto',
|
|
173
|
+
max_tokens: 4096
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const message = response.choices[0].message;
|
|
177
|
+
|
|
178
|
+
// If no tool calls, we're done
|
|
179
|
+
if (!message.tool_calls || message.tool_calls.length === 0) {
|
|
180
|
+
return message.content || '';
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Add assistant message with tool calls
|
|
184
|
+
messages.push(message);
|
|
185
|
+
|
|
186
|
+
// Execute each tool call
|
|
187
|
+
for (const toolCall of message.tool_calls) {
|
|
188
|
+
const result = await this.executeToolCall(toolCall);
|
|
189
|
+
|
|
190
|
+
if (onToolCall) {
|
|
191
|
+
onToolCall(toolCall as ToolCall, result);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Add tool result to messages
|
|
195
|
+
messages.push({
|
|
196
|
+
role: 'tool',
|
|
197
|
+
tool_call_id: toolCall.id,
|
|
198
|
+
content: result.success
|
|
199
|
+
? result.output
|
|
200
|
+
: `Error: ${result.error || 'Unknown error'}`
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
throw new Error(`Max iterations (${maxIterations}) reached`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private async executeToolCall(toolCall: any): Promise<ToolResult> {
|
|
209
|
+
const { name, arguments: argsString } = toolCall.function;
|
|
210
|
+
|
|
211
|
+
try {
|
|
212
|
+
const args = JSON.parse(argsString);
|
|
213
|
+
|
|
214
|
+
log.info(`Executing tool: ${name}`, args);
|
|
215
|
+
|
|
216
|
+
switch (name) {
|
|
217
|
+
case 'view':
|
|
218
|
+
return await this.tools.view(args);
|
|
219
|
+
case 'edit':
|
|
220
|
+
return await this.tools.edit(args);
|
|
221
|
+
case 'bash':
|
|
222
|
+
return await this.tools.bash(args);
|
|
223
|
+
case 'glob':
|
|
224
|
+
return await this.tools.glob(args);
|
|
225
|
+
case 'grep':
|
|
226
|
+
return await this.tools.grep(args);
|
|
227
|
+
case 'ls':
|
|
228
|
+
return await this.tools.ls(args);
|
|
229
|
+
default:
|
|
230
|
+
return {
|
|
231
|
+
success: false,
|
|
232
|
+
output: '',
|
|
233
|
+
error: `Unknown tool: ${name}`
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
} catch (error) {
|
|
237
|
+
log.error(`Failed to execute tool ${name}:`, error);
|
|
238
|
+
return {
|
|
239
|
+
success: false,
|
|
240
|
+
output: '',
|
|
241
|
+
error: error instanceof Error ? error.message : String(error)
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|