refactor(simulation): type RPC request payloads (#35734)

This commit is contained in:
James Long 2026-07-07 09:21:19 -04:00 committed by GitHub
commit b6a2912bb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 48 additions and 40 deletions

View file

@ -7,19 +7,18 @@ import { SimulationServer } from "./server"
/**
* Drive-mode renderer entry point.
*
* Creates the renderer (fake when OPENCODE_DRIVE_RENDERER=fake, the normal
* Creates the renderer (headless when OPENCODE_DRIVE_RENDERER=headless, the normal
* visible renderer otherwise) and starts the UI control
* server against it. The server stops when the renderer is destroyed, so the
* caller only manages the renderer lifecycle.
*/
export async function create(options: CliRendererConfig): Promise<CliRenderer> {
const renderer =
process.env.OPENCODE_DRIVE_RENDERER === "fake"
? await SimulationRenderer.create(options)
: await createCliRenderer(options)
const headless = process.env.OPENCODE_DRIVE_RENDERER === "headless"
const renderer = headless ? await SimulationRenderer.create(options) : await createCliRenderer(options)
const server = SimulationServer.start(
SimulationActions.createHarness(renderer),
DriveManifest.resolve().endpoints.ui,
headless,
)
process.stderr.write(`opencode drive ui websocket: ${server.url}\n`)
renderer.once("destroy", () => server.stop())