erosolar-cli 1.7.346 → 1.7.347
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/README.md +24 -148
- package/dist/bin/erosolar.js +5 -21
- package/dist/bin/erosolar.js.map +1 -1
- package/dist/capabilities/agentSpawningCapability.d.ts.map +1 -1
- package/dist/capabilities/agentSpawningCapability.js +56 -31
- package/dist/capabilities/agentSpawningCapability.js.map +1 -1
- package/dist/contracts/agent-schemas.json +0 -15
- package/dist/contracts/tools.schema.json +0 -9
- package/dist/core/agent.d.ts +2 -2
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js.map +1 -1
- package/dist/core/customCommands.d.ts +1 -0
- package/dist/core/customCommands.d.ts.map +1 -1
- package/dist/core/customCommands.js +3 -0
- package/dist/core/customCommands.js.map +1 -1
- package/dist/core/hooks.d.ts +113 -0
- package/dist/core/hooks.d.ts.map +1 -0
- package/dist/core/hooks.js +267 -0
- package/dist/core/hooks.js.map +1 -0
- package/dist/core/metricsTracker.d.ts +122 -0
- package/dist/core/metricsTracker.d.ts.map +1 -0
- package/dist/{alpha-zero → core}/metricsTracker.js +2 -5
- package/dist/core/metricsTracker.js.map +1 -0
- package/dist/core/securityAssessment.d.ts +91 -0
- package/dist/core/securityAssessment.d.ts.map +1 -0
- package/dist/core/securityAssessment.js +580 -0
- package/dist/core/securityAssessment.js.map +1 -0
- package/dist/core/sessionStore.d.ts +2 -0
- package/dist/core/sessionStore.d.ts.map +1 -1
- package/dist/core/sessionStore.js +1 -0
- package/dist/core/sessionStore.js.map +1 -1
- package/dist/core/toolPreconditions.d.ts.map +1 -1
- package/dist/core/toolPreconditions.js +0 -14
- package/dist/core/toolPreconditions.js.map +1 -1
- package/dist/core/toolRuntime.d.ts +22 -1
- package/dist/core/toolRuntime.d.ts.map +1 -1
- package/dist/core/toolRuntime.js +0 -5
- package/dist/core/toolRuntime.js.map +1 -1
- package/dist/core/toolValidation.d.ts.map +1 -1
- package/dist/core/toolValidation.js +14 -3
- package/dist/core/toolValidation.js.map +1 -1
- package/dist/core/validationRunner.d.ts +1 -3
- package/dist/core/validationRunner.d.ts.map +1 -1
- package/dist/core/validationRunner.js.map +1 -1
- package/dist/core/verification.d.ts +137 -0
- package/dist/core/verification.d.ts.map +1 -0
- package/dist/core/verification.js +323 -0
- package/dist/core/verification.js.map +1 -0
- package/dist/headless/headlessApp.d.ts.map +1 -1
- package/dist/headless/headlessApp.js +21 -0
- package/dist/headless/headlessApp.js.map +1 -1
- package/dist/mcp/sseClient.d.ts.map +1 -1
- package/dist/mcp/sseClient.js +9 -18
- package/dist/mcp/sseClient.js.map +1 -1
- package/dist/plugins/tools/build/buildPlugin.d.ts +0 -6
- package/dist/plugins/tools/build/buildPlugin.d.ts.map +1 -1
- package/dist/plugins/tools/build/buildPlugin.js +4 -10
- package/dist/plugins/tools/build/buildPlugin.js.map +1 -1
- package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
- package/dist/plugins/tools/nodeDefaults.js +0 -2
- package/dist/plugins/tools/nodeDefaults.js.map +1 -1
- package/dist/runtime/agentSession.d.ts +2 -2
- package/dist/runtime/agentSession.d.ts.map +1 -1
- package/dist/runtime/agentSession.js +2 -2
- package/dist/runtime/agentSession.js.map +1 -1
- package/dist/shell/interactiveShell.d.ts +43 -7
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +417 -166
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/shell/shellApp.d.ts +2 -0
- package/dist/shell/shellApp.d.ts.map +1 -1
- package/dist/shell/shellApp.js +82 -9
- package/dist/shell/shellApp.js.map +1 -1
- package/dist/shell/systemPrompt.d.ts.map +1 -1
- package/dist/shell/systemPrompt.js +1 -4
- package/dist/shell/systemPrompt.js.map +1 -1
- package/dist/shell/terminalInput.d.ts +252 -120
- package/dist/shell/terminalInput.d.ts.map +1 -1
- package/dist/shell/terminalInput.js +1117 -541
- package/dist/shell/terminalInput.js.map +1 -1
- package/dist/shell/terminalInputAdapter.d.ts +106 -24
- package/dist/shell/terminalInputAdapter.d.ts.map +1 -1
- package/dist/shell/terminalInputAdapter.js +141 -30
- package/dist/shell/terminalInputAdapter.js.map +1 -1
- package/dist/subagents/agentConfig.d.ts +27 -0
- package/dist/subagents/agentConfig.d.ts.map +1 -0
- package/dist/subagents/agentConfig.js +89 -0
- package/dist/subagents/agentConfig.js.map +1 -0
- package/dist/subagents/agentRegistry.d.ts +33 -0
- package/dist/subagents/agentRegistry.d.ts.map +1 -0
- package/dist/subagents/agentRegistry.js +162 -0
- package/dist/subagents/agentRegistry.js.map +1 -0
- package/dist/subagents/taskRunner.d.ts +7 -1
- package/dist/subagents/taskRunner.d.ts.map +1 -1
- package/dist/subagents/taskRunner.js +180 -47
- package/dist/subagents/taskRunner.js.map +1 -1
- package/dist/ui/ShellUIAdapter.d.ts +7 -1
- package/dist/ui/ShellUIAdapter.d.ts.map +1 -1
- package/dist/ui/ShellUIAdapter.js +42 -18
- package/dist/ui/ShellUIAdapter.js.map +1 -1
- package/dist/ui/display.d.ts +24 -45
- package/dist/ui/display.d.ts.map +1 -1
- package/dist/ui/display.js +140 -259
- package/dist/ui/display.js.map +1 -1
- package/dist/ui/theme.d.ts.map +1 -1
- package/dist/ui/theme.js +6 -8
- package/dist/ui/theme.js.map +1 -1
- package/dist/ui/toolDisplay.d.ts +0 -158
- package/dist/ui/toolDisplay.d.ts.map +1 -1
- package/dist/ui/toolDisplay.js +0 -348
- package/dist/ui/toolDisplay.js.map +1 -1
- package/dist/ui/unified/layout.d.ts +20 -0
- package/dist/ui/unified/layout.d.ts.map +1 -1
- package/dist/ui/unified/layout.js +105 -216
- package/dist/ui/unified/layout.js.map +1 -1
- 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/package.json +4 -4
- package/dist/alpha-zero/agentWrapper.d.ts +0 -84
- package/dist/alpha-zero/agentWrapper.d.ts.map +0 -1
- package/dist/alpha-zero/agentWrapper.js +0 -171
- package/dist/alpha-zero/agentWrapper.js.map +0 -1
- package/dist/alpha-zero/codeEvaluator.d.ts +0 -25
- package/dist/alpha-zero/codeEvaluator.d.ts.map +0 -1
- package/dist/alpha-zero/codeEvaluator.js +0 -273
- package/dist/alpha-zero/codeEvaluator.js.map +0 -1
- package/dist/alpha-zero/competitiveRunner.d.ts +0 -66
- package/dist/alpha-zero/competitiveRunner.d.ts.map +0 -1
- package/dist/alpha-zero/competitiveRunner.js +0 -224
- package/dist/alpha-zero/competitiveRunner.js.map +0 -1
- package/dist/alpha-zero/index.d.ts +0 -67
- package/dist/alpha-zero/index.d.ts.map +0 -1
- package/dist/alpha-zero/index.js +0 -99
- package/dist/alpha-zero/index.js.map +0 -1
- package/dist/alpha-zero/introspection.d.ts +0 -128
- package/dist/alpha-zero/introspection.d.ts.map +0 -1
- package/dist/alpha-zero/introspection.js +0 -300
- package/dist/alpha-zero/introspection.js.map +0 -1
- package/dist/alpha-zero/metricsTracker.d.ts +0 -71
- package/dist/alpha-zero/metricsTracker.d.ts.map +0 -1
- package/dist/alpha-zero/metricsTracker.js.map +0 -1
- package/dist/alpha-zero/security/core.d.ts +0 -125
- package/dist/alpha-zero/security/core.d.ts.map +0 -1
- package/dist/alpha-zero/security/core.js +0 -271
- package/dist/alpha-zero/security/core.js.map +0 -1
- package/dist/alpha-zero/security/google.d.ts +0 -125
- package/dist/alpha-zero/security/google.d.ts.map +0 -1
- package/dist/alpha-zero/security/google.js +0 -311
- package/dist/alpha-zero/security/google.js.map +0 -1
- package/dist/alpha-zero/security/googleLoader.d.ts +0 -17
- package/dist/alpha-zero/security/googleLoader.d.ts.map +0 -1
- package/dist/alpha-zero/security/googleLoader.js +0 -41
- package/dist/alpha-zero/security/googleLoader.js.map +0 -1
- package/dist/alpha-zero/security/index.d.ts +0 -29
- package/dist/alpha-zero/security/index.d.ts.map +0 -1
- package/dist/alpha-zero/security/index.js +0 -32
- package/dist/alpha-zero/security/index.js.map +0 -1
- package/dist/alpha-zero/security/simulation.d.ts +0 -124
- package/dist/alpha-zero/security/simulation.d.ts.map +0 -1
- package/dist/alpha-zero/security/simulation.js +0 -277
- package/dist/alpha-zero/security/simulation.js.map +0 -1
- package/dist/alpha-zero/selfModification.d.ts +0 -109
- package/dist/alpha-zero/selfModification.d.ts.map +0 -1
- package/dist/alpha-zero/selfModification.js +0 -233
- package/dist/alpha-zero/selfModification.js.map +0 -1
- package/dist/alpha-zero/types.d.ts +0 -170
- package/dist/alpha-zero/types.d.ts.map +0 -1
- package/dist/alpha-zero/types.js +0 -31
- package/dist/alpha-zero/types.js.map +0 -1
- package/dist/capabilities/securityTestingCapability.d.ts +0 -13
- package/dist/capabilities/securityTestingCapability.d.ts.map +0 -1
- package/dist/capabilities/securityTestingCapability.js +0 -25
- package/dist/capabilities/securityTestingCapability.js.map +0 -1
- package/dist/core/aiFlowOptimizer.d.ts +0 -26
- package/dist/core/aiFlowOptimizer.d.ts.map +0 -1
- package/dist/core/aiFlowOptimizer.js +0 -31
- package/dist/core/aiFlowOptimizer.js.map +0 -1
- package/dist/core/aiOptimizationEngine.d.ts +0 -158
- package/dist/core/aiOptimizationEngine.d.ts.map +0 -1
- package/dist/core/aiOptimizationEngine.js +0 -428
- package/dist/core/aiOptimizationEngine.js.map +0 -1
- package/dist/core/aiOptimizationIntegration.d.ts +0 -93
- package/dist/core/aiOptimizationIntegration.d.ts.map +0 -1
- package/dist/core/aiOptimizationIntegration.js +0 -250
- package/dist/core/aiOptimizationIntegration.js.map +0 -1
- package/dist/core/enhancedErrorRecovery.d.ts +0 -100
- package/dist/core/enhancedErrorRecovery.d.ts.map +0 -1
- package/dist/core/enhancedErrorRecovery.js +0 -345
- package/dist/core/enhancedErrorRecovery.js.map +0 -1
- package/dist/core/hooksSystem.d.ts +0 -65
- package/dist/core/hooksSystem.d.ts.map +0 -1
- package/dist/core/hooksSystem.js +0 -273
- package/dist/core/hooksSystem.js.map +0 -1
- package/dist/core/memorySystem.d.ts +0 -48
- package/dist/core/memorySystem.d.ts.map +0 -1
- package/dist/core/memorySystem.js +0 -271
- package/dist/core/memorySystem.js.map +0 -1
- package/dist/core/unified/errors.d.ts +0 -189
- package/dist/core/unified/errors.d.ts.map +0 -1
- package/dist/core/unified/errors.js +0 -497
- package/dist/core/unified/errors.js.map +0 -1
- package/dist/core/unified/index.d.ts +0 -19
- package/dist/core/unified/index.d.ts.map +0 -1
- package/dist/core/unified/index.js +0 -68
- package/dist/core/unified/index.js.map +0 -1
- package/dist/core/unified/schema.d.ts +0 -101
- package/dist/core/unified/schema.d.ts.map +0 -1
- package/dist/core/unified/schema.js +0 -350
- package/dist/core/unified/schema.js.map +0 -1
- package/dist/core/unified/toolRuntime.d.ts +0 -179
- package/dist/core/unified/toolRuntime.d.ts.map +0 -1
- package/dist/core/unified/toolRuntime.js +0 -517
- package/dist/core/unified/toolRuntime.js.map +0 -1
- package/dist/core/unified/tools.d.ts +0 -127
- package/dist/core/unified/tools.d.ts.map +0 -1
- package/dist/core/unified/tools.js +0 -1333
- package/dist/core/unified/tools.js.map +0 -1
- package/dist/core/unified/types.d.ts +0 -352
- package/dist/core/unified/types.d.ts.map +0 -1
- package/dist/core/unified/types.js +0 -12
- package/dist/core/unified/types.js.map +0 -1
- package/dist/core/unified/version.d.ts +0 -209
- package/dist/core/unified/version.d.ts.map +0 -1
- package/dist/core/unified/version.js +0 -454
- package/dist/core/unified/version.js.map +0 -1
- package/dist/plugins/tools/security/securityPlugin.d.ts +0 -3
- package/dist/plugins/tools/security/securityPlugin.d.ts.map +0 -1
- package/dist/plugins/tools/security/securityPlugin.js +0 -12
- package/dist/plugins/tools/security/securityPlugin.js.map +0 -1
- package/dist/security/active-stack-security.d.ts +0 -112
- package/dist/security/active-stack-security.d.ts.map +0 -1
- package/dist/security/active-stack-security.js +0 -296
- package/dist/security/active-stack-security.js.map +0 -1
- package/dist/security/advanced-persistence-research.d.ts +0 -92
- package/dist/security/advanced-persistence-research.d.ts.map +0 -1
- package/dist/security/advanced-persistence-research.js +0 -195
- package/dist/security/advanced-persistence-research.js.map +0 -1
- package/dist/security/advanced-targeting.d.ts +0 -119
- package/dist/security/advanced-targeting.d.ts.map +0 -1
- package/dist/security/advanced-targeting.js +0 -233
- package/dist/security/advanced-targeting.js.map +0 -1
- package/dist/security/assessment/vulnerabilityAssessment.d.ts +0 -104
- package/dist/security/assessment/vulnerabilityAssessment.d.ts.map +0 -1
- package/dist/security/assessment/vulnerabilityAssessment.js +0 -315
- package/dist/security/assessment/vulnerabilityAssessment.js.map +0 -1
- package/dist/security/authorization/securityAuthorization.d.ts +0 -88
- package/dist/security/authorization/securityAuthorization.d.ts.map +0 -1
- package/dist/security/authorization/securityAuthorization.js +0 -172
- package/dist/security/authorization/securityAuthorization.js.map +0 -1
- package/dist/security/comprehensive-targeting.d.ts +0 -85
- package/dist/security/comprehensive-targeting.d.ts.map +0 -1
- package/dist/security/comprehensive-targeting.js +0 -438
- package/dist/security/comprehensive-targeting.js.map +0 -1
- package/dist/security/global-security-integration.d.ts +0 -91
- package/dist/security/global-security-integration.d.ts.map +0 -1
- package/dist/security/global-security-integration.js +0 -218
- package/dist/security/global-security-integration.js.map +0 -1
- package/dist/security/index.d.ts +0 -38
- package/dist/security/index.d.ts.map +0 -1
- package/dist/security/index.js +0 -47
- package/dist/security/index.js.map +0 -1
- package/dist/security/persistence-analyzer.d.ts +0 -56
- package/dist/security/persistence-analyzer.d.ts.map +0 -1
- package/dist/security/persistence-analyzer.js +0 -187
- package/dist/security/persistence-analyzer.js.map +0 -1
- package/dist/security/persistence-cli.d.ts +0 -36
- package/dist/security/persistence-cli.d.ts.map +0 -1
- package/dist/security/persistence-cli.js +0 -160
- package/dist/security/persistence-cli.js.map +0 -1
- package/dist/security/persistence-research.d.ts +0 -92
- package/dist/security/persistence-research.d.ts.map +0 -1
- package/dist/security/persistence-research.js +0 -364
- package/dist/security/persistence-research.js.map +0 -1
- package/dist/security/research/persistenceResearch.d.ts +0 -97
- package/dist/security/research/persistenceResearch.d.ts.map +0 -1
- package/dist/security/research/persistenceResearch.js +0 -282
- package/dist/security/research/persistenceResearch.js.map +0 -1
- package/dist/security/security-integration.d.ts +0 -74
- package/dist/security/security-integration.d.ts.map +0 -1
- package/dist/security/security-integration.js +0 -137
- package/dist/security/security-integration.js.map +0 -1
- package/dist/security/security-testing-framework.d.ts +0 -112
- package/dist/security/security-testing-framework.d.ts.map +0 -1
- package/dist/security/security-testing-framework.js +0 -364
- package/dist/security/security-testing-framework.js.map +0 -1
- package/dist/security/simulation/attackSimulation.d.ts +0 -93
- package/dist/security/simulation/attackSimulation.d.ts.map +0 -1
- package/dist/security/simulation/attackSimulation.js +0 -341
- package/dist/security/simulation/attackSimulation.js.map +0 -1
- package/dist/security/strategic-operations.d.ts +0 -100
- package/dist/security/strategic-operations.d.ts.map +0 -1
- package/dist/security/strategic-operations.js +0 -276
- package/dist/security/strategic-operations.js.map +0 -1
- package/dist/security/tool-security-wrapper.d.ts +0 -58
- package/dist/security/tool-security-wrapper.d.ts.map +0 -1
- package/dist/security/tool-security-wrapper.js +0 -156
- package/dist/security/tool-security-wrapper.js.map +0 -1
- package/dist/shell/claudeCodeStreamHandler.d.ts +0 -145
- package/dist/shell/claudeCodeStreamHandler.d.ts.map +0 -1
- package/dist/shell/claudeCodeStreamHandler.js +0 -322
- package/dist/shell/claudeCodeStreamHandler.js.map +0 -1
- package/dist/shell/inputQueueManager.d.ts +0 -144
- package/dist/shell/inputQueueManager.d.ts.map +0 -1
- package/dist/shell/inputQueueManager.js +0 -290
- package/dist/shell/inputQueueManager.js.map +0 -1
- package/dist/shell/metricsTracker.d.ts +0 -60
- package/dist/shell/metricsTracker.d.ts.map +0 -1
- package/dist/shell/metricsTracker.js +0 -119
- package/dist/shell/metricsTracker.js.map +0 -1
- package/dist/shell/streamingOutputManager.d.ts +0 -115
- package/dist/shell/streamingOutputManager.d.ts.map +0 -1
- package/dist/shell/streamingOutputManager.js +0 -225
- package/dist/shell/streamingOutputManager.js.map +0 -1
- package/dist/tools/securityTools.d.ts +0 -22
- package/dist/tools/securityTools.d.ts.map +0 -1
- package/dist/tools/securityTools.js +0 -448
- package/dist/tools/securityTools.js.map +0 -1
- package/dist/ui/persistentPrompt.d.ts +0 -50
- package/dist/ui/persistentPrompt.d.ts.map +0 -1
- package/dist/ui/persistentPrompt.js +0 -92
- package/dist/ui/persistentPrompt.js.map +0 -1
- package/dist/ui/terminalUISchema.d.ts +0 -195
- package/dist/ui/terminalUISchema.d.ts.map +0 -1
- package/dist/ui/terminalUISchema.js +0 -113
- package/dist/ui/terminalUISchema.js.map +0 -1
- package/scripts/deploy-security-capabilities.js +0 -178
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Strategic Operations Framework
|
|
3
|
-
*
|
|
4
|
-
* Provides strategic operations capabilities for comprehensive coverage
|
|
5
|
-
* of companies, countries, and global entities with proper authorization
|
|
6
|
-
* and geopolitical considerations.
|
|
7
|
-
*
|
|
8
|
-
* @license MIT
|
|
9
|
-
* @author Bo Shang
|
|
10
|
-
*/
|
|
11
|
-
import { globalSecurityIntegration } from './global-security-integration.js';
|
|
12
|
-
import { ComprehensiveTargeting } from './comprehensive-targeting.js';
|
|
13
|
-
export class StrategicOperations {
|
|
14
|
-
comprehensiveTargeting;
|
|
15
|
-
activeOperations = new Map();
|
|
16
|
-
constructor() {
|
|
17
|
-
this.comprehensiveTargeting = new ComprehensiveTargeting();
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Plan a strategic operation
|
|
21
|
-
*/
|
|
22
|
-
planOperation(targetIdentifier, operationType, objectives) {
|
|
23
|
-
const target = this.comprehensiveTargeting.getStrategicEntity(targetIdentifier);
|
|
24
|
-
if (!target) {
|
|
25
|
-
console.warn(`Target ${targetIdentifier} not found in strategic entities`);
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
// Validate operation authorization
|
|
29
|
-
if (!target.authorizedOperations.includes(operationType)) {
|
|
30
|
-
console.warn(`Operation ${operationType} not authorized for target ${targetIdentifier}`);
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
const operation = {
|
|
34
|
-
id: this.generateOperationId(),
|
|
35
|
-
target,
|
|
36
|
-
operationType: operationType,
|
|
37
|
-
objectives,
|
|
38
|
-
riskAssessment: this.assessRisks(target, operationType),
|
|
39
|
-
authorization: this.determineAuthorization(target, operationType),
|
|
40
|
-
constraints: this.determineConstraints(target, operationType)
|
|
41
|
-
};
|
|
42
|
-
this.activeOperations.set(operation.id, operation);
|
|
43
|
-
return operation;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Execute a strategic operation
|
|
47
|
-
*/
|
|
48
|
-
async executeOperation(operationId, parameters) {
|
|
49
|
-
const operation = this.activeOperations.get(operationId);
|
|
50
|
-
if (!operation) {
|
|
51
|
-
throw new Error(`Operation ${operationId} not found`);
|
|
52
|
-
}
|
|
53
|
-
// Validate operation with global security
|
|
54
|
-
const validation = globalSecurityIntegration.validateGlobalOperation(this.getToolForOperation(operation.operationType), parameters, {
|
|
55
|
-
type: 'external',
|
|
56
|
-
target: operation.target.identifier,
|
|
57
|
-
operation: operation.operationType
|
|
58
|
-
});
|
|
59
|
-
if (!validation.allowed) {
|
|
60
|
-
throw new Error(`Operation validation failed: ${validation.reason}`);
|
|
61
|
-
}
|
|
62
|
-
// Log strategic operation
|
|
63
|
-
this.logStrategicOperation(operation, 'execution_started', parameters);
|
|
64
|
-
// Execute the operation (simulated - actual tool execution handled by tool runtime)
|
|
65
|
-
try {
|
|
66
|
-
const toolName = this.getToolForOperation(operation.operationType);
|
|
67
|
-
const result = {
|
|
68
|
-
operationId: operation.id,
|
|
69
|
-
toolName,
|
|
70
|
-
parameters,
|
|
71
|
-
status: 'completed',
|
|
72
|
-
timestamp: new Date().toISOString()
|
|
73
|
-
};
|
|
74
|
-
this.logStrategicOperation(operation, 'execution_completed', { result });
|
|
75
|
-
return result;
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
this.logStrategicOperation(operation, 'execution_failed', { error: error instanceof Error ? error.message : String(error) });
|
|
79
|
-
throw error;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Get strategic entities by type
|
|
84
|
-
*/
|
|
85
|
-
getStrategicEntitiesByType(type) {
|
|
86
|
-
return this.comprehensiveTargeting.getEntitiesByType(type);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Get strategic entities by level
|
|
90
|
-
*/
|
|
91
|
-
getStrategicEntitiesByLevel(level) {
|
|
92
|
-
return this.comprehensiveTargeting.getEntitiesByStrategicLevel(level);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Get all strategic entities
|
|
96
|
-
*/
|
|
97
|
-
getAllStrategicEntities() {
|
|
98
|
-
return this.comprehensiveTargeting.getAllStrategicEntities();
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Generate strategic operations report
|
|
102
|
-
*/
|
|
103
|
-
generateStrategicReport() {
|
|
104
|
-
const entities = this.getAllStrategicEntities();
|
|
105
|
-
const activeOps = Array.from(this.activeOperations.values());
|
|
106
|
-
const report = [
|
|
107
|
-
'🎯 Strategic Operations Report',
|
|
108
|
-
'==============================',
|
|
109
|
-
`Total Strategic Entities: ${entities.length}`,
|
|
110
|
-
`Active Operations: ${activeOps.length}`,
|
|
111
|
-
'',
|
|
112
|
-
'🏢 Technology Companies:',
|
|
113
|
-
...this.getStrategicEntitiesByType('company').map(entity => ` • ${entity.identifier} [${entity.strategicLevel}] - ${entity.geopolitical.jurisdiction}`),
|
|
114
|
-
'',
|
|
115
|
-
'🌍 Countries:',
|
|
116
|
-
...this.getStrategicEntitiesByType('country').map(entity => ` • ${entity.identifier} [${entity.strategicLevel}] - ${entity.geopolitical.alliances.join(', ')}`),
|
|
117
|
-
'',
|
|
118
|
-
'🤝 Strategic Alliances:',
|
|
119
|
-
...this.getStrategicEntitiesByType('alliance').map(entity => ` • ${entity.identifier} [${entity.strategicLevel}]`),
|
|
120
|
-
'',
|
|
121
|
-
'⚡ Critical Infrastructure:',
|
|
122
|
-
' • Global Power Grid [critical]',
|
|
123
|
-
' • Global Financial System [critical]',
|
|
124
|
-
' • Global Communications [critical]',
|
|
125
|
-
' • Global Transportation [high]',
|
|
126
|
-
' • Global Healthcare [high]',
|
|
127
|
-
'',
|
|
128
|
-
'📊 Strategic Distribution:',
|
|
129
|
-
` Critical: ${this.getStrategicEntitiesByLevel('critical').length}`,
|
|
130
|
-
` High: ${this.getStrategicEntitiesByLevel('high').length}`,
|
|
131
|
-
` Medium: ${this.getStrategicEntitiesByLevel('medium').length}`,
|
|
132
|
-
` Low: ${this.getStrategicEntitiesByLevel('low').length}`,
|
|
133
|
-
'',
|
|
134
|
-
'🔐 Security Classifications:',
|
|
135
|
-
` Public: ${entities.filter(e => e.securityClassification === 'public').length}`,
|
|
136
|
-
` Restricted: ${entities.filter(e => e.securityClassification === 'restricted').length}`,
|
|
137
|
-
` Confidential: ${entities.filter(e => e.securityClassification === 'confidential').length}`,
|
|
138
|
-
` Secret: ${entities.filter(e => e.securityClassification === 'secret').length}`
|
|
139
|
-
];
|
|
140
|
-
if (activeOps.length > 0) {
|
|
141
|
-
report.push('', '🚀 Active Operations:');
|
|
142
|
-
activeOps.forEach(op => {
|
|
143
|
-
report.push(` • ${op.id}: ${op.operationType} on ${op.target.identifier} [${op.riskAssessment.overallRisk} risk]`);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return report.join('\n');
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Assess risks for an operation
|
|
150
|
-
*/
|
|
151
|
-
assessRisks(target, _operationType) {
|
|
152
|
-
// Simplified risk assessment - in practice this would be more sophisticated
|
|
153
|
-
let geopoliticalRisk = 'low';
|
|
154
|
-
let operationalRisk = 'low';
|
|
155
|
-
let legalRisk = 'low';
|
|
156
|
-
// Geopolitical risk based on alliances and sanctions
|
|
157
|
-
if (target.geopolitical.sanctions.length > 0) {
|
|
158
|
-
geopoliticalRisk = 'high';
|
|
159
|
-
}
|
|
160
|
-
else if (target.geopolitical.alliances.includes('NATO') || target.geopolitical.alliances.includes('Five Eyes')) {
|
|
161
|
-
geopoliticalRisk = 'medium';
|
|
162
|
-
}
|
|
163
|
-
// Operational risk based on strategic level
|
|
164
|
-
if (target.strategicLevel === 'critical') {
|
|
165
|
-
operationalRisk = 'high';
|
|
166
|
-
}
|
|
167
|
-
else if (target.strategicLevel === 'high') {
|
|
168
|
-
operationalRisk = 'medium';
|
|
169
|
-
}
|
|
170
|
-
// Legal risk based on security classification
|
|
171
|
-
if (target.securityClassification === 'secret') {
|
|
172
|
-
legalRisk = 'critical';
|
|
173
|
-
}
|
|
174
|
-
else if (target.securityClassification === 'confidential') {
|
|
175
|
-
legalRisk = 'high';
|
|
176
|
-
}
|
|
177
|
-
else if (target.securityClassification === 'restricted') {
|
|
178
|
-
legalRisk = 'medium';
|
|
179
|
-
}
|
|
180
|
-
// Overall risk is the highest of the three
|
|
181
|
-
const overallRisk = [geopoliticalRisk, operationalRisk, legalRisk].reduce((highest, current) => {
|
|
182
|
-
const riskLevels = { low: 0, medium: 1, high: 2, critical: 3 };
|
|
183
|
-
return riskLevels[current] > riskLevels[highest] ? current : highest;
|
|
184
|
-
}, 'low');
|
|
185
|
-
return {
|
|
186
|
-
geopoliticalRisk,
|
|
187
|
-
operationalRisk,
|
|
188
|
-
legalRisk,
|
|
189
|
-
overallRisk
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Determine authorization requirements
|
|
194
|
-
*/
|
|
195
|
-
determineAuthorization(target, _operationType) {
|
|
196
|
-
const level = target.strategicLevel === 'critical' ? 'analysis' : 'research';
|
|
197
|
-
const approvals = ['security_team'];
|
|
198
|
-
let legalReview = false;
|
|
199
|
-
let seniorLeadership = false;
|
|
200
|
-
if (target.strategicLevel === 'critical') {
|
|
201
|
-
approvals.push('director_level');
|
|
202
|
-
legalReview = true;
|
|
203
|
-
}
|
|
204
|
-
if (target.securityClassification === 'secret' || target.securityClassification === 'confidential') {
|
|
205
|
-
approvals.push('legal_department');
|
|
206
|
-
legalReview = true;
|
|
207
|
-
}
|
|
208
|
-
if (target.strategicLevel === 'critical' && target.securityClassification === 'secret') {
|
|
209
|
-
seniorLeadership = true;
|
|
210
|
-
approvals.push('senior_leadership');
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
level,
|
|
214
|
-
approvals,
|
|
215
|
-
legalReview,
|
|
216
|
-
seniorLeadership
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Determine operational constraints
|
|
221
|
-
*/
|
|
222
|
-
determineConstraints(target, _operationType) {
|
|
223
|
-
const constraints = {
|
|
224
|
-
legalRestrictions: ['responsible_disclosure']
|
|
225
|
-
};
|
|
226
|
-
if (target.strategicLevel === 'critical') {
|
|
227
|
-
constraints.timeWindow = 'business_hours_only';
|
|
228
|
-
constraints.resourceLimits = ['monitored_execution', 'limited_scope'];
|
|
229
|
-
}
|
|
230
|
-
if (target.securityClassification === 'secret') {
|
|
231
|
-
constraints.legalRestrictions.push('classified_handling', 'need_to_know_basis');
|
|
232
|
-
constraints.ethicalConsiderations = ['national_security_implications'];
|
|
233
|
-
}
|
|
234
|
-
if (target.geopolitical.sanctions.length > 0) {
|
|
235
|
-
constraints.legalRestrictions.push('sanctions_compliance');
|
|
236
|
-
}
|
|
237
|
-
return constraints;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Get appropriate tool for operation type
|
|
241
|
-
*/
|
|
242
|
-
getToolForOperation(operationType) {
|
|
243
|
-
const toolMap = {
|
|
244
|
-
'security_analysis': 'WebFetch',
|
|
245
|
-
'vulnerability_assessment': 'WebSearch',
|
|
246
|
-
'threat_intelligence': 'WebSearch',
|
|
247
|
-
'defensive_research': 'WebFetch',
|
|
248
|
-
'compliance_audit': 'WebFetch'
|
|
249
|
-
};
|
|
250
|
-
return toolMap[operationType] || 'WebSearch';
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Generate unique operation ID
|
|
254
|
-
*/
|
|
255
|
-
generateOperationId() {
|
|
256
|
-
return `STRAT-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Log strategic operation
|
|
260
|
-
*/
|
|
261
|
-
logStrategicOperation(operation, status, details) {
|
|
262
|
-
console.log(`🎯 Strategic Operation ${operation.id}: ${status}`);
|
|
263
|
-
console.log(` Target: ${operation.target.identifier}`);
|
|
264
|
-
console.log(` Type: ${operation.operationType}`);
|
|
265
|
-
console.log(` Risk: ${operation.riskAssessment.overallRisk}`);
|
|
266
|
-
if (Object.keys(details).length > 0) {
|
|
267
|
-
console.log(` Details: ${JSON.stringify(details)}`);
|
|
268
|
-
}
|
|
269
|
-
console.log('');
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Global strategic operations instance
|
|
274
|
-
*/
|
|
275
|
-
export const strategicOperations = new StrategicOperations();
|
|
276
|
-
//# sourceMappingURL=strategic-operations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strategic-operations.js","sourceRoot":"","sources":["../../src/security/strategic-operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAwB,MAAM,8BAA8B,CAAC;AAkC5F,MAAM,OAAO,mBAAmB;IACtB,sBAAsB,CAAyB;IAC/C,gBAAgB,GAAoC,IAAI,GAAG,EAAE,CAAC;IAEtE;QACE,IAAI,CAAC,sBAAsB,GAAG,IAAI,sBAAsB,EAAE,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,gBAAwB,EAAE,aAA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,qBAAqB,CAAC,SAA6B,EAAE,MAAc,EAAE,OAAgC;QAC3G,OAAO,CAAC,GAAG,CAAC,0BAA0B,SAAS,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;QACjE,OAAO,CAAC,GAAG,CAAC,cAAc,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,YAAY,SAAS,CAAC,aAAa,EAAE,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,YAAY,SAAS,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,CAAC;QAChE,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool Security Wrapper
|
|
3
|
-
*
|
|
4
|
-
* Wraps tool execution with active stack security validation.
|
|
5
|
-
* Ensures all operations are scoped to the active stack only.
|
|
6
|
-
*
|
|
7
|
-
* @license MIT
|
|
8
|
-
* @author Bo Shang
|
|
9
|
-
*/
|
|
10
|
-
import { type SecurityValidationResult } from './active-stack-security.js';
|
|
11
|
-
export declare class ToolSecurityWrapper {
|
|
12
|
-
constructor();
|
|
13
|
-
/**
|
|
14
|
-
* Execute a tool with security validation
|
|
15
|
-
*/
|
|
16
|
-
executeTool(toolName: string, args: Record<string, unknown>): Promise<unknown>;
|
|
17
|
-
/**
|
|
18
|
-
* Validate tool operation based on tool type and arguments
|
|
19
|
-
*/
|
|
20
|
-
private validateToolOperation;
|
|
21
|
-
/**
|
|
22
|
-
* Validate file operations
|
|
23
|
-
*/
|
|
24
|
-
private validateFileOperation;
|
|
25
|
-
/**
|
|
26
|
-
* Validate command execution
|
|
27
|
-
*/
|
|
28
|
-
private validateCommandExecution;
|
|
29
|
-
/**
|
|
30
|
-
* Validate network operations
|
|
31
|
-
*/
|
|
32
|
-
private validateNetworkOperation;
|
|
33
|
-
/**
|
|
34
|
-
* Validate generic operations
|
|
35
|
-
*/
|
|
36
|
-
private validateGenericOperation;
|
|
37
|
-
/**
|
|
38
|
-
* Get security log
|
|
39
|
-
*/
|
|
40
|
-
getSecurityLog(): import("./active-stack-security.js").SecurityEvent[];
|
|
41
|
-
/**
|
|
42
|
-
* Clear security log
|
|
43
|
-
*/
|
|
44
|
-
clearSecurityLog(): void;
|
|
45
|
-
/**
|
|
46
|
-
* Internal tool execution (placeholder implementation)
|
|
47
|
-
*/
|
|
48
|
-
private executeToolInternal;
|
|
49
|
-
}
|
|
50
|
-
export declare class SecurityError extends Error {
|
|
51
|
-
readonly validationResult: SecurityValidationResult;
|
|
52
|
-
constructor(message: string, validationResult: SecurityValidationResult);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Create a secure tool runtime wrapper
|
|
56
|
-
*/
|
|
57
|
-
export declare function createSecureToolRuntime(): ToolSecurityWrapper;
|
|
58
|
-
//# sourceMappingURL=tool-security-wrapper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-security-wrapper.d.ts","sourceRoot":"","sources":["../../src/security/tool-security-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAuB,KAAK,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEhG,qBAAa,mBAAmB;;IAK9B;;OAEG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAapF;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAuB7B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAc7B;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAahC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAqBhC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAmBhC;;OAEG;IACH,cAAc;IAId;;OAEG;IACH,gBAAgB;IAIhB;;OAEG;YACW,mBAAmB;CAKlC;AAED,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAgB,gBAAgB,EAAE,wBAAwB,CAAC;gBAE/C,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,wBAAwB;CAKxE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,mBAAmB,CAE7D"}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool Security Wrapper
|
|
3
|
-
*
|
|
4
|
-
* Wraps tool execution with active stack security validation.
|
|
5
|
-
* Ensures all operations are scoped to the active stack only.
|
|
6
|
-
*
|
|
7
|
-
* @license MIT
|
|
8
|
-
* @author Bo Shang
|
|
9
|
-
*/
|
|
10
|
-
import { activeStackSecurity } from './active-stack-security.js';
|
|
11
|
-
export class ToolSecurityWrapper {
|
|
12
|
-
constructor() {
|
|
13
|
-
// Tool runtime would be initialized here in a real implementation
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Execute a tool with security validation
|
|
17
|
-
*/
|
|
18
|
-
async executeTool(toolName, args) {
|
|
19
|
-
// Validate the tool operation based on tool type
|
|
20
|
-
const validation = this.validateToolOperation(toolName, args);
|
|
21
|
-
if (!validation.allowed) {
|
|
22
|
-
throw new SecurityError(`Tool execution blocked: ${validation.reason}`, validation);
|
|
23
|
-
}
|
|
24
|
-
// Execute the actual tool
|
|
25
|
-
// Note: This would need to be adapted to the actual ToolRuntime interface
|
|
26
|
-
// For now, we'll assume a simplified interface
|
|
27
|
-
return await this.executeToolInternal(toolName, args);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Validate tool operation based on tool type and arguments
|
|
31
|
-
*/
|
|
32
|
-
validateToolOperation(toolName, args) {
|
|
33
|
-
switch (toolName) {
|
|
34
|
-
case 'read_file':
|
|
35
|
-
case 'Edit':
|
|
36
|
-
case 'list_files':
|
|
37
|
-
case 'search_files':
|
|
38
|
-
return this.validateFileOperation(toolName, args);
|
|
39
|
-
case 'execute_bash':
|
|
40
|
-
case 'execute_bash_stream':
|
|
41
|
-
return this.validateCommandExecution(args);
|
|
42
|
-
case 'WebFetch':
|
|
43
|
-
case 'WebExtract':
|
|
44
|
-
case 'WebSearch':
|
|
45
|
-
return this.validateNetworkOperation(toolName, args);
|
|
46
|
-
default:
|
|
47
|
-
// For unknown tools, apply general security validation
|
|
48
|
-
return this.validateGenericOperation(args);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Validate file operations
|
|
53
|
-
*/
|
|
54
|
-
validateFileOperation(toolName, args) {
|
|
55
|
-
const path = (args['path'] || args['file_path']);
|
|
56
|
-
if (!path) {
|
|
57
|
-
return {
|
|
58
|
-
allowed: false,
|
|
59
|
-
reason: 'Missing file path',
|
|
60
|
-
severity: 'medium',
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
const operation = toolName === 'Edit' ? 'write' : 'read';
|
|
64
|
-
return activeStackSecurity.validateFileOperation(path, operation);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Validate command execution
|
|
68
|
-
*/
|
|
69
|
-
validateCommandExecution(args) {
|
|
70
|
-
const command = args['command'];
|
|
71
|
-
if (!command) {
|
|
72
|
-
return {
|
|
73
|
-
allowed: false,
|
|
74
|
-
reason: 'Missing command',
|
|
75
|
-
severity: 'medium',
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return activeStackSecurity.validateCommandExecution(command);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Validate network operations
|
|
82
|
-
*/
|
|
83
|
-
validateNetworkOperation(toolName, args) {
|
|
84
|
-
let target;
|
|
85
|
-
if (toolName === 'WebFetch' || toolName === 'WebExtract') {
|
|
86
|
-
target = args['url'];
|
|
87
|
-
}
|
|
88
|
-
else if (toolName === 'WebSearch') {
|
|
89
|
-
target = args['query'];
|
|
90
|
-
}
|
|
91
|
-
if (!target) {
|
|
92
|
-
return {
|
|
93
|
-
allowed: false,
|
|
94
|
-
reason: 'Missing target/query',
|
|
95
|
-
severity: 'medium',
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
const operation = toolName.toLowerCase().replace('web', '');
|
|
99
|
-
return activeStackSecurity.validateNetworkOperation(target, operation);
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Validate generic operations
|
|
103
|
-
*/
|
|
104
|
-
validateGenericOperation(args) {
|
|
105
|
-
// Check for any file paths in arguments
|
|
106
|
-
for (const [key, value] of Object.entries(args)) {
|
|
107
|
-
if (typeof value === 'string' && value.includes('/')) {
|
|
108
|
-
const pathValidation = activeStackSecurity.validateFileOperation(value, 'read');
|
|
109
|
-
if (!pathValidation.allowed) {
|
|
110
|
-
return {
|
|
111
|
-
allowed: false,
|
|
112
|
-
reason: `Invalid file path in argument '${key}': ${pathValidation.reason}`,
|
|
113
|
-
severity: pathValidation.severity,
|
|
114
|
-
details: pathValidation.details,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return { allowed: true, severity: 'low' };
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Get security log
|
|
123
|
-
*/
|
|
124
|
-
getSecurityLog() {
|
|
125
|
-
return activeStackSecurity.getSecurityLog();
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Clear security log
|
|
129
|
-
*/
|
|
130
|
-
clearSecurityLog() {
|
|
131
|
-
activeStackSecurity.clearSecurityLog();
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Internal tool execution (placeholder implementation)
|
|
135
|
-
*/
|
|
136
|
-
async executeToolInternal(toolName, args) {
|
|
137
|
-
// This would call the actual ToolRuntime method
|
|
138
|
-
// For demonstration purposes, we return a mock result
|
|
139
|
-
return { success: true, tool: toolName, args };
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
export class SecurityError extends Error {
|
|
143
|
-
validationResult;
|
|
144
|
-
constructor(message, validationResult) {
|
|
145
|
-
super(message);
|
|
146
|
-
this.name = 'SecurityError';
|
|
147
|
-
this.validationResult = validationResult;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Create a secure tool runtime wrapper
|
|
152
|
-
*/
|
|
153
|
-
export function createSecureToolRuntime() {
|
|
154
|
-
return new ToolSecurityWrapper();
|
|
155
|
-
}
|
|
156
|
-
//# sourceMappingURL=tool-security-wrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-security-wrapper.js","sourceRoot":"","sources":["../../src/security/tool-security-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAiC,MAAM,4BAA4B,CAAC;AAEhG,MAAM,OAAO,mBAAmB;IAC9B;QACE,kEAAkE;IACpE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW,CAAC,QAAgB,EAAE,IAA6B;QAC/D,iDAAiD;QACjD,MAAM,UAAU,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC9D,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxB,MAAM,IAAI,aAAa,CAAC,2BAA2B,UAAU,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC;QACtF,CAAC;QAED,0BAA0B;QAC1B,0EAA0E;QAC1E,+CAA+C;QAC/C,OAAO,MAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IAED;;O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AAkC,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE;wBAC1E,QAAQ,EAAE,cAAc,CAAC,QAAQ;wBACjC,OAAO,EAAE,cAAc,CAAC,OAAO;qBAChC,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,mBAAmB,CAAC,cAAc,EAAE,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;IACzC,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,mBAAmB,CAAC,QAAgB,EAAE,IAA6B;QAC/E,gDAAgD;QAChD,sDAAsD;QACtD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjD,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtB,gBAAgB,CAA2B;IAE3D,YAAY,OAAe,EAAE,gBAA0C;QACrE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,IAAI,mBAAmB,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ClaudeCodeStreamHandler - Complete streaming I/O handler following Claude Code's approach
|
|
3
|
-
*
|
|
4
|
-
* This module combines StreamingOutputManager and InputQueueManager to provide
|
|
5
|
-
* the complete Claude Code streaming experience:
|
|
6
|
-
*
|
|
7
|
-
* 1. Natural Output Flow
|
|
8
|
-
* - Streaming output just writes to stdout normally
|
|
9
|
-
* - Cursor stays where it is after each write
|
|
10
|
-
* - Lines scroll up naturally as new content appears
|
|
11
|
-
* - NO scroll regions, NO save/restore cursor during streaming
|
|
12
|
-
*
|
|
13
|
-
* 2. Readline Handles Input
|
|
14
|
-
* - Uses Node.js readline module
|
|
15
|
-
* - Input prompt naturally moves up as output streams above it
|
|
16
|
-
* - User can type while streaming - input is queued in memory, not rendered
|
|
17
|
-
*
|
|
18
|
-
* 3. Queue-Based Approach
|
|
19
|
-
* User types during streaming → Input stored in queue → Processed after streaming ends
|
|
20
|
-
*
|
|
21
|
-
* 4. The Key Insight
|
|
22
|
-
* The cursor is NEVER moved during streaming. Output just appends at current position.
|
|
23
|
-
* The "input at bottom" effect comes from:
|
|
24
|
-
* - New output pushes older content (including the prompt) upward
|
|
25
|
-
* - After streaming ends, a new prompt is shown at the bottom
|
|
26
|
-
*/
|
|
27
|
-
import * as readline from 'node:readline';
|
|
28
|
-
import { EventEmitter } from 'node:events';
|
|
29
|
-
import { type QueuedInput } from './inputQueueManager.js';
|
|
30
|
-
export interface ClaudeCodeStreamState {
|
|
31
|
-
isStreaming: boolean;
|
|
32
|
-
queuedCount: number;
|
|
33
|
-
charsWritten: number;
|
|
34
|
-
linesWritten: number;
|
|
35
|
-
elapsedMs: number;
|
|
36
|
-
}
|
|
37
|
-
export interface ClaudeCodeStreamEvents {
|
|
38
|
-
'streaming-start': () => void;
|
|
39
|
-
'streaming-end': (stats: {
|
|
40
|
-
duration: number;
|
|
41
|
-
chars: number;
|
|
42
|
-
lines: number;
|
|
43
|
-
}) => void;
|
|
44
|
-
'input-queued': (input: QueuedInput) => void;
|
|
45
|
-
'queue-processed': (input: QueuedInput) => void;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Coordinates streaming output and queued input for Claude Code style UX.
|
|
49
|
-
*/
|
|
50
|
-
export declare class ClaudeCodeStreamHandler extends EventEmitter {
|
|
51
|
-
private readonly outputManager;
|
|
52
|
-
private readonly inputManager;
|
|
53
|
-
private readonly writeStream;
|
|
54
|
-
private readonly readStream;
|
|
55
|
-
private rl;
|
|
56
|
-
private keypressHandler;
|
|
57
|
-
private originalStdoutWrite;
|
|
58
|
-
private isOutputSuppressed;
|
|
59
|
-
constructor(writeStream?: NodeJS.WriteStream, readStream?: NodeJS.ReadStream);
|
|
60
|
-
/**
|
|
61
|
-
* Attach to an existing readline interface
|
|
62
|
-
* Call this after creating your readline.Interface
|
|
63
|
-
*/
|
|
64
|
-
attachToReadline(rl: readline.Interface): void;
|
|
65
|
-
/**
|
|
66
|
-
* Set up keypress capturing for queued input during streaming
|
|
67
|
-
*/
|
|
68
|
-
private setupKeypressCapture;
|
|
69
|
-
/**
|
|
70
|
-
* Begin streaming mode
|
|
71
|
-
*
|
|
72
|
-
* Claude Code approach:
|
|
73
|
-
* - Start capturing input to queue
|
|
74
|
-
* - Suppress readline echo (characters typed go to queue, not screen)
|
|
75
|
-
* - Output flows naturally to stdout
|
|
76
|
-
*/
|
|
77
|
-
startStreaming(): void;
|
|
78
|
-
/**
|
|
79
|
-
* End streaming mode
|
|
80
|
-
*
|
|
81
|
-
* Claude Code approach:
|
|
82
|
-
* - Stop capturing (any remaining buffer is preserved)
|
|
83
|
-
* - Restore readline echo
|
|
84
|
-
* - Return streaming statistics
|
|
85
|
-
*/
|
|
86
|
-
endStreaming(): {
|
|
87
|
-
duration: number;
|
|
88
|
-
chars: number;
|
|
89
|
-
lines: number;
|
|
90
|
-
queuedInputs: number;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Write content during streaming
|
|
94
|
-
* Just writes naturally to stdout - no cursor manipulation
|
|
95
|
-
*/
|
|
96
|
-
write(content: string): void;
|
|
97
|
-
/**
|
|
98
|
-
* Write a complete line during streaming
|
|
99
|
-
*/
|
|
100
|
-
writeLine(line?: string): void;
|
|
101
|
-
/**
|
|
102
|
-
* Check if currently streaming
|
|
103
|
-
*/
|
|
104
|
-
isStreaming(): boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Get current state
|
|
107
|
-
*/
|
|
108
|
-
getState(): ClaudeCodeStreamState;
|
|
109
|
-
/**
|
|
110
|
-
* Check if there are queued inputs to process
|
|
111
|
-
*/
|
|
112
|
-
hasQueuedInput(): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Get the next queued input
|
|
115
|
-
*/
|
|
116
|
-
getNextQueuedInput(): QueuedInput | undefined;
|
|
117
|
-
/**
|
|
118
|
-
* Get all queued inputs
|
|
119
|
-
*/
|
|
120
|
-
getAllQueuedInputs(): QueuedInput[];
|
|
121
|
-
/**
|
|
122
|
-
* Clear all queued inputs
|
|
123
|
-
*/
|
|
124
|
-
clearQueue(): void;
|
|
125
|
-
/**
|
|
126
|
-
* Get queue summary for display
|
|
127
|
-
*/
|
|
128
|
-
getQueueSummary(): string;
|
|
129
|
-
/**
|
|
130
|
-
* Suppress readline's output during streaming
|
|
131
|
-
* Characters typed will be captured but not displayed
|
|
132
|
-
*/
|
|
133
|
-
private suppressReadlineOutput;
|
|
134
|
-
/**
|
|
135
|
-
* Restore readline's normal output
|
|
136
|
-
*/
|
|
137
|
-
private restoreReadlineOutput;
|
|
138
|
-
/**
|
|
139
|
-
* Cleanup when done
|
|
140
|
-
*/
|
|
141
|
-
dispose(): void;
|
|
142
|
-
}
|
|
143
|
-
export declare function getClaudeCodeStreamHandler(): ClaudeCodeStreamHandler;
|
|
144
|
-
export declare function resetClaudeCodeStreamHandler(): void;
|
|
145
|
-
//# sourceMappingURL=claudeCodeStreamHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"claudeCodeStreamHandler.d.ts","sourceRoot":"","sources":["../../src/shell/claudeCodeStreamHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAA2C,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGn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