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 ¶
func ParseColor ¶ added in v0.12.0
ParseColor is the one place a colour is accepted: exactly "#" and six hex digits (either case), returned in lower case. Nothing else is a colour -- no name, no short form, no rgb() or url() -- so a stored value can never carry markup or CSS.
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 Colors ¶ added in v0.12.0
type Colors struct {
// contains filtered or unexported fields
}
Colors are the colours the owner gave accounts, by account hash, kept in dir/account-colors.toml next to the aliases:
"7567" = "#e69f00"
An account without an entry keeps its automatic colour. A missing or corrupt file means no colour at all; one entry that is not a colour is dropped, the others are kept. The file is read through a size bound and written atomically, mode 0600, only by the serve process.
func NewColors ¶ added in v0.12.0
NewColors keeps colours in dir/account-colors.toml and loads them. A key is the first 4 hex digits of an account hash or the whole hash, as for Aliases.
func (*Colors) Color ¶ added in v0.12.0
Color is the colour of the account with the hash key, "" when it has none (its automatic colour applies).
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 Prefs ¶ added in v0.13.0
type Prefs struct {
// contains filtered or unexported fields
}
Prefs are the viewer's theme and language, kept in dir/settings.toml next to account-colors.toml:
theme = "dark" lang = "fr"
A missing or corrupt file means nothing chosen; a value that is not a theme or a language is dropped, the other is kept. The file is read through a size bound and written atomically, mode 0600, only by the serve process.
func NewPrefs ¶ added in v0.13.0
NewPrefs keeps the preferences in dir/settings.toml and loads them.
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.