Documentation
¶
Index ¶
- Constants
- Variables
- func ExportSession(store *Store, id, outputPath string, opts ExportOptions) error
- type ActionResult
- type ActionRunOptions
- type ActionRunner
- type AgentSpec
- type Archive
- type ArchiveHistoryEvent
- type ArchiveSession
- type Callbacks
- func (*Callbacks) CreateTerminal(context.Context, acpsdk.CreateTerminalRequest) (acpsdk.CreateTerminalResponse, error)
- func (c *Callbacks) Cwd() string
- func (*Callbacks) KillTerminalCommand(context.Context, acpsdk.KillTerminalCommandRequest) (acpsdk.KillTerminalCommandResponse, error)
- func (c *Callbacks) ReadTextFile(_ context.Context, p acpsdk.ReadTextFileRequest) (acpsdk.ReadTextFileResponse, error)
- func (*Callbacks) ReleaseTerminal(context.Context, acpsdk.ReleaseTerminalRequest) (acpsdk.ReleaseTerminalResponse, error)
- func (*Callbacks) RequestPermission(_ context.Context, p acpsdk.RequestPermissionRequest) (acpsdk.RequestPermissionResponse, error)
- func (c *Callbacks) Reset()
- func (c *Callbacks) SessionUpdate(ctx context.Context, n acpsdk.SessionNotification) error
- func (c *Callbacks) Snapshot() ([]acpsdk.SessionNotification, string)
- func (*Callbacks) TerminalOutput(context.Context, acpsdk.TerminalOutputRequest) (acpsdk.TerminalOutputResponse, error)
- func (c *Callbacks) UpdateCount() int
- func (*Callbacks) WaitForTerminalExit(context.Context, acpsdk.WaitForTerminalExitRequest) (acpsdk.WaitForTerminalExitResponse, error)
- func (c *Callbacks) WaitForUpdate(ctx context.Context, previous int)
- func (c *Callbacks) WriteTextFile(_ context.Context, p acpsdk.WriteTextFileRequest) (acpsdk.WriteTextFileResponse, error)
- type CancelRequest
- type Client
- type CompareAgent
- type CompareOptions
- type CompareRow
- type CompareRunner
- type DrainOptions
- type DrainPromptRunner
- type DrainResult
- type ExportOptions
- type FlowDefinition
- type FlowEdge
- type FlowNode
- type FlowPromptRunner
- type FlowRunOptions
- type FlowRunResult
- type FlowRunState
- type FlowRunStore
- type FlowStepRecord
- type ImportOptions
- type OwnerLock
- type PendingPrompt
- type QueuedPrompt
- type Registry
- type Result
- type RunOptions
- type SessionRecord
- type SessionRunner
- type Store
- func (s *Store) AcquireOwner(owner OwnerLock) error
- func (s *Store) AppendQueuedPrompt(rec SessionRecord, prompt QueuedPrompt) (SessionRecord, error)
- func (s *Store) CancelPendingQueue(id string, when time.Time) (int, error)
- func (s *Store) CancelRequest(id string) (CancelRequest, error)
- func (s *Store) ClearOwner(id string) error
- func (s *Store) Get(id string) (SessionRecord, error)
- func (s *Store) List() ([]SessionRecord, error)
- func (s *Store) MarkPendingCanceled(id string, when time.Time) error
- func (s *Store) MarkQueueCompleted(id, queueID, response, stopReason string, when time.Time) error
- func (s *Store) MarkQueueFailed(id, queueID, message string, when time.Time) error
- func (s *Store) MarkQueueRunning(id, queueID string, when time.Time) error
- func (s *Store) NextQueuedPrompt(id string) (QueuedPrompt, bool, error)
- func (s *Store) Owner(id string) (OwnerLock, error)
- func (s *Store) Path() string
- func (s *Store) RecoverStaleQueue(id string, when time.Time) (int, error)
- func (s *Store) RequestCancel(id string, when time.Time) error
- func (s *Store) Upsert(rec SessionRecord) error
- func (s *Store) WriteOwner(owner OwnerLock) error
- type TurnSummary
- type WatchCycle
- type WatchOptions
- type WatchResult
Constants ¶
View Source
const ( FlowNodeTypeACP = "acp" FlowNodeTypeAction = "action" FlowNodeTypeCompute = "compute" 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" )
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 ( 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")
View Source
var ErrInvalidFlowDefinition = errors.New("invalid acp client flow definition")
Functions ¶
func ExportSession ¶ added in v0.20.0
func ExportSession(store *Store, id, outputPath string, opts ExportOptions) error
Types ¶
type ActionResult ¶ added in v0.23.0
type ActionRunOptions ¶ added in v0.23.0
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 ¶
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"`
}
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 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 Callbacks ¶
type Callbacks struct {
// contains filtered or unexported fields
}
func NewCallbacks ¶
func NewCallbacks(opts RunOptions) *Callbacks
func (*Callbacks) CreateTerminal ¶
func (*Callbacks) CreateTerminal(context.Context, acpsdk.CreateTerminalRequest) (acpsdk.CreateTerminalResponse, error)
func (*Callbacks) KillTerminalCommand ¶
func (*Callbacks) KillTerminalCommand(context.Context, acpsdk.KillTerminalCommandRequest) (acpsdk.KillTerminalCommandResponse, error)
func (*Callbacks) ReadTextFile ¶
func (c *Callbacks) ReadTextFile(_ context.Context, p acpsdk.ReadTextFileRequest) (acpsdk.ReadTextFileResponse, error)
func (*Callbacks) ReleaseTerminal ¶
func (*Callbacks) ReleaseTerminal(context.Context, acpsdk.ReleaseTerminalRequest) (acpsdk.ReleaseTerminalResponse, error)
func (*Callbacks) RequestPermission ¶
func (*Callbacks) RequestPermission(_ context.Context, p acpsdk.RequestPermissionRequest) (acpsdk.RequestPermissionResponse, error)
func (*Callbacks) SessionUpdate ¶
func (*Callbacks) TerminalOutput ¶
func (*Callbacks) TerminalOutput(context.Context, acpsdk.TerminalOutputRequest) (acpsdk.TerminalOutputResponse, error)
func (*Callbacks) UpdateCount ¶
func (*Callbacks) WaitForTerminalExit ¶
func (*Callbacks) WaitForTerminalExit(context.Context, acpsdk.WaitForTerminalExitRequest) (acpsdk.WaitForTerminalExitResponse, error)
func (*Callbacks) WaitForUpdate ¶
func (*Callbacks) WriteTextFile ¶
func (c *Callbacks) WriteTextFile(_ context.Context, p acpsdk.WriteTextFileRequest) (acpsdk.WriteTextFileResponse, error)
type CancelRequest ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewInProcessClient ¶
func (*Client) StartSession ¶ added in v0.19.0
type CompareAgent ¶ added in v0.20.0
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"`
}
func Compare ¶ added in v0.20.0
func Compare(ctx context.Context, agents []CompareAgent, prompt string, opts CompareOptions) ([]CompareRow, error)
type CompareRunner ¶ added in v0.20.0
type DrainOptions ¶ added in v0.19.0
type DrainPromptRunner ¶ added in v0.19.0
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 ExportOptions ¶ added in v0.20.0
type FlowDefinition ¶ added in v0.20.0
type FlowDefinition struct {
FormatVersion int `json:"format_version"`
Name string `json:"name,omitempty"`
Requires []string `json:"requires,omitempty"`
StartAt string `json:"start_at"`
Nodes []FlowNode `json:"nodes"`
Edges []FlowEdge `json:"edges,omitempty"`
}
func LoadFlowDefinition ¶ added in v0.20.0
func LoadFlowDefinition(path string) (FlowDefinition, error)
func (FlowDefinition) Validate ¶ added in v0.20.0
func (def FlowDefinition) Validate() error
type FlowNode ¶ added in v0.20.0
type FlowNode struct {
ID string `json:"id"`
Type string `json:"type"`
Prompt string `json:"prompt,omitempty"`
Agent string `json:"agent,omitempty"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Session string `json:"session,omitempty"`
Cwd string `json:"cwd,omitempty"`
Env map[string]string `json:"env,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
Value json.RawMessage `json:"value,omitempty"`
Select string `json:"select,omitempty"`
}
type FlowPromptRunner ¶ added in v0.20.0
type FlowRunOptions ¶ added in v0.20.0
type FlowRunOptions struct {
RunID string
RunRoot string
Cwd string
DefaultAgent string
DefaultCommand string
DefaultArgs []string
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) Dir ¶ added in v0.20.0
func (s *FlowRunStore) Dir() string
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) 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 ImportOptions ¶ added in v0.20.0
type PendingPrompt ¶
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 ¶
type Result ¶
type Result struct {
SessionID acpsdk.SessionId
StopReason acpsdk.StopReason
Updates []acpsdk.SessionNotification
Text string
Stderr string
Duration time.Duration
}
type RunOptions ¶
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) 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 (*Store) AcquireOwner ¶ added in v0.19.0
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 (*Store) CancelRequest ¶
func (s *Store) CancelRequest(id string) (CancelRequest, error)
func (*Store) ClearOwner ¶
func (*Store) List ¶
func (s *Store) List() ([]SessionRecord, error)
func (*Store) MarkPendingCanceled ¶
func (*Store) MarkQueueCompleted ¶ added in v0.19.0
func (*Store) MarkQueueFailed ¶ added in v0.19.0
func (*Store) MarkQueueRunning ¶ added in v0.19.0
func (*Store) NextQueuedPrompt ¶ added in v0.19.0
func (s *Store) NextQueuedPrompt(id string) (QueuedPrompt, bool, error)
func (*Store) RecoverStaleQueue ¶ added in v0.19.0
func (*Store) Upsert ¶
func (s *Store) Upsert(rec SessionRecord) error
func (*Store) WriteOwner ¶
type TurnSummary ¶
type WatchCycle ¶ added in v0.23.0
type WatchOptions ¶ added in v0.23.0
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)) (WatchResult, error)
Click to show internal directories.
Click to hide internal directories.