@ucloud-sdks/ucloud-sandbox-cli 0.1.0-beta.8 → 0.1.0-beta.9
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 +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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,J1.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 rh(t);return e.check(),e}u();var $7=K(Y7(),1),{program:Int,createCommand:wnt,createArgument:Lnt,createOption:Mnt,CommanderError:Pnt,InvalidArgumentError:ih,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.
|
|
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 rh(t);return e.check(),e}u();var $7=K(Y7(),1),{program:Int,createCommand:wnt,createArgument:Lnt,createOption:Mnt,CommanderError:Pnt,InvalidArgumentError:ih,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.9",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 cE(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 lE(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 uE(t){return uN.default(t,{language:"typescript",ignoreIllegals:!0})}function dE(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 fE(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 pE(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(pE(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(pE(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(pE(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,`;${pE(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 mE="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 OS(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 NS(t){return t.replace(N9e(),"")}var IZ={browser:typeof window<"u"&&e2.default.name||"unknown",lang:"js",lang_version:AZ,package_version:mE,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 IS(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"}},vS=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"}},Sm=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 wS(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 Sm(`${i} - ${s}`):new Sm(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=fE({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(wS(e.logger))}};u();var v9e=6e4,LS=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/${mE}`,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 bm(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 PS(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 MS=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>=MS&&(i=i+(n/MS|0),n=n%MS)}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(MS*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 Tm(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 FS(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 kS(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 BS(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 ym(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 xm(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 Cm(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,US=2;function Kr(t,e){if(bm(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=FS(r,n);if(!o)continue;s=o,i=kS(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}BS(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(!bm(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!=US&&(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!=US)||(e[s.localName]=s2(s))}else{e={$typeName:t.typeName};for(let r of t.members)(r.kind=="oneof"||r.presence==US)&&(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!=US&&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 Dm(){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=Dm().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),Tm(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,Tm(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 PS(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 PS(i,s,this.buf),this}uint64(e){let r=mt.uEnc(e);return PS(r.lo,r.hi,this.buf),this}},Al=class{constructor(e,r=Dm().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"?ym(e,t):t.fieldKind=="map"?xm(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=GS(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}: ${GS(t,r,n)}`)}function ZZ(t,e,r){let n=JZ(e,t.mapKey);if(n!==!0)return new xr(t,`invalid map key: ${GS({scalar:t.mapKey},e,n)}`);let i=_2(t,r);if(i!==!0)return new xr(t,`map entry ${pr(e)}: ${GS(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):Cm(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:Dm().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 GS(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})`:ym(t)?tJ(t.field()):xm(t)?rJ(t.field()):Cm(t)?eJ(t.desc):bm(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 qS(t,e,r)}var nJ=new WeakMap,qS=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 Rm(this.message,e),FS(this.message,e)}isSet(e){return Rm(this.message,e),YZ(this.message,e)}clear(e){Rm(this.message,e),$Z(this.message,e)}get(e){Rm(this.message,e);let r=kS(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(Rm(this.message,e),this.check){let i=ko(e,r);if(i)throw i}let n;e.fieldKind=="message"?n=T2(e,r):xm(r)||ym(r)?n=r[ms]:n=C2(e,r),BS(this.message,e,n)}getUnknown(){return this.message.$unknown}setUnknown(e){this.message.$unknown=e}};function Rm(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[HS(e)]=$9e(this._field,r),this}delete(e){let r=HS(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[HS(e)];return r!==void 0&&(r=E2(this._field,r,this.check)),r}has(e){return Object.prototype.hasOwnProperty.call(this.obj,HS(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 Cm(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 qS(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 HS(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`
|
|
@@ -352,7 +352,7 @@ sandbox-build-prod:
|
|
|
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 ih(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 ih(`Invalid language. Must be one of: ${Object.values(ao).join(", ")}`);return t}).alias("it").action(async t=>{try{process.stdout.write(`
|
|
354
354
|
`);let e=Fn(t.path);console.log(`\u{1F680} Initializing Sandbox Template...
|
|
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 C_({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(`
|
|
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:String(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 C_({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
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(`
|