@kernel.chat/kbot 3.44.0 → 3.45.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.
- package/dist/agent-teams.d.ts +1 -1
- package/dist/agent-teams.d.ts.map +1 -1
- package/dist/agent-teams.js +56 -2
- package/dist/agent-teams.js.map +1 -1
- package/dist/agents/specialists.d.ts.map +1 -1
- package/dist/agents/specialists.js +109 -0
- package/dist/agents/specialists.js.map +1 -1
- package/dist/cli.js +5 -5
- package/dist/episodic-memory.d.ts.map +1 -1
- package/dist/episodic-memory.js +8 -0
- package/dist/episodic-memory.js.map +1 -1
- package/dist/learned-router.d.ts.map +1 -1
- package/dist/learned-router.js +48 -0
- package/dist/learned-router.js.map +1 -1
- package/dist/tools/lab-neuro.d.ts.map +1 -1
- package/dist/tools/lab-neuro.js +227 -0
- package/dist/tools/lab-neuro.js.map +1 -1
- package/package.json +1 -1
package/dist/tools/lab-neuro.js
CHANGED
|
@@ -2459,6 +2459,233 @@ export function registerLabNeuroTools() {
|
|
|
2459
2459
|
return parts.join('\n');
|
|
2460
2460
|
},
|
|
2461
2461
|
});
|
|
2462
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
2463
|
+
// 11. Brain Activation Prediction
|
|
2464
|
+
// ════════════════════════════════════════════════════════════════════════════
|
|
2465
|
+
registerTool({
|
|
2466
|
+
name: 'brain_predict',
|
|
2467
|
+
description: 'Predict brain activation patterns from stimulus descriptions. Maps stimulus features to expected brain region activations based on established neuroscience literature. Supports visual, auditory, text/language, motor, emotional, and social stimulus types.',
|
|
2468
|
+
parameters: {
|
|
2469
|
+
stimulus: { type: 'string', description: 'Describe the stimulus (e.g., "a face showing fear moving across a red background")', required: true },
|
|
2470
|
+
stimulus_type: { type: 'string', description: 'Stimulus modality: visual, auditory, text, motor, emotional, social (default: visual)' },
|
|
2471
|
+
detail_level: { type: 'string', description: 'Output detail: overview or detailed (default: overview)' },
|
|
2472
|
+
},
|
|
2473
|
+
tier: 'free',
|
|
2474
|
+
async execute(args) {
|
|
2475
|
+
const stimulus = String(args.stimulus || '').toLowerCase();
|
|
2476
|
+
const stimType = String(args.stimulus_type || 'visual').toLowerCase();
|
|
2477
|
+
const detail = String(args.detail_level || 'overview').toLowerCase();
|
|
2478
|
+
if (!stimulus)
|
|
2479
|
+
return 'Error: stimulus description is required.';
|
|
2480
|
+
const activations = [];
|
|
2481
|
+
function add(region, activation, fn, reasoning) {
|
|
2482
|
+
// Check if already added, keep higher activation
|
|
2483
|
+
const existing = activations.find(a => a.region === region);
|
|
2484
|
+
if (existing) {
|
|
2485
|
+
if (activation > existing.activation) {
|
|
2486
|
+
existing.activation = activation;
|
|
2487
|
+
existing.function = fn;
|
|
2488
|
+
existing.reasoning = reasoning;
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
else {
|
|
2492
|
+
activations.push({ region, activation: Math.min(1, Math.max(0, activation)), function: fn, reasoning });
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
// ── Visual features ──
|
|
2496
|
+
if (stimType === 'visual' || /\b(see|look|watch|view|image|picture|photo|scene|display|screen)\b/.test(stimulus)) {
|
|
2497
|
+
add('V1/V2 (Primary Visual)', 0.8, 'Edge detection, orientation', 'All visual stimuli activate primary visual cortex');
|
|
2498
|
+
if (/\b(color|red|blue|green|yellow|orange|purple|hue|bright|colorful|chromatic)\b/.test(stimulus)) {
|
|
2499
|
+
add('V4 (Color Area)', 0.85, 'Color perception', 'Color features detected in stimulus');
|
|
2500
|
+
}
|
|
2501
|
+
if (/\b(move|motion|moving|flow|speed|drift|rotate|spin|flying|running|walking)\b/.test(stimulus)) {
|
|
2502
|
+
add('V5/MT (Motion Area)', 0.9, 'Motion perception', 'Motion features detected in stimulus');
|
|
2503
|
+
add('Dorsal Stream (Parietal)', 0.7, 'Where/how processing', 'Motion engages dorsal spatial stream');
|
|
2504
|
+
}
|
|
2505
|
+
if (/\b(face|facial|expression|person|people|portrait|eye|smile|frown)\b/.test(stimulus)) {
|
|
2506
|
+
add('FFA (Fusiform Face Area)', 0.95, 'Face processing', 'Face/facial features detected');
|
|
2507
|
+
add('STS (Superior Temporal Sulcus)', 0.6, 'Biological motion, gaze', 'Face stimuli engage social perception');
|
|
2508
|
+
}
|
|
2509
|
+
if (/\b(place|scene|room|building|landscape|house|city|street|indoor|outdoor|environment)\b/.test(stimulus)) {
|
|
2510
|
+
add('PPA (Parahippocampal Place Area)', 0.9, 'Scene/place processing', 'Place/scene features detected');
|
|
2511
|
+
}
|
|
2512
|
+
if (/\b(object|tool|car|chair|animal|thing|item|shape)\b/.test(stimulus)) {
|
|
2513
|
+
add('LOC (Lateral Occipital Complex)', 0.85, 'Object recognition', 'Object features detected');
|
|
2514
|
+
add('Ventral Stream (Temporal)', 0.75, 'What processing', 'Object identity engages ventral stream');
|
|
2515
|
+
}
|
|
2516
|
+
if (/\b(word|text|letter|read|written|sign|label)\b/.test(stimulus)) {
|
|
2517
|
+
add('VWFA (Visual Word Form Area)', 0.9, 'Visual word recognition', 'Written text features detected');
|
|
2518
|
+
}
|
|
2519
|
+
if (/\b(where|location|spatial|position|distance|depth|reach|grasp)\b/.test(stimulus)) {
|
|
2520
|
+
add('Dorsal Stream (Parietal)', 0.8, 'Where/how processing', 'Spatial features engage dorsal stream');
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
// ── Auditory features ──
|
|
2524
|
+
if (stimType === 'auditory' || /\b(hear|listen|sound|audio|noise|music|tone|voice|speech|song|melody)\b/.test(stimulus)) {
|
|
2525
|
+
add("A1 (Primary Auditory / Heschl's Gyrus)", 0.85, 'Sound processing', 'All auditory stimuli activate primary auditory cortex');
|
|
2526
|
+
if (/\b(tone|pure|frequency|pitch|beep|hz|hertz|sine)\b/.test(stimulus)) {
|
|
2527
|
+
add("Heschl's Gyrus", 0.9, 'Pure tone processing', 'Simple tonal features detected');
|
|
2528
|
+
}
|
|
2529
|
+
if (/\b(speech|talk|word|sentence|language|conversation|speak|voice|said)\b/.test(stimulus)) {
|
|
2530
|
+
add("Wernicke's Area (STG)", 0.9, 'Language comprehension', 'Speech/language features detected');
|
|
2531
|
+
add('Left IFG (Broca\'s)', 0.5, 'Speech processing', 'Speech perception coactivates production areas');
|
|
2532
|
+
}
|
|
2533
|
+
if (/\b(voice|speaker|vocal|human|person)\b/.test(stimulus)) {
|
|
2534
|
+
add('Superior Temporal (Voice Area)', 0.85, 'Voice identity processing', 'Human voice features detected');
|
|
2535
|
+
}
|
|
2536
|
+
if (/\b(music|melody|harmony|rhythm|song|instrument|chord|beat)\b/.test(stimulus)) {
|
|
2537
|
+
add('Planum Temporale', 0.8, 'Complex sound analysis', 'Musical/complex sound features detected');
|
|
2538
|
+
add('Right Hemisphere Auditory', 0.7, 'Melodic processing', 'Music engages right-lateralized processing');
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
// ── Text/Language features ──
|
|
2542
|
+
if (stimType === 'text' || /\b(read|write|sentence|grammar|syntax|word|meaning|comprehend|language)\b/.test(stimulus)) {
|
|
2543
|
+
add("Broca's Area (Left IFG)", 0.8, 'Language production/syntax', 'Language processing engages Broca\'s area');
|
|
2544
|
+
add("Wernicke's Area (STG)", 0.8, 'Language comprehension', 'Language comprehension processing');
|
|
2545
|
+
add('Angular Gyrus', 0.7, 'Semantic processing', 'Meaning extraction engages angular gyrus');
|
|
2546
|
+
if (/\b(read|written|text|book|letter|word)\b/.test(stimulus)) {
|
|
2547
|
+
add('VWFA (Visual Word Form Area)', 0.9, 'Reading/orthography', 'Written text processing detected');
|
|
2548
|
+
}
|
|
2549
|
+
if (/\b(grammar|syntax|structure|parse|sentence)\b/.test(stimulus)) {
|
|
2550
|
+
add('Left IFG (BA 44/45)', 0.85, 'Syntactic processing', 'Grammatical features detected');
|
|
2551
|
+
}
|
|
2552
|
+
if (/\b(meaning|semantic|concept|definition|understand)\b/.test(stimulus)) {
|
|
2553
|
+
add('Angular Gyrus', 0.85, 'Semantic integration', 'Semantic processing features detected');
|
|
2554
|
+
add('Anterior Temporal Lobe', 0.7, 'Conceptual knowledge', 'Meaning extraction engages ATL');
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
// ── Motor features ──
|
|
2558
|
+
if (stimType === 'motor' || /\b(move|reach|grasp|press|tap|walk|run|jump|kick|throw|point|gesture)\b/.test(stimulus)) {
|
|
2559
|
+
add('M1 (Primary Motor Cortex)', 0.85, 'Movement execution', 'Motor actions engage primary motor cortex');
|
|
2560
|
+
add('SMA (Supplementary Motor Area)', 0.7, 'Movement planning/sequencing', 'Motor planning for action sequences');
|
|
2561
|
+
if (/\b(plan|prepare|intend|imagine move|rehearse)\b/.test(stimulus)) {
|
|
2562
|
+
add('Premotor Cortex', 0.85, 'Movement preparation', 'Motor preparation features detected');
|
|
2563
|
+
add('SMA', 0.8, 'Sequence planning', 'Movement planning detected');
|
|
2564
|
+
}
|
|
2565
|
+
if (/\b(coordinate|balance|precise|fine|skilled|timing)\b/.test(stimulus)) {
|
|
2566
|
+
add('Cerebellum', 0.85, 'Motor coordination/timing', 'Coordination demands detected');
|
|
2567
|
+
}
|
|
2568
|
+
if (/\b(choose|select|switch|decide|habit)\b/.test(stimulus)) {
|
|
2569
|
+
add('Basal Ganglia (Striatum)', 0.8, 'Action selection', 'Action selection/switching detected');
|
|
2570
|
+
}
|
|
2571
|
+
if (/\b(hand|finger|grip|grasp|manipulate)\b/.test(stimulus)) {
|
|
2572
|
+
add('M1 (Hand Area)', 0.9, 'Fine motor control', 'Hand/finger motor features detected');
|
|
2573
|
+
add('Cerebellum', 0.7, 'Fine coordination', 'Precision grasp demands');
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
// ── Emotional features ──
|
|
2577
|
+
if (stimType === 'emotional' || /\b(fear|anger|happy|sad|disgust|surprise|emotion|threat|danger|reward|punish|stress|anxiety|joy|love|hate)\b/.test(stimulus)) {
|
|
2578
|
+
if (/\b(fear|threat|danger|alarm|scary|frightening|startl|avers)\b/.test(stimulus)) {
|
|
2579
|
+
add('Amygdala', 0.95, 'Threat detection/fear', 'Threat/fear features strongly activate amygdala');
|
|
2580
|
+
add('PAG (Periaqueductal Gray)', 0.6, 'Defensive behavior', 'Threat triggers defensive circuits');
|
|
2581
|
+
}
|
|
2582
|
+
if (/\b(disgust|revuls|nause|gross|contaminat)\b/.test(stimulus)) {
|
|
2583
|
+
add('Anterior Insula', 0.9, 'Disgust/interoception', 'Disgust features detected');
|
|
2584
|
+
}
|
|
2585
|
+
if (/\b(reward|pleasant|enjoy|like|want|crave|desire)\b/.test(stimulus)) {
|
|
2586
|
+
add('vmPFC (Ventromedial PFC)', 0.8, 'Value/reward', 'Reward valuation features detected');
|
|
2587
|
+
add('OFC (Orbitofrontal Cortex)', 0.8, 'Reward processing', 'Reward features engage OFC');
|
|
2588
|
+
add('Nucleus Accumbens', 0.75, 'Reward/pleasure', 'Reward anticipation/receipt');
|
|
2589
|
+
}
|
|
2590
|
+
if (/\b(conflict|difficult|error|uncertain|ambiguous)\b/.test(stimulus)) {
|
|
2591
|
+
add('ACC (Anterior Cingulate)', 0.85, 'Conflict monitoring', 'Conflict/uncertainty features detected');
|
|
2592
|
+
}
|
|
2593
|
+
add('Amygdala', 0.6, 'Emotional salience', 'Emotional stimuli engage amygdala for salience');
|
|
2594
|
+
if (/\b(memory|remember|context|familiar|past)\b/.test(stimulus)) {
|
|
2595
|
+
add('Hippocampus', 0.7, 'Emotional context/memory', 'Contextual memory for emotional processing');
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
// ── Social features ──
|
|
2599
|
+
if (stimType === 'social' || /\b(person|people|social|interact|group|friend|stranger|communicat|cooperat|compet|trust|betray|empathy|moral)\b/.test(stimulus)) {
|
|
2600
|
+
add('TPJ (Temporoparietal Junction)', 0.85, 'Theory of mind', 'Social stimuli engage mentalizing');
|
|
2601
|
+
add('mPFC (Medial Prefrontal Cortex)', 0.8, 'Self/other distinction', 'Social cognition engages mPFC');
|
|
2602
|
+
if (/\b(face|expression|gaze|eye contact|look at)\b/.test(stimulus)) {
|
|
2603
|
+
add('FFA (Fusiform Face Area)', 0.9, 'Face processing', 'Social face processing detected');
|
|
2604
|
+
}
|
|
2605
|
+
if (/\b(move|gesture|body|action|imitat|mirror)\b/.test(stimulus)) {
|
|
2606
|
+
add('STS (Superior Temporal Sulcus)', 0.85, 'Biological motion', 'Social motion features detected');
|
|
2607
|
+
add('Mirror Neuron System (PMC/IFG)', 0.75, 'Action understanding/imitation', 'Imitation/observation of actions');
|
|
2608
|
+
}
|
|
2609
|
+
if (/\b(moral|ethical|fair|unfair|right|wrong|justice)\b/.test(stimulus)) {
|
|
2610
|
+
add('vmPFC', 0.8, 'Moral judgment', 'Moral reasoning features detected');
|
|
2611
|
+
add('TPJ', 0.85, 'Perspective taking', 'Moral scenarios require perspective taking');
|
|
2612
|
+
}
|
|
2613
|
+
if (/\b(empathy|sympathy|pain|suffer|feel for)\b/.test(stimulus)) {
|
|
2614
|
+
add('Anterior Insula', 0.8, 'Empathic processing', 'Empathy features detected');
|
|
2615
|
+
add('ACC', 0.7, 'Empathic pain', 'Shared pain representation');
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
// If no activations were generated, add baseline for the stimulus type
|
|
2619
|
+
if (activations.length === 0) {
|
|
2620
|
+
add('Prefrontal Cortex', 0.5, 'Executive processing', 'Default engagement for cognitive processing');
|
|
2621
|
+
add('Thalamus', 0.4, 'Sensory relay', 'Thalamic gating of sensory input');
|
|
2622
|
+
}
|
|
2623
|
+
// Sort by activation level descending
|
|
2624
|
+
activations.sort((a, b) => b.activation - a.activation);
|
|
2625
|
+
// ── Format output ──
|
|
2626
|
+
const parts = [];
|
|
2627
|
+
parts.push('## Brain Activation Prediction');
|
|
2628
|
+
parts.push('');
|
|
2629
|
+
parts.push(`**Stimulus**: "${args.stimulus}"`);
|
|
2630
|
+
parts.push(`**Type**: ${stimType}`);
|
|
2631
|
+
parts.push(`**Regions activated**: ${activations.length}`);
|
|
2632
|
+
parts.push('');
|
|
2633
|
+
// Activation bar helper
|
|
2634
|
+
function bar(level) {
|
|
2635
|
+
const filled = Math.round(level * 10);
|
|
2636
|
+
return '\u2588'.repeat(filled) + '\u2591'.repeat(10 - filled);
|
|
2637
|
+
}
|
|
2638
|
+
parts.push('### Predicted Activation Map');
|
|
2639
|
+
parts.push('');
|
|
2640
|
+
parts.push('| Region | Activation | Level | Function | Reasoning |');
|
|
2641
|
+
parts.push('|--------|-----------|-------|----------|-----------|');
|
|
2642
|
+
const limit = detail === 'detailed' ? activations.length : Math.min(activations.length, 8);
|
|
2643
|
+
for (let i = 0; i < limit; i++) {
|
|
2644
|
+
const a = activations[i];
|
|
2645
|
+
const level = a.activation >= 0.8 ? 'HIGH' : a.activation >= 0.5 ? 'MED' : 'LOW';
|
|
2646
|
+
parts.push(`| ${a.region} | ${bar(a.activation)} ${fmt(a.activation, 2)} | ${level} | ${a.function} | ${a.reasoning} |`);
|
|
2647
|
+
}
|
|
2648
|
+
if (detail === 'detailed') {
|
|
2649
|
+
parts.push('');
|
|
2650
|
+
parts.push('### Processing Streams');
|
|
2651
|
+
const hasDorsal = activations.some(a => /dorsal|parietal|where|spatial/i.test(a.region));
|
|
2652
|
+
const hasVentral = activations.some(a => /ventral|temporal|what|object|face/i.test(a.region));
|
|
2653
|
+
if (hasDorsal)
|
|
2654
|
+
parts.push('- **Dorsal ("where/how")**: Active - spatial/action processing engaged');
|
|
2655
|
+
if (hasVentral)
|
|
2656
|
+
parts.push('- **Ventral ("what")**: Active - object/identity processing engaged');
|
|
2657
|
+
if (!hasDorsal && !hasVentral)
|
|
2658
|
+
parts.push('- No dominant visual processing stream identified');
|
|
2659
|
+
parts.push('');
|
|
2660
|
+
parts.push('### Network Engagement');
|
|
2661
|
+
const hasDefault = activations.some(a => /mpfc|precuneus|posterior cingulate|angular/i.test(a.region.toLowerCase()));
|
|
2662
|
+
const hasSalience = activations.some(a => /insula|acc|amygdala/i.test(a.region.toLowerCase()));
|
|
2663
|
+
const hasExecutive = activations.some(a => /dlpfc|prefrontal|ips/i.test(a.region.toLowerCase()));
|
|
2664
|
+
if (hasDefault)
|
|
2665
|
+
parts.push('- **Default Mode Network**: Engaged (self-referential/social processing)');
|
|
2666
|
+
if (hasSalience)
|
|
2667
|
+
parts.push('- **Salience Network**: Engaged (emotional/interoceptive processing)');
|
|
2668
|
+
if (hasExecutive)
|
|
2669
|
+
parts.push('- **Executive Network**: Engaged (cognitive control/attention)');
|
|
2670
|
+
if (!hasDefault && !hasSalience && !hasExecutive)
|
|
2671
|
+
parts.push('- Primarily sensory processing (no major network hubs identified)');
|
|
2672
|
+
parts.push('');
|
|
2673
|
+
parts.push('### Lateralization');
|
|
2674
|
+
const leftLateral = activations.some(a => /broca|wernicke|vwfa|left ifg|angular/i.test(a.region.toLowerCase()));
|
|
2675
|
+
const rightLateral = activations.some(a => /right hemisphere|prosody|spatial/i.test(a.region.toLowerCase()));
|
|
2676
|
+
if (leftLateral && !rightLateral)
|
|
2677
|
+
parts.push('- **Left-lateralized**: Language/analytical processing dominant');
|
|
2678
|
+
else if (rightLateral && !leftLateral)
|
|
2679
|
+
parts.push('- **Right-lateralized**: Spatial/prosodic processing dominant');
|
|
2680
|
+
else
|
|
2681
|
+
parts.push('- **Bilateral**: Both hemispheres engaged');
|
|
2682
|
+
}
|
|
2683
|
+
parts.push('');
|
|
2684
|
+
parts.push('---');
|
|
2685
|
+
parts.push('*Predictions based on established neuroscience literature (fMRI/PET meta-analyses). Actual activation patterns vary by individual, attention state, and task demands.*');
|
|
2686
|
+
return parts.join('\n');
|
|
2687
|
+
},
|
|
2688
|
+
});
|
|
2462
2689
|
}
|
|
2463
2690
|
// ─── Gaussian random helper (Box-Muller) ─────────────────────────────────────
|
|
2464
2691
|
function gaussianRandom() {
|