erosolar-cli 1.7.55 → 1.7.57
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/dist/shell/unifiedInputProcessor.d.ts +15 -12
- package/dist/shell/unifiedInputProcessor.d.ts.map +1 -1
- package/dist/shell/unifiedInputProcessor.js +45 -72
- package/dist/shell/unifiedInputProcessor.js.map +1 -1
- package/package.json +4 -4
- package/dist/active-stack-security.d.ts +0 -110
- package/dist/active-stack-security.js +0 -313
- package/dist/active-stack-security.js.map +0 -1
- package/dist/advanced-targeting.d.ts +0 -113
- package/dist/advanced-targeting.js +0 -252
- package/dist/advanced-targeting.js.map +0 -1
- package/dist/bin/adapters/node/index.js +0 -33
- package/dist/bin/adapters/types.js +0 -1
- package/dist/bin/alpha-zero/agentWrapper.js +0 -165
- package/dist/bin/alpha-zero/codeEvaluator.js +0 -272
- package/dist/bin/alpha-zero/competitiveRunner.js +0 -219
- package/dist/bin/alpha-zero/index.js +0 -98
- package/dist/bin/alpha-zero/introspection.js +0 -298
- package/dist/bin/alpha-zero/metricsTracker.js +0 -207
- package/dist/bin/alpha-zero/security/core.js +0 -269
- package/dist/bin/alpha-zero/security/google.js +0 -308
- package/dist/bin/alpha-zero/security/googleLoader.js +0 -40
- package/dist/bin/alpha-zero/security/index.js +0 -31
- package/dist/bin/alpha-zero/security/simulation.js +0 -274
- package/dist/bin/alpha-zero/selfModification.js +0 -231
- package/dist/bin/alpha-zero/types.js +0 -30
- package/dist/bin/bin/erosolar-optimized.js +0 -205
- package/dist/bin/capabilities/agentSpawningCapability.js +0 -116
- package/dist/bin/capabilities/bashCapability.js +0 -22
- package/dist/bin/capabilities/cloudCapability.js +0 -36
- package/dist/bin/capabilities/codeAnalysisCapability.js +0 -22
- package/dist/bin/capabilities/codeQualityCapability.js +0 -23
- package/dist/bin/capabilities/dependencySecurityCapability.js +0 -22
- package/dist/bin/capabilities/devCapability.js +0 -22
- package/dist/bin/capabilities/editCapability.js +0 -28
- package/dist/bin/capabilities/emailCapability.js +0 -20
- package/dist/bin/capabilities/enhancedGitCapability.js +0 -221
- package/dist/bin/capabilities/filesystemCapability.js +0 -22
- package/dist/bin/capabilities/globCapability.js +0 -28
- package/dist/bin/capabilities/interactionCapability.js +0 -20
- package/dist/bin/capabilities/learnCapability.js +0 -22
- package/dist/bin/capabilities/mcpCapability.js +0 -20
- package/dist/bin/capabilities/notebookCapability.js +0 -28
- package/dist/bin/capabilities/planningCapability.js +0 -27
- package/dist/bin/capabilities/refactoringCapability.js +0 -23
- package/dist/bin/capabilities/repoChecksCapability.js +0 -22
- package/dist/bin/capabilities/searchCapability.js +0 -22
- package/dist/bin/capabilities/skillCapability.js +0 -76
- package/dist/bin/capabilities/taskManagementCapability.js +0 -20
- package/dist/bin/capabilities/testingCapability.js +0 -23
- package/dist/bin/capabilities/toolManifest.js +0 -159
- package/dist/bin/capabilities/toolRegistry.js +0 -114
- package/dist/bin/capabilities/webCapability.js +0 -20
- package/dist/bin/config.js +0 -139
- package/dist/bin/contracts/v1/agent.js +0 -7
- package/dist/bin/contracts/v1/agentProfileManifest.js +0 -8
- package/dist/bin/contracts/v1/agentRules.js +0 -9
- package/dist/bin/contracts/v1/toolAccess.js +0 -8
- package/dist/bin/erosolar-optimized.d.ts +0 -12
- package/dist/bin/erosolar-optimized.d.ts.map +0 -1
- package/dist/bin/erosolar-optimized.js +0 -239
- package/dist/bin/erosolar-optimized.js.map +0 -1
- package/dist/bin/headless/headlessApp.js +0 -172
- package/dist/bin/mcp/config.js +0 -202
- package/dist/bin/mcp/stdioClient.js +0 -172
- package/dist/bin/mcp/toolBridge.js +0 -104
- package/dist/bin/mcp/types.js +0 -1
- package/dist/bin/plugins/index.js +0 -113
- package/dist/bin/plugins/providers/anthropic/index.js +0 -25
- package/dist/bin/plugins/providers/deepseek/index.js +0 -24
- package/dist/bin/plugins/providers/google/index.js +0 -26
- package/dist/bin/plugins/providers/index.js +0 -19
- package/dist/bin/plugins/providers/ollama/index.js +0 -59
- package/dist/bin/plugins/providers/openai/index.js +0 -26
- package/dist/bin/plugins/providers/xai/index.js +0 -24
- package/dist/bin/plugins/tools/agentSpawning/agentSpawningPlugin.js +0 -8
- package/dist/bin/plugins/tools/bash/localBashPlugin.js +0 -13
- package/dist/bin/plugins/tools/checks/localRepoChecksPlugin.js +0 -13
- package/dist/bin/plugins/tools/cloud/cloudPlugin.js +0 -13
- package/dist/bin/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +0 -13
- package/dist/bin/plugins/tools/codeQuality/codeQualityPlugin.js +0 -13
- package/dist/bin/plugins/tools/dependency/dependencyPlugin.js +0 -11
- package/dist/bin/plugins/tools/development/devPlugin.js +0 -13
- package/dist/bin/plugins/tools/edit/editPlugin.js +0 -14
- package/dist/bin/plugins/tools/email/emailPlugin.js +0 -11
- package/dist/bin/plugins/tools/enhancedGit/enhancedGitPlugin.js +0 -8
- package/dist/bin/plugins/tools/filesystem/localFilesystemPlugin.js +0 -13
- package/dist/bin/plugins/tools/glob/globPlugin.js +0 -14
- package/dist/bin/plugins/tools/index.js +0 -2
- package/dist/bin/plugins/tools/interaction/interactionPlugin.js +0 -11
- package/dist/bin/plugins/tools/learn/learnPlugin.js +0 -13
- package/dist/bin/plugins/tools/mcp/mcpPlugin.js +0 -8
- package/dist/bin/plugins/tools/nodeDefaults.js +0 -56
- package/dist/bin/plugins/tools/notebook/notebookPlugin.js +0 -14
- package/dist/bin/plugins/tools/planning/planningPlugin.js +0 -14
- package/dist/bin/plugins/tools/refactoring/refactoringPlugin.js +0 -11
- package/dist/bin/plugins/tools/registry.js +0 -57
- package/dist/bin/plugins/tools/search/localSearchPlugin.js +0 -13
- package/dist/bin/plugins/tools/skills/skillPlugin.js +0 -8
- package/dist/bin/plugins/tools/taskManagement/taskManagementPlugin.js +0 -11
- package/dist/bin/plugins/tools/testing/testingPlugin.js +0 -11
- package/dist/bin/plugins/tools/web/webPlugin.js +0 -11
- package/dist/bin/providers/anthropicProvider.js +0 -329
- package/dist/bin/providers/googleProvider.js +0 -203
- package/dist/bin/providers/openaiChatCompletionsProvider.js +0 -208
- package/dist/bin/providers/openaiResponsesProvider.js +0 -249
- package/dist/bin/providers/providerFactory.js +0 -24
- package/dist/bin/runtime/agentController.js +0 -321
- package/dist/bin/runtime/agentHost.js +0 -153
- package/dist/bin/runtime/agentSession.js +0 -195
- package/dist/bin/runtime/node.js +0 -10
- package/dist/bin/runtime/universal.js +0 -28
- package/dist/bin/skills/skillRepository.js +0 -236
- package/dist/bin/skills/types.js +0 -1
- package/dist/bin/subagents/taskRunner.js +0 -269
- package/dist/bin/tools/backgroundBashTools.js +0 -211
- package/dist/bin/tools/bashTools.js +0 -159
- package/dist/bin/tools/cloudTools.js +0 -864
- package/dist/bin/tools/codeAnalysisTools.js +0 -641
- package/dist/bin/tools/codeQualityTools.js +0 -294
- package/dist/bin/tools/dependencyTools.js +0 -282
- package/dist/bin/tools/devTools.js +0 -238
- package/dist/bin/tools/diffUtils.js +0 -137
- package/dist/bin/tools/editTools.js +0 -134
- package/dist/bin/tools/emailTools.js +0 -448
- package/dist/bin/tools/fileTools.js +0 -282
- package/dist/bin/tools/globTools.js +0 -173
- package/dist/bin/tools/grepTools.js +0 -332
- package/dist/bin/tools/interactionTools.js +0 -170
- package/dist/bin/tools/learnTools.js +0 -1818
- package/dist/bin/tools/notebookEditTools.js +0 -196
- package/dist/bin/tools/planningTools.js +0 -46
- package/dist/bin/tools/refactoringTools.js +0 -293
- package/dist/bin/tools/repoChecksTools.js +0 -160
- package/dist/bin/tools/searchTools.js +0 -206
- package/dist/bin/tools/skillTools.js +0 -177
- package/dist/bin/tools/taskManagementTools.js +0 -156
- package/dist/bin/tools/testingTools.js +0 -232
- package/dist/bin/tools/webTools.js +0 -480
- package/dist/bin/workspace.js +0 -106
- package/dist/bin/workspace.validator.js +0 -213
- package/dist/capabilities/offensiveSecurityCapability.d.ts +0 -26
- package/dist/capabilities/offensiveSecurityCapability.d.ts.map +0 -1
- package/dist/capabilities/offensiveSecurityCapability.js +0 -58
- package/dist/capabilities/offensiveSecurityCapability.js.map +0 -1
- package/dist/capabilities/realSecurityCapability.d.ts +0 -26
- package/dist/capabilities/realSecurityCapability.d.ts.map +0 -1
- package/dist/capabilities/realSecurityCapability.js +0 -53
- package/dist/capabilities/realSecurityCapability.js.map +0 -1
- package/dist/capabilities/securityCapability.d.ts +0 -32
- package/dist/capabilities/securityCapability.d.ts.map +0 -1
- package/dist/capabilities/securityCapability.js +0 -57
- package/dist/capabilities/securityCapability.js.map +0 -1
- package/dist/capabilities/ultimateSecurityCapability.d.ts +0 -42
- package/dist/capabilities/ultimateSecurityCapability.d.ts.map +0 -1
- package/dist/capabilities/ultimateSecurityCapability.js +0 -96
- package/dist/capabilities/ultimateSecurityCapability.js.map +0 -1
- package/dist/core/designThoughtCheck.d.ts +0 -196
- package/dist/core/designThoughtCheck.d.ts.map +0 -1
- package/dist/core/designThoughtCheck.js +0 -287
- package/dist/core/designThoughtCheck.js.map +0 -1
- package/dist/core/designThoughtCheckEngine.d.ts +0 -58
- package/dist/core/designThoughtCheckEngine.d.ts.map +0 -1
- package/dist/core/designThoughtCheckEngine.js +0 -358
- package/dist/core/designThoughtCheckEngine.js.map +0 -1
- package/dist/core/designThoughtCheckIntegration.d.ts +0 -103
- package/dist/core/designThoughtCheckIntegration.d.ts.map +0 -1
- package/dist/core/designThoughtCheckIntegration.js +0 -207
- package/dist/core/designThoughtCheckIntegration.js.map +0 -1
- package/dist/core/intelligenceTools.d.ts +0 -19
- package/dist/core/intelligenceTools.d.ts.map +0 -1
- package/dist/core/intelligenceTools.js +0 -453
- package/dist/core/intelligenceTools.js.map +0 -1
- package/dist/core/operationalTools.d.ts +0 -19
- package/dist/core/operationalTools.d.ts.map +0 -1
- package/dist/core/operationalTools.js +0 -467
- package/dist/core/operationalTools.js.map +0 -1
- package/dist/offensive/core/offensive-engine.d.ts +0 -171
- package/dist/offensive/core/offensive-engine.d.ts.map +0 -1
- package/dist/offensive/core/offensive-engine.js +0 -345
- package/dist/offensive/core/offensive-engine.js.map +0 -1
- package/dist/offensive/core/offensive-integration.d.ts +0 -129
- package/dist/offensive/core/offensive-integration.d.ts.map +0 -1
- package/dist/offensive/core/offensive-integration.js +0 -364
- package/dist/offensive/core/offensive-integration.js.map +0 -1
- package/dist/offensive/core/offensive-tools.d.ts +0 -55
- package/dist/offensive/core/offensive-tools.d.ts.map +0 -1
- package/dist/offensive/core/offensive-tools.js +0 -438
- package/dist/offensive/core/offensive-tools.js.map +0 -1
- package/dist/offensive/offensive-cli.d.ts +0 -48
- package/dist/offensive/offensive-cli.d.ts.map +0 -1
- package/dist/offensive/offensive-cli.js +0 -233
- package/dist/offensive/offensive-cli.js.map +0 -1
- package/dist/security/apt-simulation-cli.d.ts +0 -57
- package/dist/security/apt-simulation-cli.d.ts.map +0 -1
- package/dist/security/apt-simulation-cli.js +0 -278
- package/dist/security/apt-simulation-cli.js.map +0 -1
- package/dist/security/apt-simulation-engine-complete.d.ts +0 -97
- package/dist/security/apt-simulation-engine-complete.d.ts.map +0 -1
- package/dist/security/apt-simulation-engine-complete.js +0 -441
- package/dist/security/apt-simulation-engine-complete.js.map +0 -1
- package/dist/security/apt-simulation-engine.d.ts +0 -97
- package/dist/security/apt-simulation-engine.d.ts.map +0 -1
- package/dist/security/apt-simulation-engine.js +0 -441
- package/dist/security/apt-simulation-engine.js.map +0 -1
- package/dist/security/authorization.d.ts +0 -45
- package/dist/security/authorization.d.ts.map +0 -1
- package/dist/security/authorization.js +0 -128
- package/dist/security/authorization.js.map +0 -1
- package/dist/security/comprehensive-security-research.d.ts +0 -84
- package/dist/security/comprehensive-security-research.d.ts.map +0 -1
- package/dist/security/comprehensive-security-research.js +0 -211
- package/dist/security/comprehensive-security-research.js.map +0 -1
- package/dist/security/offensive/exploitationEngine.d.ts +0 -54
- package/dist/security/offensive/exploitationEngine.d.ts.map +0 -1
- package/dist/security/offensive/exploitationEngine.js +0 -263
- package/dist/security/offensive/exploitationEngine.js.map +0 -1
- package/dist/security/real/networkExploitation.d.ts +0 -92
- package/dist/security/real/networkExploitation.d.ts.map +0 -1
- package/dist/security/real/networkExploitation.js +0 -316
- package/dist/security/real/networkExploitation.js.map +0 -1
- package/dist/security/real/persistenceImplementation.d.ts +0 -62
- package/dist/security/real/persistenceImplementation.d.ts.map +0 -1
- package/dist/security/real/persistenceImplementation.js +0 -323
- package/dist/security/real/persistenceImplementation.js.map +0 -1
- package/dist/security/real/vulnerabilityScanner.d.ts +0 -73
- package/dist/security/real/vulnerabilityScanner.d.ts.map +0 -1
- package/dist/security/real/vulnerabilityScanner.js +0 -341
- package/dist/security/real/vulnerabilityScanner.js.map +0 -1
- package/dist/shell/capturePastePatch.d.ts +0 -9
- package/dist/shell/capturePastePatch.d.ts.map +0 -1
- package/dist/shell/capturePastePatch.js +0 -98
- package/dist/shell/capturePastePatch.js.map +0 -1
- package/dist/shell/enhancedInteractiveShell.d.ts +0 -90
- package/dist/shell/enhancedInteractiveShell.d.ts.map +0 -1
- package/dist/shell/enhancedInteractiveShell.js +0 -248
- package/dist/shell/enhancedInteractiveShell.js.map +0 -1
- package/dist/shell/inputProcessor.d.ts +0 -56
- package/dist/shell/inputProcessor.d.ts.map +0 -1
- package/dist/shell/inputProcessor.js +0 -172
- package/dist/shell/inputProcessor.js.map +0 -1
- package/dist/shell/interactiveShell-patch.d.ts +0 -27
- package/dist/shell/interactiveShell-patch.d.ts.map +0 -1
- package/dist/shell/interactiveShell-patch.js +0 -38
- package/dist/shell/interactiveShell-patch.js.map +0 -1
- package/dist/shell/interactiveShell-robust.d.ts +0 -26
- package/dist/shell/interactiveShell-robust.d.ts.map +0 -1
- package/dist/shell/interactiveShell-robust.js +0 -34
- package/dist/shell/interactiveShell-robust.js.map +0 -1
- package/dist/shell/multiLinePasteManager.d.ts +0 -106
- package/dist/shell/multiLinePasteManager.d.ts.map +0 -1
- package/dist/shell/multiLinePasteManager.js +0 -308
- package/dist/shell/multiLinePasteManager.js.map +0 -1
- package/dist/shell/processInputBlockPatch.d.ts +0 -8
- package/dist/shell/processInputBlockPatch.d.ts.map +0 -1
- package/dist/shell/processInputBlockPatch.js +0 -133
- package/dist/shell/processInputBlockPatch.js.map +0 -1
- package/dist/tools/enhancedSecurityTools.d.ts +0 -19
- package/dist/tools/enhancedSecurityTools.d.ts.map +0 -1
- package/dist/tools/enhancedSecurityTools.js +0 -215
- package/dist/tools/enhancedSecurityTools.js.map +0 -1
- package/dist/tools/offensiveSecurityTools.d.ts +0 -16
- package/dist/tools/offensiveSecurityTools.d.ts.map +0 -1
- package/dist/tools/offensiveSecurityTools.js +0 -285
- package/dist/tools/offensiveSecurityTools.js.map +0 -1
- package/dist/tools/realSecurityTools.d.ts +0 -18
- package/dist/tools/realSecurityTools.d.ts.map +0 -1
- package/dist/tools/realSecurityTools.js +0 -468
- package/dist/tools/realSecurityTools.js.map +0 -1
- package/dist/tools/securityTools.d.ts +0 -20
- package/dist/tools/securityTools.d.ts.map +0 -1
- package/dist/tools/securityTools.js +0 -449
- package/dist/tools/securityTools.js.map +0 -1
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import { buildError } from '../core/errors.js';
|
|
3
|
-
/**
|
|
4
|
-
* Background Bash Shell Manager
|
|
5
|
-
*
|
|
6
|
-
* Manages long-running background bash shells with output buffering.
|
|
7
|
-
*/
|
|
8
|
-
class BackgroundShellManager {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.shells = new Map();
|
|
11
|
-
this.nextId = 1;
|
|
12
|
-
}
|
|
13
|
-
createShell(command, workingDir) {
|
|
14
|
-
const shellId = `shell_${this.nextId++}`;
|
|
15
|
-
const shell = new BackgroundShell(shellId, command, workingDir);
|
|
16
|
-
this.shells.set(shellId, shell);
|
|
17
|
-
shell.start();
|
|
18
|
-
return shellId;
|
|
19
|
-
}
|
|
20
|
-
getShell(shellId) {
|
|
21
|
-
return this.shells.get(shellId);
|
|
22
|
-
}
|
|
23
|
-
killShell(shellId) {
|
|
24
|
-
const shell = this.shells.get(shellId);
|
|
25
|
-
if (shell) {
|
|
26
|
-
shell.kill();
|
|
27
|
-
this.shells.delete(shellId);
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
listShells() {
|
|
33
|
-
return Array.from(this.shells.keys());
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
class BackgroundShell {
|
|
37
|
-
constructor(id, command, _workingDir) {
|
|
38
|
-
this.id = id;
|
|
39
|
-
this.command = command;
|
|
40
|
-
this._workingDir = _workingDir;
|
|
41
|
-
this.outputBuffer = [];
|
|
42
|
-
this.errorBuffer = [];
|
|
43
|
-
this.lastReadPosition = 0;
|
|
44
|
-
this.isRunning = false;
|
|
45
|
-
}
|
|
46
|
-
start() {
|
|
47
|
-
this.process = spawn('bash', ['-c', this.command], {
|
|
48
|
-
cwd: this._workingDir,
|
|
49
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
50
|
-
});
|
|
51
|
-
this.isRunning = true;
|
|
52
|
-
this.process.stdout?.on('data', (data) => {
|
|
53
|
-
this.outputBuffer.push(data.toString());
|
|
54
|
-
});
|
|
55
|
-
this.process.stderr?.on('data', (data) => {
|
|
56
|
-
this.errorBuffer.push(data.toString());
|
|
57
|
-
});
|
|
58
|
-
this.process.on('exit', (code) => {
|
|
59
|
-
this.exitCode = code ?? 0;
|
|
60
|
-
this.isRunning = false;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
getNewOutput(filter) {
|
|
64
|
-
const allOutput = this.outputBuffer.join('');
|
|
65
|
-
const newOutput = allOutput.substring(this.lastReadPosition);
|
|
66
|
-
this.lastReadPosition = allOutput.length;
|
|
67
|
-
const allError = this.errorBuffer.join('');
|
|
68
|
-
let stdout = newOutput;
|
|
69
|
-
if (filter) {
|
|
70
|
-
const lines = newOutput.split('\n');
|
|
71
|
-
const filtered = lines.filter(line => filter.test(line));
|
|
72
|
-
stdout = filtered.join('\n');
|
|
73
|
-
}
|
|
74
|
-
const status = this.isRunning
|
|
75
|
-
? 'running'
|
|
76
|
-
: `exited with code ${this.exitCode}`;
|
|
77
|
-
return {
|
|
78
|
-
stdout,
|
|
79
|
-
stderr: allError,
|
|
80
|
-
status,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
kill() {
|
|
84
|
-
if (this.process) {
|
|
85
|
-
this.process.kill('SIGTERM');
|
|
86
|
-
setTimeout(() => {
|
|
87
|
-
if (this.process && !this.process.killed) {
|
|
88
|
-
this.process.kill('SIGKILL');
|
|
89
|
-
}
|
|
90
|
-
}, 5000);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
getStatus() {
|
|
94
|
-
return this.isRunning ? 'running' : `exited with code ${this.exitCode}`;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// Global manager instance
|
|
98
|
-
const shellManager = new BackgroundShellManager();
|
|
99
|
-
/**
|
|
100
|
-
* Creates background bash management tools
|
|
101
|
-
*
|
|
102
|
-
* Tools:
|
|
103
|
-
* - Bash (with run_in_background): Start background processes
|
|
104
|
-
* - BashOutput: Retrieve output from background shells
|
|
105
|
-
* - KillShell: Terminate background shells
|
|
106
|
-
*
|
|
107
|
-
* @param _workingDir - The working directory for commands (reserved for future use)
|
|
108
|
-
* @returns Array of tool definitions
|
|
109
|
-
*/
|
|
110
|
-
export function createBackgroundBashTools(_workingDir) {
|
|
111
|
-
return [
|
|
112
|
-
{
|
|
113
|
-
name: 'BashOutput',
|
|
114
|
-
description: 'Retrieves output from a running or completed background bash shell. Always returns only new output since the last check.',
|
|
115
|
-
parameters: {
|
|
116
|
-
type: 'object',
|
|
117
|
-
properties: {
|
|
118
|
-
bash_id: {
|
|
119
|
-
type: 'string',
|
|
120
|
-
description: 'The ID of the background shell to retrieve output from',
|
|
121
|
-
},
|
|
122
|
-
filter: {
|
|
123
|
-
type: 'string',
|
|
124
|
-
description: 'Optional regular expression to filter the output lines. Only lines matching this regex will be included.',
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
required: ['bash_id'],
|
|
128
|
-
additionalProperties: false,
|
|
129
|
-
},
|
|
130
|
-
handler: async (args) => {
|
|
131
|
-
const bashId = args['bash_id'];
|
|
132
|
-
const filterStr = args['filter'];
|
|
133
|
-
if (typeof bashId !== 'string' || !bashId.trim()) {
|
|
134
|
-
return 'Error: bash_id must be a non-empty string.';
|
|
135
|
-
}
|
|
136
|
-
try {
|
|
137
|
-
const shell = shellManager.getShell(bashId);
|
|
138
|
-
if (!shell) {
|
|
139
|
-
const available = shellManager.listShells();
|
|
140
|
-
return `Error: Shell "${bashId}" not found.\n\nAvailable shells: ${available.length > 0 ? available.join(', ') : 'none'}`;
|
|
141
|
-
}
|
|
142
|
-
const filter = filterStr && typeof filterStr === 'string'
|
|
143
|
-
? new RegExp(filterStr)
|
|
144
|
-
: undefined;
|
|
145
|
-
const { stdout, stderr, status } = shell.getNewOutput(filter);
|
|
146
|
-
const parts = [];
|
|
147
|
-
parts.push(`Shell: ${bashId}`);
|
|
148
|
-
parts.push(`Status: ${status}`);
|
|
149
|
-
if (stdout) {
|
|
150
|
-
parts.push('\n=== New Output ===');
|
|
151
|
-
parts.push(stdout);
|
|
152
|
-
}
|
|
153
|
-
if (stderr) {
|
|
154
|
-
parts.push('\n=== Errors ===');
|
|
155
|
-
parts.push(stderr);
|
|
156
|
-
}
|
|
157
|
-
if (!stdout && !stderr) {
|
|
158
|
-
parts.push('\n(No new output)');
|
|
159
|
-
}
|
|
160
|
-
return parts.join('\n');
|
|
161
|
-
}
|
|
162
|
-
catch (error) {
|
|
163
|
-
return buildError('retrieving shell output', error, { bash_id: bashId });
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: 'KillShell',
|
|
169
|
-
description: 'Kills a running background bash shell by its ID. Returns success or failure status.',
|
|
170
|
-
parameters: {
|
|
171
|
-
type: 'object',
|
|
172
|
-
properties: {
|
|
173
|
-
shell_id: {
|
|
174
|
-
type: 'string',
|
|
175
|
-
description: 'The ID of the background shell to kill',
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
required: ['shell_id'],
|
|
179
|
-
additionalProperties: false,
|
|
180
|
-
},
|
|
181
|
-
handler: async (args) => {
|
|
182
|
-
const shellId = args['shell_id'];
|
|
183
|
-
if (typeof shellId !== 'string' || !shellId.trim()) {
|
|
184
|
-
return 'Error: shell_id must be a non-empty string.';
|
|
185
|
-
}
|
|
186
|
-
try {
|
|
187
|
-
const success = shellManager.killShell(shellId);
|
|
188
|
-
if (success) {
|
|
189
|
-
return `✓ Shell "${shellId}" has been terminated.`;
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
const available = shellManager.listShells();
|
|
193
|
-
return `Error: Shell "${shellId}" not found.\n\nAvailable shells: ${available.length > 0 ? available.join(', ') : 'none'}`;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
return buildError('killing shell', error, { shell_id: shellId });
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
];
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Start a background bash command
|
|
205
|
-
*
|
|
206
|
-
* This should be integrated into the main Bash tool with a run_in_background parameter.
|
|
207
|
-
* For now, it's exported as a helper function.
|
|
208
|
-
*/
|
|
209
|
-
export function startBackgroundShell(command, workingDir) {
|
|
210
|
-
return shellManager.createShell(command, workingDir);
|
|
211
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { exec } from 'node:child_process';
|
|
2
|
-
import { mkdir } from 'node:fs/promises';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { promisify } from 'node:util';
|
|
5
|
-
import { createBackgroundBashTools, startBackgroundShell } from './backgroundBashTools.js';
|
|
6
|
-
import { validateBashCommand, SmartFixer } from '../core/errors/safetyValidator.js';
|
|
7
|
-
import { toStructuredError } from '../core/errors/errorTypes.js';
|
|
8
|
-
const execAsync = promisify(exec);
|
|
9
|
-
const sandboxCache = new Map();
|
|
10
|
-
export function createBashTools(workingDir) {
|
|
11
|
-
const backgroundTools = createBackgroundBashTools(workingDir);
|
|
12
|
-
return [
|
|
13
|
-
{
|
|
14
|
-
name: 'execute_bash',
|
|
15
|
-
description: 'Execute a bash command in the working directory. Use run_in_background: true to run commands in the background and monitor with BashOutput.',
|
|
16
|
-
parameters: {
|
|
17
|
-
type: 'object',
|
|
18
|
-
properties: {
|
|
19
|
-
command: {
|
|
20
|
-
type: 'string',
|
|
21
|
-
description: 'The bash command to execute',
|
|
22
|
-
},
|
|
23
|
-
timeout: {
|
|
24
|
-
type: 'number',
|
|
25
|
-
description: 'Timeout in milliseconds (default: 30000). Not used when run_in_background is true.',
|
|
26
|
-
},
|
|
27
|
-
run_in_background: {
|
|
28
|
-
type: 'boolean',
|
|
29
|
-
description: 'Set to true to run this command in the background. Returns a shell ID that can be used with BashOutput to monitor output.',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
required: ['command'],
|
|
33
|
-
},
|
|
34
|
-
handler: async (args) => {
|
|
35
|
-
const command = args['command'];
|
|
36
|
-
const timeout = args['timeout'] || 30000;
|
|
37
|
-
const runInBackground = args['run_in_background'] === true;
|
|
38
|
-
// Enhanced safety validation with structured errors
|
|
39
|
-
const validation = validateBashCommand(command);
|
|
40
|
-
if (!validation.valid) {
|
|
41
|
-
const structuredError = validation.error ? toStructuredError(validation.error) : null;
|
|
42
|
-
if (structuredError) {
|
|
43
|
-
// Return formatted error with suggestions
|
|
44
|
-
let errorMsg = structuredError.toDisplayString();
|
|
45
|
-
// Add auto-fix suggestion if available
|
|
46
|
-
if (validation.autoFix?.available) {
|
|
47
|
-
const { fixed, changes } = SmartFixer.fixDangerousCommand(command);
|
|
48
|
-
if (changes.length > 0) {
|
|
49
|
-
errorMsg += '\n\nAuto-fix available:';
|
|
50
|
-
for (const change of changes) {
|
|
51
|
-
errorMsg += `\n - ${change}`;
|
|
52
|
-
}
|
|
53
|
-
errorMsg += `\n\nFixed command: ${fixed}`;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return errorMsg;
|
|
57
|
-
}
|
|
58
|
-
return 'Error: Command validation failed';
|
|
59
|
-
}
|
|
60
|
-
// Log warnings if any
|
|
61
|
-
if (validation.warnings.length > 0) {
|
|
62
|
-
for (const warning of validation.warnings) {
|
|
63
|
-
console.warn(`[Bash Safety] ${warning}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// Handle background execution
|
|
67
|
-
if (runInBackground) {
|
|
68
|
-
const shellId = startBackgroundShell(command, workingDir);
|
|
69
|
-
return `Background shell started: ${shellId}\n\nUse BashOutput with bash_id="${shellId}" to monitor output.\nUse KillShell with shell_id="${shellId}" to terminate.`;
|
|
70
|
-
}
|
|
71
|
-
// Handle foreground execution
|
|
72
|
-
try {
|
|
73
|
-
const env = await buildSandboxEnv(workingDir);
|
|
74
|
-
const { stdout, stderr } = await execAsync(command, {
|
|
75
|
-
cwd: workingDir,
|
|
76
|
-
timeout,
|
|
77
|
-
maxBuffer: 1024 * 1024 * 10, // 10MB
|
|
78
|
-
env,
|
|
79
|
-
});
|
|
80
|
-
let result = '';
|
|
81
|
-
if (stdout)
|
|
82
|
-
result += `stdout:\n${stdout}\n`;
|
|
83
|
-
if (stderr)
|
|
84
|
-
result += `stderr:\n${stderr}\n`;
|
|
85
|
-
return result || 'Command executed successfully (no output)';
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
if (error.killed) {
|
|
89
|
-
return `Error: Command timed out after ${timeout}ms`;
|
|
90
|
-
}
|
|
91
|
-
return `Error executing command: ${error.message}\nstderr: ${error.stderr || 'none'}`;
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
name: 'execute_bash_stream',
|
|
97
|
-
description: 'Execute a bash command and stream output (for long-running commands)',
|
|
98
|
-
parameters: {
|
|
99
|
-
type: 'object',
|
|
100
|
-
properties: {
|
|
101
|
-
command: {
|
|
102
|
-
type: 'string',
|
|
103
|
-
description: 'The bash command to execute',
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
required: ['command'],
|
|
107
|
-
},
|
|
108
|
-
handler: async (_args) => {
|
|
109
|
-
await buildSandboxEnv(workingDir);
|
|
110
|
-
return 'Stream execution not yet implemented - use execute_bash instead';
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
...backgroundTools,
|
|
114
|
-
];
|
|
115
|
-
}
|
|
116
|
-
export async function buildSandboxEnv(workingDir, options) {
|
|
117
|
-
const envPreference = process.env['EROSOLAR_PRESERVE_HOME'];
|
|
118
|
-
const preserveHome = envPreference === '1'
|
|
119
|
-
? true
|
|
120
|
-
: envPreference === '0'
|
|
121
|
-
? false
|
|
122
|
-
: Boolean(options?.preserveHome);
|
|
123
|
-
const paths = await ensureSandboxPaths(workingDir);
|
|
124
|
-
const env = {
|
|
125
|
-
...process.env,
|
|
126
|
-
EROSOLAR_SANDBOX_ROOT: paths.root,
|
|
127
|
-
EROSOLAR_SANDBOX_HOME: paths.home,
|
|
128
|
-
EROSOLAR_SANDBOX_TMP: paths.tmp,
|
|
129
|
-
};
|
|
130
|
-
if (!preserveHome) {
|
|
131
|
-
env['HOME'] = paths.home;
|
|
132
|
-
}
|
|
133
|
-
env['XDG_CACHE_HOME'] = paths.cache;
|
|
134
|
-
env['XDG_CONFIG_HOME'] = paths.config;
|
|
135
|
-
env['XDG_DATA_HOME'] = paths.data;
|
|
136
|
-
env['TMPDIR'] = paths.tmp;
|
|
137
|
-
env['TMP'] = paths.tmp;
|
|
138
|
-
env['TEMP'] = paths.tmp;
|
|
139
|
-
return env;
|
|
140
|
-
}
|
|
141
|
-
async function ensureSandboxPaths(workingDir) {
|
|
142
|
-
const key = workingDir;
|
|
143
|
-
let pending = sandboxCache.get(key);
|
|
144
|
-
if (!pending) {
|
|
145
|
-
pending = createSandboxPaths(workingDir);
|
|
146
|
-
sandboxCache.set(key, pending);
|
|
147
|
-
}
|
|
148
|
-
return pending;
|
|
149
|
-
}
|
|
150
|
-
async function createSandboxPaths(workingDir) {
|
|
151
|
-
const root = join(workingDir, '.erosolar', 'shell-sandbox');
|
|
152
|
-
const home = join(root, 'home');
|
|
153
|
-
const cache = join(root, 'cache');
|
|
154
|
-
const config = join(root, 'config');
|
|
155
|
-
const data = join(root, 'data');
|
|
156
|
-
const tmp = join(root, 'tmp');
|
|
157
|
-
await Promise.all([home, cache, config, data, tmp].map((dir) => mkdir(dir, { recursive: true })));
|
|
158
|
-
return { root, home, cache, config, data, tmp };
|
|
159
|
-
}
|