opencode

package
v1.168.0-beta.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package opencode implements the local HTTP facade that lets an unmodified opencode CLI drive a hosted MARS session as if the session were a local `opencode serve` backend.

Unlike codex (a JSON-RPC-over-WebSocket app-server), opencode's TUI is natively a remote-capable HTTP client: `opencode attach <url>` points it at any server speaking the opencode REST + SSE surface. The facade implements exactly the slice of that surface a real attach exercises — captured live against `opencode serve` (see TestedVersion) — and will bridge prompts and events to the hosted session through do.HostedAgentsService in later milestones. M1 scope: the TUI attaches, renders, and idles cleanly.

Index

Constants

View Source
const TestedVersion = "1.18.25"

TestedVersion is the opencode CLI version the route inventory and response shapes below were captured against (`opencode serve` + `opencode attach` through a logging relay). opencode releases near-daily and a v2 API surface is rolling out alongside v1, so re-capture on upgrades rather than assuming stability; the unhandled-route log below is the drift detector.

Variables

This section is empty.

Functions

This section is empty.

Types

type Facade

type Facade struct {
	// SessionID is the hosted session this facade bridges to (already
	// resolved and validated by the command layer).
	SessionID string
	// Sessions is the harness bridge. Unused in M1 (stubs only); the event
	// loop and prompt path arrive in M2.
	Sessions do.HostedAgentsService
	// Dir is the directory advertised to the TUI as the workspace root
	// (opencode renders it in the footer and scopes requests to it). The
	// hosted workspace isn't locally mounted, so this is presentational —
	// the proxy's own working directory.
	Dir string
	// contains filtered or unexported fields
}

Facade impersonates an opencode server for one hosted session. It is the http.Handler ServeHTTP-transport variant of the codex Facade: dispatch is by method+path instead of JSON-RPC method, and server→client traffic is a single SSE stream instead of WebSocket frames.

One Facade serves the whole listener lifetime — HTTP has no "connection" to scope state to the way the WebSocket transport does. The one genuinely connection-like resource, the /global/event stream, guards itself with a single-consumer slot instead (mirroring the WS transport's one-client rule).

func (*Facade) ServeHTTP

func (f *Facade) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL