0xray 4.0.34 → 4.0.36
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/.grok-plugin/plugin.json +1 -1
- package/.xray/codex.json +12 -4
- package/.xray/features.json +1 -1
- package/AGENTS-consumer.md +6 -6
- package/AGENTS.md +5 -5
- package/README.md +2 -2
- package/dist/AGENTS.md +5 -5
- package/dist/CHANGELOG.md +26 -0
- package/dist/README.md +2 -2
- package/dist/cli/index.js +2 -5
- package/dist/governance/governance-service.js +1 -1
- package/dist/integrations/base/README.md +1 -9
- package/dist/integrations/base/index.d.ts +0 -1
- package/dist/integrations/base/index.js +0 -2
- package/dist/integrations/governance/index.js +31 -8
- package/dist/integrations/grok/hooks/grok-hook-utils.js +1 -1
- package/dist/integrations/grok/hooks/session-start.js +12 -0
- package/dist/integrations/grok/plugin/0xray/hooks/hooks.json +6 -6
- package/dist/integrations/hooks/goggles-mcp.mjs +10 -3
- package/dist/integrations/hooks/goggles-pipeline.mjs +110 -23
- package/dist/integrations/hooks/host-truth.mjs +74 -0
- package/dist/integrations/hooks/station-hook-runtime.cjs +3 -0
- package/dist/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
- package/dist/mcps/knowledge-skills/storyteller.server.js +0 -1
- package/dist/nucleus/delegation-gate.d.ts +2 -2
- package/dist/nucleus/delegation-gate.js +13 -2
- package/dist/nucleus/work-freshness.mjs +189 -0
- package/dist/processors/implementations/agents-md-validation-processor.js +1 -1
- package/docs-site/docs/plates/boot.md +17 -2
- package/docs-site/docs/plates/governance.md +3 -2
- package/docs-site/docs/plates/index.md +3 -1
- package/docs-site/docs/plates/memory-recall.md +26 -35
- package/docs-site/docs/plates/orchestration.md +39 -35
- package/docs-site/docs/plates/processor.md +34 -36
- package/docs-site/docs/plates/reporting.md +3 -8
- package/docs-site/docs/plates/routing.md +22 -11
- package/package.json +3 -2
- package/scripts/foundry/release.mjs +48 -5
- package/scripts/mjs/run-grok-hook.mjs +50 -0
- package/scripts/mjs/test-consumer-readiness.mjs +1 -0
- package/scripts/mjs/test-mcp-functionality.mjs +14 -9
- package/scripts/node/basic-security-audit.cjs +0 -1
- package/scripts/node/bridge-mcp-wiring.cjs +66 -3
- package/scripts/node/install-bridges.cjs +3 -3
- package/scripts/node/postinstall.cjs +1 -1
- package/scripts/node/prepare-consumer.cjs +11 -7
- package/scripts/node/setup-dev.cjs +18 -26
- package/scripts/node/validate-mcp-connectivity.js +2 -1
- package/src/integrations/grok/plugin/0xray/hooks/hooks.json +6 -6
- package/src/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
- package/src/mcps/knowledge-skills/storyteller.server.ts +0 -1
- package/xray/agents_template.md +5 -5
- package/xray/codex.json +12 -4
- package/xray/features.json +1 -1
- package/dist/agents/known-names.d.ts +0 -26
- package/dist/agents/known-names.js +0 -72
- package/dist/analytics/consent-manager.d.ts +0 -92
- package/dist/analytics/consent-manager.js +0 -257
- package/dist/benchmark/performance-benchmark.d.ts +0 -103
- package/dist/benchmark/performance-benchmark.js +0 -373
- package/dist/cli/commands/analytics-disable.d.ts +0 -9
- package/dist/cli/commands/analytics-disable.js +0 -72
- package/dist/cli/commands/analytics-enable-action.d.ts +0 -8
- package/dist/cli/commands/analytics-enable-action.js +0 -82
- package/dist/cli/commands/analytics-preview.d.ts +0 -9
- package/dist/cli/commands/analytics-preview.js +0 -106
- package/dist/cli/commands/analytics-status.d.ts +0 -9
- package/dist/cli/commands/analytics-status.js +0 -68
- package/dist/cli/commands/enforce.d.ts +0 -12
- package/dist/cli/commands/enforce.js +0 -78
- package/dist/cli/commands/govern.d.ts +0 -29
- package/dist/cli/commands/govern.js +0 -149
- package/dist/cli/commands/security-audit.d.ts +0 -23
- package/dist/cli/commands/security-audit.js +0 -219
- package/dist/cli/server.d.ts +0 -1
- package/dist/cli/server.js +0 -147
- package/dist/config/routing-mappings.d.ts +0 -26
- package/dist/config/routing-mappings.js +0 -151
- package/dist/core/bridge.mjs +0 -922
- package/dist/core/trace-context.d.ts +0 -12
- package/dist/core/trace-context.js +0 -33
- package/dist/enforcement/index.d.ts +0 -22
- package/dist/enforcement/index.js +0 -40
- package/dist/enforcement/loaders/index.d.ts +0 -36
- package/dist/enforcement/loaders/index.js +0 -39
- package/dist/enforcement/test-auto-healing.d.ts +0 -83
- package/dist/enforcement/test-auto-healing.js +0 -325
- package/dist/inference/index.d.ts +0 -10
- package/dist/inference/index.js +0 -5
- package/dist/infrastructure/iac-validator.d.ts +0 -150
- package/dist/infrastructure/iac-validator.js +0 -465
- package/dist/infrastructure/schemas/cloud-schemas.d.ts +0 -482
- package/dist/infrastructure/schemas/cloud-schemas.js +0 -488
- package/dist/integrations/base/ExampleIntegration.d.ts +0 -46
- package/dist/integrations/base/ExampleIntegration.js +0 -180
- package/dist/integrations/enforcement-gate.d.ts +0 -44
- package/dist/integrations/enforcement-gate.js +0 -348
- package/dist/mcps/connection/connection-manager.d.ts +0 -39
- package/dist/mcps/connection/connection-manager.js +0 -79
- package/dist/mcps/index.d.ts +0 -17
- package/dist/mcps/index.js +0 -65
- package/dist/mcps/orchestrator/index.d.ts +0 -6
- package/dist/mcps/orchestrator/index.js +0 -5
- package/dist/metrics/index.d.ts +0 -6
- package/dist/metrics/index.js +0 -6
- package/dist/orchestrator/self-direction-activation.d.ts +0 -108
- package/dist/orchestrator/self-direction-activation.js +0 -244
- package/dist/orchestrator/universal-registry-bridge.d.ts +0 -84
- package/dist/orchestrator/universal-registry-bridge.js +0 -246
- package/dist/performance/performance-budget-enforcer.d.ts +0 -157
- package/dist/performance/performance-budget-enforcer.js +0 -433
- package/dist/performance/performance-regression-tester.d.ts +0 -107
- package/dist/performance/performance-regression-tester.js +0 -341
- package/dist/postprocessor/analysis/CodeChangeAnalyzer.d.ts +0 -11
- package/dist/postprocessor/analysis/CodeChangeAnalyzer.js +0 -50
- package/dist/postprocessor/config/ProcessorConfigLoader.d.ts +0 -44
- package/dist/postprocessor/config/ProcessorConfigLoader.js +0 -16
- package/dist/postprocessor/integration.d.ts +0 -156
- package/dist/postprocessor/integration.js +0 -194
- package/dist/postprocessor/metamorphosis/index.d.ts +0 -2
- package/dist/postprocessor/metamorphosis/index.js +0 -1
- package/dist/postprocessor/redeploy/RetryHandler.d.ts +0 -49
- package/dist/postprocessor/redeploy/RetryHandler.js +0 -118
- package/dist/processors/implementations/session-capture-processor.d.ts +0 -14
- package/dist/processors/implementations/session-capture-processor.js +0 -37
- package/dist/public/XrayService.d.ts +0 -17
- package/dist/public/XrayService.js +0 -40
- package/dist/public/index.d.ts +0 -4
- package/dist/public/index.js +0 -2
- package/dist/security/comprehensive-security-audit.d.ts +0 -157
- package/dist/security/comprehensive-security-audit.js +0 -1004
- package/dist/security/index.d.ts +0 -13
- package/dist/security/index.js +0 -13
- package/dist/security/security-agent-coordinator.d.ts +0 -71
- package/dist/security/security-agent-coordinator.js +0 -203
- package/dist/security/security-hardening-system.d.ts +0 -238
- package/dist/security/security-hardening-system.js +0 -726
- package/dist/security/security-orchestration-layer.d.ts +0 -118
- package/dist/security/security-orchestration-layer.js +0 -495
- package/dist/testing/memory-regression-suite.d.ts +0 -105
- package/dist/testing/memory-regression-suite.js +0 -258
- package/dist/tools/assess-complexity-tool.d.ts +0 -28
- package/dist/tools/assess-complexity-tool.js +0 -44
- package/dist/tools/query-routing-tool.d.ts +0 -17
- package/dist/tools/query-routing-tool.js +0 -59
- package/dist/utils/batch-operations.d.ts +0 -25
- package/dist/utils/batch-operations.js +0 -292
- package/dist/utils/task-graph.d.ts +0 -29
- package/dist/utils/task-graph.js +0 -106
- package/dist/utils/test-template-generator.d.ts +0 -25
- package/dist/utils/test-template-generator.js +0 -178
- package/dist/utils/token-manager.d.ts +0 -48
- package/dist/utils/token-manager.js +0 -163
- package/dist/validation/agent-config-validator.d.ts +0 -110
- package/dist/validation/agent-config-validator.js +0 -280
- package/dist/validation/orchestration-flow-validator.d.ts +0 -87
- package/dist/validation/orchestration-flow-validator.js +0 -606
- package/src/mcps/connection/connection-manager.ts +0 -91
- package/src/mcps/index.ts +0 -80
- package/src/mcps/orchestrator/index.ts +0 -29
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { resolveConfigPath } from "../core/config-paths.js";
|
|
4
|
-
export class TokenManager {
|
|
5
|
-
config;
|
|
6
|
-
constructor(configPath = resolveConfigPath("config.json") || path.join(process.cwd(), ".xray", "config.json")) {
|
|
7
|
-
this.config = this.loadConfig(configPath);
|
|
8
|
-
}
|
|
9
|
-
loadConfig(configPath) {
|
|
10
|
-
try {
|
|
11
|
-
const config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
12
|
-
return (config.token_management || {
|
|
13
|
-
maxPromptTokens: 20000,
|
|
14
|
-
warningThreshold: 15000,
|
|
15
|
-
modelLimits: {},
|
|
16
|
-
contextPruning: {
|
|
17
|
-
enabled: true,
|
|
18
|
-
aggressivePruning: true,
|
|
19
|
-
preserveCriticalContext: true,
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
// Fallback defaults if config loading fails
|
|
25
|
-
return {
|
|
26
|
-
maxPromptTokens: 20000,
|
|
27
|
-
warningThreshold: 15000,
|
|
28
|
-
modelLimits: {},
|
|
29
|
-
contextPruning: {
|
|
30
|
-
enabled: true,
|
|
31
|
-
aggressivePruning: true,
|
|
32
|
-
preserveCriticalContext: true,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Estimate token count for text (rough approximation)
|
|
39
|
-
* Uses 4 characters per token as a conservative estimate
|
|
40
|
-
*/
|
|
41
|
-
estimateTokens(text) {
|
|
42
|
-
return Math.ceil(text.length / 4);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Check if prompt exceeds limits
|
|
46
|
-
*/
|
|
47
|
-
checkLimits(prompt, modelName) {
|
|
48
|
-
const currentTokens = this.estimateTokens(prompt);
|
|
49
|
-
const maxTokens = modelName
|
|
50
|
-
? this.config.modelLimits[modelName] || this.config.maxPromptTokens
|
|
51
|
-
: this.config.maxPromptTokens;
|
|
52
|
-
const withinLimit = currentTokens <= maxTokens;
|
|
53
|
-
const needsPruning = currentTokens > this.config.maxPromptTokens;
|
|
54
|
-
const warning = currentTokens > this.config.warningThreshold;
|
|
55
|
-
return {
|
|
56
|
-
withinLimit,
|
|
57
|
-
currentTokens,
|
|
58
|
-
maxTokens,
|
|
59
|
-
needsPruning,
|
|
60
|
-
warning,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Prune context to fit within token limits
|
|
65
|
-
*/
|
|
66
|
-
pruneContext(context, targetTokens = this.config.maxPromptTokens) {
|
|
67
|
-
if (!this.config.contextPruning.enabled) {
|
|
68
|
-
return context;
|
|
69
|
-
}
|
|
70
|
-
const currentTokens = this.estimateTokens(context);
|
|
71
|
-
if (currentTokens <= targetTokens) {
|
|
72
|
-
return context; // No pruning needed
|
|
73
|
-
}
|
|
74
|
-
// Preserve critical sections (AGENTS.md header, codex terms, etc.)
|
|
75
|
-
const criticalSections = this.extractCriticalSections(context);
|
|
76
|
-
const criticalTokens = this.estimateTokens(criticalSections.join("\n"));
|
|
77
|
-
// Calculate available tokens for non-critical content
|
|
78
|
-
const availableTokens = Math.max(targetTokens - criticalTokens, targetTokens * 0.3); // Reserve at least 30%
|
|
79
|
-
const nonCriticalContent = this.extractNonCriticalContent(context);
|
|
80
|
-
const prunedNonCritical = this.pruneNonCriticalContent(nonCriticalContent, availableTokens);
|
|
81
|
-
return `${criticalSections.join("\n")}\n\n${prunedNonCritical}`;
|
|
82
|
-
}
|
|
83
|
-
extractCriticalSections(context) {
|
|
84
|
-
const lines = context.split("\n");
|
|
85
|
-
const criticalSections = [];
|
|
86
|
-
// Always preserve codex terms and framework overview
|
|
87
|
-
const codexSection = this.extractSection(lines, "Universal Development Codex");
|
|
88
|
-
const frameworkSection = this.extractSection(lines, "0xRay Framework");
|
|
89
|
-
if (codexSection)
|
|
90
|
-
criticalSections.push(codexSection);
|
|
91
|
-
if (frameworkSection)
|
|
92
|
-
criticalSections.push(frameworkSection);
|
|
93
|
-
return criticalSections;
|
|
94
|
-
}
|
|
95
|
-
extractSection(lines, sectionTitle) {
|
|
96
|
-
const startIndex = lines.findIndex((line) => line.includes(sectionTitle));
|
|
97
|
-
if (startIndex === -1)
|
|
98
|
-
return null;
|
|
99
|
-
let endIndex = lines.length;
|
|
100
|
-
for (let i = startIndex + 1; i < lines.length; i++) {
|
|
101
|
-
const currentLine = lines[i];
|
|
102
|
-
if (currentLine &&
|
|
103
|
-
currentLine.startsWith("#") &&
|
|
104
|
-
currentLine !== lines[startIndex]) {
|
|
105
|
-
endIndex = i;
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return lines.slice(startIndex, endIndex).join("\n");
|
|
110
|
-
}
|
|
111
|
-
extractNonCriticalContent(context) {
|
|
112
|
-
const criticalSections = this.extractCriticalSections(context);
|
|
113
|
-
let result = context;
|
|
114
|
-
for (const section of criticalSections) {
|
|
115
|
-
result = result.replace(section, "");
|
|
116
|
-
}
|
|
117
|
-
return result.trim();
|
|
118
|
-
}
|
|
119
|
-
pruneNonCriticalContent(content, maxTokens) {
|
|
120
|
-
const lines = content.split("\n");
|
|
121
|
-
const result = [];
|
|
122
|
-
let currentTokens = 0;
|
|
123
|
-
for (const line of lines) {
|
|
124
|
-
const lineTokens = this.estimateTokens(line);
|
|
125
|
-
if (currentTokens + lineTokens <= maxTokens) {
|
|
126
|
-
result.push(line);
|
|
127
|
-
currentTokens += lineTokens;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
// Truncate line if too long
|
|
131
|
-
if (lineTokens > maxTokens * 0.1) {
|
|
132
|
-
// If single line is >10% of limit
|
|
133
|
-
const maxChars = maxTokens * 4 * 0.1; // Convert tokens to chars
|
|
134
|
-
result.push(line.substring(0, maxChars) + "...[truncated]");
|
|
135
|
-
}
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return result.join("\n");
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Generate warning message for token limits
|
|
143
|
-
*/
|
|
144
|
-
generateWarning(limitCheck) {
|
|
145
|
-
if (limitCheck.withinLimit && !limitCheck.warning)
|
|
146
|
-
return "";
|
|
147
|
-
const messages = [];
|
|
148
|
-
if (limitCheck.warning) {
|
|
149
|
-
messages.push(`⚠️ Token usage warning: ${limitCheck.currentTokens.toLocaleString()} tokens (${((limitCheck.currentTokens / limitCheck.maxTokens) * 100).toFixed(1)}% of limit)`);
|
|
150
|
-
}
|
|
151
|
-
if (!limitCheck.withinLimit) {
|
|
152
|
-
messages.push(`🚨 Token limit exceeded: ${limitCheck.currentTokens.toLocaleString()} > ${limitCheck.maxTokens.toLocaleString()} tokens`);
|
|
153
|
-
messages.push("Context will be automatically pruned to fit within limits.");
|
|
154
|
-
}
|
|
155
|
-
return messages.join("\n");
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Get current configuration
|
|
159
|
-
*/
|
|
160
|
-
getConfig() {
|
|
161
|
-
return { ...this.config };
|
|
162
|
-
}
|
|
163
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Configuration Validator
|
|
3
|
-
*
|
|
4
|
-
* Validates agent configuration files for correctness and completeness
|
|
5
|
-
* ensuring all required fields are present and properly formatted.
|
|
6
|
-
*
|
|
7
|
-
* @since 2026-01-23
|
|
8
|
-
*/
|
|
9
|
-
export interface AgentConfig {
|
|
10
|
-
name: string;
|
|
11
|
-
description: string;
|
|
12
|
-
version: string;
|
|
13
|
-
model: string;
|
|
14
|
-
mode: "primary" | "subagent";
|
|
15
|
-
logging?: {
|
|
16
|
-
level: string;
|
|
17
|
-
format: string;
|
|
18
|
-
destinations: string[];
|
|
19
|
-
retention_days?: number;
|
|
20
|
-
sensitive_data_filtering?: boolean;
|
|
21
|
-
audit_trail?: boolean;
|
|
22
|
-
};
|
|
23
|
-
processor_pipeline?: Array<{
|
|
24
|
-
name: string;
|
|
25
|
-
type: string;
|
|
26
|
-
priority: "low" | "medium" | "high" | "critical";
|
|
27
|
-
timeout_ms?: number;
|
|
28
|
-
retry_attempts?: number;
|
|
29
|
-
}>;
|
|
30
|
-
capabilities?: string[];
|
|
31
|
-
error_handling?: {
|
|
32
|
-
retry_attempts?: number;
|
|
33
|
-
circuit_breaker?: {
|
|
34
|
-
enabled?: boolean;
|
|
35
|
-
failure_threshold?: number;
|
|
36
|
-
recovery_timeout_ms?: number;
|
|
37
|
-
};
|
|
38
|
-
fallback_strategy?: string;
|
|
39
|
-
alert_on_failure?: boolean;
|
|
40
|
-
};
|
|
41
|
-
performance?: {
|
|
42
|
-
timeout_ms?: number;
|
|
43
|
-
concurrency_limit?: number;
|
|
44
|
-
memory_limit_mb?: number;
|
|
45
|
-
cpu_limit_percent?: number;
|
|
46
|
-
};
|
|
47
|
-
security?: {
|
|
48
|
-
sandboxed_execution?: boolean;
|
|
49
|
-
permission_level?: string;
|
|
50
|
-
data_classification?: string;
|
|
51
|
-
encryption_required?: boolean;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
export interface ValidationResult {
|
|
55
|
-
valid: boolean;
|
|
56
|
-
errors: string[];
|
|
57
|
-
warnings: string[];
|
|
58
|
-
config: AgentConfig | null;
|
|
59
|
-
}
|
|
60
|
-
export declare class AgentConfigValidator {
|
|
61
|
-
private readonly requiredFields;
|
|
62
|
-
private readonly validModes;
|
|
63
|
-
private readonly validLogLevels;
|
|
64
|
-
private readonly validLogFormats;
|
|
65
|
-
private readonly validPriorities;
|
|
66
|
-
private readonly validProcessorTypes;
|
|
67
|
-
/**
|
|
68
|
-
* Validate agent configuration from file
|
|
69
|
-
*/
|
|
70
|
-
validateConfigFile(filePath: string): Promise<ValidationResult>;
|
|
71
|
-
/**
|
|
72
|
-
* Validate agent configuration object
|
|
73
|
-
*/
|
|
74
|
-
validateConfig(config: AgentConfig): ValidationResult;
|
|
75
|
-
/**
|
|
76
|
-
* Validate logging configuration
|
|
77
|
-
*/
|
|
78
|
-
private validateLoggingConfig;
|
|
79
|
-
/**
|
|
80
|
-
* Validate processor pipeline configuration
|
|
81
|
-
*/
|
|
82
|
-
private validateProcessorPipeline;
|
|
83
|
-
/**
|
|
84
|
-
* Validate performance configuration
|
|
85
|
-
*/
|
|
86
|
-
private validatePerformanceConfig;
|
|
87
|
-
/**
|
|
88
|
-
* Validate security configuration
|
|
89
|
-
*/
|
|
90
|
-
private validateSecurityConfig;
|
|
91
|
-
/**
|
|
92
|
-
* Validate error handling configuration
|
|
93
|
-
*/
|
|
94
|
-
private validateErrorHandlingConfig;
|
|
95
|
-
/**
|
|
96
|
-
* Validate all agent configurations in a directory
|
|
97
|
-
*/
|
|
98
|
-
validateAllAgentConfigs(agentConfigDir?: string): Promise<{
|
|
99
|
-
results: Array<{
|
|
100
|
-
file: string;
|
|
101
|
-
result: ValidationResult;
|
|
102
|
-
}>;
|
|
103
|
-
summary: {
|
|
104
|
-
total: number;
|
|
105
|
-
valid: number;
|
|
106
|
-
invalid: number;
|
|
107
|
-
};
|
|
108
|
-
}>;
|
|
109
|
-
}
|
|
110
|
-
export declare const agentConfigValidator: AgentConfigValidator;
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Configuration Validator
|
|
3
|
-
*
|
|
4
|
-
* Validates agent configuration files for correctness and completeness
|
|
5
|
-
* ensuring all required fields are present and properly formatted.
|
|
6
|
-
*
|
|
7
|
-
* @since 2026-01-23
|
|
8
|
-
*/
|
|
9
|
-
import { frameworkLogger } from "../core/framework-logger.js";
|
|
10
|
-
import * as fs from "fs";
|
|
11
|
-
import * as path from "path";
|
|
12
|
-
import * as yaml from "yaml";
|
|
13
|
-
export class AgentConfigValidator {
|
|
14
|
-
requiredFields = [
|
|
15
|
-
"name",
|
|
16
|
-
"description",
|
|
17
|
-
"version",
|
|
18
|
-
"model",
|
|
19
|
-
"mode",
|
|
20
|
-
];
|
|
21
|
-
validModes = ["primary", "subagent"];
|
|
22
|
-
validLogLevels = ["debug", "info", "warn", "error"];
|
|
23
|
-
validLogFormats = ["json", "text"];
|
|
24
|
-
validPriorities = ["low", "medium", "high", "critical"];
|
|
25
|
-
validProcessorTypes = [
|
|
26
|
-
"validation",
|
|
27
|
-
"orchestration",
|
|
28
|
-
"monitoring",
|
|
29
|
-
];
|
|
30
|
-
/**
|
|
31
|
-
* Validate agent configuration from file
|
|
32
|
-
*/
|
|
33
|
-
async validateConfigFile(filePath) {
|
|
34
|
-
const jobId = `validate-config-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
35
|
-
try {
|
|
36
|
-
// Check if file exists
|
|
37
|
-
if (!fs.existsSync(filePath)) {
|
|
38
|
-
return {
|
|
39
|
-
valid: false,
|
|
40
|
-
errors: [`Configuration file does not exist: ${filePath}`],
|
|
41
|
-
warnings: [],
|
|
42
|
-
config: null,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
// Read and parse file
|
|
46
|
-
const content = fs.readFileSync(filePath, "utf8");
|
|
47
|
-
let config;
|
|
48
|
-
if (filePath.endsWith(".yml") || filePath.endsWith(".yaml")) {
|
|
49
|
-
config = yaml.parse(content);
|
|
50
|
-
}
|
|
51
|
-
else if (filePath.endsWith(".json")) {
|
|
52
|
-
config = JSON.parse(content);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
return {
|
|
56
|
-
valid: false,
|
|
57
|
-
errors: [`Unsupported file format: ${path.extname(filePath)}`],
|
|
58
|
-
warnings: [],
|
|
59
|
-
config: null,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
const result = this.validateConfig(config);
|
|
63
|
-
frameworkLogger.log("agent-config-validator", `Configuration validation ${result.valid ? "passed" : "failed"} for ${filePath}`, result.valid ? "success" : "error", {
|
|
64
|
-
jobId,
|
|
65
|
-
filePath,
|
|
66
|
-
errorCount: result.errors.length,
|
|
67
|
-
warningCount: result.warnings.length,
|
|
68
|
-
});
|
|
69
|
-
return {
|
|
70
|
-
...result,
|
|
71
|
-
config: result.valid ? config : null,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
frameworkLogger.log("agent-config-validator", `Configuration validation error for ${filePath}`, "error", {
|
|
76
|
-
jobId,
|
|
77
|
-
error: error instanceof Error ? error.message : String(error),
|
|
78
|
-
});
|
|
79
|
-
return {
|
|
80
|
-
valid: false,
|
|
81
|
-
errors: [
|
|
82
|
-
`Failed to parse configuration: ${error instanceof Error ? error.message : String(error)}`,
|
|
83
|
-
],
|
|
84
|
-
warnings: [],
|
|
85
|
-
config: null,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Validate agent configuration object
|
|
91
|
-
*/
|
|
92
|
-
validateConfig(config) {
|
|
93
|
-
const errors = [];
|
|
94
|
-
const warnings = [];
|
|
95
|
-
// Check required fields
|
|
96
|
-
for (const field of this.requiredFields) {
|
|
97
|
-
if (!config[field]) {
|
|
98
|
-
errors.push(`Missing required field: ${field}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
// Validate mode
|
|
102
|
-
if (config.mode && !this.validModes.includes(config.mode)) {
|
|
103
|
-
errors.push(`Invalid mode '${config.mode}'. Must be one of: ${this.validModes.join(", ")}`);
|
|
104
|
-
}
|
|
105
|
-
// Validate logging configuration
|
|
106
|
-
if (config.logging) {
|
|
107
|
-
this.validateLoggingConfig(config.logging, errors, warnings);
|
|
108
|
-
}
|
|
109
|
-
// Validate processor pipeline
|
|
110
|
-
if (config.processor_pipeline) {
|
|
111
|
-
this.validateProcessorPipeline(config.processor_pipeline, errors, warnings);
|
|
112
|
-
}
|
|
113
|
-
// Validate performance configuration
|
|
114
|
-
if (config.performance) {
|
|
115
|
-
this.validatePerformanceConfig(config.performance, errors, warnings);
|
|
116
|
-
}
|
|
117
|
-
// Validate security configuration
|
|
118
|
-
if (config.security) {
|
|
119
|
-
this.validateSecurityConfig(config.security, errors, warnings);
|
|
120
|
-
}
|
|
121
|
-
// Validate error handling configuration
|
|
122
|
-
if (config.error_handling) {
|
|
123
|
-
this.validateErrorHandlingConfig(config.error_handling, errors, warnings);
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
valid: errors.length === 0,
|
|
127
|
-
errors,
|
|
128
|
-
warnings,
|
|
129
|
-
config: null,
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Validate logging configuration
|
|
134
|
-
*/
|
|
135
|
-
validateLoggingConfig(logging, errors, warnings) {
|
|
136
|
-
if (logging.level && !this.validLogLevels.includes(logging.level)) {
|
|
137
|
-
errors.push(`Invalid log level '${logging.level}'. Must be one of: ${this.validLogLevels.join(", ")}`);
|
|
138
|
-
}
|
|
139
|
-
if (logging.format && !this.validLogFormats.includes(logging.format)) {
|
|
140
|
-
errors.push(`Invalid log format '${logging.format}'. Must be one of: ${this.validLogFormats.join(", ")}`);
|
|
141
|
-
}
|
|
142
|
-
if (logging.destinations && !Array.isArray(logging.destinations)) {
|
|
143
|
-
errors.push("logging.destinations must be an array");
|
|
144
|
-
}
|
|
145
|
-
if (logging.retention_days &&
|
|
146
|
-
(typeof logging.retention_days !== "number" || logging.retention_days < 1)) {
|
|
147
|
-
errors.push("logging.retention_days must be a positive number");
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Validate processor pipeline configuration
|
|
152
|
-
*/
|
|
153
|
-
validateProcessorPipeline(pipeline, errors, warnings) {
|
|
154
|
-
if (!Array.isArray(pipeline)) {
|
|
155
|
-
errors.push("processor_pipeline must be an array");
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
pipeline.forEach((processor, index) => {
|
|
159
|
-
if (!processor.name) {
|
|
160
|
-
errors.push(`processor_pipeline[${index}]: missing 'name' field`);
|
|
161
|
-
}
|
|
162
|
-
if (!processor.type) {
|
|
163
|
-
errors.push(`processor_pipeline[${index}]: missing 'type' field`);
|
|
164
|
-
}
|
|
165
|
-
else if (!this.validProcessorTypes.includes(processor.type)) {
|
|
166
|
-
errors.push(`processor_pipeline[${index}]: invalid type '${processor.type}'. Must be one of: ${this.validProcessorTypes.join(", ")}`);
|
|
167
|
-
}
|
|
168
|
-
if (!processor.priority) {
|
|
169
|
-
errors.push(`processor_pipeline[${index}]: missing 'priority' field`);
|
|
170
|
-
}
|
|
171
|
-
else if (!this.validPriorities.includes(processor.priority)) {
|
|
172
|
-
errors.push(`processor_pipeline[${index}]: invalid priority '${processor.priority}'. Must be one of: ${this.validPriorities.join(", ")}`);
|
|
173
|
-
}
|
|
174
|
-
if (processor.timeout_ms &&
|
|
175
|
-
(typeof processor.timeout_ms !== "number" || processor.timeout_ms < 0)) {
|
|
176
|
-
errors.push(`processor_pipeline[${index}]: timeout_ms must be a non-negative number`);
|
|
177
|
-
}
|
|
178
|
-
if (processor.retry_attempts &&
|
|
179
|
-
(typeof processor.retry_attempts !== "number" ||
|
|
180
|
-
processor.retry_attempts < 0)) {
|
|
181
|
-
errors.push(`processor_pipeline[${index}]: retry_attempts must be a non-negative number`);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Validate performance configuration
|
|
187
|
-
*/
|
|
188
|
-
validatePerformanceConfig(performance, errors, warnings) {
|
|
189
|
-
if (performance.timeout_ms &&
|
|
190
|
-
(typeof performance.timeout_ms !== "number" || performance.timeout_ms < 0)) {
|
|
191
|
-
errors.push("performance.timeout_ms must be a non-negative number");
|
|
192
|
-
}
|
|
193
|
-
if (performance.concurrency_limit &&
|
|
194
|
-
(typeof performance.concurrency_limit !== "number" ||
|
|
195
|
-
performance.concurrency_limit < 1)) {
|
|
196
|
-
errors.push("performance.concurrency_limit must be a positive number");
|
|
197
|
-
}
|
|
198
|
-
if (performance.memory_limit_mb &&
|
|
199
|
-
(typeof performance.memory_limit_mb !== "number" ||
|
|
200
|
-
performance.memory_limit_mb < 1)) {
|
|
201
|
-
errors.push("performance.memory_limit_mb must be a positive number");
|
|
202
|
-
}
|
|
203
|
-
if (performance.cpu_limit_percent &&
|
|
204
|
-
(typeof performance.cpu_limit_percent !== "number" ||
|
|
205
|
-
performance.cpu_limit_percent < 1 ||
|
|
206
|
-
performance.cpu_limit_percent > 100)) {
|
|
207
|
-
errors.push("performance.cpu_limit_percent must be between 1 and 100");
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Validate security configuration
|
|
212
|
-
*/
|
|
213
|
-
validateSecurityConfig(security, errors, warnings) {
|
|
214
|
-
if (security.permission_level &&
|
|
215
|
-
typeof security.permission_level !== "string") {
|
|
216
|
-
errors.push("security.permission_level must be a string");
|
|
217
|
-
}
|
|
218
|
-
if (security.data_classification &&
|
|
219
|
-
typeof security.data_classification !== "string") {
|
|
220
|
-
errors.push("security.data_classification must be a string");
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Validate error handling configuration
|
|
225
|
-
*/
|
|
226
|
-
validateErrorHandlingConfig(errorHandling, errors, warnings) {
|
|
227
|
-
if (errorHandling.retry_attempts &&
|
|
228
|
-
(typeof errorHandling.retry_attempts !== "number" ||
|
|
229
|
-
errorHandling.retry_attempts < 0)) {
|
|
230
|
-
errors.push("error_handling.retry_attempts must be a non-negative number");
|
|
231
|
-
}
|
|
232
|
-
if (errorHandling.circuit_breaker) {
|
|
233
|
-
const cb = errorHandling.circuit_breaker;
|
|
234
|
-
if (cb.failure_threshold &&
|
|
235
|
-
(typeof cb.failure_threshold !== "number" || cb.failure_threshold < 1)) {
|
|
236
|
-
errors.push("error_handling.circuit_breaker.failure_threshold must be a positive number");
|
|
237
|
-
}
|
|
238
|
-
if (cb.recovery_timeout_ms &&
|
|
239
|
-
(typeof cb.recovery_timeout_ms !== "number" ||
|
|
240
|
-
cb.recovery_timeout_ms < 0)) {
|
|
241
|
-
errors.push("error_handling.circuit_breaker.recovery_timeout_ms must be a non-negative number");
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Validate all agent configurations in a directory
|
|
247
|
-
*/
|
|
248
|
-
async validateAllAgentConfigs(agentConfigDir = ".opencode/agents") {
|
|
249
|
-
const results = [];
|
|
250
|
-
// Gracefully handle missing agent config directory (headless/no .opencode/ mode)
|
|
251
|
-
if (!fs.existsSync(agentConfigDir)) {
|
|
252
|
-
frameworkLogger.log("agent-config-validator", `Agent config directory not found, skipping validation: ${agentConfigDir}`, "warning", {});
|
|
253
|
-
return {
|
|
254
|
-
results: [],
|
|
255
|
-
summary: { total: 0, valid: 0, invalid: 0 },
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
try {
|
|
259
|
-
const files = fs.readdirSync(agentConfigDir);
|
|
260
|
-
const configFiles = files.filter((f) => f.endsWith(".yml") || f.endsWith(".yaml") || f.endsWith(".json"));
|
|
261
|
-
for (const file of configFiles) {
|
|
262
|
-
const filePath = path.join(agentConfigDir, file);
|
|
263
|
-
const result = await this.validateConfigFile(filePath);
|
|
264
|
-
results.push({ file, result });
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
catch (error) {
|
|
268
|
-
frameworkLogger.log("agent-config-validator", "Failed to read agent config directory", "error", { error: error instanceof Error ? error.message : String(error) });
|
|
269
|
-
}
|
|
270
|
-
const summary = {
|
|
271
|
-
total: results.length,
|
|
272
|
-
valid: results.filter((r) => r.result.valid).length,
|
|
273
|
-
invalid: results.length - results.filter((r) => r.result.valid).length,
|
|
274
|
-
};
|
|
275
|
-
frameworkLogger.log("agent-config-validator", `Validated ${summary.total} agent configurations: ${summary.valid} valid, ${summary.invalid} invalid`, summary.invalid > 0 ? "error" : "info");
|
|
276
|
-
return { results, summary };
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
// Export singleton instance
|
|
280
|
-
export const agentConfigValidator = new AgentConfigValidator();
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* COMPREHENSIVE ORCHESTRATION FLOW VALIDATION SUITE
|
|
3
|
-
* Validates the complete end-to-end orchestration pipeline
|
|
4
|
-
*/
|
|
5
|
-
interface TestResult {
|
|
6
|
-
testName: string;
|
|
7
|
-
success: boolean;
|
|
8
|
-
duration: number;
|
|
9
|
-
error?: string;
|
|
10
|
-
metrics: {
|
|
11
|
-
agentsSpawned: number;
|
|
12
|
-
agentsCompleted: number;
|
|
13
|
-
agentsFailed: number;
|
|
14
|
-
dependenciesResolved: number;
|
|
15
|
-
monitoringUpdates: number;
|
|
16
|
-
};
|
|
17
|
-
validationSteps: ValidationStep[];
|
|
18
|
-
}
|
|
19
|
-
interface ValidationStep {
|
|
20
|
-
step: string;
|
|
21
|
-
success: boolean;
|
|
22
|
-
timestamp: number;
|
|
23
|
-
details?: unknown;
|
|
24
|
-
}
|
|
25
|
-
declare class OrchestrationFlowValidator {
|
|
26
|
-
private orchestrator;
|
|
27
|
-
private stateManager;
|
|
28
|
-
private agentDelegator;
|
|
29
|
-
private testResults;
|
|
30
|
-
constructor();
|
|
31
|
-
/**
|
|
32
|
-
* SIMULATION 1: Basic Orchestration Flow
|
|
33
|
-
* Tests the fundamental orchestration pipeline
|
|
34
|
-
*/
|
|
35
|
-
testBasicOrchestrationFlow(): Promise<TestResult>;
|
|
36
|
-
/**
|
|
37
|
-
* SIMULATION 2: Dependency Management Flow
|
|
38
|
-
* Tests complex task dependencies and sequencing
|
|
39
|
-
*/
|
|
40
|
-
testDependencyManagementFlow(): Promise<TestResult>;
|
|
41
|
-
/**
|
|
42
|
-
* SIMULATION 3: Error Handling & Recovery Flow
|
|
43
|
-
* Tests system resilience and fallback mechanisms
|
|
44
|
-
*/
|
|
45
|
-
testErrorHandlingFlow(): Promise<TestResult>;
|
|
46
|
-
/**
|
|
47
|
-
* SIMULATION 4: Performance & Scalability Flow
|
|
48
|
-
* Tests system performance under load
|
|
49
|
-
*/
|
|
50
|
-
testPerformanceFlow(): Promise<TestResult>;
|
|
51
|
-
/**
|
|
52
|
-
* SIMULATION 5: Monitoring & Cleanup Flow
|
|
53
|
-
* Tests the complete monitoring and cleanup lifecycle
|
|
54
|
-
*/
|
|
55
|
-
testMonitoringCleanupFlow(): Promise<TestResult>;
|
|
56
|
-
/**
|
|
57
|
-
* Run all orchestration flow validations
|
|
58
|
-
*/
|
|
59
|
-
runCompleteValidationSuite(): Promise<ValidationSuiteResults>;
|
|
60
|
-
/**
|
|
61
|
-
* Generate comprehensive validation report
|
|
62
|
-
*/
|
|
63
|
-
private generateValidationReport;
|
|
64
|
-
/**
|
|
65
|
-
* Generate recommendations based on test results
|
|
66
|
-
*/
|
|
67
|
-
private generateRecommendations;
|
|
68
|
-
}
|
|
69
|
-
interface ValidationSuiteResults {
|
|
70
|
-
summary: {
|
|
71
|
-
totalTests: number;
|
|
72
|
-
passedTests: number;
|
|
73
|
-
failedTests: number;
|
|
74
|
-
successRate: number;
|
|
75
|
-
totalDuration: number;
|
|
76
|
-
avgDuration: number;
|
|
77
|
-
};
|
|
78
|
-
metrics: {
|
|
79
|
-
totalAgentsSpawned: number;
|
|
80
|
-
totalAgentsCompleted: number;
|
|
81
|
-
totalDependenciesResolved: number;
|
|
82
|
-
totalMonitoringUpdates: number;
|
|
83
|
-
};
|
|
84
|
-
testResults: TestResult[];
|
|
85
|
-
recommendations: string[];
|
|
86
|
-
}
|
|
87
|
-
export { OrchestrationFlowValidator };
|