@phala/cloud 0.1.1-beta.1 → 0.1.1-beta.2

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/index.mjs CHANGED
@@ -1,78 +1,1109 @@
1
- import {
2
- ApiErrorSchema,
1
+ // src/client.ts
2
+ import { ofetch } from "ofetch";
3
+ import debug from "debug";
4
+
5
+ // src/types/client.ts
6
+ import { z } from "zod";
7
+ var ApiErrorSchema = z.object({
8
+ detail: z.union([
9
+ z.string(),
10
+ z.array(
11
+ z.object({
12
+ msg: z.string(),
13
+ type: z.string().optional(),
14
+ ctx: z.record(z.unknown()).optional()
15
+ })
16
+ ),
17
+ z.record(z.unknown())
18
+ ]),
19
+ type: z.string().optional(),
20
+ code: z.string().optional()
21
+ });
22
+ var RequestError = class _RequestError extends Error {
23
+ constructor(message, options) {
24
+ super(message);
25
+ this.name = "RequestError";
26
+ this.isRequestError = true;
27
+ this.status = options?.status;
28
+ this.statusText = options?.statusText;
29
+ this.data = options?.data;
30
+ this.request = options?.request;
31
+ this.response = options?.response;
32
+ this.detail = options?.detail || message;
33
+ this.code = options?.code;
34
+ this.type = options?.type;
35
+ }
36
+ /**
37
+ * Create RequestError from FetchError
38
+ */
39
+ static fromFetchError(error) {
40
+ const parseResult = ApiErrorSchema.safeParse(error.data);
41
+ if (parseResult.success) {
42
+ return new _RequestError(error.message, {
43
+ status: error.status ?? void 0,
44
+ statusText: error.statusText ?? void 0,
45
+ data: error.data,
46
+ request: error.request ?? void 0,
47
+ response: error.response ?? void 0,
48
+ detail: parseResult.data.detail,
49
+ code: parseResult.data.code ?? void 0,
50
+ type: parseResult.data.type ?? void 0
51
+ });
52
+ }
53
+ return new _RequestError(error.message, {
54
+ status: error.status ?? void 0,
55
+ statusText: error.statusText ?? void 0,
56
+ data: error.data,
57
+ request: error.request ?? void 0,
58
+ response: error.response ?? void 0,
59
+ detail: error.data?.detail || "Unknown API error",
60
+ code: error.status?.toString() ?? void 0
61
+ });
62
+ }
63
+ /**
64
+ * Create RequestError from generic Error
65
+ */
66
+ static fromError(error, request) {
67
+ return new _RequestError(error.message, {
68
+ request: request ?? void 0,
69
+ detail: error.message
70
+ });
71
+ }
72
+ };
73
+
74
+ // src/client.ts
75
+ var SUPPORTED_API_VERSIONS = ["2025-05-31"];
76
+ var logger = debug("phala::api-client");
77
+ function formatHeaders(headers) {
78
+ return Object.entries(headers).map(([key, value]) => ` -H "${key}: ${value}"`).join("\n");
79
+ }
80
+ function formatBody(body) {
81
+ if (!body) return "";
82
+ const bodyStr = typeof body === "string" ? body : JSON.stringify(body, null, 2);
83
+ return ` -d '${bodyStr.replace(/'/g, "\\'")}'`;
84
+ }
85
+ function formatResponse(status, statusText, headers, body) {
86
+ const headerEntries = [];
87
+ headers.forEach((value, key) => {
88
+ headerEntries.push(`${key}: ${value}`);
89
+ });
90
+ const headerStr = headerEntries.join("\n");
91
+ const bodyStr = typeof body === "string" ? body : JSON.stringify(body, null, 2);
92
+ return [
93
+ `< HTTP/1.1 ${status} ${statusText}`,
94
+ headerStr ? `< ${headerStr.replace(/\n/g, "\n< ")}` : "",
95
+ "",
96
+ bodyStr
97
+ ].filter(Boolean).join("\n");
98
+ }
99
+ var Client = class {
100
+ constructor(config = {}) {
101
+ const resolvedConfig = {
102
+ ...config,
103
+ apiKey: config.apiKey || process?.env?.PHALA_CLOUD_API_KEY,
104
+ baseURL: config.baseURL || process?.env?.PHALA_CLOUD_API_PREFIX || "https://cloud-api.phala.network/api/v1"
105
+ };
106
+ const version = resolvedConfig.version && SUPPORTED_API_VERSIONS.includes(resolvedConfig.version) ? resolvedConfig.version : SUPPORTED_API_VERSIONS[0];
107
+ this.config = resolvedConfig;
108
+ if (!resolvedConfig.useCookieAuth && !resolvedConfig.apiKey) {
109
+ throw new Error(
110
+ "API key is required. Provide it via config.apiKey or set PHALA_CLOUD_API_KEY environment variable."
111
+ );
112
+ }
113
+ const { apiKey, baseURL, timeout, headers, useCookieAuth, onResponseError, ...fetchOptions } = resolvedConfig;
114
+ const requestHeaders = {
115
+ "X-Phala-Version": version,
116
+ "Content-Type": "application/json"
117
+ };
118
+ if (headers && typeof headers === "object") {
119
+ Object.entries(headers).forEach(([key, value]) => {
120
+ if (typeof value === "string") {
121
+ requestHeaders[key] = value;
122
+ }
123
+ });
124
+ }
125
+ if (!useCookieAuth && apiKey) {
126
+ requestHeaders["X-API-Key"] = apiKey;
127
+ }
128
+ this.fetchInstance = ofetch.create({
129
+ baseURL,
130
+ timeout: timeout || 3e4,
131
+ headers: requestHeaders,
132
+ ...useCookieAuth ? { credentials: "include" } : {},
133
+ ...fetchOptions,
134
+ // Log request in cURL format
135
+ onRequest({ request, options }) {
136
+ if (logger.enabled) {
137
+ const method = options.method || "GET";
138
+ const url = typeof request === "string" ? request : request.url;
139
+ const fullUrl = url.startsWith("http") ? url : `${baseURL}${url}`;
140
+ const headerObj = {};
141
+ if (options.headers && typeof options.headers === "object") {
142
+ Object.entries(options.headers).forEach(([key, value]) => {
143
+ if (typeof value === "string") {
144
+ headerObj[key] = value;
145
+ }
146
+ });
147
+ }
148
+ const curlCommand = [
149
+ `> curl -X ${method} "${fullUrl}"`,
150
+ formatHeaders(headerObj),
151
+ options.body ? formatBody(options.body) : ""
152
+ ].filter(Boolean).join("\n");
153
+ logger("\n=== REQUEST ===\n%s\n", curlCommand);
154
+ }
155
+ },
156
+ // Log response in cURL format
157
+ onResponse({ request, response, options }) {
158
+ if (logger.enabled) {
159
+ const method = options.method || "GET";
160
+ const url = typeof request === "string" ? request : request.url;
161
+ logger(
162
+ "\n=== RESPONSE [%s %s] (%dms) ===\n%s\n",
163
+ method,
164
+ url,
165
+ response.headers.get("x-response-time") || "?",
166
+ formatResponse(response.status, response.statusText, response.headers, response._data)
167
+ );
168
+ }
169
+ },
170
+ // Generic handlers for response error (similar to request.ts)
171
+ onResponseError: ({ request, response, options }) => {
172
+ console.warn(`HTTP ${response.status}: ${response.url}`);
173
+ if (logger.enabled) {
174
+ const method = options.method || "GET";
175
+ const url = typeof request === "string" ? request : request.url;
176
+ logger(
177
+ "\n=== ERROR RESPONSE [%s %s] ===\n%s\n",
178
+ method,
179
+ url,
180
+ formatResponse(response.status, response.statusText, response.headers, response._data)
181
+ );
182
+ }
183
+ if (onResponseError) {
184
+ onResponseError({ request, response, options });
185
+ }
186
+ }
187
+ });
188
+ }
189
+ /**
190
+ * Get the underlying ofetch instance for advanced usage
191
+ */
192
+ get raw() {
193
+ return this.fetchInstance;
194
+ }
195
+ // ===== Direct methods (throw on error) =====
196
+ /**
197
+ * Perform GET request (throws on error)
198
+ */
199
+ async get(request, options) {
200
+ return this.fetchInstance(request, {
201
+ ...options,
202
+ method: "GET"
203
+ });
204
+ }
205
+ /**
206
+ * Perform POST request (throws on error)
207
+ */
208
+ async post(request, body, options) {
209
+ return this.fetchInstance(request, {
210
+ ...options,
211
+ method: "POST",
212
+ body
213
+ });
214
+ }
215
+ /**
216
+ * Perform PUT request (throws on error)
217
+ */
218
+ async put(request, body, options) {
219
+ return this.fetchInstance(request, {
220
+ ...options,
221
+ method: "PUT",
222
+ body
223
+ });
224
+ }
225
+ /**
226
+ * Perform PATCH request (throws on error)
227
+ */
228
+ async patch(request, body, options) {
229
+ return this.fetchInstance(request, {
230
+ ...options,
231
+ method: "PATCH",
232
+ body
233
+ });
234
+ }
235
+ /**
236
+ * Perform DELETE request (throws on error)
237
+ */
238
+ async delete(request, options) {
239
+ return this.fetchInstance(request, {
240
+ ...options,
241
+ method: "DELETE"
242
+ });
243
+ }
244
+ // ===== Safe methods (return SafeResult) =====
245
+ /**
246
+ * Safe wrapper for any request method (zod-style result)
247
+ */
248
+ async safeRequest(fn) {
249
+ try {
250
+ const data = await fn();
251
+ return { success: true, data };
252
+ } catch (error) {
253
+ if (error && typeof error === "object" && "data" in error) {
254
+ const requestError2 = RequestError.fromFetchError(error);
255
+ return { success: false, error: requestError2 };
256
+ }
257
+ if (error instanceof Error) {
258
+ const requestError2 = RequestError.fromError(error);
259
+ return { success: false, error: requestError2 };
260
+ }
261
+ const requestError = new RequestError("Unknown error occurred", {
262
+ detail: "Unknown error occurred"
263
+ });
264
+ return { success: false, error: requestError };
265
+ }
266
+ }
267
+ /**
268
+ * Safe GET request (returns SafeResult)
269
+ */
270
+ async safeGet(request, options) {
271
+ return this.safeRequest(() => this.get(request, options));
272
+ }
273
+ /**
274
+ * Safe POST request (returns SafeResult)
275
+ */
276
+ async safePost(request, body, options) {
277
+ return this.safeRequest(() => this.post(request, body, options));
278
+ }
279
+ /**
280
+ * Safe PUT request (returns SafeResult)
281
+ */
282
+ async safePut(request, body, options) {
283
+ return this.safeRequest(() => this.put(request, body, options));
284
+ }
285
+ /**
286
+ * Safe PATCH request (returns SafeResult)
287
+ */
288
+ async safePatch(request, body, options) {
289
+ return this.safeRequest(() => this.patch(request, body, options));
290
+ }
291
+ /**
292
+ * Safe DELETE request (returns SafeResult)
293
+ */
294
+ async safeDelete(request, options) {
295
+ return this.safeRequest(() => this.delete(request, options));
296
+ }
297
+ /**
298
+ * Extend client with additional actions
299
+ *
300
+ * @example
301
+ * ```typescript
302
+ * const client = createClient({ apiKey: 'xxx' })
303
+ * .extend(publicActions)
304
+ * .extend(cvmActions)
305
+ *
306
+ * await client.getCurrentUser() // Method call instead of function call
307
+ * ```
308
+ */
309
+ extend(actions) {
310
+ const actionsObj = typeof actions === "function" ? actions(this) : actions;
311
+ const extended = Object.create(this);
312
+ for (const [key, action] of Object.entries(actionsObj)) {
313
+ if (typeof action === "function") {
314
+ extended[key] = (...args) => action(this, ...args);
315
+ }
316
+ }
317
+ return extended;
318
+ }
319
+ };
320
+ function createClient(config = {}) {
321
+ return new Client(config);
322
+ }
323
+
324
+ // src/actions/get_current_user.ts
325
+ import { z as z2 } from "zod";
326
+
327
+ // src/utils/validate-parameters.ts
328
+ function validateActionParameters(parameters) {
329
+ if (parameters?.schema !== void 0 && parameters?.schema !== false) {
330
+ if (typeof parameters.schema !== "object" || parameters.schema === null || !("parse" in parameters.schema) || typeof parameters.schema.parse !== "function") {
331
+ throw new Error("Invalid schema: must be a Zod schema object, false, or undefined");
332
+ }
333
+ }
334
+ }
335
+ function safeValidateActionParameters(parameters) {
336
+ if (parameters?.schema !== void 0 && parameters?.schema !== false) {
337
+ if (typeof parameters.schema !== "object" || parameters.schema === null || !("parse" in parameters.schema) || typeof parameters.schema.parse !== "function") {
338
+ return {
339
+ success: false,
340
+ error: {
341
+ name: "ZodError",
342
+ message: "Invalid schema: must be a Zod schema object, false, or undefined",
343
+ issues: [
344
+ {
345
+ code: "invalid_type",
346
+ expected: "object",
347
+ received: typeof parameters.schema,
348
+ path: ["schema"],
349
+ message: "Invalid schema: must be a Zod schema object, false, or undefined"
350
+ }
351
+ ]
352
+ }
353
+ };
354
+ }
355
+ }
356
+ return void 0;
357
+ }
358
+
359
+ // src/utils/define-action.ts
360
+ function defineSimpleAction(schema, fn) {
361
+ function action(client, parameters) {
362
+ return _actionImpl(client, parameters);
363
+ }
364
+ async function _actionImpl(client, parameters) {
365
+ validateActionParameters(parameters);
366
+ const response = await fn(client);
367
+ if (parameters?.schema === false) {
368
+ return response;
369
+ }
370
+ const actualSchema = parameters?.schema || schema;
371
+ return actualSchema.parse(response);
372
+ }
373
+ function safeAction(client, parameters) {
374
+ return _safeActionImpl(client, parameters);
375
+ }
376
+ async function _safeActionImpl(client, parameters) {
377
+ const parameterValidationError = safeValidateActionParameters(parameters);
378
+ if (parameterValidationError) {
379
+ return parameterValidationError;
380
+ }
381
+ const httpResult = await (async () => {
382
+ try {
383
+ const data = await fn(client);
384
+ return { success: true, data };
385
+ } catch (error) {
386
+ if (error && typeof error === "object" && "isRequestError" in error) {
387
+ return { success: false, error };
388
+ }
389
+ if (error && typeof error === "object" && "issues" in error) {
390
+ return { success: false, error };
391
+ }
392
+ return {
393
+ success: false,
394
+ error: {
395
+ name: "Error",
396
+ message: error instanceof Error ? error.message : String(error)
397
+ }
398
+ };
399
+ }
400
+ })();
401
+ if (!httpResult.success) {
402
+ return httpResult;
403
+ }
404
+ if (parameters?.schema === false) {
405
+ return { success: true, data: httpResult.data };
406
+ }
407
+ const actualSchema = parameters?.schema || schema;
408
+ return actualSchema.safeParse(httpResult.data);
409
+ }
410
+ return {
411
+ action,
412
+ safeAction
413
+ };
414
+ }
415
+ function defineAction(schema, fn) {
416
+ function action(client, ...args) {
417
+ const [params, parameters] = args;
418
+ return _actionImpl(client, params, parameters);
419
+ }
420
+ async function _actionImpl(client, params, parameters) {
421
+ validateActionParameters(parameters);
422
+ const response = await fn(client, params);
423
+ if (parameters?.schema === false) {
424
+ return response;
425
+ }
426
+ const actualSchema = parameters?.schema || schema;
427
+ return actualSchema.parse(response);
428
+ }
429
+ function safeAction(client, ...args) {
430
+ const [params, parameters] = args;
431
+ return _safeActionImpl(client, params, parameters);
432
+ }
433
+ async function _safeActionImpl(client, params, parameters) {
434
+ const parameterValidationError = safeValidateActionParameters(parameters);
435
+ if (parameterValidationError) {
436
+ return parameterValidationError;
437
+ }
438
+ const httpResult = await (async () => {
439
+ try {
440
+ const data = await fn(client, params);
441
+ return { success: true, data };
442
+ } catch (error) {
443
+ if (error && typeof error === "object" && "isRequestError" in error) {
444
+ return { success: false, error };
445
+ }
446
+ if (error && typeof error === "object" && "issues" in error) {
447
+ return { success: false, error };
448
+ }
449
+ return {
450
+ success: false,
451
+ error: {
452
+ name: "Error",
453
+ message: error instanceof Error ? error.message : String(error)
454
+ }
455
+ };
456
+ }
457
+ })();
458
+ if (!httpResult.success) {
459
+ return httpResult;
460
+ }
461
+ if (parameters?.schema === false) {
462
+ return { success: true, data: httpResult.data };
463
+ }
464
+ const actualSchema = parameters?.schema || schema;
465
+ return actualSchema.safeParse(httpResult.data);
466
+ }
467
+ return {
468
+ action,
469
+ safeAction
470
+ };
471
+ }
472
+
473
+ // src/actions/get_current_user.ts
474
+ var CurrentUserSchema = z2.object({
475
+ username: z2.string(),
476
+ email: z2.string(),
477
+ credits: z2.number(),
478
+ granted_credits: z2.number(),
479
+ avatar: z2.string(),
480
+ team_name: z2.string(),
481
+ team_tier: z2.string()
482
+ }).passthrough();
483
+ var { action: getCurrentUser, safeAction: safeGetCurrentUser } = defineSimpleAction(
484
+ CurrentUserSchema,
485
+ async (client) => {
486
+ return await client.get("/auth/me");
487
+ }
488
+ );
489
+
490
+ // src/actions/get_available_nodes.ts
491
+ import { z as z4 } from "zod";
492
+
493
+ // src/types/kms_info.ts
494
+ import { z as z3 } from "zod";
495
+
496
+ // src/types/supported_chains.ts
497
+ import { anvil, base, mainnet } from "viem/chains";
498
+ var SUPPORTED_CHAINS = {
499
+ [mainnet.id]: mainnet,
500
+ [base.id]: base,
501
+ [anvil.id]: anvil
502
+ };
503
+
504
+ // src/types/kms_info.ts
505
+ var KmsInfoBaseSchema = z3.object({
506
+ id: z3.string(),
507
+ slug: z3.string().nullable(),
508
+ url: z3.string(),
509
+ version: z3.string(),
510
+ chain_id: z3.number().nullable(),
511
+ kms_contract_address: z3.string().nullable().transform((val) => val),
512
+ gateway_app_id: z3.string().nullable().transform((val) => val)
513
+ }).passthrough();
514
+ var KmsInfoSchema = KmsInfoBaseSchema.transform((data) => {
515
+ if (data.chain_id != null) {
516
+ const chain = SUPPORTED_CHAINS[data.chain_id];
517
+ if (chain) {
518
+ return { ...data, chain };
519
+ }
520
+ }
521
+ return data;
522
+ });
523
+
524
+ // src/actions/get_available_nodes.ts
525
+ var AvailableOSImageSchema = z4.object({
526
+ name: z4.string(),
527
+ is_dev: z4.boolean(),
528
+ version: z4.union([
529
+ z4.tuple([z4.number(), z4.number(), z4.number()]),
530
+ z4.tuple([z4.number(), z4.number(), z4.number(), z4.number()])
531
+ ]),
532
+ os_image_hash: z4.string().nullable().optional()
533
+ }).passthrough();
534
+ var TeepodCapacitySchema = z4.object({
535
+ teepod_id: z4.number(),
536
+ name: z4.string(),
537
+ listed: z4.boolean(),
538
+ resource_score: z4.number(),
539
+ remaining_vcpu: z4.number(),
540
+ remaining_memory: z4.number(),
541
+ remaining_cvm_slots: z4.number(),
542
+ images: z4.array(AvailableOSImageSchema),
543
+ support_onchain_kms: z4.boolean().optional(),
544
+ fmspc: z4.string().nullable().optional(),
545
+ device_id: z4.string().nullable().optional(),
546
+ region_identifier: z4.string().nullable().optional(),
547
+ default_kms: z4.string().nullable().optional(),
548
+ kms_list: z4.array(z4.string()).default([])
549
+ }).passthrough();
550
+ var ResourceThresholdSchema = z4.object({
551
+ max_instances: z4.number().nullable().optional(),
552
+ max_vcpu: z4.number().nullable().optional(),
553
+ max_memory: z4.number().nullable().optional(),
554
+ max_disk: z4.number().nullable().optional()
555
+ }).passthrough();
556
+ var AvailableNodesSchema = z4.object({
557
+ tier: z4.string(),
558
+ // TeamTier is string enum
559
+ capacity: ResourceThresholdSchema,
560
+ nodes: z4.array(TeepodCapacitySchema),
561
+ kms_list: z4.array(KmsInfoSchema)
562
+ }).passthrough();
563
+ var { action: getAvailableNodes, safeAction: safeGetAvailableNodes } = defineSimpleAction(
3
564
  AvailableNodesSchema,
4
- CommitCvmComposeFileUpdateRequestSchema,
565
+ async (client) => {
566
+ return await client.get("/teepods/available");
567
+ }
568
+ );
569
+
570
+ // src/actions/list-instance-types.ts
571
+ import { z as z5 } from "zod";
572
+ var ListInstanceTypesRequestSchema = z5.object({
573
+ page: z5.number().int().min(1).optional().default(1),
574
+ page_size: z5.number().int().min(1).max(1e3).optional().default(100)
575
+ }).strict();
576
+ var InstanceTypeSchema = z5.object({
577
+ id: z5.string(),
578
+ name: z5.string(),
579
+ description: z5.string(),
580
+ vcpu: z5.number(),
581
+ memory_mb: z5.number(),
582
+ hourly_rate: z5.string(),
583
+ requires_gpu: z5.boolean(),
584
+ public: z5.boolean(),
585
+ enabled: z5.boolean()
586
+ }).passthrough();
587
+ var PaginatedInstanceTypesSchema = z5.object({
588
+ items: z5.array(InstanceTypeSchema),
589
+ total: z5.number(),
590
+ page: z5.number(),
591
+ page_size: z5.number(),
592
+ pages: z5.number()
593
+ }).strict();
594
+ var { action: listInstanceTypes, safeAction: safeListInstanceTypes } = defineAction(PaginatedInstanceTypesSchema, async (client, request) => {
595
+ const validatedRequest = ListInstanceTypesRequestSchema.parse(request ?? {});
596
+ const queryParams = new URLSearchParams();
597
+ queryParams.append("page", validatedRequest.page.toString());
598
+ queryParams.append("page_size", validatedRequest.page_size.toString());
599
+ return await client.get(`/api/instance-types?${queryParams.toString()}`);
600
+ });
601
+
602
+ // src/actions/workspaces/list_workspaces.ts
603
+ import { z as z6 } from "zod";
604
+ var WorkspaceResponseSchema = z6.object({
605
+ id: z6.string(),
606
+ name: z6.string(),
607
+ slug: z6.string().nullable(),
608
+ tier: z6.string(),
609
+ role: z6.string(),
610
+ created_at: z6.string()
611
+ }).passthrough();
612
+ var PaginationMetadataSchema = z6.object({
613
+ has_more: z6.boolean(),
614
+ next_cursor: z6.string().nullable(),
615
+ total: z6.number().nullable()
616
+ }).passthrough();
617
+ var ListWorkspacesSchema = z6.object({
618
+ data: z6.array(WorkspaceResponseSchema),
619
+ pagination: PaginationMetadataSchema
620
+ }).passthrough();
621
+ var { action: listWorkspaces, safeAction: safeListWorkspaces } = defineAction(ListWorkspacesSchema, async (client, request) => {
622
+ const queryParams = new URLSearchParams();
623
+ if (request?.cursor) queryParams.append("cursor", request.cursor);
624
+ if (request?.limit) queryParams.append("limit", request.limit.toString());
625
+ const url = queryParams.toString() ? `/workspaces?${queryParams.toString()}` : "/workspaces";
626
+ return await client.get(url);
627
+ });
628
+
629
+ // src/actions/workspaces/get_workspace.ts
630
+ var { action: getWorkspace, safeAction: safeGetWorkspace } = defineAction(WorkspaceResponseSchema, async (client, teamSlug) => {
631
+ return await client.get(`/workspaces/${teamSlug}`);
632
+ });
633
+
634
+ // src/actions/cvms/get_cvm_info.ts
635
+ import { z as z8 } from "zod";
636
+
637
+ // src/types/cvm_info.ts
638
+ import { z as z7 } from "zod";
639
+ var VmInfoSchema = z7.object({
640
+ id: z7.string(),
641
+ name: z7.string(),
642
+ status: z7.string(),
643
+ uptime: z7.string(),
644
+ app_url: z7.string().nullable(),
645
+ app_id: z7.string(),
646
+ instance_id: z7.string().nullable(),
647
+ configuration: z7.any().optional(),
648
+ // TODO: add VmConfiguration schema if needed
649
+ exited_at: z7.string().nullable(),
650
+ boot_progress: z7.string().nullable(),
651
+ boot_error: z7.string().nullable(),
652
+ shutdown_progress: z7.string().nullable(),
653
+ image_version: z7.string().nullable()
654
+ });
655
+ var ManagedUserSchema = z7.object({
656
+ id: z7.number(),
657
+ username: z7.string()
658
+ });
659
+ var CvmNodeSchema = z7.object({
660
+ id: z7.number(),
661
+ name: z7.string(),
662
+ region_identifier: z7.string().optional()
663
+ });
664
+ var CvmNetworkUrlsSchema = z7.object({
665
+ app: z7.string(),
666
+ instance: z7.string()
667
+ });
668
+ var CvmInfoSchema = z7.object({
669
+ hosted: VmInfoSchema,
670
+ name: z7.string(),
671
+ managed_user: ManagedUserSchema.optional().nullable(),
672
+ node: CvmNodeSchema.optional().nullable(),
673
+ listed: z7.boolean().default(false),
674
+ status: z7.string(),
675
+ in_progress: z7.boolean().default(false),
676
+ dapp_dashboard_url: z7.string().nullable(),
677
+ syslog_endpoint: z7.string().nullable(),
678
+ allow_upgrade: z7.boolean().default(false),
679
+ project_id: z7.string().nullable(),
680
+ // HashedId is represented as string in JS
681
+ project_type: z7.string().nullable(),
682
+ billing_period: z7.string().nullable(),
683
+ kms_info: KmsInfoSchema.nullable(),
684
+ vcpu: z7.number().nullable(),
685
+ memory: z7.number().nullable(),
686
+ disk_size: z7.number().nullable(),
687
+ gateway_domain: z7.string().nullable(),
688
+ public_urls: z7.array(CvmNetworkUrlsSchema)
689
+ }).partial();
690
+ var CvmLegacyDetailSchema = z7.object({
691
+ id: z7.number(),
692
+ name: z7.string(),
693
+ status: z7.string(),
694
+ in_progress: z7.boolean(),
695
+ teepod_id: z7.number().nullable(),
696
+ teepod: CvmNodeSchema,
697
+ app_id: z7.string(),
698
+ vm_uuid: z7.string().nullable(),
699
+ instance_id: z7.string().nullable(),
700
+ vcpu: z7.number().nullable(),
701
+ memory: z7.number().nullable(),
702
+ disk_size: z7.number().nullable(),
703
+ base_image: z7.string(),
704
+ encrypted_env_pubkey: z7.string().nullable(),
705
+ listed: z7.boolean(),
706
+ project_id: z7.string().nullable(),
707
+ project_type: z7.string().nullable(),
708
+ public_sysinfo: z7.boolean(),
709
+ public_logs: z7.boolean(),
710
+ dapp_dashboard_url: z7.string().nullable(),
711
+ syslog_endpoint: z7.string().nullable(),
712
+ kms_info: KmsInfoSchema.nullable(),
713
+ contract_address: z7.string().nullable(),
714
+ deployer_address: z7.string().nullable(),
715
+ scheduled_delete_at: z7.string().nullable(),
716
+ public_urls: z7.array(CvmNetworkUrlsSchema),
717
+ gateway_domain: z7.string().nullable()
718
+ });
719
+
720
+ // src/actions/cvms/get_cvm_info.ts
721
+ var GetCvmInfoRequestSchema = z8.object({
722
+ id: z8.string().optional(),
723
+ uuid: z8.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),
724
+ app_id: z8.string().refine(
725
+ (val) => !val.startsWith("app_") && val.length === 40,
726
+ "app_id should be 40 characters without prefix"
727
+ ).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
728
+ instance_id: z8.string().refine(
729
+ (val) => !val.startsWith("instance_") && val.length === 40,
730
+ "instance_id should be 40 characters without prefix"
731
+ ).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional()
732
+ }).refine(
733
+ (data) => !!(data.id || data.uuid || data.app_id || data.instance_id),
734
+ "One of id, uuid, app_id, or instance_id must be provided"
735
+ ).transform((data) => ({
736
+ cvmId: data.id || data.uuid || data.app_id || data.instance_id,
737
+ _raw: data
738
+ }));
739
+ var { action: getCvmInfo, safeAction: safeGetCvmInfo } = defineAction(CvmLegacyDetailSchema, async (client, request) => {
740
+ const validatedRequest = GetCvmInfoRequestSchema.parse(request);
741
+ return await client.get(`/cvms/${validatedRequest.cvmId}`);
742
+ });
743
+
744
+ // src/actions/cvms/get_cvm_list.ts
745
+ import { z as z9 } from "zod";
746
+ var GetCvmListRequestSchema = z9.object({
747
+ page: z9.number().int().min(1).optional(),
748
+ page_size: z9.number().int().min(1).optional(),
749
+ node_id: z9.number().int().min(1).optional()
750
+ }).strict();
751
+ var GetCvmListSchema = z9.object({
752
+ items: z9.array(CvmInfoSchema),
753
+ total: z9.number(),
754
+ page: z9.number(),
755
+ page_size: z9.number(),
756
+ pages: z9.number()
757
+ }).strict();
758
+ var { action: getCvmList, safeAction: safeGetCvmList } = defineAction(GetCvmListSchema, async (client, request) => {
759
+ const validatedRequest = GetCvmListRequestSchema.parse(request ?? {});
760
+ return await client.get("/cvms/paginated", { params: validatedRequest });
761
+ });
762
+
763
+ // src/actions/cvms/provision_cvm.ts
764
+ import { z as z10 } from "zod";
765
+ var ProvisionCvmSchema = z10.object({
766
+ app_id: z10.string().nullable().optional(),
767
+ app_env_encrypt_pubkey: z10.string().nullable().optional(),
768
+ compose_hash: z10.string(),
769
+ fmspc: z10.string().nullable().optional(),
770
+ device_id: z10.string().nullable().optional(),
771
+ os_image_hash: z10.string().nullable().optional(),
772
+ teepod_id: z10.number().nullable().optional(),
773
+ // Will be transformed to node_id
774
+ node_id: z10.number().nullable().optional(),
775
+ kms_id: z10.string().nullable().optional()
776
+ }).passthrough().transform((data) => {
777
+ if ("teepod_id" in data && data.teepod_id !== void 0) {
778
+ const { teepod_id, ...rest } = data;
779
+ return { ...rest, node_id: teepod_id };
780
+ }
781
+ return data;
782
+ });
783
+ var ProvisionCvmRequestSchema = z10.object({
784
+ node_id: z10.number().optional(),
785
+ // recommended
786
+ teepod_id: z10.number().optional(),
787
+ // deprecated, for compatibility
788
+ name: z10.string(),
789
+ image: z10.string(),
790
+ vcpu: z10.number(),
791
+ memory: z10.number(),
792
+ disk_size: z10.number(),
793
+ compose_file: z10.object({
794
+ allowed_envs: z10.array(z10.string()).optional(),
795
+ pre_launch_script: z10.string().optional(),
796
+ docker_compose_file: z10.string().optional(),
797
+ name: z10.string().optional(),
798
+ kms_enabled: z10.boolean().optional(),
799
+ public_logs: z10.boolean().optional(),
800
+ public_sysinfo: z10.boolean().optional(),
801
+ gateway_enabled: z10.boolean().optional(),
802
+ // recommended
803
+ tproxy_enabled: z10.boolean().optional()
804
+ // deprecated, for compatibility
805
+ }),
806
+ listed: z10.boolean().optional(),
807
+ instance_type: z10.string().nullable().optional(),
808
+ kms_id: z10.string().optional(),
809
+ env_keys: z10.array(z10.string()).optional()
810
+ }).passthrough();
811
+ function autofillComposeFileName(appCompose) {
812
+ if (appCompose.compose_file && !appCompose.compose_file.name) {
813
+ return {
814
+ ...appCompose,
815
+ compose_file: {
816
+ ...appCompose.compose_file,
817
+ name: appCompose.name
818
+ }
819
+ };
820
+ }
821
+ return appCompose;
822
+ }
823
+ function handleGatewayCompatibility(appCompose) {
824
+ if (!appCompose.compose_file) {
825
+ return appCompose;
826
+ }
827
+ const composeFile = { ...appCompose.compose_file };
828
+ if (typeof composeFile.gateway_enabled === "boolean" && typeof composeFile.tproxy_enabled === "boolean") {
829
+ delete composeFile.tproxy_enabled;
830
+ } else if (typeof composeFile.tproxy_enabled === "boolean" && typeof composeFile.gateway_enabled === "undefined") {
831
+ composeFile.gateway_enabled = composeFile.tproxy_enabled;
832
+ delete composeFile.tproxy_enabled;
833
+ if (typeof window !== "undefined" ? window.console : globalThis.console) {
834
+ console.warn(
835
+ "[phala/cloud] tproxy_enabled is deprecated, please use gateway_enabled instead. See docs for migration."
836
+ );
837
+ }
838
+ }
839
+ return {
840
+ ...appCompose,
841
+ compose_file: composeFile
842
+ };
843
+ }
844
+ var { action: provisionCvm, safeAction: safeProvisionCvm } = defineAction(ProvisionCvmSchema, async (client, appCompose) => {
845
+ const body = handleGatewayCompatibility(autofillComposeFileName(appCompose));
846
+ let requestBody = { ...body };
847
+ if (typeof body.node_id === "number") {
848
+ requestBody = { ...body, teepod_id: body.node_id };
849
+ delete requestBody.node_id;
850
+ } else if (typeof body.teepod_id === "number") {
851
+ console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead.");
852
+ }
853
+ return await client.post("/cvms/provision", requestBody);
854
+ });
855
+
856
+ // src/actions/cvms/commit_cvm_provision.ts
857
+ import { z as z11 } from "zod";
858
+ var CommitCvmProvisionSchema = z11.object({
859
+ id: z11.number(),
860
+ name: z11.string(),
861
+ status: z11.string(),
862
+ teepod_id: z11.number(),
863
+ teepod: z11.object({
864
+ id: z11.number(),
865
+ name: z11.string()
866
+ }).nullable(),
867
+ user_id: z11.number().nullable(),
868
+ app_id: z11.string().nullable(),
869
+ vm_uuid: z11.string().nullable(),
870
+ instance_id: z11.string().nullable(),
871
+ app_url: z11.string().nullable(),
872
+ base_image: z11.string().nullable(),
873
+ vcpu: z11.number(),
874
+ memory: z11.number(),
875
+ disk_size: z11.number(),
876
+ manifest_version: z11.number().nullable(),
877
+ version: z11.string().nullable(),
878
+ runner: z11.string().nullable(),
879
+ docker_compose_file: z11.string().nullable(),
880
+ features: z11.array(z11.string()).nullable(),
881
+ created_at: z11.string(),
882
+ encrypted_env_pubkey: z11.string().nullable().optional(),
883
+ app_auth_contract_address: z11.string().nullable().optional(),
884
+ deployer_address: z11.string().nullable().optional()
885
+ }).passthrough();
886
+ var CommitCvmProvisionRequestSchema = z11.object({
887
+ encrypted_env: z11.string().optional().nullable(),
888
+ app_id: z11.string(),
889
+ compose_hash: z11.string().optional(),
890
+ kms_id: z11.string().optional(),
891
+ contract_address: z11.string().optional(),
892
+ deployer_address: z11.string().optional(),
893
+ env_keys: z11.array(z11.string()).optional().nullable()
894
+ }).passthrough();
895
+ var { action: commitCvmProvision, safeAction: safeCommitCvmProvision } = defineAction(CommitCvmProvisionSchema, async (client, payload) => {
896
+ return await client.post("/cvms", payload);
897
+ });
898
+
899
+ // src/actions/cvms/get_cvm_compose_file.ts
900
+ import { z as z13 } from "zod";
901
+
902
+ // src/types/app_compose.ts
903
+ import { z as z12 } from "zod";
904
+ var LooseAppComposeSchema = z12.object({
905
+ allowed_envs: z12.array(z12.string()).optional(),
906
+ docker_compose_file: z12.string(),
907
+ features: z12.array(z12.string()).optional(),
908
+ name: z12.string().optional(),
909
+ manifest_version: z12.number().optional(),
910
+ kms_enabled: z12.boolean().optional(),
911
+ public_logs: z12.boolean().optional(),
912
+ public_sysinfo: z12.boolean().optional(),
913
+ tproxy_enabled: z12.boolean().optional(),
914
+ pre_launch_script: z12.string().optional()
915
+ }).passthrough();
916
+
917
+ // src/actions/cvms/get_cvm_compose_file.ts
918
+ var GetCvmComposeFileRequestSchema = z13.object({
919
+ id: z13.string().optional(),
920
+ uuid: z13.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),
921
+ app_id: z13.string().refine(
922
+ (val) => !val.startsWith("app_") && val.length === 40,
923
+ "app_id should be 40 characters without prefix"
924
+ ).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
925
+ instance_id: z13.string().refine(
926
+ (val) => !val.startsWith("instance_") && val.length === 40,
927
+ "instance_id should be 40 characters without prefix"
928
+ ).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional()
929
+ }).refine(
930
+ (data) => !!(data.id || data.uuid || data.app_id || data.instance_id),
931
+ "One of id, uuid, app_id, or instance_id must be provided"
932
+ ).transform((data) => ({
933
+ cvmId: data.id || data.uuid || data.app_id || data.instance_id,
934
+ _raw: data
935
+ }));
936
+ var { action: getCvmComposeFile, safeAction: safeGetCvmComposeFile } = defineAction(LooseAppComposeSchema, async (client, request) => {
937
+ const validatedRequest = GetCvmComposeFileRequestSchema.parse(request);
938
+ return await client.get(`/cvms/${validatedRequest.cvmId}/compose_file`);
939
+ });
940
+
941
+ // src/actions/cvms/provision_cvm_compose_file_update.ts
942
+ import { z as z14 } from "zod";
943
+ var ProvisionCvmComposeFileUpdateRequestSchema = z14.object({
944
+ id: z14.string().optional(),
945
+ uuid: z14.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),
946
+ app_id: z14.string().refine(
947
+ (val) => !val.startsWith("app_") && val.length === 40,
948
+ "app_id should be 40 characters without prefix"
949
+ ).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
950
+ instance_id: z14.string().refine(
951
+ (val) => !val.startsWith("instance_") && val.length === 40,
952
+ "instance_id should be 40 characters without prefix"
953
+ ).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional(),
954
+ app_compose: LooseAppComposeSchema,
955
+ update_env_vars: z14.boolean().optional().nullable()
956
+ }).refine(
957
+ (data) => !!(data.id || data.uuid || data.app_id || data.instance_id),
958
+ "One of id, uuid, app_id, or instance_id must be provided"
959
+ ).transform((data) => ({
960
+ cvmId: data.id || data.uuid || data.app_id || data.instance_id,
961
+ request: data.app_compose,
962
+ update_env_vars: data.update_env_vars,
963
+ _raw: data
964
+ }));
965
+ var ProvisionCvmComposeFileUpdateResultSchema = z14.object({
966
+ app_id: z14.string().nullable(),
967
+ device_id: z14.string().nullable(),
968
+ compose_hash: z14.string(),
969
+ kms_info: KmsInfoSchema.nullable().optional()
970
+ }).passthrough();
971
+ var { action: provisionCvmComposeFileUpdate, safeAction: safeProvisionCvmComposeFileUpdate } = defineAction(ProvisionCvmComposeFileUpdateResultSchema, async (client, request) => {
972
+ const validatedRequest = ProvisionCvmComposeFileUpdateRequestSchema.parse(request);
973
+ return await client.post(
974
+ `/cvms/${validatedRequest.cvmId}/compose_file/provision`,
975
+ validatedRequest.request
976
+ );
977
+ });
978
+
979
+ // src/actions/cvms/commit_cvm_compose_file_update.ts
980
+ import { z as z15 } from "zod";
981
+ var CommitCvmComposeFileUpdateRequestSchema = z15.object({
982
+ id: z15.string().optional(),
983
+ uuid: z15.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),
984
+ app_id: z15.string().refine(
985
+ (val) => !val.startsWith("app_") && val.length === 40,
986
+ "app_id should be 40 characters without prefix"
987
+ ).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
988
+ instance_id: z15.string().refine(
989
+ (val) => !val.startsWith("instance_") && val.length === 40,
990
+ "instance_id should be 40 characters without prefix"
991
+ ).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional(),
992
+ compose_hash: z15.string().min(1, "Compose hash is required"),
993
+ encrypted_env: z15.string().optional(),
994
+ env_keys: z15.array(z15.string()).optional(),
995
+ update_env_vars: z15.boolean().optional().nullable()
996
+ }).refine(
997
+ (data) => !!(data.id || data.uuid || data.app_id || data.instance_id),
998
+ "One of id, uuid, app_id, or instance_id must be provided"
999
+ ).transform((data) => ({
1000
+ cvmId: data.id || data.uuid || data.app_id || data.instance_id,
1001
+ compose_hash: data.compose_hash,
1002
+ encrypted_env: data.encrypted_env,
1003
+ env_keys: data.env_keys,
1004
+ update_env_vars: !!data.update_env_vars,
1005
+ _raw: data
1006
+ }));
1007
+ var CommitCvmComposeFileUpdateSchema = z15.any().transform(() => void 0);
1008
+ var { action: commitCvmComposeFileUpdate, safeAction: safeCommitCvmComposeFileUpdate } = defineAction(
5
1009
  CommitCvmComposeFileUpdateSchema,
6
- CommitCvmProvisionRequestSchema,
7
- CommitCvmProvisionSchema,
8
- CurrentUserSchema,
9
- CvmInfoSchema,
10
- CvmLegacyDetailSchema,
11
- CvmNetworkUrlsSchema,
12
- CvmNodeSchema,
13
- GetAppEnvEncryptPubKeyRequestSchema,
14
- GetAppEnvEncryptPubKeySchema,
15
- GetCvmComposeFileRequestSchema,
16
- GetCvmInfoRequestSchema,
17
- GetCvmListRequestSchema,
18
- GetCvmListSchema,
19
- GetKmsInfoRequestSchema,
20
- GetKmsListRequestSchema,
21
- GetKmsListSchema,
22
- InstanceTypeSchema,
23
- KmsInfoSchema,
24
- ListInstanceTypesRequestSchema,
25
- ListWorkspacesSchema,
26
- ManagedUserSchema,
27
- PaginatedInstanceTypesSchema,
28
- PaginationMetadataSchema,
29
- ProvisionCvmComposeFileUpdateRequestSchema,
30
- ProvisionCvmComposeFileUpdateResultSchema,
31
- ProvisionCvmRequestSchema,
32
- ProvisionCvmSchema,
33
- RequestError,
34
- SUPPORTED_CHAINS,
35
- VmInfoSchema,
36
- WorkspaceResponseSchema,
37
- commitCvmComposeFileUpdate,
38
- commitCvmProvision,
39
- createClient,
40
- defineAction,
41
- defineSimpleAction,
42
- getAppEnvEncryptPubKey,
43
- getAvailableNodes,
44
- getCurrentUser,
45
- getCvmComposeFile,
46
- getCvmInfo,
47
- getCvmList,
48
- getKmsInfo,
49
- getKmsList,
50
- getWorkspace,
51
- listInstanceTypes,
52
- listWorkspaces,
53
- provisionCvm,
54
- provisionCvmComposeFileUpdate,
55
- safeCommitCvmComposeFileUpdate,
56
- safeCommitCvmProvision,
57
- safeGetAppEnvEncryptPubKey,
58
- safeGetAvailableNodes,
59
- safeGetCurrentUser,
60
- safeGetCvmComposeFile,
61
- safeGetCvmInfo,
62
- safeGetCvmList,
63
- safeGetKmsInfo,
64
- safeGetKmsList,
65
- safeGetWorkspace,
66
- safeListInstanceTypes,
67
- safeListWorkspaces,
68
- safeProvisionCvm,
69
- safeProvisionCvmComposeFileUpdate,
70
- safeValidateActionParameters,
71
- validateActionParameters
72
- } from "./chunk-O5QBIXBA.mjs";
1010
+ async (client, request) => {
1011
+ const validatedRequest = CommitCvmComposeFileUpdateRequestSchema.parse(request);
1012
+ return await client.patch(`/cvms/${validatedRequest.cvmId}/compose_file`, {
1013
+ compose_hash: validatedRequest.compose_hash,
1014
+ encrypted_env: validatedRequest.encrypted_env,
1015
+ env_keys: validatedRequest.env_keys
1016
+ });
1017
+ }
1018
+ );
1019
+
1020
+ // src/actions/kms/get_kms_info.ts
1021
+ import { z as z16 } from "zod";
1022
+ var GetKmsInfoRequestSchema = z16.object({
1023
+ kms_id: z16.string().min(1, "KMS ID is required")
1024
+ });
1025
+ var { action: getKmsInfo, safeAction: safeGetKmsInfo } = defineAction(KmsInfoSchema, async (client, request) => {
1026
+ const validatedRequest = GetKmsInfoRequestSchema.parse(request);
1027
+ return await client.get(`/kms/${validatedRequest.kms_id}`);
1028
+ });
1029
+
1030
+ // src/actions/kms/get_kms_list.ts
1031
+ import { z as z17 } from "zod";
1032
+ var GetKmsListRequestSchema = z17.object({
1033
+ page: z17.number().int().min(1).optional(),
1034
+ page_size: z17.number().int().min(1).optional(),
1035
+ is_onchain: z17.boolean().optional()
1036
+ }).strict();
1037
+ var GetKmsListSchema = z17.object({
1038
+ items: z17.array(KmsInfoSchema),
1039
+ total: z17.number(),
1040
+ page: z17.number(),
1041
+ page_size: z17.number(),
1042
+ pages: z17.number()
1043
+ }).strict();
1044
+ var { action: getKmsList, safeAction: safeGetKmsList } = defineAction(GetKmsListSchema, async (client, request) => {
1045
+ const validatedRequest = GetKmsListRequestSchema.parse(request ?? {});
1046
+ return await client.get("/kms", { params: validatedRequest });
1047
+ });
1048
+
1049
+ // src/actions/kms/get_app_env_encrypt_pubkey.ts
1050
+ import { z as z18 } from "zod";
1051
+ var GetAppEnvEncryptPubKeyRequestSchema = z18.object({
1052
+ kms: z18.string().min(1, "KMS ID or slug is required"),
1053
+ app_id: z18.string().refine(
1054
+ (val) => val.length === 40 || val.startsWith("0x") && val.length === 42,
1055
+ "App ID must be exactly 40 characters or 42 characters with 0x prefix"
1056
+ )
1057
+ }).strict();
1058
+ var GetAppEnvEncryptPubKeySchema = z18.object({
1059
+ public_key: z18.string(),
1060
+ signature: z18.string()
1061
+ }).strict();
1062
+ var { action: getAppEnvEncryptPubKey, safeAction: safeGetAppEnvEncryptPubKey } = defineAction(GetAppEnvEncryptPubKeySchema, async (client, payload) => {
1063
+ const validatedRequest = GetAppEnvEncryptPubKeyRequestSchema.parse(payload);
1064
+ return await client.get(`/kms/${validatedRequest.kms}/pubkey/${validatedRequest.app_id}`);
1065
+ });
1066
+
1067
+ // src/create-client.ts
1068
+ function createClient2(config = {}) {
1069
+ const client = createClient(config);
1070
+ const allActions = {
1071
+ getCurrentUser,
1072
+ safeGetCurrentUser,
1073
+ getAvailableNodes,
1074
+ safeGetAvailableNodes,
1075
+ listInstanceTypes,
1076
+ safeListInstanceTypes,
1077
+ listWorkspaces,
1078
+ safeListWorkspaces,
1079
+ getWorkspace,
1080
+ safeGetWorkspace,
1081
+ getCvmInfo,
1082
+ safeGetCvmInfo,
1083
+ getCvmList,
1084
+ safeGetCvmList,
1085
+ provisionCvm,
1086
+ safeProvisionCvm,
1087
+ commitCvmProvision,
1088
+ safeCommitCvmProvision,
1089
+ getCvmComposeFile,
1090
+ safeGetCvmComposeFile,
1091
+ provisionCvmComposeFileUpdate,
1092
+ safeProvisionCvmComposeFileUpdate,
1093
+ commitCvmComposeFileUpdate,
1094
+ safeCommitCvmComposeFileUpdate,
1095
+ getKmsInfo,
1096
+ safeGetKmsInfo,
1097
+ getKmsList,
1098
+ safeGetKmsList,
1099
+ getAppEnvEncryptPubKey,
1100
+ safeGetAppEnvEncryptPubKey
1101
+ };
1102
+ return client.extend(allActions);
1103
+ }
73
1104
 
74
1105
  // src/actions/blockchains/deploy_app_auth.ts
75
- import { z } from "zod";
1106
+ import { z as z19 } from "zod";
76
1107
  import {
77
1108
  createPublicClient as createPublicClient2,
78
1109
  createWalletClient as createWalletClient2,
@@ -750,25 +1781,25 @@ var kmsAuthAbi = [
750
1781
  anonymous: false
751
1782
  }
752
1783
  ];
753
- var DeployAppAuthRequestBaseSchema = z.object({
1784
+ var DeployAppAuthRequestBaseSchema = z19.object({
754
1785
  // Chain configuration (conditionally required)
755
- chain: z.unknown().optional(),
756
- rpcUrl: z.string().optional(),
1786
+ chain: z19.unknown().optional(),
1787
+ rpcUrl: z19.string().optional(),
757
1788
  // Contract configuration (required)
758
- kmsContractAddress: z.string(),
1789
+ kmsContractAddress: z19.string(),
759
1790
  // Authentication mode: either privateKey OR walletClient (required, mutually exclusive)
760
- privateKey: z.string().optional(),
761
- walletClient: z.unknown().optional(),
1791
+ privateKey: z19.string().optional(),
1792
+ walletClient: z19.unknown().optional(),
762
1793
  // Public client (optional, will create default if not provided)
763
- publicClient: z.unknown().optional(),
1794
+ publicClient: z19.unknown().optional(),
764
1795
  // App configuration (optional)
765
- allowAnyDevice: z.boolean().optional().default(false),
766
- deviceId: z.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
767
- composeHash: z.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
768
- disableUpgrades: z.boolean().optional().default(false),
1796
+ allowAnyDevice: z19.boolean().optional().default(false),
1797
+ deviceId: z19.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
1798
+ composeHash: z19.string().optional().default("0000000000000000000000000000000000000000000000000000000000000000"),
1799
+ disableUpgrades: z19.boolean().optional().default(false),
769
1800
  // Validation configuration (optional)
770
- skipPrerequisiteChecks: z.boolean().optional().default(false),
771
- minBalance: z.string().optional()
1801
+ skipPrerequisiteChecks: z19.boolean().optional().default(false),
1802
+ minBalance: z19.string().optional()
772
1803
  // ETH amount as string, e.g., "0.01"
773
1804
  }).passthrough();
774
1805
  var DeployAppAuthRequestSchema = DeployAppAuthRequestBaseSchema.refine(
@@ -796,13 +1827,13 @@ var DeployAppAuthRequestSchema = DeployAppAuthRequestBaseSchema.refine(
796
1827
  path: ["chain"]
797
1828
  }
798
1829
  );
799
- var DeployAppAuthSchema = z.object({
800
- appId: z.string(),
801
- appAuthAddress: z.string(),
802
- deployer: z.string(),
803
- transactionHash: z.string(),
804
- blockNumber: z.bigint().optional(),
805
- gasUsed: z.bigint().optional()
1830
+ var DeployAppAuthSchema = z19.object({
1831
+ appId: z19.string(),
1832
+ appAuthAddress: z19.string(),
1833
+ deployer: z19.string(),
1834
+ transactionHash: z19.string(),
1835
+ blockNumber: z19.bigint().optional(),
1836
+ gasUsed: z19.bigint().optional()
806
1837
  }).passthrough();
807
1838
  function parseDeploymentResult(receipt, deployer, kmsContractAddress) {
808
1839
  try {
@@ -1048,7 +2079,7 @@ async function safeDeployAppAuth(request, parameters) {
1048
2079
  }
1049
2080
 
1050
2081
  // src/actions/blockchains/add_compose_hash.ts
1051
- import { z as z2 } from "zod";
2082
+ import { z as z20 } from "zod";
1052
2083
  import {
1053
2084
  createPublicClient as createPublicClient3,
1054
2085
  createWalletClient as createWalletClient3,
@@ -1072,29 +2103,29 @@ var appAuthAbi = [
1072
2103
  anonymous: false
1073
2104
  }
1074
2105
  ];
1075
- var AddComposeHashRequestSchema = z2.object({
2106
+ var AddComposeHashRequestSchema = z20.object({
1076
2107
  // Chain configuration (conditionally required)
1077
- chain: z2.unknown().optional(),
1078
- rpcUrl: z2.string().optional(),
1079
- appId: z2.string(),
1080
- composeHash: z2.string(),
2108
+ chain: z20.unknown().optional(),
2109
+ rpcUrl: z20.string().optional(),
2110
+ appId: z20.string(),
2111
+ composeHash: z20.string(),
1081
2112
  // Authentication mode: either privateKey OR walletClient (required, mutually exclusive)
1082
- privateKey: z2.string().optional(),
1083
- walletClient: z2.unknown().optional(),
2113
+ privateKey: z20.string().optional(),
2114
+ walletClient: z20.unknown().optional(),
1084
2115
  // Public client (optional, will create default if not provided)
1085
- publicClient: z2.unknown().optional(),
2116
+ publicClient: z20.unknown().optional(),
1086
2117
  // Validation configuration (optional)
1087
- skipPrerequisiteChecks: z2.boolean().optional().default(false),
1088
- minBalance: z2.string().optional(),
2118
+ skipPrerequisiteChecks: z20.boolean().optional().default(false),
2119
+ minBalance: z20.string().optional(),
1089
2120
  // ETH amount as string, e.g., "0.01"
1090
2121
  // Transaction control options
1091
- timeout: z2.number().optional().default(12e4),
1092
- retryOptions: z2.unknown().optional(),
1093
- signal: z2.unknown().optional(),
2122
+ timeout: z20.number().optional().default(12e4),
2123
+ retryOptions: z20.unknown().optional(),
2124
+ signal: z20.unknown().optional(),
1094
2125
  // Progress callbacks
1095
- onTransactionStateChange: z2.function().optional(),
1096
- onTransactionSubmitted: z2.function().optional(),
1097
- onTransactionConfirmed: z2.function().optional()
2126
+ onTransactionStateChange: z20.function().optional(),
2127
+ onTransactionSubmitted: z20.function().optional(),
2128
+ onTransactionConfirmed: z20.function().optional()
1098
2129
  }).passthrough().refine(
1099
2130
  (data) => {
1100
2131
  const hasPrivateKey = !!data.privateKey;
@@ -1118,12 +2149,12 @@ var AddComposeHashRequestSchema = z2.object({
1118
2149
  path: ["chain"]
1119
2150
  }
1120
2151
  );
1121
- var AddComposeHashSchema = z2.object({
1122
- composeHash: z2.string(),
1123
- appId: z2.string(),
1124
- transactionHash: z2.string(),
1125
- blockNumber: z2.bigint().optional(),
1126
- gasUsed: z2.bigint().optional()
2152
+ var AddComposeHashSchema = z20.object({
2153
+ composeHash: z20.string(),
2154
+ appId: z20.string(),
2155
+ transactionHash: z20.string(),
2156
+ blockNumber: z20.bigint().optional(),
2157
+ gasUsed: z20.bigint().optional()
1127
2158
  }).passthrough();
1128
2159
  function parseComposeHashResult(receipt, composeHash, appAuthAddress, appId) {
1129
2160
  console.log(receipt.logs);
@@ -1401,7 +2432,8 @@ export {
1401
2432
  checkNetworkStatus,
1402
2433
  commitCvmComposeFileUpdate,
1403
2434
  commitCvmProvision,
1404
- createClient,
2435
+ createClient as createBaseClient,
2436
+ createClient2 as createClient,
1405
2437
  createClientsFromBrowser,
1406
2438
  createClientsFromPrivateKey,
1407
2439
  createNetworkClients,