Documentation
¶
Overview ¶
Package model is the wire and screen model of agentscope: one Snapshot is everything the UI shows, and it carries METADATA only -- ids, working directories resolved to repositories, tool names, agent descriptions, lease notes, tell texts and timestamps. Nothing here ever holds a prompt or a response; the collector never reads those fields (see package collect).
Index ¶
- Constants
- Variables
- func ContextRatio(context, window int64) float64
- func FormatColor(r, g, b uint8) string
- func ModelFamily(id string) string
- func ModelLabel(id string) string
- func ModelName(id string) (string, bool)
- func ParseColor(s string) (r, g, b uint8, ok bool)
- func ParseLang(s string) (string, bool)
- func ParseTheme(s string) (string, bool)
- func PressureBand(ratio float64) int
- func ShortID(id string) string
- func Truncate(s string, n int) string
- type AccountUsage
- type Agent
- type AllTokens
- type Anomaly
- type Budget
- type BudgetRow
- type BudgetSpender
- type Capacity
- type CapacityItem
- type Cell
- type Counts
- type GuardLesson
- type Guardrails
- type Landing
- type Lease
- type Level
- type ModelCount
- type ModelSeen
- type Prefs
- type QueueRow
- type QueueWaiter
- type Queues
- type QuotaPoint
- type QuotaWindow
- type RecLine
- type RefusalCheck
- type RefusalExcerpt
- type RefusalRow
- type Refusals
- type RepoKind
- type Session
- type Snapshot
- type State
- type Stats
- type TargetKind
- type Tell
- type TokenSeries
- type Usage
- type WeekTotals
Constants ¶
const ( AnomalyUnresolvedKey = "unresolved key" AnomalyOrphanLease = "lease owner has no transcript" AnomalyUnknownSender = "tell from unknown session" AnomalyUnknownTarget = "tell to unknown session" AnomalyBadLine = "unparsable line" AnomalyOversizedLine = "oversized line skipped" AnomalyUnreadable = "unreadable file" AnomalyTranscriptStall = "transcript shrank" )
Anomaly kinds.
const ( // BandCalm is below 40 % of the window. BandCalm = iota // BandFair is from 40 % up to 60 %. BandFair // BandWarm is from 60 % up to 75 %. BandWarm // BandHot is from 75 % up to 90 %. BandHot // BandCritical is 90 % and over. BandCritical // Bands is the number of bands. Bands )
Context pressure is how full a session's context is against the window at which Claude Code compacts it. It is told in five bands, so the screen can colour it without the colour carrying a number.
const ( // RefusalBurst: the same session was refused by the same gate three times within // fifteen minutes. RefusalBurst = "burst" // RefusalStuck: the session's last three tool results were all refusals and it // was refused within the last fifteen minutes. RefusalStuck = "stuck" )
The reasons a row is red.
const ( LogOK = "ok" LogAbsent = "absent" // no denial log: replystamp denied nothing, or never ran LogUnreadable = "unreadable" // the file exists and could not be read LogCorrupt = "corrupt" // lines that are not records )
Log states of the replystamp cross-check.
const BudgetRedBelow = 0.10
BudgetRedBelow is the share of the limit below which a budget is red.
const DefaultCompactWindow int64 = 1_000_000
DefaultCompactWindow is the window used when neither the Claude Code settings nor the environment name one.
const MaxLangLen = 35
MaxLangLen bounds a stored language tag (RFC 5646 allows 35 characters).
const RefusalWindowSec = 2 * 3600
RefusalWindowSec is how far back the view looks: two hours.
const SecondaryWindow = 15 * time.Minute
SecondaryWindow is how far back a secondary-limit refusal keeps a token red.
const UnattributedLayer = "unattributed"
UnattributedLayer is the name of the extra layer of the aggregated charts: tokens of an API call that no recorded account can be given.
const Version = 1
Version is the snapshot schema version; the browser refuses a newer one.
Variables ¶
var Families = []string{"Opus", "Sonnet", "Haiku", "Fable"}
Families are the model families the usage charts stack, bottom to top.
Functions ¶
func ContextRatio ¶ added in v0.9.0
ContextRatio is context over window, 0 when there is no window.
func FormatColor ¶ added in v0.12.0
FormatColor is the colour as "#rrggbb", in lower case: the form that is stored and sent.
func ModelFamily ¶ added in v0.5.0
ModelFamily is the family alone ("Opus"), or "?" for an unknown id.
func ModelLabel ¶ added in v0.5.0
ModelLabel is "Opus 5.5 (claude-opus-5-5)", or "? (<raw id>)" for an unknown id, or "? (none seen)" when there is none.
func ModelName ¶ added in v0.5.0
ModelName is the short family name of a model id ("Opus 5.5") and whether the id was understood. It never guesses: a missing or unrecognised id is "?" and the caller shows the raw id beside it.
func ParseColor ¶ added in v0.12.0
ParseColor is the one place a colour is accepted, on the server and in the view: exactly "#" and six hex digits (either case). Nothing else is a colour -- no name, no short form, no rgb() or url() -- so a value read from a file or a snapshot can never carry markup or CSS.
func ParseLang ¶ added in v0.13.0
ParseLang is the one place a language is accepted: letters and digits in subtags of 1 to 8 characters, joined by "-" (a "_" is read as "-"), the first of 2 or 3 letters, at most MaxLangLen long; the result is in lower case. It does not check that the language is one the application has a catalog for: the view falls back to English for that.
func ParseTheme ¶ added in v0.13.0
ParseTheme is the one place a theme is accepted: exactly "light", "dark" or "system", in lower case. Nothing else is a theme.
func PressureBand ¶ added in v0.9.0
PressureBand is the band of a ratio of context to window. A ratio below 0, or one that is not a number, is calm; one over 1 is critical.
Types ¶
type AccountUsage ¶ added in v0.8.0
type AccountUsage struct {
// Key is the account's stable key: a short hash of its id; "" is the account
// of readings recorded before accounts were told apart (unknown, never
// guessed).
Key string `json:"key"`
Label string `json:"label"`
Plan string `json:"plan,omitempty"`
Active bool `json:"active,omitempty"`
// Alias is the display name the owner gave the account (accounts.toml); it
// replaces the label wherever the account is named. "" when it has none.
Alias string `json:"alias,omitempty"`
// Color is the colour the owner gave the account, "#rrggbb" (account-colors.toml);
// "" when it has none and the automatic colour applies.
Color string `json:"color,omitempty"`
// Suggest is the organisation's name, offered as a first value of the rename
// dialog. It is sent ONLY when the server runs with --show-org, and only for
// the account Claude Code is signed in to.
Suggest string `json:"suggest,omitempty"`
// SessionEnd and WeekEnd are the reset instants (Unix seconds) closing the
// current 5 hour and 7 day windows; 0 when unknown. ResetSource says where
// WeekEnd came from: "aiquota", "recorded" (the last reading kept) or ""
// (unknown: the weeks end now).
SessionEnd int64 `json:"sessionEnd,omitempty"`
WeekEnd int64 `json:"weekEnd"`
ResetSource string `json:"resetSource,omitempty"`
RecordingSince int64 `json:"recordingSince,omitempty"`
Windows []QuotaWindow `json:"windows"`
Short TokenSeries `json:"short"` // the 5 hour window, 10 minute buckets
Week TokenSeries `json:"week"` // the 7 day window, hourly buckets
Weeks []WeekTotals `json:"weeks"` // four 7 day windows, oldest first
}
AccountUsage is one account's view.
type Agent ¶
type Agent struct {
Model string `json:"model,omitempty"`
Models []ModelSeen `json:"models,omitempty"`
ID string `json:"id"`
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
ToolUseID string `json:"toolUseId,omitempty"`
Depth int `json:"depth"`
LastActivity time.Time `json:"lastActivity"`
Active bool `json:"active"`
// Context is the sub-agent's context size, as for a Session.
Context int64 `json:"context,omitempty"`
}
Agent is one sub-agent of a session.
type AllTokens ¶ added in v0.8.0
type AllTokens struct {
Layers []string `json:"layers"` // Families, then UnattributedLayer
Short TokenSeries `json:"short"`
Week TokenSeries `json:"week"`
// Days is 28 calendar days (local midnight to midnight), the last ending at
// the end of today.
Days TokenSeries `json:"days"`
// Unattributed is the tokens (output, cache read) that no account got.
UnattributedOut float64 `json:"unattributedOut"`
UnattributedCache float64 `json:"unattributedCache"`
}
AllTokens is the sum over accounts.
type Anomaly ¶
type Anomaly struct {
Kind string `json:"kind"`
Subject string `json:"subject"`
Detail string `json:"detail,omitempty"`
}
Anomaly is something odd the collector met and chose to show.
type Budget ¶ added in v0.22.0
type Budget struct {
At int64 `json:"at"` // Unix seconds the view was built
// Cell is the whole view: NotMeasured with the reason when nothing could be
// read (no token file, /rate_limit unreadable, ledger empty).
Cell Cell `json:"cell"`
// Rows are the readings, one per token fingerprint and resource.
Rows []BudgetRow `json:"rows,omitempty"`
// Spenders is who spent the last hour, most units first; Unattributed is what
// the counter moved without a recorded call, valid only when UnattributedKnown.
Spenders []BudgetSpender `json:"spenders,omitempty"`
Unattributed int `json:"unattributed,omitempty"`
UnattributedKnown bool `json:"unattributedKnown,omitempty"`
// Torn counts ledger lines that could not be read; shown, never hidden.
Torn int `json:"torn,omitempty"`
}
Budget is the REST budget view: how much of GitHub's REST quota is left, until when, and who spent it. It reads the call ledger and at most one free GET /rate_limit per token per minute; it never carries a token, only its fingerprint.
type BudgetRow ¶ added in v0.22.0
type BudgetRow struct {
Token string `json:"token"` // fingerprint, never the token
File string `json:"file,omitempty"` // base name of the token file
Resource string `json:"resource"` // core, graphql, ...
Limit int `json:"limit"`
Remaining int `json:"remaining"`
Reset int64 `json:"reset"` // Unix seconds the window ends
Observed int64 `json:"observed"` // Unix seconds of the reading
Source string `json:"source,omitempty"` // "rate_limit" or "headers"
// Secondary is the last secondary-limit refusal of this token (Unix seconds),
// 0 for none in the ledger.
Secondary int64 `json:"secondary,omitempty"`
}
BudgetRow is one token's resource.
type BudgetSpender ¶ added in v0.22.0
type BudgetSpender struct {
Session string `json:"session,omitempty"` // short id; "" = not a session
Program string `json:"program,omitempty"`
Calls int `json:"calls"`
Units int `json:"units"`
}
BudgetSpender is what one session or program is known to have spent.
type Capacity ¶ added in v0.8.0
type Capacity struct {
// AccountWeeks is the sum of (100 - weekly %)/100 over the accounts whose
// weekly window is current; Counted is how many that is.
AccountWeeks float64 `json:"accountWeeks"`
Counted int `json:"counted"`
Items []CapacityItem `json:"items"`
}
Capacity is what is left of the weekly windows, summed over accounts.
type CapacityItem ¶ added in v0.8.0
type CapacityItem struct {
Key string `json:"key"`
Label string `json:"label"`
Alias string `json:"alias,omitempty"`
Color string `json:"color,omitempty"`
Plan string `json:"plan,omitempty"`
Active bool `json:"active,omitempty"`
SessionOK bool `json:"sessionOk,omitempty"`
Session float64 `json:"session,omitempty"`
WeeklyOK bool `json:"weeklyOk,omitempty"`
Weekly float64 `json:"weekly,omitempty"`
NextReset int64 `json:"nextReset,omitempty"`
SessionNext int64 `json:"sessionNext,omitempty"`
// Stale is a reading whose reset has passed: the account is listed, not
// counted.
Stale bool `json:"stale,omitempty"`
// Unknown is the account of readings recorded before accounts were told
// apart: it may be one of the others, so it is listed and never counted.
Unknown bool `json:"unknown,omitempty"`
}
CapacityItem is one account's row of the capacity table.
type Cell ¶ added in v0.22.0
type Cell struct {
State State `json:"state"`
Reason string `json:"reason,omitempty"`
Alarm Level `json:"alarm,omitempty"`
}
Cell is one diagnostic value's measurement state, with the reason when it is not whole. Alarm is what the value itself says (LevelAmber or LevelRed), used only when the value was measured; the colour rule is Level.
type Counts ¶
type Counts struct {
Sessions, Active, Agents, ActiveAgents, Repos, Held, Leases, Tells, Anomalies int
}
Counts is the header line of the UI.
type GuardLesson ¶ added in v0.10.0
type GuardLesson struct {
Name string `json:"name"`
Decision string `json:"decision"`
// GateText is the ledger's text, cut to a bounded length.
GateText string `json:"gateText,omitempty"`
// WrittenAt is when the decision was recorded (Unix seconds), 0 for none.
WrittenAt int64 `json:"writtenAt,omitempty"`
// Total counts every recurrence line; Dated those with a date (Inferred of
// them with a year `recur` guessed) and Undated the rest.
Total int `json:"total"`
Dated int `json:"dated"`
Inferred int `json:"inferred"`
Undated int `json:"undated"`
// Last is the date of the latest dated recurrence, "" for none.
Last string `json:"last,omitempty"`
// After counts the recurrences dated after the day the decision was written
// (AfterInferred of them with an inferred year); 0 when nothing was written.
After int `json:"after"`
AfterInferred int `json:"afterInferred"`
// Silent is a landed gate, at least SilentWeeks old, whose named gates made no
// refusal in those weeks and that saw no recurrence since it landed: either
// obsolete or no longer running. Gated says which refusing gates the ledger
// text names, so the flag is only ever raised for a gate that can be counted.
Silent bool `json:"silent,omitempty"`
Named []string `json:"named,omitempty"`
Lines []RecLine `json:"lines,omitempty"`
}
GuardLesson is one lesson of the ledger.
type Guardrails ¶ added in v0.10.0
type Guardrails struct {
At int64 `json:"at"` // Unix seconds the view was built
// Recur is whether `recur` was read, and why not when it was not.
RecurMeasured bool `json:"recurMeasured"`
RecurErr string `json:"recurErr,omitempty"`
// RefusalsMeasured is whether the transcripts have been scanned at all.
RefusalsMeasured bool `json:"refusalsMeasured"`
// Totals is what recur counted (zero values when RecurMeasured is false).
Lessons int `json:"lessons"`
Untriaged int `json:"untriaged"`
Unreadable int `json:"unreadable"`
// Leaking is the number of landed gates (decision "gate") with a recurrence
// dated after the day they landed. SilentGates is the number of landed gates
// that look obsolete or switched off (see Lesson.Silent).
Leaking int `json:"leaking"`
SilentGates int `json:"silentGates"`
// Weeks are the Monday 00:00 (local) instants the 12 weeks start at, oldest
// first; the last is the current, partial week.
Weeks []int64 `json:"weeks"`
// RecStated and RecInferred are the dated recurrences per week: those whose
// year the memory states, and those whose year `recur` inferred.
RecStated []float64 `json:"recStated"`
RecInferred []float64 `json:"recInferred"`
// Gates names the refusing gates, the stacked layers' order; Refusals[g][w] is
// gate g's refusals in week w.
Gates []string `json:"gates"`
Refusals [][]float64 `json:"refusals"`
// ThisWeek and LastWeek are the refusals of the last two weeks, all gates.
ThisWeek int `json:"thisWeek"`
LastWeek int `json:"lastWeek"`
// Landings are the instants a gate was written into the ledger.
Landings []Landing `json:"landings,omitempty"`
Rows []GuardLesson `json:"rows"`
}
Guardrails is the Guardrails tab's data: whether the fleet's gates work. It is computed on the server, so the browser draws and never aggregates.
Two sources feed it and either can be missing: `recur --json` (the lessons, their recurrences and the ledger of decisions) and the transcripts (the refusals a gate made). A source that could not be read is "not measured" -- never zero.
type Lease ¶
type Lease struct {
Resource string `json:"resource"` // as written in the lease
Repo string `json:"repo"` // normalised key (org/repo when resolved)
Kind RepoKind `json:"kind"`
Path string `json:"path,omitempty"` // the clone, when there is one
Owner string `json:"owner"`
PID int `json:"pid"`
Note string `json:"note,omitempty"`
Acquired time.Time `json:"acquired"`
Expires time.Time `json:"expires"`
Expired bool `json:"expired"`
}
Lease is one advisory lease, expired ones included.
type ModelCount ¶ added in v0.5.0
ModelCount is how many sessions and sub-agents run one model family.
type Prefs ¶ added in v0.13.0
type Prefs struct {
Theme string `json:"theme,omitempty"` // "light", "dark" or "system"; "" is system
Lang string `json:"lang,omitempty"` // a language tag such as "fr" or "pt-br"; "" is automatic
}
Prefs are the viewer's own choices, kept by the serve process in settings.toml (next to account-colors.toml) and carried by every snapshot, so each browser opens in the theme and the language its owner chose. An empty field is "not chosen": the theme then follows the system and the language is negotiated from the browser's languages.
type QueueRow ¶ added in v0.22.0
type QueueRow struct {
Resource string `json:"resource"`
// Holder is the owner of the lease covering the resource, "" when none.
Holder string `json:"holder,omitempty"`
// HolderKnown is false when the leases could not be read: the holder is then
// unknown, not absent.
HolderKnown bool `json:"holderKnown,omitempty"`
Expires int64 `json:"expires,omitempty"` // Unix seconds, 0 without a holder
// Idle is true when the holder has done nothing with its lease for the idle
// limit.
Idle bool `json:"idle,omitempty"`
Waiters []QueueWaiter `json:"waiters"`
}
QueueRow is one resource with a line.
type QueueWaiter ¶ added in v0.22.0
type QueueWaiter struct {
Session string `json:"session"`
Since int64 `json:"since"` // Unix seconds
Position int `json:"position"`
}
QueueWaiter is one session in a line, oldest first.
type Queues ¶ added in v0.22.0
type Queues struct {
At int64 `json:"at"` // Unix seconds the view was built
Cell Cell `json:"cell"`
Rows []QueueRow `json:"rows,omitempty"`
// NeverCreated is true when agentsync's lock directory does not exist yet: no
// session ever claimed anything, which is "none yet", not a failure.
NeverCreated bool `json:"neverCreated,omitempty"`
// Unread counts queue files that could not be read; shown whenever above 0.
Unread int `json:"unread,omitempty"`
}
Queues is the lease queue view: who waits in line for which resource, behind whom. A queue directory that was never created is "none yet" (Measured, no rows); one that could not be read is NotMeasured with the reason, never "no one waits". Queue files that exist but could not be read are counted in Unread and make the view Partial.
type QuotaPoint ¶ added in v0.7.0
QuotaPoint is one recorded reading of a window.
type QuotaWindow ¶ added in v0.7.0
type QuotaWindow struct {
Label string `json:"label"`
Available bool `json:"available"`
Percent float64 `json:"percent"`
ResetsAt int64 `json:"resetsAt,omitempty"`
// History is the recorded readings, oldest first: at most one point per
// bucket of the span it is drawn over.
History []QuotaPoint `json:"history,omitempty"`
}
QuotaWindow is one official window and its recorded history.
type RecLine ¶ added in v0.10.0
type RecLine struct {
Date string `json:"date,omitempty"`
Inferred bool `json:"inferred,omitempty"`
Text string `json:"text"`
}
RecLine is one recurrence sentence of a lesson.
type RefusalCheck ¶ added in v0.23.0
type RefusalCheck struct {
Transcript int `json:"transcript"` // replystamp refusals in the transcripts, in the window
Log int `json:"log"` // denials in the log, in the window
State string `json:"state"`
Reason string `json:"reason,omitempty"`
}
RefusalCheck compares what the transcripts say replystamp refused with what its denial log says.
func (RefusalCheck) Disagree ¶ added in v0.23.0
func (c RefusalCheck) Disagree() bool
Disagree is true when both counts were read and differ.
type RefusalExcerpt ¶ added in v0.23.0
type RefusalExcerpt struct {
At int64 `json:"at"`
Gate string `json:"gate"`
Text string `json:"text"`
}
RefusalExcerpt is the gate's own words of one refusal, already redacted.
type RefusalRow ¶ added in v0.23.0
type RefusalRow struct {
Session string `json:"session"`
Gate string `json:"gate"`
Count int `json:"count"`
Last int64 `json:"last"` // Unix seconds of the latest refusal
// Why is RefusalBurst or RefusalStuck when the row is red, "" otherwise.
Why string `json:"why,omitempty"`
// Excerpts are the session's latest refusals, newest first, whatever the gate.
Excerpts []RefusalExcerpt `json:"excerpts,omitempty"`
}
RefusalRow is one session refused by one gate.
func (RefusalRow) Level ¶ added in v0.23.0
func (r RefusalRow) Level() Level
Level is the row's colour: red when it is a burst or a stuck session, green otherwise.
type Refusals ¶ added in v0.23.0
type Refusals struct {
At int64 `json:"at"` // Unix seconds the view was built
Cell Cell `json:"cell"`
Rows []RefusalRow `json:"rows,omitempty"`
Check RefusalCheck `json:"check"`
}
Refusals is the Diagnostics tab's refusals view: which session was refused by which gate in the last RefusalWindowSec seconds, from the transcripts. Before the first pass over the transcripts ended it is NotMeasured, never 0. The count of the `replystamp` gate is cross-checked against that program's own denial log; a disagreement is shown (Check), never averaged.
type RepoKind ¶
type RepoKind string
RepoKind says how a lease resource was understood.
const ( // KindRepo is an org/repo that matches a clone on this machine. KindRepo RepoKind = "repo" // KindRepoForm is an org/repo spelling with no clone here. KindRepoForm RepoKind = "repo-form" // KindOrg is an organisation that has clones here. KindOrg RepoKind = "org" // KindUnresolved is a key that is no repository: a note used as the key, // a bare name, a flag. It is shown, flagged, never hidden. KindUnresolved RepoKind = "unresolved" )
type Session ¶
type Session struct {
ID string `json:"id"`
Short string `json:"short"` // first 8 characters of ID
Title string `json:"title,omitempty"`
Slug string `json:"slug,omitempty"`
Cwd string `json:"cwd,omitempty"`
CwdRepo string `json:"cwdRepo,omitempty"` // Cwd resolved to org/repo, when it is one
Branch string `json:"branch,omitempty"`
PR string `json:"pr,omitempty"`
Project string `json:"project,omitempty"`
LastActivity time.Time `json:"lastActivity"`
Active bool `json:"active"`
HasTranscript bool `json:"hasTranscript"`
Sent int `json:"sent"` // SendMessage calls seen in the observed window
MemAdds int `json:"memAdds"` // entries in the agentsync session record
Agents []Agent `json:"agents,omitempty"`
// Model is the id of the latest assistant entry's model ("" when none was
// seen); Models is every model seen in the observed window, newest first.
Model string `json:"model,omitempty"`
Models []ModelSeen `json:"models,omitempty"`
// Context is the tokens the last API call of the session carried in (input,
// cache read and cache creation): how full its context is now; 0 when no call
// was seen.
Context int64 `json:"context,omitempty"`
// Reach is how another session addresses this one with SendMessage: the
// registry name (plus a [ref] when two live sessions share it), or
// unresolved. It is never derived from the title, the slug or the cwd.
Reach names.Reach `json:"reach"`
}
Session is one Claude Code session, with its sub-agents.
type Snapshot ¶
type Snapshot struct {
Version int `json:"version"`
At time.Time `json:"at"`
ActiveFor string `json:"activeFor"` // the activity window, e.g. "10m0s"
Horizon string `json:"horizon"` // sessions older than this are not listed
Sessions []Session `json:"sessions"`
Leases []Lease `json:"leases"`
Tells []Tell `json:"tells"`
Anomalies []Anomaly `json:"anomalies"`
Stats Stats `json:"stats"`
// Usage is the Quota tab's data; nil until the first scan finished.
Usage *Usage `json:"usage,omitempty"`
// Guardrails is the Guardrails tab's data; nil until the first pass ended.
Guardrails *Guardrails `json:"guardrails,omitempty"`
// Budget is the Diagnostics tab's REST budget view; nil until it was read.
Budget *Budget `json:"budget,omitempty"`
// Queues is the Diagnostics tab's lease queue view; nil until it was read.
Queues *Queues `json:"queues,omitempty"`
// Refusals is the Diagnostics tab's refusals view: the gates' refusals per
// session in the last two hours; nil until the engine built it.
Refusals *Refusals `json:"refusals,omitempty"`
// ContextWindow is the size, in tokens, at which Claude Code compacts a
// context: what a session's Context is measured against.
ContextWindow int64 `json:"contextWindow,omitempty"`
// AgentWindows are the compaction windows of the agent types whose
// definition names one, by type; a sub-agent of another type uses ContextWindow.
AgentWindows map[string]int64 `json:"agentWindows,omitempty"`
}
Snapshot is the whole picture at one instant.
func (Snapshot) LeasesOf ¶
LeasesOf returns the leases a session holds or held, live first and then by most recent acquisition.
func (Snapshot) ModelCounts ¶ added in v0.5.0
func (s Snapshot) ModelCounts() []ModelCount
ModelCounts counts the listed sessions and sub-agents by model family, most first (ties by name). "?" counts those whose model is unknown or unseen.
func (Snapshot) SessionByShort ¶
SessionByShort finds a session by its short id.
func (Snapshot) Task ¶
Task is the best one-line statement of what a session is doing: the note of its live lease, else its title, else its slug.
func (Snapshot) WindowOfAgent ¶ added in v0.10.4
WindowOfAgent is the window a sub-agent's Context is measured against: its type's, else the session's (ContextWindow, or the default).
type State ¶ added in v0.22.0
type State int
State is how well a value was measured. "Not measured" is never zero: a view that could not read its source says so and shows no number.
type Stats ¶
type Stats struct {
TranscriptsSeen int `json:"transcriptsSeen"`
TranscriptsRead int `json:"transcriptsRead"`
BytesRead int64 `json:"bytesRead"`
LeasesRead int `json:"leasesRead"`
LeasesTorn int `json:"leasesTorn"`
TellsRead int `json:"tellsRead"`
TellsDropped int `json:"tellsDropped"`
SubAgentsRead int `json:"subAgentsRead"`
SessionRecords int `json:"sessionRecords"`
ElapsedMicros int64 `json:"elapsedMicros"`
LinesSkipped int `json:"linesSkipped"`
LinesUnparsable int `json:"linesUnparsable"`
ReadErrors int `json:"readErrors"`
ExpiredNotListed int `json:"expiredNotListed"`
}
Stats counts what the collector looked at, so a zero is distinguishable from "could not read".
type TargetKind ¶
type TargetKind string
TargetKind says what a tell was addressed to.
const ( TargetSession TargetKind = "session" TargetResource TargetKind = "resource" )
type Tell ¶
type Tell struct {
Target string `json:"target"` // the session short id or the repo key
TargetKind TargetKind `json:"targetKind"`
From string `json:"from"` // sender session id
Text string `json:"text"` // truncated
At time.Time `json:"at"`
}
Tell is one `agentsync tell` message.
type TokenSeries ¶ added in v0.7.0
type TokenSeries struct {
Start int64 `json:"start"`
Step int64 `json:"step"`
Out [][]float64 `json:"out"`
CacheRead [][]float64 `json:"cacheRead"`
}
TokenSeries is tokens per bucket per layer: Out[layer][bucket], and the same for cache reads. Bucket i covers [Start+i*Step, Start+(i+1)*Step).
type Usage ¶ added in v0.7.0
type Usage struct {
At int64 `json:"at"` // Unix seconds the view was built
Families []string `json:"families"`
// Active is the key of the account Claude Code is signed in to now, "" when
// it cannot be told.
Active string `json:"active,omitempty"`
// QuotaErr is why aiquota could not be read, "" when it could.
QuotaErr string `json:"quotaErr,omitempty"`
// Prefs are the viewer's theme and language (settings.toml).
Prefs Prefs `json:"prefs"`
Accounts []AccountUsage `json:"accounts"`
Capacity Capacity `json:"capacity"`
// All is the tokens of every account summed, with an extra last layer for
// what could not be attributed (Layers names them).
All AllTokens `json:"all"`
}
Usage is the Quota tab's data: every account's official usage windows, what was recorded of them, and the tokens the local transcripts hold, per account and summed. It is computed on the server so the browser draws and never aggregates. An account is named by a short hash and a label, never by its e-mail or id.
type WeekTotals ¶ added in v0.7.0
type WeekTotals struct {
Start, End int64 // [Start, End)
InProgress bool
Out []float64 // per family
CacheRead []float64 // per family
// CumOut and CumCacheRead are the running totals over all families at
// 6 hour steps from Start; a window in progress stops at the present.
CumOut []float64
CumCacheRead []float64
// Percent is the last official weekly percentage recorded in the window;
// Recorded is false when none was.
Percent float64
Recorded bool
}
WeekTotals is one 7 day window aligned on the weekly reset.