acpclient

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 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"

	QueuePromptStatusPending   = "pending"
	QueuePromptStatusRunning   = "running"
	QueuePromptStatusCompleted = "completed"
	QueuePromptStatusCanceled  = "canceled"
	QueuePromptStatusFailed    = "failed"
)

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")
	ErrQueuePromptNotFound = errors.New("acp client queue prompt not found")
	ErrInvalidOwnerLock    = errors.New("acp client owner lock is invalid")
)
View Source
var ErrDrainBusy = errors.New("acp client session is already being drained")

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)

func (*Client) StartSession added in v0.19.0

func (c *Client) StartSession(ctx context.Context, existingSessionID string) (*SessionRunner, error)

type DrainOptions added in v0.19.0

type DrainOptions struct {
	Max         int
	Now         func() time.Time
	StartRunner func(context.Context, AgentSpec, RunOptions, string) (DrainPromptRunner, func() error, error)
}

type DrainPromptRunner added in v0.19.0

type DrainPromptRunner interface {
	SessionID() acpsdk.SessionId
	Prompt(context.Context, string) (Result, error)
}

type DrainResult added in v0.19.0

type DrainResult struct {
	SessionID    string
	ACPSessionID string
	Processed    int
	Completed    int
	Failed       int
	Canceled     int
	Remaining    int
}

func DrainQueue added in v0.19.0

func DrainQueue(ctx context.Context, store *Store, spec AgentSpec, opts RunOptions, sessionID string, drainOpts DrainOptions) (DrainResult, 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 QueuedPrompt added in v0.19.0

type QueuedPrompt struct {
	ID          string     `json:"id"`
	Prompt      string     `json:"prompt"`
	Status      string     `json:"status"`
	CreatedAt   time.Time  `json:"createdAt"`
	StartedAt   *time.Time `json:"startedAt,omitempty"`
	CompletedAt *time.Time `json:"completedAt,omitempty"`
	CanceledAt  *time.Time `json:"canceledAt,omitempty"`
	Response    string     `json:"response,omitempty"`
	StopReason  string     `json:"stopReason,omitempty"`
	Error       string     `json:"error,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"`
	ACPSessionID       string         `json:"acpSessionId,omitempty"`
	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"`
	PromptQueue        []QueuedPrompt `json:"promptQueue,omitempty"`
}

type SessionRunner added in v0.19.0

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

func (*SessionRunner) Prompt added in v0.19.0

func (r *SessionRunner) Prompt(ctx context.Context, prompt string) (Result, error)

func (*SessionRunner) SessionID added in v0.19.0

func (r *SessionRunner) SessionID() acpsdk.SessionId

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) AcquireOwner added in v0.19.0

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

func (*Store) AppendQueuedPrompt added in v0.19.0

func (s *Store) AppendQueuedPrompt(rec SessionRecord, prompt QueuedPrompt) (SessionRecord, error)

func (*Store) CancelPendingQueue added in v0.19.0

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

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) MarkQueueCompleted added in v0.19.0

func (s *Store) MarkQueueCompleted(id, queueID, response, stopReason string, when time.Time) error

func (*Store) MarkQueueFailed added in v0.19.0

func (s *Store) MarkQueueFailed(id, queueID, message string, when time.Time) error

func (*Store) MarkQueueRunning added in v0.19.0

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

func (*Store) NextQueuedPrompt added in v0.19.0

func (s *Store) NextQueuedPrompt(id string) (QueuedPrompt, bool, error)

func (*Store) Owner

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

func (*Store) Path

func (s *Store) Path() string

func (*Store) RecoverStaleQueue added in v0.19.0

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

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