import{t as e}from"./DTkg6Mnx.js";import{i as t,n,r,t as i}from"./B4nPZT_f.js";var a=e(`data-safety`);function o(){return{}.CLEO_DISABLE_SAFETY===`true`}var s=class{inner;cwd;config;constructor(e,t,n){this.inner=e,this.cwd=t,this.config={enabled:!0,verbose:!1,...n},this.config.verbose&&a.debug({engine:e.engine},`SafetyDataAccessor initialized`)}get engine(){return this.inner.engine}logVerbose(e){this.config.verbose&&a.debug(e)}getSafetyOptions(){return{verify:this.config.enabled,checkpoint:this.config.enabled,validateSequence:this.config.enabled,strict:this.config.enabled}}async loadArchive(){return this.logVerbose(`Loading ArchiveFile (pass-through)`),this.inner.loadArchive()}async loadSessions(){return this.logVerbose(`Loading sessions (pass-through)`),this.inner.loadSessions()}async saveSessions(e){this.logVerbose(`Saving sessions with ${e.length} sessions`),await r(this.inner,e,this.cwd,this.getSafetyOptions())}async saveArchive(e){this.logVerbose(`Saving ArchiveFile with ${e.archivedTasks?.length??0} tasks`),await n(this.inner,e,this.cwd,this.getSafetyOptions())}async appendLog(e){this.logVerbose(`Appending log entry`),await i(this.inner,e,this.cwd,this.getSafetyOptions())}async upsertSingleTask(e){this.logVerbose(`Upserting single task ${e.id}`),await t(this.inner,e.id,()=>this.inner.upsertSingleTask(e),this.cwd,this.getSafetyOptions())}async archiveSingleTask(e,n){this.logVerbose(`Archiving single task ${e}`),await t(this.inner,e,()=>this.inner.archiveSingleTask(e,n),this.cwd,this.getSafetyOptions())}async removeSingleTask(e){this.logVerbose(`Removing single task ${e}`),await t(this.inner,e,()=>this.inner.removeSingleTask(e),this.cwd,this.getSafetyOptions())}async loadSingleTask(e){return this.inner.loadSingleTask(e)}async addRelation(e,t,n,r){await this.inner.addRelation(e,t,n,r)}async removeRelation(e,t,n){await this.inner.removeRelation(e,t,n)}async getAcRows(e){return this.inner.getAcRows(e)}async getAcBindings(e){return this.inner.getAcBindings(e)}async getMetaValue(e){return this.inner.getMetaValue(e)}async setMetaValue(e,t){return this.inner.setMetaValue(e,t)}async getSchemaVersion(){return this.inner.getSchemaVersion()}async queryTasks(e){return this.inner.queryTasks(e)}async queryAuditLog(e){return this.inner.queryAuditLog(e)}async countTasks(e){return this.inner.countTasks(e)}async getChildren(e){return this.inner.getChildren(e)}async countChildren(e){return this.inner.countChildren(e)}async countActiveChildren(e){return this.inner.countActiveChildren(e)}async getAncestorChain(e){return this.inner.getAncestorChain(e)}async getSubtree(e){return this.inner.getSubtree(e)}async getDependents(e){return this.inner.getDependents(e)}async getDependencyChain(e){return this.inner.getDependencyChain(e)}async taskExists(e){return this.inner.taskExists(e)}async loadTasks(e){return this.inner.loadTasks(e)}async updateTaskFields(e,n){this.logVerbose(`Updating fields on task ${e}`),await t(this.inner,e,()=>this.inner.updateTaskFields(e,n),this.cwd,this.getSafetyOptions())}async getNextPosition(e){return this.inner.getNextPosition(e)}async shiftPositions(e,t,n){return this.inner.shiftPositions(e,t,n)}async transaction(e){return this.logVerbose(`Starting transaction`),this.inner.transaction(e)}async getActiveSession(){return this.inner.getActiveSession()}async resolveCurrentSession(){return this.inner.resolveCurrentSession()}async upsertSingleSession(e){return this.inner.upsertSingleSession(e)}async removeSingleSession(e){return this.inner.removeSingleSession(e)}async listAgentInstances(e){return this.inner.listAgentInstances(e)}async getAgentInstance(e){return this.inner.getAgentInstance(e)}async claimTask(e,t){return this.inner.claimTask(e,t)}async unclaimTask(e){return this.inner.unclaimTask(e)}async close(){this.logVerbose(`Closing accessor`),await this.inner.close()}};function c(e,t){return o()?(a.warn(`Safety disabled - emergency mode (CLEO_DISABLE_SAFETY=true). Data integrity checks bypassed.`),e):new s(e,t)}export{c as wrapWithSafety};