0xray 3.1.1 → 3.3.0
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/.opencode/codex.codex +1 -1
- package/.opencode/commands/auto-format.md +3 -3
- package/.opencode/commands/auto-summary-capture.md +2 -2
- package/.opencode/commands/enforcer-daily-scan.md +3 -3
- package/.opencode/commands/framework-compliance-audit.md +4 -4
- package/.opencode/commands/interactive-validator.md +2 -2
- package/.opencode/commands/job-summary-logger.md +2 -2
- package/.opencode/commands/mode-switch.md +1 -1
- package/.opencode/commands/model-health-check.md +2 -2
- package/.opencode/commands/performance-analysis.md +2 -2
- package/.opencode/commands/pre-commit-introspection.md +3 -3
- package/.opencode/commands/security-scan.md +3 -3
- package/.opencode/commands/sisyphus-validation.md +3 -3
- package/.opencode/commands/summary-logger.md +2 -2
- package/AGENTS.md +3 -13
- package/README.md +3 -3
- package/dist/AGENTS.md +3 -13
- package/dist/CHANGELOG.md +55 -0
- package/dist/README.md +3 -3
- package/dist/analytics/consent-manager.js +0 -1
- package/dist/analytics/emerging-pattern-detector.js +0 -1
- package/dist/analytics/pattern-learning-engine.js +0 -1
- package/dist/analytics/pattern-performance-tracker.js +0 -1
- package/dist/analytics/predictive-analytics.js +0 -1
- package/dist/analytics/prompt-pattern-analyzer.js +0 -1
- package/dist/analytics/routing-performance-analyzer.js +0 -1
- package/dist/analytics/routing-refiner.js +0 -1
- package/dist/analytics/simple-pattern-analyzer.js +0 -1
- package/dist/cli/commands/archive-logs.js +0 -1
- package/dist/cli/commands/opencode-install.js +13 -0
- package/dist/cli/commands/plugin-commands.js +0 -1
- package/dist/cli/commands/status.js +11 -13
- package/dist/cli/index.js +2 -7
- package/dist/core/activity-logger.js +0 -1
- package/dist/core/adaptive-kernel.js +0 -1
- package/dist/core/boot-orchestrator.js +2 -12
- package/dist/core/bridge.mjs +0 -1
- package/dist/core/codex-formatter.js +0 -1
- package/dist/core/codex-injector.js +0 -1
- package/dist/core/config-loader.js +36 -28
- package/dist/core/context-loader.js +0 -1
- package/dist/core/context-validator.js +0 -1
- package/dist/core/features-config.js +40 -1
- package/dist/core/kernel-patterns.js +0 -1
- package/dist/core/model-router.js +23 -64
- package/dist/core/system-prompt-generator.js +0 -1
- package/dist/delegation/agent-delegator.js +0 -1
- package/dist/delegation/agent-expertise.js +0 -1
- package/dist/delegation/analytics/index.js +0 -1
- package/dist/delegation/analytics/learning-engine.js +0 -1
- package/dist/delegation/analytics/outcome-tracker.js +0 -1
- package/dist/delegation/analytics/routing-analytics.js +0 -1
- package/dist/delegation/ast-code-parser.js +0 -1
- package/dist/delegation/complexity-analyzer.js +0 -1
- package/dist/delegation/dependency-graph-builder.js +0 -1
- package/dist/delegation/index.js +0 -1
- package/dist/delegation/metrics-aggregator.js +0 -1
- package/dist/delegation/session-coordinator.js +0 -1
- package/dist/delegation/strategy-selector.js +0 -1
- package/dist/delegation/voting-coordinator.js +0 -1
- package/dist/delegation/voting-types.js +0 -1
- package/dist/delegation/weighted-voting-aggregator.js +0 -1
- package/dist/enforcement/core/index.js +0 -1
- package/dist/enforcement/core/rule-executor.js +0 -1
- package/dist/enforcement/core/rule-hierarchy.js +0 -1
- package/dist/enforcement/core/rule-registry.js +0 -1
- package/dist/enforcement/core/violation-fixer.js +0 -1
- package/dist/enforcement/index.js +0 -1
- package/dist/enforcement/loaders/agent-triage-loader.js +0 -1
- package/dist/enforcement/loaders/agents-md-validation-loader.js +0 -1
- package/dist/enforcement/loaders/base-loader.js +0 -1
- package/dist/enforcement/loaders/codex-loader.js +0 -1
- package/dist/enforcement/loaders/index.js +0 -1
- package/dist/enforcement/loaders/loader-orchestrator.js +0 -1
- package/dist/enforcement/loaders/processor-loader.js +0 -1
- package/dist/enforcement/types.js +0 -1
- package/dist/enforcement/validators/architecture-validators.js +0 -1
- package/dist/enforcement/validators/base-validator.js +0 -1
- package/dist/enforcement/validators/code-quality-validators.js +0 -1
- package/dist/enforcement/validators/index.js +0 -1
- package/dist/enforcement/validators/security-validators.js +0 -1
- package/dist/enforcement/validators/testing-validators.js +0 -1
- package/dist/enforcement/validators/validator-registry.js +0 -1
- package/dist/governance/codex-policy.service.js +0 -1
- package/dist/inference/inference-agent-invoker.js +67 -0
- package/dist/inference/inference-applier.js +178 -0
- package/dist/inference/inference-cycle.js +51 -827
- package/dist/inference/inference-proposal-generator.js +149 -0
- package/dist/infrastructure/iac-validator.js +465 -0
- package/dist/infrastructure/schemas/cloud-schemas.js +488 -0
- package/dist/integrations/base/ExampleIntegration.js +0 -1
- package/dist/integrations/base/Integration.js +0 -1
- package/dist/integrations/base/index.js +0 -1
- package/dist/integrations/base/registry.js +0 -1
- package/dist/integrations/base/types.js +0 -1
- package/dist/integrations/enforcement-gate.js +3 -3
- package/dist/integrations/governance/governance-client.js +0 -1
- package/dist/integrations/governance/index.js +11 -19
- package/dist/integrations/governance/types.js +0 -1
- package/dist/integrations/hermes-agent/__init__.py +4 -0
- package/dist/integrations/hermes-agent/bridge.mjs +37 -0
- package/dist/integrations/openclaw/api-server.js +0 -1
- package/dist/integrations/openclaw/client.js +0 -1
- package/dist/integrations/openclaw/config.js +0 -1
- package/dist/integrations/openclaw/hooks/xray-hooks.js +0 -1
- package/dist/integrations/openclaw/index.js +0 -1
- package/dist/integrations/openclaw/types.js +0 -1
- package/dist/integrations/plugins/index.js +0 -1
- package/dist/integrations/plugins/plugin-integration.js +0 -1
- package/dist/integrations/plugins/plugin-registry.js +0 -1
- package/dist/mcps/agent-resolver.js +0 -1
- package/dist/mcps/architect-tools.server.js +119 -185
- package/dist/mcps/auto-format.server.js +56 -74
- package/dist/mcps/boot-orchestrator.server.js +67 -85
- package/dist/mcps/config/config-loader.js +6 -0
- package/dist/mcps/config/plugin-server-registry.js +0 -1
- package/dist/mcps/enforcer-tools.server.js +207 -273
- package/dist/mcps/estimation.server.js +63 -107
- package/dist/mcps/framework-compliance-audit.server.js +52 -81
- package/dist/mcps/framework-help.server.js +71 -89
- package/dist/mcps/governance.server.js +97 -149
- package/dist/mcps/knowledge-skills/api-design.server.js +33 -65
- package/dist/mcps/knowledge-skills/architecture-patterns.server.js +33 -65
- package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +123 -163
- package/dist/mcps/knowledge-skills/code-analyzer.server.js +210 -237
- package/dist/mcps/knowledge-skills/code-review.server.js +108 -142
- package/dist/mcps/knowledge-skills/content-creator.server.js +203 -225
- package/dist/mcps/knowledge-skills/database-design.server.js +116 -150
- package/dist/mcps/knowledge-skills/devops-deployment.server.js +123 -157
- package/dist/mcps/knowledge-skills/git-workflow.server.js +34 -67
- package/dist/mcps/knowledge-skills/growth-strategist.server.js +301 -323
- package/dist/mcps/knowledge-skills/log-monitor.server.js +139 -159
- package/dist/mcps/knowledge-skills/mobile-development.server.js +170 -200
- package/dist/mcps/knowledge-skills/multimodal-looker.server.js +122 -158
- package/dist/mcps/knowledge-skills/performance-optimization.server.js +88 -138
- package/dist/mcps/knowledge-skills/project-analysis.server.js +131 -218
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +115 -150
- package/dist/mcps/knowledge-skills/security-audit.server.js +16 -143
- package/dist/mcps/knowledge-skills/seo-consultant.server.js +20 -213
- package/dist/mcps/knowledge-skills/session-management.server.js +13 -90
- package/dist/mcps/knowledge-skills/skill-invocation.server.js +43 -421
- package/dist/mcps/knowledge-skills/strategist.server.js +10 -55
- package/dist/mcps/knowledge-skills/tech-writer.server.js +16 -191
- package/dist/mcps/knowledge-skills/testing-best-practices.server.js +18 -191
- package/dist/mcps/knowledge-skills/testing-strategy.server.js +18 -156
- package/dist/mcps/knowledge-skills/ui-ux-design.server.js +22 -296
- package/dist/mcps/lint.server.js +50 -91
- package/dist/mcps/model-health-check.server.js +32 -60
- package/dist/mcps/orchestrator/aside-context.js +207 -0
- package/dist/mcps/orchestrator/config/agent-capabilities.js +30 -11
- package/dist/mcps/orchestrator/config/memory-routing-bridge.js +70 -0
- package/dist/mcps/orchestrator/execution/execution-planner.js +25 -7
- package/dist/mcps/orchestrator/handlers/complexity-handler.js +5 -1
- package/dist/mcps/orchestrator/handlers/status-handler.js +8 -1
- package/dist/mcps/orchestrator/handlers/task-handler.js +59 -1
- package/dist/mcps/orchestrator/index.js +5 -0
- package/dist/mcps/orchestrator/server.js +63 -8
- package/dist/mcps/performance-analysis.server.js +56 -87
- package/dist/mcps/processor-pipeline.server.js +68 -99
- package/dist/mcps/researcher.server.js +80 -153
- package/dist/mcps/security-scan.server.js +56 -70
- package/dist/mcps/shared/knowledge-skill-base.js +11 -4
- package/dist/mcps/state-manager.server.js +124 -152
- package/dist/memory-routing/index.js +4 -0
- package/dist/memory-routing/null-provider.js +51 -0
- package/dist/memory-routing/provider-loader.js +91 -0
- package/dist/memory-routing/provider-registry.js +40 -0
- package/dist/memory-routing/types.js +7 -0
- package/dist/memory-routing/validate-config.js +32 -0
- package/dist/monitoring/nudge-watchdog.js +0 -1
- package/dist/nucleus/default-plugins.js +13 -19
- package/dist/nucleus/index.js +0 -1
- package/dist/nucleus/thin-dispatch.js +29 -1
- package/dist/orchestrator/agent-spawn-governor.js +0 -1
- package/dist/orchestrator/intelligent-commit-batcher.js +2 -10
- package/dist/orchestrator/multi-agent-orchestration-coordinator.js +0 -1
- package/dist/orchestrator/orchestrator.js +8 -18
- package/dist/orchestrator/self-direction-activation.js +0 -1
- package/dist/orchestrator/universal-registry-bridge.js +0 -1
- package/dist/performance/performance-budget-enforcer.js +0 -1
- package/dist/performance/performance-regression-tester.js +0 -1
- package/dist/plugin/plugin-codex-context.js +87 -0
- package/dist/plugin/plugin-helpers.js +155 -0
- package/dist/plugin/plugin-logger.js +46 -0
- package/dist/plugin/plugin-modules.js +144 -0
- package/dist/plugin/plugin-quality-gate.js +88 -0
- package/dist/plugin/plugin-types.js +1 -0
- package/dist/plugin/xray-codex-injection.js +338 -0
- package/dist/postprocessor/PostProcessor.js +3 -9
- package/dist/postprocessor/analysis/CodeChangeAnalyzer.js +50 -0
- package/dist/postprocessor/config/ProcessorConfigLoader.js +16 -0
- package/dist/postprocessor/integration.js +194 -0
- package/dist/postprocessor/metamorphosis/SelfProposalEngine.js +472 -0
- package/dist/postprocessor/metamorphosis/index.js +1 -0
- package/dist/postprocessor/redeploy/RetryHandler.js +118 -0
- package/dist/postprocessor/services/RegressionAnalysisService.js +0 -1
- package/dist/postprocessor/triggers/APITrigger.js +0 -1
- package/dist/postprocessor/triggers/WebhookTrigger.js +0 -1
- package/dist/processors/implementations/agents-md-validation-processor.js +0 -1
- package/dist/processors/implementations/async-pattern-processor.js +0 -1
- package/dist/processors/implementations/console-log-guard-processor.js +0 -1
- package/dist/processors/implementations/coverage-analysis-processor.js +0 -1
- package/dist/processors/implementations/inference-improvement-processor.js +2 -9
- package/dist/processors/implementations/log-protection-processor.js +0 -1
- package/dist/processors/implementations/nudge-processor.js +0 -1
- package/dist/processors/implementations/performance-budget-processor.js +0 -1
- package/dist/processors/implementations/postprocessor-chain-validator.js +0 -1
- package/dist/processors/implementations/publish-preflight-processor.js +4 -12
- package/dist/processors/implementations/session-summary-processor.js +8 -16
- package/dist/processors/implementations/spawn-governance-processor.js +0 -1
- package/dist/processors/implementations/storytelling-trigger-processor.js +3 -28
- package/dist/processors/implementations/test-auto-creation-processor.js +0 -1
- package/dist/processors/implementations/typescript-compilation-processor.js +0 -1
- package/dist/processors/implementations/version-compliance-processor.js +0 -1
- package/dist/processors/processor-interfaces.js +0 -1
- package/dist/processors/processor-types.js +0 -1
- package/dist/scripts/integration.js +0 -1
- package/dist/security/comprehensive-security-audit.js +0 -1
- package/dist/security/security-agent-coordinator.js +0 -1
- package/dist/security/security-auditor.js +0 -1
- package/dist/security/security-hardener.js +0 -1
- package/dist/security/security-hardening-system.js +0 -1
- package/dist/security/security-headers.js +0 -1
- package/dist/security/security-orchestration-layer.js +0 -1
- package/dist/services/inference-tuner.js +0 -1
- package/dist/session/session-cleanup-manager.js +0 -1
- package/dist/session/session-monitor.js +0 -1
- package/dist/session/session-state-manager.js +0 -1
- package/dist/skills/xray-orchestrator/index.js +0 -1
- package/dist/utils/codex-parser.js +0 -1
- package/dist/utils/language-detector.js +0 -1
- package/dist/utils/shutdown-handler.js +0 -1
- package/dist/validation/agent-config-validator.js +280 -0
- package/dist/validation/orchestration-flow-validator.js +606 -0
- package/package.json +1 -1
- package/scripts/node/release.mjs +2 -2
- package/scripts/node/setup.cjs +28 -0
- package/scripts/node/universal-version-manager.js +1 -1
- package/src/mcps/agent-resolver.ts +0 -1
- package/src/mcps/architect-tools.server.ts +129 -211
- package/src/mcps/auto-format.server.ts +74 -103
- package/src/mcps/boot-orchestrator.server.ts +71 -96
- package/src/mcps/config/__tests__/config-loader.test.ts +6 -6
- package/src/mcps/config/config-loader.ts +7 -0
- package/src/mcps/config/plugin-server-registry.ts +0 -1
- package/src/mcps/enforcer-tools.server.ts +217 -294
- package/src/mcps/estimation.server.ts +62 -122
- package/src/mcps/framework-compliance-audit.server.ts +53 -95
- package/src/mcps/framework-help.server.ts +74 -96
- package/src/mcps/governance.server.ts +97 -162
- package/src/mcps/knowledge-skills/api-design.server.ts +33 -72
- package/src/mcps/knowledge-skills/architecture-patterns.server.ts +33 -72
- package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +148 -193
- package/src/mcps/knowledge-skills/code-analyzer.server.ts +222 -254
- package/src/mcps/knowledge-skills/code-review.server.ts +115 -157
- package/src/mcps/knowledge-skills/content-creator.server.ts +219 -246
- package/src/mcps/knowledge-skills/database-design.server.ts +119 -160
- package/src/mcps/knowledge-skills/devops-deployment.server.ts +126 -167
- package/src/mcps/knowledge-skills/git-workflow.server.ts +32 -77
- package/src/mcps/knowledge-skills/growth-strategist.server.ts +322 -360
- package/src/mcps/knowledge-skills/log-monitor.server.ts +68 -95
- package/src/mcps/knowledge-skills/mobile-development.server.ts +16 -56
- package/src/mcps/knowledge-skills/multimodal-looker.server.ts +13 -59
- package/src/mcps/knowledge-skills/performance-optimization.server.ts +13 -74
- package/src/mcps/knowledge-skills/project-analysis.server.ts +13 -120
- package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +13 -60
- package/src/mcps/knowledge-skills/security-audit.server.ts +19 -157
- package/src/mcps/knowledge-skills/seo-consultant.server.ts +23 -227
- package/src/mcps/knowledge-skills/session-management.server.ts +17 -106
- package/src/mcps/knowledge-skills/skill-invocation.server.ts +45 -446
- package/src/mcps/knowledge-skills/strategist.server.ts +13 -63
- package/src/mcps/knowledge-skills/tech-writer.server.ts +19 -204
- package/src/mcps/knowledge-skills/testing-best-practices.server.ts +21 -204
- package/src/mcps/knowledge-skills/testing-strategy.server.ts +21 -165
- package/src/mcps/knowledge-skills/ui-ux-design.server.ts +25 -342
- package/src/mcps/lint.server.ts +52 -105
- package/src/mcps/model-health-check.server.ts +34 -70
- package/src/mcps/orchestrator/aside-context.ts +245 -0
- package/src/mcps/orchestrator/config/agent-capabilities.ts +49 -14
- package/src/mcps/orchestrator/config/memory-routing-bridge.ts +80 -0
- package/src/mcps/orchestrator/execution/execution-planner.ts +36 -9
- package/src/mcps/orchestrator/handlers/complexity-handler.ts +9 -3
- package/src/mcps/orchestrator/handlers/status-handler.ts +11 -1
- package/src/mcps/orchestrator/handlers/task-handler.ts +78 -2
- package/src/mcps/orchestrator/index.ts +29 -0
- package/src/mcps/orchestrator/server.ts +79 -24
- package/src/mcps/orchestrator/types.ts +50 -0
- package/src/mcps/performance-analysis.server.ts +59 -102
- package/src/mcps/processor-pipeline.server.ts +70 -108
- package/src/mcps/researcher.server.ts +87 -175
- package/src/mcps/security-scan.server.ts +57 -76
- package/src/mcps/shared/knowledge-skill-base.ts +12 -4
- package/src/mcps/state-manager.server.ts +129 -169
- package/src/opencode/codex.codex +1 -1
- package/src/opencode/commands/auto-format.md +3 -3
- package/src/opencode/commands/auto-summary-capture.md +2 -2
- package/src/opencode/commands/enforcer-daily-scan.md +3 -3
- package/src/opencode/commands/framework-compliance-audit.md +4 -4
- package/src/opencode/commands/interactive-validator.md +2 -2
- package/src/opencode/commands/job-summary-logger.md +2 -2
- package/src/opencode/commands/mode-switch.md +1 -1
- package/src/opencode/commands/model-health-check.md +2 -2
- package/src/opencode/commands/performance-analysis.md +2 -2
- package/src/opencode/commands/pre-commit-introspection.md +3 -3
- package/src/opencode/commands/security-scan.md +3 -3
- package/src/opencode/commands/sisyphus-validation.md +3 -3
- package/src/opencode/commands/summary-logger.md +2 -2
- package/src/skills/xray-orchestrator/index.ts +0 -1
- package/dist/nucleus/orchestrator.js +0 -479
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* xray Nucleus — Orchestrator
|
|
3
|
-
*
|
|
4
|
-
* Core boot orchestration logic extracted from boot-orchestrator.server.ts.
|
|
5
|
-
* Owns the component dependency graph, initialization sequence, and status tracking.
|
|
6
|
-
* The MCP server is a thin surface over this class.
|
|
7
|
-
*/
|
|
8
|
-
import { execSync } from "child_process";
|
|
9
|
-
import fs from "fs";
|
|
10
|
-
import path from "path";
|
|
11
|
-
import { frameworkLogger } from "../core/framework-logger.js";
|
|
12
|
-
import { resolveLogDir, resolveStateDir } from "../core/config-paths.js";
|
|
13
|
-
import { registerDefaultPlugins } from "./default-plugins.js";
|
|
14
|
-
export class NucleusOrchestrator {
|
|
15
|
-
initialized = false;
|
|
16
|
-
startTime = Date.now();
|
|
17
|
-
components = new Map();
|
|
18
|
-
dependencies = new Map();
|
|
19
|
-
health = new Map();
|
|
20
|
-
// Boot sequence in dependency order
|
|
21
|
-
bootSequence = [
|
|
22
|
-
"configuration",
|
|
23
|
-
"logging",
|
|
24
|
-
"plugin-registration",
|
|
25
|
-
"state-management",
|
|
26
|
-
"security",
|
|
27
|
-
"codex-loader",
|
|
28
|
-
"context-loader",
|
|
29
|
-
"processor-pipeline",
|
|
30
|
-
"agent-registry",
|
|
31
|
-
"orchestrator",
|
|
32
|
-
"mcp-servers",
|
|
33
|
-
"framework-hooks",
|
|
34
|
-
];
|
|
35
|
-
constructor() {
|
|
36
|
-
this.initializeDependencies();
|
|
37
|
-
}
|
|
38
|
-
isInitialized() {
|
|
39
|
-
return this.initialized;
|
|
40
|
-
}
|
|
41
|
-
getComponentResult(component) {
|
|
42
|
-
return this.components.get(component);
|
|
43
|
-
}
|
|
44
|
-
getComponentHealth(component) {
|
|
45
|
-
return this.health.get(component);
|
|
46
|
-
}
|
|
47
|
-
getComponentDependencies(component) {
|
|
48
|
-
return this.dependencies.get(component) || [];
|
|
49
|
-
}
|
|
50
|
-
initializeDependencies() {
|
|
51
|
-
this.dependencies.set("configuration", []);
|
|
52
|
-
this.dependencies.set("logging", ["configuration"]);
|
|
53
|
-
this.dependencies.set("state-management", ["configuration", "logging"]);
|
|
54
|
-
this.dependencies.set("security", ["configuration"]);
|
|
55
|
-
this.dependencies.set("codex-loader", ["configuration", "logging"]);
|
|
56
|
-
this.dependencies.set("context-loader", ["configuration", "codex-loader"]);
|
|
57
|
-
this.dependencies.set("processor-pipeline", ["state-management", "security", "codex-loader"]);
|
|
58
|
-
this.dependencies.set("agent-registry", ["configuration", "state-management", "processor-pipeline"]);
|
|
59
|
-
this.dependencies.set("orchestrator", ["agent-registry", "processor-pipeline"]);
|
|
60
|
-
this.dependencies.set("mcp-servers", ["orchestrator", "agent-registry"]);
|
|
61
|
-
this.dependencies.set("framework-hooks", ["mcp-servers", "orchestrator"]);
|
|
62
|
-
}
|
|
63
|
-
async executeBootSequence(options) {
|
|
64
|
-
const skipHealthChecks = options?.skipHealthChecks || false;
|
|
65
|
-
const parallelInit = options?.parallelInit !== false;
|
|
66
|
-
frameworkLogger.log("nucleus-orchestrator", "execute-boot-sequence", "info", {
|
|
67
|
-
skipHealthChecks,
|
|
68
|
-
parallelInit,
|
|
69
|
-
});
|
|
70
|
-
const results = {
|
|
71
|
-
success: true,
|
|
72
|
-
initializedComponents: [],
|
|
73
|
-
failedComponents: [],
|
|
74
|
-
duration: 0,
|
|
75
|
-
errors: [],
|
|
76
|
-
warnings: [],
|
|
77
|
-
};
|
|
78
|
-
const startTime = Date.now();
|
|
79
|
-
try {
|
|
80
|
-
const validationResults = await this.validatePrerequisites();
|
|
81
|
-
if (!validationResults.valid) {
|
|
82
|
-
results.success = false;
|
|
83
|
-
results.errors.push(...validationResults.errors);
|
|
84
|
-
results.duration = Date.now() - startTime;
|
|
85
|
-
return results;
|
|
86
|
-
}
|
|
87
|
-
if (parallelInit) {
|
|
88
|
-
await this.executeParallelBoot(skipHealthChecks, results);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
await this.executeSequentialBoot(skipHealthChecks, results);
|
|
92
|
-
}
|
|
93
|
-
results.duration = Date.now() - startTime;
|
|
94
|
-
this.initialized = results.success;
|
|
95
|
-
return results;
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
results.success = false;
|
|
99
|
-
results.duration = Date.now() - startTime;
|
|
100
|
-
results.errors.push(`Boot sequence failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
101
|
-
return results;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
getOverallBootStatus() {
|
|
105
|
-
const totalComponents = this.bootSequence.length;
|
|
106
|
-
const initializedComponents = Array.from(this.components.keys());
|
|
107
|
-
const healthyComponents = Array.from(this.health.values()).filter((h) => h).length;
|
|
108
|
-
return {
|
|
109
|
-
initialized: this.initialized,
|
|
110
|
-
uptime: Date.now() - this.startTime,
|
|
111
|
-
totalComponents,
|
|
112
|
-
initializedComponents: initializedComponents.length,
|
|
113
|
-
healthyComponents,
|
|
114
|
-
failedComponents: initializedComponents.length - healthyComponents,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
async getComponentStatus(component) {
|
|
118
|
-
const initialized = this.components.has(component);
|
|
119
|
-
const healthy = this.health.get(component) || false;
|
|
120
|
-
const info = this.components.get(component);
|
|
121
|
-
return {
|
|
122
|
-
initialized,
|
|
123
|
-
healthy,
|
|
124
|
-
info,
|
|
125
|
-
dependencies: this.dependencies.get(component) || [],
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
async initializeSingleComponent(component, force) {
|
|
129
|
-
if (this.components.has(component) && !force) {
|
|
130
|
-
return {
|
|
131
|
-
success: true,
|
|
132
|
-
duration: 0,
|
|
133
|
-
message: `Component already initialized: ${component}`,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
const deps = this.dependencies.get(component) || [];
|
|
137
|
-
for (const dep of deps) {
|
|
138
|
-
if (!this.components.has(dep)) {
|
|
139
|
-
return {
|
|
140
|
-
success: false,
|
|
141
|
-
duration: 0,
|
|
142
|
-
error: `Dependency not met: ${component} requires ${dep}`,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const result = await this.initializeComponent(component);
|
|
147
|
-
this.components.set(component, result);
|
|
148
|
-
this.health.set(component, result.success);
|
|
149
|
-
return result;
|
|
150
|
-
}
|
|
151
|
-
async validateAllDependencies(fix, verbose) {
|
|
152
|
-
const results = {
|
|
153
|
-
total: this.bootSequence.length,
|
|
154
|
-
valid: 0,
|
|
155
|
-
missing: 0,
|
|
156
|
-
circular: 0,
|
|
157
|
-
issues: [],
|
|
158
|
-
fixes: [],
|
|
159
|
-
};
|
|
160
|
-
for (const component of this.bootSequence) {
|
|
161
|
-
const deps = this.dependencies.get(component) || [];
|
|
162
|
-
const missingDeps = deps.filter((dep) => !this.checkComponentExists(dep));
|
|
163
|
-
if (missingDeps.length > 0) {
|
|
164
|
-
results.missing++;
|
|
165
|
-
results.issues.push(`${component} missing dependencies: ${missingDeps.join(", ")}`);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
results.valid++;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const circularDeps = this.detectCircularDependencies();
|
|
172
|
-
if (circularDeps.length > 0) {
|
|
173
|
-
results.circular = circularDeps.length;
|
|
174
|
-
results.issues.push(`Circular dependencies detected: ${circularDeps.join(", ")}`);
|
|
175
|
-
}
|
|
176
|
-
if (fix && results.issues.length > 0) {
|
|
177
|
-
results.fixes = await this.applyDependencyFixes(results.issues);
|
|
178
|
-
}
|
|
179
|
-
return results;
|
|
180
|
-
}
|
|
181
|
-
async shutdown(force, saveState) {
|
|
182
|
-
const results = {
|
|
183
|
-
success: true,
|
|
184
|
-
shutDown: 0,
|
|
185
|
-
stateSaved: saveState !== false,
|
|
186
|
-
errors: [],
|
|
187
|
-
duration: 0,
|
|
188
|
-
};
|
|
189
|
-
const startTime = Date.now();
|
|
190
|
-
try {
|
|
191
|
-
const reverseSequence = [...this.bootSequence].reverse();
|
|
192
|
-
for (const component of reverseSequence) {
|
|
193
|
-
try {
|
|
194
|
-
await this.shutdownComponent(component, force || false);
|
|
195
|
-
results.shutDown++;
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
results.errors.push(`${component}: ${error instanceof Error ? error.message : String(error)}`);
|
|
199
|
-
if (!force) {
|
|
200
|
-
results.success = false;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (saveState !== false) {
|
|
205
|
-
await this.saveShutdownState();
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
catch (error) {
|
|
209
|
-
results.success = false;
|
|
210
|
-
results.errors.push(`Shutdown error: ${error instanceof Error ? error.message : String(error)}`);
|
|
211
|
-
}
|
|
212
|
-
results.duration = Date.now() - startTime;
|
|
213
|
-
return results;
|
|
214
|
-
}
|
|
215
|
-
async validatePrerequisites() {
|
|
216
|
-
const errors = [];
|
|
217
|
-
try {
|
|
218
|
-
const nodeVersionOutput = execSync("node --version", { encoding: "utf8" })?.toString().trim() || "";
|
|
219
|
-
const nodeVersion = nodeVersionOutput || "v1.2.0";
|
|
220
|
-
const versionParts = nodeVersion.split(".");
|
|
221
|
-
const majorVersion = versionParts.length > 0 && versionParts[0]
|
|
222
|
-
? parseInt(versionParts[0].substring(1))
|
|
223
|
-
: 0;
|
|
224
|
-
if (majorVersion < 18) {
|
|
225
|
-
errors.push(`Node.js version ${nodeVersion} is too old. Requires 18+`);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
catch {
|
|
229
|
-
errors.push("Cannot determine Node.js version");
|
|
230
|
-
}
|
|
231
|
-
const requiredDirs = ["src", "src/agents", "src/mcps"];
|
|
232
|
-
for (const dir of requiredDirs) {
|
|
233
|
-
if (!fs.existsSync(dir)) {
|
|
234
|
-
errors.push(`Required directory missing: ${dir}`);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (!fs.existsSync("package.json")) {
|
|
238
|
-
errors.push("package.json not found");
|
|
239
|
-
}
|
|
240
|
-
return { valid: errors.length === 0, errors };
|
|
241
|
-
}
|
|
242
|
-
async executeParallelBoot(skipHealthChecks, results) {
|
|
243
|
-
const componentPromises = this.bootSequence.map((component) => this.initializeComponent(component, skipHealthChecks));
|
|
244
|
-
const componentResults = await Promise.allSettled(componentPromises);
|
|
245
|
-
for (let i = 0; i < componentResults.length; i++) {
|
|
246
|
-
const component = this.bootSequence[i];
|
|
247
|
-
if (!component)
|
|
248
|
-
continue;
|
|
249
|
-
const result = componentResults[i];
|
|
250
|
-
if (!result)
|
|
251
|
-
continue;
|
|
252
|
-
if (result.status === "fulfilled") {
|
|
253
|
-
const fulfilledResult = result;
|
|
254
|
-
if (fulfilledResult.value.success) {
|
|
255
|
-
results.initializedComponents.push(component);
|
|
256
|
-
this.components.set(component, fulfilledResult.value);
|
|
257
|
-
this.health.set(component, true);
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
results.failedComponents.push(component);
|
|
261
|
-
results.errors.push(`${component}: ${fulfilledResult.value.error || "Unknown error"}`);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
results.failedComponents.push(component);
|
|
266
|
-
results.errors.push(`${component}: ${result.reason}`);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
results.success = results.failedComponents.length === 0;
|
|
270
|
-
}
|
|
271
|
-
async executeSequentialBoot(skipHealthChecks, results) {
|
|
272
|
-
for (const component of this.bootSequence) {
|
|
273
|
-
try {
|
|
274
|
-
const result = await this.initializeComponent(component, skipHealthChecks);
|
|
275
|
-
if (result.success) {
|
|
276
|
-
results.initializedComponents.push(component);
|
|
277
|
-
this.components.set(component, result);
|
|
278
|
-
this.health.set(component, true);
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
results.failedComponents.push(component);
|
|
282
|
-
results.errors.push(`${component}: ${result.error}`);
|
|
283
|
-
break;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
catch (error) {
|
|
287
|
-
results.failedComponents.push(component);
|
|
288
|
-
results.errors.push(`${component}: ${error instanceof Error ? error.message : String(error)}`);
|
|
289
|
-
break;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
results.success = results.failedComponents.length === 0;
|
|
293
|
-
}
|
|
294
|
-
async initializeComponent(component, _skipHealthChecks = false) {
|
|
295
|
-
const startTime = Date.now();
|
|
296
|
-
try {
|
|
297
|
-
switch (component) {
|
|
298
|
-
case "configuration":
|
|
299
|
-
return this.initConfiguration();
|
|
300
|
-
case "logging":
|
|
301
|
-
return this.initLogging();
|
|
302
|
-
case "plugin-registration":
|
|
303
|
-
return await this.initPluginRegistration();
|
|
304
|
-
case "state-management":
|
|
305
|
-
return this.initStateManagement();
|
|
306
|
-
case "security":
|
|
307
|
-
return this.initSecurity();
|
|
308
|
-
case "codex-loader":
|
|
309
|
-
return this.initCodexLoader();
|
|
310
|
-
case "context-loader":
|
|
311
|
-
return this.initContextLoader();
|
|
312
|
-
case "processor-pipeline":
|
|
313
|
-
return this.initProcessorPipeline();
|
|
314
|
-
case "agent-registry":
|
|
315
|
-
return this.initAgentRegistry();
|
|
316
|
-
case "orchestrator":
|
|
317
|
-
return this.initOrchestrator();
|
|
318
|
-
case "mcp-servers":
|
|
319
|
-
return this.initMCPServers();
|
|
320
|
-
case "framework-hooks":
|
|
321
|
-
return this.initFrameworkHooks();
|
|
322
|
-
default:
|
|
323
|
-
throw new Error(`Unknown component: ${component}`);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
catch (error) {
|
|
327
|
-
return {
|
|
328
|
-
success: false,
|
|
329
|
-
duration: Date.now() - startTime,
|
|
330
|
-
error: error instanceof Error ? error.message : String(error),
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
initConfiguration() {
|
|
335
|
-
return { success: true, duration: 10, message: "Configuration initialized" };
|
|
336
|
-
}
|
|
337
|
-
initLogging() {
|
|
338
|
-
const logDir = resolveLogDir();
|
|
339
|
-
if (!fs.existsSync(logDir)) {
|
|
340
|
-
fs.mkdirSync(logDir, { recursive: true });
|
|
341
|
-
}
|
|
342
|
-
return { success: true, duration: 5, message: "Logging system initialized" };
|
|
343
|
-
}
|
|
344
|
-
async initPluginRegistration() {
|
|
345
|
-
const start = Date.now();
|
|
346
|
-
const r = await registerDefaultPlugins();
|
|
347
|
-
if (r.registered === 0) {
|
|
348
|
-
return {
|
|
349
|
-
success: false,
|
|
350
|
-
duration: Date.now() - start,
|
|
351
|
-
error: "No plugins registered",
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
return {
|
|
355
|
-
success: true,
|
|
356
|
-
duration: Date.now() - start,
|
|
357
|
-
message: `Plugin registration: ${r.registered} registered, ${r.failed.length} failed`,
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
initStateManagement() {
|
|
361
|
-
const stateDir = resolveStateDir();
|
|
362
|
-
if (!fs.existsSync(stateDir)) {
|
|
363
|
-
fs.mkdirSync(stateDir, { recursive: true });
|
|
364
|
-
}
|
|
365
|
-
return { success: true, duration: 8, message: "State management initialized" };
|
|
366
|
-
}
|
|
367
|
-
initSecurity() {
|
|
368
|
-
return { success: true, duration: 3, message: "Security framework initialized" };
|
|
369
|
-
}
|
|
370
|
-
initCodexLoader() {
|
|
371
|
-
return { success: true, duration: 12, message: "Codex loader initialized" };
|
|
372
|
-
}
|
|
373
|
-
initContextLoader() {
|
|
374
|
-
return { success: true, duration: 8, message: "Context loader initialized" };
|
|
375
|
-
}
|
|
376
|
-
initProcessorPipeline() {
|
|
377
|
-
return { success: true, duration: 15, message: "Processor pipeline initialized" };
|
|
378
|
-
}
|
|
379
|
-
initAgentRegistry() {
|
|
380
|
-
const agentCount = this.countAgentFiles();
|
|
381
|
-
if (agentCount < 5) {
|
|
382
|
-
throw new Error(`Insufficient agents found: ${agentCount}`);
|
|
383
|
-
}
|
|
384
|
-
return { success: true, duration: 10, message: `Agent registry initialized with ${agentCount} agents` };
|
|
385
|
-
}
|
|
386
|
-
initOrchestrator() {
|
|
387
|
-
return { success: true, duration: 20, message: "Orchestrator initialized" };
|
|
388
|
-
}
|
|
389
|
-
initMCPServers() {
|
|
390
|
-
const mcpCount = this.countMCPFiles();
|
|
391
|
-
if (mcpCount < 3) {
|
|
392
|
-
throw new Error(`Insufficient MCP servers found: ${mcpCount}`);
|
|
393
|
-
}
|
|
394
|
-
return { success: true, duration: 15, message: `MCP servers initialized (${mcpCount} servers)` };
|
|
395
|
-
}
|
|
396
|
-
initFrameworkHooks() {
|
|
397
|
-
return { success: true, duration: 5, message: "Framework hooks initialized" };
|
|
398
|
-
}
|
|
399
|
-
countAgentFiles() {
|
|
400
|
-
try {
|
|
401
|
-
const files = fs.readdirSync("src/agents");
|
|
402
|
-
return files.filter((f) => f.endsWith(".ts") && f !== "types.ts" && f !== "index.ts").length;
|
|
403
|
-
}
|
|
404
|
-
catch {
|
|
405
|
-
return 0;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
countMCPFiles() {
|
|
409
|
-
try {
|
|
410
|
-
const files = fs.readdirSync("src/mcps");
|
|
411
|
-
return files.filter((f) => f.endsWith(".server.ts")).length;
|
|
412
|
-
}
|
|
413
|
-
catch {
|
|
414
|
-
return 0;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
checkComponentExists(component) {
|
|
418
|
-
switch (component) {
|
|
419
|
-
case "configuration":
|
|
420
|
-
return fs.existsSync("opencode.json");
|
|
421
|
-
case "logging":
|
|
422
|
-
return fs.existsSync("src/framework-logger.ts");
|
|
423
|
-
case "state-management":
|
|
424
|
-
return fs.existsSync("src/state/state-manager.ts");
|
|
425
|
-
case "security":
|
|
426
|
-
return true;
|
|
427
|
-
case "codex-loader":
|
|
428
|
-
return true;
|
|
429
|
-
case "context-loader":
|
|
430
|
-
return true;
|
|
431
|
-
case "processor-pipeline":
|
|
432
|
-
return fs.existsSync("src/processors/processor-manager.ts");
|
|
433
|
-
case "agent-registry":
|
|
434
|
-
return fs.existsSync("src/agents");
|
|
435
|
-
case "orchestrator":
|
|
436
|
-
return fs.existsSync("src/delegation/agent-delegator.ts");
|
|
437
|
-
case "mcp-servers":
|
|
438
|
-
return fs.existsSync("src/mcps");
|
|
439
|
-
case "framework-hooks":
|
|
440
|
-
return fs.existsSync("src/core/xray-activation.ts");
|
|
441
|
-
default:
|
|
442
|
-
return false;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
detectCircularDependencies() {
|
|
446
|
-
const circular = [];
|
|
447
|
-
for (const [component, deps] of this.dependencies) {
|
|
448
|
-
for (const dep of deps) {
|
|
449
|
-
const depDeps = this.dependencies.get(dep) || [];
|
|
450
|
-
if (depDeps.includes(component)) {
|
|
451
|
-
circular.push(`${component} ↔ ${dep}`);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
return [...new Set(circular)];
|
|
456
|
-
}
|
|
457
|
-
async applyDependencyFixes(issues) {
|
|
458
|
-
const fixes = [];
|
|
459
|
-
for (const issue of issues) {
|
|
460
|
-
if (issue.includes("missing dependencies")) {
|
|
461
|
-
fixes.push("Dependency validation completed - manual fixes may be required");
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return fixes;
|
|
465
|
-
}
|
|
466
|
-
async shutdownComponent(component, force) {
|
|
467
|
-
frameworkLogger.log("nucleus-orchestrator", "shutdown-component", "info", { component, force });
|
|
468
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
469
|
-
}
|
|
470
|
-
async saveShutdownState() {
|
|
471
|
-
const shutdownState = {
|
|
472
|
-
timestamp: Date.now(),
|
|
473
|
-
components: Array.from(this.components.keys()),
|
|
474
|
-
health: Object.fromEntries(this.health),
|
|
475
|
-
};
|
|
476
|
-
const stateFile = path.join(".opencode", "state", "shutdown-state.json");
|
|
477
|
-
fs.writeFileSync(stateFile, JSON.stringify(shutdownState, null, 2));
|
|
478
|
-
}
|
|
479
|
-
}
|