Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"appId": "online.omniroute.desktop",
"productName": "OmniRoute",
"copyright": "Copyright © 2025 OmniRoute",
"buildDependenciesFromSource": true,
"buildDependenciesFromSource": false,
"npmRebuild": false,
"directories": {
"output": "dist-electron",
"buildResources": "assets"
Expand Down
5 changes: 4 additions & 1 deletion open-sse/mcp-server/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ function toString(value: unknown): string {
}

async function openBetterSqliteAuditDb(dbPath: string): Promise<AuditDatabase> {
const Database = (await import("better-sqlite3")).default as unknown as new (
const { createRequire } = await import("node:module");
const _require = createRequire(import.meta.url);
const mod = _require("better-sqlite3");
const Database = (mod?.default || mod) as unknown as new (
dbPath: string
) => AuditDatabase;
return new Database(dbPath);
Expand Down
16 changes: 16 additions & 0 deletions src/lib/db/omp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import path from "path";
import { createRequire } from "node:module";

const _require = createRequire(import.meta.url);
function getDatabaseClass() {
try {
if (process.versions.bun) {
return _require("bun:sqlite").Database;
}
return _require("better-sqlite3");
} catch {
return null;
}
}
const Database = process.versions.bun
? (_require("bun:sqlite").Database as typeof import("better-sqlite3"))
: (_require("better-sqlite3") as typeof import("better-sqlite3"));
Expand All @@ -15,6 +25,8 @@ const getOmpDir = () => path.join(os.homedir(), ".omp", "agent");
const getOmpDbPath = () => path.join(getOmpDir(), "agent.db");

export function getOmpCredentials(providerId: string) {
const Database = getDatabaseClass();
if (!Database) return { hasOmniRoute: false, baseUrl: null, apiKey: null };
const dbPath = getOmpDbPath();
try {
const db = new Database(dbPath, databaseOptions(true));
Expand All @@ -36,6 +48,8 @@ export function getOmpCredentials(providerId: string) {
}

export function saveOmpCredentials(providerId: string, apiKey: string, baseUrl: string) {
const Database = getDatabaseClass();
if (!Database) return;
const dbPath = getOmpDbPath();
const db = new Database(dbPath, databaseOptions());

Expand All @@ -54,6 +68,8 @@ export function saveOmpCredentials(providerId: string, apiKey: string, baseUrl:
}

export function deleteOmpCredentials(providerId: string) {
const Database = getDatabaseClass();
if (!Database) return;
const dbPath = getOmpDbPath();
const db = new Database(dbPath, databaseOptions());
db.prepare("DELETE FROM auth_credentials WHERE provider = ?").run(providerId);
Expand Down