0xray 3.1.0 → 3.1.1
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/.gitignore.default +59 -0
- package/.mcp.json +35 -0
- package/.opencode/codex.codex +1 -1
- package/.opencode/commands/dependency-audit.md +3 -3
- package/.opencode/commands/summary-logger.md +4 -4
- package/.opencode/enforcer-config.json +2 -2
- package/.opencode/hooks/post-commit +1 -1
- package/.opencode/init.sh +6 -0
- package/.plugin/plugin.json +11 -0
- package/AGENTS-consumer.md +46 -0
- package/AGENTS.md +8 -8
- package/LICENSE +1 -1
- package/README.md +8 -8
- package/SKILLS.md +140 -0
- package/dist/.gitignore.default +59 -0
- package/dist/AGENTS.md +8 -8
- package/dist/CHANGELOG.md +25 -0
- package/dist/LICENSE +1 -1
- package/dist/README.md +8 -8
- package/dist/SKILLS.md +140 -0
- package/dist/agents/index.js +3 -1
- package/dist/agents/registry.js +13 -0
- package/dist/analytics/routing-refiner.js +1 -1
- package/dist/architect/architectural-integrity.js +3 -3
- package/dist/benchmark/performance-benchmark.js +1 -2
- package/dist/cli/commands/antigravity-status.js +23 -23
- package/dist/cli/commands/credible-init.js +1 -1
- package/dist/cli/commands/hermes-install.js +8 -0
- package/dist/cli/commands/mcp-install.js +1 -1
- package/dist/cli/commands/openclaw-install.js +9 -0
- package/dist/cli/commands/opencode-install.js +22 -0
- package/dist/cli/commands/skill-install.js +39 -2
- package/dist/cli/commands/status.js +5 -0
- package/dist/cli/commands/storyteller.js +1 -1
- package/dist/cli/index.js +12 -6
- package/dist/core/activity-logger.js +4 -4
- package/dist/core/agent-spawn-gate.js +1 -1
- package/dist/core/boot-orchestrator.js +12 -13
- package/dist/core/bridge.mjs +4 -4
- package/dist/core/codex-formatter.js +1 -2
- package/dist/core/codex-injector.js +3 -3
- package/dist/core/config-loader.js +1 -2
- package/dist/core/config-paths.js +30 -23
- package/dist/core/context-loader.js +0 -3
- package/dist/core/features-config.js +1 -1
- package/dist/core/index.js +2 -2
- package/dist/core/logging-config.js +7 -7
- package/dist/core/orchestrator.js +1 -1
- package/dist/core/xray-activation.js +3 -4
- package/dist/delegation/agent-delegator.js +2 -2
- package/dist/enforcement/enforcer-tools.js +2 -2
- package/dist/enforcement/loaders/codex-loader.js +2 -2
- package/dist/execution/opencode-cli-invoker.js +1 -1
- package/dist/governance/governance-service.js +1 -1
- package/dist/governance/llm-governance-provider.js +14 -1
- package/dist/index.js +3 -5
- package/dist/inference/inference-cycle.js +11 -11
- package/dist/integrations/base/README.md +1 -1
- package/dist/integrations/enforcement-gate.js +2 -2
- package/dist/integrations/governance/index.js +1 -1
- package/dist/integrations/grok/grok-cli.js +20 -6
- package/dist/integrations/grok/hooks/pre-tool-use.js +3 -3
- package/dist/integrations/grok/plugin/0xray/.mcp.json +16 -4
- package/dist/integrations/grok/plugin/0xray/hooks/hooks.json +2 -2
- package/dist/integrations/hermes-agent/__init__.py +25 -14
- package/dist/integrations/hermes-agent/bridge.mjs +39 -4
- package/dist/integrations/hermes-agent/schemas.py +49 -0
- package/dist/integrations/hermes-agent/test_plugin.py +7 -7
- package/dist/integrations/hermes-agent/tools.py +107 -3
- package/dist/integrations/openclaw/README.md +6 -6
- package/dist/integrations/openclaw/config.js +1 -1
- package/dist/integrations/openclaw/index.js +2 -2
- package/dist/integrations/openclaw/types.js +3 -3
- package/dist/integrations/plugins/plugin-integration.js +1 -1
- package/dist/integrations/plugins/plugin-registry.js +1 -1
- package/dist/mcps/architect-tools.server.js +3 -2
- package/dist/mcps/auto-format.server.js +2 -2
- package/dist/mcps/boot-orchestrator.server.js +2 -2
- package/dist/mcps/config/config-loader.js +40 -9
- package/dist/mcps/enforcer-tools.server.js +2 -2
- package/dist/mcps/estimation.server.js +3 -2
- package/dist/mcps/framework-compliance-audit.server.js +2 -2
- package/dist/mcps/framework-help.server.js +3 -2
- package/dist/mcps/governance.server.js +8 -4
- package/dist/mcps/knowledge-skills/api-design.server.js +3 -2
- package/dist/mcps/knowledge-skills/architecture-patterns.server.js +3 -2
- package/dist/mcps/knowledge-skills/bug-triage-specialist.server.js +3 -3
- package/dist/mcps/knowledge-skills/code-analyzer.server.js +2 -2
- package/dist/mcps/knowledge-skills/code-review.server.js +2 -2
- package/dist/mcps/knowledge-skills/content-creator.server.js +3 -3
- package/dist/mcps/knowledge-skills/database-design.server.js +2 -2
- package/dist/mcps/knowledge-skills/devops-deployment.server.js +3 -2
- package/dist/mcps/knowledge-skills/git-workflow.server.js +3 -2
- package/dist/mcps/knowledge-skills/growth-strategist.server.js +3 -3
- package/dist/mcps/knowledge-skills/log-monitor.server.js +3 -3
- package/dist/mcps/knowledge-skills/mobile-development.server.js +3 -3
- package/dist/mcps/knowledge-skills/multimodal-looker.server.js +3 -3
- package/dist/mcps/knowledge-skills/performance-optimization.server.js +2 -2
- package/dist/mcps/knowledge-skills/project-analysis.server.js +2 -2
- package/dist/mcps/knowledge-skills/refactoring-strategies.server.js +3 -2
- package/dist/mcps/knowledge-skills/security-audit.server.js +2 -2
- package/dist/mcps/knowledge-skills/seo-consultant.server.js +3 -2
- package/dist/mcps/knowledge-skills/session-management.server.js +3 -2
- package/dist/mcps/knowledge-skills/skill-invocation.server.js +105 -3
- package/dist/mcps/knowledge-skills/strategist.server.js +3 -3
- package/dist/mcps/knowledge-skills/tech-writer.server.js +3 -3
- package/dist/mcps/knowledge-skills/testing-best-practices.server.js +3 -2
- package/dist/mcps/knowledge-skills/testing-strategy.server.js +2 -2
- package/dist/mcps/knowledge-skills/ui-ux-design.server.js +3 -2
- package/dist/mcps/lint.server.js +2 -2
- package/dist/mcps/model-health-check.server.js +3 -2
- package/dist/mcps/orchestrator/server.js +2 -1
- package/dist/mcps/orchestrator.server.js +2 -1
- package/dist/mcps/performance-analysis.server.js +2 -2
- package/dist/mcps/processor-pipeline.server.js +3 -2
- package/dist/mcps/registry.json +1 -1
- package/dist/mcps/researcher.server.js +2 -2
- package/dist/mcps/security-scan.server.js +2 -2
- package/dist/mcps/state-manager.server.js +5 -5
- package/dist/metrics/agent-metrics.js +1 -1
- package/dist/orchestrator/enhanced-multi-agent-orchestrator.js +2 -2
- package/dist/orchestrator/intelligent-commit-batcher.js +0 -1
- package/dist/orchestrator/multi-agent-orchestration-coordinator.js +1 -1
- package/dist/orchestrator/orchestrator.js +1 -2
- package/dist/orchestrator/universal-registry-bridge.js +1 -1
- package/dist/postprocessor/PostProcessor.js +5 -5
- package/dist/postprocessor/services/RegressionAnalysisService.js +2 -2
- package/dist/postprocessor/triggers/GitHookTrigger.js +4 -4
- package/dist/processors/implementations/inference-improvement-processor.js +0 -1
- package/dist/processors/implementations/publish-preflight-processor.js +0 -1
- package/dist/processors/implementations/session-summary-processor.js +2 -2
- package/dist/processors/implementations/storytelling-trigger-processor.js +0 -1
- package/dist/public/about.html +6 -6
- package/dist/public/enterprise.html +1 -1
- package/dist/public/features.html +2 -2
- package/dist/public/index.html +4 -4
- package/dist/reporting/report-formatter.js +1 -1
- package/dist/scripts/activate-kernel-pipeline.js +2 -2
- package/dist/scripts/pre-command +1 -1
- package/dist/services/inference-tuner.js +1 -1
- package/dist/skills/api-design/SKILL.md +1 -1
- package/dist/skills/architect-tools/SKILL.md +1 -1
- package/dist/skills/architecture-patterns/SKILL.md +1 -1
- package/dist/skills/auto-format/SKILL.md +1 -1
- package/dist/skills/boot-orchestrator/SKILL.md +1 -1
- package/dist/skills/bug-triage/SKILL.md +1 -1
- package/dist/skills/code-analyzer/SKILL.md +1 -1
- package/dist/skills/code-review/SKILL.md +1 -1
- package/dist/skills/enforcer/SKILL.md +1 -1
- package/dist/skills/framework-compliance-audit/SKILL.md +1 -1
- package/dist/skills/git-workflow/SKILL.md +1 -1
- package/dist/skills/hermes-agent/SKILL.md +2 -2
- package/dist/skills/inference-improve/SKILL.md +1 -1
- package/dist/skills/lint/SKILL.md +1 -1
- package/dist/skills/log-monitor/SKILL.md +1 -1
- package/dist/skills/model-health-check/SKILL.md +1 -1
- package/dist/skills/multimodal-looker/SKILL.md +1 -1
- package/dist/skills/orchestrator/SKILL.md +1 -1
- package/dist/skills/performance-analysis/SKILL.md +1 -1
- package/dist/skills/performance-optimization/SKILL.md +1 -1
- package/dist/skills/processor-pipeline/SKILL.md +1 -1
- package/dist/skills/project-analysis/SKILL.md +1 -1
- package/dist/skills/refactoring-strategies/SKILL.md +1 -1
- package/dist/skills/registry.json +1 -1
- package/dist/skills/researcher/SKILL.md +1 -1
- package/dist/skills/security-audit/SKILL.md +1 -1
- package/dist/skills/security-scan/SKILL.md +1 -1
- package/dist/skills/session-management/SKILL.md +1 -1
- package/dist/skills/state-manager/SKILL.md +1 -1
- package/dist/skills/storyteller/SKILL.md +1 -1
- package/dist/skills/testing-best-practices/SKILL.md +1 -1
- package/dist/skills/testing-strategy/SKILL.md +1 -1
- package/dist/skills/ui-ux-design/SKILL.md +1 -1
- package/dist/state/index.js +0 -1
- package/dist/state/state-manager.js +1 -2
- package/dist/utils/import-resolver.js +1 -1
- package/dist/utils/path-resolver.js +2 -2
- package/package.json +10 -3
- package/scripts/hooks/pre-command +1 -1
- package/scripts/hooks/run-hook.js +2 -2
- package/scripts/node/auto-reflection-generator.mjs +30 -36
- package/scripts/node/govern-reflection.mjs +1 -1
- package/scripts/node/postinstall.cjs +37 -2
- package/scripts/node/setup-xai-oauth.mjs +244 -0
- package/scripts/node/universal-version-manager.js +8 -8
- package/scripts/node/version-manager.mjs +1 -1
- package/src/integrations/grok/plugin/0xray/.mcp.json +16 -4
- package/src/integrations/grok/plugin/0xray/hooks/hooks.json +2 -2
- package/src/mcps/architect-tools.server.ts +2 -2
- package/src/mcps/auto-format.server.ts +2 -2
- package/src/mcps/boot-orchestrator.server.ts +2 -2
- package/src/mcps/config/__tests__/config-loader.test.ts +29 -33
- package/src/mcps/config/config-loader.ts +50 -11
- package/src/mcps/enforcer-tools.server.ts +2 -2
- package/src/mcps/estimation.server.ts +3 -2
- package/src/mcps/framework-compliance-audit.server.ts +2 -2
- package/src/mcps/framework-help.server.ts +3 -2
- package/src/mcps/governance.server.ts +8 -3
- package/src/mcps/knowledge-skills/api-design.server.ts +3 -2
- package/src/mcps/knowledge-skills/architecture-patterns.server.ts +2 -2
- package/src/mcps/knowledge-skills/bug-triage-specialist.server.ts +2 -2
- package/src/mcps/knowledge-skills/code-analyzer.server.ts +2 -2
- package/src/mcps/knowledge-skills/code-review.server.ts +2 -2
- package/src/mcps/knowledge-skills/content-creator.server.ts +3 -3
- package/src/mcps/knowledge-skills/database-design.server.ts +2 -2
- package/src/mcps/knowledge-skills/devops-deployment.server.ts +3 -2
- package/src/mcps/knowledge-skills/git-workflow.server.ts +3 -2
- package/src/mcps/knowledge-skills/growth-strategist.server.ts +3 -3
- package/src/mcps/knowledge-skills/log-monitor.server.ts +3 -3
- package/src/mcps/knowledge-skills/mobile-development.server.ts +3 -3
- package/src/mcps/knowledge-skills/multimodal-looker.server.ts +3 -3
- package/src/mcps/knowledge-skills/performance-optimization.server.ts +2 -2
- package/src/mcps/knowledge-skills/project-analysis.server.ts +2 -2
- package/src/mcps/knowledge-skills/refactoring-strategies.server.ts +3 -2
- package/src/mcps/knowledge-skills/security-audit.server.ts +2 -2
- package/src/mcps/knowledge-skills/seo-consultant.server.ts +3 -2
- package/src/mcps/knowledge-skills/session-management.server.ts +3 -2
- package/src/mcps/knowledge-skills/skill-invocation.server.ts +113 -3
- package/src/mcps/knowledge-skills/strategist.server.ts +3 -3
- package/src/mcps/knowledge-skills/tech-writer.server.ts +3 -3
- package/src/mcps/knowledge-skills/testing-best-practices.server.ts +3 -2
- package/src/mcps/knowledge-skills/testing-strategy.server.ts +2 -2
- package/src/mcps/knowledge-skills/ui-ux-design.server.ts +3 -2
- package/src/mcps/lint.server.ts +2 -2
- package/src/mcps/model-health-check.server.ts +2 -2
- package/src/mcps/orchestrator/server.ts +2 -1
- package/src/mcps/orchestrator.server.ts +2 -1
- package/src/mcps/performance-analysis.server.ts +2 -2
- package/src/mcps/processor-pipeline.server.ts +3 -2
- package/src/mcps/registry.json +1 -1
- package/src/mcps/researcher.server.ts +2 -2
- package/src/mcps/security-scan.server.ts +2 -2
- package/src/mcps/state-manager.server.ts +5 -5
- package/src/opencode/codex.codex +1 -1
- package/src/opencode/commands/dependency-audit.md +3 -3
- package/src/opencode/commands/summary-logger.md +4 -4
- package/src/opencode/enforcer-config.json +2 -2
- package/src/skills/api-design/SKILL.md +1 -1
- package/src/skills/architect-tools/SKILL.md +1 -1
- package/src/skills/architecture-patterns/SKILL.md +1 -1
- package/src/skills/auto-format/SKILL.md +1 -1
- package/src/skills/boot-orchestrator/SKILL.md +1 -1
- package/src/skills/bug-triage/SKILL.md +1 -1
- package/src/skills/code-analyzer/SKILL.md +1 -1
- package/src/skills/code-review/SKILL.md +1 -1
- package/src/skills/enforcer/SKILL.md +1 -1
- package/src/skills/framework-compliance-audit/SKILL.md +1 -1
- package/src/skills/git-workflow/SKILL.md +1 -1
- package/src/skills/hermes-agent/SKILL.md +2 -2
- package/src/skills/inference-improve/SKILL.md +1 -1
- package/src/skills/lint/SKILL.md +1 -1
- package/src/skills/log-monitor/SKILL.md +1 -1
- package/src/skills/model-health-check/SKILL.md +1 -1
- package/src/skills/multimodal-looker/SKILL.md +1 -1
- package/src/skills/orchestrator/SKILL.md +1 -1
- package/src/skills/performance-analysis/SKILL.md +1 -1
- package/src/skills/performance-optimization/SKILL.md +1 -1
- package/src/skills/processor-pipeline/SKILL.md +1 -1
- package/src/skills/project-analysis/SKILL.md +1 -1
- package/src/skills/refactoring-strategies/SKILL.md +1 -1
- package/src/skills/registry.json +1 -1
- package/src/skills/researcher/SKILL.md +1 -1
- package/src/skills/security-audit/SKILL.md +1 -1
- package/src/skills/security-scan/SKILL.md +1 -1
- package/src/skills/session-management/SKILL.md +1 -1
- package/src/skills/state-manager/SKILL.md +1 -1
- package/src/skills/storyteller/SKILL.md +1 -1
- package/src/skills/testing-best-practices/SKILL.md +1 -1
- package/src/skills/testing-strategy/SKILL.md +1 -1
- package/src/skills/ui-ux-design/SKILL.md +1 -1
- package/xray/agents_template.md +46 -0
- package/xray/codex.json +598 -0
- package/dist/plugin/xray-codex-injection.js +0 -857
- /package/dist/integrations/openclaw/hooks/{strray-hooks.js → xray-hooks.js} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Boot Orchestrator (min documented consumer runtime compat shim from prior 0xRay releases; primary Xray
|
|
2
|
+
* Boot Orchestrator (min documented consumer runtime compat shim from prior 0xRay releases; primary Xray paths + .xray fallbacks only; 1-line per Scope Rule).
|
|
3
3
|
*/
|
|
4
4
|
import { XrayContextLoader } from "./context-loader.js";
|
|
5
5
|
import { XrayStateManager } from "../state/state-manager.js";
|
|
@@ -9,7 +9,7 @@ import * as fs from "fs";
|
|
|
9
9
|
import * as path from "path";
|
|
10
10
|
const { existsSync, readFileSync } = fs;
|
|
11
11
|
// Path configuration - can be overridden by environment or use path resolver
|
|
12
|
-
const AGENTS_BASE_PATH = process.env.XRAY_AGENTS_PATH || process.env.
|
|
12
|
+
const AGENTS_BASE_PATH = process.env.XRAY_AGENTS_PATH || process.env.XRAY_AGENTS_PATH || "../agents";
|
|
13
13
|
import { createAgentDelegator, createSessionCoordinator, } from "../delegation/index.js";
|
|
14
14
|
import { createSessionCleanupManager } from "../session/session-cleanup-manager.js";
|
|
15
15
|
import { createSessionMonitor } from "../session/session-monitor.js";
|
|
@@ -20,7 +20,7 @@ import { frameworkLogger } from "../core/framework-logger.js";
|
|
|
20
20
|
import { featuresConfigLoader } from "../core/features-config.js";
|
|
21
21
|
import { memoryMonitor } from "../monitoring/memory-monitor.js";
|
|
22
22
|
import { advancedProfiler } from "../monitoring/advanced-profiler.js";
|
|
23
|
-
import {
|
|
23
|
+
import { xrayConfigLoader } from "./config-loader.js";
|
|
24
24
|
import { PluginRegistry } from "../integrations/plugins/index.js";
|
|
25
25
|
import { PluginServerConfigRegistry } from "../mcps/config/index.js";
|
|
26
26
|
import { initializeGovernanceIntegration } from "../integrations/governance/index.js";
|
|
@@ -47,7 +47,7 @@ function setupGracefulShutdown() {
|
|
|
47
47
|
}
|
|
48
48
|
catch (error) {
|
|
49
49
|
// Suppress error output in CLI mode to avoid breaking interface
|
|
50
|
-
if (process.env.
|
|
50
|
+
if (process.env.XRAY_CLI_MODE !== "true" &&
|
|
51
51
|
process.env.OPENCODE_CLI !== "true") {
|
|
52
52
|
frameworkLogger.log("boot-orchestrator", "shutdown-error", "error", { error, message: "Error during graceful shutdown" });
|
|
53
53
|
}
|
|
@@ -69,7 +69,7 @@ function setupGracefulShutdown() {
|
|
|
69
69
|
// Handle uncaught exceptions that might cause JSON parsing errors
|
|
70
70
|
process.on("uncaughtException", (error) => {
|
|
71
71
|
// Suppress error output in CLI mode to avoid breaking interface
|
|
72
|
-
if (process.env.
|
|
72
|
+
if (process.env.XRAY_CLI_MODE !== "true" &&
|
|
73
73
|
process.env.OPENCODE_CLI !== "true") {
|
|
74
74
|
frameworkLogger.log("boot-orchestrator", "uncaught-exception", "error", { error, message: "Uncaught Exception" });
|
|
75
75
|
}
|
|
@@ -79,7 +79,7 @@ function setupGracefulShutdown() {
|
|
|
79
79
|
});
|
|
80
80
|
process.on("unhandledRejection", (reason, promise) => {
|
|
81
81
|
// Suppress error output in CLI mode to avoid breaking interface
|
|
82
|
-
if (process.env.
|
|
82
|
+
if (process.env.XRAY_CLI_MODE !== "true" &&
|
|
83
83
|
process.env.OPENCODE_CLI !== "true") {
|
|
84
84
|
frameworkLogger.log("boot-orchestrator", "unhandled-rejection", "error", { promise, reason, message: "Unhandled Rejection" });
|
|
85
85
|
}
|
|
@@ -115,7 +115,7 @@ export class BootOrchestrator {
|
|
|
115
115
|
*/
|
|
116
116
|
async initializeDelegationSystem() {
|
|
117
117
|
try {
|
|
118
|
-
const agentDelegator = createAgentDelegator(this.stateManager,
|
|
118
|
+
const agentDelegator = createAgentDelegator(this.stateManager, xrayConfigLoader);
|
|
119
119
|
this.stateManager.set("delegation:agent_delegator", agentDelegator);
|
|
120
120
|
const sessionCoordinator = createSessionCoordinator(this.stateManager);
|
|
121
121
|
this.stateManager.set("delegation:session_coordinator", sessionCoordinator);
|
|
@@ -132,7 +132,6 @@ export class BootOrchestrator {
|
|
|
132
132
|
try {
|
|
133
133
|
const configPaths = [
|
|
134
134
|
path.join(process.cwd(), ".xray", "features.json"),
|
|
135
|
-
path.join(process.cwd(), ".opencode", "xray", "features.json"),
|
|
136
135
|
];
|
|
137
136
|
for (const configPath of configPaths) {
|
|
138
137
|
if (existsSync(configPath)) {
|
|
@@ -189,7 +188,7 @@ export class BootOrchestrator {
|
|
|
189
188
|
});
|
|
190
189
|
return false;
|
|
191
190
|
}
|
|
192
|
-
const orchestratorInstance = orchestratorModule.
|
|
191
|
+
const orchestratorInstance = orchestratorModule.xrayOrchestrator;
|
|
193
192
|
if (!orchestratorInstance) {
|
|
194
193
|
frameworkLogger.log("boot-orchestrator", "orchestrator-not-found", "error", { message: "Orchestrator instance not found in module" });
|
|
195
194
|
return false;
|
|
@@ -596,7 +595,7 @@ export class BootOrchestrator {
|
|
|
596
595
|
};
|
|
597
596
|
try {
|
|
598
597
|
frameworkLogger.log("boot-orchestrator", "loading xray configuration", "info", { jobId });
|
|
599
|
-
// Consumer runtime compat shim from prior 0xRay releases (1-line min per Scope Rule; primary xray paths +
|
|
598
|
+
// Consumer runtime compat shim from prior 0xRay releases (1-line min per Scope Rule; primary xray paths + .xray fallbacks)
|
|
600
599
|
await this.loadXrayConfiguration(jobId);
|
|
601
600
|
frameworkLogger.log("boot-orchestrator", "xray configuration loaded", "success", { jobId });
|
|
602
601
|
// Phase 1: Initialize core systems
|
|
@@ -727,12 +726,12 @@ export class BootOrchestrator {
|
|
|
727
726
|
this.stateManager.set("boot:errors", result.errors);
|
|
728
727
|
return result;
|
|
729
728
|
}
|
|
730
|
-
// Consumer runtime compat shim from prior 0xRay releases (1-line min per Scope Rule; primary xray paths +
|
|
729
|
+
// Consumer runtime compat shim from prior 0xRay releases (1-line min per Scope Rule; primary xray paths + .xray fallbacks)
|
|
731
730
|
async loadXrayConfiguration(jobId) {
|
|
732
731
|
try {
|
|
733
|
-
// Consumer runtime compat shim from prior 0xRay releases (1-line min per Scope Rule; primary xray paths +
|
|
732
|
+
// Consumer runtime compat shim from prior 0xRay releases (1-line min per Scope Rule; primary xray paths + .xray fallbacks)
|
|
734
733
|
const xrayConfig = {
|
|
735
|
-
version: "1.
|
|
734
|
+
version: "3.1.0",
|
|
736
735
|
codex_enabled: true,
|
|
737
736
|
codex_version: "v1.7.5",
|
|
738
737
|
codex_terms: [
|
package/dist/core/bridge.mjs
CHANGED
|
@@ -69,7 +69,7 @@ let frameworkLoadAttempted = false;
|
|
|
69
69
|
// ============================================================================
|
|
70
70
|
|
|
71
71
|
function findProjectRoot() {
|
|
72
|
-
const envHome = process.env.
|
|
72
|
+
const envHome = process.env.XRAY_HOME;
|
|
73
73
|
if (envHome && existsSync(join(envHome, "package.json"))) return envHome;
|
|
74
74
|
|
|
75
75
|
const candidates = [
|
|
@@ -219,7 +219,7 @@ async function handleHealth(input) {
|
|
|
219
219
|
*/
|
|
220
220
|
/** Codex candidate paths — single source of truth for both loadCodexFromFs and handleGetConfig */
|
|
221
221
|
function getCodexCandidates(projectRoot) {
|
|
222
|
-
const envDir = process.env.
|
|
222
|
+
const envDir = process.env.XRAY_CONFIG_DIR;
|
|
223
223
|
const candidates = [];
|
|
224
224
|
if (envDir) candidates.push(join(projectRoot, envDir, "codex.json"));
|
|
225
225
|
candidates.push(join(projectRoot, ".xray", "codex.json"));
|
|
@@ -747,8 +747,8 @@ function startHttpServer(port, projectRoot) {
|
|
|
747
747
|
|
|
748
748
|
return new Promise((resolve, reject) => {
|
|
749
749
|
const server = createServer(async (req, res) => {
|
|
750
|
-
// CORS headers (wildcard — restrict via
|
|
751
|
-
const corsOrigin = process.env.
|
|
750
|
+
// CORS headers (wildcard — restrict via XRAY_HTTP_CORS_ORIGIN env var in production)
|
|
751
|
+
const corsOrigin = process.env.XRAY_HTTP_CORS_ORIGIN || "*";
|
|
752
752
|
res.setHeader("Content-Type", "application/json");
|
|
753
753
|
res.setHeader("Access-Control-Allow-Origin", corsOrigin);
|
|
754
754
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
|
@@ -84,13 +84,12 @@ export const BUILTIN_CODEX = {
|
|
|
84
84
|
*/
|
|
85
85
|
export function findCodexPath(projectRoot) {
|
|
86
86
|
const root = projectRoot || process.cwd();
|
|
87
|
-
const envDir = process.env.
|
|
87
|
+
const envDir = process.env.XRAY_CONFIG_DIR;
|
|
88
88
|
const candidates = [];
|
|
89
89
|
if (envDir) {
|
|
90
90
|
candidates.push(resolve(root, envDir, "codex.json"));
|
|
91
91
|
}
|
|
92
92
|
candidates.push(join(root, ".xray", "codex.json"));
|
|
93
|
-
candidates.push(join(root, ".opencode", "xray", "codex.json"));
|
|
94
93
|
// Additional fallback locations (for standalone usage)
|
|
95
94
|
candidates.push(join(root, "codex.json"));
|
|
96
95
|
candidates.push(join(root, "src", "codex.json"));
|
|
@@ -38,7 +38,7 @@ async function initializeImports() {
|
|
|
38
38
|
const codexCache = new Map();
|
|
39
39
|
/**
|
|
40
40
|
* Codex file locations resolved through the standard priority chain.
|
|
41
|
-
* Uses config-paths.ts resolver so
|
|
41
|
+
* Uses config-paths.ts resolver so XRAY_CONFIG_DIR and .xray/ work.
|
|
42
42
|
*/
|
|
43
43
|
function getCodexFileLocations(projectRoot) {
|
|
44
44
|
const root = projectRoot || process.cwd();
|
|
@@ -170,7 +170,7 @@ export function createXrayCodexInjectorHook() {
|
|
|
170
170
|
});
|
|
171
171
|
// Skip codex enforcement during testing
|
|
172
172
|
if (process.env.NODE_ENV === "test" ||
|
|
173
|
-
process.env.
|
|
173
|
+
process.env.XRAY_TEST_MODE === "true") {
|
|
174
174
|
await frameworkLogger.log("codex-injector", "skipping enforcement in test mode", "info", { jobId });
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
@@ -263,7 +263,7 @@ export function createXrayCodexInjectorHook() {
|
|
|
263
263
|
frameworkLogger.log("codex-injector", "tool.execute.after hook triggered", "info", { jobId, tool: input.tool, sessionId });
|
|
264
264
|
// Skip codex enforcement during testing
|
|
265
265
|
if (process.env.NODE_ENV === "test" ||
|
|
266
|
-
process.env.
|
|
266
|
+
process.env.XRAY_TEST_MODE === "true") {
|
|
267
267
|
frameworkLogger.log("codex-injector", "skipping injection in test mode", "info", { jobId });
|
|
268
268
|
return output;
|
|
269
269
|
}
|
|
@@ -146,5 +146,4 @@ export class XrayConfigLoader {
|
|
|
146
146
|
}
|
|
147
147
|
// Export singleton instance
|
|
148
148
|
export const xrayConfigLoader = new XrayConfigLoader();
|
|
149
|
-
|
|
150
|
-
export { xrayConfigLoader as strRayConfigLoader };
|
|
149
|
+
// Backward compat aliases
|
|
@@ -2,17 +2,15 @@
|
|
|
2
2
|
* Config Path Resolver
|
|
3
3
|
*
|
|
4
4
|
* Centralizes all 0xRay config file path resolution.
|
|
5
|
-
* Supports
|
|
6
|
-
* making .opencode/ completely optional for environments like Hermes Agent.
|
|
5
|
+
* Supports XRAY_CONFIG_DIR env var for custom config roots.
|
|
7
6
|
*
|
|
8
7
|
* Resolution order (per file type):
|
|
9
|
-
* 1.
|
|
8
|
+
* 1. XRAY_CONFIG_DIR/<relative_path> (if env var set)
|
|
10
9
|
* 2. .xray/<relative_path> (preferred lightweight root)
|
|
11
|
-
* 3.
|
|
12
|
-
* 4. null (callers fall back to built-in defaults)
|
|
10
|
+
* 3. null (callers fall back to built-in defaults)
|
|
13
11
|
*
|
|
14
12
|
* For state/data directories, uses:
|
|
15
|
-
* 1.
|
|
13
|
+
* 1. XRAY_CONFIG_DIR/state (if env var set)
|
|
16
14
|
* 2. .xray/state
|
|
17
15
|
* 3. .opencode/state (legacy)
|
|
18
16
|
* 4. .xray/state (default — always writable)
|
|
@@ -20,7 +18,7 @@
|
|
|
20
18
|
import { existsSync } from "fs";
|
|
21
19
|
import { join, resolve } from "path";
|
|
22
20
|
/** Environment variable name for custom config root */
|
|
23
|
-
export const
|
|
21
|
+
export const XRAY_CONFIG_DIR_ENV = "XRAY_CONFIG_DIR";
|
|
24
22
|
/** Resolved config directories, cached per projectRoot */
|
|
25
23
|
const _resolvedConfigDirs = new Map();
|
|
26
24
|
/**
|
|
@@ -28,11 +26,11 @@ const _resolvedConfigDirs = new Map();
|
|
|
28
26
|
* Scans in priority order and caches the first one that exists (or the first default).
|
|
29
27
|
*/
|
|
30
28
|
export function getConfigDir(projectRoot) {
|
|
31
|
-
const root = projectRoot
|
|
29
|
+
const root = resolveRoot(projectRoot);
|
|
32
30
|
const cached = _resolvedConfigDirs.get(root);
|
|
33
31
|
if (cached)
|
|
34
32
|
return cached;
|
|
35
|
-
const envDir = process.env[
|
|
33
|
+
const envDir = process.env[XRAY_CONFIG_DIR_ENV];
|
|
36
34
|
// Priority candidates
|
|
37
35
|
const candidates = [];
|
|
38
36
|
if (envDir) {
|
|
@@ -41,7 +39,6 @@ export function getConfigDir(projectRoot) {
|
|
|
41
39
|
candidates.push({ dir: resolved, source: "env" });
|
|
42
40
|
}
|
|
43
41
|
candidates.push({ dir: join(root, ".xray"), source: "dot-xray" });
|
|
44
|
-
candidates.push({ dir: join(root, ".opencode", "xray"), source: "dot-opencode" });
|
|
45
42
|
// Return the first that exists, or the highest-priority default
|
|
46
43
|
for (const c of candidates) {
|
|
47
44
|
if (existsSync(c.dir)) {
|
|
@@ -49,7 +46,7 @@ export function getConfigDir(projectRoot) {
|
|
|
49
46
|
return c.dir;
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
|
-
// Nothing exists — use highest priority default (env > .xray
|
|
49
|
+
// Nothing exists — use highest priority default (env > .xray)
|
|
53
50
|
const defaultDir = candidates[0];
|
|
54
51
|
_resolvedConfigDirs.set(root, defaultDir.dir);
|
|
55
52
|
return defaultDir.dir;
|
|
@@ -62,14 +59,13 @@ export function getConfigDir(projectRoot) {
|
|
|
62
59
|
* @param projectRoot - Optional project root override
|
|
63
60
|
*/
|
|
64
61
|
export function resolveConfigPath(relativePath, projectRoot) {
|
|
65
|
-
const root = projectRoot
|
|
66
|
-
const envDir = process.env[
|
|
62
|
+
const root = resolveRoot(projectRoot);
|
|
63
|
+
const envDir = process.env[XRAY_CONFIG_DIR_ENV];
|
|
67
64
|
const candidates = [];
|
|
68
65
|
if (envDir) {
|
|
69
66
|
candidates.push(resolve(root, envDir, relativePath));
|
|
70
67
|
}
|
|
71
68
|
candidates.push(join(root, ".xray", relativePath));
|
|
72
|
-
candidates.push(join(root, ".opencode", "xray", relativePath));
|
|
73
69
|
for (const candidate of candidates) {
|
|
74
70
|
if (existsSync(candidate)) {
|
|
75
71
|
return candidate;
|
|
@@ -84,8 +80,8 @@ export function resolveConfigPath(relativePath, projectRoot) {
|
|
|
84
80
|
* Similar logic to resolveConfigPath but for the state/ subdirectory.
|
|
85
81
|
*/
|
|
86
82
|
export function resolveStateDir(projectRoot) {
|
|
87
|
-
const root = projectRoot
|
|
88
|
-
const envDir = process.env[
|
|
83
|
+
const root = resolveRoot(projectRoot);
|
|
84
|
+
const envDir = process.env[XRAY_CONFIG_DIR_ENV];
|
|
89
85
|
const candidates = [];
|
|
90
86
|
if (envDir) {
|
|
91
87
|
candidates.push(join(root, envDir, "state"));
|
|
@@ -111,14 +107,13 @@ export function resolveStateFilePath(projectRoot) {
|
|
|
111
107
|
* Get the profiles storage directory.
|
|
112
108
|
*/
|
|
113
109
|
export function resolveProfilesDir(projectRoot) {
|
|
114
|
-
const root = projectRoot
|
|
115
|
-
const envDir = process.env[
|
|
110
|
+
const root = resolveRoot(projectRoot);
|
|
111
|
+
const envDir = process.env[XRAY_CONFIG_DIR_ENV];
|
|
116
112
|
const candidates = [];
|
|
117
113
|
if (envDir) {
|
|
118
114
|
candidates.push(join(root, envDir, "profiles"));
|
|
119
115
|
}
|
|
120
116
|
candidates.push(join(root, ".xray", "profiles"));
|
|
121
|
-
candidates.push(join(root, ".opencode", "xray", "profiles"));
|
|
122
117
|
for (const candidate of candidates) {
|
|
123
118
|
if (existsSync(candidate)) {
|
|
124
119
|
return candidate;
|
|
@@ -130,16 +125,28 @@ export function resolveProfilesDir(projectRoot) {
|
|
|
130
125
|
* Resolve codex.json path.
|
|
131
126
|
* Has additional fallback locations beyond the standard config dir.
|
|
132
127
|
*/
|
|
128
|
+
/** Environment variable for explicit project root override */
|
|
129
|
+
export const XRAY_ROOT_ENV = "XRAY_ROOT";
|
|
130
|
+
/**
|
|
131
|
+
* Resolve project root using XRAY_ROOT env var if set,
|
|
132
|
+
* otherwise fall back to projectRoot param or cwd.
|
|
133
|
+
*/
|
|
134
|
+
export function resolveProjectRoot(projectRoot) {
|
|
135
|
+
return process.env[XRAY_ROOT_ENV] || projectRoot || process.cwd();
|
|
136
|
+
}
|
|
137
|
+
/** @deprecated Use resolveProjectRoot — kept for internal consistency */
|
|
138
|
+
function resolveRoot(projectRoot) {
|
|
139
|
+
return resolveProjectRoot(projectRoot);
|
|
140
|
+
}
|
|
133
141
|
export function resolveCodexPath(projectRoot) {
|
|
134
|
-
const root = projectRoot
|
|
135
|
-
const envDir = process.env[
|
|
142
|
+
const root = resolveRoot(projectRoot);
|
|
143
|
+
const envDir = process.env[XRAY_CONFIG_DIR_ENV];
|
|
136
144
|
const candidates = [];
|
|
137
145
|
if (envDir) {
|
|
138
146
|
candidates.push(join(root, envDir, "codex.json"));
|
|
139
147
|
}
|
|
140
148
|
candidates.push(join(root, ".xray", "codex.json"));
|
|
141
149
|
candidates.push(join(root, "xray", "codex.json"));
|
|
142
|
-
candidates.push(join(root, ".opencode", "xray", "codex.json"));
|
|
143
150
|
// Additional fallback locations (for standalone usage)
|
|
144
151
|
candidates.push(join(root, "codex.json"));
|
|
145
152
|
candidates.push(join(root, "src", "codex.json"));
|
|
@@ -150,7 +157,7 @@ export function resolveCodexPath(projectRoot) {
|
|
|
150
157
|
* Get the logs directory for framework logging.
|
|
151
158
|
*/
|
|
152
159
|
export function resolveLogDir(projectRoot) {
|
|
153
|
-
const root = projectRoot
|
|
160
|
+
const root = resolveRoot(projectRoot);
|
|
154
161
|
// Logs always go to logs/framework/ regardless of config dir
|
|
155
162
|
return join(root, "logs", "framework");
|
|
156
163
|
}
|
|
@@ -267,6 +267,3 @@ export class XrayContextLoader {
|
|
|
267
267
|
* Export singleton instance
|
|
268
268
|
*/
|
|
269
269
|
export const xrayContextLoader = XrayContextLoader.getInstance();
|
|
270
|
-
// Backward compat aliases
|
|
271
|
-
export { XrayContextLoader as StringRayContextLoader };
|
|
272
|
-
export { xrayContextLoader as strRayContextLoader };
|
package/dist/core/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { KernelOrchestrator } from "./orchestrator.js";
|
|
2
|
-
export { defaultXrayConfig
|
|
2
|
+
export { defaultXrayConfig } from "./xray-activation.js";
|
|
3
3
|
// Decoupled config path resolution (Layer 1)
|
|
4
|
-
export { getConfigDir, resolveConfigPath, resolveStateDir, resolveProfilesDir, resolveCodexPath, resolveLogDir, resetConfigDirCache,
|
|
4
|
+
export { getConfigDir, resolveConfigPath, resolveStateDir, resolveProfilesDir, resolveCodexPath, resolveLogDir, resetConfigDirCache, XRAY_CONFIG_DIR_ENV, } from "./config-paths.js";
|
|
5
5
|
// Standalone codex formatter (Layer 2)
|
|
6
6
|
export { formatCodexPrompt, formatMinimalCodexPrompt, getCodexConfig, findCodexPath, loadCodex, BUILTIN_CODEX, } from "./codex-formatter.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Default logging configuration
|
|
2
2
|
const defaultLoggingConfig = {
|
|
3
|
-
enabled: process.env.
|
|
4
|
-
level: process.env.
|
|
3
|
+
enabled: process.env.XRAY_LOGGING_ENABLED !== "false", // Default true, can be disabled
|
|
4
|
+
level: process.env.XRAY_LOG_LEVEL || "info",
|
|
5
5
|
destinations: ["console", "file"],
|
|
6
|
-
performanceMode: process.env.
|
|
6
|
+
performanceMode: process.env.XRAY_PERFORMANCE_MODE === "true",
|
|
7
7
|
};
|
|
8
8
|
// Available log levels in priority order (higher index = more verbose)
|
|
9
9
|
const LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
@@ -32,12 +32,12 @@ export function shouldLog(level) {
|
|
|
32
32
|
return messageLevelIndex >= currentLevelIndex;
|
|
33
33
|
}
|
|
34
34
|
// Environment variable configuration
|
|
35
|
-
if (process.env.
|
|
35
|
+
if (process.env.XRAY_LOGGING_ENABLED === "false") {
|
|
36
36
|
setLoggingConfig({ enabled: false });
|
|
37
37
|
}
|
|
38
|
-
if (process.env.
|
|
39
|
-
setLoggingConfig({ level: process.env.
|
|
38
|
+
if (process.env.XRAY_LOG_LEVEL) {
|
|
39
|
+
setLoggingConfig({ level: process.env.XRAY_LOG_LEVEL });
|
|
40
40
|
}
|
|
41
|
-
if (process.env.
|
|
41
|
+
if (process.env.XRAY_PERFORMANCE_MODE === "true") {
|
|
42
42
|
setLoggingConfig({ performanceMode: true });
|
|
43
43
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Consumer runtime compat shim from prior 0xRay releases (1-line min per Scope Rule; primary xray paths +
|
|
2
|
+
* Consumer runtime compat shim from prior 0xRay releases (1-line min per Scope Rule; primary xray paths + .xray fallbacks).
|
|
3
3
|
*/
|
|
4
4
|
import { frameworkLogger } from "../core/framework-logger.js";
|
|
5
5
|
import { ensureCriticalComponents } from "../architect/architectural-integrity.js";
|
|
@@ -98,7 +98,7 @@ async function activateStateManagement(jobId) {
|
|
|
98
98
|
}
|
|
99
99
|
async function activateOrchestrator(jobId) {
|
|
100
100
|
frameworkLogger.log("xray-activation", "activating xray orchestrator", "info", { jobId });
|
|
101
|
-
const {
|
|
101
|
+
const { xrayOrchestrator } = await import("./orchestrator");
|
|
102
102
|
// Also activate the multi-agent orchestration coordinator
|
|
103
103
|
const { multiAgentOrchestrationCoordinator } = await import("../orchestrator/multi-agent-orchestration-coordinator");
|
|
104
104
|
frameworkLogger.log("xray-activation", "xray orchestrator and multi-agent coordination activated", "success", { jobId });
|
|
@@ -132,5 +132,4 @@ async function activatePostProcessor(jobId) {
|
|
|
132
132
|
globalThis.xrayCodexInjector = codexInjector;
|
|
133
133
|
frameworkLogger.log("xray-activation", "codex injector activated", "success", { jobId });
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
export { activateXrayFramework as activateStringRayFramework };
|
|
135
|
+
// Backward compat aliases
|
|
@@ -47,7 +47,7 @@ export class AgentDelegator {
|
|
|
47
47
|
const candidates = [
|
|
48
48
|
path.resolve(process.cwd(), ".xray/routing-mappings.json"),
|
|
49
49
|
path.resolve(process.cwd(), "xray/routing-mappings.json"),
|
|
50
|
-
path.resolve(process.cwd(), ".
|
|
50
|
+
path.resolve(process.cwd(), ".xray/routing-mappings.json"),
|
|
51
51
|
path.resolve(process.cwd(), "routing-mappings.json"),
|
|
52
52
|
];
|
|
53
53
|
for (const p of candidates) {
|
|
@@ -451,7 +451,7 @@ export class AgentDelegator {
|
|
|
451
451
|
*/
|
|
452
452
|
resolveProjectDirectory() {
|
|
453
453
|
const root = process.cwd();
|
|
454
|
-
if (fs.existsSync(`${root}/package.json`) || fs.existsSync(`${root}/
|
|
454
|
+
if (fs.existsSync(`${root}/package.json`) || fs.existsSync(`${root}/xray.config.json`)) {
|
|
455
455
|
return root;
|
|
456
456
|
}
|
|
457
457
|
let current = root;
|
|
@@ -6,7 +6,7 @@ import { ruleEnforcer, } from "./rule-enforcer.js";
|
|
|
6
6
|
import { frameworkLogger } from "../core/framework-logger.js";
|
|
7
7
|
import { AgentDelegator } from "../delegation/agent-delegator.js";
|
|
8
8
|
import { XrayStateManager } from "../state/state-manager.js";
|
|
9
|
-
import {
|
|
9
|
+
import { xrayConfigLoader } from "../core/config-loader.js";
|
|
10
10
|
import * as fs from "fs";
|
|
11
11
|
import * as path from "path";
|
|
12
12
|
// Minimum confidence to auto-delegate to another agent
|
|
@@ -327,7 +327,7 @@ async function delegateToAgent(agentName, operation, context, jobId) {
|
|
|
327
327
|
// Create a minimal state manager and config loader for the delegator
|
|
328
328
|
const stateManager = new XrayStateManager();
|
|
329
329
|
// Create the delegator
|
|
330
|
-
const delegator = new AgentDelegator(stateManager,
|
|
330
|
+
const delegator = new AgentDelegator(stateManager, xrayConfigLoader);
|
|
331
331
|
// Build task description for the delegated agent
|
|
332
332
|
const taskDescription = buildTaskDescription(operation, context);
|
|
333
333
|
// Build the delegation request
|
|
@@ -30,13 +30,13 @@ export class CodexLoader extends BaseLoader {
|
|
|
30
30
|
name = "codex";
|
|
31
31
|
/**
|
|
32
32
|
* Path to the codex.json file.
|
|
33
|
-
|
|
33
|
+
* Uses the standard config-paths resolver which checks .xray/, etc.
|
|
34
34
|
*/
|
|
35
35
|
get codexPath() {
|
|
36
36
|
const candidates = resolveCodexPath();
|
|
37
37
|
const found = candidates.find((p) => existsSync(p));
|
|
38
38
|
// Fallback to primary path even if not found yet
|
|
39
|
-
return found ?? candidates[0] ?? this.resolvePath(".
|
|
39
|
+
return found ?? candidates[0] ?? this.resolvePath(".xray/codex.json");
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Check if codex.json exists.
|
|
@@ -17,7 +17,7 @@ import { getConfigDir } from "../core/config-paths.js";
|
|
|
17
17
|
let opencodeAvailable = null;
|
|
18
18
|
export async function invokeViaOpencode(agentName, prompt, projectRoot = process.cwd()) {
|
|
19
19
|
// In pure MCP mode we must never reach here
|
|
20
|
-
if (process.env.
|
|
20
|
+
if (process.env.XRAY_FORCE_MCP_GOVERNANCE === "true") {
|
|
21
21
|
throw new Error(`[PURE MCP] invokeViaOpencode called for "${agentName}" — this path is forbidden.`);
|
|
22
22
|
}
|
|
23
23
|
// GATE: Centralized spawn gate — blocks all agent spawning by default
|
|
@@ -128,7 +128,7 @@ export class GovernanceService {
|
|
|
128
128
|
}
|
|
129
129
|
async callSkillServer(serverName, proposals, context) {
|
|
130
130
|
const votes = [];
|
|
131
|
-
const useInProcess = process.env.VERCEL === '1';
|
|
131
|
+
const useInProcess = process.env.VERCEL === '1' || !!process.env.RAILWAY_ENVIRONMENT;
|
|
132
132
|
for (const proposal of proposals) {
|
|
133
133
|
try {
|
|
134
134
|
let text = '';
|
|
@@ -59,8 +59,10 @@ function readHermesOAuthToken() {
|
|
|
59
59
|
if (!entry?.access_token && Array.isArray(data)) {
|
|
60
60
|
entry = data.find((e) => e.provider === "xai-oauth" || !!e.access_token);
|
|
61
61
|
}
|
|
62
|
-
if (!entry?.access_token)
|
|
62
|
+
if (!entry?.access_token) {
|
|
63
|
+
process.stderr.write("[llm] readHermesOAuthToken: no access_token in auth file\n");
|
|
63
64
|
return null;
|
|
65
|
+
}
|
|
64
66
|
if (entry.expires_at && Date.now() / 1000 > entry.expires_at) {
|
|
65
67
|
frameworkLogger.log("llm-governance", "hermes-token-expired", "warning", { expiresAt: entry.expires_at });
|
|
66
68
|
return null;
|
|
@@ -82,16 +84,25 @@ function getConfig() {
|
|
|
82
84
|
const directModel = process.env.XRAY_LLM_MODEL ||
|
|
83
85
|
process.env.XRAY_GOVERNANCE_LLM_MODEL ||
|
|
84
86
|
"gpt-4o";
|
|
87
|
+
// First try: direct env-var config (highest priority)
|
|
85
88
|
const directEnabled = process.env.XRAY_GOVERNANCE_LLM_ENABLED === "true" ||
|
|
86
89
|
process.env.XRAY_LLM_ENABLED === "true";
|
|
87
90
|
if (directEnabled && directEndpoint && directApiKey) {
|
|
88
91
|
return { endpoint: directEndpoint, apiKey: directApiKey, model: directModel };
|
|
89
92
|
}
|
|
93
|
+
// Second try: Hermes xAI OAuth token from ~/.hermes/auth.json
|
|
90
94
|
const hermesToken = readHermesOAuthToken();
|
|
91
95
|
if (hermesToken) {
|
|
92
96
|
frameworkLogger.log("llm-governance", "using-hermes-oauth", "info", { provider: "xai-oauth", endpoint: XAI_ENDPOINT, model: XAI_MODEL });
|
|
93
97
|
return { endpoint: XAI_ENDPOINT, apiKey: hermesToken, model: XAI_MODEL };
|
|
94
98
|
}
|
|
99
|
+
// Third try: direct endpoint even without explicit enable flag (if endpoint+key set)
|
|
100
|
+
if (directEndpoint && directApiKey) {
|
|
101
|
+
return { endpoint: directEndpoint, apiKey: directApiKey, model: directModel };
|
|
102
|
+
}
|
|
103
|
+
if (process.env.DEBUG_LLM) {
|
|
104
|
+
process.stderr.write("[llm-debug] No config found. directEnabled=" + directEnabled + " endpoint=" + !!directEndpoint + " apiKey=" + !!directApiKey + " hermes=" + !!hermesToken + "\n");
|
|
105
|
+
}
|
|
95
106
|
return null;
|
|
96
107
|
}
|
|
97
108
|
function parseVote(text) {
|
|
@@ -111,8 +122,10 @@ function parseVote(text) {
|
|
|
111
122
|
export async function tryLLMGovernance(role, proposalTitle, proposalDescription, evidence, proposalType) {
|
|
112
123
|
const config = getConfig();
|
|
113
124
|
if (!config) {
|
|
125
|
+
process.stderr.write("[llm] no config for role=" + role + "\n");
|
|
114
126
|
return null;
|
|
115
127
|
}
|
|
128
|
+
process.stderr.write("[llm] using config endpoint=" + config.endpoint + " model=" + config.model + "\n");
|
|
116
129
|
const systemPrompt = ROLE_PROMPTS[role];
|
|
117
130
|
const userMessage = `## Proposal
|
|
118
131
|
|
package/dist/index.js
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* This is the main entry point for the 0xRay framework.
|
|
5
5
|
* It exports the core initialization function and key components.
|
|
6
6
|
*/
|
|
7
|
-
export { XrayOrchestrator
|
|
8
|
-
export { XrayStateManager
|
|
7
|
+
export { XrayOrchestrator } from "./orchestrator/orchestrator.js";
|
|
8
|
+
export { XrayStateManager } from "./state/index.js";
|
|
9
9
|
export { AgentDelegator } from "./delegation/index.js";
|
|
10
10
|
export { frameworkLogger } from "./core/framework-logger.js";
|
|
11
11
|
export { BUILTIN_CODEX } from "./core/codex-formatter.js";
|
|
12
12
|
import { defaultXrayConfig } from "./core/index.js";
|
|
13
|
-
export { defaultXrayConfig
|
|
13
|
+
export { defaultXrayConfig };
|
|
14
14
|
export { OpenClawIntegration, initializeOpenClawIntegration, getOpenClawIntegration, shutdownOpenClawIntegration } from "./integrations/openclaw/index.js";
|
|
15
15
|
// Main initialization function
|
|
16
16
|
export function initializeXray(config = {}) {
|
|
@@ -22,5 +22,3 @@ export function initializeXray(config = {}) {
|
|
|
22
22
|
message: "0xRay framework initialized successfully",
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
// Backward compat alias
|
|
26
|
-
export { initializeXray as initializeStringRay };
|