UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 1.68 kB
import{a as e}from"./openclaw-state-read-openclaw-state-db.paths-CFemYLpA.mjs";import{a as t}from"./openclaw-state-read-record-coerce-D1s3ReAs.mjs";import{n}from"./openclaw-state-read-agent-id-DmscQLD6.mjs";import"./openclaw-state-read-session-key-DaKMXMbu.mjs";import{t as r}from"./openclaw-state-read-state-migrations.receipts-C4jnz6ia.mjs";function parseHolds(e){return e.map(e=>{if(!t(e)||typeof e.agentId!=`string`||e.agentId!==n(e.agentId)||typeof e.path!=`string`||!e.path.trim())throw Error(`Invalid agent database hold in deletion journal reconstruction receipt.`);return{agentId:e.agentId,path:e.path}})}function readReport(e){let n=r(e.db,`agent-deletion-journal-reconstruction`);if(!n)return;let i=JSON.parse(n.reportJson);if(!t(i)||typeof i.description!=`string`||!Array.isArray(i.held))throw Error(`Invalid agent deletion journal reconstruction receipt.`);let a=parseHolds(i.held);if(i.missingJournal!==void 0&&!Array.isArray(i.missingJournal))throw Error(`Invalid missing-journal provenance in deletion journal reconstruction receipt.`);let o=Array.isArray(i.missingJournal)?parseHolds(i.missingJournal):i.description===`Reconstructed the missing agent deletion journal; held databases require explicit agent restore or delete.`?a:[];if(o.some(e=>!a.some(t=>t.agentId===e.agentId&&t.path===e.path)))throw Error(`Missing-journal provenance refers to an unheld agent database.`);return{...i,description:i.description,held:a,missingJournal:o}}function decodeHolds(t,n){return n.map(n=>({agentId:n.agentId,path:e(t.path,n.path)}))}function readAgentDeletionRecoveryHolds(e){return decodeHolds(e,readReport(e)?.held??[])}export{readAgentDeletionRecoveryHolds as t};