poc(daemon): Claude Agent SDK as PTY replacement#1149
Draft
nicacioliveira wants to merge 1 commit intomainfrom
Draft
poc(daemon): Claude Agent SDK as PTY replacement#1149nicacioliveira wants to merge 1 commit intomainfrom
nicacioliveira wants to merge 1 commit intomainfrom
Conversation
Proof of concept replacing @sigma/pty-ffi PTY with @anthropic-ai/claude-agent-sdk. How it works: - When USE_AGENT_SDK=true, AITask spawns a Node.js subprocess (task-sdk.mjs) instead of a PTY session - Node script uses the SDK query() function and writes newline-delimited JSON events to stdout - SdkSession reads stdout, formats events as ANSI text (xterm.js compatible), and exposes the same interface as PtySession (onData, onExit, outputBuffer) - WebSocket protocol unchanged — Terminal.tsx works without modification Validated locally: - SDK runs with existing Claude Code login (no API key required) - tool_use events (Bash, LS, Read) work correctly - Events stream over WebSocket as readable formatted text - Exit code 0 on success Next steps: - Add to Dockerfile: npm install -g @anthropic-ai/claude-agent-sdk - Update Terminal.tsx for richer event display (optional) - Remove @sigma/pty-ffi dependency once validated in production Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Contributor
Tagging OptionsShould a new tag be published when this PR is merged?
|
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.
What
Proof of concept replacing
@sigma/pty-ffiPTY with@anthropic-ai/claude-agent-sdk.How it works
USE_AGENT_SDK=trueenv var activates the new pathtask-sdk.mjs— Node.js script usingquery()from the Agent SDKsdk-session.ts— drop-in replacement forPtySessionwith same interfaceTerminal.tsxworks without changesValidated locally
Bash,LS,Readtools work correctlyBenefits
@sigma/pty-ffi(FFI dependency)Next steps
npm install -g @anthropic-ai/claude-agent-sdk@sigma/pty-ffifrom image after validationTerminal.tsxfor richer event display (optional)🤖 Generated with Claude Code
Summary by cubic
Add an optional path to run tasks via
@anthropic-ai/claude-agent-sdkinstead of the PTY, streaming structured events through a Node subprocess and formatting them to ANSI so the existing terminal and WebSocket flow work unchanged. This is behindUSE_AGENT_SDK=trueand paves the way to remove@sigma/pty-ffi.SdkSessionas a drop-in forPtySessionwith the same interface.task-sdk.mjsthat calls SDKquery()and emits NDJSON events.AITaskchooses the SDK path whenUSE_AGENT_SDK=trueand a prompt is present.Terminal.tsxand the WebSocket protocol are unchanged.Written for commit ab6f3fb. Summary will update on new commits.