opencode

package module
v0.1.0-alpha.20 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: Apache-2.0 Imports: 17 Imported by: 5

README

Opencode Go API Library

Go Reference

The Opencode Go library provides convenient access to the Opencode REST API from applications written in Go.

It is generated with Stainless.

Installation

import (
	"github.com/sst/opencode-sdk-go" // imported as opencode
)

Or to pin the version:

go get -u 'github.com/sst/opencode-sdk-go@v0.1.0-alpha.20'

Requirements

This library requires Go 1.18+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/sst/opencode-sdk-go"
)

func main() {
	client := opencode.NewClient()
	sessions, err := client.Session.List(context.TODO())
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", sessions)
}

Request fields

All request parameters are wrapped in a generic Field type, which we use to distinguish zero values from null or omitted fields.

This prevents accidentally sending a zero value if you forget a required parameter, and enables explicitly sending null, false, '', or 0 on optional parameters. Any field not specified is not sent.

To construct fields with values, use the helpers String(), Int(), Float(), or most commonly, the generic F[T](). To send a null, use Null[T](), and to send a nonconforming value, use Raw[T](any). For example:

params := FooParams{
	Name: opencode.F("hello"),

	// Explicitly send `"description": null`
	Description: opencode.Null[string](),

	Point: opencode.F(opencode.Point{
		X: opencode.Int(0),
		Y: opencode.Int(1),

		// In cases where the API specifies a given type,
		// but you want to send something else, use `Raw`:
		Z: opencode.Raw[int64](0.01), // sends a float
	}),
}
Response objects

All fields in response structs are value types (not pointers or wrappers).

If a given field is null, not present, or invalid, the corresponding field will simply be its zero value.

All response structs also include a special JSON field, containing more detailed information about each property, which you can use like so:

if res.Name == "" {
	// true if `"name"` is either not present or explicitly null
	res.JSON.Name.IsNull()

	// true if the `"name"` key was not present in the response JSON at all
	res.JSON.Name.IsMissing()

	// When the API returns data that cannot be coerced to the expected type:
	if res.JSON.Name.IsInvalid() {
		raw := res.JSON.Name.Raw()

		legacyName := struct{
			First string `json:"first"`
			Last  string `json:"last"`
		}{}
		json.Unmarshal([]byte(raw), &legacyName)
		name = legacyName.First + " " + legacyName.Last
	}
}

These .JSON structs also include an Extras map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := opencode.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Session.List(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

Errors

When the API returns a non-success status code, we return an error with type *opencode.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Session.List(context.TODO())
if err != nil {
	var apierr *opencode.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/session": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Session.List(
	ctx,
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as param.Field[io.Reader]. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper opencode.FileParam(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := opencode.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Session.List(context.TODO(), option.WithMaxRetries(5))
Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
sessions, err := client.Session.List(context.TODO(), option.WithResponseInto(&response))
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", sessions)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]interface{}

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   opencode.F("id_xxxx"),
    Data: opencode.F(FooNewParamsData{
        FirstName: opencode.F("John"),
    }),
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := opencode.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

View Source
const MessageAbortedErrorNameMessageAbortedError = shared.MessageAbortedErrorNameMessageAbortedError

This is an alias to an internal value.

View Source
const ProviderAuthErrorNameProviderAuthError = shared.ProviderAuthErrorNameProviderAuthError

This is an alias to an internal value.

View Source
const UnknownErrorNameUnknownError = shared.UnknownErrorNameUnknownError

This is an alias to an internal value.

Variables

This section is empty.

Functions

func Bool

func Bool(value bool) param.Field[bool]

Bool is a param field helper which helps specify bools.

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (OPENCODE_BASE_URL). This should be used to initialize new clients.

func F

func F[T any](value T) param.Field[T]

F is a param field helper used to initialize a param.Field generic struct. This helps specify null, zero values, and overrides, as well as normal values. You can read more about this in our README.

func FileParam

func FileParam(reader io.Reader, filename string, contentType string) param.Field[io.Reader]

FileParam is a param field helper which helps files with a mime content-type.

func Float

func Float(value float64) param.Field[float64]

Float is a param field helper which helps specify floats.

func Int

func Int(value int64) param.Field[int64]

Int is a param field helper which helps specify integers. This is particularly helpful when specifying integer constants for fields.

func Null

func Null[T any]() param.Field[T]

Null is a param field helper which explicitly sends null to the API.

func Raw

func Raw[T any](value any) param.Field[T]

Raw is a param field helper for specifying values for fields when the type you are looking to send is different from the type that is specified in the SDK. For example, if the type of the field is an integer, but you want to send a float, you could do that by setting the corresponding field with Raw[int](0.5).

func String

func String(value string) param.Field[string]

String is a param field helper which helps specify strings.

Types

type App

type App struct {
	Git      bool    `json:"git,required"`
	Hostname string  `json:"hostname,required"`
	Path     AppPath `json:"path,required"`
	Time     AppTime `json:"time,required"`
	JSON     appJSON `json:"-"`
}

func (*App) UnmarshalJSON

func (r *App) UnmarshalJSON(data []byte) (err error)

type AppLogParams added in v0.2.0

type AppLogParams struct {
	// Log level
	Level param.Field[AppLogParamsLevel] `json:"level,required"`
	// Log message
	Message param.Field[string] `json:"message,required"`
	// Service name for the log entry
	Service param.Field[string] `json:"service,required"`
	// Additional metadata for the log entry
	Extra param.Field[map[string]interface{}] `json:"extra"`
}

func (AppLogParams) MarshalJSON added in v0.2.0

func (r AppLogParams) MarshalJSON() (data []byte, err error)

type AppLogParamsLevel added in v0.2.0

type AppLogParamsLevel string

Log level

const (
	AppLogParamsLevelDebug AppLogParamsLevel = "debug"
	AppLogParamsLevelInfo  AppLogParamsLevel = "info"
	AppLogParamsLevelError AppLogParamsLevel = "error"
	AppLogParamsLevelWarn  AppLogParamsLevel = "warn"
)

func (AppLogParamsLevel) IsKnown added in v0.2.0

func (r AppLogParamsLevel) IsKnown() bool

type AppPath

type AppPath struct {
	Config string      `json:"config,required"`
	Cwd    string      `json:"cwd,required"`
	Data   string      `json:"data,required"`
	Root   string      `json:"root,required"`
	State  string      `json:"state,required"`
	JSON   appPathJSON `json:"-"`
}

func (*AppPath) UnmarshalJSON

func (r *AppPath) UnmarshalJSON(data []byte) (err error)

type AppProvidersResponse added in v0.2.0

type AppProvidersResponse struct {
	Default   map[string]string        `json:"default,required"`
	Providers []Provider               `json:"providers,required"`
	JSON      appProvidersResponseJSON `json:"-"`
}

func (*AppProvidersResponse) UnmarshalJSON added in v0.2.0

func (r *AppProvidersResponse) UnmarshalJSON(data []byte) (err error)

type AppService added in v0.2.0

type AppService struct {
	Options []option.RequestOption
}

AppService contains methods and other services that help with interacting with the opencode API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAppService method instead.

func NewAppService added in v0.2.0

func NewAppService(opts ...option.RequestOption) (r *AppService)

NewAppService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AppService) Get

func (r *AppService) Get(ctx context.Context, opts ...option.RequestOption) (res *App, err error)

Get app info

func (*AppService) Init

func (r *AppService) Init(ctx context.Context, opts ...option.RequestOption) (res *bool, err error)

Initialize the app

func (*AppService) Log added in v0.2.0

func (r *AppService) Log(ctx context.Context, body AppLogParams, opts ...option.RequestOption) (res *bool, err error)

Write a log entry to the server logs

func (*AppService) Modes

func (r *AppService) Modes(ctx context.Context, opts ...option.RequestOption) (res *[]Mode, err error)

List all modes

func (*AppService) Providers added in v0.2.0

func (r *AppService) Providers(ctx context.Context, opts ...option.RequestOption) (res *AppProvidersResponse, err error)

List all providers

type AppTime

type AppTime struct {
	Initialized float64     `json:"initialized"`
	JSON        appTimeJSON `json:"-"`
}

func (*AppTime) UnmarshalJSON

func (r *AppTime) UnmarshalJSON(data []byte) (err error)

type AssistantMessage

type AssistantMessage struct {
	ID         string                 `json:"id,required"`
	Cost       float64                `json:"cost,required"`
	ModelID    string                 `json:"modelID,required"`
	Path       AssistantMessagePath   `json:"path,required"`
	ProviderID string                 `json:"providerID,required"`
	Role       AssistantMessageRole   `json:"role,required"`
	SessionID  string                 `json:"sessionID,required"`
	System     []string               `json:"system,required"`
	Time       AssistantMessageTime   `json:"time,required"`
	Tokens     AssistantMessageTokens `json:"tokens,required"`
	Error      AssistantMessageError  `json:"error"`
	Summary    bool                   `json:"summary"`
	JSON       assistantMessageJSON   `json:"-"`
}

func (*AssistantMessage) UnmarshalJSON

func (r *AssistantMessage) UnmarshalJSON(data []byte) (err error)

type AssistantMessageError

type AssistantMessageError struct {
	// This field can have the runtime type of [shared.ProviderAuthErrorData],
	// [shared.UnknownErrorData], [interface{}].
	Data interface{}               `json:"data,required"`
	Name AssistantMessageErrorName `json:"name,required"`
	JSON assistantMessageErrorJSON `json:"-"`
	// contains filtered or unexported fields
}

func (AssistantMessageError) AsUnion

AsUnion returns a AssistantMessageErrorUnion interface which you can cast to the specific types for more type safety.

Possible runtime types of the union are shared.ProviderAuthError, shared.UnknownError, AssistantMessageErrorMessageOutputLengthError, shared.MessageAbortedError.

func (*AssistantMessageError) UnmarshalJSON

func (r *AssistantMessageError) UnmarshalJSON(data []byte) (err error)

type AssistantMessageErrorMessageOutputLengthError

type AssistantMessageErrorMessageOutputLengthError struct {
	Data interface{}                                       `json:"data,required"`
	Name AssistantMessageErrorMessageOutputLengthErrorName `json:"name,required"`
	JSON assistantMessageErrorMessageOutputLengthErrorJSON `json:"-"`
}

func (AssistantMessageErrorMessageOutputLengthError) ImplementsAssistantMessageError

func (r AssistantMessageErrorMessageOutputLengthError) ImplementsAssistantMessageError()

func (*AssistantMessageErrorMessageOutputLengthError) UnmarshalJSON

func (r *AssistantMessageErrorMessageOutputLengthError) UnmarshalJSON(data []byte) (err error)

type AssistantMessageErrorMessageOutputLengthErrorName

type AssistantMessageErrorMessageOutputLengthErrorName string
const (
	AssistantMessageErrorMessageOutputLengthErrorNameMessageOutputLengthError AssistantMessageErrorMessageOutputLengthErrorName = "MessageOutputLengthError"
)

func (AssistantMessageErrorMessageOutputLengthErrorName) IsKnown

type AssistantMessageErrorName

type AssistantMessageErrorName string
const (
	AssistantMessageErrorNameProviderAuthError        AssistantMessageErrorName = "ProviderAuthError"
	AssistantMessageErrorNameUnknownError             AssistantMessageErrorName = "UnknownError"
	AssistantMessageErrorNameMessageOutputLengthError AssistantMessageErrorName = "MessageOutputLengthError"
	AssistantMessageErrorNameMessageAbortedError      AssistantMessageErrorName = "MessageAbortedError"
)

func (AssistantMessageErrorName) IsKnown

func (r AssistantMessageErrorName) IsKnown() bool

type AssistantMessageErrorUnion

type AssistantMessageErrorUnion interface {
	ImplementsAssistantMessageError()
}

Union satisfied by shared.ProviderAuthError, shared.UnknownError, AssistantMessageErrorMessageOutputLengthError or shared.MessageAbortedError.

type AssistantMessagePath

type AssistantMessagePath struct {
	Cwd  string                   `json:"cwd,required"`
	Root string                   `json:"root,required"`
	JSON assistantMessagePathJSON `json:"-"`
}

func (*AssistantMessagePath) UnmarshalJSON

func (r *AssistantMessagePath) UnmarshalJSON(data []byte) (err error)

type AssistantMessageRole

type AssistantMessageRole string
const (
	AssistantMessageRoleAssistant AssistantMessageRole = "assistant"
)

func (AssistantMessageRole) IsKnown

func (r AssistantMessageRole) IsKnown() bool

type AssistantMessageTime

type AssistantMessageTime struct {
	Created   float64                  `json:"created,required"`
	Completed float64                  `json:"completed"`
	JSON      assistantMessageTimeJSON `json:"-"`
}

func (*AssistantMessageTime) UnmarshalJSON

func (r *AssistantMessageTime) UnmarshalJSON(data []byte) (err error)

type AssistantMessageTokens

type AssistantMessageTokens struct {
	Cache     AssistantMessageTokensCache `json:"cache,required"`
	Input     float64                     `json:"input,required"`
	Output    float64                     `json:"output,required"`
	Reasoning float64                     `json:"reasoning,required"`
	JSON      assistantMessageTokensJSON  `json:"-"`
}

func (*AssistantMessageTokens) UnmarshalJSON

func (r *AssistantMessageTokens) UnmarshalJSON(data []byte) (err error)

type AssistantMessageTokensCache

type AssistantMessageTokensCache struct {
	Read  float64                         `json:"read,required"`
	Write float64                         `json:"write,required"`
	JSON  assistantMessageTokensCacheJSON `json:"-"`
}

func (*AssistantMessageTokensCache) UnmarshalJSON

func (r *AssistantMessageTokensCache) UnmarshalJSON(data []byte) (err error)

type Client

type Client struct {
	Options []option.RequestOption
	Event   *EventService
	App     *AppService
	Find    *FindService
	File    *FileService
	Config  *ConfigService
	Session *SessionService
	Tui     *TuiService
}

Client creates a struct with services and top level methods that help with interacting with the opencode API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r *Client)

NewClient generates a new client with the default option read from the environment (OPENCODE_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type Config

type Config struct {
	// JSON schema reference for configuration validation
	Schema string `json:"$schema"`
	// @deprecated Use 'share' field instead. Share newly created sessions
	// automatically
	Autoshare bool `json:"autoshare"`
	// Automatically update to the latest version
	Autoupdate bool `json:"autoupdate"`
	// Disable providers that are loaded automatically
	DisabledProviders []string           `json:"disabled_providers"`
	Experimental      ConfigExperimental `json:"experimental"`
	// Additional instruction files or patterns to include
	Instructions []string `json:"instructions"`
	// Custom keybind configurations
	Keybinds KeybindsConfig `json:"keybinds"`
	// @deprecated Always uses stretch layout.
	Layout ConfigLayout `json:"layout"`
	// MCP (Model Context Protocol) server configurations
	Mcp map[string]ConfigMcp `json:"mcp"`
	// Modes configuration, see https://opencode.ai/docs/modes
	Mode ConfigMode `json:"mode"`
	// Model to use in the format of provider/model, eg anthropic/claude-2
	Model string `json:"model"`
	// Custom provider configurations and model overrides
	Provider map[string]ConfigProvider `json:"provider"`
	// Control sharing behavior:'manual' allows manual sharing via commands, 'auto'
	// enables automatic sharing, 'disabled' disables all sharing
	Share ConfigShare `json:"share"`
	// Small model to use for tasks like summarization and title generation in the
	// format of provider/model
	SmallModel string `json:"small_model"`
	// Theme name to use for the interface
	Theme string `json:"theme"`
	// Custom username to display in conversations instead of system username
	Username string     `json:"username"`
	JSON     configJSON `json:"-"`
}

func (*Config) UnmarshalJSON

func (r *Config) UnmarshalJSON(data []byte) (err error)

type ConfigExperimental

type ConfigExperimental struct {
	Hook ConfigExperimentalHook `json:"hook"`
	JSON configExperimentalJSON `json:"-"`
}

func (*ConfigExperimental) UnmarshalJSON

func (r *ConfigExperimental) UnmarshalJSON(data []byte) (err error)

type ConfigExperimentalHook

type ConfigExperimentalHook struct {
	FileEdited       map[string][]ConfigExperimentalHookFileEdited `json:"file_edited"`
	SessionCompleted []ConfigExperimentalHookSessionCompleted      `json:"session_completed"`
	JSON             configExperimentalHookJSON                    `json:"-"`
}

func (*ConfigExperimentalHook) UnmarshalJSON

func (r *ConfigExperimentalHook) UnmarshalJSON(data []byte) (err error)

type ConfigExperimentalHookFileEdited

type ConfigExperimentalHookFileEdited struct {
	Command     []string                             `json:"command,required"`
	Environment map[string]string                    `json:"environment"`
	JSON        configExperimentalHookFileEditedJSON `json:"-"`
}

func (*ConfigExperimentalHookFileEdited) UnmarshalJSON

func (r *ConfigExperimentalHookFileEdited) UnmarshalJSON(data []byte) (err error)

type ConfigExperimentalHookSessionCompleted

type ConfigExperimentalHookSessionCompleted struct {
	Command     []string                                   `json:"command,required"`
	Environment map[string]string                          `json:"environment"`
	JSON        configExperimentalHookSessionCompletedJSON `json:"-"`
}

func (*ConfigExperimentalHookSessionCompleted) UnmarshalJSON

func (r *ConfigExperimentalHookSessionCompleted) UnmarshalJSON(data []byte) (err error)

type ConfigLayout

type ConfigLayout string

@deprecated Always uses stretch layout.

const (
	ConfigLayoutAuto    ConfigLayout = "auto"
	ConfigLayoutStretch ConfigLayout = "stretch"
)

func (ConfigLayout) IsKnown

func (r ConfigLayout) IsKnown() bool

type ConfigMcp

type ConfigMcp struct {
	// Type of MCP server connection
	Type ConfigMcpType `json:"type,required"`
	// This field can have the runtime type of [[]string].
	Command interface{} `json:"command"`
	// Enable or disable the MCP server on startup
	Enabled bool `json:"enabled"`
	// This field can have the runtime type of [map[string]string].
	Environment interface{} `json:"environment"`
	// This field can have the runtime type of [map[string]string].
	Headers interface{} `json:"headers"`
	// URL of the remote MCP server
	URL  string        `json:"url"`
	JSON configMcpJSON `json:"-"`
	// contains filtered or unexported fields
}

func (ConfigMcp) AsUnion

func (r ConfigMcp) AsUnion() ConfigMcpUnion

AsUnion returns a ConfigMcpUnion interface which you can cast to the specific types for more type safety.

Possible runtime types of the union are McpLocalConfig, McpRemoteConfig.

func (*ConfigMcp) UnmarshalJSON

func (r *ConfigMcp) UnmarshalJSON(data []byte) (err error)

type ConfigMcpType

type ConfigMcpType string

Type of MCP server connection

const (
	ConfigMcpTypeLocal  ConfigMcpType = "local"
	ConfigMcpTypeRemote ConfigMcpType = "remote"
)

func (ConfigMcpType) IsKnown

func (r ConfigMcpType) IsKnown() bool

type ConfigMcpUnion

type ConfigMcpUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by McpLocalConfig or McpRemoteConfig.

type ConfigMode

type ConfigMode struct {
	Build       ModeConfig            `json:"build"`
	Plan        ModeConfig            `json:"plan"`
	ExtraFields map[string]ModeConfig `json:"-,extras"`
	JSON        configModeJSON        `json:"-"`
}

Modes configuration, see https://opencode.ai/docs/modes

func (*ConfigMode) UnmarshalJSON

func (r *ConfigMode) UnmarshalJSON(data []byte) (err error)

type ConfigProvider

type ConfigProvider struct {
	Models  map[string]ConfigProviderModel `json:"models,required"`
	ID      string                         `json:"id"`
	API     string                         `json:"api"`
	Env     []string                       `json:"env"`
	Name    string                         `json:"name"`
	Npm     string                         `json:"npm"`
	Options map[string]interface{}         `json:"options"`
	JSON    configProviderJSON             `json:"-"`
}

func (*ConfigProvider) UnmarshalJSON

func (r *ConfigProvider) UnmarshalJSON(data []byte) (err error)

type ConfigProviderModel

type ConfigProviderModel struct {
	ID          string                    `json:"id"`
	Attachment  bool                      `json:"attachment"`
	Cost        ConfigProviderModelsCost  `json:"cost"`
	Limit       ConfigProviderModelsLimit `json:"limit"`
	Name        string                    `json:"name"`
	Options     map[string]interface{}    `json:"options"`
	Reasoning   bool                      `json:"reasoning"`
	ReleaseDate string                    `json:"release_date"`
	Temperature bool                      `json:"temperature"`
	ToolCall    bool                      `json:"tool_call"`
	JSON        configProviderModelJSON   `json:"-"`
}

func (*ConfigProviderModel) UnmarshalJSON

func (r *ConfigProviderModel) UnmarshalJSON(data []byte) (err error)

type ConfigProviderModelsCost

type ConfigProviderModelsCost struct {
	Input      float64                      `json:"input,required"`
	Output     float64                      `json:"output,required"`
	CacheRead  float64                      `json:"cache_read"`
	CacheWrite float64                      `json:"cache_write"`
	JSON       configProviderModelsCostJSON `json:"-"`
}

func (*ConfigProviderModelsCost) UnmarshalJSON

func (r *ConfigProviderModelsCost) UnmarshalJSON(data []byte) (err error)

type ConfigProviderModelsLimit

type ConfigProviderModelsLimit struct {
	Context float64                       `json:"context,required"`
	Output  float64                       `json:"output,required"`
	JSON    configProviderModelsLimitJSON `json:"-"`
}

func (*ConfigProviderModelsLimit) UnmarshalJSON

func (r *ConfigProviderModelsLimit) UnmarshalJSON(data []byte) (err error)

type ConfigService

type ConfigService struct {
	Options []option.RequestOption
}

ConfigService contains methods and other services that help with interacting with the opencode API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewConfigService method instead.

func NewConfigService

func NewConfigService(opts ...option.RequestOption) (r *ConfigService)

NewConfigService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ConfigService) Get

func (r *ConfigService) Get(ctx context.Context, opts ...option.RequestOption) (res *Config, err error)

Get config info

type ConfigShare

type ConfigShare string

Control sharing behavior:'manual' allows manual sharing via commands, 'auto' enables automatic sharing, 'disabled' disables all sharing

const (
	ConfigShareManual   ConfigShare = "manual"
	ConfigShareAuto     ConfigShare = "auto"
	ConfigShareDisabled ConfigShare = "disabled"
)

func (ConfigShare) IsKnown

func (r ConfigShare) IsKnown() bool

type Error

type Error = apierror.Error

type EventListResponse

type EventListResponse struct {
	// This field can have the runtime type of
	// [EventListResponseEventLspClientDiagnosticsProperties],
	// [EventListResponseEventPermissionUpdatedProperties],
	// [EventListResponseEventFileEditedProperties],
	// [EventListResponseEventInstallationUpdatedProperties],
	// [EventListResponseEventMessageUpdatedProperties],
	// [EventListResponseEventMessageRemovedProperties],
	// [EventListResponseEventMessagePartUpdatedProperties],
	// [EventListResponseEventStorageWriteProperties],
	// [EventListResponseEventSessionUpdatedProperties],
	// [EventListResponseEventSessionDeletedProperties],
	// [EventListResponseEventSessionIdleProperties],
	// [EventListResponseEventSessionErrorProperties],
	// [EventListResponseEventFileWatcherUpdatedProperties].
	Properties interface{}           `json:"properties,required"`
	Type       EventListResponseType `json:"type,required"`
	JSON       eventListResponseJSON `json:"-"`
	// contains filtered or unexported fields
}

func (*EventListResponse) UnmarshalJSON

func (r *EventListResponse) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventFileEdited

type EventListResponseEventFileEdited struct {
	Properties EventListResponseEventFileEditedProperties `json:"properties,required"`
	Type       EventListResponseEventFileEditedType       `json:"type,required"`
	JSON       eventListResponseEventFileEditedJSON       `json:"-"`
}

func (*EventListResponseEventFileEdited) UnmarshalJSON

func (r *EventListResponseEventFileEdited) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventFileEditedProperties

type EventListResponseEventFileEditedProperties struct {
	File string                                         `json:"file,required"`
	JSON eventListResponseEventFileEditedPropertiesJSON `json:"-"`
}

func (*EventListResponseEventFileEditedProperties) UnmarshalJSON

func (r *EventListResponseEventFileEditedProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventFileEditedType

type EventListResponseEventFileEditedType string
const (
	EventListResponseEventFileEditedTypeFileEdited EventListResponseEventFileEditedType = "file.edited"
)

func (EventListResponseEventFileEditedType) IsKnown

type EventListResponseEventFileWatcherUpdated added in v0.16.0

type EventListResponseEventFileWatcherUpdated struct {
	Properties EventListResponseEventFileWatcherUpdatedProperties `json:"properties,required"`
	Type       EventListResponseEventFileWatcherUpdatedType       `json:"type,required"`
	JSON       eventListResponseEventFileWatcherUpdatedJSON       `json:"-"`
}

func (*EventListResponseEventFileWatcherUpdated) UnmarshalJSON added in v0.16.0

func (r *EventListResponseEventFileWatcherUpdated) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventFileWatcherUpdatedProperties added in v0.16.0

type EventListResponseEventFileWatcherUpdatedProperties struct {
	Event EventListResponseEventFileWatcherUpdatedPropertiesEvent `json:"event,required"`
	File  string                                                  `json:"file,required"`
	JSON  eventListResponseEventFileWatcherUpdatedPropertiesJSON  `json:"-"`
}

func (*EventListResponseEventFileWatcherUpdatedProperties) UnmarshalJSON added in v0.16.0

func (r *EventListResponseEventFileWatcherUpdatedProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventFileWatcherUpdatedPropertiesEvent added in v0.16.0

type EventListResponseEventFileWatcherUpdatedPropertiesEvent string
const (
	EventListResponseEventFileWatcherUpdatedPropertiesEventRename EventListResponseEventFileWatcherUpdatedPropertiesEvent = "rename"
	EventListResponseEventFileWatcherUpdatedPropertiesEventChange EventListResponseEventFileWatcherUpdatedPropertiesEvent = "change"
)

func (EventListResponseEventFileWatcherUpdatedPropertiesEvent) IsKnown added in v0.16.0

type EventListResponseEventFileWatcherUpdatedType added in v0.16.0

type EventListResponseEventFileWatcherUpdatedType string
const (
	EventListResponseEventFileWatcherUpdatedTypeFileWatcherUpdated EventListResponseEventFileWatcherUpdatedType = "file.watcher.updated"
)

func (EventListResponseEventFileWatcherUpdatedType) IsKnown added in v0.16.0

type EventListResponseEventInstallationUpdated

type EventListResponseEventInstallationUpdated struct {
	Properties EventListResponseEventInstallationUpdatedProperties `json:"properties,required"`
	Type       EventListResponseEventInstallationUpdatedType       `json:"type,required"`
	JSON       eventListResponseEventInstallationUpdatedJSON       `json:"-"`
}

func (*EventListResponseEventInstallationUpdated) UnmarshalJSON

func (r *EventListResponseEventInstallationUpdated) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventInstallationUpdatedProperties

type EventListResponseEventInstallationUpdatedProperties struct {
	Version string                                                  `json:"version,required"`
	JSON    eventListResponseEventInstallationUpdatedPropertiesJSON `json:"-"`
}

func (*EventListResponseEventInstallationUpdatedProperties) UnmarshalJSON

func (r *EventListResponseEventInstallationUpdatedProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventInstallationUpdatedType

type EventListResponseEventInstallationUpdatedType string
const (
	EventListResponseEventInstallationUpdatedTypeInstallationUpdated EventListResponseEventInstallationUpdatedType = "installation.updated"
)

func (EventListResponseEventInstallationUpdatedType) IsKnown

type EventListResponseEventLspClientDiagnostics

type EventListResponseEventLspClientDiagnostics struct {
	Properties EventListResponseEventLspClientDiagnosticsProperties `json:"properties,required"`
	Type       EventListResponseEventLspClientDiagnosticsType       `json:"type,required"`
	JSON       eventListResponseEventLspClientDiagnosticsJSON       `json:"-"`
}

func (*EventListResponseEventLspClientDiagnostics) UnmarshalJSON

func (r *EventListResponseEventLspClientDiagnostics) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventLspClientDiagnosticsProperties

type EventListResponseEventLspClientDiagnosticsProperties struct {
	Path     string                                                   `json:"path,required"`
	ServerID string                                                   `json:"serverID,required"`
	JSON     eventListResponseEventLspClientDiagnosticsPropertiesJSON `json:"-"`
}

func (*EventListResponseEventLspClientDiagnosticsProperties) UnmarshalJSON

func (r *EventListResponseEventLspClientDiagnosticsProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventLspClientDiagnosticsType

type EventListResponseEventLspClientDiagnosticsType string
const (
	EventListResponseEventLspClientDiagnosticsTypeLspClientDiagnostics EventListResponseEventLspClientDiagnosticsType = "lsp.client.diagnostics"
)

func (EventListResponseEventLspClientDiagnosticsType) IsKnown

type EventListResponseEventMessagePartUpdated

type EventListResponseEventMessagePartUpdated struct {
	Properties EventListResponseEventMessagePartUpdatedProperties `json:"properties,required"`
	Type       EventListResponseEventMessagePartUpdatedType       `json:"type,required"`
	JSON       eventListResponseEventMessagePartUpdatedJSON       `json:"-"`
}

func (*EventListResponseEventMessagePartUpdated) UnmarshalJSON

func (r *EventListResponseEventMessagePartUpdated) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventMessagePartUpdatedProperties

type EventListResponseEventMessagePartUpdatedProperties struct {
	Part Part                                                   `json:"part,required"`
	JSON eventListResponseEventMessagePartUpdatedPropertiesJSON `json:"-"`
}

func (*EventListResponseEventMessagePartUpdatedProperties) UnmarshalJSON

func (r *EventListResponseEventMessagePartUpdatedProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventMessagePartUpdatedType

type EventListResponseEventMessagePartUpdatedType string
const (
	EventListResponseEventMessagePartUpdatedTypeMessagePartUpdated EventListResponseEventMessagePartUpdatedType = "message.part.updated"
)

func (EventListResponseEventMessagePartUpdatedType) IsKnown

type EventListResponseEventMessageRemoved

type EventListResponseEventMessageRemoved struct {
	Properties EventListResponseEventMessageRemovedProperties `json:"properties,required"`
	Type       EventListResponseEventMessageRemovedType       `json:"type,required"`
	JSON       eventListResponseEventMessageRemovedJSON       `json:"-"`
}

func (*EventListResponseEventMessageRemoved) UnmarshalJSON

func (r *EventListResponseEventMessageRemoved) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventMessageRemovedProperties

type EventListResponseEventMessageRemovedProperties struct {
	MessageID string                                             `json:"messageID,required"`
	SessionID string                                             `json:"sessionID,required"`
	JSON      eventListResponseEventMessageRemovedPropertiesJSON `json:"-"`
}

func (*EventListResponseEventMessageRemovedProperties) UnmarshalJSON

func (r *EventListResponseEventMessageRemovedProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventMessageRemovedType

type EventListResponseEventMessageRemovedType string
const (
	EventListResponseEventMessageRemovedTypeMessageRemoved EventListResponseEventMessageRemovedType = "message.removed"
)

func (EventListResponseEventMessageRemovedType) IsKnown

type EventListResponseEventMessageUpdated

type EventListResponseEventMessageUpdated struct {
	Properties EventListResponseEventMessageUpdatedProperties `json:"properties,required"`
	Type       EventListResponseEventMessageUpdatedType       `json:"type,required"`
	JSON       eventListResponseEventMessageUpdatedJSON       `json:"-"`
}

func (*EventListResponseEventMessageUpdated) UnmarshalJSON

func (r *EventListResponseEventMessageUpdated) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventMessageUpdatedProperties

type EventListResponseEventMessageUpdatedProperties struct {
	Info Message                                            `json:"info,required"`
	JSON eventListResponseEventMessageUpdatedPropertiesJSON `json:"-"`
}

func (*EventListResponseEventMessageUpdatedProperties) UnmarshalJSON

func (r *EventListResponseEventMessageUpdatedProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventMessageUpdatedType

type EventListResponseEventMessageUpdatedType string
const (
	EventListResponseEventMessageUpdatedTypeMessageUpdated EventListResponseEventMessageUpdatedType = "message.updated"
)

func (EventListResponseEventMessageUpdatedType) IsKnown

type EventListResponseEventPermissionUpdated

type EventListResponseEventPermissionUpdated struct {
	Properties EventListResponseEventPermissionUpdatedProperties `json:"properties,required"`
	Type       EventListResponseEventPermissionUpdatedType       `json:"type,required"`
	JSON       eventListResponseEventPermissionUpdatedJSON       `json:"-"`
}

func (*EventListResponseEventPermissionUpdated) UnmarshalJSON

func (r *EventListResponseEventPermissionUpdated) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventPermissionUpdatedProperties

type EventListResponseEventPermissionUpdatedProperties struct {
	ID        string                                                `json:"id,required"`
	Metadata  map[string]interface{}                                `json:"metadata,required"`
	SessionID string                                                `json:"sessionID,required"`
	Time      EventListResponseEventPermissionUpdatedPropertiesTime `json:"time,required"`
	Title     string                                                `json:"title,required"`
	JSON      eventListResponseEventPermissionUpdatedPropertiesJSON `json:"-"`
}

func (*EventListResponseEventPermissionUpdatedProperties) UnmarshalJSON

func (r *EventListResponseEventPermissionUpdatedProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventPermissionUpdatedPropertiesTime

type EventListResponseEventPermissionUpdatedPropertiesTime struct {
	Created float64                                                   `json:"created,required"`
	JSON    eventListResponseEventPermissionUpdatedPropertiesTimeJSON `json:"-"`
}

func (*EventListResponseEventPermissionUpdatedPropertiesTime) UnmarshalJSON

func (r *EventListResponseEventPermissionUpdatedPropertiesTime) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventPermissionUpdatedType

type EventListResponseEventPermissionUpdatedType string
const (
	EventListResponseEventPermissionUpdatedTypePermissionUpdated EventListResponseEventPermissionUpdatedType = "permission.updated"
)

func (EventListResponseEventPermissionUpdatedType) IsKnown

type EventListResponseEventSessionDeleted

type EventListResponseEventSessionDeleted struct {
	Properties EventListResponseEventSessionDeletedProperties `json:"properties,required"`
	Type       EventListResponseEventSessionDeletedType       `json:"type,required"`
	JSON       eventListResponseEventSessionDeletedJSON       `json:"-"`
}

func (*EventListResponseEventSessionDeleted) UnmarshalJSON

func (r *EventListResponseEventSessionDeleted) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventSessionDeletedProperties

type EventListResponseEventSessionDeletedProperties struct {
	Info Session                                            `json:"info,required"`
	JSON eventListResponseEventSessionDeletedPropertiesJSON `json:"-"`
}

func (*EventListResponseEventSessionDeletedProperties) UnmarshalJSON

func (r *EventListResponseEventSessionDeletedProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventSessionDeletedType

type EventListResponseEventSessionDeletedType string
const (
	EventListResponseEventSessionDeletedTypeSessionDeleted EventListResponseEventSessionDeletedType = "session.deleted"
)

func (EventListResponseEventSessionDeletedType) IsKnown

type EventListResponseEventSessionError

type EventListResponseEventSessionError struct {
	Properties EventListResponseEventSessionErrorProperties `json:"properties,required"`
	Type       EventListResponseEventSessionErrorType       `json:"type,required"`
	JSON       eventListResponseEventSessionErrorJSON       `json:"-"`
}

func (*EventListResponseEventSessionError) UnmarshalJSON

func (r *EventListResponseEventSessionError) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventSessionErrorProperties

type EventListResponseEventSessionErrorProperties struct {
	Error     EventListResponseEventSessionErrorPropertiesError `json:"error"`
	SessionID string                                            `json:"sessionID"`
	JSON      eventListResponseEventSessionErrorPropertiesJSON  `json:"-"`
}

func (*EventListResponseEventSessionErrorProperties) UnmarshalJSON

func (r *EventListResponseEventSessionErrorProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventSessionErrorPropertiesError

type EventListResponseEventSessionErrorPropertiesError struct {
	// This field can have the runtime type of [shared.ProviderAuthErrorData],
	// [shared.UnknownErrorData], [interface{}].
	Data interface{}                                           `json:"data,required"`
	Name EventListResponseEventSessionErrorPropertiesErrorName `json:"name,required"`
	JSON eventListResponseEventSessionErrorPropertiesErrorJSON `json:"-"`
	// contains filtered or unexported fields
}

func (EventListResponseEventSessionErrorPropertiesError) AsUnion

AsUnion returns a EventListResponseEventSessionErrorPropertiesErrorUnion interface which you can cast to the specific types for more type safety.

Possible runtime types of the union are shared.ProviderAuthError, shared.UnknownError, EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError, shared.MessageAbortedError.

func (*EventListResponseEventSessionErrorPropertiesError) UnmarshalJSON

func (r *EventListResponseEventSessionErrorPropertiesError) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError

type EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError struct {
	Data interface{}                                                                   `json:"data,required"`
	Name EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthErrorName `json:"name,required"`
	JSON eventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthErrorJSON `json:"-"`
}

func (EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError) ImplementsEventListResponseEventSessionErrorPropertiesError

func (r EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError) ImplementsEventListResponseEventSessionErrorPropertiesError()

func (*EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError) UnmarshalJSON

type EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthErrorName

type EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthErrorName string
const (
	EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthErrorNameMessageOutputLengthError EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthErrorName = "MessageOutputLengthError"
)

func (EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthErrorName) IsKnown

type EventListResponseEventSessionErrorPropertiesErrorName

type EventListResponseEventSessionErrorPropertiesErrorName string
const (
	EventListResponseEventSessionErrorPropertiesErrorNameProviderAuthError        EventListResponseEventSessionErrorPropertiesErrorName = "ProviderAuthError"
	EventListResponseEventSessionErrorPropertiesErrorNameUnknownError             EventListResponseEventSessionErrorPropertiesErrorName = "UnknownError"
	EventListResponseEventSessionErrorPropertiesErrorNameMessageOutputLengthError EventListResponseEventSessionErrorPropertiesErrorName = "MessageOutputLengthError"
	EventListResponseEventSessionErrorPropertiesErrorNameMessageAbortedError      EventListResponseEventSessionErrorPropertiesErrorName = "MessageAbortedError"
)

func (EventListResponseEventSessionErrorPropertiesErrorName) IsKnown

type EventListResponseEventSessionErrorPropertiesErrorUnion

type EventListResponseEventSessionErrorPropertiesErrorUnion interface {
	ImplementsEventListResponseEventSessionErrorPropertiesError()
}

Union satisfied by shared.ProviderAuthError, shared.UnknownError, EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError or shared.MessageAbortedError.

type EventListResponseEventSessionErrorType

type EventListResponseEventSessionErrorType string
const (
	EventListResponseEventSessionErrorTypeSessionError EventListResponseEventSessionErrorType = "session.error"
)

func (EventListResponseEventSessionErrorType) IsKnown

type EventListResponseEventSessionIdle

type EventListResponseEventSessionIdle struct {
	Properties EventListResponseEventSessionIdleProperties `json:"properties,required"`
	Type       EventListResponseEventSessionIdleType       `json:"type,required"`
	JSON       eventListResponseEventSessionIdleJSON       `json:"-"`
}

func (*EventListResponseEventSessionIdle) UnmarshalJSON

func (r *EventListResponseEventSessionIdle) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventSessionIdleProperties

type EventListResponseEventSessionIdleProperties struct {
	SessionID string                                          `json:"sessionID,required"`
	JSON      eventListResponseEventSessionIdlePropertiesJSON `json:"-"`
}

func (*EventListResponseEventSessionIdleProperties) UnmarshalJSON

func (r *EventListResponseEventSessionIdleProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventSessionIdleType

type EventListResponseEventSessionIdleType string
const (
	EventListResponseEventSessionIdleTypeSessionIdle EventListResponseEventSessionIdleType = "session.idle"
)

func (EventListResponseEventSessionIdleType) IsKnown

type EventListResponseEventSessionUpdated

type EventListResponseEventSessionUpdated struct {
	Properties EventListResponseEventSessionUpdatedProperties `json:"properties,required"`
	Type       EventListResponseEventSessionUpdatedType       `json:"type,required"`
	JSON       eventListResponseEventSessionUpdatedJSON       `json:"-"`
}

func (*EventListResponseEventSessionUpdated) UnmarshalJSON

func (r *EventListResponseEventSessionUpdated) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventSessionUpdatedProperties

type EventListResponseEventSessionUpdatedProperties struct {
	Info Session                                            `json:"info,required"`
	JSON eventListResponseEventSessionUpdatedPropertiesJSON `json:"-"`
}

func (*EventListResponseEventSessionUpdatedProperties) UnmarshalJSON

func (r *EventListResponseEventSessionUpdatedProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventSessionUpdatedType

type EventListResponseEventSessionUpdatedType string
const (
	EventListResponseEventSessionUpdatedTypeSessionUpdated EventListResponseEventSessionUpdatedType = "session.updated"
)

func (EventListResponseEventSessionUpdatedType) IsKnown

type EventListResponseEventStorageWrite

type EventListResponseEventStorageWrite struct {
	Properties EventListResponseEventStorageWriteProperties `json:"properties,required"`
	Type       EventListResponseEventStorageWriteType       `json:"type,required"`
	JSON       eventListResponseEventStorageWriteJSON       `json:"-"`
}

func (*EventListResponseEventStorageWrite) UnmarshalJSON

func (r *EventListResponseEventStorageWrite) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventStorageWriteProperties

type EventListResponseEventStorageWriteProperties struct {
	Key     string                                           `json:"key,required"`
	Content interface{}                                      `json:"content"`
	JSON    eventListResponseEventStorageWritePropertiesJSON `json:"-"`
}

func (*EventListResponseEventStorageWriteProperties) UnmarshalJSON

func (r *EventListResponseEventStorageWriteProperties) UnmarshalJSON(data []byte) (err error)

type EventListResponseEventStorageWriteType

type EventListResponseEventStorageWriteType string
const (
	EventListResponseEventStorageWriteTypeStorageWrite EventListResponseEventStorageWriteType = "storage.write"
)

func (EventListResponseEventStorageWriteType) IsKnown

type EventListResponseType

type EventListResponseType string
const (
	EventListResponseTypeLspClientDiagnostics EventListResponseType = "lsp.client.diagnostics"
	EventListResponseTypePermissionUpdated    EventListResponseType = "permission.updated"
	EventListResponseTypeFileEdited           EventListResponseType = "file.edited"
	EventListResponseTypeInstallationUpdated  EventListResponseType = "installation.updated"
	EventListResponseTypeMessageUpdated       EventListResponseType = "message.updated"
	EventListResponseTypeMessageRemoved       EventListResponseType = "message.removed"
	EventListResponseTypeMessagePartUpdated   EventListResponseType = "message.part.updated"
	EventListResponseTypeStorageWrite         EventListResponseType = "storage.write"
	EventListResponseTypeSessionUpdated       EventListResponseType = "session.updated"
	EventListResponseTypeSessionDeleted       EventListResponseType = "session.deleted"
	EventListResponseTypeSessionIdle          EventListResponseType = "session.idle"
	EventListResponseTypeSessionError         EventListResponseType = "session.error"
	EventListResponseTypeFileWatcherUpdated   EventListResponseType = "file.watcher.updated"
)

func (EventListResponseType) IsKnown

func (r EventListResponseType) IsKnown() bool

type EventService

type EventService struct {
	Options []option.RequestOption
}

EventService contains methods and other services that help with interacting with the opencode API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewEventService method instead.

func NewEventService

func NewEventService(opts ...option.RequestOption) (r *EventService)

NewEventService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*EventService) ListStreaming

func (r *EventService) ListStreaming(ctx context.Context, opts ...option.RequestOption) (stream *ssestream.Stream[EventListResponse])

Get events

type File

type File struct {
	Added   int64      `json:"added,required"`
	Path    string     `json:"path,required"`
	Removed int64      `json:"removed,required"`
	Status  FileStatus `json:"status,required"`
	JSON    fileJSON   `json:"-"`
}

func (*File) UnmarshalJSON

func (r *File) UnmarshalJSON(data []byte) (err error)

type FilePart

type FilePart struct {
	ID        string         `json:"id,required"`
	MessageID string         `json:"messageID,required"`
	Mime      string         `json:"mime,required"`
	SessionID string         `json:"sessionID,required"`
	Type      FilePartType   `json:"type,required"`
	URL       string         `json:"url,required"`
	Filename  string         `json:"filename"`
	Source    FilePartSource `json:"source"`
	JSON      filePartJSON   `json:"-"`
}

func (*FilePart) UnmarshalJSON

func (r *FilePart) UnmarshalJSON(data []byte) (err error)

type FilePartInputParam

type FilePartInputParam struct {
	Mime     param.Field[string]                   `json:"mime,required"`
	Type     param.Field[FilePartInputType]        `json:"type,required"`
	URL      param.Field[string]                   `json:"url,required"`
	ID       param.Field[string]                   `json:"id"`
	Filename param.Field[string]                   `json:"filename"`
	Source   param.Field[FilePartSourceUnionParam] `json:"source"`
}

func (FilePartInputParam) MarshalJSON

func (r FilePartInputParam) MarshalJSON() (data []byte, err error)

type FilePartInputType

type FilePartInputType string
const (
	FilePartInputTypeFile FilePartInputType = "file"
)

func (FilePartInputType) IsKnown

func (r FilePartInputType) IsKnown() bool

type FilePartParam

type FilePartParam struct {
	ID        param.Field[string]                   `json:"id,required"`
	MessageID param.Field[string]                   `json:"messageID,required"`
	Mime      param.Field[string]                   `json:"mime,required"`
	SessionID param.Field[string]                   `json:"sessionID,required"`
	Type      param.Field[FilePartType]             `json:"type,required"`
	URL       param.Field[string]                   `json:"url,required"`
	Filename  param.Field[string]                   `json:"filename"`
	Source    param.Field[FilePartSourceUnionParam] `json:"source"`
}

func (FilePartParam) MarshalJSON

func (r FilePartParam) MarshalJSON() (data []byte, err error)

type FilePartSource

type FilePartSource struct {
	Path string             `json:"path,required"`
	Text FilePartSourceText `json:"text,required"`
	Type FilePartSourceType `json:"type,required"`
	Kind int64              `json:"kind"`
	Name string             `json:"name"`
	// This field can have the runtime type of [SymbolSourceRange].
	Range interface{}        `json:"range"`
	JSON  filePartSourceJSON `json:"-"`
	// contains filtered or unexported fields
}

func (FilePartSource) AsUnion

func (r FilePartSource) AsUnion() FilePartSourceUnion

AsUnion returns a FilePartSourceUnion interface which you can cast to the specific types for more type safety.

Possible runtime types of the union are FileSource, SymbolSource.

func (*FilePartSource) UnmarshalJSON

func (r *FilePartSource) UnmarshalJSON(data []byte) (err error)

type FilePartSourceParam

type FilePartSourceParam struct {
	Path  param.Field[string]                  `json:"path,required"`
	Text  param.Field[FilePartSourceTextParam] `json:"text,required"`
	Type  param.Field[FilePartSourceType]      `json:"type,required"`
	Kind  param.Field[int64]                   `json:"kind"`
	Name  param.Field[string]                  `json:"name"`
	Range param.Field[interface{}]             `json:"range"`
}

func (FilePartSourceParam) MarshalJSON

func (r FilePartSourceParam) MarshalJSON() (data []byte, err error)

type FilePartSourceText

type FilePartSourceText struct {
	End   int64                  `json:"end,required"`
	Start int64                  `json:"start,required"`
	Value string                 `json:"value,required"`
	JSON  filePartSourceTextJSON `json:"-"`
}

func (*FilePartSourceText) UnmarshalJSON

func (r *FilePartSourceText) UnmarshalJSON(data []byte) (err error)

type FilePartSourceTextParam

type FilePartSourceTextParam struct {
	End   param.Field[int64]  `json:"end,required"`
	Start param.Field[int64]  `json:"start,required"`
	Value param.Field[string] `json:"value,required"`
}

func (FilePartSourceTextParam) MarshalJSON

func (r FilePartSourceTextParam) MarshalJSON() (data []byte, err error)

type FilePartSourceType

type FilePartSourceType string
const (
	FilePartSourceTypeFile   FilePartSourceType = "file"
	FilePartSourceTypeSymbol FilePartSourceType = "symbol"
)

func (FilePartSourceType) IsKnown

func (r FilePartSourceType) IsKnown() bool

type FilePartSourceUnion

type FilePartSourceUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by FileSource or SymbolSource.

type FilePartSourceUnionParam

type FilePartSourceUnionParam interface {
	// contains filtered or unexported methods
}

Satisfied by FileSourceParam, SymbolSourceParam, FilePartSourceParam.

type FilePartType

type FilePartType string
const (
	FilePartTypeFile FilePartType = "file"
)

func (FilePartType) IsKnown

func (r FilePartType) IsKnown() bool

type FileReadParams

type FileReadParams struct {
	Path param.Field[string] `query:"path,required"`
}

func (FileReadParams) URLQuery

func (r FileReadParams) URLQuery() (v url.Values)

URLQuery serializes FileReadParams's query parameters as `url.Values`.

type FileReadResponse

type FileReadResponse struct {
	Content string               `json:"content,required"`
	Type    FileReadResponseType `json:"type,required"`
	JSON    fileReadResponseJSON `json:"-"`
}

func (*FileReadResponse) UnmarshalJSON

func (r *FileReadResponse) UnmarshalJSON(data []byte) (err error)

type FileReadResponseType

type FileReadResponseType string
const (
	FileReadResponseTypeRaw   FileReadResponseType = "raw"
	FileReadResponseTypePatch FileReadResponseType = "patch"
)

func (FileReadResponseType) IsKnown

func (r FileReadResponseType) IsKnown() bool

type FileService

type FileService struct {
	Options []option.RequestOption
}

FileService contains methods and other services that help with interacting with the opencode API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFileService method instead.

func NewFileService

func NewFileService(opts ...option.RequestOption) (r *FileService)

NewFileService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*FileService) Read

func (r *FileService) Read(ctx context.Context, query FileReadParams, opts ...option.RequestOption) (res *FileReadResponse, err error)

Read a file

func (*FileService) Status

func (r *FileService) Status(ctx context.Context, opts ...option.RequestOption) (res *[]File, err error)

Get file status

type FileSource

type FileSource struct {
	Path string             `json:"path,required"`
	Text FilePartSourceText `json:"text,required"`
	Type FileSourceType     `json:"type,required"`
	JSON fileSourceJSON     `json:"-"`
}

func (*FileSource) UnmarshalJSON

func (r *FileSource) UnmarshalJSON(data []byte) (err error)

type FileSourceParam

type FileSourceParam struct {
	Path param.Field[string]                  `json:"path,required"`
	Text param.Field[FilePartSourceTextParam] `json:"text,required"`
	Type param.Field[FileSourceType]          `json:"type,required"`
}

func (FileSourceParam) MarshalJSON

func (r FileSourceParam) MarshalJSON() (data []byte, err error)

type FileSourceType

type FileSourceType string
const (
	FileSourceTypeFile FileSourceType = "file"
)

func (FileSourceType) IsKnown

func (r FileSourceType) IsKnown() bool

type FileStatus

type FileStatus string
const (
	FileStatusAdded    FileStatus = "added"
	FileStatusDeleted  FileStatus = "deleted"
	FileStatusModified FileStatus = "modified"
)

func (FileStatus) IsKnown

func (r FileStatus) IsKnown() bool

type FindFilesParams

type FindFilesParams struct {
	Query param.Field[string] `query:"query,required"`
}

func (FindFilesParams) URLQuery

func (r FindFilesParams) URLQuery() (v url.Values)

URLQuery serializes FindFilesParams's query parameters as `url.Values`.

type FindService

type FindService struct {
	Options []option.RequestOption
}

FindService contains methods and other services that help with interacting with the opencode API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFindService method instead.

func NewFindService

func NewFindService(opts ...option.RequestOption) (r *FindService)

NewFindService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*FindService) Files

func (r *FindService) Files(ctx context.Context, query FindFilesParams, opts ...option.RequestOption) (res *[]string, err error)

Find files

func (*FindService) Symbols

func (r *FindService) Symbols(ctx context.Context, query FindSymbolsParams, opts ...option.RequestOption) (res *[]Symbol, err error)

Find workspace symbols

func (*FindService) Text

func (r *FindService) Text(ctx context.Context, query FindTextParams, opts ...option.RequestOption) (res *[]Match, err error)

Find text in files

type FindSymbolsParams

type FindSymbolsParams struct {
	Query param.Field[string] `query:"query,required"`
}

func (FindSymbolsParams) URLQuery

func (r FindSymbolsParams) URLQuery() (v url.Values)

URLQuery serializes FindSymbolsParams's query parameters as `url.Values`.

type FindTextParams

type FindTextParams struct {
	Pattern param.Field[string] `query:"pattern,required"`
}

func (FindTextParams) URLQuery

func (r FindTextParams) URLQuery() (v url.Values)

URLQuery serializes FindTextParams's query parameters as `url.Values`.

type KeybindsConfig

type KeybindsConfig struct {
	// Exit the application
	AppExit string `json:"app_exit,required"`
	// Show help dialog
	AppHelp string `json:"app_help,required"`
	// Open external editor
	EditorOpen string `json:"editor_open,required"`
	// Close file
	FileClose string `json:"file_close,required"`
	// Split/unified diff
	FileDiffToggle string `json:"file_diff_toggle,required"`
	// List files
	FileList string `json:"file_list,required"`
	// Search file
	FileSearch string `json:"file_search,required"`
	// Clear input field
	InputClear string `json:"input_clear,required"`
	// Insert newline in input
	InputNewline string `json:"input_newline,required"`
	// Paste from clipboard
	InputPaste string `json:"input_paste,required"`
	// Submit input
	InputSubmit string `json:"input_submit,required"`
	// Leader key for keybind combinations
	Leader string `json:"leader,required"`
	// Copy message
	MessagesCopy string `json:"messages_copy,required"`
	// Navigate to first message
	MessagesFirst string `json:"messages_first,required"`
	// Scroll messages down by half page
	MessagesHalfPageDown string `json:"messages_half_page_down,required"`
	// Scroll messages up by half page
	MessagesHalfPageUp string `json:"messages_half_page_up,required"`
	// Navigate to last message
	MessagesLast string `json:"messages_last,required"`
	// Toggle layout
	MessagesLayoutToggle string `json:"messages_layout_toggle,required"`
	// Navigate to next message
	MessagesNext string `json:"messages_next,required"`
	// Scroll messages down by one page
	MessagesPageDown string `json:"messages_page_down,required"`
	// Scroll messages up by one page
	MessagesPageUp string `json:"messages_page_up,required"`
	// Navigate to previous message
	MessagesPrevious string `json:"messages_previous,required"`
	// Revert message
	MessagesRevert string `json:"messages_revert,required"`
	// List available models
	ModelList string `json:"model_list,required"`
	// Create/update AGENTS.md
	ProjectInit string `json:"project_init,required"`
	// Compact the session
	SessionCompact string `json:"session_compact,required"`
	// Export session to editor
	SessionExport string `json:"session_export,required"`
	// Interrupt current session
	SessionInterrupt string `json:"session_interrupt,required"`
	// List all sessions
	SessionList string `json:"session_list,required"`
	// Create a new session
	SessionNew string `json:"session_new,required"`
	// Share current session
	SessionShare string `json:"session_share,required"`
	// Unshare current session
	SessionUnshare string `json:"session_unshare,required"`
	// Next mode
	SwitchMode string `json:"switch_mode,required"`
	// Previous Mode
	SwitchModeReverse string `json:"switch_mode_reverse,required"`
	// List available themes
	ThemeList string `json:"theme_list,required"`
	// Toggle tool details
	ToolDetails string             `json:"tool_details,required"`
	JSON        keybindsConfigJSON `json:"-"`
}

func (*KeybindsConfig) UnmarshalJSON

func (r *KeybindsConfig) UnmarshalJSON(data []byte) (err error)

type Match

type Match struct {
	AbsoluteOffset float64         `json:"absolute_offset,required"`
	LineNumber     float64         `json:"line_number,required"`
	Lines          MatchLines      `json:"lines,required"`
	Path           MatchPath       `json:"path,required"`
	Submatches     []MatchSubmatch `json:"submatches,required"`
	JSON           matchJSON       `json:"-"`
}

func (*Match) UnmarshalJSON

func (r *Match) UnmarshalJSON(data []byte) (err error)

type MatchLines

type MatchLines struct {
	Text string         `json:"text,required"`
	JSON matchLinesJSON `json:"-"`
}

func (*MatchLines) UnmarshalJSON

func (r *MatchLines) UnmarshalJSON(data []byte) (err error)

type MatchPath

type MatchPath struct {
	Text string        `json:"text,required"`
	JSON matchPathJSON `json:"-"`
}

func (*MatchPath) UnmarshalJSON

func (r *MatchPath) UnmarshalJSON(data []byte) (err error)

type MatchSubmatch

type MatchSubmatch struct {
	End   float64              `json:"end,required"`
	Match MatchSubmatchesMatch `json:"match,required"`
	Start float64              `json:"start,required"`
	JSON  matchSubmatchJSON    `json:"-"`
}

func (*MatchSubmatch) UnmarshalJSON

func (r *MatchSubmatch) UnmarshalJSON(data []byte) (err error)

type MatchSubmatchesMatch

type MatchSubmatchesMatch struct {
	Text string                   `json:"text,required"`
	JSON matchSubmatchesMatchJSON `json:"-"`
}

func (*MatchSubmatchesMatch) UnmarshalJSON

func (r *MatchSubmatchesMatch) UnmarshalJSON(data []byte) (err error)

type McpLocalConfig

type McpLocalConfig struct {
	// Command and arguments to run the MCP server
	Command []string `json:"command,required"`
	// Type of MCP server connection
	Type McpLocalConfigType `json:"type,required"`
	// Enable or disable the MCP server on startup
	Enabled bool `json:"enabled"`
	// Environment variables to set when running the MCP server
	Environment map[string]string  `json:"environment"`
	JSON        mcpLocalConfigJSON `json:"-"`
}

func (*McpLocalConfig) UnmarshalJSON

func (r *McpLocalConfig) UnmarshalJSON(data []byte) (err error)

type McpLocalConfigType

type McpLocalConfigType string

Type of MCP server connection

const (
	McpLocalConfigTypeLocal McpLocalConfigType = "local"
)

func (McpLocalConfigType) IsKnown

func (r McpLocalConfigType) IsKnown() bool

type McpRemoteConfig

type McpRemoteConfig struct {
	// Type of MCP server connection
	Type McpRemoteConfigType `json:"type,required"`
	// URL of the remote MCP server
	URL string `json:"url,required"`
	// Enable or disable the MCP server on startup
	Enabled bool `json:"enabled"`
	// Headers to send with the request
	Headers map[string]string   `json:"headers"`
	JSON    mcpRemoteConfigJSON `json:"-"`
}

func (*McpRemoteConfig) UnmarshalJSON

func (r *McpRemoteConfig) UnmarshalJSON(data []byte) (err error)

type McpRemoteConfigType

type McpRemoteConfigType string

Type of MCP server connection

const (
	McpRemoteConfigTypeRemote McpRemoteConfigType = "remote"
)

func (McpRemoteConfigType) IsKnown

func (r McpRemoteConfigType) IsKnown() bool

type Message

type Message struct {
	ID        string      `json:"id,required"`
	Role      MessageRole `json:"role,required"`
	SessionID string      `json:"sessionID,required"`
	// This field can have the runtime type of [UserMessageTime],
	// [AssistantMessageTime].
	Time interface{} `json:"time,required"`
	Cost float64     `json:"cost"`
	// This field can have the runtime type of [AssistantMessageError].
	Error   interface{} `json:"error"`
	ModelID string      `json:"modelID"`
	// This field can have the runtime type of [AssistantMessagePath].
	Path       interface{} `json:"path"`
	ProviderID string      `json:"providerID"`
	Summary    bool        `json:"summary"`
	// This field can have the runtime type of [[]string].
	System interface{} `json:"system"`
	// This field can have the runtime type of [AssistantMessageTokens].
	Tokens interface{} `json:"tokens"`
	JSON   messageJSON `json:"-"`
	// contains filtered or unexported fields
}

func (Message) AsUnion

func (r Message) AsUnion() MessageUnion

AsUnion returns a MessageUnion interface which you can cast to the specific types for more type safety.

Possible runtime types of the union are UserMessage, AssistantMessage.

func (*Message) UnmarshalJSON

func (r *Message) UnmarshalJSON(data []byte) (err error)

type MessageAbortedError

type MessageAbortedError = shared.MessageAbortedError

This is an alias to an internal type.

type MessageAbortedErrorName

type MessageAbortedErrorName = shared.MessageAbortedErrorName

This is an alias to an internal type.

type MessageRole

type MessageRole string
const (
	MessageRoleUser      MessageRole = "user"
	MessageRoleAssistant MessageRole = "assistant"
)

func (MessageRole) IsKnown

func (r MessageRole) IsKnown() bool

type MessageUnion

type MessageUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by UserMessage or AssistantMessage.

type Mode

type Mode struct {
	Name   string          `json:"name,required"`
	Tools  map[string]bool `json:"tools,required"`
	Model  ModeModel       `json:"model"`
	Prompt string          `json:"prompt"`
	JSON   modeJSON        `json:"-"`
}

func (*Mode) UnmarshalJSON

func (r *Mode) UnmarshalJSON(data []byte) (err error)

type ModeConfig

type ModeConfig struct {
	Model  string          `json:"model"`
	Prompt string          `json:"prompt"`
	Tools  map[string]bool `json:"tools"`
	JSON   modeConfigJSON  `json:"-"`
}

func (*ModeConfig) UnmarshalJSON

func (r *ModeConfig) UnmarshalJSON(data []byte) (err error)

type ModeModel

type ModeModel struct {
	ModelID    string        `json:"modelID,required"`
	ProviderID string        `json:"providerID,required"`
	JSON       modeModelJSON `json:"-"`
}

func (*ModeModel) UnmarshalJSON

func (r *ModeModel) UnmarshalJSON(data []byte) (err error)

type Model added in v0.2.0

type Model struct {
	ID          string                 `json:"id,required"`
	Attachment  bool                   `json:"attachment,required"`
	Cost        ModelCost              `json:"cost,required"`
	Limit       ModelLimit             `json:"limit,required"`
	Name        string                 `json:"name,required"`
	Options     map[string]interface{} `json:"options,required"`
	Reasoning   bool                   `json:"reasoning,required"`
	ReleaseDate string                 `json:"release_date,required"`
	Temperature bool                   `json:"temperature,required"`
	ToolCall    bool                   `json:"tool_call,required"`
	JSON        modelJSON              `json:"-"`
}

func (*Model) UnmarshalJSON added in v0.2.0

func (r *Model) UnmarshalJSON(data []byte) (err error)

type ModelCost added in v0.2.0

type ModelCost struct {
	Input      float64       `json:"input,required"`
	Output     float64       `json:"output,required"`
	CacheRead  float64       `json:"cache_read"`
	CacheWrite float64       `json:"cache_write"`
	JSON       modelCostJSON `json:"-"`
}

func (*ModelCost) UnmarshalJSON added in v0.2.0

func (r *ModelCost) UnmarshalJSON(data []byte) (err error)

type ModelLimit added in v0.2.0

type ModelLimit struct {
	Context float64        `json:"context,required"`
	Output  float64        `json:"output,required"`
	JSON    modelLimitJSON `json:"-"`
}

func (*ModelLimit) UnmarshalJSON added in v0.2.0

func (r *ModelLimit) UnmarshalJSON(data []byte) (err error)

type Part

type Part struct {
	ID        string         `json:"id,required"`
	MessageID string         `json:"messageID,required"`
	SessionID string         `json:"sessionID,required"`
	Type      PartType       `json:"type,required"`
	CallID    string         `json:"callID"`
	Cost      float64        `json:"cost"`
	Filename  string         `json:"filename"`
	Mime      string         `json:"mime"`
	Snapshot  string         `json:"snapshot"`
	Source    FilePartSource `json:"source"`
	// This field can have the runtime type of [ToolPartState].
	State     interface{} `json:"state"`
	Synthetic bool        `json:"synthetic"`
	Text      string      `json:"text"`
	// This field can have the runtime type of [TextPartTime].
	Time interface{} `json:"time"`
	// This field can have the runtime type of [StepFinishPartTokens].
	Tokens interface{} `json:"tokens"`
	Tool   string      `json:"tool"`
	URL    string      `json:"url"`
	JSON   partJSON    `json:"-"`
	// contains filtered or unexported fields
}

func (Part) AsUnion

func (r Part) AsUnion() PartUnion

AsUnion returns a PartUnion interface which you can cast to the specific types for more type safety.

Possible runtime types of the union are TextPart, FilePart, ToolPart, StepStartPart, StepFinishPart, SnapshotPart.

func (*Part) UnmarshalJSON

func (r *Part) UnmarshalJSON(data []byte) (err error)

type PartParam

type PartParam struct {
	ID        param.Field[string]                   `json:"id,required"`
	MessageID param.Field[string]                   `json:"messageID,required"`
	SessionID param.Field[string]                   `json:"sessionID,required"`
	Type      param.Field[PartType]                 `json:"type,required"`
	CallID    param.Field[string]                   `json:"callID"`
	Cost      param.Field[float64]                  `json:"cost"`
	Filename  param.Field[string]                   `json:"filename"`
	Mime      param.Field[string]                   `json:"mime"`
	Snapshot  param.Field[string]                   `json:"snapshot"`
	Source    param.Field[FilePartSourceUnionParam] `json:"source"`
	State     param.Field[interface{}]              `json:"state"`
	Synthetic param.Field[bool]                     `json:"synthetic"`
	Text      param.Field[string]                   `json:"text"`
	Time      param.Field[interface{}]              `json:"time"`
	Tokens    param.Field[interface{}]              `json:"tokens"`
	Tool      param.Field[string]                   `json:"tool"`
	URL       param.Field[string]                   `json:"url"`
}

func (PartParam) MarshalJSON

func (r PartParam) MarshalJSON() (data []byte, err error)

type PartType

type PartType string
const (
	PartTypeText       PartType = "text"
	PartTypeFile       PartType = "file"
	PartTypeTool       PartType = "tool"
	PartTypeStepStart  PartType = "step-start"
	PartTypeStepFinish PartType = "step-finish"
	PartTypeSnapshot   PartType = "snapshot"
)

func (PartType) IsKnown

func (r PartType) IsKnown() bool

type PartUnion

type PartUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by TextPart, FilePart, ToolPart, StepStartPart, StepFinishPart or SnapshotPart.

type PartUnionParam

type PartUnionParam interface {
	// contains filtered or unexported methods
}

Satisfied by TextPartParam, FilePartParam, ToolPartParam, StepStartPartParam, StepFinishPartParam, SnapshotPartParam, PartParam.

type Provider added in v0.2.0

type Provider struct {
	ID     string           `json:"id,required"`
	Env    []string         `json:"env,required"`
	Models map[string]Model `json:"models,required"`
	Name   string           `json:"name,required"`
	API    string           `json:"api"`
	Npm    string           `json:"npm"`
	JSON   providerJSON     `json:"-"`
}

func (*Provider) UnmarshalJSON added in v0.2.0

func (r *Provider) UnmarshalJSON(data []byte) (err error)

type ProviderAuthError

type ProviderAuthError = shared.ProviderAuthError

This is an alias to an internal type.

type ProviderAuthErrorData

type ProviderAuthErrorData = shared.ProviderAuthErrorData

This is an alias to an internal type.

type ProviderAuthErrorName

type ProviderAuthErrorName = shared.ProviderAuthErrorName

This is an alias to an internal type.

type Session

type Session struct {
	ID       string        `json:"id,required"`
	Time     SessionTime   `json:"time,required"`
	Title    string        `json:"title,required"`
	Version  string        `json:"version,required"`
	ParentID string        `json:"parentID"`
	Revert   SessionRevert `json:"revert"`
	Share    SessionShare  `json:"share"`
	JSON     sessionJSON   `json:"-"`
}

func (*Session) UnmarshalJSON

func (r *Session) UnmarshalJSON(data []byte) (err error)

type SessionChatParams

type SessionChatParams struct {
	ModelID    param.Field[string]                       `json:"modelID,required"`
	Parts      param.Field[[]SessionChatParamsPartUnion] `json:"parts,required"`
	ProviderID param.Field[string]                       `json:"providerID,required"`
	MessageID  param.Field[string]                       `json:"messageID"`
	Mode       param.Field[string]                       `json:"mode"`
	Tools      param.Field[map[string]bool]              `json:"tools"`
}

func (SessionChatParams) MarshalJSON

func (r SessionChatParams) MarshalJSON() (data []byte, err error)

type SessionChatParamsPart

type SessionChatParamsPart struct {
	Type      param.Field[SessionChatParamsPartsType] `json:"type,required"`
	ID        param.Field[string]                     `json:"id"`
	Filename  param.Field[string]                     `json:"filename"`
	Mime      param.Field[string]                     `json:"mime"`
	Source    param.Field[FilePartSourceUnionParam]   `json:"source"`
	Synthetic param.Field[bool]                       `json:"synthetic"`
	Text      param.Field[string]                     `json:"text"`
	Time      param.Field[interface{}]                `json:"time"`
	URL       param.Field[string]                     `json:"url"`
}

func (SessionChatParamsPart) MarshalJSON

func (r SessionChatParamsPart) MarshalJSON() (data []byte, err error)

type SessionChatParamsPartUnion

type SessionChatParamsPartUnion interface {
	// contains filtered or unexported methods
}

Satisfied by TextPartInputParam, FilePartInputParam, SessionChatParamsPart.

type SessionChatParamsPartsType

type SessionChatParamsPartsType string
const (
	SessionChatParamsPartsTypeText SessionChatParamsPartsType = "text"
	SessionChatParamsPartsTypeFile SessionChatParamsPartsType = "file"
)

func (SessionChatParamsPartsType) IsKnown

func (r SessionChatParamsPartsType) IsKnown() bool

type SessionInitParams

type SessionInitParams struct {
	MessageID  param.Field[string] `json:"messageID,required"`
	ModelID    param.Field[string] `json:"modelID,required"`
	ProviderID param.Field[string] `json:"providerID,required"`
}

func (SessionInitParams) MarshalJSON

func (r SessionInitParams) MarshalJSON() (data []byte, err error)

type SessionMessagesResponse

type SessionMessagesResponse struct {
	Info  Message                     `json:"info,required"`
	Parts []Part                      `json:"parts,required"`
	JSON  sessionMessagesResponseJSON `json:"-"`
}

func (*SessionMessagesResponse) UnmarshalJSON

func (r *SessionMessagesResponse) UnmarshalJSON(data []byte) (err error)

type SessionRevert

type SessionRevert struct {
	MessageID string            `json:"messageID,required"`
	Part      float64           `json:"part,required"`
	Snapshot  string            `json:"snapshot"`
	JSON      sessionRevertJSON `json:"-"`
}

func (*SessionRevert) UnmarshalJSON

func (r *SessionRevert) UnmarshalJSON(data []byte) (err error)

type SessionService

type SessionService struct {
	Options []option.RequestOption
}

SessionService contains methods and other services that help with interacting with the opencode API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewSessionService method instead.

func NewSessionService

func NewSessionService(opts ...option.RequestOption) (r *SessionService)

NewSessionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*SessionService) Abort

func (r *SessionService) Abort(ctx context.Context, id string, opts ...option.RequestOption) (res *bool, err error)

Abort a session

func (*SessionService) Chat

func (r *SessionService) Chat(ctx context.Context, id string, body SessionChatParams, opts ...option.RequestOption) (res *AssistantMessage, err error)

Create and send a new message to a session

func (*SessionService) Delete

func (r *SessionService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (res *bool, err error)

Delete a session and all its data

func (*SessionService) Init

func (r *SessionService) Init(ctx context.Context, id string, body SessionInitParams, opts ...option.RequestOption) (res *bool, err error)

Analyze the app and create an AGENTS.md file

func (*SessionService) List

func (r *SessionService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Session, err error)

List all sessions

func (*SessionService) Messages

func (r *SessionService) Messages(ctx context.Context, id string, opts ...option.RequestOption) (res *[]SessionMessagesResponse, err error)

List messages for a session

func (*SessionService) New

func (r *SessionService) New(ctx context.Context, opts ...option.RequestOption) (res *Session, err error)

Create a new session

func (*SessionService) Share

func (r *SessionService) Share(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error)

Share a session

func (*SessionService) Summarize

func (r *SessionService) Summarize(ctx context.Context, id string, body SessionSummarizeParams, opts ...option.RequestOption) (res *bool, err error)

Summarize the session

func (*SessionService) Unshare

func (r *SessionService) Unshare(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error)

Unshare the session

type SessionShare

type SessionShare struct {
	URL  string           `json:"url,required"`
	JSON sessionShareJSON `json:"-"`
}

func (*SessionShare) UnmarshalJSON

func (r *SessionShare) UnmarshalJSON(data []byte) (err error)

type SessionSummarizeParams

type SessionSummarizeParams struct {
	ModelID    param.Field[string] `json:"modelID,required"`
	ProviderID param.Field[string] `json:"providerID,required"`
}

func (SessionSummarizeParams) MarshalJSON

func (r SessionSummarizeParams) MarshalJSON() (data []byte, err error)

type SessionTime

type SessionTime struct {
	Created float64         `json:"created,required"`
	Updated float64         `json:"updated,required"`
	JSON    sessionTimeJSON `json:"-"`
}

func (*SessionTime) UnmarshalJSON

func (r *SessionTime) UnmarshalJSON(data []byte) (err error)

type SnapshotPart

type SnapshotPart struct {
	ID        string           `json:"id,required"`
	MessageID string           `json:"messageID,required"`
	SessionID string           `json:"sessionID,required"`
	Snapshot  string           `json:"snapshot,required"`
	Type      SnapshotPartType `json:"type,required"`
	JSON      snapshotPartJSON `json:"-"`
}

func (*SnapshotPart) UnmarshalJSON

func (r *SnapshotPart) UnmarshalJSON(data []byte) (err error)

type SnapshotPartParam

type SnapshotPartParam struct {
	ID        param.Field[string]           `json:"id,required"`
	MessageID param.Field[string]           `json:"messageID,required"`
	SessionID param.Field[string]           `json:"sessionID,required"`
	Snapshot  param.Field[string]           `json:"snapshot,required"`
	Type      param.Field[SnapshotPartType] `json:"type,required"`
}

func (SnapshotPartParam) MarshalJSON

func (r SnapshotPartParam) MarshalJSON() (data []byte, err error)

type SnapshotPartType

type SnapshotPartType string
const (
	SnapshotPartTypeSnapshot SnapshotPartType = "snapshot"
)

func (SnapshotPartType) IsKnown

func (r SnapshotPartType) IsKnown() bool

type StepFinishPart

type StepFinishPart struct {
	ID        string               `json:"id,required"`
	Cost      float64              `json:"cost,required"`
	MessageID string               `json:"messageID,required"`
	SessionID string               `json:"sessionID,required"`
	Tokens    StepFinishPartTokens `json:"tokens,required"`
	Type      StepFinishPartType   `json:"type,required"`
	JSON      stepFinishPartJSON   `json:"-"`
}

func (*StepFinishPart) UnmarshalJSON

func (r *StepFinishPart) UnmarshalJSON(data []byte) (err error)

type StepFinishPartParam

type StepFinishPartParam struct {
	ID        param.Field[string]                    `json:"id,required"`
	Cost      param.Field[float64]                   `json:"cost,required"`
	MessageID param.Field[string]                    `json:"messageID,required"`
	SessionID param.Field[string]                    `json:"sessionID,required"`
	Tokens    param.Field[StepFinishPartTokensParam] `json:"tokens,required"`
	Type      param.Field[StepFinishPartType]        `json:"type,required"`
}

func (StepFinishPartParam) MarshalJSON

func (r StepFinishPartParam) MarshalJSON() (data []byte, err error)

type StepFinishPartTokens

type StepFinishPartTokens struct {
	Cache     StepFinishPartTokensCache `json:"cache,required"`
	Input     float64                   `json:"input,required"`
	Output    float64                   `json:"output,required"`
	Reasoning float64                   `json:"reasoning,required"`
	JSON      stepFinishPartTokensJSON  `json:"-"`
}

func (*StepFinishPartTokens) UnmarshalJSON

func (r *StepFinishPartTokens) UnmarshalJSON(data []byte) (err error)

type StepFinishPartTokensCache

type StepFinishPartTokensCache struct {
	Read  float64                       `json:"read,required"`
	Write float64                       `json:"write,required"`
	JSON  stepFinishPartTokensCacheJSON `json:"-"`
}

func (*StepFinishPartTokensCache) UnmarshalJSON

func (r *StepFinishPartTokensCache) UnmarshalJSON(data []byte) (err error)

type StepFinishPartTokensCacheParam

type StepFinishPartTokensCacheParam struct {
	Read  param.Field[float64] `json:"read,required"`
	Write param.Field[float64] `json:"write,required"`
}

func (StepFinishPartTokensCacheParam) MarshalJSON

func (r StepFinishPartTokensCacheParam) MarshalJSON() (data []byte, err error)

type StepFinishPartTokensParam

type StepFinishPartTokensParam struct {
	Cache     param.Field[StepFinishPartTokensCacheParam] `json:"cache,required"`
	Input     param.Field[float64]                        `json:"input,required"`
	Output    param.Field[float64]                        `json:"output,required"`
	Reasoning param.Field[float64]                        `json:"reasoning,required"`
}

func (StepFinishPartTokensParam) MarshalJSON

func (r StepFinishPartTokensParam) MarshalJSON() (data []byte, err error)

type StepFinishPartType

type StepFinishPartType string
const (
	StepFinishPartTypeStepFinish StepFinishPartType = "step-finish"
)

func (StepFinishPartType) IsKnown

func (r StepFinishPartType) IsKnown() bool

type StepStartPart

type StepStartPart struct {
	ID        string            `json:"id,required"`
	MessageID string            `json:"messageID,required"`
	SessionID string            `json:"sessionID,required"`
	Type      StepStartPartType `json:"type,required"`
	JSON      stepStartPartJSON `json:"-"`
}

func (*StepStartPart) UnmarshalJSON

func (r *StepStartPart) UnmarshalJSON(data []byte) (err error)

type StepStartPartParam

type StepStartPartParam struct {
	ID        param.Field[string]            `json:"id,required"`
	MessageID param.Field[string]            `json:"messageID,required"`
	SessionID param.Field[string]            `json:"sessionID,required"`
	Type      param.Field[StepStartPartType] `json:"type,required"`
}

func (StepStartPartParam) MarshalJSON

func (r StepStartPartParam) MarshalJSON() (data []byte, err error)

type StepStartPartType

type StepStartPartType string
const (
	StepStartPartTypeStepStart StepStartPartType = "step-start"
)

func (StepStartPartType) IsKnown

func (r StepStartPartType) IsKnown() bool

type Symbol

type Symbol struct {
	Kind     float64        `json:"kind,required"`
	Location SymbolLocation `json:"location,required"`
	Name     string         `json:"name,required"`
	JSON     symbolJSON     `json:"-"`
}

func (*Symbol) UnmarshalJSON

func (r *Symbol) UnmarshalJSON(data []byte) (err error)

type SymbolLocation

type SymbolLocation struct {
	Range SymbolLocationRange `json:"range,required"`
	Uri   string              `json:"uri,required"`
	JSON  symbolLocationJSON  `json:"-"`
}

func (*SymbolLocation) UnmarshalJSON

func (r *SymbolLocation) UnmarshalJSON(data []byte) (err error)

type SymbolLocationRange

type SymbolLocationRange struct {
	End   SymbolLocationRangeEnd   `json:"end,required"`
	Start SymbolLocationRangeStart `json:"start,required"`
	JSON  symbolLocationRangeJSON  `json:"-"`
}

func (*SymbolLocationRange) UnmarshalJSON

func (r *SymbolLocationRange) UnmarshalJSON(data []byte) (err error)

type SymbolLocationRangeEnd

type SymbolLocationRangeEnd struct {
	Character float64                    `json:"character,required"`
	Line      float64                    `json:"line,required"`
	JSON      symbolLocationRangeEndJSON `json:"-"`
}

func (*SymbolLocationRangeEnd) UnmarshalJSON

func (r *SymbolLocationRangeEnd) UnmarshalJSON(data []byte) (err error)

type SymbolLocationRangeStart

type SymbolLocationRangeStart struct {
	Character float64                      `json:"character,required"`
	Line      float64                      `json:"line,required"`
	JSON      symbolLocationRangeStartJSON `json:"-"`
}

func (*SymbolLocationRangeStart) UnmarshalJSON

func (r *SymbolLocationRangeStart) UnmarshalJSON(data []byte) (err error)

type SymbolSource

type SymbolSource struct {
	Kind  int64              `json:"kind,required"`
	Name  string             `json:"name,required"`
	Path  string             `json:"path,required"`
	Range SymbolSourceRange  `json:"range,required"`
	Text  FilePartSourceText `json:"text,required"`
	Type  SymbolSourceType   `json:"type,required"`
	JSON  symbolSourceJSON   `json:"-"`
}

func (*SymbolSource) UnmarshalJSON

func (r *SymbolSource) UnmarshalJSON(data []byte) (err error)

type SymbolSourceParam

type SymbolSourceParam struct {
	Kind  param.Field[int64]                   `json:"kind,required"`
	Name  param.Field[string]                  `json:"name,required"`
	Path  param.Field[string]                  `json:"path,required"`
	Range param.Field[SymbolSourceRangeParam]  `json:"range,required"`
	Text  param.Field[FilePartSourceTextParam] `json:"text,required"`
	Type  param.Field[SymbolSourceType]        `json:"type,required"`
}

func (SymbolSourceParam) MarshalJSON

func (r SymbolSourceParam) MarshalJSON() (data []byte, err error)

type SymbolSourceRange

type SymbolSourceRange struct {
	End   SymbolSourceRangeEnd   `json:"end,required"`
	Start SymbolSourceRangeStart `json:"start,required"`
	JSON  symbolSourceRangeJSON  `json:"-"`
}

func (*SymbolSourceRange) UnmarshalJSON

func (r *SymbolSourceRange) UnmarshalJSON(data []byte) (err error)

type SymbolSourceRangeEnd

type SymbolSourceRangeEnd struct {
	Character float64                  `json:"character,required"`
	Line      float64                  `json:"line,required"`
	JSON      symbolSourceRangeEndJSON `json:"-"`
}

func (*SymbolSourceRangeEnd) UnmarshalJSON

func (r *SymbolSourceRangeEnd) UnmarshalJSON(data []byte) (err error)

type SymbolSourceRangeEndParam

type SymbolSourceRangeEndParam struct {
	Character param.Field[float64] `json:"character,required"`
	Line      param.Field[float64] `json:"line,required"`
}

func (SymbolSourceRangeEndParam) MarshalJSON

func (r SymbolSourceRangeEndParam) MarshalJSON() (data []byte, err error)

type SymbolSourceRangeParam

type SymbolSourceRangeParam struct {
	End   param.Field[SymbolSourceRangeEndParam]   `json:"end,required"`
	Start param.Field[SymbolSourceRangeStartParam] `json:"start,required"`
}

func (SymbolSourceRangeParam) MarshalJSON

func (r SymbolSourceRangeParam) MarshalJSON() (data []byte, err error)

type SymbolSourceRangeStart

type SymbolSourceRangeStart struct {
	Character float64                    `json:"character,required"`
	Line      float64                    `json:"line,required"`
	JSON      symbolSourceRangeStartJSON `json:"-"`
}

func (*SymbolSourceRangeStart) UnmarshalJSON

func (r *SymbolSourceRangeStart) UnmarshalJSON(data []byte) (err error)

type SymbolSourceRangeStartParam

type SymbolSourceRangeStartParam struct {
	Character param.Field[float64] `json:"character,required"`
	Line      param.Field[float64] `json:"line,required"`
}

func (SymbolSourceRangeStartParam) MarshalJSON

func (r SymbolSourceRangeStartParam) MarshalJSON() (data []byte, err error)

type SymbolSourceType

type SymbolSourceType string
const (
	SymbolSourceTypeSymbol SymbolSourceType = "symbol"
)

func (SymbolSourceType) IsKnown

func (r SymbolSourceType) IsKnown() bool

type TextPart

type TextPart struct {
	ID        string       `json:"id,required"`
	MessageID string       `json:"messageID,required"`
	SessionID string       `json:"sessionID,required"`
	Text      string       `json:"text,required"`
	Type      TextPartType `json:"type,required"`
	Synthetic bool         `json:"synthetic"`
	Time      TextPartTime `json:"time"`
	JSON      textPartJSON `json:"-"`
}

func (*TextPart) UnmarshalJSON

func (r *TextPart) UnmarshalJSON(data []byte) (err error)

type TextPartInputParam

type TextPartInputParam struct {
	Text      param.Field[string]                 `json:"text,required"`
	Type      param.Field[TextPartInputType]      `json:"type,required"`
	ID        param.Field[string]                 `json:"id"`
	Synthetic param.Field[bool]                   `json:"synthetic"`
	Time      param.Field[TextPartInputTimeParam] `json:"time"`
}

func (TextPartInputParam) MarshalJSON

func (r TextPartInputParam) MarshalJSON() (data []byte, err error)

type TextPartInputTimeParam

type TextPartInputTimeParam struct {
	Start param.Field[float64] `json:"start,required"`
	End   param.Field[float64] `json:"end"`
}

func (TextPartInputTimeParam) MarshalJSON

func (r TextPartInputTimeParam) MarshalJSON() (data []byte, err error)

type TextPartInputType

type TextPartInputType string
const (
	TextPartInputTypeText TextPartInputType = "text"
)

func (TextPartInputType) IsKnown

func (r TextPartInputType) IsKnown() bool

type TextPartParam

type TextPartParam struct {
	ID        param.Field[string]            `json:"id,required"`
	MessageID param.Field[string]            `json:"messageID,required"`
	SessionID param.Field[string]            `json:"sessionID,required"`
	Text      param.Field[string]            `json:"text,required"`
	Type      param.Field[TextPartType]      `json:"type,required"`
	Synthetic param.Field[bool]              `json:"synthetic"`
	Time      param.Field[TextPartTimeParam] `json:"time"`
}

func (TextPartParam) MarshalJSON

func (r TextPartParam) MarshalJSON() (data []byte, err error)

type TextPartTime

type TextPartTime struct {
	Start float64          `json:"start,required"`
	End   float64          `json:"end"`
	JSON  textPartTimeJSON `json:"-"`
}

func (*TextPartTime) UnmarshalJSON

func (r *TextPartTime) UnmarshalJSON(data []byte) (err error)

type TextPartTimeParam

type TextPartTimeParam struct {
	Start param.Field[float64] `json:"start,required"`
	End   param.Field[float64] `json:"end"`
}

func (TextPartTimeParam) MarshalJSON

func (r TextPartTimeParam) MarshalJSON() (data []byte, err error)

type TextPartType

type TextPartType string
const (
	TextPartTypeText TextPartType = "text"
)

func (TextPartType) IsKnown

func (r TextPartType) IsKnown() bool

type ToolPart

type ToolPart struct {
	ID        string        `json:"id,required"`
	CallID    string        `json:"callID,required"`
	MessageID string        `json:"messageID,required"`
	SessionID string        `json:"sessionID,required"`
	State     ToolPartState `json:"state,required"`
	Tool      string        `json:"tool,required"`
	Type      ToolPartType  `json:"type,required"`
	JSON      toolPartJSON  `json:"-"`
}

func (*ToolPart) UnmarshalJSON

func (r *ToolPart) UnmarshalJSON(data []byte) (err error)

type ToolPartParam

type ToolPartParam struct {
	ID        param.Field[string]                  `json:"id,required"`
	CallID    param.Field[string]                  `json:"callID,required"`
	MessageID param.Field[string]                  `json:"messageID,required"`
	SessionID param.Field[string]                  `json:"sessionID,required"`
	State     param.Field[ToolPartStateUnionParam] `json:"state,required"`
	Tool      param.Field[string]                  `json:"tool,required"`
	Type      param.Field[ToolPartType]            `json:"type,required"`
}

func (ToolPartParam) MarshalJSON

func (r ToolPartParam) MarshalJSON() (data []byte, err error)

type ToolPartState

type ToolPartState struct {
	Status ToolPartStateStatus `json:"status,required"`
	Error  string              `json:"error"`
	// This field can have the runtime type of [interface{}], [map[string]interface{}].
	Input interface{} `json:"input"`
	// This field can have the runtime type of [map[string]interface{}].
	Metadata interface{} `json:"metadata"`
	Output   string      `json:"output"`
	// This field can have the runtime type of [ToolStateRunningTime],
	// [ToolStateCompletedTime], [ToolStateErrorTime].
	Time  interface{}       `json:"time"`
	Title string            `json:"title"`
	JSON  toolPartStateJSON `json:"-"`
	// contains filtered or unexported fields
}

func (ToolPartState) AsUnion

func (r ToolPartState) AsUnion() ToolPartStateUnion

AsUnion returns a ToolPartStateUnion interface which you can cast to the specific types for more type safety.

Possible runtime types of the union are ToolStatePending, ToolStateRunning, ToolStateCompleted, ToolStateError.

func (*ToolPartState) UnmarshalJSON

func (r *ToolPartState) UnmarshalJSON(data []byte) (err error)

type ToolPartStateParam

type ToolPartStateParam struct {
	Status   param.Field[ToolPartStateStatus] `json:"status,required"`
	Error    param.Field[string]              `json:"error"`
	Input    param.Field[interface{}]         `json:"input"`
	Metadata param.Field[interface{}]         `json:"metadata"`
	Output   param.Field[string]              `json:"output"`
	Time     param.Field[interface{}]         `json:"time"`
	Title    param.Field[string]              `json:"title"`
}

func (ToolPartStateParam) MarshalJSON

func (r ToolPartStateParam) MarshalJSON() (data []byte, err error)

type ToolPartStateStatus

type ToolPartStateStatus string
const (
	ToolPartStateStatusPending   ToolPartStateStatus = "pending"
	ToolPartStateStatusRunning   ToolPartStateStatus = "running"
	ToolPartStateStatusCompleted ToolPartStateStatus = "completed"
	ToolPartStateStatusError     ToolPartStateStatus = "error"
)

func (ToolPartStateStatus) IsKnown

func (r ToolPartStateStatus) IsKnown() bool

type ToolPartStateUnion

type ToolPartStateUnion interface {
	// contains filtered or unexported methods
}

Union satisfied by ToolStatePending, ToolStateRunning, ToolStateCompleted or ToolStateError.

type ToolPartStateUnionParam

type ToolPartStateUnionParam interface {
	// contains filtered or unexported methods
}

Satisfied by ToolStatePendingParam, ToolStateRunningParam, ToolStateCompletedParam, ToolStateErrorParam, ToolPartStateParam.

type ToolPartType

type ToolPartType string
const (
	ToolPartTypeTool ToolPartType = "tool"
)

func (ToolPartType) IsKnown

func (r ToolPartType) IsKnown() bool

type ToolStateCompleted

type ToolStateCompleted struct {
	Input    map[string]interface{}   `json:"input,required"`
	Metadata map[string]interface{}   `json:"metadata,required"`
	Output   string                   `json:"output,required"`
	Status   ToolStateCompletedStatus `json:"status,required"`
	Time     ToolStateCompletedTime   `json:"time,required"`
	Title    string                   `json:"title,required"`
	JSON     toolStateCompletedJSON   `json:"-"`
}

func (*ToolStateCompleted) UnmarshalJSON

func (r *ToolStateCompleted) UnmarshalJSON(data []byte) (err error)

type ToolStateCompletedParam

type ToolStateCompletedParam struct {
	Input    param.Field[map[string]interface{}]      `json:"input,required"`
	Metadata param.Field[map[string]interface{}]      `json:"metadata,required"`
	Output   param.Field[string]                      `json:"output,required"`
	Status   param.Field[ToolStateCompletedStatus]    `json:"status,required"`
	Time     param.Field[ToolStateCompletedTimeParam] `json:"time,required"`
	Title    param.Field[string]                      `json:"title,required"`
}

func (ToolStateCompletedParam) MarshalJSON

func (r ToolStateCompletedParam) MarshalJSON() (data []byte, err error)

type ToolStateCompletedStatus

type ToolStateCompletedStatus string
const (
	ToolStateCompletedStatusCompleted ToolStateCompletedStatus = "completed"
)

func (ToolStateCompletedStatus) IsKnown

func (r ToolStateCompletedStatus) IsKnown() bool

type ToolStateCompletedTime

type ToolStateCompletedTime struct {
	End   float64                    `json:"end,required"`
	Start float64                    `json:"start,required"`
	JSON  toolStateCompletedTimeJSON `json:"-"`
}

func (*ToolStateCompletedTime) UnmarshalJSON

func (r *ToolStateCompletedTime) UnmarshalJSON(data []byte) (err error)

type ToolStateCompletedTimeParam

type ToolStateCompletedTimeParam struct {
	End   param.Field[float64] `json:"end,required"`
	Start param.Field[float64] `json:"start,required"`
}

func (ToolStateCompletedTimeParam) MarshalJSON

func (r ToolStateCompletedTimeParam) MarshalJSON() (data []byte, err error)

type ToolStateError

type ToolStateError struct {
	Error  string                 `json:"error,required"`
	Input  map[string]interface{} `json:"input,required"`
	Status ToolStateErrorStatus   `json:"status,required"`
	Time   ToolStateErrorTime     `json:"time,required"`
	JSON   toolStateErrorJSON     `json:"-"`
}

func (*ToolStateError) UnmarshalJSON

func (r *ToolStateError) UnmarshalJSON(data []byte) (err error)

type ToolStateErrorParam

type ToolStateErrorParam struct {
	Error  param.Field[string]                  `json:"error,required"`
	Input  param.Field[map[string]interface{}]  `json:"input,required"`
	Status param.Field[ToolStateErrorStatus]    `json:"status,required"`
	Time   param.Field[ToolStateErrorTimeParam] `json:"time,required"`
}

func (ToolStateErrorParam) MarshalJSON

func (r ToolStateErrorParam) MarshalJSON() (data []byte, err error)

type ToolStateErrorStatus

type ToolStateErrorStatus string
const (
	ToolStateErrorStatusError ToolStateErrorStatus = "error"
)

func (ToolStateErrorStatus) IsKnown

func (r ToolStateErrorStatus) IsKnown() bool

type ToolStateErrorTime

type ToolStateErrorTime struct {
	End   float64                `json:"end,required"`
	Start float64                `json:"start,required"`
	JSON  toolStateErrorTimeJSON `json:"-"`
}

func (*ToolStateErrorTime) UnmarshalJSON

func (r *ToolStateErrorTime) UnmarshalJSON(data []byte) (err error)

type ToolStateErrorTimeParam

type ToolStateErrorTimeParam struct {
	End   param.Field[float64] `json:"end,required"`
	Start param.Field[float64] `json:"start,required"`
}

func (ToolStateErrorTimeParam) MarshalJSON

func (r ToolStateErrorTimeParam) MarshalJSON() (data []byte, err error)

type ToolStatePending

type ToolStatePending struct {
	Status ToolStatePendingStatus `json:"status,required"`
	JSON   toolStatePendingJSON   `json:"-"`
}

func (*ToolStatePending) UnmarshalJSON

func (r *ToolStatePending) UnmarshalJSON(data []byte) (err error)

type ToolStatePendingParam

type ToolStatePendingParam struct {
	Status param.Field[ToolStatePendingStatus] `json:"status,required"`
}

func (ToolStatePendingParam) MarshalJSON

func (r ToolStatePendingParam) MarshalJSON() (data []byte, err error)

type ToolStatePendingStatus

type ToolStatePendingStatus string
const (
	ToolStatePendingStatusPending ToolStatePendingStatus = "pending"
)

func (ToolStatePendingStatus) IsKnown

func (r ToolStatePendingStatus) IsKnown() bool

type ToolStateRunning

type ToolStateRunning struct {
	Status   ToolStateRunningStatus `json:"status,required"`
	Time     ToolStateRunningTime   `json:"time,required"`
	Input    interface{}            `json:"input"`
	Metadata map[string]interface{} `json:"metadata"`
	Title    string                 `json:"title"`
	JSON     toolStateRunningJSON   `json:"-"`
}

func (*ToolStateRunning) UnmarshalJSON

func (r *ToolStateRunning) UnmarshalJSON(data []byte) (err error)

type ToolStateRunningParam

type ToolStateRunningParam struct {
	Status   param.Field[ToolStateRunningStatus]    `json:"status,required"`
	Time     param.Field[ToolStateRunningTimeParam] `json:"time,required"`
	Input    param.Field[interface{}]               `json:"input"`
	Metadata param.Field[map[string]interface{}]    `json:"metadata"`
	Title    param.Field[string]                    `json:"title"`
}

func (ToolStateRunningParam) MarshalJSON

func (r ToolStateRunningParam) MarshalJSON() (data []byte, err error)

type ToolStateRunningStatus

type ToolStateRunningStatus string
const (
	ToolStateRunningStatusRunning ToolStateRunningStatus = "running"
)

func (ToolStateRunningStatus) IsKnown

func (r ToolStateRunningStatus) IsKnown() bool

type ToolStateRunningTime

type ToolStateRunningTime struct {
	Start float64                  `json:"start,required"`
	JSON  toolStateRunningTimeJSON `json:"-"`
}

func (*ToolStateRunningTime) UnmarshalJSON

func (r *ToolStateRunningTime) UnmarshalJSON(data []byte) (err error)

type ToolStateRunningTimeParam

type ToolStateRunningTimeParam struct {
	Start param.Field[float64] `json:"start,required"`
}

func (ToolStateRunningTimeParam) MarshalJSON

func (r ToolStateRunningTimeParam) MarshalJSON() (data []byte, err error)

type TuiPromptParams

type TuiPromptParams struct {
	Parts param.Field[[]PartUnionParam] `json:"parts,required"`
	Text  param.Field[string]           `json:"text,required"`
}

func (TuiPromptParams) MarshalJSON

func (r TuiPromptParams) MarshalJSON() (data []byte, err error)

type TuiService

type TuiService struct {
	Options []option.RequestOption
}

TuiService contains methods and other services that help with interacting with the opencode API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewTuiService method instead.

func NewTuiService

func NewTuiService(opts ...option.RequestOption) (r *TuiService)

NewTuiService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*TuiService) OpenHelp

func (r *TuiService) OpenHelp(ctx context.Context, opts ...option.RequestOption) (res *bool, err error)

Open the help dialog

func (*TuiService) Prompt

func (r *TuiService) Prompt(ctx context.Context, body TuiPromptParams, opts ...option.RequestOption) (res *bool, err error)

Send a prompt to the TUI

type UnknownError

type UnknownError = shared.UnknownError

This is an alias to an internal type.

type UnknownErrorData

type UnknownErrorData = shared.UnknownErrorData

This is an alias to an internal type.

type UnknownErrorName

type UnknownErrorName = shared.UnknownErrorName

This is an alias to an internal type.

type UserMessage

type UserMessage struct {
	ID        string          `json:"id,required"`
	Role      UserMessageRole `json:"role,required"`
	SessionID string          `json:"sessionID,required"`
	Time      UserMessageTime `json:"time,required"`
	JSON      userMessageJSON `json:"-"`
}

func (*UserMessage) UnmarshalJSON

func (r *UserMessage) UnmarshalJSON(data []byte) (err error)

type UserMessageRole

type UserMessageRole string
const (
	UserMessageRoleUser UserMessageRole = "user"
)

func (UserMessageRole) IsKnown

func (r UserMessageRole) IsKnown() bool

type UserMessageTime

type UserMessageTime struct {
	Created float64             `json:"created,required"`
	JSON    userMessageTimeJSON `json:"-"`
}

func (*UserMessageTime) UnmarshalJSON

func (r *UserMessageTime) UnmarshalJSON(data []byte) (err error)

Directories

Path Synopsis
packages

Jump to

Keyboard shortcuts

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