{"modulePath":"github.com/lichdotdev/lich","version":"v0.93.1","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package codexprofile\n\nPackage 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.\n\nA 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).\n\n## Constants\n\n```go\nconst HomeVar = \"CODEX_HOME\"\n```\nHomeVar is the variable Codex reads its state directory from.\n\n```go\nconst Personal = profilestore.Personal\n```\nPersonal 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\".\n\n## Variables\n\n```go\nvar ErrProfileGone = profilestore.ErrGone\n```\nErrProfileGone 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.\n\n## Functions\n\n```go\nfunc ConfigDir(slug string) (string, error)\n```\nConfigDir is a profile's state directory, Personal's included. A profile that does not exist answers ErrProfileGone.\n\n```go\nfunc Delete(slug string) error\n```\nDelete removes a profile's directory and its login with it. Personal cannot be deleted.\n\n```go\nfunc Dir(slug string) (string, error)\n```\nDir is the CODEX\\_HOME of a profile lich created. It does not check that the profile exists; ConfigDir does.\n\n```go\nfunc EnsureShared(slug string) error\n```\nEnsureShared 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.\n\n```go\nfunc Env(base []string, dir string) []string\n```\nEnv is base with a profile's directory as CODEX\\_HOME and the variables that would override its login removed.\n\n```go\nfunc IsPersonal(slug string) bool\n```\nIsPersonal reports whether slug names the default profile. Empty does too: it is what every session row born before profiles carries.\n\n```go\nfunc MoveConversation(conversationID, toSlug string) error\n```\nMoveConversation moves a Codex conversation from the profile that holds it to another: its rollout, and the images it generated (generated\\_images/\\\u003cid\u003e). 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).\n\nWhat 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.\n\n```go\nfunc PersonalDir() (string, error)\n```\nPersonalDir is the default profile's state directory: what Codex resolves from lich's own environment.\n\n```go\nfunc RolloutIn(dir, conversationID string) (string, bool)\n```\nRolloutIn locates a conversation's rollout under one state directory. Codex files a rollout by the date it started, sessions/\\\u003cyyyy\u003e/\\\u003cmm\u003e/\\\u003cdd\u003e/rollout-\\\u003ctimestamp\u003e-\\\u003cid\u003e.jsonl, so the date parts are globbed rather than reconstructed.\n\n```go\nfunc Root() (string, error)\n```\nRoot is where lich keeps its Codex profiles, beside the Claude Code ones.\n\n## Types\n\n```go\ntype BinResolver interface {\n\tProviderBin(providerID, projectID string) string\n}\n```\nBinResolver supplies the Codex binary: the configured one, or \"\" for the default name on PATH. The store implements it.\n\n```go\ntype Info = api.ProfileInfo\n```\n\n```go\ntype LoginEvent = api.ProfileLogin\n```\n\n```go\ntype Plugin = api.ProfilePlugin\n```\n\n```go\ntype PluginResult = api.ProfilePluginResult\n```\n\n```go\ntype Profile = profilestore.Profile\n```\nProfile is one Codex login lich knows about.\n\n```go\nfunc ConfigDirs() []Profile\n```\nConfigDirs 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.\n\n```go\nfunc Create(name string) (Profile, error)\n```\nCreate makes a profile named name: its directory, laid out against Personal (layout.go), and its sidecar. It does not log in.\n\n```go\nfunc List() ([]Profile, error)\n```\nList is every profile, Personal first and the rest in the order they were created.\n\n```go\nfunc Owner(conversationID string) (Profile, string, bool)\n```\nOwner 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.\n\n```go\nfunc Update(slug string, u profilestore.Update) (Profile, error)\n```\nUpdate changes a profile's name, color or image. The slug and the directory stay.\n\n```go\ntype Service struct {\n\t// contains filtered or unexported fields\n}\n```\nService 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.\n\n```go\nfunc New(bins BinResolver, emit func(name string, data any)) *Service\n```\nNew returns a Service that runs the Codex binary bins resolves and reports a login's progress through emit.\n\n```go\nfunc (s *Service) CancelLogin(_ context.Context, opts api.ProfileSlugOptions) (api.None, error)\n```\nCancelLogin answers cancelLogin over RPC.\n\n```go\nfunc (s *Service) CreateProfile(_ context.Context, opts api.CreateProfileOptions) (Profile, error)\n```\nCreateProfile makes a profile and lays it out against Personal. The window logs it in next (Login).\n\n```go\nfunc (s *Service) DeleteProfile(ctx context.Context, opts api.ProfileSlugOptions) (api.None, error)\n```\nDeleteProfile 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.\n\n```go\nfunc (s *Service) InstallPlugins(_ context.Context, opts api.InstallPluginsOptions) ([]PluginResult, error)\n```\nInstallPlugins 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.\n\n```go\nfunc (s *Service) Login(_ context.Context, opts api.ProfileSlugOptions) (api.None, error)\n```\nLogin 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.\n\nThe 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.\n\n```go\nfunc (s *Service) LoginCommand(_ context.Context, opts api.ProfileSlugOptions) (string, error)\n```\nLoginCommand 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.\n\n```go\nfunc (s *Service) Plugins(_ context.Context, opts api.ProfileSlugOptions) ([]Plugin, error)\n```\nPlugins 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.\n\n```go\nfunc (s *Service) Profiles(_ context.Context, _ api.None) ([]Info, error)\n```\nProfiles lists every profile with its login state. The statuses are asked for at once, one CLI each.\n\n```go\nfunc (s *Service) SetAccount(account func(slug string) (email, plan string))\n```\nSetAccount 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.\n\n```go\nfunc (s *Service) SetLichPlugin(install func(slug string) error, key string)\n```\nSetLichPlugin wires the lich plugin: install puts it into a profile and key is the plugin@marketplace it installs. Startup wiring.\n\n```go\nfunc (s *Service) SetSessions(inUse func(slug string) int, forget func(slug string) error)\n```\nSetSessions 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.\n\n```go\nfunc (s *Service) UpdateProfile(_ context.Context, opts api.UpdateProfileOptions) (Profile, error)\n```\nUpdateProfile changes a profile's name, color or image and returns it; its directory never moves.\n\n","path":"github.com/lichdotdev/lich/internal/codexprofile","name":"codexprofile","synopsis":"Package codexprofile keeps more than one Codex login on one machine, the way internal/claudeprofile does for Claude Code.","isRedistributable":true}
