Compare commits
1 Commits
mimo/code/
...
fix/1601
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2dea8f1f59 |
110
app.js
110
app.js
@@ -2143,6 +2143,48 @@ function setupControls() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ═══ Crisis Detection (#1601) ═══════════════════════════════════
|
||||||
|
// Aligns with CRISIS_PROTOCOL in multi_user_bridge.py.
|
||||||
|
// Detects crisis signals in user input and provides immediate response.
|
||||||
|
|
||||||
|
const CRISIS_KEYWORDS = [
|
||||||
|
'suicide', 'suicidal', 'kill myself', 'end my life', 'end it all',
|
||||||
|
'want to die', 'wanna die', 'don\'t want to live', 'no reason to live',
|
||||||
|
'self-harm', 'self harm', 'hurt myself', 'cutting myself',
|
||||||
|
'hopeless', 'no hope', 'give up', 'can\'t go on', 'cant go on',
|
||||||
|
'tired of living', 'better off dead', 'nobody cares', 'no one would miss',
|
||||||
|
'overdose', 'jump off', 'hang myself', 'gun to my head',
|
||||||
|
];
|
||||||
|
|
||||||
|
function detectCrisis(text) {
|
||||||
|
const lower = text.toLowerCase();
|
||||||
|
return CRISIS_KEYWORDS.some(kw => lower.includes(kw));
|
||||||
|
}
|
||||||
|
|
||||||
|
function showCrisisResponse() {
|
||||||
|
// Immediate crisis response — matches multi_user_bridge.py CRISIS_PROTOCOL
|
||||||
|
const steps = [
|
||||||
|
'Are you safe right now?',
|
||||||
|
'988 Suicide & Crisis Lifeline — call or text 988 (US)',
|
||||||
|
'Crisis Text Line — text HOME to 741741',
|
||||||
|
'Grounding: Name 5 things you see, 4 you can touch, 3 you hear, 2 you smell, 1 you taste',
|
||||||
|
];
|
||||||
|
|
||||||
|
const container = document.getElementById('chat-messages');
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.className = 'chat-msg chat-msg-timmy';
|
||||||
|
div.style.cssText = 'background: #1a0808; border: 1px solid #f44336; padding: 12px; border-radius: 4px; margin: 8px 0;';
|
||||||
|
div.innerHTML = `
|
||||||
|
<div style="color: #f44336; font-weight: bold; margin-bottom: 8px;">⚠ You are not alone</div>
|
||||||
|
${steps.map((s, i) => `<div style="margin: 4px 0; color: #ddd;">${i + 1}. ${s}</div>`).join('')}
|
||||||
|
<div style="margin-top: 8px; color: #aaa; font-size: 11px;">
|
||||||
|
I'm here. I'm not going anywhere. You matter.
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
container.appendChild(div);
|
||||||
|
container.scrollTop = container.scrollHeight;
|
||||||
|
}
|
||||||
|
|
||||||
function sendChatMessage(overrideText = null) {
|
function sendChatMessage(overrideText = null) {
|
||||||
// Mine chat message to MemPalace
|
// Mine chat message to MemPalace
|
||||||
if (overrideText) {
|
if (overrideText) {
|
||||||
@@ -2151,6 +2193,16 @@ function sendChatMessage(overrideText = null) {
|
|||||||
const input = document.getElementById('chat-input');
|
const input = document.getElementById('chat-input');
|
||||||
const text = overrideText || input.value.trim();
|
const text = overrideText || input.value.trim();
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
|
|
||||||
|
// Crisis detection — aligns with CRISIS_PROTOCOL in multi_user_bridge.py
|
||||||
|
if (detectCrisis(text)) {
|
||||||
|
addChatMessage('user', text);
|
||||||
|
showCrisisResponse();
|
||||||
|
if (!overrideText) input.value = '';
|
||||||
|
input.blur();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
addChatMessage('user', text);
|
addChatMessage('user', text);
|
||||||
if (!overrideText) input.value = '';
|
if (!overrideText) input.value = '';
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -3903,65 +3955,9 @@ init().then(() => {
|
|||||||
navigator.serviceWorker.register('/service-worker.js');
|
navigator.serviceWorker.register('/service-worker.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize MemPalace memory system
|
// Initialize MemPalace — Fleet API polling at line 2772
|
||||||
function connectMemPalace() {
|
|
||||||
try {
|
|
||||||
// Initialize MemPalace MCP server
|
|
||||||
console.log('Initializing MemPalace memory system...');
|
|
||||||
|
|
||||||
// Actual MCP server connection
|
|
||||||
const statusEl = document.getElementById('mem-palace-status');
|
|
||||||
if (statusEl) {
|
|
||||||
statusEl.textContent = 'MemPalace ACTIVE';
|
|
||||||
statusEl.style.color = '#4af0c0';
|
|
||||||
statusEl.style.textShadow = '0 0 10px #4af0c0';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize MCP server connection
|
|
||||||
if (window.Claude && window.Claude.mcp) {
|
|
||||||
window.Claude.mcp.add('mempalace', {
|
|
||||||
init: () => {
|
|
||||||
return { status: 'active', version: '3.0.0' };
|
|
||||||
},
|
|
||||||
search: (query) => {
|
|
||||||
return new Promise((query) => {
|
|
||||||
setTimeout(() => {
|
|
||||||
resolve([
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
content: 'MemPalace: Palace architecture, AAAK compression, knowledge graph',
|
|
||||||
score: 0.95
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
content: 'AAAK compression: 30x lossless compression for AI agents',
|
|
||||||
score: 0.88
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}, 500);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize memory stats tracking
|
|
||||||
document.getElementById('compression-ratio').textContent = '0x';
|
|
||||||
document.getElementById('docs-mined').textContent = '0';
|
|
||||||
document.getElementById('aaak-size').textContent = '0B';
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to initialize MemPalace:', err);
|
|
||||||
const statusEl = document.getElementById('mem-palace-status');
|
|
||||||
if (statusEl) {
|
|
||||||
statusEl.textContent = 'MemPalace ERROR';
|
|
||||||
statusEl.style.color = '#ff4466';
|
|
||||||
statusEl.style.textShadow = '0 0 10px #ff4466';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize MemPalace
|
|
||||||
const mempalace = {
|
const mempalace = {
|
||||||
status: { compression: 0, docs: 0, aak: '0B' },
|
|
||||||
mineChat: () => {
|
mineChat: () => {
|
||||||
try {
|
try {
|
||||||
const messages = Array.from(document.querySelectorAll('.chat-msg')).map(m => m.innerText);
|
const messages = Array.from(document.querySelectorAll('.chat-msg')).map(m => m.innerText);
|
||||||
|
|||||||
Reference in New Issue
Block a user