forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup.ts
More file actions
35 lines (31 loc) · 1.56 KB
/
Copy pathstartup.ts
File metadata and controls
35 lines (31 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Agent-kernel startup guard. Runs at app boot to validate the production
// SQLite path (the real better-sqlite3 driver, rebuilt for Electron's ABI) that
// unit tests cannot exercise — they inject node:sqlite instead. This is the
// runtime complement to store.test.ts's structural coverage.
//
// Kill-switch philosophy: this is a NON-FATAL guard. If the bundled SQLite
// runtime can't support the AgentStore feature set, or the store can't open its
// database, we log and continue — the app runs, the agent kernel just isn't
// available. It must never crash the app on boot.
//
// PR #3a scope: probe + open/migrate/close only. The AgentRuntimeKernel singleton
// and chat routing are wired in later PRs; nothing consumes the store yet.
import { probeSqliteRuntime, SqliteAgentStore } from './store'
export function probeAgentStoreRuntimeAtStartup(): void {
try {
// 1. Fail-fast feature probe on a throwaway :memory: db (STRICT tables,
// json_valid CHECKs, partial-unique indexes) using the real driver.
probeSqliteRuntime()
// 2. Open the production database on the real driver: exercises migrate()
// (all 14 migrations) + reconcileStartup() against the actual on-disk
// file. Closed immediately — no consumer holds it in this PR.
const store = new SqliteAgentStore()
store.close()
console.log('[agent-kernel] SQLite runtime probe + store open/migrate succeeded')
} catch (error) {
console.error(
'[agent-kernel] SQLite runtime guard failed — agent kernel will be unavailable this session:',
error
)
}
}