@phala/cloud 0.2.4 → 0.2.5

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.
Files changed (32) hide show
  1. package/dist/actions/apps/get_app_attestation.d.ts +963 -0
  2. package/dist/actions/apps/get_app_device_allowlist.d.ts +108 -0
  3. package/dist/actions/blockchains/abi/dstack_app.d.ts +101 -0
  4. package/dist/actions/blockchains/add_device.d.ts +62 -0
  5. package/dist/actions/blockchains/check_device_allowed.d.ts +44 -0
  6. package/dist/actions/blockchains/get_allowed_devices.d.ts +65 -0
  7. package/dist/actions/blockchains/remove_device.d.ts +62 -0
  8. package/dist/actions/blockchains/set_allow_any_device.d.ts +62 -0
  9. package/dist/actions/cvms/get_cvm_attestation.d.ts +220 -0
  10. package/dist/actions/cvms/get_cvm_compose_file.d.ts +16 -0
  11. package/dist/actions/cvms/provision_cvm.d.ts +26 -1
  12. package/dist/actions/cvms/provision_cvm_compose_file_update.d.ts +18 -0
  13. package/dist/actions/cvms/refresh_cvm_instance_id.d.ts +93 -0
  14. package/dist/actions/cvms/refresh_cvm_instance_ids.d.ts +194 -0
  15. package/dist/actions/cvms/replicate_cvm.d.ts +126 -0
  16. package/dist/actions/cvms/restart_cvm.d.ts +2 -2
  17. package/dist/actions/cvms/shutdown_cvm.d.ts +2 -2
  18. package/dist/actions/cvms/start_cvm.d.ts +2 -2
  19. package/dist/actions/cvms/stop_cvm.d.ts +2 -2
  20. package/dist/actions/index.d.ts +14 -1
  21. package/dist/actions/kms/get_kms_onchain_detail.d.ts +688 -0
  22. package/dist/actions/os_images/get_os_images.d.ts +217 -0
  23. package/dist/actions/workspaces/get_workspace.d.ts +2 -0
  24. package/dist/actions/workspaces/list_workspaces.d.ts +18 -0
  25. package/dist/create-client.d.ts +30 -0
  26. package/dist/index.js +1269 -251
  27. package/dist/index.mjs +1233 -251
  28. package/dist/types/app_compose.d.ts +5 -0
  29. package/dist/types/app_info_v20260121.d.ts +68 -0
  30. package/dist/types/cvm_info.d.ts +3 -3
  31. package/dist/types/cvm_info_v20260121.d.ts +22 -0
  32. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1066,7 +1066,8 @@ var WorkspaceResponseSchema = z7.object({
1066
1066
  tier: z7.string(),
1067
1067
  role: z7.string(),
1068
1068
  is_default: z7.boolean(),
1069
- created_at: z7.string()
1069
+ created_at: z7.string(),
1070
+ confidential_models_enabled: z7.boolean().optional()
1070
1071
  }).passthrough();
1071
1072
  var PaginationMetadataSchema = z7.object({
1072
1073
  has_more: z7.boolean(),
@@ -1255,6 +1256,7 @@ var CvmInfoV20260121Schema = z9.object({
1255
1256
  name: z9.string(),
1256
1257
  app_id: z9.string().nullable().optional(),
1257
1258
  vm_uuid: z9.string().nullable().optional(),
1259
+ instance_id: z9.string().nullable().optional(),
1258
1260
  resource: CvmResourceInfoV20260121Schema,
1259
1261
  node_info: NodeRefSchema.nullable().optional(),
1260
1262
  os: CvmOsInfoV20260121Schema.nullable().optional(),
@@ -1271,6 +1273,7 @@ var CvmInfoV20260121Schema = z9.object({
1271
1273
  public_tcbinfo: z9.boolean().optional(),
1272
1274
  gateway_enabled: z9.boolean().optional(),
1273
1275
  secure_time: z9.boolean().optional(),
1276
+ listed: z9.boolean().optional().default(false),
1274
1277
  storage_fs: z9.string().optional(),
1275
1278
  workspace: WorkspaceRefSchema.nullable().optional(),
1276
1279
  creator: UserRefSchema.nullable().optional()
@@ -1495,6 +1498,7 @@ var LooseAppComposeSchema = z12.object({
1495
1498
  public_logs: z12.boolean().optional(),
1496
1499
  public_sysinfo: z12.boolean().optional(),
1497
1500
  tproxy_enabled: z12.boolean().optional(),
1501
+ storage_fs: z12.enum(["ext4", "zfs"]).optional(),
1498
1502
  pre_launch_script: z12.string().optional(),
1499
1503
  env_pubkey: z12.string().optional(),
1500
1504
  salt: z12.string().optional().nullable()
@@ -1551,8 +1555,9 @@ var ProvisionCvmRequestSchema = z13.object({
1551
1555
  public_sysinfo: z13.boolean().optional(),
1552
1556
  gateway_enabled: z13.boolean().optional(),
1553
1557
  // recommended
1554
- tproxy_enabled: z13.boolean().optional()
1558
+ tproxy_enabled: z13.boolean().optional(),
1555
1559
  // deprecated, for compatibility
1560
+ storage_fs: z13.enum(["ext4", "zfs"]).optional()
1556
1561
  }).superRefine((data, ctx) => {
1557
1562
  validateComposePayloadSize(data.docker_compose_file, data.pre_launch_script, ctx);
1558
1563
  }),
@@ -2101,7 +2106,7 @@ var VMSchema = z25.object({
2101
2106
  vm_uuid: z25.string().nullable(),
2102
2107
  instance_id: z25.string().nullable(),
2103
2108
  app_url: z25.string().optional().nullable(),
2104
- base_image: z25.string().nullable(),
2109
+ base_image: z25.string().optional().nullable(),
2105
2110
  vcpu: z25.number(),
2106
2111
  memory: z25.number(),
2107
2112
  disk_size: z25.number(),
@@ -2519,6 +2524,66 @@ var { action: syncGithubSshKeys, safeAction: safeSyncGithubSshKeys } = defineSim
2519
2524
  }
2520
2525
  );
2521
2526
 
2527
+ // src/actions/os_images/get_os_images.ts
2528
+ import { z as z43 } from "zod";
2529
+ var OSImagePublicSchema = z43.object({
2530
+ name: z43.string(),
2531
+ slug: z43.string(),
2532
+ version: z43.string(),
2533
+ os_image_hash: z43.string().nullable(),
2534
+ is_dev: z43.boolean(),
2535
+ requires_gpu: z43.boolean()
2536
+ }).passthrough();
2537
+ var GetOsImagesRequestSchema = z43.object({
2538
+ page: z43.number().int().min(1).optional(),
2539
+ page_size: z43.number().int().min(1).optional(),
2540
+ is_dev: z43.boolean().optional()
2541
+ }).strict();
2542
+ var GetOsImagesResponseSchema = z43.object({
2543
+ items: z43.array(OSImagePublicSchema),
2544
+ total: z43.number(),
2545
+ page: z43.number(),
2546
+ page_size: z43.number(),
2547
+ pages: z43.number()
2548
+ }).passthrough();
2549
+ var { action: getOsImages, safeAction: safeGetOsImages } = defineAction(GetOsImagesResponseSchema, async (client, request) => {
2550
+ const validatedRequest = GetOsImagesRequestSchema.parse(request ?? {});
2551
+ return await client.get("/os-images", { params: validatedRequest });
2552
+ });
2553
+
2554
+ // src/actions/kms/get_kms_onchain_detail.ts
2555
+ import { z as z44 } from "zod";
2556
+ var OnChainDeviceSchema = z44.object({
2557
+ device_id: z44.string(),
2558
+ node_name: z44.string().nullable().optional(),
2559
+ on_chain_allowed: z44.boolean().nullable()
2560
+ }).passthrough();
2561
+ var OnChainOsImageSchema = z44.object({
2562
+ name: z44.string(),
2563
+ version: z44.string(),
2564
+ os_image_hash: z44.string().nullable(),
2565
+ on_chain_allowed: z44.boolean().nullable()
2566
+ }).passthrough();
2567
+ var OnChainKmsContractSchema = z44.object({
2568
+ contract_address: z44.string(),
2569
+ chain_id: z44.number(),
2570
+ chain_name: z44.string(),
2571
+ devices: z44.array(OnChainDeviceSchema),
2572
+ os_images: z44.array(OnChainOsImageSchema)
2573
+ }).passthrough();
2574
+ var GetKmsOnChainDetailResponseSchema = z44.object({
2575
+ chain_name: z44.string(),
2576
+ chain_id: z44.number(),
2577
+ contracts: z44.array(OnChainKmsContractSchema)
2578
+ }).passthrough();
2579
+ var GetKmsOnChainDetailRequestSchema = z44.object({
2580
+ chain: z44.string()
2581
+ }).strict();
2582
+ var { action: getKmsOnChainDetail, safeAction: safeGetKmsOnChainDetail } = defineAction(GetKmsOnChainDetailResponseSchema, async (client, request) => {
2583
+ const { chain } = GetKmsOnChainDetailRequestSchema.parse(request);
2584
+ return await client.get(`/kms/on-chain/${chain}`);
2585
+ });
2586
+
2522
2587
  // src/create-client.ts
2523
2588
  function createClient2(config = {}) {
2524
2589
  const client = createClient(config);
@@ -2604,167 +2669,171 @@ function createClient2(config = {}) {
2604
2669
  deleteSshKey,
2605
2670
  safeDeleteSshKey,
2606
2671
  syncGithubSshKeys,
2607
- safeSyncGithubSshKeys
2672
+ safeSyncGithubSshKeys,
2673
+ getOsImages,
2674
+ safeGetOsImages,
2675
+ getKmsOnChainDetail,
2676
+ safeGetKmsOnChainDetail
2608
2677
  };
2609
2678
  return client.extend(allActions);
2610
2679
  }
2611
2680
 
2612
2681
  // src/types/app_info_v20251028.ts
2613
- import { z as z43 } from "zod";
2614
- var CvmBasicInfoV20251028Schema = z43.object({
2615
- vm_uuid: z43.string().nullable(),
2616
- app_id: z43.string(),
2617
- name: z43.string().default(""),
2618
- status: z43.string(),
2619
- vcpu: z43.number().int(),
2620
- memory: z43.number().int(),
2621
- disk_size: z43.number().int(),
2622
- teepod_id: z43.number().int(),
2623
- teepod_name: z43.string(),
2624
- region_identifier: z43.string().nullable().optional(),
2625
- kms_type: z43.string().nullable().optional(),
2626
- instance_type: z43.string().nullable().optional(),
2627
- listed: z43.boolean().nullable().optional(),
2628
- base_image: z43.string().nullable().optional(),
2629
- kms_slug: z43.string().nullable().optional(),
2630
- kms_id: z43.string().nullable().optional(),
2631
- instance_id: z43.string().nullable().optional(),
2682
+ import { z as z45 } from "zod";
2683
+ var CvmBasicInfoV20251028Schema = z45.object({
2684
+ vm_uuid: z45.string().nullable(),
2685
+ app_id: z45.string(),
2686
+ name: z45.string().default(""),
2687
+ status: z45.string(),
2688
+ vcpu: z45.number().int(),
2689
+ memory: z45.number().int(),
2690
+ disk_size: z45.number().int(),
2691
+ teepod_id: z45.number().int(),
2692
+ teepod_name: z45.string(),
2693
+ region_identifier: z45.string().nullable().optional(),
2694
+ kms_type: z45.string().nullable().optional(),
2695
+ instance_type: z45.string().nullable().optional(),
2696
+ listed: z45.boolean().nullable().optional(),
2697
+ base_image: z45.string().nullable().optional(),
2698
+ kms_slug: z45.string().nullable().optional(),
2699
+ kms_id: z45.string().nullable().optional(),
2700
+ instance_id: z45.string().nullable().optional(),
2632
2701
  machine_info: MachineInfoV20251028Schema.nullable().optional(),
2633
- updated_at: z43.string().nullable().optional()
2702
+ updated_at: z45.string().nullable().optional()
2634
2703
  });
2635
- var AppProfileSchema = z43.object({
2636
- display_name: z43.string().nullable().optional(),
2637
- avatar_url: z43.string().nullable().optional(),
2638
- description: z43.string().nullable().optional(),
2639
- custom_domain: z43.string().nullable().optional()
2704
+ var AppProfileSchema = z45.object({
2705
+ display_name: z45.string().nullable().optional(),
2706
+ avatar_url: z45.string().nullable().optional(),
2707
+ description: z45.string().nullable().optional(),
2708
+ custom_domain: z45.string().nullable().optional()
2640
2709
  });
2641
- var DstackAppFullResponseV20251028Schema = z43.object({
2642
- id: z43.string(),
2643
- name: z43.string(),
2644
- app_id: z43.string(),
2645
- app_provision_type: z43.string().nullable().optional(),
2646
- app_icon_url: z43.string().nullable().optional(),
2647
- created_at: z43.string(),
2648
- kms_type: z43.string(),
2710
+ var DstackAppFullResponseV20251028Schema = z45.object({
2711
+ id: z45.string(),
2712
+ name: z45.string(),
2713
+ app_id: z45.string(),
2714
+ app_provision_type: z45.string().nullable().optional(),
2715
+ app_icon_url: z45.string().nullable().optional(),
2716
+ created_at: z45.string(),
2717
+ kms_type: z45.string(),
2649
2718
  profile: AppProfileSchema.nullable().optional(),
2650
2719
  current_cvm: CvmBasicInfoV20251028Schema.nullable().optional(),
2651
- cvms: z43.array(CvmBasicInfoV20251028Schema).default([]),
2652
- cvm_count: z43.number().int().default(0)
2720
+ cvms: z45.array(CvmBasicInfoV20251028Schema).default([]),
2721
+ cvm_count: z45.number().int().default(0)
2653
2722
  });
2654
- var DstackAppMinimalResponseV20251028Schema = z43.object({
2655
- id: z43.null().optional(),
2656
- app_id: z43.string(),
2657
- name: z43.null().optional(),
2658
- app_provision_type: z43.null().optional(),
2659
- app_icon_url: z43.null().optional(),
2660
- created_at: z43.null().optional(),
2661
- kms_type: z43.null().optional(),
2662
- current_cvm: z43.null().optional(),
2663
- cvms: z43.null().optional(),
2664
- cvm_count: z43.null().optional()
2723
+ var DstackAppMinimalResponseV20251028Schema = z45.object({
2724
+ id: z45.null().optional(),
2725
+ app_id: z45.string(),
2726
+ name: z45.null().optional(),
2727
+ app_provision_type: z45.null().optional(),
2728
+ app_icon_url: z45.null().optional(),
2729
+ created_at: z45.null().optional(),
2730
+ kms_type: z45.null().optional(),
2731
+ current_cvm: z45.null().optional(),
2732
+ cvms: z45.null().optional(),
2733
+ cvm_count: z45.null().optional()
2665
2734
  });
2666
- var DstackAppWithCvmResponseV20251028Schema = z43.union([
2735
+ var DstackAppWithCvmResponseV20251028Schema = z45.union([
2667
2736
  DstackAppFullResponseV20251028Schema,
2668
2737
  DstackAppMinimalResponseV20251028Schema
2669
2738
  ]);
2670
- var DstackAppListResponseV20251028Schema = z43.object({
2671
- dstack_apps: z43.array(DstackAppWithCvmResponseV20251028Schema),
2672
- page: z43.number().int(),
2673
- page_size: z43.number().int(),
2674
- total: z43.number().int(),
2675
- total_pages: z43.number().int()
2739
+ var DstackAppListResponseV20251028Schema = z45.object({
2740
+ dstack_apps: z45.array(DstackAppWithCvmResponseV20251028Schema),
2741
+ page: z45.number().int(),
2742
+ page_size: z45.number().int(),
2743
+ total: z45.number().int(),
2744
+ total_pages: z45.number().int()
2676
2745
  });
2677
2746
 
2678
2747
  // src/types/app_info_v20260121.ts
2679
- import { z as z44 } from "zod";
2680
- var DstackAppFullResponseV20260121Schema = z44.object({
2681
- id: z44.string(),
2682
- name: z44.string(),
2683
- app_id: z44.string(),
2684
- app_provision_type: z44.string().nullable().optional(),
2685
- app_icon_url: z44.string().nullable().optional(),
2686
- created_at: z44.string(),
2687
- kms_type: z44.string(),
2688
- profile: z44.object({
2689
- display_name: z44.string().nullable().optional(),
2690
- avatar_url: z44.string().nullable().optional(),
2691
- description: z44.string().nullable().optional(),
2692
- custom_domain: z44.string().nullable().optional()
2748
+ import { z as z46 } from "zod";
2749
+ var DstackAppFullResponseV20260121Schema = z46.object({
2750
+ id: z46.string(),
2751
+ name: z46.string(),
2752
+ app_id: z46.string(),
2753
+ app_provision_type: z46.string().nullable().optional(),
2754
+ app_icon_url: z46.string().nullable().optional(),
2755
+ created_at: z46.string(),
2756
+ kms_type: z46.string(),
2757
+ profile: z46.object({
2758
+ display_name: z46.string().nullable().optional(),
2759
+ avatar_url: z46.string().nullable().optional(),
2760
+ description: z46.string().nullable().optional(),
2761
+ custom_domain: z46.string().nullable().optional()
2693
2762
  }).nullable().optional(),
2694
2763
  current_cvm: CvmInfoV20260121Schema.nullable().optional(),
2695
- cvms: z44.array(CvmInfoV20260121Schema).default([]),
2696
- cvm_count: z44.number().int().default(0)
2764
+ cvms: z46.array(CvmInfoV20260121Schema).default([]),
2765
+ cvm_count: z46.number().int().default(0)
2697
2766
  });
2698
- var DstackAppMinimalResponseV20260121Schema = z44.object({
2699
- id: z44.null().optional(),
2700
- app_id: z44.string(),
2701
- name: z44.null().optional(),
2702
- app_provision_type: z44.null().optional(),
2703
- app_icon_url: z44.null().optional(),
2704
- created_at: z44.null().optional(),
2705
- kms_type: z44.null().optional(),
2706
- current_cvm: z44.null().optional(),
2707
- cvms: z44.null().optional(),
2708
- cvm_count: z44.null().optional()
2767
+ var DstackAppMinimalResponseV20260121Schema = z46.object({
2768
+ id: z46.null().optional(),
2769
+ app_id: z46.string(),
2770
+ name: z46.null().optional(),
2771
+ app_provision_type: z46.null().optional(),
2772
+ app_icon_url: z46.null().optional(),
2773
+ created_at: z46.null().optional(),
2774
+ kms_type: z46.null().optional(),
2775
+ current_cvm: z46.null().optional(),
2776
+ cvms: z46.null().optional(),
2777
+ cvm_count: z46.null().optional()
2709
2778
  });
2710
- var DstackAppWithCvmResponseV20260121Schema = z44.union([
2779
+ var DstackAppWithCvmResponseV20260121Schema = z46.union([
2711
2780
  DstackAppFullResponseV20260121Schema,
2712
2781
  DstackAppMinimalResponseV20260121Schema
2713
2782
  ]);
2714
- var DstackAppListResponseV20260121Schema = z44.object({
2715
- dstack_apps: z44.array(DstackAppWithCvmResponseV20260121Schema),
2716
- page: z44.number().int(),
2717
- page_size: z44.number().int(),
2718
- total: z44.number().int(),
2719
- total_pages: z44.number().int()
2783
+ var DstackAppListResponseV20260121Schema = z46.object({
2784
+ dstack_apps: z46.array(DstackAppWithCvmResponseV20260121Schema),
2785
+ page: z46.number().int(),
2786
+ page_size: z46.number().int(),
2787
+ total: z46.number().int(),
2788
+ total_pages: z46.number().int()
2720
2789
  });
2721
2790
 
2722
2791
  // src/types/app_revision.ts
2723
- import { z as z45 } from "zod";
2724
- var CvmRefSchema = z45.object({
2725
- object_type: z45.literal("cvm"),
2726
- id: z45.string().nullable().optional(),
2727
- name: z45.string().nullable().optional(),
2728
- app_id: z45.string().nullable().optional(),
2729
- vm_uuid: z45.string().nullable().optional()
2792
+ import { z as z47 } from "zod";
2793
+ var CvmRefSchema = z47.object({
2794
+ object_type: z47.literal("cvm"),
2795
+ id: z47.string().nullable().optional(),
2796
+ name: z47.string().nullable().optional(),
2797
+ app_id: z47.string().nullable().optional(),
2798
+ vm_uuid: z47.string().nullable().optional()
2730
2799
  });
2731
- var AppRevisionResponseSchema = z45.object({
2732
- revision_id: z45.string(),
2733
- app_id: z45.string(),
2734
- vm_uuid: z45.string(),
2735
- compose_hash: z45.string(),
2736
- created_at: z45.string(),
2737
- trace_id: z45.string().nullable().optional(),
2738
- operation_type: z45.string(),
2800
+ var AppRevisionResponseSchema = z47.object({
2801
+ revision_id: z47.string(),
2802
+ app_id: z47.string(),
2803
+ vm_uuid: z47.string(),
2804
+ compose_hash: z47.string(),
2805
+ created_at: z47.string(),
2806
+ trace_id: z47.string().nullable().optional(),
2807
+ operation_type: z47.string(),
2739
2808
  triggered_by: UserRefSchema.nullable().optional(),
2740
2809
  cvm: CvmRefSchema.nullable().optional(),
2741
2810
  workspace: WorkspaceRefSchema.nullable().optional()
2742
2811
  });
2743
- var AppRevisionDetailResponseSchema = z45.object({
2744
- revision_id: z45.string(),
2745
- app_id: z45.string(),
2746
- vm_uuid: z45.string(),
2747
- compose_hash: z45.string(),
2748
- compose_file: z45.union([z45.record(z45.any()), z45.string()]).nullable().optional(),
2749
- encrypted_env: z45.string(),
2750
- user_config: z45.string(),
2751
- created_at: z45.string(),
2752
- trace_id: z45.string().nullable().optional(),
2753
- operation_type: z45.string(),
2812
+ var AppRevisionDetailResponseSchema = z47.object({
2813
+ revision_id: z47.string(),
2814
+ app_id: z47.string(),
2815
+ vm_uuid: z47.string(),
2816
+ compose_hash: z47.string(),
2817
+ compose_file: z47.union([z47.record(z47.any()), z47.string()]).nullable().optional(),
2818
+ encrypted_env: z47.string(),
2819
+ user_config: z47.string(),
2820
+ created_at: z47.string(),
2821
+ trace_id: z47.string().nullable().optional(),
2822
+ operation_type: z47.string(),
2754
2823
  triggered_by: UserRefSchema.nullable().optional(),
2755
2824
  cvm: CvmRefSchema.nullable().optional(),
2756
2825
  workspace: WorkspaceRefSchema.nullable().optional()
2757
2826
  });
2758
- var AppRevisionsResponseSchema = z45.object({
2759
- revisions: z45.array(AppRevisionResponseSchema),
2760
- total: z45.number().int(),
2761
- page: z45.number().int(),
2762
- page_size: z45.number().int(),
2763
- total_pages: z45.number().int()
2827
+ var AppRevisionsResponseSchema = z47.object({
2828
+ revisions: z47.array(AppRevisionResponseSchema),
2829
+ total: z47.number().int(),
2830
+ page: z47.number().int(),
2831
+ page_size: z47.number().int(),
2832
+ total_pages: z47.number().int()
2764
2833
  });
2765
2834
 
2766
2835
  // src/actions/blockchains/deploy_app_auth.ts
2767
- import { z as z46 } from "zod";
2836
+ import { z as z48 } from "zod";
2768
2837
  import {
2769
2838
  createPublicClient as createPublicClient2,
2770
2839
  createWalletClient as createWalletClient2,
@@ -3425,25 +3494,25 @@ var kmsAuthAbi = [
3425
3494
  anonymous: false
3426
3495
  }
3427
3496
  ];
3428
- var DeployAppAuthRequestBaseSchema = z46.object({
3497
+ var DeployAppAuthRequestBaseSchema = z48.object({
3429
3498
  // Chain configuration (conditionally required)
3430
- chain: z46.unknown().optional(),
3431
- rpcUrl: z46.string().optional(),
3499
+ chain: z48.unknown().optional(),
3500
+ rpcUrl: z48.string().optional(),
3432
3501
  // Contract configuration (required)
3433
- kmsContractAddress: z46.string(),
3502
+ kmsContractAddress: z48.string(),
3434
3503
  // Authentication mode: either privateKey OR walletClient (required, mutually exclusive)
3435
- privateKey: z46.string().optional(),
3436
- walletClient: z46.unknown().optional(),
3504
+ privateKey: z48.string().optional(),
3505
+ walletClient: z48.unknown().optional(),
3437
3506
  // Public client (optional, will create default if not provided)
3438
- publicClient: z46.unknown().optional(),
3507
+ publicClient: z48.unknown().optional(),
3439
3508
  // App configuration (optional)
3440
- allowAnyDevice: z46.boolean().optional().default(false),
3441
- deviceId: z46.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
3442
- composeHash: z46.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
3443
- disableUpgrades: z46.boolean().optional().default(false),
3509
+ allowAnyDevice: z48.boolean().optional().default(false),
3510
+ deviceId: z48.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
3511
+ composeHash: z48.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
3512
+ disableUpgrades: z48.boolean().optional().default(false),
3444
3513
  // Validation configuration (optional)
3445
- skipPrerequisiteChecks: z46.boolean().optional().default(false),
3446
- minBalance: z46.string().optional()
3514
+ skipPrerequisiteChecks: z48.boolean().optional().default(false),
3515
+ minBalance: z48.string().optional()
3447
3516
  // ETH amount as string, e.g., "0.01"
3448
3517
  }).passthrough();
3449
3518
  var DeployAppAuthRequestSchema = DeployAppAuthRequestBaseSchema.refine(
@@ -3471,13 +3540,13 @@ var DeployAppAuthRequestSchema = DeployAppAuthRequestBaseSchema.refine(
3471
3540
  path: ["chain"]
3472
3541
  }
3473
3542
  );
3474
- var DeployAppAuthSchema = z46.object({
3475
- appId: z46.string(),
3476
- appAuthAddress: z46.string(),
3477
- deployer: z46.string(),
3478
- transactionHash: z46.string(),
3479
- blockNumber: z46.bigint().optional(),
3480
- gasUsed: z46.bigint().optional()
3543
+ var DeployAppAuthSchema = z48.object({
3544
+ appId: z48.string(),
3545
+ appAuthAddress: z48.string(),
3546
+ deployer: z48.string(),
3547
+ transactionHash: z48.string(),
3548
+ blockNumber: z48.bigint().optional(),
3549
+ gasUsed: z48.bigint().optional()
3481
3550
  }).passthrough();
3482
3551
  function parseDeploymentResult(receipt, deployer, kmsContractAddress) {
3483
3552
  try {
@@ -3723,7 +3792,7 @@ async function safeDeployAppAuth(request, parameters) {
3723
3792
  }
3724
3793
 
3725
3794
  // src/actions/blockchains/add_compose_hash.ts
3726
- import { z as z47 } from "zod";
3795
+ import { z as z49 } from "zod";
3727
3796
  import {
3728
3797
  createPublicClient as createPublicClient3,
3729
3798
  createWalletClient as createWalletClient3,
@@ -3747,29 +3816,29 @@ var appAuthAbi = [
3747
3816
  anonymous: false
3748
3817
  }
3749
3818
  ];
3750
- var AddComposeHashRequestSchema = z47.object({
3819
+ var AddComposeHashRequestSchema = z49.object({
3751
3820
  // Chain configuration (conditionally required)
3752
- chain: z47.unknown().optional(),
3753
- rpcUrl: z47.string().optional(),
3754
- appId: z47.string(),
3755
- composeHash: z47.string(),
3821
+ chain: z49.unknown().optional(),
3822
+ rpcUrl: z49.string().optional(),
3823
+ appId: z49.string(),
3824
+ composeHash: z49.string(),
3756
3825
  // Authentication mode: either privateKey OR walletClient (required, mutually exclusive)
3757
- privateKey: z47.string().optional(),
3758
- walletClient: z47.unknown().optional(),
3826
+ privateKey: z49.string().optional(),
3827
+ walletClient: z49.unknown().optional(),
3759
3828
  // Public client (optional, will create default if not provided)
3760
- publicClient: z47.unknown().optional(),
3829
+ publicClient: z49.unknown().optional(),
3761
3830
  // Validation configuration (optional)
3762
- skipPrerequisiteChecks: z47.boolean().optional().default(false),
3763
- minBalance: z47.string().optional(),
3831
+ skipPrerequisiteChecks: z49.boolean().optional().default(false),
3832
+ minBalance: z49.string().optional(),
3764
3833
  // ETH amount as string, e.g., "0.01"
3765
3834
  // Transaction control options
3766
- timeout: z47.number().optional().default(12e4),
3767
- retryOptions: z47.unknown().optional(),
3768
- signal: z47.unknown().optional(),
3835
+ timeout: z49.number().optional().default(12e4),
3836
+ retryOptions: z49.unknown().optional(),
3837
+ signal: z49.unknown().optional(),
3769
3838
  // Progress callbacks
3770
- onTransactionStateChange: z47.function().optional(),
3771
- onTransactionSubmitted: z47.function().optional(),
3772
- onTransactionConfirmed: z47.function().optional()
3839
+ onTransactionStateChange: z49.function().optional(),
3840
+ onTransactionSubmitted: z49.function().optional(),
3841
+ onTransactionConfirmed: z49.function().optional()
3773
3842
  }).passthrough().refine(
3774
3843
  (data) => {
3775
3844
  const hasPrivateKey = !!data.privateKey;
@@ -3793,12 +3862,12 @@ var AddComposeHashRequestSchema = z47.object({
3793
3862
  path: ["chain"]
3794
3863
  }
3795
3864
  );
3796
- var AddComposeHashSchema = z47.object({
3797
- composeHash: z47.string(),
3798
- appId: z47.string(),
3799
- transactionHash: z47.string(),
3800
- blockNumber: z47.bigint().optional(),
3801
- gasUsed: z47.bigint().optional()
3865
+ var AddComposeHashSchema = z49.object({
3866
+ composeHash: z49.string(),
3867
+ appId: z49.string(),
3868
+ transactionHash: z49.string(),
3869
+ blockNumber: z49.bigint().optional(),
3870
+ gasUsed: z49.bigint().optional()
3802
3871
  }).passthrough();
3803
3872
  function parseComposeHashResult(receipt, composeHash, appAuthAddress, appId) {
3804
3873
  console.log(receipt.logs);
@@ -3989,16 +4058,721 @@ async function safeAddComposeHash(request, parameters) {
3989
4058
  }
3990
4059
  }
3991
4060
 
4061
+ // src/actions/blockchains/add_device.ts
4062
+ import { z as z50 } from "zod";
4063
+ import {
4064
+ createPublicClient as createPublicClient4,
4065
+ createWalletClient as createWalletClient4,
4066
+ http as http4,
4067
+ parseEther as parseEther3
4068
+ } from "viem";
4069
+ import { privateKeyToAccount as privateKeyToAccount4 } from "viem/accounts";
4070
+
4071
+ // src/actions/blockchains/abi/dstack_app.ts
4072
+ var dstackAppAbi = [
4073
+ // ── Write functions ──────────────────────────────────────────────
4074
+ {
4075
+ inputs: [{ internalType: "bytes32", name: "deviceId", type: "bytes32" }],
4076
+ name: "addDevice",
4077
+ outputs: [],
4078
+ stateMutability: "nonpayable",
4079
+ type: "function"
4080
+ },
4081
+ {
4082
+ inputs: [{ internalType: "bytes32", name: "deviceId", type: "bytes32" }],
4083
+ name: "removeDevice",
4084
+ outputs: [],
4085
+ stateMutability: "nonpayable",
4086
+ type: "function"
4087
+ },
4088
+ {
4089
+ inputs: [{ internalType: "bool", name: "_allowAnyDevice", type: "bool" }],
4090
+ name: "setAllowAnyDevice",
4091
+ outputs: [],
4092
+ stateMutability: "nonpayable",
4093
+ type: "function"
4094
+ },
4095
+ // ── Read functions ───────────────────────────────────────────────
4096
+ {
4097
+ inputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
4098
+ name: "allowedDeviceIds",
4099
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
4100
+ stateMutability: "view",
4101
+ type: "function"
4102
+ },
4103
+ {
4104
+ inputs: [],
4105
+ name: "allowAnyDevice",
4106
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
4107
+ stateMutability: "view",
4108
+ type: "function"
4109
+ },
4110
+ {
4111
+ inputs: [],
4112
+ name: "owner",
4113
+ outputs: [{ internalType: "address", name: "", type: "address" }],
4114
+ stateMutability: "view",
4115
+ type: "function"
4116
+ },
4117
+ // ── Events ───────────────────────────────────────────────────────
4118
+ {
4119
+ anonymous: false,
4120
+ inputs: [{ indexed: false, internalType: "bytes32", name: "deviceId", type: "bytes32" }],
4121
+ name: "DeviceAdded",
4122
+ type: "event"
4123
+ },
4124
+ {
4125
+ anonymous: false,
4126
+ inputs: [{ indexed: false, internalType: "bytes32", name: "deviceId", type: "bytes32" }],
4127
+ name: "DeviceRemoved",
4128
+ type: "event"
4129
+ },
4130
+ {
4131
+ anonymous: false,
4132
+ inputs: [{ indexed: false, internalType: "bool", name: "allowAny", type: "bool" }],
4133
+ name: "AllowAnyDeviceSet",
4134
+ type: "event"
4135
+ }
4136
+ ];
4137
+
4138
+ // src/actions/blockchains/add_device.ts
4139
+ var AddDeviceRequestSchema = z50.object({
4140
+ chain: z50.unknown().optional(),
4141
+ rpcUrl: z50.string().optional(),
4142
+ appAddress: z50.string(),
4143
+ deviceId: z50.string(),
4144
+ privateKey: z50.string().optional(),
4145
+ walletClient: z50.unknown().optional(),
4146
+ publicClient: z50.unknown().optional(),
4147
+ skipPrerequisiteChecks: z50.boolean().optional().default(false),
4148
+ minBalance: z50.string().optional(),
4149
+ timeout: z50.number().optional().default(12e4),
4150
+ retryOptions: z50.unknown().optional(),
4151
+ signal: z50.unknown().optional(),
4152
+ onTransactionStateChange: z50.function().optional(),
4153
+ onTransactionSubmitted: z50.function().optional(),
4154
+ onTransactionConfirmed: z50.function().optional()
4155
+ }).passthrough().refine((data) => !!data.privateKey !== !!data.walletClient, {
4156
+ message: "Either 'privateKey' or 'walletClient' must be provided, but not both",
4157
+ path: ["privateKey", "walletClient"]
4158
+ }).refine(
4159
+ (data) => {
4160
+ if (!!data.publicClient && !!data.walletClient) return true;
4161
+ return !!data.chain;
4162
+ },
4163
+ {
4164
+ message: "Chain is required when publicClient or walletClient is not provided",
4165
+ path: ["chain"]
4166
+ }
4167
+ );
4168
+ var AddDeviceSchema = z50.object({
4169
+ appAddress: z50.string(),
4170
+ deviceId: z50.string(),
4171
+ transactionHash: z50.string(),
4172
+ blockNumber: z50.bigint().optional(),
4173
+ gasUsed: z50.bigint().optional()
4174
+ }).passthrough();
4175
+ async function addDevice(request, parameters) {
4176
+ const validatedRequest = AddDeviceRequestSchema.parse(request);
4177
+ const {
4178
+ chain,
4179
+ rpcUrl,
4180
+ appAddress,
4181
+ deviceId,
4182
+ privateKey,
4183
+ walletClient: providedWalletClient,
4184
+ publicClient: providedPublicClient,
4185
+ timeout = 12e4,
4186
+ retryOptions,
4187
+ signal,
4188
+ onTransactionStateChange,
4189
+ onTransactionSubmitted,
4190
+ onTransactionConfirmed,
4191
+ skipPrerequisiteChecks = false,
4192
+ minBalance
4193
+ } = validatedRequest;
4194
+ const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
4195
+ const deviceIdHex = asHex(deviceId);
4196
+ let publicClient;
4197
+ let walletClient;
4198
+ let address;
4199
+ let chainId;
4200
+ if (privateKey) {
4201
+ const account = privateKeyToAccount4(privateKey);
4202
+ publicClient = providedPublicClient ? providedPublicClient : createPublicClient4({ chain, transport: http4(rpcUrl) });
4203
+ walletClient = createWalletClient4({
4204
+ account,
4205
+ chain,
4206
+ transport: http4(rpcUrl)
4207
+ });
4208
+ address = account.address;
4209
+ chainId = chain.id;
4210
+ } else if (providedWalletClient) {
4211
+ walletClient = providedWalletClient;
4212
+ publicClient = providedPublicClient ? providedPublicClient : createPublicClient4({ chain, transport: http4(rpcUrl) });
4213
+ if (!walletClient.account?.address) {
4214
+ throw new Error("WalletClient must have an account with address");
4215
+ }
4216
+ address = walletClient.account.address;
4217
+ chainId = chain ? chain.id : await walletClient.getChainId();
4218
+ } else {
4219
+ throw new Error("Either privateKey or walletClient must be provided");
4220
+ }
4221
+ const networkClients = { publicClient, walletClient, address, chainId };
4222
+ const transactionTracker = createTransactionTracker();
4223
+ if (onTransactionStateChange && typeof onTransactionStateChange === "function") {
4224
+ const pollStatus = () => {
4225
+ onTransactionStateChange(transactionTracker.status);
4226
+ if (!transactionTracker.isComplete) {
4227
+ setTimeout(pollStatus, 100);
4228
+ }
4229
+ };
4230
+ setTimeout(pollStatus, 10);
4231
+ }
4232
+ if (!skipPrerequisiteChecks) {
4233
+ const requirements = {
4234
+ targetChainId: chainId,
4235
+ minBalance: minBalance ? parseEther3(minBalance) : parseEther3("0.001")
4236
+ };
4237
+ const validation = await validateNetworkPrerequisites(networkClients, requirements);
4238
+ if (!validation.networkValid) {
4239
+ throw new Error(
4240
+ `Network mismatch: Expected chain ${requirements.targetChainId}, but wallet is on chain ${validation.details.currentChainId}`
4241
+ );
4242
+ }
4243
+ if (!validation.balanceValid) {
4244
+ const requiredEth = Number(requirements.minBalance) / 1e18;
4245
+ const currentEth = Number(validation.details.balance) / 1e18;
4246
+ throw new Error(
4247
+ `Insufficient balance: Required ${requiredEth} ETH, but account has ${currentEth.toFixed(6)} ETH`
4248
+ );
4249
+ }
4250
+ }
4251
+ const addDeviceOperation = async (clients) => {
4252
+ return clients.walletClient.writeContract({
4253
+ address: contractAddress,
4254
+ abi: dstackAppAbi,
4255
+ functionName: "addDevice",
4256
+ args: [deviceIdHex],
4257
+ account: clients.walletClient.account || clients.address,
4258
+ chain: chain || null
4259
+ });
4260
+ };
4261
+ const transactionResult = retryOptions ? await executeTransactionWithRetry(
4262
+ addDeviceOperation,
4263
+ networkClients,
4264
+ [],
4265
+ {
4266
+ timeout,
4267
+ confirmations: 1,
4268
+ onSubmitted: onTransactionSubmitted,
4269
+ onConfirmed: onTransactionConfirmed,
4270
+ signal
4271
+ },
4272
+ retryOptions
4273
+ ) : await transactionTracker.execute(addDeviceOperation, networkClients, [], {
4274
+ timeout,
4275
+ confirmations: 1,
4276
+ onSubmitted: onTransactionSubmitted,
4277
+ onConfirmed: onTransactionConfirmed,
4278
+ signal
4279
+ });
4280
+ const result = {
4281
+ appAddress: contractAddress,
4282
+ deviceId: deviceIdHex,
4283
+ transactionHash: transactionResult.receipt.transactionHash,
4284
+ blockNumber: transactionResult.receipt.blockNumber,
4285
+ gasUsed: transactionResult.receipt.gasUsed
4286
+ };
4287
+ if (parameters?.schema === false) {
4288
+ return result;
4289
+ }
4290
+ const schema = parameters?.schema || AddDeviceSchema;
4291
+ return schema.parse(result);
4292
+ }
4293
+ async function safeAddDevice(request, parameters) {
4294
+ try {
4295
+ const result = await addDevice(request, parameters);
4296
+ return { success: true, data: result };
4297
+ } catch (error) {
4298
+ const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
4299
+ return {
4300
+ success: false,
4301
+ error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
4302
+ };
4303
+ }
4304
+ }
4305
+
4306
+ // src/actions/blockchains/remove_device.ts
4307
+ import { z as z51 } from "zod";
4308
+ import {
4309
+ createPublicClient as createPublicClient5,
4310
+ createWalletClient as createWalletClient5,
4311
+ http as http5,
4312
+ parseEther as parseEther4
4313
+ } from "viem";
4314
+ import { privateKeyToAccount as privateKeyToAccount5 } from "viem/accounts";
4315
+ var RemoveDeviceRequestSchema = z51.object({
4316
+ chain: z51.unknown().optional(),
4317
+ rpcUrl: z51.string().optional(),
4318
+ appAddress: z51.string(),
4319
+ deviceId: z51.string(),
4320
+ privateKey: z51.string().optional(),
4321
+ walletClient: z51.unknown().optional(),
4322
+ publicClient: z51.unknown().optional(),
4323
+ skipPrerequisiteChecks: z51.boolean().optional().default(false),
4324
+ minBalance: z51.string().optional(),
4325
+ timeout: z51.number().optional().default(12e4),
4326
+ retryOptions: z51.unknown().optional(),
4327
+ signal: z51.unknown().optional(),
4328
+ onTransactionStateChange: z51.function().optional(),
4329
+ onTransactionSubmitted: z51.function().optional(),
4330
+ onTransactionConfirmed: z51.function().optional()
4331
+ }).passthrough().refine((data) => !!data.privateKey !== !!data.walletClient, {
4332
+ message: "Either 'privateKey' or 'walletClient' must be provided, but not both",
4333
+ path: ["privateKey", "walletClient"]
4334
+ }).refine(
4335
+ (data) => {
4336
+ if (!!data.publicClient && !!data.walletClient) return true;
4337
+ return !!data.chain;
4338
+ },
4339
+ {
4340
+ message: "Chain is required when publicClient or walletClient is not provided",
4341
+ path: ["chain"]
4342
+ }
4343
+ );
4344
+ var RemoveDeviceSchema = z51.object({
4345
+ appAddress: z51.string(),
4346
+ deviceId: z51.string(),
4347
+ transactionHash: z51.string(),
4348
+ blockNumber: z51.bigint().optional(),
4349
+ gasUsed: z51.bigint().optional()
4350
+ }).passthrough();
4351
+ async function removeDevice(request, parameters) {
4352
+ const validatedRequest = RemoveDeviceRequestSchema.parse(request);
4353
+ const {
4354
+ chain,
4355
+ rpcUrl,
4356
+ appAddress,
4357
+ deviceId,
4358
+ privateKey,
4359
+ walletClient: providedWalletClient,
4360
+ publicClient: providedPublicClient,
4361
+ timeout = 12e4,
4362
+ retryOptions,
4363
+ signal,
4364
+ onTransactionStateChange,
4365
+ onTransactionSubmitted,
4366
+ onTransactionConfirmed,
4367
+ skipPrerequisiteChecks = false,
4368
+ minBalance
4369
+ } = validatedRequest;
4370
+ const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
4371
+ const deviceIdHex = asHex(deviceId);
4372
+ let publicClient;
4373
+ let walletClient;
4374
+ let address;
4375
+ let chainId;
4376
+ if (privateKey) {
4377
+ const account = privateKeyToAccount5(privateKey);
4378
+ publicClient = providedPublicClient ? providedPublicClient : createPublicClient5({ chain, transport: http5(rpcUrl) });
4379
+ walletClient = createWalletClient5({
4380
+ account,
4381
+ chain,
4382
+ transport: http5(rpcUrl)
4383
+ });
4384
+ address = account.address;
4385
+ chainId = chain.id;
4386
+ } else if (providedWalletClient) {
4387
+ walletClient = providedWalletClient;
4388
+ publicClient = providedPublicClient ? providedPublicClient : createPublicClient5({ chain, transport: http5(rpcUrl) });
4389
+ if (!walletClient.account?.address) {
4390
+ throw new Error("WalletClient must have an account with address");
4391
+ }
4392
+ address = walletClient.account.address;
4393
+ chainId = chain ? chain.id : await walletClient.getChainId();
4394
+ } else {
4395
+ throw new Error("Either privateKey or walletClient must be provided");
4396
+ }
4397
+ const networkClients = { publicClient, walletClient, address, chainId };
4398
+ const transactionTracker = createTransactionTracker();
4399
+ if (onTransactionStateChange && typeof onTransactionStateChange === "function") {
4400
+ const pollStatus = () => {
4401
+ onTransactionStateChange(transactionTracker.status);
4402
+ if (!transactionTracker.isComplete) {
4403
+ setTimeout(pollStatus, 100);
4404
+ }
4405
+ };
4406
+ setTimeout(pollStatus, 10);
4407
+ }
4408
+ if (!skipPrerequisiteChecks) {
4409
+ const requirements = {
4410
+ targetChainId: chainId,
4411
+ minBalance: minBalance ? parseEther4(minBalance) : parseEther4("0.001")
4412
+ };
4413
+ const validation = await validateNetworkPrerequisites(networkClients, requirements);
4414
+ if (!validation.networkValid) {
4415
+ throw new Error(
4416
+ `Network mismatch: Expected chain ${requirements.targetChainId}, but wallet is on chain ${validation.details.currentChainId}`
4417
+ );
4418
+ }
4419
+ if (!validation.balanceValid) {
4420
+ const requiredEth = Number(requirements.minBalance) / 1e18;
4421
+ const currentEth = Number(validation.details.balance) / 1e18;
4422
+ throw new Error(
4423
+ `Insufficient balance: Required ${requiredEth} ETH, but account has ${currentEth.toFixed(6)} ETH`
4424
+ );
4425
+ }
4426
+ }
4427
+ const removeDeviceOperation = async (clients) => {
4428
+ return clients.walletClient.writeContract({
4429
+ address: contractAddress,
4430
+ abi: dstackAppAbi,
4431
+ functionName: "removeDevice",
4432
+ args: [deviceIdHex],
4433
+ account: clients.walletClient.account || clients.address,
4434
+ chain: chain || null
4435
+ });
4436
+ };
4437
+ const transactionResult = retryOptions ? await executeTransactionWithRetry(
4438
+ removeDeviceOperation,
4439
+ networkClients,
4440
+ [],
4441
+ {
4442
+ timeout,
4443
+ confirmations: 1,
4444
+ onSubmitted: onTransactionSubmitted,
4445
+ onConfirmed: onTransactionConfirmed,
4446
+ signal
4447
+ },
4448
+ retryOptions
4449
+ ) : await transactionTracker.execute(removeDeviceOperation, networkClients, [], {
4450
+ timeout,
4451
+ confirmations: 1,
4452
+ onSubmitted: onTransactionSubmitted,
4453
+ onConfirmed: onTransactionConfirmed,
4454
+ signal
4455
+ });
4456
+ const result = {
4457
+ appAddress: contractAddress,
4458
+ deviceId: deviceIdHex,
4459
+ transactionHash: transactionResult.receipt.transactionHash,
4460
+ blockNumber: transactionResult.receipt.blockNumber,
4461
+ gasUsed: transactionResult.receipt.gasUsed
4462
+ };
4463
+ if (parameters?.schema === false) {
4464
+ return result;
4465
+ }
4466
+ const schema = parameters?.schema || RemoveDeviceSchema;
4467
+ return schema.parse(result);
4468
+ }
4469
+ async function safeRemoveDevice(request, parameters) {
4470
+ try {
4471
+ const result = await removeDevice(request, parameters);
4472
+ return { success: true, data: result };
4473
+ } catch (error) {
4474
+ const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
4475
+ return {
4476
+ success: false,
4477
+ error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
4478
+ };
4479
+ }
4480
+ }
4481
+
4482
+ // src/actions/blockchains/set_allow_any_device.ts
4483
+ import { z as z52 } from "zod";
4484
+ import {
4485
+ createPublicClient as createPublicClient6,
4486
+ createWalletClient as createWalletClient6,
4487
+ http as http6,
4488
+ parseEther as parseEther5
4489
+ } from "viem";
4490
+ import { privateKeyToAccount as privateKeyToAccount6 } from "viem/accounts";
4491
+ var SetAllowAnyDeviceRequestSchema = z52.object({
4492
+ chain: z52.unknown().optional(),
4493
+ rpcUrl: z52.string().optional(),
4494
+ appAddress: z52.string(),
4495
+ allow: z52.boolean(),
4496
+ privateKey: z52.string().optional(),
4497
+ walletClient: z52.unknown().optional(),
4498
+ publicClient: z52.unknown().optional(),
4499
+ skipPrerequisiteChecks: z52.boolean().optional().default(false),
4500
+ minBalance: z52.string().optional(),
4501
+ timeout: z52.number().optional().default(12e4),
4502
+ retryOptions: z52.unknown().optional(),
4503
+ signal: z52.unknown().optional(),
4504
+ onTransactionStateChange: z52.function().optional(),
4505
+ onTransactionSubmitted: z52.function().optional(),
4506
+ onTransactionConfirmed: z52.function().optional()
4507
+ }).passthrough().refine((data) => !!data.privateKey !== !!data.walletClient, {
4508
+ message: "Either 'privateKey' or 'walletClient' must be provided, but not both",
4509
+ path: ["privateKey", "walletClient"]
4510
+ }).refine(
4511
+ (data) => {
4512
+ if (!!data.publicClient && !!data.walletClient) return true;
4513
+ return !!data.chain;
4514
+ },
4515
+ {
4516
+ message: "Chain is required when publicClient or walletClient is not provided",
4517
+ path: ["chain"]
4518
+ }
4519
+ );
4520
+ var SetAllowAnyDeviceSchema = z52.object({
4521
+ appAddress: z52.string(),
4522
+ allow: z52.boolean(),
4523
+ transactionHash: z52.string(),
4524
+ blockNumber: z52.bigint().optional(),
4525
+ gasUsed: z52.bigint().optional()
4526
+ }).passthrough();
4527
+ async function setAllowAnyDevice(request, parameters) {
4528
+ const validatedRequest = SetAllowAnyDeviceRequestSchema.parse(request);
4529
+ const {
4530
+ chain,
4531
+ rpcUrl,
4532
+ appAddress,
4533
+ allow,
4534
+ privateKey,
4535
+ walletClient: providedWalletClient,
4536
+ publicClient: providedPublicClient,
4537
+ timeout = 12e4,
4538
+ retryOptions,
4539
+ signal,
4540
+ onTransactionStateChange,
4541
+ onTransactionSubmitted,
4542
+ onTransactionConfirmed,
4543
+ skipPrerequisiteChecks = false,
4544
+ minBalance
4545
+ } = validatedRequest;
4546
+ const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
4547
+ let publicClient;
4548
+ let walletClient;
4549
+ let address;
4550
+ let chainId;
4551
+ if (privateKey) {
4552
+ const account = privateKeyToAccount6(privateKey);
4553
+ publicClient = providedPublicClient ? providedPublicClient : createPublicClient6({ chain, transport: http6(rpcUrl) });
4554
+ walletClient = createWalletClient6({
4555
+ account,
4556
+ chain,
4557
+ transport: http6(rpcUrl)
4558
+ });
4559
+ address = account.address;
4560
+ chainId = chain.id;
4561
+ } else if (providedWalletClient) {
4562
+ walletClient = providedWalletClient;
4563
+ publicClient = providedPublicClient ? providedPublicClient : createPublicClient6({ chain, transport: http6(rpcUrl) });
4564
+ if (!walletClient.account?.address) {
4565
+ throw new Error("WalletClient must have an account with address");
4566
+ }
4567
+ address = walletClient.account.address;
4568
+ chainId = chain ? chain.id : await walletClient.getChainId();
4569
+ } else {
4570
+ throw new Error("Either privateKey or walletClient must be provided");
4571
+ }
4572
+ const networkClients = { publicClient, walletClient, address, chainId };
4573
+ const transactionTracker = createTransactionTracker();
4574
+ if (onTransactionStateChange && typeof onTransactionStateChange === "function") {
4575
+ const pollStatus = () => {
4576
+ onTransactionStateChange(transactionTracker.status);
4577
+ if (!transactionTracker.isComplete) {
4578
+ setTimeout(pollStatus, 100);
4579
+ }
4580
+ };
4581
+ setTimeout(pollStatus, 10);
4582
+ }
4583
+ if (!skipPrerequisiteChecks) {
4584
+ const requirements = {
4585
+ targetChainId: chainId,
4586
+ minBalance: minBalance ? parseEther5(minBalance) : parseEther5("0.001")
4587
+ };
4588
+ const validation = await validateNetworkPrerequisites(networkClients, requirements);
4589
+ if (!validation.networkValid) {
4590
+ throw new Error(
4591
+ `Network mismatch: Expected chain ${requirements.targetChainId}, but wallet is on chain ${validation.details.currentChainId}`
4592
+ );
4593
+ }
4594
+ if (!validation.balanceValid) {
4595
+ const requiredEth = Number(requirements.minBalance) / 1e18;
4596
+ const currentEth = Number(validation.details.balance) / 1e18;
4597
+ throw new Error(
4598
+ `Insufficient balance: Required ${requiredEth} ETH, but account has ${currentEth.toFixed(6)} ETH`
4599
+ );
4600
+ }
4601
+ }
4602
+ const setAllowAnyOperation = async (clients) => {
4603
+ return clients.walletClient.writeContract({
4604
+ address: contractAddress,
4605
+ abi: dstackAppAbi,
4606
+ functionName: "setAllowAnyDevice",
4607
+ args: [allow],
4608
+ account: clients.walletClient.account || clients.address,
4609
+ chain: chain || null
4610
+ });
4611
+ };
4612
+ const transactionResult = retryOptions ? await executeTransactionWithRetry(
4613
+ setAllowAnyOperation,
4614
+ networkClients,
4615
+ [],
4616
+ {
4617
+ timeout,
4618
+ confirmations: 1,
4619
+ onSubmitted: onTransactionSubmitted,
4620
+ onConfirmed: onTransactionConfirmed,
4621
+ signal
4622
+ },
4623
+ retryOptions
4624
+ ) : await transactionTracker.execute(setAllowAnyOperation, networkClients, [], {
4625
+ timeout,
4626
+ confirmations: 1,
4627
+ onSubmitted: onTransactionSubmitted,
4628
+ onConfirmed: onTransactionConfirmed,
4629
+ signal
4630
+ });
4631
+ const result = {
4632
+ appAddress: contractAddress,
4633
+ allow,
4634
+ transactionHash: transactionResult.receipt.transactionHash,
4635
+ blockNumber: transactionResult.receipt.blockNumber,
4636
+ gasUsed: transactionResult.receipt.gasUsed
4637
+ };
4638
+ if (parameters?.schema === false) {
4639
+ return result;
4640
+ }
4641
+ const schema = parameters?.schema || SetAllowAnyDeviceSchema;
4642
+ return schema.parse(result);
4643
+ }
4644
+ async function safeSetAllowAnyDevice(request, parameters) {
4645
+ try {
4646
+ const result = await setAllowAnyDevice(request, parameters);
4647
+ return { success: true, data: result };
4648
+ } catch (error) {
4649
+ const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
4650
+ return {
4651
+ success: false,
4652
+ error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
4653
+ };
4654
+ }
4655
+ }
4656
+
4657
+ // src/actions/blockchains/get_allowed_devices.ts
4658
+ import { z as z53 } from "zod";
4659
+ import { createPublicClient as createPublicClient7, http as http7 } from "viem";
4660
+ var GetAllowedDevicesSchema = z53.object({
4661
+ appAddress: z53.string(),
4662
+ owner: z53.string(),
4663
+ allowAnyDevice: z53.boolean(),
4664
+ devices: z53.array(z53.string())
4665
+ });
4666
+ async function getAllowedDevices(request) {
4667
+ const { chain, rpcUrl, appAddress, deviceIds, publicClient: providedPublicClient } = request;
4668
+ const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
4669
+ const publicClient = providedPublicClient ? providedPublicClient : (() => {
4670
+ if (!chain) throw new Error("Chain is required when publicClient is not provided");
4671
+ return createPublicClient7({ chain, transport: http7(rpcUrl) });
4672
+ })();
4673
+ const [allowAnyDevice, owner] = await Promise.all([
4674
+ publicClient.readContract({
4675
+ address: contractAddress,
4676
+ abi: dstackAppAbi,
4677
+ functionName: "allowAnyDevice"
4678
+ }),
4679
+ publicClient.readContract({
4680
+ address: contractAddress,
4681
+ abi: dstackAppAbi,
4682
+ functionName: "owner"
4683
+ })
4684
+ ]);
4685
+ if (allowAnyDevice) {
4686
+ return {
4687
+ appAddress: contractAddress,
4688
+ owner,
4689
+ allowAnyDevice: true,
4690
+ devices: deviceIds.map((id) => asHex(id))
4691
+ };
4692
+ }
4693
+ let devices;
4694
+ if (deviceIds.length === 0) {
4695
+ devices = [];
4696
+ } else {
4697
+ const calls = deviceIds.map((deviceId) => ({
4698
+ address: contractAddress,
4699
+ abi: dstackAppAbi,
4700
+ functionName: "allowedDeviceIds",
4701
+ args: [asHex(deviceId)]
4702
+ }));
4703
+ const multicallResults = await publicClient.multicall({ contracts: calls });
4704
+ devices = deviceIds.map((deviceId, i) => ({
4705
+ deviceId: asHex(deviceId),
4706
+ allowed: multicallResults[i]?.status === "success" && multicallResults[i]?.result === true
4707
+ })).filter((r) => r.allowed).map((r) => r.deviceId);
4708
+ }
4709
+ return {
4710
+ appAddress: contractAddress,
4711
+ owner,
4712
+ allowAnyDevice: false,
4713
+ devices
4714
+ };
4715
+ }
4716
+ async function safeGetAllowedDevices(request) {
4717
+ try {
4718
+ const result = await getAllowedDevices(request);
4719
+ return { success: true, data: result };
4720
+ } catch (error) {
4721
+ const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
4722
+ return {
4723
+ success: false,
4724
+ error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
4725
+ };
4726
+ }
4727
+ }
4728
+
4729
+ // src/actions/blockchains/check_device_allowed.ts
4730
+ import { createPublicClient as createPublicClient8, http as http8 } from "viem";
4731
+ async function checkDeviceAllowed(request) {
4732
+ const { chain, rpcUrl, appAddress, deviceId, publicClient: providedPublicClient } = request;
4733
+ const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
4734
+ const deviceIdHex = asHex(deviceId);
4735
+ const publicClient = providedPublicClient ? providedPublicClient : (() => {
4736
+ if (!chain) throw new Error("Chain is required when publicClient is not provided");
4737
+ return createPublicClient8({ chain, transport: http8(rpcUrl) });
4738
+ })();
4739
+ const allowAny = await publicClient.readContract({
4740
+ address: contractAddress,
4741
+ abi: dstackAppAbi,
4742
+ functionName: "allowAnyDevice"
4743
+ });
4744
+ if (allowAny) return true;
4745
+ const allowed = await publicClient.readContract({
4746
+ address: contractAddress,
4747
+ abi: dstackAppAbi,
4748
+ functionName: "allowedDeviceIds",
4749
+ args: [deviceIdHex]
4750
+ });
4751
+ return allowed;
4752
+ }
4753
+ async function safeCheckDeviceAllowed(request) {
4754
+ try {
4755
+ const result = await checkDeviceAllowed(request);
4756
+ return { success: true, data: result };
4757
+ } catch (error) {
4758
+ const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
4759
+ return {
4760
+ success: false,
4761
+ error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
4762
+ };
4763
+ }
4764
+ }
4765
+
3992
4766
  // src/actions/workspaces/get_workspace_nodes.ts
3993
- import { z as z48 } from "zod";
4767
+ import { z as z54 } from "zod";
3994
4768
  var NodeRefSchema2 = NodeRefSchema;
3995
4769
  var NodeInfoSchema = NodeRefSchema2;
3996
- var GetWorkspaceNodesSchema = z48.object({
3997
- items: z48.array(NodeRefSchema2),
3998
- total: z48.number(),
3999
- page: z48.number(),
4000
- page_size: z48.number(),
4001
- pages: z48.number()
4770
+ var GetWorkspaceNodesSchema = z54.object({
4771
+ items: z54.array(NodeRefSchema2),
4772
+ total: z54.number(),
4773
+ page: z54.number(),
4774
+ page_size: z54.number(),
4775
+ pages: z54.number()
4002
4776
  }).passthrough();
4003
4777
  var { action: getWorkspaceNodes, safeAction: safeGetWorkspaceNodes } = defineAction(GetWorkspaceNodesSchema, async (client, request) => {
4004
4778
  const { teamSlug, page, pageSize } = request;
@@ -4010,42 +4784,56 @@ var { action: getWorkspaceNodes, safeAction: safeGetWorkspaceNodes } = defineAct
4010
4784
  });
4011
4785
 
4012
4786
  // src/actions/workspaces/get_workspace_quotas.ts
4013
- import { z as z49 } from "zod";
4014
- var QuotaMetricSchema = z49.object({
4015
- limit: z49.number(),
4016
- remaining: z49.number()
4787
+ import { z as z55 } from "zod";
4788
+ var QuotaMetricSchema = z55.object({
4789
+ limit: z55.number(),
4790
+ remaining: z55.number()
4017
4791
  }).passthrough();
4018
- var WorkspaceQuotasSchema = z49.object({
4792
+ var WorkspaceQuotasSchema = z55.object({
4019
4793
  vm_slots: QuotaMetricSchema,
4020
4794
  vcpu: QuotaMetricSchema,
4021
4795
  memory_mb: QuotaMetricSchema,
4022
4796
  disk_gb: QuotaMetricSchema
4023
4797
  }).passthrough();
4024
- var WorkspaceReservedGpuQuotaSchema = z49.object({
4798
+ var WorkspaceReservedGpuQuotaSchema = z55.object({
4025
4799
  gpus: QuotaMetricSchema,
4026
- in_use: z49.number(),
4027
- misconfigured: z49.number()
4800
+ in_use: z55.number(),
4801
+ misconfigured: z55.number()
4028
4802
  }).passthrough();
4029
- var GetWorkspaceQuotasSchema = z49.object({
4030
- team_slug: z49.string(),
4031
- tier: z49.string(),
4803
+ var GetWorkspaceQuotasSchema = z55.object({
4804
+ team_slug: z55.string(),
4805
+ tier: z55.string(),
4032
4806
  quotas: WorkspaceQuotasSchema,
4033
4807
  reserved_nodes: QuotaMetricSchema,
4034
4808
  reserved_gpu: WorkspaceReservedGpuQuotaSchema,
4035
- as_of: z49.string()
4809
+ as_of: z55.string()
4036
4810
  }).passthrough();
4037
4811
  var { action: getWorkspaceQuotas, safeAction: safeGetWorkspaceQuotas } = defineAction(GetWorkspaceQuotasSchema, async (client, request) => {
4038
4812
  return await client.get(`/workspaces/${request.teamSlug}/quotas`);
4039
4813
  });
4040
4814
 
4815
+ // src/actions/cvms/replicate_cvm.ts
4816
+ import { z as z56 } from "zod";
4817
+ var ReplicateCvmRequestSchema = refineCvmId(
4818
+ CvmIdObjectSchema.extend({
4819
+ node_id: z56.number().optional()
4820
+ })
4821
+ );
4822
+ var { action: replicateCvm, safeAction: safeReplicateCvm } = defineAction(VMSchema, async (client, request) => {
4823
+ const parsed = ReplicateCvmRequestSchema.parse(request);
4824
+ const { cvmId } = CvmIdSchema.parse(parsed);
4825
+ const { node_id } = parsed;
4826
+ return await client.post(`/cvms/${cvmId}/replicas`, { node_id });
4827
+ });
4828
+
4041
4829
  // src/actions/cvms/watch_cvm_state.ts
4042
- import { z as z50 } from "zod";
4043
- var WatchCvmStateParamsSchema = z50.object({
4044
- target: z50.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),
4045
- interval: z50.number().min(5).max(30).default(5).describe("Polling interval in seconds"),
4046
- timeout: z50.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),
4047
- maxRetries: z50.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),
4048
- retryDelay: z50.number().min(0).default(5e3).describe("Delay between retries in milliseconds")
4830
+ import { z as z57 } from "zod";
4831
+ var WatchCvmStateParamsSchema = z57.object({
4832
+ target: z57.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),
4833
+ interval: z57.number().min(5).max(30).default(5).describe("Polling interval in seconds"),
4834
+ timeout: z57.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),
4835
+ maxRetries: z57.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),
4836
+ retryDelay: z57.number().min(0).default(5e3).describe("Delay between retries in milliseconds")
4049
4837
  });
4050
4838
  var WatchCvmStateRequestSchema = WatchCvmStateParamsSchema;
4051
4839
  var WatchAbortedError = class extends Error {
@@ -4232,22 +5020,75 @@ function sleep(ms, signal) {
4232
5020
  });
4233
5021
  }
4234
5022
 
5023
+ // src/actions/cvms/refresh_cvm_instance_id.ts
5024
+ import { z as z58 } from "zod";
5025
+ var InstanceIdRefreshResultSchema = z58.object({
5026
+ cvm_id: z58.number().int(),
5027
+ identifier: z58.string(),
5028
+ status: z58.enum(["updated", "unchanged", "skipped", "conflict", "error"]),
5029
+ old_instance_id: z58.string().nullable().optional(),
5030
+ new_instance_id: z58.string().nullable().optional(),
5031
+ source: z58.enum(["teepod_state", "teepod_info", "gateway", "none"]),
5032
+ verified_with_gateway: z58.boolean(),
5033
+ reason: z58.string().nullable().optional()
5034
+ });
5035
+ var RefreshCvmInstanceIdRequestSchema = refineCvmId(
5036
+ CvmIdObjectSchema.extend({
5037
+ overwrite: z58.boolean().optional(),
5038
+ dry_run: z58.boolean().optional()
5039
+ })
5040
+ );
5041
+ var { action: refreshCvmInstanceId, safeAction: safeRefreshCvmInstanceId } = defineAction(InstanceIdRefreshResultSchema, async (client, request) => {
5042
+ const parsed = RefreshCvmInstanceIdRequestSchema.parse(request);
5043
+ const { cvmId } = CvmIdSchema.parse(parsed);
5044
+ const { overwrite, dry_run } = parsed;
5045
+ return await client.patch(`/cvms/${cvmId}/instance-id`, {
5046
+ overwrite,
5047
+ dry_run
5048
+ });
5049
+ });
5050
+
5051
+ // src/actions/cvms/refresh_cvm_instance_ids.ts
5052
+ import { z as z59 } from "zod";
5053
+ var RefreshCvmInstanceIdsRequestSchema = z59.object({
5054
+ cvm_ids: z59.array(z59.string()).optional(),
5055
+ running_only: z59.boolean().optional(),
5056
+ missing_only: z59.boolean().optional(),
5057
+ overwrite: z59.boolean().optional(),
5058
+ limit: z59.number().int().min(1).max(500).optional(),
5059
+ dry_run: z59.boolean().optional()
5060
+ }).strict();
5061
+ var RefreshCvmInstanceIdsResponseSchema = z59.object({
5062
+ total: z59.number().int(),
5063
+ scanned: z59.number().int(),
5064
+ updated: z59.number().int(),
5065
+ unchanged: z59.number().int(),
5066
+ skipped: z59.number().int(),
5067
+ conflicts: z59.number().int(),
5068
+ errors: z59.number().int(),
5069
+ items: z59.array(InstanceIdRefreshResultSchema)
5070
+ });
5071
+ var { action: refreshCvmInstanceIds, safeAction: safeRefreshCvmInstanceIds } = defineAction(RefreshCvmInstanceIdsResponseSchema, async (client, request) => {
5072
+ const parsed = RefreshCvmInstanceIdsRequestSchema.parse(request);
5073
+ return await client.patch("/cvms/instance-ids", parsed);
5074
+ });
5075
+
4235
5076
  // src/actions/cvms/get_cvm_status_batch.ts
4236
- import { z as z51 } from "zod";
4237
- var CvmStatusSchema = z51.object({
4238
- vm_uuid: z51.string(),
4239
- status: z51.string(),
4240
- uptime: z51.string().nullable().optional(),
4241
- in_progress: z51.boolean(),
4242
- boot_progress: z51.string().nullable().optional(),
4243
- boot_error: z51.string().nullable().optional(),
4244
- operation_type: z51.string().nullable().optional(),
4245
- operation_started_at: z51.string().nullable().optional(),
4246
- correlation_id: z51.string().nullable().optional()
5077
+ import { z as z60 } from "zod";
5078
+ var CvmStatusSchema = z60.object({
5079
+ vm_uuid: z60.string(),
5080
+ status: z60.string(),
5081
+ uptime: z60.string().nullable().optional(),
5082
+ in_progress: z60.boolean(),
5083
+ boot_progress: z60.string().nullable().optional(),
5084
+ boot_error: z60.string().nullable().optional(),
5085
+ operation_type: z60.string().nullable().optional(),
5086
+ operation_started_at: z60.string().nullable().optional(),
5087
+ correlation_id: z60.string().nullable().optional()
4247
5088
  });
4248
- var GetCvmStatusBatchResponseSchema = z51.record(z51.string(), CvmStatusSchema);
4249
- var GetCvmStatusBatchRequestSchema = z51.object({
4250
- vmUuids: z51.array(z51.string())
5089
+ var GetCvmStatusBatchResponseSchema = z60.record(z60.string(), CvmStatusSchema);
5090
+ var GetCvmStatusBatchRequestSchema = z60.object({
5091
+ vmUuids: z60.array(z60.string())
4251
5092
  });
4252
5093
  var { action: getCvmStatusBatch, safeAction: safeGetCvmStatusBatch } = defineAction(GetCvmStatusBatchResponseSchema, async (client, request) => {
4253
5094
  const { vmUuids } = GetCvmStatusBatchRequestSchema.parse(request);
@@ -4255,11 +5096,11 @@ var { action: getCvmStatusBatch, safeAction: safeGetCvmStatusBatch } = defineAct
4255
5096
  });
4256
5097
 
4257
5098
  // src/actions/cvms/get_cvm_user_config.ts
4258
- import { z as z52 } from "zod";
4259
- var CvmUserConfigSchema = z52.object({
4260
- hostname: z52.string().nullable().optional(),
4261
- ssh_authorized_keys: z52.array(z52.string()).default([]),
4262
- default_gateway_domain: z52.string().nullable().optional()
5099
+ import { z as z61 } from "zod";
5100
+ var CvmUserConfigSchema = z61.object({
5101
+ hostname: z61.string().nullable().optional(),
5102
+ ssh_authorized_keys: z61.array(z61.string()).default([]),
5103
+ default_gateway_domain: z61.string().nullable().optional()
4263
5104
  });
4264
5105
  var GetCvmUserConfigRequestSchema = CvmIdSchema;
4265
5106
  var { action: getCvmUserConfig, safeAction: safeGetCvmUserConfig } = defineAction(CvmUserConfigSchema, async (client, request) => {
@@ -4268,19 +5109,19 @@ var { action: getCvmUserConfig, safeAction: safeGetCvmUserConfig } = defineActio
4268
5109
  });
4269
5110
 
4270
5111
  // src/actions/apps/get_app_list.ts
4271
- import { z as z53 } from "zod";
4272
- var GetAppListRequestSchema = z53.object({
4273
- page: z53.number().int().min(1).optional(),
4274
- page_size: z53.number().int().min(1).max(100).optional(),
4275
- search: z53.string().optional(),
4276
- status: z53.array(z53.string()).optional(),
4277
- listed: z53.boolean().optional(),
4278
- base_image: z53.string().optional(),
4279
- instance_type: z53.string().optional(),
4280
- kms_slug: z53.string().optional(),
4281
- kms_type: z53.string().optional(),
4282
- node: z53.string().optional(),
4283
- region: z53.string().optional()
5112
+ import { z as z62 } from "zod";
5113
+ var GetAppListRequestSchema = z62.object({
5114
+ page: z62.number().int().min(1).optional(),
5115
+ page_size: z62.number().int().min(1).max(100).optional(),
5116
+ search: z62.string().optional(),
5117
+ status: z62.array(z62.string()).optional(),
5118
+ listed: z62.boolean().optional(),
5119
+ base_image: z62.string().optional(),
5120
+ instance_type: z62.string().optional(),
5121
+ kms_slug: z62.string().optional(),
5122
+ kms_type: z62.string().optional(),
5123
+ node: z62.string().optional(),
5124
+ region: z62.string().optional()
4284
5125
  }).strict();
4285
5126
  function getSchemaForVersion4(version) {
4286
5127
  return version === "2025-10-28" ? DstackAppListResponseV20251028Schema : DstackAppListResponseV20260121Schema;
@@ -4310,9 +5151,9 @@ async function safeGetAppList(client, request) {
4310
5151
  }
4311
5152
 
4312
5153
  // src/actions/apps/get_app_info.ts
4313
- import { z as z54 } from "zod";
4314
- var GetAppInfoRequestSchema = z54.object({
4315
- appId: z54.string().min(1)
5154
+ import { z as z63 } from "zod";
5155
+ var GetAppInfoRequestSchema = z63.object({
5156
+ appId: z63.string().min(1)
4316
5157
  }).strict();
4317
5158
  function getSchemaForVersion5(version) {
4318
5159
  return version === "2025-10-28" ? DstackAppWithCvmResponseV20251028Schema : DstackAppWithCvmResponseV20260121Schema;
@@ -4342,12 +5183,12 @@ async function safeGetAppInfo(client, request) {
4342
5183
  }
4343
5184
 
4344
5185
  // src/actions/apps/get_app_cvms.ts
4345
- import { z as z55 } from "zod";
4346
- var GetAppCvmsRequestSchema = z55.object({
4347
- appId: z55.string().min(1)
5186
+ import { z as z64 } from "zod";
5187
+ var GetAppCvmsRequestSchema = z64.object({
5188
+ appId: z64.string().min(1)
4348
5189
  }).strict();
4349
5190
  function getSchemaForVersion6(version) {
4350
- return version === "2025-10-28" ? z55.array(CvmInfoV20251028Schema) : z55.array(CvmInfoV20260121Schema);
5191
+ return version === "2025-10-28" ? z64.array(CvmInfoV20251028Schema) : z64.array(CvmInfoV20260121Schema);
4351
5192
  }
4352
5193
  async function getAppCvms(client, request) {
4353
5194
  const { appId } = GetAppCvmsRequestSchema.parse(request);
@@ -4373,12 +5214,54 @@ async function safeGetAppCvms(client, request) {
4373
5214
  }
4374
5215
  }
4375
5216
 
5217
+ // src/actions/apps/get_app_device_allowlist.ts
5218
+ import { z as z65 } from "zod";
5219
+ var DeviceAllowlistItemSchema = z65.object({
5220
+ device_id: z65.string(),
5221
+ node_name: z65.string().nullable(),
5222
+ cvm_ids: z65.array(z65.number()),
5223
+ allowed_onchain: z65.boolean(),
5224
+ status: z65.string()
5225
+ });
5226
+ var DeviceAllowlistResponseSchema = z65.object({
5227
+ is_onchain_kms: z65.boolean(),
5228
+ allow_any_device: z65.boolean().nullable().optional(),
5229
+ chain_id: z65.number().nullable().optional(),
5230
+ app_contract_address: z65.string().nullable().optional(),
5231
+ devices: z65.array(DeviceAllowlistItemSchema).optional().default([])
5232
+ });
5233
+ var GetAppDeviceAllowlistRequestSchema = z65.object({
5234
+ appId: z65.string().min(1)
5235
+ }).strict();
5236
+ async function getAppDeviceAllowlist(client, request) {
5237
+ const { appId } = GetAppDeviceAllowlistRequestSchema.parse(request);
5238
+ const response = await client.get(`/apps/${appId}/device-allowlist`);
5239
+ return DeviceAllowlistResponseSchema.parse(response);
5240
+ }
5241
+ async function safeGetAppDeviceAllowlist(client, request) {
5242
+ try {
5243
+ const data = await getAppDeviceAllowlist(client, request);
5244
+ return { success: true, data };
5245
+ } catch (error) {
5246
+ if (error && typeof error === "object" && ("status" in error || "issues" in error)) {
5247
+ return { success: false, error };
5248
+ }
5249
+ return {
5250
+ success: false,
5251
+ error: {
5252
+ name: "Error",
5253
+ message: error instanceof Error ? error.message : String(error)
5254
+ }
5255
+ };
5256
+ }
5257
+ }
5258
+
4376
5259
  // src/actions/apps/get_app_revisions.ts
4377
- import { z as z56 } from "zod";
4378
- var GetAppRevisionsRequestSchema = z56.object({
4379
- appId: z56.string().min(1),
4380
- page: z56.number().int().min(1).optional(),
4381
- page_size: z56.number().int().min(1).max(1e3).optional()
5260
+ import { z as z66 } from "zod";
5261
+ var GetAppRevisionsRequestSchema = z66.object({
5262
+ appId: z66.string().min(1),
5263
+ page: z66.number().int().min(1).optional(),
5264
+ page_size: z66.number().int().min(1).max(1e3).optional()
4382
5265
  }).strict();
4383
5266
  async function getAppRevisions(client, request) {
4384
5267
  const { appId, ...params } = GetAppRevisionsRequestSchema.parse(request);
@@ -4404,11 +5287,11 @@ async function safeGetAppRevisions(client, request) {
4404
5287
  }
4405
5288
 
4406
5289
  // src/actions/apps/get_app_revision_detail.ts
4407
- import { z as z57 } from "zod";
4408
- var GetAppRevisionDetailRequestSchema = z57.object({
4409
- appId: z57.string().min(1),
4410
- revisionId: z57.string().min(1),
4411
- rawComposeFile: z57.boolean().optional()
5290
+ import { z as z67 } from "zod";
5291
+ var GetAppRevisionDetailRequestSchema = z67.object({
5292
+ appId: z67.string().min(1),
5293
+ revisionId: z67.string().min(1),
5294
+ rawComposeFile: z67.boolean().optional()
4412
5295
  }).strict();
4413
5296
  async function getAppRevisionDetail(client, request) {
4414
5297
  const { appId, revisionId, rawComposeFile } = GetAppRevisionDetailRequestSchema.parse(request);
@@ -4435,15 +5318,15 @@ async function safeGetAppRevisionDetail(client, request) {
4435
5318
  }
4436
5319
 
4437
5320
  // src/actions/apps/get_app_filter_options.ts
4438
- import { z as z58 } from "zod";
4439
- var AppFilterOptionsSchema = z58.object({
4440
- statuses: z58.array(z58.string()),
4441
- image_versions: z58.array(z58.string()),
4442
- instance_types: z58.array(z58.string()),
4443
- kms_slugs: z58.array(z58.string()),
4444
- kms_types: z58.array(z58.string()),
4445
- regions: z58.array(z58.string()),
4446
- nodes: z58.array(z58.string())
5321
+ import { z as z68 } from "zod";
5322
+ var AppFilterOptionsSchema = z68.object({
5323
+ statuses: z68.array(z68.string()),
5324
+ image_versions: z68.array(z68.string()),
5325
+ instance_types: z68.array(z68.string()),
5326
+ kms_slugs: z68.array(z68.string()),
5327
+ kms_types: z68.array(z68.string()),
5328
+ regions: z68.array(z68.string()),
5329
+ nodes: z68.array(z68.string())
4447
5330
  });
4448
5331
  async function getAppFilterOptions(client) {
4449
5332
  const response = await client.get("/apps/filter-options");
@@ -4467,6 +5350,54 @@ async function safeGetAppFilterOptions(client) {
4467
5350
  }
4468
5351
  }
4469
5352
 
5353
+ // src/actions/apps/get_app_attestation.ts
5354
+ import { z as z69 } from "zod";
5355
+ var KmsInfoSchema2 = z69.object({
5356
+ contract_address: z69.string(),
5357
+ chain_id: z69.string().nullable(),
5358
+ version: z69.string(),
5359
+ url: z69.string(),
5360
+ gateway_app_id: z69.string().nullable(),
5361
+ gateway_app_url: z69.string(),
5362
+ kms_type: z69.string()
5363
+ });
5364
+ var GuestAgentInfoSchema = z69.object({
5365
+ app_id: z69.string().optional(),
5366
+ instance_id: z69.string().optional(),
5367
+ app_name: z69.string().optional(),
5368
+ device_id: z69.string().optional()
5369
+ }).passthrough().nullable();
5370
+ var AppAttestationInstanceSchema = z69.object({
5371
+ vm_uuid: z69.string().nullable().optional(),
5372
+ name: z69.string().optional(),
5373
+ instance_id: z69.string().nullable().optional(),
5374
+ status: z69.string().optional(),
5375
+ image_version: z69.string().nullable().optional(),
5376
+ quote: z69.string().nullable().optional(),
5377
+ ppid: z69.string().optional(),
5378
+ device_id: z69.string().optional(),
5379
+ tcb_info: TcbInfoSchema.nullable().optional(),
5380
+ app_certificates: z69.array(CertificateSchema).nullable().optional(),
5381
+ compose_file: z69.string().nullable().optional(),
5382
+ error: z69.string().nullable().optional()
5383
+ });
5384
+ var AppAttestationResponseSchema = z69.object({
5385
+ app_id: z69.string(),
5386
+ contract_address: z69.string(),
5387
+ kms_info: KmsInfoSchema2,
5388
+ instances: z69.array(AppAttestationInstanceSchema),
5389
+ kms_guest_agent_info: GuestAgentInfoSchema,
5390
+ gateway_guest_agent_info: GuestAgentInfoSchema,
5391
+ qemu_version: z69.string().nullable()
5392
+ });
5393
+ var GetAppAttestationRequestSchema = z69.object({
5394
+ appId: z69.string().min(1)
5395
+ }).strict();
5396
+ var { action: getAppAttestation, safeAction: safeGetAppAttestation } = defineAction(AppAttestationResponseSchema, async (client, request) => {
5397
+ const { appId } = GetAppAttestationRequestSchema.parse(request);
5398
+ return await client.get(`/apps/${appId}/attestations`);
5399
+ });
5400
+
4470
5401
  // src/parse_dotenv.ts
4471
5402
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
4472
5403
  function parseEnv(input) {
@@ -4506,8 +5437,11 @@ import { getComposeHash as getComposeHash2 } from "@phala/dstack-sdk/get-compose
4506
5437
  import { verifyEnvEncryptPublicKey } from "@phala/dstack-sdk/verify-env-encrypt-public-key";
4507
5438
  export {
4508
5439
  AddComposeHashSchema,
5440
+ AddDeviceSchema,
4509
5441
  AllFamiliesResponseSchema,
4510
5442
  ApiErrorSchema,
5443
+ AppAttestationInstanceSchema,
5444
+ AppAttestationResponseSchema,
4511
5445
  AppFilterOptionsSchema,
4512
5446
  AppProfileSchema,
4513
5447
  AppRevisionDetailResponseSchema,
@@ -4518,6 +5452,9 @@ export {
4518
5452
  AvailableNodesSchema,
4519
5453
  BillingPeriodSchema,
4520
5454
  BusinessError,
5455
+ CertificateIssuerSchema,
5456
+ CertificateSchema,
5457
+ CertificateSubjectSchema,
4521
5458
  CommitCvmComposeFileUpdateRequestSchema,
4522
5459
  CommitCvmComposeFileUpdateSchema,
4523
5460
  CommitCvmProvisionRequestSchema,
@@ -4563,9 +5500,13 @@ export {
4563
5500
  DstackAppMinimalResponseV20260121Schema,
4564
5501
  DstackAppWithCvmResponseV20251028Schema,
4565
5502
  DstackAppWithCvmResponseV20260121Schema,
5503
+ EventLogSchema,
4566
5504
  FamilyGroupSchema,
4567
5505
  FamilyInstanceTypesResponseSchema,
5506
+ GetAllowedDevicesSchema,
5507
+ GetAppAttestationRequestSchema,
4568
5508
  GetAppCvmsRequestSchema,
5509
+ GetAppDeviceAllowlistRequestSchema,
4569
5510
  GetAppEnvEncryptPubKeyRequestSchema,
4570
5511
  GetAppEnvEncryptPubKeySchema,
4571
5512
  GetAppInfoRequestSchema,
@@ -4590,10 +5531,15 @@ export {
4590
5531
  GetKmsInfoRequestSchema,
4591
5532
  GetKmsListRequestSchema,
4592
5533
  GetKmsListSchema,
5534
+ GetKmsOnChainDetailRequestSchema,
5535
+ GetKmsOnChainDetailResponseSchema,
5536
+ GetOsImagesRequestSchema,
5537
+ GetOsImagesResponseSchema,
4593
5538
  GetWorkspaceNodesSchema,
4594
5539
  GetWorkspaceQuotasSchema,
4595
5540
  ImportGithubProfileRequestSchema,
4596
5541
  ImportGithubProfileResponseSchema,
5542
+ InstanceIdRefreshResultSchema,
4597
5543
  InstanceTypeSchema,
4598
5544
  KmsInfoSchema,
4599
5545
  KmsTypeSchema,
@@ -4610,7 +5556,11 @@ export {
4610
5556
  NextAppIdsSchema,
4611
5557
  NodeInfoSchema,
4612
5558
  NodeRefSchema,
5559
+ OSImagePublicSchema,
4613
5560
  OSImageVariantSchema,
5561
+ OnChainDeviceSchema,
5562
+ OnChainKmsContractSchema,
5563
+ OnChainOsImageSchema,
4614
5564
  PaginatedCvmInfosV20251028Schema,
4615
5565
  PaginatedCvmInfosV20260121Schema,
4616
5566
  PaginationMetadataSchema,
@@ -4620,17 +5570,24 @@ export {
4620
5570
  ProvisionCvmRequestSchema,
4621
5571
  ProvisionCvmSchema,
4622
5572
  QuotaMetricSchema,
5573
+ RefreshCvmInstanceIdRequestSchema,
5574
+ RefreshCvmInstanceIdsRequestSchema,
5575
+ RefreshCvmInstanceIdsResponseSchema,
5576
+ RemoveDeviceSchema,
5577
+ ReplicateCvmRequestSchema,
4623
5578
  RequestError,
4624
5579
  ResourceError,
4625
5580
  RestartCvmRequestSchema,
4626
5581
  SUPPORTED_API_VERSIONS,
4627
5582
  SUPPORTED_CHAINS,
4628
5583
  ServerError,
5584
+ SetAllowAnyDeviceSchema,
4629
5585
  ShutdownCvmRequestSchema,
4630
5586
  SshKeySchema,
4631
5587
  StartCvmRequestSchema,
4632
5588
  StopCvmRequestSchema,
4633
5589
  SyncGithubSshKeysResponseSchema,
5590
+ TcbInfoSchema,
4634
5591
  TransactionError,
4635
5592
  UnknownError,
4636
5593
  UpdateCvmEnvsRequestSchema,
@@ -4656,10 +5613,12 @@ export {
4656
5613
  WorkspaceReservedGpuQuotaSchema,
4657
5614
  WorkspaceResponseSchema,
4658
5615
  addComposeHash,
5616
+ addDevice,
4659
5617
  addNetwork,
4660
5618
  asHex,
4661
5619
  autoCreateClients,
4662
5620
  checkBalance,
5621
+ checkDeviceAllowed,
4663
5622
  checkNetworkStatus,
4664
5623
  commitCvmComposeFileUpdate,
4665
5624
  commitCvmProvision,
@@ -4676,6 +5635,7 @@ export {
4676
5635
  deleteCvm,
4677
5636
  deleteSshKey,
4678
5637
  deployAppAuth,
5638
+ dstackAppAbi,
4679
5639
  dumpAppCompose,
4680
5640
  encryptEnvVars2 as encryptEnvVars,
4681
5641
  estimateTransactionGas,
@@ -4688,7 +5648,10 @@ export {
4688
5648
  formatValidationErrors,
4689
5649
  generateDefaultCvmName,
4690
5650
  generateFallbackHostname,
5651
+ getAllowedDevices,
5652
+ getAppAttestation,
4691
5653
  getAppCvms,
5654
+ getAppDeviceAllowlist,
4692
5655
  getAppEnvEncryptPubKey,
4693
5656
  getAppFilterOptions,
4694
5657
  getAppInfo,
@@ -4714,6 +5677,8 @@ export {
4714
5677
  getErrorMessage,
4715
5678
  getKmsInfo,
4716
5679
  getKmsList,
5680
+ getKmsOnChainDetail,
5681
+ getOsImages,
4717
5682
  getValidationFields,
4718
5683
  getWorkspace,
4719
5684
  getWorkspaceNodes,
@@ -4732,15 +5697,24 @@ export {
4732
5697
  provisionCvm,
4733
5698
  provisionCvmComposeFileUpdate,
4734
5699
  refineCvmId,
5700
+ refreshCvmInstanceId,
5701
+ refreshCvmInstanceIds,
5702
+ removeDevice,
5703
+ replicateCvm,
4735
5704
  restartCvm,
4736
5705
  safeAddComposeHash,
5706
+ safeAddDevice,
5707
+ safeCheckDeviceAllowed,
4737
5708
  safeCommitCvmComposeFileUpdate,
4738
5709
  safeCommitCvmProvision,
4739
5710
  safeCreateSshKey,
4740
5711
  safeDeleteCvm,
4741
5712
  safeDeleteSshKey,
4742
5713
  safeDeployAppAuth,
5714
+ safeGetAllowedDevices,
5715
+ safeGetAppAttestation,
4743
5716
  safeGetAppCvms,
5717
+ safeGetAppDeviceAllowlist,
4744
5718
  safeGetAppEnvEncryptPubKey,
4745
5719
  safeGetAppFilterOptions,
4746
5720
  safeGetAppInfo,
@@ -4764,6 +5738,8 @@ export {
4764
5738
  safeGetCvmUserConfig,
4765
5739
  safeGetKmsInfo,
4766
5740
  safeGetKmsList,
5741
+ safeGetKmsOnChainDetail,
5742
+ safeGetOsImages,
4767
5743
  safeGetWorkspace,
4768
5744
  safeGetWorkspaceNodes,
4769
5745
  safeGetWorkspaceQuotas,
@@ -4775,7 +5751,12 @@ export {
4775
5751
  safeNextAppIds,
4776
5752
  safeProvisionCvm,
4777
5753
  safeProvisionCvmComposeFileUpdate,
5754
+ safeRefreshCvmInstanceId,
5755
+ safeRefreshCvmInstanceIds,
5756
+ safeRemoveDevice,
5757
+ safeReplicateCvm,
4778
5758
  safeRestartCvm,
5759
+ safeSetAllowAnyDevice,
4779
5760
  safeShutdownCvm,
4780
5761
  safeStartCvm,
4781
5762
  safeStopCvm,
@@ -4787,6 +5768,7 @@ export {
4787
5768
  safeUpdateOsImage,
4788
5769
  safeUpdatePreLaunchScript,
4789
5770
  safeValidateActionParameters,
5771
+ setAllowAnyDevice,
4790
5772
  shutdownCvm,
4791
5773
  sortObject,
4792
5774
  startCvm,