nx_office_serve.nx
buildroot/runtime/nx_office_serve.nx
about
nx_office_serve.nx -- NISHI OFFICE v1, the PRODUCT surface over the gated format organs (operator 2026-07-09:
"we need to build our own nishi office"). Until now the suite was organs + scattered sample pages; THIS organ is
the office: a zero-JS web app where a family member CREATES, EDITS, VERSIONS, PREVIEWS and DOWNLOADS real
documents / spreadsheets / decks. Every save = a NEW version (v1,v2,...) -- nothing is ever overwritten; that
additive never-lose history is the suite's one measured exceed, now surfaced as the product spine.
Engines (forked ELFs, the gated organs): doc = _offc/nx_docx.elf writerich (H/B/I/P + T pipe-cells) ?
sheet = _offc/nx_xlsx.elf fromtsv (TSV grid, =SUM/AVERAGE/MIN/MAX/COUNT formulas) ? deck = _offc/nx_pptx.elf
fromspec (S title / B bullet). Preview = each organ's own html mode. Honest v1 scope: SPEC editors (plain
textarea round-trip), NOT WYSIWYG -- that is the named next rung, along with co-edit (CRDT) and in-app AI.
Layout under <root>/: index.txt (append-only name\tkind registry) + <name>/manifest.txt (append-only
v<N>\t<kind>\t<usec> lines) + <name>/v<N>/{spec.txt, file.<ext>, preview.html}.
PURE CORE (no main): of_handle (request -> response), of_read_req/of_write_all (fd shells), of_selftest (the
offline gate body). Consumers: _hdl_build/nx_office_gate (offline gate) + _hdl_build/nx_office_daemon (accept
loop, port 8030). Same discipline as nx_relate_serve. license_tier: ORIGINAL
dependencies 5 imports · 3 importers
imports: nx_tool_run.nxnx_connect.nxnx_itoa_lib.nxnx_rebac.nxnx_http_client.nx
imported by: nx_office_daemon.nxnx_office_gate.nxnx_office_snapshot.nx
structs
| none |
consts
| 25 | const OF_AUTHZ: *u8 = "officeauthz_" |
| 26 | const OF_RELATE: *u8 = "knowledge/status/relate_" |
functions
| 28 | func p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 31 | func pn(v: i64) -> i64 { nxi_out(v); return 0 } calls 1: nxi_out |
| 32 | func of_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 33 | func of_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i } |
| 34 | func of_catc(dst: *u8, off: i64, code: i64) -> i64 { dst[off] = code as u8; return off + 1 } |
| 39 | func of_catn(dst: *u8, off: i64, v: i64) -> i64 { return nxi_buf(dst, off, v) } |
| 40 | func of_seq(a: *u8, b: *u8) -> i64 |
| 46 | func of_starts(s: *u8, pfx: *u8) -> i64 { var i: i64 = 0; while pfx[i] != (0 as u8) { if s[i] != pfx[i] { return 0 } i = i + 1 } return 1 } |
| 47 | func of_memhas(buf: *u8, n: i64, needle: *u8) -> i64 |
| 60 | func of_esc(dst: *u8, off: i64, s: *u8) -> i64 |
| 71 | func of_hexval(c: i64) -> i64 called by 1: of_form_get |
| 78 | func of_form_get(body: *u8, blen: i64, key: *u8, out: *u8, cap: i64) -> i64 |
| 109 | func of_write_all(fd: i64, buf: *u8, n: i64) -> i64 |
| 115 | func of_read_req(fd: i64, buf: *u8, cap: i64) -> i64 calls 1: sys_read |
| 163 | func of_read_file(path: *u8, buf: *u8, cap: i64) -> i64 |
| 171 | func of_write_file(path: *u8, buf: *u8, n: i64) -> i64 |
| 179 | func of_hdr_get(req: *u8, reqlen: i64, key: *u8, out: *u8, cap: i64) -> i64 |
| 205 | func of_atoi(s: *u8) -> i64 |
| 217 | func of_name_ok(name: *u8) -> i64 |
| 232 | func of_kind_idx(kind: *u8) -> i64 |
| 238 | func of_ext(k: i64) -> *u8 |
| 243 | func of_elf(k: i64) -> *u8 called by 1: of_save |
| 248 | func of_ct(k: i64) -> *u8 called by 1: of_serve |
| 253 | func of_kind_name(k: i64) -> *u8 |
| 259 | func of_manifest_count(root: *u8, name: *u8, kindout: *u8, kcap: i64) -> i64 |
| 279 | func of_vdir(root: *u8, name: *u8, vn: i64, out: *u8) -> i64 |
| 285 | func of_append_line(path: *u8, line: *u8, n: i64) -> i64 |
| 296 | func of_save(root: *u8, base: *u8, name: *u8, kind: *u8, spec: *u8, sl: i64, auto: i64) -> i64 |
| 361 | func of_css(out: *u8, off: i64) -> i64 calls 1: of_cat |
| 435 | func of_esc_n(out: *u8, off: i64, src: *u8, a: i64, b: i64) -> i64 |
| 448 | func of_render_doc(out: *u8, off: i64, spec: *u8, sl: i64) -> i64 |
| 482 | func of_render_sheet(out: *u8, off: i64, spec: *u8, sl: i64) -> i64 |
| 502 | func of_render_deck(out: *u8, off: i64, spec: *u8, sl: i64) -> i64 |
| 527 | func of_toolbar(out: *u8, off: i64, ks: i64) -> i64 |
| 544 | func of_read_asset(name: *u8, buf: *u8, cap: i64) -> i64 |
| 556 | func of_serve_js(out: *u8, cap: i64) -> i64 |
| 570 | func of_serve_sw(out: *u8, cap: i64) -> i64 |
| 594 | func of_serve_manifest(out: *u8, base: *u8, cap: i64) -> i64 |
| 614 | func of_page_top(out: *u8, off: i64, title: *u8) -> i64 |
| 630 | func of_page_foot(out: *u8, off: i64) -> i64 |
| 637 | func of_shell_top(out: *u8, off: i64, title: *u8, base: *u8, q: *u8) -> i64 called by 1: of_handle_auth |
| 658 | func of_ago(out: *u8, off: i64, us: i64) -> i64 |
| 669 | func of_manifest_last_us(root: *u8, name: *u8) -> i64 |
| 689 | func of_manifest_is_auto(root: *u8, name: *u8, vn: i64) -> i64 |
| 728 | func of_thumb(out: *u8, off: i64, root: *u8, name: *u8, ks: i64, vc: i64) -> i64 |
| 820 | func of_lower(s: *u8) -> i64 |
| 826 | func of_chip(out: *u8, off: i64, base: *u8, q: *u8, tv: *u8, sv: *u8, label: *u8, on: i64) -> i64 |
| 842 | func of_findpos(buf: *u8, n: i64, needle: *u8) -> i64 |
| 863 | func of_side_path(root: *u8, name: *u8, leaf: *u8, out: *u8) -> i64 |
| 868 | func of_starred(root: *u8, name: *u8) -> i64 |
| 881 | func of_star_toggle(root: *u8, name: *u8) -> i64 |
| 892 | func of_folder_get(root: *u8, name: *u8, out: *u8, cap: i64) -> i64 |
| 908 | func of_folder_set(root: *u8, name: *u8, val: *u8) -> i64 |
| 916 | func of_tmpl(out: *u8, off: i64, base: *u8, k: i64, icon: *u8, title: *u8, blurb: *u8, spec: *u8) -> i64 |
| 934 | func of_form(out: *u8, off: i64, base: *u8, k: i64) -> i64 |
| 962 | func of_home(root: *u8, base: *u8, qs: *u8, out: *u8, cap: i64, azprefix: *u8, me: *u8, authed: i64) -> i64 |
| 1169 | func of_lineeq(a: *u8, b: *u8) -> i64 |
| 1176 | func of_split_lines(buf: *u8, n: i64, lp: *i64, maxl: i64) -> i64 |
| 1188 | func of_read_version_spec(root: *u8, name: *u8, vn: i64, buf: *u8, cap: i64) -> i64 |
| 1198 | func of_render_diff(out: *u8, off: i64, bufa: *u8, na_bytes: i64, bufb: *u8, nb_bytes: i64) -> i64 |
| 1240 | func of_diffpage(root: *u8, base: *u8, name: *u8, va: i64, vb: i64, out: *u8, cap: i64) -> i64 |
| 1263 | func of_docpage(root: *u8, base: *u8, name: *u8, out: *u8, cap: i64) -> i64 |
| 1429 | func of_err(out: *u8, status: *u8, msg: *u8) -> i64 |
| 1447 | func of_extract_json_content(buf: *u8, n: i64, out: *u8, cap: i64) -> i64 |
| 1486 | func of_spec_to_text(spec: *u8, sl: i64, out: *u8, cap: i64) -> i64 |
| 1514 | func of_llm_complete_n(prompt: *u8, plen: i64, out: *u8, cap: i64, maxtok: i64) -> i64 |
| 1557 | func of_llm_complete(prompt: *u8, plen: i64, out: *u8, cap: i64) -> i64 |
| 1563 | func of_ai_prompt_sheet(ptext: *u8, out: *u8) -> i64 |
| 1570 | func of_ai_prompt_deck(ptext: *u8, out: *u8) -> i64 |
| 1596 | func of_agent_path(root: *u8, name: *u8, out: *u8) -> i64 |
| 1601 | func of_agent_read(root: *u8, name: *u8, buf: *u8, cap: i64) -> i64 |
| 1606 | func of_agent_write(root: *u8, name: *u8, buf: *u8, n: i64) -> i64 |
| 1612 | func of_agent_tagcount(buf: *u8, n: i64, tag: i64) -> i64 |
| 1624 | func of_agent_tagline(buf: *u8, n: i64, tag: i64, idx: i64, out: *u8, cap: i64) -> i64 |
| 1652 | func of_agent_done(buf: *u8, n: i64) -> i64 |
| 1661 | func of_agent_plan_parse(comp: *u8, cl: i64, out: *u8, cap: i64) -> i64 |
| 1733 | func of_cl_frame(out: *u8, n: i64, cap: i64) -> i64 |
| 1753 | func of_serve(root: *u8, name: *u8, vn: i64, mode: i64, out: *u8, cap: i64) -> i64 |
| 1787 | func of_parse_nv(path: *u8, pfxlen: i64, name: *u8, ncap: i64) -> i64 |
| 1811 | func of_docref(out: *u8, name: *u8) -> i64 { var o: i64 = of_cat(out, 0, "doc:" as *u8); o = of_cat(out, o, name); out[o] = 0 as u8; return o } |
| 1812 | func of_meref(out: *u8, handle: *u8) -> i64 { var o: i64 = of_cat(out, 0, "user:" as *u8); o = of_cat(out, o, handle); out[o] = 0 as u8; return o } |
| 1813 | func of_grpref(out: *u8, gname: *u8) -> i64 { var o: i64 = of_cat(out, 0, "group:" as *u8); o = of_cat(out, o, gname); out[o] = 0 as u8; return o } |
| 1815 | func of_grpmemberref(out: *u8, gname: *u8) -> i64 { var o: i64 = of_grpref(out, gname); o = of_cat(out, o, "#member" as *u8); out[o] = 0 as u8; return o } |
| 1817 | func of_tok_ok(s: *u8) -> i64 |
| 1834 | func of_sess_field(dst: *u8, off: i64, tok: *u8) -> i64 |
| 1840 | func of_deny_read(out: *u8) -> i64 { return of_err(out, "404 Not Found" as *u8, "no such file" as *u8) } |
| 1841 | func of_deny_write(out: *u8) -> i64 { return of_err(out, "403 Forbidden" as *u8, "this document is owned; you need edit access (ask the owner to share it)" as *u8) } |
| 1842 | func of_after_colon(s: *u8) -> *u8 { var i: i64 = 0; while s[i] != (0 as u8) { if (s[i] as i64) == 58 { return (s as i64 + i + 1) as *u8 } i = i + 1 } return s } |
| 1844 | func of_read_ok(azprefix: *u8, me: *u8, authed: i64, nm: *u8) -> i64 |
| 1850 | func of_write_ok(azprefix: *u8, me: *u8, authed: i64, nm: *u8) -> i64 |
| 1857 | func of_do_share(base: *u8, azprefix: *u8, me: *u8, handle: *u8, authed: i64, body: *u8, blen: i64, out: *u8, grant: i64) -> i64 |
| 1880 | func of_before_hash(dst: *u8, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { if (s[i] as i64) == 35 { dst[i] = 0 as u8; return i } dst[i] = s[i]; i = i + 1 } dst[i] = 0 as u8; return i } |
| 1882 | func of_share_row(out: *u8, off: i64, base: *u8, nm: *u8, subref: *u8, rel: *u8, tok: *u8) -> i64 |
| 1906 | func of_managepage(base: *u8, azprefix: *u8, me: *u8, authed: i64, nm: *u8, tok: *u8, out: *u8, cap: i64) -> i64 |
| 1932 | func of_do_group(base: *u8, azprefix: *u8, me: *u8, handle: *u8, authed: i64, body: *u8, blen: i64, out: *u8, add: i64) -> i64 |
| 1952 | func of_groupspage(base: *u8, azprefix: *u8, me: *u8, authed: i64, tok: *u8, out: *u8, cap: i64) -> i64 |
| 1991 | func of_collect_docs(azprefix: *u8, sub: *u8, rel: *u8, out: *i64, n: i64, cap: i64) -> i64 |
| 2004 | func of_my_docs(azprefix: *u8, me: *u8, out: *i64, cap: i64) -> i64 |
| 2024 | func of_sharedpage(base: *u8, azprefix: *u8, me: *u8, authed: i64, out: *u8, cap: i64) -> i64 |
| 2043 | func of_handle(root: *u8, base: *u8, req: *u8, reqlen: i64, out: *u8, cap: i64) -> i64 |
| 2050 | func of_handle_auth(root: *u8, base: *u8, req: *u8, reqlen: i64, out: *u8, cap: i64, handle: *u8, azprefix: *u8, tok: *u8) -> i64 |
| 2513 | func of_ck(name: *u8, cond: i64, pass: *i64, fail: *i64) -> i64 |
| 2518 | func of_selftest(root: *u8) -> i64 |