codexaccounts

package
v0.16.521 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package codexaccounts keeps more than one sign-in of the Codex CLI on a machine. Codex keeps its sign-in in $CODEX_HOME/auth.json and renews it there itself, so a second sign-in is a second home, and the home is the sign-in's own whole: its auth.json, its sessions, its databases and everything else the CLI writes. Nothing in it is a link to the main home, and the main home (the CLI's own, ~/.codex) is only ever read. What a person sets up by hand there (settings) is copied into the sign-in's home before a launch on it (Sync), so the main home stays the one place to change it.

Index

Constants

View Source
const (
	MaxAccounts = 8
	MaxName     = 60
)

MaxAccounts caps the sign-ins of a machine; MaxName a name's length in runes.

Variables

View Source
var (
	ErrNotFound = errors.New("codexaccounts: no such account")
	ErrTooMany  = errors.New("codexaccounts: too many accounts")
	ErrBadName  = errors.New("codexaccounts: the name is empty, too long or taken")
)

The refusals the caller is told.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	// Main: a new Codex chat that names no sign-in is offered this one first. One account at most; none means the
	// CLI's own home.
	Main bool `json:"main,omitempty"`
}

Account is one more sign-in of Codex beside the main one (the main one is the CLI's own home and is not listed).

type Store

type Store struct {
	// Dir is the runtime's data folder: the list is <Dir>/v2/codex-accounts.json, a home <Dir>/codex-accounts/<id>.
	Dir  string
	Main string
	// contains filtered or unexported fields
}

Store keeps the accounts of a data folder. Main is the CLI's own home (~/.codex or $CODEX_HOME).

func (*Store) Add

func (s *Store) Add(name string) (Account, error)

Add makes an account and its home (not signed in yet).

func (*Store) AuthFile

func (s *Store) AuthFile(id string) string

AuthFile is the auth.json of an account.

func (*Store) Home

func (s *Store) Home(id string) string

Home is the CODEX_HOME of an account. It is named .codex like the main one, so a transcript in it reads as Codex's wherever a path is told apart by that name.

func (*Store) List

func (s *Store) List() ([]Account, error)

List is the accounts in the order they were added.

func (*Store) Remove

func (s *Store) Remove(id string) error

Remove forgets an account and takes its home away: its sign-in, its sessions and its copies of the settings. The main home has nothing of it.

func (*Store) Rename

func (s *Store) Rename(id, name string) (Account, error)

Rename gives an account another name.

func (*Store) SetMain

func (s *Store) SetMain(id string) error

SetMain makes an account the one a new chat is offered first; "" gives that back to the CLI's own home.

func (*Store) SignedIn

func (s *Store) SignedIn(id string) bool

SignedIn says whether an account's home has a sign-in.

func (*Store) Sync

func (s *Store) Sync(id string) error

Sync copies the settings of the main home into an account's home: each as the main home has it now, and none the main home lost. Everything else in the account's home is left as it is. It is called before every launch on the account.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL