Provider adapter — trait & Claude Code integration #11
Labels
No labels
area:config
area:contracts
area:engine
area:eventsourcing
area:frontend
area:git
area:ipc
area:persistence
area:provider
area:scaffold
area:terminal
type:user-story
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/peon#11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
User story
As a user, I want forge-agent to spawn and communicate with Claude Code CLI via JSON-RPC over stdio, streaming text deltas, tool calls, thinking blocks, and completion signals, so that I can interact with Claude as an AI coding agent.
Acceptance criteria
ProviderAdapter trait (
provider/adapter.rs)#[async_trait] trait ProviderAdapter: Send + Syncwith methods:fn provider(&self) -> Providerasync fn health_check(&self) -> Result<ProviderHealth, ProviderError>async fn start_session(thread_id, config: SessionConfig) -> Result<Pin<Box<dyn Stream<Item = ProviderEvent> + Send>>, ProviderError>async fn send_message(thread_id, message: String) -> Result<(), ProviderError>async fn interrupt(thread_id) -> Result<(), ProviderError>SessionConfigstruct:working_dir,model,runtime_mode,system_prompt: Option<String>ProviderHealthstruct:is_available,version: Option<String>,authenticated,error: Option<String>ProviderErrorenum with variants:NotFound,SpawnFailed,SessionNotFound,ProtocolError,InterruptedClaudeAdapter (
provider/claude.rs)cli_path: PathBufandsessions: Arc<DashMap<Uuid, ClaudeSession>>health_check(): runsclaude-code --version, checks exit code and outputstart_session(): spawnsclaude-code --app-server --model <model>withstdin(Stdio::piped()),stdout(Stdio::piped()),stderr(Stdio::piped()), working dir from configProviderEventvariantstokio_stream::Stream<Item = ProviderEvent>send_message(): writes JSON-RPC request to the session's stdininterrupt(): sends SIGTERM to the child process, cleans up sessionAtomicU64counter per sessionProviderManager
HashMap<Provider, Arc<dyn ProviderAdapter>>get(provider: &Provider) -> Option<Arc<dyn ProviderAdapter>>CLI auto-detection
whichcrate to findclaude/claude-codeifProvidersConfigpaths are emptyTests
Out of scope
References
Dependencies
issue-4-event-sourcing(rebase #3 in once it lands)