Documentation
¶
Index ¶
- Constants
- func CheckPlugin(root, directory string) error
- func ConfigDir(lookup func(string) (string, bool)) string
- func DataDir(lookup func(string) (string, bool)) string
- func HomeEnvironment(home string) map[string]string
- func IsMissing(err error) bool
- func ModelSelectionShapeError(value string) error
- func NewID(prefix string) string
- func NewMessageID() string
- func SessionPath(id string) string
- func WritePlugin(root, config string, ownsHome bool) (string, error)
- type Client
- func (c *Client) Args() []string
- func (c *Client) CancelInput(ctx context.Context, sessionID, inputID string) error
- func (c *Client) Do(ctx context.Context, directory, method, path string, body, out any) error
- func (c *Client) Enqueue(ctx context.Context, input InboxInput) error
- func (c *Client) Export(ctx context.Context, id string) (Export, error)
- func (c *Client) Import(ctx context.Context, snapshot Export, location Location) error
- func (c *Client) Inbox(ctx context.Context, sessionID string) ([]InboxInput, error)
- func (c *Client) Interrupt(ctx context.Context, id string) error
- func (c *Client) Move(ctx context.Context, id, directory string) error
- func (c *Client) ReadAddress(stdout io.Reader) error
- func (c *Client) Session(ctx context.Context, id string) (NativeSession, error)
- func (c *Client) Subscribe(ctx context.Context) (*Stream, error)
- func (c *Client) UsageAccess(ctx context.Context, directory, providerID string, selected ModelRef, ...) (usage.Access, error)
- func (c *Client) UsageGateways(ctx context.Context, directory string, selected ModelRef, ...) ([]gateway.Route, error)
- func (c *Client) Wait(ctx context.Context, id string) error
- func (c *Client) WaitForPlugins(ctx context.Context, directory string) error
- type Content
- type Event
- type Export
- type Form
- type FormField
- type HTTPError
- type InboxInput
- type Location
- type Model
- type ModelRef
- type NativeAgent
- type NativeAttachment
- type NativeCommand
- type NativeError
- type NativeMessage
- type NativeSession
- type NativeSessionStatus
- type NativeTodo
- type NativeTokens
- type PermissionRequest
- type ProtocolError
- type Stream
- type ToolState
Constants ¶
const CarrierKey = "acp-go-opencodev2"
const EventCapacity = 256
const InternalEnvPrefix = "ACP_GO_OPENCODEV2_INTERNAL_"
const MaxBodyBytes = 64 << 20
const ServerUsername = "opencode"
ServerUsername is the basic-auth user the adapter configures the native server with and sends on every request.
Variables ¶
This section is empty.
Functions ¶
func CheckPlugin ¶
func HomeEnvironment ¶
func NewMessageID ¶
func NewMessageID() string
NewMessageID uses the native timestamp layout so later CLI messages sort after it.
func SessionPath ¶
Types ¶
type Client ¶
Client is an authenticated native HTTP endpoint shared by every session.
func (*Client) CancelInput ¶
func (*Client) ReadAddress ¶
ReadAddress reads the owned server's bound loopback address before any HTTP request.
func (*Client) UsageAccess ¶
func (c *Client) UsageAccess(ctx context.Context, directory, providerID string, selected ModelRef, lookup func(string) (string, bool)) (usage.Access, error)
UsageAccess verifies the effective model route and the native active credential.
func (*Client) UsageGateways ¶
type Content ¶
type Content struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Text string `json:"text,omitempty"`
State json.RawMessage `json:"state,omitempty"`
URI string `json:"uri,omitempty"`
MIME string `json:"mime,omitempty"`
}
Content is one native assistant or tool content block.
type Event ¶
type Event struct {
ID string `json:"id"`
Type string `json:"type"`
Created int64 `json:"created"`
Data json.RawMessage `json:"data"`
Durable *struct {
AggregateID string `json:"aggregateID"`
Seq int64 `json:"seq"`
Version int `json:"version"`
} `json:"durable,omitempty"`
Raw json.RawMessage `json:"-"`
}
func (*Event) UnmarshalJSON ¶
type Export ¶
type Export struct {
Info NativeSession `json:"info"`
Messages []NativeMessage `json:"messages"`
Raw json.RawMessage `json:"-"`
}
Export is the native, lossless session transfer format.
func (Export) CompletedPrefix ¶
CompletedPrefix retains only executions ending in a durable idle marker.
func (Export) ContainsHistory ¶
ContainsHistory verifies saved identities, order, and content. Export omits in-flight assistant, shell, and compaction records; they can appear later at their original positions when they finish.
func (Export) ExecutionPrefix ¶
ExecutionPrefix cuts the export at the terminal event's durable idle marker.
func (Export) SameConfiguration ¶
SameConfiguration excludes native accounting that advances during execution.
func (*Export) UnmarshalJSON ¶
type FormField ¶
type FormField struct {
Key string `json:"key"`
Type string `json:"type"`
Label string `json:"label"`
Description string `json:"description"`
Required bool `json:"required"`
Options []struct {
Value string `json:"value"`
Label string `json:"label"`
} `json:"options"`
Raw json.RawMessage `json:"-"`
}
func (*FormField) UnmarshalJSON ¶
type HTTPError ¶
type HTTPError struct {
Status int
Native NativeError
}
type InboxInput ¶
type InboxInput struct {
ID string `json:"id"`
SessionID string `json:"sessionID"`
Type string `json:"type"`
Payload json.RawMessage `json:"payload"`
Delivery string `json:"delivery"`
Time struct {
Created int64 `json:"created"`
} `json:"time"`
}
InboxInput is native input waiting for the next execution.
func (InboxInput) Validate ¶
func (input InboxInput) Validate(sessionID string) error
type Model ¶
type Model struct {
Package string `json:"package"`
ID string `json:"id"`
ProviderID string `json:"providerID"`
Name string `json:"name"`
Enabled bool `json:"enabled"`
Capabilities struct {
Input []string `json:"input"`
} `json:"capabilities"`
Variants []struct {
ID string `json:"id"`
} `json:"variants"`
Limit map[string]float64 `json:"limit"`
}
type NativeAgent ¶
type NativeAttachment ¶
type NativeCommand ¶
type NativeError ¶
type NativeMessage ¶
type NativeMessage struct {
ID string `json:"id"`
Type string `json:"type"`
Text string `json:"text,omitempty"`
Model ModelRef `json:"model"`
Agent string `json:"agent,omitempty"`
Content []Content `json:"content,omitempty"`
Files []NativeAttachment `json:"files,omitempty"`
Finish string `json:"finish,omitempty"`
Outcome string `json:"outcome,omitempty"`
Error *NativeError `json:"error,omitempty"`
Tokens NativeTokens `json:"tokens"`
Cost float64 `json:"cost"`
Time struct {
Created int64 `json:"created"`
Completed int64 `json:"completed"`
} `json:"time"`
Raw json.RawMessage `json:"-"`
}
NativeMessage is a projected message returned by the native transcript API. Raw retains fields needed by import even when ACP does not display them.
func (*NativeMessage) UnmarshalJSON ¶
func (m *NativeMessage) UnmarshalJSON(data []byte) error
type NativeSession ¶
type NativeSession struct {
ID string `json:"id"`
ParentID string `json:"parentID,omitempty"`
Title string `json:"title,omitempty"`
Agent string `json:"agent,omitempty"`
Model ModelRef `json:"model"`
Location Location `json:"location"`
Metadata map[string]any `json:"metadata,omitempty"`
Cost float64 `json:"cost"`
Outcome string `json:"outcome,omitempty"`
Time struct {
Created int64 `json:"created"`
Updated int64 `json:"updated"`
Idle int64 `json:"idle"`
} `json:"time"`
}
type NativeSessionStatus ¶
type NativeSessionStatus struct {
Type string `json:"type"`
}
type NativeTodo ¶
type NativeTokens ¶
type PermissionRequest ¶
type ProtocolError ¶
type ProtocolError struct{ Message string }
ProtocolError reports a response that cannot belong to the native JSON API.
func (*ProtocolError) Error ¶
func (e *ProtocolError) Error() string