runrequest

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 19 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 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

View Source
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

func NewID

func NewID() string

NewID is a fresh C2 id: 8 characters of [a-z2-7], 40 random bits.

Types

type ErrRefused

type ErrRefused struct {
	Status int
	Reason string
}

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

type Factory struct {
	URL    string
	CAFile string
	HC     *http.Client
}

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.

func (Factory) Request

func (f Factory) Request(ctx context.Context, r Request) (Result, error)

Request posts r to the factory as the human it names, with their own token.

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.

func (Manifest) Request

func (m Manifest) Request(_ context.Context, r Request) (Result, error)

Request renders r as a claim, its run id derived from r's idempotency key.

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 Requester

type Requester interface {
	Request(ctx context.Context, r Request) (Result, error)
}

Requester asks for a 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

type TaskResult struct {
	Task, Room string
	Issue      int
	Duplicate  bool
	Sponsor    string
}

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

Jump to

Keyboard shortcuts

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