feat(server): replace Claude Agent SDK runtime with a direct stream-json CLI driver (subscription billing)#1
Closed
akarabach wants to merge 199 commits into
Closed
feat(server): replace Claude Agent SDK runtime with a direct stream-json CLI driver (subscription billing)#1akarabach wants to merge 199 commits into
akarabach wants to merge 199 commits into
Conversation
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: julius <julius0216@outlook.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com> Co-authored-by: codex <codex@users.noreply.github.com>
…ingdotgg#1995) Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: Julius Marminge <jmarminge@gmail.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
…tgg#2004) Co-authored-by: Cursor Agent <cursoragent@cursor.com>
…ingdotgg#1541) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: cursor[bot] <206951365+cursor[bot]@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
…gg#2024) Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Julius Marminge <julius@macmini.local>
Co-authored-by: Julius Marminge <julius@macmini.local>
Co-authored-by: Julius Marminge <julius@macmini.local>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
- Restrict release workflow defaults to read-only access - Grant `id-token` only to the publish job - Document safe handling for `pull_request_target` in PR size checks
Co-authored-by: Julius Marminge <julius@macmini.local>
Replace the @anthropic-ai/claude-agent-sdk runtime with a direct stream-json child-process driver so usage bills against the user's Claude subscription instead of pay-per-token API credits. The SDK is now a type-only devDependency (zero runtime code, types unchanged). - ClaudeCliTransport.ts (new): spawn + NDJSON framing + control protocol (interrupt/setModel/setPermissionMode/setMaxThinkingTokens), can_use_tool permission bridge over stdio, initialize handshake - ClaudeAdapter.ts: createQuery -> makeClaudeCliQuery; import type only - ClaudeProvider.ts: capabilities/auth probe ported off SDK runtime - package.json: SDK moved dependencies -> devDependencies - ClaudeCliTransport.test.ts (new): protocol integration tests
Owner
Author
|
Superseded by the upstream PR pingdotgg#2729 (correct base). |
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.
Why
Driving Claude through
@anthropic-ai/claude-agent-sdkcould bill usage against pay-per-token API credits. We need Claude usage to draw from the user's Claude subscription (Pro/Max) instead. The SDK'squery()is what spawns and drives theclaudebinary, so removing the SDK runtime (while keeping its types) lets us own the process and its environment directly.What
ClaudeCliTransport.ts— an SDK-free driver that spawns the nativeclaudebinary and speaks itsstream-jsonIPC protocol directly.ClaudeAdapter.ts— thecreateQueryseam now uses the new transport; the SDK import isimport typeonly.ClaudeProvider.ts— the capabilities/auth probe no longer executes SDK runtime code (uses the transport'sinitialize()handshake).@anthropic-ai/claude-agent-sdkmoveddependencies→devDependencies(types only — zero runtime code ships).How it works now
createQuery→makeClaudeCliQueryspawnsclaude --output-format stream-json --verbose --input-format stream-json …, then:SDKMessagestream the adapter already consumes — no downstream changes.interrupt,setModel,setPermissionMode,setMaxThinkingTokens) are written as NDJSON.canUseToolcallback the CLI runs with--permission-prompt-tool stdio, socan_use_toolrequests arrive on the same stdout stream and are answered on stdin — no separate MCP server.initializehandshake is sent on startup (also powers the auth/capabilities probe).Because no SDK code runs, the spawned process uses the local
claudelogin → subscription billing (providedANTHROPIC_API_KEYis not in the server environment).Verification
claudebinary with a real subscription — needs a manual end-to-end pass (streaming, tool approval, resume,claude auth status).Screenshot
TODO: screenshot