feat: switch OpenCode Go usage to API

OpenCode Go now reads quota usage with a bearer API key from OpenCode auth.json
Removes the old workspace ID and browser cookie credential flow
Deletes legacy OpenCode Go credential files during upgrade
This commit is contained in:
Bohdan Triapitsyn
2026-08-12 01:49:22 +03:00
parent d1224213ca
commit 5917325d49
29 changed files with 192 additions and 182 deletions
@@ -2,7 +2,7 @@ import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
const MANAGED_QUOTA_PROVIDERS = new Set(['opencode-go', 'ollama-cloud', 'cursor']);
const MANAGED_QUOTA_PROVIDERS = new Set(['ollama-cloud', 'cursor']);
const credentialsDirectory = () => path.join(
process.env.OPENCHAMBER_DATA_DIR
@@ -46,3 +46,13 @@ export const deleteQuotaCredential = (providerId) => {
if (error?.code !== 'ENOENT') throw error;
}
};
// OpenCode Go used to store a browser auth cookie here. Its usage API now uses
// OpenCode's auth.json API key, so remove the obsolete secret without reading it.
export const deleteLegacyOpenCodeGoCredential = () => {
try {
fs.unlinkSync(path.join(credentialsDirectory(), 'opencode-go.json'));
} catch (error) {
if (error?.code !== 'ENOENT') throw error;
}
};