Spaces:
Running
Running
Update index.html
Browse files- index.html +190 -69
index.html
CHANGED
|
@@ -3,30 +3,24 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>β‘ Chronos V3 β
|
| 7 |
-
|
| 8 |
|
| 9 |
<!-- βββ EXTERNAL LIBRARIES βββ -->
|
| 10 |
-
<!-- 1. Load WebLLM as a module
|
| 11 |
<script type="module">
|
| 12 |
-
import * as webllm from "https://cdn.jsdelivr.net/npm/@mlc-ai/web-llm@0.2.
|
| 13 |
window.webllm = webllm;
|
| 14 |
</script>
|
| 15 |
|
| 16 |
-
<!-- 2. Other libraries
|
| 17 |
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
|
| 18 |
<script src="https://cdn.jsdelivr.net/npm/d3@7/dist/d3.min.js"></script>
|
| 19 |
<script src="https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.js"></script>
|
| 20 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
|
| 21 |
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
| 22 |
-
|
| 23 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 24 |
<link href="https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&family=VT323&display=swap" rel="stylesheet">
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
<style>
|
| 31 |
:root{--bg:#080b08;--bg2:#0c100c;--bg3:#111611;--bg4:#161e16;--fg:#3dff70;--fg-dim:#1c8038;--fg-faint:#0b2e16;--amber:#ffbb33;--cyan:#33f0ff;--red:#ff3355;--border:#1a2e1a;--glow:0 0 8px #3dff7066,0 0 24px #3dff7022;--scan:repeating-linear-gradient(0deg,transparent,transparent 2px,rgba(0,0,0,.15) 2px,rgba(0,0,0,.15) 4px)}
|
| 32 |
*{box-sizing:border-box;margin:0;padding:0}
|
|
@@ -196,7 +190,7 @@ canvas#spark{width:100%;height:28px;display:block}
|
|
| 196 |
<h1>β SERVE VIA HTTP REQUIRED</h1>
|
| 197 |
<div class="bd">
|
| 198 |
WebLLM needs <code>SharedArrayBuffer</code>. Serve via:<br>
|
| 199 |
-
<div class="cmd-row" onclick="navigator.clipboard?.writeText('python
|
| 200 |
Then open: <code>http://127.0.0.1:8080/htmlClaw_V3.html</code>
|
| 201 |
</div>
|
| 202 |
<button class="sbtn-main" onclick="document.getElementById('setup-banner').classList.add('hidden')">DISMISS β</button>
|
|
@@ -205,7 +199,7 @@ canvas#spark{width:100%;height:28px;display:block}
|
|
| 205 |
|
| 206 |
<div id="app">
|
| 207 |
<header id="hdr">
|
| 208 |
-
<div class="logo">β‘ CHRONOS <span style="color:var(--fg-dim);font-size:9px">V3 Β·
|
| 209 |
<div class="hpills">
|
| 210 |
<span class="hpill"><span class="dot" id="mdot"></span><span id="mstatus">NO MODEL</span></span>
|
| 211 |
<span class="hpill" id="tools-pill">TOOLS: 0</span>
|
|
@@ -217,9 +211,8 @@ canvas#spark{width:100%;height:28px;display:block}
|
|
| 217 |
<div class="stitle">β Model</div>
|
| 218 |
<div class="sbody">
|
| 219 |
<select class="ctrl" id="msel">
|
| 220 |
-
<option value="
|
| 221 |
-
<option value="
|
| 222 |
-
|
| 223 |
<option value="Llama-3.2-3B-Instruct-q4f16_1-MLC">Llama 3.2 Β· 3B</option>
|
| 224 |
<option value="Phi-3.5-mini-instruct-q4f16_1-MLC">Phi-3.5 Β· 3.8B</option>
|
| 225 |
<option value="Llama-3.1-8B-Instruct-q4f16_1-MLC">Llama 3.1 Β· 8B</option>
|
|
@@ -237,6 +230,13 @@ canvas#spark{width:100%;height:28px;display:block}
|
|
| 237 |
<div class="frow"><span class="fname" id="user-n">user.md</span><span class="fbadge" id="user-b">default</span><button class="bxs" onclick="MemoryModule.trigger('user')">LOAD</button><button class="bxs" onclick="openEdit('user')">EDIT</button><input type="file" id="user-f" accept=".md,.txt"></div>
|
| 238 |
</div>
|
| 239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
<div class="stitle">β‘ Skills</div>
|
| 241 |
<div class="sbody">
|
| 242 |
<div class="frow" style="justify-content:space-between"><span style="font-size:10px;color:var(--fg-dim)">Dynamic injection</span><button class="bxs" onclick="MemoryModule.trigger('skill')">+ SKILL</button><input type="file" id="skill-f" accept=".md,.txt" multiple></div>
|
|
@@ -253,7 +253,7 @@ canvas#spark{width:100%;height:28px;display:block}
|
|
| 253 |
</div>
|
| 254 |
<input id="rag-query" placeholder="Search query...">
|
| 255 |
<div class="rag-btn-row">
|
| 256 |
-
<button class="bxs" onclick="RAGModule.
|
| 257 |
<button class="bxs" onclick="RAGModule.inject()">β PROMPT</button>
|
| 258 |
</div>
|
| 259 |
<div id="rag-results"></div>
|
|
@@ -339,7 +339,7 @@ const store = new Store({
|
|
| 339 |
isGenerating: false,
|
| 340 |
toolsUsed: 0,
|
| 341 |
messages: [],
|
| 342 |
-
mem: { soul: 'You are Chronos, a cyberpunk AI agent.', user: '', skills: {} },
|
| 343 |
graph: { nodes: [], links: [] },
|
| 344 |
tpsHist: []
|
| 345 |
});
|
|
@@ -363,6 +363,10 @@ class ToolRegistry {
|
|
| 363 |
this.tools.set(name, { name, description: desc, schema, execute: fn });
|
| 364 |
bus.emit('tool:registered', name);
|
| 365 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
async run(name, args) {
|
| 367 |
const t = this.tools.get(name);
|
| 368 |
if (!t) throw new Error(`Tool '${name}' not found`);
|
|
@@ -380,6 +384,9 @@ const tools = new ToolRegistry();
|
|
| 380 |
bus.on('tool:registered', () => {
|
| 381 |
document.getElementById('tools-pill').textContent = `TOOLS: ${tools.getNames().length}`;
|
| 382 |
});
|
|
|
|
|
|
|
|
|
|
| 383 |
|
| 384 |
const UI = {
|
| 385 |
appendMessage(role, text) {
|
|
@@ -450,6 +457,58 @@ function log(text, type = '') {
|
|
| 450 |
el.appendChild(d); el.scrollTop = el.scrollHeight;
|
| 451 |
}
|
| 452 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 453 |
|
| 454 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 455 |
// MODULE: MEMORY (soul.md, user.md, skills)
|
|
@@ -513,7 +572,6 @@ const MemoryModule = {
|
|
| 513 |
}
|
| 514 |
};
|
| 515 |
|
| 516 |
-
|
| 517 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 518 |
// MODULE: RAG (Retrieval-Augmented Generation)
|
| 519 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -523,12 +581,15 @@ const RAGModule = {
|
|
| 523 |
this.index = JSON.parse(localStorage.getItem('chronos_rag') || '[]');
|
| 524 |
this.updateStats();
|
| 525 |
},
|
| 526 |
-
|
|
|
|
|
|
|
| 527 |
const sentences = text.split(/[.!?]\s+/).filter(s => s.trim().length > 20);
|
| 528 |
sentences.forEach(s => this.index.push(s.trim()));
|
| 529 |
localStorage.setItem('chronos_rag', JSON.stringify(this.index));
|
| 530 |
this.updateStats();
|
| 531 |
-
|
|
|
|
| 532 |
},
|
| 533 |
search(query, topK = 5) {
|
| 534 |
const terms = query.toLowerCase().split(/\s+/);
|
|
@@ -562,11 +623,6 @@ const RAGModule = {
|
|
| 562 |
document.getElementById('uin').value = prompt;
|
| 563 |
}
|
| 564 |
};
|
| 565 |
-
window.RAGModule = RAGModule;
|
| 566 |
-
document.getElementById('rag-query')?.addEventListener('keydown', e => {
|
| 567 |
-
if (e.key === 'Enter') RAGModule.searchUI();
|
| 568 |
-
});
|
| 569 |
-
|
| 570 |
|
| 571 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 572 |
// MODULE: COMMAND PALETTE
|
|
@@ -582,9 +638,7 @@ const CommandPaletteModule = {
|
|
| 582 |
if (e.key === 'Escape') this.close();
|
| 583 |
});
|
| 584 |
},
|
| 585 |
-
toggle() {
|
| 586 |
-
this.open ? this.close() : this.show();
|
| 587 |
-
},
|
| 588 |
show() {
|
| 589 |
this.open = true;
|
| 590 |
document.getElementById('cmd-palette').classList.add('vis');
|
|
@@ -618,7 +672,6 @@ const CommandPaletteModule = {
|
|
| 618 |
};
|
| 619 |
document.getElementById('cp-search')?.addEventListener('input', e => CommandPaletteModule.render(e.target.value));
|
| 620 |
|
| 621 |
-
|
| 622 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 623 |
// MODULE: CONSOLE LOG POPUP
|
| 624 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -654,7 +707,6 @@ const ConsoleModule = {
|
|
| 654 |
}
|
| 655 |
};
|
| 656 |
|
| 657 |
-
|
| 658 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 659 |
// MODULE: SPEECH I/O
|
| 660 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -666,10 +718,11 @@ const SpeechModule = {
|
|
| 666 |
btn.addEventListener('click', () => this.toggle());
|
| 667 |
if ('speechSynthesis' in window) {
|
| 668 |
bus.on('message:rendered', (container) => {
|
| 669 |
-
if (container.classList.contains('agent
|
| 670 |
const speakBtn = document.createElement('button');
|
| 671 |
speakBtn.className = 'bxs';
|
| 672 |
speakBtn.textContent = 'π';
|
|
|
|
| 673 |
speakBtn.onclick = () => speechSynthesis.speak(new SpeechSynthesisUtterance(container.textContent));
|
| 674 |
container.appendChild(speakBtn);
|
| 675 |
}
|
|
@@ -706,7 +759,6 @@ const SpeechModule = {
|
|
| 706 |
}
|
| 707 |
};
|
| 708 |
|
| 709 |
-
|
| 710 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 711 |
// MODULE: FILE SYSTEM ACCESS
|
| 712 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -739,7 +791,6 @@ const FileSystemModule = {
|
|
| 739 |
}
|
| 740 |
};
|
| 741 |
|
| 742 |
-
|
| 743 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 744 |
// MODULE: EXPORT
|
| 745 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -750,6 +801,7 @@ const ExportModule = {
|
|
| 750 |
memory: store.state.mem,
|
| 751 |
graph: store.state.graph,
|
| 752 |
rag: RAGModule.index,
|
|
|
|
| 753 |
messages: store.state.messages,
|
| 754 |
settings: {
|
| 755 |
model: document.getElementById('msel').value,
|
|
@@ -766,7 +818,6 @@ const ExportModule = {
|
|
| 766 |
}
|
| 767 |
};
|
| 768 |
|
| 769 |
-
|
| 770 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 771 |
// MODULE: CONTEXT MANAGER (auto-summarize)
|
| 772 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -781,36 +832,82 @@ const ContextManager = {
|
|
| 781 |
document.getElementById('s-ctx').textContent = pct + '%';
|
| 782 |
},
|
| 783 |
async compact() {
|
| 784 |
-
if (store.state.messages.length < 10) return;
|
| 785 |
const old = store.state.messages.slice(0, -5);
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 802 |
}
|
| 803 |
};
|
| 804 |
|
| 805 |
-
|
| 806 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 807 |
-
// TOOLS IMPLEMENTATION
|
| 808 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 809 |
tools.register('web_search', 'Search web via Brave API', { query: 'string' }, async (args) => {
|
| 810 |
const apiKey = localStorage.getItem('chronos_brave_key') || '';
|
| 811 |
-
if (!apiKey) return 'ERROR: No Brave API key.';
|
| 812 |
try {
|
| 813 |
-
const url = `
|
| 814 |
const res = await fetch(url, { headers: { 'X-Subscription-Token': apiKey, 'Accept': 'application/json' } });
|
| 815 |
if (!res.ok) return `Search failed: ${res.status}`;
|
| 816 |
const data = await res.json();
|
|
@@ -830,6 +927,7 @@ tools.register('run_code', 'Execute JavaScript', { code: 'string' }, async (args
|
|
| 830 |
|
| 831 |
tools.register('run_python', 'Execute Python via Pyodide', { code: 'string' }, async (args) => {
|
| 832 |
if (!window.pyodide) {
|
|
|
|
| 833 |
window.pyodide = await loadPyodide();
|
| 834 |
}
|
| 835 |
try {
|
|
@@ -899,7 +997,6 @@ tools.register('rag_search', 'Search local RAG index', { query: 'string' }, asyn
|
|
| 899 |
return results.map((r, i) => `${i + 1}. ${r.text}`).join('\n\n') || 'No RAG results.';
|
| 900 |
});
|
| 901 |
|
| 902 |
-
|
| 903 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 904 |
// MERMAID RENDERER
|
| 905 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -931,7 +1028,6 @@ bus.on('message:rendered', async (container) => {
|
|
| 931 |
}
|
| 932 |
});
|
| 933 |
|
| 934 |
-
|
| 935 |
// ββββββββββββββββββββββββββββββββοΏ½οΏ½ββββββββββββββββββββββββββ
|
| 936 |
// D3 KNOWLEDGE GRAPH
|
| 937 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -962,7 +1058,6 @@ bus.on('graph:updated', () => {
|
|
| 962 |
});
|
| 963 |
});
|
| 964 |
|
| 965 |
-
|
| 966 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 967 |
// EASYMDE MODAL
|
| 968 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -992,9 +1087,8 @@ window.saveModal = function() {
|
|
| 992 |
closeModal();
|
| 993 |
};
|
| 994 |
|
| 995 |
-
|
| 996 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 997 |
-
// CORE AGENT LOOP
|
| 998 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 999 |
let engine;
|
| 1000 |
|
|
@@ -1005,11 +1099,30 @@ async function loadModel() {
|
|
| 1005 |
log(`loading ${id}`, 'w');
|
| 1006 |
|
| 1007 |
try {
|
| 1008 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1009 |
engine = await window.webllm.CreateMLCEngine(id, {
|
| 1010 |
-
appConfig:
|
| 1011 |
initProgressCallback: (report) => {
|
| 1012 |
-
// Updates the UI with download percentage
|
| 1013 |
const pct = Math.round((report.progress || 0) * 100);
|
| 1014 |
document.getElementById('mstatus').textContent = `LOADING ${pct}%`;
|
| 1015 |
if (report.text) log(report.text, '');
|
|
@@ -1026,6 +1139,15 @@ async function loadModel() {
|
|
| 1026 |
UI.appendMessage('agent', `**${id}** loaded.\n\nTools: ${tools.getNames().join(', ')}\n\nTry: "Search for AI news", "Extract facts: Chris likes cyberpunk", or drop an image.`);
|
| 1027 |
} catch (e) {
|
| 1028 |
log(`β load failed: ${e.message}`, 'e');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1029 |
document.getElementById('mstatus').textContent = 'ERROR';
|
| 1030 |
document.getElementById('lbtn').disabled = false;
|
| 1031 |
}
|
|
@@ -1129,7 +1251,6 @@ function drawSpark() {
|
|
| 1129 |
ctx.stroke();
|
| 1130 |
}
|
| 1131 |
|
| 1132 |
-
|
| 1133 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1134 |
// WIRING
|
| 1135 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1143,7 +1264,6 @@ document.getElementById('uin').addEventListener('keydown', e => {
|
|
| 1143 |
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); document.getElementById('sbtn').click(); }
|
| 1144 |
});
|
| 1145 |
|
| 1146 |
-
// Drag-drop images
|
| 1147 |
const msgsEl = document.getElementById('msgs');
|
| 1148 |
msgsEl.addEventListener('dragover', e => { e.preventDefault(); msgsEl.classList.add('dragover'); });
|
| 1149 |
msgsEl.addEventListener('dragleave', () => msgsEl.classList.remove('dragover'));
|
|
@@ -1164,6 +1284,7 @@ msgsEl.addEventListener('drop', async e => {
|
|
| 1164 |
|
| 1165 |
// Init all modules
|
| 1166 |
MemoryModule.init();
|
|
|
|
| 1167 |
RAGModule.init();
|
| 1168 |
CommandPaletteModule.init();
|
| 1169 |
ConsoleModule.init();
|
|
@@ -1175,14 +1296,14 @@ if (window.crossOriginIsolated) {
|
|
| 1175 |
setTimeout(() => { if (!window.crossOriginIsolated) document.getElementById('setup-banner').classList.remove('hidden'); }, 500);
|
| 1176 |
}
|
| 1177 |
document.getElementById('brave-in').value = localStorage.getItem('chronos_brave_key') || '';
|
| 1178 |
-
log('Chronos V3 initialized', 'g');
|
| 1179 |
log(`Tools: ${tools.getNames().join(', ')}`, '');
|
| 1180 |
|
| 1181 |
-
|
| 1182 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1183 |
// EXPOSE TO GLOBAL SCOPE (Required for inline HTML onclicks)
|
| 1184 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1185 |
window.MemoryModule = MemoryModule;
|
|
|
|
| 1186 |
window.RAGModule = RAGModule;
|
| 1187 |
window.CommandPaletteModule = CommandPaletteModule;
|
| 1188 |
window.ConsoleModule = ConsoleModule;
|
|
@@ -1194,7 +1315,7 @@ window.openEdit = openEdit;
|
|
| 1194 |
window.closeModal = closeModal;
|
| 1195 |
window.saveModal = saveModal;
|
| 1196 |
window.log = log;
|
| 1197 |
-
window.store = store;
|
| 1198 |
</script>
|
| 1199 |
</body>
|
| 1200 |
-
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>β‘ Chronos V3 β Level 5 Self-Improving</title>
|
|
|
|
| 7 |
|
| 8 |
<!-- βββ EXTERNAL LIBRARIES βββ -->
|
| 9 |
+
<!-- 1. Load WebLLM 0.2.84 as a module (Required for OpenBMB compatibility) -->
|
| 10 |
<script type="module">
|
| 11 |
+
import * as webllm from "https://cdn.jsdelivr.net/npm/@mlc-ai/web-llm@0.2.84/lib/index.js";
|
| 12 |
window.webllm = webllm;
|
| 13 |
</script>
|
| 14 |
|
| 15 |
+
<!-- 2. Other libraries -->
|
| 16 |
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
|
| 17 |
<script src="https://cdn.jsdelivr.net/npm/d3@7/dist/d3.min.js"></script>
|
| 18 |
<script src="https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.js"></script>
|
| 19 |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
|
| 20 |
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
|
|
|
| 21 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 22 |
<link href="https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&family=VT323&display=swap" rel="stylesheet">
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
<style>
|
| 25 |
:root{--bg:#080b08;--bg2:#0c100c;--bg3:#111611;--bg4:#161e16;--fg:#3dff70;--fg-dim:#1c8038;--fg-faint:#0b2e16;--amber:#ffbb33;--cyan:#33f0ff;--red:#ff3355;--border:#1a2e1a;--glow:0 0 8px #3dff7066,0 0 24px #3dff7022;--scan:repeating-linear-gradient(0deg,transparent,transparent 2px,rgba(0,0,0,.15) 2px,rgba(0,0,0,.15) 4px)}
|
| 26 |
*{box-sizing:border-box;margin:0;padding:0}
|
|
|
|
| 190 |
<h1>β SERVE VIA HTTP REQUIRED</h1>
|
| 191 |
<div class="bd">
|
| 192 |
WebLLM needs <code>SharedArrayBuffer</code>. Serve via:<br>
|
| 193 |
+
<div class="cmd-row" onclick="navigator.clipboard?.writeText('python -m http.server 8080')"><span>python -m http.server 8080</span><span style="color:var(--fg-dim)">click to copy</span></div>
|
| 194 |
Then open: <code>http://127.0.0.1:8080/htmlClaw_V3.html</code>
|
| 195 |
</div>
|
| 196 |
<button class="sbtn-main" onclick="document.getElementById('setup-banner').classList.add('hidden')">DISMISS β</button>
|
|
|
|
| 199 |
|
| 200 |
<div id="app">
|
| 201 |
<header id="hdr">
|
| 202 |
+
<div class="logo">β‘ CHRONOS <span style="color:var(--fg-dim);font-size:9px">V3 Β· LEVEL 5</span></div>
|
| 203 |
<div class="hpills">
|
| 204 |
<span class="hpill"><span class="dot" id="mdot"></span><span id="mstatus">NO MODEL</span></span>
|
| 205 |
<span class="hpill" id="tools-pill">TOOLS: 0</span>
|
|
|
|
| 211 |
<div class="stitle">β Model</div>
|
| 212 |
<div class="sbody">
|
| 213 |
<select class="ctrl" id="msel">
|
| 214 |
+
<option value="Llama-3.2-1B-Instruct-q4f16_1-MLC">Llama 3.2 Β· 1B (fastest)</option>
|
| 215 |
+
<option value="MiniCPM5-2B-q4f16_1-MLC">MiniCPM5-2B (OpenBMB)</option>
|
|
|
|
| 216 |
<option value="Llama-3.2-3B-Instruct-q4f16_1-MLC">Llama 3.2 Β· 3B</option>
|
| 217 |
<option value="Phi-3.5-mini-instruct-q4f16_1-MLC">Phi-3.5 Β· 3.8B</option>
|
| 218 |
<option value="Llama-3.1-8B-Instruct-q4f16_1-MLC">Llama 3.1 Β· 8B</option>
|
|
|
|
| 230 |
<div class="frow"><span class="fname" id="user-n">user.md</span><span class="fbadge" id="user-b">default</span><button class="bxs" onclick="MemoryModule.trigger('user')">LOAD</button><button class="bxs" onclick="openEdit('user')">EDIT</button><input type="file" id="user-f" accept=".md,.txt"></div>
|
| 231 |
</div>
|
| 232 |
|
| 233 |
+
<div class="stitle">𧬠ToolForge (Self-Learned)</div>
|
| 234 |
+
<div class="sbody">
|
| 235 |
+
<div class="meta" style="margin-bottom:6px">Agent-created tools persist across reloads.</div>
|
| 236 |
+
<div class="chips" id="toolforg-chips"></div>
|
| 237 |
+
<button class="bxs" onclick="ToolForgeModule.clearCustomTools()" style="margin-top:6px; color:var(--red)">CLEAR ALL</button>
|
| 238 |
+
</div>
|
| 239 |
+
|
| 240 |
<div class="stitle">β‘ Skills</div>
|
| 241 |
<div class="sbody">
|
| 242 |
<div class="frow" style="justify-content:space-between"><span style="font-size:10px;color:var(--fg-dim)">Dynamic injection</span><button class="bxs" onclick="MemoryModule.trigger('skill')">+ SKILL</button><input type="file" id="skill-f" accept=".md,.txt" multiple></div>
|
|
|
|
| 253 |
</div>
|
| 254 |
<input id="rag-query" placeholder="Search query...">
|
| 255 |
<div class="rag-btn-row">
|
| 256 |
+
<button class="bxs" onclick="RAGModule.searchUI()">SEARCH</button>
|
| 257 |
<button class="bxs" onclick="RAGModule.inject()">β PROMPT</button>
|
| 258 |
</div>
|
| 259 |
<div id="rag-results"></div>
|
|
|
|
| 339 |
isGenerating: false,
|
| 340 |
toolsUsed: 0,
|
| 341 |
messages: [],
|
| 342 |
+
mem: { soul: 'You are Chronos, a cyberpunk AI agent capable of self-improvement. You can create new tools for yourself using the create_tool meta-tool.', user: '', skills: {} },
|
| 343 |
graph: { nodes: [], links: [] },
|
| 344 |
tpsHist: []
|
| 345 |
});
|
|
|
|
| 363 |
this.tools.set(name, { name, description: desc, schema, execute: fn });
|
| 364 |
bus.emit('tool:registered', name);
|
| 365 |
}
|
| 366 |
+
unregister(name) {
|
| 367 |
+
this.tools.delete(name);
|
| 368 |
+
bus.emit('tool:unregistered', name);
|
| 369 |
+
}
|
| 370 |
async run(name, args) {
|
| 371 |
const t = this.tools.get(name);
|
| 372 |
if (!t) throw new Error(`Tool '${name}' not found`);
|
|
|
|
| 384 |
bus.on('tool:registered', () => {
|
| 385 |
document.getElementById('tools-pill').textContent = `TOOLS: ${tools.getNames().length}`;
|
| 386 |
});
|
| 387 |
+
bus.on('tool:unregistered', () => {
|
| 388 |
+
document.getElementById('tools-pill').textContent = `TOOLS: ${tools.getNames().length}`;
|
| 389 |
+
});
|
| 390 |
|
| 391 |
const UI = {
|
| 392 |
appendMessage(role, text) {
|
|
|
|
| 457 |
el.appendChild(d); el.scrollTop = el.scrollHeight;
|
| 458 |
}
|
| 459 |
|
| 460 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 461 |
+
// MODULE: TOOLFORGE (LEVEL 5: SELF-IMPROVING AGENT)
|
| 462 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 463 |
+
const ToolForgeModule = {
|
| 464 |
+
init() {
|
| 465 |
+
this.loadCustomTools();
|
| 466 |
+
this.refreshUI();
|
| 467 |
+
},
|
| 468 |
+
loadCustomTools() {
|
| 469 |
+
const customTools = JSON.parse(localStorage.getItem('chronos_custom_tools') || '{}');
|
| 470 |
+
for (const [name, data] of Object.entries(customTools)) {
|
| 471 |
+
try {
|
| 472 |
+
// Sandboxed execution: function takes 'args' and returns a string/Promise
|
| 473 |
+
const toolFn = new Function('args', `return (async () => { ${data.code} })();`);
|
| 474 |
+
tools.register(name, data.description, data.schema, toolFn);
|
| 475 |
+
} catch (e) {
|
| 476 |
+
console.error(`Failed to load custom tool ${name}:`, e);
|
| 477 |
+
}
|
| 478 |
+
}
|
| 479 |
+
},
|
| 480 |
+
refreshUI() {
|
| 481 |
+
const customTools = JSON.parse(localStorage.getItem('chronos_custom_tools') || '{}');
|
| 482 |
+
const chips = document.getElementById('toolforg-chips');
|
| 483 |
+
chips.innerHTML = '';
|
| 484 |
+
if (Object.keys(customTools).length === 0) {
|
| 485 |
+
chips.innerHTML = '<span style="font-size:9px;color:var(--fg-dim)">No custom tools yet. Ask the agent to create one!</span>';
|
| 486 |
+
return;
|
| 487 |
+
}
|
| 488 |
+
Object.keys(customTools).forEach(name => {
|
| 489 |
+
const c = document.createElement('div');
|
| 490 |
+
c.className = 'chip';
|
| 491 |
+
c.innerHTML = `${name} <span class="rm" onclick="ToolForgeModule.removeTool('${name}')">β</span>`;
|
| 492 |
+
chips.appendChild(c);
|
| 493 |
+
});
|
| 494 |
+
},
|
| 495 |
+
removeTool(name) {
|
| 496 |
+
const customTools = JSON.parse(localStorage.getItem('chronos_custom_tools') || '{}');
|
| 497 |
+
delete customTools[name];
|
| 498 |
+
localStorage.setItem('chronos_custom_tools', JSON.stringify(customTools));
|
| 499 |
+
tools.unregister(name);
|
| 500 |
+
this.refreshUI();
|
| 501 |
+
log(`Removed custom tool: ${name}`, 'w');
|
| 502 |
+
},
|
| 503 |
+
clearCustomTools() {
|
| 504 |
+
if(!confirm("Delete all self-learned tools?")) return;
|
| 505 |
+
localStorage.setItem('chronos_custom_tools', '{}');
|
| 506 |
+
// Clear from registry
|
| 507 |
+
const customTools = JSON.parse(localStorage.getItem('chronos_custom_tools') || '{}'); // now empty
|
| 508 |
+
// We just reload the page to cleanly reset the registry
|
| 509 |
+
location.reload();
|
| 510 |
+
}
|
| 511 |
+
};
|
| 512 |
|
| 513 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 514 |
// MODULE: MEMORY (soul.md, user.md, skills)
|
|
|
|
| 572 |
}
|
| 573 |
};
|
| 574 |
|
|
|
|
| 575 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 576 |
// MODULE: RAG (Retrieval-Augmented Generation)
|
| 577 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 581 |
this.index = JSON.parse(localStorage.getItem('chronos_rag') || '[]');
|
| 582 |
this.updateStats();
|
| 583 |
},
|
| 584 |
+
index() {
|
| 585 |
+
const text = document.getElementById('rag-text').value;
|
| 586 |
+
if (!text) return;
|
| 587 |
const sentences = text.split(/[.!?]\s+/).filter(s => s.trim().length > 20);
|
| 588 |
sentences.forEach(s => this.index.push(s.trim()));
|
| 589 |
localStorage.setItem('chronos_rag', JSON.stringify(this.index));
|
| 590 |
this.updateStats();
|
| 591 |
+
log(`β Indexed ${sentences.length} sentences`, 'g');
|
| 592 |
+
document.getElementById('rag-text').value = '';
|
| 593 |
},
|
| 594 |
search(query, topK = 5) {
|
| 595 |
const terms = query.toLowerCase().split(/\s+/);
|
|
|
|
| 623 |
document.getElementById('uin').value = prompt;
|
| 624 |
}
|
| 625 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 626 |
|
| 627 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 628 |
// MODULE: COMMAND PALETTE
|
|
|
|
| 638 |
if (e.key === 'Escape') this.close();
|
| 639 |
});
|
| 640 |
},
|
| 641 |
+
toggle() { this.open ? this.close() : this.show(); },
|
|
|
|
|
|
|
| 642 |
show() {
|
| 643 |
this.open = true;
|
| 644 |
document.getElementById('cmd-palette').classList.add('vis');
|
|
|
|
| 672 |
};
|
| 673 |
document.getElementById('cp-search')?.addEventListener('input', e => CommandPaletteModule.render(e.target.value));
|
| 674 |
|
|
|
|
| 675 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 676 |
// MODULE: CONSOLE LOG POPUP
|
| 677 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 707 |
}
|
| 708 |
};
|
| 709 |
|
|
|
|
| 710 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 711 |
// MODULE: SPEECH I/O
|
| 712 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 718 |
btn.addEventListener('click', () => this.toggle());
|
| 719 |
if ('speechSynthesis' in window) {
|
| 720 |
bus.on('message:rendered', (container) => {
|
| 721 |
+
if (container.parentElement.classList.contains('agent')) {
|
| 722 |
const speakBtn = document.createElement('button');
|
| 723 |
speakBtn.className = 'bxs';
|
| 724 |
speakBtn.textContent = 'π';
|
| 725 |
+
speakBtn.style.marginLeft = '8px';
|
| 726 |
speakBtn.onclick = () => speechSynthesis.speak(new SpeechSynthesisUtterance(container.textContent));
|
| 727 |
container.appendChild(speakBtn);
|
| 728 |
}
|
|
|
|
| 759 |
}
|
| 760 |
};
|
| 761 |
|
|
|
|
| 762 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 763 |
// MODULE: FILE SYSTEM ACCESS
|
| 764 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 791 |
}
|
| 792 |
};
|
| 793 |
|
|
|
|
| 794 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 795 |
// MODULE: EXPORT
|
| 796 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 801 |
memory: store.state.mem,
|
| 802 |
graph: store.state.graph,
|
| 803 |
rag: RAGModule.index,
|
| 804 |
+
customTools: JSON.parse(localStorage.getItem('chronos_custom_tools') || '{}'),
|
| 805 |
messages: store.state.messages,
|
| 806 |
settings: {
|
| 807 |
model: document.getElementById('msel').value,
|
|
|
|
| 818 |
}
|
| 819 |
};
|
| 820 |
|
|
|
|
| 821 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 822 |
// MODULE: CONTEXT MANAGER (auto-summarize)
|
| 823 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 832 |
document.getElementById('s-ctx').textContent = pct + '%';
|
| 833 |
},
|
| 834 |
async compact() {
|
| 835 |
+
if (store.state.messages.length < 10 || !engine) return;
|
| 836 |
const old = store.state.messages.slice(0, -5);
|
| 837 |
+
try {
|
| 838 |
+
const summary = await engine.chat.completions.create({
|
| 839 |
+
messages: [
|
| 840 |
+
{ role: 'system', content: 'Summarize this conversation in 2-3 sentences.' },
|
| 841 |
+
{ role: 'user', content: old.map(m => `${m.role}: ${m.content}`).join('\n') }
|
| 842 |
+
],
|
| 843 |
+
max_tokens: 150
|
| 844 |
+
});
|
| 845 |
+
const summaryText = summary.choices[0].message.content;
|
| 846 |
+
store.set({
|
| 847 |
+
messages: [
|
| 848 |
+
{ role: 'system', content: `Previous conversation summary: ${summaryText}` },
|
| 849 |
+
...store.state.messages.slice(-5)
|
| 850 |
+
]
|
| 851 |
+
});
|
| 852 |
+
log('π Context auto-summarized', 'w');
|
| 853 |
+
UI.showToast('Context compacted');
|
| 854 |
+
} catch(e) {
|
| 855 |
+
log('Context compaction failed', 'e');
|
| 856 |
+
}
|
| 857 |
}
|
| 858 |
};
|
| 859 |
|
|
|
|
| 860 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 861 |
+
// TOOLS IMPLEMENTATION (Including Level 5 Meta-Tool)
|
| 862 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 863 |
+
|
| 864 |
+
// LEVEL 5: SELF-IMPROVING META-TOOL
|
| 865 |
+
tools.register('create_tool', 'Create and register a new JavaScript tool at runtime. Use this when you need a new capability not covered by existing tools.', {
|
| 866 |
+
name: 'string (alphanumeric and underscores only)',
|
| 867 |
+
description: 'string (clear description of what the tool does)',
|
| 868 |
+
schema: 'string (JSON string of the arguments schema, e.g., {"query": "string"})',
|
| 869 |
+
code: 'string (JavaScript code for the tool. Must be an async function body that takes "args" as a parameter and returns a string or Promise<string>)'
|
| 870 |
+
}, async (args) => {
|
| 871 |
+
try {
|
| 872 |
+
if (!/^[a-zA-Z0-9_]+$/.test(args.name)) {
|
| 873 |
+
return "ERROR: Tool name must be alphanumeric and underscores only.";
|
| 874 |
+
}
|
| 875 |
+
if (tools.tools.has(args.name)) {
|
| 876 |
+
return `ERROR: Tool '${args.name}' already exists.`;
|
| 877 |
+
}
|
| 878 |
+
|
| 879 |
+
let parsedSchema;
|
| 880 |
+
try {
|
| 881 |
+
parsedSchema = JSON.parse(args.schema);
|
| 882 |
+
} catch (e) {
|
| 883 |
+
return `ERROR: Invalid JSON schema. ${e.message}`;
|
| 884 |
+
}
|
| 885 |
+
|
| 886 |
+
// Sandboxed execution: function takes 'args' and returns a string/Promise
|
| 887 |
+
const toolFn = new Function('args', `return (async () => { ${args.code} })();`);
|
| 888 |
+
|
| 889 |
+
tools.register(args.name, args.description, parsedSchema, toolFn);
|
| 890 |
+
|
| 891 |
+
const customTools = JSON.parse(localStorage.getItem('chronos_custom_tools') || '{}');
|
| 892 |
+
customTools[args.name] = {
|
| 893 |
+
description: args.description,
|
| 894 |
+
schema: parsedSchema,
|
| 895 |
+
code: args.code
|
| 896 |
+
};
|
| 897 |
+
localStorage.setItem('chronos_custom_tools', JSON.stringify(customTools));
|
| 898 |
+
|
| 899 |
+
ToolForgeModule.refreshUI();
|
| 900 |
+
return `SUCCESS: Tool '${args.name}' created, registered, and saved to memory. You can now use it.`;
|
| 901 |
+
} catch (e) {
|
| 902 |
+
return `ERROR creating tool: ${e.message}`;
|
| 903 |
+
}
|
| 904 |
+
});
|
| 905 |
+
|
| 906 |
tools.register('web_search', 'Search web via Brave API', { query: 'string' }, async (args) => {
|
| 907 |
const apiKey = localStorage.getItem('chronos_brave_key') || '';
|
| 908 |
+
if (!apiKey) return 'ERROR: No Brave API key set in sidebar.';
|
| 909 |
try {
|
| 910 |
+
const url = `https://api.search.brave.com/res/v1/web/search?q=${encodeURIComponent(args.query)}&count=5`;
|
| 911 |
const res = await fetch(url, { headers: { 'X-Subscription-Token': apiKey, 'Accept': 'application/json' } });
|
| 912 |
if (!res.ok) return `Search failed: ${res.status}`;
|
| 913 |
const data = await res.json();
|
|
|
|
| 927 |
|
| 928 |
tools.register('run_python', 'Execute Python via Pyodide', { code: 'string' }, async (args) => {
|
| 929 |
if (!window.pyodide) {
|
| 930 |
+
log('Loading Pyodide...', 'w');
|
| 931 |
window.pyodide = await loadPyodide();
|
| 932 |
}
|
| 933 |
try {
|
|
|
|
| 997 |
return results.map((r, i) => `${i + 1}. ${r.text}`).join('\n\n') || 'No RAG results.';
|
| 998 |
});
|
| 999 |
|
|
|
|
| 1000 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1001 |
// MERMAID RENDERER
|
| 1002 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 1028 |
}
|
| 1029 |
});
|
| 1030 |
|
|
|
|
| 1031 |
// ββββββββββββββββββββββββββββββββοΏ½οΏ½ββββββββββββββββββββββββββ
|
| 1032 |
// D3 KNOWLEDGE GRAPH
|
| 1033 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 1058 |
});
|
| 1059 |
});
|
| 1060 |
|
|
|
|
| 1061 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1062 |
// EASYMDE MODAL
|
| 1063 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 1087 |
closeModal();
|
| 1088 |
};
|
| 1089 |
|
|
|
|
| 1090 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1091 |
+
// CORE AGENT LOOP
|
| 1092 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1093 |
let engine;
|
| 1094 |
|
|
|
|
| 1099 |
log(`loading ${id}`, 'w');
|
| 1100 |
|
| 1101 |
try {
|
| 1102 |
+
// Start with the default prebuilt config
|
| 1103 |
+
let appConfig = window.webllm.prebuiltAppConfig || { model_list: [] };
|
| 1104 |
+
|
| 1105 |
+
// FIX: Inject custom appConfig for OpenBMB MiniCPM5-2B
|
| 1106 |
+
if (id === 'MiniCPM5-2B-q4f16_1-MLC') {
|
| 1107 |
+
appConfig = {
|
| 1108 |
+
model_list: [
|
| 1109 |
+
...appConfig.model_list,
|
| 1110 |
+
{
|
| 1111 |
+
model: "https://huggingface.co/ozhyhinas/MiniCPM5-2B-q4f16_1-MLC",
|
| 1112 |
+
model_id: "MiniCPM5-2B-q4f16_1-MLC",
|
| 1113 |
+
model_lib: "https://huggingface.co/ozhyhinas/MiniCPM5-2B-q4f16_1-MLC/resolve/main/libs/MiniCPM5-2B-q4f16_1-MLC-webgpu.wasm",
|
| 1114 |
+
vram_required_MB: 1900,
|
| 1115 |
+
low_resource_required: true,
|
| 1116 |
+
required_features: ["shader-f16"],
|
| 1117 |
+
overrides: { context_window_size: 4096 }
|
| 1118 |
+
}
|
| 1119 |
+
]
|
| 1120 |
+
};
|
| 1121 |
+
}
|
| 1122 |
+
|
| 1123 |
engine = await window.webllm.CreateMLCEngine(id, {
|
| 1124 |
+
appConfig: appConfig,
|
| 1125 |
initProgressCallback: (report) => {
|
|
|
|
| 1126 |
const pct = Math.round((report.progress || 0) * 100);
|
| 1127 |
document.getElementById('mstatus').textContent = `LOADING ${pct}%`;
|
| 1128 |
if (report.text) log(report.text, '');
|
|
|
|
| 1139 |
UI.appendMessage('agent', `**${id}** loaded.\n\nTools: ${tools.getNames().join(', ')}\n\nTry: "Search for AI news", "Extract facts: Chris likes cyberpunk", or drop an image.`);
|
| 1140 |
} catch (e) {
|
| 1141 |
log(`β load failed: ${e.message}`, 'e');
|
| 1142 |
+
|
| 1143 |
+
if (e.message.includes('compatible GPU') || e.message.includes('adapter') || e.message.includes('shader-f16') || e.message.includes('No available adapters')) {
|
| 1144 |
+
log('β οΈ Your GPU or browser may not support the required WebGPU features (like shader-f16) for this specific model.', 'w');
|
| 1145 |
+
log('π‘ Try a different model (e.g., Llama 3.2 1B) or check chrome://gpu for WebGPU status. Enable #ignore-gpu-blocklist in chrome://flags.', 'w');
|
| 1146 |
+
UI.showToast('WebGPU incompatible or missing required features');
|
| 1147 |
+
} else if (e.message.includes('No URL found')) {
|
| 1148 |
+
log('β οΈ Model ID not found in registry. Ensure you are using WebLLM 0.2.84+.', 'w');
|
| 1149 |
+
}
|
| 1150 |
+
|
| 1151 |
document.getElementById('mstatus').textContent = 'ERROR';
|
| 1152 |
document.getElementById('lbtn').disabled = false;
|
| 1153 |
}
|
|
|
|
| 1251 |
ctx.stroke();
|
| 1252 |
}
|
| 1253 |
|
|
|
|
| 1254 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1255 |
// WIRING
|
| 1256 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 1264 |
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); document.getElementById('sbtn').click(); }
|
| 1265 |
});
|
| 1266 |
|
|
|
|
| 1267 |
const msgsEl = document.getElementById('msgs');
|
| 1268 |
msgsEl.addEventListener('dragover', e => { e.preventDefault(); msgsEl.classList.add('dragover'); });
|
| 1269 |
msgsEl.addEventListener('dragleave', () => msgsEl.classList.remove('dragover'));
|
|
|
|
| 1284 |
|
| 1285 |
// Init all modules
|
| 1286 |
MemoryModule.init();
|
| 1287 |
+
ToolForgeModule.init(); // LEVEL 5 INIT
|
| 1288 |
RAGModule.init();
|
| 1289 |
CommandPaletteModule.init();
|
| 1290 |
ConsoleModule.init();
|
|
|
|
| 1296 |
setTimeout(() => { if (!window.crossOriginIsolated) document.getElementById('setup-banner').classList.remove('hidden'); }, 500);
|
| 1297 |
}
|
| 1298 |
document.getElementById('brave-in').value = localStorage.getItem('chronos_brave_key') || '';
|
| 1299 |
+
log('Chronos V3 Level 5 initialized', 'g');
|
| 1300 |
log(`Tools: ${tools.getNames().join(', ')}`, '');
|
| 1301 |
|
|
|
|
| 1302 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1303 |
// EXPOSE TO GLOBAL SCOPE (Required for inline HTML onclicks)
|
| 1304 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1305 |
window.MemoryModule = MemoryModule;
|
| 1306 |
+
window.ToolForgeModule = ToolForgeModule;
|
| 1307 |
window.RAGModule = RAGModule;
|
| 1308 |
window.CommandPaletteModule = CommandPaletteModule;
|
| 1309 |
window.ConsoleModule = ConsoleModule;
|
|
|
|
| 1315 |
window.closeModal = closeModal;
|
| 1316 |
window.saveModal = saveModal;
|
| 1317 |
window.log = log;
|
| 1318 |
+
window.store = store;
|
| 1319 |
</script>
|
| 1320 |
</body>
|
| 1321 |
+
</html>
|