UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

31 lines (30 loc) • 1.79 kB
import { a as executeSqliteQueryTakeFirstSync, o as getNodeSqliteKysely } from "./kysely-sync-DUWzQvCU.mjs"; import "./sqlite-schema-facts-BVf0E_0z.mjs"; import { i as tableExists } from "./openclaw-state-db-schema-helpers-DKz5xGgh.mjs"; import { s as withExistingOpenClawStateDatabaseArtifactPreservingReadOnly, u as withExistingOpenClawStateDatabaseReadOnly } from "./openclaw-state-db-readonly-ywwvuxdQ.mjs"; //#region src/state/config-machine-state.ts function normalizeConfigMachineStateKey(key) { const normalized = key.trim(); if (!normalized) throw new Error("config machine state key must not be empty"); return normalized; } function readConfigMachineStateRowInDatabase(database, key) { if (!tableExists(database, "config_machine_state")) return; const db = getNodeSqliteKysely(database); return executeSqliteQueryTakeFirstSync(database, db.selectFrom("config_machine_state").select(["value_json", "updated_at_ms"]).where("state_key", "=", normalizeConfigMachineStateKey(key))); } function readConfigMachineStateWithMetadata(key, options = {}, behavior = {}) { const read = ({ db: database }) => { const row = readConfigMachineStateRowInDatabase(database, key); return row ? { value: JSON.parse(row.value_json), updatedAtMs: row.updated_at_ms } : void 0; }; return behavior.artifactPreservingReadOnly ? withExistingOpenClawStateDatabaseArtifactPreservingReadOnly(read, options) : withExistingOpenClawStateDatabaseReadOnly(read, options); } function readConfigMachineState(key, options = {}, behavior = {}) { return readConfigMachineStateWithMetadata(key, options, behavior)?.value; } //#endregion export { readConfigMachineStateWithMetadata as i, readConfigMachineState as n, readConfigMachineStateRowInDatabase as r, normalizeConfigMachineStateKey as t };