Documentation
¶
Overview ¶
Package accounts is what agentscope knows about WHO a call was made as: the signed-in account (read from ~/.claude.json), the stamps the `stamp` hook appends when it changes, and the display names the owner gives accounts.
An account is known by a short hash of its id and a label; its e-mail and its id are never kept. The organisation's name is read only when the owner asks for it (--show-org), and only to suggest a display name.
Index ¶
Constants ¶
const (
// MaxName is the longest display name, in bytes.
MaxName = 64
)
Bounds on the alias file: it is a hand-edited list of a few accounts.
const ( // RotateBytes is the size past which accounts.jsonl is renamed to // accounts.jsonl.1 (the previous one is dropped): a stamp is written once per // CHANGE of account, so a file this large is years of switching. RotateBytes = 256 << 10 )
Bounds on the stamp file.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aliases ¶
type Aliases struct {
// contains filtered or unexported fields
}
Aliases are the display names the owner gave accounts, by account hash, kept in dir/accounts.toml:
"7567" = "Labo (team)"
A missing or corrupt file means no alias at all, never an error on screen: the account is then shown as "label #hash". The file is written atomically, mode 0600, only by the serve process.
func NewAliases ¶
NewAliases keeps aliases in dir/accounts.toml and loads them. A key is the first 4 hex digits of an account hash (what the screen shows after "#") or the whole hash.
func (*Aliases) Name ¶
Name is the display name of the account with the hash key, "" when it has none.
type Identity ¶
type Identity struct {
// Key is the 8 hex digit hash of the account id (see quota.AccountKey).
Key string
// Label is "Claude Code", and its plan in brackets when one is known.
Label string
// Plan is the subscription ("team", "max", ...), "" when unknown.
Plan string
// Org is the organisation's name: set only when the caller asked for it.
Org string
}
Identity is the signed-in account as agentscope names it.
func ReadIdentity ¶
ReadIdentity reads the signed-in account from the .claude.json at path. ok is false when the file cannot be read, is no JSON object, or names no account: nothing is guessed. withOrg says whether the organisation's name is read.
type Stamp ¶
type Stamp struct {
At time.Time `json:"at"`
SessionID string `json:"session_id,omitempty"`
AccountHash string `json:"account_hash"`
Label string `json:"label,omitempty"`
Plan string `json:"plan,omitempty"`
}
Stamp says that from At on, calls were made as an account: what the `stamp` hook appends, once per change of account, to accounts.jsonl.
type Stamps ¶
type Stamps struct {
// contains filtered or unexported fields
}
Stamps is the stamp file in a directory.
type Timeline ¶
type Timeline struct {
// contains filtered or unexported fields
}
Timeline is the stamps, oldest first.
func (Timeline) At ¶
At is the account a call at t was made as: the latest stamp at or before t. ok is false when no stamp is that old.