Spaces:
Running
Running
| import { updateWorld } from "./world.js"; | |
| import { updateAgents, spawnAgent } from "./agents.js"; | |
| import { loadURL, scrapeDOM } from "./web.js"; | |
| import { llmIntent } from "./llm.js"; | |
| const log = document.getElementById("log"); | |
| const input = document.getElementById("input"); | |
| export let Psi = 0.5; | |
| export let sigma = 0.5; | |
| function print(m){ log.innerHTML += m+"<br/>"; log.scrollTop=log.scrollHeight; } | |
| function parseIntent(text){ | |
| if(text.startsWith("open")) return {type:"web", url:text.split(" ").pop()}; | |
| if(text.includes("spawn")) return {type:"agent"}; | |
| if(text.includes("brighter")) return {type:"inject", v:1.5}; | |
| return {type:"llm", text}; | |
| } | |
| async function route(intent){ | |
| if(intent.type==="web"){ | |
| loadURL(intent.url); | |
| print("Web opened: "+intent.url); | |
| } | |
| if(intent.type==="agent"){ | |
| spawnAgent(); | |
| print("Agent spawned"); | |
| } | |
| if(intent.type==="inject"){ | |
| Psi = intent.v; | |
| print("Ψ updated"); | |
| } | |
| if(intent.type==="llm"){ | |
| const cmd = await llmIntent(intent.text); | |
| route(cmd); | |
| } | |
| } | |
| input.addEventListener("keydown", e=>{ | |
| if(e.key==="Enter"){ | |
| const t=input.value; | |
| print("> "+t); | |
| route(parseIntent(t)); | |
| input.value=""; | |
| } | |
| }); | |
| function loop(){ | |
| updateWorld(Psi, sigma); | |
| updateAgents(); | |
| requestAnimationFrame(loop); | |
| } | |
| print("CodexReality3D v9+ ONLINE"); | |
| loop(); |