UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.09 kB
import{r as e}from"./openclaw-state-read-semver-CqfGj9gv.mjs";import{v as t}from"./openclaw-state-read-read-open-flags-CtNL1rJs.mjs";import{a as n}from"./openclaw-state-read-openclaw-state-db.paths-CFemYLpA.mjs";import{u as r}from"./openclaw-state-read-sqlite-post-commit-CEHMNIsB.mjs";import{r as i}from"./openclaw-state-read-sqlite-files-B6lm_PVC.mjs";import{a,i as o,r as s}from"./openclaw-state-read-kysely-sync-DQyYiAw5.mjs";import{T as c,o as l}from"./openclaw-state-read-sqlite-schema-facts-DxLfPKu-.mjs";import{o as u}from"./openclaw-state-read-openclaw-state-db-schema-helpers-BkqUYEFY.mjs";import{n as d}from"./openclaw-state-read-agent-id-DmscQLD6.mjs";import{r as f}from"./openclaw-state-read-openclaw-state-db-admission--7YB7DUG.mjs";import{g as p,m,p as h}from"./openclaw-state-read.worker.js";import"./openclaw-state-read-session-key-DaKMXMbu.mjs";import{lstatSync as g,statSync as _}from"node:fs";import v from"node:path";var y=/* @__PURE__ */ e({hasUnavailableMissingSqlitePath:()=>hasUnavailableMissingSqlitePath,readAgentDatabasePreflightTargets:()=>readAgentDatabasePreflightTargets,readOpenClawAgentDatabaseRegistryRows:()=>readOpenClawAgentDatabaseRegistryRows,readRegisteredAgentDatabaseRows:()=>readRegisteredAgentDatabaseRows});const b=/* @__PURE__ */ new WeakSet;function hasUnavailableMissingSqlitePath(e){for(let n of i(e))try{return g(n),!0}catch(e){if(!t(e,`ENOENT`))return!0}let n=v.dirname(e);for(;;){try{let e=g(n);if(!e.isSymbolicLink())return!e.isDirectory();try{return!_(n).isDirectory()}catch{return!0}}catch(e){if(!t(e,`ENOENT`))return!0}let e=v.dirname(n);if(e===n)return!1;n=e}}function readOpenClawAgentDatabaseRegistryRows(e,t){let n=a(e),i=l(e),c=r(e)?u(e,`agent_databases`)?{type:`table`}:void 0:i?i.tables.has(`agent_databases`)?{type:`table`}:i.views.has(`agent_databases`)||i.indexes.has(`agent_databases`)||i.triggers.has(`agent_databases`)?{type:`invalid`}:void 0:o(e,n.selectFrom(`sqlite_master`).select(`type`).where(`name`,`=`,`agent_databases`));if(!c)return[];if(c.type!==`table`)throw Error(`OpenClaw state database ${t} has an invalid agent registry.`);return s(e,n.selectFrom(`agent_databases`).selectAll().orderBy(`agent_id`,`asc`).orderBy(`path`,`asc`)).rows}function readAgentDatabasePreflightTargets(e,t){return readOpenClawAgentDatabaseRegistryRows(e,t).flatMap(e=>typeof e.agent_id==`string`&&typeof e.path==`string`?[{agentId:e.agent_id,path:n(t,e.path)}]:[])}function readRegisteredAgentDatabaseRows(e,t,i){if(r(e))i&&c(`postgres`,`file-snapshot`);else if(!f(e)){if(i)m(e,t);else{let n=l(e);if(!n||!b.has(n)){if(p(e,t).some(({kind:e})=>h[e].includes(`agent_databases`)))throw Error(`OpenClaw state database ${t} has a legacy agent database registry schema; run openclaw doctor --fix to migrate it.`);n&&b.add(n)}}}return readOpenClawAgentDatabaseRegistryRows(e,t).map(e=>({agentId:d(e.agent_id),path:n(t,e.path),schemaVersion:e.schema_version,lastSeenAt:e.last_seen_at,sizeBytes:e.size_bytes}))}export{readRegisteredAgentDatabaseRows as i,y as n,readAgentDatabasePreflightTargets as r,hasUnavailableMissingSqlitePath as t};