erosolar-cli 1.7.13 → 1.7.15
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/core/responseVerifier.d.ts +79 -0
- package/dist/core/responseVerifier.d.ts.map +1 -0
- package/dist/core/responseVerifier.js +443 -0
- package/dist/core/responseVerifier.js.map +1 -0
- package/dist/shell/interactiveShell.d.ts +5 -0
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +45 -14
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/ui/ShellUIAdapter.d.ts +3 -0
- package/dist/ui/ShellUIAdapter.d.ts.map +1 -1
- package/dist/ui/ShellUIAdapter.js +4 -10
- package/dist/ui/ShellUIAdapter.js.map +1 -1
- package/dist/ui/display.d.ts +15 -0
- package/dist/ui/display.d.ts.map +1 -1
- package/dist/ui/display.js +57 -0
- package/dist/ui/display.js.map +1 -1
- package/dist/ui/persistentPrompt.d.ts +4 -0
- package/dist/ui/persistentPrompt.d.ts.map +1 -1
- package/dist/ui/persistentPrompt.js +10 -11
- package/dist/ui/persistentPrompt.js.map +1 -1
- package/package.json +1 -1
- package/dist/bin/core/agent.js +0 -362
- package/dist/bin/core/agentProfileManifest.js +0 -187
- package/dist/bin/core/agentProfiles.js +0 -34
- package/dist/bin/core/agentRulebook.js +0 -135
- package/dist/bin/core/agentSchemaLoader.js +0 -233
- package/dist/bin/core/contextManager.js +0 -412
- package/dist/bin/core/contextWindow.js +0 -122
- package/dist/bin/core/customCommands.js +0 -80
- package/dist/bin/core/errors/apiKeyErrors.js +0 -114
- package/dist/bin/core/errors/errorTypes.js +0 -340
- package/dist/bin/core/errors/safetyValidator.js +0 -304
- package/dist/bin/core/errors.js +0 -32
- package/dist/bin/core/modelDiscovery.js +0 -755
- package/dist/bin/core/preferences.js +0 -224
- package/dist/bin/core/schemaValidator.js +0 -92
- package/dist/bin/core/secretStore.js +0 -199
- package/dist/bin/core/sessionStore.js +0 -187
- package/dist/bin/core/toolRuntime.js +0 -290
- package/dist/bin/core/types.js +0 -1
- package/dist/bin/shell/bracketedPasteManager.js +0 -350
- package/dist/bin/shell/fileChangeTracker.js +0 -65
- package/dist/bin/shell/interactiveShell.js +0 -2908
- package/dist/bin/shell/liveStatus.js +0 -78
- package/dist/bin/shell/shellApp.js +0 -290
- package/dist/bin/shell/systemPrompt.js +0 -60
- package/dist/bin/shell/updateManager.js +0 -108
- package/dist/bin/ui/ShellUIAdapter.js +0 -459
- package/dist/bin/ui/UnifiedUIController.js +0 -183
- package/dist/bin/ui/animation/AnimationScheduler.js +0 -430
- package/dist/bin/ui/codeHighlighter.js +0 -854
- package/dist/bin/ui/designSystem.js +0 -121
- package/dist/bin/ui/display.js +0 -1222
- package/dist/bin/ui/interrupts/InterruptManager.js +0 -437
- package/dist/bin/ui/layout.js +0 -139
- package/dist/bin/ui/orchestration/StatusOrchestrator.js +0 -403
- package/dist/bin/ui/outputMode.js +0 -38
- package/dist/bin/ui/persistentPrompt.js +0 -183
- package/dist/bin/ui/richText.js +0 -338
- package/dist/bin/ui/shortcutsHelp.js +0 -87
- package/dist/bin/ui/telemetry/UITelemetry.js +0 -443
- package/dist/bin/ui/textHighlighter.js +0 -210
- package/dist/bin/ui/theme.js +0 -116
- package/dist/bin/ui/toolDisplay.js +0 -423
- package/dist/bin/ui/toolDisplayAdapter.js +0 -357
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Safety Validator - Enhanced validation with auto-fixing
|
|
3
|
-
*
|
|
4
|
-
* Validates operations for safety, provides suggestions, and attempts auto-fixing
|
|
5
|
-
*/
|
|
6
|
-
import { DangerousOperationError, BlockedOperationError, ResourceLimitError, ValidationError, } from './errorTypes.js';
|
|
7
|
-
const DANGEROUS_PATTERNS = [
|
|
8
|
-
// Critical - system destruction
|
|
9
|
-
{
|
|
10
|
-
pattern: /rm\s+-rf\s+\/($|\s)/,
|
|
11
|
-
reason: 'Attempts to delete entire root filesystem',
|
|
12
|
-
severity: 'critical',
|
|
13
|
-
safeAlternative: 'rm -rf ./specific-directory',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
pattern: /:\(\)\s*\{[^}]*\}\s*;\s*:/,
|
|
17
|
-
reason: 'Fork bomb that crashes system',
|
|
18
|
-
severity: 'critical',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
pattern: /mkfs\./,
|
|
22
|
-
reason: 'Formats filesystem, destroying all data',
|
|
23
|
-
severity: 'critical',
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
pattern: /dd\s+.*of=\/dev\/(sd|hd|nvme)/,
|
|
27
|
-
reason: 'Writes directly to disk, can destroy data',
|
|
28
|
-
severity: 'critical',
|
|
29
|
-
},
|
|
30
|
-
// High - data loss
|
|
31
|
-
{
|
|
32
|
-
pattern: /rm\s+-rf\s+(\/(?!\s)|~\/)/,
|
|
33
|
-
reason: 'Removes files recursively without confirmation',
|
|
34
|
-
severity: 'high',
|
|
35
|
-
safeAlternative: 'rm -ri ./directory (interactive)',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
pattern: />\s*\/dev\/(sd|hd|nvme)/,
|
|
39
|
-
reason: 'Redirects output to disk device',
|
|
40
|
-
severity: 'high',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
pattern: /shred\s+-[a-z]*n/,
|
|
44
|
-
reason: 'Securely deletes files, unrecoverable',
|
|
45
|
-
severity: 'high',
|
|
46
|
-
},
|
|
47
|
-
// Medium - risky operations
|
|
48
|
-
{
|
|
49
|
-
pattern: /chmod\s+-R\s+777/,
|
|
50
|
-
reason: 'Makes all files world-writable (security risk)',
|
|
51
|
-
severity: 'medium',
|
|
52
|
-
safeAlternative: 'chmod -R 755 ./directory',
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
pattern: /curl.*\|\s*sh/,
|
|
56
|
-
reason: 'Pipes remote script to shell (security risk)',
|
|
57
|
-
severity: 'medium',
|
|
58
|
-
safeAlternative: 'Download and inspect script first',
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
pattern: /wget.*\|\s*sh/,
|
|
62
|
-
reason: 'Pipes remote script to shell (security risk)',
|
|
63
|
-
severity: 'medium',
|
|
64
|
-
safeAlternative: 'Download and inspect script first',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
pattern: /eval\s+\$\(/,
|
|
68
|
-
reason: 'Executes arbitrary code (injection risk)',
|
|
69
|
-
severity: 'medium',
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
const BLOCKED_OPERATIONS = [
|
|
73
|
-
{
|
|
74
|
-
pattern: /npm\s+publish/,
|
|
75
|
-
policy: 'Publishing requires explicit user approval',
|
|
76
|
-
allowedAlternatives: ['npm publish --dry-run'],
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
pattern: /git\s+push\s+--force/,
|
|
80
|
-
policy: 'Force push can overwrite remote history',
|
|
81
|
-
allowedAlternatives: ['git push --force-with-lease'],
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
pattern: /docker\s+system\s+prune\s+-a/,
|
|
85
|
-
policy: 'Removes all unused Docker resources',
|
|
86
|
-
allowedAlternatives: ['docker system prune'],
|
|
87
|
-
},
|
|
88
|
-
];
|
|
89
|
-
/**
|
|
90
|
-
* Validate bash command for safety
|
|
91
|
-
*/
|
|
92
|
-
export function validateBashCommand(command) {
|
|
93
|
-
const warnings = [];
|
|
94
|
-
// Check for dangerous patterns (CRITICAL - must block)
|
|
95
|
-
for (const { pattern, reason, severity, safeAlternative } of DANGEROUS_PATTERNS) {
|
|
96
|
-
if (pattern.test(command)) {
|
|
97
|
-
if (severity === 'critical' || severity === 'high') {
|
|
98
|
-
const error = new DangerousOperationError(command, reason, safeAlternative);
|
|
99
|
-
return {
|
|
100
|
-
valid: false,
|
|
101
|
-
error,
|
|
102
|
-
warnings,
|
|
103
|
-
autoFix: safeAlternative ? {
|
|
104
|
-
available: true,
|
|
105
|
-
apply: () => safeAlternative,
|
|
106
|
-
description: `Replace with: ${safeAlternative}`,
|
|
107
|
-
} : undefined,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
// Medium severity - warn but allow
|
|
112
|
-
warnings.push(`Warning: ${reason}. Consider: ${safeAlternative || 'reviewing command'}`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// Check for blocked operations (ERROR - policy violation)
|
|
117
|
-
for (const { pattern, policy, allowedAlternatives } of BLOCKED_OPERATIONS) {
|
|
118
|
-
if (pattern.test(command)) {
|
|
119
|
-
const error = new BlockedOperationError(command, policy, allowedAlternatives);
|
|
120
|
-
return {
|
|
121
|
-
valid: false,
|
|
122
|
-
error,
|
|
123
|
-
warnings,
|
|
124
|
-
autoFix: allowedAlternatives && allowedAlternatives.length > 0 ? {
|
|
125
|
-
available: true,
|
|
126
|
-
apply: () => allowedAlternatives[0],
|
|
127
|
-
description: `Replace with: ${allowedAlternatives[0]}`,
|
|
128
|
-
} : undefined,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return { valid: true, warnings };
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Validate tool arguments with auto-fixing
|
|
136
|
-
*/
|
|
137
|
-
export function validateToolArgs(_toolName, args, constraints) {
|
|
138
|
-
const warnings = [];
|
|
139
|
-
for (const [field, value] of Object.entries(args)) {
|
|
140
|
-
const constraint = constraints[field];
|
|
141
|
-
if (!constraint)
|
|
142
|
-
continue;
|
|
143
|
-
// Type validation
|
|
144
|
-
if (typeof value !== constraint.type) {
|
|
145
|
-
const error = new ValidationError(field, value, `Must be ${constraint.type}`, `${field}: <${constraint.type} value>`);
|
|
146
|
-
return {
|
|
147
|
-
valid: false,
|
|
148
|
-
error,
|
|
149
|
-
warnings,
|
|
150
|
-
autoFix: {
|
|
151
|
-
available: true,
|
|
152
|
-
apply: () => convertType(value, constraint.type),
|
|
153
|
-
description: `Convert ${field} to ${constraint.type}`,
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
// Range validation (for numbers)
|
|
158
|
-
if (constraint.type === 'number' && typeof value === 'number') {
|
|
159
|
-
if (constraint.max !== undefined && value > constraint.max) {
|
|
160
|
-
const error = new ResourceLimitError(field, value, constraint.max);
|
|
161
|
-
const safeValue = Math.floor(constraint.max * 0.8);
|
|
162
|
-
return {
|
|
163
|
-
valid: false,
|
|
164
|
-
error,
|
|
165
|
-
warnings,
|
|
166
|
-
autoFix: {
|
|
167
|
-
available: true,
|
|
168
|
-
apply: () => safeValue,
|
|
169
|
-
description: `Reduce ${field} to ${safeValue}`,
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
if (constraint.min !== undefined && value < constraint.min) {
|
|
174
|
-
const error = new ValidationError(field, value, `Must be at least ${constraint.min}`, `${constraint.min}`);
|
|
175
|
-
return {
|
|
176
|
-
valid: false,
|
|
177
|
-
error,
|
|
178
|
-
warnings,
|
|
179
|
-
autoFix: {
|
|
180
|
-
available: true,
|
|
181
|
-
apply: () => constraint.min,
|
|
182
|
-
description: `Set ${field} to minimum value ${constraint.min}`,
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
// Warning thresholds (80% of max)
|
|
187
|
-
if (constraint.max !== undefined && value > constraint.max * 0.8) {
|
|
188
|
-
warnings.push(`${field} is ${value}, approaching maximum of ${constraint.max}`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return { valid: true, warnings };
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Helper: Convert value to target type
|
|
196
|
-
*/
|
|
197
|
-
function convertType(value, targetType) {
|
|
198
|
-
switch (targetType) {
|
|
199
|
-
case 'number':
|
|
200
|
-
return Number(value);
|
|
201
|
-
case 'string':
|
|
202
|
-
return String(value);
|
|
203
|
-
case 'boolean':
|
|
204
|
-
return Boolean(value);
|
|
205
|
-
default:
|
|
206
|
-
return value;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Smart fixer - attempts to automatically fix common issues
|
|
211
|
-
*/
|
|
212
|
-
export class SmartFixer {
|
|
213
|
-
/**
|
|
214
|
-
* Fix dangerous bash commands by replacing with safe alternatives
|
|
215
|
-
*/
|
|
216
|
-
static fixDangerousCommand(command) {
|
|
217
|
-
let fixed = command;
|
|
218
|
-
const changes = [];
|
|
219
|
-
// Fix rm -rf / → rm -rf ./
|
|
220
|
-
if (/rm\s+-rf\s+\/($|\s)/.test(fixed)) {
|
|
221
|
-
fixed = fixed.replace(/rm\s+-rf\s+\/($|\s)/, 'rm -rf ./');
|
|
222
|
-
changes.push('Changed "rm -rf /" to "rm -rf ./"');
|
|
223
|
-
}
|
|
224
|
-
// Fix chmod 777 → chmod 755
|
|
225
|
-
if (/chmod\s+-R\s+777/.test(fixed)) {
|
|
226
|
-
fixed = fixed.replace(/chmod\s+-R\s+777/g, 'chmod -R 755');
|
|
227
|
-
changes.push('Changed "chmod -R 777" to "chmod -R 755"');
|
|
228
|
-
}
|
|
229
|
-
// Fix git push --force → git push --force-with-lease
|
|
230
|
-
if (/git\s+push\s+--force($|\s)/.test(fixed)) {
|
|
231
|
-
fixed = fixed.replace(/git\s+push\s+--force($|\s)/g, 'git push --force-with-lease ');
|
|
232
|
-
changes.push('Changed "git push --force" to "git push --force-with-lease"');
|
|
233
|
-
}
|
|
234
|
-
return { fixed, changes };
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Fix resource limits by reducing to safe values
|
|
238
|
-
*/
|
|
239
|
-
static fixResourceLimits(args, limits) {
|
|
240
|
-
const fixed = { ...args };
|
|
241
|
-
const changes = [];
|
|
242
|
-
for (const [field, limit] of Object.entries(limits)) {
|
|
243
|
-
if (field in fixed && typeof fixed[field] === 'number') {
|
|
244
|
-
const value = fixed[field];
|
|
245
|
-
if (value > limit) {
|
|
246
|
-
const safeValue = Math.floor(limit * 0.8); // 80% of limit
|
|
247
|
-
fixed[field] = safeValue;
|
|
248
|
-
changes.push(`Reduced ${field} from ${value} to ${safeValue}`);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return { fixed, changes };
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Fix validation errors by coercing types
|
|
256
|
-
*/
|
|
257
|
-
static fixValidationErrors(args, schema) {
|
|
258
|
-
const fixed = { ...args };
|
|
259
|
-
const changes = [];
|
|
260
|
-
for (const [field, constraint] of Object.entries(schema)) {
|
|
261
|
-
if (field in fixed && typeof fixed[field] !== constraint.type) {
|
|
262
|
-
const original = fixed[field];
|
|
263
|
-
fixed[field] = convertType(original, constraint.type);
|
|
264
|
-
changes.push(`Converted ${field} from ${typeof original} to ${constraint.type}`);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return { fixed, changes };
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Validator with auto-fix integration
|
|
272
|
-
*/
|
|
273
|
-
export class AutoFixValidator {
|
|
274
|
-
constructor(autoFixEnabled = false) {
|
|
275
|
-
this.autoFixEnabled = autoFixEnabled;
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Validate with optional auto-fixing
|
|
279
|
-
*/
|
|
280
|
-
async validate(value, validator) {
|
|
281
|
-
let result = validator(value);
|
|
282
|
-
// If invalid and auto-fix is available, try to fix
|
|
283
|
-
if (!result.valid && this.autoFixEnabled && result.autoFix?.available) {
|
|
284
|
-
console.warn(`[AutoFix] Attempting to fix: ${result.error?.message}`);
|
|
285
|
-
try {
|
|
286
|
-
const fixedValue = result.autoFix.apply();
|
|
287
|
-
console.warn(`[AutoFix] Applied: ${result.autoFix.description}`);
|
|
288
|
-
// Re-validate fixed value
|
|
289
|
-
result = validator(fixedValue);
|
|
290
|
-
if (result.valid) {
|
|
291
|
-
console.log('[AutoFix] Validation passed after fix');
|
|
292
|
-
return { value: fixedValue, result };
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
catch (error) {
|
|
296
|
-
console.error('[AutoFix] Failed to apply fix:', error);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
return { value, result };
|
|
300
|
-
}
|
|
301
|
-
setAutoFix(enabled) {
|
|
302
|
-
this.autoFixEnabled = enabled;
|
|
303
|
-
}
|
|
304
|
-
}
|
package/dist/bin/core/errors.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export function buildError(action, error, context) {
|
|
2
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
3
|
-
const contextDetails = formatContext(context);
|
|
4
|
-
return contextDetails ? `Error ${action}: ${message} (${contextDetails})` : `Error ${action}: ${message}`;
|
|
5
|
-
}
|
|
6
|
-
function formatContext(context) {
|
|
7
|
-
if (!context) {
|
|
8
|
-
return '';
|
|
9
|
-
}
|
|
10
|
-
const entries = Object.entries(context).filter(([, value]) => value !== undefined && value !== null);
|
|
11
|
-
if (entries.length === 0) {
|
|
12
|
-
return '';
|
|
13
|
-
}
|
|
14
|
-
return entries
|
|
15
|
-
.map(([key, value]) => `${formatContextKey(key)} ${formatContextValue(value)}`)
|
|
16
|
-
.join(', ');
|
|
17
|
-
}
|
|
18
|
-
function formatContextKey(key) {
|
|
19
|
-
if (!key) {
|
|
20
|
-
return key;
|
|
21
|
-
}
|
|
22
|
-
return key.slice(0, 1).toUpperCase() + key.slice(1);
|
|
23
|
-
}
|
|
24
|
-
function formatContextValue(value) {
|
|
25
|
-
if (typeof value === 'string') {
|
|
26
|
-
return value || '(empty)';
|
|
27
|
-
}
|
|
28
|
-
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
29
|
-
return String(value);
|
|
30
|
-
}
|
|
31
|
-
return '(unknown)';
|
|
32
|
-
}
|