LordXido commited on
Commit
07a4adc
·
verified ·
1 Parent(s): eda5cf6

Update main.js

Browse files
Files changed (1) hide show
  1. main.js +42 -45
main.js CHANGED
@@ -1,59 +1,56 @@
1
- import { loadURL } from "./web.js";
 
 
 
2
 
3
- // ----- Console -----
4
  const log = document.getElementById("log");
5
  const input = document.getElementById("input");
6
 
7
- function print(msg) {
8
- log.innerHTML += msg + "<br/>";
9
- log.scrollTop = log.scrollHeight;
10
- }
11
-
12
- // ----- Intent Parsing (v8) -----
13
- function parseIntent(text) {
14
- const t = text.toLowerCase();
15
 
16
- if (t.includes("open") || t.includes("browse")) {
17
- return { type: "web", url: text.split(" ").pop() };
18
- }
19
-
20
- if (t.includes("brighter")) {
21
- return { type: "inject", value: 2 };
22
- }
23
 
24
- return { type: "command", raw: text };
 
 
 
 
25
  }
26
 
27
- // ----- Command Router -----
28
- function route(intent) {
29
- switch (intent.type) {
30
- case "web":
31
- print("Opening web layer → " + intent.url);
32
- loadURL(intent.url);
33
- break;
34
-
35
- case "inject":
36
- Psi = intent.value;
37
- print("Ψ injected → " + Psi);
38
- break;
39
-
40
- case "command":
41
- handle(intent.raw);
42
- break;
43
  }
44
  }
45
 
46
- // ----- Input Handling -----
47
- input.addEventListener("keydown", e => {
48
- if (e.key === "Enter") {
49
- const text = input.value.trim();
50
- print("> " + text);
51
- route(parseIntent(text));
52
- input.value = "";
53
  }
54
  });
55
 
56
- // Boot
57
- print("CodexReality3D v8 ONLINE");
58
- print("World + Web Unified");
59
- print("Try: open wikipedia.org");
 
 
 
 
 
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();