UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

66 lines (65 loc) • 3.27 kB
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs"; import { a as getOrLoadSqliteDatabaseAdmissionForPath, b as publishSqliteDatabaseAdmission, h as peekSqliteDatabaseAdmissionForPath, o as getSqliteDatabaseAdmission } from "./sqlite-database-admission-DQIqro3d.mjs"; import { a as executeSqliteQueryTakeFirstSync, s as getNodeSqliteKysely } from "./kysely-sync-YJo2lmGV.mjs"; import { a as tableExists } from "./openclaw-state-db-schema-helpers-nImZNMq_.mjs"; import { isMainThread } from "node:worker_threads"; //#region src/agents/auth-profiles/persisted-rows-receipt.ts const rowsReceipt = { name: "auth-profiles.rows", read: (e) => isRecord(e) ? e : void 0 }; const initialReceipt = {}; function readAuthProfileRowsReceipt(e) { return peekSqliteDatabaseAdmissionForPath(e, rowsReceipt) ?? initialReceipt; } function publishAuthProfileRowsChanged(e) { publishSqliteDatabaseAdmission(e, rowsReceipt, {}); } //#endregion //#region src/state/config-machine-state-row.ts const catalogReceipt = { name: "model-catalog.remote", read: (e) => isRecord(e) ? e : void 0 }; function readRemoteModelCatalogReceipt(e) { return getOrLoadSqliteDatabaseAdmissionForPath(e, catalogReceipt, () => ({})) ?? {}; } const ttsPathAdmission = { name: "state.tts-prefs-path", read(e) { if (!isRecord(e)) return; const t = e.row; if (t === void 0) return { row: void 0 }; if (isRecord(t) && typeof t.value_json === "string" && typeof t.updated_at_ms === "number") return { row: { value_json: t.value_json, updated_at_ms: t.updated_at_ms } }; } }; /** Named row owners publish only the facts covered by this mutation. */ function publishConfigMachineStateRow(e, t, n) { if (t === "tts.prefsPath") publishSqliteDatabaseAdmission(e, ttsPathAdmission, { row: n }); else if (t === "authProfiles.store" || t === "authProfiles.state") publishAuthProfileRowsChanged(e); else if (t === "modelCatalog.remote.v3" || t === "modelCatalog.remote.v2" || t === "modelCatalog.remote") publishSqliteDatabaseAdmission(e, catalogReceipt, {}); } /** Host installation is serialized with the synchronous path writer, including absent values. */ function getTtsMachinePathAdmission(e, t) { return getOrLoadSqliteDatabaseAdmissionForPath(e, ttsPathAdmission, () => t ? { row: t() } : void 0); } function normalizeConfigMachineStateKey(e) { const t = e.trim(); if (!t) throw new Error("config machine state key must not be empty"); return t; } function readConfigMachineStateRowInDatabase(e, t) { const n = normalizeConfigMachineStateKey(t); const r = n === "tts.prefsPath" ? getSqliteDatabaseAdmission(e, ttsPathAdmission) : void 0; if (r) return r.row; if (!tableExists(e, "config_machine_state")) return; const i = getNodeSqliteKysely(e); const a = executeSqliteQueryTakeFirstSync(e, i.selectFrom("config_machine_state").select(["value_json", "updated_at_ms"]).where("state_key", "=", n)); if (isMainThread && n === "tts.prefsPath") publishConfigMachineStateRow(e, n, a); return a; } //#endregion export { readRemoteModelCatalogReceipt as a, readConfigMachineStateRowInDatabase as i, normalizeConfigMachineStateKey as n, publishAuthProfileRowsChanged as o, publishConfigMachineStateRow as r, readAuthProfileRowsReceipt as s, getTtsMachinePathAdmission as t };