create-byan-agent 2.5.0 → 2.6.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.
@@ -13,6 +13,8 @@ const FiveWhysAnalyzer = require('./dispatcher/five-whys-analyzer');
13
13
  const ActiveListener = require('./orchestrator/active-listener');
14
14
  const MantraValidator = require('./generation/mantra-validator');
15
15
  const VoiceIntegration = require('./integration/voice-integration');
16
+ const EloEngine = require('./elo/index');
17
+ const FactChecker = require('./fact-check/index');
16
18
 
17
19
  const crypto = require('crypto');
18
20
  const fs = require('fs');
@@ -119,6 +121,23 @@ class ByanV2 {
119
121
  }
120
122
  }
121
123
 
124
+ // EloEngine
125
+ if (bmadConfig.elo?.enabled !== false) {
126
+ this.eloEngine = new EloEngine({
127
+ storagePath: bmadConfig.elo?.storage_path
128
+ });
129
+ this.logger.info('[ByanV2] ELO trust system enabled');
130
+ }
131
+
132
+ // FactChecker
133
+ if (bmadConfig.fact_check?.enabled !== false) {
134
+ this.factChecker = new FactChecker({
135
+ ...bmadConfig.fact_check,
136
+ graph_path: bmadConfig.fact_check?.graph_path || '_byan/_memory/fact-graph.json'
137
+ }, this.sessionState);
138
+ this.logger.info('[ByanV2] Fact-check system enabled');
139
+ }
140
+
122
141
  // VoiceIntegration
123
142
  if (bmadConfig.voice_integration?.enabled !== false) {
124
143
  this.voiceIntegration = new VoiceIntegration(this.sessionState, this.logger);
@@ -170,6 +189,10 @@ class ByanV2 {
170
189
 
171
190
  this.metrics.increment('sessionsStarted');
172
191
 
192
+ if (this.eloEngine) {
193
+ this.eloEngine.applyIdleDecay();
194
+ }
195
+
173
196
  await this.stateMachine.transition('INTERVIEW');
174
197
 
175
198
  this.logger.info('State transition', {
@@ -640,12 +663,143 @@ class ByanV2 {
640
663
  }
641
664
 
642
665
  async getSessionSummary() {
643
- return {
666
+ const summary = {
644
667
  sessionId: this.sessionState.sessionId,
645
668
  questionsAsked: this.sessionState.userResponses.length,
646
669
  state: this.stateMachine.getCurrentState().name,
647
670
  timestamp: new Date().toISOString()
648
671
  };
672
+
673
+ if (this.eloEngine) {
674
+ summary.elo = this.eloEngine.getSummary();
675
+ summary.recommendedModel = this.eloEngine.routeLLM().model;
676
+ }
677
+
678
+ if (this.factChecker) {
679
+ summary.factCheck = { enabled: true, mode: this.factChecker.config.mode };
680
+ }
681
+
682
+ return summary;
683
+ }
684
+
685
+ // ========================================
686
+ // ELO Trust System Methods
687
+ // ========================================
688
+
689
+ /**
690
+ * Get challenge configuration for the LLM before evaluating a claim.
691
+ * @param {string} domain
692
+ * @returns {ChallengeContext}
693
+ */
694
+ getClaimContext(domain) {
695
+ if (!this.eloEngine) throw new Error('ELO system not enabled');
696
+ return this.eloEngine.evaluateContext(domain);
697
+ }
698
+
699
+ /**
700
+ * Record the result of a claim evaluation and update ELO.
701
+ * @param {string} domain
702
+ * @param {'VALIDATED'|'BLOCKED'|'PARTIALLY_VALID'} result
703
+ * @param {object} opts - { blockedReason, claimExcerpt }
704
+ * @returns {{ newRating, delta, tiltDetected, interventionMode, message }}
705
+ */
706
+ recordClaimResult(domain, result, opts = {}) {
707
+ if (!this.eloEngine) throw new Error('ELO system not enabled');
708
+ return this.eloEngine.recordResult(domain, result, opts);
709
+ }
710
+
711
+ /**
712
+ * Declare user expertise for a domain (sets provisional ELO).
713
+ * @param {string} domain
714
+ * @param {'beginner'|'intermediate'|'advanced'|'expert'|'principal'} level
715
+ */
716
+ declareExpertise(domain, level) {
717
+ if (!this.eloEngine) throw new Error('ELO system not enabled');
718
+ return this.eloEngine.declareExpertise(domain, level);
719
+ }
720
+
721
+ /**
722
+ * Get the [ELO] dashboard for a domain: why + how to progress.
723
+ * @param {string} domain
724
+ * @returns {string}
725
+ */
726
+ getEloDashboard(domain) {
727
+ if (!this.eloEngine) throw new Error('ELO system not enabled');
728
+ return this.eloEngine.getDashboard(domain);
729
+ }
730
+
731
+ /**
732
+ * Get ELO summary across all domains.
733
+ * @returns {Array}
734
+ */
735
+ getEloSummary() {
736
+ if (!this.eloEngine) return [];
737
+ return this.eloEngine.getSummary();
738
+ }
739
+
740
+ /**
741
+ * Get LLM model recommendation based on ELO profile.
742
+ * @returns {{ model, label, reason, maxRating }}
743
+ */
744
+ routeLLM() {
745
+ if (!this.eloEngine) return { model: 'claude-sonnet-4.5', label: 'default', reason: 'ELO not enabled' };
746
+ return this.eloEngine.routeLLM();
747
+ }
748
+
749
+ // ========================================
750
+ // Fact-Check Methods
751
+ // ========================================
752
+
753
+ /**
754
+ * Check a claim against the knowledge base.
755
+ * @param {string} claim
756
+ * @param {object} opts - { domain, level, source, proof }
757
+ * @returns {{ assertionType, level, score, status, source, proof, warning }}
758
+ */
759
+ checkClaim(claim, opts = {}) {
760
+ if (!this.factChecker) throw new Error('Fact-check system not enabled');
761
+ return this.factChecker.check(claim, opts);
762
+ }
763
+
764
+ /**
765
+ * Parse text and auto-detect implicit claims using trigger patterns.
766
+ * @param {string} text
767
+ * @returns {Array<{ pattern, matched, position, excerpt }>}
768
+ */
769
+ parseClaims(text) {
770
+ if (!this.factChecker) throw new Error('Fact-check system not enabled');
771
+ return this.factChecker.parse(text);
772
+ }
773
+
774
+ /**
775
+ * Mark a claim as user-verified with a proof artifact.
776
+ * @param {string} claim
777
+ * @param {string} proof
778
+ * @returns {{ id, status, claim }}
779
+ */
780
+ verifyFact(claim, proof) {
781
+ if (!this.factChecker) throw new Error('Fact-check system not enabled');
782
+ return this.factChecker.verify(claim, proof);
783
+ }
784
+
785
+ /**
786
+ * Generate a Markdown fact sheet for the session.
787
+ * @param {string} sessionId
788
+ * @param {object} facts - { verified, claims, disputed, opinions }
789
+ * @returns {{ content, path }}
790
+ */
791
+ generateFactSheet(sessionId, facts, save = true) {
792
+ if (!this.factChecker) throw new Error('Fact-check system not enabled');
793
+ return this.factChecker.generateFactSheet(sessionId, facts, save);
794
+ }
795
+
796
+ /**
797
+ * Get all facts from the persistent knowledge graph.
798
+ * @returns {Array<object>}
799
+ */
800
+ getKnowledgeGraph() {
801
+ if (!this.factChecker) return [];
802
+ return this.factChecker.graph.load().facts;
649
803
  }
650
804
  }
651
805