Vanha frontend siirretty temp/. Uusi rakenne: - StatusBar.astro, Terminal.astro, Editor.astro, Guide.astro - global.css erillinen - Wasm pääsäikeessä (ei Worker — yksinkertainen, debugattava) - Tab-completion, dropdown, projektikortti, Monaco, GUIDE.md - Ei tokenisointia eikä koodilaboratoriota Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
// Kipinä WASM Worker (ES module) — ajaa kielimallin inferenssin erillisessä säikeessä
|
|
import init, { start_agent_node, set_gpu_load, set_auto_tasks } from './pkg/node.js';
|
|
|
|
let wasmReady = false;
|
|
|
|
// Välitetään console.log -viestit pääsäikeelle jotta UI-kuuntelijat näkevät ne
|
|
const _origLog = console.log;
|
|
console.log = function(...args) {
|
|
_origLog.apply(console, args);
|
|
self.postMessage({ type: 'log', message: args.join(' ') });
|
|
};
|
|
|
|
self.onmessage = async (e) => {
|
|
const { type, data } = e.data;
|
|
|
|
if (type === 'init') {
|
|
try {
|
|
await init();
|
|
wasmReady = true;
|
|
self.postMessage({ type: 'ready' });
|
|
} catch (err) {
|
|
self.postMessage({ type: 'error', message: 'WASM init: ' + err.message });
|
|
}
|
|
} else if (type === 'start') {
|
|
if (!wasmReady) return;
|
|
const { hubUrl, hasWebGPU, deviceInfo, taskId } = data;
|
|
try {
|
|
await start_agent_node(hubUrl, hasWebGPU, deviceInfo, taskId);
|
|
self.postMessage({ type: 'started' });
|
|
} catch (err) {
|
|
self.postMessage({ type: 'error', message: 'Node: ' + err.message });
|
|
}
|
|
} else if (type === 'set_gpu_load') {
|
|
if (wasmReady) set_gpu_load(data.load);
|
|
} else if (type === 'set_auto_tasks') {
|
|
if (wasmReady) set_auto_tasks(data.enabled);
|
|
}
|
|
};
|