phala 1.2.1 → 1.2.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.
Files changed (2) hide show
  1. package/dist/index.js +3 -4
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -182,8 +182,7 @@ ${be}/dashboard/cvms/app_${a}`),0))}catch(n){return p.error(`Failed to upgrade C
182
182
  Please either:
183
183
  1. Create an SSH key pair: ssh-keygen -t rsa
184
184
  2. Specify a different key file: --ssh-pubkey <path>
185
- `));return}}try{let n=nt.readFileSync(t,"utf8").trim();return p.info(`Using SSH public key from ${t}`),n}catch(n){throw new Error(`Failed to read SSH public key from ${t}: ${n instanceof Error?n.message:String(n)}`)}}};var NA=(e,t)=>({publicLogs:e.publicLogs??t?.public_logs??!0,publicSysinfo:e.publicSysinfo??t?.public_sysinfo??!0,publicTcbinfo:e.publicTcbinfo??t?.public_tcbinfo??!0,secureTime:e.secureTime??t?.secure_time??!1,listed:e.listed??t?.listed??!1});function jA(e,t,n,r,o){let a={name:"",allowed_envs:n?.map(s=>s.key)||[],public_logs:r.publicLogs,public_sysinfo:r.publicSysinfo,public_tcbinfo:r.publicTcbinfo,secure_time:r.secureTime,...mf(e)};return e.runner==="bash"?a.bash_script=t:a.docker_compose_file=t,e.runner&&(a.runner=e.runner),e.noPreLaunchScript?a.pre_launch_script="":o&&(a.pre_launch_script=o),e.fs&&(a.storage_fs=e.fs),e.experimentalKeyProviderType&&(a.key_provider=e.experimentalKeyProviderType),a}var VA=(e,t,n,r,o,a,s)=>{let i=e.appCompose?{name:t,compose_file_raw:n,listed:o.listed}:{name:t,compose_file:jA(e,n,r,o,s),listed:o.listed};e.initScript!==void 0&&(i.init_scripts=e.initScript),e.launchToken!==void 0&&(i.launch_token=e.launchToken),e.generateLaunchToken!==void 0&&(i.generate_launch_token=e.generateLaunchToken);let{kmsType:c,deprecatedKmsId:l}=a??pf(e);e.instanceType&&(i.instance_type=e.instanceType),e.vcpu&&(i.vcpu=Number(e.vcpu)),e.memory&&(i.memory=cf(e.memory)),e.diskSize&&(i.disk_size=Bi(e.diskSize)),e.node&&(i.node=e.node),e.region&&(i.region=e.region),e.image&&(i.image=e.image),i.kms=c,e.kmsContract&&(i.kms_contract=e.kmsContract),e.kmsContractId&&(i.kms_contract_id=e.kmsContractId),e.keyProviderMode&&(i.key_provider_mode=e.keyProviderMode),e.skipGateway===!0&&(i.skip_gateway=!0);let m=c==="ETHEREUM"||c==="BASE";if(e.devOs===!0?i.prefer_dev=!0:(e.devOs===!1||m)&&(i.prefer_dev=!1),e.customAppId&&(i.app_id=e.customAppId,c==="PHALA")){if(!e.nonce)throw new Error("--nonce is required when using --custom-app-id with PHALA KMS.");let u=Number(e.nonce);if(Number.isNaN(u))throw new Error(`Invalid nonce value: "${e.nonce}". Nonce must be a valid number.`);i.nonce=u}if(e.nonce&&!e.customAppId)throw new Error("--nonce requires --custom-app-id to be specified.");return i},FA=(e,t)=>{if(e.compose_hash){if(e.instance_id){let n=gm(e);p.info(`mr_config_id (v3): ${hm(n)}`),p.info(`mr_config document: ${Ls(n)}`);return}p.info("mr_config_id (v3): finalized on first boot (instance_id)"),p.info(` compose_hash: ${e.compose_hash}`),p.info(` app_id: ${e.app_id||"(not assigned)"}`),p.info(` key_provider: ${e.key_provider}`),p.info(` key_provider_id: ${e.key_provider_id||"(none)"}`),t&&p.info(" gpu_policy_hash: bound at boot when the node attaches GPUs")}},zA=async(e,t,n,r,o,a,s,i)=>{let c=pf(e),l=await LA(e),m=await OA(e),u=[...n||[]];m&&u.push({key:"DSTACK_AUTHORIZED_KEYS",value:m});let d=NA(e,s),f=VA(e,l,t,u,d,c,i);o.write(`Provisioning CVM ${l}...
186
- `);let g=await Ds(r,f);if(!g.success)throw g.error;let h=g.data,y,I=h.kms_info;if(!h.app_id&&!!I?.chain_id&&!!I?.kms_contract_address){if(!I?.chain_id||!I?.chain)throw new Error("KMS chain info is missing from provision response. Please retry or contact support.");if(!I?.kms_contract_address)throw new Error("KMS contract address is missing from provision response. Please retry or contact support.");let S=await DA(e,I.chain_id),C=await Us({chain:I.chain,rpcUrl:e.rpcUrl,kmsContractAddress:I.kms_contract_address,privateKey:S,deviceId:h.device_id,composeHash:h.compose_hash});if(!C.success)throw C.error??new Error("Deployment contract failed");let A=C.data,$=I.slug||I.id;if(!$)throw new Error("KMS reference (slug or id) is missing from provision response");let z=await Br(r,{app_id:A.appId,kms:$});if(!z.success)throw z.error;let V=Ui(z.data,A.appId,I.k256_pubkey),ee=await Ge(u,V);y=await Ho(r,{token:h.token,app_id:A.appId,encrypted_env:ee,compose_hash:h.compose_hash,kms_id:$,contract_address:A.appAuthAddress,deployer_address:A.deployer})}else{let S=u&&u.length>0?await Ge(u,h.app_env_encrypt_pubkey):void 0;y=await Ho(r,{token:h.token,app_id:h.app_id,encrypted_env:S,compose_hash:h.compose_hash,kms_id:c.deprecatedKmsId})}if(!y.success)throw y.error;let k=y.data;if(e.experimentalKeyProviderType&&FA({app_id:k.app_id||h.app_id||"",compose_hash:h.compose_hash||"",key_provider:e.experimentalKeyProviderType,key_provider_id:I?.k256_pubkey||"",instance_id:k.instance_id||""},!!e.instanceType),e?.json!==!1)o.write(`${JSON.stringify({success:!0,vm_uuid:k.vm_uuid,name:k.name,app_id:k.app_id,dashboard_url:`${be}/dashboard/cvms/${k.vm_uuid}`,...k.launch_token?{launch_token:k.launch_token}:{}},null,2)}
185
+ `));return}}try{let n=nt.readFileSync(t,"utf8").trim();return p.info(`Using SSH public key from ${t}`),n}catch(n){throw new Error(`Failed to read SSH public key from ${t}: ${n instanceof Error?n.message:String(n)}`)}}};var NA=(e,t)=>({publicLogs:e.publicLogs??t?.public_logs??!0,publicSysinfo:e.publicSysinfo??t?.public_sysinfo??!0,publicTcbinfo:e.publicTcbinfo??t?.public_tcbinfo??!0,secureTime:e.secureTime??t?.secure_time??!1,listed:e.listed??t?.listed??!1});function jA(e,t,n,r,o){let a={name:"",allowed_envs:n?.map(s=>s.key)||[],public_logs:r.publicLogs,public_sysinfo:r.publicSysinfo,public_tcbinfo:r.publicTcbinfo,secure_time:r.secureTime,...mf(e)};return e.runner==="bash"?a.bash_script=t:a.docker_compose_file=t,e.runner&&(a.runner=e.runner),e.noPreLaunchScript?a.pre_launch_script="":o&&(a.pre_launch_script=o),e.fs&&(a.storage_fs=e.fs),e.experimentalKeyProviderType&&(a.key_provider=e.experimentalKeyProviderType),a}var VA=(e,t,n,r,o,a,s)=>{let i=e.appCompose?{name:t,compose_file_raw:n,listed:o.listed}:{name:t,compose_file:jA(e,n,r,o,s),listed:o.listed};e.initScript!==void 0&&(i.init_scripts=e.initScript),e.launchToken!==void 0&&(i.launch_token=e.launchToken),e.generateLaunchToken!==void 0&&(i.generate_launch_token=e.generateLaunchToken);let{kmsType:c,deprecatedKmsId:l}=a??pf(e);e.instanceType&&(i.instance_type=e.instanceType),e.vcpu&&(i.vcpu=Number(e.vcpu)),e.memory&&(i.memory=cf(e.memory)),e.diskSize&&(i.disk_size=Bi(e.diskSize)),e.node&&(i.node=e.node),e.region&&(i.region=e.region),e.image&&(i.image=e.image),i.kms=c,e.kmsContract&&(i.kms_contract=e.kmsContract),e.kmsContractId&&(i.kms_contract_id=e.kmsContractId),e.keyProviderMode&&(i.key_provider_mode=e.keyProviderMode),e.skipGateway===!0&&(i.skip_gateway=!0);let m=c==="ETHEREUM"||c==="BASE";if(e.devOs===!0?i.prefer_dev=!0:(e.devOs===!1||m)&&(i.prefer_dev=!1),e.customAppId&&(i.app_id=e.customAppId,c==="PHALA")){if(!e.nonce)throw new Error("--nonce is required when using --custom-app-id with PHALA KMS.");let u=Number(e.nonce);if(Number.isNaN(u))throw new Error(`Invalid nonce value: "${e.nonce}". Nonce must be a valid number.`);i.nonce=u}if(e.nonce&&!e.customAppId)throw new Error("--nonce requires --custom-app-id to be specified.");return i},FA=(e,t)=>{if(e.compose_hash){if(e.instance_id){let n=gm(e);p.info(`mr_config_id (v3): ${hm(n)}`),p.info(`mr_config document: ${Ls(n)}`);return}p.info("mr_config_id (v3): finalized on first boot (instance_id)"),p.info(` compose_hash: ${e.compose_hash}`),p.info(` app_id: ${e.app_id||"(not assigned)"}`),p.info(` key_provider: ${e.key_provider}`),p.info(` key_provider_id: ${e.key_provider_id||"(none)"}`),t&&p.info(" gpu_policy_hash: bound at boot when the node attaches GPUs")}},zA=async(e,t,n,r,o,a,s,i)=>{let c=pf(e),l=await LA(e),m=await OA(e),u=[...n||[]];m&&u.push({key:"DSTACK_AUTHORIZED_KEYS",value:m});let d=NA(e,s),f=VA(e,l,t,u,d,c,i);p.info(`Provisioning CVM ${l}...`);let g=await Ds(r,f);if(!g.success)throw g.error;let h=g.data,y,I=h.kms_info;if(!h.app_id&&!!I?.chain_id&&!!I?.kms_contract_address){if(!I?.chain_id||!I?.chain)throw new Error("KMS chain info is missing from provision response. Please retry or contact support.");if(!I?.kms_contract_address)throw new Error("KMS contract address is missing from provision response. Please retry or contact support.");let S=await DA(e,I.chain_id),C=await Us({chain:I.chain,rpcUrl:e.rpcUrl,kmsContractAddress:I.kms_contract_address,privateKey:S,deviceId:h.device_id,composeHash:h.compose_hash});if(!C.success)throw C.error??new Error("Deployment contract failed");let A=C.data,$=I.slug||I.id;if(!$)throw new Error("KMS reference (slug or id) is missing from provision response");let z=await Br(r,{app_id:A.appId,kms:$});if(!z.success)throw z.error;let V=Ui(z.data,A.appId,I.k256_pubkey),ee=await Ge(u,V);y=await Ho(r,{token:h.token,app_id:A.appId,encrypted_env:ee,compose_hash:h.compose_hash,kms_id:$,contract_address:A.appAuthAddress,deployer_address:A.deployer})}else{let S=u&&u.length>0?await Ge(u,h.app_env_encrypt_pubkey):void 0;y=await Ho(r,{token:h.token,app_id:h.app_id,encrypted_env:S,compose_hash:h.compose_hash,kms_id:c.deprecatedKmsId})}if(!y.success)throw y.error;let k=y.data;if(e.experimentalKeyProviderType&&FA({app_id:k.app_id||h.app_id||"",compose_hash:h.compose_hash||"",key_provider:e.experimentalKeyProviderType,key_provider_id:I?.k256_pubkey||"",instance_id:k.instance_id||""},!!e.instanceType),e?.json!==!1)o.write(`${JSON.stringify({success:!0,vm_uuid:k.vm_uuid,name:k.name,app_id:k.app_id,dashboard_url:`${be}/dashboard/cvms/${k.vm_uuid}`,...k.launch_token?{launch_token:k.launch_token}:{}},null,2)}
187
186
  `);else{let S=Wi`
188
187
  CVM created successfully!
189
188
 
@@ -198,7 +197,7 @@ This is the only time the launch token is shown. Store it.
198
197
  `):p.warn(g);return}if(d.requiresOnChainHash){if(e.prepareOnly){let C=d.kmsInfo?.chain_id,A=d.kmsInfo?.chain,$=c.app_id,z=A?.blockExplorers?.default?.url,V=z&&$?`${z}/address/${$.startsWith("0x")?$:`0x${$}`}`:void 0,ee=d.composeHash.startsWith("0x")?d.composeHash:`0x${d.composeHash}`,ie=d.onchainStatus,le={success:!0,prepare_only:!0,compose_hash:ee,app_id:c.app_id,device_id:d.deviceId,kms_info:d.kmsInfo,chain_id:C,contract_explorer_url:V,onchain_status:ie,commit_token:d.commitToken,commit_url:d.commitUrl,api_commit_url:d.apiCommitUrl};if(e.json!==!1)o.write(`${JSON.stringify(le,null,2)}
199
198
  `);else{let J=["CVM update prepared successfully (pending on-chain approval).","",`Compose Hash: ${ee}`,`App ID: ${c.app_id}`,`Device ID: ${d.deviceId}`];if(C&&J.push(`Chain: ${A?.name||"Unknown"} (ID: ${C})`),V&&J.push(`Contract: ${V}`),J.push(`Commit Token: ${d.commitToken||"N/A"}`,`Commit URL: ${d.commitUrl||"N/A"}`,`API Commit URL: ${d.apiCommitUrl||"N/A"} (POST)`),ie){let O=ie.compose_hash_allowed?"registered":"NOT registered",Y=ie.device_id_allowed?"registered":"NOT registered";J.push("","On-chain Status:",` Compose Hash: ${O}`,` Device ID: ${Y}`),ie.is_allowed&&J.push(" All prerequisites met. You can commit with --transaction-hash already-registered.")}J.push("","To complete the update after on-chain approval:",` phala deploy --cvm-id ${e.uuid} \\`," --commit \\",` --token ${d.commitToken||"<token>"} \\`,` --compose-hash ${ee} \\`," --transaction-hash <tx-hash>"),o.write(`${J.join(`
200
199
  `)}
201
- `)}return}if(!e.privateKey)throw new Error("Private key is required for contract DstackApp");e.debug&&(console.log("[DEBUG] patchCvm.composeHash:",d.composeHash),console.log("[DEBUG] cvm.app_id:",c.app_id),console.log("[DEBUG] patchCvm.deviceId:",d.deviceId));let g=c.kms_info?.chain_id,h=g!=null?Pt[g]:void 0;if(!h)throw new Error(g!=null?`CVM chain id ${g} is not supported by this CLI build`:"CVM kms_info is missing chain_id");let y=await cn({chain:h,rpcUrl:e.rpcUrl,appAddress:c.app_id,deviceId:d.deviceId,composeHash:d.composeHash});if(!y.success){let C=y.error;throw new Error(`Failed to check on-chain prerequisites (contract: ${c.app_id}): ${C.message}`)}if(e.debug&&console.log("[DEBUG] prereqs:",y.data),!y.data.deviceAllowed){p.info("Device not registered on-chain, adding...");let C=await Kt({chain:h,rpcUrl:e.rpcUrl,appAddress:c.app_id,deviceId:d.deviceId,privateKey:e.privateKey});if(!C.success){let A=C.error;throw new Error(`Failed to register device on-chain (device: ${d.deviceId.slice(0,10)}...): ${A.message}`)}}let I=await zt({chain:h,rpcUrl:e.rpcUrl,appId:c.app_id,composeHash:d.composeHash,privateKey:e.privateKey});if(!I.success){let C=I.error;throw new Error(`Failed to register compose hash on-chain (hash: ${d.composeHash.slice(0,10)}...): ${C.message}`)}let k=I.data.transactionHash;e.debug&&console.log("[DEBUG] transactionHash:",k);let S=await Xs(r,{id:e.uuid,composeHash:d.composeHash,transactionHash:k});if(!S.success){let C=S.error.message,A="status"in S.error?S.error.status:void 0;throw A===466?new Error("Compose hash expired. Please retry the update from the beginning."):A===467?new Error(`Transaction verification failed on backend. Hash: ${k}`):A===468?new Error(`Compose hash not found on-chain. Contract: ${c.app_id}`):new Error(`Failed to confirm CVM update after on-chain registration: ${C}`)}f=S.data.correlationId}if(await uf(r,e),e.wait){p.info("Waiting for update to complete...");try{let h=Date.now();await Sa(e.uuid,3e5,a,c.status==="stopped"?"stopped":"running"),f&&await Ld(r,e.uuid,f,3e5-(Date.now()-h))}catch(g){throw new Error(`Wait failed: ${g instanceof Error?g.message:String(g)}`)}}e?.json!==!1?o.write(`${JSON.stringify({success:!0,vm_uuid:e.uuid,name:c.name,app_id:c.app_id,dashboard_url:`${be}/dashboard/cvms/${e.uuid}`},null,2)}
200
+ `)}return}if(!e.privateKey)throw new Error("Private key is required for contract DstackApp");e.debug&&(console.log("[DEBUG] patchCvm.composeHash:",d.composeHash),console.log("[DEBUG] cvm.app_id:",c.app_id),console.log("[DEBUG] patchCvm.deviceId:",d.deviceId));let g=c.kms_info?.chain_id,h=g!=null?Pt[g]:void 0;if(!h)throw new Error(g!=null?`CVM chain id ${g} is not supported by this CLI build`:"CVM kms_info is missing chain_id");let y=await cn({chain:h,rpcUrl:e.rpcUrl,appAddress:c.app_id,deviceId:d.deviceId,composeHash:d.composeHash});if(!y.success){let C=y.error;throw new Error(`Failed to check on-chain prerequisites (contract: ${c.app_id}): ${C.message}`)}if(e.debug&&console.log("[DEBUG] prereqs:",y.data),!y.data.deviceAllowed){p.info("Device not registered on-chain, adding...");let C=await Kt({chain:h,rpcUrl:e.rpcUrl,appAddress:c.app_id,deviceId:d.deviceId,privateKey:e.privateKey});if(!C.success){let A=C.error;throw new Error(`Failed to register device on-chain (device: ${d.deviceId.slice(0,10)}...): ${A.message}`)}}let I=await zt({chain:h,rpcUrl:e.rpcUrl,appId:c.app_id,composeHash:d.composeHash,privateKey:e.privateKey});if(!I.success){let C=I.error;throw new Error(`Failed to register compose hash on-chain (hash: ${d.composeHash.slice(0,10)}...): ${C.message}`)}let k=I.data.transactionHash;e.debug&&console.log("[DEBUG] transactionHash:",k);let S=await Xs(r,{id:e.uuid,composeHash:d.composeHash,transactionHash:k});if(!S.success){let C=S.error.message,A="status"in S.error?S.error.status:void 0;throw A===466?new Error("Compose hash expired. Please retry the update from the beginning."):A===467?new Error(`Transaction verification failed on backend. Hash: ${k}`):A===468?new Error(`Compose hash not found on-chain. Contract: ${c.app_id}`):new Error(`Failed to confirm CVM update after on-chain registration: ${C}`)}f=S.data.correlationId}if(await uf(r,e),e.wait){p.info("Waiting for update to complete...");try{let h=Date.now();f&&await Ld(r,e.uuid,f,3e5),await Sa(e.uuid,3e5-(Date.now()-h),a,c.status==="stopped"?"stopped":"running")}catch(g){throw new Error(`Wait failed: ${g instanceof Error?g.message:String(g)}`)}}e?.json!==!1?o.write(`${JSON.stringify({success:!0,vm_uuid:c.vm_uuid,name:c.name,app_id:c.app_id,dashboard_url:`${be}/dashboard/cvms/${c.vm_uuid}`},null,2)}
202
201
  `):o.write(`CVM updated successfully!
203
202
  `)},HA=async(e,t,n)=>{if(!e.token)throw new Error("--token is required for --commit mode");if(!e.uuid)throw new Error("--cvm-id is required for --commit mode");e.transactionHash||p.info("No --transaction-hash provided, using 'already-registered' (state-only check)"),p.info(`Committing CVM update for ${e.uuid}...`);let r=await Zs(t,{id:e.uuid,token:e.token,composeHash:e.composeHash||"",transactionHash:e.transactionHash||""});if(!r.success){let o=r.error instanceof Error?r.error.message:String(r.error),s=o.includes("expired")||o.includes("Invalid")?" Run --prepare-only again to get a new commit token.":"";throw new Error(`Failed to commit CVM update: ${o}${s}`)}await uf(t,e),e.json!==!1?n.write(`${JSON.stringify({success:!0,vm_uuid:e.uuid,correlation_id:r.data.correlationId,status:r.data.status},null,2)}
204
203
  `):n.write(`CVM update committed successfully! Correlation ID: ${r.data.correlationId}
@@ -414,7 +413,7 @@ Compute or verify keccak256 checksums of hex inputs.
414
413
  Read from stdin when no arguments are given.
415
414
  `),1;try{let r=(await x$(t.stdin)).split(/\s+/).filter(Boolean),o;return r.length===0?o=P$(new Uint8Array(0)):o=Oc(r),t.stdout.write(`${o} -
416
415
  `),0}catch(n){return t.fail(n instanceof Error?n.message:"Failed to compute keccak256"),1}}var Wy=b({path:["keccak256sum"],meta:qy,schema:Gy,handler:T$});import{z as tn}from"zod";var Jy={name:"annotations",category:"manage",description:"Show or set CVM annotations: unmeasured key/value metadata for host-side tools",stability:"stable",arguments:[{name:"args",description:"[cvm-id] [KEY=VALUE ...]. The CVM id is optional and falls back to phala.toml; an argument containing '=' is a pair.",required:!1,variadic:!0,target:"args"}],options:[{name:"unset",description:"Remove an annotation key (repeatable)",type:"string[]",target:"unset"},{name:"clear",description:"Remove every annotation",type:"boolean",target:"clear"},{name:"replace",description:"Make the given pairs the whole set instead of merging them",type:"boolean",target:"replace"}],examples:[{name:"Show annotations",value:"phala annotations app_abc123"},{name:"Set annotations (CVM from phala.toml)",value:"phala annotations memory_tier=fast pin_numa=0"},{name:"Remove a key",value:"phala annotations app_abc123 --unset memory_tier"},{name:"Replace the whole set",value:"phala annotations app_abc123 memory_tier=fast --replace"},{name:"Remove every annotation",value:"phala annotations app_abc123 --clear"}]},Yy=tn.object({args:tn.array(tn.string()).default([]),"--":tn.array(tn.string()).default([]),unset:tn.array(tn.string()).optional(),clear:tn.boolean().default(!1),replace:tn.boolean().default(!1)});function M$(e){let[t,...n]=e,r=t!==void 0&&!t.includes("="),a=(r?n:e).map(s=>{let i=s.indexOf("=");if(i<0)throw new Error(`Expected KEY=VALUE, got '${s}'. Only the first argument can be a CVM id.`);return[s.slice(0,i),s.slice(i+1)]});return{cvmId:r?t:void 0,pairs:a}}function Xy(e,t){if(H()){e.success({annotations:t});return}let n=Object.entries(t);if(n.length===0){p.info("No annotations");return}for(let[r,o]of n)e.stdout.write(`${r}=${o}
417
- `)}async function D$(e,t){try{let{cvmId:n,pairs:r}=M$([...e.args,...e["--"]]),o=n?{id:n}:t.cvmId;if(!o)return t.fail("No CVM ID provided. Pass a CVM identifier or set it in phala.toml."),1;let a=e.unset??[];if(e.clear&&(r.length>0||a.length>0))return t.fail("--clear cannot be combined with KEY=VALUE pairs or --unset."),1;if(e.replace&&(r.length===0||a.length>0))return t.fail("--replace needs KEY=VALUE pairs and cannot be combined with --unset."),1;let s=await E(t),i=e.clear||r.length>0||a.length>0,c={};if(!e.clear&&!e.replace){let u=await ti(s,o);if(!u.success)throw u.error;if(c=u.data.annotations,!i)return Xy(t,c),0}let l={...c,...Object.fromEntries(r)};for(let u of a)delete l[u];let m=await ni(s,{...o,annotations:l});if(!m.success)throw m.error;return Xy(t,m.data.annotations),0}catch(n){return t.failWithError(n,{operation:"CVM annotations"}),1}}var Zy=b({path:["annotations"],meta:Jy,schema:Yy,handler:D$});var V$=j$(import.meta.url),F$=O$(V$),z$=N$(F$,"../package.json"),ss=JSON.parse(U$(z$,"utf-8")),K$="+af690f5",H$=`v${ss.version}${K$}`,q$=ia(),L=new pa;L.registerCommand(ff);L.registerCommand(kh);L.registerGroup(xh);L.registerCommand(Mh);L.registerCommand(Oh);L.registerCommand(Vh);L.registerCommand(qh);L.registerCommand(eg);L.registerCommand(oh);L.registerCommand(ch);L.registerCommand(ph);L.registerCommand(gh);L.registerCommand(Jh);L.registerCommand(Bf);L.registerCommand(rg);L.registerCommand(Gg);L.registerCommand(pc);L.registerCommand(dc);L.registerCommand(gc);L.registerCommand(hc);L.registerCommand(Jg);L.registerCommand(Pu);L.registerCommand(Lg);L.registerCommand(Sy);L.registerCommand(Xg);L.registerCommand(Ag);L.registerCommand(Wy);L.registerCommand(Zy);L.registerCommand(Kf);L.registerGroup(wc.group);for(let e of wc.commands)L.registerCommand(e);L.registerGroup($i.group);for(let e of $i.commands)L.registerCommand(e);L.registerGroup(Mi.group);for(let e of Mi.commands)L.registerCommand(e);L.registerGroup(Ji.group);for(let e of Ji.commands)L.registerCommand(e);L.registerGroup(Ra.group);for(let e of Ra.commands)L.registerCommand(e);for(let e of Ra.subgroups??[]){L.registerGroup(e.group);for(let t of e.commands)L.registerCommand(t)}L.registerGroup(_c.group);for(let e of _c.commands)L.registerCommand(e);L.registerGroup(Yi.group);for(let e of Yi.commands)L.registerCommand(e);L.registerGroup(xc.group);for(let e of xc.commands)L.registerCommand(e);L.registerGroup(ac.group);for(let e of ac.commands)L.registerCommand(e);L.registerGroup(ic.group);for(let e of ic.commands)L.registerCommand(e);L.registerGroup(lc.group);for(let e of lc.commands)L.registerCommand(e);L.registerGroup(Uc.group);for(let e of Uc.commands)L.registerCommand(e);process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function is(e){e.destroyed||e.writableLength===0||await Promise.race([L$(e,"drain"),new Promise(t=>setTimeout(t,5e3))])}async function G$(){await wu({env:process.env,stderr:process.stderr});let e=await yu({registry:L,argv:process.argv.slice(2),executableName:ss.name??"phala",version:H$,packageName:ss.name??"phala",packageVersion:ss.version,runtime:q$,cwd:process.cwd(),env:process.env,stdout:process.stdout,stderr:process.stderr,stdin:process.stdin});await Promise.all([is(process.stdout),is(process.stderr)]),process.exit(e)}G$().catch(async e=>{console.error("An error occurred:",e),await Promise.all([is(process.stdout),is(process.stderr)]),process.exit(1)});
416
+ `)}async function D$(e,t){try{let{cvmId:n,pairs:r}=M$([...e.args,...e["--"]]),o=n?{id:n}:t.cvmId;if(!o)return t.fail("No CVM ID provided. Pass a CVM identifier or set it in phala.toml."),1;let a=e.unset??[];if(e.clear&&(r.length>0||a.length>0))return t.fail("--clear cannot be combined with KEY=VALUE pairs or --unset."),1;if(e.replace&&(r.length===0||a.length>0))return t.fail("--replace needs KEY=VALUE pairs and cannot be combined with --unset."),1;let s=await E(t),i=e.clear||r.length>0||a.length>0,c={};if(!e.clear&&!e.replace){let u=await ti(s,o);if(!u.success)throw u.error;if(c=u.data.annotations,!i)return Xy(t,c),0}let l={...c,...Object.fromEntries(r)};for(let u of a)delete l[u];let m=await ni(s,{...o,annotations:l});if(!m.success)throw m.error;return Xy(t,m.data.annotations),0}catch(n){return t.failWithError(n,{operation:"CVM annotations"}),1}}var Zy=b({path:["annotations"],meta:Jy,schema:Yy,handler:D$});var V$=j$(import.meta.url),F$=O$(V$),z$=N$(F$,"../package.json"),ss=JSON.parse(U$(z$,"utf-8")),K$="+2657978",H$=`v${ss.version}${K$}`,q$=ia(),L=new pa;L.registerCommand(ff);L.registerCommand(kh);L.registerGroup(xh);L.registerCommand(Mh);L.registerCommand(Oh);L.registerCommand(Vh);L.registerCommand(qh);L.registerCommand(eg);L.registerCommand(oh);L.registerCommand(ch);L.registerCommand(ph);L.registerCommand(gh);L.registerCommand(Jh);L.registerCommand(Bf);L.registerCommand(rg);L.registerCommand(Gg);L.registerCommand(pc);L.registerCommand(dc);L.registerCommand(gc);L.registerCommand(hc);L.registerCommand(Jg);L.registerCommand(Pu);L.registerCommand(Lg);L.registerCommand(Sy);L.registerCommand(Xg);L.registerCommand(Ag);L.registerCommand(Wy);L.registerCommand(Zy);L.registerCommand(Kf);L.registerGroup(wc.group);for(let e of wc.commands)L.registerCommand(e);L.registerGroup($i.group);for(let e of $i.commands)L.registerCommand(e);L.registerGroup(Mi.group);for(let e of Mi.commands)L.registerCommand(e);L.registerGroup(Ji.group);for(let e of Ji.commands)L.registerCommand(e);L.registerGroup(Ra.group);for(let e of Ra.commands)L.registerCommand(e);for(let e of Ra.subgroups??[]){L.registerGroup(e.group);for(let t of e.commands)L.registerCommand(t)}L.registerGroup(_c.group);for(let e of _c.commands)L.registerCommand(e);L.registerGroup(Yi.group);for(let e of Yi.commands)L.registerCommand(e);L.registerGroup(xc.group);for(let e of xc.commands)L.registerCommand(e);L.registerGroup(ac.group);for(let e of ac.commands)L.registerCommand(e);L.registerGroup(ic.group);for(let e of ic.commands)L.registerCommand(e);L.registerGroup(lc.group);for(let e of lc.commands)L.registerCommand(e);L.registerGroup(Uc.group);for(let e of Uc.commands)L.registerCommand(e);process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function is(e){e.destroyed||e.writableLength===0||await Promise.race([L$(e,"drain"),new Promise(t=>setTimeout(t,5e3))])}async function G$(){await wu({env:process.env,stderr:process.stderr});let e=await yu({registry:L,argv:process.argv.slice(2),executableName:ss.name??"phala",version:H$,packageName:ss.name??"phala",packageVersion:ss.version,runtime:q$,cwd:process.cwd(),env:process.env,stdout:process.stdout,stderr:process.stderr,stdin:process.stdin});await Promise.all([is(process.stdout),is(process.stderr)]),process.exit(e)}G$().catch(async e=>{console.error("An error occurred:",e),await Promise.all([is(process.stdout),is(process.stderr)]),process.exit(1)});
418
417
  /*! Bundled license information:
419
418
 
420
419
  @noble/hashes/esm/utils.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phala",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "CLI for Managing Phala Cloud Services",
5
5
  "author": {
6
6
  "name": "Phala Network",
@@ -47,7 +47,7 @@
47
47
  "@iarna/toml": "^2.2.5",
48
48
  "@michaelhomer/jqjs": "^1.5.0",
49
49
  "@noble/curves": "^1.8.1",
50
- "@phala/cloud": "^0.4.0",
50
+ "@phala/cloud": "^0.5.0",
51
51
  "arg": "^5.0.2",
52
52
  "chalk": "5.2.0",
53
53
  "dedent": "^1.7.0",