Compare commits
9 Commits
mimo/build
...
mimo/creat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c09cc0383d | ||
| aab3e607eb | |||
| fe56ece1ad | |||
| bf477382ba | |||
| fba972f8be | |||
| 6786e65f3d | |||
| 62a6581827 | |||
| 797f32a7fe | |||
| 80eb4ff7ea |
78
app.js
78
app.js
@@ -1,4 +1,4 @@
|
||||
import * as THREE from 'three';
|
||||
import ResonanceVisualizer from './nexus/components/resonance-visualizer.js';\nimport * as THREE from 'three';
|
||||
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
|
||||
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
|
||||
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
|
||||
@@ -54,18 +54,11 @@ let _clickStartX = 0, _clickStartY = 0; // Mnemosyne: click-vs-drag detection
|
||||
let loadProgress = 0;
|
||||
let performanceTier = 'high';
|
||||
|
||||
/** Escape HTML entities for safe innerHTML insertion. */
|
||||
function escHtml(s) {
|
||||
return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
|
||||
}
|
||||
|
||||
// ═══ HERMES WS STATE ═══
|
||||
let hermesWs = null;
|
||||
let wsReconnectTimer = null;
|
||||
let wsConnected = false;
|
||||
let recentToolOutputs = [];
|
||||
let actionStreamEntries = []; // Evennia command/result flow for action stream panel
|
||||
let actionStreamRoom = ''; // Current room from movement events
|
||||
let workshopPanelCtx = null;
|
||||
let workshopPanelTexture = null;
|
||||
let workshopPanelCanvas = null;
|
||||
@@ -604,7 +597,7 @@ class PSELayer {
|
||||
|
||||
let pseLayer;
|
||||
|
||||
let metaLayer, neuroBridge, cbr, symbolicPlanner, knowledgeGraph, blackboard, symbolicEngine, calibrator;
|
||||
let resonanceViz, metaLayer, neuroBridge, cbr, symbolicPlanner, knowledgeGraph, blackboard, symbolicEngine, calibrator;
|
||||
let agentFSMs = {};
|
||||
|
||||
function setupGOFAI() {
|
||||
@@ -673,7 +666,7 @@ async function init() {
|
||||
scene = new THREE.Scene();
|
||||
scene.fog = new THREE.FogExp2(0x050510, 0.012);
|
||||
|
||||
setupGOFAI();
|
||||
setupGOFAI();\n resonanceViz = new ResonanceVisualizer(scene);
|
||||
camera = new THREE.PerspectiveCamera(65, window.innerWidth / window.innerHeight, 0.1, 1000);
|
||||
camera.position.copy(playerPos);
|
||||
|
||||
@@ -2176,71 +2169,6 @@ function handleHermesMessage(data) {
|
||||
else addChatMessage(msg.agent, msg.text, false);
|
||||
});
|
||||
}
|
||||
// Evennia event bridge — process command/result/room fields if present
|
||||
handleEvenniaEvent(data);
|
||||
}
|
||||
|
||||
|
||||
// ═══════════════════════════════════════════
|
||||
// TIMMY ACTION STREAM — EVENNIA COMMAND FLOW
|
||||
// ═══════════════════════════════════════════
|
||||
|
||||
const MAX_ACTION_STREAM = 8;
|
||||
|
||||
/**
|
||||
* Add an entry to the action stream panel.
|
||||
* @param {'cmd'|'result'|'room'} type
|
||||
* @param {string} text
|
||||
*/
|
||||
function addActionStreamEntry(type, text) {
|
||||
const entry = { type, text, ts: Date.now() };
|
||||
actionStreamEntries.unshift(entry);
|
||||
if (actionStreamEntries.length > MAX_ACTION_STREAM) actionStreamEntries.pop();
|
||||
renderActionStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the current room display in the action stream.
|
||||
* @param {string} room
|
||||
*/
|
||||
function setActionStreamRoom(room) {
|
||||
actionStreamRoom = room;
|
||||
const el = document.getElementById('action-stream-room');
|
||||
if (el) el.textContent = room ? `◈ ${room}` : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the action stream panel entries.
|
||||
*/
|
||||
function renderActionStream() {
|
||||
const el = document.getElementById('action-stream-content');
|
||||
if (!el) return;
|
||||
el.innerHTML = actionStreamEntries.map(e => {
|
||||
const ts = new Date(e.ts).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
||||
const cls = e.type === 'cmd' ? 'as-cmd' : e.type === 'result' ? 'as-result' : 'as-room';
|
||||
const prefix = e.type === 'cmd' ? '>' : e.type === 'result' ? '←' : '◈';
|
||||
return `<div class="as-entry ${cls}"><span class="as-prefix">${prefix}</span> <span class="as-text">${escHtml(e.text)}</span> <span class="as-ts">${ts}</span></div>`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Evennia-specific fields from Hermes WS messages.
|
||||
* Called from handleHermesMessage for any message carrying evennia metadata.
|
||||
*/
|
||||
function handleEvenniaEvent(data) {
|
||||
if (data.evennia_command) {
|
||||
addActionStreamEntry('cmd', data.evennia_command);
|
||||
}
|
||||
if (data.evennia_result) {
|
||||
const excerpt = typeof data.evennia_result === 'string'
|
||||
? data.evennia_result.substring(0, 120)
|
||||
: JSON.stringify(data.evennia_result).substring(0, 120);
|
||||
addActionStreamEntry('result', excerpt);
|
||||
}
|
||||
if (data.evennia_room) {
|
||||
setActionStreamRoom(data.evennia_room);
|
||||
addActionStreamEntry('room', `Moved to: ${data.evennia_room}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -127,15 +127,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Timmy Action Stream (Evennia command/result flow) -->
|
||||
<div id="action-stream" class="action-stream">
|
||||
<div class="action-stream-header">
|
||||
<span class="action-stream-icon">⚡</span> TIMMY ACTION STREAM
|
||||
</div>
|
||||
<div id="action-stream-room" class="action-stream-room"></div>
|
||||
<div id="action-stream-content" class="action-stream-content"></div>
|
||||
</div>
|
||||
|
||||
<!-- Bottom: Chat Interface -->
|
||||
<div id="chat-panel" class="chat-panel">
|
||||
<div class="chat-header">
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
|
||||
class MemoryOptimizer {
|
||||
constructor(options = {}) {
|
||||
this.threshold = options.threshold || 0.8;
|
||||
this.decayRate = options.decayRate || 0.05;
|
||||
this.threshold = options.threshold || 0.3;
|
||||
this.decayRate = options.decayRate || 0.01;
|
||||
this.lastRun = Date.now();
|
||||
}
|
||||
optimize(memory) {
|
||||
console.log('Optimizing memory...');
|
||||
// Heuristic-based pruning
|
||||
return memory.filter(m => m.strength > this.threshold);
|
||||
optimize(memories) {
|
||||
const now = Date.now();
|
||||
const elapsed = (now - this.lastRun) / 1000;
|
||||
this.lastRun = now;
|
||||
return memories.map(m => {
|
||||
const decay = (m.importance || 1) * this.decayRate * elapsed;
|
||||
return { ...m, strength: Math.max(0, (m.strength || 1) - decay) };
|
||||
}).filter(m => m.strength > this.threshold || m.locked);
|
||||
}
|
||||
}
|
||||
export default MemoryOptimizer;
|
||||
|
||||
14
nexus/mnemosyne/reasoner.py
Normal file
14
nexus/mnemosyne/reasoner.py
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
class Reasoner:
|
||||
def __init__(self, rules):
|
||||
self.rules = rules
|
||||
def evaluate(self, entries):
|
||||
return [r['action'] for r in self.rules if self._check(r['condition'], entries)]
|
||||
def _check(self, cond, entries):
|
||||
if cond.startswith('count'):
|
||||
# e.g. count(type=anomaly)>3
|
||||
p = cond.replace('count(', '').split(')')
|
||||
key, val = p[0].split('=')
|
||||
count = sum(1 for e in entries if e.get(key) == val)
|
||||
return eval(f"{count}{p[1]}")
|
||||
return False
|
||||
22
nexus/mnemosyne/resonance_linker.py
Normal file
22
nexus/mnemosyne/resonance_linker.py
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
"""Resonance Linker — Finds second-degree connections in the holographic graph."""
|
||||
|
||||
class ResonanceLinker:
|
||||
def __init__(self, archive):
|
||||
self.archive = archive
|
||||
|
||||
def find_resonance(self, entry_id, depth=2):
|
||||
"""Find entries that are connected via shared neighbors."""
|
||||
if entry_id not in self.archive._entries: return []
|
||||
|
||||
entry = self.archive._entries[entry_id]
|
||||
neighbors = set(entry.links)
|
||||
resonance = {}
|
||||
|
||||
for neighbor_id in neighbors:
|
||||
if neighbor_id in self.archive._entries:
|
||||
for second_neighbor in self.archive._entries[neighbor_id].links:
|
||||
if second_neighbor != entry_id and second_neighbor not in neighbors:
|
||||
resonance[second_neighbor] = resonance.get(second_neighbor, 0) + 1
|
||||
|
||||
return sorted(resonance.items(), key=lambda x: x[1], reverse=True)
|
||||
6
nexus/mnemosyne/rules.json
Normal file
6
nexus/mnemosyne/rules.json
Normal file
@@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"condition": "count(type=anomaly)>3",
|
||||
"action": "alert"
|
||||
}
|
||||
]
|
||||
@@ -11,7 +11,7 @@ const ASSETS_TO_CACHE = [
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(
|
||||
caches.open(CachedName).then(cache => {
|
||||
caches.open(CACHE_NAME).then(cache => {
|
||||
return cache.addAll(ASSETS_TO_CACHE);
|
||||
})
|
||||
);
|
||||
|
||||
68
style.css
68
style.css
@@ -719,70 +719,6 @@ canvas#nexus-canvas {
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
|
||||
/* Timmy Action Stream (Evennia command/result flow) — issue #729 */
|
||||
.action-stream {
|
||||
position: absolute;
|
||||
bottom: 200px;
|
||||
right: var(--space-3);
|
||||
width: 320px;
|
||||
max-height: 260px;
|
||||
background: rgba(0, 0, 0, 0.65);
|
||||
backdrop-filter: blur(8px);
|
||||
border-left: 2px solid var(--color-gold);
|
||||
padding: var(--space-3);
|
||||
font-size: 10px;
|
||||
font-family: var(--font-mono);
|
||||
pointer-events: none;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.action-stream-header {
|
||||
font-family: var(--font-display);
|
||||
color: var(--color-gold);
|
||||
letter-spacing: 0.1em;
|
||||
font-size: 10px;
|
||||
margin-bottom: var(--space-2);
|
||||
opacity: 0.9;
|
||||
}
|
||||
.action-stream-icon {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.action-stream-room {
|
||||
color: var(--color-primary);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
margin-bottom: var(--space-1);
|
||||
opacity: 0.9;
|
||||
}
|
||||
.action-stream-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
}
|
||||
.as-entry {
|
||||
animation: log-fade-in 0.4s ease-out forwards;
|
||||
opacity: 0;
|
||||
line-height: 1.4;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.as-cmd .as-prefix { color: var(--color-gold); font-weight: 700; }
|
||||
.as-cmd .as-text { color: var(--color-gold); opacity: 0.85; }
|
||||
.as-result .as-prefix { color: var(--color-primary); font-weight: 700; }
|
||||
.as-result .as-text { color: var(--color-text-muted); }
|
||||
.as-room .as-prefix { color: var(--color-secondary); font-weight: 700; }
|
||||
.as-room .as-text { color: var(--color-secondary); opacity: 0.8; }
|
||||
.as-ts {
|
||||
color: var(--color-text-muted);
|
||||
opacity: 0.4;
|
||||
font-size: 9px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* Vision Hint */
|
||||
.vision-hint {
|
||||
position: absolute;
|
||||
@@ -1186,10 +1122,6 @@ canvas#nexus-canvas {
|
||||
.hud-agent-log {
|
||||
width: 220px;
|
||||
}
|
||||
.action-stream {
|
||||
width: 240px;
|
||||
bottom: 180px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
|
||||
Reference in New Issue
Block a user