UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 2.21 kB
import{d as e}from"./transcript-plugin-instance-invocation-7y9lfaeO.mjs";import{m as t,p as n}from"./transcript-agent-creation-claim-Da8lP1e6.mjs";import{s as r}from"./transcript-sqlite-post-commit-B_pko32i.mjs";import{a as i,i as a}from"./transcript-openclaw-agent-db.paths-DbFl2s5M.mjs";import{a as o,r as s}from"./transcript-kysely-sync-CAP5xe3V.mjs";import{v as c}from"./transcript-openclaw-state-db-cache-kzfc9rd-.mjs";import"./transcript-openclaw-agent-db-contract-DXUC0rkZ.mjs";import{h as l,t as u,u as d}from"./transcript-openclaw-agent-db-validation-cache-CKkKL5V4.mjs";import{n as f,t as p}from"./transcript-agent-deletion-journal-w8euRg8V.mjs";import{n as m}from"./transcript-openclaw-state-db-MJzYHUz2.mjs";import{n as h,s as g}from"./transcript-openclaw-agent-db-registry-listing-hSVmRkvc.mjs";import"node:path";import{statSync as _}from"node:fs";function resolveRegisteredAgentDatabaseStoredPath(r,a){let c=n(r.path,a.path);if(a.path!==e(a.path))return c;let l=o(r.db),{rows:u}=s(r.db,l.selectFrom(`agent_databases`).select(`path`).where(`agent_id`,`=`,a.agentId));return u.some(e=>e.path===c)?c:u.find(e=>i(t(r.path,e.path),a.path))?.path??c}function registerOpenClawAgentDatabase(e,t){if(!a(e.path,e.env)){e.admittedDb&&l({...e,db:e.admittedDb});return}let n=f({agentId:e.agentId,path:e.path},{env:e.env}),i=null;try{i=_(e.path).size}catch{i=null}let v=Date.now();if(t?.starting?.(),m(a=>{p(a,n);let l=resolveRegisteredAgentDatabaseStoredPath(a,e),u=o(a.db);s(a.db,u.insertInto(`agent_databases`).values({agent_id:e.agentId,path:l,schema_version:e.schemaVersion??38,last_seen_at:v,size_bytes:i}).onConflict(t=>t.columns([`agent_id`,`path`]).doUpdateSet({schema_version:e.schemaVersion??38,last_seen_at:v,size_bytes:i}))),g(a,`upsert`,[e]);let d=t?.committed;if(d){let t=Object.freeze({agentId:e.agentId,agentPath:e.path,stateDatabasePath:a.path,stateDatabaseIdentity:c(a).key});if(!r(a.db,{stage(){},rollback(){},commit:()=>d(t)}))throw Error(`Agent registration requires its canonical transaction publication scope`)}h(e.agentId,a.db)},{env:e.env,initializationAgentPaths:[e.path]}),e.admittedDb){let t={...e,db:e.admittedDb};u(t)||l(t)}else d(e.path)}export{registerOpenClawAgentDatabase as t};