Add Ollama cloud usage provider#470
Conversation
|
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 |
|
There seems to be a lot of demand so i'll reopen this for now |
|
@cubic-dev-ai review this |
@robinebers I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
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
| Manual Keychain setup: | ||
|
|
||
| ```sh | ||
| security add-generic-password -U -a "$(id -un)" -s "OpenUsage Ollama Session" -w "PASTE_SESSION_COOKIE" |
There was a problem hiding this comment.
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>
| 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" |
| if (String(html || "").indexOf("Cloud Usage") === -1) return null | ||
| const text = textFromHtml(html) | ||
| const percentages = [] | ||
| const re = /(\d+(?:\.\d+)?)%\s*used/gi |
There was a problem hiding this comment.
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>
|
Looked into this, this is a bit fragile and unfortunately they don't seem to have a an official API for now. Bummer! |
Port upstream PR robinebers#470; exclude accidental release binaries from fork tree. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
https://ollama.com/settingsusage from__Secure-sessionvia env, Keychain, or Firefox cookie store.Verification
bunx vitest run plugins/ollama/plugin.test.jsbun run buildcargo test -q --manifest-path src-tauri/Cargo.toml plugin_engine::host_api::tests::redact_body_redacts_email_in_htmlcargo test -q --manifest-path src-tauri/Cargo.toml plugin_engine::host_api::tests::redact_log_message_redacts_emailcargo test -q --manifest-path src-tauri/Cargo.toml plugin_engine::host_api::tests::redact_body_redacts_user_id_and_emailcargo test -q --manifest-path src-tauri/Cargo.toml plugin_engine::host_api::tests::env_api_respects_allowlist_in_host_and_jsGET http://127.0.0.1:6736/v1/usage/ollamareturns200 OKwithplan: ProandSource: Settings page.Notes
currentColor.host_apitest group still has an unrelated existing timeout case inccusage_timeout_kills_descendant_and_closes_pipes.Summary by cubic
Add
ollamaprovider to track Cloud session and weekly usage by scraping the authenticated settings page first, with a fallback to a future API usingOLLAMA_API_KEYwhen no cookie is available. Includes docs, README entry, env examples, an Ollama icon, and host API email redaction.New Features
ollamaprovider: scrapeshttps://ollama.com/settingsvia__Secure-session, or usesGET /api/account/usagewithOLLAMA_API_KEYwhen no cookie is available.OLLAMA_SESSION_COOKIE,OLLAMA_COOKIE, macOS Keychain, and Firefox/LibreWolf cookies; accepts raw (including padded) session values and full Cookie header values.Bug Fixes
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