@timmeck/brain-core 2.36.55 → 2.36.57

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 (47) hide show
  1. package/command-center.html +111 -0
  2. package/dist/action/__tests__/action-bridge.test.d.ts +1 -0
  3. package/dist/action/__tests__/action-bridge.test.js +145 -0
  4. package/dist/action/__tests__/action-bridge.test.js.map +1 -0
  5. package/dist/action/action-bridge.d.ts +95 -0
  6. package/dist/action/action-bridge.js +241 -0
  7. package/dist/action/action-bridge.js.map +1 -0
  8. package/dist/action/index.d.ts +2 -0
  9. package/dist/action/index.js +2 -0
  10. package/dist/action/index.js.map +1 -0
  11. package/dist/codegen/__tests__/code-forge.test.d.ts +1 -0
  12. package/dist/codegen/__tests__/code-forge.test.js +105 -0
  13. package/dist/codegen/__tests__/code-forge.test.js.map +1 -0
  14. package/dist/codegen/code-forge.d.ts +87 -0
  15. package/dist/codegen/code-forge.js +211 -0
  16. package/dist/codegen/code-forge.js.map +1 -0
  17. package/dist/codegen/index.d.ts +2 -0
  18. package/dist/codegen/index.js +1 -0
  19. package/dist/codegen/index.js.map +1 -1
  20. package/dist/content/__tests__/content-forge.test.d.ts +1 -0
  21. package/dist/content/__tests__/content-forge.test.js +117 -0
  22. package/dist/content/__tests__/content-forge.test.js.map +1 -0
  23. package/dist/content/content-forge.d.ts +104 -0
  24. package/dist/content/content-forge.js +213 -0
  25. package/dist/content/content-forge.js.map +1 -0
  26. package/dist/content/index.d.ts +2 -0
  27. package/dist/content/index.js +2 -0
  28. package/dist/content/index.js.map +1 -0
  29. package/dist/dashboard/command-center-server.d.ts +6 -0
  30. package/dist/dashboard/command-center-server.js +58 -1
  31. package/dist/dashboard/command-center-server.js.map +1 -1
  32. package/dist/index.d.ts +8 -0
  33. package/dist/index.js +8 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/research/research-orchestrator.d.ts +12 -0
  36. package/dist/research/research-orchestrator.js +108 -0
  37. package/dist/research/research-orchestrator.js.map +1 -1
  38. package/dist/strategy/__tests__/strategy-forge.test.d.ts +1 -0
  39. package/dist/strategy/__tests__/strategy-forge.test.js +121 -0
  40. package/dist/strategy/__tests__/strategy-forge.test.js.map +1 -0
  41. package/dist/strategy/index.d.ts +2 -0
  42. package/dist/strategy/index.js +2 -0
  43. package/dist/strategy/index.js.map +1 -0
  44. package/dist/strategy/strategy-forge.d.ts +111 -0
  45. package/dist/strategy/strategy-forge.js +264 -0
  46. package/dist/strategy/strategy-forge.js.map +1 -0
  47. package/package.json +1 -1
@@ -306,6 +306,28 @@ canvas{display:block;width:100%;height:100%}
306
306
  </div>
307
307
  </div>
308
308
 
309
+ <!-- Guardrail Ampel -->
310
+ <div class="section">
311
+ <div class="section-title"><span class="icon">&#x1F6E1;&#xFE0F;</span> Guardrails</div>
312
+ <div class="card" id="guardrailCard">
313
+ <div class="grid grid-3" style="text-align:center">
314
+ <div>
315
+ <div id="guardrailAmpel" style="width:24px;height:24px;border-radius:50%;margin:0 auto 6px;background:var(--text-dim)"></div>
316
+ <div style="font-size:11px;color:var(--text-dim)" data-t="Health Score">Health Score</div>
317
+ <div id="guardrailScore" style="font-size:18px;font-weight:700">--</div>
318
+ </div>
319
+ <div>
320
+ <div style="font-size:11px;color:var(--text-dim)">Circuit Breaker</div>
321
+ <div id="guardrailBreaker" style="font-size:14px;font-weight:600">--</div>
322
+ </div>
323
+ <div>
324
+ <div style="font-size:11px;color:var(--text-dim)" data-t="Geschützte Pfade">Geschützte Pfade</div>
325
+ <div id="guardrailPaths" style="font-size:14px;font-weight:600">--</div>
326
+ </div>
327
+ </div>
328
+ </div>
329
+ </div>
330
+
309
331
  <!-- Error Log -->
310
332
  <div class="section">
311
333
  <div class="section-title"><span class="icon">&#x26A0;</span> <span data-t="Letzte Fehler & Warnungen">Letzte Fehler & Warnungen</span> <span id="errorCount" style="color:var(--text-dim);font-weight:400;font-size:12px"></span></div>
@@ -605,6 +627,20 @@ canvas{display:block;width:100%;height:100%}
605
627
  <div class="card" style="text-align:center"><div class="card-value" id="int-tr-cost" style="color:var(--magenta)">$0.00</div><div class="card-sub" data-t="Gesamtkosten">Gesamtkosten</div></div>
606
628
  </div>
607
629
  </div>
630
+
631
+ <!-- Research Roadmaps (DAG) -->
632
+ <div class="section">
633
+ <div class="section-title"><span class="icon">&#x1F5FA;&#xFE0F;</span> Research Roadmaps — <span data-t="Forschungs-Pläne">Forschungs-Pläne</span></div>
634
+ <p style="font-size:12px;color:var(--text-dim);margin-bottom:12px" data-t="Multi-step Forschungspläne mit Abhängigkeiten. Grün=erreicht, Blau=aktiv, Grau=blockiert.">Multi-step Forschungspläne mit Abhängigkeiten. Grün=erreicht, Blau=aktiv, Grau=blockiert.</p>
635
+ <div id="roadmapList"><div class="empty" data-t="Keine Roadmaps">Keine Roadmaps</div></div>
636
+ </div>
637
+
638
+ <!-- Creative Insights -->
639
+ <div class="section">
640
+ <div class="section-title"><span class="icon">&#x2728;</span> Creative Insights — <span data-t="Kreative Verbindungen">Kreative Verbindungen</span></div>
641
+ <p style="font-size:12px;color:var(--text-dim);margin-bottom:12px" data-t="Cross-Domain Ideen mit Neuheits- und Plausibilitäts-Scores.">Cross-Domain Ideen mit Neuheits- und Plausibilitäts-Scores.</p>
642
+ <div id="creativeInsightsList"><div class="empty" data-t="Keine Creative Insights">Keine Creative Insights</div></div>
643
+ </div>
608
644
  </div>
609
645
 
610
646
  <!-- ════ Page 6: Cross-Brain & Borg ═════════════════ -->
@@ -860,6 +896,12 @@ const translations = { en: {
860
896
  'Traces & Spans':'Traces & Spans','Traces gesamt':'Total Traces','Aktiv':'Active','Spans gesamt':'Total Spans','Gesamtkosten':'Total Cost',
861
897
  'Noch keine Feature-Wünsche — Brain analysiert automatisch':'No feature wishes yet — Brain analyzes automatically',
862
898
  'Brain erkennt was ihm fehlt und sucht nach passenden Features aus absorbierten Repos.':'Brain detects what it needs and searches for matching features from absorbed repos.',
899
+ 'Geschützte Pfade':'Protected Paths','Forschungs-Pläne':'Research Plans',
900
+ 'Multi-step Forschungspläne mit Abhängigkeiten. Grün=erreicht, Blau=aktiv, Grau=blockiert.':'Multi-step research plans with dependencies. Green=achieved, Blue=active, Gray=blocked.',
901
+ 'Keine Roadmaps':'No roadmaps','erreicht':'achieved',
902
+ 'Kreative Verbindungen':'Creative Connections',
903
+ 'Cross-Domain Ideen mit Neuheits- und Plausibilitäts-Scores.':'Cross-domain ideas with novelty and plausibility scores.',
904
+ 'Keine Creative Insights':'No creative insights','Neuheit':'Novelty','Plausibilität':'Plausibility',
863
905
  }};
864
906
  let currentLang = localStorage.getItem('brain-lang') || 'en';
865
907
  function t(text) { if (currentLang === 'en' && translations.en[text]) return translations.en[text]; return text; }
@@ -931,6 +973,9 @@ function connectSSE() {
931
973
  es.addEventListener('knowledge', e => { state.knowledge = JSON.parse(e.data); renderKnowledge(); });
932
974
  es.addEventListener('debates', e => { state.debates = JSON.parse(e.data); renderDebates(); });
933
975
  es.addEventListener('emotional', e => { state.emotional = JSON.parse(e.data); });
976
+ es.addEventListener('guardrail-health', e => { state.guardrailHealth = JSON.parse(e.data); renderGuardrails(); });
977
+ es.addEventListener('roadmaps', e => { state.roadmaps = JSON.parse(e.data); renderRoadmaps(); });
978
+ es.addEventListener('creative-insights', e => { state.creativeInsights = JSON.parse(e.data); renderCreativeInsights(); });
934
979
  es.onerror = () => { state.connected = false; updateConnection(); };
935
980
  }
936
981
 
@@ -951,10 +996,14 @@ async function loadInitial() {
951
996
  state.missions = data.missions; state.knowledge = data.knowledge; state.repoAbsorber = data.repoAbsorber; state.intelligence = data.intelligence;
952
997
  state.debates = data.debates;
953
998
  state.emotional = data.emotional;
999
+ state.guardrailHealth = data.guardrailHealth;
1000
+ state.roadmaps = data.roadmaps;
1001
+ state.creativeInsights = data.creativeInsights;
954
1002
  if (data.thoughts) { state.thoughts = data.thoughts; renderThoughts(); }
955
1003
  renderEcosystem(); renderEngines(); renderWatchdog(); renderPlugins();
956
1004
  renderBorg(); renderAnalytics(); renderLLM(); renderErrors();
957
1005
  renderSelfMod(); renderMissions(); renderRepoAbsorber(); renderIntelligence(); renderKnowledge(); renderDebates();
1006
+ renderGuardrails(); renderRoadmaps(); renderCreativeInsights();
958
1007
  } catch {}
959
1008
  }
960
1009
 
@@ -1682,6 +1731,68 @@ function renderDebates() {
1682
1731
  }
1683
1732
  }
1684
1733
 
1734
+ // ── Guardrails ───────────────────────────────────────────
1735
+ function renderGuardrails() {
1736
+ const d = state.guardrailHealth; if (!d) return;
1737
+ const score = d.score ?? d.healthScore ?? 0;
1738
+ const ampel = document.getElementById('guardrailAmpel');
1739
+ const scoreEl = document.getElementById('guardrailScore');
1740
+ const breakerEl = document.getElementById('guardrailBreaker');
1741
+ const pathsEl = document.getElementById('guardrailPaths');
1742
+ if (ampel) {
1743
+ const col = score > 0.8 ? 'var(--green)' : score > 0.5 ? 'var(--yellow)' : 'var(--red)';
1744
+ ampel.style.background = col;
1745
+ ampel.style.boxShadow = `0 0 12px ${col}`;
1746
+ }
1747
+ if (scoreEl) scoreEl.textContent = (score * 100).toFixed(0) + '%';
1748
+ if (breakerEl) {
1749
+ const tripped = d.circuitBreakerTripped ?? d.circuitBreaker?.tripped ?? false;
1750
+ breakerEl.textContent = tripped ? 'TRIPPED' : 'OK';
1751
+ breakerEl.style.color = tripped ? 'var(--red)' : 'var(--green)';
1752
+ }
1753
+ if (pathsEl) pathsEl.textContent = d.protectedPaths ?? d.protected ?? '-';
1754
+ }
1755
+
1756
+ // ── Roadmaps ─────────────────────────────────────────────
1757
+ function renderRoadmaps() {
1758
+ const list = state.roadmaps; if (!list) return;
1759
+ const el = document.getElementById('roadmapList'); if (!el) return;
1760
+ const items = Array.isArray(list) ? list : [];
1761
+ if (!items.length) { el.innerHTML = `<div class="empty">${t('Keine Roadmaps')}</div>`; return; }
1762
+ el.innerHTML = items.map(rm => {
1763
+ const statusCol = rm.status === 'completed' ? 'var(--green)' : rm.status === 'active' ? 'var(--cyan)' : 'var(--text-dim)';
1764
+ return `<div class="card" style="margin-bottom:8px;padding:10px 14px">
1765
+ <div style="display:flex;justify-content:space-between;align-items:center">
1766
+ <strong style="color:var(--cyan)">#${rm.id}: ${(rm.title||'').substring(0,80)}</strong>
1767
+ <span style="color:${statusCol};font-size:11px;text-transform:uppercase">${rm.status||'?'}</span>
1768
+ </div>
1769
+ ${rm.goalCount ? `<div style="font-size:11px;color:var(--text-dim);margin-top:4px">${rm.goalCount} Goals | ${rm.achievedCount ?? 0} ${t('erreicht')}</div>` : ''}
1770
+ </div>`;
1771
+ }).join('');
1772
+ }
1773
+
1774
+ // ── Creative Insights ────────────────────────────────────
1775
+ function renderCreativeInsights() {
1776
+ const list = state.creativeInsights; if (!list) return;
1777
+ const el = document.getElementById('creativeInsightsList'); if (!el) return;
1778
+ const items = Array.isArray(list) ? list : [];
1779
+ if (!items.length) { el.innerHTML = `<div class="empty">${t('Keine Creative Insights')}</div>`; return; }
1780
+ el.innerHTML = items.slice(0, 10).map(ins => {
1781
+ const novelty = ins.noveltyScore ?? ins.novelty ?? 0;
1782
+ const plaus = ins.plausibility ?? 0;
1783
+ const nCol = novelty > 0.7 ? 'var(--green)' : novelty > 0.4 ? 'var(--yellow)' : 'var(--text-dim)';
1784
+ const pCol = plaus > 0.7 ? 'var(--green)' : plaus > 0.4 ? 'var(--yellow)' : 'var(--text-dim)';
1785
+ return `<div class="card" style="margin-bottom:6px;padding:8px 14px">
1786
+ <div style="font-size:13px;color:var(--text)">${(ins.title ?? ins.description ?? '').substring(0,120)}</div>
1787
+ <div style="font-size:11px;color:var(--text-dim);margin-top:4px">
1788
+ ${t('Neuheit')}: <span style="color:${nCol}">${(novelty*100).toFixed(0)}%</span> &nbsp;|&nbsp;
1789
+ ${t('Plausibilität')}: <span style="color:${pCol}">${(plaus*100).toFixed(0)}%</span> &nbsp;|&nbsp;
1790
+ Status: ${ins.status || '-'}
1791
+ </div>
1792
+ </div>`;
1793
+ }).join('');
1794
+ }
1795
+
1685
1796
  // ── Quick Actions ─────────────────────────────────────────
1686
1797
  document.querySelectorAll('.action-btn').forEach(btn => {
1687
1798
  btn.addEventListener('click', async () => {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,145 @@
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
+ import Database from 'better-sqlite3';
3
+ vi.mock('../../utils/logger.js', () => ({
4
+ getLogger: () => ({ info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() }),
5
+ }));
6
+ import { ActionBridgeEngine, runActionBridgeMigration } from '../action-bridge.js';
7
+ describe('ActionBridgeEngine', () => {
8
+ let db;
9
+ beforeEach(() => { db = new Database(':memory:'); });
10
+ afterEach(() => { db.close(); });
11
+ it('proposes an action and retrieves it', () => {
12
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
13
+ const id = engine.propose({ source: 'proactive', type: 'adjust_parameter', title: 'Increase learning rate', confidence: 0.8 });
14
+ expect(id).toBeGreaterThan(0);
15
+ const queue = engine.getQueue('pending');
16
+ expect(queue).toHaveLength(1);
17
+ expect(queue[0].title).toBe('Increase learning rate');
18
+ expect(queue[0].riskLevel).toBe('low');
19
+ });
20
+ it('evaluates risk correctly for each type', () => {
21
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
22
+ expect(engine.evaluateRisk('adjust_parameter')).toBe('low');
23
+ expect(engine.evaluateRisk('create_goal')).toBe('low');
24
+ expect(engine.evaluateRisk('start_mission')).toBe('low');
25
+ expect(engine.evaluateRisk('publish_content')).toBe('medium');
26
+ expect(engine.evaluateRisk('execute_trade')).toBe('medium');
27
+ expect(engine.evaluateRisk('apply_code')).toBe('high');
28
+ });
29
+ it('auto-executes qualifying low-risk actions', async () => {
30
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
31
+ const handler = vi.fn().mockResolvedValue({ adjusted: true });
32
+ engine.registerHandler('adjust_parameter', handler);
33
+ engine.propose({ source: 'proactive', type: 'adjust_parameter', title: 'Auto test', confidence: 0.8 });
34
+ const executed = await engine.processQueue();
35
+ expect(executed).toBe(1);
36
+ expect(handler).toHaveBeenCalled();
37
+ const history = engine.getHistory();
38
+ expect(history).toHaveLength(1);
39
+ expect(history[0].status).toBe('completed');
40
+ });
41
+ it('does not auto-execute when confidence too low', async () => {
42
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
43
+ engine.registerHandler('adjust_parameter', vi.fn());
44
+ engine.propose({ source: 'proactive', type: 'adjust_parameter', title: 'Low conf', confidence: 0.3 });
45
+ const executed = await engine.processQueue();
46
+ expect(executed).toBe(0);
47
+ });
48
+ it('does not auto-execute apply_code (always high risk)', async () => {
49
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
50
+ engine.registerHandler('apply_code', vi.fn());
51
+ engine.propose({ source: 'codegen', type: 'apply_code', title: 'Refactor', confidence: 0.99 });
52
+ const executed = await engine.processQueue();
53
+ expect(executed).toBe(0); // never auto for apply_code
54
+ });
55
+ it('executes action manually', async () => {
56
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
57
+ engine.registerHandler('publish_content', vi.fn().mockResolvedValue({ published: true }));
58
+ const id = engine.propose({ source: 'creative', type: 'publish_content', title: 'Post insight', confidence: 0.5 });
59
+ const result = await engine.executeAction(id);
60
+ expect(result.success).toBe(true);
61
+ });
62
+ it('records failed execution', async () => {
63
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
64
+ engine.registerHandler('publish_content', vi.fn().mockRejectedValue(new Error('API down')));
65
+ const id = engine.propose({ source: 'creative', type: 'publish_content', title: 'Fail test', confidence: 0.9 });
66
+ const result = await engine.executeAction(id);
67
+ expect(result.success).toBe(false);
68
+ const action = engine.getAction(id);
69
+ expect(action?.status).toBe('failed');
70
+ });
71
+ it('returns error when no handler registered', async () => {
72
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
73
+ const id = engine.propose({ source: 'proactive', type: 'start_mission', title: 'No handler', confidence: 0.9 });
74
+ const result = await engine.executeAction(id);
75
+ expect(result.success).toBe(false);
76
+ expect(result.result).toBe('No handler registered');
77
+ });
78
+ it('rolls back a completed action', async () => {
79
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
80
+ engine.registerHandler('adjust_parameter', vi.fn().mockResolvedValue({}));
81
+ const id = engine.propose({ source: 'proactive', type: 'adjust_parameter', title: 'Rollback test', confidence: 0.9 });
82
+ await engine.executeAction(id);
83
+ engine.rollback(id);
84
+ const action = engine.getAction(id);
85
+ expect(action?.status).toBe('rolled_back');
86
+ });
87
+ it('cannot rollback a pending action', () => {
88
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
89
+ const id = engine.propose({ source: 'proactive', type: 'adjust_parameter', title: 'No rollback', confidence: 0.5 });
90
+ expect(() => engine.rollback(id)).toThrow('cannot be rolled back');
91
+ });
92
+ it('tracks success rate', async () => {
93
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
94
+ engine.registerHandler('adjust_parameter', vi.fn().mockResolvedValue({}));
95
+ engine.registerHandler('create_goal', vi.fn().mockRejectedValue(new Error('fail')));
96
+ const id1 = engine.propose({ source: 'proactive', type: 'adjust_parameter', title: 'Success', confidence: 0.9 });
97
+ const id2 = engine.propose({ source: 'proactive', type: 'create_goal', title: 'Fail', confidence: 0.9 });
98
+ await engine.executeAction(id1);
99
+ await engine.executeAction(id2);
100
+ expect(engine.getSuccessRate()).toBe(0.5);
101
+ expect(engine.getSuccessRate('adjust_parameter')).toBe(1);
102
+ expect(engine.getSuccessRate(undefined, 'proactive')).toBe(0.5);
103
+ });
104
+ it('records outcome manually', () => {
105
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
106
+ const id = engine.propose({ source: 'mission', type: 'start_mission', title: 'Outcome test', confidence: 0.7 });
107
+ // Manually mark as executing first by internal exec
108
+ engine.registerHandler('start_mission', vi.fn().mockResolvedValue({}));
109
+ engine.recordOutcome(id, { success: true, result: { missionId: 42 }, learnedLesson: 'Missions work' });
110
+ const action = engine.getAction(id);
111
+ expect(action?.status).toBe('completed');
112
+ expect(action?.outcome?.learnedLesson).toBe('Missions work');
113
+ });
114
+ it('rejects proposal when queue is full', () => {
115
+ const engine = new ActionBridgeEngine(db, { brainName: 'test', maxPendingActions: 2 });
116
+ engine.propose({ source: 'proactive', type: 'adjust_parameter', title: 'One', confidence: 0.5 });
117
+ engine.propose({ source: 'proactive', type: 'adjust_parameter', title: 'Two', confidence: 0.5 });
118
+ const id = engine.propose({ source: 'proactive', type: 'adjust_parameter', title: 'Three', confidence: 0.5 });
119
+ expect(id).toBe(-1);
120
+ });
121
+ it('disables auto-execute when configured', async () => {
122
+ const engine = new ActionBridgeEngine(db, { brainName: 'test', autoExecuteEnabled: false });
123
+ engine.registerHandler('adjust_parameter', vi.fn());
124
+ engine.propose({ source: 'proactive', type: 'adjust_parameter', title: 'No auto', confidence: 0.9 });
125
+ const executed = await engine.processQueue();
126
+ expect(executed).toBe(0);
127
+ });
128
+ it('getStatus returns overview', () => {
129
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
130
+ engine.propose({ source: 'proactive', type: 'adjust_parameter', title: 'Test', confidence: 0.5 });
131
+ const status = engine.getStatus();
132
+ expect(status.queueSize).toBe(1);
133
+ expect(status.autoExecuteEnabled).toBe(true);
134
+ expect(status.topSources).toHaveLength(1);
135
+ expect(status.topSources[0].source).toBe('proactive');
136
+ });
137
+ it('migration is idempotent', () => {
138
+ const engine = new ActionBridgeEngine(db, { brainName: 'test' });
139
+ engine.propose({ source: 'proactive', type: 'start_mission', title: 'Survives', confidence: 0.5 });
140
+ runActionBridgeMigration(db);
141
+ const queue = engine.getQueue('pending');
142
+ expect(queue).toHaveLength(1);
143
+ });
144
+ });
145
+ //# sourceMappingURL=action-bridge.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-bridge.test.js","sourceRoot":"","sources":["../../../src/action/__tests__/action-bridge.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAA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AAI,CAAC,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QACjC,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;QACjE,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QACnG,wBAAwB,CAAC,EAAE,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,95 @@
1
+ import type Database from 'better-sqlite3';
2
+ export interface ProposedAction {
3
+ id: number;
4
+ source: 'proactive' | 'creative' | 'mission' | 'selfmod' | 'codegen' | 'research';
5
+ type: 'publish_content' | 'apply_code' | 'execute_trade' | 'adjust_parameter' | 'create_goal' | 'start_mission';
6
+ title: string;
7
+ description: string;
8
+ confidence: number;
9
+ riskLevel: 'low' | 'medium' | 'high';
10
+ payload: Record<string, unknown>;
11
+ status: 'pending' | 'approved' | 'executing' | 'completed' | 'failed' | 'rolled_back';
12
+ outcome?: ActionOutcome;
13
+ executedAt?: string;
14
+ createdAt?: string;
15
+ }
16
+ export interface ActionOutcome {
17
+ success: boolean;
18
+ result: unknown;
19
+ metrics?: Record<string, number>;
20
+ learnedLesson?: string;
21
+ }
22
+ export interface ActionBridgeConfig {
23
+ brainName: string;
24
+ maxPendingActions?: number;
25
+ autoExecuteEnabled?: boolean;
26
+ }
27
+ export interface ActionBridgeStatus {
28
+ queueSize: number;
29
+ executed24h: number;
30
+ successRate: number;
31
+ topSources: Array<{
32
+ source: string;
33
+ count: number;
34
+ }>;
35
+ autoExecuteEnabled: boolean;
36
+ }
37
+ type ActionType = ProposedAction['type'];
38
+ type ActionSource = ProposedAction['source'];
39
+ type RiskLevel = ProposedAction['riskLevel'];
40
+ export declare function runActionBridgeMigration(db: Database.Database): void;
41
+ export declare class ActionBridgeEngine {
42
+ private readonly db;
43
+ private readonly config;
44
+ private readonly log;
45
+ private handlers;
46
+ private readonly stmtInsert;
47
+ private readonly stmtGetById;
48
+ private readonly stmtUpdateStatus;
49
+ private readonly stmtSetOutcome;
50
+ private readonly stmtGetQueue;
51
+ private readonly stmtGetHistory;
52
+ private readonly stmtSuccessRate;
53
+ private readonly stmtSuccessRateByType;
54
+ private readonly stmtSuccessRateBySource;
55
+ private readonly stmtExecuted24h;
56
+ private readonly stmtTopSources;
57
+ constructor(db: Database.Database, config: ActionBridgeConfig);
58
+ /** Register an execution handler for an action type */
59
+ registerHandler(type: ActionType, handler: (payload: Record<string, unknown>) => Promise<unknown> | unknown): void;
60
+ /** Propose a new action — returns the action ID */
61
+ propose(action: {
62
+ source: ActionSource;
63
+ type: ActionType;
64
+ title: string;
65
+ description?: string;
66
+ confidence: number;
67
+ payload?: Record<string, unknown>;
68
+ }): number;
69
+ /** Evaluate risk level for an action type */
70
+ evaluateRisk(type: ActionType, _confidence?: number): RiskLevel;
71
+ /** Check if an action qualifies for auto-execution */
72
+ canAutoExecute(action: ProposedAction): boolean;
73
+ /** Execute a specific action by ID */
74
+ executeAction(actionId: number): Promise<{
75
+ success: boolean;
76
+ result: unknown;
77
+ }>;
78
+ /** Process pending queue — auto-execute qualifying actions */
79
+ processQueue(): Promise<number>;
80
+ /** Record outcome for an already-executed action */
81
+ recordOutcome(actionId: number, outcome: ActionOutcome): void;
82
+ /** Rollback a completed action */
83
+ rollback(actionId: number): void;
84
+ /** Get success rate (optionally filtered by type or source) */
85
+ getSuccessRate(type?: string, source?: string): number;
86
+ /** Get queue items by status */
87
+ getQueue(status?: string): ProposedAction[];
88
+ /** Get action history (completed/failed/rolled_back) */
89
+ getHistory(limit?: number): ProposedAction[];
90
+ /** Get a single action by ID */
91
+ getAction(id: number): ProposedAction | null;
92
+ /** Get status overview */
93
+ getStatus(): ActionBridgeStatus;
94
+ }
95
+ export {};