openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
41 lines (40 loc) • 2.02 kB
JavaScript
import { t as clearNodeSqliteKyselyCacheForDatabase } from "./kysely-sync-cache-state-D75yJYFp.mjs";
import { S as getNodeSqliteKysely, x as executeSqliteQueryTakeFirstSync } from "./openclaw-state-db-schema-helpers-Bn-sHIhd.mjs";
import { a as setSqliteBusyTimeout } from "./sqlite-busy-timeout-BbWQYMTz.mjs";
import { t as openNodeSqliteDatabase } from "./node-sqlite-DrCtoYsd.mjs";
import { i as assertSupportedStateSchemaVersion } from "./openclaw-state-db-schema-version-86tJzspq.mjs";
//#region src/agents/harness/native-hook-relay-bridge-query.ts
function readNativeHookRelayBridgeRow(e, t) {
const n = getNodeSqliteKysely(e);
return executeSqliteQueryTakeFirstSync(e, n.selectFrom("native_hook_relay_bridges").selectAll().where("relay_id", "=", t));
}
//#endregion
//#region src/agents/harness/native-hook-relay-bridge-record.ts
/** Validate and convert a persisted native relay locator row. */
function readNativeHookRelayBridgeRecordRow(e) {
if (!e || typeof e.relay_id !== "string" || e.relay_id.length === 0 || !Number.isSafeInteger(e.pid) || e.hostname !== "127.0.0.1" || !Number.isSafeInteger(e.port) || Number(e.port) <= 0 || Number(e.port) > 65535 || typeof e.token !== "string" || e.token.length === 0 || !Number.isSafeInteger(e.expires_at_ms)) return;
return {
relayId: e.relay_id,
pid: Number(e.pid),
hostname: e.hostname,
port: Number(e.port),
token: e.token,
expiresAtMs: Number(e.expires_at_ms)
};
}
//#endregion
//#region src/agents/harness/native-hook-relay-client-read.ts
/** One-shot locator admission never initializes or migrates shared state. */
function readNativeHookRelayClientRecord(e, t) {
const n = openNodeSqliteDatabase(e.stateDbPath, { readOnly: true });
try {
setSqliteBusyTimeout(n, t);
assertSupportedStateSchemaVersion(n, e.stateDbPath);
return readNativeHookRelayBridgeRecordRow(readNativeHookRelayBridgeRow(n, e.relayId));
} finally {
clearNodeSqliteKyselyCacheForDatabase(n);
n.close();
}
}
//#endregion
export { readNativeHookRelayClientRecord };