Documentation
¶
Overview ¶
Package runrequest asks for the next run. Only the factory creates AgentRuns (C3): with SP3, the broker calls POST /v1/runs with the human's own access token (C4); before SP3, it renders the claim for the owner to create (ruling P14).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBudget is the factory refusing a run over the principal's budget (429). ErrBudget = errors.New("over_budget") // ErrForbidden is the factory refusing the principal (403), or no token to present. ErrForbidden = errors.New("forbidden") // ErrNoKey is a factory request with no idempotency key, refused before the call. ErrNoKey = errors.New("runrequest: a factory request needs an idempotency key") )
Functions ¶
Types ¶
type ErrRefused ¶
ErrRefused is the factory refusing a task request: its status and its code, "refused" for a code outside POST /v1/tasks's closed list. A value, so errors.As matches it as written.
func (ErrRefused) Error ¶
func (e ErrRefused) Error() string
type Factory ¶
Factory is SP3's run API at URL. HC, when set, is the client (tests). Otherwise each call builds the audited egress client, trusting the PEM CA in CAFile, read at that call so a rotated CA needs no restart (S-1), or the system roots when CAFile is empty.
func (Factory) CreateTask ¶
func (f Factory) CreateTask(ctx context.Context, r TaskRequest) (TaskResult, error)
CreateTask posts r to the factory's POST /v1/tasks with the caller's own token, as Request does.
type Manifest ¶
type Manifest struct {
// Kind is the runs kind, required: the claim rendered is one of its runs.
Kind runwatch.Kind
}
Manifest renders the AgentRun claim for the owner to create (ruling P14), of Kind: its GVK and namespace, and the name prefix runwatch parses.
type Request ¶
type Request struct {
Role, Repository, BaseRef, Branch, TaskText, TaskURL, DataClass, RoomRef, Principal, AccessToken string
IdempotencyKey string
EgressProfiles []string
}
Request is one run to start: the claim's fields, the principal asking, and that principal's own access token for the factory (C4). IdempotencyKey names the act that asks (review 4.4 I1): the same key always means the same run.
type Result ¶
type Result struct {
RunID string `json:"runId"`
Via string `json:"via"`
Manifest json.RawMessage `json:"manifest,omitempty"`
}
Result is the requested run: its id, how it was requested ("manifest" or "factory"), and before SP3 the rendered claim.
type TaskRequest ¶
type TaskRequest struct {
Repository, Title, Text, DataClass, OnBehalfOf, Ref string
MaxCostUSD float64
AccessToken, IdempotencyKey string
}
TaskRequest is one api task to create: the factory's POST /v1/tasks fields, the caller's own access token (C4) and the key that names the act. Neither of the last two is in the body.
type TaskResult ¶
TaskResult is the factory's answer: the task and its room (the same id), the issue filed (0 when none), whether the key had already created it, and the GitHub login that sponsors it ("" on a duplicate, or when the factory's answer is not a login).