Add Claude structured session adapter - #13569
Closed
brennanb2025 wants to merge 4 commits into
Closed
Conversation
9 tasks
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the host-side Claude structured-session adapter as the first PR in the Claude stack. It drives the user's installed Claude CLI directly through one long-lived bidirectional
stream-jsonchild per session; no Agent SDK or package dependency is added.The adapter pre-mints deterministic provider session IDs, resumes from the durable provider-handle chain, pins
CLAUDE_CONFIG_DIR, proves ownership throughsystem/initplus process identity, buffers events until acquisition is committed, and persists the last observed leaf on graceful close. It also implements replay-acknowledged sends, acknowledged interrupt/model/permission-mode/effort controls, live model discovery with shared-catalog fallback, bounded image inputs, permission and multi-question callbacks, and fail-closed local-only capability data for SSH/WSL.Launches deliberately use the default interactive setting sources (
user,project,local) so user MCP servers, skills, hooks, project instructions, and configured auth/gateway behavior remain intact. The adapter never strips or overrides auth environment; diagnostics expose only booleans and setting-source names, never credential values or gateway URLs.Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm test— 49,035 passed and 99 skipped; 5 unrelated baseline/environment failures remained in the macOS Bash 3 root-directory fixture, a timed macOS helper-process fixture, and the real POSIX SSH GC scale fixture. The Claude-focused suite passes independently.pnpm build— not run; this host-only adapter adds no packaging dependency or UI surface.Additional gates:
pnpm lint,pnpm typecheck, andpnpm testpassed; 451 files and 3,451 tests passed, 3 skipped.pnpm run check:max-lines-ratchetpassed.pnpm run check:code-quality:changedpassed with zero new findings.AI Review Report
Reviewed acquisition races, init/session proof, chain-head resume behavior, replay acknowledgement, close persistence, prompt callback cardinality, option discovery fallback, bounded input handling, and secret exposure. The review found and fixed two issues: startup exits now reject acquisition immediately instead of waiting for the init deadline, and auth-source diagnostics were reduced to booleans rather than relaying provider strings.
Cross-platform review covered macOS, Linux, and Windows command launch semantics, including the existing Windows wrapper path and platform-native process-tree cleanup. This slice intentionally reports SSH and WSL unsupported; local folder workspaces and git worktrees share the same path resolver, and no keyboard, UI, or Electron behavior changes here.
Security Audit
Notes
The subscription-auth product-policy decision remains parked; this PR uses the user's installed CLI and existing login exactly as approved, and does not implement around that dependency with API keys.
Deferred to the next stacked PRs: Claude event-to-journal translation plus runtime/wire registration, then opt-in capability-gated client selection and option UI. The branch is rebased on
9202192f10; later stack PRs will stay based on the current Codex structured tip, and this PR can be retargeted to the default branch after its base merges.