acpclient

package
v0.30.33 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackgroundPolicyVersion = 1

	BackgroundStateRunning  = "running"
	BackgroundStateBlocked  = "blocked"
	BackgroundStateError    = "error"
	BackgroundStateDisabled = "disabled"

	BackgroundOutcomeStarted           = "started"
	BackgroundOutcomeResumed           = "resumed"
	BackgroundOutcomeStopped           = "stopped"
	BackgroundOutcomeProfileUntrusted  = "profile_untrusted"
	BackgroundOutcomeProfileDrift      = "profile_drift"
	BackgroundOutcomeProfileMissing    = "profile_missing"
	BackgroundOutcomeSessionMissing    = "session_missing"
	BackgroundOutcomePolicyInvalid     = "policy_invalid"
	BackgroundOutcomeWorkerError       = "worker_error"
	BackgroundOutcomeWorkerPanic       = "worker_panic"
	BackgroundOutcomeCompleted         = "completed"
	BackgroundOutcomeStateWriteFailed  = "state_write_failed"
	BackgroundOutcomeAuditAppendFailed = "audit_append_failed"
)
View Source
const (
	BackgroundAuditStart  = "start"
	BackgroundAuditResume = "resume"
	BackgroundAuditBlock  = "block"
	BackgroundAuditError  = "error"
	BackgroundAuditStop   = "stop"
)
View Source
const (
	FlowNodeTypeACP        = flowjson.NodeTypeACP
	FlowNodeTypeAction     = flowjson.NodeTypeAction
	FlowNodeTypeCompute    = flowjson.NodeTypeCompute
	FlowNodeTypeCheckpoint = flowjson.NodeTypeCheckpoint

	FlowRunStatusRunning   = "running"
	FlowRunStatusCompleted = "completed"
	FlowRunStatusFailed    = "failed"

	FlowStepStatusCompleted = "completed"
	FlowStepStatusFailed    = "failed"
)
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"

	OwnerKindExecution = "execution"
	OwnerKindSnapshot  = "snapshot"
)
View Source
const FlowReplayBundleSchema = acpx.SchemaFlowRunBundleV1

Variables

View Source
var (
	ErrSessionActive             = errors.New("acp client session is active")
	ErrSessionArchiveCollision   = errors.New("acp client archive destination session exists")
	ErrUnsupportedArchiveVersion = errors.New("unsupported acp client archive format version")
	ErrInvalidSessionArchive     = errors.New("invalid acp client archive")
)
View Source
var (
	ErrBackgroundPolicyNotFound          = errors.New("acp background policy not found")
	ErrBackgroundPolicyConflict          = errors.New("acp background policy conflicts with active worker")
	ErrBackgroundAcknowledgementRequired = errors.New("acp background unattended execution acknowledgement is required")
	ErrBackgroundProfileUntrusted        = errors.New("acp background profile trust is invalid")
	ErrBackgroundProfileIneligible       = errors.New("acp background profile is ineligible")
	ErrBackgroundManagerClosed           = errors.New("acp background manager is closed")
	ErrBackgroundTransitionBusy          = errors.New("acp background session transition is busy")
	ErrBackgroundPersistenceDegraded     = errors.New("acp background persistence is degraded")
)
View Source
var (
	ErrPathOutsideCWD = errors.New("acp client path is outside cwd")
	ErrWritesDisabled = errors.New("acp client filesystem writes are disabled")
)
View Source
var (
	ErrInvalidJSONRPCMessage = errors.New("invalid acp json-rpc message")
	ErrRawHistoryUnavailable = errors.New("acp client raw event history unavailable")
)
View Source
var (
	ErrProfileNotFound       = errors.New("acp client profile not found")
	ErrProfileShadowsBuiltin = errors.New("acp client profile shadows built-in agent")
)
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")
	ErrCancelRequested = errors.New("acp client cancellation requested")
)
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")
	ErrOwnerNotCancelable          = errors.New("acp client owner does not represent active execution")
	ErrOwnerLeaseBusy              = errors.New("acp client owner lease is held")
	ErrStoreProcessLockUnsupported = errors.New("acp client cross-process store locks are unsupported")
	ErrStoreCommitUnconfirmed      = errors.New("acp client store commit completed but durability confirmation failed")
)
View Source
var ErrCancellationTransportUnsupported = errors.New("acp client cancellation requires closable in-process transports")
View Source
var ErrDrainBusy = errors.New("acp client session is already being drained")
View Source
var ErrInvalidFlowDefinition = flowjson.ErrInvalidDefinition
View Source
var ErrStoreLockPathUnsafe = errors.New("acp client store lock path is unsafe")

Functions

func ExportSession added in v0.20.0

func ExportSession(store *Store, id, outputPath string, opts ExportOptions) (err error)

func ValidateJSONRPCMessage added in v0.25.0

func ValidateJSONRPCMessage(message json.RawMessage) error

Types

type ActionResult added in v0.23.0

type ActionResult struct {
	ExitCode int
	Stdout   string
	Stderr   string
	Duration time.Duration
}

type ActionRunOptions added in v0.23.0

type ActionRunOptions struct {
	Command string
	Args    []string
	Cwd     string
	Env     map[string]string
	Input   json.RawMessage
}

type ActionRunner added in v0.23.0

type ActionRunner interface {
	RunAction(context.Context, ActionRunOptions) (ActionResult, error)
}

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 Archive added in v0.20.0

type Archive struct {
	FormatVersion  int                   `json:"format_version"`
	ExportedAt     string                `json:"exported_at"`
	ExportedBy     string                `json:"exported_by"`
	Session        ArchiveSession        `json:"session"`
	History        []ArchiveHistoryEvent `json:"history,omitempty"`
	SummaryHistory []ArchiveHistoryEvent `json:"summary_history,omitempty"`
	RawHistory     []json.RawMessage     `json:"-"`
}

func (*Archive) UnmarshalJSON added in v0.25.0

func (a *Archive) UnmarshalJSON(b []byte) error

type ArchiveHistoryEvent added in v0.20.0

type ArchiveHistoryEvent struct {
	Kind       string    `json:"kind"`
	ID         string    `json:"id,omitempty"`
	Prompt     string    `json:"prompt,omitempty"`
	Response   string    `json:"response,omitempty"`
	Status     string    `json:"status,omitempty"`
	StopReason string    `json:"stop_reason,omitempty"`
	CreatedAt  time.Time `json:"created_at,omitzero"`
	UpdatedAt  time.Time `json:"updated_at,omitzero"`
}

type ArchiveHistoryMode added in v0.25.0

type ArchiveHistoryMode string
const (
	ArchiveHistoryModeSummary ArchiveHistoryMode = "summary"
	ArchiveHistoryModeRaw     ArchiveHistoryMode = "raw"
	ArchiveHistoryModeBoth    ArchiveHistoryMode = "both"
)

type ArchiveSession added in v0.20.0

type ArchiveSession struct {
	RecordID    string        `json:"record_id"`
	Name        *string       `json:"name,omitempty"`
	Agent       string        `json:"agent"`
	AgentName   string        `json:"agent_name,omitempty"`
	CWDRelative string        `json:"cwd_relative"`
	CWDOriginal string        `json:"cwd_original"`
	CreatedAt   string        `json:"created_at"`
	UpdatedAt   string        `json:"updated_at"`
	State       SessionRecord `json:"state"`
}

type BackgroundAudit added in v0.30.30

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

func NewBackgroundAudit added in v0.30.30

func NewBackgroundAudit(path string) *BackgroundAudit

func NewDefaultBackgroundAudit added in v0.30.30

func NewDefaultBackgroundAudit() (*BackgroundAudit, error)

func (*BackgroundAudit) Append added in v0.30.30

func (a *BackgroundAudit) Append(record BackgroundAuditRecord) error

func (*BackgroundAudit) Path added in v0.30.30

func (a *BackgroundAudit) Path() string

func (*BackgroundAudit) Read added in v0.30.30

func (a *BackgroundAudit) Read() (records []BackgroundAuditRecord, err error)

type BackgroundAuditRecord added in v0.30.30

type BackgroundAuditRecord struct {
	RecordID       string    `json:"recordId"`
	At             time.Time `json:"at"`
	Action         string    `json:"action"`
	SessionID      string    `json:"sessionId"`
	Profile        string    `json:"profile"`
	DescriptorHash string    `json:"descriptorHash"`
	Outcome        string    `json:"outcome"`
}

type BackgroundManager added in v0.30.30

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

func NewBackgroundManager added in v0.30.30

func NewBackgroundManager(sessions *Store, store *BackgroundStore, audit *BackgroundAudit, opts BackgroundManagerOptions) *BackgroundManager

func NewDefaultBackgroundManager added in v0.30.30

func NewDefaultBackgroundManager(ctx context.Context, sessions *Store, profiles *ProfileStore, registry Registry) (*BackgroundManager, error)

func (*BackgroundManager) Get added in v0.30.30

func (m *BackgroundManager) Get(sessionID string) (BackgroundStatus, error)

func (*BackgroundManager) List added in v0.30.30

func (m *BackgroundManager) List() ([]BackgroundStatus, error)

func (*BackgroundManager) Resume added in v0.30.30

func (m *BackgroundManager) Resume() error

func (*BackgroundManager) Shutdown added in v0.30.30

func (m *BackgroundManager) Shutdown()

func (*BackgroundManager) Start added in v0.30.30

func (m *BackgroundManager) Start(sessionID, profile string, acknowledged bool) (status BackgroundStatus, err error)

func (*BackgroundManager) Stop added in v0.30.30

func (m *BackgroundManager) Stop(sessionID string) (status BackgroundStatus, err error)

type BackgroundManagerOptions added in v0.30.30

type BackgroundManagerOptions struct {
	Context      context.Context
	Now          func() time.Time
	Resolver     BackgroundProfileResolver
	Watcher      BackgroundWatcher
	WatchOptions WatchOptions
}

type BackgroundPolicy added in v0.30.30

type BackgroundPolicy struct {
	SessionID           string    `json:"sessionId"`
	Profile             string    `json:"profile"`
	DescriptorHash      string    `json:"descriptorHash"`
	PolicyVersion       int       `json:"policyVersion"`
	AcknowledgedAt      time.Time `json:"acknowledgedAt"`
	Enabled             bool      `json:"enabled"`
	State               string    `json:"state"`
	Outcome             string    `json:"outcome"`
	PersistenceDegraded bool      `json:"persistenceDegraded,omitzero"`
	StartedAt           time.Time `json:"startedAt,omitzero"`
	UpdatedAt           time.Time `json:"updatedAt"`
}

type BackgroundProfileResolver added in v0.30.30

type BackgroundProfileResolver func(string) (ResolvedBackgroundProfile, error)

func NewBackgroundProfileResolver added in v0.30.30

func NewBackgroundProfileResolver(registry Registry, profiles *ProfileStore) BackgroundProfileResolver

type BackgroundStatus added in v0.30.30

type BackgroundStatus struct {
	SessionID           string
	Profile             string
	DescriptorHash      string
	PolicyVersion       int
	AcknowledgedAt      time.Time
	Enabled             bool
	State               string
	Outcome             string
	PersistenceDegraded bool
	StartedAt           time.Time
	UpdatedAt           time.Time
}

type BackgroundStore added in v0.30.30

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

func NewBackgroundStore added in v0.30.30

func NewBackgroundStore(path string) *BackgroundStore

func NewDefaultBackgroundStore added in v0.30.30

func NewDefaultBackgroundStore() (*BackgroundStore, error)

func (*BackgroundStore) Get added in v0.30.30

func (s *BackgroundStore) Get(sessionID string) (BackgroundPolicy, error)

func (*BackgroundStore) List added in v0.30.30

func (s *BackgroundStore) List() ([]BackgroundPolicy, error)

func (*BackgroundStore) Path added in v0.30.30

func (s *BackgroundStore) Path() string

func (*BackgroundStore) Upsert added in v0.30.30

func (s *BackgroundStore) Upsert(policy BackgroundPolicy) error

type BackgroundWatcher added in v0.30.30

type BackgroundWatcher func(context.Context, *Store, AgentSpec, RunOptions, string, WatchOptions, func(WatchCycle)) (WatchResult, 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) EventSnapshot added in v0.25.0

func (c *Callbacks) EventSnapshot() []EventLogLine

func (*Callbacks) RecordEvent added in v0.25.0

func (c *Callbacks) RecordEvent(direction EventDirection, message json.RawMessage) error

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 CompareAgent added in v0.20.0

type CompareAgent struct {
	Name string
	Spec AgentSpec
}

type CompareOptions added in v0.20.0

type CompareOptions struct {
	Cwd     string
	Timeout time.Duration
	Runner  CompareRunner
}

type CompareRow added in v0.20.0

type CompareRow struct {
	Agent      string         `json:"agent"`
	Status     string         `json:"status"`
	WallMS     int64          `json:"wall_ms"`
	StopReason string         `json:"stop_reason,omitempty"`
	Final      string         `json:"final,omitempty"`
	Error      string         `json:"error,omitempty"`
	Events     []EventLogLine `json:"-"`
}

func Compare added in v0.20.0

func Compare(ctx context.Context, agents []CompareAgent, prompt string, opts CompareOptions) ([]CompareRow, error)

type CompareRun added in v0.25.0

type CompareRun struct {
	RunID        string       `json:"run_id"`
	RunDir       string       `json:"run_dir"`
	Status       string       `json:"status"`
	PromptDigest string       `json:"prompt_digest,omitempty"`
	StartedAt    time.Time    `json:"started_at,omitzero"`
	FinishedAt   time.Time    `json:"finished_at,omitzero"`
	Rows         []CompareRow `json:"rows"`
}

type CompareRunBundle added in v0.25.0

type CompareRunBundle struct {
	CompareRun
	AgentDirs map[string]string `json:"-"`
}

type CompareRunStore added in v0.25.0

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

func NewCompareRunStore added in v0.25.0

func NewCompareRunStore(root string) *CompareRunStore

func (*CompareRunStore) Save added in v0.25.0

type CompareRunner added in v0.20.0

type CompareRunner interface {
	RunPrompt(context.Context, AgentSpec, RunOptions, string) (Result, 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) (result DrainResult, err error)

type EventDirection added in v0.25.0

type EventDirection string
const (
	EventDirectionOutbound EventDirection = "outbound"
	EventDirectionInbound  EventDirection = "inbound"
)

type EventLogLine added in v0.25.0

type EventLogLine struct {
	Seq       int             `json:"seq"`
	At        time.Time       `json:"at,omitzero"`
	Direction EventDirection  `json:"direction"`
	Message   json.RawMessage `json:"message"`
}

type EventLogMetadata added in v0.25.0

type EventLogMetadata struct {
	SessionID string `json:"session_id"`
	Path      string `json:"path"`
	Exists    bool   `json:"exists"`
	Count     int    `json:"count"`
}

type ExportOptions added in v0.20.0

type ExportOptions struct {
	HomeDir     string
	Now         func() time.Time
	HistoryMode ArchiveHistoryMode
}

type FlowDefinition added in v0.20.0

type FlowDefinition = flowjson.Definition

func LoadFlowDefinition added in v0.20.0

func LoadFlowDefinition(path string) (FlowDefinition, error)

type FlowEdge added in v0.20.0

type FlowEdge = flowjson.Edge

type FlowNode added in v0.20.0

type FlowNode = flowjson.Node

type FlowPromptRunner added in v0.20.0

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

type FlowReplayArtifactRef added in v0.25.0

type FlowReplayArtifactRef struct {
	Kind   string `json:"kind"`
	SHA256 string `json:"sha256"`
	Path   string `json:"path"`
}

type FlowReplayProjections added in v0.25.0

type FlowReplayProjections struct {
	Run   string `json:"run"`
	Live  string `json:"live"`
	Steps string `json:"steps"`
}

type FlowReplaySession added in v0.25.0

type FlowReplaySession struct {
	Handle    string `json:"handle"`
	SessionID string `json:"session_id,omitempty"`
	Events    string `json:"events"`
}

type FlowReplayStep added in v0.25.0

type FlowReplayStep struct {
	NodeID         string                `json:"node_id"`
	Type           string                `json:"type"`
	Status         string                `json:"status"`
	Error          string                `json:"error,omitempty"`
	Output         string                `json:"output,omitempty"`
	OutputArtifact FlowReplayArtifactRef `json:"output_artifact,omitzero"`
	StdoutArtifact FlowReplayArtifactRef `json:"stdout_artifact,omitzero"`
	StderrArtifact FlowReplayArtifactRef `json:"stderr_artifact,omitzero"`
	PromptArtifact FlowReplayArtifactRef `json:"prompt_artifact,omitzero"`
}

type FlowReplaySummary added in v0.25.0

type FlowReplaySummary struct {
	RunID        string `json:"run_id"`
	Status       string `json:"status"`
	ManifestPath string `json:"manifest_path"`
	StepCount    int    `json:"step_count"`
	TraceCount   int    `json:"trace_count"`
	SessionCount int    `json:"session_count"`
}

func LoadFlowReplaySummary added in v0.25.0

func LoadFlowReplaySummary(runDir string) (FlowReplaySummary, error)

type FlowRunManifest added in v0.25.0

type FlowRunManifest struct {
	Schema      string                  `json:"schema"`
	RunID       string                  `json:"run_id"`
	Status      string                  `json:"status"`
	Definition  string                  `json:"definition"`
	Input       string                  `json:"input"`
	State       string                  `json:"state"`
	Trace       string                  `json:"trace"`
	Projections FlowReplayProjections   `json:"projections"`
	Steps       []FlowReplayStep        `json:"steps"`
	Sessions    []FlowReplaySession     `json:"sessions,omitempty"`
	Artifacts   []FlowReplayArtifactRef `json:"artifacts,omitempty"`
}

type FlowRunOptions added in v0.20.0

type FlowRunOptions struct {
	RunID              string
	RunRoot            string
	Cwd                string
	DefaultAgent       string
	DefaultCommand     string
	DefaultArgs        []string
	Registry           Registry
	AllowedPermissions []string
	ActionOutputLimit  int
	ActionRunner       ActionRunner
	StartRunner        func(context.Context, AgentSpec, RunOptions, string) (FlowPromptRunner, func() error, error)
}

type FlowRunResult added in v0.20.0

type FlowRunResult struct {
	RunID   string                     `json:"run_id"`
	Status  string                     `json:"status"`
	RunDir  string                     `json:"run_dir,omitempty"`
	Outputs map[string]json.RawMessage `json:"outputs"`
	Steps   []FlowStepRecord           `json:"steps"`
}

func RunFlow added in v0.20.0

func RunFlow(ctx context.Context, def FlowDefinition, input map[string]any, opts FlowRunOptions) (FlowRunResult, error)

type FlowRunState added in v0.20.0

type FlowRunState struct {
	RunID  string           `json:"run_id"`
	Status string           `json:"status"`
	Steps  []FlowStepRecord `json:"steps"`
}

type FlowRunStore added in v0.20.0

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

func NewFlowRunStore added in v0.20.0

func NewFlowRunStore(rootDir, runID string) (*FlowRunStore, error)

func (*FlowRunStore) AppendTraceEvent added in v0.25.0

func (s *FlowRunStore) AppendTraceEvent(event acpx.TraceEvent) (err error)

func (*FlowRunStore) Dir added in v0.20.0

func (s *FlowRunStore) Dir() string

func (*FlowRunStore) WriteACPXManifest added in v0.27.0

func (s *FlowRunStore) WriteACPXManifest(manifest acpx.Manifest) error

func (*FlowRunStore) WriteArtifact added in v0.25.0

func (s *FlowRunStore) WriteArtifact(kind string, data []byte) (FlowReplayArtifactRef, error)

func (*FlowRunStore) WriteDefinition added in v0.20.0

func (s *FlowRunStore) WriteDefinition(def FlowDefinition) error

func (*FlowRunStore) WriteInput added in v0.20.0

func (s *FlowRunStore) WriteInput(input any) error

func (*FlowRunStore) WriteManifest added in v0.25.0

func (s *FlowRunStore) WriteManifest(manifest FlowRunManifest) error

func (*FlowRunStore) WriteProjection added in v0.25.0

func (s *FlowRunStore) WriteProjection(name string, value any) error

func (*FlowRunStore) WriteState added in v0.20.0

func (s *FlowRunStore) WriteState(state FlowRunState) error

func (*FlowRunStore) WriteStep added in v0.20.0

func (s *FlowRunStore) WriteStep(nodeID string, output json.RawMessage) error

type FlowStepRecord added in v0.20.0

type FlowStepRecord struct {
	NodeID string          `json:"node_id"`
	Type   string          `json:"type,omitempty"`
	Status string          `json:"status"`
	Output json.RawMessage `json:"output,omitempty"`
	Error  string          `json:"error,omitempty"`
}

type FlowSwitchEdge added in v0.27.0

type FlowSwitchEdge = flowjson.SwitchEdge

type FlowTraceEvent added in v0.25.0

type FlowTraceEvent struct {
	Seq      int       `json:"seq"`
	At       time.Time `json:"at"`
	Kind     string    `json:"kind"`
	NodeID   string    `json:"node_id"`
	Type     string    `json:"type"`
	Status   string    `json:"status"`
	Error    string    `json:"error,omitempty"`
	Output   string    `json:"output,omitempty"`
	Session  string    `json:"session,omitempty"`
	Artifact string    `json:"artifact,omitempty"`
}

type ImportOptions added in v0.20.0

type ImportOptions struct {
	SessionID          string
	Cwd                string
	HomeDir            string
	Agent              string
	CommandFingerprint string
}

type JSONRPCMessage added in v0.25.0

type JSONRPCMessage json.RawMessage

type OwnerLease added in v0.30.30

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

func (*OwnerLease) Release added in v0.30.30

func (l *OwnerLease) Release() error

type OwnerLock

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

func (OwnerLock) Cancelable added in v0.30.30

func (o OwnerLock) Cancelable() bool

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 Profile added in v0.24.0

type Profile struct {
	Name          string    `json:"name"`
	Spec          AgentSpec `json:"spec"`
	Cwd           string    `json:"cwd,omitempty"`
	SourceKind    string    `json:"sourceKind,omitempty"`
	SourceID      string    `json:"sourceId,omitempty"`
	Hash          string    `json:"hash"`
	Trusted       bool      `json:"trusted,omitempty"`
	CreatedAt     time.Time `json:"createdAt"`
	UpdatedAt     time.Time `json:"updatedAt"`
	PluginName    string    `json:"pluginName,omitempty"`
	PluginVersion string    `json:"pluginVersion,omitempty"`
}

func (Profile) DescriptorHash added in v0.24.0

func (p Profile) DescriptorHash() string

func (Profile) TrustValid added in v0.30.30

func (p Profile) TrustValid() bool

type ProfileStore added in v0.24.0

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

func NewDefaultProfileStore added in v0.24.0

func NewDefaultProfileStore() (*ProfileStore, error)

func NewProfileStore added in v0.24.0

func NewProfileStore(path string) *ProfileStore

func (*ProfileStore) Add added in v0.24.0

func (s *ProfileStore) Add(profile Profile) error

func (*ProfileStore) Get added in v0.24.0

func (s *ProfileStore) Get(name string) (Profile, error)

func (*ProfileStore) List added in v0.24.0

func (s *ProfileStore) List() ([]Profile, error)

func (*ProfileStore) Path added in v0.24.0

func (s *ProfileStore) Path() string

func (*ProfileStore) Remove added in v0.24.0

func (s *ProfileStore) Remove(name string) error

func (*ProfileStore) Trust added in v0.24.0

func (s *ProfileStore) Trust(name string) error

func (*ProfileStore) WithTrustedProfile added in v0.30.30

func (s *ProfileStore) WithTrustedProfile(name, pinnedHash string, callback func(Profile) error) error

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)

func (Registry) WithProfiles added in v0.24.0

func (r Registry) WithProfiles(profiles []Profile) (Registry, error)

type ResolvedBackgroundProfile added in v0.30.30

type ResolvedBackgroundProfile struct {
	Spec               AgentSpec
	Options            RunOptions
	DescriptorHash     string
	TrustValid         bool
	WithTrustedProfile func(string, func(Profile) error) error
}

type Result

type Result struct {
	SessionID  acpsdk.SessionId
	StopReason acpsdk.StopReason
	Updates    []acpsdk.SessionNotification
	Events     []EventLogLine
	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, error)
}

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"`
}

func ImportSession added in v0.20.0

func ImportSession(store *Store, archivePath string, opts ImportOptions) (SessionRecord, error)

type SessionRunner added in v0.19.0

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

func (*SessionRunner) LastEvents added in v0.25.0

func (r *SessionRunner) LastEvents() []EventLogLine

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) AcquireOwnerLease added in v0.30.30

func (s *Store) AcquireOwnerLease(owner OwnerLock) (*OwnerLease, error)

func (*Store) AppendEventLog added in v0.25.0

func (s *Store) AppendEventLog(id string, events []EventLogLine) (err 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) CheckCancellation added in v0.30.30

func (s *Store) CheckCancellation(id string) (bool, error)

CheckCancellation reads the session record, which is the cancellation authority. The legacy sidecar remains a best-effort compatibility projection.

func (*Store) CopyEventLog added in v0.25.0

func (s *Store) CopyEventLog(id, outputPath string) (err error)

func (*Store) EventLogMetadata added in v0.25.0

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

func (*Store) Get

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

func (*Store) InsertSession added in v0.30.30

func (s *Store) InsertSession(rec 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) MarkQueueCompletedWithEvents added in v0.30.30

func (s *Store) MarkQueueCompletedWithEvents(id, queueID, response, stopReason string, events []EventLogLine, 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) MarkSessionCompleted added in v0.30.30

func (s *Store) MarkSessionCompleted(rec SessionRecord, turn TurnSummary) error

func (*Store) MarkSessionCompletedWithEvents added in v0.30.30

func (s *Store) MarkSessionCompletedWithEvents(rec SessionRecord, turn TurnSummary, events []EventLogLine) error

func (*Store) MarkSessionStarted added in v0.30.30

func (s *Store) MarkSessionStarted(rec SessionRecord) 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) ReadEventLog added in v0.25.0

func (s *Store) ReadEventLog(id string) ([]EventLogLine, error)

func (*Store) ReconcileCancellationRequests added in v0.30.30

func (s *Store) ReconcileCancellationRequests() error

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) RequestCancelActiveExecution added in v0.30.30

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

func (*Store) Upsert

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

func (*Store) WriteEventLog added in v0.25.0

func (s *Store) WriteEventLog(id string, events []EventLogLine) error

type TurnSummary

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

type WatchCycle added in v0.23.0

type WatchCycle struct {
	SessionID     string
	ACPSessionID  string
	Cycle         int
	PendingBefore int
	Processed     int
	Completed     int
	Failed        int
	Canceled      int
	Remaining     int
	Idle          bool
	StartedAt     time.Time
	CompletedAt   time.Time
}

type WatchOptions added in v0.23.0

type WatchOptions struct {
	Interval      time.Duration
	MaxPerCycle   int
	MaxCycles     int
	StopWhenEmpty bool
	Now           func() time.Time
	Sleep         func(context.Context, time.Duration) error
	StartRunner   func(context.Context, AgentSpec, RunOptions, string) (DrainPromptRunner, func() error, error)
}

type WatchResult added in v0.23.0

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

func WatchQueue added in v0.23.0

func WatchQueue(ctx context.Context, store *Store, spec AgentSpec, opts RunOptions, sessionID string, watchOpts WatchOptions, onCycle func(WatchCycle)) (result WatchResult, err error)

Jump to

Keyboard shortcuts

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