feat(ai-autopilot): surfaces (terminal / in-page / background)#104
Merged
Conversation
Run the same autopilot in three places, all over the Supervisor's onEvent stream: - terminalSink() / formatEvent(): print events inline (terminal surface) - EventStream: a replayable, multi-consumer event transport with offset/tail replay (borrows Flue's Durable-Streams tail=N); a late subscriber still sees full history - launchAutopilot(start): run a Supervisor detached, return an AutopilotHandle (status/events/stream/result) backing the background + in-page (SSE) surfaces Verified end-to-end against a real Supervisor (terminal tree, background status running->done, live stream ordering, tail replay). Closes #100.
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.
Closes #100. Third child of epic #97.
What
Run the same autopilot in three places. The Supervisor already emits progress via
onEvent; surfaces adapt that one stream to each environment — they differ only in rendering and whether the run blocks.terminalSink()prints each event inline (formatEvent()renders one event as a line).launchAutopilot(start)runs a Supervisor detached and returns anAutopilotHandle:status()('running' → 'done' | 'error'),events(offset)history replay, andresult().startis caller-provided (onEvent => new Supervisor({ ...opts, onEvent }).run(task)), so the surface knows nothing about how the Supervisor is built.stream()to push over SSE: it replays history, then goes live, then ends.EventStreamis the underlying replayable, multi-consumer transport with offset/tail replay — borrowed from Flue's Durable-Streamstail=N(per the #101 teardown). A late subscriber still sees the full history.Test
16 new tests (history/tail replay, async iteration incl. multiple concurrent iterators, every
formatEventvariant, terminal sink, and the fulllaunchAutopilotlifecycle incl. error path). Full suite 63/63 green.Verified end-to-end against a real
Supervisor+AiFake: terminal prints the event tree; the background handle goes running→done; the live stream yields all six events in order; tail-replay from an offset works;result()resolves with the synthesized text.Scope
Surfaces over the event stream. No infra. This is the last of the four epic children buildable without a real sandbox; the remaining epic work is the real runner adapters (FlueRunner/WebContainer/Docker) on #99.