feat(cloud): bidirectional CloudBrain over the agent dev-session protocol - #65
Merged
Conversation
…ocol The hosted path becomes a real coding brain: CloudBrain now creates an /agent/dev/sessions session, maps seq-numbered SSE frames (tool_call included) onto the existing BrainEvent vocabulary, POSTs locally executed tool results upstream (serialized, retried once against an idempotent server), and implements control(pause|resume|steer). close() aborts the stream and deletes the server session. Effort now rides the wire. Replay safety: frames at or below the last-seen seq are skipped, so a redelivered mutating tool_call can never execute twice; reconnect resumes from ?last_seq. Older servers (404/403 on create) fall back to the pre-existing one-way chat stream unchanged. Ships Phase A/B of the API coding IDE hardening spec: the current-state audit (AETHER_AGENT_API_CURRENT_STATE.md), dev-session route constants + GET SSE support in transport, the new frame vocabulary in stream.ts, and 10 protocol tests covering the round-trip, dedupe, reconnect, control, teardown, and both fallback splits. Co-Authored-By: Claude Fable 5 <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.
Purpose
Phase A + B of the API Coding IDE Hardening lane: make the hosted API path a true bidirectional coding brain.
CloudBrain.sendToolResult()andcontrol()are no longer no-ops — the cloud model can now drive the local host loop's tools while all execution stays on the user's machine.Changes
src/core/brain_cloud.ts— rewritten. Primary path: create an/agent/dev/sessionssession (effort + declared capabilities on the wire), consume seq-numbered GET SSE, surfacetool_callframes as BrainEvents, POST tool results upstream (serialized, one retry against an idempotent server),control(pause|resume|steer),close()aborts the stream and deletes the session. Frames at or below the last-seen seq are skipped so a redelivered mutatingtool_callnever executes twice; a dropped stream reconnects from?last_seq. Legacy servers (404/403 on create) fall back to the existing one-way chat stream unchanged.src/core/stream.ts— dev-session frame vocabulary (session,tool_call,tool_result_ack), optionalseqon every frame,okondone(only when the wire carried it — legacy frames stay byte-identical).src/core/transport.ts— dev-session route constants + GET support for SSE streams.src/core/envelope.ts—buildDevSessionRequest(effort finally reaches the hosted brain).AETHER_AGENT_API_CURRENT_STATE.md— Phase A audit deliverable (spec §121): current architecture map of both repos + defect register feeding Phases B–H.RELEASE_NOTES.md— patch notes for this release.Verification
npm run typecheckclean.node --testsuite green (0 fail), including 10 new protocol tests intest/brain_cloud_dev.test.ts: tool round-trip with upstream POST body assertions, seq-dedupe (duplicate mutating frame fires once), reconnect-from-last_seq, server error →done ok:false, control/steer POST, DELETE on close, tool-result retry, legacy 404 fallback (results/control stay no-ops there), non-404 create failure surfaces instead of silently downgrading.feat/agent-dev-sessions) ships separately; this client negotiatesprotocol_versionand fails safe against servers without it.Risks
sendToolResultswallows a twice-failed upstream POST by design (the server's tool-result timeout terminates the session with a clear error frame rather than the host loop crashing mid-render).🤖 Generated with Claude Code