@minimax-ai/code 0.6.4 → 0.6.5

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.
Files changed (27) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/CHANGELOG.zh-CN.md +10 -0
  3. package/README.zh-CN.md +1 -0
  4. package/chunks/{application-YV6I5PN3.js → application-ZJ5NM3DF.js} +1 -1
  5. package/chunks/{auth-command-F6CMS6YE.js → auth-command-OLQL7FZY.js} +1 -1
  6. package/chunks/{chunk-RWMY26JX.js → chunk-2XPMNZVR.js} +519 -518
  7. package/chunks/{chunk-LOIYR2RZ.js → chunk-37SOT72H.js} +1 -1
  8. package/chunks/{chunk-Z4VKGZFA.js → chunk-3FETZOUF.js} +30 -30
  9. package/chunks/{chunk-IBPQKAN6.js → chunk-JIWEZSQY.js} +676 -676
  10. package/chunks/{chunk-C2QIYD6E.js → chunk-JL7ZXU6T.js} +1 -1
  11. package/chunks/{chunk-77TNCP5I.js → chunk-LM3FMMAB.js} +1 -1
  12. package/chunks/{chunk-OQ7HN3XJ.js → chunk-LQIEYG3O.js} +1 -1
  13. package/chunks/{chunk-AQ73XBVZ.js → chunk-NFVRVRCL.js} +1 -1
  14. package/chunks/{chunk-DKHGVKVS.js → chunk-OSA3A5UV.js} +1 -1
  15. package/chunks/{chunk-AVYSGYVY.js → chunk-TWO6GIVD.js} +1 -1
  16. package/chunks/{data-dir-U4LWH2QP.js → data-dir-KFZIXVT7.js} +1 -1
  17. package/chunks/{dist-KNYBCP4F.js → dist-PBZ5PIWM.js} +1 -1
  18. package/chunks/{launcher-74Z5T4C2.js → launcher-BK5UP7KA.js} +87 -87
  19. package/chunks/{lifecycle-ADITN7NX.js → lifecycle-RMTLVDXY.js} +1 -1
  20. package/chunks/{main-WKTFLQ4A.js → main-ANJ6TEDF.js} +2 -2
  21. package/chunks/{plugin-command-7PC7EX65.js → plugin-command-AXB4A2DP.js} +1 -1
  22. package/chunks/{provider-command-JWWVMDYX.js → provider-command-2MVBCAF6.js} +1 -1
  23. package/chunks/{run-acp-command-AAHBRZ4K.js → run-acp-command-4JFNMYRS.js} +2 -2
  24. package/chunks/{run-exec-command-HGDHDSXT.js → run-exec-command-SAUHM46S.js} +1 -1
  25. package/chunks/{update-X4G4FEY3.js → update-HOQ5YQFF.js} +1 -1
  26. package/cli.js +2 -2
  27. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
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{Aa as re,a as Te,ia as ne,za as ie}from"./chunk-AVYSGYVY.js";import{c as oe}from"./chunk-Z4VKGZFA.js";import{e as Se}from"./chunk-D76SO2ME.js";var u="mcode-public",c=["agent.default"],p="agent-backend";var Me={cn:{dev:"https://account.minimax.cn",test:"https://account.minimax.cn",staging:"https://account.minimax.cn",prod:"https://account.minimax.cn"},en:{dev:"https://account.minimax.io",test:"https://account.minimax.io",staging:"https://account.minimax.io",prod:"https://account.minimax.io"}};function Mt(t,e){if([t.MCODE_OAUTH_DEVICE_AUTHORIZATION_ENDPOINT,t.MCODE_OAUTH_TOKEN_ENDPOINT,t.MCODE_OAUTH_REVOCATION_ENDPOINT].every(s=>!s?.trim())){let s=Me[e.region][e.buildEnv];return{deviceAuthorizationEndpoint:`${s}/oauth2/device/code`,...se(e.buildEnv),tokenEndpoint:`${s}/oauth2/token`,revocationEndpoint:`${s}/oauth2/revoke`}}let i=H(t.MCODE_OAUTH_DEVICE_AUTHORIZATION_ENDPOINT),r=H(t.MCODE_OAUTH_TOKEN_ENDPOINT),o=H(t.MCODE_OAUTH_REVOCATION_ENDPOINT);if(!i||!r||!o)throw new TypeError("Shared MCode OAuth requires all three public OAuth endpoints to be configured.");return{deviceAuthorizationEndpoint:i,...se(e.buildEnv),tokenEndpoint:r,revocationEndpoint:o}}function se(t){return t==="staging"?{deviceAuthorizationHeaders:{"X-User-Pre":"1"}}:{}}function H(t){if(t?.trim())try{let e=new URL(t);return e.protocol!=="https:"||e.username||e.password||e.hash?void 0:e.toString()}catch{return}}import{randomUUID as $}from"node:crypto";import{watchFile as Ke,unwatchFile as $e}from"node:fs";var ce=Se(Te(),1);import{open as be}from"node:fs/promises";import{chmod as ae,mkdir as Ie,open as Ce,rename as Oe,unlink as ke}from"node:fs/promises";import{dirname as Pe}from"node:path";async function O(t){await Ie(t,{recursive:!0,mode:448}),process.platform!=="win32"&&await ae(t,448)}async function b(t,e){let n=Pe(t);await O(n);let i=`${t}.${process.pid}.${Date.now()}.tmp`,r=await Ce(i,"wx",384);try{await r.writeFile(e,{encoding:"utf8"}),await r.sync()}finally{await r.close()}try{process.platform!=="win32"&&await ae(i,384),await Oe(i,t)}catch(o){throw await ke(i).catch(()=>{}),o}}import{dirname as xe}from"node:path";var w=class{lockPath;staleMs;retries;constructor(e,n={}){this.lockPath=e,this.staleMs=n.staleMs??3e4,this.retries=n.retries??120}async withLock(e){await O(xe(this.lockPath)),await(await be(this.lockPath,"a",384)).close();let i,r=await ce.default.lock(this.lockPath,{realpath:!1,stale:this.staleMs,retries:{retries:this.retries,factor:1.15,minTimeout:5,maxTimeout:250},onCompromised:o=>{i??=o}});try{return await e()}finally{try{await r()}catch(o){if(!i)throw o}if(i)throw i}}};import{createHash as Re,randomBytes as Ne}from"node:crypto";var Ue="urn:ietf:params:oauth:grant-type:device_code",l=class extends Error{code;httpStatus;constructor(e,n,i){super(n??`The OAuth server rejected the request (${e}${i?`, HTTP ${i}`:""}).`),this.code=e,this.httpStatus=i,this.name="OAuthProtocolError"}},j=class{options;fetchImpl;sleep;now;constructor(e){this.options=e,this.fetchImpl=e.fetchImpl??fetch,this.sleep=e.sleep??(n=>new Promise(i=>setTimeout(i,n))),this.now=e.now??Date.now}async startDeviceAuthorization(e={}){let n=Ne(32).toString("base64url"),i=Re("sha256").update(n,"ascii").digest("base64url"),r=await this.postForm(this.options.deviceAuthorizationEndpoint,{client_id:u,scope:c.join(" "),audience:p,code_challenge:i,code_challenge_method:"S256"},{headers:this.options.deviceAuthorizationHeaders,signal:e.signal}),o=d(r,"user_code"),s=d(r,"device_code"),a=R(r,"expired_in"),h=!s&&!!o&&a!==void 0,C=s??(h?o:void 0),B=d(r,"verification_uri")??d(r,"verification_url"),te=R(r,"expires_in")??ze(a,this.now()),V=R(r,"interval"),Ae=h&&V!==void 0?V/1e3:V??5;if(!C||!o||!B||!te)throw new l("invalid_device_authorization_response");return{deviceCode:C,codeVerifier:n,...h?{tokenPollingParameter:"user_code"}:{},userCode:o,verificationUri:B,...d(r,"verification_uri_complete")||h?{verificationUriComplete:d(r,"verification_uri_complete")??B}:{},expiresInSec:te,intervalSec:Ae}}async pollDeviceToken(e,n={}){let i=this.now()+e.expiresInSec*1e3,r=e.intervalSec*1e3;for(;this.now()<i;){n.signal?.throwIfAborted();let o=e.tokenPollingParameter==="user_code"?{user_code:e.userCode}:{device_code:e.deviceCode},s=await this.postFormAllowOAuthError(this.options.tokenEndpoint,{grant_type:Ue,...o,client_id:u,code_verifier:e.codeVerifier},{signal:n.signal}),a=d(s.body,"status");if(s.ok&&a==="pending"){await x(this.sleep,r,n.signal);continue}if(s.ok&&a==="slow_down"){r+=5e3,await x(this.sleep,r,n.signal);continue}if(s.ok&&(a==="denied"||a==="access_denied"))throw new l("access_denied");if(s.ok&&(a==="expired"||a==="expired_token"))throw new l("expired_token");if(s.ok)return de(s.body);if(s.error==="authorization_pending"){await x(this.sleep,r,n.signal);continue}if(s.error==="slow_down"){r+=5e3,await x(this.sleep,r,n.signal);continue}throw new l(s.error??"device_authorization_failed",void 0,s.status)}throw new l("expired_token","The OAuth device authorization expired.")}async refreshToken(e){let n=await this.postForm(this.options.tokenEndpoint,{grant_type:"refresh_token",refresh_token:e,client_id:u,scope:c.join(" "),audience:p});return de(n,e)}async revokeToken(e){let n=await this.postFormAllowOAuthError(this.options.revocationEndpoint,{token:e,token_type_hint:"refresh_token",client_id:u},{allowEmptySuccess:!0});if(!n.ok)throw new l(n.error??"oauth_request_failed",void 0,n.status)}async postForm(e,n,i={}){let r=await this.postFormAllowOAuthError(e,n,i);if(!r.ok)throw new l(r.error??"oauth_request_failed",void 0,r.status);return r.body}async postFormAllowOAuthError(e,n,i={}){let r=await this.fetchImpl(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded",...i.headers},body:new URLSearchParams(n),signal:i.signal}),o=N(await r.json().catch(()=>{}));if(!o&&r.ok&&i.allowEmptySuccess)return{ok:!0,status:r.status,body:{}};if(!o)throw new l("invalid_json_response",void 0,r.status);let s=d(o,"error");return{ok:r.ok&&!s,status:r.status,body:o,...s?{error:s}:{}}}};async function x(t,e,n){if(!n){await t(e);return}n.throwIfAborted();let i,r=()=>i(n.reason),o=new Promise((s,a)=>{i=a});n.addEventListener("abort",r,{once:!0});try{await Promise.race([t(e),o])}finally{n.removeEventListener("abort",r)}}function de(t,e){let n=d(t,"access_token"),i=d(t,"refresh_token")??e,r=d(t,"token_type"),o=R(t,"expires_in"),s=n?De(n):void 0,a=Le(t.scope??s?.scope??s?.scp);if(!n||!i||r?.toLowerCase()!=="bearer"||!o||!a.includes(c[0]))throw new l("invalid_token_response");return{accessToken:n,refreshToken:i,tokenType:"Bearer",scopes:a,audience:p,expiresInSec:o,...d(s,"sub")?{subject:d(s,"sub")}:{},...d(s,"account_id")?{accountId:d(s,"account_id")}:{}}}function De(t){let e=t.split(".");if(!(e.length!==3||!e[1]))try{return N(JSON.parse(Buffer.from(e[1],"base64url").toString("utf8")))}catch{return}}function Le(t){return typeof t=="string"?t.split(/\s+/u).filter(Boolean):Array.isArray(t)&&t.every(e=>typeof e=="string")?t:[]}function N(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}function d(t,e){let i=N(t)?.[e];return typeof i=="string"&&i.trim()?i.trim():void 0}function R(t,e){let i=N(t)?.[e];return typeof i=="number"&&Number.isFinite(i)&&i>0?i:void 0}function ze(t,e){if(t===void 0)return;if(t<1e12)return t;let n=t-e;return n>0?Math.ceil(n/1e3):void 0}import{readFile as Be}from"node:fs/promises";var E=2,Ve=1,He=/access[_-]?token|refresh[_-]?token|device[_-]?code|code[_-]?verifier/iu;function he(t){if(!(typeof t!="object"||t===null))for(let[e,n]of Object.entries(t)){if(He.test(e))throw new TypeError("Sensitive OAuth fields cannot be persisted in auth-state.json.");he(n)}}function ue(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError("Invalid OAuth state.");let e=t;if(!(typeof e.schemaVersion=="number"&&Number.isInteger(e.schemaVersion)&&e.schemaVersion>=Ve&&e.schemaVersion<=E&&["anonymous","authorizing","authenticated","refreshing","scope_upgrade_required","logging_out","logout_pending","expired","error"].includes(e.status)&&(e.schemaVersion===1&&(e.storeKind==="os-keyring"||e.storeKind==="file")||e.schemaVersion===E&&e.storeKind==="file")&&e.clientId==="mcode-public"&&Array.isArray(e.scopes)&&e.scopes.every(i=>typeof i=="string")&&e.audience==="agent-backend"&&je(e.buildEnv,e.region)&&(e.expiresAtMs===void 0||typeof e.expiresAtMs=="number"&&Number.isFinite(e.expiresAtMs))&&Number.isSafeInteger(e.generation)&&e.generation>=0&&(e.authorization===void 0||Fe(e.authorization))))throw new TypeError("Invalid OAuth state.");return he(e),e}function je(t,e){return t===void 0&&e===void 0?!0:(t==="dev"||t==="test"||t==="staging"||t==="prod")&&(e==="cn"||e==="en")}function Fe(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=t;return typeof e.leaseId=="string"&&e.leaseId.length>0&&typeof e.leaseExpiresAtMs=="number"&&Number.isFinite(e.leaseExpiresAtMs)&&F(e.userCode)&&F(e.verificationUri)&&F(e.verificationUriComplete)}function F(t){return t===void 0||typeof t=="string"}var y=class{path;constructor(e){this.path=e}async read(){let e;try{e=await Be(this.path,"utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}try{return ue(JSON.parse(e))}catch(n){throw n instanceof TypeError?n:new TypeError("Invalid OAuth state.")}}async write(e){let n=ue(e);await b(this.path,`${JSON.stringify(n,null,2)}
2
+ import{Aa as re,a as Te,ia as ne,za as ie}from"./chunk-TWO6GIVD.js";import{c as oe}from"./chunk-3FETZOUF.js";import{e as Se}from"./chunk-D76SO2ME.js";var u="mcode-public",c=["agent.default"],p="agent-backend";var Me={cn:{dev:"https://account.minimax.cn",test:"https://account.minimax.cn",staging:"https://account.minimax.cn",prod:"https://account.minimax.cn"},en:{dev:"https://account.minimax.io",test:"https://account.minimax.io",staging:"https://account.minimax.io",prod:"https://account.minimax.io"}};function Mt(t,e){if([t.MCODE_OAUTH_DEVICE_AUTHORIZATION_ENDPOINT,t.MCODE_OAUTH_TOKEN_ENDPOINT,t.MCODE_OAUTH_REVOCATION_ENDPOINT].every(s=>!s?.trim())){let s=Me[e.region][e.buildEnv];return{deviceAuthorizationEndpoint:`${s}/oauth2/device/code`,...se(e.buildEnv),tokenEndpoint:`${s}/oauth2/token`,revocationEndpoint:`${s}/oauth2/revoke`}}let i=H(t.MCODE_OAUTH_DEVICE_AUTHORIZATION_ENDPOINT),r=H(t.MCODE_OAUTH_TOKEN_ENDPOINT),o=H(t.MCODE_OAUTH_REVOCATION_ENDPOINT);if(!i||!r||!o)throw new TypeError("Shared MCode OAuth requires all three public OAuth endpoints to be configured.");return{deviceAuthorizationEndpoint:i,...se(e.buildEnv),tokenEndpoint:r,revocationEndpoint:o}}function se(t){return t==="staging"?{deviceAuthorizationHeaders:{"X-User-Pre":"1"}}:{}}function H(t){if(t?.trim())try{let e=new URL(t);return e.protocol!=="https:"||e.username||e.password||e.hash?void 0:e.toString()}catch{return}}import{randomUUID as $}from"node:crypto";import{watchFile as Ke,unwatchFile as $e}from"node:fs";var ce=Se(Te(),1);import{open as be}from"node:fs/promises";import{chmod as ae,mkdir as Ie,open as Ce,rename as Oe,unlink as ke}from"node:fs/promises";import{dirname as Pe}from"node:path";async function O(t){await Ie(t,{recursive:!0,mode:448}),process.platform!=="win32"&&await ae(t,448)}async function b(t,e){let n=Pe(t);await O(n);let i=`${t}.${process.pid}.${Date.now()}.tmp`,r=await Ce(i,"wx",384);try{await r.writeFile(e,{encoding:"utf8"}),await r.sync()}finally{await r.close()}try{process.platform!=="win32"&&await ae(i,384),await Oe(i,t)}catch(o){throw await ke(i).catch(()=>{}),o}}import{dirname as xe}from"node:path";var w=class{lockPath;staleMs;retries;constructor(e,n={}){this.lockPath=e,this.staleMs=n.staleMs??3e4,this.retries=n.retries??120}async withLock(e){await O(xe(this.lockPath)),await(await be(this.lockPath,"a",384)).close();let i,r=await ce.default.lock(this.lockPath,{realpath:!1,stale:this.staleMs,retries:{retries:this.retries,factor:1.15,minTimeout:5,maxTimeout:250},onCompromised:o=>{i??=o}});try{return await e()}finally{try{await r()}catch(o){if(!i)throw o}if(i)throw i}}};import{createHash as Re,randomBytes as Ne}from"node:crypto";var Ue="urn:ietf:params:oauth:grant-type:device_code",l=class extends Error{code;httpStatus;constructor(e,n,i){super(n??`The OAuth server rejected the request (${e}${i?`, HTTP ${i}`:""}).`),this.code=e,this.httpStatus=i,this.name="OAuthProtocolError"}},j=class{options;fetchImpl;sleep;now;constructor(e){this.options=e,this.fetchImpl=e.fetchImpl??fetch,this.sleep=e.sleep??(n=>new Promise(i=>setTimeout(i,n))),this.now=e.now??Date.now}async startDeviceAuthorization(e={}){let n=Ne(32).toString("base64url"),i=Re("sha256").update(n,"ascii").digest("base64url"),r=await this.postForm(this.options.deviceAuthorizationEndpoint,{client_id:u,scope:c.join(" "),audience:p,code_challenge:i,code_challenge_method:"S256"},{headers:this.options.deviceAuthorizationHeaders,signal:e.signal}),o=d(r,"user_code"),s=d(r,"device_code"),a=R(r,"expired_in"),h=!s&&!!o&&a!==void 0,C=s??(h?o:void 0),B=d(r,"verification_uri")??d(r,"verification_url"),te=R(r,"expires_in")??ze(a,this.now()),V=R(r,"interval"),Ae=h&&V!==void 0?V/1e3:V??5;if(!C||!o||!B||!te)throw new l("invalid_device_authorization_response");return{deviceCode:C,codeVerifier:n,...h?{tokenPollingParameter:"user_code"}:{},userCode:o,verificationUri:B,...d(r,"verification_uri_complete")||h?{verificationUriComplete:d(r,"verification_uri_complete")??B}:{},expiresInSec:te,intervalSec:Ae}}async pollDeviceToken(e,n={}){let i=this.now()+e.expiresInSec*1e3,r=e.intervalSec*1e3;for(;this.now()<i;){n.signal?.throwIfAborted();let o=e.tokenPollingParameter==="user_code"?{user_code:e.userCode}:{device_code:e.deviceCode},s=await this.postFormAllowOAuthError(this.options.tokenEndpoint,{grant_type:Ue,...o,client_id:u,code_verifier:e.codeVerifier},{signal:n.signal}),a=d(s.body,"status");if(s.ok&&a==="pending"){await x(this.sleep,r,n.signal);continue}if(s.ok&&a==="slow_down"){r+=5e3,await x(this.sleep,r,n.signal);continue}if(s.ok&&(a==="denied"||a==="access_denied"))throw new l("access_denied");if(s.ok&&(a==="expired"||a==="expired_token"))throw new l("expired_token");if(s.ok)return de(s.body);if(s.error==="authorization_pending"){await x(this.sleep,r,n.signal);continue}if(s.error==="slow_down"){r+=5e3,await x(this.sleep,r,n.signal);continue}throw new l(s.error??"device_authorization_failed",void 0,s.status)}throw new l("expired_token","The OAuth device authorization expired.")}async refreshToken(e){let n=await this.postForm(this.options.tokenEndpoint,{grant_type:"refresh_token",refresh_token:e,client_id:u,scope:c.join(" "),audience:p});return de(n,e)}async revokeToken(e){let n=await this.postFormAllowOAuthError(this.options.revocationEndpoint,{token:e,token_type_hint:"refresh_token",client_id:u},{allowEmptySuccess:!0});if(!n.ok)throw new l(n.error??"oauth_request_failed",void 0,n.status)}async postForm(e,n,i={}){let r=await this.postFormAllowOAuthError(e,n,i);if(!r.ok)throw new l(r.error??"oauth_request_failed",void 0,r.status);return r.body}async postFormAllowOAuthError(e,n,i={}){let r=await this.fetchImpl(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded",...i.headers},body:new URLSearchParams(n),signal:i.signal}),o=N(await r.json().catch(()=>{}));if(!o&&r.ok&&i.allowEmptySuccess)return{ok:!0,status:r.status,body:{}};if(!o)throw new l("invalid_json_response",void 0,r.status);let s=d(o,"error");return{ok:r.ok&&!s,status:r.status,body:o,...s?{error:s}:{}}}};async function x(t,e,n){if(!n){await t(e);return}n.throwIfAborted();let i,r=()=>i(n.reason),o=new Promise((s,a)=>{i=a});n.addEventListener("abort",r,{once:!0});try{await Promise.race([t(e),o])}finally{n.removeEventListener("abort",r)}}function de(t,e){let n=d(t,"access_token"),i=d(t,"refresh_token")??e,r=d(t,"token_type"),o=R(t,"expires_in"),s=n?De(n):void 0,a=Le(t.scope??s?.scope??s?.scp);if(!n||!i||r?.toLowerCase()!=="bearer"||!o||!a.includes(c[0]))throw new l("invalid_token_response");return{accessToken:n,refreshToken:i,tokenType:"Bearer",scopes:a,audience:p,expiresInSec:o,...d(s,"sub")?{subject:d(s,"sub")}:{},...d(s,"account_id")?{accountId:d(s,"account_id")}:{}}}function De(t){let e=t.split(".");if(!(e.length!==3||!e[1]))try{return N(JSON.parse(Buffer.from(e[1],"base64url").toString("utf8")))}catch{return}}function Le(t){return typeof t=="string"?t.split(/\s+/u).filter(Boolean):Array.isArray(t)&&t.every(e=>typeof e=="string")?t:[]}function N(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}function d(t,e){let i=N(t)?.[e];return typeof i=="string"&&i.trim()?i.trim():void 0}function R(t,e){let i=N(t)?.[e];return typeof i=="number"&&Number.isFinite(i)&&i>0?i:void 0}function ze(t,e){if(t===void 0)return;if(t<1e12)return t;let n=t-e;return n>0?Math.ceil(n/1e3):void 0}import{readFile as Be}from"node:fs/promises";var E=2,Ve=1,He=/access[_-]?token|refresh[_-]?token|device[_-]?code|code[_-]?verifier/iu;function he(t){if(!(typeof t!="object"||t===null))for(let[e,n]of Object.entries(t)){if(He.test(e))throw new TypeError("Sensitive OAuth fields cannot be persisted in auth-state.json.");he(n)}}function ue(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError("Invalid OAuth state.");let e=t;if(!(typeof e.schemaVersion=="number"&&Number.isInteger(e.schemaVersion)&&e.schemaVersion>=Ve&&e.schemaVersion<=E&&["anonymous","authorizing","authenticated","refreshing","scope_upgrade_required","logging_out","logout_pending","expired","error"].includes(e.status)&&(e.schemaVersion===1&&(e.storeKind==="os-keyring"||e.storeKind==="file")||e.schemaVersion===E&&e.storeKind==="file")&&e.clientId==="mcode-public"&&Array.isArray(e.scopes)&&e.scopes.every(i=>typeof i=="string")&&e.audience==="agent-backend"&&je(e.buildEnv,e.region)&&(e.expiresAtMs===void 0||typeof e.expiresAtMs=="number"&&Number.isFinite(e.expiresAtMs))&&Number.isSafeInteger(e.generation)&&e.generation>=0&&(e.authorization===void 0||Fe(e.authorization))))throw new TypeError("Invalid OAuth state.");return he(e),e}function je(t,e){return t===void 0&&e===void 0?!0:(t==="dev"||t==="test"||t==="staging"||t==="prod")&&(e==="cn"||e==="en")}function Fe(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=t;return typeof e.leaseId=="string"&&e.leaseId.length>0&&typeof e.leaseExpiresAtMs=="number"&&Number.isFinite(e.leaseExpiresAtMs)&&F(e.userCode)&&F(e.verificationUri)&&F(e.verificationUriComplete)}function F(t){return t===void 0||typeof t=="string"}var y=class{path;constructor(e){this.path=e}async read(){let e;try{e=await Be(this.path,"utf8")}catch(n){if(n.code==="ENOENT")return null;throw n}try{return ue(JSON.parse(e))}catch(n){throw n instanceof TypeError?n:new TypeError("Invalid OAuth state.")}}async write(e){let n=ue(e);await b(this.path,`${JSON.stringify(n,null,2)}
3
3
  `)}};var qe=600*1e3,Ge=250,f=class extends Error{code="AUTH_REQUIRED";constructor(e){super("MCode authentication is required.",e),this.name="AuthRequiredError"}},T=class extends Error{code="AUTH_LOGIN_CANCELLED";constructor(){super("MCode OAuth device authorization was cancelled."),this.name="AuthLoginCancelledError"}},U=class extends Error{code="AUTH_SESSION_CHANGED";constructor(){super("The login changed while this request was in progress."),this.name="AuthSessionChangedError"}};function Je(t,e){if(!t||t!==e)throw new U}var M=class extends Error{missingScopes;code="AUTH_SCOPE_UPGRADE_REQUIRED";constructor(e){super("The current MCode authorization does not include the required scope."),this.missingScopes=e,this.name="AuthScopeUpgradeRequiredError"}},I=class extends Error{code="AUTH_RESOURCE_CONTRACT_MISMATCH";constructor(){super("The stored credential does not match the MCode resource contract."),this.name="AuthResourceContractMismatchError"}};function le(t){return t instanceof f||t instanceof M||t instanceof I}var q=class extends Error{active;requested;code="AUTH_DOMAIN_CONFLICT";constructor(e,n){super(`MCode is signed in to ${e.buildEnv}/${e.region}; sign out before using ${n.buildEnv}/${n.region}.`),this.active=e,this.requested=n,this.name="AuthDomainConflictError"}},G=class{options;stateStore;lock;now;sleep;authorizationLeaseMs;statePollIntervalMs;createLeaseId;loginPromise;loginAbortController;initializePromise;constructor(e){this.options=e,this.stateStore=new y(e.namespace.statePath),this.lock=new w(e.namespace.lockPath),this.now=e.now??Date.now,this.sleep=e.sleep??(n=>new Promise(i=>setTimeout(i,n))),this.authorizationLeaseMs=e.authorizationLeaseMs??qe,this.statePollIntervalMs=e.statePollIntervalMs??Ge,this.createLeaseId=e.createLeaseId??$}async getStatus(){await this.initialize();let e=await this.stateStore.read();if(!e)return{status:"anonymous",generation:0,scopes:[]};if(e.status==="authorizing"||e.status==="refreshing"){let n=await this.recoverInterruptedCredentialCommit(e);return _(n)}if(e.status==="authenticated"||e.status==="expired"){let n=await this.options.credentialStore.get(this.options.namespace.credentialKey);if(!n||n.generation!==e.generation)return _({...e,status:"error"});try{S(n,[...c])}catch(r){if(r instanceof M)return _({...k(n,this.options.credentialStore.kind,this.options.namespace),status:"scope_upgrade_required"});if(r instanceof I)return _({...e,status:"error"});throw r}let i=k(n,this.options.credentialStore.kind,this.options.namespace);return e.status==="expired"||n.expiresAtMs<=this.now()?_({...i,status:"expired"}):_(i)}return _(e)}login(e={}){if(!this.loginPromise){let n=new AbortController,i=this.initialize().then(()=>this.runLogin(e,n.signal)).finally(()=>{this.loginPromise===i&&(this.loginPromise=void 0,this.loginAbortController=void 0)});this.loginAbortController=n,this.loginPromise=i}return this.loginPromise}async cancelLogin(){let e=this.loginAbortController,n=this.loginPromise;if(!(!e||!n)){e.abort();try{await n}catch(i){if(!(i instanceof T))throw i}}}async getAccessToken(e){await this.initialize(),Ye(e.requiredScopes);try{let n=await this.readUsableCredential(e.requiredScopes);if(this.satisfiesMinValidity(n,e.minValidityMs))return K(n.credential)}catch(n){if(!(n instanceof f))throw n}return this.lock.withLock(async()=>{let n=await this.readUsableCredential(e.requiredScopes);return this.satisfiesMinValidity(n,e.minValidityMs)?K(n.credential):this.refreshCredential(n)})}satisfiesMinValidity(e,n){if(e.state.status!=="authenticated")return!1;let i=e.credential.expiresAtMs-this.now();return i>0&&i>=n}async handleUnauthorized(e){await this.initialize();try{return await this.lock.withLock(async()=>{let n=await this.readUsableCredential([...c]);if(e.loginEpoch!==void 0)Je(e.loginEpoch,n.credential.loginEpoch);else if(n.credential.generation>e.generation)throw new U;return n.credential.generation>e.generation?"retry":n.credential.generation<e.generation?"logout":(await this.refreshCredential(n,{rejected:!0}),"retry")})}catch(n){if(le(n))return"logout";throw n}}async logout(e){return await this.initialize(),this.lock.withLock(async()=>{let n=await this.stateStore.read(),i=await this.options.credentialStore.get(this.options.namespace.credentialKey),r=Math.max(n?.generation??0,i?.generation??0);if(!i&&(!n||n.status==="anonymous"))return{status:"anonymous",generation:r};let o=r+1;if(await this.stateStore.write(A({status:"logging_out",generation:o,storeKind:this.options.credentialStore.kind},this.options.namespace)),e.revoke&&i)try{await this.options.oauthClient.revokeToken(i.refreshToken)}catch{return await this.stateStore.write(A({status:"logout_pending",generation:o,storeKind:this.options.credentialStore.kind},this.options.namespace)),{status:"logout_pending",generation:o}}return await this.options.credentialStore.delete(this.options.namespace.credentialKey),await this.stateStore.write(A({status:"anonymous",generation:o,storeKind:this.options.credentialStore.kind},this.options.namespace)),{status:"anonymous",generation:o}})}watch(e){let n=()=>{this.getStatus().then(e).catch(()=>{})};return Ke(this.options.namespace.statePath,{interval:this.statePollIntervalMs},n),()=>$e(this.options.namespace.statePath,n)}initialize(){return this.initializePromise??=(async()=>{await this.options.initialize?.(),await this.options.credentialStore.healthCheck()})().catch(e=>{throw this.initializePromise=void 0,e}),this.initializePromise}async runLogin(e,n){for(;;){v(n);let i=this.createLeaseId(),r=await this.lock.withLock(async()=>{let o=await this.stateStore.read();Xe(o,this.options.namespace);let s=await this.options.credentialStore.get(this.options.namespace.credentialKey);if(o&&s&&o.generation===s.generation&&(o.status==="authenticated"||o.status==="expired"||o.status==="refreshing"))try{return S(s,[...c]),o.status==="authenticated"&&s.expiresAtMs>this.now()?{kind:"authenticated",generation:s.generation}:{kind:"refresh",generation:s.generation}}catch(h){if(!(h instanceof M)&&!(h instanceof I))throw h}if(o?.status==="authorizing"&&o.authorization&&o.authorization.leaseExpiresAtMs>this.now())return{kind:"wait",leaseExpiresAtMs:o.authorization.leaseExpiresAtMs};let a=Math.max(o?.generation??0,s?.generation??0);return await this.stateStore.write({...A({status:"authorizing",generation:a,storeKind:this.options.credentialStore.kind},this.options.namespace),authorization:{leaseId:i,leaseExpiresAtMs:this.now()+this.authorizationLeaseMs}}),{kind:"owner"}});if(r.kind==="authenticated")return{status:"authenticated",generation:r.generation};if(r.kind==="refresh"){try{await this.lock.withLock(async()=>{let s=await this.readUsableCredential([...c]);s.credential.generation>r.generation&&this.satisfiesMinValidity(s,1)||await this.refreshCredential(s)})}catch(s){if(le(s))continue;throw s}let o=await this.stateStore.read();if(o?.status==="authenticated")return{status:"authenticated",generation:o.generation};continue}if(r.kind==="wait"){let o=await this.waitForAuthorization(r.leaseExpiresAtMs,e.onDeviceAuthorization,n);if(o)return o;continue}try{let o=await this.options.oauthClient.startDeviceAuthorization({signal:n});await this.publishAuthorizationProgress(i,o),e.onDeviceAuthorization?.(Qe(o));let s=await this.options.oauthClient.pollDeviceToken(o,{signal:n});return await this.commitLogin(i,s,n)}catch(o){let s=n.aborted;throw await this.releaseAuthorizationLease(i,s?"anonymous":"error"),s?new T:o}}}async commitLogin(e,n,i){return this.lock.withLock(async()=>{v(i);let r=await this.stateStore.read();if(r?.status!=="authorizing"||r.authorization?.leaseId!==e)throw new f;let o=await this.options.credentialStore.get(this.options.namespace.credentialKey);v(i);let s=Math.max(r.generation,o?.generation??0)+1,a=pe(n,s,this.now(),$());await this.options.credentialStore.put(this.options.namespace.credentialKey,a);try{v(i),await this.stateStore.write(k(a,this.options.credentialStore.kind,this.options.namespace)),v(i)}catch(h){throw h instanceof T&&(await this.stateStore.write(r),o?await this.options.credentialStore.put(this.options.namespace.credentialKey,o):await this.options.credentialStore.delete(this.options.namespace.credentialKey)),h}return{status:"authenticated",generation:s}})}async waitForAuthorization(e,n,i){let r=!1;for(;this.now()<e;){v(i);let o=await this.stateStore.read();if(!r&&o?.status==="authorizing"&&o.authorization?.userCode&&o.authorization.verificationUri&&(n?.({userCode:o.authorization.userCode,verificationUri:o.authorization.verificationUri,...o.authorization.verificationUriComplete?{verificationUriComplete:o.authorization.verificationUriComplete}:{},expiresInSec:Math.max(1,Math.ceil((o.authorization.leaseExpiresAtMs-this.now())/1e3))}),r=!0),o?.status==="authenticated"){let s=await this.options.credentialStore.get(this.options.namespace.credentialKey);if(s&&s.generation===o.generation)return S(s,[...c]),{status:"authenticated",generation:o.generation}}if(o?.status!=="authorizing")return;await Ze(this.sleep,this.statePollIntervalMs,i)}}async publishAuthorizationProgress(e,n){await this.lock.withLock(async()=>{let i=await this.stateStore.read();if(i?.status!=="authorizing"||i.authorization?.leaseId!==e)throw new f;await this.stateStore.write({...i,authorization:{...i.authorization,userCode:n.userCode,verificationUri:n.verificationUri,...n.verificationUriComplete?{verificationUriComplete:n.verificationUriComplete}:{}}})})}async releaseAuthorizationLease(e,n){await this.lock.withLock(async()=>{let i=await this.stateStore.read();i?.status!=="authorizing"||i.authorization?.leaseId!==e||await this.stateStore.write(A({status:n,generation:i.generation,storeKind:this.options.credentialStore.kind},this.options.namespace))})}async recoverInterruptedCredentialCommit(e){let n=await this.options.credentialStore.get(this.options.namespace.credentialKey);return!n||n.generation<=e.generation?e:(S(n,[...c]),this.lock.withLock(async()=>{let i=await this.stateStore.read(),r=await this.options.credentialStore.get(this.options.namespace.credentialKey);if(!i||!r||i.status!=="authorizing"&&i.status!=="refreshing"||r.generation<=i.generation)return i??e;S(r,[...c]);let o=k(r,this.options.credentialStore.kind,this.options.namespace);return await this.stateStore.write(o),o}))}async readUsableCredential(e){let n=await this.stateStore.read();if(!n||n.status!=="authenticated"&&n.status!=="expired"&&n.status!=="refreshing")throw new f;let i=await this.options.credentialStore.get(this.options.namespace.credentialKey);if(!i||n.generation!==i.generation)throw new f;return S(i,e),{state:n,credential:i}}async refreshCredential(e,n={}){await this.stateStore.write({...e.state,status:"refreshing"});let i;try{i=await this.options.oauthClient.refreshToken(e.credential.refreshToken)}catch(o){if(We(o))throw await this.stateStore.write(A({status:"anonymous",generation:e.credential.generation+1,storeKind:this.options.credentialStore.kind},this.options.namespace)),await this.options.credentialStore.delete(this.options.namespace.credentialKey),new f({cause:o});{let s=!n.rejected&&e.state.status==="authenticated"&&e.credential.expiresAtMs>this.now();await this.stateStore.write({...e.state,status:s?"authenticated":"expired"})}throw o}let r=pe(i,Math.max(e.state.generation,e.credential.generation)+1,this.now(),e.credential.loginEpoch);return await this.options.credentialStore.put(this.options.namespace.credentialKey,r),await this.stateStore.write(k(r,this.options.credentialStore.kind,this.options.namespace)),K(r)}};function v(t){if(t?.aborted)throw new T}function We(t){return t instanceof l&&t.code==="invalid_grant"&&t.httpStatus===400}async function Ze(t,e,n){if(!n){await t(e);return}v(n);let i,r=()=>i(new T),o=new Promise((s,a)=>{i=a});n.addEventListener("abort",r,{once:!0});try{await Promise.race([t(e),o])}finally{n.removeEventListener("abort",r)}}function Qe(t){return{userCode:t.userCode,verificationUri:t.verificationUri,...t.verificationUriComplete?{verificationUriComplete:t.verificationUriComplete}:{},expiresInSec:t.expiresInSec}}function A(t,e){return{schemaVersion:E,status:t.status,storeKind:t.storeKind,clientId:u,scopes:[...c],audience:p,buildEnv:e.buildEnv,region:e.region,generation:t.generation}}function k(t,e,n){return{...A({status:"authenticated",generation:t.generation,storeKind:e},n),scopes:t.scopes,expiresAtMs:t.expiresAtMs}}function pe(t,e,n,i=$()){let r={schemaVersion:1,accessToken:t.accessToken,refreshToken:t.refreshToken,tokenType:t.tokenType,clientId:u,scopes:t.scopes,audience:p,expiresAtMs:n+t.expiresInSec*1e3,generation:e,loginEpoch:i,...t.subject?{subject:t.subject}:{},...t.accountId?{accountId:t.accountId}:{}};if(S(r,[...c]),t.audience!==p)throw new I;return r}function Ye(t){let e=t.filter(n=>!c.includes(n));if(e.length>0)throw new M(e)}function S(t,e){if(t.clientId!==u||t.audience!==p||t.tokenType!=="Bearer")throw new I;let n=e.filter(i=>!t.scopes.includes(i));if(n.length>0)throw new M(n)}function _(t){return{status:t.status,generation:t.generation,scopes:t.scopes,...t.buildEnv===void 0?{}:{buildEnv:t.buildEnv},...t.region===void 0?{}:{region:t.region},...t.expiresAtMs===void 0?{}:{expiresAtMs:t.expiresAtMs}}}function Xe(t,e){if(!(!t||t.status==="anonymous"||t.buildEnv===void 0||t.region===void 0||t.buildEnv===e.buildEnv&&t.region===e.region))throw new q({buildEnv:t.buildEnv,region:t.region},{buildEnv:e.buildEnv,region:e.region})}function K(t){return{accessToken:t.accessToken,...t.loginEpoch?{loginEpoch:t.loginEpoch}:{},expiresAtMs:t.expiresAtMs,generation:t.generation,scopes:c,audience:p}}import{createHash as et}from"node:crypto";import{join as g,resolve as tt}from"node:path";function J(t){let e=g(tt(t.dataDir),"auth"),n=g(e,t.buildEnv,t.region,u),i=`com.minimax.mcode.oauth.${t.buildEnv}.${t.region}`,r=et("sha256").update(`${e}\0${u}`).digest("base64url");return{authHome:e,namespaceHome:n,lockPath:g(n,"auth.lock"),statePath:g(n,"auth-state.json"),credentialPath:g(n,"auth.json"),legacyLockPath:g(e,"auth.lock"),legacyStatePath:g(e,"auth-state.json"),legacyEncryptedCredentialPath:g(e,"credentials.enc"),buildEnv:t.buildEnv,region:t.region,credentialKey:{service:i,account:r}}}async function nt(t){let e=await it(t),n=new y(t.statePath);await new w(t.lockPath).withLock(async()=>{let r=await n.read();if(r?.schemaVersion===E)return;let o=r??e;o&&await n.write(ot(o,t))})}async function it(t){let e=new y(t.legacyStatePath);return new w(t.legacyLockPath).withLock(async()=>{let i=await e.read();if(!rt(i,t))return null;let{authorization:r,...o}=i;return await e.write({...o,status:"error"}),i})}function rt(t,e){return t!==null&&t.status!=="error"&&t.buildEnv===e.buildEnv&&t.region===e.region}function ot(t,e){return{schemaVersion:E,status:"anonymous",storeKind:"file",clientId:"mcode-public",scopes:["agent.default"],audience:"agent-backend",buildEnv:e.buildEnv,region:e.region,generation:t.generation+1}}import{readFile as ct,stat as fe}from"node:fs/promises";import{join as dt}from"node:path";var st=1,at=1,m=class extends Error{code="CREDENTIAL_RECORD_CORRUPT";constructor(){super("The stored OAuth credential record is invalid."),this.name="CredentialRecordCorruptError"}},D=class extends Error{code="AUTH_CREDENTIAL_STORE_PERMISSION";constructor(){super("The OAuth credential file permissions are not private."),this.name="CredentialStorePermissionError"}};function W(t){return t===void 0||typeof t=="string"}function Z(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new m;let e=t,n=e.scopes,i=Array.isArray(n)&&n.every(o=>typeof o=="string");if(!(typeof e.schemaVersion=="number"&&Number.isInteger(e.schemaVersion)&&e.schemaVersion>=at&&e.schemaVersion<=st&&typeof e.accessToken=="string"&&e.accessToken.length>0&&typeof e.refreshToken=="string"&&e.refreshToken.length>0&&e.tokenType==="Bearer"&&e.clientId===u&&i&&e.audience===p&&typeof e.expiresAtMs=="number"&&Number.isFinite(e.expiresAtMs)&&Number.isSafeInteger(e.generation)&&e.generation>=0&&W(e.subject)&&W(e.accountId)&&W(e.loginEpoch)))throw new m;return e}var Y=1;function Q(t){return`${t.service}\0${t.account}`}function me(t){if(typeof t!="object"||t===null||Array.isArray(t))throw new m;let e=t;if(e.schemaVersion!==Y||typeof e.records!="object"||e.records===null||Array.isArray(e.records))throw new m;let n=Object.fromEntries(Object.entries(e.records).map(([i,r])=>[i,Z(r)]));return{schemaVersion:Y,records:n}}var L=class{kind="file";authHome;path;constructor(e){this.authHome=e.authHome,this.path=dt(e.authHome,"auth.json")}async get(e){return(await this.readPayload()).records[Q(e)]??null}async put(e,n){let i=await this.readPayload();i.records[Q(e)]=Z(n),await this.writePayload(i)}async delete(e){let n=await this.readPayload();delete n.records[Q(e)],await this.writePayload(n)}async healthCheck(){await O(this.authHome),await this.assertPrivatePermissions()}async readPayload(){let e;try{await this.assertPrivatePermissions(),e=await ct(this.path,"utf8")}catch(n){if(n.code==="ENOENT")return{schemaVersion:Y,records:{}};throw n}try{return me(JSON.parse(e))}catch(n){throw n instanceof m?n:new m}}async assertPrivatePermissions(){if(process.platform!=="win32")try{let[e,n]=await Promise.all([fe(this.authHome),fe(this.path)]);if((e.mode&63)!==0||(n.mode&63)!==0)throw new D}catch(e){if(e.code==="ENOENT")return;throw e}}async writePayload(e){let n=me(e);await b(this.path,`${JSON.stringify(n,null,2)}
4
4
  `)}};function ut(t){return new L(t)}var X;function ge(t){X=t}function ht(t={}){let e=t.embeddedBuildEnvironment??we(),n=t.embeddedBuildVariant??lt(),i=t.runtimeBuildEnv??ne();return oe({buildEnv:e??pt(i),internalBuild:n==="internal"})}function z(t={}){let e=ht(t);return{region:t.runtimeRegion??"cn",buildEnv:X??e.buildEnv??"test"}}function zn(t=we()){return X??t??"dev"}function we(){return"prod"}function lt(){return"standard"}function pt(t){return t==="dev"?"test":t}import gt from"node:fs";import P from"node:fs";import Ee from"node:path";var ye="preferences",ft="mcode-region.json";function _e(t,e){try{let n=JSON.parse(P.readFileSync(ve(t),"utf8"));if(n.version!==1||!n.regions||typeof n.regions!="object")return;let i=n.regions[e];return i==="cn"||i==="en"?i:void 0}catch{return}}function jn(t,e){let n=Ee.join(t,ye);P.mkdirSync(n,{recursive:!0,mode:448});let i=ve(t),o={version:1,regions:{...mt(i),[e.buildEnv]:e.region},updatedAtMs:Date.now()},s=`${i}.${process.pid}.${Date.now()}.tmp`;return P.writeFileSync(s,`${JSON.stringify(o,null,2)}
5
5
  `,{encoding:"utf8",mode:384}),P.renameSync(s,i),i}function ve(t){return Ee.join(t,ye,ft)}function mt(t){try{let e=JSON.parse(P.readFileSync(t,"utf8"));return e.version!==1||!e.regions||typeof e.regions!="object"?{}:Object.fromEntries(Object.entries(e.regions).filter(([n,i])=>(n==="dev"||n==="test"||n==="staging"||n==="prod")&&(i==="cn"||i==="en")))}catch{return{}}}var wt=/^[A-Za-z0-9._-]+$/u,ee="--env",Et=new Set(["--lane","--resume","--tui-mode","-m","--model","--system-prompt","--system-prompt-file","--append-system-prompt","--append-system-prompt-file"]),yt=Object.freeze({test:"test",pre:"staging",staging:"staging",prod:"prod"});function Wn(t={}){ie(!1),re(!1);let{target:e=process.env,dataDir:n,startupBuildEnvironment:i,...r}=t;i&&ge(i);let o=z(r),s=n?_e(n,o.buildEnv):void 0,a=n?vt(n,o.buildEnv):void 0,h=St(e.MAVIS_REGION),C=z({...r,runtimeRegion:r.runtimeRegion??h??s??a?.region??"cn"});return n&&(e.MINIMAX_DATA_DIR=n,e.MAVIS_DATA_DIR=n),e.MAVIS_REGION=C.region,e.MAVIS_BUILD_ENV=C.buildEnv,e.__MAVIS_RUNTIME_MANAGED="1",C}function _t(t){let e=yt[t.trim()];if(!e)throw new Error("--env must be test, staging, pre, or prod.");return e}function Zn(t,e){let n=[];for(let i=0;i<t.length;i+=1){let r=t[i];if(r!==void 0){if(r==="--")break;if(r===ee){let o=t[i+1];if(!o||o.startsWith("-"))throw new Error("--env requires a value.");n.push(o),i+=1;continue}if(r.startsWith(`${ee}=`)){n.push(r.slice(ee.length+1));continue}if(Et.has(r)){i+=1;continue}if(r==="--session"&&t[i+1]&&!t[i+1]?.startsWith("-")){i+=1;continue}if(!r.startsWith("-"))break}}if(n.length!==0){if(!e)throw new Error("--env is only available in the internal MCode package.");if(n.length>1)throw new Error("--env may only be specified once.");return _t(n[0]??"")}}function Qn(t,e=z().buildEnv){if(t===void 0)return;if(e!=="test"&&e!=="staging")throw new Error("--lane is only supported in test or staging builds.");let n=t.trim();if(!wt.test(n))throw new Error("--lane only accepts letters, numbers, dot, underscore, and hyphen.");return n}function vt(t,e){let n=["cn","en"].filter(r=>{try{let o=J({dataDir:t,buildEnv:e,region:r}),s=JSON.parse(gt.readFileSync(o.statePath,"utf8"));return s.buildEnv===e&&s.region===r&&At(s.status)}catch{return!1}}),i=n.length===1?n[0]:void 0;return i?{buildEnv:e,region:i}:void 0}function At(t){return t==="authorizing"||t==="authenticated"||t==="refreshing"||t==="scope_upgrade_required"||t==="expired"}function St(t){return t==="cn"||t==="en"?t:void 0}export{c as a,J as b,nt as c,j as d,Mt as e,U as f,le as g,G as h,ut as i,ht as j,z as k,zn as l,jn as m,Wn as n,_t as o,Zn as p,Qn as q};
@@ -1,2 +1,2 @@
1
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 p}from"./chunk-AQ73XBVZ.js";import{e as g,k as d,m as h}from"./chunk-C2QIYD6E.js";import{isAbsolute as f,resolve as A}from"node:path";import{spawn as E}from"node:child_process";import{fileURLToPath as y}from"node:url";function T(e){return t=>R(t,e)}function R(e,t){let i=S(e,t),[o,r]=process.platform==="darwin"?["open",[i]]:process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",i]]:["xdg-open",[i]];return new Promise((s,u)=>{let n=E(o,r,{detached:!0,stdio:"ignore",windowsHide:!0});n.once("error",u),n.once("spawn",()=>{n.unref(),s()})})}function S(e,t){return/^https?:\/\//iu.test(e)?e:/^file:\/\//iu.test(e)?y(e):f(e)?e:A(t,e)}var x="mcode-internal";function k(e){try{let t=new URL(e);return t.searchParams.set("client_surface","tui"),t.searchParams.set("download_source",x),t.toString()}catch{return e}}var w={cn:{dev:"https://agent.minimaxi.com",test:"https://agent.minimaxi.com",staging:"https://agent.minimaxi.com",prod:"https://agent.minimax.cn"},en:{dev:"https://agent.minimax.io",test:"https://agent.minimax.io",staging:"https://agent.minimax.io",prod:"https://agent.minimax.io"}};function m(e){let t=w[e.region][e.buildEnv];return`${t}/auth/logout?logout_redirect_uri=${encodeURIComponent(t)}`}var c=class{constructor(t){this.options=t;let i=d({runtimeRegion:process.env.MAVIS_REGION==="en"?"en":"cn"});this.scope={region:t.region??i.region,buildEnv:t.buildEnv??i.buildEnv}}scope;async login(t,i=this.scope.region){this.track("login_click",{hailuo_user_id:this.hailuoUserId()});try{let o={...this.scope,region:i},r=!P(o,this.scope),s=this.options.sharedAuthCore;if(r){if(!this.options.resolveSharedAuthCore)throw new Error(C(this.scope,o));s=this.options.resolveSharedAuthCore(i)}let u=(await s.getStatus()).status==="authenticated",n=!1;await s.login({onDeviceAuthorization:M=>{n=!0,t?.({state:"device-authorization",...M})}}),this.persistRegionPreference(o);let l=u&&!n,v={state:l?"already-authenticated":"authenticated",message:l?r?`Already signed in with ${a(o.region)}.`:"Already signed in with MiniMax.":r?`Signed in with ${a(o.region)}.`:"Signed in with MiniMax.",...r?{restartRequired:!0}:{}};return this.trackLoginResult("1",""),v}catch(o){throw this.trackLoginResult("2",b(o)),o}}async logout(){this.track("logout_click",{hailuo_user_id:this.hailuoUserId()});let t=await this.options.sharedAuthCore.getStatus(),i=await this.options.sharedAuthCore.logout({revoke:!0}),o=m(this.scope);return t.status==="anonymous"&&i.status==="anonymous"?{state:"already-signed-out",message:"Already signed out of MiniMax.",logoutUrl:o}:{state:"signed-out",logoutUrl:o,message:i.status==="logout_pending"?`Signed out locally from ${a(this.scope.region)} across MCode. Server revocation is pending until the network recovers.`:`Signed out of ${a(this.scope.region)} on Desktop, CLI/TUI, and embedded mcode-tools.`}}trackLoginResult(t,i){this.track("login_result",{hailuo_user_id:this.hailuoUserId(),source:this.options.telemetrySource??"mcode_cli",result_type:t,fail_reason:i,login_type:"minimax_oauth"})}persistRegionPreference(t){try{this.options.writeRegionPreference?.(this.options.dataDir,t)}catch{}}hailuoUserId(){try{return this.options.hailuoUserId?.()?.trim()??""}catch{return""}}track(t,i){try{this.options.telemetry?.track(t,i)}catch{}}};function b(e){let t=e instanceof Error?e.message:String(e);return/cancel/iu.test(t)?"3":/network|offline|fetch|ECONN|ENOTFOUND|ETIMEDOUT/iu.test(t)?"2":/oauth|authorization|login failed|invalid login state/iu.test(t)?"5":/server|HTTP 5\d\d/iu.test(t)?"1":"4"}function P(e,t){return e.region===t.region&&e.buildEnv===t.buildEnv}function C(e,t){return e.region!==t.region?`Signed in to ${a(e.region)}. Run \`mcode logout\` before signing in to ${a(t.region)}.`:`Signed in to another MiniMax ${e.buildEnv} environment. Run \`mcode logout\` before signing in to ${t.buildEnv}.`}function a(e){return e==="cn"?"MiniMax China":"MiniMax Global"}function j(e){let t=d({runtimeRegion:e.region,runtimeBuildEnv:e.buildEnv}),i=e.region??t.region,o=e.buildEnv??t.buildEnv,r={dataDir:e.dataDir,region:i,buildEnv:o,...e.telemetry?{telemetry:e.telemetry}:{},...e.telemetrySource?{telemetrySource:e.telemetrySource}:{},...e.hailuoUserId?{hailuoUserId:e.hailuoUserId}:{},writeRegionPreference:e.writeRegionPreference??h},s=n=>(e.createSharedSession??p)({dataDir:e.dataDir,region:n,buildEnv:o,oauthEndpoints:g(e.oauthEndpointEnvironment??process.env,{buildEnv:o,region:n})}),u=e.sharedAuthCore??s(i);return new c({...r,sharedAuthCore:u,resolveSharedAuthCore:s})}export{T as a,k as b,j as c};
2
+ import{a as p}from"./chunk-NFVRVRCL.js";import{e as g,k as d,m as h}from"./chunk-JL7ZXU6T.js";import{isAbsolute as f,resolve as A}from"node:path";import{spawn as E}from"node:child_process";import{fileURLToPath as y}from"node:url";function T(e){return t=>R(t,e)}function R(e,t){let i=S(e,t),[o,r]=process.platform==="darwin"?["open",[i]]:process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",i]]:["xdg-open",[i]];return new Promise((s,u)=>{let n=E(o,r,{detached:!0,stdio:"ignore",windowsHide:!0});n.once("error",u),n.once("spawn",()=>{n.unref(),s()})})}function S(e,t){return/^https?:\/\//iu.test(e)?e:/^file:\/\//iu.test(e)?y(e):f(e)?e:A(t,e)}var x="mcode-internal";function k(e){try{let t=new URL(e);return t.searchParams.set("client_surface","tui"),t.searchParams.set("download_source",x),t.toString()}catch{return e}}var w={cn:{dev:"https://agent.minimaxi.com",test:"https://agent.minimaxi.com",staging:"https://agent.minimaxi.com",prod:"https://agent.minimax.cn"},en:{dev:"https://agent.minimax.io",test:"https://agent.minimax.io",staging:"https://agent.minimax.io",prod:"https://agent.minimax.io"}};function m(e){let t=w[e.region][e.buildEnv];return`${t}/auth/logout?logout_redirect_uri=${encodeURIComponent(t)}`}var c=class{constructor(t){this.options=t;let i=d({runtimeRegion:process.env.MAVIS_REGION==="en"?"en":"cn"});this.scope={region:t.region??i.region,buildEnv:t.buildEnv??i.buildEnv}}scope;async login(t,i=this.scope.region){this.track("login_click",{hailuo_user_id:this.hailuoUserId()});try{let o={...this.scope,region:i},r=!P(o,this.scope),s=this.options.sharedAuthCore;if(r){if(!this.options.resolveSharedAuthCore)throw new Error(C(this.scope,o));s=this.options.resolveSharedAuthCore(i)}let u=(await s.getStatus()).status==="authenticated",n=!1;await s.login({onDeviceAuthorization:M=>{n=!0,t?.({state:"device-authorization",...M})}}),this.persistRegionPreference(o);let l=u&&!n,v={state:l?"already-authenticated":"authenticated",message:l?r?`Already signed in with ${a(o.region)}.`:"Already signed in with MiniMax.":r?`Signed in with ${a(o.region)}.`:"Signed in with MiniMax.",...r?{restartRequired:!0}:{}};return this.trackLoginResult("1",""),v}catch(o){throw this.trackLoginResult("2",b(o)),o}}async logout(){this.track("logout_click",{hailuo_user_id:this.hailuoUserId()});let t=await this.options.sharedAuthCore.getStatus(),i=await this.options.sharedAuthCore.logout({revoke:!0}),o=m(this.scope);return t.status==="anonymous"&&i.status==="anonymous"?{state:"already-signed-out",message:"Already signed out of MiniMax.",logoutUrl:o}:{state:"signed-out",logoutUrl:o,message:i.status==="logout_pending"?`Signed out locally from ${a(this.scope.region)} across MCode. Server revocation is pending until the network recovers.`:`Signed out of ${a(this.scope.region)} on Desktop, CLI/TUI, and embedded mcode-tools.`}}trackLoginResult(t,i){this.track("login_result",{hailuo_user_id:this.hailuoUserId(),source:this.options.telemetrySource??"mcode_cli",result_type:t,fail_reason:i,login_type:"minimax_oauth"})}persistRegionPreference(t){try{this.options.writeRegionPreference?.(this.options.dataDir,t)}catch{}}hailuoUserId(){try{return this.options.hailuoUserId?.()?.trim()??""}catch{return""}}track(t,i){try{this.options.telemetry?.track(t,i)}catch{}}};function b(e){let t=e instanceof Error?e.message:String(e);return/cancel/iu.test(t)?"3":/network|offline|fetch|ECONN|ENOTFOUND|ETIMEDOUT/iu.test(t)?"2":/oauth|authorization|login failed|invalid login state/iu.test(t)?"5":/server|HTTP 5\d\d/iu.test(t)?"1":"4"}function P(e,t){return e.region===t.region&&e.buildEnv===t.buildEnv}function C(e,t){return e.region!==t.region?`Signed in to ${a(e.region)}. Run \`mcode logout\` before signing in to ${a(t.region)}.`:`Signed in to another MiniMax ${e.buildEnv} environment. Run \`mcode logout\` before signing in to ${t.buildEnv}.`}function a(e){return e==="cn"?"MiniMax China":"MiniMax Global"}function j(e){let t=d({runtimeRegion:e.region,runtimeBuildEnv:e.buildEnv}),i=e.region??t.region,o=e.buildEnv??t.buildEnv,r={dataDir:e.dataDir,region:i,buildEnv:o,...e.telemetry?{telemetry:e.telemetry}:{},...e.telemetrySource?{telemetrySource:e.telemetrySource}:{},...e.hailuoUserId?{hailuoUserId:e.hailuoUserId}:{},writeRegionPreference:e.writeRegionPreference??h},s=n=>(e.createSharedSession??p)({dataDir:e.dataDir,region:n,buildEnv:o,oauthEndpoints:g(e.oauthEndpointEnvironment??process.env,{buildEnv:o,region:n})}),u=e.sharedAuthCore??s(i);return new c({...r,sharedAuthCore:u,resolveSharedAuthCore:s})}export{T as a,k as b,j as c};
@@ -1,5 +1,5 @@
1
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 y,c as M,d as p}from"./chunk-NICEDCLM.js";import{b as ie}from"./chunk-FKQFVOLR.js";import{a as q,b as C,c as ee,e as te,f as I,h as re,i as ne}from"./chunk-3MHUE4DM.js";import{a as A,b as U,c as _,d as F,e as K,f as V,k as z,m as b,n as H,p as x,q as X,r as G,s as Y,t as Z,w as W,x as Q}from"./chunk-RDUENEEQ.js";import{a as Oe}from"./chunk-HQ2U4QVQ.js";import{n as S}from"./chunk-Z4VKGZFA.js";import{e as Le}from"./chunk-D76SO2ME.js";var pe=Le(Oe(),1);import{createHash as De}from"node:crypto";import{existsSync as k,mkdirSync as se,readFileSync as v,renameSync as ce,rmSync as de,writeFileSync as le}from"node:fs";import{homedir as Je}from"node:os";import d from"node:path";var Be="https://algeng-ali-shanghai-agent-02.oss-cn-shanghai.aliyuncs.com/minimax-dialogue/data/env/.npm-global/mcode",je=8e3,$=class{currentVersion;installRoot;releaseBaseUrl;publicKey;environment;dependencies;constructor(e){this.currentVersion=U(e.currentVersion),this.installRoot=e.installRoot??L(e.environment),this.releaseBaseUrl=(e.releaseBaseUrl??Be).replace(/\/+$/u,""),this.publicKey=e.publicKey,this.environment=e.environment??process.env,this.dependencies={fetchBytes:Ke,installArtifact:ze,validateInstalledVersion:He,...e.dependencies}}async check(e={}){M(e.signal),p(e,"checking",!0);let r=e.channel?A(e.channel):_e(this.installRoot),n=e.version?U(e.version):void 0,i=n?`${this.releaseBaseUrl}/releases/${encodeURIComponent(n)}/manifest.json`:`${this.releaseBaseUrl}/channels/${r}.json`,o=this.publicKey??Fe(this.installRoot,this.environment),a=ae(e.timeoutMs),s=new AbortController,c=oe(e.signal,s),f=!1,l=setTimeout(()=>{f=!0,s.abort(new Error(`MCode update check timed out after ${a}ms.`))},a);l.unref?.();try{let[u,h]=await Promise.all([this.dependencies.fetchBytes(i,{signal:s.signal,proxyEnvironment:this.environment}),this.dependencies.fetchBytes(`${i}.sig`,{signal:s.signal,proxyEnvironment:this.environment})]),g=_(u,h.toString("utf8"),o);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}.`);K(g,F());let m=V(this.currentVersion,g.version);return{status:m<0?"available":m>0?"ahead":"current",channel:r,currentVersion:this.currentVersion,latestVersion:g.version,manifest:g}}catch(u){throw e.signal?.aborted?new y:f?new Error(`MCode update check timed out after ${a}ms.`,{cause:u}):u}finally{clearTimeout(l),c()}}async apply(e={}){let r=await this.check(e);if(r.status==="current")return{...r,applied:!1,installRoot:this.installRoot};if(r.status==="ahead"&&!e.version)throw new Error(`Installed MCode ${this.currentVersion} is newer than ${r.channel} ${r.latestVersion}; pass --to to downgrade explicitly.`);let n=ae(e.timeoutMs);M(e.signal),p(e,"downloading",!0);let i=new AbortController,o=oe(e.signal,i),a=!1,s=setTimeout(()=>{a=!0,i.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:i.signal,proxyEnvironment:this.environment})}catch(m){throw e.signal?.aborted?new y:a?new Error(`MCode artifact download timed out after ${n}ms.`,{cause:m}):m}finally{clearTimeout(s),o()}M(e.signal),Xe(c,r.manifest);let f=d.join(this.installRoot,"versions"),l=d.join(f,r.latestVersion),u=d.join(f,`.staging-${r.latestVersion}-${process.pid}-${Date.now()}`),h=d.join(u,`minimax-mcode-${r.latestVersion}.tgz`);se(u,{recursive:!0});let g=!1;try{return p(e,"staging",!0),M(e.signal),le(h,c,{mode:384}),M(e.signal),p(e,"installing",!1),await this.dependencies.installArtifact({artifact:h,prefix:u,registry:r.manifest.registry,proxyEnvironment:this.environment}),M(e.signal),S(()=>de(h,{force:!0})),p(e,"validating",!1),await this.dependencies.validateInstalledVersion(u,r.latestVersion),M(e.signal),p(e,"activating",!1),k(l)?(await this.dependencies.validateInstalledVersion(l,r.latestVersion),T(u)):(S(()=>ce(u,l)),g=!0),Ge(this.installRoot,r.latestVersion),p(e,"completed",!1),{...r,applied:!0,installRoot:this.installRoot}}catch(m){throw T(u),g&&Ye(this.installRoot)!==r.latestVersion&&T(l),m instanceof y||e.signal?.aborted?new y:new Error(`MCode ${r.latestVersion} was not activated; the previous version is unchanged: ${ge(m)}`,{cause:m})}}};function L(t=process.env){if(t.MCODE_INSTALL_ROOT)return d.resolve(t.MCODE_INSTALL_ROOT);if(process.platform==="win32"){let r=t.LOCALAPPDATA;if(!r)throw new Error("LOCALAPPDATA is required to resolve the MCode install root.");return d.join(r,"MinimaxCode")}let e=t.XDG_DATA_HOME||d.join(Je(),".local","share");return d.join(e,"minimax-code")}function _e(t){let e=d.join(t,"update.json");if(!k(e))return"stable";let r;try{r=JSON.parse(v(e,"utf8"))}catch(n){throw new Error(`MCode update channel config is invalid: ${ge(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 A(r.channel)}function Fe(t,e){let r=e.MCODE_RELEASE_PUBLIC_KEY_FILE;if(r)return v(d.resolve(r),"utf8");let n=d.join(t,"install.json");if(!k(n))throw new Error("MCode update trust root is missing. Install with the official Shell/PowerShell installer first.");let i=JSON.parse(v(n,"utf8"));if(typeof i.publicKey!="string"||!i.publicKey.includes("BEGIN PUBLIC KEY"))throw new Error("MCode installer metadata does not contain a valid release public key.");return i.publicKey}function ae(t){if(t===void 0)return je;if(!Number.isSafeInteger(t)||t<100||t>6e4)throw new Error("MCode update timeout must be an integer between 100 and 60000 milliseconds.");return t}async function Ke(t,e={}){let[{default:r},{createTuiNetworkDispatcher:n}]=await Promise.all([import("./undici-75A6L7DQ.js"),import("./network-proxy-D4QGWYR5.js")]),i=n(e.proxyEnvironment);try{let o=await r.fetch(t,{signal:e.signal,dispatcher:i,redirect:"error"});if(!o.ok)throw new Error(`MCode release server returned HTTP ${o.status} for ${t}`);return Buffer.from(await o.arrayBuffer())}finally{await i.close()}}async function ze(t){let e=process.platform==="win32"?"npm.cmd":"npm";await ue(e,["install","--global","--prefix",t.prefix,t.artifact,"--registry",t.registry,"--no-audit","--no-fund","--package-lock=false"],t.proxyEnvironment,!0)}async function He(t,e){let r=d.join(t,"bin","mcode"),n=["--version"];if(process.platform==="win32"){let o=q(t,b().packageName),a=JSON.parse(v(d.join(o,"package.json"),"utf8")),s=ne(a.bin,"mcode");if(!s||!k(d.join(t,"mcode.cmd")))throw new Error(`Installed MCode launcher is missing or invalid at ${t}.`);r=process.execPath,n=[d.join(o,s),"--version"]}let i=await ue(r,n,process.env,!0);if(i.trim()!==e)throw new Error(`Installed MCode version mismatch: expected ${e}, got ${i.trim()}`)}function ue(t,e,r,n=!1){return new Promise((i,o)=>{let a=!1,s=(0,pe.default)(t,e,{env:r,shell:!1,stdio:n?["ignore","pipe","pipe"]:"inherit",windowsHide:!0}),c=[],f=[];s.stdout?.on("data",l=>c.push(l)),s.stderr?.on("data",l=>f.push(l)),s.once("error",l=>{a||(a=!0,o(l))}),s.once("close",(l,u)=>{if(a)return;if(a=!0,l===0)return i(Buffer.concat(c).toString("utf8"));let h=Buffer.concat(f).toString("utf8").trim();o(new Error(`${t} failed (${u?`signal ${u}`:`exit ${String(l)}`})${h?`: ${h}`:""}`))})})}function oe(t,e){if(!t)return()=>{};let r=()=>e.abort(t.reason);return t.aborted?r():t.addEventListener("abort",r,{once:!0}),()=>t.removeEventListener("abort",r)}function Xe(t,e){if(t.length!==e.installArtifact.size)throw new Error(`MCode artifact checksum/size verification failed: expected ${e.installArtifact.size} bytes, got ${t.length}.`);if(De("sha256").update(t).digest("hex")!==e.installArtifact.sha256)throw new Error("MCode artifact checksum verification failed.")}function Ge(t,e){se(t,{recursive:!0});let r=d.join(t,"current"),n=`${r}.tmp-${process.pid}-${Date.now()}`;le(n,`${e}
2
+ import{a as y,c as M,d as p}from"./chunk-NICEDCLM.js";import{b as ie}from"./chunk-FKQFVOLR.js";import{a as q,b as C,c as ee,e as te,f as I,h as re,i as ne}from"./chunk-3MHUE4DM.js";import{a as A,b as U,c as _,d as F,e as K,f as V,k as z,m as b,n as H,p as x,q as X,r as G,s as Y,t as Z,w as W,x as Q}from"./chunk-RDUENEEQ.js";import{a as Oe}from"./chunk-HQ2U4QVQ.js";import{n as S}from"./chunk-3FETZOUF.js";import{e as Le}from"./chunk-D76SO2ME.js";var pe=Le(Oe(),1);import{createHash as De}from"node:crypto";import{existsSync as k,mkdirSync as se,readFileSync as v,renameSync as ce,rmSync as de,writeFileSync as le}from"node:fs";import{homedir as Je}from"node:os";import d from"node:path";var Be="https://algeng-ali-shanghai-agent-02.oss-cn-shanghai.aliyuncs.com/minimax-dialogue/data/env/.npm-global/mcode",je=8e3,$=class{currentVersion;installRoot;releaseBaseUrl;publicKey;environment;dependencies;constructor(e){this.currentVersion=U(e.currentVersion),this.installRoot=e.installRoot??L(e.environment),this.releaseBaseUrl=(e.releaseBaseUrl??Be).replace(/\/+$/u,""),this.publicKey=e.publicKey,this.environment=e.environment??process.env,this.dependencies={fetchBytes:Ke,installArtifact:ze,validateInstalledVersion:He,...e.dependencies}}async check(e={}){M(e.signal),p(e,"checking",!0);let r=e.channel?A(e.channel):_e(this.installRoot),n=e.version?U(e.version):void 0,i=n?`${this.releaseBaseUrl}/releases/${encodeURIComponent(n)}/manifest.json`:`${this.releaseBaseUrl}/channels/${r}.json`,o=this.publicKey??Fe(this.installRoot,this.environment),a=ae(e.timeoutMs),s=new AbortController,c=oe(e.signal,s),f=!1,l=setTimeout(()=>{f=!0,s.abort(new Error(`MCode update check timed out after ${a}ms.`))},a);l.unref?.();try{let[u,h]=await Promise.all([this.dependencies.fetchBytes(i,{signal:s.signal,proxyEnvironment:this.environment}),this.dependencies.fetchBytes(`${i}.sig`,{signal:s.signal,proxyEnvironment:this.environment})]),g=_(u,h.toString("utf8"),o);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}.`);K(g,F());let m=V(this.currentVersion,g.version);return{status:m<0?"available":m>0?"ahead":"current",channel:r,currentVersion:this.currentVersion,latestVersion:g.version,manifest:g}}catch(u){throw e.signal?.aborted?new y:f?new Error(`MCode update check timed out after ${a}ms.`,{cause:u}):u}finally{clearTimeout(l),c()}}async apply(e={}){let r=await this.check(e);if(r.status==="current")return{...r,applied:!1,installRoot:this.installRoot};if(r.status==="ahead"&&!e.version)throw new Error(`Installed MCode ${this.currentVersion} is newer than ${r.channel} ${r.latestVersion}; pass --to to downgrade explicitly.`);let n=ae(e.timeoutMs);M(e.signal),p(e,"downloading",!0);let i=new AbortController,o=oe(e.signal,i),a=!1,s=setTimeout(()=>{a=!0,i.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:i.signal,proxyEnvironment:this.environment})}catch(m){throw e.signal?.aborted?new y:a?new Error(`MCode artifact download timed out after ${n}ms.`,{cause:m}):m}finally{clearTimeout(s),o()}M(e.signal),Xe(c,r.manifest);let f=d.join(this.installRoot,"versions"),l=d.join(f,r.latestVersion),u=d.join(f,`.staging-${r.latestVersion}-${process.pid}-${Date.now()}`),h=d.join(u,`minimax-mcode-${r.latestVersion}.tgz`);se(u,{recursive:!0});let g=!1;try{return p(e,"staging",!0),M(e.signal),le(h,c,{mode:384}),M(e.signal),p(e,"installing",!1),await this.dependencies.installArtifact({artifact:h,prefix:u,registry:r.manifest.registry,proxyEnvironment:this.environment}),M(e.signal),S(()=>de(h,{force:!0})),p(e,"validating",!1),await this.dependencies.validateInstalledVersion(u,r.latestVersion),M(e.signal),p(e,"activating",!1),k(l)?(await this.dependencies.validateInstalledVersion(l,r.latestVersion),T(u)):(S(()=>ce(u,l)),g=!0),Ge(this.installRoot,r.latestVersion),p(e,"completed",!1),{...r,applied:!0,installRoot:this.installRoot}}catch(m){throw T(u),g&&Ye(this.installRoot)!==r.latestVersion&&T(l),m instanceof y||e.signal?.aborted?new y:new Error(`MCode ${r.latestVersion} was not activated; the previous version is unchanged: ${ge(m)}`,{cause:m})}}};function L(t=process.env){if(t.MCODE_INSTALL_ROOT)return d.resolve(t.MCODE_INSTALL_ROOT);if(process.platform==="win32"){let r=t.LOCALAPPDATA;if(!r)throw new Error("LOCALAPPDATA is required to resolve the MCode install root.");return d.join(r,"MinimaxCode")}let e=t.XDG_DATA_HOME||d.join(Je(),".local","share");return d.join(e,"minimax-code")}function _e(t){let e=d.join(t,"update.json");if(!k(e))return"stable";let r;try{r=JSON.parse(v(e,"utf8"))}catch(n){throw new Error(`MCode update channel config is invalid: ${ge(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 A(r.channel)}function Fe(t,e){let r=e.MCODE_RELEASE_PUBLIC_KEY_FILE;if(r)return v(d.resolve(r),"utf8");let n=d.join(t,"install.json");if(!k(n))throw new Error("MCode update trust root is missing. Install with the official Shell/PowerShell installer first.");let i=JSON.parse(v(n,"utf8"));if(typeof i.publicKey!="string"||!i.publicKey.includes("BEGIN PUBLIC KEY"))throw new Error("MCode installer metadata does not contain a valid release public key.");return i.publicKey}function ae(t){if(t===void 0)return je;if(!Number.isSafeInteger(t)||t<100||t>6e4)throw new Error("MCode update timeout must be an integer between 100 and 60000 milliseconds.");return t}async function Ke(t,e={}){let[{default:r},{createTuiNetworkDispatcher:n}]=await Promise.all([import("./undici-75A6L7DQ.js"),import("./network-proxy-D4QGWYR5.js")]),i=n(e.proxyEnvironment);try{let o=await r.fetch(t,{signal:e.signal,dispatcher:i,redirect:"error"});if(!o.ok)throw new Error(`MCode release server returned HTTP ${o.status} for ${t}`);return Buffer.from(await o.arrayBuffer())}finally{await i.close()}}async function ze(t){let e=process.platform==="win32"?"npm.cmd":"npm";await ue(e,["install","--global","--prefix",t.prefix,t.artifact,"--registry",t.registry,"--no-audit","--no-fund","--package-lock=false"],t.proxyEnvironment,!0)}async function He(t,e){let r=d.join(t,"bin","mcode"),n=["--version"];if(process.platform==="win32"){let o=q(t,b().packageName),a=JSON.parse(v(d.join(o,"package.json"),"utf8")),s=ne(a.bin,"mcode");if(!s||!k(d.join(t,"mcode.cmd")))throw new Error(`Installed MCode launcher is missing or invalid at ${t}.`);r=process.execPath,n=[d.join(o,s),"--version"]}let i=await ue(r,n,process.env,!0);if(i.trim()!==e)throw new Error(`Installed MCode version mismatch: expected ${e}, got ${i.trim()}`)}function ue(t,e,r,n=!1){return new Promise((i,o)=>{let a=!1,s=(0,pe.default)(t,e,{env:r,shell:!1,stdio:n?["ignore","pipe","pipe"]:"inherit",windowsHide:!0}),c=[],f=[];s.stdout?.on("data",l=>c.push(l)),s.stderr?.on("data",l=>f.push(l)),s.once("error",l=>{a||(a=!0,o(l))}),s.once("close",(l,u)=>{if(a)return;if(a=!0,l===0)return i(Buffer.concat(c).toString("utf8"));let h=Buffer.concat(f).toString("utf8").trim();o(new Error(`${t} failed (${u?`signal ${u}`:`exit ${String(l)}`})${h?`: ${h}`:""}`))})})}function oe(t,e){if(!t)return()=>{};let r=()=>e.abort(t.reason);return t.aborted?r():t.addEventListener("abort",r,{once:!0}),()=>t.removeEventListener("abort",r)}function Xe(t,e){if(t.length!==e.installArtifact.size)throw new Error(`MCode artifact checksum/size verification failed: expected ${e.installArtifact.size} bytes, got ${t.length}.`);if(De("sha256").update(t).digest("hex")!==e.installArtifact.sha256)throw new Error("MCode artifact checksum verification failed.")}function Ge(t,e){se(t,{recursive:!0});let r=d.join(t,"current"),n=`${r}.tmp-${process.pid}-${Date.now()}`;le(n,`${e}
3
3
  `,{mode:384}),S(()=>ce(n,r))}function T(t){de(t,{recursive:!0,force:!0,maxRetries:4,retryDelay:50})}function Ye(t){let e=d.join(t,"current");if(k(e))return v(e,"utf8").trim()||void 0}function ge(t){return t instanceof Error?t.message:String(t)}function kt(t=process.env){return"A staged MCode update will activate after this process exits."}function wt(t=process.env){return"MCode update was staged, but its activation journal could not be scheduled."}function fe(t){return"MCode npm prefix updater received a non-prefix plan."}function me(t){return"MCode npm prefix ownership metadata is missing."}function he(t,e={}){if(e.blockingSessionCount===void 0)return`MCode ${t} is already staged. Restarting will resume activation after running MCode sessions exit.`;let r=Math.max(0,Math.trunc(e.blockingSessionCount));return r>0?`MCode ${t} is already staged. Activation will wait for ${String(r)} other MCode ${r===1?"session":"sessions"} to exit.`:`MCode ${t} is already staged. It will activate after this process exits.`}function Me(t,e={}){if(e.blockingSessionCount===void 0)return`MCode ${t} is already active. Restarting will finish update cleanup after running MCode sessions exit.`;let r=Math.max(0,Math.trunc(e.blockingSessionCount));return r>0?`MCode ${t} is already active. Update cleanup will wait for ${String(r)} other MCode ${r===1?"session":"sessions"} to exit.`:`MCode ${t} is already active. Restarting will finish update cleanup.`}function Pe(t,e,r){return`MCode update staged ${t}; expected ${e}.`}function xe(t,e=process.env){let r=e.LC_ALL||e.LC_MESSAGES||e.LANG;return ie(r,"update.versionedInstalled").replace("{version}",t)}function ye(t,e,r){return`MCode ${t} was not staged; the active installation is unchanged: ${e}`}import{randomUUID as R}from"node:crypto";import{chmodSync as Ze,existsSync as O,mkdirSync as N,readdirSync as We,readFileSync as B,renameSync as Se,rmSync as D,writeFileSync as Ve}from"node:fs";import P from"node:path";var j="releases",be="current",Qe=".mcode-update.lock",qe=2;function Ce(t,e,r=process.platform){return E(r).join(t,j,`.staging-${e}-${process.pid}-${R()}`)}function $e(t){N(t,{recursive:!0,mode:448})}function Re(t){let e=P.join(t,Qe);N(e,{recursive:!0,mode:448});let r=`${String(process.pid)}-${R()}.claim`,n=P.join(e,r);Ve(n,`choosing
4
4
  `,{flag:"wx",mode:384});try{let o=Math.max(0,...ke(e).map(s=>s.ticket??0))+1;if(w(n,`${String(o)}
5
5
  `,384),ke(e).some(s=>s.name!==r&&(s.ticket===void 0||s.ticket<o||s.ticket===o&&(s.pid<process.pid||s.pid===process.pid&&s.name.localeCompare(r)<0))))throw new Error("Another MCode update is already running.")}catch(o){throw D(n,{force:!0}),o}let i=!1;return()=>{i||(i=!0,D(n,{force:!0}))}}function Ne(t,e=process.platform){let r=E(e),n=r.join(t.activePrefix,j),i=Ae(t.stagingPrefix,t,e);et(t.stagingPrefix,i,t.runtimeExecutable,e),ve(t.stagingPrefix,t,e),N(n,{recursive:!0,mode:448});let o=t.expectedVersion,a=r.join(n,o);return O(a)&&(o=`${t.expectedVersion}-repair-${R()}`,a=r.join(n,o)),Se(t.stagingPrefix,a),ve(a,t,e),nt(t,e),rt(t.activePrefix,e)||tt(t.activePrefix,e),w(r.join(t.activePrefix,be),`${o}
@@ -1,2 +1,2 @@
1
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{b as i,c as n,d as o,h as a,i as r}from"./chunk-C2QIYD6E.js";function s(t){let e=i({dataDir:t.dataDir,buildEnv:t.buildEnv,region:t.region}),u=t.oauthClient??h(t.oauthEndpoints),d=r({authHome:e.namespaceHome});return new a({namespace:e,oauthClient:u,credentialStore:d,initialize:()=>n(e)})}function h(t){if(!t)throw new TypeError("Shared MCode OAuth requires explicit device authorization, token, and revocation endpoints.");return new o(t)}export{s as a};
2
+ import{b as i,c as n,d as o,h as a,i as r}from"./chunk-JL7ZXU6T.js";function s(t){let e=i({dataDir:t.dataDir,buildEnv:t.buildEnv,region:t.region}),u=t.oauthClient??h(t.oauthEndpoints),d=r({authHome:e.namespaceHome});return new a({namespace:e,oauthClient:u,credentialStore:d,initialize:()=>n(e)})}function h(t){if(!t)throw new TypeError("Shared MCode OAuth requires explicit device authorization, token, and revocation endpoints.");return new o(t)}export{s as a};
@@ -1,2 +1,2 @@
1
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{l as i,n as D}from"./chunk-C2QIYD6E.js";import{ua as a,y as n}from"./chunk-AVYSGYVY.js";function o(t,r=n,e=a){return r(void 0,e())}function u(){return o(i())}function m(t){let r=t.MINIMAX_DATA_DIR?.trim();return r||t.MAVIS_DATA_DIR?.trim()||void 0}function f(t=process.env,r=u){return m(t)??r()}function v(t=u,r=process.env){return f(r,t)}function p(t={}){let r=(t.getBuildEnv??i)(),e=v(t.getDefaultDataDir??(()=>o(r)),t.environment??process.env);return(t.configureRuntimeEnvironment??D)({dataDir:e}),Promise.resolve(e)}export{o as a,f as b,v as c,p as d};
2
+ import{l as i,n as D}from"./chunk-JL7ZXU6T.js";import{ua as a,y as n}from"./chunk-TWO6GIVD.js";function o(t,r=n,e=a){return r(void 0,e())}function u(){return o(i())}function m(t){let r=t.MINIMAX_DATA_DIR?.trim();return r||t.MAVIS_DATA_DIR?.trim()||void 0}function f(t=process.env,r=u){return m(t)??r()}function v(t=u,r=process.env){return f(r,t)}function p(t={}){let r=(t.getBuildEnv??i)(),e=v(t.getDefaultDataDir??(()=>o(r)),t.environment??process.env);return(t.configureRuntimeEnvironment??D)({dataDir:e}),Promise.resolve(e)}export{o as a,f as b,v as c,p as d};
@@ -1,5 +1,5 @@
1
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{n as Or}from"./chunk-Z4VKGZFA.js";import{a as ue,c as S,e as Cr}from"./chunk-D76SO2ME.js";var Gl=S((S_,Yl)=>{var Ne=ue("constants"),Ay=process.cwd,Wn=null,wy=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Wn||(Wn=Ay.call(process)),Wn};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Kr=process.chdir,process.chdir=function(e){Wn=null,Kr.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Kr));var Kr;Yl.exports=_y;function _y(e){Ne.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=r(e.chmodSync),e.fchmodSync=r(e.fchmodSync),e.lchmodSync=r(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=l(e.statSync),e.fstatSync=l(e.fstatSync),e.lstatSync=l(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,f,d){d&&process.nextTick(d)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,f,d,p){p&&process.nextTick(p)},e.lchownSync=function(){}),wy==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function f(d,p,h){var m=Date.now(),y=0;u(d,p,function g(b){if(b&&(b.code==="EACCES"||b.code==="EPERM"||b.code==="EBUSY")&&Date.now()-m<6e4){setTimeout(function(){e.stat(p,function(v,x){v&&v.code==="ENOENT"?u(d,p,g):h(b)})},y),y<100&&(y+=10);return}h&&h(b)})}return Object.setPrototypeOf&&Object.setPrototypeOf(f,u),f})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function f(d,p,h,m,y,g){var b;if(g&&typeof g=="function"){var v=0;b=function(x,k,C){if(x&&x.code==="EAGAIN"&&v<10)return v++,u.call(e,d,p,h,m,y,b);g.apply(this,arguments)}}return u.call(e,d,p,h,m,y,b)}return Object.setPrototypeOf&&Object.setPrototypeOf(f,u),f})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(f,d,p,h,m){for(var y=0;;)try{return u.call(e,f,d,p,h,m)}catch(g){if(g.code==="EAGAIN"&&y<10){y++;continue}throw g}}})(e.readSync);function t(u){u.lchmod=function(f,d,p){u.open(f,Ne.O_WRONLY|Ne.O_SYMLINK,d,function(h,m){if(h){p&&p(h);return}u.fchmod(m,d,function(y){u.close(m,function(g){p&&p(y||g)})})})},u.lchmodSync=function(f,d){var p=u.openSync(f,Ne.O_WRONLY|Ne.O_SYMLINK,d),h=!0,m;try{m=u.fchmodSync(p,d),h=!1}finally{if(h)try{u.closeSync(p)}catch{}else u.closeSync(p)}return m}}function n(u){Ne.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(f,d,p,h){u.open(f,Ne.O_SYMLINK,function(m,y){if(m){h&&h(m);return}u.futimes(y,d,p,function(g){u.close(y,function(b){h&&h(g||b)})})})},u.lutimesSync=function(f,d,p){var h=u.openSync(f,Ne.O_SYMLINK),m,y=!0;try{m=u.futimesSync(h,d,p),y=!1}finally{if(y)try{u.closeSync(h)}catch{}else u.closeSync(h)}return m}):u.futimes&&(u.lutimes=function(f,d,p,h){h&&process.nextTick(h)},u.lutimesSync=function(){})}function i(u){return u&&function(f,d,p){return u.call(e,f,d,function(h){c(h)&&(h=null),p&&p.apply(this,arguments)})}}function r(u){return u&&function(f,d){try{return u.call(e,f,d)}catch(p){if(!c(p))throw p}}}function o(u){return u&&function(f,d,p,h){return u.call(e,f,d,p,function(m){c(m)&&(m=null),h&&h.apply(this,arguments)})}}function s(u){return u&&function(f,d,p){try{return u.call(e,f,d,p)}catch(h){if(!c(h))throw h}}}function a(u){return u&&function(f,d,p){typeof d=="function"&&(p=d,d=null);function h(m,y){y&&(y.uid<0&&(y.uid+=4294967296),y.gid<0&&(y.gid+=4294967296)),p&&p.apply(this,arguments)}return d?u.call(e,f,d,h):u.call(e,f,h)}}function l(u){return u&&function(f,d){var p=d?u.call(e,f,d):u.call(e,f);return p&&(p.uid<0&&(p.uid+=4294967296),p.gid<0&&(p.gid+=4294967296)),p}}function c(u){if(!u||u.code==="ENOSYS")return!0;var f=!process.getuid||process.getuid()!==0;return!!(f&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var Jl=S((v_,Hl)=>{var Wl=ue("stream").Stream;Hl.exports=Ey;function Ey(e){return{ReadStream:t,WriteStream:n};function t(i,r){if(!(this instanceof t))return new t(i,r);Wl.call(this);var o=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,r=r||{};for(var s=Object.keys(r),a=0,l=s.length;a<l;a++){var c=s[a];this[c]=r[c]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(u,f){if(u){o.emit("error",u),o.readable=!1;return}o.fd=f,o.emit("open",f),o._read()})}function n(i,r){if(!(this instanceof n))return new n(i,r);Wl.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var o=Object.keys(r),s=0,a=o.length;s<a;s++){var l=o[s];this[l]=r[l]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Ql=S((A_,Xl)=>{"use strict";Xl.exports=ky;var xy=Object.getPrototypeOf||function(e){return e.__proto__};function ky(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:xy(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}});var Wr=S((w_,Gr)=>{var D=ue("fs"),Cy=Gl(),Oy=Jl(),Ty=Ql(),Hn=ue("util"),Z,Xn;typeof Symbol=="function"&&typeof Symbol.for=="function"?(Z=Symbol.for("graceful-fs.queue"),Xn=Symbol.for("graceful-fs.previous")):(Z="___graceful-fs.queue",Xn="___graceful-fs.previous");function Iy(){}function ec(e,t){Object.defineProperty(e,Z,{get:function(){return t}})}var Ze=Iy;Hn.debuglog?Ze=Hn.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Ze=function(){var e=Hn.format.apply(Hn,arguments);e="GFS4: "+e.split(/\n/).join(`
2
+ import{n as Or}from"./chunk-3FETZOUF.js";import{a as ue,c as S,e as Cr}from"./chunk-D76SO2ME.js";var Gl=S((S_,Yl)=>{var Ne=ue("constants"),Ay=process.cwd,Wn=null,wy=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Wn||(Wn=Ay.call(process)),Wn};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Kr=process.chdir,process.chdir=function(e){Wn=null,Kr.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Kr));var Kr;Yl.exports=_y;function _y(e){Ne.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=r(e.chmodSync),e.fchmodSync=r(e.fchmodSync),e.lchmodSync=r(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=l(e.statSync),e.fstatSync=l(e.fstatSync),e.lstatSync=l(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,f,d){d&&process.nextTick(d)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,f,d,p){p&&process.nextTick(p)},e.lchownSync=function(){}),wy==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function f(d,p,h){var m=Date.now(),y=0;u(d,p,function g(b){if(b&&(b.code==="EACCES"||b.code==="EPERM"||b.code==="EBUSY")&&Date.now()-m<6e4){setTimeout(function(){e.stat(p,function(v,x){v&&v.code==="ENOENT"?u(d,p,g):h(b)})},y),y<100&&(y+=10);return}h&&h(b)})}return Object.setPrototypeOf&&Object.setPrototypeOf(f,u),f})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function f(d,p,h,m,y,g){var b;if(g&&typeof g=="function"){var v=0;b=function(x,k,C){if(x&&x.code==="EAGAIN"&&v<10)return v++,u.call(e,d,p,h,m,y,b);g.apply(this,arguments)}}return u.call(e,d,p,h,m,y,b)}return Object.setPrototypeOf&&Object.setPrototypeOf(f,u),f})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(f,d,p,h,m){for(var y=0;;)try{return u.call(e,f,d,p,h,m)}catch(g){if(g.code==="EAGAIN"&&y<10){y++;continue}throw g}}})(e.readSync);function t(u){u.lchmod=function(f,d,p){u.open(f,Ne.O_WRONLY|Ne.O_SYMLINK,d,function(h,m){if(h){p&&p(h);return}u.fchmod(m,d,function(y){u.close(m,function(g){p&&p(y||g)})})})},u.lchmodSync=function(f,d){var p=u.openSync(f,Ne.O_WRONLY|Ne.O_SYMLINK,d),h=!0,m;try{m=u.fchmodSync(p,d),h=!1}finally{if(h)try{u.closeSync(p)}catch{}else u.closeSync(p)}return m}}function n(u){Ne.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(f,d,p,h){u.open(f,Ne.O_SYMLINK,function(m,y){if(m){h&&h(m);return}u.futimes(y,d,p,function(g){u.close(y,function(b){h&&h(g||b)})})})},u.lutimesSync=function(f,d,p){var h=u.openSync(f,Ne.O_SYMLINK),m,y=!0;try{m=u.futimesSync(h,d,p),y=!1}finally{if(y)try{u.closeSync(h)}catch{}else u.closeSync(h)}return m}):u.futimes&&(u.lutimes=function(f,d,p,h){h&&process.nextTick(h)},u.lutimesSync=function(){})}function i(u){return u&&function(f,d,p){return u.call(e,f,d,function(h){c(h)&&(h=null),p&&p.apply(this,arguments)})}}function r(u){return u&&function(f,d){try{return u.call(e,f,d)}catch(p){if(!c(p))throw p}}}function o(u){return u&&function(f,d,p,h){return u.call(e,f,d,p,function(m){c(m)&&(m=null),h&&h.apply(this,arguments)})}}function s(u){return u&&function(f,d,p){try{return u.call(e,f,d,p)}catch(h){if(!c(h))throw h}}}function a(u){return u&&function(f,d,p){typeof d=="function"&&(p=d,d=null);function h(m,y){y&&(y.uid<0&&(y.uid+=4294967296),y.gid<0&&(y.gid+=4294967296)),p&&p.apply(this,arguments)}return d?u.call(e,f,d,h):u.call(e,f,h)}}function l(u){return u&&function(f,d){var p=d?u.call(e,f,d):u.call(e,f);return p&&(p.uid<0&&(p.uid+=4294967296),p.gid<0&&(p.gid+=4294967296)),p}}function c(u){if(!u||u.code==="ENOSYS")return!0;var f=!process.getuid||process.getuid()!==0;return!!(f&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var Jl=S((v_,Hl)=>{var Wl=ue("stream").Stream;Hl.exports=Ey;function Ey(e){return{ReadStream:t,WriteStream:n};function t(i,r){if(!(this instanceof t))return new t(i,r);Wl.call(this);var o=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,r=r||{};for(var s=Object.keys(r),a=0,l=s.length;a<l;a++){var c=s[a];this[c]=r[c]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(u,f){if(u){o.emit("error",u),o.readable=!1;return}o.fd=f,o.emit("open",f),o._read()})}function n(i,r){if(!(this instanceof n))return new n(i,r);Wl.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var o=Object.keys(r),s=0,a=o.length;s<a;s++){var l=o[s];this[l]=r[l]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Ql=S((A_,Xl)=>{"use strict";Xl.exports=ky;var xy=Object.getPrototypeOf||function(e){return e.__proto__};function ky(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:xy(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}});var Wr=S((w_,Gr)=>{var D=ue("fs"),Cy=Gl(),Oy=Jl(),Ty=Ql(),Hn=ue("util"),Z,Xn;typeof Symbol=="function"&&typeof Symbol.for=="function"?(Z=Symbol.for("graceful-fs.queue"),Xn=Symbol.for("graceful-fs.previous")):(Z="___graceful-fs.queue",Xn="___graceful-fs.previous");function Iy(){}function ec(e,t){Object.defineProperty(e,Z,{get:function(){return t}})}var Ze=Iy;Hn.debuglog?Ze=Hn.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Ze=function(){var e=Hn.format.apply(Hn,arguments);e="GFS4: "+e.split(/\n/).join(`
3
3
  GFS4: `),console.error(e)});D[Z]||(zl=global[Z]||[],ec(D,zl),D.close=(function(e){function t(n,i){return e.call(D,n,function(r){r||Zl(),typeof i=="function"&&i.apply(this,arguments)})}return Object.defineProperty(t,Xn,{value:e}),t})(D.close),D.closeSync=(function(e){function t(n){e.apply(D,arguments),Zl()}return Object.defineProperty(t,Xn,{value:e}),t})(D.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Ze(D[Z]),ue("assert").equal(D[Z].length,0)}));var zl;global[Z]||ec(global,D[Z]);Gr.exports=Vr(Ty(D));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!D.__patched&&(Gr.exports=Vr(D),D.__patched=!0);function Vr(e){Cy(e),e.gracefulify=Vr,e.createReadStream=k,e.createWriteStream=C;var t=e.readFile;e.readFile=n;function n(A,O,E){return typeof O=="function"&&(E=O,O=null),T(A,O,E);function T($,W,F,q){return t($,W,function(N){N&&(N.code==="EMFILE"||N.code==="ENFILE")?bt([T,[$,W,F],N,q||Date.now(),Date.now()]):typeof F=="function"&&F.apply(this,arguments)})}}var i=e.writeFile;e.writeFile=r;function r(A,O,E,T){return typeof E=="function"&&(T=E,E=null),$(A,O,E,T);function $(W,F,q,N,Q){return i(W,F,q,function(R){R&&(R.code==="EMFILE"||R.code==="ENFILE")?bt([$,[W,F,q,N],R,Q||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=s);function s(A,O,E,T){return typeof E=="function"&&(T=E,E=null),$(A,O,E,T);function $(W,F,q,N,Q){return o(W,F,q,function(R){R&&(R.code==="EMFILE"||R.code==="ENFILE")?bt([$,[W,F,q,N],R,Q||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}var a=e.copyFile;a&&(e.copyFile=l);function l(A,O,E,T){return typeof E=="function"&&(T=E,E=0),$(A,O,E,T);function $(W,F,q,N,Q){return a(W,F,q,function(R){R&&(R.code==="EMFILE"||R.code==="ENFILE")?bt([$,[W,F,q,N],R,Q||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}var c=e.readdir;e.readdir=f;var u=/^v[0-5]\./;function f(A,O,E){typeof O=="function"&&(E=O,O=null);var T=u.test(process.version)?function(F,q,N,Q){return c(F,$(F,q,N,Q))}:function(F,q,N,Q){return c(F,q,$(F,q,N,Q))};return T(A,O,E);function $(W,F,q,N){return function(Q,R){Q&&(Q.code==="EMFILE"||Q.code==="ENFILE")?bt([T,[W,F,q],Q,N||Date.now(),Date.now()]):(R&&R.sort&&R.sort(),typeof q=="function"&&q.call(this,Q,R))}}}if(process.version.substr(0,4)==="v0.8"){var d=Oy(e);g=d.ReadStream,v=d.WriteStream}var p=e.ReadStream;p&&(g.prototype=Object.create(p.prototype),g.prototype.open=b);var h=e.WriteStream;h&&(v.prototype=Object.create(h.prototype),v.prototype.open=x),Object.defineProperty(e,"ReadStream",{get:function(){return g},set:function(A){g=A},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return v},set:function(A){v=A},enumerable:!0,configurable:!0});var m=g;Object.defineProperty(e,"FileReadStream",{get:function(){return m},set:function(A){m=A},enumerable:!0,configurable:!0});var y=v;Object.defineProperty(e,"FileWriteStream",{get:function(){return y},set:function(A){y=A},enumerable:!0,configurable:!0});function g(A,O){return this instanceof g?(p.apply(this,arguments),this):g.apply(Object.create(g.prototype),arguments)}function b(){var A=this;w(A.path,A.flags,A.mode,function(O,E){O?(A.autoClose&&A.destroy(),A.emit("error",O)):(A.fd=E,A.emit("open",E),A.read())})}function v(A,O){return this instanceof v?(h.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function x(){var A=this;w(A.path,A.flags,A.mode,function(O,E){O?(A.destroy(),A.emit("error",O)):(A.fd=E,A.emit("open",E))})}function k(A,O){return new e.ReadStream(A,O)}function C(A,O){return new e.WriteStream(A,O)}var L=e.open;e.open=w;function w(A,O,E,T){return typeof E=="function"&&(T=E,E=null),$(A,O,E,T);function $(W,F,q,N,Q){return L(W,F,q,function(R,d_){R&&(R.code==="EMFILE"||R.code==="ENFILE")?bt([$,[W,F,q,N],R,Q||Date.now(),Date.now()]):typeof N=="function"&&N.apply(this,arguments)})}}return e}function bt(e){Ze("ENQUEUE",e[0].name,e[1]),D[Z].push(e),Yr()}var Jn;function Zl(){for(var e=Date.now(),t=0;t<D[Z].length;++t)D[Z][t].length>2&&(D[Z][t][3]=e,D[Z][t][4]=e);Yr()}function Yr(){if(clearTimeout(Jn),Jn=void 0,D[Z].length!==0){var e=D[Z].shift(),t=e[0],n=e[1],i=e[2],r=e[3],o=e[4];if(r===void 0)Ze("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-r>=6e4){Ze("TIMEOUT",t.name,n);var s=n.pop();typeof s=="function"&&s.call(null,i)}else{var a=Date.now()-o,l=Math.max(o-r,1),c=Math.min(l*1.2,100);a>=c?(Ze("RETRY",t.name,n),t.apply(null,n.concat([r]))):D[Z].push(e)}Jn===void 0&&(Jn=setTimeout(Yr,0))}}});var nc=S((__,tc)=>{function fe(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}tc.exports=fe;fe.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};fe.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};fe.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var i=this,r=setTimeout(function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout(function(){i._operationTimeoutCb(i._attempts)},i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)},n);return this._options.unref&&r.unref(),!0};fe.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};fe.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};fe.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};fe.prototype.start=fe.prototype.try;fe.prototype.errors=function(){return this._errors};fe.prototype.attempts=function(){return this._attempts};fe.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,i=0;i<this._errors.length;i++){var r=this._errors[i],o=r.message,s=(e[o]||0)+1;e[o]=s,s>=n&&(t=r,n=s)}return t}});var ic=S(et=>{var Ly=nc();et.operation=function(e){var t=et.timeouts(e);return new Ly(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};et.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var i=[],r=0;r<t.retries;r++)i.push(this.createTimeout(r,t));return e&&e.forever&&!i.length&&i.push(this.createTimeout(r,t)),i.sort(function(o,s){return o-s}),i};et.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return i=Math.min(i,t.maxTimeout),i};et.wrap=function(e,t,n){if(t instanceof Array&&(n=t,t=null),!n){n=[];for(var i in e)typeof e[i]=="function"&&n.push(i)}for(var r=0;r<n.length;r++){var o=n[r],s=e[o];e[o]=function(l){var c=et.operation(t),u=Array.prototype.slice.call(arguments,1),f=u.pop();u.push(function(d){c.retry(d)||(d&&(arguments[0]=c.mainError()),f.apply(this,arguments))}),c.attempt(function(){l.apply(e,u)})}.bind(e,s),e[o].options=t}}});var oc=S((x_,rc)=>{rc.exports=ic()});var sc=S((k_,Qn)=>{Qn.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Qn.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Qn.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var fc=S((C_,At)=>{var P=global.process,tt=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};tt(P)?(ac=ue("assert"),St=sc(),lc=/^win/i.test(P.platform),zt=ue("events"),typeof zt!="function"&&(zt=zt.EventEmitter),P.__signal_exit_emitter__?J=P.__signal_exit_emitter__:(J=P.__signal_exit_emitter__=new zt,J.count=0,J.emitted={}),J.infinite||(J.setMaxListeners(1/0),J.infinite=!0),At.exports=function(e,t){if(!tt(global.process))return function(){};ac.equal(typeof e,"function","a callback must be provided for exit handler"),vt===!1&&Hr();var n="exit";t&&t.alwaysLast&&(n="afterexit");var i=function(){J.removeListener(n,e),J.listeners("exit").length===0&&J.listeners("afterexit").length===0&&zn()};return J.on(n,e),i},zn=function(){!vt||!tt(global.process)||(vt=!1,St.forEach(function(t){try{P.removeListener(t,Zn[t])}catch{}}),P.emit=ei,P.reallyExit=Jr,J.count-=1)},At.exports.unload=zn,nt=function(t,n,i){J.emitted[t]||(J.emitted[t]=!0,J.emit(t,n,i))},Zn={},St.forEach(function(e){Zn[e]=function(){if(tt(global.process)){var n=P.listeners(e);n.length===J.count&&(zn(),nt("exit",null,e),nt("afterexit",null,e),lc&&e==="SIGHUP"&&(e="SIGINT"),P.kill(P.pid,e))}}}),At.exports.signals=function(){return St},vt=!1,Hr=function(){vt||!tt(global.process)||(vt=!0,J.count+=1,St=St.filter(function(t){try{return P.on(t,Zn[t]),!0}catch{return!1}}),P.emit=uc,P.reallyExit=cc)},At.exports.load=Hr,Jr=P.reallyExit,cc=function(t){tt(global.process)&&(P.exitCode=t||0,nt("exit",P.exitCode,null),nt("afterexit",P.exitCode,null),Jr.call(P,P.exitCode))},ei=P.emit,uc=function(t,n){if(t==="exit"&&tt(global.process)){n!==void 0&&(P.exitCode=n);var i=ei.apply(this,arguments);return nt("exit",P.exitCode,null),nt("afterexit",P.exitCode,null),i}else return ei.apply(this,arguments)}):At.exports=function(){return function(){}};var ac,St,lc,zt,J,zn,nt,Zn,vt,Hr,Jr,cc,ei,uc});var pc=S((O_,Xr)=>{"use strict";var dc=Symbol();function My(e,t,n){let i=t[dc];if(i)return t.stat(e,(o,s)=>{if(o)return n(o);n(null,s.mtime,i)});let r=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,r,r,o=>{if(o)return n(o);t.stat(e,(s,a)=>{if(s)return n(s);let l=a.mtime.getTime()%1e3===0?"s":"ms";Object.defineProperty(t,dc,{value:l}),n(null,a.mtime,l)})})}function Ny(e){let t=Date.now();return e==="s"&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}Xr.exports.probe=My;Xr.exports.getMtime=Ny});var bc=S((T_,en)=>{"use strict";var Ry=ue("path"),Zr=Wr(),Py=oc(),Fy=fc(),mc=pc(),Ee={};function Zt(e,t){return t.lockfilePath||`${e}.lock`}function eo(e,t,n){if(!t.realpath)return n(null,Ry.resolve(e));t.fs.realpath(e,n)}function zr(e,t,n){let i=Zt(e,t);t.fs.mkdir(i,r=>{if(!r)return mc.probe(i,t.fs,(o,s,a)=>{if(o)return t.fs.rmdir(i,()=>{}),n(o);n(null,s,a)});if(r.code!=="EEXIST")return n(r);if(t.stale<=0)return n(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:e}));t.fs.stat(i,(o,s)=>{if(o)return o.code==="ENOENT"?zr(e,{...t,stale:0},n):n(o);if(!hc(s,t))return n(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:e}));yc(e,t,a=>{if(a)return n(a);zr(e,{...t,stale:0},n)})})})}function hc(e,t){return e.mtime.getTime()<Date.now()-t.stale}function yc(e,t,n){t.fs.rmdir(Zt(e,t),i=>{if(i&&i.code!=="ENOENT")return n(i);n()})}function ti(e,t){let n=Ee[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{n.updateTimeout=null,t.fs.stat(n.lockfilePath,(i,r)=>{let o=n.lastUpdate+t.stale<Date.now();if(i)return i.code==="ENOENT"||o?Qr(e,n,Object.assign(i,{code:"ECOMPROMISED"})):(n.updateDelay=1e3,ti(e,t));if(!(n.mtime.getTime()===r.mtime.getTime()))return Qr(e,n,Object.assign(new Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let a=mc.getMtime(n.mtimePrecision);t.fs.utimes(n.lockfilePath,a,a,l=>{let c=n.lastUpdate+t.stale<Date.now();if(!n.released){if(l)return l.code==="ENOENT"||c?Qr(e,n,Object.assign(l,{code:"ECOMPROMISED"})):(n.updateDelay=1e3,ti(e,t));n.mtime=a,n.lastUpdate=Date.now(),n.updateDelay=null,ti(e,t)}})})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function Qr(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),Ee[e]===t&&delete Ee[e],t.options.onCompromised(n)}function Dy(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:Zr,onCompromised:i=>{throw i},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),eo(e,t,(i,r)=>{if(i)return n(i);let o=Py.operation(t.retries);o.attempt(()=>{zr(r,t,(s,a,l)=>{if(o.retry(s))return;if(s)return n(o.mainError());let c=Ee[r]={lockfilePath:Zt(r,t),mtime:a,mtimePrecision:l,options:t,lastUpdate:Date.now()};ti(r,t),n(null,u=>{if(c.released)return u&&u(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));gc(r,{...t,realpath:!1},u)})})})})}function gc(e,t,n){t={fs:Zr,realpath:!0,...t},eo(e,t,(i,r)=>{if(i)return n(i);let o=Ee[r];if(!o)return n(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete Ee[r],yc(r,t,n)})}function By(e,t,n){t={stale:1e4,realpath:!0,fs:Zr,...t},t.stale=Math.max(t.stale||0,2e3),eo(e,t,(i,r)=>{if(i)return n(i);t.fs.stat(Zt(r,t),(o,s)=>o?o.code==="ENOENT"?n(null,!1):n(o):n(null,!hc(s,t)))})}function qy(){return Ee}Fy(()=>{for(let e in Ee){let t=Ee[e].options;try{t.fs.rmdirSync(Zt(e,t))}catch{}}});en.exports.lock=Dy;en.exports.unlock=gc;en.exports.check=By;en.exports.getLocks=qy});var vc=S((I_,Sc)=>{"use strict";var $y=Wr();function jy(e){let t=["mkdir","realpath","stat","rmdir","utimes"],n={...e};return t.forEach(i=>{n[i]=(...r)=>{let o=r.pop(),s;try{s=e[`${i}Sync`](...r)}catch(a){return o(a)}o(null,s)}}),n}function Uy(e){return(...t)=>new Promise((n,i)=>{t.push((r,o)=>{r?i(r):n(o)}),e(...t)})}function Ky(e){return(...t)=>{let n,i;if(t.push((r,o)=>{n=r,i=o}),e(...t),n)throw n;return i}}function Vy(e){if(e={...e},e.fs=jy(e.fs||$y),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}Sc.exports={toPromise:Uy,toSync:Ky,toSyncOptions:Vy}});var no=S((L_,Re)=>{"use strict";var wt=bc(),{toPromise:ni,toSync:ii,toSyncOptions:to}=vc();async function Ac(e,t){let n=await ni(wt.lock)(e,t);return ni(n)}function Yy(e,t){let n=ii(wt.lock)(e,to(t));return ii(n)}function Gy(e,t){return ni(wt.unlock)(e,t)}function Wy(e,t){return ii(wt.unlock)(e,to(t))}function Hy(e,t){return ni(wt.check)(e,t)}function Jy(e,t){return ii(wt.check)(e,to(t))}Re.exports=Ac;Re.exports.lock=Ac;Re.exports.unlock=Gy;Re.exports.lockSync=Yy;Re.exports.unlockSync=Wy;Re.exports.check=Hy;Re.exports.checkSync=Jy});var I=S(ee=>{"use strict";var oo=Symbol.for("yaml.alias"),Cc=Symbol.for("yaml.document"),ri=Symbol.for("yaml.map"),Oc=Symbol.for("yaml.pair"),so=Symbol.for("yaml.scalar"),oi=Symbol.for("yaml.seq"),xe=Symbol.for("yaml.node.type"),Zy=e=>!!e&&typeof e=="object"&&e[xe]===oo,eg=e=>!!e&&typeof e=="object"&&e[xe]===Cc,tg=e=>!!e&&typeof e=="object"&&e[xe]===ri,ng=e=>!!e&&typeof e=="object"&&e[xe]===Oc,Tc=e=>!!e&&typeof e=="object"&&e[xe]===so,ig=e=>!!e&&typeof e=="object"&&e[xe]===oi;function Ic(e){if(e&&typeof e=="object")switch(e[xe]){case ri:case oi:return!0}return!1}function rg(e){if(e&&typeof e=="object")switch(e[xe]){case oo:case ri:case so:case oi:return!0}return!1}var og=e=>(Tc(e)||Ic(e))&&!!e.anchor;ee.ALIAS=oo;ee.DOC=Cc;ee.MAP=ri;ee.NODE_TYPE=xe;ee.PAIR=Oc;ee.SCALAR=so;ee.SEQ=oi;ee.hasAnchor=og;ee.isAlias=Zy;ee.isCollection=Ic;ee.isDocument=eg;ee.isMap=tg;ee.isNode=rg;ee.isPair=ng;ee.isScalar=Tc;ee.isSeq=ig});var tn=S(ao=>{"use strict";var V=I(),ae=Symbol("break visit"),Lc=Symbol("skip children"),Se=Symbol("remove node");function si(e,t){let n=Mc(t);V.isDocument(e)?xt(null,e.contents,n,Object.freeze([e]))===Se&&(e.contents=null):xt(null,e,n,Object.freeze([]))}si.BREAK=ae;si.SKIP=Lc;si.REMOVE=Se;function xt(e,t,n,i){let r=Nc(e,t,n,i);if(V.isNode(r)||V.isPair(r))return Rc(e,i,r),xt(e,r,n,i);if(typeof r!="symbol"){if(V.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=xt(o,t.items[o],n,i);if(typeof s=="number")o=s-1;else{if(s===ae)return ae;s===Se&&(t.items.splice(o,1),o-=1)}}}else if(V.isPair(t)){i=Object.freeze(i.concat(t));let o=xt("key",t.key,n,i);if(o===ae)return ae;o===Se&&(t.key=null);let s=xt("value",t.value,n,i);if(s===ae)return ae;s===Se&&(t.value=null)}}return r}async function ai(e,t){let n=Mc(t);V.isDocument(e)?await kt(null,e.contents,n,Object.freeze([e]))===Se&&(e.contents=null):await kt(null,e,n,Object.freeze([]))}ai.BREAK=ae;ai.SKIP=Lc;ai.REMOVE=Se;async function kt(e,t,n,i){let r=await Nc(e,t,n,i);if(V.isNode(r)||V.isPair(r))return Rc(e,i,r),kt(e,r,n,i);if(typeof r!="symbol"){if(V.isCollection(t)){i=Object.freeze(i.concat(t));for(let o=0;o<t.items.length;++o){let s=await kt(o,t.items[o],n,i);if(typeof s=="number")o=s-1;else{if(s===ae)return ae;s===Se&&(t.items.splice(o,1),o-=1)}}}else if(V.isPair(t)){i=Object.freeze(i.concat(t));let o=await kt("key",t.key,n,i);if(o===ae)return ae;o===Se&&(t.key=null);let s=await kt("value",t.value,n,i);if(s===ae)return ae;s===Se&&(t.value=null)}}return r}function Mc(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Nc(e,t,n,i){if(typeof n=="function")return n(e,t,i);if(V.isMap(t))return n.Map?.(e,t,i);if(V.isSeq(t))return n.Seq?.(e,t,i);if(V.isPair(t))return n.Pair?.(e,t,i);if(V.isScalar(t))return n.Scalar?.(e,t,i);if(V.isAlias(t))return n.Alias?.(e,t,i)}function Rc(e,t,n){let i=t[t.length-1];if(V.isCollection(i))i.items[e]=n;else if(V.isPair(i))e==="key"?i.key=n:i.value=n;else if(V.isDocument(i))i.contents=n;else{let r=V.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}ao.visit=si;ao.visitAsync=ai});var lo=S(Fc=>{"use strict";var Pc=I(),sg=tn(),ag={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},lg=e=>e.replace(/[!,[\]{}]/g,t=>ag[t]),nn=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let i=t.trim().split(/[ \t]+/),r=i.shift();switch(r){case"%TAG":{if(i.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[o,s]=i;return this.tags[o]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[o]=i;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let s=/^\d+\.\d+$/.test(o);return n(6,`Unsupported YAML version ${o}`,s),!1}}default:return n(0,`Unknown directive ${r}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let s=t.slice(2,-1);return s==="!"||s==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),s)}let[,i,r]=t.match(/^(.*!)([^!]*)$/s);r||n(`The ${t} tag has no suffix`);let o=this.tags[i];if(o)try{return o+decodeURIComponent(r)}catch(s){return n(String(s)),null}return i==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[n,i]of Object.entries(this.tags))if(t.startsWith(i))return n+lg(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),r;if(t&&i.length>0&&Pc.isNode(t.contents)){let o={};sg.visit(t.contents,(s,a)=>{Pc.isNode(a)&&a.tag&&(o[a.tag]=!0)}),r=Object.keys(o)}else r=[];for(let[o,s]of i)o==="!!"&&s==="tag:yaml.org,2002:"||(!t||r.some(a=>a.startsWith(s)))&&n.push(`%TAG ${o} ${s}`);return n.join(`
4
4
  `)}};nn.defaultYaml={explicit:!1,version:"1.2"};nn.defaultTags={"!!":"tag:yaml.org,2002:"};Fc.Directives=nn});var li=S(rn=>{"use strict";var Dc=I(),cg=tn();function ug(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function Bc(e){let t=new Set;return cg.visit(e,{Value(n,i){i.anchor&&t.add(i.anchor)}}),t}function qc(e,t){for(let n=1;;++n){let i=`${e}${n}`;if(!t.has(i))return i}}function fg(e,t){let n=[],i=new Map,r=null;return{onAnchor:o=>{n.push(o),r??(r=Bc(e));let s=qc(t,r);return r.add(s),s},setAnchors:()=>{for(let o of n){let s=i.get(o);if(typeof s=="object"&&s.anchor&&(Dc.isScalar(s.node)||Dc.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:i}}rn.anchorIsValid=ug;rn.anchorNames=Bc;rn.createNodeAnchors=fg;rn.findNewAnchor=qc});var co=S($c=>{"use strict";function on(e,t,n,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let r=0,o=i.length;r<o;++r){let s=i[r],a=on(e,i,String(r),s);a===void 0?delete i[r]:a!==s&&(i[r]=a)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let o=i.get(r),s=on(e,i,r,o);s===void 0?i.delete(r):s!==o&&i.set(r,s)}else if(i instanceof Set)for(let r of Array.from(i)){let o=on(e,i,r,r);o===void 0?i.delete(r):o!==r&&(i.delete(r),i.add(o))}else for(let[r,o]of Object.entries(i)){let s=on(e,i,r,o);s===void 0?delete i[r]:s!==o&&(i[r]=s)}return e.call(t,n,i)}$c.applyReviver=on});var Fe=S(Uc=>{"use strict";var dg=I();function jc(e,t,n){if(Array.isArray(e))return e.map((i,r)=>jc(i,String(r),n));if(e&&typeof e.toJSON=="function"){if(!n||!dg.hasAnchor(e))return e.toJSON(t,n);let i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=o=>{i.res=o,delete n.onCreate};let r=e.toJSON(t,n);return n.onCreate&&n.onCreate(r),r}return typeof e=="bigint"&&!n?.keep?Number(e):e}Uc.toJS=jc});var ci=S(Vc=>{"use strict";var pg=co(),Kc=I(),mg=Fe(),uo=class{constructor(t){Object.defineProperty(this,Kc.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:i,onAnchor:r,reviver:o}={}){if(!Kc.isDocument(t))throw new TypeError("A document argument is required");let s={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},a=mg.toJS(this,"",s);if(typeof r=="function")for(let{count:l,res:c}of s.anchors.values())r(c,l);return typeof o=="function"?pg.applyReviver(o,{"":a},"",a):a}};Vc.NodeBase=uo});var sn=S(Yc=>{"use strict";var hg=li(),yg=tn(),Ct=I(),gg=ci(),bg=Fe(),fo=class extends gg.NodeBase{constructor(t){super(Ct.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;n?.aliasResolveCache?i=n.aliasResolveCache:(i=[],yg.visit(t,{Node:(o,s)=>{(Ct.isAlias(s)||Ct.hasAnchor(s))&&i.push(s)}}),n&&(n.aliasResolveCache=i));let r;for(let o of i){if(o===this)break;o.anchor===this.source&&(r=o)}return r}toJSON(t,n){if(!n)return{source:this.source};let{anchors:i,doc:r,maxAliasCount:o}=n,s=this.resolve(r,n);if(!s){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=i.get(s);if(a||(bg.toJS(s,null,n),a=i.get(s)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(o>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=ui(r,s,i)),a.count*a.aliasCount>o)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(t,n,i){let r=`*${this.source}`;if(t){if(hg.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(t.implicitKey)return`${r} `}return r}};function ui(e,t,n){if(Ct.isAlias(t)){let i=t.resolve(e),r=n&&i&&n.get(i);return r?r.count*r.aliasCount:0}else if(Ct.isCollection(t)){let i=0;for(let r of t.items){let o=ui(e,r,n);o>i&&(i=o)}return i}else if(Ct.isPair(t)){let i=ui(e,t.key,n),r=ui(e,t.value,n);return Math.max(i,r)}return 1}Yc.Alias=fo});var U=S(po=>{"use strict";var Sg=I(),vg=ci(),Ag=Fe(),wg=e=>!e||typeof e!="function"&&typeof e!="object",De=class extends vg.NodeBase{constructor(t){super(Sg.SCALAR),this.value=t}toJSON(t,n){return n?.keep?this.value:Ag.toJS(this.value,t,n)}toString(){return String(this.value)}};De.BLOCK_FOLDED="BLOCK_FOLDED";De.BLOCK_LITERAL="BLOCK_LITERAL";De.PLAIN="PLAIN";De.QUOTE_DOUBLE="QUOTE_DOUBLE";De.QUOTE_SINGLE="QUOTE_SINGLE";po.Scalar=De;po.isScalarValue=wg});var an=S(Wc=>{"use strict";var _g=sn(),rt=I(),Gc=U(),Eg="tag:yaml.org,2002:";function xg(e,t,n){if(t){let i=n.filter(o=>o.tag===t),r=i.find(o=>!o.format)??i[0];if(!r)throw new Error(`Tag ${t} not found`);return r}return n.find(i=>i.identify?.(e)&&!i.format)}function kg(e,t,n){if(rt.isDocument(e)&&(e=e.contents),rt.isNode(e))return e;if(rt.isPair(e)){let f=n.schema[rt.MAP].createNode?.(n.schema,null,n);return f.items.push(e),f}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:i,onAnchor:r,onTagObj:o,schema:s,sourceObjects:a}=n,l;if(i&&e&&typeof e=="object"){if(l=a.get(e),l)return l.anchor??(l.anchor=r(e)),new _g.Alias(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t=Eg+t.slice(2));let c=xg(e,t,s.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let f=new Gc.Scalar(e);return l&&(l.node=f),f}c=e instanceof Map?s[rt.MAP]:Symbol.iterator in Object(e)?s[rt.SEQ]:s[rt.MAP]}o&&(o(c),delete n.onTagObj);let u=c?.createNode?c.createNode(n.schema,e,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,e,n):new Gc.Scalar(e);return t?u.tag=t:c.default||(u.tag=c.tag),l&&(l.node=u),u}Wc.createNode=kg});var di=S(fi=>{"use strict";var Cg=an(),ve=I(),Og=ci();function mo(e,t,n){let i=n;for(let r=t.length-1;r>=0;--r){let o=t[r];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=i,i=s}else i=new Map([[o,i]])}return Cg.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Hc=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,ho=class extends Og.NodeBase{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(i=>ve.isNode(i)||ve.isPair(i)?i.clone(t):i),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(Hc(t))this.add(n);else{let[i,...r]=t,o=this.get(i,!0);if(ve.isCollection(o))o.addIn(r,n);else if(o===void 0&&this.schema)this.set(i,mo(this.schema,r,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}deleteIn(t){let[n,...i]=t;if(i.length===0)return this.delete(n);let r=this.get(n,!0);if(ve.isCollection(r))return r.deleteIn(i);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}getIn(t,n){let[i,...r]=t,o=this.get(i,!0);return r.length===0?!n&&ve.isScalar(o)?o.value:o:ve.isCollection(o)?o.getIn(r,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!ve.isPair(n))return!1;let i=n.value;return i==null||t&&ve.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){let[n,...i]=t;if(i.length===0)return this.has(n);let r=this.get(n,!0);return ve.isCollection(r)?r.hasIn(i):!1}setIn(t,n){let[i,...r]=t;if(r.length===0)this.set(i,n);else{let o=this.get(i,!0);if(ve.isCollection(o))o.setIn(r,n);else if(o===void 0&&this.schema)this.set(i,mo(this.schema,r,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}};fi.Collection=ho;fi.collectionFromPath=mo;fi.isEmptyPath=Hc});var ln=S(pi=>{"use strict";var Tg=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function yo(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Ig=(e,t,n)=>e.endsWith(`
5
5
  `)?yo(n,t):n.includes(`
@@ -1,2 +1,2 @@
1
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,b,c,d}from"./chunk-DKHGVKVS.js";import"./chunk-C2QIYD6E.js";import"./chunk-AVYSGYVY.js";import"./chunk-Z4VKGZFA.js";import"./chunk-CWWDVX6C.js";import"./chunk-ZITT4GJK.js";import"./chunk-D76SO2ME.js";export{b as getTuiDataDirPath,d as prepareTuiDataDir,a as resolveDefaultTuiDataDir,c as resolveTuiDataDir};
2
+ import{a,b,c,d}from"./chunk-OSA3A5UV.js";import"./chunk-JL7ZXU6T.js";import"./chunk-TWO6GIVD.js";import"./chunk-3FETZOUF.js";import"./chunk-CWWDVX6C.js";import"./chunk-ZITT4GJK.js";import"./chunk-D76SO2ME.js";export{b as getTuiDataDirPath,d as prepareTuiDataDir,a as resolveDefaultTuiDataDir,c as resolveTuiDataDir};
@@ -1,2 +1,2 @@
1
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{$ as W,$a as cb,A as v,Aa as ua,B as w,Ba as va,C as x,Ca as wa,D as y,Da as xa,E as z,Ea as ya,F as A,Fa as za,G as B,Ga as Aa,H as C,Ha as Ba,I as D,Ia as Ca,J as E,Ja as Da,K as F,Ka as Ea,L as G,La as Fa,M as H,Ma as Ga,N as I,Na as Ha,O as J,Oa as Ia,P as K,Pa as Ja,Q as L,Qa as Ka,R as M,Ra as La,S as N,Sa as Ma,T as O,Ta as Na,U as P,Ua as Oa,V as Q,Va as Pa,W as R,Wa as Qa,X as S,Xa as Ra,Y as T,Ya as $a,Z as U,Za as ab,_ as V,_a as bb,ab as db,ba as X,bb as eb,ca as Y,cb as fb,d as a,da as Z,db as gb,ea as _,eb as hb,f as b,fa as $,fb as ib,g as c,ga as aa,gb as jb,h as d,ha as ba,hb as kb,ia as ca,ib as lb,j as e,ja as da,jb as mb,k as f,ka as ea,kb as nb,l as g,la as fa,m as h,ma as ga,n as i,na as ha,o as j,oa as ia,p as k,pa as ja,q as l,qa as ka,r as m,ra as la,s as n,sa as ma,t as o,ta as na,u as p,ua as oa,v as q,va as pa,w as r,wa as qa,x as s,xa as ra,y as t,ya as sa,z as u,za as ta}from"./chunk-AVYSGYVY.js";import"./chunk-Z4VKGZFA.js";import"./chunk-CWWDVX6C.js";import{a as Sa,b as Ta,c as Ua,d as Va,e as Wa,f as Xa,g as Ya,h as Za,i as _a}from"./chunk-ZITT4GJK.js";import"./chunk-D76SO2ME.js";export{z as AGENT_BUILTIN_MCP_TOOL_IDS,A as AGENT_BUILTIN_SKILL_IDS,y as AGENT_BUILTIN_TOOL_IDS,B as AGENT_CAPABILITY_OWNED_SKILL_IDS,n as AGENT_RUNTIME_FRAMEWORKS,Wa as ASR_PROXY_AUTH_ENV_KEYS,ia as BRAND,V as BROWSER_CONFIG_DEFAULTS,Fa as CUSTOM_PROVIDER_ID_PREFIX,lb as ConfigFileError,I as DATA_CONTRIBUTION_CONFIG_DEFAULTS,o as DEFAULT_AGENT_RUNTIME_FRAMEWORK,sa as DEFAULT_MODEL_PRESETS,ka as DEFAULT_PORT,k as DEFAULT_SKILLS_CONFIG,m as EXTERNAL_SOURCE_KIND_LIST,Q as GOAL_CONFIG_DEFAULTS,R as GOAL_CONFIG_LIMITS,N as GOAL_EVALUATOR_MODEL_POLICIES,P as GOAL_SUBAGENT_PROFILES,M as GOAL_VERIFICATION_EVIDENCE_MODES,L as GOAL_VERIFICATION_MODES,O as GOAL_VERIFIER_READONLY_PROFILE,s as LEGACY_DATA_DIR_BASENAME,Ta as LEGACY_RUNTIME_ENV_KEYS,cb as LOCAL_RUNTIME_AUTH_CONTEXT_FILE,Da as MANAGED_MINIMAX_PROVIDER_ID,Sa as MANAGED_RUNTIME_KEYS,h as MEMORY_V2_DEFAULTS,Ea as MINIMAX_API_PROVIDER_ID,r as NEW_DATA_DIR_BASENAME,la as OPENCODE_PORT_OFFSET,Va as PARENT_HINT_KEYS,ja as RUNTIME_ENV_PREFIX,Ua as RUNTIME_IDENTITY_KEYS,Y as SANDBOX_CONFIG_DEFAULTS,_ as SUBAGENT_CONFIG_DEFAULTS,jb as TEST_PORT_ROLE_FLOOR,ib as TEST_PORT_ROLE_OFFSET,T as TOOL_RESULT_COMPACTION_DEFAULTS,ra as allowsManagedMinimaxProviderOverride,Xa as buildChildEnv,hb as clearLocalRuntimeAuthContextFile,Ra as compareAndSetLocalModelContext,Ka as credentialEnvReferenceName,na as detectGitPortInfo,bb as detectPidOwner,_a as findLegacyRuntimeEnvKeys,ab as formatPidFile,wa as getConfig,qa as getConfigPath,pa as getDataDir,u as getLegacyDataDirPath,za as getOpenCodePort,t as getPrimaryDataDirPath,oa as getProfile,ca as getRuntimeBuildEnv,ea as getRuntimePresetKey,ba as getRuntimeRegion,X as getSandboxConfigDefaults,G as isAgentBuiltinMcpToolEnabled,H as isAgentBuiltinSkillEnabled,F as isAgentBuiltinToolEnabled,ga as isBetaFeatureProdReady,Ga as isFirstPartyMinimaxMessagesRoute,ha as isInternalBuild,Aa as isLegacyManagedMinimaxProvider,i as isLegacyMemoryRecallEnabled,a as isLocalSourceProvenanceEnabled,Ba as isManagedProviderBaseUrl,da as isManagedRuntime,g as isMemoryV2Enabled,aa as isProposalEligibleAgent,Ia as listRouteModelIds,mb as loadConfigFromFile,w as migrateDefaultDataDir,x as migrateProfileDataDir,j as minimaxApiModels,db as normalizeLocalRuntimeAuthContext,D as parseAgentCapabilityConfig,q as parseAgentRuntimeConfig,p as parseAgentRuntimeFramework,C as parseAgentsConfig,W as parseBrowserConfig,e as parseConfigText,J as parseDataContributionConfig,S as parseGoalConfig,$a as parsePidFile,c as parseRunawayGuardOverride,Z as parseSandboxConfig,l as parseSkillsConfig,$ as parseSubagentConfig,U as parseToolResultCompactionConfig,kb as pickTestPort,Ma as probeProviderCredential,K as readDataContributionEnabled,nb as readExplicitBetaFeatureFromFile,fb as readLocalRuntimeAuthContext,Na as removeLocalProviderConfig,Oa as replaceLocalManagedMinimaxProvider,va as resetConfig,ma as resetGitDetect,E as resolveAgentCapabilities,fa as resolveBetaFeature,v as resolveDataDir,eb as resolveLocalRuntimeAuthContextPath,Ja as resolveModelAvailability,Ha as resolveModelCallRoute,ya as resolvePort,xa as resolvePromptConfig,Ca as resolveProviderAuthMode,La as resolveProviderCredential,d as resolveRunawayGuardConfig,f as serializeConfigPreservingComments,ta as setLegacyByokProviderMigrationEnabled,ua as setManagedPresetBaseUrlSyncEnabled,Ya as stripManagedRuntimeEnv,Za as stripRuntimeBoundaryKeysFrom,Pa as updateLocalByokConfig,Qa as updateLocalModelSelection,gb as writeLocalRuntimeAuthContext,b as writeTuiStatusLineSetting};
2
+ import{$ as W,$a as cb,A as v,Aa as ua,B as w,Ba as va,C as x,Ca as wa,D as y,Da as xa,E as z,Ea as ya,F as A,Fa as za,G as B,Ga as Aa,H as C,Ha as Ba,I as D,Ia as Ca,J as E,Ja as Da,K as F,Ka as Ea,L as G,La as Fa,M as H,Ma as Ga,N as I,Na as Ha,O as J,Oa as Ia,P as K,Pa as Ja,Q as L,Qa as Ka,R as M,Ra as La,S as N,Sa as Ma,T as O,Ta as Na,U as P,Ua as Oa,V as Q,Va as Pa,W as R,Wa as Qa,X as S,Xa as Ra,Y as T,Ya as $a,Z as U,Za as ab,_ as V,_a as bb,ab as db,ba as X,bb as eb,ca as Y,cb as fb,d as a,da as Z,db as gb,ea as _,eb as hb,f as b,fa as $,fb as ib,g as c,ga as aa,gb as jb,h as d,ha as ba,hb as kb,ia as ca,ib as lb,j as e,ja as da,jb as mb,k as f,ka as ea,kb as nb,l as g,la as fa,m as h,ma as ga,n as i,na as ha,o as j,oa as ia,p as k,pa as ja,q as l,qa as ka,r as m,ra as la,s as n,sa as ma,t as o,ta as na,u as p,ua as oa,v as q,va as pa,w as r,wa as qa,x as s,xa as ra,y as t,ya as sa,z as u,za as ta}from"./chunk-TWO6GIVD.js";import"./chunk-3FETZOUF.js";import"./chunk-CWWDVX6C.js";import{a as Sa,b as Ta,c as Ua,d as Va,e as Wa,f as Xa,g as Ya,h as Za,i as _a}from"./chunk-ZITT4GJK.js";import"./chunk-D76SO2ME.js";export{z as AGENT_BUILTIN_MCP_TOOL_IDS,A as AGENT_BUILTIN_SKILL_IDS,y as AGENT_BUILTIN_TOOL_IDS,B as AGENT_CAPABILITY_OWNED_SKILL_IDS,n as AGENT_RUNTIME_FRAMEWORKS,Wa as ASR_PROXY_AUTH_ENV_KEYS,ia as BRAND,V as BROWSER_CONFIG_DEFAULTS,Fa as CUSTOM_PROVIDER_ID_PREFIX,lb as ConfigFileError,I as DATA_CONTRIBUTION_CONFIG_DEFAULTS,o as DEFAULT_AGENT_RUNTIME_FRAMEWORK,sa as DEFAULT_MODEL_PRESETS,ka as DEFAULT_PORT,k as DEFAULT_SKILLS_CONFIG,m as EXTERNAL_SOURCE_KIND_LIST,Q as GOAL_CONFIG_DEFAULTS,R as GOAL_CONFIG_LIMITS,N as GOAL_EVALUATOR_MODEL_POLICIES,P as GOAL_SUBAGENT_PROFILES,M as GOAL_VERIFICATION_EVIDENCE_MODES,L as GOAL_VERIFICATION_MODES,O as GOAL_VERIFIER_READONLY_PROFILE,s as LEGACY_DATA_DIR_BASENAME,Ta as LEGACY_RUNTIME_ENV_KEYS,cb as LOCAL_RUNTIME_AUTH_CONTEXT_FILE,Da as MANAGED_MINIMAX_PROVIDER_ID,Sa as MANAGED_RUNTIME_KEYS,h as MEMORY_V2_DEFAULTS,Ea as MINIMAX_API_PROVIDER_ID,r as NEW_DATA_DIR_BASENAME,la as OPENCODE_PORT_OFFSET,Va as PARENT_HINT_KEYS,ja as RUNTIME_ENV_PREFIX,Ua as RUNTIME_IDENTITY_KEYS,Y as SANDBOX_CONFIG_DEFAULTS,_ as SUBAGENT_CONFIG_DEFAULTS,jb as TEST_PORT_ROLE_FLOOR,ib as TEST_PORT_ROLE_OFFSET,T as TOOL_RESULT_COMPACTION_DEFAULTS,ra as allowsManagedMinimaxProviderOverride,Xa as buildChildEnv,hb as clearLocalRuntimeAuthContextFile,Ra as compareAndSetLocalModelContext,Ka as credentialEnvReferenceName,na as detectGitPortInfo,bb as detectPidOwner,_a as findLegacyRuntimeEnvKeys,ab as formatPidFile,wa as getConfig,qa as getConfigPath,pa as getDataDir,u as getLegacyDataDirPath,za as getOpenCodePort,t as getPrimaryDataDirPath,oa as getProfile,ca as getRuntimeBuildEnv,ea as getRuntimePresetKey,ba as getRuntimeRegion,X as getSandboxConfigDefaults,G as isAgentBuiltinMcpToolEnabled,H as isAgentBuiltinSkillEnabled,F as isAgentBuiltinToolEnabled,ga as isBetaFeatureProdReady,Ga as isFirstPartyMinimaxMessagesRoute,ha as isInternalBuild,Aa as isLegacyManagedMinimaxProvider,i as isLegacyMemoryRecallEnabled,a as isLocalSourceProvenanceEnabled,Ba as isManagedProviderBaseUrl,da as isManagedRuntime,g as isMemoryV2Enabled,aa as isProposalEligibleAgent,Ia as listRouteModelIds,mb as loadConfigFromFile,w as migrateDefaultDataDir,x as migrateProfileDataDir,j as minimaxApiModels,db as normalizeLocalRuntimeAuthContext,D as parseAgentCapabilityConfig,q as parseAgentRuntimeConfig,p as parseAgentRuntimeFramework,C as parseAgentsConfig,W as parseBrowserConfig,e as parseConfigText,J as parseDataContributionConfig,S as parseGoalConfig,$a as parsePidFile,c as parseRunawayGuardOverride,Z as parseSandboxConfig,l as parseSkillsConfig,$ as parseSubagentConfig,U as parseToolResultCompactionConfig,kb as pickTestPort,Ma as probeProviderCredential,K as readDataContributionEnabled,nb as readExplicitBetaFeatureFromFile,fb as readLocalRuntimeAuthContext,Na as removeLocalProviderConfig,Oa as replaceLocalManagedMinimaxProvider,va as resetConfig,ma as resetGitDetect,E as resolveAgentCapabilities,fa as resolveBetaFeature,v as resolveDataDir,eb as resolveLocalRuntimeAuthContextPath,Ja as resolveModelAvailability,Ha as resolveModelCallRoute,ya as resolvePort,xa as resolvePromptConfig,Ca as resolveProviderAuthMode,La as resolveProviderCredential,d as resolveRunawayGuardConfig,f as serializeConfigPreservingComments,ta as setLegacyByokProviderMigrationEnabled,ua as setManagedPresetBaseUrlSyncEnabled,Ya as stripManagedRuntimeEnv,Za as stripRuntimeBoundaryKeysFrom,Pa as updateLocalByokConfig,Qa as updateLocalModelSelection,gb as writeLocalRuntimeAuthContext,b as writeTuiStatusLineSetting};