@layr-labs/ecloud-sdk 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client/common/config/environment.ts","../src/client/common/utils/userapi.ts","../src/client/common/utils/auth.ts","../src/client/common/utils/helpers.ts","../src/client/common/constants.ts","../src/client/common/utils/billing.ts","../src/client/common/telemetry/noop.ts","../src/client/common/telemetry/posthog.ts","../src/client/common/telemetry/metricsContext.ts","../src/client/common/telemetry/index.ts","../src/client/common/telemetry/wrapper.ts","../src/client/common/utils/logger.ts","../src/client/common/utils/dirname.ts"],"sourcesContent":["/**\n * Environment configuration for different networks\n */\n\nimport { BillingEnvironmentConfig, EnvironmentConfig } from \"../types\";\n\n// Chain IDs\nexport const SEPOLIA_CHAIN_ID = 11155111;\nexport const MAINNET_CHAIN_ID = 1;\n\n// Common addresses across all chains\nexport const CommonAddresses: Record<string, string> = {\n ERC7702Delegator: \"0x63c0c19a282a1b52b07dd5a65b58948a07dae32b\",\n};\n\n// Addresses specific to each chain\nexport const ChainAddresses: Record<number, Record<string, string>> = {\n [MAINNET_CHAIN_ID]: {\n PermissionController: \"0x25E5F8B1E7aDf44518d35D5B2271f114e081f0E5\",\n },\n [SEPOLIA_CHAIN_ID]: {\n PermissionController: \"0x44632dfBdCb6D3E21EF613B0ca8A6A0c618F5a37\",\n },\n};\n\n// Billing environment configurations (separate from chain environments)\nconst BILLING_ENVIRONMENTS: Record<\"dev\" | \"prod\", BillingEnvironmentConfig> = {\n dev: {\n billingApiServerURL: \"https://billingapi-dev.eigencloud.xyz\",\n },\n prod: {\n billingApiServerURL: \"https://billingapi.eigencloud.xyz\",\n },\n};\n\n// Chain environment configurations\nconst ENVIRONMENTS: Record<string, Omit<EnvironmentConfig, \"chainID\">> = {\n \"sepolia-dev\": {\n name: \"sepolia\",\n build: \"dev\",\n appControllerAddress: \"0xa86DC1C47cb2518327fB4f9A1627F51966c83B92\",\n permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,\n erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,\n kmsServerURL: \"http://10.128.0.57:8080\",\n userApiServerURL: \"https://userapi-compute-sepolia-dev.eigencloud.xyz\",\n defaultRPCURL: \"https://ethereum-sepolia-rpc.publicnode.com\",\n },\n sepolia: {\n name: \"sepolia\",\n build: \"prod\",\n appControllerAddress: \"0x0dd810a6ffba6a9820a10d97b659f07d8d23d4E2\",\n permissionControllerAddress: ChainAddresses[SEPOLIA_CHAIN_ID].PermissionController,\n erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,\n kmsServerURL: \"http://10.128.15.203:8080\",\n userApiServerURL: \"https://userapi-compute-sepolia-prod.eigencloud.xyz\",\n defaultRPCURL: \"https://ethereum-sepolia-rpc.publicnode.com\",\n },\n \"mainnet-alpha\": {\n name: \"mainnet-alpha\",\n build: \"prod\",\n appControllerAddress: \"0xc38d35Fc995e75342A21CBd6D770305b142Fbe67\",\n permissionControllerAddress: ChainAddresses[MAINNET_CHAIN_ID].PermissionController,\n erc7702DelegatorAddress: CommonAddresses.ERC7702Delegator,\n kmsServerURL: \"http://10.128.0.2:8080\",\n userApiServerURL: \"https://userapi-compute.eigencloud.xyz\",\n defaultRPCURL: \"https://ethereum-rpc.publicnode.com\",\n },\n};\n\nconst CHAIN_ID_TO_ENVIRONMENT: Record<string, string> = {\n [SEPOLIA_CHAIN_ID.toString()]: \"sepolia\",\n [MAINNET_CHAIN_ID.toString()]: \"mainnet-alpha\",\n};\n\n/**\n * Get environment configuration\n */\nexport function getEnvironmentConfig(environment: string, chainID?: bigint): EnvironmentConfig {\n const env = ENVIRONMENTS[environment];\n if (!env) {\n throw new Error(`Unknown environment: ${environment}`);\n }\n\n // Check if environment is available in current build\n if (!isEnvironmentAvailable(environment)) {\n throw new Error(\n `Environment ${environment} is not available in this build type. ` +\n `Available environments: ${getAvailableEnvironments().join(\", \")}`,\n );\n }\n\n // If chainID provided, validate it matches\n if (chainID) {\n const expectedEnv = CHAIN_ID_TO_ENVIRONMENT[chainID.toString()];\n if (expectedEnv && expectedEnv !== environment) {\n throw new Error(`Environment ${environment} does not match chain ID ${chainID}`);\n }\n }\n\n // Determine chain ID from environment if not provided\n // Both \"sepolia\" and \"sepolia-dev\" use Sepolia chain ID\n const resolvedChainID =\n chainID ||\n (environment === \"sepolia\" || environment === \"sepolia-dev\"\n ? SEPOLIA_CHAIN_ID\n : MAINNET_CHAIN_ID);\n\n return {\n ...env,\n chainID: BigInt(resolvedChainID),\n };\n}\n\n/**\n * Get billing environment configuration\n * @param build - The build type (\"dev\" or \"prod\")\n */\nexport function getBillingEnvironmentConfig(build: \"dev\" | \"prod\"): {\n billingApiServerURL: string;\n} {\n const config = BILLING_ENVIRONMENTS[build];\n if (!config) {\n throw new Error(`Unknown billing environment: ${build}`);\n }\n return config;\n}\n\n/**\n * Detect environment from chain ID\n */\nexport function detectEnvironmentFromChainID(chainID: bigint): string | undefined {\n return CHAIN_ID_TO_ENVIRONMENT[chainID.toString()];\n}\n\n/**\n * Get build type from environment variable or build-time constant (defaults to 'prod')\n * BUILD_TYPE_BUILD_TIME is replaced at build time by tsup's define option\n */\n// @ts-ignore - BUILD_TYPE_BUILD_TIME is injected at build time by tsup\ndeclare const BUILD_TYPE_BUILD_TIME: string | undefined;\n\nexport function getBuildType(): \"dev\" | \"prod\" {\n // First check build-time constant (set by tsup define)\n // @ts-ignore - BUILD_TYPE_BUILD_TIME is injected at build time\n const buildTimeType =\n typeof BUILD_TYPE_BUILD_TIME !== \"undefined\" ? BUILD_TYPE_BUILD_TIME?.toLowerCase() : undefined;\n\n // Fall back to runtime environment variable\n const runtimeType = process.env.BUILD_TYPE?.toLowerCase();\n\n const buildType = buildTimeType || runtimeType;\n\n if (buildType === \"dev\") {\n return \"dev\";\n }\n return \"prod\";\n}\n\n/**\n * Get available environments based on build type\n * - dev: only \"sepolia-dev\"\n * - prod: \"sepolia\" and \"mainnet-alpha\"\n */\nexport function getAvailableEnvironments(): string[] {\n const buildType = getBuildType();\n\n if (buildType === \"dev\") {\n return [\"sepolia-dev\"];\n }\n\n // prod build\n return [\"sepolia\", \"mainnet-alpha\"];\n}\n\n/**\n * Check if an environment is available in the current build\n */\nexport function isEnvironmentAvailable(environment: string): boolean {\n return getAvailableEnvironments().includes(environment);\n}\n\n/**\n * Check if environment is mainnet (chain ID 1)\n */\nexport function isMainnet(environmentConfig: EnvironmentConfig): boolean {\n return environmentConfig.chainID === BigInt(MAINNET_CHAIN_ID);\n}\n","/**\n * UserAPI Client to manage interactions with the coordinator\n */\n\nimport axios, { AxiosResponse } from \"axios\";\nimport FormData from \"form-data\";\nimport { Address, Hex, createPublicClient, http } from \"viem\";\nimport { calculatePermissionSignature } from \"./auth\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { EnvironmentConfig } from \"../types\";\nimport { addHexPrefix, stripHexPrefix, getChainFromID } from \"./helpers\";\n\nexport interface AppProfileInfo {\n name: string;\n website?: string;\n description?: string;\n xURL?: string;\n imageURL?: string;\n}\n\nexport interface AppMetrics {\n cpu_utilization_percent?: number;\n memory_utilization_percent?: number;\n memory_used_bytes?: number;\n memory_total_bytes?: number;\n}\n\nexport interface DerivedAddress {\n address: string;\n derivationPath: string;\n}\n\nexport interface AppInfo {\n address: Address;\n status: string;\n ip: string;\n machineType: string;\n profile?: AppProfileInfo;\n metrics?: AppMetrics;\n evmAddresses: DerivedAddress[];\n solanaAddresses: DerivedAddress[];\n}\n\nexport interface AppInfoResponse {\n apps: Array<{\n addresses: {\n data: {\n evmAddresses: DerivedAddress[];\n solanaAddresses: DerivedAddress[];\n };\n signature: string;\n };\n app_status: string;\n ip: string;\n machine_type: string;\n profile?: AppProfileInfo;\n metrics?: AppMetrics;\n }>;\n}\n\nconst MAX_ADDRESS_COUNT = 5;\n\n// Permission constants\nexport const CanViewAppLogsPermission = \"0x2fd3f2fe\" as Hex;\nexport const CanViewSensitiveAppInfoPermission = \"0x0e67b22f\" as Hex;\nexport const CanUpdateAppProfilePermission = \"0x036fef61\" as Hex;\n\n/**\n * SDK_VERSION_BUILD_TIME is replaced at build time by tsup's define option\n */\n// @ts-ignore - SDK_VERSION_BUILD_TIME is injected at build time by tsup\ndeclare const SDK_VERSION_BUILD_TIME: string | undefined;\n\n/**\n * Get the default client ID using the build-time version\n */\nfunction getDefaultClientId(): string {\n // @ts-ignore - SDK_VERSION_BUILD_TIME is injected at build time\n const version = typeof SDK_VERSION_BUILD_TIME !== \"undefined\" ? SDK_VERSION_BUILD_TIME : \"0.0.0\";\n return `ecloud-sdk/v${version}`;\n}\n\nexport class UserApiClient {\n private readonly account?: ReturnType<typeof privateKeyToAccount>;\n private readonly rpcUrl?: string;\n private readonly clientId: string;\n\n constructor(\n private readonly config: EnvironmentConfig,\n privateKey?: string | Hex,\n rpcUrl?: string,\n clientId?: string,\n ) {\n if (privateKey) {\n const privateKeyHex = addHexPrefix(privateKey);\n this.account = privateKeyToAccount(privateKeyHex);\n }\n this.rpcUrl = rpcUrl;\n this.clientId = clientId || getDefaultClientId();\n }\n\n async getInfos(appIDs: Address[], addressCount = 1): Promise<AppInfo[]> {\n const count = Math.min(addressCount, MAX_ADDRESS_COUNT);\n\n const endpoint = `${this.config.userApiServerURL}/info`;\n const url = `${endpoint}?${new URLSearchParams({ apps: appIDs.join(\",\") })}`;\n\n const res = await this.makeAuthenticatedRequest(url, CanViewSensitiveAppInfoPermission);\n const result: AppInfoResponse = await res.json();\n\n // optional: verify signatures with KMS key\n // const { signingKey } = getKMSKeysForEnvironment(this.config.name);\n\n // Truncate without mutating the original object\n // API returns apps in the same order as the request, so use appIDs[i] as the address\n return result.apps.map((app, i) => {\n // TODO: Implement signature verification\n // const valid = await verifyKMSSignature(appInfo.addresses, signingKey);\n // if (!valid) {\n // throw new Error(`Invalid signature for app ${appIDs[i]}`);\n // }\n\n // Slice derived addresses to requested count\n const evmAddresses = app.addresses?.data?.evmAddresses?.slice(0, count) || [];\n const solanaAddresses = app.addresses?.data?.solanaAddresses?.slice(0, count) || [];\n\n return {\n address: appIDs[i] as Address,\n status: app.app_status,\n ip: app.ip,\n machineType: app.machine_type,\n profile: app.profile,\n metrics: app.metrics,\n evmAddresses,\n solanaAddresses,\n };\n });\n }\n\n /**\n * Get available SKUs (instance types) from UserAPI\n */\n async getSKUs(): Promise<{\n skus: Array<{ sku: string; description: string }>;\n }> {\n const endpoint = `${this.config.userApiServerURL}/skus`;\n const response = await this.makeAuthenticatedRequest(endpoint);\n\n const result = await response.json();\n\n // Transform response to match expected format\n return {\n skus: result.skus || result.SKUs || [],\n };\n }\n\n /**\n * Get logs for an app\n */\n async getLogs(appID: Address): Promise<string> {\n const endpoint = `${this.config.userApiServerURL}/logs/${appID}`;\n const response = await this.makeAuthenticatedRequest(endpoint, CanViewAppLogsPermission);\n return await response.text();\n }\n\n /**\n * Get statuses for apps\n */\n async getStatuses(appIDs: Address[]): Promise<Array<{ address: Address; status: string }>> {\n const endpoint = `${this.config.userApiServerURL}/status`;\n const url = `${endpoint}?${new URLSearchParams({ apps: appIDs.join(\",\") })}`;\n const response = await this.makeAuthenticatedRequest(url);\n const result = await response.json();\n\n // Transform response to match expected format\n // The API returns an array of app statuses\n const apps = result.apps || result.Apps || [];\n return apps.map((app: any, i: number) => ({\n address: (app.address || appIDs[i]) as Address,\n status: app.status || app.Status || \"\",\n }));\n }\n\n /**\n * Upload app profile information with optional image\n */\n async uploadAppProfile(\n appAddress: Address,\n name: string,\n website?: string,\n description?: string,\n xURL?: string,\n imagePath?: string,\n ): Promise<{\n name: string;\n website?: string;\n description?: string;\n xURL?: string;\n imageURL?: string;\n }> {\n const endpoint = `${this.config.userApiServerURL}/apps/${appAddress}/profile`;\n\n // Build multipart form data using form-data package\n const formData = new FormData();\n\n // Add required name field\n formData.append(\"name\", name);\n\n // Add optional text fields\n if (website) {\n formData.append(\"website\", website);\n }\n if (description) {\n formData.append(\"description\", description);\n }\n if (xURL) {\n formData.append(\"xURL\", xURL);\n }\n\n // Add optional image file\n if (imagePath) {\n const fs = await import(\"fs\");\n const path = await import(\"path\");\n const fileName = path.basename(imagePath);\n\n // Read file into buffer\n const fileBuffer = fs.readFileSync(imagePath);\n formData.append(\"image\", fileBuffer, fileName);\n }\n\n // Make authenticated POST request\n const headers: Record<string, string> = {\n \"x-client-id\": this.clientId,\n ...formData.getHeaders(),\n };\n\n // Add auth headers (Authorization and X-eigenx-expiry)\n if (this.account) {\n const expiry = BigInt(Math.floor(Date.now() / 1000) + 5 * 60); // 5 minutes\n const authHeaders = await this.generateAuthHeaders(CanUpdateAppProfilePermission, expiry);\n Object.assign(headers, authHeaders);\n }\n\n try {\n // Use axios to post req\n const response: AxiosResponse = await axios.post(endpoint, formData, {\n headers,\n maxRedirects: 0,\n validateStatus: () => true, // Don't throw on any status\n maxContentLength: Infinity, // Allow large file uploads\n maxBodyLength: Infinity, // Allow large file uploads\n });\n\n const status = response.status;\n\n if (status !== 200 && status !== 201) {\n const body =\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data);\n\n // Detect Cloudflare challenge page\n if (status === 403 && body.includes(\"Cloudflare\") && body.includes(\"challenge-platform\")) {\n throw new Error(\n `Cloudflare protection is blocking the request. This is likely due to bot detection.\\n` +\n `Status: ${status}`,\n );\n }\n\n throw new Error(\n `UserAPI request failed: ${status} ${status >= 200 && status < 300 ? \"OK\" : \"Error\"} - ${body.substring(0, 500)}${body.length > 500 ? \"...\" : \"\"}`,\n );\n }\n\n return response.data;\n } catch (error: any) {\n if (\n error.message?.includes(\"fetch failed\") ||\n error.message?.includes(\"ECONNREFUSED\") ||\n error.message?.includes(\"ENOTFOUND\") ||\n error.cause\n ) {\n const cause = error.cause?.message || error.cause || error.message;\n throw new Error(\n `Failed to connect to UserAPI at ${endpoint}: ${cause}\\n` +\n `Please check:\\n` +\n `1. Your internet connection\\n` +\n `2. The API server is accessible: ${this.config.userApiServerURL}\\n` +\n `3. Firewall/proxy settings`,\n );\n }\n throw error;\n }\n }\n\n private async makeAuthenticatedRequest(\n url: string,\n permission?: Hex,\n ): Promise<{ json: () => Promise<any>; text: () => Promise<string> }> {\n const headers: Record<string, string> = {\n \"x-client-id\": this.clientId,\n };\n // Add auth headers if permission is specified\n if (permission && this.account) {\n const expiry = BigInt(Math.floor(Date.now() / 1000) + 5 * 60); // 5 minutes\n const authHeaders = await this.generateAuthHeaders(permission, expiry);\n Object.assign(headers, authHeaders);\n }\n\n try {\n // Use axios to match\n const response: AxiosResponse = await axios.get(url, {\n headers,\n maxRedirects: 0,\n validateStatus: () => true, // Don't throw on any status\n });\n\n const status = response.status;\n const statusText = status >= 200 && status < 300 ? \"OK\" : \"Error\";\n\n if (status < 200 || status >= 300) {\n const body =\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data);\n throw new Error(`UserAPI request failed: ${status} ${statusText} - ${body}`);\n }\n\n // Return Response-like object for compatibility\n return {\n json: async () => response.data,\n text: async () =>\n typeof response.data === \"string\" ? response.data : JSON.stringify(response.data),\n };\n } catch (error: any) {\n // Handle network errors (fetch failed, connection refused, etc.)\n if (\n error.message?.includes(\"fetch failed\") ||\n error.message?.includes(\"ECONNREFUSED\") ||\n error.message?.includes(\"ENOTFOUND\") ||\n error.cause\n ) {\n const cause = error.cause?.message || error.cause || error.message;\n throw new Error(\n `Failed to connect to UserAPI at ${url}: ${cause}\\n` +\n `Please check:\\n` +\n `1. Your internet connection\\n` +\n `2. The API server is accessible: ${this.config.userApiServerURL}\\n` +\n `3. Firewall/proxy settings`,\n );\n }\n // Re-throw other errors as-is\n throw error;\n }\n }\n\n /**\n * Generate authentication headers for UserAPI requests\n */\n private async generateAuthHeaders(\n permission: Hex,\n expiry: bigint,\n ): Promise<Record<string, string>> {\n if (!this.account) {\n throw new Error(\"Private key required for authenticated requests\");\n }\n\n if (!this.rpcUrl) {\n throw new Error(\"RPC URL required for authenticated requests\");\n }\n\n const chain = getChainFromID(this.config.chainID);\n\n const publicClient = createPublicClient({\n chain,\n transport: http(this.rpcUrl),\n });\n\n // Calculate permission signature using shared auth utility\n const { signature } = await calculatePermissionSignature({\n permission,\n expiry,\n appControllerAddress: this.config.appControllerAddress,\n publicClient,\n account: this.account,\n });\n\n // Return auth headers\n return {\n Authorization: `Bearer ${stripHexPrefix(signature)}`,\n \"X-eigenx-expiry\": expiry.toString(),\n };\n }\n}\n","/**\n * Shared authentication utilities for API clients\n */\n\nimport { Hex, parseAbi, type Address } from \"viem\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { createPublicClient } from \"viem\";\n\n// Minimal AppController ABI for permission calculation\nconst APP_CONTROLLER_ABI = parseAbi([\n \"function calculateApiPermissionDigestHash(bytes4 permission, uint256 expiry) view returns (bytes32)\",\n]);\n\nexport interface PermissionSignatureOptions {\n permission: Hex;\n expiry: bigint;\n appControllerAddress: Address;\n publicClient: ReturnType<typeof createPublicClient>;\n account: ReturnType<typeof privateKeyToAccount>;\n}\n\nexport interface PermissionSignatureResult {\n signature: string;\n digest: Hex;\n}\n\n/**\n * Calculate permission digest via AppController contract and sign it with EIP-191\n */\nexport async function calculatePermissionSignature(\n options: PermissionSignatureOptions,\n): Promise<PermissionSignatureResult> {\n const { permission, expiry, appControllerAddress, publicClient, account } = options;\n\n // Calculate permission digest hash using AppController contract\n const digest = (await publicClient.readContract({\n address: appControllerAddress,\n abi: APP_CONTROLLER_ABI,\n functionName: \"calculateApiPermissionDigestHash\",\n args: [permission, expiry],\n })) as Hex;\n\n // Sign the digest using EIP-191 (signMessage handles prefixing automatically)\n const signature = await account.signMessage({\n message: { raw: digest },\n });\n\n return { signature, digest };\n}\n\nexport interface BillingAuthSignatureOptions {\n account: ReturnType<typeof privateKeyToAccount>;\n product: string;\n expiry: bigint;\n}\n\nexport interface BillingAuthSignatureResult {\n signature: Hex;\n expiry: bigint;\n}\n\n/**\n * Sign billing authentication message using EIP-712 typed data\n */\nexport async function calculateBillingAuthSignature(\n options: BillingAuthSignatureOptions,\n): Promise<BillingAuthSignatureResult> {\n const { account, product, expiry } = options;\n\n // Sign using EIP-712 typed data\n const signature = await account.signTypedData({\n domain: {\n name: \"EigenCloud Billing API\",\n version: \"1\",\n },\n types: {\n BillingAuth: [\n { name: \"product\", type: \"string\" },\n { name: \"expiry\", type: \"uint256\" },\n ],\n },\n primaryType: \"BillingAuth\",\n message: {\n product,\n expiry,\n },\n });\n\n return { signature, expiry };\n}\n","/**\n * General utility helpers\n */\n\nimport { extractChain } from \"viem\";\nimport type { Chain, Hex } from \"viem\";\nimport { sepolia } from \"viem/chains\";\nimport { SUPPORTED_CHAINS } from \"../constants\";\n\n/**\n * Get a viem Chain object from a chain ID.\n * Supports mainnet (1) and sepolia (11155111), defaults to the fallback chain for unknown chains.\n */\nexport function getChainFromID(chainID: bigint, fallback: Chain = sepolia): Chain {\n const id = Number(chainID) as (typeof SUPPORTED_CHAINS)[number][\"id\"];\n return extractChain({ chains: SUPPORTED_CHAINS, id }) || fallback;\n}\n\n/**\n * Ensure hex string has 0x prefix\n */\nexport function addHexPrefix(value: string): Hex {\n return (value.startsWith(\"0x\") ? value : `0x${value}`) as Hex;\n}\n\n/**\n * Remove 0x prefix from hex string if present\n */\nexport function stripHexPrefix(value: string): string {\n return value.startsWith(\"0x\") ? value.slice(2) : value;\n}\n","/**\n * Constants used throughout the SDK\n */\n\nimport { sepolia, mainnet } from \"viem/chains\";\n\nexport const SUPPORTED_CHAINS = [mainnet, sepolia] as const;\n\nexport const DOCKER_PLATFORM = \"linux/amd64\";\nexport const REGISTRY_PROPAGATION_WAIT_SECONDS = 3;\nexport const LAYERED_DOCKERFILE_NAME = \"Dockerfile.eigencompute\";\nexport const ENV_SOURCE_SCRIPT_NAME = \"compute-source-env.sh\";\nexport const KMS_CLIENT_BINARY_NAME = \"kms-client\";\nexport const KMS_ENCRYPTION_KEY_NAME = \"kms-encryption-public-key.pem\";\nexport const KMS_SIGNING_KEY_NAME = \"kms-signing-public-key.pem\";\nexport const TLS_KEYGEN_BINARY_NAME = \"tls-keygen\";\nexport const CADDYFILE_NAME = \"Caddyfile\";\nexport const TEMP_IMAGE_PREFIX = \"ecloud-temp-\";\nexport const LAYERED_BUILD_DIR_PREFIX = \"ecloud-layered-build\";\nexport const SHA256_PREFIX = \"sha256:\";\nexport const JWT_FILE_PATH = \"/run/container_launcher/attestation_verifier_claims_token\";\n","/**\n * Billing utility functions\n */\n\nimport type { SubscriptionStatus } from \"../types\";\n\n/**\n * Check if subscription status allows deploying apps\n */\nexport function isSubscriptionActive(status: SubscriptionStatus): boolean {\n return status === \"active\" || status === \"trialing\";\n}\n","/**\n * No-op telemetry client implementation\n */\n\nimport { TelemetryClient, Metric } from \"./types\";\n\n/**\n * NoopClient implements the TelemetryClient interface with no-op methods\n */\nexport class NoopClient implements TelemetryClient {\n /**\n * AddMetric implements the TelemetryClient interface\n */\n async addMetric(_metric: Metric): Promise<void> {\n // No-op\n }\n\n /**\n * Close implements the TelemetryClient interface\n */\n async close(): Promise<void> {\n // No-op\n }\n}\n\n/**\n * Check if a client is a NoopClient\n */\nexport function isNoopClient(client: TelemetryClient): boolean {\n return client instanceof NoopClient;\n}\n","/**\n * PostHog telemetry client implementation\n *\n * Uses the official posthog-node library\n */\n\nimport { PostHog } from \"posthog-node\";\nimport { TelemetryClient, Metric, AppEnvironment } from \"./types\";\n\n/**\n * PostHogClient implements the TelemetryClient interface using posthog-node\n */\nexport class PostHogClient implements TelemetryClient {\n private readonly client: PostHog;\n private readonly namespace: string;\n private readonly appEnvironment: AppEnvironment;\n\n constructor(environment: AppEnvironment, namespace: string, apiKey: string, endpoint?: string) {\n this.namespace = namespace;\n this.appEnvironment = environment;\n\n // Initialize PostHog client\n // posthog-node expects the full URL for the host option\n const host = endpoint || \"https://us.i.posthog.com\";\n\n this.client = new PostHog(apiKey, {\n host: host,\n flushAt: 1, // Flush immediately for CLI/SDK usage\n flushInterval: 0, // Disable interval flushing\n });\n\n // Identify the user with their UUID\n this.client.identify({\n distinctId: environment.userUUID,\n properties: {\n os: environment.os,\n arch: environment.arch,\n ...(environment.cliVersion ? { cliVersion: environment.cliVersion } : {}),\n },\n });\n }\n\n /**\n * AddMetric implements the TelemetryClient interface\n */\n async addMetric(metric: Metric): Promise<void> {\n // Never throw errors from telemetry operations\n try {\n // Create properties map starting with base properties\n const props: Record<string, any> = {\n name: metric.name,\n value: metric.value,\n };\n\n // Add metric dimensions\n for (const [k, v] of Object.entries(metric.dimensions)) {\n props[k] = v;\n }\n\n // Capture event using the namespace as the event name\n // With flushAt: 1, events are automatically flushed after each capture\n this.client.capture({\n distinctId: this.appEnvironment.userUUID,\n event: this.namespace,\n properties: props,\n });\n } catch {\n // Silently ignore telemetry errors\n }\n }\n\n /**\n * Close implements the TelemetryClient interface\n */\n async close(): Promise<void> {\n try {\n // Shutdown PostHog client and flush any pending events\n // shutdown() is synchronous but internally handles async cleanup\n this.client.shutdown();\n } catch {\n // Silently ignore errors during shutdown\n }\n }\n}\n\n/**\n * Embedded PostHog API key (can be exposed in TypeScript)\n * This can be set at build time or overridden via environment variable\n */\n// @ts-ignore - POSTHOG_API_KEY_BUILD_TIME is injected at build time by tsup\ndeclare const POSTHOG_API_KEY_BUILD_TIME: string | undefined;\n\n/**\n * Get PostHog API key from environment variable or build-time constant\n */\nexport function getPostHogAPIKey(): string | undefined {\n // Priority order:\n // 1. Environment variable\n // 2. Build-time constant (set at build time)\n // Check environment variable first\n if (process.env.ECLOUD_POSTHOG_KEY) {\n return process.env.ECLOUD_POSTHOG_KEY;\n }\n\n // Return build-time constant if available\n // @ts-ignore - POSTHOG_API_KEY_BUILD_TIME is injected at build time\n return typeof POSTHOG_API_KEY_BUILD_TIME !== \"undefined\" ? POSTHOG_API_KEY_BUILD_TIME : undefined;\n}\n\n/**\n * Get PostHog endpoint from environment variable or default\n */\nexport function getPostHogEndpoint(): string {\n return process.env.ECLOUD_POSTHOG_ENDPOINT || \"https://us.i.posthog.com\";\n}\n","/**\n * MetricsContext management\n */\n\nimport { MetricsContext } from \"./types\";\n\n/**\n * Create a new metrics context\n */\nexport function createMetricsContext(): MetricsContext {\n return {\n startTime: new Date(),\n metrics: [],\n properties: {},\n };\n}\n\n/**\n * Add a metric to the context without dimensions\n */\nexport function addMetric(context: MetricsContext, name: string, value: number): void {\n addMetricWithDimensions(context, name, value, {});\n}\n\n/**\n * Add a metric to the context with dimensions\n */\nexport function addMetricWithDimensions(\n context: MetricsContext,\n name: string,\n value: number,\n dimensions: Record<string, string>,\n): void {\n context.metrics.push({\n name,\n value,\n dimensions,\n });\n}\n","/**\n * Telemetry module for ECloud SDK and CLI\n *\n * Provides telemetry functionality matching the Go implementation.\n * Supports both \"ecloud-cli\" and \"ecloud-sdk\" namespaces.\n */\n\nimport { TelemetryClient, Metric, AppEnvironment } from \"./types\";\nimport { NoopClient, isNoopClient } from \"./noop\";\nimport { PostHogClient, getPostHogAPIKey, getPostHogEndpoint } from \"./posthog\";\nimport * as os from \"os\";\n\nexport * from \"./types\";\nexport * from \"./metricsContext\";\nexport * from \"./noop\";\nexport * from \"./posthog\";\nexport * from \"./wrapper\";\n\n/**\n * Options for creating a telemetry client\n */\nexport interface TelemetryClientOptions {\n /**\n * Whether telemetry is enabled (only enabled if explicitly set to true, defaults to disabled)\n */\n telemetryEnabled?: boolean;\n /**\n * PostHog API key (if not provided, will check environment variables)\n */\n apiKey?: string;\n /**\n * PostHog endpoint (if not provided, will use default)\n */\n endpoint?: string;\n}\n\n/**\n * Create a telemetry client\n *\n * @param environment - Application environment information (must include userUUID)\n * @param namespace - Namespace for telemetry events (\"ecloud-cli\" or \"ecloud-sdk\")\n * @param options - Optional telemetry client options\n * @returns TelemetryClient instance (NoopClient if telemetry is disabled or no API key)\n */\nexport function createTelemetryClient(\n environment: AppEnvironment,\n namespace: \"ecloud-cli\" | \"ecloud-sdk\",\n options?: TelemetryClientOptions,\n): TelemetryClient {\n // Check if telemetry is enabled\n // Only enabled if explicitly set to true\n // If undefined or false, telemetry is disabled\n const telemetryEnabled = options?.telemetryEnabled === true;\n\n // If telemetry is disabled, return noop client\n if (!telemetryEnabled) {\n return new NoopClient();\n }\n\n // Get API key from options, environment variable, or return noop\n const resolvedApiKey = options?.apiKey || getPostHogAPIKey();\n if (!resolvedApiKey) {\n // No API key available, return noop client\n return new NoopClient();\n }\n\n // Get endpoint from options or environment variable\n const endpoint = options?.endpoint || getPostHogEndpoint();\n\n try {\n return new PostHogClient(environment, namespace, resolvedApiKey, endpoint);\n } catch {\n // If initialization fails, return noop client\n return new NoopClient();\n }\n}\n\n/**\n * Create an AppEnvironment from current system information\n *\n * @param userUUID - User UUID for identification (required - no I/O in SDK)\n * @param cliVersion - Optional CLI version (for CLI usage)\n * @param osOverride - Optional OS override (defaults to current platform)\n * @param archOverride - Optional architecture override (defaults to current architecture)\n * @returns AppEnvironment with user UUID, OS, and architecture\n */\nexport function createAppEnvironment(\n userUUID: string,\n cliVersion?: string,\n osOverride?: string,\n archOverride?: string,\n): AppEnvironment {\n return {\n userUUID,\n cliVersion,\n os: osOverride || os.platform(),\n arch: archOverride || os.arch(),\n };\n}\n\n/**\n * Emit metrics from a metrics context\n *\n * @param client - Telemetry client to use\n * @param context - Metrics context containing metrics to emit\n * @returns Promise that resolves when all metrics are emitted\n */\nexport async function emitMetrics(\n client: TelemetryClient,\n context: {\n metrics: Metric[];\n properties: Record<string, string>;\n },\n): Promise<void> {\n if (isNoopClient(client)) {\n return;\n }\n\n // Emit each metric with properties merged into dimensions\n for (const metric of context.metrics) {\n const dimensions = {\n ...metric.dimensions,\n ...context.properties,\n };\n\n const metricWithProperties: Metric = {\n ...metric,\n dimensions,\n };\n\n try {\n await client.addMetric(metricWithProperties);\n } catch {\n // Silently ignore telemetry errors\n }\n }\n}\n","/**\n * Telemetry wrapper utilities for SDK functions\n *\n * Provides helpers to wrap SDK function execution with telemetry tracking\n */\n\nimport {\n createTelemetryClient,\n createAppEnvironment,\n createMetricsContext,\n addMetric,\n addMetricWithDimensions,\n emitMetrics,\n} from \"./index\";\nimport { randomUUID } from \"crypto\";\n\n/**\n * Generate a random UUID for telemetry identification\n * Used when userUUID is not provided (SDK usage outside CLI)\n */\nfunction generateRandomUUID(): string {\n return randomUUID();\n}\n\n/**\n * Options for telemetry wrapper\n */\nexport interface TelemetryWrapperOptions {\n /**\n * Function name for telemetry (e.g., \"deploy\", \"upgrade\", \"createApp\")\n */\n functionName: string;\n /**\n * Skip telemetry if true (used when called from CLI)\n */\n skipTelemetry?: boolean;\n /**\n * Additional properties to include in telemetry\n */\n properties?: Record<string, string>;\n /**\n * User UUID for identification (required if skipTelemetry is false)\n * If not provided and telemetry is enabled, will generate a random UUID for this session\n */\n userUUID?: string;\n /**\n * Whether telemetry is enabled (defaults to true if not provided)\n */\n telemetryEnabled?: boolean;\n /**\n * PostHog API key (optional, will check environment variables if not provided)\n */\n apiKey?: string;\n /**\n * PostHog endpoint (optional, will use default if not provided)\n */\n endpoint?: string;\n}\n\n/**\n * Wrap a function execution with telemetry\n *\n * @param options - Telemetry wrapper options\n * @param action - The function to execute\n * @returns The result of the action\n */\nexport async function withSDKTelemetry<T>(\n options: TelemetryWrapperOptions,\n action: () => Promise<T>,\n): Promise<T> {\n // Skip telemetry if requested (e.g., when called from CLI)\n if (options.skipTelemetry) {\n return action();\n }\n\n // Generate a random UUID if not provided (for SDK usage outside CLI)\n // This ensures each SDK session has a unique identifier\n const userUUID = options.userUUID || generateRandomUUID();\n\n const environment = createAppEnvironment(userUUID);\n const client = createTelemetryClient(environment, \"ecloud-sdk\", {\n telemetryEnabled: options.telemetryEnabled,\n apiKey: options.apiKey,\n endpoint: options.endpoint,\n });\n const metrics = createMetricsContext();\n\n // Set source to identify SDK usage\n metrics.properties[\"source\"] = \"ecloud-sdk\";\n\n // Set function name in properties\n metrics.properties[\"function\"] = options.functionName;\n\n // Add any additional properties\n if (options.properties) {\n Object.assign(metrics.properties, options.properties);\n }\n\n // Add initial count metric\n addMetric(metrics, \"Count\", 1);\n\n let actionError: Error | undefined;\n let result: T;\n\n try {\n result = await action();\n return result;\n } catch (err) {\n actionError = err instanceof Error ? err : new Error(String(err));\n throw err;\n } finally {\n // Add result metric\n const resultValue = actionError ? \"Failure\" : \"Success\";\n const dimensions: Record<string, string> = {};\n if (actionError) {\n dimensions[\"error\"] = actionError.message;\n }\n addMetricWithDimensions(metrics, resultValue, 1, dimensions);\n\n // Add duration metric\n const duration = Date.now() - metrics.startTime.getTime();\n addMetric(metrics, \"DurationMilliseconds\", duration);\n\n // Emit all metrics\n try {\n await emitMetrics(client, metrics);\n await client.close();\n } catch {\n // Silently ignore telemetry errors\n }\n }\n}\n","/**\n * Default logger\n */\n\nimport { Logger } from \"../types\";\n\nexport const defaultLogger: Logger = {\n info: (...args) => console.info(...args),\n warn: (...args) => console.warn(...args),\n error: (...args) => console.error(...args),\n debug: (...args) => console.debug(...args),\n};\n\nexport const getLogger: (verbose?: boolean) => Logger = (verbose?: boolean) => ({\n info: (...args) => console.info(...args),\n warn: (...args) => console.warn(...args),\n error: (...args) => console.error(...args),\n debug: (...args) => verbose && console.debug(...args),\n});\n","/**\n * ESM and CJS compatible getDirname utility\n */\n\nimport * as path from \"path\";\nimport { fileURLToPath } from \"url\";\n\n/**\n * Get __dirname equivalent that works in both ESM and CJS\n * In CJS builds, __dirname is available and will be used\n * In ESM builds, import.meta.url is used\n */\nexport function getDirname(): string {\n // Check for CJS __dirname first (available in CommonJS)\n if (typeof __dirname !== \"undefined\") {\n return __dirname;\n }\n\n // For ESM, we need to use import.meta.url\n // This will be evaluated at build time by tsup for ESM builds\n // For CJS builds, the above check will catch it, so this won't execute\n try {\n const metaUrl = import.meta.url;\n return path.dirname(fileURLToPath(metaUrl));\n } catch {\n // Fallback (shouldn't reach here in normal usage)\n return process.cwd();\n }\n}\n"],"mappings":";AAOO,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AAGzB,IAAM,kBAA0C;AAAA,EACrD,kBAAkB;AACpB;AAGO,IAAM,iBAAyD;AAAA,EACpE,CAAC,gBAAgB,GAAG;AAAA,IAClB,sBAAsB;AAAA,EACxB;AAAA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,IAAI,SAAS,QAAQ,KAAK,GAAG,IAAI;AAAA,EACvC,OAAO,IAAI,SAAS,QAAQ,MAAM,GAAG,IAAI;AAAA,EACzC,OAAO,IAAI,SAAS,QAAQ,MAAM,GAAG,IAAI;AAC3C;AAEO,IAAM,YAA2C,CAAC,aAAuB;AAAA,EAC9E,MAAM,IAAI,SAAS,QAAQ,KAAK,GAAG,IAAI;AAAA,EACvC,MAAM,IAAI,SAAS,QAAQ,KAAK,GAAG,IAAI;AAAA,EACvC,OAAO,IAAI,SAAS,QAAQ,MAAM,GAAG,IAAI;AAAA,EACzC,OAAO,IAAI,SAAS,WAAW,QAAQ,MAAM,GAAG,IAAI;AACtD;;;ACdA,YAAY,UAAU;AACtB,SAAS,qBAAqB;AAOvB,SAAS,aAAqB;AAEnC,MAAI,OAAO,cAAc,aAAa;AACpC,WAAO;AAAA,EACT;AAKA,MAAI;AACF,UAAM,UAAU,YAAY;AAC5B,WAAY,aAAQ,cAAc,OAAO,CAAC;AAAA,EAC5C,QAAQ;AAEN,WAAO,QAAQ,IAAI;AAAA,EACrB;AACF;","names":["sepolia","sepolia","path"]}
@@ -17,7 +17,7 @@ import {
17
17
  getLogger,
18
18
  stripHexPrefix,
19
19
  withSDKTelemetry
20
- } from "./chunk-73YDSHDG.js";
20
+ } from "./chunk-AOZRDBLK.js";
21
21
 
22
22
  // src/client/common/contract/eip7702.ts
23
23
  import {
@@ -2756,20 +2756,20 @@ async function prepareDeployBatch(options, logger) {
2756
2756
  environmentConfig
2757
2757
  };
2758
2758
  }
2759
- async function executeDeployBatch(prepared, gas, logger) {
2759
+ async function executeDeployBatch(data, context, gas, logger) {
2760
2760
  const pendingMessage = "Deploying new app...";
2761
2761
  const txHash = await executeBatch(
2762
2762
  {
2763
- walletClient: prepared.walletClient,
2764
- publicClient: prepared.publicClient,
2765
- environmentConfig: prepared.environmentConfig,
2766
- executions: prepared.executions,
2763
+ walletClient: context.walletClient,
2764
+ publicClient: context.publicClient,
2765
+ environmentConfig: context.environmentConfig,
2766
+ executions: data.executions,
2767
2767
  pendingMessage,
2768
2768
  gas
2769
2769
  },
2770
2770
  logger
2771
2771
  );
2772
- return { appId: prepared.appId, txHash };
2772
+ return { appId: data.appId, txHash };
2773
2773
  }
2774
2774
  async function deployApp(options, logger) {
2775
2775
  const prepared = await prepareDeployBatch(
@@ -2783,7 +2783,17 @@ async function deployApp(options, logger) {
2783
2783
  },
2784
2784
  logger
2785
2785
  );
2786
- return executeDeployBatch(prepared, options.gas, logger);
2786
+ const data = {
2787
+ appId: prepared.appId,
2788
+ salt: prepared.salt,
2789
+ executions: prepared.executions
2790
+ };
2791
+ const context = {
2792
+ walletClient: prepared.walletClient,
2793
+ publicClient: prepared.publicClient,
2794
+ environmentConfig: prepared.environmentConfig
2795
+ };
2796
+ return executeDeployBatch(data, context, options.gas, logger);
2787
2797
  }
2788
2798
  async function prepareUpgradeBatch(options) {
2789
2799
  const {
@@ -2879,14 +2889,14 @@ async function prepareUpgradeBatch(options) {
2879
2889
  environmentConfig
2880
2890
  };
2881
2891
  }
2882
- async function executeUpgradeBatch(prepared, gas, logger) {
2883
- const pendingMessage = `Upgrading app ${prepared.appId}...`;
2892
+ async function executeUpgradeBatch(data, context, gas, logger) {
2893
+ const pendingMessage = `Upgrading app ${data.appId}...`;
2884
2894
  const txHash = await executeBatch(
2885
2895
  {
2886
- walletClient: prepared.walletClient,
2887
- publicClient: prepared.publicClient,
2888
- environmentConfig: prepared.environmentConfig,
2889
- executions: prepared.executions,
2896
+ walletClient: context.walletClient,
2897
+ publicClient: context.publicClient,
2898
+ environmentConfig: context.environmentConfig,
2899
+ executions: data.executions,
2890
2900
  pendingMessage,
2891
2901
  gas
2892
2902
  },
@@ -2904,7 +2914,16 @@ async function upgradeApp(options, logger) {
2904
2914
  publicLogs: options.publicLogs,
2905
2915
  needsPermissionChange: options.needsPermissionChange
2906
2916
  });
2907
- return executeUpgradeBatch(prepared, options.gas, logger);
2917
+ const data = {
2918
+ appId: prepared.appId,
2919
+ executions: prepared.executions
2920
+ };
2921
+ const context = {
2922
+ walletClient: prepared.walletClient,
2923
+ publicClient: prepared.publicClient,
2924
+ environmentConfig: prepared.environmentConfig
2925
+ };
2926
+ return executeUpgradeBatch(data, context, options.gas, logger);
2908
2927
  }
2909
2928
  async function sendAndWaitForTransaction(options, logger) {
2910
2929
  const {
@@ -3643,6 +3662,7 @@ async function buildDockerImage(buildContext, dockerfilePath, tag, logger) {
3643
3662
  tag,
3644
3663
  "-f",
3645
3664
  dockerfilePath,
3665
+ "--load",
3646
3666
  "--progress=plain",
3647
3667
  buildContext
3648
3668
  ];
@@ -3766,9 +3786,9 @@ async function pullDockerImage(docker, imageTag, platform = "linux/amd64", logge
3766
3786
 
3767
3787
  // src/client/common/docker/push.ts
3768
3788
  import * as child_process2 from "child_process";
3769
- import { exec as exec3 } from "child_process";
3789
+ import { execFile } from "child_process";
3770
3790
  import { promisify as promisify2 } from "util";
3771
- var execAsync = promisify2(exec3);
3791
+ var execFileAsync = promisify2(execFile);
3772
3792
  async function pushDockerImage(docker, imageRef, logger) {
3773
3793
  logger?.info?.(`Pushing image ${imageRef}...`);
3774
3794
  return new Promise((resolve2, reject) => {
@@ -3835,7 +3855,7 @@ async function verifyImageExists(imageRef, logger) {
3835
3855
  let retries = 5;
3836
3856
  while (retries > 0) {
3837
3857
  try {
3838
- await execAsync(`docker manifest inspect ${imageRef}`, {
3858
+ await execFileAsync("docker", ["manifest", "inspect", imageRef], {
3839
3859
  maxBuffer: 10 * 1024 * 1024,
3840
3860
  timeout: 1e4
3841
3861
  // 10 second timeout
@@ -4293,10 +4313,10 @@ async function setupLayeredBuildDirectory(environmentConfig, layeredDockerfileCo
4293
4313
  // src/client/common/registry/digest.ts
4294
4314
  import * as child_process3 from "child_process";
4295
4315
  import { promisify as promisify3 } from "util";
4296
- var execFileAsync = promisify3(child_process3.execFile);
4316
+ var execFileAsync2 = promisify3(child_process3.execFile);
4297
4317
  async function getImageDigestAndName(imageRef) {
4298
4318
  try {
4299
- const { stdout } = await execFileAsync(
4319
+ const { stdout } = await execFileAsync2(
4300
4320
  "docker",
4301
4321
  ["manifest", "inspect", imageRef],
4302
4322
  { maxBuffer: 10 * 1024 * 1024 }
@@ -4336,7 +4356,7 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
4336
4356
  }
4337
4357
  async function extractDigestFromSinglePlatform(manifest, imageRef) {
4338
4358
  try {
4339
- const { stdout } = await execFileAsync("docker", ["inspect", imageRef], {
4359
+ const { stdout } = await execFileAsync2("docker", ["inspect", imageRef], {
4340
4360
  maxBuffer: 10 * 1024 * 1024
4341
4361
  });
4342
4362
  const inspectData = JSON.parse(stdout);
@@ -5038,23 +5058,24 @@ async function prepareDeploy(options, logger = defaultLogger) {
5038
5058
  environmentConfig: batch.environmentConfig,
5039
5059
  executions: batch.executions
5040
5060
  });
5061
+ const data = {
5062
+ appId: batch.appId,
5063
+ salt: batch.salt,
5064
+ executions: batch.executions
5065
+ };
5041
5066
  return {
5042
5067
  prepared: {
5043
- batch,
5068
+ data,
5044
5069
  appName,
5045
- imageRef: finalImageRef,
5046
- preflightCtx: {
5047
- privateKey: preflightCtx.privateKey,
5048
- rpcUrl: preflightCtx.rpcUrl,
5049
- environmentConfig: preflightCtx.environmentConfig
5050
- }
5070
+ imageRef: finalImageRef
5051
5071
  },
5052
5072
  gasEstimate
5053
5073
  };
5054
5074
  }
5055
5075
  );
5056
5076
  }
5057
- async function executeDeploy(prepared, gas, logger = defaultLogger, skipTelemetry) {
5077
+ async function executeDeploy(options) {
5078
+ const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
5058
5079
  return withSDKTelemetry(
5059
5080
  {
5060
5081
  functionName: "executeDeploy",
@@ -5062,7 +5083,7 @@ async function executeDeploy(prepared, gas, logger = defaultLogger, skipTelemetr
5062
5083
  },
5063
5084
  async () => {
5064
5085
  logger.info("Deploying on-chain...");
5065
- const { appId, txHash } = await executeDeployBatch(prepared.batch, gas, logger);
5086
+ const { appId, txHash } = await executeDeployBatch(prepared.data, context, gas, logger);
5066
5087
  return {
5067
5088
  appId,
5068
5089
  txHash,
@@ -5289,23 +5310,23 @@ async function prepareUpgrade(options, logger = defaultLogger) {
5289
5310
  environmentConfig: batch.environmentConfig,
5290
5311
  executions: batch.executions
5291
5312
  });
5313
+ const data = {
5314
+ appId: batch.appId,
5315
+ executions: batch.executions
5316
+ };
5292
5317
  return {
5293
5318
  prepared: {
5294
- batch,
5319
+ data,
5295
5320
  appId: appID,
5296
- imageRef: finalImageRef,
5297
- preflightCtx: {
5298
- privateKey: preflightCtx.privateKey,
5299
- rpcUrl: preflightCtx.rpcUrl,
5300
- environmentConfig: preflightCtx.environmentConfig
5301
- }
5321
+ imageRef: finalImageRef
5302
5322
  },
5303
5323
  gasEstimate
5304
5324
  };
5305
5325
  }
5306
5326
  );
5307
5327
  }
5308
- async function executeUpgrade(prepared, gas, logger = defaultLogger, skipTelemetry) {
5328
+ async function executeUpgrade(options) {
5329
+ const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
5309
5330
  return withSDKTelemetry(
5310
5331
  {
5311
5332
  functionName: "executeUpgrade",
@@ -5313,7 +5334,7 @@ async function executeUpgrade(prepared, gas, logger = defaultLogger, skipTelemet
5313
5334
  },
5314
5335
  async () => {
5315
5336
  logger.info("Upgrading on-chain...");
5316
- const txHash = await executeUpgradeBatch(prepared.batch, gas, logger);
5337
+ const txHash = await executeUpgradeBatch(prepared.data, context, gas, logger);
5317
5338
  return {
5318
5339
  appId: prepared.appId,
5319
5340
  imageRef: prepared.imageRef,
@@ -5442,10 +5463,10 @@ import * as path6 from "path";
5442
5463
  import * as fs5 from "fs";
5443
5464
  import * as path4 from "path";
5444
5465
  import * as os2 from "os";
5445
- import { exec as exec4, execFile as execFile2 } from "child_process";
5466
+ import { exec as exec3, execFile as execFile3 } from "child_process";
5446
5467
  import { promisify as promisify4 } from "util";
5447
- var execAsync2 = promisify4(exec4);
5448
- var execFileAsync2 = promisify4(execFile2);
5468
+ var execAsync = promisify4(exec3);
5469
+ var execFileAsync3 = promisify4(execFile3);
5449
5470
  async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
5450
5471
  if (!repoURL) {
5451
5472
  throw new Error("repoURL is required");
@@ -5454,13 +5475,13 @@ async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
5454
5475
  Cloning repo: ${repoURL} \u2192 ${targetDir}
5455
5476
  `);
5456
5477
  try {
5457
- await execAsync2(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
5478
+ await execAsync(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
5458
5479
  maxBuffer: 10 * 1024 * 1024
5459
5480
  });
5460
- await execFileAsync2("git", ["-C", targetDir, "checkout", "--quiet", ref], {
5481
+ await execFileAsync3("git", ["-C", targetDir, "checkout", "--quiet", ref], {
5461
5482
  maxBuffer: 10 * 1024 * 1024
5462
5483
  });
5463
- await execFileAsync2(
5484
+ await execFileAsync3(
5464
5485
  "git",
5465
5486
  ["-C", targetDir, "submodule", "update", "--init", "--recursive", "--progress"],
5466
5487
  { maxBuffer: 10 * 1024 * 1024 }
@@ -5505,14 +5526,14 @@ Cloning template: ${repoURL} \u2192 extracting ${subPath}
5505
5526
  }
5506
5527
  async function cloneSparse(repoURL, ref, subPath, tempDir) {
5507
5528
  try {
5508
- await execFileAsync2("git", ["init", tempDir]);
5509
- await execFileAsync2("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
5510
- await execFileAsync2("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
5529
+ await execFileAsync3("git", ["init", tempDir]);
5530
+ await execFileAsync3("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
5531
+ await execFileAsync3("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
5511
5532
  const sparseCheckoutPath = path4.join(tempDir, ".git/info/sparse-checkout");
5512
5533
  fs5.writeFileSync(sparseCheckoutPath, `${subPath}
5513
5534
  `);
5514
- await execFileAsync2("git", ["-C", tempDir, "fetch", "origin", ref]);
5515
- await execFileAsync2("git", ["-C", tempDir, "checkout", ref]);
5535
+ await execFileAsync3("git", ["-C", tempDir, "fetch", "origin", ref]);
5536
+ await execFileAsync3("git", ["-C", tempDir, "checkout", ref]);
5516
5537
  } catch (error) {
5517
5538
  throw new Error(`Failed to clone sparse repository: ${error.message}`);
5518
5539
  }
@@ -6005,7 +6026,14 @@ async function logs(options, logger = defaultLogger, skipTelemetry = false) {
6005
6026
  }
6006
6027
 
6007
6028
  // src/client/modules/compute/app/index.ts
6008
- import { parseAbi, encodeFunctionData as encodeFunctionData3 } from "viem";
6029
+ import {
6030
+ parseAbi,
6031
+ encodeFunctionData as encodeFunctionData3,
6032
+ createWalletClient as createWalletClient2,
6033
+ createPublicClient as createPublicClient4,
6034
+ http as http4
6035
+ } from "viem";
6036
+ import { privateKeyToAccount as privateKeyToAccount3 } from "viem/accounts";
6009
6037
  var CONTROLLER_ABI = parseAbi([
6010
6038
  "function startApp(address appId)",
6011
6039
  "function stopApp(address appId)",
@@ -6088,6 +6116,151 @@ function createAppModule(ctx) {
6088
6116
  imageRef: result.imageRef
6089
6117
  };
6090
6118
  },
6119
+ // Granular deploy control
6120
+ async prepareDeploy(opts) {
6121
+ return prepareDeploy(
6122
+ {
6123
+ privateKey,
6124
+ rpcUrl: ctx.rpcUrl,
6125
+ environment: ctx.environment,
6126
+ appName: opts.name,
6127
+ instanceType: opts.instanceType,
6128
+ dockerfilePath: opts.dockerfile,
6129
+ envFilePath: opts.envFile,
6130
+ imageRef: opts.imageRef,
6131
+ logVisibility: opts.logVisibility,
6132
+ resourceUsageMonitoring: opts.resourceUsageMonitoring,
6133
+ skipTelemetry
6134
+ },
6135
+ logger
6136
+ );
6137
+ },
6138
+ async executeDeploy(prepared, gas) {
6139
+ const account = privateKeyToAccount3(privateKey);
6140
+ const chain = getChainFromID(environment.chainID);
6141
+ const publicClient = createPublicClient4({
6142
+ chain,
6143
+ transport: http4(ctx.rpcUrl)
6144
+ });
6145
+ const walletClient = createWalletClient2({
6146
+ account,
6147
+ chain,
6148
+ transport: http4(ctx.rpcUrl)
6149
+ });
6150
+ const result = await executeDeploy({
6151
+ prepared,
6152
+ context: {
6153
+ walletClient,
6154
+ publicClient,
6155
+ environmentConfig: environment
6156
+ },
6157
+ gas,
6158
+ logger,
6159
+ skipTelemetry
6160
+ });
6161
+ return {
6162
+ appId: result.appId,
6163
+ txHash: result.txHash,
6164
+ appName: result.appName,
6165
+ imageRef: result.imageRef
6166
+ };
6167
+ },
6168
+ async watchDeployment(appId) {
6169
+ return watchDeployment(
6170
+ appId,
6171
+ privateKey,
6172
+ ctx.rpcUrl,
6173
+ ctx.environment,
6174
+ logger,
6175
+ ctx.clientId,
6176
+ skipTelemetry
6177
+ );
6178
+ },
6179
+ // Granular upgrade control
6180
+ async prepareUpgrade(appId, opts) {
6181
+ return prepareUpgrade(
6182
+ {
6183
+ appId,
6184
+ privateKey,
6185
+ rpcUrl: ctx.rpcUrl,
6186
+ environment: ctx.environment,
6187
+ instanceType: opts.instanceType,
6188
+ dockerfilePath: opts.dockerfile,
6189
+ envFilePath: opts.envFile,
6190
+ imageRef: opts.imageRef,
6191
+ logVisibility: opts.logVisibility,
6192
+ resourceUsageMonitoring: opts.resourceUsageMonitoring,
6193
+ skipTelemetry
6194
+ },
6195
+ logger
6196
+ );
6197
+ },
6198
+ async executeUpgrade(prepared, gas) {
6199
+ const account = privateKeyToAccount3(privateKey);
6200
+ const chain = getChainFromID(environment.chainID);
6201
+ const publicClient = createPublicClient4({
6202
+ chain,
6203
+ transport: http4(ctx.rpcUrl)
6204
+ });
6205
+ const walletClient = createWalletClient2({
6206
+ account,
6207
+ chain,
6208
+ transport: http4(ctx.rpcUrl)
6209
+ });
6210
+ const result = await executeUpgrade({
6211
+ prepared,
6212
+ context: {
6213
+ walletClient,
6214
+ publicClient,
6215
+ environmentConfig: environment
6216
+ },
6217
+ gas,
6218
+ logger,
6219
+ skipTelemetry
6220
+ });
6221
+ return {
6222
+ appId: result.appId,
6223
+ txHash: result.txHash,
6224
+ imageRef: result.imageRef
6225
+ };
6226
+ },
6227
+ async watchUpgrade(appId) {
6228
+ return watchUpgrade(
6229
+ appId,
6230
+ privateKey,
6231
+ ctx.rpcUrl,
6232
+ ctx.environment,
6233
+ logger,
6234
+ ctx.clientId,
6235
+ skipTelemetry
6236
+ );
6237
+ },
6238
+ // Profile management
6239
+ async setProfile(appId, profile) {
6240
+ return withSDKTelemetry(
6241
+ {
6242
+ functionName: "setProfile",
6243
+ skipTelemetry,
6244
+ properties: { environment: ctx.environment }
6245
+ },
6246
+ async () => {
6247
+ const userApiClient = new UserApiClient(
6248
+ environment,
6249
+ privateKey,
6250
+ ctx.rpcUrl,
6251
+ ctx.clientId
6252
+ );
6253
+ return userApiClient.uploadAppProfile(
6254
+ appId,
6255
+ profile.name,
6256
+ profile.website,
6257
+ profile.description,
6258
+ profile.xURL,
6259
+ profile.imagePath
6260
+ );
6261
+ }
6262
+ );
6263
+ },
6091
6264
  async logs(opts) {
6092
6265
  return logs(
6093
6266
  {
@@ -6286,4 +6459,4 @@ export {
6286
6459
  createAppModule,
6287
6460
  createComputeModule
6288
6461
  };
6289
- //# sourceMappingURL=chunk-LUFEUEOG.js.map
6462
+ //# sourceMappingURL=chunk-MQ2NGP4C.js.map