@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/actions/cvms/get_available_os_images.d.ts +217 -0
- package/dist/actions/cvms/get_cvm_state.d.ts +93 -0
- package/dist/actions/cvms/update_os_image.d.ts +61 -0
- package/dist/actions/cvms/watch_cvm_state.d.ts +157 -0
- package/dist/actions/get_available_nodes.d.ts +11 -11
- package/dist/actions/get_current_user.d.ts +11 -11
- package/dist/actions/index.d.ts +5 -0
- package/dist/actions/kms/next_app_ids.d.ts +73 -0
- package/dist/create-client.d.ts +60 -0
- package/dist/index.js +486 -171
- package/dist/index.mjs +466 -171
- package/dist/utils/define-action.d.ts +8 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -50,12 +50,15 @@ __export(index_exports, {
|
|
|
50
50
|
CvmNetworkSchema: () => CvmNetworkSchema,
|
|
51
51
|
CvmNetworkUrlsSchema: () => CvmNetworkUrlsSchema,
|
|
52
52
|
CvmNodeSchema: () => CvmNodeSchema,
|
|
53
|
+
CvmStateSchema: () => CvmStateSchema,
|
|
53
54
|
CvmSystemInfoSchema: () => CvmSystemInfoSchema,
|
|
54
55
|
DeleteCvmRequestSchema: () => DeleteCvmRequestSchema,
|
|
55
56
|
DeployAppAuthRequestSchema: () => DeployAppAuthRequestSchema,
|
|
56
57
|
DeployAppAuthSchema: () => DeployAppAuthSchema,
|
|
57
58
|
GetAppEnvEncryptPubKeyRequestSchema: () => GetAppEnvEncryptPubKeyRequestSchema,
|
|
58
59
|
GetAppEnvEncryptPubKeySchema: () => GetAppEnvEncryptPubKeySchema,
|
|
60
|
+
GetAvailableOSImagesRequestSchema: () => GetAvailableOSImagesRequestSchema,
|
|
61
|
+
GetAvailableOSImagesResponseSchema: () => GetAvailableOSImagesResponseSchema,
|
|
59
62
|
GetCvmAttestationRequestSchema: () => GetCvmAttestationRequestSchema,
|
|
60
63
|
GetCvmComposeFileRequestSchema: () => GetCvmComposeFileRequestSchema,
|
|
61
64
|
GetCvmContainersStatsRequestSchema: () => GetCvmContainersStatsRequestSchema,
|
|
@@ -64,6 +67,7 @@ __export(index_exports, {
|
|
|
64
67
|
GetCvmListRequestSchema: () => GetCvmListRequestSchema,
|
|
65
68
|
GetCvmListSchema: () => GetCvmListSchema,
|
|
66
69
|
GetCvmNetworkRequestSchema: () => GetCvmNetworkRequestSchema,
|
|
70
|
+
GetCvmStateRequestSchema: () => GetCvmStateRequestSchema,
|
|
67
71
|
GetCvmStatsRequestSchema: () => GetCvmStatsRequestSchema,
|
|
68
72
|
GetKmsInfoRequestSchema: () => GetKmsInfoRequestSchema,
|
|
69
73
|
GetKmsListRequestSchema: () => GetKmsListRequestSchema,
|
|
@@ -73,7 +77,11 @@ __export(index_exports, {
|
|
|
73
77
|
ListInstanceTypesRequestSchema: () => ListInstanceTypesRequestSchema,
|
|
74
78
|
ListWorkspacesSchema: () => ListWorkspacesSchema,
|
|
75
79
|
ManagedUserSchema: () => ManagedUserSchema,
|
|
80
|
+
MaxRetriesExceededError: () => MaxRetriesExceededError,
|
|
76
81
|
NetworkError: () => NetworkError,
|
|
82
|
+
NextAppIdsRequestSchema: () => NextAppIdsRequestSchema,
|
|
83
|
+
NextAppIdsSchema: () => NextAppIdsSchema,
|
|
84
|
+
OSImageVariantSchema: () => OSImageVariantSchema,
|
|
77
85
|
PaginatedInstanceTypesSchema: () => PaginatedInstanceTypesSchema,
|
|
78
86
|
PaginationMetadataSchema: () => PaginationMetadataSchema,
|
|
79
87
|
PhalaCloudError: () => PhalaCloudError,
|
|
@@ -92,10 +100,13 @@ __export(index_exports, {
|
|
|
92
100
|
UnknownError: () => UnknownError,
|
|
93
101
|
UpdateCvmResourcesRequestSchema: () => UpdateCvmResourcesRequestSchema,
|
|
94
102
|
UpdateCvmVisibilityRequestSchema: () => UpdateCvmVisibilityRequestSchema,
|
|
103
|
+
UpdateOsImageRequestSchema: () => UpdateOsImageRequestSchema,
|
|
95
104
|
VMSchema: () => VMSchema,
|
|
96
105
|
ValidationError: () => ValidationError,
|
|
97
106
|
VmInfoSchema: () => VmInfoSchema,
|
|
98
107
|
WalletError: () => WalletError,
|
|
108
|
+
WatchAbortedError: () => WatchAbortedError,
|
|
109
|
+
WatchCvmStateRequestSchema: () => WatchCvmStateRequestSchema,
|
|
99
110
|
WorkspaceResponseSchema: () => WorkspaceResponseSchema,
|
|
100
111
|
addComposeHash: () => addComposeHash,
|
|
101
112
|
addNetwork: () => addNetwork,
|
|
@@ -126,6 +137,7 @@ __export(index_exports, {
|
|
|
126
137
|
formatValidationErrors: () => formatValidationErrors,
|
|
127
138
|
getAppEnvEncryptPubKey: () => getAppEnvEncryptPubKey,
|
|
128
139
|
getAvailableNodes: () => getAvailableNodes,
|
|
140
|
+
getAvailableOsImages: () => getAvailableOsImages,
|
|
129
141
|
getComposeHash: () => import_get_compose_hash3.getComposeHash,
|
|
130
142
|
getCurrentUser: () => getCurrentUser,
|
|
131
143
|
getCvmAttestation: () => getCvmAttestation,
|
|
@@ -135,6 +147,7 @@ __export(index_exports, {
|
|
|
135
147
|
getCvmInfo: () => getCvmInfo,
|
|
136
148
|
getCvmList: () => getCvmList,
|
|
137
149
|
getCvmNetwork: () => getCvmNetwork,
|
|
150
|
+
getCvmState: () => getCvmState,
|
|
138
151
|
getCvmStats: () => getCvmStats,
|
|
139
152
|
getErrorMessage: () => getErrorMessage,
|
|
140
153
|
getKmsInfo: () => getKmsInfo,
|
|
@@ -143,6 +156,7 @@ __export(index_exports, {
|
|
|
143
156
|
getWorkspace: () => getWorkspace,
|
|
144
157
|
listInstanceTypes: () => listInstanceTypes,
|
|
145
158
|
listWorkspaces: () => listWorkspaces,
|
|
159
|
+
nextAppIds: () => nextAppIds,
|
|
146
160
|
parseApiError: () => parseApiError,
|
|
147
161
|
parseEnv: () => parseEnv,
|
|
148
162
|
parseEnvVars: () => parseEnvVars,
|
|
@@ -158,6 +172,7 @@ __export(index_exports, {
|
|
|
158
172
|
safeDeployAppAuth: () => safeDeployAppAuth,
|
|
159
173
|
safeGetAppEnvEncryptPubKey: () => safeGetAppEnvEncryptPubKey,
|
|
160
174
|
safeGetAvailableNodes: () => safeGetAvailableNodes,
|
|
175
|
+
safeGetAvailableOsImages: () => safeGetAvailableOsImages,
|
|
161
176
|
safeGetCurrentUser: () => safeGetCurrentUser,
|
|
162
177
|
safeGetCvmAttestation: () => safeGetCvmAttestation,
|
|
163
178
|
safeGetCvmComposeFile: () => safeGetCvmComposeFile,
|
|
@@ -166,12 +181,14 @@ __export(index_exports, {
|
|
|
166
181
|
safeGetCvmInfo: () => safeGetCvmInfo,
|
|
167
182
|
safeGetCvmList: () => safeGetCvmList,
|
|
168
183
|
safeGetCvmNetwork: () => safeGetCvmNetwork,
|
|
184
|
+
safeGetCvmState: () => safeGetCvmState,
|
|
169
185
|
safeGetCvmStats: () => safeGetCvmStats,
|
|
170
186
|
safeGetKmsInfo: () => safeGetKmsInfo,
|
|
171
187
|
safeGetKmsList: () => safeGetKmsList,
|
|
172
188
|
safeGetWorkspace: () => safeGetWorkspace,
|
|
173
189
|
safeListInstanceTypes: () => safeListInstanceTypes,
|
|
174
190
|
safeListWorkspaces: () => safeListWorkspaces,
|
|
191
|
+
safeNextAppIds: () => safeNextAppIds,
|
|
175
192
|
safeProvisionCvm: () => safeProvisionCvm,
|
|
176
193
|
safeProvisionCvmComposeFileUpdate: () => safeProvisionCvmComposeFileUpdate,
|
|
177
194
|
safeRestartCvm: () => safeRestartCvm,
|
|
@@ -180,6 +197,7 @@ __export(index_exports, {
|
|
|
180
197
|
safeStopCvm: () => safeStopCvm,
|
|
181
198
|
safeUpdateCvmResources: () => safeUpdateCvmResources,
|
|
182
199
|
safeUpdateCvmVisibility: () => safeUpdateCvmVisibility,
|
|
200
|
+
safeUpdateOsImage: () => safeUpdateOsImage,
|
|
183
201
|
safeValidateActionParameters: () => safeValidateActionParameters,
|
|
184
202
|
shutdownCvm: () => shutdownCvm,
|
|
185
203
|
sortObject: () => sortObject,
|
|
@@ -188,10 +206,12 @@ __export(index_exports, {
|
|
|
188
206
|
switchToNetwork: () => switchToNetwork,
|
|
189
207
|
updateCvmResources: () => updateCvmResources,
|
|
190
208
|
updateCvmVisibility: () => updateCvmVisibility,
|
|
209
|
+
updateOsImage: () => updateOsImage,
|
|
191
210
|
validateActionParameters: () => validateActionParameters,
|
|
192
211
|
validateNetworkPrerequisites: () => validateNetworkPrerequisites,
|
|
193
212
|
verifyEnvEncryptPublicKey: () => import_verify_env_encrypt_public_key.verifyEnvEncryptPublicKey,
|
|
194
213
|
waitForTransactionReceipt: () => waitForTransactionReceipt,
|
|
214
|
+
watchCvmState: () => watchCvmState,
|
|
195
215
|
withComposeMethods: () => withComposeMethods
|
|
196
216
|
});
|
|
197
217
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1567,6 +1587,26 @@ var { action: getAppEnvEncryptPubKey, safeAction: safeGetAppEnvEncryptPubKey } =
|
|
|
1567
1587
|
return await client.get(`/kms/${validatedRequest.kms}/pubkey/${validatedRequest.app_id}`);
|
|
1568
1588
|
});
|
|
1569
1589
|
|
|
1590
|
+
// src/actions/kms/next_app_ids.ts
|
|
1591
|
+
var import_zod18 = require("zod");
|
|
1592
|
+
var NextAppIdsRequestSchema = import_zod18.z.object({
|
|
1593
|
+
counts: import_zod18.z.number().int().min(1).max(20).optional().default(1)
|
|
1594
|
+
}).strict();
|
|
1595
|
+
var NextAppIdsSchema = import_zod18.z.object({
|
|
1596
|
+
app_ids: import_zod18.z.array(
|
|
1597
|
+
import_zod18.z.object({
|
|
1598
|
+
app_id: import_zod18.z.string(),
|
|
1599
|
+
nonce: import_zod18.z.number().int().min(0)
|
|
1600
|
+
})
|
|
1601
|
+
)
|
|
1602
|
+
}).strict();
|
|
1603
|
+
var { action: nextAppIds, safeAction: safeNextAppIds } = defineAction(NextAppIdsSchema, async (client, payload) => {
|
|
1604
|
+
const validatedRequest = NextAppIdsRequestSchema.parse(payload ?? {});
|
|
1605
|
+
const params = new URLSearchParams();
|
|
1606
|
+
params.append("counts", validatedRequest.counts.toString());
|
|
1607
|
+
return await client.get(`/kms/phala/next_app_id?${params.toString()}`);
|
|
1608
|
+
});
|
|
1609
|
+
|
|
1570
1610
|
// src/actions/cvms/start_cvm.ts
|
|
1571
1611
|
var StartCvmRequestSchema = CvmIdSchema;
|
|
1572
1612
|
var { action: startCvm, safeAction: safeStartCvm } = defineAction(VMSchema, async (client, request) => {
|
|
@@ -1592,10 +1632,10 @@ var { action: shutdownCvm, safeAction: safeShutdownCvm } = defineAction(VMSchema
|
|
|
1592
1632
|
});
|
|
1593
1633
|
|
|
1594
1634
|
// src/actions/cvms/restart_cvm.ts
|
|
1595
|
-
var
|
|
1635
|
+
var import_zod19 = require("zod");
|
|
1596
1636
|
var RestartCvmRequestSchema = refineCvmId(
|
|
1597
1637
|
CvmIdObjectSchema.extend({
|
|
1598
|
-
force:
|
|
1638
|
+
force: import_zod19.z.boolean().optional()
|
|
1599
1639
|
})
|
|
1600
1640
|
);
|
|
1601
1641
|
var { action: restartCvm, safeAction: safeRestartCvm } = defineAction(VMSchema, async (client, request) => {
|
|
@@ -1606,10 +1646,10 @@ var { action: restartCvm, safeAction: safeRestartCvm } = defineAction(VMSchema,
|
|
|
1606
1646
|
});
|
|
1607
1647
|
|
|
1608
1648
|
// src/actions/cvms/delete_cvm.ts
|
|
1609
|
-
var
|
|
1649
|
+
var import_zod20 = require("zod");
|
|
1610
1650
|
var DeleteCvmRequestSchema = CvmIdSchema;
|
|
1611
1651
|
var { action: deleteCvm, safeAction: safeDeleteCvm } = defineAction(
|
|
1612
|
-
|
|
1652
|
+
import_zod20.z.void(),
|
|
1613
1653
|
async (client, request) => {
|
|
1614
1654
|
const { cvmId } = DeleteCvmRequestSchema.parse(request);
|
|
1615
1655
|
await client.delete(`/cvms/${cvmId}`);
|
|
@@ -1618,41 +1658,41 @@ var { action: deleteCvm, safeAction: safeDeleteCvm } = defineAction(
|
|
|
1618
1658
|
);
|
|
1619
1659
|
|
|
1620
1660
|
// src/actions/cvms/get_cvm_stats.ts
|
|
1621
|
-
var
|
|
1622
|
-
var DiskInfoSchema =
|
|
1623
|
-
name:
|
|
1624
|
-
mount_point:
|
|
1625
|
-
total_size:
|
|
1626
|
-
free_size:
|
|
1661
|
+
var import_zod21 = require("zod");
|
|
1662
|
+
var DiskInfoSchema = import_zod21.z.object({
|
|
1663
|
+
name: import_zod21.z.string(),
|
|
1664
|
+
mount_point: import_zod21.z.string(),
|
|
1665
|
+
total_size: import_zod21.z.number(),
|
|
1666
|
+
free_size: import_zod21.z.number()
|
|
1627
1667
|
});
|
|
1628
|
-
var SystemInfoSchema =
|
|
1629
|
-
os_name:
|
|
1630
|
-
os_version:
|
|
1631
|
-
kernel_version:
|
|
1632
|
-
cpu_model:
|
|
1633
|
-
num_cpus:
|
|
1634
|
-
total_memory:
|
|
1635
|
-
available_memory:
|
|
1636
|
-
used_memory:
|
|
1637
|
-
free_memory:
|
|
1638
|
-
total_swap:
|
|
1639
|
-
used_swap:
|
|
1640
|
-
free_swap:
|
|
1641
|
-
uptime:
|
|
1642
|
-
loadavg_one:
|
|
1643
|
-
loadavg_five:
|
|
1644
|
-
loadavg_fifteen:
|
|
1645
|
-
disks:
|
|
1668
|
+
var SystemInfoSchema = import_zod21.z.object({
|
|
1669
|
+
os_name: import_zod21.z.string(),
|
|
1670
|
+
os_version: import_zod21.z.string(),
|
|
1671
|
+
kernel_version: import_zod21.z.string(),
|
|
1672
|
+
cpu_model: import_zod21.z.string(),
|
|
1673
|
+
num_cpus: import_zod21.z.number(),
|
|
1674
|
+
total_memory: import_zod21.z.number(),
|
|
1675
|
+
available_memory: import_zod21.z.number(),
|
|
1676
|
+
used_memory: import_zod21.z.number(),
|
|
1677
|
+
free_memory: import_zod21.z.number(),
|
|
1678
|
+
total_swap: import_zod21.z.number(),
|
|
1679
|
+
used_swap: import_zod21.z.number(),
|
|
1680
|
+
free_swap: import_zod21.z.number(),
|
|
1681
|
+
uptime: import_zod21.z.number(),
|
|
1682
|
+
loadavg_one: import_zod21.z.number(),
|
|
1683
|
+
loadavg_five: import_zod21.z.number(),
|
|
1684
|
+
loadavg_fifteen: import_zod21.z.number(),
|
|
1685
|
+
disks: import_zod21.z.array(DiskInfoSchema)
|
|
1646
1686
|
});
|
|
1647
|
-
var CvmSystemInfoSchema =
|
|
1648
|
-
is_online:
|
|
1649
|
-
is_public:
|
|
1650
|
-
error:
|
|
1687
|
+
var CvmSystemInfoSchema = import_zod21.z.object({
|
|
1688
|
+
is_online: import_zod21.z.boolean(),
|
|
1689
|
+
is_public: import_zod21.z.boolean().default(false),
|
|
1690
|
+
error: import_zod21.z.string().nullable(),
|
|
1651
1691
|
sysinfo: SystemInfoSchema.nullable(),
|
|
1652
|
-
status:
|
|
1653
|
-
in_progress:
|
|
1654
|
-
boot_progress:
|
|
1655
|
-
boot_error:
|
|
1692
|
+
status: import_zod21.z.string().nullable(),
|
|
1693
|
+
in_progress: import_zod21.z.boolean().default(false),
|
|
1694
|
+
boot_progress: import_zod21.z.string().nullable(),
|
|
1695
|
+
boot_error: import_zod21.z.string().nullable()
|
|
1656
1696
|
});
|
|
1657
1697
|
var GetCvmStatsRequestSchema = CvmIdSchema;
|
|
1658
1698
|
var { action: getCvmStats, safeAction: safeGetCvmStats } = defineAction(CvmSystemInfoSchema, async (client, request) => {
|
|
@@ -1661,18 +1701,18 @@ var { action: getCvmStats, safeAction: safeGetCvmStats } = defineAction(CvmSyste
|
|
|
1661
1701
|
});
|
|
1662
1702
|
|
|
1663
1703
|
// src/actions/cvms/get_cvm_network.ts
|
|
1664
|
-
var
|
|
1665
|
-
var CvmNetworkUrlsSchema2 =
|
|
1666
|
-
app:
|
|
1667
|
-
instance:
|
|
1704
|
+
var import_zod22 = require("zod");
|
|
1705
|
+
var CvmNetworkUrlsSchema2 = import_zod22.z.object({
|
|
1706
|
+
app: import_zod22.z.string(),
|
|
1707
|
+
instance: import_zod22.z.string()
|
|
1668
1708
|
});
|
|
1669
|
-
var CvmNetworkSchema =
|
|
1670
|
-
is_online:
|
|
1671
|
-
is_public:
|
|
1672
|
-
error:
|
|
1673
|
-
internal_ip:
|
|
1674
|
-
latest_handshake:
|
|
1675
|
-
public_urls:
|
|
1709
|
+
var CvmNetworkSchema = import_zod22.z.object({
|
|
1710
|
+
is_online: import_zod22.z.boolean(),
|
|
1711
|
+
is_public: import_zod22.z.boolean().default(true),
|
|
1712
|
+
error: import_zod22.z.string().nullable(),
|
|
1713
|
+
internal_ip: import_zod22.z.string().nullable(),
|
|
1714
|
+
latest_handshake: import_zod22.z.string().nullable(),
|
|
1715
|
+
public_urls: import_zod22.z.array(CvmNetworkUrlsSchema2).nullable()
|
|
1676
1716
|
});
|
|
1677
1717
|
var GetCvmNetworkRequestSchema = CvmIdSchema;
|
|
1678
1718
|
var { action: getCvmNetwork, safeAction: safeGetCvmNetwork } = defineAction(CvmNetworkSchema, async (client, request) => {
|
|
@@ -1681,36 +1721,36 @@ var { action: getCvmNetwork, safeAction: safeGetCvmNetwork } = defineAction(CvmN
|
|
|
1681
1721
|
});
|
|
1682
1722
|
|
|
1683
1723
|
// src/actions/cvms/get_cvm_docker_compose.ts
|
|
1684
|
-
var
|
|
1724
|
+
var import_zod23 = require("zod");
|
|
1685
1725
|
var GetCvmDockerComposeRequestSchema = CvmIdSchema;
|
|
1686
|
-
var { action: getCvmDockerCompose, safeAction: safeGetCvmDockerCompose } = defineAction(
|
|
1726
|
+
var { action: getCvmDockerCompose, safeAction: safeGetCvmDockerCompose } = defineAction(import_zod23.z.string(), async (client, request) => {
|
|
1687
1727
|
const { cvmId } = GetCvmDockerComposeRequestSchema.parse(request);
|
|
1688
1728
|
return await client.get(`/cvms/${cvmId}/docker-compose.yml`);
|
|
1689
1729
|
});
|
|
1690
1730
|
|
|
1691
1731
|
// src/actions/cvms/get_cvm_containers_stats.ts
|
|
1692
|
-
var
|
|
1693
|
-
var ContainerInfoSchema =
|
|
1694
|
-
id:
|
|
1695
|
-
names:
|
|
1696
|
-
image:
|
|
1697
|
-
image_id:
|
|
1698
|
-
command:
|
|
1699
|
-
created:
|
|
1700
|
-
state:
|
|
1701
|
-
status:
|
|
1702
|
-
log_endpoint:
|
|
1732
|
+
var import_zod24 = require("zod");
|
|
1733
|
+
var ContainerInfoSchema = import_zod24.z.object({
|
|
1734
|
+
id: import_zod24.z.string(),
|
|
1735
|
+
names: import_zod24.z.array(import_zod24.z.string()),
|
|
1736
|
+
image: import_zod24.z.string(),
|
|
1737
|
+
image_id: import_zod24.z.string(),
|
|
1738
|
+
command: import_zod24.z.string().nullable().optional(),
|
|
1739
|
+
created: import_zod24.z.number(),
|
|
1740
|
+
state: import_zod24.z.string(),
|
|
1741
|
+
status: import_zod24.z.string(),
|
|
1742
|
+
log_endpoint: import_zod24.z.string().nullable()
|
|
1703
1743
|
});
|
|
1704
|
-
var CvmContainersStatsSchema =
|
|
1705
|
-
is_online:
|
|
1706
|
-
is_public:
|
|
1707
|
-
error:
|
|
1708
|
-
docker_compose_file:
|
|
1709
|
-
manifest_version:
|
|
1710
|
-
version:
|
|
1711
|
-
runner:
|
|
1712
|
-
features:
|
|
1713
|
-
containers:
|
|
1744
|
+
var CvmContainersStatsSchema = import_zod24.z.object({
|
|
1745
|
+
is_online: import_zod24.z.boolean(),
|
|
1746
|
+
is_public: import_zod24.z.boolean().default(true),
|
|
1747
|
+
error: import_zod24.z.string().nullable(),
|
|
1748
|
+
docker_compose_file: import_zod24.z.string().nullable(),
|
|
1749
|
+
manifest_version: import_zod24.z.number().nullable(),
|
|
1750
|
+
version: import_zod24.z.string().nullable(),
|
|
1751
|
+
runner: import_zod24.z.string().nullable(),
|
|
1752
|
+
features: import_zod24.z.array(import_zod24.z.string()).nullable(),
|
|
1753
|
+
containers: import_zod24.z.array(ContainerInfoSchema).nullable()
|
|
1714
1754
|
});
|
|
1715
1755
|
var GetCvmContainersStatsRequestSchema = CvmIdSchema;
|
|
1716
1756
|
var { action: getCvmContainersStats, safeAction: safeGetCvmContainersStats } = defineAction(CvmContainersStatsSchema, async (client, request) => {
|
|
@@ -1719,62 +1759,62 @@ var { action: getCvmContainersStats, safeAction: safeGetCvmContainersStats } = d
|
|
|
1719
1759
|
});
|
|
1720
1760
|
|
|
1721
1761
|
// src/actions/cvms/get_cvm_attestation.ts
|
|
1722
|
-
var
|
|
1723
|
-
var CertificateSubjectSchema =
|
|
1724
|
-
common_name:
|
|
1725
|
-
organization:
|
|
1726
|
-
country:
|
|
1727
|
-
state:
|
|
1728
|
-
locality:
|
|
1762
|
+
var import_zod25 = require("zod");
|
|
1763
|
+
var CertificateSubjectSchema = import_zod25.z.object({
|
|
1764
|
+
common_name: import_zod25.z.string().nullable(),
|
|
1765
|
+
organization: import_zod25.z.string().nullable(),
|
|
1766
|
+
country: import_zod25.z.string().nullable(),
|
|
1767
|
+
state: import_zod25.z.string().nullable(),
|
|
1768
|
+
locality: import_zod25.z.string().nullable()
|
|
1729
1769
|
});
|
|
1730
|
-
var CertificateIssuerSchema =
|
|
1731
|
-
common_name:
|
|
1732
|
-
organization:
|
|
1733
|
-
country:
|
|
1770
|
+
var CertificateIssuerSchema = import_zod25.z.object({
|
|
1771
|
+
common_name: import_zod25.z.string().nullable(),
|
|
1772
|
+
organization: import_zod25.z.string().nullable(),
|
|
1773
|
+
country: import_zod25.z.string().nullable()
|
|
1734
1774
|
});
|
|
1735
|
-
var CertificateSchema =
|
|
1775
|
+
var CertificateSchema = import_zod25.z.object({
|
|
1736
1776
|
subject: CertificateSubjectSchema,
|
|
1737
1777
|
issuer: CertificateIssuerSchema,
|
|
1738
|
-
serial_number:
|
|
1739
|
-
not_before:
|
|
1778
|
+
serial_number: import_zod25.z.string(),
|
|
1779
|
+
not_before: import_zod25.z.string(),
|
|
1740
1780
|
// datetime serialized as ISO string
|
|
1741
|
-
not_after:
|
|
1781
|
+
not_after: import_zod25.z.string(),
|
|
1742
1782
|
// datetime serialized as ISO string
|
|
1743
|
-
version:
|
|
1744
|
-
fingerprint:
|
|
1745
|
-
signature_algorithm:
|
|
1746
|
-
sans:
|
|
1747
|
-
is_ca:
|
|
1748
|
-
position_in_chain:
|
|
1749
|
-
quote:
|
|
1750
|
-
app_id:
|
|
1751
|
-
cert_usage:
|
|
1783
|
+
version: import_zod25.z.string(),
|
|
1784
|
+
fingerprint: import_zod25.z.string(),
|
|
1785
|
+
signature_algorithm: import_zod25.z.string(),
|
|
1786
|
+
sans: import_zod25.z.array(import_zod25.z.string()).nullable(),
|
|
1787
|
+
is_ca: import_zod25.z.boolean(),
|
|
1788
|
+
position_in_chain: import_zod25.z.number().nullable(),
|
|
1789
|
+
quote: import_zod25.z.string().nullable(),
|
|
1790
|
+
app_id: import_zod25.z.string().nullable().optional(),
|
|
1791
|
+
cert_usage: import_zod25.z.string().nullable().optional()
|
|
1752
1792
|
});
|
|
1753
|
-
var EventLogSchema =
|
|
1754
|
-
imr:
|
|
1755
|
-
event_type:
|
|
1756
|
-
digest:
|
|
1757
|
-
event:
|
|
1758
|
-
event_payload:
|
|
1793
|
+
var EventLogSchema = import_zod25.z.object({
|
|
1794
|
+
imr: import_zod25.z.number(),
|
|
1795
|
+
event_type: import_zod25.z.number(),
|
|
1796
|
+
digest: import_zod25.z.string(),
|
|
1797
|
+
event: import_zod25.z.string(),
|
|
1798
|
+
event_payload: import_zod25.z.string()
|
|
1759
1799
|
});
|
|
1760
|
-
var TcbInfoSchema =
|
|
1761
|
-
mrtd:
|
|
1762
|
-
rootfs_hash:
|
|
1763
|
-
rtmr0:
|
|
1764
|
-
rtmr1:
|
|
1765
|
-
rtmr2:
|
|
1766
|
-
rtmr3:
|
|
1767
|
-
event_log:
|
|
1768
|
-
app_compose:
|
|
1800
|
+
var TcbInfoSchema = import_zod25.z.object({
|
|
1801
|
+
mrtd: import_zod25.z.string(),
|
|
1802
|
+
rootfs_hash: import_zod25.z.string().nullable().optional(),
|
|
1803
|
+
rtmr0: import_zod25.z.string(),
|
|
1804
|
+
rtmr1: import_zod25.z.string(),
|
|
1805
|
+
rtmr2: import_zod25.z.string(),
|
|
1806
|
+
rtmr3: import_zod25.z.string(),
|
|
1807
|
+
event_log: import_zod25.z.array(EventLogSchema),
|
|
1808
|
+
app_compose: import_zod25.z.string()
|
|
1769
1809
|
});
|
|
1770
|
-
var CvmAttestationSchema =
|
|
1771
|
-
name:
|
|
1772
|
-
is_online:
|
|
1773
|
-
is_public:
|
|
1774
|
-
error:
|
|
1775
|
-
app_certificates:
|
|
1810
|
+
var CvmAttestationSchema = import_zod25.z.object({
|
|
1811
|
+
name: import_zod25.z.string().nullable(),
|
|
1812
|
+
is_online: import_zod25.z.boolean(),
|
|
1813
|
+
is_public: import_zod25.z.boolean().default(true),
|
|
1814
|
+
error: import_zod25.z.string().nullable(),
|
|
1815
|
+
app_certificates: import_zod25.z.array(CertificateSchema).nullable(),
|
|
1776
1816
|
tcb_info: TcbInfoSchema.nullable(),
|
|
1777
|
-
compose_file:
|
|
1817
|
+
compose_file: import_zod25.z.string().nullable()
|
|
1778
1818
|
});
|
|
1779
1819
|
var GetCvmAttestationRequestSchema = CvmIdSchema;
|
|
1780
1820
|
var { action: getCvmAttestation, safeAction: safeGetCvmAttestation } = defineAction(CvmAttestationSchema, async (client, request) => {
|
|
@@ -1783,17 +1823,17 @@ var { action: getCvmAttestation, safeAction: safeGetCvmAttestation } = defineAct
|
|
|
1783
1823
|
});
|
|
1784
1824
|
|
|
1785
1825
|
// src/actions/cvms/update_cvm_resources.ts
|
|
1786
|
-
var
|
|
1826
|
+
var import_zod26 = require("zod");
|
|
1787
1827
|
var UpdateCvmResourcesRequestSchema = refineCvmId(
|
|
1788
1828
|
CvmIdObjectSchema.extend({
|
|
1789
|
-
vcpu:
|
|
1790
|
-
memory:
|
|
1791
|
-
disk_size:
|
|
1792
|
-
instance_type:
|
|
1793
|
-
allow_restart:
|
|
1829
|
+
vcpu: import_zod26.z.number().optional(),
|
|
1830
|
+
memory: import_zod26.z.number().optional(),
|
|
1831
|
+
disk_size: import_zod26.z.number().optional(),
|
|
1832
|
+
instance_type: import_zod26.z.string().optional(),
|
|
1833
|
+
allow_restart: import_zod26.z.boolean().optional()
|
|
1794
1834
|
})
|
|
1795
1835
|
);
|
|
1796
|
-
var { action: updateCvmResources, safeAction: safeUpdateCvmResources } = defineAction(
|
|
1836
|
+
var { action: updateCvmResources, safeAction: safeUpdateCvmResources } = defineAction(import_zod26.z.void(), async (client, request) => {
|
|
1797
1837
|
const parsed = UpdateCvmResourcesRequestSchema.parse(request);
|
|
1798
1838
|
const { cvmId } = CvmIdSchema.parse(parsed);
|
|
1799
1839
|
const { ...body } = parsed;
|
|
@@ -1802,11 +1842,11 @@ var { action: updateCvmResources, safeAction: safeUpdateCvmResources } = defineA
|
|
|
1802
1842
|
});
|
|
1803
1843
|
|
|
1804
1844
|
// src/actions/cvms/update_cvm_visibility.ts
|
|
1805
|
-
var
|
|
1845
|
+
var import_zod27 = require("zod");
|
|
1806
1846
|
var UpdateCvmVisibilityRequestSchema = refineCvmId(
|
|
1807
1847
|
CvmIdObjectSchema.extend({
|
|
1808
|
-
public_sysinfo:
|
|
1809
|
-
public_logs:
|
|
1848
|
+
public_sysinfo: import_zod27.z.boolean(),
|
|
1849
|
+
public_logs: import_zod27.z.boolean()
|
|
1810
1850
|
})
|
|
1811
1851
|
);
|
|
1812
1852
|
var { action: updateCvmVisibility, safeAction: safeUpdateCvmVisibility } = defineAction(CvmLegacyDetailSchema, async (client, request) => {
|
|
@@ -1816,6 +1856,59 @@ var { action: updateCvmVisibility, safeAction: safeUpdateCvmVisibility } = defin
|
|
|
1816
1856
|
return await client.patch(`/cvms/${cvmId}/visibility`, { public_sysinfo, public_logs });
|
|
1817
1857
|
});
|
|
1818
1858
|
|
|
1859
|
+
// src/actions/cvms/get_available_os_images.ts
|
|
1860
|
+
var import_zod28 = require("zod");
|
|
1861
|
+
var OSImageVariantSchema = import_zod28.z.object({
|
|
1862
|
+
name: import_zod28.z.string(),
|
|
1863
|
+
os_image_hash: import_zod28.z.string().nullable(),
|
|
1864
|
+
is_current: import_zod28.z.boolean()
|
|
1865
|
+
});
|
|
1866
|
+
var AvailableOSImageSchema2 = import_zod28.z.object({
|
|
1867
|
+
version: import_zod28.z.union([
|
|
1868
|
+
import_zod28.z.tuple([import_zod28.z.number(), import_zod28.z.number(), import_zod28.z.number(), import_zod28.z.number()]),
|
|
1869
|
+
import_zod28.z.tuple([import_zod28.z.number(), import_zod28.z.number(), import_zod28.z.number()])
|
|
1870
|
+
]),
|
|
1871
|
+
prod: OSImageVariantSchema.nullable(),
|
|
1872
|
+
dev: OSImageVariantSchema.nullable()
|
|
1873
|
+
});
|
|
1874
|
+
var GetAvailableOSImagesResponseSchema = import_zod28.z.array(AvailableOSImageSchema2);
|
|
1875
|
+
var GetAvailableOSImagesRequestSchema = CvmIdSchema;
|
|
1876
|
+
var { action: getAvailableOsImages, safeAction: safeGetAvailableOsImages } = defineAction(GetAvailableOSImagesResponseSchema, async (client, request) => {
|
|
1877
|
+
const { cvmId } = GetAvailableOSImagesRequestSchema.parse(request);
|
|
1878
|
+
return await client.get(`/cvms/${cvmId}/available-os-images`);
|
|
1879
|
+
});
|
|
1880
|
+
|
|
1881
|
+
// src/actions/cvms/update_os_image.ts
|
|
1882
|
+
var import_zod29 = require("zod");
|
|
1883
|
+
var UpdateOsImageRequestSchema = refineCvmId(
|
|
1884
|
+
CvmIdObjectSchema.extend({
|
|
1885
|
+
os_image_name: import_zod29.z.string().min(1, "OS image name is required")
|
|
1886
|
+
})
|
|
1887
|
+
);
|
|
1888
|
+
var { action: updateOsImage, safeAction: safeUpdateOsImage } = defineAction(import_zod29.z.void(), async (client, request) => {
|
|
1889
|
+
const parsed = UpdateOsImageRequestSchema.parse(request);
|
|
1890
|
+
const { cvmId } = CvmIdSchema.parse(parsed);
|
|
1891
|
+
const { os_image_name } = parsed;
|
|
1892
|
+
await client.patch(`/cvms/${cvmId}/os-image`, { os_image_name });
|
|
1893
|
+
return void 0;
|
|
1894
|
+
});
|
|
1895
|
+
|
|
1896
|
+
// src/actions/cvms/get_cvm_state.ts
|
|
1897
|
+
var import_zod30 = require("zod");
|
|
1898
|
+
var CvmStateSchema = import_zod30.z.object({
|
|
1899
|
+
status: import_zod30.z.string(),
|
|
1900
|
+
derived_status: import_zod30.z.string().optional(),
|
|
1901
|
+
vm_uuid: import_zod30.z.string().optional(),
|
|
1902
|
+
instance_id: import_zod30.z.string().optional(),
|
|
1903
|
+
uptime: import_zod30.z.string().optional()
|
|
1904
|
+
// Add other state fields as needed
|
|
1905
|
+
});
|
|
1906
|
+
var GetCvmStateRequestSchema = CvmIdSchema;
|
|
1907
|
+
var { action: getCvmState, safeAction: safeGetCvmState } = defineAction(CvmStateSchema, async (client, request) => {
|
|
1908
|
+
const { cvmId } = GetCvmStateRequestSchema.parse(request);
|
|
1909
|
+
return await client.get(`/cvms/${cvmId}/state`);
|
|
1910
|
+
});
|
|
1911
|
+
|
|
1819
1912
|
// src/create-client.ts
|
|
1820
1913
|
function createClient2(config = {}) {
|
|
1821
1914
|
const client = createClient(config);
|
|
@@ -1868,18 +1961,26 @@ function createClient2(config = {}) {
|
|
|
1868
1961
|
safeUpdateCvmResources,
|
|
1869
1962
|
updateCvmVisibility,
|
|
1870
1963
|
safeUpdateCvmVisibility,
|
|
1964
|
+
getAvailableOsImages,
|
|
1965
|
+
safeGetAvailableOsImages,
|
|
1966
|
+
updateOsImage,
|
|
1967
|
+
safeUpdateOsImage,
|
|
1871
1968
|
getKmsInfo,
|
|
1872
1969
|
safeGetKmsInfo,
|
|
1873
1970
|
getKmsList,
|
|
1874
1971
|
safeGetKmsList,
|
|
1875
1972
|
getAppEnvEncryptPubKey,
|
|
1876
|
-
safeGetAppEnvEncryptPubKey
|
|
1973
|
+
safeGetAppEnvEncryptPubKey,
|
|
1974
|
+
nextAppIds,
|
|
1975
|
+
safeNextAppIds,
|
|
1976
|
+
getCvmState,
|
|
1977
|
+
safeGetCvmState
|
|
1877
1978
|
};
|
|
1878
1979
|
return client.extend(allActions);
|
|
1879
1980
|
}
|
|
1880
1981
|
|
|
1881
1982
|
// src/actions/blockchains/deploy_app_auth.ts
|
|
1882
|
-
var
|
|
1983
|
+
var import_zod31 = require("zod");
|
|
1883
1984
|
var import_viem3 = require("viem");
|
|
1884
1985
|
var import_accounts2 = require("viem/accounts");
|
|
1885
1986
|
|
|
@@ -2529,25 +2630,25 @@ var kmsAuthAbi = [
|
|
|
2529
2630
|
anonymous: false
|
|
2530
2631
|
}
|
|
2531
2632
|
];
|
|
2532
|
-
var DeployAppAuthRequestBaseSchema =
|
|
2633
|
+
var DeployAppAuthRequestBaseSchema = import_zod31.z.object({
|
|
2533
2634
|
// Chain configuration (conditionally required)
|
|
2534
|
-
chain:
|
|
2535
|
-
rpcUrl:
|
|
2635
|
+
chain: import_zod31.z.unknown().optional(),
|
|
2636
|
+
rpcUrl: import_zod31.z.string().optional(),
|
|
2536
2637
|
// Contract configuration (required)
|
|
2537
|
-
kmsContractAddress:
|
|
2638
|
+
kmsContractAddress: import_zod31.z.string(),
|
|
2538
2639
|
// Authentication mode: either privateKey OR walletClient (required, mutually exclusive)
|
|
2539
|
-
privateKey:
|
|
2540
|
-
walletClient:
|
|
2640
|
+
privateKey: import_zod31.z.string().optional(),
|
|
2641
|
+
walletClient: import_zod31.z.unknown().optional(),
|
|
2541
2642
|
// Public client (optional, will create default if not provided)
|
|
2542
|
-
publicClient:
|
|
2643
|
+
publicClient: import_zod31.z.unknown().optional(),
|
|
2543
2644
|
// App configuration (optional)
|
|
2544
|
-
allowAnyDevice:
|
|
2545
|
-
deviceId:
|
|
2546
|
-
composeHash:
|
|
2547
|
-
disableUpgrades:
|
|
2645
|
+
allowAnyDevice: import_zod31.z.boolean().optional().default(false),
|
|
2646
|
+
deviceId: import_zod31.z.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
|
|
2647
|
+
composeHash: import_zod31.z.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
|
|
2648
|
+
disableUpgrades: import_zod31.z.boolean().optional().default(false),
|
|
2548
2649
|
// Validation configuration (optional)
|
|
2549
|
-
skipPrerequisiteChecks:
|
|
2550
|
-
minBalance:
|
|
2650
|
+
skipPrerequisiteChecks: import_zod31.z.boolean().optional().default(false),
|
|
2651
|
+
minBalance: import_zod31.z.string().optional()
|
|
2551
2652
|
// ETH amount as string, e.g., "0.01"
|
|
2552
2653
|
}).passthrough();
|
|
2553
2654
|
var DeployAppAuthRequestSchema = DeployAppAuthRequestBaseSchema.refine(
|
|
@@ -2575,13 +2676,13 @@ var DeployAppAuthRequestSchema = DeployAppAuthRequestBaseSchema.refine(
|
|
|
2575
2676
|
path: ["chain"]
|
|
2576
2677
|
}
|
|
2577
2678
|
);
|
|
2578
|
-
var DeployAppAuthSchema =
|
|
2579
|
-
appId:
|
|
2580
|
-
appAuthAddress:
|
|
2581
|
-
deployer:
|
|
2582
|
-
transactionHash:
|
|
2583
|
-
blockNumber:
|
|
2584
|
-
gasUsed:
|
|
2679
|
+
var DeployAppAuthSchema = import_zod31.z.object({
|
|
2680
|
+
appId: import_zod31.z.string(),
|
|
2681
|
+
appAuthAddress: import_zod31.z.string(),
|
|
2682
|
+
deployer: import_zod31.z.string(),
|
|
2683
|
+
transactionHash: import_zod31.z.string(),
|
|
2684
|
+
blockNumber: import_zod31.z.bigint().optional(),
|
|
2685
|
+
gasUsed: import_zod31.z.bigint().optional()
|
|
2585
2686
|
}).passthrough();
|
|
2586
2687
|
function parseDeploymentResult(receipt, deployer, kmsContractAddress) {
|
|
2587
2688
|
try {
|
|
@@ -2827,7 +2928,7 @@ async function safeDeployAppAuth(request, parameters) {
|
|
|
2827
2928
|
}
|
|
2828
2929
|
|
|
2829
2930
|
// src/actions/blockchains/add_compose_hash.ts
|
|
2830
|
-
var
|
|
2931
|
+
var import_zod32 = require("zod");
|
|
2831
2932
|
var import_viem4 = require("viem");
|
|
2832
2933
|
var import_accounts3 = require("viem/accounts");
|
|
2833
2934
|
var appAuthAbi = [
|
|
@@ -2845,29 +2946,29 @@ var appAuthAbi = [
|
|
|
2845
2946
|
anonymous: false
|
|
2846
2947
|
}
|
|
2847
2948
|
];
|
|
2848
|
-
var AddComposeHashRequestSchema =
|
|
2949
|
+
var AddComposeHashRequestSchema = import_zod32.z.object({
|
|
2849
2950
|
// Chain configuration (conditionally required)
|
|
2850
|
-
chain:
|
|
2851
|
-
rpcUrl:
|
|
2852
|
-
appId:
|
|
2853
|
-
composeHash:
|
|
2951
|
+
chain: import_zod32.z.unknown().optional(),
|
|
2952
|
+
rpcUrl: import_zod32.z.string().optional(),
|
|
2953
|
+
appId: import_zod32.z.string(),
|
|
2954
|
+
composeHash: import_zod32.z.string(),
|
|
2854
2955
|
// Authentication mode: either privateKey OR walletClient (required, mutually exclusive)
|
|
2855
|
-
privateKey:
|
|
2856
|
-
walletClient:
|
|
2956
|
+
privateKey: import_zod32.z.string().optional(),
|
|
2957
|
+
walletClient: import_zod32.z.unknown().optional(),
|
|
2857
2958
|
// Public client (optional, will create default if not provided)
|
|
2858
|
-
publicClient:
|
|
2959
|
+
publicClient: import_zod32.z.unknown().optional(),
|
|
2859
2960
|
// Validation configuration (optional)
|
|
2860
|
-
skipPrerequisiteChecks:
|
|
2861
|
-
minBalance:
|
|
2961
|
+
skipPrerequisiteChecks: import_zod32.z.boolean().optional().default(false),
|
|
2962
|
+
minBalance: import_zod32.z.string().optional(),
|
|
2862
2963
|
// ETH amount as string, e.g., "0.01"
|
|
2863
2964
|
// Transaction control options
|
|
2864
|
-
timeout:
|
|
2865
|
-
retryOptions:
|
|
2866
|
-
signal:
|
|
2965
|
+
timeout: import_zod32.z.number().optional().default(12e4),
|
|
2966
|
+
retryOptions: import_zod32.z.unknown().optional(),
|
|
2967
|
+
signal: import_zod32.z.unknown().optional(),
|
|
2867
2968
|
// Progress callbacks
|
|
2868
|
-
onTransactionStateChange:
|
|
2869
|
-
onTransactionSubmitted:
|
|
2870
|
-
onTransactionConfirmed:
|
|
2969
|
+
onTransactionStateChange: import_zod32.z.function().optional(),
|
|
2970
|
+
onTransactionSubmitted: import_zod32.z.function().optional(),
|
|
2971
|
+
onTransactionConfirmed: import_zod32.z.function().optional()
|
|
2871
2972
|
}).passthrough().refine(
|
|
2872
2973
|
(data) => {
|
|
2873
2974
|
const hasPrivateKey = !!data.privateKey;
|
|
@@ -2891,12 +2992,12 @@ var AddComposeHashRequestSchema = import_zod28.z.object({
|
|
|
2891
2992
|
path: ["chain"]
|
|
2892
2993
|
}
|
|
2893
2994
|
);
|
|
2894
|
-
var AddComposeHashSchema =
|
|
2895
|
-
composeHash:
|
|
2896
|
-
appId:
|
|
2897
|
-
transactionHash:
|
|
2898
|
-
blockNumber:
|
|
2899
|
-
gasUsed:
|
|
2995
|
+
var AddComposeHashSchema = import_zod32.z.object({
|
|
2996
|
+
composeHash: import_zod32.z.string(),
|
|
2997
|
+
appId: import_zod32.z.string(),
|
|
2998
|
+
transactionHash: import_zod32.z.string(),
|
|
2999
|
+
blockNumber: import_zod32.z.bigint().optional(),
|
|
3000
|
+
gasUsed: import_zod32.z.bigint().optional()
|
|
2900
3001
|
}).passthrough();
|
|
2901
3002
|
function parseComposeHashResult(receipt, composeHash, appAuthAddress, appId) {
|
|
2902
3003
|
console.log(receipt.logs);
|
|
@@ -3087,6 +3188,200 @@ async function safeAddComposeHash(request, parameters) {
|
|
|
3087
3188
|
}
|
|
3088
3189
|
}
|
|
3089
3190
|
|
|
3191
|
+
// src/actions/cvms/watch_cvm_state.ts
|
|
3192
|
+
var import_zod33 = require("zod");
|
|
3193
|
+
var WatchCvmStateParamsSchema = import_zod33.z.object({
|
|
3194
|
+
target: import_zod33.z.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),
|
|
3195
|
+
interval: import_zod33.z.number().min(5).max(30).default(5).describe("Polling interval in seconds"),
|
|
3196
|
+
timeout: import_zod33.z.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),
|
|
3197
|
+
maxRetries: import_zod33.z.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),
|
|
3198
|
+
retryDelay: import_zod33.z.number().min(0).default(5e3).describe("Delay between retries in milliseconds")
|
|
3199
|
+
});
|
|
3200
|
+
var WatchCvmStateRequestSchema = WatchCvmStateParamsSchema;
|
|
3201
|
+
var WatchAbortedError = class extends Error {
|
|
3202
|
+
constructor() {
|
|
3203
|
+
super("Watch operation was aborted");
|
|
3204
|
+
this.name = "WatchAbortedError";
|
|
3205
|
+
}
|
|
3206
|
+
};
|
|
3207
|
+
var MaxRetriesExceededError = class extends Error {
|
|
3208
|
+
constructor(attempts) {
|
|
3209
|
+
super(`Maximum retry attempts (${attempts}) exceeded`);
|
|
3210
|
+
this.attempts = attempts;
|
|
3211
|
+
this.name = "MaxRetriesExceededError";
|
|
3212
|
+
}
|
|
3213
|
+
};
|
|
3214
|
+
function parseSSEEvent(eventType, data) {
|
|
3215
|
+
try {
|
|
3216
|
+
const parsed = JSON.parse(data);
|
|
3217
|
+
return { type: eventType, data: parsed };
|
|
3218
|
+
} catch {
|
|
3219
|
+
return { type: "error", data: { error: "Failed to parse SSE event" } };
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
async function watchCvmState(client, request, options = {}) {
|
|
3223
|
+
const { cvmId } = CvmIdSchema.parse(request);
|
|
3224
|
+
const { target, interval, timeout, maxRetries, retryDelay } = WatchCvmStateParamsSchema.parse(request);
|
|
3225
|
+
const { signal, onEvent } = options;
|
|
3226
|
+
let attempt = 0;
|
|
3227
|
+
while (attempt < maxRetries) {
|
|
3228
|
+
if (signal?.aborted) {
|
|
3229
|
+
throw new WatchAbortedError();
|
|
3230
|
+
}
|
|
3231
|
+
attempt++;
|
|
3232
|
+
try {
|
|
3233
|
+
const result = await watchSingleAttempt(
|
|
3234
|
+
client,
|
|
3235
|
+
cvmId,
|
|
3236
|
+
target,
|
|
3237
|
+
interval,
|
|
3238
|
+
timeout,
|
|
3239
|
+
signal,
|
|
3240
|
+
onEvent
|
|
3241
|
+
);
|
|
3242
|
+
if (result) {
|
|
3243
|
+
return result;
|
|
3244
|
+
}
|
|
3245
|
+
if (attempt >= maxRetries) {
|
|
3246
|
+
throw new MaxRetriesExceededError(attempt);
|
|
3247
|
+
}
|
|
3248
|
+
await sleep(retryDelay, signal);
|
|
3249
|
+
} catch (error) {
|
|
3250
|
+
if (signal?.aborted) {
|
|
3251
|
+
throw new WatchAbortedError();
|
|
3252
|
+
}
|
|
3253
|
+
if (error instanceof WatchAbortedError || error instanceof MaxRetriesExceededError) {
|
|
3254
|
+
throw error;
|
|
3255
|
+
}
|
|
3256
|
+
if (attempt >= maxRetries) {
|
|
3257
|
+
throw error;
|
|
3258
|
+
}
|
|
3259
|
+
if (onEvent) {
|
|
3260
|
+
onEvent({
|
|
3261
|
+
type: "error",
|
|
3262
|
+
data: { error: error instanceof Error ? error.message : String(error) }
|
|
3263
|
+
});
|
|
3264
|
+
}
|
|
3265
|
+
await sleep(retryDelay, signal);
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
throw new MaxRetriesExceededError(attempt);
|
|
3269
|
+
}
|
|
3270
|
+
async function watchSingleAttempt(client, cvmId, target, interval, timeout, signal, onEvent) {
|
|
3271
|
+
const params = new URLSearchParams({
|
|
3272
|
+
target,
|
|
3273
|
+
interval: String(interval),
|
|
3274
|
+
timeout: String(timeout)
|
|
3275
|
+
});
|
|
3276
|
+
const baseURL = client.config.baseURL || "";
|
|
3277
|
+
const fullUrl = `${baseURL}/cvms/${cvmId}/state?${params.toString()}`;
|
|
3278
|
+
const headers = {
|
|
3279
|
+
Accept: "text/event-stream",
|
|
3280
|
+
"Cache-Control": "no-cache"
|
|
3281
|
+
};
|
|
3282
|
+
if (!client.config.useCookieAuth && client.config.apiKey) {
|
|
3283
|
+
headers["X-API-Key"] = client.config.apiKey;
|
|
3284
|
+
}
|
|
3285
|
+
if (client.config.headers) {
|
|
3286
|
+
Object.entries(client.config.headers).forEach(([key, value]) => {
|
|
3287
|
+
if (typeof value === "string") {
|
|
3288
|
+
headers[key] = value;
|
|
3289
|
+
}
|
|
3290
|
+
});
|
|
3291
|
+
}
|
|
3292
|
+
const response = await client.raw.native(fullUrl, {
|
|
3293
|
+
method: "GET",
|
|
3294
|
+
headers,
|
|
3295
|
+
signal,
|
|
3296
|
+
...client.config.useCookieAuth ? { credentials: "include" } : {}
|
|
3297
|
+
});
|
|
3298
|
+
if (!response.ok) {
|
|
3299
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
3300
|
+
}
|
|
3301
|
+
if (!response.body) {
|
|
3302
|
+
throw new Error("Response body is null");
|
|
3303
|
+
}
|
|
3304
|
+
return parseSSEStream(response.body, signal, onEvent);
|
|
3305
|
+
}
|
|
3306
|
+
async function parseSSEStream(stream, signal, onEvent) {
|
|
3307
|
+
const reader = stream.getReader();
|
|
3308
|
+
const decoder = new TextDecoder();
|
|
3309
|
+
let buffer = "";
|
|
3310
|
+
let finalState = null;
|
|
3311
|
+
let currentEvent = "";
|
|
3312
|
+
let currentData = "";
|
|
3313
|
+
const processLine = (line) => {
|
|
3314
|
+
if (line.startsWith("event:")) {
|
|
3315
|
+
currentEvent = line.slice(6).trim();
|
|
3316
|
+
} else if (line.startsWith("data:")) {
|
|
3317
|
+
currentData = line.slice(5).trim();
|
|
3318
|
+
} else if (line === "") {
|
|
3319
|
+
if (currentEvent && currentData) {
|
|
3320
|
+
const event = parseSSEEvent(currentEvent, currentData);
|
|
3321
|
+
if (event.type === "state") {
|
|
3322
|
+
finalState = event.data;
|
|
3323
|
+
}
|
|
3324
|
+
onEvent?.(event);
|
|
3325
|
+
if (event.type === "complete") {
|
|
3326
|
+
return "complete";
|
|
3327
|
+
}
|
|
3328
|
+
if (event.type === "timeout") {
|
|
3329
|
+
return "timeout";
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
currentEvent = "";
|
|
3333
|
+
currentData = "";
|
|
3334
|
+
}
|
|
3335
|
+
return null;
|
|
3336
|
+
};
|
|
3337
|
+
try {
|
|
3338
|
+
while (true) {
|
|
3339
|
+
if (signal?.aborted) {
|
|
3340
|
+
throw new WatchAbortedError();
|
|
3341
|
+
}
|
|
3342
|
+
const { done, value } = await reader.read();
|
|
3343
|
+
if (done) {
|
|
3344
|
+
break;
|
|
3345
|
+
}
|
|
3346
|
+
buffer += decoder.decode(value, { stream: true });
|
|
3347
|
+
const lines = buffer.split("\n");
|
|
3348
|
+
buffer = lines.pop() || "";
|
|
3349
|
+
for (const line of lines) {
|
|
3350
|
+
const result = processLine(line.trim());
|
|
3351
|
+
if (result === "complete") {
|
|
3352
|
+
return finalState;
|
|
3353
|
+
}
|
|
3354
|
+
if (result === "timeout") {
|
|
3355
|
+
return null;
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
return finalState;
|
|
3360
|
+
} catch (error) {
|
|
3361
|
+
if (error instanceof WatchAbortedError) {
|
|
3362
|
+
throw error;
|
|
3363
|
+
}
|
|
3364
|
+
throw new Error(`SSE stream error: ${error instanceof Error ? error.message : String(error)}`);
|
|
3365
|
+
} finally {
|
|
3366
|
+
reader.releaseLock();
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
function sleep(ms, signal) {
|
|
3370
|
+
return new Promise((resolve, reject) => {
|
|
3371
|
+
if (signal?.aborted) {
|
|
3372
|
+
reject(new WatchAbortedError());
|
|
3373
|
+
return;
|
|
3374
|
+
}
|
|
3375
|
+
const timer = setTimeout(resolve, ms);
|
|
3376
|
+
if (signal) {
|
|
3377
|
+
signal.addEventListener("abort", () => {
|
|
3378
|
+
clearTimeout(timer);
|
|
3379
|
+
reject(new WatchAbortedError());
|
|
3380
|
+
});
|
|
3381
|
+
}
|
|
3382
|
+
});
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3090
3385
|
// src/parse_dotenv.ts
|
|
3091
3386
|
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
3092
3387
|
function parseEnv(input) {
|
|
@@ -3144,12 +3439,15 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3144
3439
|
CvmNetworkSchema,
|
|
3145
3440
|
CvmNetworkUrlsSchema,
|
|
3146
3441
|
CvmNodeSchema,
|
|
3442
|
+
CvmStateSchema,
|
|
3147
3443
|
CvmSystemInfoSchema,
|
|
3148
3444
|
DeleteCvmRequestSchema,
|
|
3149
3445
|
DeployAppAuthRequestSchema,
|
|
3150
3446
|
DeployAppAuthSchema,
|
|
3151
3447
|
GetAppEnvEncryptPubKeyRequestSchema,
|
|
3152
3448
|
GetAppEnvEncryptPubKeySchema,
|
|
3449
|
+
GetAvailableOSImagesRequestSchema,
|
|
3450
|
+
GetAvailableOSImagesResponseSchema,
|
|
3153
3451
|
GetCvmAttestationRequestSchema,
|
|
3154
3452
|
GetCvmComposeFileRequestSchema,
|
|
3155
3453
|
GetCvmContainersStatsRequestSchema,
|
|
@@ -3158,6 +3456,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3158
3456
|
GetCvmListRequestSchema,
|
|
3159
3457
|
GetCvmListSchema,
|
|
3160
3458
|
GetCvmNetworkRequestSchema,
|
|
3459
|
+
GetCvmStateRequestSchema,
|
|
3161
3460
|
GetCvmStatsRequestSchema,
|
|
3162
3461
|
GetKmsInfoRequestSchema,
|
|
3163
3462
|
GetKmsListRequestSchema,
|
|
@@ -3167,7 +3466,11 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3167
3466
|
ListInstanceTypesRequestSchema,
|
|
3168
3467
|
ListWorkspacesSchema,
|
|
3169
3468
|
ManagedUserSchema,
|
|
3469
|
+
MaxRetriesExceededError,
|
|
3170
3470
|
NetworkError,
|
|
3471
|
+
NextAppIdsRequestSchema,
|
|
3472
|
+
NextAppIdsSchema,
|
|
3473
|
+
OSImageVariantSchema,
|
|
3171
3474
|
PaginatedInstanceTypesSchema,
|
|
3172
3475
|
PaginationMetadataSchema,
|
|
3173
3476
|
PhalaCloudError,
|
|
@@ -3186,10 +3489,13 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3186
3489
|
UnknownError,
|
|
3187
3490
|
UpdateCvmResourcesRequestSchema,
|
|
3188
3491
|
UpdateCvmVisibilityRequestSchema,
|
|
3492
|
+
UpdateOsImageRequestSchema,
|
|
3189
3493
|
VMSchema,
|
|
3190
3494
|
ValidationError,
|
|
3191
3495
|
VmInfoSchema,
|
|
3192
3496
|
WalletError,
|
|
3497
|
+
WatchAbortedError,
|
|
3498
|
+
WatchCvmStateRequestSchema,
|
|
3193
3499
|
WorkspaceResponseSchema,
|
|
3194
3500
|
addComposeHash,
|
|
3195
3501
|
addNetwork,
|
|
@@ -3220,6 +3526,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3220
3526
|
formatValidationErrors,
|
|
3221
3527
|
getAppEnvEncryptPubKey,
|
|
3222
3528
|
getAvailableNodes,
|
|
3529
|
+
getAvailableOsImages,
|
|
3223
3530
|
getComposeHash,
|
|
3224
3531
|
getCurrentUser,
|
|
3225
3532
|
getCvmAttestation,
|
|
@@ -3229,6 +3536,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3229
3536
|
getCvmInfo,
|
|
3230
3537
|
getCvmList,
|
|
3231
3538
|
getCvmNetwork,
|
|
3539
|
+
getCvmState,
|
|
3232
3540
|
getCvmStats,
|
|
3233
3541
|
getErrorMessage,
|
|
3234
3542
|
getKmsInfo,
|
|
@@ -3237,6 +3545,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3237
3545
|
getWorkspace,
|
|
3238
3546
|
listInstanceTypes,
|
|
3239
3547
|
listWorkspaces,
|
|
3548
|
+
nextAppIds,
|
|
3240
3549
|
parseApiError,
|
|
3241
3550
|
parseEnv,
|
|
3242
3551
|
parseEnvVars,
|
|
@@ -3252,6 +3561,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3252
3561
|
safeDeployAppAuth,
|
|
3253
3562
|
safeGetAppEnvEncryptPubKey,
|
|
3254
3563
|
safeGetAvailableNodes,
|
|
3564
|
+
safeGetAvailableOsImages,
|
|
3255
3565
|
safeGetCurrentUser,
|
|
3256
3566
|
safeGetCvmAttestation,
|
|
3257
3567
|
safeGetCvmComposeFile,
|
|
@@ -3260,12 +3570,14 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3260
3570
|
safeGetCvmInfo,
|
|
3261
3571
|
safeGetCvmList,
|
|
3262
3572
|
safeGetCvmNetwork,
|
|
3573
|
+
safeGetCvmState,
|
|
3263
3574
|
safeGetCvmStats,
|
|
3264
3575
|
safeGetKmsInfo,
|
|
3265
3576
|
safeGetKmsList,
|
|
3266
3577
|
safeGetWorkspace,
|
|
3267
3578
|
safeListInstanceTypes,
|
|
3268
3579
|
safeListWorkspaces,
|
|
3580
|
+
safeNextAppIds,
|
|
3269
3581
|
safeProvisionCvm,
|
|
3270
3582
|
safeProvisionCvmComposeFileUpdate,
|
|
3271
3583
|
safeRestartCvm,
|
|
@@ -3274,6 +3586,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3274
3586
|
safeStopCvm,
|
|
3275
3587
|
safeUpdateCvmResources,
|
|
3276
3588
|
safeUpdateCvmVisibility,
|
|
3589
|
+
safeUpdateOsImage,
|
|
3277
3590
|
safeValidateActionParameters,
|
|
3278
3591
|
shutdownCvm,
|
|
3279
3592
|
sortObject,
|
|
@@ -3282,9 +3595,11 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
3282
3595
|
switchToNetwork,
|
|
3283
3596
|
updateCvmResources,
|
|
3284
3597
|
updateCvmVisibility,
|
|
3598
|
+
updateOsImage,
|
|
3285
3599
|
validateActionParameters,
|
|
3286
3600
|
validateNetworkPrerequisites,
|
|
3287
3601
|
verifyEnvEncryptPublicKey,
|
|
3288
3602
|
waitForTransactionReceipt,
|
|
3603
|
+
watchCvmState,
|
|
3289
3604
|
withComposeMethods
|
|
3290
3605
|
});
|