Skip to content

Expose a backend-only driver for external OpenCode clients #65

Description

@ItsWendell

I'm looking at using opencode-drive for deterministic desktop E2E tests.

My current setup starts:

  • An isolated real OpenCode service
  • A small scripted OpenAI-compatible LLM
  • A desktop client
  • Playwright connected over CDP

Drive would be a much better replacement for the scripted LLM and service lifecycle. The native simulation transport, tool control, settlement checks, disconnects, and network fault injection would all be useful.

The main issue is that the public driver API is currently coupled to OpenCode's TUI. OpenCodeDriver.use() launches a primary TUI, while a manual script can launch only the server but doesn't expose connection details intended for launching another frontend process.

A backend-only API for this use case would be great. Something along these lines:

OpenCodeBackend.use(options, ({ opencode, llm, tools, service, artifacts }) =>
  Effect.gen(function* () {
    // Launch a desktop or web client against the service.
  }),
)

Alternatively, an option such as OpenCodeDriver.use({ tui: false }, ...) could work.

The important parts for me would be:

  • Prepare the isolated project, config, home, and service registration
  • Launch OpenCode with the simulation backend, without launching a TUI
  • Expose the generated SDK client
  • Expose enough connection information or environment variables for an external frontend
  • Keep the current LLM and tool controllers
  • Keep settlement and scoped cleanup
  • Ideally retain server restart and network controls

The only blocker is integrating its backend lifecycle without also taking ownership of the frontend.

I'm willing to open a PR adding this soon if the proposed direction makes sense.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions