@phala/cloud 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/cvms/get_cvm_init_scripts.d.ts +6 -1
- package/dist/actions/cvms/log-time.d.ts +5 -0
- package/dist/actions/cvms/logs.d.ts +64 -0
- package/dist/actions/cvms/patch_cvm.d.ts +7 -0
- package/dist/actions/cvms/provision_cvm.d.ts +3 -0
- package/dist/actions/cvms/put_cvm_init_scripts.d.ts +150 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/create-client.d.ts +129 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1066 -344
- package/dist/index.mjs +1052 -344
- package/dist/types/app_info_v20260121.d.ts +12 -0
- package/dist/types/cvm_info_v20251028.d.ts +1 -1
- package/dist/types/cvm_info_v20260121.d.ts +7 -0
- package/dist/user-agent.d.ts +30 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -192,6 +192,7 @@ __export(index_exports, {
|
|
|
192
192
|
ListKmsContractsSchema: () => ListKmsContractsSchema,
|
|
193
193
|
ListSshKeysResponseSchema: () => ListSshKeysResponseSchema,
|
|
194
194
|
ListWorkspacesSchema: () => ListWorkspacesSchema,
|
|
195
|
+
LogAccessError: () => LogAccessError,
|
|
195
196
|
LooseAppComposeSchema: () => LooseAppComposeSchema,
|
|
196
197
|
MAX_COMPOSE_PAYLOAD_BYTES: () => MAX_COMPOSE_PAYLOAD_BYTES,
|
|
197
198
|
MAX_INIT_SCRIPTS: () => MAX_INIT_SCRIPTS,
|
|
@@ -222,6 +223,7 @@ __export(index_exports, {
|
|
|
222
223
|
ProvisionCvmComposeFileUpdateResultSchema: () => ProvisionCvmComposeFileUpdateResultSchema,
|
|
223
224
|
ProvisionCvmRequestSchema: () => ProvisionCvmRequestSchema,
|
|
224
225
|
ProvisionCvmSchema: () => ProvisionCvmSchema,
|
|
226
|
+
PutCvmInitScriptsRequestSchema: () => PutCvmInitScriptsRequestSchema,
|
|
225
227
|
QuotaMetricSchema: () => QuotaMetricSchema,
|
|
226
228
|
RefreshCvmInstanceIdRequestSchema: () => RefreshCvmInstanceIdRequestSchema,
|
|
227
229
|
RefreshCvmInstanceIdsRequestSchema: () => RefreshCvmInstanceIdsRequestSchema,
|
|
@@ -318,6 +320,11 @@ __export(index_exports, {
|
|
|
318
320
|
executeTransaction: () => executeTransaction,
|
|
319
321
|
executeTransactionWithRetry: () => executeTransactionWithRetry,
|
|
320
322
|
extractNetworkClients: () => extractNetworkClients,
|
|
323
|
+
fetchContainerLogs: () => fetchContainerLogs,
|
|
324
|
+
fetchContainerLogsEntries: () => fetchContainerLogsEntries,
|
|
325
|
+
fetchCvmChannelLogs: () => fetchCvmChannelLogs,
|
|
326
|
+
fetchCvmLogs: () => fetchCvmLogs,
|
|
327
|
+
followCvmLogs: () => followCvmLogs,
|
|
321
328
|
formatErrorMessage: () => formatErrorMessage,
|
|
322
329
|
formatStructuredError: () => formatStructuredError,
|
|
323
330
|
formatStructuredErrorDetailValue: () => formatStructuredErrorDetailValue,
|
|
@@ -347,6 +354,7 @@ __export(index_exports, {
|
|
|
347
354
|
getCvmInfo: () => getCvmInfo,
|
|
348
355
|
getCvmInitScripts: () => getCvmInitScripts,
|
|
349
356
|
getCvmList: () => getCvmList,
|
|
357
|
+
getCvmLogEndpoint: () => getCvmLogEndpoint,
|
|
350
358
|
getCvmNetwork: () => getCvmNetwork,
|
|
351
359
|
getCvmPreLaunchScript: () => getCvmPreLaunchScript,
|
|
352
360
|
getCvmSshKeys: () => getCvmSshKeys,
|
|
@@ -388,11 +396,13 @@ __export(index_exports, {
|
|
|
388
396
|
preprocessAppCompose: () => preprocessAppCompose,
|
|
389
397
|
provisionCvm: () => provisionCvm,
|
|
390
398
|
provisionCvmComposeFileUpdate: () => provisionCvmComposeFileUpdate,
|
|
399
|
+
putCvmInitScripts: () => putCvmInitScripts,
|
|
391
400
|
refineCvmId: () => refineCvmId,
|
|
392
401
|
refreshCvmInstanceId: () => refreshCvmInstanceId,
|
|
393
402
|
refreshCvmInstanceIds: () => refreshCvmInstanceIds,
|
|
394
403
|
removeDevice: () => removeDevice,
|
|
395
404
|
replicateCvm: () => replicateCvm,
|
|
405
|
+
resolveLogTimeWindow: () => resolveLogTimeWindow,
|
|
396
406
|
restartCvm: () => restartCvm,
|
|
397
407
|
revokeCurrentApiToken: () => revokeCurrentApiToken,
|
|
398
408
|
safeAddComposeHash: () => safeAddComposeHash,
|
|
@@ -462,6 +472,7 @@ __export(index_exports, {
|
|
|
462
472
|
safePatchCvm: () => safePatchCvm,
|
|
463
473
|
safeProvisionCvm: () => safeProvisionCvm,
|
|
464
474
|
safeProvisionCvmComposeFileUpdate: () => safeProvisionCvmComposeFileUpdate,
|
|
475
|
+
safePutCvmInitScripts: () => safePutCvmInitScripts,
|
|
465
476
|
safeRefreshCvmInstanceId: () => safeRefreshCvmInstanceId,
|
|
466
477
|
safeRefreshCvmInstanceIds: () => safeRefreshCvmInstanceIds,
|
|
467
478
|
safeRemoveDevice: () => safeRemoveDevice,
|
|
@@ -490,6 +501,9 @@ __export(index_exports, {
|
|
|
490
501
|
sortObject: () => sortObject,
|
|
491
502
|
startCvm: () => startCvm,
|
|
492
503
|
stopCvm: () => stopCvm,
|
|
504
|
+
streamContainerLogs: () => streamContainerLogs,
|
|
505
|
+
streamContainerLogsEntries: () => streamContainerLogsEntries,
|
|
506
|
+
streamCvmChannelLogs: () => streamCvmChannelLogs,
|
|
493
507
|
switchToNetwork: () => switchToNetwork,
|
|
494
508
|
syncGithubSshKeys: () => syncGithubSshKeys,
|
|
495
509
|
updateCvmAnnotations: () => updateCvmAnnotations,
|
|
@@ -932,6 +946,34 @@ function isAppIdConflictError(error) {
|
|
|
932
946
|
return error instanceof ResourceError && error.errorCode === "ERR-03-007";
|
|
933
947
|
}
|
|
934
948
|
|
|
949
|
+
// src/user-agent.ts
|
|
950
|
+
function runtimeToken(runtime) {
|
|
951
|
+
const deno = runtime.Deno?.version?.deno;
|
|
952
|
+
if (typeof deno === "string" && deno.length > 0) {
|
|
953
|
+
return `deno/${deno}`;
|
|
954
|
+
}
|
|
955
|
+
const bun = runtime.Bun?.version;
|
|
956
|
+
if (typeof bun === "string" && bun.length > 0) {
|
|
957
|
+
return `bun/${bun}`;
|
|
958
|
+
}
|
|
959
|
+
const node = runtime.process?.versions?.node;
|
|
960
|
+
if (typeof node === "string" && node.length > 0) {
|
|
961
|
+
return `node/${node}`;
|
|
962
|
+
}
|
|
963
|
+
if (runtime.navigator?.userAgent === "Cloudflare-Workers") {
|
|
964
|
+
return "workerd";
|
|
965
|
+
}
|
|
966
|
+
return void 0;
|
|
967
|
+
}
|
|
968
|
+
function defaultUserAgent(runtime = globalThis) {
|
|
969
|
+
if (runtime.window !== void 0 && runtime.document !== void 0) {
|
|
970
|
+
return void 0;
|
|
971
|
+
}
|
|
972
|
+
const product = "phala-cloud-sdk-js/0.6.0";
|
|
973
|
+
const token = runtimeToken(runtime);
|
|
974
|
+
return token ? `${product} ${token}` : product;
|
|
975
|
+
}
|
|
976
|
+
|
|
935
977
|
// src/client.ts
|
|
936
978
|
var SUPPORTED_API_VERSIONS = [
|
|
937
979
|
"2025-10-28",
|
|
@@ -991,6 +1033,10 @@ var Client = class _Client {
|
|
|
991
1033
|
...fetchOptions
|
|
992
1034
|
} = this.config;
|
|
993
1035
|
const requestHeaders = new Headers({ "Content-Type": "application/json" });
|
|
1036
|
+
const userAgent = defaultUserAgent();
|
|
1037
|
+
if (userAgent) {
|
|
1038
|
+
requestHeaders.set("User-Agent", userAgent);
|
|
1039
|
+
}
|
|
994
1040
|
new Headers(headers).forEach((value, key) => requestHeaders.set(key, value));
|
|
995
1041
|
requestHeaders.set("X-Phala-Version", version);
|
|
996
1042
|
if (!useCookieAuth && apiKey) {
|
|
@@ -1542,7 +1588,8 @@ var CvmInfoV20251028Schema = import_zod5.z.object({
|
|
|
1542
1588
|
status: import_zod5.z.string(),
|
|
1543
1589
|
in_progress: import_zod5.z.boolean().default(false),
|
|
1544
1590
|
dapp_dashboard_url: import_zod5.z.string().nullable(),
|
|
1545
|
-
|
|
1591
|
+
/** Presigned serial log URL; expires shortly after it is issued. */
|
|
1592
|
+
syslog_endpoint: import_zod5.z.string().nullable().describe("Presigned serial log URL that expires shortly after issuance."),
|
|
1546
1593
|
allow_upgrade: import_zod5.z.boolean().default(false),
|
|
1547
1594
|
project_id: import_zod5.z.string().nullable(),
|
|
1548
1595
|
project_type: import_zod5.z.string().nullable(),
|
|
@@ -1579,7 +1626,8 @@ var CvmDetailV20251028Schema = import_zod5.z.object({
|
|
|
1579
1626
|
public_logs: import_zod5.z.boolean().optional().default(false),
|
|
1580
1627
|
managed_env: import_zod5.z.boolean().optional().default(false),
|
|
1581
1628
|
dapp_dashboard_url: import_zod5.z.string().optional().nullable(),
|
|
1582
|
-
|
|
1629
|
+
/** Presigned serial log URL; expires shortly after it is issued. */
|
|
1630
|
+
syslog_endpoint: import_zod5.z.string().nullable().optional().describe("Optional presigned serial log URL that expires shortly after issuance."),
|
|
1583
1631
|
kms_info: KmsInfoSchema.optional().nullable(),
|
|
1584
1632
|
contract_address: import_zod5.z.string().optional().nullable(),
|
|
1585
1633
|
deployer_address: import_zod5.z.string().optional().nullable(),
|
|
@@ -1678,10 +1726,18 @@ var CvmGatewayInfoV20260121Schema = import_zod6.z.object({
|
|
|
1678
1726
|
cname: import_zod6.z.string().nullable().optional()
|
|
1679
1727
|
});
|
|
1680
1728
|
var CvmLogUrlsV20260121Schema = import_zod6.z.object({
|
|
1681
|
-
serial
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1729
|
+
/** Presigned serial log URL; expires shortly after it is issued. */
|
|
1730
|
+
serial: import_zod6.z.string().nullable().optional().describe("Optional presigned serial log URL that expires shortly after issuance."),
|
|
1731
|
+
/** Presigned stdout log URL; expires shortly after it is issued. */
|
|
1732
|
+
stdout: import_zod6.z.string().nullable().optional().describe("Optional presigned stdout log URL that expires shortly after issuance."),
|
|
1733
|
+
/** Presigned stderr log URL; expires shortly after it is issued. */
|
|
1734
|
+
stderr: import_zod6.z.string().nullable().optional().describe("Optional presigned stderr log URL that expires shortly after issuance."),
|
|
1735
|
+
/** Container URL base without query; present only when public logs and a VM UUID exist. */
|
|
1736
|
+
container_log_base: import_zod6.z.string().nullable().optional().describe("Optional container log URL base without query parameters."),
|
|
1737
|
+
/** Container URL auth query; present only when public logs and a VM UUID exist. */
|
|
1738
|
+
auth_query: import_zod6.z.string().nullable().optional().describe(
|
|
1739
|
+
"Optional container log auth query; null when public logs or VM UUID are unavailable."
|
|
1740
|
+
)
|
|
1685
1741
|
});
|
|
1686
1742
|
var DeviceIdEntrySchema = import_zod6.z.object({
|
|
1687
1743
|
device_id: import_zod6.z.string(),
|
|
@@ -2288,7 +2344,9 @@ var ProvisionCvmRequestSchema = import_zod10.z.object({
|
|
|
2288
2344
|
storage_discard: import_zod10.z.boolean().nullable().optional(),
|
|
2289
2345
|
event_log_version: import_zod10.z.union([import_zod10.z.literal(1), import_zod10.z.literal(2)]).nullable().optional(),
|
|
2290
2346
|
snapshotter: import_zod10.z.enum(["overlayfs", "stargz"]).nullable().optional(),
|
|
2291
|
-
verity_volumes: import_zod10.z.array(VerityVolumeSchema).nullable().optional()
|
|
2347
|
+
verity_volumes: import_zod10.z.array(VerityVolumeSchema).nullable().optional(),
|
|
2348
|
+
// Raw guest init scripts. Platform slugs use init_scripts instead.
|
|
2349
|
+
init_script: import_zod10.z.union([import_zod10.z.string(), import_zod10.z.array(import_zod10.z.string())]).optional()
|
|
2292
2350
|
}).passthrough().superRefine((data, ctx) => {
|
|
2293
2351
|
validateComposePayloadSize(data.docker_compose_file, data.pre_launch_script, ctx);
|
|
2294
2352
|
}).optional(),
|
|
@@ -5695,7 +5753,8 @@ var ContainerInfoSchema = import_zod43.z.object({
|
|
|
5695
5753
|
created: import_zod43.z.number(),
|
|
5696
5754
|
state: import_zod43.z.string(),
|
|
5697
5755
|
status: import_zod43.z.string(),
|
|
5698
|
-
|
|
5756
|
+
/** Presigned container log URL that expires shortly after it is issued. */
|
|
5757
|
+
log_endpoint: import_zod43.z.string().nullable().describe("Presigned container log URL that expires shortly after issuance.")
|
|
5699
5758
|
});
|
|
5700
5759
|
var CvmContainersStatsSchema = import_zod43.z.object({
|
|
5701
5760
|
is_online: import_zod43.z.boolean(),
|
|
@@ -6113,6 +6172,8 @@ var PatchCvmRequestSchema = refineCvmId(
|
|
|
6113
6172
|
compose: ComposePatchSchema.optional(),
|
|
6114
6173
|
// Platform init scripts this CVM runs, replacing the current set
|
|
6115
6174
|
init_scripts: import_zod49.z.array(InitScriptSlugSchema).optional(),
|
|
6175
|
+
// Raw guest init scripts, replacing the current set. System admins only.
|
|
6176
|
+
init_script: import_zod49.z.array(import_zod49.z.string()).optional(),
|
|
6116
6177
|
// Confirms turning on docker_cleanup or requirements.ephemeral_data_disk,
|
|
6117
6178
|
// which erase data on every boot
|
|
6118
6179
|
confirm_data_wipe: import_zod49.z.boolean().optional(),
|
|
@@ -6848,7 +6909,8 @@ var CvmInitScriptSchema = import_zod66.z.object({
|
|
|
6848
6909
|
reason: import_zod66.z.string().nullable().optional()
|
|
6849
6910
|
});
|
|
6850
6911
|
var CvmInitScriptsSchema = import_zod66.z.object({
|
|
6851
|
-
items: import_zod66.z.array(CvmInitScriptSchema)
|
|
6912
|
+
items: import_zod66.z.array(CvmInitScriptSchema),
|
|
6913
|
+
has_custom_scripts: import_zod66.z.boolean()
|
|
6852
6914
|
});
|
|
6853
6915
|
var GetCvmInitScriptsRequestSchema = CvmIdSchema;
|
|
6854
6916
|
var { action: getCvmInitScripts, safeAction: safeGetCvmInitScripts } = defineAction(CvmInitScriptsSchema, async (client, request) => {
|
|
@@ -6856,22 +6918,78 @@ var { action: getCvmInitScripts, safeAction: safeGetCvmInitScripts } = defineAct
|
|
|
6856
6918
|
return await client.get(`/cvms/${cvmId}/init-scripts`);
|
|
6857
6919
|
});
|
|
6858
6920
|
|
|
6859
|
-
// src/actions/
|
|
6921
|
+
// src/actions/cvms/put_cvm_init_scripts.ts
|
|
6860
6922
|
var import_zod67 = require("zod");
|
|
6861
|
-
var
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6923
|
+
var PutCvmInitScriptsRequestSchema = refineCvmId(
|
|
6924
|
+
CvmIdObjectSchema.extend({
|
|
6925
|
+
scripts: import_zod67.z.array(import_zod67.z.string()).max(5),
|
|
6926
|
+
prepareOnly: import_zod67.z.boolean().optional()
|
|
6927
|
+
})
|
|
6928
|
+
);
|
|
6929
|
+
function extractDetailsMap2(detail) {
|
|
6930
|
+
const map = {};
|
|
6931
|
+
if (!detail || typeof detail !== "object") return map;
|
|
6932
|
+
const obj = detail;
|
|
6933
|
+
const details = obj.details;
|
|
6934
|
+
if (!Array.isArray(details)) return map;
|
|
6935
|
+
for (const item of details) {
|
|
6936
|
+
if (item && typeof item === "object" && "field" in item && "value" in item) {
|
|
6937
|
+
map[item.field] = item.value;
|
|
6938
|
+
}
|
|
6939
|
+
}
|
|
6940
|
+
return map;
|
|
6941
|
+
}
|
|
6942
|
+
var { action: putCvmInitScripts, safeAction: safePutCvmInitScripts } = defineAction(PatchCvmResultSchema, async (client, request) => {
|
|
6943
|
+
const parsed = PutCvmInitScriptsRequestSchema.parse(request);
|
|
6944
|
+
const { cvmId } = CvmIdSchema.parse(parsed);
|
|
6945
|
+
try {
|
|
6946
|
+
const response = parsed.prepareOnly ? await client.put(
|
|
6947
|
+
`/cvms/${cvmId}/init-scripts`,
|
|
6948
|
+
{ scripts: parsed.scripts },
|
|
6949
|
+
{ headers: { "X-Prepare-Only": "true" } }
|
|
6950
|
+
) : await client.put(
|
|
6951
|
+
`/cvms/${cvmId}/init-scripts`,
|
|
6952
|
+
{ scripts: parsed.scripts }
|
|
6953
|
+
);
|
|
6954
|
+
return {
|
|
6955
|
+
requiresOnChainHash: false,
|
|
6956
|
+
correlationId: response.correlation_id ?? ""
|
|
6957
|
+
};
|
|
6958
|
+
} catch (error) {
|
|
6959
|
+
if (error instanceof PhalaCloudError && error.status === 465) {
|
|
6960
|
+
const details = extractDetailsMap2(error.detail);
|
|
6961
|
+
return {
|
|
6962
|
+
requiresOnChainHash: true,
|
|
6963
|
+
composeHash: details.compose_hash,
|
|
6964
|
+
appId: String(details.app_id),
|
|
6965
|
+
deviceId: details.device_id,
|
|
6966
|
+
kmsInfo: details.kms_info,
|
|
6967
|
+
commitToken: details.commit_token,
|
|
6968
|
+
commitUrl: details.commit_url,
|
|
6969
|
+
apiCommitUrl: details.api_commit_url,
|
|
6970
|
+
onchainStatus: details.onchain_status
|
|
6971
|
+
};
|
|
6972
|
+
}
|
|
6973
|
+
throw error;
|
|
6974
|
+
}
|
|
6975
|
+
});
|
|
6976
|
+
|
|
6977
|
+
// src/actions/ssh_keys/list_ssh_keys.ts
|
|
6978
|
+
var import_zod68 = require("zod");
|
|
6979
|
+
var SshKeySchema = import_zod68.z.object({
|
|
6980
|
+
id: import_zod68.z.string(),
|
|
6981
|
+
user_id: import_zod68.z.string(),
|
|
6982
|
+
name: import_zod68.z.string(),
|
|
6983
|
+
public_key: import_zod68.z.string(),
|
|
6984
|
+
fingerprint: import_zod68.z.string(),
|
|
6985
|
+
key_type: import_zod68.z.string(),
|
|
6986
|
+
source: import_zod68.z.string(),
|
|
6987
|
+
key_metadata: import_zod68.z.record(import_zod68.z.string(), import_zod68.z.unknown()).nullable().optional(),
|
|
6988
|
+
last_synced_at: import_zod68.z.string().nullable().optional(),
|
|
6989
|
+
created_at: import_zod68.z.string(),
|
|
6990
|
+
updated_at: import_zod68.z.string()
|
|
6991
|
+
});
|
|
6992
|
+
var ListSshKeysResponseSchema = import_zod68.z.array(SshKeySchema);
|
|
6875
6993
|
async function listSshKeys(client) {
|
|
6876
6994
|
const response = await client.get("/user/ssh-keys");
|
|
6877
6995
|
return ListSshKeysResponseSchema.parse(response);
|
|
@@ -6895,15 +7013,15 @@ async function safeListSshKeys(client) {
|
|
|
6895
7013
|
}
|
|
6896
7014
|
|
|
6897
7015
|
// src/actions/ssh_keys/import_github_profile.ts
|
|
6898
|
-
var
|
|
6899
|
-
var ImportGithubProfileRequestSchema =
|
|
6900
|
-
github_username:
|
|
7016
|
+
var import_zod69 = require("zod");
|
|
7017
|
+
var ImportGithubProfileRequestSchema = import_zod69.z.object({
|
|
7018
|
+
github_username: import_zod69.z.string().min(1)
|
|
6901
7019
|
});
|
|
6902
|
-
var ImportGithubProfileResponseSchema =
|
|
6903
|
-
github_username:
|
|
6904
|
-
keys_added:
|
|
6905
|
-
keys_skipped:
|
|
6906
|
-
errors:
|
|
7020
|
+
var ImportGithubProfileResponseSchema = import_zod69.z.object({
|
|
7021
|
+
github_username: import_zod69.z.string(),
|
|
7022
|
+
keys_added: import_zod69.z.number().int(),
|
|
7023
|
+
keys_skipped: import_zod69.z.number().int(),
|
|
7024
|
+
errors: import_zod69.z.array(import_zod69.z.string()).default([])
|
|
6907
7025
|
});
|
|
6908
7026
|
var { action: importGithubProfileSshKeys, safeAction: safeImportGithubProfileSshKeys } = defineAction(
|
|
6909
7027
|
ImportGithubProfileResponseSchema,
|
|
@@ -6914,10 +7032,10 @@ var { action: importGithubProfileSshKeys, safeAction: safeImportGithubProfileSsh
|
|
|
6914
7032
|
);
|
|
6915
7033
|
|
|
6916
7034
|
// src/actions/ssh_keys/create_ssh_key.ts
|
|
6917
|
-
var
|
|
6918
|
-
var CreateSshKeyRequestSchema =
|
|
6919
|
-
name:
|
|
6920
|
-
public_key:
|
|
7035
|
+
var import_zod70 = require("zod");
|
|
7036
|
+
var CreateSshKeyRequestSchema = import_zod70.z.object({
|
|
7037
|
+
name: import_zod70.z.string().min(1),
|
|
7038
|
+
public_key: import_zod70.z.string().min(1)
|
|
6921
7039
|
});
|
|
6922
7040
|
var { action: createSshKey, safeAction: safeCreateSshKey } = defineAction(SshKeySchema, async (client, request) => {
|
|
6923
7041
|
const { name, public_key } = CreateSshKeyRequestSchema.parse(request);
|
|
@@ -6925,24 +7043,24 @@ var { action: createSshKey, safeAction: safeCreateSshKey } = defineAction(SshKey
|
|
|
6925
7043
|
});
|
|
6926
7044
|
|
|
6927
7045
|
// src/actions/ssh_keys/delete_ssh_key.ts
|
|
6928
|
-
var
|
|
6929
|
-
var DeleteSshKeyRequestSchema =
|
|
6930
|
-
keyId:
|
|
7046
|
+
var import_zod71 = require("zod");
|
|
7047
|
+
var DeleteSshKeyRequestSchema = import_zod71.z.object({
|
|
7048
|
+
keyId: import_zod71.z.string().min(1)
|
|
6931
7049
|
});
|
|
6932
|
-
var { action: deleteSshKey, safeAction: safeDeleteSshKey } = defineAction(
|
|
7050
|
+
var { action: deleteSshKey, safeAction: safeDeleteSshKey } = defineAction(import_zod71.z.void(), async (client, request) => {
|
|
6933
7051
|
const { keyId } = DeleteSshKeyRequestSchema.parse(request);
|
|
6934
7052
|
await client.delete(`/user/ssh-keys/${keyId}`);
|
|
6935
7053
|
return void 0;
|
|
6936
7054
|
});
|
|
6937
7055
|
|
|
6938
7056
|
// src/actions/ssh_keys/sync_github_ssh_keys.ts
|
|
6939
|
-
var
|
|
6940
|
-
var SyncGithubSshKeysResponseSchema =
|
|
6941
|
-
synced_count:
|
|
6942
|
-
keys_added:
|
|
6943
|
-
keys_updated:
|
|
6944
|
-
keys_removed:
|
|
6945
|
-
errors:
|
|
7057
|
+
var import_zod72 = require("zod");
|
|
7058
|
+
var SyncGithubSshKeysResponseSchema = import_zod72.z.object({
|
|
7059
|
+
synced_count: import_zod72.z.number().int(),
|
|
7060
|
+
keys_added: import_zod72.z.number().int(),
|
|
7061
|
+
keys_updated: import_zod72.z.number().int(),
|
|
7062
|
+
keys_removed: import_zod72.z.number().int(),
|
|
7063
|
+
errors: import_zod72.z.array(import_zod72.z.string()).default([])
|
|
6946
7064
|
});
|
|
6947
7065
|
var { action: syncGithubSshKeys, safeAction: safeSyncGithubSshKeys } = defineSimpleAction(
|
|
6948
7066
|
SyncGithubSshKeysResponseSchema,
|
|
@@ -6952,20 +7070,20 @@ var { action: syncGithubSshKeys, safeAction: safeSyncGithubSshKeys } = defineSim
|
|
|
6952
7070
|
);
|
|
6953
7071
|
|
|
6954
7072
|
// src/actions/ssh_keys/get_cvm_ssh_keys.ts
|
|
6955
|
-
var
|
|
6956
|
-
var CvmSshKeySchema =
|
|
6957
|
-
id:
|
|
6958
|
-
owner_user_id:
|
|
6959
|
-
owner_username:
|
|
6960
|
-
added_by_user_id:
|
|
6961
|
-
name:
|
|
6962
|
-
public_key:
|
|
6963
|
-
fingerprint:
|
|
6964
|
-
key_type:
|
|
6965
|
-
});
|
|
6966
|
-
var CvmSshKeysResponseSchema =
|
|
6967
|
-
keys:
|
|
6968
|
-
restart_required:
|
|
7073
|
+
var import_zod73 = require("zod");
|
|
7074
|
+
var CvmSshKeySchema = import_zod73.z.object({
|
|
7075
|
+
id: import_zod73.z.string(),
|
|
7076
|
+
owner_user_id: import_zod73.z.string(),
|
|
7077
|
+
owner_username: import_zod73.z.string(),
|
|
7078
|
+
added_by_user_id: import_zod73.z.string(),
|
|
7079
|
+
name: import_zod73.z.string(),
|
|
7080
|
+
public_key: import_zod73.z.string(),
|
|
7081
|
+
fingerprint: import_zod73.z.string(),
|
|
7082
|
+
key_type: import_zod73.z.string()
|
|
7083
|
+
});
|
|
7084
|
+
var CvmSshKeysResponseSchema = import_zod73.z.object({
|
|
7085
|
+
keys: import_zod73.z.array(CvmSshKeySchema),
|
|
7086
|
+
restart_required: import_zod73.z.boolean()
|
|
6969
7087
|
});
|
|
6970
7088
|
var GetCvmSshKeysRequestSchema = CvmIdSchema;
|
|
6971
7089
|
var { action: getCvmSshKeys, safeAction: safeGetCvmSshKeys } = defineAction(CvmSshKeysResponseSchema, async (client, request) => {
|
|
@@ -6974,12 +7092,12 @@ var { action: getCvmSshKeys, safeAction: safeGetCvmSshKeys } = defineAction(CvmS
|
|
|
6974
7092
|
});
|
|
6975
7093
|
|
|
6976
7094
|
// src/actions/ssh_keys/update_cvm_ssh_keys.ts
|
|
6977
|
-
var
|
|
7095
|
+
var import_zod74 = require("zod");
|
|
6978
7096
|
var UpdateCvmSshKeysRequestSchema = refineCvmId(
|
|
6979
7097
|
CvmIdObjectSchema.extend({
|
|
6980
|
-
ssh_key_ids:
|
|
6981
|
-
usernames:
|
|
6982
|
-
apply_now:
|
|
7098
|
+
ssh_key_ids: import_zod74.z.array(import_zod74.z.string()),
|
|
7099
|
+
usernames: import_zod74.z.array(import_zod74.z.string()).optional(),
|
|
7100
|
+
apply_now: import_zod74.z.boolean().optional()
|
|
6983
7101
|
})
|
|
6984
7102
|
);
|
|
6985
7103
|
var { action: updateCvmSshKeys, safeAction: safeUpdateCvmSshKeys } = defineAction(CvmSshKeysResponseSchema, async (client, request) => {
|
|
@@ -6993,9 +7111,9 @@ var { action: updateCvmSshKeys, safeAction: safeUpdateCvmSshKeys } = defineActio
|
|
|
6993
7111
|
});
|
|
6994
7112
|
|
|
6995
7113
|
// src/actions/api_tokens/revoke_current_api_token.ts
|
|
6996
|
-
var
|
|
7114
|
+
var import_zod75 = require("zod");
|
|
6997
7115
|
var { action: revokeCurrentApiToken, safeAction: safeRevokeCurrentApiToken } = defineSimpleAction(
|
|
6998
|
-
|
|
7116
|
+
import_zod75.z.void(),
|
|
6999
7117
|
async (client) => {
|
|
7000
7118
|
await client.delete("/tokens/self");
|
|
7001
7119
|
return void 0;
|
|
@@ -7003,34 +7121,34 @@ var { action: revokeCurrentApiToken, safeAction: safeRevokeCurrentApiToken } = d
|
|
|
7003
7121
|
);
|
|
7004
7122
|
|
|
7005
7123
|
// src/actions/cvms/check_cvm_is_allowed.ts
|
|
7006
|
-
var
|
|
7007
|
-
var IsAllowedResultBaseSchema =
|
|
7008
|
-
app_contract_address:
|
|
7009
|
-
compose_hash:
|
|
7010
|
-
device_id:
|
|
7011
|
-
compose_hash_allowed:
|
|
7012
|
-
allow_any_device:
|
|
7013
|
-
device_id_allowed:
|
|
7014
|
-
is_allowed:
|
|
7015
|
-
error:
|
|
7124
|
+
var import_zod76 = require("zod");
|
|
7125
|
+
var IsAllowedResultBaseSchema = import_zod76.z.object({
|
|
7126
|
+
app_contract_address: import_zod76.z.string(),
|
|
7127
|
+
compose_hash: import_zod76.z.string(),
|
|
7128
|
+
device_id: import_zod76.z.string(),
|
|
7129
|
+
compose_hash_allowed: import_zod76.z.boolean(),
|
|
7130
|
+
allow_any_device: import_zod76.z.boolean(),
|
|
7131
|
+
device_id_allowed: import_zod76.z.boolean().nullable().optional(),
|
|
7132
|
+
is_allowed: import_zod76.z.boolean(),
|
|
7133
|
+
error: import_zod76.z.string().nullable().optional()
|
|
7016
7134
|
});
|
|
7017
7135
|
var IsAllowedResultV20260121Schema = IsAllowedResultBaseSchema.extend({
|
|
7018
|
-
cvm_id:
|
|
7136
|
+
cvm_id: import_zod76.z.number().optional()
|
|
7019
7137
|
});
|
|
7020
7138
|
var IsAllowedResultV20260522Schema = IsAllowedResultBaseSchema.extend({
|
|
7021
|
-
cvm_id:
|
|
7139
|
+
cvm_id: import_zod76.z.string().optional()
|
|
7022
7140
|
});
|
|
7023
|
-
var IsAllowedResultAnySchema =
|
|
7141
|
+
var IsAllowedResultAnySchema = import_zod76.z.union([
|
|
7024
7142
|
IsAllowedResultV20260121Schema,
|
|
7025
7143
|
IsAllowedResultV20260522Schema
|
|
7026
7144
|
]);
|
|
7027
7145
|
var IsAllowedResultSchema = IsAllowedResultV20260522Schema;
|
|
7028
7146
|
var CheckCvmIsAllowedInputSchema = placementRequest(
|
|
7029
|
-
|
|
7030
|
-
cvmId:
|
|
7031
|
-
compose_hash:
|
|
7032
|
-
node:
|
|
7033
|
-
device_id:
|
|
7147
|
+
import_zod76.z.object({
|
|
7148
|
+
cvmId: import_zod76.z.string().min(1),
|
|
7149
|
+
compose_hash: import_zod76.z.string().optional(),
|
|
7150
|
+
node: import_zod76.z.string().min(1).optional(),
|
|
7151
|
+
device_id: import_zod76.z.string().optional()
|
|
7034
7152
|
})
|
|
7035
7153
|
);
|
|
7036
7154
|
var CheckCvmIsAllowedRequestSchema = CheckCvmIsAllowedInputSchema;
|
|
@@ -7062,14 +7180,14 @@ async function safeCheckCvmIsAllowed(client, request) {
|
|
|
7062
7180
|
}
|
|
7063
7181
|
|
|
7064
7182
|
// src/actions/apps/check_app_is_allowed.ts
|
|
7065
|
-
var
|
|
7183
|
+
var import_zod77 = require("zod");
|
|
7066
7184
|
var CheckAppIsAllowedRequestSchema = placementRequest(
|
|
7067
|
-
|
|
7068
|
-
appId:
|
|
7069
|
-
compose_hash:
|
|
7070
|
-
node:
|
|
7071
|
-
device_id:
|
|
7072
|
-
chain_id:
|
|
7185
|
+
import_zod77.z.object({
|
|
7186
|
+
appId: import_zod77.z.string().min(1),
|
|
7187
|
+
compose_hash: import_zod77.z.string(),
|
|
7188
|
+
node: import_zod77.z.string().min(1).optional(),
|
|
7189
|
+
device_id: import_zod77.z.string().optional(),
|
|
7190
|
+
chain_id: import_zod77.z.number().optional()
|
|
7073
7191
|
})
|
|
7074
7192
|
);
|
|
7075
7193
|
var { action: checkAppIsAllowed, safeAction: safeCheckAppIsAllowed } = defineAction(IsAllowedResultSchema, async (client, request) => {
|
|
@@ -7078,29 +7196,29 @@ var { action: checkAppIsAllowed, safeAction: safeCheckAppIsAllowed } = defineAct
|
|
|
7078
7196
|
});
|
|
7079
7197
|
|
|
7080
7198
|
// src/actions/apps/check_app_cvms_is_allowed.ts
|
|
7081
|
-
var
|
|
7082
|
-
var AppCvmsBatchIsAllowedResponseBaseSchema =
|
|
7083
|
-
is_onchain:
|
|
7084
|
-
total:
|
|
7085
|
-
allowed_count:
|
|
7086
|
-
denied_count:
|
|
7087
|
-
error_count:
|
|
7199
|
+
var import_zod78 = require("zod");
|
|
7200
|
+
var AppCvmsBatchIsAllowedResponseBaseSchema = import_zod78.z.object({
|
|
7201
|
+
is_onchain: import_zod78.z.boolean(),
|
|
7202
|
+
total: import_zod78.z.number().default(0),
|
|
7203
|
+
allowed_count: import_zod78.z.number().default(0),
|
|
7204
|
+
denied_count: import_zod78.z.number().default(0),
|
|
7205
|
+
error_count: import_zod78.z.number().default(0)
|
|
7088
7206
|
});
|
|
7089
7207
|
var AppCvmsBatchIsAllowedResponseV20260121Schema = AppCvmsBatchIsAllowedResponseBaseSchema.extend({
|
|
7090
|
-
results:
|
|
7091
|
-
skipped_cvm_ids:
|
|
7208
|
+
results: import_zod78.z.array(IsAllowedResultV20260121Schema.extend({ cvm_id: import_zod78.z.number() })).default([]),
|
|
7209
|
+
skipped_cvm_ids: import_zod78.z.array(import_zod78.z.number()).default([])
|
|
7092
7210
|
});
|
|
7093
7211
|
var AppCvmsBatchIsAllowedResponseV20260522Schema = AppCvmsBatchIsAllowedResponseBaseSchema.extend({
|
|
7094
|
-
results:
|
|
7095
|
-
skipped_cvm_ids:
|
|
7212
|
+
results: import_zod78.z.array(IsAllowedResultV20260522Schema.extend({ cvm_id: import_zod78.z.string() })).default([]),
|
|
7213
|
+
skipped_cvm_ids: import_zod78.z.array(import_zod78.z.string()).default([])
|
|
7096
7214
|
});
|
|
7097
|
-
var AppCvmsBatchIsAllowedResponseAnySchema =
|
|
7215
|
+
var AppCvmsBatchIsAllowedResponseAnySchema = import_zod78.z.union([
|
|
7098
7216
|
AppCvmsBatchIsAllowedResponseV20260121Schema,
|
|
7099
7217
|
AppCvmsBatchIsAllowedResponseV20260522Schema
|
|
7100
7218
|
]);
|
|
7101
7219
|
var AppCvmsBatchIsAllowedResponseSchema = AppCvmsBatchIsAllowedResponseV20260522Schema;
|
|
7102
|
-
var CheckAppCvmsIsAllowedRequestSchema =
|
|
7103
|
-
appId:
|
|
7220
|
+
var CheckAppCvmsIsAllowedRequestSchema = import_zod78.z.object({
|
|
7221
|
+
appId: import_zod78.z.string().min(1)
|
|
7104
7222
|
});
|
|
7105
7223
|
function getSchemaForVersion9(version) {
|
|
7106
7224
|
if (version === "2026-01-21") return AppCvmsBatchIsAllowedResponseV20260121Schema;
|
|
@@ -7132,64 +7250,40 @@ async function safeCheckAppCvmsIsAllowed(client, request) {
|
|
|
7132
7250
|
}
|
|
7133
7251
|
|
|
7134
7252
|
// src/actions/apps/get_app_list.ts
|
|
7135
|
-
var
|
|
7253
|
+
var import_zod81 = require("zod");
|
|
7136
7254
|
|
|
7137
7255
|
// src/types/app_info_v20251028.ts
|
|
7138
|
-
var
|
|
7139
|
-
var CvmBasicInfoV20251028Schema =
|
|
7140
|
-
vm_uuid:
|
|
7141
|
-
app_id:
|
|
7142
|
-
name:
|
|
7143
|
-
status:
|
|
7144
|
-
vcpu:
|
|
7145
|
-
memory:
|
|
7146
|
-
disk_size:
|
|
7147
|
-
teepod_id:
|
|
7148
|
-
teepod_name:
|
|
7149
|
-
region_identifier:
|
|
7150
|
-
kms_type:
|
|
7151
|
-
instance_type:
|
|
7152
|
-
listed:
|
|
7153
|
-
base_image:
|
|
7154
|
-
kms_slug:
|
|
7256
|
+
var import_zod79 = require("zod");
|
|
7257
|
+
var CvmBasicInfoV20251028Schema = import_zod79.z.object({
|
|
7258
|
+
vm_uuid: import_zod79.z.string().nullable(),
|
|
7259
|
+
app_id: import_zod79.z.string(),
|
|
7260
|
+
name: import_zod79.z.string().default(""),
|
|
7261
|
+
status: import_zod79.z.string(),
|
|
7262
|
+
vcpu: import_zod79.z.number().int(),
|
|
7263
|
+
memory: import_zod79.z.number().int(),
|
|
7264
|
+
disk_size: import_zod79.z.number().int(),
|
|
7265
|
+
teepod_id: import_zod79.z.number().int(),
|
|
7266
|
+
teepod_name: import_zod79.z.string(),
|
|
7267
|
+
region_identifier: import_zod79.z.string().nullable().optional(),
|
|
7268
|
+
kms_type: import_zod79.z.string().nullable().optional(),
|
|
7269
|
+
instance_type: import_zod79.z.string().nullable().optional(),
|
|
7270
|
+
listed: import_zod79.z.boolean().nullable().optional(),
|
|
7271
|
+
base_image: import_zod79.z.string().nullable().optional(),
|
|
7272
|
+
kms_slug: import_zod79.z.string().nullable().optional(),
|
|
7155
7273
|
/** @deprecated Identifies a KMS node, not the on-chain KMS contract. Use kms_contract_id. */
|
|
7156
|
-
kms_id:
|
|
7157
|
-
kms_contract_id:
|
|
7158
|
-
instance_id:
|
|
7274
|
+
kms_id: import_zod79.z.string().nullable().optional(),
|
|
7275
|
+
kms_contract_id: import_zod79.z.string().nullable().optional(),
|
|
7276
|
+
instance_id: import_zod79.z.string().nullable().optional(),
|
|
7159
7277
|
machine_info: MachineInfoV20251028Schema.nullable().optional(),
|
|
7160
|
-
updated_at:
|
|
7161
|
-
});
|
|
7162
|
-
var AppProfileSchema = import_zod78.z.object({
|
|
7163
|
-
display_name: import_zod78.z.string().nullable().optional(),
|
|
7164
|
-
avatar_url: import_zod78.z.string().nullable().optional(),
|
|
7165
|
-
description: import_zod78.z.string().nullable().optional(),
|
|
7166
|
-
custom_domain: import_zod78.z.string().nullable().optional()
|
|
7167
|
-
});
|
|
7168
|
-
var DstackAppFullResponseV20251028Schema = import_zod78.z.object({
|
|
7169
|
-
id: import_zod78.z.string(),
|
|
7170
|
-
name: import_zod78.z.string(),
|
|
7171
|
-
app_id: import_zod78.z.string(),
|
|
7172
|
-
app_provision_type: import_zod78.z.string().nullable().optional(),
|
|
7173
|
-
app_icon_url: import_zod78.z.string().nullable().optional(),
|
|
7174
|
-
created_at: import_zod78.z.string(),
|
|
7175
|
-
kms_type: import_zod78.z.string(),
|
|
7176
|
-
profile: AppProfileSchema.nullable().optional(),
|
|
7177
|
-
current_cvm: CvmBasicInfoV20251028Schema.nullable().optional(),
|
|
7178
|
-
cvms: import_zod78.z.array(CvmBasicInfoV20251028Schema).default([]),
|
|
7179
|
-
cvm_count: import_zod78.z.number().int().default(0)
|
|
7278
|
+
updated_at: import_zod79.z.string().nullable().optional()
|
|
7180
7279
|
});
|
|
7181
|
-
var
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
total: import_zod78.z.number().int(),
|
|
7187
|
-
total_pages: import_zod78.z.number().int()
|
|
7280
|
+
var AppProfileSchema = import_zod79.z.object({
|
|
7281
|
+
display_name: import_zod79.z.string().nullable().optional(),
|
|
7282
|
+
avatar_url: import_zod79.z.string().nullable().optional(),
|
|
7283
|
+
description: import_zod79.z.string().nullable().optional(),
|
|
7284
|
+
custom_domain: import_zod79.z.string().nullable().optional()
|
|
7188
7285
|
});
|
|
7189
|
-
|
|
7190
|
-
// src/types/app_info_v20260121.ts
|
|
7191
|
-
var import_zod79 = require("zod");
|
|
7192
|
-
var DstackAppFullResponseV20260121Schema = import_zod79.z.object({
|
|
7286
|
+
var DstackAppFullResponseV20251028Schema = import_zod79.z.object({
|
|
7193
7287
|
id: import_zod79.z.string(),
|
|
7194
7288
|
name: import_zod79.z.string(),
|
|
7195
7289
|
app_id: import_zod79.z.string(),
|
|
@@ -7197,46 +7291,70 @@ var DstackAppFullResponseV20260121Schema = import_zod79.z.object({
|
|
|
7197
7291
|
app_icon_url: import_zod79.z.string().nullable().optional(),
|
|
7198
7292
|
created_at: import_zod79.z.string(),
|
|
7199
7293
|
kms_type: import_zod79.z.string(),
|
|
7200
|
-
profile:
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7294
|
+
profile: AppProfileSchema.nullable().optional(),
|
|
7295
|
+
current_cvm: CvmBasicInfoV20251028Schema.nullable().optional(),
|
|
7296
|
+
cvms: import_zod79.z.array(CvmBasicInfoV20251028Schema).default([]),
|
|
7297
|
+
cvm_count: import_zod79.z.number().int().default(0)
|
|
7298
|
+
});
|
|
7299
|
+
var DstackAppWithCvmResponseV20251028Schema = DstackAppFullResponseV20251028Schema;
|
|
7300
|
+
var DstackAppListResponseV20251028Schema = import_zod79.z.object({
|
|
7301
|
+
dstack_apps: import_zod79.z.array(DstackAppWithCvmResponseV20251028Schema),
|
|
7302
|
+
page: import_zod79.z.number().int(),
|
|
7303
|
+
page_size: import_zod79.z.number().int(),
|
|
7304
|
+
total: import_zod79.z.number().int(),
|
|
7305
|
+
total_pages: import_zod79.z.number().int()
|
|
7306
|
+
});
|
|
7307
|
+
|
|
7308
|
+
// src/types/app_info_v20260121.ts
|
|
7309
|
+
var import_zod80 = require("zod");
|
|
7310
|
+
var DstackAppFullResponseV20260121Schema = import_zod80.z.object({
|
|
7311
|
+
id: import_zod80.z.string(),
|
|
7312
|
+
name: import_zod80.z.string(),
|
|
7313
|
+
app_id: import_zod80.z.string(),
|
|
7314
|
+
app_provision_type: import_zod80.z.string().nullable().optional(),
|
|
7315
|
+
app_icon_url: import_zod80.z.string().nullable().optional(),
|
|
7316
|
+
created_at: import_zod80.z.string(),
|
|
7317
|
+
kms_type: import_zod80.z.string(),
|
|
7318
|
+
profile: import_zod80.z.object({
|
|
7319
|
+
display_name: import_zod80.z.string().nullable().optional(),
|
|
7320
|
+
avatar_url: import_zod80.z.string().nullable().optional(),
|
|
7321
|
+
description: import_zod80.z.string().nullable().optional(),
|
|
7322
|
+
custom_domain: import_zod80.z.string().nullable().optional()
|
|
7205
7323
|
}).nullable().optional(),
|
|
7206
7324
|
current_cvm: CvmInfoV20260121Schema.nullable().optional(),
|
|
7207
|
-
cvms:
|
|
7208
|
-
cvm_count:
|
|
7325
|
+
cvms: import_zod80.z.array(CvmInfoV20260121Schema).default([]),
|
|
7326
|
+
cvm_count: import_zod80.z.number().int().default(0)
|
|
7209
7327
|
});
|
|
7210
7328
|
var DstackAppFullResponseV20260522Schema = DstackAppFullResponseV20260121Schema.extend({
|
|
7211
7329
|
current_cvm: CvmInfoV20260522Schema.nullable().optional(),
|
|
7212
|
-
cvms:
|
|
7330
|
+
cvms: import_zod80.z.array(CvmInfoV20260522Schema).default([])
|
|
7213
7331
|
});
|
|
7214
7332
|
var DstackAppWithCvmResponseV20260121Schema = DstackAppFullResponseV20260121Schema;
|
|
7215
7333
|
var DstackAppWithCvmResponseV20260522Schema = DstackAppFullResponseV20260522Schema;
|
|
7216
|
-
var DstackAppListResponseV20260121Schema =
|
|
7217
|
-
dstack_apps:
|
|
7218
|
-
page:
|
|
7219
|
-
page_size:
|
|
7220
|
-
total:
|
|
7221
|
-
total_pages:
|
|
7334
|
+
var DstackAppListResponseV20260121Schema = import_zod80.z.object({
|
|
7335
|
+
dstack_apps: import_zod80.z.array(DstackAppWithCvmResponseV20260121Schema),
|
|
7336
|
+
page: import_zod80.z.number().int(),
|
|
7337
|
+
page_size: import_zod80.z.number().int(),
|
|
7338
|
+
total: import_zod80.z.number().int(),
|
|
7339
|
+
total_pages: import_zod80.z.number().int()
|
|
7222
7340
|
});
|
|
7223
7341
|
var DstackAppListResponseV20260522Schema = DstackAppListResponseV20260121Schema.extend({
|
|
7224
|
-
dstack_apps:
|
|
7342
|
+
dstack_apps: import_zod80.z.array(DstackAppWithCvmResponseV20260522Schema)
|
|
7225
7343
|
});
|
|
7226
7344
|
|
|
7227
7345
|
// src/actions/apps/get_app_list.ts
|
|
7228
|
-
var GetAppListRequestSchema =
|
|
7229
|
-
page:
|
|
7230
|
-
page_size:
|
|
7231
|
-
search:
|
|
7232
|
-
status:
|
|
7233
|
-
listed:
|
|
7234
|
-
base_image:
|
|
7235
|
-
instance_type:
|
|
7236
|
-
kms_slug:
|
|
7237
|
-
kms_type:
|
|
7238
|
-
node:
|
|
7239
|
-
region:
|
|
7346
|
+
var GetAppListRequestSchema = import_zod81.z.object({
|
|
7347
|
+
page: import_zod81.z.number().int().min(1).optional(),
|
|
7348
|
+
page_size: import_zod81.z.number().int().min(1).max(100).optional(),
|
|
7349
|
+
search: import_zod81.z.string().optional(),
|
|
7350
|
+
status: import_zod81.z.array(import_zod81.z.string()).optional(),
|
|
7351
|
+
listed: import_zod81.z.boolean().optional(),
|
|
7352
|
+
base_image: import_zod81.z.string().optional(),
|
|
7353
|
+
instance_type: import_zod81.z.string().optional(),
|
|
7354
|
+
kms_slug: import_zod81.z.string().optional(),
|
|
7355
|
+
kms_type: import_zod81.z.string().optional(),
|
|
7356
|
+
node: import_zod81.z.string().optional(),
|
|
7357
|
+
region: import_zod81.z.string().optional()
|
|
7240
7358
|
}).strict();
|
|
7241
7359
|
function getSchemaForVersion10(version) {
|
|
7242
7360
|
if (version === "2025-10-28") return DstackAppListResponseV20251028Schema;
|
|
@@ -7268,9 +7386,9 @@ async function safeGetAppList(client, request) {
|
|
|
7268
7386
|
}
|
|
7269
7387
|
|
|
7270
7388
|
// src/actions/apps/get_app_info.ts
|
|
7271
|
-
var
|
|
7272
|
-
var GetAppInfoRequestSchema =
|
|
7273
|
-
appId:
|
|
7389
|
+
var import_zod82 = require("zod");
|
|
7390
|
+
var GetAppInfoRequestSchema = import_zod82.z.object({
|
|
7391
|
+
appId: import_zod82.z.string().min(1)
|
|
7274
7392
|
}).strict();
|
|
7275
7393
|
function getSchemaForVersion11(version) {
|
|
7276
7394
|
if (version === "2025-10-28") return DstackAppWithCvmResponseV20251028Schema;
|
|
@@ -7302,14 +7420,14 @@ async function safeGetAppInfo(client, request) {
|
|
|
7302
7420
|
}
|
|
7303
7421
|
|
|
7304
7422
|
// src/actions/apps/get_app_cvms.ts
|
|
7305
|
-
var
|
|
7306
|
-
var GetAppCvmsRequestSchema =
|
|
7307
|
-
appId:
|
|
7423
|
+
var import_zod83 = require("zod");
|
|
7424
|
+
var GetAppCvmsRequestSchema = import_zod83.z.object({
|
|
7425
|
+
appId: import_zod83.z.string().min(1)
|
|
7308
7426
|
}).strict();
|
|
7309
7427
|
function getSchemaForVersion12(version) {
|
|
7310
|
-
if (version === "2025-10-28") return
|
|
7311
|
-
if (version === "2026-01-21") return
|
|
7312
|
-
return
|
|
7428
|
+
if (version === "2025-10-28") return import_zod83.z.array(CvmInfoV20251028Schema);
|
|
7429
|
+
if (version === "2026-01-21") return import_zod83.z.array(CvmInfoV20260121Schema);
|
|
7430
|
+
return import_zod83.z.array(CvmInfoV20260522Schema);
|
|
7313
7431
|
}
|
|
7314
7432
|
async function getAppCvms(client, request) {
|
|
7315
7433
|
const { appId } = GetAppCvmsRequestSchema.parse(request);
|
|
@@ -7336,18 +7454,18 @@ async function safeGetAppCvms(client, request) {
|
|
|
7336
7454
|
}
|
|
7337
7455
|
|
|
7338
7456
|
// src/actions/apps/create_app_instance.ts
|
|
7339
|
-
var
|
|
7457
|
+
var import_zod84 = require("zod");
|
|
7340
7458
|
var CreateAppInstanceRequestSchema = placementRequest(
|
|
7341
|
-
|
|
7342
|
-
appId:
|
|
7343
|
-
name:
|
|
7344
|
-
node:
|
|
7345
|
-
docker_compose_file:
|
|
7346
|
-
pre_launch_script:
|
|
7347
|
-
encrypted_env:
|
|
7348
|
-
compose_hash:
|
|
7349
|
-
token:
|
|
7350
|
-
transaction_hash:
|
|
7459
|
+
import_zod84.z.object({
|
|
7460
|
+
appId: import_zod84.z.string().min(1),
|
|
7461
|
+
name: import_zod84.z.string().optional(),
|
|
7462
|
+
node: import_zod84.z.string().min(1).optional(),
|
|
7463
|
+
docker_compose_file: import_zod84.z.string().optional(),
|
|
7464
|
+
pre_launch_script: import_zod84.z.string().optional(),
|
|
7465
|
+
encrypted_env: import_zod84.z.string().optional(),
|
|
7466
|
+
compose_hash: import_zod84.z.string().optional(),
|
|
7467
|
+
token: import_zod84.z.string().optional(),
|
|
7468
|
+
transaction_hash: import_zod84.z.string().optional()
|
|
7351
7469
|
}).strict()
|
|
7352
7470
|
);
|
|
7353
7471
|
var { action: createAppInstance, safeAction: safeCreateAppInstance } = defineAction(VMSchema, async (client, request) => {
|
|
@@ -7357,36 +7475,36 @@ var { action: createAppInstance, safeAction: safeCreateAppInstance } = defineAct
|
|
|
7357
7475
|
});
|
|
7358
7476
|
|
|
7359
7477
|
// src/actions/apps/get_app_device_allowlist.ts
|
|
7360
|
-
var
|
|
7361
|
-
var DeviceAllowlistItemBaseSchema =
|
|
7362
|
-
device_id:
|
|
7363
|
-
node_name:
|
|
7364
|
-
allowed_onchain:
|
|
7365
|
-
status:
|
|
7478
|
+
var import_zod85 = require("zod");
|
|
7479
|
+
var DeviceAllowlistItemBaseSchema = import_zod85.z.object({
|
|
7480
|
+
device_id: import_zod85.z.string(),
|
|
7481
|
+
node_name: import_zod85.z.string().nullable(),
|
|
7482
|
+
allowed_onchain: import_zod85.z.boolean(),
|
|
7483
|
+
status: import_zod85.z.string()
|
|
7366
7484
|
});
|
|
7367
7485
|
var DeviceAllowlistItemV20260121Schema = DeviceAllowlistItemBaseSchema.extend({
|
|
7368
|
-
cvm_ids:
|
|
7486
|
+
cvm_ids: import_zod85.z.array(import_zod85.z.number())
|
|
7369
7487
|
});
|
|
7370
7488
|
var DeviceAllowlistItemV20260522Schema = DeviceAllowlistItemBaseSchema.extend({
|
|
7371
|
-
cvm_ids:
|
|
7489
|
+
cvm_ids: import_zod85.z.array(import_zod85.z.string())
|
|
7372
7490
|
});
|
|
7373
|
-
var DeviceAllowlistResponseBaseSchema =
|
|
7374
|
-
is_onchain_kms:
|
|
7375
|
-
allow_any_device:
|
|
7376
|
-
chain_id:
|
|
7377
|
-
app_contract_address:
|
|
7491
|
+
var DeviceAllowlistResponseBaseSchema = import_zod85.z.object({
|
|
7492
|
+
is_onchain_kms: import_zod85.z.boolean(),
|
|
7493
|
+
allow_any_device: import_zod85.z.boolean().nullable().optional(),
|
|
7494
|
+
chain_id: import_zod85.z.number().nullable().optional(),
|
|
7495
|
+
app_contract_address: import_zod85.z.string().nullable().optional()
|
|
7378
7496
|
});
|
|
7379
7497
|
var DeviceAllowlistResponseV20260121Schema = DeviceAllowlistResponseBaseSchema.extend({
|
|
7380
|
-
devices:
|
|
7498
|
+
devices: import_zod85.z.array(DeviceAllowlistItemV20260121Schema).optional().default([])
|
|
7381
7499
|
});
|
|
7382
7500
|
var DeviceAllowlistResponseV20260522Schema = DeviceAllowlistResponseBaseSchema.extend({
|
|
7383
|
-
devices:
|
|
7501
|
+
devices: import_zod85.z.array(DeviceAllowlistItemV20260522Schema).optional().default([])
|
|
7384
7502
|
});
|
|
7385
|
-
var DeviceAllowlistItemAnySchema =
|
|
7503
|
+
var DeviceAllowlistItemAnySchema = import_zod85.z.union([
|
|
7386
7504
|
DeviceAllowlistItemV20260121Schema,
|
|
7387
7505
|
DeviceAllowlistItemV20260522Schema
|
|
7388
7506
|
]);
|
|
7389
|
-
var DeviceAllowlistResponseAnySchema =
|
|
7507
|
+
var DeviceAllowlistResponseAnySchema = import_zod85.z.union([
|
|
7390
7508
|
DeviceAllowlistResponseV20260121Schema,
|
|
7391
7509
|
DeviceAllowlistResponseV20260522Schema
|
|
7392
7510
|
]);
|
|
@@ -7394,8 +7512,8 @@ function getSchemaForVersion13(version) {
|
|
|
7394
7512
|
if (version === "2026-01-21") return DeviceAllowlistResponseV20260121Schema;
|
|
7395
7513
|
return DeviceAllowlistResponseV20260522Schema;
|
|
7396
7514
|
}
|
|
7397
|
-
var GetAppDeviceAllowlistRequestSchema =
|
|
7398
|
-
appId:
|
|
7515
|
+
var GetAppDeviceAllowlistRequestSchema = import_zod85.z.object({
|
|
7516
|
+
appId: import_zod85.z.string().min(1)
|
|
7399
7517
|
}).strict();
|
|
7400
7518
|
async function getAppDeviceAllowlist(client, request) {
|
|
7401
7519
|
const { appId } = GetAppDeviceAllowlistRequestSchema.parse(request);
|
|
@@ -7423,57 +7541,57 @@ async function safeGetAppDeviceAllowlist(client, request) {
|
|
|
7423
7541
|
}
|
|
7424
7542
|
|
|
7425
7543
|
// src/actions/apps/get_app_revisions.ts
|
|
7426
|
-
var
|
|
7544
|
+
var import_zod87 = require("zod");
|
|
7427
7545
|
|
|
7428
7546
|
// src/types/app_revision.ts
|
|
7429
|
-
var
|
|
7430
|
-
var CvmRefSchema =
|
|
7431
|
-
object_type:
|
|
7432
|
-
id:
|
|
7433
|
-
name:
|
|
7434
|
-
app_id:
|
|
7435
|
-
vm_uuid:
|
|
7436
|
-
});
|
|
7437
|
-
var AppRevisionResponseSchema =
|
|
7438
|
-
revision_id:
|
|
7439
|
-
app_id:
|
|
7440
|
-
vm_uuid:
|
|
7441
|
-
compose_hash:
|
|
7442
|
-
created_at:
|
|
7443
|
-
trace_id:
|
|
7444
|
-
operation_type:
|
|
7547
|
+
var import_zod86 = require("zod");
|
|
7548
|
+
var CvmRefSchema = import_zod86.z.object({
|
|
7549
|
+
object_type: import_zod86.z.literal("cvm"),
|
|
7550
|
+
id: import_zod86.z.string().nullable().optional(),
|
|
7551
|
+
name: import_zod86.z.string().nullable().optional(),
|
|
7552
|
+
app_id: import_zod86.z.string().nullable().optional(),
|
|
7553
|
+
vm_uuid: import_zod86.z.string().nullable().optional()
|
|
7554
|
+
});
|
|
7555
|
+
var AppRevisionResponseSchema = import_zod86.z.object({
|
|
7556
|
+
revision_id: import_zod86.z.string(),
|
|
7557
|
+
app_id: import_zod86.z.string(),
|
|
7558
|
+
vm_uuid: import_zod86.z.string(),
|
|
7559
|
+
compose_hash: import_zod86.z.string(),
|
|
7560
|
+
created_at: import_zod86.z.string(),
|
|
7561
|
+
trace_id: import_zod86.z.string().nullable().optional(),
|
|
7562
|
+
operation_type: import_zod86.z.string(),
|
|
7445
7563
|
triggered_by: UserRefSchema.nullable().optional(),
|
|
7446
7564
|
cvm: CvmRefSchema.nullable().optional(),
|
|
7447
7565
|
workspace: WorkspaceRefSchema.nullable().optional()
|
|
7448
7566
|
});
|
|
7449
|
-
var AppRevisionDetailResponseSchema =
|
|
7450
|
-
revision_id:
|
|
7451
|
-
app_id:
|
|
7452
|
-
vm_uuid:
|
|
7453
|
-
compose_hash:
|
|
7454
|
-
compose_file:
|
|
7455
|
-
encrypted_env:
|
|
7456
|
-
user_config:
|
|
7457
|
-
created_at:
|
|
7458
|
-
trace_id:
|
|
7459
|
-
operation_type:
|
|
7567
|
+
var AppRevisionDetailResponseSchema = import_zod86.z.object({
|
|
7568
|
+
revision_id: import_zod86.z.string(),
|
|
7569
|
+
app_id: import_zod86.z.string(),
|
|
7570
|
+
vm_uuid: import_zod86.z.string(),
|
|
7571
|
+
compose_hash: import_zod86.z.string(),
|
|
7572
|
+
compose_file: import_zod86.z.union([import_zod86.z.record(import_zod86.z.string(), import_zod86.z.any()), import_zod86.z.string()]).nullable().optional(),
|
|
7573
|
+
encrypted_env: import_zod86.z.string(),
|
|
7574
|
+
user_config: import_zod86.z.string(),
|
|
7575
|
+
created_at: import_zod86.z.string(),
|
|
7576
|
+
trace_id: import_zod86.z.string().nullable().optional(),
|
|
7577
|
+
operation_type: import_zod86.z.string(),
|
|
7460
7578
|
triggered_by: UserRefSchema.nullable().optional(),
|
|
7461
7579
|
cvm: CvmRefSchema.nullable().optional(),
|
|
7462
7580
|
workspace: WorkspaceRefSchema.nullable().optional()
|
|
7463
7581
|
});
|
|
7464
|
-
var AppRevisionsResponseSchema =
|
|
7465
|
-
revisions:
|
|
7466
|
-
total:
|
|
7467
|
-
page:
|
|
7468
|
-
page_size:
|
|
7469
|
-
total_pages:
|
|
7582
|
+
var AppRevisionsResponseSchema = import_zod86.z.object({
|
|
7583
|
+
revisions: import_zod86.z.array(AppRevisionResponseSchema),
|
|
7584
|
+
total: import_zod86.z.number().int(),
|
|
7585
|
+
page: import_zod86.z.number().int(),
|
|
7586
|
+
page_size: import_zod86.z.number().int(),
|
|
7587
|
+
total_pages: import_zod86.z.number().int()
|
|
7470
7588
|
});
|
|
7471
7589
|
|
|
7472
7590
|
// src/actions/apps/get_app_revisions.ts
|
|
7473
|
-
var GetAppRevisionsRequestSchema =
|
|
7474
|
-
appId:
|
|
7475
|
-
page:
|
|
7476
|
-
page_size:
|
|
7591
|
+
var GetAppRevisionsRequestSchema = import_zod87.z.object({
|
|
7592
|
+
appId: import_zod87.z.string().min(1),
|
|
7593
|
+
page: import_zod87.z.number().int().min(1).optional(),
|
|
7594
|
+
page_size: import_zod87.z.number().int().min(1).max(1e3).optional()
|
|
7477
7595
|
}).strict();
|
|
7478
7596
|
async function getAppRevisions(client, request) {
|
|
7479
7597
|
const { appId, ...params } = GetAppRevisionsRequestSchema.parse(request);
|
|
@@ -7499,11 +7617,11 @@ async function safeGetAppRevisions(client, request) {
|
|
|
7499
7617
|
}
|
|
7500
7618
|
|
|
7501
7619
|
// src/actions/apps/get_app_revision_detail.ts
|
|
7502
|
-
var
|
|
7503
|
-
var GetAppRevisionDetailRequestSchema =
|
|
7504
|
-
appId:
|
|
7505
|
-
revisionId:
|
|
7506
|
-
rawComposeFile:
|
|
7620
|
+
var import_zod88 = require("zod");
|
|
7621
|
+
var GetAppRevisionDetailRequestSchema = import_zod88.z.object({
|
|
7622
|
+
appId: import_zod88.z.string().min(1),
|
|
7623
|
+
revisionId: import_zod88.z.string().min(1),
|
|
7624
|
+
rawComposeFile: import_zod88.z.boolean().optional()
|
|
7507
7625
|
}).strict();
|
|
7508
7626
|
async function getAppRevisionDetail(client, request) {
|
|
7509
7627
|
const { appId, revisionId, rawComposeFile } = GetAppRevisionDetailRequestSchema.parse(request);
|
|
@@ -7530,15 +7648,15 @@ async function safeGetAppRevisionDetail(client, request) {
|
|
|
7530
7648
|
}
|
|
7531
7649
|
|
|
7532
7650
|
// src/actions/apps/get_app_filter_options.ts
|
|
7533
|
-
var
|
|
7534
|
-
var AppFilterOptionsSchema =
|
|
7535
|
-
statuses:
|
|
7536
|
-
image_versions:
|
|
7537
|
-
instance_types:
|
|
7538
|
-
kms_slugs:
|
|
7539
|
-
kms_types:
|
|
7540
|
-
regions:
|
|
7541
|
-
nodes:
|
|
7651
|
+
var import_zod89 = require("zod");
|
|
7652
|
+
var AppFilterOptionsSchema = import_zod89.z.object({
|
|
7653
|
+
statuses: import_zod89.z.array(import_zod89.z.string()),
|
|
7654
|
+
image_versions: import_zod89.z.array(import_zod89.z.string()),
|
|
7655
|
+
instance_types: import_zod89.z.array(import_zod89.z.string()),
|
|
7656
|
+
kms_slugs: import_zod89.z.array(import_zod89.z.string()),
|
|
7657
|
+
kms_types: import_zod89.z.array(import_zod89.z.string()),
|
|
7658
|
+
regions: import_zod89.z.array(import_zod89.z.string()),
|
|
7659
|
+
nodes: import_zod89.z.array(import_zod89.z.string())
|
|
7542
7660
|
});
|
|
7543
7661
|
async function getAppFilterOptions(client) {
|
|
7544
7662
|
const response = await client.get("/apps/filter-options");
|
|
@@ -7563,53 +7681,53 @@ async function safeGetAppFilterOptions(client) {
|
|
|
7563
7681
|
}
|
|
7564
7682
|
|
|
7565
7683
|
// src/actions/apps/get_app_attestation.ts
|
|
7566
|
-
var
|
|
7567
|
-
var KmsInfoSchema2 =
|
|
7568
|
-
contract_address:
|
|
7569
|
-
chain_id:
|
|
7570
|
-
version:
|
|
7571
|
-
url:
|
|
7572
|
-
gateway_app_id:
|
|
7573
|
-
gateway_app_url:
|
|
7574
|
-
kms_type:
|
|
7575
|
-
});
|
|
7576
|
-
var GuestAgentInfoSchema =
|
|
7577
|
-
app_id:
|
|
7578
|
-
instance_id:
|
|
7579
|
-
app_name:
|
|
7580
|
-
device_id:
|
|
7684
|
+
var import_zod90 = require("zod");
|
|
7685
|
+
var KmsInfoSchema2 = import_zod90.z.object({
|
|
7686
|
+
contract_address: import_zod90.z.string(),
|
|
7687
|
+
chain_id: import_zod90.z.number().nullable(),
|
|
7688
|
+
version: import_zod90.z.string(),
|
|
7689
|
+
url: import_zod90.z.string(),
|
|
7690
|
+
gateway_app_id: import_zod90.z.string().nullable(),
|
|
7691
|
+
gateway_app_url: import_zod90.z.string(),
|
|
7692
|
+
kms_type: import_zod90.z.string()
|
|
7693
|
+
});
|
|
7694
|
+
var GuestAgentInfoSchema = import_zod90.z.object({
|
|
7695
|
+
app_id: import_zod90.z.string().optional(),
|
|
7696
|
+
instance_id: import_zod90.z.string().optional(),
|
|
7697
|
+
app_name: import_zod90.z.string().optional(),
|
|
7698
|
+
device_id: import_zod90.z.string().optional()
|
|
7581
7699
|
}).passthrough().nullable();
|
|
7582
|
-
var AppAttestationInstanceSchema =
|
|
7583
|
-
vm_uuid:
|
|
7584
|
-
name:
|
|
7585
|
-
instance_id:
|
|
7586
|
-
status:
|
|
7587
|
-
image_version:
|
|
7588
|
-
quote:
|
|
7589
|
-
ppid:
|
|
7590
|
-
ppid_sha256:
|
|
7591
|
-
device_id:
|
|
7592
|
-
fmspc:
|
|
7593
|
-
tee_tcb_svn:
|
|
7594
|
-
mr_config_id:
|
|
7595
|
-
cpusvn:
|
|
7596
|
-
pcesvn:
|
|
7700
|
+
var AppAttestationInstanceSchema = import_zod90.z.object({
|
|
7701
|
+
vm_uuid: import_zod90.z.string().nullable().optional(),
|
|
7702
|
+
name: import_zod90.z.string().optional(),
|
|
7703
|
+
instance_id: import_zod90.z.string().nullable().optional(),
|
|
7704
|
+
status: import_zod90.z.string().optional(),
|
|
7705
|
+
image_version: import_zod90.z.string().nullable().optional(),
|
|
7706
|
+
quote: import_zod90.z.string().nullable().optional(),
|
|
7707
|
+
ppid: import_zod90.z.string().optional(),
|
|
7708
|
+
ppid_sha256: import_zod90.z.string().nullable().optional(),
|
|
7709
|
+
device_id: import_zod90.z.string().optional(),
|
|
7710
|
+
fmspc: import_zod90.z.string().nullable().optional(),
|
|
7711
|
+
tee_tcb_svn: import_zod90.z.string().nullable().optional(),
|
|
7712
|
+
mr_config_id: import_zod90.z.string().nullable().optional(),
|
|
7713
|
+
cpusvn: import_zod90.z.string().nullable().optional(),
|
|
7714
|
+
pcesvn: import_zod90.z.number().nullable().optional(),
|
|
7597
7715
|
tcb_info: TcbInfoSchema.nullable().optional(),
|
|
7598
|
-
app_certificates:
|
|
7599
|
-
compose_file:
|
|
7600
|
-
error:
|
|
7716
|
+
app_certificates: import_zod90.z.array(CertificateSchema).nullable().optional(),
|
|
7717
|
+
compose_file: import_zod90.z.string().nullable().optional(),
|
|
7718
|
+
error: import_zod90.z.string().nullable().optional()
|
|
7601
7719
|
});
|
|
7602
|
-
var AppAttestationResponseSchema =
|
|
7603
|
-
app_id:
|
|
7604
|
-
contract_address:
|
|
7720
|
+
var AppAttestationResponseSchema = import_zod90.z.object({
|
|
7721
|
+
app_id: import_zod90.z.string(),
|
|
7722
|
+
contract_address: import_zod90.z.string(),
|
|
7605
7723
|
kms_info: KmsInfoSchema2,
|
|
7606
|
-
instances:
|
|
7724
|
+
instances: import_zod90.z.array(AppAttestationInstanceSchema),
|
|
7607
7725
|
kms_guest_agent_info: GuestAgentInfoSchema,
|
|
7608
7726
|
gateway_guest_agent_info: GuestAgentInfoSchema,
|
|
7609
|
-
qemu_version:
|
|
7727
|
+
qemu_version: import_zod90.z.string().nullable()
|
|
7610
7728
|
});
|
|
7611
|
-
var GetAppAttestationRequestSchema =
|
|
7612
|
-
appId:
|
|
7729
|
+
var GetAppAttestationRequestSchema = import_zod90.z.object({
|
|
7730
|
+
appId: import_zod90.z.string().min(1)
|
|
7613
7731
|
}).strict();
|
|
7614
7732
|
var { action: getAppAttestation, safeAction: safeGetAppAttestation } = defineAction(AppAttestationResponseSchema, async (client, request) => {
|
|
7615
7733
|
const { appId } = GetAppAttestationRequestSchema.parse(request);
|
|
@@ -7617,17 +7735,17 @@ var { action: getAppAttestation, safeAction: safeGetAppAttestation } = defineAct
|
|
|
7617
7735
|
});
|
|
7618
7736
|
|
|
7619
7737
|
// src/actions/apps/app_launch_token.ts
|
|
7620
|
-
var
|
|
7621
|
-
var AppLaunchTokenSchema =
|
|
7738
|
+
var import_zod91 = require("zod");
|
|
7739
|
+
var AppLaunchTokenSchema = import_zod91.z.object({
|
|
7622
7740
|
/** The app's new launch token. Returned only here, once. */
|
|
7623
|
-
launch_token:
|
|
7741
|
+
launch_token: import_zod91.z.string(),
|
|
7624
7742
|
/** Value for `requirements.launch_token_hash` of every CVM of the app. */
|
|
7625
|
-
launch_token_hash:
|
|
7743
|
+
launch_token_hash: import_zod91.z.string()
|
|
7626
7744
|
});
|
|
7627
|
-
var SetAppLaunchTokenRequestSchema =
|
|
7628
|
-
appId:
|
|
7745
|
+
var SetAppLaunchTokenRequestSchema = import_zod91.z.object({
|
|
7746
|
+
appId: import_zod91.z.string().min(1),
|
|
7629
7747
|
/** Token to set (at least 32 bytes). Omit to have Phala Cloud generate one. */
|
|
7630
|
-
launchToken:
|
|
7748
|
+
launchToken: import_zod91.z.string().optional()
|
|
7631
7749
|
});
|
|
7632
7750
|
var { action: setAppLaunchToken, safeAction: safeSetAppLaunchToken } = defineAction(AppLaunchTokenSchema, async (client, request) => {
|
|
7633
7751
|
const { appId, launchToken } = SetAppLaunchTokenRequestSchema.parse(request);
|
|
@@ -7636,36 +7754,36 @@ var { action: setAppLaunchToken, safeAction: safeSetAppLaunchToken } = defineAct
|
|
|
7636
7754
|
launchToken === void 0 ? {} : { launch_token: launchToken }
|
|
7637
7755
|
);
|
|
7638
7756
|
});
|
|
7639
|
-
var ClearAppLaunchTokenRequestSchema =
|
|
7640
|
-
appId:
|
|
7757
|
+
var ClearAppLaunchTokenRequestSchema = import_zod91.z.object({
|
|
7758
|
+
appId: import_zod91.z.string().min(1)
|
|
7641
7759
|
});
|
|
7642
|
-
var { action: clearAppLaunchToken, safeAction: safeClearAppLaunchToken } = defineAction(
|
|
7760
|
+
var { action: clearAppLaunchToken, safeAction: safeClearAppLaunchToken } = defineAction(import_zod91.z.void(), async (client, request) => {
|
|
7643
7761
|
const { appId } = ClearAppLaunchTokenRequestSchema.parse(request);
|
|
7644
7762
|
await client.delete(`/apps/${appId}/launch-token`);
|
|
7645
7763
|
return void 0;
|
|
7646
7764
|
});
|
|
7647
7765
|
|
|
7648
7766
|
// src/actions/os_images/get_os_images.ts
|
|
7649
|
-
var
|
|
7650
|
-
var OSImagePublicSchema =
|
|
7651
|
-
name:
|
|
7652
|
-
slug:
|
|
7653
|
-
version:
|
|
7654
|
-
os_image_hash:
|
|
7655
|
-
is_dev:
|
|
7656
|
-
requires_gpu:
|
|
7767
|
+
var import_zod92 = require("zod");
|
|
7768
|
+
var OSImagePublicSchema = import_zod92.z.object({
|
|
7769
|
+
name: import_zod92.z.string(),
|
|
7770
|
+
slug: import_zod92.z.string(),
|
|
7771
|
+
version: import_zod92.z.string(),
|
|
7772
|
+
os_image_hash: import_zod92.z.string().nullable(),
|
|
7773
|
+
is_dev: import_zod92.z.boolean(),
|
|
7774
|
+
requires_gpu: import_zod92.z.boolean()
|
|
7657
7775
|
}).passthrough();
|
|
7658
|
-
var GetOsImagesRequestSchema =
|
|
7659
|
-
page:
|
|
7660
|
-
page_size:
|
|
7661
|
-
is_dev:
|
|
7776
|
+
var GetOsImagesRequestSchema = import_zod92.z.object({
|
|
7777
|
+
page: import_zod92.z.number().int().min(1).optional(),
|
|
7778
|
+
page_size: import_zod92.z.number().int().min(1).optional(),
|
|
7779
|
+
is_dev: import_zod92.z.boolean().optional()
|
|
7662
7780
|
}).strict();
|
|
7663
|
-
var GetOsImagesResponseSchema =
|
|
7664
|
-
items:
|
|
7665
|
-
total:
|
|
7666
|
-
page:
|
|
7667
|
-
page_size:
|
|
7668
|
-
pages:
|
|
7781
|
+
var GetOsImagesResponseSchema = import_zod92.z.object({
|
|
7782
|
+
items: import_zod92.z.array(OSImagePublicSchema),
|
|
7783
|
+
total: import_zod92.z.number(),
|
|
7784
|
+
page: import_zod92.z.number(),
|
|
7785
|
+
page_size: import_zod92.z.number(),
|
|
7786
|
+
pages: import_zod92.z.number()
|
|
7669
7787
|
}).passthrough();
|
|
7670
7788
|
var { action: getOsImages, safeAction: safeGetOsImages } = defineAction(GetOsImagesResponseSchema, async (client, request) => {
|
|
7671
7789
|
const validatedRequest = GetOsImagesRequestSchema.parse(request ?? {});
|
|
@@ -7701,6 +7819,8 @@ var additionalActions = {
|
|
|
7701
7819
|
safeUpdateCvmAnnotations,
|
|
7702
7820
|
getCvmInitScripts,
|
|
7703
7821
|
safeGetCvmInitScripts,
|
|
7822
|
+
putCvmInitScripts,
|
|
7823
|
+
safePutCvmInitScripts,
|
|
7704
7824
|
setAppLaunchToken,
|
|
7705
7825
|
safeSetAppLaunchToken,
|
|
7706
7826
|
clearAppLaunchToken,
|
|
@@ -7866,6 +7986,594 @@ function buildClient(client) {
|
|
|
7866
7986
|
return extended;
|
|
7867
7987
|
}
|
|
7868
7988
|
|
|
7989
|
+
// src/actions/cvms/log-time.ts
|
|
7990
|
+
var DURATION_SECONDS = {
|
|
7991
|
+
s: 1,
|
|
7992
|
+
m: 60,
|
|
7993
|
+
h: 60 * 60,
|
|
7994
|
+
d: 24 * 60 * 60
|
|
7995
|
+
};
|
|
7996
|
+
function parseRfc3339(value) {
|
|
7997
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(Z|([+-])(\d{2}):(\d{2}))$/.exec(
|
|
7998
|
+
value
|
|
7999
|
+
);
|
|
8000
|
+
if (!match) return void 0;
|
|
8001
|
+
const year = Number(match[1]);
|
|
8002
|
+
const month = Number(match[2]);
|
|
8003
|
+
const day = Number(match[3]);
|
|
8004
|
+
const hour = Number(match[4]);
|
|
8005
|
+
const minute = Number(match[5]);
|
|
8006
|
+
const second = Number(match[6]);
|
|
8007
|
+
const fraction = match[7];
|
|
8008
|
+
const sign = match[9];
|
|
8009
|
+
const offsetHour = Number(match[10] ?? 0);
|
|
8010
|
+
const offsetMinute = Number(match[11] ?? 0);
|
|
8011
|
+
const lastDateOfMonth = /* @__PURE__ */ new Date(0);
|
|
8012
|
+
lastDateOfMonth.setUTCFullYear(year, month, 0);
|
|
8013
|
+
const daysInMonth = lastDateOfMonth.getUTCDate();
|
|
8014
|
+
if (year < 1 || month < 1 || month > 12 || day < 1 || day > daysInMonth || hour > 23 || minute > 59 || second > 59 || offsetHour > 23 || offsetMinute > 59) {
|
|
8015
|
+
return void 0;
|
|
8016
|
+
}
|
|
8017
|
+
const fractionalMilliseconds = fraction ? Number(`0.${fraction}`) * 1e3 : 0;
|
|
8018
|
+
const offset = sign === "+" ? 1 : sign === "-" ? -1 : 0;
|
|
8019
|
+
const offsetMilliseconds = offset * (offsetHour * 60 + offsetMinute) * 6e4;
|
|
8020
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
8021
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
8022
|
+
date.setUTCHours(hour, minute, second, 0);
|
|
8023
|
+
return date.getTime() + fractionalMilliseconds - offsetMilliseconds;
|
|
8024
|
+
}
|
|
8025
|
+
function parseLogTime(value, nowMs) {
|
|
8026
|
+
if (/^-?\d+$/.test(value)) {
|
|
8027
|
+
const seconds = Number(value);
|
|
8028
|
+
const milliseconds = seconds * 1e3;
|
|
8029
|
+
if (Number.isSafeInteger(seconds) && Number.isSafeInteger(milliseconds)) {
|
|
8030
|
+
return milliseconds;
|
|
8031
|
+
}
|
|
8032
|
+
}
|
|
8033
|
+
const relative = /^(\d+)([smhd])$/.exec(value);
|
|
8034
|
+
if (relative) {
|
|
8035
|
+
const unit = relative[2];
|
|
8036
|
+
if (!unit || !(unit in DURATION_SECONDS)) {
|
|
8037
|
+
throw new Error(
|
|
8038
|
+
`Invalid log time '${value}'. Use RFC3339, Unix seconds, or a relative duration such as 10m.`
|
|
8039
|
+
);
|
|
8040
|
+
}
|
|
8041
|
+
const duration = Number(relative[1]) * (DURATION_SECONDS[unit] ?? 0);
|
|
8042
|
+
const milliseconds = nowMs - duration * 1e3;
|
|
8043
|
+
if (Number.isFinite(milliseconds) && Number.isSafeInteger(Math.floor(milliseconds / 1e3))) {
|
|
8044
|
+
return milliseconds;
|
|
8045
|
+
}
|
|
8046
|
+
}
|
|
8047
|
+
const rfc3339 = parseRfc3339(value);
|
|
8048
|
+
if (rfc3339 !== void 0) return rfc3339;
|
|
8049
|
+
throw new Error(
|
|
8050
|
+
`Invalid log time '${value}'. Use RFC3339, Unix seconds, or a relative duration such as 10m.`
|
|
8051
|
+
);
|
|
8052
|
+
}
|
|
8053
|
+
function resolveLogTimeWindow(since, until, nowMs = Date.now()) {
|
|
8054
|
+
const resolvedSince = since === void 0 ? void 0 : typeof since === "number" ? Math.floor(since) : Math.floor(parseLogTime(since, nowMs) / 1e3);
|
|
8055
|
+
const resolvedUntil = until === void 0 ? void 0 : typeof until === "number" ? Math.ceil(until) : Math.ceil(parseLogTime(until, nowMs) / 1e3);
|
|
8056
|
+
if (resolvedSince !== void 0 && !Number.isSafeInteger(resolvedSince) || resolvedUntil !== void 0 && !Number.isSafeInteger(resolvedUntil)) {
|
|
8057
|
+
throw new Error("Log time is outside the supported Unix seconds range.");
|
|
8058
|
+
}
|
|
8059
|
+
return {
|
|
8060
|
+
...resolvedSince === void 0 ? {} : { since: resolvedSince },
|
|
8061
|
+
...resolvedUntil === void 0 ? {} : { until: resolvedUntil }
|
|
8062
|
+
};
|
|
8063
|
+
}
|
|
8064
|
+
|
|
8065
|
+
// src/actions/cvms/logs.ts
|
|
8066
|
+
var CVM_LOGS_INFO_API_VERSION = "2026-01-21";
|
|
8067
|
+
var LOG_ERROR_HTTP_STATUS = {
|
|
8068
|
+
"ERR-17-001": 400,
|
|
8069
|
+
"ERR-17-002": 401,
|
|
8070
|
+
"ERR-17-003": 401,
|
|
8071
|
+
"ERR-17-004": 404,
|
|
8072
|
+
"ERR-17-005": 409,
|
|
8073
|
+
"ERR-17-006": 409,
|
|
8074
|
+
"ERR-17-007": 404,
|
|
8075
|
+
"ERR-17-008": 502,
|
|
8076
|
+
"ERR-17-009": 502,
|
|
8077
|
+
"ERR-17-010": 504,
|
|
8078
|
+
"ERR-17-011": 429,
|
|
8079
|
+
"ERR-17-012": 503,
|
|
8080
|
+
"ERR-17-013": 404
|
|
8081
|
+
};
|
|
8082
|
+
function logErrorHttpStatus(code) {
|
|
8083
|
+
return LOG_ERROR_HTTP_STATUS[code];
|
|
8084
|
+
}
|
|
8085
|
+
var LogAccessError = class extends ResourceError {
|
|
8086
|
+
constructor(options) {
|
|
8087
|
+
const details = options.code ? `${options.code}: ${options.message}` : options.message;
|
|
8088
|
+
const suggestionText = options.suggestions?.length ? `
|
|
8089
|
+
Suggestions:
|
|
8090
|
+
${options.suggestions.map((suggestion) => `- ${suggestion}`).join("\n")}` : "";
|
|
8091
|
+
const status = options.httpStatus ?? (options.code ? logErrorHttpStatus(options.code) : void 0) ?? 0;
|
|
8092
|
+
super(`${details}${suggestionText}`, {
|
|
8093
|
+
status,
|
|
8094
|
+
statusText: "",
|
|
8095
|
+
errorCode: options.code,
|
|
8096
|
+
suggestions: options.suggestions ? [...options.suggestions] : void 0
|
|
8097
|
+
});
|
|
8098
|
+
this.name = "LogAccessError";
|
|
8099
|
+
this.code = options.code;
|
|
8100
|
+
this.httpStatus = status || void 0;
|
|
8101
|
+
this.suggestions = options.suggestions ? [...options.suggestions] : [];
|
|
8102
|
+
}
|
|
8103
|
+
};
|
|
8104
|
+
function resolveCvmId(id) {
|
|
8105
|
+
return CvmIdSchema.parse(typeof id === "string" ? { id } : id).cvmId;
|
|
8106
|
+
}
|
|
8107
|
+
function buildLogUrl(baseUrl, options) {
|
|
8108
|
+
const params = [];
|
|
8109
|
+
if (options.since !== void 0) params.push(`since=${options.since}`);
|
|
8110
|
+
if (options.until !== void 0) params.push(`until=${options.until}`);
|
|
8111
|
+
if (options.follow) params.push("follow=true");
|
|
8112
|
+
if (options.tail !== void 0) params.push(`tail=${options.tail}`);
|
|
8113
|
+
if (options.timestamps) params.push("timestamps=true");
|
|
8114
|
+
if (options.ansi) params.push("ansi=true");
|
|
8115
|
+
if (options.format) params.push(`format=${options.format}`);
|
|
8116
|
+
const sep = baseUrl.includes("?") ? "&" : "?";
|
|
8117
|
+
return params.length > 0 ? `${baseUrl}${sep}${params.join("&")}` : baseUrl;
|
|
8118
|
+
}
|
|
8119
|
+
async function streamResponse(response, onData) {
|
|
8120
|
+
const reader = response.body?.getReader();
|
|
8121
|
+
if (!reader) throw new Error("No response body available for streaming");
|
|
8122
|
+
const decoder = new TextDecoder();
|
|
8123
|
+
let buffer = "";
|
|
8124
|
+
let finished = false;
|
|
8125
|
+
try {
|
|
8126
|
+
while (true) {
|
|
8127
|
+
const { done, value } = await reader.read();
|
|
8128
|
+
buffer += decoder.decode(value, { stream: !done });
|
|
8129
|
+
let newline = buffer.indexOf("\n");
|
|
8130
|
+
while (newline >= 0) {
|
|
8131
|
+
const line = buffer.slice(0, newline + 1);
|
|
8132
|
+
buffer = buffer.slice(newline + 1);
|
|
8133
|
+
const content = line.replace(/\r?\n$/, "");
|
|
8134
|
+
if (content !== "[vmm heartbeat]" && content !== "[teepod heartbeat]") {
|
|
8135
|
+
throwTextStreamError(content);
|
|
8136
|
+
onData(line);
|
|
8137
|
+
}
|
|
8138
|
+
newline = buffer.indexOf("\n");
|
|
8139
|
+
}
|
|
8140
|
+
if (done) {
|
|
8141
|
+
finished = true;
|
|
8142
|
+
break;
|
|
8143
|
+
}
|
|
8144
|
+
}
|
|
8145
|
+
if (buffer && buffer !== "[vmm heartbeat]" && buffer !== "[teepod heartbeat]") {
|
|
8146
|
+
throwTextStreamError(buffer);
|
|
8147
|
+
onData(buffer);
|
|
8148
|
+
}
|
|
8149
|
+
} finally {
|
|
8150
|
+
if (!finished) await reader.cancel().catch(() => {
|
|
8151
|
+
});
|
|
8152
|
+
reader.releaseLock();
|
|
8153
|
+
}
|
|
8154
|
+
}
|
|
8155
|
+
async function throwResponseError(response) {
|
|
8156
|
+
const body = await response.text();
|
|
8157
|
+
let envelope;
|
|
8158
|
+
try {
|
|
8159
|
+
envelope = JSON.parse(body);
|
|
8160
|
+
} catch {
|
|
8161
|
+
envelope = {};
|
|
8162
|
+
}
|
|
8163
|
+
const suggestions = Array.isArray(envelope.suggestions) ? envelope.suggestions.filter((item) => typeof item === "string") : [];
|
|
8164
|
+
throw new LogAccessError({
|
|
8165
|
+
code: typeof envelope.error_code === "string" ? envelope.error_code : void 0,
|
|
8166
|
+
message: typeof envelope.message === "string" ? envelope.message : `HTTP ${response.status} ${response.statusText}`,
|
|
8167
|
+
httpStatus: response.status,
|
|
8168
|
+
suggestions
|
|
8169
|
+
});
|
|
8170
|
+
}
|
|
8171
|
+
function throwTextStreamError(line) {
|
|
8172
|
+
const match = /^\[error\] (ERR-17-\d{3}) (.*)$/.exec(line.trim());
|
|
8173
|
+
const code = match?.[1];
|
|
8174
|
+
const message = match?.[2];
|
|
8175
|
+
if (code && message !== void 0) throw new LogAccessError({ code, message });
|
|
8176
|
+
}
|
|
8177
|
+
function parseTimestampedMessage(message) {
|
|
8178
|
+
const match = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})) (.*)$/s.exec(
|
|
8179
|
+
message
|
|
8180
|
+
);
|
|
8181
|
+
if (!match) return {};
|
|
8182
|
+
const time = Date.parse(match[1]);
|
|
8183
|
+
if (!Number.isFinite(time)) return {};
|
|
8184
|
+
return {
|
|
8185
|
+
timestamp: match[1],
|
|
8186
|
+
second: Math.floor(time / 1e3),
|
|
8187
|
+
message: match[2]
|
|
8188
|
+
};
|
|
8189
|
+
}
|
|
8190
|
+
function formatFollowContainerEntry(entry, includeTimestamps) {
|
|
8191
|
+
if (includeTimestamps) return { channel: entry.channel, message: entry.message };
|
|
8192
|
+
const timestamp = parseTimestampedMessage(entry.message);
|
|
8193
|
+
return {
|
|
8194
|
+
channel: entry.channel,
|
|
8195
|
+
message: timestamp.timestamp ? timestamp.message ?? "" : entry.message
|
|
8196
|
+
};
|
|
8197
|
+
}
|
|
8198
|
+
function parseStructuredLogLineToEntry(line) {
|
|
8199
|
+
const trimmed = line.trim();
|
|
8200
|
+
if (!trimmed) return null;
|
|
8201
|
+
let parsed;
|
|
8202
|
+
try {
|
|
8203
|
+
parsed = JSON.parse(trimmed);
|
|
8204
|
+
} catch {
|
|
8205
|
+
throw new LogAccessError({ message: "Invalid NDJSON log record." });
|
|
8206
|
+
}
|
|
8207
|
+
if (typeof parsed.error_code === "string") {
|
|
8208
|
+
throw new LogAccessError({
|
|
8209
|
+
code: parsed.error_code,
|
|
8210
|
+
message: typeof parsed.message === "string" ? parsed.message : "The log stream ended with an error.",
|
|
8211
|
+
suggestions: Array.isArray(parsed.suggestions) ? parsed.suggestions.filter((item) => typeof item === "string") : []
|
|
8212
|
+
});
|
|
8213
|
+
}
|
|
8214
|
+
if (parsed.channel !== "stdout" && parsed.channel !== "stderr" || typeof parsed.message !== "string") {
|
|
8215
|
+
throw new LogAccessError({ message: "Invalid NDJSON log record." });
|
|
8216
|
+
}
|
|
8217
|
+
const entry = {
|
|
8218
|
+
channel: parsed.channel,
|
|
8219
|
+
message: parsed.message
|
|
8220
|
+
};
|
|
8221
|
+
const timestamp = parseTimestampedMessage(entry.message).timestamp;
|
|
8222
|
+
if (timestamp) entry.timestamp = timestamp;
|
|
8223
|
+
return entry;
|
|
8224
|
+
}
|
|
8225
|
+
function parseStructuredLogsToEntries(input) {
|
|
8226
|
+
const entries = [];
|
|
8227
|
+
for (const line of input.split(/\r?\n/)) {
|
|
8228
|
+
const entry = parseStructuredLogLineToEntry(line);
|
|
8229
|
+
if (entry) entries.push(entry);
|
|
8230
|
+
}
|
|
8231
|
+
return entries;
|
|
8232
|
+
}
|
|
8233
|
+
async function streamNdjsonEntriesResponse(response, onEntry) {
|
|
8234
|
+
const reader = response.body?.getReader();
|
|
8235
|
+
if (!reader) throw new Error("No response body available for streaming");
|
|
8236
|
+
const decoder = new TextDecoder();
|
|
8237
|
+
let buffer = "";
|
|
8238
|
+
let finished = false;
|
|
8239
|
+
try {
|
|
8240
|
+
while (true) {
|
|
8241
|
+
const { done, value } = await reader.read();
|
|
8242
|
+
buffer += decoder.decode(value, { stream: !done });
|
|
8243
|
+
let newline = buffer.indexOf("\n");
|
|
8244
|
+
while (newline >= 0) {
|
|
8245
|
+
const entry = parseStructuredLogLineToEntry(buffer.slice(0, newline));
|
|
8246
|
+
if (entry) onEntry(entry);
|
|
8247
|
+
buffer = buffer.slice(newline + 1);
|
|
8248
|
+
newline = buffer.indexOf("\n");
|
|
8249
|
+
}
|
|
8250
|
+
if (done) {
|
|
8251
|
+
finished = true;
|
|
8252
|
+
break;
|
|
8253
|
+
}
|
|
8254
|
+
}
|
|
8255
|
+
if (buffer.trim()) {
|
|
8256
|
+
const entry = parseStructuredLogLineToEntry(buffer);
|
|
8257
|
+
if (entry) onEntry(entry);
|
|
8258
|
+
}
|
|
8259
|
+
} finally {
|
|
8260
|
+
if (!finished) await reader.cancel().catch(() => {
|
|
8261
|
+
});
|
|
8262
|
+
reader.releaseLock();
|
|
8263
|
+
}
|
|
8264
|
+
}
|
|
8265
|
+
function assertSupportedNodeLogOptions(options) {
|
|
8266
|
+
const unsupported = [
|
|
8267
|
+
options.timestamps && "timestamps",
|
|
8268
|
+
options.since !== void 0 && "since",
|
|
8269
|
+
options.until !== void 0 && "until",
|
|
8270
|
+
options.format === "ndjson" && "format=ndjson"
|
|
8271
|
+
].filter((option) => Boolean(option));
|
|
8272
|
+
if (unsupported.length > 0) {
|
|
8273
|
+
throw new Error(`${unsupported.join(", ")} not supported for serial/stdout/stderr logs`);
|
|
8274
|
+
}
|
|
8275
|
+
if (options.ansi && options.format === "ndjson") {
|
|
8276
|
+
throw new LogAccessError({
|
|
8277
|
+
code: "ERR-17-001",
|
|
8278
|
+
message: "ansi is valid only with format=text"
|
|
8279
|
+
});
|
|
8280
|
+
}
|
|
8281
|
+
}
|
|
8282
|
+
async function getCvmInfoLogs(client, cvmId) {
|
|
8283
|
+
return await client.get(`/cvms/${cvmId}`, {
|
|
8284
|
+
headers: { "X-Phala-Version": CVM_LOGS_INFO_API_VERSION }
|
|
8285
|
+
});
|
|
8286
|
+
}
|
|
8287
|
+
async function getCvmLogEndpoint(client, id, channel) {
|
|
8288
|
+
const cvmId = resolveCvmId(id);
|
|
8289
|
+
const info = await getCvmInfoLogs(client, cvmId);
|
|
8290
|
+
const endpoint = info.logs?.[channel];
|
|
8291
|
+
if (!endpoint) {
|
|
8292
|
+
throw new Error(`No ${channel} log endpoint available for CVM '${cvmId}'`);
|
|
8293
|
+
}
|
|
8294
|
+
return endpoint;
|
|
8295
|
+
}
|
|
8296
|
+
async function getContainerLogEndpoint(client, id, containerName, matchContainerIdPrefix = true) {
|
|
8297
|
+
const cvmId = resolveCvmId(id);
|
|
8298
|
+
const composition = await client.get(`/cvms/${cvmId}/composition`);
|
|
8299
|
+
if (!composition.containers?.length) {
|
|
8300
|
+
throw new Error(`No containers found for CVM '${cvmId}'`);
|
|
8301
|
+
}
|
|
8302
|
+
let containers = composition.containers;
|
|
8303
|
+
if (containerName) {
|
|
8304
|
+
containers = containers.filter((c) => {
|
|
8305
|
+
const matchedByName = c.names.some((n) => n === containerName || n === `/${containerName}`);
|
|
8306
|
+
if (matchedByName) return true;
|
|
8307
|
+
if (!matchContainerIdPrefix) return false;
|
|
8308
|
+
return c.id.startsWith(containerName);
|
|
8309
|
+
});
|
|
8310
|
+
if (!containers.length) {
|
|
8311
|
+
throw new Error(`Container '${containerName}' not found in CVM '${cvmId}'`);
|
|
8312
|
+
}
|
|
8313
|
+
}
|
|
8314
|
+
const container = containers.find((c) => c.log_endpoint);
|
|
8315
|
+
if (!container?.log_endpoint) {
|
|
8316
|
+
throw new Error(`No log endpoints available for CVM '${cvmId}'`);
|
|
8317
|
+
}
|
|
8318
|
+
return container.log_endpoint;
|
|
8319
|
+
}
|
|
8320
|
+
function waitForReconnect(signal, delayMs) {
|
|
8321
|
+
if (signal?.aborted) return Promise.resolve();
|
|
8322
|
+
return new Promise((resolve) => {
|
|
8323
|
+
const timeout = setTimeout(() => {
|
|
8324
|
+
signal?.removeEventListener("abort", onAbort);
|
|
8325
|
+
resolve();
|
|
8326
|
+
}, delayMs);
|
|
8327
|
+
const onAbort = () => {
|
|
8328
|
+
clearTimeout(timeout);
|
|
8329
|
+
signal?.removeEventListener("abort", onAbort);
|
|
8330
|
+
resolve();
|
|
8331
|
+
};
|
|
8332
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
8333
|
+
});
|
|
8334
|
+
}
|
|
8335
|
+
function getErrorHttpStatus(error) {
|
|
8336
|
+
if (typeof error !== "object" || error === null) return void 0;
|
|
8337
|
+
if ("httpStatus" in error && typeof error.httpStatus === "number") {
|
|
8338
|
+
return error.httpStatus;
|
|
8339
|
+
}
|
|
8340
|
+
if ("status" in error && typeof error.status === "number") {
|
|
8341
|
+
return error.status;
|
|
8342
|
+
}
|
|
8343
|
+
return void 0;
|
|
8344
|
+
}
|
|
8345
|
+
async function followLogRequests(resolveUrl, consume, signal, refreshCvm) {
|
|
8346
|
+
let failureCount = 0;
|
|
8347
|
+
let expiredRetries = 0;
|
|
8348
|
+
while (!signal?.aborted) {
|
|
8349
|
+
try {
|
|
8350
|
+
const url = await resolveUrl();
|
|
8351
|
+
if (signal?.aborted) return;
|
|
8352
|
+
const response = await fetch(url, { signal });
|
|
8353
|
+
if (!response.ok) await throwResponseError(response);
|
|
8354
|
+
failureCount = 0;
|
|
8355
|
+
await consume(response);
|
|
8356
|
+
expiredRetries = 0;
|
|
8357
|
+
if (signal?.aborted) return;
|
|
8358
|
+
} catch (error) {
|
|
8359
|
+
if (signal?.aborted || error instanceof Error && error.name === "AbortError") {
|
|
8360
|
+
return;
|
|
8361
|
+
}
|
|
8362
|
+
let retryError = error;
|
|
8363
|
+
if (error instanceof LogAccessError && error.code === "ERR-17-003") {
|
|
8364
|
+
expiredRetries += 1;
|
|
8365
|
+
if (expiredRetries > 3) throw error;
|
|
8366
|
+
try {
|
|
8367
|
+
await refreshCvm?.();
|
|
8368
|
+
continue;
|
|
8369
|
+
} catch (refreshError) {
|
|
8370
|
+
retryError = refreshError;
|
|
8371
|
+
}
|
|
8372
|
+
}
|
|
8373
|
+
const status = getErrorHttpStatus(retryError);
|
|
8374
|
+
if (status !== void 0 && status < 500) throw retryError;
|
|
8375
|
+
if (retryError instanceof LogAccessError && status === void 0) {
|
|
8376
|
+
throw retryError;
|
|
8377
|
+
}
|
|
8378
|
+
failureCount += 1;
|
|
8379
|
+
if (failureCount >= 5) throw retryError;
|
|
8380
|
+
const delayMs = Math.min(250 * 2 ** (failureCount - 1), 5e3);
|
|
8381
|
+
await waitForReconnect(signal, delayMs);
|
|
8382
|
+
}
|
|
8383
|
+
}
|
|
8384
|
+
}
|
|
8385
|
+
async function fetchCvmChannelLogs(client, id, channel, options = {}) {
|
|
8386
|
+
assertSupportedNodeLogOptions(options);
|
|
8387
|
+
const times = resolveLogTimeWindow(options.since, options.until);
|
|
8388
|
+
const baseUrl = await getCvmLogEndpoint(client, id, channel);
|
|
8389
|
+
const url = buildLogUrl(baseUrl, {
|
|
8390
|
+
since: times.since,
|
|
8391
|
+
until: times.until,
|
|
8392
|
+
tail: options.tail,
|
|
8393
|
+
ansi: options.ansi
|
|
8394
|
+
});
|
|
8395
|
+
const response = await fetch(url, { signal: options.signal });
|
|
8396
|
+
if (!response.ok) await throwResponseError(response);
|
|
8397
|
+
return response.text();
|
|
8398
|
+
}
|
|
8399
|
+
async function streamCvmChannelLogs(client, id, channel, onData, options = {}, signal) {
|
|
8400
|
+
assertSupportedNodeLogOptions(options);
|
|
8401
|
+
const abort = signal ?? options.signal;
|
|
8402
|
+
const times = resolveLogTimeWindow(options.since, options.until);
|
|
8403
|
+
let firstRequest = true;
|
|
8404
|
+
await followLogRequests(
|
|
8405
|
+
async () => {
|
|
8406
|
+
const baseUrl = await getCvmLogEndpoint(client, id, channel);
|
|
8407
|
+
const tail = firstRequest ? options.tail : 0;
|
|
8408
|
+
firstRequest = false;
|
|
8409
|
+
return buildLogUrl(baseUrl, {
|
|
8410
|
+
since: times.since,
|
|
8411
|
+
until: times.until,
|
|
8412
|
+
tail,
|
|
8413
|
+
follow: true,
|
|
8414
|
+
ansi: options.ansi
|
|
8415
|
+
});
|
|
8416
|
+
},
|
|
8417
|
+
(response) => streamResponse(response, onData),
|
|
8418
|
+
abort,
|
|
8419
|
+
async () => {
|
|
8420
|
+
await getCvmInfoLogs(client, resolveCvmId(id));
|
|
8421
|
+
}
|
|
8422
|
+
);
|
|
8423
|
+
}
|
|
8424
|
+
async function fetchContainerLogsEntries(client, id, options = {}) {
|
|
8425
|
+
const times = resolveLogTimeWindow(options.since, options.until);
|
|
8426
|
+
const baseUrl = await getContainerLogEndpoint(
|
|
8427
|
+
client,
|
|
8428
|
+
id,
|
|
8429
|
+
options.container,
|
|
8430
|
+
options.matchContainerIdPrefix ?? true
|
|
8431
|
+
);
|
|
8432
|
+
const url = buildLogUrl(baseUrl, {
|
|
8433
|
+
...times,
|
|
8434
|
+
tail: options.tail,
|
|
8435
|
+
timestamps: options.timestamps,
|
|
8436
|
+
ansi: options.ansi,
|
|
8437
|
+
format: options.format ?? "ndjson"
|
|
8438
|
+
});
|
|
8439
|
+
const response = await fetch(url, { signal: options.signal });
|
|
8440
|
+
if (!response.ok) await throwResponseError(response);
|
|
8441
|
+
return parseStructuredLogsToEntries(await response.text());
|
|
8442
|
+
}
|
|
8443
|
+
async function fetchContainerLogs(client, id, options = {}) {
|
|
8444
|
+
const entries = await fetchContainerLogsEntries(client, id, {
|
|
8445
|
+
...options,
|
|
8446
|
+
format: "ndjson"
|
|
8447
|
+
});
|
|
8448
|
+
return entries.map((entry) => entry.message === "" ? "\n" : entry.message).join("");
|
|
8449
|
+
}
|
|
8450
|
+
async function streamContainerLogsEntries(client, id, onEntry, options = {}, signal) {
|
|
8451
|
+
const abort = signal ?? options.signal;
|
|
8452
|
+
const times = resolveLogTimeWindow(options.since, options.until);
|
|
8453
|
+
const cursor = { since: times.since, boundaryCounts: /* @__PURE__ */ new Map() };
|
|
8454
|
+
let replayCounts = /* @__PURE__ */ new Map();
|
|
8455
|
+
let firstRequest = true;
|
|
8456
|
+
const buildRequestUrl = async () => {
|
|
8457
|
+
const baseUrl = await getContainerLogEndpoint(
|
|
8458
|
+
client,
|
|
8459
|
+
id,
|
|
8460
|
+
options.container,
|
|
8461
|
+
options.matchContainerIdPrefix ?? true
|
|
8462
|
+
);
|
|
8463
|
+
const tail = firstRequest ? options.tail : void 0;
|
|
8464
|
+
firstRequest = false;
|
|
8465
|
+
replayCounts = new Map(cursor.boundaryCounts);
|
|
8466
|
+
return buildLogUrl(baseUrl, {
|
|
8467
|
+
since: cursor.since,
|
|
8468
|
+
until: times.until,
|
|
8469
|
+
tail,
|
|
8470
|
+
follow: true,
|
|
8471
|
+
timestamps: true,
|
|
8472
|
+
format: "ndjson"
|
|
8473
|
+
});
|
|
8474
|
+
};
|
|
8475
|
+
await followLogRequests(
|
|
8476
|
+
buildRequestUrl,
|
|
8477
|
+
(response) => streamNdjsonEntriesResponse(response, (entry) => {
|
|
8478
|
+
const timestamp = parseTimestampedMessage(entry.message);
|
|
8479
|
+
if (timestamp.second === void 0 || !timestamp.timestamp) {
|
|
8480
|
+
onEntry(formatFollowContainerEntry(entry, options.timestamps ?? false));
|
|
8481
|
+
return;
|
|
8482
|
+
}
|
|
8483
|
+
const key = JSON.stringify([entry.channel, entry.message]);
|
|
8484
|
+
if (cursor.boundarySecond !== void 0 && timestamp.second < cursor.boundarySecond) {
|
|
8485
|
+
onEntry(formatFollowContainerEntry(entry, options.timestamps ?? false));
|
|
8486
|
+
return;
|
|
8487
|
+
}
|
|
8488
|
+
if (timestamp.second === cursor.boundarySecond) {
|
|
8489
|
+
const replayCount = replayCounts.get(key) ?? 0;
|
|
8490
|
+
if (replayCount > 0) {
|
|
8491
|
+
replayCounts.set(key, replayCount - 1);
|
|
8492
|
+
return;
|
|
8493
|
+
}
|
|
8494
|
+
} else if (cursor.boundarySecond === void 0 || timestamp.second > cursor.boundarySecond) {
|
|
8495
|
+
cursor.boundarySecond = timestamp.second;
|
|
8496
|
+
cursor.boundaryCounts.clear();
|
|
8497
|
+
}
|
|
8498
|
+
cursor.since = Math.max(cursor.since ?? timestamp.second, timestamp.second);
|
|
8499
|
+
cursor.boundaryCounts.set(key, (cursor.boundaryCounts.get(key) ?? 0) + 1);
|
|
8500
|
+
onEntry(formatFollowContainerEntry(entry, options.timestamps ?? false));
|
|
8501
|
+
}),
|
|
8502
|
+
abort,
|
|
8503
|
+
async () => {
|
|
8504
|
+
await getCvmInfoLogs(client, resolveCvmId(id));
|
|
8505
|
+
}
|
|
8506
|
+
);
|
|
8507
|
+
}
|
|
8508
|
+
async function streamContainerLogs(client, id, onData, options = {}, signal) {
|
|
8509
|
+
return streamContainerLogsEntries(
|
|
8510
|
+
client,
|
|
8511
|
+
id,
|
|
8512
|
+
(entry) => onData(entry.message === "" ? "\n" : entry.message),
|
|
8513
|
+
options,
|
|
8514
|
+
signal
|
|
8515
|
+
);
|
|
8516
|
+
}
|
|
8517
|
+
async function fetchCvmLogs(client, id, source, options = {}) {
|
|
8518
|
+
if (source.type === "node") {
|
|
8519
|
+
return fetchCvmChannelLogs(client, id, source.channel, options);
|
|
8520
|
+
}
|
|
8521
|
+
if (options.format === "ndjson") {
|
|
8522
|
+
return fetchContainerLogsEntries(client, id, {
|
|
8523
|
+
...options,
|
|
8524
|
+
container: source.name,
|
|
8525
|
+
matchContainerIdPrefix: source.matchContainerIdPrefix
|
|
8526
|
+
});
|
|
8527
|
+
}
|
|
8528
|
+
return fetchContainerLogs(client, id, {
|
|
8529
|
+
...options,
|
|
8530
|
+
container: source.name,
|
|
8531
|
+
matchContainerIdPrefix: source.matchContainerIdPrefix
|
|
8532
|
+
});
|
|
8533
|
+
}
|
|
8534
|
+
async function* followCvmLogs(client, id, source, options = {}) {
|
|
8535
|
+
const pending = [];
|
|
8536
|
+
let wake;
|
|
8537
|
+
let done = false;
|
|
8538
|
+
let error;
|
|
8539
|
+
const push = (item) => {
|
|
8540
|
+
pending.push(item);
|
|
8541
|
+
wake?.();
|
|
8542
|
+
};
|
|
8543
|
+
const run = source.type === "node" ? streamCvmChannelLogs(client, id, source.channel, push, options, options.signal) : streamContainerLogsEntries(
|
|
8544
|
+
client,
|
|
8545
|
+
id,
|
|
8546
|
+
push,
|
|
8547
|
+
{
|
|
8548
|
+
...options,
|
|
8549
|
+
container: source.name,
|
|
8550
|
+
matchContainerIdPrefix: source.matchContainerIdPrefix
|
|
8551
|
+
},
|
|
8552
|
+
options.signal
|
|
8553
|
+
);
|
|
8554
|
+
void run.then(
|
|
8555
|
+
() => {
|
|
8556
|
+
done = true;
|
|
8557
|
+
wake?.();
|
|
8558
|
+
},
|
|
8559
|
+
(reason) => {
|
|
8560
|
+
error = reason;
|
|
8561
|
+
done = true;
|
|
8562
|
+
wake?.();
|
|
8563
|
+
}
|
|
8564
|
+
);
|
|
8565
|
+
while (!done || pending.length > 0) {
|
|
8566
|
+
if (pending.length > 0) {
|
|
8567
|
+
yield pending.shift();
|
|
8568
|
+
continue;
|
|
8569
|
+
}
|
|
8570
|
+
await new Promise((resolve) => {
|
|
8571
|
+
wake = resolve;
|
|
8572
|
+
});
|
|
8573
|
+
}
|
|
8574
|
+
if (error) throw error;
|
|
8575
|
+
}
|
|
8576
|
+
|
|
7869
8577
|
// src/parse_dotenv.ts
|
|
7870
8578
|
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
7871
8579
|
function parseEnv(input) {
|
|
@@ -8064,6 +8772,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
8064
8772
|
ListKmsContractsSchema,
|
|
8065
8773
|
ListSshKeysResponseSchema,
|
|
8066
8774
|
ListWorkspacesSchema,
|
|
8775
|
+
LogAccessError,
|
|
8067
8776
|
LooseAppComposeSchema,
|
|
8068
8777
|
MAX_COMPOSE_PAYLOAD_BYTES,
|
|
8069
8778
|
MAX_INIT_SCRIPTS,
|
|
@@ -8094,6 +8803,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
8094
8803
|
ProvisionCvmComposeFileUpdateResultSchema,
|
|
8095
8804
|
ProvisionCvmRequestSchema,
|
|
8096
8805
|
ProvisionCvmSchema,
|
|
8806
|
+
PutCvmInitScriptsRequestSchema,
|
|
8097
8807
|
QuotaMetricSchema,
|
|
8098
8808
|
RefreshCvmInstanceIdRequestSchema,
|
|
8099
8809
|
RefreshCvmInstanceIdsRequestSchema,
|
|
@@ -8190,6 +8900,11 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
8190
8900
|
executeTransaction,
|
|
8191
8901
|
executeTransactionWithRetry,
|
|
8192
8902
|
extractNetworkClients,
|
|
8903
|
+
fetchContainerLogs,
|
|
8904
|
+
fetchContainerLogsEntries,
|
|
8905
|
+
fetchCvmChannelLogs,
|
|
8906
|
+
fetchCvmLogs,
|
|
8907
|
+
followCvmLogs,
|
|
8193
8908
|
formatErrorMessage,
|
|
8194
8909
|
formatStructuredError,
|
|
8195
8910
|
formatStructuredErrorDetailValue,
|
|
@@ -8219,6 +8934,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
8219
8934
|
getCvmInfo,
|
|
8220
8935
|
getCvmInitScripts,
|
|
8221
8936
|
getCvmList,
|
|
8937
|
+
getCvmLogEndpoint,
|
|
8222
8938
|
getCvmNetwork,
|
|
8223
8939
|
getCvmPreLaunchScript,
|
|
8224
8940
|
getCvmSshKeys,
|
|
@@ -8260,11 +8976,13 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
8260
8976
|
preprocessAppCompose,
|
|
8261
8977
|
provisionCvm,
|
|
8262
8978
|
provisionCvmComposeFileUpdate,
|
|
8979
|
+
putCvmInitScripts,
|
|
8263
8980
|
refineCvmId,
|
|
8264
8981
|
refreshCvmInstanceId,
|
|
8265
8982
|
refreshCvmInstanceIds,
|
|
8266
8983
|
removeDevice,
|
|
8267
8984
|
replicateCvm,
|
|
8985
|
+
resolveLogTimeWindow,
|
|
8268
8986
|
restartCvm,
|
|
8269
8987
|
revokeCurrentApiToken,
|
|
8270
8988
|
safeAddComposeHash,
|
|
@@ -8334,6 +9052,7 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
8334
9052
|
safePatchCvm,
|
|
8335
9053
|
safeProvisionCvm,
|
|
8336
9054
|
safeProvisionCvmComposeFileUpdate,
|
|
9055
|
+
safePutCvmInitScripts,
|
|
8337
9056
|
safeRefreshCvmInstanceId,
|
|
8338
9057
|
safeRefreshCvmInstanceIds,
|
|
8339
9058
|
safeRemoveDevice,
|
|
@@ -8362,6 +9081,9 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
|
|
|
8362
9081
|
sortObject,
|
|
8363
9082
|
startCvm,
|
|
8364
9083
|
stopCvm,
|
|
9084
|
+
streamContainerLogs,
|
|
9085
|
+
streamContainerLogsEntries,
|
|
9086
|
+
streamCvmChannelLogs,
|
|
8365
9087
|
switchToNetwork,
|
|
8366
9088
|
syncGithubSshKeys,
|
|
8367
9089
|
updateCvmAnnotations,
|