code wiki / _hdl_build / nx_gen.nx

nx_gen.nx

buildroot/runtime/_hdl_build/nx_gen.nx

11139 B177 linesdepth 5pulls 5 transitivereach 2 importersview sourcekind tooltopic gen
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_connect.nx nx_gen.nx nx_gen_explorer.nx nx_gen_gate.nx

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

main sys_write g_slen sys_mmap g_streq g_cat g_jesc g_post g_cat ↻ g_itoa sys_mmap ↻ g_catn g_http sys_socket sys_write ↻ sys_set_socket_timeout sys_mmap ↻ sys_setsockopt sys_munmap sys_mmap ↻ nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll sys_close sys_read g_atoi g_itoa ↻ g_render_body g_atoi ↻ g_cat ↻ g_jesc ↻ g_itoa ↻ g_is_decimal

structs

none

consts

17const K_MAGIC_4194304: i64 = 4194304
18const K_MAGIC_131072: i64 = 131072
19const K_MAGIC_65536: i64 = 65536
20const K_MAGIC_18795: i64 = 18795
21const G_TMO_FAST: i64 = 60
22const G_TMO_RENDER: i64 = 300

functions

24func g_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 1: main
25func 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 }
26func 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
27func 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 }
called by 3: g_render_bodyg_postmain calls 1: sys_mmap
28func 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
30func 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 }
called by 2: g_render_bodymain
32func g_jesc(dst: *u8, off: i64, s: *u8) -> i64
called by 2: g_render_bodymain
44func g_is_decimal(s: *u8) -> i64
called by 1: main
56func g_http(port: i64, req: *u8, reqlen: i64, tmo: i64) -> i64
77func g_render_body(body: *u8, argc: i64, argv: *i64) -> i64
called by 1: main calls 4: g_atoig_catg_jescg_itoa
104func g_post(req: *u8, path: *u8, body: *u8, bo: i64) -> i64
called by 1: main calls 3: g_catg_itoag_catn
112func main(argc: i64, argv: *i64) -> i64