code wiki / _hdl_build / nx_gen.nx
nx_gen.nx
buildroot/runtime/_hdl_build/nx_gen.nx
about
nx_gen.nx -- the sovereign GEN MCP tool: a thin NAS-side client for the gen orchestrator daemon (loopback :18795).
Runs ON THE NAS (invoked by nx_tools_api over /mcp), so it can reach the plain-HTTP loopback daemon that nx_https_get
(HTTPS-only) and the login-gated /gen edge cannot -- and returns the daemon's JSON straight through the MCP channel
(no root-owned files, no namespace/harness games). Verbs:
anatomy <prompt> -> POST /api/anatomy {prompt} = instant deterministic QC (risk/factors/wetfix)
recent [n] -> GET /api/recent?n=n = latest gallery cids
chat <message> -> POST /api/chat {message} = companion reply (photo msgs also gen)
generate <prompt> [count] [WxH] [seed] -> POST /api/generate = render on the swarm GPU + ingest -> {count,ms,cids}
img2img <cid> <prompt> [denoise] -> POST /api/img2img = edit an EXISTING gallery cid -> new cid
batch <prompt> [count] [WxH] [seed] -> POST /api/batch = async render (edge-timeout-proof) -> job id
batchget <jid> -> GET /api/batch/<jid> = poll the async job ({"done":0} while rendering)
(2026-08-04: generate/img2img/batch/batchget close the "expose the gen daemon as a full MCP tool" debt --
agents/workflows drive the WHOLE gen loop over MCP; the daemon resolves its GPU worker from the swarm SSOT.)
license_tier: ORIGINAL expect_exit: 0
dependencies 2 imports · 2 importers
imports: nx_syscalls.nxnx_connect.nx
imported by: nx_gen_explorer.nxnx_gen_gate.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 17 | const K_MAGIC_4194304: i64 = 4194304 |
| 18 | const K_MAGIC_131072: i64 = 131072 |
| 19 | const K_MAGIC_65536: i64 = 65536 |
| 20 | const K_MAGIC_18795: i64 = 18795 |
| 21 | const G_TMO_FAST: i64 = 60 |
| 22 | const G_TMO_RENDER: i64 = 300 |
functions
| 24 | func g_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } called by 1: main |
| 25 | func g_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 } |
| 26 | func g_catn(dst: *u8, off: i64, s: *u8, n: i64) -> i64 { var o: i64=off; var i: i64=0; while i<n {dst[o]=s[i]; o=o+1; i=i+1} return o } called by 1: g_post |
| 27 | func g_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 } |
| 28 | func g_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8) { if (a[i]&0xff)!=(b[i]&0xff) { return 0 } i=i+1 } if b[i]!=(0 as u8) { return 0 } return 1 } called by 1: main |
| 30 | func g_atoi(s: *u8, dflt: i64) -> i64 { var v: i64=0; var seen: i64=0; var i: i64=0; while s[i]!=(0 as u8) { let c: i64=s[i]&0xff; if c>=48 { if c<=57 { v=v*10+(c-48); seen=1 } } i=i+1 } if seen==0 { return dflt } return v } |
| 32 | func g_jesc(dst: *u8, off: i64, s: *u8) -> i64 |
| 44 | func g_is_decimal(s: *u8) -> i64 called by 1: main |
| 56 | func g_http(port: i64, req: *u8, reqlen: i64, tmo: i64) -> i64 called by 1: main calls 7: sys_socketsys_writesys_set_socket_timeoutsys_mmapnx_connect_boundedsys_close+1 |
| 77 | func g_render_body(body: *u8, argc: i64, argv: *i64) -> i64 |
| 104 | func g_post(req: *u8, path: *u8, body: *u8, bo: i64) -> i64 |
| 112 | func main(argc: i64, argv: *i64) -> i64 |