CLI to manage multiple AI auth profiles and usage in one place.
- Stores multiple
codexandcopilotprofiles in one local store. - Switches the active Codex profile and applies it to Codex CLI auth.
- Fetches usage data for saved profiles with caching and concurrency controls.
- Supports per-profile notes for account context.
- Bun
>= 1.3(required at runtime) - npm (optional, only if you install via npm)
agentbar is distributed through npm, but the executable runs with Bun (#!/usr/bin/env bun).
Recommended (Bun):
bun add -g agentbar
agentbar --helpAlternative (npm):
npm install -g agentbar
agentbar --helpUpdate:
bun update -g agentbar
# or, if installed via npm:
npm update -g agentbarCheck installed version:
agentbar --version
# or:
agentbar -vLogin and save profiles:
agentbar login codex
agentbar login copilotList accounts:
agentbar accounts
agentbar accounts --jsonSwitch active Codex profile:
agentbar switch codex alice@example.comCheck usage:
agentbar usage
agentbar usage --provider codexSet and clear notes:
agentbar note set codex alice@example.com "Work account"
agentbar note clear codex alice@example.comDelete saved profiles:
agentbar delete codex alice@example.com --yes
agentbar delete copilot alice@example.com --yesactiveinagentbar accountsmeans the profile currently applied to Codex CLI.- Only Codex supports active switching in
agentbar. - Copilot rows are always inactive and usage-only.
- Profile selection is case-insensitive by email.
- If multiple profiles share the same email, provide
--plan. - If required selectors are omitted in a TTY session,
agentbarprompts interactively. - In non-interactive mode, ambiguous selectors fail with an error.
agentbar delete ...requires--yesoutside interactive TTY.note setwithout note text requires interactive input; otherwise it fails.
agentbar switch codex writes to:
$CODEX_HOME/auth.jsonwhenCODEX_HOMEis set~/.codex/auth.jsonotherwise
agentbar login codex
agentbar login copilot
agentbar accounts [provider] [--json]
agentbar switch codex [email] [--plan <plan>] [--json]
agentbar delete codex [email] [--plan <plan>] [--yes] [--json]
agentbar delete copilot [email] [--plan <plan>] [--yes] [--json]
agentbar usage [provider] [--provider codex|copilot] [--refresh] [--json]
agentbar note set <provider> [email] [note...] [--plan <plan>] [--json]
agentbar note clear <provider> [email] [--plan <plan>] [--json]
agentbar config [--json]
agentbar config list [--json]
agentbar config get <key> [--json]
agentbar config set <key> <value> [--json]
agentbar config unset <key> [--json]
Paths:
- Profile store:
~/.agentbar/store.json - Config:
~/.agentbar/config.json - Usage cache:
~/.agentbar/usage-cache.json
Security model:
- Tokens are stored as plain JSON on disk.
- Treat
~/.agentbar/store.jsonas a password file. - Do not share or commit local store/config/cache files.
- On POSIX systems, files are written with
0600. - Store and cache writes use file locking for safer concurrent access.
Set and read config values:
agentbar config list
agentbar config get usage.timeoutMs
agentbar config set usage.timeoutMs 8000
agentbar config unset usage.timeoutMsSupported keys:
usage.timeoutMs(default10000, non-negative integer)usage.ttlMs(default60000, non-negative integer)usage.errorTtlMs(default10000, non-negative integer)usage.concurrency(default4, positive integer)
Usage cache behavior:
- Successful rows are cached for
usage.ttlMs. - Error rows are cached for
min(usage.errorTtlMs, usage.ttlMs). - Use
agentbar usage --refreshto bypass cache.
- Use
--jsonon list/switch/delete/usage/note/config commands for machine-readable output. NO_COLOR=1disables ANSI colors.FORCE_COLOR=1forces ANSI colors.AGENTBAR_DEBUG_TIMING=1prints per-profile timing to stderr.AGENTBAR_DEBUG_STACK=1prints stack traces for unexpected errors.
git clone https://github.com/nbsp1221/agentbar
cd agentbar
bun install
bun run src/index.ts --help
bun run testWatch mode:
bun run test:watchnpm publish is automated by GitHub Actions on v* tag pushes.
npm version patch
git push origin main --follow-tagsCurrent workflow publishes with npm publish --provenance.
Current auth model: npm trusted publishing (OIDC).
One-time npm setup is required before the first release:
- Open npm package settings for
agentbar. - Add a Trusted Publisher for this GitHub repository/workflow.
- Target workflow file:
.github/workflows/publish-npm.yml.
After trusted publisher is configured, no NPM_TOKEN repository secret is needed.
agentbar is not affiliated with OpenAI or GitHub.