@phala/cloud 0.2.0 → 0.2.1-beta.1
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/actions/cvms/commit_cvm_provision.d.ts +69 -21
- package/dist/actions/cvms/get_cvm_list.d.ts +16 -16
- package/dist/actions/cvms/provision_cvm.d.ts +132 -50
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/kms/get_kms_list.d.ts +4 -4
- package/dist/actions/list-instance-types.d.ts +295 -90
- package/dist/create-client.d.ts +21 -7
- package/dist/index.js +164 -48
- package/dist/index.mjs +154 -44
- package/dist/utils/errors.d.ts +137 -20
- package/dist/utils/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,19 @@ import { type Client } from "../../client";
|
|
|
4
4
|
* Commit CVM Provision (Create CVM from provisioned data)
|
|
5
5
|
*
|
|
6
6
|
* This action creates a CVM using previously provisioned data and encrypted environment variables.
|
|
7
|
-
* It
|
|
7
|
+
* It MUST be called after `provisionCvm` to complete the CVM deployment process.
|
|
8
|
+
*
|
|
9
|
+
* ## Two-Step Deployment Flow
|
|
10
|
+
*
|
|
11
|
+
* 1. **Provision** (`provisionCvm`): Prepares resources and returns `compose_hash` (and `app_id` for PHALA KMS)
|
|
12
|
+
* 2. **Commit** (this function): Creates the actual CVM using provisioned data
|
|
13
|
+
*
|
|
14
|
+
* ## KMS Type and app_id Source
|
|
15
|
+
*
|
|
16
|
+
* The `app_id` source depends on the KMS type used during provisioning:
|
|
17
|
+
*
|
|
18
|
+
* - **PHALA KMS** (default): `app_id` is obtained from centralized KMS - returned by `provisionCvm()`
|
|
19
|
+
* - **ETHEREUM/BASE KMS** (on-chain): `app_id` must be obtained by deploying your contract and interacting with the on-chain KMS - NOT provided by `provisionCvm()`
|
|
8
20
|
*
|
|
9
21
|
* @example
|
|
10
22
|
* ```typescript
|
|
@@ -12,20 +24,43 @@ import { type Client } from "../../client";
|
|
|
12
24
|
*
|
|
13
25
|
* const client = createClient();
|
|
14
26
|
*
|
|
15
|
-
* //
|
|
16
|
-
* const provision = await provisionCvm(client,
|
|
27
|
+
* // Example 1: PHALA KMS (default - app_id from provision)
|
|
28
|
+
* const provision = await provisionCvm(client, {
|
|
29
|
+
* name: "my-cvm",
|
|
30
|
+
* instance_type: "tdx.small",
|
|
31
|
+
* kms: "PHALA", // or omit for default
|
|
32
|
+
* compose_file: { docker_compose_file: "..." },
|
|
33
|
+
* });
|
|
17
34
|
*
|
|
18
|
-
* //
|
|
35
|
+
* // app_id is provided by provision API
|
|
19
36
|
* const cvm = await commitCvmProvision(client, {
|
|
20
|
-
*
|
|
21
|
-
* app_id: provision.app_id,
|
|
37
|
+
* app_id: provision.app_id, // From provision response
|
|
22
38
|
* compose_hash: provision.compose_hash,
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
39
|
+
* encrypted_env: "...",
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // Example 2: On-chain KMS (app_id from contract deployment)
|
|
43
|
+
* const provision = await provisionCvm(client, {
|
|
44
|
+
* name: "my-cvm",
|
|
45
|
+
* instance_type: "tdx.small",
|
|
46
|
+
* kms: "ETHEREUM", // or "BASE" for Base network
|
|
47
|
+
* compose_file: { docker_compose_file: "..." },
|
|
26
48
|
* });
|
|
27
49
|
*
|
|
28
|
-
*
|
|
50
|
+
* // Step 1: Deploy your contract and get app_id from on-chain KMS
|
|
51
|
+
* const contractTx = await deployContract({
|
|
52
|
+
* kmsContract: "0x...",
|
|
53
|
+
* // ... contract deployment params
|
|
54
|
+
* });
|
|
55
|
+
* const appId = await getAppIdFromKms(contractTx);
|
|
56
|
+
*
|
|
57
|
+
* // Step 2: Commit with app_id from on-chain interaction
|
|
58
|
+
* const cvm = await commitCvmProvision(client, {
|
|
59
|
+
* app_id: appId, // From on-chain KMS, NOT from provision
|
|
60
|
+
* compose_hash: provision.compose_hash, // From provision response
|
|
61
|
+
* contract_address: "0x123...", // Your deployed contract
|
|
62
|
+
* deployer_address: "0x456...", // Deployer address
|
|
63
|
+
* });
|
|
29
64
|
* ```
|
|
30
65
|
*
|
|
31
66
|
* ## Returns
|
|
@@ -34,9 +69,22 @@ import { type Client } from "../../client";
|
|
|
34
69
|
*
|
|
35
70
|
* The created CVM details including id, name, status, and other metadata. Return type depends on schema parameter.
|
|
36
71
|
*
|
|
37
|
-
* ## Parameters
|
|
72
|
+
* ## Required Parameters
|
|
73
|
+
*
|
|
74
|
+
* - **app_id**: Application identifier
|
|
75
|
+
* - For PHALA KMS: Use `provision.app_id` from `provisionCvm()` response
|
|
76
|
+
* - For ETHEREUM/BASE KMS (on-chain): Obtain from your on-chain KMS contract deployment
|
|
77
|
+
* - **compose_hash**: Must be obtained from `provisionCvm()` response (used to retrieve provision data from Redis)
|
|
78
|
+
*
|
|
79
|
+
* ## Optional Parameters
|
|
80
|
+
*
|
|
81
|
+
* - **encrypted_env**: Hex-encoded encrypted environment variables
|
|
82
|
+
* - **env_keys**: List of environment variable keys to allow
|
|
83
|
+
* - **kms_id**: KMS instance identifier (if using specific KMS)
|
|
84
|
+
* - **contract_address**: On-chain KMS contract address (required for ETHEREUM/BASE KMS)
|
|
85
|
+
* - **deployer_address**: Deployer address for on-chain verification (required for ETHEREUM/BASE KMS)
|
|
38
86
|
*
|
|
39
|
-
*
|
|
87
|
+
* ## Schema Parameter
|
|
40
88
|
*
|
|
41
89
|
* - **Type:** `ZodSchema | false`
|
|
42
90
|
* - **Default:** `CommitCvmProvisionSchema`
|
|
@@ -178,7 +226,7 @@ export type CommitCvmProvision = z.infer<typeof CommitCvmProvisionSchema>;
|
|
|
178
226
|
export declare const CommitCvmProvisionRequestSchema: z.ZodObject<{
|
|
179
227
|
encrypted_env: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
180
228
|
app_id: z.ZodString;
|
|
181
|
-
compose_hash: z.
|
|
229
|
+
compose_hash: z.ZodString;
|
|
182
230
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
183
231
|
contract_address: z.ZodOptional<z.ZodString>;
|
|
184
232
|
deployer_address: z.ZodOptional<z.ZodString>;
|
|
@@ -186,7 +234,7 @@ export declare const CommitCvmProvisionRequestSchema: z.ZodObject<{
|
|
|
186
234
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
187
235
|
encrypted_env: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
188
236
|
app_id: z.ZodString;
|
|
189
|
-
compose_hash: z.
|
|
237
|
+
compose_hash: z.ZodString;
|
|
190
238
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
191
239
|
contract_address: z.ZodOptional<z.ZodString>;
|
|
192
240
|
deployer_address: z.ZodOptional<z.ZodString>;
|
|
@@ -194,7 +242,7 @@ export declare const CommitCvmProvisionRequestSchema: z.ZodObject<{
|
|
|
194
242
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
195
243
|
encrypted_env: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
196
244
|
app_id: z.ZodString;
|
|
197
|
-
compose_hash: z.
|
|
245
|
+
compose_hash: z.ZodString;
|
|
198
246
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
199
247
|
contract_address: z.ZodOptional<z.ZodString>;
|
|
200
248
|
deployer_address: z.ZodOptional<z.ZodString>;
|
|
@@ -205,7 +253,7 @@ declare const commitCvmProvision: {
|
|
|
205
253
|
(client: Client, params: z.objectOutputType<{
|
|
206
254
|
encrypted_env: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
207
255
|
app_id: z.ZodString;
|
|
208
|
-
compose_hash: z.
|
|
256
|
+
compose_hash: z.ZodString;
|
|
209
257
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
210
258
|
contract_address: z.ZodOptional<z.ZodString>;
|
|
211
259
|
deployer_address: z.ZodOptional<z.ZodString>;
|
|
@@ -247,7 +295,7 @@ declare const commitCvmProvision: {
|
|
|
247
295
|
<T extends z.ZodTypeAny>(client: Client, params: z.objectOutputType<{
|
|
248
296
|
encrypted_env: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
249
297
|
app_id: z.ZodString;
|
|
250
|
-
compose_hash: z.
|
|
298
|
+
compose_hash: z.ZodString;
|
|
251
299
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
252
300
|
contract_address: z.ZodOptional<z.ZodString>;
|
|
253
301
|
deployer_address: z.ZodOptional<z.ZodString>;
|
|
@@ -258,7 +306,7 @@ declare const commitCvmProvision: {
|
|
|
258
306
|
(client: Client, params: z.objectOutputType<{
|
|
259
307
|
encrypted_env: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
260
308
|
app_id: z.ZodString;
|
|
261
|
-
compose_hash: z.
|
|
309
|
+
compose_hash: z.ZodString;
|
|
262
310
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
263
311
|
contract_address: z.ZodOptional<z.ZodString>;
|
|
264
312
|
deployer_address: z.ZodOptional<z.ZodString>;
|
|
@@ -270,7 +318,7 @@ declare const commitCvmProvision: {
|
|
|
270
318
|
(client: Client, params: z.objectOutputType<{
|
|
271
319
|
encrypted_env: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
272
320
|
app_id: z.ZodString;
|
|
273
|
-
compose_hash: z.
|
|
321
|
+
compose_hash: z.ZodString;
|
|
274
322
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
275
323
|
contract_address: z.ZodOptional<z.ZodString>;
|
|
276
324
|
deployer_address: z.ZodOptional<z.ZodString>;
|
|
@@ -312,7 +360,7 @@ declare const commitCvmProvision: {
|
|
|
312
360
|
<T extends z.ZodTypeAny>(client: Client, params: z.objectOutputType<{
|
|
313
361
|
encrypted_env: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
314
362
|
app_id: z.ZodString;
|
|
315
|
-
compose_hash: z.
|
|
363
|
+
compose_hash: z.ZodString;
|
|
316
364
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
317
365
|
contract_address: z.ZodOptional<z.ZodString>;
|
|
318
366
|
deployer_address: z.ZodOptional<z.ZodString>;
|
|
@@ -323,7 +371,7 @@ declare const commitCvmProvision: {
|
|
|
323
371
|
(client: Client, params: z.objectOutputType<{
|
|
324
372
|
encrypted_env: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
325
373
|
app_id: z.ZodString;
|
|
326
|
-
compose_hash: z.
|
|
374
|
+
compose_hash: z.ZodString;
|
|
327
375
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
328
376
|
contract_address: z.ZodOptional<z.ZodString>;
|
|
329
377
|
deployer_address: z.ZodOptional<z.ZodString>;
|
|
@@ -8,15 +8,15 @@ export declare const GetCvmListRequestSchema: z.ZodObject<{
|
|
|
8
8
|
user_id: z.ZodOptional<z.ZodString>;
|
|
9
9
|
}, "strict", z.ZodTypeAny, {
|
|
10
10
|
teepod_id?: number | undefined;
|
|
11
|
+
user_id?: string | undefined;
|
|
11
12
|
page?: number | undefined;
|
|
12
13
|
page_size?: number | undefined;
|
|
13
|
-
user_id?: string | undefined;
|
|
14
14
|
node_id?: number | undefined;
|
|
15
15
|
}, {
|
|
16
16
|
teepod_id?: number | undefined;
|
|
17
|
+
user_id?: string | undefined;
|
|
17
18
|
page?: number | undefined;
|
|
18
19
|
page_size?: number | undefined;
|
|
19
|
-
user_id?: string | undefined;
|
|
20
20
|
node_id?: number | undefined;
|
|
21
21
|
}>;
|
|
22
22
|
export declare const GetCvmListSchema: z.ZodObject<{
|
|
@@ -262,8 +262,6 @@ export declare const GetCvmListSchema: z.ZodObject<{
|
|
|
262
262
|
page_size: z.ZodNumber;
|
|
263
263
|
pages: z.ZodNumber;
|
|
264
264
|
}, "strict", z.ZodTypeAny, {
|
|
265
|
-
page: number;
|
|
266
|
-
page_size: number;
|
|
267
265
|
items: {
|
|
268
266
|
status: string;
|
|
269
267
|
name: string;
|
|
@@ -318,10 +316,10 @@ export declare const GetCvmListSchema: z.ZodObject<{
|
|
|
318
316
|
}[];
|
|
319
317
|
}[];
|
|
320
318
|
total: number;
|
|
321
|
-
pages: number;
|
|
322
|
-
}, {
|
|
323
319
|
page: number;
|
|
324
320
|
page_size: number;
|
|
321
|
+
pages: number;
|
|
322
|
+
}, {
|
|
325
323
|
items: {
|
|
326
324
|
status: string;
|
|
327
325
|
name: string;
|
|
@@ -376,6 +374,8 @@ export declare const GetCvmListSchema: z.ZodObject<{
|
|
|
376
374
|
allow_upgrade?: boolean | undefined;
|
|
377
375
|
}[];
|
|
378
376
|
total: number;
|
|
377
|
+
page: number;
|
|
378
|
+
page_size: number;
|
|
379
379
|
pages: number;
|
|
380
380
|
}>;
|
|
381
381
|
export type GetCvmListRequest = z.infer<typeof GetCvmListRequestSchema>;
|
|
@@ -405,13 +405,11 @@ export type GetCvmListResponse = z.infer<typeof GetCvmListSchema>;
|
|
|
405
405
|
declare const getCvmList: {
|
|
406
406
|
(client: Client, params?: {
|
|
407
407
|
teepod_id?: number | undefined;
|
|
408
|
+
user_id?: string | undefined;
|
|
408
409
|
page?: number | undefined;
|
|
409
410
|
page_size?: number | undefined;
|
|
410
|
-
user_id?: string | undefined;
|
|
411
411
|
node_id?: number | undefined;
|
|
412
412
|
} | undefined): Promise<{
|
|
413
|
-
page: number;
|
|
414
|
-
page_size: number;
|
|
415
413
|
items: {
|
|
416
414
|
status: string;
|
|
417
415
|
name: string;
|
|
@@ -466,22 +464,24 @@ declare const getCvmList: {
|
|
|
466
464
|
}[];
|
|
467
465
|
}[];
|
|
468
466
|
total: number;
|
|
467
|
+
page: number;
|
|
468
|
+
page_size: number;
|
|
469
469
|
pages: number;
|
|
470
470
|
}>;
|
|
471
471
|
<T extends z.ZodTypeAny>(client: Client, params?: {
|
|
472
472
|
teepod_id?: number | undefined;
|
|
473
|
+
user_id?: string | undefined;
|
|
473
474
|
page?: number | undefined;
|
|
474
475
|
page_size?: number | undefined;
|
|
475
|
-
user_id?: string | undefined;
|
|
476
476
|
node_id?: number | undefined;
|
|
477
477
|
} | undefined, parameters?: {
|
|
478
478
|
schema: T;
|
|
479
479
|
} | undefined): Promise<z.TypeOf<T>>;
|
|
480
480
|
(client: Client, params?: {
|
|
481
481
|
teepod_id?: number | undefined;
|
|
482
|
+
user_id?: string | undefined;
|
|
482
483
|
page?: number | undefined;
|
|
483
484
|
page_size?: number | undefined;
|
|
484
|
-
user_id?: string | undefined;
|
|
485
485
|
node_id?: number | undefined;
|
|
486
486
|
} | undefined, parameters?: {
|
|
487
487
|
schema: false;
|
|
@@ -489,13 +489,11 @@ declare const getCvmList: {
|
|
|
489
489
|
}, safeGetCvmList: {
|
|
490
490
|
(client: Client, params?: {
|
|
491
491
|
teepod_id?: number | undefined;
|
|
492
|
+
user_id?: string | undefined;
|
|
492
493
|
page?: number | undefined;
|
|
493
494
|
page_size?: number | undefined;
|
|
494
|
-
user_id?: string | undefined;
|
|
495
495
|
node_id?: number | undefined;
|
|
496
496
|
} | undefined): Promise<import("../..").SafeResult<{
|
|
497
|
-
page: number;
|
|
498
|
-
page_size: number;
|
|
499
497
|
items: {
|
|
500
498
|
status: string;
|
|
501
499
|
name: string;
|
|
@@ -550,22 +548,24 @@ declare const getCvmList: {
|
|
|
550
548
|
}[];
|
|
551
549
|
}[];
|
|
552
550
|
total: number;
|
|
551
|
+
page: number;
|
|
552
|
+
page_size: number;
|
|
553
553
|
pages: number;
|
|
554
554
|
}>>;
|
|
555
555
|
<T extends z.ZodTypeAny>(client: Client, params?: {
|
|
556
556
|
teepod_id?: number | undefined;
|
|
557
|
+
user_id?: string | undefined;
|
|
557
558
|
page?: number | undefined;
|
|
558
559
|
page_size?: number | undefined;
|
|
559
|
-
user_id?: string | undefined;
|
|
560
560
|
node_id?: number | undefined;
|
|
561
561
|
} | undefined, parameters?: {
|
|
562
562
|
schema: T;
|
|
563
563
|
} | undefined): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
564
564
|
(client: Client, params?: {
|
|
565
565
|
teepod_id?: number | undefined;
|
|
566
|
+
user_id?: string | undefined;
|
|
566
567
|
page?: number | undefined;
|
|
567
568
|
page_size?: number | undefined;
|
|
568
|
-
user_id?: string | undefined;
|
|
569
569
|
node_id?: number | undefined;
|
|
570
570
|
} | undefined, parameters?: {
|
|
571
571
|
schema: false;
|
|
@@ -1,47 +1,112 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type Client } from "../../client";
|
|
3
3
|
/**
|
|
4
|
-
* Provision a CVM
|
|
4
|
+
* Provision a CVM
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* Performs a pre-deployment eligibility check, validating whether the requested resources
|
|
7
|
+
* are available and the user has sufficient permissions to deploy. Returns provision data
|
|
8
|
+
* including `app_id`, encryption public key (`app_env_encrypt_pubkey`), and `compose_hash`
|
|
9
|
+
* required for the subsequent `commitCvmProvision` call.
|
|
10
|
+
*
|
|
11
|
+
* ## Automatic Resource Selection
|
|
12
|
+
*
|
|
13
|
+
* The new matching engine automatically selects optimal resources based on your requirements:
|
|
14
|
+
* - **Node Selection**: Specify `node_id` or `region`, or omit both for automatic best-match selection
|
|
15
|
+
* - **OS Image**: Specify exact image name or let system choose the latest stable version
|
|
16
|
+
* - **KMS**: Choose KMS type via `kms` parameter (defaults to PHALA) or specify `kms_id` directly
|
|
7
17
|
*
|
|
8
18
|
* @example
|
|
9
19
|
* ```typescript
|
|
10
|
-
* import { createClient,
|
|
20
|
+
* import { createClient, provisionCvm, commitCvmProvision } from '@phala/cloud'
|
|
11
21
|
*
|
|
12
22
|
* const client = createClient();
|
|
13
|
-
* const nodes = await getAvailableNodes(client);
|
|
14
|
-
* const node = nodes.nodes[0];
|
|
15
23
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* image: leechael/phala-cloud-bun-starter:latest
|
|
21
|
-
* container_name: demo
|
|
22
|
-
* ports:
|
|
23
|
-
* - "3000:3000"
|
|
24
|
-
* volumes:
|
|
25
|
-
* - /var/run/tappd.sock:/var/run/tappd.sock
|
|
26
|
-
*`;
|
|
27
|
-
*
|
|
28
|
-
* const app_compose = {
|
|
29
|
-
* name: 'my-app',
|
|
30
|
-
* node_id: node.node_id,
|
|
31
|
-
* image: node.images[0].name,
|
|
32
|
-
* vcpu: 1,
|
|
33
|
-
* memory: 1024,
|
|
34
|
-
* disk_size: 10,
|
|
24
|
+
* // Example 1: Minimal configuration with auto-selection
|
|
25
|
+
* const provision = await provisionCvm(client, {
|
|
26
|
+
* name: 'my-app', // Unique in workspace level
|
|
27
|
+
* instance_type: 'tdx.small',
|
|
35
28
|
* compose_file: {
|
|
36
|
-
* docker_compose_file:
|
|
37
|
-
*
|
|
29
|
+
* docker_compose_file: `
|
|
30
|
+
* services:
|
|
31
|
+
* demo:
|
|
32
|
+
* image: leechael/phala-cloud-bun-starter:latest
|
|
33
|
+
* ports:
|
|
34
|
+
* - "80:3000"
|
|
35
|
+
* volumes:
|
|
36
|
+
* - /var/run/dstack.sock:/var/run/dstack.sock
|
|
37
|
+
* `,
|
|
38
38
|
* },
|
|
39
|
-
* };
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // Example 2: With region preference
|
|
42
|
+
* const provision = await provisionCvm(client, {
|
|
43
|
+
* name: 'my-app',
|
|
44
|
+
* instance_type: 'tdx.medium',
|
|
45
|
+
* region: 'us-east', // Filter by region
|
|
46
|
+
* compose_file: { /* ... *\/ },
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // Example 3: With specific node and KMS type
|
|
50
|
+
* const provision = await provisionCvm(client, {
|
|
51
|
+
* name: 'my-app',
|
|
52
|
+
* node_id: 123, // Specific node
|
|
53
|
+
* kms: 'PHALA', // KMS type (PHALA, BASE, ETHERUEM)
|
|
54
|
+
* disk_size: 40,
|
|
55
|
+
* image: 'dstack-0.5.5',
|
|
56
|
+
* compose_file: { /* ... *\/ },
|
|
57
|
+
* });
|
|
40
58
|
*
|
|
41
|
-
*
|
|
42
|
-
* console.log(
|
|
59
|
+
* console.log(provision.app_id);
|
|
60
|
+
* console.log(provision.compose_hash); // Required for commitCvmProvision
|
|
43
61
|
* ```
|
|
44
62
|
*
|
|
63
|
+
* ## Required Parameters
|
|
64
|
+
*
|
|
65
|
+
* - **name**: CVM instance name
|
|
66
|
+
* - **compose_file**: Docker Compose configuration with `docker_compose_file` field
|
|
67
|
+
*
|
|
68
|
+
* ## Optional Parameters
|
|
69
|
+
*
|
|
70
|
+
* ### Instance Type
|
|
71
|
+
* - **instance_type**: Instance type identifier (default: "tdx.small")
|
|
72
|
+
* - Use `listAllInstanceTypeFamilies()` or `listFamilyInstanceTypes()` to discover available types
|
|
73
|
+
* - Examples: "tdx.small", "tdx.medium", "tdx.large"
|
|
74
|
+
* - Omit to use the default small instance type
|
|
75
|
+
*
|
|
76
|
+
* ### Node Selection (all optional - system auto-selects if omitted)
|
|
77
|
+
* - **node_id**: Specific node ID to deploy on
|
|
78
|
+
* - **region**: Region preference (e.g., "us-east", "eu-west")
|
|
79
|
+
* - If both omitted, system automatically selects the best available node
|
|
80
|
+
*
|
|
81
|
+
* ### OS Image Selection
|
|
82
|
+
* - **image**: OS image name (optional)
|
|
83
|
+
* - Omit to let the system automatically select the latest stable image
|
|
84
|
+
* - Specify a specific image name if needed (e.g., "dstack-0.5.5")
|
|
85
|
+
*
|
|
86
|
+
* ### KMS Configuration
|
|
87
|
+
* - **kms**: KMS type - "PHALA" (default), "ETHEREUM", or "BASE"
|
|
88
|
+
* - **kms_contract**: (Advanced) Specific KMS contract address
|
|
89
|
+
* - Omit to let the system automatically select an appropriate KMS contract
|
|
90
|
+
* - Specify only when: migrating KMS contracts, or selecting a specific contract on networks with multiple deployments
|
|
91
|
+
*
|
|
92
|
+
* ### Other Options
|
|
93
|
+
* - **disk_size**: Disk size in GB (optional)
|
|
94
|
+
* - Each instance type has a default disk size
|
|
95
|
+
* - Specify only if you need a different size than the default
|
|
96
|
+
* - **env_keys**: List of allowed environment variable keys
|
|
97
|
+
* - **listed**: Whether the CVM is publicly listed (default: true)
|
|
98
|
+
*
|
|
99
|
+
* ## Returns
|
|
100
|
+
*
|
|
101
|
+
* Provision data object containing:
|
|
102
|
+
* - **app_id**: Application identifier (required for commit step)
|
|
103
|
+
* - **app_env_encrypt_pubkey**: Public key for encrypting environment variables
|
|
104
|
+
* - **compose_hash**: Hash identifying this provision (required for commit step)
|
|
105
|
+
* - **device_id**: Device identifier for attestation
|
|
106
|
+
* - **fmspc**: Firmware Security Patch Configuration value
|
|
107
|
+
* - **os_image_hash**: Hash of the selected OS image
|
|
108
|
+
* - **instance_type**: The matched instance type identifier
|
|
109
|
+
*
|
|
45
110
|
* ## Safe Version
|
|
46
111
|
*
|
|
47
112
|
* Use `safeProvisionCvm` for error handling without exceptions:
|
|
@@ -50,6 +115,7 @@ import { type Client } from "../../client";
|
|
|
50
115
|
* const result = await safeProvisionCvm(client, app_compose);
|
|
51
116
|
* if (result.success) {
|
|
52
117
|
* console.log(result.data.app_id);
|
|
118
|
+
* console.log(result.data.compose_hash);
|
|
53
119
|
* } else {
|
|
54
120
|
* console.error('Failed to provision CVM:', result.error.message);
|
|
55
121
|
* }
|
|
@@ -62,6 +128,7 @@ export declare const ProvisionCvmSchema: z.ZodEffects<z.ZodObject<{
|
|
|
62
128
|
fmspc: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
129
|
device_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
64
130
|
os_image_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
131
|
+
instance_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
65
132
|
teepod_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
66
133
|
node_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
67
134
|
kms_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -72,6 +139,7 @@ export declare const ProvisionCvmSchema: z.ZodEffects<z.ZodObject<{
|
|
|
72
139
|
fmspc: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
73
140
|
device_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
74
141
|
os_image_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
142
|
+
instance_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
75
143
|
teepod_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
76
144
|
node_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
77
145
|
kms_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -82,6 +150,7 @@ export declare const ProvisionCvmSchema: z.ZodEffects<z.ZodObject<{
|
|
|
82
150
|
fmspc: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
83
151
|
device_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
84
152
|
os_image_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
153
|
+
instance_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
85
154
|
teepod_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
86
155
|
node_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
87
156
|
kms_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -92,6 +161,7 @@ export declare const ProvisionCvmSchema: z.ZodEffects<z.ZodObject<{
|
|
|
92
161
|
fmspc: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
93
162
|
device_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
94
163
|
os_image_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
164
|
+
instance_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
95
165
|
teepod_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
96
166
|
node_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
97
167
|
kms_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -102,6 +172,7 @@ export declare const ProvisionCvmSchema: z.ZodEffects<z.ZodObject<{
|
|
|
102
172
|
fmspc: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
103
173
|
device_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
104
174
|
os_image_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
175
|
+
instance_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
105
176
|
teepod_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
106
177
|
node_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
107
178
|
kms_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -110,23 +181,25 @@ export type ProvisionCvm = z.infer<typeof ProvisionCvmSchema>;
|
|
|
110
181
|
export declare const ProvisionCvmRequestSchema: z.ZodObject<{
|
|
111
182
|
node_id: z.ZodOptional<z.ZodNumber>;
|
|
112
183
|
teepod_id: z.ZodOptional<z.ZodNumber>;
|
|
184
|
+
region: z.ZodOptional<z.ZodString>;
|
|
113
185
|
name: z.ZodString;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
186
|
+
instance_type: z.ZodDefault<z.ZodString>;
|
|
187
|
+
image: z.ZodOptional<z.ZodString>;
|
|
188
|
+
vcpu: z.ZodOptional<z.ZodNumber>;
|
|
189
|
+
memory: z.ZodOptional<z.ZodNumber>;
|
|
190
|
+
disk_size: z.ZodOptional<z.ZodNumber>;
|
|
118
191
|
compose_file: z.ZodObject<{
|
|
119
192
|
allowed_envs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
120
193
|
pre_launch_script: z.ZodOptional<z.ZodString>;
|
|
121
194
|
docker_compose_file: z.ZodOptional<z.ZodString>;
|
|
122
|
-
name: z.ZodOptional<z.ZodString
|
|
195
|
+
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
123
196
|
kms_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
124
197
|
public_logs: z.ZodOptional<z.ZodBoolean>;
|
|
125
198
|
public_sysinfo: z.ZodOptional<z.ZodBoolean>;
|
|
126
199
|
gateway_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
127
200
|
tproxy_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
128
201
|
}, "strip", z.ZodTypeAny, {
|
|
129
|
-
name
|
|
202
|
+
name: string;
|
|
130
203
|
public_sysinfo?: boolean | undefined;
|
|
131
204
|
public_logs?: boolean | undefined;
|
|
132
205
|
docker_compose_file?: string | undefined;
|
|
@@ -147,29 +220,32 @@ export declare const ProvisionCvmRequestSchema: z.ZodObject<{
|
|
|
147
220
|
tproxy_enabled?: boolean | undefined;
|
|
148
221
|
}>;
|
|
149
222
|
listed: z.ZodOptional<z.ZodBoolean>;
|
|
150
|
-
instance_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
151
223
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
224
|
+
kms: z.ZodOptional<z.ZodEnum<["PHALA", "ETHEREUM", "BASE"]>>;
|
|
225
|
+
kms_contract: z.ZodOptional<z.ZodString>;
|
|
152
226
|
env_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
153
227
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
154
228
|
node_id: z.ZodOptional<z.ZodNumber>;
|
|
155
229
|
teepod_id: z.ZodOptional<z.ZodNumber>;
|
|
230
|
+
region: z.ZodOptional<z.ZodString>;
|
|
156
231
|
name: z.ZodString;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
232
|
+
instance_type: z.ZodDefault<z.ZodString>;
|
|
233
|
+
image: z.ZodOptional<z.ZodString>;
|
|
234
|
+
vcpu: z.ZodOptional<z.ZodNumber>;
|
|
235
|
+
memory: z.ZodOptional<z.ZodNumber>;
|
|
236
|
+
disk_size: z.ZodOptional<z.ZodNumber>;
|
|
161
237
|
compose_file: z.ZodObject<{
|
|
162
238
|
allowed_envs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
163
239
|
pre_launch_script: z.ZodOptional<z.ZodString>;
|
|
164
240
|
docker_compose_file: z.ZodOptional<z.ZodString>;
|
|
165
|
-
name: z.ZodOptional<z.ZodString
|
|
241
|
+
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
166
242
|
kms_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
167
243
|
public_logs: z.ZodOptional<z.ZodBoolean>;
|
|
168
244
|
public_sysinfo: z.ZodOptional<z.ZodBoolean>;
|
|
169
245
|
gateway_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
170
246
|
tproxy_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
171
247
|
}, "strip", z.ZodTypeAny, {
|
|
172
|
-
name
|
|
248
|
+
name: string;
|
|
173
249
|
public_sysinfo?: boolean | undefined;
|
|
174
250
|
public_logs?: boolean | undefined;
|
|
175
251
|
docker_compose_file?: string | undefined;
|
|
@@ -190,29 +266,32 @@ export declare const ProvisionCvmRequestSchema: z.ZodObject<{
|
|
|
190
266
|
tproxy_enabled?: boolean | undefined;
|
|
191
267
|
}>;
|
|
192
268
|
listed: z.ZodOptional<z.ZodBoolean>;
|
|
193
|
-
instance_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
194
269
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
270
|
+
kms: z.ZodOptional<z.ZodEnum<["PHALA", "ETHEREUM", "BASE"]>>;
|
|
271
|
+
kms_contract: z.ZodOptional<z.ZodString>;
|
|
195
272
|
env_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
196
273
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
197
274
|
node_id: z.ZodOptional<z.ZodNumber>;
|
|
198
275
|
teepod_id: z.ZodOptional<z.ZodNumber>;
|
|
276
|
+
region: z.ZodOptional<z.ZodString>;
|
|
199
277
|
name: z.ZodString;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
278
|
+
instance_type: z.ZodDefault<z.ZodString>;
|
|
279
|
+
image: z.ZodOptional<z.ZodString>;
|
|
280
|
+
vcpu: z.ZodOptional<z.ZodNumber>;
|
|
281
|
+
memory: z.ZodOptional<z.ZodNumber>;
|
|
282
|
+
disk_size: z.ZodOptional<z.ZodNumber>;
|
|
204
283
|
compose_file: z.ZodObject<{
|
|
205
284
|
allowed_envs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
206
285
|
pre_launch_script: z.ZodOptional<z.ZodString>;
|
|
207
286
|
docker_compose_file: z.ZodOptional<z.ZodString>;
|
|
208
|
-
name: z.ZodOptional<z.ZodString
|
|
287
|
+
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
209
288
|
kms_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
210
289
|
public_logs: z.ZodOptional<z.ZodBoolean>;
|
|
211
290
|
public_sysinfo: z.ZodOptional<z.ZodBoolean>;
|
|
212
291
|
gateway_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
213
292
|
tproxy_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
214
293
|
}, "strip", z.ZodTypeAny, {
|
|
215
|
-
name
|
|
294
|
+
name: string;
|
|
216
295
|
public_sysinfo?: boolean | undefined;
|
|
217
296
|
public_logs?: boolean | undefined;
|
|
218
297
|
docker_compose_file?: string | undefined;
|
|
@@ -233,8 +312,9 @@ export declare const ProvisionCvmRequestSchema: z.ZodObject<{
|
|
|
233
312
|
tproxy_enabled?: boolean | undefined;
|
|
234
313
|
}>;
|
|
235
314
|
listed: z.ZodOptional<z.ZodBoolean>;
|
|
236
|
-
instance_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
237
315
|
kms_id: z.ZodOptional<z.ZodString>;
|
|
316
|
+
kms: z.ZodOptional<z.ZodEnum<["PHALA", "ETHEREUM", "BASE"]>>;
|
|
317
|
+
kms_contract: z.ZodOptional<z.ZodString>;
|
|
238
318
|
env_keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
239
319
|
}, z.ZodTypeAny, "passthrough">>;
|
|
240
320
|
export type ProvisionCvmRequest = z.infer<typeof ProvisionCvmRequestSchema> & {
|
|
@@ -254,6 +334,7 @@ declare const provisionCvm: {
|
|
|
254
334
|
fmspc: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
255
335
|
device_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
256
336
|
os_image_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
337
|
+
instance_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
257
338
|
teepod_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
258
339
|
node_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
259
340
|
kms_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -272,6 +353,7 @@ declare const provisionCvm: {
|
|
|
272
353
|
fmspc: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
273
354
|
device_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
274
355
|
os_image_hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
356
|
+
instance_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
275
357
|
teepod_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
276
358
|
node_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
277
359
|
kms_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { getKmsList, safeGetKmsList, GetKmsListSchema, GetKmsListRequestSchema,
|
|
|
15
15
|
export { nextAppIds, safeNextAppIds, NextAppIdsSchema, NextAppIdsRequestSchema, type NextAppIdsRequest, type NextAppIds, } from "./kms/next_app_ids";
|
|
16
16
|
export { listWorkspaces, safeListWorkspaces, WorkspaceResponseSchema, ListWorkspacesSchema, PaginationMetadataSchema, type WorkspaceResponse, type ListWorkspaces, type PaginationMetadata, type ListWorkspacesRequest, } from "./workspaces/list_workspaces";
|
|
17
17
|
export { getWorkspace, safeGetWorkspace, } from "./workspaces/get_workspace";
|
|
18
|
-
export {
|
|
18
|
+
export { listAllInstanceTypeFamilies, safeListAllInstanceTypeFamilies, listFamilyInstanceTypes, safeListFamilyInstanceTypes, AllFamiliesResponseSchema, FamilyInstanceTypesResponseSchema, FamilyGroupSchema, InstanceTypeSchema, ListFamilyInstanceTypesRequestSchema, type AllFamiliesResponse, type FamilyInstanceTypesResponse, type FamilyGroup, type InstanceType, type ListFamilyInstanceTypesRequest, } from "./list-instance-types";
|
|
19
19
|
export { startCvm, safeStartCvm, StartCvmRequestSchema, type StartCvmRequest, } from "./cvms/start_cvm";
|
|
20
20
|
export { shutdownCvm, safeShutdownCvm, ShutdownCvmRequestSchema, type ShutdownCvmRequest, } from "./cvms/shutdown_cvm";
|
|
21
21
|
export { stopCvm, safeStopCvm, StopCvmRequestSchema, type StopCvmRequest, } from "./cvms/stop_cvm";
|
|
@@ -61,8 +61,6 @@ export declare const GetKmsListSchema: z.ZodObject<{
|
|
|
61
61
|
page_size: z.ZodNumber;
|
|
62
62
|
pages: z.ZodNumber;
|
|
63
63
|
}, "strict", z.ZodTypeAny, {
|
|
64
|
-
page: number;
|
|
65
|
-
page_size: number;
|
|
66
64
|
items: z.objectOutputType<{
|
|
67
65
|
id: z.ZodString;
|
|
68
66
|
slug: z.ZodNullable<z.ZodString>;
|
|
@@ -73,10 +71,10 @@ export declare const GetKmsListSchema: z.ZodObject<{
|
|
|
73
71
|
gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
|
|
74
72
|
}, z.ZodTypeAny, "passthrough">[];
|
|
75
73
|
total: number;
|
|
76
|
-
pages: number;
|
|
77
|
-
}, {
|
|
78
74
|
page: number;
|
|
79
75
|
page_size: number;
|
|
76
|
+
pages: number;
|
|
77
|
+
}, {
|
|
80
78
|
items: z.objectInputType<{
|
|
81
79
|
id: z.ZodString;
|
|
82
80
|
slug: z.ZodNullable<z.ZodString>;
|
|
@@ -87,6 +85,8 @@ export declare const GetKmsListSchema: z.ZodObject<{
|
|
|
87
85
|
gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
|
|
88
86
|
}, z.ZodTypeAny, "passthrough">[];
|
|
89
87
|
total: number;
|
|
88
|
+
page: number;
|
|
89
|
+
page_size: number;
|
|
90
90
|
pages: number;
|
|
91
91
|
}>;
|
|
92
92
|
export type GetKmsListRequest = z.infer<typeof GetKmsListRequestSchema>;
|