From eb19fd812e15de5a6930daf2fcd0b2b0757687c7 Mon Sep 17 00:00:00 2001 From: t Date: Sat, 13 Jun 2026 12:22:18 -0600 Subject: auth: openai_responses provider for Codex subscription (Tier 2) Add the OpenAI Responses API wire dialect (openai_responses APIStyle + OpenAIResponsesConfig), a request serializer (instructions/input items, flat function tools, reasoning, store:false, include encrypted reasoning), and a streaming state machine over the typed response.* SSE events mapping to the shared block model. Wire dispatch, buildProviderConfig, the C-ABI free switch, and the reasoning selectors. Ship a commented Codex example in the default config. Implemented from the Responses API docs + the open-source Codex client and covered by fixture tests; live verification against a ChatGPT plan is still required (documented). --- src/tui_selectors.zig | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/tui_selectors.zig') diff --git a/src/tui_selectors.zig b/src/tui_selectors.zig index a37acb8..590d321 100644 --- a/src/tui_selectors.zig +++ b/src/tui_selectors.zig @@ -48,7 +48,10 @@ pub const ReasoningOption = struct { detail: []const u8, value: Value, - pub const Value = union(APIStyle) { + /// Two payload families, decoupled from `APIStyle`: `openai_chat` carries + /// a `reasoning` effort (shared by the `openai_chat` and `openai_responses` + /// styles), `anthropic_messages` carries a thinking selection. + pub const Value = union(enum) { /// OpenAI `reasoning` enum value. openai_chat: ReasoningEffort, /// Anthropic thinking selection: either disabled, or adaptive at an @@ -85,7 +88,8 @@ pub const ReasoningOption = struct { /// The reasoning options offered for a provider config's API style. pub fn forStyle(style: APIStyle) []const ReasoningOption { return switch (style) { - .openai_chat => &openai, + // The Responses style takes the same reasoning-effort options. + .openai_chat, .openai_responses => &openai, .anthropic_messages => &anthropic, }; } @@ -95,6 +99,7 @@ pub const ReasoningOption = struct { switch (self.value) { .openai_chat => |r| switch (cfg.*) { .openai_chat => |*c| c.reasoning = r, + .openai_responses => |*c| c.reasoning = r, .anthropic_messages => {}, }, .anthropic_messages => |sel| switch (cfg.*) { @@ -105,7 +110,7 @@ pub const ReasoningOption = struct { c.effort = e; }, }, - .openai_chat => {}, + .openai_chat, .openai_responses => {}, }, } } @@ -114,7 +119,8 @@ pub const ReasoningOption = struct { /// preselect the picker on the active value). pub fn matches(self: ReasoningOption, cfg: ProviderConfig) bool { switch (self.value) { - .openai_chat => |r| return cfg == .openai_chat and cfg.openai_chat.reasoning == r, + .openai_chat => |r| return (cfg == .openai_chat and cfg.openai_chat.reasoning == r) or + (cfg == .openai_responses and cfg.openai_responses.reasoning == r), .anthropic_messages => |sel| { if (cfg != .anthropic_messages) return false; const c = cfg.anthropic_messages; @@ -167,7 +173,7 @@ pub fn adaptiveFallback(cfg: *ProviderConfig) bool { c.thinking_budget_tokens = budget; return true; }, - .openai_chat => return false, + .openai_chat, .openai_responses => return false, } } -- cgit v1.3