@layr-labs/ecloud-sdk 0.0.1-dev → 0.0.1-rfc.1

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.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Address, Hex, WalletClient, PublicClient, PrivateKeyAccount } from 'viem';
1
+ import { Address, Hex } from 'viem';
2
2
 
3
3
  /**
4
4
  * Core types for ECloud SDK
@@ -7,35 +7,24 @@ import { Address, Hex, WalletClient, PublicClient, PrivateKeyAccount } from 'vie
7
7
  type AppId = Address;
8
8
  type logVisibility = "public" | "private" | "off";
9
9
  interface DeployAppOpts {
10
- /** App name - required */
11
- name: string;
12
- /** Path to Dockerfile (if building from Dockerfile) - either this or imageRef is required */
10
+ name?: string;
13
11
  dockerfile?: string;
14
- /** Path to .env file - optional */
15
12
  envFile?: string;
16
- /** Image reference (registry/path:tag) - either this or dockerfile is required */
17
13
  imageRef?: string;
18
- /** Instance type SKU - required */
19
- instanceType: string;
20
- /** Log visibility setting - required */
21
- logVisibility: logVisibility;
22
- /** Optional gas params from estimation */
23
- gas?: {
24
- maxFeePerGas?: bigint;
25
- maxPriorityFeePerGas?: bigint;
26
- };
14
+ instanceType?: string;
15
+ logVisibility?: logVisibility;
27
16
  }
28
17
  interface UpgradeAppOpts {
29
- /** Path to Dockerfile (if building from Dockerfile) - either this or imageRef is required */
18
+ /** Path to Dockerfile (if building from Dockerfile) */
30
19
  dockerfile?: string;
31
- /** Image reference (registry/path:tag) - either this or dockerfile is required */
20
+ /** Image reference (registry/path:tag) - optional, will prompt if not provided */
32
21
  imageRef?: string;
33
- /** Path to .env file - optional */
22
+ /** Path to .env file - optional, will use .env if exists or prompt */
34
23
  envFile?: string;
35
- /** Instance type SKU - required */
36
- instanceType: string;
37
- /** Log visibility setting - required */
38
- logVisibility: logVisibility;
24
+ /** Instance type - optional, will prompt if not provided */
25
+ instanceType?: string;
26
+ /** Log visibility setting - optional, will prompt if not provided */
27
+ logVisibility?: logVisibility;
39
28
  gas?: {
40
29
  maxFeePerGas?: bigint;
41
30
  maxPriorityFeePerGas?: bigint;
@@ -46,6 +35,7 @@ interface LifecycleOpts {
46
35
  maxFeePerGas?: bigint;
47
36
  maxPriorityFeePerGas?: bigint;
48
37
  };
38
+ force?: boolean;
49
39
  }
50
40
  interface AppRecord {
51
41
  id: AppId;
@@ -77,7 +67,7 @@ interface DeployOptions {
77
67
  }
78
68
  interface DeployResult {
79
69
  /** App ID (contract address) */
80
- appId: string;
70
+ appID: string;
81
71
  /** App name */
82
72
  appName: string;
83
73
  /** Final image reference */
@@ -219,30 +209,8 @@ interface BillingEnvironmentConfig {
219
209
  * Create command
220
210
  *
221
211
  * Creates a new app project from a template
222
- *
223
- * NOTE: This SDK function is non-interactive. All required parameters must be
224
- * provided explicitly. Use the CLI for interactive parameter collection.
225
212
  */
226
213
 
227
- /**
228
- * Required create app options for SDK (non-interactive)
229
- */
230
- interface SDKCreateAppOpts {
231
- /** Project name - required */
232
- name: string;
233
- /** Programming language - required (typescript, golang, rust, python) */
234
- language: string;
235
- /** Template name/category (e.g., "minimal") or custom template URL - optional, defaults to first available */
236
- template?: string;
237
- /** Template version/ref - optional */
238
- templateVersion?: string;
239
- /** Verbose output - optional */
240
- verbose?: boolean;
241
- }
242
- /**
243
- * Legacy interface for backward compatibility
244
- * @deprecated Use SDKCreateAppOpts instead
245
- */
246
214
  interface CreateAppOpts {
247
215
  name?: string;
248
216
  language?: string;
@@ -250,53 +218,17 @@ interface CreateAppOpts {
250
218
  templateVersion?: string;
251
219
  verbose?: boolean;
252
220
  }
253
- declare const PRIMARY_LANGUAGES: string[];
254
- /**
255
- * Get available template categories for a language
256
- */
257
- declare function getAvailableTemplates(language: string): Promise<Array<{
258
- name: string;
259
- description: string;
260
- }>>;
261
221
  /**
262
222
  * Create a new app project from template
263
- *
264
- * This function is non-interactive and requires all parameters to be provided explicitly.
265
- *
266
- * @param options - Required options including name and language
267
- * @param logger - Optional logger instance
268
- * @throws Error if required parameters are missing or invalid
269
223
  */
270
- declare function createApp(options: SDKCreateAppOpts | CreateAppOpts, logger?: Logger): Promise<void>;
224
+ declare function createApp(options: CreateAppOpts, logger?: Logger): Promise<void>;
271
225
 
272
226
  /**
273
227
  * Logs command
274
228
  *
275
229
  * View app logs with optional watch mode
276
- *
277
- * NOTE: This SDK function is non-interactive. All required parameters must be
278
- * provided explicitly. Use the CLI for interactive parameter collection.
279
230
  */
280
231
 
281
- /**
282
- * Required logs options for SDK (non-interactive)
283
- */
284
- interface SDKLogsOptions {
285
- /** App ID (address) or app name - required */
286
- appID: string | Address;
287
- /** Watch logs continuously - optional */
288
- watch?: boolean;
289
- /** Environment name - optional, defaults to 'sepolia' */
290
- environment?: string;
291
- /** Private key for authenticated requests - optional */
292
- privateKey?: string;
293
- /** RPC URL - optional, uses environment default */
294
- rpcUrl?: string;
295
- }
296
- /**
297
- * Legacy interface for backward compatibility
298
- * @deprecated Use SDKLogsOptions instead
299
- */
300
232
  interface LogsOptions {
301
233
  appID?: string | Address;
302
234
  watch?: boolean;
@@ -306,43 +238,25 @@ interface LogsOptions {
306
238
  }
307
239
  /**
308
240
  * View app logs
309
- *
310
- * This function is non-interactive and requires appID to be provided explicitly.
311
- *
312
- * @param options - Required options including appID
313
- * @param logger - Optional logger instance
314
- * @throws Error if appID is missing or invalid
315
241
  */
316
- declare function logs(options: SDKLogsOptions | LogsOptions, logger?: Logger): Promise<void>;
242
+ declare function logs(options: LogsOptions, logger?: Logger): Promise<void>;
317
243
 
318
244
  /**
319
245
  * Main App namespace entry point
320
246
  */
321
247
 
322
- /**
323
- * Encode start app call data for gas estimation
324
- */
325
- declare function encodeStartAppData(appId: AppId): `0x${string}`;
326
- /**
327
- * Encode stop app call data for gas estimation
328
- */
329
- declare function encodeStopAppData(appId: AppId): `0x${string}`;
330
- /**
331
- * Encode terminate app call data for gas estimation
332
- */
333
- declare function encodeTerminateAppData(appId: AppId): `0x${string}`;
334
248
  interface AppModule {
335
249
  create: (opts: CreateAppOpts) => Promise<void>;
336
250
  deploy: (opts: DeployAppOpts) => Promise<{
337
- appId: AppId;
251
+ appID: AppId;
338
252
  tx: `0x${string}`;
339
253
  appName: string;
340
254
  imageRef: string;
341
255
  ipAddress?: string;
342
256
  }>;
343
- upgrade: (appId: AppId, opts: UpgradeAppOpts) => Promise<{
257
+ upgrade: (appID: AppId, opts: UpgradeAppOpts) => Promise<{
344
258
  tx: `0x${string}`;
345
- appId: string;
259
+ appID: string;
346
260
  imageRef: string;
347
261
  }>;
348
262
  logs: (opts: LogsOptions) => Promise<void>;
@@ -355,9 +269,6 @@ interface AppModule {
355
269
  terminate: (appId: AppId, opts?: LifecycleOpts) => Promise<{
356
270
  tx: `0x${string}` | false;
357
271
  }>;
358
- undelegate: () => Promise<{
359
- tx: `0x${string}` | false;
360
- }>;
361
272
  }
362
273
  interface AppModuleConfig {
363
274
  verbose?: boolean;
@@ -383,469 +294,85 @@ interface BillingModuleConfig {
383
294
  declare function createBillingModule(config: BillingModuleConfig): BillingModule;
384
295
 
385
296
  /**
386
- * Non-interactive validation utilities for SDK
387
- *
388
- * These functions validate parameters without any interactive prompts.
389
- * They either return the validated value or throw an error.
297
+ * Interactive prompts using @inquirer/prompts
390
298
  */
391
299
 
392
300
  /**
393
- * Validate app name format
394
- * @throws Error if name is invalid
301
+ * Prompt for Dockerfile selection
395
302
  */
396
- declare function validateAppName(name: string): void;
303
+ declare function getDockerfileInteractive(dockerfilePath?: string): Promise<string>;
397
304
  /**
398
- * Validate Docker image reference format
399
- * @returns true if valid, error message string if invalid
305
+ * Prompt for image reference
400
306
  */
401
- declare function validateImageReference(value: string): true | string;
307
+ declare function getImageReferenceInteractive(imageRef?: string, buildFromDockerfile?: boolean): Promise<string>;
402
308
  /**
403
- * Validate image reference and throw if invalid
404
- * @throws Error if image reference is invalid
309
+ * Prompt for app name
405
310
  */
406
- declare function assertValidImageReference(value: string): void;
311
+ declare function getOrPromptAppName(appName: string | undefined, environment: string, imageRef: string): Promise<string>;
407
312
  /**
408
- * Extract app name from image reference
313
+ * Prompt for environment file
409
314
  */
410
- declare function extractAppNameFromImage(imageRef: string): string;
411
- /**
412
- * Validate that a file path exists
413
- * @returns true if valid, error message string if invalid
414
- */
415
- declare function validateFilePath(value: string): true | string;
416
- /**
417
- * Validate file path and throw if invalid
418
- * @throws Error if file path is invalid or doesn't exist
419
- */
420
- declare function assertValidFilePath(value: string): void;
315
+ declare function getEnvFileInteractive(envFilePath?: string): Promise<string>;
421
316
  /**
422
- * Validate instance type SKU against available types
423
- * @returns the validated SKU
424
- * @throws Error if SKU is not in the available types list
317
+ * Prompt for instance type
425
318
  */
426
- declare function validateInstanceTypeSKU(sku: string, availableTypes: Array<{
319
+ declare function getInstanceTypeInteractive(instanceType: string | undefined, defaultSKU: string, availableTypes: Array<{
427
320
  sku: string;
428
- }>): string;
429
- /**
430
- * Validate private key format
431
- * Matches Go's common.ValidatePrivateKey() function
432
- */
433
- declare function validatePrivateKeyFormat(key: string): boolean;
434
- /**
435
- * Validate private key and throw if invalid
436
- * @throws Error if private key format is invalid
437
- */
438
- declare function assertValidPrivateKey(key: string): void;
439
- /**
440
- * Validate URL format
441
- * @returns undefined if valid, error message string if invalid
442
- */
443
- declare function validateURL(rawURL: string): string | undefined;
444
- /**
445
- * Validate X/Twitter URL format
446
- * @returns undefined if valid, error message string if invalid
447
- */
448
- declare function validateXURL(rawURL: string): string | undefined;
449
- /**
450
- * Validate description length
451
- * @returns undefined if valid, error message string if invalid
452
- */
453
- declare function validateDescription(description: string): string | undefined;
321
+ description: string;
322
+ }>): Promise<string>;
454
323
  /**
455
- * Validate image file path
456
- * @returns undefined if valid, error message string if invalid
324
+ * Prompt for app ID (supports app name or address)
457
325
  */
458
- declare function validateImagePath(filePath: string): string | undefined;
326
+ interface GetAppIDOptions {
327
+ appID?: string | Address;
328
+ environment: string;
329
+ privateKey?: string;
330
+ rpcUrl?: string;
331
+ action?: string;
332
+ }
459
333
  /**
460
- * Validate and normalize app ID address
461
- * @param appID - App ID (must be a valid address)
462
- * @returns Normalized app address
463
- * @throws Error if app ID is not a valid address
464
- *
465
- * Note: Name resolution should be handled by CLI before calling SDK functions.
466
- * The SDK only accepts resolved addresses.
334
+ * Prompt for app ID (supports app name or address)
467
335
  */
468
- declare function validateAppID(appID: string | Address): Address;
469
- type LogVisibility = "public" | "private" | "off";
336
+ declare function getOrPromptAppID(appIDOrOptions: string | Address | GetAppIDOptions | undefined, environment?: string): Promise<Address>;
470
337
  /**
471
- * Validate and convert log visibility setting to internal format
472
- * @param logVisibility - Log visibility setting
473
- * @returns Object with logRedirect and publicLogs settings
474
- * @throws Error if log visibility value is invalid
338
+ * Prompt for log settings
475
339
  */
476
- declare function validateLogVisibility(logVisibility: LogVisibility): {
340
+ declare function getLogSettingsInteractive(logVisibility?: "public" | "private" | "off"): Promise<{
477
341
  logRedirect: string;
478
342
  publicLogs: boolean;
479
- };
480
- type ResourceUsageMonitoring = "enable" | "disable";
481
- /**
482
- * Validate and convert resource usage monitoring setting to internal format
483
- * @param resourceUsageMonitoring - Resource usage monitoring setting
484
- * @returns The resourceUsageAllow value for the Dockerfile label ("always" or "never")
485
- * @throws Error if resource usage monitoring value is invalid
486
- */
487
- declare function validateResourceUsageMonitoring(resourceUsageMonitoring: ResourceUsageMonitoring | undefined): string;
488
- /**
489
- * Sanitize string (HTML escape and trim)
490
- */
491
- declare function sanitizeString(s: string): string;
492
- /**
493
- * Sanitize URL (add https:// if missing, validate)
494
- * @throws Error if URL is invalid after sanitization
495
- */
496
- declare function sanitizeURL(rawURL: string): string;
497
- /**
498
- * Sanitize X/Twitter URL (handle username-only input, normalize)
499
- * @throws Error if URL is invalid after sanitization
500
- */
501
- declare function sanitizeXURL(rawURL: string): string;
502
- interface DeployParams {
503
- dockerfilePath?: string;
504
- imageRef?: string;
505
- appName: string;
506
- envFilePath?: string;
507
- instanceType: string;
508
- logVisibility: LogVisibility;
509
- }
510
- /**
511
- * Validate deploy parameters
512
- * @throws Error if required parameters are missing or invalid
513
- */
514
- declare function validateDeployParams(params: Partial<DeployParams>): void;
515
- interface UpgradeParams {
516
- appID: string | Address;
517
- dockerfilePath?: string;
518
- imageRef?: string;
519
- envFilePath?: string;
520
- instanceType: string;
521
- logVisibility: LogVisibility;
522
- }
523
- /**
524
- * Validate upgrade parameters
525
- * @throws Error if required parameters are missing or invalid
526
- */
527
- declare function validateUpgradeParams(params: Partial<UpgradeParams>): void;
528
- interface CreateAppParams {
529
- name: string;
530
- language: string;
531
- template?: string;
532
- templateVersion?: string;
533
- }
534
- /**
535
- * Validate create app parameters
536
- * @throws Error if required parameters are missing or invalid
537
- */
538
- declare function validateCreateAppParams(params: Partial<CreateAppParams>): void;
539
- interface LogsParams {
540
- appID: string | Address;
541
- watch?: boolean;
542
- }
543
- /**
544
- * Validate logs parameters
545
- * @throws Error if required parameters are missing or invalid
546
- */
547
- declare function validateLogsParams(params: Partial<LogsParams>): void;
548
-
549
- /**
550
- * Contract interactions
551
- *
552
- * This module handles on-chain contract interactions using viem
553
- */
554
-
555
- /**
556
- * Gas estimation result
557
- */
558
- interface GasEstimate {
559
- /** Estimated gas limit for the transaction */
560
- gasLimit: bigint;
561
- /** Max fee per gas (EIP-1559) */
562
- maxFeePerGas: bigint;
563
- /** Max priority fee per gas (EIP-1559) */
564
- maxPriorityFeePerGas: bigint;
565
- /** Maximum cost in wei (gasLimit * maxFeePerGas) */
566
- maxCostWei: bigint;
567
- /** Maximum cost formatted as ETH string */
568
- maxCostEth: string;
569
- }
570
- /**
571
- * Options for estimating transaction gas
572
- */
573
- interface EstimateGasOptions {
574
- privateKey: string;
575
- rpcUrl: string;
576
- environmentConfig: EnvironmentConfig;
577
- to: Address;
578
- data: Hex;
579
- value?: bigint;
580
- }
581
- /**
582
- * Format Wei to ETH string
583
- */
584
- declare function formatETH(wei: bigint): string;
585
- /**
586
- * Estimate gas cost for a transaction
587
- *
588
- * Use this to get cost estimate before prompting user for confirmation.
589
- */
590
- declare function estimateTransactionGas(options: EstimateGasOptions): Promise<GasEstimate>;
591
- /**
592
- * Prepared deploy batch ready for gas estimation and execution
593
- */
594
- interface PreparedDeployBatch {
595
- /** The app ID that will be deployed */
596
- appId: Address;
597
- /** The salt used for deployment */
598
- salt: Uint8Array;
599
- /** Batch executions to be sent */
600
- executions: Array<{
601
- target: Address;
602
- value: bigint;
603
- callData: Hex;
604
- }>;
605
- /** Wallet client for sending transaction */
606
- walletClient: WalletClient;
607
- /** Public client for reading chain state */
608
- publicClient: PublicClient;
609
- /** Environment configuration */
610
- environmentConfig: EnvironmentConfig;
611
- }
612
- /**
613
- * Prepared upgrade batch ready for gas estimation and execution
614
- */
615
- interface PreparedUpgradeBatch {
616
- /** The app ID being upgraded */
617
- appId: Address;
618
- /** Batch executions to be sent */
619
- executions: Array<{
620
- target: Address;
621
- value: bigint;
622
- callData: Hex;
623
- }>;
624
- /** Wallet client for sending transaction */
625
- walletClient: WalletClient;
626
- /** Public client for reading chain state */
627
- publicClient: PublicClient;
628
- /** Environment configuration */
629
- environmentConfig: EnvironmentConfig;
630
- }
631
- /**
632
- * Get apps by creator (paginated)
633
- */
634
- interface AppConfig {
635
- release: any;
636
- status: number;
637
- }
638
- /**
639
- * Fetch all apps by a developer by auto-pagination
640
- */
641
- declare function getAllAppsByDeveloper(rpcUrl: string, env: EnvironmentConfig, developer: Address, pageSize?: bigint): Promise<{
642
- apps: Address[];
643
- appConfigs: AppConfig[];
644
343
  }>;
344
+ declare function extractAppNameFromImage(imageRef: string): string;
645
345
  /**
646
- * Get latest release block numbers for multiple apps
647
- */
648
- declare function getAppLatestReleaseBlockNumbers(rpcUrl: string, environmentConfig: EnvironmentConfig, appIDs: Address[]): Promise<Map<Address, number>>;
649
- /**
650
- * Get block timestamps for multiple block numbers
651
- */
652
- declare function getBlockTimestamps(rpcUrl: string, environmentConfig: EnvironmentConfig, blockNumbers: number[]): Promise<Map<number, number>>;
653
-
654
- /**
655
- * Main deploy function
656
- *
657
- * This is the main entry point for deploying applications to ecloud TEE.
658
- * It orchestrates all the steps: build, push, encrypt, and deploy on-chain.
659
- *
660
- * NOTE: This SDK function is non-interactive. All required parameters must be
661
- * provided explicitly. Use the CLI for interactive parameter collection.
662
- */
663
-
664
- /**
665
- * Required deploy options for SDK (non-interactive)
666
- */
667
- interface SDKDeployOptions {
668
- /** Private key for signing transactions (hex string with or without 0x prefix) */
669
- privateKey: string;
670
- /** RPC URL for blockchain connection - optional, uses environment default if not provided */
671
- rpcUrl?: string;
672
- /** Environment name (e.g., 'sepolia', 'mainnet-alpha') - defaults to 'sepolia' */
673
- environment?: string;
674
- /** Path to Dockerfile (if building from Dockerfile) - either this or imageRef is required */
675
- dockerfilePath?: string;
676
- /** Image reference (registry/path:tag) - either this or dockerfilePath is required */
677
- imageRef?: string;
678
- /** Path to .env file - optional */
679
- envFilePath?: string;
680
- /** App name - required */
681
- appName: string;
682
- /** Instance type SKU - required */
683
- instanceType: string;
684
- /** Log visibility setting - required */
685
- logVisibility: LogVisibility;
686
- /** Resource usage monitoring setting - optional, defaults to 'enable' */
687
- resourceUsageMonitoring?: ResourceUsageMonitoring;
688
- /** Optional gas params from estimation */
689
- gas?: {
690
- maxFeePerGas?: bigint;
691
- maxPriorityFeePerGas?: bigint;
692
- };
693
- }
694
- /**
695
- * Prepared deployment ready for gas estimation and execution
346
+ * Confirm prompts the user to confirm an action with a yes/no question.
696
347
  */
697
- interface PreparedDeploy {
698
- /** The prepared batch (executions, clients, etc.) */
699
- batch: PreparedDeployBatch;
700
- /** App name */
701
- appName: string;
702
- /** Final image reference */
703
- imageRef: string;
704
- /** Preflight context for post-deploy operations */
705
- preflightCtx: {
706
- privateKey: string;
707
- rpcUrl: string;
708
- environmentConfig: EnvironmentConfig;
709
- };
710
- }
348
+ declare function confirm(prompt: string): Promise<boolean>;
711
349
  /**
712
- * Result from prepareDeploy - includes prepared batch and gas estimate
350
+ * ConfirmWithDefault prompts the user to confirm an action with a yes/no question and a default value.
713
351
  */
714
- interface PrepareDeployResult {
715
- /** Prepared deployment state */
716
- prepared: PreparedDeploy;
717
- /** Gas estimate for the batch transaction */
718
- gasEstimate: GasEstimate;
719
- }
352
+ declare function confirmWithDefault(prompt: string, defaultValue?: boolean): Promise<boolean>;
720
353
  /**
721
- * Prepare deployment - does all work up to the transaction
722
- *
723
- * This allows CLI to:
724
- * 1. Call prepareDeploy to build image, prepare release, get gas estimate
725
- * 2. Prompt user to confirm the cost
726
- * 3. Call executeDeploy with confirmed gas params
354
+ * Prompt for RPC URL
355
+ * Matches Go's getRPCURL() behavior with interactive prompt
727
356
  */
728
- declare function prepareDeploy(options: Omit<SDKDeployOptions, "gas">, logger?: Logger): Promise<PrepareDeployResult>;
357
+ declare function getRPCUrlInteractive(rpcUrl?: string, defaultRpcUrl?: string): Promise<string>;
729
358
  /**
730
- * Execute a prepared deployment
731
- *
732
- * Call this after prepareDeploy and user confirmation.
733
- * Note: This only submits the on-chain transaction. Call watchDeployment separately
734
- * to wait for the app to be running.
359
+ * Prompt for environment selection
360
+ * Matches Go's GetEnvironmentConfig() behavior with interactive prompt
735
361
  */
736
- declare function executeDeploy(prepared: PreparedDeploy, gas: {
737
- maxFeePerGas?: bigint;
738
- maxPriorityFeePerGas?: bigint;
739
- } | undefined, logger?: Logger): Promise<DeployResult>;
362
+ declare function getEnvironmentInteractive(environment?: string): Promise<string>;
740
363
  /**
741
- * Watch a deployment until the app is running
742
- *
743
- * Call this after executeDeploy to wait for the app to be provisioned.
744
- * Can be called separately to allow for intermediate operations (e.g., profile upload).
364
+ * Prompt for private key with hidden input
365
+ * Matches Go's output.InputHiddenString() function
745
366
  */
746
- declare function watchDeployment(appId: string, privateKey: string, rpcUrl: string, environment: string, logger?: Logger): Promise<string | undefined>;
367
+ declare function getPrivateKeyInteractive(privateKey?: string): Promise<string>;
747
368
 
748
369
  /**
749
- * Main upgrade function
750
- *
751
- * This is the main entry point for upgrading existing applications on ecloud TEE.
752
- * It orchestrates all the steps: build, push, encrypt, and upgrade on-chain.
753
- *
754
- * NOTE: This SDK function is non-interactive. All required parameters must be
755
- * provided explicitly. Use the CLI for interactive parameter collection.
370
+ * Collect app profile information interactively
371
+ * If defaultName is provided, it will be used as the suggested name
372
+ * If allowRetry is true, user can re-enter information on rejection (deploy flow)
373
+ * If allowRetry is false, rejection returns an error (profile set flow)
756
374
  */
757
-
758
- /**
759
- * Required upgrade options for SDK (non-interactive)
760
- */
761
- interface SDKUpgradeOptions {
762
- /** App ID to upgrade - required */
763
- appId: string | Address;
764
- /** Private key for signing transactions (hex string with or without 0x prefix) */
765
- privateKey: string;
766
- /** RPC URL for blockchain connection - optional, uses environment default if not provided */
767
- rpcUrl?: string;
768
- /** Environment name (e.g., 'sepolia', 'mainnet-alpha') - defaults to 'sepolia' */
769
- environment?: string;
770
- /** Path to Dockerfile (if building from Dockerfile) - either this or imageRef is required */
771
- dockerfilePath?: string;
772
- /** Image reference (registry/path:tag) - either this or dockerfilePath is required */
773
- imageRef?: string;
774
- /** Path to .env file - optional */
775
- envFilePath?: string;
776
- /** Instance type SKU - required */
777
- instanceType: string;
778
- /** Log visibility setting - required */
779
- logVisibility: LogVisibility;
780
- /** Resource usage monitoring setting - optional, defaults to 'enable' */
781
- resourceUsageMonitoring?: ResourceUsageMonitoring;
782
- /** Optional gas params from estimation */
783
- gas?: {
784
- maxFeePerGas?: bigint;
785
- maxPriorityFeePerGas?: bigint;
786
- };
787
- }
788
- interface UpgradeResult {
789
- /** App ID (contract address) */
790
- appId: string;
791
- /** Final image reference */
792
- imageRef: string;
793
- /** Transaction hash */
794
- txHash: `0x${string}`;
795
- }
796
- /**
797
- * Prepared upgrade ready for gas estimation and execution
798
- */
799
- interface PreparedUpgrade {
800
- /** The prepared batch (executions, clients, etc.) */
801
- batch: PreparedUpgradeBatch;
802
- /** App ID being upgraded */
803
- appId: string;
804
- /** Final image reference */
805
- imageRef: string;
806
- /** Preflight context for post-upgrade operations */
807
- preflightCtx: {
808
- privateKey: string;
809
- rpcUrl: string;
810
- environmentConfig: EnvironmentConfig;
811
- };
812
- }
813
- /**
814
- * Result from prepareUpgrade - includes prepared batch and gas estimate
815
- */
816
- interface PrepareUpgradeResult {
817
- /** Prepared upgrade state */
818
- prepared: PreparedUpgrade;
819
- /** Gas estimate for the batch transaction */
820
- gasEstimate: GasEstimate;
821
- }
822
- /**
823
- * Prepare upgrade - does all work up to the transaction
824
- *
825
- * This allows CLI to:
826
- * 1. Call prepareUpgrade to build image, prepare release, get gas estimate
827
- * 2. Prompt user to confirm the cost
828
- * 3. Call executeUpgrade with confirmed gas params
829
- */
830
- declare function prepareUpgrade(options: Omit<SDKUpgradeOptions, "gas">, logger?: Logger): Promise<PrepareUpgradeResult>;
831
- /**
832
- * Execute a prepared upgrade
833
- *
834
- * Call this after prepareUpgrade and user confirmation.
835
- * Note: This only submits the on-chain transaction. Call watchUpgrade separately
836
- * to wait for the upgrade to complete.
837
- */
838
- declare function executeUpgrade(prepared: PreparedUpgrade, gas: {
839
- maxFeePerGas?: bigint;
840
- maxPriorityFeePerGas?: bigint;
841
- } | undefined, logger?: Logger): Promise<UpgradeResult>;
842
- /**
843
- * Watch an upgrade until it completes
844
- *
845
- * Call this after executeUpgrade to wait for the upgrade to finish.
846
- * Can be called separately to allow for intermediate operations.
847
- */
848
- declare function watchUpgrade(appId: string, privateKey: string, rpcUrl: string, environment: string, logger?: Logger): Promise<void>;
375
+ declare function getAppProfileInteractive(defaultName?: string, allowRetry?: boolean): Promise<AppProfile | null>;
849
376
 
850
377
  /**
851
378
  * Environment configuration for different networks
@@ -855,7 +382,6 @@ declare function watchUpgrade(appId: string, privateKey: string, rpcUrl: string,
855
382
  * Get environment configuration
856
383
  */
857
384
  declare function getEnvironmentConfig(environment: string, chainID?: bigint): EnvironmentConfig;
858
- declare function getBuildType(): "dev" | "prod";
859
385
  /**
860
386
  * Get available environments based on build type
861
387
  * - dev: only "sepolia-dev"
@@ -866,10 +392,6 @@ declare function getAvailableEnvironments(): string[];
866
392
  * Check if an environment is available in the current build
867
393
  */
868
394
  declare function isEnvironmentAvailable(environment: string): boolean;
869
- /**
870
- * Check if environment is mainnet (chain ID 1)
871
- */
872
- declare function isMainnet(environmentConfig: EnvironmentConfig): boolean;
873
395
 
874
396
  /**
875
397
  * Billing utility functions
@@ -911,7 +433,7 @@ declare function storePrivateKey(privateKey: string): Promise<void>;
911
433
  * Note: Returns the single stored key for all environments.
912
434
  * The environment parameter is kept for API compatibility but is ignored.
913
435
  */
914
- declare function getPrivateKey(): Promise<`0x${string}` | null>;
436
+ declare function getPrivateKey(): Promise<string | null>;
915
437
  /**
916
438
  * Delete a private key from OS keyring
917
439
  * Returns true if deletion was successful, false otherwise
@@ -964,7 +486,7 @@ declare function getAddressFromPrivateKey(privateKey: string): string;
964
486
  * 3. OS keyring (stored via `ecloud auth login`)
965
487
  */
966
488
  interface PrivateKeySource {
967
- key: `0x${string}`;
489
+ key: string;
968
490
  source: string;
969
491
  }
970
492
  /**
@@ -988,175 +510,41 @@ declare function requirePrivateKey(options: {
988
510
  }): Promise<PrivateKeySource>;
989
511
 
990
512
  /**
991
- * Private Key Generation
513
+ * Security Utilities
992
514
  *
993
- * Generate new secp256k1 private keys for Ethereum
994
- */
995
- interface GeneratedKey {
996
- privateKey: string;
997
- address: string;
998
- }
999
- /**
1000
- * Generate a new secp256k1 private key
515
+ * Provides secure display and input handling for sensitive data like private keys
1001
516
  */
1002
- declare function generateNewPrivateKey(): GeneratedKey;
1003
-
1004
517
  /**
1005
- * TemplateEntry represents a single template in the catalog
518
+ * Display sensitive content using system pager (less/more)
519
+ * Returns true if content was displayed, false if user aborted
1006
520
  */
1007
- interface TemplateEntry {
1008
- path: string;
1009
- description: string;
1010
- postProcess?: {
1011
- replaceNameIn?: string[];
1012
- };
1013
- }
521
+ declare function showPrivateKey(content: string): Promise<boolean>;
1014
522
  /**
1015
- * TemplateCatalog represents the structure of templates.json
1016
- * Organized by language first, then by category (e.g., "typescript" -> "minimal")
523
+ * Clear terminal screen
1017
524
  */
1018
- interface TemplateCatalog {
1019
- [language: string]: {
1020
- [category: string]: TemplateEntry;
1021
- };
1022
- }
525
+ declare function clearTerminal(): void;
1023
526
  /**
1024
- * Fetch template catalog from remote URL or local file
1025
- * Uses a 15-minute in-memory cache to avoid excessive network requests
527
+ * Get hidden input (password-style)
1026
528
  */
1027
- declare function fetchTemplateCatalog(): Promise<TemplateCatalog>;
529
+ declare function getHiddenInput(message: string): Promise<string>;
1028
530
  /**
1029
- * Get template entry by language and category
1030
- */
1031
- declare function getTemplate(catalog: TemplateCatalog, category: string, language: string): TemplateEntry;
1032
- /**
1033
- * Get category descriptions for a given language
1034
- */
1035
- declare function getCategoryDescriptions(catalog: TemplateCatalog, language: string): Record<string, string>;
1036
-
1037
- /**
1038
- * EIP-7702 transaction handling
1039
- *
1040
- * This module handles EIP-7702 delegation and batch execution
531
+ * Display multi-line warning for destructive operations
1041
532
  */
533
+ declare function displayWarning(lines: string[]): void;
1042
534
 
1043
535
  /**
1044
- * Options for estimating batch gas
1045
- */
1046
- interface EstimateBatchGasOptions {
1047
- publicClient: PublicClient;
1048
- environmentConfig: EnvironmentConfig;
1049
- executions: Array<{
1050
- target: Address;
1051
- value: bigint;
1052
- callData: Hex;
1053
- }>;
1054
- }
1055
- /**
1056
- * Estimate gas cost for a batch transaction
536
+ * Private Key Generation
1057
537
  *
1058
- * Use this to get cost estimate before prompting user for confirmation.
1059
- * Note: This provides a conservative estimate since batch transactions
1060
- * through EIP-7702 can have variable costs.
1061
- */
1062
- declare function estimateBatchGas(options: EstimateBatchGasOptions): Promise<GasEstimate>;
1063
-
1064
- /**
1065
- * Preflight checks
538
+ * Generate new secp256k1 private keys for Ethereum
1066
539
  */
1067
-
1068
- interface PreflightContext {
540
+ interface GeneratedKey {
1069
541
  privateKey: string;
1070
- rpcUrl: string;
1071
- environmentConfig: EnvironmentConfig;
1072
- account: PrivateKeyAccount;
1073
- selfAddress: Address;
542
+ address: string;
1074
543
  }
1075
-
1076
- /**
1077
- * Instance type utilities
1078
- */
1079
-
1080
- /**
1081
- * Get current instance type for an app (best-effort)
1082
- * Returns empty string if unable to fetch (API unavailable, app info not ready, etc.).
1083
- * This is used as a convenience default for the upgrade flow.
1084
- */
1085
- declare function getCurrentInstanceType(preflightCtx: PreflightContext, appID: Address, logger: Logger): Promise<string>;
1086
-
1087
544
  /**
1088
- * UserAPI Client to manage interactions with the coordinator
545
+ * Generate a new secp256k1 private key
1089
546
  */
1090
-
1091
- interface AppProfileInfo {
1092
- name: string;
1093
- website?: string;
1094
- description?: string;
1095
- xURL?: string;
1096
- imageURL?: string;
1097
- }
1098
- interface AppMetrics {
1099
- cpu_utilization_percent?: number;
1100
- memory_utilization_percent?: number;
1101
- memory_used_bytes?: number;
1102
- memory_total_bytes?: number;
1103
- }
1104
- interface DerivedAddress {
1105
- address: string;
1106
- derivationPath: string;
1107
- }
1108
- interface AppInfo {
1109
- address: Address;
1110
- status: string;
1111
- ip: string;
1112
- machineType: string;
1113
- profile?: AppProfileInfo;
1114
- metrics?: AppMetrics;
1115
- evmAddresses: DerivedAddress[];
1116
- solanaAddresses: DerivedAddress[];
1117
- }
1118
- declare class UserApiClient {
1119
- private readonly config;
1120
- private readonly account?;
1121
- private readonly rpcUrl?;
1122
- constructor(config: EnvironmentConfig, privateKey?: string | Hex, rpcUrl?: string);
1123
- getInfos(appIDs: Address[], addressCount?: number): Promise<AppInfo[]>;
1124
- /**
1125
- * Get available SKUs (instance types) from UserAPI
1126
- */
1127
- getSKUs(): Promise<{
1128
- skus: Array<{
1129
- sku: string;
1130
- description: string;
1131
- }>;
1132
- }>;
1133
- /**
1134
- * Get logs for an app
1135
- */
1136
- getLogs(appID: Address): Promise<string>;
1137
- /**
1138
- * Get statuses for apps
1139
- */
1140
- getStatuses(appIDs: Address[]): Promise<Array<{
1141
- address: Address;
1142
- status: string;
1143
- }>>;
1144
- /**
1145
- * Upload app profile information with optional image
1146
- */
1147
- uploadAppProfile(appAddress: Address, name: string, website?: string, description?: string, xURL?: string, imagePath?: string): Promise<{
1148
- name: string;
1149
- website?: string;
1150
- description?: string;
1151
- xURL?: string;
1152
- imageURL?: string;
1153
- }>;
1154
- private makeAuthenticatedRequest;
1155
- /**
1156
- * Generate authentication headers for UserAPI requests
1157
- */
1158
- private generateAuthHeaders;
1159
- }
547
+ declare function generateNewPrivateKey(): GeneratedKey;
1160
548
 
1161
549
  /**
1162
550
  * Main SDK Client entry point
@@ -1175,4 +563,4 @@ interface ECloudClient {
1175
563
  }
1176
564
  declare function createECloudClient(cfg: ClientConfig): ECloudClient;
1177
565
 
1178
- export { type AlreadyActiveResponse, type AppId, type AppInfo, type AppMetrics, type AppModuleConfig, type AppProfile, type AppProfileInfo, type AppProfileResponse, type AppRecord, type BillingEnvironmentConfig, type BillingModuleConfig, type CancelResponse, type CancelSuccessResponse, type ChainID, type CheckoutCreatedResponse, type ClientConfig, type CreateAppOpts, type CreateAppParams, type CreateSubscriptionResponse, type DeployAppOpts, type DeployOptions, type DeployParams, type DeployResult, type DockerImageConfig, type ECloudClient, type Environment, type EnvironmentConfig, type EstimateBatchGasOptions, type EstimateGasOptions, type GasEstimate, type GeneratedKey, type ImageDigestResult, type LegacyKey, type LifecycleOpts, type LogVisibility, type Logger, type LogsOptions, type LogsParams, type NoActiveSubscriptionResponse, PRIMARY_LANGUAGES, type ParsedEnvironment, type PaymentIssueResponse, type PrepareDeployResult, type PrepareUpgradeResult, type PreparedDeploy, type PreparedUpgrade, type PrivateKeySource, type ProductID, type ProductSubscriptionResponse, type Release, type ResourceUsageMonitoring, type SDKCreateAppOpts, type SDKDeployOptions, type SDKLogsOptions, type SDKUpgradeOptions, type StoredKey, type SubscribeResponse, type SubscriptionLineItem, type SubscriptionOpts, type SubscriptionStatus, type UpgradeAppOpts, type UpgradeParams, UserApiClient, assertValidFilePath, assertValidImageReference, assertValidPrivateKey, createApp, createAppModule, createBillingModule, createECloudClient, deleteLegacyPrivateKey, deletePrivateKey, encodeStartAppData, encodeStopAppData, encodeTerminateAppData, estimateBatchGas, estimateTransactionGas, executeDeploy, executeUpgrade, extractAppNameFromImage, fetchTemplateCatalog, formatETH, generateNewPrivateKey, getAddressFromPrivateKey, getAllAppsByDeveloper, getAppLatestReleaseBlockNumbers, getAvailableEnvironments, getAvailableTemplates, getBlockTimestamps, getBuildType, getCategoryDescriptions, getCurrentInstanceType, getEnvironmentConfig, getLegacyKeys, getLegacyPrivateKey, getPrivateKey, getPrivateKeyWithSource, getTemplate, isEnvironmentAvailable, isMainnet, isSubscriptionActive, keyExists, listStoredKeys, type logVisibility, logs, prepareDeploy, prepareUpgrade, requirePrivateKey, sanitizeString, sanitizeURL, sanitizeXURL, storePrivateKey, validateAppID, validateAppName, validateCreateAppParams, validateDeployParams, validateDescription, validateFilePath, validateImagePath, validateImageReference, validateInstanceTypeSKU, validateLogVisibility, validateLogsParams, validatePrivateKey, validatePrivateKeyFormat, validateResourceUsageMonitoring, validateURL, validateUpgradeParams, validateXURL, watchDeployment, watchUpgrade };
566
+ export { type AlreadyActiveResponse, type AppId, type AppModuleConfig, type AppProfile, type AppProfileResponse, type AppRecord, type BillingEnvironmentConfig, type BillingModuleConfig, type CancelResponse, type CancelSuccessResponse, type ChainID, type CheckoutCreatedResponse, type ClientConfig, type CreateAppOpts, type CreateSubscriptionResponse, type DeployAppOpts, type DeployOptions, type DeployResult, type DockerImageConfig, type ECloudClient, type Environment, type EnvironmentConfig, type GeneratedKey, type GetAppIDOptions, type ImageDigestResult, type LegacyKey, type LifecycleOpts, type Logger, type LogsOptions, type NoActiveSubscriptionResponse, type ParsedEnvironment, type PaymentIssueResponse, type PrivateKeySource, type ProductID, type ProductSubscriptionResponse, type Release, type StoredKey, type SubscribeResponse, type SubscriptionLineItem, type SubscriptionOpts, type SubscriptionStatus, type UpgradeAppOpts, clearTerminal, confirm, confirmWithDefault, createApp, createAppModule, createBillingModule, createECloudClient, deleteLegacyPrivateKey, deletePrivateKey, displayWarning, extractAppNameFromImage, generateNewPrivateKey, getAddressFromPrivateKey, getAppProfileInteractive, getAvailableEnvironments, getDockerfileInteractive, getEnvFileInteractive, getEnvironmentConfig, getEnvironmentInteractive, getHiddenInput, getImageReferenceInteractive, getInstanceTypeInteractive, getLegacyKeys, getLegacyPrivateKey, getLogSettingsInteractive, getOrPromptAppID, getOrPromptAppName, getPrivateKey, getPrivateKeyInteractive, getPrivateKeyWithSource, getRPCUrlInteractive, isEnvironmentAvailable, isSubscriptionActive, keyExists, listStoredKeys, type logVisibility, logs, requirePrivateKey, showPrivateKey, storePrivateKey, validatePrivateKey };