Repository navigation
feat(claude): expose the latest attributed model request on demand - #1060
Conversation
|
GO at 7fb9175. Read the diff (contract, Claude capture/reader, open-settings, session wiring, credential guard, vendor test). Did not run it. The shape matches the spec: opt-in, read on demand outside the control stream, attribution by Claude's own index joined to root assistant frames, fail closed (missing attribution rejects, partial body never returned, null from dispose or exit), credential redaction through the shared guard, refusals on every other adapter, and the version floor declared per installation through Non-blocking:
|
Co-authored-by: xxchan <[email protected]>
Co-authored-by: xxchan <[email protected]>
7fb9175 to
bf80518
Compare
|
GO at bf80518. Read the new commit only (the rest is unchanged from 7fb9175, now on base 94e43d1). It covers all four notes: the capture flag now merges into I will approve after the 0.125.0 tag exists, once CI is green at this head.
|
…endencies (#1071) <!-- stamp:review:v1 --> <sup><img src="https://api.raft.build/api/avatars/pixel/ZXll.svg" width="16" height="16" align="absmiddle" alt=""> <b>Lookout</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_b803efe30032eaa31fb1805a73392e4a"><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 --> ## Summary Fix `oxlint` `import/max-dependencies` (11 > 10) introduced on `main` when PR #1060 (`openClaudeModelRequests`) and PR #1061 (`closeLineProcess`) landed back-to-back in `packages/oar/src/runtimes/claude/session.ts`. Uses `globalThis.crypto.randomUUID()` (matching `packages/oar/src/runtimes/claude/account-usage.ts:186`) and removes the `node:crypto` import so `claude/session.ts` returns to 10 imports. ## Verification - Local `pnpm run typecheck && pnpm run lint`: passed with 0 errors and 0 warnings. Co-authored-by: Lookout <[email protected]>
<!-- stamp:review:v1 --> <sup><img src="https://cdn.slock.ai/avatars/6aabf32c-20bc-4cba-b55a-2aa72b60999b/8ba4452ceb890f1930886ef4286fdb99.webp" width="16" height="16" align="absmiddle" alt=""> <b>Otter</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_0b1bf9453517e141e8eadf05a736f253"><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 --> Pi SDK sessions can now opt into `modelRequests: "latest"` and read the last root model request after Pi and installed extensions have transformed its payload. A new or resumed session starts empty. The value is kept in memory, read through OAR's credential redaction, and cleared on disposal. Manual compaction leaves the last root request intact. On Pi SDK 1.5.2 the retained body matched the JSON received by a local scripted provider for Anthropic Messages, OpenAI Chat Completions and OpenAI Responses. Each test compared three turns with a user extension that replaced the payload. Pi’s Google adapter transforms the SDK parameters again before HTTP, and Pi RPC calls OAR’s extension before a user extension can replace the payload. These paths explicitly refuse capture. The native suite also covers resume, redaction, disposal and the default opt-out. The existing public contract and Claude implementation are in #1039 and #1060. Co-authored-by: Otter <[email protected]> Co-authored-by: xxchan <[email protected]>
<!-- 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_010f166b1c3ba63a625f97aa49c7a328"><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 --> ## OAR 0.126.0 ### Behavior changes hosts should know - **`installation()` refuses programs that are not the vendor CLI, and every refusal is typed** (#1084). The `unsupported` snapshot now always carries a `code`, and the old untyped variant is gone, so custom runtime probes must set one: - `version_unsupported`: the vendor CLI is outside the supported range. This is the only code admitted to `checkUpdate()` and `upgrade()`. Hosts should show every other code as a setup problem, not reinstall. - `unrecognized_executable`: the program in the slot does not identify as the vendor CLI. Identity comes from its version output, so a wrapper (for example an `OAR_CLAUDE_BIN` script) that prints a bare version is now refused; Claude must print `(Claude Code)`. - `readiness_failed`: the runtime's readiness check (`--help`, `app-server --help`, `acp --help` and the like) exited nonzero, or `--version` failed where the runtime declares an identity or version policy. - Host refusals: `unsupported_platform`, `unsupported_node_version`, `unsupported_host` (for example Pi RPC inside a single executable or Electron, or Cursor subprocess mode inside a single executable) and `dependency_missing` (a required module such as Pi's RPC entry or Cursor's SDK cannot be resolved). Cursor now refuses Node below 22.13.0 in both modes. - **OpenCode now has a version range**: `>=1.18.30 <2.0.0 || >=2.0.27 <3.0.0`. Installs below 1.18.30, at 2.0.0 to 2.0.26, or on 3.x that worked before are now `version_unsupported`. - Candidate selection changed: a refused candidate falls through to the next one, and a vendor install that is only too old wins over a refusal of another kind. Antigravity, DSH, OpenCode, Qoder and Qwen gained a `--help` readiness probe, so an uncached probe starts one more process. - **`rateLimited` means the whole account is limited** (#1073). On Codex only the account bucket and its credits set it; a single-model bucket such as Spark stays in `windows`. On Claude only the five-hour and seven-day windows set it; per-model windows and `seven_day_oauth_apps` do not, and unlimited Extra Usage counts as headroom. `usedRatio` never rounds an unexhausted reading up to 1, and on Codex it no longer exceeds 1. Codex no longer reports `reauth_required` or `unsupported` for process exits, initialize failures or timeouts, and its usage and limit-reset errors carry the native `cause`. Grok reports `reauth_required` only for ACP code `-32000`, not for any error mentioning sign-in. Codex's legacy single-bucket view gets `scope: account`. Antigravity sets `rateLimited` when every group is exhausted and credits are at or below zero. - **`plan` is the name the runtime shows the user** (#1076). Claude reads `oauthAccount.planDisplayName` when the stored account matches the signed-in one, and falls back to the native plan code otherwise. Hosts that compared `plan` against native codes such as `max` will now see display names on `authStatus`, `login` and `accountUsage`. - **Idle sessions and short-lived queries end through stdin EOF** (#1061, #1074). Claude and Codex now end an idle session, and their query processes (usage, models, skills, inventory; on Codex also limit reset and a completed login), by closing stdin and killing the tree only after the kill grace. Factory's account process does the same. A session with an active turn is still stopped at once. Qoder and Qwen share the same path, so their grace moved from a fixed 5 s to the kill grace (10 s by default, `OAR_KILL_GRACE_MS`). - **Antigravity quota notices mid-turn fail the turn as `quota` with `resetsAt`** (#1068), after earlier tool work too. Normal text that quotes the notice still completes. ### New - **Credentials declared for every runtime** (#1085). `Runtime.credentials` on all 15 built-in runtimes lists its stores (`directoryEnv`, `fallbackDirectoryEnvs`, keychain `service`), its variables with the `provider` and logical `field` each belongs to (for stripping, redaction and error attribution), `scope` (`single_account` or `per_provider`), `management` (`native`, or `external`: no native login, the person or host supplies the credential), `signInPaste`, `usageDirectoryEnv` and key `interpolation`. `LoginAccount.accountId` is set on Claude (`oauthAccount.accountUuid`, only when the stored account matches the signed-in one) and on Codex (only when the login lives in Codex's default file store and the file's sign-in token matches the signed-in account). A missing `accountId` never means "no account". - **Latest model request** (#1060, #1072). Open with `modelRequests: "latest"` and call `Session.lastModelRequest()` for the last attributed root request, read on demand and redacted. Claude (2.1.274 and later; resume verified on 2.1.326) reads its own capture, which writes the body of every model call, child and auxiliary calls included, to a private directory. Pi SDK keeps the body after Pi and extensions have transformed it, for Anthropic Messages, OpenAI Chat Completions and OpenAI Responses models; other model APIs are refused at open. Pi RPC and all other runtimes declare the option refused. `RefusableSessionOption` gains `"modelRequests"`. - **Native session file** (#1065, #1086). `Session.nativeSessionFile()` returns the file Codex (0.169.0 and later) or Pi has saved, once it exists, on fresh, resumed and forked sessions, and still after disposal. It returns `null` for a path that contains a credential. The path is the runtime's own spelling and can differ between opens of the same session (Codex on Windows adds `\\?\` on resume); compare files by filesystem identity. - **Claude side questions** (#1066). `Runtime.sideQuestion` answers one question about a saved Claude session from a disposable native fork with no tools, no MCP servers, no slash commands and no user or project hooks. It makes its own provider request with Claude's default model unless `model` is given, and times out after 60 s by default. The source can be running or stopped and is left unchanged. Claude Code 2.1.326 and later. - **Codex applied file changes per path** (#1063) on `tool_call_ended.fileChanges` and the session view, with moves kept together. Codex 0.160.1 and later. - `SessionCapabilityDeclaration` gains `sideQuestion`, `fileChanges` and `nativeSessionFile`. New exported types include `ModelRequest`, `FileChange`, `SideQuestionOptions`, the installation refusal types and `CredentialField`. ### Fixes - **Steer and abort** (#1070). - Pi RPC no longer kills a live process 10 s after a refused abort, and Pi SDK aborts between `agent_end` and `agent_settled`. - Factory retries reach `droid` after a refused interrupt. - Cursor bounds `abort()` at 10 s. In subprocess mode it stops the child if the run ignores cancel; in-process, a hung cancel answers `accepted` after 10 s while the run may continue. A live native refusal is `runtime_refused`. - Codex abort refusals keep `session_not_found` and the native error. - DSH maps process exit to `runtime_exited`, answers a prompt sent while another is starting with `busy`, and answers idle steer with `no_active_turn` before checking images. - Pi Durable agrees with `status()` right after `prompt()`, answers idle steer with `no_active_turn`, still returns `accepted` when a status read fails after a durable commit, bounds `abort()` at 10 s and reports aborted inbox inputs as `input_dropped`. - **DSH cold profile initialization** (#1080). Concurrent session, model and skill startup on a fresh DSH profile no longer races (3 in 100 shared-profile pairs failed on 0.2.2-rc.5): it now uses the one-opener coordinator Codex already had. This holds within one OAR process; separate processes can still race. ### Tests and docs - Configured-append contract on Antigravity, DSH, Factory, Grok, Pi Durable and Qoder (#1057, #1077); Qoder notification abort (#1059); Windows OpenCode startup diagnostics (#1064, #1078, #1083); tests tell processes apart across PID reuse (#1081, #1087). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Cindy <[email protected]>
A host can opt in with
modelRequests: "latest"and callSession.lastModelRequest()to read Claude's latest attributed root request. Sessions opened without the option have no reader. Other adapters explicitly refuse it. This is the Claude portion of the View Context design in #1039.Each Claude process gets a private capture directory through the native settings flag. OAR confirms the effective setting before returning the session. It joins Claude's index to real root assistant replies and reads the complete JSON body on demand, outside the control stream. Reads wait up to two seconds for an outstanding attribution, report missing captures and native withholds, apply session credential redaction, and return null at disposal or exit. A resumed or forked open starts with its own empty directory.
Claude Code 2.1.273 wrote bodies but no index. 2.1.274 added the required index and passed two fresh turns. Its independent resume check refuses because that version lacks get_status. On 2.1.326, fresh, resumed and forked opens each passed two turns. All five measured root attributions followed the assistant frame by 7 to 14 ms. A provider failing once and then succeeding produced one attributed response. Tests cover missing and partial writes, stale entries, turn failure, disposal, provider content and redaction.
The full local check passed with 5,509 unit tests and 19 mock behavior cases. The Claude vendor control passed on the CI pin.