{"modulePath":"github.com/beeper/agentremote","version":"v0.0.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\n## Functions\n\n```go\nfunc IsAuthError(err error) bool\n```\nIsAuthError returns true if the error is an auth error.\n\n```go\nfunc NormalizeBaseURL(raw string) (string, error)\n```\nNormalizeBaseURL ensures a base URL is valid and has no trailing slash.\n\n## Types\n\n```go\ntype APIError struct {\n\tStatusCode int\n\tBody       string\n}\n```\nAPIError captures non-2xx responses from the OpenCode server.\n\n```go\nfunc (e *APIError) Error() string\n```\n\n```go\ntype Client struct {\n\t// contains filtered or unexported fields\n}\n```\nClient handles HTTP interactions with an OpenCode server.\n\n```go\nfunc NewClient(baseURL, username, password string) (*Client, error)\n```\nNewClient constructs an OpenCode client with basic auth if a password is provided.\n\n```go\nfunc (c *Client) AbortSession(ctx context.Context, sessionID string) error\n```\nAbortSession aborts a running session.\n\n```go\nfunc (c *Client) CreateSession(ctx context.Context, title, directory string) (*Session, error)\n```\nCreateSession creates a new session with an optional title and directory.\n\n```go\nfunc (c *Client) DeleteSession(ctx context.Context, sessionID string) error\n```\nDeleteSession deletes an OpenCode session.\n\n```go\nfunc (c *Client) GetMessage(ctx context.Context, sessionID, messageID string) (*MessageWithParts, error)\n```\nGetMessage fetches a single message and its parts.\n\n```go\nfunc (c *Client) ListMessages(ctx context.Context, sessionID string, limit int) ([]MessageWithParts, error)\n```\nListMessages lists recent messages in a session.\n\n```go\nfunc (c *Client) ListSessions(ctx context.Context) ([]Session, error)\n```\nListSessions returns all sessions from the server.\n\n```go\nfunc (c *Client) RejectQuestion(ctx context.Context, requestID string) error\n```\n\n```go\nfunc (c *Client) RespondPermission(ctx context.Context, sessionID, permissionID, response string) error\n```\n\n```go\nfunc (c *Client) SendMessageAsync(ctx context.Context, sessionID, messageID string, parts []PartInput) error\n```\nSendMessageAsync sends a message to a session asynchronously. The server returns 204 immediately; the assistant response is delivered via SSE.\n\n```go\nfunc (c *Client) StreamEvents(ctx context.Context) (\u003c-chan Event, \u003c-chan error)\n```\nStreamEvents connects to the OpenCode /event SSE endpoint. It returns a channel of events and a channel for errors.\n\n```go\nfunc (c *Client) UpdateSessionTitle(ctx context.Context, sessionID, title string) (*Session, error)\n```\nUpdateSessionTitle updates the title of an OpenCode session.\n\n```go\ntype Event struct {\n\tType       string          `json:\"type\"`\n\tProperties json.RawMessage `json:\"properties\"`\n}\n```\nEvent represents a server-sent event from the OpenCode event stream.\n\n```go\nfunc (e Event) DecodeInfo(target any) error\n```\nDecodeInfo decodes the info payload inside an event into the provided target.\n\n```go\ntype Message struct {\n\tID         string      `json:\"id\"`\n\tSessionID  string      `json:\"sessionID\"`\n\tRole       string      `json:\"role\"`\n\tParentID   string      `json:\"parentID,omitempty\"`\n\tAgent      string      `json:\"agent,omitempty\"`\n\tModelID    string      `json:\"modelID,omitempty\"`\n\tProviderID string      `json:\"providerID,omitempty\"`\n\tMode       string      `json:\"mode,omitempty\"`\n\tFinish     string      `json:\"finish,omitempty\"`\n\tCost       float64     `json:\"cost,omitempty\"`\n\tTokens     *TokenUsage `json:\"tokens,omitempty\"`\n\tTime       MessageTime `json:\"time\"`\n}\n```\nMessage represents the info block for a session message.\n\n```go\ntype MessageTime struct {\n\tCreated   Timestamp `json:\"created\"`\n\tCompleted Timestamp `json:\"completed,omitempty\"`\n}\n```\nMessageTime holds timing info for a message.\n\n```go\ntype MessageWithParts struct {\n\tInfo  Message `json:\"info\"`\n\tParts []Part  `json:\"parts\"`\n}\n```\nMessageWithParts bundles a message info block with its parts.\n\n```go\ntype ModelRef struct {\n\tProviderID string `json:\"providerID,omitempty\"`\n\tModelID    string `json:\"modelID,omitempty\"`\n}\n```\nModelRef identifies a provider/model pair.\n\n```go\ntype Part struct {\n\tID          string          `json:\"id\"`\n\tSessionID   string          `json:\"sessionID,omitempty\"`\n\tMessageID   string          `json:\"messageID,omitempty\"`\n\tType        string          `json:\"type\"`\n\tText        string          `json:\"text,omitempty\"`\n\tFilename    string          `json:\"filename,omitempty\"`\n\tURL         string          `json:\"url,omitempty\"`\n\tMime        string          `json:\"mime,omitempty\"`\n\tName        string          `json:\"name,omitempty\"`\n\tPrompt      string          `json:\"prompt,omitempty\"`\n\tDescription string          `json:\"description,omitempty\"`\n\tAgent       string          `json:\"agent,omitempty\"`\n\tModel       *ModelRef       `json:\"model,omitempty\"`\n\tCommand     string          `json:\"command,omitempty\"`\n\tCallID      string          `json:\"callID,omitempty\"`\n\tTool        string          `json:\"tool,omitempty\"`\n\tState       *ToolState      `json:\"state,omitempty\"`\n\tSnapshot    string          `json:\"snapshot,omitempty\"`\n\tHash        string          `json:\"hash,omitempty\"`\n\tFiles       []string        `json:\"files,omitempty\"`\n\tReason      string          `json:\"reason,omitempty\"`\n\tCost        float64         `json:\"cost,omitempty\"`\n\tTokens      *TokenUsage     `json:\"tokens,omitempty\"`\n\tAttempt     int             `json:\"attempt,omitempty\"`\n\tAuto        bool            `json:\"auto,omitempty\"`\n\tTime        *PartTime       `json:\"time,omitempty\"`\n\tMetadata    map[string]any  `json:\"metadata,omitempty\"`\n\tError       json.RawMessage `json:\"error,omitempty\"`\n\tSource      json.RawMessage `json:\"source,omitempty\"`\n\tExtra       map[string]any  `json:\"extra,omitempty\"`\n}\n```\nPart represents a message part. Only a subset of fields is used by the bridge.\n\n```go\ntype PartInput struct {\n\tID          string    `json:\"id,omitempty\"`\n\tType        string    `json:\"type\"`\n\tText        string    `json:\"text,omitempty\"`\n\tMime        string    `json:\"mime,omitempty\"`\n\tFilename    string    `json:\"filename,omitempty\"`\n\tURL         string    `json:\"url,omitempty\"`\n\tName        string    `json:\"name,omitempty\"`\n\tPrompt      string    `json:\"prompt,omitempty\"`\n\tDescription string    `json:\"description,omitempty\"`\n\tAgent       string    `json:\"agent,omitempty\"`\n\tModel       *ModelRef `json:\"model,omitempty\"`\n\tCommand     string    `json:\"command,omitempty\"`\n}\n```\nPartInput is used to send parts to OpenCode.\n\n```go\ntype PartTime struct {\n\tStart Timestamp `json:\"start\"`\n\tEnd   Timestamp `json:\"end,omitempty\"`\n}\n```\nPartTime represents part timing metadata.\n\n```go\ntype PermissionRequest struct {\n\tID         string          `json:\"id\"`\n\tSessionID  string          `json:\"sessionID\"`\n\tPermission string          `json:\"permission\"`\n\tPatterns   []string        `json:\"patterns\"`\n\tMetadata   map[string]any  `json:\"metadata\"`\n\tAlways     []string        `json:\"always\"`\n\tTool       *RequestToolRef `json:\"tool,omitempty\"`\n}\n```\n\n```go\ntype QuestionInfo struct {\n\tQuestion string           `json:\"question\"`\n\tHeader   string           `json:\"header\"`\n\tOptions  []QuestionOption `json:\"options\"`\n\tMultiple bool             `json:\"multiple,omitempty\"`\n\tCustom   bool             `json:\"custom,omitempty\"`\n}\n```\n\n```go\ntype QuestionOption struct {\n\tLabel       string `json:\"label\"`\n\tDescription string `json:\"description\"`\n}\n```\n\n```go\ntype QuestionRequest struct {\n\tID        string          `json:\"id\"`\n\tSessionID string          `json:\"sessionID\"`\n\tQuestions []QuestionInfo  `json:\"questions\"`\n\tTool      *RequestToolRef `json:\"tool,omitempty\"`\n}\n```\n\n```go\ntype RequestToolRef struct {\n\tMessageID string `json:\"messageID,omitempty\"`\n\tCallID    string `json:\"callID,omitempty\"`\n}\n```\n\n```go\ntype Session struct {\n\tID        string      `json:\"id\"`\n\tSlug      string      `json:\"slug\"`\n\tProjectID string      `json:\"projectID\"`\n\tDirectory string      `json:\"directory\"`\n\tParentID  string      `json:\"parentID,omitempty\"`\n\tTitle     string      `json:\"title\"`\n\tVersion   string      `json:\"version\"`\n\tTime      SessionTime `json:\"time\"`\n}\n```\nSession represents an OpenCode session summary.\n\n```go\ntype SessionTime struct {\n\tCreated Timestamp `json:\"created\"`\n\tUpdated Timestamp `json:\"updated\"`\n}\n```\nSessionTime holds session timing metadata.\n\n```go\ntype Timestamp int64\n```\nTimestamp represents millisecond timestamps returned by the OpenCode API.\n\n```go\nfunc (t *Timestamp) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON accepts either integer or floating-point JSON numbers.\n\n```go\ntype TokenCache struct {\n\tRead  float64 `json:\"read,omitempty\"`\n\tWrite float64 `json:\"write,omitempty\"`\n}\n```\nTokenCache represents cached token usage.\n\n```go\ntype TokenUsage struct {\n\tInput     float64     `json:\"input,omitempty\"`\n\tOutput    float64     `json:\"output,omitempty\"`\n\tReasoning float64     `json:\"reasoning,omitempty\"`\n\tCache     *TokenCache `json:\"cache,omitempty\"`\n}\n```\nTokenUsage represents token usage.\n\n```go\ntype ToolState struct {\n\tStatus      string         `json:\"status\"`\n\tInput       map[string]any `json:\"input,omitempty\"`\n\tRaw         string         `json:\"raw,omitempty\"`\n\tTitle       string         `json:\"title,omitempty\"`\n\tMetadata    map[string]any `json:\"metadata,omitempty\"`\n\tOutput      string         `json:\"output,omitempty\"`\n\tError       string         `json:\"error,omitempty\"`\n\tTime        *ToolStateTime `json:\"time,omitempty\"`\n\tAttachments []Part         `json:\"attachments,omitempty\"`\n}\n```\nToolState captures tool execution state.\n\n```go\ntype ToolStateTime struct {\n\tStart     Timestamp `json:\"start,omitempty\"`\n\tEnd       Timestamp `json:\"end,omitempty\"`\n\tCompacted Timestamp `json:\"compacted,omitempty\"`\n}\n```\nToolStateTime captures tool state timing.\n\n","path":"github.com/beeper/agentremote/bridges/opencode/api","name":"api","synopsis":"","isRedistributable":true}
