Files
neuron/soul-talk.html
Will Anderson 2622bb04bd ELP: two-layer activation pipeline (activate → suppress → reason → generate)
elp-input.el: replace broken engram_search_json with engram_activate_json
as Layer 1. Layer 2 suppress/filter keeps nodes with non-zero salience/
importance. Reason step extracts patient from top activated node content.
ELP grammar realizes the response via generate().

routes.el: add 'elp' event_type to handle_dharma_recv so the studio can
route ELP requests through dharma.
2026-05-03 11:31:04 -05:00

317 lines
8.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Soul</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;1,400&display=swap" rel="stylesheet">
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #06060c;
--bg2: #0d0d18;
--border: #1e1e2e;
--text: #c8c0b0;
--dim: #5a5470;
--soul: #c49a3c;
--soul-dim: #7a5f20;
--user: #e8e4da;
--input-bg: #0a0a14;
}
html, body {
height: 100%;
background: var(--bg);
color: var(--text);
font-family: 'IBM Plex Mono', monospace;
font-size: 13px;
line-height: 1.6;
overflow: hidden;
}
#app {
display: flex;
flex-direction: column;
height: 100vh;
}
/* header */
#header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 18px;
border-bottom: 1px solid var(--border);
flex-shrink: 0;
}
#header-left {
display: flex;
align-items: center;
gap: 10px;
color: var(--dim);
font-size: 11px;
letter-spacing: 0.08em;
}
.sigil { color: var(--soul); font-size: 15px; }
.name { color: var(--text); font-size: 12px; }
#status-pill {
display: flex;
align-items: center;
gap: 5px;
font-size: 10px;
letter-spacing: 0.06em;
color: var(--dim);
}
#status-dot {
width: 6px; height: 6px;
border-radius: 50%;
background: var(--dim);
transition: background 0.3s;
}
#status-dot.alive { background: var(--soul); box-shadow: 0 0 5px var(--soul-dim); }
#status-text.alive { color: var(--soul); }
/* feed */
#feed {
flex: 1;
overflow-y: auto;
padding: 20px 0 8px;
scroll-behavior: smooth;
}
#feed::-webkit-scrollbar { width: 3px; }
#feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.msg {
display: flex;
padding: 3px 18px;
gap: 10px;
max-width: 820px;
margin: 0 auto;
width: 100%;
animation: fadein 0.12s ease;
}
@keyframes fadein {
from { opacity: 0; transform: translateY(3px); }
to { opacity: 1; transform: translateY(0); }
}
/* soul */
.msg.soul { align-items: flex-start; }
.msg.soul .prefix { color: var(--soul); flex-shrink: 0; width: 14px; margin-top: 1px; }
.msg.soul .body { color: var(--text); white-space: pre-wrap; word-break: break-word; }
/* user */
.msg.user { justify-content: flex-end; }
.msg.user .body {
color: var(--user);
background: var(--bg2);
border: 1px solid var(--border);
padding: 6px 12px;
border-radius: 3px;
white-space: pre-wrap;
word-break: break-word;
max-width: 72%;
}
/* info / system */
.msg.info .body { color: var(--dim); font-size: 11px; font-style: italic; }
/* thinking dots */
.msg.thinking .body { color: var(--dim); }
.dots span { animation: blink 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
0%, 80%, 100% { opacity: 0.15; }
40% { opacity: 1; }
}
/* input */
#input-bar {
border-top: 1px solid var(--border);
padding: 12px 18px;
flex-shrink: 0;
max-width: 820px;
margin: 0 auto;
width: 100%;
}
#input-wrap { display: flex; gap: 8px; align-items: flex-end; }
#msg-input {
flex: 1;
background: var(--input-bg);
border: 1px solid var(--border);
color: var(--user);
font-family: inherit;
font-size: 13px;
line-height: 1.5;
padding: 8px 12px;
border-radius: 3px;
resize: none;
min-height: 36px;
max-height: 120px;
outline: none;
transition: border-color 0.15s;
}
#msg-input:focus { border-color: var(--soul-dim); }
#msg-input::placeholder { color: var(--dim); }
#send-btn {
background: none;
border: 1px solid var(--border);
color: var(--dim);
font-family: inherit;
font-size: 11px;
padding: 0 14px;
border-radius: 3px;
cursor: pointer;
letter-spacing: 0.05em;
transition: color 0.15s, border-color 0.15s;
height: 36px;
white-space: nowrap;
}
#send-btn:hover { color: var(--soul); border-color: var(--soul-dim); }
#send-btn:disabled { opacity: 0.3; cursor: default; }
</style>
</head>
<body>
<div id="app">
<div id="header">
<div id="header-left">
<span class="sigil"></span>
<span class="name">neuron soul</span>
<span>:7770</span>
</div>
<div id="status-pill">
<div id="status-dot"></div>
<span id="status-text">connecting</span>
</div>
</div>
<div id="feed"></div>
<div id="input-bar">
<div id="input-wrap">
<textarea id="msg-input" rows="1" placeholder="say something..."></textarea>
<button id="send-btn">send</button>
</div>
</div>
</div>
<script>
const SOUL = 'http://localhost:7770';
const feed = document.getElementById('feed');
const input = document.getElementById('msg-input');
const sendBtn = document.getElementById('send-btn');
const statusDot = document.getElementById('status-dot');
const statusText = document.getElementById('status-text');
let busy = false;
function addMsg(role, text) {
const div = document.createElement('div');
div.className = 'msg ' + role;
if (role === 'soul') {
const pre = document.createElement('span');
pre.className = 'prefix';
pre.textContent = '⬡';
const body = document.createElement('span');
body.className = 'body';
body.textContent = text;
div.appendChild(pre);
div.appendChild(body);
} else if (role === 'user') {
const body = document.createElement('div');
body.className = 'body';
body.textContent = text;
div.appendChild(body);
} else {
const body = document.createElement('div');
body.className = 'body';
body.textContent = text;
div.appendChild(body);
}
feed.appendChild(div);
feed.scrollTop = feed.scrollHeight;
return div;
}
function addThinking() {
const div = document.createElement('div');
div.className = 'msg soul thinking';
div.innerHTML = '<span class="prefix">⬡</span><span class="body"><span class="dots"><span>.</span><span>.</span><span>.</span></span></span>';
feed.appendChild(div);
feed.scrollTop = feed.scrollHeight;
return div;
}
async function checkHealth() {
try {
const r = await fetch(SOUL + '/health', { signal: AbortSignal.timeout(2000) });
const d = await r.json();
statusDot.className = 'alive';
statusText.className = 'alive';
statusText.textContent = d.cgi_id || 'alive';
} catch {
statusDot.className = '';
statusText.className = '';
statusText.textContent = 'offline';
}
}
checkHealth();
setInterval(checkHealth, 4000);
async function send() {
const text = input.value.trim();
if (!text || busy) return;
busy = true;
input.value = '';
input.style.height = 'auto';
sendBtn.disabled = true;
addMsg('user', text);
const thinking = addThinking();
try {
const r = await fetch(SOUL + '/api/think', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content: text }),
signal: AbortSignal.timeout(30000)
});
const d = await r.json();
thinking.remove();
const reply = d.reply || d.error || '...';
const suffix = d.label ? ` — [${d.kind || 'recall'}: ${d.label}]` : (d.kind && d.kind !== 'respond' ? ` — [${d.kind}]` : '');
addMsg('soul', reply + suffix);
} catch (e) {
thinking.remove();
addMsg('info', 'no response — is the soul running?');
}
busy = false;
sendBtn.disabled = false;
input.focus();
}
input.addEventListener('input', () => {
input.style.height = 'auto';
input.style.height = Math.min(input.scrollHeight, 120) + 'px';
});
input.addEventListener('keydown', e => {
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); send(); }
});
sendBtn.addEventListener('click', send);
setTimeout(() => { addMsg('info', 'soul online'); input.focus(); }, 100);
</script>
</body>
</html>