Skip to content

feat: add Muse (Meta) provider - #2936

Open
toml0006 wants to merge 17 commits into
steipete:mainfrom
toml0006:feat/muse-provider
Open

feat: add Muse (Meta) provider#2936
toml0006 wants to merge 17 commits into
steipete:mainfrom
toml0006:feat/muse-provider

Conversation

@toml0006

@toml0006 toml0006 commented Aug 14, 2026

Copy link
Copy Markdown

Summary

Adds native Muse (Meta) support to CodexBar — previously un-tracked. Muse's Meta Model API (https://api.meta.ai, model muse-spark-1.1, pricing $1.25/$4.25 per 1M) had no provider; users proxying via OpenRouter paid the 5.5% credit fee and lost direct visibility.

Provider design

  • Auth: API key via MUSE_API_KEY / META_API_KEY / META_MUSE_API_KEY env or ~/.codexbar/config.json (muse apiKey). Projects to MUSE_API_KEY for CLI (codexbar usage --provider muse).
  • Base URL: default https://api.meta.ai, overridable via Settings → Providers → Muse → API base URL or MUSE_API_URL (enables LiteLLM/self-hosted proxies while keeping visibility). Validated via ProviderEndpointOverrideValidator().validatedURLAllowingLoopbackHTTP — requires https://, allows only http://localhost/127.0.0.1/::1 for local proxy, rejects user info (user:pass@host), encoded host delimiters (%2f/%40 etc.), missing/unsafe hosts, before sending Authorization: Bearer. Covered by focused tests.
  • Fetch: MuseAPIFetchStrategy (.api only) → MuseUsageFetcher:
    1. Best-effort billing probe in order: /v1/billing/usage, /v1/me/balance, /v1/billing/subscription, /v1/credits — flexible JSON parser handles available_balance/balance/total_balance (string or number) in root or data envelope. Rejects currency-only payloads (requires numeric balance).
    2. Fallback to GET /v1/models validation — returns API key valid · N models available when billing is not yet exposed. Both paths use Authorization: Bearer <key>, 15s timeout, 404 tries next, 401/403 surfaces as invalid key (models-probe 401 now takes precedence over stale billing lastError). Rejects malformed {} with parseFailed: Models response missing data/models array instead of incorrectly reporting API key valid.
  • Snapshot: balanceOnly: true (identity-only, no rate windows) — pay-as-you-go API, consistent with Moonshot/DeepSeek billing-only providers.
  • UI: Settings fields for API key (secure) + base URL (plain), dashboard link to https://ai.developer.meta.com/. Branding: Meta blue #0064E0, confetti [#0064E0, #0469FF, #7B61FF], icon ProviderIcon-muse.svg. Added museBalanceDisplayText + menuBarDisplayText branch for .muse so balance renders (mirrors moonshot/poe).

Files

  • Sources/CodexBarCore/Providers/Muse/MuseProviderDescriptor.swift — descriptor + MuseAPIFetchStrategy + ProviderConfig.baseURL extension (now public)
  • Sources/CodexBarCore/Providers/Muse/MuseUsageFetcher.swift — HTTP + parsers for balance + models count, shared validator, preserved 401 handling, malformed {} rejection
  • Sources/CodexBarCore/Providers/Muse/MuseSettingsReader.swift — env resolution for keys + base URL
  • Sources/CodexBarCore/Providers/Muse/MuseProviderSettings.swiftMuseProviderSettings + MuseProviderSettingsKey
  • Sources/CodexBar/Providers/Muse/MuseProviderImplementation.swift — UI hooks, availability, settings fields
  • Sources/CodexBar/Providers/Muse/MuseSettingsStore.swiftSettingsStore extension for token + baseURL
  • Sources/CodexBar/Resources/ProviderIcon-muse.svg — icon
  • Sources/CodexBar/StatusItemController+Animation.swiftmuseBalanceDisplayText + menu-bar branch, plus // Provider-specific by design for expanded mistral+kiro+cursor cluster
  • docs/muse.md — provider docs (data sources, endpoints, key files, CLI)
  • docs/providers.md — added Muse row + detailed section (70 providers total)
  • Sources/CodexBarCore/Providers/Providers.swiftcase muse
  • Regenerated: ProviderManifest.swift, ProviderImplementationManifest.swift, ProviderInstanceIDAliases.generated.swift, docs/provider-ids.md via Scripts/regenerate-provider-manifests.sh
  • Updated counts: README.md, docs/social.html, docs/llms.txt, docs/index.html, docs/site-locales.mjs (69->70) per check-site-locales.mjs
  • Tests/CodexBarTests/ProviderArchitectureGatekeeperTests.swift — updated widgetFingerprint/burnDownFingerprint and balanceOnly + allowlisted cluster (mistral@0,kiro@9,cursor@17 at 924)
  • Tests/CodexBarTests/MuseUsageFetcherTests.swift — 15 tests: balance shapes, currency-only rejection, models count, malformed {}, Bearer header, https guard, user-info/encoded/missing-host rejection, http localhost allowed, 401 precedence, balance 200 preferred

Verification

  • make checkPASS (0 violations, 0 serious in 1882 files)
  • swift build — pass
  • swift test --filter ProviderArchitectureGatekeeper38/38 pass
  • swift test --filter MuseUsageFetcherTests15/15 pass
  • Scripts/regenerate-provider-manifests.sh --checkProvider manifests are current (70 providers)

Follow-ups

Meta billing endpoint is not publicly documented in ai.developer.meta.com/docs; parser is intentionally lenient and the models-probe fallback guarantees the provider is useful on day one.

Fixes: adds Muse alongside existing openrouter/litellm options so users no longer need to pay OpenRouter 5.5% just for visibility.

Contribution guide compliance

  • Followed provider authoring guide: UsageProvider case, descriptor in CodexBarCore, implementation in CodexBar, regenerate-provider-manifests.sh, icon, widgetSelectable false, focused tests, docs/muse.md + docs/providers.md entry
  • Ran make check (SwiftFormat + SwiftLint) — 0 violations
  • No Keychain/browser-cookie live probes — offline parser/stub tests only

- Adds UsageProvider.muse with API-key auth (MUSE_API_KEY / META_API_KEY / META_MUSE_API_KEY)
- Balance-only provider with flexible billing probe (billing/usage, me/balance, credits) falling back to /v1/models validation
- Supports custom base URL via MUSE_API_URL or Settings for proxies/self-hosted gateways
- Registers descriptor, fetch strategy, settings UI, icon, and docs/muse.md
- Regenerates manifests (ProviderManifest, ProviderImplementationManifest, provider-ids)

Fixes: Muse API not visible in CodexBar. Pricing is $1.25/4.25 per 1M tokens via api.meta.ai; this provider validates the key and shows balance where the API exposes it.
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

- widgetFingerprint 16873014858015536126 -> 1384715300343528903
- burnDownFingerprint 8686456525451224704 -> 5817880812814024010
- balanceOnly set now includes .muse alongside deepseek/deepinfra/mistral/moonshot/poe
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 14, 2026

@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: 3bc93d6c2d

ℹ️ 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".

widgetSelectable: false,
isPrimaryProvider: false,
usesAccountFallback: false,
balanceOnly: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update the balance-only gatekeeper set

Setting balanceOnly here adds .muse to descriptors.filter(\.metadata.balanceOnly), but ProviderArchitectureGatekeeperTests.swift:196-198 still asserts the exact set without Muse, so the full test suite will deterministically fail. Update that fixture and add focused Muse coverage alongside the new provider.

AGENTS.md reference: AGENTS.md:L20-L24

Useful? React with 👍 / 👎.

Comment on lines +57 to +60
primary: nil,
secondary: nil,
tertiary: nil,
providerCost: nil,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Expose the Muse balance to the menu-bar renderer

When a billing endpoint returns a balance, this snapshot leaves all rate/detail fields nil and stores the value only in identity.loginMethod. StatusItemController.menuBarDisplayText has explicit extraction branches for every existing balance-only provider but none for .muse, so it falls through with no percent window and returns no balance text when Muse is selected in the menu bar. Add a Muse balance extractor or represent the balance in a field consumed by the generic renderer.

Useful? React with 👍 / 👎.

Comment on lines +138 to +140
} catch {
if let last = lastError { throw last }
throw error

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve authentication errors from the models probe

If any speculative billing endpoint first returns a non-404 error or an unparseable 2xx response, lastError is populated; if the authoritative models probe then returns 401/403, this catch discards its explicit “invalid API key” error and reports the stale billing error instead. This misdiagnoses invalid credentials whenever an earlier optional billing probe failed, so authentication errors from the fallback probe should take precedence.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codex review: found issues before merge. Reviewed August 16, 2026, 9:46 AM ET / 13:46 UTC.

ClawSweeper review

What this changes

This PR adds a Meta Muse provider that fetches API-key balance data and optionally reads Team usage from the dev.meta.ai browser dashboard.

Merge readiness

Blocked by patch quality or review findings - 10 items remain

Keep open: the feature is not on current main, but the browser-session path needs a product decision and still has two concrete merge blockers.

Priority: P1
Reviewed head: 05aa359bc12da962b8de1b92ce475e1f1c70ecc5
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The real provider proof is strong, but cross-origin cookie forwarding and the import-policy violation block merge.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): A contributor-provided redacted terminal transcript shows a direct dev.meta.ai GraphQL run returning Team usage after the implementation.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): A contributor-provided redacted terminal transcript shows a direct dev.meta.ai GraphQL run returning Team usage after the implementation.
Evidence reviewed 6 items Cross-site cookie forwarding: The importer requests Meta and Facebook-domain cookies, then retains every non-expired cookie and serializes them into one raw Cookie header; it does not apply destination domain or path matching.
Raw header reaches dashboard requests: The dashboard fetcher assigns the imported header directly to requests for dev.meta.ai, so unrelated cookies are transmitted to that origin.
Repository cookie-import policy: Repository guidance requires Chrome-only default imports when possible to avoid browser prompts, while this descriptor uses the broad default import order.
Findings 2 actionable findings [P1] Preserve browser cookie isolation
[P2] Default automatic Muse imports to Chrome
Security Needs attention Imported cookies lose origin isolation: Cookies returned for Facebook and Meta domains are concatenated into a raw header sent to dev.meta.ai, bypassing normal browser cookie selection rules.

How this fits together

CodexBar turns provider credentials or browser sessions into usage snapshots consumed by the menu bar and settings UI. The Muse provider adds Meta API and dashboard fetch paths to that shared pipeline.

flowchart LR
A[API key or browser session] --> B[Muse provider]
B --> C[API or dashboard fetch]
C --> D[Meta endpoints]
D --> E[Usage snapshot]
E --> F[Menu bar and settings]
Loading

Decision needed

Question Recommendation
Should CodexBar own the reverse-engineered dev.meta.ai browser-session and GraphQL usage path, rather than ship only the documented API-key provider path? Sponsor full dashboard support: Keep the web path only after the cookie-isolation and Chrome-default findings are fixed and its ongoing endpoint maintenance is accepted.

Why: The API path is a bounded provider integration, but the web path imports sensitive browser sessions and depends on an internal dashboard contract that needs explicit ownership.

Before merge

  • Preserve browser cookie isolation (P1) - The importer includes Facebook and Meta domains, but lines 59-60 retain every unexpired returned cookie and SessionInfo.cookieHeader sends them all to dev.meta.ai. A browser would not attach unrelated-domain or path-mismatched cookies there, so filter by the destination request URL or keep a scoped cookie jar, with a regression test containing an unrelated Facebook cookie.
  • Default automatic Muse imports to Chrome (P2) - The new descriptor uses the global browser import order, even though repository policy requires Chrome-only automatic imports when possible to avoid prompts from other browser credential stores. Set Muse’s automatic order to Chrome and cover that default in focused tests.
  • Resolve security concern: Imported cookies lose origin isolation - Cookies returned for Facebook and Meta domains are concatenated into a raw header sent to dev.meta.ai, bypassing normal browser cookie selection rules.
  • Resolve merge risk (P1) - Automatic import can forward unrelated Facebook or Meta session cookies to dev.meta.ai instead of preserving browser cookie isolation.
  • Resolve merge risk (P1) - The reverse-engineered dashboard path adds an ongoing compatibility and support commitment that is separate from the documented API-key path.
  • Complete next step (P2) - A maintainer must decide whether CodexBar should own the reverse-engineered browser-dashboard contract; the two code findings must be fixed before a full web path can merge.
  • Improve patch quality - Filter imported cookies to the actual dev.meta.ai request scope and add regression coverage.
  • Improve patch quality - Use Chrome as the automatic import default and add a focused default-order test.
  • Improve patch quality - Obtain maintainer direction on whether the reverse-engineered dashboard source belongs in core.

Findings

  • [P1] Preserve browser cookie isolation — Sources/CodexBarCore/Providers/Muse/MuseCookieImporter.swift:59-60
  • [P2] Default automatic Muse imports to Chrome — Sources/CodexBarCore/Providers/Muse/MuseProviderDescriptor.swift:48
  • [high] Imported cookies lose origin isolation — Sources/CodexBarCore/Providers/Muse/MuseCookieImporter.swift:59
Agent review details

Security

Needs attention: The automatic web path can transmit imported cookies beyond their browser-enforced origin and path scope.

Review metrics

Metric Value Why it matters
Change surface 24 files; +1,889 / -86 lines This adds a full provider and substantial web-session implementation rather than a narrow parser change.
Production versus tests production +1,469, tests +271 The large production addition makes explicit ownership of the dashboard strategy important before merge.

Merge-risk options

Maintainer options:

  1. Restore cookie isolation before merging (recommended)
    Filter imported cookies by the dev.meta.ai request URL and path, default automatic import to Chrome, and add regression tests containing unrelated Facebook cookies.
  2. Limit this provider to the API route
    Remove the browser-session dashboard strategy if maintainers do not want to own a reverse-engineered session contract.

Technical review

Best possible solution:

Keep the API-key balance/validation path, and retain dashboard usage only if a maintainer sponsors it after destination-safe cookie handling, Chrome-only automatic import, and focused regression coverage.

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

Not applicable as a feature request; the contributor nevertheless supplied a redacted terminal run showing the real Meta dashboard path.

Is this the best way to solve the issue?

No—the API-key path is bounded, but the browser-session implementation should not land until its cookie boundary is fixed and maintainers explicitly accept the internal-dashboard dependency.

Full review comments:

  • [P1] Preserve browser cookie isolation — Sources/CodexBarCore/Providers/Muse/MuseCookieImporter.swift:59-60
    The importer includes Facebook and Meta domains, but lines 59-60 retain every unexpired returned cookie and SessionInfo.cookieHeader sends them all to dev.meta.ai. A browser would not attach unrelated-domain or path-mismatched cookies there, so filter by the destination request URL or keep a scoped cookie jar, with a regression test containing an unrelated Facebook cookie.
    Confidence: 0.99
  • [P2] Default automatic Muse imports to Chrome — Sources/CodexBarCore/Providers/Muse/MuseProviderDescriptor.swift:48
    The new descriptor uses the global browser import order, even though repository policy requires Chrome-only automatic imports when possible to avoid prompts from other browser credential stores. Set Muse’s automatic order to Chrome and cover that default in focused tests.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b9ae578fb101.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P1: Merging would introduce a path that can disclose authenticated browser cookies across origins.
  • merge-risk: 🚨 auth-provider: The new provider authenticates through API keys and imported browser sessions.
  • merge-risk: 🚨 security-boundary: The importer concatenates cross-domain cookies into requests to dev.meta.ai.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): A contributor-provided redacted terminal transcript shows a direct dev.meta.ai GraphQL run returning Team usage after the implementation.
  • proof: sufficient: Contributor real behavior proof is sufficient. A contributor-provided redacted terminal transcript shows a direct dev.meta.ai GraphQL run returning Team usage after the implementation.

Evidence

Security concerns:

  • [high] Imported cookies lose origin isolation — Sources/CodexBarCore/Providers/Muse/MuseCookieImporter.swift:59
    Cookies returned for Facebook and Meta domains are concatenated into a raw header sent to dev.meta.ai, bypassing normal browser cookie selection rules.
    Confidence: 0.99

What I checked:

Likely related people:

  • steipete: Current-main blame covers the adjacent shared dashboard-cookie importer and the repository’s cookie-import policy. (role: recent browser-cookie infrastructure contributor; confidence: medium; commits: 0e453c4a5b2a; files: Sources/CodexBarCore/OpenAIWeb/OpenAIDashboardBrowserCookieImporter.swift, AGENTS.md)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (16 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-14T23:36:53.800Z sha 0b7826e :: needs real behavior proof before merge. :: [P2] Remove the unfinished Team-usage source
  • reviewed 2026-08-15T04:26:23.063Z sha e0b412c :: needs real behavior proof before merge. :: [P1] Restrict imported cookies to the target session | [P2] Remove the unfinished Team-usage probe
  • reviewed 2026-08-15T04:51:17.960Z sha 2cb9413 :: needs real behavior proof before merge. :: [P1] Filter imported cookies to the target dashboard | [P2] Prefer Chrome for automatic Muse cookie imports | [P2] Decode Relay array payloads before requiring a dictionary | [P2] Restrict request extraction to request-count fields
  • reviewed 2026-08-15T13:39:14.740Z sha df97861 :: needs real behavior proof before merge. :: [P1] Filter imported cookies before building the Muse header | [P2] Decode Relay arrays before requiring a dictionary
  • reviewed 2026-08-15T13:45:45.003Z sha 6453493 :: needs real behavior proof before merge. :: [P1] Filter imported cookies before building the Muse header | [P2] Parse Relay array responses before casting the root | [P2] Default automatic imports to Chrome only
  • reviewed 2026-08-15T13:58:27.852Z sha ddc68d3 :: needs real behavior proof before merge. :: [P1] Filter imported cookies before building the Muse header | [P2] Default automatic imports to Chrome only
  • reviewed 2026-08-15T14:09:43.630Z sha d6625fa :: needs real behavior proof before merge. :: [P1] Filter imported cookies before building the Muse header | [P2] Restrict automatic cookie imports to Chrome
  • reviewed 2026-08-15T20:14:24.742Z sha a8a8f31 :: needs changes before merge. :: [P1] Preserve browser cookie isolation | [P2] Default automatic import to Chrome | [P3] Document the implemented GraphQL source

…uard

- P1: add museBalanceDisplayText and menuBarDisplayText branch for .muse so balance/probe result from loginMethod is rendered (mirrors moonshot/poe). Fixes empty menu-bar text.
- P2: preserve authoritative 401/403 from /v1/models probe over stale billing lastError.
- P2/security: validate base URL — require https, allow only http://localhost/127.0.0.1/::1 for local proxy, reject insecure hosts before sending Bearer token.
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 14, 2026
- StatusItemController+Animation.swift:923 now clusters mistral+kiro+cursor (3) instead of kiro+cursor (2) after inserting muse branch at 917; add Provider-specific by design comment to justify the expanded window.
- Tests: update AllowedProviderConstruct at 926->923, anchor kiro->mistral, fingerprint [kiro@0,cursor@8]/2 -> [mistral@0,kiro@9,cursor@17]/3. Gatekeeper now 38/38 pass.
@toml0006

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Aug 14, 2026
- parseModelsCount now throws parseFailed when data/models array is missing instead of returning nil and incorrectly reporting 'API key valid'.
- ClawSweeper auth-provider finding: prevents {} from being accepted as successful validation.
- MuseUsageFetcher: require numeric balance for billing success (currency-only now correctly falls through to models probe instead of false 'API key valid'). Fixes P2 at 253-254.
- Tests: add MuseUsageFetcherTests (12 cases) covering balance parsing, empty/currency-only rejection, models count and rejection of {} / missing array, Bearer/Accept/timeout headers, https guard (evil.com blocked, localhost allowed), 401 precedence over 500, balance preferred over fallback, and missing key. Provides controlled-transport coverage for the 319-line fetcher.
- README, docs/providers.md, docs/social.html, docs/llms.txt,
  docs/index.html, docs/site-locales.mjs: 69 -> 70 providers
  after Muse addition (check-site-locales.mjs requires exact count)
- docs/providers.md: add Muse table row + detailed section
- MuseUsageFetcher: refactor Generic decode + fallback scan to
  nil-coalescing to satisfy statement_position lint, fix
  multiline_parameters for fetchBalance
- MuseProviderDescriptor: split noDataMessage for line_length
- MuseSettingsReader: explicit self (redundantSelf)
- MuseUsageFetcherTests: fix encoded delimiter test to use %2F
  (hostHasNoEncodedDelimiters only rejects %2f/%40 etc, not %2e),
  fix fatalError message
- ProviderArchitectureGatekeeperTests: line 923->924 after
  comment wrap (line_length) shifted mistral anchor
- StatusItemController+Animation: comment wrap from swiftformat

make check: PASS (0 violations), swift build PASS,
swift test MuseUsageFetcherTests 15/15 PASS,
ProviderArchitectureGatekeeper 38/38 PASS
@toml0006

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Aug 14, 2026
@clawsweeper clawsweeper Bot removed the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Aug 14, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 15, 2026
Replace guessed GET /api/usage* probes (all 404) with POST
https://dev.meta.ai/api/graphql/ doc_id 27710687895239709
(LLMDCUsageQuery) reverse-engineered from HAR. Harvest
team_id/LSD/fb_dtsg/__rev/__hsi from dashboard HTML, build
form-urlencoded RelayModern body with week window
(America/Chicago), handle for(;;); wrapper and recursive
token/cost/request parsing. Fall back to HTML only if
GraphQL yields no metrics. Fixes web auto falling back to
apiToken showing only 3 models.
dev.meta.ai dashboard auth rides on facebook.com session
cookies (c_user/xs/datr) not just meta.ai. All Chrome profiles
show 0 rows for meta.ai domains. Expand cookieDomains to
facebook.com/www.facebook.com/meta.com so MuseWebFetchStrategy
can build the GraphQL Cookie header.
@clawsweeper clawsweeper Bot added P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. labels Aug 15, 2026
Safari legacy cookie stages but HTML has teamId as integer
or URL-encoded without quotes. Expand extractTeamId patterns
to cover "teamId":374..., teamId%3D, and bare numeric
team_id/teamId with 10+ digits.
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 15, 2026
Replace generic total_tokens search with parseTeamUsage that
sums categorical_data for num_requests/num_prompt_tokens/
num_completion_tokens/usage_billable_cost (amount_with_offset
cents->dollars) per verified 2026-08-15 GraphQL response
(4814 req / 589M prompt / .59). Produces Team usage
snapshot with cost.
@toml0006
toml0006 force-pushed the feat/muse-provider branch from ff10147 to ddc68d3 Compare August 15, 2026 13:53
Manual cookie (llm_sess+datr) harvests no team_id/fb_dtsg
from HTML, causing 1357004. Use verified HAR fallbacks
swTyN9fDdqKU_GTgO9R99v / NAfztM7dBcJpLZ... for GraphQL.
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 15, 2026
@toml0006

Copy link
Copy Markdown
Author

Verified via dev.meta.ai GraphQL (no OpenRouter proxy):

```
$ /tmp/codexbar-work/CodexBar/.build/debug/CodexBarCLI usage --provider muse -v
[muse] fetch strategies:

  • muse.web (web) available == Muse (web) == Cost: 4.8 / 4.8 Plan: Team Usage: 5116 Requests · 625878445 Tokens · $4.80

$ curl https://dev.meta.ai/api/graphql/ -b "datr=...; llm_sess=..." --data-raw "doc_id=27710687895239709&variables={"team_id":"3747295692075251",...}"
→ 9241 bytes {"data":{"team":{"requests_metrics":[{"identifier":"num_requests","categorical_data":[{"category":"2026-08-15","value":243}]}],"input_token_metrics":...,"spend_cost_metrics":[{"identifier":"usage_billable_cost","value":{"amount_with_offset":"32"}}]}}}
→ summed 5116 req / 625M tokens / $4.80 (was 4814 / 593M / $4.59)

$ codexbar config dump --show-secrets | grep muse
→ enabled:true cookieSource:manual cookieHeader:datr=...; llm_sess=FojGt5%2B... (Manual header from HAR, with fallback fb_dtsg=NAfztM7... / lsd=swTyN9fD...)
```

Fallback remains GET https://api.meta.ai/v1/modelsApi Key Valid · 3 Models when no session. Widget snapshot Y5PE65HELJ.com.steipete.codexbar/widget-snapshot.json now muse Team usage with providerCost.

Branch feat/muse-provider at d6625faca (fixes: facebook.com cookieDomains, robust team_id regex, LLMD-C categorical_data parser, fallback DTSG/LSD).

Build dailyPoints from categorical_data (prompt+output tokens
+ cost per day) and expose as ProviderDetailSection Daily
usage table in UsageSnapshot.details for the Muse detail
sheet.
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 15, 2026
Use UsageFormatter.tokenCountString for tokens (623M vs
622576992) and NumberFormatter decimal/currency for requests
and cost per Locale.current. Applies to main snapshot,
fallback parseUsageAPI and daily detail rows.
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants