openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
9 lines (8 loc) • 19.8 kB
JavaScript
import{n as e,r as t}from"./rolldown-runtime-CNOWq4Kh.js";import{or as n}from"./_4____________________________.js";import{GP as r,HP as i,JP as a,KP as o,MP as s,OP as c,UP as l,WP as u}from"./_2_____________________________.js";var d;function f(){return(f=e((()=>{d=[`requested`,`staging`,`validating`,`repairing`,`activating`,`restarting`,`verifying`,`finished`]})))()}function ee(e){return!!(e&&m.has(e))}function p(e=e=>e){return`Inspect \`${e(`openclaw update status`)}\` and \`${e(`openclaw doctor`)}\`. Wait for the owning updater and its child processes to stop before running \`${e(`openclaw update repair`)}\`. The timeout does not make rollback or removal of retained update state safe.`}var m,h;function g(){return(g=e((()=>{m=new Set([`preflight-node-runtime-incompatible`,`git-version-unsupported`,`preflight-insufficient-space`,`snapshot-capacity-insufficient`]),h={"external-supervisor-update-required":"This Gateway is managed by an external supervisor. Use your server or deployment's update workflow to update OpenClaw and restart the Gateway. The OpenClaw app and `openclaw update` cannot update this installation. No package changes or Gateway restart were attempted.","container-image-install":`Pull or build the target Docker/container image, then redeploy it with the same state/config mounts. No package changes or Gateway restart were attempted.`,"unmanaged-package-install":`No npm, pnpm, or Bun global owner was detected. Reinstall using the original method; use Yarn for Yarn global installs. No package changes or Gateway restart were attempted.`,"package-update-requires-cli":"Run `openclaw update` through this install's npm, pnpm, or Bun global launcher. No package changes or Gateway restart were attempted."}})))()}function _(e,t={}){if(!Number.isFinite(e))return`unknown`;let n=t.decimals??1,r=t.unit??`s`,i=(Math.max(0,e)/1e3).toFixed(Math.max(0,n)).replace(/\.0+$/,``).replace(/(\.\d*[1-9])0+$/,`$1`);return r===`seconds`?`${i} seconds`:`${i}s`}function v(e,t={}){if(!Number.isFinite(e))return`unknown`;let n=Math.max(0,Math.round(e));return n<1e3?`${n}ms`:_(e,{decimals:t.decimals??2,unit:t.unit??`s`})}function y(){return(y=e((()=>{})))()}function te(e){return`Doctor config promotion refused for top-level keys: ${e.keys.join(`, `)||`none recorded`}. ${e.reason}: ${e.message}`}function b(e){return e.reason===`expired`?`lease loss: expired; expiredByMs=${e.expiredByMs}; expiresAt=${e.expiresAt}; heartbeatAgeMs=${e.heartbeatAgeMs}${e.renewalTimerLateByMs===void 0?``:`; renewal timer late ${e.renewalTimerLateByMs} ms`}`:e.reason===`replaced`?`lease loss: replaced; owner=[redacted]`:`lease loss: ${e.reason}`}function x(e){let t=[[`prefix`,e.prefix],[`package`,e.packageRoot],[`running install`,e.runningRoot],[`running prefix`,e.runningPrefix],[`launcher`,e.launcher],[`launcher target`,e.launcherTarget]];return[`Warning: npm destination ownership ${e.ownership}; cause ${e.cause}; kind ${e.destinationKind}`,...t.flatMap(([e,t])=>t===null?[]:[`${e} \`${t}\``]),`Next step: ${S}`].join(`; `)}function ne(e){let t=e.slice(-3),n=e.find(e=>(e.failureFacts?.length??0)>0);return n&&!t.includes(n)?[n,...t.slice(-2)]:t}function re(e){let t=e.destination?x(e.destination):e.message;return`Failing check ${e.check} (${e.code})${e.location?` at ${e.location}`:``}${e.pluginId?`; plugin ${e.pluginId}`:``}${e.affectedKey?`; key ${e.affectedKey}`:``}${t?`: ${t}`:``}${e.leaseLoss?`; ${b(e.leaseLoss)}`:``}`}var S;function C(){return(C=e((()=>{S=`Use the destination's owning installation and service account, or correct the npm prefix mismatch before retrying: https://docs.openclaw.ai/install/update-troubleshooting#node-and-global-install-permissions. Do not overwrite another installation.`})))()}function w(e,t=e=>e){switch(e){case`inside-gateway-process-tree`:case`inside-gateway-service`:case`service-membership-unverified`:case`service-ancestry-unverified`:return`Run \`${t(`openclaw update repair`)}\` from a terminal outside the Gateway process tree. Do not run this repair through the Gateway's exec tool.`;case`inside-triage-process-tree`:return`Run \`${t(`openclaw update repair`)}\` from a terminal outside automatic triage and the Gateway process tree. Do not stop the Gateway from its fixing subtree.`;default:return}}function T(){return(T=e((()=>{})))()}function E(e){let t=e.find(e=>e.step===D),n=Number(t?.detail);return Number.isSafeInteger(n)&&n>0?n:0}function ie(e){let t=E(e);return t>0?`Update history truncated: ${t} ${t===1?`row`:`rows`} omitted.`:void 0}var D;function O(){return(O=e((()=>{D=`history:truncated`})))()}function k(e){return Object.hasOwn(F,e)}function A(e){return e.startsWith(P)}function j(e){return e.status!==`failed`&&e.status!==`rolled-back`}function M(e){return j(e)?e.steps.flatMap(t=>A(t.step)&&t.status===`skipped`?[{id:t.step.slice(14),runId:e.runId??``,reason:t.detail??`no reason recorded`}]:[]):[]}function N(e){let{label:t,retry:n}=k(e.id)?F[e.id]:{label:`Update step ${e.id}`,retry:`Update OpenClaw to a version that retries it.`};return`${t} is owed: ${e.reason.replace(/[.\s]+$/u,``)}. ${n}`}var P,F;function I(){return(I=e((()=>{P=`finalize:owed:`,F={"shell-completion":{label:`Shell completion refresh`,retry:"Retried by the next `openclaw update`; run `openclaw update repair` to retry it now."},"service-definition":{label:`Gateway service definition refresh`,retry:"Settled when `openclaw update` next refreshes the service definition; `openclaw update repair` rechecks it."},"plugin-convergence":{label:`Plugin convergence`,retry:"Retried by the next `openclaw update`; run `openclaw update repair` to retry it now."},"post-plugin-doctor":{label:`Post-plugin Doctor`,retry:"Settled when `openclaw update` next completes Doctor after changing plugins; run `openclaw update repair` to retry it now."}}})))()}function ae(e){let t=e.some(e=>e.step===`finalize:doctor:model-retirement`&&e.status===`completed`);return[...new Set(e.flatMap(e=>(e.step===`reconcile:settle`||e.status===`completed`&&e.step.startsWith(`warning:`))&&!(t&&e.step===`warning:finalize:doctor:model-retirement`)&&e.detail?[e.detail]:[]))]}function oe(e){let t=e=>s(e,{style:`iec`,maxUnit:`giga`,separator:` `,fractionDigits:(e,t)=>+(t===`giga`&&e<10)}),n=`${t(e.sqliteBytes)} SQLite and ${e.pluginBytes===null?`plugin files not yet inspected`:`${t(e.pluginBytes)} plugin files`}`,r=e.candidates.map(({directory:e,availableBytes:n,allocationError:r})=>`${e}: ${n===null?`free space unavailable`:`${t(n)} available`}${r?` (unavailable: ${r})`:``}`).join(`; `),i=e.selection?`Snapshot location: ${e.selection.directory} (${e.selection.kind}).`:e.reason===`snapshot-location-unavailable`?`No snapshot location with enough free space could be allocated.`:`No snapshot location has enough measured free space.`,a=e.reason===`snapshot-location-unavailable`?` Fix the reported path or permissions, or set TMPDIR to a writable directory with sufficient space, then retry the update.`:` Free space or set TMPDIR to a directory on a filesystem with sufficient space, then retry the update.`;return`${i} Snapshot requires ${e.pluginBytes===null?`at least `:``}${t(e.requiredBytes)} for ${n} and scratch space. Checked ${r}.${e.selection?``:a}`}function L(){return(L=e((()=>{c()})))()}var R=t({renderUpdateRunReport:()=>G});function z(e,t){return e.versionMatch===void 0?{kind:`unobserved`}:e.versionMatch?{kind:`verified`}:e.runningVersion&&t.version&&e.runningVersion!==t.version?{kind:`mismatch`,field:`version`}:e.runningBuildId&&t.buildId&&e.runningBuildId!==t.buildId?{kind:`mismatch`,field:`build`}:{kind:`unavailable`}}function se(e,t){let n=z(e,t);return n.kind===`mismatch`?`${n.field} mismatch`:{unobserved:null,verified:`version verified`,unavailable:`service identity unavailable`}[n.kind]}function B(e){return e.kind===`responding`?`Current health: Gateway answered on the recorded port (${H(e.version,120)}).`:`Current health unavailable; saved verification describes the update attempt only.`}function V(e,t){if(t?.exitCode!==0||t.failureFacts?.length)return;let{recovery:n}=e;return n?.serviceRestartSafe&&n.service===`healthy`?n.version:e.versionMatch&&(e.coreReady??e.readyz)&&e.settled?e.runningVersion:void 0}function ce(e,t,n=e.recovery?.reason??`not-recorded`){let{recovery:r}=e;if(!t){if(!r)return;let e=r.packageRollbackVerified;if(!r.serviceRestartSafe)return`${e?`package rollback verified; service restart not verified`:`not verified`} (${n})`;let t=H(r.version,120);return r.service===`healthy`?`${e?`package rollback verified; `:``}Gateway serving ${t}; health verified`:r.service!==`failed`&&!e?`verified safe to restart`:`${e?`package rollback verified (${t})`:`runtime files verified`}; Gateway health ${r.service===`failed`?`failed`:`unverified`} (${n}). Run \`openclaw gateway status --deep\` to check the serving version and readiness.`}let i=V(e,t);if(i){let e=r?.serviceRestartSafe===!1?`; restart remains unsafe (${n})`:``;return`${r?.packageRollbackVerified?`package rollback verified; `:``}verified serving ${H(i,120)}${e}`}let a=t.failureFacts?.[0]?.code;return a?a===`gateway-probe-failed`?`recovery check failed (${a})`:a===`stopped-free`?`not serving (${a})`:`readiness unverified (${a})`:`Gateway readiness is pending; recovery check completed without verified readiness`}function H(e,t){return e.length<=t?e:`${n(e,0,t-1)}…`}function U(e){let t=e.sha?.slice(0,8);return e.version?`${e.version}${t?` (${t})`:``}`:t}function W(e,t){if(e.target?.installationMethod===`ocm`)return t?[]:e.origin.nextAction?[e.origin.nextAction]:[];if(e.status===`running`)return[`Check progress with openclaw update status.`];if(e.status!==`failed`)return[];let n=w(e.reason);if(n)return t?[]:[n];if(e.reason===`legacy-driver-expired`)return[o];if(e.reason===`update-activation-timeout`)return t?[]:[p()];if(e.reason===`global-install-foreign-destination`)return t?[]:[`Next step: ${S}`];if(e.reason===`state-migrated-no-rollback`||e.verification.rollbackOutcome?.reason===`state-migrated-no-rollback`)return t?[]:[`State may have changed during migration, so rolling back code alone is unsafe. Keep the new installation and backups; inspect openclaw update status and run openclaw doctor before recovery.`];let r=e.reason&&Object.hasOwn(q,e.reason)?q[e.reason]:void 0,i=r?[r]:[];return t||i.push(e.reason===`repair-failed`?`Run openclaw triage to diagnose this repair failure.`:`Run openclaw triage to diagnose and repair the failed update.`),i}function G(e,t={}){let n=r(e),a=u(e),o=t.currentHealth??(e.target?.installationMethod!==`ocm`&&e.status!==`running`&&t.nextAction===void 0&&e.origin.nextAction?{kind:`unavailable`}:void 0),s=e.status===`failed`&&o?.kind===`responding`&&!!e.after.version&&o.version===e.after.version&&e.verification.recovery?.serviceRestartSafe===!1&&e.verification.recovery.reason===`runtime-verification-failed`&&!e.steps.some(e=>e.step===`doctor process settlement`),c=U(e.before),l=U(e.after),d=H(e.reason?.trim()||e.status===`failed`&&e.steps.find(e=>e.status===`failed`&&e.step!==`requested`)?.step||`unknown reason`,240),f=!o&&e.verification.serviceRunning===!0?e.verification.runningVersion:void 0,p=e.status===`failed`&&(e.reason===`node-runtime-preflight`||e.reason===`preflight-node-runtime-incompatible`),m=M(e),g=[...ae(e.steps).filter(e=>!m.some(t=>e.startsWith(t.reason))),...m.map(N)].map(e=>`Warning: ${e}`),_=e.status===`failed`&&ee(e.reason)&&t.nextAction?t.nextAction.split(`
`)[0]?.split(`
`):void 0,y=_?.[0]?.match(/^Update refused: .+/u)?.[0],b;switch(e.status){case`succeeded`:{let t=g.length;for(let n of e.steps){if(n.status!==`failed`||J.has(n.step)||m.some(({id:e})=>e===n.step))continue;let r=`warning:${n.step}`;e.steps.some(e=>e.step===r&&e.status===`completed`&&!!e.detail)||t++}let r=t>0?`; ${t} warning${t===1?` needs`:`s need`} attention`:``;b=n?`✅ OpenClaw repair completed${l?` for ${l}`:``}${r}.`:l?`✅ OpenClaw updated to ${l}${c?` (from ${c})`:``}${r}.`:`✅ OpenClaw updated${r}.`;break}case`failed`:b=a?`ℹ️ OpenClaw abandoned update reconciled.`:e.reason===`legacy-driver-expired`?`ℹ️ OpenClaw update abandoned: ${d}.`:y?`⚠️ ${y}`:p?`⚠️ OpenClaw could not complete the update. A required system check failed.`:`⚠️ OpenClaw ${e.reason===`repair-failed`||n?`repair`:`update`} failed: ${d}.`;break;case`skipped`:b=e.reason===`still-starting`?`ℹ️ OpenClaw${l?` ${l}`:``} installed; Gateway still starting; readiness unverified; recovery backups retained.`:e.reason===`gateway-readiness-unverified`?`ℹ️ OpenClaw${l?` ${l}`:``} installed; Gateway readiness unverified; recovery backups retained.`:e.reason===`doctor-maintenance-pending`?`ℹ️ OpenClaw repair pending: Doctor maintenance remains unfinished.`:`ℹ️ OpenClaw update skipped: ${d}.`;break;case`rolled-back`:b=`↩️ OpenClaw update rolled back to ${l??f??c??`the previous version`}: ${d}.`;break;case`running`:b=`${K}${e.target?.installationMethod===`ocm`?`managed by OCM`:e.phase}.`}b=H(b,500);let x=t.markdownLimit??1500,S=ie(e.steps),C=[...S?[S]:[],...e.status===`succeeded`?g:[]];o&&(s||!e.origin.nextAction&&!t.nextAction)&&(C.push(B(o)),s&&C.push(`The target version is serving; the saved runtime verification failure no longer applies. The recorded update outcome is unchanged.`)),t.mode&&t.mode!==`unknown`&&C.push(`Update mode: ${t.mode}`);let w=e.target&&(U(e.target)||e.target.tag||e.target.channel);w&&C.push(`Update target: ${H(w,120)}`);let T=e.origin.admission;if(T){let e=T.candidateVersion?` (${H(T.candidateVersion,120)})`:``;C.push(`Update safety checks ran in the ${T.owner} updater${e}.`),T.checks?.length&&C.push(`Admission checks: ${T.checks.map(e=>`${H(e.name,120)}: ${e.status}`).join(`, `)}.`),T.fallbackReason&&C.push(`Admission fallback: ${H(T.fallbackReason,500)}`)}for(let t of e.steps)e.status===`running`&&t.status===`in_progress`&&t.detail&&C.push(`Waiting: ${t.step}${t.startedAtMs===void 0?``:` (started ${new Date(t.startedAtMs).toISOString()})`} — ${t.detail}`),t.snapshotCapacity&&C.push(oe(t.snapshotCapacity)),t.detail&&(t.step.startsWith(`diagnostic:database snapshot`)||t.step.startsWith(`diagnostic:database migration writes`)||t.step.startsWith(`diagnostic:database rollback`))&&C.push(t.detail),t.configWriteRefusal&&C.push(te(t.configWriteRefusal));let E=e.steps.flatMap(e=>e.configChange?[e.configChange]:[]),D=[...new Set(E.flatMap(e=>e.kind===`key`?[e.key]:[]))];D.length&&C.push(`Doctor changed config keys: ${D.join(`, `)}.`);for(let e of new Set(E.flatMap(e=>e.kind===`migration`?[e.message]:[])))C.push(`Warning: Doctor migration: ${e}`);let O=e.steps.filter(e=>J.has(e.step)),k=O.map(e=>{let t=e.startedAtMs!=null&&e.endedAtMs!=null?` (${v(Math.max(0,e.endedAtMs-e.startedAtMs))})`:``;return`${e.step}${t}`});if(k.length){C.push(`Phases: ${k.join(` → `)}`);let t=O.reduce((e,t)=>e+(t.startedAtMs!=null&&t.endedAtMs!=null?Math.max(0,t.endedAtMs-t.startedAtMs):0),0),n=e.createdAtMs==null||e.finishedAtMs==null?0:e.finishedAtMs-e.createdAtMs;n-t>=1e3&&C.push(`Total: ${v(n)}, including work outside these phases.`)}for(let t of ne(e.steps.filter(e=>e.status===`failed`))){let e=`Failed: ${t.step}${t.detail?` — ${t.detail}`:``}`;C.push(H(e,300)),t.stderrTail&&(t.termination===`signal`||t.step===`candidate-state-snapshot`)&&C.push(`Stderr${t.termination===`signal`?` (${t.signal??`unknown signal`})`:``}:\n${t.stderrTail}`),C.push(...(t.failureFacts??[]).slice(0,5).map(n=>re({...n,message:e.length<=300&&n.message&&t.detail?.includes(n.message)?void 0:n.message})))}e.status!==`succeeded`&&C.push(...g);let A=e.verification,j=e.steps.findLast(e=>e.step===`gateway recovery verification`),P=!s&&j&&ce(A,j);P&&C.push(`Recorded recovery: ${P}.`);let F=[A.booted?`gateway booted`:void 0,A.serviceRunning===void 0?void 0:A.serviceRunning?`service running${A.runningVersion?` (${H(A.runningVersion,120)})`:``}`:`service stopped`,se(A,e.after),A.channelsReady===void 0?void 0:A.channelsReady?`channels ready`:`channels not ready`,A.readyz===void 0?void 0:A.readyz?`HTTP ready`:`HTTP not ready`,A.coreReady===void 0?void 0:A.coreReady?`core ready`:`core not ready`,A.pluginErrors?.length?`${A.pluginErrors.length} plugin activation error(s)`:void 0].filter(Boolean);F.length&&C.push(`Recorded verification: ${F.join(`; `)}.`);for(let t of e.repair.slice(-3))C.push(H(`Repair ${t.attempt}: ${t.status}${t.summary||t.reason?` — ${t.summary??t.reason}`:``}`,300));e.downtimeMs!=null&&C.push(`Gateway downtime: ${v(e.downtimeMs)}.`);let I=e.status===`skipped`&&e.reason&&Object.hasOwn(h,e.reason)?h[e.reason]:void 0,L=t.nextAction??(s?void 0:e.origin.nextAction)??I,R=L&&o?`${B(o)} ${o.kind===`responding`?`This observation supersedes saved claims that the Gateway is stopped; other recovery constraints still apply. The recorded update outcome is unchanged.`:`Check current Gateway status before acting on this saved advice.`}\nHistorical recovery advice: “${L}”`:L,z=e.repair.at(-1)?.reason,V=z===`requester-revoked`||z===`repair-requires-config-change`?z:e.reason,G=e.status===`failed`&&V===`requester-revoked`?R?`Repair stopped because the chat requester is no longer a command owner. Further recovery requires a current command owner.`:`Repair stopped because the chat requester is no longer a command owner. A current command owner must start a new update, or the operator can run openclaw triage locally.`:e.status===`failed`&&V===`repair-requires-config-change`?R?`Doctor could not promote config changes. Review the named keys and writer refusal before continuing recovery.`:`Doctor could not promote config changes. Review the named keys and writer refusal, then run openclaw doctor --fix under your own authority, or openclaw triage.`:void 0,q=a?[]:e.status===`running`?t.nextAction?[t.nextAction]:W(e):G?[G,...R?[R]:[]]:[...new Set([I?void 0:t.doctorHint??A.doctorHint??e.origin.doctorHint,...W(e,R),R].filter(e=>!!e))];e.status!==`succeeded`&&e.origin.cause&&C.unshift(`Cause: ${e.origin.cause}`);let Y=e.steps.find(e=>e.step===i)?.detail,X=Y?[`Repaired update: ${Y}`]:[],Z=X.map(e=>H(e,300)),Q=q.at(-1);if(y){let e=[`Details:`,`Reason code: ${d}`,...C,...q].join(`
`),t=_?.slice(1)??[],n=H([b,...Z,...t].join(`
`),1100);return{headline:b,lines:[...X,...t,...S?[S]:[]],markdown:`${n}\n\n${H(e,x-n.length-2)}`}}if(p||e.reason===`doctor-maintenance-pending`){let e=[`Details:`,`Reason code: ${d}`,...C,...q.filter(e=>e!==Q)],t=[b,...Z,...Q?[H(Q,1100)]:[],``].join(`
`);return{headline:b,lines:[...X,...Q?[Q,``]:[],...e],markdown:`${t}\n${H(e.join(`
`),x-t.length-1)}`}}C.unshift(...X),C.push(...q);let le=[b,...C.filter(e=>e!==Q)].join(`
`),$=Q?`\n${H(Q,1100)}`:``;return{headline:b,lines:C,markdown:`${H(le,x-$.length)}${$}`}}var K,q,J;function Y(){return(Y=e((()=>{f(),g(),y(),C(),T(),a(),O(),I(),l(),L(),K=`⬆️ OpenClaw update in progress: `,q={"preflight-local-replay-conflict":`A local commit conflicts with the update target. Resolve the conflict in the paths named by the failing check (rebase the local commits onto the update target, or drop them), then rerun the update.`,"preflight-insufficient-space":`Free space on the preflight staging and package-manager store filesystems, then rerun the update.`,"pnpm-corepack-missing":`This pnpm checkout could not auto-enable pnpm because corepack is missing. Install pnpm manually or install Node with corepack available, then rerun the update command.`,"pnpm-corepack-enable-failed":`Run corepack enable manually or install pnpm manually, then rerun the update command.`,"pnpm-npm-bootstrap-failed":`This pnpm checkout could not bootstrap pnpm from npm automatically. Install pnpm manually, then rerun the update command.`,"preferred-manager-unavailable":`Install the checkout's declared package manager manually, then rerun the update command.`},J=new Set(d)})))()}export{d as a,R as i,G as n,f as o,z as r,Y as t};