codexprofile

package
v0.93.0-rc.14 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 21 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 codexprofile keeps more than one Codex login on one machine, the way internal/claudeprofile does for Claude Code. A profile is a state directory of its own (CODEX_HOME) holding its own `codex login`, so every account runs with its full login. The default profile, Personal, is whatever Codex reads without lich's help: CODEX_HOME from lich's environment, else ~/.codex.

A profile directory is never moved once it exists, and renaming a profile changes its display name only: the slug names the directory, and Codex may key a login on the directory string (its keyring store does).

Index

Constants

View Source
const HomeVar = "CODEX_HOME"

HomeVar is the variable Codex reads its state directory from.

View Source
const Personal = profilestore.Personal

Personal is the slug of the default profile. It is reserved: no profile lich creates can take it, which is what lets a project setting name Personal explicitly where an empty value means "inherit the global one".

Variables

View Source
var ErrProfileGone = profilestore.ErrGone

ErrProfileGone is the error a spawn returns for a session born in a profile that was deleted since. The window matches it to offer a new session in the project's own profile instead.

Functions

func ConfigDir

func ConfigDir(slug string) (string, error)

ConfigDir is a profile's state directory, Personal's included. A profile that does not exist answers ErrProfileGone.

func Delete

func Delete(slug string) error

Delete removes a profile's directory and its login with it. Personal cannot be deleted.

func Dir

func Dir(slug string) (string, error)

Dir is the CODEX_HOME of a profile lich created. It does not check that the profile exists; ConfigDir does.

func EnsureShared

func EnsureShared(slug string) error

EnsureShared links into a profile the shared entries Personal gained since the profile was made and rebuilds its config.toml from Personal's, which runs before every spawn into it.

func Env

func Env(base []string, dir string) []string

Env is base with a profile's directory as CODEX_HOME and the variables that would override its login removed.

func IsPersonal

func IsPersonal(slug string) bool

IsPersonal reports whether slug names the default profile. Empty does too: it is what every session row born before profiles carries.

func MoveConversation

func MoveConversation(conversationID, toSlug string) error

MoveConversation moves a Codex conversation from the profile that holds it to another: its rollout, and the images it generated (generated_images/<id>). The target's own thread database learns the conversation from the rollout the next time Codex reads it (measured on 0.162.1: a rollout alone in an empty home was found by id and indexed there).

What stays behind is what is not keyed by the id: the prompt history (history.jsonl), and the source's thread database row: that database is Codex's, and lich leaves it alone.

func PersonalDir

func PersonalDir() (string, error)

PersonalDir is the default profile's state directory: what Codex resolves from lich's own environment.

func RolloutIn

func RolloutIn(dir, conversationID string) (string, bool)

RolloutIn locates a conversation's rollout under one state directory. Codex files a rollout by the date it started, sessions/<yyyy>/<mm>/<dd>/rollout-<timestamp>-<id>.jsonl, so the date parts are globbed rather than reconstructed.

func Root

func Root() (string, error)

Root is where lich keeps its Codex profiles, beside the Claude Code ones.

Types

type BinResolver

type BinResolver interface {
	ProviderBin(providerID, projectID string) string
}

BinResolver supplies the Codex binary: the configured one, or "" for the default name on PATH. The store implements it.

type Info

type Info = api.ProfileInfo

type LoginEvent

type LoginEvent = api.ProfileLogin

type Plugin

type Plugin = api.ProfilePlugin

type PluginResult

type PluginResult = api.ProfilePluginResult

type Profile

type Profile = profilestore.Profile

Profile is one Codex login lich knows about.

func ConfigDirs

func ConfigDirs() []Profile

ConfigDirs is every profile, Personal first. Every reader of Codex's rollouts scans all of them: a conversation lives in exactly one, and which one is what says the profile it belongs to.

func Create

func Create(name string) (Profile, error)

Create makes a profile named name: its directory, laid out against Personal (layout.go), and its sidecar. It does not log in.

func List

func List() ([]Profile, error)

List is every profile, Personal first and the rest in the order they were created.

func Owner

func Owner(conversationID string) (Profile, string, bool)

Owner is the profile holding a Codex conversation, and the path of its rollout there. A conversation id is a UUID and lives in exactly one profile, so the first match is the only one.

func Update added in v0.75.0

func Update(slug string, u profilestore.Update) (Profile, error)

Update changes a profile's name, color or image. The slug and the directory stay.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the window's door to the Codex profiles: listing them with their login state, creating, renaming and deleting them, logging one in, and porting plugins between them.

func New

func New(bins BinResolver, emit func(name string, data any)) *Service

New returns a Service that runs the Codex binary bins resolves and reports a login's progress through emit.

func (*Service) CancelLogin

func (s *Service) CancelLogin(_ context.Context, opts api.ProfileSlugOptions) (api.None, error)

CancelLogin answers cancelLogin over RPC.

func (*Service) CreateProfile

func (s *Service) CreateProfile(_ context.Context, opts api.CreateProfileOptions) (Profile, error)

CreateProfile makes a profile and lays it out against Personal. The window logs it in next (Login).

func (*Service) DeleteProfile

func (s *Service) DeleteProfile(ctx context.Context, opts api.ProfileSlugOptions) (api.None, error)

DeleteProfile removes a profile and its login, and clears every setting that named it, so a project set to it falls back to the global profile. It refuses while a session runs in it. A parked session born in it fails to resume with ErrProfileGone.

func (*Service) InstallPlugins

func (s *Service) InstallPlugins(_ context.Context, opts api.InstallPluginsOptions) ([]PluginResult, error)

InstallPlugins installs each plugin@marketplace into a profile through Codex's own `plugin add`, run as that profile so Codex writes its own paths. A marketplace the profile has not declared is declared as Personal declares it, its ref included, and fetched first. One result per key, in order; one failure does not stop the rest.

func (*Service) Login

func (s *Service) Login(_ context.Context, opts api.ProfileSlugOptions) (api.None, error)

Login runs `codex login` as a profile. The CLI opens the browser itself and waits for the sign-in page's callback on localhost:1455; what it prints, the fallback address included, arrives as LoginEvent output. When the CLI exits, `codex login status` decides whether the login took. It returns once the CLI is started.

The callback port is fixed, so two logins cannot run at once, in lich or outside it: the second CLI says the port is taken, in its own words.

func (*Service) LoginCommand

func (s *Service) LoginCommand(_ context.Context, opts api.ProfileSlugOptions) (string, error)

LoginCommand is the command line that logs a profile in from a terminal, for a user who would rather run it in a shell card than through Login.

func (*Service) Plugins

func (s *Service) Plugins(_ context.Context, opts api.ProfileSlugOptions) ([]Plugin, error)

Plugins lists the plugins a profile has installed, the ones a port can carry to another profile, in its config.toml's order. The lich plugin is not among them.

func (*Service) Profiles

func (s *Service) Profiles(_ context.Context, _ api.None) ([]Info, error)

Profiles lists every profile with its login state. The statuses are asked for at once, one CLI each.

func (*Service) SetAccount

func (s *Service) SetAccount(account func(slug string) (email, plan string))

SetAccount wires the question of whose login a profile holds and on which plan: the quota service's reading of the profile's own directory (quota.CodexProfilePlan), which asks upstream and is cached there. Startup wiring; without it a logged-in profile carries no account.

func (*Service) SetLichPlugin

func (s *Service) SetLichPlugin(install func(slug string) error, key string)

SetLichPlugin wires the lich plugin: install puts it into a profile and key is the plugin@marketplace it installs. Startup wiring.

func (*Service) SetSessions

func (s *Service) SetSessions(inUse func(slug string) int, forget func(slug string) error)

SetSessions wires the two questions a delete asks: how many live sessions run in a profile, and how to forget the settings that name it. Startup wiring.

func (*Service) UpdateProfile added in v0.75.0

func (s *Service) UpdateProfile(_ context.Context, opts api.UpdateProfileOptions) (Profile, error)

UpdateProfile changes a profile's name, color or image and returns it; its directory never moves.

Jump to

Keyboard shortcuts

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