Extract chatgpt_data_residency (fallback: chatgpt_compute_residency) from
the OAuth JWT and send as x-openai-internal-codex-residency header on
requests to chatgpt.com/backend-api/codex. Residency-enforced workspaces
return 401 without this header.
Fixes#23896
Split _preflight_codex_input_items into per-item-type helpers over a
_PreflightCtx; streaming assembly moves into _CodexResponseAssembler with a
per-event dispatch table; run_codex_app_server_turn loses its session/usage/
interrupt regions to _ensure_codex_session/_finish_codex_turn/
_consume_user_interrupt/_queue_token_counts (counts built lazily so stub agents
without a session DB are never touched). Responses input/normalization and
stream callback order verified byte-identical against merge-base.