@phala/cloud 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1369,6 +1369,26 @@ var { action: getAppEnvEncryptPubKey, safeAction: safeGetAppEnvEncryptPubKey } =
1369
1369
  return await client.get(`/kms/${validatedRequest.kms}/pubkey/${validatedRequest.app_id}`);
1370
1370
  });
1371
1371
 
1372
+ // src/actions/kms/next_app_ids.ts
1373
+ import { z as z18 } from "zod";
1374
+ var NextAppIdsRequestSchema = z18.object({
1375
+ counts: z18.number().int().min(1).max(20).optional().default(1)
1376
+ }).strict();
1377
+ var NextAppIdsSchema = z18.object({
1378
+ app_ids: z18.array(
1379
+ z18.object({
1380
+ app_id: z18.string(),
1381
+ nonce: z18.number().int().min(0)
1382
+ })
1383
+ )
1384
+ }).strict();
1385
+ var { action: nextAppIds, safeAction: safeNextAppIds } = defineAction(NextAppIdsSchema, async (client, payload) => {
1386
+ const validatedRequest = NextAppIdsRequestSchema.parse(payload ?? {});
1387
+ const params = new URLSearchParams();
1388
+ params.append("counts", validatedRequest.counts.toString());
1389
+ return await client.get(`/kms/phala/next_app_id?${params.toString()}`);
1390
+ });
1391
+
1372
1392
  // src/actions/cvms/start_cvm.ts
1373
1393
  var StartCvmRequestSchema = CvmIdSchema;
1374
1394
  var { action: startCvm, safeAction: safeStartCvm } = defineAction(VMSchema, async (client, request) => {
@@ -1394,10 +1414,10 @@ var { action: shutdownCvm, safeAction: safeShutdownCvm } = defineAction(VMSchema
1394
1414
  });
1395
1415
 
1396
1416
  // src/actions/cvms/restart_cvm.ts
1397
- import { z as z18 } from "zod";
1417
+ import { z as z19 } from "zod";
1398
1418
  var RestartCvmRequestSchema = refineCvmId(
1399
1419
  CvmIdObjectSchema.extend({
1400
- force: z18.boolean().optional()
1420
+ force: z19.boolean().optional()
1401
1421
  })
1402
1422
  );
1403
1423
  var { action: restartCvm, safeAction: safeRestartCvm } = defineAction(VMSchema, async (client, request) => {
@@ -1408,10 +1428,10 @@ var { action: restartCvm, safeAction: safeRestartCvm } = defineAction(VMSchema,
1408
1428
  });
1409
1429
 
1410
1430
  // src/actions/cvms/delete_cvm.ts
1411
- import { z as z19 } from "zod";
1431
+ import { z as z20 } from "zod";
1412
1432
  var DeleteCvmRequestSchema = CvmIdSchema;
1413
1433
  var { action: deleteCvm, safeAction: safeDeleteCvm } = defineAction(
1414
- z19.void(),
1434
+ z20.void(),
1415
1435
  async (client, request) => {
1416
1436
  const { cvmId } = DeleteCvmRequestSchema.parse(request);
1417
1437
  await client.delete(`/cvms/${cvmId}`);
@@ -1420,41 +1440,41 @@ var { action: deleteCvm, safeAction: safeDeleteCvm } = defineAction(
1420
1440
  );
1421
1441
 
1422
1442
  // src/actions/cvms/get_cvm_stats.ts
1423
- import { z as z20 } from "zod";
1424
- var DiskInfoSchema = z20.object({
1425
- name: z20.string(),
1426
- mount_point: z20.string(),
1427
- total_size: z20.number(),
1428
- free_size: z20.number()
1443
+ import { z as z21 } from "zod";
1444
+ var DiskInfoSchema = z21.object({
1445
+ name: z21.string(),
1446
+ mount_point: z21.string(),
1447
+ total_size: z21.number(),
1448
+ free_size: z21.number()
1429
1449
  });
1430
- var SystemInfoSchema = z20.object({
1431
- os_name: z20.string(),
1432
- os_version: z20.string(),
1433
- kernel_version: z20.string(),
1434
- cpu_model: z20.string(),
1435
- num_cpus: z20.number(),
1436
- total_memory: z20.number(),
1437
- available_memory: z20.number(),
1438
- used_memory: z20.number(),
1439
- free_memory: z20.number(),
1440
- total_swap: z20.number(),
1441
- used_swap: z20.number(),
1442
- free_swap: z20.number(),
1443
- uptime: z20.number(),
1444
- loadavg_one: z20.number(),
1445
- loadavg_five: z20.number(),
1446
- loadavg_fifteen: z20.number(),
1447
- disks: z20.array(DiskInfoSchema)
1450
+ var SystemInfoSchema = z21.object({
1451
+ os_name: z21.string(),
1452
+ os_version: z21.string(),
1453
+ kernel_version: z21.string(),
1454
+ cpu_model: z21.string(),
1455
+ num_cpus: z21.number(),
1456
+ total_memory: z21.number(),
1457
+ available_memory: z21.number(),
1458
+ used_memory: z21.number(),
1459
+ free_memory: z21.number(),
1460
+ total_swap: z21.number(),
1461
+ used_swap: z21.number(),
1462
+ free_swap: z21.number(),
1463
+ uptime: z21.number(),
1464
+ loadavg_one: z21.number(),
1465
+ loadavg_five: z21.number(),
1466
+ loadavg_fifteen: z21.number(),
1467
+ disks: z21.array(DiskInfoSchema)
1448
1468
  });
1449
- var CvmSystemInfoSchema = z20.object({
1450
- is_online: z20.boolean(),
1451
- is_public: z20.boolean().default(false),
1452
- error: z20.string().nullable(),
1469
+ var CvmSystemInfoSchema = z21.object({
1470
+ is_online: z21.boolean(),
1471
+ is_public: z21.boolean().default(false),
1472
+ error: z21.string().nullable(),
1453
1473
  sysinfo: SystemInfoSchema.nullable(),
1454
- status: z20.string().nullable(),
1455
- in_progress: z20.boolean().default(false),
1456
- boot_progress: z20.string().nullable(),
1457
- boot_error: z20.string().nullable()
1474
+ status: z21.string().nullable(),
1475
+ in_progress: z21.boolean().default(false),
1476
+ boot_progress: z21.string().nullable(),
1477
+ boot_error: z21.string().nullable()
1458
1478
  });
1459
1479
  var GetCvmStatsRequestSchema = CvmIdSchema;
1460
1480
  var { action: getCvmStats, safeAction: safeGetCvmStats } = defineAction(CvmSystemInfoSchema, async (client, request) => {
@@ -1463,18 +1483,18 @@ var { action: getCvmStats, safeAction: safeGetCvmStats } = defineAction(CvmSyste
1463
1483
  });
1464
1484
 
1465
1485
  // src/actions/cvms/get_cvm_network.ts
1466
- import { z as z21 } from "zod";
1467
- var CvmNetworkUrlsSchema2 = z21.object({
1468
- app: z21.string(),
1469
- instance: z21.string()
1486
+ import { z as z22 } from "zod";
1487
+ var CvmNetworkUrlsSchema2 = z22.object({
1488
+ app: z22.string(),
1489
+ instance: z22.string()
1470
1490
  });
1471
- var CvmNetworkSchema = z21.object({
1472
- is_online: z21.boolean(),
1473
- is_public: z21.boolean().default(true),
1474
- error: z21.string().nullable(),
1475
- internal_ip: z21.string().nullable(),
1476
- latest_handshake: z21.string().nullable(),
1477
- public_urls: z21.array(CvmNetworkUrlsSchema2).nullable()
1491
+ var CvmNetworkSchema = z22.object({
1492
+ is_online: z22.boolean(),
1493
+ is_public: z22.boolean().default(true),
1494
+ error: z22.string().nullable(),
1495
+ internal_ip: z22.string().nullable(),
1496
+ latest_handshake: z22.string().nullable(),
1497
+ public_urls: z22.array(CvmNetworkUrlsSchema2).nullable()
1478
1498
  });
1479
1499
  var GetCvmNetworkRequestSchema = CvmIdSchema;
1480
1500
  var { action: getCvmNetwork, safeAction: safeGetCvmNetwork } = defineAction(CvmNetworkSchema, async (client, request) => {
@@ -1483,36 +1503,36 @@ var { action: getCvmNetwork, safeAction: safeGetCvmNetwork } = defineAction(CvmN
1483
1503
  });
1484
1504
 
1485
1505
  // src/actions/cvms/get_cvm_docker_compose.ts
1486
- import { z as z22 } from "zod";
1506
+ import { z as z23 } from "zod";
1487
1507
  var GetCvmDockerComposeRequestSchema = CvmIdSchema;
1488
- var { action: getCvmDockerCompose, safeAction: safeGetCvmDockerCompose } = defineAction(z22.string(), async (client, request) => {
1508
+ var { action: getCvmDockerCompose, safeAction: safeGetCvmDockerCompose } = defineAction(z23.string(), async (client, request) => {
1489
1509
  const { cvmId } = GetCvmDockerComposeRequestSchema.parse(request);
1490
1510
  return await client.get(`/cvms/${cvmId}/docker-compose.yml`);
1491
1511
  });
1492
1512
 
1493
1513
  // src/actions/cvms/get_cvm_containers_stats.ts
1494
- import { z as z23 } from "zod";
1495
- var ContainerInfoSchema = z23.object({
1496
- id: z23.string(),
1497
- names: z23.array(z23.string()),
1498
- image: z23.string(),
1499
- image_id: z23.string(),
1500
- command: z23.string().nullable().optional(),
1501
- created: z23.number(),
1502
- state: z23.string(),
1503
- status: z23.string(),
1504
- log_endpoint: z23.string().nullable()
1514
+ import { z as z24 } from "zod";
1515
+ var ContainerInfoSchema = z24.object({
1516
+ id: z24.string(),
1517
+ names: z24.array(z24.string()),
1518
+ image: z24.string(),
1519
+ image_id: z24.string(),
1520
+ command: z24.string().nullable().optional(),
1521
+ created: z24.number(),
1522
+ state: z24.string(),
1523
+ status: z24.string(),
1524
+ log_endpoint: z24.string().nullable()
1505
1525
  });
1506
- var CvmContainersStatsSchema = z23.object({
1507
- is_online: z23.boolean(),
1508
- is_public: z23.boolean().default(true),
1509
- error: z23.string().nullable(),
1510
- docker_compose_file: z23.string().nullable(),
1511
- manifest_version: z23.number().nullable(),
1512
- version: z23.string().nullable(),
1513
- runner: z23.string().nullable(),
1514
- features: z23.array(z23.string()).nullable(),
1515
- containers: z23.array(ContainerInfoSchema).nullable()
1526
+ var CvmContainersStatsSchema = z24.object({
1527
+ is_online: z24.boolean(),
1528
+ is_public: z24.boolean().default(true),
1529
+ error: z24.string().nullable(),
1530
+ docker_compose_file: z24.string().nullable(),
1531
+ manifest_version: z24.number().nullable(),
1532
+ version: z24.string().nullable(),
1533
+ runner: z24.string().nullable(),
1534
+ features: z24.array(z24.string()).nullable(),
1535
+ containers: z24.array(ContainerInfoSchema).nullable()
1516
1536
  });
1517
1537
  var GetCvmContainersStatsRequestSchema = CvmIdSchema;
1518
1538
  var { action: getCvmContainersStats, safeAction: safeGetCvmContainersStats } = defineAction(CvmContainersStatsSchema, async (client, request) => {
@@ -1521,62 +1541,62 @@ var { action: getCvmContainersStats, safeAction: safeGetCvmContainersStats } = d
1521
1541
  });
1522
1542
 
1523
1543
  // src/actions/cvms/get_cvm_attestation.ts
1524
- import { z as z24 } from "zod";
1525
- var CertificateSubjectSchema = z24.object({
1526
- common_name: z24.string().nullable(),
1527
- organization: z24.string().nullable(),
1528
- country: z24.string().nullable(),
1529
- state: z24.string().nullable(),
1530
- locality: z24.string().nullable()
1544
+ import { z as z25 } from "zod";
1545
+ var CertificateSubjectSchema = z25.object({
1546
+ common_name: z25.string().nullable(),
1547
+ organization: z25.string().nullable(),
1548
+ country: z25.string().nullable(),
1549
+ state: z25.string().nullable(),
1550
+ locality: z25.string().nullable()
1531
1551
  });
1532
- var CertificateIssuerSchema = z24.object({
1533
- common_name: z24.string().nullable(),
1534
- organization: z24.string().nullable(),
1535
- country: z24.string().nullable()
1552
+ var CertificateIssuerSchema = z25.object({
1553
+ common_name: z25.string().nullable(),
1554
+ organization: z25.string().nullable(),
1555
+ country: z25.string().nullable()
1536
1556
  });
1537
- var CertificateSchema = z24.object({
1557
+ var CertificateSchema = z25.object({
1538
1558
  subject: CertificateSubjectSchema,
1539
1559
  issuer: CertificateIssuerSchema,
1540
- serial_number: z24.string(),
1541
- not_before: z24.string(),
1560
+ serial_number: z25.string(),
1561
+ not_before: z25.string(),
1542
1562
  // datetime serialized as ISO string
1543
- not_after: z24.string(),
1563
+ not_after: z25.string(),
1544
1564
  // datetime serialized as ISO string
1545
- version: z24.string(),
1546
- fingerprint: z24.string(),
1547
- signature_algorithm: z24.string(),
1548
- sans: z24.array(z24.string()).nullable(),
1549
- is_ca: z24.boolean(),
1550
- position_in_chain: z24.number().nullable(),
1551
- quote: z24.string().nullable(),
1552
- app_id: z24.string().nullable().optional(),
1553
- cert_usage: z24.string().nullable().optional()
1565
+ version: z25.string(),
1566
+ fingerprint: z25.string(),
1567
+ signature_algorithm: z25.string(),
1568
+ sans: z25.array(z25.string()).nullable(),
1569
+ is_ca: z25.boolean(),
1570
+ position_in_chain: z25.number().nullable(),
1571
+ quote: z25.string().nullable(),
1572
+ app_id: z25.string().nullable().optional(),
1573
+ cert_usage: z25.string().nullable().optional()
1554
1574
  });
1555
- var EventLogSchema = z24.object({
1556
- imr: z24.number(),
1557
- event_type: z24.number(),
1558
- digest: z24.string(),
1559
- event: z24.string(),
1560
- event_payload: z24.string()
1575
+ var EventLogSchema = z25.object({
1576
+ imr: z25.number(),
1577
+ event_type: z25.number(),
1578
+ digest: z25.string(),
1579
+ event: z25.string(),
1580
+ event_payload: z25.string()
1561
1581
  });
1562
- var TcbInfoSchema = z24.object({
1563
- mrtd: z24.string(),
1564
- rootfs_hash: z24.string().nullable().optional(),
1565
- rtmr0: z24.string(),
1566
- rtmr1: z24.string(),
1567
- rtmr2: z24.string(),
1568
- rtmr3: z24.string(),
1569
- event_log: z24.array(EventLogSchema),
1570
- app_compose: z24.string()
1582
+ var TcbInfoSchema = z25.object({
1583
+ mrtd: z25.string(),
1584
+ rootfs_hash: z25.string().nullable().optional(),
1585
+ rtmr0: z25.string(),
1586
+ rtmr1: z25.string(),
1587
+ rtmr2: z25.string(),
1588
+ rtmr3: z25.string(),
1589
+ event_log: z25.array(EventLogSchema),
1590
+ app_compose: z25.string()
1571
1591
  });
1572
- var CvmAttestationSchema = z24.object({
1573
- name: z24.string().nullable(),
1574
- is_online: z24.boolean(),
1575
- is_public: z24.boolean().default(true),
1576
- error: z24.string().nullable(),
1577
- app_certificates: z24.array(CertificateSchema).nullable(),
1592
+ var CvmAttestationSchema = z25.object({
1593
+ name: z25.string().nullable(),
1594
+ is_online: z25.boolean(),
1595
+ is_public: z25.boolean().default(true),
1596
+ error: z25.string().nullable(),
1597
+ app_certificates: z25.array(CertificateSchema).nullable(),
1578
1598
  tcb_info: TcbInfoSchema.nullable(),
1579
- compose_file: z24.string().nullable()
1599
+ compose_file: z25.string().nullable()
1580
1600
  });
1581
1601
  var GetCvmAttestationRequestSchema = CvmIdSchema;
1582
1602
  var { action: getCvmAttestation, safeAction: safeGetCvmAttestation } = defineAction(CvmAttestationSchema, async (client, request) => {
@@ -1585,17 +1605,17 @@ var { action: getCvmAttestation, safeAction: safeGetCvmAttestation } = defineAct
1585
1605
  });
1586
1606
 
1587
1607
  // src/actions/cvms/update_cvm_resources.ts
1588
- import { z as z25 } from "zod";
1608
+ import { z as z26 } from "zod";
1589
1609
  var UpdateCvmResourcesRequestSchema = refineCvmId(
1590
1610
  CvmIdObjectSchema.extend({
1591
- vcpu: z25.number().optional(),
1592
- memory: z25.number().optional(),
1593
- disk_size: z25.number().optional(),
1594
- instance_type: z25.string().optional(),
1595
- allow_restart: z25.boolean().optional()
1611
+ vcpu: z26.number().optional(),
1612
+ memory: z26.number().optional(),
1613
+ disk_size: z26.number().optional(),
1614
+ instance_type: z26.string().optional(),
1615
+ allow_restart: z26.boolean().optional()
1596
1616
  })
1597
1617
  );
1598
- var { action: updateCvmResources, safeAction: safeUpdateCvmResources } = defineAction(z25.void(), async (client, request) => {
1618
+ var { action: updateCvmResources, safeAction: safeUpdateCvmResources } = defineAction(z26.void(), async (client, request) => {
1599
1619
  const parsed = UpdateCvmResourcesRequestSchema.parse(request);
1600
1620
  const { cvmId } = CvmIdSchema.parse(parsed);
1601
1621
  const { ...body } = parsed;
@@ -1604,11 +1624,11 @@ var { action: updateCvmResources, safeAction: safeUpdateCvmResources } = defineA
1604
1624
  });
1605
1625
 
1606
1626
  // src/actions/cvms/update_cvm_visibility.ts
1607
- import { z as z26 } from "zod";
1627
+ import { z as z27 } from "zod";
1608
1628
  var UpdateCvmVisibilityRequestSchema = refineCvmId(
1609
1629
  CvmIdObjectSchema.extend({
1610
- public_sysinfo: z26.boolean(),
1611
- public_logs: z26.boolean()
1630
+ public_sysinfo: z27.boolean(),
1631
+ public_logs: z27.boolean()
1612
1632
  })
1613
1633
  );
1614
1634
  var { action: updateCvmVisibility, safeAction: safeUpdateCvmVisibility } = defineAction(CvmLegacyDetailSchema, async (client, request) => {
@@ -1618,6 +1638,59 @@ var { action: updateCvmVisibility, safeAction: safeUpdateCvmVisibility } = defin
1618
1638
  return await client.patch(`/cvms/${cvmId}/visibility`, { public_sysinfo, public_logs });
1619
1639
  });
1620
1640
 
1641
+ // src/actions/cvms/get_available_os_images.ts
1642
+ import { z as z28 } from "zod";
1643
+ var OSImageVariantSchema = z28.object({
1644
+ name: z28.string(),
1645
+ os_image_hash: z28.string().nullable(),
1646
+ is_current: z28.boolean()
1647
+ });
1648
+ var AvailableOSImageSchema2 = z28.object({
1649
+ version: z28.union([
1650
+ z28.tuple([z28.number(), z28.number(), z28.number(), z28.number()]),
1651
+ z28.tuple([z28.number(), z28.number(), z28.number()])
1652
+ ]),
1653
+ prod: OSImageVariantSchema.nullable(),
1654
+ dev: OSImageVariantSchema.nullable()
1655
+ });
1656
+ var GetAvailableOSImagesResponseSchema = z28.array(AvailableOSImageSchema2);
1657
+ var GetAvailableOSImagesRequestSchema = CvmIdSchema;
1658
+ var { action: getAvailableOsImages, safeAction: safeGetAvailableOsImages } = defineAction(GetAvailableOSImagesResponseSchema, async (client, request) => {
1659
+ const { cvmId } = GetAvailableOSImagesRequestSchema.parse(request);
1660
+ return await client.get(`/cvms/${cvmId}/available-os-images`);
1661
+ });
1662
+
1663
+ // src/actions/cvms/update_os_image.ts
1664
+ import { z as z29 } from "zod";
1665
+ var UpdateOsImageRequestSchema = refineCvmId(
1666
+ CvmIdObjectSchema.extend({
1667
+ os_image_name: z29.string().min(1, "OS image name is required")
1668
+ })
1669
+ );
1670
+ var { action: updateOsImage, safeAction: safeUpdateOsImage } = defineAction(z29.void(), async (client, request) => {
1671
+ const parsed = UpdateOsImageRequestSchema.parse(request);
1672
+ const { cvmId } = CvmIdSchema.parse(parsed);
1673
+ const { os_image_name } = parsed;
1674
+ await client.patch(`/cvms/${cvmId}/os-image`, { os_image_name });
1675
+ return void 0;
1676
+ });
1677
+
1678
+ // src/actions/cvms/get_cvm_state.ts
1679
+ import { z as z30 } from "zod";
1680
+ var CvmStateSchema = z30.object({
1681
+ status: z30.string(),
1682
+ derived_status: z30.string().optional(),
1683
+ vm_uuid: z30.string().optional(),
1684
+ instance_id: z30.string().optional(),
1685
+ uptime: z30.string().optional()
1686
+ // Add other state fields as needed
1687
+ });
1688
+ var GetCvmStateRequestSchema = CvmIdSchema;
1689
+ var { action: getCvmState, safeAction: safeGetCvmState } = defineAction(CvmStateSchema, async (client, request) => {
1690
+ const { cvmId } = GetCvmStateRequestSchema.parse(request);
1691
+ return await client.get(`/cvms/${cvmId}/state`);
1692
+ });
1693
+
1621
1694
  // src/create-client.ts
1622
1695
  function createClient2(config = {}) {
1623
1696
  const client = createClient(config);
@@ -1670,18 +1743,26 @@ function createClient2(config = {}) {
1670
1743
  safeUpdateCvmResources,
1671
1744
  updateCvmVisibility,
1672
1745
  safeUpdateCvmVisibility,
1746
+ getAvailableOsImages,
1747
+ safeGetAvailableOsImages,
1748
+ updateOsImage,
1749
+ safeUpdateOsImage,
1673
1750
  getKmsInfo,
1674
1751
  safeGetKmsInfo,
1675
1752
  getKmsList,
1676
1753
  safeGetKmsList,
1677
1754
  getAppEnvEncryptPubKey,
1678
- safeGetAppEnvEncryptPubKey
1755
+ safeGetAppEnvEncryptPubKey,
1756
+ nextAppIds,
1757
+ safeNextAppIds,
1758
+ getCvmState,
1759
+ safeGetCvmState
1679
1760
  };
1680
1761
  return client.extend(allActions);
1681
1762
  }
1682
1763
 
1683
1764
  // src/actions/blockchains/deploy_app_auth.ts
1684
- import { z as z27 } from "zod";
1765
+ import { z as z31 } from "zod";
1685
1766
  import {
1686
1767
  createPublicClient as createPublicClient2,
1687
1768
  createWalletClient as createWalletClient2,
@@ -2342,25 +2423,25 @@ var kmsAuthAbi = [
2342
2423
  anonymous: false
2343
2424
  }
2344
2425
  ];
2345
- var DeployAppAuthRequestBaseSchema = z27.object({
2426
+ var DeployAppAuthRequestBaseSchema = z31.object({
2346
2427
  // Chain configuration (conditionally required)
2347
- chain: z27.unknown().optional(),
2348
- rpcUrl: z27.string().optional(),
2428
+ chain: z31.unknown().optional(),
2429
+ rpcUrl: z31.string().optional(),
2349
2430
  // Contract configuration (required)
2350
- kmsContractAddress: z27.string(),
2431
+ kmsContractAddress: z31.string(),
2351
2432
  // Authentication mode: either privateKey OR walletClient (required, mutually exclusive)
2352
- privateKey: z27.string().optional(),
2353
- walletClient: z27.unknown().optional(),
2433
+ privateKey: z31.string().optional(),
2434
+ walletClient: z31.unknown().optional(),
2354
2435
  // Public client (optional, will create default if not provided)
2355
- publicClient: z27.unknown().optional(),
2436
+ publicClient: z31.unknown().optional(),
2356
2437
  // App configuration (optional)
2357
- allowAnyDevice: z27.boolean().optional().default(false),
2358
- deviceId: z27.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
2359
- composeHash: z27.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
2360
- disableUpgrades: z27.boolean().optional().default(false),
2438
+ allowAnyDevice: z31.boolean().optional().default(false),
2439
+ deviceId: z31.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
2440
+ composeHash: z31.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
2441
+ disableUpgrades: z31.boolean().optional().default(false),
2361
2442
  // Validation configuration (optional)
2362
- skipPrerequisiteChecks: z27.boolean().optional().default(false),
2363
- minBalance: z27.string().optional()
2443
+ skipPrerequisiteChecks: z31.boolean().optional().default(false),
2444
+ minBalance: z31.string().optional()
2364
2445
  // ETH amount as string, e.g., "0.01"
2365
2446
  }).passthrough();
2366
2447
  var DeployAppAuthRequestSchema = DeployAppAuthRequestBaseSchema.refine(
@@ -2388,13 +2469,13 @@ var DeployAppAuthRequestSchema = DeployAppAuthRequestBaseSchema.refine(
2388
2469
  path: ["chain"]
2389
2470
  }
2390
2471
  );
2391
- var DeployAppAuthSchema = z27.object({
2392
- appId: z27.string(),
2393
- appAuthAddress: z27.string(),
2394
- deployer: z27.string(),
2395
- transactionHash: z27.string(),
2396
- blockNumber: z27.bigint().optional(),
2397
- gasUsed: z27.bigint().optional()
2472
+ var DeployAppAuthSchema = z31.object({
2473
+ appId: z31.string(),
2474
+ appAuthAddress: z31.string(),
2475
+ deployer: z31.string(),
2476
+ transactionHash: z31.string(),
2477
+ blockNumber: z31.bigint().optional(),
2478
+ gasUsed: z31.bigint().optional()
2398
2479
  }).passthrough();
2399
2480
  function parseDeploymentResult(receipt, deployer, kmsContractAddress) {
2400
2481
  try {
@@ -2640,7 +2721,7 @@ async function safeDeployAppAuth(request, parameters) {
2640
2721
  }
2641
2722
 
2642
2723
  // src/actions/blockchains/add_compose_hash.ts
2643
- import { z as z28 } from "zod";
2724
+ import { z as z32 } from "zod";
2644
2725
  import {
2645
2726
  createPublicClient as createPublicClient3,
2646
2727
  createWalletClient as createWalletClient3,
@@ -2664,29 +2745,29 @@ var appAuthAbi = [
2664
2745
  anonymous: false
2665
2746
  }
2666
2747
  ];
2667
- var AddComposeHashRequestSchema = z28.object({
2748
+ var AddComposeHashRequestSchema = z32.object({
2668
2749
  // Chain configuration (conditionally required)
2669
- chain: z28.unknown().optional(),
2670
- rpcUrl: z28.string().optional(),
2671
- appId: z28.string(),
2672
- composeHash: z28.string(),
2750
+ chain: z32.unknown().optional(),
2751
+ rpcUrl: z32.string().optional(),
2752
+ appId: z32.string(),
2753
+ composeHash: z32.string(),
2673
2754
  // Authentication mode: either privateKey OR walletClient (required, mutually exclusive)
2674
- privateKey: z28.string().optional(),
2675
- walletClient: z28.unknown().optional(),
2755
+ privateKey: z32.string().optional(),
2756
+ walletClient: z32.unknown().optional(),
2676
2757
  // Public client (optional, will create default if not provided)
2677
- publicClient: z28.unknown().optional(),
2758
+ publicClient: z32.unknown().optional(),
2678
2759
  // Validation configuration (optional)
2679
- skipPrerequisiteChecks: z28.boolean().optional().default(false),
2680
- minBalance: z28.string().optional(),
2760
+ skipPrerequisiteChecks: z32.boolean().optional().default(false),
2761
+ minBalance: z32.string().optional(),
2681
2762
  // ETH amount as string, e.g., "0.01"
2682
2763
  // Transaction control options
2683
- timeout: z28.number().optional().default(12e4),
2684
- retryOptions: z28.unknown().optional(),
2685
- signal: z28.unknown().optional(),
2764
+ timeout: z32.number().optional().default(12e4),
2765
+ retryOptions: z32.unknown().optional(),
2766
+ signal: z32.unknown().optional(),
2686
2767
  // Progress callbacks
2687
- onTransactionStateChange: z28.function().optional(),
2688
- onTransactionSubmitted: z28.function().optional(),
2689
- onTransactionConfirmed: z28.function().optional()
2768
+ onTransactionStateChange: z32.function().optional(),
2769
+ onTransactionSubmitted: z32.function().optional(),
2770
+ onTransactionConfirmed: z32.function().optional()
2690
2771
  }).passthrough().refine(
2691
2772
  (data) => {
2692
2773
  const hasPrivateKey = !!data.privateKey;
@@ -2710,12 +2791,12 @@ var AddComposeHashRequestSchema = z28.object({
2710
2791
  path: ["chain"]
2711
2792
  }
2712
2793
  );
2713
- var AddComposeHashSchema = z28.object({
2714
- composeHash: z28.string(),
2715
- appId: z28.string(),
2716
- transactionHash: z28.string(),
2717
- blockNumber: z28.bigint().optional(),
2718
- gasUsed: z28.bigint().optional()
2794
+ var AddComposeHashSchema = z32.object({
2795
+ composeHash: z32.string(),
2796
+ appId: z32.string(),
2797
+ transactionHash: z32.string(),
2798
+ blockNumber: z32.bigint().optional(),
2799
+ gasUsed: z32.bigint().optional()
2719
2800
  }).passthrough();
2720
2801
  function parseComposeHashResult(receipt, composeHash, appAuthAddress, appId) {
2721
2802
  console.log(receipt.logs);
@@ -2906,6 +2987,200 @@ async function safeAddComposeHash(request, parameters) {
2906
2987
  }
2907
2988
  }
2908
2989
 
2990
+ // src/actions/cvms/watch_cvm_state.ts
2991
+ import { z as z33 } from "zod";
2992
+ var WatchCvmStateParamsSchema = z33.object({
2993
+ target: z33.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),
2994
+ interval: z33.number().min(5).max(30).default(5).describe("Polling interval in seconds"),
2995
+ timeout: z33.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),
2996
+ maxRetries: z33.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),
2997
+ retryDelay: z33.number().min(0).default(5e3).describe("Delay between retries in milliseconds")
2998
+ });
2999
+ var WatchCvmStateRequestSchema = WatchCvmStateParamsSchema;
3000
+ var WatchAbortedError = class extends Error {
3001
+ constructor() {
3002
+ super("Watch operation was aborted");
3003
+ this.name = "WatchAbortedError";
3004
+ }
3005
+ };
3006
+ var MaxRetriesExceededError = class extends Error {
3007
+ constructor(attempts) {
3008
+ super(`Maximum retry attempts (${attempts}) exceeded`);
3009
+ this.attempts = attempts;
3010
+ this.name = "MaxRetriesExceededError";
3011
+ }
3012
+ };
3013
+ function parseSSEEvent(eventType, data) {
3014
+ try {
3015
+ const parsed = JSON.parse(data);
3016
+ return { type: eventType, data: parsed };
3017
+ } catch {
3018
+ return { type: "error", data: { error: "Failed to parse SSE event" } };
3019
+ }
3020
+ }
3021
+ async function watchCvmState(client, request, options = {}) {
3022
+ const { cvmId } = CvmIdSchema.parse(request);
3023
+ const { target, interval, timeout, maxRetries, retryDelay } = WatchCvmStateParamsSchema.parse(request);
3024
+ const { signal, onEvent } = options;
3025
+ let attempt = 0;
3026
+ while (attempt < maxRetries) {
3027
+ if (signal?.aborted) {
3028
+ throw new WatchAbortedError();
3029
+ }
3030
+ attempt++;
3031
+ try {
3032
+ const result = await watchSingleAttempt(
3033
+ client,
3034
+ cvmId,
3035
+ target,
3036
+ interval,
3037
+ timeout,
3038
+ signal,
3039
+ onEvent
3040
+ );
3041
+ if (result) {
3042
+ return result;
3043
+ }
3044
+ if (attempt >= maxRetries) {
3045
+ throw new MaxRetriesExceededError(attempt);
3046
+ }
3047
+ await sleep(retryDelay, signal);
3048
+ } catch (error) {
3049
+ if (signal?.aborted) {
3050
+ throw new WatchAbortedError();
3051
+ }
3052
+ if (error instanceof WatchAbortedError || error instanceof MaxRetriesExceededError) {
3053
+ throw error;
3054
+ }
3055
+ if (attempt >= maxRetries) {
3056
+ throw error;
3057
+ }
3058
+ if (onEvent) {
3059
+ onEvent({
3060
+ type: "error",
3061
+ data: { error: error instanceof Error ? error.message : String(error) }
3062
+ });
3063
+ }
3064
+ await sleep(retryDelay, signal);
3065
+ }
3066
+ }
3067
+ throw new MaxRetriesExceededError(attempt);
3068
+ }
3069
+ async function watchSingleAttempt(client, cvmId, target, interval, timeout, signal, onEvent) {
3070
+ const params = new URLSearchParams({
3071
+ target,
3072
+ interval: String(interval),
3073
+ timeout: String(timeout)
3074
+ });
3075
+ const baseURL = client.config.baseURL || "";
3076
+ const fullUrl = `${baseURL}/cvms/${cvmId}/state?${params.toString()}`;
3077
+ const headers = {
3078
+ Accept: "text/event-stream",
3079
+ "Cache-Control": "no-cache"
3080
+ };
3081
+ if (!client.config.useCookieAuth && client.config.apiKey) {
3082
+ headers["X-API-Key"] = client.config.apiKey;
3083
+ }
3084
+ if (client.config.headers) {
3085
+ Object.entries(client.config.headers).forEach(([key, value]) => {
3086
+ if (typeof value === "string") {
3087
+ headers[key] = value;
3088
+ }
3089
+ });
3090
+ }
3091
+ const response = await client.raw.native(fullUrl, {
3092
+ method: "GET",
3093
+ headers,
3094
+ signal,
3095
+ ...client.config.useCookieAuth ? { credentials: "include" } : {}
3096
+ });
3097
+ if (!response.ok) {
3098
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
3099
+ }
3100
+ if (!response.body) {
3101
+ throw new Error("Response body is null");
3102
+ }
3103
+ return parseSSEStream(response.body, signal, onEvent);
3104
+ }
3105
+ async function parseSSEStream(stream, signal, onEvent) {
3106
+ const reader = stream.getReader();
3107
+ const decoder = new TextDecoder();
3108
+ let buffer = "";
3109
+ let finalState = null;
3110
+ let currentEvent = "";
3111
+ let currentData = "";
3112
+ const processLine = (line) => {
3113
+ if (line.startsWith("event:")) {
3114
+ currentEvent = line.slice(6).trim();
3115
+ } else if (line.startsWith("data:")) {
3116
+ currentData = line.slice(5).trim();
3117
+ } else if (line === "") {
3118
+ if (currentEvent && currentData) {
3119
+ const event = parseSSEEvent(currentEvent, currentData);
3120
+ if (event.type === "state") {
3121
+ finalState = event.data;
3122
+ }
3123
+ onEvent?.(event);
3124
+ if (event.type === "complete") {
3125
+ return "complete";
3126
+ }
3127
+ if (event.type === "timeout") {
3128
+ return "timeout";
3129
+ }
3130
+ }
3131
+ currentEvent = "";
3132
+ currentData = "";
3133
+ }
3134
+ return null;
3135
+ };
3136
+ try {
3137
+ while (true) {
3138
+ if (signal?.aborted) {
3139
+ throw new WatchAbortedError();
3140
+ }
3141
+ const { done, value } = await reader.read();
3142
+ if (done) {
3143
+ break;
3144
+ }
3145
+ buffer += decoder.decode(value, { stream: true });
3146
+ const lines = buffer.split("\n");
3147
+ buffer = lines.pop() || "";
3148
+ for (const line of lines) {
3149
+ const result = processLine(line.trim());
3150
+ if (result === "complete") {
3151
+ return finalState;
3152
+ }
3153
+ if (result === "timeout") {
3154
+ return null;
3155
+ }
3156
+ }
3157
+ }
3158
+ return finalState;
3159
+ } catch (error) {
3160
+ if (error instanceof WatchAbortedError) {
3161
+ throw error;
3162
+ }
3163
+ throw new Error(`SSE stream error: ${error instanceof Error ? error.message : String(error)}`);
3164
+ } finally {
3165
+ reader.releaseLock();
3166
+ }
3167
+ }
3168
+ function sleep(ms, signal) {
3169
+ return new Promise((resolve, reject) => {
3170
+ if (signal?.aborted) {
3171
+ reject(new WatchAbortedError());
3172
+ return;
3173
+ }
3174
+ const timer = setTimeout(resolve, ms);
3175
+ if (signal) {
3176
+ signal.addEventListener("abort", () => {
3177
+ clearTimeout(timer);
3178
+ reject(new WatchAbortedError());
3179
+ });
3180
+ }
3181
+ });
3182
+ }
3183
+
2909
3184
  // src/parse_dotenv.ts
2910
3185
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
2911
3186
  function parseEnv(input) {
@@ -2964,12 +3239,15 @@ export {
2964
3239
  CvmNetworkSchema,
2965
3240
  CvmNetworkUrlsSchema,
2966
3241
  CvmNodeSchema,
3242
+ CvmStateSchema,
2967
3243
  CvmSystemInfoSchema,
2968
3244
  DeleteCvmRequestSchema,
2969
3245
  DeployAppAuthRequestSchema,
2970
3246
  DeployAppAuthSchema,
2971
3247
  GetAppEnvEncryptPubKeyRequestSchema,
2972
3248
  GetAppEnvEncryptPubKeySchema,
3249
+ GetAvailableOSImagesRequestSchema,
3250
+ GetAvailableOSImagesResponseSchema,
2973
3251
  GetCvmAttestationRequestSchema,
2974
3252
  GetCvmComposeFileRequestSchema,
2975
3253
  GetCvmContainersStatsRequestSchema,
@@ -2978,6 +3256,7 @@ export {
2978
3256
  GetCvmListRequestSchema,
2979
3257
  GetCvmListSchema,
2980
3258
  GetCvmNetworkRequestSchema,
3259
+ GetCvmStateRequestSchema,
2981
3260
  GetCvmStatsRequestSchema,
2982
3261
  GetKmsInfoRequestSchema,
2983
3262
  GetKmsListRequestSchema,
@@ -2987,7 +3266,11 @@ export {
2987
3266
  ListInstanceTypesRequestSchema,
2988
3267
  ListWorkspacesSchema,
2989
3268
  ManagedUserSchema,
3269
+ MaxRetriesExceededError,
2990
3270
  NetworkError,
3271
+ NextAppIdsRequestSchema,
3272
+ NextAppIdsSchema,
3273
+ OSImageVariantSchema,
2991
3274
  PaginatedInstanceTypesSchema,
2992
3275
  PaginationMetadataSchema,
2993
3276
  PhalaCloudError,
@@ -3006,10 +3289,13 @@ export {
3006
3289
  UnknownError,
3007
3290
  UpdateCvmResourcesRequestSchema,
3008
3291
  UpdateCvmVisibilityRequestSchema,
3292
+ UpdateOsImageRequestSchema,
3009
3293
  VMSchema,
3010
3294
  ValidationError,
3011
3295
  VmInfoSchema,
3012
3296
  WalletError,
3297
+ WatchAbortedError,
3298
+ WatchCvmStateRequestSchema,
3013
3299
  WorkspaceResponseSchema,
3014
3300
  addComposeHash,
3015
3301
  addNetwork,
@@ -3040,6 +3326,7 @@ export {
3040
3326
  formatValidationErrors,
3041
3327
  getAppEnvEncryptPubKey,
3042
3328
  getAvailableNodes,
3329
+ getAvailableOsImages,
3043
3330
  getComposeHash2 as getComposeHash,
3044
3331
  getCurrentUser,
3045
3332
  getCvmAttestation,
@@ -3049,6 +3336,7 @@ export {
3049
3336
  getCvmInfo,
3050
3337
  getCvmList,
3051
3338
  getCvmNetwork,
3339
+ getCvmState,
3052
3340
  getCvmStats,
3053
3341
  getErrorMessage,
3054
3342
  getKmsInfo,
@@ -3057,6 +3345,7 @@ export {
3057
3345
  getWorkspace,
3058
3346
  listInstanceTypes,
3059
3347
  listWorkspaces,
3348
+ nextAppIds,
3060
3349
  parseApiError,
3061
3350
  parseEnv,
3062
3351
  parseEnvVars,
@@ -3072,6 +3361,7 @@ export {
3072
3361
  safeDeployAppAuth,
3073
3362
  safeGetAppEnvEncryptPubKey,
3074
3363
  safeGetAvailableNodes,
3364
+ safeGetAvailableOsImages,
3075
3365
  safeGetCurrentUser,
3076
3366
  safeGetCvmAttestation,
3077
3367
  safeGetCvmComposeFile,
@@ -3080,12 +3370,14 @@ export {
3080
3370
  safeGetCvmInfo,
3081
3371
  safeGetCvmList,
3082
3372
  safeGetCvmNetwork,
3373
+ safeGetCvmState,
3083
3374
  safeGetCvmStats,
3084
3375
  safeGetKmsInfo,
3085
3376
  safeGetKmsList,
3086
3377
  safeGetWorkspace,
3087
3378
  safeListInstanceTypes,
3088
3379
  safeListWorkspaces,
3380
+ safeNextAppIds,
3089
3381
  safeProvisionCvm,
3090
3382
  safeProvisionCvmComposeFileUpdate,
3091
3383
  safeRestartCvm,
@@ -3094,6 +3386,7 @@ export {
3094
3386
  safeStopCvm,
3095
3387
  safeUpdateCvmResources,
3096
3388
  safeUpdateCvmVisibility,
3389
+ safeUpdateOsImage,
3097
3390
  safeValidateActionParameters,
3098
3391
  shutdownCvm,
3099
3392
  sortObject,
@@ -3102,9 +3395,11 @@ export {
3102
3395
  switchToNetwork,
3103
3396
  updateCvmResources,
3104
3397
  updateCvmVisibility,
3398
+ updateOsImage,
3105
3399
  validateActionParameters,
3106
3400
  validateNetworkPrerequisites,
3107
3401
  verifyEnvEncryptPublicKey,
3108
3402
  waitForTransactionReceipt,
3403
+ watchCvmState,
3109
3404
  withComposeMethods
3110
3405
  };