Documentation
¶
Overview ¶
Package agent provides agent lifecycle management and orchestration.
Index ¶
- Variables
- func ClearState()
- func LoadState() (map[string]int, error)
- func RemoveAgentFromState(agentName string) error
- type LibClient
- func (c *LibClient) Close(ctx context.Context) error
- func (c *LibClient) GetProcess() *termexec.Process
- func (c *LibClient) Handler() http.Handler
- func (c *LibClient) Port() int
- func (c *LibClient) ReadScreen() string
- func (c *LibClient) SendMessage(content string) error
- func (c *LibClient) Start() error
- func (c *LibClient) WaitForCompletion(ctx context.Context, timeout time.Duration) error
- func (c *LibClient) WaitForStable(timeout time.Duration) error
- type LibClientConfig
- type Manager
- func (m *Manager) ExpandWithDependencies(agents []string) []string
- func (m *Manager) GetDependencyLevels(agents []string) [][]string
- func (m *Manager) GetRunningAgents() []*RunningAgent
- func (m *Manager) GetTransitiveDependencies(agentName string) []string
- func (m *Manager) RunAgent(ctx context.Context, name string) Result
- func (m *Manager) StopAll()
- func (m *Manager) TopologicalSort(agents []string) []string
- type Orchestrator
- type OrchestratorConfig
- type Result
- type RunningAgent
Constants ¶
This section is empty.
Variables ¶
var (
StateFile = filepath.Join(os.TempDir(), "pagent-state.json")
)
State file paths
Functions ¶
func RemoveAgentFromState ¶ added in v0.1.2
RemoveAgentFromState removes a specific agent from the state file
Types ¶
type LibClient ¶
type LibClient struct {
// contains filtered or unexported fields
}
LibClient provides direct library integration with agentapi instead of spawning the agentapi binary and communicating via HTTP
func NewLibClient ¶
func NewLibClient(ctx context.Context, cfg LibClientConfig) (*LibClient, error)
NewLibClient creates a new agentapi library client
func (*LibClient) GetProcess ¶
GetProcess returns the underlying termexec.Process for advanced usage
func (*LibClient) ReadScreen ¶
ReadScreen returns the current terminal screen content
func (*LibClient) SendMessage ¶
SendMessage sends a message to the agent
func (*LibClient) WaitForCompletion ¶
WaitForCompletion waits for the agent to finish processing a task
type LibClientConfig ¶
type LibClientConfig struct {
Port int
Verbose bool
AgentCmd string // e.g., "claude"
AgentArgs []string // additional args for the agent
TerminalWidth uint16
TerminalHeight uint16
}
LibClientConfig configures the library client
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages agent lifecycle
func NewManager ¶
NewManager creates a new agent manager
func NewManagerWithInputs ¶
func NewManagerWithInputs(cfg *config.Config, primaryFile string, inputFiles []string, inputDir string, verbose bool) *Manager
NewManagerWithInputs creates a manager with multiple input files
func (*Manager) ExpandWithDependencies ¶
ExpandWithDependencies takes a list of agents and returns the list expanded to include all transitive dependencies. The returned list is in dependency order.
func (*Manager) GetDependencyLevels ¶
GetDependencyLevels groups agents by dependency level for parallel execution. Level 0: agents with no dependencies Level 1: agents whose dependencies are all in level 0 Level N: agents whose dependencies are all in levels 0..N-1 Returns a slice of levels, where each level is a slice of agent names.
func (*Manager) GetRunningAgents ¶
func (m *Manager) GetRunningAgents() []*RunningAgent
GetRunningAgents returns currently running agents
func (*Manager) GetTransitiveDependencies ¶
GetTransitiveDependencies returns all dependencies for an agent, including transitive ones. This is useful for auto-including required agents when a user requests a specific agent.
func (*Manager) TopologicalSort ¶
TopologicalSort returns agents in dependency order
type Orchestrator ¶
type Orchestrator interface {
// RunAgent executes a single agent and returns the result.
RunAgent(ctx context.Context, name string) Result
// TopologicalSort returns agents in dependency order.
TopologicalSort(agents []string) []string
// GetDependencyLevels groups agents by dependency level for parallel execution.
// Level 0 agents have no dependencies, level 1 depends only on level 0, etc.
GetDependencyLevels(agents []string) [][]string
// ExpandWithDependencies takes a list of agents and returns the list expanded
// to include all transitive dependencies in dependency order.
ExpandWithDependencies(agents []string) []string
// GetTransitiveDependencies returns all dependencies for an agent, including transitive ones.
GetTransitiveDependencies(agentName string) []string
// StopAll stops all running agents.
StopAll()
// GetRunningAgents returns currently running agents.
GetRunningAgents() []*RunningAgent
}
Orchestrator defines the interface for agent orchestration. This abstraction enables: - Unit testing with mock implementations - Alternative implementations (e.g., remote agent execution) - Dependency injection in calling code
type OrchestratorConfig ¶
type OrchestratorConfig struct {
// Config is the pagent configuration
Config interface {
GetAgentNames() []string
GetDependencies(name string) []string
}
// PrimaryFile is the main input file
PrimaryFile string
// InputFiles is the list of all input files
InputFiles []string
// InputDir is the input directory (empty if single file)
InputDir string
// Verbose enables debug logging
Verbose bool
}
OrchestratorConfig contains configuration for creating an orchestrator. This provides a cleaner factory interface than passing many parameters.