Skip to content

Feature Request: Add OpenCode Go subscription quota tracking via browser session cookie #100

Description

@TaylanTatli

Summary

Please add support for tracking OpenCode Go subscription quotas in onWatch.

OpenCode does not appear to provide a documented public quota API. However, AIMeter already has a working OpenCode adapter that retrieves the quota information by using the user's authenticated browser session cookie and parsing the usage data returned by opencode.ai.

Reference implementation:

https://github.com/bugwz/AIMeter/blob/main/src/adapters/OpenCodeAdapter.ts

Motivation

OpenCode Go users currently need to open the OpenCode website manually to check their remaining quota and reset times.

Adding OpenCode Go as a provider would allow its quota to be displayed alongside Codex, Claude, MiniMax, Z.ai, Cursor, and the other subscriptions already supported by onWatch.

This request is specifically about the OpenCode Go subscription quota shown on opencode.ai, not local OpenCode CLI token accounting or OpenRouter usage.

Existing working approach

The AIMeter implementation demonstrates that this is technically possible without a public API.

Its OpenCode adapter:

  1. Accepts an authenticated OpenCode browser cookie, either as:

    • the raw authentication token;
    • auth=... / __Host-auth=...; or
    • a complete Cookie header.
  2. Resolves the user's OpenCode workspace ID automatically, while also supporting a manually supplied workspace ID.

  3. Requests:

    https://opencode.ai/workspace/{workspaceId}/go
    

    using the session cookie and normal browser request headers.

  4. Falls back to OpenCode's internal server-function endpoints when the Go page does not provide a usable payload.

  5. Extracts and normalizes the following quota windows:

    • Session / rolling window — 5 hours
    • Weekly window — 7 days
    • Monthly window — when present
  6. Returns both:

    • utilization percentage;
    • reset timestamp/countdown.
  7. Detects invalid or expired sessions and reports response-format changes separately.

Suggested onWatch implementation

A first implementation could be introduced as an opt-in Beta provider.

Authentication

Support manual configuration through the dashboard and/or environment variables such as:

OPENCODE_COOKIE=auth=...
OPENCODE_WORKSPACE_ID=wrk_...   # optional override

Automatic browser-cookie discovery could be considered later, but manual cookie entry would be sufficient for an initial implementation.

Provider behavior

The OpenCode tracker could:

  • resolve the workspace ID automatically;
  • poll the OpenCode Go page at the normal onWatch polling interval;
  • parse the embedded usage payload;
  • fall back to the internal subscription/server-function response when necessary;
  • map the results to normal onWatch quota cards;
  • store historical snapshots and cycle data using the existing provider architecture.

Suggested cards:

  • Session — 5 hours
  • Weekly — 7 days
  • Monthly, when returned by OpenCode

Each card should show utilization, remaining quota, and reset countdown like the other providers.

Security considerations

Because the browser session cookie is sensitive, the implementation should:

  • never write the cookie to logs;
  • redact it from diagnostics and error messages;
  • store it using the same protection used for other sensitive provider credentials;
  • clearly explain that logging out or session rotation may invalidate it;
  • provide a clear “session expired, re-authenticate” error;
  • keep all processing local, consistent with onWatch's privacy model.

Reliability considerations

This integration would depend on undocumented website behavior, so it may occasionally break when OpenCode changes its frontend or internal server functions.

To reduce maintenance risk:

  • mark the provider as Beta;
  • fail gracefully when the expected payload is absent;
  • distinguish authentication errors from parser errors;
  • add parser tests using sanitized response fixtures;
  • allow the internal server IDs and relevant paths to be updated independently where practical.

The AIMeter adapter already implements multiple parsing strategies and fallback paths, which could serve as a useful reference rather than starting from scratch.

Acceptance criteria

  • OpenCode Go can be enabled as a provider.
  • A valid session cookie can be entered securely.
  • Workspace ID is resolved automatically or supplied manually.
  • Session and weekly utilization percentages are displayed.
  • Reset timestamps/countdowns are displayed.
  • Monthly usage is displayed when available.
  • Historical snapshots are stored like other onWatch providers.
  • Expired cookies and changed response formats produce clear, non-sensitive errors.

Thank you for considering this. OpenCode Go support would make onWatch significantly more useful for users combining several coding-plan subscriptions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions