@phala/cloud 0.2.4 → 0.2.8
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/apps/check_app_cvms_is_allowed.d.ts +164 -0
- package/dist/actions/apps/check_app_is_allowed.d.ts +109 -0
- package/dist/actions/apps/get_app_attestation.d.ts +963 -0
- package/dist/actions/apps/get_app_device_allowlist.d.ts +108 -0
- package/dist/actions/blockchains/abi/dstack_app.d.ts +131 -0
- package/dist/actions/blockchains/add_device.d.ts +62 -0
- package/dist/actions/blockchains/check_compose_hash_allowed.d.ts +43 -0
- package/dist/actions/blockchains/check_device_allowed.d.ts +44 -0
- package/dist/actions/blockchains/check_on_chain_prerequisites.d.ts +59 -0
- package/dist/actions/blockchains/get_allowed_devices.d.ts +65 -0
- package/dist/actions/blockchains/remove_device.d.ts +62 -0
- package/dist/actions/blockchains/set_allow_any_device.d.ts +62 -0
- package/dist/actions/cvms/check_cvm_is_allowed.d.ts +145 -0
- package/dist/actions/cvms/commit_cvm_provision.d.ts +19 -0
- package/dist/actions/cvms/commit_cvm_update.d.ts +100 -0
- package/dist/actions/cvms/confirm_cvm_patch.d.ts +92 -0
- package/dist/actions/cvms/get_cvm_attestation.d.ts +220 -0
- package/dist/actions/cvms/get_cvm_compose_file.d.ts +16 -0
- package/dist/actions/cvms/patch_cvm.d.ts +447 -0
- package/dist/actions/cvms/provision_cvm.d.ts +26 -1
- package/dist/actions/cvms/provision_cvm_compose_file_update.d.ts +26 -0
- package/dist/actions/cvms/refresh_cvm_instance_id.d.ts +93 -0
- package/dist/actions/cvms/refresh_cvm_instance_ids.d.ts +194 -0
- package/dist/actions/cvms/replicate_cvm.d.ts +126 -0
- package/dist/actions/cvms/restart_cvm.d.ts +2 -2
- package/dist/actions/cvms/shutdown_cvm.d.ts +2 -2
- package/dist/actions/cvms/start_cvm.d.ts +2 -2
- package/dist/actions/cvms/stop_cvm.d.ts +2 -2
- package/dist/actions/index.d.ts +22 -1
- package/dist/actions/kms/get_kms_onchain_detail.d.ts +688 -0
- package/dist/actions/os_images/get_os_images.d.ts +217 -0
- package/dist/actions/workspaces/get_workspace.d.ts +2 -0
- package/dist/actions/workspaces/list_workspaces.d.ts +18 -0
- package/dist/client.d.ts +5 -0
- package/dist/create-client.d.ts +30 -0
- package/dist/index.js +1909 -365
- package/dist/index.mjs +1843 -363
- package/dist/types/app_compose.d.ts +5 -0
- package/dist/types/app_info_v20260121.d.ts +158 -6
- package/dist/types/cvm_info.d.ts +3 -3
- package/dist/types/cvm_info_v20260121.d.ts +82 -4
- package/dist/utils/error_codes.d.ts +48 -0
- package/dist/utils/errors.d.ts +9 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/verify-webhook.d.ts +35 -0
- package/dist/webhook.d.ts +11 -0
- package/dist/webhook.js +68 -0
- package/dist/webhook.mjs +40 -0
- package/package.json +7 -2
package/dist/index.js
CHANGED
|
@@ -31,8 +31,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
AddComposeHashSchema: () => AddComposeHashSchema,
|
|
34
|
+
AddDeviceSchema: () => AddDeviceSchema,
|
|
34
35
|
AllFamiliesResponseSchema: () => AllFamiliesResponseSchema,
|
|
35
36
|
ApiErrorSchema: () => ApiErrorSchema,
|
|
37
|
+
AppAttestationInstanceSchema: () => AppAttestationInstanceSchema,
|
|
38
|
+
AppAttestationResponseSchema: () => AppAttestationResponseSchema,
|
|
39
|
+
AppCvmsBatchIsAllowedResponseSchema: () => AppCvmsBatchIsAllowedResponseSchema,
|
|
36
40
|
AppFilterOptionsSchema: () => AppFilterOptionsSchema,
|
|
37
41
|
AppProfileSchema: () => AppProfileSchema,
|
|
38
42
|
AppRevisionDetailResponseSchema: () => AppRevisionDetailResponseSchema,
|
|
@@ -43,10 +47,18 @@ __export(index_exports, {
|
|
|
43
47
|
AvailableNodesSchema: () => AvailableNodesSchema,
|
|
44
48
|
BillingPeriodSchema: () => BillingPeriodSchema,
|
|
45
49
|
BusinessError: () => BusinessError,
|
|
50
|
+
CertificateIssuerSchema: () => CertificateIssuerSchema,
|
|
51
|
+
CertificateSchema: () => CertificateSchema,
|
|
52
|
+
CertificateSubjectSchema: () => CertificateSubjectSchema,
|
|
53
|
+
CheckAppCvmsIsAllowedRequestSchema: () => CheckAppCvmsIsAllowedRequestSchema,
|
|
54
|
+
CheckAppIsAllowedRequestSchema: () => CheckAppIsAllowedRequestSchema,
|
|
55
|
+
CheckCvmIsAllowedRequestSchema: () => CheckCvmIsAllowedRequestSchema,
|
|
46
56
|
CommitCvmComposeFileUpdateRequestSchema: () => CommitCvmComposeFileUpdateRequestSchema,
|
|
47
57
|
CommitCvmComposeFileUpdateSchema: () => CommitCvmComposeFileUpdateSchema,
|
|
48
58
|
CommitCvmProvisionRequestSchema: () => CommitCvmProvisionRequestSchema,
|
|
49
59
|
CommitCvmProvisionSchema: () => CommitCvmProvisionSchema,
|
|
60
|
+
CommitCvmUpdateRequestSchema: () => CommitCvmUpdateRequestSchema,
|
|
61
|
+
ConfirmCvmPatchRequestSchema: () => ConfirmCvmPatchRequestSchema,
|
|
50
62
|
CreateSshKeyRequestSchema: () => CreateSshKeyRequestSchema,
|
|
51
63
|
CreditsInfoSchema: () => CreditsInfoSchema,
|
|
52
64
|
CurrentUserSchema: () => CurrentUserV20251028Schema,
|
|
@@ -88,9 +100,14 @@ __export(index_exports, {
|
|
|
88
100
|
DstackAppMinimalResponseV20260121Schema: () => DstackAppMinimalResponseV20260121Schema,
|
|
89
101
|
DstackAppWithCvmResponseV20251028Schema: () => DstackAppWithCvmResponseV20251028Schema,
|
|
90
102
|
DstackAppWithCvmResponseV20260121Schema: () => DstackAppWithCvmResponseV20260121Schema,
|
|
103
|
+
ErrorCodes: () => ErrorCodes,
|
|
104
|
+
EventLogSchema: () => EventLogSchema,
|
|
91
105
|
FamilyGroupSchema: () => FamilyGroupSchema,
|
|
92
106
|
FamilyInstanceTypesResponseSchema: () => FamilyInstanceTypesResponseSchema,
|
|
107
|
+
GetAllowedDevicesSchema: () => GetAllowedDevicesSchema,
|
|
108
|
+
GetAppAttestationRequestSchema: () => GetAppAttestationRequestSchema,
|
|
93
109
|
GetAppCvmsRequestSchema: () => GetAppCvmsRequestSchema,
|
|
110
|
+
GetAppDeviceAllowlistRequestSchema: () => GetAppDeviceAllowlistRequestSchema,
|
|
94
111
|
GetAppEnvEncryptPubKeyRequestSchema: () => GetAppEnvEncryptPubKeyRequestSchema,
|
|
95
112
|
GetAppEnvEncryptPubKeySchema: () => GetAppEnvEncryptPubKeySchema,
|
|
96
113
|
GetAppInfoRequestSchema: () => GetAppInfoRequestSchema,
|
|
@@ -115,11 +132,17 @@ __export(index_exports, {
|
|
|
115
132
|
GetKmsInfoRequestSchema: () => GetKmsInfoRequestSchema,
|
|
116
133
|
GetKmsListRequestSchema: () => GetKmsListRequestSchema,
|
|
117
134
|
GetKmsListSchema: () => GetKmsListSchema,
|
|
135
|
+
GetKmsOnChainDetailRequestSchema: () => GetKmsOnChainDetailRequestSchema,
|
|
136
|
+
GetKmsOnChainDetailResponseSchema: () => GetKmsOnChainDetailResponseSchema,
|
|
137
|
+
GetOsImagesRequestSchema: () => GetOsImagesRequestSchema,
|
|
138
|
+
GetOsImagesResponseSchema: () => GetOsImagesResponseSchema,
|
|
118
139
|
GetWorkspaceNodesSchema: () => GetWorkspaceNodesSchema,
|
|
119
140
|
GetWorkspaceQuotasSchema: () => GetWorkspaceQuotasSchema,
|
|
120
141
|
ImportGithubProfileRequestSchema: () => ImportGithubProfileRequestSchema,
|
|
121
142
|
ImportGithubProfileResponseSchema: () => ImportGithubProfileResponseSchema,
|
|
143
|
+
InstanceIdRefreshResultSchema: () => InstanceIdRefreshResultSchema,
|
|
122
144
|
InstanceTypeSchema: () => InstanceTypeSchema,
|
|
145
|
+
IsAllowedResultSchema: () => IsAllowedResultSchema,
|
|
123
146
|
KmsInfoSchema: () => KmsInfoSchema,
|
|
124
147
|
KmsTypeSchema: () => KmsTypeSchema,
|
|
125
148
|
ListFamilyInstanceTypesRequestSchema: () => ListFamilyInstanceTypesRequestSchema,
|
|
@@ -135,27 +158,40 @@ __export(index_exports, {
|
|
|
135
158
|
NextAppIdsSchema: () => NextAppIdsSchema,
|
|
136
159
|
NodeInfoSchema: () => NodeInfoSchema,
|
|
137
160
|
NodeRefSchema: () => NodeRefSchema,
|
|
161
|
+
OSImagePublicSchema: () => OSImagePublicSchema,
|
|
138
162
|
OSImageVariantSchema: () => OSImageVariantSchema,
|
|
163
|
+
OnChainDeviceSchema: () => OnChainDeviceSchema,
|
|
164
|
+
OnChainKmsContractSchema: () => OnChainKmsContractSchema,
|
|
165
|
+
OnChainOsImageSchema: () => OnChainOsImageSchema,
|
|
139
166
|
PaginatedCvmInfosV20251028Schema: () => PaginatedCvmInfosV20251028Schema,
|
|
140
167
|
PaginatedCvmInfosV20260121Schema: () => PaginatedCvmInfosV20260121Schema,
|
|
141
168
|
PaginationMetadataSchema: () => PaginationMetadataSchema,
|
|
169
|
+
PatchCvmRequestSchema: () => PatchCvmRequestSchema,
|
|
170
|
+
PatchCvmResultSchema: () => PatchCvmResultSchema,
|
|
142
171
|
PhalaCloudError: () => PhalaCloudError,
|
|
143
172
|
ProvisionCvmComposeFileUpdateRequestSchema: () => ProvisionCvmComposeFileUpdateRequestSchema,
|
|
144
173
|
ProvisionCvmComposeFileUpdateResultSchema: () => ProvisionCvmComposeFileUpdateResultSchema,
|
|
145
174
|
ProvisionCvmRequestSchema: () => ProvisionCvmRequestSchema,
|
|
146
175
|
ProvisionCvmSchema: () => ProvisionCvmSchema,
|
|
147
176
|
QuotaMetricSchema: () => QuotaMetricSchema,
|
|
177
|
+
RefreshCvmInstanceIdRequestSchema: () => RefreshCvmInstanceIdRequestSchema,
|
|
178
|
+
RefreshCvmInstanceIdsRequestSchema: () => RefreshCvmInstanceIdsRequestSchema,
|
|
179
|
+
RefreshCvmInstanceIdsResponseSchema: () => RefreshCvmInstanceIdsResponseSchema,
|
|
180
|
+
RemoveDeviceSchema: () => RemoveDeviceSchema,
|
|
181
|
+
ReplicateCvmRequestSchema: () => ReplicateCvmRequestSchema,
|
|
148
182
|
RequestError: () => RequestError,
|
|
149
183
|
ResourceError: () => ResourceError,
|
|
150
184
|
RestartCvmRequestSchema: () => RestartCvmRequestSchema,
|
|
151
185
|
SUPPORTED_API_VERSIONS: () => SUPPORTED_API_VERSIONS,
|
|
152
186
|
SUPPORTED_CHAINS: () => SUPPORTED_CHAINS,
|
|
153
187
|
ServerError: () => ServerError,
|
|
188
|
+
SetAllowAnyDeviceSchema: () => SetAllowAnyDeviceSchema,
|
|
154
189
|
ShutdownCvmRequestSchema: () => ShutdownCvmRequestSchema,
|
|
155
190
|
SshKeySchema: () => SshKeySchema,
|
|
156
191
|
StartCvmRequestSchema: () => StartCvmRequestSchema,
|
|
157
192
|
StopCvmRequestSchema: () => StopCvmRequestSchema,
|
|
158
193
|
SyncGithubSshKeysResponseSchema: () => SyncGithubSshKeysResponseSchema,
|
|
194
|
+
TcbInfoSchema: () => TcbInfoSchema,
|
|
159
195
|
TransactionError: () => TransactionError,
|
|
160
196
|
UnknownError: () => UnknownError,
|
|
161
197
|
UpdateCvmEnvsRequestSchema: () => UpdateCvmEnvsRequestSchema,
|
|
@@ -181,13 +217,22 @@ __export(index_exports, {
|
|
|
181
217
|
WorkspaceReservedGpuQuotaSchema: () => WorkspaceReservedGpuQuotaSchema,
|
|
182
218
|
WorkspaceResponseSchema: () => WorkspaceResponseSchema,
|
|
183
219
|
addComposeHash: () => addComposeHash,
|
|
220
|
+
addDevice: () => addDevice,
|
|
184
221
|
addNetwork: () => addNetwork,
|
|
185
222
|
asHex: () => asHex,
|
|
186
223
|
autoCreateClients: () => autoCreateClients,
|
|
224
|
+
checkAppCvmsIsAllowed: () => checkAppCvmsIsAllowed,
|
|
225
|
+
checkAppIsAllowed: () => checkAppIsAllowed,
|
|
187
226
|
checkBalance: () => checkBalance,
|
|
227
|
+
checkComposeHashAllowed: () => checkComposeHashAllowed,
|
|
228
|
+
checkCvmIsAllowed: () => checkCvmIsAllowed,
|
|
229
|
+
checkDeviceAllowed: () => checkDeviceAllowed,
|
|
188
230
|
checkNetworkStatus: () => checkNetworkStatus,
|
|
231
|
+
checkOnChainPrerequisites: () => checkOnChainPrerequisites,
|
|
189
232
|
commitCvmComposeFileUpdate: () => commitCvmComposeFileUpdate,
|
|
190
233
|
commitCvmProvision: () => commitCvmProvision,
|
|
234
|
+
commitCvmUpdate: () => commitCvmUpdate,
|
|
235
|
+
confirmCvmPatch: () => confirmCvmPatch,
|
|
191
236
|
convertToHostname: () => convertToHostname,
|
|
192
237
|
createBaseClient: () => createClient,
|
|
193
238
|
createClient: () => createClient2,
|
|
@@ -201,6 +246,7 @@ __export(index_exports, {
|
|
|
201
246
|
deleteCvm: () => deleteCvm,
|
|
202
247
|
deleteSshKey: () => deleteSshKey,
|
|
203
248
|
deployAppAuth: () => deployAppAuth,
|
|
249
|
+
dstackAppAbi: () => dstackAppAbi,
|
|
204
250
|
dumpAppCompose: () => dumpAppCompose,
|
|
205
251
|
encryptEnvVars: () => import_encrypt_env_vars2.encryptEnvVars,
|
|
206
252
|
estimateTransactionGas: () => estimateTransactionGas,
|
|
@@ -213,7 +259,10 @@ __export(index_exports, {
|
|
|
213
259
|
formatValidationErrors: () => formatValidationErrors,
|
|
214
260
|
generateDefaultCvmName: () => generateDefaultCvmName,
|
|
215
261
|
generateFallbackHostname: () => generateFallbackHostname,
|
|
262
|
+
getAllowedDevices: () => getAllowedDevices,
|
|
263
|
+
getAppAttestation: () => getAppAttestation,
|
|
216
264
|
getAppCvms: () => getAppCvms,
|
|
265
|
+
getAppDeviceAllowlist: () => getAppDeviceAllowlist,
|
|
217
266
|
getAppEnvEncryptPubKey: () => getAppEnvEncryptPubKey,
|
|
218
267
|
getAppFilterOptions: () => getAppFilterOptions,
|
|
219
268
|
getAppInfo: () => getAppInfo,
|
|
@@ -239,11 +288,15 @@ __export(index_exports, {
|
|
|
239
288
|
getErrorMessage: () => getErrorMessage,
|
|
240
289
|
getKmsInfo: () => getKmsInfo,
|
|
241
290
|
getKmsList: () => getKmsList,
|
|
291
|
+
getKmsOnChainDetail: () => getKmsOnChainDetail,
|
|
292
|
+
getOsImages: () => getOsImages,
|
|
242
293
|
getValidationFields: () => getValidationFields,
|
|
243
294
|
getWorkspace: () => getWorkspace,
|
|
244
295
|
getWorkspaceNodes: () => getWorkspaceNodes,
|
|
245
296
|
getWorkspaceQuotas: () => getWorkspaceQuotas,
|
|
246
297
|
importGithubProfileSshKeys: () => importGithubProfileSshKeys,
|
|
298
|
+
isAppIdConflictError: () => isAppIdConflictError,
|
|
299
|
+
isConflictError: () => isConflictError,
|
|
247
300
|
isValidHostname: () => isValidHostname,
|
|
248
301
|
listAllInstanceTypeFamilies: () => listAllInstanceTypeFamilies,
|
|
249
302
|
listFamilyInstanceTypes: () => listFamilyInstanceTypes,
|
|
@@ -253,19 +306,36 @@ __export(index_exports, {
|
|
|
253
306
|
parseApiError: () => parseApiError,
|
|
254
307
|
parseEnv: () => parseEnv,
|
|
255
308
|
parseEnvVars: () => parseEnvVars,
|
|
309
|
+
patchCvm: () => patchCvm,
|
|
256
310
|
preprocessAppCompose: () => preprocessAppCompose,
|
|
257
311
|
provisionCvm: () => provisionCvm,
|
|
258
312
|
provisionCvmComposeFileUpdate: () => provisionCvmComposeFileUpdate,
|
|
259
313
|
refineCvmId: () => refineCvmId,
|
|
314
|
+
refreshCvmInstanceId: () => refreshCvmInstanceId,
|
|
315
|
+
refreshCvmInstanceIds: () => refreshCvmInstanceIds,
|
|
316
|
+
removeDevice: () => removeDevice,
|
|
317
|
+
replicateCvm: () => replicateCvm,
|
|
260
318
|
restartCvm: () => restartCvm,
|
|
261
319
|
safeAddComposeHash: () => safeAddComposeHash,
|
|
320
|
+
safeAddDevice: () => safeAddDevice,
|
|
321
|
+
safeCheckAppCvmsIsAllowed: () => safeCheckAppCvmsIsAllowed,
|
|
322
|
+
safeCheckAppIsAllowed: () => safeCheckAppIsAllowed,
|
|
323
|
+
safeCheckComposeHashAllowed: () => safeCheckComposeHashAllowed,
|
|
324
|
+
safeCheckCvmIsAllowed: () => safeCheckCvmIsAllowed,
|
|
325
|
+
safeCheckDeviceAllowed: () => safeCheckDeviceAllowed,
|
|
326
|
+
safeCheckOnChainPrerequisites: () => safeCheckOnChainPrerequisites,
|
|
262
327
|
safeCommitCvmComposeFileUpdate: () => safeCommitCvmComposeFileUpdate,
|
|
263
328
|
safeCommitCvmProvision: () => safeCommitCvmProvision,
|
|
329
|
+
safeCommitCvmUpdate: () => safeCommitCvmUpdate,
|
|
330
|
+
safeConfirmCvmPatch: () => safeConfirmCvmPatch,
|
|
264
331
|
safeCreateSshKey: () => safeCreateSshKey,
|
|
265
332
|
safeDeleteCvm: () => safeDeleteCvm,
|
|
266
333
|
safeDeleteSshKey: () => safeDeleteSshKey,
|
|
267
334
|
safeDeployAppAuth: () => safeDeployAppAuth,
|
|
335
|
+
safeGetAllowedDevices: () => safeGetAllowedDevices,
|
|
336
|
+
safeGetAppAttestation: () => safeGetAppAttestation,
|
|
268
337
|
safeGetAppCvms: () => safeGetAppCvms,
|
|
338
|
+
safeGetAppDeviceAllowlist: () => safeGetAppDeviceAllowlist,
|
|
269
339
|
safeGetAppEnvEncryptPubKey: () => safeGetAppEnvEncryptPubKey,
|
|
270
340
|
safeGetAppFilterOptions: () => safeGetAppFilterOptions,
|
|
271
341
|
safeGetAppInfo: () => safeGetAppInfo,
|
|
@@ -289,6 +359,8 @@ __export(index_exports, {
|
|
|
289
359
|
safeGetCvmUserConfig: () => safeGetCvmUserConfig,
|
|
290
360
|
safeGetKmsInfo: () => safeGetKmsInfo,
|
|
291
361
|
safeGetKmsList: () => safeGetKmsList,
|
|
362
|
+
safeGetKmsOnChainDetail: () => safeGetKmsOnChainDetail,
|
|
363
|
+
safeGetOsImages: () => safeGetOsImages,
|
|
292
364
|
safeGetWorkspace: () => safeGetWorkspace,
|
|
293
365
|
safeGetWorkspaceNodes: () => safeGetWorkspaceNodes,
|
|
294
366
|
safeGetWorkspaceQuotas: () => safeGetWorkspaceQuotas,
|
|
@@ -298,9 +370,15 @@ __export(index_exports, {
|
|
|
298
370
|
safeListSshKeys: () => safeListSshKeys,
|
|
299
371
|
safeListWorkspaces: () => safeListWorkspaces,
|
|
300
372
|
safeNextAppIds: () => safeNextAppIds,
|
|
373
|
+
safePatchCvm: () => safePatchCvm,
|
|
301
374
|
safeProvisionCvm: () => safeProvisionCvm,
|
|
302
375
|
safeProvisionCvmComposeFileUpdate: () => safeProvisionCvmComposeFileUpdate,
|
|
376
|
+
safeRefreshCvmInstanceId: () => safeRefreshCvmInstanceId,
|
|
377
|
+
safeRefreshCvmInstanceIds: () => safeRefreshCvmInstanceIds,
|
|
378
|
+
safeRemoveDevice: () => safeRemoveDevice,
|
|
379
|
+
safeReplicateCvm: () => safeReplicateCvm,
|
|
303
380
|
safeRestartCvm: () => safeRestartCvm,
|
|
381
|
+
safeSetAllowAnyDevice: () => safeSetAllowAnyDevice,
|
|
304
382
|
safeShutdownCvm: () => safeShutdownCvm,
|
|
305
383
|
safeStartCvm: () => safeStartCvm,
|
|
306
384
|
safeStopCvm: () => safeStopCvm,
|
|
@@ -312,6 +390,7 @@ __export(index_exports, {
|
|
|
312
390
|
safeUpdateOsImage: () => safeUpdateOsImage,
|
|
313
391
|
safeUpdatePreLaunchScript: () => safeUpdatePreLaunchScript,
|
|
314
392
|
safeValidateActionParameters: () => safeValidateActionParameters,
|
|
393
|
+
setAllowAnyDevice: () => setAllowAnyDevice,
|
|
315
394
|
shutdownCvm: () => shutdownCvm,
|
|
316
395
|
sortObject: () => sortObject,
|
|
317
396
|
startCvm: () => startCvm,
|
|
@@ -392,13 +471,14 @@ var RequestError = class _RequestError extends PhalaCloudError {
|
|
|
392
471
|
static fromFetchError(error) {
|
|
393
472
|
const parseResult = ApiErrorSchema.safeParse(error.data);
|
|
394
473
|
if (parseResult.success) {
|
|
474
|
+
const detail = parseResult.data.detail ?? (error.data && typeof error.data === "object" && "error_code" in error.data ? error.data : void 0);
|
|
395
475
|
return new _RequestError(error.message, {
|
|
396
476
|
status: error.status ?? void 0,
|
|
397
477
|
statusText: error.statusText ?? void 0,
|
|
398
478
|
data: error.data,
|
|
399
479
|
request: error.request ?? void 0,
|
|
400
480
|
response: error.response ?? void 0,
|
|
401
|
-
detail
|
|
481
|
+
detail,
|
|
402
482
|
code: parseResult.data.code ?? void 0,
|
|
403
483
|
type: parseResult.data.type ?? void 0
|
|
404
484
|
});
|
|
@@ -667,6 +747,12 @@ function formatStructuredError(error, options) {
|
|
|
667
747
|
}
|
|
668
748
|
return parts.join("\n");
|
|
669
749
|
}
|
|
750
|
+
function isConflictError(error) {
|
|
751
|
+
return error.status === 409;
|
|
752
|
+
}
|
|
753
|
+
function isAppIdConflictError(error) {
|
|
754
|
+
return error instanceof ResourceError && error.errorCode === "ERR-03-007";
|
|
755
|
+
}
|
|
670
756
|
|
|
671
757
|
// src/client.ts
|
|
672
758
|
var SUPPORTED_API_VERSIONS = [
|
|
@@ -730,8 +816,20 @@ var Client = class _Client {
|
|
|
730
816
|
headers: requestHeaders,
|
|
731
817
|
...useCookieAuth ? { credentials: "include" } : {},
|
|
732
818
|
...fetchOptions,
|
|
733
|
-
//
|
|
819
|
+
// Strip Content-Type for FormData so the browser/runtime sets
|
|
820
|
+
// the correct multipart/form-data boundary automatically.
|
|
821
|
+
// This runs after ofetch merges instance and per-request headers,
|
|
822
|
+
// so deleting here is final.
|
|
734
823
|
onRequest({ request, options }) {
|
|
824
|
+
if (options.body instanceof FormData) {
|
|
825
|
+
const h = options.headers;
|
|
826
|
+
if (h instanceof Headers) {
|
|
827
|
+
h.delete("content-type");
|
|
828
|
+
} else if (h && typeof h === "object" && !Array.isArray(h)) {
|
|
829
|
+
delete h["Content-Type"];
|
|
830
|
+
delete h["content-type"];
|
|
831
|
+
}
|
|
832
|
+
}
|
|
735
833
|
if (logger.enabled) {
|
|
736
834
|
const method = options.method || "GET";
|
|
737
835
|
const url = typeof request === "string" ? request : request.url;
|
|
@@ -863,16 +961,28 @@ var Client = class _Client {
|
|
|
863
961
|
throw phalaCloudError;
|
|
864
962
|
}
|
|
865
963
|
}
|
|
964
|
+
/**
|
|
965
|
+
* Build request options, stripping Content-Type when body is FormData
|
|
966
|
+
* so the browser/runtime sets the correct multipart boundary automatically.
|
|
967
|
+
*/
|
|
968
|
+
// biome-ignore lint/suspicious/noExplicitAny: ofetch generic variance
|
|
969
|
+
buildRequestOptions(method, body, options) {
|
|
970
|
+
const opts = { ...options, method, body };
|
|
971
|
+
if (body instanceof FormData) {
|
|
972
|
+
const existing = opts.headers;
|
|
973
|
+
opts.headers = {
|
|
974
|
+
...existing,
|
|
975
|
+
"Content-Type": ""
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
return opts;
|
|
979
|
+
}
|
|
866
980
|
/**
|
|
867
981
|
* Perform POST request (throws PhalaCloudError on error)
|
|
868
982
|
*/
|
|
869
983
|
async post(request, body, options) {
|
|
870
984
|
try {
|
|
871
|
-
return await this.fetchInstance(request,
|
|
872
|
-
...options,
|
|
873
|
-
method: "POST",
|
|
874
|
-
body
|
|
875
|
-
});
|
|
985
|
+
return await this.fetchInstance(request, this.buildRequestOptions("POST", body, options));
|
|
876
986
|
} catch (error) {
|
|
877
987
|
const requestError = this.convertToRequestError(error);
|
|
878
988
|
const phalaCloudError = this.emitError(requestError);
|
|
@@ -884,11 +994,7 @@ var Client = class _Client {
|
|
|
884
994
|
*/
|
|
885
995
|
async put(request, body, options) {
|
|
886
996
|
try {
|
|
887
|
-
return await this.fetchInstance(request,
|
|
888
|
-
...options,
|
|
889
|
-
method: "PUT",
|
|
890
|
-
body
|
|
891
|
-
});
|
|
997
|
+
return await this.fetchInstance(request, this.buildRequestOptions("PUT", body, options));
|
|
892
998
|
} catch (error) {
|
|
893
999
|
const requestError = this.convertToRequestError(error);
|
|
894
1000
|
const phalaCloudError = this.emitError(requestError);
|
|
@@ -900,11 +1006,7 @@ var Client = class _Client {
|
|
|
900
1006
|
*/
|
|
901
1007
|
async patch(request, body, options) {
|
|
902
1008
|
try {
|
|
903
|
-
return await this.fetchInstance(request,
|
|
904
|
-
...options,
|
|
905
|
-
method: "PATCH",
|
|
906
|
-
body
|
|
907
|
-
});
|
|
1009
|
+
return await this.fetchInstance(request, this.buildRequestOptions("PATCH", body, options));
|
|
908
1010
|
} catch (error) {
|
|
909
1011
|
const requestError = this.convertToRequestError(error);
|
|
910
1012
|
const phalaCloudError = this.emitError(requestError);
|
|
@@ -1402,7 +1504,8 @@ var WorkspaceResponseSchema = import_zod7.z.object({
|
|
|
1402
1504
|
tier: import_zod7.z.string(),
|
|
1403
1505
|
role: import_zod7.z.string(),
|
|
1404
1506
|
is_default: import_zod7.z.boolean(),
|
|
1405
|
-
created_at: import_zod7.z.string()
|
|
1507
|
+
created_at: import_zod7.z.string(),
|
|
1508
|
+
confidential_models_enabled: import_zod7.z.boolean().optional()
|
|
1406
1509
|
}).passthrough();
|
|
1407
1510
|
var PaginationMetadataSchema = import_zod7.z.object({
|
|
1408
1511
|
has_more: import_zod7.z.boolean(),
|
|
@@ -1557,7 +1660,7 @@ var CvmOsInfoV20260121Schema = import_zod9.z.object({
|
|
|
1557
1660
|
is_dev: import_zod9.z.boolean().nullable().optional(),
|
|
1558
1661
|
os_image_hash: import_zod9.z.string().nullable().optional()
|
|
1559
1662
|
});
|
|
1560
|
-
var
|
|
1663
|
+
var CvmKmsInfoV20260121BaseSchema = import_zod9.z.object({
|
|
1561
1664
|
chain_id: import_zod9.z.number().int().nullable().optional(),
|
|
1562
1665
|
dstack_kms_address: import_zod9.z.string().nullable().optional(),
|
|
1563
1666
|
dstack_app_address: import_zod9.z.string().nullable().optional(),
|
|
@@ -1565,6 +1668,15 @@ var CvmKmsInfoV20260121Schema = import_zod9.z.object({
|
|
|
1565
1668
|
rpc_endpoint: import_zod9.z.string().nullable().optional(),
|
|
1566
1669
|
encrypted_env_pubkey: import_zod9.z.string().nullable().optional()
|
|
1567
1670
|
});
|
|
1671
|
+
var CvmKmsInfoV20260121Schema = CvmKmsInfoV20260121BaseSchema.transform((data) => {
|
|
1672
|
+
if (data.chain_id != null) {
|
|
1673
|
+
const chain = SUPPORTED_CHAINS[data.chain_id];
|
|
1674
|
+
if (chain) {
|
|
1675
|
+
return { ...data, chain };
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
return data;
|
|
1679
|
+
});
|
|
1568
1680
|
var CvmProgressInfoV20260121Schema = import_zod9.z.object({
|
|
1569
1681
|
target: import_zod9.z.string().nullable().optional(),
|
|
1570
1682
|
started_at: import_zod9.z.string().nullable().optional(),
|
|
@@ -1591,6 +1703,7 @@ var CvmInfoV20260121Schema = import_zod9.z.object({
|
|
|
1591
1703
|
name: import_zod9.z.string(),
|
|
1592
1704
|
app_id: import_zod9.z.string().nullable().optional(),
|
|
1593
1705
|
vm_uuid: import_zod9.z.string().nullable().optional(),
|
|
1706
|
+
instance_id: import_zod9.z.string().nullable().optional(),
|
|
1594
1707
|
resource: CvmResourceInfoV20260121Schema,
|
|
1595
1708
|
node_info: NodeRefSchema.nullable().optional(),
|
|
1596
1709
|
os: CvmOsInfoV20260121Schema.nullable().optional(),
|
|
@@ -1607,6 +1720,7 @@ var CvmInfoV20260121Schema = import_zod9.z.object({
|
|
|
1607
1720
|
public_tcbinfo: import_zod9.z.boolean().optional(),
|
|
1608
1721
|
gateway_enabled: import_zod9.z.boolean().optional(),
|
|
1609
1722
|
secure_time: import_zod9.z.boolean().optional(),
|
|
1723
|
+
listed: import_zod9.z.boolean().optional().default(false),
|
|
1610
1724
|
storage_fs: import_zod9.z.string().optional(),
|
|
1611
1725
|
workspace: WorkspaceRefSchema.nullable().optional(),
|
|
1612
1726
|
creator: UserRefSchema.nullable().optional()
|
|
@@ -1831,6 +1945,7 @@ var LooseAppComposeSchema = import_zod12.z.object({
|
|
|
1831
1945
|
public_logs: import_zod12.z.boolean().optional(),
|
|
1832
1946
|
public_sysinfo: import_zod12.z.boolean().optional(),
|
|
1833
1947
|
tproxy_enabled: import_zod12.z.boolean().optional(),
|
|
1948
|
+
storage_fs: import_zod12.z.enum(["ext4", "zfs"]).optional(),
|
|
1834
1949
|
pre_launch_script: import_zod12.z.string().optional(),
|
|
1835
1950
|
env_pubkey: import_zod12.z.string().optional(),
|
|
1836
1951
|
salt: import_zod12.z.string().optional().nullable()
|
|
@@ -1887,8 +2002,9 @@ var ProvisionCvmRequestSchema = import_zod13.z.object({
|
|
|
1887
2002
|
public_sysinfo: import_zod13.z.boolean().optional(),
|
|
1888
2003
|
gateway_enabled: import_zod13.z.boolean().optional(),
|
|
1889
2004
|
// recommended
|
|
1890
|
-
tproxy_enabled: import_zod13.z.boolean().optional()
|
|
2005
|
+
tproxy_enabled: import_zod13.z.boolean().optional(),
|
|
1891
2006
|
// deprecated, for compatibility
|
|
2007
|
+
storage_fs: import_zod13.z.enum(["ext4", "zfs"]).optional()
|
|
1892
2008
|
}).superRefine((data, ctx) => {
|
|
1893
2009
|
validateComposePayloadSize(data.docker_compose_file, data.pre_launch_script, ctx);
|
|
1894
2010
|
}),
|
|
@@ -2076,7 +2192,8 @@ var ProvisionCvmComposeFileUpdateResultSchema = import_zod15.z.object({
|
|
|
2076
2192
|
app_id: import_zod15.z.string().nullable(),
|
|
2077
2193
|
device_id: import_zod15.z.string().nullable(),
|
|
2078
2194
|
compose_hash: import_zod15.z.string(),
|
|
2079
|
-
kms_info: KmsInfoSchema.nullable().optional()
|
|
2195
|
+
kms_info: KmsInfoSchema.nullable().optional(),
|
|
2196
|
+
compose_hash_registered: import_zod15.z.boolean().optional().default(false)
|
|
2080
2197
|
}).passthrough();
|
|
2081
2198
|
var { action: provisionCvmComposeFileUpdate, safeAction: safeProvisionCvmComposeFileUpdate } = defineAction(ProvisionCvmComposeFileUpdateResultSchema, async (client, request) => {
|
|
2082
2199
|
const validatedRequest = ProvisionCvmComposeFileUpdateRequestSchema.parse(request);
|
|
@@ -2183,14 +2300,24 @@ var { action: updateCvmEnvs, safeAction: safeUpdateCvmEnvs } = defineAction(Upda
|
|
|
2183
2300
|
const detail = error.detail;
|
|
2184
2301
|
if (detail && typeof detail === "object") {
|
|
2185
2302
|
const detailObj = detail;
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2303
|
+
const detailsArray = detailObj.details;
|
|
2304
|
+
if (detailsArray && Array.isArray(detailsArray)) {
|
|
2305
|
+
const fieldMap = new Map(detailsArray.map((d) => [d.field, d.value]));
|
|
2306
|
+
const composeHash = fieldMap.get("compose_hash");
|
|
2307
|
+
const appId = fieldMap.get("app_id");
|
|
2308
|
+
const deviceId = fieldMap.get("device_id");
|
|
2309
|
+
const kmsInfo = fieldMap.get("kms_info");
|
|
2310
|
+
if (composeHash && appId) {
|
|
2311
|
+
return {
|
|
2312
|
+
status: "precondition_required",
|
|
2313
|
+
message: detailObj.message || "Compose hash verification required",
|
|
2314
|
+
compose_hash: composeHash,
|
|
2315
|
+
app_id: appId,
|
|
2316
|
+
device_id: deviceId || "",
|
|
2317
|
+
kms_info: kmsInfo
|
|
2318
|
+
};
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2194
2321
|
}
|
|
2195
2322
|
}
|
|
2196
2323
|
throw error;
|
|
@@ -2257,14 +2384,24 @@ var { action: updateDockerCompose, safeAction: safeUpdateDockerCompose } = defin
|
|
|
2257
2384
|
const detail = error.detail;
|
|
2258
2385
|
if (detail && typeof detail === "object") {
|
|
2259
2386
|
const detailObj = detail;
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2387
|
+
const detailsArray = detailObj.details;
|
|
2388
|
+
if (detailsArray && Array.isArray(detailsArray)) {
|
|
2389
|
+
const fieldMap = new Map(detailsArray.map((d) => [d.field, d.value]));
|
|
2390
|
+
const composeHash = fieldMap.get("compose_hash");
|
|
2391
|
+
const appId = fieldMap.get("app_id");
|
|
2392
|
+
const deviceId = fieldMap.get("device_id");
|
|
2393
|
+
const kmsInfo = fieldMap.get("kms_info");
|
|
2394
|
+
if (composeHash && appId) {
|
|
2395
|
+
return {
|
|
2396
|
+
status: "precondition_required",
|
|
2397
|
+
message: detailObj.message || "Compose hash verification required",
|
|
2398
|
+
compose_hash: composeHash,
|
|
2399
|
+
app_id: appId,
|
|
2400
|
+
device_id: deviceId || "",
|
|
2401
|
+
kms_info: kmsInfo
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2268
2405
|
}
|
|
2269
2406
|
}
|
|
2270
2407
|
throw error;
|
|
@@ -2331,14 +2468,24 @@ var { action: updatePreLaunchScript, safeAction: safeUpdatePreLaunchScript } = d
|
|
|
2331
2468
|
const detail = error.detail;
|
|
2332
2469
|
if (detail && typeof detail === "object") {
|
|
2333
2470
|
const detailObj = detail;
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2471
|
+
const detailsArray = detailObj.details;
|
|
2472
|
+
if (detailsArray && Array.isArray(detailsArray)) {
|
|
2473
|
+
const fieldMap = new Map(detailsArray.map((d) => [d.field, d.value]));
|
|
2474
|
+
const composeHash = fieldMap.get("compose_hash");
|
|
2475
|
+
const appId = fieldMap.get("app_id");
|
|
2476
|
+
const deviceId = fieldMap.get("device_id");
|
|
2477
|
+
const kmsInfo = fieldMap.get("kms_info");
|
|
2478
|
+
if (composeHash && appId) {
|
|
2479
|
+
return {
|
|
2480
|
+
status: "precondition_required",
|
|
2481
|
+
message: detailObj.message || "Compose hash verification required",
|
|
2482
|
+
compose_hash: composeHash,
|
|
2483
|
+
app_id: appId,
|
|
2484
|
+
device_id: deviceId || "",
|
|
2485
|
+
kms_info: kmsInfo
|
|
2486
|
+
};
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2342
2489
|
}
|
|
2343
2490
|
}
|
|
2344
2491
|
throw error;
|
|
@@ -2437,7 +2584,7 @@ var VMSchema = import_zod25.z.object({
|
|
|
2437
2584
|
vm_uuid: import_zod25.z.string().nullable(),
|
|
2438
2585
|
instance_id: import_zod25.z.string().nullable(),
|
|
2439
2586
|
app_url: import_zod25.z.string().optional().nullable(),
|
|
2440
|
-
base_image: import_zod25.z.string().nullable(),
|
|
2587
|
+
base_image: import_zod25.z.string().optional().nullable(),
|
|
2441
2588
|
vcpu: import_zod25.z.number(),
|
|
2442
2589
|
memory: import_zod25.z.number(),
|
|
2443
2590
|
disk_size: import_zod25.z.number(),
|
|
@@ -2855,6 +3002,66 @@ var { action: syncGithubSshKeys, safeAction: safeSyncGithubSshKeys } = defineSim
|
|
|
2855
3002
|
}
|
|
2856
3003
|
);
|
|
2857
3004
|
|
|
3005
|
+
// src/actions/os_images/get_os_images.ts
|
|
3006
|
+
var import_zod43 = require("zod");
|
|
3007
|
+
var OSImagePublicSchema = import_zod43.z.object({
|
|
3008
|
+
name: import_zod43.z.string(),
|
|
3009
|
+
slug: import_zod43.z.string(),
|
|
3010
|
+
version: import_zod43.z.string(),
|
|
3011
|
+
os_image_hash: import_zod43.z.string().nullable(),
|
|
3012
|
+
is_dev: import_zod43.z.boolean(),
|
|
3013
|
+
requires_gpu: import_zod43.z.boolean()
|
|
3014
|
+
}).passthrough();
|
|
3015
|
+
var GetOsImagesRequestSchema = import_zod43.z.object({
|
|
3016
|
+
page: import_zod43.z.number().int().min(1).optional(),
|
|
3017
|
+
page_size: import_zod43.z.number().int().min(1).optional(),
|
|
3018
|
+
is_dev: import_zod43.z.boolean().optional()
|
|
3019
|
+
}).strict();
|
|
3020
|
+
var GetOsImagesResponseSchema = import_zod43.z.object({
|
|
3021
|
+
items: import_zod43.z.array(OSImagePublicSchema),
|
|
3022
|
+
total: import_zod43.z.number(),
|
|
3023
|
+
page: import_zod43.z.number(),
|
|
3024
|
+
page_size: import_zod43.z.number(),
|
|
3025
|
+
pages: import_zod43.z.number()
|
|
3026
|
+
}).passthrough();
|
|
3027
|
+
var { action: getOsImages, safeAction: safeGetOsImages } = defineAction(GetOsImagesResponseSchema, async (client, request) => {
|
|
3028
|
+
const validatedRequest = GetOsImagesRequestSchema.parse(request ?? {});
|
|
3029
|
+
return await client.get("/os-images", { params: validatedRequest });
|
|
3030
|
+
});
|
|
3031
|
+
|
|
3032
|
+
// src/actions/kms/get_kms_onchain_detail.ts
|
|
3033
|
+
var import_zod44 = require("zod");
|
|
3034
|
+
var OnChainDeviceSchema = import_zod44.z.object({
|
|
3035
|
+
device_id: import_zod44.z.string(),
|
|
3036
|
+
node_name: import_zod44.z.string().nullable().optional(),
|
|
3037
|
+
on_chain_allowed: import_zod44.z.boolean().nullable()
|
|
3038
|
+
}).passthrough();
|
|
3039
|
+
var OnChainOsImageSchema = import_zod44.z.object({
|
|
3040
|
+
name: import_zod44.z.string(),
|
|
3041
|
+
version: import_zod44.z.string(),
|
|
3042
|
+
os_image_hash: import_zod44.z.string().nullable(),
|
|
3043
|
+
on_chain_allowed: import_zod44.z.boolean().nullable()
|
|
3044
|
+
}).passthrough();
|
|
3045
|
+
var OnChainKmsContractSchema = import_zod44.z.object({
|
|
3046
|
+
contract_address: import_zod44.z.string(),
|
|
3047
|
+
chain_id: import_zod44.z.number(),
|
|
3048
|
+
chain_name: import_zod44.z.string(),
|
|
3049
|
+
devices: import_zod44.z.array(OnChainDeviceSchema),
|
|
3050
|
+
os_images: import_zod44.z.array(OnChainOsImageSchema)
|
|
3051
|
+
}).passthrough();
|
|
3052
|
+
var GetKmsOnChainDetailResponseSchema = import_zod44.z.object({
|
|
3053
|
+
chain_name: import_zod44.z.string(),
|
|
3054
|
+
chain_id: import_zod44.z.number(),
|
|
3055
|
+
contracts: import_zod44.z.array(OnChainKmsContractSchema)
|
|
3056
|
+
}).passthrough();
|
|
3057
|
+
var GetKmsOnChainDetailRequestSchema = import_zod44.z.object({
|
|
3058
|
+
chain: import_zod44.z.string()
|
|
3059
|
+
}).strict();
|
|
3060
|
+
var { action: getKmsOnChainDetail, safeAction: safeGetKmsOnChainDetail } = defineAction(GetKmsOnChainDetailResponseSchema, async (client, request) => {
|
|
3061
|
+
const { chain } = GetKmsOnChainDetailRequestSchema.parse(request);
|
|
3062
|
+
return await client.get(`/kms/on-chain/${chain}`);
|
|
3063
|
+
});
|
|
3064
|
+
|
|
2858
3065
|
// src/create-client.ts
|
|
2859
3066
|
function createClient2(config = {}) {
|
|
2860
3067
|
const client = createClient(config);
|
|
@@ -2940,167 +3147,171 @@ function createClient2(config = {}) {
|
|
|
2940
3147
|
deleteSshKey,
|
|
2941
3148
|
safeDeleteSshKey,
|
|
2942
3149
|
syncGithubSshKeys,
|
|
2943
|
-
safeSyncGithubSshKeys
|
|
3150
|
+
safeSyncGithubSshKeys,
|
|
3151
|
+
getOsImages,
|
|
3152
|
+
safeGetOsImages,
|
|
3153
|
+
getKmsOnChainDetail,
|
|
3154
|
+
safeGetKmsOnChainDetail
|
|
2944
3155
|
};
|
|
2945
3156
|
return client.extend(allActions);
|
|
2946
3157
|
}
|
|
2947
3158
|
|
|
2948
3159
|
// src/types/app_info_v20251028.ts
|
|
2949
|
-
var
|
|
2950
|
-
var CvmBasicInfoV20251028Schema =
|
|
2951
|
-
vm_uuid:
|
|
2952
|
-
app_id:
|
|
2953
|
-
name:
|
|
2954
|
-
status:
|
|
2955
|
-
vcpu:
|
|
2956
|
-
memory:
|
|
2957
|
-
disk_size:
|
|
2958
|
-
teepod_id:
|
|
2959
|
-
teepod_name:
|
|
2960
|
-
region_identifier:
|
|
2961
|
-
kms_type:
|
|
2962
|
-
instance_type:
|
|
2963
|
-
listed:
|
|
2964
|
-
base_image:
|
|
2965
|
-
kms_slug:
|
|
2966
|
-
kms_id:
|
|
2967
|
-
instance_id:
|
|
3160
|
+
var import_zod45 = require("zod");
|
|
3161
|
+
var CvmBasicInfoV20251028Schema = import_zod45.z.object({
|
|
3162
|
+
vm_uuid: import_zod45.z.string().nullable(),
|
|
3163
|
+
app_id: import_zod45.z.string(),
|
|
3164
|
+
name: import_zod45.z.string().default(""),
|
|
3165
|
+
status: import_zod45.z.string(),
|
|
3166
|
+
vcpu: import_zod45.z.number().int(),
|
|
3167
|
+
memory: import_zod45.z.number().int(),
|
|
3168
|
+
disk_size: import_zod45.z.number().int(),
|
|
3169
|
+
teepod_id: import_zod45.z.number().int(),
|
|
3170
|
+
teepod_name: import_zod45.z.string(),
|
|
3171
|
+
region_identifier: import_zod45.z.string().nullable().optional(),
|
|
3172
|
+
kms_type: import_zod45.z.string().nullable().optional(),
|
|
3173
|
+
instance_type: import_zod45.z.string().nullable().optional(),
|
|
3174
|
+
listed: import_zod45.z.boolean().nullable().optional(),
|
|
3175
|
+
base_image: import_zod45.z.string().nullable().optional(),
|
|
3176
|
+
kms_slug: import_zod45.z.string().nullable().optional(),
|
|
3177
|
+
kms_id: import_zod45.z.string().nullable().optional(),
|
|
3178
|
+
instance_id: import_zod45.z.string().nullable().optional(),
|
|
2968
3179
|
machine_info: MachineInfoV20251028Schema.nullable().optional(),
|
|
2969
|
-
updated_at:
|
|
3180
|
+
updated_at: import_zod45.z.string().nullable().optional()
|
|
2970
3181
|
});
|
|
2971
|
-
var AppProfileSchema =
|
|
2972
|
-
display_name:
|
|
2973
|
-
avatar_url:
|
|
2974
|
-
description:
|
|
2975
|
-
custom_domain:
|
|
3182
|
+
var AppProfileSchema = import_zod45.z.object({
|
|
3183
|
+
display_name: import_zod45.z.string().nullable().optional(),
|
|
3184
|
+
avatar_url: import_zod45.z.string().nullable().optional(),
|
|
3185
|
+
description: import_zod45.z.string().nullable().optional(),
|
|
3186
|
+
custom_domain: import_zod45.z.string().nullable().optional()
|
|
2976
3187
|
});
|
|
2977
|
-
var DstackAppFullResponseV20251028Schema =
|
|
2978
|
-
id:
|
|
2979
|
-
name:
|
|
2980
|
-
app_id:
|
|
2981
|
-
app_provision_type:
|
|
2982
|
-
app_icon_url:
|
|
2983
|
-
created_at:
|
|
2984
|
-
kms_type:
|
|
3188
|
+
var DstackAppFullResponseV20251028Schema = import_zod45.z.object({
|
|
3189
|
+
id: import_zod45.z.string(),
|
|
3190
|
+
name: import_zod45.z.string(),
|
|
3191
|
+
app_id: import_zod45.z.string(),
|
|
3192
|
+
app_provision_type: import_zod45.z.string().nullable().optional(),
|
|
3193
|
+
app_icon_url: import_zod45.z.string().nullable().optional(),
|
|
3194
|
+
created_at: import_zod45.z.string(),
|
|
3195
|
+
kms_type: import_zod45.z.string(),
|
|
2985
3196
|
profile: AppProfileSchema.nullable().optional(),
|
|
2986
3197
|
current_cvm: CvmBasicInfoV20251028Schema.nullable().optional(),
|
|
2987
|
-
cvms:
|
|
2988
|
-
cvm_count:
|
|
2989
|
-
});
|
|
2990
|
-
var DstackAppMinimalResponseV20251028Schema =
|
|
2991
|
-
id:
|
|
2992
|
-
app_id:
|
|
2993
|
-
name:
|
|
2994
|
-
app_provision_type:
|
|
2995
|
-
app_icon_url:
|
|
2996
|
-
created_at:
|
|
2997
|
-
kms_type:
|
|
2998
|
-
current_cvm:
|
|
2999
|
-
cvms:
|
|
3000
|
-
cvm_count:
|
|
3001
|
-
});
|
|
3002
|
-
var DstackAppWithCvmResponseV20251028Schema =
|
|
3198
|
+
cvms: import_zod45.z.array(CvmBasicInfoV20251028Schema).default([]),
|
|
3199
|
+
cvm_count: import_zod45.z.number().int().default(0)
|
|
3200
|
+
});
|
|
3201
|
+
var DstackAppMinimalResponseV20251028Schema = import_zod45.z.object({
|
|
3202
|
+
id: import_zod45.z.null().optional(),
|
|
3203
|
+
app_id: import_zod45.z.string(),
|
|
3204
|
+
name: import_zod45.z.null().optional(),
|
|
3205
|
+
app_provision_type: import_zod45.z.null().optional(),
|
|
3206
|
+
app_icon_url: import_zod45.z.null().optional(),
|
|
3207
|
+
created_at: import_zod45.z.null().optional(),
|
|
3208
|
+
kms_type: import_zod45.z.null().optional(),
|
|
3209
|
+
current_cvm: import_zod45.z.null().optional(),
|
|
3210
|
+
cvms: import_zod45.z.null().optional(),
|
|
3211
|
+
cvm_count: import_zod45.z.null().optional()
|
|
3212
|
+
});
|
|
3213
|
+
var DstackAppWithCvmResponseV20251028Schema = import_zod45.z.union([
|
|
3003
3214
|
DstackAppFullResponseV20251028Schema,
|
|
3004
3215
|
DstackAppMinimalResponseV20251028Schema
|
|
3005
3216
|
]);
|
|
3006
|
-
var DstackAppListResponseV20251028Schema =
|
|
3007
|
-
dstack_apps:
|
|
3008
|
-
page:
|
|
3009
|
-
page_size:
|
|
3010
|
-
total:
|
|
3011
|
-
total_pages:
|
|
3217
|
+
var DstackAppListResponseV20251028Schema = import_zod45.z.object({
|
|
3218
|
+
dstack_apps: import_zod45.z.array(DstackAppWithCvmResponseV20251028Schema),
|
|
3219
|
+
page: import_zod45.z.number().int(),
|
|
3220
|
+
page_size: import_zod45.z.number().int(),
|
|
3221
|
+
total: import_zod45.z.number().int(),
|
|
3222
|
+
total_pages: import_zod45.z.number().int()
|
|
3012
3223
|
});
|
|
3013
3224
|
|
|
3014
3225
|
// src/types/app_info_v20260121.ts
|
|
3015
|
-
var
|
|
3016
|
-
var DstackAppFullResponseV20260121Schema =
|
|
3017
|
-
id:
|
|
3018
|
-
name:
|
|
3019
|
-
app_id:
|
|
3020
|
-
app_provision_type:
|
|
3021
|
-
app_icon_url:
|
|
3022
|
-
created_at:
|
|
3023
|
-
kms_type:
|
|
3024
|
-
profile:
|
|
3025
|
-
display_name:
|
|
3026
|
-
avatar_url:
|
|
3027
|
-
description:
|
|
3028
|
-
custom_domain:
|
|
3226
|
+
var import_zod46 = require("zod");
|
|
3227
|
+
var DstackAppFullResponseV20260121Schema = import_zod46.z.object({
|
|
3228
|
+
id: import_zod46.z.string(),
|
|
3229
|
+
name: import_zod46.z.string(),
|
|
3230
|
+
app_id: import_zod46.z.string(),
|
|
3231
|
+
app_provision_type: import_zod46.z.string().nullable().optional(),
|
|
3232
|
+
app_icon_url: import_zod46.z.string().nullable().optional(),
|
|
3233
|
+
created_at: import_zod46.z.string(),
|
|
3234
|
+
kms_type: import_zod46.z.string(),
|
|
3235
|
+
profile: import_zod46.z.object({
|
|
3236
|
+
display_name: import_zod46.z.string().nullable().optional(),
|
|
3237
|
+
avatar_url: import_zod46.z.string().nullable().optional(),
|
|
3238
|
+
description: import_zod46.z.string().nullable().optional(),
|
|
3239
|
+
custom_domain: import_zod46.z.string().nullable().optional()
|
|
3029
3240
|
}).nullable().optional(),
|
|
3030
3241
|
current_cvm: CvmInfoV20260121Schema.nullable().optional(),
|
|
3031
|
-
cvms:
|
|
3032
|
-
cvm_count:
|
|
3033
|
-
});
|
|
3034
|
-
var DstackAppMinimalResponseV20260121Schema =
|
|
3035
|
-
id:
|
|
3036
|
-
app_id:
|
|
3037
|
-
name:
|
|
3038
|
-
app_provision_type:
|
|
3039
|
-
app_icon_url:
|
|
3040
|
-
created_at:
|
|
3041
|
-
kms_type:
|
|
3042
|
-
current_cvm:
|
|
3043
|
-
cvms:
|
|
3044
|
-
cvm_count:
|
|
3045
|
-
});
|
|
3046
|
-
var DstackAppWithCvmResponseV20260121Schema =
|
|
3242
|
+
cvms: import_zod46.z.array(CvmInfoV20260121Schema).default([]),
|
|
3243
|
+
cvm_count: import_zod46.z.number().int().default(0)
|
|
3244
|
+
});
|
|
3245
|
+
var DstackAppMinimalResponseV20260121Schema = import_zod46.z.object({
|
|
3246
|
+
id: import_zod46.z.null().optional(),
|
|
3247
|
+
app_id: import_zod46.z.string(),
|
|
3248
|
+
name: import_zod46.z.null().optional(),
|
|
3249
|
+
app_provision_type: import_zod46.z.null().optional(),
|
|
3250
|
+
app_icon_url: import_zod46.z.null().optional(),
|
|
3251
|
+
created_at: import_zod46.z.null().optional(),
|
|
3252
|
+
kms_type: import_zod46.z.null().optional(),
|
|
3253
|
+
current_cvm: import_zod46.z.null().optional(),
|
|
3254
|
+
cvms: import_zod46.z.null().optional(),
|
|
3255
|
+
cvm_count: import_zod46.z.null().optional()
|
|
3256
|
+
});
|
|
3257
|
+
var DstackAppWithCvmResponseV20260121Schema = import_zod46.z.union([
|
|
3047
3258
|
DstackAppFullResponseV20260121Schema,
|
|
3048
3259
|
DstackAppMinimalResponseV20260121Schema
|
|
3049
3260
|
]);
|
|
3050
|
-
var DstackAppListResponseV20260121Schema =
|
|
3051
|
-
dstack_apps:
|
|
3052
|
-
page:
|
|
3053
|
-
page_size:
|
|
3054
|
-
total:
|
|
3055
|
-
total_pages:
|
|
3261
|
+
var DstackAppListResponseV20260121Schema = import_zod46.z.object({
|
|
3262
|
+
dstack_apps: import_zod46.z.array(DstackAppWithCvmResponseV20260121Schema),
|
|
3263
|
+
page: import_zod46.z.number().int(),
|
|
3264
|
+
page_size: import_zod46.z.number().int(),
|
|
3265
|
+
total: import_zod46.z.number().int(),
|
|
3266
|
+
total_pages: import_zod46.z.number().int()
|
|
3056
3267
|
});
|
|
3057
3268
|
|
|
3058
3269
|
// src/types/app_revision.ts
|
|
3059
|
-
var
|
|
3060
|
-
var CvmRefSchema =
|
|
3061
|
-
object_type:
|
|
3062
|
-
id:
|
|
3063
|
-
name:
|
|
3064
|
-
app_id:
|
|
3065
|
-
vm_uuid:
|
|
3066
|
-
});
|
|
3067
|
-
var AppRevisionResponseSchema =
|
|
3068
|
-
revision_id:
|
|
3069
|
-
app_id:
|
|
3070
|
-
vm_uuid:
|
|
3071
|
-
compose_hash:
|
|
3072
|
-
created_at:
|
|
3073
|
-
trace_id:
|
|
3074
|
-
operation_type:
|
|
3270
|
+
var import_zod47 = require("zod");
|
|
3271
|
+
var CvmRefSchema = import_zod47.z.object({
|
|
3272
|
+
object_type: import_zod47.z.literal("cvm"),
|
|
3273
|
+
id: import_zod47.z.string().nullable().optional(),
|
|
3274
|
+
name: import_zod47.z.string().nullable().optional(),
|
|
3275
|
+
app_id: import_zod47.z.string().nullable().optional(),
|
|
3276
|
+
vm_uuid: import_zod47.z.string().nullable().optional()
|
|
3277
|
+
});
|
|
3278
|
+
var AppRevisionResponseSchema = import_zod47.z.object({
|
|
3279
|
+
revision_id: import_zod47.z.string(),
|
|
3280
|
+
app_id: import_zod47.z.string(),
|
|
3281
|
+
vm_uuid: import_zod47.z.string(),
|
|
3282
|
+
compose_hash: import_zod47.z.string(),
|
|
3283
|
+
created_at: import_zod47.z.string(),
|
|
3284
|
+
trace_id: import_zod47.z.string().nullable().optional(),
|
|
3285
|
+
operation_type: import_zod47.z.string(),
|
|
3075
3286
|
triggered_by: UserRefSchema.nullable().optional(),
|
|
3076
3287
|
cvm: CvmRefSchema.nullable().optional(),
|
|
3077
3288
|
workspace: WorkspaceRefSchema.nullable().optional()
|
|
3078
3289
|
});
|
|
3079
|
-
var AppRevisionDetailResponseSchema =
|
|
3080
|
-
revision_id:
|
|
3081
|
-
app_id:
|
|
3082
|
-
vm_uuid:
|
|
3083
|
-
compose_hash:
|
|
3084
|
-
compose_file:
|
|
3085
|
-
encrypted_env:
|
|
3086
|
-
user_config:
|
|
3087
|
-
created_at:
|
|
3088
|
-
trace_id:
|
|
3089
|
-
operation_type:
|
|
3290
|
+
var AppRevisionDetailResponseSchema = import_zod47.z.object({
|
|
3291
|
+
revision_id: import_zod47.z.string(),
|
|
3292
|
+
app_id: import_zod47.z.string(),
|
|
3293
|
+
vm_uuid: import_zod47.z.string(),
|
|
3294
|
+
compose_hash: import_zod47.z.string(),
|
|
3295
|
+
compose_file: import_zod47.z.union([import_zod47.z.record(import_zod47.z.any()), import_zod47.z.string()]).nullable().optional(),
|
|
3296
|
+
encrypted_env: import_zod47.z.string(),
|
|
3297
|
+
user_config: import_zod47.z.string(),
|
|
3298
|
+
created_at: import_zod47.z.string(),
|
|
3299
|
+
trace_id: import_zod47.z.string().nullable().optional(),
|
|
3300
|
+
operation_type: import_zod47.z.string(),
|
|
3090
3301
|
triggered_by: UserRefSchema.nullable().optional(),
|
|
3091
3302
|
cvm: CvmRefSchema.nullable().optional(),
|
|
3092
3303
|
workspace: WorkspaceRefSchema.nullable().optional()
|
|
3093
3304
|
});
|
|
3094
|
-
var AppRevisionsResponseSchema =
|
|
3095
|
-
revisions:
|
|
3096
|
-
total:
|
|
3097
|
-
page:
|
|
3098
|
-
page_size:
|
|
3099
|
-
total_pages:
|
|
3305
|
+
var AppRevisionsResponseSchema = import_zod47.z.object({
|
|
3306
|
+
revisions: import_zod47.z.array(AppRevisionResponseSchema),
|
|
3307
|
+
total: import_zod47.z.number().int(),
|
|
3308
|
+
page: import_zod47.z.number().int(),
|
|
3309
|
+
page_size: import_zod47.z.number().int(),
|
|
3310
|
+
total_pages: import_zod47.z.number().int()
|
|
3100
3311
|
});
|
|
3101
3312
|
|
|
3102
3313
|
// src/actions/blockchains/deploy_app_auth.ts
|
|
3103
|
-
var
|
|
3314
|
+
var import_zod48 = require("zod");
|
|
3104
3315
|
var import_viem3 = require("viem");
|
|
3105
3316
|
var import_accounts2 = require("viem/accounts");
|
|
3106
3317
|
|
|
@@ -3120,6 +3331,51 @@ function asHex(value) {
|
|
|
3120
3331
|
throw new Error(`Invalid hex value: ${value}`);
|
|
3121
3332
|
}
|
|
3122
3333
|
|
|
3334
|
+
// src/utils/error_codes.ts
|
|
3335
|
+
var ErrorCodes = {
|
|
3336
|
+
// Module 01: CVM Preflight & Compose Hash
|
|
3337
|
+
NODE_NOT_FOUND: "ERR-01-001",
|
|
3338
|
+
COMPOSE_FILE_REQUIRED: "ERR-01-002",
|
|
3339
|
+
INVALID_COMPOSE_FILE: "ERR-01-003",
|
|
3340
|
+
DUPLICATE_CVM_NAME: "ERR-01-004",
|
|
3341
|
+
HASH_REGISTRATION_REQUIRED: "ERR-01-005",
|
|
3342
|
+
HASH_INVALID_OR_EXPIRED: "ERR-01-006",
|
|
3343
|
+
TX_VERIFICATION_FAILED: "ERR-01-007",
|
|
3344
|
+
HASH_NOT_ALLOWED: "ERR-01-008",
|
|
3345
|
+
// Module 02: Inventory
|
|
3346
|
+
INSTANCE_TYPE_NOT_FOUND: "ERR-02-001",
|
|
3347
|
+
RESOURCE_NOT_AVAILABLE: "ERR-02-002",
|
|
3348
|
+
INSUFFICIENT_VCPU: "ERR-02-003",
|
|
3349
|
+
INSUFFICIENT_MEMORY: "ERR-02-004",
|
|
3350
|
+
INSUFFICIENT_SLOTS: "ERR-02-005",
|
|
3351
|
+
GPU_ALLOCATION_ERROR: "ERR-02-006",
|
|
3352
|
+
INSUFFICIENT_GPU: "ERR-02-007",
|
|
3353
|
+
INVALID_REQUEST: "ERR-02-008",
|
|
3354
|
+
INCOMPATIBLE_CONFIG: "ERR-02-009",
|
|
3355
|
+
IMAGE_NOT_FOUND: "ERR-02-010",
|
|
3356
|
+
KMS_NOT_FOUND: "ERR-02-011",
|
|
3357
|
+
TEEPOD_NOT_ACCESSIBLE: "ERR-02-012",
|
|
3358
|
+
OS_IMAGE_NOT_COMPATIBLE: "ERR-02-013",
|
|
3359
|
+
NODE_CAPACITY_NOT_CONFIGURED: "ERR-02-014",
|
|
3360
|
+
QUOTA_EXCEEDED: "ERR-02-015",
|
|
3361
|
+
// Module 03: CVM Operations
|
|
3362
|
+
CVM_NOT_FOUND: "ERR-03-001",
|
|
3363
|
+
MULTIPLE_CVMS_SAME_NAME: "ERR-03-002",
|
|
3364
|
+
CVM_NOT_IN_WORKSPACE: "ERR-03-003",
|
|
3365
|
+
CVM_ACCESS_DENIED: "ERR-03-005",
|
|
3366
|
+
REPLICA_IMAGE_NOT_AVAILABLE: "ERR-03-006",
|
|
3367
|
+
CVM_APP_ID_CONFLICT: "ERR-03-007",
|
|
3368
|
+
// Module 04: Workspace
|
|
3369
|
+
INSUFFICIENT_BALANCE: "ERR-04-001",
|
|
3370
|
+
MAX_CVM_LIMIT: "ERR-04-002",
|
|
3371
|
+
RESOURCE_LIMIT_EXCEEDED: "ERR-04-003",
|
|
3372
|
+
// Module 05: Credentials
|
|
3373
|
+
TOKEN_LIMIT_EXCEEDED: "ERR-05-001",
|
|
3374
|
+
TOKEN_RATE_LIMIT: "ERR-05-002",
|
|
3375
|
+
// Module 06: Auth
|
|
3376
|
+
OAUTH_EMAIL_INVALID: "ERR-06-001"
|
|
3377
|
+
};
|
|
3378
|
+
|
|
3123
3379
|
// src/utils/network.ts
|
|
3124
3380
|
var NetworkError = class extends Error {
|
|
3125
3381
|
constructor(message, code, details) {
|
|
@@ -3750,25 +4006,25 @@ var kmsAuthAbi = [
|
|
|
3750
4006
|
anonymous: false
|
|
3751
4007
|
}
|
|
3752
4008
|
];
|
|
3753
|
-
var DeployAppAuthRequestBaseSchema =
|
|
4009
|
+
var DeployAppAuthRequestBaseSchema = import_zod48.z.object({
|
|
3754
4010
|
// Chain configuration (conditionally required)
|
|
3755
|
-
chain:
|
|
3756
|
-
rpcUrl:
|
|
4011
|
+
chain: import_zod48.z.unknown().optional(),
|
|
4012
|
+
rpcUrl: import_zod48.z.string().optional(),
|
|
3757
4013
|
// Contract configuration (required)
|
|
3758
|
-
kmsContractAddress:
|
|
4014
|
+
kmsContractAddress: import_zod48.z.string(),
|
|
3759
4015
|
// Authentication mode: either privateKey OR walletClient (required, mutually exclusive)
|
|
3760
|
-
privateKey:
|
|
3761
|
-
walletClient:
|
|
4016
|
+
privateKey: import_zod48.z.string().optional(),
|
|
4017
|
+
walletClient: import_zod48.z.unknown().optional(),
|
|
3762
4018
|
// Public client (optional, will create default if not provided)
|
|
3763
|
-
publicClient:
|
|
4019
|
+
publicClient: import_zod48.z.unknown().optional(),
|
|
3764
4020
|
// App configuration (optional)
|
|
3765
|
-
allowAnyDevice:
|
|
3766
|
-
deviceId:
|
|
3767
|
-
composeHash:
|
|
3768
|
-
disableUpgrades:
|
|
4021
|
+
allowAnyDevice: import_zod48.z.boolean().optional().default(false),
|
|
4022
|
+
deviceId: import_zod48.z.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
|
|
4023
|
+
composeHash: import_zod48.z.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
|
|
4024
|
+
disableUpgrades: import_zod48.z.boolean().optional().default(false),
|
|
3769
4025
|
// Validation configuration (optional)
|
|
3770
|
-
skipPrerequisiteChecks:
|
|
3771
|
-
minBalance:
|
|
4026
|
+
skipPrerequisiteChecks: import_zod48.z.boolean().optional().default(false),
|
|
4027
|
+
minBalance: import_zod48.z.string().optional()
|
|
3772
4028
|
// ETH amount as string, e.g., "0.01"
|
|
3773
4029
|
}).passthrough();
|
|
3774
4030
|
var DeployAppAuthRequestSchema = DeployAppAuthRequestBaseSchema.refine(
|
|
@@ -3796,13 +4052,13 @@ var DeployAppAuthRequestSchema = DeployAppAuthRequestBaseSchema.refine(
|
|
|
3796
4052
|
path: ["chain"]
|
|
3797
4053
|
}
|
|
3798
4054
|
);
|
|
3799
|
-
var DeployAppAuthSchema =
|
|
3800
|
-
appId:
|
|
3801
|
-
appAuthAddress:
|
|
3802
|
-
deployer:
|
|
3803
|
-
transactionHash:
|
|
3804
|
-
blockNumber:
|
|
3805
|
-
gasUsed:
|
|
4055
|
+
var DeployAppAuthSchema = import_zod48.z.object({
|
|
4056
|
+
appId: import_zod48.z.string(),
|
|
4057
|
+
appAuthAddress: import_zod48.z.string(),
|
|
4058
|
+
deployer: import_zod48.z.string(),
|
|
4059
|
+
transactionHash: import_zod48.z.string(),
|
|
4060
|
+
blockNumber: import_zod48.z.bigint().optional(),
|
|
4061
|
+
gasUsed: import_zod48.z.bigint().optional()
|
|
3806
4062
|
}).passthrough();
|
|
3807
4063
|
function parseDeploymentResult(receipt, deployer, kmsContractAddress) {
|
|
3808
4064
|
try {
|
|
@@ -4048,7 +4304,7 @@ async function safeDeployAppAuth(request, parameters) {
|
|
|
4048
4304
|
}
|
|
4049
4305
|
|
|
4050
4306
|
// src/actions/blockchains/add_compose_hash.ts
|
|
4051
|
-
var
|
|
4307
|
+
var import_zod49 = require("zod");
|
|
4052
4308
|
var import_viem4 = require("viem");
|
|
4053
4309
|
var import_accounts3 = require("viem/accounts");
|
|
4054
4310
|
var appAuthAbi = [
|
|
@@ -4066,29 +4322,29 @@ var appAuthAbi = [
|
|
|
4066
4322
|
anonymous: false
|
|
4067
4323
|
}
|
|
4068
4324
|
];
|
|
4069
|
-
var AddComposeHashRequestSchema =
|
|
4325
|
+
var AddComposeHashRequestSchema = import_zod49.z.object({
|
|
4070
4326
|
// Chain configuration (conditionally required)
|
|
4071
|
-
chain:
|
|
4072
|
-
rpcUrl:
|
|
4073
|
-
appId:
|
|
4074
|
-
composeHash:
|
|
4327
|
+
chain: import_zod49.z.unknown().optional(),
|
|
4328
|
+
rpcUrl: import_zod49.z.string().optional(),
|
|
4329
|
+
appId: import_zod49.z.string(),
|
|
4330
|
+
composeHash: import_zod49.z.string(),
|
|
4075
4331
|
// Authentication mode: either privateKey OR walletClient (required, mutually exclusive)
|
|
4076
|
-
privateKey:
|
|
4077
|
-
walletClient:
|
|
4332
|
+
privateKey: import_zod49.z.string().optional(),
|
|
4333
|
+
walletClient: import_zod49.z.unknown().optional(),
|
|
4078
4334
|
// Public client (optional, will create default if not provided)
|
|
4079
|
-
publicClient:
|
|
4335
|
+
publicClient: import_zod49.z.unknown().optional(),
|
|
4080
4336
|
// Validation configuration (optional)
|
|
4081
|
-
skipPrerequisiteChecks:
|
|
4082
|
-
minBalance:
|
|
4337
|
+
skipPrerequisiteChecks: import_zod49.z.boolean().optional().default(false),
|
|
4338
|
+
minBalance: import_zod49.z.string().optional(),
|
|
4083
4339
|
// ETH amount as string, e.g., "0.01"
|
|
4084
4340
|
// Transaction control options
|
|
4085
|
-
timeout:
|
|
4086
|
-
retryOptions:
|
|
4087
|
-
signal:
|
|
4341
|
+
timeout: import_zod49.z.number().optional().default(12e4),
|
|
4342
|
+
retryOptions: import_zod49.z.unknown().optional(),
|
|
4343
|
+
signal: import_zod49.z.unknown().optional(),
|
|
4088
4344
|
// Progress callbacks
|
|
4089
|
-
onTransactionStateChange:
|
|
4090
|
-
onTransactionSubmitted:
|
|
4091
|
-
onTransactionConfirmed:
|
|
4345
|
+
onTransactionStateChange: import_zod49.z.function().optional(),
|
|
4346
|
+
onTransactionSubmitted: import_zod49.z.function().optional(),
|
|
4347
|
+
onTransactionConfirmed: import_zod49.z.function().optional()
|
|
4092
4348
|
}).passthrough().refine(
|
|
4093
4349
|
(data) => {
|
|
4094
4350
|
const hasPrivateKey = !!data.privateKey;
|
|
@@ -4112,12 +4368,12 @@ var AddComposeHashRequestSchema = import_zod47.z.object({
|
|
|
4112
4368
|
path: ["chain"]
|
|
4113
4369
|
}
|
|
4114
4370
|
);
|
|
4115
|
-
var AddComposeHashSchema =
|
|
4116
|
-
composeHash:
|
|
4117
|
-
appId:
|
|
4118
|
-
transactionHash:
|
|
4119
|
-
blockNumber:
|
|
4120
|
-
gasUsed:
|
|
4371
|
+
var AddComposeHashSchema = import_zod49.z.object({
|
|
4372
|
+
composeHash: import_zod49.z.string(),
|
|
4373
|
+
appId: import_zod49.z.string(),
|
|
4374
|
+
transactionHash: import_zod49.z.string(),
|
|
4375
|
+
blockNumber: import_zod49.z.bigint().optional(),
|
|
4376
|
+
gasUsed: import_zod49.z.bigint().optional()
|
|
4121
4377
|
}).passthrough();
|
|
4122
4378
|
function parseComposeHashResult(receipt, composeHash, appAuthAddress, appId) {
|
|
4123
4379
|
console.log(receipt.logs);
|
|
@@ -4247,6 +4503,24 @@ async function addComposeHash(request, parameters) {
|
|
|
4247
4503
|
);
|
|
4248
4504
|
}
|
|
4249
4505
|
}
|
|
4506
|
+
const contractOwner = await publicClient.readContract({
|
|
4507
|
+
address: appAuthAddress,
|
|
4508
|
+
abi: [
|
|
4509
|
+
{
|
|
4510
|
+
inputs: [],
|
|
4511
|
+
name: "owner",
|
|
4512
|
+
outputs: [{ type: "address" }],
|
|
4513
|
+
stateMutability: "view",
|
|
4514
|
+
type: "function"
|
|
4515
|
+
}
|
|
4516
|
+
],
|
|
4517
|
+
functionName: "owner"
|
|
4518
|
+
});
|
|
4519
|
+
if (contractOwner.toLowerCase() !== address.toLowerCase()) {
|
|
4520
|
+
throw new Error(
|
|
4521
|
+
`Sender ${address} is not the owner of contract ${appAuthAddress}. Contract owner is ${contractOwner}.`
|
|
4522
|
+
);
|
|
4523
|
+
}
|
|
4250
4524
|
const addComposeHashOperation = async (clients) => {
|
|
4251
4525
|
const hash = await clients.walletClient.writeContract({
|
|
4252
4526
|
address: appAuthAddress,
|
|
@@ -4308,102 +4582,937 @@ async function safeAddComposeHash(request, parameters) {
|
|
|
4308
4582
|
}
|
|
4309
4583
|
}
|
|
4310
4584
|
|
|
4311
|
-
// src/actions/
|
|
4312
|
-
var
|
|
4313
|
-
var
|
|
4314
|
-
var
|
|
4315
|
-
var GetWorkspaceNodesSchema = import_zod48.z.object({
|
|
4316
|
-
items: import_zod48.z.array(NodeRefSchema2),
|
|
4317
|
-
total: import_zod48.z.number(),
|
|
4318
|
-
page: import_zod48.z.number(),
|
|
4319
|
-
page_size: import_zod48.z.number(),
|
|
4320
|
-
pages: import_zod48.z.number()
|
|
4321
|
-
}).passthrough();
|
|
4322
|
-
var { action: getWorkspaceNodes, safeAction: safeGetWorkspaceNodes } = defineAction(GetWorkspaceNodesSchema, async (client, request) => {
|
|
4323
|
-
const { teamSlug, page, pageSize } = request;
|
|
4324
|
-
const queryParams = new URLSearchParams();
|
|
4325
|
-
if (page !== void 0) queryParams.append("page", page.toString());
|
|
4326
|
-
if (pageSize !== void 0) queryParams.append("page_size", pageSize.toString());
|
|
4327
|
-
const url = queryParams.toString() ? `/workspaces/${teamSlug}/nodes?${queryParams.toString()}` : `/workspaces/${teamSlug}/nodes`;
|
|
4328
|
-
return await client.get(url);
|
|
4329
|
-
});
|
|
4585
|
+
// src/actions/blockchains/add_device.ts
|
|
4586
|
+
var import_zod50 = require("zod");
|
|
4587
|
+
var import_viem5 = require("viem");
|
|
4588
|
+
var import_accounts4 = require("viem/accounts");
|
|
4330
4589
|
|
|
4331
|
-
// src/actions/
|
|
4332
|
-
var
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
}
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
}
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4590
|
+
// src/actions/blockchains/abi/dstack_app.ts
|
|
4591
|
+
var dstackAppAbi = [
|
|
4592
|
+
// ── Write functions ──────────────────────────────────────────────
|
|
4593
|
+
{
|
|
4594
|
+
inputs: [{ internalType: "bytes32", name: "deviceId", type: "bytes32" }],
|
|
4595
|
+
name: "addDevice",
|
|
4596
|
+
outputs: [],
|
|
4597
|
+
stateMutability: "nonpayable",
|
|
4598
|
+
type: "function"
|
|
4599
|
+
},
|
|
4600
|
+
{
|
|
4601
|
+
inputs: [{ internalType: "bytes32", name: "deviceId", type: "bytes32" }],
|
|
4602
|
+
name: "removeDevice",
|
|
4603
|
+
outputs: [],
|
|
4604
|
+
stateMutability: "nonpayable",
|
|
4605
|
+
type: "function"
|
|
4606
|
+
},
|
|
4607
|
+
{
|
|
4608
|
+
inputs: [{ internalType: "bool", name: "_allowAnyDevice", type: "bool" }],
|
|
4609
|
+
name: "setAllowAnyDevice",
|
|
4610
|
+
outputs: [],
|
|
4611
|
+
stateMutability: "nonpayable",
|
|
4612
|
+
type: "function"
|
|
4613
|
+
},
|
|
4614
|
+
// ── Read functions ───────────────────────────────────────────────
|
|
4615
|
+
{
|
|
4616
|
+
inputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
4617
|
+
name: "allowedDeviceIds",
|
|
4618
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
4619
|
+
stateMutability: "view",
|
|
4620
|
+
type: "function"
|
|
4621
|
+
},
|
|
4622
|
+
{
|
|
4623
|
+
inputs: [],
|
|
4624
|
+
name: "allowAnyDevice",
|
|
4625
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
4626
|
+
stateMutability: "view",
|
|
4627
|
+
type: "function"
|
|
4628
|
+
},
|
|
4629
|
+
{
|
|
4630
|
+
inputs: [],
|
|
4631
|
+
name: "owner",
|
|
4632
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
4633
|
+
stateMutability: "view",
|
|
4634
|
+
type: "function"
|
|
4635
|
+
},
|
|
4636
|
+
{
|
|
4637
|
+
inputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
4638
|
+
name: "allowedComposeHashes",
|
|
4639
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
4640
|
+
stateMutability: "view",
|
|
4641
|
+
type: "function"
|
|
4642
|
+
},
|
|
4643
|
+
// ── Errors ───────────────────────────────────────────────────────
|
|
4644
|
+
{
|
|
4645
|
+
inputs: [{ internalType: "address", name: "owner", type: "address" }],
|
|
4646
|
+
name: "OwnableInvalidOwner",
|
|
4647
|
+
type: "error"
|
|
4648
|
+
},
|
|
4649
|
+
{
|
|
4650
|
+
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
4651
|
+
name: "OwnableUnauthorizedAccount",
|
|
4652
|
+
type: "error"
|
|
4653
|
+
},
|
|
4654
|
+
// ── Events ───────────────────────────────────────────────────────
|
|
4655
|
+
{
|
|
4656
|
+
anonymous: false,
|
|
4657
|
+
inputs: [{ indexed: false, internalType: "bytes32", name: "deviceId", type: "bytes32" }],
|
|
4658
|
+
name: "DeviceAdded",
|
|
4659
|
+
type: "event"
|
|
4660
|
+
},
|
|
4661
|
+
{
|
|
4662
|
+
anonymous: false,
|
|
4663
|
+
inputs: [{ indexed: false, internalType: "bytes32", name: "deviceId", type: "bytes32" }],
|
|
4664
|
+
name: "DeviceRemoved",
|
|
4665
|
+
type: "event"
|
|
4666
|
+
},
|
|
4667
|
+
{
|
|
4668
|
+
anonymous: false,
|
|
4669
|
+
inputs: [{ indexed: false, internalType: "bool", name: "allowAny", type: "bool" }],
|
|
4670
|
+
name: "AllowAnyDeviceSet",
|
|
4671
|
+
type: "event"
|
|
4672
|
+
}
|
|
4673
|
+
];
|
|
4359
4674
|
|
|
4360
|
-
// src/actions/
|
|
4361
|
-
var
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4675
|
+
// src/actions/blockchains/add_device.ts
|
|
4676
|
+
var AddDeviceRequestSchema = import_zod50.z.object({
|
|
4677
|
+
chain: import_zod50.z.unknown().optional(),
|
|
4678
|
+
rpcUrl: import_zod50.z.string().optional(),
|
|
4679
|
+
appAddress: import_zod50.z.string(),
|
|
4680
|
+
deviceId: import_zod50.z.string(),
|
|
4681
|
+
privateKey: import_zod50.z.string().optional(),
|
|
4682
|
+
walletClient: import_zod50.z.unknown().optional(),
|
|
4683
|
+
publicClient: import_zod50.z.unknown().optional(),
|
|
4684
|
+
skipPrerequisiteChecks: import_zod50.z.boolean().optional().default(false),
|
|
4685
|
+
minBalance: import_zod50.z.string().optional(),
|
|
4686
|
+
timeout: import_zod50.z.number().optional().default(12e4),
|
|
4687
|
+
retryOptions: import_zod50.z.unknown().optional(),
|
|
4688
|
+
signal: import_zod50.z.unknown().optional(),
|
|
4689
|
+
onTransactionStateChange: import_zod50.z.function().optional(),
|
|
4690
|
+
onTransactionSubmitted: import_zod50.z.function().optional(),
|
|
4691
|
+
onTransactionConfirmed: import_zod50.z.function().optional()
|
|
4692
|
+
}).passthrough().refine((data) => !!data.privateKey !== !!data.walletClient, {
|
|
4693
|
+
message: "Either 'privateKey' or 'walletClient' must be provided, but not both",
|
|
4694
|
+
path: ["privateKey", "walletClient"]
|
|
4695
|
+
}).refine(
|
|
4696
|
+
(data) => {
|
|
4697
|
+
if (!!data.publicClient && !!data.walletClient) return true;
|
|
4698
|
+
return !!data.chain;
|
|
4699
|
+
},
|
|
4700
|
+
{
|
|
4701
|
+
message: "Chain is required when publicClient or walletClient is not provided",
|
|
4702
|
+
path: ["chain"]
|
|
4374
4703
|
}
|
|
4375
|
-
|
|
4376
|
-
var
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4704
|
+
);
|
|
4705
|
+
var AddDeviceSchema = import_zod50.z.object({
|
|
4706
|
+
appAddress: import_zod50.z.string(),
|
|
4707
|
+
deviceId: import_zod50.z.string(),
|
|
4708
|
+
transactionHash: import_zod50.z.string(),
|
|
4709
|
+
blockNumber: import_zod50.z.bigint().optional(),
|
|
4710
|
+
gasUsed: import_zod50.z.bigint().optional()
|
|
4711
|
+
}).passthrough();
|
|
4712
|
+
async function addDevice(request, parameters) {
|
|
4713
|
+
const validatedRequest = AddDeviceRequestSchema.parse(request);
|
|
4714
|
+
const {
|
|
4715
|
+
chain,
|
|
4716
|
+
rpcUrl,
|
|
4717
|
+
appAddress,
|
|
4718
|
+
deviceId,
|
|
4719
|
+
privateKey,
|
|
4720
|
+
walletClient: providedWalletClient,
|
|
4721
|
+
publicClient: providedPublicClient,
|
|
4722
|
+
timeout = 12e4,
|
|
4723
|
+
retryOptions,
|
|
4724
|
+
signal,
|
|
4725
|
+
onTransactionStateChange,
|
|
4726
|
+
onTransactionSubmitted,
|
|
4727
|
+
onTransactionConfirmed,
|
|
4728
|
+
skipPrerequisiteChecks = false,
|
|
4729
|
+
minBalance
|
|
4730
|
+
} = validatedRequest;
|
|
4731
|
+
const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
|
|
4732
|
+
const deviceIdHex = asHex(deviceId);
|
|
4733
|
+
let publicClient;
|
|
4734
|
+
let walletClient;
|
|
4735
|
+
let address;
|
|
4736
|
+
let chainId;
|
|
4737
|
+
if (privateKey) {
|
|
4738
|
+
const account = (0, import_accounts4.privateKeyToAccount)(privateKey);
|
|
4739
|
+
const transport = (0, import_viem5.http)(rpcUrl, { timeout });
|
|
4740
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem5.createPublicClient)({ chain, transport });
|
|
4741
|
+
walletClient = (0, import_viem5.createWalletClient)({
|
|
4742
|
+
account,
|
|
4743
|
+
chain,
|
|
4744
|
+
transport
|
|
4745
|
+
});
|
|
4746
|
+
address = account.address;
|
|
4747
|
+
chainId = chain.id;
|
|
4748
|
+
} else if (providedWalletClient) {
|
|
4749
|
+
walletClient = providedWalletClient;
|
|
4750
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem5.createPublicClient)({
|
|
4751
|
+
chain,
|
|
4752
|
+
transport: (0, import_viem5.http)(rpcUrl, { timeout })
|
|
4753
|
+
});
|
|
4754
|
+
if (!walletClient.account?.address) {
|
|
4755
|
+
throw new Error("WalletClient must have an account with address");
|
|
4756
|
+
}
|
|
4757
|
+
address = walletClient.account.address;
|
|
4758
|
+
chainId = chain ? chain.id : await walletClient.getChainId();
|
|
4759
|
+
} else {
|
|
4760
|
+
throw new Error("Either privateKey or walletClient must be provided");
|
|
4381
4761
|
}
|
|
4382
|
-
};
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
const
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4762
|
+
const networkClients = { publicClient, walletClient, address, chainId };
|
|
4763
|
+
const transactionTracker = createTransactionTracker();
|
|
4764
|
+
if (onTransactionStateChange && typeof onTransactionStateChange === "function") {
|
|
4765
|
+
const pollStatus = () => {
|
|
4766
|
+
onTransactionStateChange(transactionTracker.status);
|
|
4767
|
+
if (!transactionTracker.isComplete) {
|
|
4768
|
+
setTimeout(pollStatus, 100);
|
|
4769
|
+
}
|
|
4770
|
+
};
|
|
4771
|
+
setTimeout(pollStatus, 10);
|
|
4389
4772
|
}
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
const
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4773
|
+
if (!skipPrerequisiteChecks) {
|
|
4774
|
+
const requirements = {
|
|
4775
|
+
targetChainId: chainId,
|
|
4776
|
+
minBalance: minBalance ? (0, import_viem5.parseEther)(minBalance) : (0, import_viem5.parseEther)("0.001")
|
|
4777
|
+
};
|
|
4778
|
+
const validation = await validateNetworkPrerequisites(networkClients, requirements);
|
|
4779
|
+
if (!validation.networkValid) {
|
|
4780
|
+
throw new Error(
|
|
4781
|
+
`Network mismatch: Expected chain ${requirements.targetChainId}, but wallet is on chain ${validation.details.currentChainId}`
|
|
4782
|
+
);
|
|
4783
|
+
}
|
|
4784
|
+
if (!validation.balanceValid) {
|
|
4785
|
+
const requiredEth = Number(requirements.minBalance) / 1e18;
|
|
4786
|
+
const currentEth = Number(validation.details.balance) / 1e18;
|
|
4787
|
+
throw new Error(
|
|
4788
|
+
`Insufficient balance: Required ${requiredEth} ETH, but account has ${currentEth.toFixed(6)} ETH`
|
|
4789
|
+
);
|
|
4790
|
+
}
|
|
4791
|
+
}
|
|
4792
|
+
const contractOwner = await publicClient.readContract({
|
|
4793
|
+
address: contractAddress,
|
|
4794
|
+
abi: dstackAppAbi,
|
|
4795
|
+
functionName: "owner"
|
|
4796
|
+
});
|
|
4797
|
+
if (contractOwner.toLowerCase() !== address.toLowerCase()) {
|
|
4798
|
+
throw new Error(
|
|
4799
|
+
`Sender ${address} is not the owner of contract ${contractAddress}. Contract owner is ${contractOwner}.`
|
|
4800
|
+
);
|
|
4801
|
+
}
|
|
4802
|
+
const addDeviceOperation = async (clients) => {
|
|
4803
|
+
return clients.walletClient.writeContract({
|
|
4804
|
+
address: contractAddress,
|
|
4805
|
+
abi: dstackAppAbi,
|
|
4806
|
+
functionName: "addDevice",
|
|
4807
|
+
args: [deviceIdHex],
|
|
4808
|
+
account: clients.walletClient.account || clients.address,
|
|
4809
|
+
chain: chain || null
|
|
4810
|
+
});
|
|
4811
|
+
};
|
|
4812
|
+
const transactionResult = retryOptions ? await executeTransactionWithRetry(
|
|
4813
|
+
addDeviceOperation,
|
|
4814
|
+
networkClients,
|
|
4815
|
+
[],
|
|
4816
|
+
{
|
|
4817
|
+
timeout,
|
|
4818
|
+
confirmations: 1,
|
|
4819
|
+
onSubmitted: onTransactionSubmitted,
|
|
4820
|
+
onConfirmed: onTransactionConfirmed,
|
|
4821
|
+
signal
|
|
4822
|
+
},
|
|
4823
|
+
retryOptions
|
|
4824
|
+
) : await transactionTracker.execute(addDeviceOperation, networkClients, [], {
|
|
4825
|
+
timeout,
|
|
4826
|
+
confirmations: 1,
|
|
4827
|
+
onSubmitted: onTransactionSubmitted,
|
|
4828
|
+
onConfirmed: onTransactionConfirmed,
|
|
4829
|
+
signal
|
|
4830
|
+
});
|
|
4831
|
+
const result = {
|
|
4832
|
+
appAddress: contractAddress,
|
|
4833
|
+
deviceId: deviceIdHex,
|
|
4834
|
+
transactionHash: transactionResult.receipt.transactionHash,
|
|
4835
|
+
blockNumber: transactionResult.receipt.blockNumber,
|
|
4836
|
+
gasUsed: transactionResult.receipt.gasUsed
|
|
4837
|
+
};
|
|
4838
|
+
if (parameters?.schema === false) {
|
|
4839
|
+
return result;
|
|
4840
|
+
}
|
|
4841
|
+
const schema = parameters?.schema || AddDeviceSchema;
|
|
4842
|
+
return schema.parse(result);
|
|
4843
|
+
}
|
|
4844
|
+
async function safeAddDevice(request, parameters) {
|
|
4845
|
+
try {
|
|
4846
|
+
const result = await addDevice(request, parameters);
|
|
4847
|
+
return { success: true, data: result };
|
|
4848
|
+
} catch (error) {
|
|
4849
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
|
|
4850
|
+
return {
|
|
4851
|
+
success: false,
|
|
4852
|
+
error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
|
|
4853
|
+
};
|
|
4854
|
+
}
|
|
4855
|
+
}
|
|
4856
|
+
|
|
4857
|
+
// src/actions/blockchains/remove_device.ts
|
|
4858
|
+
var import_zod51 = require("zod");
|
|
4859
|
+
var import_viem6 = require("viem");
|
|
4860
|
+
var import_accounts5 = require("viem/accounts");
|
|
4861
|
+
var RemoveDeviceRequestSchema = import_zod51.z.object({
|
|
4862
|
+
chain: import_zod51.z.unknown().optional(),
|
|
4863
|
+
rpcUrl: import_zod51.z.string().optional(),
|
|
4864
|
+
appAddress: import_zod51.z.string(),
|
|
4865
|
+
deviceId: import_zod51.z.string(),
|
|
4866
|
+
privateKey: import_zod51.z.string().optional(),
|
|
4867
|
+
walletClient: import_zod51.z.unknown().optional(),
|
|
4868
|
+
publicClient: import_zod51.z.unknown().optional(),
|
|
4869
|
+
skipPrerequisiteChecks: import_zod51.z.boolean().optional().default(false),
|
|
4870
|
+
minBalance: import_zod51.z.string().optional(),
|
|
4871
|
+
timeout: import_zod51.z.number().optional().default(12e4),
|
|
4872
|
+
retryOptions: import_zod51.z.unknown().optional(),
|
|
4873
|
+
signal: import_zod51.z.unknown().optional(),
|
|
4874
|
+
onTransactionStateChange: import_zod51.z.function().optional(),
|
|
4875
|
+
onTransactionSubmitted: import_zod51.z.function().optional(),
|
|
4876
|
+
onTransactionConfirmed: import_zod51.z.function().optional()
|
|
4877
|
+
}).passthrough().refine((data) => !!data.privateKey !== !!data.walletClient, {
|
|
4878
|
+
message: "Either 'privateKey' or 'walletClient' must be provided, but not both",
|
|
4879
|
+
path: ["privateKey", "walletClient"]
|
|
4880
|
+
}).refine(
|
|
4881
|
+
(data) => {
|
|
4882
|
+
if (!!data.publicClient && !!data.walletClient) return true;
|
|
4883
|
+
return !!data.chain;
|
|
4884
|
+
},
|
|
4885
|
+
{
|
|
4886
|
+
message: "Chain is required when publicClient or walletClient is not provided",
|
|
4887
|
+
path: ["chain"]
|
|
4888
|
+
}
|
|
4889
|
+
);
|
|
4890
|
+
var RemoveDeviceSchema = import_zod51.z.object({
|
|
4891
|
+
appAddress: import_zod51.z.string(),
|
|
4892
|
+
deviceId: import_zod51.z.string(),
|
|
4893
|
+
transactionHash: import_zod51.z.string(),
|
|
4894
|
+
blockNumber: import_zod51.z.bigint().optional(),
|
|
4895
|
+
gasUsed: import_zod51.z.bigint().optional()
|
|
4896
|
+
}).passthrough();
|
|
4897
|
+
async function removeDevice(request, parameters) {
|
|
4898
|
+
const validatedRequest = RemoveDeviceRequestSchema.parse(request);
|
|
4899
|
+
const {
|
|
4900
|
+
chain,
|
|
4901
|
+
rpcUrl,
|
|
4902
|
+
appAddress,
|
|
4903
|
+
deviceId,
|
|
4904
|
+
privateKey,
|
|
4905
|
+
walletClient: providedWalletClient,
|
|
4906
|
+
publicClient: providedPublicClient,
|
|
4907
|
+
timeout = 12e4,
|
|
4908
|
+
retryOptions,
|
|
4909
|
+
signal,
|
|
4910
|
+
onTransactionStateChange,
|
|
4911
|
+
onTransactionSubmitted,
|
|
4912
|
+
onTransactionConfirmed,
|
|
4913
|
+
skipPrerequisiteChecks = false,
|
|
4914
|
+
minBalance
|
|
4915
|
+
} = validatedRequest;
|
|
4916
|
+
const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
|
|
4917
|
+
const deviceIdHex = asHex(deviceId);
|
|
4918
|
+
let publicClient;
|
|
4919
|
+
let walletClient;
|
|
4920
|
+
let address;
|
|
4921
|
+
let chainId;
|
|
4922
|
+
if (privateKey) {
|
|
4923
|
+
const account = (0, import_accounts5.privateKeyToAccount)(privateKey);
|
|
4924
|
+
const transport = (0, import_viem6.http)(rpcUrl, { timeout });
|
|
4925
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem6.createPublicClient)({ chain, transport });
|
|
4926
|
+
walletClient = (0, import_viem6.createWalletClient)({
|
|
4927
|
+
account,
|
|
4928
|
+
chain,
|
|
4929
|
+
transport
|
|
4930
|
+
});
|
|
4931
|
+
address = account.address;
|
|
4932
|
+
chainId = chain.id;
|
|
4933
|
+
} else if (providedWalletClient) {
|
|
4934
|
+
walletClient = providedWalletClient;
|
|
4935
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem6.createPublicClient)({
|
|
4936
|
+
chain,
|
|
4937
|
+
transport: (0, import_viem6.http)(rpcUrl, { timeout })
|
|
4938
|
+
});
|
|
4939
|
+
if (!walletClient.account?.address) {
|
|
4940
|
+
throw new Error("WalletClient must have an account with address");
|
|
4941
|
+
}
|
|
4942
|
+
address = walletClient.account.address;
|
|
4943
|
+
chainId = chain ? chain.id : await walletClient.getChainId();
|
|
4944
|
+
} else {
|
|
4945
|
+
throw new Error("Either privateKey or walletClient must be provided");
|
|
4946
|
+
}
|
|
4947
|
+
const networkClients = { publicClient, walletClient, address, chainId };
|
|
4948
|
+
const transactionTracker = createTransactionTracker();
|
|
4949
|
+
if (onTransactionStateChange && typeof onTransactionStateChange === "function") {
|
|
4950
|
+
const pollStatus = () => {
|
|
4951
|
+
onTransactionStateChange(transactionTracker.status);
|
|
4952
|
+
if (!transactionTracker.isComplete) {
|
|
4953
|
+
setTimeout(pollStatus, 100);
|
|
4954
|
+
}
|
|
4955
|
+
};
|
|
4956
|
+
setTimeout(pollStatus, 10);
|
|
4957
|
+
}
|
|
4958
|
+
if (!skipPrerequisiteChecks) {
|
|
4959
|
+
const requirements = {
|
|
4960
|
+
targetChainId: chainId,
|
|
4961
|
+
minBalance: minBalance ? (0, import_viem6.parseEther)(minBalance) : (0, import_viem6.parseEther)("0.001")
|
|
4962
|
+
};
|
|
4963
|
+
const validation = await validateNetworkPrerequisites(networkClients, requirements);
|
|
4964
|
+
if (!validation.networkValid) {
|
|
4965
|
+
throw new Error(
|
|
4966
|
+
`Network mismatch: Expected chain ${requirements.targetChainId}, but wallet is on chain ${validation.details.currentChainId}`
|
|
4967
|
+
);
|
|
4968
|
+
}
|
|
4969
|
+
if (!validation.balanceValid) {
|
|
4970
|
+
const requiredEth = Number(requirements.minBalance) / 1e18;
|
|
4971
|
+
const currentEth = Number(validation.details.balance) / 1e18;
|
|
4972
|
+
throw new Error(
|
|
4973
|
+
`Insufficient balance: Required ${requiredEth} ETH, but account has ${currentEth.toFixed(6)} ETH`
|
|
4974
|
+
);
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
4977
|
+
const removeDeviceOperation = async (clients) => {
|
|
4978
|
+
return clients.walletClient.writeContract({
|
|
4979
|
+
address: contractAddress,
|
|
4980
|
+
abi: dstackAppAbi,
|
|
4981
|
+
functionName: "removeDevice",
|
|
4982
|
+
args: [deviceIdHex],
|
|
4983
|
+
account: clients.walletClient.account || clients.address,
|
|
4984
|
+
chain: chain || null
|
|
4985
|
+
});
|
|
4986
|
+
};
|
|
4987
|
+
const transactionResult = retryOptions ? await executeTransactionWithRetry(
|
|
4988
|
+
removeDeviceOperation,
|
|
4989
|
+
networkClients,
|
|
4990
|
+
[],
|
|
4991
|
+
{
|
|
4992
|
+
timeout,
|
|
4993
|
+
confirmations: 1,
|
|
4994
|
+
onSubmitted: onTransactionSubmitted,
|
|
4995
|
+
onConfirmed: onTransactionConfirmed,
|
|
4996
|
+
signal
|
|
4997
|
+
},
|
|
4998
|
+
retryOptions
|
|
4999
|
+
) : await transactionTracker.execute(removeDeviceOperation, networkClients, [], {
|
|
5000
|
+
timeout,
|
|
5001
|
+
confirmations: 1,
|
|
5002
|
+
onSubmitted: onTransactionSubmitted,
|
|
5003
|
+
onConfirmed: onTransactionConfirmed,
|
|
5004
|
+
signal
|
|
5005
|
+
});
|
|
5006
|
+
const result = {
|
|
5007
|
+
appAddress: contractAddress,
|
|
5008
|
+
deviceId: deviceIdHex,
|
|
5009
|
+
transactionHash: transactionResult.receipt.transactionHash,
|
|
5010
|
+
blockNumber: transactionResult.receipt.blockNumber,
|
|
5011
|
+
gasUsed: transactionResult.receipt.gasUsed
|
|
5012
|
+
};
|
|
5013
|
+
if (parameters?.schema === false) {
|
|
5014
|
+
return result;
|
|
5015
|
+
}
|
|
5016
|
+
const schema = parameters?.schema || RemoveDeviceSchema;
|
|
5017
|
+
return schema.parse(result);
|
|
5018
|
+
}
|
|
5019
|
+
async function safeRemoveDevice(request, parameters) {
|
|
5020
|
+
try {
|
|
5021
|
+
const result = await removeDevice(request, parameters);
|
|
5022
|
+
return { success: true, data: result };
|
|
5023
|
+
} catch (error) {
|
|
5024
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
|
|
5025
|
+
return {
|
|
5026
|
+
success: false,
|
|
5027
|
+
error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
|
|
5028
|
+
};
|
|
5029
|
+
}
|
|
5030
|
+
}
|
|
5031
|
+
|
|
5032
|
+
// src/actions/blockchains/set_allow_any_device.ts
|
|
5033
|
+
var import_zod52 = require("zod");
|
|
5034
|
+
var import_viem7 = require("viem");
|
|
5035
|
+
var import_accounts6 = require("viem/accounts");
|
|
5036
|
+
var SetAllowAnyDeviceRequestSchema = import_zod52.z.object({
|
|
5037
|
+
chain: import_zod52.z.unknown().optional(),
|
|
5038
|
+
rpcUrl: import_zod52.z.string().optional(),
|
|
5039
|
+
appAddress: import_zod52.z.string(),
|
|
5040
|
+
allow: import_zod52.z.boolean(),
|
|
5041
|
+
privateKey: import_zod52.z.string().optional(),
|
|
5042
|
+
walletClient: import_zod52.z.unknown().optional(),
|
|
5043
|
+
publicClient: import_zod52.z.unknown().optional(),
|
|
5044
|
+
skipPrerequisiteChecks: import_zod52.z.boolean().optional().default(false),
|
|
5045
|
+
minBalance: import_zod52.z.string().optional(),
|
|
5046
|
+
timeout: import_zod52.z.number().optional().default(12e4),
|
|
5047
|
+
retryOptions: import_zod52.z.unknown().optional(),
|
|
5048
|
+
signal: import_zod52.z.unknown().optional(),
|
|
5049
|
+
onTransactionStateChange: import_zod52.z.function().optional(),
|
|
5050
|
+
onTransactionSubmitted: import_zod52.z.function().optional(),
|
|
5051
|
+
onTransactionConfirmed: import_zod52.z.function().optional()
|
|
5052
|
+
}).passthrough().refine((data) => !!data.privateKey !== !!data.walletClient, {
|
|
5053
|
+
message: "Either 'privateKey' or 'walletClient' must be provided, but not both",
|
|
5054
|
+
path: ["privateKey", "walletClient"]
|
|
5055
|
+
}).refine(
|
|
5056
|
+
(data) => {
|
|
5057
|
+
if (!!data.publicClient && !!data.walletClient) return true;
|
|
5058
|
+
return !!data.chain;
|
|
5059
|
+
},
|
|
5060
|
+
{
|
|
5061
|
+
message: "Chain is required when publicClient or walletClient is not provided",
|
|
5062
|
+
path: ["chain"]
|
|
5063
|
+
}
|
|
5064
|
+
);
|
|
5065
|
+
var SetAllowAnyDeviceSchema = import_zod52.z.object({
|
|
5066
|
+
appAddress: import_zod52.z.string(),
|
|
5067
|
+
allow: import_zod52.z.boolean(),
|
|
5068
|
+
transactionHash: import_zod52.z.string(),
|
|
5069
|
+
blockNumber: import_zod52.z.bigint().optional(),
|
|
5070
|
+
gasUsed: import_zod52.z.bigint().optional()
|
|
5071
|
+
}).passthrough();
|
|
5072
|
+
async function setAllowAnyDevice(request, parameters) {
|
|
5073
|
+
const validatedRequest = SetAllowAnyDeviceRequestSchema.parse(request);
|
|
5074
|
+
const {
|
|
5075
|
+
chain,
|
|
5076
|
+
rpcUrl,
|
|
5077
|
+
appAddress,
|
|
5078
|
+
allow,
|
|
5079
|
+
privateKey,
|
|
5080
|
+
walletClient: providedWalletClient,
|
|
5081
|
+
publicClient: providedPublicClient,
|
|
5082
|
+
timeout = 12e4,
|
|
5083
|
+
retryOptions,
|
|
5084
|
+
signal,
|
|
5085
|
+
onTransactionStateChange,
|
|
5086
|
+
onTransactionSubmitted,
|
|
5087
|
+
onTransactionConfirmed,
|
|
5088
|
+
skipPrerequisiteChecks = false,
|
|
5089
|
+
minBalance
|
|
5090
|
+
} = validatedRequest;
|
|
5091
|
+
const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
|
|
5092
|
+
let publicClient;
|
|
5093
|
+
let walletClient;
|
|
5094
|
+
let address;
|
|
5095
|
+
let chainId;
|
|
5096
|
+
if (privateKey) {
|
|
5097
|
+
const account = (0, import_accounts6.privateKeyToAccount)(privateKey);
|
|
5098
|
+
const transport = (0, import_viem7.http)(rpcUrl, { timeout });
|
|
5099
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem7.createPublicClient)({ chain, transport });
|
|
5100
|
+
walletClient = (0, import_viem7.createWalletClient)({
|
|
5101
|
+
account,
|
|
5102
|
+
chain,
|
|
5103
|
+
transport
|
|
5104
|
+
});
|
|
5105
|
+
address = account.address;
|
|
5106
|
+
chainId = chain.id;
|
|
5107
|
+
} else if (providedWalletClient) {
|
|
5108
|
+
walletClient = providedWalletClient;
|
|
5109
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem7.createPublicClient)({
|
|
5110
|
+
chain,
|
|
5111
|
+
transport: (0, import_viem7.http)(rpcUrl, { timeout })
|
|
5112
|
+
});
|
|
5113
|
+
if (!walletClient.account?.address) {
|
|
5114
|
+
throw new Error("WalletClient must have an account with address");
|
|
5115
|
+
}
|
|
5116
|
+
address = walletClient.account.address;
|
|
5117
|
+
chainId = chain ? chain.id : await walletClient.getChainId();
|
|
5118
|
+
} else {
|
|
5119
|
+
throw new Error("Either privateKey or walletClient must be provided");
|
|
5120
|
+
}
|
|
5121
|
+
const networkClients = { publicClient, walletClient, address, chainId };
|
|
5122
|
+
const transactionTracker = createTransactionTracker();
|
|
5123
|
+
if (onTransactionStateChange && typeof onTransactionStateChange === "function") {
|
|
5124
|
+
const pollStatus = () => {
|
|
5125
|
+
onTransactionStateChange(transactionTracker.status);
|
|
5126
|
+
if (!transactionTracker.isComplete) {
|
|
5127
|
+
setTimeout(pollStatus, 100);
|
|
5128
|
+
}
|
|
5129
|
+
};
|
|
5130
|
+
setTimeout(pollStatus, 10);
|
|
5131
|
+
}
|
|
5132
|
+
if (!skipPrerequisiteChecks) {
|
|
5133
|
+
const requirements = {
|
|
5134
|
+
targetChainId: chainId,
|
|
5135
|
+
minBalance: minBalance ? (0, import_viem7.parseEther)(minBalance) : (0, import_viem7.parseEther)("0.001")
|
|
5136
|
+
};
|
|
5137
|
+
const validation = await validateNetworkPrerequisites(networkClients, requirements);
|
|
5138
|
+
if (!validation.networkValid) {
|
|
5139
|
+
throw new Error(
|
|
5140
|
+
`Network mismatch: Expected chain ${requirements.targetChainId}, but wallet is on chain ${validation.details.currentChainId}`
|
|
5141
|
+
);
|
|
5142
|
+
}
|
|
5143
|
+
if (!validation.balanceValid) {
|
|
5144
|
+
const requiredEth = Number(requirements.minBalance) / 1e18;
|
|
5145
|
+
const currentEth = Number(validation.details.balance) / 1e18;
|
|
5146
|
+
throw new Error(
|
|
5147
|
+
`Insufficient balance: Required ${requiredEth} ETH, but account has ${currentEth.toFixed(6)} ETH`
|
|
5148
|
+
);
|
|
5149
|
+
}
|
|
5150
|
+
}
|
|
5151
|
+
const setAllowAnyOperation = async (clients) => {
|
|
5152
|
+
return clients.walletClient.writeContract({
|
|
5153
|
+
address: contractAddress,
|
|
5154
|
+
abi: dstackAppAbi,
|
|
5155
|
+
functionName: "setAllowAnyDevice",
|
|
5156
|
+
args: [allow],
|
|
5157
|
+
account: clients.walletClient.account || clients.address,
|
|
5158
|
+
chain: chain || null
|
|
5159
|
+
});
|
|
5160
|
+
};
|
|
5161
|
+
const transactionResult = retryOptions ? await executeTransactionWithRetry(
|
|
5162
|
+
setAllowAnyOperation,
|
|
5163
|
+
networkClients,
|
|
5164
|
+
[],
|
|
5165
|
+
{
|
|
5166
|
+
timeout,
|
|
5167
|
+
confirmations: 1,
|
|
5168
|
+
onSubmitted: onTransactionSubmitted,
|
|
5169
|
+
onConfirmed: onTransactionConfirmed,
|
|
5170
|
+
signal
|
|
5171
|
+
},
|
|
5172
|
+
retryOptions
|
|
5173
|
+
) : await transactionTracker.execute(setAllowAnyOperation, networkClients, [], {
|
|
5174
|
+
timeout,
|
|
5175
|
+
confirmations: 1,
|
|
5176
|
+
onSubmitted: onTransactionSubmitted,
|
|
5177
|
+
onConfirmed: onTransactionConfirmed,
|
|
5178
|
+
signal
|
|
5179
|
+
});
|
|
5180
|
+
const result = {
|
|
5181
|
+
appAddress: contractAddress,
|
|
5182
|
+
allow,
|
|
5183
|
+
transactionHash: transactionResult.receipt.transactionHash,
|
|
5184
|
+
blockNumber: transactionResult.receipt.blockNumber,
|
|
5185
|
+
gasUsed: transactionResult.receipt.gasUsed
|
|
5186
|
+
};
|
|
5187
|
+
if (parameters?.schema === false) {
|
|
5188
|
+
return result;
|
|
5189
|
+
}
|
|
5190
|
+
const schema = parameters?.schema || SetAllowAnyDeviceSchema;
|
|
5191
|
+
return schema.parse(result);
|
|
5192
|
+
}
|
|
5193
|
+
async function safeSetAllowAnyDevice(request, parameters) {
|
|
5194
|
+
try {
|
|
5195
|
+
const result = await setAllowAnyDevice(request, parameters);
|
|
5196
|
+
return { success: true, data: result };
|
|
5197
|
+
} catch (error) {
|
|
5198
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
|
|
5199
|
+
return {
|
|
5200
|
+
success: false,
|
|
5201
|
+
error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
|
|
5202
|
+
};
|
|
5203
|
+
}
|
|
5204
|
+
}
|
|
5205
|
+
|
|
5206
|
+
// src/actions/blockchains/get_allowed_devices.ts
|
|
5207
|
+
var import_zod53 = require("zod");
|
|
5208
|
+
var import_viem8 = require("viem");
|
|
5209
|
+
var GetAllowedDevicesSchema = import_zod53.z.object({
|
|
5210
|
+
appAddress: import_zod53.z.string(),
|
|
5211
|
+
owner: import_zod53.z.string(),
|
|
5212
|
+
allowAnyDevice: import_zod53.z.boolean(),
|
|
5213
|
+
devices: import_zod53.z.array(import_zod53.z.string())
|
|
5214
|
+
});
|
|
5215
|
+
async function getAllowedDevices(request) {
|
|
5216
|
+
const { chain, rpcUrl, appAddress, deviceIds, publicClient: providedPublicClient } = request;
|
|
5217
|
+
const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
|
|
5218
|
+
const publicClient = providedPublicClient ? providedPublicClient : (() => {
|
|
5219
|
+
if (!chain) throw new Error("Chain is required when publicClient is not provided");
|
|
5220
|
+
return (0, import_viem8.createPublicClient)({ chain, transport: (0, import_viem8.http)(rpcUrl) });
|
|
5221
|
+
})();
|
|
5222
|
+
const [allowAnyDevice, owner] = await Promise.all([
|
|
5223
|
+
publicClient.readContract({
|
|
5224
|
+
address: contractAddress,
|
|
5225
|
+
abi: dstackAppAbi,
|
|
5226
|
+
functionName: "allowAnyDevice"
|
|
5227
|
+
}),
|
|
5228
|
+
publicClient.readContract({
|
|
5229
|
+
address: contractAddress,
|
|
5230
|
+
abi: dstackAppAbi,
|
|
5231
|
+
functionName: "owner"
|
|
5232
|
+
})
|
|
5233
|
+
]);
|
|
5234
|
+
if (allowAnyDevice) {
|
|
5235
|
+
return {
|
|
5236
|
+
appAddress: contractAddress,
|
|
5237
|
+
owner,
|
|
5238
|
+
allowAnyDevice: true,
|
|
5239
|
+
devices: deviceIds.map((id) => asHex(id))
|
|
5240
|
+
};
|
|
5241
|
+
}
|
|
5242
|
+
let devices;
|
|
5243
|
+
if (deviceIds.length === 0) {
|
|
5244
|
+
devices = [];
|
|
5245
|
+
} else {
|
|
5246
|
+
const calls = deviceIds.map((deviceId) => ({
|
|
5247
|
+
address: contractAddress,
|
|
5248
|
+
abi: dstackAppAbi,
|
|
5249
|
+
functionName: "allowedDeviceIds",
|
|
5250
|
+
args: [asHex(deviceId)]
|
|
5251
|
+
}));
|
|
5252
|
+
const multicallResults = await publicClient.multicall({ contracts: calls });
|
|
5253
|
+
devices = deviceIds.map((deviceId, i) => ({
|
|
5254
|
+
deviceId: asHex(deviceId),
|
|
5255
|
+
allowed: multicallResults[i]?.status === "success" && multicallResults[i]?.result === true
|
|
5256
|
+
})).filter((r) => r.allowed).map((r) => r.deviceId);
|
|
5257
|
+
}
|
|
5258
|
+
return {
|
|
5259
|
+
appAddress: contractAddress,
|
|
5260
|
+
owner,
|
|
5261
|
+
allowAnyDevice: false,
|
|
5262
|
+
devices
|
|
5263
|
+
};
|
|
5264
|
+
}
|
|
5265
|
+
async function safeGetAllowedDevices(request) {
|
|
5266
|
+
try {
|
|
5267
|
+
const result = await getAllowedDevices(request);
|
|
5268
|
+
return { success: true, data: result };
|
|
5269
|
+
} catch (error) {
|
|
5270
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
|
|
5271
|
+
return {
|
|
5272
|
+
success: false,
|
|
5273
|
+
error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
|
|
5274
|
+
};
|
|
5275
|
+
}
|
|
5276
|
+
}
|
|
5277
|
+
|
|
5278
|
+
// src/actions/blockchains/check_device_allowed.ts
|
|
5279
|
+
var import_viem9 = require("viem");
|
|
5280
|
+
async function checkDeviceAllowed(request) {
|
|
5281
|
+
const { chain, rpcUrl, appAddress, deviceId, publicClient: providedPublicClient } = request;
|
|
5282
|
+
const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
|
|
5283
|
+
const deviceIdHex = asHex(deviceId);
|
|
5284
|
+
const publicClient = providedPublicClient ? providedPublicClient : (() => {
|
|
5285
|
+
if (!chain) throw new Error("Chain is required when publicClient is not provided");
|
|
5286
|
+
return (0, import_viem9.createPublicClient)({ chain, transport: (0, import_viem9.http)(rpcUrl) });
|
|
5287
|
+
})();
|
|
5288
|
+
const allowAny = await publicClient.readContract({
|
|
5289
|
+
address: contractAddress,
|
|
5290
|
+
abi: dstackAppAbi,
|
|
5291
|
+
functionName: "allowAnyDevice"
|
|
5292
|
+
});
|
|
5293
|
+
if (allowAny) return true;
|
|
5294
|
+
const allowed = await publicClient.readContract({
|
|
5295
|
+
address: contractAddress,
|
|
5296
|
+
abi: dstackAppAbi,
|
|
5297
|
+
functionName: "allowedDeviceIds",
|
|
5298
|
+
args: [deviceIdHex]
|
|
5299
|
+
});
|
|
5300
|
+
return allowed;
|
|
5301
|
+
}
|
|
5302
|
+
async function safeCheckDeviceAllowed(request) {
|
|
5303
|
+
try {
|
|
5304
|
+
const result = await checkDeviceAllowed(request);
|
|
5305
|
+
return { success: true, data: result };
|
|
5306
|
+
} catch (error) {
|
|
5307
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
|
|
5308
|
+
return {
|
|
5309
|
+
success: false,
|
|
5310
|
+
error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
|
|
5311
|
+
};
|
|
5312
|
+
}
|
|
5313
|
+
}
|
|
5314
|
+
|
|
5315
|
+
// src/actions/blockchains/check_compose_hash_allowed.ts
|
|
5316
|
+
var import_viem10 = require("viem");
|
|
5317
|
+
async function checkComposeHashAllowed(request) {
|
|
5318
|
+
const { chain, rpcUrl, appAddress, composeHash, publicClient: providedPublicClient } = request;
|
|
5319
|
+
const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
|
|
5320
|
+
const composeHashHex = asHex(composeHash);
|
|
5321
|
+
const publicClient = providedPublicClient ? providedPublicClient : (() => {
|
|
5322
|
+
if (!chain) throw new Error("Chain is required when publicClient is not provided");
|
|
5323
|
+
return (0, import_viem10.createPublicClient)({ chain, transport: (0, import_viem10.http)(rpcUrl) });
|
|
5324
|
+
})();
|
|
5325
|
+
const allowed = await publicClient.readContract({
|
|
5326
|
+
address: contractAddress,
|
|
5327
|
+
abi: dstackAppAbi,
|
|
5328
|
+
functionName: "allowedComposeHashes",
|
|
5329
|
+
args: [composeHashHex]
|
|
5330
|
+
});
|
|
5331
|
+
return allowed;
|
|
5332
|
+
}
|
|
5333
|
+
async function safeCheckComposeHashAllowed(request) {
|
|
5334
|
+
try {
|
|
5335
|
+
const result = await checkComposeHashAllowed(request);
|
|
5336
|
+
return { success: true, data: result };
|
|
5337
|
+
} catch (error) {
|
|
5338
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
|
|
5339
|
+
return {
|
|
5340
|
+
success: false,
|
|
5341
|
+
error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
|
|
5342
|
+
};
|
|
5343
|
+
}
|
|
5344
|
+
}
|
|
5345
|
+
|
|
5346
|
+
// src/actions/blockchains/check_on_chain_prerequisites.ts
|
|
5347
|
+
var import_viem11 = require("viem");
|
|
5348
|
+
async function checkOnChainPrerequisites(request) {
|
|
5349
|
+
const {
|
|
5350
|
+
chain,
|
|
5351
|
+
rpcUrl,
|
|
5352
|
+
appAddress,
|
|
5353
|
+
deviceId,
|
|
5354
|
+
composeHash,
|
|
5355
|
+
publicClient: providedPublicClient
|
|
5356
|
+
} = request;
|
|
5357
|
+
const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
|
|
5358
|
+
const deviceIdHex = asHex(deviceId);
|
|
5359
|
+
const composeHashHex = asHex(composeHash);
|
|
5360
|
+
const publicClient = providedPublicClient ? providedPublicClient : (() => {
|
|
5361
|
+
if (!chain) throw new Error("Chain is required when publicClient is not provided");
|
|
5362
|
+
return (0, import_viem11.createPublicClient)({ chain, transport: (0, import_viem11.http)(rpcUrl) });
|
|
5363
|
+
})();
|
|
5364
|
+
const calls = [
|
|
5365
|
+
{
|
|
5366
|
+
address: contractAddress,
|
|
5367
|
+
abi: dstackAppAbi,
|
|
5368
|
+
functionName: "allowAnyDevice"
|
|
5369
|
+
},
|
|
5370
|
+
{
|
|
5371
|
+
address: contractAddress,
|
|
5372
|
+
abi: dstackAppAbi,
|
|
5373
|
+
functionName: "allowedDeviceIds",
|
|
5374
|
+
args: [deviceIdHex]
|
|
5375
|
+
},
|
|
5376
|
+
{
|
|
5377
|
+
address: contractAddress,
|
|
5378
|
+
abi: dstackAppAbi,
|
|
5379
|
+
functionName: "allowedComposeHashes",
|
|
5380
|
+
args: [composeHashHex]
|
|
5381
|
+
}
|
|
5382
|
+
];
|
|
5383
|
+
const multicallResults = await publicClient.multicall({ contracts: calls });
|
|
5384
|
+
const allowAnyDevice = multicallResults[0]?.status === "success" && multicallResults[0]?.result === true;
|
|
5385
|
+
const deviceIdAllowed = multicallResults[1]?.status === "success" && multicallResults[1]?.result === true;
|
|
5386
|
+
const composeHashAllowed = multicallResults[2]?.status === "success" && multicallResults[2]?.result === true;
|
|
5387
|
+
return {
|
|
5388
|
+
allowAnyDevice,
|
|
5389
|
+
deviceAllowed: allowAnyDevice || deviceIdAllowed,
|
|
5390
|
+
composeHashAllowed
|
|
5391
|
+
};
|
|
5392
|
+
}
|
|
5393
|
+
async function safeCheckOnChainPrerequisites(request) {
|
|
5394
|
+
try {
|
|
5395
|
+
const result = await checkOnChainPrerequisites(request);
|
|
5396
|
+
return { success: true, data: result };
|
|
5397
|
+
} catch (error) {
|
|
5398
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
|
|
5399
|
+
return {
|
|
5400
|
+
success: false,
|
|
5401
|
+
error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
|
|
5402
|
+
};
|
|
5403
|
+
}
|
|
5404
|
+
}
|
|
5405
|
+
|
|
5406
|
+
// src/actions/workspaces/get_workspace_nodes.ts
|
|
5407
|
+
var import_zod54 = require("zod");
|
|
5408
|
+
var NodeRefSchema2 = NodeRefSchema;
|
|
5409
|
+
var NodeInfoSchema = NodeRefSchema2;
|
|
5410
|
+
var GetWorkspaceNodesSchema = import_zod54.z.object({
|
|
5411
|
+
items: import_zod54.z.array(NodeRefSchema2),
|
|
5412
|
+
total: import_zod54.z.number(),
|
|
5413
|
+
page: import_zod54.z.number(),
|
|
5414
|
+
page_size: import_zod54.z.number(),
|
|
5415
|
+
pages: import_zod54.z.number()
|
|
5416
|
+
}).passthrough();
|
|
5417
|
+
var { action: getWorkspaceNodes, safeAction: safeGetWorkspaceNodes } = defineAction(GetWorkspaceNodesSchema, async (client, request) => {
|
|
5418
|
+
const { teamSlug, page, pageSize } = request;
|
|
5419
|
+
const queryParams = new URLSearchParams();
|
|
5420
|
+
if (page !== void 0) queryParams.append("page", page.toString());
|
|
5421
|
+
if (pageSize !== void 0) queryParams.append("page_size", pageSize.toString());
|
|
5422
|
+
const url = queryParams.toString() ? `/workspaces/${teamSlug}/nodes?${queryParams.toString()}` : `/workspaces/${teamSlug}/nodes`;
|
|
5423
|
+
return await client.get(url);
|
|
5424
|
+
});
|
|
5425
|
+
|
|
5426
|
+
// src/actions/workspaces/get_workspace_quotas.ts
|
|
5427
|
+
var import_zod55 = require("zod");
|
|
5428
|
+
var QuotaMetricSchema = import_zod55.z.object({
|
|
5429
|
+
limit: import_zod55.z.number(),
|
|
5430
|
+
remaining: import_zod55.z.number()
|
|
5431
|
+
}).passthrough();
|
|
5432
|
+
var WorkspaceQuotasSchema = import_zod55.z.object({
|
|
5433
|
+
vm_slots: QuotaMetricSchema,
|
|
5434
|
+
vcpu: QuotaMetricSchema,
|
|
5435
|
+
memory_mb: QuotaMetricSchema,
|
|
5436
|
+
disk_gb: QuotaMetricSchema
|
|
5437
|
+
}).passthrough();
|
|
5438
|
+
var WorkspaceReservedGpuQuotaSchema = import_zod55.z.object({
|
|
5439
|
+
gpus: QuotaMetricSchema,
|
|
5440
|
+
in_use: import_zod55.z.number(),
|
|
5441
|
+
misconfigured: import_zod55.z.number()
|
|
5442
|
+
}).passthrough();
|
|
5443
|
+
var GetWorkspaceQuotasSchema = import_zod55.z.object({
|
|
5444
|
+
team_slug: import_zod55.z.string(),
|
|
5445
|
+
tier: import_zod55.z.string(),
|
|
5446
|
+
quotas: WorkspaceQuotasSchema,
|
|
5447
|
+
reserved_nodes: QuotaMetricSchema,
|
|
5448
|
+
reserved_gpu: WorkspaceReservedGpuQuotaSchema,
|
|
5449
|
+
as_of: import_zod55.z.string()
|
|
5450
|
+
}).passthrough();
|
|
5451
|
+
var { action: getWorkspaceQuotas, safeAction: safeGetWorkspaceQuotas } = defineAction(GetWorkspaceQuotasSchema, async (client, request) => {
|
|
5452
|
+
return await client.get(`/workspaces/${request.teamSlug}/quotas`);
|
|
5453
|
+
});
|
|
5454
|
+
|
|
5455
|
+
// src/actions/cvms/replicate_cvm.ts
|
|
5456
|
+
var import_zod56 = require("zod");
|
|
5457
|
+
var ReplicateCvmRequestSchema = refineCvmId(
|
|
5458
|
+
CvmIdObjectSchema.extend({
|
|
5459
|
+
node_id: import_zod56.z.number().optional()
|
|
5460
|
+
})
|
|
5461
|
+
);
|
|
5462
|
+
var { action: replicateCvm, safeAction: safeReplicateCvm } = defineAction(VMSchema, async (client, request) => {
|
|
5463
|
+
const parsed = ReplicateCvmRequestSchema.parse(request);
|
|
5464
|
+
const { cvmId } = CvmIdSchema.parse(parsed);
|
|
5465
|
+
const { node_id } = parsed;
|
|
5466
|
+
return await client.post(`/cvms/${cvmId}/replicas`, { node_id });
|
|
5467
|
+
});
|
|
5468
|
+
|
|
5469
|
+
// src/actions/cvms/watch_cvm_state.ts
|
|
5470
|
+
var import_zod57 = require("zod");
|
|
5471
|
+
var WatchCvmStateParamsSchema = import_zod57.z.object({
|
|
5472
|
+
target: import_zod57.z.string().describe("Target status to wait for (e.g., 'running', 'stopped')"),
|
|
5473
|
+
interval: import_zod57.z.number().min(5).max(30).default(5).describe("Polling interval in seconds"),
|
|
5474
|
+
timeout: import_zod57.z.number().min(10).max(600).default(300).describe("Timeout per attempt in seconds"),
|
|
5475
|
+
maxRetries: import_zod57.z.number().min(0).default(Number.POSITIVE_INFINITY).describe("Maximum number of retry attempts (Infinity for unlimited)"),
|
|
5476
|
+
retryDelay: import_zod57.z.number().min(0).default(5e3).describe("Delay between retries in milliseconds")
|
|
5477
|
+
});
|
|
5478
|
+
var WatchCvmStateRequestSchema = WatchCvmStateParamsSchema;
|
|
5479
|
+
var WatchAbortedError = class extends Error {
|
|
5480
|
+
constructor() {
|
|
5481
|
+
super("Watch operation was aborted");
|
|
5482
|
+
this.name = "WatchAbortedError";
|
|
5483
|
+
}
|
|
5484
|
+
};
|
|
5485
|
+
var MaxRetriesExceededError = class extends Error {
|
|
5486
|
+
constructor(attempts) {
|
|
5487
|
+
super(`Maximum retry attempts (${attempts}) exceeded`);
|
|
5488
|
+
this.attempts = attempts;
|
|
5489
|
+
this.name = "MaxRetriesExceededError";
|
|
5490
|
+
}
|
|
5491
|
+
};
|
|
5492
|
+
function parseSSEEvent(eventType, data) {
|
|
5493
|
+
try {
|
|
5494
|
+
const parsed = JSON.parse(data);
|
|
5495
|
+
return { type: eventType, data: parsed };
|
|
5496
|
+
} catch {
|
|
5497
|
+
return { type: "error", data: { error: "Failed to parse SSE event" } };
|
|
5498
|
+
}
|
|
5499
|
+
}
|
|
5500
|
+
async function watchCvmState(client, request, options = {}) {
|
|
5501
|
+
const { cvmId } = CvmIdSchema.parse(request);
|
|
5502
|
+
const { target, interval, timeout, maxRetries, retryDelay } = WatchCvmStateParamsSchema.parse(request);
|
|
5503
|
+
const { signal, onEvent } = options;
|
|
5504
|
+
let attempt = 0;
|
|
5505
|
+
while (attempt < maxRetries) {
|
|
5506
|
+
if (signal?.aborted) {
|
|
5507
|
+
throw new WatchAbortedError();
|
|
5508
|
+
}
|
|
5509
|
+
attempt++;
|
|
5510
|
+
try {
|
|
5511
|
+
const result = await watchSingleAttempt(
|
|
5512
|
+
client,
|
|
5513
|
+
cvmId,
|
|
5514
|
+
target,
|
|
5515
|
+
interval,
|
|
4407
5516
|
timeout,
|
|
4408
5517
|
signal,
|
|
4409
5518
|
onEvent
|
|
@@ -4551,22 +5660,230 @@ function sleep(ms, signal) {
|
|
|
4551
5660
|
});
|
|
4552
5661
|
}
|
|
4553
5662
|
|
|
5663
|
+
// src/actions/cvms/patch_cvm.ts
|
|
5664
|
+
var import_zod58 = require("zod");
|
|
5665
|
+
var PatchCvmRequestSchema = refineCvmId(
|
|
5666
|
+
CvmIdObjectSchema.extend({
|
|
5667
|
+
// Compose-hash-affecting fields
|
|
5668
|
+
docker_compose_file: import_zod58.z.string().optional(),
|
|
5669
|
+
pre_launch_script: import_zod58.z.string().optional(),
|
|
5670
|
+
allowed_envs: import_zod58.z.array(import_zod58.z.string()).optional(),
|
|
5671
|
+
// Visibility
|
|
5672
|
+
public_logs: import_zod58.z.boolean().optional(),
|
|
5673
|
+
public_sysinfo: import_zod58.z.boolean().optional(),
|
|
5674
|
+
public_tcbinfo: import_zod58.z.boolean().optional(),
|
|
5675
|
+
// Non-compose-hash config
|
|
5676
|
+
encrypted_env: import_zod58.z.string().optional(),
|
|
5677
|
+
user_config: import_zod58.z.string().optional(),
|
|
5678
|
+
gpus: import_zod58.z.object({
|
|
5679
|
+
count: import_zod58.z.number(),
|
|
5680
|
+
product_name: import_zod58.z.string().optional()
|
|
5681
|
+
}).optional(),
|
|
5682
|
+
// Resources
|
|
5683
|
+
vcpu: import_zod58.z.number().optional(),
|
|
5684
|
+
memory: import_zod58.z.number().optional(),
|
|
5685
|
+
disk_size: import_zod58.z.number().optional(),
|
|
5686
|
+
// OS image
|
|
5687
|
+
image: import_zod58.z.string().optional(),
|
|
5688
|
+
// Shutdown behavior
|
|
5689
|
+
shutdown_timeout: import_zod58.z.number().optional(),
|
|
5690
|
+
allow_force_stop: import_zod58.z.boolean().optional(),
|
|
5691
|
+
// Prepare-only mode (for multisig workflows)
|
|
5692
|
+
prepareOnly: import_zod58.z.boolean().optional()
|
|
5693
|
+
})
|
|
5694
|
+
);
|
|
5695
|
+
var PatchCvmAcceptedSchema = import_zod58.z.object({
|
|
5696
|
+
requiresOnChainHash: import_zod58.z.literal(false),
|
|
5697
|
+
correlationId: import_zod58.z.string()
|
|
5698
|
+
});
|
|
5699
|
+
var PatchCvmHashRequiredSchema = import_zod58.z.object({
|
|
5700
|
+
requiresOnChainHash: import_zod58.z.literal(true),
|
|
5701
|
+
composeHash: import_zod58.z.string(),
|
|
5702
|
+
appId: import_zod58.z.string(),
|
|
5703
|
+
deviceId: import_zod58.z.string(),
|
|
5704
|
+
kmsInfo: KmsInfoSchema,
|
|
5705
|
+
commitToken: import_zod58.z.string().optional(),
|
|
5706
|
+
commitUrl: import_zod58.z.string().optional(),
|
|
5707
|
+
apiCommitUrl: import_zod58.z.string().optional(),
|
|
5708
|
+
onchainStatus: import_zod58.z.object({
|
|
5709
|
+
compose_hash_allowed: import_zod58.z.boolean(),
|
|
5710
|
+
device_id_allowed: import_zod58.z.boolean(),
|
|
5711
|
+
is_allowed: import_zod58.z.boolean()
|
|
5712
|
+
}).optional()
|
|
5713
|
+
});
|
|
5714
|
+
var PatchCvmResultSchema = import_zod58.z.discriminatedUnion("requiresOnChainHash", [
|
|
5715
|
+
PatchCvmAcceptedSchema,
|
|
5716
|
+
PatchCvmHashRequiredSchema
|
|
5717
|
+
]);
|
|
5718
|
+
function extractDetailsMap(detail) {
|
|
5719
|
+
const map = {};
|
|
5720
|
+
if (!detail || typeof detail !== "object") return map;
|
|
5721
|
+
const obj = detail;
|
|
5722
|
+
const details = obj.details;
|
|
5723
|
+
if (!Array.isArray(details)) return map;
|
|
5724
|
+
for (const item of details) {
|
|
5725
|
+
if (item && typeof item === "object" && "field" in item && "value" in item) {
|
|
5726
|
+
map[item.field] = item.value;
|
|
5727
|
+
}
|
|
5728
|
+
}
|
|
5729
|
+
return map;
|
|
5730
|
+
}
|
|
5731
|
+
var { action: patchCvm, safeAction: safePatchCvm } = defineAction(PatchCvmResultSchema, async (client, request) => {
|
|
5732
|
+
const parsed = PatchCvmRequestSchema.parse(request);
|
|
5733
|
+
const { cvmId } = CvmIdSchema.parse(parsed);
|
|
5734
|
+
const { id, uuid, app_id, instance_id, name, prepareOnly, ...body } = parsed;
|
|
5735
|
+
try {
|
|
5736
|
+
const response = prepareOnly ? await client.patch(`/cvms/${cvmId}`, body, {
|
|
5737
|
+
headers: { "X-Prepare-Only": "true" }
|
|
5738
|
+
}) : await client.patch(`/cvms/${cvmId}`, body);
|
|
5739
|
+
return {
|
|
5740
|
+
requiresOnChainHash: false,
|
|
5741
|
+
correlationId: response.correlation_id
|
|
5742
|
+
};
|
|
5743
|
+
} catch (error) {
|
|
5744
|
+
if (error instanceof PhalaCloudError && error.status === 465) {
|
|
5745
|
+
const details = extractDetailsMap(error.detail);
|
|
5746
|
+
return {
|
|
5747
|
+
requiresOnChainHash: true,
|
|
5748
|
+
composeHash: details.compose_hash,
|
|
5749
|
+
appId: String(details.app_id),
|
|
5750
|
+
deviceId: details.device_id,
|
|
5751
|
+
kmsInfo: details.kms_info,
|
|
5752
|
+
commitToken: details.commit_token,
|
|
5753
|
+
commitUrl: details.commit_url,
|
|
5754
|
+
apiCommitUrl: details.api_commit_url,
|
|
5755
|
+
onchainStatus: details.onchain_status
|
|
5756
|
+
};
|
|
5757
|
+
}
|
|
5758
|
+
throw error;
|
|
5759
|
+
}
|
|
5760
|
+
});
|
|
5761
|
+
|
|
5762
|
+
// src/actions/cvms/confirm_cvm_patch.ts
|
|
5763
|
+
var import_zod59 = require("zod");
|
|
5764
|
+
var ConfirmCvmPatchRequestSchema = refineCvmId(
|
|
5765
|
+
CvmIdObjectSchema.extend({
|
|
5766
|
+
composeHash: import_zod59.z.string().describe("Compose hash from patchCvm Phase 1 response"),
|
|
5767
|
+
transactionHash: import_zod59.z.string().describe("Transaction hash proving on-chain registration")
|
|
5768
|
+
})
|
|
5769
|
+
);
|
|
5770
|
+
var ConfirmCvmPatchResultSchema = import_zod59.z.object({
|
|
5771
|
+
correlationId: import_zod59.z.string()
|
|
5772
|
+
});
|
|
5773
|
+
var { action: confirmCvmPatch, safeAction: safeConfirmCvmPatch } = defineAction(ConfirmCvmPatchResultSchema, async (client, request) => {
|
|
5774
|
+
const parsed = ConfirmCvmPatchRequestSchema.parse(request);
|
|
5775
|
+
const { cvmId } = CvmIdSchema.parse(parsed);
|
|
5776
|
+
const response = await client.patch(
|
|
5777
|
+
`/cvms/${cvmId}`,
|
|
5778
|
+
{},
|
|
5779
|
+
{
|
|
5780
|
+
headers: {
|
|
5781
|
+
"X-Compose-Hash": parsed.composeHash,
|
|
5782
|
+
"X-Transaction-Hash": parsed.transactionHash
|
|
5783
|
+
}
|
|
5784
|
+
}
|
|
5785
|
+
);
|
|
5786
|
+
return {
|
|
5787
|
+
correlationId: response.correlation_id
|
|
5788
|
+
};
|
|
5789
|
+
});
|
|
5790
|
+
|
|
5791
|
+
// src/actions/cvms/commit_cvm_update.ts
|
|
5792
|
+
var import_zod60 = require("zod");
|
|
5793
|
+
var CommitCvmUpdateRequestSchema = refineCvmId(
|
|
5794
|
+
CvmIdObjectSchema.extend({
|
|
5795
|
+
token: import_zod60.z.string().describe("One-time commit token from prepare-only flow"),
|
|
5796
|
+
composeHash: import_zod60.z.string().describe("Compose hash from Phase 1 response"),
|
|
5797
|
+
transactionHash: import_zod60.z.string().describe("Transaction hash proving on-chain registration")
|
|
5798
|
+
})
|
|
5799
|
+
);
|
|
5800
|
+
var CommitCvmUpdateResultSchema = import_zod60.z.object({
|
|
5801
|
+
correlationId: import_zod60.z.string(),
|
|
5802
|
+
status: import_zod60.z.string()
|
|
5803
|
+
});
|
|
5804
|
+
var { action: commitCvmUpdate, safeAction: safeCommitCvmUpdate } = defineAction(CommitCvmUpdateResultSchema, async (client, request) => {
|
|
5805
|
+
const parsed = CommitCvmUpdateRequestSchema.parse(request);
|
|
5806
|
+
const { cvmId } = CvmIdSchema.parse(parsed);
|
|
5807
|
+
const response = await client.post(`/cvms/${cvmId}/commit-update`, {
|
|
5808
|
+
token: parsed.token,
|
|
5809
|
+
compose_hash: parsed.composeHash,
|
|
5810
|
+
transaction_hash: parsed.transactionHash
|
|
5811
|
+
});
|
|
5812
|
+
return {
|
|
5813
|
+
correlationId: response.correlation_id,
|
|
5814
|
+
status: response.status
|
|
5815
|
+
};
|
|
5816
|
+
});
|
|
5817
|
+
|
|
5818
|
+
// src/actions/cvms/refresh_cvm_instance_id.ts
|
|
5819
|
+
var import_zod61 = require("zod");
|
|
5820
|
+
var InstanceIdRefreshResultSchema = import_zod61.z.object({
|
|
5821
|
+
cvm_id: import_zod61.z.number().int(),
|
|
5822
|
+
identifier: import_zod61.z.string(),
|
|
5823
|
+
status: import_zod61.z.enum(["updated", "unchanged", "skipped", "conflict", "error"]),
|
|
5824
|
+
old_instance_id: import_zod61.z.string().nullable().optional(),
|
|
5825
|
+
new_instance_id: import_zod61.z.string().nullable().optional(),
|
|
5826
|
+
source: import_zod61.z.enum(["teepod_state", "teepod_info", "gateway", "none"]),
|
|
5827
|
+
verified_with_gateway: import_zod61.z.boolean(),
|
|
5828
|
+
reason: import_zod61.z.string().nullable().optional()
|
|
5829
|
+
});
|
|
5830
|
+
var RefreshCvmInstanceIdRequestSchema = refineCvmId(
|
|
5831
|
+
CvmIdObjectSchema.extend({
|
|
5832
|
+
overwrite: import_zod61.z.boolean().optional(),
|
|
5833
|
+
dry_run: import_zod61.z.boolean().optional()
|
|
5834
|
+
})
|
|
5835
|
+
);
|
|
5836
|
+
var { action: refreshCvmInstanceId, safeAction: safeRefreshCvmInstanceId } = defineAction(InstanceIdRefreshResultSchema, async (client, request) => {
|
|
5837
|
+
const parsed = RefreshCvmInstanceIdRequestSchema.parse(request);
|
|
5838
|
+
const { cvmId } = CvmIdSchema.parse(parsed);
|
|
5839
|
+
const { overwrite, dry_run } = parsed;
|
|
5840
|
+
return await client.patch(`/cvms/${cvmId}/instance-id`, {
|
|
5841
|
+
overwrite,
|
|
5842
|
+
dry_run
|
|
5843
|
+
});
|
|
5844
|
+
});
|
|
5845
|
+
|
|
5846
|
+
// src/actions/cvms/refresh_cvm_instance_ids.ts
|
|
5847
|
+
var import_zod62 = require("zod");
|
|
5848
|
+
var RefreshCvmInstanceIdsRequestSchema = import_zod62.z.object({
|
|
5849
|
+
cvm_ids: import_zod62.z.array(import_zod62.z.string()).optional(),
|
|
5850
|
+
running_only: import_zod62.z.boolean().optional(),
|
|
5851
|
+
missing_only: import_zod62.z.boolean().optional(),
|
|
5852
|
+
overwrite: import_zod62.z.boolean().optional(),
|
|
5853
|
+
limit: import_zod62.z.number().int().min(1).max(500).optional(),
|
|
5854
|
+
dry_run: import_zod62.z.boolean().optional()
|
|
5855
|
+
}).strict();
|
|
5856
|
+
var RefreshCvmInstanceIdsResponseSchema = import_zod62.z.object({
|
|
5857
|
+
total: import_zod62.z.number().int(),
|
|
5858
|
+
scanned: import_zod62.z.number().int(),
|
|
5859
|
+
updated: import_zod62.z.number().int(),
|
|
5860
|
+
unchanged: import_zod62.z.number().int(),
|
|
5861
|
+
skipped: import_zod62.z.number().int(),
|
|
5862
|
+
conflicts: import_zod62.z.number().int(),
|
|
5863
|
+
errors: import_zod62.z.number().int(),
|
|
5864
|
+
items: import_zod62.z.array(InstanceIdRefreshResultSchema)
|
|
5865
|
+
});
|
|
5866
|
+
var { action: refreshCvmInstanceIds, safeAction: safeRefreshCvmInstanceIds } = defineAction(RefreshCvmInstanceIdsResponseSchema, async (client, request) => {
|
|
5867
|
+
const parsed = RefreshCvmInstanceIdsRequestSchema.parse(request);
|
|
5868
|
+
return await client.patch("/cvms/instance-ids", parsed);
|
|
5869
|
+
});
|
|
5870
|
+
|
|
4554
5871
|
// src/actions/cvms/get_cvm_status_batch.ts
|
|
4555
|
-
var
|
|
4556
|
-
var CvmStatusSchema =
|
|
4557
|
-
vm_uuid:
|
|
4558
|
-
status:
|
|
4559
|
-
uptime:
|
|
4560
|
-
in_progress:
|
|
4561
|
-
boot_progress:
|
|
4562
|
-
boot_error:
|
|
4563
|
-
operation_type:
|
|
4564
|
-
operation_started_at:
|
|
4565
|
-
correlation_id:
|
|
4566
|
-
});
|
|
4567
|
-
var GetCvmStatusBatchResponseSchema =
|
|
4568
|
-
var GetCvmStatusBatchRequestSchema =
|
|
4569
|
-
vmUuids:
|
|
5872
|
+
var import_zod63 = require("zod");
|
|
5873
|
+
var CvmStatusSchema = import_zod63.z.object({
|
|
5874
|
+
vm_uuid: import_zod63.z.string(),
|
|
5875
|
+
status: import_zod63.z.string(),
|
|
5876
|
+
uptime: import_zod63.z.string().nullable().optional(),
|
|
5877
|
+
in_progress: import_zod63.z.boolean(),
|
|
5878
|
+
boot_progress: import_zod63.z.string().nullable().optional(),
|
|
5879
|
+
boot_error: import_zod63.z.string().nullable().optional(),
|
|
5880
|
+
operation_type: import_zod63.z.string().nullable().optional(),
|
|
5881
|
+
operation_started_at: import_zod63.z.string().nullable().optional(),
|
|
5882
|
+
correlation_id: import_zod63.z.string().nullable().optional()
|
|
5883
|
+
});
|
|
5884
|
+
var GetCvmStatusBatchResponseSchema = import_zod63.z.record(import_zod63.z.string(), CvmStatusSchema);
|
|
5885
|
+
var GetCvmStatusBatchRequestSchema = import_zod63.z.object({
|
|
5886
|
+
vmUuids: import_zod63.z.array(import_zod63.z.string())
|
|
4570
5887
|
});
|
|
4571
5888
|
var { action: getCvmStatusBatch, safeAction: safeGetCvmStatusBatch } = defineAction(GetCvmStatusBatchResponseSchema, async (client, request) => {
|
|
4572
5889
|
const { vmUuids } = GetCvmStatusBatchRequestSchema.parse(request);
|
|
@@ -4574,11 +5891,11 @@ var { action: getCvmStatusBatch, safeAction: safeGetCvmStatusBatch } = defineAct
|
|
|
4574
5891
|
});
|
|
4575
5892
|
|
|
4576
5893
|
// src/actions/cvms/get_cvm_user_config.ts
|
|
4577
|
-
var
|
|
4578
|
-
var CvmUserConfigSchema =
|
|
4579
|
-
hostname:
|
|
4580
|
-
ssh_authorized_keys:
|
|
4581
|
-
default_gateway_domain:
|
|
5894
|
+
var import_zod64 = require("zod");
|
|
5895
|
+
var CvmUserConfigSchema = import_zod64.z.object({
|
|
5896
|
+
hostname: import_zod64.z.string().nullable().optional(),
|
|
5897
|
+
ssh_authorized_keys: import_zod64.z.array(import_zod64.z.string()).default([]),
|
|
5898
|
+
default_gateway_domain: import_zod64.z.string().nullable().optional()
|
|
4582
5899
|
});
|
|
4583
5900
|
var GetCvmUserConfigRequestSchema = CvmIdSchema;
|
|
4584
5901
|
var { action: getCvmUserConfig, safeAction: safeGetCvmUserConfig } = defineAction(CvmUserConfigSchema, async (client, request) => {
|
|
@@ -4586,20 +5903,78 @@ var { action: getCvmUserConfig, safeAction: safeGetCvmUserConfig } = defineActio
|
|
|
4586
5903
|
return await client.get(`/cvms/${cvmId}/user_config`);
|
|
4587
5904
|
});
|
|
4588
5905
|
|
|
5906
|
+
// src/actions/cvms/check_cvm_is_allowed.ts
|
|
5907
|
+
var import_zod65 = require("zod");
|
|
5908
|
+
var IsAllowedResultSchema = import_zod65.z.object({
|
|
5909
|
+
cvm_id: import_zod65.z.number().optional(),
|
|
5910
|
+
app_contract_address: import_zod65.z.string(),
|
|
5911
|
+
compose_hash: import_zod65.z.string(),
|
|
5912
|
+
device_id: import_zod65.z.string(),
|
|
5913
|
+
compose_hash_allowed: import_zod65.z.boolean(),
|
|
5914
|
+
allow_any_device: import_zod65.z.boolean(),
|
|
5915
|
+
device_id_allowed: import_zod65.z.boolean().nullable().optional(),
|
|
5916
|
+
is_allowed: import_zod65.z.boolean(),
|
|
5917
|
+
error: import_zod65.z.string().nullable().optional()
|
|
5918
|
+
});
|
|
5919
|
+
var CheckCvmIsAllowedInputSchema = import_zod65.z.object({
|
|
5920
|
+
cvmId: import_zod65.z.string().min(1),
|
|
5921
|
+
compose_hash: import_zod65.z.string().optional(),
|
|
5922
|
+
node_id: import_zod65.z.number().optional(),
|
|
5923
|
+
device_id: import_zod65.z.string().optional()
|
|
5924
|
+
});
|
|
5925
|
+
var CheckCvmIsAllowedRequestSchema = CheckCvmIsAllowedInputSchema;
|
|
5926
|
+
var { action: checkCvmIsAllowed, safeAction: safeCheckCvmIsAllowed } = defineAction(IsAllowedResultSchema, async (client, request) => {
|
|
5927
|
+
const { cvmId, ...body } = CheckCvmIsAllowedRequestSchema.parse(request);
|
|
5928
|
+
return await client.post(`/cvms/${cvmId}/is-allowed`, body);
|
|
5929
|
+
});
|
|
5930
|
+
|
|
5931
|
+
// src/actions/apps/check_app_is_allowed.ts
|
|
5932
|
+
var import_zod66 = require("zod");
|
|
5933
|
+
var CheckAppIsAllowedRequestSchema = import_zod66.z.object({
|
|
5934
|
+
appId: import_zod66.z.string().min(1),
|
|
5935
|
+
compose_hash: import_zod66.z.string(),
|
|
5936
|
+
node_id: import_zod66.z.number().optional(),
|
|
5937
|
+
device_id: import_zod66.z.string().optional(),
|
|
5938
|
+
chain_id: import_zod66.z.number().optional()
|
|
5939
|
+
});
|
|
5940
|
+
var { action: checkAppIsAllowed, safeAction: safeCheckAppIsAllowed } = defineAction(IsAllowedResultSchema, async (client, request) => {
|
|
5941
|
+
const { appId, ...body } = CheckAppIsAllowedRequestSchema.parse(request);
|
|
5942
|
+
return await client.post(`/apps/${appId}/is-allowed`, body);
|
|
5943
|
+
});
|
|
5944
|
+
|
|
5945
|
+
// src/actions/apps/check_app_cvms_is_allowed.ts
|
|
5946
|
+
var import_zod67 = require("zod");
|
|
5947
|
+
var AppCvmsBatchIsAllowedResponseSchema = import_zod67.z.object({
|
|
5948
|
+
is_onchain: import_zod67.z.boolean(),
|
|
5949
|
+
results: import_zod67.z.array(IsAllowedResultSchema.extend({ cvm_id: import_zod67.z.number() })).default([]),
|
|
5950
|
+
total: import_zod67.z.number().default(0),
|
|
5951
|
+
allowed_count: import_zod67.z.number().default(0),
|
|
5952
|
+
denied_count: import_zod67.z.number().default(0),
|
|
5953
|
+
error_count: import_zod67.z.number().default(0),
|
|
5954
|
+
skipped_cvm_ids: import_zod67.z.array(import_zod67.z.number()).default([])
|
|
5955
|
+
});
|
|
5956
|
+
var CheckAppCvmsIsAllowedRequestSchema = import_zod67.z.object({
|
|
5957
|
+
appId: import_zod67.z.string().min(1)
|
|
5958
|
+
});
|
|
5959
|
+
var { action: checkAppCvmsIsAllowed, safeAction: safeCheckAppCvmsIsAllowed } = defineAction(AppCvmsBatchIsAllowedResponseSchema, async (client, request) => {
|
|
5960
|
+
const { appId } = CheckAppCvmsIsAllowedRequestSchema.parse(request);
|
|
5961
|
+
return await client.post(`/apps/${appId}/cvms/is-allowed`, {});
|
|
5962
|
+
});
|
|
5963
|
+
|
|
4589
5964
|
// src/actions/apps/get_app_list.ts
|
|
4590
|
-
var
|
|
4591
|
-
var GetAppListRequestSchema =
|
|
4592
|
-
page:
|
|
4593
|
-
page_size:
|
|
4594
|
-
search:
|
|
4595
|
-
status:
|
|
4596
|
-
listed:
|
|
4597
|
-
base_image:
|
|
4598
|
-
instance_type:
|
|
4599
|
-
kms_slug:
|
|
4600
|
-
kms_type:
|
|
4601
|
-
node:
|
|
4602
|
-
region:
|
|
5965
|
+
var import_zod68 = require("zod");
|
|
5966
|
+
var GetAppListRequestSchema = import_zod68.z.object({
|
|
5967
|
+
page: import_zod68.z.number().int().min(1).optional(),
|
|
5968
|
+
page_size: import_zod68.z.number().int().min(1).max(100).optional(),
|
|
5969
|
+
search: import_zod68.z.string().optional(),
|
|
5970
|
+
status: import_zod68.z.array(import_zod68.z.string()).optional(),
|
|
5971
|
+
listed: import_zod68.z.boolean().optional(),
|
|
5972
|
+
base_image: import_zod68.z.string().optional(),
|
|
5973
|
+
instance_type: import_zod68.z.string().optional(),
|
|
5974
|
+
kms_slug: import_zod68.z.string().optional(),
|
|
5975
|
+
kms_type: import_zod68.z.string().optional(),
|
|
5976
|
+
node: import_zod68.z.string().optional(),
|
|
5977
|
+
region: import_zod68.z.string().optional()
|
|
4603
5978
|
}).strict();
|
|
4604
5979
|
function getSchemaForVersion4(version) {
|
|
4605
5980
|
return version === "2025-10-28" ? DstackAppListResponseV20251028Schema : DstackAppListResponseV20260121Schema;
|
|
@@ -4629,9 +6004,9 @@ async function safeGetAppList(client, request) {
|
|
|
4629
6004
|
}
|
|
4630
6005
|
|
|
4631
6006
|
// src/actions/apps/get_app_info.ts
|
|
4632
|
-
var
|
|
4633
|
-
var GetAppInfoRequestSchema =
|
|
4634
|
-
appId:
|
|
6007
|
+
var import_zod69 = require("zod");
|
|
6008
|
+
var GetAppInfoRequestSchema = import_zod69.z.object({
|
|
6009
|
+
appId: import_zod69.z.string().min(1)
|
|
4635
6010
|
}).strict();
|
|
4636
6011
|
function getSchemaForVersion5(version) {
|
|
4637
6012
|
return version === "2025-10-28" ? DstackAppWithCvmResponseV20251028Schema : DstackAppWithCvmResponseV20260121Schema;
|
|
@@ -4661,12 +6036,12 @@ async function safeGetAppInfo(client, request) {
|
|
|
4661
6036
|
}
|
|
4662
6037
|
|
|
4663
6038
|
// src/actions/apps/get_app_cvms.ts
|
|
4664
|
-
var
|
|
4665
|
-
var GetAppCvmsRequestSchema =
|
|
4666
|
-
appId:
|
|
6039
|
+
var import_zod70 = require("zod");
|
|
6040
|
+
var GetAppCvmsRequestSchema = import_zod70.z.object({
|
|
6041
|
+
appId: import_zod70.z.string().min(1)
|
|
4667
6042
|
}).strict();
|
|
4668
6043
|
function getSchemaForVersion6(version) {
|
|
4669
|
-
return version === "2025-10-28" ?
|
|
6044
|
+
return version === "2025-10-28" ? import_zod70.z.array(CvmInfoV20251028Schema) : import_zod70.z.array(CvmInfoV20260121Schema);
|
|
4670
6045
|
}
|
|
4671
6046
|
async function getAppCvms(client, request) {
|
|
4672
6047
|
const { appId } = GetAppCvmsRequestSchema.parse(request);
|
|
@@ -4692,12 +6067,54 @@ async function safeGetAppCvms(client, request) {
|
|
|
4692
6067
|
}
|
|
4693
6068
|
}
|
|
4694
6069
|
|
|
6070
|
+
// src/actions/apps/get_app_device_allowlist.ts
|
|
6071
|
+
var import_zod71 = require("zod");
|
|
6072
|
+
var DeviceAllowlistItemSchema = import_zod71.z.object({
|
|
6073
|
+
device_id: import_zod71.z.string(),
|
|
6074
|
+
node_name: import_zod71.z.string().nullable(),
|
|
6075
|
+
cvm_ids: import_zod71.z.array(import_zod71.z.number()),
|
|
6076
|
+
allowed_onchain: import_zod71.z.boolean(),
|
|
6077
|
+
status: import_zod71.z.string()
|
|
6078
|
+
});
|
|
6079
|
+
var DeviceAllowlistResponseSchema = import_zod71.z.object({
|
|
6080
|
+
is_onchain_kms: import_zod71.z.boolean(),
|
|
6081
|
+
allow_any_device: import_zod71.z.boolean().nullable().optional(),
|
|
6082
|
+
chain_id: import_zod71.z.number().nullable().optional(),
|
|
6083
|
+
app_contract_address: import_zod71.z.string().nullable().optional(),
|
|
6084
|
+
devices: import_zod71.z.array(DeviceAllowlistItemSchema).optional().default([])
|
|
6085
|
+
});
|
|
6086
|
+
var GetAppDeviceAllowlistRequestSchema = import_zod71.z.object({
|
|
6087
|
+
appId: import_zod71.z.string().min(1)
|
|
6088
|
+
}).strict();
|
|
6089
|
+
async function getAppDeviceAllowlist(client, request) {
|
|
6090
|
+
const { appId } = GetAppDeviceAllowlistRequestSchema.parse(request);
|
|
6091
|
+
const response = await client.get(`/apps/${appId}/device-allowlist`);
|
|
6092
|
+
return DeviceAllowlistResponseSchema.parse(response);
|
|
6093
|
+
}
|
|
6094
|
+
async function safeGetAppDeviceAllowlist(client, request) {
|
|
6095
|
+
try {
|
|
6096
|
+
const data = await getAppDeviceAllowlist(client, request);
|
|
6097
|
+
return { success: true, data };
|
|
6098
|
+
} catch (error) {
|
|
6099
|
+
if (error && typeof error === "object" && ("status" in error || "issues" in error)) {
|
|
6100
|
+
return { success: false, error };
|
|
6101
|
+
}
|
|
6102
|
+
return {
|
|
6103
|
+
success: false,
|
|
6104
|
+
error: {
|
|
6105
|
+
name: "Error",
|
|
6106
|
+
message: error instanceof Error ? error.message : String(error)
|
|
6107
|
+
}
|
|
6108
|
+
};
|
|
6109
|
+
}
|
|
6110
|
+
}
|
|
6111
|
+
|
|
4695
6112
|
// src/actions/apps/get_app_revisions.ts
|
|
4696
|
-
var
|
|
4697
|
-
var GetAppRevisionsRequestSchema =
|
|
4698
|
-
appId:
|
|
4699
|
-
page:
|
|
4700
|
-
page_size:
|
|
6113
|
+
var import_zod72 = require("zod");
|
|
6114
|
+
var GetAppRevisionsRequestSchema = import_zod72.z.object({
|
|
6115
|
+
appId: import_zod72.z.string().min(1),
|
|
6116
|
+
page: import_zod72.z.number().int().min(1).optional(),
|
|
6117
|
+
page_size: import_zod72.z.number().int().min(1).max(1e3).optional()
|
|
4701
6118
|
}).strict();
|
|
4702
6119
|
async function getAppRevisions(client, request) {
|
|
4703
6120
|
const { appId, ...params } = GetAppRevisionsRequestSchema.parse(request);
|
|
@@ -4723,11 +6140,11 @@ async function safeGetAppRevisions(client, request) {
|
|
|
4723
6140
|
}
|
|
4724
6141
|
|
|
4725
6142
|
// src/actions/apps/get_app_revision_detail.ts
|
|
4726
|
-
var
|
|
4727
|
-
var GetAppRevisionDetailRequestSchema =
|
|
4728
|
-
appId:
|
|
4729
|
-
revisionId:
|
|
4730
|
-
rawComposeFile:
|
|
6143
|
+
var import_zod73 = require("zod");
|
|
6144
|
+
var GetAppRevisionDetailRequestSchema = import_zod73.z.object({
|
|
6145
|
+
appId: import_zod73.z.string().min(1),
|
|
6146
|
+
revisionId: import_zod73.z.string().min(1),
|
|
6147
|
+
rawComposeFile: import_zod73.z.boolean().optional()
|
|
4731
6148
|
}).strict();
|
|
4732
6149
|
async function getAppRevisionDetail(client, request) {
|
|
4733
6150
|
const { appId, revisionId, rawComposeFile } = GetAppRevisionDetailRequestSchema.parse(request);
|
|
@@ -4754,15 +6171,15 @@ async function safeGetAppRevisionDetail(client, request) {
|
|
|
4754
6171
|
}
|
|
4755
6172
|
|
|
4756
6173
|
// src/actions/apps/get_app_filter_options.ts
|
|
4757
|
-
var
|
|
4758
|
-
var AppFilterOptionsSchema =
|
|
4759
|
-
statuses:
|
|
4760
|
-
image_versions:
|
|
4761
|
-
instance_types:
|
|
4762
|
-
kms_slugs:
|
|
4763
|
-
kms_types:
|
|
4764
|
-
regions:
|
|
4765
|
-
nodes:
|
|
6174
|
+
var import_zod74 = require("zod");
|
|
6175
|
+
var AppFilterOptionsSchema = import_zod74.z.object({
|
|
6176
|
+
statuses: import_zod74.z.array(import_zod74.z.string()),
|
|
6177
|
+
image_versions: import_zod74.z.array(import_zod74.z.string()),
|
|
6178
|
+
instance_types: import_zod74.z.array(import_zod74.z.string()),
|
|
6179
|
+
kms_slugs: import_zod74.z.array(import_zod74.z.string()),
|
|
6180
|
+
kms_types: import_zod74.z.array(import_zod74.z.string()),
|
|
6181
|
+
regions: import_zod74.z.array(import_zod74.z.string()),
|
|
6182
|
+
nodes: import_zod74.z.array(import_zod74.z.string())
|
|
4766
6183
|
});
|
|
4767
6184
|
async function getAppFilterOptions(client) {
|
|
4768
6185
|
const response = await client.get("/apps/filter-options");
|
|
@@ -4786,6 +6203,54 @@ async function safeGetAppFilterOptions(client) {
|
|
|
4786
6203
|
}
|
|
4787
6204
|
}
|
|
4788
6205
|
|
|
6206
|
+
// src/actions/apps/get_app_attestation.ts
|
|
6207
|
+
var import_zod75 = require("zod");
|
|
6208
|
+
var KmsInfoSchema2 = import_zod75.z.object({
|
|
6209
|
+
contract_address: import_zod75.z.string(),
|
|
6210
|
+
chain_id: import_zod75.z.string().nullable(),
|
|
6211
|
+
version: import_zod75.z.string(),
|
|
6212
|
+
url: import_zod75.z.string(),
|
|
6213
|
+
gateway_app_id: import_zod75.z.string().nullable(),
|
|
6214
|
+
gateway_app_url: import_zod75.z.string(),
|
|
6215
|
+
kms_type: import_zod75.z.string()
|
|
6216
|
+
});
|
|
6217
|
+
var GuestAgentInfoSchema = import_zod75.z.object({
|
|
6218
|
+
app_id: import_zod75.z.string().optional(),
|
|
6219
|
+
instance_id: import_zod75.z.string().optional(),
|
|
6220
|
+
app_name: import_zod75.z.string().optional(),
|
|
6221
|
+
device_id: import_zod75.z.string().optional()
|
|
6222
|
+
}).passthrough().nullable();
|
|
6223
|
+
var AppAttestationInstanceSchema = import_zod75.z.object({
|
|
6224
|
+
vm_uuid: import_zod75.z.string().nullable().optional(),
|
|
6225
|
+
name: import_zod75.z.string().optional(),
|
|
6226
|
+
instance_id: import_zod75.z.string().nullable().optional(),
|
|
6227
|
+
status: import_zod75.z.string().optional(),
|
|
6228
|
+
image_version: import_zod75.z.string().nullable().optional(),
|
|
6229
|
+
quote: import_zod75.z.string().nullable().optional(),
|
|
6230
|
+
ppid: import_zod75.z.string().optional(),
|
|
6231
|
+
device_id: import_zod75.z.string().optional(),
|
|
6232
|
+
tcb_info: TcbInfoSchema.nullable().optional(),
|
|
6233
|
+
app_certificates: import_zod75.z.array(CertificateSchema).nullable().optional(),
|
|
6234
|
+
compose_file: import_zod75.z.string().nullable().optional(),
|
|
6235
|
+
error: import_zod75.z.string().nullable().optional()
|
|
6236
|
+
});
|
|
6237
|
+
var AppAttestationResponseSchema = import_zod75.z.object({
|
|
6238
|
+
app_id: import_zod75.z.string(),
|
|
6239
|
+
contract_address: import_zod75.z.string(),
|
|
6240
|
+
kms_info: KmsInfoSchema2,
|
|
6241
|
+
instances: import_zod75.z.array(AppAttestationInstanceSchema),
|
|
6242
|
+
kms_guest_agent_info: GuestAgentInfoSchema,
|
|
6243
|
+
gateway_guest_agent_info: GuestAgentInfoSchema,
|
|
6244
|
+
qemu_version: import_zod75.z.string().nullable()
|
|
6245
|
+
});
|
|
6246
|
+
var GetAppAttestationRequestSchema = import_zod75.z.object({
|
|
6247
|
+
appId: import_zod75.z.string().min(1)
|
|
6248
|
+
}).strict();
|
|
6249
|
+
var { action: getAppAttestation, safeAction: safeGetAppAttestation } = defineAction(AppAttestationResponseSchema, async (client, request) => {
|
|
6250
|
+
const { appId } = GetAppAttestationRequestSchema.parse(request);
|
|
6251
|
+
return await client.get(`/apps/${appId}/attestations`);
|
|
6252
|
+
});
|
|
6253
|
+
|
|
4789
6254
|
// src/parse_dotenv.ts
|
|
4790
6255
|
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
4791
6256
|
function parseEnv(input) {
|
|
@@ -4824,8 +6289,12 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
4824
6289
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4825
6290
|
0 && (module.exports = {
|
|
4826
6291
|
AddComposeHashSchema,
|
|
6292
|
+
AddDeviceSchema,
|
|
4827
6293
|
AllFamiliesResponseSchema,
|
|
4828
6294
|
ApiErrorSchema,
|
|
6295
|
+
AppAttestationInstanceSchema,
|
|
6296
|
+
AppAttestationResponseSchema,
|
|
6297
|
+
AppCvmsBatchIsAllowedResponseSchema,
|
|
4829
6298
|
AppFilterOptionsSchema,
|
|
4830
6299
|
AppProfileSchema,
|
|
4831
6300
|
AppRevisionDetailResponseSchema,
|
|
@@ -4836,10 +6305,18 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
4836
6305
|
AvailableNodesSchema,
|
|
4837
6306
|
BillingPeriodSchema,
|
|
4838
6307
|
BusinessError,
|
|
6308
|
+
CertificateIssuerSchema,
|
|
6309
|
+
CertificateSchema,
|
|
6310
|
+
CertificateSubjectSchema,
|
|
6311
|
+
CheckAppCvmsIsAllowedRequestSchema,
|
|
6312
|
+
CheckAppIsAllowedRequestSchema,
|
|
6313
|
+
CheckCvmIsAllowedRequestSchema,
|
|
4839
6314
|
CommitCvmComposeFileUpdateRequestSchema,
|
|
4840
6315
|
CommitCvmComposeFileUpdateSchema,
|
|
4841
6316
|
CommitCvmProvisionRequestSchema,
|
|
4842
6317
|
CommitCvmProvisionSchema,
|
|
6318
|
+
CommitCvmUpdateRequestSchema,
|
|
6319
|
+
ConfirmCvmPatchRequestSchema,
|
|
4843
6320
|
CreateSshKeyRequestSchema,
|
|
4844
6321
|
CreditsInfoSchema,
|
|
4845
6322
|
CurrentUserSchema,
|
|
@@ -4881,9 +6358,14 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
4881
6358
|
DstackAppMinimalResponseV20260121Schema,
|
|
4882
6359
|
DstackAppWithCvmResponseV20251028Schema,
|
|
4883
6360
|
DstackAppWithCvmResponseV20260121Schema,
|
|
6361
|
+
ErrorCodes,
|
|
6362
|
+
EventLogSchema,
|
|
4884
6363
|
FamilyGroupSchema,
|
|
4885
6364
|
FamilyInstanceTypesResponseSchema,
|
|
6365
|
+
GetAllowedDevicesSchema,
|
|
6366
|
+
GetAppAttestationRequestSchema,
|
|
4886
6367
|
GetAppCvmsRequestSchema,
|
|
6368
|
+
GetAppDeviceAllowlistRequestSchema,
|
|
4887
6369
|
GetAppEnvEncryptPubKeyRequestSchema,
|
|
4888
6370
|
GetAppEnvEncryptPubKeySchema,
|
|
4889
6371
|
GetAppInfoRequestSchema,
|
|
@@ -4908,11 +6390,17 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
4908
6390
|
GetKmsInfoRequestSchema,
|
|
4909
6391
|
GetKmsListRequestSchema,
|
|
4910
6392
|
GetKmsListSchema,
|
|
6393
|
+
GetKmsOnChainDetailRequestSchema,
|
|
6394
|
+
GetKmsOnChainDetailResponseSchema,
|
|
6395
|
+
GetOsImagesRequestSchema,
|
|
6396
|
+
GetOsImagesResponseSchema,
|
|
4911
6397
|
GetWorkspaceNodesSchema,
|
|
4912
6398
|
GetWorkspaceQuotasSchema,
|
|
4913
6399
|
ImportGithubProfileRequestSchema,
|
|
4914
6400
|
ImportGithubProfileResponseSchema,
|
|
6401
|
+
InstanceIdRefreshResultSchema,
|
|
4915
6402
|
InstanceTypeSchema,
|
|
6403
|
+
IsAllowedResultSchema,
|
|
4916
6404
|
KmsInfoSchema,
|
|
4917
6405
|
KmsTypeSchema,
|
|
4918
6406
|
ListFamilyInstanceTypesRequestSchema,
|
|
@@ -4928,27 +6416,40 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
4928
6416
|
NextAppIdsSchema,
|
|
4929
6417
|
NodeInfoSchema,
|
|
4930
6418
|
NodeRefSchema,
|
|
6419
|
+
OSImagePublicSchema,
|
|
4931
6420
|
OSImageVariantSchema,
|
|
6421
|
+
OnChainDeviceSchema,
|
|
6422
|
+
OnChainKmsContractSchema,
|
|
6423
|
+
OnChainOsImageSchema,
|
|
4932
6424
|
PaginatedCvmInfosV20251028Schema,
|
|
4933
6425
|
PaginatedCvmInfosV20260121Schema,
|
|
4934
6426
|
PaginationMetadataSchema,
|
|
6427
|
+
PatchCvmRequestSchema,
|
|
6428
|
+
PatchCvmResultSchema,
|
|
4935
6429
|
PhalaCloudError,
|
|
4936
6430
|
ProvisionCvmComposeFileUpdateRequestSchema,
|
|
4937
6431
|
ProvisionCvmComposeFileUpdateResultSchema,
|
|
4938
6432
|
ProvisionCvmRequestSchema,
|
|
4939
6433
|
ProvisionCvmSchema,
|
|
4940
6434
|
QuotaMetricSchema,
|
|
6435
|
+
RefreshCvmInstanceIdRequestSchema,
|
|
6436
|
+
RefreshCvmInstanceIdsRequestSchema,
|
|
6437
|
+
RefreshCvmInstanceIdsResponseSchema,
|
|
6438
|
+
RemoveDeviceSchema,
|
|
6439
|
+
ReplicateCvmRequestSchema,
|
|
4941
6440
|
RequestError,
|
|
4942
6441
|
ResourceError,
|
|
4943
6442
|
RestartCvmRequestSchema,
|
|
4944
6443
|
SUPPORTED_API_VERSIONS,
|
|
4945
6444
|
SUPPORTED_CHAINS,
|
|
4946
6445
|
ServerError,
|
|
6446
|
+
SetAllowAnyDeviceSchema,
|
|
4947
6447
|
ShutdownCvmRequestSchema,
|
|
4948
6448
|
SshKeySchema,
|
|
4949
6449
|
StartCvmRequestSchema,
|
|
4950
6450
|
StopCvmRequestSchema,
|
|
4951
6451
|
SyncGithubSshKeysResponseSchema,
|
|
6452
|
+
TcbInfoSchema,
|
|
4952
6453
|
TransactionError,
|
|
4953
6454
|
UnknownError,
|
|
4954
6455
|
UpdateCvmEnvsRequestSchema,
|
|
@@ -4974,13 +6475,22 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
4974
6475
|
WorkspaceReservedGpuQuotaSchema,
|
|
4975
6476
|
WorkspaceResponseSchema,
|
|
4976
6477
|
addComposeHash,
|
|
6478
|
+
addDevice,
|
|
4977
6479
|
addNetwork,
|
|
4978
6480
|
asHex,
|
|
4979
6481
|
autoCreateClients,
|
|
6482
|
+
checkAppCvmsIsAllowed,
|
|
6483
|
+
checkAppIsAllowed,
|
|
4980
6484
|
checkBalance,
|
|
6485
|
+
checkComposeHashAllowed,
|
|
6486
|
+
checkCvmIsAllowed,
|
|
6487
|
+
checkDeviceAllowed,
|
|
4981
6488
|
checkNetworkStatus,
|
|
6489
|
+
checkOnChainPrerequisites,
|
|
4982
6490
|
commitCvmComposeFileUpdate,
|
|
4983
6491
|
commitCvmProvision,
|
|
6492
|
+
commitCvmUpdate,
|
|
6493
|
+
confirmCvmPatch,
|
|
4984
6494
|
convertToHostname,
|
|
4985
6495
|
createBaseClient,
|
|
4986
6496
|
createClient,
|
|
@@ -4994,6 +6504,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
4994
6504
|
deleteCvm,
|
|
4995
6505
|
deleteSshKey,
|
|
4996
6506
|
deployAppAuth,
|
|
6507
|
+
dstackAppAbi,
|
|
4997
6508
|
dumpAppCompose,
|
|
4998
6509
|
encryptEnvVars,
|
|
4999
6510
|
estimateTransactionGas,
|
|
@@ -5006,7 +6517,10 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5006
6517
|
formatValidationErrors,
|
|
5007
6518
|
generateDefaultCvmName,
|
|
5008
6519
|
generateFallbackHostname,
|
|
6520
|
+
getAllowedDevices,
|
|
6521
|
+
getAppAttestation,
|
|
5009
6522
|
getAppCvms,
|
|
6523
|
+
getAppDeviceAllowlist,
|
|
5010
6524
|
getAppEnvEncryptPubKey,
|
|
5011
6525
|
getAppFilterOptions,
|
|
5012
6526
|
getAppInfo,
|
|
@@ -5032,11 +6546,15 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5032
6546
|
getErrorMessage,
|
|
5033
6547
|
getKmsInfo,
|
|
5034
6548
|
getKmsList,
|
|
6549
|
+
getKmsOnChainDetail,
|
|
6550
|
+
getOsImages,
|
|
5035
6551
|
getValidationFields,
|
|
5036
6552
|
getWorkspace,
|
|
5037
6553
|
getWorkspaceNodes,
|
|
5038
6554
|
getWorkspaceQuotas,
|
|
5039
6555
|
importGithubProfileSshKeys,
|
|
6556
|
+
isAppIdConflictError,
|
|
6557
|
+
isConflictError,
|
|
5040
6558
|
isValidHostname,
|
|
5041
6559
|
listAllInstanceTypeFamilies,
|
|
5042
6560
|
listFamilyInstanceTypes,
|
|
@@ -5046,19 +6564,36 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5046
6564
|
parseApiError,
|
|
5047
6565
|
parseEnv,
|
|
5048
6566
|
parseEnvVars,
|
|
6567
|
+
patchCvm,
|
|
5049
6568
|
preprocessAppCompose,
|
|
5050
6569
|
provisionCvm,
|
|
5051
6570
|
provisionCvmComposeFileUpdate,
|
|
5052
6571
|
refineCvmId,
|
|
6572
|
+
refreshCvmInstanceId,
|
|
6573
|
+
refreshCvmInstanceIds,
|
|
6574
|
+
removeDevice,
|
|
6575
|
+
replicateCvm,
|
|
5053
6576
|
restartCvm,
|
|
5054
6577
|
safeAddComposeHash,
|
|
6578
|
+
safeAddDevice,
|
|
6579
|
+
safeCheckAppCvmsIsAllowed,
|
|
6580
|
+
safeCheckAppIsAllowed,
|
|
6581
|
+
safeCheckComposeHashAllowed,
|
|
6582
|
+
safeCheckCvmIsAllowed,
|
|
6583
|
+
safeCheckDeviceAllowed,
|
|
6584
|
+
safeCheckOnChainPrerequisites,
|
|
5055
6585
|
safeCommitCvmComposeFileUpdate,
|
|
5056
6586
|
safeCommitCvmProvision,
|
|
6587
|
+
safeCommitCvmUpdate,
|
|
6588
|
+
safeConfirmCvmPatch,
|
|
5057
6589
|
safeCreateSshKey,
|
|
5058
6590
|
safeDeleteCvm,
|
|
5059
6591
|
safeDeleteSshKey,
|
|
5060
6592
|
safeDeployAppAuth,
|
|
6593
|
+
safeGetAllowedDevices,
|
|
6594
|
+
safeGetAppAttestation,
|
|
5061
6595
|
safeGetAppCvms,
|
|
6596
|
+
safeGetAppDeviceAllowlist,
|
|
5062
6597
|
safeGetAppEnvEncryptPubKey,
|
|
5063
6598
|
safeGetAppFilterOptions,
|
|
5064
6599
|
safeGetAppInfo,
|
|
@@ -5082,6 +6617,8 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5082
6617
|
safeGetCvmUserConfig,
|
|
5083
6618
|
safeGetKmsInfo,
|
|
5084
6619
|
safeGetKmsList,
|
|
6620
|
+
safeGetKmsOnChainDetail,
|
|
6621
|
+
safeGetOsImages,
|
|
5085
6622
|
safeGetWorkspace,
|
|
5086
6623
|
safeGetWorkspaceNodes,
|
|
5087
6624
|
safeGetWorkspaceQuotas,
|
|
@@ -5091,9 +6628,15 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5091
6628
|
safeListSshKeys,
|
|
5092
6629
|
safeListWorkspaces,
|
|
5093
6630
|
safeNextAppIds,
|
|
6631
|
+
safePatchCvm,
|
|
5094
6632
|
safeProvisionCvm,
|
|
5095
6633
|
safeProvisionCvmComposeFileUpdate,
|
|
6634
|
+
safeRefreshCvmInstanceId,
|
|
6635
|
+
safeRefreshCvmInstanceIds,
|
|
6636
|
+
safeRemoveDevice,
|
|
6637
|
+
safeReplicateCvm,
|
|
5096
6638
|
safeRestartCvm,
|
|
6639
|
+
safeSetAllowAnyDevice,
|
|
5097
6640
|
safeShutdownCvm,
|
|
5098
6641
|
safeStartCvm,
|
|
5099
6642
|
safeStopCvm,
|
|
@@ -5105,6 +6648,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5105
6648
|
safeUpdateOsImage,
|
|
5106
6649
|
safeUpdatePreLaunchScript,
|
|
5107
6650
|
safeValidateActionParameters,
|
|
6651
|
+
setAllowAnyDevice,
|
|
5108
6652
|
shutdownCvm,
|
|
5109
6653
|
sortObject,
|
|
5110
6654
|
startCvm,
|