@trenchwork/erosolar 1.1.16
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/LICENSE +21 -0
- package/README.md +232 -0
- package/agents/erosolar-code.rules.json +199 -0
- package/dist/bin/cliMode.d.ts +8 -0
- package/dist/bin/cliMode.d.ts.map +1 -0
- package/dist/bin/cliMode.js +20 -0
- package/dist/bin/cliMode.js.map +1 -0
- package/dist/bin/deepseek.d.ts +3 -0
- package/dist/bin/deepseek.d.ts.map +1 -0
- package/dist/bin/deepseek.js +232 -0
- package/dist/bin/deepseek.js.map +1 -0
- package/dist/bin/erosolar.d.ts +7 -0
- package/dist/bin/erosolar.d.ts.map +1 -0
- package/dist/bin/erosolar.js +7 -0
- package/dist/bin/erosolar.js.map +1 -0
- package/dist/bin/selfTest.d.ts +14 -0
- package/dist/bin/selfTest.d.ts.map +1 -0
- package/dist/bin/selfTest.js +298 -0
- package/dist/bin/selfTest.js.map +1 -0
- package/dist/capabilities/baseCapability.d.ts +72 -0
- package/dist/capabilities/baseCapability.d.ts.map +1 -0
- package/dist/capabilities/baseCapability.js +183 -0
- package/dist/capabilities/baseCapability.js.map +1 -0
- package/dist/capabilities/bashCapability.d.ts +13 -0
- package/dist/capabilities/bashCapability.d.ts.map +1 -0
- package/dist/capabilities/bashCapability.js +24 -0
- package/dist/capabilities/bashCapability.js.map +1 -0
- package/dist/capabilities/editCapability.d.ts +17 -0
- package/dist/capabilities/editCapability.d.ts.map +1 -0
- package/dist/capabilities/editCapability.js +27 -0
- package/dist/capabilities/editCapability.js.map +1 -0
- package/dist/capabilities/enhancedGitCapability.d.ts +7 -0
- package/dist/capabilities/enhancedGitCapability.d.ts.map +1 -0
- package/dist/capabilities/enhancedGitCapability.js +220 -0
- package/dist/capabilities/enhancedGitCapability.js.map +1 -0
- package/dist/capabilities/filesystemCapability.d.ts +13 -0
- package/dist/capabilities/filesystemCapability.d.ts.map +1 -0
- package/dist/capabilities/filesystemCapability.js +24 -0
- package/dist/capabilities/filesystemCapability.js.map +1 -0
- package/dist/capabilities/gitHistoryCapability.d.ts +6 -0
- package/dist/capabilities/gitHistoryCapability.d.ts.map +1 -0
- package/dist/capabilities/gitHistoryCapability.js +184 -0
- package/dist/capabilities/gitHistoryCapability.js.map +1 -0
- package/dist/capabilities/hitlCapability.d.ts +18 -0
- package/dist/capabilities/hitlCapability.d.ts.map +1 -0
- package/dist/capabilities/hitlCapability.js +29 -0
- package/dist/capabilities/hitlCapability.js.map +1 -0
- package/dist/capabilities/index.d.ts +13 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +18 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/kaliCapability.d.ts +14 -0
- package/dist/capabilities/kaliCapability.d.ts.map +1 -0
- package/dist/capabilities/kaliCapability.js +478 -0
- package/dist/capabilities/kaliCapability.js.map +1 -0
- package/dist/capabilities/mcpCapability.d.ts +7 -0
- package/dist/capabilities/mcpCapability.d.ts.map +1 -0
- package/dist/capabilities/mcpCapability.js +80 -0
- package/dist/capabilities/mcpCapability.js.map +1 -0
- package/dist/capabilities/memoryCapability.d.ts +10 -0
- package/dist/capabilities/memoryCapability.d.ts.map +1 -0
- package/dist/capabilities/memoryCapability.js +22 -0
- package/dist/capabilities/memoryCapability.js.map +1 -0
- package/dist/capabilities/notebookCapability.d.ts +6 -0
- package/dist/capabilities/notebookCapability.d.ts.map +1 -0
- package/dist/capabilities/notebookCapability.js +17 -0
- package/dist/capabilities/notebookCapability.js.map +1 -0
- package/dist/capabilities/searchCapability.d.ts +19 -0
- package/dist/capabilities/searchCapability.d.ts.map +1 -0
- package/dist/capabilities/searchCapability.js +29 -0
- package/dist/capabilities/searchCapability.js.map +1 -0
- package/dist/capabilities/skillCapability.d.ts +6 -0
- package/dist/capabilities/skillCapability.d.ts.map +1 -0
- package/dist/capabilities/skillCapability.js +17 -0
- package/dist/capabilities/skillCapability.js.map +1 -0
- package/dist/capabilities/todoCapability.d.ts +11 -0
- package/dist/capabilities/todoCapability.d.ts.map +1 -0
- package/dist/capabilities/todoCapability.js +22 -0
- package/dist/capabilities/todoCapability.js.map +1 -0
- package/dist/capabilities/toolManifest.d.ts +3 -0
- package/dist/capabilities/toolManifest.d.ts.map +1 -0
- package/dist/capabilities/toolManifest.js +163 -0
- package/dist/capabilities/toolManifest.js.map +1 -0
- package/dist/capabilities/toolRegistry.d.ts +25 -0
- package/dist/capabilities/toolRegistry.d.ts.map +1 -0
- package/dist/capabilities/toolRegistry.js +150 -0
- package/dist/capabilities/toolRegistry.js.map +1 -0
- package/dist/capabilities/unifiedCodingCapability.d.ts +62 -0
- package/dist/capabilities/unifiedCodingCapability.d.ts.map +1 -0
- package/dist/capabilities/unifiedCodingCapability.js +788 -0
- package/dist/capabilities/unifiedCodingCapability.js.map +1 -0
- package/dist/capabilities/webCapability.d.ts +23 -0
- package/dist/capabilities/webCapability.d.ts.map +1 -0
- package/dist/capabilities/webCapability.js +33 -0
- package/dist/capabilities/webCapability.js.map +1 -0
- package/dist/config.d.ts +25 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +155 -0
- package/dist/config.js.map +1 -0
- package/dist/contracts/agent-profiles.schema.json +43 -0
- package/dist/contracts/agent-schemas.json +470 -0
- package/dist/contracts/models.schema.json +9 -0
- package/dist/contracts/module-schema.json +367 -0
- package/dist/contracts/schemas/agent-profile.schema.json +157 -0
- package/dist/contracts/schemas/agent-rules.schema.json +238 -0
- package/dist/contracts/schemas/agent-schemas.schema.json +528 -0
- package/dist/contracts/schemas/agent.schema.json +90 -0
- package/dist/contracts/schemas/tool-selection.schema.json +174 -0
- package/dist/contracts/tools.schema.json +42 -0
- package/dist/contracts/unified-schema.json +660 -0
- package/dist/contracts/v1/agent.d.ts +179 -0
- package/dist/contracts/v1/agent.d.ts.map +1 -0
- package/dist/contracts/v1/agent.js +8 -0
- package/dist/contracts/v1/agent.js.map +1 -0
- package/dist/contracts/v1/agentProfileManifest.d.ts +60 -0
- package/dist/contracts/v1/agentProfileManifest.d.ts.map +1 -0
- package/dist/contracts/v1/agentProfileManifest.js +9 -0
- package/dist/contracts/v1/agentProfileManifest.js.map +1 -0
- package/dist/contracts/v1/agentRules.d.ts +60 -0
- package/dist/contracts/v1/agentRules.d.ts.map +1 -0
- package/dist/contracts/v1/agentRules.js +10 -0
- package/dist/contracts/v1/agentRules.js.map +1 -0
- package/dist/contracts/v1/provider.d.ts +149 -0
- package/dist/contracts/v1/provider.d.ts.map +1 -0
- package/dist/contracts/v1/provider.js +7 -0
- package/dist/contracts/v1/provider.js.map +1 -0
- package/dist/contracts/v1/tool.d.ts +136 -0
- package/dist/contracts/v1/tool.d.ts.map +1 -0
- package/dist/contracts/v1/tool.js +7 -0
- package/dist/contracts/v1/tool.js.map +1 -0
- package/dist/contracts/v1/toolAccess.d.ts +43 -0
- package/dist/contracts/v1/toolAccess.d.ts.map +1 -0
- package/dist/contracts/v1/toolAccess.js +9 -0
- package/dist/contracts/v1/toolAccess.js.map +1 -0
- package/dist/core/agent.d.ts +320 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +1627 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/agentProfileManifest.d.ts +3 -0
- package/dist/core/agentProfileManifest.d.ts.map +1 -0
- package/dist/core/agentProfileManifest.js +188 -0
- package/dist/core/agentProfileManifest.js.map +1 -0
- package/dist/core/agentProfiles.d.ts +22 -0
- package/dist/core/agentProfiles.d.ts.map +1 -0
- package/dist/core/agentProfiles.js +35 -0
- package/dist/core/agentProfiles.js.map +1 -0
- package/dist/core/agentRegistry.d.ts +111 -0
- package/dist/core/agentRegistry.d.ts.map +1 -0
- package/dist/core/agentRegistry.js +229 -0
- package/dist/core/agentRegistry.js.map +1 -0
- package/dist/core/agentRulebook.d.ts +11 -0
- package/dist/core/agentRulebook.d.ts.map +1 -0
- package/dist/core/agentRulebook.js +136 -0
- package/dist/core/agentRulebook.js.map +1 -0
- package/dist/core/agentSchemaLoader.d.ts +131 -0
- package/dist/core/agentSchemaLoader.d.ts.map +1 -0
- package/dist/core/agentSchemaLoader.js +235 -0
- package/dist/core/agentSchemaLoader.js.map +1 -0
- package/dist/core/aiErrorFixer.d.ts +57 -0
- package/dist/core/aiErrorFixer.d.ts.map +1 -0
- package/dist/core/aiErrorFixer.js +214 -0
- package/dist/core/aiErrorFixer.js.map +1 -0
- package/dist/core/auth.d.ts +15 -0
- package/dist/core/auth.d.ts.map +1 -0
- package/dist/core/auth.js +291 -0
- package/dist/core/auth.js.map +1 -0
- package/dist/core/bashCommandGuidance.d.ts +16 -0
- package/dist/core/bashCommandGuidance.d.ts.map +1 -0
- package/dist/core/bashCommandGuidance.js +40 -0
- package/dist/core/bashCommandGuidance.js.map +1 -0
- package/dist/core/constants.d.ts +31 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +62 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/contextManager.d.ts +271 -0
- package/dist/core/contextManager.d.ts.map +1 -0
- package/dist/core/contextManager.js +1073 -0
- package/dist/core/contextManager.js.map +1 -0
- package/dist/core/contextWindow.d.ts +42 -0
- package/dist/core/contextWindow.d.ts.map +1 -0
- package/dist/core/contextWindow.js +123 -0
- package/dist/core/contextWindow.js.map +1 -0
- package/dist/core/customCommands.d.ts +19 -0
- package/dist/core/customCommands.d.ts.map +1 -0
- package/dist/core/customCommands.js +85 -0
- package/dist/core/customCommands.js.map +1 -0
- package/dist/core/errors/apiKeyErrors.d.ts +11 -0
- package/dist/core/errors/apiKeyErrors.d.ts.map +1 -0
- package/dist/core/errors/apiKeyErrors.js +159 -0
- package/dist/core/errors/apiKeyErrors.js.map +1 -0
- package/dist/core/errors/errorTypes.d.ts +111 -0
- package/dist/core/errors/errorTypes.d.ts.map +1 -0
- package/dist/core/errors/errorTypes.js +345 -0
- package/dist/core/errors/errorTypes.js.map +1 -0
- package/dist/core/errors/index.d.ts +50 -0
- package/dist/core/errors/index.d.ts.map +1 -0
- package/dist/core/errors/index.js +156 -0
- package/dist/core/errors/index.js.map +1 -0
- package/dist/core/errors/networkErrors.d.ts +14 -0
- package/dist/core/errors/networkErrors.d.ts.map +1 -0
- package/dist/core/errors/networkErrors.js +53 -0
- package/dist/core/errors/networkErrors.js.map +1 -0
- package/dist/core/errors/safetyValidator.d.ts +109 -0
- package/dist/core/errors/safetyValidator.d.ts.map +1 -0
- package/dist/core/errors/safetyValidator.js +271 -0
- package/dist/core/errors/safetyValidator.js.map +1 -0
- package/dist/core/errors.d.ts +4 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +33 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/finalResponseFormatter.d.ts +10 -0
- package/dist/core/finalResponseFormatter.d.ts.map +1 -0
- package/dist/core/finalResponseFormatter.js +14 -0
- package/dist/core/finalResponseFormatter.js.map +1 -0
- package/dist/core/guardrails.d.ts +146 -0
- package/dist/core/guardrails.d.ts.map +1 -0
- package/dist/core/guardrails.js +361 -0
- package/dist/core/guardrails.js.map +1 -0
- package/dist/core/hitl.d.ts +119 -0
- package/dist/core/hitl.d.ts.map +1 -0
- package/dist/core/hitl.js +387 -0
- package/dist/core/hitl.js.map +1 -0
- package/dist/core/hooks.d.ts +95 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +239 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +7 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/inputProtection.d.ts +122 -0
- package/dist/core/inputProtection.d.ts.map +1 -0
- package/dist/core/inputProtection.js +422 -0
- package/dist/core/inputProtection.js.map +1 -0
- package/dist/core/modelDiscovery.d.ts +105 -0
- package/dist/core/modelDiscovery.d.ts.map +1 -0
- package/dist/core/modelDiscovery.js +768 -0
- package/dist/core/modelDiscovery.js.map +1 -0
- package/dist/core/multilinePasteHandler.d.ts +35 -0
- package/dist/core/multilinePasteHandler.d.ts.map +1 -0
- package/dist/core/multilinePasteHandler.js +81 -0
- package/dist/core/multilinePasteHandler.js.map +1 -0
- package/dist/core/preferences.d.ts +65 -0
- package/dist/core/preferences.d.ts.map +1 -0
- package/dist/core/preferences.js +305 -0
- package/dist/core/preferences.js.map +1 -0
- package/dist/core/providerKeys.d.ts +20 -0
- package/dist/core/providerKeys.d.ts.map +1 -0
- package/dist/core/providerKeys.js +40 -0
- package/dist/core/providerKeys.js.map +1 -0
- package/dist/core/refusalDetection.d.ts +2 -0
- package/dist/core/refusalDetection.d.ts.map +1 -0
- package/dist/core/refusalDetection.js +51 -0
- package/dist/core/refusalDetection.js.map +1 -0
- package/dist/core/resultVerification.d.ts +47 -0
- package/dist/core/resultVerification.d.ts.map +1 -0
- package/dist/core/resultVerification.js +126 -0
- package/dist/core/resultVerification.js.map +1 -0
- package/dist/core/schemaValidator.d.ts +49 -0
- package/dist/core/schemaValidator.d.ts.map +1 -0
- package/dist/core/schemaValidator.js +234 -0
- package/dist/core/schemaValidator.js.map +1 -0
- package/dist/core/secretStore.d.ts +48 -0
- package/dist/core/secretStore.d.ts.map +1 -0
- package/dist/core/secretStore.js +268 -0
- package/dist/core/secretStore.js.map +1 -0
- package/dist/core/sessionStorage.d.ts +10 -0
- package/dist/core/sessionStorage.d.ts.map +1 -0
- package/dist/core/sessionStorage.js +46 -0
- package/dist/core/sessionStorage.js.map +1 -0
- package/dist/core/sessionStore.d.ts +35 -0
- package/dist/core/sessionStore.d.ts.map +1 -0
- package/dist/core/sessionStore.js +191 -0
- package/dist/core/sessionStore.js.map +1 -0
- package/dist/core/shutdown.d.ts +34 -0
- package/dist/core/shutdown.d.ts.map +1 -0
- package/dist/core/shutdown.js +186 -0
- package/dist/core/shutdown.js.map +1 -0
- package/dist/core/sudoPasswordManager.d.ts +52 -0
- package/dist/core/sudoPasswordManager.d.ts.map +1 -0
- package/dist/core/sudoPasswordManager.js +115 -0
- package/dist/core/sudoPasswordManager.js.map +1 -0
- package/dist/core/taskCompletionDetector.d.ts +117 -0
- package/dist/core/taskCompletionDetector.d.ts.map +1 -0
- package/dist/core/taskCompletionDetector.js +532 -0
- package/dist/core/taskCompletionDetector.js.map +1 -0
- package/dist/core/testFailureMonitor.d.ts +67 -0
- package/dist/core/testFailureMonitor.d.ts.map +1 -0
- package/dist/core/testFailureMonitor.js +262 -0
- package/dist/core/testFailureMonitor.js.map +1 -0
- package/dist/core/toolPreconditions.d.ts +34 -0
- package/dist/core/toolPreconditions.d.ts.map +1 -0
- package/dist/core/toolPreconditions.js +242 -0
- package/dist/core/toolPreconditions.js.map +1 -0
- package/dist/core/toolRuntime.d.ts +192 -0
- package/dist/core/toolRuntime.d.ts.map +1 -0
- package/dist/core/toolRuntime.js +460 -0
- package/dist/core/toolRuntime.js.map +1 -0
- package/dist/core/types/utilityTypes.d.ts +183 -0
- package/dist/core/types/utilityTypes.d.ts.map +1 -0
- package/dist/core/types/utilityTypes.js +273 -0
- package/dist/core/types/utilityTypes.js.map +1 -0
- package/dist/core/types.d.ts +334 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +76 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/updateChecker.d.ts +148 -0
- package/dist/core/updateChecker.d.ts.map +1 -0
- package/dist/core/updateChecker.js +599 -0
- package/dist/core/updateChecker.js.map +1 -0
- package/dist/core/usageTracker.d.ts +11 -0
- package/dist/core/usageTracker.d.ts.map +1 -0
- package/dist/core/usageTracker.js +128 -0
- package/dist/core/usageTracker.js.map +1 -0
- package/dist/headless/interactiveShell.d.ts +22 -0
- package/dist/headless/interactiveShell.d.ts.map +1 -0
- package/dist/headless/interactiveShell.js +2100 -0
- package/dist/headless/interactiveShell.js.map +1 -0
- package/dist/leanAgent.d.ts +73 -0
- package/dist/leanAgent.d.ts.map +1 -0
- package/dist/leanAgent.js +177 -0
- package/dist/leanAgent.js.map +1 -0
- package/dist/plugins/index.d.ts +49 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +104 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/providers/anthropic/index.d.ts +9 -0
- package/dist/plugins/providers/anthropic/index.d.ts.map +1 -0
- package/dist/plugins/providers/anthropic/index.js +48 -0
- package/dist/plugins/providers/anthropic/index.js.map +1 -0
- package/dist/plugins/providers/deepseek/index.d.ts +11 -0
- package/dist/plugins/providers/deepseek/index.d.ts.map +1 -0
- package/dist/plugins/providers/deepseek/index.js +54 -0
- package/dist/plugins/providers/deepseek/index.js.map +1 -0
- package/dist/plugins/providers/index.d.ts +2 -0
- package/dist/plugins/providers/index.d.ts.map +1 -0
- package/dist/plugins/providers/index.js +17 -0
- package/dist/plugins/providers/index.js.map +1 -0
- package/dist/plugins/providers/openai/index.d.ts +10 -0
- package/dist/plugins/providers/openai/index.d.ts.map +1 -0
- package/dist/plugins/providers/openai/index.js +47 -0
- package/dist/plugins/providers/openai/index.js.map +1 -0
- package/dist/plugins/providers/xai/index.d.ts +10 -0
- package/dist/plugins/providers/xai/index.d.ts.map +1 -0
- package/dist/plugins/providers/xai/index.js +47 -0
- package/dist/plugins/providers/xai/index.js.map +1 -0
- package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.d.ts +10 -0
- package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.js +110 -0
- package/dist/plugins/tools/agentSpawning/agentSpawningPlugin.js.map +1 -0
- package/dist/plugins/tools/bash/localBashPlugin.d.ts +3 -0
- package/dist/plugins/tools/bash/localBashPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/bash/localBashPlugin.js +14 -0
- package/dist/plugins/tools/bash/localBashPlugin.js.map +1 -0
- package/dist/plugins/tools/edit/editPlugin.d.ts +9 -0
- package/dist/plugins/tools/edit/editPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/edit/editPlugin.js +15 -0
- package/dist/plugins/tools/edit/editPlugin.js.map +1 -0
- package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.d.ts +3 -0
- package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.js +9 -0
- package/dist/plugins/tools/enhancedGit/enhancedGitPlugin.js.map +1 -0
- package/dist/plugins/tools/filesystem/localFilesystemPlugin.d.ts +3 -0
- package/dist/plugins/tools/filesystem/localFilesystemPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/filesystem/localFilesystemPlugin.js +14 -0
- package/dist/plugins/tools/filesystem/localFilesystemPlugin.js.map +1 -0
- package/dist/plugins/tools/gitHistory/gitHistoryPlugin.d.ts +3 -0
- package/dist/plugins/tools/gitHistory/gitHistoryPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/gitHistory/gitHistoryPlugin.js +9 -0
- package/dist/plugins/tools/gitHistory/gitHistoryPlugin.js.map +1 -0
- package/dist/plugins/tools/index.d.ts +3 -0
- package/dist/plugins/tools/index.d.ts.map +1 -0
- package/dist/plugins/tools/index.js +3 -0
- package/dist/plugins/tools/index.js.map +1 -0
- package/dist/plugins/tools/integrity/integrityPlugin.d.ts +3 -0
- package/dist/plugins/tools/integrity/integrityPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/integrity/integrityPlugin.js +31 -0
- package/dist/plugins/tools/integrity/integrityPlugin.js.map +1 -0
- package/dist/plugins/tools/kali/kaliPlugin.d.ts +3 -0
- package/dist/plugins/tools/kali/kaliPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/kali/kaliPlugin.js +10 -0
- package/dist/plugins/tools/kali/kaliPlugin.js.map +1 -0
- package/dist/plugins/tools/mcp/mcpClient.d.ts +49 -0
- package/dist/plugins/tools/mcp/mcpClient.d.ts.map +1 -0
- package/dist/plugins/tools/mcp/mcpClient.js +112 -0
- package/dist/plugins/tools/mcp/mcpClient.js.map +1 -0
- package/dist/plugins/tools/mcp/mcpPlugin.d.ts +3 -0
- package/dist/plugins/tools/mcp/mcpPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/mcp/mcpPlugin.js +10 -0
- package/dist/plugins/tools/mcp/mcpPlugin.js.map +1 -0
- package/dist/plugins/tools/nodeDefaults.d.ts +13 -0
- package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -0
- package/dist/plugins/tools/nodeDefaults.js +37 -0
- package/dist/plugins/tools/nodeDefaults.js.map +1 -0
- package/dist/plugins/tools/orchestration/orchestrationPlugin.d.ts +3 -0
- package/dist/plugins/tools/orchestration/orchestrationPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/orchestration/orchestrationPlugin.js +340 -0
- package/dist/plugins/tools/orchestration/orchestrationPlugin.js.map +1 -0
- package/dist/plugins/tools/registry.d.ts +22 -0
- package/dist/plugins/tools/registry.d.ts.map +1 -0
- package/dist/plugins/tools/registry.js +58 -0
- package/dist/plugins/tools/registry.js.map +1 -0
- package/dist/plugins/tools/search/localSearchPlugin.d.ts +3 -0
- package/dist/plugins/tools/search/localSearchPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/search/localSearchPlugin.js +14 -0
- package/dist/plugins/tools/search/localSearchPlugin.js.map +1 -0
- package/dist/plugins/tools/skills/skillPlugin.d.ts +3 -0
- package/dist/plugins/tools/skills/skillPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/skills/skillPlugin.js +27 -0
- package/dist/plugins/tools/skills/skillPlugin.js.map +1 -0
- package/dist/plugins/tools/todo/todoPlugin.d.ts +3 -0
- package/dist/plugins/tools/todo/todoPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/todo/todoPlugin.js +10 -0
- package/dist/plugins/tools/todo/todoPlugin.js.map +1 -0
- package/dist/providers/baseProvider.d.ts +148 -0
- package/dist/providers/baseProvider.d.ts.map +1 -0
- package/dist/providers/baseProvider.js +284 -0
- package/dist/providers/baseProvider.js.map +1 -0
- package/dist/providers/openaiChatCompletionsProvider.d.ts +64 -0
- package/dist/providers/openaiChatCompletionsProvider.d.ts.map +1 -0
- package/dist/providers/openaiChatCompletionsProvider.js +1018 -0
- package/dist/providers/openaiChatCompletionsProvider.js.map +1 -0
- package/dist/providers/providerFactory.d.ts +22 -0
- package/dist/providers/providerFactory.d.ts.map +1 -0
- package/dist/providers/providerFactory.js +25 -0
- package/dist/providers/providerFactory.js.map +1 -0
- package/dist/providers/resilientProvider.d.ts +103 -0
- package/dist/providers/resilientProvider.d.ts.map +1 -0
- package/dist/providers/resilientProvider.js +468 -0
- package/dist/providers/resilientProvider.js.map +1 -0
- package/dist/runtime/agentController.d.ts +121 -0
- package/dist/runtime/agentController.d.ts.map +1 -0
- package/dist/runtime/agentController.js +739 -0
- package/dist/runtime/agentController.js.map +1 -0
- package/dist/runtime/agentHost.d.ts +61 -0
- package/dist/runtime/agentHost.d.ts.map +1 -0
- package/dist/runtime/agentHost.js +158 -0
- package/dist/runtime/agentHost.js.map +1 -0
- package/dist/runtime/agentSession.d.ts +49 -0
- package/dist/runtime/agentSession.d.ts.map +1 -0
- package/dist/runtime/agentSession.js +218 -0
- package/dist/runtime/agentSession.js.map +1 -0
- package/dist/runtime/agentSpawningWiring.d.ts +23 -0
- package/dist/runtime/agentSpawningWiring.d.ts.map +1 -0
- package/dist/runtime/agentSpawningWiring.js +119 -0
- package/dist/runtime/agentSpawningWiring.js.map +1 -0
- package/dist/runtime/agentWorkerPool.d.ts +167 -0
- package/dist/runtime/agentWorkerPool.d.ts.map +1 -0
- package/dist/runtime/agentWorkerPool.js +435 -0
- package/dist/runtime/agentWorkerPool.js.map +1 -0
- package/dist/runtime/node.d.ts +7 -0
- package/dist/runtime/node.d.ts.map +1 -0
- package/dist/runtime/node.js +56 -0
- package/dist/runtime/node.js.map +1 -0
- package/dist/runtime/universal.d.ts +18 -0
- package/dist/runtime/universal.d.ts.map +1 -0
- package/dist/runtime/universal.js +21 -0
- package/dist/runtime/universal.js.map +1 -0
- package/dist/shell/autoExecutor.d.ts +70 -0
- package/dist/shell/autoExecutor.d.ts.map +1 -0
- package/dist/shell/autoExecutor.js +320 -0
- package/dist/shell/autoExecutor.js.map +1 -0
- package/dist/shell/commandRegistry.d.ts +122 -0
- package/dist/shell/commandRegistry.d.ts.map +1 -0
- package/dist/shell/commandRegistry.js +355 -0
- package/dist/shell/commandRegistry.js.map +1 -0
- package/dist/shell/composableMessage.d.ts +178 -0
- package/dist/shell/composableMessage.d.ts.map +1 -0
- package/dist/shell/composableMessage.js +384 -0
- package/dist/shell/composableMessage.js.map +1 -0
- package/dist/shell/liveStatus.d.ts +27 -0
- package/dist/shell/liveStatus.d.ts.map +1 -0
- package/dist/shell/liveStatus.js +53 -0
- package/dist/shell/liveStatus.js.map +1 -0
- package/dist/shell/systemPrompt.d.ts +12 -0
- package/dist/shell/systemPrompt.d.ts.map +1 -0
- package/dist/shell/systemPrompt.js +16 -0
- package/dist/shell/systemPrompt.js.map +1 -0
- package/dist/shell/vimMode.d.ts +66 -0
- package/dist/shell/vimMode.d.ts.map +1 -0
- package/dist/shell/vimMode.js +435 -0
- package/dist/shell/vimMode.js.map +1 -0
- package/dist/tools/bashTools.d.ts +11 -0
- package/dist/tools/bashTools.d.ts.map +1 -0
- package/dist/tools/bashTools.js +779 -0
- package/dist/tools/bashTools.js.map +1 -0
- package/dist/tools/diffUtils.d.ts +43 -0
- package/dist/tools/diffUtils.d.ts.map +1 -0
- package/dist/tools/diffUtils.js +607 -0
- package/dist/tools/diffUtils.js.map +1 -0
- package/dist/tools/editTools.d.ts +29 -0
- package/dist/tools/editTools.d.ts.map +1 -0
- package/dist/tools/editTools.js +792 -0
- package/dist/tools/editTools.js.map +1 -0
- package/dist/tools/fileChangeTracker.d.ts +47 -0
- package/dist/tools/fileChangeTracker.d.ts.map +1 -0
- package/dist/tools/fileChangeTracker.js +154 -0
- package/dist/tools/fileChangeTracker.js.map +1 -0
- package/dist/tools/fileReadTracker.d.ts +69 -0
- package/dist/tools/fileReadTracker.d.ts.map +1 -0
- package/dist/tools/fileReadTracker.js +213 -0
- package/dist/tools/fileReadTracker.js.map +1 -0
- package/dist/tools/fileTools.d.ts +3 -0
- package/dist/tools/fileTools.d.ts.map +1 -0
- package/dist/tools/fileTools.js +389 -0
- package/dist/tools/fileTools.js.map +1 -0
- package/dist/tools/grepTools.d.ts +3 -0
- package/dist/tools/grepTools.d.ts.map +1 -0
- package/dist/tools/grepTools.js +128 -0
- package/dist/tools/grepTools.js.map +1 -0
- package/dist/tools/heliaControl.d.ts +51 -0
- package/dist/tools/heliaControl.d.ts.map +1 -0
- package/dist/tools/heliaControl.js +93 -0
- package/dist/tools/heliaControl.js.map +1 -0
- package/dist/tools/hitlTools.d.ts +7 -0
- package/dist/tools/hitlTools.d.ts.map +1 -0
- package/dist/tools/hitlTools.js +185 -0
- package/dist/tools/hitlTools.js.map +1 -0
- package/dist/tools/localExplore.d.ts +38 -0
- package/dist/tools/localExplore.d.ts.map +1 -0
- package/dist/tools/localExplore.js +30 -0
- package/dist/tools/localExplore.js.map +1 -0
- package/dist/tools/memoryTools.d.ts +20 -0
- package/dist/tools/memoryTools.d.ts.map +1 -0
- package/dist/tools/memoryTools.js +180 -0
- package/dist/tools/memoryTools.js.map +1 -0
- package/dist/tools/notebookTools.d.ts +20 -0
- package/dist/tools/notebookTools.d.ts.map +1 -0
- package/dist/tools/notebookTools.js +140 -0
- package/dist/tools/notebookTools.js.map +1 -0
- package/dist/tools/searchTools.d.ts +12 -0
- package/dist/tools/searchTools.d.ts.map +1 -0
- package/dist/tools/searchTools.js +413 -0
- package/dist/tools/searchTools.js.map +1 -0
- package/dist/tools/skillTools.d.ts +24 -0
- package/dist/tools/skillTools.d.ts.map +1 -0
- package/dist/tools/skillTools.js +140 -0
- package/dist/tools/skillTools.js.map +1 -0
- package/dist/tools/todoTools.d.ts +24 -0
- package/dist/tools/todoTools.d.ts.map +1 -0
- package/dist/tools/todoTools.js +101 -0
- package/dist/tools/todoTools.js.map +1 -0
- package/dist/tools/webTools.d.ts +26 -0
- package/dist/tools/webTools.d.ts.map +1 -0
- package/dist/tools/webTools.js +332 -0
- package/dist/tools/webTools.js.map +1 -0
- package/dist/ui/RenderGate.d.ts +83 -0
- package/dist/ui/RenderGate.d.ts.map +1 -0
- package/dist/ui/RenderGate.js +138 -0
- package/dist/ui/RenderGate.js.map +1 -0
- package/dist/ui/animatedStatus.d.ts +140 -0
- package/dist/ui/animatedStatus.d.ts.map +1 -0
- package/dist/ui/animatedStatus.js +480 -0
- package/dist/ui/animatedStatus.js.map +1 -0
- package/dist/ui/animation/AnimationScheduler.d.ts +197 -0
- package/dist/ui/animation/AnimationScheduler.d.ts.map +1 -0
- package/dist/ui/animation/AnimationScheduler.js +440 -0
- package/dist/ui/animation/AnimationScheduler.js.map +1 -0
- package/dist/ui/codeHighlighter.d.ts +6 -0
- package/dist/ui/codeHighlighter.d.ts.map +1 -0
- package/dist/ui/codeHighlighter.js +855 -0
- package/dist/ui/codeHighlighter.js.map +1 -0
- package/dist/ui/designSystem.d.ts +26 -0
- package/dist/ui/designSystem.d.ts.map +1 -0
- package/dist/ui/designSystem.js +114 -0
- package/dist/ui/designSystem.js.map +1 -0
- package/dist/ui/errorFormatter.d.ts +64 -0
- package/dist/ui/errorFormatter.d.ts.map +1 -0
- package/dist/ui/errorFormatter.js +316 -0
- package/dist/ui/errorFormatter.js.map +1 -0
- package/dist/ui/globalWriteLock.d.ts +63 -0
- package/dist/ui/globalWriteLock.d.ts.map +1 -0
- package/dist/ui/globalWriteLock.js +173 -0
- package/dist/ui/globalWriteLock.js.map +1 -0
- package/dist/ui/index.d.ts +31 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +49 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/ink/App.d.ts +39 -0
- package/dist/ui/ink/App.d.ts.map +1 -0
- package/dist/ui/ink/App.js +9 -0
- package/dist/ui/ink/App.js.map +1 -0
- package/dist/ui/ink/ChatStatic.d.ts +29 -0
- package/dist/ui/ink/ChatStatic.d.ts.map +1 -0
- package/dist/ui/ink/ChatStatic.js +14 -0
- package/dist/ui/ink/ChatStatic.js.map +1 -0
- package/dist/ui/ink/InkPromptController.d.ts +282 -0
- package/dist/ui/ink/InkPromptController.d.ts.map +1 -0
- package/dist/ui/ink/InkPromptController.js +508 -0
- package/dist/ui/ink/InkPromptController.js.map +1 -0
- package/dist/ui/ink/Prompt.d.ts +31 -0
- package/dist/ui/ink/Prompt.d.ts.map +1 -0
- package/dist/ui/ink/Prompt.js +197 -0
- package/dist/ui/ink/Prompt.js.map +1 -0
- package/dist/ui/ink/StatusLine.d.ts +25 -0
- package/dist/ui/ink/StatusLine.d.ts.map +1 -0
- package/dist/ui/ink/StatusLine.js +11 -0
- package/dist/ui/ink/StatusLine.js.map +1 -0
- package/dist/ui/ink/adapter.d.ts +58 -0
- package/dist/ui/ink/adapter.d.ts.map +1 -0
- package/dist/ui/ink/adapter.js +113 -0
- package/dist/ui/ink/adapter.js.map +1 -0
- package/dist/ui/interrupts/InterruptManager.d.ts +157 -0
- package/dist/ui/interrupts/InterruptManager.d.ts.map +1 -0
- package/dist/ui/interrupts/InterruptManager.js +501 -0
- package/dist/ui/interrupts/InterruptManager.js.map +1 -0
- package/dist/ui/layout.d.ts +27 -0
- package/dist/ui/layout.d.ts.map +1 -0
- package/dist/ui/layout.js +184 -0
- package/dist/ui/layout.js.map +1 -0
- package/dist/ui/outputMode.d.ts +58 -0
- package/dist/ui/outputMode.d.ts.map +1 -0
- package/dist/ui/outputMode.js +179 -0
- package/dist/ui/outputMode.js.map +1 -0
- package/dist/ui/overlay/OverlayManager.d.ts +105 -0
- package/dist/ui/overlay/OverlayManager.d.ts.map +1 -0
- package/dist/ui/overlay/OverlayManager.js +304 -0
- package/dist/ui/overlay/OverlayManager.js.map +1 -0
- package/dist/ui/premiumComponents.d.ts +54 -0
- package/dist/ui/premiumComponents.d.ts.map +1 -0
- package/dist/ui/premiumComponents.js +241 -0
- package/dist/ui/premiumComponents.js.map +1 -0
- package/dist/ui/richText.d.ts +13 -0
- package/dist/ui/richText.d.ts.map +1 -0
- package/dist/ui/richText.js +444 -0
- package/dist/ui/richText.js.map +1 -0
- package/dist/ui/telemetry/ResponseTracker.d.ts +22 -0
- package/dist/ui/telemetry/ResponseTracker.d.ts.map +1 -0
- package/dist/ui/telemetry/ResponseTracker.js +60 -0
- package/dist/ui/telemetry/ResponseTracker.js.map +1 -0
- package/dist/ui/telemetry/UITelemetry.d.ts +181 -0
- package/dist/ui/telemetry/UITelemetry.d.ts.map +1 -0
- package/dist/ui/telemetry/UITelemetry.js +446 -0
- package/dist/ui/telemetry/UITelemetry.js.map +1 -0
- package/dist/ui/textHighlighter.d.ts +83 -0
- package/dist/ui/textHighlighter.d.ts.map +1 -0
- package/dist/ui/textHighlighter.js +267 -0
- package/dist/ui/textHighlighter.js.map +1 -0
- package/dist/ui/theme.d.ts +351 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/dist/ui/theme.js +434 -0
- package/dist/ui/theme.js.map +1 -0
- package/dist/ui/toolDisplay.d.ts +221 -0
- package/dist/ui/toolDisplay.d.ts.map +1 -0
- package/dist/ui/toolDisplay.js +1654 -0
- package/dist/ui/toolDisplay.js.map +1 -0
- package/dist/ui/uiConstants.d.ts +253 -0
- package/dist/ui/uiConstants.d.ts.map +1 -0
- package/dist/ui/uiConstants.js +437 -0
- package/dist/ui/uiConstants.js.map +1 -0
- package/dist/utils/analytics.d.ts +2 -0
- package/dist/utils/analytics.d.ts.map +1 -0
- package/dist/utils/analytics.js +51 -0
- package/dist/utils/analytics.js.map +1 -0
- package/dist/utils/askUserPrompt.d.ts +21 -0
- package/dist/utils/askUserPrompt.d.ts.map +1 -0
- package/dist/utils/askUserPrompt.js +87 -0
- package/dist/utils/askUserPrompt.js.map +1 -0
- package/dist/utils/asyncUtils.d.ts +95 -0
- package/dist/utils/asyncUtils.d.ts.map +1 -0
- package/dist/utils/asyncUtils.js +286 -0
- package/dist/utils/asyncUtils.js.map +1 -0
- package/dist/utils/debugLogger.d.ts +6 -0
- package/dist/utils/debugLogger.d.ts.map +1 -0
- package/dist/utils/debugLogger.js +39 -0
- package/dist/utils/debugLogger.js.map +1 -0
- package/dist/utils/errorUtils.d.ts +12 -0
- package/dist/utils/errorUtils.d.ts.map +1 -0
- package/dist/utils/errorUtils.js +83 -0
- package/dist/utils/errorUtils.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +10 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +78 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/packageInfo.d.ts +14 -0
- package/dist/utils/packageInfo.d.ts.map +1 -0
- package/dist/utils/packageInfo.js +45 -0
- package/dist/utils/packageInfo.js.map +1 -0
- package/dist/utils/planFormatter.d.ts +34 -0
- package/dist/utils/planFormatter.d.ts.map +1 -0
- package/dist/utils/planFormatter.js +141 -0
- package/dist/utils/planFormatter.js.map +1 -0
- package/dist/utils/securityUtils.d.ts +145 -0
- package/dist/utils/securityUtils.d.ts.map +1 -0
- package/dist/utils/securityUtils.js +507 -0
- package/dist/utils/securityUtils.js.map +1 -0
- package/dist/utils/statusReporter.d.ts +6 -0
- package/dist/utils/statusReporter.d.ts.map +1 -0
- package/dist/utils/statusReporter.js +26 -0
- package/dist/utils/statusReporter.js.map +1 -0
- package/dist/workspace.d.ts +8 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +135 -0
- package/dist/workspace.js.map +1 -0
- package/dist/workspace.validator.d.ts +49 -0
- package/dist/workspace.validator.d.ts.map +1 -0
- package/dist/workspace.validator.js +215 -0
- package/dist/workspace.validator.js.map +1 -0
- package/package.json +135 -0
- package/scripts/postinstall.cjs +58 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { type JSONSchemaObject, type ProviderId, type ProviderToolDefinition, type ToolCallRequest } from './types.js';
|
|
2
|
+
import { ContextManager } from './contextManager.js';
|
|
3
|
+
import { type PreflightWarning } from './toolPreconditions.js';
|
|
4
|
+
/**
|
|
5
|
+
* Execution context for tool operations with strict TypeScript typing
|
|
6
|
+
*/
|
|
7
|
+
export interface ToolExecutionContext {
|
|
8
|
+
readonly profileName: string;
|
|
9
|
+
readonly provider: ProviderId;
|
|
10
|
+
readonly model: string;
|
|
11
|
+
readonly workspaceContext?: string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Type-safe tool observer with generic parameter inference for AI flow monitoring
|
|
15
|
+
*/
|
|
16
|
+
export interface ToolRuntimeObserver<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
17
|
+
/** Called when tool execution begins */
|
|
18
|
+
onToolStart?(call: ToolCallRequest & {
|
|
19
|
+
args: T;
|
|
20
|
+
}): void;
|
|
21
|
+
/** Called when tool execution completes successfully */
|
|
22
|
+
onToolResult?(call: ToolCallRequest & {
|
|
23
|
+
args: T;
|
|
24
|
+
}, output: string): void;
|
|
25
|
+
/** Called when tool execution fails */
|
|
26
|
+
onToolError?(call: ToolCallRequest & {
|
|
27
|
+
args: T;
|
|
28
|
+
}, error: string): void;
|
|
29
|
+
/** Called when cached result is used instead of execution */
|
|
30
|
+
onCacheHit?(call: ToolCallRequest & {
|
|
31
|
+
args: T;
|
|
32
|
+
}): void;
|
|
33
|
+
/** Called for progress updates during long-running operations */
|
|
34
|
+
onToolProgress?(call: ToolCallRequest & {
|
|
35
|
+
args: T;
|
|
36
|
+
}, progress: ToolProgressUpdate): void;
|
|
37
|
+
/** Called for pre-flight warnings before tool execution */
|
|
38
|
+
onToolWarning?(call: ToolCallRequest & {
|
|
39
|
+
args: T;
|
|
40
|
+
}, warning: PreflightWarning | string): void;
|
|
41
|
+
}
|
|
42
|
+
interface ToolRuntimeOptions {
|
|
43
|
+
readonly observer?: ToolRuntimeObserver;
|
|
44
|
+
readonly contextManager?: ContextManager;
|
|
45
|
+
readonly enableCache?: boolean;
|
|
46
|
+
readonly cacheTTLMs?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Working directory used to load `.erosolar/settings.json` hooks.
|
|
49
|
+
* If unset, hooks are loaded from `~/.erosolar/settings.json`
|
|
50
|
+
* only (user-global) and the project-local file is skipped.
|
|
51
|
+
*/
|
|
52
|
+
readonly workingDir?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Generic tool handler with parameter type inference for AI flow execution
|
|
56
|
+
*/
|
|
57
|
+
type ToolHandler<T extends Record<string, unknown> = Record<string, unknown>> = (args: T) => Promise<string> | string;
|
|
58
|
+
/**
|
|
59
|
+
* Enhanced tool definition with parameter type safety for AI software engineering
|
|
60
|
+
*/
|
|
61
|
+
export interface ToolDefinition<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
62
|
+
/** Unique identifier for the tool */
|
|
63
|
+
readonly name: string;
|
|
64
|
+
/** Human-readable description for AI understanding */
|
|
65
|
+
readonly description: string;
|
|
66
|
+
/** JSON Schema defining the tool's parameter structure */
|
|
67
|
+
readonly parameters?: JSONSchemaObject;
|
|
68
|
+
/** Function that implements the tool's behavior */
|
|
69
|
+
readonly handler: ToolHandler<T>;
|
|
70
|
+
/** Whether results can be cached for performance optimization */
|
|
71
|
+
readonly cacheable?: boolean;
|
|
72
|
+
/** Optional per-tool cache TTL in milliseconds (falls back to runtime default) */
|
|
73
|
+
readonly cacheTtlMs?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Collection of related tools grouped by functionality
|
|
77
|
+
*/
|
|
78
|
+
export interface ToolSuite {
|
|
79
|
+
/** Unique identifier for the tool suite */
|
|
80
|
+
readonly id: string;
|
|
81
|
+
/** Human-readable description of the suite's purpose */
|
|
82
|
+
readonly description?: string;
|
|
83
|
+
/** Array of tool definitions in this suite */
|
|
84
|
+
readonly tools: readonly ToolDefinition[];
|
|
85
|
+
}
|
|
86
|
+
export interface ToolHistoryEntry {
|
|
87
|
+
toolName: string;
|
|
88
|
+
args: Record<string, unknown>;
|
|
89
|
+
timestamp: number;
|
|
90
|
+
success: boolean;
|
|
91
|
+
hasOutput: boolean;
|
|
92
|
+
error?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface DiffSnapshotRecord {
|
|
95
|
+
command: string;
|
|
96
|
+
output: string;
|
|
97
|
+
timestamp: number;
|
|
98
|
+
}
|
|
99
|
+
export interface ToolProgressUpdate {
|
|
100
|
+
current: number;
|
|
101
|
+
total?: number;
|
|
102
|
+
message?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Report incremental progress for the currently executing tool.
|
|
106
|
+
* Tools can call this to surface live status updates (e.g., indexing files).
|
|
107
|
+
*/
|
|
108
|
+
export declare function reportToolProgress(progress: ToolProgressUpdate): void;
|
|
109
|
+
/**
|
|
110
|
+
* Type-safe utility functions for tool runtime operations
|
|
111
|
+
*/
|
|
112
|
+
export declare namespace ToolRuntimeUtils {
|
|
113
|
+
/**
|
|
114
|
+
* Creates a type-safe tool definition with inferred parameter types
|
|
115
|
+
*/
|
|
116
|
+
function createToolDefinition<T extends Record<string, unknown>>(definition: ToolDefinition<T>): ToolDefinition<T>;
|
|
117
|
+
/**
|
|
118
|
+
* Creates a type-safe tool suite with inferred tool types
|
|
119
|
+
*/
|
|
120
|
+
function createToolSuite(suite: ToolSuite): ToolSuite;
|
|
121
|
+
/**
|
|
122
|
+
* Type guard to check if a tool definition matches expected parameter schema
|
|
123
|
+
*/
|
|
124
|
+
function isToolDefinition(__tool: ToolDefinition, expectedSchema?: JSONSchemaObject): boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Interface describing the public API of ToolRuntime.
|
|
128
|
+
* Used by wrapper implementations like RestrictedToolRuntime.
|
|
129
|
+
*/
|
|
130
|
+
export interface IToolRuntime {
|
|
131
|
+
listProviderTools(): ProviderToolDefinition[];
|
|
132
|
+
execute(call: ToolCallRequest, context?: {
|
|
133
|
+
profileName?: string;
|
|
134
|
+
provider?: string;
|
|
135
|
+
model?: string;
|
|
136
|
+
}): Promise<string>;
|
|
137
|
+
registerSuite(suite: ToolSuite): void;
|
|
138
|
+
unregisterSuite(id: string): void;
|
|
139
|
+
clearCache(): void;
|
|
140
|
+
getCacheStats(): {
|
|
141
|
+
size: number;
|
|
142
|
+
entries: number;
|
|
143
|
+
};
|
|
144
|
+
clearToolHistory(): void;
|
|
145
|
+
getToolHistory(): readonly ToolHistoryEntry[];
|
|
146
|
+
clearDiffSnapshots(): void;
|
|
147
|
+
getDiffSnapshots(): readonly DiffSnapshotRecord[];
|
|
148
|
+
}
|
|
149
|
+
export declare class ToolRuntime implements IToolRuntime {
|
|
150
|
+
private readonly registry;
|
|
151
|
+
private readonly registrationOrder;
|
|
152
|
+
private readonly observer;
|
|
153
|
+
private readonly contextManager;
|
|
154
|
+
private readonly cache;
|
|
155
|
+
private readonly enableCache;
|
|
156
|
+
private readonly cacheTTLMs;
|
|
157
|
+
private readonly toolHistory;
|
|
158
|
+
private readonly maxHistorySize;
|
|
159
|
+
private readonly diffSnapshots;
|
|
160
|
+
private readonly maxDiffSnapshots;
|
|
161
|
+
private readonly maxDiffSnapshotLength;
|
|
162
|
+
private readonly hooks;
|
|
163
|
+
constructor(baseTools?: ToolDefinition[], options?: ToolRuntimeOptions);
|
|
164
|
+
registerSuite(suite: ToolSuite): void;
|
|
165
|
+
unregisterSuite(id: string): void;
|
|
166
|
+
listProviderTools(): ProviderToolDefinition[];
|
|
167
|
+
execute(call: ToolCallRequest, _context?: {
|
|
168
|
+
profileName?: string;
|
|
169
|
+
provider?: string;
|
|
170
|
+
model?: string;
|
|
171
|
+
}): Promise<string>;
|
|
172
|
+
private getCacheKey;
|
|
173
|
+
clearCache(): void;
|
|
174
|
+
getCacheStats(): {
|
|
175
|
+
size: number;
|
|
176
|
+
entries: number;
|
|
177
|
+
};
|
|
178
|
+
clearToolHistory(): void;
|
|
179
|
+
getToolHistory(): readonly ToolHistoryEntry[];
|
|
180
|
+
private recordToolHistory;
|
|
181
|
+
clearDiffSnapshots(): void;
|
|
182
|
+
getDiffSnapshots(): readonly DiffSnapshotRecord[];
|
|
183
|
+
private addTool;
|
|
184
|
+
private removeFromOrder;
|
|
185
|
+
private recordDiffSnapshot;
|
|
186
|
+
private findGitDiffCommand;
|
|
187
|
+
private extractCommands;
|
|
188
|
+
private isGitDiffCommand;
|
|
189
|
+
}
|
|
190
|
+
export declare function createDefaultToolRuntime(context: ToolExecutionContext, toolSuites?: ToolSuite[], options?: ToolRuntimeOptions): ToolRuntime;
|
|
191
|
+
export {};
|
|
192
|
+
//# sourceMappingURL=toolRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolRuntime.d.ts","sourceRoot":"","sources":["../../src/core/toolRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAwE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAKrI;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9F,wCAAwC;IACxC,WAAW,CAAC,CAAC,IAAI,EAAE,eAAe,GAAG;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;IAExD,wDAAwD;IACxD,YAAY,CAAC,CAAC,IAAI,EAAE,eAAe,GAAG;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzE,uCAA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B,OAAO,CAAC,eAAe;IAoBvB,OAAO,CAAC,gBAAgB;CAGzB;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,oBAAoB,EAC7B,UAAU,GAAE,SAAS,EAAO,EAC5B,OAAO,GAAE,kBAAuB,GAC/B,WAAW,CAUb"}
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
2
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
|
+
import { ToolArgumentValidationError, coerceToolArguments, validateToolArguments, } from './schemaValidator.js';
|
|
4
|
+
import { validateToolPreconditions, validateAIFlowPatterns, EDIT_WITHOUT_READ } from './toolPreconditions.js';
|
|
5
|
+
import { safeTruncate } from './resultVerification.js';
|
|
6
|
+
import { logDebug } from '../utils/debugLogger.js';
|
|
7
|
+
import { loadHooksConfig, runPreToolUseHooks, runPostToolUseHooks } from './hooks.js';
|
|
8
|
+
const toolExecutionContext = new AsyncLocalStorage();
|
|
9
|
+
/**
|
|
10
|
+
* Report incremental progress for the currently executing tool.
|
|
11
|
+
* Tools can call this to surface live status updates (e.g., indexing files).
|
|
12
|
+
*/
|
|
13
|
+
export function reportToolProgress(progress) {
|
|
14
|
+
const context = toolExecutionContext.getStore();
|
|
15
|
+
if (!context?.observer?.onToolProgress) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const current = Number.isFinite(progress.current) ? Math.max(0, progress.current) : 0;
|
|
19
|
+
const total = progress.total !== undefined ? Math.max(current, progress.total) : current;
|
|
20
|
+
try {
|
|
21
|
+
context.observer.onToolProgress(context.call, {
|
|
22
|
+
current,
|
|
23
|
+
total,
|
|
24
|
+
message: progress.message,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// Swallow observer errors so they don't break tool execution
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Idempotent tools that can be safely cached
|
|
32
|
+
const CACHEABLE_TOOLS = new Set([
|
|
33
|
+
'Read',
|
|
34
|
+
'read_file',
|
|
35
|
+
'Glob',
|
|
36
|
+
'glob_search',
|
|
37
|
+
'Grep',
|
|
38
|
+
'grep_search',
|
|
39
|
+
'find_definition',
|
|
40
|
+
'analyze_code_quality',
|
|
41
|
+
'extract_exports',
|
|
42
|
+
]);
|
|
43
|
+
function buildOptimizationHint(warning) {
|
|
44
|
+
const code = warning.code;
|
|
45
|
+
const suggestion = warning.suggestion || warning.message;
|
|
46
|
+
switch (code) {
|
|
47
|
+
case 'SEARCH_BROAD_PATTERN':
|
|
48
|
+
case 'SEARCH_CONTEXT_OVERFLOW_RISK':
|
|
49
|
+
return (`\n\n<optimization-hint>\n` +
|
|
50
|
+
`⚡ SEARCH: ${suggestion}\n` +
|
|
51
|
+
`</optimization-hint>`);
|
|
52
|
+
case EDIT_WITHOUT_READ:
|
|
53
|
+
case 'EDIT_PLACEHOLDER':
|
|
54
|
+
return (`\n\n<optimization-hint>\n` +
|
|
55
|
+
`⚡ EDIT: Read the file first to copy exact whitespace. ${suggestion}\n` +
|
|
56
|
+
`</optimization-hint>`);
|
|
57
|
+
case 'NPM_INCOMPLETE_WORKFLOW':
|
|
58
|
+
return (`\n\n<optimization-hint>\n` +
|
|
59
|
+
`⚡ PUBLISH: ${suggestion}\n` +
|
|
60
|
+
`</optimization-hint>`);
|
|
61
|
+
default:
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Type-safe utility functions for tool runtime operations
|
|
67
|
+
*/
|
|
68
|
+
export var ToolRuntimeUtils;
|
|
69
|
+
(function (ToolRuntimeUtils) {
|
|
70
|
+
/**
|
|
71
|
+
* Creates a type-safe tool definition with inferred parameter types
|
|
72
|
+
*/
|
|
73
|
+
function createToolDefinition(definition) {
|
|
74
|
+
return definition;
|
|
75
|
+
}
|
|
76
|
+
ToolRuntimeUtils.createToolDefinition = createToolDefinition;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a type-safe tool suite with inferred tool types
|
|
79
|
+
*/
|
|
80
|
+
function createToolSuite(suite) {
|
|
81
|
+
return suite;
|
|
82
|
+
}
|
|
83
|
+
ToolRuntimeUtils.createToolSuite = createToolSuite;
|
|
84
|
+
/**
|
|
85
|
+
* Type guard to check if a tool definition matches expected parameter schema
|
|
86
|
+
*/
|
|
87
|
+
function isToolDefinition(__tool, expectedSchema) {
|
|
88
|
+
if (!expectedSchema)
|
|
89
|
+
return true;
|
|
90
|
+
// In a real implementation, this would validate against the schema
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
ToolRuntimeUtils.isToolDefinition = isToolDefinition;
|
|
94
|
+
})(ToolRuntimeUtils || (ToolRuntimeUtils = {}));
|
|
95
|
+
export class ToolRuntime {
|
|
96
|
+
registry = new Map();
|
|
97
|
+
registrationOrder = [];
|
|
98
|
+
observer;
|
|
99
|
+
contextManager;
|
|
100
|
+
cache = new Map();
|
|
101
|
+
enableCache;
|
|
102
|
+
cacheTTLMs;
|
|
103
|
+
toolHistory = [];
|
|
104
|
+
maxHistorySize = 50; // Keep last 50 tool calls for AI flow pattern detection
|
|
105
|
+
diffSnapshots = [];
|
|
106
|
+
maxDiffSnapshots = 5; // Keep only the most recent git diff outputs
|
|
107
|
+
maxDiffSnapshotLength = 4000;
|
|
108
|
+
hooks;
|
|
109
|
+
constructor(baseTools = [], options = {}) {
|
|
110
|
+
this.observer = options.observer ?? null;
|
|
111
|
+
this.contextManager = options.contextManager ?? null;
|
|
112
|
+
this.enableCache = options.enableCache ?? true;
|
|
113
|
+
this.cacheTTLMs = options.cacheTTLMs ?? 5 * 60 * 1000; // 5 minutes default
|
|
114
|
+
// Load hook config eagerly. Hot-reloading on every tool call would
|
|
115
|
+
// give the user faster feedback but at the cost of file I/O on
|
|
116
|
+
// every step — we accept "edit settings → restart CLI" as the
|
|
117
|
+
// tradeoff (matches Claude Code).
|
|
118
|
+
try {
|
|
119
|
+
this.hooks = loadHooksConfig(options.workingDir ?? process.cwd());
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
logDebug('[hooks] config load failed: ' + err.message);
|
|
123
|
+
this.hooks = {};
|
|
124
|
+
}
|
|
125
|
+
if (baseTools.length) {
|
|
126
|
+
this.registerSuite({
|
|
127
|
+
id: 'runtime.core',
|
|
128
|
+
description: 'Core runtime metadata tools',
|
|
129
|
+
tools: baseTools,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
registerSuite(suite) {
|
|
134
|
+
if (!suite?.id?.trim()) {
|
|
135
|
+
throw new Error('Tool suite id cannot be blank.');
|
|
136
|
+
}
|
|
137
|
+
this.unregisterSuite(suite.id);
|
|
138
|
+
for (const definition of suite.tools ?? []) {
|
|
139
|
+
this.addTool(definition, suite.id);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
unregisterSuite(id) {
|
|
143
|
+
if (!id?.trim()) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
for (const [name, record] of this.registry.entries()) {
|
|
147
|
+
if (record.suiteId === id) {
|
|
148
|
+
this.registry.delete(name);
|
|
149
|
+
this.removeFromOrder(name);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
listProviderTools() {
|
|
154
|
+
return this.registrationOrder
|
|
155
|
+
.map((name) => this.registry.get(name))
|
|
156
|
+
.filter((record) => Boolean(record))
|
|
157
|
+
.map(({ definition }) => ({
|
|
158
|
+
name: definition.name,
|
|
159
|
+
description: definition.description,
|
|
160
|
+
...(definition.parameters && { parameters: definition.parameters }),
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
async execute(call, _context) {
|
|
164
|
+
const record = this.registry.get(call.name);
|
|
165
|
+
const rawArgs = normalizeToolArguments(call.arguments);
|
|
166
|
+
const args = coerceToolArguments(record?.definition.parameters, rawArgs);
|
|
167
|
+
const augmentedCall = { ...call, args };
|
|
168
|
+
if (!record) {
|
|
169
|
+
const message = `Tool "${call.name}" is not available.`;
|
|
170
|
+
this.observer?.onToolError?.(augmentedCall, message);
|
|
171
|
+
// Performance monitoring removed - no legacy components
|
|
172
|
+
return message;
|
|
173
|
+
}
|
|
174
|
+
// Check if tool is cacheable
|
|
175
|
+
const isCacheable = record.definition.cacheable ?? CACHEABLE_TOOLS.has(call.name);
|
|
176
|
+
const cacheTtl = typeof record.definition.cacheTtlMs === 'number' && Number.isFinite(record.definition.cacheTtlMs)
|
|
177
|
+
? Math.max(0, Math.floor(record.definition.cacheTtlMs))
|
|
178
|
+
: this.cacheTTLMs;
|
|
179
|
+
const canUseCache = this.enableCache && isCacheable && cacheTtl > 0;
|
|
180
|
+
// Try to get from cache
|
|
181
|
+
if (canUseCache) {
|
|
182
|
+
const cacheKey = this.getCacheKey({ ...call, arguments: args });
|
|
183
|
+
const cached = this.cache.get(cacheKey);
|
|
184
|
+
if (cached && Date.now() - cached.timestamp < cacheTtl) {
|
|
185
|
+
this.observer?.onCacheHit?.(augmentedCall);
|
|
186
|
+
this.observer?.onToolResult?.(augmentedCall, cached.result);
|
|
187
|
+
// Record cache hit as successful execution with 0ms time
|
|
188
|
+
// Performance monitoring removed - no legacy components
|
|
189
|
+
this.recordToolHistory({
|
|
190
|
+
toolName: call.name,
|
|
191
|
+
args,
|
|
192
|
+
timestamp: Date.now(),
|
|
193
|
+
success: true,
|
|
194
|
+
hasOutput: hasNonEmptyOutput(cached.result),
|
|
195
|
+
});
|
|
196
|
+
return cached.result;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
this.observer?.onToolStart?.(augmentedCall);
|
|
200
|
+
// Performance monitoring removed - no legacy components
|
|
201
|
+
try {
|
|
202
|
+
validateToolArguments(record.definition.name, record.definition.parameters, args);
|
|
203
|
+
// Pre-flight AI flow validation - catch common tool usage failures
|
|
204
|
+
const preflightWarnings = validateToolPreconditions(call.name, args);
|
|
205
|
+
for (const warning of preflightWarnings) {
|
|
206
|
+
this.observer?.onToolWarning?.(augmentedCall, warning);
|
|
207
|
+
}
|
|
208
|
+
// Advanced AI flow pattern validation using tool history
|
|
209
|
+
const aiFlowWarnings = validateAIFlowPatterns(call.name, args, this.toolHistory);
|
|
210
|
+
for (const warning of aiFlowWarnings) {
|
|
211
|
+
this.observer?.onToolWarning?.(augmentedCall, warning);
|
|
212
|
+
}
|
|
213
|
+
// Collect optimization hints to inject into result
|
|
214
|
+
const optimizationHints = [];
|
|
215
|
+
const seenOptimizationCodes = new Set();
|
|
216
|
+
for (const warning of [...preflightWarnings, ...aiFlowWarnings]) {
|
|
217
|
+
if (warning.code && seenOptimizationCodes.has(warning.code)) {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
const hint = buildOptimizationHint(warning);
|
|
221
|
+
if (hint) {
|
|
222
|
+
if (warning.code) {
|
|
223
|
+
seenOptimizationCodes.add(warning.code);
|
|
224
|
+
}
|
|
225
|
+
optimizationHints.push(hint);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// PreToolUse hooks: run user-configured shell commands that
|
|
229
|
+
// can block this tool call. Best-effort — if the hook errors,
|
|
230
|
+
// times out, or returns malformed output, we pass through.
|
|
231
|
+
try {
|
|
232
|
+
const blocked = await runPreToolUseHooks(this.hooks, call.name, args);
|
|
233
|
+
if (blocked) {
|
|
234
|
+
const reason = blocked.reason || 'Blocked by hook';
|
|
235
|
+
const message = `Error: ${call.name} blocked by user hook: ${reason}`;
|
|
236
|
+
this.observer?.onToolError?.(augmentedCall, message);
|
|
237
|
+
this.recordToolHistory({
|
|
238
|
+
toolName: call.name,
|
|
239
|
+
args,
|
|
240
|
+
timestamp: Date.now(),
|
|
241
|
+
success: false,
|
|
242
|
+
hasOutput: false,
|
|
243
|
+
});
|
|
244
|
+
return message;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (err) {
|
|
248
|
+
// A buggy hook should never crash the agent. Log + continue.
|
|
249
|
+
logDebug('[hooks] PreToolUse error: ' + err.message);
|
|
250
|
+
}
|
|
251
|
+
const result = await toolExecutionContext.run({ call: augmentedCall, observer: this.observer ?? undefined }, async () => record.definition.handler(args));
|
|
252
|
+
let output = typeof result === 'string' ? result : JSON.stringify(result, null, 2);
|
|
253
|
+
// PostToolUse hooks: append text from each matching hook so
|
|
254
|
+
// the model sees the augmentation. Useful for "lint after every
|
|
255
|
+
// edit" / "echo every Bash command to a log" patterns.
|
|
256
|
+
try {
|
|
257
|
+
const post = await runPostToolUseHooks(this.hooks, call.name, args, output);
|
|
258
|
+
if (post?.appendToResult) {
|
|
259
|
+
output = `${output}\n\n[hook] ${post.appendToResult}`;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
logDebug('[hooks] PostToolUse error: ' + err.message);
|
|
264
|
+
}
|
|
265
|
+
let snapshotCandidate = output;
|
|
266
|
+
// Truncate output if context manager is available
|
|
267
|
+
if (this.contextManager) {
|
|
268
|
+
const truncated = this.contextManager.truncateToolOutput(output, call.name);
|
|
269
|
+
if (truncated.wasTruncated) {
|
|
270
|
+
output = truncated.content;
|
|
271
|
+
// Log truncation for debugging
|
|
272
|
+
if (process.env['DEBUG_CONTEXT']) {
|
|
273
|
+
logDebug(`[Context Manager] Truncated ${call.name} output: ${truncated.originalLength} -> ${truncated.truncatedLength} chars`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
snapshotCandidate = output;
|
|
277
|
+
}
|
|
278
|
+
this.recordDiffSnapshot(args, snapshotCandidate);
|
|
279
|
+
// Cache the result if cacheable
|
|
280
|
+
if (canUseCache) {
|
|
281
|
+
const cacheKey = this.getCacheKey({ ...call, arguments: args });
|
|
282
|
+
this.cache.set(cacheKey, {
|
|
283
|
+
result: output,
|
|
284
|
+
timestamp: Date.now(),
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
// Append optimization hints to guide future LLM behavior
|
|
288
|
+
if (optimizationHints.length > 0) {
|
|
289
|
+
output = output + optimizationHints.join('');
|
|
290
|
+
}
|
|
291
|
+
this.observer?.onToolResult?.(augmentedCall, output);
|
|
292
|
+
this.recordToolHistory({
|
|
293
|
+
toolName: call.name,
|
|
294
|
+
args,
|
|
295
|
+
timestamp: Date.now(),
|
|
296
|
+
success: true,
|
|
297
|
+
hasOutput: hasNonEmptyOutput(output),
|
|
298
|
+
});
|
|
299
|
+
// Record successful execution
|
|
300
|
+
// Performance monitoring removed - no legacy components
|
|
301
|
+
return output;
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
let formatted;
|
|
305
|
+
if (error instanceof ToolArgumentValidationError) {
|
|
306
|
+
formatted = error.message;
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
310
|
+
formatted = `Failed to run "${call.name}": ${message}`;
|
|
311
|
+
}
|
|
312
|
+
this.observer?.onToolError?.(augmentedCall, formatted);
|
|
313
|
+
this.recordToolHistory({
|
|
314
|
+
toolName: call.name,
|
|
315
|
+
args,
|
|
316
|
+
timestamp: Date.now(),
|
|
317
|
+
success: false,
|
|
318
|
+
hasOutput: hasNonEmptyOutput(formatted),
|
|
319
|
+
error: formatted,
|
|
320
|
+
});
|
|
321
|
+
// Record failed execution - no legacy performance monitoring
|
|
322
|
+
return formatted;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
getCacheKey(call) {
|
|
326
|
+
return `${call.name}:${JSON.stringify(call.arguments)}`;
|
|
327
|
+
}
|
|
328
|
+
clearCache() {
|
|
329
|
+
this.cache.clear();
|
|
330
|
+
}
|
|
331
|
+
getCacheStats() {
|
|
332
|
+
let totalSize = 0;
|
|
333
|
+
for (const entry of this.cache.values()) {
|
|
334
|
+
totalSize += entry.result.length;
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
size: totalSize,
|
|
338
|
+
entries: this.cache.size,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
clearToolHistory() {
|
|
342
|
+
this.toolHistory.length = 0;
|
|
343
|
+
}
|
|
344
|
+
getToolHistory() {
|
|
345
|
+
return this.toolHistory;
|
|
346
|
+
}
|
|
347
|
+
recordToolHistory(entry) {
|
|
348
|
+
this.toolHistory.push(entry);
|
|
349
|
+
if (this.toolHistory.length > this.maxHistorySize) {
|
|
350
|
+
this.toolHistory.shift();
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
clearDiffSnapshots() {
|
|
354
|
+
this.diffSnapshots.length = 0;
|
|
355
|
+
}
|
|
356
|
+
getDiffSnapshots() {
|
|
357
|
+
return this.diffSnapshots;
|
|
358
|
+
}
|
|
359
|
+
addTool(definition, suiteId) {
|
|
360
|
+
if (!definition?.name?.trim()) {
|
|
361
|
+
throw new Error(`Tool names cannot be blank (suite "${suiteId}").`);
|
|
362
|
+
}
|
|
363
|
+
if (this.registry.has(definition.name)) {
|
|
364
|
+
const owner = this.registry.get(definition.name)?.suiteId ?? 'unknown';
|
|
365
|
+
throw new Error(`Tool "${definition.name}" already registered by suite "${owner}".`);
|
|
366
|
+
}
|
|
367
|
+
this.registry.set(definition.name, {
|
|
368
|
+
suiteId,
|
|
369
|
+
definition,
|
|
370
|
+
});
|
|
371
|
+
this.registrationOrder.push(definition.name);
|
|
372
|
+
}
|
|
373
|
+
removeFromOrder(name) {
|
|
374
|
+
const index = this.registrationOrder.indexOf(name);
|
|
375
|
+
if (index >= 0) {
|
|
376
|
+
this.registrationOrder.splice(index, 1);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
recordDiffSnapshot(args, output) {
|
|
380
|
+
const command = this.findGitDiffCommand(args);
|
|
381
|
+
if (!command || !output) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
this.diffSnapshots.push({
|
|
385
|
+
command,
|
|
386
|
+
output: safeTruncate(output, this.maxDiffSnapshotLength, 'git-diff'),
|
|
387
|
+
timestamp: Date.now(),
|
|
388
|
+
});
|
|
389
|
+
if (this.diffSnapshots.length > this.maxDiffSnapshots) {
|
|
390
|
+
this.diffSnapshots.shift();
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
findGitDiffCommand(args) {
|
|
394
|
+
for (const command of this.extractCommands(args)) {
|
|
395
|
+
if (this.isGitDiffCommand(command)) {
|
|
396
|
+
return command;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
extractCommands(args) {
|
|
402
|
+
const commands = [];
|
|
403
|
+
const command = args['command'];
|
|
404
|
+
if (typeof command === 'string' && command.trim()) {
|
|
405
|
+
commands.push(command.trim());
|
|
406
|
+
}
|
|
407
|
+
const commandList = args['commands'];
|
|
408
|
+
if (Array.isArray(commandList)) {
|
|
409
|
+
for (const value of commandList) {
|
|
410
|
+
if (typeof value === 'string' && value.trim()) {
|
|
411
|
+
commands.push(value.trim());
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return commands;
|
|
416
|
+
}
|
|
417
|
+
isGitDiffCommand(command) {
|
|
418
|
+
return /\bgit\s+(?:--no-pager\s+)?(?:diff|show)\b/i.test(command);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
export function createDefaultToolRuntime(context, toolSuites = [], options = {}) {
|
|
422
|
+
// Start with no default introspection tools - they waste tokens
|
|
423
|
+
// Model knows its capabilities from tool definitions
|
|
424
|
+
const runtime = new ToolRuntime([], options);
|
|
425
|
+
for (const suite of toolSuites) {
|
|
426
|
+
runtime.registerSuite(suite);
|
|
427
|
+
}
|
|
428
|
+
return runtime;
|
|
429
|
+
}
|
|
430
|
+
// Removed unused introspection tools (context_snapshot, capabilities_overview, profile_details)
|
|
431
|
+
// Model already knows capabilities from tool definitions; these just wasted tokens
|
|
432
|
+
function hasNonEmptyOutput(output) {
|
|
433
|
+
return typeof output === 'string' && output.trim().length > 0;
|
|
434
|
+
}
|
|
435
|
+
function normalizeToolArguments(value) {
|
|
436
|
+
if (value instanceof Map) {
|
|
437
|
+
return Object.fromEntries(value.entries());
|
|
438
|
+
}
|
|
439
|
+
if (isRecord(value)) {
|
|
440
|
+
return value;
|
|
441
|
+
}
|
|
442
|
+
if (typeof value === 'string') {
|
|
443
|
+
const trimmed = value.trim();
|
|
444
|
+
if (!trimmed) {
|
|
445
|
+
return {};
|
|
446
|
+
}
|
|
447
|
+
try {
|
|
448
|
+
const parsed = JSON.parse(trimmed);
|
|
449
|
+
return isRecord(parsed) ? parsed : {};
|
|
450
|
+
}
|
|
451
|
+
catch {
|
|
452
|
+
return {};
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return {};
|
|
456
|
+
}
|
|
457
|
+
function isRecord(value) {
|
|
458
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
459
|
+
}
|
|
460
|
+
//# sourceMappingURL=toolRuntime.js.map
|