Skip to content

feat: add Muse coding-plan provider - #128

Open
yesme wants to merge 2 commits into
onllm-dev:mainfrom
yesme:muse-provider-upstream
Open

feat: add Muse coding-plan provider#128
yesme wants to merge 2 commits into
onllm-dev:mainfrom
yesme:muse-provider-upstream

Conversation

@yesme

@yesme yesme commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Track Meta Muse coding-plan quotas (5h prompts + weekly) from the same subscription snapshot muse /usage shows.

Why this shape

Meta publishes no aggregate usage endpoint for the coding plan (probed /v1/usage, /v1/billing, org usage/costs - all 404). Each poll sends one minimal streamed probe (POST /v1/responses with stream: true, input ping, max_output_tokens: 16) and extracts the inline subscription object. Verified against the live API:

{"subscription": {"tier": "pro",
  "weekly": {"resets_at": "1789344000", "used_percent": "12.5"},
  "window": {"resets_at": "1789078632", "used_percent": "34", "window_duration_mins": "300"}}}

Auth

Resolves as META_API_KEY -> providers.meta.api_key in the muse login file -> macOS Keychain / Linux keyring entry written by muse login. The Keychain lookup is deadline-bounded (15s + regression test) so an unanswered approval dialog can never block daemon startup.

Includes

  • API client + types (string-or-number scalars, epoch s/ms, last-snapshot-wins SSE scan)
  • Credential auto-detect (unix keychain/keyring, windows file) + probe-model resolution
  • SQLite store (snapshots, quota values, reset cycles) + reset-cycle tracker + polling agent + daemon wiring
  • 7 web endpoints, dashboard cards, menubar card, settings form, setup wizard, install.sh/ps1, docs/MUSE_SETUP.md, landing card

Verified

  • ./app.sh --smoke green on this branch; tests/test_install.sh 27/27 (incl. 2 new Muse cases)
  • End-to-end against the live API (daemon poll, store, cycles, all endpoints, dashboard tab, menubar)
  • One pre-existing failure, unrelated: tools/perf-monitor TestMain_RestartFailureExitsWithError hangs in this dev environment because the test helper starts a real onwatch (found via PATH) and blocks forever on its output pipe. It fails identically with and without a repo-local binary, and involves no code touched by this PR.

Track Meta Muse coding-plan quotas (5h prompts + weekly) from the same
subscription snapshot 'muse /usage' shows. Meta publishes no aggregate
usage endpoint, so each poll sends one minimal streamed probe to
POST /v1/responses (input ping, max 16 output tokens) and extracts the
inline subscription object.

Auth resolves as META_API_KEY, then the muse login file, then the
macOS Keychain / Linux keyring entry written by 'muse login'. The
Keychain lookup is deadline-bounded (15s) so an unanswered approval
dialog can never block daemon startup.

Includes: API client + types, credential auto-detect (unix/windows),
SQLite store + reset-cycle tracker, polling agent, daemon wiring,
7 web endpoints, dashboard cards + menubar + settings, setup wizard,
install.sh/ps1, docs/MUSE_SETUP.md, landing card.
The usage probe was a full streamed generation on the same Meta API key
the TUI uses. That held the HTTP stream until ping finished, 429'd live
muse sessions, and looked like Muse/onWatch crashing.

- Close the SSE stream as soon as the subscription snapshot arrives
- Skip the probe while a `muse` process is running
- Treat HTTP 429 as a skipped cycle, not a hard error
- Reject nil snapshots on insert
- Ad-hoc codesign Darwin builds so taskgated does not SIGKILL unsigned pages

Co-authored-by: Grok <grok@x.ai>
@yesme

yesme commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up fix on this branch: b32ea7b

Cause: the usage probe was a full streamed POST /v1/responses on the same Meta API key as the live Muse TUI. Holding that generation until ping finished 429'd the CLI (reason="rate_limited" in muse traces) and looked like Muse/onWatch crashing. Separately, unsigned Darwin pages can be SIGKILL'd by taskgated.

What changed:

  • Close the SSE stream as soon as the subscription snapshot arrives
  • Skip the probe while a muse process is running
  • Treat HTTP 429 as a skipped cycle
  • Ad-hoc codesign Darwin production builds

@prakersh

Copy link
Copy Markdown
Contributor

Thanks for this, it is a clean provider addition. It follows the existing per-provider layout, and everything passes on our side: go vet, go test -race across api, agent, store, tracker and web, 27/27 in tests/test_install.sh, and it rebases onto main with no conflicts.

We are keeping the 120s default polling as is. The 5h window is token metered, so a 16 token probe is noise, and we would rather have one polling model across all providers.

Two things before we merge:

  1. The live-CLI guard uses pgrep, which does not exist on Windows, so LookPath fails and the probe never skips there. We already solve this in internal/agent/anthropic_cc_detect.go (IsClaudeCodeRunning): ps -Ao args= on unix, tasklist on Windows. Could you lift that into a small shared helper and have Muse use it? Dropping the skip entirely and relying on the early stream close is also fine by us.

  2. isProviderConfigured("muse") calls DetectMuseCredentials on every provider-list request, so each one shells out to security or secret-tool with a 15s deadline. Please resolve it once at startup, or memoize it.

Optional: a MUSE_BASE_URL override would match ZAI_BASE_URL for proxy setups.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants