opencode

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

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

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

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.10'

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()
	stream := client.Event.ListStreaming(context.TODO())
	for stream.Next() {
		fmt.Printf("%+v\n", stream.Current())
	}
	err := stream.Err()
	if err != nil {
		panic(err.Error())
	}
}

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.Event.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:

stream := client.Event.ListStreaming(context.TODO())
if stream.Err() != nil {
	var apierr *opencode.Error
	if errors.As(stream.Err(), &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(stream.Err().Error()) // GET "/event": 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.Event.ListStreaming(
	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.Event.ListStreaming(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
stream := client.Event.ListStreaming(context.TODO(), option.WithResponseInto(&response))
if stream.Err() != nil {
	// handle error
}
fmt.Printf("%+v\n", events)

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 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"`
	User     string  `json:"user,required"`
	JSON     appJSON `json:"-"`
}

func (*App) UnmarshalJSON

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

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 AppService

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

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

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"`
	Parts      []AssistantMessagePart `json:"parts,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.

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"
)

func (AssistantMessageErrorName) IsKnown

func (r AssistantMessageErrorName) IsKnown() bool

type AssistantMessageErrorUnion

type AssistantMessageErrorUnion interface {
	ImplementsAssistantMessageError()
}

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

type AssistantMessagePart

type AssistantMessagePart struct {
	Type AssistantMessagePartType `json:"type,required"`
	ID   string                   `json:"id"`
	// This field can have the runtime type of [ToolPartState].
	State interface{}              `json:"state"`
	Text  string                   `json:"text"`
	Tool  string                   `json:"tool"`
	JSON  assistantMessagePartJSON `json:"-"`
	// contains filtered or unexported fields
}

func (AssistantMessagePart) AsUnion

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

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

func (*AssistantMessagePart) UnmarshalJSON

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

type AssistantMessagePartType

type AssistantMessagePartType string
const (
	AssistantMessagePartTypeText      AssistantMessagePartType = "text"
	AssistantMessagePartTypeTool      AssistantMessagePartType = "tool"
	AssistantMessagePartTypeStepStart AssistantMessagePartType = "step-start"
)

func (AssistantMessagePartType) IsKnown

func (r AssistantMessagePartType) IsKnown() bool

type AssistantMessagePartUnion

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

Union satisfied by TextPart, ToolPart or StepStartPart.

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
}

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"`
	// 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 Keybinds `json:"keybinds"`
	// MCP (Model Context Protocol) server configurations
	Mcp map[string]ConfigMcp `json:"mcp"`
	// 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"`
	// Theme name to use for the interface
	Theme string     `json:"theme"`
	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 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"`
	// 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 McpLocal, McpRemote.

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 McpLocal or McpRemote.

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 ConfigProvidersResponse

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

func (*ConfigProvidersResponse) UnmarshalJSON

func (r *ConfigProvidersResponse) 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

func (*ConfigService) Providers

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

List all providers

type Error

type Error = apierror.Error

type EventListResponse

type EventListResponse struct {
	// This field can have the runtime type of
	// [EventListResponseEventLspClientDiagnosticsProperties],
	// [EventListResponseEventPermissionUpdatedProperties],
	// [EventListResponseEventFileEditedProperties],
	// [EventListResponseEventInstallationUpdatedProperties],
	// [EventListResponseEventStorageWriteProperties],
	// [EventListResponseEventMessageUpdatedProperties],
	// [EventListResponseEventMessageRemovedProperties],
	// [EventListResponseEventMessagePartUpdatedProperties],
	// [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

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

func (*EventListResponseEventFileWatcherUpdated) UnmarshalJSON

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

type EventListResponseEventFileWatcherUpdatedProperties

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

func (*EventListResponseEventFileWatcherUpdatedProperties) UnmarshalJSON

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

type EventListResponseEventFileWatcherUpdatedPropertiesEvent

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

func (EventListResponseEventFileWatcherUpdatedPropertiesEvent) IsKnown

type EventListResponseEventFileWatcherUpdatedType

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

func (EventListResponseEventFileWatcherUpdatedType) IsKnown

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 {
	MessageID string                                                 `json:"messageID,required"`
	Part      AssistantMessagePart                                   `json:"part,required"`
	SessionID string                                                 `json:"sessionID,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"`
	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.

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"
)

func (EventListResponseEventSessionErrorPropertiesErrorName) IsKnown

type EventListResponseEventSessionErrorPropertiesErrorUnion

type EventListResponseEventSessionErrorPropertiesErrorUnion interface {
	ImplementsEventListResponseEventSessionErrorPropertiesError()
}

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

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"
	EventListResponseTypeStorageWrite         EventListResponseType = "storage.write"
	EventListResponseTypeMessageUpdated       EventListResponseType = "message.updated"
	EventListResponseTypeMessageRemoved       EventListResponseType = "message.removed"
	EventListResponseTypeMessagePartUpdated   EventListResponseType = "message.part.updated"
	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 FilePart

type FilePart struct {
	Mime     string       `json:"mime,required"`
	Type     FilePartType `json:"type,required"`
	URL      string       `json:"url,required"`
	Filename string       `json:"filename"`
	JSON     filePartJSON `json:"-"`
}

func (*FilePart) UnmarshalJSON

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

type FilePartParam

type FilePartParam struct {
	Mime     param.Field[string]       `json:"mime,required"`
	Type     param.Field[FilePartType] `json:"type,required"`
	URL      param.Field[string]       `json:"url,required"`
	Filename param.Field[string]       `json:"filename"`
}

func (FilePartParam) MarshalJSON

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

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 *[]FileStatusResponse, err error)

Get file status

type FileStatusResponse

type FileStatusResponse struct {
	Added   int64                    `json:"added,required"`
	File    string                   `json:"file,required"`
	Removed int64                    `json:"removed,required"`
	Status  FileStatusResponseStatus `json:"status,required"`
	JSON    fileStatusResponseJSON   `json:"-"`
}

func (*FileStatusResponse) UnmarshalJSON

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

type FileStatusResponseStatus

type FileStatusResponseStatus string
const (
	FileStatusResponseStatusAdded    FileStatusResponseStatus = "added"
	FileStatusResponseStatusDeleted  FileStatusResponseStatus = "deleted"
	FileStatusResponseStatusModified FileStatusResponseStatus = "modified"
)

func (FileStatusResponseStatus) IsKnown

func (r FileStatusResponseStatus) 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 *[]FindSymbolsResponse, err error)

Find workspace symbols

func (*FindService) Text

func (r *FindService) Text(ctx context.Context, query FindTextParams, opts ...option.RequestOption) (res *[]FindTextResponse, 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 FindSymbolsResponse

type FindSymbolsResponse = interface{}

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 FindTextResponse

type FindTextResponse struct {
	AbsoluteOffset float64                    `json:"absolute_offset,required"`
	LineNumber     float64                    `json:"line_number,required"`
	Lines          FindTextResponseLines      `json:"lines,required"`
	Path           FindTextResponsePath       `json:"path,required"`
	Submatches     []FindTextResponseSubmatch `json:"submatches,required"`
	JSON           findTextResponseJSON       `json:"-"`
}

func (*FindTextResponse) UnmarshalJSON

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

type FindTextResponseLines

type FindTextResponseLines struct {
	Text string                    `json:"text,required"`
	JSON findTextResponseLinesJSON `json:"-"`
}

func (*FindTextResponseLines) UnmarshalJSON

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

type FindTextResponsePath

type FindTextResponsePath struct {
	Text string                   `json:"text,required"`
	JSON findTextResponsePathJSON `json:"-"`
}

func (*FindTextResponsePath) UnmarshalJSON

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

type FindTextResponseSubmatch

type FindTextResponseSubmatch struct {
	End   float64                         `json:"end,required"`
	Match FindTextResponseSubmatchesMatch `json:"match,required"`
	Start float64                         `json:"start,required"`
	JSON  findTextResponseSubmatchJSON    `json:"-"`
}

func (*FindTextResponseSubmatch) UnmarshalJSON

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

type FindTextResponseSubmatchesMatch

type FindTextResponseSubmatchesMatch struct {
	Text string                              `json:"text,required"`
	JSON findTextResponseSubmatchesMatchJSON `json:"-"`
}

func (*FindTextResponseSubmatchesMatch) UnmarshalJSON

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

type Keybinds

type Keybinds struct {
	// Exit the application
	AppExit string `json:"app_exit"`
	// Open external editor
	EditorOpen string `json:"editor_open"`
	// Show help dialog
	Help string `json:"help"`
	// Navigate to next history item
	HistoryNext string `json:"history_next"`
	// Navigate to previous history item
	HistoryPrevious string `json:"history_previous"`
	// Clear input field
	InputClear string `json:"input_clear"`
	// Insert newline in input
	InputNewline string `json:"input_newline"`
	// Paste from clipboard
	InputPaste string `json:"input_paste"`
	// Submit input
	InputSubmit string `json:"input_submit"`
	// Leader key for keybind combinations
	Leader string `json:"leader"`
	// Navigate to first message
	MessagesFirst string `json:"messages_first"`
	// Scroll messages down by half page
	MessagesHalfPageDown string `json:"messages_half_page_down"`
	// Scroll messages up by half page
	MessagesHalfPageUp string `json:"messages_half_page_up"`
	// Navigate to last message
	MessagesLast string `json:"messages_last"`
	// Navigate to next message
	MessagesNext string `json:"messages_next"`
	// Scroll messages down by one page
	MessagesPageDown string `json:"messages_page_down"`
	// Scroll messages up by one page
	MessagesPageUp string `json:"messages_page_up"`
	// Navigate to previous message
	MessagesPrevious string `json:"messages_previous"`
	// List available models
	ModelList string `json:"model_list"`
	// Initialize project configuration
	ProjectInit string `json:"project_init"`
	// Toggle compact mode for session
	SessionCompact string `json:"session_compact"`
	// Interrupt current session
	SessionInterrupt string `json:"session_interrupt"`
	// List all sessions
	SessionList string `json:"session_list"`
	// Create a new session
	SessionNew string `json:"session_new"`
	// Share current session
	SessionShare string `json:"session_share"`
	// List available themes
	ThemeList string `json:"theme_list"`
	// Show tool details
	ToolDetails string       `json:"tool_details"`
	JSON        keybindsJSON `json:"-"`
}

func (*Keybinds) UnmarshalJSON

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

type McpLocal

type McpLocal struct {
	// Command and arguments to run the MCP server
	Command []string `json:"command,required"`
	// Type of MCP server connection
	Type McpLocalType `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        mcpLocalJSON      `json:"-"`
}

func (*McpLocal) UnmarshalJSON

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

type McpLocalType

type McpLocalType string

Type of MCP server connection

const (
	McpLocalTypeLocal McpLocalType = "local"
)

func (McpLocalType) IsKnown

func (r McpLocalType) IsKnown() bool

type McpRemote

type McpRemote struct {
	// Type of MCP server connection
	Type McpRemoteType `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"`
	JSON    mcpRemoteJSON `json:"-"`
}

func (*McpRemote) UnmarshalJSON

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

type McpRemoteType

type McpRemoteType string

Type of MCP server connection

const (
	McpRemoteTypeRemote McpRemoteType = "remote"
)

func (McpRemoteType) IsKnown

func (r McpRemoteType) IsKnown() bool

type Message

type Message struct {
	ID string `json:"id,required"`
	// This field can have the runtime type of [[]UserMessagePart],
	// [[]AssistantMessagePart].
	Parts     interface{} `json:"parts,required"`
	Role      MessageRole `json:"role,required"`
	SessionID string      `json:"sessionID,required"`
	// This field can have the runtime type of [MessageUserMessageTime],
	// [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 MessageUserMessage, AssistantMessage.

func (*Message) UnmarshalJSON

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

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 MessageUserMessage or AssistantMessage.

type MessageUserMessage

type MessageUserMessage struct {
	ID        string                 `json:"id,required"`
	Parts     []UserMessagePart      `json:"parts,required"`
	Role      MessageUserMessageRole `json:"role,required"`
	SessionID string                 `json:"sessionID,required"`
	Time      MessageUserMessageTime `json:"time,required"`
	JSON      messageUserMessageJSON `json:"-"`
}

func (*MessageUserMessage) UnmarshalJSON

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

type MessageUserMessageRole

type MessageUserMessageRole string
const (
	MessageUserMessageRoleUser MessageUserMessageRole = "user"
)

func (MessageUserMessageRole) IsKnown

func (r MessageUserMessageRole) IsKnown() bool

type MessageUserMessageTime

type MessageUserMessageTime struct {
	Created float64                    `json:"created,required"`
	JSON    messageUserMessageTimeJSON `json:"-"`
}

func (*MessageUserMessageTime) UnmarshalJSON

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

type Model

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

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

type ModelCost

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

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

type ModelLimit

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

func (*ModelLimit) UnmarshalJSON

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

type Provider

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

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[[]UserMessagePartUnionParam] `json:"parts,required"`
	ProviderID param.Field[string]                      `json:"providerID,required"`
}

func (SessionChatParams) MarshalJSON

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

type SessionInitParams

type SessionInitParams struct {
	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 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 *[]Message, 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 StepStartPart

type StepStartPart struct {
	Type StepStartPartType `json:"type,required"`
	JSON stepStartPartJSON `json:"-"`
}

func (*StepStartPart) UnmarshalJSON

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

type StepStartPartType

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

func (StepStartPartType) IsKnown

func (r StepStartPartType) IsKnown() bool

type TextPart

type TextPart struct {
	Text string       `json:"text,required"`
	Type TextPartType `json:"type,required"`
	JSON textPartJSON `json:"-"`
}

func (*TextPart) UnmarshalJSON

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

type TextPartParam

type TextPartParam struct {
	Text param.Field[string]       `json:"text,required"`
	Type param.Field[TextPartType] `json:"type,required"`
}

func (TextPartParam) MarshalJSON

func (r TextPartParam) 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"`
	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 ToolPartState

type ToolPartState struct {
	Status ToolPartStateStatus `json:"status,required"`
	Error  string              `json:"error"`
	// This field can have the runtime type of [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 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 ToolPartType

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

func (ToolPartType) IsKnown

func (r ToolPartType) IsKnown() bool

type ToolStateCompleted

type ToolStateCompleted struct {
	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"`
	Input    interface{}              `json:"input"`
	JSON     toolStateCompletedJSON   `json:"-"`
}

func (*ToolStateCompleted) UnmarshalJSON

func (r *ToolStateCompleted) UnmarshalJSON(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 ToolStateError

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

func (*ToolStateError) UnmarshalJSON

func (r *ToolStateError) UnmarshalJSON(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 ToolStatePending

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

func (*ToolStatePending) UnmarshalJSON

func (r *ToolStatePending) UnmarshalJSON(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 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 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 UserMessagePart

type UserMessagePart struct {
	Type     UserMessagePartType `json:"type,required"`
	Filename string              `json:"filename"`
	Mime     string              `json:"mime"`
	Text     string              `json:"text"`
	URL      string              `json:"url"`
	JSON     userMessagePartJSON `json:"-"`
	// contains filtered or unexported fields
}

func (UserMessagePart) AsUnion

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

Possible runtime types of the union are TextPart, FilePart.

func (*UserMessagePart) UnmarshalJSON

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

type UserMessagePartParam

type UserMessagePartParam struct {
	Type     param.Field[UserMessagePartType] `json:"type,required"`
	Filename param.Field[string]              `json:"filename"`
	Mime     param.Field[string]              `json:"mime"`
	Text     param.Field[string]              `json:"text"`
	URL      param.Field[string]              `json:"url"`
}

func (UserMessagePartParam) MarshalJSON

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

type UserMessagePartType

type UserMessagePartType string
const (
	UserMessagePartTypeText UserMessagePartType = "text"
	UserMessagePartTypeFile UserMessagePartType = "file"
)

func (UserMessagePartType) IsKnown

func (r UserMessagePartType) IsKnown() bool

type UserMessagePartUnion

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

Union satisfied by TextPart or FilePart.

type UserMessagePartUnionParam

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

Satisfied by TextPartParam, FilePartParam, UserMessagePartParam.

Directories

Path Synopsis
packages

Jump to

Keyboard shortcuts

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