@bumpyclock/pi-codex-compat

Pi extension consolidating OpenAI Codex fast mode, native compaction, named OAuth accounts, live quota, historical usage, and token throughput status.

Packages

Package details

extension

Install @bumpyclock/pi-codex-compat from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@bumpyclock/pi-codex-compat
Package
@bumpyclock/pi-codex-compat
Version
0.2.0
Published
Jul 27, 2026
Downloads
134/mo · 31/wk
Author
bumpyclock
License
MIT
Types
extension
Size
300.9 KB
Dependencies
1 dependency · 3 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@bumpyclock/pi-codex-compat

One Pi extension that consolidates OpenAI/Codex-focused behavior:

  • /fast priority service tier (service_tier: "priority") for verified OpenAI Codex Responses requests
  • OpenAI native compaction replay for openai and openai-codex Responses APIs
  • Named OpenAI Codex OAuth accounts (/accounts)
  • Live Codex subscription quota (/usage)
  • Historical Pi/Codex CLI cost report (/usage-history)
  • Token throughput status (all providers)
  • Unified /codex manager menu

Minimum tested Pi release: 0.82.1 (@earendil-works/*).

Install

pi install npm:@bumpyclock/pi-codex-compat

Or from a local checkout:

pi install /absolute/path/to/pi-codex-compat

Important migration notes

Do not load this package together with:

  • local openai-codex-fast-mode.ts
  • local openai-compaction
  • local usage.ts / token-rate-status.ts
  • pi-accounts / pi-codex-accounts
  • pi-usage / pi-codex-usage

Duplicate extensions can refresh the same rotating credential or register conflicting commands.

Disable or remove those local/extension copies before enabling this package.

Commands

Command Modes Behavior
/codex TUI menu Accounts, Quota, Fast mode, Historical usage, Settings, Status, Help
/codex status TUI, RPC Feature status
/codex help TUI, RPC Help text
/accounts TUI Named Codex OAuth account manager
/usage TUI Live Codex subscription quota
/usage-history TUI, RPC Agent-driven historical cost report
/fast [toggle|on|off|status] TUI, RPC Priority tier toggle
Alt+Shift+F TUI Toggle fast mode

Print and JSON modes throw a clear unsupported-mode error for these commands because Pi 0.82.1 has no observable extension-command output channel there. RPC receives a notification for TUI-only menus.

Settings

Canonical user settings:

~/.pi/agent/pi-codex-compat.json

Trusted project overrides (non-secret only):

<workspace>/.pi/pi-codex-compat.json

Private Codex account credentials:

~/.pi/agent/pi-codex-compat-accounts.json

Example:

{
  "fastMode": { "enabled": false },
  "openaiNativeCompaction": {
    "enabled": true,
    "debug": false,
    "redactSensitiveData": true,
    "supportedProviders": ["openai", "openai-codex"],
    "supportedApis": ["openai-responses", "openai-codex-responses"]
  },
  "tps": {
    "enabled": true,
    "notifyOnComplete": true
  },
  "auth": {
    "disableApiKeyWhenCodexAuthenticated": false
  }
}

Auth cost-safety policy

auth.disableApiKeyWhenCodexAuthenticated (default false) is an opt-in guard:

  • When on and a Codex OAuth login exists (default Pi openai-codex OAuth in auth.json, or a named account selected by this extension), every exact provider openai model is hidden — including built-ins and models.json additions.
  • Stale sessions still selecting openai are blocked on each turn, compaction, and summarizing tree navigation. Non-summarizing tree navigation stays allowed.
  • openai-codex and unrelated providers are unchanged. The policy never auto-switches models and never mutates OPENAI_API_KEY or credential files.
  • When auth storage cannot be read, presence is treated as unknown and the policy fails closed while enabled.
  • Toggle from /codex → Settings. Status shows Direct OpenAI API key: allowed|blocked while Codex is logged in.

Precedence

Defaults → old package-local compaction settings → legacy global settings.json → canonical user settings → legacy project settings.json → canonical project settings → PI_OPENAI_NATIVE_COMPACTION_* environment overrides.

Canonical values win over legacy values at the same scope. Environment overrides win over all files. Validated recognized values are migrated into canonical files; legacy sources are retained for rollback.

Legacy sources consulted when canonical values are absent:

  • ~/.pi/agent/settings.jsonextensionSettings.openaiCodexFastMode
  • ~/.pi/agent/extensions/openai-compaction/settings.json
  • openaiNativeCompaction in global/project settings.json
  • PI_OPENAI_NATIVE_COMPACTION_*
  • pi-accounts.json → only the openai-codex provider section
  • pi-codex-accounts.json / codex-accounts.json

Security and failure behavior

  • Account activation failures fail closed for openai-codex (no silent fallback credential).
  • When auth.disableApiKeyWhenCodexAuthenticated is enabled, unknown/corrupt Codex auth storage fails closed for direct openai API-key use (hide/block with a redacted error).
  • The auth.json presence reader is extension-owned and read-only: it never creates or writes auth.json, and never logs token fields.
  • Compaction failures fail open to Pi's normal compaction.
  • Quota requests send credentials only to the official ChatGPT origin (https://chatgpt.com) and use bounded response reads.
  • Debug artifacts redact authorization headers, API keys, JWT-like values, and exact credential strings.
  • Credential files use private directory permissions and mode 0600 on POSIX.
  • Pi extensions run with full user permissions. Only install packages you trust. See Pi's unsandboxed extension trust model.

Development

npm install
npm run format
npm run check
npm run pack:dry
npm run smoke:pi

Releases

Merges to main update a Release Please pull request. Merging that release pull request creates a GitHub release and publishes the matching package version through .github/workflows/release.yml.

The workflow uses npm trusted publishing with GitHub Actions OIDC and provenance; it does not require a long-lived npm token. Manual runs default to a dry run. Choose release only when package.json contains the version to release.

License

MIT. See LICENSE and NOTICES.md for adapted upstream attribution (Jordy Van Domselaar; narumiruna).