import{Ml as e}from"./model-selection-p21GBPS6.js";import{t}from"./openclaw-root-D_0Q6--h.js";import{t as n}from"./command-format-BbDT1tlm.js";import{n as r,r as i}from"./channel-account-context-kX_5d8CX.js";async function a(e){return await r({root:await t({moduleUrl:import.meta.url,argv1:process.argv[1],cwd:process.cwd()}),timeoutMs:e.timeoutMs,fetchGit:e.fetchGit,includeRegistry:e.includeRegistry})}function o(t){let n=t.registry?.latestVersion??null,r=n?i(e,n):null,a=r!=null&&r<0,o=t.installKind===`git`&&typeof t.git?.behind==`number`?t.git.behind:null,s=o!=null&&o>0;return{available:s||a,hasGitUpdate:s,hasRegistryUpdate:a,latestVersion:a?n:null,gitBehind:o}}function s(e){let t=o(e);if(!t.available)return null;let r=[];return t.hasGitUpdate&&t.gitBehind!=null&&r.push(`git behind ${t.gitBehind}`),t.hasRegistryUpdate&&t.latestVersion&&r.push(`npm ${t.latestVersion}`),`Update available${r.length>0?` (${r.join(` · `)})`:``}. Run: ${n(`openclaw update`)}`}function c(t){let n=[],r=()=>{if(t.registry?.latestVersion){let r=i(e,t.registry.latestVersion);r===0?n.push(`npm latest ${t.registry.latestVersion}`):r!=null&&r<0?n.push(`npm update ${t.registry.latestVersion}`):n.push(`npm latest ${t.registry.latestVersion} (local newer)`);return}t.registry?.error&&n.push(`npm latest unknown`)};if(t.installKind===`git`&&t.git){let e=t.git.branch?`git ${t.git.branch}`:`git`;n.push(e),t.git.upstream&&n.push(`↔ ${t.git.upstream}`),t.git.dirty===!0&&n.push(`dirty`),t.git.behind!=null&&t.git.ahead!=null&&(t.git.behind===0&&t.git.ahead===0?n.push(`up to date`):t.git.behind>0&&t.git.ahead===0?n.push(`behind ${t.git.behind}`):t.git.behind===0&&t.git.ahead>0?n.push(`ahead ${t.git.ahead}`):t.git.behind>0&&t.git.ahead>0&&n.push(`diverged (ahead ${t.git.ahead}, behind ${t.git.behind})`)),t.git.fetchOk===!1&&n.push(`fetch failed`),r()}else n.push(t.packageManager===`unknown`?`pkg`:t.packageManager),r();return t.deps&&(t.deps.status===`ok`&&n.push(`deps ok`),t.deps.status===`missing`&&n.push(`deps missing`),t.deps.status===`stale`&&n.push(`deps stale`)),`Update: ${n.join(` · `)}`}export{o as i,c as n,a as r,s as t};
