nx_aimode_lib.nx
buildroot/runtime/nx_aimode_lib.nx
about
nx_aimode_lib.nx -- BR50: read a Google AI Mode share link as its ANSWER TEXT, never as a script shell.
WHAT THE WIRE SHOWS (measured 2026-09-18/19 with the CDP oracle ac_cdp/aimode_oracle over the operator's
share https://share.google/aimode/vVS1jO66c6HI3D4YN, network capture + DOM poll):
* share.google/aimode/<id> --302--> www.google.com/share.google?q=aimode/<id> --301-->
www.google.com/search?...&udm=50... (a 92,807 B script shell, title "Google Search", noscript
enable-JS redirect, five scripts, NO answer text). A COLD fetch of that /search url (no cookies)
returns the same shell -- proven twice sovereignly (nx_research_fetch).
* The FIRST /search response SETS cookies. A SECOND, cookie-WARMED GET of the same /search url
(the oracle's idx=1, cookie_header_len 0->1812) returns a 406,554 B server-rendered document that
is NOT the shell: it carries the AI Mode streaming containers AND, server-rendered as plain text in
its markup, the continuation URL /async/folwr?... (garc/mlro/elrc/_xsrf tokens all present -- 12
hits; the cold shell has ZERO). NO JavaScript computed those tokens: they are in the SSR HTML.
* A GET of that /async/folwr url (with the same cookie jar) returns a 1,452,920 B HTML fragment that
carries the WHOLE conversation's answer prose ("Neo-Hookean", "Hyperelastic", "Tyranny",
"Neuromorphic", "Tesla" all present). This is the ANSWER, delivered in ONE synchronous response --
no streaming wait is needed on the sovereign side (the referee browser waits; we do not).
* The oracle was NOT signed in ("Sign in" in the nav) and no request that carries the answer is a POST
or a batchexecute with a JS-signed body: every answer-bearing request is a plain same-origin GET.
SO THE SOVEREIGN PATH IS THREE COOKIE-SHARING GETs, no js_eval (BR3), no signed session:
PASS A follow share.google -> ... -> /search (cold), collecting Set-Cookie into a jar, capture final url
PASS B warm GET the final /search url WITH the jar -> extract the /async/folwr continuation url
PASS C GET /async/folwr WITH the jar -> the answer HTML fragment -> nx_html_to_text
A sign-in / consent wall is a NAMED refusal; a shell that never yields a continuation or answer is
REFUSED-NO-ANSWER by name; an empty body is REFUSED-EMPTY-BODY.
COMPOSES INCUMBENTS, DUPLICATES NOTHING: the TLS-1.3 session, redirect Location resolution, cookie jar,
gzip and chunked decoders are the estate's (nx_https_fetch_follow's ff_path/ff_resolve_location/
ff_collect_cookies/ff_gunzip, nx_https_get_complete's req driver, nx_http_response_parse/nx_http_dechunk,
nx_https_redirect). This file writes only the jar-keeping loop those helpers were never wired into, and
the answer parser. ms_find (balanced-substring) is nx_media_state's.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 6 imports · 2 importers
imports: nx_syscalls.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_fetch_follow.nxnx_html_to_text.nxnx_media_state.nx
imported by: nx_aimode_read.nxnx_aimode_read_gate.nx
structs
| none |
consts
| 45 | const AM_OK: i64 = 0 |
| 46 | const AM_SIGNIN: i64 = 10 // REFUSED-SIGNIN |
| 47 | const AM_CONSENT: i64 = 11 // REFUSED-CONSENT-WALL |
| 48 | const AM_NO_ANSWER: i64 = 12 // REFUSED-NO-ANSWER (shell never populated / async carried no answer) |
| 49 | const AM_EMPTY: i64 = 13 // REFUSED-EMPTY-BODY |
| 50 | const AM_FETCH: i64 = 14 // a pass could not fetch at all (connect/handshake/parse) |
| 51 | const AM_NOFINAL: i64 = 15 // redirects never settled on a 200 |
| 52 | const AM_NOCONT: i64 = 16 // warm doc carried no /async/folwr continuation AND no inline answer |
| 55 | const AM_RAW: i64 = 12582912 // 12 MB raw response reserve per hop (async decoded ~1.45MB; gzip smaller) |
| 56 | const AM_JAR: i64 = 8192 // cookie jar (n=v; n=v) |
| 57 | const AM_URL: i64 = 16384 // a resolved url (google search urls are long) |
| 58 | const AM_HOPS: i64 = 8 // share.google->/share.google->/search is 2; head-room for extra bounces |
| 59 | const AM_MINANS: i64 = 400 // an answer shorter than this is not an answer (a shell yields ~little text) |
| 61 | const AM_CHROME_UA: *u8 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36" |
| 122 | const AM_HOP_REDIR: i64 = 0 - 1 |
functions
| 63 | func am_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 64 | func am_cat(dst: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[o] = s[i]; o = o + 1; i = i + 1 } return o } |
| 65 | func am_catn(dst: *u8, o: i64, v: i64) -> i64 |
| 75 | func am_has_ci(buf: *u8, n: i64, pat: *u8) -> i64 |
| 97 | func am_build_get(req: *u8, host: *u8, hlen: i64, path: *u8, plen: i64, jar: *u8, jl: i64, xhdr: *u8) -> i64 |
| 123 | func am_hop(urlbuf: *u8, store: *TrustStore, jar: *u8, jl: *i64, xhdr: *u8, |
| 181 | func am_follow(start_url: *u8, store: *TrustStore, jar: *u8, jl: *i64, xhdr: *u8, |
| 210 | func am_extract_folwr(doc: *u8, n: i64, out: *u8) -> i64 |
| 261 | func am_citations(doc: *u8, n: i64, sink: *u8, sink_cap: i64) -> i64 |
| 300 | func am_is_shell(buf: *u8, n: i64) -> i64 |
| 304 | func am_is_signin(buf: *u8, n: i64) -> i64 |
| 309 | func am_is_consent(buf: *u8, n: i64) -> i64 |
| 315 | func am_dbg(a: *u8, x: i64, b: *u8, y: i64, c: *u8, z: i64) -> i64 |
| 321 | func am_dbg_url(a: *u8, u: *u8) -> i64 { sys_write(2, a, am_slen(a)); sys_write(2, u, am_slen(u)); sys_write(2, "\n" as *u8, 1); return 0 } |
| 327 | func br_share_read(share_url: *u8, store: *TrustStore, out: *u8, out_cap: i64, |