File size: 1,338 Bytes
07a4adc
 
 
 
a69d494
821cd82
 
 
07a4adc
 
a69d494
07a4adc
a3ea276
07a4adc
 
 
 
 
872f1df
 
07a4adc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
821cd82
 
 
07a4adc
 
 
 
 
 
821cd82
 
 
07a4adc
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
53
54
55
56
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();