Documentation
¶
Overview ¶
Package usagefeed fills the machine's usage outbox (internal/usageoutbox) from the facts of the agent CLIs' transcripts (internal/usagereport): a `call` record for every model call and a `session` record for every session that is new or changed (docs/hub/usage.md). It copies numbers and ids, never the text of a conversation: the facts it reads hold none, and a record has no field that could carry any.
Index ¶
Constants ¶
const ( // DefaultMaxPending and DefaultMaxBytes bound what waits for the hub's acknowledgement: a hub that stops reading // does not make the outbox grow without end. Reaching either pauses the feed; nothing is dropped. DefaultMaxPending = 200_000 DefaultMaxBytes = 64 << 20 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Outbox *usageoutbox.Outbox
Source Source
// StatePath keeps what was already written, so a restart does not write it all again.
StatePath string
// Identity says which account and endpoint a provider's CLI uses now; nil knows nothing.
Identity func(provider string) Identity
// SessionIdentity says which account and endpoint a session ran on, when the runtime noted it at the launch (a chat
// on a provider the person added, or on another account of one); ok is false for a session nobody noted, which is
// then the CLI's own. nil knows none.
SessionIdentity func(provider, sessionID string) (Identity, bool)
// Now is the clock (tests move it); nil is the real one.
Now func() time.Time
// MaxPending and MaxBytes cap the unacknowledged records (count, bytes on disk); zero is the default.
MaxPending int
MaxBytes int64
// SkillMetrics adds skillsListed and skillsLoaded to the sessions' metrics. Off unless the machine's
// fleet flag turned it on.
SkillMetrics bool
}
Config is what the feed needs.
type Feed ¶
type Feed struct {
// contains filtered or unexported fields
}
Feed writes the outbox.
func New ¶
New loads the state. A state of another epoch than the outbox's (the folder was made anew) is forgotten.
type Identity ¶
type Identity struct {
AccountRef string
AuthMode string // subscription, api_key, ""
BaseURLHost string // "" for the CLI's default
}
Identity is what the machine can say of the account its agent CLI uses now: never a key or a token, only a stable name of the account (docs/hub/usage.md, accountRef), how it signs in, and where its calls go.
type Local ¶
Local reads the identity from what the CLIs keep on this machine. Getenv is the environment a CLI would be started with (the agent's env files over its own); Home is the account's home.
type Source ¶
type Source interface {
Refresh()
Entries() []usagereport.Entry
}
Source is the transcripts' facts; usagereport.Collector is one.