openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 19.5 kB
JavaScript
import e from"node:fs";import{sameFileIdentity as t}from"@openclaw/fs-safe/advanced";import{sha256FileSync as n}from"@openclaw/fs-safe/durability";import"@openclaw/fs-safe/errors";import{createHash as r}from"node:crypto";import{hasNodeErrorCode as i}from"@openclaw/fs-safe/path";function createRuntimeProcessEntrypoints(e){function runtimeProcessEntrypoint(t,n=t,r=`.js`,i){return{currentModuleUrl:e,sourceModulePath:`src/${t}${i??`.ts`}`,sourceExtension:i,sourceWorkerName:t.startsWith(`infra/`)?t.slice(6):`../${t}`,distWorkerPath:`${n}${r}`}}let 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`),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`),systemCaWarmup:runtimeProcessEntrypoint(`gateway/system-ca-warmup.worker`),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`),sharedStateStore:runtimeProcessEntrypoint(`state/openclaw-state.worker`),clientCredentials:runtimeProcessEntrypoint(`infra/client-credential.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`),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`),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(`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:r,bytes:i}=n(e,{maxBytes:t});return{sha256:r,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(n,r,i){let a=e.fstatSync(n,{bigint:!0}),o=e.lstatSync(r,{bigint:!0});if(!a.isFile()||!o.isFile()||!t(i,a)||!t(i,o))throw Error(`SQLite snapshot file changed: ${r}`)}function hashPublishedFileSync(t,n){let r=e.openSync(t,`r`);try{assertOpenFileIdentitySync(r,t,n);let i=e.fstatSync(r,{bigint:!0}),a=hashFileDescriptorSync(r),o=e.fstatSync(r,{bigint:!0});if(!sameFileMutationFingerprint(i,o)){if(!sameFileStatFingerprint(i,o))throw Error(`SQLite snapshot file changed while reading: ${t}`);assertExpectedContent(hashFileDescriptorSync(r),a,t)}return assertOpenFileIdentitySync(r,t,n),a}finally{e.closeSync(r)}}function sameFileStatFingerprint(e,n){return t(e,n)&&e.size===n.size}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)))}function fingerprintFile(t,n){let r=BigInt(Date.now())*1000000n,i=e.openSync(t,`r`);try{let a=e.fstatSync(i,{bigint:!0});if(!a.isFile())throw Error(`SQLite generation target must be a regular file`);let o=n.get(t);if(o&&canRetainDigest(a,r)&&sameFileMutationFingerprint(o,a)){let n=e.fstatSync(i,{bigint:!0}),r=e.statSync(t,{bigint:!0});if(r.isFile()&&sameFileMutationFingerprint(a,n)&&sameFileMutationFingerprint(n,r))return o}let{sha256:s}=hashPublishedFileSync(e.realpathSync.native(t),a),c=e.fstatSync(i,{bigint:!0}),l=e.statSync(t,{bigint:!0});if(!sameFileStatFingerprint(a,c)||!sameFileStatFingerprint(c,l))throw Error(`SQLite generation target changed while hashing: ${t}`);let u={birthtimeNs:timestampNs(c.birthtimeNs,c.birthtimeMs),ctimeNs:timestampNs(c.ctimeNs,c.ctimeMs),dev:c.dev,ino:c.ino,mtimeNs:timestampNs(c.mtimeNs,c.mtimeMs),sha256:s,size:c.size};return canRetainDigest(a,r)&&sameFileMutationFingerprint(a,c)&&sameFileMutationFingerprint(c,l)?n.set(t,u):n.delete(t),u}finally{e.closeSync(i)}}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),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 a=[``,`-wal`,`-journal`];function stat(t){try{let n=e.statSync(t,{bigint:!0});if(!n.isFile())throw Error(`SQLite source is not a regular file: ${t}`);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(t){let n=e.realpathSync.native(t),o=a.map(e=>stat(n+e));if(!o[0])return;let s=r(`sha256`).update(n),c=Buffer.allocUnsafe(65536);for(let[t,r]of a.entries()){let a=o[t];if(s.update(`\0${r}\0${identity(a)}\0`),!a)continue;let l;try{l=e.openSync(n+r,`r`)}catch(e){if(i(e,`ENOENT`))return;throw e}try{if(identity(e.fstatSync(l,{bigint:!0}))!==identity(a))return;let t=a.size;for(;t>0n;){let n=Number(t>BigInt(c.length)?BigInt(c.length):t),r=e.readSync(l,c,0,n,null);if(r===0)return;s.update(c.subarray(0,r)),t-=BigInt(r)}if(identity(e.fstatSync(l,{bigint:!0}))!==identity(a))return}finally{e.closeSync(l)}}if(!(e.realpathSync.native(t)!==n||a.some((e,t)=>identity(stat(n+e))!==identity(o[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{};