Skip to content

feat(openai): read subscription API credits through a local-storage plugin capability - #5100

Open
fcakyon wants to merge 3 commits into
steipete:mainfrom
fcakyon:feat/plugin-browser-local-storage
Open

fcakyon wants to merge 3 commits into
steipete:mainfrom
fcakyon:feat/plugin-browser-local-storage

Conversation

@fcakyon

@fcakyon fcakyon commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Design question for @steipete: would you accept a bundled-only browser-local-storage host capability, so the OpenAI subscription credit lookup can live in a JavaScript plugin? When you closed #5036 you wrote: "A plugin-compatible credential contract, or an approved host capability for this discovery, would change that decision." This draft is that capability plus the plugin, so the shape can be judged in code. If the answer is no, closing it is fine. Refs #5034 and #4844.

  • ctx.browser.localStorage(origin, key) returns one { id, label, value } per Chromium profile that holds the key, in the default browser order. It reuses BrowserLocalStorageAPI.live, the same discovery the DeepSeek importer uses, so no Keychain prompt and no WebView
  • Bundled plugins only. The manifest declares localStorage: [{ origin, keys }] next to the capability, validated like cookieDomains. An undeclared origin or key, a user-installed plugin, and the off or manual cookie sources are denied before any read
  • Opt-in by source: only --source web gets a resolver, so auto and api take the same path as main. openai.js, OPENAI_ALLOW_BALANCE_FALLBACK and the Linux sess- route are untouched. The web mode is declared on macOS only, so CLI source checks on other platforms do not change
  • Returned values go into the redaction set, and both engines call one shared helper
  • New openai-platform.ts plugin, built like gemini-web: reads oai-auth:onboard, skips JWTs whose exp has passed, POST /v1/dashboard/onboarding/login, then GET /v1/dashboard/billing/credit_grants with the sess- key. It tries the next profile on a 401 and never refreshes, stores or rotates a token
  • Not in this PR: the Settings source picker and menu card polish, so the CLI and JSON output are the contract here
$ codexbar usage --provider openai --source web
API credit   $113.51 of $124.00 left · Expires Nov 26

Two identical live runs on ChatGPT Pro. --source auto and --source api return the same HTTP 403 message as v0.84.0.

Questions for you:

  1. Should the host return the raw value, as ctx.browser.cookieHeader does, or an opaque handle like ctx.browser.sessions for request-url cookies?
  2. Is one capability with an origin and key allowlist enough, or should a grant be provider-specific?
  3. Should the Settings picker land in this PR or a follow-up?

Adds a bundled-only browser-local-storage host capability and an openai-platform plugin behind the opt-in web source.
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 16, 2026
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codex review: blocked before merge.

What this changes

This PR adds an opt-in macOS OpenAI credit source through a bundled-plugin browser local-storage capability.

Example: A ChatGPT Pro subscriber runs codexbar usage --provider openai --source web.

  • Before: The OpenAI provider has no browser-session source for discovering subscription API credits.
  • After: The supplied live CLI output shows $113.51 of $124.00 remaining, expiring November 26.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The supplied CLI proof supports the feature and both prior defects are fixed; the unresolved capability direction caps overall readiness.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The contributor records the shipped macOS CLI web source returning subscription-credit amounts in two live runs and compares unchanged auto/api behavior with v0.84.0; the earlier native screenshots are excluded from plugin-path proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Subscribers cannot automatically discover and inspect their subscription-linked OpenAI API credits through the existing OpenAI provider.
Reason: The CLI-focused proposal has demonstrated value, but it introduces a new bundled-plugin credential capability without recorded approval of this contract.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open for an owner decision on the proposed browser local-storage capability; both earlier findings are addressed, and no new blocking defect was identified.

Priority: P2
Reviewed head: 2d9428fbf8aa0050ec85734a409640b503d8cdb9
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should this PR expose raw, origin/key-allowlisted browser local-storage values to bundled plugins for the opt-in OpenAI web source?
  • Recommendation: Approve the bounded bundled capability: Accept the explicit-web, macOS-only origin/key grant design and keep the Settings picker as follow-up work.
  • Why: The earlier maintainer decision invited a capability proposal, but no recorded approval chooses this raw-value contract over an opaque broker or explicitly provisioned session credential.

Before merge

  • Await maintainer action - The plugin-host owner must approve the proposed bundled browser local-storage contract or specify the accepted alternative.

Findings

None.

Tests

  • Missing end-to-end proof: A base-fail/head-pass execution of the added account-routing and HTTP-error regression tests is not shown.
Agent review details

How this fits together

The provider fetch pipeline supplies a capability-gated browser-storage reader to the plugin engines; the OpenAI script exchanges a discovered access token for a Platform session and returns credit data through the shared app and CLI snapshot contract.

flowchart TD
  A[Explicit web source] --> B[OpenAI provider strategy]
  B --> C[Plugin runtime and grant checks]
  C --> D[Chromium local storage]
  D --> E[OpenAI Platform plugin]
  E --> F[OpenAI session and grants endpoints]
  F --> G[Shared usage snapshot]
  G --> H[CLI output]
Loading

Technical review

Best possible solution:

Land an owner-approved plugin credential contract that enables subscription-credit reads while preserving existing API credentials, project scoping, and Linux balance access.

Do we have a high-confidence way to reproduce the issue?

Current main exposes only auto/api OpenAI sources and lacks plugin browser local-storage discovery; the contributor supplies live CLI evidence for the added web source.

Is this the best way to solve the issue?

The implementation follows the requested plugin ownership boundary and reuses existing discovery and account-routing helpers, but its credential API remains an owner choice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1f6da9bec444.

Provenance checked

  • OpenAI plugin ownership and API fallback keeps the original intent (a634f55: The plugin cutover retained typed history, project scoping, and billing fallback while removing native fetchers.)
  • Shared browser capability enforcement keeps the original intent (94efcfd: Browser credential access belongs in declared shared host capabilities with origin restrictions and redaction.)
  • Saved-account and project authority keeps the original intent (807d07d: Selected token accounts must not inherit an unrelated configured project or silently receive unscoped billing results.)
  • Descriptor-owned cost presentation keeps the original intent (4cdb349: Provider descriptors own cost presentation, including OpenAI spend styling.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 94efcfd adds Sources/CodexBarCore/Plugins/ProviderPluginManifest.swift:56 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 94efcfdf4a4b; files: Sources/CodexBarCore/Plugins/ProviderPluginManifest.swift)
  • Matt Stallone: Raw commit 807d07d adds Tests/CodexBarTests/OpenAIAPIProjectScopeTests.swift:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 807d07d0c4d2; files: Tests/CodexBarTests/OpenAIAPIProjectScopeTests.swift)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: ⏳ waiting on maintainer.
  • remove merge-risk: 🚨 auth-provider: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.

Label justifications:

  • P2: This is a useful opt-in provider feature with existing default and Linux routes preserved.
  • merge-risk: 🚨 compatibility: The PR extends the plugin manifest and context contract with a new credential-access capability whose permanent shape awaits owner acceptance.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-16T08:56:37.581Z sha 3407586 :: blocked before merge. :: [P1] Honor saved API-account selection before choosing the web strategy | [P2] Give users a recovery action for Platform HTTP failures

Reviewed November 16, 2026, 10:46 AM ET / 15:46 UTC (Revision 2).

@fcakyon

fcakyon commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. labels Nov 16, 2026
@fcakyon
fcakyon marked this pull request as ready for review November 16, 2026 20:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T20:54:39.453039Z 2d9428f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d9428fbf8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant