graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Every ChatGPT login is the chatgpt-new sign-in (ADR 0229)
justrachd8a349ef4f53
diff --git a/README.md b/README.mdindex 3cd18d53..9f037130 100644--- a/README.md+++ b/README.md@@ -55,7 +55,7 @@ the newest beta. Both check the download against the release's `SHA256SUMS`.<summary>Other sign-ins, installing from a checkout, and editors</summary>```sh-graff login chatgpt # ChatGPT account (same as: graff login codex)+graff login chatgpt # ChatGPT sign-in (same as: graff login codex)graff login kimigraff login zaigraff login xai@@ -193,7 +193,7 @@ live catalog.| `/plan` | read-only exploration || `/strict` | every message is a tool |-Providers: Anthropic, OpenAI, DeepSeek, xAI, Z.AI, Kimi, Codex (ChatGPT login),+Providers: Anthropic, OpenAI, DeepSeek, xAI, Z.AI, Kimi, ChatGPT plan, Codex,Vercel, OpenRouter, MiniMax, Xiaomi, Groq, Cerebras, Mistral, plus oneworkspace router in `.graff/.config.router`. `graff models refresh` pulls thecatalogs. Claude-subscription OAuth is deliberately not supported.diff --git a/docs/adr/0229-every-chatgpt-login-is-chatgpt-new.md b/docs/adr/0229-every-chatgpt-login-is-chatgpt-new.mdnew file mode 100644index 00000000..da0a3f97--- /dev/null+++ b/docs/adr/0229-every-chatgpt-login-is-chatgpt-new.md@@ -0,0 +1,45 @@+# 0229. Every ChatGPT login is the `chatgpt-new` sign-in++Status: accepted 2026-10-01. Replaces the "Codex first" decision in ADR 0221.++## Context++ADR 0221 shipped the ChatGPT plan's sign-in for open-source apps as an opt-in+`chatgpt-new` provider and kept Codex the primary ChatGPT route until a change+on OpenAI's side forced the switch: `chatgpt` named the Codex login, and+`codex` preceded `chatgpt-new` in the provider table, so a bare model name and+the startup default resolved to Codex when both were signed in.++That change has come: the login through the Codex CLI's client no longer+works for graff. The sign-in for open-source apps is OpenAI's documented route+and the one that does.++OpenAI still refuses every refresh of the new sign-in with `invalid_grant`+([report](../upstream/openai-sign-in-refresh-invalid-grant.md)). The+documented refresh request is unchanged, and so are the other open-source+clients of the flow.++## Decision++- Every ChatGPT login name, `codex` included (`chatgpt`, `codex`, `openai`,+ `gpt`, `oai`), runs the `chatgpt-new` sign-in in `graff login`, `/login`+ and `graff logout` (`args.loginTarget`). Bare `/login` lists one ChatGPT+ entry.+- Picking a `codex` model with no credential offers the same sign-in and+ continues on `chatgpt-new`, on that model when the route serves it and on+ its default model otherwise.+- `chatgpt-new` precedes `codex` in the provider table and its Lean, Python+ and JSON mirrors, so a bare model name both serve and the startup default+ pick it when both have a credential.+- The `codex` provider stays for a `CODEX_HOME/auth.json` the Codex CLI+ wrote, and `graff login --refresh` still renews that file. A saved or+ explicit `provider/model` keeps its route, and graff never moves a session+ between the two routes on its own.++## Consequences++Until OpenAI's refresh works, a sign-in lasts an hour. A longer session stops+with a sign-in error, and `graff login chatgpt` signs in again; a returning+sign-in reuses the registration and skips consent. What only the Codex route+serves (hosted image generation and hosted tool search, ADR 0221) needs an+existing Codex CLI login. Revisit when OpenAI's refresh works.diff --git a/docs/adr/README.md b/docs/adr/README.mdindex e36a8dc2..9f613fb1 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -255,6 +255,7 @@ record only when you need the evidence or the edge cases.| [0226](0226-codex-follows-the-catalog-effort-and-verbosity.md) | On the codex provider, graff's default `medium` effort is sent as the model catalog's default level, and the Responses body carries the catalog's `text.verbosity` (not on compaction or output-schema requests). Any other effort is sent as chosen. || [0227](0227-children-inherit-the-roots-loaded-mcp-tools.md) | A spawned child's catalog gains the MCP tools its root loaded, with full schemas (`worker_mcp.inherit` into `Agent.worker_tools`, served first by `toolsJson`). Unloaded tools stay out; children still have no load tool. || [0228](0228-read-only-child-calls-declared-read-only-mcp-tools.md) | An MCP tool is a read when its server declares `readOnlyHint: true` (`mcp.Tool.read_only`). A read-only (informational) child may call those and inherits only those from its root; undeclared MCP tools stay refused. |+| [0229](0229-every-chatgpt-login-is-chatgpt-new.md) | The Codex client's login no longer works, so every ChatGPT login name (`chatgpt`, `codex`, `openai`, `gpt`, `oai`) and the model picker run the `chatgpt-new` sign-in, and `chatgpt-new` precedes `codex` in the provider table. The `codex` provider stays for an existing Codex CLI `auth.json`. Replaces ADR 0221's "Codex first". |## When to write onediff --git a/lean-proofs/Graff/Provider.lean b/lean-proofs/Graff/Provider.leanindex 4706ee1f..d83aec38 100644--- a/lean-proofs/Graff/Provider.lean+++ b/lean-proofs/Graff/Provider.lean@@ -68,8 +68,8 @@ def specs : List Row :=, { id := "fireworks", kind := .openai, auth := .bearer, catalog := .openai }, { id := "mlx", kind := .openai, auth := .bearer }, { id := "lmstudio", kind := .openai, auth := .bearer }- , { id := "codex", kind := .responses, auth := .bearer, login := .codexDevice, catalog := .codex, subLogin := true }, { id := "chatgpt-new", kind := .responses, auth := .bearer, login := .chatgptBrowser, catalog := .openai, subLogin := true }+ , { id := "codex", kind := .responses, auth := .bearer, login := .codexDevice, catalog := .codex, subLogin := true }]def ids : List String := specs.map (·.id)diff --git a/scripts/test-pty-repl.py b/scripts/test-pty-repl.pyindex a406f150..927756f3 100755--- a/scripts/test-pty-repl.py+++ b/scripts/test-pty-repl.py@@ -76,7 +76,7 @@ def main() -> None:session.send_line("/help")session.wait_for_literal("/models [health]", start=cursor)session.wait_for_literal("/fallback [allow|remove|off]", start=cursor)- session.wait_for_literal("/login [codegraff|codex|kimi|xai|zai]", start=cursor)+ session.wait_for_literal("/login [codegraff|chatgpt|kimi|xai|zai]", start=cursor)session.wait_for_literal(base, start=cursor)session.wait_for_prompt(start=cursor)cursor = len(session.raw)diff --git a/spec/conformance.py b/spec/conformance.pyindex 90a9fd0a..05b4ecc0 100644--- a/spec/conformance.py+++ b/spec/conformance.py@@ -320,7 +320,7 @@ def check_provider() -> int:if len(PROVIDER_SPECS) != 24:raise Counterexample("provider-count", None, f"n={len(PROVIDER_SPECS)} want=24")responses = [r for r in PROVIDER_SPECS if r["kind"] == "responses"]- if [r["id"] for r in responses] != ["openai", "codex", "chatgpt-new"]:+ if [r["id"] for r in responses] != ["openai", "chatgpt-new", "codex"]:raise Counterexample("responses-vendors", None, f"{responses}")x_key = [r for r in PROVIDER_SPECS if r["auth"] == "x_api_key"]if [r["id"] for r in x_key] != ["anthropic"]:diff --git a/spec/kernels/providers.json b/spec/kernels/providers.jsonindex 95fd69b9..85a4860c 100644--- a/spec/kernels/providers.json+++ b/spec/kernels/providers.json@@ -201,20 +201,20 @@"takes_effort": false},{- "id": "codex",+ "id": "chatgpt-new","kind": "responses","auth": "bearer",- "login": "codex_device",- "catalog": "codex",+ "login": "chatgpt_browser",+ "catalog": "openai","sub_login": true,"takes_effort": false},{- "id": "chatgpt-new",+ "id": "codex","kind": "responses","auth": "bearer",- "login": "chatgpt_browser",- "catalog": "openai",+ "login": "codex_device",+ "catalog": "codex","sub_login": true,"takes_effort": false}diff --git a/spec/ref/provider.py b/spec/ref/provider.pyindex 7e853408..6a6d9948 100644--- a/spec/ref/provider.py+++ b/spec/ref/provider.py@@ -53,8 +53,8 @@ SPECS: list[dict] = [row("fireworks", "openai", "bearer", catalog="openai"),row("mlx", "openai", "bearer"),row("lmstudio", "openai", "bearer"),- row("codex", "responses", "bearer", login="codex_device", catalog="codex", sub_login=True),row("chatgpt-new", "responses", "bearer", login="chatgpt_browser", catalog="openai", sub_login=True),+ row("codex", "responses", "bearer", login="codex_device", catalog="codex", sub_login=True),]diff --git a/src/agent_responses.zig b/src/agent_responses.zigindex fbfd3d44..72f0a9ff 100644--- a/src/agent_responses.zig+++ b/src/agent_responses.zig@@ -148,7 +148,7 @@ pub fn failureDiagnostic(allocator: std.mem.Allocator, provider: []const u8, fai// A spent ChatGPT plan allowance, often mid-stream (ADR 0221).if (policy.isPlanUsageLimit(failure.code)) try w.writeAll(" \xe2\x80\x94 " ++ @import("oauth_chatgpt.zig").usage_hint);// Reached only after the one refresh-and-retry could not help.- if (std.mem.eql(u8, provider, "chatgpt-new") and policy.isAuthError(failure.authText())) try w.writeAll(" \xe2\x80\x94 sign in again with `graff login chatgpt-new`");+ if (std.mem.eql(u8, provider, "chatgpt-new") and policy.isAuthError(failure.authText())) try w.writeAll(" \xe2\x80\x94 sign in again with `graff login chatgpt`");return allocator.dupe(u8, w.buffered());}@@ -164,7 +164,7 @@ test "failureDiagnostic points a spent ChatGPT plan at its usage page, a rejectetry std.testing.expectEqualStrings("subscription_sharing_invalid_user", user.authText());const signed_out = try failureDiagnostic(a, "chatgpt-new", user);defer a.free(signed_out);- try std.testing.expect(std.mem.endsWith(u8, signed_out, "sign in again with `graff login chatgpt-new`"));+ try std.testing.expect(std.mem.endsWith(u8, signed_out, "sign in again with `graff login chatgpt`"));// A message that already reads as auth keeps it; a plan limit is no sign-in.try std.testing.expectEqualStrings("Unauthorized", (ResponsesFailure{ .message = "Unauthorized", .code = "server_error" }).authText());try std.testing.expectEqualStrings("Usage limit reached.", (ResponsesFailure{ .message = "Usage limit reached.", .code = "subscription_sharing_usage_limit_exceeded" }).authText());diff --git a/src/args.zig b/src/args.zigindex 61eb28d3..46b0fe9e 100644--- a/src/args.zig+++ b/src/args.zig@@ -265,7 +265,7 @@ pub fn parse(init: std.process.Init) !Flags {if (flags.login_flag and flags.positionals.items.len > 1) {const name = flags.positionals.items[1];const target = loginTarget(name) orelse- std.process.fatal("unknown login '{s}' — graff login [codegraff|chatgpt|chatgpt-new|kimi|xai|zai]", .{name});+ std.process.fatal("unknown login '{s}' — graff login [codegraff|chatgpt|kimi|xai|zai]", .{name});flags.codex_login = std.mem.eql(u8, target, "codex");flags.kimi_login = std.mem.eql(u8, target, "kimi");flags.xai_login = std.mem.eql(u8, target, "xai");@@ -319,28 +319,28 @@ pub fn parse(init: std.process.Init) !Flags {}/// The provider a login name means, for `graff login <name>` and `/login-/// <name>` alike. codex is the ChatGPT account login, so the names people-/// reach for (chatgpt, openai, gpt, oai) land there too. Null: not a login.+/// <name>` alike. Every ChatGPT name, codex included, is the plan's sign-in,+/// chatgpt-new: the Codex client's login no longer works (ADR 0229). Null:+/// not a login.pub fn loginTarget(name: []const u8) ?[]const u8 {const aliases = [_][2][]const u8{- .{ "codex", "codex" }, .{ "chatgpt", "codex" }, .{ "openai", "codex" }, .{ "gpt", "codex" },- .{ "oai", "codex" }, .{ "codegraff", "codegraff" }, .{ "graff", "codegraff" }, .{ "kimi", "kimi" },- .{ "xai", "xai" }, .{ "grok", "xai" },+ .{ "codex", "chatgpt-new" }, .{ "chatgpt", "chatgpt-new" }, .{ "openai", "chatgpt-new" }, .{ "gpt", "chatgpt-new" },+ .{ "oai", "chatgpt-new" }, .{ "codegraff", "codegraff" }, .{ "graff", "codegraff" }, .{ "kimi", "kimi" },+ .{ "xai", "xai" }, .{ "grok", "xai" },};for (aliases) |pair| if (std.ascii.eqlIgnoreCase(name, pair[0])) return pair[1];if (@import("oauth_zai.zig").isLoginName(name)) return "zai";- if (@import("oauth_chatgpt.zig").isLoginName(name)) return "chatgpt-new"; // opt-in (ADR 0221)+ if (@import("oauth_chatgpt.zig").isLoginName(name)) return "chatgpt-new";return null;}-test "loginTarget: chatgpt and codex are one login; unknown names are not logins" {- for ([_][]const u8{ "codex", "chatgpt", "ChatGPT", "openai", "gpt", "oai" }) |name|- try std.testing.expectEqualStrings("codex", loginTarget(name).?);+test "loginTarget: every ChatGPT name, codex included, is the plan's sign-in; unknown names are not logins" {+ for ([_][]const u8{ "codex", "chatgpt", "ChatGPT", "openai", "gpt", "oai", "chatgpt-new", "chat-gpt-new" }) |name|+ try std.testing.expectEqualStrings("chatgpt-new", loginTarget(name).?);try std.testing.expectEqualStrings("codegraff", loginTarget("graff").?);try std.testing.expectEqualStrings("xai", loginTarget("grok").?);try std.testing.expectEqualStrings("kimi", loginTarget("kimi").?);try std.testing.expectEqualStrings("zai", loginTarget("zai").?);- try std.testing.expectEqualStrings("chatgpt-new", loginTarget("chatgpt-new").?);try std.testing.expect(loginTarget("chatgptt") == null);try std.testing.expect(loginTarget("") == null);}diff --git a/src/cli.zig b/src/cli.zigindex e49f31be..e4b7c66f 100644--- a/src/cli.zig+++ b/src/cli.zig@@ -78,7 +78,7 @@ pub const usage_text =\\ graff [flags] start the REPL\\ graff [-p] "prompt" one-shot: run the prompt, print the answer, exit\\ graff login get a codegraff key (device-code OAuth)- \\ graff login codex [--refresh] ChatGPT/Codex OAuth login (PKCE)+ \\ graff login chatgpt ChatGPT sign-in (also: codex, openai)\\ graff login kimi Kimi Code OAuth login (device-code)\\ graff login xai Grok/SuperGrok OAuth login (device-code)\\ graff login zai Z.AI Coding Plan OAuth logindiff --git a/src/command_catalog.zig b/src/command_catalog.zigindex 08b2e49d..26878ec2 100644--- a/src/command_catalog.zig+++ b/src/command_catalog.zig@@ -79,7 +79,7 @@ pub const commands = [_]Item{.{ .name = "/ultracode", .desc = "toggle persistent workflow mode; bare opens an on/off picker, or /ultracode on|off" },.{ .name = "/fallback", .usage = "/fallback [allow|remove|off]", .desc = "opt-in cross-provider fallback for this workspace (same-provider rollout stays on)" },.{ .name = "/key", .usage = "/key [provider secret]", .desc = "show API-key status; /key <provider> <secret> adds one live (+ Keychain)" },- .{ .name = "/login", .usage = "/login [codegraff|codex|kimi|xai|zai]", .desc = "OAuth sign-in (no key to paste); bare opens a picker (codex alias: oai; zai aliases: glm, z.ai)" },+ .{ .name = "/login", .usage = "/login [codegraff|chatgpt|kimi|xai|zai]", .desc = "OAuth sign-in (no key to paste); bare opens a picker (chatgpt aliases: codex, openai, oai; zai aliases: glm, z.ai)" },.{ .name = "/keepcontext", .desc = "toggle keeping the conversation when /model switches wire format (default on)" },.{ .name = "/effort", .desc = "reasoning depth: low|medium|high|... (codex, deepseek, codegraff; persists)" },.{ .name = "/reasoning", .desc = "alias for /effort" },diff --git a/src/commands_model.zig b/src/commands_model.zigindex 7dced15d..65fc8cb2 100644--- a/src/commands_model.zig+++ b/src/commands_model.zig@@ -340,19 +340,16 @@ pub fn tryHandle(root: *Agent, keys: *Keys, arena: Allocator, line: []const u8,if (std.mem.startsWith(u8, line, "/login")) {root.ensureStoredKeys(keys);// Interactive OAuth sign-in for the providers that have a device/PKCE- // flow (codegraff, codex/ChatGPT, kimi). Mirrors the `graff login`+ // flow (codegraff, ChatGPT, kimi). Mirrors the `graff login`// subcommands but runs in-session and pulls the fresh key into the live// Keys, so this conversation keeps going without a restart. Pure// API-key providers don't log in — they point back at /key.const rest = std.mem.trim(u8, line["/login".len..], " \t");var lit = std.mem.tokenizeAny(u8, rest, " \t");var target = lit.next() orelse "";- const refresh = while (lit.next()) |a| {- if (std.mem.eql(u8, a, "--refresh")) break true;- } else false;const login_targets = [_]PickItem{.{ .name = "codegraff", .desc = "free codegraff key (device-code OAuth)" },- .{ .name = "codex", .desc = "ChatGPT account sign-in (also: chatgpt, openai)" },+ .{ .name = "chatgpt", .desc = "ChatGPT sign-in (also: codex, openai)" },.{ .name = "kimi", .desc = "Kimi Code sign-in (device-code OAuth)" },.{ .name = "xai", .desc = "Grok / SuperGrok sign-in (device-code OAuth)" },.{ .name = "zai", .desc = "Z.AI Coding Plan sign-in (CLI OAuth)" },@@ -364,14 +361,14 @@ pub fn tryHandle(root: *Agent, keys: *Keys, arena: Allocator, line: []const u8,target = login_targets[idx].name;} else {try out.writeAll("interactive logins (OAuth \xe2\x80\x94 no key to paste):\n");- for (login_targets) |t| try out.print(" {s} /login {s:<10} {s}\n", .{ if (keys.get(t.name) != null) "\xe2\x9c\x93" else "\xc2\xb7", t.name, t.desc });+ for (login_targets) |t| try out.print(" {s} /login {s:<10} {s}\n", .{ if (keys.get(@import("args.zig").loginTarget(t.name) orelse t.name) != null) "\xe2\x9c\x93" else "\xc2\xb7", t.name, t.desc });try out.print("{s}other providers use an API key: /key <provider> <key>{s}\n", .{ style.dim, style.reset });try out.flush();return true;}}- // Same names as `graff login`: chatgpt, openai, gpt and oai are the codex login;- // chatgpt-new is the opt-in plan sign-in (ADR 0221).+ // Same names as `graff login`: every ChatGPT name, codex included, is+ // the plan's sign-in, chatgpt-new (ADR 0229).target = @import("args.zig").loginTarget(target) orelse target;const home = root.home;@@ -382,12 +379,6 @@ pub fn tryHandle(root: *Agent, keys: *Keys, arena: Allocator, line: []const u8,try out.flush();return true;};- } else if (std.mem.eql(u8, target, "codex")) {- oauth.codexLogin(root.io, root.gpa, arena, home, refresh) catch |err| {- try out.print("\xe2\x9c\x97 codex login failed: {t}\n", .{err});- try out.flush();- return true;- };} else if (std.mem.eql(u8, target, "kimi")) {oauth.kimiLogin(root.io, root.gpa, arena, home) catch |err| {try out.print("\xe2\x9c\x97 kimi login failed: {t}\n", .{err});@@ -419,7 +410,7 @@ pub fn tryHandle(root: *Agent, keys: *Keys, arena: Allocator, line: []const u8,try out.flush();return true;}- try out.print("can't log into '{s}' \xe2\x80\x94 try /login codegraff | chatgpt | chatgpt-new | kimi | xai | zai (others: /key <provider> <key>)\n", .{target});+ try out.print("can't log into '{s}' \xe2\x80\x94 try /login codegraff | chatgpt | kimi | xai | zai (others: /key <provider> <key>)\n", .{target});try out.flush();return true;}diff --git a/src/oauth_chatgpt.zig b/src/oauth_chatgpt.zigindex d3719b6f..e15ddcff 100644--- a/src/oauth_chatgpt.zig+++ b/src/oauth_chatgpt.zig@@ -367,14 +367,14 @@ fn finish(io: Io, gpa: Allocator, arena: Allocator, home: []const u8, saved: ?Refn report(out: *Io.Writer, o: Outcome) !void {switch (o.state) {.first, .ok => try out.print("✓ signed in to ChatGPT as {s}; plan usage is on. Use it with /model chatgpt-new or `graff --model chatgpt-new/gpt-6.1-sol`. Manage usage: {s}\n", .{ o.account, manage_usage_url }),- .noplan => try out.print("✓ signed in to ChatGPT as {s}, but plan usage was not allowed. Run `graff login chatgpt-new` again and allow it, or use an API key.\n", .{o.account}),+ .noplan => try out.print("✓ signed in to ChatGPT as {s}, but plan usage was not allowed. Run `graff login chatgpt` again and allow it, or use an API key.\n", .{o.account}),.denied => try out.writeAll("✗ ChatGPT sign-in was cancelled. Nothing changed.\n"),.@"error" => try out.print("✗ ChatGPT sign-in failed: {s}\n", .{o.detail}),}try out.flush();}-/// `graff login chatgpt-new`: open the browser, wait for the loopback callback,+/// `graff login chatgpt`: open the browser, wait for the loopback callback,/// answer it with the branded page, and save the record.pub fn login(io: Io, gpa: Allocator, arena: Allocator, home: []const u8) !void {var obuf: [4096]u8 = undefined;diff --git a/src/picker_auth.zig b/src/picker_auth.zigindex 88ea39f0..19f8c3ad 100644--- a/src/picker_auth.zig+++ b/src/picker_auth.zig@@ -293,6 +293,9 @@ pub fn offerProviderAuth(return;}+ // The Codex client's login no longer works (ADR 0229): a codex seat signs+ // in through the ChatGPT sign-in and continues on chatgpt-new.+ const seat_pid = if (std.mem.eql(u8, pid, "codex") and std.mem.eql(u8, picked, "log in (OAuth)")) "chatgpt-new" else pid;if (std.mem.eql(u8, picked, "log in (OAuth)")) {const home = root.home;try out.flush(); // hand stdout to the login flow's own writer@@ -302,12 +305,6 @@ pub fn offerProviderAuth(try out.flush();return;};- } else if (std.mem.eql(u8, pid, "codex")) {- oauth.codexLogin(root.io, root.gpa, arena, home, false) catch |err| {- try out.print("\xe2\x9c\x97 codex login failed: {t}\n", .{err});- try out.flush();- return;- };} else if (std.mem.eql(u8, pid, "kimi")) {oauth.kimiLogin(root.io, root.gpa, arena, home) catch |err| {try out.print("\xe2\x9c\x97 kimi login failed: {t}\n", .{err});@@ -326,14 +323,14 @@ pub fn offerProviderAuth(try out.flush();return;};- } else if (std.mem.eql(u8, pid, "chatgpt-new")) {+ } else if (std.mem.eql(u8, seat_pid, "chatgpt-new")) {@import("oauth_chatgpt.zig").login(root.io, root.gpa, arena, home) catch |err| {try out.print("\xe2\x9c\x97 chatgpt login failed: {t}\n", .{err});try out.flush();return;};}- reloadLoginKey(root, keys, arena, pid);+ reloadLoginKey(root, keys, arena, seat_pid);} else {try out.print("paste your {s} API key, then Enter (input is hidden; blank cancels): ", .{pid});try out.flush();@@ -351,12 +348,17 @@ pub fn offerProviderAuth(}// Auth done — switch now if the key/login took, else keep the current model.+ // A codex seat moved to chatgpt-new keeps its model when that route serves it.+ const seat_spec = provider_mod.specFor(seat_pid) orelse spec;+ const seat_default = pricing.providerDefaultModel(seat_pid, seat_spec.default_model);const selected_model = if (default_selection and std.mem.eql(u8, pid, "codex"))- pricing.providerDefaultModel(pid, spec.default_model)+ seat_default+ else if (!std.mem.eql(u8, seat_pid, pid) and !pricing.providerModelInTable(seat_pid, model))+ seat_defaultelsemodel;- const provider = keys.providerById(pid, selected_model) catch {- try out.print("still no usable key for {s} — kept {s}{s}{s}\n", .{ pid, style.accent, root.provider.model, style.reset });+ const provider = keys.providerById(seat_pid, selected_model) catch {+ try out.print("still no usable key for {s} — kept {s}{s}{s}\n", .{ seat_pid, style.accent, root.provider.model, style.reset });try out.flush();return;};diff --git a/src/provider.zig b/src/provider.zigindex ef717a7a..d574ed33 100644--- a/src/provider.zig+++ b/src/provider.zig@@ -125,16 +125,17 @@ pub const provider_specs = [_]ProviderSpec{// lm-studio: the LM Studio app's local OpenAI-compatible server (default :1234).// Load a model in LM Studio, then `LMSTUDIO_API_KEY=local graff --model lmstudio`..{ .id = "lmstudio", .display_name = "lmstudio", .kind = .openai, .auth = .bearer, .url = "http://127.0.0.1:1234/v1/chat/completions", .env_key = "LMSTUDIO_API_KEY", .default_model = "lmstudio" },+ // chatgpt-new: the person's ChatGPT plan through OpenAI's sign-in for+ // open-source apps (ADR 0221). The key is the OAuth access token saved by+ // `graff login chatgpt`, sent to the public Responses endpoint. Before+ // codex on purpose: it is the primary ChatGPT route (ADR 0229), so a bare+ // model name and the startup default pick it when both are signed in.+ .{ .id = "chatgpt-new", .display_name = "ChatGPT plan (new sign-in)", .kind = .responses, .auth = .bearer, .url = "https://api.openai.com/v1/responses", .env_key = "CHATGPT_NEW_DISABLED", .default_model = "gpt-6.1-sol", .login = .chatgpt_browser, .sub_login = true, .catalog = .openai, .models_url = "https://api.openai.com/v1/models?client_version=0.159.0" },// codex: ChatGPT login via the Responses API. Its "key" isn't an env var// — it's the OAuth access token read from CODEX_HOME/auth.json at startup// (see loadCodexAuth), the same on-disk-credential trick used for the// codegraff gateway key in ~/forge/.credentials.json..{ .id = "codex", .display_name = "Codex (ChatGPT)", .kind = .responses, .auth = .bearer, .url = "https://chatgpt.com/backend-api/codex/responses", .env_key = "CODEX_DISABLED", .default_model = "gpt-5.6-sol", .login = .codex_device, .sub_login = true, .catalog = .codex },- // chatgpt-new: the person's ChatGPT plan through OpenAI's sign-in for- // open-source apps (ADR 0221). The key is the OAuth access token saved by- // `graff login chatgpt-new`, sent to the public Responses endpoint. After- // codex on purpose: Codex stays the primary ChatGPT route (spec order).- .{ .id = "chatgpt-new", .display_name = "ChatGPT plan (new sign-in)", .kind = .responses, .auth = .bearer, .url = "https://api.openai.com/v1/responses", .env_key = "CHATGPT_NEW_DISABLED", .default_model = "gpt-6.1-sol", .login = .chatgpt_browser, .sub_login = true, .catalog = .openai, .models_url = "https://api.openai.com/v1/models?client_version=0.159.0" },};/// Optional workspace-local router loaded from `.graff/.config.router`.diff --git a/src/route_check.zig b/src/route_check.zigindex 70b77311..6d812643 100644--- a/src/route_check.zig+++ b/src/route_check.zig@@ -129,8 +129,9 @@ test "seatFor: family-alias spelling seats the sub, exact names hold, unknown mitry std.testing.expectEqualStrings("kimi", kk.seat.pid);try std.testing.expectEqualStrings("k3", kk.seat.model);try std.testing.expectEqual(pricing.Billing.sub, kk.seat.billing);+ // ADR 0229: with both ChatGPT routes signed in, the plan's sign-in wins.const sol = seatFor(all, "gpt-5.6-sol");- try std.testing.expectEqualStrings("codex", sol.seat.pid);+ try std.testing.expectEqualStrings("chatgpt-new", sol.seat.pid);try std.testing.expectEqual(pricing.Billing.sub, sol.seat.billing);try std.testing.expect(seatFor(all, "totally-unknown-zzz") == .unknown);diff --git a/src/startup.zig b/src/startup.zigindex 4cafa2eb..bcbe3715 100644--- a/src/startup.zig+++ b/src/startup.zig@@ -314,19 +314,21 @@ pub fn runSubcommand(io: Io, gpa: Allocator, arena: Allocator, init: std.process// `harness login [name] [--refresh]`: OAuth login. Default target is// codegraff (device-code flow, writes ~/.simple-harness-codegraff.json);- // `chatgpt` or `codex` (or --refresh) runs the ChatGPT PKCE/refresh flow →- // ~/.codex/auth.json. args.loginTarget owns the names.+ // `chatgpt` is the plan's sign-in (chatgpt-new, ADR 0229); `codex` (or+ // --refresh) runs the Codex PKCE/refresh flow → ~/.codex/auth.json.+ // args.loginTarget owns the names.if (flags.login_flag) {const home = keys_cli.homeEnv(init.environ_map) orelse std.process.fatal("no HOME/USERPROFILE", .{});if (flags.chatgpt_login) try @import("oauth_chatgpt.zig").login(io, gpa, arena, home) else if (flags.xai_login) try oauth.xaiLogin(io, gpa, arena, home) else if (flags.kimi_login) try oauth.kimiLogin(io, gpa, arena, home) else if (flags.zai_login) try oauth.zaiLogin(io, gpa, arena, home) else if (flags.codex_login or flags.refresh_flag) try oauth.codexLogin(io, gpa, arena, home, flags.refresh_flag) else try oauth.codegraffLogin(io, gpa, arena, home);return true;}- // `graff logout chatgpt-new`: revoke the plan's refresh token, clear the tokens.+ // `graff logout chatgpt`: revoke the plan's refresh token, clear the tokens.if (flags.positionals.items.len > 0 and std.mem.eql(u8, flags.positionals.items[0], "logout")) {const home = keys_cli.homeEnv(init.environ_map) orelse std.process.fatal("no HOME/USERPROFILE", .{});const target = if (flags.positionals.items.len > 1) flags.positionals.items[1] else "";- if (!@import("oauth_chatgpt.zig").isLoginName(target)) std.process.fatal("graff logout supports: chatgpt-new", .{});+ const plan = std.mem.eql(u8, @import("args.zig").loginTarget(target) orelse "", "chatgpt-new");+ if (!plan) std.process.fatal("graff logout supports: chatgpt", .{});try @import("oauth_chatgpt.zig").logout(io, gpa, arena, home);return true;}