UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 20 kB
import{r as e}from"./openclaw-state-read-semver-CqfGj9gv.mjs";import{a as t}from"./openclaw-state-read-record-coerce-D1s3ReAs.mjs";import{u as n}from"./openclaw-state-read-openclaw-state-db-readonly-CDG18cNK.mjs";import{n as r,t as i}from"./openclaw-state-read-config-machine-state-rtO7vE83.mjs";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 a={"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 t(e)?e.type===`channelIngress.failedHealth`?e.input===void 0:e.type===`channelIngress.accounts`?t(e.input)&&typeof e.input.channelId==`string`:e.type===`channelIngress.health`&&t(e.input)&&typeof e.input.now==`number`&&typeof e.input.failed==`boolean`&&typeof e.input.pressure==`boolean`:!1}function isJournalOwner(e){return t(e)&&typeof e.sessionId==`string`&&typeof e.environmentId==`string`&&typeof e.ownerEpoch==`number`&&typeof e.placementGeneration==`number`}function isWorkspaceJournalReadCommand(e){return t(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 t(e)&&e.type===`tui.lastSession.read`&&typeof e.stateKey==`string`}var o=/* @__PURE__ */ e({prepareOpenClawStateRead:()=>prepareOpenClawStateRead});async function prepareOpenClawStateRead(e,t,a){if(t.type===`templates.inventory`){let{readTemplateStateCommandInDatabase:e}=await import(`./openclaw-state-read-state-read.kernel-BK-GNJQ0.mjs`);return n=>e(n,t)}if(t.type===`deliveryQueue.outbound`){let{assertOpenClawStateWriteAllowed:n}=await import(`./openclaw-state-read.worker.js`).then(e=>e.q),{readOutboundDeliveriesInDatabase:r}=await import(`./openclaw-state-read-delivery-queue-storage.kernel-CgxXgsLS.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-oZLCuwUU.mjs`);return n=>a?a.read(n):e(n,t)}if(isChannelIngressReadCommand(t)){let{readChannelIngressInDatabase:e}=await import(`./openclaw-state-read-ingress-queue-read.worker-ClEf_GsA.mjs`);return n=>e(n,t)}if(t.type===`subagents.runs`){let{readSubagentRunsInWorker:e}=await import(`./openclaw-state-read-subagent-registry.store.worker-DzjeqrFq.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-5KP8ul1p.mjs`);return n=>e(n,t)}if(t.type===`sessionGroups.snapshot`){let{readSessionGroupCatalogSnapshot:e}=await import(`./openclaw-state-read-session-group-catalog.kernel-BqLZYFCU.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-BgaXi2E5.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-B3c83QpO.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-uiXzkAAF.mjs`);return n=>({type:t.type,runs:e(n)})}if(t.type===`cron.currentReceipt`||t.type===`cron.scratch`||t.type===`cron.jobNames`||t.type===`cron.quarantine`){let{readCronStateCommandInDatabase:e}=await import(`./openclaw-state-read-read-command-D-A9yAv8.mjs`);return n=>e(n,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-CBotY6Gk.mjs`);return r=>n(r,e.databasePath,t)}if(isPluginStateReadCommand(t)){let{readPluginStateCommand:n}=await import(`./openclaw-state-read-plugin-state.worker-DlNk5P5p.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-CU-l3WqR.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-D1qnT1x8.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-D1qnT1x8.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-BzQQCeuA.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-V1rK3HH2.mjs`).then(e=>e.s),{inspectExecutionIdentityRunInDatabase:n}=await import(`./openclaw-state-read-execution-identity-context-CycLh5d8.mjs`),{tableExists:r}=await import(`./openclaw-state-read-openclaw-state-db-schema-helpers-BkqUYEFY.mjs`).then(e=>e.i),{ExecutionDecisionCursorError:i}=await import(`./openclaw-state-read-execution-decision-receipts-DnyVRmWj.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-CU-l3WqR.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-BkqUYEFY.mjs`).then(e=>e.i),{readUpdateRunRecord:n}=await import(`./openclaw-state-read-update-run-read.kernel-DS4CWnDd.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-DS4CWnDd.mjs`);return n=>({type:t.type,runs:e(n,t.input)})}if(n(t)){let{readUpdateRunAdmissionCommand:e}=await import(`./openclaw-state-read-update-run-admission.read-Jyh4nsMI.mjs`);return n=>e(n,t)}if(t.type===`updateRuns.status`){let{runSqliteReadSnapshotSync:e}=await import(`./openclaw-state-read-sqlite-transaction-V1rK3HH2.mjs`).then(e=>e.s),{readUpdateRunStatusInDatabase:n}=await import(`./openclaw-state-read-update-run-read.kernel-DS4CWnDd.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-V1rK3HH2.mjs`).then(e=>e.s),{readUpdateRunHistoryStatusInDatabase:n}=await import(`./openclaw-state-read-update-run-read.kernel-DS4CWnDd.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-DS4CWnDd.mjs`);return n=>({type:t.type,run:e(n)})}if(t.type===`updateRuns.pluginCohortRecoveries`){let{runSqliteReadSnapshotSync:e}=await import(`./openclaw-state-read-sqlite-transaction-V1rK3HH2.mjs`).then(e=>e.s),{inspectPluginCohortRecoveryRows:n}=await import(`./openclaw-state-read-update-run-recovery-store-B-8Xa-fT.mjs`).then(e=>e.n);return r=>({type:t.type,pairs:e(r,()=>n(r))})}if(t.type===`updateRuns.pluginSnapshotCollection`){let{runSqliteReadSnapshotSync:e}=await import(`./openclaw-state-read-sqlite-transaction-V1rK3HH2.mjs`).then(e=>e.s),{canCollectPluginSourceSnapshotsInDatabase:n}=await import(`./openclaw-state-read-update-run-recovery-store-B-8Xa-fT.mjs`).then(e=>e.n);return r=>({type:t.type,allowed:e(r,()=>n(r))})}if(t.type===`exec-approvals.read`){let{readExecApprovalsConfigRow:e}=await import(`./openclaw-state-read-exec-approvals-sqlite-I2OhWX2X.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-BkqUYEFY.mjs`).then(e=>e.i),{selectSkillLibraryRevisionMetadataBatch:n}=await import(`./openclaw-state-read-selection-read.kernel-BT-mpqNO.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-BkqUYEFY.mjs`).then(e=>e.i),{selectSkillLibraryRevisionManifestsBatch:n}=await import(`./openclaw-state-read-selection-read.kernel-BT-mpqNO.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-Ci9xADce.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-CvRgjxah.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-CvRgjxah.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-CvRgjxah.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-CvRgjxah.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-Aazs75VQ.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-Aazs75VQ.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-W4q5C2Wg.mjs`);return n=>({type:t.type,record:e(n,t.configKey)})}if(i(t))return e=>r(e,t);if(t.type===`workspace.snapshot`){let{readWorkspaceStateSnapshotForDirectoryInDatabase:n}=await import(`./openclaw-state-read-workspace-state-store.kernel-B3u5O2Ey.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-uo4nWWzQ.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-CHbOJpn7.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-CHbOJpn7.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-CXR1ef3q.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-CiKzT4Gs.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-DWvr5yjx.mjs`);return n=>e(n,t)}if(t.type===`userPreferences.sessionPins`){let{selectPersonalPinnedSessionKeys:e}=await import(`./openclaw-state-read-user-preferences.store-CzrRAUJG.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-CzrRAUJG.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-V1rK3HH2.mjs`).then(e=>e.s),{tableExists:n}=await import(`./openclaw-state-read-openclaw-state-db-schema-helpers-BkqUYEFY.mjs`).then(e=>e.i),{selectResolvedUserProfileMetadataById:r}=await import(`./openclaw-state-read-user-profiles-internal-D1K1kSBE.mjs`).then(e=>e.f),{readUserPreferences:i}=await import(`./openclaw-state-read-user-preferences.store-CzrRAUJG.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-CL7FHeP-.mjs`);return n=>e(n,t)}if(t.type===`sessionRepositoryWorkspaces.find`){let{tableExists:e}=await import(`./openclaw-state-read-openclaw-state-db-schema-helpers-BkqUYEFY.mjs`).then(e=>e.i),{runSqliteReadSnapshotSync:n}=await import(`./openclaw-state-read-sqlite-transaction-V1rK3HH2.mjs`).then(e=>e.s),{findSessionRepositoryWorkspaceInDatabase:r}=await import(`./openclaw-state-read-session-repository-workspaces.kernel-DpMTYRRG.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-Di362tbf.mjs`);return n=>e(n,t)}if(t.type===`workerPlacements.changeSnapshot`){let{readWorkerPlacementChangeSnapshotInDatabase:e}=await import(`./openclaw-state-read-placement-row-codec-H0QnPs2g.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-DhgQ9VvA.mjs`);return n=>e(n,t)}if(t.type===`workers.placementPreservation`){let{readWorkerPlacementsForReconcileInDatabase:e}=await import(`./openclaw-state-read-placement-row-codec-H0QnPs2g.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-CsboOx2D.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-D7WSR_KV.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-CsboOx2D.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-CzSxrn9W.mjs`);return n=>e(n,t)}if(t.type===`agentDeletionJournal.status`){let{readAgentDeletionJournalStatusInDatabase:e}=await import(`./openclaw-state-read-agent-deletion-journal.read-DWSUE9n3.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-BIOQ3Z8Y.mjs`);return n=>({type:t.type,agentIds:e(n)})}if(t.type===`worktrees.cleanupState`){let{listRegistryWorktreesInDatabase:e}=await import(`./openclaw-state-read-registry-read.kernel-Mu3y8MTg.mjs`).then(e=>e.i),{readWorktreeRunLeaseStateInDatabase:n}=await import(`./openclaw-state-read-run-lease-owner-fmiThuBE.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{a as n,prepareOpenClawStateRead,o as t};