code wiki / _hdl_build / nx_gen_orchestrator.nx

nx_gen_orchestrator.nx

buildroot/runtime/_hdl_build/nx_gen_orchestrator.nx

82462 B1349 linesdepth 8pulls 27 transitivereach 6 importersview sourcekind librarytopic gen
docsdependenciesstructsconstsfunctions

about

nx_gen_orchestrator.nx -- the NAS-side Elder AI gen daemon (the sovereign gen-img, off Docker). Loopback HTTP backend behind nx_gen_gateway (which OPAQUE-gates /gen + prefix-strips). Routes: GET / -> the gen UI (batch form + results strip + gallery link) POST /api/generate -> validate -> POST the GPU worker /sdapi/v1/txt2img (batch_size=count) -> gp_response (decode/inject-GENREC/ingest/blob/sidecar) -> {cids[]} GET /img/<cid> -> serve the PNG blob (sidecar CID->path lookup) GET /api/recent?n= -> the most recent CIDs (results strip / gallery feed) POST /api/mesh -> {prompt} -> t2mesh (parametric SDF template) -> surface-nets -> STL on disk -> {object,verts,tris,stl} (the 3D lane; CPU in-process, no GPU worker) GET /mesh/<obj>.stl -> serve the emitted STL (name matched against the FIXED template vocabulary, client bytes never reach the filesystem path = traversal impossible) GET /health -> 200 Worker endpoint + store/blob/sidecar paths + generator-host are data-driven via argv (Rule 11/17). argv: [1]=listen_port [2]=worker_a [3]=worker_b [4]=worker_c [5]=worker_d [6]=worker_port [7]=store_prefix [8]=blobdir [9]=sidecar [10]=generator_host [11]=budget license_tier: ORIGINAL

dependencies 14 imports · 6 importers

nx_gen_pipeline.nx nx_syscalls.nx nx_sdfrender.nx nx_meshgen.nx nx_t2mesh.nx nx_companion_identity.nx nx_gen_worker.nx nx_companion_persona.nx nx_companion_wardrobe.nx nx_companion_state.nx nx_gen_orchestrator.nx nx_gen_gateway_gate.nx nx_gen_mesh_gate.nx nx_gen_multiworker_gate.nx nx_gen_orchestrator_daemon.nx nx_gen_orchestrator_gate.nx nx_gen_real_gate.nx

diagram shows first 10 each side; +4 more imports, +0 more importers in the complete lists below.

imports: nx_gen_pipeline.nxnx_syscalls.nxnx_sdfrender.nxnx_meshgen.nxnx_t2mesh.nxnx_companion_identity.nxnx_gen_worker.nxnx_companion_persona.nxnx_companion_wardrobe.nxnx_companion_state.nxnx_anatomy_risk.nxnx_render_coherence.nxnx_swarm_endpoint_lib.nxnx_store_seed_lib.nx

imported by: nx_gen_gateway_gate.nxnx_gen_mesh_gate.nxnx_gen_multiworker_gate.nxnx_gen_orchestrator_daemon.nxnx_gen_orchestrator_gate.nxnx_gen_real_gate.nx

structs

none

consts

32const GEN_BATCH_CAP: i64 = 8
33const GEN_UI_HTML: *u8 = "<!doctype html><html><head><meta charset=utf-8><meta name=viewport content=\"width=device-width,initial-scale=1\"><title>Elder AI &mdash; Gen</title><style>body{font-family:system-ui,sans-serif;max-width:900px;margin:2vh auto;padding:0 16px;color:#cdd7e6;background:#0b1019}h1{font-size:1.25rem;color:#e8eef7}label{display:block;font-size:.78rem;color:#7c8aa5;margin:8px 0 2px}textarea,input,select{width:100%;padding:8px;box-sizing:border-box;border:1px solid #2a3550;border-radius:5px;background:#121a28;color:#e8eef7}.row{display:flex;gap:8px;flex-wrap:wrap}.row>div{flex:1;min-width:90px}button{padding:10px 18px;margin:12px 0;background:#2d6cdf;color:#fff;border:0;border-radius:6px;cursor:pointer;font-size:1rem}#s{font-size:.82rem;color:#7c8aa5;min-height:1.2em}#g{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px;margin-top:14px}#g img{width:100%;border-radius:6px;background:#121a28}a{color:#6ea8fe}.mt{margin-top:26px}#cl{background:#121a28;border:1px solid #2a3550;border-radius:6px;padding:10px;min-height:120px;max-height:340px;overflow-y:auto;font-size:.9rem}#cl>div{margin:6px 0}#cs{font-size:.78rem;color:#7c8aa5;min-height:1em}.cu{color:#6ea8fe;font-weight:600}.ca{color:#e8a0c0;font-weight:600}</style></head><body><h1>Elder AI &mdash; image generation</h1><label>Prompt</label><textarea id=p rows=3>a red fox in a snowy pine forest, photograph</textarea><label>Negative prompt</label><input id=n value=\"blurry, lowres\"><div class=row><div><label>Width</label><input id=w type=number value=512></div><div><label>Height</label><input id=h type=number value=512></div><div><label>Steps</label><input id=st type=number value=8></div><div><label>CFG</label><input id=c value=1.0></div><div><label>Seed (-1 rnd)</label><input id=sd type=number value=-1></div><div><label>Count</label><input id=cn type=number value=1 min=1 max=8></div></div><label>Sampler</label><select id=sm><option>euler</option><option>euler_a</option><option>dpm++_2m</option><option>heun</option><option>ddim</option></select><button onclick=gen()>Generate</button> <a href=\"/gen/\">gallery</a><div id=s>ready.</div><div id=g></div><script>function $(i){return document.getElementById(i)}\nasync function gen(){$('s').textContent='generating...';$('g').innerHTML='';try{var r=await fetch('/gen/api/generate',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({prompt:$('p').value,negative:$('n').value,width:+$('w').value,height:+$('h').value,steps:+$('st').value,cfg:$('c').value,seed:+$('sd').value,count:+$('cn').value,sampler:$('sm').value})});var j=await r.json();if(!r.ok){$('s').textContent='error: '+(j.error||r.status);return}$('s').textContent=j.count+' image(s) in '+j.ms+'ms';for(var i=0;i<j.cids.length;i++){var im=document.createElement('img');im.src='/gen/img/'+j.cids[i];$('g').appendChild(im)}}catch(e){$('s').textContent='error: '+e}}\nfetch('/gen/api/recent?n=24').then(function(r){return r.json()}).then(function(j){if(j&&j.cids){for(var i=0;i<j.cids.length;i++){var im=document.createElement('img');im.src='/gen/img/'+j.cids[i];$('g').appendChild(im)}}}).catch(function(){})\nasync function mesh(){$('ms').textContent='generating mesh...';$('mo').innerHTML='';try{var r=await fetch('/gen/api/mesh',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({prompt:$('mp').value})});var j=await r.json();if(!r.ok){$('ms').textContent='error: '+(j.error||r.status);return}$('ms').textContent=j.object+' -- '+j.verts+' verts, '+j.tris+' tris, watertight, '+j.ms+'ms';var a=document.createElement('a');a.href=j.stl;a.download=j.object+'.stl';a.textContent='download '+j.object+'.stl (print-ready)';$('mo').appendChild(a)}catch(e){$('ms').textContent='error: '+e}}</script><h1 style=\"margin-top:26px\">Elder AI &mdash; 3D object</h1><label>Object prompt &mdash; text to a printable watertight STL (vocabulary: ball, snowman, dumbbell, tree, mushroom, bottle, person, cactus, capsule)</label><input id=mp value=\"a snowman in the yard\"><button onclick=mesh()>Generate 3D</button><div id=ms>ready.</div><div id=mo></div>" as *u8
34const GEN_CHAT_HTML: *u8 = "<h1 class=mt>Elara &mdash; chat</h1><div id=cl></div><div class=row style='margin-top:8px'><div style='flex:4'><input id=ci placeholder='say something to Elara'></div><div><button onclick=say()>Send</button></div></div><div id=cs></div><script>var CHIST=[{role:'system',content:'You are Elara, a warm, affectionate, playful companion who speaks naturally and stays in character. Keep replies conversational.'}];function cadd(role,txt){var d=document.createElement('div');d.className=(role=='user'?'cu':'ca');d.textContent=(role=='user'?'you: ':'Elara: ')+txt;var cl=document.getElementById('cl');cl.appendChild(d);cl.scrollTop=1e9}\nasync function say(){var el=document.getElementById('ci');var t=el.value.trim();if(!t){return}el.value='';cadd('user',t);document.getElementById('cs').textContent='Elara is typing...';try{var r=await fetch('/gen/api/chat',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({message:t})});var j=await r.json();if(!r.ok){document.getElementById('cs').textContent='error: '+(j.error||r.status);return}var m=(j.choices&&j.choices[0]&&j.choices[0].message&&j.choices[0].message.content)||'(no reply)';cadd('assistant',m);if(j.images&&j.images.length){var cl=document.getElementById('cl');for(var ii=0;ii<j.images.length;ii++){var im=document.createElement('img');im.src='/gen/img/'+j.images[ii];im.style.maxWidth='170px';im.style.borderRadius='8px';im.style.margin='4px 4px 0 0';cl.appendChild(im)}cl.scrollTop=1e9}document.getElementById('cs').textContent=''}catch(e){document.getElementById('cs').textContent='error: '+e}}\ndocument.getElementById('ci').addEventListener('keydown',function(e){if(e.key=='Enter'){say()}})</script></body></html>" as *u8
343const GO_STEPS_FLOOR: i64 = 1
344const GO_STEPS_CEIL: i64 = 50
345const GO_STEPS_FALLBACK: i64 = 8
349const GO_PHOTO_SIZE: *u8 = "768x1024"
396const GO_CH_DOT: i64 = 46
397const GO_CH_COLON: i64 = 58
398const GO_CH_D0: i64 = 48
399const GO_CH_D9: i64 = 57
822const GO_W_PROMPT_CAP: i64 = 8192
823const GO_W_REQ_CAP: i64 = 65536
824const GO_W_RESP_CAP: i64 = 262144
828const GO_WPLANE: *u8 = "/volume1/homes/elderwesto/nishihost/knowledge/store/writemode-"

functions

36func go_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
37func go_itoa(dst: *u8, off: i64, v: i64) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var o: i64=off; var q: i64=k-1; while q>=0{dst[o]=t[q];o=o+1;q=q-1} return o }
38func go_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var i: i64=0; while s[i]!=(0 as u8){dst[o]=s[i]; o=o+1; i=i+1} return o }
39func go_catb(dst: *u8, off: i64, src: *u8, n: i64) -> i64 { var o: i64=off; var i: i64=0; while i<n {dst[o]=src[i]; o=o+1; i=i+1} return o }
40func go_starts(buf: *u8, n: i64, pre: *u8) -> i64 { var i: i64=0; while pre[i]!=(0 as u8){ if i>=n {return 0} if buf[i]!=pre[i]{return 0} i=i+1 } return 1 }
called by 1: go_serve_conn
42func go_send(cfd: i64, status: *u8, ctype: *u8, body: *u8, blen: i64) -> i64
52func go_send_bin(cfd: i64, ctype: *u8, body: *u8, blen: i64) -> i64
62func go_400(cfd: i64, msg: *u8) -> i64 { let b: *u8 = sys_mmap(256); var o: i64 = go_cat(b,0,"{\"error\":\"" as *u8); o=go_cat(b,o,msg); o=go_cat(b,o,"\"}" as *u8); go_send(cfd, "400 Bad Request" as *u8, "application/json" as *u8, b, o); return 0 }
63func go_503(cfd: i64, msg: *u8) -> i64 { let b: *u8 = sys_mmap(256); var o: i64 = go_cat(b,0,"{\"error\":\"" as *u8); o=go_cat(b,o,msg); o=go_cat(b,o,"\"}" as *u8); go_send(cfd, "503 Service Unavailable" as *u8, "application/json" as *u8, b, o); return 0 }
66func go_read_full(cfd: i64, req: *u8, cap: i64) -> i64
87func go_find_seq(buf: *u8, n: i64, needle: *u8, nl: i64) -> i64
93func go_hdr_int(req: *u8, hend: i64, name: *u8, nl: i64) -> i64
called by 1: go_read_full calls 1: go_find_seq
104func go_reqpath(req: *u8, rn: i64, out: *u8, cap: i64) -> i64
called by 1: go_serve_conn
114func go_json_findval(body: *u8, blen: i64, key: *u8) -> i64
133func go_skip_sp(body: *u8, blen: i64, i0: i64) -> i64 { var i: i64=i0; var sk: i64=1; while sk==1 { if i<blen { if (body[i]&0xff)==32 { i=i+1 } else { sk=0 } } else { sk=0 } } return i }
134func go_json_str(body: *u8, blen: i64, key: *u8, out: *u8, outcap: i64) -> i64
156func go_json_int(body: *u8, blen: i64, key: *u8, dflt: i64) -> i64
170func go_json_raw(body: *u8, blen: i64, key: *u8, out: *u8, outcap: i64) -> i64
186func go_emit_jstr(dst: *u8, off: i64, s: *u8) -> i64
205func go_body_start(resp: *u8, n: i64) -> i64 { let he: i64 = go_find_seq(resp, n, "\r\n\r\n" as *u8, 4); if he < 0 { return 0 } return he + 4 }
208func go_sidecar_lookup(sidecar: *u8, cid: *u8, cidlen: i64, pathout: *u8) -> i64
238func go_serve_img(cfd: i64, path: *u8, plen: i64, sidecar: *u8) -> i64
284func go_serve_recent(cfd: i64, sidecar: *u8, k: i64) -> i64
351func go_default_steps() -> i64
370func go_append_turbo_args(dst: *u8, off: i64, steps: i64, cfg: *u8, neg: *u8, seed: i64) -> i64
403func go_swarm_worker(w: *i64) -> i64
called by 1: go_workers_assemble calls 1: se_addr
436func go_workers_assemble(cfg: *i64, ha: i64, hb: i64, hc: i64, hd: i64, wport: i64, wa: *i64, wb: *i64, wc: *i64, wd: *i64, wpa: *i64) -> i64
449func go_handle_generate(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
566func go_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{return v} if c>57{return v} v=v*10+(c-48); i=i+1 } return v }
called by 1: main
574func go_contains_ci(hay: *u8, hlen: i64, needle: *u8) -> i64
called by 1: go_handle_chat
592func go_parse_count(s: *u8) -> i64
called by 1: go_handle_chat
614func go_handle_chat(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
815func go_streq(a: *u8, b: *u8) -> i64
831func go_wmode(mode: *u8, reg: *u8, lane: *u8, structure: *u8) -> i64
878func go_wsys(structure: *u8, out: *u8) -> i64
called by 1: go_handle_write calls 2: go_catgo_streq
894func go_wq_catn(b: *u8, off: i64, v: i64) -> i64
called by 1: go_handle_write calls 1: sys_mmap
905func go_handle_write(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
987func go_wfs(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd, s, n); return 0 }
called by 1: go_write_stl calls 1: sys_write
988func go_stlnum(fd: i64, v: i64) -> i64
called by 1: go_write_stl calls 2: sys_mmapsys_write
998func go_write_stl(vbuf: *i64, fbuf: *i64, nf: i64, path: *u8) -> i64
1017func go_mesh_path(sp: *u8, blobdir: *u8, nm: *u8) -> i64
1025func go_handle_mesh(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
1063func go_name_eq(path: *u8, plen: i64, nm: *u8) -> i64
called by 1: go_serve_mesh_file
1075func go_serve_mesh_file(cfd: i64, path: *u8, plen: i64, blobdir: *u8) -> i64
1095func go_mood_label(st: *i64, out: *u8) -> i64
called by 1: go_serve_state calls 1: go_cat
1105func go_day_activity(out: *u8) -> i64
1121func go_serve_state(cfd: i64) -> i64
1139func go_serve_ui(cfd: i64) -> i64
1157func go_handle_batch(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
1173func go_serve_batch(cfd: i64, path: *u8, plen: i64) -> i64
1191func go_png_dim(png: *u8, n: i64, wh: *i64) -> i64
called by 1: go_handle_img2img
1205func go_handle_img2img(cfd: i64, body: *u8, bn: i64, cfg: *i64) -> i64
1298func go_handle_anatomy(cfd: i64, body: *u8, bn: i64) -> i64
1319func go_serve_conn(cfd: i64, cfg: *i64) -> i64