UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 19.8 kB
import{n as e}from"./sqlite-readonly-rolldown-runtime-DJBNY8Aw.mjs";import{Et as t,Jt as n,Lt as r,r as i,t as a}from"./sqlite-readonly-subsystem-Bfq7Sewc.mjs";import{c as o,i as s,l as c,n as l,r as u,s as d,t as f}from"./sqlite-readonly-sqlite-snapshot-staging-owner-Bx_sVS1z.mjs";import{kt as p}from"./sqlite-readonly-runtime-process-manifest-DDSkIpjb.mjs";import{_ as m,d as h,g,h as _,i as v,m as y}from"./sqlite-readonly-sqlite-snapshot-capacity-error-CpnKAwJy.mjs";import{m as b,o as x,p as S}from"./sqlite-readonly-sqlite-readonly-location-CrsaHxKY.mjs";import{i as C}from"./sqlite-readonly-file-descriptor-XY1-VkqF.mjs";import{Tn as w,gn as T,ln as E,yn as D}from"./sqlite-readonly-sqlite-database-admission-Bj6bmeyX.mjs";import{r as O}from"./sqlite-readonly-path-existence-lfal2A68.mjs";import{s as k}from"./sqlite-readonly-openclaw-state-maintenance-context-BTKm0Xem.mjs";import{r as A,t as j}from"./sqlite-readonly-node-sqlite-C-jA8uc4.mjs";import{i as M,r as N,t as P}from"./sqlite-readonly-retained-operation-CV17ZGcz.mjs";import{n as F}from"./sqlite-readonly-sqlite-private-directory-C33vL62s.mjs";import{Ct as I,St as L,p as R}from"./sqlite-readonly-location.worker.js";import"./sqlite-readonly-pool-m9JiklDF.mjs";import{a as z}from"./sqlite-readonly-spawn-diagnostics-ChQW81dO.mjs";import B from"node:path";import{hash as V}from"node:crypto";import H,{closeSync as U,openSync as W}from"node:fs";import{AsyncLocalStorage as G}from"node:async_hooks";function sha256Base64Url(e){return V(`sha256`,e,`base64url`)}function sha256FileSync(e){let t=W(e,`r`);try{return C(t).digest}finally{U(t)}}const K=r(Symbol.for(`openclaw.sqliteSnapshotFlights`),()=>({unscoped:/* @__PURE__ */ new Map,scoped:/* @__PURE__ */ new WeakMap}));function completed$1(e){let t=P(()=>{});return t.resolve(e),t.operation}function serviceWhenSettled(e,t){e.result.then(t,t)}function createFlight(e,t,n){let r,i=!1,a=!1,o,s,c,l=P(()=>{if(!(a||l.operation.read().status!==`pending`)){a=!0;try{i||(i=!0,r=n(d.controller.signal,e=>c=e),serviceWhenSettled(r.operation,serviceFlight)),r.operation.service();let e=r.operation.read();e.status===`fulfilled`?l.resolve(e.value):e.status===`rejected`&&l.reject(e.error)}catch(e){l.reject(e)}finally{a=!1}}}),u=P(()=>{l.operation.service();let n=l.operation.read();if(n.status!==`pending`&&u.operation.read().status===`pending`){if(e.get(t)===d&&e.delete(t),n.status===`rejected`)u.reject(c??n.error);else if(d.references>0)u.resolve(n.value);else{o||(o=releaseSnapshot(d,n.value),serviceWhenSettled(o,()=>u.operation.service())),o.service();let e=o.read();e.status===`fulfilled`?e.value?u.resolve(n.value):u.reject(new w(`SQLite orphan snapshot cleanup did not complete`)):e.status===`rejected`&&u.reject(e.error)}}});function serviceFlight(){l.operation.service();for(let e of d.listeners)e();u.operation.service()}let d={controller:new AbortController,references:0,listeners:/* @__PURE__ */ new Set,production:l.operation,settled:u.operation,closeProducer(){return s??=r?.startClose?.()??completed$1(void 0),s}};return m(u.operation.result,()=>{d.controller.abort(/* @__PURE__ */ Error(`SQLite snapshot owner stopped`)),serviceFlight()}),d}function releaseSnapshot(e,t){return N(t.startCleanup(),t=>t?M(e.closeProducer(),()=>!0):completed$1(!1))}function leaseFlight(e,t){let n=!1,r,releaseReference=()=>(n||(n=!0,e.references--),e.references===0),startCleanup=()=>(r??=!n&&releaseReference()?releaseSnapshot(e,t):completed$1(!0),r);return{location:t.location,cleanupRoot:t.cleanupRoot,privateFamily:t.privateFamily,cleanup(){if(n){let e=r?.read();return!e||e.status===`fulfilled`&&e.value}if(e.references>1)return releaseReference(),!0;let i=t.cleanup();return i&&releaseReference(),i},cleanupAsync:()=>startCleanup().result,startCleanup}}function startSnapshotFlight(e,t,n,r,i){r?.throwIfAborted();let a=`${D(e).key}:${t}`,o=K.unscoped;if(i?.scope){let e=K.scoped.get(i.scope);e||(e=/* @__PURE__ */ new Map,K.scoped.set(i.scope,e)),o=e}let s=o.get(a);s||(s=createFlight(o,a,n),o.set(a,s));let c=s;c.references++;let l=!1,u=!1,d,f=P(()=>{if(f.operation.read().status===`pending`){if(l||r?.aborted){if(u||(u=!0,c.references--),c.references===0&&(c.controller.abort(r?.reason),o.get(a)===c&&o.delete(a),c.settled.service(),c.settled.read().status===`pending`))return;f.reject(r?.reason??/* @__PURE__ */ Error(`SQLite snapshot preparation closed`))}else{c.production.service();let e=c.production.read();if(e.status===`pending`)return;e.status===`fulfilled`?f.resolve(leaseFlight(c,e.value)):(c.references--,f.reject(e.error))}r?.removeEventListener(`abort`,service),c.listeners.delete(service),c.settled.service()}}),service=()=>f.operation.service();return serviceWhenSettled(c.settled,service),c.listeners.add(service),r?.addEventListener(`abort`,service,{once:!0}),queueMicrotask(service),{...f.operation,startClose(){l=!0,f.operation.service();let e=f.operation.read();return d??=e.status===`fulfilled`?M(e.value.startCleanup(),e=>{if(!e)throw new w(`SQLite snapshot lease cleanup did not complete`)}):c.references===0?c.closeProducer():completed$1(void 0),d}}}function startAwaitedSnapshotWork(e){let t=P(()=>{});return Promise.resolve().then(e).then(t.resolve,t.reject),t.operation}async function prepareSingleFlightSqliteSnapshot(e,t,n,r,i){return startSnapshotFlight(e,t,(e,t)=>({operation:startAwaitedSnapshotWork(async()=>{let r=await n(e,t);return{...r,startCleanup:()=>startAwaitedSnapshotWork(()=>r.cleanupAsync())}})}),r,i).result}function startSingleFlightSqliteSnapshot(e,t,n,r,i){return startSnapshotFlight(e,t,(e,t)=>{let r=n(e,t);return{operation:r,startClose:()=>r.startClose()}},r,i)}const q=r(Symbol.for(`openclaw.sqliteLiveSnapshotOwners`),()=>/* @__PURE__ */ new Map);function registerLiveSqliteSnapshotOwner(e){let t=D(e.databasePath),n={assertCurrent:e.assertCurrent,database:e.database};return q.set(t.key,n),()=>{q.get(t.key)===n&&q.delete(t.key)}}function prepareSqliteSnapshotFromLiveOwner(e,t){t?.throwIfAborted();let n=D(e),r=q.get(n.key);if(r)return r.assertCurrent(),prepareSingleFlightSqliteSnapshot(n.canonicalPath,`live-owner:openclaw-state`,e=>x(r.database,r.assertCurrent,e),t)}const J=r(Symbol.for(`openclaw.sqliteReusableSnapshots`),()=>/* @__PURE__ */ new Map),Y=r(Symbol.for(`openclaw.sqliteReusableSnapshotScopes`),()=>({depth:0,retiring:/* @__PURE__ */ new Set}));function isSqliteSnapshotReuseActive(){return Y.depth>0}function completed(e){let t=P(()=>{});return t.resolve(e),t.operation}function readSource(e){try{let t=H.statSync(e,{bigint:!0,throwIfNoEntry:!1});if(!t?.isFile()||H.statSync(`${e}-journal`,{throwIfNoEntry:!1}))return;let n=H.statSync(`${e}-wal`,{bigint:!0,throwIfNoEntry:!1}),r=n&&n.size>0n?n:void 0;return{fingerprint:[`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,r?`${r.dev}:${r.ino}:${r.size}:${r.mtimeNs}`:`none`].join(`|`),main:t,newestMs:Math.max(Number(t.mtimeMs),Number(r?.mtimeMs??0)),quiescentMs:[t,r].some(e=>e&&e.mtimeNs%1000000000n==0n)?2e3:50}}catch{return}}function canonicalKey(e){try{return H.realpathSync.native(e)}catch{return}}function retire(e,t){J.get(e)===t&&J.delete(e),t.retired=!0,t.leases===0&&settleRetirement(t.retire)}function settleRetirement(e){let t=new Promise(t=>{t(e())}).catch(reportRetirementFailure).finally(()=>Y.retiring.delete(t));Y.retiring.add(t)}function reportRetirementFailure(e){i({subsystem:`infra/sqlite-snapshot`}).warn({error:String(e)},`Retiring a reusable SQLite snapshot failed.`)}function lend(e,t){t.leases+=1;let n=!1,release=()=>(n||(n=!0,--t.leases,t.leases===0&&t.retired&&retire(e,t)),!0);return{location:t.location,cleanupRoot:t.cleanupRoot,privateFamily:t.privateFamily,cleanup:release,cleanupAsync:async()=>release(),startCleanup:()=>completed(release())}}function leaseReusableSqliteSnapshot(e,t,n={}){let r=canonicalKey(e),i=r?J.get(r):void 0;if(r&&i){if(readSource(r)?.fingerprint!==i.fingerprint||!H.existsSync(i.location))retire(r,i);else if(!i.logicalOnly||n.logicalReader){if(t)try{E(i.main,t)}catch{return}return lend(r,i)}}}function captureReusableSqliteSource(e){let t=Y.depth>0?canonicalKey(e):void 0,n=t?readSource(t):void 0;return n&&Date.now()-n.newestMs>=n.quiescentMs?n:void 0}function captureFamily(e){try{return R(e.location,e.cleanupRoot??B.dirname(e.location))}catch{return}}const X=r(Symbol.for(`openclaw.sqliteReusableSnapshotSources`),()=>/* @__PURE__ */ new Map);function bindReusableSqliteSource(e,t){t&&X.set(e,t)}function publishBoundReusableSqliteSnapshot(e,t,n){let r=canonicalKey(e)??B.resolve(e),i=J.get(r),a=X.get(t.location)??(i?.location===t.location?i:void 0);return X.delete(t.location),a?publishReusableSqliteSnapshot(e,a,t,n):t}function publishReusableSqliteSnapshot(e,t,n,r,i={}){let a=canonicalKey(e)??B.resolve(e),o=J.get(a);if(o?.location===n.location&&o.fingerprint===t.fingerprint)return settleRetirement(r),lend(a,o);o&&retire(a,o);let s={...t,logicalOnly:i.logicalOnly===!0,location:n.location,cleanupRoot:n.cleanupRoot,privateFamily:n.privateFamily??captureFamily(n),leases:0,retired:!1,retire:r};return J.set(a,s),lend(a,s)}function createLeasedSqliteSnapshotPreparation(e){return{...completed(e),startClose:()=>M(e.startCleanup(),()=>void 0)}}const Z=[``,`-wal`,`-shm`,`-journal`],Q=Z.slice(1);Buffer.from([0,5,22,7]);const $=a(`state/sqlite`);var SqliteOrphanedSidecarsError=class extends Error{constructor(e,t,n){super(`SQLite database is missing at ${e}, and orphaned sidecars could not be copied: ${t.join(`, `)}. Refusing to open because SQLite could delete orphan WAL or journal state. Preserve the sidecar bytes, restore the main database, and pair it with the matching sidecar before retrying.`,{cause:n}),this.name=`SqliteOrphanedSidecarsError`}};function resolveSqliteDatabaseFilePaths(e){return Z.map(t=>`${e}${t}`)}function findMatchingOrphanedSidecarCopy(e,t){let n=B.dirname(e),r=`${B.basename(e)}.orphaned-`,i=H.readdirSync(n,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.startsWith(r)).map(e=>B.join(n,e.name)).filter(e=>H.statSync(e).size===t);if(i.length===0)return;let a=sha256FileSync(e);for(let e of i)if(sha256FileSync(e)===a)return e}function copyOrphanedSidecar(e,t){let n=`${e}.orphaned-${t}`;for(let t=0;;t+=1){let r=t===0?n:`${n}-${t}`;try{return H.copyFileSync(e,r,H.constants.COPYFILE_EXCL),r}catch(e){if(e.code!==`EEXIST`)throw e}}}function quarantineOrphanedSqliteSidecars(e){if(H.existsSync(e))return;let t=[{path:`${e}-wal`,minimumBytes:32},{path:`${e}-journal`,minimumBytes:0}].flatMap(e=>{let t=H.statSync(e.path,{throwIfNoEntry:!1});return t?.isFile()===!0&&t.size>e.minimumBytes?[{path:e.path,size:t.size}]:[]});if(t.length===0)return;let n=Date.now(),r=[];try{for(let e of t){if(findMatchingOrphanedSidecarCopy(e.path,e.size))continue;let t=copyOrphanedSidecar(e.path,n);r.push({quarantinePath:t,sourcePath:e.path})}}catch(n){throw new SqliteOrphanedSidecarsError(e,t.map(e=>e.path),n)}if(r.length===0)return;let i=r.map(({sourcePath:e,quarantinePath:t})=>`${e} -> ${t}`);$.warn(`SQLite database is missing at ${e}; copied orphaned sidecars: ${i.join(`, `)}. Committed frames could not be applied because the main database is missing. The bytes are preserved. Recovery requires restoring the main database and pairing it with the quarantined file.`,{databasePath:e,copiedSidecars:r})}function buildUpdateRehearsalPathEnv(e){return{HOME:e,USERPROFILE:e,TMPDIR:e,TMP:e,TEMP:e,XDG_CONFIG_HOME:B.join(e,`config`),XDG_CACHE_HOME:B.join(e,`cache`),XDG_DATA_HOME:B.join(e,`data`),XDG_STATE_HOME:B.join(e,`state`),OPENCLAW_HOME:e,OPENCLAW_STATE_DIR:e,OPENCLAW_CONFIG_PATH:B.join(e,`openclaw.json`),OPENCLAW_WORKSPACE_DIR:B.join(e,`workspace`),OPENCLAW_SKIP_CHANNELS:`1`,OPENCLAW_SKIP_PROVIDERS:`1`,OPENCLAW_SKIP_CRON:`1`,OPENCLAW_SKIP_GMAIL_WATCHER:`1`,OPENCLAW_SKIP_CANVAS_HOST:`1`,OPENCLAW_SKIP_BROWSER_CONTROL_SERVER:`1`,OPENCLAW_SKIP_STARTUP_MODEL_PREWARM:`1`,OPENCLAW_NO_AUTO_UPDATE:`1`,NODE_DISABLE_COMPILE_CACHE:`1`}}function projectUpdateRehearsalDatabaseConfig(e,t){if(!n(e)||!n(e.database)||!resolveUpdateRehearsalRoot(t))return e;let{engine:r,families:i}=e.database;return r===`postgres`||n(i)&&Object.values(i).some(e=>n(e)&&e.engine===`postgres`)?{...e,database:{engine:`sqlite`}}:e}function resolveUpdateRehearsalRoot(e){let t=e.OPENCLAW_STATE_DIR;if(t&&B.isAbsolute(t)&&[`0`,`1`].includes(e.OPENCLAW_UPDATE_IN_PROGRESS??``)&&!Object.entries(buildUpdateRehearsalPathEnv(t)).some(([t,n])=>e[t]!==n)&&e.OPENCLAW_SERVICE_REPAIR_POLICY===`external`&&e.OPENCLAW_UPDATE_PARENT_ALLOWS_GATEWAY_SERVICE_REPAIR===`0`&&e.OPENCLAW_UPDATE_PARENT_ALLOWS_GATEWAY_ACTIVATION===`0`&&!e.OPENCLAW_COMPATIBILITY_HOST_VERSION)return B.resolve(t)}function isUpdateRehearsalReadOnlyPath(e,t){let n=resolveUpdateRehearsalRoot(t);if(!n)return!1;let r=B.resolve(e);return!p(n,r)||!p(O(n),O(r))}function isUpdateRehearsalPrivateDatabase(e,t){return resolveUpdateRehearsalRoot(t)!==void 0&&resolveSqliteDatabaseFilePaths(e).every(e=>!isUpdateRehearsalReadOnlyPath(e,t))}var ee=/* @__PURE__ */ e({openSqliteReadOnlyDatabase:()=>openSqliteReadOnlyDatabase,prepareSqliteReadOnlyLocation:()=>prepareSqliteReadOnlyLocation,prepareSqliteReadOnlyLocationAwaited:()=>prepareSqliteReadOnlyLocationAwaited,prepareSqliteReadOnlyLocationSync:()=>prepareSqliteReadOnlyLocationSync,startSqliteReadOnlyLocationAsync:()=>startSqliteReadOnlyLocationAsync});function findArtifactSnapshot(e,t){let n=e.snapshots.get(t.canonicalPath);if(n&&(n.sourceIdentity.key!==t.key||n.sourceIdentity.birthtime!==t.birthtime))throw Error(`SQLite database file identity changed during inspection`);return n}function retainArtifactSnapshot(e,t,n){let r=g(t.cleanupRoot??B.dirname(t.location));e.privateRoots.add(t.cleanupRoot??B.dirname(t.location));let i={...t,sourceIdentity:n,cleanup:()=>(r(),t.cleanup()),cleanupAsync:()=>(r(),t.cleanupAsync())};return e.snapshots.set(n.canonicalPath,i),i}function assertCustodiedSourceUnchanged(e,t){let n=H.statSync(e,{bigint:!0,throwIfNoEntry:!1});if(!n||n.ino!==t.ino||n.size!==t.size||n.mtimeNs!==t.mtimeNs||k(e)===void 0)throw Error(`SQLite source changed during in-place inspection: ${e}`)}function openSqliteReadOnlyDatabase(e,t={}){let n=L.getStore();if(!n||!I(`agent`,e))return j(e,{...t,readOnly:!0});let r=D(e),i=findArtifactSnapshot(n,r),a=i?void 0:k(r.canonicalPath);i||a||isUpdateRehearsalPrivateDatabase(e,process.env)||(i=retainArtifactSnapshot(n,prepareSqliteReadOnlyLocationSync(e),r));let o=i?g(i.cleanupRoot??B.dirname(i.location)):void 0,s={},close=()=>{s.close?.(),o?.(),n.readers.delete(close)};n.readers.add(close);let c=i?.location??(a?A(r.canonicalPath):e),l=j(c,{...t,readOnly:!0}),u=l.close.bind(l);return s.close=()=>{l.isOpen&&(u(),a&&assertCustodiedSourceUnchanged(r.canonicalPath,a))},l.close=close,l}async function prepareSqliteReadOnlyLocation(e,n={}){let r=z(n.signal),i=n.preserveSourceArtifacts===!0||I(`agent`,e);try{if(r?.throwIfAborted(),!i&&n.allowLiveOwner!==!1){let t=prepareSqliteSnapshotFromLiveOwner(e,r);if(t)return await t}r?.throwIfAborted();let a=n.reuse===!0&&i,o=a?leaseReusableSqliteSnapshot(e,n.expectedSourceIdentity):void 0;if(o)return o;let s=n.requireCleanup??n.signal!==void 0,c=prepareSingleFlightSqliteSnapshot(e,`${i?`worker-sync`:`worker-async`}:${s?`strict`:`best-effort`}:sync-token${n.expectedSourceIdentity?`:${JSON.stringify(n.expectedSourceIdentity)}`:``}`,async(r,o)=>{let c,l=a?captureReusableSqliteSource(e):void 0;try{r.throwIfAborted(),c=await S(void 0,!1,r),r.throwIfAborted();let t=await d(e,{mode:i?`sync`:`async`,signal:r,stagingRoot:c,expectedSourceIdentity:n.expectedSourceIdentity});r.throwIfAborted(),bindReusableSqliteSource(t,l);let o=v(t,c,s);return a&&(o.privateFamily=captureFamily(o)),o}catch(e){if(c&&!await _(c)){let n=new w(`${t(e)}; SQLite snapshot cleanup failed: ${c}`,{cause:e});throw o?.(n),n}throw e instanceof w?(o(e),e):(r.throwIfAborted(),e)}},r,n.shared===!1?{scope:{}}:void 0);return a?c.then(t=>publishBoundReusableSqliteSnapshot(e,t,()=>t.cleanup())):c}catch(e){throw r?.throwIfAborted(),e}}function startSqliteReadOnlyLocationAsync(e,t={}){let n=z(t.signal);n?.throwIfAborted();let r=B.resolve(e),i=t.preserveSourceArtifacts===!0||I(`agent`,r),a=t.expectedSourceIdentity===void 0?void 0:T(t.expectedSourceIdentity);if(a&&!i)throw Error(`SQLite source identity requires artifact-preserving preparation`);let o=t.reuse&&i?leaseReusableSqliteSnapshot(r,a):void 0;if(o)return createLeasedSqliteSnapshotPreparation(o);let c=t.signal!==void 0,{env:u,cwd:d}=l(),p=F(),m=s(),h=f(),g=G.snapshot();return startSingleFlightSqliteSnapshot(r,`${i?`worker-sync`:`worker-async`}:${c?`strict`:`best-effort`}:async-token${a?`:${JSON.stringify(a)}`:``}`,e=>g(()=>{let t=h.start({type:`prepare`,root:p,pathname:r,allowLegacyWorker:!1,preserveSourceArtifacts:i,expectedSourceIdentity:a,deadlineOwnedByCaller:m,launch:{env:u,cwd:d,transport:{kind:`native`}}},e);return{...M(t,e=>{if(e.type!==`prepared`)throw Error(`SQLite snapshot producer returned an allocation without its prepared location`);let t=v(e.location,e.directory,c);return t.privateFamily=i?R(e.location,e.directory):void 0,t}),startClose:()=>t.startClose()}}),n,{scope:h})}async function prepareSqliteReadOnlyLocationAwaited(e,t){let n=z(t.signal),r=B.resolve(e),i=T(t.expectedSourceIdentity);return(t.reuse?leaseReusableSqliteSnapshot(r,i):void 0)||(t.reuse&&!t.allowLiveOwner&&isSqliteSnapshotReuseActive()?prepareSqliteReadOnlyLocation(r,{preserveSourceArtifacts:!0,signal:n,requireCleanup:!0,reuse:!0,expectedSourceIdentity:i}):prepareSingleFlightSqliteSnapshot(r,`worker-${t.allowLiveOwner?`metadata`:`sync`}:strict:awaited-token:${JSON.stringify(i)}`,async(e,n)=>{let a=t.allowLiveOwner;return useAwaitedSnapshotWorker(e,n,async(t,n)=>{let s={mode:a?`metadata`:`sync`,stagingRoot:n,expectedSourceIdentity:i,signal:e},c=a?await o(r,s):await t.run(r,s);if(typeof c!=`string`)throw Error(`SQLite snapshot preparation returned an invalid location`);return e.throwIfAborted(),v(c,n,!0)})},n))}async function useAwaitedSnapshotWorker(e,t,n){e.throwIfAborted();let r=l(),i=u({...r,retainOnOperationError:!0}),a,o,retire=()=>{if(o&&o.read().status!==`rejected`)return o;let e=P(()=>{});return o=e.operation,(async()=>{if(a){let e=i.isRetired();e&&(await i.close(),i=u(r)),await i.run(a,{mode:e?`staging-reconcile`:`staging-retire`})}await i.close(),await i.closed,a&&await H.promises.rm(a,{recursive:!0,force:!0,maxRetries:3,retryDelay:20})})().then(e.resolve,e.reject),o};try{let t=await i.run(F(),{mode:`staging-create`,signal:e});if(typeof t!=`string`)throw Error(`SQLite snapshot allocation returned an invalid directory`);a=t,h(a,retire),e.throwIfAborted();let r=await n(i,a);return e.throwIfAborted(),r}catch(e){try{if(a){if(!await _(a))throw new w(`SQLite snapshot cleanup failed: ${a}`)}else await i.close(),await i.closed}catch(n){let r=AggregateError([e,n],`SQLite snapshot preparation and cleanup failed`);throw t?.(r),r}throw e}}function prepareSqliteReadOnlyLocationSync(e,n,r={}){let i=r.reuse?leaseReusableSqliteSnapshot(e,n):void 0;if(i)return i;let a=r.reuse?captureReusableSqliteSource(e):void 0,o=b();try{let t=v(c(e,o,`sync`,n),o);return a?publishReusableSqliteSnapshot(e,a,t,()=>t.cleanup()):t}catch(e){throw y(o)?e:new w(`${t(e)}; SQLite snapshot cleanup failed: ${o}`,{cause:e})}}export{registerLiveSqliteSnapshotOwner as _,ee as a,projectUpdateRehearsalDatabaseConfig as c,quarantineOrphanedSqliteSidecars as d,resolveSqliteDatabaseFilePaths as f,publishReusableSqliteSnapshot as g,leaseReusableSqliteSnapshot as h,prepareSqliteReadOnlyLocationSync as i,resolveUpdateRehearsalRoot as l,isSqliteSnapshotReuseActive as m,prepareSqliteReadOnlyLocation as n,startSqliteReadOnlyLocationAsync as o,captureReusableSqliteSource as p,prepareSqliteReadOnlyLocationAwaited as r,isUpdateRehearsalPrivateDatabase as s,openSqliteReadOnlyDatabase as t,Q as u,sha256Base64Url as v};