phala 1.1.0-beta.2 → 1.1.0-beta.3

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
@@ -446,6 +446,92 @@ Get detailed information about a specific CVM.
446
446
  phala cvms get app_123456
447
447
  ```
448
448
 
449
+ #### Deploy (Simplified)
450
+
451
+ ```bash
452
+ phala deploy [options]
453
+ ```
454
+
455
+ Create a new CVM with automatic resource matching. This is the recommended command for most users as it simplifies deployment by automatically selecting optimal resources based on availability.
456
+
457
+ **Key Features:**
458
+ - **Auto Resource Matching**: Backend automatically finds the best available node based on your requirements
459
+ - **All Parameters Optional**: Specify only what you need; the system handles the rest
460
+ - **Structured Error Messages**: Clear error codes (ERR-xxxx) with actionable suggestions
461
+ - **On-chain KMS Support**: Built-in support for decentralized key management
462
+
463
+ **Options:**
464
+ - `-n, --name <name>`: Name of the CVM (auto-generated from folder name if not provided)
465
+ - `-c, --compose <compose>`: Path to Docker Compose file (default: docker-compose.yml)
466
+ - `-t, --instance-type <type>`: Instance type (e.g., tdx.small, tdx.medium, tdx.large) - **optional**, auto-selected if not specified
467
+ - `-r, --region <region>`: Preferred region (e.g., us-west, eu-central) - **optional**, auto-selected if not specified
468
+ - `--vcpu <vcpu>`: Number of vCPUs - **optional**, auto-matched if not specified
469
+ - `--memory <memory>`: Memory with unit (e.g., 2G, 1024MB) - **optional**, auto-matched if not specified
470
+ - `--disk-size <diskSize>`: Disk size with unit (e.g., 50G, 100GB) - **optional**, auto-matched if not specified
471
+ - `--image <image>`: OS image version - **optional**, auto-selected if not specified
472
+ - `--node-id <nodeId>`: Specific node ID - **optional**, auto-selected if not specified
473
+ - `-e, --env-file <envFile>`: Path to environment variables file
474
+ - `-i, --interactive`: Enable interactive mode for required parameters
475
+ - `--kms-id <kmsId>`: KMS ID for on-chain key management
476
+ - `--private-key <key>`: Private key for on-chain KMS deployment
477
+ - `--rpc-url <url>`: RPC URL for blockchain interaction
478
+ - `--uuid <uuid>`: UUID of existing CVM to upgrade
479
+ - `--wait`: Wait for deployment/update to complete before returning
480
+ - `-j, --json`: Output in JSON format
481
+ - `-d, --debug`: Enable debug logging
482
+
483
+ **Examples:**
484
+
485
+ ```bash
486
+ # Simplest - auto-select everything
487
+ phala deploy
488
+
489
+ # Specify instance type and region
490
+ phala deploy --instance-type tdx.medium --region us-west
491
+
492
+ # Manual resource specification
493
+ phala deploy --vcpu 4 --memory 8G --disk-size 100G
494
+
495
+ # With on-chain KMS
496
+ phala deploy --kms-id ethereum --private-key <key> --rpc-url <url>
497
+
498
+ # Deploy to specific node (advanced)
499
+ phala deploy --node-id 6
500
+
501
+ # Interactive mode for guided setup
502
+ phala deploy --interactive
503
+ ```
504
+
505
+ **Error Handling:**
506
+
507
+ The deploy command provides structured error messages with unique error codes for easy troubleshooting:
508
+
509
+ ```
510
+ Error [ERR-1003]: The selected node does not have enough CPU capacity
511
+
512
+ Details:
513
+ - Need 4 CPUs, but only 2 are available
514
+ - node_id: 6
515
+
516
+ Suggestions:
517
+ - Choose a smaller instance type
518
+ - Reduce the number of CPUs requested
519
+ - Remove the --node-id flag to search all available nodes
520
+
521
+ Need help? Contact support: https://cloud.phala.network/contact
522
+ Reference error code: ERR-1003
523
+ ```
524
+
525
+ Common error codes:
526
+ - `ERR-1001`: Instance type not found
527
+ - `ERR-1002`: No available resources match requirements
528
+ - `ERR-1003`: Insufficient CPU capacity
529
+ - `ERR-1004`: Insufficient memory
530
+ - `ERR-2003`: OS image not available
531
+ - `ERR-2005`: Node not accessible
532
+
533
+ For a complete list of error codes, refer to the error code documentation.
534
+
449
535
  #### Create CVM
450
536
 
451
537
  ```bash
@@ -1,4 +1,6 @@
1
1
  import { z } from 'zod';
2
+ import { CvmLegacyDetail } from '@phala/cloud';
3
+ export { CvmLegacyDetail as CvmInfoResponse } from '@phala/cloud';
2
4
 
3
5
  declare const dockerConfigSchema: z.ZodObject<{
4
6
  password: z.ZodString;
@@ -104,42 +106,42 @@ declare const postCvmResponseSchema: z.ZodObject<{
104
106
  name?: string;
105
107
  id?: number;
106
108
  }>>;
107
- user_id: z.ZodNumber;
109
+ user_id: z.ZodNullable<z.ZodNumber>;
108
110
  app_id: z.ZodString;
109
111
  vm_uuid: z.ZodNullable<z.ZodString>;
110
112
  instance_id: z.ZodNullable<z.ZodString>;
111
113
  app_url: z.ZodNullable<z.ZodString>;
112
- base_image: z.ZodString;
114
+ base_image: z.ZodNullable<z.ZodString>;
113
115
  vcpu: z.ZodNumber;
114
116
  memory: z.ZodNumber;
115
117
  disk_size: z.ZodNumber;
116
- manifest_version: z.ZodNumber;
117
- version: z.ZodString;
118
- runner: z.ZodString;
119
- docker_compose_file: z.ZodString;
118
+ manifest_version: z.ZodNullable<z.ZodNumber>;
119
+ version: z.ZodNullable<z.ZodString>;
120
+ runner: z.ZodNullable<z.ZodString>;
121
+ docker_compose_file: z.ZodNullable<z.ZodString>;
120
122
  features: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
121
123
  created_at: z.ZodString;
122
- encrypted_env_pubkey: z.ZodString;
124
+ encrypted_env_pubkey: z.ZodNullable<z.ZodString>;
123
125
  }, "strip", z.ZodTypeAny, {
124
126
  status?: string;
125
127
  name?: string;
126
128
  vcpu?: number;
127
129
  memory?: number;
130
+ id?: number;
131
+ app_id?: string;
132
+ instance_id?: string;
128
133
  version?: string;
129
134
  runner?: string;
130
135
  docker_compose_file?: string;
131
136
  features?: string[];
132
137
  manifest_version?: number;
133
- id?: number;
134
138
  teepod_id?: number;
135
139
  teepod?: {
136
140
  name?: string;
137
141
  id?: number;
138
142
  };
139
143
  user_id?: number;
140
- app_id?: string;
141
144
  vm_uuid?: string;
142
- instance_id?: string;
143
145
  app_url?: string;
144
146
  base_image?: string;
145
147
  disk_size?: number;
@@ -150,21 +152,21 @@ declare const postCvmResponseSchema: z.ZodObject<{
150
152
  name?: string;
151
153
  vcpu?: number;
152
154
  memory?: number;
155
+ id?: number;
156
+ app_id?: string;
157
+ instance_id?: string;
153
158
  version?: string;
154
159
  runner?: string;
155
160
  docker_compose_file?: string;
156
161
  features?: string[];
157
162
  manifest_version?: number;
158
- id?: number;
159
163
  teepod_id?: number;
160
164
  teepod?: {
161
165
  name?: string;
162
166
  id?: number;
163
167
  };
164
168
  user_id?: number;
165
- app_id?: string;
166
169
  vm_uuid?: string;
167
- instance_id?: string;
168
170
  app_url?: string;
169
171
  base_image?: string;
170
172
  disk_size?: number;
@@ -198,9 +200,9 @@ declare const getCvmNetworkResponseSchema: z.ZodObject<{
198
200
  instance?: string;
199
201
  }>, "many">;
200
202
  }, "strip", z.ZodTypeAny, {
203
+ error?: string;
201
204
  is_online?: boolean;
202
205
  is_public?: boolean;
203
- error?: string;
204
206
  internal_ip?: string;
205
207
  latest_handshake?: string;
206
208
  public_urls?: {
@@ -208,9 +210,9 @@ declare const getCvmNetworkResponseSchema: z.ZodObject<{
208
210
  instance?: string;
209
211
  }[];
210
212
  }, {
213
+ error?: string;
211
214
  is_online?: boolean;
212
215
  is_public?: boolean;
213
- error?: string;
214
216
  internal_ip?: string;
215
217
  latest_handshake?: string;
216
218
  public_urls?: {
@@ -288,42 +290,42 @@ declare const replicateCvmResponseSchema: z.ZodObject<{
288
290
  name?: string;
289
291
  id?: number;
290
292
  }>;
291
- user_id: z.ZodNumber;
293
+ user_id: z.ZodNullable<z.ZodNumber>;
292
294
  app_id: z.ZodString;
293
- vm_uuid: z.ZodString;
295
+ vm_uuid: z.ZodNullable<z.ZodString>;
294
296
  instance_id: z.ZodNullable<z.ZodString>;
295
297
  app_url: z.ZodNullable<z.ZodString>;
296
- base_image: z.ZodString;
298
+ base_image: z.ZodNullable<z.ZodString>;
297
299
  vcpu: z.ZodNumber;
298
300
  memory: z.ZodNumber;
299
301
  disk_size: z.ZodNumber;
300
- manifest_version: z.ZodNumber;
302
+ manifest_version: z.ZodNullable<z.ZodNumber>;
301
303
  version: z.ZodNullable<z.ZodString>;
302
- runner: z.ZodString;
303
- docker_compose_file: z.ZodString;
304
+ runner: z.ZodNullable<z.ZodString>;
305
+ docker_compose_file: z.ZodNullable<z.ZodString>;
304
306
  features: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
305
307
  created_at: z.ZodString;
306
- encrypted_env_pubkey: z.ZodString;
308
+ encrypted_env_pubkey: z.ZodNullable<z.ZodString>;
307
309
  }, "strip", z.ZodTypeAny, {
308
310
  status?: string;
309
311
  name?: string;
310
312
  vcpu?: number;
311
313
  memory?: number;
314
+ id?: number;
315
+ app_id?: string;
316
+ instance_id?: string;
312
317
  version?: string;
313
318
  runner?: string;
314
319
  docker_compose_file?: string;
315
320
  features?: string[];
316
321
  manifest_version?: number;
317
- id?: number;
318
322
  teepod_id?: number;
319
323
  teepod?: {
320
324
  name?: string;
321
325
  id?: number;
322
326
  };
323
327
  user_id?: number;
324
- app_id?: string;
325
328
  vm_uuid?: string;
326
- instance_id?: string;
327
329
  app_url?: string;
328
330
  base_image?: string;
329
331
  disk_size?: number;
@@ -334,21 +336,21 @@ declare const replicateCvmResponseSchema: z.ZodObject<{
334
336
  name?: string;
335
337
  vcpu?: number;
336
338
  memory?: number;
339
+ id?: number;
340
+ app_id?: string;
341
+ instance_id?: string;
337
342
  version?: string;
338
343
  runner?: string;
339
344
  docker_compose_file?: string;
340
345
  features?: string[];
341
346
  manifest_version?: number;
342
- id?: number;
343
347
  teepod_id?: number;
344
348
  teepod?: {
345
349
  name?: string;
346
350
  id?: number;
347
351
  };
348
352
  user_id?: number;
349
- app_id?: string;
350
353
  vm_uuid?: string;
351
- instance_id?: string;
352
354
  app_url?: string;
353
355
  base_image?: string;
354
356
  disk_size?: number;
@@ -507,9 +509,9 @@ declare const cvmAttestationResponseSchema: z.ZodObject<{
507
509
  }>>;
508
510
  compose_file: z.ZodNullable<z.ZodString>;
509
511
  }, "strip", z.ZodTypeAny, {
512
+ error?: string;
510
513
  is_online?: boolean;
511
514
  is_public?: boolean;
512
- error?: string;
513
515
  app_certificates?: {
514
516
  version?: string;
515
517
  subject?: {
@@ -551,9 +553,9 @@ declare const cvmAttestationResponseSchema: z.ZodObject<{
551
553
  };
552
554
  compose_file?: string;
553
555
  }, {
556
+ error?: string;
554
557
  is_online?: boolean;
555
558
  is_public?: boolean;
556
- error?: string;
557
559
  app_certificates?: {
558
560
  version?: string;
559
561
  subject?: {
@@ -773,18 +775,7 @@ interface PubkeyResponse {
773
775
  app_env_encrypt_pubkey: string;
774
776
  app_id_salt: string;
775
777
  }
776
- interface CvmInfoResponse {
777
- id: number;
778
- name: string;
779
- status: string;
780
- app_id: string;
781
- vcpu: number;
782
- memory: number;
783
- disk_size: number;
784
- base_image: string;
785
- encrypted_env_pubkey: string;
786
- env_pubkey?: string;
787
- }
778
+
788
779
  interface UpgradeResponse {
789
780
  detail?: string;
790
781
  [key: string]: unknown;
@@ -809,15 +800,16 @@ interface CvmComposeConfigResponse {
809
800
  /**
810
801
  * Check CVM exists for the current user and appId
811
802
  * @param appId App ID (with or without app_ prefix)
803
+ * @param silent If true, don't log success/error messages (useful for JSON output mode)
812
804
  * @returns CVM appId string (without app_ prefix) or throws if not found
813
805
  */
814
- declare function checkCvmExists(appId: string): Promise<string>;
806
+ declare function checkCvmExists(appId: string, silent?: boolean): Promise<string>;
815
807
  /**
816
808
  * Get CVM by App ID using SDK
817
809
  * @param appId App ID (with or without app_ prefix)
818
810
  * @returns CVM details
819
811
  */
820
- declare function getCvmByAppId(appId: string): Promise<CvmInfoResponse>;
812
+ declare function getCvmByAppId(appId: string): Promise<CvmLegacyDetail>;
821
813
  /**
822
814
  * Get CVM compose configuration
823
815
  */
@@ -926,4 +918,4 @@ declare function upgradeCvm(appId: string, vmConfig: VMConfig): Promise<UpgradeR
926
918
  */
927
919
  declare function getTeepods(v03x_only?: boolean): Promise<TeepodResponse>;
928
920
 
929
- export { AvailableNodesResponse, CertificateInfo, CertificateNameInfo, ComposeFile, CvmAttestationResponse, CvmComposeConfigResponse, CvmInfoResponse, CvmListResponse, DockerConfig, EncryptedEnvItem, GetCvmNetworkResponse, Image, KmsListItem, PostCvmResponse, PubkeyResponse, ReplicateCvmResponse, ResizeCvmPayload, TCBEventLogEntry, TCBInfo, TEEPod, TeepodResponse, UpgradeResponse, UserInfoResponse, VMConfig, checkCvmExists, composeFileSchema, createCvm, cvmAttestationResponseSchema, deleteCvm, dockerConfigSchema, encryptedEnvItemSchema, getCvmAttestation, getCvmByAppId, getCvmComposeConfig, getCvmNetwork, getCvmNetworkResponseSchema, getPubkeyFromCvm, getTeepods, imageSchema, postCvmResponseSchema, replicateCvm, replicateCvmResponseSchema, resizeCvm, restartCvm, selectCvm, startCvm, stopCvm, teepodSchema, upgradeCvm };
921
+ export { AvailableNodesResponse, CertificateInfo, CertificateNameInfo, ComposeFile, CvmAttestationResponse, CvmComposeConfigResponse, CvmListResponse, DockerConfig, EncryptedEnvItem, GetCvmNetworkResponse, Image, KmsListItem, PostCvmResponse, PubkeyResponse, ReplicateCvmResponse, ResizeCvmPayload, TCBEventLogEntry, TCBInfo, TEEPod, TeepodResponse, UpgradeResponse, UserInfoResponse, VMConfig, checkCvmExists, composeFileSchema, createCvm, cvmAttestationResponseSchema, deleteCvm, dockerConfigSchema, encryptedEnvItemSchema, getCvmAttestation, getCvmByAppId, getCvmComposeConfig, getCvmNetwork, getCvmNetworkResponseSchema, getPubkeyFromCvm, getTeepods, imageSchema, postCvmResponseSchema, replicateCvm, replicateCvmResponseSchema, resizeCvm, restartCvm, selectCvm, startCvm, stopCvm, teepodSchema, upgradeCvm };