@timmeck/brain-core 2.17.1 → 2.19.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.
@@ -0,0 +1,108 @@
1
+ import type Database from 'better-sqlite3';
2
+ import type { ThoughtStream } from '../consciousness/thought-stream.js';
3
+ export interface AttentionEngineConfig {
4
+ brainName: string;
5
+ /** How quickly attention decays per cycle (0-1). Default: 0.85 */
6
+ decayRate?: number;
7
+ /** Burst window in ms for urgency detection. Default: 180_000 (3 min) */
8
+ burstWindowMs?: number;
9
+ /** How many events in the burst window trigger urgency. Default: 3 */
10
+ burstThreshold?: number;
11
+ }
12
+ export interface AttentionScore {
13
+ topic: string;
14
+ score: number;
15
+ recency: number;
16
+ frequency: number;
17
+ impact: number;
18
+ urgency: number;
19
+ lastSeen: number;
20
+ }
21
+ export type WorkContext = 'debugging' | 'coding' | 'reviewing' | 'trading' | 'publishing' | 'researching' | 'idle';
22
+ export interface ContextSwitch {
23
+ from: WorkContext;
24
+ to: WorkContext;
25
+ timestamp: number;
26
+ trigger: string;
27
+ }
28
+ export interface FocusEntry {
29
+ topic: string;
30
+ score: number;
31
+ context: WorkContext;
32
+ timestamp: number;
33
+ }
34
+ export interface AttentionStatus {
35
+ currentContext: WorkContext;
36
+ topTopics: AttentionScore[];
37
+ contextHistory: ContextSwitch[];
38
+ engineWeights: Record<string, number>;
39
+ urgentTopics: string[];
40
+ totalEvents: number;
41
+ uptime: number;
42
+ }
43
+ export interface EngineWeight {
44
+ engine: string;
45
+ weight: number;
46
+ reason: string;
47
+ }
48
+ export declare class AttentionEngine {
49
+ private db;
50
+ private brainName;
51
+ private thoughtStream;
52
+ private unsubscribe;
53
+ private log;
54
+ private scores;
55
+ private currentContext;
56
+ private contextHistory;
57
+ private engineWeights;
58
+ private eventLog;
59
+ private totalEvents;
60
+ private startTime;
61
+ private decayRate;
62
+ private burstWindowMs;
63
+ private burstThreshold;
64
+ private static readonly CONTEXT_RULES;
65
+ constructor(db: Database.Database, config: AttentionEngineConfig);
66
+ /** Wire into ThoughtStream to passively observe all engine activity. */
67
+ setThoughtStream(stream: ThoughtStream): void;
68
+ /** Process a thought from any engine. */
69
+ private onThought;
70
+ /** Update the attention score for a topic. */
71
+ private updateScore;
72
+ /** Compute composite attention score. */
73
+ private computeScore;
74
+ /** Apply time-based decay to all attention scores. Called each feedback cycle. */
75
+ decay(): void;
76
+ /** Detect work context from a thought. */
77
+ private detectContext;
78
+ /** Record a context switch. */
79
+ private switchContext;
80
+ /** Check if a topic has burst activity (urgency). */
81
+ private checkUrgency;
82
+ /** Compute recommended engine weights based on current attention state.
83
+ * Engines related to high-attention topics get more weight. */
84
+ computeEngineWeights(): EngineWeight[];
85
+ /** Get the current weight for an engine. Orchestrator uses this to decide cycle budget. */
86
+ getEngineWeight(engine: string): number;
87
+ /** Manually set high attention on a topic (via MCP tool). */
88
+ setFocus(topic: string, intensity?: number): void;
89
+ /** Get top N topics by attention score. */
90
+ getTopTopics(limit?: number): AttentionScore[];
91
+ /** Get topics with urgency > 1.0. */
92
+ getUrgentTopics(): AttentionScore[];
93
+ /** Get context switch history. */
94
+ getContextHistory(limit?: number): ContextSwitch[];
95
+ /** Get current work context. */
96
+ getCurrentContext(): WorkContext;
97
+ /** Get full attention status. */
98
+ getStatus(): AttentionStatus;
99
+ /** Get focus timeline from DB. */
100
+ getFocusTimeline(limit?: number): FocusEntry[];
101
+ /** Extract a normalized topic from a thought. */
102
+ private extractTopic;
103
+ private runMigration;
104
+ private persistFocusEntry;
105
+ private persistContextSwitch;
106
+ private loadPersistedState;
107
+ stop(): void;
108
+ }
@@ -0,0 +1,411 @@
1
+ import { getLogger } from '../utils/logger.js';
2
+ // ── Engine ──────────────────────────────────────────────
3
+ export class AttentionEngine {
4
+ db;
5
+ brainName;
6
+ thoughtStream = null;
7
+ unsubscribe = null;
8
+ log = getLogger();
9
+ // Attention state
10
+ scores = new Map();
11
+ currentContext = 'idle';
12
+ contextHistory = [];
13
+ engineWeights = new Map();
14
+ eventLog = [];
15
+ totalEvents = 0;
16
+ startTime = Date.now();
17
+ // Config
18
+ decayRate;
19
+ burstWindowMs;
20
+ burstThreshold;
21
+ // Context detection rules: tool/event patterns → context
22
+ static CONTEXT_RULES = [
23
+ { pattern: /error|bug|fix|crash|exception|stack|debug/i, context: 'debugging' },
24
+ { pattern: /trade|signal|backtest|kelly|dca|grid|risk/i, context: 'trading' },
25
+ { pattern: /post|publish|campaign|schedule|hashtag|engagement|competitor/i, context: 'publishing' },
26
+ { pattern: /review|pr|diff|approve|reject|codegen/i, context: 'reviewing' },
27
+ { pattern: /research|hypothes|experiment|distill|agenda|journal/i, context: 'researching' },
28
+ { pattern: /code|module|register|function|refactor|implement/i, context: 'coding' },
29
+ ];
30
+ constructor(db, config) {
31
+ this.db = db;
32
+ this.brainName = config.brainName;
33
+ this.decayRate = config.decayRate ?? 0.85;
34
+ this.burstWindowMs = config.burstWindowMs ?? 180_000;
35
+ this.burstThreshold = config.burstThreshold ?? 3;
36
+ this.runMigration();
37
+ // Initialize default engine weights (equal)
38
+ const engines = [
39
+ 'self_observer', 'anomaly_detective', 'cross_domain', 'adaptive_strategy',
40
+ 'experiment', 'knowledge_distiller', 'research_agenda', 'counterfactual', 'journal',
41
+ ];
42
+ for (const e of engines) {
43
+ this.engineWeights.set(e, 1.0);
44
+ }
45
+ // Load persisted focus timeline on startup
46
+ this.loadPersistedState();
47
+ }
48
+ // ── ThoughtStream integration ─────────────────────────
49
+ /** Wire into ThoughtStream to passively observe all engine activity. */
50
+ setThoughtStream(stream) {
51
+ // Unsubscribe from previous stream if any
52
+ if (this.unsubscribe)
53
+ this.unsubscribe();
54
+ this.thoughtStream = stream;
55
+ this.unsubscribe = stream.onThought((thought) => {
56
+ this.onThought(thought);
57
+ });
58
+ }
59
+ /** Process a thought from any engine. */
60
+ onThought(thought) {
61
+ this.totalEvents++;
62
+ // Extract topic from thought content + engine
63
+ const topic = this.extractTopic(thought);
64
+ const significance = thought.significance === 'breakthrough' ? 3 : thought.significance === 'notable' ? 2 : 1;
65
+ // Record event
66
+ this.eventLog.push({ topic, timestamp: thought.timestamp, significance });
67
+ // Trim event log (keep last 1000)
68
+ if (this.eventLog.length > 1000) {
69
+ this.eventLog.splice(0, this.eventLog.length - 1000);
70
+ }
71
+ // Update attention score
72
+ this.updateScore(topic, significance);
73
+ // Detect context switches
74
+ const detectedContext = this.detectContext(thought);
75
+ if (detectedContext !== this.currentContext) {
76
+ this.switchContext(detectedContext, `${thought.engine}: ${thought.content.substring(0, 60)}`);
77
+ }
78
+ // Check urgency (burst detection)
79
+ this.checkUrgency(topic);
80
+ }
81
+ // ── Attention scoring ─────────────────────────────────
82
+ /** Update the attention score for a topic. */
83
+ updateScore(topic, significance) {
84
+ const now = Date.now();
85
+ const existing = this.scores.get(topic);
86
+ if (existing) {
87
+ existing.frequency++;
88
+ existing.impact = Math.max(existing.impact, significance);
89
+ existing.lastSeen = now;
90
+ // Recalculate composite score
91
+ existing.recency = 1.0; // Just seen
92
+ existing.score = this.computeScore(existing);
93
+ }
94
+ else {
95
+ const score = {
96
+ topic,
97
+ score: significance,
98
+ recency: 1.0,
99
+ frequency: 1,
100
+ impact: significance,
101
+ urgency: 0,
102
+ lastSeen: now,
103
+ };
104
+ score.score = this.computeScore(score);
105
+ this.scores.set(topic, score);
106
+ }
107
+ }
108
+ /** Compute composite attention score. */
109
+ computeScore(s) {
110
+ // Weighted formula: recency × (frequency_log × impact × (1 + urgency))
111
+ const freqFactor = Math.log2(s.frequency + 1); // Logarithmic so it doesn't explode
112
+ return s.recency * freqFactor * s.impact * (1 + s.urgency);
113
+ }
114
+ /** Apply time-based decay to all attention scores. Called each feedback cycle. */
115
+ decay() {
116
+ const now = Date.now();
117
+ const toDelete = [];
118
+ for (const [topic, score] of this.scores) {
119
+ // Recency decays based on time since last seen
120
+ const ageMs = now - score.lastSeen;
121
+ score.recency = Math.exp(-ageMs / 600_000); // 10-min half-life
122
+ score.urgency *= this.decayRate;
123
+ score.score = this.computeScore(score);
124
+ // Remove very stale topics (score < 0.01)
125
+ if (score.score < 0.01) {
126
+ toDelete.push(topic);
127
+ }
128
+ }
129
+ for (const t of toDelete) {
130
+ this.scores.delete(t);
131
+ }
132
+ }
133
+ // ── Context detection ─────────────────────────────────
134
+ /** Detect work context from a thought. */
135
+ detectContext(thought) {
136
+ const text = `${thought.engine} ${thought.content} ${thought.type}`;
137
+ for (const rule of AttentionEngine.CONTEXT_RULES) {
138
+ if (rule.pattern.test(text))
139
+ return rule.context;
140
+ }
141
+ return this.currentContext; // No change if nothing matches
142
+ }
143
+ /** Record a context switch. */
144
+ switchContext(newContext, trigger) {
145
+ const sw = {
146
+ from: this.currentContext,
147
+ to: newContext,
148
+ timestamp: Date.now(),
149
+ trigger,
150
+ };
151
+ this.contextHistory.push(sw);
152
+ // Keep last 100 switches
153
+ if (this.contextHistory.length > 100) {
154
+ this.contextHistory.splice(0, this.contextHistory.length - 100);
155
+ }
156
+ this.log.info(`[attention] Context switch: ${sw.from} → ${sw.to} (${trigger.substring(0, 40)})`);
157
+ this.currentContext = newContext;
158
+ // Persist context switch
159
+ this.persistContextSwitch(sw);
160
+ }
161
+ // ── Urgency detection (burst detection) ───────────────
162
+ /** Check if a topic has burst activity (urgency). */
163
+ checkUrgency(topic) {
164
+ const now = Date.now();
165
+ const windowStart = now - this.burstWindowMs;
166
+ const recentCount = this.eventLog.filter(e => e.topic === topic && e.timestamp > windowStart).length;
167
+ if (recentCount >= this.burstThreshold) {
168
+ const score = this.scores.get(topic);
169
+ if (score) {
170
+ const newUrgency = Math.min(3.0, recentCount / this.burstThreshold);
171
+ if (newUrgency > score.urgency) {
172
+ score.urgency = newUrgency;
173
+ score.score = this.computeScore(score);
174
+ this.log.info(`[attention] Urgency burst: "${topic}" (${recentCount} events in ${this.burstWindowMs / 1000}s)`);
175
+ }
176
+ }
177
+ }
178
+ }
179
+ // ── Resource allocation ───────────────────────────────
180
+ /** Compute recommended engine weights based on current attention state.
181
+ * Engines related to high-attention topics get more weight. */
182
+ computeEngineWeights() {
183
+ const weights = [];
184
+ const topTopics = this.getTopTopics(5);
185
+ // Base weight for all engines
186
+ const baseWeight = 1.0;
187
+ // Map: which engines handle which types of attention
188
+ const engineTopicMap = {
189
+ anomaly_detective: /anomal|spike|burst|error|deviation/i,
190
+ self_observer: /performance|insight|observation|metric/i,
191
+ cross_domain: /cross|correlat|peer|brain/i,
192
+ experiment: /experiment|test|hypothesis|parameter/i,
193
+ knowledge_distiller: /knowledge|principle|pattern|distill/i,
194
+ adaptive_strategy: /strategy|adapt|revert|regression/i,
195
+ research_agenda: /agenda|research|priority|gap/i,
196
+ counterfactual: /counterfactual|what.if|hypothetical/i,
197
+ journal: /journal|reflect|discover|breakthrough/i,
198
+ };
199
+ for (const [engine, pattern] of Object.entries(engineTopicMap)) {
200
+ let boost = 0;
201
+ let reason = 'baseline';
202
+ for (const topic of topTopics) {
203
+ if (pattern.test(topic.topic)) {
204
+ boost += topic.score * 0.5;
205
+ reason = `high attention on "${topic.topic}"`;
206
+ }
207
+ }
208
+ // Urgency boost
209
+ const urgentTopics = topTopics.filter(t => t.urgency > 1.0);
210
+ for (const urgent of urgentTopics) {
211
+ if (pattern.test(urgent.topic)) {
212
+ boost += urgent.urgency;
213
+ reason = `urgent: "${urgent.topic}"`;
214
+ }
215
+ }
216
+ const weight = baseWeight + boost;
217
+ this.engineWeights.set(engine, weight);
218
+ weights.push({ engine, weight, reason });
219
+ }
220
+ return weights.sort((a, b) => b.weight - a.weight);
221
+ }
222
+ /** Get the current weight for an engine. Orchestrator uses this to decide cycle budget. */
223
+ getEngineWeight(engine) {
224
+ return this.engineWeights.get(engine) ?? 1.0;
225
+ }
226
+ // ── Manual focus ──────────────────────────────────────
227
+ /** Manually set high attention on a topic (via MCP tool). */
228
+ setFocus(topic, intensity = 2.0) {
229
+ const existing = this.scores.get(topic);
230
+ if (existing) {
231
+ existing.impact = Math.max(existing.impact, intensity);
232
+ existing.urgency = Math.max(existing.urgency, intensity);
233
+ existing.lastSeen = Date.now();
234
+ existing.recency = 1.0;
235
+ existing.score = this.computeScore(existing);
236
+ }
237
+ else {
238
+ const score = {
239
+ topic,
240
+ score: intensity * 2,
241
+ recency: 1.0,
242
+ frequency: 1,
243
+ impact: intensity,
244
+ urgency: intensity,
245
+ lastSeen: Date.now(),
246
+ };
247
+ score.score = this.computeScore(score);
248
+ this.scores.set(topic, score);
249
+ }
250
+ this.thoughtStream?.emit('attention', 'focusing', `Manual focus set: "${topic}" (intensity: ${intensity})`, 'notable');
251
+ this.persistFocusEntry(topic);
252
+ }
253
+ // ── Query methods ─────────────────────────────────────
254
+ /** Get top N topics by attention score. */
255
+ getTopTopics(limit = 10) {
256
+ return Array.from(this.scores.values())
257
+ .sort((a, b) => b.score - a.score)
258
+ .slice(0, limit);
259
+ }
260
+ /** Get topics with urgency > 1.0. */
261
+ getUrgentTopics() {
262
+ return Array.from(this.scores.values())
263
+ .filter(s => s.urgency >= 1.0)
264
+ .sort((a, b) => b.urgency - a.urgency);
265
+ }
266
+ /** Get context switch history. */
267
+ getContextHistory(limit = 20) {
268
+ return this.contextHistory.slice(-limit).reverse();
269
+ }
270
+ /** Get current work context. */
271
+ getCurrentContext() {
272
+ return this.currentContext;
273
+ }
274
+ /** Get full attention status. */
275
+ getStatus() {
276
+ return {
277
+ currentContext: this.currentContext,
278
+ topTopics: this.getTopTopics(10),
279
+ contextHistory: this.getContextHistory(10),
280
+ engineWeights: Object.fromEntries(this.engineWeights),
281
+ urgentTopics: this.getUrgentTopics().map(t => t.topic),
282
+ totalEvents: this.totalEvents,
283
+ uptime: Date.now() - this.startTime,
284
+ };
285
+ }
286
+ /** Get focus timeline from DB. */
287
+ getFocusTimeline(limit = 50) {
288
+ const rows = this.db.prepare('SELECT topic, score, context, timestamp FROM attention_focus ORDER BY timestamp DESC LIMIT ?').all(limit);
289
+ return rows;
290
+ }
291
+ // ── Topic extraction ──────────────────────────────────
292
+ /** Extract a normalized topic from a thought. */
293
+ extractTopic(thought) {
294
+ // Use engine name + thought type as primary topic
295
+ const base = `${thought.engine}:${thought.type}`;
296
+ // Extract specific keywords for more granular tracking
297
+ const content = thought.content.toLowerCase();
298
+ // Anomaly-specific
299
+ if (content.includes('anomal'))
300
+ return 'anomaly_detection';
301
+ if (content.includes('breakout'))
302
+ return 'signal_breakout';
303
+ if (content.includes('hypothesis') || content.includes('hypothes'))
304
+ return 'hypothesis_testing';
305
+ if (content.includes('experiment'))
306
+ return 'experiment_management';
307
+ if (content.includes('dream') || content.includes('consolidat'))
308
+ return 'dream_consolidation';
309
+ if (content.includes('prediction') || content.includes('predict'))
310
+ return 'prediction_accuracy';
311
+ if (content.includes('knowledge') || content.includes('distill') || content.includes('principle'))
312
+ return 'knowledge_distillation';
313
+ if (content.includes('correlation'))
314
+ return 'cross_domain_correlation';
315
+ if (content.includes('autorespond') || content.includes('parameter'))
316
+ return 'auto_response';
317
+ if (content.includes('code') && content.includes('min'))
318
+ return 'code_mining';
319
+ if (content.includes('code') && content.includes('gen'))
320
+ return 'code_generation';
321
+ if (content.includes('error') || content.includes('bug'))
322
+ return 'error_tracking';
323
+ if (content.includes('trade') || content.includes('signal'))
324
+ return 'trade_signals';
325
+ if (content.includes('post') || content.includes('publish') || content.includes('engagement'))
326
+ return 'content_publishing';
327
+ if (content.includes('insight'))
328
+ return 'insight_generation';
329
+ if (content.includes('feedback cycle'))
330
+ return 'feedback_cycle';
331
+ return base;
332
+ }
333
+ // ── Persistence ───────────────────────────────────────
334
+ runMigration() {
335
+ this.db.exec(`
336
+ CREATE TABLE IF NOT EXISTS attention_focus (
337
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
338
+ topic TEXT NOT NULL,
339
+ score REAL NOT NULL,
340
+ context TEXT NOT NULL,
341
+ timestamp INTEGER NOT NULL
342
+ );
343
+
344
+ CREATE TABLE IF NOT EXISTS attention_context_switches (
345
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
346
+ from_context TEXT NOT NULL,
347
+ to_context TEXT NOT NULL,
348
+ trigger_text TEXT NOT NULL,
349
+ timestamp INTEGER NOT NULL
350
+ );
351
+
352
+ CREATE INDEX IF NOT EXISTS idx_attention_focus_ts ON attention_focus(timestamp);
353
+ CREATE INDEX IF NOT EXISTS idx_attention_context_ts ON attention_context_switches(timestamp);
354
+ `);
355
+ }
356
+ persistFocusEntry(topic) {
357
+ const score = this.scores.get(topic);
358
+ if (!score)
359
+ return;
360
+ this.db.prepare('INSERT INTO attention_focus (topic, score, context, timestamp) VALUES (?, ?, ?, ?)').run(topic, score.score, this.currentContext, Date.now());
361
+ }
362
+ persistContextSwitch(sw) {
363
+ this.db.prepare('INSERT INTO attention_context_switches (from_context, to_context, trigger_text, timestamp) VALUES (?, ?, ?, ?)').run(sw.from, sw.to, sw.trigger, sw.timestamp);
364
+ }
365
+ loadPersistedState() {
366
+ // Load recent context switches
367
+ const switches = this.db.prepare('SELECT from_context, to_context, trigger_text, timestamp FROM attention_context_switches ORDER BY timestamp DESC LIMIT 50').all();
368
+ for (const s of switches.reverse()) {
369
+ this.contextHistory.push({
370
+ from: s.from_context,
371
+ to: s.to_context,
372
+ timestamp: s.timestamp,
373
+ trigger: s.trigger_text,
374
+ });
375
+ }
376
+ // Set current context from last switch
377
+ if (switches.length > 0) {
378
+ this.currentContext = switches[0].to_context;
379
+ }
380
+ // Load recent focus entries to seed scores
381
+ const entries = this.db.prepare('SELECT topic, score, context, timestamp FROM attention_focus ORDER BY timestamp DESC LIMIT 100').all();
382
+ for (const entry of entries) {
383
+ if (!this.scores.has(entry.topic)) {
384
+ const age = Date.now() - entry.timestamp;
385
+ const recency = Math.exp(-age / 600_000);
386
+ this.scores.set(entry.topic, {
387
+ topic: entry.topic,
388
+ score: entry.score * recency,
389
+ recency,
390
+ frequency: 1,
391
+ impact: 1,
392
+ urgency: 0,
393
+ lastSeen: entry.timestamp,
394
+ });
395
+ }
396
+ }
397
+ }
398
+ // ── Lifecycle ─────────────────────────────────────────
399
+ stop() {
400
+ if (this.unsubscribe) {
401
+ this.unsubscribe();
402
+ this.unsubscribe = null;
403
+ }
404
+ // Persist top focus entries on shutdown
405
+ const top = this.getTopTopics(20);
406
+ for (const t of top) {
407
+ this.persistFocusEntry(t.topic);
408
+ }
409
+ }
410
+ }
411
+ //# sourceMappingURL=attention-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attention-engine.js","sourceRoot":"","sources":["../../src/attention/attention-engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAiE/C,2DAA2D;AAE3D,MAAM,OAAO,eAAe;IAClB,EAAE,CAAoB;IACtB,SAAS,CAAS;IAClB,aAAa,GAAyB,IAAI,CAAC;IAC3C,WAAW,GAAwB,IAAI,CAAC;IACxC,GAAG,GAAG,SAAS,EAAE,CAAC;IAE1B,kBAAkB;IACV,MAAM,GAAgC,IAAI,GAAG,EAAE,CAAC;IAChD,cAAc,GAAgB,MAAM,CAAC;IACrC,cAAc,GAAoB,EAAE,CAAC;IACrC,aAAa,GAAwB,IAAI,GAAG,EAAE,CAAC;IAC/C,QAAQ,GAAsE,EAAE,CAAC;IACjF,WAAW,GAAG,CAAC,CAAC;IAChB,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE/B,SAAS;IACD,SAAS,CAAS;IAClB,aAAa,CAAS;IACtB,cAAc,CAAS;IAE/B,yDAAyD;IACjD,MAAM,CAAU,aAAa,GAAqD;QACxF,EAAE,OAAO,EAAE,4CAA4C,EAAE,OAAO,EAAE,WAAW,EAAE;QAC/E,EAAE,OAAO,EAAE,4CAA4C,EAAE,OAAO,EAAE,SAAS,EAAE;QAC7E,EAAE,OAAO,EAAE,+DAA+D,EAAE,OAAO,EAAE,YAAY,EAAE;QACnG,EAAE,OAAO,EAAE,wCAAwC,EAAE,OAAO,EAAE,WAAW,EAAE;QAC3E,EAAE,OAAO,EAAE,sDAAsD,EAAE,OAAO,EAAE,aAAa,EAAE;QAC3F,EAAE,OAAO,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AAM,EAAE,CAAC;oBACT,OAAO,EAAE,CAAC;oBACV,QAAQ,EAAE,KAAK,CAAC,SAAS;iBAC1B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,yDAAyD;IAEzD,IAAI;QACF,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC1B,CAAC;QAED,wCAAwC;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAClC,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;YACpB,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { AttentionEngine } from './attention-engine.js';
2
+ export type { AttentionEngineConfig, AttentionScore, AttentionStatus, WorkContext, ContextSwitch, FocusEntry, EngineWeight, } from './attention-engine.js';
@@ -0,0 +1,2 @@
1
+ export { AttentionEngine } from './attention-engine.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/attention/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { CodeGenerator } from './code-generator.js';
2
+ import type { CodeMiner } from './code-miner.js';
3
+ import type { PatternExtractor } from './pattern-extractor.js';
4
+ export interface CodegenServerOptions {
5
+ port: number;
6
+ codeGenerator: CodeGenerator;
7
+ codeMiner?: CodeMiner | null;
8
+ patternExtractor?: PatternExtractor | null;
9
+ }
10
+ export declare class CodegenServer {
11
+ private options;
12
+ private server;
13
+ private clients;
14
+ private heartbeatTimer;
15
+ private dashboardHtml;
16
+ private logger;
17
+ constructor(options: CodegenServerOptions);
18
+ start(): void;
19
+ stop(): void;
20
+ getClientCount(): number;
21
+ /** Broadcast an SSE event to all connected clients. */
22
+ broadcast(event: string, data: unknown): void;
23
+ private handleGetState;
24
+ private handleGenerate;
25
+ private handleReview;
26
+ }