Spaces:
Running
Running
Update main.js
Browse files
main.js
CHANGED
|
@@ -1,59 +1,56 @@
|
|
| 1 |
-
import {
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
// ----- Console -----
|
| 4 |
const log = document.getElementById("log");
|
| 5 |
const input = document.getElementById("input");
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
log.scrollTop = log.scrollHeight;
|
| 10 |
-
}
|
| 11 |
-
|
| 12 |
-
// ----- Intent Parsing (v8) -----
|
| 13 |
-
function parseIntent(text) {
|
| 14 |
-
const t = text.toLowerCase();
|
| 15 |
|
| 16 |
-
|
| 17 |
-
return { type: "web", url: text.split(" ").pop() };
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
-
if (t.includes("brighter")) {
|
| 21 |
-
return { type: "inject", value: 2 };
|
| 22 |
-
}
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
}
|
| 44 |
}
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
input.value = "";
|
| 53 |
}
|
| 54 |
});
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { updateWorld } from "./world.js";
|
| 2 |
+
import { updateAgents, spawnAgent } from "./agents.js";
|
| 3 |
+
import { loadURL, scrapeDOM } from "./web.js";
|
| 4 |
+
import { llmIntent } from "./llm.js";
|
| 5 |
|
|
|
|
| 6 |
const log = document.getElementById("log");
|
| 7 |
const input = document.getElementById("input");
|
| 8 |
|
| 9 |
+
export let Psi = 0.5;
|
| 10 |
+
export let sigma = 0.5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
function print(m){ log.innerHTML += m+"<br/>"; log.scrollTop=log.scrollHeight; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
function parseIntent(text){
|
| 15 |
+
if(text.startsWith("open")) return {type:"web", url:text.split(" ").pop()};
|
| 16 |
+
if(text.includes("spawn")) return {type:"agent"};
|
| 17 |
+
if(text.includes("brighter")) return {type:"inject", v:1.5};
|
| 18 |
+
return {type:"llm", text};
|
| 19 |
}
|
| 20 |
|
| 21 |
+
async function route(intent){
|
| 22 |
+
if(intent.type==="web"){
|
| 23 |
+
loadURL(intent.url);
|
| 24 |
+
print("Web opened: "+intent.url);
|
| 25 |
+
}
|
| 26 |
+
if(intent.type==="agent"){
|
| 27 |
+
spawnAgent();
|
| 28 |
+
print("Agent spawned");
|
| 29 |
+
}
|
| 30 |
+
if(intent.type==="inject"){
|
| 31 |
+
Psi = intent.v;
|
| 32 |
+
print("Ψ updated");
|
| 33 |
+
}
|
| 34 |
+
if(intent.type==="llm"){
|
| 35 |
+
const cmd = await llmIntent(intent.text);
|
| 36 |
+
route(cmd);
|
| 37 |
}
|
| 38 |
}
|
| 39 |
|
| 40 |
+
input.addEventListener("keydown", e=>{
|
| 41 |
+
if(e.key==="Enter"){
|
| 42 |
+
const t=input.value;
|
| 43 |
+
print("> "+t);
|
| 44 |
+
route(parseIntent(t));
|
| 45 |
+
input.value="";
|
|
|
|
| 46 |
}
|
| 47 |
});
|
| 48 |
|
| 49 |
+
function loop(){
|
| 50 |
+
updateWorld(Psi, sigma);
|
| 51 |
+
updateAgents();
|
| 52 |
+
requestAnimationFrame(loop);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
print("CodexReality3D v9+ ONLINE");
|
| 56 |
+
loop();
|