@minimax-ai/code 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +179 -164
- package/CHANGELOG.zh-CN.md +264 -0
- package/README.md +6 -3
- package/README.zh-CN.md +4 -2
- package/assets/agents/_tui/prompt-base-all.md.hbs +12 -0
- package/assets/agents/_tui/prompt-base-windows.md.hbs +45 -0
- package/assets/agents/_tui/prompt-base-worker.md.hbs +4 -0
- package/assets/agents/_tui/prompt-session-branch.md.hbs +13 -0
- package/assets/agents/_tui/prompt-session-root.md.hbs +4 -0
- package/assets/agents/mavis/tui/PERSONA-zh.md.hbs +17 -0
- package/assets/agents/mavis/tui/PERSONA.md.hbs +22 -0
- package/assets/agents/mavis/tui/SYSTEM.md.hbs +110 -0
- package/assets/agents/mavis/tui/features/delegation.md.hbs +52 -0
- package/assets/agents/mavis/tui/features/task-management.md.hbs +11 -0
- package/assets/agents/mavis/tui/features/web-search.md.hbs +7 -0
- package/chunks/{application-F5GCGMBT.js → application-VM7NETBS.js} +1 -1
- package/chunks/chunk-B7AEIYE2.js +155 -0
- package/chunks/{chunk-ZQ5NFQRA.js → chunk-BPRXRI4W.js} +467 -467
- package/chunks/chunk-C3JRMX7L.js +2 -0
- package/chunks/{chunk-VVZRUBTN.js → chunk-CSEMCTUO.js} +490 -490
- package/chunks/{chunk-3X7O237P.js → chunk-J6D4YR7Q.js} +1 -1
- package/chunks/chunk-OGKBQLFH.js +33 -0
- package/chunks/launcher-U4C3IZNL.js +231 -0
- package/chunks/{lifecycle-W7H7AQB2.js → lifecycle-KCPZFQXU.js} +1 -1
- package/chunks/{main-L3MJW47H.js → main-X4HBPBMC.js} +1 -1
- package/chunks/{plugin-command-KVTQXIBN.js → plugin-command-A5E7VOZF.js} +1 -1
- package/chunks/provider-command-MKFDOYFC.js +3 -0
- package/chunks/{run-acp-command-RJAB4GDT.js → run-acp-command-X52GQQTB.js} +1 -1
- package/chunks/{run-exec-command-KYGOLZKQ.js → run-exec-command-YNDAZGJH.js} +1 -1
- package/chunks/update-WS5F7FXU.js +15 -0
- package/cli.js +1 -1
- package/package.json +2 -1
- package/chunks/chunk-COTC5RMO.js +0 -156
- package/chunks/chunk-GWC5532O.js +0 -2
- package/chunks/launcher-UNNRDX2R.js +0 -231
- package/chunks/provider-command-NMPS5C3N.js +0 -3
- package/chunks/update-NYOPKJYL.js +0 -14
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { createRequire as __mavis_cR } from "module"; import { basename as __mavis_basename, dirname as __mavis_dirname, join as __mavis_join } from "path"; import { fileURLToPath as __mavis_fileURLToPath, pathToFileURL as __mavis_pathToFileURL } from "url"; const __mavis_tuiCurrentModuleDir = __mavis_dirname(__mavis_fileURLToPath(import.meta.url)); const __mavis_tuiPackageRoot = __mavis_basename(__mavis_tuiCurrentModuleDir) === "chunks" ? __mavis_dirname(__mavis_tuiCurrentModuleDir) : __mavis_tuiCurrentModuleDir; const __mavis_tuiPackageEntryUrl = __mavis_pathToFileURL(__mavis_join(__mavis_tuiPackageRoot, "cli.js")).href; const require = __mavis_cR(__mavis_tuiPackageEntryUrl); const __dirname = __mavis_tuiPackageRoot;
|
|
2
|
+
import{a as _e}from"./chunk-O6RIRKRN.js";import{a as j}from"./chunk-HQ2U4QVQ.js";import{e as T}from"./chunk-I7TKU4UZ.js";import{e as _}from"./chunk-D76SO2ME.js";import{createPublicKey as Te,verify as Ue}from"node:crypto";var Ie=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z][0-9A-Za-z.-]*)?$/u,Ve=/^[0-9a-f]{64}$/u,Oe=/^(?:stable|preview)$/u,De=["darwin-arm64","darwin-x64","linux-x64","windows-x64"],je=[...De,"windows-arm64"];function B(e){if(!Oe.test(e))throw new Error(`Unsupported MCode update channel: ${JSON.stringify(e)}`);return e}function v(e){if(!Ie.test(e))throw new Error(`Invalid MCode version: ${JSON.stringify(e)}`);return e}function oe(e,t,r){let n=Be(t),o=!1;try{o=Ue(null,e,Te(r),n)}catch(i){throw new Error(`MCode release signature could not be verified: ${ne(i)}`)}if(!o)throw new Error("MCode release signature verification failed.");let a;try{a=JSON.parse(Buffer.from(e).toString("utf8"))}catch(i){throw new Error(`MCode release manifest is not valid JSON: ${ne(i)}`)}return Le(a)}function Le(e){if(!L(e))throw new Error("MCode release manifest must be an object.");if(e.schemaVersion!==1)throw new Error(`Unsupported MCode release schema: ${String(e.schemaVersion)}`);if(e.product!=="minimax-code")throw new Error(`Unexpected release product: ${String(e.product)}`);let t=typeof e.channel=="string"&&/^[0-9A-Za-z][0-9A-Za-z._-]*$/u.test(e.channel)?e.channel:void 0;if(!t)throw new Error("MCode release channel is invalid.");let r=typeof e.version=="string"?v(e.version):void 0;if(!r)throw new Error("MCode release version is missing.");if(typeof e.publishedAt!="string"||!Number.isFinite(Date.parse(e.publishedAt)))throw new Error("MCode release publishedAt is invalid.");if(typeof e.minNodeVersion!="string"||!/^\d+\.\d+\.\d+$/u.test(e.minNodeVersion))throw new Error("MCode release minNodeVersion is invalid.");let n=ie(e.registry,"registry"),o=E(e.installArtifact,!0,"installArtifact");if(!L(e.targets))throw new Error("MCode release targets are missing.");let a={"darwin-arm64":E(e.targets["darwin-arm64"],!1,"targets.darwin-arm64"),"darwin-x64":E(e.targets["darwin-x64"],!1,"targets.darwin-x64"),"linux-x64":E(e.targets["linux-x64"],!1,"targets.linux-x64"),"windows-x64":E(e.targets["windows-x64"],!1,"targets.windows-x64")};return e.targets["windows-arm64"]!==void 0&&(a["windows-arm64"]=E(e.targets["windows-arm64"],!1,"targets.windows-arm64")),{schemaVersion:1,product:"minimax-code",channel:t,version:r,publishedAt:e.publishedAt,minNodeVersion:e.minNodeVersion,registry:n,installArtifact:o,targets:a}}function E(e,t,r){if(!L(e))throw new Error(`${r} is missing.`);if(typeof e.sha256!="string"||!Ve.test(e.sha256))throw new Error(`${r}.sha256 is invalid.`);if(!Number.isSafeInteger(e.size)||e.size<=0)throw new Error(`${r}.size is invalid.`);let n={sha256:e.sha256,size:e.size};return t?{...n,url:ie(e.url,`${r}.url`)}:n}function ie(e,t){if(typeof e!="string")throw new Error(`${t} must be an HTTPS URL.`);let r;try{r=new URL(e)}catch{throw new Error(`${t} must be an HTTPS URL.`)}if(r.protocol!=="https:"||r.username||r.password)throw new Error(`${t} must be an HTTPS URL without embedded credentials.`);return r.href}function Be(e){let t=e.trim();if(!/^[A-Za-z0-9+/]+={0,2}$/u.test(t))throw new Error("MCode release signature is not valid base64.");let r=Buffer.from(t,"base64");if(r.length!==64)throw new Error("MCode release signature has an invalid length.");return r}function ae(e=process.platform,t=process.arch){let r=`${e==="win32"?"windows":e}-${t}`;if(je.includes(r))return r;throw new Error(`Unsupported MCode update host: ${e}-${t}`)}function se(e,t){if(!e.targets[t])throw new Error(`MCode ${e.version} does not provide a release for ${t}.`)}function re(e){v(e);let[t="",r]=e.split("-",2);return{core:t.split(".").map(n=>Number.parseInt(n,10)),prerelease:r?r.split(".").map(n=>/^\d+$/u.test(n)?Number(n):n):[]}}function ce(e,t){let r=re(e),n=re(t);for(let a=0;a<3;a+=1){let i=(r.core[a]??0)-(n.core[a]??0);if(i!==0)return i}if(r.prerelease.length===0&&n.prerelease.length>0)return 1;if(n.prerelease.length===0&&r.prerelease.length>0)return-1;let o=Math.max(r.prerelease.length,n.prerelease.length);for(let a=0;a<o;a+=1){let i=r.prerelease[a],s=n.prerelease[a];if(i===void 0)return-1;if(s===void 0)return 1;if(i!==s)return typeof i=="number"&&typeof s=="number"?i-s:typeof i=="number"?-1:typeof s=="number"?1:i.localeCompare(s)}return 0}function L(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ne(e){return e instanceof Error?e.message:String(e)}var M=class extends Error{constructor(t="MCode update cancelled; the previous installation remains active."){super(t),this.name="McodeUpdateCancelledError"}},F=class extends Error{constructor(t){super(t),this.name="McodeUpdateAdmissionError"}};function x(e){if(e?.aborted)throw new M}function P(e,t,r){try{e.onPhase?.({phase:t,cancellable:r})}catch{}}function jt(e){return e instanceof M}function Lt(e){return e instanceof F}var he=_(j(),1),I=_(_e(),1);import{createHash as Fe}from"node:crypto";import{existsSync as U,mkdirSync as pe,readFileSync as k,renameSync as fe,rmSync as ge,writeFileSync as me}from"node:fs";import{homedir as Je}from"node:os";import m from"node:path";var ze="https://algeng-ali-shanghai-agent-02.oss-cn-shanghai.aliyuncs.com/minimax-dialogue/data/env/.npm-global/mcode",He=8e3,de=class{currentVersion;installRoot;releaseBaseUrl;publicKey;environment;dependencies;constructor(t){this.currentVersion=v(t.currentVersion),this.installRoot=t.installRoot??Ge(t.environment),this.releaseBaseUrl=(t.releaseBaseUrl??ze).replace(/\/+$/u,""),this.publicKey=t.publicKey,this.environment=t.environment??process.env,this.dependencies={fetchBytes:We,installArtifact:Ze,validateInstalledVersion:Xe,...t.dependencies}}async check(t={}){x(t.signal),P(t,"checking",!0);let r=t.channel?B(t.channel):Ke(this.installRoot),n=t.version?v(t.version):void 0,o=n?`${this.releaseBaseUrl}/releases/${encodeURIComponent(n)}/manifest.json`:`${this.releaseBaseUrl}/channels/${r}.json`,a=this.publicKey??Ye(this.installRoot,this.environment),i=le(t.timeoutMs),s=new AbortController,c=ue(t.signal,s),d=!1,l=setTimeout(()=>{d=!0,s.abort(new Error(`MCode update check timed out after ${i}ms.`))},i);l.unref?.();try{let[p,f]=await Promise.all([this.dependencies.fetchBytes(o,{signal:s.signal,proxyEnvironment:this.environment}),this.dependencies.fetchBytes(`${o}.sig`,{signal:s.signal,proxyEnvironment:this.environment})]),g=oe(p,f.toString("utf8"),a);if(!n&&g.channel!==r)throw new Error(`Signed MCode release channel mismatch: expected ${r}, got ${g.channel}.`);if(n&&g.version!==n)throw new Error(`Signed MCode release version mismatch: expected ${n}, got ${g.version}.`);se(g,ae());let y=ce(this.currentVersion,g.version);return{status:y<0?"available":y>0?"ahead":"current",channel:r,currentVersion:this.currentVersion,latestVersion:g.version,manifest:g}}catch(p){throw t.signal?.aborted?new M:d?new Error(`MCode update check timed out after ${i}ms.`,{cause:p}):p}finally{clearTimeout(l),c()}}async apply(t={}){let r=await this.check(t);if(r.status==="current")return{...r,applied:!1,installRoot:this.installRoot};if(r.status==="ahead"&&!t.version)throw new Error(`Installed MCode ${this.currentVersion} is newer than ${r.channel} ${r.latestVersion}; pass --to to downgrade explicitly.`);let n=le(t.timeoutMs);x(t.signal),P(t,"downloading",!0);let o=new AbortController,a=ue(t.signal,o),i=!1,s=setTimeout(()=>{i=!0,o.abort(new Error(`MCode artifact download timed out after ${n}ms.`))},n);s.unref?.();let c;try{c=await this.dependencies.fetchBytes(r.manifest.installArtifact.url,{signal:o.signal,proxyEnvironment:this.environment})}catch(y){throw t.signal?.aborted?new M:i?new Error(`MCode artifact download timed out after ${n}ms.`,{cause:y}):y}finally{clearTimeout(s),a()}x(t.signal),Qe(c,r.manifest);let d=m.join(this.installRoot,"versions"),l=m.join(d,r.latestVersion),p=m.join(d,`.staging-${r.latestVersion}-${process.pid}-${Date.now()}`),f=m.join(p,`minimax-mcode-${r.latestVersion}.tgz`);pe(p,{recursive:!0});let g=!1;try{return P(t,"staging",!0),x(t.signal),me(f,c,{mode:384}),x(t.signal),P(t,"installing",!1),await this.dependencies.installArtifact({artifact:f,prefix:p,registry:r.manifest.registry,proxyEnvironment:this.environment}),x(t.signal),T(()=>ge(f,{force:!0})),P(t,"validating",!1),await this.dependencies.validateInstalledVersion(p,r.latestVersion),x(t.signal),P(t,"activating",!1),U(l)?(await this.dependencies.validateInstalledVersion(l,r.latestVersion),J(p)):(T(()=>fe(p,l)),g=!0),qe(this.installRoot,r.latestVersion),P(t,"completed",!1),{...r,applied:!0,installRoot:this.installRoot}}catch(y){throw J(p),g&&et(this.installRoot)!==r.latestVersion&&J(l),y instanceof M||t.signal?.aborted?new M:new Error(`MCode ${r.latestVersion} was not activated; the previous version is unchanged: ${we(y)}`,{cause:y})}}};function Ge(e=process.env){if(e.MCODE_INSTALL_ROOT)return m.resolve(e.MCODE_INSTALL_ROOT);if(process.platform==="win32"){let r=e.LOCALAPPDATA;if(!r)throw new Error("LOCALAPPDATA is required to resolve the MCode install root.");return m.join(r,"MinimaxCode")}let t=e.XDG_DATA_HOME||m.join(Je(),".local","share");return m.join(t,"minimax-code")}function Ke(e){let t=m.join(e,"update.json");if(!U(t))return"stable";let r;try{r=JSON.parse(k(t,"utf8"))}catch(n){throw new Error(`MCode update channel config is invalid: ${we(n)}`)}if(typeof r!="object"||r===null||!("channel"in r)||typeof r.channel!="string")throw new Error("MCode update channel config is missing channel.");return B(r.channel)}function ye(e){let t=m.join(e,"install.json");try{let r=JSON.parse(k(t,"utf8"));return r.product==="minimax-code"&&r.updateOwner==="mcode-installer"}catch{return!1}}function Ye(e,t){let r=t.MCODE_RELEASE_PUBLIC_KEY_FILE;if(r)return k(m.resolve(r),"utf8");let n=m.join(e,"install.json");if(!U(n))throw new Error("MCode update trust root is missing. Install with the official Shell/PowerShell installer first.");let o=JSON.parse(k(n,"utf8"));if(typeof o.publicKey!="string"||!o.publicKey.includes("BEGIN PUBLIC KEY"))throw new Error("MCode installer metadata does not contain a valid release public key.");return o.publicKey}function le(e){if(e===void 0)return He;if(!Number.isSafeInteger(e)||e<100||e>6e4)throw new Error("MCode update timeout must be an integer between 100 and 60000 milliseconds.");return e}async function We(e,t={}){let r=new I.EnvHttpProxyAgent({httpProxy:t.proxyEnvironment?.HTTP_PROXY??t.proxyEnvironment?.http_proxy,httpsProxy:t.proxyEnvironment?.HTTPS_PROXY??t.proxyEnvironment?.https_proxy,noProxy:t.proxyEnvironment?.NO_PROXY??t.proxyEnvironment?.no_proxy});try{let n=await(0,I.fetch)(e,{signal:t.signal,dispatcher:r,redirect:"error"});if(!n.ok)throw new Error(`MCode release server returned HTTP ${n.status} for ${e}`);return Buffer.from(await n.arrayBuffer())}finally{await r.close()}}async function Ze(e){let t=process.platform==="win32"?"npm.cmd":"npm";await Me(t,["install","--global","--prefix",e.prefix,e.artifact,"--registry",e.registry,"--no-audit","--no-fund","--package-lock=false"],e.proxyEnvironment,!0)}async function Xe(e,t){let r=process.platform==="win32"?m.join(e,"mcode.cmd"):m.join(e,"bin","mcode"),n=await Me(r,["--version"],process.env,!0);if(n.trim()!==t)throw new Error(`Installed MCode version mismatch: expected ${t}, got ${n.trim()}`)}function Me(e,t,r,n=!1){return new Promise((o,a)=>{let i=!1,s=(0,he.default)(e,t,{env:r,shell:!1,stdio:n?["ignore","pipe","pipe"]:"inherit",windowsHide:!0}),c=[],d=[];s.stdout?.on("data",l=>c.push(l)),s.stderr?.on("data",l=>d.push(l)),s.once("error",l=>{i||(i=!0,a(l))}),s.once("exit",(l,p)=>{if(i)return;if(i=!0,l===0)return o(Buffer.concat(c).toString("utf8"));let f=Buffer.concat(d).toString("utf8").trim();a(new Error(`${e} failed (${p?`signal ${p}`:`exit ${String(l)}`})${f?`: ${f}`:""}`))})})}function ue(e,t){if(!e)return()=>{};let r=()=>t.abort(e.reason);return e.aborted?r():e.addEventListener("abort",r,{once:!0}),()=>e.removeEventListener("abort",r)}function Qe(e,t){if(e.length!==t.installArtifact.size)throw new Error(`MCode artifact checksum/size verification failed: expected ${t.installArtifact.size} bytes, got ${e.length}.`);if(Fe("sha256").update(e).digest("hex")!==t.installArtifact.sha256)throw new Error("MCode artifact checksum verification failed.")}function qe(e,t){pe(e,{recursive:!0});let r=m.join(e,"current"),n=`${r}.tmp-${process.pid}-${Date.now()}`;me(n,`${t}
|
|
3
|
+
`,{mode:384}),T(()=>fe(n,r))}function J(e){ge(e,{recursive:!0,force:!0,maxRetries:4,retryDelay:50})}function et(e){let t=m.join(e,"current");if(U(t))return k(t,"utf8").trim()||void 0}function we(e){return e instanceof Error?e.message:String(e)}var G=_(j(),1);import{existsSync as H,readFileSync as be,realpathSync as Ee,statSync as tt}from"node:fs";import w from"node:path";var ve="https://registry.npmjs.org/",xe="https://registry.npmjs.org/",rt="https://registry.npmmirror.com/",nt=3e4,z="code",K="@minimax",Se="@minimax-ai",ot="@minimax-ai/code";async function er(e){let t=e.platform??process.platform,r={installRoot:e.installRoot,platform:t,packageRoot:e.packageRoot??lt,npmGlobalPrefix:e.npmGlobalPrefix??(()=>Re(t==="win32"?"npm.cmd":"npm",["prefix","--global"])),managedInstall:e.managedInstall??ye,prefixInstall:e.prefixInstall??Y};if(r.managedInstall(r.installRoot))return"managed-installer";if(r.prefixInstall())return"npm-prefix";let n=r.packageRoot();if(!n)return"unsupported";let o=it(n);if(o)return o;try{return at(n,await r.npmGlobalPrefix(),t)}catch{return"unsupported"}}function it(e){let t=e.replaceAll("\\","/").toLocaleLowerCase();if(/\/pnpm\/global\/(?:v11\/[^/]+|[^/]+)\/node_modules\/@minimax(?:-ai)?\/code$/u.test(t))return"pnpm-global";if(/\/(?:\.config\/yarn|\.yarn)\/global\/node_modules\/@minimax(?:-ai)?\/code$/u.test(t))return"yarn-global";if(/\/\.bun\/install\/global\/node_modules\/@minimax(?:-ai)?\/code$/u.test(t))return"bun-global";if(/\/lib\/node_modules\/@minimax(?:-ai)?\/code$/u.test(t)||/\/npm\/node_modules\/@minimax(?:-ai)?\/code$/u.test(t))return"npm-global"}function V(e=dt()??ot,t){if(e===A(K)){let r=t?new URL(t).href:ve;if(r===ve)return{packageName:e,registry:r};throw new Error(`Unsupported MCode npm registry: ${r}`)}if(e===A(Se)){let r=t?new URL(t).href:xe;if(r===xe||r===rt)return{packageName:e,registry:r};throw new Error(`Unsupported MCode npm registry: ${r}`)}throw new Error(`Unsupported MCode npm package: ${String(e)}`)}function tr(e=st(),t=ct()){return t||(e==="test"?"test":e==="staging"?"preview":"latest")}function at(e,t,r=process.platform){let n=S(e,r),o=r==="win32"?w.win32:w.posix,a=gt(e)??A(K);return(r==="win32"?[o.join(t,"node_modules",a)]:[o.join(t,"lib","node_modules",a),o.join(t,"node_modules",a)]).some(s=>S(s,r)===n)?"npm-global":"unsupported"}function rr(e,t,r=process.platform,n=V(),o){let a=`${n.packageName}@${v(t)}`,i=["--registry",n.registry],s=`--registry ${n.registry}`;switch(e){case"npm-prefix":{if(!o)throw new Error("MCode npm prefix ownership metadata is missing.");if(o.packageName!==n.packageName||new URL(o.registry).href!==n.registry)throw new Error("MCode npm prefix ownership does not match the installed package.");return{executable:o.executable,args:["install","--global","--prefix",o.prefix,a,...i],display:`${o.executable} install --global --prefix ${o.prefix} ${a} ${s}`}}case"npm-global":return{executable:r==="win32"?"npm.cmd":"npm",args:["install","--global",a,...i],display:`npm install --global ${a} ${s}`};case"pnpm-global":return{executable:r==="win32"?"pnpm.cmd":"pnpm",args:["add","--global",a,...i],display:`pnpm add --global ${a} ${s}`};case"yarn-global":return{executable:r==="win32"?"yarn.cmd":"yarn",args:["global","add",a,...i],display:`yarn global add ${a} ${s}`};case"bun-global":return{executable:r==="win32"?"bun.exe":"bun",args:["add","--global",a,...i],display:`bun add --global ${a} ${s}`}}}async function nr(e,t={}){let r=t.platform??process.platform,n=t.distribution??V(),a=await(t.run??Re)(r==="win32"?"npm.cmd":"npm",["view",`${n.packageName}@${e}`,"version","--json","--registry",n.registry,"--fetch-timeout",String(nt)]),i;try{i=JSON.parse(a)}catch{i=a.trim()}if(Array.isArray(i)){if(i.length!==1)throw new Error("MCode registry returned an invalid latest version.");i=i[0]}if(typeof i!="string")throw new Error("MCode registry returned an invalid latest version.");let s=v(i);if(e==="latest"&&s.includes("-"))throw new Error("MCode latest must resolve to a stable semantic version.");return s}function st(){return"prod"}function ct(){return"latest"}function or(e,t=process.env,r={}){return new Promise((n,o)=>{let a=!1,i=(0,G.default)(e.executable,[...e.args],{env:t,shell:!1,stdio:["ignore","pipe","pipe"],windowsHide:!0}),s=[],c=[];i.stdout?.on("data",d=>{s.push(d),Pe(r,d)}),i.stderr?.on("data",d=>{c.push(d),Pe(r,d)}),i.once("error",d=>{a||(a=!0,o(d))}),i.once("exit",(d,l)=>{if(a)return;if(a=!0,d===0){n();return}let p=Buffer.concat([...c,...s]).toString("utf8").trim();o(new Error(`${e.executable} failed (${l?`signal ${l}`:`exit ${String(d)}`})${p?`: ${p}`:""}`))})})}function Pe(e,t){try{e.onOutput?.(t.toString("utf8"))}catch{}}function dt(e=process.argv[1]){return O(e)?.packageName}function ir(e=process.argv[1]){return O(e)?.version}function Y(e=process.argv[1],t=process.platform,r=process.execPath){let n=O(e);if(!n)return;let o=t==="win32"?w.win32:w.posix,a=o.dirname(o.dirname(n.packageRoot));if(o.basename(a).toLocaleLowerCase()!=="node_modules")return;let i=o.dirname(a),s=t!=="win32"&&o.basename(i)==="lib"?o.dirname(i):i,c=ut(s,n.packageRoot,t,o);if(c)return c.packageName!==n.packageName?void 0:c;if(o.basename(s).toLocaleLowerCase()!==".minimax-code")return;let d=o.join(o.dirname(r),t==="win32"?"npm.cmd":"npm");if(!H(d))return;let l=V(n.packageName);return{executable:d,packageName:n.packageName,prefix:s,registry:l.registry}}function lt(e=process.argv[1]){return O(e)?.packageRoot}function O(e){if(!e)return;let t;try{let r=Ee(e);t=tt(r).isDirectory()?r:w.dirname(r)}catch{return}for(;;){let r=w.join(t,"package.json");if(H(r))try{let o=JSON.parse(be(r,"utf8")),a=W(o.name);if(a)return{packageName:a,packageRoot:t,...typeof o.version=="string"?{version:o.version}:{}}}catch{return}let n=w.dirname(t);if(n===t)return;t=n}}function ut(e,t,r,n){let o=e;for(let a=0;a<3;a+=1){let i=pt(o,e,t,r,n);if(i)return i;let s=n.dirname(o);if(s===o)break;o=s}}function pt(e,t,r,n,o){try{let a=be(o.join(e,"install.json"),"utf8").replace(/^\uFEFF/u,""),i=JSON.parse(a),s=W(i.packageName),c=i.schemaVersion===1&&i.layoutVersion===void 0,d=i.schemaVersion===2&&i.layoutVersion===2&&i.releasesDirectory==="releases"&&i.currentFile==="current";if(!c&&!d||i.product!=="minimax-code"||i.updateOwner!=="npm-prefix"||i.packageManager!=="npm"||!s||typeof i.registry!="string"||i.distTag!=="latest"||typeof i.prefix!="string"||typeof i.npmExecutable!="string")return;let l=V(s,i.registry);if(S(i.prefix,n)!==S(e,n)||new URL(i.registry).href!==l.registry||!H(i.npmExecutable)||c&&S(t,n)!==S(e,n))return;if(d){let p=o.join(e,"releases"),f=o.relative(p,t);if(!f||f.startsWith("..")||o.isAbsolute(f)||f.includes(o.sep)||!/^[0-9A-Za-z][0-9A-Za-z._-]*$/u.test(f)||!ft(t,r,o))return}return{executable:i.npmExecutable,packageName:s,prefix:e,registry:l.registry}}catch{return}}function ft(e,t,r){let n=r.relative(r.resolve(e),r.resolve(t));return n!==""&&!n.startsWith("..")&&!r.isAbsolute(n)}function W(e){if(e===A(K)||e===A(Se))return e}function A(e){return`${e}/${z}`}function gt(e){let r=e.replaceAll("\\","/").split("/");if(r.at(-1)===z)return W(`${r.at(-2)}/${z}`)}function S(e,t){let r;try{r=Ee(e)}catch{r=(t==="win32"?w.win32:w.posix).resolve(e)}return t==="win32"?r.toLocaleLowerCase():r}function Re(e,t){return new Promise((r,n)=>{let o=!1,a=(0,G.default)(e,[...t],{shell:!1,stdio:["ignore","pipe","pipe"],windowsHide:!0}),i=[],s=[];a.stdout?.on("data",c=>i.push(c)),a.stderr?.on("data",c=>s.push(c)),a.once("error",c=>{o||(o=!0,n(c))}),a.once("exit",(c,d)=>{if(o)return;if(o=!0,c===0){r(Buffer.concat(i).toString("utf8").trim());return}let l=Buffer.concat([...s,...i]).toString("utf8").trim();n(new Error(`${e} failed (${d?`signal ${d}`:`exit ${String(c)}`})${l?`: ${l}`:""}`))})})}var X=_(j(),1);import{createHash as mt,randomUUID as ht}from"node:crypto";import{cpSync as dr,existsSync as h,mkdirSync as yt,readdirSync as Mt,readFileSync as C,renameSync as wt,rmSync as b,writeFileSync as D}from"node:fs";import u from"node:path";var $=".mcode-update-pending.json",Ae=".mcode-active",vt=".mcode-update-activator.json",xt=".mcode-update-activation-status.json",Pt=1,$e=1,bt=1,Et=3e4,St="MCODE_UPDATE_PARENT_PID";function Z(e,t=process.platform){let r=te(t);return t==="win32"?r.join(e,"node_modules"):r.join(e,"lib","node_modules")}function Rt(e,t,r=process.platform){return te(r).join(Z(e,r),...t.split("/"))}function Nt(e,t,r=process.platform){let n=te(r),o=r==="win32"?["mcode.cmd","mcode.ps1"]:["mcode"],a=r==="win32"?"":"bin";return o.map(i=>{let s=n.join(e,a,i);return{activePath:s,stagedPath:n.join(t,a,i),backupPath:`${s}.mcode-update-backup`}})}function pr(e,t,r=process.platform){let n=Rt(e,t,r),o=u.join(n,"package.json"),a=JSON.parse(C(o,"utf8")),i=It(a.bin);if(a.name!==t||typeof a.version!="string"||!i)throw new Error(`MCode package metadata is invalid at ${o}.`);return{packageRoot:n,version:a.version,binEntry:i}}function fr(e,t,r,n){let o=u.join(t.packageRoot,...t.binEntry.split("/"));return new Promise((a,i)=>{let s=(0,X.default)(r,[o,"--version"],{cwd:e,env:process.env,stdio:["ignore","pipe","pipe"],windowsHide:!0}),c=[],d=[];s.stdout?.on("data",l=>c.push(l)),s.stderr?.on("data",l=>d.push(l)),s.once("error",i),s.once("exit",(l,p)=>{let f=Buffer.concat(c).toString("utf8").trim();if(l===0&&f===n)return a();let g=Buffer.concat(d).toString("utf8").trim()||f;i(new Error(`Staged MCode validation failed (${p?`signal ${p}`:`exit ${String(l)}`})${g?`: ${g}`:""}`))})})}async function kt(e,t=process.execPath,r=process.pid,n=[],o=process.env,a=process.cwd()){let{contents:i,pending:s}=ee(e);if(u.resolve(e)!==u.resolve(s.activePrefix,$))throw new Error(`MCode pending update file is outside its active prefix: ${e}`);let c=mt("sha256").update(i).digest("hex"),d=u.join(s.activePrefix,vt);if(!Ct(d,c))return;let l=u.join(s.activePrefix,".mcode-update-activator.cjs");try{ke(s.activePrefix,c,"scheduled"),D(l,Vt(),{mode:448});let p=(0,X.default)(t,[l,e,c,String(r),a,...n],{cwd:s.activePrefix,env:o,detached:!0,stdio:n.length>0?"inherit":"ignore",windowsHide:!0});await new Promise((f,g)=>{p.once("error",g),p.once("spawn",f)}),p.unref()}catch(p){try{ke(s.activePrefix,c,"failed",p)}catch{}throw _t(d,c,process.pid),p}}async function gr(e=process.argv[1],t=process.execPath,r=process.pid,n=[],o=process.env){let a=q(e);if(!a)return!1;let i=u.join(a,$);return h(i)?(await kt(i,t,r,n,o),!0):!1}function mr(e){b(e,{recursive:!0,force:!0,maxRetries:4,retryDelay:50})}function hr(e=process.argv[1]){let t=q(e);if(!t)return;let r=u.join(t,$);if(!h(r))return;let{pending:n}=ee(r);if(u.resolve(r)!==u.resolve(n.activePrefix,$))throw new Error(`MCode pending update file is outside its active prefix: ${r}`);let o=At(n);if(!o)throw new Error(`MCode pending update artifacts are incomplete at ${r}.`);return{pendingFile:r,activation:n,state:o}}function At(e){if(e.launchers.length===0)return;if(Ne(e.activeModulesRoot,e.packageName,e.expectedVersion)&&e.launchers.every(o=>h(o.activePath)||h(o.stagedPath)))return"activated";if(!Ne(e.stagedModulesRoot,e.packageName,e.expectedVersion))return;let n=h(e.backupModulesRoot);return e.launchers.every(o=>h(o.stagedPath)||n&&h(o.activePath)&&h(o.backupPath))?"staged":void 0}function Ne(e,t,r){try{let n=JSON.parse(C(u.join(e,...t.split("/"),"package.json"),"utf8"));return n.name===t&&n.version===r}catch{return!1}}async function yr(e=process.argv[1],t=process.env){let r=Number(t[St]);return Number.isSafeInteger(r)&&r>0&&await $t(r),{remove:Tt(e)??(()=>{})}}async function $t(e){let t=Date.now()+Et;for(;Q(e);){if(Date.now()>=t)throw new Error(`MCode restart waited too long for parent process ${e} to exit.`);await new Promise(r=>setTimeout(r,100))}}function Q(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function Ct(e,t){for(let r=0;r<3;r+=1){let n={schemaVersion:$e,journalDigest:t,pid:process.pid,startedAtMs:Date.now()};try{return D(e,`${JSON.stringify(n)}
|
|
4
|
+
`,{flag:"wx",mode:384}),!0}catch(a){if(a.code!=="EEXIST")throw a}let o=Ce(e);if(o&&Q(o.pid)){if(o.journalDigest===t)return!1;throw new Error("Another MCode prefix activator is running for a different journal.")}b(e,{force:!0})}throw new Error(`MCode prefix activator lease could not be acquired at ${e}.`)}function Ce(e){try{let t=JSON.parse(C(e,"utf8"));return t.schemaVersion!==$e||typeof t.journalDigest!="string"||!Number.isSafeInteger(t.pid)||(t.pid??0)<=0||typeof t.startedAtMs!="number"?void 0:t}catch{return}}function _t(e,t,r){let n=Ce(e);n?.journalDigest!==t||n.pid!==r||b(e,{force:!0})}function ke(e,t,r,n){let o=u.join(e,xt),a=`${o}.tmp-${process.pid}-${ht()}`,i=n instanceof Error?n.message:n===void 0?void 0:String(n),s={schemaVersion:bt,journalDigest:t,state:r,updatedAtMs:Date.now(),...i?{error:i.slice(0,2e3)}:{}};try{D(a,`${JSON.stringify(s)}
|
|
5
|
+
`,{mode:384}),b(o,{force:!0}),wt(a,o)}catch(c){throw b(a,{force:!0}),c}}function Tt(e=process.argv[1]){let t=q(e);if(!t)return;let r=u.join(t,Ae);yt(r,{recursive:!0,mode:448});let n=u.join(r,`${process.pid}.json`),o=!1,a=()=>b(n,{force:!0}),i=()=>{o||(o=!0,process.off("exit",a),b(n,{force:!0}))};return D(n,`${JSON.stringify({pid:process.pid,startedAtMs:Date.now()})}
|
|
6
|
+
`,{mode:384}),process.once("exit",a),i}function Mr(e,t=process.pid){let r=u.join(e,Ae);if(!h(r))return 0;let n;try{n=Mt(r)}catch{return}let o=0;for(let a of n){if(!a.endsWith(".json"))continue;let i=Number(a.slice(0,-5));if(!(!Number.isSafeInteger(i)||i<=0||i===t)){if(Q(i)){o+=1;continue}try{b(u.join(r,a),{force:!0})}catch{}}}return o}function q(e){if(!e)return;try{let r=Y(e);if(r)return r.prefix}catch{}let t=u.dirname(e);for(;;){let r=u.join(t,"install.json");if(h(r))try{let a=JSON.parse(C(r,"utf8"));if(a.updateOwner==="npm-prefix"&&typeof a.prefix=="string")return a.prefix}catch{return}let n=u.join(t,$);if(h(n))try{let a=Ut(n);return u.resolve(a.activePrefix)===u.resolve(t)?a.activePrefix:void 0}catch{return}let o=u.dirname(t);if(o===t)return;t=o}}function Ut(e){return ee(e).pending}function ee(e){let t=C(e,"utf8"),r=JSON.parse(t);if(r.schemaVersion!==Pt||typeof r.activePrefix!="string"||typeof r.stagingPrefix!="string"||typeof r.activeModulesRoot!="string"||typeof r.stagedModulesRoot!="string"||typeof r.backupModulesRoot!="string"||r.packageName!=="@minimax-ai/code"&&r.packageName!=="@minimax-ai/code"||typeof r.expectedVersion!="string"||!Array.isArray(r.launchers)||!r.launchers.every(s=>s!==null&&typeof s=="object"&&"activePath"in s&&typeof s.activePath=="string"&&"stagedPath"in s&&typeof s.stagedPath=="string"&&"backupPath"in s&&typeof s.backupPath=="string"))throw new Error(`MCode pending update metadata is invalid at ${e}.`);let n=r,o=Z(n.activePrefix,process.platform),a=Z(n.stagingPrefix,process.platform),i=Nt(n.activePrefix,n.stagingPrefix,process.platform);if(u.resolve(n.activePrefix)===u.resolve(n.stagingPrefix)||!N(n.activeModulesRoot,o)||!N(n.stagedModulesRoot,a)||!N(n.backupModulesRoot,`${o}.mcode-update-backup`)||n.launchers.length!==i.length||n.launchers.some((s,c)=>{let d=i[c];return!d||!N(s.activePath,d.activePath)||!N(s.stagedPath,d.stagedPath)||!N(s.backupPath,d.backupPath)})||!R(n.activePrefix,n.activeModulesRoot)||!R(n.activePrefix,n.backupModulesRoot)||!R(n.stagingPrefix,n.stagedModulesRoot)||n.launchers.some(s=>!R(n.activePrefix,s.activePath)||!R(n.activePrefix,s.backupPath)||!R(n.stagingPrefix,s.stagedPath)))throw new Error(`MCode pending update paths are invalid at ${e}.`);return{contents:t,pending:n}}function R(e,t){let r=u.relative(u.resolve(e),u.resolve(t));return r!==""&&!r.startsWith("..")&&!u.isAbsolute(r)}function N(e,t){return u.resolve(e)===u.resolve(t)}function te(e){return e==="win32"?u.win32:u.posix}function It(e){let t=typeof e=="string"?e:e&&typeof e=="object"&&"mcode"in e?e.mcode:void 0;if(typeof t!="string"||!t.trim())return;let r=t.replaceAll("\\","/").replace(/^\.\//u,"");if(!(r.startsWith("/")||r.split("/").some(n=>n==="..")))return r}function Vt(){return String.raw`'use strict';
|
|
7
|
+
const fs = require('node:fs');
|
|
8
|
+
const path = require('node:path');
|
|
9
|
+
const cp = require('node:child_process');
|
|
10
|
+
const crypto = require('node:crypto');
|
|
11
|
+
const pendingFile = process.argv[2];
|
|
12
|
+
const pendingDigest = process.argv[3];
|
|
13
|
+
const parentPid = Number(process.argv[4]);
|
|
14
|
+
const restartCwd = process.argv[5];
|
|
15
|
+
const restartArgs = process.argv.slice(6);
|
|
16
|
+
const pendingContents = fs.readFileSync(pendingFile, 'utf8');
|
|
17
|
+
if (crypto.createHash('sha256').update(pendingContents).digest('hex') !== pendingDigest) throw new Error('MCode pending update journal changed after scheduling.');
|
|
18
|
+
const pending = JSON.parse(pendingContents);
|
|
19
|
+
const leaseFile = path.join(pending.activePrefix, '.mcode-update-activator.json');
|
|
20
|
+
const statusFile = path.join(pending.activePrefix, '.mcode-update-activation-status.json');
|
|
21
|
+
fs.writeFileSync(leaseFile, JSON.stringify({ schemaVersion: 1, journalDigest: pendingDigest, pid: process.pid, startedAtMs: Date.now() }) + '\n', { mode: 0o600 });
|
|
22
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
23
|
+
const alive = (pid) => { try { process.kill(pid, 0); return true; } catch (error) { return error && error.code === 'EPERM'; } };
|
|
24
|
+
const remove = (target) => { try { fs.rmSync(target, { recursive: true, force: true, maxRetries: 8, retryDelay: 100 }); } catch {} };
|
|
25
|
+
const writeStatus = (state, error) => {
|
|
26
|
+
const temporaryFile = statusFile + '.tmp-' + process.pid;
|
|
27
|
+
const errorMessage = error === undefined ? undefined : String(error && error.message || error).slice(0, 2000);
|
|
28
|
+
try {
|
|
29
|
+
fs.writeFileSync(temporaryFile, JSON.stringify({ schemaVersion: 1, journalDigest: pendingDigest, state, updatedAtMs: Date.now(), ...(errorMessage ? { error: errorMessage } : {}) }) + '\n', { mode: 0o600 });
|
|
30
|
+
fs.rmSync(statusFile, { force: true });
|
|
31
|
+
fs.renameSync(temporaryFile, statusFile);
|
|
32
|
+
} catch {
|
|
33
|
+
remove(temporaryFile);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
// The pending journal is durable. Keep the detached handoff alive until every process using the
|
|
37
|
+
// old prefix exits; a TUI-owned Runtime or another MCode session may legitimately take over 30s.
|
|
38
|
+
async function waitForExit(pid) {
|
|
39
|
+
while (alive(pid)) await sleep(100);
|
|
40
|
+
}
|
|
41
|
+
async function waitForMarkers() {
|
|
42
|
+
const directory = path.join(pending.activePrefix, '.mcode-active');
|
|
43
|
+
for (;;) {
|
|
44
|
+
const blockers = fs.existsSync(directory) ? fs.readdirSync(directory).filter((name) => name.endsWith('.json')).filter((name) => {
|
|
45
|
+
const pid = Number(name.slice(0, -5));
|
|
46
|
+
if (!Number.isSafeInteger(pid) || pid <= 0 || pid === process.pid) return false;
|
|
47
|
+
if (alive(pid)) return true;
|
|
48
|
+
try { fs.rmSync(path.join(directory, name), { force: true }); } catch {}
|
|
49
|
+
return false;
|
|
50
|
+
}) : [];
|
|
51
|
+
if (blockers.length === 0) return;
|
|
52
|
+
await sleep(100);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function recoverInterrupted() {
|
|
56
|
+
const activeVersion = (() => {
|
|
57
|
+
try {
|
|
58
|
+
return JSON.parse(fs.readFileSync(path.join(pending.activeModulesRoot, ...pending.packageName.split('/'), 'package.json'), 'utf8')).version;
|
|
59
|
+
} catch { return undefined; }
|
|
60
|
+
})();
|
|
61
|
+
if (activeVersion === pending.expectedVersion) {
|
|
62
|
+
const launchers = pending.launchers || [];
|
|
63
|
+
const canCompleteLaunchers = launchers.every((launcher) => fs.existsSync(launcher.activePath) || fs.existsSync(launcher.stagedPath));
|
|
64
|
+
if (canCompleteLaunchers) {
|
|
65
|
+
for (const launcher of launchers) {
|
|
66
|
+
if (!fs.existsSync(launcher.activePath)) fs.renameSync(launcher.stagedPath, launcher.activePath);
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!fs.existsSync(pending.backupModulesRoot)) return false;
|
|
72
|
+
if (fs.existsSync(pending.activeModulesRoot)) {
|
|
73
|
+
if (!fs.existsSync(pending.stagedModulesRoot)) fs.renameSync(pending.activeModulesRoot, pending.stagedModulesRoot);
|
|
74
|
+
else remove(pending.activeModulesRoot);
|
|
75
|
+
}
|
|
76
|
+
fs.renameSync(pending.backupModulesRoot, pending.activeModulesRoot);
|
|
77
|
+
for (const launcher of pending.launchers || []) {
|
|
78
|
+
if (!fs.existsSync(launcher.backupPath)) continue;
|
|
79
|
+
if (fs.existsSync(launcher.activePath)) {
|
|
80
|
+
if (!fs.existsSync(launcher.stagedPath)) fs.renameSync(launcher.activePath, launcher.stagedPath);
|
|
81
|
+
else remove(launcher.activePath);
|
|
82
|
+
}
|
|
83
|
+
fs.renameSync(launcher.backupPath, launcher.activePath);
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
function cleanup() {
|
|
88
|
+
remove(pending.backupModulesRoot);
|
|
89
|
+
for (const launcher of pending.launchers || []) remove(launcher.backupPath);
|
|
90
|
+
fs.rmSync(pendingFile, { force: true });
|
|
91
|
+
remove(pending.stagingPrefix);
|
|
92
|
+
remove(path.join(pending.activePrefix, '.mcode-update-activator.cjs'));
|
|
93
|
+
remove(leaseFile);
|
|
94
|
+
}
|
|
95
|
+
async function activate() {
|
|
96
|
+
const alreadyActivated = await recoverInterrupted();
|
|
97
|
+
const restart = (args) => new Promise((resolve, reject) => {
|
|
98
|
+
if (args.length === 0) return resolve();
|
|
99
|
+
const child = cp.spawn(process.execPath, args, {
|
|
100
|
+
cwd: restartCwd, env: process.env, detached: true, stdio: 'inherit', windowsHide: false,
|
|
101
|
+
});
|
|
102
|
+
child.once('error', reject);
|
|
103
|
+
child.once('spawn', () => { child.unref(); resolve(); });
|
|
104
|
+
});
|
|
105
|
+
if (alreadyActivated) {
|
|
106
|
+
await restart(restartArgs);
|
|
107
|
+
writeStatus('completed');
|
|
108
|
+
cleanup();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const launchers = pending.launchers || [];
|
|
112
|
+
let modulesMoved = false;
|
|
113
|
+
const moved = [];
|
|
114
|
+
const installed = [];
|
|
115
|
+
try {
|
|
116
|
+
const stagedManifest = JSON.parse(fs.readFileSync(path.join(pending.stagedModulesRoot, ...pending.packageName.split('/'), 'package.json'), 'utf8'));
|
|
117
|
+
if (stagedManifest.name !== pending.packageName || stagedManifest.version !== pending.expectedVersion) throw new Error('Staged MCode package identity or version is invalid.');
|
|
118
|
+
if (launchers.some((launcher) => !fs.existsSync(launcher.stagedPath))) throw new Error('Staged MCode launcher is missing.');
|
|
119
|
+
fs.renameSync(pending.activeModulesRoot, pending.backupModulesRoot);
|
|
120
|
+
modulesMoved = true;
|
|
121
|
+
for (const launcher of launchers) { if (fs.existsSync(launcher.activePath)) { fs.renameSync(launcher.activePath, launcher.backupPath); moved.push(launcher); } }
|
|
122
|
+
fs.renameSync(pending.stagedModulesRoot, pending.activeModulesRoot);
|
|
123
|
+
for (const launcher of launchers) { if (fs.existsSync(launcher.stagedPath)) { fs.renameSync(launcher.stagedPath, launcher.activePath); installed.push(launcher); } }
|
|
124
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(pending.activeModulesRoot, ...pending.packageName.split('/'), 'package.json'), 'utf8'));
|
|
125
|
+
if (manifest.name !== pending.packageName || manifest.version !== pending.expectedVersion) throw new Error('Activated MCode package identity or version is invalid.');
|
|
126
|
+
await restart(restartArgs);
|
|
127
|
+
writeStatus('completed');
|
|
128
|
+
cleanup();
|
|
129
|
+
} catch (error) {
|
|
130
|
+
try {
|
|
131
|
+
if (modulesMoved) {
|
|
132
|
+
if (fs.existsSync(pending.activeModulesRoot)) {
|
|
133
|
+
if (!fs.existsSync(pending.stagedModulesRoot)) fs.renameSync(pending.activeModulesRoot, pending.stagedModulesRoot);
|
|
134
|
+
else remove(pending.activeModulesRoot);
|
|
135
|
+
}
|
|
136
|
+
if (fs.existsSync(pending.backupModulesRoot)) fs.renameSync(pending.backupModulesRoot, pending.activeModulesRoot);
|
|
137
|
+
}
|
|
138
|
+
for (const launcher of installed) { if (fs.existsSync(launcher.activePath)) { if (!fs.existsSync(launcher.stagedPath)) fs.renameSync(launcher.activePath, launcher.stagedPath); else remove(launcher.activePath); } }
|
|
139
|
+
for (const launcher of moved) if (fs.existsSync(launcher.backupPath)) fs.renameSync(launcher.backupPath, launcher.activePath);
|
|
140
|
+
} catch (rollbackError) {
|
|
141
|
+
process.stderr.write(String(rollbackError && rollbackError.stack || rollbackError) + '\\n');
|
|
142
|
+
}
|
|
143
|
+
writeStatus('failed', error);
|
|
144
|
+
process.stderr.write(String(error && error.stack || error) + '\\n');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
(async () => {
|
|
148
|
+
writeStatus('waiting-parent');
|
|
149
|
+
await waitForExit(parentPid);
|
|
150
|
+
writeStatus('waiting-processes');
|
|
151
|
+
await waitForMarkers();
|
|
152
|
+
writeStatus('activating');
|
|
153
|
+
await activate();
|
|
154
|
+
})().catch((error) => { writeStatus('failed', error); process.stderr.write(String(error && error.stack || error) + '\n'); process.exitCode = 1; });
|
|
155
|
+
`}export{ce as a,F as b,P as c,jt as d,Lt as e,de as f,Ge as g,er as h,V as i,tr as j,rr as k,nr as l,or as m,ir as n,Y as o,pr as p,fr as q,gr as r,mr as s,hr as t,yr as u,Mr as v};
|