fix(ai-vault): require node:sqlite backup support in remote SQLite probes (#24086)

* fix(ai-vault): require the full SyncDatabase node:sqlite surface in host SQLite probes

The SSH and WSL OpenCode probes admitted any Node with DatabaseSync, so
Node 22.13-22.15 hosts (no backup export) skipped the pinned-runtime
fallback. Share one admission predicate with isSqliteAvailable() and
embed its source in both probe scripts.

* build(cli): list the node:sqlite admission predicate in the CLI project

---------

Co-authored-by: m4air <m4air@m4airs-Air.localdomain>
This commit is contained in:
OrcaWin
2026-09-30 22:57:01 -07:00
committed by GitHub
co-authored by m4air
parent 07e9fdfd13
commit 3fe4b18dae
9 changed files with 131 additions and 4 deletions
@@ -0,0 +1,30 @@
import { runInNewContext } from 'node:vm'
import { describe, expect, it } from 'vitest'
import { hasNodeSqliteReaderApi, NODE_SQLITE_READER_API_SOURCE } from './node-sqlite-reader-api'
const probe = (sqlite: unknown): unknown =>
runInNewContext(`(${NODE_SQLITE_READER_API_SOURCE})(sqlite)`, { sqlite })
class DatabaseSync {}
const backup = async (): Promise<void> => {}
describe('node:sqlite reader admission', () => {
it.each([
['DatabaseSync with backup (Node >= 22.16)', { DatabaseSync, backup }, true],
['DatabaseSync without backup (Node 22.13-22.15)', { DatabaseSync }, false],
['backup without DatabaseSync', { backup }, false],
['non-function DatabaseSync', { DatabaseSync: {}, backup }, false],
['non-function backup', { DatabaseSync, backup: true }, false],
['missing module', undefined, false],
['null module', null, false]
])('agrees in-process and in the embedded probe for %s', (_label, sqlite, admitted) => {
expect(hasNodeSqliteReaderApi(sqlite)).toBe(admitted)
expect(probe(sqlite)).toBe(admitted)
})
it('admits the actual runtime module', () => {
const sqlite: unknown = process.getBuiltinModule('node:sqlite')
expect(hasNodeSqliteReaderApi(sqlite)).toBe(true)
expect(probe(sqlite)).toBe(true)
})
})