Documentation
¶
Overview ¶
Package agentrun composes the existing agent authorities for CLI and remote callers.
Index ¶
- func DecodeRequest(stdin io.Reader) (agents.RemoteRequest, error)
- func Handle(ctx context.Context, ops Operations, root string, stderr io.Writer, ...) error
- func Serve(ctx context.Context, ops Operations, root string, stdin io.Reader, ...) int
- type AwaitRequest
- type Awaiter
- type CompareRequest
- type Dependencies
- type DiffRequest
- type DiscoveryRequest
- type DispatchRequest
- type ExperimentRequest
- type ListRequest
- type LogsRequest
- type LookupRequest
- type Operations
- type PlanRequest
- type ProfileEntry
- type ProfilesCatalog
- type PruneEntry
- type PrunePlan
- type PruneRequest
- type ReviewRequest
- type RunRequest
- type Service
- func (s *Service) Await(ctx context.Context, r AwaitRequest) (agents.Result, error)
- func (s *Service) Compare(ctx context.Context, r CompareRequest) (agents.ExperimentReport, error)
- func (s *Service) Diff(ctx context.Context, r DiffRequest) (string, error)
- func (s *Service) Dispatch(ctx context.Context, r DispatchRequest) (agents.Result, error)
- func (s *Service) Experiment(_ context.Context, r ExperimentRequest) (agents.ExperimentReport, error)
- func (s *Service) List(_ context.Context, r ListRequest) ([]agents.Result, error)
- func (s *Service) Logs(_ context.Context, r LogsRequest) (string, error)
- func (s *Service) Operations() Operations
- func (s *Service) Plan(_ context.Context, r PlanRequest) (agents.Plan, error)
- func (s *Service) PrepareDispatch(r DispatchRequest) (agents.Store, agents.DispatchDeps, error)
- func (s *Service) Profiles(_ context.Context, r DiscoveryRequest) (ProfilesCatalog, error)
- func (s *Service) Prune(_ context.Context, r PruneRequest) (PrunePlan, error)
- func (s *Service) Review(_ context.Context, r ReviewRequest) (agents.ReviewRecord, error)
- func (s *Service) Run(ctx context.Context, r RunRequest) (agents.Result, error)
- func (s *Service) Status(_ context.Context, r LookupRequest) (agents.Result, error)
- func (s *Service) Stop(_ context.Context, r LookupRequest) (agents.Record, error)
- func (s *Service) TaskTypes(_ context.Context, r DiscoveryRequest) (TaskTypesCatalog, error)
- type TaskTypeEntry
- type TaskTypesCatalog
- type TranscriptReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeRequest ¶
func DecodeRequest(stdin io.Reader) (agents.RemoteRequest, error)
func Handle ¶
func Handle(ctx context.Context, ops Operations, root string, stderr io.Writer, r agents.RemoteRequest, response *agents.RemoteResponse) error
Types ¶
type AwaitRequest ¶
type Awaiter ¶
type Awaiter struct {
Load func(string) (agents.Record, error)
Render func(agents.Record) agents.Result
Now func() time.Time
Wait func(context.Context, time.Duration) error
}
Awaiter observes durable records; a terminal observation wins over cancellation.
type CompareRequest ¶
type CompareRequest struct {
ProjectsRoot string
Stderr io.Writer
Task string
TaskType string
Complexity string
Effort string
Profiles []string
Repeat int
Concurrency int
Repository string
Base string
// Timeout bounds each attempt; empty means each profile's own bound.
Timeout time.Duration
TimeoutSet bool
}
CompareRequest is one experiment: the same task across several profiles.
type Dependencies ¶
type Dependencies struct {
Root, EnsureRoot func(string) (string, error)
ConfigPath func() string
LoadConfig func(string) (agents.Config, error)
Dispatch func(context.Context, agents.DispatchRequest, agents.DispatchDeps) (agents.Record, error)
PrepareRun func(context.Context, agents.DispatchRequest, agents.DispatchDeps) (*agents.PreparedRun, error)
StartRun func(*agents.PreparedRun, agents.DispatchDeps) (agents.Record, error)
Stop func(agents.Store, string, agents.OwnerDeps) (agents.Record, error)
SpawnOwner func(string, func() (string, error), []*os.File) (int, error)
Executable func() (string, error)
Now func() time.Time
Wait func(context.Context, time.Duration) error
BeforeCreate func(string, []string) error
AfterCreate func(string, io.Writer, string, []worktrees.CreateResult)
Transcripts TranscriptReader
Preflight func(context.Context, agents.Resolved) error
DetectVersion func(context.Context, string) string
Diff func(context.Context, agents.Record, bool, agents.TargetDeps) (string, error)
NewAgentID func() (string, error)
NewExperimentID func() string
}
func DefaultDependencies ¶
func DefaultDependencies() Dependencies
DefaultDependencies supplies real operations; composition binds the two creation callbacks.
type DiffRequest ¶
DiffRequest reads one run's diff.
type DiscoveryRequest ¶
type DiscoveryRequest struct{ ProjectsRoot string }
DiscoveryRequest is one catalog read.
type DispatchRequest ¶
type DispatchRequest struct {
ProjectsRoot string
Stderr io.Writer
Request agents.DispatchRequest
}
type ExperimentRequest ¶
type ExperimentRequest struct{ ProjectsRoot, ExperimentID string }
ExperimentRequest looks up one durable experiment.
type ListRequest ¶
type ListRequest struct{ ProjectsRoot string }
type LogsRequest ¶
type LookupRequest ¶
type LookupRequest struct{ ProjectsRoot, AgentID string }
type Operations ¶
type Operations struct {
Dispatch func(context.Context, DispatchRequest) (agents.Result, error)
Status func(context.Context, LookupRequest) (agents.Result, error)
Await func(context.Context, AwaitRequest) (agents.Result, error)
List func(context.Context, ListRequest) ([]agents.Result, error)
Logs func(context.Context, LogsRequest) (string, error)
Stop func(context.Context, LookupRequest) (agents.Record, error)
Run func(context.Context, RunRequest) (agents.Result, error)
Plan func(context.Context, PlanRequest) (agents.Plan, error)
Compare func(context.Context, CompareRequest) (agents.ExperimentReport, error)
Experiment func(context.Context, ExperimentRequest) (agents.ExperimentReport, error)
Profiles func(context.Context, DiscoveryRequest) (ProfilesCatalog, error)
TaskTypes func(context.Context, DiscoveryRequest) (TaskTypesCatalog, error)
Diff func(context.Context, DiffRequest) (string, error)
Review func(context.Context, ReviewRequest) (agents.ReviewRecord, error)
Prune func(context.Context, PruneRequest) (PrunePlan, error)
}
Operations is every concrete effect shared by command adapters and protocol handling. The first six are the remote protocol's surface; the rest are local-only.
type PlanRequest ¶
type PlanRequest struct {
ProjectsRoot string
Request agents.RunRequest
}
PlanRequest is one dry-run resolution.
type ProfileEntry ¶
type ProfileEntry struct {
Name string `json:"name"`
Resolved agents.Resolved `json:"resolved"`
Capabilities agents.HarnessCapabilities `json:"capabilities"`
Usable bool `json:"usable"`
Problem string `json:"problem,omitempty"`
}
ProfileEntry is one configured profile plus what it resolves to.
type ProfilesCatalog ¶
type ProfilesCatalog struct {
Profiles []ProfileEntry `json:"profiles"`
Providers []string `json:"providers"`
Fallback []string `json:"fallback,omitempty"`
DefaultProfile string `json:"default_profile,omitempty"`
Harnesses []agents.HarnessCapabilities `json:"harnesses"`
}
ProfilesCatalog is the machine-readable profile discovery document.
type PruneEntry ¶
type PruneEntry struct {
AgentID string `json:"agent_id"`
State string `json:"state"`
AgeMS int64 `json:"age_ms"`
Action string `json:"action"`
Reason string `json:"reason,omitempty"`
Dir string `json:"dir,omitempty"`
}
PruneEntry is one candidate in a retention plan.
type PrunePlan ¶
type PrunePlan struct {
OlderThanMS int64 `json:"older_than_ms"`
Applied bool `json:"applied"`
Entries []PruneEntry `json:"entries"`
Removed int `json:"removed"`
}
PrunePlan is the durable, reviewable output of a retention run.
type PruneRequest ¶
PruneRequest plans or applies retention.
type ReviewRequest ¶
type ReviewRequest struct {
ProjectsRoot, AgentID string
Status string
Evaluator string
Note string
}
ReviewRequest appends one acceptance decision.
type RunRequest ¶
type RunRequest struct {
ProjectsRoot string
Stderr io.Writer
Request agents.RunRequest
// AgentID is normally empty; an experiment pre-allocates it.
AgentID string
// Wait makes the service wait for the attempt and, when the task type
// allows it, carry out a runtime failover. Zero returns as soon as the
// owner starts.
Wait time.Duration
}
RunRequest is one high-level execution: the caller names the work and the policy, and the planner resolves the rest.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New(deps Dependencies) *Service
func (*Service) Compare ¶
func (s *Service) Compare(ctx context.Context, r CompareRequest) (agents.ExperimentReport, error)
Compare runs the same task across several profiles from one pinned base commit. Every worktree is created before any worker starts, so a base that moves mid-experiment produces a reported `base_mismatch` attempt instead of a silently unfair comparison.
func (*Service) Experiment ¶
func (s *Service) Experiment(_ context.Context, r ExperimentRequest) (agents.ExperimentReport, error)
Experiment re-reads one durable experiment and joins it with its member records.
func (*Service) Operations ¶
func (s *Service) Operations() Operations
func (*Service) Plan ¶
Plan resolves a request without starting anything. It never probes a harness, so a dry run creates no worktree, writes no record and starts no process.
func (*Service) PrepareDispatch ¶
func (s *Service) PrepareDispatch(r DispatchRequest) (agents.Store, agents.DispatchDeps, error)
PrepareDispatch assembles the agent-side seams for one dispatch or run.
func (*Service) Profiles ¶
func (s *Service) Profiles(_ context.Context, r DiscoveryRequest) (ProfilesCatalog, error)
Profiles reads the machine-readable profile catalog.
func (*Service) Prune ¶
Prune plans or applies retention. It never touches a running, leased, unaccepted-required or accepted run.
func (*Service) Review ¶
func (s *Service) Review(_ context.Context, r ReviewRequest) (agents.ReviewRecord, error)
Review appends one acceptance decision to a terminal execution.
func (*Service) Run ¶
Run resolves a task type and profile, prepares one execution, and starts its detached owner. It returns as soon as the owner is running, unless the caller asked to wait: only a waiting caller can carry out a runtime failover, because it is the process that observes the failure.
func (*Service) TaskTypes ¶
func (s *Service) TaskTypes(_ context.Context, r DiscoveryRequest) (TaskTypesCatalog, error)
TaskTypes reads the machine-readable task-type catalog.
type TaskTypeEntry ¶
type TaskTypeEntry struct {
Name string `json:"name"`
Policy agents.TaskType `json:"policy"`
Builtin bool `json:"builtin"`
Validations map[string][]agents.ValidationStep `json:"validations,omitempty"`
}
TaskTypeEntry is one task type with its resolved policy.
type TaskTypesCatalog ¶
type TaskTypesCatalog struct {
TaskTypes []TaskTypeEntry `json:"task_types"`
Default string `json:"default_task_type"`
}
TaskTypesCatalog is the machine-readable task-type discovery document.
type TranscriptReader ¶
type TranscriptReader struct {
Stat func(string) (os.FileInfo, error)
Open func(string) (io.ReadCloser, error)
}
func DefaultTranscriptReader ¶
func DefaultTranscriptReader() TranscriptReader