UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 27.3 kB
import{n as e}from"./openclaw-state-read-rolldown-runtime-C7TU3oOp.mjs";import{gn as t,xt as n}from"./openclaw-state-read-subsystem-Dwoo5bcz.mjs";import{F as r}from"./openclaw-state-read-openclaw-state-db-cache-DyomEqgV.mjs";import{a as i,c as a,f as o,i as s,n as c,p as l,r as u,s as d,t as f,u as p}from"./openclaw-state-read-row-codec-CeR1CPnW.mjs";import{o as m}from"./openclaw-state-read-sqlite-schema-facts-Dtolu7-X.mjs";import{a as h,r as g,u as _}from"./openclaw-state-read-kysely-sync-Bcu0Qb7F.mjs";import{a as v}from"./openclaw-state-read-sqlite-transaction-Bt-IwVhZ.mjs";import"./openclaw-state-read.worker.js";import{i as y}from"./openclaw-state-read-agent-deletion-journal-DL9LzEUJ.mjs";import"node:crypto";function configRevisionDefinition(e){let{updatedAtMs:t,state:n,...r}=e;return r}function resolveCronJobConfigRevision(e){let t=u({...e,updatedAtMs:0,state:{}});return d(configRevisionDefinition(t))}function isReceiptStatus(e){return e===`running`||e===`ok`||e===`error`||e===`skipped`||e===`interrupted`||e===`superseded`}function receiptFromRow(e){if(!isReceiptStatus(e.status))throw Error(`invalid cron run receipt status ${e.status}`);return{receiptId:e.receipt_id,storeKey:e.store_key,jobId:e.job_id,configRevision:e.config_revision,agentId:e.agent_id,...e.request_run_id?{requestRunId:e.request_run_id}:{},status:e.status,ownerPid:e.owner_pid,ownerStartTime:e.owner_start_time,startedAtMs:e.started_at_ms,finishedAtMs:e.finished_at_ms,...e.error_text?{error:e.error_text}:{},...e.delivery_attempt_state===`not-started`?{deliveryNotStarted:!0}:{}}}function receiptHandle(e){return{receiptId:e.receiptId,storeKey:e.storeKey,jobId:e.jobId,configRevision:e.configRevision,agentId:e.agentId,ownerPid:e.ownerPid,ownerStartTime:e.ownerStartTime,startedAtMs:e.startedAtMs}}function matchesCronRunReceiptOwner(e,t){return e!==void 0&&e.receiptId===t.receiptId&&e.ownerPid===t.ownerPid&&e.ownerStartTime===t.ownerStartTime}function readCronRunReceiptCurrentFactsInDatabase(e,t){return v(e,()=>{let{handle:n}=t,r=t.includeAvailability&&!!y({db:e},n.agentId,`runtime`),i;try{i=readActiveCronRunReceiptsInDatabase(e,n.storeKey,[n.jobId])[0]}catch(e){if(!(e instanceof Error)||e.message!==`no such table: cron_run_receipts`)throw e}let o=t.includeJob&&matchesCronRunReceiptOwner(i,n)?c(f(e,n.storeKey,/* @__PURE__ */ new Set([n.jobId]))).store.jobs[0]:void 0;return{receipt:i,job:o?{agentId:o.agentId,sessionKey:o.sessionKey,hasCanonicalDeliveryMode:a(o.delivery)}:void 0,deletionBlocked:r}})}function readActiveCronRunReceiptsInDatabase(e,t,n){let r=h(e).selectFrom(`cron_run_receipts`).selectAll().where(`status`,`=`,`running`).where(`job_id`,`in`,_(n));t!==void 0&&(r=r.where(`store_key`,`=`,t));let i=g(e,r).rows,a=new Set(n);return i.filter(e=>a.has(e.job_id)).map(e=>receiptHandle(receiptFromRow(e)))}function isPluginStateReadCommand(e){return e.type===`pluginState.lookup`||e.type===`pluginState.lookupMany`||e.type===`pluginState.entries`||e.type===`pluginState.entriesInKeyRange`||e.type===`pluginState.count`}function readFailure(e,t){return{operation:e,code:`PLUGIN_STATE_READ_FAILED`,message:t}}function writeFailure(e,t){return{operation:e,code:`PLUGIN_STATE_WRITE_FAILED`,message:t}}const b={"pluginState.loadNamespace":readFailure(`entries`,`Failed to load plugin state namespace.`),"pluginState.executeOperation":writeFailure(`register`,`Failed to execute plugin state operation.`),"pluginState.appendJournal":writeFailure(`register`,`Failed to register sequenced plugin state journal entry.`),"pluginState.entriesInKeyRange":readFailure(`entries`,`Failed to list plugin state entries by key range.`),"pluginState.moveEntries":writeFailure(`register`,`Failed to move plugin state entries.`),"pluginState.observe":readFailure(`lookup`,`Failed to observe plugin state entry.`),"pluginState.compareUpdate":writeFailure(`register`,`Failed to update plugin state entry.`),"pluginState.compareDelete":writeFailure(`delete`,`Failed to conditionally delete plugin state entry.`),"pluginState.register":writeFailure(`register`,`Failed to register plugin state entry.`),"pluginState.replace":writeFailure(`register`,`Failed to replace plugin state namespace.`),"pluginState.replaceEntry":writeFailure(`register`,`Failed to replace plugin state entry.`),"pluginState.registerIfAbsent":writeFailure(`register`,`Failed to register plugin state entry.`),"pluginState.deleteIfEqual":writeFailure(`delete`,`Failed to conditionally delete plugin state entry.`),"pluginState.lookup":readFailure(`lookup`,`Failed to read plugin state entry.`),"pluginState.lookupMany":readFailure(`lookup`,`Failed to read plugin state entries.`),"pluginState.consume":readFailure(`consume`,`Failed to consume plugin state entry.`),"pluginState.delete":writeFailure(`delete`,`Failed to delete plugin state entry.`),"pluginState.entries":readFailure(`entries`,`Failed to list plugin state entries.`),"pluginState.count":readFailure(`count`,`Failed to count plugin state entries.`),"pluginState.clear":writeFailure(`clear`,`Failed to clear plugin state namespace.`),"pluginState.clearRuntimeHealth":writeFailure(`clear`,`Failed to clear runtime health records.`)};function isChannelIngressReadCommand(e){return n(e)?e.type===`channelIngress.failedHealth`?e.input===void 0:e.type===`channelIngress.accounts`?n(e.input)&&typeof e.input.channelId==`string`:e.type===`channelIngress.health`&&n(e.input)&&typeof e.input.now==`number`&&typeof e.input.failed==`boolean`&&typeof e.input.pressure==`boolean`:!1}function rowToState(e){return e.revision===null||e.updated_at_ms===null?{currentRevision:0}:e.content===null?{currentRevision:e.revision}:{currentRevision:e.revision,scratch:{content:e.content,revision:e.revision,...e.source_sha256?{sourceSha256:e.source_sha256}:{},updatedAtMs:e.updated_at_ms}}}function readHeartbeatMonitorScratchFromDatabase(e,t,n){let r=i(e),a=g(e,r.selectFrom(`cron_jobs`).leftJoin(`cron_job_scratch`,e=>e.onRef(`cron_job_scratch.store_key`,`=`,`cron_jobs.store_key`).onRef(`cron_job_scratch.job_id`,`=`,`cron_jobs.job_id`)).select([`cron_jobs.job_id as job_id`,`cron_job_scratch.content as content`,`cron_job_scratch.revision as revision`,`cron_job_scratch.source_sha256 as source_sha256`,`cron_job_scratch.updated_at_ms as updated_at_ms`]).where(`cron_jobs.store_key`,`=`,t).where(`cron_jobs.declaration_key`,`=`,`heartbeat:${n}`).where(`cron_jobs.payload_kind`,`=`,`heartbeat`)).rows[0];return a?{jobId:a.job_id,state:rowToState(a)}:void 0}function readCronScratchSnapshotInDatabase(e,t){if(t.selector.kind===`heartbeat`)return readHeartbeatMonitorScratchFromDatabase(e,t.storeKey,t.selector.agentId);let n=i(e),r=g(e,n.selectFrom(n.selectFrom(`cron_jobs`).selectAll().as(`cron_rows`)).leftJoin(`cron_job_scratch`,e=>e.onRef(`cron_job_scratch.store_key`,`=`,`cron_rows.store_key`).onRef(`cron_job_scratch.job_id`,`=`,`cron_rows.job_id`)).select(s.map(e=>`cron_rows.${e}`)).select([`cron_job_scratch.content as content`,`cron_job_scratch.revision as revision`,`cron_job_scratch.source_sha256 as source_sha256`,`cron_job_scratch.updated_at_ms as updated_at_ms`]).where(`cron_rows.store_key`,`=`,t.storeKey).where(`cron_rows.job_id`,`=`,t.selector.jobId)).rows[0];if(!r||r.job_id!==t.selector.jobId)return;let a=c([r],t.selector.createdAtMsFallback).store.jobs[0];if(a)return{jobId:a.id,configRevision:resolveCronJobConfigRevision(a),state:rowToState(r)}}function readCronJobNamesInDatabase(e,n,r){if(m(e)?.tables.has(`cron_jobs`)===!1)return/* @__PURE__ */ new Map;let a=i(e).selectFrom(`cron_jobs`).select([`job_id`,`name`]).where(`store_key`,`=`,r);n&&(a=a.where(`job_id`,`in`,_(n)));let o=g(e,a).rows;return new Map(o.map(e=>[e.job_id,t(e.name)]))}function cronQuarantineScope(e){return`cron.quarantine:${e}`}function readCronQuarantinedJobsInDatabase(e,t){return g(e,h(e).selectFrom(`diagnostic_events`).select(`payload_json`).where(`scope`,`=`,cronQuarantineScope(t)).orderBy(`sequence`,`asc`)).rows.map(e=>JSON.parse(e.payload_json))}function isCronStateReadCommand(e){switch(e.type){case`cron.currentReceipt`:case`cron.scratch`:case`cron.jobNames`:case`cron.quarantine`:return!0;default:return!1}}function readCronStateCommandInDatabase(e,t){switch(t.type){case`cron.currentReceipt`:return{type:t.type,facts:readCronRunReceiptCurrentFactsInDatabase(e,t)};case`cron.scratch`:return{type:t.type,snapshot:readCronScratchSnapshotInDatabase(e,t)};case`cron.jobNames`:{let n=t.storePath??p(e,void 0,r().environment);return{type:t.type,storeKey:n,names:readCronJobNamesInDatabase(e,t.jobIds,n)}}case`cron.quarantine`:return{type:t.type,entries:readCronQuarantinedJobsInDatabase(e,t.storeKey)};default:throw Error(`Unsupported Cron read command`)}}function isJournalOwner(e){return n(e)&&typeof e.sessionId==`string`&&typeof e.environmentId==`string`&&typeof e.ownerEpoch==`number`&&typeof e.placementGeneration==`number`}function isWorkspaceJournalReadCommand(e){return n(e)&&(e.type===`placementJournals.owners`||(e.type===`placementJournals.placement`||e.type===`placementJournals.load`)&&isJournalOwner(e.owner)&&(e.allowFailedOwner===void 0||typeof e.allowFailedOwner==`boolean`))}function isTuiLastSessionReadCommand(e){return n(e)&&e.type===`tui.lastSession.read`&&typeof e.stateKey==`string`}var x=/* @__PURE__ */ e({prepareOpenClawStateRead:()=>prepareOpenClawStateRead});async function prepareOpenClawStateRead(e,t,n){if(t.type===`templates.inventory`){let{readTemplateStateCommandInDatabase:e}=await import(`./openclaw-state-read-state-read.kernel-CdcC3-jz.mjs`);return n=>e(n,t)}if(t.type===`agentDatabaseDeletion.snapshot`){let{readAgentDatabaseDeletionWorkerSnapshot:n}=await import(`./openclaw-state-read-agent-deletion-journal.snapshot.worker-CsMDP44Z.mjs`);return r=>({type:t.type,snapshot:n(r,e.databasePath,t.purpose)})}if(t.type===`deliveryQueue.outbound`){let{assertOpenClawStateWriteAllowed:n}=await import(`./openclaw-state-read.worker.js`).then(e=>e.G),{readOutboundDeliveriesInDatabase:r}=await import(`./openclaw-state-read-delivery-queue-storage.kernel-CFA8pPNU.mjs`);return i=>(n({database:i,databasePath:e.databasePath,env:e.context.environment}),{type:t.type,entries:r({db:i},t)})}if(t.type===`acpSessions.resume`||t.type===`acpSessions.list`||t.type===`acpSessions.metadata`){let{readAcpSessionCommand:e}=await import(`./openclaw-state-read-session-meta-read.worker-Bi1A8UXY.mjs`);return r=>n?n.read(r):e(r,t)}if(isChannelIngressReadCommand(t)){let{readChannelIngressInDatabase:e}=await import(`./openclaw-state-read-ingress-queue-read.worker-uavSNwCz.mjs`);return n=>e(n,t)}if(t.type===`subagents.runs`){let{readSubagentRunsInWorker:e}=await import(`./openclaw-state-read-subagent-registry.store.worker-DVATgm1M.mjs`);return n=>e(n,t)}if(t.type===`mcpOAuth.statuses`||t.type===`mcpOAuth.readOnly`||t.type===`mcpOAuth.keys`||t.type===`mcpOAuth.pending`||t.type===`mcpOAuth.countPrincipals`){let{readMcpOAuthStateCommand:e}=await import(`./openclaw-state-read-openclaw-state-read-mcp-oauth-C-JXNrEM.mjs`);return n=>e(n,t)}if(t.type===`sessionGroups.snapshot`){let{readSessionGroupCatalogSnapshot:e}=await import(`./openclaw-state-read-session-group-catalog.kernel-DxgwFq4T.mjs`);return n=>({type:t.type,snapshot:e(n)})}if(t.type===`sessionGroups.members`){let{readSessionGroupMembership:n}=await import(`./openclaw-state-read-session-group-membership.read-Cyo1Zfgo.mjs`).then(e=>e.t);return()=>({type:t.type,snapshot:n(t.cfg,e.context.environment)})}if(t.type===`conversationBindings.inspect`){let{inspectCurrentConversationBindingRecordInDatabase:e}=await import(`./openclaw-state-read-current-conversation-bindings.kernel-DSqafVBH.mjs`);return n=>({type:t.type,record:e(n,t.conversation)})}if(t.type===`backup.runs`){let{readBackupRunsInDatabase:e}=await import(`./openclaw-state-read-backup-run-records.kernel-B7OSUw07.mjs`);return n=>({type:t.type,runs:e(n)})}if(isCronStateReadCommand(t))return e=>readCronStateCommandInDatabase(e,t);if(t.type===`devicePairing.list`||t.type===`devicePairing.lookup`||t.type===`devicePairing.pending`||t.type===`devicePairing.bootstrapContext`){let{executeDevicePairingRead:n}=await import(`./openclaw-state-read-device-pairing-read.kernel-CN79agV6.mjs`);return r=>n(r,e.databasePath,t)}if(isPluginStateReadCommand(t)){let{readPluginStateCommand:n}=await import(`./openclaw-state-read-plugin-state.worker-CyqZ12tL.mjs`);return r=>n({db:r,path:e.databasePath},t)}if(t.type===`pluginBlob.lookup`){let{pluginBlobLookupInDatabase:n}=await import(`./openclaw-state-read-plugin-blob-store.sqlite-Bjd4Lghd.mjs`);return r=>({type:t.type,value:n(r,{...t.input,env:e.context.environment,path:e.databasePath})})}if(t.type===`capture.readOnlyEvents`){let{readDebugProxyCaptureSessionEvents:e}=await import(`./openclaw-state-read-store-readonly-D99EwZNf.mjs`);return n=>({type:t.type,events:e(n,t.sessionId,t.limit)})}if(t.type===`capture.readOnlyBlob`){let{readDebugProxyCaptureBlob:e}=await import(`./openclaw-state-read-store-readonly-D99EwZNf.mjs`);return n=>({type:t.type,blob:e(n,t.blobId)})}if(t.type===`config.snapshot.read`){let{readConfigSnapshotAuditRecordInDatabase:e}=await import(`./openclaw-state-read-config-journal-snapshot.kernel-DfDs8M_V.mjs`);return n=>({type:t.type,snapshot:e(n)})}if(t.type===`audit.run.inspect`){let{runSqliteReadSnapshotSync:e}=await import(`./openclaw-state-read-sqlite-transaction-Bt-IwVhZ.mjs`).then(e=>e.s),{inspectExecutionIdentityRunInDatabase:n}=await import(`./openclaw-state-read-execution-identity-context-C04Qq6_Q.mjs`),{tableExists:r}=await import(`./openclaw-state-read-openclaw-state-db-schema-helpers-QFZd8aJI.mjs`).then(e=>e.i),{ExecutionDecisionCursorError:i}=await import(`./openclaw-state-read-execution-decision-receipts-BJn2SP-h.mjs`);return a=>{try{return{type:t.type,result:{status:`inspected`,inspection:e(a,()=>n(a,t.input,{executionIdentityContexts:r(a,`execution_identity_contexts`),auditEvents:r(a,`audit_events`),cronRunReceipts:r(a,`cron_run_receipts`),executionOwnerLifecycleBindings:r(a,`execution_owner_lifecycle_bindings`)}))}}}catch(e){if(!(e instanceof i))throw e;return{type:t.type,result:{status:`invalid-cursor`,message:e.message}}}}}if(t.type===`pluginBlob.entries`){let{pluginBlobEntriesInDatabase:n}=await import(`./openclaw-state-read-plugin-blob-store.sqlite-Bjd4Lghd.mjs`);return r=>({type:t.type,value:n(r,{...t.input,env:e.context.environment,path:e.databasePath})})}if(t.type===`updateRuns.get`){let{tableExists:e}=await import(`./openclaw-state-read-openclaw-state-db-schema-helpers-QFZd8aJI.mjs`).then(e=>e.i),{readUpdateRunRecord:n}=await import(`./openclaw-state-read-update-run-read.kernel-NvkRc4sp.mjs`);return r=>({type:t.type,run:e(r,`update_runs`)?n(r,t.runId):void 0})}if(t.type===`updateRuns.list`){let{readUpdateRuns:e}=await import(`./openclaw-state-read-update-run-read.kernel-NvkRc4sp.mjs`);return n=>({type:t.type,runs:e(n,t.input)})}if(t.type===`updateRuns.reconciliationCandidates`){let{readUpdateRunReconciliationCandidates:e}=await import(`./openclaw-state-read-update-run-reconciliation.read-CIX49yzG.mjs`);return n=>({type:t.type,candidates:e(n,t.input)})}if(t.type===`updateRuns.reconciliationCandidate`){let{tableExists:e}=await import(`./openclaw-state-read-openclaw-state-db-schema-helpers-QFZd8aJI.mjs`).then(e=>e.i),{readUpdateRunRecord:n}=await import(`./openclaw-state-read-update-run-read.kernel-NvkRc4sp.mjs`),{inspectUpdateRunReconciliation:r}=await import(`./openclaw-state-read-update-run-reconciliation.read-CIX49yzG.mjs`);return i=>{let a=e(i,`update_runs`)?n(i,t.runId):void 0;return{type:t.type,candidate:a?r(i,a,{}):void 0}}}if(t.type===`updateRuns.status`){let{runSqliteReadSnapshotSync:e}=await import(`./openclaw-state-read-sqlite-transaction-Bt-IwVhZ.mjs`).then(e=>e.s),{readUpdateRunStatusInDatabase:n}=await import(`./openclaw-state-read-update-run-read.kernel-NvkRc4sp.mjs`);return r=>({type:t.type,status:e(r,()=>n(r))})}if(t.type===`updateRuns.historyStatus`){let{runSqliteReadSnapshotSync:e}=await import(`./openclaw-state-read-sqlite-transaction-Bt-IwVhZ.mjs`).then(e=>e.s),{readUpdateRunHistoryStatusInDatabase:n}=await import(`./openclaw-state-read-update-run-read.kernel-NvkRc4sp.mjs`);return r=>({type:t.type,status:e(r,()=>n(r))})}if(t.type===`updateRuns.interruptedCandidate`){let{readInterruptedUpdateCandidate:e}=await import(`./openclaw-state-read-update-run-read.kernel-NvkRc4sp.mjs`);return n=>({type:t.type,run:e(n)})}if(t.type===`exec-approvals.read`){let{readExecApprovalsConfigRow:e}=await import(`./openclaw-state-read-exec-approvals-sqlite-DpK3LWxW.mjs`);return n=>({type:t.type,row:e(n)})}if(t.type===`skills.library.descriptions`){let{tableExists:e}=await import(`./openclaw-state-read-openclaw-state-db-schema-helpers-QFZd8aJI.mjs`).then(e=>e.i),{selectSkillLibraryRevisionMetadataBatch:n}=await import(`./openclaw-state-read-selection-read.kernel-DI0uSzNF.mjs`);return r=>({type:t.type,value:e(r,`skill_library_entries`)?n(r,t.input):void 0})}if(t.type===`skills.library.manifests`){let{tableExists:e}=await import(`./openclaw-state-read-openclaw-state-db-schema-helpers-QFZd8aJI.mjs`).then(e=>e.i),{selectSkillLibraryRevisionManifestsBatch:n}=await import(`./openclaw-state-read-selection-read.kernel-DI0uSzNF.mjs`);return r=>({type:t.type,value:e(r,`skill_library_entries`)?n(r,t.input):void 0})}if(t.type===`operatorApprovals.placementGrant`){let{readPlacementGrantRows:e}=await import(`./openclaw-state-read-operator-approval-placement-grants.read.worker-CZ3NTxlC.mjs`);return n=>({type:t.type,rows:e(n,t.input)})}if(t.type===`operatorApprovals.pendingSnapshot`){let{readOperatorApprovalPendingSnapshotInDatabase:e}=await import(`./openclaw-state-read-operator-approval-store.kernel.worker-DPXsqdXA.mjs`);return n=>({type:t.type,page:e(t.input,n)})}if(t.type===`operatorApprovals.pending`){let{readPendingOperatorApprovalsInDatabase:e}=await import(`./openclaw-state-read-operator-approval-store.kernel.worker-DPXsqdXA.mjs`);return n=>({type:t.type,pending:e(t.input,n)})}if(t.type===`operatorApprovals.prepareReplay`){let{readOperatorApprovalReplayInDatabase:e}=await import(`./openclaw-state-read-operator-approval-store.kernel.worker-DPXsqdXA.mjs`);return n=>({type:t.type,replay:e(t.input,n)})}if(t.type===`operatorApprovals.history`){let{listTerminalOperatorApprovalsInDatabase:e}=await import(`./openclaw-state-read-operator-approval-store.kernel.worker-DPXsqdXA.mjs`);return n=>({type:t.type,history:e(t.input,n)})}if(t.type===`operatorApprovals.validateCronGrant`){let{lookupCronStandingGrantInDatabase:e}=await import(`./openclaw-state-read-operator-approval-standing-grants.worker-Dpci6sHW.mjs`);return n=>({type:t.type,result:e(n,t.input,!1)})}if(t.type===`operatorApprovals.listCronGrants`){let{listCronStandingGrantsInDatabase:e}=await import(`./openclaw-state-read-operator-approval-standing-grants.worker-Dpci6sHW.mjs`);return n=>({type:t.type,grants:e(n,t.input)})}if(t.type===`onboardingRecommendations.read`){let{readOnboardingRecommendationsInDatabase:e}=await import(`./openclaw-state-read-onboarding-recommendations.kernel-K8r2biul.mjs`);return n=>({type:t.type,record:e(n,t.configKey)})}if(o(t))return e=>l(e,t);if(t.type===`workspace.snapshot`){let{readWorkspaceStateSnapshotForDirectoryInDatabase:n}=await import(`./openclaw-state-read-workspace-state-store.kernel-CFwxmJ4g.mjs`);return r=>({type:t.type,snapshot:n({workspaceDir:t.workspaceDir,database:{db:r,path:e.databasePath}})})}if(t.type===`githubPublication.lifecycle`){let{readGitHubPublicationSessionLifecycle:e}=await import(`./openclaw-state-read-github-publication-session-lifecycles.worker-Lg6oFR2C.mjs`).then(e=>e.t);return n=>({type:t.type,lifecycle:e(t,n)})}if(t.type===`githubPublication.request`){let{readGitHubPublicationRequest:e}=await import(`./openclaw-state-read-github-publication-store.worker-B2gw4lDs.mjs`);return n=>({type:t.type,row:e(n,{requestId:t.requestId})})}if(t.type===`githubPublication.knownPullRequestUrls`){let{readKnownGitHubPublicationPullRequestUrlsInDatabase:e}=await import(`./openclaw-state-read-github-publication-store.worker-B2gw4lDs.mjs`);return n=>({type:t.type,urls:e(n,t.input)})}if(t.type===`githubRepository.knownPullRequestUrls`){let{readKnownRepositoryGitHubPublicationPullRequestUrlsInDatabase:e}=await import(`./openclaw-state-read-github-repository-publication-store.worker-DElgJaCT.mjs`);return n=>({type:t.type,urls:e(n,t.input)})}if(t.type===`userProfiles.catalogIdentity`||t.type===`userProfiles.identity`||t.type===`userProfiles.githubIdentity.cached`||t.type===`userProfiles.githubAttribution.resolve`||t.type===`userProfiles.channelIdentity.list`||t.type===`userProfiles.channelIdentity.resolve`||t.type===`userProfiles.reconcile`||t.type===`userProfiles.catalog`||t.type===`userProfiles.avatar.inspect`||t.type===`userProfiles.avatar.read`){let{readUserProfileCommand:e}=await import(`./openclaw-state-read-user-profile-read.worker-DWqO44ZR.mjs`);return n=>e(n,t)}if(t.type===`userBackground.snapshot`||t.type===`userBackground.image`){let{readUserBackgroundCommand:e}=await import(`./openclaw-state-read-user-background.kernel-DSqAjTnf.mjs`);return n=>e(n,t)}if(t.type===`userPreferences.sessionPins`){let{selectPersonalPinnedSessionKeys:e}=await import(`./openclaw-state-read-user-preferences.store-Bfv_XrVt.mjs`).then(e=>e.n);return n=>({type:t.type,sessionKeys:e(n)})}if(t.type===`userPreferences.values`){let{selectUserPreferenceValues:e}=await import(`./openclaw-state-read-user-preferences.store-Bfv_XrVt.mjs`).then(e=>e.n);return n=>({type:t.type,values:e(n,t.profileIds,t.key)})}if(t.type===`userPreferences.read`){let{runSqliteReadSnapshotSync:e}=await import(`./openclaw-state-read-sqlite-transaction-Bt-IwVhZ.mjs`).then(e=>e.s),{tableExists:n}=await import(`./openclaw-state-read-openclaw-state-db-schema-helpers-QFZd8aJI.mjs`).then(e=>e.i),{selectResolvedUserProfileMetadataById:r}=await import(`./openclaw-state-read-user-profiles-internal-RPWRWaaD.mjs`).then(e=>e.d),{readUserPreferences:i}=await import(`./openclaw-state-read-user-preferences.store-Bfv_XrVt.mjs`).then(e=>e.n);return a=>({type:t.type,preferences:e(a,()=>{let e=n(a,`user_profiles`)?r(a,t.profileId):void 0;return e?{profileId:e.id,entries:n(a,`user_preferences`)?i(a,e.id,t.keys):{}}:void 0})})}if(t.type===`userModelAccounts.authorization`||t.type===`userModelAccounts.links`||t.type===`userModelAccounts.summary`||t.type===`userModelAccounts.selection`||t.type===`userModelAccounts.catalog`){let{readUserModelAccountCommand:e}=await import(`./openclaw-state-read-user-model-accounts.read.worker-CThcJhFM.mjs`);return n=>e(n,t)}if(t.type===`sessionRepositoryWorkspaces.find`){let{tableExists:e}=await import(`./openclaw-state-read-openclaw-state-db-schema-helpers-QFZd8aJI.mjs`).then(e=>e.i),{runSqliteReadSnapshotSync:n}=await import(`./openclaw-state-read-sqlite-transaction-Bt-IwVhZ.mjs`).then(e=>e.s),{findSessionRepositoryWorkspaceInDatabase:r}=await import(`./openclaw-state-read-session-repository-workspaces.kernel-DWkUR_P4.mjs`);return i=>t.owners.length===0||!e(i,`session_repository_workspaces`)?{type:t.type,workspaces:[]}:{type:t.type,workspaces:n(i,()=>t.owners.flatMap(e=>{let t=r(i,e);return t?[t]:[]}))}}if(t.type===`sessionRows.sharedFacts`){let{readSessionRowsSharedFacts:e}=await import(`./openclaw-state-read-openclaw-state-read-session-rows.worker-Dh3hYjN3.mjs`);return n=>e(n,t)}if(t.type===`workerPlacements.changeSnapshot`){let{readWorkerPlacementChangeSnapshotInDatabase:e}=await import(`./openclaw-state-read-placement-row-codec-DQrOmCiV.mjs`).then(e=>e.i);return n=>({type:t.type,placements:e(n,t.profileIds)})}if(isWorkspaceJournalReadCommand(t)){let{readWorkspaceJournalInDatabase:e}=await import(`./openclaw-state-read-placement-workspace-journal-CylVI9We.mjs`);return n=>e(n,t)}if(t.type===`workers.placementRecoveryCandidates`){let{readWorkerPlacementRecoveryCandidatesInDatabase:e}=await import(`./openclaw-state-read-placement-read-projection-DGqKnI3c.mjs`);return n=>({type:t.type,candidates:e(n)})}if(t.type===`workers.placementPreservation`){let{readWorkerPlacementsForReconcileInDatabase:e}=await import(`./openclaw-state-read-placement-row-codec-DQrOmCiV.mjs`).then(e=>e.i);return n=>({type:t.type,placements:e(n)})}if(t.type===`workers.placementEnvironmentOwner`){let{readWorkerPlacementEnvironmentOwnerInDatabase:e}=await import(`./openclaw-state-read-placement-read-projection-DGqKnI3c.mjs`);return n=>({type:t.type,placement:e(n,t.environmentId)})}if(t.type===`workers.placementPendingResults`){let{listPendingWorkerWorkspaceResultsInDatabase:e}=await import(`./openclaw-state-read-placement-workspace-result-DV9gRfRy.mjs`);return n=>({type:t.type,pendingResults:e(n,t.sessionId)})}if(t.type===`workers.placementProjection`){let{readWorkerSessionPlacementProjectionInDatabase:e}=await import(`./openclaw-state-read-placement-read-projection-DGqKnI3c.mjs`);return n=>({type:t.type,result:e(n,t.sessionIds,t.conflictBindings)})}if(isTuiLastSessionReadCommand(t)){let{readTuiLastSessionCommand:e}=await import(`./openclaw-state-read-tui-last-session.kernel-bg6yCyvU.mjs`);return n=>e(n,t)}if(t.type===`preparedPoolPresence.read`){let{readPreparedPoolPresenceDemandInDatabase:e}=await import(`./openclaw-state-read-prepared-pool-presence-store.worker-sa4IBOjG.mjs`);return n=>({type:t.type,demand:e(n)})}if(t.type===`workerEnvironments.snapshot`){let{runSqliteReadSnapshotSync:e}=await import(`./openclaw-state-read-sqlite-transaction-Bt-IwVhZ.mjs`).then(e=>e.s),{readWorkerEnvironmentFacts:n}=await import(`./openclaw-state-read-store-row-codec-2LqV4jhI.mjs`);return r=>({type:t.type,facts:e(r,()=>n(r,t.ids))})}if(t.type===`agentDeletionJournal.status`){let{readAgentDeletionJournalStatusInDatabase:e}=await import(`./openclaw-state-read-agent-deletion-journal.read-BNE7CEJK.mjs`).then(e=>e.t);return n=>({type:t.type,status:e(n,t.agentId)})}if(t.type===`agentDeletionJournal.retainedIds`){let{readRetainedAgentDeletionIds:e}=await import(`./openclaw-state-read-agent-deletion-journal.snapshot.worker-CsMDP44Z.mjs`);return n=>({type:t.type,agentIds:e(n)})}if(t.type===`sandboxRegistry.list`){let{readSandboxRegistryInDatabase:e}=await import(`./openclaw-state-read-registry.kernel-DxBhY13A.mjs`);return n=>({type:t.type,entries:e(n,t.workspaceDir)})}if(t.type===`sandboxRegistry.get`){let{readSandboxRegistryEntryInDatabase:e}=await import(`./openclaw-state-read-registry.kernel-DxBhY13A.mjs`);return n=>({type:t.type,entry:e(n,t.containerName)})}if(t.type===`sandboxRegistry.runtimeIds`){let{readSandboxRuntimeIdsInDatabase:e}=await import(`./openclaw-state-read-registry.kernel-DxBhY13A.mjs`);return n=>({type:t.type,runtimeIds:e(n,t)})}if(t.type===`sandboxRegistry.browsers`){let{readSandboxBrowserRegistryInDatabase:e}=await import(`./openclaw-state-read-registry.kernel-DxBhY13A.mjs`);return n=>({type:t.type,entries:e(n,t.workspaceDir)})}if(t.type===`worktrees.cleanupState`){let{listRegistryWorktreesInDatabase:e}=await import(`./openclaw-state-read-registry-read.kernel-DMLhSU5E.mjs`).then(e=>e.i),{readWorktreeRunLeaseStateInDatabase:n}=await import(`./openclaw-state-read-run-lease-owner-yHigBNsQ.mjs`).then(e=>e.r);return r=>({type:t.type,records:e(r),leases:n(r)})}throw Error(`Unsupported shared-state read command: `+t.type)}export{resolveCronJobConfigRevision as i,b as n,prepareOpenClawStateRead,readCronRunReceiptCurrentFactsInDatabase as r,x as t};