Skip to content

feat(server): replace Claude Agent SDK runtime with a direct stream-json CLI driver (subscription billing)#2729

Open
akarabach wants to merge 1 commit into
pingdotgg:mainfrom
akarabach:read-claude-streamed-messages
Open

feat(server): replace Claude Agent SDK runtime with a direct stream-json CLI driver (subscription billing)#2729
akarabach wants to merge 1 commit into
pingdotgg:mainfrom
akarabach:read-claude-streamed-messages

Conversation

@akarabach
Copy link
Copy Markdown
Contributor

@akarabach akarabach commented May 16, 2026

I know it will never be merged, but, it's alternative solution not to create emdash/cmax for claude. We can spawn claude process!

Ive not reviewed the code (working on internal browser integration and dont want to spend time on this pr)

Screenshot 2026-05-16 at 15 55 15

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
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 923d7104-3e95-4ffe-92d6-c9443befd9c6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels May 16, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8dc80e8. Configure here.

reject(error);
}
});
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silent write failure leaves pending control promises orphaned

Medium Severity

writeLine internally catches all errors and never throws, so the try/catch around it in sendControlRequest is dead code. If writeLine silently returns without writing (because !child.stdin.writable is true while closed and exited are still false — e.g. after the prompt pump's finally block ends stdin), the pending control promise is registered in pendingControl but the message is never sent. The promise hangs until the process exits and the close handler rejects all pending entries. Methods like interrupt(), setModel(), etc. can appear to hang in this window.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8dc80e8. Configure here.

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 16, 2026

Approvability

Verdict: Needs human review

This PR replaces core SDK runtime infrastructure with a custom CLI transport and explicitly affects billing behavior (subscription vs API credits). The stated billing rationale combined with the scope of the infrastructure change and an unresolved bug finding warrants careful human review.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant