acp

package
v0.7.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolVersion = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentInfo

type AgentInfo struct {
	Name    string `json:"name"`
	Title   string `json:"title,omitempty"`
	Version string `json:"version,omitempty"`
}

type AgentSpec

type AgentSpec struct {
	Name        string
	Command     string
	Args        []string
	Environment map[string]string
}

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(reader io.ReadCloser, writer io.WriteCloser, requestHandler RequestHandler, notificationHandler NotificationHandler) *Connection

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) Closed

func (c *Connection) Closed() <-chan struct{}

func (*Connection) Notify

func (c *Connection) Notify(method string, params any) error

func (*Connection) Request

func (c *Connection) Request(ctx context.Context, method string, params any, result any) error

type ContextPolicy

type ContextPolicy struct {
	HistoryOwner                string `json:"history_owner"`
	AgentDockPersistsTranscript bool   `json:"agentdock_persists_transcript"`
	AgentDockReplaysTranscript  bool   `json:"agentdock_replays_transcript"`
	RestartRequiresExplicitLoad bool   `json:"restart_requires_explicit_load"`
}

type Error

type Error struct {
	Code      string
	Message   string
	Retryable bool
	Details   map[string]any
	Cause     error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Event

type Event struct {
	Seq                 uint64          `json:"seq"`
	Type                string          `json:"type"`
	SessionID           string          `json:"session_id"`
	RunID               string          `json:"run_id,omitempty"`
	CreatedAt           time.Time       `json:"created_at"`
	Update              json.RawMessage `json:"update,omitempty"`
	UpdateTruncated     bool            `json:"update_truncated,omitempty"`
	OriginalUpdateBytes int             `json:"original_update_bytes,omitempty"`
	StopReason          string          `json:"stop_reason,omitempty"`
	ErrorCode           string          `json:"error_code,omitempty"`
	Message             string          `json:"message,omitempty"`
}

type EventPolicy

type EventPolicy struct {
	Incremental       bool   `json:"incremental"`
	Cursor            string `json:"cursor"`
	MaxEventsPerPage  int    `json:"max_events_per_page"`
	MaxRetainedEvents int    `json:"max_retained_events"`
	MaxRetainedBytes  int    `json:"max_retained_bytes"`
	MaxUpdateBytes    int    `json:"max_update_bytes"`
}

type InitializeResult

type InitializeResult struct {
	ProtocolVersion   int            `json:"protocolVersion"`
	AgentCapabilities map[string]any `json:"agentCapabilities"`
	AgentInfo         AgentInfo      `json:"agentInfo"`
	AuthMethods       []any          `json:"authMethods,omitempty"`
	Meta              map[string]any `json:"_meta,omitempty"`
}

type Interaction

type Interaction struct {
	ID        string             `json:"id"`
	SessionID string             `json:"session_id"`
	Kind      string             `json:"kind"`
	Status    InteractionStatus  `json:"status"`
	ToolCall  map[string]any     `json:"tool_call,omitempty"`
	Options   []PermissionOption `json:"options,omitempty"`
	CreatedAt time.Time          `json:"created_at"`
	ExpiresAt time.Time          `json:"expires_at"`
	// contains filtered or unexported fields
}

type InteractionPolicy

type InteractionPolicy struct {
	MemoryOnly            bool `json:"memory_only"`
	MaxOptions            int  `json:"max_options"`
	MaxToolCallBytes      int  `json:"max_tool_call_bytes"`
	MaxPendingGlobal      int  `json:"max_pending_global"`
	MaxPendingPerSession  int  `json:"max_pending_per_session"`
	AlwaysOptionsFiltered bool `json:"always_options_filtered"`
}

type InteractionStatus

type InteractionStatus string
const (
	InteractionPending   InteractionStatus = "pending"
	InteractionResponded InteractionStatus = "responded"
	InteractionCancelled InteractionStatus = "cancelled"
	InteractionExpired   InteractionStatus = "expired"
)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(opts Options) (*Manager, error)

func (*Manager) AgentInfo

func (m *Manager) AgentInfo(ctx context.Context) (InitializeResult, error)

func (*Manager) AgentName

func (m *Manager) AgentName() string

func (*Manager) Authenticate

func (m *Manager) Authenticate(ctx context.Context, methodID string) error

func (*Manager) CancelPrompt

func (m *Manager) CancelPrompt(_ context.Context, sessionID, runID string) error

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) CloseSession

func (m *Manager) CloseSession(ctx context.Context, id string) (SessionRecord, error)

func (*Manager) DeleteSession

func (m *Manager) DeleteSession(ctx context.Context, id string) error

func (*Manager) ForkSession

func (m *Manager) ForkSession(ctx context.Context, id, cwd string, additionalDirectories []string) (SessionResult, error)

func (*Manager) InspectInteraction

func (m *Manager) InspectInteraction(id string) (Interaction, error)

func (*Manager) InspectSession

func (m *Manager) InspectSession(id string) (SessionRecord, error)

func (*Manager) ListInteractions

func (m *Manager) ListInteractions(sessionID string, pendingOnly bool) []Interaction

func (*Manager) ListSessions

func (m *Manager) ListSessions() ([]SessionRecord, error)

func (*Manager) LoadSession

func (m *Manager) LoadSession(ctx context.Context, id string) (SessionResult, error)

func (*Manager) NewSession

func (m *Manager) NewSession(ctx context.Context, cwd string, additionalDirectories []string) (SessionResult, error)

func (*Manager) PromptEvents

func (m *Manager) PromptEvents(ctx context.Context, runID string, after uint64, limit int, wait time.Duration) (PromptEventsResult, error)

func (*Manager) RespondInteraction

func (m *Manager) RespondInteraction(id, optionID string, cancelled bool) (Interaction, error)

func (*Manager) ResumeSession

func (m *Manager) ResumeSession(ctx context.Context, id string) (SessionResult, error)

func (*Manager) SetSessionConfigOption

func (m *Manager) SetSessionConfigOption(ctx context.Context, id, configID string, value any) (any, error)

func (*Manager) SetSessionMode

func (m *Manager) SetSessionMode(ctx context.Context, id, modeID string) error

func (*Manager) StartPrompt

func (m *Manager) StartPrompt(ctx context.Context, sessionID, text string) (PromptStartResult, error)

func (*Manager) Steer

func (m *Manager) Steer(ctx context.Context, sessionID, text string) (map[string]any, error)

type NotificationHandler

type NotificationHandler func(string, json.RawMessage)

type Options

type Options struct {
	Home               string
	DefaultCWD         string
	Agent              AgentSpec
	MaxConcurrentRuns  int
	InteractionTimeout time.Duration
}

type PermissionOption

type PermissionOption struct {
	OptionID string `json:"optionId"`
	Name     string `json:"name"`
	Kind     string `json:"kind"`
}

type PromptEventsResult

type PromptEventsResult struct {
	RunID        string     `json:"run_id"`
	SessionID    string     `json:"session_id"`
	Status       RunStatus  `json:"status"`
	Events       []Event    `json:"events"`
	NextSeq      uint64     `json:"next_seq"`
	FirstSeq     uint64     `json:"first_seq"`
	LatestSeq    uint64     `json:"latest_seq"`
	DroppedCount uint64     `json:"dropped_count"`
	HasMore      bool       `json:"has_more"`
	Truncated    bool       `json:"truncated"`
	StartedAt    time.Time  `json:"started_at"`
	EndedAt      *time.Time `json:"ended_at,omitempty"`
	StopReason   string     `json:"stop_reason,omitempty"`
	ErrorCode    string     `json:"error_code,omitempty"`
	Message      string     `json:"message,omitempty"`
}

type PromptStartResult

type PromptStartResult struct {
	RunID     string    `json:"run_id"`
	SessionID string    `json:"session_id"`
	Status    RunStatus `json:"status"`
	StartedAt time.Time `json:"started_at"`
}

type RequestHandler

type RequestHandler func(context.Context, string, json.RawMessage) (any, *rpcError)

type Run

type Run struct {
	ID         string
	SessionID  string
	Status     RunStatus
	StartedAt  time.Time
	EndedAt    *time.Time
	StopReason string
	Err        error
	// contains filtered or unexported fields
}

type RunStatus

type RunStatus string
const (
	RunRunning     RunStatus = "running"
	RunCompleted   RunStatus = "completed"
	RunCancelled   RunStatus = "cancelled"
	RunInterrupted RunStatus = "interrupted"
	RunFailed      RunStatus = "failed"
)

type RuntimePolicies

type RuntimePolicies struct {
	Context      ContextPolicy     `json:"context_policy"`
	Events       EventPolicy       `json:"event_policy"`
	Interactions InteractionPolicy `json:"interaction_policy"`
	Steering     SteeringPolicy    `json:"steering_policy"`
}

RuntimePolicies is the machine-readable contract returned by acp_session info. Values are derived from the same constants that enforce the runtime, keeping client guidance and server behavior in one source of truth.

func CurrentPolicies

func CurrentPolicies() RuntimePolicies

type SessionRecord

type SessionRecord struct {
	SchemaVersion         int           `json:"schema_version"`
	ID                    string        `json:"id"`
	Agent                 string        `json:"agent"`
	RemoteSessionID       string        `json:"remote_session_id"`
	CWD                   string        `json:"cwd"`
	AdditionalDirectories []string      `json:"additional_directories,omitempty"`
	ModeID                string        `json:"mode_id,omitempty"`
	Status                SessionStatus `json:"status"`
	LastStopReason        string        `json:"last_stop_reason,omitempty"`
	CreatedAt             time.Time     `json:"created_at"`
	UpdatedAt             time.Time     `json:"updated_at"`
	ClosedAt              *time.Time    `json:"closed_at,omitempty"`
}

type SessionResult

type SessionResult struct {
	Session       SessionRecord `json:"session"`
	Modes         any           `json:"modes,omitempty"`
	ConfigOptions any           `json:"config_options,omitempty"`
	Agent         AgentInfo     `json:"agent"`
}

type SessionStatus

type SessionStatus string
const (
	SessionReady       SessionStatus = "ready"
	SessionRunning     SessionStatus = "running"
	SessionInterrupted SessionStatus = "interrupted"
	SessionClosed      SessionStatus = "closed"
	SessionError       SessionStatus = "error"
)

type SteeringPolicy

type SteeringPolicy struct {
	NativeWhenSupported             bool `json:"native_when_supported"`
	IdlePromptRequiredStartsRun     bool `json:"idle_prompt_required_starts_run"`
	CompatibilityFallbackReturnsRun bool `json:"compatibility_fallback_returns_run"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL