@ucloud-sdks/ucloud-sandbox-cli 0.1.0-beta.5 → 0.1.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -225,7 +225,7 @@ ${H6}
225
225
  Try running with %s or get access `,He.cyan("sudo"))+`
226
226
  to the local update config store via
227
227
  `+He.cyan((0,Z1.format)(" sudo chown -R $USER:$(id -gn $USER) %s ",bu));Is.default.on("exit",()=>{console.error(Jn(r,{textAlignment:"center"}))})}}check(){!this.config||this.config.get("optOut")||this.#n||(this.update=this.config.get("update"),this.update&&(this.update.current=this.#t,this.config.delete("update")),!(Date.now()-this.config.get("lastUpdateCheck")<this.#r)&&(0,D7.spawn)(Is.default.execPath,[EA.default.join(zTe,"check.js"),JSON.stringify(this.#e)],{detached:!0,stdio:"ignore"}).unref())}async fetchInfo(){let{distTag:e}=this.#e,r=await WR(this._packageName,{version:e});return{latest:r,current:this.#t,type:ND(this.#t,r)||e,name:this._packageName}}notify(e){let r=!this._shouldNotifyInNpmScript&&mB;if(!Is.default.stdout.isTTY||r||!this.update||!A7.default.gt(this.update.latest,this.update.current))return this;e={isGlobal:O7.default,isYarnGlobal:wB(),...e};let n;e.isYarnGlobal?n=`yarn global add ${this._packageName}`:e.isGlobal?n=`npm i -g ${this._packageName}`:JR()?n=`yarn add ${this._packageName}`:n=`npm i ${this._packageName}`;let i="Update available "+He.dim("{currentVersion}")+He.reset(" \u2192 ")+He.green("{latestVersion}")+`
228
- Run `+He.cyan("{updateCommand}")+" to update",s=e.message||i;e.boxenOptions=e.boxenOptions||{padding:1,margin:1,textAlignment:"center",borderColor:"yellow",borderStyle:"round"};let o=Jn(gA(s,{packageName:this._packageName,currentVersion:this.update.current,latestVersion:this.update.latest,updateCommand:n}),e.boxenOptions);return e.defer===!1?console.error(o):(Is.default.on("exit",()=>{console.error(o)}),Is.default.on("SIGINT",()=>{console.error(""),Is.default.exit()})),this}};function SA(t){let e=new th(t);return e.check(),e}u();var $7=K(Y7(),1),{program:Int,createCommand:wnt,createArgument:Lnt,createOption:Mnt,CommanderError:Pnt,InvalidArgumentError:nh,InvalidOptionArgumentError:Fnt,Command:We,Argument:knt,Option:Sa,Help:Bnt}=$7.default;var LA={};Eu(LA,{author:()=>_ye,bin:()=>Dye,bugs:()=>gye,default:()=>Oye,dependencies:()=>Rye,description:()=>pye,devDependencies:()=>xye,engines:()=>Aye,files:()=>Cye,homepage:()=>hye,keywords:()=>bye,license:()=>mye,name:()=>fye,publishConfig:()=>Sye,repository:()=>Eye,scripts:()=>yye,sideEffects:()=>Tye,version:()=>MA});var fye="@ucloud-sdks/ucloud-sandbox-cli",MA="0.1.0-beta.5",pye="CLI for managing UCloud sandbox templates",hye="https://ucloud.cn",mye="MIT",_ye={name:"jason.mei"},gye="https://github.com/ucloud/ucloud-sandbox-cli/issues",Eye={type:"git",url:"git+https://github.com/ucloud/ucloud-sandbox-cli.git",directory:"packages/cli"},Sye={access:"public"},bye=["ucloud","ai-agents","agents","ai","code-interpreter","sandbox","code","cli","runtime","vm","nodejs","javascript","typescript"],Tye=!1,yye={prepublishOnly:"pnpm build",build:"tsc --noEmit --skipLibCheck && tsup --minify",dev:"tsup --watch",lint:"eslint src",format:"prettier --write src","test:interactive":"pnpm build && ./dist/index.js",test:"vitest run","test:watch":"vitest watch","test:coverage":"vitest run --coverage","check-deps":"knip","update-deps":"ncu -u && pnpm i","generate-ref":"./scripts/generate_sdk_ref.sh"},xye={e2b:"file:./packages/js-sdk","@types/command-exists":"^1.2.3","@types/handlebars":"^4.1.0","@types/inquirer":"^9.0.7","@types/json2md":"^1.5.4","@types/node":"^20.19.19","@types/npmcli__package-json":"^4.0.4","@types/statuses":"^2.0.5","@types/update-notifier":"6.0.5","@vitest/coverage-v8":"^3.2.4",json2md:"^2.0.1",knip:"^5.43.6","npm-check-updates":"^16.14.6",tsup:"^8.4.0",typescript:"^5.2.2",vitest:"^3.2.4"},Cye=["dist","LICENSE","README.md","package.json"],Dye={"ucloud-sandbox-cli":"dist/index.js"},Rye={"@iarna/toml":"^2.2.5","@inquirer/prompts":"^7.9.0","@npmcli/package-json":"^5.2.1","async-listen":"^3.0.1",boxen:"^7.1.1",chalk:"^5.3.0","cli-highlight":"^2.1.11","command-exists":"^1.2.9",commander:"^11.1.0","console-table-printer":"^2.11.2","dockerfile-ast":"^0.6.1",handlebars:"^4.7.8",inquirer:"^12.10.0",open:"^9.1.0",statuses:"^2.0.1","strip-ansi":"^7.1.0","update-notifier":"^6.0.2",yup:"^1.3.2"},Aye={node:">=20"},Oye={name:fye,version:MA,description:pye,homepage:hye,license:mye,author:_ye,bugs:gye,repository:Eye,publishConfig:Sye,keywords:bye,sideEffects:Tye,scripts:yye,devDependencies:xye,files:Cye,bin:Dye,dependencies:Rye,engines:Aye};u();u();var uN=K(Jj());u();var dd=K(require("path"));function Fn(t){let e=process.cwd();return t?dd.isAbsolute(t)?t:dd.resolve(e,t):e}function eQ(t){return dd.relative(process.cwd(),t)}var MIe="#FFB766";function aE(t){let e=Ae(t.email),r=t.teamName?Ae(t.teamName):PIe("Log out and log in to get team name"),n=Ae(t.teamId);return`You are logged in as ${e},
228
+ Run `+He.cyan("{updateCommand}")+" to update",s=e.message||i;e.boxenOptions=e.boxenOptions||{padding:1,margin:1,textAlignment:"center",borderColor:"yellow",borderStyle:"round"};let o=Jn(gA(s,{packageName:this._packageName,currentVersion:this.update.current,latestVersion:this.update.latest,updateCommand:n}),e.boxenOptions);return e.defer===!1?console.error(o):(Is.default.on("exit",()=>{console.error(o)}),Is.default.on("SIGINT",()=>{console.error(""),Is.default.exit()})),this}};function SA(t){let e=new th(t);return e.check(),e}u();var $7=K(Y7(),1),{program:Int,createCommand:wnt,createArgument:Lnt,createOption:Mnt,CommanderError:Pnt,InvalidArgumentError:nh,InvalidOptionArgumentError:Fnt,Command:We,Argument:knt,Option:Sa,Help:Bnt}=$7.default;var LA={};Eu(LA,{author:()=>_ye,bin:()=>Dye,bugs:()=>gye,default:()=>Oye,dependencies:()=>Rye,description:()=>pye,devDependencies:()=>xye,engines:()=>Aye,files:()=>Cye,homepage:()=>hye,keywords:()=>bye,license:()=>mye,name:()=>fye,publishConfig:()=>Sye,repository:()=>Eye,scripts:()=>yye,sideEffects:()=>Tye,version:()=>MA});var fye="@ucloud-sdks/ucloud-sandbox-cli",MA="0.1.0-beta.7",pye="CLI for managing UCloud sandbox templates",hye="https://ucloud.cn",mye="MIT",_ye={name:"jason.mei"},gye="https://github.com/ucloud/ucloud-sandbox-cli/issues",Eye={type:"git",url:"git+https://github.com/ucloud/ucloud-sandbox-cli.git",directory:"packages/cli"},Sye={access:"public"},bye=["ucloud","ai-agents","agents","ai","code-interpreter","sandbox","code","cli","runtime","vm","nodejs","javascript","typescript"],Tye=!1,yye={prepublishOnly:"pnpm build",build:"tsc --noEmit --skipLibCheck && tsup --minify",dev:"tsup --watch",lint:"eslint src",format:"prettier --write src","test:interactive":"pnpm build && ./dist/index.js",test:"vitest run","test:watch":"vitest watch","test:coverage":"vitest run --coverage","check-deps":"knip","update-deps":"ncu -u && pnpm i","generate-ref":"./scripts/generate_sdk_ref.sh"},xye={e2b:"file:./packages/js-sdk","@types/command-exists":"^1.2.3","@types/handlebars":"^4.1.0","@types/inquirer":"^9.0.7","@types/json2md":"^1.5.4","@types/node":"^20.19.19","@types/npmcli__package-json":"^4.0.4","@types/statuses":"^2.0.5","@types/update-notifier":"6.0.5","@vitest/coverage-v8":"^3.2.4",json2md:"^2.0.1",knip:"^5.43.6","npm-check-updates":"^16.14.6",tsup:"^8.4.0",typescript:"^5.2.2",vitest:"^3.2.4"},Cye=["dist","LICENSE","README.md","package.json"],Dye={"ucloud-sandbox-cli":"dist/index.js"},Rye={"@iarna/toml":"^2.2.5","@inquirer/prompts":"^7.9.0","@npmcli/package-json":"^5.2.1","async-listen":"^3.0.1",boxen:"^7.1.1",chalk:"^5.3.0","cli-highlight":"^2.1.11","command-exists":"^1.2.9",commander:"^11.1.0","console-table-printer":"^2.11.2","dockerfile-ast":"^0.6.1",handlebars:"^4.7.8",inquirer:"^12.10.0",open:"^9.1.0",statuses:"^2.0.1","strip-ansi":"^7.1.0","update-notifier":"^6.0.2",yup:"^1.3.2"},Aye={node:">=20"},Oye={name:fye,version:MA,description:pye,homepage:hye,license:mye,author:_ye,bugs:gye,repository:Eye,publishConfig:Sye,keywords:bye,sideEffects:Tye,scripts:yye,devDependencies:xye,files:Cye,bin:Dye,dependencies:Rye,engines:Aye};u();u();var uN=K(Jj());u();var dd=K(require("path"));function Fn(t){let e=process.cwd();return t?dd.isAbsolute(t)?t:dd.resolve(e,t):e}function eQ(t){return dd.relative(process.cwd(),t)}var MIe="#FFB766";function aE(t){let e=Ae(t.email),r=t.teamName?Ae(t.teamName):PIe("Log out and log in to get team name"),n=Ae(t.teamId);return`You are logged in as ${e},
229
229
  Selected team: ${r} (${n})`}function nQ(t,e){let r=Ae(t.name),n=Ae(t.teamID),i=t.teamID==e?ze(" (currently selected team)"):"";return`${r} (${n})${i}`}function rr(t,e){let r=dN(t.aliases),n=r?Ae(r):"",i=e?FIe(" <-> ")+Dt(e):"";return`${`${t.templateID} `}${n}${i}`.trim()}function PIe(t){return He.redBright(t)}function va(t,e){return He.redBright(`${t?`${t}
230
230
  `:""}${e?e.stack:""}
231
231
  `)}function FIe(t){return He.dim(t)}function Ae(t){return He.bold(t)}function ze(t){return He.hex(MIe)(t)}function cE(t){return He.blue(t)}function Ct(t){return He.blue(t)}function Dt(t){return t?Ct("./"+eQ(t)):""}function iQ(t){return He.blueBright(t)}function fd(t){return He.underline(t)}function dN(t){if(t)return t.join(", ")}function lE(t){return uN.default(t,{language:"typescript",ignoreIllegals:!0})}function uE(t){return uN.default(t,{language:"python",ignoreIllegals:!0})}var kIe={topLeft:"",topRight:"",bottomLeft:"",bottomRight:"",top:"",bottom:"",left:"",right:""},tQ=2,rQ=1;function pd(t,e,r){return Jn(t,{borderStyle:{...kIe,top:"\u2500",bottom:r?"\u2500":""},titleAlignment:"center",float:"left",title:e?Ae(e):void 0,margin:{top:0,bottom:0,left:1,right:0},fullscreen:n=>[n,0],padding:{bottom:r?rQ:0,left:tQ,right:tQ,top:rQ}})}u();u();u();u();u();var BIe=/\{[^{}]+\}/g,UIe=()=>typeof process=="object"&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function GIe(){return Math.random().toString(36).slice(2,11)}function dE(t){let{baseUrl:e="",Request:r=globalThis.Request,fetch:n=globalThis.fetch,querySerializer:i,bodySerializer:s,headers:o,requestInitExt:a=void 0,...c}={...t};a=UIe()?a:void 0,e=aQ(e);let l=[];async function d(f,p){let{baseUrl:h,fetch:m=n,Request:_=r,headers:E,params:S={},parseAs:x="json",querySerializer:D,bodySerializer:A=s??qIe,body:P,...W}=p||{},B=e;h&&(B=aQ(h)??e);let w=typeof i=="function"?i:sQ(i);D&&(w=typeof D=="function"?D:sQ({...typeof i=="object"?i:{},...D}));let O=P===void 0?void 0:A(P,oQ(o,E,S.header)),v=oQ(O===void 0||O instanceof FormData?{}:{"Content-Type":"application/json"},o,E,S.header),H={redirect:"follow",...c,...W,body:O,headers:v},te,oe,ce=new _(YIe(f,{baseUrl:B,params:S,querySerializer:w}),H),re;for(let le in W)le in ce||(ce[le]=W[le]);if(l.length){te=GIe(),oe=Object.freeze({baseUrl:B,fetch:m,parseAs:x,querySerializer:w,bodySerializer:A});for(let le of l)if(le&&typeof le=="object"&&typeof le.onRequest=="function"){let Ee=await le.onRequest({request:ce,schemaPath:f,params:S,options:oe,id:te});if(Ee)if(Ee instanceof _)ce=Ee;else if(Ee instanceof Response){re=Ee;break}else throw new Error("onRequest: must return new Request() or Response() when modifying the request")}}if(!re){try{re=await m(ce,a)}catch(le){let Ee=le;if(l.length)for(let be=l.length-1;be>=0;be--){let ut=l[be];if(ut&&typeof ut=="object"&&typeof ut.onError=="function"){let dt=await ut.onError({request:ce,error:Ee,schemaPath:f,params:S,options:oe,id:te});if(dt){if(dt instanceof Response){Ee=void 0,re=dt;break}if(dt instanceof Error){Ee=dt;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(Ee)throw Ee}if(l.length)for(let le=l.length-1;le>=0;le--){let Ee=l[le];if(Ee&&typeof Ee=="object"&&typeof Ee.onResponse=="function"){let be=await Ee.onResponse({request:ce,response:re,schemaPath:f,params:S,options:oe,id:te});if(be){if(!(be instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");re=be}}}}if(re.status===204||ce.method==="HEAD"||re.headers.get("Content-Length")==="0")return re.ok?{data:void 0,response:re}:{error:void 0,response:re};if(re.ok)return x==="stream"?{data:re.body,response:re}:{data:await re[x](),response:re};let ge=await re.text();try{ge=JSON.parse(ge)}catch{}return{error:ge,response:re}}return{request(f,p,h){return d(p,{...h,method:f.toUpperCase()})},GET(f,p){return d(f,{...p,method:"GET"})},PUT(f,p){return d(f,{...p,method:"PUT"})},POST(f,p){return d(f,{...p,method:"POST"})},DELETE(f,p){return d(f,{...p,method:"DELETE"})},OPTIONS(f,p){return d(f,{...p,method:"OPTIONS"})},HEAD(f,p){return d(f,{...p,method:"HEAD"})},PATCH(f,p){return d(f,{...p,method:"PATCH"})},TRACE(f,p){return d(f,{...p,method:"TRACE"})},use(...f){for(let p of f)if(p){if(typeof p!="object"||!("onRequest"in p||"onResponse"in p||"onError"in p))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");l.push(p)}},eject(...f){for(let p of f){let h=l.indexOf(p);h!==-1&&l.splice(h,1)}}}}function fE(t,e,r){if(e==null)return"";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${r?.allowReserved===!0?e:encodeURIComponent(e)}`}function cQ(t,e,r){if(!e||typeof e!="object")return"";let n=[],i={simple:",",label:".",matrix:";"}[r.style]||"&";if(r.style!=="deepObject"&&r.explode===!1){for(let a in e)n.push(a,r.allowReserved===!0?e[a]:encodeURIComponent(e[a]));let o=n.join(",");switch(r.style){case"form":return`${t}=${o}`;case"label":return`.${o}`;case"matrix":return`;${t}=${o}`;default:return o}}for(let o in e){let a=r.style==="deepObject"?`${t}[${o}]`:o;n.push(fE(a,e[o],r))}let s=n.join(i);return r.style==="label"||r.style==="matrix"?`${i}${s}`:s}function lQ(t,e,r){if(!Array.isArray(e))return"";if(r.explode===!1){let s={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[r.style]||",",o=(r.allowReserved===!0?e:e.map(a=>encodeURIComponent(a))).join(s);switch(r.style){case"simple":return o;case"label":return`.${o}`;case"matrix":return`;${t}=${o}`;default:return`${t}=${o}`}}let n={simple:",",label:".",matrix:";"}[r.style]||"&",i=[];for(let s of e)r.style==="simple"||r.style==="label"?i.push(r.allowReserved===!0?s:encodeURIComponent(s)):i.push(fE(t,s,r));return r.style==="label"||r.style==="matrix"?`${n}${i.join(n)}`:i.join(n)}function sQ(t){return function(r){let n=[];if(r&&typeof r=="object")for(let i in r){let s=r[i];if(s!=null){if(Array.isArray(s)){if(s.length===0)continue;n.push(lQ(i,s,{style:"form",explode:!0,...t?.array,allowReserved:t?.allowReserved||!1}));continue}if(typeof s=="object"){n.push(cQ(i,s,{style:"deepObject",explode:!0,...t?.object,allowReserved:t?.allowReserved||!1}));continue}n.push(fE(i,s,t))}}return n.join("&")}}function HIe(t,e){let r=t;for(let n of t.match(BIe)??[]){let i=n.substring(1,n.length-1),s=!1,o="simple";if(i.endsWith("*")&&(s=!0,i=i.substring(0,i.length-1)),i.startsWith(".")?(o="label",i=i.substring(1)):i.startsWith(";")&&(o="matrix",i=i.substring(1)),!e||e[i]===void 0||e[i]===null)continue;let a=e[i];if(Array.isArray(a)){r=r.replace(n,lQ(i,a,{style:o,explode:s}));continue}if(typeof a=="object"){r=r.replace(n,cQ(i,a,{style:o,explode:s}));continue}if(o==="matrix"){r=r.replace(n,`;${fE(i,a)}`);continue}r=r.replace(n,o==="label"?`.${encodeURIComponent(a)}`:encodeURIComponent(a))}return r}function qIe(t,e){return t instanceof FormData?t:e&&(e.get instanceof Function?e.get("Content-Type")??e.get("content-type"):e["Content-Type"]??e["content-type"])==="application/x-www-form-urlencoded"?new URLSearchParams(t).toString():JSON.stringify(t)}function YIe(t,e){let r=`${e.baseUrl}${t}`;e.params?.path&&(r=HIe(r,e.params.path));let n=e.querySerializer(e.params.query??{});return n.startsWith("?")&&(n=n.substring(1)),n&&(r+=`?${n}`),r}function oQ(...t){let e=new Headers;for(let r of t){if(!r||typeof r!="object")continue;let n=r instanceof Headers?r.entries():Object.entries(r);for(let[i,s]of n)if(s===null)e.delete(i);else if(Array.isArray(s))for(let o of s)e.append(i,o);else s!==void 0&&e.set(i,s)}return e}function aQ(t){return t.endsWith("/")?t.substring(0,t.length-1):t}u();var e2=K(fN());var hE="2.8.3";u();var Jv=K(fN());function O9e(){return globalThis.Bun?{runtime:"bun",version:globalThis.Bun.version}:globalThis.Deno?{runtime:"deno",version:globalThis.Deno.version.deno}:globalThis.process?.release?.name==="node"?{runtime:"node",version:Jv.default.version||"unknown"}:typeof EdgeRuntime=="string"?{runtime:"vercel-edge",version:"unknown"}:globalThis.navigator?.userAgent==="Cloudflare-Workers"?{runtime:"cloudflare-worker",version:"unknown"}:typeof window<"u"?{runtime:"browser",version:Jv.default.version||"unknown"}:{runtime:"unknown",version:"unknown"}}var{runtime:Li,version:AZ}=O9e();async function OZ(t){if(typeof crypto<"u"){let i=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-256",i),o=new Uint8Array(s);return btoa(String.fromCharCode(...o))}let{createHash:e}=require("crypto");return e("sha256").update(t,"utf8").digest().toString("base64")}function AS(t){return Math.ceil(t/1e3)}async function NZ(){if(Li==="browser")throw new Error("Browser runtime is not supported for glob");return await Promise.resolve().then(()=>(pX(),fX))}async function vZ(){if(Li==="browser")throw new Error("Browser runtime is not supported for tar");return await Promise.resolve().then(()=>(RZ(),DZ))}function N9e({onlyFirst:t=!1}={}){let i="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(i,t?void 0:"g")}function OS(t){return t.replace(N9e(),"")}var IZ={browser:typeof window<"u"&&e2.default.name||"unknown",lang:"js",lang_version:AZ,package_version:hE,publisher:"e2b",sdk_runtime:Li,system:e2.default.os?.family||"unknown"};function xl(t){return Li==="deno"?Deno.env.get(t):typeof process>"u"?"":process.env[t]}u();function vS(t){return new Gd(`${t}: This error is likely due to sandbox timeout. You can modify the sandbox timeout by passing 'timeoutMs' when starting the sandbox or calling '.setTimeout' on the sandbox with the desired timeout.`)}var nr=class extends Error{constructor(e,r){super(e),this.name="SandboxError",r&&(this.stack=r)}},Gd=class extends nr{constructor(e,r){super(e,r),this.name="TimeoutError"}},Xa=class extends nr{constructor(e,r){super(e,r),this.name="InvalidArgumentError"}},NS=class extends nr{constructor(e,r){super(e,r),this.name="NotEnoughSpaceError"}},ni=class extends nr{constructor(e,r){super(e,r),this.name="NotFoundError"}},hs=class extends Error{constructor(e){super(e),this.name="AuthenticationError"}},Hd=class extends nr{constructor(e,r){super(e,r),this.name="TemplateError"}},Em=class extends nr{constructor(e){super(e),this.name="RateLimitError"}},Cn=class extends Error{constructor(e,r){super(e),this.name="BuildError",r&&(this.stack=r)}},Za=class extends Cn{constructor(e,r){super(e,r),this.name="FileUploadError"}};u();function wZ(t){return JSON.parse(JSON.stringify(t))}function LZ(t){async function*e(r){for await(let n of r)t.debug?.("Response stream:",wZ(n)),yield n}return r=>async n=>{t.info?.(`Request: POST ${n.url}`);let i=await r(n);return i.stream?{...i,message:e(i.message)}:(t.info?.("Response:",wZ(i.message)),i)}}function IS(t){return{async onRequest({request:e}){return t.info?.(`Request ${e.method} ${e.url}`),e},async onResponse({response:e}){return e.status>=400?t.error?.("Response:",e.status,e.statusText):t.info?.("Response:",e.status,e.statusText),e}}}function Gn(t,e=nr,r){if(!t.error)return;if(t.response.status===401){let i="Unauthorized, please check your credentials.",s=t.error?.message??t.error;return s?new hs(`${i} - ${s}`):new hs(i)}if(t.response.status===429){let i="Rate limit exceeded, please try again later",s=t.error?.message??t.error;return s?new Em(`${i} - ${s}`):new Em(i)}let n=t.error?.message??t.error;return new e(`${t.response.status}: ${n}`,r)}var Fr=class{api;constructor(e,r={requireAccessToken:!1,requireApiKey:!1}){if(r?.requireApiKey&&!e.apiKey)throw new hs("API key is required, please visit https://console.ucloud.cn/modelverse/experience/api-keys to get your API key. You can either set the environment variable `E2B_API_KEY` or you can pass it directly to the sandbox like Sandbox.create({ apiKey: '...' })");if(r?.requireAccessToken&&!e.accessToken)throw new hs("Access token is required, please visit https://console.ucloud.cn/modelverse/experience/api-keys to get your access token. You can set the environment variable `E2B_ACCESS_TOKEN` or pass the `accessToken` in options.");this.api=dE({baseUrl:e.apiUrl,headers:{...IZ,...e.apiKey&&{"X-API-Key":e.apiKey},...e.headers},querySerializer:{array:{style:"form",explode:!1}}}),e.logger&&this.api.use(IS(e.logger))}};u();var v9e=6e4,wS=3e5,Cl=50,Dl="Keepalive-Ping-Interval",Qt=class t{static envdPort=49983;debug;domain;apiUrl;sandboxUrl;logger;requestTimeoutMs;apiKey;accessToken;headers;constructor(e){this.apiKey=e?.apiKey||t.apiKey,this.debug=e?.debug||t.debug,this.domain=e?.domain||t.domain,this.accessToken=e?.accessToken||t.accessToken,this.requestTimeoutMs=e?.requestTimeoutMs??v9e,this.logger=e?.logger,this.headers=e?.headers||{},this.headers["User-Agent"]=`e2b-js-sdk/${hE}`,this.apiUrl=e?.apiUrl||t.apiUrl||(this.debug?"http://localhost:3000":`https://api.${this.domain}`),this.sandboxUrl=e?.sandboxUrl||t.sandboxUrl}static get domain(){return xl("E2B_DOMAIN")||"sandbox.ucloudai.com"}static get apiUrl(){return xl("E2B_API_URL")}static get sandboxUrl(){return xl("E2B_SANDBOX_URL")}static get debug(){return(xl("E2B_DEBUG")||"false").toLowerCase()==="true"}static get apiKey(){return xl("E2B_API_KEY")}static get accessToken(){return xl("E2B_ACCESS_TOKEN")}getSignal(e){let r=e??this.requestTimeoutMs;return r?AbortSignal.timeout(r):void 0}getSandboxUrl(e,r){return this.sandboxUrl?this.sandboxUrl:`${this.debug?"http":"https"}://${this.getHost(e,r.envdPort,r.sandboxDomain)}`}getHost(e,r,n){return this.debug?`localhost:${r}`:`${r}-${e}.${n??this.domain}`}},Ja="user";u();async function t2({path:t,operation:e,user:r,expirationInSeconds:n,envdAccessToken:i}){if(!i)throw new Error("Access token is not set and signature cannot be generated!");let s=n?Math.floor(Date.now()/1e3)+n:null,o;return r==null&&(r=""),s===null?o=`${t}:${e}:${r}:${i}`:o=`${t}:${e}:${r}:${i}:${s.toString()}`,{signature:"v1_"+(await OZ(o)).replace(/=+$/,""),expiration:s}}u();u();u();u();var Le;(function(t){t[t.Canceled=1]="Canceled",t[t.Unknown=2]="Unknown",t[t.InvalidArgument=3]="InvalidArgument",t[t.DeadlineExceeded=4]="DeadlineExceeded",t[t.NotFound=5]="NotFound",t[t.AlreadyExists=6]="AlreadyExists",t[t.PermissionDenied=7]="PermissionDenied",t[t.ResourceExhausted=8]="ResourceExhausted",t[t.FailedPrecondition=9]="FailedPrecondition",t[t.Aborted=10]="Aborted",t[t.OutOfRange=11]="OutOfRange",t[t.Unimplemented=12]="Unimplemented",t[t.Internal=13]="Internal",t[t.Unavailable=14]="Unavailable",t[t.DataLoss=15]="DataLoss",t[t.Unauthenticated=16]="Unauthenticated"})(Le||(Le={}));u();u();function Sm(t,e){return t!==null&&typeof t=="object"&&"$typeName"in t&&typeof t.$typeName=="string"?e===void 0?!0:e.typeName===t.$typeName:!1}u();u();var j;(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(j||(j={}));u();u();u();function PZ(){let t=0,e=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(t|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[t,e]}let r=this.buf[this.pos++];if(t|=(r&15)<<28,e=(r&112)>>4,(r&128)==0)return this.assertBounds(),[t,e];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function MS(t,e,r){for(let s=0;s<28;s=s+7){let o=t>>>s,a=!(!(o>>>7)&&e==0),c=(a?o|128:o)&255;if(r.push(c),!a)return}let n=t>>>28&15|(e&7)<<4,i=e>>3!=0;if(r.push((i?n|128:n)&255),!!i){for(let s=3;s<31;s=s+7){let o=e>>>s,a=!!(o>>>7),c=(a?o|128:o)&255;if(r.push(c),!a)return}r.push(e>>>31&1)}}var LS=4294967296;function r2(t){let e=t[0]==="-";e&&(t=t.slice(1));let r=1e6,n=0,i=0;function s(o,a){let c=Number(t.slice(o,a));i*=r,n=n*r+c,n>=LS&&(i=i+(n/LS|0),n=n%LS)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?kZ(n,i):i2(n,i)}function FZ(t,e){let r=i2(t,e),n=r.hi&2147483648;n&&(r=kZ(r.lo,r.hi));let i=n2(r.lo,r.hi);return n?"-"+i:i}function n2(t,e){if({lo:t,hi:e}=I9e(t,e),e<=2097151)return String(LS*e+t);let r=t&16777215,n=(t>>>24|e<<8)&16777215,i=e>>16&65535,s=r+n*6777216+i*6710656,o=n+i*8147497,a=i*2,c=1e7;return s>=c&&(o+=Math.floor(s/c),s%=c),o>=c&&(a+=Math.floor(o/c),o%=c),a.toString()+MZ(o)+MZ(s)}function I9e(t,e){return{lo:t>>>0,hi:e>>>0}}function i2(t,e){return{lo:t|0,hi:e|0}}function kZ(t,e){return e=~e,t?t=~t+1:e+=1,i2(t,e)}var MZ=t=>{let e=String(t);return"0000000".slice(e.length)+e};function bm(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let r=0;r<9;r++)e.push(t&127|128),t=t>>7;e.push(1)}}function BZ(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,(t&128)==0)return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let r=5;(t&128)!==0&&r<10;r++)t=this.buf[this.pos++];if((t&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var mt=w9e();function w9e(){let t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(!!globalThis.Deno||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let r=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),i=BigInt("0"),s=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(o){let a=typeof o=="bigint"?o:BigInt(o);if(a>n||a<r)throw new Error(`invalid int64: ${o}`);return a},uParse(o){let a=typeof o=="bigint"?o:BigInt(o);if(a>s||a<i)throw new Error(`invalid uint64: ${o}`);return a},enc(o){return t.setBigInt64(0,this.parse(o),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(o){return t.setBigInt64(0,this.uParse(o),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec(o,a){return t.setInt32(0,o,!0),t.setInt32(4,a,!0),t.getBigInt64(0,!0)},uDec(o,a){return t.setInt32(0,o,!0),t.setInt32(4,a,!0),t.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),UZ(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),GZ(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),UZ(r),r2(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),GZ(r),r2(r)},dec(r,n){return FZ(r,n)},uDec(r,n){return n2(r,n)}}}function UZ(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function GZ(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}function ii(t,e){switch(t){case j.STRING:return"";case j.BOOL:return!1;case j.DOUBLE:case j.FLOAT:return 0;case j.INT64:case j.UINT64:case j.SFIXED64:case j.FIXED64:case j.SINT64:return e?"0":mt.zero;case j.BYTES:return new Uint8Array(0);default:return 0}}function HZ(t,e){switch(t){case j.BOOL:return e===!1;case j.STRING:return e==="";case j.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}u();u();var qZ=2,ms=Symbol.for("reflect unsafe local");function PS(t,e){let r=t[e.localName].case;return r===void 0?r:e.fields.find(n=>n.localName===r)}function YZ(t,e){let r=e.localName;if(e.oneof)return t[e.oneof.localName].case===r;if(e.presence!=qZ)return t[r]!==void 0&&Object.prototype.hasOwnProperty.call(t,r);switch(e.fieldKind){case"list":return t[r].length>0;case"map":return Object.keys(t[r]).length>0;case"scalar":return!HZ(e.scalar,t[r]);case"enum":return t[r]!==e.enum.values[0].number}throw new Error("message field with implicit presence")}function Rl(t,e){return Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==void 0}function FS(t,e){if(e.oneof){let r=t[e.oneof.localName];return r.case===e.localName?r.value:void 0}return t[e.localName]}function kS(t,e,r){e.oneof?t[e.oneof.localName]={case:e.localName,value:r}:t[e.localName]=r}function $Z(t,e){let r=e.localName;if(e.oneof){let n=e.oneof.localName;t[n].case===r&&(t[n]={case:void 0})}else if(e.presence!=qZ)delete t[r];else switch(e.fieldKind){case"map":t[r]={};break;case"list":t[r]=[];break;case"enum":t[r]=e.enum.values[0].number;break;case"scalar":t[r]=ii(e.scalar,e.longAsString);break}}function Vs(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Tm(t,e){var r,n,i,s;if(Vs(t)&&ms in t&&"add"in t&&"field"in t&&typeof t.field=="function"){if(e!==void 0){let o=e,a=t.field();return o.listKind==a.listKind&&o.scalar===a.scalar&&((r=o.message)===null||r===void 0?void 0:r.typeName)===((n=a.message)===null||n===void 0?void 0:n.typeName)&&((i=o.enum)===null||i===void 0?void 0:i.typeName)===((s=a.enum)===null||s===void 0?void 0:s.typeName)}return!0}return!1}function ym(t,e){var r,n,i,s;if(Vs(t)&&ms in t&&"has"in t&&"field"in t&&typeof t.field=="function"){if(e!==void 0){let o=e,a=t.field();return o.mapKey===a.mapKey&&o.mapKind==a.mapKind&&o.scalar===a.scalar&&((r=o.message)===null||r===void 0?void 0:r.typeName)===((n=a.message)===null||n===void 0?void 0:n.typeName)&&((i=o.enum)===null||i===void 0?void 0:i.typeName)===((s=a.enum)===null||s===void 0?void 0:s.typeName)}return!0}return!1}function xm(t,e){return Vs(t)&&ms in t&&"desc"in t&&Vs(t.desc)&&t.desc.kind==="message"&&(e===void 0||t.desc.typeName==e.typeName)}u();function VZ(t){return WZ(t.$typeName)}function Ws(t){let e=t.fields[0];return WZ(t.typeName)&&e!==void 0&&e.fieldKind=="scalar"&&e.name=="value"&&e.number==1}function WZ(t){return t.startsWith("google.protobuf.")&&["DoubleValue","FloatValue","Int64Value","UInt64Value","Int32Value","UInt32Value","BoolValue","StringValue","BytesValue"].includes(t.substring(16))}var L9e=999,M9e=998,BS=2;function Kr(t,e){if(Sm(e,t))return e;let r=U9e(t);return e!==void 0&&P9e(t,r,e),r}function P9e(t,e,r){for(let n of t.members){let i=r[n.localName];if(i==null)continue;let s;if(n.kind=="oneof"){let o=PS(r,n);if(!o)continue;s=o,i=FS(r,o)}else s=n;switch(s.fieldKind){case"message":i=o2(s,i);break;case"scalar":i=jZ(s,i);break;case"list":i=k9e(s,i);break;case"map":i=F9e(s,i);break}kS(e,s,i)}return e}function jZ(t,e){return t.scalar==j.BYTES?a2(e):e}function F9e(t,e){if(Vs(e)){if(t.scalar==j.BYTES)return zZ(e,a2);if(t.mapKind=="message")return zZ(e,r=>o2(t,r))}return e}function k9e(t,e){if(Array.isArray(e)){if(t.scalar==j.BYTES)return e.map(a2);if(t.listKind=="message")return e.map(r=>o2(t,r))}return e}function o2(t,e){if(t.fieldKind=="message"&&!t.oneof&&Ws(t.message))return jZ(t.message.fields[0],e);if(Vs(e)){if(t.message.typeName=="google.protobuf.Struct"&&t.parent.typeName!=="google.protobuf.Value")return e;if(!Sm(e,t.message))return Kr(t.message,e)}return e}function a2(t){return Array.isArray(t)?new Uint8Array(t):t}function zZ(t,e){let r={};for(let n of Object.entries(t))r[n[0]]=e(n[1]);return r}var B9e=Symbol(),KZ=new WeakMap;function U9e(t){let e;if(G9e(t)){let r=KZ.get(t),n,i;if(r)({prototype:n,members:i}=r);else{n={},i=new Set;for(let s of t.members)s.kind!="oneof"&&(s.fieldKind!="scalar"&&s.fieldKind!="enum"||s.presence!=BS&&(i.add(s),n[s.localName]=s2(s)));KZ.set(t,{prototype:n,members:i})}e=Object.create(n),e.$typeName=t.typeName;for(let s of t.members)i.has(s)||s.kind=="field"&&(s.fieldKind=="message"||(s.fieldKind=="scalar"||s.fieldKind=="enum")&&s.presence!=BS)||(e[s.localName]=s2(s))}else{e={$typeName:t.typeName};for(let r of t.members)(r.kind=="oneof"||r.presence==BS)&&(e[r.localName]=s2(r))}return e}function G9e(t){switch(t.file.edition){case L9e:return!1;case M9e:return!0;default:return t.fields.some(e=>e.presence!=BS&&e.fieldKind!="message"&&!e.oneof)}}function s2(t){if(t.kind=="oneof")return{case:void 0};if(t.fieldKind=="list")return[];if(t.fieldKind=="map")return{};if(t.fieldKind=="message")return B9e;let e=t.getDefaultValue();return e!==void 0?t.fieldKind=="scalar"&&t.longAsString?e.toString():e:t.fieldKind=="scalar"?ii(t.scalar,t.longAsString):t.enum.values[0].number}u();u();u();var H9e=["FieldValueInvalidError","FieldListRangeError","ForeignFieldError"],xr=class extends Error{constructor(e,r,n="FieldValueInvalidError"){super(r),this.name=n,this.field=()=>e}};function QZ(t){return t instanceof Error&&H9e.includes(t.name)&&"field"in t&&typeof t.field=="function"}u();u();var c2=Symbol.for("@bufbuild/protobuf/text-encoding");function Cm(){if(globalThis[c2]==null){let t=new globalThis.TextEncoder,e=new globalThis.TextDecoder;globalThis[c2]={encodeUtf8(r){return t.encode(r)},decodeUtf8(r){return e.decode(r)},checkUtf8(r){try{return encodeURIComponent(r),!0}catch{return!1}}}}return globalThis[c2]}var Xt;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(Xt||(Xt={}));var u2=34028234663852886e22,d2=-34028234663852886e22,f2=4294967295,p2=2147483647,h2=-2147483648,qd=class{constructor(e=Cm().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let i=0;i<this.chunks.length;i++)e+=this.chunks[i].length;let r=new Uint8Array(e),n=0;for(let i=0;i<this.chunks.length;i++)r.set(this.chunks[i],n),n+=this.chunks[i].length;return this.chunks=[],r}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),r=this.stack.pop();if(!r)throw new Error("invalid state, fork stack empty");return this.chunks=r.chunks,this.buf=r.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,r){return this.uint32((e<<3|r)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(XZ(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return l2(e),bm(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let r=this.encodeUtf8(e);return this.uint32(r.byteLength),this.raw(r)}float(e){q9e(e);let r=new Uint8Array(4);return new DataView(r.buffer).setFloat32(0,e,!0),this.raw(r)}double(e){let r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,e,!0),this.raw(r)}fixed32(e){XZ(e);let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,e,!0),this.raw(r)}sfixed32(e){l2(e);let r=new Uint8Array(4);return new DataView(r.buffer).setInt32(0,e,!0),this.raw(r)}sint32(e){return l2(e),e=(e<<1^e>>31)>>>0,bm(e,this.buf),this}sfixed64(e){let r=new Uint8Array(8),n=new DataView(r.buffer),i=mt.enc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(r)}fixed64(e){let r=new Uint8Array(8),n=new DataView(r.buffer),i=mt.uEnc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(r)}int64(e){let r=mt.enc(e);return MS(r.lo,r.hi,this.buf),this}sint64(e){let r=mt.enc(e),n=r.hi>>31,i=r.lo<<1^n,s=(r.hi<<1|r.lo>>>31)^n;return MS(i,s,this.buf),this}uint64(e){let r=mt.uEnc(e);return MS(r.lo,r.hi,this.buf),this}},Al=class{constructor(e,r=Cm().decodeUtf8){this.decodeUtf8=r,this.varint64=PZ,this.uint32=BZ,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),r=e>>>3,n=e&7;if(r<=0||n<0||n>5)throw new Error("illegal tag: field no "+r+" wire type "+n);return[r,n]}skip(e,r){let n=this.pos;switch(e){case Xt.Varint:for(;this.buf[this.pos++]&128;);break;case Xt.Bit64:this.pos+=4;case Xt.Bit32:this.pos+=4;break;case Xt.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Xt.StartGroup:for(;;){let[s,o]=this.tag();if(o===Xt.EndGroup){if(r!==void 0&&s!==r)throw new Error("invalid end group tag");break}this.skip(o,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return mt.dec(...this.varint64())}uint64(){return mt.uDec(...this.varint64())}sint64(){let[e,r]=this.varint64(),n=-(e&1);return e=(e>>>1|(r&1)<<31)^n,r=r>>>1^n,mt.dec(e,r)}bool(){let[e,r]=this.varint64();return e!==0||r!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return mt.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return mt.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),r=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(r,r+e)}string(){return this.decodeUtf8(this.bytes())}};function l2(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid int32: "+typeof t);if(!Number.isInteger(t)||t>p2||t<h2)throw new Error("invalid int32: "+t)}function XZ(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid uint32: "+typeof t);if(!Number.isInteger(t)||t>f2||t<0)throw new Error("invalid uint32: "+t)}function q9e(t){if(typeof t=="string"){let e=t;if(t=Number(t),Number.isNaN(t)&&e!=="NaN")throw new Error("invalid float32: "+e)}else if(typeof t!="number")throw new Error("invalid float32: "+typeof t);if(Number.isFinite(t)&&(t>u2||t<d2))throw new Error("invalid float32: "+t)}function ko(t,e){let r=t.fieldKind=="list"?Tm(e,t):t.fieldKind=="map"?ym(e,t):_2(t,e);if(r===!0)return;let n;switch(t.fieldKind){case"list":n=`expected ${tJ(t)}, got ${pr(e)}`;break;case"map":n=`expected ${rJ(t)}, got ${pr(e)}`;break;default:n=US(t,e,r)}return new xr(t,n)}function m2(t,e,r){let n=_2(t,r);if(n!==!0)return new xr(t,`list item #${e+1}: ${US(t,r,n)}`)}function ZZ(t,e,r){let n=JZ(e,t.mapKey);if(n!==!0)return new xr(t,`invalid map key: ${US({scalar:t.mapKey},e,n)}`);let i=_2(t,r);if(i!==!0)return new xr(t,`map entry ${pr(e)}: ${US(t,r,i)}`)}function _2(t,e){return t.scalar!==void 0?JZ(e,t.scalar):t.enum!==void 0?t.enum.open?Number.isInteger(e):t.enum.values.some(r=>r.number===e):xm(e,t.message)}function JZ(t,e){switch(e){case j.DOUBLE:return typeof t=="number";case j.FLOAT:return typeof t!="number"?!1:Number.isNaN(t)||!Number.isFinite(t)?!0:t>u2||t<d2?`${t.toFixed()} out of range`:!0;case j.INT32:case j.SFIXED32:case j.SINT32:return typeof t!="number"||!Number.isInteger(t)?!1:t>p2||t<h2?`${t.toFixed()} out of range`:!0;case j.FIXED32:case j.UINT32:return typeof t!="number"||!Number.isInteger(t)?!1:t>f2||t<0?`${t.toFixed()} out of range`:!0;case j.BOOL:return typeof t=="boolean";case j.STRING:return typeof t!="string"?!1:Cm().checkUtf8(t)||"invalid UTF8";case j.BYTES:return t instanceof Uint8Array;case j.INT64:case j.SFIXED64:case j.SINT64:if(typeof t=="bigint"||typeof t=="number"||typeof t=="string"&&t.length>0)try{return mt.parse(t),!0}catch{return`${t} out of range`}return!1;case j.FIXED64:case j.UINT64:if(typeof t=="bigint"||typeof t=="number"||typeof t=="string"&&t.length>0)try{return mt.uParse(t),!0}catch{return`${t} out of range`}return!1}}function US(t,e,r){return r=typeof r=="string"?`: ${r}`:`, got ${pr(e)}`,t.scalar!==void 0?`expected ${Y9e(t.scalar)}`+r:t.enum!==void 0?`expected ${t.enum.toString()}`+r:`expected ${eJ(t.message)}`+r}function pr(t){switch(typeof t){case"object":return t===null?"null":t instanceof Uint8Array?`Uint8Array(${t.length})`:Array.isArray(t)?`Array(${t.length})`:Tm(t)?tJ(t.field()):ym(t)?rJ(t.field()):xm(t)?eJ(t.desc):Sm(t)?`message ${t.$typeName}`:"object";case"string":return t.length>30?"string":`"${t.split('"').join('\\"')}"`;case"boolean":return String(t);case"number":return String(t);case"bigint":return String(t)+"n";default:return typeof t}}function eJ(t){return`ReflectMessage (${t.typeName})`}function tJ(t){switch(t.listKind){case"message":return`ReflectList (${t.message.toString()})`;case"enum":return`ReflectList (${t.enum.toString()})`;case"scalar":return`ReflectList (${j[t.scalar]})`}}function rJ(t){switch(t.mapKind){case"message":return`ReflectMap (${j[t.mapKey]}, ${t.message.toString()})`;case"enum":return`ReflectMap (${j[t.mapKey]}, ${t.enum.toString()})`;case"scalar":return`ReflectMap (${j[t.mapKey]}, ${j[t.scalar]})`}}function Y9e(t){switch(t){case j.STRING:return"string";case j.BOOL:return"boolean";case j.INT64:case j.SINT64:case j.SFIXED64:return"bigint (int64)";case j.UINT64:case j.FIXED64:return"bigint (uint64)";case j.BYTES:return"Uint8Array";case j.DOUBLE:return"number (float64)";case j.FLOAT:return"number (float32)";case j.FIXED32:case j.UINT32:return"number (uint32)";case j.INT32:case j.SFIXED32:case j.SINT32:return"number (int32)"}}function jr(t,e,r=!0){return new HS(t,e,r)}var nJ=new WeakMap,HS=class{get sortedFields(){let e=nJ.get(this.desc);if(e)return e;let r=this.desc.fields.concat().sort((n,i)=>n.number-i.number);return nJ.set(this.desc,r),r}constructor(e,r,n=!0){this.lists=new Map,this.maps=new Map,this.check=n,this.desc=e,this.message=this[ms]=r??Kr(e),this.fields=e.fields,this.oneofs=e.oneofs,this.members=e.members}findNumber(e){return this._fieldsByNumber||(this._fieldsByNumber=new Map(this.desc.fields.map(r=>[r.number,r]))),this._fieldsByNumber.get(e)}oneofCase(e){return Dm(this.message,e),PS(this.message,e)}isSet(e){return Dm(this.message,e),YZ(this.message,e)}clear(e){Dm(this.message,e),$Z(this.message,e)}get(e){Dm(this.message,e);let r=FS(this.message,e);switch(e.fieldKind){case"list":let n=this.lists.get(e);return(!n||n[ms]!==r)&&this.lists.set(e,n=new S2(e,r,this.check)),n;case"map":let i=this.maps.get(e);return(!i||i[ms]!==r)&&this.maps.set(e,i=new b2(e,r,this.check)),i;case"message":return y2(e,r,this.check);case"scalar":return r===void 0?ii(e.scalar,!1):x2(e,r);case"enum":return r??e.enum.values[0].number}}set(e,r){if(Dm(this.message,e),this.check){let i=ko(e,r);if(i)throw i}let n;e.fieldKind=="message"?n=T2(e,r):ym(r)||Tm(r)?n=r[ms]:n=C2(e,r),kS(this.message,e,n)}getUnknown(){return this.message.$unknown}setUnknown(e){this.message.$unknown=e}};function Dm(t,e){if(e.parent.typeName!==t.$typeName)throw new xr(e,`cannot use ${e.toString()} with message ${t.$typeName}`,"ForeignFieldError")}var S2=class{field(){return this._field}get size(){return this._arr.length}constructor(e,r,n){this._field=e,this._arr=this[ms]=r,this.check=n}get(e){let r=this._arr[e];return r===void 0?void 0:g2(this._field,r,this.check)}set(e,r){if(e<0||e>=this._arr.length)throw new xr(this._field,`list item #${e+1}: out of range`);if(this.check){let n=m2(this._field,e,r);if(n)throw n}this._arr[e]=iJ(this._field,r)}add(e){if(this.check){let r=m2(this._field,this._arr.length,e);if(r)throw r}this._arr.push(iJ(this._field,e))}clear(){this._arr.splice(0,this._arr.length)}[Symbol.iterator](){return this.values()}keys(){return this._arr.keys()}*values(){for(let e of this._arr)yield g2(this._field,e,this.check)}*entries(){for(let e=0;e<this._arr.length;e++)yield[e,g2(this._field,this._arr[e],this.check)]}};var b2=class{constructor(e,r,n=!0){this.obj=this[ms]=r??{},this.check=n,this._field=e}field(){return this._field}set(e,r){if(this.check){let n=ZZ(this._field,e,r);if(n)throw n}return this.obj[GS(e)]=$9e(this._field,r),this}delete(e){let r=GS(e),n=Object.prototype.hasOwnProperty.call(this.obj,r);return n&&delete this.obj[r],n}clear(){for(let e of Object.keys(this.obj))delete this.obj[e]}get(e){let r=this.obj[GS(e)];return r!==void 0&&(r=E2(this._field,r,this.check)),r}has(e){return Object.prototype.hasOwnProperty.call(this.obj,GS(e))}*keys(){for(let e of Object.keys(this.obj))yield sJ(e,this._field.mapKey)}*entries(){for(let e of Object.entries(this.obj))yield[sJ(e[0],this._field.mapKey),E2(this._field,e[1],this.check)]}[Symbol.iterator](){return this.entries()}get size(){return Object.keys(this.obj).length}*values(){for(let e of Object.values(this.obj))yield E2(this._field,e,this.check)}forEach(e,r){for(let n of this.entries())e.call(r,n[1],n[0],this)}};function T2(t,e){return xm(e)?VZ(e.message)&&!t.oneof&&t.fieldKind=="message"?e.message.value:e.desc.typeName=="google.protobuf.Struct"&&t.parent.typeName!="google.protobuf.Value"?aJ(e.message):e.message:e}function y2(t,e,r){return e!==void 0&&(Ws(t.message)&&!t.oneof&&t.fieldKind=="message"?e={$typeName:t.message.typeName,value:x2(t.message.fields[0],e)}:t.message.typeName=="google.protobuf.Struct"&&t.parent.typeName!="google.protobuf.Value"&&Vs(e)&&(e=oJ(e))),new HS(t.message,e,r)}function iJ(t,e){return t.listKind=="message"?T2(t,e):C2(t,e)}function g2(t,e,r){return t.listKind=="message"?y2(t,e,r):x2(t,e)}function $9e(t,e){return t.mapKind=="message"?T2(t,e):C2(t,e)}function E2(t,e,r){return t.mapKind=="message"?y2(t,e,r):e}function GS(t){return typeof t=="string"||typeof t=="number"?t:String(t)}function sJ(t,e){switch(e){case j.STRING:return t;case j.INT32:case j.FIXED32:case j.UINT32:case j.SFIXED32:case j.SINT32:{let r=Number.parseInt(t);if(Number.isFinite(r))return r;break}case j.BOOL:switch(t){case"true":return!0;case"false":return!1}break;case j.UINT64:case j.FIXED64:try{return mt.uParse(t)}catch{}break;default:try{return mt.parse(t)}catch{}break}return t}function x2(t,e){switch(t.scalar){case j.INT64:case j.SFIXED64:case j.SINT64:"longAsString"in t&&t.longAsString&&typeof e=="string"&&(e=mt.parse(e));break;case j.FIXED64:case j.UINT64:"longAsString"in t&&t.longAsString&&typeof e=="string"&&(e=mt.uParse(e));break}return e}function C2(t,e){switch(t.scalar){case j.INT64:case j.SFIXED64:case j.SINT64:"longAsString"in t&&t.longAsString?e=String(e):(typeof e=="string"||typeof e=="number")&&(e=mt.parse(e));break;case j.FIXED64:case j.UINT64:"longAsString"in t&&t.longAsString?e=String(e):(typeof e=="string"||typeof e=="number")&&(e=mt.uParse(e));break}return e}function oJ(t){let e={$typeName:"google.protobuf.Struct",fields:{}};if(Vs(t))for(let[r,n]of Object.entries(t))e.fields[r]=lJ(n);return e}function aJ(t){let e={};for(let[r,n]of Object.entries(t.fields))e[r]=cJ(n);return e}function cJ(t){switch(t.kind.case){case"structValue":return aJ(t.kind.value);case"listValue":return t.kind.value.values.map(cJ);case"nullValue":case void 0:return null;default:return t.kind.value}}function lJ(t){let e={$typeName:"google.protobuf.Value",kind:{case:void 0}};switch(typeof t){case"number":e.kind={case:"numberValue",value:t};break;case"string":e.kind={case:"stringValue",value:t};break;case"boolean":e.kind={case:"boolValue",value:t};break;case"object":if(t===null)e.kind={case:"nullValue",value:0};else if(Array.isArray(t)){let r={$typeName:"google.protobuf.ListValue",values:[]};if(Array.isArray(t))for(let n of t)r.values.push(lJ(n));e.kind={case:"listValue",value:r}}else e.kind={case:"structValue",value:oJ(t)};break}return e}u();u();u();function $d(t){let e=V9e(),r=t.length*3/4;t[t.length-2]=="="?r-=2:t[t.length-1]=="="&&(r-=1);let n=new Uint8Array(r),i=0,s=0,o,a=0;for(let c=0;c<t.length;c++){if(o=e[t.charCodeAt(c)],o===void 0)switch(t[c]){case"=":s=0;case`
@@ -243,10 +243,10 @@ Selected team: ${r} (${n})`}function nQ(t,e){let r=Ae(t.name),n=Ae(t.teamID),i=t
243
243
  `;continue}if(r.type==="ENV"){let n=[];for(let i=0;i<r.args.length;i+=2)n.push(`${r.args[i]}=${r.args[i+1]}`);e+=`ENV ${n.join(" ")}
244
244
  `;continue}e+=`${r.type} ${r.args.join(" ")}
245
245
  `}return this.startCmd&&(e+=`ENTRYPOINT ${this.startCmd}
246
- `),e}async build(e,r){r.skipCache&&(this.force=!0),r.onBuildLogs?.(new Dn(new Date,"info",`Requesting build for template: ${r.alias}`));let{templateID:n,buildID:i}=await mte(e,{alias:r.alias,cpuCount:r.cpuCount??2,memoryMB:r.memoryMB??1024});r.onBuildLogs?.(new Dn(new Date,"info",`Template created with ID: ${n}, Build ID: ${i}`));let s=await this.instructionsWithHashes(),o=s.map(async(a,c)=>{if(a.type!=="COPY")return;let l=a.args.length>0?a.args[0]:null,d=a.filesHash??null;if(l===null||d===null)throw new Error("Source path and files hash are required");let f=a.forceUpload,p;c+1>=0&&c+1<this.stackTraces.length&&(p=this.stackTraces[c+1]);let{present:h,url:m}=await _te(e,{templateID:n,filesHash:d},p);f&&m!=null||h===!1&&m!=null?(await gte({fileName:l,fileContextPath:this.fileContextPath.toString(),url:m,ignorePatterns:[...this.fileIgnorePatterns,...uI(this.fileContextPath.toString())],resolveSymlinks:a.resolveSymlinks??!1},p),r.onBuildLogs?.(new Dn(new Date,"info",`Uploaded '${l}'`))):r.onBuildLogs?.(new Dn(new Date,"info",`Skipping upload of '${l}', already cached`))});return await Promise.all(o),r.onBuildLogs?.(new Dn(new Date,"info","All file uploads completed")),r.onBuildLogs?.(new Dn(new Date,"info","Starting building...")),await Ete(e,{templateID:n,buildID:i,template:this.serialize(s)}),{alias:r.alias,templateId:n,buildId:i}}async instructionsWithHashes(){return Promise.all(this.instructions.map(async(e,r)=>{if(e.type!=="COPY")return e;let n=e.args.length>0?e.args[0]:null,i=e.args.length>1?e.args[1]:null;if(n===null||i===null)throw new Error("Source path and destination path are required");let s;return r+1>=0&&r+1<this.stackTraces.length&&(s=this.stackTraces[r+1]),{...e,filesHash:await ute(n,i,this.fileContextPath.toString(),[...this.fileIgnorePatterns,...Li==="browser"?[]:uI(this.fileContextPath.toString())],e.resolveSymlinks??!1,s)}}))}serialize(e){let r={startCmd:this.startCmd,readyCmd:this.readyCmd,steps:e,force:this.force};return this.baseImage!==void 0&&(r.fromImage=this.baseImage),this.baseTemplate!==void 0&&(r.fromTemplate=this.baseTemplate),this.registryConfig!==void 0&&(r.fromImageRegistry=this.registryConfig),r}};function Hn(t){return new rc(t)}Hn.build=rc.build;Hn.buildInBackground=rc.buildInBackground;Hn.getBuildStatus=rc.getBuildStatus;Hn.toJSON=rc.toJSON;Hn.toDockerfile=rc.toDockerfile;u();u();var Hte=K(require("os")),qte=K(require("path")),ET=K(require("fs")),qn=qte.join(Hte.homedir(),".ucloud-sandbox-cli","config.json"),mDt=process.env.UCLOUD_SANDBOX_DOCS_BASE||`https://${process.env.UCLOUD_SANDBOX_DOMAIN||"sandbox.ucloudai.com"}/docs`;function Xr(){if(!ET.existsSync(qn))return null;try{let t=ET.readFileSync(qn,"utf8");return!t||t.trim()===""?null:JSON.parse(t)}catch{return null}}var ST=process.env.UCLOUD_SANDBOX_API_KEY,bT=process.env.UCLOUD_SANDBOX_ACCESS_TOKEN,$te=t=>{let e,r;switch(t){case"UCLOUD_SANDBOX_API_KEY":e="https://console.ucloud.cn/modelverse/experience/api-keys",r="API key";break;case"UCLOUD_SANDBOX_ACCESS_TOKEN":e="https://console.ucloud.cn/modelverse/experience/api-keys",r="access token";break}if(!e||!r)throw new Error(`Unknown key name: ${t}`);return Jn(`You must be logged in to use this command. Run ${Ae("ucloud-sandbox-cli auth login")}.
246
+ `),e}async build(e,r){r.skipCache&&(this.force=!0),r.onBuildLogs?.(new Dn(new Date,"info",`Requesting build for template: ${r.alias}`));let{templateID:n,buildID:i}=await mte(e,{alias:r.alias,cpuCount:r.cpuCount??2,memoryMB:r.memoryMB??1024});r.onBuildLogs?.(new Dn(new Date,"info",`Template created with ID: ${n}, Build ID: ${i}`));let s=await this.instructionsWithHashes(),o=s.map(async(a,c)=>{if(a.type!=="COPY")return;let l=a.args.length>0?a.args[0]:null,d=a.filesHash??null;if(l===null||d===null)throw new Error("Source path and files hash are required");let f=a.forceUpload,p;c+1>=0&&c+1<this.stackTraces.length&&(p=this.stackTraces[c+1]);let{present:h,url:m}=await _te(e,{templateID:n,filesHash:d},p);f&&m!=null||h===!1&&m!=null?(await gte({fileName:l,fileContextPath:this.fileContextPath.toString(),url:m,ignorePatterns:[...this.fileIgnorePatterns,...uI(this.fileContextPath.toString())],resolveSymlinks:a.resolveSymlinks??!1},p),r.onBuildLogs?.(new Dn(new Date,"info",`Uploaded '${l}'`))):r.onBuildLogs?.(new Dn(new Date,"info",`Skipping upload of '${l}', already cached`))});return await Promise.all(o),r.onBuildLogs?.(new Dn(new Date,"info","All file uploads completed")),r.onBuildLogs?.(new Dn(new Date,"info","Starting building...")),await Ete(e,{templateID:n,buildID:i,template:this.serialize(s)}),{alias:r.alias,templateId:n,buildId:i}}async instructionsWithHashes(){return Promise.all(this.instructions.map(async(e,r)=>{if(e.type!=="COPY")return e;let n=e.args.length>0?e.args[0]:null,i=e.args.length>1?e.args[1]:null;if(n===null||i===null)throw new Error("Source path and destination path are required");let s;return r+1>=0&&r+1<this.stackTraces.length&&(s=this.stackTraces[r+1]),{...e,filesHash:await ute(n,i,this.fileContextPath.toString(),[...this.fileIgnorePatterns,...Li==="browser"?[]:uI(this.fileContextPath.toString())],e.resolveSymlinks??!1,s)}}))}serialize(e){let r={startCmd:this.startCmd,readyCmd:this.readyCmd,steps:e,force:this.force};return this.baseImage!==void 0&&(r.fromImage=this.baseImage),this.baseTemplate!==void 0&&(r.fromTemplate=this.baseTemplate),this.registryConfig!==void 0&&(r.fromImageRegistry=this.registryConfig),r}};function Hn(t){return new rc(t)}Hn.build=rc.build;Hn.buildInBackground=rc.buildInBackground;Hn.getBuildStatus=rc.getBuildStatus;Hn.toJSON=rc.toJSON;Hn.toDockerfile=rc.toDockerfile;u();u();var Hte=K(require("os")),qte=K(require("path")),ET=K(require("fs")),qn=qte.join(Hte.homedir(),".ucloud-sandbox-cli","config.json"),mDt=process.env.UCLOUD_SANDBOX_DOCS_BASE||`https://${process.env.UCLOUD_SANDBOX_DOMAIN||"sandbox.ucloudai.com"}/docs`;function Xr(){if(!ET.existsSync(qn))return null;try{let t=ET.readFileSync(qn,"utf8");return!t||t.trim()===""?null:JSON.parse(t)}catch{return null}}var ST=process.env.AGENTBOX_API_KEY,bT=process.env.AGENTBOX_ACCESS_TOKEN,$te=t=>{let e,r;switch(t){case"AGENTBOX_API_KEY":e="https://console.ucloud.cn/modelverse/experience/api-keys",r="API key";break;case"AGENTBOX_ACCESS_TOKEN":e="https://console.ucloud.cn/modelverse/experience/api-keys",r="access token";break}if(!e||!r)throw new Error(`Unknown key name: ${t}`);return Jn(`You must be logged in to use this command. Run ${Ae("ucloud-sandbox-cli auth login")}.
247
247
 
248
248
  If you are seeing this message in CI/CD you may need to set the ${Ae(`${t}`)} environment variable.
249
- Visit ${ze(e)} to get the ${r}.`,{width:70,float:"center",padding:.5,margin:1,borderStyle:"round",borderColor:"redBright"})};function Yn(){if(ST||(ST=Xr()?.teamApiKey),!ST)console.error($te("UCLOUD_SANDBOX_API_KEY")),process.exit(1);else return ST}function Vte(){let t=Xr();return t||(console.error("No user config found, run `ucloud-sandbox-cli auth login` to log in first."),process.exit(1)),t}function nc(){if(!bT){let t=Xr();bT=t?.accessToken||t?.teamApiKey}if(!bT)console.error($te("UCLOUD_SANDBOX_API_KEY")),process.exit(1);else return bT}var Yte=Xr(),ki=new Qt({accessToken:process.env.UCLOUD_SANDBOX_ACCESS_TOKEN||Yte?.accessToken,apiKey:process.env.UCLOUD_SANDBOX_API_KEY||Yte?.teamApiKey,domain:process.env.UCLOUD_SANDBOX_DOMAIN||"sandbox.ucloudai.com",apiUrl:process.env.UCLOUD_SANDBOX_API_URL||"https://api.sandbox.ucloudai.com"}),Rn=new Fr(ki);u();var Es="sandbox.Dockerfile",df="Dockerfile";u();var An=new Sa("-p, --path <path>",`change root directory where command is executed to ${Ae("<path>")} directory`),Ss=new Sa("--config <config-toml>",`specify path to the config toml. By default tries to find ${Ae("./sandbox.toml")} in root directory.`),RDt=new Sa("-s, --select","select multiple sandbox templates from interactive list"),Zm=new Sa("-s, --select","select sandbox template from interactive list"),$o=new Sa("-t, --team <team-id>","specify the team ID that the operation will be associated with.");u();var QT=K(require("child_process")),Sne=K(Jte());var n_=K(require("fs")),Ko=K(require("path"));u();u();var Bi=K(sre()),Jm=K(cre()),mre=K(ure()),d4e=Object.prototype.toString,f4e=Error.prototype.toString,p4e=RegExp.prototype.toString,h4e=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",m4e=/^Symbol\((.*)\)(.*)$/;function _4e(t){return t!=+t?"NaN":t===0&&1/t<0?"-0":""+t}function dre(t,e=!1){if(t==null||t===!0||t===!1)return""+t;let r=typeof t;if(r==="number")return _4e(t);if(r==="string")return e?`"${t}"`:t;if(r==="function")return"[Function "+(t.name||"anonymous")+"]";if(r==="symbol")return h4e.call(t).replace(m4e,"Symbol($1)");let n=d4e.call(t).slice(8,-1);return n==="Date"?isNaN(t.getTime())?""+t:t.toISOString(t):n==="Error"||t instanceof Error?"["+f4e.call(t)+"]":n==="RegExp"?p4e.call(t):null}function Wo(t,e){let r=dre(t,e);return r!==null?r:JSON.stringify(t,function(n,i){let s=dre(this[n],e);return s!==null?s:i},2)}function _re(t){return t==null?[]:[].concat(t)}var gre,Ere,Sre,g4e=/\$\{\s*(\w+)\s*\}/g;gre=Symbol.toStringTag;var OT=class{constructor(e,r,n,i){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[gre]="Error",this.name="ValidationError",this.value=r,this.path=n,this.type=i,this.errors=[],this.inner=[],_re(e).forEach(s=>{if(On.isError(s)){this.errors.push(...s.errors);let o=s.inner.length?s.inner:[s];this.inner.push(...o)}else this.errors.push(s)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}};Ere=Symbol.hasInstance;Sre=Symbol.toStringTag;var On=class t extends Error{static formatError(e,r){let n=r.label||r.path||"this";return r=Object.assign({},r,{path:n,originalPath:r.path}),typeof e=="string"?e.replace(g4e,(i,s)=>Wo(r[s])):typeof e=="function"?e(r):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,r,n,i,s){let o=new OT(e,r,n,i);if(s)return o;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[Sre]="Error",this.name=o.name,this.message=o.message,this.type=o.type,this.value=o.value,this.path=o.path,this.errors=o.errors,this.inner=o.inner,Error.captureStackTrace&&Error.captureStackTrace(this,t)}static[Ere](e){return OT[Symbol.hasInstance](e)||super[Symbol.hasInstance](e)}},js={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:t,type:e,value:r,originalValue:n})=>{let i=n!=null&&n!==r?` (cast from the value \`${Wo(n,!0)}\`).`:".";return e!=="mixed"?`${t} must be a \`${e}\` type, but the final value was: \`${Wo(r,!0)}\``+i:`${t} must match the configured type. The validated value was: \`${Wo(r,!0)}\``+i}},$n={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},ic={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},yw={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},xw={isValue:"${path} field must be ${value}"},DT={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"},RT={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},bre={notType:t=>{let{path:e,value:r,spec:n}=t,i=n.types.length;if(Array.isArray(r)){if(r.length<i)return`${e} tuple value has too few items, expected a length of ${i} but got ${r.length} for value: \`${Wo(r,!0)}\``;if(r.length>i)return`${e} tuple value has too many items, expected a length of ${i} but got ${r.length} for value: \`${Wo(r,!0)}\``}return On.formatError(js.notType,t)}},UDt=Object.assign(Object.create(null),{mixed:js,string:$n,number:ic,date:yw,object:DT,array:RT,boolean:xw,tuple:bre}),BT=t=>t&&t.__isYupSchema__,NT=class t{static fromOptions(e,r){if(!r.then&&!r.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:n,then:i,otherwise:s}=r,o=typeof n=="function"?n:(...a)=>a.every(c=>c===n);return new t(e,(a,c)=>{var l;let d=o(...a)?i:s;return(l=d?.(c))!=null?l:c})}constructor(e,r){this.fn=void 0,this.refs=e,this.refs=e,this.fn=r}resolve(e,r){let n=this.refs.map(s=>s.getValue(r?.value,r?.parent,r?.context)),i=this.fn(n,e,r);if(i===void 0||i===e)return e;if(!BT(i))throw new TypeError("conditions must return a schema object");return i.resolve(r)}},CT={context:"$",value:"."};var zo=class{constructor(e,r={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===CT.context,this.isValue=this.key[0]===CT.value,this.isSibling=!this.isContext&&!this.isValue;let n=this.isContext?CT.context:this.isValue?CT.value:"";this.path=this.key.slice(n.length),this.getter=this.path&&(0,Bi.getter)(this.path,!0),this.map=r.map}getValue(e,r,n){let i=this.isContext?n:this.isValue?e:r;return this.getter&&(i=this.getter(i||{})),this.map&&(i=this.map(i)),i}cast(e,r){return this.getValue(e,r?.parent,r?.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}};zo.prototype.__isYupRef=!0;var bs=t=>t==null;function pf(t){function e({value:r,path:n="",options:i,originalValue:s,schema:o},a,c){let{name:l,test:d,params:f,message:p,skipAbsent:h}=t,{parent:m,context:_,abortEarly:E=o.spec.abortEarly,disableStackTrace:S=o.spec.disableStackTrace}=i,x={value:r,parent:m,context:_};function D(H={}){let te=Tre(Object.assign({value:r,originalValue:s,label:o.spec.label,path:H.path||n,spec:o.spec,disableStackTrace:H.disableStackTrace||S},f,H.params),x),oe=new On(On.formatError(H.message||p,te),r,te.path,H.type||l,te.disableStackTrace);return oe.params=te,oe}let A=E?a:c,P={path:n,parent:m,type:l,from:i.from,createError:D,resolve(H){return yre(H,x)},options:i,originalValue:s,schema:o},W=H=>{On.isError(H)?A(H):H?c(null):A(D())},B=H=>{On.isError(H)?A(H):a(H)};if(h&&bs(r))return W(!0);let O;try{var v;if(O=d.call(P,r,P),typeof((v=O)==null?void 0:v.then)=="function"){if(i.sync)throw new Error(`Validation test of type: "${P.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(O).then(W,B)}}catch(H){B(H);return}W(O)}return e.OPTIONS=t,e}function Tre(t,e){if(!t)return t;for(let r of Object.keys(t))t[r]=yre(t[r],e);return t}function yre(t,e){return zo.isRef(t)?t.getValue(e.value,e.parent,e.context):t}function E4e(t,e,r,n=r){let i,s,o;return e?((0,Bi.forEach)(e,(a,c,l)=>{let d=c?a.slice(1,a.length-1):a;t=t.resolve({context:n,parent:i,value:r});let f=t.type==="tuple",p=l?parseInt(d,10):0;if(t.innerType||f){if(f&&!l)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${o}" must contain an index to the tuple element, e.g. "${o}[0]"`);if(r&&p>=r.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${e}. because there is no value at that index. `);i=r,r=r&&r[p],t=f?t.spec.types[p]:t.innerType}if(!l){if(!t.fields||!t.fields[d])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${o} which is a type: "${t.type}")`);i=r,r=r&&r[d],t=t.fields[d]}s=d,o=c?"["+a+"]":"."+a}),{schema:t,parent:i,parentPath:s}):{parent:i,parentPath:e,schema:t}}var vT=class t extends Set{describe(){let e=[];for(let r of this.values())e.push(zo.isRef(r)?r.describe():r);return e}resolveAll(e){let r=[];for(let n of this.values())r.push(e(n));return r}clone(){return new t(this.values())}merge(e,r){let n=this.clone();return e.forEach(i=>n.add(i)),r.forEach(i=>n.delete(i)),n}};function hf(t,e=new Map){if(BT(t)||!t||typeof t!="object")return t;if(e.has(t))return e.get(t);let r;if(t instanceof Date)r=new Date(t.getTime()),e.set(t,r);else if(t instanceof RegExp)r=new RegExp(t),e.set(t,r);else if(Array.isArray(t)){r=new Array(t.length),e.set(t,r);for(let n=0;n<t.length;n++)r[n]=hf(t[n],e)}else if(t instanceof Map){r=new Map,e.set(t,r);for(let[n,i]of t.entries())r.set(n,hf(i,e))}else if(t instanceof Set){r=new Set,e.set(t,r);for(let n of t)r.add(hf(n,e))}else if(t instanceof Object){r={},e.set(t,r);for(let[n,i]of Object.entries(t))r[n]=hf(i,e)}else throw Error(`Unable to clone ${t}`);return r}function S4e(t){if(!(t!=null&&t.length))return;let e=[],r="",n=!1,i=!1;for(let s=0;s<t.length;s++){let o=t[s];if(o==="["&&!i){r&&(e.push(...r.split(".").filter(Boolean)),r=""),n=!0;continue}if(o==="]"&&!i){r&&(/^\d+$/.test(r)?e.push(r):e.push(r.replace(/^"|"$/g,"")),r=""),n=!1;continue}if(o==='"'){i=!i;continue}if(o==="."&&!n&&!i){r&&(e.push(r),r="");continue}r+=o}return r&&e.push(...r.split(".").filter(Boolean)),e}function b4e(t,e){let r=e?`${e}.${t.path}`:t.path;return t.errors.map(n=>({message:n,path:S4e(r)}))}function xre(t,e){var r;if(!((r=t.inner)!=null&&r.length)&&t.errors.length)return b4e(t,e);let n=e?`${e}.${t.path}`:t.path;return t.inner.flatMap(i=>xre(i,n))}var Zr=class{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new vT,this._blacklist=new vT,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(js.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},e?.spec),this.withMutation(r=>{r.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;let r=Object.create(Object.getPrototypeOf(this));return r.type=this.type,r._typeCheck=this._typeCheck,r._whitelist=this._whitelist.clone(),r._blacklist=this._blacklist.clone(),r.internalTests=Object.assign({},this.internalTests),r.exclusiveTests=Object.assign({},this.exclusiveTests),r.deps=[...this.deps],r.conditions=[...this.conditions],r.tests=[...this.tests],r.transforms=[...this.transforms],r.spec=hf(Object.assign({},this.spec,e)),r}label(e){let r=this.clone();return r.spec.label=e,r}meta(...e){if(e.length===0)return this.spec.meta;let r=this.clone();return r.spec.meta=Object.assign(r.spec.meta||{},e[0]),r}withMutation(e){let r=this._mutate;this._mutate=!0;let n=e(this);return this._mutate=r,n}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let r=this,n=e.clone(),i=Object.assign({},r.spec,n.spec);return n.spec=i,n.internalTests=Object.assign({},r.internalTests,n.internalTests),n._whitelist=r._whitelist.merge(e._whitelist,e._blacklist),n._blacklist=r._blacklist.merge(e._blacklist,e._whitelist),n.tests=r.tests,n.exclusiveTests=r.exclusiveTests,n.withMutation(s=>{e.tests.forEach(o=>{s.test(o.OPTIONS)})}),n.transforms=[...r.transforms,...n.transforms],n}isType(e){return e==null?!!(this.spec.nullable&&e===null||this.spec.optional&&e===void 0):this._typeCheck(e)}resolve(e){let r=this;if(r.conditions.length){let n=r.conditions;r=r.clone(),r.conditions=[],r=n.reduce((i,s)=>s.resolve(i,e),r),r=r.resolve(e)}return r}resolveOptions(e){var r,n,i,s;return Object.assign({},e,{from:e.from||[],strict:(r=e.strict)!=null?r:this.spec.strict,abortEarly:(n=e.abortEarly)!=null?n:this.spec.abortEarly,recursive:(i=e.recursive)!=null?i:this.spec.recursive,disableStackTrace:(s=e.disableStackTrace)!=null?s:this.spec.disableStackTrace})}cast(e,r={}){let n=this.resolve(Object.assign({},r,{value:e})),i=r.assert==="ignore-optionality",s=n._cast(e,r);if(r.assert!==!1&&!n.isType(s)){if(i&&bs(s))return s;let o=Wo(e),a=Wo(s);throw new TypeError(`The value of ${r.path||"field"} could not be cast to a value that satisfies the schema type: "${n.type}".
249
+ Visit ${ze(e)} to get the ${r}.`,{width:70,float:"center",padding:.5,margin:1,borderStyle:"round",borderColor:"redBright"})};function Yn(){if(ST||(ST=Xr()?.teamApiKey),!ST)console.error($te("AGENTBOX_API_KEY")),process.exit(1);else return ST}function Vte(){let t=Xr();return t||(console.error("No user config found, run `ucloud-sandbox-cli auth login` to log in first."),process.exit(1)),t}function nc(){if(!bT){let t=Xr();bT=t?.accessToken||t?.teamApiKey}if(!bT)console.error($te("AGENTBOX_API_KEY")),process.exit(1);else return bT}var Yte=Xr(),ki=new Qt({accessToken:process.env.AGENTBOX_ACCESS_TOKEN||Yte?.accessToken,apiKey:process.env.AGENTBOX_API_KEY||Yte?.teamApiKey,domain:process.env.UCLOUD_SANDBOX_DOMAIN||"sandbox.ucloudai.com",apiUrl:process.env.UCLOUD_SANDBOX_API_URL||"https://api.sandbox.ucloudai.com"}),Rn=new Fr(ki);u();var Es="sandbox.Dockerfile",df="Dockerfile";u();var An=new Sa("-p, --path <path>",`change root directory where command is executed to ${Ae("<path>")} directory`),Ss=new Sa("--config <config-toml>",`specify path to the config toml. By default tries to find ${Ae("./sandbox.toml")} in root directory.`),RDt=new Sa("-s, --select","select multiple sandbox templates from interactive list"),Zm=new Sa("-s, --select","select sandbox template from interactive list"),$o=new Sa("-t, --team <team-id>","specify the team ID that the operation will be associated with.");u();var QT=K(require("child_process")),Sne=K(Jte());var n_=K(require("fs")),Ko=K(require("path"));u();u();var Bi=K(sre()),Jm=K(cre()),mre=K(ure()),d4e=Object.prototype.toString,f4e=Error.prototype.toString,p4e=RegExp.prototype.toString,h4e=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",m4e=/^Symbol\((.*)\)(.*)$/;function _4e(t){return t!=+t?"NaN":t===0&&1/t<0?"-0":""+t}function dre(t,e=!1){if(t==null||t===!0||t===!1)return""+t;let r=typeof t;if(r==="number")return _4e(t);if(r==="string")return e?`"${t}"`:t;if(r==="function")return"[Function "+(t.name||"anonymous")+"]";if(r==="symbol")return h4e.call(t).replace(m4e,"Symbol($1)");let n=d4e.call(t).slice(8,-1);return n==="Date"?isNaN(t.getTime())?""+t:t.toISOString(t):n==="Error"||t instanceof Error?"["+f4e.call(t)+"]":n==="RegExp"?p4e.call(t):null}function Wo(t,e){let r=dre(t,e);return r!==null?r:JSON.stringify(t,function(n,i){let s=dre(this[n],e);return s!==null?s:i},2)}function _re(t){return t==null?[]:[].concat(t)}var gre,Ere,Sre,g4e=/\$\{\s*(\w+)\s*\}/g;gre=Symbol.toStringTag;var OT=class{constructor(e,r,n,i){this.name=void 0,this.message=void 0,this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=void 0,this.inner=void 0,this[gre]="Error",this.name="ValidationError",this.value=r,this.path=n,this.type=i,this.errors=[],this.inner=[],_re(e).forEach(s=>{if(On.isError(s)){this.errors.push(...s.errors);let o=s.inner.length?s.inner:[s];this.inner.push(...o)}else this.errors.push(s)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0]}};Ere=Symbol.hasInstance;Sre=Symbol.toStringTag;var On=class t extends Error{static formatError(e,r){let n=r.label||r.path||"this";return r=Object.assign({},r,{path:n,originalPath:r.path}),typeof e=="string"?e.replace(g4e,(i,s)=>Wo(r[s])):typeof e=="function"?e(r):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,r,n,i,s){let o=new OT(e,r,n,i);if(s)return o;super(),this.value=void 0,this.path=void 0,this.type=void 0,this.params=void 0,this.errors=[],this.inner=[],this[Sre]="Error",this.name=o.name,this.message=o.message,this.type=o.type,this.value=o.value,this.path=o.path,this.errors=o.errors,this.inner=o.inner,Error.captureStackTrace&&Error.captureStackTrace(this,t)}static[Ere](e){return OT[Symbol.hasInstance](e)||super[Symbol.hasInstance](e)}},js={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:t,type:e,value:r,originalValue:n})=>{let i=n!=null&&n!==r?` (cast from the value \`${Wo(n,!0)}\`).`:".";return e!=="mixed"?`${t} must be a \`${e}\` type, but the final value was: \`${Wo(r,!0)}\``+i:`${t} must match the configured type. The validated value was: \`${Wo(r,!0)}\``+i}},$n={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",datetime:"${path} must be a valid ISO date-time",datetime_precision:"${path} must be a valid ISO date-time with a sub-second precision of exactly ${precision} digits",datetime_offset:'${path} must be a valid ISO date-time with UTC "Z" timezone',trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},ic={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},yw={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},xw={isValue:"${path} field must be ${value}"},DT={noUnknown:"${path} field has unspecified keys: ${unknown}",exact:"${path} object contains unknown properties: ${properties}"},RT={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"},bre={notType:t=>{let{path:e,value:r,spec:n}=t,i=n.types.length;if(Array.isArray(r)){if(r.length<i)return`${e} tuple value has too few items, expected a length of ${i} but got ${r.length} for value: \`${Wo(r,!0)}\``;if(r.length>i)return`${e} tuple value has too many items, expected a length of ${i} but got ${r.length} for value: \`${Wo(r,!0)}\``}return On.formatError(js.notType,t)}},UDt=Object.assign(Object.create(null),{mixed:js,string:$n,number:ic,date:yw,object:DT,array:RT,boolean:xw,tuple:bre}),BT=t=>t&&t.__isYupSchema__,NT=class t{static fromOptions(e,r){if(!r.then&&!r.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:n,then:i,otherwise:s}=r,o=typeof n=="function"?n:(...a)=>a.every(c=>c===n);return new t(e,(a,c)=>{var l;let d=o(...a)?i:s;return(l=d?.(c))!=null?l:c})}constructor(e,r){this.fn=void 0,this.refs=e,this.refs=e,this.fn=r}resolve(e,r){let n=this.refs.map(s=>s.getValue(r?.value,r?.parent,r?.context)),i=this.fn(n,e,r);if(i===void 0||i===e)return e;if(!BT(i))throw new TypeError("conditions must return a schema object");return i.resolve(r)}},CT={context:"$",value:"."};var zo=class{constructor(e,r={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===CT.context,this.isValue=this.key[0]===CT.value,this.isSibling=!this.isContext&&!this.isValue;let n=this.isContext?CT.context:this.isValue?CT.value:"";this.path=this.key.slice(n.length),this.getter=this.path&&(0,Bi.getter)(this.path,!0),this.map=r.map}getValue(e,r,n){let i=this.isContext?n:this.isValue?e:r;return this.getter&&(i=this.getter(i||{})),this.map&&(i=this.map(i)),i}cast(e,r){return this.getValue(e,r?.parent,r?.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}};zo.prototype.__isYupRef=!0;var bs=t=>t==null;function pf(t){function e({value:r,path:n="",options:i,originalValue:s,schema:o},a,c){let{name:l,test:d,params:f,message:p,skipAbsent:h}=t,{parent:m,context:_,abortEarly:E=o.spec.abortEarly,disableStackTrace:S=o.spec.disableStackTrace}=i,x={value:r,parent:m,context:_};function D(H={}){let te=Tre(Object.assign({value:r,originalValue:s,label:o.spec.label,path:H.path||n,spec:o.spec,disableStackTrace:H.disableStackTrace||S},f,H.params),x),oe=new On(On.formatError(H.message||p,te),r,te.path,H.type||l,te.disableStackTrace);return oe.params=te,oe}let A=E?a:c,P={path:n,parent:m,type:l,from:i.from,createError:D,resolve(H){return yre(H,x)},options:i,originalValue:s,schema:o},W=H=>{On.isError(H)?A(H):H?c(null):A(D())},B=H=>{On.isError(H)?A(H):a(H)};if(h&&bs(r))return W(!0);let O;try{var v;if(O=d.call(P,r,P),typeof((v=O)==null?void 0:v.then)=="function"){if(i.sync)throw new Error(`Validation test of type: "${P.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);return Promise.resolve(O).then(W,B)}}catch(H){B(H);return}W(O)}return e.OPTIONS=t,e}function Tre(t,e){if(!t)return t;for(let r of Object.keys(t))t[r]=yre(t[r],e);return t}function yre(t,e){return zo.isRef(t)?t.getValue(e.value,e.parent,e.context):t}function E4e(t,e,r,n=r){let i,s,o;return e?((0,Bi.forEach)(e,(a,c,l)=>{let d=c?a.slice(1,a.length-1):a;t=t.resolve({context:n,parent:i,value:r});let f=t.type==="tuple",p=l?parseInt(d,10):0;if(t.innerType||f){if(f&&!l)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${o}" must contain an index to the tuple element, e.g. "${o}[0]"`);if(r&&p>=r.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${e}. because there is no value at that index. `);i=r,r=r&&r[p],t=f?t.spec.types[p]:t.innerType}if(!l){if(!t.fields||!t.fields[d])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${o} which is a type: "${t.type}")`);i=r,r=r&&r[d],t=t.fields[d]}s=d,o=c?"["+a+"]":"."+a}),{schema:t,parent:i,parentPath:s}):{parent:i,parentPath:e,schema:t}}var vT=class t extends Set{describe(){let e=[];for(let r of this.values())e.push(zo.isRef(r)?r.describe():r);return e}resolveAll(e){let r=[];for(let n of this.values())r.push(e(n));return r}clone(){return new t(this.values())}merge(e,r){let n=this.clone();return e.forEach(i=>n.add(i)),r.forEach(i=>n.delete(i)),n}};function hf(t,e=new Map){if(BT(t)||!t||typeof t!="object")return t;if(e.has(t))return e.get(t);let r;if(t instanceof Date)r=new Date(t.getTime()),e.set(t,r);else if(t instanceof RegExp)r=new RegExp(t),e.set(t,r);else if(Array.isArray(t)){r=new Array(t.length),e.set(t,r);for(let n=0;n<t.length;n++)r[n]=hf(t[n],e)}else if(t instanceof Map){r=new Map,e.set(t,r);for(let[n,i]of t.entries())r.set(n,hf(i,e))}else if(t instanceof Set){r=new Set,e.set(t,r);for(let n of t)r.add(hf(n,e))}else if(t instanceof Object){r={},e.set(t,r);for(let[n,i]of Object.entries(t))r[n]=hf(i,e)}else throw Error(`Unable to clone ${t}`);return r}function S4e(t){if(!(t!=null&&t.length))return;let e=[],r="",n=!1,i=!1;for(let s=0;s<t.length;s++){let o=t[s];if(o==="["&&!i){r&&(e.push(...r.split(".").filter(Boolean)),r=""),n=!0;continue}if(o==="]"&&!i){r&&(/^\d+$/.test(r)?e.push(r):e.push(r.replace(/^"|"$/g,"")),r=""),n=!1;continue}if(o==='"'){i=!i;continue}if(o==="."&&!n&&!i){r&&(e.push(r),r="");continue}r+=o}return r&&e.push(...r.split(".").filter(Boolean)),e}function b4e(t,e){let r=e?`${e}.${t.path}`:t.path;return t.errors.map(n=>({message:n,path:S4e(r)}))}function xre(t,e){var r;if(!((r=t.inner)!=null&&r.length)&&t.errors.length)return b4e(t,e);let n=e?`${e}.${t.path}`:t.path;return t.inner.flatMap(i=>xre(i,n))}var Zr=class{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new vT,this._blacklist=new vT,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError(js.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,disableStackTrace:!1,nullable:!1,optional:!0,coerce:!0},e?.spec),this.withMutation(r=>{r.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;let r=Object.create(Object.getPrototypeOf(this));return r.type=this.type,r._typeCheck=this._typeCheck,r._whitelist=this._whitelist.clone(),r._blacklist=this._blacklist.clone(),r.internalTests=Object.assign({},this.internalTests),r.exclusiveTests=Object.assign({},this.exclusiveTests),r.deps=[...this.deps],r.conditions=[...this.conditions],r.tests=[...this.tests],r.transforms=[...this.transforms],r.spec=hf(Object.assign({},this.spec,e)),r}label(e){let r=this.clone();return r.spec.label=e,r}meta(...e){if(e.length===0)return this.spec.meta;let r=this.clone();return r.spec.meta=Object.assign(r.spec.meta||{},e[0]),r}withMutation(e){let r=this._mutate;this._mutate=!0;let n=e(this);return this._mutate=r,n}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let r=this,n=e.clone(),i=Object.assign({},r.spec,n.spec);return n.spec=i,n.internalTests=Object.assign({},r.internalTests,n.internalTests),n._whitelist=r._whitelist.merge(e._whitelist,e._blacklist),n._blacklist=r._blacklist.merge(e._blacklist,e._whitelist),n.tests=r.tests,n.exclusiveTests=r.exclusiveTests,n.withMutation(s=>{e.tests.forEach(o=>{s.test(o.OPTIONS)})}),n.transforms=[...r.transforms,...n.transforms],n}isType(e){return e==null?!!(this.spec.nullable&&e===null||this.spec.optional&&e===void 0):this._typeCheck(e)}resolve(e){let r=this;if(r.conditions.length){let n=r.conditions;r=r.clone(),r.conditions=[],r=n.reduce((i,s)=>s.resolve(i,e),r),r=r.resolve(e)}return r}resolveOptions(e){var r,n,i,s;return Object.assign({},e,{from:e.from||[],strict:(r=e.strict)!=null?r:this.spec.strict,abortEarly:(n=e.abortEarly)!=null?n:this.spec.abortEarly,recursive:(i=e.recursive)!=null?i:this.spec.recursive,disableStackTrace:(s=e.disableStackTrace)!=null?s:this.spec.disableStackTrace})}cast(e,r={}){let n=this.resolve(Object.assign({},r,{value:e})),i=r.assert==="ignore-optionality",s=n._cast(e,r);if(r.assert!==!1&&!n.isType(s)){if(i&&bs(s))return s;let o=Wo(e),a=Wo(s);throw new TypeError(`The value of ${r.path||"field"} could not be cast to a value that satisfies the schema type: "${n.type}".
250
250
 
251
251
  attempted value: ${o}
252
252
  `+(a!==o?`result of cast: ${a}`:""))}return s}_cast(e,r){let n=e===void 0?e:this.transforms.reduce((i,s)=>s.call(this,i,e,this,r),e);return n===void 0&&(n=this.getDefault(r)),n}_validate(e,r={},n,i){let{path:s,originalValue:o=e,strict:a=this.spec.strict}=r,c=e;a||(c=this._cast(c,Object.assign({assert:!1},r)));let l=[];for(let d of Object.values(this.internalTests))d&&l.push(d);this.runTests({path:s,value:c,originalValue:o,options:r,tests:l},n,d=>{if(d.length)return i(d,c);this.runTests({path:s,value:c,originalValue:o,options:r,tests:this.tests},n,i)})}runTests(e,r,n){let i=!1,{tests:s,value:o,originalValue:a,path:c,options:l}=e,d=_=>{i||(i=!0,r(_,o))},f=_=>{i||(i=!0,n(_,o))},p=s.length,h=[];if(!p)return f([]);let m={value:o,originalValue:a,path:c,options:l,schema:this};for(let _=0;_<s.length;_++){let E=s[_];E(m,d,function(x){x&&(Array.isArray(x)?h.push(...x):h.push(x)),--p<=0&&f(h)})}}asNestedTest({key:e,index:r,parent:n,parentPath:i,originalParent:s,options:o}){let a=e??r;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");let c=typeof a=="number",l=n[a],d=Object.assign({},o,{strict:!0,parent:n,value:l,originalValue:s[a],key:void 0,[c?"index":"key"]:a,path:c||a.includes(".")?`${i||""}[${c?a:`"${a}"`}]`:(i?`${i}.`:"")+e});return(f,p,h)=>this.resolve(d)._validate(l,d,p,h)}validate(e,r){var n;let i=this.resolve(Object.assign({},r,{value:e})),s=(n=r?.disableStackTrace)!=null?n:i.spec.disableStackTrace;return new Promise((o,a)=>i._validate(e,r,(c,l)=>{On.isError(c)&&(c.value=l),a(c)},(c,l)=>{c.length?a(new On(c,l,void 0,void 0,s)):o(l)}))}validateSync(e,r){var n;let i=this.resolve(Object.assign({},r,{value:e})),s,o=(n=r?.disableStackTrace)!=null?n:i.spec.disableStackTrace;return i._validate(e,Object.assign({},r,{sync:!0}),(a,c)=>{throw On.isError(a)&&(a.value=c),a},(a,c)=>{if(a.length)throw new On(a,e,void 0,void 0,o);s=c}),s}isValid(e,r){return this.validate(e,r).then(()=>!0,n=>{if(On.isError(n))return!1;throw n})}isValidSync(e,r){try{return this.validateSync(e,r),!0}catch(n){if(On.isError(n))return!1;throw n}}_getDefault(e){let r=this.spec.default;return r==null?r:typeof r=="function"?r.call(this,e):hf(r)}getDefault(e){return this.resolve(e||{})._getDefault(e)}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,r){let n=this.clone({nullable:e});return n.internalTests.nullable=pf({message:r,name:"nullable",test(i){return i===null?this.schema.spec.nullable:!0}}),n}optionality(e,r){let n=this.clone({optional:e});return n.internalTests.optionality=pf({message:r,name:"optionality",test(i){return i===void 0?this.schema.spec.optional:!0}}),n}optional(){return this.optionality(!0)}defined(e=js.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=js.notNull){return this.nullability(!1,e)}required(e=js.required){return this.clone().withMutation(r=>r.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let r=this.clone();return r.transforms.push(e),r}test(...e){let r;if(e.length===1?typeof e[0]=="function"?r={test:e[0]}:r=e[0]:e.length===2?r={name:e[0],test:e[1]}:r={name:e[0],message:e[1],test:e[2]},r.message===void 0&&(r.message=js.default),typeof r.test!="function")throw new TypeError("`test` is a required parameters");let n=this.clone(),i=pf(r),s=r.exclusive||r.name&&n.exclusiveTests[r.name]===!0;if(r.exclusive&&!r.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return r.name&&(n.exclusiveTests[r.name]=!!r.exclusive),n.tests=n.tests.filter(o=>!(o.OPTIONS.name===r.name&&(s||o.OPTIONS.test===i.OPTIONS.test))),n.tests.push(i),n}when(e,r){!Array.isArray(e)&&typeof e!="string"&&(r=e,e=".");let n=this.clone(),i=_re(e).map(s=>new zo(s));return i.forEach(s=>{s.isSibling&&n.deps.push(s.key)}),n.conditions.push(typeof r=="function"?new NT(i,r):NT.fromOptions(i,r)),n}typeError(e){let r=this.clone();return r.internalTests.typeError=pf({message:e,name:"typeError",skipAbsent:!0,test(n){return this.schema._typeCheck(n)?!0:this.createError({params:{type:this.schema.type}})}}),r}oneOf(e,r=js.oneOf){let n=this.clone();return e.forEach(i=>{n._whitelist.add(i),n._blacklist.delete(i)}),n.internalTests.whiteList=pf({message:r,name:"oneOf",skipAbsent:!0,test(i){let s=this.schema._whitelist,o=s.resolveAll(this.resolve);return o.includes(i)?!0:this.createError({params:{values:Array.from(s).join(", "),resolved:o}})}}),n}notOneOf(e,r=js.notOneOf){let n=this.clone();return e.forEach(i=>{n._blacklist.add(i),n._whitelist.delete(i)}),n.internalTests.blacklist=pf({message:r,name:"notOneOf",test(i){let s=this.schema._blacklist,o=s.resolveAll(this.resolve);return o.includes(i)?this.createError({params:{values:Array.from(s).join(", "),resolved:o}}):!0}}),n}strip(e=!0){let r=this.clone();return r.spec.strip=e,r}describe(e){let r=(e?this.resolve(e):this).clone(),{label:n,meta:i,optional:s,nullable:o}=r.spec;return{meta:i,label:n,optional:s,nullable:o,default:r.getDefault(e),type:r.type,oneOf:r._whitelist.describe(),notOneOf:r._blacklist.describe(),tests:r.tests.filter((c,l,d)=>d.findIndex(f=>f.OPTIONS.name===c.OPTIONS.name)===l).map(c=>{let l=c.OPTIONS.params&&e?Tre(Object.assign({},c.OPTIONS.params),e):c.OPTIONS.params;return{name:c.OPTIONS.name,params:l}})}}get"~standard"(){let e=this;return{version:1,vendor:"yup",async validate(n){try{return{value:await e.validate(n,{abortEarly:!1})}}catch(i){if(i instanceof On)return{issues:xre(i)};throw i}}}}};Zr.prototype.__isYupSchema__=!0;for(let t of["validate","validateSync"])Zr.prototype[`${t}At`]=function(e,r,n={}){let{parent:i,parentPath:s,schema:o}=E4e(this,e,r,n.context);return o[t](i&&i[s],Object.assign({},n,{parent:i,path:e}))};for(let t of["equals","is"])Zr.prototype[t]=Zr.prototype.oneOf;for(let t of["not","nope"])Zr.prototype[t]=Zr.prototype.notOneOf;var T4e=()=>!0;function y4e(t){return new IT(t)}var IT=class extends Zr{constructor(e){super(typeof e=="function"?{type:"mixed",check:e}:Object.assign({type:"mixed",check:T4e},e))}};y4e.prototype=IT.prototype;function x4e(){return new wT}var wT=class extends Zr{constructor(){super({type:"boolean",check(e){return e instanceof Boolean&&(e=e.valueOf()),typeof e=="boolean"}}),this.withMutation(()=>{this.transform((e,r)=>{if(this.spec.coerce&&!this.isType(e)){if(/^(true|1)$/i.test(String(e)))return!0;if(/^(false|0)$/i.test(String(e)))return!1}return e})})}isTrue(e=xw.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"true"},test(r){return bs(r)||r===!0}})}isFalse(e=xw.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"false"},test(r){return bs(r)||r===!1}})}default(e){return super.default(e)}defined(e){return super.defined(e)}optional(){return super.optional()}required(e){return super.required(e)}notRequired(){return super.notRequired()}nullable(){return super.nullable()}nonNullable(e){return super.nonNullable(e)}strip(e){return super.strip(e)}};x4e.prototype=wT.prototype;var C4e=/^(\d{4}|[+-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,.](\d{1,}))?)?(?:(Z)|([+-])(\d{2})(?::?(\d{2}))?)?)?$/;function D4e(t){let e=Cw(t);if(!e)return Date.parse?Date.parse(t):Number.NaN;if(e.z===void 0&&e.plusMinus===void 0)return new Date(e.year,e.month,e.day,e.hour,e.minute,e.second,e.millisecond).valueOf();let r=0;return e.z!=="Z"&&e.plusMinus!==void 0&&(r=e.hourOffset*60+e.minuteOffset,e.plusMinus==="+"&&(r=0-r)),Date.UTC(e.year,e.month,e.day,e.hour,e.minute+r,e.second,e.millisecond)}function Cw(t){var e,r;let n=C4e.exec(t);return n?{year:Vo(n[1]),month:Vo(n[2],1)-1,day:Vo(n[3],1),hour:Vo(n[4]),minute:Vo(n[5]),second:Vo(n[6]),millisecond:n[7]?Vo(n[7].substring(0,3)):0,precision:(e=(r=n[7])==null?void 0:r.length)!=null?e:void 0,z:n[8]||void 0,plusMinus:n[9]||void 0,hourOffset:Vo(n[10]),minuteOffset:Vo(n[11])}:null}function Vo(t,e=0){return Number(t)||e}var R4e=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,A4e=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,O4e=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,N4e="^\\d{4}-\\d{2}-\\d{2}",v4e="\\d{2}:\\d{2}:\\d{2}",I4e="(([+-]\\d{2}(:?\\d{2})?)|Z)",w4e=new RegExp(`${N4e}T${v4e}(\\.\\d+)?${I4e}$`),L4e=t=>bs(t)||t===t.trim(),M4e={}.toString();function sc(){return new LT}var LT=class extends Zr{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,r)=>{if(!this.spec.coerce||this.isType(e)||Array.isArray(e))return e;let n=e!=null&&e.toString?e.toString():e;return n===M4e?e:n})})}required(e){return super.required(e).withMutation(r=>r.test({message:e||js.required,name:"required",skipAbsent:!0,test:n=>!!n.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(r=>r.OPTIONS.name!=="required"),e))}length(e,r=$n.length){return this.test({message:r,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(n){return n.length===this.resolve(e)}})}min(e,r=$n.min){return this.test({message:r,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(n){return n.length>=this.resolve(e)}})}max(e,r=$n.max){return this.test({name:"max",exclusive:!0,message:r,params:{max:e},skipAbsent:!0,test(n){return n.length<=this.resolve(e)}})}matches(e,r){let n=!1,i,s;return r&&(typeof r=="object"?{excludeEmptyString:n=!1,message:i,name:s}=r:i=r),this.test({name:s||"matches",message:i||$n.matches,params:{regex:e},skipAbsent:!0,test:o=>o===""&&n||o.search(e)!==-1})}email(e=$n.email){return this.matches(R4e,{name:"email",message:e,excludeEmptyString:!0})}url(e=$n.url){return this.matches(A4e,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=$n.uuid){return this.matches(O4e,{name:"uuid",message:e,excludeEmptyString:!1})}datetime(e){let r="",n,i;return e&&(typeof e=="object"?{message:r="",allowOffset:n=!1,precision:i=void 0}=e:r=e),this.matches(w4e,{name:"datetime",message:r||$n.datetime,excludeEmptyString:!0}).test({name:"datetime_offset",message:r||$n.datetime_offset,params:{allowOffset:n},skipAbsent:!0,test:s=>{if(!s||n)return!0;let o=Cw(s);return o?!!o.z:!1}}).test({name:"datetime_precision",message:r||$n.datetime_precision,params:{precision:i},skipAbsent:!0,test:s=>{if(!s||i==null)return!0;let o=Cw(s);return o?o.precision===i:!1}})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=$n.trim){return this.transform(r=>r!=null?r.trim():r).test({message:e,name:"trim",test:L4e})}lowercase(e=$n.lowercase){return this.transform(r=>bs(r)?r:r.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>bs(r)||r===r.toLowerCase()})}uppercase(e=$n.uppercase){return this.transform(r=>bs(r)?r:r.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:r=>bs(r)||r===r.toUpperCase()})}};sc.prototype=LT.prototype;var P4e=t=>t!=+t;function UT(){return new MT}var MT=class extends Zr{constructor(){super({type:"number",check(e){return e instanceof Number&&(e=e.valueOf()),typeof e=="number"&&!P4e(e)}}),this.withMutation(()=>{this.transform((e,r)=>{if(!this.spec.coerce)return e;let n=e;if(typeof n=="string"){if(n=n.replace(/\s/g,""),n==="")return NaN;n=+n}return this.isType(n)||n===null?n:parseFloat(n)})})}min(e,r=ic.min){return this.test({message:r,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(n){return n>=this.resolve(e)}})}max(e,r=ic.max){return this.test({message:r,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(n){return n<=this.resolve(e)}})}lessThan(e,r=ic.lessThan){return this.test({message:r,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(n){return n<this.resolve(e)}})}moreThan(e,r=ic.moreThan){return this.test({message:r,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(n){return n>this.resolve(e)}})}positive(e=ic.positive){return this.moreThan(0,e)}negative(e=ic.negative){return this.lessThan(0,e)}integer(e=ic.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:r=>Number.isInteger(r)})}truncate(){return this.transform(e=>bs(e)?e:e|0)}round(e){var r;let n=["ceil","floor","round","trunc"];if(e=((r=e)==null?void 0:r.toLowerCase())||"round",e==="trunc")return this.truncate();if(n.indexOf(e.toLowerCase())===-1)throw new TypeError("Only valid options for round() are: "+n.join(", "));return this.transform(i=>bs(i)?i:Math[e](i))}};UT.prototype=MT.prototype;var Cre=new Date(""),F4e=t=>Object.prototype.toString.call(t)==="[object Date]";function Dre(){return new e_}var e_=class t extends Zr{constructor(){super({type:"date",check(e){return F4e(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,r)=>!this.spec.coerce||this.isType(e)||e===null?e:(e=D4e(e),isNaN(e)?t.INVALID_DATE:new Date(e)))})}prepareParam(e,r){let n;if(zo.isRef(e))n=e;else{let i=this.cast(e);if(!this._typeCheck(i))throw new TypeError(`\`${r}\` must be a Date or a value that can be \`cast()\` to a Date`);n=i}return n}min(e,r=yw.min){let n=this.prepareParam(e,"min");return this.test({message:r,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(i){return i>=this.resolve(n)}})}max(e,r=yw.max){let n=this.prepareParam(e,"max");return this.test({message:r,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(i){return i<=this.resolve(n)}})}};e_.INVALID_DATE=Cre;Dre.prototype=e_.prototype;Dre.INVALID_DATE=Cre;function k4e(t,e=[]){let r=[],n=new Set,i=new Set(e.map(([o,a])=>`${o}-${a}`));function s(o,a){let c=(0,Bi.split)(o)[0];n.add(c),i.has(`${a}-${c}`)||r.push([a,c])}for(let o of Object.keys(t)){let a=t[o];n.add(o),zo.isRef(a)&&a.isSibling?s(a.path,o):BT(a)&&"deps"in a&&a.deps.forEach(c=>s(c,o))}return mre.default.array(Array.from(n),r).reverse()}function fre(t,e){let r=1/0;return t.some((n,i)=>{var s;if((s=e.path)!=null&&s.includes(n))return r=i,!0}),r}function Rre(t){return(e,r)=>fre(t,e)-fre(t,r)}var Are=(t,e,r)=>{if(typeof t!="string")return t;let n=t;try{n=JSON.parse(t)}catch{}return r.isType(n)?n:t};function AT(t){if("fields"in t){let e={};for(let[r,n]of Object.entries(t.fields))e[r]=AT(n);return t.setFields(e)}if(t.type==="array"){let e=t.optional();return e.innerType&&(e.innerType=AT(e.innerType)),e}return t.type==="tuple"?t.optional().clone({types:t.spec.types.map(AT)}):"optional"in t?t.optional():t}var B4e=(t,e)=>{let r=[...(0,Bi.normalizePath)(e)];if(r.length===1)return r[0]in t;let n=r.pop(),i=(0,Bi.getter)((0,Bi.join)(r),!0)(t);return!!(i&&n in i)},pre=t=>Object.prototype.toString.call(t)==="[object Object]";function hre(t,e){let r=Object.keys(t.fields);return Object.keys(e).filter(n=>r.indexOf(n)===-1)}var U4e=Rre([]);function Dw(t){return new PT(t)}var PT=class extends Zr{constructor(e){super({type:"object",check(r){return pre(r)||typeof r=="function"}}),this.fields=Object.create(null),this._sortErrors=U4e,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,r={}){var n;let i=super._cast(e,r);if(i===void 0)return this.getDefault(r);if(!this._typeCheck(i))return i;let s=this.fields,o=(n=r.stripUnknown)!=null?n:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(i).filter(f=>!this._nodes.includes(f))),c={},l=Object.assign({},r,{parent:c,__validating:r.__validating||!1}),d=!1;for(let f of a){let p=s[f],h=f in i,m=i[f];if(p){let _;l.path=(r.path?`${r.path}.`:"")+f,p=p.resolve({value:m,context:r.context,parent:c});let E=p instanceof Zr?p.spec:void 0,S=E?.strict;if(E!=null&&E.strip){d=d||f in i;continue}_=!r.__validating||!S?p.cast(m,l):m,_!==void 0&&(c[f]=_)}else h&&!o&&(c[f]=m);(h!==f in c||c[f]!==m)&&(d=!0)}return d?c:i}_validate(e,r={},n,i){let{from:s=[],originalValue:o=e,recursive:a=this.spec.recursive}=r;r.from=[{schema:this,value:o},...s],r.__validating=!0,r.originalValue=o,super._validate(e,r,n,(c,l)=>{if(!a||!pre(l)){i(c,l);return}o=o||l;let d=[];for(let f of this._nodes){let p=this.fields[f];!p||zo.isRef(p)||d.push(p.asNestedTest({options:r,key:f,parent:l,parentPath:r.path,originalParent:o}))}this.runTests({tests:d,value:l,originalValue:o,options:r},n,f=>{i(f.sort(this._sortErrors).concat(c),l)})})}clone(e){let r=super.clone(e);return r.fields=Object.assign({},this.fields),r._nodes=this._nodes,r._excludedEdges=this._excludedEdges,r._sortErrors=this._sortErrors,r}concat(e){let r=super.concat(e),n=r.fields;for(let[i,s]of Object.entries(this.fields)){let o=n[i];n[i]=o===void 0?s:o}return r.withMutation(i=>i.setFields(n,[...this._excludedEdges,...e._excludedEdges]))}_getDefault(e){if("default"in this.spec)return super._getDefault(e);if(!this._nodes.length)return;let r={};return this._nodes.forEach(n=>{var i;let s=this.fields[n],o=e;(i=o)!=null&&i.value&&(o=Object.assign({},o,{parent:o.value,value:o.value[n]})),r[n]=s&&"getDefault"in s?s.getDefault(o):void 0}),r}setFields(e,r){let n=this.clone();return n.fields=e,n._nodes=k4e(e,r),n._sortErrors=Rre(Object.keys(e)),r&&(n._excludedEdges=r),n}shape(e,r=[]){return this.clone().withMutation(n=>{let i=n._excludedEdges;return r.length&&(Array.isArray(r[0])||(r=[r]),i=[...n._excludedEdges,...r]),n.setFields(Object.assign(n.fields,e),i)})}partial(){let e={};for(let[r,n]of Object.entries(this.fields))e[r]="optional"in n&&n.optional instanceof Function?n.optional():n;return this.setFields(e)}deepPartial(){return AT(this)}pick(e){let r={};for(let n of e)this.fields[n]&&(r[n]=this.fields[n]);return this.setFields(r,this._excludedEdges.filter(([n,i])=>e.includes(n)&&e.includes(i)))}omit(e){let r=[];for(let n of Object.keys(this.fields))e.includes(n)||r.push(n);return this.pick(r)}from(e,r,n){let i=(0,Bi.getter)(e,!0);return this.transform(s=>{if(!s)return s;let o=s;return B4e(s,e)&&(o=Object.assign({},s),n||delete o[e],o[r]=i(s)),o})}json(){return this.transform(Are)}exact(e){return this.test({name:"exact",exclusive:!0,message:e||DT.exact,test(r){if(r==null)return!0;let n=hre(this.schema,r);return n.length===0||this.createError({params:{properties:n.join(", ")}})}})}stripUnknown(){return this.clone({noUnknown:!0})}noUnknown(e=!0,r=DT.noUnknown){typeof e!="boolean"&&(r=e,e=!0);let n=this.test({name:"noUnknown",exclusive:!0,message:r,test(i){if(i==null)return!0;let s=hre(this.schema,i);return!e||s.length===0||this.createError({params:{unknown:s.join(", ")}})}});return n.spec.noUnknown=e,n}unknown(e=!0,r=DT.noUnknown){return this.noUnknown(!e,r)}transformKeys(e){return this.transform(r=>{if(!r)return r;let n={};for(let i of Object.keys(r))n[e(i)]=r[i];return n})}camelCase(){return this.transformKeys(Jm.camelCase)}snakeCase(){return this.transformKeys(Jm.snakeCase)}constantCase(){return this.transformKeys(e=>(0,Jm.snakeCase)(e).toUpperCase())}describe(e){let r=(e?this.resolve(e):this).clone(),n=super.describe(e);n.fields={};for(let[s,o]of Object.entries(r.fields)){var i;let a=e;(i=a)!=null&&i.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[s]})),n.fields[s]=o.describe(a)}return n}};Dw.prototype=PT.prototype;function G4e(t){return new FT(t)}var FT=class extends Zr{constructor(e){super({type:"array",spec:{types:e},check(r){return Array.isArray(r)}}),this.innerType=void 0,this.innerType=e}_cast(e,r){let n=super._cast(e,r);if(!this._typeCheck(n)||!this.innerType)return n;let i=!1,s=n.map((o,a)=>{let c=this.innerType.cast(o,Object.assign({},r,{path:`${r.path||""}[${a}]`,parent:n,originalValue:o,value:o,index:a}));return c!==o&&(i=!0),c});return i?s:n}_validate(e,r={},n,i){var s;let o=this.innerType,a=(s=r.recursive)!=null?s:this.spec.recursive;r.originalValue!=null&&r.originalValue,super._validate(e,r,n,(c,l)=>{var d;if(!a||!o||!this._typeCheck(l)){i(c,l);return}let f=new Array(l.length);for(let h=0;h<l.length;h++){var p;f[h]=o.asNestedTest({options:r,index:h,parent:l,parentPath:r.path,originalParent:(p=r.originalValue)!=null?p:e})}this.runTests({value:l,tests:f,originalValue:(d=r.originalValue)!=null?d:e,options:r},n,h=>i(h.concat(c),l))})}clone(e){let r=super.clone(e);return r.innerType=this.innerType,r}json(){return this.transform(Are)}concat(e){let r=super.concat(e);return r.innerType=this.innerType,e.innerType&&(r.innerType=r.innerType?r.innerType.concat(e.innerType):e.innerType),r}of(e){let r=this.clone();if(!BT(e))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+Wo(e));return r.innerType=e,r.spec=Object.assign({},r.spec,{types:e}),r}length(e,r=RT.length){return this.test({message:r,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(n){return n.length===this.resolve(e)}})}min(e,r){return r=r||RT.min,this.test({message:r,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(n){return n.length>=this.resolve(e)}})}max(e,r){return r=r||RT.max,this.test({message:r,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(n){return n.length<=this.resolve(e)}})}ensure(){return this.default(()=>[]).transform((e,r)=>this._typeCheck(e)?e:r==null?[]:[].concat(r))}compact(e){let r=e?(n,i,s)=>!e(n,i,s):n=>!!n;return this.transform(n=>n!=null?n.filter(r):n)}describe(e){let r=(e?this.resolve(e):this).clone(),n=super.describe(e);if(r.innerType){var i;let s=e;(i=s)!=null&&i.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[0]})),n.innerType=r.innerType.describe(s)}return n}};G4e.prototype=FT.prototype;function H4e(t){return new kT(t)}var kT=class extends Zr{constructor(e){super({type:"tuple",spec:{types:e},check(r){let n=this.spec.types;return Array.isArray(r)&&r.length===n.length}}),this.withMutation(()=>{this.typeError(bre.notType)})}_cast(e,r){let{types:n}=this.spec,i=super._cast(e,r);if(!this._typeCheck(i))return i;let s=!1,o=n.map((a,c)=>{let l=a.cast(i[c],Object.assign({},r,{path:`${r.path||""}[${c}]`,parent:i,originalValue:i[c],value:i[c],index:c}));return l!==i[c]&&(s=!0),l});return s?o:i}_validate(e,r={},n,i){let s=this.spec.types;super._validate(e,r,n,(o,a)=>{var c;if(!this._typeCheck(a)){i(o,a);return}let l=[];for(let[f,p]of s.entries()){var d;l[f]=p.asNestedTest({options:r,index:f,parent:a,parentPath:r.path,originalParent:(d=r.originalValue)!=null?d:e})}this.runTests({value:a,tests:l,originalValue:(c=r.originalValue)!=null?c:e,options:r},n,f=>i(f.concat(o),a))})}describe(e){let r=(e?this.resolve(e):this).clone(),n=super.describe(e);return n.innerType=r.spec.types.map((i,s)=>{var o;let a=e;return(o=a)!=null&&o.value&&(a=Object.assign({},a,{parent:a.value,value:a.value[s]})),i.describe(a)}),n}};H4e.prototype=kT.prototype;var zT=K(ine()),_f=K(require("fs/promises")),sne=K(require("fs")),KT=K(require("path"));var Wn="sandbox.toml";function _8e(t){return`# This is a config for UCloud Sandbox template.
@@ -338,16 +338,16 @@ Sandbox templates to delete`))),i.forEach(s=>console.log(rr({...s,templateID:s.t
338
338
  `).trimEnd()}${yf}`});var KM=K(Nle());var yc=K(require("fs")),pu=K(require("path"));u();var ao=(n=>(n.TypeScript="typescript",n.PythonSync="python-sync",n.PythonAsync="python-async",n))(ao||{}),li={typescript:"TypeScript","python-sync":"Python (sync)","python-async":"Python (async)"};u();var fu=K(require("path"));u();var Wf=K(require("fs")),Tde=K(bde()),aa=K(require("path"));var hg=class{handlebars;constructor(){let e=Tde.default.create();e.registerHelper("eq",function(r,n,i){return r===n?i.fn(this):""}),e.registerHelper("escapeQuotes",function(r){return r&&r.replace(/'/g,"\\'")}),e.registerHelper("escapeDoubleQuotes",function(r){return r&&r.replace(/"/g,'\\"')}),this.handlebars=e}compile(e){return this.handlebars.compile(e)}};async function yde(t){let e=await Hn.toJSON(t,!1),r=JSON.parse(e),n=[];for(let i of r.steps)switch(i.type){case"ENV":{let s={};for(let o=0;o<i.args.length;o+=2)o+1<i.args.length&&(s[i.args[o]]=i.args[o+1]);n.push({type:"ENV",envVars:s});break}case"COPY":{if(i.args.length>=2){let s=i.args[0],o=i.args[1];(!o||o==="")&&(o="."),n.push({type:"COPY",src:s,dest:o})}break}default:n.push({type:i.type,args:i.args})}return{...r,steps:n}}async function WM(t,e,r,n){let i=new hg,s=await yde(t),o=aa.join(__dirname,"templates"),a=Wf.readFileSync(aa.join(o,"typescript-template.hbs"),"utf8"),c=Wf.readFileSync(aa.join(o,"typescript-build.hbs"),"utf8"),l=i.compile(a),d=i.compile(c),f={...s},p=l(f),h=d({alias:e,cpuCount:r,memoryMB:n});return{templateContent:p.trim(),buildContent:h.trim()}}async function zM(t,e,r,n,i=!1){let s=new hg,o=await yde(t),a=aa.join(__dirname,"templates"),c=Wf.readFileSync(aa.join(a,"python-template.hbs"),"utf8"),l=Wf.readFileSync(aa.join(a,`python-build-${i?"async":"sync"}.hbs`),"utf8"),d=s.compile(c),f=s.compile(l),p=d({...o,isAsync:i}),h=f({alias:e,cpuCount:r,memoryMB:n});return{templateContent:p.trim(),buildContent:h.trim()}}async function xde(t,e,r){let n=new hg,i=aa.join(__dirname,"templates"),s=Wf.readFileSync(aa.join(i,"readme.hbs"),"utf8"),o=n.compile(s),a={alias:t,templateDir:e,templateFile:r.templateFile,buildDevFile:r.buildDevFile,buildProdFile:r.buildProdFile,isTypeScript:r.language==="typescript",isPython:r.language==="python-sync"||r.language==="python-async",isPythonSync:r.language==="python-sync",isPythonAsync:r.language==="python-async"};return o(a).trim()}u();var zf=K(require("fs")),Cde=K(require("path"));async function du(t,e){if(zf.existsSync(t))throw new Error(`File ${t} already exists. Aborting to avoid overwrite.`);let r=Cde.dirname(t);zf.existsSync(r)||await zf.promises.mkdir(r,{recursive:!0}),await zf.promises.writeFile(t,e)}async function aC(t,e,r,n,i,s){switch(r){case"typescript":{let{templateContent:o,buildContent:a}=await WM(n,`${e}-dev`,i,s),{buildContent:c}=await WM(n,e,i,s),l="template.ts",d="build.dev.ts",f="build.prod.ts";return await du(fu.join(t,l),o),await du(fu.join(t,d),a),await du(fu.join(t,f),c),console.log(`
339
339
  \u2705 Generated ${ze(li.typescript)} template files:`),console.log(` ${Dt(l)}`),console.log(` ${Dt(d)}`),console.log(` ${Dt(f)}`),{templateFile:l,buildDevFile:d,buildProdFile:f,language:r}}case"python-sync":case"python-async":{let o=r==="python-async",{templateContent:a,buildContent:c}=await zM(n,`${e}-dev`,i,s,o),{buildContent:l}=await zM(n,e,i,s,o),d="template.py",f="build_dev.py",p="build_prod.py";return await du(fu.join(t,d),a),await du(fu.join(t,f),c),await du(fu.join(t,p),l),console.log(`
340
340
  \u2705 Generated ${ze(li[r])} template files:`),console.log(` ${Dt(d)}`),console.log(` ${Dt(f)}`),console.log(` ${Dt(p)}`),{templateFile:d,buildDevFile:f,buildProdFile:p,language:r}}default:throw new Error("Unsupported language")}}var Dde="my-template";async function _$e(t,e,r,n,i){let s=Hn().fromImage("sandbox/base").runCmd("echo Hello World Sandbox!");return aC(t,e,r,s,n,i)}async function g$e(t,e,r){try{let n="Makefile",i=yc.existsSync(pu.join(t,n)),s="";i&&(s=`cd ${r} && `);let o=`
341
- .PHONY: sandbox:build:dev
342
- sandbox:build:dev:
341
+ .PHONY: sandbox-build-dev
342
+ sandbox-build-dev:
343
343
  ${s}python ${e.buildDevFile}
344
344
 
345
- .PHONY: sandbox:build:prod
346
- sandbox:build:prod:
345
+ .PHONY: sandbox-build-prod
346
+ sandbox-build-prod:
347
347
  ${s}python ${e.buildProdFile}
348
348
  `;if(i){let a=pu.join(t,n);await yc.promises.appendFile(a,`
349
349
  `+o,"utf8")}else{let a=pu.join(t,r,n);await yc.promises.writeFile(a,o,"utf8")}console.log(`
350
- \u{1F4DD} Added build scripts to Makefile:`),console.log(` ${ze("make sandbox:build:dev")} - Build development template`),console.log(` ${ze("make sandbox:build:prod")} - Build production template`)}catch(n){console.warn(`
350
+ \u{1F4DD} Added build scripts to Makefile:`),console.log(` ${ze("make sandbox-build-dev")} - Build development template`),console.log(` ${ze("make sandbox-build-prod")} - Build production template`)}catch(n){console.warn(`
351
351
  \u26A0\uFE0F Could not add scripts to Makefile:`,n instanceof Error?n.message:n)}}async function E$e(t,e,r){try{let n="",i;try{i=await KM.default.load(t),n=`cd ${r} && `}catch{let o=pu.join(t,r);i=await KM.default.create(o)}i.update({scripts:{...i.content.scripts,"sandbox:build:dev":`${n}npx tsx ${e.buildDevFile}`,"sandbox:build:prod":`${n}npx tsx ${e.buildProdFile}`}}),await i.save(),console.log(`
352
352
  \u{1F4DD} Added build scripts to package.json:`),console.log(` ${ze("npm run sandbox:build:dev")} - Build development template`),console.log(` ${ze("npm run sandbox:build:prod")} - Build production template`)}catch(n){console.warn(`
353
353
  \u26A0\uFE0F Could not add scripts to package.json:`,n instanceof Error?n.message:n)}}function S$e(t){return/^[a-z0-9][a-z0-9_-]*[a-z0-9]$|^[a-z0-9]$/.test(t)}function Rde(t){if(!t||t.trim().length===0)throw new Error("Template name cannot be empty");if(!S$e(t.trim()))throw new Error("Template name must contain only lowercase letters, numbers, hyphens, and underscores, and cannot start or end with a hyphen or underscore")}var Ade=new We("init").description("initialize a new sandbox template using the SDK").addOption(An).option("-n, --name <name>","template name (alias)",t=>{try{Rde(t)}catch(e){throw new nh(e instanceof Error?e.message:String(e))}return t}).option("-l, --language <language>",`target language: ${Object.values(ao).join(", ")}`,t=>{if(!Object.values(ao).includes(t))throw new nh(`Invalid language. Must be one of: ${Object.values(ao).join(", ")}`);return t}).alias("it").action(async t=>{try{process.stdout.write(`
@@ -355,7 +355,7 @@ sandbox:build:prod:
355
355
  `);let r=t.name??Dde;t.name===void 0&&(r=await F9({message:"Enter template name (alias):",default:Dde,validate:l=>{try{Rde(l)}catch(d){return d instanceof Error?d.message:d}return!0}})),r=r.trim(),console.log(`Using template name: ${r}`);let n;t.language?(n=t.language,console.log(`Using language: ${li[n]}`)):n=await x_({message:"Select target language for template files:",choices:[{name:li.typescript,value:"typescript",description:"Generate .ts files for JavaScript/TypeScript projects"},{name:li["python-sync"],value:"python-sync",description:"Generate synchronous Python template files"},{name:li["python-async"],value:"python-async",description:"Generate asynchronous Python template files"}],default:"typescript"});let i=r,s=pu.join(e,i);if(yc.existsSync(s))throw new Error(`Directory '${i}' already exists. Please choose a different template name or remove the existing directory.`);await yc.promises.mkdir(s,{recursive:!0});let o=await _$e(s,r,n);switch(n){case"typescript":await E$e(e,o,i);break;case"python-async":case"python-sync":await g$e(e,o,i);break;default:throw new Error("Unsupported language for scripts")}let a=await xde(r,i,o),c=pu.join(s,"README.md");switch(await yc.promises.writeFile(c,a,"utf8"),console.log(`
356
356
  \u{1F389} Template initialized successfully!`),console.log(`
357
357
  Template created in: ${ze(`./${i}/`)}`),console.log(`
358
- \u{1F528} To get started with your template:`),n){case"typescript":console.log(` ${ze("npm install ucloud_sandbox")} (install SDK dependency)`),console.log(` ${ze("npm run sandbox:build:dev")} (for development)`),console.log(` ${ze("npm run sandbox:build:prod")} (for production)`);break;case"python-async":case"python-sync":console.log(` ${ze("pip install ucloud_sandbox")} (install SDK dependency)`),console.log(` ${ze("make sandbox:build:dev")} (for development)`),console.log(` ${ze("make sandbox:build:prod")} (for production)`);break;default:throw new Error("Unsupported language for instructions")}console.log(`
358
+ \u{1F528} To get started with your template:`),n){case"typescript":console.log(` ${ze("npm install ucloud_sandbox")} (install SDK dependency)`),console.log(` ${ze("npm run sandbox:build:dev")} (for development)`),console.log(` ${ze("npm run sandbox:build:prod")} (for production)`);break;case"python-async":case"python-sync":console.log(` ${ze("pip install ucloud_sandbox")} (install SDK dependency)`),console.log(` ${ze("make sandbox-build-dev")} (for development)`),console.log(` ${ze("make sandbox-build-prod")} (for production)`);break;default:throw new Error("Unsupported language for instructions")}console.log(`
359
359
  Learn more about Sandbox Templates: ${ze("https://sandbox.ucloudai.com/docs")}
360
360
  `)}catch(e){console.error(e),process.exit(1)}});u();var hu=K(require("fs")),mg=K(require("path"));async function b$e(t,e,r,n){let i=Hn({fileContextPath:t}),s;try{s=i.fromDockerfile(r)}catch(c){console.warn(`
361
361
  \u26A0\uFE0F Unfortunately, we weren't able to fully convert the template to the new SDK format.`),console.warn(`