opencode

package
v0.6.40 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFileName = "opencode.json"
)

Variables

This section is empty.

Functions

func New

func New(config v1.Config) v1.Tool

Types

type ConfigTemplateInput

type ConfigTemplateInput struct {
	ConsoleURL   string
	ConsoleToken string
	DeployToken  string
	AgentRunID   string

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

	// Endpoint is the AI provider API endpoint.
	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

	// ExaMcpConfigs holds additional external MCP server configurations.
	ExaMcpConfigs []agentrunv1.ExaMcpServerConfig
}

type Event

type Event struct {
	ID      string
	Message *console.AgentMessageAttributes
	Done    bool
	// contains filtered or unexported fields
}

func (*Event) FromEventResponse

func (in *Event) FromEventResponse(e EventListResponse)

func (*Event) Sanitize

func (in *Event) Sanitize()

type EventListResponse

type EventListResponse struct {
	Timestamp int64        `json:"timestamp"`
	SessionID string       `json:"sessionID"`
	Part      *StreamPart  `json:"part,omitempty"`
	Error     *StreamError `json:"error,omitempty"`
}

type Model

type Model string
const (
	ModelGPT5  Model = "gpt-5"
	ModelGPT51 Model = "gpt-5.1"
	ModelGPT52 Model = "gpt-5.2"
	ModelGPT53 Model = "gpt-5.3"
	ModelGPT54 Model = "gpt-5.4"
)

func EnsureModel

func EnsureModel(model string) Model

type Opencode

type Opencode struct {
	toolv1.DefaultTool
	// contains filtered or unexported fields
}

Opencode implements toolv1.Tool interface.

func (*Opencode) AnalysisFollowUpRun added in v0.6.40

func (in *Opencode) AnalysisFollowUpRun(ctx context.Context, followUpPrompt string) error

AnalysisFollowUpRun re-runs OpenCode with followUpPrompt. Errors are returned to the caller and must not be sent on ErrorChan.

func (*Opencode) BabysitRun

func (in *Opencode) BabysitRun(ctx context.Context, bCtx *v1.BabysitContext) bool

func (*Opencode) Configure

func (in *Opencode) Configure(consoleURL, consoleToken, deployToken string) error

func (*Opencode) ConfigureBabysitRun

func (in *Opencode) ConfigureBabysitRun() error

func (*Opencode) OnMessage

func (in *Opencode) OnMessage(f func(message *console.AgentMessageAttributes))

func (*Opencode) Run

func (in *Opencode) Run(ctx context.Context, options ...exec.Option)

type Provider

type Provider string
const (
	ProviderPlural Provider = "plural"
	ProviderOpenAI Provider = "openai"
)

func EnsureProvider

func EnsureProvider(defaultProvider string, proxyEnabled bool) Provider

func (Provider) Endpoint

func (in Provider) Endpoint() string

type StreamError

type StreamError struct {
	Name string           `json:"name"`
	Data *StreamErrorData `json:"data,omitempty"`
}

type StreamErrorData

type StreamErrorData struct {
	Message string `json:"message"`
}

type StreamPart

type StreamPart struct {
	ID        string           `json:"id"`
	SessionID string           `json:"sessionID"`
	MessageID string           `json:"messageID"`
	CallID    string           `json:"callID,omitempty"`
	Type      StreamPartType   `json:"type"`
	Text      string           `json:"text,omitempty"`
	Tool      string           `json:"tool,omitempty"`
	Cost      float64          `json:"cost,omitempty"`
	Tokens    *StreamTokens    `json:"tokens,omitempty"`
	State     *StreamToolState `json:"state,omitempty"`
}

type StreamPartType

type StreamPartType string
const (
	StreamPartTypeText       StreamPartType = "text"
	StreamPartTypeTool       StreamPartType = "tool"
	StreamPartTypeStepStart  StreamPartType = "step-start"
	StreamPartTypeStepFinish StreamPartType = "step-finish"
)

type StreamTokens

type StreamTokens struct {
	Total     float64 `json:"total"`
	Input     float64 `json:"input"`
	Output    float64 `json:"output"`
	Reasoning float64 `json:"reasoning"`
}

type StreamToolState

type StreamToolState struct {
	Status StreamToolStatus `json:"status"`
	Input  json.RawMessage  `json:"input,omitempty"`
	Output string           `json:"output,omitempty"`
}

type StreamToolStatus

type StreamToolStatus string
const (
	StreamToolStatusRunning   StreamToolStatus = "running"
	StreamToolStatusCompleted StreamToolStatus = "completed"
	StreamToolStatusPending   StreamToolStatus = "pending"
	StreamToolStatusError     StreamToolStatus = "error"
)

Jump to

Keyboard shortcuts

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