Documentation
¶
Overview ¶
Package opencode discovers models exposed by a local OpenCode runtime.
Index ¶
- func ValidateServerURL(raw string) (string, error)
- type Config
- type Connection
- type Dependencies
- type Discovery
- type IncompatibleError
- type Mode
- type Model
- type Process
- type Runtime
- func (r *Runtime) EffectiveTools() []string
- func (r *Runtime) EffectiveToolsKnown() bool
- func (r *Runtime) Execute(ctx context.Context, prompt string, options vetox.ExecutionOptions) vetox.Result
- func (r *Runtime) ExecuteWithEvents(ctx context.Context, prompt string, options vetox.ExecutionOptions, ...) vetox.Result
- func (r *Runtime) Run(ctx context.Context, prompt string) vetox.Result
- func (r *Runtime) RuntimeID() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateServerURL ¶
ValidateServerURL accepts only explicit local HTTP endpoints. It normalizes localhost to 127.0.0.1 to avoid name-resolution surprises.
Types ¶
type Config ¶
Config is safe to persist in ~/.veto/config.json. It never contains provider credentials or OpenCode's provider-auth state.
type Connection ¶
type Connection struct {
Discovery Discovery
// contains filtered or unexported fields
}
Connection owns a managed OpenCode process when Mode is managed.
func Connect ¶
func Connect(ctx context.Context, config Config, deps Dependencies) (*Connection, error)
Connect discovers OpenCode and retains a managed process until Close.
func (*Connection) Close ¶
func (c *Connection) Close() error
Close releases a managed server. Attach and CLI connections are no-ops.
type Dependencies ¶
type Dependencies struct {
LookPath func(string) (string, error)
Run func(context.Context, string, ...string) ([]byte, error)
Stream func(context.Context, string, []string, []string, io.Writer, io.Writer) error
Start func(string, []string, []string) (Process, error)
Do func(*http.Request) (*http.Response, error)
Getenv func(string) string
}
Dependencies makes filesystem-free process and HTTP boundaries injectable.
func DefaultDependencies ¶
func DefaultDependencies() Dependencies
DefaultDependencies returns bounded production process and HTTP boundaries.
type Discovery ¶
type Discovery struct {
Mode Mode `json:"mode"`
Server string `json:"server,omitempty"`
Executable string `json:"executable,omitempty"`
Version string `json:"version"`
Models []Model `json:"models"`
}
Discovery describes a reachable OpenCode runtime and its connected models.
func ProbeCLI ¶
func ProbeCLI(ctx context.Context, deps Dependencies) (Discovery, error)
ProbeCLI checks that the CLI exists and reports a compatible version without listing models or contacting providers. It is suitable for doctor checks of managed mode, where starting a server would be an unwanted side effect.
type IncompatibleError ¶
IncompatibleError means OpenCode was reachable but did not satisfy the documented CLI or server contract.
func (*IncompatibleError) Error ¶
func (e *IncompatibleError) Error() string
type Runtime ¶ added in v0.4.0
type Runtime struct {
// contains filtered or unexported fields
}
Runtime executes one specific OpenCode provider/model binding. Every call creates a fresh session; it never resumes a prior Veto or user session.
func NewRuntime ¶ added in v0.4.0
func NewRuntime(config Config, discovery Discovery, model Model, deps Dependencies) *Runtime
NewRuntime binds one discovered provider/model to an OpenCode transport.
func (*Runtime) EffectiveTools ¶ added in v0.4.0
EffectiveTools is deliberately unknown until OpenCode exposes the tools for the active project/session. Veto must not infer shell, file, or browser access from a model name.