Documentation
¶
Overview ¶
Package subprocess manages the opencode acp child process and wires its stdio into the coder/acp-go-sdk protocol layer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Path is the resolved path to the opencode binary.
Path string
// Args are user-supplied flags appended to `opencode acp`. The
// SDK always prepends `--host 127.0.0.1 --port 0` and `--cwd <Cwd>`
// (when Cwd is set) to these flags.
Args []string
// Env overlays the inherited environment. nil means inherit
// os.Environ() unchanged.
Env map[string]string
// Cwd is the working directory for the subprocess.
Cwd string
// Logger receives diagnostics. Must not be nil.
Logger *slog.Logger
// StderrCallback, if set, receives each stderr line. If nil, stderr
// is forwarded to Logger at debug level.
StderrCallback func(line string)
}
Config configures the opencode acp subprocess.
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process is a running `opencode acp` subprocess attached to a coder ClientSideConnection.
func Spawn ¶
Spawn launches opencode acp with the supplied configuration and wires its stdio into a ClientSideConnection bound to the provided client. The returned Process is responsible for the subprocess lifetime; call Close to terminate.
Spawn does not run the ACP initialize handshake — callers invoke Process.Conn().Initialize themselves so they can control timeout and parameters.
func (*Process) Close ¶
Close shuts down the subprocess. It closes stdin (requesting graceful shutdown), waits up to 5s for the process to exit, then delivers a process-group-wide SIGKILL so any children opencode spawned are also reaped. Close is idempotent and safe to call after Start failures.
func (*Process) Conn ¶
func (p *Process) Conn() *acp.ClientSideConnection
Conn returns the underlying ClientSideConnection for making outbound ACP calls.
func (*Process) Done ¶
func (p *Process) Done() <-chan struct{}
Done returns a channel that closes when the peer disconnects.