@@ -156,28 +156,34 @@ export function buildLlmIdentityHeaders(id: ProxyIdentity): Record<string, strin
156156}
157157
158158/**
159- * Context-shaped identity headers — mirrors the 3.12.3 host builder `TV`
159+ * Context-shaped identity headers — mirrors the host builder
160+ * `TV` (3.12.3 chunk-ZH56ETHO) / `c5` (3.14.0 chunk-WFF5YMZO) / bundle `IJt`
160161 * (buildZCodeSourceHeadersFromContext), reached via the endpoint-routing
161- * source-headers factory (`V6n`). 3.12.3 changes vs 3.11: X-ZCode-Agent is
162- * GONE from this plane, and language/timezone are always present with the
163- * "unknown" fallback. Consumers: endpoint-routing.ts (source headers),
164- * claim/client.ts, routes-quota.ts, async bridge.
162+ * source-headers factory (`V6n`). X-ZCode-Agent is GONE from this plane, and
163+ * language/timezone are always present with the "unknown" fallback. Consumers:
164+ * endpoint-routing.ts (source headers), claim/client.ts, routes-quota.ts ,
165+ * async bridge.
165166 *
166- * Order (bundle `TV`):
167- * HTTP-Referer, User-Agent, [X-ZCode-App-Version], X-Title, [X-Platform],
167+ * Order — RUNTIME INSERTION order, not source written order (2026-09-19
168+ * correction, `_reverse/NOTEPAD.md` §E): the official builder spreads a
169+ * 3-key base first (`yE`/`cU`/`Llr` = `{"User-Agent","HTTP-Referer","X-Title"}`)
170+ * and then overrides/adds keys. JS spread semantics keep overridden keys at
171+ * their base positions, so the wire order is:
172+ * User-Agent, HTTP-Referer, X-Title, [X-ZCode-App-Version], [X-Platform],
168173 * [X-Release-Channel], X-Client-Language, X-Client-Timezone,
169174 * [X-Os-Category], [X-Os-Version], [X-Device-Mid]
175+ * (verified byte-level against both the 3.12.3 and 3.14.0 bundles/hosts).
170176 *
171177 * Returns `Record<string, string>` rather than a fixed interface because
172178 * several headers are conditionally omitted.
173179 */
174180export function buildIdentityHeaders ( id : ProxyIdentity ) : Record < string , string > {
175181 const v = resolveIdentityValues ( id ) ;
176182 return {
177- "HTTP-Referer" : id . refererOrigin ,
178183 "User-Agent" : `ZCode/${ v . n ?? "unknown" } ` ,
179- ... ( v . n ? { "X-ZCode-App-Version " : v . n } : { } ) ,
184+ "HTTP-Referer " : id . refererOrigin ,
180185 "X-Title" : `Z Code@${ id . sourceTitle } ` ,
186+ ...( v . n ? { "X-ZCode-App-Version" : v . n } : { } ) ,
181187 ...( v . platform && v . arch ? { "X-Platform" : `${ v . platform } -${ v . arch } ` } : { } ) ,
182188 ...( v . releaseChannel ? { "X-Release-Channel" : v . releaseChannel } : { } ) ,
183189 "X-Client-Language" : v . clientLanguage ?? "unknown" ,
0 commit comments