openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 5.74 kB
JavaScript
import"./openclaw-state-read-sqlite-readonly-worker-umlSCyCR.mjs";import"./openclaw-state-read-map-size-DJbMcZYM.mjs";import{v as e}from"./openclaw-state-read-home-dir-BQZX1pD2.mjs";import"./openclaw-state-read-sqlite-database-admission-Ck6VG7rE.mjs";import"./openclaw-state-read-pool-1Cp_Z7yz.mjs";import"./openclaw-state-read-logger-Ix7jXPG1.mjs";import"./openclaw-state-read-sqlite-lifecycle-errors-3AcFJUep.mjs";import"./openclaw-state-read-openclaw-state-db.paths-CFemYLpA.mjs";import"./openclaw-state-read-gateway-lock-payload-C9huNHFz.mjs";import{a as t,t as n}from"./openclaw-state-read-pid-alive-_-Y1IvGj.mjs";import"./openclaw-state-read-gateway-state-owner-BJTFuTQ0.mjs";import"./openclaw-state-read-runtime-process-entrypoints-ItwYqjQs.mjs";import"./openclaw-state-read-runtime-worker-url-ClM3d-g2.mjs";import{t as r}from"./openclaw-state-read-subsystem-DSi0tJn8.mjs";import"./openclaw-state-read-worker-cpu-Ca-4Z8Q3.mjs";import"./openclaw-state-read-sqlite-snapshot-capacity-error-Df9fZtJA.mjs";import"./openclaw-state-read-gateway-process-argv-CwtqUewA.mjs";import{a as i,r as a}from"./openclaw-state-read-kysely-sync-DQyYiAw5.mjs";import"./openclaw-state-read-errors-D_saNBXy.mjs";import"./openclaw-state-read-open-pprz0Grj.mjs";import"./openclaw-state-read-sqlite-worker-operation-admission-DTfv_SKu.mjs";import{a as o}from"./openclaw-state-read-sqlite-transaction-V1rK3HH2.mjs";import{o as s}from"./openclaw-state-read-openclaw-state-db-schema-helpers-BkqUYEFY.mjs";import"./openclaw-state-read-sqlite-snapshot-staging-owner-B9a1YbDW.mjs";import"./openclaw-state-read-openclaw-state-db-DnrW7QY9.mjs";import"./openclaw-state-read-gateway-supervision-queMstQ7.mjs";import"./openclaw-state-read-async-work-scope-CNcLd_yE.mjs";import"./openclaw-state-read-openclaw-state-db-readonly-CDG18cNK.mjs";import"./openclaw-state-read-windows-appcontainer-spawn-B9xODvkk.mjs";import"./openclaw-state-read.worker.js";import"./openclaw-state-read-openclaw-state-worker-context-Cvog3s4V.mjs";import"./openclaw-state-read-update-run-schema-BQRxjcpp.mjs";import"./openclaw-state-read-windows-install-roots-nshDFN0K.mjs";import{t as c}from"./openclaw-state-read-update-run-recovery-store-B-8Xa-fT.mjs";import"./openclaw-state-read-startup-migration-checkpoint-B37WkXCU.mjs";import"./openclaw-state-read-darwin-process-command-CcgIy_8D.mjs";import{a as l}from"./openclaw-state-read-restart-sentinel-store-B_R93Cio.mjs";import{decodeRun as u,hasStoredUpdateRecovery as d,n as f,readUpdateRunRecord as p,t as m}from"./openclaw-state-read-update-run-read.kernel-DS4CWnDd.mjs";import"node:fs";import"node:path";import"node:worker_threads";import"node:child_process";import{hostname as h}from"node:os";import"node:crypto";import"@openclaw/proc-safe/identity";e(Symbol.for(`openclaw.stateLeaseHeartbeatCarriers`),()=>/* @__PURE__ */ new Map),r(`state/lease`),r(`gateway`),process.platform,r(`restart`);function toUpdateRunDriver({host:e,pid:t,startIdentity:n}){return{host:e,pid:t,startIdentity:n}}function sameUpdateRunDriver(e,t){return e.host===t.host&&e.pid===t.pid&&e.startIdentity===t.startIdentity}function inspectUpdateRunDriver(e){if(e.host!==h())return`unknown`;if(t(e.pid))return`dead`;let r=n(e.pid);return r===null?`unknown`:String(r)===e.startIdentity?`alive`:`dead`}function updateRunLastActivity(e){return Math.max(e.updatedAtMs,...e.steps.flatMap(e=>[e.startedAtMs??0,e.endedAtMs??0]))}function hasUnrecordedUpdateRunDriver(e){return e.steps.some(e=>e.step===`driver:identity-unavailable`)}function recordedUpdateRunDrivers(e){return[...e.origin.driver?[e.origin.driver]:[],...e.origin.previousDrivers??[]].map(toUpdateRunDriver)}function inspectUpdateRunAbandonment(e,t={}){return e.status===`running`?inspectUpdateRunDriverAbandonment(e,t):void 0}function inspectUpdateRunDriverAbandonment(e,t){if(f(e))return m;let n=hasUnrecordedUpdateRunDriver(e);if(!t.explicit&&n)return;let r=recordedUpdateRunDrivers(e),i=e.origin.managedHandoff;if(i&&(r=[i.helper,...r.filter(e=>!sameUpdateRunDriver(e,i.parent)&&!sameUpdateRunDriver(e,i.helper))]),!((!r.length||n)&&Date.now()-updateRunLastActivity(e)<=18e5))return r.length?r.every(e=>inspectUpdateRunDriver(e)===`dead`)?i?`handoff-terminated`:`inactive-driver-dead`:t.exclusiveRepair&&!n&&r.every(e=>inspectUpdateRunDriver(e)!==`alive`)?`exclusive-repair-ownership`:void 0:t.explicit?`operator-reconciled-inactive-run`:void 0}function inspectUpdateRunReconciliation(e,t,n){let r=d(e,t.runId)?void 0:inspectUpdateRunAbandonment(t,n);if(r&&!n.explicit&&t.trigger!==`cli`&&(t.phase===`restarting`||t.phase===`verifying`)&&s(e,`gateway_restart_sentinel`)){let n=l(e),r=n.kind===`valid`?n.sentinel.payload:void 0;if(r?.kind===`update`&&r.status===`ok`&&r.stats?.runId===t.runId&&!r.stats.handoffId)return{record:t,rule:void 0}}return{record:t,rule:r}}function readUpdateRunReconciliationRows(e,t){if(!s(e,`update_runs`))return[];let n=i(e).selectFrom(`update_runs`).selectAll().where(`status`,`=`,`running`);return t.runIds&&(n=n.where(`run_id`,`in`,[...t.runIds])),t.excludeRunId&&(n=n.where(`run_id`,`!=`,t.excludeRunId)),a(e,n.orderBy(`run_id`)).rows}function readUpdateRunReconciliationCandidates(e,t){return!e.isTransaction&&readUpdateRunReconciliationRows(e,t).length===0?[]:o(e,()=>readUpdateRunReconciliationRows(e,t).map(n=>inspectUpdateRunReconciliation(e,u(n),t)))}function readUpdateRunAdmissionCommand(e,t){return t.type===`updateRuns.reconciliationCandidates`?{type:t.type,candidates:readUpdateRunReconciliationCandidates(e,t.input)}:o(e,()=>{if(t.type===`updateRuns.recoveryAdmission`)return{type:t.type,facts:c(e)};let n=s(e,`update_runs`)?p(e,t.runId):void 0;return{type:t.type,candidate:n?inspectUpdateRunReconciliation(e,n,{}):void 0}})}export{readUpdateRunAdmissionCommand};