Documentation
¶
Index ¶
- Constants
- Variables
- func AdvancePluginGeneration(root string) error
- func CheckPlugin(root, directory string) error
- func ConfigDir(lookup func(string) (string, bool)) string
- func DataDir(lookup func(string) (string, bool)) string
- func ExecutionMarker(event Event) (id, outcome string, err error)
- 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) StreamExport(ctx context.Context, id string, info func(json.RawMessage) error, ...) 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 Message
- 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
EventCapacity bounds the decoded frames waiting for the runtime pump.
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 ¶
var ErrMarkerMissing = errors.New("native execution marker missing")
ErrMarkerMissing reports an export that does not yet hold the execution's durable idle marker.
Functions ¶
func AdvancePluginGeneration ¶
AdvancePluginGeneration makes the environment plugin forget the session environments it applied, so the next tool call in each session reads its carrier again.
func CheckPlugin ¶
CheckPlugin verifies the environment plugin loaded for directory, which names the native location exactly as the adapter addressed it.
func ExecutionMarker ¶
ExecutionMarker names the durable idle marker a terminal execution event leaves in its session's history, and the outcome it records.
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) StreamExport ¶
func (c *Client) StreamExport(ctx context.Context, id string, info func(json.RawMessage) error, message func(raw []byte) error) error
StreamExport reads one session export as it arrives: info receives the session information, then message receives each settled message's raw bytes in native order. A message's bytes are valid only during its call, so the export is never held whole.
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"`
SessionID string `json:"-"`
Raw json.RawMessage `json:"-"`
}
Event is one native SSE frame. SessionID names the session the event addresses, read from its data once when the frame is decoded.
func DecodeEvent ¶
DecodeEvent decodes one owned SSE frame, which becomes the event's Raw; Data is the slice of Raw holding the event's data, not a copy.
type Export ¶
type Export struct {
Info NativeSession
InfoRaw json.RawMessage
Messages []Message
}
Export is the native, lossless session transfer format: the session's information and its settled messages, each kept as its raw bytes.
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) MarshalJSON ¶
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 Message ¶
Message is one exported native message: its raw bytes and the fields a checkpoint orders and cuts by. Decode yields the full projection.
func ParseMessage ¶
func ParseMessage(raw json.RawMessage) (Message, error)
ParseMessage reads a message whose raw bytes the caller hands over.
func (Message) Decode ¶
func (m Message) Decode() (NativeMessage, error)
Decode returns the message's full projection.
func (Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
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"`
}
NativeMessage is a projected message returned by the native transcript API.
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