Documentation
¶
Index ¶
- Constants
- Variables
- type CommandExecutor
- type Config
- type MeterRequest
- type MeterResponse
- type OSCommandExecutor
- type RunResult
- type Runner
- func (r *Runner) CheckPreviewHealth(ctx context.Context) error
- func (r *Runner) ReportUsage(ctx context.Context, token, model string, tokensUsed int64, costUSD float64) (*MeterResponse, error)
- func (r *Runner) ResolveToken() (string, error)
- func (r *Runner) Run(ctx context.Context) (*RunResult, error)
Constants ¶
const ( DefaultTaskNamespace = "default" DefaultBaseBranch = "main" DefaultMaxIterations = 5 DefaultTokenFile = "/etc/diverge/token/token" DefaultMCPURL = "http://diverge-server.diverge-system.svc:8080/mcp" DefaultMeterURL = "http://diverge-server.diverge-system.svc:8080/api/v1/agenttask/meter" DefaultPreviewHeaderKey = "x-diverge-env" DefaultWorkspaceDir = "/workspace" DefaultModel = "claude-3-7-sonnet" DefaultTokensPerIteration = int64(2500) DefaultCostPerIterationUSD = 0.05 )
Variables ¶
var ( // ErrBudgetExceeded is returned when the LLM metering endpoint reports that the task has exceeded its token or USD budget. ErrBudgetExceeded = errors.New("agent task budget exceeded") // ErrModelDisallowed is returned when the LLM metering endpoint rejects the requested model under the Macaroon token caveats. ErrModelDisallowed = errors.New("agent task model disallowed") // ErrMaxIterationsReached is returned when the agent loop exhausts MaxIterations without passing verification. ErrMaxIterationsReached = errors.New("max iterations reached without passing verification") )
Functions ¶
This section is empty.
Types ¶
type CommandExecutor ¶
type CommandExecutor interface {
Run(ctx context.Context, dir string, env []string, name string, args ...string) (string, error)
}
CommandExecutor abstracts external command execution for testability.
type Config ¶
type Config struct {
TaskName string
TaskNamespace string
Objective string
RepoURL string
BaseBranch string
WorkingBranch string
BudgetUSD string
MaxIterations int
TokenFile string
MCPURL string
MeterURL string
PreviewURL string
PreviewHeaderKey string
PreviewHeaderValue string
WorkspaceDir string
AgentCommand string
VerifyCommand string
Model string
TokensPerIteration int64
CostPerIterationUSD float64
}
Config holds the runtime configuration for the autonomous agent runner.
type MeterRequest ¶
type MeterRequest struct {
Model string `json:"model"`
TokensUsed int64 `json:"tokensUsed"`
CostUSD float64 `json:"costUSD"`
}
MeterRequest matches internal/server.LLMMeterRequest JSON schema for POST /api/v1/agenttask/meter.
type MeterResponse ¶
type MeterResponse struct {
Allowed bool `json:"allowed"`
Suspended bool `json:"suspended"`
Reason string `json:"reason,omitempty"`
TotalTokensUsed int64 `json:"totalTokensUsed"`
TotalCostUSD float64 `json:"totalCostUSD"`
}
MeterResponse matches internal/server.LLMMeterResponse JSON schema returned by POST /api/v1/agenttask/meter.
type OSCommandExecutor ¶
type OSCommandExecutor struct{}
OSCommandExecutor runs commands on the host OS via os/exec.
type RunResult ¶
type RunResult struct {
Succeeded bool
Iterations int
Committed bool
WorkingBranch string
TotalTokensUsed int64
TotalCostUSD float64
}
RunResult summarizes the outcome of an autonomous agent runner execution.
type Runner ¶
Runner orchestrates the autonomous agent loop inside a Diverge sandbox pod.
func (*Runner) CheckPreviewHealth ¶
CheckPreviewHealth probes the ephemeral preview URL (if configured) with the Diverge isolation header.
func (*Runner) ReportUsage ¶
func (r *Runner) ReportUsage(ctx context.Context, token, model string, tokensUsed int64, costUSD float64) (*MeterResponse, error)
ReportUsage reports token and cost consumption for an iteration to the Diverge metering endpoint.
func (*Runner) ResolveToken ¶
ResolveToken loads the Macaroon capability token from DIVERGE_MACAROON_TOKEN or Config.TokenFile.