phala 1.0.29 → 1.0.30
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/api/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{$ as N,A as g,B as h,C as i,D as j,E as k,F as l,G as n,H as q,I as s,J as u,K as v,L as w,M as y,N as z,O as A,P as B,Q as C,R as D,S as E,T as F,U as G,V as H,W as I,X as J,Y as K,Z as L,_ as M,aa as O,ba as P,ca as Q,o,p as r,q as e,r as f,s as m,t as p,u as t,v as x,w as a,x as b,y as c,z as d}from"../chunk-
|
1
|
+
import{$ as N,A as g,B as h,C as i,D as j,E as k,F as l,G as n,H as q,I as s,J as u,K as v,L as w,M as y,N as z,O as A,P as B,Q as C,R as D,S as E,T as F,U as G,V as H,W as I,X as J,Y as K,Z as L,_ as M,aa as O,ba as P,ca as Q,o,p as r,q as e,r as f,s as m,t as p,u as t,v as x,w as a,x as b,y as c,z as d}from"../chunk-2X5HREGL.js";import"../chunk-4YCH6IZV.js";export{k as capacitySchema,z as checkCvmExists,r as composeFileSchema,e as configurationSchema,D as createCvm,v as cvmAttestationResponseSchema,s as cvmComposeConfigSchema,t as cvmInstanceSchema,I as deleteCvm,o as dockerConfigSchema,h as encryptedEnvItemSchema,L as getCvmAttestation,A as getCvmByAppId,b as getCvmByAppIdResponseSchema,M as getCvmComposeConfig,C as getCvmNetwork,q as getCvmNetworkResponseSchema,y as getCvms,d as getCvmsByUserIdResponseSchema,B as getPubkeyFromCvm,a as getPubkeyFromCvmResponseSchema,Q as getTeepodImages,P as getTeepods,w as getUserInfo,c as getUserInfoResponseSchema,f as hostedSchema,i as imageSchema,l as kmsListItemSchema,m as managedUserSchema,p as nodeSchema,x as postCvmResponseSchema,N as replicateCvm,u as replicateCvmResponseSchema,O as resizeCvm,G as restartCvm,K as selectCvm,E as startCvm,F as stopCvm,n as teepodResponseSchema,j as teepodSchema,J as updateCvm,H as upgradeCvm,g as upgradeCvmResponseSchema};
|
2
2
|
//# sourceMappingURL=index.js.map
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{b as ee}from"./chunk-4YCH6IZV.js";import _ from"chalk";function ke(r){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return r.replace(new RegExp(t,"g"),"")}function L(r){return ke(r).length}function z(r,t){if(!r)return[""];if(L(r)<=t)return[r];let o=[],n="",s=0,a=r.split(/(\s+)/).filter(l=>l.trim().length>0);for(let l of a){let b=L(l);if(b>t){n&&(o.push(n),n="",s=0),o.push(l);continue}s+b+(s>0?1:0)>t?(o.push(n),n=l,s=b):n?(n=`${n} ${l}`,s+=b+1):(n=l,s=b)}return n&&o.push(n),o}var y={error:(r,...t)=>{console.error(_.red("\u2717"),_.red(r),...t)},warn:(r,...t)=>{console.log(_.yellow("\u26A0"),_.yellow(r),...t)},info:(r,...t)=>{console.log(_.blue("\u2139"),_.blue(r),...t)},success:(r,...t)=>{console.log(_.green("\u2713"),_.green(r),...t)},debug:(r,...t)=>{process.env.DEBUG&&console.log(_.gray("\u{1F50D}"),_.gray(r),...t)},table:(r,t)=>{if(r.length===0){console.log(_.yellow("No data to display"));return}if(t)if(typeof t[0]=="string"){let o=t.map(n=>({key:n,header:n.charAt(0).toUpperCase()+n.slice(1)}));H(r,{columns:o,borderStyle:"rounded",headerStyle:n=>_.cyan.bold(n)})}else H(r,{columns:t,borderStyle:"rounded",headerStyle:o=>_.cyan.bold(o)});else H(r,{borderStyle:"rounded",headerStyle:o=>_.cyan.bold(o)})},keyValueTable:(r,t)=>{let n={...{borderStyle:"rounded",enableTextWrapping:!0,maxDepth:2,formatKeys:!0,keyFormatter:h=>{let k=["URL","ID","API","UI","URI","CPU","GPU","RAM","JSON","XML","HTML","HTTP","HTTPS","SSH","FTP","IP","TCP","UDP","DNS","SSL","TLS","SQL","VCPU","CVM","TEE","IO"],S={teepod:"TEEPod",dstack:"Dstack"},R;h.includes("_")?R=h.split("_").map(w=>w.charAt(0).toUpperCase()+w.slice(1).toLowerCase()).join(" "):h.includes("-")?R=h.split("-").map(w=>w.charAt(0).toUpperCase()+w.slice(1).toLowerCase()).join(" "):R=h.charAt(0).toUpperCase()+h.slice(1).replace(/([a-z])([A-Z])/g,"$1 $2");for(let w of k){let $=new RegExp(`\\b${w.toLowerCase()}\\b`,"gi");R=R.replace($,w)}for(let[w,$]of Object.entries(S)){let B=new RegExp(`\\b${w}\\b`,"gi");R=R.replace(B,$)}return R},valueFormatter:h=>String(h??"")},...t},{include:s,exclude:a,keyFormatter:l,valueFormatter:b,formatKeys:E,keyWidth:x,valueWidth:P,borderStyle:M,enableTextWrapping:p,maxDepth:m}=n,c=Object.keys(r);if(s&&(c=c.filter(h=>s.includes(h))),a&&(c=c.filter(h=>!a.includes(h))),c.length===0){console.log(_.yellow("No properties to display"));return}let g=c.map(h=>{let k=r[h],S;return k==null?S="":typeof k=="object"&&!Array.isArray(k)?S=te(k,0,m):Array.isArray(k)?k.length===0?S="[]":typeof k[0]=="object"?S=`[${k.length} items]`:S=`[${k.join(", ")}]`:S=String(k),b&&(S=b(k,h)),{key:E&&l?_.cyan.bold(l(h)):_.cyan.bold(h),value:S}}),f=re(),i=x,u=P;if(i||(i=Math.max(...g.map(h=>L(h.key)),10),i=Math.min(i,Math.floor(f/3))),!u){u=Math.max(...g.map(S=>L(S.value)),10),u+=3;let h=7,k=f-i-h;u=Math.min(u,k)}let d=xe(M),D=`${d.topLeft}${d.horizontal.repeat(i+2)}${d.topT}${d.horizontal.repeat(u+2)}${d.topRight}`,I=`${d.leftT}${d.horizontal.repeat(i+2)}${d.cross}${d.horizontal.repeat(u+2)}${d.rightT}`;console.log(D),console.log(I),g.forEach((h,k)=>{let S=p?z(h.key,i):[h.key],R=p?z(h.value,u):[h.value],w=Math.max(S.length,R.length);for(let $=0;$<w;$++){let B=S[$]||"",Q=R[$]||"",ve=B+" ".repeat(Math.max(0,i-L(B))),Ce=Q+" ".repeat(Math.max(0,u-L(Q)));console.log(`${d.vertical} ${ve} ${d.vertical} ${Ce} ${d.vertical}`)}k<g.length-1&&console.log(`${d.leftT}${d.horizontal.repeat(i+2)}${d.cross}${d.horizontal.repeat(u+2)}${d.rightT}`)});let Z=`${d.bottomLeft}${d.horizontal.repeat(i+2)}${d.bottomT}${d.horizontal.repeat(u+2)}${d.bottomRight}`;console.log(Z)},startSpinner:r=>(process.stdout.write(`${_.blue("\u27F3")} ${r}... `),{stop:(t=!0,o)=>{let n=t?_.green("\u2713"):_.red("\u2717"),s=o?`: ${o}`:"";console.log(`${n}${s}`)}}),break(){console.log("")}};function te(r,t,o){if(t>=o)return"[Nested Object]";if(r==null)return"";if(Array.isArray(r))return r.length===0?"[]":`[${r.length} items]`;let n=[];for(let[s,a]of Object.entries(r))a==null?n.push(`${s}: `):typeof a=="object"?n.push(`${s}: ${te(a,t+1,o)}`):n.push(`${s}: ${a}`);return n.join(", ")}function xe(r="single"){return{single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",leftT:"\u251C",rightT:"\u2524",topT:"\u252C",bottomT:"\u2534",cross:"\u253C"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",leftT:"\u2560",rightT:"\u2563",topT:"\u2566",bottomT:"\u2569",cross:"\u256C"},rounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",leftT:"\u251C",rightT:"\u2524",topT:"\u252C",bottomT:"\u2534",cross:"\u253C"}}[r]}function re(){return process.stdout.columns||80}function Se(r,t,o={}){let n=re(),s=o.borderChars??3,l=(o.additionalBorderWidth??1)+t.length*s,b=n-l,E={},x=0,P=0;for(let m of t){let c=m.key;if(m.fixedWidth!==void 0){E[c]=m.fixedWidth,x+=m.fixedWidth;continue}let g=m.minWidth??m.header.length,f;m.getWidth?f=Math.max(g,m.header.length,...r.map(i=>m.getWidth(i))):m.getValue?f=Math.max(g,m.header.length,...r.map(i=>String(m.getValue(i)||"").length)):f=Math.max(g,m.header.length,...r.map(i=>String(i[m.key]||"").length)),E[c]=f,x+=f,P+=m.weight??1}let M=Math.max(0,b-x);if(M>0&&P>0)for(let m of t){let c=m.key;if(m.fixedWidth===void 0&&m.weight){let g=Math.floor(M*(m.weight/P));E[c]+=g}}let p=Object.values(E).reduce((m,c)=>m+c,0)+l;if(p>n){let m=b/(p-l),c={};for(let g of t){let f=g.key,i=g.minWidth??g.header.length;c[f]=Math.max(i,Math.floor(E[f]*m))}return c}return E}function H(r,t={}){if(t.keyValueMode&&r.length===1){let p=r[0],m=[];t.columns||(t.columns=Object.keys(p).map(c=>({key:c,header:c.charAt(0).toUpperCase()+c.slice(1).replace(/([A-Z])/g," $1")})));for(let c of t.columns){let g=String(c.key),f;if(c.accessor)f=c.accessor(p);else if(typeof c.key=="string"&&c.key.includes(".")){let i=c.key.split("."),u=p;for(let d of i){if(u==null){f="";break}u=u[d]}f=u}else f=p[c.key];c.formatter&&(f=c.formatter(f)),m.push({key:c.header||g,value:f})}r=m,t.columns=[{key:"key",minWidth:15},{key:"value",minWidth:20}]}if(r.length===0){console.log(_.yellow("No data to display"));return}let n={...{includeHeaders:!0,border:!0,borderStyle:"single",headerStyle:p=>_.bold(p),cellStyle:p=>p,enableTextWrapping:!0},...t},s=n.columns;if(s)s=s.map(p=>({...p,enableTextWrapping:p.enableTextWrapping!==void 0?p.enableTextWrapping:n.enableTextWrapping}));else{let p=r[0];s=Object.keys(p).map(m=>({key:m,header:m.charAt(0).toUpperCase()+m.slice(1),enableTextWrapping:n.enableTextWrapping}))}let l={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",leftT:"\u251C",rightT:"\u2524",topT:"\u252C",bottomT:"\u2534",cross:"\u253C"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",leftT:"\u2560",rightT:"\u2563",topT:"\u2566",bottomT:"\u2569",cross:"\u256C"},rounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",leftT:"\u251C",rightT:"\u2524",topT:"\u252C",bottomT:"\u2534",cross:"\u253C"}}[n.borderStyle],b=s.map(p=>({key:p.key,header:p.header||String(p.key),minWidth:p.minWidth||3,weight:p.weight,enableTextWrapping:p.enableTextWrapping,getValue:p.accessor?m=>p.accessor(m):m=>{if(typeof p.key=="string"&&p.key.includes(".")){let c=p.key.split("."),g=m;for(let f of c){if(g==null)return"";g=g[f]}return g??""}return m[p.key]??""}})),E=Se(r,b),x=s.map((p,m)=>({...p,width:E[b[m].key]})),P=x.map(p=>p.header||String(p.key)),M=(p,m)=>{let c=x.map(i=>{let u;if(i.accessor)u=i.accessor(p);else if(typeof i.key=="string"&&i.key.includes(".")){let D=i.key.split("."),I=p;for(let Z of D){if(I==null){u="";break}I=I[Z]}u=I??""}else u=p[i.key]??"";let d=i.formatter?i.formatter(u):String(u||"");return i.enableTextWrapping?{lines:z(d,i.width),key:String(i.key)}:{lines:[d.length>i.width?d.substring(0,i.width-1)+"\u2026":d],key:String(i.key)}}),g=Math.max(...c.map(i=>i.lines.length)),f=[];for(let i=0;i<g;i++){let u=c.map((d,D)=>{let I=d.lines[i]||"";return n.cellStyle(I.padEnd(x[D].width),m,d.key)});f.push(u)}return f};if(n.border){let p=l.topLeft+x.map(c=>l.horizontal.repeat(c.width+2)).join(l.topT)+l.topRight;if(console.log(p),n.includeHeaders){let c=x.map((i,u)=>({lines:i.enableTextWrapping?z(P[u],i.width):[P[u]],width:i.width})),g=Math.max(...c.map(i=>i.lines.length));for(let i=0;i<g;i++){let u=l.vertical+c.map(d=>{let D=d.lines[i]||"";return" "+n.headerStyle(D.padEnd(d.width))+" "}).join(l.vertical)+l.vertical;console.log(u)}let f=l.leftT+x.map(i=>l.horizontal.repeat(i.width+2)).join(l.cross)+l.rightT;console.log(f)}r.forEach((c,g)=>{let f=M(c,g);if(f.forEach(i=>{console.log(l.vertical+i.map(u=>` ${u} `).join(l.vertical)+l.vertical)}),g<r.length-1&&f.length>1){let i=l.leftT+x.map(u=>l.horizontal.repeat(u.width+2)).join(l.cross)+l.rightT;console.log(i)}});let m=l.bottomLeft+x.map(c=>l.horizontal.repeat(c.width+2)).join(l.bottomT)+l.bottomRight;console.log(m)}else{if(n.includeHeaders){let p=x.map((g,f)=>({lines:g.enableTextWrapping?z(P[f],g.width):[P[f]],width:g.width})),m=Math.max(...p.map(g=>g.lines.length));for(let g=0;g<m;g++){let f=p.map(i=>{let u=i.lines[g]||"";return n.headerStyle(u.padEnd(i.width))}).join(" ");console.log(f)}let c=x.map(g=>"\u2500".repeat(g.width)).join(" ");console.log(c)}r.forEach((p,m)=>{let c=M(p,m);c.forEach(g=>{console.log(g.join(" "))}),m<r.length-1&&c.length>1&&console.log("")})}console.log(`Total: ${r.length} rows`)}import{z as e}from"zod";import{INVALID as Te,ParseStatus as we,ZodIssueCode as O,ZodParsedType as ne,ZodType as Re,addIssueToContext as V,z as oe}from"zod";var Ee="ZodDecimal",Pe=/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/,j=class extends Re{_parse(t){if(t.data!==null&&typeof t.data=="object"&&"toNumber"in t.data&&(t.data=t.data.toNumber()),this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==ne.number){let a=this._getOrReturnCtx(t);return V(a,{code:O.invalid_type,expected:ne.number,received:a.parsedType}),Te}let n,s=new we;for(let a of this._def.checks)if(a.kind==="precision"){let l=t.data.toString().match(Pe);Math.max((l[1]?l[1].length:0)-(l[2]?parseInt(l[2],10):0),0)>a.value&&(n=this._getOrReturnCtx(t,n),V(n,{code:O.custom,message:a.message,params:{precision:a.value}}),s.dirty())}else a.kind==="wholeNumber"?t.data.toString().split(".")[0].length>a.value&&(n=this._getOrReturnCtx(t,n),V(n,{code:O.custom,message:a.message,params:{wholeNumber:a.value}}),s.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),V(n,{code:O.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),V(n,{code:O.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="finite"&&(Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{code:O.not_finite,message:a.message}),s.dirty()));return{status:s.value,value:t.data}}setLimit(t,o,n,s){return new j({...this._def,checks:[...this._def.checks,{kind:t,value:o,inclusive:n,message:s}]})}_addCheck(t){return new j({...this._def,checks:[...this._def.checks,t]})}lte(t,o){return this.setLimit("max",t,!0,o)}lt(t,o){return this.setLimit("max",t,!1,o)}max=this.lte;gt(t,o){return this.setLimit("min",t,!1,o)}gte(t,o){return this.setLimit("min",t,!0,o)}min=this.gte;precision(t,o){return this._addCheck({kind:"precision",value:t,message:o})}wholeNumber(t,o){return this._addCheck({kind:"wholeNumber",value:t,message:o})}get minValue(){let t=null;for(let o of this._def.checks)o.kind==="min"&&(t===null||o.value>t)&&(t=o.value);return t}get maxValue(){let t=null;for(let o of this._def.checks)o.kind==="max"&&(t===null||o.value<t)&&(t=o.value);return t}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:t})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:t})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:t})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:t})}finite(t){return this._addCheck({kind:"finite",message:t})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:t})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:t})}get isFinite(){let t=null,o=null;for(let n of this._def.checks){if(n.kind==="finite")return!0;n.kind==="min"?(o===null||n.value>o)&&(o=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(o)&&Number.isFinite(t)}},N=j;ee(N,"create",t=>new j({checks:[],typeName:Ee,coerce:t?.coerce??!1}));var Qe=oe.object({template:oe.string().min(1,"Template cannot be empty")});var Ae=e.object({password:e.string(),registry:e.string().nullable(),username:e.string()}),Ie=e.object({docker_compose_file:e.string(),docker_config:Ae.optional().nullable(),features:e.array(e.string()),kms_enabled:e.boolean(),manifest_version:e.number(),name:e.string(),public_logs:e.boolean(),public_sysinfo:e.boolean(),runner:e.string().optional(),salt:e.string().nullable().optional(),tproxy_enabled:e.boolean(),version:e.string().optional()}).passthrough(),$e=e.object({name:e.string(),image:e.string(),compose_file:Ie.nullable().optional(),vcpu:e.number(),memory:e.number(),disk_size:e.number(),ports:e.array(e.any())}).passthrough(),Me=e.object({id:e.string(),name:e.string(),status:e.string(),uptime:e.string(),app_url:e.string().nullable(),app_id:e.string(),instance_id:e.string().nullable(),configuration:$e.nullable().optional(),exited_at:e.string().nullable(),boot_progress:e.string().nullable(),boot_error:e.string().nullable(),shutdown_progress:e.string().nullable(),image_version:e.string().nullable()}).passthrough(),De=e.object({id:e.number(),username:e.string()}),Le=e.object({id:e.number(),name:e.string(),region_identifier:e.string().optional()}),Y=e.object({hosted:Me,name:e.string(),managed_user:De,node:Le,listed:e.boolean(),status:e.string(),in_progress:e.boolean(),dapp_dashboard_url:e.string().nullable(),syslog_endpoint:e.string(),allow_upgrade:e.boolean()}),W=e.object({id:e.number(),name:e.string(),status:e.string(),teepod_id:e.number().nullable(),teepod:e.object({id:e.number(),name:e.string()}).nullable(),user_id:e.number(),app_id:e.string(),vm_uuid:e.string().nullable(),instance_id:e.string().nullable(),app_url:e.string().nullable(),base_image:e.string(),vcpu:e.number(),memory:e.number(),disk_size:e.number(),manifest_version:e.number(),version:e.string(),runner:e.string(),docker_compose_file:e.string(),features:e.array(e.string()).nullable(),created_at:e.string(),encrypted_env_pubkey:e.string()}),se=e.object({app_env_encrypt_pubkey:e.string(),app_id_salt:e.string()}),ie=e.object({id:e.number(),teepod_id:e.number().nullable(),teepod:e.object({id:e.number(),name:e.string()}).nullable(),name:e.string(),status:e.string(),in_progress:e.boolean(),app_id:e.string(),vm_uuid:e.string(),instance_id:e.string().nullable(),vcpu:e.number(),memory:e.number(),disk_size:e.number(),base_image:e.string(),encrypted_env_pubkey:e.string(),listed:e.boolean(),project_id:e.string(),project_type:e.string().nullable()}),ae=e.object({username:e.string(),email:e.string(),credits:N.create({coerce:!0}),granted_credits:N.create({coerce:!0}),avatar:e.string()}).passthrough(),ot=e.array(Y),le=e.object({detail:e.string()}),st=e.object({key:e.string(),value:e.string()}),J=e.object({name:e.string(),description:e.string().optional(),version:e.array(e.number()).optional(),is_dev:e.boolean().optional(),os_image_hash:e.string().nullable().optional(),rootfs_hash:e.string().optional(),shared_ro:e.boolean().optional(),cmdline:e.string().optional(),kernel:e.string().optional(),initrd:e.string().optional(),hda:e.string().nullable().optional(),rootfs:e.string().optional(),bios:e.string().optional()}),Oe=e.object({teepod_id:e.number().nullable(),id:e.number().optional(),name:e.string(),listed:e.boolean().optional(),resource_score:e.number().optional(),remaining_vcpu:e.number().optional(),remaining_memory:e.number().optional(),remaining_cvm_slots:e.number().optional(),images:e.array(J).optional(),region_identifier:e.string().optional(),dedicated_for_team_id:e.number().nullable().optional(),support_onchain_kms:e.boolean().optional(),fmspc:e.string().nullable().optional(),device_id:e.string().nullable().optional()}),Ve=e.object({max_instances:e.number().nullable(),max_vcpu:e.number().nullable(),max_memory:e.number().nullable(),max_disk:e.number().nullable()}),Ne=e.object({id:e.string(),slug:e.string(),url:e.string(),version:e.string(),chain_id:e.number(),kms_contract_address:e.string(),gateway_app_id:e.string().nullable().optional()}),ce=e.object({tier:e.string(),capacity:Ve,nodes:e.array(Oe),kms_list:e.array(Ne).optional()}),pe=e.object({is_online:e.boolean(),is_public:e.boolean(),error:e.string().nullable(),internal_ip:e.string(),latest_handshake:e.string(),public_urls:e.array(e.object({app:e.string(),instance:e.string()}))}),me=e.object({compose_file:e.object({bash_script:e.string().nullable(),docker_compose_file:e.string(),docker_config:e.object({password:e.string(),registry:e.string().nullable(),username:e.string()}),features:e.array(e.string()),kms_enabled:e.boolean(),manifest_version:e.number(),name:e.string(),pre_launch_script:e.string(),public_logs:e.boolean(),public_sysinfo:e.boolean(),runner:e.string(),salt:e.string(),tproxy_enabled:e.boolean(),version:e.string()}),env_pubkey:e.string(),salt:e.string()}),ge=e.object({id:e.number(),name:e.string(),status:e.string(),teepod_id:e.number(),teepod:e.object({id:e.number(),name:e.string()}),user_id:e.number(),app_id:e.string(),vm_uuid:e.string(),instance_id:e.string().nullable(),app_url:e.string().nullable(),base_image:e.string(),vcpu:e.number(),memory:e.number(),disk_size:e.number(),manifest_version:e.number(),version:e.string().nullable(),runner:e.string(),docker_compose_file:e.string(),features:e.array(e.string()).nullable(),created_at:e.string(),encrypted_env_pubkey:e.string()}),ue=e.object({is_online:e.boolean(),is_public:e.boolean(),error:e.string().nullable(),app_certificates:e.array(e.object({subject:e.object({common_name:e.string().nullable(),organization:e.string().nullable(),country:e.string().nullable(),state:e.string().nullable().optional(),locality:e.string().nullable().optional()}),issuer:e.object({common_name:e.string().nullable(),organization:e.string().nullable(),country:e.string().nullable()}),serial_number:e.string(),not_before:e.string(),not_after:e.string(),version:e.string(),fingerprint:e.string(),signature_algorithm:e.string(),sans:e.string().nullable(),is_ca:e.boolean(),position_in_chain:e.number(),quote:e.string().nullable()})).nullable(),tcb_info:e.object({mrtd:e.string(),rootfs_hash:e.string(),rtmr0:e.string(),rtmr1:e.string(),rtmr2:e.string(),rtmr3:e.string(),event_log:e.array(e.object({imr:e.number(),event_type:e.number(),digest:e.string(),event:e.string(),event_payload:e.string()}))}).nullable(),compose_file:e.string().nullable()});import{createClient as Fe}from"@phala/cloud";var at=process.env.CLOUD_URL||"https://cloud.phala.network";var lt=1,ct=2048,pt=40,mt="dstack-0.3.6",v={USER_INFO:"auth/me",TEEPODS:"teepods/available",TEEPOD_IMAGES:r=>`teepods/${r}/images`,CVMS:r=>`cvms?user_id=${r}`,CVM_BY_APP_ID:r=>`cvms/app_${r}`,CVM_NETWORK:r=>`cvms/app_${r}/network`,CVM_START:r=>`cvms/app_${r}/start`,CVM_STOP:r=>`cvms/app_${r}/stop`,CVM_RESTART:r=>`cvms/app_${r}/restart`,CVM_LOGS:r=>`cvms/app_${r}/logs`,CVM_FROM_CONFIGURATION:"cvms/from_cvm_configuration",CVM_PUBKEY:"cvms/pubkey/from_cvm_configuration",CVM_UPGRADE:r=>`cvms/app_${r}/compose`,CVM_ATTESTATION:r=>`cvms/app_${r}/attestation`,CVM_RESIZE:r=>`cvms/app_${r}/resources`,CVM_COMPOSE:r=>`cvms/${r}/compose`,REPLICATE_CVM:r=>`cvms/${r}/replicas`},gt=`version: '3.8'
|
1
|
+
import{b as ee}from"./chunk-4YCH6IZV.js";import _ from"chalk";function ke(r){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return r.replace(new RegExp(t,"g"),"")}function L(r){return ke(r).length}function F(r,t){if(!r)return[""];if(L(r)<=t)return[r];let o=[],n="",s=0,a=r.split(/(\s+)/).filter(l=>l.trim().length>0);for(let l of a){let b=L(l);if(b>t){n&&(o.push(n),n="",s=0),o.push(l);continue}s+b+(s>0?1:0)>t?(o.push(n),n=l,s=b):n?(n=`${n} ${l}`,s+=b+1):(n=l,s=b)}return n&&o.push(n),o}var y={error:(r,...t)=>{console.error(_.red("\u2717"),_.red(r),...t)},warn:(r,...t)=>{console.log(_.yellow("\u26A0"),_.yellow(r),...t)},info:(r,...t)=>{console.log(_.blue("\u2139"),_.blue(r),...t)},success:(r,...t)=>{console.log(_.green("\u2713"),_.green(r),...t)},debug:(r,...t)=>{process.env.DEBUG&&console.log(_.gray("\u{1F50D}"),_.gray(r),...t)},table:(r,t)=>{if(r.length===0){console.log(_.yellow("No data to display"));return}if(t)if(typeof t[0]=="string"){let o=t.map(n=>({key:n,header:n.charAt(0).toUpperCase()+n.slice(1)}));H(r,{columns:o,borderStyle:"rounded",headerStyle:n=>_.cyan.bold(n)})}else H(r,{columns:t,borderStyle:"rounded",headerStyle:o=>_.cyan.bold(o)});else H(r,{borderStyle:"rounded",headerStyle:o=>_.cyan.bold(o)})},keyValueTable:(r,t)=>{let n={...{borderStyle:"rounded",enableTextWrapping:!0,maxDepth:2,formatKeys:!0,keyFormatter:h=>{let k=["URL","ID","API","UI","URI","CPU","GPU","RAM","JSON","XML","HTML","HTTP","HTTPS","SSH","FTP","IP","TCP","UDP","DNS","SSL","TLS","SQL","VCPU","CVM","TEE","IO"],S={teepod:"TEEPod",dstack:"Dstack"},R;h.includes("_")?R=h.split("_").map(w=>w.charAt(0).toUpperCase()+w.slice(1).toLowerCase()).join(" "):h.includes("-")?R=h.split("-").map(w=>w.charAt(0).toUpperCase()+w.slice(1).toLowerCase()).join(" "):R=h.charAt(0).toUpperCase()+h.slice(1).replace(/([a-z])([A-Z])/g,"$1 $2");for(let w of k){let $=new RegExp(`\\b${w.toLowerCase()}\\b`,"gi");R=R.replace($,w)}for(let[w,$]of Object.entries(S)){let B=new RegExp(`\\b${w}\\b`,"gi");R=R.replace(B,$)}return R},valueFormatter:h=>String(h??"")},...t},{include:s,exclude:a,keyFormatter:l,valueFormatter:b,formatKeys:E,keyWidth:x,valueWidth:P,borderStyle:M,enableTextWrapping:p,maxDepth:m}=n,c=Object.keys(r);if(s&&(c=c.filter(h=>s.includes(h))),a&&(c=c.filter(h=>!a.includes(h))),c.length===0){console.log(_.yellow("No properties to display"));return}let u=c.map(h=>{let k=r[h],S;return k==null?S="":typeof k=="object"&&!Array.isArray(k)?S=te(k,0,m):Array.isArray(k)?k.length===0?S="[]":typeof k[0]=="object"?S=`[${k.length} items]`:S=`[${k.join(", ")}]`:S=String(k),b&&(S=b(k,h)),{key:E&&l?_.cyan.bold(l(h)):_.cyan.bold(h),value:S}}),f=re(),i=x,g=P;if(i||(i=Math.max(...u.map(h=>L(h.key)),10),i=Math.min(i,Math.floor(f/3))),!g){g=Math.max(...u.map(S=>L(S.value)),10),g+=3;let h=7,k=f-i-h;g=Math.min(g,k)}let d=xe(M),D=`${d.topLeft}${d.horizontal.repeat(i+2)}${d.topT}${d.horizontal.repeat(g+2)}${d.topRight}`,I=`${d.leftT}${d.horizontal.repeat(i+2)}${d.cross}${d.horizontal.repeat(g+2)}${d.rightT}`;console.log(D),console.log(I),u.forEach((h,k)=>{let S=p?F(h.key,i):[h.key],R=p?F(h.value,g):[h.value],w=Math.max(S.length,R.length);for(let $=0;$<w;$++){let B=S[$]||"",Q=R[$]||"",ve=B+" ".repeat(Math.max(0,i-L(B))),Ce=Q+" ".repeat(Math.max(0,g-L(Q)));console.log(`${d.vertical} ${ve} ${d.vertical} ${Ce} ${d.vertical}`)}k<u.length-1&&console.log(`${d.leftT}${d.horizontal.repeat(i+2)}${d.cross}${d.horizontal.repeat(g+2)}${d.rightT}`)});let Z=`${d.bottomLeft}${d.horizontal.repeat(i+2)}${d.bottomT}${d.horizontal.repeat(g+2)}${d.bottomRight}`;console.log(Z)},startSpinner:r=>(process.stdout.write(`${_.blue("\u27F3")} ${r}... `),{stop:(t=!0,o)=>{let n=t?_.green("\u2713"):_.red("\u2717"),s=o?`: ${o}`:"";console.log(`${n}${s}`)}}),break(){console.log("")}};function te(r,t,o){if(t>=o)return"[Nested Object]";if(r==null)return"";if(Array.isArray(r))return r.length===0?"[]":`[${r.length} items]`;let n=[];for(let[s,a]of Object.entries(r))a==null?n.push(`${s}: `):typeof a=="object"?n.push(`${s}: ${te(a,t+1,o)}`):n.push(`${s}: ${a}`);return n.join(", ")}function xe(r="single"){return{single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",leftT:"\u251C",rightT:"\u2524",topT:"\u252C",bottomT:"\u2534",cross:"\u253C"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",leftT:"\u2560",rightT:"\u2563",topT:"\u2566",bottomT:"\u2569",cross:"\u256C"},rounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",leftT:"\u251C",rightT:"\u2524",topT:"\u252C",bottomT:"\u2534",cross:"\u253C"}}[r]}function re(){return process.stdout.columns||80}function Se(r,t,o={}){let n=re(),s=o.borderChars??3,l=(o.additionalBorderWidth??1)+t.length*s,b=n-l,E={},x=0,P=0;for(let m of t){let c=m.key;if(m.fixedWidth!==void 0){E[c]=m.fixedWidth,x+=m.fixedWidth;continue}let u=m.minWidth??m.header.length,f;m.getWidth?f=Math.max(u,m.header.length,...r.map(i=>m.getWidth(i))):m.getValue?f=Math.max(u,m.header.length,...r.map(i=>String(m.getValue(i)||"").length)):f=Math.max(u,m.header.length,...r.map(i=>String(i[m.key]||"").length)),E[c]=f,x+=f,P+=m.weight??1}let M=Math.max(0,b-x);if(M>0&&P>0)for(let m of t){let c=m.key;if(m.fixedWidth===void 0&&m.weight){let u=Math.floor(M*(m.weight/P));E[c]+=u}}let p=Object.values(E).reduce((m,c)=>m+c,0)+l;if(p>n){let m=b/(p-l),c={};for(let u of t){let f=u.key,i=u.minWidth??u.header.length;c[f]=Math.max(i,Math.floor(E[f]*m))}return c}return E}function H(r,t={}){if(t.keyValueMode&&r.length===1){let p=r[0],m=[];t.columns||(t.columns=Object.keys(p).map(c=>({key:c,header:c.charAt(0).toUpperCase()+c.slice(1).replace(/([A-Z])/g," $1")})));for(let c of t.columns){let u=String(c.key),f;if(c.accessor)f=c.accessor(p);else if(typeof c.key=="string"&&c.key.includes(".")){let i=c.key.split("."),g=p;for(let d of i){if(g==null){f="";break}g=g[d]}f=g}else f=p[c.key];c.formatter&&(f=c.formatter(f)),m.push({key:c.header||u,value:f})}r=m,t.columns=[{key:"key",minWidth:15},{key:"value",minWidth:20}]}if(r.length===0){console.log(_.yellow("No data to display"));return}let n={...{includeHeaders:!0,border:!0,borderStyle:"single",headerStyle:p=>_.bold(p),cellStyle:p=>p,enableTextWrapping:!0},...t},s=n.columns;if(s)s=s.map(p=>({...p,enableTextWrapping:p.enableTextWrapping!==void 0?p.enableTextWrapping:n.enableTextWrapping}));else{let p=r[0];s=Object.keys(p).map(m=>({key:m,header:m.charAt(0).toUpperCase()+m.slice(1),enableTextWrapping:n.enableTextWrapping}))}let l={single:{topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",leftT:"\u251C",rightT:"\u2524",topT:"\u252C",bottomT:"\u2534",cross:"\u253C"},double:{topLeft:"\u2554",topRight:"\u2557",bottomLeft:"\u255A",bottomRight:"\u255D",horizontal:"\u2550",vertical:"\u2551",leftT:"\u2560",rightT:"\u2563",topT:"\u2566",bottomT:"\u2569",cross:"\u256C"},rounded:{topLeft:"\u256D",topRight:"\u256E",bottomLeft:"\u2570",bottomRight:"\u256F",horizontal:"\u2500",vertical:"\u2502",leftT:"\u251C",rightT:"\u2524",topT:"\u252C",bottomT:"\u2534",cross:"\u253C"}}[n.borderStyle],b=s.map(p=>({key:p.key,header:p.header||String(p.key),minWidth:p.minWidth||3,weight:p.weight,enableTextWrapping:p.enableTextWrapping,getValue:p.accessor?m=>p.accessor(m):m=>{if(typeof p.key=="string"&&p.key.includes(".")){let c=p.key.split("."),u=m;for(let f of c){if(u==null)return"";u=u[f]}return u??""}return m[p.key]??""}})),E=Se(r,b),x=s.map((p,m)=>({...p,width:E[b[m].key]})),P=x.map(p=>p.header||String(p.key)),M=(p,m)=>{let c=x.map(i=>{let g;if(i.accessor)g=i.accessor(p);else if(typeof i.key=="string"&&i.key.includes(".")){let D=i.key.split("."),I=p;for(let Z of D){if(I==null){g="";break}I=I[Z]}g=I??""}else g=p[i.key]??"";let d=i.formatter?i.formatter(g):String(g||"");return i.enableTextWrapping?{lines:F(d,i.width),key:String(i.key)}:{lines:[d.length>i.width?d.substring(0,i.width-1)+"\u2026":d],key:String(i.key)}}),u=Math.max(...c.map(i=>i.lines.length)),f=[];for(let i=0;i<u;i++){let g=c.map((d,D)=>{let I=d.lines[i]||"";return n.cellStyle(I.padEnd(x[D].width),m,d.key)});f.push(g)}return f};if(n.border){let p=l.topLeft+x.map(c=>l.horizontal.repeat(c.width+2)).join(l.topT)+l.topRight;if(console.log(p),n.includeHeaders){let c=x.map((i,g)=>({lines:i.enableTextWrapping?F(P[g],i.width):[P[g]],width:i.width})),u=Math.max(...c.map(i=>i.lines.length));for(let i=0;i<u;i++){let g=l.vertical+c.map(d=>{let D=d.lines[i]||"";return" "+n.headerStyle(D.padEnd(d.width))+" "}).join(l.vertical)+l.vertical;console.log(g)}let f=l.leftT+x.map(i=>l.horizontal.repeat(i.width+2)).join(l.cross)+l.rightT;console.log(f)}r.forEach((c,u)=>{let f=M(c,u);if(f.forEach(i=>{console.log(l.vertical+i.map(g=>` ${g} `).join(l.vertical)+l.vertical)}),u<r.length-1&&f.length>1){let i=l.leftT+x.map(g=>l.horizontal.repeat(g.width+2)).join(l.cross)+l.rightT;console.log(i)}});let m=l.bottomLeft+x.map(c=>l.horizontal.repeat(c.width+2)).join(l.bottomT)+l.bottomRight;console.log(m)}else{if(n.includeHeaders){let p=x.map((u,f)=>({lines:u.enableTextWrapping?F(P[f],u.width):[P[f]],width:u.width})),m=Math.max(...p.map(u=>u.lines.length));for(let u=0;u<m;u++){let f=p.map(i=>{let g=i.lines[u]||"";return n.headerStyle(g.padEnd(i.width))}).join(" ");console.log(f)}let c=x.map(u=>"\u2500".repeat(u.width)).join(" ");console.log(c)}r.forEach((p,m)=>{let c=M(p,m);c.forEach(u=>{console.log(u.join(" "))}),m<r.length-1&&c.length>1&&console.log("")})}console.log(`Total: ${r.length} rows`)}import{z as e}from"zod";import{INVALID as Te,ParseStatus as we,ZodIssueCode as O,ZodParsedType as ne,ZodType as Re,addIssueToContext as V,z as oe}from"zod";var Ee="ZodDecimal",Pe=/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/,j=class extends Re{_parse(t){if(t.data!==null&&typeof t.data=="object"&&"toNumber"in t.data&&(t.data=t.data.toNumber()),this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==ne.number){let a=this._getOrReturnCtx(t);return V(a,{code:O.invalid_type,expected:ne.number,received:a.parsedType}),Te}let n,s=new we;for(let a of this._def.checks)if(a.kind==="precision"){let l=t.data.toString().match(Pe);Math.max((l[1]?l[1].length:0)-(l[2]?parseInt(l[2],10):0),0)>a.value&&(n=this._getOrReturnCtx(t,n),V(n,{code:O.custom,message:a.message,params:{precision:a.value}}),s.dirty())}else a.kind==="wholeNumber"?t.data.toString().split(".")[0].length>a.value&&(n=this._getOrReturnCtx(t,n),V(n,{code:O.custom,message:a.message,params:{wholeNumber:a.value}}),s.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),V(n,{code:O.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),V(n,{code:O.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="finite"&&(Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),V(n,{code:O.not_finite,message:a.message}),s.dirty()));return{status:s.value,value:t.data}}setLimit(t,o,n,s){return new j({...this._def,checks:[...this._def.checks,{kind:t,value:o,inclusive:n,message:s}]})}_addCheck(t){return new j({...this._def,checks:[...this._def.checks,t]})}lte(t,o){return this.setLimit("max",t,!0,o)}lt(t,o){return this.setLimit("max",t,!1,o)}max=this.lte;gt(t,o){return this.setLimit("min",t,!1,o)}gte(t,o){return this.setLimit("min",t,!0,o)}min=this.gte;precision(t,o){return this._addCheck({kind:"precision",value:t,message:o})}wholeNumber(t,o){return this._addCheck({kind:"wholeNumber",value:t,message:o})}get minValue(){let t=null;for(let o of this._def.checks)o.kind==="min"&&(t===null||o.value>t)&&(t=o.value);return t}get maxValue(){let t=null;for(let o of this._def.checks)o.kind==="max"&&(t===null||o.value<t)&&(t=o.value);return t}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:t})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:t})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:t})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:t})}finite(t){return this._addCheck({kind:"finite",message:t})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:t})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:t})}get isFinite(){let t=null,o=null;for(let n of this._def.checks){if(n.kind==="finite")return!0;n.kind==="min"?(o===null||n.value>o)&&(o=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(o)&&Number.isFinite(t)}},N=j;ee(N,"create",t=>new j({checks:[],typeName:Ee,coerce:t?.coerce??!1}));var Qe=oe.object({template:oe.string().min(1,"Template cannot be empty")});var Ae=e.object({password:e.string(),registry:e.string().nullable(),username:e.string()}),Ie=e.object({docker_compose_file:e.string(),docker_config:Ae.optional().nullable(),features:e.array(e.string()),kms_enabled:e.boolean(),manifest_version:e.number(),name:e.string(),public_logs:e.boolean(),public_sysinfo:e.boolean(),runner:e.string().optional(),salt:e.string().nullable().optional(),tproxy_enabled:e.boolean(),version:e.string().optional()}).passthrough(),$e=e.object({name:e.string(),image:e.string(),compose_file:Ie.nullable().optional(),vcpu:e.number(),memory:e.number(),disk_size:e.number(),ports:e.array(e.any())}).passthrough(),Me=e.object({id:e.string(),name:e.string(),status:e.string(),uptime:e.string(),app_url:e.string().nullable(),app_id:e.string(),instance_id:e.string().nullable(),configuration:$e.nullable().optional(),exited_at:e.string().nullable(),boot_progress:e.string().nullable(),boot_error:e.string().nullable(),shutdown_progress:e.string().nullable(),image_version:e.string().nullable()}).passthrough(),De=e.object({id:e.number(),username:e.string()}),Le=e.object({id:e.number(),name:e.string(),region_identifier:e.string().optional()}),Y=e.object({hosted:Me,name:e.string(),managed_user:De,node:Le,listed:e.boolean(),status:e.string(),in_progress:e.boolean(),dapp_dashboard_url:e.string().nullable(),syslog_endpoint:e.string(),allow_upgrade:e.boolean()}),W=e.object({id:e.number(),name:e.string(),status:e.string(),teepod_id:e.number().nullable(),teepod:e.object({id:e.number(),name:e.string()}).nullable(),user_id:e.number(),app_id:e.string(),vm_uuid:e.string().nullable(),instance_id:e.string().nullable(),app_url:e.string().nullable(),base_image:e.string(),vcpu:e.number(),memory:e.number(),disk_size:e.number(),manifest_version:e.number(),version:e.string(),runner:e.string(),docker_compose_file:e.string(),features:e.array(e.string()).nullable(),created_at:e.string(),encrypted_env_pubkey:e.string()}),se=e.object({app_env_encrypt_pubkey:e.string(),app_id_salt:e.string()}),ie=e.object({id:e.number(),teepod_id:e.number().nullable(),teepod:e.object({id:e.number(),name:e.string()}).nullable(),name:e.string(),status:e.string(),in_progress:e.boolean(),app_id:e.string(),vm_uuid:e.string(),instance_id:e.string().nullable(),vcpu:e.number(),memory:e.number(),disk_size:e.number(),base_image:e.string(),encrypted_env_pubkey:e.string(),listed:e.boolean(),project_id:e.string(),project_type:e.string().nullable()}),ae=e.object({username:e.string(),email:e.string(),credits:N.create({coerce:!0}),granted_credits:N.create({coerce:!0}),avatar:e.string()}).passthrough(),ot=e.array(Y),le=e.object({detail:e.string()}),st=e.object({key:e.string(),value:e.string()}),J=e.object({name:e.string(),description:e.string().optional(),version:e.array(e.number()).optional(),is_dev:e.boolean().optional(),os_image_hash:e.string().nullable().optional(),rootfs_hash:e.string().optional(),shared_ro:e.boolean().optional(),cmdline:e.string().optional(),kernel:e.string().optional(),initrd:e.string().optional(),hda:e.string().nullable().optional(),rootfs:e.string().optional(),bios:e.string().optional()}),Oe=e.object({teepod_id:e.number().nullable(),id:e.number().optional(),name:e.string(),listed:e.boolean().optional(),resource_score:e.number().optional(),remaining_vcpu:e.number().optional(),remaining_memory:e.number().optional(),remaining_cvm_slots:e.number().optional(),images:e.array(J).optional(),region_identifier:e.string().optional(),dedicated_for_team_id:e.number().nullable().optional(),support_onchain_kms:e.boolean().optional(),fmspc:e.string().nullable().optional(),device_id:e.string().nullable().optional()}),Ve=e.object({max_instances:e.number().nullable(),max_vcpu:e.number().nullable(),max_memory:e.number().nullable(),max_disk:e.number().nullable()}),Ne=e.object({id:e.string(),slug:e.string(),url:e.string(),version:e.string(),chain_id:e.number(),kms_contract_address:e.string(),gateway_app_id:e.string().nullable().optional()}),ce=e.object({tier:e.string(),capacity:Ve,nodes:e.array(Oe),kms_list:e.array(Ne).optional()}),pe=e.object({is_online:e.boolean(),is_public:e.boolean(),error:e.string().nullable(),internal_ip:e.string(),latest_handshake:e.string(),public_urls:e.array(e.object({app:e.string(),instance:e.string()}))}),me=e.object({compose_file:e.object({bash_script:e.string().nullable(),docker_compose_file:e.string(),docker_config:e.object({password:e.string(),registry:e.string().nullable(),username:e.string()}),features:e.array(e.string()),kms_enabled:e.boolean(),manifest_version:e.number(),name:e.string(),pre_launch_script:e.string(),public_logs:e.boolean(),public_sysinfo:e.boolean(),runner:e.string(),salt:e.string(),tproxy_enabled:e.boolean(),version:e.string()}),env_pubkey:e.string(),salt:e.string()}),ue=e.object({id:e.number(),name:e.string(),status:e.string(),teepod_id:e.number(),teepod:e.object({id:e.number(),name:e.string()}),user_id:e.number(),app_id:e.string(),vm_uuid:e.string(),instance_id:e.string().nullable(),app_url:e.string().nullable(),base_image:e.string(),vcpu:e.number(),memory:e.number(),disk_size:e.number(),manifest_version:e.number(),version:e.string().nullable(),runner:e.string(),docker_compose_file:e.string(),features:e.array(e.string()).nullable(),created_at:e.string(),encrypted_env_pubkey:e.string()}),ge=e.object({is_online:e.boolean(),is_public:e.boolean(),error:e.string().nullable(),app_certificates:e.array(e.object({subject:e.object({common_name:e.string().nullable(),organization:e.string().nullable(),country:e.string().nullable(),state:e.string().nullable().optional(),locality:e.string().nullable().optional()}),issuer:e.object({common_name:e.string().nullable(),organization:e.string().nullable(),country:e.string().nullable()}),serial_number:e.string(),not_before:e.string(),not_after:e.string(),version:e.string(),fingerprint:e.string(),signature_algorithm:e.string(),sans:e.string().nullable(),is_ca:e.boolean(),position_in_chain:e.number(),quote:e.string().nullable()})).nullable(),tcb_info:e.object({mrtd:e.string(),rootfs_hash:e.string(),rtmr0:e.string(),rtmr1:e.string(),rtmr2:e.string(),rtmr3:e.string(),event_log:e.array(e.object({imr:e.number(),event_type:e.number(),digest:e.string(),event:e.string(),event_payload:e.string()}))}).nullable(),compose_file:e.string().nullable()});import{createClient as ze}from"@phala/cloud";var at=process.env.CLOUD_URL||"https://cloud.phala.network";var lt=1,ct=2048,pt=40,mt="dstack-0.3.6",v={USER_INFO:"auth/me",TEEPODS:"teepods/available",TEEPOD_IMAGES:r=>`teepods/${r}/images`,CVMS:r=>`cvms?user_id=${r}`,CVM_BY_APP_ID:r=>`cvms/app_${r}`,CVM_NETWORK:r=>`cvms/app_${r}/network`,CVM_START:r=>`cvms/app_${r}/start`,CVM_STOP:r=>`cvms/app_${r}/stop`,CVM_RESTART:r=>`cvms/app_${r}/restart`,CVM_LOGS:r=>`cvms/app_${r}/logs`,CVM_FROM_CONFIGURATION:"cvms/from_cvm_configuration",CVM_PUBKEY:"cvms/pubkey/from_cvm_configuration",CVM_UPGRADE:r=>`cvms/app_${r}/compose`,CVM_ATTESTATION:r=>`cvms/app_${r}/attestation`,CVM_RESIZE:r=>`cvms/app_${r}/resources`,CVM_COMPOSE:r=>`cvms/${r}/compose`,REPLICATE_CVM:r=>`cvms/${r}/replicas`},ut=`version: '3.8'
|
2
2
|
services:
|
3
3
|
postgres:
|
4
4
|
image: ankane/pgvector:latest
|
@@ -43,7 +43,7 @@ networks:
|
|
43
43
|
driver: bridge
|
44
44
|
|
45
45
|
volumes:
|
46
|
-
postgres-data:`,
|
46
|
+
postgres-data:`,gt=`version: '3.8'
|
47
47
|
services:
|
48
48
|
app:
|
49
49
|
image: {{imageName}}
|
@@ -54,5 +54,5 @@ services:
|
|
54
54
|
{{#each envVars}} - {{{this}}}
|
55
55
|
{{/each}}
|
56
56
|
restart: always
|
57
|
-
`;function de(r){try{return JSON.stringify(r)}catch(t){return t instanceof Error&&t.message.includes("cyclic")?"[Cyclic Object]":String(r)}}async function vt(r){try{y.debug(`Fetching user info from ${v.USER_INFO}`);let o=await
|
58
|
-
//# sourceMappingURL=chunk-
|
57
|
+
`;function de(r){try{return JSON.stringify(r)}catch(t){return t instanceof Error&&t.message.includes("cyclic")?"[Cyclic Object]":String(r)}}async function vt(r){try{y.debug(`Fetching user info from ${v.USER_INFO}`);let o=await ze({apiKey:r}).get(v.USER_INFO);y.debug(`Received response: ${de(o)}`);try{return ae.parse(o)}catch(n){throw y.error(`Failed to parse user info response: ${n}`),y.debug(`Response structure: ${de(o)}`),n}}catch(t){throw y.error(`Failed to get user info: ${t instanceof Error?t.message:String(t)}`),new Error(`Failed to get user info: ${t instanceof Error?t.message:String(t)}`)}}import{createClient as T}from"@phala/cloud";import We from"inquirer";import{z as ye}from"zod";import A from"node:fs";import X from"node:path";import z from"node:os";import G from"node:crypto";var K=X.join(z.homedir(),".phala-cloud"),U=X.join(K,"api-key"),q=X.join(K,"docker-credentials.json");function fe(){if(!A.existsSync(K))try{A.mkdirSync(K,{recursive:!0})}catch(r){throw y.error(`Failed to create directory ${K}:`,r),r}}function he(){let r=[z.hostname(),z.platform(),z.arch(),z.cpus()[0]?.model||"",z.userInfo().username],t=G.createHash("sha256");return t.update(r.join("|")),t.digest()}function Fe(r){try{let t=he(),o=G.randomBytes(16),n=G.createCipheriv("aes-256-cbc",t.slice(0,32),o),s=n.update(r,"utf8","hex");return s+=n.final("hex"),o.toString("hex")+":"+s}catch(t){throw y.error("Encryption failed:",t),new Error("Failed to encrypt data")}}function je(r){try{let t=he(),o=r.split(":");if(o.length!==2)throw new Error("Invalid encrypted format");let n=Buffer.from(o[0],"hex"),s=o[1],a=G.createDecipheriv("aes-256-cbc",t.slice(0,32),n),l=a.update(s,"hex","utf8");return l+=a.final("utf8"),l}catch(t){throw y.error("Decryption failed:",t),new Error("Failed to decrypt data")}}async function Rt(r){fe();try{let t=Fe(r);A.writeFileSync(U,t,{mode:384})}catch(t){throw y.error("Failed to save API key:",t),t}}function C(){try{if(process.env.PHALA_CLOUD_API_KEY)return process.env.PHALA_CLOUD_API_KEY;if(A.existsSync(U)){let r=A.readFileSync(U,"utf8").trim();return je(r)}return null}catch(r){return y.error("Failed to read API key:",r),null}}async function Et(){try{A.existsSync(U)?(A.unlinkSync(U),y.success("API key removed successfully.")):y.warn("No API key found to remove.")}catch(r){throw y.error("Failed to remove API key:",r),r}}async function Pt(r){fe();try{A.writeFileSync(q,JSON.stringify(r,null,2),{mode:384}),y.success("Docker information saved successfully.")}catch(t){throw y.error("Failed to save Docker information:",t),t}}async function At(){try{if(A.existsSync(q)){let r=A.readFileSync(q,"utf8");return JSON.parse(r)}return null}catch(r){return y.error("Failed to read Docker credentials:",r),null}}async function be(){try{let r=C(),o=await T({apiKey:r}).get(v.CVMS(0));return ye.array(Y).parse(o)}catch(r){throw new Error(`Failed to get CVMs: ${r instanceof Error?r.message:String(r)}`)}}async function jt(r){let o=(await be()).find(n=>n.hosted?.app_id===r||`app_${n.hosted?.app_id}`===r);if(!o)y.error(`CVM with App ID app_${r} not detected`),process.exit(1);else return y.success(`CVM with App ID app_${r} detected`),o.hosted?.app_id||""}async function Wt(r){try{let t=C(),n=await T({apiKey:t}).get(v.CVM_BY_APP_ID(r));return ie.parse(n)}catch(t){throw new Error(`Failed to get CVM by App ID: ${t instanceof Error?t.message:String(t)}`)}}async function Kt(r){try{let t=C(),n=await T({apiKey:t}).post(v.CVM_PUBKEY,r);return se.parse(n)}catch(t){throw new Error(`Failed to get pubkey from CVM: ${t instanceof Error?t.message:String(t)}`)}}async function Ut(r){try{let t=C(),n=await T({apiKey:t}).get(v.CVM_NETWORK(r));return pe.parse(n)}catch(t){throw new Error(`Failed to get network information for CVM: ${t instanceof Error?t.message:String(t)}`)}}async function Bt(r){try{let t=C(),n=await T({apiKey:t}).post(v.CVM_FROM_CONFIGURATION,r);return W.parse(n)}catch(t){throw t instanceof ye.ZodError?(y.error("Schema validation error:",JSON.stringify(t.errors,null,2)),y.error("API response:",JSON.stringify(t.format(),null,2)),new Error(`Response validation failed: ${JSON.stringify(t.errors)}`)):new Error(`Failed to create CVM: ${t instanceof Error?t.message:String(t)}`)}}async function Gt(r){try{let t=C(),n=await T({apiKey:t}).post(v.CVM_START(r));return W.parse(n)}catch(t){throw new Error(`Failed to start CVM: ${t instanceof Error?t.message:String(t)}`)}}async function Zt(r){try{let t=C(),n=await T({apiKey:t}).post(v.CVM_STOP(r));return W.parse(n)}catch(t){throw new Error(`Failed to stop CVM: ${t instanceof Error?t.message:String(t)}`)}}async function Ht(r){try{let t=C(),n=await T({apiKey:t}).post(v.CVM_RESTART(r));return W.parse(n)}catch(t){throw new Error(`Failed to restart CVM: ${t instanceof Error?t.message:String(t)}`)}}async function Yt(r,t){let o=C(),s=await T({apiKey:o}).put(v.CVM_UPGRADE(r),t);return le.parse(s)}async function Jt(r){try{let t=C();return await T({apiKey:t}).delete(v.CVM_BY_APP_ID(r)),!0}catch(t){throw new Error(`Failed to delete CVM: ${t instanceof Error?t.message:String(t)}`)}}async function qt(r){try{let t=C();return await T({apiKey:t}).put(v.CVM_BY_APP_ID(r.app_id),r)}catch(t){throw new Error(`Failed to update CVM: ${t instanceof Error?t.message:String(t)}`)}}async function Xt(){let r=y.startSpinner("Fetching available CVMs"),t=await be();if(r.stop(!0),!t||t.length===0){y.info("No CVMs found for your account");return}let o=t.map(s=>{let a=s.hosted?.app_id||s.hosted?.id,l=s.name||s.hosted?.name,b=s.status||s.hosted?.status;return{name:`${l||"Unnamed"} (${a}) - Status: ${b||"Unknown"}`,value:a}}),{selectedCvm:n}=await We.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:o}]);return n}async function Qt(r){try{let t=C(),n=await T({apiKey:t}).get(v.CVM_ATTESTATION(r));try{return ge.parse(n)}catch(s){return y.debug(`Validation error: ${s instanceof Error?s.message:String(s)}`),{is_online:!!n?.is_online,is_public:!!n?.is_public,error:typeof n?.error=="string"?n.error:null,app_certificates:Array.isArray(n?.app_certificates)?n.app_certificates:null,tcb_info:n?.tcb_info||null,compose_file:typeof n?.compose_file=="string"?n.compose_file:null}}}catch(t){throw new Error(`Failed to get attestation information: ${t instanceof Error?t.message:String(t)}`)}}async function er(r){try{let t=C(),n=await T({apiKey:t}).get(v.CVM_COMPOSE(r));return me.parse(n)}catch(t){throw new Error(`Failed to get CVM compose config: ${t instanceof Error?t.message:String(t)}`)}}async function tr(r,t){try{let o=C(),s=await T({apiKey:o}).post(v.REPLICATE_CVM(r),t);return ue.parse(s)}catch(o){throw new Error(`Failed to replicate CVM: ${o instanceof Error?o.message:String(o)}`)}}async function rr(r,t,o,n,s){try{let a=C(),l=T({apiKey:a}),b={};if(t!==void 0&&(b.vcpu=t),o!==void 0&&(b.memory=o),n!==void 0&&(b.disk_size=n),s!==void 0&&(b.allow_restart=s),Object.keys(b).length===0)throw new Error("At least one resource parameter must be provided");return await l.patch(v.CVM_RESIZE(r),b),!0}catch(a){throw new Error(`Failed to resize CVM: ${a instanceof Error?a.message:String(a)}`)}}import{createClient as _e}from"@phala/cloud";import{z as Ke}from"zod";async function Ue(){try{let r=C(),o=await(await _e({apiKey:r})).get(v.TEEPODS);return ce.parse(o)}catch(r){throw new Error(`Failed to get TEEPods: ${r instanceof Error?r.message:String(r)}`)}}async function gr(r){try{let t=C(),o=_e({apiKey:t}),s=(await Ue()).nodes.find(l=>l.teepod_id===Number(r));if(s&&s.images&&s.images.length>0)return s.images;let a=await(await o).get(v.TEEPOD_IMAGES(r));return Ke.array(J).parse(a)}catch(t){throw new Error(`Failed to get TEEPod images: ${t instanceof Error?t.message:String(t)}`)}}export{y as a,Rt as b,C as c,Et as d,Pt as e,At as f,at as g,lt as h,ct as i,pt as j,mt as k,ut as l,gt as m,Qe as n,Ae as o,Ie as p,$e as q,Me as r,De as s,Le as t,Y as u,W as v,se as w,ie as x,ae as y,ot as z,le as A,st as B,J as C,Oe as D,Ve as E,Ne as F,ce as G,pe as H,me as I,ue as J,ge as K,vt as L,be as M,jt as N,Wt as O,Kt as P,Ut as Q,Bt as R,Gt as S,Zt as T,Ht as U,Yt as V,Jt as W,qt as X,Xt as Y,Qt as Z,er as _,tr as $,rr as aa,Ue as ba,gr as ca};
|
58
|
+
//# sourceMappingURL=chunk-2X5HREGL.js.map
|