UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 20.9 kB
import{createHash as e}from"node:crypto";import t from"node:fs";import{sameFileIdentity as n}from"@openclaw/fs-safe/advanced";import{sha256FileSync as r}from"@openclaw/fs-safe/durability";import"@openclaw/fs-safe/errors";import{hasNodeErrorCode as i}from"@openclaw/fs-safe/path";function createRuntimeProcessEntrypoints(e){let runtimeProcessEntrypoint=(t,n=t,r=`.js`,i)=>({currentModuleUrl:e,sourceModulePath:`src/${t}${i??`.ts`}`,sourceExtension:i,sourceWorkerName:t.startsWith(`infra/`)?t.slice(6):`../${t}`,distWorkerPath:`${n}${r}`}),loaderFreeEntrypoint=e=>runtimeProcessEntrypoint(e,void 0,void 0,`.mjs`);return{daemonRuntimeProbe:runtimeProcessEntrypoint(`infra/daemon-runtime-probe.entry`),pluginToolsServe:runtimeProcessEntrypoint(`mcp/plugin-tools-serve`),openclawToolsServe:runtimeProcessEntrypoint(`mcp/openclaw-tools-serve`),repositoryPublicationRestore:loaderFreeEntrypoint(`gateway/repository-publication-restore.generated.worker`),nodeWorkspacePublicationSnapshot:loaderFreeEntrypoint(`node-host/node-worker-publication-snapshot.generated.worker`),nodeWorkspaceManifest:loaderFreeEntrypoint(`node-host/node-worker-workspace-manifest.generated.worker`),nodeWorkspaceGitHistory:loaderFreeEntrypoint(`node-host/node-worker-workspace-git-history.generated.worker`),doctorDatabaseEngineInspection:runtimeProcessEntrypoint(`commands/doctor-database-engine-inspection.worker`),doctorDatabaseBloat:runtimeProcessEntrypoint(`commands/doctor-db-bloat.worker`),backupDatabaseDiscovery:runtimeProcessEntrypoint(`infra/backup-database-discovery.worker`),sqliteHeaderProbe:runtimeProcessEntrypoint(`infra/sqlite-header-probe.worker`),databaseBackup:runtimeProcessEntrypoint(`snapshot/database-backup.worker`),managedHandoffEngine:runtimeProcessEntrypoint(`infra/update-managed-service-handoff-engine.worker`),updatePostgresState:runtimeProcessEntrypoint(`infra/update-candidate-state.postgres.worker`),databasePortCommand:runtimeProcessEntrypoint(`infra/database-engine/port-command.entry.worker`),stallObserver:runtimeProcessEntrypoint(`logging/diagnostic-stall-observer.worker`),fileLog:runtimeProcessEntrypoint(`logging/logger-file.worker`),systemCaWarmup:runtimeProcessEntrypoint(`gateway/system-ca-warmup.worker`),openclawIdTunnel:runtimeProcessEntrypoint(`gateway/openclaw-id/tunnel-child/entry`),shutdownHardExit:loaderFreeEntrypoint(`cli/gateway-cli/shutdown-hard-exit.worker`),packageIntegrityHasher:runtimeProcessEntrypoint(`infra/package-update-integrity-hasher.worker`),packageLocalOverrides:runtimeProcessEntrypoint(`infra/package-local-overrides.worker`),directoryWatchHost:runtimeProcessEntrypoint(`infra/directory-watch-host.worker`),directoryWatchParent:runtimeProcessEntrypoint(`infra/directory-watch-parent.worker`),workspaceQuiescenceAcquire:loaderFreeEntrypoint(`gateway/worker-environments/workspace-quiescence-acquire.generated.worker`),workspaceQuiescenceRenew:loaderFreeEntrypoint(`gateway/worker-environments/workspace-quiescence-renew.generated.worker`),workspaceQuiescenceRelease:loaderFreeEntrypoint(`gateway/worker-environments/workspace-quiescence-release.generated.worker`),packageActivationRecovery:runtimeProcessEntrypoint(`infra/package-update-activation-sealed`,`package-update-activation-recovery`,`.mjs`),managedHandoffPostgresBridge:runtimeProcessEntrypoint(`infra/update-managed-service-handoff-postgres.worker`,`managed-handoff-postgres-bridge.worker`,`.mjs`),managedHandoffRuntime:runtimeProcessEntrypoint(`infra/update-managed-service-handoff-sealed`,`managed-handoff-runtime`,`.mjs`),sqliteVector:runtimeProcessEntrypoint(`infra/database-engine/sqlite-vector.child`),postgresBridge:runtimeProcessEntrypoint(`infra/postgres-sync/bridge.worker`),secretEgressProxy:runtimeProcessEntrypoint(`secrets/egress-proxy/proxy.worker`),codeModeNode:runtimeProcessEntrypoint(`agents/code-mode-node.worker`),cronReadOnly:runtimeProcessEntrypoint(`cron/store/read-only.worker`),stateRead:runtimeProcessEntrypoint(`state/openclaw-state-read.worker`),workerNativeLifecycle:runtimeProcessEntrypoint(`infra/worker-native-lifecycle.worker`),spawnBroker:runtimeProcessEntrypoint(`process/spawn-broker/worker`),cronStreamMatcher:runtimeProcessEntrypoint(`gateway/cron-stream-matcher.worker`),controlUiFile:runtimeProcessEntrypoint(`gateway/control-ui-file.worker`),publicSessionCard:runtimeProcessEntrypoint(`gateway/control-ui-public-session-card.worker`),nodeBootstrapArtifact:runtimeProcessEntrypoint(`gateway/worker-environments/node-bootstrap-artifact.worker`),nativeHookRelayClient:runtimeProcessEntrypoint(`agents/harness/native-hook-relay-client.worker`),computerHost:runtimeProcessEntrypoint(`gateway/desktop/computer.worker`),imageProcessor:runtimeProcessEntrypoint(`media/image-processor.worker`),fileToolPlanning:runtimeProcessEntrypoint(`agents/sessions/tools/file-tool-planning.worker`),fileToolRead:runtimeProcessEntrypoint(`agents/sessions/tools/read-file.worker`),attachmentProcessor:runtimeProcessEntrypoint(`media/attachment-processor.worker`),widgetScriptSyntax:runtimeProcessEntrypoint(`canvas/widget-script-syntax.worker`),gitOperations:runtimeProcessEntrypoint(`infra/git-operation.worker`),gitPackCleanup:runtimeProcessEntrypoint(`agents/worktrees/git-pack-cleanup.worker`),fsSafeCopy:runtimeProcessEntrypoint(`infra/fs-safe-copy.worker`),execRealpath:runtimeProcessEntrypoint(`infra/exec-realpath.worker`),sharedStateStore:runtimeProcessEntrypoint(`state/openclaw-state.worker`),clientCredentials:runtimeProcessEntrypoint(`infra/client-credential.worker`),secretFileRead:runtimeProcessEntrypoint(`infra/secret-file-read.worker`),ttsPreferences:runtimeProcessEntrypoint(`tts/tts-settings-write.worker`),authProfileInlineUsage:runtimeProcessEntrypoint(`agents/auth-profiles/inline-usage.worker`),pluginModelCatalogRead:runtimeProcessEntrypoint(`agents/plugin-model-catalog-read.worker`),pluginModelCatalogCredentials:runtimeProcessEntrypoint(`agents/plugin-model-catalog.worker`),pluginCaptureNativeResource:runtimeProcessEntrypoint(`plugins/plugin-capture-native-resource`),pluginGenerationPreparation:runtimeProcessEntrypoint(`plugins/plugin-generation-preparation.worker`),agentDatabaseExecution:runtimeProcessEntrypoint(`state/openclaw-agent-execution.worker`),workspaceMemory:runtimeProcessEntrypoint(`worker/memory-worker-entry`,`agents/workspace-memory.worker`),localAgentAvatar:runtimeProcessEntrypoint(`agents/identity-avatar-file.worker`),identityFile:runtimeProcessEntrypoint(`agents/identity-file.worker`),workspaceSkills:runtimeProcessEntrypoint(`worker/skills-worker-entry`,`agents/workspace-skills.worker`),skillsDiscovery:runtimeProcessEntrypoint(`skills/runtime/discovery.worker`),boardStore:runtimeProcessEntrypoint(`boards/sqlite-board-store.worker`),progressCardStore:runtimeProcessEntrypoint(`session-cards/progress-card-store.worker`),sessionSharingStore:runtimeProcessEntrypoint(`config/sessions/session-sharing-store.worker`),sessionForkDomain:runtimeProcessEntrypoint(`config/sessions/session-fork-domain.worker`),sessionGoalOperations:runtimeProcessEntrypoint(`config/sessions/goals-operations.worker`),sessionLifecyclePlanningDomain:runtimeProcessEntrypoint(`config/sessions/session-lifecycle-projection.worker`),sessionMessageRewriteDomain:runtimeProcessEntrypoint(`config/sessions/session-message-rewrite.worker`),sessionDiskBudget:runtimeProcessEntrypoint(`config/sessions/disk-budget.worker`),contextEngineTurnOutbox:runtimeProcessEntrypoint(`agents/harness/context-engine-turn-outbox.worker`),sqliteStore:runtimeProcessEntrypoint(`infra/sqlite-store.worker`),sqliteWriterAdmission:runtimeProcessEntrypoint(`infra/sqlite-writer-admission.worker`),agentSchemaInspection:runtimeProcessEntrypoint(`state/openclaw-agent-schema-inspection.worker`),stateMigrationSnapshot:runtimeProcessEntrypoint(`infra/state-migrations.snapshot.worker`),githubExec:runtimeProcessEntrypoint(`agents/github-exec-launcher`),shellSnapshotEnvironment:runtimeProcessEntrypoint(`agents/shell-snapshot-env.worker`),sqliteReadOnly:runtimeProcessEntrypoint(`infra/sqlite-readonly-location.worker`),sqliteSnapshotStaging:runtimeProcessEntrypoint(`infra/sqlite-snapshot-staging.worker`),sqliteReadOnlyNativeResource:runtimeProcessEntrypoint(`infra/sqlite-readonly-native-resource`),sqliteSourceRevision:runtimeProcessEntrypoint(`infra/sqlite-source-revision.worker`),sqliteIntegrity:runtimeProcessEntrypoint(`infra/sqlite-integrity.worker`),sqliteCloseProbe:runtimeProcessEntrypoint(`infra/bun-sqlite-close-probe.worker`),preparedModelCatalog:runtimeProcessEntrypoint(`agents/prepared-model-catalog.worker`),providerPromptState:runtimeProcessEntrypoint(`agents/embedded-agent-runner/provider-prompt-state.worker`),retiredWorktreeCleanup:runtimeProcessEntrypoint(`agents/worktrees/retired-worktree-cleanup.worker`),updateNativeGate:runtimeProcessEntrypoint(`cli/update-cli/update-command-native-gate.worker`),updateStateSizes:runtimeProcessEntrypoint(`infra/update-state-sizes.entry`),updateRepair:runtimeProcessEntrypoint(`infra/update-repair.worker`),immutableBuild:runtimeProcessEntrypoint(`infra/update-immutable-build.worker`),updateMigratedFinalize:runtimeProcessEntrypoint(`infra/update-migrated-finalize.worker`),updateConfigProjection:runtimeProcessEntrypoint(`infra/update-config-projection.worker`),updateAutomaticCleanup:runtimeProcessEntrypoint(`infra/update-automatic-cleanup.worker`),updateCandidateState:runtimeProcessEntrypoint(`infra/update-candidate-state.worker`),doctorLint:runtimeProcessEntrypoint(`commands/doctor-lint.worker`),doctor:runtimeProcessEntrypoint(`commands/doctor.worker`),databaseVerify:runtimeProcessEntrypoint(`state/openclaw-database-verify.worker`),stateOwnership:runtimeProcessEntrypoint(`state/openclaw-state-ownership.worker`),stateLeaseHeartbeat:runtimeProcessEntrypoint(`state/openclaw-state-lease-heartbeat.worker`),gatewayStateOwnerHeartbeat:runtimeProcessEntrypoint(`infra/gateway-state-owner-heartbeat.worker`),sessionTranscriptArchive:runtimeProcessEntrypoint(`config/sessions/session-accessor.sqlite-archive.worker`),sessionTranscript:runtimeProcessEntrypoint(`config/sessions/session-transcript.worker`),usageOverview:runtimeProcessEntrypoint(`infra/session-cost-usage-overview-report.worker`),workerTranscriptCommit:runtimeProcessEntrypoint(`gateway/worker-environments/transcript-commit.worker`),sessionManagerMetadata:runtimeProcessEntrypoint(`agents/sessions/session-manager-metadata.worker`),sessionTranscriptProjectionPublication:runtimeProcessEntrypoint(`config/sessions/session-transcript-projection-publication.worker`),sessionTranscriptActiveFactsBackfill:runtimeProcessEntrypoint(`config/sessions/session-transcript-active-facts-backfill.worker`),sessionTranscriptReports:runtimeProcessEntrypoint(`config/sessions/session-accessor.sqlite-transcript-reports.worker`),sessionTranscriptReconcile:runtimeProcessEntrypoint(`config/sessions/session-transcript-reconcile.worker`),tailscaleRouteOwner:runtimeProcessEntrypoint(`infra/tailscale-route-owner.worker`),serviceChildRelay:runtimeProcessEntrypoint(`process/supervisor/service-child-relay`),terminalPty:runtimeProcessEntrypoint(`process/terminal-pty-worker`),serviceChildGroupAnchor:runtimeProcessEntrypoint(`process/supervisor/service-child-group-anchor`),serviceChildWindowsJobAnchor:runtimeProcessEntrypoint(`process/supervisor/service-child-windows-job-anchor`),bunSqliteLibrary:runtimeProcessEntrypoint(`infra/bun-sqlite-library`)}}function pluginRuntimeProcess(e,t,n){return{plugin:e,ownerSource:`extensions/${e}/${t}.ts`,sourceWorkerName:n,distWorkerPath:`extensions/${e}/${n}.js`,package:{name:`@openclaw/${e}`,distWorkerPath:`${n}.js`}}}({...pluginRuntimeProcess(`browser`,`native-host-entry`,`native-host-entry`)}),{...pluginRuntimeProcess(`browser`,`native-host-entry`,`relay-daemon-entry`)},{...pluginRuntimeProcess(`browser`,`setup-entry`,`setup-entry`)},{...pluginRuntimeProcess(`code-mode-quickjs`,`src/executor`,`src/code-mode.worker`)},pluginRuntimeProcess(`codex`,`stdio-worker-entrypoint`,`stdio.worker`),pluginRuntimeProcess(`codex`,`catalog-page-worker-entrypoint`,`catalog-page.worker`),pluginRuntimeProcess(`codex`,`session-history-worker-entrypoint`,`session-history.worker`),{...pluginRuntimeProcess(`discord`,`src/voice/audio-worker-thread`,`src/voice/audio-worker.runtime`)},{...pluginRuntimeProcess(`document-extract`,`document-extractor-worker-entrypoint`,`document-extractor.worker`)},{...pluginRuntimeProcess(`web-readability`,`web-content-extractor-worker.runtime`,`web-content-extractor.worker`)},{...pluginRuntimeProcess(`file-transfer`,`src/node-host/dir-fetch-archive`,`src/node-host/dir-fetch-archive.worker`)},{...pluginRuntimeProcess(`file-transfer`,`src/node-host/dir-list-worker-command`,`src/node-host/dir-list.worker`)},{...pluginRuntimeProcess(`imessage`,`src/chat-db`,`src/chat-db.worker`)},{...pluginRuntimeProcess(`knowledge`,`src/registry-client`,`src/registry-worker`)},{...pluginRuntimeProcess(`knowledge`,`src/storage-client`,`src/storage-worker`)},{...pluginRuntimeProcess(`memory-core`,`src/memory/manager-cpu-entrypoints`,`src/memory/manager-search.worker`)},{...pluginRuntimeProcess(`memory-core`,`src/memory/manager-cpu-entrypoints`,`src/memory/manager-index.worker`)},{...pluginRuntimeProcess(`memory-core`,`src/memory/manager-cpu-entrypoints`,`src/memory/manager-publication.worker`)},{...pluginRuntimeProcess(`memory-core`,`src/memory/manager-cpu-entrypoints`,`src/standing-intents.worker`)},{...pluginRuntimeProcess(`memory-core`,`src/memory/manager-cpu-entrypoints`,`src/memory-entry-origins.worker`)},pluginRuntimeProcess(`memory-lancedb`,`memory-stats-entrypoint`,`memory-stats.worker`),{...pluginRuntimeProcess(`memory-wiki`,`src/query-reader`,`src/query-reader.worker`)},{...pluginRuntimeProcess(`openai`,`realtime-quicksilver-peer.runtime`,`realtime-quicksilver-audio.worker`)},{...pluginRuntimeProcess(`openai`,`realtime-quicksilver-socket`,`realtime-quicksilver-socket.worker`)},{...pluginRuntimeProcess(`qa-lab`,`src/execution-identity-storage-inspection`,`src/execution-identity-storage-inspection.worker`)},{...pluginRuntimeProcess(`telegram`,`src/telegram-ingress-worker`,`src/telegram-ingress-worker.runtime`)},{...pluginRuntimeProcess(`telegram`,`src/widgets/widget-check`,`src/widgets/widget-check.worker`)},pluginRuntimeProcess(`onnx`,`index`,`src/inference.worker`),pluginRuntimeProcess(`team-reports`,`index`,`src/store.worker`),pluginRuntimeProcess(`team-reports`,`index`,`src/run.worker`),pluginRuntimeProcess(`logbook`,`index`,`src/store.worker`),pluginRuntimeProcess(`workboard`,`index`,`src/sqlite-store.worker`),createRuntimeProcessEntrypoints(import.meta.url);function sameFileMutationFingerprint(e,t){return e.birthtimeNs===t.birthtimeNs&&e.ctimeNs===t.ctimeNs&&e.dev===t.dev&&e.ino===t.ino&&e.mtimeNs===t.mtimeNs&&e.size===t.size}function hashFileDescriptorSync(e,t){let{digest:n,bytes:i}=r(e,{maxBytes:t});return{sha256:n,sizeBytes:i}}function assertExpectedContent(e,t,n){if(e.sizeBytes!==t.sizeBytes)throw Error(`SQLite snapshot size mismatch for ${n}: expected ${t.sizeBytes}, got ${e.sizeBytes}`);if(e.sha256!==t.sha256)throw Error(`SQLite snapshot hash mismatch for ${n}: expected ${t.sha256}, got ${e.sha256}`)}function assertOpenFileIdentitySync(e,r,i){let a=t.fstatSync(e,{bigint:!0}),o=t.lstatSync(r,{bigint:!0});if(!a.isFile()||!o.isFile()||!n(i,a)||!n(i,o))throw Error(`SQLite snapshot file changed: ${r}`)}function hashPublishedFileSync(e,n,r=hashFileDescriptorSync){let i=t.openSync(e,`r`);try{assertOpenFileIdentitySync(i,e,n);let a=t.fstatSync(i,{bigint:!0}),o=r(i),s=t.fstatSync(i,{bigint:!0});if(!sameFileMutationFingerprint(a,s)){if(!sameFileStatFingerprint(a,s))throw Error(`SQLite snapshot file changed while reading: ${e}`);assertExpectedContent(r(i),o,e)}return assertOpenFileIdentitySync(i,e,n),o}finally{t.closeSync(i)}}function sameFileStatFingerprint(e,t){return n(e,t)&&e.size===t.size}process.platform!==`linux`&&process.platform;function canRetainDigest(e,t){let n=t-2000000000n;return typeof e.dev==`bigint`&&typeof e.ino==`bigint`&&typeof e.size==`bigint`&&e.dev!==0n&&e.ino!==0n&&typeof e.birthtimeNs==`bigint`&&typeof e.mtimeNs==`bigint`&&typeof e.ctimeNs==`bigint`&&e.mtimeNs>0n&&e.ctimeNs>0n&&e.mtimeNs<n&&e.ctimeNs<n}function timestampNs(e,t){return e??(typeof t==`bigint`?t*1000000n:BigInt(Math.trunc(t*1e6)))}const a=1073741824;function hashSqliteDatabaseDescriptorSync(n){let r=t.fstatSync(n).size;if(r<=a)return hashFileDescriptorSync(n);let i=Math.min(1073742336,r),o=e(`sha256`),s=Buffer.allocUnsafe(1048576),c=0;for(;;){if(c>=a&&c<i){o.update(Buffer.alloc(i-c)),c=i;continue}let e=c<a?Math.min(s.length,a-c):s.length,r=t.readSync(n,s,0,e,c);if(r===0)return{sha256:o.digest(`hex`),sizeBytes:c};o.update(s.subarray(0,r)),c+=r}}function fingerprintFile(e,n,r=!1){let i=BigInt(Date.now())*1000000n,a=t.openSync(e,`r`);try{let o=t.fstatSync(a,{bigint:!0});if(!o.isFile())throw Error(`SQLite generation target must be a regular file`);let s=n.get(e);if(s&&canRetainDigest(o,i)&&sameFileMutationFingerprint(s,o)){let n=t.fstatSync(a,{bigint:!0}),r=t.statSync(e,{bigint:!0});if(r.isFile()&&sameFileMutationFingerprint(o,n)&&sameFileMutationFingerprint(n,r))return s}let{sha256:c}=hashPublishedFileSync(t.realpathSync.native(e),o,r?hashSqliteDatabaseDescriptorSync:void 0),l=t.fstatSync(a,{bigint:!0}),u=t.statSync(e,{bigint:!0});if(!sameFileStatFingerprint(o,l)||!sameFileStatFingerprint(l,u))throw Error(`SQLite generation target changed while hashing: ${e}`);let d={birthtimeNs:timestampNs(l.birthtimeNs,l.birthtimeMs),ctimeNs:timestampNs(l.ctimeNs,l.ctimeMs),dev:l.dev,ino:l.ino,mtimeNs:timestampNs(l.mtimeNs,l.mtimeMs),sha256:c,size:l.size};return canRetainDigest(o,i)&&sameFileMutationFingerprint(o,l)&&sameFileMutationFingerprint(l,u)?n.set(e,d):n.delete(e),d}finally{t.closeSync(a)}}function readOptionalFile(e,t){try{return fingerprintFile(e,t)}catch(n){if(n.code===`ENOENT`){t.delete(e);return}throw n}}function createSqliteFileGenerationReader(){let e=/* @__PURE__ */ new Map;return t=>{let n=fingerprintFile(t,e,!0),r=readOptionalFile(`${t}-journal`,e),i=readOptionalFile(`${t}-wal`,e);return{database:n,...r?{journal:r}:{},...i?{wal:i}:{}}}}function readStableSqliteFileGeneration(e,t=createSqliteFileGenerationReader()){let n=t(e),r=t(e);if(!sameSqliteFileGeneration(n,r))throw Error(`SQLite file generation changed while reading: ${e}`);return r}function sameFileFingerprint(e,t){return e.dev===t.dev&&e.ino===t.ino&&sameFileStatFingerprint(e,t)&&e.sha256===t.sha256}function sameOptionalFileFingerprint(e,t){return e===void 0?t===void 0:t!==void 0&&sameFileFingerprint(e,t)}function sameSqliteFileGeneration(e,t){return sameFileFingerprint(e.database,t.database)&&sameOptionalFileFingerprint(e.journal,t.journal)&&sameOptionalFileFingerprint(e.wal?.size===0n?void 0:e.wal,t.wal?.size===0n?void 0:t.wal)}function serializeFileFingerprint(e){return{birthtimeNs:e.birthtimeNs.toString(),ctimeNs:e.ctimeNs.toString(),dev:e.dev.toString(),ino:e.ino.toString(),mtimeNs:e.mtimeNs.toString(),sha256:e.sha256,size:e.size.toString()}}function serializeSqliteFileGeneration(e){return JSON.stringify({database:serializeFileFingerprint(e.database),...e.journal?{journal:serializeFileFingerprint(e.journal)}:{},...e.wal?{wal:serializeFileFingerprint(e.wal)}:{}})}const o=[``,`-wal`,`-journal`];function stat(e){try{let n=t.statSync(e,{bigint:!0});if(!n.isFile())throw Error(`SQLite source is not a regular file: ${e}`);return n}catch(e){if(i(e,`ENOENT`))return;throw e}}function identity(e){return e?[e.dev,e.ino,e.size,e.mtimeNs,e.ctimeNs].join(`:`):`missing`}function readSqliteSourceContentVersionInProcess(n){let r=t.realpathSync.native(n),a=o.map(e=>stat(r+e));if(!a[0])return;let s=e(`sha256`).update(r),c=Buffer.allocUnsafe(65536);for(let[e,n]of o.entries()){let o=a[e];if(s.update(`\0${n}\0${identity(o)}\0`),!o)continue;let l;try{l=t.openSync(r+n,`r`)}catch(e){if(i(e,`ENOENT`))return;throw e}try{if(identity(t.fstatSync(l,{bigint:!0}))!==identity(o))return;let e=o.size;for(;e>0n;){let n=Number(e>BigInt(c.length)?BigInt(c.length):e),r=t.readSync(l,c,0,n,null);if(r===0)return;s.update(c.subarray(0,r)),e-=BigInt(r)}if(identity(t.fstatSync(l,{bigint:!0}))!==identity(o))return}finally{t.closeSync(l)}}if(!(t.realpathSync.native(n)!==r||o.some((e,t)=>identity(stat(r+e))!==identity(a[t]))))return s.digest(`hex`)}if(process.argv[2]===`--openclaw-sqlite-readonly-child`){let e;try{let t=process.argv[4],n=process.argv[3];if(n!==`content-version`&&n!==`file-generation`||!t)throw Error(`SQLite content observation requires its mode and source path`);e=n===`file-generation`?{ok:!0,generation:serializeSqliteFileGeneration(readStableSqliteFileGeneration(t))}:{ok:!0,contentVersion:readSqliteSourceContentVersionInProcess(t)??``}}catch(t){process.exitCode=1,e={ok:!1,message:t instanceof Error?t.message:String(t)}}process.stdout.write(JSON.stringify(e))}export{};