phala 0.0.1-alpha

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/banner.ts","../src/commands/auth/index.ts","../src/commands/auth/login.ts","../src/utils/credentials.ts","../src/api/client.ts","../src/utils/constants.ts","../src/api/types.ts","../src/utils/types.ts","../src/api/auth.ts","../src/commands/auth/logout.ts","../src/commands/auth/status.ts","../src/commands/teepods/index.ts","../src/commands/teepods/list.ts","../src/api/teepods.ts","../src/commands/teepods/images.ts","../src/commands/docker/index.ts","../src/commands/docker/login.ts","../src/utils/docker.ts","../src/utils/prompts.ts","../src/commands/docker/build.ts","../src/commands/docker/push.ts","../src/commands/docker/tags.ts","../src/commands/docker/run.ts","../src/commands/docker/generate.ts","../src/commands/simulator/index.ts","../src/commands/simulator/start.ts","../src/commands/simulator/stop.ts","../src/commands/config/index.ts","../src/commands/config/get.ts","../src/utils/config.ts","../src/commands/config/set.ts","../src/commands/config/list.ts","../src/commands/cvms/index.ts","../src/commands/cvms/list.ts","../src/api/cvms.ts","../src/commands/cvms/get.ts","../src/commands/cvms/start.ts","../src/commands/cvms/stop.ts","../src/commands/cvms/restart.ts","../src/commands/cvms/attestation.ts","../src/commands/cvms/create.ts","../src/utils/secrets.ts","../src/commands/cvms/delete.ts","../src/commands/cvms/upgrade.ts","../src/commands/cvms/resize.ts"],"sourcesContent":["#!/usr/bin/env bun\nimport { Command } from \"commander\"\nimport { logo } from \"./utils/banner\"\nimport { authCommands } from \"./commands/auth\"\nimport { teepodsCommands } from \"./commands/teepods\"\nimport { dockerCommands } from \"./commands/docker\"\nimport { simulatorCommands } from \"./commands/simulator\"\nimport { configCommands } from \"./commands/config\"\nimport { logger } from \"./utils/logger\"\nimport { cvmsCommand } from './commands/cvms'\n\nprocess.on(\"SIGINT\", () => process.exit(0))\nprocess.on(\"SIGTERM\", () => process.exit(0))\n\nasync function main() {\n const program = new Command()\n .name(\"phala\")\n .description(`${logo}\\nPhala Cloud CLI - Manage your Phala Cloud Deployments`)\n .version(\"0.0.1\")\n .addCommand(authCommands)\n .addCommand(teepodsCommands)\n .addCommand(dockerCommands)\n .addCommand(simulatorCommands)\n .addCommand(configCommands)\n .addCommand(cvmsCommand)\n\n program.parse(process.argv)\n}\n\nmain().catch((error) => {\n logger.error(\"An error occurred:\", error)\n process.exit(1)\n})","import chalk from 'chalk';\nconst logoColor = chalk.hex('#cdfa50');\nexport const logo = logoColor(`\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣤⣤⣤⣀⡀⠀⢀⣀⣤⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⡿⠛⠉⠁⠀⠈⠉⠛⠿⠛⠉⠉⠉⠉⠙⠷⣄⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣧⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣆⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⠞⠛⠉⠙⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠛⢶⣄⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣦⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣷⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⣿⣿⡿⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⣀⣴⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠻⠿⠿⠿⠿⠃⠀⢀⣾⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠛⠋⠁⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⡿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⡤⠤⠤⠴⠒⠒⠒⠒⠒⢿⡿⠓⠒⠒⠢⠤⠤⠤⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣯⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⣀⣨⣿⣦⣤⣀⡀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣿⣿⣿⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣾⣿⣿⣿⣿⣿⡏⠉⠛⣿⣆⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⣀⣀⣀⣀⡸⠿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⣸⡿⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⠀⢸⣿⣿⣿⣿⡇⠀⣿⣿⣿⣿⣿⣿⠃⢀⣠⣴⡿⠃⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⣿⣿⠿⢇⣀⣀⣀⣀⣸⣿⣿⣿⣿⣿⡿⠿⠿⠛⠛⠁⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⡠⠀⠀⠀⠀⠈⠻⢿⣿⣿⣿⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠠⣄⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⢸⣆⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⠿⣿⣿⣿⣿⣿⠿⠟⠋⠁⠀⠀⠀⠀⠀⠀⣀⣾⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠙⠻⢶⣦⣤⣄⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣤⣴⣶⠿⠛⠁⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠙⠛⠻⠿⠿⠿⠿⢿⣿⣿⣿⠿⠿⠿⠿⠟⠛⠛⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n`);\n\nexport const smallLogo = logoColor(`\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⣤⣤⣤⣀⡀⠀⢀⣀⣤⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⡿⠛⠉⠁⠀⠈⠉⠛⠿⠛⠉⠉⠉⠉⠙⠷⣄⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣧⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣆⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⠞⠛⠉⠙⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠛⢶⣄⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣦⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣷⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣴⣿⣿⡿⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⣀⣴⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠻⠿⠿⠿⠿⠃⠀⢀⣾⣿⣿⣿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠛⠋⠁⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⡿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⡤⠤⠤⠴⠒⠒⠒⠒⠒⢿⡿⠓⠒⠒⠢⠤⠤⠤⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣯⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⣀⣨⣿⣦⣤⣀⡀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣿⣿⣿⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣾⣿⣿⣿⣿⣿⡏⠉⠛⣿⣆⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⣀⣀⣀⣀⡸⠿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⣸⡿⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⠀⢸⣿⣿⣿⣿⡇⠀⣿⣿⣿⣿⣿⣿⠃⢀⣠⣴⡿⠃⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⣿⣿⠿⢇⣀⣀⣀⣀⣸⣿⣿⣿⣿⣿⡿⠿⠿⠛⠛⠁⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⡠⠀⠀⠀⠀⠈⠻⢿⣿⣿⣿⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀⠀⠠⣄⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⢸⣆⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⠿⣿⣿⣿⣿⣿⠿⠟⠋⠁⠀⠀⠀⠀⠀⠀⣀⣾⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠙⠻⢶⣦⣤⣄⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣤⣴⣶⠿⠛⠁⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠙⠛⠻⠿⠿⠿⠿⢿⣿⣿⣿⠿⠿⠿⠿⠟⠛⠛⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n`);\n\nexport const minimalLogo = chalk.cyan('PHALA TEE CLOUD CLI');","import { Command } from 'commander';\nimport { loginCommand } from './login';\nimport { logoutCommand } from './logout';\nimport { statusCommand } from './status';\n\nexport const authCommands = new Command()\n .name('auth')\n .description('Authenticate with Phala Cloud')\n .addCommand(loginCommand)\n .addCommand(logoutCommand)\n .addCommand(statusCommand);\n","import { Command } from 'commander';\nimport { removeApiKey, saveApiKey } from '@/src/utils/credentials';\nimport { logger } from '@/src/utils/logger';\nimport prompts from 'prompts';\nimport { getUserInfo } from '@/src/api/auth';\n\nexport const loginCommand = new Command()\n .name('login')\n .description('Set the API key for authentication')\n .argument('[api-key]', 'Phala Cloud API key to set')\n .action(async (apiKey?: string) => {\n try {\n // If no API key is provided, prompt for it\n if (!apiKey) {\n const response = await prompts({\n type: 'password',\n name: 'apiKey',\n message: 'Enter your API key:',\n validate: async (value) => {\n if (value.length === 0) {\n return 'API key cannot be empty';\n } else {\n try {\n await saveApiKey(value);\n const checkUserInfo = await getUserInfo();\n if (!checkUserInfo.username) {\n await removeApiKey();\n return 'Invalid API key';\n }\n } catch (error) {\n return 'Invalid API key';\n }\n }\n return true;\n }\n });\n \n apiKey = response.apiKey;\n } else {\n // Validate the API key\n const checkUserInfo = await getUserInfo();\n if (!checkUserInfo.username) {\n await removeApiKey();\n return 'Invalid API key';\n }\n }\n \n logger.success('API key validated and saved successfully');\n logger.info('\\nYou can check your authentication status with \"phala auth status\"');\n } catch (error) {\n logger.error(`Failed to set API key: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import fs from 'fs';\nimport path from 'path';\nimport os from 'os';\nimport crypto from 'crypto';\nimport { logger } from './logger';\n\n// Define the directory and file for storing credentials\nconst PHALA_CLOUD_DIR = path.join(os.homedir(), '.phala-cloud');\nconst API_KEY_FILE = path.join(PHALA_CLOUD_DIR, 'api-key');\nconst DOCKER_CREDENTIALS_FILE = path.join(PHALA_CLOUD_DIR, 'docker-credentials.json');\n\n// Ensure the .phala-cloud directory exists\nfunction ensureDirectoryExists(): void {\n if (!fs.existsSync(PHALA_CLOUD_DIR)) {\n try {\n fs.mkdirSync(PHALA_CLOUD_DIR, { recursive: true });\n } catch (error) {\n logger.error(`Failed to create directory ${PHALA_CLOUD_DIR}:`, error);\n throw error;\n }\n }\n}\n\n// Generate a machine-specific encryption key\nfunction getMachineKey(): Buffer {\n // Create a deterministic but machine-specific key\n const machineParts = [\n os.hostname(),\n os.platform(),\n os.arch(),\n os.cpus()[0]?.model || '',\n os.userInfo().username\n ];\n \n // Create a hash of the machine parts\n const hash = crypto.createHash('sha256');\n hash.update(machineParts.join('|'));\n return hash.digest();\n}\n\n// Encrypt data\nfunction encrypt(text: string): string {\n try {\n const key = getMachineKey();\n const iv = crypto.randomBytes(16);\n const cipher = crypto.createCipheriv('aes-256-cbc', key.slice(0, 32), iv);\n \n let encrypted = cipher.update(text, 'utf8', 'hex');\n encrypted += cipher.final('hex');\n \n // Return IV + encrypted data\n return iv.toString('hex') + ':' + encrypted;\n } catch (error) {\n logger.error('Encryption failed:', error);\n throw new Error('Failed to encrypt data');\n }\n}\n\n// Decrypt data\nfunction decrypt(encryptedText: string): string {\n try {\n const key = getMachineKey();\n const parts = encryptedText.split(':');\n \n if (parts.length !== 2) {\n throw new Error('Invalid encrypted format');\n }\n \n const iv = Buffer.from(parts[0], 'hex');\n const encrypted = parts[1];\n \n const decipher = crypto.createDecipheriv('aes-256-cbc', key.slice(0, 32), iv);\n \n let decrypted = decipher.update(encrypted, 'hex', 'utf8');\n decrypted += decipher.final('utf8');\n \n return decrypted;\n } catch (error) {\n logger.error('Decryption failed:', error);\n throw new Error('Failed to decrypt data');\n }\n}\n\n// API Key Management\nexport async function saveApiKey(apiKey: string): Promise<void> {\n ensureDirectoryExists();\n try {\n // Encrypt the API key before saving\n const encryptedApiKey = encrypt(apiKey);\n fs.writeFileSync(API_KEY_FILE, encryptedApiKey, { mode: 0o600 }); // Restrict permissions to user only\n } catch (error) {\n logger.error('Failed to save API key:', error);\n throw error;\n }\n}\n\nexport async function getApiKey(): Promise<string | null> {\n try {\n if (fs.existsSync(API_KEY_FILE)) {\n const encryptedApiKey = fs.readFileSync(API_KEY_FILE, 'utf8').trim();\n // Decrypt the API key\n return decrypt(encryptedApiKey);\n }\n return null;\n } catch (error) {\n logger.error('Failed to read API key:', error);\n return null;\n }\n}\n\nexport async function removeApiKey(): Promise<void> {\n try {\n if (fs.existsSync(API_KEY_FILE)) {\n fs.unlinkSync(API_KEY_FILE);\n logger.success('API key removed successfully.');\n } else {\n logger.warn('No API key found to remove.');\n }\n } catch (error) {\n logger.error('Failed to remove API key:', error);\n throw error;\n }\n}\n\n// Docker Credentials Management\ninterface DockerCredentials {\n username: string;\n password: string;\n registry?: string;\n}\n\nexport async function saveDockerCredentials(credentials: DockerCredentials): Promise<void> {\n ensureDirectoryExists();\n try {\n // Encrypt the password\n credentials.password = encrypt(credentials.password);\n \n fs.writeFileSync(\n DOCKER_CREDENTIALS_FILE, \n JSON.stringify(credentials, null, 2), \n { mode: 0o600 } // Restrict permissions to user only\n );\n logger.success('Docker credentials saved successfully.');\n } catch (error) {\n logger.error('Failed to save Docker credentials:', error);\n throw error;\n }\n}\n\nexport async function getDockerCredentials(): Promise<DockerCredentials | null> {\n try {\n if (fs.existsSync(DOCKER_CREDENTIALS_FILE)) {\n const data = fs.readFileSync(DOCKER_CREDENTIALS_FILE, 'utf8');\n const credentials = JSON.parse(data) as DockerCredentials;\n \n // Decrypt the password\n if (credentials.password) {\n credentials.password = decrypt(credentials.password);\n }\n \n return credentials;\n }\n return null;\n } catch (error) {\n logger.error('Failed to read Docker credentials:', error);\n return null;\n }\n}\n\nexport async function removeDockerCredentials(): Promise<void> {\n try {\n if (fs.existsSync(DOCKER_CREDENTIALS_FILE)) {\n fs.unlinkSync(DOCKER_CREDENTIALS_FILE);\n logger.success('Docker credentials removed successfully.');\n } else {\n logger.warn('No Docker credentials found to remove.');\n }\n } catch (error) {\n logger.error('Failed to remove Docker credentials:', error);\n throw error;\n }\n} ","import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';\nimport { getApiKey } from '../utils/credentials';\nimport { logger } from '../utils/logger';\nimport { CLOUD_API_URL, CLI_VERSION } from '../utils/constants';\n\n// Helper function to safely stringify objects that might contain cyclic references\nfunction safeStringify(obj: any): string {\n try {\n return JSON.stringify(obj);\n } catch (error) {\n if (error instanceof Error && error.message.includes('cyclic')) {\n return '[Cyclic Object]';\n }\n return String(obj);\n }\n}\n\nexport class ApiClient {\n private client: AxiosInstance;\n private apiKey: string | null = null;\n\n constructor(baseURL: string) {\n logger.debug(`Creating API client with base URL: ${baseURL}`);\n \n this.client = axios.create({\n baseURL,\n headers: {\n 'Content-Type': 'application/json',\n 'User-Agent': `tee-cloud-cli/${CLI_VERSION}`,\n },\n });\n\n // Add request interceptor to include API key\n this.client.interceptors.request.use(async (config) => {\n if (!this.apiKey) {\n this.apiKey = await getApiKey();\n if (!this.apiKey) {\n throw new Error('API key not found. Please set an API key first with \"phala auth login\"');\n }\n logger.debug(`API key loaded: ${this.apiKey.substring(0, 5)}...`);\n }\n \n config.headers['X-API-Key'] = this.apiKey;\n logger.debug(`Making request to: ${config.baseURL}${config.url}`);\n return config;\n });\n\n // Add response interceptor for error handling\n this.client.interceptors.response.use(\n (response) => {\n logger.debug(`Received successful response from: ${response.config.url}`);\n return response;\n },\n (error) => {\n if (error.response) {\n const { status, data } = error.response;\n \n logger.debug(`Received error response: ${status} - ${safeStringify(data)}`);\n \n if (status === 401) {\n logger.error('Authentication failed. Please check your API key.');\n } else if (status === 403) {\n logger.error('You do not have permission to perform this action.');\n } else if (status === 404) {\n logger.error('Resource not found.');\n } else {\n logger.error(`API Error (${status}): ${data.message || safeStringify(data)}`);\n }\n } else if (error.request) {\n logger.error('No response received from the server. Please check your internet connection.');\n logger.debug(`Request details: ${safeStringify(error.request).substring(0, 200)}...`);\n } else {\n logger.error(`Error: ${error.message}`);\n }\n \n return Promise.reject(error);\n }\n );\n }\n\n async get<T>(url: string, config?: AxiosRequestConfig): Promise<T> {\n try {\n logger.debug(`GET request to: ${url}`);\n const response = await this.client.get<T>(url, config);\n return response.data;\n } catch (error) {\n logger.debug(`GET request failed: ${error instanceof Error ? error.message : String(error)}`);\n throw error;\n }\n }\n\n async post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T> {\n try {\n logger.debug(`POST request to: ${url}`);\n const response = await this.client.post<T>(url, data, config);\n return response.data;\n } catch (error) {\n logger.debug(`POST request failed: ${error instanceof Error ? error.message : String(error)}`);\n throw error;\n }\n }\n\n async put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T> {\n try {\n logger.debug(`PUT request to: ${url}`);\n const response = await this.client.put<T>(url, data, config);\n return response.data;\n } catch (error) {\n logger.debug(`PUT request failed: ${error instanceof Error ? error.message : String(error)}`);\n throw error;\n }\n }\n\n async delete<T>(url: string, config?: AxiosRequestConfig): Promise<T> {\n try {\n logger.debug(`DELETE request to: ${url}`);\n const response = await this.client.delete<T>(url, config);\n return response.data;\n } catch (error) {\n logger.debug(`DELETE request failed: ${error instanceof Error ? error.message : String(error)}`);\n throw error;\n }\n }\n\n async patch<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T> {\n try {\n logger.debug(`PATCH request to: ${url}`);\n const response = await this.client.patch<T>(url, data, config);\n return response.data;\n } catch (error) {\n logger.debug(`PATCH request failed: ${error instanceof Error ? error.message : String(error)}`);\n throw error;\n }\n }\n}\n\n// Create and export a singleton instance\nlogger.debug(`Initializing API client with URL: ${CLOUD_API_URL}`);\nexport const apiClient = new ApiClient(CLOUD_API_URL); ","// API URLs\nexport const CLOUD_API_URL = process.env.CLOUD_API_URL || 'https://cloud-api.phala.network';\nexport const CLOUD_URL = process.env.CLOUD_URL || 'https://cloud.phala.network';\n\n// CLI Version\nexport const CLI_VERSION = '0.0.1';\n\n// Docker Hub API\nexport const DOCKER_HUB_API_URL = 'https://hub.docker.com/v2';\n\n// TEE Simulator\nexport const TEE_SIMULATOR = 'phalanetwork/tappd-simulator:latest';\n\n// Default resource configurations\nexport const DEFAULT_VCPU = 1;\nexport const DEFAULT_MEMORY = 2048; // MB\nexport const DEFAULT_DISK_SIZE = 20; // GB\n\n// API Endpoints\nexport const API_ENDPOINTS = {\n // Auth\n USER_INFO: '/api/v1/auth/me',\n\n // TEEPods\n TEEPODS: '/api/v1/teepods?enabled=true',\n TEEPOD_IMAGES: (teepodId: string) => `/api/v1/teepods/${teepodId}/images`,\n \n // CVMs\n CVMS: (userId: number) => `/api/v1/cvms?user_id=${userId}`,\n CVM_BY_APP_ID: (appId: string) => `/api/v1/cvms/app_${appId}`,\n CVM_START: (appId: string) => `/api/v1/cvms/app_${appId}/start`,\n CVM_STOP: (appId: string) => `/api/v1/cvms/app_${appId}/stop`,\n CVM_RESTART: (appId: string) => `/api/v1/cvms/app_${appId}/restart`,\n CVM_LOGS: (appId: string) => `/api/v1/cvms/app_${appId}/logs`,\n CVM_FROM_CONFIGURATION: '/api/v1/cvms/from_cvm_configuration',\n CVM_PUBKEY: '/api/v1/cvms/pubkey/from_cvm_configuration',\n CVM_UPGRADE: (appId: string) => `/api/v1/cvms/app_${appId}/compose`,\n CVM_ATTESTATION: (appId: string) => `/api/v1/cvms/app_${appId}/attestation`,\n CVM_RESIZE: (appId: string) => `/api/v1/cvms/app_${appId}/resources`,\n};\n\nexport const DOCKER_COMPOSE_ELIZA_V2_TEMPLATE = `version: '3.8'\nservices:\n postgres:\n image: postgres:15\n environment:\n - POSTGRES_PASSWORD=postgres\n - POSTGRES_USER=postgres\n - POSTGRES_DB=eliza\n volumes:\n - postgres-data:/var/lib/postgresql/data\n ports:\n - \"127.0.0.1:5432:5432\"\n healthcheck:\n test: [\"CMD-SHELL\", \"pg_isready -U postgres\"]\n interval: 5s\n timeout: 5s\n retries: 5\n restart: always\n eliza:\n image: {{imageName}}:{{tag}}\n container_name: elizav2\n command: bun run start\n stdin_open: true\n tty: true\n volumes:\n - /var/run/tappd.sock:/var/run/tappd.sock\n environment:\n{{#each envVars}} - {{{this}}}\n{{/each}}\n ports:\n - \"3000:3000\"\n - \"5173:5173\"\n depends_on:\n postgres:\n condition: service_healthy\n restart: always\n networks:\n - eliza-network\n\n\nnetworks:\n eliza-network:\n driver: bridge\n\nvolumes:\n postgres-data:`;\n\nexport const DOCKER_COMPOSE_BASIC_TEMPLATE = `version: '3.8'\nservices:\n app:\n image: {{imageName}}:{{tag}}\n container_name: app\n volumes:\n - /var/run/tappd.sock:/var/run/tappd.sock\n environment:\n{{#each envVars}} - {{{this}}}\n{{/each}}\n restart: always\n`","import { z } from 'zod';\nimport { ZodDecimal as zodDecimal } from '../utils/types';\n// Docker Config Schema\nexport const dockerConfigSchema = z.object({\n password: z.string(),\n registry: z.string().nullable(),\n username: z.string()\n});\n\n// Compose File Schema\nexport const composeFileSchema = z.object({\n docker_compose_file: z.string(),\n docker_config: dockerConfigSchema.optional(),\n features: z.array(z.string()),\n kms_enabled: z.boolean(),\n manifest_version: z.number(),\n name: z.string(),\n public_logs: z.boolean(),\n public_sysinfo: z.boolean(),\n runner: z.string().optional(),\n salt: z.string().nullable().optional(),\n tproxy_enabled: z.boolean(),\n version: z.string().optional()\n});\n\n// Configuration Schema\nexport const configurationSchema = z.object({\n name: z.string(),\n image: z.string(),\n compose_file: composeFileSchema,\n vcpu: z.number(),\n memory: z.number(),\n disk_size: z.number(),\n ports: z.array(z.any())\n});\n\n// Hosted Schema\nexport const hostedSchema = z.object({\n id: z.string(),\n name: z.string(),\n status: z.string(),\n uptime: z.string(),\n app_url: z.string(),\n app_id: z.string(),\n instance_id: z.string(),\n configuration: configurationSchema,\n exited_at: z.string(),\n boot_progress: z.string(),\n boot_error: z.string(),\n shutdown_progress: z.string(),\n image_version: z.string()\n});\n\n// Managed User Schema\nexport const managedUserSchema = z.object({\n id: z.number(),\n username: z.string()\n});\n\n// Node Schema\nexport const nodeSchema = z.object({\n id: z.number(),\n name: z.string()\n});\n\n// CVM Instance Schema\nexport const cvmInstanceSchema = z.object({\n hosted: hostedSchema,\n name: z.string(),\n managed_user: managedUserSchema,\n node: nodeSchema,\n listed: z.boolean(),\n status: z.string(),\n in_progress: z.boolean(),\n dapp_dashboard_url: z.string().nullable(),\n syslog_endpoint: z.string(),\n allow_upgrade: z.boolean()\n});\n\n// Create CVM Response Schema\nexport const createCvmResponseSchema = z.object({\n id: z.number(),\n name: z.string(),\n status: z.string(),\n teepod_id: z.number(),\n teepod: z.object({\n id: z.number(),\n name: z.string()\n }),\n user_id: z.number(),\n app_id: z.string(),\n vm_uuid: z.string().nullable(),\n instance_id: z.string().nullable(),\n app_url: z.string().nullable(),\n base_image: z.string(),\n vcpu: z.number(),\n memory: z.number(),\n disk_size: z.number(),\n manifest_version: z.number(),\n version: z.string(),\n runner: z.string(),\n docker_compose_file: z.string(),\n features: z.array(z.string()).nullable(),\n created_at: z.string(),\n encrypted_env_pubkey: z.string()\n});\n\n// Get Pubkey From CVM Response Schema\nexport const getPubkeyFromCvmResponseSchema = z.object({\n app_env_encrypt_pubkey: z.string(),\n app_id_salt: z.string()\n});\n\n// Get CVM By App ID Response Schema\nexport const getCvmByAppIdResponseSchema = z.object({\n id: z.number(),\n teepod_id: z.number(),\n teepod: z.object({\n id: z.number(),\n name: z.string()\n }),\n name: z.string(),\n status: z.string(),\n in_progress: z.boolean(),\n app_id: z.string(),\n vm_uuid: z.string(),\n instance_id: z.string(),\n vcpu: z.number(),\n memory: z.number(),\n disk_size: z.number(),\n base_image: z.string(),\n encrypted_env_pubkey: z.string(),\n listed: z.boolean(),\n project_id: z.string(),\n project_type: z.string().nullable()\n});\n\n// Get User Info Response Schema\nexport const getUserInfoResponseSchema = z.object({\n username: z.string(),\n email: z.string(),\n credits: zodDecimal.create({ coerce: true }),\n role: z.string(),\n avatar: z.string(),\n flag_reset_password: z.boolean(),\n team_name: z.string(),\n team_tier: z.string(),\n trial_ended_at: z.string().nullable()\n});\n\n// Get CVMs By User ID Response Schema\nexport const getCvmsByUserIdResponseSchema = z.array(cvmInstanceSchema);\n\n// Upgrade CVM Response Schema\nexport const upgradeCvmResponseSchema = z.object({\n detail: z.string()\n});\n\n// Encrypted Env Item Schema\nexport const encryptedEnvItemSchema = z.object({\n key: z.string(),\n value: z.string()\n});\n\n// TEEPod Schema\nexport const teepodSchema = z.object({\n id: z.number(),\n name: z.string(),\n status: z.string()\n});\n\n// Image Schema\nexport const imageSchema = z.object({\n name: z.string(),\n description: z.string().optional()\n});\n\n// Type exports\nexport type DockerConfig = z.infer<typeof dockerConfigSchema>;\nexport type ComposeFile = z.infer<typeof composeFileSchema>;\nexport type Configuration = z.infer<typeof configurationSchema>;\nexport type Hosted = z.infer<typeof hostedSchema>;\nexport type ManagedUser = z.infer<typeof managedUserSchema>;\nexport type Node = z.infer<typeof nodeSchema>;\nexport type CvmInstance = z.infer<typeof cvmInstanceSchema>;\nexport type CreateCvmResponse = z.infer<typeof createCvmResponseSchema>;\nexport type GetPubkeyFromCvmResponse = z.infer<typeof getPubkeyFromCvmResponseSchema>;\nexport type GetCvmByAppIdResponse = z.infer<typeof getCvmByAppIdResponseSchema>;\nexport type GetUserInfoResponse = z.infer<typeof getUserInfoResponseSchema>;\nexport type GetCvmsByUserIdResponse = z.infer<typeof getCvmsByUserIdResponseSchema>;\nexport type UpgradeCvmResponse = z.infer<typeof upgradeCvmResponseSchema>;\nexport type EncryptedEnvItem = z.infer<typeof encryptedEnvItemSchema>;\nexport type TEEPod = z.infer<typeof teepodSchema>;\nexport type Image = z.infer<typeof imageSchema>;","import {\n INVALID,\n ParseContext,\n ParseInput,\n ParseReturnType,\n ParseStatus,\n RawCreateParams,\n ZodIssueCode,\n ZodParsedType,\n ZodType,\n ZodTypeDef,\n addIssueToContext,\n z,\n} from 'zod';\n\nexport type ZodDecimalCheck =\n | { kind: 'precision'; value: number; message?: string }\n | { kind: 'wholeNumber'; value: number; message?: string }\n | { kind: 'min'; value: number; inclusive: boolean; message?: string }\n | { kind: 'max'; value: number; inclusive: boolean; message?: string }\n | { kind: 'finite'; message?: string };\n\nconst zodDecimalKind = 'ZodDecimal';\n\nexport interface ZodDecimalDef extends ZodTypeDef {\n checks: ZodDecimalCheck[];\n typeName: typeof zodDecimalKind;\n coerce: boolean;\n}\n\nconst precisionRegex = /(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ZodDecimal extends ZodType<number, ZodDecimalDef, any> {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n _parse(input: ParseInput): ParseReturnType<number> {\n // detect decimal js object\n if (input.data !== null && typeof input.data === 'object' && 'toNumber' in input.data) {\n input.data = input.data.toNumber();\n }\n if (this._def.coerce) {\n input.data = Number(input.data);\n }\n\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.number) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.number,\n received: ctx.parsedType,\n });\n return INVALID;\n }\n\n let ctx: undefined | ParseContext = undefined;\n const status = new ParseStatus();\n\n for (const check of this._def.checks) {\n if (check.kind === 'precision') {\n const parts = input.data.toString().match(precisionRegex);\n const decimals = Math.max(\n (parts[1] ? parts[1].length : 0) - (parts[2] ? parseInt(parts[2], 10) : 0),\n 0\n );\n if (decimals > check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.custom,\n message: check.message,\n params: {\n precision: check.value,\n },\n });\n status.dirty();\n }\n } else if (check.kind === 'wholeNumber') {\n const wholeNumber = input.data.toString().split('.')[0];\n const tooLong = wholeNumber.length > check.value;\n\n if (tooLong) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.custom,\n message: check.message,\n params: {\n wholeNumber: check.value,\n },\n });\n status.dirty();\n }\n } else if (check.kind === 'min') {\n const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;\n if (tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: 'number',\n inclusive: check.inclusive,\n exact: false,\n message: check.message,\n });\n status.dirty();\n }\n } else if (check.kind === 'max') {\n const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;\n if (tooBig) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: 'number',\n inclusive: check.inclusive,\n exact: false,\n message: check.message,\n });\n status.dirty();\n }\n } else if (check.kind === 'finite') {\n if (!Number.isFinite(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_finite,\n message: check.message,\n });\n status.dirty();\n }\n }\n }\n\n return { status: status.value, value: input.data };\n }\n\n static create = (params?: RawCreateParams & { coerce?: true }): ZodDecimal => {\n return new ZodDecimal({\n checks: [],\n typeName: zodDecimalKind,\n coerce: params?.coerce ?? false,\n });\n };\n\n protected setLimit(\n kind: 'min' | 'max',\n value: number,\n inclusive: boolean,\n message?: string\n ): ZodDecimal {\n return new ZodDecimal({\n ...this._def,\n checks: [\n ...this._def.checks,\n {\n kind,\n value,\n inclusive,\n message,\n },\n ],\n });\n }\n\n _addCheck(check: ZodDecimalCheck): ZodDecimal {\n return new ZodDecimal({\n ...this._def,\n checks: [...this._def.checks, check],\n });\n }\n\n lte(value: number, message?: string): ZodDecimal {\n return this.setLimit('max', value, true, message);\n }\n\n lt(value: number, message?: string): ZodDecimal {\n return this.setLimit('max', value, false, message);\n }\n max = this.lte;\n\n gt(value: number, message?: string): ZodDecimal {\n return this.setLimit('min', value, false, message);\n }\n gte(value: number, message?: string): ZodDecimal {\n return this.setLimit('min', value, true, message);\n }\n\n min = this.gte;\n\n precision(value: number, message?: string): ZodDecimal {\n return this._addCheck({\n kind: 'precision',\n value,\n message,\n });\n }\n wholeNumber(value: number, message?: string): ZodDecimal {\n return this._addCheck({\n kind: 'wholeNumber',\n value,\n message,\n });\n }\n\n get minValue() {\n let min: number | null = null;\n for (const ch of this._def.checks) {\n if (ch.kind === 'min') {\n if (min === null || ch.value > min) min = ch.value;\n }\n }\n return min;\n }\n\n get maxValue() {\n let max: number | null = null;\n for (const ch of this._def.checks) {\n if (ch.kind === 'max') {\n if (max === null || ch.value < max) max = ch.value;\n }\n }\n return max;\n }\n\n positive(message?: string) {\n return this._addCheck({\n kind: 'min',\n value: 0,\n inclusive: false,\n message,\n });\n }\n\n negative(message?: string) {\n return this._addCheck({\n kind: 'max',\n value: 0,\n inclusive: false,\n message,\n });\n }\n\n nonpositive(message?: string) {\n return this._addCheck({\n kind: 'max',\n value: 0,\n inclusive: true,\n message,\n });\n }\n\n nonnegative(message?: string) {\n return this._addCheck({\n kind: 'min',\n value: 0,\n inclusive: true,\n message,\n });\n }\n\n finite(message?: string) {\n return this._addCheck({\n kind: 'finite',\n message,\n });\n }\n\n safe(message?: string) {\n return this._addCheck({\n kind: 'min',\n inclusive: true,\n value: Number.MIN_SAFE_INTEGER,\n message,\n })._addCheck({\n kind: 'max',\n inclusive: true,\n value: Number.MAX_SAFE_INTEGER,\n message,\n });\n }\n\n get isFinite() {\n let max: number | null = null,\n min: number | null = null;\n for (const ch of this._def.checks) {\n if (ch.kind === 'finite') {\n return true;\n } else if (ch.kind === 'min') {\n if (min === null || ch.value > min) min = ch.value;\n } else if (ch.kind === 'max') {\n if (max === null || ch.value < max) max = ch.value;\n }\n }\n return Number.isFinite(min) && Number.isFinite(max);\n }\n}\n\n// Docker Compose Template Schema\nexport const ComposeTemplateSchema = z.object({\n template: z.string().min(1, \"Template cannot be empty\")\n});\n\nexport type ComposeTemplate = z.infer<typeof ComposeTemplateSchema>;","import { apiClient } from './client';\nimport { API_ENDPOINTS } from '../utils/constants';\nimport { GetUserInfoResponse, getUserInfoResponseSchema } from './types';\nimport { logger } from '../utils/logger';\n\n// Helper function to safely stringify objects that might contain cyclic references\nfunction safeStringify(obj: any): string {\n try {\n return JSON.stringify(obj);\n } catch (error) {\n if (error instanceof Error && error.message.includes('cyclic')) {\n return '[Cyclic Object]';\n }\n return String(obj);\n }\n}\n\n/**\n * Get user information\n * @returns User information\n */\nexport async function getUserInfo(): Promise<GetUserInfoResponse> {\n try {\n logger.debug(`Fetching user info from ${API_ENDPOINTS.USER_INFO}`);\n const response = await apiClient.get<any>(API_ENDPOINTS.USER_INFO);\n logger.debug(`Received response: ${safeStringify(response)}`);\n \n // Try to parse the response with the schema\n try {\n return getUserInfoResponseSchema.parse(response);\n } catch (parseError) {\n logger.error(`Failed to parse user info response: ${parseError}`);\n logger.debug(`Response structure: ${safeStringify(response)}`);\n throw parseError;\n }\n } catch (error) {\n logger.error(`Failed to get user info: ${error instanceof Error ? error.message : String(error)}`);\n throw new Error(`Failed to get user info: ${error instanceof Error ? error.message : String(error)}`);\n }\n}","import { Command } from 'commander';\nimport { removeApiKey } from '@/src/utils/credentials';\nimport { logger } from '@/src/utils/logger';\n\nexport const logoutCommand = new Command()\n .name('logout')\n .description('Remove the stored API key')\n .action(async () => {\n try {\n await removeApiKey();\n logger.success('API key removed successfully');\n } catch (error) {\n logger.error(`Failed to remove API key: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { getApiKey } from '@/src/utils/credentials';\nimport { getUserInfo } from '@/src/api/auth';\nimport { logger } from '@/src/utils/logger';\n\nexport const statusCommand = new Command()\n .name('status')\n .description('Check authentication status')\n .option('-j, --json', 'Output in JSON format')\n .option('-d, --debug', 'Enable debug output')\n .action(async (options) => {\n try {\n // Enable debug mode if requested\n if (options.debug) {\n process.env.DEBUG = 'true';\n }\n \n const apiKey = await getApiKey();\n \n if (!apiKey) {\n logger.warn('Not authenticated. Please set an API key with \"phala auth login\"');\n return;\n }\n \n logger.debug(`Using API key: ${apiKey.substring(0, 5)}...`);\n const spinner = logger.startSpinner('Checking authentication status');\n \n try {\n const userInfo = await getUserInfo();\n spinner.stop(true);\n \n if (options.json) {\n console.log(JSON.stringify(userInfo, null, 2));\n return;\n }\n \n logger.success(`Authenticated as ${userInfo.username}`);\n logger.break();\n \n // Create a simple object for console.table\n const tableData = {\n 'Username': userInfo.username,\n 'Email': userInfo.email,\n 'Role': userInfo.role,\n 'Team': `${userInfo.team_name} (${userInfo.team_tier})`,\n 'Credits': `$${userInfo.credits}`\n };\n \n if (userInfo.trial_ended_at) {\n tableData['Trial Ended At'] = userInfo.trial_ended_at;\n }\n \n // Display the table\n console.table(tableData);\n } catch (error) {\n spinner.stop(false);\n logger.error('Authentication failed. Your API key may be invalid or expired.');\n logger.info('Please set a new API key with \"phala auth login\"');\n \n if (options.debug) {\n logger.debug(`Error details: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n } catch (error) {\n logger.error(`Failed to check authentication status: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { listCommand } from './list';\nimport { imagesCommand } from './images';\n\nexport const teepodsCommands = new Command()\n .name('teepods')\n .description('TEEPod management commands')\n .addCommand(listCommand)\n .addCommand(imagesCommand);\n","import { Command } from 'commander';\nimport { getTeepods } from '@/src/api/teepods';\nimport { logger } from '@/src/utils/logger';\n\nexport const listCommand = new Command()\n .name('list')\n .description('List available TEEPods')\n .action(async () => {\n try {\n const spinner = logger.startSpinner('Fetching TEEPods');\n \n const teepods = await getTeepods();\n \n spinner.stop(true);\n \n if (teepods.length === 0) {\n logger.info('No TEEPods found');\n return;\n }\n \n logger.info('Available TEEPods:');\n logger.table(teepods, ['id', 'name', 'status']);\n } catch (error) {\n logger.error(`Failed to list TEEPods: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { apiClient } from './client';\nimport { API_ENDPOINTS } from '../utils/constants';\nimport { TEEPod, Image, teepodSchema, imageSchema } from './types';\nimport { z } from 'zod';\n\n/**\n * Get all TEEPods\n * @returns List of TEEPods\n */\nexport async function getTeepods(): Promise<TEEPod[]> {\n try {\n const response = await apiClient.get<TEEPod[]>(API_ENDPOINTS.TEEPODS);\n return z.array(teepodSchema).parse(response);\n } catch (error) {\n throw new Error(`Failed to get TEEPods: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Get images for a TEEPod\n * @param teepodId TEEPod ID\n * @returns List of images\n */\nexport async function getTeepodImages(teepodId: string): Promise<Image[]> {\n try {\n const response = await apiClient.get<Image[]>(API_ENDPOINTS.TEEPOD_IMAGES(teepodId));\n return z.array(imageSchema).parse(response);\n } catch (error) {\n throw new Error(`Failed to get TEEPod images: ${error instanceof Error ? error.message : String(error)}`);\n }\n} ","import { Command } from 'commander';\nimport { getTeepodImages, getTeepods } from '@/src/api/teepods';\nimport { logger } from '@/src/utils/logger';\nimport inquirer from 'inquirer';\n\nexport const imagesCommand = new Command()\n .name('images')\n .description('List available images for a TEEPod')\n .option('-t, --teepod-id <teepodId>', 'TEEPod ID')\n .action(async (options) => {\n try {\n const spinner = logger.startSpinner(`Fetching images for TEEPod ${options.teepodId}`);\n \n if (!options.teepodId) {\n // Fetch available TEEPods\n const teepodsSpinner = logger.startSpinner('Fetching available TEEPods');\n const teepods = await getTeepods();\n teepodsSpinner.stop(true);\n\n if (teepods.length === 0) {\n logger.error('No TEEPods available. Please try again later.');\n process.exit(1);\n }\n\n // Use inquirer to select a TEEPod\n const { selectedTeepodId } = await inquirer.prompt([\n {\n type: 'list',\n name: 'selectedTeepodId',\n message: 'Select a TEEPod:',\n choices: teepods.map(pod => ({\n name: `${pod.name} (${pod.status})`,\n value: pod.id\n }))\n }\n ]);\n \n options.teepodId = selectedTeepodId;\n }\n \n const images = await getTeepodImages(options.teepodId);\n \n spinner.stop(true);\n \n if (images.length === 0) {\n logger.info(`No images found for TEEPod ${options.teepodId}`);\n return;\n }\n \n logger.info(`Available images for TEEPod ${options.teepodId}:`);\n logger.table(images, ['name', 'description']);\n } catch (error) {\n logger.error(`Failed to list images: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { loginCommand } from './login';\nimport { buildCommand } from './build';\nimport { pushCommand } from './push';\nimport { tagsCommand } from './tags';\nimport { runCommand } from './run';\nimport { generateCommand } from './generate';\n\nexport const dockerCommands = new Command()\n .name('docker')\n .description('Login to Docker Hub and manage Docker images')\n .addCommand(loginCommand)\n .addCommand(buildCommand)\n .addCommand(pushCommand)\n .addCommand(tagsCommand)\n .addCommand(runCommand)\n .addCommand(generateCommand);\n","import { Command } from 'commander';\nimport { DockerService } from '../../utils/docker';\nimport { saveDockerCredentials } from '../../utils/credentials';\nimport { logger } from '../../utils/logger';\nimport prompts from 'prompts';\n\nexport const loginCommand = new Command()\n .name('login')\n .description('Login to Docker Hub')\n .option('-u, --username <username>', 'Docker Hub username')\n .option('-p, --password <password>', 'Docker Hub password')\n .option('-r, --registry <registry>', 'Docker registry URL')\n .action(async (options) => {\n try {\n let username = options.username;\n let password = options.password;\n const registry = options.registry;\n \n // If no username is provided, prompt for it\n if (!username) {\n const response = await prompts({\n type: 'text',\n name: 'username',\n message: 'Enter your Docker Hub username:',\n validate: value => value.length > 0 ? true : 'Username cannot be empty'\n });\n \n if (!response.username) {\n logger.error('Username is required');\n process.exit(1);\n }\n \n username = response.username;\n }\n \n // If no password is provided, prompt for it\n if (!password) {\n const response = await prompts({\n type: 'password',\n name: 'password',\n message: 'Enter your Docker Hub password:',\n validate: value => value.length > 0 ? true : 'Password cannot be empty'\n });\n \n if (!response.password) {\n logger.error('Password is required');\n process.exit(1);\n }\n \n password = response.password;\n }\n \n // Login to Docker Hub\n const dockerService = new DockerService('', username, registry);\n const success = await dockerService.login(username, password, registry);\n \n if (!success) {\n logger.error('Failed to login to Docker Hub');\n process.exit(1);\n }\n \n // Save credentials\n await saveDockerCredentials({\n username,\n password,\n registry: registry || null\n });\n \n logger.success('Logged in to Docker Hub successfully');\n } catch (error) {\n logger.error(`Failed to login to Docker Hub: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { execa } from 'execa';\nimport fs from 'fs';\nimport path from 'path';\nimport axios from 'axios';\nimport { logger } from './logger';\nimport { DOCKER_COMPOSE_BASIC_TEMPLATE, DOCKER_COMPOSE_ELIZA_V2_TEMPLATE, DOCKER_HUB_API_URL } from './constants';\nimport { getDockerCredentials } from './credentials';\nimport Handlebars from 'handlebars';\nimport { exec, spawn } from 'child_process';\nimport { promisify } from 'util';\nimport os from 'os';\nimport { validateFileExists } from './prompts';\nimport { ComposeTemplateSchema } from './types';\n\nconst execAsync = promisify(exec);\nconst LOGS_DIR = '.phala-cloud/logs';\nconst COMPOSE_FILES_DIR = '.phala-cloud/compose';\nconst MAX_CONSOLE_LINES = 10;\n\nexport class DockerService {\n private username: string;\n private image: string;\n private registry: string;\n\n constructor(image: string, username?: string, registry?: string) {\n this.image = image;\n this.username = username || '';\n this.registry = registry || '';\n }\n\n private ensureLogsDir(): void {\n const logsPath = path.resolve(LOGS_DIR);\n if (!fs.existsSync(logsPath)) {\n fs.mkdirSync(logsPath, { recursive: true });\n }\n }\n\n private getLogFilePath(operation: string): string {\n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\n return path.resolve(LOGS_DIR, `${this.image}-${operation}-${timestamp}.log`);\n }\n\n private getSystemArchitecture(): string {\n const arch = os.arch();\n switch (arch) {\n case 'arm':\n case 'arm64':\n return 'arm64';\n case 'x64':\n return 'amd64';\n default:\n return arch;\n }\n }\n\n private spawnProcess(command: string, args: string[], operation: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const proc = spawn(command, args);\n const logFile = this.getLogFilePath(operation);\n\n // Ensure logs directory exists before creating write stream\n this.ensureLogsDir();\n\n const logStream = fs.createWriteStream(logFile, { flags: 'a' });\n const consoleBuffer: string[] = [];\n\n const processOutput = (data: Buffer, isError: boolean = false) => {\n const lines = data.toString().split('\\n');\n\n // Write to log file\n logStream.write(data);\n\n // Update console buffer\n lines.forEach(line => {\n if (line.trim()) {\n consoleBuffer.push(line);\n // Keep only the last MAX_CONSOLE_LINES lines\n if (consoleBuffer.length > MAX_CONSOLE_LINES) {\n consoleBuffer.shift();\n }\n\n // Clear console and print the buffer\n console.clear();\n console.log(`Latest ${MAX_CONSOLE_LINES} lines (full log at ${logFile}):`);\n console.log('-'.repeat(50));\n consoleBuffer.forEach(bufferedLine => {\n if (isError) {\n console.error(bufferedLine);\n } else {\n console.log(bufferedLine);\n }\n });\n }\n });\n };\n\n proc.stdout.on('data', (data) => processOutput(data));\n proc.stderr.on('data', (data) => processOutput(data, true));\n\n proc.on('close', (code) => {\n logStream.end();\n if (code === 0) {\n console.log(`\\nOperation completed. Full log available at: ${logFile}`);\n resolve();\n } else {\n reject(new Error(`Process exited with code ${code}. Check log file: ${logFile}`));\n }\n });\n\n proc.on('error', (err) => {\n logStream.end();\n reject(err);\n });\n });\n }\n\n /**\n * Set Docker credentials\n * @param username Docker username\n * @param registry Docker registry\n */\n setCredentials(username: string, registry?: string): void {\n this.username = username;\n if (registry) {\n this.registry = registry;\n }\n }\n\n /**\n * Build a Docker image\n * @param dockerfile Path to Dockerfile\n * @param tag Tag for the image\n * @returns Success status\n */\n async buildImage(dockerfile: string, tag: string): Promise<boolean> {\n try {\n const arch = this.getSystemArchitecture();\n const fullImageName = `${this.username}/${this.image}:${tag}`;\n\n const spinner = logger.startSpinner(`Building Docker image ${this.username}/${this.image}:${tag}`);\n\n // Ensure the Dockerfile exists\n validateFileExists(dockerfile);\n\n const buildArgs = ['build', '-t', fullImageName, '-f', dockerfile];\n\n if (arch === 'arm64') {\n console.log('Detected arm64 architecture, using --platform linux/amd64');\n buildArgs.push('--platform', 'linux/amd64');\n }\n\n // Build the image\n buildArgs.push('.');\n\n await this.spawnProcess('docker', buildArgs, 'build');\n\n spinner.stop(true, `Docker image ${fullImageName} built successfully`);\n return true;\n } catch (error) {\n logger.error(`Failed to build Docker image: ${error instanceof Error ? error.message : String(error)}`);\n return false;\n }\n }\n\n /**\n * Push a Docker image to Docker Hub\n * @param tag Tag for the image\n * @returns Success status\n */\n async pushImage(tag: string): Promise<boolean> {\n try {\n const spinner = logger.startSpinner(`Pushing Docker image ${this.username}/${this.image}:${tag} to Docker Hub`);\n\n // Check if user is logged in\n const credentials = await getDockerCredentials();\n if (!credentials) {\n spinner.stop(false);\n throw new Error('Docker credentials not found. Please log in first with \"phala docker login\"');\n }\n\n const fullImageName = `${this.username}/${this.image}:${tag}`;\n console.log(`Pushing image ${fullImageName} to Docker Hub...`);\n\n await this.spawnProcess('docker', ['push', fullImageName], 'push');\n\n spinner.stop(true, `Docker image ${fullImageName} pushed successfully`);\n return true;\n } catch (error) {\n logger.error(`Failed to push Docker image: ${error instanceof Error ? error.message : String(error)}`);\n return false;\n }\n }\n\n /**\n * List tags for a Docker image\n * @returns List of tags\n */\n async listTags(): Promise<string[]> {\n try {\n const spinner = logger.startSpinner(`Listing tags for ${this.username}/${this.image}`);\n\n // Get tags from Docker Hub API\n const response = await axios.get(`${DOCKER_HUB_API_URL}/repositories/${this.username}/${this.image}/tags`);\n\n if (!response.data || !response.data.results) {\n spinner.stop(false);\n throw new Error('Failed to get tags from Docker Hub');\n }\n\n const tags = response.data.results.map((result: any) => result.name);\n\n spinner.stop(true, `Found ${tags.length} tags`);\n return tags;\n } catch (error) {\n logger.error(`Failed to list tags: ${error instanceof Error ? error.message : String(error)}`);\n return [];\n }\n }\n\n /**\n * Delete a Docker image tag\n * @param tag Tag to delete\n * @returns Success status\n */\n async deleteTag(tag: string): Promise<boolean> {\n try {\n const spinner = logger.startSpinner(`Deleting tag ${this.username}/${this.image}:${tag}`);\n\n // Check if user is logged in\n const credentials = await getDockerCredentials();\n if (!credentials) {\n spinner.stop(false);\n throw new Error('Docker credentials not found. Please log in first with \"phala docker login\"');\n }\n\n // Delete the tag using Docker Hub API\n const response = await axios.delete(\n `${DOCKER_HUB_API_URL}/repositories/${this.username}/${this.image}/tags/${tag}`,\n {\n auth: {\n username: credentials.username,\n password: credentials.password\n }\n }\n );\n\n spinner.stop(true, 'Tag deleted successfully');\n return true;\n } catch (error) {\n logger.error(`Failed to delete tag: ${error instanceof Error ? error.message : String(error)}`);\n return false;\n }\n }\n\n /**\n * Login to Docker Hub\n * @param username Docker username\n * @param password Docker password\n * @param registry Docker registry\n * @returns Success status\n */\n async login(username: string, password: string, registry?: string): Promise<boolean> {\n try {\n const spinner = logger.startSpinner(`Logging in to Docker Hub as ${username}`);\n\n // Login to Docker\n await execa('docker', [\n 'login',\n ...(registry ? [registry] : []),\n '-u',\n username,\n '--password-stdin'\n ], {\n input: password\n });\n\n spinner.stop(true, 'Logged in to Docker Hub successfully');\n return true;\n } catch (error) {\n logger.error(`Failed to login to Docker Hub: ${error instanceof Error ? error.message : String(error)}`);\n return false;\n }\n }\n\n /**\n * Build a Docker Compose file\n * @param tag Tag for the image\n * @param envFile Optional path to environment file\n * @param version Version of the template to use\n * @returns Path to the generated Docker Compose file\n */\n async buildComposeFile(tag: string, envFile?: string, templateType?: string): Promise<string> {\n if (!this.username) {\n throw new Error('Docker Hub username is required for building compose file');\n }\n\n const template = (templateType == 'eliza') ? DOCKER_COMPOSE_ELIZA_V2_TEMPLATE : DOCKER_COMPOSE_BASIC_TEMPLATE;\n\n // Validate template structure\n const validatedTemplate = ComposeTemplateSchema.parse({ template });\n\n // Ensure compose files directory exists\n const composePath = COMPOSE_FILES_DIR;\n \n // Create directory if it doesn't exist\n if (!fs.existsSync(composePath)) {\n logger.info(`Creating directory: ${composePath}`);\n fs.mkdirSync(composePath, { recursive: true });\n }\n\n let envVars: string[] = [];\n \n // Only parse env file if it's provided\n if (envFile) {\n // Parse env file to get variable names\n const envContent = fs.readFileSync(envFile, 'utf-8');\n envVars = envContent\n .split('\\n')\n .filter(line => line && !line.startsWith('#'))\n .map(line => {\n // Remove inline comments\n const commentIndex = line.indexOf('#');\n if (commentIndex > 0) {\n line = line.substring(0, commentIndex).trim();\n }\n return line.trim();\n })\n .filter(line => line.includes('='))\n .map(line => {\n const [key, value] = line.split('=', 2);\n const trimmedKey = key.trim();\n const trimmedValue = value ? value.trim() : '';\n\n // Skip empty values\n if (trimmedValue === '') {\n return null;\n }\n\n // Keep the original key without any transformation\n return `${trimmedKey}=${trimmedKey}`; // Create KEY=KEY format\n })\n .filter(Boolean as any); // Remove null entries\n }\n\n // Create full image name with username\n const fullImageName = `${this.username}/${this.image}`;\n\n // Compile template with data\n const compiledTemplate = Handlebars.compile(validatedTemplate.template, { noEscape: true });\n const composeContent = compiledTemplate({\n imageName: fullImageName,\n tag,\n envVars: envVars.map(env => env.replace(/=.*/, '=\\${' + env.split('=')[0] + '}'))\n });\n\n // Write the docker-compose file with standardized name in the compose directory\n const composeFile = path.join(composePath, `${this.image}-${tag}-tee-compose.yaml`);\n fs.writeFileSync(composeFile, composeContent);\n\n logger.success(`Backup of docker compose file created at: ${composeFile}`);\n return composeFile;\n }\n\n /**\n * Run a Docker Compose file locally\n * @param composePath Path to Docker Compose file\n * @param envFile Path to environment file\n * @returns Success status\n */\n async runComposeLocally(composePath: string, envFile?: string): Promise<boolean> {\n try {\n // TODO: Update log when optimized simulator is implemented\n const spinner = logger.startSpinner(`Running Docker Compose file at ${composePath}\\n- If you run with the simulator, set DSTACK_SIMULATOR_ENDPOINT to http://host.docker.internal:8090`);\n\n // Ensure the Docker Compose file exists\n validateFileExists(composePath);\n\n // Build the command arguments\n const composeArgs = [\n '-f',\n composePath,\n 'up',\n '-d'\n ];\n\n // Only add env-file if it's provided\n if (envFile) {\n // Ensure the environment file exists\n validateFileExists(envFile);\n composeArgs.splice(2, 0, '--env-file', envFile);\n }\n\n // Run the Docker Compose file\n await execa('docker-compose', composeArgs);\n\n spinner.stop(true, 'Docker Compose file running successfully');\n return true;\n } catch (error) {\n logger.error(`Failed to run Docker Compose file: ${error instanceof Error ? error.message : String(error)}`);\n return false;\n }\n }\n\n /**\n * Run the TEE simulator\n * @param image Simulator image\n * @returns Success status\n */\n async runSimulator(image: string): Promise<boolean> {\n try {\n logger.info(`Running TEE simulator with image ${image}`);\n\n logger.info('Pulling latest simulator image...');\n await execAsync(`docker pull ${image}`);\n\n logger.info('Starting simulator in background...');\n const { stdout } = await execAsync(`docker run -d --name tee-simulator --rm -p 8090:8090 ${image}`);\n const containerId = stdout.trim();\n\n logger.success(`TEE simulator running successfully. Container ID: ${containerId}`);\n logger.info(`\\n\\nUseful commands:`);\n logger.info(`- View logs: docker logs -f ${containerId}`);\n logger.info(`- Stop simulator: docker stop ${containerId}`);\n return true;\n } catch (error) {\n logger.error(`Failed to run TEE simulator: ${error instanceof Error ? error.message : String(error)}`);\n return false;\n }\n }\n\n /**\n * Stop the TEE simulator\n * @returns Success status\n */\n async stopSimulator(): Promise<boolean> {\n try {\n const spinner = logger.startSpinner('Stopping TEE simulator...');\n\n // Stop the simulator\n await execAsync(`docker stop tee-simulator`);\n\n spinner.stop(true, 'TEE simulator stopped successfully');\n return true;\n } catch (error) {\n logger.error(`Failed to stop TEE simulator: ${error instanceof Error ? error.message : String(error)}`);\n return false;\n }\n }\n\n /**\n * List local Docker images and their tags\n * @returns Array of objects with image name and tag\n */\n static async listLocalImages(): Promise<Array<{ name: string, tag: string }>> {\n try {\n // Query Docker for local images in format that outputs repository and tag\n const { stdout } = await execAsync('docker images --format \"{{.Repository}}:{{.Tag}}\"');\n\n // Parse the output and filter out any <none> tags or images\n const imageList = stdout.split('\\n')\n .filter(line => line && !line.includes('<none>'))\n .map(line => {\n const [repo, tag] = line.split(':');\n // Separate username/image format if available\n const nameParts = repo.split('/');\n const name = nameParts.length > 1 ? nameParts[1] : repo;\n return { name, tag };\n });\n\n return imageList;\n } catch (error) {\n logger.error(`Failed to list local Docker images: ${error instanceof Error ? error.message : String(error)}`);\n return [];\n }\n }\n}\n\n","import inquirer from 'inquirer';\nimport fs from 'fs';\nimport path from 'path';\n\n/**\n * Validates that a file exists at the given path\n * @param filePath Path to the file to validate\n * @param basePath Optional base path to resolve relative paths against (defaults to process.cwd())\n * @returns True if the file exists, throws an error if not\n * @throws Error if the file does not exist\n */\nexport function validateFileExists(\n filePath: string,\n basePath: string = process.cwd()\n): boolean {\n const resolvedPath = path.resolve(basePath, filePath);\n if (!fs.existsSync(resolvedPath)) {\n throw new Error(`File not found at ${resolvedPath}`);\n }\n return true;\n}\n\n/**\n * Prompts the user for a file path and validates that the file exists\n * @param message The prompt message to display\n * @param defaultValue The default value for the prompt\n * @param name The name of the prompt (used as property name in the returned object)\n * @param basePath Optional base path to resolve relative paths against (defaults to process.cwd())\n * @returns The validated file path\n */\nexport async function promptForFile(\n message: string,\n defaultValue: string,\n name: string = 'file',\n basePath: string = process.cwd()\n): Promise<string> {\n const response = await inquirer.prompt([\n {\n type: 'input',\n name,\n message,\n default: defaultValue,\n validate: (input) => {\n const filePath = path.resolve(basePath, input);\n if (!fs.existsSync(filePath)) {\n return `File not found at ${filePath}`;\n }\n return true;\n }\n }\n ]);\n\n return response[name];\n} ","import { Command } from 'commander';\nimport { DockerService } from '../../utils/docker';\nimport { getDockerCredentials } from '../../utils/credentials';\nimport { logger } from '../../utils/logger';\nimport path from 'path';\nimport inquirer from 'inquirer';\nimport fs from 'fs';\nimport { promptForFile } from '../../utils/prompts';\n\nexport const buildCommand = new Command()\n .name('build')\n .description('Build a Docker image')\n .option('-i, --image <image>', 'Image name')\n .option('-t, --tag <tag>', 'Image tag')\n .option('-f, --file <file>', 'Path to Dockerfile', 'Dockerfile')\n .action(async (options) => {\n try {\n // Get Docker credentials\n const credentials = await getDockerCredentials();\n \n if (!credentials) {\n logger.error('Docker credentials not found. Please login first with \"phala docker login\"');\n process.exit(1);\n }\n \n // Prompt for image name if not provided\n if (!options.image) {\n const response = await inquirer.prompt([\n {\n type: 'input',\n name: 'image',\n message: 'Enter the Docker image name:',\n validate: (input) => {\n if (!input.trim()) {\n return 'Image name is required';\n }\n return true;\n }\n }\n ]);\n \n options.image = response.image;\n }\n\n if (!options.tag) {\n const response = await inquirer.prompt([\n {\n type: 'input',\n name: 'tag',\n message: 'Enter the Docker image tag:',\n default: 'latest', // Add random hash later\n validate: (input) => {\n if (!input.trim()) {\n return 'Tag is required';\n }\n return true;\n }\n }\n ]);\n\n options.tag = response.tag;\n }\n\n // Prompt for Dockerfile path if the default doesn't exist\n const defaultPath = path.resolve(process.cwd(), options.file);\n if (!fs.existsSync(defaultPath)) {\n logger.info(`Default Dockerfile not found at ${defaultPath}`);\n \n options.file = await promptForFile(\n 'Enter the path to your Dockerfile:',\n 'Dockerfile',\n 'file'\n );\n }\n \n // Resolve the Dockerfile path\n const dockerfilePath = path.resolve(process.cwd(), options.file);\n \n // Build the image\n const dockerService = new DockerService(options.image, credentials.username, credentials.registry);\n const success = await dockerService.buildImage(dockerfilePath, options.tag);\n \n if (!success) {\n logger.error('Failed to build Docker image');\n process.exit(1);\n }\n \n logger.success(`Docker image ${credentials.username}/${options.image}:${options.tag} built successfully`);\n } catch (error) {\n logger.error(`Failed to build Docker image: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { DockerService } from '../../utils/docker';\nimport { getDockerCredentials } from '../../utils/credentials';\nimport { logger } from '../../utils/logger';\nimport inquirer from 'inquirer';\n\nexport const pushCommand = new Command()\n .name('push')\n .description('Push a Docker image to Docker Hub')\n .option('-i, --image <image>', 'Image name')\n .option('-t, --tag <tag>', 'Image tag')\n .action(async (options) => {\n try {\n // Get Docker credentials\n const credentials = await getDockerCredentials();\n \n if (!credentials) {\n logger.error('Docker credentials not found. Please login first with \"phala docker login\"');\n process.exit(1);\n }\n\n let imageName = options.image;\n let imageTag = options.tag;\n\n // If image or tag is not provided, list local images and prompt user to select\n if (!imageName || !imageTag) {\n const localImages = await DockerService.listLocalImages();\n \n if (localImages.length === 0) {\n logger.error('No local Docker images found. Please build an image first with \"phala docker build\"');\n process.exit(1);\n }\n\n // If no image specified, prompt to select from available images\n if (!imageName) {\n // Get unique image names\n const uniqueImageNames = Array.from(new Set(localImages.map(img => img.name)));\n \n const { selectedImage } = await inquirer.prompt([\n {\n type: 'list',\n name: 'selectedImage',\n message: 'Select an image to push:',\n choices: uniqueImageNames\n }\n ]);\n \n imageName = selectedImage;\n }\n \n // If no tag specified, prompt to select from available tags for the image\n if (!imageTag) {\n // Filter tags for the selected image\n const availableTags = localImages\n .filter(img => img.name === imageName)\n .map(img => img.tag);\n \n if (availableTags.length === 0) {\n logger.error(`No tags found for image ${imageName}`);\n process.exit(1);\n }\n \n const { selectedTag } = await inquirer.prompt([\n {\n type: 'list',\n name: 'selectedTag',\n message: `Select a tag for ${imageName}:`,\n choices: availableTags\n }\n ]);\n \n imageTag = selectedTag;\n }\n }\n \n // Push the image\n const dockerService = new DockerService(imageName, credentials.username, credentials.registry);\n const success = await dockerService.pushImage(imageTag);\n \n if (!success) {\n logger.error('Failed to push Docker image');\n process.exit(1);\n }\n \n logger.success(`Docker image ${credentials.username}/${imageName}:${imageTag} pushed successfully`);\n } catch (error) {\n logger.error(`Failed to push Docker image: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { DockerService } from '../../utils/docker';\nimport { getDockerCredentials } from '../../utils/credentials';\nimport { logger } from '../../utils/logger';\n\nexport const tagsCommand = new Command()\n .name('tags')\n .description('List tags for a Docker image')\n .requiredOption('-i, --image <image>', 'Image name')\n .option('-j, --json', 'Output in JSON format')\n .action(async (options) => {\n try {\n // Get Docker credentials\n const credentials = await getDockerCredentials();\n \n if (!credentials) {\n logger.error('Docker credentials not found. Please login first with \"teecloud docker login\"');\n process.exit(1);\n }\n \n // List tags\n const dockerService = new DockerService(options.image, credentials.username, credentials.registry);\n const tags = await dockerService.listTags();\n \n if (tags.length === 0) {\n logger.info(`No tags found for image ${credentials.username}/${options.image}`);\n return;\n }\n \n if (options.json) {\n console.log(JSON.stringify(tags, null, 2));\n return;\n }\n \n logger.info(`Tags for image ${credentials.username}/${options.image}:`);\n tags.forEach(tag => {\n logger.info(`- ${tag}`);\n });\n } catch (error) {\n logger.error(`Failed to list tags: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { DockerService } from '../../utils/docker';\nimport { logger } from '../../utils/logger';\nimport inquirer from 'inquirer';\nimport fs from 'fs';\nimport path from 'path';\nimport { validateFileExists } from '../../utils/prompts';\n\nexport const runCommand = new Command()\n .name('run')\n .description('Run a Docker Compose setup')\n .option('-c, --compose <compose>', 'Path to docker-compose.yml file')\n .option('-e, --env-file <env-file>', 'Path to environment variables file')\n .option('--skip-env', 'Skip environment variables file prompt', true)\n .action(async (options) => {\n try {\n let composePath = options.compose;\n let envFilePath = options.env;\n\n // If compose path is not provided, prompt the user\n if (!composePath) {\n // Check if docker-compose.yml exists in current directory\n const defaultComposePath = path.join(process.cwd(), 'docker-compose.yml');\n const hasDefaultCompose = fs.existsSync(defaultComposePath);\n\n if (hasDefaultCompose) {\n const { useDefault } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'useDefault',\n message: 'Use docker-compose.yml in current directory?',\n default: true\n }\n ]);\n\n if (useDefault) {\n composePath = defaultComposePath;\n }\n }\n\n // If still no compose path, prompt for it\n if (!composePath) {\n const { composePath: inputPath } = await inquirer.prompt([\n {\n type: 'input',\n name: 'composePath',\n message: 'Enter path to docker-compose.yml file:',\n validate: (input) => {\n if (validateFileExists(input)) {\n return true;\n }\n return 'File not found';\n }\n }\n ]);\n composePath = inputPath;\n }\n } else {\n // Validate the provided compose path\n try {\n validateFileExists(composePath);\n } catch (error) {\n logger.error(`File not found: ${composePath}`);\n process.exit(1);\n }\n }\n\n // If env file path is not provided, prompt the user\n if (!envFilePath && !options.skipEnv) {\n // Check if .env exists in current directory\n const defaultEnvPath = path.join(process.cwd(), '.env');\n const hasDefaultEnv = fs.existsSync(defaultEnvPath);\n\n if (hasDefaultEnv) {\n const { useDefault } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'useDefault',\n message: 'Use .env file in current directory?',\n default: true\n }\n ]);\n\n if (useDefault) {\n envFilePath = defaultEnvPath;\n }\n }\n\n // If still no env file path, prompt for it\n if (!envFilePath) {\n const { envPath } = await inquirer.prompt([\n {\n type: 'input',\n name: 'envPath',\n message: 'Enter path to environment variables file:',\n validate: (input) => {\n try {\n validateFileExists(input);\n return true;\n } catch (error) {\n return `File not found: ${input}`;\n }\n }\n }\n ]);\n envFilePath = envPath;\n }\n }\n\n // Create a DockerService instance (empty image name as we're just using it for compose)\n const dockerService = new DockerService('');\n \n // Run the compose setup\n if (envFilePath) {\n try {\n validateFileExists(envFilePath);\n } catch (error) {\n logger.error(`File not found: ${envFilePath}`);\n process.exit(1);\n }\n logger.info(`Running Docker Compose with compose file: ${composePath} and env file: ${envFilePath}`);\n } else {\n logger.info(`Running Docker Compose with compose file: ${composePath} without env file`);\n }\n const success = await dockerService.runComposeLocally(composePath, envFilePath);\n \n if (!success) {\n logger.error('Failed to run Docker Compose');\n process.exit(1);\n }\n \n logger.success('Docker Compose is running');\n } catch (error) {\n logger.error(`Failed to run Docker Compose: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { DockerService } from '../../utils/docker';\nimport { getDockerCredentials } from '../../utils/credentials';\nimport { logger } from '../../utils/logger';\nimport inquirer from 'inquirer';\nimport fs from 'fs';\nimport path from 'path';\nimport { validateFileExists } from '../../utils/prompts';\n\nexport const generateCommand = new Command()\n .name('generate')\n .description('Generate a Docker Compose file')\n .option('-i, --image <image>', 'Docker image name to use in the compose file')\n .option('-t, --tag <tag>', 'Docker image tag to use in the compose file')\n .option('-e, --env-file <envFile>', 'Path to environment variables file')\n .option('-o, --output <output>', 'Output path for generated docker-compose.yml')\n .option('--template <template>', 'Template to use for the generated docker-compose.yml', )\n .option('--manual', 'Skip automatic image detection and enter image/tag manually')\n .action(async (options) => {\n try {\n // Get Docker credentials to create the Docker service\n const credentials = await getDockerCredentials();\n if (!credentials || !credentials.username) {\n logger.error('Docker Hub username not found. Please login first with `tcc docker login`');\n process.exit(1);\n }\n\n // Variables to hold selected image and tag\n let selectedImage = options.image || '';\n let selectedTag = options.tag || '';\n \n // If image or tag not provided and manual mode not specified, detect and offer local images\n if ((!selectedImage || !selectedTag) && !options.manual) {\n try {\n logger.info('Detecting local Docker images...');\n const localImages = await DockerService.listLocalImages();\n \n if (localImages.length === 0) {\n logger.warn('No local Docker images found. You will need to enter image details manually.');\n } else {\n // Group images by name\n const imageMap = new Map<string, string[]>();\n \n localImages.forEach(image => {\n if (!imageMap.has(image.name)) {\n imageMap.set(image.name, []);\n }\n imageMap.get(image.name)?.push(image.tag);\n });\n \n // If image is already specified, but tag isn't, just select tag for the image\n if (selectedImage && !selectedTag) {\n const availableTags = imageMap.get(selectedImage) || [];\n if (availableTags.length > 0) {\n // Ask user to select a tag\n const { imageTag } = await inquirer.prompt([\n {\n type: 'list',\n name: 'imageTag',\n message: `Select a tag for ${selectedImage}:`,\n choices: [...availableTags, new inquirer.Separator(), '[ Enter manually ]']\n }\n ]);\n \n if (imageTag !== '[ Enter manually ]') {\n selectedTag = imageTag;\n }\n } else {\n logger.warn(`No tags found for image ${selectedImage}. You will need to enter the tag manually.`);\n }\n } \n // If image is not specified, ask for both image and tag\n else if (!selectedImage) {\n // Ask user to select an image name\n const imageNames = Array.from(imageMap.keys());\n const { imageName } = await inquirer.prompt([\n {\n type: 'list',\n name: 'imageName',\n message: 'Select a Docker image:',\n choices: [...imageNames, new inquirer.Separator(), '[ Enter manually ]']\n }\n ]);\n \n if (imageName === '[ Enter manually ]') {\n // User chose to enter manually, go to manual input flow\n } else {\n selectedImage = imageName;\n \n // Get available tags for selected image\n const availableTags = imageMap.get(imageName) || [];\n \n // Ask user to select a tag\n const { imageTag } = await inquirer.prompt([\n {\n type: 'list',\n name: 'imageTag',\n message: 'Select a tag:',\n choices: [...availableTags, new inquirer.Separator(), '[ Enter manually ]']\n }\n ]);\n \n if (imageTag !== '[ Enter manually ]') {\n selectedTag = imageTag;\n }\n }\n }\n }\n } catch (error) {\n logger.warn(`Failed to detect local images: ${error instanceof Error ? error.message : String(error)}`);\n logger.info('Continuing with manual input...');\n }\n }\n \n // If image still not set, prompt for it\n if (!selectedImage) {\n const { inputImage } = await inquirer.prompt([\n {\n type: 'input',\n name: 'inputImage',\n message: 'Enter Docker image name:',\n validate: (input) => {\n if (!input.trim()) {\n return 'Image name cannot be empty';\n }\n return true;\n }\n }\n ]);\n selectedImage = inputImage;\n }\n \n // If tag still not set, prompt for it\n if (!selectedTag) {\n const { inputTag } = await inquirer.prompt([\n {\n type: 'input',\n name: 'inputTag',\n message: `Enter tag for image ${selectedImage}:`,\n validate: (input) => {\n if (!input.trim()) {\n return 'Tag cannot be empty';\n }\n return true;\n }\n }\n ]);\n selectedTag = inputTag;\n }\n\n // Get environment file path from options or prompt\n let envFilePath = options.envFile;\n if (!envFilePath) {\n // Check if .env exists in current directory\n const defaultEnvPath = path.join(process.cwd(), '.env');\n const hasDefaultEnv = fs.existsSync(defaultEnvPath);\n\n if (hasDefaultEnv) {\n const { useDefault } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'useDefault',\n message: 'Use .env file in current directory?',\n default: true\n }\n ]);\n\n if (useDefault) {\n envFilePath = defaultEnvPath;\n }\n }\n\n // If still no env file path, prompt for it\n if (!envFilePath) {\n const { envPath } = await inquirer.prompt([\n {\n type: 'input',\n name: 'envPath',\n message: 'Enter path to environment variables file:',\n validate: (input) => {\n try {\n validateFileExists(input);\n return true;\n } catch (error) {\n return `File not found: ${input}`;\n }\n }\n }\n ]);\n envFilePath = envPath;\n }\n } else {\n // Validate the provided env file path\n try {\n validateFileExists(envFilePath);\n } catch (error) {\n logger.error(`File not found: ${envFilePath}`);\n process.exit(1);\n }\n }\n\n // Get output path from options or set default\n let outputPath = options.output;\n if (!outputPath) {\n outputPath = path.join(process.cwd(), 'docker-compose.yml');\n \n // If file already exists, confirm overwrite\n if (fs.existsSync(outputPath)) {\n const { confirmOverwrite } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'confirmOverwrite',\n message: `File ${outputPath} already exists. Overwrite?`,\n default: false\n }\n ]);\n if (!confirmOverwrite) {\n const { customPath } = await inquirer.prompt([\n {\n type: 'input',\n name: 'customPath',\n message: 'Enter alternative output path:',\n default: path.join(process.cwd(), `${selectedImage}-${selectedTag}-compose.yml`)\n }\n ]);\n outputPath = customPath;\n }\n }\n }\n \n // Create a DockerService instance\n const dockerService = new DockerService(selectedImage, credentials.username, credentials.registry);\n\n // Generate the Docker Compose file\n if (envFilePath) {\n logger.info(`Generating Docker Compose file for ${selectedImage}:${selectedTag} using env file: ${envFilePath}`);\n } else {\n logger.info(`Generating Docker Compose file for ${selectedImage}:${selectedTag} without env file`);\n }\n const composePath = await dockerService.buildComposeFile(selectedTag, envFilePath, options.template);\n \n // Copy the generated file to the output path if needed\n if (composePath !== outputPath) {\n // Ensure the output directory exists\n const outputDir = path.dirname(outputPath);\n if (!fs.existsSync(outputDir)) {\n logger.info(`Creating directory: ${outputDir}`);\n fs.mkdirSync(outputDir, { recursive: true });\n }\n \n fs.copyFileSync(composePath, outputPath);\n }\n \n logger.success(`Docker Compose file generated successfully: ${outputPath}`);\n } catch (error) {\n logger.error(`Failed to generate Docker Compose file: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { startCommand } from './start';\nimport { stopCommand } from './stop';\n\nexport const simulatorCommands = new Command()\n .name('simulator')\n .description('TEE simulator commands')\n .addCommand(startCommand)\n .addCommand(stopCommand);\n","import { Command } from 'commander';\nimport { DockerService } from '../../utils/docker';\nimport { logger } from '../../utils/logger';\nimport { TEE_SIMULATOR } from '../../utils/constants';\n\nexport const startCommand = new Command()\n .name('start')\n .description('Start the TEE simulator')\n .option('-i, --image <image>', 'Simulator image', TEE_SIMULATOR)\n .action(async (options) => {\n try {\n // Start the simulator\n const dockerService = new DockerService('');\n const success = await dockerService.runSimulator(options.image);\n \n if (!success) {\n logger.error('Failed to start TEE simulator');\n process.exit(1);\n }\n } catch (error) {\n logger.error(`Failed to start TEE simulator: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { DockerService } from '../../utils/docker';\nimport { logger } from '../../utils/logger';\n\nexport const stopCommand = new Command()\n .name('stop')\n .description('Stop the TEE simulator')\n .action(async () => {\n try {\n // Stop the simulator\n const dockerService = new DockerService('');\n const success = await dockerService.stopSimulator();\n \n if (!success) {\n logger.error('Failed to stop TEE simulator');\n process.exit(1);\n }\n } catch (error) {\n logger.error(`Failed to stop TEE simulator: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { getCommand } from './get';\nimport { setCommand } from './set';\nimport { listCommand } from './list';\n\nexport const configCommands = new Command()\n .name('config')\n .description('Manage your local configuration')\n .addCommand(getCommand)\n .addCommand(setCommand)\n .addCommand(listCommand);\n","import { Command } from 'commander';\nimport { getConfigValue } from '@/src/utils/config';\nimport { logger } from '@/src/utils/logger';\n\nexport const getCommand = new Command()\n .name('get')\n .description('Get a configuration value')\n .argument('<key>', 'Configuration key')\n .action((key) => {\n try {\n const value = getConfigValue(key);\n \n if (value === undefined) {\n logger.error(`Configuration key '${key}' not found`);\n process.exit(1);\n }\n \n logger.info(`${key}: ${JSON.stringify(value)}`);\n } catch (error) {\n logger.error(`Failed to get configuration value: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import fs from 'fs';\nimport path from 'path';\nimport os from 'os';\nimport { logger } from './logger';\n\n// Define the directory and file for storing configuration\nconst PHALA_CLOUD_DIR = path.join(os.homedir(), '.phala-cloud');\nconst CONFIG_FILE = path.join(PHALA_CLOUD_DIR, 'config.json');\n\n// Default configuration\nconst DEFAULT_CONFIG = {\n apiUrl: 'https://cloud-api.phala.network',\n cloudUrl: 'https://cloud.phala.network',\n defaultTeepodId: 3,\n defaultImage: 'dstack-dev-0.3.5',\n defaultVcpu: 1,\n defaultMemory: 2048,\n defaultDiskSize: 20,\n};\n\n// Ensure the .phala-cloud directory exists\nfunction ensureDirectoryExists(): void {\n if (!fs.existsSync(PHALA_CLOUD_DIR)) {\n try {\n fs.mkdirSync(PHALA_CLOUD_DIR, { recursive: true });\n } catch (error) {\n logger.error(`Failed to create directory ${PHALA_CLOUD_DIR}:`, error);\n throw error;\n }\n }\n}\n\n// Load configuration\nexport function loadConfig(): Record<string, any> {\n try {\n if (fs.existsSync(CONFIG_FILE)) {\n const configData = fs.readFileSync(CONFIG_FILE, 'utf8');\n return { ...DEFAULT_CONFIG, ...JSON.parse(configData) };\n }\n return DEFAULT_CONFIG;\n } catch (error) {\n logger.error('Failed to load configuration:', error);\n return DEFAULT_CONFIG;\n }\n}\n\n// Save configuration\nexport function saveConfig(config: Record<string, any>): void {\n ensureDirectoryExists();\n try {\n fs.writeFileSync(\n CONFIG_FILE,\n JSON.stringify({ ...loadConfig(), ...config }, null, 2),\n { mode: 0o600 } // Restrict permissions to user only\n );\n logger.success('Configuration saved successfully.');\n } catch (error) {\n logger.error('Failed to save configuration:', error);\n throw error;\n }\n}\n\n// Get a configuration value\nexport function getConfigValue(key: string): any {\n const config = loadConfig();\n return config[key];\n}\n\n// Set a configuration value\nexport function setConfigValue(key: string, value: any): void {\n const config = loadConfig();\n config[key] = value;\n saveConfig(config);\n}\n\n// List all configuration values\nexport function listConfigValues(): Record<string, any> {\n return loadConfig();\n} ","import { Command } from 'commander';\nimport { setConfigValue } from '@/src/utils/config';\nimport { logger } from '@/src/utils/logger';\n\nexport const setCommand = new Command()\n .name('set')\n .description('Set a configuration value')\n .argument('<key>', 'Configuration key')\n .argument('<value>', 'Configuration value')\n .action((key, value) => {\n try {\n // Try to parse the value as JSON if it looks like a JSON value\n let parsedValue = value;\n if (value.startsWith('{') || value.startsWith('[') || \n value === 'true' || value === 'false' || \n !isNaN(Number(value))) {\n try {\n parsedValue = JSON.parse(value);\n } catch (e) {\n // If parsing fails, use the original string value\n }\n }\n \n setConfigValue(key, parsedValue);\n logger.success(`Configuration value for '${key}' set successfully`);\n } catch (error) {\n logger.error(`Failed to set configuration value: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { listConfigValues } from '@/src/utils/config';\nimport { logger } from '@/src/utils/logger';\n\nexport const listCommand = new Command()\n .name('list')\n .description('List all configuration values')\n .option('-j, --json', 'Output in JSON format')\n .action((options) => {\n try {\n const config = listConfigValues();\n \n if (options.json) {\n console.log(JSON.stringify(config, null, 2));\n return;\n }\n \n logger.info('Configuration values:');\n for (const [key, value] of Object.entries(config)) {\n logger.info(`${key}: ${JSON.stringify(value)}`);\n }\n } catch (error) {\n logger.error(`Failed to list configuration values: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { listCommand } from './list';\nimport { getCommand } from './get';\nimport { startCommand } from './start';\nimport { stopCommand } from './stop';\nimport { restartCommand } from './restart';\nimport { attestationCommand } from './attestation';\nimport { createCommand } from './create';\nimport { deleteCommand } from './delete';\nimport { upgradeCommand } from './upgrade';\nimport { resizeCommand } from './resize';\n\nexport const cvmsCommand = new Command()\n .name('cvms')\n .description('Manage Phala Confidential Virtual Machines (CVMs)')\n .addCommand(listCommand)\n .addCommand(getCommand)\n .addCommand(createCommand)\n .addCommand(upgradeCommand)\n .addCommand(startCommand)\n .addCommand(stopCommand)\n .addCommand(restartCommand)\n .addCommand(attestationCommand)\n .addCommand(deleteCommand)\n .addCommand(resizeCommand); ","import { Command } from 'commander';\nimport { getCvms } from '@/src/api/cvms';\nimport { logger } from '@/src/utils/logger';\nimport { CLOUD_URL } from '@/src/utils/constants';\n\nexport const listCommand = new Command()\n .name('list')\n .description('List all CVMs')\n .option('-j, --json', 'Output in JSON format')\n .action(async (options) => {\n try {\n const spinner = logger.startSpinner('Fetching CVMs');\n \n const cvms = await getCvms();\n \n spinner.stop(true);\n \n if (!cvms || cvms.length === 0) {\n logger.info('No CVMs found');\n return;\n }\n \n if (options.json) {\n console.log(JSON.stringify(cvms, null, 2));\n return;\n }\n \n cvms.forEach((cvm) => {\n logger.keyValueTable({\n 'App ID': cvm.hosted.app_id,\n 'Name': cvm.name,\n 'Status': cvm.status,\n 'Node Info URL': cvm.hosted.app_url,\n 'App URL': `${CLOUD_URL}/dashboard/cvms/app_${cvm.hosted.app_id}`\n });\n });\n logger.success(`Found ${cvms.length} CVMs:`);\n } catch (error) {\n logger.error(`Failed to list CVMs: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { apiClient } from './client';\nimport { API_ENDPOINTS } from '../utils/constants';\nimport {\n CvmInstance,\n GetCvmByAppIdResponse,\n GetPubkeyFromCvmResponse,\n CreateCvmResponse,\n UpgradeCvmResponse,\n cvmInstanceSchema,\n getCvmByAppIdResponseSchema,\n getPubkeyFromCvmResponseSchema,\n createCvmResponseSchema,\n upgradeCvmResponseSchema\n} from './types';\nimport { z } from 'zod';\n\n/**\n * Get all CVMs for the current user\n * @returns List of CVMs\n */\nexport async function getCvms(): Promise<CvmInstance[]> {\n try {\n const response = await apiClient.get<CvmInstance[]>(API_ENDPOINTS.CVMS(0));\n return z.array(cvmInstanceSchema).parse(response);\n } catch (error) {\n throw new Error(`Failed to get CVMs: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Get a CVM by App ID\n * @param appId App ID\n * @returns CVM details\n */\nexport async function getCvmByAppId(appId: string): Promise<GetCvmByAppIdResponse> {\n try {\n const response = await apiClient.get<GetCvmByAppIdResponse>(API_ENDPOINTS.CVM_BY_APP_ID(appId));\n return getCvmByAppIdResponseSchema.parse(response);\n } catch (error) {\n throw new Error(`Failed to get CVM by App ID: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Get public key from CVM\n * @param vmConfig VM configuration\n * @returns Public key\n */\nexport async function getPubkeyFromCvm(vmConfig: any): Promise<GetPubkeyFromCvmResponse> {\n try {\n const response = await apiClient.post<GetPubkeyFromCvmResponse>(API_ENDPOINTS.CVM_PUBKEY, vmConfig);\n return getPubkeyFromCvmResponseSchema.parse(response);\n } catch (error) {\n throw new Error(`Failed to get pubkey from CVM: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Create a new CVM\n * @param vmConfig VM configuration\n * @returns Created CVM details\n */\nexport async function createCvm(vmConfig: any): Promise<CreateCvmResponse> {\n try {\n const response = await apiClient.post<CreateCvmResponse>(API_ENDPOINTS.CVM_FROM_CONFIGURATION, vmConfig);\n return createCvmResponseSchema.parse(response);\n } catch (error) {\n if (error instanceof z.ZodError) {\n console.error('Schema validation error:', JSON.stringify(error.errors, null, 2));\n console.error('API response:', JSON.stringify(error.format(), null, 2));\n throw new Error(`Response validation failed: ${JSON.stringify(error.errors)}`);\n }\n throw new Error(`Failed to create CVM: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Start a CVM\n * @param appId App ID\n * @returns Success status\n */\nexport async function startCvm(appId: string): Promise<boolean> {\n try {\n await apiClient.post(API_ENDPOINTS.CVM_START(appId));\n return true;\n } catch (error) {\n throw new Error(`Failed to start CVM: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Stop a CVM\n * @param appId App ID\n * @returns Success status\n */\nexport async function stopCvm(appId: string): Promise<boolean> {\n try {\n await apiClient.post(API_ENDPOINTS.CVM_STOP(appId));\n return true;\n } catch (error) {\n throw new Error(`Failed to stop CVM: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Restart a CVM\n * @param appId App ID\n * @returns Success status\n */\nexport async function restartCvm(appId: string): Promise<boolean> {\n try {\n await apiClient.post(API_ENDPOINTS.CVM_RESTART(appId));\n return true;\n } catch (error) {\n throw new Error(`Failed to restart CVM: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Upgrade a CVM\n * @param appId App ID\n * @param vmConfig VM configuration\n * @returns Upgrade response\n */\nexport async function upgradeCvm(appId: string, vmConfig: any): Promise<UpgradeCvmResponse> {\n try {\n const response = await apiClient.put<UpgradeCvmResponse>(API_ENDPOINTS.CVM_UPGRADE(appId), vmConfig);\n return upgradeCvmResponseSchema.parse(response);\n } catch (error) {\n throw new Error(`Failed to upgrade CVM: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Delete a CVM\n * @param appId App ID\n * @returns Success status\n */\nexport async function deleteCvm(appId: string): Promise<boolean> {\n try {\n await apiClient.delete(API_ENDPOINTS.CVM_BY_APP_ID(appId));\n return true;\n } catch (error) {\n throw new Error(`Failed to delete CVM: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Update a CVM\n * @param updatePayload Update payload\n * @returns Updated CVM details\n */\nexport async function updateCvm(updatePayload: any): Promise<any> {\n try {\n const response = await apiClient.put(API_ENDPOINTS.CVM_BY_APP_ID(updatePayload.app_id), updatePayload);\n return response;\n } catch (error) {\n throw new Error(`Failed to update CVM: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Presents a list of CVMs to the user and allows them to select one\n * @returns The selected CVM app ID or undefined if no CVMs exist\n */\nexport async function selectCvm(): Promise<string | undefined> {\n const { logger } = await import('../utils/logger');\n const inquirer = (await import('inquirer')).default;\n \n const listSpinner = logger.startSpinner('Fetching available CVMs');\n const cvms = await getCvms();\n listSpinner.stop(true);\n \n if (!cvms || cvms.length === 0) {\n logger.info('No CVMs found for your account');\n return undefined;\n }\n \n // Prepare choices for the inquirer prompt\n const choices = cvms.map(cvm => {\n // Handle different API response formats\n const id = cvm.hosted?.app_id || cvm.hosted?.id;\n const name = cvm.name || (cvm.hosted && cvm.hosted.name);\n const status = cvm.status || (cvm.hosted && cvm.hosted.status);\n \n return {\n name: `${name || 'Unnamed'} (${id}) - Status: ${status || 'Unknown'}`,\n value: id\n };\n });\n \n const { selectedCvm } = await inquirer.prompt([\n {\n type: 'list',\n name: 'selectedCvm',\n message: 'Select a CVM:',\n choices\n }\n ]);\n \n return selectedCvm;\n}\n\n/**\n * Get attestation information for a CVM\n * @param appId App ID\n * @returns Attestation information\n */\nexport async function getCvmAttestation(appId: string): Promise<any> {\n try {\n const response = await apiClient.get(API_ENDPOINTS.CVM_ATTESTATION(appId));\n return response;\n } catch (error) {\n throw new Error(`Failed to get attestation information: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\n/**\n * Resize a CVM's resources\n * @param appId App ID\n * @param vcpu Number of virtual CPUs (optional)\n * @param memory Memory size in MB (optional)\n * @param diskSize Disk size in GB (optional)\n * @param allowRestart Whether to allow restart (1) or not (0) for the resize operation (optional)\n * @returns Success status\n */\nexport async function resizeCvm(\n appId: string, \n vcpu?: number, \n memory?: number, \n diskSize?: number, \n allowRestart?: number\n): Promise<boolean> {\n try {\n // Only include defined parameters in the payload\n const resizePayload: Record<string, any> = {};\n \n if (vcpu !== undefined) resizePayload.vcpu = vcpu;\n if (memory !== undefined) resizePayload.memory = memory;\n if (diskSize !== undefined) resizePayload.disk_size = diskSize;\n if (allowRestart !== undefined) resizePayload.allow_restart = allowRestart;\n \n // Check if any parameters were provided\n if (Object.keys(resizePayload).length === 0) {\n throw new Error('At least one resource parameter must be provided');\n }\n \n await apiClient.patch(API_ENDPOINTS.CVM_RESIZE(appId), resizePayload);\n return true;\n } catch (error) {\n throw new Error(`Failed to resize CVM: ${error instanceof Error ? error.message : String(error)}`);\n }\n} ","import { Command } from 'commander';\nimport { getCvmByAppId, getCvms, selectCvm } from '@/src/api/cvms';\nimport { logger } from '@/src/utils/logger';\nimport { CLOUD_URL } from '@/src/utils/constants';\n\nexport const getCommand = new Command()\n .name('get')\n .description('Get details of a CVM')\n .option('-i, --id <app-id>', 'App ID of the CVM (optional)')\n .option('-j, --json', 'Output in JSON format')\n .action(async (options) => {\n try {\n let appId = options.id;\n \n // If no app ID is provided, fetch all CVMs and let the user select one\n if (!appId) {\n appId = await selectCvm();\n if (!appId) {\n return; // No CVMs found or user canceled\n }\n }\n \n const spinner = logger.startSpinner(`Fetching CVM with App ID ${appId}`);\n \n const cvm = await getCvmByAppId(appId);\n \n spinner.stop(true);\n \n if (!cvm) {\n logger.error(`CVM with App ID ${appId} not found`);\n process.exit(1);\n }\n \n if (options.json) {\n console.log(JSON.stringify(cvm, null, 2));\n return;\n }\n \n // Display additional details if available\n logger.keyValueTable({\n 'Name': cvm.name,\n 'Status': cvm.status,\n 'vCPU': cvm.vcpu,\n 'Memory': `${cvm.memory} MB`,\n 'Disk Size': `${cvm.disk_size} GB`,\n 'Dstack Image': cvm.base_image,\n 'TEEPod ID': cvm.teepod_id,\n 'App URL': `${CLOUD_URL}/dashboard/cvms/app_${cvm.app_id}`\n });\n } catch (error) {\n logger.error(`Failed to get CVM details: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { startCvm, selectCvm } from '@/src/api/cvms';\nimport { logger } from '@/src/utils/logger';\n\nexport const startCommand = new Command()\n .name('start')\n .description('Start a stopped CVM')\n .argument('[app-id]', 'App ID of the CVM (if not provided, a selection prompt will appear)')\n .action(async (appId) => {\n try {\n // If no app ID is provided, prompt user to select one\n if (!appId) {\n appId = await selectCvm();\n if (!appId) {\n return; // No CVMs found or user canceled\n }\n }\n \n const spinner = logger.startSpinner(`Starting CVM with App ID ${appId}`);\n \n await startCvm(appId);\n \n spinner.stop(true);\n logger.success(`CVM with App ID ${appId} started successfully`);\n } catch (error) {\n logger.error(`Failed to start CVM: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { stopCvm, selectCvm } from '@/src/api/cvms';\nimport { logger } from '@/src/utils/logger';\n\nexport const stopCommand = new Command()\n .name('stop')\n .description('Stop a running CVM')\n .argument('[app-id]', 'App ID of the CVM (if not provided, a selection prompt will appear)')\n .action(async (appId) => {\n try {\n // If no app ID is provided, prompt user to select one\n if (!appId) {\n appId = await selectCvm();\n if (!appId) {\n return; // No CVMs found or user canceled\n }\n }\n \n const spinner = logger.startSpinner(`Stopping CVM with App ID ${appId}`);\n \n await stopCvm(appId);\n \n spinner.stop(true);\n logger.success(`CVM with App ID ${appId} stopped successfully`);\n } catch (error) {\n logger.error(`Failed to stop CVM: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { restartCvm, selectCvm } from '@/src/api/cvms';\nimport { logger } from '@/src/utils/logger';\n\nexport const restartCommand = new Command()\n .name('restart')\n .description('Restart a CVM')\n .argument('[app-id]', 'App ID of the CVM (if not provided, a selection prompt will appear)')\n .action(async (appId) => {\n try {\n // If no app ID is provided, prompt user to select one\n if (!appId) {\n appId = await selectCvm();\n if (!appId) {\n return; // No CVMs found or user canceled\n }\n }\n \n const spinner = logger.startSpinner(`Restarting CVM with App ID ${appId}`);\n \n await restartCvm(appId);\n \n spinner.stop(true);\n logger.success(`CVM with App ID ${appId} restarted successfully`);\n } catch (error) {\n logger.error(`Failed to restart CVM: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { getCvmAttestation, selectCvm } from '@/src/api/cvms';\nimport { logger } from '@/src/utils/logger';\nimport chalk from 'chalk';\n\nexport const attestationCommand = new Command()\n .name('attestation')\n .description('Get attestation information for a CVM')\n .argument('[app-id]', 'CVM app ID (will prompt for selection if not provided)')\n .option('-j, --json', 'Output in JSON format')\n .action(async (appId?: string, options?: { json?: boolean }) => {\n try {\n if (!appId) {\n logger.info('No CVM specified, fetching available CVMs...');\n const selectedCvm = await selectCvm();\n if (!selectedCvm) {\n return;\n }\n appId = selectedCvm;\n }\n\n logger.info(`Fetching attestation information for CVM ${appId}...`);\n const spinner = logger.startSpinner('Fetching attestation information');\n\n try {\n const attestationData = await getCvmAttestation(appId);\n spinner.stop(true);\n\n if (!attestationData || Object.keys(attestationData).length === 0) {\n logger.info('No attestation information found');\n return;\n }\n\n // If JSON output is requested, just print the raw response\n if (options?.json) {\n console.log(JSON.stringify(attestationData, null, 2));\n return;\n }\n\n // Display the attestation summary\n logger.success('Attestation Summary:');\n const summaryData = {\n 'Status': attestationData.is_online ? chalk.green('Online') : chalk.red('Offline'),\n 'Public Access': attestationData.is_public ? chalk.green('Enabled') : chalk.yellow('Disabled'),\n 'Error': attestationData.error || 'None',\n 'Certificates': `${attestationData.app_certificates?.length || 0} found`\n };\n \n logger.keyValueTable(summaryData, {\n borderStyle: 'rounded'\n });\n\n // Display certificate information\n if (attestationData.app_certificates && attestationData.app_certificates.length > 0) {\n \n attestationData.app_certificates.forEach((cert, index) => {\n logger.success(`Certificate #${index + 1} (${cert.position_in_chain === 0 ? 'End Entity' : 'CA'}):`);\n \n const certData = {\n 'Subject': `${cert.subject.common_name || 'Unknown'}${cert.subject.organization ? ` (${cert.subject.organization})` : ''}`,\n 'Issuer': `${cert.issuer.common_name || 'Unknown'}${cert.issuer.organization ? ` (${cert.issuer.organization})` : ''}`,\n 'Serial Number': cert.serial_number,\n 'Validity': `${new Date(cert.not_before).toLocaleString()} to ${new Date(cert.not_after).toLocaleString()}`,\n 'Fingerprint': cert.fingerprint,\n 'Signature Algorithm': cert.signature_algorithm,\n 'Is CA': cert.is_ca ? 'Yes' : 'No',\n 'Position in Chain': cert.position_in_chain\n };\n \n logger.keyValueTable(certData, {\n borderStyle: 'single'\n });\n \n // Skip displaying the quote as it's very large and mostly binary data\n });\n }\n\n // Display TCB info if available\n if (attestationData.tcb_info) {\n logger.success('Trusted Computing Base (TCB) Information:');\n \n logger.keyValueTable(attestationData.tcb_info, {\n borderStyle: 'single'\n });\n }\n } catch (error) {\n spinner.stop(true);\n throw error;\n }\n } catch (error) {\n logger.error(`Failed to get attestation information: ${error instanceof Error ? error.message : String(error)}`);\n }\n });\n","import { Command } from 'commander';\nimport { createCvm, getPubkeyFromCvm } from '@/src/api/cvms';\nimport { getTeepodImages, getTeepods } from '@/src/api/teepods';\nimport { logger } from '@/src/utils/logger';\nimport { DEFAULT_VCPU, DEFAULT_MEMORY, DEFAULT_DISK_SIZE, CLOUD_URL } from '@/src/utils/constants';\nimport { encryptEnvVars, type EnvVar } from '@phala/dstack-sdk/encrypt-env-vars';\n\nimport fs from 'fs';\nimport path from 'path';\nimport inquirer from 'inquirer';\nimport { parseEnv } from '@/src/utils/secrets';\nimport { promptForFile } from '@/src/utils/prompts';\n\nexport const createCommand = new Command()\n .name('create')\n .description('Create a new CVM')\n .option('-n, --name <name>', 'Name of the CVM')\n .option('-c, --compose <compose>', 'Path to Docker Compose file')\n .option('--vcpu <vcpu>', 'Number of vCPUs', String(DEFAULT_VCPU))\n .option('--memory <memory>', 'Memory in MB', String(DEFAULT_MEMORY))\n .option('--disk-size <diskSize>', 'Disk size in GB', String(DEFAULT_DISK_SIZE))\n .option('--teepod-id <teepodId>', 'TEEPod ID to use')\n .option('--image <image>', 'Version of dstack image to use')\n .option('-e, --env-file <envFile>', 'Path to environment file')\n .option('--skip-env', 'Skip environment variable prompt', false)\n .option('--debug', 'Enable debug mode', false)\n .action(async (options) => {\n try {\n // Prompt for required options if not provided\n if (!options.name) {\n const { name } = await inquirer.prompt([\n {\n type: 'input',\n name: 'name',\n message: 'Enter a name for the CVM:',\n validate: (input) => {\n if (!input.trim()) {\n return 'CVM name is required';\n }\n return true;\n }\n }\n ]);\n options.name = name;\n }\n\n // Get examples directories\n const examplesDir = path.join(process.cwd(), 'examples');\n const examples = [];\n\n if (fs.existsSync(examplesDir)) {\n const exampleDirs = fs.readdirSync(examplesDir, { withFileTypes: true })\n .filter(dirent => dirent.isDirectory() && !dirent.name.startsWith('.'))\n .map(dirent => dirent.name);\n\n examples.push(...exampleDirs);\n }\n\n // Validate and read the Docker Compose file\n let composeString = '';\n try {\n // If compose path not provided, prompt with examples\n if (!options.compose) {\n if (examples.length > 0) {\n // Prepare choices for the inquirer prompt\n const choices = [\n ...examples.map((example, index) => ({\n name: example,\n value: { type: 'example', name: example }\n })),\n new inquirer.Separator(),\n { name: 'Enter a file path', value: { type: 'custom' } }\n ];\n\n const { selection } = await inquirer.prompt([\n {\n type: 'list',\n name: 'selection',\n message: 'Choose a Docker Compose example or enter a custom path:',\n choices\n }\n ]);\n\n if (selection.type === 'example') {\n // User selected an example\n const exampleDir = path.join(examplesDir, selection.name);\n const possibleFiles = ['docker-compose.yml', 'docker-compose.yaml'];\n\n let foundCompose = false;\n for (const file of possibleFiles) {\n const composePath = path.join(exampleDir, file);\n if (fs.existsSync(composePath)) {\n options.compose = composePath;\n foundCompose = true;\n logger.info(`Using example: ${selection.name} (${options.compose})`);\n break;\n }\n }\n\n if (!foundCompose) {\n logger.error(`Could not find docker-compose.yml or docker-compose.yaml in ${exampleDir}`);\n process.exit(1);\n }\n } else {\n // User chose to enter a custom path\n const { customPath } = await inquirer.prompt([\n {\n type: 'input',\n name: 'customPath',\n message: 'Enter the path to your Docker Compose file:',\n validate: (input) => {\n if (!input.trim()) {\n return 'Docker Compose file path is required';\n }\n return true;\n }\n }\n ]);\n\n options.compose = customPath;\n }\n } else {\n // No examples available, just ask for the path\n const { customPath } = await inquirer.prompt([\n {\n type: 'input',\n name: 'customPath',\n message: 'Enter the path to your Docker Compose file:',\n validate: (input) => {\n if (!input.trim()) {\n return 'Docker Compose file path is required';\n }\n return true;\n }\n }\n ]);\n\n options.compose = customPath;\n }\n }\n\n const composePath = path.resolve(options.compose);\n if (!fs.existsSync(composePath)) {\n logger.error(`Docker Compose file not found: ${composePath}`);\n process.exit(1);\n }\n composeString = fs.readFileSync(composePath, 'utf8');\n } catch (error) {\n logger.error(`Failed to read Docker Compose file: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n\n // Process environment variables\n let envs: EnvVar[] = [];\n\n // Process environment variables from file\n if (options.envFile) {\n try {\n envs = parseEnv([], options.envFile);\n } catch (error) {\n logger.error(`Failed to read environment file: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n } else if (!options.skipEnv) { \n const envVars = await promptForFile(\n 'Enter the path to your environment file:',\n '.env',\n 'file',\n );\n envs = parseEnv([], envVars);\n }\n\n // Prompt for resource configuration if needed\n const resourceQuestions = [];\n\n if (options.vcpu === String(DEFAULT_VCPU)) {\n resourceQuestions.push({\n type: 'input',\n name: 'vcpu',\n message: `Enter number of vCPUs (default: ${DEFAULT_VCPU}):`,\n default: String(DEFAULT_VCPU),\n validate: (input) => {\n const num = parseInt(input);\n if (isNaN(num) || num <= 0) {\n return 'Please enter a valid positive number';\n }\n return true;\n }\n });\n }\n\n if (options.memory === String(DEFAULT_MEMORY)) {\n resourceQuestions.push({\n type: 'input',\n name: 'memory',\n message: `Enter memory in MB (default: ${DEFAULT_MEMORY}):`,\n default: String(DEFAULT_MEMORY),\n validate: (input) => {\n const num = parseInt(input);\n if (isNaN(num) || num <= 0) {\n return 'Please enter a valid positive number';\n }\n return true;\n }\n });\n }\n\n if (options.diskSize === String(DEFAULT_DISK_SIZE)) {\n resourceQuestions.push({\n type: 'input',\n name: 'diskSize',\n message: `Enter disk size in GB (default: ${DEFAULT_DISK_SIZE}):`,\n default: String(DEFAULT_DISK_SIZE),\n validate: (input) => {\n const num = parseInt(input);\n if (isNaN(num) || num <= 0) {\n return 'Please enter a valid positive number';\n }\n return true;\n }\n });\n }\n\n if (resourceQuestions.length > 0) {\n const resources = await inquirer.prompt(resourceQuestions);\n\n if (resources.vcpu) {\n options.vcpu = resources.vcpu;\n }\n\n if (resources.memory) {\n options.memory = resources.memory;\n }\n\n if (resources.diskSize) {\n options.diskSize = resources.diskSize;\n }\n }\n\n // Fetch available TEEPods\n if (!options.teepodId) {\n const teepodsSpinner = logger.startSpinner('Fetching available TEEPods');\n const teepods = await getTeepods();\n teepodsSpinner.stop(true);\n\n if (teepods.length === 0) {\n logger.error('No TEEPods available. Please try again later.');\n process.exit(1);\n }\n\n // Use inquirer to select a TEEPod\n const { selectedTeepodId } = await inquirer.prompt([\n {\n type: 'list',\n name: 'selectedTeepodId',\n message: 'Select a TEEPod:',\n choices: teepods.map(pod => ({\n name: `${pod.name} (${pod.status})`,\n value: pod.id\n }))\n }\n ]);\n\n // Find the selected TEEPod\n const selectedTeepod = teepods.find(pod => pod.id === selectedTeepodId);\n if (!selectedTeepod) {\n logger.error('Failed to find selected TEEPod');\n process.exit(1);\n }\n\n logger.info(`Selected TEEPod: ${selectedTeepod.name}`);\n options.teepodId = selectedTeepod.id;\n }\n\n if (!options.image) {\n const images = await getTeepodImages(options.teepodId);\n const imageChoices = images.map(image => ({\n name: `${image.name}`,\n value: image.name\n }));\n\n const { selectedImage } = await inquirer.prompt([\n {\n type: 'list',\n name: 'selectedImage',\n message: 'Select an image:',\n choices: imageChoices\n }\n ]);\n options.image = selectedImage.value;\n }\n\n // Prepare VM configuration\n const vmConfig = {\n teepod_id: options.teepodId || 3,\n name: options.name,\n image: options.image || 'dstack-dev-0.3.5',\n vcpu: parseInt(options.vcpu),\n memory: parseInt(options.memory),\n disk_size: parseInt(options.diskSize),\n compose_manifest: {\n docker_compose_file: composeString,\n docker_config: {\n url: '',\n username: '',\n password: '',\n },\n features: ['kms', 'tproxy-net'],\n kms_enabled: true,\n manifest_version: 2,\n name: options.name,\n public_logs: true,\n public_sysinfo: true,\n tproxy_enabled: true,\n },\n listed: false,\n };\n\n // Get public key from CVM\n const spinner = logger.startSpinner('Getting public key from CVM');\n const pubkey = await getPubkeyFromCvm(vmConfig);\n spinner.stop(true);\n\n if (!pubkey) {\n logger.error('Failed to get public key from CVM');\n process.exit(1);\n }\n\n // Encrypt environment variables\n const encryptSpinner = logger.startSpinner('Encrypting environment variables');\n const encrypted_env = await encryptEnvVars(envs, pubkey.app_env_encrypt_pubkey);\n encryptSpinner.stop(true);\n\n if (options.debug) {\n logger.debug('Public key:', pubkey.app_env_encrypt_pubkey);\n logger.debug('Encrypted environment variables:', encrypted_env);\n logger.debug('Environment variables:', JSON.stringify(envs));\n }\n\n // Create the CVM\n const createSpinner = logger.startSpinner('Creating CVM');\n const response = await createCvm({\n ...vmConfig,\n encrypted_env,\n app_env_encrypt_pubkey: pubkey.app_env_encrypt_pubkey,\n app_id_salt: pubkey.app_id_salt,\n });\n createSpinner.stop(true);\n\n if (!response) {\n logger.error('Failed to create CVM');\n process.exit(1);\n }\n\n logger.success('CVM created successfully');\n logger.info(`CVM ID: ${response.id}`);\n logger.info(`Name: ${response.name}`);\n logger.info(`Status: ${response.status}`);\n logger.info(`App ID: ${response.app_id}`);\n\n if (response.app_url) {\n logger.info(`App URL: ${response.app_url}`);\n } else {\n logger.info(`App URL: ${CLOUD_URL}/dashboard/cvms/app_${response.app_id}`);\n }\n\n logger.info('');\n logger.info('Your CVM is being created. You can check its status with:');\n logger.info(`phala cvms status ${response.app_id}`);\n } catch (error) {\n logger.error(`Failed to create CVM: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import fs from 'fs';\nimport { EnvVar } from '@phala/dstack-sdk/encrypt-env-vars';\n\nexport const parseEnv = (envs: string[], envFile: string): EnvVar[] => {\n // Process environment variables\n const envVars: Record<string, string> = {};\n if (envs) {\n for (const env of envs) {\n if (env.includes(\"=\")) {\n const [key, value] = env.split(\"=\");\n if (key && value) {\n envVars[key] = value;\n }\n }\n }\n }\n\n if (envFile) {\n const envFileContent = fs.readFileSync(envFile, \"utf8\");\n for (const line of envFileContent.split(\"\\n\")) {\n // Skip empty lines or comment lines\n if (!line.trim() || line.trim().startsWith('#')) continue;\n \n if (line.includes(\"=\")) {\n // Split only on the first equals sign\n const [key, ...valueParts] = line.split(\"=\");\n let value = valueParts.join(\"=\");\n \n // Remove inline comments (anything after # with whitespace before it)\n const commentIndex = value.search(/\\s+#/);\n if (commentIndex !== -1) {\n value = value.substring(0, commentIndex).trim();\n }\n \n if (key && value) {\n envVars[key.trim()] = value.trim();\n }\n }\n }\n }\n\n // Add environment variables to the payload\n return Object.entries(envVars).map(([key, value]) => ({\n key,\n value,\n }));\n};","import { Command } from 'commander';\nimport { deleteCvm, selectCvm } from '@/src/api/cvms';\nimport { logger } from '@/src/utils/logger';\nimport inquirer from 'inquirer';\n\nexport const deleteCommand = new Command()\n .name('delete')\n .description('Delete a CVM')\n .argument('[app-id]', 'App ID of the CVM to delete (if not provided, a selection prompt will appear)')\n .option('-f, --force', 'Skip confirmation prompt', false)\n .action(async (appId, options) => {\n try {\n // If no app ID is provided, prompt user to select one\n if (!appId) {\n appId = await selectCvm();\n if (!appId) {\n return; // No CVMs found or user canceled\n }\n }\n \n // Confirm deletion unless force option is used\n if (!options.force) {\n const { confirm } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'confirm',\n message: `Are you sure you want to delete CVM with App ID ${appId}? This action cannot be undone.`,\n default: false,\n },\n ]);\n \n if (!confirm) {\n logger.info('Deletion cancelled');\n return;\n }\n }\n \n // Delete the CVM\n const spinner = logger.startSpinner(`Deleting CVM ${appId}`);\n const success = await deleteCvm(appId);\n spinner.stop(true);\n \n if (!success) {\n logger.error(`Failed to delete CVM ${appId}`);\n process.exit(1);\n }\n \n logger.success(`CVM ${appId} deleted successfully`);\n } catch (error) {\n logger.error(`Failed to delete CVM: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { upgradeCvm, getCvmByAppId, selectCvm } from '@/src/api/cvms';\nimport { logger } from '@/src/utils/logger';\nimport fs from 'fs';\nimport { promptForFile } from '@/src/utils/prompts';\nimport { parseEnv } from '@/src/utils/secrets';\nimport { encryptEnvVars, type EnvVar } from '@phala/dstack-sdk/encrypt-env-vars';\n\nexport const upgradeCommand = new Command()\n .name('upgrade')\n .description('Upgrade a CVM to a new version')\n .argument('[app-id]', 'CVM app ID to upgrade (will prompt for selection if not provided)')\n .option('-c, --compose <compose>', 'Path to new Docker Compose file')\n .option('-e, --env-file <envFile>', 'Path to environment file')\n .option('--debug', 'Enable debug mode', false)\n .action(async (appId, options) => {\n try {\n // If no app ID is provided, prompt user to select one\n if (!appId) {\n logger.info('No CVM specified, fetching available CVMs...');\n const selectedCvm = await selectCvm();\n if (!selectedCvm) {\n return;\n }\n appId = selectedCvm;\n }\n\n // Get current CVM configuration\n const spinner = logger.startSpinner(`Fetching current configuration for CVM ${appId}`);\n const currentCvm = await getCvmByAppId(appId);\n spinner.stop(true);\n \n if (!currentCvm) {\n logger.error(`CVM with App ID ${appId} not found`);\n process.exit(1);\n }\n \n // Prepare upgrade payload\n const upgradePayload: any = {};\n\n // If compose path not provided, prompt with examples\n if (!options.compose) {\n options.compose = await promptForFile(\n 'Enter the path to your Docker Compose file:',\n 'docker-compose.yml',\n 'file'\n );\n }\n \n // Update Docker Compose file if provided\n let composeString = '';\n if (options.compose) {\n try {\n composeString = fs.readFileSync(options.compose, 'utf8');\n } catch (error) {\n logger.error(`Failed to read Docker Compose file: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }\n \n // Process environment variables if provided\n let encrypted_env = \"\";\n if (options.envFile) {\n let envs: EnvVar[] = [];\n \n // Process environment variables from file\n if (options.envFile) {\n try {\n envs = parseEnv([], options.envFile);\n encrypted_env = await encryptEnvVars(envs, currentCvm.encrypted_env_pubkey);\n } catch (error) {\n logger.error(`Failed to read environment file: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }\n \n }\n\n const vm_config = {\n compose_manifest: {\n docker_compose_file: composeString,\n manifest_version: 1,\n runner: \"docker-compose\",\n version: \"1.0.0\",\n features: [\"kms\", \"tproxy-net\"],\n name: `app_${options.appId}`,\n },\n encrypted_env,\n allow_restart: true,\n };\n \n // Upgrade the CVM\n const upgradeSpinner = logger.startSpinner(`Upgrading CVM ${appId}`);\n const response = await upgradeCvm(appId, vm_config);\n upgradeSpinner.stop(true);\n \n if (!response) {\n logger.error('Failed to upgrade CVM');\n process.exit(1);\n }\n \n logger.success(`CVM ${appId} upgraded successfully`);\n if (response.detail) {\n logger.info(`Details: ${response.detail}`);\n }\n } catch (error) {\n logger.error(`Failed to upgrade CVM: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); ","import { Command } from 'commander';\nimport { getCvmByAppId, resizeCvm, selectCvm } from '@/src/api/cvms';\nimport { logger } from '@/src/utils/logger';\nimport inquirer from 'inquirer';\n\nexport const resizeCommand = new Command()\n .name('resize')\n .description('Resize resources for a CVM')\n .argument('[app-id]', 'App ID of the CVM (if not provided, a selection prompt will appear)')\n .option('-v, --vcpu <vcpu>', 'Number of virtual CPUs')\n .option('-m, --memory <memory>', 'Memory size in MB')\n .option('-d, --disk-size <diskSize>', 'Disk size in GB')\n .option('-r, --allow-restart <allowRestart>', 'Allow restart of the CVM if needed for resizing')\n .option('-y, --yes', 'Automatically confirm the resize operation')\n .action(async (appId, options) => {\n try {\n // If no app ID is provided, prompt user to select one\n if (!appId) {\n appId = await selectCvm();\n if (!appId) {\n logger.info('No CVMs found or selection cancelled');\n return;\n }\n }\n\n const cvm = await getCvmByAppId(appId);\n \n // Initialize parameters\n let vcpu: number | undefined = options.vcpu;\n let memory: number | undefined = options.memory;\n let diskSize: number | undefined = options.diskSize;\n let allowRestart: boolean | undefined = options.allowRestart;\n // Prompt for vCPU if selected\n if (!vcpu) {\n const response = await inquirer.prompt([\n {\n type: 'input',\n name: 'vcpu',\n message: 'Enter number of vCPUs:',\n validate: (input) => {\n const num = parseInt(input);\n if (isNaN(num) || num < 0) {\n return 'Please enter a valid non-negative number';\n }\n return true;\n },\n default: cvm.vcpu,\n filter: (input) => parseInt(input)\n }\n ]);\n vcpu = response.vcpu;\n }\n \n // Prompt for memory\n if (!memory) {\n const response = await inquirer.prompt([\n {\n type: 'input',\n name: 'memory',\n message: 'Enter memory in MB:',\n validate: (input) => {\n const num = parseInt(input);\n if (isNaN(num) || num < 0) {\n return 'Please enter a valid non-negative number';\n }\n return true;\n },\n default: cvm.memory,\n filter: (input) => parseInt(input)\n }\n ]);\n memory = response.memory;\n }\n \n // Prompt for disk size\n if (!diskSize) {\n const response = await inquirer.prompt([\n {\n type: 'input',\n name: 'diskSize',\n message: 'Enter disk size in GB:',\n validate: (input) => {\n const num = parseInt(input);\n if (isNaN(num) || num < 0) {\n return 'Please enter a valid non-negative number';\n }\n return true;\n },\n default: cvm.disk_size,\n filter: (input) => parseInt(input)\n }\n ]);\n diskSize = response.diskSize;\n }\n \n // Ask about restart permission\n if (!allowRestart) {\n const response = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'allowRestart',\n message: 'Allow restart of the CVM if needed for resizing?',\n default: false\n }\n ]);\n allowRestart = response.allowRestart;\n }\n \n // Prepare confirmation message\n let confirmMessage = `Are you sure you want to resize CVM ${appId} with the following changes:\\n`;\n logger.keyValueTable(\n { 'vCPUs': cvm.vcpu !== vcpu ? `${cvm.vcpu} -> ${vcpu}` : cvm.vcpu,\n 'Memory': cvm.memory !== memory ? `${cvm.memory} MB -> ${memory} MB` : cvm.memory,\n 'Disk Size': cvm.disk_size !== diskSize ? `${cvm.disk_size} GB -> ${diskSize} GB` : cvm.disk_size,\n 'Allow Restart': allowRestart ? 'Yes' : 'No' }\n );\n \n // Confirm the resize operation\n if (!options.yes) {\n const { confirm } = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'confirm',\n message: confirmMessage,\n default: false\n }\n ]);\n \n if (!confirm) {\n logger.info('Resize operation cancelled');\n return;\n }\n }\n \n const spinner = logger.startSpinner(`Resizing CVM with App ID ${appId}`);\n \n // Convert boolean to number (0 or 1) as expected by the API\n const allowRestartValue = allowRestart ? 1 : 0;\n \n await resizeCvm(appId, vcpu, memory, diskSize, allowRestartValue);\n \n spinner.stop(true);\n logger.success(`CVM with App ID ${appId} resized successfully`);\n } catch (error) {\n logger.error(`Failed to resize CVM: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n }); "],"mappings":";gDACA,OAAS,WAAAA,OAAe,YCDxB,OAAOC,OAAW,QAClB,IAAMC,GAAYD,GAAM,IAAI,SAAS,EACxBE,GAAOD,GAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAsB7B,EAEYE,GAAYF,GAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAsBlC,EAEYG,GAAcJ,GAAM,KAAK,qBAAqB,EClD3D,OAAS,WAAAK,OAAe,YCAxB,OAAS,WAAAC,OAAe,YCAxB,OAAOC,MAAQ,KACf,OAAOC,OAAU,OACjB,OAAOC,MAAQ,KACf,OAAOC,MAAY,SAInB,IAAMC,EAAkBC,GAAK,KAAKC,EAAG,QAAQ,EAAG,cAAc,EACxDC,EAAeF,GAAK,KAAKD,EAAiB,SAAS,E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,IAAIC,GAAQ,EACzB,KAAK,OAAO,EACZ,YAAY,GAAGC;AAAA,sDAA6D,EAC5E,QAAQ,OAAO,EACf,WAAWC,EAAY,EACvB,WAAWC,EAAe,EAC1B,WAAWC,EAAc,EACzB,WAAWC,EAAiB,EAC5B,WAAWC,EAAc,EACzB,WAAWC,EAAW,EAEjB,MAAM,QAAQ,IAAI,CAC5B,CAEAR,GAAK,EAAE,MAAOS,GAAU,CACtBC,EAAO,MAAM,qBAAsBD,CAAK,EACxC,QAAQ,KAAK,CAAC,CAChB,CAAC","names":["Command","chalk","logoColor","logo","smallLogo","minimalLogo","Command","Command","fs","path","os","crypto","PHALA_CLOUD_DIR","path","os","API_KEY_FILE","DOCKER_CREDENTIALS_FILE","ensureDirectoryExists","fs","error","logger","getMachineKey","machineParts","hash","crypto","encrypt","text","key","iv","cipher","encrypted","decrypt","encryptedText","parts","decipher","decrypted","saveApiKey","apiKey","encryptedApiKey","getApiKey","removeApiKey","saveDockerCredentials","credentials","getDockerCredentials","data","prompts","axios","CLOUD_API_URL","CLOUD_URL","CLI_VERSION","DOCKER_HUB_API_URL","TEE_SIMULATOR","DEFAULT_VCPU","DEFAULT_MEMORY","DEFAULT_DISK_SIZE","API_ENDPOINTS","teepodId","userId","appId","DOCKER_COMPOSE_ELIZA_V2_TEMPLATE","DOCKER_COMPOSE_BASIC_TEMPLATE","safeStringify","obj","error","ApiClient","baseURL","logger","axios","CLI_VERSION","config","getApiKey","response","status","data","url","CLOUD_API_URL","apiClient","z","INVALID","ParseStatus","ZodIssueCode","ZodParsedType","ZodType","addIssueToContext","z","zodDecimalKind","precisionRegex","_ZodDecimal","ZodType","input","ZodParsedType","ctx","addIssueToContext","ZodIssueCode","INVALID","status","ParseStatus","check","parts","kind","value","inclusive","message","min","ch","max","ZodDecimal","__publicField","params","ComposeTemplateSchema","z","dockerConfigSchema","z","composeFileSchema","configurationSchema","hostedSchema","managedUserSchema","nodeSchema","cvmInstanceSchema","createCvmResponseSchema","getPubkeyFromCvmResponseSchema","getCvmByAppIdResponseSchema","getUserInfoResponseSchema","ZodDecimal","getCvmsByUserIdResponseSchema","upgradeCvmResponseSchema","encryptedEnvItemSchema","teepodSchema","imageSchema","safeStringify","obj","error","getUserInfo","logger","API_ENDPOINTS","response","apiClient","getUserInfoResponseSchema","parseError","loginCommand","Command","apiKey","prompts","value","saveApiKey","getUserInfo","removeApiKey","logger","error","Command","logoutCommand","Command","removeApiKey","logger","error","Command","statusCommand","Command","options","apiKey","getApiKey","logger","spinner","userInfo","getUserInfo","tableData","error","authCommands","Command","loginCommand","logoutCommand","statusCommand","Command","Command","z","getTeepods","response","apiClient","API_ENDPOINTS","teepodSchema","error","getTeepodImages","teepodId","imageSchema","listCommand","Command","spinner","logger","teepods","getTeepods","error","Command","inquirer","imagesCommand","Command","options","spinner","logger","teepodsSpinner","teepods","getTeepods","selectedTeepodId","pod","images","getTeepodImages","error","teepodsCommands","Command","listCommand","imagesCommand","Command","Command","execa","fs","path","axios","Handlebars","exec","spawn","promisify","os","inquirer","fs","path","validateFileExists","filePath","basePath","resolvedPath","promptForFile","message","defaultValue","name","input","execAsync","promisify","exec","LOGS_DIR","COMPOSE_FILES_DIR","MAX_CONSOLE_LINES","DockerService","image","username","registry","logsPath","path","fs","operation","timestamp","arch","os","command","args","resolve","reject","proc","spawn","logFile","logStream","consoleBuffer","processOutput","data","isError","lines","line","bufferedLine","code","err","dockerfile","tag","fullImageName","spinner","logger","validateFileExists","buildArgs","error","getDockerCredentials","response","axios","DOCKER_HUB_API_URL","tags","result","credentials","password","execa","envFile","templateType","template","DOCKER_COMPOSE_ELIZA_V2_TEMPLATE","DOCKER_COMPOSE_BASIC_TEMPLATE","validatedTemplate","ComposeTemplateSchema","composePath","envVars","commentIndex","key","value","trimmedKey","composeContent","Handlebars","env","composeFile","composeArgs","stdout","containerId","repo","nameParts","prompts","loginCommand","Command","options","username","password","registry","response","value","logger","DockerService","saveDockerCredentials","error","Command","path","inquirer","fs","buildCommand","Command","options","credentials","getDockerCredentials","logger","response","inquirer","input","defaultPath","path","fs","promptForFile","dockerfilePath","DockerService","error","Command","inquirer","pushCommand","Command","options","credentials","getDockerCredentials","logger","imageName","imageTag","localImages","DockerService","uniqueImageNames","img","selectedImage","availableTags","selectedTag","error","Command","tagsCommand","Command","options","credentials","getDockerCredentials","logger","tags","DockerService","tag","error","Command","inquirer","fs","path","runCommand","Command","options","composePath","envFilePath","validateFileExists","logger","defaultComposePath","path","fs","useDefault","inquirer","inputPath","input","defaultEnvPath","envPath","dockerService","DockerService","error","Command","inquirer","fs","path","generateCommand","Command","options","credentials","getDockerCredentials","logger","selectedImage","selectedTag","localImages","DockerService","imageMap","image","availableTags","imageTag","inquirer","imageNames","imageName","error","inputImage","input","inputTag","envFilePath","validateFileExists","defaultEnvPath","path","fs","useDefault","envPath","outputPath","confirmOverwrite","customPath","dockerService","composePath","outputDir","dockerCommands","Command","loginCommand","buildCommand","pushCommand","tagsCommand","runCommand","generateCommand","Command","Command","startCommand","Command","TEE_SIMULATOR","options","DockerService","logger","error","Command","stopCommand","Command","DockerService","logger","error","simulatorCommands","Command","startCommand","stopCommand","Command","Command","fs","path","os","PHALA_CLOUD_DIR","path","os","CONFIG_FILE","DEFAULT_CONFIG","ensureDirectoryExists","fs","error","logger","loadConfig","configData","saveConfig","config","getConfigValue","key","setConfigValue","value","listConfigValues","getCommand","Command","key","value","getConfigValue","logger","error","Command","setCommand","Command","key","value","parsedValue","setConfigValue","logger","error","Command","listCommand","Command","options","config","listConfigValues","logger","key","value","error","configCommands","Command","getCommand","setCommand","listCommand","Command","Command","z","getCvms","response","apiClient","API_ENDPOINTS","cvmInstanceSchema","error","getCvmByAppId","appId","getCvmByAppIdResponseSchema","getPubkeyFromCvm","vmConfig","getPubkeyFromCvmResponseSchema","createCvm","createCvmResponseSchema","startCvm","stopCvm","restartCvm","upgradeCvm","upgradeCvmResponseSchema","deleteCvm","selectCvm","logger","inquirer","listSpinner","cvms","getCvms","choices","cvm","id","name","status","selectedCvm","getCvmAttestation","appId","apiClient","API_ENDPOINTS","error","resizeCvm","vcpu","memory","diskSize","allowRestart","resizePayload","listCommand","Command","options","spinner","logger","cvms","getCvms","cvm","CLOUD_URL","error","Command","getCommand","Command","options","appId","selectCvm","spinner","logger","cvm","getCvmByAppId","CLOUD_URL","error","Command","startCommand","Command","appId","selectCvm","spinner","logger","startCvm","error","Command","stopCommand","Command","appId","selectCvm","spinner","logger","stopCvm","error","Command","restartCommand","Command","appId","selectCvm","spinner","logger","restartCvm","error","Command","chalk","attestationCommand","Command","appId","options","logger","selectedCvm","selectCvm","spinner","attestationData","getCvmAttestation","summaryData","cert","index","certData","error","Command","encryptEnvVars","fs","path","inquirer","fs","parseEnv","envs","envFile","envVars","env","key","value","envFileContent","line","valueParts","commentIndex","createCommand","Command","DEFAULT_VCPU","DEFAULT_MEMORY","DEFAULT_DISK_SIZE","options","name","inquirer","input","examplesDir","path","examples","fs","exampleDirs","dirent","composeString","choices","example","index","selection","exampleDir","possibleFiles","foundCompose","file","composePath","logger","customPath","error","envs","parseEnv","envVars","promptForFile","resourceQuestions","num","resources","teepodsSpinner","teepods","getTeepods","selectedTeepodId","pod","selectedTeepod","imageChoices","getTeepodImages","image","selectedImage","vmConfig","spinner","pubkey","getPubkeyFromCvm","encryptSpinner","encrypted_env","encryptEnvVars","createSpinner","response","createCvm","CLOUD_URL","Command","inquirer","deleteCommand","Command","appId","options","selectCvm","confirm","logger","spinner","success","deleteCvm","error","Command","fs","encryptEnvVars","upgradeCommand","Command","appId","options","logger","selectedCvm","selectCvm","spinner","currentCvm","getCvmByAppId","upgradePayload","promptForFile","composeString","fs","error","encrypted_env","envs","parseEnv","vm_config","upgradeSpinner","response","upgradeCvm","Command","inquirer","resizeCommand","Command","appId","options","selectCvm","logger","cvm","getCvmByAppId","vcpu","memory","diskSize","allowRestart","input","num","confirmMessage","confirm","spinner","resizeCvm","error","cvmsCommand","Command","listCommand","getCommand","createCommand","upgradeCommand","startCommand","stopCommand","restartCommand","attestationCommand","deleteCommand","resizeCommand","main","Command","logo","authCommands","teepodsCommands","dockerCommands","simulatorCommands","configCommands","cvmsCommand","error","logger"]}
@@ -0,0 +1,2 @@
1
+ import{b as a,c as b,d as c,e as d,f as e}from"./chunk-A4IAJHG6.js";export{b as calculateColumnWidths,d as calculateNestedTableWidths,c as calculateTableWidths,e as formatTable,a as logger};
2
+ //# sourceMappingURL=logger-LBGFMBSV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}