Documentation
¶
Index ¶
- Constants
- func DisplayTextForPart(part Part) string
- func WaitForHealthOrExit(ctx context.Context, client healthClient, proc *ServerProcess, ...) error
- type Client
- func (c *Client) AbortSession(ctx context.Context, sessionID string) error
- func (c *Client) BaseURL() string
- func (c *Client) CreateSession(ctx context.Context, directory string) (*Session, error)
- func (c *Client) GetSession(ctx context.Context, sessionID string) (*Session, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) ListMessages(ctx context.Context, sessionID string) ([]MessageResponse, error)
- func (c *Client) ListProviders(ctx context.Context) ([]Provider, []string, error)
- func (c *Client) ListSessions(ctx context.Context) ([]Session, error)
- func (c *Client) ReplyQuestion(ctx context.Context, requestID string, answers [][]string) error
- func (c *Client) SendMessage(ctx context.Context, sessionID, text, providerID, modelID, agent string) <-chan string
- func (c *Client) SendMessageEvents(ctx context.Context, sessionID, text, providerID, modelID, agent string) <-chan StreamEvent
- type MessageInfo
- type MessageModelRef
- type MessageResponse
- type Model
- type ModelRef
- type Part
- type Provider
- type QuestionInfo
- type QuestionOption
- type QuestionRequest
- type ServerProcess
- type Session
- type SessionTime
- type StreamEvent
- type ToolEvent
Constants ¶
const DefaultBaseURL = "http://127.0.0.1:4096"
Variables ¶
This section is empty.
Functions ¶
func DisplayTextForPart ¶
func WaitForHealthOrExit ¶
func WaitForHealthOrExit(ctx context.Context, client healthClient, proc *ServerProcess, timeout time.Duration) error
WaitForHealthOrExit polls health until ready, timeout, cancellation, or the managed opencode process exits before becoming ready.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with a running `opencode serve` process.
func NewClientWithURL ¶
func (*Client) AbortSession ¶
func (*Client) CreateSession ¶
func (*Client) GetSession ¶
func (*Client) ListMessages ¶
func (*Client) ListProviders ¶
func (*Client) ReplyQuestion ¶
func (*Client) SendMessage ¶
func (c *Client) SendMessage(ctx context.Context, sessionID, text, providerID, modelID, agent string) <-chan string
SendMessage streams the assistant's reply token-by-token via the returned channel. It first tries the SSE-based approach (prompt_async + /event); if that fails (404 or connection error) it falls back to the synchronous /session/{id}/message endpoint.
func (*Client) SendMessageEvents ¶
func (c *Client) SendMessageEvents(ctx context.Context, sessionID, text, providerID, modelID, agent string) <-chan StreamEvent
type MessageInfo ¶
type MessageModelRef ¶
type MessageResponse ¶
type MessageResponse struct {
Info MessageInfo `json:"info"`
Parts []Part `json:"parts"`
}
type QuestionInfo ¶
type QuestionInfo struct {
Question string `json:"question"`
Header string `json:"header"`
Options []QuestionOption `json:"options"`
Multiple bool `json:"multiple"`
Custom *bool `json:"custom,omitempty"`
}
type QuestionOption ¶
type QuestionRequest ¶
type QuestionRequest struct {
ID string `json:"id"`
SessionID string `json:"sessionID"`
Questions []QuestionInfo `json:"questions"`
}
type ServerProcess ¶
type ServerProcess struct {
// contains filtered or unexported fields
}
ServerProcess owns an opencode server process started by plums.
func StartServer ¶
func StartServer(ctx context.Context, baseURL, directory string) (*ServerProcess, error)
StartServer starts `opencode serve` for baseURL and returns once the process has been launched. Call WaitForHealth before using the client.
func (*ServerProcess) Done ¶
func (p *ServerProcess) Done() <-chan struct{}
Done returns a channel that is closed when the managed process exits.
func (*ServerProcess) Stop ¶
func (p *ServerProcess) Stop()
Stop terminates the managed opencode server process.
type Session ¶
type Session struct {
ID string `json:"id"`
Title string `json:"title"`
Directory string `json:"directory"`
Model *ModelRef `json:"model"`
Time SessionTime `json:"time"`
}
type SessionTime ¶
type StreamEvent ¶
type StreamEvent struct {
Text string
Tool *ToolEvent
Question *QuestionRequest
}