@trenchwork/erosolar 1.1.40
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 +225 -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 +203 -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 +11 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +16 -0
- package/dist/capabilities/index.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 +790 -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 +184 -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/adversarial.d.ts +38 -0
- package/dist/core/adversarial.d.ts.map +1 -0
- package/dist/core/adversarial.js +106 -0
- package/dist/core/adversarial.js.map +1 -0
- package/dist/core/agent.d.ts +329 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +1668 -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/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 +272 -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 +236 -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 +67 -0
- package/dist/core/preferences.d.ts.map +1 -0
- package/dist/core/preferences.js +315 -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 +266 -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 +477 -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/headless/interactiveShell.d.ts +39 -0
- package/dist/headless/interactiveShell.d.ts.map +1 -0
- package/dist/headless/interactiveShell.js +2052 -0
- package/dist/headless/interactiveShell.js.map +1 -0
- package/dist/headless/printMode.d.ts +17 -0
- package/dist/headless/printMode.d.ts.map +1 -0
- package/dist/headless/printMode.js +40 -0
- package/dist/headless/printMode.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 +59 -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/mcp/mcpPlugin.d.ts +3 -0
- package/dist/plugins/tools/mcp/mcpPlugin.d.ts.map +1 -0
- package/dist/plugins/tools/mcp/mcpPlugin.js +27 -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 +33 -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 +70 -0
- package/dist/providers/openaiChatCompletionsProvider.d.ts.map +1 -0
- package/dist/providers/openaiChatCompletionsProvider.js +1043 -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 +50 -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/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 +383 -0
- package/dist/tools/webTools.js.map +1 -0
- package/dist/ui/ink/App.d.ts +42 -0
- package/dist/ui/ink/App.d.ts.map +1 -0
- package/dist/ui/ink/App.js +10 -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 +289 -0
- package/dist/ui/ink/InkPromptController.d.ts.map +1 -0
- package/dist/ui/ink/InkPromptController.js +552 -0
- package/dist/ui/ink/InkPromptController.js.map +1 -0
- package/dist/ui/ink/Menu.d.ts +21 -0
- package/dist/ui/ink/Menu.d.ts.map +1 -0
- package/dist/ui/ink/Menu.js +61 -0
- package/dist/ui/ink/Menu.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 +21 -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/theme.d.ts +351 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/dist/ui/theme.js +437 -0
- package/dist/ui/theme.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/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 +132 -0
- package/dist/utils/securityUtils.d.ts.map +1 -0
- package/dist/utils/securityUtils.js +324 -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 +123 -0
- package/scripts/postinstall.cjs +58 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heuristic: did the model return a safety/policy refusal?
|
|
3
|
+
*
|
|
4
|
+
* Used by the interactive shell to short-circuit the auto-continue
|
|
5
|
+
* loop — a "no, I won't do that" response is the terminal turn rather
|
|
6
|
+
* than a stop the auto-continue logic should bulldoze through with
|
|
7
|
+
* another "continue" prompt. Extracted to a free function so it's
|
|
8
|
+
* unit-testable without standing up the whole shell.
|
|
9
|
+
*
|
|
10
|
+
* Looks at the first ~1KB of the buffered response — refusals lead
|
|
11
|
+
* with the decline, so a substring scan is enough and keeps the cost
|
|
12
|
+
* trivial.
|
|
13
|
+
*/
|
|
14
|
+
const DECLINE_PHRASES = [
|
|
15
|
+
"i can't help",
|
|
16
|
+
'i cannot help',
|
|
17
|
+
"i won't help",
|
|
18
|
+
'i will not help',
|
|
19
|
+
"i can't assist",
|
|
20
|
+
'i cannot assist',
|
|
21
|
+
"i won't assist",
|
|
22
|
+
"i'm not going to help",
|
|
23
|
+
'i am not going to help',
|
|
24
|
+
"i'm not able to help",
|
|
25
|
+
'i am not able to help',
|
|
26
|
+
"i'm unable to help",
|
|
27
|
+
"i'm not going to continue",
|
|
28
|
+
"i've declined",
|
|
29
|
+
'i have declined',
|
|
30
|
+
'i decline',
|
|
31
|
+
'i must decline',
|
|
32
|
+
'i need to decline',
|
|
33
|
+
"i'm declining",
|
|
34
|
+
"i'm not comfortable",
|
|
35
|
+
'against my guidelines',
|
|
36
|
+
'against my values',
|
|
37
|
+
'violates my',
|
|
38
|
+
];
|
|
39
|
+
export function isSafetyRefusal(text) {
|
|
40
|
+
if (!text)
|
|
41
|
+
return false;
|
|
42
|
+
const head = text.slice(0, 1024).toLowerCase();
|
|
43
|
+
if (!head.trim())
|
|
44
|
+
return false;
|
|
45
|
+
for (const phrase of DECLINE_PHRASES) {
|
|
46
|
+
if (head.includes(phrase))
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=refusalDetection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusalDetection.js","sourceRoot":"","sources":["../../src/core/refusalDetection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,eAAe,GAAsB;IACzC,cAAc;IACd,eAAe;IACf,cAAc;IACd,iBAAiB;IACjB,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,uBAAuB;IACvB,wBAAwB;IACxB,sBAAsB;IACtB,uBAAuB;IACvB,oBAAoB;IACpB,2BAA2B;IAC3B,eAAe;IACf,iBAAiB;IACjB,WAAW;IACX,gBAAgB;IAChB,mBAAmB;IACnB,eAAe;IACf,qBAAqB;IACrB,uBAAuB;IACvB,mBAAmB;IACnB,aAAa;CACd,CAAC;AAEF,MAAM,UAAU,eAAe,CAAC,IAA+B;IAC7D,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACxB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/C,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QAAE,OAAO,KAAK,CAAC;IAC/B,KAAK,MAAM,MAAM,IAAI,eAAe,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;IACzC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result Verification - Re-exported from orchestrationCapability
|
|
3
|
+
* Provides verifiedSuccess, verifiedFailure, analyzeOutput, OutputPatterns, etc.
|
|
4
|
+
*/
|
|
5
|
+
export type VerificationStatus = 'VERIFIED_SUCCESS' | 'VERIFIED_FAILURE' | 'UNVERIFIED' | 'PARTIAL_SUCCESS' | 'REQUIRES_USER_ACTION';
|
|
6
|
+
export interface VerifiedResult {
|
|
7
|
+
status: VerificationStatus;
|
|
8
|
+
summary: string;
|
|
9
|
+
details: string;
|
|
10
|
+
verificationChecks?: VerificationCheck[];
|
|
11
|
+
suggestedActions?: string[];
|
|
12
|
+
verifiedAt: string;
|
|
13
|
+
durationMs?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface VerificationCheck {
|
|
16
|
+
check: string;
|
|
17
|
+
passed: boolean;
|
|
18
|
+
details?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const OutputPatterns: {
|
|
21
|
+
git: {
|
|
22
|
+
success: RegExp[];
|
|
23
|
+
failure: RegExp[];
|
|
24
|
+
};
|
|
25
|
+
npm: {
|
|
26
|
+
success: RegExp[];
|
|
27
|
+
failure: RegExp[];
|
|
28
|
+
};
|
|
29
|
+
command: {
|
|
30
|
+
success: RegExp[];
|
|
31
|
+
failure: RegExp[];
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare function verifiedSuccess(summary: string, details: string, checks?: VerificationCheck[], durationMs?: number): string;
|
|
35
|
+
export declare function verifiedFailure(summary: string, details: string, suggestedActions?: string[], checks?: VerificationCheck[], durationMs?: number): string;
|
|
36
|
+
export declare function analyzeOutput(output: string, patterns: {
|
|
37
|
+
success: RegExp[];
|
|
38
|
+
failure: RegExp[];
|
|
39
|
+
}, exitCode?: number): {
|
|
40
|
+
isSuccess: boolean;
|
|
41
|
+
isFailure: boolean;
|
|
42
|
+
matchedPattern?: string;
|
|
43
|
+
confidence: 'high' | 'medium' | 'low';
|
|
44
|
+
};
|
|
45
|
+
export declare function createCommandCheck(checkName: string, exitCode: number, output: string, expectedPatterns?: RegExp[]): VerificationCheck;
|
|
46
|
+
export declare function safeTruncate(content: string, maxLength: number, _label?: string): string;
|
|
47
|
+
//# sourceMappingURL=resultVerification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resultVerification.d.ts","sourceRoot":"","sources":["../../src/core/resultVerification.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,MAAM,MAAM,kBAAkB,GAC1B,kBAAkB,GAClB,kBAAkB,GAClB,YAAY,GACZ,iBAAiB,GACjB,sBAAsB,CAAC;AAE3B,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACzC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;CAa1B,CAAC;AA8BF,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,iBAAiB,EAAE,EAC5B,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CASR;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAC3B,MAAM,CAAC,EAAE,iBAAiB,EAAE,EAC5B,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAUR;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,EAClD,QAAQ,CAAC,EAAE,MAAM,GAChB;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;CAAE,CAa5G;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B,iBAAiB,CAWnB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAAkB,GAAG,MAAM,CAInG"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result Verification - Re-exported from orchestrationCapability
|
|
3
|
+
* Provides verifiedSuccess, verifiedFailure, analyzeOutput, OutputPatterns, etc.
|
|
4
|
+
*/
|
|
5
|
+
// ANSI color codes for enhanced terminal output
|
|
6
|
+
const ANSI_RESET = '\x1b[0m';
|
|
7
|
+
const ANSI_RED = '\x1b[31m';
|
|
8
|
+
const ANSI_GREEN = '\x1b[32m';
|
|
9
|
+
const ANSI_YELLOW = '\x1b[33m';
|
|
10
|
+
const ANSI_BLUE = '\x1b[34m';
|
|
11
|
+
const ANSI_MAGENTA = '\x1b[35m';
|
|
12
|
+
const ANSI_CYAN = '\x1b[36m';
|
|
13
|
+
const ANSI_DIM = '\x1b[2m';
|
|
14
|
+
const ANSI_BOLD = '\x1b[1m';
|
|
15
|
+
const ANSI_RED_BOLD = '\x1b[1;31m';
|
|
16
|
+
const ANSI_GREEN_BOLD = '\x1b[1;32m';
|
|
17
|
+
const ANSI_YELLOW_BOLD = '\x1b[1;33m';
|
|
18
|
+
export const OutputPatterns = {
|
|
19
|
+
git: {
|
|
20
|
+
success: [/\[.+\s+\w+\]/, /pushed/i, /merged/i, /On branch/i, /nothing to commit/i, /Already up to date/i],
|
|
21
|
+
failure: [/fatal:/i, /error:/i, /conflict/i, /rejected/i, /CONFLICT/, /Aborting/i],
|
|
22
|
+
},
|
|
23
|
+
npm: {
|
|
24
|
+
success: [/npm notice/i, /\+ .+@\d+\.\d+\.\d+/, /published/i],
|
|
25
|
+
failure: [/npm ERR!/i, /ERESOLVE/i, /E404/i, /EINTEGRITY/i],
|
|
26
|
+
},
|
|
27
|
+
command: {
|
|
28
|
+
success: [/^(success|completed|done|finished)/im, /successfully/i],
|
|
29
|
+
failure: [/^error/im, /^fatal/im, /failed/i, /command not found/i, /permission denied/i, /ENOENT/i, /EACCES/i],
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
function formatVerifiedResult(result) {
|
|
33
|
+
if (result.status === 'VERIFIED_SUCCESS')
|
|
34
|
+
return result.details || result.summary;
|
|
35
|
+
const lines = [];
|
|
36
|
+
switch (result.status) {
|
|
37
|
+
case 'VERIFIED_FAILURE':
|
|
38
|
+
lines.push(`${ANSI_RED_BOLD}═══ FAILED ═══${ANSI_RESET}`);
|
|
39
|
+
break;
|
|
40
|
+
case 'UNVERIFIED':
|
|
41
|
+
lines.push(`${ANSI_YELLOW_BOLD}═══ UNVERIFIED ═══${ANSI_RESET}`);
|
|
42
|
+
break;
|
|
43
|
+
case 'PARTIAL_SUCCESS':
|
|
44
|
+
lines.push(`${ANSI_YELLOW_BOLD}═══ PARTIAL SUCCESS ═══${ANSI_RESET}`);
|
|
45
|
+
break;
|
|
46
|
+
case 'REQUIRES_USER_ACTION':
|
|
47
|
+
lines.push(`${ANSI_CYAN}═══ ACTION REQUIRED ═══${ANSI_RESET}`);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
lines.push('', result.summary, '');
|
|
51
|
+
if (result.verificationChecks) {
|
|
52
|
+
const failedChecks = result.verificationChecks.filter(c => !c.passed);
|
|
53
|
+
if (failedChecks.length > 0) {
|
|
54
|
+
lines.push('Failed checks:');
|
|
55
|
+
for (const check of failedChecks) {
|
|
56
|
+
lines.push(` ${ANSI_RED}✗${ANSI_RESET} ${check.check}${check.details ? `: ${check.details}` : ''}`);
|
|
57
|
+
}
|
|
58
|
+
lines.push('');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (result.details)
|
|
62
|
+
lines.push(result.details, '');
|
|
63
|
+
if (result.suggestedActions?.length) {
|
|
64
|
+
lines.push('Suggested actions:');
|
|
65
|
+
for (const action of result.suggestedActions)
|
|
66
|
+
lines.push(` ${ANSI_GREEN}→${ANSI_RESET} ${action}`);
|
|
67
|
+
}
|
|
68
|
+
return lines.join('\n');
|
|
69
|
+
}
|
|
70
|
+
export function verifiedSuccess(summary, details, checks, durationMs) {
|
|
71
|
+
return formatVerifiedResult({
|
|
72
|
+
status: 'VERIFIED_SUCCESS',
|
|
73
|
+
summary,
|
|
74
|
+
details,
|
|
75
|
+
verificationChecks: checks,
|
|
76
|
+
verifiedAt: new Date().toISOString(),
|
|
77
|
+
durationMs,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export function verifiedFailure(summary, details, suggestedActions, checks, durationMs) {
|
|
81
|
+
return formatVerifiedResult({
|
|
82
|
+
status: 'VERIFIED_FAILURE',
|
|
83
|
+
summary,
|
|
84
|
+
details,
|
|
85
|
+
verificationChecks: checks,
|
|
86
|
+
suggestedActions,
|
|
87
|
+
verifiedAt: new Date().toISOString(),
|
|
88
|
+
durationMs,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export function analyzeOutput(output, patterns, exitCode) {
|
|
92
|
+
const normalizedOutput = output.normalize('NFC');
|
|
93
|
+
for (const pattern of patterns.failure) {
|
|
94
|
+
if (pattern.test(normalizedOutput))
|
|
95
|
+
return { isSuccess: false, isFailure: true, matchedPattern: pattern.source, confidence: 'high' };
|
|
96
|
+
}
|
|
97
|
+
for (const pattern of patterns.success) {
|
|
98
|
+
if (pattern.test(normalizedOutput))
|
|
99
|
+
return { isSuccess: true, isFailure: false, matchedPattern: pattern.source, confidence: 'high' };
|
|
100
|
+
}
|
|
101
|
+
if (exitCode !== undefined) {
|
|
102
|
+
if (exitCode !== 0)
|
|
103
|
+
return { isSuccess: false, isFailure: true, confidence: 'high' };
|
|
104
|
+
return { isSuccess: false, isFailure: false, confidence: 'low' };
|
|
105
|
+
}
|
|
106
|
+
return { isSuccess: false, isFailure: false, confidence: 'low' };
|
|
107
|
+
}
|
|
108
|
+
export function createCommandCheck(checkName, exitCode, output, expectedPatterns) {
|
|
109
|
+
let passed = exitCode === 0;
|
|
110
|
+
let details = exitCode === 0 ? 'Exit code 0' : `Exit code ${exitCode}`;
|
|
111
|
+
if (expectedPatterns && passed) {
|
|
112
|
+
const foundPattern = expectedPatterns.some((p) => p.test(output));
|
|
113
|
+
if (!foundPattern) {
|
|
114
|
+
passed = false;
|
|
115
|
+
details = 'Exit code 0 but expected output pattern not found';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return { check: checkName, passed, details };
|
|
119
|
+
}
|
|
120
|
+
export function safeTruncate(content, maxLength, _label = 'Content') {
|
|
121
|
+
if (content.length <= maxLength)
|
|
122
|
+
return content;
|
|
123
|
+
const hiddenChars = content.length - maxLength;
|
|
124
|
+
return `${content.slice(0, maxLength)}\n\n[... ${hiddenChars} characters truncated]`;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=resultVerification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resultVerification.js","sourceRoot":"","sources":["../../src/core/resultVerification.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,gDAAgD;AAChD,MAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,MAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,MAAM,UAAU,GAAG,UAAU,CAAC;AAC9B,MAAM,WAA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AAED,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,SAAiB,EAAE,SAAiB,SAAS;IACzF,IAAI,OAAO,CAAC,MAAM,IAAI,SAAS;QAAE,OAAO,OAAO,CAAC;IAChD,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAC/C,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,YAAY,WAAW,wBAAwB,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { JSONSchemaObject } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Enhanced validation error with structured error information
|
|
4
|
+
*/
|
|
5
|
+
export declare class ToolArgumentValidationError extends Error {
|
|
6
|
+
readonly issues: readonly string[];
|
|
7
|
+
readonly toolName: string;
|
|
8
|
+
constructor(toolName: string, issues: string[]);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Runtime type guards for tool argument validation
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace TypeGuards {
|
|
14
|
+
/**
|
|
15
|
+
* Type guard for string values
|
|
16
|
+
*/
|
|
17
|
+
function isString(value: unknown): value is string;
|
|
18
|
+
/**
|
|
19
|
+
* Type guard for number values
|
|
20
|
+
*/
|
|
21
|
+
function isNumber(value: unknown): value is number;
|
|
22
|
+
/**
|
|
23
|
+
* Type guard for boolean values
|
|
24
|
+
*/
|
|
25
|
+
function isBoolean(value: unknown): value is boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard for array values
|
|
28
|
+
*/
|
|
29
|
+
function isArray(value: unknown): value is unknown[];
|
|
30
|
+
/**
|
|
31
|
+
* Type guard for object values
|
|
32
|
+
*/
|
|
33
|
+
function isObject(value: unknown): value is Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* Type guard for non-null values
|
|
36
|
+
*/
|
|
37
|
+
function isNotNull(value: unknown): value is NonNullable<unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Type guard for enum values
|
|
40
|
+
*/
|
|
41
|
+
function isEnum<T extends string>(value: unknown, enumValues: readonly T[]): value is T;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Coerce loosely-typed tool arguments into their declared schema types.
|
|
45
|
+
* This makes tools resilient to providers that emit boolean/number values as strings.
|
|
46
|
+
*/
|
|
47
|
+
export declare function coerceToolArguments(schema: JSONSchemaObject | undefined, args: Record<string, unknown>): Record<string, unknown>;
|
|
48
|
+
export declare function validateToolArguments(toolName: string, schema: JSONSchemaObject | undefined, args: Record<string, unknown>): void;
|
|
49
|
+
//# sourceMappingURL=schemaValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaValidator.d.ts","sourceRoot":"","sources":["../../src/core/schemaValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,gBAAgB,EAAsB,MAAM,YAAY,CAAC;AAExF;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;CAM/C;AAED;;GAEG;AACH,yBAAiB,UAAU,CAAC;IAC1B;;OAEG;IACH,SAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;IAED;;OAEG;IACH,SAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;IAED;;OAEG;IACH,SAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;IAED;;OAEG;IACH,SAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,EAAE,CAE1D;IAED;;OAEG;IACH,SAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;IAED;;OAEG;IACH,SAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC,CAEvE;IAED;;OAEG;IACH,SAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,CAE7F;CACF;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiCzB;AAoCD,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,GAAG,SAAS,EACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,IAAI,CA6BN"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced validation error with structured error information
|
|
3
|
+
*/
|
|
4
|
+
export class ToolArgumentValidationError extends Error {
|
|
5
|
+
issues;
|
|
6
|
+
toolName;
|
|
7
|
+
constructor(toolName, issues) {
|
|
8
|
+
super(formatMessage(toolName, issues));
|
|
9
|
+
this.name = 'ToolArgumentValidationError';
|
|
10
|
+
this.issues = issues;
|
|
11
|
+
this.toolName = toolName;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Runtime type guards for tool argument validation
|
|
16
|
+
*/
|
|
17
|
+
export var TypeGuards;
|
|
18
|
+
(function (TypeGuards) {
|
|
19
|
+
/**
|
|
20
|
+
* Type guard for string values
|
|
21
|
+
*/
|
|
22
|
+
function isString(value) {
|
|
23
|
+
return typeof value === 'string';
|
|
24
|
+
}
|
|
25
|
+
TypeGuards.isString = isString;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard for number values
|
|
28
|
+
*/
|
|
29
|
+
function isNumber(value) {
|
|
30
|
+
return typeof value === 'number' && !Number.isNaN(value);
|
|
31
|
+
}
|
|
32
|
+
TypeGuards.isNumber = isNumber;
|
|
33
|
+
/**
|
|
34
|
+
* Type guard for boolean values
|
|
35
|
+
*/
|
|
36
|
+
function isBoolean(value) {
|
|
37
|
+
return typeof value === 'boolean';
|
|
38
|
+
}
|
|
39
|
+
TypeGuards.isBoolean = isBoolean;
|
|
40
|
+
/**
|
|
41
|
+
* Type guard for array values
|
|
42
|
+
*/
|
|
43
|
+
function isArray(value) {
|
|
44
|
+
return Array.isArray(value);
|
|
45
|
+
}
|
|
46
|
+
TypeGuards.isArray = isArray;
|
|
47
|
+
/**
|
|
48
|
+
* Type guard for object values
|
|
49
|
+
*/
|
|
50
|
+
function isObject(value) {
|
|
51
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
52
|
+
}
|
|
53
|
+
TypeGuards.isObject = isObject;
|
|
54
|
+
/**
|
|
55
|
+
* Type guard for non-null values
|
|
56
|
+
*/
|
|
57
|
+
function isNotNull(value) {
|
|
58
|
+
return value !== undefined && value !== null;
|
|
59
|
+
}
|
|
60
|
+
TypeGuards.isNotNull = isNotNull;
|
|
61
|
+
/**
|
|
62
|
+
* Type guard for enum values
|
|
63
|
+
*/
|
|
64
|
+
function isEnum(value, enumValues) {
|
|
65
|
+
return TypeGuards.isString(value) && enumValues.includes(value);
|
|
66
|
+
}
|
|
67
|
+
TypeGuards.isEnum = isEnum;
|
|
68
|
+
})(TypeGuards || (TypeGuards = {}));
|
|
69
|
+
/**
|
|
70
|
+
* Coerce loosely-typed tool arguments into their declared schema types.
|
|
71
|
+
* This makes tools resilient to providers that emit boolean/number values as strings.
|
|
72
|
+
*/
|
|
73
|
+
export function coerceToolArguments(schema, args) {
|
|
74
|
+
if (!schema || schema.type !== 'object' || !schema.properties) {
|
|
75
|
+
return args;
|
|
76
|
+
}
|
|
77
|
+
const coerced = { ...args };
|
|
78
|
+
for (const [key, definition] of Object.entries(schema.properties)) {
|
|
79
|
+
if (!Object.hasOwn(args, key)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const value = args[key];
|
|
83
|
+
if (value === undefined || value === null) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
switch (definition.type) {
|
|
87
|
+
case 'boolean': {
|
|
88
|
+
const normalized = coerceBoolean(value);
|
|
89
|
+
coerced[key] = normalized;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case 'number': {
|
|
93
|
+
const normalized = coerceNumber(value);
|
|
94
|
+
coerced[key] = normalized;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
default:
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return coerced;
|
|
102
|
+
}
|
|
103
|
+
function coerceBoolean(value) {
|
|
104
|
+
if (typeof value === 'boolean') {
|
|
105
|
+
return value;
|
|
106
|
+
}
|
|
107
|
+
if (typeof value === 'number') {
|
|
108
|
+
if (value === 1)
|
|
109
|
+
return true;
|
|
110
|
+
if (value === 0)
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
if (typeof value === 'string') {
|
|
114
|
+
const trimmed = value.trim().toLowerCase();
|
|
115
|
+
if (trimmed === 'true' || trimmed === '1')
|
|
116
|
+
return true;
|
|
117
|
+
if (trimmed === 'false' || trimmed === '0')
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
function coerceNumber(value) {
|
|
123
|
+
if (typeof value === 'number') {
|
|
124
|
+
// Reject NaN, Infinity, and -Infinity
|
|
125
|
+
if (!Number.isFinite(value)) {
|
|
126
|
+
return value; // Return as-is to fail validation
|
|
127
|
+
}
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
if (typeof value === 'string' && value.trim().length > 0) {
|
|
131
|
+
const parsed = Number(value);
|
|
132
|
+
// Only accept finite numbers
|
|
133
|
+
if (Number.isFinite(parsed)) {
|
|
134
|
+
return parsed;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
export function validateToolArguments(toolName, schema, args) {
|
|
140
|
+
if (!schema || schema.type !== 'object') {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const errors = [];
|
|
144
|
+
const properties = schema.properties ?? {};
|
|
145
|
+
const required = Array.isArray(schema.required) ? schema.required : [];
|
|
146
|
+
for (const property of required) {
|
|
147
|
+
if (!hasArgument(args, property)) {
|
|
148
|
+
errors.push(`Missing required property "${property}".`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
for (const [key, value] of Object.entries(args)) {
|
|
152
|
+
const definition = properties[key];
|
|
153
|
+
if (!definition) {
|
|
154
|
+
// Silently ignore unknown properties - models sometimes hallucinate extra params
|
|
155
|
+
// This is more lenient than strict JSON schema validation but prevents errors
|
|
156
|
+
// when models pass extra parameters that don't affect tool behavior
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
validateSchemaProperty(definition, value, key, errors);
|
|
160
|
+
}
|
|
161
|
+
if (errors.length) {
|
|
162
|
+
throw new ToolArgumentValidationError(toolName, errors);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function validateSchemaProperty(definition, value, path, errors) {
|
|
166
|
+
switch (definition.type) {
|
|
167
|
+
case 'string': {
|
|
168
|
+
if (typeof value !== 'string') {
|
|
169
|
+
errors.push(`Argument "${path}" must be a string.`);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (definition.enum && !definition.enum.includes(value)) {
|
|
173
|
+
errors.push(`Argument "${path}" must be one of: ${definition.enum.map((entry) => `"${entry}"`).join(', ')}.`);
|
|
174
|
+
}
|
|
175
|
+
if (typeof definition.minLength === 'number' && value.length < definition.minLength) {
|
|
176
|
+
errors.push(`Argument "${path}" must be at least ${definition.minLength} character${definition.minLength === 1 ? '' : 's'} long.`);
|
|
177
|
+
}
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
case 'number': {
|
|
181
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
182
|
+
errors.push(`Argument "${path}" must be a finite number.`);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
// Validate minimum constraint
|
|
186
|
+
if (typeof definition.minimum === 'number' && value < definition.minimum) {
|
|
187
|
+
errors.push(`Argument "${path}" must be at least ${definition.minimum}.`);
|
|
188
|
+
}
|
|
189
|
+
// Validate maximum constraint
|
|
190
|
+
if (typeof definition.maximum === 'number' && value > definition.maximum) {
|
|
191
|
+
errors.push(`Argument "${path}" must be at most ${definition.maximum}.`);
|
|
192
|
+
}
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
case 'boolean': {
|
|
196
|
+
if (typeof value !== 'boolean') {
|
|
197
|
+
errors.push(`Argument "${path}" must be a boolean.`);
|
|
198
|
+
}
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
case 'array': {
|
|
202
|
+
if (!Array.isArray(value)) {
|
|
203
|
+
errors.push(`Argument "${path}" must be an array.`);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
validateArrayItems(definition, value, path, errors);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
default:
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function validateArrayItems(definition, value, path, errors) {
|
|
214
|
+
const itemSchema = definition.items;
|
|
215
|
+
if (!itemSchema) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
219
|
+
const entry = value[index];
|
|
220
|
+
validateSchemaProperty(itemSchema, entry, `${path}[${index}]`, errors);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function hasArgument(args, key) {
|
|
224
|
+
if (!Object.hasOwn(args, key)) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
const value = args[key];
|
|
228
|
+
return value !== undefined && value !== null;
|
|
229
|
+
}
|
|
230
|
+
function formatMessage(toolName, issues) {
|
|
231
|
+
const detail = issues.join(' ');
|
|
232
|
+
return `Invalid arguments for "${toolName}": ${detail}`;
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=schemaValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaValidator.js","sourceRoot":"","sources":["../../src/core/schemaValidator.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IAC3C,MAAM,CAAoB;IAC1B,QAAQ,CAAS;IAE1B,YAAY,QAAgB,EAAE,MAAgB;QAC5C,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,KAAW,UAAU,CAiD1B;AAjDD,WAAiB,UAAU;IACzB;;OAEG;IACH,SAAgB,QAAQ,CAAC,KAAc;QACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;IACnC,CAAC;IAFe,mBAAQ,WAEvB,CAAA;IAED;;OAEG;IACH,SAAgB,QAAQ,CAAC,KAAc;QACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC;IAFe,mBAAQ,WAEvB,CAAA;IAED;;OAEG;IACH,SAAgB,SAAS,CAAC,KAAc;QACtC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;IACpC,CAAC;IAFe,oBAAS,YAExB,CAAA;IAED;;OAEG;IACH,SAAgB,OAAO,C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B,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC;IACpC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IAED,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,sBAAsB,CAAC,UAAU,EAAE,KAAK,EAAE,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,MAAM,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,IAA6B,EAAE,GAAW;IAC7D,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AAC/C,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB,EAAE,MAAgB;IACvD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,0BAA0B,QAAQ,MAAM,MAAM,EAAE,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ProviderId } from './types.js';
|
|
2
|
+
export type SecretName = 'DEEPSEEK_API_KEY' | 'TAVILY_API_KEY';
|
|
3
|
+
export interface SecretDefinition {
|
|
4
|
+
id: SecretName;
|
|
5
|
+
label: string;
|
|
6
|
+
description: string;
|
|
7
|
+
envVar: SecretName;
|
|
8
|
+
providers: ProviderId[];
|
|
9
|
+
}
|
|
10
|
+
export declare class MissingSecretError extends Error {
|
|
11
|
+
readonly secret: SecretDefinition;
|
|
12
|
+
constructor(secret: SecretDefinition);
|
|
13
|
+
}
|
|
14
|
+
export declare function listSecretDefinitions(): SecretDefinition[];
|
|
15
|
+
export declare function getSecretDefinition(id: SecretName): SecretDefinition | null;
|
|
16
|
+
export declare function getSecretValue(id: SecretName): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Load all stored secrets into process.env at startup.
|
|
19
|
+
* This ensures secrets are available before any provider checks.
|
|
20
|
+
*
|
|
21
|
+
* IMPORTANT: Stored secrets always take precedence over environment variables
|
|
22
|
+
* for provider API keys. This ensures keys set via /secrets are used even if
|
|
23
|
+
* the user has old/stale keys exported in their shell environment.
|
|
24
|
+
*/
|
|
25
|
+
export declare function loadAllSecrets(): void;
|
|
26
|
+
export declare function setSecretValue(id: SecretName, rawValue: string): void;
|
|
27
|
+
export declare function maskSecret(value: string): string;
|
|
28
|
+
export declare function ensureSecretForProvider(provider: ProviderId): string;
|
|
29
|
+
export declare function getSecretDefinitionForProvider(provider: ProviderId): SecretDefinition | null;
|
|
30
|
+
/**
|
|
31
|
+
* Sanitize error messages to remove potential API keys and secrets.
|
|
32
|
+
* This prevents accidental token leakage in logs, error reports, and console output.
|
|
33
|
+
*
|
|
34
|
+
* @param message - The error message or string to sanitize
|
|
35
|
+
* @returns The sanitized string with secrets replaced by [REDACTED]
|
|
36
|
+
*/
|
|
37
|
+
export declare function sanitizeErrorMessage(message: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Sanitize an Error object's message and stack trace.
|
|
40
|
+
* Returns a new error message string with secrets removed.
|
|
41
|
+
*/
|
|
42
|
+
export declare function sanitizeError(error: Error): string;
|
|
43
|
+
/**
|
|
44
|
+
* Create a safe error message from an unknown error value.
|
|
45
|
+
* Ensures no secrets are leaked regardless of error type.
|
|
46
|
+
*/
|
|
47
|
+
export declare function safeErrorMessage(error: unknown): string;
|
|
48
|
+
//# sourceMappingURL=secretStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secretStore.d.ts","sourceRoot":"","sources":["../../src/core/secretStore.ts"],"names":[],"mappings":"A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