erosolar-cli 1.7.14 → 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 +38 -0
- 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/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,135 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
-
import { dirname, resolve } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
5
|
-
const DEFAULT_RULEBOOK_ROOT = resolve(MODULE_DIR, '..', '..');
|
|
6
|
-
const manifestCache = new Map();
|
|
7
|
-
const promptCache = new Map();
|
|
8
|
-
export function loadAgentRulebook(profile, options = {}) {
|
|
9
|
-
// If inline manifest is provided, use it directly
|
|
10
|
-
if (options.inline) {
|
|
11
|
-
const manifest = options.inline;
|
|
12
|
-
if (manifest.profile !== profile) {
|
|
13
|
-
throw new Error(`Rulebook profile mismatch for ${profile}. Expected \"${profile}\" but inline manifest declares \"${manifest.profile}\".`);
|
|
14
|
-
}
|
|
15
|
-
return manifest;
|
|
16
|
-
}
|
|
17
|
-
// Otherwise load from file
|
|
18
|
-
const root = options.root ?? DEFAULT_RULEBOOK_ROOT;
|
|
19
|
-
const filePath = resolveRulebookPath(profile, root, options.file);
|
|
20
|
-
const cacheKey = filePath;
|
|
21
|
-
const cached = manifestCache.get(cacheKey);
|
|
22
|
-
if (cached) {
|
|
23
|
-
return cached;
|
|
24
|
-
}
|
|
25
|
-
const raw = readFileSync(filePath, 'utf8');
|
|
26
|
-
const manifest = JSON.parse(raw);
|
|
27
|
-
if (manifest.profile !== profile) {
|
|
28
|
-
throw new Error(`Rulebook profile mismatch for ${profile}. Expected \"${profile}\" but file declares \"${manifest.profile}\".`);
|
|
29
|
-
}
|
|
30
|
-
manifestCache.set(cacheKey, manifest);
|
|
31
|
-
return manifest;
|
|
32
|
-
}
|
|
33
|
-
export function buildAgentRulebookPrompt(profile, options = {}) {
|
|
34
|
-
// If inline, don't cache (since it might change)
|
|
35
|
-
if (options.inline) {
|
|
36
|
-
const manifest = loadAgentRulebook(profile, { inline: options.inline });
|
|
37
|
-
return formatAgentRulebook(manifest);
|
|
38
|
-
}
|
|
39
|
-
const root = options.root ?? DEFAULT_RULEBOOK_ROOT;
|
|
40
|
-
const filePath = resolveRulebookPath(profile, root, options.file);
|
|
41
|
-
const cacheKey = filePath;
|
|
42
|
-
const cached = promptCache.get(cacheKey);
|
|
43
|
-
if (cached) {
|
|
44
|
-
return cached;
|
|
45
|
-
}
|
|
46
|
-
const manifest = loadAgentRulebook(profile, { root, file: options.file });
|
|
47
|
-
const prompt = formatAgentRulebook(manifest);
|
|
48
|
-
promptCache.set(cacheKey, prompt);
|
|
49
|
-
return prompt;
|
|
50
|
-
}
|
|
51
|
-
export function formatAgentRulebook(manifest) {
|
|
52
|
-
const lines = [];
|
|
53
|
-
const headerLabel = manifest.label || manifest.profile;
|
|
54
|
-
lines.push(`${headerLabel} — rulebook version ${manifest.version} (contract ${manifest.contractVersion}).`);
|
|
55
|
-
if (manifest.description) {
|
|
56
|
-
lines.push(manifest.description.trim());
|
|
57
|
-
}
|
|
58
|
-
if (manifest.globalPrinciples?.length) {
|
|
59
|
-
lines.push('\nGLOBAL PRINCIPLES:');
|
|
60
|
-
for (const rule of manifest.globalPrinciples) {
|
|
61
|
-
lines.push(formatRuleLine(rule));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
for (const phase of manifest.phases) {
|
|
65
|
-
const phaseSummary = [phase.label || phase.id];
|
|
66
|
-
if (phase.description) {
|
|
67
|
-
phaseSummary.push(`– ${phase.description}`);
|
|
68
|
-
}
|
|
69
|
-
lines.push(`\nPHASE ${phase.id}: ${phaseSummary.join(' ')}`);
|
|
70
|
-
if (phase.trigger) {
|
|
71
|
-
lines.push(` Trigger: ${phase.trigger}`);
|
|
72
|
-
}
|
|
73
|
-
for (const step of phase.steps) {
|
|
74
|
-
lines.push(formatStepLine(step));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return lines.filter(Boolean).join('\n');
|
|
78
|
-
}
|
|
79
|
-
function resolveRulebookPath(profile, root, fileOverride) {
|
|
80
|
-
const trimmedOverride = fileOverride?.trim();
|
|
81
|
-
if (trimmedOverride) {
|
|
82
|
-
return resolve(root, trimmedOverride);
|
|
83
|
-
}
|
|
84
|
-
return resolve(root, 'agents', `${profile}.rules.json`);
|
|
85
|
-
}
|
|
86
|
-
function formatRuleLine(rule, indent = ' ') {
|
|
87
|
-
const severity = rule.severity?.toUpperCase() ?? 'INFO';
|
|
88
|
-
const parts = [`[${severity}] (${rule.id}) ${rule.summary}`];
|
|
89
|
-
if (rule.detail) {
|
|
90
|
-
parts.push(`— ${rule.detail}`);
|
|
91
|
-
}
|
|
92
|
-
if (rule.evidenceRequired) {
|
|
93
|
-
parts.push(`Evidence: ${rule.evidenceRequired}`);
|
|
94
|
-
}
|
|
95
|
-
return `${indent}${parts.join(' ')}`;
|
|
96
|
-
}
|
|
97
|
-
function formatStepLine(step) {
|
|
98
|
-
const details = [];
|
|
99
|
-
if (step.intent) {
|
|
100
|
-
details.push(step.intent);
|
|
101
|
-
}
|
|
102
|
-
if (step.description && step.description !== step.intent) {
|
|
103
|
-
details.push(step.description);
|
|
104
|
-
}
|
|
105
|
-
const header = [` STEP ${step.id}: ${step.title}`];
|
|
106
|
-
if (details.length) {
|
|
107
|
-
header.push(`(${details.join(' — ')})`);
|
|
108
|
-
}
|
|
109
|
-
const lines = [header.join(' ')];
|
|
110
|
-
if (step.entryCriteria?.length) {
|
|
111
|
-
lines.push(` Entry: ${step.entryCriteria.join('; ')}`);
|
|
112
|
-
}
|
|
113
|
-
if (step.exitCriteria?.length) {
|
|
114
|
-
lines.push(` Exit: ${step.exitCriteria.join('; ')}`);
|
|
115
|
-
}
|
|
116
|
-
if (step.allowedTools?.length) {
|
|
117
|
-
lines.push(` Allowed tools: ${step.allowedTools.join(', ')}`);
|
|
118
|
-
}
|
|
119
|
-
if (step.blockedTools?.length) {
|
|
120
|
-
lines.push(` Blocked tools: ${step.blockedTools.join(', ')}`);
|
|
121
|
-
}
|
|
122
|
-
if (step.notes?.length) {
|
|
123
|
-
lines.push(` Notes: ${step.notes.join(' ')}`);
|
|
124
|
-
}
|
|
125
|
-
for (const rule of step.rules) {
|
|
126
|
-
lines.push(formatRuleLine(rule, ' - '));
|
|
127
|
-
}
|
|
128
|
-
if (step.subSteps?.length) {
|
|
129
|
-
lines.push(' Sub-steps:');
|
|
130
|
-
for (const subStep of step.subSteps) {
|
|
131
|
-
lines.push(formatStepLine(subStep).replace(/^ /gm, ' '));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return lines.join('\n');
|
|
135
|
-
}
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized agent schema loader.
|
|
3
|
-
*
|
|
4
|
-
* This module provides type-safe loading and validation of the centralized
|
|
5
|
-
* agent configuration schema from src/contracts/agent-schemas.json.
|
|
6
|
-
* All agent-related configuration should be loaded through this module
|
|
7
|
-
* to ensure consistency across the application.
|
|
8
|
-
*/
|
|
9
|
-
import { readFileSync } from 'node:fs';
|
|
10
|
-
import { join, dirname } from 'node:path';
|
|
11
|
-
import { fileURLToPath } from 'node:url';
|
|
12
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
-
const __dirname = dirname(__filename);
|
|
14
|
-
/**
|
|
15
|
-
* Cached schema instance
|
|
16
|
-
*/
|
|
17
|
-
let cachedSchema = null;
|
|
18
|
-
/**
|
|
19
|
-
* Load the centralized agent schemas manifest.
|
|
20
|
-
* Results are cached for performance.
|
|
21
|
-
*
|
|
22
|
-
* @returns The complete agent schemas manifest
|
|
23
|
-
* @throws Error if the schema file cannot be read or parsed
|
|
24
|
-
*/
|
|
25
|
-
export function getAgentSchemas() {
|
|
26
|
-
if (cachedSchema) {
|
|
27
|
-
return cachedSchema;
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
const schemaPath = join(__dirname, '..', 'contracts', 'agent-schemas.json');
|
|
31
|
-
const raw = readFileSync(schemaPath, 'utf-8');
|
|
32
|
-
const parsed = JSON.parse(raw);
|
|
33
|
-
// Basic validation
|
|
34
|
-
validateAgentSchemas(parsed);
|
|
35
|
-
cachedSchema = parsed;
|
|
36
|
-
return cachedSchema;
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
throw new Error(`Failed to load agent schemas: ${error instanceof Error ? error.message : String(error)}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get all provider configurations
|
|
44
|
-
*/
|
|
45
|
-
export function getProviders() {
|
|
46
|
-
const schemas = getAgentSchemas();
|
|
47
|
-
return schemas.providers;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get a specific provider by ID
|
|
51
|
-
*/
|
|
52
|
-
export function getProvider(providerId) {
|
|
53
|
-
const providers = getProviders();
|
|
54
|
-
return providers.find((p) => p.id === providerId);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Get all model configurations (includes both static and discovered models)
|
|
58
|
-
*/
|
|
59
|
-
export function getModels() {
|
|
60
|
-
const schemas = getAgentSchemas();
|
|
61
|
-
const staticModels = schemas.models;
|
|
62
|
-
// Try to load discovered models
|
|
63
|
-
try {
|
|
64
|
-
const { getCachedDiscoveredModels } = require('./modelDiscovery.js');
|
|
65
|
-
const discoveredModels = getCachedDiscoveredModels();
|
|
66
|
-
// Merge models, preferring static definitions over discovered ones
|
|
67
|
-
const staticIds = new Set(staticModels.map((m) => m.id));
|
|
68
|
-
const uniqueDiscovered = discoveredModels.filter((m) => !staticIds.has(m.id));
|
|
69
|
-
return [...staticModels, ...uniqueDiscovered];
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
// If discovery module fails, just return static models
|
|
73
|
-
return staticModels;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Get models for a specific provider
|
|
78
|
-
*/
|
|
79
|
-
export function getModelsByProvider(providerId) {
|
|
80
|
-
const models = getModels();
|
|
81
|
-
return models.filter((m) => m.provider === providerId);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Get a specific model by ID
|
|
85
|
-
*/
|
|
86
|
-
export function getModel(modelId) {
|
|
87
|
-
const models = getModels();
|
|
88
|
-
return models.find((m) => m.id === modelId);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Get all agent profiles
|
|
92
|
-
*/
|
|
93
|
-
export function getProfiles() {
|
|
94
|
-
const schemas = getAgentSchemas();
|
|
95
|
-
return schemas.profiles;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Get a specific profile by name
|
|
99
|
-
*/
|
|
100
|
-
export function getProfile(profileName) {
|
|
101
|
-
const profiles = getProfiles();
|
|
102
|
-
return profiles.find((p) => p.name === profileName);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Get all slash commands
|
|
106
|
-
*/
|
|
107
|
-
export function getSlashCommands() {
|
|
108
|
-
const schemas = getAgentSchemas();
|
|
109
|
-
return schemas.slashCommands ?? [];
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Get all capabilities
|
|
113
|
-
*/
|
|
114
|
-
export function getCapabilities() {
|
|
115
|
-
const schemas = getAgentSchemas();
|
|
116
|
-
return schemas.capabilities ?? [];
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Validate the agent schemas manifest structure
|
|
120
|
-
*/
|
|
121
|
-
function validateAgentSchemas(manifest) {
|
|
122
|
-
// Check required fields
|
|
123
|
-
if (!manifest.contractVersion) {
|
|
124
|
-
throw new Error('Missing required field: contractVersion');
|
|
125
|
-
}
|
|
126
|
-
if (!manifest.version) {
|
|
127
|
-
throw new Error('Missing required field: version');
|
|
128
|
-
}
|
|
129
|
-
if (!Array.isArray(manifest.providers) || manifest.providers.length === 0) {
|
|
130
|
-
throw new Error('Missing or empty required field: providers');
|
|
131
|
-
}
|
|
132
|
-
if (!Array.isArray(manifest.models) || manifest.models.length === 0) {
|
|
133
|
-
throw new Error('Missing or empty required field: models');
|
|
134
|
-
}
|
|
135
|
-
if (!Array.isArray(manifest.profiles) || manifest.profiles.length === 0) {
|
|
136
|
-
throw new Error('Missing or empty required field: profiles');
|
|
137
|
-
}
|
|
138
|
-
// Validate provider uniqueness
|
|
139
|
-
const providerIds = new Set();
|
|
140
|
-
for (const provider of manifest.providers) {
|
|
141
|
-
if (!provider.id || !provider.label) {
|
|
142
|
-
throw new Error('Provider missing required fields: id, label');
|
|
143
|
-
}
|
|
144
|
-
if (providerIds.has(provider.id)) {
|
|
145
|
-
throw new Error(`Duplicate provider ID: ${provider.id}`);
|
|
146
|
-
}
|
|
147
|
-
providerIds.add(provider.id);
|
|
148
|
-
}
|
|
149
|
-
// Validate model uniqueness and provider references
|
|
150
|
-
const modelIds = new Set();
|
|
151
|
-
for (const model of manifest.models) {
|
|
152
|
-
if (!model.id || !model.label || !model.provider) {
|
|
153
|
-
throw new Error('Model missing required fields: id, label, provider');
|
|
154
|
-
}
|
|
155
|
-
if (modelIds.has(model.id)) {
|
|
156
|
-
throw new Error(`Duplicate model ID: ${model.id}`);
|
|
157
|
-
}
|
|
158
|
-
if (!providerIds.has(model.provider)) {
|
|
159
|
-
throw new Error(`Model "${model.id}" references unknown provider: ${model.provider}`);
|
|
160
|
-
}
|
|
161
|
-
modelIds.add(model.id);
|
|
162
|
-
}
|
|
163
|
-
// Validate profile uniqueness and references
|
|
164
|
-
const profileNames = new Set();
|
|
165
|
-
for (const profile of manifest.profiles) {
|
|
166
|
-
if (!profile.name || !profile.label || !profile.defaultProvider || !profile.defaultModel) {
|
|
167
|
-
throw new Error('Profile missing required fields: name, label, defaultProvider, defaultModel');
|
|
168
|
-
}
|
|
169
|
-
if (profileNames.has(profile.name)) {
|
|
170
|
-
throw new Error(`Duplicate profile name: ${profile.name}`);
|
|
171
|
-
}
|
|
172
|
-
if (!providerIds.has(profile.defaultProvider)) {
|
|
173
|
-
throw new Error(`Profile "${profile.name}" references unknown provider: ${profile.defaultProvider}`);
|
|
174
|
-
}
|
|
175
|
-
if (!modelIds.has(profile.defaultModel)) {
|
|
176
|
-
throw new Error(`Profile "${profile.name}" references unknown model: ${profile.defaultModel}`);
|
|
177
|
-
}
|
|
178
|
-
profileNames.add(profile.name);
|
|
179
|
-
}
|
|
180
|
-
// Validate slash commands uniqueness
|
|
181
|
-
if (manifest.slashCommands) {
|
|
182
|
-
const commands = new Set();
|
|
183
|
-
for (const cmd of manifest.slashCommands) {
|
|
184
|
-
if (!cmd.command || !cmd.description) {
|
|
185
|
-
throw new Error('Slash command missing required fields: command, description');
|
|
186
|
-
}
|
|
187
|
-
if (commands.has(cmd.command)) {
|
|
188
|
-
throw new Error(`Duplicate slash command: ${cmd.command}`);
|
|
189
|
-
}
|
|
190
|
-
commands.add(cmd.command);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
// Validate capabilities uniqueness
|
|
194
|
-
if (manifest.capabilities) {
|
|
195
|
-
const capabilities = new Set();
|
|
196
|
-
for (const cap of manifest.capabilities) {
|
|
197
|
-
if (!cap.id || !cap.label) {
|
|
198
|
-
throw new Error('Capability missing required fields: id, label');
|
|
199
|
-
}
|
|
200
|
-
if (capabilities.has(cap.id)) {
|
|
201
|
-
throw new Error(`Duplicate capability ID: ${cap.id}`);
|
|
202
|
-
}
|
|
203
|
-
capabilities.add(cap.id);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Clear the cached schema (useful for testing)
|
|
209
|
-
*/
|
|
210
|
-
export function clearSchemaCache() {
|
|
211
|
-
cachedSchema = null;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Validate that a provider ID exists in the schema
|
|
215
|
-
*/
|
|
216
|
-
export function isValidProvider(providerId) {
|
|
217
|
-
const provider = getProvider(providerId);
|
|
218
|
-
return provider !== undefined;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Validate that a model ID exists in the schema
|
|
222
|
-
*/
|
|
223
|
-
export function isValidModel(modelId) {
|
|
224
|
-
const model = getModel(modelId);
|
|
225
|
-
return model !== undefined;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Validate that a profile name exists in the schema
|
|
229
|
-
*/
|
|
230
|
-
export function isValidProfile(profileName) {
|
|
231
|
-
const profile = getProfile(profileName);
|
|
232
|
-
return profile !== undefined;
|
|
233
|
-
}
|