feat(agent): M7 — headless serve control protocol over stdio#9
Merged
Conversation
agent-core: add AgentEvent (Stream/ToolStart/ToolEnd/TurnEnd) and
Agent::run_events — the full observation surface. Agent::run is now a thin
wrapper that forwards only Stream events. No behavior change to existing tests.
agent: `beyond-ai-agent serve` — a newline-delimited JSON control protocol
over stdio, modeled on pi's rpc mode + opencode's session server. The server
is the source of truth; any client (TUI, editor, or an SSH pipe) drives it:
- commands {id?,type,…}: prompt | get_state | get_messages | new_session
- frames: {type:"response",…} and streamed {type:"event", event:<AgentEvent>}
- session state serde-persisted to --session-file, so a later serve over the
same file reattaches with the full transcript (the SSH remote-control story).
Proven by a serve e2e (tests/serve_e2e.rs) driving the REAL binary over
stdin/stdout against a mock model server: a prompt streams tool_start/tool_end
events then a success response, get_messages returns the transcript, and a
FRESH serve process reattaches to the persisted session and restores it.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 — M7: headless
serveThe provable headless server — modeled on pi's
rpcmode and opencode's session server. The server is the source of truth; any client (a TUI, an editor, or ansshpipe) drives it over newline-delimited JSON on stdio. This is the "remote control over SSH" requirement.agent-core
AgentEvent(Stream(StreamEvent)/ToolStart/ToolEnd/TurnEnd) +Agent::run_events— the full observation surface.Agent::runbecomes a thin wrapper forwarding onlyStreamevents (no behavior change to existing callers/tests).agent (
serve){id?, type, …}→prompt|get_state|get_messages|new_session.{type:"response", …}and streamed{type:"event", event: <AgentEvent>}; areadyframe on startup. One writer task serializes all frames so output never interleaves.--session-fileafter each turn → a laterserveover the same file reattaches with the full transcript.Proven by
tests/serve_e2e.rsdrives the realservebinary over stdin/stdout against a mock model server:prompt→ streamstool_start/tool_endevents for areadround-trip, then a successresponse.get_messages→ returns the transcript (tool result + final text).serveprocess over the same--session-filereattaches and restores the transcript — no re-prompt.Plus the M5
rune2e still passes. Whole workspace: clippy-D warnings,cargo fmt --all --check, all unit + e2e tests green.Series: M1 #5 · M2 #6 · M3+M4 #7 · M5+M6 #8 merged. Next: M8 — Beyond platform tools (fork/sync/logs) + full e2e through the actual gateway binary.
🤖 Generated with Claude Code