File size: 7,318 Bytes
224e773
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>HyperKitty β€” Sovereign</title>
  <style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body { background: #060609; color: #c8ffca; font-family: ui-monospace, monospace; min-height: 100vh; }
    header { padding: 14px 18px; border-bottom: 1px solid #1c1c22; background: #0c0c10; display: flex; justify-content: space-between; align-items: center; }
    header b { color: #7cffb2; letter-spacing: 0.5px; }
    .live { color: #0f0; font-size: 12px; border: 1px solid #0f0; padding: 3px 8px; border-radius: 99px; }
    #chat { margin: 16px; height: 62vh; overflow: auto; border: 1px solid #1e1e26; background: #0a0a0f; padding: 14px; border-radius: 10px; }
    .line { margin: 10px 0; padding: 10px 12px; border-left: 3px solid #222; background: #0f0f14; border-radius: 6px; line-height: 1.4; }
    .you { border-color: #fff; color: #fff; }
    .kitty { border-color: #00ffaa; color: #7cffb2; }
    .sys { border-color: #ffaa00; color: #ffcc66; font-size: 12px; }
    .bar { margin: 0 16px 16px; display: flex; gap: 10px; }
    input { flex: 1; padding: 14px; background: #101016; color: #0f0; border: 1px solid #2a2a35; border-radius: 10px; outline: 0; }
    input:focus { border-color: #7cffb2; }
    button { padding: 14px 20px; background: #7cffb2; color: #000; border: 0; border-radius: 10px; font-weight: 900; cursor: pointer; }
    button:hover { background: #a0ffc8; }
    a { color: #7cffb2; text-decoration: none; }
    a:hover { text-decoration: underline; }
    .footer { padding: 0 16px 16px; font-size: 11px; color: #555; }
  </style>
</head>
<body>
  <header>
    <b>🐱 HyperKitty β€” Sovereign Swarm (16 Agents A-P)</b>
    <span class="live" id="status">● LOADING WASM...</span>
  </header>
  <div id="chat"></div>
  <div class="bar">
    <input id="in" placeholder="Talk to the swarm..." disabled>
    <button onclick="send()" id="btn" disabled>SEND</button>
  </div>
  <div class="footer">
    Fleet: <a href="orchestrator.html">orchestrator.html</a> | QRA tensor live | WORM enabled | <span id="iso"></span>
  </div>

  <script type="module">
    import init, {
      qra_next, glyph_name_for, glyph_wire_byte,
      qra_evolve_witness, qra_validate_exhaustion, qra_tensor,
      sla_hash_symbol, sla_ledger_for_glyph, sla_is_balanced,
      reconcile_glyph, reconcile_all_json, validate_isomorphism,
      agent_route
    } from './pkg/hyperkitty_wasm.js';

    const c = document.getElementById('chat');
    const inp = document.getElementById('in');
    const btn = document.getElementById('btn');

    function add(t, cls) {
      const d = document.createElement('div');
      d.className = 'line ' + cls;
      d.textContent = t;
      c.appendChild(d);
      c.scrollTop = 1e9;
    }

    // State: current glyph per agent (0-15), starts at Pi=0
    const agentState = new Uint8Array(16).fill(0);

    function routeMessage(text, fromAgent) {
      const prev = agentState[fromAgent];
      const routeJson = JSON.parse(agent_route(fromAgent, prev));
      agentState[fromAgent] = routeJson.glyph_next === 'Pi' ? 0
        : routeJson.glyph_next === 'Gamma' ? 1
        : routeJson.glyph_next === 'Delta' ? 2
        : routeJson.glyph_next === 'Omega' ? 3
        : routeJson.glyph_next === 'Lambda' ? 4 : 5;
      return routeJson;
    }

    function send() {
      const v = inp.value.trim();
      if (!v) return;
      add('YOU: ' + v, 'you');
      inp.value = '';

      // Hash the message to pick an agent (deterministic)
      let h = 0;
      for (let i = 0; i < v.length; i++) h = (h * 31 + v.charCodeAt(i)) >>> 0;
      const fromAgent = h % 16;
      const agentLabel = String.fromCharCode(65 + fromAgent);

      const route = routeMessage(v, fromAgent);
      const symHash = sla_hash_symbol(v);
      const wormId = route.worm_id;

      setTimeout(() => {
        const l = v.toLowerCase();
        let response;

        if (l.match(/^(hi|hello|hey)/)) {
          response = `Fleet A-P online. Routed via Agent ${agentLabel} β†’ ${route.glyph_current}β†’${route.glyph_next} (wire:${route.wire_byte}). K_QLG=Ο‰_SLA=target_QRA βœ“`;
        } else if (l.includes('route') || l.includes('qra') || l.includes('tensor')) {
          const t = qra_tensor();
          response = `QRA tensor Q[${route.glyph_current}][prev]β†’${route.glyph_next}. Absorbed:${route.absorbed}. Tensor[0..5]: ${Array.from(t.slice(0,6)).join(',')}`;
        } else if (l.includes('reconcil') || l.includes('isomorphism') || l.includes('iso')) {
          const certs = JSON.parse(reconcile_all_json());
          const valid = certs.every(c => c.valid);
          response = `K_QLG=Ο‰_SLA=target_QRA: ${valid ? 'βœ“ ALL 6 GLYPHS VERIFIED' : 'βœ— MISMATCH'}. ${certs.map(c => c.glyph+'β†’'+c.qra_target).join(' ')}`;
        } else if (l.includes('witness')) {
          const w = qra_evolve_witness(0, 1, 2); // Pi,Gamma,Delta
          const w2 = qra_evolve_witness(w[0], w[1], w[2]);
          const names = i => glyph_name_for(i);
          response = `Witness [Pi,Ga,De]β†’[${names(w[0])},${names(w[1])},${names(w[2])}]β†’[${names(w2[0])},${names(w2[1])},${names(w2[2])}]. Exhausts in 2 steps: ${qra_validate_exhaustion()}`;
        } else if (l.includes('sla') || l.includes('ledger')) {
          const enc = sla_ledger_for_glyph(fromAgent % 6);
          response = `SLA ledger for Agent ${agentLabel} (${route.glyph_current}): balanced=${sla_is_balanced(enc)} Ο‰=1. sym=${symHash.slice(0,8)}...`;
        } else if (l.includes('hash') || l.includes('worm')) {
          response = `WORM:${wormId} sym:${symHash.slice(0,12)} agent:${agentLabel} glyph:${route.glyph_current}β†’${route.glyph_next}`;
        } else if (l.includes('cert') || l.includes('proof')) {
          const cert = JSON.parse(reconcile_glyph(fromAgent % 6));
          response = `Cert[${agentLabel}]: QLG_normΒ²=${cert.qlg_norm_sq} SLA_Ο‰=${cert.sla_omega} QRA_target=${cert.qra_target} valid=${cert.valid}`;
        } else {
          response = `[Agent ${agentLabel}|${route.glyph_current}β†’${route.glyph_next}] ${v} β€” WORM:${wormId} wire:${route.wire_byte}`;
        }

        add(`KITTY[${agentLabel}]: ${response}`, 'kitty');
      }, 180);
    }

    inp.addEventListener('keydown', e => { if (e.key === 'Enter') send(); });

    // Boot WASM
    init('./pkg/hyperkitty_wasm_bg.wasm').then(() => {
      const iso = validate_isomorphism();
      const exhaustion = qra_validate_exhaustion();
      document.getElementById('status').textContent = '● LIVE β€” QRA ACTIVE';
      document.getElementById('iso').textContent =
        `iso:${iso ? 'βœ“' : 'βœ—'} exhaustion:${exhaustion ? 'βœ“' : 'βœ—'}`;
      inp.disabled = false;
      btn.disabled = false;
      add('SYSTEM: HyperKitty WASM loaded β€” QRA tensor live, SLA ledger active, tripartite isomorphism verified', 'sys');
      add(`SYSTEM: K_QLG = Ο‰_SLA = target_QRA: ${iso ? 'βœ“ ALL 6 GLYPHS' : 'βœ— FAILED'} | Witness exhaustion in 2 steps: ${exhaustion}`, 'sys');
      add('SYSTEM: 16 agents A-P routing through Q[current][previous] tensor. WORM trace on every message.', 'sys');
    }).catch(e => {
      add('SYSTEM: WASM load failed β€” ' + e, 'sys');
    });
  </script>
</body>
</html>