Repository navigation
Closed
Description
Overview
Implement the low-level transport for communicating with external ACP agents over stdio using newline-delimited JSON-RPC 2.0. This is a pure I/O layer — no business logic, no agent-specific behavior.
Acceptance Criteria
-
AcpTransporttrait from Shared types, traits, and interface contracts for agent subsystems #998 fully implemented - Can spawn a subprocess, send NDJSON messages, receive responses
- Handles process crash gracefully (detect broken pipe, report error)
- Graceful shutdown sequence works (close -> SIGTERM -> SIGKILL)
- Stderr lines are logged but do not interfere with protocol
- Buffered reading handles partial lines correctly
- Concurrent send/receive works without deadlock
- Unit test with mock subprocess (simple echo server script)
- Code passes
bun run quality:fix
Technical Specifications
New Module
packages/desktop-app/src-tauri/src/acp/transport.rs
Process Spawning
- Launch external agent binary as child process with stdin/stdout/stderr pipes
- Configurable: command, args, env vars, working directory
- Use
tokio::process::Commandfor async subprocess management
NDJSON Framing
- Write: serialize
AcpMessageto JSON, append newline, write to stdin - Read:
BufReaderon stdout,read_line()per message, parse asAcpMessage - Handle partial lines (buffered reader accumulates until newline)
Bidirectional Streaming
- Tokio tasks for concurrent read/write
- Write task: consumes from
mpsc::Sender, writes to stdin - Read task: reads from stdout, produces to
mpsc::Receiver - Internal channel-based architecture decouples caller from I/O
Stderr Capture
- Background task reads stderr lines
- Log via
tracingat warn level - Do not treat stderr as protocol data
Lifecycle
- Graceful shutdown: send close message, wait 5s, SIGTERM, wait 2s, SIGKILL
- Track process exit status
- No reconnection (sessions are one-shot)
Error Types
- Transport errors: pipe broken, process died, spawn failed
- Protocol errors: invalid JSON, unexpected message format
- Both surfaced with distinct error variants
Reference Files
packages/core/src/mcp/server.rs— existing MCP server (stdio transport pattern)
Exports
StdioTransportstruct implementingAcpTransport
Dependencies
Related Issues
- ACP Integration and Local LLM Capability #997 (parent epic)
Activity
malibio commentedon Apr 3, 2026
Baseline: Frontend tests have pre-existing vitest startup error (TypeError: Attempted to assign to readonly property). This is not caused by this PR.
feat: ACP stdio NDJSON transport layer (closes #1001)
feat: local agent ReAct loop with history management and context budg…
feat: local agent ReAct loop with history management and context budg…
feat: local agent ReAct loop with history management and context budg…
feat: ACP stdio NDJSON transport layer (closes #1001) (#1020)
feat: local agent ReAct loop with history management and context budg…