@phala/cloud 0.2.5 → 0.2.9
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/create_app_instance.d.ts +196 -0
- package/dist/actions/apps/get_app_device_allowlist.d.ts +2 -2
- package/dist/actions/blockchains/abi/dstack_app.d.ts +30 -0
- package/dist/actions/blockchains/check_compose_hash_allowed.d.ts +43 -0
- package/dist/actions/blockchains/check_on_chain_prerequisites.d.ts +59 -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/patch_cvm.d.ts +447 -0
- package/dist/actions/cvms/provision_cvm_compose_file_update.d.ts +8 -0
- package/dist/actions/index.d.ts +9 -0
- package/dist/client.d.ts +5 -0
- package/dist/index.js +741 -191
- package/dist/index.mjs +710 -191
- package/dist/types/app_info_v20260121.d.ts +90 -6
- package/dist/types/cvm_info_v20260121.d.ts +60 -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
|
@@ -36,6 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
ApiErrorSchema: () => ApiErrorSchema,
|
|
37
37
|
AppAttestationInstanceSchema: () => AppAttestationInstanceSchema,
|
|
38
38
|
AppAttestationResponseSchema: () => AppAttestationResponseSchema,
|
|
39
|
+
AppCvmsBatchIsAllowedResponseSchema: () => AppCvmsBatchIsAllowedResponseSchema,
|
|
39
40
|
AppFilterOptionsSchema: () => AppFilterOptionsSchema,
|
|
40
41
|
AppProfileSchema: () => AppProfileSchema,
|
|
41
42
|
AppRevisionDetailResponseSchema: () => AppRevisionDetailResponseSchema,
|
|
@@ -49,10 +50,16 @@ __export(index_exports, {
|
|
|
49
50
|
CertificateIssuerSchema: () => CertificateIssuerSchema,
|
|
50
51
|
CertificateSchema: () => CertificateSchema,
|
|
51
52
|
CertificateSubjectSchema: () => CertificateSubjectSchema,
|
|
53
|
+
CheckAppCvmsIsAllowedRequestSchema: () => CheckAppCvmsIsAllowedRequestSchema,
|
|
54
|
+
CheckAppIsAllowedRequestSchema: () => CheckAppIsAllowedRequestSchema,
|
|
55
|
+
CheckCvmIsAllowedRequestSchema: () => CheckCvmIsAllowedRequestSchema,
|
|
52
56
|
CommitCvmComposeFileUpdateRequestSchema: () => CommitCvmComposeFileUpdateRequestSchema,
|
|
53
57
|
CommitCvmComposeFileUpdateSchema: () => CommitCvmComposeFileUpdateSchema,
|
|
54
58
|
CommitCvmProvisionRequestSchema: () => CommitCvmProvisionRequestSchema,
|
|
55
59
|
CommitCvmProvisionSchema: () => CommitCvmProvisionSchema,
|
|
60
|
+
CommitCvmUpdateRequestSchema: () => CommitCvmUpdateRequestSchema,
|
|
61
|
+
ConfirmCvmPatchRequestSchema: () => ConfirmCvmPatchRequestSchema,
|
|
62
|
+
CreateAppInstanceRequestSchema: () => CreateAppInstanceRequestSchema,
|
|
56
63
|
CreateSshKeyRequestSchema: () => CreateSshKeyRequestSchema,
|
|
57
64
|
CreditsInfoSchema: () => CreditsInfoSchema,
|
|
58
65
|
CurrentUserSchema: () => CurrentUserV20251028Schema,
|
|
@@ -94,6 +101,7 @@ __export(index_exports, {
|
|
|
94
101
|
DstackAppMinimalResponseV20260121Schema: () => DstackAppMinimalResponseV20260121Schema,
|
|
95
102
|
DstackAppWithCvmResponseV20251028Schema: () => DstackAppWithCvmResponseV20251028Schema,
|
|
96
103
|
DstackAppWithCvmResponseV20260121Schema: () => DstackAppWithCvmResponseV20260121Schema,
|
|
104
|
+
ErrorCodes: () => ErrorCodes,
|
|
97
105
|
EventLogSchema: () => EventLogSchema,
|
|
98
106
|
FamilyGroupSchema: () => FamilyGroupSchema,
|
|
99
107
|
FamilyInstanceTypesResponseSchema: () => FamilyInstanceTypesResponseSchema,
|
|
@@ -135,6 +143,7 @@ __export(index_exports, {
|
|
|
135
143
|
ImportGithubProfileResponseSchema: () => ImportGithubProfileResponseSchema,
|
|
136
144
|
InstanceIdRefreshResultSchema: () => InstanceIdRefreshResultSchema,
|
|
137
145
|
InstanceTypeSchema: () => InstanceTypeSchema,
|
|
146
|
+
IsAllowedResultSchema: () => IsAllowedResultSchema,
|
|
138
147
|
KmsInfoSchema: () => KmsInfoSchema,
|
|
139
148
|
KmsTypeSchema: () => KmsTypeSchema,
|
|
140
149
|
ListFamilyInstanceTypesRequestSchema: () => ListFamilyInstanceTypesRequestSchema,
|
|
@@ -158,6 +167,8 @@ __export(index_exports, {
|
|
|
158
167
|
PaginatedCvmInfosV20251028Schema: () => PaginatedCvmInfosV20251028Schema,
|
|
159
168
|
PaginatedCvmInfosV20260121Schema: () => PaginatedCvmInfosV20260121Schema,
|
|
160
169
|
PaginationMetadataSchema: () => PaginationMetadataSchema,
|
|
170
|
+
PatchCvmRequestSchema: () => PatchCvmRequestSchema,
|
|
171
|
+
PatchCvmResultSchema: () => PatchCvmResultSchema,
|
|
161
172
|
PhalaCloudError: () => PhalaCloudError,
|
|
162
173
|
ProvisionCvmComposeFileUpdateRequestSchema: () => ProvisionCvmComposeFileUpdateRequestSchema,
|
|
163
174
|
ProvisionCvmComposeFileUpdateResultSchema: () => ProvisionCvmComposeFileUpdateResultSchema,
|
|
@@ -211,12 +222,20 @@ __export(index_exports, {
|
|
|
211
222
|
addNetwork: () => addNetwork,
|
|
212
223
|
asHex: () => asHex,
|
|
213
224
|
autoCreateClients: () => autoCreateClients,
|
|
225
|
+
checkAppCvmsIsAllowed: () => checkAppCvmsIsAllowed,
|
|
226
|
+
checkAppIsAllowed: () => checkAppIsAllowed,
|
|
214
227
|
checkBalance: () => checkBalance,
|
|
228
|
+
checkComposeHashAllowed: () => checkComposeHashAllowed,
|
|
229
|
+
checkCvmIsAllowed: () => checkCvmIsAllowed,
|
|
215
230
|
checkDeviceAllowed: () => checkDeviceAllowed,
|
|
216
231
|
checkNetworkStatus: () => checkNetworkStatus,
|
|
232
|
+
checkOnChainPrerequisites: () => checkOnChainPrerequisites,
|
|
217
233
|
commitCvmComposeFileUpdate: () => commitCvmComposeFileUpdate,
|
|
218
234
|
commitCvmProvision: () => commitCvmProvision,
|
|
235
|
+
commitCvmUpdate: () => commitCvmUpdate,
|
|
236
|
+
confirmCvmPatch: () => confirmCvmPatch,
|
|
219
237
|
convertToHostname: () => convertToHostname,
|
|
238
|
+
createAppInstance: () => createAppInstance,
|
|
220
239
|
createBaseClient: () => createClient,
|
|
221
240
|
createClient: () => createClient2,
|
|
222
241
|
createClientsFromBrowser: () => createClientsFromBrowser,
|
|
@@ -278,6 +297,8 @@ __export(index_exports, {
|
|
|
278
297
|
getWorkspaceNodes: () => getWorkspaceNodes,
|
|
279
298
|
getWorkspaceQuotas: () => getWorkspaceQuotas,
|
|
280
299
|
importGithubProfileSshKeys: () => importGithubProfileSshKeys,
|
|
300
|
+
isAppIdConflictError: () => isAppIdConflictError,
|
|
301
|
+
isConflictError: () => isConflictError,
|
|
281
302
|
isValidHostname: () => isValidHostname,
|
|
282
303
|
listAllInstanceTypeFamilies: () => listAllInstanceTypeFamilies,
|
|
283
304
|
listFamilyInstanceTypes: () => listFamilyInstanceTypes,
|
|
@@ -287,6 +308,7 @@ __export(index_exports, {
|
|
|
287
308
|
parseApiError: () => parseApiError,
|
|
288
309
|
parseEnv: () => parseEnv,
|
|
289
310
|
parseEnvVars: () => parseEnvVars,
|
|
311
|
+
patchCvm: () => patchCvm,
|
|
290
312
|
preprocessAppCompose: () => preprocessAppCompose,
|
|
291
313
|
provisionCvm: () => provisionCvm,
|
|
292
314
|
provisionCvmComposeFileUpdate: () => provisionCvmComposeFileUpdate,
|
|
@@ -298,9 +320,17 @@ __export(index_exports, {
|
|
|
298
320
|
restartCvm: () => restartCvm,
|
|
299
321
|
safeAddComposeHash: () => safeAddComposeHash,
|
|
300
322
|
safeAddDevice: () => safeAddDevice,
|
|
323
|
+
safeCheckAppCvmsIsAllowed: () => safeCheckAppCvmsIsAllowed,
|
|
324
|
+
safeCheckAppIsAllowed: () => safeCheckAppIsAllowed,
|
|
325
|
+
safeCheckComposeHashAllowed: () => safeCheckComposeHashAllowed,
|
|
326
|
+
safeCheckCvmIsAllowed: () => safeCheckCvmIsAllowed,
|
|
301
327
|
safeCheckDeviceAllowed: () => safeCheckDeviceAllowed,
|
|
328
|
+
safeCheckOnChainPrerequisites: () => safeCheckOnChainPrerequisites,
|
|
302
329
|
safeCommitCvmComposeFileUpdate: () => safeCommitCvmComposeFileUpdate,
|
|
303
330
|
safeCommitCvmProvision: () => safeCommitCvmProvision,
|
|
331
|
+
safeCommitCvmUpdate: () => safeCommitCvmUpdate,
|
|
332
|
+
safeConfirmCvmPatch: () => safeConfirmCvmPatch,
|
|
333
|
+
safeCreateAppInstance: () => safeCreateAppInstance,
|
|
304
334
|
safeCreateSshKey: () => safeCreateSshKey,
|
|
305
335
|
safeDeleteCvm: () => safeDeleteCvm,
|
|
306
336
|
safeDeleteSshKey: () => safeDeleteSshKey,
|
|
@@ -343,6 +373,7 @@ __export(index_exports, {
|
|
|
343
373
|
safeListSshKeys: () => safeListSshKeys,
|
|
344
374
|
safeListWorkspaces: () => safeListWorkspaces,
|
|
345
375
|
safeNextAppIds: () => safeNextAppIds,
|
|
376
|
+
safePatchCvm: () => safePatchCvm,
|
|
346
377
|
safeProvisionCvm: () => safeProvisionCvm,
|
|
347
378
|
safeProvisionCvmComposeFileUpdate: () => safeProvisionCvmComposeFileUpdate,
|
|
348
379
|
safeRefreshCvmInstanceId: () => safeRefreshCvmInstanceId,
|
|
@@ -443,13 +474,14 @@ var RequestError = class _RequestError extends PhalaCloudError {
|
|
|
443
474
|
static fromFetchError(error) {
|
|
444
475
|
const parseResult = ApiErrorSchema.safeParse(error.data);
|
|
445
476
|
if (parseResult.success) {
|
|
477
|
+
const detail = parseResult.data.detail ?? (error.data && typeof error.data === "object" && "error_code" in error.data ? error.data : void 0);
|
|
446
478
|
return new _RequestError(error.message, {
|
|
447
479
|
status: error.status ?? void 0,
|
|
448
480
|
statusText: error.statusText ?? void 0,
|
|
449
481
|
data: error.data,
|
|
450
482
|
request: error.request ?? void 0,
|
|
451
483
|
response: error.response ?? void 0,
|
|
452
|
-
detail
|
|
484
|
+
detail,
|
|
453
485
|
code: parseResult.data.code ?? void 0,
|
|
454
486
|
type: parseResult.data.type ?? void 0
|
|
455
487
|
});
|
|
@@ -718,6 +750,12 @@ function formatStructuredError(error, options) {
|
|
|
718
750
|
}
|
|
719
751
|
return parts.join("\n");
|
|
720
752
|
}
|
|
753
|
+
function isConflictError(error) {
|
|
754
|
+
return error.status === 409;
|
|
755
|
+
}
|
|
756
|
+
function isAppIdConflictError(error) {
|
|
757
|
+
return error instanceof ResourceError && error.errorCode === "ERR-03-007";
|
|
758
|
+
}
|
|
721
759
|
|
|
722
760
|
// src/client.ts
|
|
723
761
|
var SUPPORTED_API_VERSIONS = [
|
|
@@ -781,8 +819,20 @@ var Client = class _Client {
|
|
|
781
819
|
headers: requestHeaders,
|
|
782
820
|
...useCookieAuth ? { credentials: "include" } : {},
|
|
783
821
|
...fetchOptions,
|
|
784
|
-
//
|
|
822
|
+
// Strip Content-Type for FormData so the browser/runtime sets
|
|
823
|
+
// the correct multipart/form-data boundary automatically.
|
|
824
|
+
// This runs after ofetch merges instance and per-request headers,
|
|
825
|
+
// so deleting here is final.
|
|
785
826
|
onRequest({ request, options }) {
|
|
827
|
+
if (options.body instanceof FormData) {
|
|
828
|
+
const h = options.headers;
|
|
829
|
+
if (h instanceof Headers) {
|
|
830
|
+
h.delete("content-type");
|
|
831
|
+
} else if (h && typeof h === "object" && !Array.isArray(h)) {
|
|
832
|
+
delete h["Content-Type"];
|
|
833
|
+
delete h["content-type"];
|
|
834
|
+
}
|
|
835
|
+
}
|
|
786
836
|
if (logger.enabled) {
|
|
787
837
|
const method = options.method || "GET";
|
|
788
838
|
const url = typeof request === "string" ? request : request.url;
|
|
@@ -914,16 +964,28 @@ var Client = class _Client {
|
|
|
914
964
|
throw phalaCloudError;
|
|
915
965
|
}
|
|
916
966
|
}
|
|
967
|
+
/**
|
|
968
|
+
* Build request options, stripping Content-Type when body is FormData
|
|
969
|
+
* so the browser/runtime sets the correct multipart boundary automatically.
|
|
970
|
+
*/
|
|
971
|
+
// biome-ignore lint/suspicious/noExplicitAny: ofetch generic variance
|
|
972
|
+
buildRequestOptions(method, body, options) {
|
|
973
|
+
const opts = { ...options, method, body };
|
|
974
|
+
if (body instanceof FormData) {
|
|
975
|
+
const existing = opts.headers;
|
|
976
|
+
opts.headers = {
|
|
977
|
+
...existing,
|
|
978
|
+
"Content-Type": ""
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
return opts;
|
|
982
|
+
}
|
|
917
983
|
/**
|
|
918
984
|
* Perform POST request (throws PhalaCloudError on error)
|
|
919
985
|
*/
|
|
920
986
|
async post(request, body, options) {
|
|
921
987
|
try {
|
|
922
|
-
return await this.fetchInstance(request,
|
|
923
|
-
...options,
|
|
924
|
-
method: "POST",
|
|
925
|
-
body
|
|
926
|
-
});
|
|
988
|
+
return await this.fetchInstance(request, this.buildRequestOptions("POST", body, options));
|
|
927
989
|
} catch (error) {
|
|
928
990
|
const requestError = this.convertToRequestError(error);
|
|
929
991
|
const phalaCloudError = this.emitError(requestError);
|
|
@@ -935,11 +997,7 @@ var Client = class _Client {
|
|
|
935
997
|
*/
|
|
936
998
|
async put(request, body, options) {
|
|
937
999
|
try {
|
|
938
|
-
return await this.fetchInstance(request,
|
|
939
|
-
...options,
|
|
940
|
-
method: "PUT",
|
|
941
|
-
body
|
|
942
|
-
});
|
|
1000
|
+
return await this.fetchInstance(request, this.buildRequestOptions("PUT", body, options));
|
|
943
1001
|
} catch (error) {
|
|
944
1002
|
const requestError = this.convertToRequestError(error);
|
|
945
1003
|
const phalaCloudError = this.emitError(requestError);
|
|
@@ -951,11 +1009,7 @@ var Client = class _Client {
|
|
|
951
1009
|
*/
|
|
952
1010
|
async patch(request, body, options) {
|
|
953
1011
|
try {
|
|
954
|
-
return await this.fetchInstance(request,
|
|
955
|
-
...options,
|
|
956
|
-
method: "PATCH",
|
|
957
|
-
body
|
|
958
|
-
});
|
|
1012
|
+
return await this.fetchInstance(request, this.buildRequestOptions("PATCH", body, options));
|
|
959
1013
|
} catch (error) {
|
|
960
1014
|
const requestError = this.convertToRequestError(error);
|
|
961
1015
|
const phalaCloudError = this.emitError(requestError);
|
|
@@ -1609,7 +1663,7 @@ var CvmOsInfoV20260121Schema = import_zod9.z.object({
|
|
|
1609
1663
|
is_dev: import_zod9.z.boolean().nullable().optional(),
|
|
1610
1664
|
os_image_hash: import_zod9.z.string().nullable().optional()
|
|
1611
1665
|
});
|
|
1612
|
-
var
|
|
1666
|
+
var CvmKmsInfoV20260121BaseSchema = import_zod9.z.object({
|
|
1613
1667
|
chain_id: import_zod9.z.number().int().nullable().optional(),
|
|
1614
1668
|
dstack_kms_address: import_zod9.z.string().nullable().optional(),
|
|
1615
1669
|
dstack_app_address: import_zod9.z.string().nullable().optional(),
|
|
@@ -1617,6 +1671,15 @@ var CvmKmsInfoV20260121Schema = import_zod9.z.object({
|
|
|
1617
1671
|
rpc_endpoint: import_zod9.z.string().nullable().optional(),
|
|
1618
1672
|
encrypted_env_pubkey: import_zod9.z.string().nullable().optional()
|
|
1619
1673
|
});
|
|
1674
|
+
var CvmKmsInfoV20260121Schema = CvmKmsInfoV20260121BaseSchema.transform((data) => {
|
|
1675
|
+
if (data.chain_id != null) {
|
|
1676
|
+
const chain = SUPPORTED_CHAINS[data.chain_id];
|
|
1677
|
+
if (chain) {
|
|
1678
|
+
return { ...data, chain };
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
return data;
|
|
1682
|
+
});
|
|
1620
1683
|
var CvmProgressInfoV20260121Schema = import_zod9.z.object({
|
|
1621
1684
|
target: import_zod9.z.string().nullable().optional(),
|
|
1622
1685
|
started_at: import_zod9.z.string().nullable().optional(),
|
|
@@ -2132,7 +2195,8 @@ var ProvisionCvmComposeFileUpdateResultSchema = import_zod15.z.object({
|
|
|
2132
2195
|
app_id: import_zod15.z.string().nullable(),
|
|
2133
2196
|
device_id: import_zod15.z.string().nullable(),
|
|
2134
2197
|
compose_hash: import_zod15.z.string(),
|
|
2135
|
-
kms_info: KmsInfoSchema.nullable().optional()
|
|
2198
|
+
kms_info: KmsInfoSchema.nullable().optional(),
|
|
2199
|
+
compose_hash_registered: import_zod15.z.boolean().optional().default(false)
|
|
2136
2200
|
}).passthrough();
|
|
2137
2201
|
var { action: provisionCvmComposeFileUpdate, safeAction: safeProvisionCvmComposeFileUpdate } = defineAction(ProvisionCvmComposeFileUpdateResultSchema, async (client, request) => {
|
|
2138
2202
|
const validatedRequest = ProvisionCvmComposeFileUpdateRequestSchema.parse(request);
|
|
@@ -2239,14 +2303,24 @@ var { action: updateCvmEnvs, safeAction: safeUpdateCvmEnvs } = defineAction(Upda
|
|
|
2239
2303
|
const detail = error.detail;
|
|
2240
2304
|
if (detail && typeof detail === "object") {
|
|
2241
2305
|
const detailObj = detail;
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2306
|
+
const detailsArray = detailObj.details;
|
|
2307
|
+
if (detailsArray && Array.isArray(detailsArray)) {
|
|
2308
|
+
const fieldMap = new Map(detailsArray.map((d) => [d.field, d.value]));
|
|
2309
|
+
const composeHash = fieldMap.get("compose_hash");
|
|
2310
|
+
const appId = fieldMap.get("app_id");
|
|
2311
|
+
const deviceId = fieldMap.get("device_id");
|
|
2312
|
+
const kmsInfo = fieldMap.get("kms_info");
|
|
2313
|
+
if (composeHash && appId) {
|
|
2314
|
+
return {
|
|
2315
|
+
status: "precondition_required",
|
|
2316
|
+
message: detailObj.message || "Compose hash verification required",
|
|
2317
|
+
compose_hash: composeHash,
|
|
2318
|
+
app_id: appId,
|
|
2319
|
+
device_id: deviceId || "",
|
|
2320
|
+
kms_info: kmsInfo
|
|
2321
|
+
};
|
|
2322
|
+
}
|
|
2323
|
+
}
|
|
2250
2324
|
}
|
|
2251
2325
|
}
|
|
2252
2326
|
throw error;
|
|
@@ -2313,14 +2387,24 @@ var { action: updateDockerCompose, safeAction: safeUpdateDockerCompose } = defin
|
|
|
2313
2387
|
const detail = error.detail;
|
|
2314
2388
|
if (detail && typeof detail === "object") {
|
|
2315
2389
|
const detailObj = detail;
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2390
|
+
const detailsArray = detailObj.details;
|
|
2391
|
+
if (detailsArray && Array.isArray(detailsArray)) {
|
|
2392
|
+
const fieldMap = new Map(detailsArray.map((d) => [d.field, d.value]));
|
|
2393
|
+
const composeHash = fieldMap.get("compose_hash");
|
|
2394
|
+
const appId = fieldMap.get("app_id");
|
|
2395
|
+
const deviceId = fieldMap.get("device_id");
|
|
2396
|
+
const kmsInfo = fieldMap.get("kms_info");
|
|
2397
|
+
if (composeHash && appId) {
|
|
2398
|
+
return {
|
|
2399
|
+
status: "precondition_required",
|
|
2400
|
+
message: detailObj.message || "Compose hash verification required",
|
|
2401
|
+
compose_hash: composeHash,
|
|
2402
|
+
app_id: appId,
|
|
2403
|
+
device_id: deviceId || "",
|
|
2404
|
+
kms_info: kmsInfo
|
|
2405
|
+
};
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2324
2408
|
}
|
|
2325
2409
|
}
|
|
2326
2410
|
throw error;
|
|
@@ -2387,14 +2471,24 @@ var { action: updatePreLaunchScript, safeAction: safeUpdatePreLaunchScript } = d
|
|
|
2387
2471
|
const detail = error.detail;
|
|
2388
2472
|
if (detail && typeof detail === "object") {
|
|
2389
2473
|
const detailObj = detail;
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2474
|
+
const detailsArray = detailObj.details;
|
|
2475
|
+
if (detailsArray && Array.isArray(detailsArray)) {
|
|
2476
|
+
const fieldMap = new Map(detailsArray.map((d) => [d.field, d.value]));
|
|
2477
|
+
const composeHash = fieldMap.get("compose_hash");
|
|
2478
|
+
const appId = fieldMap.get("app_id");
|
|
2479
|
+
const deviceId = fieldMap.get("device_id");
|
|
2480
|
+
const kmsInfo = fieldMap.get("kms_info");
|
|
2481
|
+
if (composeHash && appId) {
|
|
2482
|
+
return {
|
|
2483
|
+
status: "precondition_required",
|
|
2484
|
+
message: detailObj.message || "Compose hash verification required",
|
|
2485
|
+
compose_hash: composeHash,
|
|
2486
|
+
app_id: appId,
|
|
2487
|
+
device_id: deviceId || "",
|
|
2488
|
+
kms_info: kmsInfo
|
|
2489
|
+
};
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2398
2492
|
}
|
|
2399
2493
|
}
|
|
2400
2494
|
throw error;
|
|
@@ -3240,6 +3334,51 @@ function asHex(value) {
|
|
|
3240
3334
|
throw new Error(`Invalid hex value: ${value}`);
|
|
3241
3335
|
}
|
|
3242
3336
|
|
|
3337
|
+
// src/utils/error_codes.ts
|
|
3338
|
+
var ErrorCodes = {
|
|
3339
|
+
// Module 01: CVM Preflight & Compose Hash
|
|
3340
|
+
NODE_NOT_FOUND: "ERR-01-001",
|
|
3341
|
+
COMPOSE_FILE_REQUIRED: "ERR-01-002",
|
|
3342
|
+
INVALID_COMPOSE_FILE: "ERR-01-003",
|
|
3343
|
+
DUPLICATE_CVM_NAME: "ERR-01-004",
|
|
3344
|
+
HASH_REGISTRATION_REQUIRED: "ERR-01-005",
|
|
3345
|
+
HASH_INVALID_OR_EXPIRED: "ERR-01-006",
|
|
3346
|
+
TX_VERIFICATION_FAILED: "ERR-01-007",
|
|
3347
|
+
HASH_NOT_ALLOWED: "ERR-01-008",
|
|
3348
|
+
// Module 02: Inventory
|
|
3349
|
+
INSTANCE_TYPE_NOT_FOUND: "ERR-02-001",
|
|
3350
|
+
RESOURCE_NOT_AVAILABLE: "ERR-02-002",
|
|
3351
|
+
INSUFFICIENT_VCPU: "ERR-02-003",
|
|
3352
|
+
INSUFFICIENT_MEMORY: "ERR-02-004",
|
|
3353
|
+
INSUFFICIENT_SLOTS: "ERR-02-005",
|
|
3354
|
+
GPU_ALLOCATION_ERROR: "ERR-02-006",
|
|
3355
|
+
INSUFFICIENT_GPU: "ERR-02-007",
|
|
3356
|
+
INVALID_REQUEST: "ERR-02-008",
|
|
3357
|
+
INCOMPATIBLE_CONFIG: "ERR-02-009",
|
|
3358
|
+
IMAGE_NOT_FOUND: "ERR-02-010",
|
|
3359
|
+
KMS_NOT_FOUND: "ERR-02-011",
|
|
3360
|
+
TEEPOD_NOT_ACCESSIBLE: "ERR-02-012",
|
|
3361
|
+
OS_IMAGE_NOT_COMPATIBLE: "ERR-02-013",
|
|
3362
|
+
NODE_CAPACITY_NOT_CONFIGURED: "ERR-02-014",
|
|
3363
|
+
QUOTA_EXCEEDED: "ERR-02-015",
|
|
3364
|
+
// Module 03: CVM Operations
|
|
3365
|
+
CVM_NOT_FOUND: "ERR-03-001",
|
|
3366
|
+
MULTIPLE_CVMS_SAME_NAME: "ERR-03-002",
|
|
3367
|
+
CVM_NOT_IN_WORKSPACE: "ERR-03-003",
|
|
3368
|
+
CVM_ACCESS_DENIED: "ERR-03-005",
|
|
3369
|
+
REPLICA_IMAGE_NOT_AVAILABLE: "ERR-03-006",
|
|
3370
|
+
CVM_APP_ID_CONFLICT: "ERR-03-007",
|
|
3371
|
+
// Module 04: Workspace
|
|
3372
|
+
INSUFFICIENT_BALANCE: "ERR-04-001",
|
|
3373
|
+
MAX_CVM_LIMIT: "ERR-04-002",
|
|
3374
|
+
RESOURCE_LIMIT_EXCEEDED: "ERR-04-003",
|
|
3375
|
+
// Module 05: Credentials
|
|
3376
|
+
TOKEN_LIMIT_EXCEEDED: "ERR-05-001",
|
|
3377
|
+
TOKEN_RATE_LIMIT: "ERR-05-002",
|
|
3378
|
+
// Module 06: Auth
|
|
3379
|
+
OAUTH_EMAIL_INVALID: "ERR-06-001"
|
|
3380
|
+
};
|
|
3381
|
+
|
|
3243
3382
|
// src/utils/network.ts
|
|
3244
3383
|
var NetworkError = class extends Error {
|
|
3245
3384
|
constructor(message, code, details) {
|
|
@@ -4367,6 +4506,24 @@ async function addComposeHash(request, parameters) {
|
|
|
4367
4506
|
);
|
|
4368
4507
|
}
|
|
4369
4508
|
}
|
|
4509
|
+
const contractOwner = await publicClient.readContract({
|
|
4510
|
+
address: appAuthAddress,
|
|
4511
|
+
abi: [
|
|
4512
|
+
{
|
|
4513
|
+
inputs: [],
|
|
4514
|
+
name: "owner",
|
|
4515
|
+
outputs: [{ type: "address" }],
|
|
4516
|
+
stateMutability: "view",
|
|
4517
|
+
type: "function"
|
|
4518
|
+
}
|
|
4519
|
+
],
|
|
4520
|
+
functionName: "owner"
|
|
4521
|
+
});
|
|
4522
|
+
if (contractOwner.toLowerCase() !== address.toLowerCase()) {
|
|
4523
|
+
throw new Error(
|
|
4524
|
+
`Sender ${address} is not the owner of contract ${appAuthAddress}. Contract owner is ${contractOwner}.`
|
|
4525
|
+
);
|
|
4526
|
+
}
|
|
4370
4527
|
const addComposeHashOperation = async (clients) => {
|
|
4371
4528
|
const hash = await clients.walletClient.writeContract({
|
|
4372
4529
|
address: appAuthAddress,
|
|
@@ -4479,6 +4636,24 @@ var dstackAppAbi = [
|
|
|
4479
4636
|
stateMutability: "view",
|
|
4480
4637
|
type: "function"
|
|
4481
4638
|
},
|
|
4639
|
+
{
|
|
4640
|
+
inputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
4641
|
+
name: "allowedComposeHashes",
|
|
4642
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
4643
|
+
stateMutability: "view",
|
|
4644
|
+
type: "function"
|
|
4645
|
+
},
|
|
4646
|
+
// ── Errors ───────────────────────────────────────────────────────
|
|
4647
|
+
{
|
|
4648
|
+
inputs: [{ internalType: "address", name: "owner", type: "address" }],
|
|
4649
|
+
name: "OwnableInvalidOwner",
|
|
4650
|
+
type: "error"
|
|
4651
|
+
},
|
|
4652
|
+
{
|
|
4653
|
+
inputs: [{ internalType: "address", name: "account", type: "address" }],
|
|
4654
|
+
name: "OwnableUnauthorizedAccount",
|
|
4655
|
+
type: "error"
|
|
4656
|
+
},
|
|
4482
4657
|
// ── Events ───────────────────────────────────────────────────────
|
|
4483
4658
|
{
|
|
4484
4659
|
anonymous: false,
|
|
@@ -4564,17 +4739,21 @@ async function addDevice(request, parameters) {
|
|
|
4564
4739
|
let chainId;
|
|
4565
4740
|
if (privateKey) {
|
|
4566
4741
|
const account = (0, import_accounts4.privateKeyToAccount)(privateKey);
|
|
4567
|
-
|
|
4742
|
+
const transport = (0, import_viem5.http)(rpcUrl, { timeout });
|
|
4743
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem5.createPublicClient)({ chain, transport });
|
|
4568
4744
|
walletClient = (0, import_viem5.createWalletClient)({
|
|
4569
4745
|
account,
|
|
4570
4746
|
chain,
|
|
4571
|
-
transport
|
|
4747
|
+
transport
|
|
4572
4748
|
});
|
|
4573
4749
|
address = account.address;
|
|
4574
4750
|
chainId = chain.id;
|
|
4575
4751
|
} else if (providedWalletClient) {
|
|
4576
4752
|
walletClient = providedWalletClient;
|
|
4577
|
-
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem5.createPublicClient)({
|
|
4753
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem5.createPublicClient)({
|
|
4754
|
+
chain,
|
|
4755
|
+
transport: (0, import_viem5.http)(rpcUrl, { timeout })
|
|
4756
|
+
});
|
|
4578
4757
|
if (!walletClient.account?.address) {
|
|
4579
4758
|
throw new Error("WalletClient must have an account with address");
|
|
4580
4759
|
}
|
|
@@ -4613,6 +4792,16 @@ async function addDevice(request, parameters) {
|
|
|
4613
4792
|
);
|
|
4614
4793
|
}
|
|
4615
4794
|
}
|
|
4795
|
+
const contractOwner = await publicClient.readContract({
|
|
4796
|
+
address: contractAddress,
|
|
4797
|
+
abi: dstackAppAbi,
|
|
4798
|
+
functionName: "owner"
|
|
4799
|
+
});
|
|
4800
|
+
if (contractOwner.toLowerCase() !== address.toLowerCase()) {
|
|
4801
|
+
throw new Error(
|
|
4802
|
+
`Sender ${address} is not the owner of contract ${contractAddress}. Contract owner is ${contractOwner}.`
|
|
4803
|
+
);
|
|
4804
|
+
}
|
|
4616
4805
|
const addDeviceOperation = async (clients) => {
|
|
4617
4806
|
return clients.walletClient.writeContract({
|
|
4618
4807
|
address: contractAddress,
|
|
@@ -4735,17 +4924,21 @@ async function removeDevice(request, parameters) {
|
|
|
4735
4924
|
let chainId;
|
|
4736
4925
|
if (privateKey) {
|
|
4737
4926
|
const account = (0, import_accounts5.privateKeyToAccount)(privateKey);
|
|
4738
|
-
|
|
4927
|
+
const transport = (0, import_viem6.http)(rpcUrl, { timeout });
|
|
4928
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem6.createPublicClient)({ chain, transport });
|
|
4739
4929
|
walletClient = (0, import_viem6.createWalletClient)({
|
|
4740
4930
|
account,
|
|
4741
4931
|
chain,
|
|
4742
|
-
transport
|
|
4932
|
+
transport
|
|
4743
4933
|
});
|
|
4744
4934
|
address = account.address;
|
|
4745
4935
|
chainId = chain.id;
|
|
4746
4936
|
} else if (providedWalletClient) {
|
|
4747
4937
|
walletClient = providedWalletClient;
|
|
4748
|
-
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem6.createPublicClient)({
|
|
4938
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem6.createPublicClient)({
|
|
4939
|
+
chain,
|
|
4940
|
+
transport: (0, import_viem6.http)(rpcUrl, { timeout })
|
|
4941
|
+
});
|
|
4749
4942
|
if (!walletClient.account?.address) {
|
|
4750
4943
|
throw new Error("WalletClient must have an account with address");
|
|
4751
4944
|
}
|
|
@@ -4905,17 +5098,21 @@ async function setAllowAnyDevice(request, parameters) {
|
|
|
4905
5098
|
let chainId;
|
|
4906
5099
|
if (privateKey) {
|
|
4907
5100
|
const account = (0, import_accounts6.privateKeyToAccount)(privateKey);
|
|
4908
|
-
|
|
5101
|
+
const transport = (0, import_viem7.http)(rpcUrl, { timeout });
|
|
5102
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem7.createPublicClient)({ chain, transport });
|
|
4909
5103
|
walletClient = (0, import_viem7.createWalletClient)({
|
|
4910
5104
|
account,
|
|
4911
5105
|
chain,
|
|
4912
|
-
transport
|
|
5106
|
+
transport
|
|
4913
5107
|
});
|
|
4914
5108
|
address = account.address;
|
|
4915
5109
|
chainId = chain.id;
|
|
4916
5110
|
} else if (providedWalletClient) {
|
|
4917
5111
|
walletClient = providedWalletClient;
|
|
4918
|
-
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem7.createPublicClient)({
|
|
5112
|
+
publicClient = providedPublicClient ? providedPublicClient : (0, import_viem7.createPublicClient)({
|
|
5113
|
+
chain,
|
|
5114
|
+
transport: (0, import_viem7.http)(rpcUrl, { timeout })
|
|
5115
|
+
});
|
|
4919
5116
|
if (!walletClient.account?.address) {
|
|
4920
5117
|
throw new Error("WalletClient must have an account with address");
|
|
4921
5118
|
}
|
|
@@ -5118,6 +5315,97 @@ async function safeCheckDeviceAllowed(request) {
|
|
|
5118
5315
|
}
|
|
5119
5316
|
}
|
|
5120
5317
|
|
|
5318
|
+
// src/actions/blockchains/check_compose_hash_allowed.ts
|
|
5319
|
+
var import_viem10 = require("viem");
|
|
5320
|
+
async function checkComposeHashAllowed(request) {
|
|
5321
|
+
const { chain, rpcUrl, appAddress, composeHash, publicClient: providedPublicClient } = request;
|
|
5322
|
+
const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
|
|
5323
|
+
const composeHashHex = asHex(composeHash);
|
|
5324
|
+
const publicClient = providedPublicClient ? providedPublicClient : (() => {
|
|
5325
|
+
if (!chain) throw new Error("Chain is required when publicClient is not provided");
|
|
5326
|
+
return (0, import_viem10.createPublicClient)({ chain, transport: (0, import_viem10.http)(rpcUrl) });
|
|
5327
|
+
})();
|
|
5328
|
+
const allowed = await publicClient.readContract({
|
|
5329
|
+
address: contractAddress,
|
|
5330
|
+
abi: dstackAppAbi,
|
|
5331
|
+
functionName: "allowedComposeHashes",
|
|
5332
|
+
args: [composeHashHex]
|
|
5333
|
+
});
|
|
5334
|
+
return allowed;
|
|
5335
|
+
}
|
|
5336
|
+
async function safeCheckComposeHashAllowed(request) {
|
|
5337
|
+
try {
|
|
5338
|
+
const result = await checkComposeHashAllowed(request);
|
|
5339
|
+
return { success: true, data: result };
|
|
5340
|
+
} catch (error) {
|
|
5341
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
|
|
5342
|
+
return {
|
|
5343
|
+
success: false,
|
|
5344
|
+
error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
|
|
5345
|
+
};
|
|
5346
|
+
}
|
|
5347
|
+
}
|
|
5348
|
+
|
|
5349
|
+
// src/actions/blockchains/check_on_chain_prerequisites.ts
|
|
5350
|
+
var import_viem11 = require("viem");
|
|
5351
|
+
async function checkOnChainPrerequisites(request) {
|
|
5352
|
+
const {
|
|
5353
|
+
chain,
|
|
5354
|
+
rpcUrl,
|
|
5355
|
+
appAddress,
|
|
5356
|
+
deviceId,
|
|
5357
|
+
composeHash,
|
|
5358
|
+
publicClient: providedPublicClient
|
|
5359
|
+
} = request;
|
|
5360
|
+
const contractAddress = appAddress.startsWith("0x") ? appAddress : `0x${appAddress}`;
|
|
5361
|
+
const deviceIdHex = asHex(deviceId);
|
|
5362
|
+
const composeHashHex = asHex(composeHash);
|
|
5363
|
+
const publicClient = providedPublicClient ? providedPublicClient : (() => {
|
|
5364
|
+
if (!chain) throw new Error("Chain is required when publicClient is not provided");
|
|
5365
|
+
return (0, import_viem11.createPublicClient)({ chain, transport: (0, import_viem11.http)(rpcUrl) });
|
|
5366
|
+
})();
|
|
5367
|
+
const calls = [
|
|
5368
|
+
{
|
|
5369
|
+
address: contractAddress,
|
|
5370
|
+
abi: dstackAppAbi,
|
|
5371
|
+
functionName: "allowAnyDevice"
|
|
5372
|
+
},
|
|
5373
|
+
{
|
|
5374
|
+
address: contractAddress,
|
|
5375
|
+
abi: dstackAppAbi,
|
|
5376
|
+
functionName: "allowedDeviceIds",
|
|
5377
|
+
args: [deviceIdHex]
|
|
5378
|
+
},
|
|
5379
|
+
{
|
|
5380
|
+
address: contractAddress,
|
|
5381
|
+
abi: dstackAppAbi,
|
|
5382
|
+
functionName: "allowedComposeHashes",
|
|
5383
|
+
args: [composeHashHex]
|
|
5384
|
+
}
|
|
5385
|
+
];
|
|
5386
|
+
const multicallResults = await publicClient.multicall({ contracts: calls });
|
|
5387
|
+
const allowAnyDevice = multicallResults[0]?.status === "success" && multicallResults[0]?.result === true;
|
|
5388
|
+
const deviceIdAllowed = multicallResults[1]?.status === "success" && multicallResults[1]?.result === true;
|
|
5389
|
+
const composeHashAllowed = multicallResults[2]?.status === "success" && multicallResults[2]?.result === true;
|
|
5390
|
+
return {
|
|
5391
|
+
allowAnyDevice,
|
|
5392
|
+
deviceAllowed: allowAnyDevice || deviceIdAllowed,
|
|
5393
|
+
composeHashAllowed
|
|
5394
|
+
};
|
|
5395
|
+
}
|
|
5396
|
+
async function safeCheckOnChainPrerequisites(request) {
|
|
5397
|
+
try {
|
|
5398
|
+
const result = await checkOnChainPrerequisites(request);
|
|
5399
|
+
return { success: true, data: result };
|
|
5400
|
+
} catch (error) {
|
|
5401
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown blockchain error";
|
|
5402
|
+
return {
|
|
5403
|
+
success: false,
|
|
5404
|
+
error: { isRequestError: true, message: errorMessage, status: 500, detail: errorMessage }
|
|
5405
|
+
};
|
|
5406
|
+
}
|
|
5407
|
+
}
|
|
5408
|
+
|
|
5121
5409
|
// src/actions/workspaces/get_workspace_nodes.ts
|
|
5122
5410
|
var import_zod54 = require("zod");
|
|
5123
5411
|
var NodeRefSchema2 = NodeRefSchema;
|
|
@@ -5375,22 +5663,177 @@ function sleep(ms, signal) {
|
|
|
5375
5663
|
});
|
|
5376
5664
|
}
|
|
5377
5665
|
|
|
5378
|
-
// src/actions/cvms/
|
|
5666
|
+
// src/actions/cvms/patch_cvm.ts
|
|
5379
5667
|
var import_zod58 = require("zod");
|
|
5380
|
-
var
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5668
|
+
var PatchCvmRequestSchema = refineCvmId(
|
|
5669
|
+
CvmIdObjectSchema.extend({
|
|
5670
|
+
// Compose-hash-affecting fields
|
|
5671
|
+
docker_compose_file: import_zod58.z.string().optional(),
|
|
5672
|
+
pre_launch_script: import_zod58.z.string().optional(),
|
|
5673
|
+
allowed_envs: import_zod58.z.array(import_zod58.z.string()).optional(),
|
|
5674
|
+
// Visibility
|
|
5675
|
+
public_logs: import_zod58.z.boolean().optional(),
|
|
5676
|
+
public_sysinfo: import_zod58.z.boolean().optional(),
|
|
5677
|
+
public_tcbinfo: import_zod58.z.boolean().optional(),
|
|
5678
|
+
// Non-compose-hash config
|
|
5679
|
+
encrypted_env: import_zod58.z.string().optional(),
|
|
5680
|
+
user_config: import_zod58.z.string().optional(),
|
|
5681
|
+
gpus: import_zod58.z.object({
|
|
5682
|
+
count: import_zod58.z.number(),
|
|
5683
|
+
product_name: import_zod58.z.string().optional()
|
|
5684
|
+
}).optional(),
|
|
5685
|
+
// Resources
|
|
5686
|
+
vcpu: import_zod58.z.number().optional(),
|
|
5687
|
+
memory: import_zod58.z.number().optional(),
|
|
5688
|
+
disk_size: import_zod58.z.number().optional(),
|
|
5689
|
+
// OS image
|
|
5690
|
+
image: import_zod58.z.string().optional(),
|
|
5691
|
+
// Shutdown behavior
|
|
5692
|
+
shutdown_timeout: import_zod58.z.number().optional(),
|
|
5693
|
+
allow_force_stop: import_zod58.z.boolean().optional(),
|
|
5694
|
+
// Prepare-only mode (for multisig workflows)
|
|
5695
|
+
prepareOnly: import_zod58.z.boolean().optional()
|
|
5696
|
+
})
|
|
5697
|
+
);
|
|
5698
|
+
var PatchCvmAcceptedSchema = import_zod58.z.object({
|
|
5699
|
+
requiresOnChainHash: import_zod58.z.literal(false),
|
|
5700
|
+
correlationId: import_zod58.z.string()
|
|
5701
|
+
});
|
|
5702
|
+
var PatchCvmHashRequiredSchema = import_zod58.z.object({
|
|
5703
|
+
requiresOnChainHash: import_zod58.z.literal(true),
|
|
5704
|
+
composeHash: import_zod58.z.string(),
|
|
5705
|
+
appId: import_zod58.z.string(),
|
|
5706
|
+
deviceId: import_zod58.z.string(),
|
|
5707
|
+
kmsInfo: KmsInfoSchema,
|
|
5708
|
+
commitToken: import_zod58.z.string().optional(),
|
|
5709
|
+
commitUrl: import_zod58.z.string().optional(),
|
|
5710
|
+
apiCommitUrl: import_zod58.z.string().optional(),
|
|
5711
|
+
onchainStatus: import_zod58.z.object({
|
|
5712
|
+
compose_hash_allowed: import_zod58.z.boolean(),
|
|
5713
|
+
device_id_allowed: import_zod58.z.boolean(),
|
|
5714
|
+
is_allowed: import_zod58.z.boolean()
|
|
5715
|
+
}).optional()
|
|
5716
|
+
});
|
|
5717
|
+
var PatchCvmResultSchema = import_zod58.z.discriminatedUnion("requiresOnChainHash", [
|
|
5718
|
+
PatchCvmAcceptedSchema,
|
|
5719
|
+
PatchCvmHashRequiredSchema
|
|
5720
|
+
]);
|
|
5721
|
+
function extractDetailsMap(detail) {
|
|
5722
|
+
const map = {};
|
|
5723
|
+
if (!detail || typeof detail !== "object") return map;
|
|
5724
|
+
const obj = detail;
|
|
5725
|
+
const details = obj.details;
|
|
5726
|
+
if (!Array.isArray(details)) return map;
|
|
5727
|
+
for (const item of details) {
|
|
5728
|
+
if (item && typeof item === "object" && "field" in item && "value" in item) {
|
|
5729
|
+
map[item.field] = item.value;
|
|
5730
|
+
}
|
|
5731
|
+
}
|
|
5732
|
+
return map;
|
|
5733
|
+
}
|
|
5734
|
+
var { action: patchCvm, safeAction: safePatchCvm } = defineAction(PatchCvmResultSchema, async (client, request) => {
|
|
5735
|
+
const parsed = PatchCvmRequestSchema.parse(request);
|
|
5736
|
+
const { cvmId } = CvmIdSchema.parse(parsed);
|
|
5737
|
+
const { id, uuid, app_id, instance_id, name, prepareOnly, ...body } = parsed;
|
|
5738
|
+
try {
|
|
5739
|
+
const response = prepareOnly ? await client.patch(`/cvms/${cvmId}`, body, {
|
|
5740
|
+
headers: { "X-Prepare-Only": "true" }
|
|
5741
|
+
}) : await client.patch(`/cvms/${cvmId}`, body);
|
|
5742
|
+
return {
|
|
5743
|
+
requiresOnChainHash: false,
|
|
5744
|
+
correlationId: response.correlation_id
|
|
5745
|
+
};
|
|
5746
|
+
} catch (error) {
|
|
5747
|
+
if (error instanceof PhalaCloudError && error.status === 465) {
|
|
5748
|
+
const details = extractDetailsMap(error.detail);
|
|
5749
|
+
return {
|
|
5750
|
+
requiresOnChainHash: true,
|
|
5751
|
+
composeHash: details.compose_hash,
|
|
5752
|
+
appId: String(details.app_id),
|
|
5753
|
+
deviceId: details.device_id,
|
|
5754
|
+
kmsInfo: details.kms_info,
|
|
5755
|
+
commitToken: details.commit_token,
|
|
5756
|
+
commitUrl: details.commit_url,
|
|
5757
|
+
apiCommitUrl: details.api_commit_url,
|
|
5758
|
+
onchainStatus: details.onchain_status
|
|
5759
|
+
};
|
|
5760
|
+
}
|
|
5761
|
+
throw error;
|
|
5762
|
+
}
|
|
5763
|
+
});
|
|
5764
|
+
|
|
5765
|
+
// src/actions/cvms/confirm_cvm_patch.ts
|
|
5766
|
+
var import_zod59 = require("zod");
|
|
5767
|
+
var ConfirmCvmPatchRequestSchema = refineCvmId(
|
|
5768
|
+
CvmIdObjectSchema.extend({
|
|
5769
|
+
composeHash: import_zod59.z.string().describe("Compose hash from patchCvm Phase 1 response"),
|
|
5770
|
+
transactionHash: import_zod59.z.string().describe("Transaction hash proving on-chain registration")
|
|
5771
|
+
})
|
|
5772
|
+
);
|
|
5773
|
+
var ConfirmCvmPatchResultSchema = import_zod59.z.object({
|
|
5774
|
+
correlationId: import_zod59.z.string()
|
|
5775
|
+
});
|
|
5776
|
+
var { action: confirmCvmPatch, safeAction: safeConfirmCvmPatch } = defineAction(ConfirmCvmPatchResultSchema, async (client, request) => {
|
|
5777
|
+
const parsed = ConfirmCvmPatchRequestSchema.parse(request);
|
|
5778
|
+
const { cvmId } = CvmIdSchema.parse(parsed);
|
|
5779
|
+
const response = await client.patch(
|
|
5780
|
+
`/cvms/${cvmId}`,
|
|
5781
|
+
{},
|
|
5782
|
+
{
|
|
5783
|
+
headers: {
|
|
5784
|
+
"X-Compose-Hash": parsed.composeHash,
|
|
5785
|
+
"X-Transaction-Hash": parsed.transactionHash
|
|
5786
|
+
}
|
|
5787
|
+
}
|
|
5788
|
+
);
|
|
5789
|
+
return {
|
|
5790
|
+
correlationId: response.correlation_id
|
|
5791
|
+
};
|
|
5792
|
+
});
|
|
5793
|
+
|
|
5794
|
+
// src/actions/cvms/commit_cvm_update.ts
|
|
5795
|
+
var import_zod60 = require("zod");
|
|
5796
|
+
var CommitCvmUpdateRequestSchema = refineCvmId(
|
|
5797
|
+
CvmIdObjectSchema.extend({
|
|
5798
|
+
token: import_zod60.z.string().describe("One-time commit token from prepare-only flow"),
|
|
5799
|
+
composeHash: import_zod60.z.string().describe("Compose hash from Phase 1 response"),
|
|
5800
|
+
transactionHash: import_zod60.z.string().describe("Transaction hash proving on-chain registration")
|
|
5801
|
+
})
|
|
5802
|
+
);
|
|
5803
|
+
var CommitCvmUpdateResultSchema = import_zod60.z.object({
|
|
5804
|
+
correlationId: import_zod60.z.string(),
|
|
5805
|
+
status: import_zod60.z.string()
|
|
5806
|
+
});
|
|
5807
|
+
var { action: commitCvmUpdate, safeAction: safeCommitCvmUpdate } = defineAction(CommitCvmUpdateResultSchema, async (client, request) => {
|
|
5808
|
+
const parsed = CommitCvmUpdateRequestSchema.parse(request);
|
|
5809
|
+
const { cvmId } = CvmIdSchema.parse(parsed);
|
|
5810
|
+
const response = await client.post(`/cvms/${cvmId}/commit-update`, {
|
|
5811
|
+
token: parsed.token,
|
|
5812
|
+
compose_hash: parsed.composeHash,
|
|
5813
|
+
transaction_hash: parsed.transactionHash
|
|
5814
|
+
});
|
|
5815
|
+
return {
|
|
5816
|
+
correlationId: response.correlation_id,
|
|
5817
|
+
status: response.status
|
|
5818
|
+
};
|
|
5819
|
+
});
|
|
5820
|
+
|
|
5821
|
+
// src/actions/cvms/refresh_cvm_instance_id.ts
|
|
5822
|
+
var import_zod61 = require("zod");
|
|
5823
|
+
var InstanceIdRefreshResultSchema = import_zod61.z.object({
|
|
5824
|
+
cvm_id: import_zod61.z.number().int(),
|
|
5825
|
+
identifier: import_zod61.z.string(),
|
|
5826
|
+
status: import_zod61.z.enum(["updated", "unchanged", "skipped", "conflict", "error"]),
|
|
5827
|
+
old_instance_id: import_zod61.z.string().nullable().optional(),
|
|
5828
|
+
new_instance_id: import_zod61.z.string().nullable().optional(),
|
|
5829
|
+
source: import_zod61.z.enum(["teepod_state", "teepod_info", "gateway", "none"]),
|
|
5830
|
+
verified_with_gateway: import_zod61.z.boolean(),
|
|
5831
|
+
reason: import_zod61.z.string().nullable().optional()
|
|
5389
5832
|
});
|
|
5390
5833
|
var RefreshCvmInstanceIdRequestSchema = refineCvmId(
|
|
5391
5834
|
CvmIdObjectSchema.extend({
|
|
5392
|
-
overwrite:
|
|
5393
|
-
dry_run:
|
|
5835
|
+
overwrite: import_zod61.z.boolean().optional(),
|
|
5836
|
+
dry_run: import_zod61.z.boolean().optional()
|
|
5394
5837
|
})
|
|
5395
5838
|
);
|
|
5396
5839
|
var { action: refreshCvmInstanceId, safeAction: safeRefreshCvmInstanceId } = defineAction(InstanceIdRefreshResultSchema, async (client, request) => {
|
|
@@ -5404,24 +5847,24 @@ var { action: refreshCvmInstanceId, safeAction: safeRefreshCvmInstanceId } = def
|
|
|
5404
5847
|
});
|
|
5405
5848
|
|
|
5406
5849
|
// src/actions/cvms/refresh_cvm_instance_ids.ts
|
|
5407
|
-
var
|
|
5408
|
-
var RefreshCvmInstanceIdsRequestSchema =
|
|
5409
|
-
cvm_ids:
|
|
5410
|
-
running_only:
|
|
5411
|
-
missing_only:
|
|
5412
|
-
overwrite:
|
|
5413
|
-
limit:
|
|
5414
|
-
dry_run:
|
|
5850
|
+
var import_zod62 = require("zod");
|
|
5851
|
+
var RefreshCvmInstanceIdsRequestSchema = import_zod62.z.object({
|
|
5852
|
+
cvm_ids: import_zod62.z.array(import_zod62.z.string()).optional(),
|
|
5853
|
+
running_only: import_zod62.z.boolean().optional(),
|
|
5854
|
+
missing_only: import_zod62.z.boolean().optional(),
|
|
5855
|
+
overwrite: import_zod62.z.boolean().optional(),
|
|
5856
|
+
limit: import_zod62.z.number().int().min(1).max(500).optional(),
|
|
5857
|
+
dry_run: import_zod62.z.boolean().optional()
|
|
5415
5858
|
}).strict();
|
|
5416
|
-
var RefreshCvmInstanceIdsResponseSchema =
|
|
5417
|
-
total:
|
|
5418
|
-
scanned:
|
|
5419
|
-
updated:
|
|
5420
|
-
unchanged:
|
|
5421
|
-
skipped:
|
|
5422
|
-
conflicts:
|
|
5423
|
-
errors:
|
|
5424
|
-
items:
|
|
5859
|
+
var RefreshCvmInstanceIdsResponseSchema = import_zod62.z.object({
|
|
5860
|
+
total: import_zod62.z.number().int(),
|
|
5861
|
+
scanned: import_zod62.z.number().int(),
|
|
5862
|
+
updated: import_zod62.z.number().int(),
|
|
5863
|
+
unchanged: import_zod62.z.number().int(),
|
|
5864
|
+
skipped: import_zod62.z.number().int(),
|
|
5865
|
+
conflicts: import_zod62.z.number().int(),
|
|
5866
|
+
errors: import_zod62.z.number().int(),
|
|
5867
|
+
items: import_zod62.z.array(InstanceIdRefreshResultSchema)
|
|
5425
5868
|
});
|
|
5426
5869
|
var { action: refreshCvmInstanceIds, safeAction: safeRefreshCvmInstanceIds } = defineAction(RefreshCvmInstanceIdsResponseSchema, async (client, request) => {
|
|
5427
5870
|
const parsed = RefreshCvmInstanceIdsRequestSchema.parse(request);
|
|
@@ -5429,21 +5872,21 @@ var { action: refreshCvmInstanceIds, safeAction: safeRefreshCvmInstanceIds } = d
|
|
|
5429
5872
|
});
|
|
5430
5873
|
|
|
5431
5874
|
// src/actions/cvms/get_cvm_status_batch.ts
|
|
5432
|
-
var
|
|
5433
|
-
var CvmStatusSchema =
|
|
5434
|
-
vm_uuid:
|
|
5435
|
-
status:
|
|
5436
|
-
uptime:
|
|
5437
|
-
in_progress:
|
|
5438
|
-
boot_progress:
|
|
5439
|
-
boot_error:
|
|
5440
|
-
operation_type:
|
|
5441
|
-
operation_started_at:
|
|
5442
|
-
correlation_id:
|
|
5443
|
-
});
|
|
5444
|
-
var GetCvmStatusBatchResponseSchema =
|
|
5445
|
-
var GetCvmStatusBatchRequestSchema =
|
|
5446
|
-
vmUuids:
|
|
5875
|
+
var import_zod63 = require("zod");
|
|
5876
|
+
var CvmStatusSchema = import_zod63.z.object({
|
|
5877
|
+
vm_uuid: import_zod63.z.string(),
|
|
5878
|
+
status: import_zod63.z.string(),
|
|
5879
|
+
uptime: import_zod63.z.string().nullable().optional(),
|
|
5880
|
+
in_progress: import_zod63.z.boolean(),
|
|
5881
|
+
boot_progress: import_zod63.z.string().nullable().optional(),
|
|
5882
|
+
boot_error: import_zod63.z.string().nullable().optional(),
|
|
5883
|
+
operation_type: import_zod63.z.string().nullable().optional(),
|
|
5884
|
+
operation_started_at: import_zod63.z.string().nullable().optional(),
|
|
5885
|
+
correlation_id: import_zod63.z.string().nullable().optional()
|
|
5886
|
+
});
|
|
5887
|
+
var GetCvmStatusBatchResponseSchema = import_zod63.z.record(import_zod63.z.string(), CvmStatusSchema);
|
|
5888
|
+
var GetCvmStatusBatchRequestSchema = import_zod63.z.object({
|
|
5889
|
+
vmUuids: import_zod63.z.array(import_zod63.z.string())
|
|
5447
5890
|
});
|
|
5448
5891
|
var { action: getCvmStatusBatch, safeAction: safeGetCvmStatusBatch } = defineAction(GetCvmStatusBatchResponseSchema, async (client, request) => {
|
|
5449
5892
|
const { vmUuids } = GetCvmStatusBatchRequestSchema.parse(request);
|
|
@@ -5451,11 +5894,11 @@ var { action: getCvmStatusBatch, safeAction: safeGetCvmStatusBatch } = defineAct
|
|
|
5451
5894
|
});
|
|
5452
5895
|
|
|
5453
5896
|
// src/actions/cvms/get_cvm_user_config.ts
|
|
5454
|
-
var
|
|
5455
|
-
var CvmUserConfigSchema =
|
|
5456
|
-
hostname:
|
|
5457
|
-
ssh_authorized_keys:
|
|
5458
|
-
default_gateway_domain:
|
|
5897
|
+
var import_zod64 = require("zod");
|
|
5898
|
+
var CvmUserConfigSchema = import_zod64.z.object({
|
|
5899
|
+
hostname: import_zod64.z.string().nullable().optional(),
|
|
5900
|
+
ssh_authorized_keys: import_zod64.z.array(import_zod64.z.string()).default([]),
|
|
5901
|
+
default_gateway_domain: import_zod64.z.string().nullable().optional()
|
|
5459
5902
|
});
|
|
5460
5903
|
var GetCvmUserConfigRequestSchema = CvmIdSchema;
|
|
5461
5904
|
var { action: getCvmUserConfig, safeAction: safeGetCvmUserConfig } = defineAction(CvmUserConfigSchema, async (client, request) => {
|
|
@@ -5463,20 +5906,78 @@ var { action: getCvmUserConfig, safeAction: safeGetCvmUserConfig } = defineActio
|
|
|
5463
5906
|
return await client.get(`/cvms/${cvmId}/user_config`);
|
|
5464
5907
|
});
|
|
5465
5908
|
|
|
5909
|
+
// src/actions/cvms/check_cvm_is_allowed.ts
|
|
5910
|
+
var import_zod65 = require("zod");
|
|
5911
|
+
var IsAllowedResultSchema = import_zod65.z.object({
|
|
5912
|
+
cvm_id: import_zod65.z.number().optional(),
|
|
5913
|
+
app_contract_address: import_zod65.z.string(),
|
|
5914
|
+
compose_hash: import_zod65.z.string(),
|
|
5915
|
+
device_id: import_zod65.z.string(),
|
|
5916
|
+
compose_hash_allowed: import_zod65.z.boolean(),
|
|
5917
|
+
allow_any_device: import_zod65.z.boolean(),
|
|
5918
|
+
device_id_allowed: import_zod65.z.boolean().nullable().optional(),
|
|
5919
|
+
is_allowed: import_zod65.z.boolean(),
|
|
5920
|
+
error: import_zod65.z.string().nullable().optional()
|
|
5921
|
+
});
|
|
5922
|
+
var CheckCvmIsAllowedInputSchema = import_zod65.z.object({
|
|
5923
|
+
cvmId: import_zod65.z.string().min(1),
|
|
5924
|
+
compose_hash: import_zod65.z.string().optional(),
|
|
5925
|
+
node_id: import_zod65.z.number().optional(),
|
|
5926
|
+
device_id: import_zod65.z.string().optional()
|
|
5927
|
+
});
|
|
5928
|
+
var CheckCvmIsAllowedRequestSchema = CheckCvmIsAllowedInputSchema;
|
|
5929
|
+
var { action: checkCvmIsAllowed, safeAction: safeCheckCvmIsAllowed } = defineAction(IsAllowedResultSchema, async (client, request) => {
|
|
5930
|
+
const { cvmId, ...body } = CheckCvmIsAllowedRequestSchema.parse(request);
|
|
5931
|
+
return await client.post(`/cvms/${cvmId}/is-allowed`, body);
|
|
5932
|
+
});
|
|
5933
|
+
|
|
5934
|
+
// src/actions/apps/check_app_is_allowed.ts
|
|
5935
|
+
var import_zod66 = require("zod");
|
|
5936
|
+
var CheckAppIsAllowedRequestSchema = import_zod66.z.object({
|
|
5937
|
+
appId: import_zod66.z.string().min(1),
|
|
5938
|
+
compose_hash: import_zod66.z.string(),
|
|
5939
|
+
node_id: import_zod66.z.number().optional(),
|
|
5940
|
+
device_id: import_zod66.z.string().optional(),
|
|
5941
|
+
chain_id: import_zod66.z.number().optional()
|
|
5942
|
+
});
|
|
5943
|
+
var { action: checkAppIsAllowed, safeAction: safeCheckAppIsAllowed } = defineAction(IsAllowedResultSchema, async (client, request) => {
|
|
5944
|
+
const { appId, ...body } = CheckAppIsAllowedRequestSchema.parse(request);
|
|
5945
|
+
return await client.post(`/apps/${appId}/is-allowed`, body);
|
|
5946
|
+
});
|
|
5947
|
+
|
|
5948
|
+
// src/actions/apps/check_app_cvms_is_allowed.ts
|
|
5949
|
+
var import_zod67 = require("zod");
|
|
5950
|
+
var AppCvmsBatchIsAllowedResponseSchema = import_zod67.z.object({
|
|
5951
|
+
is_onchain: import_zod67.z.boolean(),
|
|
5952
|
+
results: import_zod67.z.array(IsAllowedResultSchema.extend({ cvm_id: import_zod67.z.number() })).default([]),
|
|
5953
|
+
total: import_zod67.z.number().default(0),
|
|
5954
|
+
allowed_count: import_zod67.z.number().default(0),
|
|
5955
|
+
denied_count: import_zod67.z.number().default(0),
|
|
5956
|
+
error_count: import_zod67.z.number().default(0),
|
|
5957
|
+
skipped_cvm_ids: import_zod67.z.array(import_zod67.z.number()).default([])
|
|
5958
|
+
});
|
|
5959
|
+
var CheckAppCvmsIsAllowedRequestSchema = import_zod67.z.object({
|
|
5960
|
+
appId: import_zod67.z.string().min(1)
|
|
5961
|
+
});
|
|
5962
|
+
var { action: checkAppCvmsIsAllowed, safeAction: safeCheckAppCvmsIsAllowed } = defineAction(AppCvmsBatchIsAllowedResponseSchema, async (client, request) => {
|
|
5963
|
+
const { appId } = CheckAppCvmsIsAllowedRequestSchema.parse(request);
|
|
5964
|
+
return await client.post(`/apps/${appId}/cvms/is-allowed`, {});
|
|
5965
|
+
});
|
|
5966
|
+
|
|
5466
5967
|
// src/actions/apps/get_app_list.ts
|
|
5467
|
-
var
|
|
5468
|
-
var GetAppListRequestSchema =
|
|
5469
|
-
page:
|
|
5470
|
-
page_size:
|
|
5471
|
-
search:
|
|
5472
|
-
status:
|
|
5473
|
-
listed:
|
|
5474
|
-
base_image:
|
|
5475
|
-
instance_type:
|
|
5476
|
-
kms_slug:
|
|
5477
|
-
kms_type:
|
|
5478
|
-
node:
|
|
5479
|
-
region:
|
|
5968
|
+
var import_zod68 = require("zod");
|
|
5969
|
+
var GetAppListRequestSchema = import_zod68.z.object({
|
|
5970
|
+
page: import_zod68.z.number().int().min(1).optional(),
|
|
5971
|
+
page_size: import_zod68.z.number().int().min(1).max(100).optional(),
|
|
5972
|
+
search: import_zod68.z.string().optional(),
|
|
5973
|
+
status: import_zod68.z.array(import_zod68.z.string()).optional(),
|
|
5974
|
+
listed: import_zod68.z.boolean().optional(),
|
|
5975
|
+
base_image: import_zod68.z.string().optional(),
|
|
5976
|
+
instance_type: import_zod68.z.string().optional(),
|
|
5977
|
+
kms_slug: import_zod68.z.string().optional(),
|
|
5978
|
+
kms_type: import_zod68.z.string().optional(),
|
|
5979
|
+
node: import_zod68.z.string().optional(),
|
|
5980
|
+
region: import_zod68.z.string().optional()
|
|
5480
5981
|
}).strict();
|
|
5481
5982
|
function getSchemaForVersion4(version) {
|
|
5482
5983
|
return version === "2025-10-28" ? DstackAppListResponseV20251028Schema : DstackAppListResponseV20260121Schema;
|
|
@@ -5506,9 +6007,9 @@ async function safeGetAppList(client, request) {
|
|
|
5506
6007
|
}
|
|
5507
6008
|
|
|
5508
6009
|
// src/actions/apps/get_app_info.ts
|
|
5509
|
-
var
|
|
5510
|
-
var GetAppInfoRequestSchema =
|
|
5511
|
-
appId:
|
|
6010
|
+
var import_zod69 = require("zod");
|
|
6011
|
+
var GetAppInfoRequestSchema = import_zod69.z.object({
|
|
6012
|
+
appId: import_zod69.z.string().min(1)
|
|
5512
6013
|
}).strict();
|
|
5513
6014
|
function getSchemaForVersion5(version) {
|
|
5514
6015
|
return version === "2025-10-28" ? DstackAppWithCvmResponseV20251028Schema : DstackAppWithCvmResponseV20260121Schema;
|
|
@@ -5538,12 +6039,12 @@ async function safeGetAppInfo(client, request) {
|
|
|
5538
6039
|
}
|
|
5539
6040
|
|
|
5540
6041
|
// src/actions/apps/get_app_cvms.ts
|
|
5541
|
-
var
|
|
5542
|
-
var GetAppCvmsRequestSchema =
|
|
5543
|
-
appId:
|
|
6042
|
+
var import_zod70 = require("zod");
|
|
6043
|
+
var GetAppCvmsRequestSchema = import_zod70.z.object({
|
|
6044
|
+
appId: import_zod70.z.string().min(1)
|
|
5544
6045
|
}).strict();
|
|
5545
6046
|
function getSchemaForVersion6(version) {
|
|
5546
|
-
return version === "2025-10-28" ?
|
|
6047
|
+
return version === "2025-10-28" ? import_zod70.z.array(CvmInfoV20251028Schema) : import_zod70.z.array(CvmInfoV20260121Schema);
|
|
5547
6048
|
}
|
|
5548
6049
|
async function getAppCvms(client, request) {
|
|
5549
6050
|
const { appId } = GetAppCvmsRequestSchema.parse(request);
|
|
@@ -5569,24 +6070,42 @@ async function safeGetAppCvms(client, request) {
|
|
|
5569
6070
|
}
|
|
5570
6071
|
}
|
|
5571
6072
|
|
|
6073
|
+
// src/actions/apps/create_app_instance.ts
|
|
6074
|
+
var import_zod71 = require("zod");
|
|
6075
|
+
var CreateAppInstanceRequestSchema = import_zod71.z.object({
|
|
6076
|
+
appId: import_zod71.z.string().min(1),
|
|
6077
|
+
node_id: import_zod71.z.number().optional(),
|
|
6078
|
+
docker_compose_file: import_zod71.z.string().optional(),
|
|
6079
|
+
pre_launch_script: import_zod71.z.string().optional(),
|
|
6080
|
+
encrypted_env: import_zod71.z.string().optional(),
|
|
6081
|
+
compose_hash: import_zod71.z.string().optional(),
|
|
6082
|
+
token: import_zod71.z.string().optional(),
|
|
6083
|
+
transaction_hash: import_zod71.z.string().optional()
|
|
6084
|
+
}).strict();
|
|
6085
|
+
var { action: createAppInstance, safeAction: safeCreateAppInstance } = defineAction(VMSchema, async (client, request) => {
|
|
6086
|
+
const parsed = CreateAppInstanceRequestSchema.parse(request);
|
|
6087
|
+
const { appId, ...body } = parsed;
|
|
6088
|
+
return await client.post(`/apps/${appId}/instances`, body);
|
|
6089
|
+
});
|
|
6090
|
+
|
|
5572
6091
|
// src/actions/apps/get_app_device_allowlist.ts
|
|
5573
|
-
var
|
|
5574
|
-
var DeviceAllowlistItemSchema =
|
|
5575
|
-
device_id:
|
|
5576
|
-
node_name:
|
|
5577
|
-
cvm_ids:
|
|
5578
|
-
allowed_onchain:
|
|
5579
|
-
status:
|
|
5580
|
-
});
|
|
5581
|
-
var DeviceAllowlistResponseSchema =
|
|
5582
|
-
is_onchain_kms:
|
|
5583
|
-
allow_any_device:
|
|
5584
|
-
chain_id:
|
|
5585
|
-
app_contract_address:
|
|
5586
|
-
devices:
|
|
5587
|
-
});
|
|
5588
|
-
var GetAppDeviceAllowlistRequestSchema =
|
|
5589
|
-
appId:
|
|
6092
|
+
var import_zod72 = require("zod");
|
|
6093
|
+
var DeviceAllowlistItemSchema = import_zod72.z.object({
|
|
6094
|
+
device_id: import_zod72.z.string(),
|
|
6095
|
+
node_name: import_zod72.z.string().nullable(),
|
|
6096
|
+
cvm_ids: import_zod72.z.array(import_zod72.z.number()),
|
|
6097
|
+
allowed_onchain: import_zod72.z.boolean(),
|
|
6098
|
+
status: import_zod72.z.string()
|
|
6099
|
+
});
|
|
6100
|
+
var DeviceAllowlistResponseSchema = import_zod72.z.object({
|
|
6101
|
+
is_onchain_kms: import_zod72.z.boolean(),
|
|
6102
|
+
allow_any_device: import_zod72.z.boolean().nullable().optional(),
|
|
6103
|
+
chain_id: import_zod72.z.number().nullable().optional(),
|
|
6104
|
+
app_contract_address: import_zod72.z.string().nullable().optional(),
|
|
6105
|
+
devices: import_zod72.z.array(DeviceAllowlistItemSchema).optional().default([])
|
|
6106
|
+
});
|
|
6107
|
+
var GetAppDeviceAllowlistRequestSchema = import_zod72.z.object({
|
|
6108
|
+
appId: import_zod72.z.string().min(1)
|
|
5590
6109
|
}).strict();
|
|
5591
6110
|
async function getAppDeviceAllowlist(client, request) {
|
|
5592
6111
|
const { appId } = GetAppDeviceAllowlistRequestSchema.parse(request);
|
|
@@ -5612,11 +6131,11 @@ async function safeGetAppDeviceAllowlist(client, request) {
|
|
|
5612
6131
|
}
|
|
5613
6132
|
|
|
5614
6133
|
// src/actions/apps/get_app_revisions.ts
|
|
5615
|
-
var
|
|
5616
|
-
var GetAppRevisionsRequestSchema =
|
|
5617
|
-
appId:
|
|
5618
|
-
page:
|
|
5619
|
-
page_size:
|
|
6134
|
+
var import_zod73 = require("zod");
|
|
6135
|
+
var GetAppRevisionsRequestSchema = import_zod73.z.object({
|
|
6136
|
+
appId: import_zod73.z.string().min(1),
|
|
6137
|
+
page: import_zod73.z.number().int().min(1).optional(),
|
|
6138
|
+
page_size: import_zod73.z.number().int().min(1).max(1e3).optional()
|
|
5620
6139
|
}).strict();
|
|
5621
6140
|
async function getAppRevisions(client, request) {
|
|
5622
6141
|
const { appId, ...params } = GetAppRevisionsRequestSchema.parse(request);
|
|
@@ -5642,11 +6161,11 @@ async function safeGetAppRevisions(client, request) {
|
|
|
5642
6161
|
}
|
|
5643
6162
|
|
|
5644
6163
|
// src/actions/apps/get_app_revision_detail.ts
|
|
5645
|
-
var
|
|
5646
|
-
var GetAppRevisionDetailRequestSchema =
|
|
5647
|
-
appId:
|
|
5648
|
-
revisionId:
|
|
5649
|
-
rawComposeFile:
|
|
6164
|
+
var import_zod74 = require("zod");
|
|
6165
|
+
var GetAppRevisionDetailRequestSchema = import_zod74.z.object({
|
|
6166
|
+
appId: import_zod74.z.string().min(1),
|
|
6167
|
+
revisionId: import_zod74.z.string().min(1),
|
|
6168
|
+
rawComposeFile: import_zod74.z.boolean().optional()
|
|
5650
6169
|
}).strict();
|
|
5651
6170
|
async function getAppRevisionDetail(client, request) {
|
|
5652
6171
|
const { appId, revisionId, rawComposeFile } = GetAppRevisionDetailRequestSchema.parse(request);
|
|
@@ -5673,15 +6192,15 @@ async function safeGetAppRevisionDetail(client, request) {
|
|
|
5673
6192
|
}
|
|
5674
6193
|
|
|
5675
6194
|
// src/actions/apps/get_app_filter_options.ts
|
|
5676
|
-
var
|
|
5677
|
-
var AppFilterOptionsSchema =
|
|
5678
|
-
statuses:
|
|
5679
|
-
image_versions:
|
|
5680
|
-
instance_types:
|
|
5681
|
-
kms_slugs:
|
|
5682
|
-
kms_types:
|
|
5683
|
-
regions:
|
|
5684
|
-
nodes:
|
|
6195
|
+
var import_zod75 = require("zod");
|
|
6196
|
+
var AppFilterOptionsSchema = import_zod75.z.object({
|
|
6197
|
+
statuses: import_zod75.z.array(import_zod75.z.string()),
|
|
6198
|
+
image_versions: import_zod75.z.array(import_zod75.z.string()),
|
|
6199
|
+
instance_types: import_zod75.z.array(import_zod75.z.string()),
|
|
6200
|
+
kms_slugs: import_zod75.z.array(import_zod75.z.string()),
|
|
6201
|
+
kms_types: import_zod75.z.array(import_zod75.z.string()),
|
|
6202
|
+
regions: import_zod75.z.array(import_zod75.z.string()),
|
|
6203
|
+
nodes: import_zod75.z.array(import_zod75.z.string())
|
|
5685
6204
|
});
|
|
5686
6205
|
async function getAppFilterOptions(client) {
|
|
5687
6206
|
const response = await client.get("/apps/filter-options");
|
|
@@ -5706,47 +6225,47 @@ async function safeGetAppFilterOptions(client) {
|
|
|
5706
6225
|
}
|
|
5707
6226
|
|
|
5708
6227
|
// src/actions/apps/get_app_attestation.ts
|
|
5709
|
-
var
|
|
5710
|
-
var KmsInfoSchema2 =
|
|
5711
|
-
contract_address:
|
|
5712
|
-
chain_id:
|
|
5713
|
-
version:
|
|
5714
|
-
url:
|
|
5715
|
-
gateway_app_id:
|
|
5716
|
-
gateway_app_url:
|
|
5717
|
-
kms_type:
|
|
5718
|
-
});
|
|
5719
|
-
var GuestAgentInfoSchema =
|
|
5720
|
-
app_id:
|
|
5721
|
-
instance_id:
|
|
5722
|
-
app_name:
|
|
5723
|
-
device_id:
|
|
6228
|
+
var import_zod76 = require("zod");
|
|
6229
|
+
var KmsInfoSchema2 = import_zod76.z.object({
|
|
6230
|
+
contract_address: import_zod76.z.string(),
|
|
6231
|
+
chain_id: import_zod76.z.string().nullable(),
|
|
6232
|
+
version: import_zod76.z.string(),
|
|
6233
|
+
url: import_zod76.z.string(),
|
|
6234
|
+
gateway_app_id: import_zod76.z.string().nullable(),
|
|
6235
|
+
gateway_app_url: import_zod76.z.string(),
|
|
6236
|
+
kms_type: import_zod76.z.string()
|
|
6237
|
+
});
|
|
6238
|
+
var GuestAgentInfoSchema = import_zod76.z.object({
|
|
6239
|
+
app_id: import_zod76.z.string().optional(),
|
|
6240
|
+
instance_id: import_zod76.z.string().optional(),
|
|
6241
|
+
app_name: import_zod76.z.string().optional(),
|
|
6242
|
+
device_id: import_zod76.z.string().optional()
|
|
5724
6243
|
}).passthrough().nullable();
|
|
5725
|
-
var AppAttestationInstanceSchema =
|
|
5726
|
-
vm_uuid:
|
|
5727
|
-
name:
|
|
5728
|
-
instance_id:
|
|
5729
|
-
status:
|
|
5730
|
-
image_version:
|
|
5731
|
-
quote:
|
|
5732
|
-
ppid:
|
|
5733
|
-
device_id:
|
|
6244
|
+
var AppAttestationInstanceSchema = import_zod76.z.object({
|
|
6245
|
+
vm_uuid: import_zod76.z.string().nullable().optional(),
|
|
6246
|
+
name: import_zod76.z.string().optional(),
|
|
6247
|
+
instance_id: import_zod76.z.string().nullable().optional(),
|
|
6248
|
+
status: import_zod76.z.string().optional(),
|
|
6249
|
+
image_version: import_zod76.z.string().nullable().optional(),
|
|
6250
|
+
quote: import_zod76.z.string().nullable().optional(),
|
|
6251
|
+
ppid: import_zod76.z.string().optional(),
|
|
6252
|
+
device_id: import_zod76.z.string().optional(),
|
|
5734
6253
|
tcb_info: TcbInfoSchema.nullable().optional(),
|
|
5735
|
-
app_certificates:
|
|
5736
|
-
compose_file:
|
|
5737
|
-
error:
|
|
6254
|
+
app_certificates: import_zod76.z.array(CertificateSchema).nullable().optional(),
|
|
6255
|
+
compose_file: import_zod76.z.string().nullable().optional(),
|
|
6256
|
+
error: import_zod76.z.string().nullable().optional()
|
|
5738
6257
|
});
|
|
5739
|
-
var AppAttestationResponseSchema =
|
|
5740
|
-
app_id:
|
|
5741
|
-
contract_address:
|
|
6258
|
+
var AppAttestationResponseSchema = import_zod76.z.object({
|
|
6259
|
+
app_id: import_zod76.z.string(),
|
|
6260
|
+
contract_address: import_zod76.z.string(),
|
|
5742
6261
|
kms_info: KmsInfoSchema2,
|
|
5743
|
-
instances:
|
|
6262
|
+
instances: import_zod76.z.array(AppAttestationInstanceSchema),
|
|
5744
6263
|
kms_guest_agent_info: GuestAgentInfoSchema,
|
|
5745
6264
|
gateway_guest_agent_info: GuestAgentInfoSchema,
|
|
5746
|
-
qemu_version:
|
|
6265
|
+
qemu_version: import_zod76.z.string().nullable()
|
|
5747
6266
|
});
|
|
5748
|
-
var GetAppAttestationRequestSchema =
|
|
5749
|
-
appId:
|
|
6267
|
+
var GetAppAttestationRequestSchema = import_zod76.z.object({
|
|
6268
|
+
appId: import_zod76.z.string().min(1)
|
|
5750
6269
|
}).strict();
|
|
5751
6270
|
var { action: getAppAttestation, safeAction: safeGetAppAttestation } = defineAction(AppAttestationResponseSchema, async (client, request) => {
|
|
5752
6271
|
const { appId } = GetAppAttestationRequestSchema.parse(request);
|
|
@@ -5796,6 +6315,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5796
6315
|
ApiErrorSchema,
|
|
5797
6316
|
AppAttestationInstanceSchema,
|
|
5798
6317
|
AppAttestationResponseSchema,
|
|
6318
|
+
AppCvmsBatchIsAllowedResponseSchema,
|
|
5799
6319
|
AppFilterOptionsSchema,
|
|
5800
6320
|
AppProfileSchema,
|
|
5801
6321
|
AppRevisionDetailResponseSchema,
|
|
@@ -5809,10 +6329,16 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5809
6329
|
CertificateIssuerSchema,
|
|
5810
6330
|
CertificateSchema,
|
|
5811
6331
|
CertificateSubjectSchema,
|
|
6332
|
+
CheckAppCvmsIsAllowedRequestSchema,
|
|
6333
|
+
CheckAppIsAllowedRequestSchema,
|
|
6334
|
+
CheckCvmIsAllowedRequestSchema,
|
|
5812
6335
|
CommitCvmComposeFileUpdateRequestSchema,
|
|
5813
6336
|
CommitCvmComposeFileUpdateSchema,
|
|
5814
6337
|
CommitCvmProvisionRequestSchema,
|
|
5815
6338
|
CommitCvmProvisionSchema,
|
|
6339
|
+
CommitCvmUpdateRequestSchema,
|
|
6340
|
+
ConfirmCvmPatchRequestSchema,
|
|
6341
|
+
CreateAppInstanceRequestSchema,
|
|
5816
6342
|
CreateSshKeyRequestSchema,
|
|
5817
6343
|
CreditsInfoSchema,
|
|
5818
6344
|
CurrentUserSchema,
|
|
@@ -5854,6 +6380,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5854
6380
|
DstackAppMinimalResponseV20260121Schema,
|
|
5855
6381
|
DstackAppWithCvmResponseV20251028Schema,
|
|
5856
6382
|
DstackAppWithCvmResponseV20260121Schema,
|
|
6383
|
+
ErrorCodes,
|
|
5857
6384
|
EventLogSchema,
|
|
5858
6385
|
FamilyGroupSchema,
|
|
5859
6386
|
FamilyInstanceTypesResponseSchema,
|
|
@@ -5895,6 +6422,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5895
6422
|
ImportGithubProfileResponseSchema,
|
|
5896
6423
|
InstanceIdRefreshResultSchema,
|
|
5897
6424
|
InstanceTypeSchema,
|
|
6425
|
+
IsAllowedResultSchema,
|
|
5898
6426
|
KmsInfoSchema,
|
|
5899
6427
|
KmsTypeSchema,
|
|
5900
6428
|
ListFamilyInstanceTypesRequestSchema,
|
|
@@ -5918,6 +6446,8 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5918
6446
|
PaginatedCvmInfosV20251028Schema,
|
|
5919
6447
|
PaginatedCvmInfosV20260121Schema,
|
|
5920
6448
|
PaginationMetadataSchema,
|
|
6449
|
+
PatchCvmRequestSchema,
|
|
6450
|
+
PatchCvmResultSchema,
|
|
5921
6451
|
PhalaCloudError,
|
|
5922
6452
|
ProvisionCvmComposeFileUpdateRequestSchema,
|
|
5923
6453
|
ProvisionCvmComposeFileUpdateResultSchema,
|
|
@@ -5971,12 +6501,20 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
5971
6501
|
addNetwork,
|
|
5972
6502
|
asHex,
|
|
5973
6503
|
autoCreateClients,
|
|
6504
|
+
checkAppCvmsIsAllowed,
|
|
6505
|
+
checkAppIsAllowed,
|
|
5974
6506
|
checkBalance,
|
|
6507
|
+
checkComposeHashAllowed,
|
|
6508
|
+
checkCvmIsAllowed,
|
|
5975
6509
|
checkDeviceAllowed,
|
|
5976
6510
|
checkNetworkStatus,
|
|
6511
|
+
checkOnChainPrerequisites,
|
|
5977
6512
|
commitCvmComposeFileUpdate,
|
|
5978
6513
|
commitCvmProvision,
|
|
6514
|
+
commitCvmUpdate,
|
|
6515
|
+
confirmCvmPatch,
|
|
5979
6516
|
convertToHostname,
|
|
6517
|
+
createAppInstance,
|
|
5980
6518
|
createBaseClient,
|
|
5981
6519
|
createClient,
|
|
5982
6520
|
createClientsFromBrowser,
|
|
@@ -6038,6 +6576,8 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
6038
6576
|
getWorkspaceNodes,
|
|
6039
6577
|
getWorkspaceQuotas,
|
|
6040
6578
|
importGithubProfileSshKeys,
|
|
6579
|
+
isAppIdConflictError,
|
|
6580
|
+
isConflictError,
|
|
6041
6581
|
isValidHostname,
|
|
6042
6582
|
listAllInstanceTypeFamilies,
|
|
6043
6583
|
listFamilyInstanceTypes,
|
|
@@ -6047,6 +6587,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
6047
6587
|
parseApiError,
|
|
6048
6588
|
parseEnv,
|
|
6049
6589
|
parseEnvVars,
|
|
6590
|
+
patchCvm,
|
|
6050
6591
|
preprocessAppCompose,
|
|
6051
6592
|
provisionCvm,
|
|
6052
6593
|
provisionCvmComposeFileUpdate,
|
|
@@ -6058,9 +6599,17 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
6058
6599
|
restartCvm,
|
|
6059
6600
|
safeAddComposeHash,
|
|
6060
6601
|
safeAddDevice,
|
|
6602
|
+
safeCheckAppCvmsIsAllowed,
|
|
6603
|
+
safeCheckAppIsAllowed,
|
|
6604
|
+
safeCheckComposeHashAllowed,
|
|
6605
|
+
safeCheckCvmIsAllowed,
|
|
6061
6606
|
safeCheckDeviceAllowed,
|
|
6607
|
+
safeCheckOnChainPrerequisites,
|
|
6062
6608
|
safeCommitCvmComposeFileUpdate,
|
|
6063
6609
|
safeCommitCvmProvision,
|
|
6610
|
+
safeCommitCvmUpdate,
|
|
6611
|
+
safeConfirmCvmPatch,
|
|
6612
|
+
safeCreateAppInstance,
|
|
6064
6613
|
safeCreateSshKey,
|
|
6065
6614
|
safeDeleteCvm,
|
|
6066
6615
|
safeDeleteSshKey,
|
|
@@ -6103,6 +6652,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
6103
6652
|
safeListSshKeys,
|
|
6104
6653
|
safeListWorkspaces,
|
|
6105
6654
|
safeNextAppIds,
|
|
6655
|
+
safePatchCvm,
|
|
6106
6656
|
safeProvisionCvm,
|
|
6107
6657
|
safeProvisionCvmComposeFileUpdate,
|
|
6108
6658
|
safeRefreshCvmInstanceId,
|