opencode

package
v0.6.73 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigFileName = "opencode.json"

ConfigFileName is the native OpenCode configuration filename.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent added in v0.6.65

type Agent struct {
	// contains filtered or unexported fields
}

Agent owns OpenCode's shared preparation and lifecycle entrypoints. Runtime settings, native configuration, and ACP environment details live in their responsibility-specific files.

func NewAgent added in v0.6.65

func NewAgent(config toolv1.Config) *Agent

NewAgent creates an OpenCode Agent for one agent run. Credentials in the run configuration are used only while writing provider configuration; resolved settings never contain credentials.

func (*Agent) Capabilities added in v0.6.65

func (*Agent) Capabilities() toolv1.AgentCapabilities

Capabilities advertises the modes supported by OpenCode's configured agents.

func (*Agent) Configure added in v0.6.65

func (agent *Agent) Configure(ctx context.Context, request toolv1.ConfigureRequest) error

Configure writes the native OpenCode provider configuration. Shared prompt and skill files are prepared by Prepare.

func (*Agent) Export added in v0.6.65

func (agent *Agent) Export(ctx context.Context, request toolv1.ExportRequest) (toolv1.ExportResult, error)

Export writes the native OpenCode session export into OutputDir and returns that directory as the source for the shared artifact builder.

func (*Agent) Import added in v0.6.72

func (agent *Agent) Import(ctx context.Context, request toolv1.ImportRequest) (string, error)

func (*Agent) Prepare added in v0.6.65

func (agent *Agent) Prepare(ctx context.Context, request toolv1.FileSystemRequest) error

Prepare writes the OpenCode system prompt and run skills for a phase.

func (*Agent) ResolveSettings added in v0.6.65

func (agent *Agent) ResolveSettings(run *agentrunv1.AgentRun) (toolv1.Settings, error)

ResolveSettings resolves provider/model defaults without copying credentials into the provider-neutral runtime settings.

func (*Agent) Type added in v0.6.65

func (*Agent) Type() console.AgentRuntimeType

Type identifies the Console runtime implemented by Agent.

type ConfigTemplateInput

type ConfigTemplateInput struct {
	// ConsoleURL and ConsoleToken configure the Plural provider. They hold the sidecar's URL and a
	// placeholder key; the sidecar swaps in the deploy token, so no real Console credential is written.
	ConsoleURL   string
	ConsoleToken string
	AgentRunID   string

	// ReadOnlyDirectories are external directories OpenCode may inspect but
	// must never edit, such as repository prebake roots.
	ReadOnlyDirectories []string

	// Provider is the AI provider to use.
	Provider Provider

	// OpenAICompatible selects the OpenAI-compatible chat completions SDK (npm @ai-sdk/openai-compatible).
	OpenAICompatible bool

	// Endpoint is an optional override for the provider baseURL (for example a custom OpenAI-compatible URL).
	// When empty, baseURL is omitted so OpenCode uses the models.dev default for the provider.
	Endpoint string

	// Model is the AI model to use.
	Model string

	// Token is the API token for the AI provider.
	Token string

	// Mode is the agent run mode.
	Mode console.AgentRunMode

	// DindEnabled is true when the agent run pod has Docker-in-Docker available.
	DindEnabled bool

	// StreamingProxy routes plural provider requests through the in-pod mcpserver proxy.
	StreamingProxy bool

	// StreamingProxyBaseURL is the OpenAI-compatible base URL for the in-pod streaming proxy.
	StreamingProxyBaseURL string
}

type Provider

type Provider string

Provider is an OpenCode provider id (https://models.dev).

const (
	// ProviderPlural routes requests through the Console AI proxy (/ext/ai/v1).
	ProviderPlural Provider = "plural"
	ProviderOpenAI Provider = "openai"

	// Common models.dev provider ids for direct (non-proxy) usage.
	ProviderAnthropic     Provider = "anthropic"
	ProviderAmazonBedrock Provider = "amazon-bedrock"
	ProviderGoogleVertex  Provider = "google-vertex"
	ProviderOllama        Provider = "ollama"
	ProviderAzure         Provider = "azure"
	ProviderXAI           Provider = "xai"

	// ProviderBedrock and ProviderVertex are legacy aliases accepted by the
	// Console provider contract in addition to the canonical models.dev IDs.
	ProviderBedrock Provider = "bedrock"
	ProviderVertex  Provider = "vertex"

	// ProviderOpenAICompatible is the fixed provider key for custom OpenAI-compatible endpoints.
	ProviderOpenAICompatible Provider = "openai-compatible"
)

type Transport added in v0.6.65

type Transport struct {
	// contains filtered or unexported fields
}

Transport invokes OpenCode through its ACP interface. It owns process launch, while ACP session projection and protocol handling stay with the runtime configuration and provider-neutral engine.

func NewTransport added in v0.6.65

func NewTransport(agent *Agent) (*Transport, error)

NewTransport creates the OpenCode ACP transport for an Agent.

func (*Transport) Capabilities added in v0.6.65

func (transport *Transport) Capabilities() toolv1.TransportCapabilities

Capabilities reports the ACP features implemented by OpenCode.

func (*Transport) Kind added in v0.6.65

func (*Transport) Kind() toolv1.TransportKind

Kind identifies this as an Agent Client Protocol transport.

func (*Transport) Turn added in v0.6.65

func (transport *Transport) Turn(ctx context.Context, request toolv1.TurnRequest, sink toolv1.TurnSink) (toolv1.TurnResult, error)

Turn launches OpenCode, then delegates ACP session lifecycle and event mapping to the provider-neutral engine.

Jump to

Keyboard shortcuts

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