Documentation
¶
Overview ¶
Package status writes a run's status file: what the run has spent so far, its cap, what is left and what holds it, for the agent and the job to read while the agent works. The file holds amounts, counts, times and words from closed lists, never a prompt, a path or a model's answer. Its contract is status/v0.1 of Costroid/costroid-schemas.
Index ¶
Constants ¶
const FileVariable = "COSTROID_STATUS_FILE"
FileVariable names the status file's path.
const Schema = "costroid.status/0.1"
Schema names the contract's version in every file.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cap ¶
type Cap struct {
Currency string `json:"currency"`
Amount decimal.Decimal `json:"amount"`
Remainder *decimal.Decimal `json:"remainder"`
Overshoot *decimal.Decimal `json:"overshoot"`
}
Cap is the run's cap beside its spend in USD. Remainder and Overshoot are nil together, when no one figure compares with the cap.
func NewCap ¶
NewCap sets the cap beside the spend. Spend in no USD entry is zero; spend in two USD entries, or spend not known, compares with nothing.
func (*Cap) UnmarshalJSON ¶
UnmarshalJSON reads a cap whose amounts are decimal strings or null.
type NoFileError ¶
type NoFileError struct {
Path string
}
NoFileError is a status file that does not exist: no costroid run has started an agent that writes it in this job. An empty Path is an environment that names no status file.
func (*NoFileError) Error ¶
func (e *NoFileError) Error() string
type Spend ¶
type Spend struct {
Currency string `json:"currency"`
CostBasis *focus.CostBasis `json:"cost_basis"`
ListCost decimal.Decimal `json:"list_cost"`
}
Spend is what the run's priced usage comes to in one currency and basis, at the catalog's list prices. A nil CostBasis is a basis the agent's reader states only when the agent ends.
func (*Spend) UnmarshalJSON ¶
UnmarshalJSON reads an entry whose amount is a decimal string.
type Status ¶
type Status struct {
Schema string `json:"schema"`
State State `json:"state"`
Agent string `json:"agent"`
Updates Updates `json:"updates"`
StartedAt time.Time `json:"started_at"`
UpdatedAt time.Time `json:"updated_at"`
Spend []Spend `json:"spend"`
Requests *int `json:"requests"`
Cap Cap `json:"cap"`
EnforcementGrade string `json:"enforcement_grade"`
}
Status is one write of the file. A nil Spend is spend not known, and an empty one is a run that has spent nothing yet.