Documentation
¶
Overview ¶
Package adapter holds what every agent adapter hands the wrapper.
Index ¶
Constants ¶
const ( GradeAgentFlag = "agent-flag" GradeWrapperWatchdog = "wrapper-watchdog" GradeNone = "none" )
Enforcement grades.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface {
// Name is the costroid/agent tag.
Name() string
// Plan rewrites a command to run under the budget, or refuses it.
Plan(argv []string, budget decimal.Decimal) (Plan, error)
// NewSession starts reading a run of the planned command.
NewSession(plan Plan) Session
}
Agent is one supported agent.
type Count ¶
type Count struct {
Class focus.TokenClass
Tokens int64
}
Count is one class and its tokens.
type Enforcement ¶
Enforcement is the grade a run was held at. Note states the limit of the grade in words and travels on every row.
type Plan ¶
type Plan struct {
Argv []string
Enforcement Enforcement
}
Plan is how one agent command runs under a budget.
type Report ¶
type Report struct {
SessionID string
AgentVersion string
CostBasis focus.CostBasis
CostSource string
Requests []Request
Warnings []string
// Enforcement is the grade the run earned, when it differs from what the
// plan could promise. Empty means the plan's grade held.
Enforcement Enforcement
// Nested holds the sessions of other agent processes that started and
// ended inside the run, each under its own session id. Their requests are
// never in Requests.
Nested []Report
}
Report is what a run's usage came to.
type Request ¶
type Request struct {
// ID is the provider's request id, or the adapter's stated stand-in when
// the source has none.
ID string
Provider string
Model string
Start, End time.Time
ServiceTier string
Region string
// ContextInputTokens is the request's whole input. Zero when the grain
// is coarser than a request, because a sum cannot select a context tier.
ContextInputTokens int64
Grain Grain
Tokens Tokens
// AssumedWrite is the cache write class that took tokens whose lifetime the
// source did not report, by the adapter's rule. Empty when it reported all.
AssumedWrite focus.TokenClass
}
Request is one unit of usage at the finest grain the source reports.
type Session ¶
type Session interface {
// Feed reads one line of the agent's stdout, seen at the given time.
Feed(line []byte, at time.Time) error
// Finish reads whatever the agent left behind and returns the run's usage.
Finish() (Report, error)
}
Session reads one run.
type Tailer ¶
type Tailer interface {
// Tail follows the file until ctx ends. It calls settled with the run's
// requests so far each time a new one settles while the agent is working.
Tail(ctx context.Context, settled func([]Request))
}
Tailer is a Session that watches a file the agent writes during a run.
type Tokens ¶
type Tokens struct {
InputUncached int64
CacheRead int64
CacheWrite5m int64
CacheWrite1h int64
CacheWrite30m int64
Output int64
ReasoningOutput int64
CachedInputReported int64
}
Tokens holds the canonical classes. Billed classes are disjoint; the two informational classes repeat tokens a billed class already counts.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package claudecode reads Claude Code runs.
|
Package claudecode reads Claude Code runs. |
|
Package codex reads `codex exec --json` runs.
|
Package codex reads `codex exec --json` runs. |