summaryrefslogtreecommitdiffhomepage
path: root/bin/seed-opencode-keys.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-05-21 17:30:08 +0900
committerAdam Malczewski <[email protected]>2026-05-21 17:30:08 +0900
commitd6b208342edf97bafa5b1dcc986b782f9879d141 (patch)
treec6d8f9bffa86f78e3b1369b811bef9642df788d0 /bin/seed-opencode-keys.ts
parent1f309ccca20aabbd0ee3fb8fbb3c8192124edd95 (diff)
downloaddispatch-d6b208342edf97bafa5b1dcc986b782f9879d141.tar.gz
dispatch-d6b208342edf97bafa5b1dcc986b782f9879d141.zip
feat: SQLite database for all credentials, keys, wake schedule, and usage cache
- Add SQLite database at ~/.local/share/dispatch/dispatch.db with tables: credentials, api_keys, wake_schedule, usage_cache - Store Claude OAuth credentials in DB with import button in Model Status UI - Store OpenCode/Copilot API keys in DB with paste-to-import modal - Store OpenCode cookie and workspace IDs in DB - Migrate wake schedule from .wake-schedule.json to DB - Migrate usage cache from in-memory Map + localStorage to DB - Remove all env var and file fallbacks — DB is the single source of truth - Add seed scripts: bin/import-credentials.ts, bin/seed-opencode-keys.ts - Docker: container runs as host UID/GID with matching home directory - Clean up dispatch.toml: remove env fields, update comments - Progress bar time markers for usage cycle tracking
Diffstat (limited to 'bin/seed-opencode-keys.ts')
-rw-r--r--bin/seed-opencode-keys.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/seed-opencode-keys.ts b/bin/seed-opencode-keys.ts
new file mode 100644
index 0000000..c461592
--- /dev/null
+++ b/bin/seed-opencode-keys.ts
@@ -0,0 +1,28 @@
+#!/usr/bin/env bun
+/**
+ * Seed API keys from environment variables into the SQLite database.
+ */
+import { setApiKey, getDatabasePath } from "../packages/core/src/index.js";
+
+console.log(`Database: ${getDatabasePath()}\n`);
+
+const keys = [
+ { keyId: "opencode-1", provider: "opencode-go", envVar: "OPENCODE_KEY_1" },
+ { keyId: "opencode-2", provider: "opencode-go", envVar: "OPENCODE_KEY_2" },
+ { keyId: "copilot", provider: "github-copilot", envVar: "COPILOT_TOKEN" },
+ { keyId: "opencode-cookie", provider: "opencode-go", envVar: "OPENCODE_COOKIE" },
+ { keyId: "opencode-ws1", provider: "opencode-go", envVar: "OPENCODE_WS1_ID" },
+ { keyId: "opencode-ws2", provider: "opencode-go", envVar: "OPENCODE_WS2_ID" },
+];
+
+for (const { keyId, provider, envVar } of keys) {
+ const value = process.env[envVar];
+ if (value) {
+ setApiKey(keyId, provider, value);
+ console.log(`${keyId}: imported from $${envVar}`);
+ } else {
+ console.log(`${keyId}: SKIPPED ($${envVar} not set)`);
+ }
+}
+
+console.log("\nDone.");