agentrun

package
v0.197.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agentrun composes the existing agent authorities for CLI and remote callers.

Index

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

func Serve

func Serve(ctx context.Context, ops Operations, root string, stdin io.Reader, stdout, stderr io.Writer) int

Serve reports refusals inside the response; only encoding failure exits nonzero.

Types

type AwaitRequest

type AwaitRequest struct {
	ProjectsRoot, AgentID string
	WaitTimeout           time.Duration
}

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.

func (Awaiter) Await

func (a Awaiter) Await(ctx context.Context, id string, deadline time.Time) (agents.Result, error)

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

type DiffRequest struct {
	ProjectsRoot, AgentID string
	Patch                 bool
}

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 LogsRequest struct {
	ProjectsRoot, AgentID string
	Tail                  int
	Raw                   bool
}

type LookupRequest

type LookupRequest struct{ ProjectsRoot, AgentID string }

type Operations

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

type PruneRequest struct {
	ProjectsRoot string
	OlderThan    time.Duration
	Apply        bool
}

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) Await

func (s *Service) Await(ctx context.Context, r AwaitRequest) (agents.Result, error)

func (*Service) Compare

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) Diff

func (s *Service) Diff(ctx context.Context, r DiffRequest) (string, error)

Diff renders one run's diff.

func (*Service) Dispatch

func (s *Service) Dispatch(ctx context.Context, r DispatchRequest) (agents.Result, error)

func (*Service) Experiment

Experiment re-reads one durable experiment and joins it with its member records.

func (*Service) List

func (s *Service) List(_ context.Context, r ListRequest) ([]agents.Result, error)

func (*Service) Logs

func (s *Service) Logs(_ context.Context, r LogsRequest) (string, error)

func (*Service) Operations

func (s *Service) Operations() Operations

func (*Service) Plan

func (s *Service) Plan(_ context.Context, r PlanRequest) (agents.Plan, error)

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

Profiles reads the machine-readable profile catalog.

func (*Service) Prune

func (s *Service) Prune(_ context.Context, r PruneRequest) (PrunePlan, error)

Prune plans or applies retention. It never touches a running, leased, unaccepted-required or accepted run.

func (*Service) Review

Review appends one acceptance decision to a terminal execution.

func (*Service) Run

func (s *Service) Run(ctx context.Context, r RunRequest) (agents.Result, error)

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) Status

func (s *Service) Status(_ context.Context, r LookupRequest) (agents.Result, error)

func (*Service) Stop

func (*Service) TaskTypes

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

func (TranscriptReader) Read

func (r TranscriptReader) Read(record agents.Record, tail int, raw bool) (string, error)

Jump to

Keyboard shortcuts

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