Documentation
¶
Overview ¶
Package task defines task lifecycle values, shared commands, and reusable event folds.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcceptedInputOutput ¶ added in v0.15.0
AcceptedInputOutput reports whether root agent output proves an input was accepted.
func ClearsExitError ¶ added in v0.12.0
ClearsExitError reports whether accepted activity clears the last exit error from a prior turn. Messages that accompany a turn without starting a new one (exit, diff stat, native subagent updates, background command updates, raw relay lines, pending user actions, metadata updates, log output, stripped env) never clear it; a ResultMessage clears it only when the turn succeeded; every other message starts a new turn. Ordered folds use ExitStatus to defer this interpretation for input attempts whose delivery is not yet established.
Types ¶
type CostSource ¶ added in v0.13.1
type CostSource string
CostSource describes where a displayed turn cost came from.
const ( // CostEstimated is calculated from model token prices. CostEstimated CostSource = "estimated" // CostReported is supplied by the harness. CostReported CostSource = "reported" )
type CostTracker ¶ added in v0.13.1
type CostTracker struct {
// Harness selects the cost-reporting semantics for this tracker.
Harness harness.Name
// Model is the current model used to price usage, updated by agent messages.
Model string
// TotalUSD is the cumulative task cost after the latest observed message.
TotalUSD float64
// contains filtered or unexported fields
}
CostTracker maintains one task's cost through turns, compaction, and context clearing. It uses only durable agent messages, so live folds and streamed log replay agree.
func (*CostTracker) Observe ¶ added in v0.13.1
func (c *CostTracker) Observe(msg agent.Message, at time.Time, pricer usage.ModelPricer) (TurnCost, bool)
Observe folds one agent message and returns a cost only at a result boundary. A false result means the turn's cost is unknown, including unpriced models.
type CreateRequest ¶ added in v0.11.5
CreateRequest describes an automated task creation request for one managed repository.
type DiscardRollup ¶ added in v0.13.0
type DiscardRollup struct{}
DiscardRollup ignores every rollup record. Task execution defaults to it so tasks are always safe to fold without a wired implementation; the task manager replaces it with the real sink at construction.
func (DiscardRollup) Close ¶ added in v0.13.0
func (DiscardRollup) Close() error
Close implements RollupSink with no resources to release.
func (DiscardRollup) Discard ¶ added in v0.13.0
func (DiscardRollup) Discard(usagedb.TaskMeta)
Discard implements RollupSink by discarding the purge notification.
func (DiscardRollup) Observe ¶ added in v0.13.0
func (DiscardRollup) Observe(usagedb.TaskMeta, *usagedb.Event)
Observe implements RollupSink by discarding the event.
func (DiscardRollup) ObserveQuota ¶ added in v0.13.0
func (DiscardRollup) ObserveQuota(*usagedb.QuotaChange)
ObserveQuota implements RollupSink by discarding the change.
type ExitStatus ¶ added in v0.14.4
type ExitStatus struct {
// Error is the latest exit diagnostic after reconciliation. Callers must
// treat it as read-only and update the status through Observe.
Error string
// contains filtered or unexported fields
}
ExitStatus reconciles relay termination with root turn and input delivery evidence. The zero value is ready for an ordered stream of messages.
func (*ExitStatus) Observe ¶ added in v0.14.4
func (s *ExitStatus) Observe(msg agent.Message) bool
Observe folds one message and reports whether it should be published. A marked input attempt preserves the prior completion until delivery succeeds or actual root output arrives. Failed and truncated attempts cannot invalidate a completed turn. Unmarked inputs begin a turn immediately.
type Result ¶
type Result struct {
State State
DiffStat v3.DiffStat
// DiskUsedBytes is the final measured writable-layer size. Nil means the
// runtime could not provide a measurement.
DiskUsedBytes *int64
CostUSD float64
Duration time.Duration
NumTurns int
Usage agent.Usage
AgentResult string
StartupFailure *v3.StartupFailure
Err error
}
Result holds the bounded durable outcome of a completed task. Completed-task restoration should read this summary without decoding message bodies; logs that predate required fields may fall back to a full history fold.
Persistence uses explicit projections to versioned data schemas.
type ResultTextWindow ¶ added in v0.12.0
type ResultTextWindow struct {
// contains filtered or unexported fields
}
ResultTextWindow accumulates the root assistant text of the current turn so a streaming consumer can produce the fallback result text at the point a ResultMessage arrives. Any other message type (a boundary, see fallbackBoundary) resets the window; finalized TextMessages accumulate with consecutive duplicates collapsed, and TextDeltaMessages count only until the first finalized text.
func (*ResultTextWindow) Update ¶ added in v0.12.0
func (w *ResultTextWindow) Update(msg agent.Message)
Update folds one message into the window.
func (*ResultTextWindow) Value ¶ added in v0.12.0
func (w *ResultTextWindow) Value() string
Value returns the accumulated fallback text: finalized messages joined by blank lines, or the trimmed delta stream when none arrived.
type RollupSink ¶ added in v0.13.0
type RollupSink interface {
// Observe records one translated rollup event. Called with the task
// mutex held, so implementations must not call back into the task and
// should keep per-call work bounded.
Observe(meta usagedb.TaskMeta, e *usagedb.Event)
// ObserveQuota records one provider quota-window status change.
ObserveQuota(c *usagedb.QuotaChange)
// Discard drops a purged task's unflushed data and resume bookkeeping.
// The task guarantees no later events reach the sink for this task.
Discard(meta usagedb.TaskMeta)
// Close flushes all pending deltas and releases resources.
Close() error
}
RollupSink consumes task messages for the cross-task usage rollup. Tasks always carry a non-nil sink: taskrun.NewTask defaults to DiscardRollup and the task manager replaces it with the wired implementation.
type State ¶
type State string
State represents the lifecycle state of a task. The persisted and API representation is the string value itself, so a corrupt or forward-versioned value round-trips instead of aliasing an unrelated state.
Transitions are written by message processing, lifecycle operations, and recovery. A few transitions are reachable from more than one source, so task code uses compare-and-swap helpers to keep them race-safe.
const ( StatePending State = "pending" StateBranching State = "branching" StateProvisioning State = "provisioning" StateStarting State = "starting" StateRunning State = "running" StateWaiting State = "waiting" StateAsking State = "asking" StateHasPlan State = "has_plan" StatePulling State = "pulling" StatePushing State = "pushing" StateStopping State = "stopping" StateStopped State = "stopped" StatePurging State = "purging" StateCrashed State = "crashed" StateFailed State = "failed" StatePurged State = "purged" )
Task lifecycle states.
func (State) IsTerminal ¶ added in v0.11.5
IsTerminal reports whether the task cannot be revived.
func (*State) UnmarshalJSON ¶ added in v0.15.0
UnmarshalJSON rejects an unrecognized task state instead of decoding it silently.
type TurnCost ¶ added in v0.13.1
type TurnCost struct {
USD float64
Source CostSource
}
TurnCost is a completed turn's cost in USD and its provenance.
Directories
¶
| Path | Synopsis |
|---|---|
|
data/headercache/v11
Package v11 defines the independent version 11 task-header cache schema.
|
Package v11 defines the independent version 11 task-header cache schema. |
|
Package taskmgr coordinates task execution, pending prompts, attachments, and ordered runtime history import.
|
Package taskmgr coordinates task execution, pending prompts, attachments, and ordered runtime history import. |
|
Package taskrun orchestrates coding-agent state and ordered conversation and Git history.
|
Package taskrun orchestrates coding-agent state and ordered conversation and Git history. |