opencode

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const Harness = "opencode"

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func IsID

func IsID(id string) bool

func Messages

func Messages(msgs []Message) []history.Message

func Reply

func Reply(msgs []Message, id string) (string, bool)

func Steps

func Steps(msgs []Message) []outputs.Step

func Transcript

func Transcript(s Session, msgs []Message) history.Transcript

func Usage

func Usage(msgs []Message) usage.Stats

Types

type Answer

type Answer struct {
	Answers [][]string `json:"answers,omitempty"`
	Reply   string     `json:"reply,omitempty"`
	Reject  bool       `json:"reject,omitempty"`
}

type Ask

type Ask struct {
	ID         string     `json:"id"`
	SessionID  string     `json:"sessionID"`
	Questions  []Question `json:"questions,omitempty"`
	Permission string     `json:"permission,omitempty"`
	Patterns   []string   `json:"patterns,omitempty"`
	Key        string     `json:"key,omitempty"`
}

func (Ask) Activity

func (a Ask) Activity() string

func (Ask) Fingerprint

func (a Ask) Fingerprint() string

type Backend

type Backend struct {
	Client
	Bin string
	// contains filtered or unexported fields
}

func New

func New(url, bin string) *Backend

func (*Backend) All

func (b *Backend) All(ctx context.Context, sid string) ([]Message, error)

func (*Backend) Attach

func (b *Backend) Attach(sid string) *exec.Cmd

func (*Backend) Dir

func (b *Backend) Dir(ctx context.Context, sid string) string

func (*Backend) Find

func (b *Backend) Find(ctx context.Context, sid string) (history.Transcript, bool)

func (*Backend) Live

func (b *Backend) Live(ctx context.Context, ids []string) (live []Live, gone []string)

func (*Backend) Outputs

func (b *Backend) Outputs(ctx context.Context, sid, home string) ([]outputs.File, []outputs.Link, map[string]time.Time, error)

func (*Backend) Page

func (b *Backend) Page(ctx context.Context, sid string) (history.Page, error)

func (*Backend) Reply

func (b *Backend) Reply(sid, id string) (string, error)

func (*Backend) Respond

func (b *Backend) Respond(ctx context.Context, sid, id string, a Answer) error

func (*Backend) Root

func (b *Backend) Root(ctx context.Context, sid string) bool

func (*Backend) Send

func (b *Backend) Send(ctx context.Context, sid string, p Prompt) error

func (*Backend) Start

func (b *Backend) Start(ctx context.Context, dir, title string, p Prompt) (string, error)

func (*Backend) Stop

func (b *Backend) Stop(ctx context.Context, sid string) error

func (*Backend) Transcripts

func (b *Backend) Transcripts(ctx context.Context, max int) []history.Transcript

type Client

type Client struct {
	URL string
	// contains filtered or unexported fields
}

func (*Client) Abort

func (c *Client) Abort(ctx context.Context, sid, dir string) error

func (*Client) Answer

func (c *Client) Answer(ctx context.Context, dir, id string, a Answer) error

func (*Client) Asks

func (c *Client) Asks(ctx context.Context, dir string) (map[string][]Ask, error)

func (*Client) Branch

func (c *Client) Branch(ctx context.Context, dir string) string

func (*Client) Busy

func (c *Client) Busy(ctx context.Context, dir string) (map[string]bool, error)

func (*Client) Create

func (c *Client) Create(ctx context.Context, dir, title string) (Session, error)

func (*Client) Messages

func (c *Client) Messages(ctx context.Context, sid string, limit int) ([]Message, error)

func (*Client) Prompt

func (c *Client) Prompt(ctx context.Context, sid, dir string, p Prompt) error

func (*Client) Session

func (c *Client) Session(ctx context.Context, sid string) (Session, error)

func (*Client) Sessions

func (c *Client) Sessions(ctx context.Context, max int) ([]Session, error)

func (*Client) Watch

func (c *Client) Watch(ctx context.Context, on func(Event))

type Event

type Event struct {
	Directory string
	Type      string
	SessionID string
	Status    string
}

type Live

type Live struct {
	history.Transcript
	Busy bool
	Asks []Ask
}

type Message

type Message struct {
	Info struct {
		ID         string `json:"id"`
		Role       string `json:"role"`
		ModelID    string `json:"modelID"`
		ProviderID string `json:"providerID"`
		Model      struct {
			ProviderID string `json:"providerID"`
			ModelID    string `json:"modelID"`
		} `json:"model"`
		Time struct {
			Created   int64 `json:"created"`
			Completed int64 `json:"completed"`
		} `json:"time"`
		Tokens struct {
			Input  int `json:"input"`
			Output int `json:"output"`
			Cache  struct {
				Read  int `json:"read"`
				Write int `json:"write"`
			} `json:"cache"`
		} `json:"tokens"`
	} `json:"info"`
	Parts []Part `json:"parts"`
}

type Part

type Part struct {
	ID        string `json:"id"`
	Type      string `json:"type"`
	Text      string `json:"text"`
	Synthetic bool   `json:"synthetic"`
	Ignored   bool   `json:"ignored"`
	Tool      string `json:"tool"`
	State     struct {
		Status string          `json:"status"`
		Input  json.RawMessage `json:"input"`
		Output string          `json:"output"`
		Time   struct {
			Start int64 `json:"start"`
		} `json:"time"`
	} `json:"state"`
}

type Prompt

type Prompt struct {
	Text  string
	Model string
	Brief string
}

type Question

type Question struct {
	Question string `json:"question"`
	Header   string `json:"header,omitempty"`
	Options  []struct {
		Label       string `json:"label"`
		Description string `json:"description,omitempty"`
	} `json:"options"`
	Multiple bool `json:"multiple,omitempty"`
	Custom   bool `json:"custom,omitempty"`
}

type Session

type Session struct {
	ID        string `json:"id"`
	ParentID  string `json:"parentID,omitempty"`
	Directory string `json:"directory"`
	Title     string `json:"title"`
	Model     struct {
		ID         string `json:"id"`
		ProviderID string `json:"providerID"`
	} `json:"model"`
	Time struct {
		Created  int64  `json:"created"`
		Updated  int64  `json:"updated"`
		Archived *int64 `json:"archived,omitempty"`
	} `json:"time"`
}

Jump to

Keyboard shortcuts

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