Documentation
¶
Overview ¶
Package opencode provides an agent provider for opencode sessions
Index ¶
- type MessageData
- type OpenCodeAgent
- func (a *OpenCodeAgent) CurrentTask() string
- func (a *OpenCodeAgent) Directory() string
- func (a *OpenCodeAgent) ID() string
- func (a *OpenCodeAgent) IsBackground() bool
- func (a *OpenCodeAgent) LastActivity() time.Time
- func (a *OpenCodeAgent) LastError() error
- func (a *OpenCodeAgent) LoadFullHistory()
- func (a *OpenCodeAgent) Metrics() agent.Metrics
- func (a *OpenCodeAgent) Name() string
- func (a *OpenCodeAgent) Output() io.Reader
- func (a *OpenCodeAgent) ParentID() string
- func (a *OpenCodeAgent) Pause() error
- func (a *OpenCodeAgent) ProjectID() string
- func (a *OpenCodeAgent) Refresh() error
- func (a *OpenCodeAgent) Resume() error
- func (a *OpenCodeAgent) SendInput(input string) error
- func (a *OpenCodeAgent) StartTime() time.Time
- func (a *OpenCodeAgent) Status() agent.Status
- func (a *OpenCodeAgent) Terminate() error
- func (a *OpenCodeAgent) Type() string
- type PartData
- type Provider
- func (p *Provider) ChildCount(parentID string) int
- func (p *Provider) Discover(ctx context.Context) ([]agent.Agent, error)
- func (p *Provider) Get(id string) (agent.Agent, error)
- func (p *Provider) GetChildren(parentID string) []agent.Agent
- func (p *Provider) List() []agent.Agent
- func (p *Provider) ListPrimary() []agent.Agent
- func (p *Provider) Name() string
- func (p *Provider) SendInput(id string, input string) error
- func (p *Provider) Spawn(ctx context.Context, config agent.SpawnConfig) (agent.Agent, error)
- func (p *Provider) Terminate(id string) error
- func (p *Provider) Type() string
- func (p *Provider) Watch(ctx context.Context) (<-chan agent.Event, error)
- type SessionData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageData ¶
type MessageData struct {
ID string `json:"id"`
SessionID string `json:"sessionID"`
Role string `json:"role"`
Time struct {
Created int64 `json:"created"` // Unix timestamp in milliseconds
} `json:"time"`
Summary struct {
Title string `json:"title"`
} `json:"summary"`
Agent string `json:"agent,omitempty"`
Model struct {
ProviderID string `json:"providerID"`
ModelID string `json:"modelID"`
} `json:"model,omitempty"`
}
MessageData represents a message in the session
type OpenCodeAgent ¶
type OpenCodeAgent struct {
// contains filtered or unexported fields
}
OpenCodeAgent implements the Agent interface for opencode sessions
func NewOpenCodeAgent ¶
func NewOpenCodeAgent(storagePath, sessionFilePath string) (*OpenCodeAgent, error)
NewOpenCodeAgent creates a new OpenCodeAgent from a session JSON file
func (*OpenCodeAgent) CurrentTask ¶
func (a *OpenCodeAgent) CurrentTask() string
CurrentTask returns the current task description
func (*OpenCodeAgent) Directory ¶
func (a *OpenCodeAgent) Directory() string
Directory returns the working directory
func (*OpenCodeAgent) ID ¶
func (a *OpenCodeAgent) ID() string
ID returns the agent's unique identifier
func (*OpenCodeAgent) IsBackground ¶
func (a *OpenCodeAgent) IsBackground() bool
func (*OpenCodeAgent) LastActivity ¶
func (a *OpenCodeAgent) LastActivity() time.Time
LastActivity returns the last activity time
func (*OpenCodeAgent) LastError ¶
func (a *OpenCodeAgent) LastError() error
LastError returns the last error
func (*OpenCodeAgent) LoadFullHistory ¶
func (a *OpenCodeAgent) LoadFullHistory()
func (*OpenCodeAgent) Metrics ¶
func (a *OpenCodeAgent) Metrics() agent.Metrics
Metrics returns the agent's metrics
func (*OpenCodeAgent) Name ¶
func (a *OpenCodeAgent) Name() string
Name returns the agent's display name
func (*OpenCodeAgent) Output ¶
func (a *OpenCodeAgent) Output() io.Reader
Output returns the output stream (lazy-loads history on first access)
func (*OpenCodeAgent) ParentID ¶
func (a *OpenCodeAgent) ParentID() string
func (*OpenCodeAgent) Pause ¶
func (a *OpenCodeAgent) Pause() error
Pause pauses the agent (not supported)
func (*OpenCodeAgent) ProjectID ¶
func (a *OpenCodeAgent) ProjectID() string
ProjectID returns the project identifier
func (*OpenCodeAgent) Refresh ¶
func (a *OpenCodeAgent) Refresh() error
Refresh refreshes the agent's state from disk
func (*OpenCodeAgent) Resume ¶
func (a *OpenCodeAgent) Resume() error
Resume resumes the agent (not supported)
func (*OpenCodeAgent) SendInput ¶
func (a *OpenCodeAgent) SendInput(input string) error
SendInput sends input to the agent by appending to the session via CLI
func (*OpenCodeAgent) StartTime ¶
func (a *OpenCodeAgent) StartTime() time.Time
StartTime returns when the agent started
func (*OpenCodeAgent) Status ¶
func (a *OpenCodeAgent) Status() agent.Status
Status returns the current status
func (*OpenCodeAgent) Terminate ¶
func (a *OpenCodeAgent) Terminate() error
Terminate terminates the agent
type PartData ¶
type PartData struct {
ID string `json:"id"`
MessageID string `json:"messageID"`
SessionID string `json:"sessionID"`
Type string `json:"type"` // "text", "tool-invocation", etc.
Time struct {
Created int64 `json:"created"`
} `json:"time"`
Text string `json:"text,omitempty"`
ToolName string `json:"toolName,omitempty"`
ToolCallID string `json:"toolCallId,omitempty"`
State string `json:"state,omitempty"` // "running", "success", "error"
}
PartData represents a message part (content, tool calls, etc.)
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the agent.Provider interface for opencode
func NewProvider ¶
NewProvider creates a new opencode provider
func (*Provider) ChildCount ¶
ChildCount returns the number of child agents for a given parent ID
func (*Provider) GetChildren ¶
GetChildren returns all child agents for a given parent ID
func (*Provider) ListPrimary ¶
ListPrimary returns only primary agents (agents without a parent)
type SessionData ¶
type SessionData struct {
ID string `json:"id"`
Version string `json:"version"`
ProjectID string `json:"projectID"`
Directory string `json:"directory"`
ParentID string `json:"parentID,omitempty"`
Title string `json:"title"`
Time struct {
Created int64 `json:"created"` // Unix timestamp in milliseconds
Updated int64 `json:"updated"` // Unix timestamp in milliseconds
} `json:"time"`
Summary struct {
Additions int `json:"additions"`
Deletions int `json:"deletions"`
Files int `json:"files"`
} `json:"summary"`
}
SessionData represents the opencode session.json structure