0xray 3.2.0 → 3.3.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.
Files changed (36) hide show
  1. package/.opencode/codex.codex +1 -1
  2. package/dist/CHANGELOG.md +36 -0
  3. package/dist/core/features-config.js +3 -0
  4. package/dist/integrations/grok/grok-cli.js +6 -0
  5. package/dist/mcps/index.js +1 -0
  6. package/dist/mcps/knowledge-skills/skill-invocation.server.js +3 -2
  7. package/dist/mcps/knowledge-skills/storyteller.server.js +167 -0
  8. package/dist/mcps/orchestrator/config/agent-capabilities.js +30 -11
  9. package/dist/mcps/orchestrator/config/memory-routing-bridge.js +70 -0
  10. package/dist/mcps/orchestrator/execution/execution-planner.js +38 -8
  11. package/dist/mcps/orchestrator/handlers/task-handler.js +55 -2
  12. package/dist/mcps/researcher-confidence.js +92 -0
  13. package/dist/mcps/researcher.server.js +19 -3
  14. package/dist/memory-routing/index.js +4 -0
  15. package/dist/memory-routing/null-provider.js +63 -0
  16. package/dist/memory-routing/provider-loader.js +91 -0
  17. package/dist/memory-routing/provider-registry.js +40 -0
  18. package/dist/memory-routing/types.js +7 -0
  19. package/dist/memory-routing/validate-config.js +32 -0
  20. package/dist/nucleus/thin-dispatch.js +29 -1
  21. package/package.json +1 -1
  22. package/scripts/node/install-bridges.cjs +364 -0
  23. package/scripts/node/postinstall.cjs +24 -83
  24. package/scripts/node/setup.cjs +2 -6
  25. package/scripts/node/universal-version-manager.js +2 -2
  26. package/src/mcps/index.ts +1 -0
  27. package/src/mcps/knowledge-skills/skill-invocation.server.ts +3 -2
  28. package/src/mcps/knowledge-skills/storyteller.server.ts +206 -0
  29. package/src/mcps/orchestrator/config/agent-capabilities.ts +49 -14
  30. package/src/mcps/orchestrator/config/memory-routing-bridge.ts +80 -0
  31. package/src/mcps/orchestrator/execution/execution-planner.ts +49 -10
  32. package/src/mcps/orchestrator/handlers/task-handler.ts +71 -2
  33. package/src/mcps/orchestrator/types.ts +17 -0
  34. package/src/mcps/researcher-confidence.ts +144 -0
  35. package/src/mcps/researcher.server.ts +28 -3
  36. package/src/opencode/codex.codex +1 -1
@@ -0,0 +1,144 @@
1
+ import { frameworkLogger } from '../core/framework-logger.js';
2
+ import { getMemoryRoutingProviderSync } from '../memory-routing/index.js';
3
+ import type {
4
+ MemoryRoutingContext,
5
+ MemoryTaskConfidence,
6
+ } from '../memory-routing/types.js';
7
+
8
+ const TRAP_LANGUAGE = /TYPE:\s*ontological-trap|ontological[- ]trap/i;
9
+ const DEFAULT_MIN_CONFIDENCE_GATE = 0.55;
10
+
11
+ export interface ResearcherMemoryContext {
12
+ providerId: string;
13
+ confidence: MemoryTaskConfidence;
14
+ matchedSignals: string[];
15
+ recommendedAgent: string | null;
16
+ triggeredBy: 'trap-language' | 'high-confidence-primitives';
17
+ }
18
+
19
+ export function shouldQueryRepertoireConfidence(
20
+ description: string,
21
+ proposalType = '',
22
+ ): boolean {
23
+ const text = `${description} ${proposalType}`.trim();
24
+ return TRAP_LANGUAGE.test(text);
25
+ }
26
+
27
+ export function hasHighConfidencePrimitiveMatch(
28
+ routingContext: MemoryRoutingContext,
29
+ minConfidence = DEFAULT_MIN_CONFIDENCE_GATE,
30
+ ): boolean {
31
+ const confidences = routingContext.signalConfidences ?? {};
32
+ return Object.values(confidences).some((confidence) => confidence >= minConfidence);
33
+ }
34
+
35
+ function buildTaskText(
36
+ proposalTitle: string,
37
+ proposalDescription: string,
38
+ proposalType: string,
39
+ ): string {
40
+ return [proposalTitle, proposalDescription, proposalType].filter(Boolean).join('\n');
41
+ }
42
+
43
+ /**
44
+ * Resolve Repertoire task confidence for researcher proposal analysis.
45
+ * Triggered by ontological-trap language or high-confidence primitive matches.
46
+ */
47
+ export function resolveResearcherMemoryContext(input: {
48
+ proposalTitle?: string;
49
+ proposalDescription?: string;
50
+ proposalType?: string;
51
+ }): ResearcherMemoryContext | null {
52
+ const proposalTitle = input.proposalTitle ?? '';
53
+ const proposalDescription = input.proposalDescription ?? '';
54
+ const proposalType = input.proposalType ?? '';
55
+ const taskText = buildTaskText(proposalTitle, proposalDescription, proposalType);
56
+
57
+ const provider = getMemoryRoutingProviderSync();
58
+ if (provider.id === 'null' || !provider.getTaskConfidence) {
59
+ return null;
60
+ }
61
+
62
+ const trapLanguageDetected = shouldQueryRepertoireConfidence(
63
+ proposalDescription,
64
+ proposalType,
65
+ );
66
+ const routingContext = provider.buildRoutingContext(taskText);
67
+ const primitiveMatchDetected = hasHighConfidencePrimitiveMatch(routingContext);
68
+
69
+ if (!trapLanguageDetected && !primitiveMatchDetected) {
70
+ return null;
71
+ }
72
+
73
+ const confidence = provider.getTaskConfidence({
74
+ id: 'researcher-proposal',
75
+ description: taskText,
76
+ type: proposalType || 'governance',
77
+ });
78
+
79
+ const matchedSignals =
80
+ confidence.matchedSignals.length > 0
81
+ ? confidence.matchedSignals
82
+ : routingContext.matchedSignals;
83
+
84
+ const context: ResearcherMemoryContext = {
85
+ providerId: provider.id,
86
+ confidence,
87
+ matchedSignals,
88
+ recommendedAgent: confidence.recommendedAgent,
89
+ triggeredBy: trapLanguageDetected ? 'trap-language' : 'high-confidence-primitives',
90
+ };
91
+
92
+ if (confidence.highConfidenceTrapPresent) {
93
+ frameworkLogger.log('mcps/researcher', 'repertoire-trap-detected', 'info', {
94
+ providerId: provider.id,
95
+ matchedSignals,
96
+ complexityBoost: confidence.complexityBoost,
97
+ recommendedAgent: confidence.recommendedAgent,
98
+ triggeredBy: context.triggeredBy,
99
+ });
100
+ }
101
+
102
+ return context;
103
+ }
104
+
105
+ export function buildMemoryRoutingEvidence(
106
+ context: ResearcherMemoryContext,
107
+ ): string[] {
108
+ const { confidence, matchedSignals, recommendedAgent } = context;
109
+ const signalSummary = confidence.signals
110
+ .map((entry) => `${entry.name} (${entry.confidence.toFixed(2)})`)
111
+ .join(', ');
112
+
113
+ const lines = [
114
+ `Repertoire memory routing (${context.providerId}, trigger: ${context.triggeredBy})`,
115
+ `Matched signals: ${matchedSignals.join(', ') || 'none'}`,
116
+ `Signal confidences: ${signalSummary || 'none'}`,
117
+ `High-confidence trap present: ${confidence.highConfidenceTrapPresent}`,
118
+ `Complexity boost: ${confidence.complexityBoost}`,
119
+ ];
120
+
121
+ if (recommendedAgent) {
122
+ lines.push(`Recommended agent for trap handling: ${recommendedAgent}`);
123
+ }
124
+
125
+ return lines;
126
+ }
127
+
128
+ export function formatMemoryRoutingBlock(context: ResearcherMemoryContext): string {
129
+ const { confidence, matchedSignals, recommendedAgent } = context;
130
+ const lines = [
131
+ 'MEMORY_ROUTING:',
132
+ ` provider: ${context.providerId}`,
133
+ ` trigger: ${context.triggeredBy}`,
134
+ ` matchedSignals: ${matchedSignals.join(', ') || 'none'}`,
135
+ ` highConfidenceTrapPresent: ${confidence.highConfidenceTrapPresent}`,
136
+ ` complexityBoost: ${confidence.complexityBoost}`,
137
+ ];
138
+
139
+ if (recommendedAgent) {
140
+ lines.push(` recommendedAgent: ${recommendedAgent}`);
141
+ }
142
+
143
+ return lines.join('\n');
144
+ }
@@ -13,6 +13,11 @@ import * as fs from "fs";
13
13
  import * as path from "path";
14
14
  import { frameworkLogger } from "../core/framework-logger.js";
15
15
  import { tryLLMGovernance } from "../governance/llm-governance-provider.js";
16
+ import {
17
+ buildMemoryRoutingEvidence,
18
+ formatMemoryRoutingBlock,
19
+ resolveResearcherMemoryContext,
20
+ } from "./researcher-confidence.js";
16
21
  import { XrayKnowledgeSkillBase } from "./shared/knowledge-skill-base.js";
17
22
 
18
23
  interface SearchResult {
@@ -452,20 +457,40 @@ class XrayLibrarianServer extends XrayKnowledgeSkillBase {
452
457
  async analyzeProposal(args: AnalyzeProposalArgs): Promise<CallToolResult> {
453
458
  const { proposalTitle = "", proposalDescription = "", evidence = [], proposalType = "" } = args || {};
454
459
 
460
+ const memoryContext = resolveResearcherMemoryContext({
461
+ proposalTitle,
462
+ proposalDescription,
463
+ proposalType,
464
+ });
465
+
466
+ const enrichedEvidence = [...(evidence || [])];
467
+ if (memoryContext?.confidence.highConfidenceTrapPresent) {
468
+ enrichedEvidence.push(...buildMemoryRoutingEvidence(memoryContext));
469
+ }
470
+
455
471
  const vote = await tryLLMGovernance(
456
472
  "researcher",
457
473
  proposalTitle || "",
458
474
  proposalDescription || "",
459
- evidence || [],
475
+ enrichedEvidence,
460
476
  proposalType || "",
461
477
  );
462
478
 
479
+ const memoryRoutingBlock =
480
+ memoryContext?.confidence.highConfidenceTrapPresent
481
+ ? `\n${formatMemoryRoutingBlock(memoryContext)}`
482
+ : "";
483
+
463
484
  if (!vote) {
485
+ const abstainReason = memoryContext?.confidence.highConfidenceTrapPresent
486
+ ? "No LLM governance provider configured. Repertoire detected a high-confidence ontological trap — route to the recommended agent before proceeding."
487
+ : "No LLM governance provider configured. Set XRAY_GOVERNANCE_LLM_ENABLED=true + XRAY_LLM_ENDPOINT, or install Hermes and run: hermes auth add xai-oauth --no-browser";
488
+
464
489
  return {
465
490
  content: [
466
491
  {
467
492
  type: "text",
468
- text: "DECISION: abstain\nCONFIDENCE: 0.50\nREASONING: No LLM governance provider configured. Set XRAY_GOVERNANCE_LLM_ENABLED=true + XRAY_LLM_ENDPOINT, or install Hermes and run: hermes auth add xai-oauth --no-browser",
493
+ text: `DECISION: abstain\nCONFIDENCE: 0.50\nREASONING: ${abstainReason}${memoryRoutingBlock}`,
469
494
  },
470
495
  ],
471
496
  };
@@ -475,7 +500,7 @@ class XrayLibrarianServer extends XrayKnowledgeSkillBase {
475
500
  content: [
476
501
  {
477
502
  type: "text",
478
- text: `DECISION: ${vote.decision}\nCONFIDENCE: ${vote.confidence.toFixed(2)}\nREASONING: ${vote.reasoning}`,
503
+ text: `DECISION: ${vote.decision}\nCONFIDENCE: ${vote.confidence.toFixed(2)}\nREASONING: ${vote.reasoning}${memoryRoutingBlock}`,
479
504
  },
480
505
  ],
481
506
  };
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.2.0",
2
+ "version": "3.3.1",
3
3
  "terms": [
4
4
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60
5
5
  ],