Repository navigation
feat(claude): limit resets through Claude Code's interactive UI - #752
Conversation
inspectLimitResets lists them and redeemLimitReset (resetId names a kind) spends one by driving the hidden /limit-reset command in a pseudo-terminal, since Claude Code 2.1.322 has no -p, SDK or control-protocol form. Reverses the 2026-11-10 refusal at the project owner's direction; the driver, its screen recognisers and tests are ported from Raft's daemon. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
CHANGES at
The source comparison found the requested Two contract/documentation corrections also matter: No real account, reset, login or paid inference was used in this review. macOS execution remains unverified by this review.
|
Match the whole confirmation dialog, not only its title and Yes row; keep every idempotency key that typed a command for the life of the process; give a call waiting for the UI slot its own deadline; end a terminal's processes that outlived the program (environment marker on Linux, the program's group elsewhere); keep the screen fixtures LF on Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
b095323 to
0ba3ce6
Compare
|
CHANGES at
Please also narrow the new spec sentence saying that the marker ends “every process it started”: the existing marker mechanism explicitly cannot find a detached process that discarded its inherited environment. Describe the observed-tree and retained-marker boundary rather than an unconditional guarantee. Validation: 91 targeted tests passed, including all original review counterexamples, Codex reset tests and the new real Linux
|
|
Additional native result for xxair ran the portable synthetic terminal probe on macOS27.0 (26A428), arm64, Node26.10.0, pnpm11.22.0. The helper exited in about13ms before the synthetic CLI wrote its child PID. A direct launch using the same {"case":"scriptInvocation_startup","detached":true,"stdio":["pipe","pipe","pipe"],"exitCode":1,"signal":null,"stdout":"","stderr":"script: tcgetattr/ioctl: Operation not supported on socket\n"}
[P1] Make the advertised macOS path launch through a compatible transport, or report it unsupported. The current
|
The shell under script now ends the program's session when the program exits, so a child left behind is gone before script exits, observed or not. A process group counts as the program's only while a process seen earlier is still in it, and nothing is looked up below script once it exited, so a reused pid or group id never authorizes a kill. macOS is unsupported_platform: its BSD script exits when stdin is a socket, which Node pipes are there (found by xxair on macOS 27.0). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Re-review of
The previously checked one-Yes rule, inspection refusal to confirm, explicit-false consent guard and Promise reuse remain intact. Codex implementation is unchanged; the expanded public result/reason unions still need the planned release note for hosts with exhaustive switches. Non-blocking comment cleanup: CI and merge remain with the author. Approval is for this exact head and the documented Linux-only scope.
|
<!-- stamp:review:v1 --> <sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg" width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_ab238713ca1834e477cdf55ade43ffdb"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp →</a></sup> --- <!-- /stamp:review:v1 --> Claude limit resets through Claude Code's own interactive UI, and usage windows that say which model they count. ## Claude: limit resets (#752) - New optional member `Runtime.inspectLimitResets(installation, options?)` (Claude only) lists the account's resets per kind: `weekly`, `fable`, `full`, and `five_hour` only with `includeFiveHour: true`. Each kind is `available` (with `resetsLeft` and `expiresText`), `none`, `not_offered`, `unknown` or `not_checked`; the result also carries the Claude Code `version`, and `program: "legacy"` / `fiveHourSpent: true` when the older program answered. - `claudeRuntime` now has `redeemLimitReset(installation, { idempotencyKey, resetId })`; for Claude `resetId` is required and names the kind. Claude's `accountUsage` still reports no `limitResets`: list them with `inspectLimitResets`, not from the usage snapshot. - Claude Code 2.1.322 has no `-p`, SDK or control-protocol form, so OAR drives the hidden `/limit-reset <kind>` command in a pseudo-terminal (the system `script`) and reads the screen. Every screen must match the recorded text word for word apart from dates, counts and percentages (the whole confirmation dialog included); anything else ends the attempt with Esc. Yes is sent at most once, never while inspecting. - At the 5-hour limit, Claude's older reset program spends its reset as soon as any `/limit-reset` opens. Without `fiveHourLimitConsent: true`, OAR reads usage right before the first command and types nothing when the account is at the limit (`consent_required`) or the read fails (`not_attempted` / `usage_unread`). A `weekly`, `fable` or `full` redeem without consent also needs Claude Code's cached feature flags to show the newer reset program, and otherwise answers `consent_required`. A `five_hour` redeem is itself the consent. - An idempotency key is remembered for the life of the process once its attempt typed a command: the same key gets the first answer, never a second Yes; the same key with another `resetId` rejects. An attempt that sent nothing is not remembered. Claude answers a timeout with `not_attempted` or `unknown` instead of rejecting (Codex still rejects). - Each call starts Claude Code's UI, which sends one 1-token model request at startup; on a subscription it likely counts as usage. `inspectLimitResets` is not a passive read: call it on the account owner's request and never poll it. - Linux only, with the system `script` (util-linux) available; anywhere else, or without it, the answer is `unsupported_platform`. (macOS's BSD `script` exits when its stdin is a socket, which Node pipes are there.) - Evidence: the screen recognisers come from Raft's offline harness, which drove the real 2.1.322 UI against a fake backend; the real server's Fable and full screens are unverified, and no real account's reset has been spent through OAR. **Source compatibility.** New exported types: `LimitResetInspection`, `LimitResetInspectOptions`, `LimitResetInspector`, `LimitResetKindStatus`, `LimitResetNotAttemptedReason`, `LimitResetUnsupportedReason`, `AccountUsageWindowScope`; new option `LimitResetOptions.fiveHourLimitConsent`. `LimitResetResult` gains `not_attempted` (`busy`, `deadline`, `usage_unread`, `startup_failed`) and `unknown` (optionally `fiveHourSpent`), and its `unsupported` reason is now typed `LimitResetUnsupportedReason` (the account-usage reasons plus `unsupported_platform`, `unsupported_version`, `reset_id_required`, `consent_required`). Codex's behavior is unchanged, but a host with an exhaustive `switch` over these unions, or one that assigns the reason to `AccountUsageUnsupportedReason`, needs updating. A host that offered redeem only where `redeemLimitReset` exists now sees it on Claude too. `oar list` gains an `inspectLimitResets` key. ## Account usage: window scope (#753) - `AccountUsageWindow.scope`: `{ kind: "account" }` when the runtime reports the window as the account's, `{ kind: "model", name }` when it reports it as one model's, with the runtime's own name kept as given (Claude "Opus", "Sonnet", "Fable"; Codex `limitName`, which can be a quota alias such as `gpt-reserve`). Omitted, meaning unknown, where the runtime says neither (Claude's OAuth apps window, Codex's other unnamed buckets, Kimi's name-only rows). - `scope` says what a window counts, not whether a full one stops work: extra usage can carry Claude, Grok and Kimi accounts past a full subscription window, which `rateLimited` already weighs. Also in this release: spawn validation errors no longer echo a rejected argument or environment value (#751). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Cindy <[email protected]>
Claude limit resets through Claude Code's own interactive UI:
inspectLimitResetslists them andredeemLimitReset(with aresetIdnaming a kind) spends one.This reverses the 2026-11-10 refusal (#721). The project owner decided that if a host offers this at all, the driver belongs in OAR: Raft had already built it inside its daemon, pinned to Claude Code 2.1.322 and Linux, and it broke at every update. Claude Code 2.1.322 still has no
-p, SDK or control-protocol form (itsget_usagereads/api/oauth/usagewithout the reset parameters), and the upstream request anthropics/claude-code#108851 has no answer.decisions.mdrecords the reversal and when to move to a native form.The driver is Raft's (
claudeLimitReset.ts,claudeLimitResetScreens.ts,claudeTerminalScreen.ts,claudeLimitResetTerminal.ts), ported with its 66 unit tests and the screen fixtures recorded from the real 2.1.322 UI against a fake backend. Its safety rules carry over unchanged: the command always names a kind; keys reach a dialog only after it held still 600 ms; one Yes at most, only with 30 s left for the answer, never in an inspection; any unrecognised screen ends the attempt with Esc; at the 5-hour limit nothing is typed without the person's consent (the older program spends on open); idempotency keys are remembered for the life of the process.Changes from Raft's version:
Claude Code v<version>banner, and every screen must match word for word; the banner's version is reported.scriptexits at once when its stdin is a socket, which Node pipes are there (found by xxair on macOS 27.0); macOS and Windows areunsupported_platformuntil a follow-up gives it a real pipe.accountUsage, right before the first command.redeemLimitResettakesfiveHourLimitConsenttoo, so a person at the 5-hour limit can spend afullreset knowingly.not_attempted(busy,deadline,usage_unread,startup_failed),unknown(withfiveHourSpent),unsupported(unsupported_platform,unsupported_version,reset_id_required,consent_required,endpoint_unavailablefor "Unknown command"). The same key with anotherresetIdrejects.shared/executable/script-terminal.ts, with its spawn insidespawnChecked.scriptends the program's session when it exits, a group counts only while a process seen earlier is still in it, nothing is looked up belowscriptafter it exited, and the Linux environment marker ends what still carries it.Contract:
Runtime.inspectLimitResets,LimitResetInspection,LimitResetKindStatus, new result kinds and reasons inLimitResetResult. Codex is unchanged.Known cost, documented: the interactive UI sends one 1-token model request at startup (seen in the harness; magpie notes it can open a 5-hour window on an idle subscription). OAR does not suppress it.
Not in this PR: the offline harness (fake backend + scenarios in a network namespace) moves into OAR next; no real account's reset has been spent through OAR.
Docs:
docs/spec/account-usage.md#claude-limit-resets,docs/runtimes/claude.md#limit-resets,docs/design/decisions.md, capabilities, roadmap, README.🤖 Generated with Claude Code