Skip to content

Add Ollama cloud usage provider#470

Closed
gustavosmendes wants to merge 5 commits into
robinebers:mainfrom
gustavosmendes:codex/ollama-personal
Closed

Add Ollama cloud usage provider#470
gustavosmendes wants to merge 5 commits into
robinebers:mainfrom
gustavosmendes:codex/ollama-personal

Conversation

@gustavosmendes
Copy link
Copy Markdown

@gustavosmendes gustavosmendes commented May 16, 2026

Summary

  • Add an Ollama provider plugin for personal Cloud Usage tracking.
  • Scrape authenticated https://ollama.com/settings usage from __Secure-session via env, Keychain, or Firefox cookie store.
  • Add docs/env entries and host API redaction coverage for Ollama auth fields.

Verification

  • bunx vitest run plugins/ollama/plugin.test.js
  • bun run build
  • cargo test -q --manifest-path src-tauri/Cargo.toml plugin_engine::host_api::tests::redact_body_redacts_email_in_html
  • cargo test -q --manifest-path src-tauri/Cargo.toml plugin_engine::host_api::tests::redact_log_message_redacts_email
  • cargo test -q --manifest-path src-tauri/Cargo.toml plugin_engine::host_api::tests::redact_body_redacts_user_id_and_email
  • cargo test -q --manifest-path src-tauri/Cargo.toml plugin_engine::host_api::tests::env_api_respects_allowlist_in_host_and_js
  • Installed local app and verified GET http://127.0.0.1:6736/v1/usage/ollama returns 200 OK with plan: Pro and Source: Settings page.

Notes

  • No app layout changes. New provider icon uses currentColor.
  • Full host_api test group still has an unrelated existing timeout case in ccusage_timeout_kills_descendant_and_closes_pipes.

Summary by cubic

Add ollama provider to track Cloud session and weekly usage by scraping the authenticated settings page first, with a fallback to a future API using OLLAMA_API_KEY when no cookie is available. Includes docs, README entry, env examples, an Ollama icon, and host API email redaction.

  • New Features

    • Added ollama provider: scrapes https://ollama.com/settings via __Secure-session, or uses GET /api/account/usage with OLLAMA_API_KEY when no cookie is available.
    • Auth sources: OLLAMA_SESSION_COOKIE, OLLAMA_COOKIE, macOS Keychain, and Firefox/LibreWolf cookies; accepts raw (including padded) session values and full Cookie header values.
    • Output: Plan, Session %, Weekly %, reset times, and Source.
  • Bug Fixes

    • Host API now redacts email addresses in HTML/text bodies and logs.
    • Allowlisted OLLAMA_* env vars (OLLAMA_API_KEY, OLLAMA_HOST, OLLAMA_SESSION_COOKIE, OLLAMA_COOKIE) and added tests for redaction and env access.

Written for commit 0ad2744. Summary will update on new commits. Review in cubic

@github-actions github-actions Bot added rust Pull requests that update rust code plugin docs labels May 16, 2026
@robinebers
Copy link
Copy Markdown
Owner

Hi, I've decided to decline new plugins for the time being. They've become unmaintanable, as I don't own most of these subscriptions and that results in slop (can't test them myself). Maybe this will change in the future.

Thank you

@robinebers
Copy link
Copy Markdown
Owner

There seems to be a lot of demand so i'll reopen this for now

@robinebers robinebers reopened this May 22, 2026
@robinebers
Copy link
Copy Markdown
Owner

@cubic-dev-ai review this

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai Bot commented May 22, 2026

@cubic-dev-ai review this

@robinebers I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="plugins/ollama/plugin.js">

<violation number="1" location="plugins/ollama/plugin.js:239">
P2: Percentage parsing is global and can pick unrelated `"% used"` values, producing incorrect Session/Weekly usage when the settings page contains additional percentage text.</violation>
</file>

<file name="docs/providers/ollama.md">

<violation number="1" location="docs/providers/ollama.md:31">
P1: Manual Keychain setup example passes the session cookie as a CLI argument via `-w`, which exposes the secret in shell history and process listings. The `security` command should prompt interactively instead.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread docs/providers/ollama.md
Manual Keychain setup:

```sh
security add-generic-password -U -a "$(id -un)" -s "OpenUsage Ollama Session" -w "PASTE_SESSION_COOKIE"
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

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

P1: Manual Keychain setup example passes the session cookie as a CLI argument via -w, which exposes the secret in shell history and process listings. The security command should prompt interactively instead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/providers/ollama.md, line 31:

<comment>Manual Keychain setup example passes the session cookie as a CLI argument via `-w`, which exposes the secret in shell history and process listings. The `security` command should prompt interactively instead.</comment>

<file context>
@@ -0,0 +1,61 @@
+Manual Keychain setup:
+
+```sh
+security add-generic-password -U -a "$(id -un)" -s "OpenUsage Ollama Session" -w "PASTE_SESSION_COOKIE"
+```
+
</file context>
Suggested change
security add-generic-password -U -a "$(id -un)" -s "OpenUsage Ollama Session" -w "PASTE_SESSION_COOKIE"
security add-generic-password -U -a "$(id -un)" -s "OpenUsage Ollama Session"
Fix with Cubic

Comment thread plugins/ollama/plugin.js
if (String(html || "").indexOf("Cloud Usage") === -1) return null
const text = textFromHtml(html)
const percentages = []
const re = /(\d+(?:\.\d+)?)%\s*used/gi
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot May 22, 2026

Choose a reason for hiding this comment

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

P2: Percentage parsing is global and can pick unrelated "% used" values, producing incorrect Session/Weekly usage when the settings page contains additional percentage text.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/ollama/plugin.js, line 239:

<comment>Percentage parsing is global and can pick unrelated `"% used"` values, producing incorrect Session/Weekly usage when the settings page contains additional percentage text.</comment>

<file context>
@@ -0,0 +1,347 @@
+    if (String(html || "").indexOf("Cloud Usage") === -1) return null
+    const text = textFromHtml(html)
+    const percentages = []
+    const re = /(\d+(?:\.\d+)?)%\s*used/gi
+    let match
+    while ((match = re.exec(text)) && percentages.length < 2) {
</file context>
Fix with Cubic

@robinebers robinebers marked this pull request as ready for review May 22, 2026 10:28
@robinebers
Copy link
Copy Markdown
Owner

Looked into this, this is a bit fragile and unfortunately they don't seem to have a an official API for now. Bummer!

@robinebers robinebers closed this May 22, 2026
barramee27 added a commit to barramee27/crossusage that referenced this pull request May 23, 2026
Port upstream PR robinebers#470; exclude accidental release binaries from fork tree.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs plugin rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants