nx_mesh_serve.nx
buildroot/runtime/nx_mesh_serve.nx
about
nx_mesh_serve.nx -- WORKER MESH SERVICE: the standing daemon that makes the whole mesh LIVE at a URL, now a
gated 3-route console (fronted by nx_mesh_gateway which OPAQUE-validates every /mesh/* request, strips the
/mesh prefix, and reverse-proxies to us on :8029). Routes (paths are POST-strip, i.e. what the gateway forwards):
GET / -> the mesh console: a prompt box that opens an EventSource to /mesh/gen and shows the image
GET /gen?p=<prompt> -> text/event-stream of the pipeline (accepted->authorized->routed->generating->result{url})
GET /served_<N>.png -> the generated PNG, served from sites/nishifamily/mesh/ (GATED: only reachable through
the authed gateway, so a logged-in operator can SEE their result; strict whitelist,
no path traversal)
The /gen route fork+dup3's the client socket onto the conductor's stdout and execve's ./nx_mesh_run.elf sse so the
SSE frames stream straight to the client. The / and /served routes fork a child that writes the response and exits
(bounds memory: the file buffer is freed with the child). Run from the nishihost cwd (where the organ elfs +
sites/ live). Build --build-only (it loops forever). license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_runtime.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 17 | const MS_MAGIC_8029: i64 = 8029 |
| 18 | const MS_MAGIC_8192: i64 = 8192 |
| 19 | const MS_MAGIC_1024: i64 = 1024 |
| 20 | const MS_MAGIC_8191: i64 = 8191 |
| 151 | const MS_HOME_HTML: *u8 = "<!doctype html><html><head><meta charset=utf-8><meta name=viewport content='width=device-width,initial-scale=1'><title>Nishi Mesh</title><style>body{font-family:system-ui,sans-serif;max-width:640px;margin:6vh auto;padding:0 18px;color:#cdd7e6;background:#0b1019}h1{font-size:1.25rem;color:#e8eef7}p{color:#7c8aa5;font-size:.88rem;line-height:1.5}input{width:100%;padding:10px;margin:8px 0;box-sizing:border-box;border:1px solid #2a3550;border-radius:6px;background:#121a28;color:#e8eef7;font-size:.95rem}button{padding:10px 18px;background:#2d6cdf;color:#fff;border:0;border-radius:6px;cursor:pointer;font-size:.95rem}button:disabled{opacity:.5;cursor:default}pre{margin:16px 0;padding:12px;background:#121a28;border-left:3px solid #2d6cdf;color:#cdd7e6;white-space:pre-wrap;min-height:1.2em;font-size:.82rem}img{max-width:100%;border-radius:8px;margin-top:12px;display:none}a{color:#5a9bff;font-size:.85rem;text-decoration:none}.row{display:flex;gap:8px;align-items:center}</style></head><body><h1>Nishi Mesh — sovereign job console</h1><p>Submit a prompt. The NAS dispatches it over the sovereign mesh to a GPU worker on the RTX 5080, streams the pipeline live, and lands the image below — all behind your login. This is the sovereign container plane that replaces Docker/Portainer.</p><input id=p value='a red fox in a snowy forest at sunrise'><div class=row><button id=b onclick='go()'>Generate</button><a href='/gallery/'>open gallery</a></div><pre id=log>ready.</pre><img id=out><script>function E(i){return document.getElementById(i)} function L(s){var g=E('log');g.appendChild(document.createTextNode(s));g.appendChild(document.createElement('br'))} function go(){var p=E('p').value;var out=E('out');var b=E('b');E('log').textContent='';b.disabled=true;out.style.display='none';L('submitting: '+p);var es=new EventSource('/mesh/gen?p='+encodeURIComponent(p));es.addEventListener('accepted',function(e){L('accepted')});es.addEventListener('authorized',function(e){L('authorized (capability ok)')});es.addEventListener('routed',function(e){var d={};try{d=JSON.parse(e.data)}catch(x){}L('routed to worker: '+(d.worker||'gpu'))});es.addEventListener('generating',function(e){L('generating on GPU...')});es.addEventListener('result',function(e){var d={};try{d=JSON.parse(e.data)}catch(x){}var u=d.url||'';var n=u.substring(u.lastIndexOf('/')+1);out.src='/mesh/'+n;out.style.display='block';L('done: '+n);b.disabled=false;es.close()});es.addEventListener('error',function(e){var d={};try{d=JSON.parse(e.data)}catch(x){}L('error: '+(d.error||'stream ended'));b.disabled=false;es.close()});es.onerror=function(){b.disabled=false}}</script></body></html>" as *u8 |
functions
| 22 | func ms_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 23 | func ms_atoi(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } return v } called by 1: main |
| 25 | func ms_num(buf: *u8, o: i64, v: i64) -> i64 |
| 35 | func ms_lit(buf: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { buf[o+i] = s[i]; i = i + 1 } return o + i } |
| 38 | func ms_hexval(c: i64) -> i64 called by 1: ms_extract_prompt |
| 47 | func ms_extract_prompt(req: *u8, n: i64, out: *u8, cap: i64) -> i64 |
| 96 | func ms_extract_path(req: *u8, n: i64, out: *u8, cap: i64) -> i64 called by 1: main |
| 120 | func ms_starts(path: *u8, plen: i64, pat: *u8, patlen: i64) -> i64 called by 1: main |
| 128 | func ms_is_served_png(path: *u8, plen: i64) -> i64 called by 1: main |
| 154 | func ms_serve_home(cfd: i64) |
| 170 | func ms_serve_png(cfd: i64, path: *u8, plen: i64) |
| 196 | func main(argc: i64, argv: *i64) -> i64 |