erosolar-cli 1.7.280 → 1.7.281
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 +1 -0
- 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/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 +17 -7
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +218 -161
- 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 +40 -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 +78 -178
- package/dist/shell/terminalInput.d.ts.map +1 -1
- package/dist/shell/terminalInput.js +494 -877
- package/dist/shell/terminalInput.js.map +1 -1
- package/dist/shell/terminalInputAdapter.d.ts +28 -34
- package/dist/shell/terminalInputAdapter.d.ts.map +1 -1
- package/dist/shell/terminalInputAdapter.js +26 -47
- 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.map +1 -1
- package/dist/ui/ShellUIAdapter.js +13 -12
- package/dist/ui/ShellUIAdapter.js.map +1 -1
- package/dist/ui/display.d.ts +22 -39
- package/dist/ui/display.d.ts.map +1 -1
- package/dist/ui/display.js +136 -277
- 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 +1 -0
- package/dist/ui/unified/layout.d.ts.map +1 -1
- package/dist/ui/unified/layout.js +15 -25
- 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 +1 -1
- 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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
let inlineAgentConfig = null;
|
|
2
|
+
/**
|
|
3
|
+
* Set inline agent config (from CLI flag or env). Values are normalized eagerly.
|
|
4
|
+
*/
|
|
5
|
+
export function setInlineAgentConfig(config) {
|
|
6
|
+
inlineAgentConfig = config ? normalizeConfig(config) : null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Retrieve the current inline agent configuration.
|
|
10
|
+
*/
|
|
11
|
+
export function getInlineAgentConfig() {
|
|
12
|
+
return inlineAgentConfig;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Parse a JSON string into inline agent config, throwing a descriptive error on failure.
|
|
16
|
+
*/
|
|
17
|
+
export function parseInlineAgentConfig(json) {
|
|
18
|
+
try {
|
|
19
|
+
const parsed = JSON.parse(json);
|
|
20
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
21
|
+
throw new Error('Inline agents must be an object keyed by agent name.');
|
|
22
|
+
}
|
|
23
|
+
return normalizeConfig(parsed);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const message = error instanceof Error ? error.message : 'Unknown error parsing inline agents';
|
|
27
|
+
throw new Error(`Invalid inline agent config: ${message}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load inline agent config from environment variables.
|
|
32
|
+
* Supports EROSOLAR_AGENTS as a JSON string.
|
|
33
|
+
*/
|
|
34
|
+
export function loadInlineAgentConfigFromEnv(env = process.env) {
|
|
35
|
+
const raw = env['EROSOLAR_AGENTS']?.trim();
|
|
36
|
+
if (!raw) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return parseInlineAgentConfig(raw);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.warn('[agent-config] Failed to parse EROSOLAR_AGENTS:', error);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function normalizeConfig(config) {
|
|
48
|
+
const normalized = {};
|
|
49
|
+
for (const [key, value] of Object.entries(config)) {
|
|
50
|
+
if (!key.trim()) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const agentName = key.trim();
|
|
54
|
+
if (!value || typeof value !== 'object') {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const record = value;
|
|
58
|
+
const description = typeof record['description'] === 'string' ? record['description'].trim() : undefined;
|
|
59
|
+
const prompt = typeof record['prompt'] === 'string' ? record['prompt'].trim() : undefined;
|
|
60
|
+
const model = typeof record['model'] === 'string' ? record['model'].trim() : undefined;
|
|
61
|
+
const permissionMode = typeof record['permissionMode'] === 'string' ? record['permissionMode'].trim() : undefined;
|
|
62
|
+
const tools = normalizeStringList(record['tools']);
|
|
63
|
+
const skills = normalizeStringList(record['skills']);
|
|
64
|
+
normalized[agentName] = {
|
|
65
|
+
description,
|
|
66
|
+
prompt,
|
|
67
|
+
model,
|
|
68
|
+
permissionMode,
|
|
69
|
+
tools,
|
|
70
|
+
skills,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return normalized;
|
|
74
|
+
}
|
|
75
|
+
function normalizeStringList(value) {
|
|
76
|
+
if (typeof value === 'string') {
|
|
77
|
+
const trimmed = value.trim();
|
|
78
|
+
return trimmed ? [trimmed] : undefined;
|
|
79
|
+
}
|
|
80
|
+
if (Array.isArray(value)) {
|
|
81
|
+
const entries = value
|
|
82
|
+
.filter((entry) => typeof entry === 'string')
|
|
83
|
+
.map((entry) => entry.trim())
|
|
84
|
+
.filter(Boolean);
|
|
85
|
+
return entries.length ? entries : undefined;
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=agentConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentConfig.js","sourceRoot":"","sources":["../../src/subagents/agentConfig.ts"],"names":[],"mappings":"AAWA,IAAI,iBAAiB,GAAgC,IAAI,CAAC;AAE1D;;IAEI;AACJ,MAAM,UAAU,oBAAoB,CAAC,MAAmC;IACtE,iBAAiB,GAAG,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACnE,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,eAAe,CAAC,MAAiC,CAAC,CAAC;IAC5D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,qCAAqC,CAAC;QAC/F,MAAM,IAAI,KAAK,CAAC,gCAAgC,OAAO,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAA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ap } from './agentConfig.js';
|
|
2
|
+
export type AgentSource = 'builtin' | 'project' | 'user' | 'inline';
|
|
3
|
+
export interface AgentDefinition {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
prompt: string;
|
|
7
|
+
tools?: string[];
|
|
8
|
+
model?: string;
|
|
9
|
+
permissionMode?: string;
|
|
10
|
+
skills?: string[];
|
|
11
|
+
source: AgentSource;
|
|
12
|
+
path?: string;
|
|
13
|
+
summary?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AgentRegistryOptions {
|
|
16
|
+
workingDir: string;
|
|
17
|
+
inlineAgents?: InlineAgentConfigMap | null;
|
|
18
|
+
builtIns?: AgentDefinition[];
|
|
19
|
+
}
|
|
20
|
+
export declare class AgentRegistry {
|
|
21
|
+
private readonly workingDir;
|
|
22
|
+
private readonly inlineAgents;
|
|
23
|
+
private readonly builtIns;
|
|
24
|
+
private agents;
|
|
25
|
+
constructor(options: AgentRegistryOptions);
|
|
26
|
+
refresh(): AgentDefinition[];
|
|
27
|
+
list(): AgentDefinition[];
|
|
28
|
+
resolve(name: string): AgentDefinition | null;
|
|
29
|
+
private register;
|
|
30
|
+
private loadFromDirectory;
|
|
31
|
+
private loadInlineAgents;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=agentRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentRegistry.d.ts","sourceRoot":"","sources":["../../src/subagents/agentRegistry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAwB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEpE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;CAC9B;AAKD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA8B;IAC3D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C,OAAO,CAAC,MAAM,CAAsC;gBAExC,OAAO,EAAE,oBAAoB;IAOzC,OAAO,IAAI,eAAe,EAAE;IAwB5B,IAAI,IAAI,eAAe,EAAE;IAIzB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI;IAK7C,OAAO,CAAC,QAAQ;IAWhB,OAAO,CAAC,iBAAiB;IAiDzB,OAAO,CAAC,gBAAgB;CAkBzB"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
2
|
+
import { join, basename } from 'node:path';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { parseFrontmatter } from '../utils/frontmatter.js';
|
|
5
|
+
import { getInlineAgentConfig } from './agentConfig.js';
|
|
6
|
+
const PROJECT_AGENT_DIR = '.claude/agents';
|
|
7
|
+
const USER_AGENT_DIR = '.claude/agents';
|
|
8
|
+
export class AgentRegistry {
|
|
9
|
+
workingDir;
|
|
10
|
+
inlineAgents;
|
|
11
|
+
builtIns;
|
|
12
|
+
agents = new Map();
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.workingDir = options.workingDir;
|
|
15
|
+
this.inlineAgents = options.inlineAgents ?? getInlineAgentConfig();
|
|
16
|
+
this.builtIns = options.builtIns ?? [];
|
|
17
|
+
this.refresh();
|
|
18
|
+
}
|
|
19
|
+
refresh() {
|
|
20
|
+
this.agents.clear();
|
|
21
|
+
// Lowest priority: built-in agents
|
|
22
|
+
for (const agent of this.builtIns) {
|
|
23
|
+
this.register(agent);
|
|
24
|
+
}
|
|
25
|
+
// User-level agents (~/.claude/agents)
|
|
26
|
+
const userDir = join(homedir(), USER_AGENT_DIR);
|
|
27
|
+
this.loadFromDirectory(userDir, 'user');
|
|
28
|
+
// Inline agents (CLI/env)
|
|
29
|
+
if (this.inlineAgents) {
|
|
30
|
+
this.loadInlineAgents(this.inlineAgents);
|
|
31
|
+
}
|
|
32
|
+
// Project-level agents (.claude/agents)
|
|
33
|
+
const projectDir = join(this.workingDir, PROJECT_AGENT_DIR);
|
|
34
|
+
this.loadFromDirectory(projectDir, 'project');
|
|
35
|
+
return this.list();
|
|
36
|
+
}
|
|
37
|
+
list() {
|
|
38
|
+
return Array.from(this.agents.values()).sort((a, b) => a.name.localeCompare(b.name));
|
|
39
|
+
}
|
|
40
|
+
resolve(name) {
|
|
41
|
+
const key = normalizeName(name);
|
|
42
|
+
return this.agents.get(key) ?? null;
|
|
43
|
+
}
|
|
44
|
+
register(agent) {
|
|
45
|
+
const key = normalizeName(agent.name);
|
|
46
|
+
if (!key) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this.agents.set(key, {
|
|
50
|
+
...agent,
|
|
51
|
+
name: key,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
loadFromDirectory(dir, source) {
|
|
55
|
+
if (!existsSync(dir)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let entries = [];
|
|
59
|
+
try {
|
|
60
|
+
entries = readdirSync(dir);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
for (const entry of entries) {
|
|
66
|
+
const fullPath = join(dir, entry);
|
|
67
|
+
try {
|
|
68
|
+
const stats = statSync(fullPath);
|
|
69
|
+
if (stats.isDirectory()) {
|
|
70
|
+
this.loadFromDirectory(fullPath, source);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (!entry.toLowerCase().endsWith('.md')) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const content = readFileSync(fullPath, 'utf8');
|
|
77
|
+
const parsed = parseFrontmatter(content);
|
|
78
|
+
const name = normalizeName(parsed.attributes.name || basename(entry, '.md'));
|
|
79
|
+
if (!name) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const description = extractDescription(parsed);
|
|
83
|
+
const prompt = parsed.body?.trim() || '';
|
|
84
|
+
this.register({
|
|
85
|
+
name,
|
|
86
|
+
description,
|
|
87
|
+
prompt,
|
|
88
|
+
tools: normalizeStringList(parsed.attributes.tools),
|
|
89
|
+
model: parsed.attributes.model ? String(parsed.attributes.model) : undefined,
|
|
90
|
+
permissionMode: parsed.attributes.permissionMode ? String(parsed.attributes.permissionMode) : undefined,
|
|
91
|
+
skills: normalizeStringList(parsed.attributes.skills),
|
|
92
|
+
summary: parsed.attributes.summary ? String(parsed.attributes.summary) : undefined,
|
|
93
|
+
source,
|
|
94
|
+
path: fullPath,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.warn(`[agent-registry] Failed to load agent from ${fullPath}:`, error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
loadInlineAgents(definitions) {
|
|
103
|
+
for (const [name, config] of Object.entries(definitions)) {
|
|
104
|
+
const normalized = normalizeName(name);
|
|
105
|
+
if (!normalized) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
this.register({
|
|
109
|
+
name: normalized,
|
|
110
|
+
description: config.description || `Inline agent ${normalized}`,
|
|
111
|
+
prompt: config.prompt || '',
|
|
112
|
+
tools: Array.isArray(config.tools) ? config.tools : config.tools ? [config.tools] : undefined,
|
|
113
|
+
model: config.model,
|
|
114
|
+
permissionMode: config.permissionMode,
|
|
115
|
+
skills: Array.isArray(config.skills) ? config.skills : config.skills ? [config.skills] : undefined,
|
|
116
|
+
source: 'inline',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function normalizeName(value) {
|
|
122
|
+
if (typeof value !== 'string') {
|
|
123
|
+
return '';
|
|
124
|
+
}
|
|
125
|
+
const trimmed = value.trim();
|
|
126
|
+
if (!trimmed) {
|
|
127
|
+
return '';
|
|
128
|
+
}
|
|
129
|
+
return trimmed.toLowerCase().replace(/\s+/g, '-');
|
|
130
|
+
}
|
|
131
|
+
function normalizeStringList(value) {
|
|
132
|
+
if (!value) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
if (typeof value === 'string') {
|
|
136
|
+
const trimmed = value.trim();
|
|
137
|
+
if (!trimmed) {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
return trimmed.split(',').map((entry) => entry.trim()).filter(Boolean);
|
|
141
|
+
}
|
|
142
|
+
if (Array.isArray(value)) {
|
|
143
|
+
const normalized = value
|
|
144
|
+
.filter((entry) => typeof entry === 'string')
|
|
145
|
+
.map((entry) => entry.trim())
|
|
146
|
+
.filter(Boolean);
|
|
147
|
+
return normalized.length ? normalized : undefined;
|
|
148
|
+
}
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
function extractDescription(parsed) {
|
|
152
|
+
const attrDescription = typeof parsed.attributes['description'] === 'string' ? parsed.attributes['description'].trim() : '';
|
|
153
|
+
if (attrDescription) {
|
|
154
|
+
return attrDescription;
|
|
155
|
+
}
|
|
156
|
+
const firstLine = parsed.body?.split('\n').find((line) => line.trim().length > 0);
|
|
157
|
+
if (firstLine) {
|
|
158
|
+
return firstLine.trim().slice(0, 200);
|
|
159
|
+
}
|
|
160
|
+
return 'Custom subagent';
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=agentRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentRegistry.js","sourceRoot":"","sources":["../../src/subagents/agentRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAwB,MAAM,kBAAkB,CAAC;AAuB9E,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,MAAM,OAAO,aAAa;IACP,UAAU,CAAS;IACnB,YAAY,CAA8B;IAC1C,QAAQ,CAAoB;IACrC,MAAM,GAAG,IAAI,GAAG,EAA2B,CAAC;IAEpD,YAAY,OAA6B;QACvC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,oBAAoB,EAAE,CAAC;QACnE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;QACvC,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAEpB,mCAAmC;QACnC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QAED,uCAAuC;QACvC,MAAM,OAAO,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AAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,UAAU,GAAG,KAAK;aACrB,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;aAC7D,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;aAC5B,MAAM,CAAC,OAAO,CAAC,CAAC;QACnB,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IACpD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,kBAAkB,CAAC,MAA2C;IACrE,MAAM,eAAe,GAAG,OAAO,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5H,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAClF,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
import type { CapabilityContext } from '../runtime/agentHost.js';
|
|
2
|
+
import { AgentRegistry, type AgentDefinition } from './agentRegistry.js';
|
|
2
3
|
type TaskModelName = 'sonnet' | 'opus' | 'haiku';
|
|
4
|
+
type TaskThoroughness = 'quick' | 'medium' | 'very_thorough';
|
|
3
5
|
export interface TaskInvocationOptions {
|
|
4
6
|
description: string;
|
|
5
7
|
prompt: string;
|
|
6
8
|
subagentType: string;
|
|
7
9
|
model?: TaskModelName;
|
|
8
10
|
resumeId?: string;
|
|
11
|
+
thoroughness?: TaskThoroughness;
|
|
9
12
|
}
|
|
10
13
|
interface TaskExecutionResult {
|
|
11
14
|
output: string;
|
|
12
15
|
}
|
|
16
|
+
export declare const BUILTIN_AGENT_DEFINITIONS: AgentDefinition[];
|
|
13
17
|
export declare class TaskRunner {
|
|
14
18
|
private readonly context;
|
|
19
|
+
private readonly registry;
|
|
15
20
|
private readonly snapshots;
|
|
16
|
-
constructor(context: CapabilityContext);
|
|
21
|
+
constructor(context: CapabilityContext, registry?: AgentRegistry);
|
|
17
22
|
runTask(options: TaskInvocationOptions): Promise<TaskExecutionResult>;
|
|
23
|
+
private buildToolRuntime;
|
|
18
24
|
private resolveToolPermissions;
|
|
19
25
|
private buildModelSelection;
|
|
20
26
|
private composeSystemPrompt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskRunner.d.ts","sourceRoot":"","sources":["../../src/subagents/taskRunner.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAQjE,KAAK,aAAa,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"taskRunner.d.ts","sourceRoot":"","sources":["../../src/subagents/taskRunner.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAQjE,OAAO,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEzE,KAAK,aAAa,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AACjD,KAAK,gBAAgB,GAAG,OAAO,GAAG,QAAQ,GAAG,eAAe,CAAC;AAE7D,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC;AAED,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB;AAYD,eAAO,MAAM,yBAAyB,EAAE,eAAe,EAsCtD,CAAC;AAUF,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2B;gBAEzC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,CAAC,EAAE,aAAa;IAU1D,OAAO,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA2G3E,OAAO,CAAC,gBAAgB;IAkBxB,OAAO,CAAC,sBAAsB;IAS9B,OAAO,CAAC,mBAAmB;IAuB3B,OAAO,CAAC,mBAAmB;CAwD5B"}
|
|
@@ -5,38 +5,46 @@ import { join } from 'node:path';
|
|
|
5
5
|
import { createNodeRuntime } from '../runtime/node.js';
|
|
6
6
|
import { loadToolSettings } from '../core/preferences.js';
|
|
7
7
|
import { buildEnabledToolSet, evaluateToolPermissions } from '../capabilities/toolRegistry.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import { AgentRegistry } from './agentRegistry.js';
|
|
9
|
+
export const BUILTIN_AGENT_DEFINITIONS = [
|
|
10
|
+
{
|
|
11
|
+
name: 'general-purpose',
|
|
12
|
+
description: 'Complete research, editing, and implementation tasks end-to-end.',
|
|
13
|
+
summary: 'Autonomous agent for multi-step work.',
|
|
14
|
+
prompt: [
|
|
14
15
|
'Own the entire task autonomously. Narrate your plan, gather context with filesystem/search tools, and make changes when necessary.',
|
|
15
16
|
'Always cite the evidence, commands, and files you touched. Include TODOs or risks that need human review.',
|
|
16
|
-
],
|
|
17
|
-
|
|
17
|
+
].join('\n'),
|
|
18
|
+
model: 'sonnet',
|
|
19
|
+
source: 'builtin',
|
|
18
20
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
summary: '
|
|
23
|
-
|
|
21
|
+
{
|
|
22
|
+
name: 'explore',
|
|
23
|
+
description: 'Fast, read-only agent for mapping codebases and answering structural questions.',
|
|
24
|
+
summary: 'Read/search focused, no edits.',
|
|
25
|
+
prompt: [
|
|
26
|
+
'Operate in read-only mode. Do not edit files or run mutating commands.',
|
|
24
27
|
'Prioritize read/search/glob tools before editing. Call out every directory or file you investigated.',
|
|
25
28
|
'Return a crisp summary of what you learned plus direct file references so the parent agent can follow up.',
|
|
26
|
-
],
|
|
27
|
-
|
|
29
|
+
].join('\n'),
|
|
30
|
+
tools: ['read', 'read_file', 'read_files', 'list_files', 'search_files', 'glob_search', 'grep_search', 'find_definition', 'context_snapshot'],
|
|
31
|
+
model: 'haiku',
|
|
32
|
+
source: 'builtin',
|
|
28
33
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
summary: '
|
|
33
|
-
|
|
34
|
+
{
|
|
35
|
+
name: 'plan',
|
|
36
|
+
description: 'Break down complex efforts into actionable steps and identify risks or dependencies.',
|
|
37
|
+
summary: 'Planning-first, read/search only.',
|
|
38
|
+
prompt: [
|
|
34
39
|
'Produce a numbered plan with estimates, dependency notes, and explicit testing checkpoints.',
|
|
35
40
|
'If the task mentions code changes, suggest which files/modules should be edited and why before any implementation occurs.',
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
'Do not modify files directly; focus on analysis and recommendations.',
|
|
42
|
+
].join('\n'),
|
|
43
|
+
tools: ['read', 'read_file', 'read_files', 'list_files', 'search_files', 'glob_search', 'grep_search', 'find_definition', 'context_snapshot'],
|
|
44
|
+
model: 'sonnet',
|
|
45
|
+
source: 'builtin',
|
|
38
46
|
},
|
|
39
|
-
|
|
47
|
+
];
|
|
40
48
|
const MODEL_ID_LOOKUP = {
|
|
41
49
|
sonnet: { provider: 'anthropic', model: 'claude-sonnet-4-5-20250929' },
|
|
42
50
|
opus: { provider: 'anthropic', model: 'claude-opus-4-20250514' },
|
|
@@ -45,12 +53,24 @@ const MODEL_ID_LOOKUP = {
|
|
|
45
53
|
const TASK_STORE_DIR = join(homedir(), '.erosolar', 'tasks');
|
|
46
54
|
export class TaskRunner {
|
|
47
55
|
context;
|
|
56
|
+
registry;
|
|
48
57
|
snapshots = new TaskSnapshotStore();
|
|
49
|
-
constructor(context) {
|
|
58
|
+
constructor(context, registry) {
|
|
50
59
|
this.context = context;
|
|
60
|
+
this.registry =
|
|
61
|
+
registry ??
|
|
62
|
+
new AgentRegistry({
|
|
63
|
+
workingDir: context.workingDir,
|
|
64
|
+
builtIns: BUILTIN_AGENT_DEFINITIONS,
|
|
65
|
+
});
|
|
51
66
|
}
|
|
52
67
|
async runTask(options) {
|
|
53
|
-
|
|
68
|
+
this.registry.refresh();
|
|
69
|
+
const definition = this.registry.resolve(options.subagentType);
|
|
70
|
+
if (!definition) {
|
|
71
|
+
const available = this.registry.list().map((agent) => agent.name).join(', ');
|
|
72
|
+
throw new Error(`Subagent "${options.subagentType}" is not defined. Available agents: ${available || 'none found'}`);
|
|
73
|
+
}
|
|
54
74
|
const { allowedPluginIds } = this.resolveToolPermissions();
|
|
55
75
|
const adapterOptions = allowedPluginIds.size
|
|
56
76
|
? {
|
|
@@ -66,8 +86,14 @@ export class TaskRunner {
|
|
|
66
86
|
});
|
|
67
87
|
try {
|
|
68
88
|
const session = runtime.session;
|
|
69
|
-
const
|
|
70
|
-
const
|
|
89
|
+
const preferredModel = options.model ?? definition.model;
|
|
90
|
+
const selection = this.buildModelSelection(session.profileConfig, preferredModel);
|
|
91
|
+
const { runtime: toolRuntime, allowedTools, missingTools } = this.buildToolRuntime(session.toolRuntime, definition.tools);
|
|
92
|
+
const systemPrompt = this.composeSystemPrompt(session.profileConfig.systemPrompt, definition, options.description, {
|
|
93
|
+
thoroughness: options.thoroughness,
|
|
94
|
+
allowedTools,
|
|
95
|
+
missingTools,
|
|
96
|
+
});
|
|
71
97
|
let finalMetadata = null;
|
|
72
98
|
const agent = session.createAgent({
|
|
73
99
|
provider: selection.provider,
|
|
@@ -81,7 +107,7 @@ export class TaskRunner {
|
|
|
81
107
|
finalMetadata = metadata;
|
|
82
108
|
}
|
|
83
109
|
},
|
|
84
|
-
});
|
|
110
|
+
}, toolRuntime);
|
|
85
111
|
const resumeSnapshot = options.resumeId ? await this.snapshots.load(options.resumeId) : null;
|
|
86
112
|
if (options.resumeId && !resumeSnapshot) {
|
|
87
113
|
throw new Error(`Resume id "${options.resumeId}" was not found. Call Task without resume to start a new agent.`);
|
|
@@ -98,7 +124,7 @@ export class TaskRunner {
|
|
|
98
124
|
id: resumeId,
|
|
99
125
|
profile: this.context.profile,
|
|
100
126
|
description: options.description,
|
|
101
|
-
subagentType: definition.
|
|
127
|
+
subagentType: definition.name,
|
|
102
128
|
history,
|
|
103
129
|
createdAt: resumeSnapshot?.createdAt ?? new Date().toISOString(),
|
|
104
130
|
updatedAt: new Date().toISOString(),
|
|
@@ -107,7 +133,7 @@ export class TaskRunner {
|
|
|
107
133
|
const usageLine = formatUsage(extractUsage(finalMetadata));
|
|
108
134
|
const durationLine = `Duration: ${formatDuration(durationMs)}${usageLine ? ` | ${usageLine}` : ''}`;
|
|
109
135
|
const lines = [
|
|
110
|
-
`Task "${options.description}" completed by ${definition.
|
|
136
|
+
`Task "${options.description}" completed by ${definition.name} agent (${selection.model})`,
|
|
111
137
|
`${durationLine} | Resume ID: ${resumeId}`,
|
|
112
138
|
];
|
|
113
139
|
if (definition.summary) {
|
|
@@ -123,6 +149,18 @@ export class TaskRunner {
|
|
|
123
149
|
await runtime.host.dispose();
|
|
124
150
|
}
|
|
125
151
|
}
|
|
152
|
+
buildToolRuntime(baseRuntime, requestedTools) {
|
|
153
|
+
if (!requestedTools?.length) {
|
|
154
|
+
return { runtime: baseRuntime, allowedTools: [], missingTools: [] };
|
|
155
|
+
}
|
|
156
|
+
const available = baseRuntime.listProviderTools();
|
|
157
|
+
const { allowedNames, missing } = resolveAllowedToolNames(requestedTools, available);
|
|
158
|
+
if (!allowedNames.size) {
|
|
159
|
+
return { runtime: baseRuntime, allowedTools: [], missingTools: missing };
|
|
160
|
+
}
|
|
161
|
+
const runtime = new RestrictedToolRuntime(baseRuntime, allowedNames);
|
|
162
|
+
return { runtime, allowedTools: Array.from(allowedNames), missingTools: missing };
|
|
163
|
+
}
|
|
126
164
|
resolveToolPermissions() {
|
|
127
165
|
const settings = loadToolSettings();
|
|
128
166
|
const selection = buildEnabledToolSet(settings);
|
|
@@ -132,8 +170,9 @@ export class TaskRunner {
|
|
|
132
170
|
};
|
|
133
171
|
}
|
|
134
172
|
buildModelSelection(profile, preferred) {
|
|
135
|
-
|
|
136
|
-
|
|
173
|
+
const normalized = preferred?.trim().toLowerCase();
|
|
174
|
+
if (normalized && normalized !== 'inherit' && MODEL_ID_LOOKUP[normalized]) {
|
|
175
|
+
const mapping = MODEL_ID_LOOKUP[normalized];
|
|
137
176
|
return {
|
|
138
177
|
provider: mapping.provider,
|
|
139
178
|
model: mapping.model,
|
|
@@ -148,16 +187,46 @@ export class TaskRunner {
|
|
|
148
187
|
maxTokens: profile.maxTokens,
|
|
149
188
|
};
|
|
150
189
|
}
|
|
151
|
-
composeSystemPrompt(basePrompt, definition, description) {
|
|
190
|
+
composeSystemPrompt(basePrompt, definition, description, extras) {
|
|
191
|
+
const toolLine = extras.allowedTools.length
|
|
192
|
+
? `Allowed tools for this subagent: ${extras.allowedTools.join(', ')}.`
|
|
193
|
+
: 'This subagent inherits all tools available to the parent agent.';
|
|
194
|
+
const missingLine = extras.missingTools.length
|
|
195
|
+
? `Requested but unavailable tools: ${extras.missingTools.join(', ')}.`
|
|
196
|
+
: null;
|
|
197
|
+
const thoroughnessLine = extras.thoroughness
|
|
198
|
+
? `Requested exploration thoroughness: ${extras.thoroughness.replace('_', ' ')}.`
|
|
199
|
+
: null;
|
|
200
|
+
const permissionLine = definition.permissionMode
|
|
201
|
+
? `Permission mode: ${definition.permissionMode}`
|
|
202
|
+
: null;
|
|
203
|
+
const skillsLine = definition.skills && definition.skills.length
|
|
204
|
+
? `Auto-load skills: ${definition.skills.join(', ')}`
|
|
205
|
+
: null;
|
|
206
|
+
const agentMeta = [
|
|
207
|
+
`Subagent: ${definition.name}`,
|
|
208
|
+
`Purpose: ${definition.summary || definition.description}`,
|
|
209
|
+
toolLine,
|
|
210
|
+
missingLine,
|
|
211
|
+
permissionLine,
|
|
212
|
+
skillsLine,
|
|
213
|
+
thoroughnessLine,
|
|
214
|
+
]
|
|
215
|
+
.filter(Boolean)
|
|
216
|
+
.join('\n');
|
|
152
217
|
const lines = [
|
|
153
218
|
basePrompt.trim(),
|
|
154
219
|
'',
|
|
155
220
|
'You are an autonomous sub-agent launched via the Task tool. Operate independently and return a single comprehensive report to the parent agent.',
|
|
156
221
|
`Task summary: ${description}`,
|
|
157
|
-
|
|
222
|
+
agentMeta,
|
|
158
223
|
'',
|
|
159
224
|
'Execution rules:',
|
|
160
|
-
|
|
225
|
+
'- Use ONLY the tools listed above. Do not request tools that are unavailable.',
|
|
226
|
+
'- Keep your own context focused; do not bloat the response with unnecessary content.',
|
|
227
|
+
'- Always cite the evidence, commands, and files you touched so the parent agent can verify your work.',
|
|
228
|
+
'- If you are read-only, explicitly state any edits you avoided and the files you inspected.',
|
|
229
|
+
definition.prompt,
|
|
161
230
|
'',
|
|
162
231
|
'When you finish:',
|
|
163
232
|
'- Provide a concise summary with actionable next steps.',
|
|
@@ -167,6 +236,82 @@ export class TaskRunner {
|
|
|
167
236
|
return lines.join('\n').trim();
|
|
168
237
|
}
|
|
169
238
|
}
|
|
239
|
+
const BASELINE_ALLOWED_TOOLS = ['context_snapshot', 'capabilities_overview', 'profile_details'];
|
|
240
|
+
class RestrictedToolRuntime {
|
|
241
|
+
base;
|
|
242
|
+
allowed;
|
|
243
|
+
constructor(base, allowed) {
|
|
244
|
+
this.base = base;
|
|
245
|
+
this.allowed = allowed;
|
|
246
|
+
}
|
|
247
|
+
listProviderTools() {
|
|
248
|
+
return this.base.listProviderTools().filter((tool) => this.allowed.has(tool.name));
|
|
249
|
+
}
|
|
250
|
+
async execute(call, context) {
|
|
251
|
+
if (!this.allowed.has(call.name)) {
|
|
252
|
+
const allowedList = Array.from(this.allowed).join(', ');
|
|
253
|
+
return `Tool "${call.name}" is not allowed for this agent. Allowed tools: ${allowedList || 'none'}.`;
|
|
254
|
+
}
|
|
255
|
+
return this.base.execute(call, context);
|
|
256
|
+
}
|
|
257
|
+
registerSuite(suite) {
|
|
258
|
+
this.base.registerSuite(suite);
|
|
259
|
+
}
|
|
260
|
+
unregisterSuite(id) {
|
|
261
|
+
this.base.unregisterSuite(id);
|
|
262
|
+
}
|
|
263
|
+
clearCache() {
|
|
264
|
+
this.base.clearCache();
|
|
265
|
+
}
|
|
266
|
+
getCacheStats() {
|
|
267
|
+
return this.base.getCacheStats();
|
|
268
|
+
}
|
|
269
|
+
clearToolHistory() {
|
|
270
|
+
this.base.clearToolHistory();
|
|
271
|
+
}
|
|
272
|
+
getToolHistory() {
|
|
273
|
+
return this.base.getToolHistory();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
function resolveAllowedToolNames(requested, available) {
|
|
277
|
+
const normalizedAvailable = new Map();
|
|
278
|
+
for (const tool of available) {
|
|
279
|
+
normalizedAvailable.set(normalizeToolName(tool.name), tool.name);
|
|
280
|
+
}
|
|
281
|
+
const allowed = new Set();
|
|
282
|
+
const missing = [];
|
|
283
|
+
// Always allow baseline runtime metadata tools
|
|
284
|
+
for (const name of BASELINE_ALLOWED_TOOLS) {
|
|
285
|
+
const normalized = normalizeToolName(name);
|
|
286
|
+
if (normalizedAvailable.has(normalized)) {
|
|
287
|
+
allowed.add(normalizedAvailable.get(normalized));
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
allowed.add(name);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
for (const entry of requested) {
|
|
294
|
+
const normalized = normalizeToolName(entry);
|
|
295
|
+
if (!normalized) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
const exact = normalizedAvailable.get(normalized);
|
|
299
|
+
if (exact) {
|
|
300
|
+
allowed.add(exact);
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
const fuzzy = Array.from(normalizedAvailable.entries()).find(([candidate]) => candidate.includes(normalized) || normalized.includes(candidate));
|
|
304
|
+
if (fuzzy) {
|
|
305
|
+
allowed.add(fuzzy[1]);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
missing.push(entry);
|
|
309
|
+
}
|
|
310
|
+
return { allowedNames: allowed, missing };
|
|
311
|
+
}
|
|
312
|
+
function normalizeToolName(value) {
|
|
313
|
+
return value.replace(/[^a-z0-9]/gi, '').toLowerCase();
|
|
314
|
+
}
|
|
170
315
|
class TaskSnapshotStore {
|
|
171
316
|
async load(id) {
|
|
172
317
|
try {
|
|
@@ -197,18 +342,6 @@ class TaskSnapshotStore {
|
|
|
197
342
|
return `task_${randomUUID()}`;
|
|
198
343
|
}
|
|
199
344
|
}
|
|
200
|
-
function resolveSubAgentDefinition(name) {
|
|
201
|
-
const normalized = name ? name.trim().toLowerCase() : '';
|
|
202
|
-
const candidate = normalized ? SUBAGENT_DEFINITIONS[normalized] : undefined;
|
|
203
|
-
if (candidate) {
|
|
204
|
-
return candidate;
|
|
205
|
-
}
|
|
206
|
-
const fallback = SUBAGENT_DEFINITIONS['general-purpose'];
|
|
207
|
-
if (!fallback) {
|
|
208
|
-
throw new Error('General-purpose subagent definition is missing.');
|
|
209
|
-
}
|
|
210
|
-
return fallback;
|
|
211
|
-
}
|
|
212
345
|
function sanitizeId(value) {
|
|
213
346
|
return value.replace(/[^a-zA-Z0-9_-]/g, '').slice(0, 64) || 'task';
|
|
214
347
|
}
|