opencode

package
v0.10.15 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const OpenCodeModelDiscoveryFreshnessWindow = 24 * time.Hour

Variables

This section is empty.

Functions

func DefaultOpenCodeModelDiscovery

func DefaultOpenCodeModelDiscovery() harnesses.ModelDiscoverySnapshot

func ReadOpenCodeModelDiscovery

func ReadOpenCodeModelDiscovery(ctx context.Context, binary string, args ...string) (harnesses.ModelDiscoverySnapshot, error)

Types

type OpenCodeModelCost

type OpenCodeModelCost struct {
	InputUSDPerMTok      float64 `json:"input_usd_per_mtok"`
	OutputUSDPerMTok     float64 `json:"output_usd_per_mtok"`
	CacheReadUSDPerMTok  float64 `json:"cache_read_usd_per_mtok"`
	CacheWriteUSDPerMTok float64 `json:"cache_write_usd_per_mtok"`
}

OpenCodeModelCost captures the per-million-token prices printed by `opencode models --verbose`.

type OpenCodeModelEvidence

type OpenCodeModelEvidence struct {
	Model        string             `json:"model"`
	ProviderID   string             `json:"provider_id,omitempty"`
	ModelID      string             `json:"model_id,omitempty"`
	Status       string             `json:"status,omitempty"`
	Cost         *OpenCodeModelCost `json:"cost,omitempty"`
	ContextLimit int                `json:"context_limit,omitempty"`
	OutputLimit  int                `json:"output_limit,omitempty"`
	Reasoning    bool               `json:"reasoning"`
	ToolCall     bool               `json:"tool_call"`
	Attachment   bool               `json:"attachment"`
	Variants     []string           `json:"variants,omitempty"`
}

OpenCodeModelEvidence captures the stable model metadata exposed by `opencode models --verbose`. It intentionally does not include account or quota state because the current opencode CLI does not expose those as structured data.

func ParseOpenCodeVerboseModelEvidence

func ParseOpenCodeVerboseModelEvidence(text string) ([]OpenCodeModelEvidence, error)

func ReadOpenCodeVerboseModelEvidence

func ReadOpenCodeVerboseModelEvidence(ctx context.Context, binary string, args ...string) ([]OpenCodeModelEvidence, error)

type Runner

type Runner struct {
	// Binary is the absolute path to the opencode executable. When empty the
	// runner resolves "opencode" via PATH at Execute time.
	Binary string

	// BaseArgs is prepended to the per-request argument list.
	// opencode default: ["run", "--format", "json"]
	BaseArgs []string

	// PromptMode controls how the prompt is delivered:
	//   "arg" (default) — prompt is appended as the final positional argument
	//   "stdin"         — prompt is piped on stdin
	PromptMode string

	// EventBuffer overrides the per-Execute channel buffer size.
	EventBuffer int
}

Runner is the subprocess-backed opencode harness. It launches opencode in run --format json mode, parses the JSON output into harness Events, and emits a final Event when the subprocess exits.

opencode run auto-approves all tool permissions; no extra flags are needed for any permission level.

func (*Runner) Execute

func (r *Runner) Execute(ctx context.Context, req harnesses.ExecuteRequest) (<-chan harnesses.Event, error)

Execute runs one resolved request through the opencode CLI and emits JSON-derived events on the returned channel.

func (*Runner) HealthCheck

func (r *Runner) HealthCheck(ctx context.Context) error

HealthCheck verifies the opencode binary is present.

func (*Runner) Info

func (r *Runner) Info() harnesses.HarnessInfo

Info returns identity + capability metadata for this harness.

Jump to

Keyboard shortcuts

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