phala 1.0.20 → 1.0.22

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/README.md CHANGED
@@ -63,7 +63,7 @@ ___
63
63
 
64
64
  To deploy applications to Phala Cloud, you'll need an API key:
65
65
 
66
- - Visit [Phala Cloud](https://cloud.phala.network/login) to log into your Phala Cloud account. If you do not have an account, registe [here](https://cloud.phala.network/register?invite=beta) or run `npx phala free` in the terminal.
66
+ - Visit [Phala Cloud](https://cloud.phala.network/login) to log into your Phala Cloud account. If you do not have an account, registe [here](https://cloud.phala.network/register?invite=beta).
67
67
  - After logging in, navigate to the "API Keys" section in your profile
68
68
  - Create a new API key with an appropriate name (e.g., "CLI Access")
69
69
  - Copy the generated API key - you'll need it for authentication
@@ -243,18 +243,21 @@ phala auth logout
243
243
  #### Status
244
244
 
245
245
  ```bash
246
- phala auth status [options]
246
+ phala status [options]
247
247
  ```
248
248
 
249
- Check your authentication status with Phala Cloud. Displays user information in a table format.
249
+ Check your authentication status with Phala Cloud. Displays user information including API endpoint, username, and current workspace.
250
+
251
+ > **Note**: `phala auth status` is still available for backward compatibility, but it's recommended to use `phala status` instead.
250
252
 
251
253
  **Options:**
252
254
  - `-j, --json`: Output in JSON format
255
+ - `-d, --debug`: Enable debug output
253
256
 
254
257
  **Example:**
255
258
  ```bash
256
- phala auth status
257
- phala auth status --json
259
+ phala status
260
+ phala status --json
258
261
  ```
259
262
 
260
263
  ### Docker Management Commands
@@ -339,7 +342,15 @@ phala docker generate --image my-tee-app --tag v1.0.0 --env-file ./.env
339
342
 
340
343
  ### TEE Simulator Commands
341
344
 
342
- Commands for managing the local TEE simulator for development and testing.
345
+ Commands for managing the local TEE simulator for development and testing. When run without subcommands, shows the current status of the simulator.
346
+
347
+ #### Check Status
348
+
349
+ ```bash
350
+ phala simulator
351
+ ```
352
+
353
+ Shows the current status of the TEE simulator, including the process ID and endpoint information if running.
343
354
 
344
355
  #### Start Simulator
345
356
 
@@ -352,10 +363,16 @@ Start the TEE simulator locally for development and testing.
352
363
  **Options:**
353
364
 
354
365
  - `-p, --port <port>`: Port to bind the simulator to (default: 8000)
366
+ - `-v, --verbose`: Enable verbose output
367
+
368
+ **Examples:**
355
369
 
356
- **Example:**
357
370
  ```bash
371
+ # Start with default options
358
372
  phala simulator start
373
+
374
+ # Start with verbose output
375
+ phala simulator start --verbose
359
376
  ```
360
377
 
361
378
  #### Stop Simulator
@@ -367,10 +384,22 @@ phala simulator stop
367
384
  Stop the running TEE simulator.
368
385
 
369
386
  **Example:**
387
+
370
388
  ```bash
371
389
  phala simulator stop
372
390
  ```
373
391
 
392
+ #### Environment Variables
393
+
394
+ When the simulator is running, you'll need to set these environment variables to use it:
395
+
396
+ ```bash
397
+ export DSTACK_SIMULATOR_ENDPOINT=/path/to/dstack.sock
398
+ export TAPPD_SIMULATOR_ENDPOINT=/path/to/tappd.sock
399
+ ```
400
+
401
+ These variables will be automatically displayed when you run `phala simulator` while the simulator is running.
402
+
374
403
  ### Cloud Virtual Machine (CVM) Commands
375
404
 
376
405
  Commands for managing Cloud Virtual Machines (CVMs) on Phala Cloud.
@@ -1,5 +1,4 @@
1
1
  import { ZodType, ParseInput, ParseReturnType, RawCreateParams, ZodTypeDef, z } from 'zod';
2
- import { AxiosRequestConfig } from 'axios';
3
2
 
4
3
  type ZodDecimalCheck = {
5
4
  kind: 'precision';
@@ -2187,11 +2186,11 @@ declare const postCvmResponseSchema: z.ZodObject<{
2187
2186
  created_at: z.ZodString;
2188
2187
  encrypted_env_pubkey: z.ZodString;
2189
2188
  }, "strip", z.ZodTypeAny, {
2189
+ status?: string;
2190
2190
  teepod?: {
2191
2191
  name?: string;
2192
2192
  id?: number;
2193
2193
  };
2194
- status?: string;
2195
2194
  docker_compose_file?: string;
2196
2195
  features?: string[];
2197
2196
  manifest_version?: number;
@@ -2212,11 +2211,11 @@ declare const postCvmResponseSchema: z.ZodObject<{
2212
2211
  created_at?: string;
2213
2212
  encrypted_env_pubkey?: string;
2214
2213
  }, {
2214
+ status?: string;
2215
2215
  teepod?: {
2216
2216
  name?: string;
2217
2217
  id?: number;
2218
2218
  };
2219
- status?: string;
2220
2219
  docker_compose_file?: string;
2221
2220
  features?: string[];
2222
2221
  manifest_version?: number;
@@ -2275,11 +2274,11 @@ declare const getCvmByAppIdResponseSchema: z.ZodObject<{
2275
2274
  project_id: z.ZodString;
2276
2275
  project_type: z.ZodNullable<z.ZodString>;
2277
2276
  }, "strip", z.ZodTypeAny, {
2277
+ status?: string;
2278
2278
  teepod?: {
2279
2279
  name?: string;
2280
2280
  id?: number;
2281
2281
  };
2282
- status?: string;
2283
2282
  name?: string;
2284
2283
  vcpu?: number;
2285
2284
  memory?: number;
@@ -2296,11 +2295,11 @@ declare const getCvmByAppIdResponseSchema: z.ZodObject<{
2296
2295
  project_id?: string;
2297
2296
  project_type?: string;
2298
2297
  }, {
2298
+ status?: string;
2299
2299
  teepod?: {
2300
2300
  name?: string;
2301
2301
  id?: number;
2302
2302
  };
2303
- status?: string;
2304
2303
  name?: string;
2305
2304
  vcpu?: number;
2306
2305
  memory?: number;
@@ -3500,18 +3499,18 @@ declare const kmsListItemSchema: z.ZodObject<{
3500
3499
  kms_contract_address: z.ZodString;
3501
3500
  gateway_app_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3502
3501
  }, "strip", z.ZodTypeAny, {
3503
- url?: string;
3504
3502
  version?: string;
3505
3503
  id?: string;
3506
3504
  slug?: string;
3505
+ url?: string;
3507
3506
  chain_id?: number;
3508
3507
  kms_contract_address?: string;
3509
3508
  gateway_app_id?: string;
3510
3509
  }, {
3511
- url?: string;
3512
3510
  version?: string;
3513
3511
  id?: string;
3514
3512
  slug?: string;
3513
+ url?: string;
3515
3514
  chain_id?: number;
3516
3515
  kms_contract_address?: string;
3517
3516
  gateway_app_id?: string;
@@ -3659,18 +3658,18 @@ declare const teepodResponseSchema: z.ZodObject<{
3659
3658
  kms_contract_address: z.ZodString;
3660
3659
  gateway_app_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3661
3660
  }, "strip", z.ZodTypeAny, {
3662
- url?: string;
3663
3661
  version?: string;
3664
3662
  id?: string;
3665
3663
  slug?: string;
3664
+ url?: string;
3666
3665
  chain_id?: number;
3667
3666
  kms_contract_address?: string;
3668
3667
  gateway_app_id?: string;
3669
3668
  }, {
3670
- url?: string;
3671
3669
  version?: string;
3672
3670
  id?: string;
3673
3671
  slug?: string;
3672
+ url?: string;
3674
3673
  chain_id?: number;
3675
3674
  kms_contract_address?: string;
3676
3675
  gateway_app_id?: string;
@@ -3714,10 +3713,10 @@ declare const teepodResponseSchema: z.ZodObject<{
3714
3713
  max_disk?: number;
3715
3714
  };
3716
3715
  kms_list?: {
3717
- url?: string;
3718
3716
  version?: string;
3719
3717
  id?: string;
3720
3718
  slug?: string;
3719
+ url?: string;
3721
3720
  chain_id?: number;
3722
3721
  kms_contract_address?: string;
3723
3722
  gateway_app_id?: string;
@@ -3761,10 +3760,10 @@ declare const teepodResponseSchema: z.ZodObject<{
3761
3760
  max_disk?: number;
3762
3761
  };
3763
3762
  kms_list?: {
3764
- url?: string;
3765
3763
  version?: string;
3766
3764
  id?: string;
3767
3765
  slug?: string;
3766
+ url?: string;
3768
3767
  chain_id?: number;
3769
3768
  kms_contract_address?: string;
3770
3769
  gateway_app_id?: string;
@@ -4026,11 +4025,11 @@ declare const replicateCvmResponseSchema: z.ZodObject<{
4026
4025
  created_at: z.ZodString;
4027
4026
  encrypted_env_pubkey: z.ZodString;
4028
4027
  }, "strip", z.ZodTypeAny, {
4028
+ status?: string;
4029
4029
  teepod?: {
4030
4030
  name?: string;
4031
4031
  id?: number;
4032
4032
  };
4033
- status?: string;
4034
4033
  docker_compose_file?: string;
4035
4034
  features?: string[];
4036
4035
  manifest_version?: number;
@@ -4051,11 +4050,11 @@ declare const replicateCvmResponseSchema: z.ZodObject<{
4051
4050
  created_at?: string;
4052
4051
  encrypted_env_pubkey?: string;
4053
4052
  }, {
4053
+ status?: string;
4054
4054
  teepod?: {
4055
4055
  name?: string;
4056
4056
  id?: number;
4057
4057
  };
4058
- status?: string;
4059
4058
  docker_compose_file?: string;
4060
4059
  features?: string[];
4061
4060
  manifest_version?: number;
@@ -4323,18 +4322,6 @@ declare const cvmAttestationResponseSchema: z.ZodObject<{
4323
4322
  */
4324
4323
  declare function getUserInfo(): Promise<GetUserInfoResponse>;
4325
4324
 
4326
- declare class ApiClient {
4327
- private client;
4328
- private apiKey;
4329
- constructor(baseURL: string);
4330
- get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
4331
- post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
4332
- put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
4333
- delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
4334
- patch<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
4335
- }
4336
- declare const apiClient: ApiClient;
4337
-
4338
4325
  /**
4339
4326
  * Get all CVMs for the current user
4340
4327
  * @returns List of CVMs
@@ -4483,4 +4470,4 @@ declare function getTeepods(): Promise<TeepodResponse>;
4483
4470
  */
4484
4471
  declare function getTeepodImages(teepodId: string): Promise<Image[]>;
4485
4472
 
4486
- export { ApiClient, Capacity, CertificateInfo, CertificateNameInfo, ComposeFile, Configuration, CvmAttestationResponse, CvmComposeConfig, CvmInstance, DockerConfig, EncryptedEnvItem, GetCvmByAppIdResponse, GetCvmNetworkResponse, GetCvmsByUserIdResponse, GetPubkeyFromCvmResponse, GetUserInfoResponse, Hosted, Image, KmsListItem, ManagedUser, Node, PostCvmResponse, ReplicateCvmResponse, ResizeCvmPayload, TCBEventLogEntry, TCBInfo, TEEPod, TeepodResponse, UpdateCvmPayload, UpgradeCvmResponse, VMConfig, apiClient, capacitySchema, checkCvmExists, composeFileSchema, configurationSchema, createCvm, cvmAttestationResponseSchema, cvmComposeConfigSchema, cvmInstanceSchema, deleteCvm, dockerConfigSchema, encryptedEnvItemSchema, getCvmAttestation, getCvmByAppId, getCvmByAppIdResponseSchema, getCvmComposeConfig, getCvmNetwork, getCvmNetworkResponseSchema, getCvms, getCvmsByUserIdResponseSchema, getPubkeyFromCvm, getPubkeyFromCvmResponseSchema, getTeepodImages, getTeepods, getUserInfo, getUserInfoResponseSchema, hostedSchema, imageSchema, kmsListItemSchema, managedUserSchema, nodeSchema, postCvmResponseSchema, replicateCvm, replicateCvmResponseSchema, resizeCvm, restartCvm, selectCvm, startCvm, stopCvm, teepodResponseSchema, teepodSchema, updateCvm, upgradeCvm, upgradeCvmResponseSchema };
4473
+ export { Capacity, CertificateInfo, CertificateNameInfo, ComposeFile, Configuration, CvmAttestationResponse, CvmComposeConfig, CvmInstance, DockerConfig, EncryptedEnvItem, GetCvmByAppIdResponse, GetCvmNetworkResponse, GetCvmsByUserIdResponse, GetPubkeyFromCvmResponse, GetUserInfoResponse, Hosted, Image, KmsListItem, ManagedUser, Node, PostCvmResponse, ReplicateCvmResponse, ResizeCvmPayload, TCBEventLogEntry, TCBInfo, TEEPod, TeepodResponse, UpdateCvmPayload, UpgradeCvmResponse, VMConfig, capacitySchema, checkCvmExists, composeFileSchema, configurationSchema, createCvm, cvmAttestationResponseSchema, cvmComposeConfigSchema, cvmInstanceSchema, deleteCvm, dockerConfigSchema, encryptedEnvItemSchema, getCvmAttestation, getCvmByAppId, getCvmByAppIdResponseSchema, getCvmComposeConfig, getCvmNetwork, getCvmNetworkResponseSchema, getCvms, getCvmsByUserIdResponseSchema, getPubkeyFromCvm, getPubkeyFromCvmResponseSchema, getTeepodImages, getTeepods, getUserInfo, getUserInfoResponseSchema, hostedSchema, imageSchema, kmsListItemSchema, managedUserSchema, nodeSchema, postCvmResponseSchema, replicateCvm, replicateCvmResponseSchema, resizeCvm, restartCvm, selectCvm, startCvm, stopCvm, teepodResponseSchema, teepodSchema, updateCvm, upgradeCvm, upgradeCvmResponseSchema };
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,da as R,ea as S,n as o,o 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-X3GHW5ET.js";export{o as ApiClient,r as apiClient,n as capacitySchema,B as checkCvmExists,f as composeFileSchema,m as configurationSchema,F as createCvm,y as cvmAttestationResponseSchema,v as cvmComposeConfigSchema,a as cvmInstanceSchema,K as deleteCvm,e as dockerConfigSchema,j as encryptedEnvItemSchema,N as getCvmAttestation,C as getCvmByAppId,d as getCvmByAppIdResponseSchema,O as getCvmComposeConfig,E as getCvmNetwork,u as getCvmNetworkResponseSchema,A as getCvms,h as getCvmsByUserIdResponseSchema,D as getPubkeyFromCvm,c as getPubkeyFromCvmResponseSchema,S as getTeepodImages,R as getTeepods,z as getUserInfo,g as getUserInfoResponseSchema,p as hostedSchema,k as imageSchema,q as kmsListItemSchema,t as managedUserSchema,x as nodeSchema,b as postCvmResponseSchema,P as replicateCvm,w as replicateCvmResponseSchema,Q as resizeCvm,I as restartCvm,M as selectCvm,G as startCvm,H as stopCvm,s as teepodResponseSchema,l as teepodSchema,L as updateCvm,J as upgradeCvm,i as upgradeCvmResponseSchema};
1
+ import{A as l,B as n,C as q,D as s,E as u,F as v,G as w,H as y,I as z,J as A,K as B,L as C,M as D,N as E,O as F,P as G,Q as H,R as I,S as J,T as K,U as L,V as M,W as N,X as O,Y as P,Z as Q,j as o,k as r,l as e,m as f,n as m,o as p,p as t,q as x,r as a,s as b,t as c,u as d,v as g,w as h,x as i,y as j,z as k}from"../chunk-YV2WYCLU.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
@@ -0,0 +1,58 @@
1
+ var ge=Object.defineProperty;var ue=(r,t,n)=>t in r?ge(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n;var Z=(r,t,n)=>(ue(r,typeof t!="symbol"?t+"":t,n),n);import b from"chalk";function de(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 M(r){return de(r).length}function z(r,t){if(!r)return[""];if(M(r)<=t)return[r];let n=[],o="",m=0,a=r.split(/(\s+)/).filter(i=>i.trim().length>0);for(let i of a){let _=M(i);if(_>t){o&&(n.push(o),o="",m=0),n.push(i);continue}m+_+(m>0?1:0)>t?(n.push(o),o=i,m=_):o?(o=`${o} ${i}`,m+=_+1):(o=i,m=_)}return o&&n.push(o),n}var x={error:(r,...t)=>{console.error(b.red("\u2717"),b.red(r),...t)},warn:(r,...t)=>{console.log(b.yellow("\u26A0"),b.yellow(r),...t)},info:(r,...t)=>{console.log(b.blue("\u2139"),b.blue(r),...t)},success:(r,...t)=>{console.log(b.green("\u2713"),b.green(r),...t)},debug:(r,...t)=>{process.env.DEBUG&&console.log(b.gray("\u{1F50D}"),b.gray(r),...t)},table:(r,t)=>{if(r.length===0){console.log(b.yellow("No data to display"));return}if(t)if(typeof t[0]=="string"){let n=t.map(o=>({key:o,header:o.charAt(0).toUpperCase()+o.slice(1)}));U(r,{columns:n,borderStyle:"rounded",headerStyle:o=>b.cyan.bold(o)})}else U(r,{columns:t,borderStyle:"rounded",headerStyle:n=>b.cyan.bold(n)});else U(r,{borderStyle:"rounded",headerStyle:n=>b.cyan.bold(n)})},keyValueTable:(r,t)=>{let o={...{borderStyle:"rounded",enableTextWrapping:!0,maxDepth:2,formatKeys:!0,keyFormatter:h=>{let v=["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"],k={teepod:"TEEPod",dstack:"Dstack"},w;h.includes("_")?w=h.split("_").map(T=>T.charAt(0).toUpperCase()+T.slice(1).toLowerCase()).join(" "):h.includes("-")?w=h.split("-").map(T=>T.charAt(0).toUpperCase()+T.slice(1).toLowerCase()).join(" "):w=h.charAt(0).toUpperCase()+h.slice(1).replace(/([a-z])([A-Z])/g,"$1 $2");for(let T of v){let $=new RegExp(`\\b${T.toLowerCase()}\\b`,"gi");w=w.replace($,T)}for(let[T,$]of Object.entries(k)){let D=new RegExp(`\\b${T}\\b`,"gi");w=w.replace(D,$)}return w},valueFormatter:h=>String(h??"")},...t},{include:m,exclude:a,keyFormatter:i,valueFormatter:_,formatKeys:R,keyWidth:C,valueWidth:E,borderStyle:A,enableTextWrapping:c,maxDepth:p}=o,l=Object.keys(r);if(m&&(l=l.filter(h=>m.includes(h))),a&&(l=l.filter(h=>!a.includes(h))),l.length===0){console.log(b.yellow("No properties to display"));return}let g=l.map(h=>{let v=r[h],k;return v==null?k="":typeof v=="object"&&!Array.isArray(v)?k=H(v,0,p):Array.isArray(v)?v.length===0?k="[]":typeof v[0]=="object"?k=`[${v.length} items]`:k=`[${v.join(", ")}]`:k=String(v),_&&(k=_(v,h)),{key:R&&i?b.cyan.bold(i(h)):b.cyan.bold(h),value:k}}),f=K(),s=C,u=E;if(s||(s=Math.max(...g.map(h=>M(h.key)),10),s=Math.min(s,Math.floor(f/3))),!u){u=Math.max(...g.map(k=>M(k.value)),10),u+=3;let h=7,v=f-s-h;u=Math.min(u,v)}let d=fe(A),I=`${d.topLeft}${d.horizontal.repeat(s+2)}${d.topT}${d.horizontal.repeat(u+2)}${d.topRight}`,P=`${d.leftT}${d.horizontal.repeat(s+2)}${d.cross}${d.horizontal.repeat(u+2)}${d.rightT}`;console.log(I),console.log(P),g.forEach((h,v)=>{let k=c?z(h.key,s):[h.key],w=c?z(h.value,u):[h.value],T=Math.max(k.length,w.length);for(let $=0;$<T;$++){let D=k[$]||"",G=w[$]||"",pe=D+" ".repeat(Math.max(0,s-M(D))),me=G+" ".repeat(Math.max(0,u-M(G)));console.log(`${d.vertical} ${pe} ${d.vertical} ${me} ${d.vertical}`)}v<g.length-1&&console.log(`${d.leftT}${d.horizontal.repeat(s+2)}${d.cross}${d.horizontal.repeat(u+2)}${d.rightT}`)});let j=`${d.bottomLeft}${d.horizontal.repeat(s+2)}${d.bottomT}${d.horizontal.repeat(u+2)}${d.bottomRight}`;console.log(j)},startSpinner:r=>(process.stdout.write(`${b.blue("\u27F3")} ${r}... `),{stop:(t=!0,n)=>{let o=t?b.green("\u2713"):b.red("\u2717"),m=n?`: ${n}`:"";console.log(`${o}${m}`)}}),break(){console.log("")}};function H(r,t,n){if(t>=n)return"[Nested Object]";if(r==null)return"";if(Array.isArray(r))return r.length===0?"[]":`[${r.length} items]`;let o=[];for(let[m,a]of Object.entries(r))a==null?o.push(`${m}: `):typeof a=="object"?o.push(`${m}: ${H(a,t+1,n)}`):o.push(`${m}: ${a}`);return o.join(", ")}function fe(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 K(){return process.stdout.columns||80}function he(r,t,n={}){let o=K(),m=n.borderChars??3,i=(n.additionalBorderWidth??1)+t.length*m,_=o-i,R={},C=0,E=0;for(let p of t){let l=p.key;if(p.fixedWidth!==void 0){R[l]=p.fixedWidth,C+=p.fixedWidth;continue}let g=p.minWidth??p.header.length,f;p.getWidth?f=Math.max(g,p.header.length,...r.map(s=>p.getWidth(s))):p.getValue?f=Math.max(g,p.header.length,...r.map(s=>String(p.getValue(s)||"").length)):f=Math.max(g,p.header.length,...r.map(s=>String(s[p.key]||"").length)),R[l]=f,C+=f,E+=p.weight??1}let A=Math.max(0,_-C);if(A>0&&E>0)for(let p of t){let l=p.key;if(p.fixedWidth===void 0&&p.weight){let g=Math.floor(A*(p.weight/E));R[l]+=g}}let c=Object.values(R).reduce((p,l)=>p+l,0)+i;if(c>o){let p=_/(c-i),l={};for(let g of t){let f=g.key,s=g.minWidth??g.header.length;l[f]=Math.max(s,Math.floor(R[f]*p))}return l}return R}function U(r,t={}){if(t.keyValueMode&&r.length===1){let c=r[0],p=[];t.columns||(t.columns=Object.keys(c).map(l=>({key:l,header:l.charAt(0).toUpperCase()+l.slice(1).replace(/([A-Z])/g," $1")})));for(let l of t.columns){let g=String(l.key),f;if(l.accessor)f=l.accessor(c);else if(typeof l.key=="string"&&l.key.includes(".")){let s=l.key.split("."),u=c;for(let d of s){if(u==null){f="";break}u=u[d]}f=u}else f=c[l.key];l.formatter&&(f=l.formatter(f)),p.push({key:l.header||g,value:f})}r=p,t.columns=[{key:"key",minWidth:15},{key:"value",minWidth:20}]}if(r.length===0){console.log(b.yellow("No data to display"));return}let o={...{includeHeaders:!0,border:!0,borderStyle:"single",headerStyle:c=>b.bold(c),cellStyle:c=>c,enableTextWrapping:!0},...t},m=o.columns;if(m)m=m.map(c=>({...c,enableTextWrapping:c.enableTextWrapping!==void 0?c.enableTextWrapping:o.enableTextWrapping}));else{let c=r[0];m=Object.keys(c).map(p=>({key:p,header:p.charAt(0).toUpperCase()+p.slice(1),enableTextWrapping:o.enableTextWrapping}))}let i={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"}}[o.borderStyle],_=m.map(c=>({key:c.key,header:c.header||String(c.key),minWidth:c.minWidth||3,weight:c.weight,enableTextWrapping:c.enableTextWrapping,getValue:c.accessor?p=>c.accessor(p):p=>{if(typeof c.key=="string"&&c.key.includes(".")){let l=c.key.split("."),g=p;for(let f of l){if(g==null)return"";g=g[f]}return g??""}return p[c.key]??""}})),R=he(r,_),C=m.map((c,p)=>({...c,width:R[_[p].key]})),E=C.map(c=>c.header||String(c.key)),A=(c,p)=>{let l=C.map(s=>{let u;if(s.accessor)u=s.accessor(c);else if(typeof s.key=="string"&&s.key.includes(".")){let I=s.key.split("."),P=c;for(let j of I){if(P==null){u="";break}P=P[j]}u=P??""}else u=c[s.key]??"";let d=s.formatter?s.formatter(u):String(u||"");return s.enableTextWrapping?{lines:z(d,s.width),key:String(s.key)}:{lines:[d.length>s.width?d.substring(0,s.width-1)+"\u2026":d],key:String(s.key)}}),g=Math.max(...l.map(s=>s.lines.length)),f=[];for(let s=0;s<g;s++){let u=l.map((d,I)=>{let P=d.lines[s]||"";return o.cellStyle(P.padEnd(C[I].width),p,d.key)});f.push(u)}return f};if(o.border){let c=i.topLeft+C.map(l=>i.horizontal.repeat(l.width+2)).join(i.topT)+i.topRight;if(console.log(c),o.includeHeaders){let l=C.map((s,u)=>({lines:s.enableTextWrapping?z(E[u],s.width):[E[u]],width:s.width})),g=Math.max(...l.map(s=>s.lines.length));for(let s=0;s<g;s++){let u=i.vertical+l.map(d=>{let I=d.lines[s]||"";return" "+o.headerStyle(I.padEnd(d.width))+" "}).join(i.vertical)+i.vertical;console.log(u)}let f=i.leftT+C.map(s=>i.horizontal.repeat(s.width+2)).join(i.cross)+i.rightT;console.log(f)}r.forEach((l,g)=>{let f=A(l,g);if(f.forEach(s=>{console.log(i.vertical+s.map(u=>` ${u} `).join(i.vertical)+i.vertical)}),g<r.length-1&&f.length>1){let s=i.leftT+C.map(u=>i.horizontal.repeat(u.width+2)).join(i.cross)+i.rightT;console.log(s)}});let p=i.bottomLeft+C.map(l=>i.horizontal.repeat(l.width+2)).join(i.bottomT)+i.bottomRight;console.log(p)}else{if(o.includeHeaders){let c=C.map((g,f)=>({lines:g.enableTextWrapping?z(E[f],g.width):[E[f]],width:g.width})),p=Math.max(...c.map(g=>g.lines.length));for(let g=0;g<p;g++){let f=c.map(s=>{let u=s.lines[g]||"";return o.headerStyle(u.padEnd(s.width))}).join(" ");console.log(f)}let l=C.map(g=>"\u2500".repeat(g.width)).join(" ");console.log(l)}r.forEach((c,p)=>{let l=A(c,p);l.forEach(g=>{console.log(g.join(" "))}),p<r.length-1&&l.length>1&&console.log("")})}console.log(`Total: ${r.length} rows`)}import{z as e}from"zod";import{INVALID as be,ParseStatus as ye,ZodIssueCode as V,ZodParsedType as Y,ZodType as _e,addIssueToContext as O,z as q}from"zod";var ve="ZodDecimal",Ce=/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/,N=class extends _e{_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)!==Y.number){let a=this._getOrReturnCtx(t);return O(a,{code:V.invalid_type,expected:Y.number,received:a.parsedType}),be}let o,m=new ye;for(let a of this._def.checks)if(a.kind==="precision"){let i=t.data.toString().match(Ce);Math.max((i[1]?i[1].length:0)-(i[2]?parseInt(i[2],10):0),0)>a.value&&(o=this._getOrReturnCtx(t,o),O(o,{code:V.custom,message:a.message,params:{precision:a.value}}),m.dirty())}else a.kind==="wholeNumber"?t.data.toString().split(".")[0].length>a.value&&(o=this._getOrReturnCtx(t,o),O(o,{code:V.custom,message:a.message,params:{wholeNumber:a.value}}),m.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(o=this._getOrReturnCtx(t,o),O(o,{code:V.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),m.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(o=this._getOrReturnCtx(t,o),O(o,{code:V.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),m.dirty()):a.kind==="finite"&&(Number.isFinite(t.data)||(o=this._getOrReturnCtx(t,o),O(o,{code:V.not_finite,message:a.message}),m.dirty()));return{status:m.value,value:t.data}}setLimit(t,n,o,m){return new N({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:m}]})}_addCheck(t){return new N({...this._def,checks:[...this._def.checks,t]})}lte(t,n){return this.setLimit("max",t,!0,n)}lt(t,n){return this.setLimit("max",t,!1,n)}max=this.lte;gt(t,n){return this.setLimit("min",t,!1,n)}gte(t,n){return this.setLimit("min",t,!0,n)}min=this.gte;precision(t,n){return this._addCheck({kind:"precision",value:t,message:n})}wholeNumber(t,n){return this._addCheck({kind:"wholeNumber",value:t,message:n})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.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,n=null;for(let o of this._def.checks){if(o.kind==="finite")return!0;o.kind==="min"?(n===null||o.value>n)&&(n=o.value):o.kind==="max"&&(t===null||o.value<t)&&(t=o.value)}return Number.isFinite(n)&&Number.isFinite(t)}},L=N;Z(L,"create",t=>new N({checks:[],typeName:ve,coerce:t?.coerce??!1}));var Be=q.object({template:q.string().min(1,"Template cannot be empty")});var ke=e.object({password:e.string(),registry:e.string().nullable(),username:e.string()}),Se=e.object({docker_compose_file:e.string(),docker_config:ke.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(),xe=e.object({name:e.string(),image:e.string(),compose_file:Se.nullable().optional(),vcpu:e.number(),memory:e.number(),disk_size:e.number(),ports:e.array(e.any())}).passthrough(),Te=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:xe.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(),we=e.object({id:e.number(),username:e.string()}),Re=e.object({id:e.number(),name:e.string(),region_identifier:e.string().optional()}),F=e.object({hosted:Te,name:e.string(),managed_user:we,node:Re,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()}),J=e.object({app_env_encrypt_pubkey:e.string(),app_id_salt:e.string()}),X=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()}),Q=e.object({username:e.string(),email:e.string(),credits:L.create({coerce:!0}),granted_credits:L.create({coerce:!0}),role:e.string(),avatar:e.string(),flag_reset_password:e.boolean(),team_name:e.string(),team_tier:e.string(),trial_ended_at:e.string().nullable()}),Ye=e.array(F),ee=e.object({detail:e.string()}),qe=e.object({key:e.string(),value:e.string()}),B=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()}),Ee=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(B).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()}),Pe=e.object({max_instances:e.number().nullable(),max_vcpu:e.number().nullable(),max_memory:e.number().nullable(),max_disk:e.number().nullable()}),$e=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()}),te=e.object({tier:e.string(),capacity:Pe,nodes:e.array(Ee),kms_list:e.array($e).optional()}),re=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()}))}),ne=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()}),oe=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()}),se=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 Ae}from"@phala/cloud";var Xe=process.env.CLOUD_URL||"https://cloud.phala.network";var Qe=1,et=2048,tt=40,rt="dstack-0.3.6",y={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`},nt=`version: '3.8'
2
+ services:
3
+ postgres:
4
+ image: ankane/pgvector:latest
5
+ environment:
6
+ - POSTGRES_PASSWORD=postgres
7
+ - POSTGRES_USER=postgres
8
+ - POSTGRES_DB=eliza
9
+ - PGDATA=/var/lib/postgresql/data/pgdata
10
+ volumes:
11
+ - postgres-data:/var/lib/postgresql/data:rw
12
+ ports:
13
+ - '127.0.0.1:5432:5432'
14
+ healthcheck:
15
+ test: ['CMD-SHELL', 'pg_isready -U $\${POSTGRES_USER} -d $\${POSTGRES_DB}']
16
+ interval: 5s
17
+ timeout: 5s
18
+ retries: 5
19
+ restart: always
20
+ networks:
21
+ - eliza-network
22
+ eliza:
23
+ image: {{imageName}}
24
+ command: bun run start
25
+ volumes:
26
+ - /var/run/tappd.sock:/var/run/tappd.sock
27
+ environment:
28
+ {{#each envVars}} - {{{this}}}
29
+ {{/each}}
30
+ ports:
31
+ - '3000:3000'
32
+ - '50000-50100:50000-50100/udp'
33
+ depends_on:
34
+ postgres:
35
+ condition: service_healthy
36
+ restart: always
37
+ networks:
38
+ - eliza-network
39
+
40
+
41
+ networks:
42
+ eliza-network:
43
+ driver: bridge
44
+
45
+ volumes:
46
+ postgres-data:`,ot=`version: '3.8'
47
+ services:
48
+ app:
49
+ image: {{imageName}}
50
+ container_name: app
51
+ volumes:
52
+ - /var/run/tappd.sock:/var/run/tappd.sock
53
+ environment:
54
+ {{#each envVars}} - {{{this}}}
55
+ {{/each}}
56
+ restart: always
57
+ `;function ie(r){try{return JSON.stringify(r)}catch(t){return t instanceof Error&&t.message.includes("cyclic")?"[Cyclic Object]":String(r)}}async function mt(){try{x.debug(`Fetching user info from ${y.USER_INFO}`);let t=await Ae().get(y.USER_INFO);x.debug(`Received response: ${ie(t)}`);try{return Q.parse(t)}catch(n){throw x.error(`Failed to parse user info response: ${n}`),x.debug(`Response structure: ${ie(t)}`),n}}catch(r){throw x.error(`Failed to get user info: ${r instanceof Error?r.message:String(r)}`),new Error(`Failed to get user info: ${r instanceof Error?r.message:String(r)}`)}}import{createClient as S}from"@phala/cloud";import Ie from"inquirer";import{z as ae}from"zod";async function le(){try{let t=await S().get(y.CVMS(0));return ae.array(F).parse(t)}catch(r){throw new Error(`Failed to get CVMs: ${r instanceof Error?r.message:String(r)}`)}}async function Ct(r){let n=(await le()).find(o=>o.hosted?.app_id===r||`app_${o.hosted?.app_id}`===r);if(!n)x.error(`CVM with App ID app_${r} not detected`),process.exit(1);else return x.success(`CVM with App ID app_${r} detected`),n.hosted?.app_id||""}async function kt(r){try{let n=await S().get(y.CVM_BY_APP_ID(r));return X.parse(n)}catch(t){throw new Error(`Failed to get CVM by App ID: ${t instanceof Error?t.message:String(t)}`)}}async function St(r){try{let n=await S().post(y.CVM_PUBKEY,r);return J.parse(n)}catch(t){throw new Error(`Failed to get pubkey from CVM: ${t instanceof Error?t.message:String(t)}`)}}async function xt(r){try{let n=await S().get(y.CVM_NETWORK(r));return re.parse(n)}catch(t){throw new Error(`Failed to get network information for CVM: ${t instanceof Error?t.message:String(t)}`)}}async function Tt(r){try{let n=await S().post(y.CVM_FROM_CONFIGURATION,r);return W.parse(n)}catch(t){throw t instanceof ae.ZodError?(x.error("Schema validation error:",JSON.stringify(t.errors,null,2)),x.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 wt(r){try{let n=await S().post(y.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 Rt(r){try{let n=await S().post(y.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 Et(r){try{let n=await S().post(y.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 Pt(r,t){try{let o=await S().put(y.CVM_UPGRADE(r),t);return ee.parse(o)}catch(n){throw new Error(`Failed to upgrade CVM: ${n instanceof Error?n.message:String(n)}`)}}async function $t(r){try{return await S().delete(y.CVM_BY_APP_ID(r)),!0}catch(t){throw new Error(`Failed to delete CVM: ${t instanceof Error?t.message:String(t)}`)}}async function At(r){try{return await S().put(y.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 It(){let r=x.startSpinner("Fetching available CVMs"),t=await le();if(r.stop(!0),!t||t.length===0){x.info("No CVMs found for your account");return}let n=t.map(m=>{let a=m.hosted?.app_id||m.hosted?.id,i=m.name||m.hosted?.name,_=m.status||m.hosted?.status;return{name:`${i||"Unnamed"} (${a}) - Status: ${_||"Unknown"}`,value:a}}),{selectedCvm:o}=await Ie.prompt([{type:"list",name:"selectedCvm",message:"Select a CVM:",choices:n}]);return o}async function Mt(r){try{let n=await S().get(y.CVM_ATTESTATION(r));try{return se.parse(n)}catch(o){return x.debug(`Validation error: ${o instanceof Error?o.message:String(o)}`),{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 Vt(r){try{let n=await S().get(y.CVM_COMPOSE(r));return ne.parse(n)}catch(t){throw new Error(`Failed to get CVM compose config: ${t instanceof Error?t.message:String(t)}`)}}async function Ot(r,t){try{let o=await S().post(y.REPLICATE_CVM(r),t);return oe.parse(o)}catch(n){throw new Error(`Failed to replicate CVM: ${n instanceof Error?n.message:String(n)}`)}}async function Lt(r,t,n,o,m){try{let a=S(),i={};if(t!==void 0&&(i.vcpu=t),n!==void 0&&(i.memory=n),o!==void 0&&(i.disk_size=o),m!==void 0&&(i.allow_restart=m),Object.keys(i).length===0)throw new Error("At least one resource parameter must be provided");return await a.patch(y.CVM_RESIZE(r),i),!0}catch(a){throw new Error(`Failed to resize CVM: ${a instanceof Error?a.message:String(a)}`)}}import{createClient as ce}from"@phala/cloud";import{z as Me}from"zod";async function Ve(){try{let t=await(await ce()).get(y.TEEPODS);return te.parse(t)}catch(r){throw new Error(`Failed to get TEEPods: ${r instanceof Error?r.message:String(r)}`)}}async function Zt(r){try{let t=ce(),o=(await Ve()).nodes.find(a=>a.teepod_id===Number(r));if(o&&o.images&&o.images.length>0)return o.images;let m=await(await t).get(y.TEEPOD_IMAGES(r));return Me.array(B).parse(m)}catch(t){throw new Error(`Failed to get TEEPod images: ${t instanceof Error?t.message:String(t)}`)}}export{x as a,Xe as b,Qe as c,et as d,tt as e,rt as f,nt as g,ot as h,Be as i,ke as j,Se as k,xe as l,Te as m,we as n,Re as o,F as p,W as q,J as r,X as s,Q as t,Ye as u,ee as v,qe as w,B as x,Ee as y,Pe as z,$e as A,te as B,re as C,ne as D,oe as E,se as F,mt as G,le as H,Ct as I,kt as J,St as K,xt as L,Tt as M,wt as N,Rt as O,Et as P,Pt as Q,$t as R,At as S,It as T,Mt as U,Vt as V,Ot as W,Lt as X,Ve as Y,Zt as Z};
58
+ //# sourceMappingURL=chunk-YV2WYCLU.js.map