acpclient

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionStatusQueued          = "queued"
	SessionStatusRunning         = "running"
	SessionStatusCompleted       = "completed"
	SessionStatusCanceled        = "canceled"
	SessionStatusCancelRequested = "cancel_requested"

	PendingPromptStatusPending  = "pending"
	PendingPromptStatusCanceled = "canceled"
)

Variables

View Source
var (
	ErrPathOutsideCWD = errors.New("acp client path is outside cwd")
	ErrWritesDisabled = errors.New("acp client filesystem writes are disabled")
)
View Source
var (
	ErrMissingCommand = errors.New("acp client command is required")
	ErrShellCommand   = errors.New("acp client command must be an executable path/name, with args passed separately")
	ErrUnknownAgent   = errors.New("unknown acp client agent")
)
View Source
var ErrSessionNotFound = errors.New("acp client session not found")

Functions

This section is empty.

Types

type AgentSpec

type AgentSpec struct {
	Name    string   `json:"name"`
	Command string   `json:"command"`
	Args    []string `json:"args,omitempty"`
	EnvKeys []string `json:"envKeys,omitempty"`
}

func (AgentSpec) Fingerprint

func (s AgentSpec) Fingerprint() string

func (AgentSpec) Validate

func (s AgentSpec) Validate() error

type Callbacks

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

func NewCallbacks

func NewCallbacks(opts RunOptions) *Callbacks

func (*Callbacks) Cwd

func (c *Callbacks) Cwd() string

func (*Callbacks) Reset

func (c *Callbacks) Reset()

func (*Callbacks) SessionUpdate

func (c *Callbacks) SessionUpdate(ctx context.Context, n acpsdk.SessionNotification) error

func (*Callbacks) Snapshot

func (c *Callbacks) Snapshot() ([]acpsdk.SessionNotification, string)

func (*Callbacks) UpdateCount

func (c *Callbacks) UpdateCount() int

func (*Callbacks) WaitForUpdate

func (c *Callbacks) WaitForUpdate(ctx context.Context, previous int)

type CancelRequest

type CancelRequest struct {
	SessionID   string    `json:"sessionId"`
	RequestedAt time.Time `json:"requestedAt"`
}

type Client

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

func NewInProcessClient

func NewInProcessClient(peerInput io.Writer, peerOutput io.Reader, opts RunOptions) *Client

func Start

func Start(ctx context.Context, spec AgentSpec, opts RunOptions) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) RunPrompt

func (c *Client) RunPrompt(ctx context.Context, prompt string) (Result, error)

type OwnerLock

type OwnerLock struct {
	SessionID          string    `json:"sessionId"`
	PID                int       `json:"pid"`
	CommandFingerprint string    `json:"commandFingerprint"`
	StartedAt          time.Time `json:"startedAt"`
}

type PendingPrompt

type PendingPrompt struct {
	ID         string     `json:"id"`
	Prompt     string     `json:"prompt"`
	Status     string     `json:"status"`
	CreatedAt  time.Time  `json:"createdAt"`
	CanceledAt *time.Time `json:"canceledAt,omitempty"`
}

type Registry

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

func DefaultRegistry

func DefaultRegistry() Registry

func NewRegistry

func NewRegistry(specs []AgentSpec) Registry

func (Registry) Lookup

func (r Registry) Lookup(name string) (AgentSpec, bool)

func (Registry) Resolve

func (r Registry) Resolve(opts RunOptions) (AgentSpec, error)

type Result

type Result struct {
	SessionID  acpsdk.SessionId
	StopReason acpsdk.StopReason
	Updates    []acpsdk.SessionNotification
	Text       string
	Stderr     string
	Duration   time.Duration
}

type RunOptions

type RunOptions struct {
	Agent           string
	Command         string
	Args            []string
	Cwd             string
	AllowWrites     bool
	Timeout         time.Duration
	SessionStarted  func(sessionID string) error
	CancelRequested func(sessionID string) bool
}

type SessionRecord

type SessionRecord struct {
	ID                 string         `json:"id"`
	Agent              string         `json:"agent"`
	CommandFingerprint string         `json:"commandFingerprint"`
	Cwd                string         `json:"cwd"`
	Status             string         `json:"status"`
	CreatedAt          time.Time      `json:"createdAt"`
	UpdatedAt          time.Time      `json:"updatedAt"`
	LastStopReason     string         `json:"lastStopReason,omitempty"`
	Summary            string         `json:"summary,omitempty"`
	Turns              []TurnSummary  `json:"turns,omitempty"`
	PendingPrompt      *PendingPrompt `json:"pendingPrompt,omitempty"`
}

type Store

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

func NewDefaultStore

func NewDefaultStore() (*Store, error)

func NewStore

func NewStore(path string) *Store

func (*Store) CancelRequest

func (s *Store) CancelRequest(id string) (CancelRequest, error)

func (*Store) ClearOwner

func (s *Store) ClearOwner(id string) error

func (*Store) Get

func (s *Store) Get(id string) (SessionRecord, error)

func (*Store) List

func (s *Store) List() ([]SessionRecord, error)

func (*Store) MarkPendingCanceled

func (s *Store) MarkPendingCanceled(id string, when time.Time) error

func (*Store) Owner

func (s *Store) Owner(id string) (OwnerLock, error)

func (*Store) Path

func (s *Store) Path() string

func (*Store) RequestCancel

func (s *Store) RequestCancel(id string, when time.Time) error

func (*Store) Upsert

func (s *Store) Upsert(rec SessionRecord) error

func (*Store) WriteOwner

func (s *Store) WriteOwner(owner OwnerLock) error

type TurnSummary

type TurnSummary struct {
	Prompt     string    `json:"prompt"`
	Response   string    `json:"response"`
	StopReason string    `json:"stopReason"`
	CreatedAt  time.Time `json:"createdAt"`
}

Jump to

Keyboard shortcuts

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