feat(ai-autopilot): runner start() + reachable preview — boot-and-serve (#137)#138
Merged
Merged
Conversation
…ve (#137) The runner seam could not run an app: exec() awaits the process to exit (a dev server hangs), and preview() only formatted a URL with nothing behind it. So 'produce a running app' was unreachable. Add: - RunnerSession.start(command): launch a long-running command in the background, returning a RunnerProcess ({ command, exit, stop() }). Optional, like preview. - PreviewOptions.waitMs: preview() waits for the port to accept connections before returning, so the URL is live on return. - start_server runner tool (when the session supports start). LocalRunner implements it for real: start spawns in its own process group so stop()/dispose() kill the whole tree; preview polls the port. FakeRunner mirrors it. Proven by a real boot-and-serve test: boot an HTTP server, start it, preview waits, fetch the URL and assert the body, stop kills it. 213 tests green. This is the contract each sandboxed adapter in #109 (Docker/WebContainer/Flue) must satisfy; LocalRunner is the reference.
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 #137. Enabler for #109 and the honest completion of the live capstone (#124).
The gap
The runner seam couldn't actually run an app:
RunnerSession.execawaits the process to exit (so a dev server hangs until timeout), andpreview()was a stub that formatted a URL with nothing listening behind it. "Produce a running app" was unreachable — #124 proved file-scaffolding, not serving.What's added
RunnerSession.start(command, opts)→RunnerProcess { command, exit, stop() }— launch a long-running command (a dev server) in the background, returning immediately. Optional, likepreview(presence = capability).PreviewOptions.waitMs—preview()waits for the port to accept connections before resolving, so the URL is live on return.start_serverrunner tool (exposed when the session supportsstart, and rides theexectoggle).Implementations
LocalRunner(the reference):startspawns in its own process group (detached) sostop()kills the whole tree (the shell and the server it launched), escalating SIGTERM → SIGKILL;dispose()stops any leftover processes;previewpolls the port withnet.connect.FakeRunner: mirrorsstart(records calls, controllable process) for tests.Verified
Real boot-and-serve test (no external infra, no deps): boot a Node HTTP server into a
LocalRunnerworkspace,startit,preview({ waitMs })waits until reachable,fetchthe URL and assert the body (hello from runner),stopit and confirm the port is dead; a separate test assertsdisposestops a still-running process. 213 tests green (204 + 9), typecheck + build clean.This is the contract each sandboxed adapter in #109 (Docker / WebContainer / Flue) must satisfy; LocalRunner is the reference they mirror.