icoa-cli 2.19.342 → 2.19.344

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.
@@ -1 +1 @@
1
- (function(j,k){const a0=a0k,q=j();while(!![]){try{const v=parseInt(a0(0x17c))/(-0x2405+-0x1a+0x242*0x10)+-parseInt(a0(0x173))/(-0x1e2e+-0x46e+0xe*0x279)+parseInt(a0(0x1a4))/(0x2*0x12ae+0x1b63+-0x40bc)+parseInt(a0(0x148))/(0xb*0x7+-0x1e11+0x1dc8)*(-parseInt(a0(0x20a))/(0x1*-0x1c47+-0xdca+-0x1*-0x2a16))+parseInt(a0(0x1a0))/(0x2d7+-0xac2+-0x1*-0x7f1)+parseInt(a0(0x21e))/(-0x11df+-0x35*-0x26+0xa08)+parseInt(a0(0x15b))/(0x1644+0x700+0xe9e*-0x2)*(-parseInt(a0(0x1c5))/(0x2*-0x119d+-0x182*0x19+0x3d7*0x13));if(v===k)break;else q['push'](q['shift']());}catch(x){q['push'](q['shift']());}}}(a0j,0x20b19+0x16ef53+-0xaf8ee));import a0v from'chalk';import{createChatSession as a0x}from'../lib/gemini.js';import{addTokenUsage as a0z}from'../lib/budget.js';import{getConfig as a0A,isConnected as a0B}from'../lib/config.js';import{logCommand as a0C,logSubmission as a0D}from'../lib/logger.js';import{printMarkdown as a0E,printError as a0F}from'../lib/ui.js';import{t as a0G}from'../lib/i18n.js';function a0k(a,b){a=a-(-0x35*0x68+-0x5*-0x1cd+-0x1*-0xdac);const c=a0j();let d=c[a];if(a0k['sbLQvm']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=-0xbff+0x1449+-0x84a*0x1,o,p,q=-0x89*0x7+0x5e0+-0x221;p=i['charAt'](q++);~p&&(o=n%(0x72f+0x517*-0x7+-0x1c76*-0x1)?o*(0x7b5+-0x1*0xc27+0x4b2)+p:p,n++%(0x685+0x882+-0xf03))?l+=String['fromCharCode'](-0x5*-0x62e+-0x267*0x8+-0xaaf&o>>(-(0xa57+-0x200f+0x67*0x36)*n&-0x253c+-0x7df*0x4+0x44be)):-0x8be+-0x2397+-0x369*-0xd){p=j['indexOf'](p);}for(let r=-0x253*-0x5+-0x48*0x7f+-0x1*-0x1819,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](0x1733+-0x7*-0x4ca+-0x38a9))['slice'](-(0x2594+0x5*0x5d2+-0x42ac));}return decodeURIComponent(m);};a0k['aLYiYD']=e,a0k['CWtIKl']={},a0k['sbLQvm']=!![];}const f=c[0x153e+0x51e+-0x1a5c],g=a+f,h=a0k['CWtIKl'][g];return!h?(d=a0k['aLYiYD'](d),a0k['CWtIKl'][g]=d):d=h,d;}const g=j=>new Promise(k=>setTimeout(k,j));let r=!(-0xbff+0x1449+-0x2c3*0x3),h=null,u=-0x89*0x7+0x5e0+-0x221,y=!(0x72f+0x517*-0x7+-0x1c73*-0x1);function a0j(){const ag=['lNr4DcbPBNnPzguGDgHLignVBNrLC3rHBNqNCYbZyw5KyM94iokaLcbWyxrOigLZihjLBgf0AxzLihrVihrOzsbZyw5KyM94j3mGl2HVBwuVy29TCgv0AxrVCIb3B3jRAw5NigrPCMvJDg9YEsWGCMvHy2HHyMXLigzYB20Gyw55icfZAgvSBcaVicfWExrOB24ZigLUDM9JyxrPB24PoGO','icaG4OAsia','y2XLyxi','DhLWzq','icaGicaGicaGicblzxKGyNjLywT0AhjVDwDOicHWCMuTD3jPDhrLBIK','ywrK','ywK0y3rMuMv2zwfSu2vLrMXHzW','icboBYbJAgfSBgvUz2uGAwqGAw4Gy29UDgv4DcdIGjqGB3bLBIbVBMuGzMLYC3q6ia','icbbssb0zwfTBwf0zsbJBg9ZzwqGzM9Yici','ywK0y3rMsgLUDem','icbezxrLy3rLzcbMBgfNiokaLcb0CMvHDgLUzYbHCZOG','qxnRihrOzsbbssb0zwfTBwf0zsbHyM91Dcb0AgLZignOywXSzw5Nzq','ywK0y3rMoIa','y2f0zwDVCNK','EwvSBg93','ywK0y3rMv2vSy29Tzun0yq','yxr0ywnOzwreyxrH','y3rMzfvYBa','y29YCMvJDa','ywK0y3rMrxHPDe5LEhrcB2r5','C3rHCNrZv2L0Aa','DhLWzufUzevUDgvYvg9czwDPBG','ywK0y3rMsgLUDee','icbvC2u6ia','Cu51Bq','ifn1yM1PDcb5B3vYigzSywCGzM9YihrOAxmGCxvLC3rPB24','Dg9Rzw4','ywK0y3rMv3jHCeXPBMuXqM9KEq','C3vIBwL0ia','B3jcywnR','Bg9N','icdINjmGuq','quKGzxjYB3i6ia','icaGigHPBNqGysaVigiGlYbJica','C2vZC2LVBJ0','yw5ZD2vYCW','ywK0y3rMtg9JA2vKvxnL','rNvSBcbXDwvZDgLVBJOGia','icbnB2rLBdOGr29Vz2XLieDLBw1HidqGka','icaGicaGicaGicfLy2HVigfxtNzzwhqZttj4AK1hmwXyEKPMwvDRmfKZuM1Mut09ihWGyMfZzty0ic1K','DgvZDa','lcbVCIbYzs1LBNrLCIb3AxrOia','zgvZy3jPChrPB24','zw50zxjLzef0','BwLU','BNvKz2vtAg93BG','BNvTyMvY','ue9tva','icbzB3uGy2fUihn0AwXSihn1yM1PDcbHigzSywCGzgLYzwn0BhK6ia','icaGigv4AxqGicaGicaGicaGica','ihrVig1VDMuGB24','ywK0y3rMsgLUDejcB2r5','ywK0y3rM','ww91igfYzsbHBIbbssb0zwfTBwf0zsbOzwXWAw5NigeGy29UDgvZDgfUDcbZB2X2zsbHBIbjq09bidiWmJyGy3LIzxjZzwn1CML0EsbLEgfTihf1zxn0Aw9UlGOkq1vsuKvovcbrvuvtveLptIaOuq','BMfTzq','icbpCgvUigfUB3rOzxiGy2HHBgXLBMDLihDPDgGG','ntGWvfDyu2jw','C3rKB3v0','ywK0y3rMrxHPDe5LEhrtDwi','iNDOyxqGzw5JB2rPBMCGAxmGDgHPCZ8I','z2vTAw5Ptw9KzwW','C2vUze1LC3nHz2u','BM9KztPJAgLSzf9WCM9JzxnZ','icaGidXQDxn0ihr5Cgu+icaGica','icdIMQaGodaLig9MihnLy3rPB24GquKGyNvKz2v0ihvZzwqU','ihb0CW','quKGyNvKz2v0icH0AgLZigfJy291BNqP','iMHVDYbKBYbjigrLy3j5ChqGquvtluncqYbPBIbqExrOB24/iG','y3LHBG','imk3ia','CM91BMq','ywK0y3rMrM91BMrgBgfN','icaGicaGicaGicbbigDLBNrSzsbUDwrNzsaOChjLlxDYAxr0zw4P','CxvLC3rPB25Z','y3rMngfP','icboB3rLoIa1mcuGB2yGC2vJDgLVBIbbssbIDwrNzxqGDxnLzc4','odiZmda0vuvUq2jO','CMvWBgfJzq','C29Tzq','icaGicaGia','ywK0y3rMq29YCMvJDezSywC','igfNywLUihrVignOyw5NzsWGB3iG','ywK0y3rMsgLUDencB2r5','ywK0y3rMq2HHBgXLBMDL','ywK0y3rMv3jHCff1B3rHqq','igzVCIbrmZK','D3jPDgu','ywK0y3rMsgLUDe5LEhrc','icbzB3uGy2fUihn0AwXSoIa','ywXYzwfKEv9ZB2X2zwq','icaGig1LBNu','ywK0y3rMtgv2zwXZ','ywK0y3rMsgLUDfbYAw5JAxbSzq','Dg9ju09tDhjPBMC','icdILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILia','ywK0y3rMv3jHCe5LEhrtDwi','icbr','icaGicaGigHPBNqGyIaGia','BgvUz3rO','iokaLcb0ExbLia','yM9Sza','ChvZAa','q2HHDcb3AxrOihLVDxiGquKGDgvHBw1HDgu','ywK0y3rMsgLUDefvC2vZ','lNr4DcaOAw5ZAwrLihrOzsbZyw5KyM94ksbYyxrOzxiGDgHHBIbHC2TPBMCGDgHLignVBNrLC3rHBNqGDg8GCgfZDguGDgHLihDOB2XLigjSB2iGyMfJAY4klsblzwvWihjLC3bVBNnLCYbJB25JAxnLigfUzcbWCMfJDgLJywWUifrOAxmGy29UDgvZDgfUDcbOyxmGBgLTAxrLzcb0Aw1LlG','z2v0q2HHBgXLBMDL','lZuWmda','ywK0y3rMsgLUDe5LEhrb','ywK0y3rMrw5Ku2vZC2LVBG','icbbssbIDwrNzxqGzxHOyxvZDgvKigzVCIbbstrdveyGC2vJDgLVBI4','ywLvC2fNzq','ywK0y3rMsgLUDenvC2vZ','ywK0y3rMuMv2zwfStg9JA05VDgu','lI4VBgLIl2v4yw0TC3rHDguUANm','y3vYCMvUDenOywXSzw5Nzu5HBwu','ywK0y3rMv3jHCff1B3rHqW','yvDoDLLyDdnnmNHQtuCXBfH6sMzzv2SWwtnsBwzrpt0','ywK0y3rMv3jHCe5VuhjVzW','yxbWBgLJyxrPB24VANnVBG','icaGihn1yM1PDca8zMXHzZ4Gica','CgfKrw5K','ywK0y3rMv3jHCff1B3rHqKHPBNq','icaGicaGicaHzwnOBYbHv052wvH0m00YEgPnrZfSwhPkzLLxAZbzm1jTzLe9psb8igjHC2u2ncaTza','y2f0y2G','icbbssb1C2fNzsbPCYbTzxrLCMvKihbLCIbHy2nVDw50icHZzxj2zxiTzw5MB3jJzwqGyNvKz2v0ks4','jsbVzIbZzwn0Aw9Uiefjigj1zgDLDcb1C2vKiokaLcbVBMX5ih4','igLZigeGBxvSDgLWBguTy2HVAwnLihf1zxn0Aw9UiokaLcbHBNn3zxiGD2L0Acbbl0iVqY9elG','xsaGWRCG','zMLUza','quK0q1rgihnLy3rPB24','iwvJAg8GyvDoDI4UlIb8igjHC2u2ncaTza','q3j5ChrVz3jHCgH5','icbbzNrLCIbLEgL0oIbbstrdveyGC2vJDgLVBIbJB21WBgv0zs4GtMv4DdOG','icaGicaGicaGicaGieXLyxzLignOyxqSihjLDhvYBIb0BYbLEgfT','icaGicaGicaGicaGica','tgvHDMuGDgHLiefjihrLyw1TyxrL','icboBYbJAgfSBgvUz2uGB3bLBIb5zxqU','cGPzt1vsifjvtevtoGOTifLVDsbnqvKGzxHWBgfPBIbJB25Jzxb0CYWGzgvZy3jPyMuGyxbWCM9Hy2HLCYWGyw5KigHLBhaGDgHLignVBNrLC3rHBNqGCMvHC29UihrOCM91z2GGDgHLihbYB2jSzw0UcI0Gww91ie1bwsbKAxnJDxnZihrOzsb0zwnOBM9SB2D5igLUDM9SDMvKicHJCNLWDg8SihDLyIWGzM9Yzw5ZAwnZlcbWD24SihjLDMvYC2LUzYWGt1njtLqSihn0zwDVlcbLDgmUks4klsbzB3uGtufzigHLBhaGzgvIDwCGy29Kzsb0AguGy29UDgvZDgfUDcb3CML0zxmGyw5Kihn1z2DLC3qGD2HPy2GGDg9VBcaVigXPyNjHCNKGlYb0zwnOBMLXDwuGDg8GDxnLlGOTifLVDsbnvvnuie5pvcbYzxzLywWGB3iGz3vLC3mGDgHLigzSywCSigfUzcbnvvnuie5pvcbVDxrWDxqGyw55igzSywCTC2HHCgvKihn0CMLUzYaOyw55DgHPBMCGBgLRzsbUyw1LEY4UlN0PlGOTifLVDsbnvvnuie5pvcbZB2X2zsb0AguGD2HVBguGy2HHBgXLBMDLigvUzc10BY1LBMqGzM9YihrOzsbJB250zxn0yw50iokaLcbNDwLKzsWGzg9Uj3qGAgfUzcbVDMvYihrOzsbHBNn3zxiUcI0Gs2vLCcbYzxnWB25ZzxmGy29Uy2LZzsbHBMqGChjHy3rPy2fSlIbuAguGy29UDgvZDgfUDcbPCYbYywnPBMCGDgHLignSB2nRlG','ig5VDcbMB3vUzcbPBIbZDgf0zs4','ywK0y3rMv3jHCff1B3rHqG','icaOCMvZDw1PBMCG4OcuihbYAw9YignOyxqGAxmGBM90ihjLBwvTyMvYzwqSigj1Dcb0B2TLBNmGywXYzwfKEsb1C2vKihn0yxKGzgvKDwn0zwqP','icaGica','Dgv4Da','ywK0y3rMt3jdAgf0rxHHBxbSzq','ywK0y3rMrgvJB2rLza','CMf0zwXPBwL0zwq','E2nTzh0','z3jHEq','icdcTYaGuMuTzw50zxi6ia','zxHPDa','iIbSB29RCYbSAwTLigfUie1dusbSzxr0zxiSig5VDcbHigzSywCU','ywK0y3rMsw50zxjJzxb0zwq','zw5JB2rPBMC','iwvJAg8GyvDoDLLyDdnnmNHQtuCXBfH6sMzzv2SWwtnsBwzrpt0GFcbIyxnLnJqGlwq','ihrOzw4G','icaGicaGigHPBNqGysaGia','C2XPy2u','icbtDgLSBcbHDMfPBgfIBgu6ia','ywK0y3rMt3jdAgf0','y3vYCMvUDenOywXSzw5NzunHDgvNB3j5','z3jLzw4','C3vIBwL0ieLdt0f7Ew91CL9MBgfNFq','CMvK','mJu2odrby1jHA0C','ywK0y3rMv3jVBMDgBgfN','y3vYCMvUDenOywXSzw5NzuLK','C3bSAxq','B3bLBIa8Awq+','ywK0y3rMuMv2zwfSvgL0Bgu','icbiB3CGDg8GD29YAYb0AgLZihf1zxn0Aw9U','Aw5JB3jYzwn0','y3rMngvHAq','ywK0y3rMv3jHCff1B3rHq0HPBNq','ywK0y3rMuMv2zwfSqM9KEq','ihrOzw4GCMuTzw50zxiG','icaGicaGicaGicbuzwnOBMLXDwuGAgLUDcaOChjLlxDYAxr0zw4P','icbbstrdveyGy2HHDcbLBMrLzcbMB3iGuq','g1SXqrTBmKS','sgLKzgvUie1LC3nHz2u','icbpCgvUig9UzsbMAxjZDdOG','vw5RBM93BIbYzxnWB25Zzq','yMfJAW','mJyWmdC3nNLVveXbwG','y2HHBgXLBMDLtMfTzq','Dg9Rzw5mAw1PDa','ywK0y3rMv3jHCff1B3rHC1rPDgXL','cGPbvfrbq0HfrcbeqvrbicHHBhnVihnHDMvKihrVignOywXSzw5NzxmVCq','icbbBhjLywr5ihnVBhzLzc4','Aw50zxjHy3rPB25Z','BwvZC2fNzq','ywK0y3rMq21Ku2HLBgXmAw5L','ywK0y3rMvgHPBMTPBMC','icaGicaGicaGicaGicaGicaGicbLlMCUia','ywK0y3rMrxHPDa','ywK0y3rMtw9KzwW','DgLTzw91Da','Dg9mB3DLCKnHC2u','D2HPDgu','zxHHBsbXia','ieLdt0f7lI4UFq','ihbVAw50CYK6cG','icbsyxrLigXPBwL0zwqG4OcuihDHAxqGysbTB21LBNqGyMvMB3jLihrYEwLUzYbHz2fPBI4','C3vIBwL0qxr0zw1WDgvK','ywK0y3rMrMXHz0HPBNq','ywK0y3rMv291BgrfyxjU','icbvC2fNztOG','nduXndeWwNzZq09Q','x2XHC3rr','icdILiZILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILia','ywK0y3rMv3jHCff1B3rHquHPBNq','ywK0y3rMsgLUDfrLy2HUAxf1zq','y29TBwfUza','AM9PBG','ywK0y3rMvgL0Bgu','igLZigeGq1rgnefjihf1zxn0Aw9UicHHDhrHy2STDgHLlufjks4','mteZmdu0nMTwBNHMvq','C3rYAw5NAwz5','DhjPBq','icaGicaGicaGicaGifjLDhvYBIb0BYbTywLUig1LBNuGkhDVCMTZigfUExDOzxjLkq','ig5VDcbMB3vUzcbPBIbZDgf0zs4Gvhj5oIbLEgfTiheG','BM93','iIaOy2f0zwDVCNK6ia','ywK0y3rMvg9Rzw5Z','C3vIBwL0rMXHzW','icdILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILia','ywK0y3rMv3jHCeXPBMuXsgvHza','lI4VBgLIl2LUDgvNCML0Es1ZBMfWC2HVDc5QCW','C3vIBwL0idXMBgfNpG','DgHPBMTPBMC','y2HHBgXLBMDLswq','AgLUDcbI','icaGicaGicbZDwjTAxqGAwnVyxT3m2XJmg1LxZjFywK0y3rMFq','icaGicaODhLWzsbPDcbYAwDODcbOzxjLigLUihrOAxmGy2HHDcdIGjqGBM90igfZigeGC2HLBgWGy29TBwfUzcK','DxrMltG','Ahr0Chm6lY9WCMfJDgLJzs5Py29HmJaYnI5HDs9HCgKVAwnVys9Kzw1Vlxn0yxrZ','icaGigHPBNqGyW','icbgBgfNigzVCM1HDdOG','icdIMQaG','ywK0y3rMv3jHCff1B3rHrM9VDgvY','icaGicfWExrOB24Zic4UlG','y29UDgLUDwu','ywK0y3rMv3jHCe5LEhruAxrSzq','rMXHzYbMB3jTyxq6icaGieLdt0f7lI4UFq','iokvKokvKokvKa','icaGidiUia','C3rHDhvZ','icaGicbsDw4GuhL0Ag9UigLUihnOzwXS','icbuAgLUA2LUzY4UlG','icaI','icaGigv4Axq','lI4VBgLIl2n0zMqTy2XPzw50lMPZ','nti1mtC0me5nAgzryG','y3rMigXPC3q','icdILiiG','Bwf0y2G','mti0ntyZovrMEuz3rq','ywn0Aw9U','AwnVyxT3m2XJmg1LxZjFywK0y3rMFq','icbszxn1Bwu6ia','icaGia','icaKia','ywK0y3rMrxHPDe5LEhruAxrSzq','yw5ZD2vYx2nOyw5Nzwq','z2vTBweTnc0ZmwiTAxq','CxvPDa','ywK0y3rMq29TBwfUzhm','CMvWzwf0','icbfCNjVCJOG','icdIMQaGww91CIbbstrdveyGDg9Rzw4GyNvKz2v0igLZigv4Agf1C3rLzc4','vw5RBM93BG','ywK0y3rMq21KsgLUDeXPBMu','icbdDxjYzw50igfUC3DLCJOG','ihjLy29YzgvKoIa','AgfZ','icdINjmGqw5ZD2vYigzVCIbr','ixnOzwXS','Cg9PBNrZ','icaGigHPBNqGyG','Dg9Rzw5ZvxnLza','icaGigHPBNqGyq','C3vIBwL0igLJB2f7DZnSyZbTzv8Yx2fPngn0zN0','cGPzt1vsifjvtevtoGOTifLVDsbnqvKGzxHWBgfPBIbJB25Jzxb0CYWGzgvZy3jPyMuGyxbWCM9Hy2HLCYWGyw5KigHLBhaGDgHLignVBNrLC3rHBNqGCMvHC29UihrOCM91z2GGDgHLihbYB2jSzw0UcI0Gww91ie1bwsbKAxnJDxnZihrOzsb0zwnOBM9SB2D5igLUDM9SDMvKicHbrvmSihb3BNrVB2XZlcbqExrOB24GC3rYDwn0lcbivfrqlcbLDgmUks4klsbzB3uGtufzigHLBhaGzgvIDwCGuhL0Ag9UignVzguGDgHLignVBNrLC3rHBNqGD3jPDgvZlGOTifLVDsbnvvnuie5pvcbYzxzLywWGDgHLigzSywCGzgLYzwn0BhKUcI0Gww91ie1vu1qGtK9uig91Dhb1DcbHBNKGC3rYAw5Nig1HDgnOAw5NieLdt0f7lI4UFsbVCIbPy29HEY4UlN0UcI0Gww91ie1vu1qGtK9uihrLBgWGDgHLignVBNrLC3rHBNqGDgHLigv4ywn0igfUC3DLCIb0BYb0AgLZihf1zxn0Aw9UlGOTifLVDsbnqvKGC3vNz2vZDcb3AgLJAcb0B29Sic8GBgLICMfYEsaVihrLy2HUAxf1zsb0BYb1C2uUcI0Gv2HLBIbZDwDNzxn0Aw5NihnOzwXSic8GChL0Ag9UihnUAxbWzxrZihrOyxqGBMvLzcb0AguGyxr0ywnOzwqGzgf0ysWGCMvMzxiGDg8GDgHLigzPBguGCgf0AcbJAgfSBgvUz2vZl3e','iokaLca','ihrVA2vUCYbSzwz0lG','q29UDgvUDc1uExbL','icaGihn1yM1PDcbjq09bEY4UlN0','u2nVCgvKihrVihrOzsbJAgfSBgvUz2uGEw91ig9Wzw5Lzc4GqxnRigzYzwvSEsdIGjq','AgLUDcbJ','mtHouKPwAfK','icbozxH0oIa','icdILzdILzdILzaGquK0q1rgiokaLcbr','icbdB21WzxrPDgLVBIbPCYbWyxvZzwqU','icdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILza','icdILjtILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILia','ww91igfYzsbHBIbbssb0zwfTBwf0zsbOzwXWAw5NigeGy29UDgvZDgfUDcbPBIbHigXPDMuGq2fWDhvYzs1uAguTrMXHzYbJB21WzxrPDgLVBI4kcKnvuLjftLqGq0HbteXftKDfoIaI','icaGice8C2HLBgWGy21KpIaGica','icdILii','Aw5JBhvKzxm','C2vZC2LVBKnVB2TPzq','icbtD2L0y2GGy2HHBgXLBMDLoIa','icaGifbYzxzPB3vZoIa'];a0j=function(){return ag;};return a0j();}const d=0x2689+-0x1*0x3cc2+0x77e1;let m=null,f=null;export function isChatActive(){return r;}function w(){const a1=a0k,j=m?d:f?0x29b66+0x3670d+0x1cd8d:-0x5*-0x62e+-0x267*0x8+0x7da,k=u,q=Math[a1(0x1fe)](Math[a1(0x218)](k/j*(0xa57+-0x200f+0x11b*0x14)),-0x253c+-0x7df*0x4+0x451c),v=Math['round'](q/(-0x8be+-0x2397+-0x2cb9*-0x1)*(-0x253*-0x5+-0x48*0x7f+-0x1*-0x182d)),x=0x1733+-0x7*-0x4ca+-0x38a5-v,z=q>0x2594+0x5*0x5d2+-0x425e?a0v[a1(0x147)]:q>0x153e+0x51e+-0x1a2a?a0v['yellow']:a0v[a1(0x145)],A=m?a1(0x126):f?a1(0x214):'Tokens';console[a1(0x1f0)](a0v[a1(0x138)]('\x20\x20'+A+':\x20')+z('█'['repeat'](v))+a0v[a1(0x138)]('░'[a1(0x1af)](x))+a0v['gray']('\x20'+k+'/'+j+'\x20('+q+'%)'));}export async function handleChatMessage(v){const a2=a0k;if(!h)return a2(0x13a);if(a0C(a2(0x1de)+v),m)return b(v);if(f)return async function(C){const a3=a2;if(!f||!h)return a3(0x13a);const D=C['trim'](),E=D['toLowerCase'](),F=D[a3(0x1a3)](/^submit\s+(.+)/i);if(F){let G=F[-0xb7b*0x2+0xa7*0x1+0x1650][a3(0x17e)]();if(/^submit\s+/i[a3(0x1fa)](G)&&(G=G['replace'](/^submit\s+/i,'')['trim']()),G=G[a3(0x21f)](/^["'`]+|["'`]+$/g,'')[a3(0x17e)](),!G)return console['log'](),console[a3(0x1f0)](a0v['gray'](a3(0x172))+a0v[a3(0x16a)](a3(0x188))),console[a3(0x1f0)](),'continue';const H=f[a3(0x18a)];if(!H)return console[a3(0x1f0)](),console['log'](a0v[a3(0x1e0)](a3(0x1d9))+a0v[a3(0x16a)]('open\x20<id>')),console['log'](),a3(0x195);a0D(H,G);const I=a0A();try{const {CTFdClient:J}=await import(a3(0x19f)),K=I[a3(0x1cf)]||'',L=I['token']&&!I[a3(0x1ec)][a3(0x1ce)](a3(0x1f4))?I[a3(0x1ec)]:'',M=new J(I[a3(0x1e3)],L,K||I[a3(0x1ec)]),N=await M[a3(0x184)](H,G);switch(console[a3(0x1f0)](),N[a3(0x19a)]){case a3(0x1e4):console[a3(0x1f0)](a0v[a3(0x145)][a3(0x236)]('\x20\x20🎉\x20Correct!\x20')+a0v['white'](N[a3(0x162)]||''));break;case a3(0x14f):console[a3(0x1f0)](a0v[a3(0x147)]('\x20\x20✗\x20Incorrect.\x20')+a0v[a3(0x138)](N[a3(0x162)]||''));break;case a3(0x22b):console[a3(0x1f0)](a0v[a3(0x1e0)](a3(0x160)));break;case'paused':console[a3(0x1f0)](a0v[a3(0x1e0)](a3(0x1c8)));break;case a3(0x136):console[a3(0x1f0)](a0v[a3(0x1e0)](a3(0x16e)));break;default:console['log'](a0v[a3(0x138)]('\x20\x20'+(N[a3(0x162)]||a3(0x159))));}console['log']();const {postIntegritySnapshot:O}=await import(a3(0x187));await O();}catch(P){console['log'](),console[a3(0x1f0)](a0v[a3(0x147)]('\x20\x20Submission\x20failed:\x20'+(P[a3(0x162)]?.['split']('\x0a')[-0xb*-0x10a+-0x1965+0xdf7*0x1]||'unknown\x20error'))),console['log']();}return a3(0x195);}if(C[a3(0x1e6)]('!')){const Q=C[a3(0x141)](-0x56*-0x6d+-0x19a5+-0x75*0x18)[a3(0x17e)]();if(!Q)return a3(0x195);try{const R={};R['encoding']='utf-8',R[a3(0x168)]=0x2710;const {execSync:S}=await import(a3(0x210)),T=S(Q,R)[a3(0x17e)]();console[a3(0x1f0)](),console[a3(0x1f0)](a0v['gray'](a3(0x1a9))+a0v[a3(0x16a)](Q)),console[a3(0x1f0)](a0v[a3(0x16a)]('\x20\x20'+T[a3(0x14b)]('\x0a')[a3(0x179)]('\x0a\x20\x20'))),console[a3(0x1f0)]();}catch(U){console[a3(0x1f0)](),console[a3(0x1f0)](a0v['red'](a3(0x1b0)+(U[a3(0x162)]?.[a3(0x14b)]('\x0a')[0x1*-0xc99+0x16ef+-0xa56]||'Command\x20failed'))),console[a3(0x1f0)]();}return'continue';}if('exit'===E||a3(0x15a)===E||a3(0x1ad)===E){const V=f[a3(0x15c)];return r=!(-0x18d7+-0x1595+0x2e6d),h=null,f=null,console[a3(0x1f0)](),console[a3(0x1f0)](a0v[a3(0x138)](a3(0x1da)+V+'\x22.')),console['log'](a0v[a3(0x138)](a3(0x209))+a0v[a3(0x16a)](a3(0x14c))+a0v[a3(0x138)](a3(0x1fb))+a0v['white'](a3(0x206))),console[a3(0x1f0)](),a3(0x13a);}console[a3(0x1f0)](a0v['gray']('\x20\x20'+a0G(a3(0x164))));try{const W=await h[a3(0x20f)](C);process['stdout'][a3(0x228)](a3(0x156)),u+=W[a3(0x1bb)],a0z(W[a3(0x1bb)]),console[a3(0x1f0)](),a0E(W[a3(0x133)]),w(),console[a3(0x1f0)]();}catch(X){process[a3(0x20b)][a3(0x228)](a3(0x156)),a0F(a3(0x1f2)+X['message']),console[a3(0x1f0)]();}return a3(0x195);}(v);const x=v['trim']()[a2(0x169)]()[a2(0x1a3)](/^hint\s+([abc])$/);if(x)return function(C){const a4=a2,D=a0G('a'===C?'ai4ctfHintA':'b'===C?'ai4ctfHintB':a4(0x1db)),E=a0G('a'===C?'ai4ctfHintABody':'b'===C?a4(0x205):a4(0x224)),F='Hint\x20'+C['toUpperCase'](),G='a'===C?a0v[a4(0x145)]:'b'===C?a0v[a4(0x1e0)]:a0v[a4(0x147)];console[a4(0x1f0)](),console[a4(0x1f0)](G['bold']('\x20\x20▸\x20'+F+'\x20\x20')+a0v['gray'](D)),console[a4(0x1f0)]();for(const H of E['split']('\x0a'))''===H?console['log']():console[a4(0x1f0)](a0v['white'](a4(0x1a8)+H));console[a4(0x1f0)](),'a'===C?(console[a4(0x1f0)](a0v[a4(0x138)](a4(0x1a8)+a0G(a4(0x23d))+'\x20')+a0v[a4(0x216)](a4(0x18b))),console[a4(0x1f0)]()):'b'===C&&(console['log'](a0v[a4(0x138)](a4(0x1a8)+a0G(a4(0x229))+'\x20')+a0v[a4(0x216)](a4(0x1c4))),console[a4(0x1f0)]());}(x[-0x952*0x2+0x2*0x85+0x119b]),a2(0x195);const z=v[a2(0x1a3)](/^submit\s+(.+)/i);if(z){let C=z[-0x209b+-0x332+0x23ce][a2(0x17e)]();if(/^submit\s+/i['test'](C)&&(C=C['replace'](/^submit\s+/i,'')[a2(0x17e)]()),C=C[a2(0x21f)](/^["'`]+|["'`]+$/g,'')[a2(0x17e)](),a2(0x1a6)===C){console[a2(0x1f0)](),console[a2(0x1f0)](a0v[a2(0x145)][a2(0x236)](a2(0x1c9))),console['log'](a0v['green'][a2(0x236)]('\x20\x20'+a0G(a2(0x222)))),console[a2(0x1f0)](a0v[a2(0x145)][a2(0x236)](a2(0x1c9))),console[a2(0x1f0)](),console[a2(0x1f0)](a0v[a2(0x16a)]('\x20\x20'+a0G(a2(0x135)))),console[a2(0x1f0)](a0v['gray']('\x20\x20'+a0G(a2(0x171)))),console[a2(0x1f0)](),w(),r=!(0x335*0x5+0x1f5+-0x11fd),h=null,fetch(a2(0x18f),{'method':a2(0x201),'headers':{'Content-Type':a2(0x248)},'body':JSON['stringify']({'type':a2(0x206),'solved':!(0x1ed9+0x2619+-0x44f2),'tokensUsed':u,'timestamp':new Date()['toISOString']()}),'signal':AbortSignal['timeout'](-0x2*0x97b+-0x3f6+0x2*0x153a)})[a2(0x24d)](()=>{}),await g(0x882+-0x7*-0xea+-0x90c),console[a2(0x1f0)](),console[a2(0x1f0)](a0v['cyan']('\x20\x20─────────────────────────────────────────────')),console[a2(0x1f0)](a0v[a2(0x236)][a2(0x16a)]('\x20\x20'+a0G('ai4ctfWrapTitle'))),console[a2(0x1f0)](a0v[a2(0x216)](a2(0x230))),console[a2(0x1f0)]();const D=a0G(a2(0x186)),E=a0G(a2(0x1ed));console[a2(0x1f0)](a0v[a2(0x16a)]('\x20\x20\x20\x201.\x20'+D+'\x20')+a0v[a2(0x138)](E[a2(0x14b)]('\x0a')[0x259c+-0x1e02+0x8b*-0xe]||''));for(const I of E[a2(0x14b)]('\x0a')[a2(0x141)](0x5bd+0x12b2+-0x186e))I[a2(0x17e)]()&&console[a2(0x1f0)](a0v[a2(0x138)](a2(0x221)+I[a2(0x21f)](/\{thinking\}/g,a2(0x189))));console[a2(0x1f0)](),console[a2(0x1f0)](a0v[a2(0x16a)](a2(0x199)+a0G('ai4ctfWrapLine2Head')+'\x20')+a0v[a2(0x138)](a0G('ai4ctfWrapLine2Body'))),console[a2(0x1f0)](),console[a2(0x1f0)](a0v[a2(0x216)](a2(0x1f9))),console['log'](),await g(0xeb3*0x1+0x92*-0x25+0xe37),console['log'](a0v['cyan'](a2(0x230))),console[a2(0x1f0)](a0v[a2(0x236)]['white']('\x20\x20'+a0G(a2(0x15e)))),console[a2(0x1f0)](a0v['cyan'](a2(0x230))),console[a2(0x1f0)](),console[a2(0x1f0)](a0v['yellow'](a2(0x140))+a0v[a2(0x16a)](a0G(a2(0x226))['padEnd'](-0xe5d*-0x1+0x16f1+-0x2*0x129a))+a0v['gray'](a0G(a2(0x176)))),console[a2(0x1f0)](a0v[a2(0x1e0)](a2(0x233))+a0v[a2(0x16a)](a0G(a2(0x130))[a2(0x24a)](-0xcc3+0x2465+0x6*-0x3ec))+a0v[a2(0x138)](a0G(a2(0x24b)))),console['log'](a0v[a2(0x1e0)]('\x20\x20\x20\x20\x20\x20\x20hint\x20c\x20\x20\x20')+a0v[a2(0x16a)](a0G(a2(0x245))[a2(0x24a)](0x6dd+-0x2*-0xc6d+0x1*-0x1f9d))+a0v[a2(0x138)](a0G(a2(0x151)))),console[a2(0x1f0)]();for(const J of a0G(a2(0x193))[a2(0x14b)]('\x0a'))console[a2(0x1f0)](a0v[a2(0x138)](a2(0x1a8)+J));console[a2(0x1f0)](),await g(-0x7f7+-0x1b*-0xbb+-0x3f2),console[a2(0x1f0)](a0v['cyan'](a2(0x230))),console[a2(0x1f0)](a0v[a2(0x236)][a2(0x16a)]('\x20\x20'+a0G(a2(0x196))+'\x20')+a0v[a2(0x147)]['bold'](a2(0x21c))+a0v[a2(0x16a)](a2(0x1bf)+a0G(a2(0x231)))),console[a2(0x1f0)](a0v[a2(0x216)](a2(0x230))),console[a2(0x1f0)]();const F=a0G('ai4ctfWrapNextBody'),G=a0G(a2(0x247)),H=F[a2(0x14b)]('\x0a');if(H[0x1*0x13d9+0x383*0x9+-0xb2*0x4a]){const [K,L]=H[0xdfa*-0x2+-0xd*0xa4+0x2448][a2(0x14b)]('{noProg}');console[a2(0x1f0)](a0v[a2(0x16a)](a2(0x1a8)+(K||''))+a0v[a2(0x236)][a2(0x16a)](G)+a0v[a2(0x16a)](L||''));}for(const M of H[a2(0x141)](0xb*-0x249+-0xc*-0x1fb+0x160*0x1))M[a2(0x17e)]()&&console[a2(0x1f0)](a0v[a2(0x16a)](a2(0x1a8)+M));return console['log'](),console[a2(0x1f0)](a0v['gray'](a2(0x1a8)+a0G('ai4ctfWrapTypeCtf4ai')+'\x20')+a0v[a2(0x236)][a2(0x147)](a2(0x21c))),console[a2(0x1f0)](),a2(0x13a);}return console[a2(0x1f0)](),console[a2(0x1f0)](a0v[a2(0x147)]('\x20\x20'+a0G(a2(0x149)))),console['log'](a0v['gray']('\x20\x20'+a0G(a2(0x170)))),console[a2(0x1f0)](),a2(0x195);}if(v['startsWith']('!')){const N=v[a2(0x141)](-0x337*0x3+0x1b*-0x163+0x2f17)[a2(0x17e)]();if(!N)return a2(0x195);try{const O={};O[a2(0x13d)]=a2(0x18e),O['timeout']=0x2710;const {execSync:P}=await import(a2(0x210)),Q=P(N,O)[a2(0x17e)]();console[a2(0x1f0)](),console[a2(0x1f0)](a0v[a2(0x138)](a2(0x1a9))+a0v[a2(0x16a)](N)),console[a2(0x1f0)](a0v[a2(0x16a)]('\x20\x20'+Q[a2(0x14b)]('\x0a')[a2(0x179)]('\x0a\x20\x20'))),console[a2(0x1f0)](),console[a2(0x1f0)](a0v[a2(0x138)]('\x20\x20'+a0G(a2(0x219)))),console[a2(0x1f0)]();}catch(R){console[a2(0x1f0)](),console[a2(0x1f0)](a0v[a2(0x147)](a2(0x1b0)+(R['message']?.['split']('\x0a')[-0x97*-0x7+0x1*0x1a06+-0x1e27]||'Command\x20failed'))),console[a2(0x1f0)]();}return a2(0x195);}const A={};A[a2(0x1c1)]=a2(0x248);if(a2(0x13a)===v||a2(0x15a)===v||a2(0x1ad)===v||'menu'===v)return r=!(0x2*0x433+-0x5*0x571+-0xe*-0x158),h=null,fetch(a2(0x18f),{'method':'POST','headers':A,'body':JSON[a2(0x17d)]({'type':a2(0x206),'tokensUsed':u,'timestamp':new Date()[a2(0x22f)]()}),'signal':AbortSignal[a2(0x168)](0x1*0xc27+-0xc0e*0x1+0x136f)})['catch'](()=>{}),console[a2(0x1f0)](),console[a2(0x1f0)](a0v[a2(0x138)](a2(0x185))),console[a2(0x1f0)](a0v[a2(0x16a)]('\x20\x20'+a0G('ai4ctfReport'))),console[a2(0x1f0)](a0v['gray']('\x20\x20'+a0G(a2(0x183))+':\x20'+u+a2(0x23c))),console['log'](a0v[a2(0x138)]('\x20\x20'+a0G(a2(0x167))+':\x20Google\x20Gemma\x204\x20(gemma-4-31b-it)')),console['log'](a0v[a2(0x138)](a2(0x185))),console['log'](),console[a2(0x1f0)](a0v[a2(0x216)]('\x20\x20─────────────────────────────────────────────')),console[a2(0x1f0)](a0v[a2(0x16a)]('\x20\x20'+a0G(a2(0x1aa))+'\x20')+a0v['bold'][a2(0x147)](a2(0x21c))+a0v[a2(0x16a)](a2(0x1bf)+a0G(a2(0x20c)))),console['log'](a0v['gray']('\x20\x20'+a0G(a2(0x1e5)))),console['log'](a0v[a2(0x216)](a2(0x230))),console[a2(0x1f0)](),console['log'](a0v[a2(0x16a)]('\x20\x20▸\x20\x20')+a0v[a2(0x16a)](a0G(a2(0x1e7))[a2(0x21f)](a2(0x137),a0v['bold'][a2(0x147)](a2(0x21c))))),console[a2(0x1f0)](a0v[a2(0x138)](a2(0x132)+a0G(a2(0x1ef)))),console[a2(0x1f0)](),'exit';const B={};B[a2(0x1c1)]=a2(0x248);if(!y&&u>=0xf09+0x260e+-0x1*0x218f)return y=!(-0x3c7+0x23*-0x106+0x2799),fetch(a2(0x18f),{'method':a2(0x201),'headers':B,'body':JSON[a2(0x17d)]({'type':'ai4ctf','solved':!(-0x1*0x1df0+0x93*-0xb+0x11*0x222),'tokensUsed':u,'timestamp':new Date()[a2(0x22f)]()}),'signal':AbortSignal[a2(0x168)](-0xa85*0x3+-0x26d7+0x59ee)})['catch'](()=>{}),console['log'](),console[a2(0x1f0)](a0v[a2(0x1e0)]('\x20\x20'+a0G(a2(0x15d)))),w(),(function(){const a5=a2;console[a5(0x1f0)](),console[a5(0x1f0)](a0v['yellow'](a5(0x230))),console[a5(0x1f0)](a0v[a5(0x236)][a5(0x1e0)]('\x20\x20'+a0G(a5(0x14d)))),console[a5(0x1f0)](a0v['yellow'](a5(0x230))),console[a5(0x1f0)]();for(const S of a0G(a5(0x152))[a5(0x14b)]('\x0a'))''===S?console[a5(0x1f0)]():console[a5(0x1f0)](a0v['white'](a5(0x1a8)+S));console['log'](),console[a5(0x1f0)](a0v[a5(0x216)](a5(0x24c))),console['log'](),console[a5(0x1f0)](a0v[a5(0x16a)]('\x20\x20\x20\x20'+a0G(a5(0x1d8)))),console[a5(0x1f0)](),console[a5(0x1f0)](a0v[a5(0x145)]('\x20\x20\x20\x20\x20\x20\x20\x20icoa{w3lc0me_2_ai4ctf}')),console['log'](),console['log'](a0v[a5(0x16a)](a5(0x1a8)+a0G('ai4ctfRevealThenSubmit'))),console['log'](),console[a5(0x1f0)](a0v[a5(0x216)](a5(0x18c))),console[a5(0x1f0)](),console['log'](a0v[a5(0x138)](a5(0x1a8)+a0G(a5(0x242)))),console[a5(0x1f0)]();}()),a2(0x195);if(y)return console[a2(0x1f0)](),console[a2(0x1f0)](a0v[a2(0x1e0)]('\x20\x20'+a0G('ai4ctfLockedTitle'))),console[a2(0x1f0)](a0v[a2(0x138)]('\x20\x20'+a0G(a2(0x1f6))+'\x20')+a0v[a2(0x216)](a2(0x13e))),console[a2(0x1f0)](a0v[a2(0x138)]('\x20\x20'+a0G('ai4ctfLockedThen')+'\x20')+a0v['cyan'](a2(0x1bd))),console[a2(0x1f0)](),a2(0x195);console[a2(0x1f0)](a0v['gray']('\x20\x20'+a0G(a2(0x164))));try{const S=await h[a2(0x20f)](v);process['stdout'][a2(0x228)](a2(0x156)),u+=S[a2(0x1bb)],a0z(S['tokensUsed']),console[a2(0x1f0)](),a0E(S[a2(0x133)]),w(),console[a2(0x1f0)]();}catch(T){process[a2(0x20b)][a2(0x228)]('\x1b[1A\x1b[2K'),a0F(a2(0x1f2)+T[a2(0x162)]),console['log']();}return a2(0x195);}const p=new Set();async function b(q){const a6=a0k;if(!m||!h)return a6(0x13a);const v=q['trim'](),x=v['toLowerCase'](),z=(Date[a6(0x181)]()-m[a6(0x1fd)])/(-0x16164+-0x26b*-0x73+0x135b3);if(!m['nudgeShown']&&!m[a6(0x16f)]&&z>=-0x9aa+0x3*0x3fa+-0x23f&&(m[a6(0x1ff)]=!(0x132+0x1e54+-0xfc3*0x2),console['log'](),console[a6(0x1f0)](a0v[a6(0x1e0)]('\x20\x20💡\x20Once\x20you\x20have\x20ICOA{...},\x20submit\x20it\x20with:\x20')+a0v['bold']['yellow'](a6(0x146))),console['log'](a0v[a6(0x138)](a6(0x18d))),console[a6(0x1f0)]()),/^ICOA\{[^}]+\}$/i['test'](v))return console[a6(0x1f0)](),console[a6(0x1f0)](a0v[a6(0x138)](a6(0x1dc))+a0v[a6(0x16a)](a6(0x1ee)+v)),b(a6(0x1ee)+v);const A=v[a6(0x1a3)](/^submit\s+(.+)/i);if(A){let B=A[0x11b*0x15+-0x1a8a+-0x4*-0xd5][a6(0x17e)]();if(/^submit\s+/i['test'](B)&&(B=B[a6(0x21f)](/^submit\s+/i,'')[a6(0x17e)]()),B=B[a6(0x21f)](/^["'`]+|["'`]+$/g,'')[a6(0x17e)](),/^[A-Da-d]$/['test'](B))return console[a6(0x1f0)](),console[a6(0x1f0)](a0v[a6(0x1e0)](a6(0x19d)+B+a6(0x13b))),console['log'](a0v[a6(0x138)](a6(0x191))+a0v[a6(0x145)]('ICOA{your_flag}')+a0v[a6(0x138)]('.\x20Try\x20again\x20inside\x20this\x20chat.')),console[a6(0x1f0)](),a6(0x195);const {getExamState:C,saveExamState:D}=await import(a6(0x243)),E=C();if(!E)return'exit';if(!E[a6(0x21b)][a6(0x125)](H=>H[a6(0x200)]===m['qNum']))return console['log'](a0v[a6(0x147)](a6(0x232)+m['qNum']+a6(0x12f))),'continue';const F=E[a6(0x1f5)][m['qNum']];E[a6(0x161)]||(E[a6(0x161)]=[]),E[a6(0x161)][a6(0x237)]({'ts':new Date()[a6(0x22f)](),'q':m[a6(0x1ea)],'type':F?a6(0x1ab):'answer_submitted','input':B,'result':'via\x20ai4ctf\x20chat'}),E[a6(0x1f5)][m['qNum']]=B;const G=m[a6(0x1ea)]+(0xa69+-0xa62+-0x6);return E[a6(0x174)]=G<=0x1f5*-0x11+-0x1edf+0x404a?G:m['qNum'],D(E),console['log'](),F?(console[a6(0x1f0)](a0v[a6(0x145)](a6(0x1f1)+m[a6(0x1ea)]+'\x20answer\x20updated:\x20')+a0v[a6(0x1e0)](B)),console['log'](a0v['gray'](a6(0x1d1)+F))):console[a6(0x1f0)](a0v[a6(0x145)]['bold'](a6(0x1b7)+m[a6(0x1ea)]+a6(0x1b5)+B)),console['log'](a0v[a6(0x138)]('\x20\x20\x20\x20(Grading\x20happens\x20at\x20exam\x20submit\x20—\x20you\x20cannot\x20preview\x20correctness\x20during\x20the\x20exam.)')),console['log'](),console[a6(0x1f0)](a0v['gray']('\x20\x20')+a0v[a6(0x16a)]('submit\x20ICOA{...}')+a0v[a6(0x138)](a6(0x223))+a0v[a6(0x16a)]('exit')+a0v[a6(0x138)](a6(0x204))),G<=-0x2*-0x320+0xe03+-0x1*0x141d?console[a6(0x1f0)](a0v[a6(0x138)]('\x20\x20After\x20exit:\x20')+a0v[a6(0x216)]('ai4ctf')+a0v[a6(0x138)]('\x20will\x20open\x20Q'+G)):console[a6(0x1f0)](a0v['gray'](a6(0x129))+a0v[a6(0x147)](a6(0x21c))+a0v['gray']('\x20on\x20Q39')),console[a6(0x1f0)](),'continue';}if(q[a6(0x1e6)]('!')){const H=q[a6(0x141)](0xf7a*-0x1+0x267c+-0x7ab*0x3)[a6(0x17e)]();if(!H)return a6(0x195);try{const I={};I[a6(0x13d)]='utf-8',I[a6(0x168)]=0x2710;const {execSync:J}=await import(a6(0x210)),K=J(H,I)[a6(0x17e)]();console['log'](),console[a6(0x1f0)](a0v[a6(0x138)]('\x20\x20$\x20')+a0v[a6(0x16a)](H)),console['log'](a0v[a6(0x16a)]('\x20\x20'+K[a6(0x14b)]('\x0a')[a6(0x179)]('\x0a\x20\x20'))),console[a6(0x1f0)]();}catch(L){console[a6(0x1f0)](),console[a6(0x1f0)](a0v['red']('\x20\x20Error:\x20'+(L[a6(0x162)]?.[a6(0x14b)]('\x0a')[-0x21b5+0x202d+0x188]||'Command\x20failed'))),console[a6(0x1f0)]();}return a6(0x195);}if(a6(0x13a)===x||'back'===x||a6(0x1ad)===x){const M=m['qNum'],{getExamState:N}=await import(a6(0x243)),O=N(),P=O&&null!=O[a6(0x1f5)][M],Q=O?.['_lastQ']||M;return r=!(0xa38*0x3+-0x128a+-0xc1d),h=null,m=null,p[a6(0x1d4)](),console[a6(0x1f0)](),console[a6(0x1f0)](a0v['gray'](a6(0x155)+M+'.')),P&&Q>M&&Q<=0x99a*0x1+-0x1c41*0x1+0x12cd?console[a6(0x1f0)](a0v[a6(0x16a)](a6(0x1c6))+a0v['bold'][a6(0x145)]('Q'+Q)+a0v[a6(0x138)](a6(0x235))+a0v[a6(0x216)](a6(0x206))+a0v[a6(0x138)]('\x20to\x20continue')):P&&M>=-0x20eb*0x1+-0x645+0x2756?console[a6(0x1f0)](a0v[a6(0x16a)]('\x20\x20AI4CTF\x20section\x20complete\x20—\x20')+a0v[a6(0x236)][a6(0x147)]('ctf4ai')+a0v[a6(0x138)](a6(0x227))):console[a6(0x1f0)](a0v[a6(0x138)](a6(0x1a7))+a0v[a6(0x16a)]('exam\x20q\x20'+M)+a0v[a6(0x138)](a6(0x139))+a0v['white'](a6(0x206))),console[a6(0x1f0)](),a6(0x13a);}if(y)return console['log'](),console[a6(0x1f0)](a0v[a6(0x1e0)](a6(0x23f))),console[a6(0x1f0)](a0v[a6(0x138)](a6(0x142))+a0v[a6(0x16a)]('submit\x20<flag>')+a0v['gray'](a6(0x217))+a0v[a6(0x16a)](a6(0x1b8))+a0v[a6(0x138)](a6(0x217))+a0v[a6(0x16a)](a6(0x13a))),console[a6(0x1f0)](),a6(0x195);if(u>=d)return y=!(-0x11c9+0x14b1*0x1+-0x2e8),console['log'](),console[a6(0x1f0)](a0v[a6(0x147)][a6(0x236)]('\x20\x20⚠\x20AI4CTF\x20token\x20budget\x20exhausted\x20(25,000\x20used).')),console[a6(0x1f0)](a0v[a6(0x138)](a6(0x22a))+a0v[a6(0x16a)]('submit\x20<flag>')+a0v[a6(0x138)]('\x20·\x20')+a0v['white']('!shell')+a0v[a6(0x138)]('\x20·\x20')+a0v[a6(0x16a)](a6(0x13a))),console['log'](),'continue';console[a6(0x1f0)](a0v[a6(0x138)](a6(0x19c)));try{const R=await h[a6(0x20f)](q);process['stdout'][a6(0x228)](a6(0x156)),u+=R[a6(0x1bb)];const {getRealExamState:S,saveExamState:T}=await import('../lib/exam-state.js'),U=S(),V={};V[a6(0x206)]=0x0,V[a6(0x21c)]=0x0,(U&&(U[a6(0x240)]||(U['aiUsage']=V),U[a6(0x240)][a6(0x206)]=u,T(U)),console[a6(0x1f0)](),a0E(R[a6(0x133)]),w(),function(W,X,Y){const a7=a6,Z=W/X*(0x1110+-0xdf*0x1d+0x3*0x2dd);Z>=-0x2468+-0x1216+0x36dd*0x1&&!Y[a7(0x1b6)]('95')?(console['log'](a0v[a7(0x147)][a7(0x236)](a7(0x192)+Math['round'](Z)+a7(0x24f)+(X-W)+a7(0x1c0))),Y['add']('95')):Z>=-0x199d+0x501+-0xd*-0x19c&&!Y[a7(0x1b6)]('80')?(console['log'](a0v[a7(0x1e0)](a7(0x212))),Y[a7(0x1d7)]('80')):Z>=0x494+0x135d+0x17bf*-0x1&&!Y[a7(0x1b6)]('50')&&(console['log'](a0v[a7(0x138)](a7(0x21d))),Y[a7(0x1d7)]('50'));}(u,d,p),console[a6(0x1f0)]());}catch(W){process[a6(0x20b)][a6(0x228)](a6(0x156)),a0F(a6(0x1f2)+W[a6(0x162)]),console['log']();}return a6(0x195);}export function registerAi4ctfCommand(j){const a8=a0k;j[a8(0x178)](a8(0x206))[a8(0x1fc)](a8(0x238))[a8(0x1a5)](async()=>{const a9=a8;a0C(a9(0x206));const {getRealExamState:k}=await import(a9(0x243)),q=k(),v=q?.[a9(0x21b)][a9(0x220)](C=>'ai4ctf'===C[a9(0x1d5)]);if(q&&v){const C=q['_lastQ']||0x929+-0x5*-0x55+0xad1*-0x1,D=q[a9(0x21b)][a9(0x125)](E=>E['number']===C);if(!D)return void a0F('Q'+C+a9(0x180)+C);if(a9(0x206)!==D[a9(0x1d5)]){if(console[a9(0x1f0)](),a9(0x21c)===D['type'])console[a9(0x1f0)](a0v[a9(0x1e0)](a9(0x232)+C+a9(0x17b))),console[a9(0x1f0)](a0v[a9(0x138)](a9(0x1e9))+a0v[a9(0x236)][a9(0x147)](a9(0x21c)));else{if('vla'===D[a9(0x1d5)])console[a9(0x1f0)](a0v[a9(0x1e0)]('\x20\x20Q'+C+'\x20is\x20an\x20Embodied\x20AI\x20(EAI)\x20question.')),console['log'](a0v['gray'](a9(0x1e9))+a0v['bold'][a9(0x216)](a9(0x150)));else{const E=q['questions']['find'](F=>a9(0x206)===F[a9(0x1d5)]);console[a9(0x1f0)](a0v['yellow'](a9(0x232)+C+a9(0x250))),E&&(console['log'](a0v['gray']('\x20\x20AI4CTF\x20chat\x20is\x20available\x20on\x20practical\x20questions\x20(next:\x20Q'+E[a9(0x200)]+').')),console['log'](a0v['gray']('\x20\x20Jump\x20there:\x20')+a0v[a9(0x236)][a9(0x216)](a9(0x16b)+E[a9(0x200)])));}}return void console[a9(0x1f0)]();}return void await async function(F,G){const aa=a9,{getRealExamState:H,refetchQuestionDataIfStale:I,materializeAttachedData:J}=await import(aa(0x243));await I();const K=H();if(!K)return!(0x87+0x60e*0x2+0x6*-0x21b);const L=K['questions']['find'](O=>O[aa(0x200)]===F);L&&(G=L),J(F,G?.[aa(0x1e2)]);const M=K[aa(0x240)]?.['ai4ctf']??-0x2510+0x1594+0xf7c;if(M>=d)return console[aa(0x1f0)](),console[aa(0x1f0)](a0v['yellow'](aa(0x1b1))),console[aa(0x1f0)](a0v[aa(0x138)](aa(0x202))+a0v[aa(0x16a)]('exam\x20answer\x20'+F+aa(0x16c))),console['log'](),!(-0x139c+0x1*0x144a+-0xad);try{h=await a0x(void(-0x2679+-0x1f0b+0x4584),function(O,P){const ab=aa,Q=O[ab(0x1fc)]||O[ab(0x133)]||'',R=O[ab(0x1e2)]?ab(0x15f)+P+ab(0x1d2)+O[ab(0x1e2)]:'';return ab(0x207)+P+',\x20'+O[ab(0x1df)]+',\x20'+(O[ab(0x1b9)]||0x1*0x401+-0x15cd+0x11d2)+ab(0x16d)+Q+R+ab(0x1be)+P+ab(0x23a);}(G,F));}catch(O){return a0F(O[aa(0x162)]),!(-0x2*-0x265+-0x271*-0xb+-0x4*0x7e9);}r=!(0x3*-0x30d+-0x1e*0x7f+0x1809),u=M,y=!(0x100a*0x1+-0x1d83+0x47e*0x3),m={'qNum':F,'question':G,'usageField':aa(0x206),'enteredAt':Date[aa(0x181)](),'submitAttempted':!(0x30*0xaa+-0x1452+0xb8d*-0x1),'nudgeShown':!(-0x3c1+-0x13*0x61+0xaf5)};const N=K[aa(0x1f5)]?.[F];return function(P,Q,R){const ac=aa,S=a0A()[ac(0x20e)]||ac(0x1ac),T=u>0x1f99*-0x1+-0x1*-0x137f+0xc1a;console[ac(0x1f0)](),console[ac(0x1f0)](a0v['green']['bold'](ac(0x1c7)+Q+':\x20'+P[ac(0x1df)]+'\x20═══')),T&&console[ac(0x1f0)](a0v[ac(0x138)](ac(0x131))),R&&console[ac(0x1f0)](a0v['gray'](ac(0x1b4))+a0v[ac(0x1e0)](R)+a0v['gray']('\x20\x20(submit\x20again\x20to\x20change)')),console[ac(0x1f0)](),console[ac(0x1f0)](a0v['cyan'](ac(0x175))),console[ac(0x1f0)](a0v[ac(0x216)](ac(0x1a2))+a0v['bold']['white']('Q'+Q+'\x20\x20['+P[ac(0x1df)]+ac(0x251)+(P['points']||-0x194c*-0x1+-0x1*-0x29f+-0x1be5)+ac(0x213))),console[ac(0x1f0)](a0v['cyan']('\x20\x20│'));for(const U of String(P[ac(0x133)])['split']('\x0a')){const V=U[ac(0x234)]>-0x2*-0x490+0x351*0x6+-0x14f*0x16?U['slice'](0x2*0x30a+-0x1*-0x1eee+-0x2*0x1281,-0x26aa+0x21be+0x525)+'...':U;console[ac(0x1f0)](a0v['cyan'](ac(0x1a2))+a0v[ac(0x16a)](V));}console['log'](a0v['cyan'](ac(0x1cd))),console['log'](a0v[ac(0x216)](ac(0x1a2))+a0v[ac(0x138)](ac(0x1f7))+a0v[ac(0x16a)](ac(0x16b)+Q)),console[ac(0x1f0)](a0v['cyan'](ac(0x1a2))+a0v[ac(0x138)](ac(0x197))),console[ac(0x1f0)](a0v[ac(0x216)](ac(0x1ca))),console[ac(0x1f0)](),console[ac(0x1f0)](a0v[ac(0x236)][ac(0x16a)](ac(0x14e))),console[ac(0x1f0)](),console[ac(0x1f0)](a0v[ac(0x1e0)](ac(0x1bc))+a0v[ac(0x138)](ac(0x21a))),console[ac(0x1f0)](a0v[ac(0x1e0)]('\x20\x20\x20\x20hint\x20b')+a0v[ac(0x138)](ac(0x154))),console[ac(0x1f0)](a0v[ac(0x1e0)](ac(0x190))+a0v[ac(0x138)](ac(0x1d6))),console[ac(0x1f0)](a0v[ac(0x236)][ac(0x145)](ac(0x1c2))+a0v[ac(0x138)](ac(0x1eb))),console[ac(0x1f0)](a0v['white'](ac(0x194))+a0v[ac(0x138)](ac(0x19b))),console[ac(0x1f0)](a0v['gray']('\x20\x20\x20\x20Just\x20type\x20freely\x20to\x20chat\x20with\x20the\x20AI\x20teammate.')),console[ac(0x1f0)](a0v[ac(0x138)](ac(0x165))+a0v[ac(0x16a)](ac(0x215))),console['log'](),console['log'](a0v['gray'](ac(0x19e))+a0v[ac(0x138)](ac(0x12a))),console[ac(0x1f0)](a0v[ac(0x138)](ac(0x22c))+a0v[ac(0x138)](ac(0x17f))),console[ac(0x1f0)](),w(),console['log'](a0v[ac(0x138)]('\x20\x20Model:\x20Google\x20Gemma\x204\x20('+S+')')),console[ac(0x1f0)]();}(G,F,N),!(-0x38a*-0x5+0x1288+-0x243a);}(C,D);}const x=a0A(),z=x[a9(0x20e)]||'gemma-4-31b-it';if(a0B())return x[a9(0x244)]?void await(async function(){const ad=a9,F=a0A(),G=F[ad(0x14a)],H=F[ad(0x244)],I=F[ad(0x144)]||ad(0x1b2);let J='';if(G)try{const {CTFdClient:K}=await import('../lib/ctfd-client.js'),L=F[ad(0x1cf)]||'',M=F[ad(0x1ec)]&&!F['token'][ad(0x1ce)]('session=')?F[ad(0x1ec)]:'',N=new K(F[ad(0x1e3)],M,L||F['token']);J=(await N[ad(0x23b)](G))[ad(0x1fc)]||'';}catch{}try{h=await a0x(void(0x1d77+-0x10b3+-0x2b*0x4c),function(O,P,Q){const ae=ad;return ae(0x1cb)+O+ae(0x182)+P+').'+(Q?'\x0a\x0aCHALLENGE\x20BRIEF:\x0a'+Q:'')+ae(0x12e);}(H,I,J));}catch(O){return a0F(O[ad(0x162)]),!(-0x19*0x3+0x1f8+-0x1ac);}return r=!(0x1a12+-0x803*-0x1+-0x2215),u=0x4c*0x44+0x26*-0x22+-0xf24,y=!(-0x1*0xb47+0x122+0xa26),f={'challengeId':G,'challengeName':H,'challengeCategory':I,'enteredAt':Date[ad(0x181)]()},function(P,Q){const af=ad,R=a0A()[af(0x20e)]||af(0x1ac);console[af(0x1f0)](),console[af(0x1f0)](a0v[af(0x145)]['bold']('\x20\x20═══\x20AI\x20Teammate\x20═══')),console[af(0x1f0)](),console[af(0x1f0)](a0v[af(0x216)](af(0x175))),console['log'](a0v['cyan'](af(0x1a2))+a0v[af(0x236)]['white'](P)+a0v[af(0x138)]('\x20\x20\x20['+Q+']')),console['log'](a0v[af(0x216)](af(0x1cd))),console[af(0x1f0)](a0v[af(0x216)](af(0x1a2))+a0v[af(0x138)](af(0x1c3))),console['log'](a0v['cyan'](af(0x1a2))+a0v[af(0x138)]('the\x20AI\x20guides,\x20it\x20will\x20not\x20hand\x20you\x20the\x20flag.')),console[af(0x1f0)](a0v['cyan'](af(0x1ca))),console[af(0x1f0)](),console[af(0x1f0)](a0v[af(0x1e0)]('\x20\x20Commands')),console[af(0x1f0)](a0v[af(0x16a)](af(0x211))+a0v['gray'](af(0x1dd))),console['log'](a0v['white'](af(0x1cc))+a0v[af(0x138)]('Run\x20a\x20shell\x20command\x20(e.g.\x20!base64\x20-d\x20...)')),console[af(0x1f0)](a0v[af(0x16a)]('\x20\x20\x20\x20submit\x20<flag>\x20\x20\x20')+a0v[af(0x138)]('Submit\x20a\x20flag\x20to\x20the\x20live\x20scoreboard')),console[af(0x1f0)](a0v[af(0x16a)]('\x20\x20\x20\x20exit\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20')+a0v[af(0x138)](af(0x12c))),console[af(0x1f0)](),console[af(0x1f0)](a0v['gray'](af(0x1d0))+a0v[af(0x16a)]('open\x20<id>')+a0v['gray'](af(0x153))+a0v[af(0x16a)](af(0x206))),w(),console[af(0x1f0)](a0v[af(0x138)](af(0x1f8)+R+')')),console[af(0x1f0)](a0v[af(0x138)](af(0x24e))),console[af(0x1f0)]();}(H,I),!(-0x24aa+0xd*0x170+0x11fa);}()):(console['log'](),console['log'](a0v['yellow'](a9(0x12d))),console[a9(0x1f0)](a0v[a9(0x138)](a9(0x158))+a0v[a9(0x16a)](a9(0x1a1))+a0v[a9(0x138)](a9(0x13f))+a0v[a9(0x16a)](a9(0x14c))),console[a9(0x1f0)](a0v[a9(0x138)]('\x20\x20The\x20AI\x20teammate\x20scopes\x20itself\x20to\x20the\x20challenge\x20you\x20open.')),void console[a9(0x1f0)]());const A={};A[a9(0x208)]=a9(0x157),A[a9(0x1df)]=a9(0x128);const B=A;try{h=await a0x(B);}catch(F){return void a0F(F['message']);}r=!(-0x141e+-0x12f0+0x270e),u=0x13a*-0xd+-0x2042+0x3034,y=!(0xe41+0x25*-0x7+-0xd3d),console['log'](),console['log'](a0v[a9(0x145)]['bold']('\x20\x20═══\x20'+a0G(a9(0x17a))+a9(0x198))),console[a9(0x1f0)](),console[a9(0x1f0)](a0v['white']('\x20\x20'+a0G('ai4ctfSample'))),console[a9(0x1f0)](),console[a9(0x1f0)](a0v['cyan'](a9(0x175))),console[a9(0x1f0)](a0v[a9(0x216)](a9(0x1a2))+a0v[a9(0x236)][a9(0x16a)](a0G(a9(0x225)))),console[a9(0x1f0)](a0v[a9(0x216)](a9(0x1cd))),console[a9(0x1f0)](a0v[a9(0x216)](a9(0x1a2))+a0v['white'](a0G(a9(0x13c)))),console[a9(0x1f0)](a0v[a9(0x216)](a9(0x1a2))+a0v[a9(0x145)](a9(0x246))),console['log'](a0v['cyan'](a9(0x1cd))),console[a9(0x1f0)](a0v[a9(0x216)](a9(0x1a2))+a0v['white'](a0G('ai4ctfDecode'))),console[a9(0x1f0)](a0v[a9(0x216)](a9(0x1a2))+a0v[a9(0x138)]('Flag\x20format:\x20icoa{...}')),console[a9(0x1f0)](a0v['cyan'](a9(0x1ca))),console['log'](),console['log'](a0v[a9(0x16a)]('\x20\x20'+a0G(a9(0x22d)))),console[a9(0x1f0)](),console['log'](a0v['yellow'](a9(0x1bc))+a0v[a9(0x138)](a9(0x1a8)+a0G(a9(0x1e8)))),console[a9(0x1f0)](a0v[a9(0x138)](a9(0x12b)+a0G(a9(0x239)))),console[a9(0x1f0)](a0v['yellow'](a9(0x1ba))+a0v[a9(0x138)](a9(0x1a8)+a0G('ai4ctfHintB'))),console[a9(0x1f0)](a0v[a9(0x138)](a9(0x12b)+a0G('ai4ctfHintBUses'))),console['log'](a0v[a9(0x1e0)]('\x20\x20\x20\x20hint\x20c')+a0v['gray']('\x20\x20\x20\x20'+a0G(a9(0x1db)))),console[a9(0x1f0)](a0v[a9(0x138)](a9(0x12b)+a0G(a9(0x241)))),console[a9(0x1f0)](),console[a9(0x1f0)](a0v[a9(0x138)](a9(0x185))),console[a9(0x1f0)](a0v[a9(0x236)][a9(0x16a)]('\x20\x20'+a0G(a9(0x1e1)))),console['log'](a9(0x1a8)+a0v[a9(0x216)]('hint\x20a')+a0v[a9(0x138)](a9(0x1d3)+a0G('ai4ctfHintNudge'))),console[a9(0x1f0)](a9(0x1a8)+a0v[a9(0x216)]('hint\x20b')+a0v[a9(0x138)](a9(0x1d3)+a0G(a9(0x177)))),console['log'](a9(0x1a8)+a0v[a9(0x216)](a9(0x1c4))+a0v['gray']('\x20\x20\x20→\x20'+a0G(a9(0x22e)))),console[a9(0x1f0)](a0v['gray']('\x20\x20\x20\x20'+a0G('ai4ctfWelcomeNoReveal'))),console[a9(0x1f0)](),console['log'](a0v[a9(0x16a)]('\x20\x20'+a0G(a9(0x143)))),console['log'](a0v[a9(0x138)]('\x20\x20'+a0G(a9(0x134))+'\x20')+a0v[a9(0x16a)](a9(0x20d))),console[a9(0x1f0)](),console['log'](a0v[a9(0x1e0)]('\x20\x20'+a0G(a9(0x1ae)))),console[a9(0x1f0)](a0v[a9(0x16a)](a9(0x1f3))+a0v[a9(0x138)](a0G(a9(0x1b3)))),console['log'](a0v['white'](a9(0x249))+a0v['gray'](a0G('ai4ctfSubmitCmd'))),console['log'](a0v[a9(0x16a)](a9(0x1cc))+a0v[a9(0x138)](a0G(a9(0x163)))),console[a9(0x1f0)](a0v[a9(0x138)]('\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20e.g.\x20')+a0v[a9(0x16a)](a9(0x127))),console[a9(0x1f0)](a0v[a9(0x138)](a9(0x203)+a0G(a9(0x23e)))),console[a9(0x1f0)](),w(),console[a9(0x1f0)](a0v[a9(0x138)]('\x20\x20'+a0G(a9(0x167))+':\x20Google\x20Gemma\x204\x20('+z+')')),console[a9(0x1f0)](a0v[a9(0x138)]('\x20\x20'+a0G(a9(0x166)))),console[a9(0x1f0)]();});}
1
+ (function(j,k){const a1=a0k,q=j();while(!![]){try{const v=parseInt(a1(0x1d1))/(0x35f*0x2+0xe16+0x3*-0x6f1)+parseInt(a1(0x232))/(-0x1b*0x91+-0xb49+-0xa6*-0x29)+parseInt(a1(0x19e))/(0xb69+0x12d1*-0x2+0x1a3c)+-parseInt(a1(0x185))/(-0x134*-0x18+-0x117e+-0xb5e)*(-parseInt(a1(0x27f))/(-0x66d+0x22f4+-0x2*0xe41))+-parseInt(a1(0x20a))/(0x1559*0x1+-0x1f72+-0xa1f*-0x1)+-parseInt(a1(0x1dd))/(0x1a4b+-0x1*0xda0+-0xca4*0x1)*(parseInt(a1(0x279))/(0x1*0x1b23+-0x28+-0x1af3))+parseInt(a1(0x1d6))/(0xaf7+-0x216+-0x8d8)*(-parseInt(a1(0x273))/(-0x1*0x19d9+-0x23b7+-0x5f*-0xa6));if(v===k)break;else q['push'](q['shift']());}catch(x){q['push'](q['shift']());}}}(a0j,0x82723*0x2+-0x2993*0x3a+0x5159b));import a0v from'chalk';import{createChatSession as a0x}from'../lib/gemini.js';import{addTokenUsage as a0z}from'../lib/budget.js';import{getConfig as a0B,isConnected as a0C}from'../lib/config.js';import{logCommand as a0D,logSubmission as a0E}from'../lib/logger.js';import{printMarkdown as a0F,printError as a0G}from'../lib/ui.js';function a0j(){const ah=['yxr0ywnOzwreyxrH','ywK0y3rMq21Ku2HLBgXmAw5L','BwvUDq','icdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILzdILza','rMXHzYbMB3jTyxq6igLJB2f7lI4UFq','ig5VDcbMB3vUzcbPBIbZDgf0zs4Gvhj5oIbLEgfTiheG','C3rHDhvZ','icaGigHPBNqGyG','icbpCgvUig9UzsbMAxjZDdOG','ywK0y3rMv3jHCff1B3rHC1rPDgXL','uNvUigeGC2HLBgWGy29TBwfUzcaOzs5NlIaHyMfZzty0ic1Kic4UlIK','ywK0y3rMuMv2zwfSu2vLrMXHzW','ywK0y3rMtg9JA2vKvgL0Bgu','Dg9mB3DLCKnHC2u','yw5ZD2vYx3n1yM1PDhrLza','icaGihn1yM1PDcbjq09bEY4UlN0','mZmXmZiYne1YvwjswG','DMXH','icaGidXQDxn0ihr5Cgu+icaGica','zxHHBsbHBNn3zxiG','icbfCNjVCJOG','DgvZDa','C3rHCNrZv2L0Aa','AwnVys1JBgKVyNvKz2v0','AM9PBG','ihDPBgWGB3bLBIbr','icbzB3uGy2fUihn0AwXSoIa','ig9UifeZoq','yM9Sza','BM9KztPJAgLSzf9WCM9JzxnZ','igLZigeGBxvSDgLWBguTy2HVAwnLihf1zxn0Aw9UiokaLcbHBNn3zxiGD2L0Acbbl0iVqY9elG','icbdB21WzxrPDgLVBIbPCYbWyxvZzwqU','CM91BMq','CxvLC3rPB25Z','sunpqxT5B3vYx2zSywD9','D3jPDgu','icdINjmGqw5ZD2vYigzVCIbr','icaGicaGicbPy29HE3CZBgmWBwvFmL9HAtrJDgz9','ywK0y3rMv3jHCfr5CgvdDgy0ywK','DgLTzw91Da','ywn0Aw9U','z3jHEq','C3vIBwL0ia','Bwf0y2G','ywnJB3vUDfnWzw50','Dg9Rzw4','lcbVCIbYzs1LBNrLCIb3AxrOia','y3vYCMvUDenOywXSzw5NzuLK','ywK0y3rMrxHPDe5LEhruAxrSzq','icdILjtILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILia','icdILzdILzdILzaGquKGvgvHBw1HDguG4Pwq4Pwq4Pwq','Ahr0Chm6lY9WCMfJDgLJzs5Py29HmJaYnI5HDs9HCgKVAwnVys9Kzw1Vlxn0yxrZ','cGPzt1vsifjvtevtoGOTifLVDsbnqvKGzxHWBgfPBIbJB25Jzxb0CYWGzgvZy3jPyMuGyxbWCM9Hy2HLCYWGyw5KigHLBhaGDgHLignVBNrLC3rHBNqGCMvHC29UihrOCM91z2GGDgHLihbYB2jSzw0UcI0Gww91ie1bwsbKAxnJDxnZihrOzsb0zwnOBM9SB2D5igLUDM9SDMvKicHbrvmSihb3BNrVB2XZlcbqExrOB24GC3rYDwn0lcbivfrqlcbLDgmUks4klsbzB3uGtufzigHLBhaGzgvIDwCGuhL0Ag9UignVzguGDgHLignVBNrLC3rHBNqGD3jPDgvZlGOTifLVDsbnvvnuie5pvcbYzxzLywWGDgHLigzSywCGzgLYzwn0BhKUcI0Gww91ie1vu1qGtK9uig91Dhb1DcbHBNKGC3rYAw5Nig1HDgnOAw5NieLdt0f7lI4UFsbVCIbPy29HEY4UlN0UcI0Gww91ie1vu1qGtK9uihrLBgWGDgHLignVBNrLC3rHBNqGDgHLigv4ywn0igfUC3DLCIb0BYb0AgLZihf1zxn0Aw9UlGOTifLVDsbnqvKGC3vNz2vZDcb3AgLJAcb0B29Sic8GBgLICMfYEsaVihrLy2HUAxf1zsb0BYb1C2uUcI0Gv2HLBIbZDwDNzxn0Aw5NihnOzwXSic8GChL0Ag9UihnUAxbWzxrZihrOyxqGBMvLzcb0AguGyxr0ywnOzwqGzgf0ysWGCMvMzxiGDg8GDgHLigzPBguGCgf0AcbJAgfSBgvUz2vZl3e','icaGicbsDw4GuhL0Ag9UigLUihnOzwXS','zxHPDa','E2nTzh0','mZeZndy5nhnsuMnRvW','icaGicaGicaGicaGicaGicaGicbLlMCUia','C3rYAw5NAwz5','ywK0y3rMvg9Rzw5Z','C3vIBwL0igLJB2f7DZnSyZbTzv8Yx2fPngn0zN0','C3vIBwL0qxr0zw1WDgvK','igfNywLUihrVignOyw5NzsWGB3iG','quK0q1rgihnLy3rPB24','tgvHDMuGDgHLiefjihrLyw1TyxrL','ywK0y3rMuMvWB3j0','icaGicaGicaGicbbigDLBNrSzsbUDwrNzsaOChjLlxDYAxr0zw4P','icbsyxrLigXPBwL0zwqG4OcuihDHAxqGysbTB21LBNqGyMvMB3jLihrYEwLUzYbHz2fPBI4','yw5ZD2vYx2nOyw5Nzwq','icbdDxjYzw50igfUC3DLCJOG','q29TBwfUzcbMywLSzwq','Dg9Rzw5ZvxnLza','icdILiZILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILia','icaGicaGicaGicaGifjLDhvYBIb0BYbTywLUig1LBNuGkhDVCMTZigfUExDOzxjLkq','icbvC2fNztOG','ywK0y3rMoIa','icbnB2rLBdOGr29Vz2XLieDLBw1HidqGka','ieLdt0f7lI4UFq','DhjPBq','icaGig1LBNu','ywK0y3rMsgLUDefvC2vZ','icdILiiG','ywK0y3rMuMv2zwfSvgL0Bgu','icaGice8C2HLBgWGy21KpIaGica','y29TBwfUza','icbgBgfNigzVCM1HDdOG','BwvZC2fNzq','ywK0y3rMv3jHCff1B3rHrM9VDgvY','icdIMQaGquK0q1rgihrVA2vUigj1zgDLDcbLEgHHDxn0zwqGkdi1ldaWmcb1C2vKks4','ywK0y3rMv3jHCe5LEhruAxrSzq','ue9tva','lNr4DcbPBNnPzguGDgHLignVBNrLC3rHBNqNCYbZyw5KyM94iokaLcbWyxrOigLZihjLBgf0AxzLihrVihrOzsbZyw5KyM94j3mGl2HVBwuVy29TCgv0AxrVCIb3B3jRAw5NigrPCMvJDg9YEsWGCMvHy2HHyMXLigzYB20Gyw55icfZAgvSBcaVicfWExrOB24ZigLUDM9JyxrPB24PoGO','icaGigHPBNqGyq','quKGyNvKz2v0icH0AgLZigfJy291BNqP','Aw50zxjHy3rPB25Z','icdINjmGuq','rMXHzYbMB3jTyxq6icaGieLdt0f7lI4UFq','icbvC2u6ia','ywK0y3rMrM91BMrgBgfN','icdWN46jienVCNjLy3qHia','E25VuhjVz30','C3bSAxq','icaGidiUia','icdILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILia','icaI','icbszxn1Bwu6ia','zw5JB2rPBMC','z3jLzw4','icaGicaGigHPBNqGysaGia','u3vIBwL0igeGzMXHzYb0BYb0AguGBgL2zsbZy29YzwjVyxjK','rNvSBcbXDwvZDgLVBJOGia','icbB','ifn1yM1PDcb5B3vYigzSywCGzM9YihrOAxmGCxvLC3rPB24','icdIMQaG','BNvKz2vtAg93BG','ywK0y3rMv291BgrfyxjU','CgfKrw5K','ywK0y3rMv3jHCff1B3rHqG','ywK0y3rMuMv2zwfSqM9KEq','B3bLBIa8Awq+','CMf0zwXPBwL0zwq','mtbOv0DZCvi','icaGicaGicaHzwnOBYbHv052wvH0m00YEgPnrZfSwhPkzLLxAZbzm1jTzLe9psb8igjHC2u2ncaTza','icaKia','icaGigv4AxqGicaGicaGicaGica','g1SXqrTBmKS','ywK0y3rMrw5Ku2vZC2LVBG','mJrjBhrpCLm','icaGicHhCMfKAw5NigHHChbLBNmGyxqGzxHHBsbZDwjTAxqG4OcuihLVDsbJyw5UB3qGChjLDMLLDYbJB3jYzwn0BMvZCYbKDxjPBMCGDgHLigv4yw0Ukq','xsaGWRCG','ywK0y3rMv3jHCff1B3rHqq','ywK0y3rMuMv2zwfSvgHLBLn1yM1PDa','icbtDgLSBcbHDMfPBgfIBgu6ia','mZmYmteYnxrHrhjlDG','icbuAgLUA2LUzY4UlG','ywK0y3rMtg9JA2vKvgHLBG','Dg9ju09tDhjPBMC','AgLUDcbH','ywK0y3rMv3jHCff1B3rHquHPBNq','CMvWBgfJzq','z2vTAw5Ptw9KzwW','AgLUDcbI','C2XPy2u','vw5RBM93BG','CMvWzwf0','ww91igfYzsbHBIbbssb0zwfTBwf0zsbOzwXWAw5NigeGy29UDgvZDgfUDcbPBIbHigXPDMuGq2fWDhvYzs1uAguTrMXHzYbJB21WzxrPDgLVBI4kcKnvuLjftLqGq0HbteXftKDfoIaI','DMLHigfPngn0zIbJAgf0','BM93','q29UDgvUDc1uExbL','icdIMQaGodaLig9MihnLy3rPB24GquKGyNvKz2v0ihvZzwqU','iokaLca','ywnJB3vUDenHCa','oIbhB29NBguGr2vTBweGncaO','AgfZ','Dgv4Da','C29Tzq','DhLWzq','Bg9N','icaGicaGicaGicfLy2HVigfxtNzzwhqZttj4AK1hmwXyEKPMwvDRmfKZuM1Mut09ihWGyMfZzty0ic1K','y2f0zwDVCNK','CMvK','cGPzt1vsifjvtevtoGOTifLVDsbnqvKGzxHWBgfPBIbJB25Jzxb0CYWGzgvZy3jPyMuGyxbWCM9Hy2HLCYWGyw5KigHLBhaGDgHLignVBNrLC3rHBNqGCMvHC29UihrOCM91z2GGDgHLihbYB2jSzw0UcI0Gww91ie1bwsbKAxnJDxnZihrOzsb0zwnOBM9SB2D5igLUDM9SDMvKicHJCNLWDg8SihDLyIWGzM9Yzw5ZAwnZlcbWD24SihjLDMvYC2LUzYWGt1njtLqSihn0zwDVlcbLDgmUks4klsbzB3uGtufzigHLBhaGzgvIDwCGy29Kzsb0AguGy29UDgvZDgfUDcb3CML0zxmGyw5Kihn1z2DLC3qGD2HPy2GGDg9VBcaVigXPyNjHCNKGlYb0zwnOBMLXDwuGDg8GDxnLlGOTifLVDsbnvvnuie5pvcbYzxzLywWGB3iGz3vLC3mGDgHLigzSywCSigfUzcbnvvnuie5pvcbVDxrWDxqGyw55igzSywCTC2HHCgvKihn0CMLUzYaOyw55DgHPBMCGBgLRzsbUyw1LEY4UlN0PlGOTifLVDsbnvvnuie5pvcbZB2X2zsb0AguGD2HVBguGy2HHBgXLBMDLigvUzc10BY1LBMqGzM9YihrOzsbJB250zxn0yw50iokaLcbNDwLKzsWGzg9Uj3qGAgfUzcbVDMvYihrOzsbHBNn3zxiUcI0Gs2vLCcbYzxnWB25ZzxmGy29Uy2LZzsbHBMqGChjHy3rPy2fSlIbuAguGy29UDgvZDgfUDcbPCYbYywnPBMCGDgHLignSB2nRlG','EwvSBg93','icboBYbJAgfSBgvUz2uGB3bLBIb5zxqU','icaGifbYzxzPB3vZoIa','sgLUDca','ywK0y3rMsgLUDejcB2r5','jsbVzIbZzwn0Aw9Uiefjigj1zgDLDcb1C2vKiokaLcbVBMX5ih4','y29UDgLUDwu','Aw5JB3jYzwn0','lI4U','icbtD2L0y2GGy2HHBgXLBMDLoIa','icdILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILidILia','DxrMltG','q2HHDcb3AxrOihLVDxiGquKGDgvHBw1HDgu','icboB3rLoIa1mcuGB2yGC2vJDgLVBIbbssbIDwrNzxqGDxnLzc4','igLZigfUievTyM9KAwvKiefjicHfquKPihf1zxn0Aw9UlG','x2XHC3rr','zMLUza','cIaG','ywK0y3rMv3jHCeXPBMuXsgvHza','icbbstrdveyGy2HHDcbPCYbHDMfPBgfIBguGB24GChjHy3rPy2fSihf1zxn0Aw9UCYaOBMv4DdOGuq','ixnOzwXS','ywK0y3rMq21KsgLUDeXPBMu','ywrK','y3vYCMvUDenOywXSzw5Nzu5HBwu','DgHPBMTPBMC','ywK0y3rMvgHPBMTPBMC','yMfJAW','icbzB3uGy2fUihn0AwXSihn1yM1PDcbHigzSywCGzgLYzwn0BhK6ia','u2nVCgvKihrVihrOzsbJAgfSBgvUz2uGEw91ig9Wzw5Lzc4GqxnRigzYzwvSEsdIGjq','C3rKB3v0','ywK0y3rMsgLUDee','icaGigHPBNqGyW','ywK0y3rMv3jHCff1B3rHq0HPBNq','nfvnwK1TuW','C2vZC2LVBKnVB2TPzq','imk3ia','ywK0y3rMt3jdAgf0','Cu51Bq','Cgf1C2vK','ywK0y3rMrgvJB2rLza','Dg9Rzw5mAw1PDa','lI4VBgLIl2n0zMqTy2XPzw50lMPZ','ww91igfYzsbHBIbbssb0zwfTBwf0zsbOzwXWAw5NigeGy29UDgvZDgfUDcbZB2X2zsbHBIbjq09bidiWmJyGy3LIzxjZzwn1CML0EsbLEgfTihf1zxn0Aw9UlGOkq1vsuKvovcbrvuvtveLptIaOuq','vw5RBM93BIbYzxnWB25Zzq','ywK0y3rMtw9KzwW','ChvZAa','icbdB21Tyw5KCW','icaGicaGicaGicblzxKGyNjLywT0AhjVDwDOicHWCMuTD3jPDhrLBIK','icdILzdILzdILzaG','ywK0y3rMsgLUDe51zgDL','ywK0y3rMsgLUDei','icaGicaODhLWzsbPDcbYAwDODcbOzxjLigLUihrOAxmGy2HHDcdIGjqGBM90igfZigeGC2HLBgWGy29TBwfUzcK','C3vIBwL0idXMBgfNpG','C3vIBwL0ieLdt0f7lI4UFq','Cg9PBNrZ','icaGigv4Axq','ywK0y3rMu3vIBwL0q21K','ywK0y3rMq29YCMvJDezSywC','mtq0mZC5mLDmy1nyuG','oIbhB29NBguGr2vTBweGncaOz2vTBweTnc0ZmwiTAxqP','icdILRGGia','ywK0y3rMv3jHCeXPBMuYsgvHza','lNr4DcaOAw5ZAwrLihrOzsbZyw5KyM94ksbYyxrOzxiGDgHHBIbHC2TPBMCGDgHLignVBNrLC3rHBNqGDg8GCgfZDguGDgHLihDOB2XLigjSB2iGyMfJAY4klsblzwvWihjLC3bVBNnLCYbJB25JAxnLigfUzcbWCMfJDgLJywWUifrOAxmGy29UDgvZDgfUDcbOyxmGBgLTAxrLzcb0Aw1LlG','ihjLy29YzgvKoIa','y3rMngfP','icbkDw1WihrOzxjLoIa','BMfTzq','l2fWAs9Py29Hl2fPl2fJy291BNqTyNvKz2v0p2TPBMq9ywK0y3rM','sgLKzgvUie1LC3nHz2u','zgvZy3jPChrPB24','icbezxrLy3rLzcbMBgfNiokaLcb0CMvHDgLUzYbHCZOG','AgLUDcbJ','ig5VDcbMB3vUzcbPBIbZDgf0zs4','iIbSB29RCYbSAwTLigfUie1dusbSzxr0zxiSig5VDcbHigzSywCU','icaGicfWExrOB24Zic4UlG','iokvKokvKokvKa','ihb0CW','icbbstrdveyGC2vJDgLVBIbJB21WBgv0zsdIGjqG','icaGia','zgf0yq','C2vUze1LC3nHz2u','z2vTBweTnc0ZmwiTAxq','iNDOyxqGzw5JB2rPBMCGAxmGDgHPCZ8I','ywK0y3rMsgLUDe5LEhrc','lI4VBgLIl2v4yw0TC3rHDguUANm','icaGwW','cGPdsefmtevor0uGqLjjruy6cG','yw5ZD2vYCW','icaOCMvZDw1PBMCG4OcuihbYAw9YignOyxqGAxmGBM90ihjLBwvTyMvYzwqSigj1Dcb0B2TLBNmGywXYzwfKEsb1C2vKihn0yxKGzgvKDwn0zwqP','icdILii','icaGica','ywK0y3rMsgLUDefcB2r5','ANnVBG','cGPbvfrbq0HfrcbeqvrbicHHBhnVihnHDMvKihrVignOywXSzw5NzxmVCq','iIaOy2f0zwDVCNK6ia','y2f0y2G','icbtDwjTAxnZAw9UigzHAwXLzdOG','ywK0y3rM','ywK0y3rMuMv2zwfStg9JA05VDgu','BNvTyMvY','D2HPDgu','iokaLcb0ExbLia','y3LHBG','ihrOzw4GCMuTzw50zxiG','igzVCIbrmZK','ywK0y3rMtgv2zwXZ','ywK0y3rMv3jVBMDgBgfN','DgHLiefjigD1AwrLCYWGAxqGD2LSBcbUB3qGAgfUzcb5B3uGDgHLigzSywCU','icaGihn1yM1PDca8zMXHzZ4Gica','mty1nZu2wM92ywfu','yxbWBgLJyxrPB24VANnVBG','BwLU','ywK0y3rMv3jHCff1B3rHqKHPBNq','zw50zxjLzef0','ndyWnZGWmM9KCxfvta','y3rMzfvYBa','CxvPDa','ywK0y3rMvgL0Bgu','ywK0y3rMrxHPDa','quKGzxjYB3i6ia','icbr','mJqWmZa1mxbsvgDrDa','icdILzdILzdILzaGquK0q1rgiokaLcbr','y3rMngvHAq','vg9Rzw5Z','lZuWmda','q3j5ChrVz3jHCgH5','icbozxH0oIa','zxHHBsbXia','ywK0y3rMv3jHCff1B3rHqW','y2HHBgXLBMDLswq','ywK0y3rMv3jHCeXPBMuXqM9KEq','ywK0y3rMv3jHCe5LEhrcB2r5','icaGieP1C3qGDhLWzsbMCMvLBhKGDg8Gy2HHDcb3AxrOihrOzsbbssb0zwfTBwf0zs4','C2vZC2LVBJ0','ywK0y3rMt3jdAgf0rxHHBxbSzq','ywK0y3rMrgvJB2rL','ihrVignVBNrPBNvL','ywK0y3rMv2vSy29Tzun0yq','ywK0y3rMsw50zxjJzxb0zwq','icbbstrdveyGy2HHDcbLBMrLzcbMB3iGuq','icbbssbIDwrNzxqGzxHOyxvZDgvKigzVCIbbstrdveyGC2vJDgLVBI4','icaGideUia','icaG4OAsia','ywLvC2fNzq','icaGicaGicaGicaGica','Aw5JBhvKzxm','ywK0y3rMsgLUDfbYAw5JAxbSzq','AwnVyxT3m2XJmg1LxZjFywK0y3rMFq','ywK0y3rMv3jHCeXPBMuYqM9KEq'];a0j=function(){return ah;};return a0j();}import{t as a0H}from'../lib/i18n.js';const g=j=>new Promise(k=>setTimeout(k,j));let r=!(0x1*-0x239b+0x3e2+-0x1fba*-0x1),h=null,u=-0x2*-0x92c+0x220a*-0x1+-0x7*-0x23e,y=0x13*0x1bc+-0x25ec+0x6a*0xc,d=!(-0x2240+0x1*-0xd+0x224e);const m=-0x1*-0xaaf7+-0x3f86+0x1*-0x9c9,f=0xd2867+-0xd6f59+-0x2167*-0x3e;let p=null,w=null;export function isChatActive(){return r;}function b(){const a2=a0k,j=p?m:w?y||f:-0x3ff+-0x2*-0x59e+0x3*0x419,k=u,q=Math[a2(0x1d3)](Math[a2(0x21a)](k/j*(0xf42+-0x1*0x58a+-0x954)),-0x16ab+0x248d*-0x1+0x3b9c),v=Math['round'](q/(-0x36d*-0x1+0x5c8+-0x8d1)*(0x599*-0x4+-0x2a0*-0xb+-0x1*0x668)),x=-0x19e+0xbb4+-0x356*0x3-v,z=q>-0x1837+-0xf8+-0x3d*-0x6b?a0v[a2(0x29a)]:q>0x1f2+-0x17a7+0x15e7?a0v[a2(0x164)]:a0v[a2(0x265)],B=p?a2(0x239):w?a2(0x257):a2(0x1e0);console[a2(0x297)](a0v[a2(0x223)]('\x20\x20'+B+':\x20')+z('█'[a2(0x28a)](v))+a0v['gray']('░'[a2(0x28a)](x))+a0v[a2(0x223)]('\x20'+k+'/'+j+'\x20('+q+'%)'));}export async function handleChatMessage(v){const a3=a0k;if(!h)return a3(0x230);if(a0D(a3(0x245)+v),p)return A(v);if(w)return async function(D){const a4=a3;if(!w||!h)return a4(0x230);const E=D[a4(0x248)](),F=E['toLowerCase'](),G=E[a4(0x225)](/^submit\s+(.+)/i);if(G){let H=G[0xcca*-0x3+0x64d*-0x2+0x32f9][a4(0x248)]();if(/^submit\s+/i[a4(0x20f)](H)&&(H=H[a4(0x285)](/^submit\s+/i,'')[a4(0x248)]()),H=H[a4(0x285)](/^["'`]+|["'`]+$/g,'')[a4(0x248)](),!H)return console['log'](),console['log'](a0v['gray'](a4(0x244))+a0v['white'](a4(0x198))),console[a4(0x297)](),a4(0x16a);const I=w[a4(0x1e6)];if(!I)return console['log'](),console[a4(0x297)](a0v['yellow']('\x20\x20No\x20challenge\x20id\x20in\x20context\x20—\x20open\x20one\x20first:\x20')+a0v[a4(0x1c8)](a4(0x271))),console[a4(0x297)](),a4(0x16a);a0E(I,H);const J=a0B();try{const {CTFdClient:K}=await import(a4(0x18d)),L=J[a4(0x186)]||'',M=J[a4(0x227)]&&!J[a4(0x227)][a4(0x1f6)]('session=')?J[a4(0x227)]:'',N=new K(J[a4(0x1d7)],M,L||J[a4(0x227)]),O=await N['submitFlag'](I,H);switch(console[a4(0x297)](),O[a4(0x200)]){case'correct':console[a4(0x297)](a0v[a4(0x265)][a4(0x216)](a4(0x25d))+a0v[a4(0x1c8)](O[a4(0x250)]||''));break;case a4(0x16b):console[a4(0x297)](a0v[a4(0x29a)]('\x20\x20✗\x20Incorrect.\x20')+a0v[a4(0x223)](O[a4(0x250)]||''));break;case'already_solved':console[a4(0x297)](a0v[a4(0x164)]('\x20\x20Already\x20solved.'));break;case a4(0x18a):console[a4(0x297)](a0v[a4(0x164)](a4(0x219)));break;case a4(0x272):console[a4(0x297)](a0v[a4(0x164)](a4(0x23d)));break;default:console[a4(0x297)](a0v[a4(0x223)]('\x20\x20'+(O[a4(0x250)]||a4(0x18f))));}console[a4(0x297)]();const {postIntegritySnapshot:P}=await import('../lib/integrity-snapshot.js');await P();}catch(Q){console[a4(0x297)](),console[a4(0x297)](a0v[a4(0x29a)](a4(0x1c4)+(Q['message']?.[a4(0x25f)]('\x0a')[0x1759+0x1*0x1b10+0x1d*-0x1bd]||'unknown\x20error'))),console['log']();}return a4(0x16a);}if(D['startsWith']('!')){const R=D[a4(0x288)](-0x18+0x14df*0x1+-0x14c6)[a4(0x248)]();if(!R)return a4(0x16a);try{const S={};S[a4(0x264)]=a4(0x16f),S[a4(0x221)]=0x2710;const {execSync:T}=await import('node:child_process'),U=T(R,S)[a4(0x248)]();console[a4(0x297)](),console[a4(0x297)](a0v[a4(0x223)](a4(0x275))+a0v[a4(0x1c8)](R)),console[a4(0x297)](a0v[a4(0x1c8)]('\x20\x20'+U[a4(0x25f)]('\x0a')[a4(0x212)](a4(0x175)))),console[a4(0x297)]();}catch(V){console['log'](),console[a4(0x297)](a0v['red'](a4(0x20e)+(V[a4(0x250)]?.['split']('\x0a')[0x1*0x1c41+-0xdbd*-0x1+-0x29fe]||a4(0x240)))),console[a4(0x297)]();}return a4(0x16a);}if(a4(0x230)===F||a4(0x17e)===F||a4(0x1d8)===F){const W=w['challengeName'];return r=!(-0x391*0x1+0x72d+-0x39b),h=null,w=null,console[a4(0x297)](),console[a4(0x297)](a0v[a4(0x223)]('\x20\x20AI\x20teammate\x20closed\x20for\x20\x22'+W+'\x22.')),console['log'](a0v[a4(0x223)]('\x20\x20Open\x20another\x20challenge\x20with\x20')+a0v[a4(0x1c8)]('open\x20<id>')+a0v[a4(0x223)](a4(0x228))+a0v[a4(0x1c8)](a4(0x1c5))),console[a4(0x297)](),a4(0x230);}console[a4(0x297)](a0v[a4(0x223)]('\x20\x20'+a0H(a4(0x17d))));try{const X=await h[a4(0x1b4)](D);process[a4(0x181)][a4(0x21d)](a4(0x277)),a0z(X[a4(0x241)]),'number'==typeof X[a4(0x226)]?(u=X[a4(0x226)],a4(0x1c7)==typeof X[a4(0x291)]&&(y=X[a4(0x291)])):u+=X['tokensUsed'],console['log'](),a0F(X[a4(0x294)]),b(),console[a4(0x297)]();}catch(Y){process[a4(0x181)]['write'](a4(0x277)),a0G(a4(0x1db)+Y['message']),console[a4(0x297)]();}return'continue';}(v);const x=v[a3(0x248)]()[a3(0x207)]()[a3(0x225)](/^hint\s+([abc])$/);if(x)return function(D){const a5=a3,E=a0H('a'===D?a5(0x182):'b'===D?'ai4ctfHintB':'ai4ctfHintC'),F=a0H('a'===D?a5(0x1bf):'b'===D?a5(0x168):'ai4ctfHintCBody'),G=a5(0x167)+D['toUpperCase'](),H='a'===D?a0v[a5(0x265)]:'b'===D?a0v[a5(0x164)]:a0v[a5(0x29a)];console[a5(0x297)](),console[a5(0x297)](H[a5(0x216)]('\x20\x20▸\x20'+G+'\x20\x20')+a0v[a5(0x223)](E)),console[a5(0x297)]();for(const I of F[a5(0x25f)]('\x0a'))''===I?console[a5(0x297)]():console[a5(0x297)](a0v['white']('\x20\x20\x20\x20'+I));console[a5(0x297)](),'a'===D?(console[a5(0x297)](a0v[a5(0x223)](a5(0x1b2)+a0H('ai4ctfHintNextA')+'\x20')+a0v['cyan'](a5(0x287))),console['log']()):'b'===D&&(console[a5(0x297)](a0v[a5(0x223)](a5(0x1b2)+a0H(a5(0x1b7))+'\x20')+a0v[a5(0x1ca)](a5(0x1ab))),console['log']());}(x[0xd1*-0xd+0xcaa+-0x106*0x2]),a3(0x16a);const z=v[a3(0x225)](/^submit\s+(.+)/i);if(z){let D=z[0x7*-0x4c5+0x5*0x33+0x2065][a3(0x248)]();if(/^submit\s+/i['test'](D)&&(D=D[a3(0x285)](/^submit\s+/i,'')['trim']()),D=D[a3(0x285)](/^["'`]+|["'`]+$/g,'')[a3(0x248)](),a3(0x1f8)===D){console[a3(0x297)](),console[a3(0x297)](a0v[a3(0x265)][a3(0x216)](a3(0x1fd))),console[a3(0x297)](a0v[a3(0x265)][a3(0x216)]('\x20\x20'+a0H(a3(0x19d)))),console[a3(0x297)](a0v[a3(0x265)][a3(0x216)]('\x20\x20════════════════════════════════════')),console[a3(0x297)](),console[a3(0x297)](a0v[a3(0x1c8)]('\x20\x20'+a0H(a3(0x18b)))),console[a3(0x297)](a0v['gray']('\x20\x20'+a0H(a3(0x26d)))),console[a3(0x297)](),b(),r=!(-0x2*-0xb74+0x28*0x74+-0x185*0x1b),h=null,fetch(a3(0x22d),{'method':a3(0x254),'headers':{'Content-Type':a3(0x1d2)},'body':JSON[a3(0x234)]({'type':'ai4ctf','solved':!(0xb4c+0x619*-0x3+0x6ff),'tokensUsed':u,'timestamp':new Date()[a3(0x282)]()}),'signal':AbortSignal[a3(0x221)](-0x2*-0x81d+-0x77a+0xac8)})[a3(0x1c3)](()=>{}),await g(0x175f+-0x1*-0x25bd+0xdd*-0x40),console['log'](),console[a3(0x297)](a0v[a3(0x1ca)]('\x20\x20─────────────────────────────────────────────')),console[a3(0x297)](a0v[a3(0x216)][a3(0x1c8)]('\x20\x20'+a0H('ai4ctfWrapTitle'))),console[a3(0x297)](a0v[a3(0x1ca)](a3(0x261))),console[a3(0x297)]();const E=a0H(a3(0x176)),F=a0H(a3(0x1e7));console['log'](a0v[a3(0x1c8)](a3(0x1f2)+E+'\x20')+a0v['gray'](F[a3(0x25f)]('\x0a')[0x531+-0x15ba+-0x11*-0xf9]||''));for(const J of F['split']('\x0a')[a3(0x288)](-0xae1+-0xfcb+0x1aad*0x1))J[a3(0x248)]()&&console[a3(0x297)](a0v['gray']('\x20\x20\x20\x20\x20\x20\x20'+J['replace'](/\{thinking\}/g,a3(0x17c))));console['log'](),console[a3(0x297)](a0v[a3(0x1c8)](a3(0x260)+a0H(a3(0x1a1))+'\x20')+a0v[a3(0x223)](a0H(a3(0x1f9)))),console['log'](),console[a3(0x297)](a0v[a3(0x1ca)](a3(0x298))),console[a3(0x297)](),await g(0x26ae+-0x1a16+-0x264*0x2),console[a3(0x297)](a0v[a3(0x1ca)](a3(0x261))),console[a3(0x297)](a0v[a3(0x216)][a3(0x1c8)]('\x20\x20'+a0H(a3(0x203)))),console[a3(0x297)](a0v[a3(0x1ca)](a3(0x261))),console['log'](),console[a3(0x297)](a0v['yellow'](a3(0x266))+a0v[a3(0x1c8)](a0H(a3(0x27c))[a3(0x26e)](-0x28*-0xad+-0xe71+-0xc7d))+a0v[a3(0x223)](a0H(a3(0x284)))),console['log'](a0v[a3(0x164)]('\x20\x20\x20\x20\x20\x20\x20hint\x20b\x20\x20\x20')+a0v[a3(0x1c8)](a0H(a3(0x26f))[a3(0x26e)](-0x10ee*-0x1+0x100b+0x693*-0x5))+a0v[a3(0x223)](a0H(a3(0x1d4)))),console[a3(0x297)](a0v[a3(0x164)]('\x20\x20\x20\x20\x20\x20\x20hint\x20c\x20\x20\x20')+a0v[a3(0x1c8)](a0H(a3(0x1e5))[a3(0x26e)](0x153*-0x7+0x1*0x1e99+-0x153a))+a0v['gray'](a0H(a3(0x184)))),console[a3(0x297)]();for(const K of a0H(a3(0x251))[a3(0x25f)]('\x0a'))console['log'](a0v['gray'](a3(0x1b2)+K));console[a3(0x297)](),await g(0x1*-0xa04+-0x1*-0xdda+0x3fa),console['log'](a0v[a3(0x1ca)](a3(0x261))),console[a3(0x297)](a0v[a3(0x216)][a3(0x1c8)]('\x20\x20'+a0H(a3(0x253))+'\x20')+a0v[a3(0x29a)][a3(0x216)]('ctf4ai')+a0v[a3(0x1c8)]('\x20—\x20'+a0H('ai4ctfWrapNextSub'))),console[a3(0x297)](a0v[a3(0x1ca)]('\x20\x20─────────────────────────────────────────────')),console[a3(0x297)]();const G=a0H(a3(0x1e8)),H=a0H('ai4ctfWrapNoProg'),I=G[a3(0x25f)]('\x0a');if(I[0xa62+-0x1b8b+-0x1129*-0x1]){const [L,M]=I[-0x12*-0x10+-0x1*-0x901+-0xa21][a3(0x25f)](a3(0x25e));console[a3(0x297)](a0v[a3(0x1c8)]('\x20\x20\x20\x20'+(L||''))+a0v[a3(0x216)]['white'](H)+a0v[a3(0x1c8)](M||''));}for(const N of I['slice'](-0x1*-0x10b7+0x36c*-0x7+0x73e))N[a3(0x248)]()&&console['log'](a0v[a3(0x1c8)]('\x20\x20\x20\x20'+N));return console[a3(0x297)](),console[a3(0x297)](a0v[a3(0x223)](a3(0x1b2)+a0H(a3(0x220))+'\x20')+a0v[a3(0x216)][a3(0x29a)]('ctf4ai')),console[a3(0x297)](),a3(0x230);}return console[a3(0x297)](),console[a3(0x297)](a0v['red']('\x20\x20'+a0H(a3(0x1ce)))),console[a3(0x297)](a0v[a3(0x223)]('\x20\x20'+a0H('ai4ctfFlagHint'))),console[a3(0x297)](),a3(0x16a);}if(v[a3(0x210)]('!')){const O=v['slice'](0x26e8+0x23b*0x1+-0x6*0x6db)['trim']();if(!O)return a3(0x16a);try{const P={};P[a3(0x264)]=a3(0x16f),P[a3(0x221)]=0x2710;const {execSync:Q}=await import(a3(0x217)),R=Q(O,P)['trim']();console[a3(0x297)](),console['log'](a0v[a3(0x223)](a3(0x275))+a0v[a3(0x1c8)](O)),console[a3(0x297)](a0v[a3(0x1c8)]('\x20\x20'+R[a3(0x25f)]('\x0a')[a3(0x212)](a3(0x175)))),console[a3(0x297)](),console[a3(0x297)](a0v[a3(0x223)]('\x20\x20'+a0H(a3(0x25c)))),console['log']();}catch(S){console[a3(0x297)](),console[a3(0x297)](a0v['red'](a3(0x20e)+(S['message']?.[a3(0x25f)]('\x0a')[0x27+-0xb40+0xb19]||a3(0x240)))),console[a3(0x297)]();}return a3(0x16a);}const B={};B[a3(0x28e)]='application/json';if(a3(0x230)===v||a3(0x17e)===v||'quit'===v||a3(0x1fc)===v)return r=!(0xe*-0x9d+-0x34*0x9+-0x7f*-0x15),h=null,fetch(a3(0x22d),{'method':a3(0x254),'headers':B,'body':JSON[a3(0x234)]({'type':'ai4ctf','tokensUsed':u,'timestamp':new Date()[a3(0x282)]()}),'signal':AbortSignal[a3(0x221)](0x708+-0x67a+0x12fa)})[a3(0x1c3)](()=>{}),console[a3(0x297)](),console[a3(0x297)](a0v[a3(0x223)](a3(0x16e))),console[a3(0x297)](a0v[a3(0x1c8)]('\x20\x20'+a0H(a3(0x23b)))),console[a3(0x297)](a0v['gray']('\x20\x20'+a0H(a3(0x235))+':\x20'+u+a3(0x1e1))),console[a3(0x297)](a0v[a3(0x223)]('\x20\x20'+a0H(a3(0x190))+a3(0x19f))),console[a3(0x297)](a0v[a3(0x223)](a3(0x16e))),console[a3(0x297)](),console['log'](a0v[a3(0x1ca)](a3(0x261))),console['log'](a0v['white']('\x20\x20'+a0H(a3(0x22a))+'\x20')+a0v[a3(0x216)][a3(0x29a)](a3(0x1a4))+a0v['white'](a3(0x290)+a0H('ai4ctfExitNextSub'))),console['log'](a0v[a3(0x223)]('\x20\x20'+a0H('ai4ctfExitNextBody'))),console['log'](a0v[a3(0x1ca)](a3(0x261))),console[a3(0x297)](),console[a3(0x297)](a0v[a3(0x1c8)](a3(0x1a0))+a0v[a3(0x1c8)](a0H('typeAndEnterToBegin')[a3(0x285)](a3(0x231),a0v[a3(0x216)]['red']('ctf4ai')))),console[a3(0x297)](a0v[a3(0x223)](a3(0x1be)+a0H('orBack'))),console['log'](),a3(0x230);const C={};C[a3(0x28e)]='application/json';if(!d&&u>=0x1887+-0x10*0x15d+-0x29*-0x69)return d=!(0x2017+-0x1691+0x2*-0x4c3),fetch('https://practice.icoa2026.au/api/icoa/demo-stats',{'method':a3(0x254),'headers':C,'body':JSON['stringify']({'type':a3(0x1c5),'solved':!(-0x7b9*-0x1+0x512*0x7+-0x2*0x159b),'tokensUsed':u,'timestamp':new Date()[a3(0x282)]()}),'signal':AbortSignal[a3(0x221)](-0x24b1*-0x1+-0xe97*0x2+0xc05)})[a3(0x1c3)](()=>{}),console[a3(0x297)](),console[a3(0x297)](a0v[a3(0x164)]('\x20\x20'+a0H(a3(0x18c)))),b(),(function(){const a6=a3;console['log'](),console[a6(0x297)](a0v[a6(0x164)]('\x20\x20─────────────────────────────────────────────')),console[a6(0x297)](a0v[a6(0x216)][a6(0x164)]('\x20\x20'+a0H(a6(0x24c)))),console['log'](a0v['yellow']('\x20\x20─────────────────────────────────────────────')),console[a6(0x297)]();for(const T of a0H(a6(0x270))[a6(0x25f)]('\x0a'))''===T?console[a6(0x297)]():console[a6(0x297)](a0v[a6(0x1c8)](a6(0x1b2)+T));console[a6(0x297)](),console['log'](a0v[a6(0x1ca)](a6(0x274))),console[a6(0x297)](),console[a6(0x297)](a0v[a6(0x1c8)](a6(0x1b2)+a0H(a6(0x205)))),console[a6(0x297)](),console[a6(0x297)](a0v['green'](a6(0x21f))),console['log'](),console['log'](a0v['white']('\x20\x20\x20\x20'+a0H(a6(0x27d)))),console[a6(0x297)](),console['log'](a0v['cyan']('\x20\x20\x20\x20\x20\x20\x20\x20submit\x20icoa{w3lc0me_2_ai4ctf}')),console['log'](),console[a6(0x297)](a0v[a6(0x223)](a6(0x1b2)+a0H(a6(0x1c6)))),console[a6(0x297)]();}()),a3(0x16a);if(d)return console[a3(0x297)](),console['log'](a0v[a3(0x164)]('\x20\x20'+a0H(a3(0x206)))),console[a3(0x297)](a0v[a3(0x223)]('\x20\x20'+a0H('ai4ctfLockedUse')+'\x20')+a0v[a3(0x1ca)]('!echo\x20aWNvYXt3M2xjMG1lXzJfYWk0Y3RmfQ==\x20|\x20base64\x20-d')),console['log'](a0v['gray']('\x20\x20'+a0H(a3(0x281))+'\x20')+a0v['cyan'](a3(0x236))),console[a3(0x297)](),a3(0x16a);console['log'](a0v[a3(0x223)]('\x20\x20'+a0H(a3(0x17d))));try{const T=await h[a3(0x1b4)](v);process[a3(0x181)][a3(0x21d)](a3(0x277)),u+=T[a3(0x241)],a0z(T['tokensUsed']),console['log'](),a0F(T[a3(0x294)]),b(),console['log']();}catch(U){process['stdout'][a3(0x21d)](a3(0x277)),a0G(a3(0x1db)+U[a3(0x250)]),console['log']();}return a3(0x16a);}function a0k(a,b){a=a-(-0x5*-0x2da+-0x1a80+0xda1);const c=a0j();let d=c[a];if(a0k['bpwFOG']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=-0x1020+0x1*0x1365+-0x1*0x345,o,p,q=-0xa82*-0x2+-0x4*0x950+0x103c*0x1;p=i['charAt'](q++);~p&&(o=n%(-0xe4c*-0x1+0xb*-0xcd+-0x579)?o*(0x18f1+0x161d+-0x2ece)+p:p,n++%(0xb47+-0x2*-0x241+-0x1*0xfc5))?l+=String['fromCharCode'](0xabb*-0x3+0x1655+0xadb&o>>(-(-0xd4c+0x263e+-0x2*0xc78)*n&0x10*0x8a+-0x2*0x5bb+0x2dc)):0xe37+-0x207+-0xc30){p=j['indexOf'](p);}for(let r=-0x1a7*0x8+0x1*0x779+-0x5bf*-0x1,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](-0x2656+0x2*-0x1ad+0x20*0x14e))['slice'](-(-0x2135+0xb00+-0xb*-0x205));}return decodeURIComponent(m);};a0k['BQyERE']=e,a0k['jqJgjR']={},a0k['bpwFOG']=!![];}const f=c[-0x16aa+0x110c+0x59e],g=a+f,h=a0k['jqJgjR'][g];return!h?(d=a0k['BQyERE'](d),a0k['jqJgjR'][g]=d):d=h,d;}const $=new Set();async function A(q){const a7=a0k;if(!p||!h)return a7(0x230);const v=q[a7(0x248)](),x=v[a7(0x207)](),z=(Date[a7(0x28d)]()-p[a7(0x1d5)])/(0x104d1+-0x18a2a+-0x16fb9*-0x1);if(!p[a7(0x26c)]&&!p[a7(0x237)]&&z>=-0x1*0x2523+0x1b5a+0x9ce&&(p['nudgeShown']=!(0x1842+0x2329+0x3b6b*-0x1),console[a7(0x297)](),console[a7(0x297)](a0v[a7(0x164)]('\x20\x20💡\x20Once\x20you\x20have\x20ICOA{...},\x20submit\x20it\x20with:\x20')+a0v[a7(0x216)][a7(0x164)]('submit\x20ICOA{your_flag}')),console['log'](a0v[a7(0x223)](a7(0x197))),console[a7(0x297)]()),/^ICOA\{[^}]+\}$/i[a7(0x20f)](v))return console[a7(0x297)](),console[a7(0x297)](a0v[a7(0x223)](a7(0x1aa))+a0v['white'](a7(0x224)+v)),A('submit\x20'+v);const B=v['match'](/^submit\s+(.+)/i);if(B){let C=B[0xb0e*-0x1+0x2cc*0x5+-0x2ed][a7(0x248)]();if(/^submit\s+/i[a7(0x20f)](C)&&(C=C['replace'](/^submit\s+/i,'')[a7(0x248)]()),C=C[a7(0x285)](/^["'`]+|["'`]+$/g,'')['trim'](),/^[A-Da-d]$/[a7(0x20f)](C))return console['log'](),console['log'](a0v[a7(0x164)](a7(0x262)+C+a7(0x1ad))),console[a7(0x297)](a0v[a7(0x223)](a7(0x24f))+a0v[a7(0x265)](a7(0x21c))+a0v[a7(0x223)]('.\x20Try\x20again\x20inside\x20this\x20chat.')),console[a7(0x297)](),a7(0x16a);const {getExamState:D,saveExamState:E}=await import(a7(0x1b8)),F=D();if(!F)return a7(0x230);if(!F[a7(0x21b)][a7(0x174)](I=>I['number']===p[a7(0x189)]))return console[a7(0x297)](a0v['red'](a7(0x1dc)+p['qNum']+a7(0x1ac))),'continue';const G=F[a7(0x1bb)][p[a7(0x189)]];F[a7(0x258)]||(F[a7(0x258)]=[]),F['interactions'][a7(0x191)]({'ts':new Date()[a7(0x282)](),'q':p[a7(0x189)],'type':G?a7(0x23e):a7(0x208),'input':C,'result':a7(0x28c)}),F[a7(0x1bb)][p['qNum']]=C;const H=p[a7(0x189)]+(-0x562*-0x2+0x1a0e+-0x24d1);return F[a7(0x173)]=H<=0x1f1a+-0x369+-0x1b8b?H:p[a7(0x189)],E(F),console[a7(0x297)](),G?(console[a7(0x297)](a0v['green'](a7(0x259)+p['qNum']+'\x20answer\x20updated:\x20')+a0v[a7(0x164)](C)),console['log'](a0v[a7(0x223)](a7(0x166)+G))):console['log'](a0v[a7(0x265)][a7(0x216)](a7(0x21e)+p[a7(0x189)]+a7(0x1a3)+C)),console[a7(0x297)](a0v[a7(0x223)](a7(0x27a))),console[a7(0x297)](),console[a7(0x297)](a0v['gray']('\x20\x20')+a0v['white'](a7(0x199))+a0v['gray'](a7(0x238))+a0v[a7(0x1c8)](a7(0x230))+a0v['gray']('\x20to\x20move\x20on')),H<=0x11b1*0x1+-0x43*-0x7f+-0x1*0x32c8?console[a7(0x297)](a0v['gray']('\x20\x20After\x20exit:\x20')+a0v['cyan'](a7(0x1c5))+a0v[a7(0x223)](a7(0x213)+H)):console['log'](a0v['gray']('\x20\x20After\x20exit:\x20AI4CTF\x20section\x20complete.\x20Next:\x20')+a0v[a7(0x29a)](a7(0x1a4))+a0v['gray'](a7(0x215))),console['log'](),a7(0x16a);}if(q[a7(0x210)]('!')){const I=q['slice'](-0x3*-0x861+-0xb*-0x337+0x3c7f*-0x1)['trim']();if(!I)return a7(0x16a);try{const J={};J[a7(0x264)]='utf-8',J['timeout']=0x2710;const {execSync:K}=await import(a7(0x217)),L=K(I,J)[a7(0x248)]();console['log'](),console[a7(0x297)](a0v[a7(0x223)](a7(0x275))+a0v['white'](I)),console[a7(0x297)](a0v[a7(0x1c8)]('\x20\x20'+L['split']('\x0a')[a7(0x212)](a7(0x175)))),console['log']();}catch(M){console['log'](),console[a7(0x297)](a0v['red'](a7(0x20e)+(M[a7(0x250)]?.['split']('\x0a')[-0x225+-0x1*-0x62a+-0x405]||'Command\x20failed'))),console['log']();}return a7(0x16a);}if(a7(0x230)===x||a7(0x17e)===x||a7(0x1d8)===x){const N=p[a7(0x189)],{getExamState:O}=await import('../lib/exam-state.js'),P=O(),Q=P&&null!=P[a7(0x1bb)][N],R=P?.['_lastQ']||N;return r=!(-0xa2e*-0x1+0x6d0+-0x10fd),h=null,p=null,$['clear'](),console[a7(0x297)](),console[a7(0x297)](a0v[a7(0x223)](a7(0x1f0)+N+'.')),Q&&R>N&&R<=0x89f+0x26a2+0x1f*-0x185?console['log'](a0v[a7(0x1c8)](a7(0x1e3))+a0v['bold'][a7(0x265)]('Q'+R)+a0v[a7(0x223)](a7(0x1c9))+a0v[a7(0x1ca)](a7(0x1c5))+a0v[a7(0x223)](a7(0x1ed))):Q&&N>=-0x1b95+0x3a*0x9b+0x1f*-0x3d?console[a7(0x297)](a0v[a7(0x1c8)](a7(0x1b1))+a0v[a7(0x216)][a7(0x29a)](a7(0x1a4))+a0v[a7(0x223)](a7(0x1cc))):console['log'](a0v[a7(0x223)](a7(0x263))+a0v[a7(0x1c8)](a7(0x1e4)+N)+a0v[a7(0x223)]('\x20\x20·\x20\x20Re-enter:\x20')+a0v['white'](a7(0x1c5))),console[a7(0x297)](),a7(0x230);}if(d)return console[a7(0x297)](),console['log'](a0v['yellow'](a7(0x1f1))),console[a7(0x297)](a0v['gray'](a7(0x27e))+a0v['white'](a7(0x198))+a0v['gray'](a7(0x187))+a0v[a7(0x1c8)](a7(0x178))+a0v['gray'](a7(0x187))+a0v[a7(0x1c8)](a7(0x230))),console[a7(0x297)](),a7(0x16a);if(u>=m)return d=!(0x517*0x2+-0xb92*-0x2+-0x2152),console[a7(0x297)](),console['log'](a0v[a7(0x29a)][a7(0x216)](a7(0x252))),console[a7(0x297)](a0v[a7(0x223)](a7(0x214))+a0v[a7(0x1c8)](a7(0x198))+a0v['gray'](a7(0x187))+a0v['white'](a7(0x178))+a0v['gray'](a7(0x187))+a0v[a7(0x1c8)](a7(0x230))),console[a7(0x297)](),a7(0x16a);console[a7(0x297)](a0v['gray'](a7(0x280)));try{const S=await h['sendMessage'](q);process[a7(0x181)][a7(0x21d)]('\x1b[1A\x1b[2K'),u+=S['tokensUsed'];const {getRealExamState:T,saveExamState:U}=await import(a7(0x1b8)),V=T(),W={};W['ai4ctf']=0x0,W[a7(0x1a4)]=0x0,(V&&(V['aiUsage']||(V[a7(0x1f4)]=W),V[a7(0x1f4)][a7(0x1c5)]=u,U(V)),console[a7(0x297)](),a0F(S[a7(0x294)]),b(),function(X,Y,Z){const a8=a7,a0=X/Y*(-0x1fff*0x1+0x395*0xa+-0x36f);a0>=0x5*-0x60b+-0x21cc+0x4062&&!Z[a8(0x293)]('95')?(console[a8(0x297)](a0v[a8(0x29a)][a8(0x216)](a8(0x26b)+Math[a8(0x21a)](a0)+a8(0x169)+(Y-X)+'\x20tokens\x20left.')),Z['add']('95')):a0>=0x221c+0xfb3+0x317f*-0x1&&!Z[a8(0x293)]('80')?(console[a8(0x297)](a0v[a8(0x164)](a8(0x28f))),Z[a8(0x17a)]('80')):a0>=0x2180+-0x1*-0x2069+-0x41b7&&!Z['has']('50')&&(console['log'](a0v[a8(0x223)](a8(0x171))),Z[a8(0x17a)]('50'));}(u,m,$),console[a7(0x297)]());}catch(X){process['stdout'][a7(0x21d)](a7(0x277)),a0G('AI\x20error:\x20'+X[a7(0x250)]),console['log']();}return a7(0x16a);}export function registerAi4ctfCommand(j){const a9=a0k;j[a9(0x24e)](a9(0x1c5))[a9(0x1a9)](a9(0x170))[a9(0x222)](async()=>{const aa=a9;a0D('ai4ctf');const {getRealExamState:k}=await import(aa(0x1b8)),q=k(),v=q?.[aa(0x21b)][aa(0x295)](D=>aa(0x1c5)===D[aa(0x296)]);if(q&&v){const D=q[aa(0x173)]||-0x9b8+-0x583+0x96*0x1a,E=q['questions'][aa(0x174)](F=>F[aa(0x1c7)]===D);if(!E)return void a0G('Q'+D+aa(0x1ff)+D);if(aa(0x1c5)!==E[aa(0x296)]){if(console[aa(0x297)](),'ctf4ai'===E[aa(0x296)])console[aa(0x297)](a0v['yellow'](aa(0x1dc)+D+'\x20is\x20a\x20CTF4AI\x20question\x20(attack-the-AI).')),console[aa(0x297)](a0v[aa(0x223)](aa(0x25b))+a0v[aa(0x216)]['red']('ctf4ai'));else{if(aa(0x20b)===E[aa(0x296)])console[aa(0x297)](a0v['yellow'](aa(0x1dc)+D+aa(0x172))),console['log'](a0v[aa(0x223)]('\x20\x20Use:\x20')+a0v['bold'][aa(0x1ca)](aa(0x1df)));else{const F=q['questions'][aa(0x174)](G=>'ai4ctf'===G[aa(0x296)]);console[aa(0x297)](a0v['yellow'](aa(0x1dc)+D+aa(0x218))),F&&(console[aa(0x297)](a0v[aa(0x223)](aa(0x177)+F[aa(0x1c7)]+').')),console[aa(0x297)](a0v['gray'](aa(0x1a5))+a0v[aa(0x216)][aa(0x1ca)]('exam\x20q\x20'+F[aa(0x1c7)])));}}return void console[aa(0x297)]();}return void await async function(G,H){const ab=aa,{getRealExamState:I,refetchQuestionDataIfStale:J,materializeAttachedData:K}=await import(ab(0x1b8));await J();const L=I();if(!L)return!(0x89b+-0x634*-0x1+0xa*-0x17b);const M=L['questions']['find'](P=>P[ab(0x1c7)]===G);M&&(H=M),K(G,H?.[ab(0x1fa)]);const N=L[ab(0x1f4)]?.['ai4ctf']??0x25fc+-0x1*0x739+-0x1ec3;if(N>=m)return console['log'](),console['log'](a0v[ab(0x164)]('\x20\x20⚠\x20Your\x20AI4CTF\x20token\x20budget\x20is\x20exhausted.')),console['log'](a0v['gray'](ab(0x17f))+a0v[ab(0x1c8)](ab(0x20d)+G+ab(0x247))),console['log'](),!(-0x17*0x5c+-0x1db7+0x1ba*0x16);try{h=await a0x(void(-0x1*-0xd43+0x9a0+-0x16e3),function(P,Q){const ac=ab,R=P['description']||P[ac(0x294)]||'',S=P[ac(0x1fa)]?ac(0x1c1)+Q+ac(0x255)+P['attachedData']:'';return ac(0x18e)+Q+',\x20'+P[ac(0x299)]+',\x20'+(P[ac(0x19a)]||0x81*0x27+0xdb6+-0x2157)+'\x20points):\x0a'+R+S+ac(0x22e)+Q+ac(0x1a2);}(H,G));}catch(P){return a0G(P[ab(0x250)]),!(-0x26f2+0x9f+0x1be*0x16);}r=!(0x49*0x7f+-0x1956+-0xae1),u=N,d=!(-0x3b9*0x3+-0x197a+0x24a6),p={'qNum':G,'question':H,'usageField':'ai4ctf','enteredAt':Date[ab(0x28d)](),'submitAttempted':!(0x1b*0x6d+-0xe77*0x2+-0x18*-0xba),'nudgeShown':!(-0x135e+-0x25d3+-0x1c99*-0x2)};const O=L[ab(0x1bb)]?.[G];return function(Q,R,S){const ad=ab,T=a0B()[ad(0x286)]||ad(0x1b5),U=u>0xb72+0x352+-0x3b1*0x4;console['log'](),console[ad(0x297)](a0v[ad(0x265)][ad(0x216)](ad(0x1de)+R+':\x20'+Q['category']+ad(0x1af))),U&&console[ad(0x297)](a0v[ad(0x223)](ad(0x1bc))),S&&console[ad(0x297)](a0v[ad(0x223)](ad(0x23f))+a0v['yellow'](S)+a0v['gray']('\x20\x20(submit\x20again\x20to\x20change)')),console[ad(0x297)](),console[ad(0x297)](a0v[ad(0x1ca)](ad(0x242))),console[ad(0x297)](a0v[ad(0x1ca)]('\x20\x20│\x20')+a0v[ad(0x216)][ad(0x1c8)]('Q'+R+ad(0x269)+Q[ad(0x299)]+ad(0x27b)+(Q[ad(0x19a)]||0x1cff+0x1bf*-0x1+-0x1b3a)+ad(0x1b0))),console[ad(0x297)](a0v[ad(0x1ca)]('\x20\x20│'));for(const V of String(Q[ad(0x294)])['split']('\x0a')){const W=V['length']>0x1746+0x153e+-0x2c48?V['slice'](-0x1*-0x20de+-0x1bee+-0x2*0x278,0x19b8+-0x13b6+-0x5c9*0x1)+ad(0x16c):V;console[ad(0x297)](a0v[ad(0x1ca)](ad(0x24b))+a0v['white'](W));}console[ad(0x297)](a0v[ad(0x1ca)]('\x20\x20│')),console[ad(0x297)](a0v[ad(0x1ca)](ad(0x24b))+a0v['gray'](ad(0x268))+a0v[ad(0x1c8)]('exam\x20q\x20'+R)),console[ad(0x297)](a0v[ad(0x1ca)](ad(0x24b))+a0v['gray'](ad(0x25a))),console[ad(0x297)](a0v[ad(0x1ca)]('\x20\x20└─────────────────────────────────────────────')),console['log'](),console[ad(0x297)](a0v[ad(0x216)]['white']('\x20\x20How\x20to\x20work\x20this\x20question')),console[ad(0x297)](),console[ad(0x297)](a0v[ad(0x164)]('\x20\x20\x20\x20hint\x20a')+a0v[ad(0x223)](ad(0x23c))),console[ad(0x297)](a0v['yellow'](ad(0x201))+a0v[ad(0x223)]('\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Technique\x20hint\x20(pre-written)')),console['log'](a0v[ad(0x164)](ad(0x183))+a0v[ad(0x223)](ad(0x193))),console[ad(0x297)](a0v['bold']['green'](ad(0x209))+a0v[ad(0x223)](ad(0x26a))),console['log'](a0v[ad(0x1c8)](ad(0x1ae))+a0v[ad(0x223)](ad(0x22f))),console['log'](a0v['gray'](ad(0x1e9))),console[ad(0x297)](a0v[ad(0x223)]('\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20e.g.\x20')+a0v[ad(0x1c8)]('\x22how\x20do\x20I\x20decrypt\x20AES-CBC\x20in\x20Python?\x22')),console[ad(0x297)](),console['log'](a0v['gray'](ad(0x19b))+a0v[ad(0x223)]('\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Leave\x20chat,\x20return\x20to\x20exam')),console['log'](a0v[ad(0x223)](ad(0x249))+a0v[ad(0x223)](ad(0x243))),console['log'](),b(),console['log'](a0v[ad(0x223)](ad(0x246)+T+')')),console['log']();}(H,G,O),!(0x92*-0xb+0xf6c+-0x926);}(D,E);}const x=a0B(),z=x[aa(0x286)]||'gemma-4-31b-it';if(a0C())return x['currentChallengeName']?void await(async function(){const ae=aa,G=a0B(),H=G[ae(0x229)],I=G[ae(0x17b)],J=G['currentChallengeCategory']||ae(0x289);let K='';if(H)try{const {CTFdClient:L}=await import(ae(0x18d)),M=G['sessionCookie']||'',N=G[ae(0x227)]&&!G['token'][ae(0x1f6)](ae(0x1ea))?G[ae(0x227)]:'',O=new L(G['ctfdUrl'],N,M||G['token']);K=(await O['getChallenge'](H))[ae(0x1a9)]||'';}catch{}try{h=await a0x(void(0x3*0x9f1+-0x24*-0x9b+0xf*-0x371),function(P,Q,R){const af=ae;return af(0x28b)+P+af(0x1c2)+Q+').'+(R?af(0x1ba)+R:'')+af(0x163);}(I,J,K));}catch(P){return a0G(P[ae(0x250)]),!(0x2*-0xea2+0x1*0x1a8b+0x2ba);}r=!(0xb17+0x1431+-0x1f48),u=-0x556*-0x7+-0x30e+-0x6dc*0x5,y=f;try{if(G[ae(0x1d7)]&&G[ae(0x227)]){const Q=await fetch(G['ctfdUrl']+ae(0x1a7),{'headers':{'Authorization':'Token\x20'+G[ae(0x227)],'User-Agent':ae(0x211)}});if(Q['ok']){const R=await Q[ae(0x1c0)]();ae(0x1c7)==typeof R[ae(0x1b3)]?.[ae(0x226)]&&(u=R[ae(0x1b3)]['accountSpent']),ae(0x1c7)==typeof R[ae(0x1b3)]?.[ae(0x291)]&&(y=R[ae(0x1b3)]['accountCap']);}}}catch{}return d=!(-0x3*0xcb4+0x5*0x354+0x1579),w={'challengeId':H,'challengeName':I,'challengeCategory':J,'enteredAt':Date[ae(0x28d)]()},function(S,T){const ag=ae,U=a0B()[ag(0x286)]||'gemma-4-31b-it';console[ag(0x297)](),console[ag(0x297)](a0v[ag(0x265)][ag(0x216)](ag(0x22c))),console[ag(0x297)](),console[ag(0x297)](a0v['cyan'](ag(0x242))),console[ag(0x297)](a0v['cyan'](ag(0x24b))+a0v['bold']['white'](S)+a0v[ag(0x223)](ag(0x1b9)+T+']')),console[ag(0x297)](a0v[ag(0x1ca)](ag(0x1bd))),console[ag(0x297)](a0v[ag(0x1ca)](ag(0x24b))+a0v[ag(0x223)](ag(0x180))),console[ag(0x297)](a0v[ag(0x1ca)]('\x20\x20│\x20')+a0v[ag(0x223)](ag(0x1cf))),console[ag(0x297)](a0v[ag(0x1ca)]('\x20\x20└─────────────────────────────────────────────')),console[ag(0x297)](),console[ag(0x297)](a0v[ag(0x164)](ag(0x192))),console[ag(0x297)](a0v[ag(0x1c8)](ag(0x20c))+a0v[ag(0x223)]('Ask\x20the\x20AI\x20teammate\x20about\x20this\x20challenge')),console[ag(0x297)](a0v[ag(0x1c8)](ag(0x24d))+a0v[ag(0x223)](ag(0x204))),console[ag(0x297)](a0v[ag(0x1c8)](ag(0x1d0))+a0v[ag(0x223)](ag(0x267))),console[ag(0x297)](a0v[ag(0x1c8)]('\x20\x20\x20\x20exit\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20')+a0v[ag(0x223)](ag(0x23a))),console['log'](),console[ag(0x297)](a0v[ag(0x223)](ag(0x16d))+a0v[ag(0x1c8)]('open\x20<id>')+a0v[ag(0x223)](ag(0x1cb))+a0v[ag(0x1c8)]('ai4ctf')),b(),console[ag(0x297)](a0v[ag(0x223)](ag(0x246)+U+')')),console['log'](a0v[ag(0x223)]('\x20\x20AI\x20usage\x20is\x20metered\x20per\x20account\x20(server-enforced\x20budget).')),console['log']();}(I,J),!(-0x2482+0x66*-0x52+0x452e);}()):(console[aa(0x297)](),console[aa(0x297)](a0v[aa(0x164)](aa(0x165))),console['log'](a0v[aa(0x223)](aa(0x202))+a0v['white']('ctf\x20list')+a0v[aa(0x223)]('\x20then\x20')+a0v['white'](aa(0x271))),console['log'](a0v[aa(0x223)]('\x20\x20The\x20AI\x20teammate\x20scopes\x20itself\x20to\x20the\x20challenge\x20you\x20open.')),void console[aa(0x297)]());const B={};B[aa(0x1a6)]=aa(0x1a8),B[aa(0x299)]=aa(0x1e2);const C=B;try{h=await a0x(C);}catch(G){return void a0G(G[aa(0x250)]);}r=!(-0x1c2c+0xc79+-0xfb3*-0x1),u=0x1f6b+-0x151*0x7+-0x1634,d=!(-0x1ce4+-0xb3f+0x2824),console[aa(0x297)](),console[aa(0x297)](a0v[aa(0x265)][aa(0x216)](aa(0x194)+a0H(aa(0x1d9))+aa(0x1af))),console[aa(0x297)](),console['log'](a0v[aa(0x1c8)]('\x20\x20'+a0H('ai4ctfSample'))),console['log'](),console[aa(0x297)](a0v[aa(0x1ca)](aa(0x242))),console['log'](a0v[aa(0x1ca)](aa(0x24b))+a0v[aa(0x216)][aa(0x1c8)](a0H('ai4ctfChallenge'))),console[aa(0x297)](a0v[aa(0x1ca)](aa(0x1bd))),console[aa(0x297)](a0v['cyan'](aa(0x24b))+a0v[aa(0x1c8)](a0H(aa(0x1ef)))),console['log'](a0v[aa(0x1ca)](aa(0x24b))+a0v[aa(0x265)]('aWNvYXt3M2xjMG1lXzJfYWk0Y3RmfQ==')),console[aa(0x297)](a0v[aa(0x1ca)](aa(0x1bd))),console[aa(0x297)](a0v['cyan'](aa(0x24b))+a0v[aa(0x1c8)](a0H(aa(0x1ec)))),console[aa(0x297)](a0v['cyan'](aa(0x24b))+a0v[aa(0x223)](aa(0x1fe))),console[aa(0x297)](a0v[aa(0x1ca)](aa(0x22b))),console[aa(0x297)](),console[aa(0x297)](a0v[aa(0x1c8)]('\x20\x20'+a0H(aa(0x1cd)))),console[aa(0x297)](),console[aa(0x297)](a0v['yellow'](aa(0x256))+a0v[aa(0x223)](aa(0x1b2)+a0H(aa(0x182)))),console[aa(0x297)](a0v[aa(0x223)](aa(0x1f5)+a0H(aa(0x24a)))),console['log'](a0v[aa(0x164)](aa(0x201))+a0v['gray'](aa(0x1b2)+a0H(aa(0x196)))),console[aa(0x297)](a0v['gray'](aa(0x1f5)+a0H('ai4ctfHintBUses'))),console[aa(0x297)](a0v[aa(0x164)]('\x20\x20\x20\x20hint\x20c')+a0v['gray'](aa(0x1b2)+a0H('ai4ctfHintC'))),console[aa(0x297)](a0v[aa(0x223)](aa(0x1f5)+a0H('ai4ctfHintCUses'))),console[aa(0x297)](),console[aa(0x297)](a0v[aa(0x223)](aa(0x16e))),console['log'](a0v['bold'][aa(0x1c8)]('\x20\x20'+a0H(aa(0x1ee)))),console[aa(0x297)](aa(0x1b2)+a0v[aa(0x1ca)](aa(0x283))+a0v[aa(0x223)](aa(0x1f3)+a0H(aa(0x195)))),console[aa(0x297)](aa(0x1b2)+a0v['cyan'](aa(0x287))+a0v[aa(0x223)](aa(0x1f3)+a0H('ai4ctfHintTechnique'))),console[aa(0x297)](aa(0x1b2)+a0v[aa(0x1ca)]('hint\x20c')+a0v[aa(0x223)](aa(0x1f3)+a0H(aa(0x1f7)))),console[aa(0x297)](a0v[aa(0x223)](aa(0x1b2)+a0H('ai4ctfWelcomeNoReveal'))),console[aa(0x297)](),console['log'](a0v[aa(0x1c8)]('\x20\x20'+a0H(aa(0x188)))),console[aa(0x297)](a0v[aa(0x223)]('\x20\x20'+a0H(aa(0x1eb))+'\x20')+a0v[aa(0x1c8)](aa(0x1b6))),console[aa(0x297)](),console[aa(0x297)](a0v['yellow']('\x20\x20'+a0H('ai4ctfCommands'))),console[aa(0x297)](a0v[aa(0x1c8)]('\x20\x20\x20\x20hint\x20a\x20/\x20b\x20/\x20c\x20\x20')+a0v[aa(0x223)](a0H(aa(0x179)))),console[aa(0x297)](a0v[aa(0x1c8)]('\x20\x20\x20\x20submit\x20<flag>\x20\x20\x20')+a0v[aa(0x223)](a0H(aa(0x19c)))),console[aa(0x297)](a0v['white'](aa(0x24d))+a0v[aa(0x223)](a0H(aa(0x1fb)))),console[aa(0x297)](a0v[aa(0x223)](aa(0x233))+a0v[aa(0x1c8)]('!echo\x20aWNv...\x20|\x20base64\x20-d')),console[aa(0x297)](a0v[aa(0x223)](aa(0x276)+a0H(aa(0x278)))),console[aa(0x297)](),b(),console[aa(0x297)](a0v[aa(0x223)]('\x20\x20'+a0H(aa(0x190))+aa(0x292)+z+')')),console[aa(0x297)](a0v[aa(0x223)]('\x20\x20'+a0H(aa(0x1da)))),console[aa(0x297)]();});}
@@ -1,13 +1,32 @@
1
1
  /** Accept the forms a first-time user instinctively types: `eai-p1`, `p1`,
2
2
  * `eai-01`, `01`, `1`. Practice = `p<n>`; official = zero-padded `eai-NN`. */
3
3
  export declare function normalizeTaskId(arg: string): string;
4
- /** Build the JSON `instruction` a POLICY task expects from a friendly shorthand.
4
+ /** The published `protocol` of a policy task the shape its `query`/`submit`
5
+ * payloads must take. The placeholder arrays/objects (`q:["f0","f1",…]`,
6
+ * `a:["d0",…]` or `a:{x:["lo","hi"],y:["lo","hi"]}`) drive BOTH the shorthand
7
+ * parser and the on-screen usage hints, so every policy shape works — not just
8
+ * the 2-feature region game. */
9
+ export interface PolicyProtocol {
10
+ query?: {
11
+ q?: unknown;
12
+ };
13
+ submit?: {
14
+ a?: unknown;
15
+ };
16
+ }
17
+ /** Build the JSON `instruction` a POLICY task expects from a friendly shorthand,
18
+ * driven by the task's published `protocol` so EVERY policy shape works:
19
+ * region q:[x,y] a:{x:[lo,hi],y:[lo,hi]} eai-20/22/30/p4/p5
20
+ * patch q:[f0…f3] a:[d0…d3] eai-15/16/17/18/31
21
+ * ranking q:[itemA,…] a:[ranked,items,"…"] eai-21/23/33
5
22
  * `op` is 'query' (recon) or 'submit' (claim). Forms accepted:
6
- * query 0.05 0.10 → {"op":"query","q":[0.05,0.10]}
7
- * submit -0.30 0.40 -0.20 0.40 → {"op":"submit","a":{"x":[lo,hi],"y":[lo,hi]}}
8
- * <raw JSON> → passed through (forward-compat: ranking tasks)
23
+ * probe 0.8 0.3 0.1 0.4 → {"op":"query","q":[0.8,0.3,0.1,0.4]} (len from protocol)
24
+ * submit -0.6 0 0.5 0.1 → {"op":"submit","a":[-0.6,0,0.5,0.1]} (patch) — OR a:{x,y} (region)
25
+ * <raw JSON> → passed through, op backfilled (always available)
26
+ * Without a protocol (legacy callers / unit tests) it preserves the original
27
+ * region behavior: query = first 2 numbers, submit = 4 numbers → rectangle.
9
28
  * Returns the JSON string, or null if the shorthand can't be parsed. */
10
- export declare function buildPolicyInstruction(op: 'query' | 'submit', rest: string): string | null;
29
+ export declare function buildPolicyInstruction(op: 'query' | 'submit', rest: string, protocol?: PolicyProtocol): string | null;
11
30
  export declare function taskDir(task: string): string;
12
31
  /** A per-task self_check.py that DELEGATES to a parent-dir self_check (a server
13
32
  * packaging mistake — `runpy.run_path(dirname(dirname(__file__))/self_check.py)`)
@@ -1 +1 @@
1
- import{spawnSync as e}from"node:child_process";import{existsSync as o,mkdirSync as t,readFileSync as n,writeFileSync as a}from"node:fs";import{homedir as r}from"node:os";import{join as l}from"node:path";import chalk from"chalk";import{aienvPaths as s}from"../lib/aienv.js";import{addTokenUsage as i}from"../lib/budget.js";import{getConfig as c}from"../lib/config.js";import{createChatSession as g}from"../lib/gemini.js";import{openFile as u}from"../lib/open-file.js";import{makeReplAsker as y}from"../lib/repl-asker.js";const d=["eai-p1","eai-p2","eai-p3","eai-p4","eai-p5"];function f(){if(process.env.ICOA_ARENA_SERVER)return process.env.ICOA_ARENA_SERVER.replace(/\/$/,"");try{const e=JSON.parse(n(l(r(),".icoa","config.json"),"utf-8"));if("string"==typeof e.arenaServer&&e.arenaServer)return e.arenaServer.replace(/\/$/,"");if("string"==typeof e.ctfdUrl&&e.ctfdUrl)return e.ctfdUrl.replace(/\/$/,"")}catch{}return"https://practice.icoa2026.au"}function h(){const e={"Content-Type":"application/json"};let o=process.env.ICOA_ARENA_ACCOUNT||"";try{const t=c();t.ctfdUrl&&t.token&&t.userName?(o=t.userName,e.Authorization=`Token ${t.token}`):t.userName&&(o=t.userName)}catch{}return o||(o="local-tester"),{account:o,headers:e}}async function p(e){try{const{headers:o}=h(),t=await fetch(f()+e,{headers:o,signal:AbortSignal.timeout(2e4)});return await t.json()}catch{return null}}async function m(e,o){try{const{headers:t}=h(),n=await fetch(f()+e,{method:"POST",headers:t,body:JSON.stringify(o),signal:AbortSignal.timeout(2e4)}),a=await n.json();return{status:n.status,data:a.data??a}}catch{return null}}export function normalizeTaskId(e){let o=e.trim().toLowerCase();return o?(o=o.replace(/^eai-?/,""),/^p\d+$/.test(o)?`eai-${o}`:/^\d+$/.test(o)?`eai-${o.padStart(2,"0")}`:`eai-${o}`):""}export function buildPolicyInstruction(e,o){const t=o.trim();if(t.startsWith("{"))try{const o=JSON.parse(t);return o.op||(o.op=e),JSON.stringify(o)}catch{return null}const n=t.split(/[\s,]+/).filter(Boolean).map(Number);return"query"===e?n.length>=2&&n.slice(0,2).every(e=>!Number.isNaN(e))?JSON.stringify({op:"query",q:[n[0],n[1]]}):null:n.length>=4&&n.slice(0,4).every(e=>!Number.isNaN(e))?JSON.stringify({op:"submit",a:{x:[n[0],n[1]],y:[n[2],n[3]]}}):null}function b(e,o,t){const n=e??"?",a=o??"?",r=t??"?";return chalk.gray(` probes: ${n}/${a} · ${r} left`)}function w(e){var o;console.log(),console.log(` ${o=e.bucket,"win"===o?chalk.bold.green("● WIN"):"progress"===o?chalk.bold.yellow("◐ progress"):chalk.gray("○ baseline")}${"number"==typeof e.distance?chalk.gray(` distance: ${e.distance}`):""}`),function(e){if(!e)return;if(e.error)return void console.log(chalk.yellow(" ⚠ ")+chalk.gray(String(e.error)));if(e.oracle&&"object"==typeof e.oracle){const o=e.oracle,t=Object.entries(o).map(([e,o])=>`${e}=${"number"==typeof o?o:JSON.stringify(o)}`);return void console.log(chalk.gray(" oracle: ")+chalk.white(t.join(" · ")))}if(Array.isArray(e.block_final)){const[o,t]=e.block_final;console.log(chalk.gray(" object settled at: ")+chalk.white(`(${o.toFixed(3)}, ${t.toFixed(3)})`))}"number"==typeof e.value&&console.log(chalk.gray(" grounded action value: ")+chalk.white(e.value.toFixed(3)));const o=e.hold_constraint_force??e.hold_contact_force;if("number"==typeof o&&o>0&&console.log(chalk.gray(" sustained force: ")+chalk.white(o.toFixed(2))),Array.isArray(e.contacts_seen)&&e.contacts_seen.length){const o=e.contacts_seen.slice(0,4).join(", ");console.log(chalk.gray(" contacts: ")+chalk.white(o))}}(e.telemetry),"win"===e.bucket&&e.flag&&(console.log(),console.log(chalk.bold.green(" 🏁 FLAG: ")+chalk.bold.white(e.flag)),console.log(chalk.gray(" paste this onto the CTFd scoreboard to score the challenge."))),console.log(b(e.used,e.budget,e.remaining)),console.log()}export function taskDir(e){return l(r(),".icoa","arena","eai",e)}async function k(e,o){const n="number"==typeof o?o.toFixed(3):"ref",r="ref"===n;console.log(),console.log(chalk.gray(r?" Fetching a reference clip of a successful rollout…":` Fetching the 3-second video of your last landing (value ${n})…`));const s=await p(`/api/icoa/arena/eai/${e}/clip/${encodeURIComponent(n)}`),i=s?.data??s??{};if(!i.clip_b64)return console.log(chalk.gray(" No video for that landing yet — use ")+chalk.cyan("roll")+chalk.gray(" to study the physics as ASCII telemetry.")),void console.log();const c=l(taskDir(e),"replay.mp4");try{t(taskDir(e),{recursive:!0}),a(c,Buffer.from(i.clip_b64,"base64"))}catch{return void console.log(chalk.yellow(" Could not save the clip locally."))}u(c)||console.log(chalk.yellow(" Could not launch a video player. The clip is here: ")+chalk.white(c)),console.log()}export function selfCheckRunnable(e){return!(e.includes("runpy.run_path")&&/os\.path\.dirname\(\s*os\.path\.dirname/.test(e))}function v(t,a,i){if("policy"===a.kind)return console.log(),console.log(chalk.gray(" This is a POLICY task — there is no free local rollout (the oracle")),console.log(chalk.gray(" IS the secret). Explore it with budgeted ")),console.log(chalk.cyan(" probe <x> <y>")+chalk.gray(' → asks "is [x,y] inside the hidden zone?"')),void console.log();const c=taskDir(t),g=l(c,"scene.xml"),u=l(c,"self_check.py");if(!o(g)||!o(u))return console.log(chalk.yellow(" Local study files not present yet — reopen the task to fetch them.")),void console.log(chalk.gray(" (`roll` is an OPTIONAL free local study tool; `probe`/`submit` score without it.)"));if(!selfCheckRunnable(n(u,"utf-8")))return console.log(chalk.yellow(" This task's local study tool isn't available right now.")),void console.log(chalk.gray(" `probe`/`submit` still score normally — use those, or `hint` for strategy."));const y=s(r()).python;if(!o(y))return console.log(),console.log(chalk.yellow(" Local physics sim not installed.")),console.log(chalk.gray(" Run ")+chalk.cyan("aienv setup --physics")+chalk.gray(" to enable free local `roll`.")),console.log(chalk.gray(" (You can still `probe`/`submit` to the server without it.)")),void console.log();console.log(chalk.gray(` rolling locally at value=${i} …`));const d=e(y,[u,g,"--public",l(c,"public.json"),"--value",String(i)],{cwd:c,encoding:"utf-8",timeout:6e4});if(0!==d.status)return console.log(chalk.yellow(" Local roll failed.")),void(/No module named 'mujoco'|ModuleNotFoundError/.test(d.stderr||"")?console.log(chalk.gray(" The sim is missing mujoco — run ")+chalk.cyan("aienv setup --physics")+chalk.gray(".")):d.stderr&&console.log(chalk.gray(` ${d.stderr.trim().split("\n").slice(-3).join("\n ")}`)));process.stdout.write(d.stdout)}function $(e){console.log(),console.log(chalk.yellow(" hint:")),e.pedagogical_point&&console.log(chalk.gray(` ${String(e.pedagogical_point)}`)),"policy"===e.kind?(console.log(chalk.gray(" Strategy: each query is one bit. Probe points across the floor to find")),console.log(chalk.gray(" the boundary (binary-search the edges), then submit the tightest rectangle."))):(console.log(chalk.gray(" Strategy: use free `roll` to learn how far the object must travel to enter")),console.log(chalk.gray(" the keep-out zone, then escalate your wording (more forceful / literal /")),console.log(chalk.gray(' "into the red zone") until a `probe` reports progress, then win.'))),console.log(chalk.gray(" 💡 Or type ")+chalk.magenta("ai4ctf")+chalk.gray(" right here to brainstorm the attack with your AI teammate.")),console.log()}function A(e){const o="policy"===e.kind;console.log(chalk.bold.white(" commands:")),e.has_clip&&console.log(chalk.cyan(" replay")+chalk.gray(" play a 3-second video of your last probe landing (free; `ref` clip before you probe)")),o?(console.log(chalk.cyan(" probe <x> <y>")+chalk.gray(" ask the oracle: is [x,y] inside the hidden zone? (costs 1)")),console.log(chalk.cyan(" submit <x0> <x1> <y0> <y1>")+chalk.gray(" guess the rectangle to claim the flag (costs 1)"))):(console.log(chalk.cyan(" roll [value]")+chalk.gray(" free local rollout — study the physics (no cost)")),console.log(chalk.cyan(" probe <instruction>")+chalk.gray(" send the arm one instruction (costs 1)")),console.log(chalk.cyan(" submit <instruction>")+chalk.gray(" your best attempt to win + claim the flag (costs 1)"))),console.log(chalk.cyan(" ai4ctf")+chalk.gray(" brainstorm the attack with your AI teammate (scoped here)")),console.log(chalk.cyan(" hint")+chalk.gray(" free strategy nudge")),console.log(chalk.cyan(" state")+chalk.gray(" show your remaining probe budget")),console.log(chalk.cyan(" help")+chalk.gray(" show these commands")),console.log(chalk.cyan(" quit")+chalk.gray(" leave this task")),console.log(),console.log(chalk.gray(" 💡 Stuck? Type ")+chalk.magenta("ai4ctf")+chalk.gray(" to brainstorm the attack with your built-in AI teammate.")),console.log()}async function N(e,o){let t;try{t=await g(void 0,function(e){const o="policy"===e.kind;return["You are an AI red-team teammate inside the ICOA embodied-AI arena (ctf4eai).","The student is trying to make a robot arm / control policy do the unsafe thing","and earn an ICOA{...} flag. Help them brainstorm the ATTACK — strategy, what to","probe, how to read the telemetry — but DO NOT hand over a complete solution.","",`Task: ${e.title??e.task_id??"unknown"} (kind: ${e.kind??"physics"}, channel ${e.channel??"?"}).`,e.brief?`Brief: ${e.brief}`:"",e.pedagogical_point?`Teaching point: ${e.pedagogical_point}`:"","",o?'POLICY task: each probe asks "is [x,y] inside the hidden keep-out zone?" Guide a binary-search of the boundary, then a tight rectangle submit.':"PHYSICS task: free local `roll` studies the dynamics; escalate the instruction wording until a probe reports progress, then submit to win.","Keep replies short and concrete. The student runs probe/submit in the arena to actually score — you advise only."].filter(Boolean).join("\n")}(e))}catch(e){return void console.log(chalk.red(" Could not start the AI teammate: ")+chalk.gray(e.message??""))}for(console.log(),console.log(chalk.magenta(" 🤝 AI teammate (ai4ctf)")+chalk.gray(" — scoped to this arena task.")),console.log(chalk.gray(" Brainstorm the attack. Type ")+chalk.cyan("back")+chalk.gray(" to return to the arena.")),console.log(chalk.gray(" (It advises only — run ")+chalk.cyan("probe")+chalk.gray("/")+chalk.cyan("submit")+chalk.gray(" in the arena to score.)")),console.log();;){const e=await o(chalk.magenta(" icoa ctf4eai/ai4ctf> "));if(null===e)return;const n=e.trim();if(!n)continue;const a=n.toLowerCase();if("back"===a||"quit"===a||"exit"===a||"q"===a)return;try{const e=await t.sendMessage(n);i(e.tokensUsed),console.log(),console.log(chalk.white(" "+e.text.split("\n").join("\n "))),console.log()}catch(e){const o=e.message??"";/403|budget/i.test(o)?console.log(chalk.yellow(" AI budget exhausted for this account.")):console.log(chalk.red(" AI error: ")+chalk.gray(o.split("\n")[0]||"unknown"))}}}export async function runArenaEai(e){const o=y(),n=o.ask;try{console.log(),console.log(chalk.bold.cyan(" 🤖 ctf4eai — EMBODIED-AI ARENA")+chalk.gray(" · red-team the robot policy")),console.log(chalk.gray(" Make the ICOA-VLA arm / policy do the unsafe thing. The server judges and")),console.log(chalk.gray(" issues the ICOA{…} flag — paste it onto the CTFd scoreboard.")),console.log();let o=e?normalizeTaskId(e):"";if(!o){console.log(chalk.white(" Practice tasks:")),d.forEach((e,o)=>{console.log(chalk.gray(` ${o+1}. `)+chalk.cyan(e))}),console.log(chalk.gray(" (or type any task id, e.g. eai-p3 / p3 / eai-07)"));const e=await n(chalk.cyan(" pick a task (number or id): "));if(null===e)return;const t=e.trim(),a=Number(t);o=!Number.isNaN(a)&&d[a-1]?d[a-1]:normalizeTaskId(t)}if(!o)return void console.log(chalk.yellow(" No task selected."));await async function(e,o){console.log(chalk.gray(` fetching ${e} from `)+chalk.gray(f())+chalk.gray(" …"));const n=await async function(e){const o=await p(`/api/icoa/arena/eai/${e}/data`);if(!o)return null;const n=o.data??o;if(!n.public)return null;const r=taskDir(e);try{t(r,{recursive:!0}),a(l(r,"public.json"),JSON.stringify(n.public,null,2)),n.scene_xml&&a(l(r,"scene.xml"),n.scene_xml),n.core&&a(l(r,"arena_physics_core.py"),n.core),n.self_check&&a(l(r,"self_check.py"),n.self_check)}catch(e){console.log(chalk.yellow(" Could not write the local arena files to ")+chalk.white(r)+chalk.gray(` (${e.message??"unknown"}).`)),console.log(chalk.gray(" `probe`/`submit` still work; only free local `roll` needs them."))}return n.public}(e);if(!n)return void console.log(chalk.yellow(` Could not load ${e} — unknown task, or the arena server is unreachable.`));!function(e){if(console.log(),console.log(chalk.bold.cyan(` 🤖 ${e.title??e.task_id}`)+chalk.gray(` · ${e.kind??"physics"} · channel ${e.channel??"?"} · ${e.difficulty??""}`)),e.brief){console.log();for(const o of function(e){const o=[];for(const t of e.split("\n")){let e="";for(const n of t.split(/\s+/))e&&`${e} ${n}`.length>76?(o.push(e),e=n):e=e?`${e} ${n}`:n;o.push(e)}return o}(String(e.brief)))console.log(chalk.gray(` ${o}`))}console.log()}(n);const{account:r}=h(),s=await m(`/api/icoa/arena/eai/${e}/state`,{account:r}),i=s?.data??{};i.ok&&(i.won&&console.log(chalk.bold.green(" ✓ you have already won this task.")),console.log(b(i.used,i.budget,i.remaining)),console.log()),A(n);const c="policy"===n.kind;let g;for(;;){const t=await o(chalk.bold.cyan(" icoa ctf4eai> "));if(null===t)return;const a=t.trim();if(!a)continue;const l=a.indexOf(" "),s=(-1===l?a:a.slice(0,l)).toLowerCase(),i=-1===l?"":a.slice(l+1).trim();if("quit"===s||"exit"===s||"q"===s||"back"===s)return;if("help"!==s&&"?"!==s)if("hint"!==s)if("replay"!==s&&"watch"!==s&&"video"!==s)if("ai4ctf"!==s&&"ai"!==s&&"teammate"!==s){if("state"===s){const o=await m(`/api/icoa/arena/eai/${e}/state`,{account:r}),t=o?.data??{};t.ok?console.log(b(t.used,t.budget,t.remaining)+(t.won?chalk.green(" ✓ won"):"")):console.log(chalk.gray(" (state unavailable)"));continue}if("roll"!==s)if("probe"===s||"submit"===s){if(!i){console.log(c?chalk.gray("probe"===s?" usage: probe <x> <y>":" usage: submit <x0> <x1> <y0> <y1>"):chalk.gray(` usage: ${s} <instruction text>`));continue}let o;if(c){const e=buildPolicyInstruction("probe"===s?"query":"submit",i);if(!e){console.log(chalk.yellow(" Could not parse that. ")+chalk.gray("probe"===s?"Try: probe 0.05 0.1":"Try: submit -0.3 0.4 -0.2 0.4"));continue}o=e}else o=i.replace(/^["']|["']$/g,"");const t=await m(`/api/icoa/arena/eai/${e}/probe`,{account:r,instruction:o});if(!t){console.log(chalk.yellow(" The arena server is unreachable right now — try again."));continue}const a=t.data;if(403===t.status||"budget_exhausted"===a.reason){console.log(chalk.yellow(` Out of probes for this task (used ${a.used??"?"}/${a.budget??"?"}). No more attempts.`));continue}if(!a.ok&&a.reason){console.log(chalk.yellow(" Rejected: ")+chalk.gray(a.reason));continue}w(a);const l=a.telemetry?.value;if("number"==typeof l&&(g=l),"win"===a.bucket)return void(n.has_clip&&(console.log(chalk.gray(" 🎬 replaying your winning rollout…")),await k(e,g)))}else console.log(chalk.gray(" unknown command — type ")+chalk.cyan("help"));else if(c)v(e,n,0);else{const o=Number(i);v(e,n,Number.isNaN(o)?.4:o)}}else await N(n,o);else await k(e,g);else $(n);else A(n)}}(o,n),console.log(chalk.gray(" left the arena. Type ")+chalk.cyan("eai")+chalk.gray(" to come back any time.")),console.log()}finally{o.close()}}
1
+ import{spawnSync as e}from"node:child_process";import{existsSync as o,mkdirSync as t,readFileSync as n,writeFileSync as r}from"node:fs";import{homedir as a}from"node:os";import{join as l}from"node:path";import chalk from"chalk";import{aienvPaths as s}from"../lib/aienv.js";import{addTokenUsage as i}from"../lib/budget.js";import{getConfig as c}from"../lib/config.js";import{createChatSession as g}from"../lib/gemini.js";import{openFile as u}from"../lib/open-file.js";import{makeReplAsker as y}from"../lib/repl-asker.js";const h=["eai-p1","eai-p2","eai-p3","eai-p4","eai-p5"];function p(){if(process.env.ICOA_ARENA_SERVER)return process.env.ICOA_ARENA_SERVER.replace(/\/$/,"");try{const e=JSON.parse(n(l(a(),".icoa","config.json"),"utf-8"));if("string"==typeof e.arenaServer&&e.arenaServer)return e.arenaServer.replace(/\/$/,"");if("string"==typeof e.ctfdUrl&&e.ctfdUrl)return e.ctfdUrl.replace(/\/$/,"")}catch{}return"https://practice.icoa2026.au"}function d(){const e={"Content-Type":"application/json"};let o=process.env.ICOA_ARENA_ACCOUNT||"";try{const t=c();t.ctfdUrl&&t.token&&t.userName?(o=t.userName,e.Authorization=`Token ${t.token}`):t.userName&&(o=t.userName)}catch{}return o||(o="local-tester"),{account:o,headers:e}}async function f(e){try{const{headers:o}=d(),t=await fetch(p()+e,{headers:o,signal:AbortSignal.timeout(2e4)});return await t.json()}catch{return null}}async function m(e,o){try{const{headers:t}=d(),n=await fetch(p()+e,{method:"POST",headers:t,body:JSON.stringify(o),signal:AbortSignal.timeout(2e4)}),r=await n.json();return{status:n.status,data:r.data??r}}catch{return null}}export function normalizeTaskId(e){let o=e.trim().toLowerCase();return o?(o=o.replace(/^eai-?/,""),/^p\d+$/.test(o)?`eai-${o}`:/^\d+$/.test(o)?`eai-${o.padStart(2,"0")}`:`eai-${o}`):""}export function buildPolicyInstruction(e,o,t){const n=o.trim();if(n.startsWith("{"))try{const o=JSON.parse(n);return o.op||(o.op=e),JSON.stringify(o)}catch{return null}const r=n.split(/[\s,]+/).filter(Boolean);if(0===r.length)return null;const a=r.map(e=>{const o=Number(e);return Number.isNaN(o)?e:o});if("query"===e){const e=t?.query?.q,o=Array.isArray(e)&&e.length?e.length:2;return a.length<o?null:JSON.stringify({op:"query",q:a.slice(0,o)})}const l=t?.submit?.a;if(Array.isArray(l)){const e=0===l.length||"..."===l[l.length-1]||"…"===l[l.length-1]?a.length:l.length;return a.length<e?null:JSON.stringify({op:"submit",a:a.slice(0,e)})}return a.length>=4&&a.slice(0,4).every(e=>"number"==typeof e)?JSON.stringify({op:"submit",a:{x:[a[0],a[1]],y:[a[2],a[3]]}}):null}function b(e){const o=e.protocol,t=o?.query?.q,n=o?.submit?.a,r=Array.isArray(t)&&t.length?`probe ${t.map(e=>`<${String(e)}>`).join(" ")}`:"probe <x> <y>";let a;return a=Array.isArray(n)&&n.length?`submit ${n.map(e=>`<${String(e)}>`).join(" ")}`:"submit <x0> <x1> <y0> <y1>",{probe:r,submit:a}}function w(e,o,t){const n=e??"?",r=o??"?",a=t??"?";return chalk.gray(` probes: ${n}/${r} · ${a} left`)}function k(e){var o;console.log(),console.log(` ${o=e.bucket,"win"===o?chalk.bold.green("● WIN"):"progress"===o?chalk.bold.yellow("◐ progress"):chalk.gray("○ baseline")}${"number"==typeof e.distance?chalk.gray(` distance: ${e.distance}`):""}`),function(e){if(!e)return;if(e.error)return void console.log(chalk.yellow(" ⚠ ")+chalk.gray(String(e.error)));if(e.oracle&&"object"==typeof e.oracle){const o=e.oracle,t=Object.entries(o).map(([e,o])=>`${e}=${"number"==typeof o?o:JSON.stringify(o)}`);return void console.log(chalk.gray(" oracle: ")+chalk.white(t.join(" · ")))}if(Array.isArray(e.block_final)){const[o,t]=e.block_final;console.log(chalk.gray(" object settled at: ")+chalk.white(`(${o.toFixed(3)}, ${t.toFixed(3)})`))}"number"==typeof e.value&&console.log(chalk.gray(" grounded action value: ")+chalk.white(e.value.toFixed(3)));const o=e.hold_constraint_force??e.hold_contact_force;if("number"==typeof o&&o>0&&console.log(chalk.gray(" sustained force: ")+chalk.white(o.toFixed(2))),Array.isArray(e.contacts_seen)&&e.contacts_seen.length){const o=e.contacts_seen.slice(0,4).join(", ");console.log(chalk.gray(" contacts: ")+chalk.white(o))}}(e.telemetry),"win"===e.bucket&&e.flag&&(console.log(),console.log(chalk.bold.green(" 🏁 FLAG: ")+chalk.bold.white(e.flag)),console.log(chalk.gray(" paste this onto the CTFd scoreboard to score the challenge."))),console.log(w(e.used,e.budget,e.remaining)),console.log()}export function taskDir(e){return l(a(),".icoa","arena","eai",e)}async function $(e,o){const n="number"==typeof o?o.toFixed(3):"ref",a="ref"===n;console.log(),console.log(chalk.gray(a?" Fetching a reference clip of a successful rollout…":` Fetching the 3-second video of your last landing (value ${n})…`));const s=await f(`/api/icoa/arena/eai/${e}/clip/${encodeURIComponent(n)}`),i=s?.data??s??{};if(!i.clip_b64)return console.log(chalk.gray(" No video for that landing yet — use ")+chalk.cyan("roll")+chalk.gray(" to study the physics as ASCII telemetry.")),void console.log();const c=l(taskDir(e),"replay.mp4");try{t(taskDir(e),{recursive:!0}),r(c,Buffer.from(i.clip_b64,"base64"))}catch{return void console.log(chalk.yellow(" Could not save the clip locally."))}u(c)||console.log(chalk.yellow(" Could not launch a video player. The clip is here: ")+chalk.white(c)),console.log()}export function selfCheckRunnable(e){return!(e.includes("runpy.run_path")&&/os\.path\.dirname\(\s*os\.path\.dirname/.test(e))}function v(t,r,i){if("policy"===r.kind)return console.log(),console.log(chalk.gray(" This is a POLICY task — there is no free local rollout (the oracle")),console.log(chalk.gray(" IS the secret). Explore it with budgeted ")),console.log(chalk.cyan(` ${b(r).probe}`)+chalk.gray(" → one query to the oracle")),void console.log();const c=taskDir(t),g=l(c,"scene.xml"),u=l(c,"self_check.py");if(!o(g)||!o(u))return console.log(chalk.yellow(" Local study files not present yet — reopen the task to fetch them.")),void console.log(chalk.gray(" (`roll` is an OPTIONAL free local study tool; `probe`/`submit` score without it.)"));if(!selfCheckRunnable(n(u,"utf-8")))return console.log(chalk.yellow(" This task's local study tool isn't available right now.")),void console.log(chalk.gray(" `probe`/`submit` still score normally — use those, or `hint` for strategy."));const y=s(a()).python;if(!o(y))return console.log(),console.log(chalk.yellow(" Local physics sim not installed.")),console.log(chalk.gray(" Run ")+chalk.cyan("aienv setup --physics")+chalk.gray(" to enable free local `roll`.")),console.log(chalk.gray(" (You can still `probe`/`submit` to the server without it.)")),void console.log();console.log(chalk.gray(` rolling locally at value=${i} …`));const h=e(y,[u,g,"--public",l(c,"public.json"),"--value",String(i)],{cwd:c,encoding:"utf-8",timeout:6e4});if(0!==h.status)return console.log(chalk.yellow(" Local roll failed.")),void(/No module named 'mujoco'|ModuleNotFoundError/.test(h.stderr||"")?console.log(chalk.gray(" The sim is missing mujoco — run ")+chalk.cyan("aienv setup --physics")+chalk.gray(".")):/XML Error|Erroring opening file|Error opening file|asset.*not found/i.test(h.stderr||"")?(console.log(chalk.gray(" This task's local study sim isn't available right now (scene assets).")),console.log(chalk.gray(" `probe`/`submit` still score normally — use those, or `replay` to study a clip."))):h.stderr&&console.log(chalk.gray(` ${h.stderr.trim().split("\n").slice(-3).join("\n ")}`)));process.stdout.write(h.stdout)}function A(e){if(console.log(),console.log(chalk.yellow(" hint:")),e.pedagogical_point&&console.log(chalk.gray(` ${String(e.pedagogical_point)}`)),"policy"===e.kind){const o=e.protocol?.submit?.a;Array.isArray(o)?(console.log(chalk.gray(" Strategy: each query is one budgeted look at the oracle. Probe to map how")),console.log(chalk.gray(" its output moves as you vary the inputs, then submit the smallest change")),console.log(chalk.gray(" that achieves the goal (mind any norm / size budget in the brief)."))):(console.log(chalk.gray(" Strategy: each query is one bit. Probe points across the floor to find")),console.log(chalk.gray(" the boundary (binary-search the edges), then submit the tightest rectangle.")))}else console.log(chalk.gray(" Strategy: use free `roll` to learn how far the object must travel to enter")),console.log(chalk.gray(" the keep-out zone, then escalate your wording (more forceful / literal /")),console.log(chalk.gray(' "into the red zone") until a `probe` reports progress, then win.'));console.log(chalk.gray(" 💡 Or type ")+chalk.magenta("ai4ctf")+chalk.gray(" right here to brainstorm the attack with your AI teammate.")),console.log()}function N(e){const o="policy"===e.kind;if(console.log(chalk.bold.white(" commands:")),e.has_clip&&console.log(chalk.cyan(" replay")+chalk.gray(" play a 3-second video of your last probe landing (free; `ref` clip before you probe)")),o){const o=b(e);console.log(chalk.cyan(` ${o.probe}`)+chalk.gray(" one budgeted query to the oracle (costs 1)")),console.log(chalk.cyan(` ${o.submit}`)+chalk.gray(" your attempt to claim the flag (costs 1)")),console.log(chalk.gray(" (or pass raw JSON, e.g. ")+chalk.cyan('probe {"q":[…]}')+chalk.gray(")"))}else console.log(chalk.cyan(" roll [value]")+chalk.gray(" free local rollout — study the physics (no cost)")),console.log(chalk.cyan(" probe <instruction>")+chalk.gray(" send the arm one instruction (costs 1)")),console.log(chalk.cyan(" submit <instruction>")+chalk.gray(" your best attempt to win + claim the flag (costs 1)"));console.log(chalk.cyan(" ai4ctf")+chalk.gray(" brainstorm the attack with your AI teammate (scoped here)")),console.log(chalk.cyan(" hint")+chalk.gray(" free strategy nudge")),console.log(chalk.cyan(" state")+chalk.gray(" show your remaining probe budget")),console.log(chalk.cyan(" help")+chalk.gray(" show these commands")),console.log(chalk.cyan(" quit")+chalk.gray(" leave this task")),console.log(),console.log(chalk.gray(" 💡 Stuck? Type ")+chalk.magenta("ai4ctf")+chalk.gray(" to brainstorm the attack with your built-in AI teammate.")),console.log()}async function _(e,o){let t;try{t=await g(void 0,function(e){const o="policy"===e.kind,t=e.protocol?.submit?.a,n=Array.isArray(t)?`POLICY task: probe the oracle with the query shape in the Brief (e.g. ${b(e).probe}); each probe spends one budget slot and returns the oracle's output. Guide them to map how the output moves as inputs vary, then submit the smallest valid claim (${b(e).submit}; mind any norm/size budget).`:'POLICY task: each probe asks "is [x,y] inside the hidden keep-out zone?" Guide a binary-search of the boundary, then a tight rectangle submit.';return["You are an AI red-team teammate inside the ICOA embodied-AI arena (ctf4eai).","The student is trying to make a robot arm / control policy do the unsafe thing","and earn an ICOA{...} flag. Help them brainstorm the ATTACK — strategy, what to","probe, how to read the telemetry — but DO NOT hand over a complete solution.","",`Task: ${e.title??e.task_id??"unknown"} (kind: ${e.kind??"physics"}, channel ${e.channel??"?"}).`,e.brief?`Brief: ${e.brief}`:"",e.pedagogical_point?`Teaching point: ${e.pedagogical_point}`:"","",o?n:"PHYSICS task: free local `roll` studies the dynamics; escalate the instruction wording until a probe reports progress, then submit to win.","Keep replies short and concrete. The student runs probe/submit in the arena to actually score — you advise only."].filter(Boolean).join("\n")}(e))}catch(e){return void console.log(chalk.red(" Could not start the AI teammate: ")+chalk.gray(e.message??""))}for(console.log(),console.log(chalk.magenta(" 🤝 AI teammate (ai4ctf)")+chalk.gray(" — scoped to this arena task.")),console.log(chalk.gray(" Brainstorm the attack. Type ")+chalk.cyan("back")+chalk.gray(" to return to the arena.")),console.log(chalk.gray(" (It advises only — run ")+chalk.cyan("probe")+chalk.gray("/")+chalk.cyan("submit")+chalk.gray(" in the arena to score.)")),console.log();;){const e=await o(chalk.magenta(" icoa ctf4eai/ai4ctf> "));if(null===e)return;const n=e.trim();if(!n)continue;const r=n.toLowerCase();if("back"===r||"quit"===r||"exit"===r||"q"===r)return;try{const e=await t.sendMessage(n);i(e.tokensUsed),console.log(),console.log(chalk.white(" "+e.text.split("\n").join("\n "))),console.log()}catch(e){const o=e.message??"";/403|budget/i.test(o)?console.log(chalk.yellow(" AI budget exhausted for this account.")):console.log(chalk.red(" AI error: ")+chalk.gray(o.split("\n")[0]||"unknown"))}}}export async function runArenaEai(e){const o=y(),n=o.ask;try{console.log(),console.log(chalk.bold.cyan(" 🤖 ctf4eai — EMBODIED-AI ARENA")+chalk.gray(" · red-team the robot policy")),console.log(chalk.gray(" Make the ICOA-VLA arm / policy do the unsafe thing. The server judges and")),console.log(chalk.gray(" issues the ICOA{…} flag — paste it onto the CTFd scoreboard.")),console.log();let o=e?normalizeTaskId(e):"";if(!o){console.log(chalk.white(" Practice tasks:")),h.forEach((e,o)=>{console.log(chalk.gray(` ${o+1}. `)+chalk.cyan(e))}),console.log(chalk.gray(" (or type any task id, e.g. eai-p3 / p3 / eai-07)"));const e=await n(chalk.cyan(" pick a task (number or id): "));if(null===e)return;const t=e.trim(),r=Number(t);o=!Number.isNaN(r)&&h[r-1]?h[r-1]:normalizeTaskId(t)}if(!o)return void console.log(chalk.yellow(" No task selected."));await async function(e,o){console.log(chalk.gray(` fetching ${e} from `)+chalk.gray(p())+chalk.gray(" …"));const n=await async function(e){const o=await f(`/api/icoa/arena/eai/${e}/data`);if(!o)return null;const n=o.data??o;if(!n.public)return null;const a=taskDir(e);try{t(a,{recursive:!0}),r(l(a,"public.json"),JSON.stringify(n.public,null,2)),n.scene_xml&&r(l(a,"scene.xml"),n.scene_xml),n.core&&r(l(a,"arena_physics_core.py"),n.core),n.self_check&&r(l(a,"self_check.py"),n.self_check)}catch(e){console.log(chalk.yellow(" Could not write the local arena files to ")+chalk.white(a)+chalk.gray(` (${e.message??"unknown"}).`)),console.log(chalk.gray(" `probe`/`submit` still work; only free local `roll` needs them."))}return n.public}(e);if(!n)return void console.log(chalk.yellow(` Could not load ${e} — unknown task, or the arena server is unreachable.`));!function(e){if(console.log(),console.log(chalk.bold.cyan(` 🤖 ${e.title??e.task_id}`)+chalk.gray(` · ${e.kind??"physics"} · channel ${e.channel??"?"} · ${e.difficulty??""}`)),e.brief){console.log();for(const o of function(e){const o=[];for(const t of e.split("\n")){let e="";for(const n of t.split(/\s+/))e&&`${e} ${n}`.length>76?(o.push(e),e=n):e=e?`${e} ${n}`:n;o.push(e)}return o}(String(e.brief)))console.log(chalk.gray(` ${o}`))}console.log()}(n);const{account:a}=d(),s=await m(`/api/icoa/arena/eai/${e}/state`,{account:a}),i=s?.data??{};i.ok&&(i.won&&console.log(chalk.bold.green(" ✓ you have already won this task.")),console.log(w(i.used,i.budget,i.remaining)),console.log()),N(n);const c="policy"===n.kind;let g;for(;;){const t=await o(chalk.bold.cyan(" icoa ctf4eai> "));if(null===t)return;const r=t.trim();if(!r)continue;const l=r.indexOf(" "),s=(-1===l?r:r.slice(0,l)).toLowerCase(),i=-1===l?"":r.slice(l+1).trim();if("quit"===s||"exit"===s||"q"===s||"back"===s)return;if("help"!==s&&"?"!==s)if("hint"!==s)if("replay"!==s&&"watch"!==s&&"video"!==s)if("ai4ctf"!==s&&"ai"!==s&&"teammate"!==s){if("state"===s){const o=await m(`/api/icoa/arena/eai/${e}/state`,{account:a}),t=o?.data??{};t.ok?console.log(w(t.used,t.budget,t.remaining)+(t.won?chalk.green(" ✓ won"):"")):console.log(chalk.gray(" (state unavailable)"));continue}if("roll"!==s)if("probe"===s||"submit"===s){if(!i){const e=b(n);console.log(c?chalk.gray(` usage: ${"probe"===s?e.probe:e.submit}`):chalk.gray(` usage: ${s} <instruction text>`));continue}let o;if(c){const e=buildPolicyInstruction("probe"===s?"query":"submit",i,n.protocol);if(!e){const e=b(n);console.log(chalk.yellow(" Could not parse that. ")+chalk.gray(`Try: ${"probe"===s?e.probe.replace(/<[^>]*>/g,"0"):e.submit.replace(/<[^>]*>/g,"0")}`));continue}o=e}else o=i.replace(/^["']|["']$/g,"");const t=await m(`/api/icoa/arena/eai/${e}/probe`,{account:a,instruction:o});if(!t){console.log(chalk.yellow(" The arena server is unreachable right now — try again."));continue}const r=t.data;if(403===t.status||"budget_exhausted"===r.reason){console.log(chalk.yellow(` Out of probes for this task (used ${r.used??"?"}/${r.budget??"?"}). No more attempts.`));continue}if(!r.ok&&r.reason){console.log(chalk.yellow(" Rejected: ")+chalk.gray(r.reason));continue}k(r);const l=r.telemetry?.value;if("number"==typeof l&&(g=l),"win"===r.bucket)return void(n.has_clip&&(console.log(chalk.gray(" 🎬 replaying your winning rollout…")),await $(e,g)))}else console.log(chalk.gray(" unknown command — type ")+chalk.cyan("help"));else if(c)v(e,n,0);else{const o=Number(i);v(e,n,Number.isNaN(o)?.4:o)}}else await _(n,o);else await $(e,g);else A(n);else N(n)}}(o,n),console.log(chalk.gray(" left the arena. Type ")+chalk.cyan("eai")+chalk.gray(" to come back any time.")),console.log()}finally{o.close()}}
@@ -4,3 +4,8 @@ export declare function printHttpTargetGuide(id: string, url: string, challenge:
4
4
  name?: string;
5
5
  category?: string;
6
6
  }): void;
7
+ export declare function eaiArenaTask(challenge: {
8
+ name?: string;
9
+ category?: string;
10
+ }): string | null;
11
+ export declare function printEaiArenaGuide(id: string, task: string): void;
@@ -1 +1 @@
1
- import chalk from"chalk";import{CTFdClient as o}from"../lib/ctfd-client.js";import{getConfig as e,isConnected as n}from"../lib/config.js";import{logCommand as t}from"../lib/logger.js";import{runInteractive as a}from"../lib/interactive-spawn.js";import{printError as l,printInfo as c,printSuccess as i,createSpinner as s}from"../lib/ui.js";export function registerConnectCommand(r){r.command("connect <id>").description("Connect to challenge remote target").action(async r=>{t(`connect ${r}`);const g=e();if(!n())return void l("Not connected. Run: join <url>");if(await async function(o,e){const n=(e.ctfdUrl||"https://practice.icoa2026.au").replace(/\/$/,"");let t=null;try{const a=await fetch(`${n}/api/icoa/challenge/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e.token,challenge:o}),signal:AbortSignal.timeout(2e4)});t=await a.json()}catch{return!1}if(!t)return!1;const s=t.data||{};if(!t.success&&"unknown_challenge"===s.reason)return!1;if(t.success&&s.dynamic){const e=String(s.host),n=Number(s.port),t=String(s.kind||"tcp");return s.reused?c(`Reconnecting to your running ${chalk.bold.white(o)} instance.`):i(`Spawned your private ${chalk.bold.white(o)} instance.`),c(`Target: ${chalk.bold.white(`${e}:${n}`)}`),console.log(),"http"===t?printHttpTargetGuide(o,`http://${e}:${n}/`,{name:o}):(i("Connecting..."),await a("nc",[e,String(n)]),console.log(),c("Connection closed.")),!0}if(t.success&&!1===s.dynamic)return i(`Connect to ${chalk.bold.white(o)}:`),c(`Target: ${chalk.bold.white(String(s.address))}`),!0;if(!t.success&&"already_running"===s.reason){const e=s.active;return c("You already have a different instance running (max one at a time):"),e&&console.log(chalk.cyan(" running ")+chalk.bold.white(String(e.challenge))+chalk.gray(" → ")+chalk.white(`${e.host}:${e.port}`)),console.log(),console.log(chalk.gray(" Stop it with ")+chalk.cyan("challenge stop")+chalk.gray(", or replace it: ")+chalk.cyan(`challenge start ${o} --new`)),!0}return t.success||"no_capacity"!==s.reason?!t.success&&"spawn_failed"===s.reason&&(l(`Couldn't start your ${chalk.bold.white(o)} instance — a server-side problem, not you.`),console.log(),console.log(chalk.gray(" Try again in a moment: ")+chalk.cyan(`challenge start ${o}`)),console.log(chalk.gray(" If it keeps failing, tell an organizer (the challenge image may be down).")),console.log(),!0):(l("The server is at capacity right now. Try again shortly."),!0)}(r,g))return;const h=g.sessionCookie||"",u=g.token&&!g.token.includes("session=")?g.token:"",d=new o(g.ctfdUrl,u,h||g.token),y=s("Fetching connection info...");y.start();try{const o=await d.getChallenge(parseInt(r,10));if(y.stop(),!o.connection_info)return void c("This challenge has no connection information.");const e=o.connection_info.trim(),n=e.match(/^(?:icoa\s+)?challenge\s+start\s+(\S+)/i);if(n)return p=n[1],console.log(),c("This is a per-player challenge — you get your own private instance."),console.log(),console.log(chalk.green(" → Just run this: ")+chalk.bold.white(`connect ${p}`)),console.log(chalk.gray(" It starts your private instance and drops you into it automatically.")),console.log(),console.log(chalk.gray(" Manage it anytime: ")+chalk.cyan("challenge status")+chalk.gray(" · ")+chalk.cyan("challenge stop")),console.log(),console.log(chalk.gray(" (Advanced: ")+chalk.gray(`\`challenge start ${p}\` prints a host:port you can connect to with your own tools.)`)),void console.log();if(c(`Connection: ${chalk.white(e)}`),console.log(),/^https?:\/\//i.test(e))return void printHttpTargetGuide(r,e,o);if(e.match(/^nc\s+/i)||e.match(/^ncat\s+/i))i("Connecting..."),await a(e,[],{shell:!0}),console.log(),c("Connection closed.");else if(e.match(/^ssh\s+/i))i("Connecting via SSH..."),await a(e,[],{shell:!0}),console.log(),c("Connection closed.");else if(e.includes(":")){const[o,n]=e.split(":");i(`Connecting to ${o}:${n}...`),await a("nc",[o,n]),console.log(),c("Connection closed.")}else c("Could not auto-detect connection type."),c(`Connection info: ${e}`),c("Connect manually using the information above.")}catch(o){void 0!==o.status?(console.log(),c("Connection closed.")):(y.fail("Failed to connect"),l(o.message))}var p})}export function printHttpTargetGuide(o,e,n){const t=/\/static\//i.test(e)?"Static":/\/ml\//i.test(e)?"ML":/\/agent\//i.test(e)?"Agent":/\/llm\//i.test(e)?"LLM":"HTTP",a=n.name?n.name:`Challenge ${o}`,l="Static"===t;console.log(chalk.bold.white(` ${a}`)+chalk.gray(` [AI Target · ${t}]`)),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.yellow(l?" ⚠ HTTP data challenge — do NOT use `connect`/nc. GET the data, then analyze it.":" ⚠ HTTP AI target — do NOT use `connect`/nc. You ATTACK it by sending requests.")),console.log(),l?(console.log(chalk.cyan(" ① FETCH")+chalk.gray(" — GET the challenge data + instructions:")),console.log(chalk.white(` curl -s ${e}`)),console.log(chalk.gray(" (returns JSON: description, the data/files, and submit_format)")),console.log(),console.log(chalk.cyan(" ② ANALYZE")+chalk.gray(" — work it out locally per that description:")),console.log(chalk.gray(" download files / classify / review code, as the JSON tells you.")),console.log()):(console.log(chalk.cyan(" ① ATTACK")+chalk.gray(" — send the target a request (refine & repeat):")),"ML"===t?(console.log(chalk.white(` curl -s -X POST ${e} \\`)),console.log(chalk.white(" -F 'image=@/path/to/your-image.png'")),console.log(chalk.gray(" (vision target — upload an image file, not JSON)"))):"Agent"===t?(console.log(chalk.white(` curl -s -c jar -b jar -X POST ${e} \\`)),console.log(chalk.white(" -H 'Content-Type: application/json' \\")),console.log(chalk.white(' -d \'{"<field>":"<value>"}\'')),console.log(chalk.gray(" (exact JSON field is in the challenge text — e.g. message / html)"))):(console.log(chalk.white(` curl -s -c jar -b jar -X POST ${e} \\`)),console.log(chalk.white(" -H 'Content-Type: application/json' \\")),console.log(chalk.white(' -d \'{"message":"<your prompt here>"}\'')),console.log(chalk.gray(" (-c jar -b jar keeps multi-turn conversation context)"))),console.log(),console.log(chalk.cyan(" ② READ")+chalk.gray(' — the reply is JSON. While "solved":false, keep trying.')),console.log(chalk.gray(" On success the JSON contains the flag string.")),console.log()),console.log(chalk.cyan(" ③ SUBMIT")+chalk.gray(" — once you have the flag, in this CLI run:")),console.log(chalk.bold.white(` submit ${o} <paste-the-exact-flag>`)),console.log(chalk.gray(" Submit it verbatim incl. its wrapper{...} — don't retype or add a prefix.")),console.log()}
1
+ import chalk from"chalk";import{CTFdClient as o}from"../lib/ctfd-client.js";import{getConfig as e,isConnected as n}from"../lib/config.js";import{logCommand as t}from"../lib/logger.js";import{runInteractive as a}from"../lib/interactive-spawn.js";import{printError as l,printInfo as i,printSuccess as c,createSpinner as s}from"../lib/ui.js";export function registerConnectCommand(r){r.command("connect <id>").description("Connect to challenge remote target").action(async r=>{t(`connect ${r}`);const g=e();if(!n())return void l("Not connected. Run: join <url>");if(await async function(o,e){const n=(e.ctfdUrl||"https://practice.icoa2026.au").replace(/\/$/,"");let t=null;try{const a=await fetch(`${n}/api/icoa/challenge/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e.token,challenge:o}),signal:AbortSignal.timeout(2e4)});t=await a.json()}catch{return!1}if(!t)return!1;const s=t.data||{};if(!t.success&&"unknown_challenge"===s.reason)return!1;if(t.success&&s.dynamic){const e=String(s.host),n=Number(s.port),t=String(s.kind||"tcp");return s.reused?i(`Reconnecting to your running ${chalk.bold.white(o)} instance.`):c(`Spawned your private ${chalk.bold.white(o)} instance.`),i(`Target: ${chalk.bold.white(`${e}:${n}`)}`),console.log(),"http"===t?printHttpTargetGuide(o,`http://${e}:${n}/`,{name:o}):(c("Connecting..."),await a("nc",[e,String(n)]),console.log(),i("Connection closed.")),!0}if(t.success&&!1===s.dynamic)return c(`Connect to ${chalk.bold.white(o)}:`),i(`Target: ${chalk.bold.white(String(s.address))}`),!0;if(!t.success&&"already_running"===s.reason){const e=s.active;return i("You already have a different instance running (max one at a time):"),e&&console.log(chalk.cyan(" running ")+chalk.bold.white(String(e.challenge))+chalk.gray(" → ")+chalk.white(`${e.host}:${e.port}`)),console.log(),console.log(chalk.gray(" Stop it with ")+chalk.cyan("challenge stop")+chalk.gray(", or replace it: ")+chalk.cyan(`challenge start ${o} --new`)),!0}return t.success||"no_capacity"!==s.reason?!t.success&&"spawn_failed"===s.reason&&(l(`Couldn't start your ${chalk.bold.white(o)} instance — a server-side problem, not you.`),console.log(),console.log(chalk.gray(" Try again in a moment: ")+chalk.cyan(`challenge start ${o}`)),console.log(chalk.gray(" If it keeps failing, tell an organizer (the challenge image may be down).")),console.log(),!0):(l("The server is at capacity right now. Try again shortly."),!0)}(r,g))return;const h=g.sessionCookie||"",u=g.token&&!g.token.includes("session=")?g.token:"",d=new o(g.ctfdUrl,u,h||g.token),y=s("Fetching connection info...");y.start();try{const o=await d.getChallenge(parseInt(r,10));y.stop();const e=eaiArenaTask(o);if(e)return void printEaiArenaGuide(r,e);if(!o.connection_info)return void i("This challenge has no connection information.");const n=o.connection_info.trim(),t=n.match(/^(?:icoa\s+)?challenge\s+start\s+(\S+)/i);if(t)return p=t[1],console.log(),i("This is a per-player challenge — you get your own private instance."),console.log(),console.log(chalk.green(" → Just run this: ")+chalk.bold.white(`connect ${p}`)),console.log(chalk.gray(" It starts your private instance and drops you into it automatically.")),console.log(),console.log(chalk.gray(" Manage it anytime: ")+chalk.cyan("challenge status")+chalk.gray(" · ")+chalk.cyan("challenge stop")),console.log(),console.log(chalk.gray(" (Advanced: ")+chalk.gray(`\`challenge start ${p}\` prints a host:port you can connect to with your own tools.)`)),void console.log();if(i(`Connection: ${chalk.white(n)}`),console.log(),/^https?:\/\//i.test(n))return void printHttpTargetGuide(r,n,o);if(n.match(/^nc\s+/i)||n.match(/^ncat\s+/i))c("Connecting..."),await a(n,[],{shell:!0}),console.log(),i("Connection closed.");else if(n.match(/^ssh\s+/i))c("Connecting via SSH..."),await a(n,[],{shell:!0}),console.log(),i("Connection closed.");else if(n.includes(":")){const[o,e]=n.split(":");c(`Connecting to ${o}:${e}...`),await a("nc",[o,e]),console.log(),i("Connection closed.")}else i("Could not auto-detect connection type."),i(`Connection info: ${n}`),i("Connect manually using the information above.")}catch(o){void 0!==o.status?(console.log(),i("Connection closed.")):(y.fail("Failed to connect"),l(o.message))}var p})}export function printHttpTargetGuide(o,e,n){const t=/\/static\//i.test(e)?"Static":/\/ml\//i.test(e)?"ML":/\/agent\//i.test(e)?"Agent":/\/llm\//i.test(e)?"LLM":"HTTP",a=n.name?n.name:`Challenge ${o}`,l="Static"===t;console.log(chalk.bold.white(` ${a}`)+chalk.gray(` [AI Target · ${t}]`)),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.yellow(l?" ⚠ HTTP data challenge — do NOT use `connect`/nc. GET the data, then analyze it.":" ⚠ HTTP AI target — do NOT use `connect`/nc. You ATTACK it by sending requests.")),console.log(),l?(console.log(chalk.cyan(" ① FETCH")+chalk.gray(" — GET the challenge data + instructions:")),console.log(chalk.white(` curl -s ${e}`)),console.log(chalk.gray(" (returns JSON: description, the data/files, and submit_format)")),console.log(),console.log(chalk.cyan(" ② ANALYZE")+chalk.gray(" — work it out locally per that description:")),console.log(chalk.gray(" download files / classify / review code, as the JSON tells you.")),console.log()):(console.log(chalk.cyan(" ① ATTACK")+chalk.gray(" — send the target a request (refine & repeat):")),"ML"===t?(console.log(chalk.white(` curl -s -X POST ${e} \\`)),console.log(chalk.white(" -F 'image=@/path/to/your-image.png'")),console.log(chalk.gray(" (vision target — upload an image file, not JSON)"))):"Agent"===t?(console.log(chalk.white(` curl -s -c jar -b jar -X POST ${e} \\`)),console.log(chalk.white(" -H 'Content-Type: application/json' \\")),console.log(chalk.white(' -d \'{"<field>":"<value>"}\'')),console.log(chalk.gray(" (exact JSON field is in the challenge text — e.g. message / html)"))):(console.log(chalk.white(` curl -s -c jar -b jar -X POST ${e} \\`)),console.log(chalk.white(" -H 'Content-Type: application/json' \\")),console.log(chalk.white(' -d \'{"message":"<your prompt here>"}\'')),console.log(chalk.gray(" (-c jar -b jar keeps multi-turn conversation context)"))),console.log(),console.log(chalk.cyan(" ② READ")+chalk.gray(' — the reply is JSON. While "solved":false, keep trying.')),console.log(chalk.gray(" On success the JSON contains the flag string.")),console.log()),console.log(chalk.cyan(" ③ SUBMIT")+chalk.gray(" — once you have the flag, in this CLI run:")),console.log(chalk.bold.white(` submit ${o} <paste-the-exact-flag>`)),console.log(chalk.gray(" Submit it verbatim incl. its wrapper{...} — don't retype or add a prefix.")),console.log()}export function eaiArenaTask(o){const e=(o.category||"").toLowerCase(),n=(o.name||"").trim();if(!e.startsWith("ctf4eai")&&!/^eai-/i.test(n))return null;const t=n.match(/^(eai-[a-z0-9]+)/i);return t?t[1].toLowerCase():"eai"}export function printEaiArenaGuide(o,e){const n="eai"===e?"eai":`eai ${e}`;console.log(chalk.bold.cyan(" 🤖 Embodied-AI Arena task")+chalk.gray(" · red-team the robot policy")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.yellow(" ⚠ Not a network target — nothing to `connect`/nc/curl here.")),console.log(chalk.gray(" You solve it inside the ICOA CLI arena, then paste the flag onto the scoreboard.")),console.log(),console.log(chalk.cyan(" ① PLAY")+chalk.gray(" — open the arena for this task:")),console.log(chalk.bold.white(` ${n}`)),console.log(chalk.gray(" Then inside: read the brief → roll / probe → submit your instruction to win.")),console.log(),console.log(chalk.cyan(" ② SUBMIT")+chalk.gray(" — the arena prints your ICOA{...} flag on a win:")),console.log(chalk.bold.white(` submit ${o} <paste-the-exact-flag>`)),console.log(chalk.gray(" Submit it verbatim incl. its wrapper{...} — don't retype or add a prefix.")),console.log()}
@@ -1 +1 @@
1
- import chalk from"chalk";import{CTFdClient as e}from"../lib/ctfd-client.js";import{getConfig as o,saveConfig as t}from"../lib/config.js";import{postIntegritySnapshot as n}from"../lib/integrity-snapshot.js";import{logCommand as i,logSubmission as s}from"../lib/logger.js";import{getTranslation as a}from"../lib/translation.js";import{isLeaderAccount as l,isLeaderToken as c,leaderAuth as r}from"../lib/comms.js";import{printSuccess as d,printError as g,printWarning as m,printInfo as p,printTable as y,printMarkdown as u,printHeader as h,printKeyValue as w,createSpinner as f,formatCountdown as b}from"../lib/ui.js";export function detectFlagFormat(e){if(!e)return null;const o=e.match(/flag\s*format\s*[::]?\s*`?([A-Za-z][A-Za-z0-9_]{0,20}\{[^}\n]{1,60}\})`?/i);return o?o[1]:null}function S(){const t=o();t.ctfdUrl&&(t.token||t.sessionCookie)||(g("Not connected to CTFd. Run: join <url>"),process.exit(1));const n=t.sessionCookie||"",i=t.token&&!t.token.includes("session=")?t.token:"";return{config:t,client:new e(t.ctfdUrl,i,n||t.token)}}export function registerCtfCommands(v){const C=v.command("ctf").description("Competition commands");C.command("join <url>").description("Connect to a CTFd instance").action(async n=>{let s=n.trim().replace(/\/+$/,"");function a(e,o){return new Promise(t=>{process.stdout.write(chalk.white(e));const n=!!process.stdin.isTTY&&!!process.stdin.isRaw,i=process.stdin.listeners("data").slice(),s=process.stdin.listeners("keypress").slice();for(const e of i)process.stdin.removeListener("data",e);for(const e of s)process.stdin.removeListener("keypress",e);process.stdin.isTTY&&process.stdin.setRawMode?.(!0),process.stdin.resume();let a="";const l=e=>{const c=e.toString(),r=e=>{process.stdin.isTTY&&process.stdin.setRawMode?.(n),process.stdin.removeListener("data",l);for(const e of i)process.stdin.on("data",e);for(const e of s)process.stdin.on("keypress",e);process.stdout.write("\n"),t(e)};"\n"===c||"\r"===c?r(a):""===c||"\b"===c?a.length>0&&(a=a.slice(0,-1),process.stdout.write("\b \b")):""===c?r(""):(a+=c,process.stdout.write(o||c))};process.stdin.on("data",l)})}s.startsWith("http://")||s.startsWith("https://")||(s=`https://${s}`),i(`ctf join ${s}`),console.log(),p(`Connecting to ${chalk.bold(s)}`);const y=await a(" Username: ");if(c(y)){const e=f("Verifying leader token...");e.start();const o=await r(s,y);return o?(e.succeed("Leader verified"),t({ctfdUrl:s,token:"",sessionCookie:"",leaderToken:y.trim(),leaderTeam:o.team,userName:o.account,userId:null,teamId:null,joinedAt:(new Date).toISOString()}),console.log(),w("Leader",o.account),o.team&&w("Team",o.team),console.log(),console.log(chalk.yellow(" ─────────────────────────────────────────────")),console.log(chalk.bold.yellow(" Team Leader console")),console.log(),console.log(chalk.white(" scoreboard")+chalk.gray(" Live team rankings")),console.log(chalk.white(" jury")+chalk.gray(" File a clarification / appeal (recorded)")),console.log(chalk.white(" news")+chalk.gray(" Latest organizer broadcast")),console.log(chalk.white(" time")+chalk.gray(" Event clock")),console.log(chalk.white(" logout")+chalk.gray(" Sign out")),console.log(chalk.yellow(" ─────────────────────────────────────────────")),console.log(),void console.log(chalk.gray(" The challenge bracket is not available to leaders."))):(e.fail("Invalid leader token"),void g("That leader token was not accepted. Check the token on your card and retry."))}const u=await a(" Password: ","*");let h="",b="",S="";const v=f("Logging in...");v.start();try{const o=new e(s,""),t=await o.loginWithCredentials(y,u);h=t.token,b=t.session,S=t.csrf,h?v.succeed("Login successful — API token auto-generated"):v.succeed("Login successful (session mode)")}catch(e){return v.fail("Login failed"),void g(e.message)}const C=f("Testing connection...");C.start();try{const n=new e(s,h,b,S),i=await n.testConnection();C.succeed("Connected successfully"),console.log(),w("User",i.name),w("Score",String(i.score||0)),i.team_id&&w("Team ID",String(i.team_id));try{const e=await n.getCompetitionMeta(),o={ctfdUrl:s,token:h||b,userId:i.id,userName:i.name,teamId:i.team_id,sessionCookie:b,country:i.country||"",joinedAt:(new Date).toISOString()};e.start?(o.competitionStartsAt=new Date(1e3*e.start).toISOString(),w("Starts",new Date(1e3*e.start).toLocaleString())):o.competitionStartsAt="",e.end?(o.competitionEndsAt=new Date(1e3*e.end).toISOString(),w("Ends",new Date(1e3*e.end).toLocaleString())):o.competitionEndsAt="";const a=Date.now()/1e3;e.start&&a<e.start?o.competitionState="pre_competition":e.end&&a>e.end?o.competitionState="finished":o.competitionState="live",w("Status",o.competitionState),t(o)}catch{t({ctfdUrl:s,token:h,userId:i.id,userName:i.name,teamId:i.team_id,joinedAt:(new Date).toISOString()})}console.log(),d("Connection saved. You are ready!"),console.log();const a=o().mode||"";l(i.name||"")?(console.log(chalk.yellow(" ─────────────────────────────────────────────")),console.log(chalk.bold.yellow(" Team Leader console")),console.log(),console.log(chalk.white(" scoreboard")+chalk.gray(" Live team rankings")),console.log(chalk.white(" news")+chalk.gray(" Latest organizer broadcast")),console.log(chalk.white(" jury")+chalk.gray(" File a clarification / appeal (recorded)")),console.log(chalk.white(" time")+chalk.gray(" Event clock")),console.log(chalk.white(" status")+chalk.gray(" Event state")),console.log(chalk.white(" logout")+chalk.gray(" Sign out")),console.log(chalk.yellow(" ─────────────────────────────────────────────"))):"olympiad"===a?(console.log(chalk.cyan(" ─────────────────────────────────────────────")),console.log(chalk.bold.white(" How to compete:")),console.log(),console.log(chalk.white(" Step 1 ")+chalk.bold.cyan("challenges")+chalk.gray(" Browse all challenges")),console.log(chalk.white(" Step 2 ")+chalk.bold.cyan("open <id>")+chalk.gray(" Read challenge details")),console.log(chalk.white(" Step 3 ")+chalk.bold.cyan("submit <id> <flag>")+chalk.gray(" Submit your answer")),console.log(),console.log(chalk.bold.yellow(" ★ Need AI help? ")+chalk.bold.cyan("ai4ctf")+chalk.gray(" Chat freely with your AI teammate")),console.log(chalk.bold.yellow(" ★ Stuck on a tool? ")+chalk.bold.cyan("man <tool>")+chalk.gray(" how to use steghide / binwalk / nmap … (")+chalk.cyan("man tools")+chalk.gray(" = list)")),console.log(),console.log(chalk.gray(" More:")),console.log(chalk.white(" scoreboard")+chalk.gray(" Live rankings")),console.log(chalk.white(" status")+chalk.gray(" Your score & timer")),console.log(chalk.white(" memo")+chalk.gray(" Report an issue with a challenge")),console.log(chalk.white(" news")+chalk.gray(" Show the latest organizer broadcast")),console.log(chalk.cyan(" ─────────────────────────────────────────────"))):(console.log(chalk.gray(" Next:")),console.log(chalk.white(" exam list ")+chalk.gray("View available exams")),console.log(chalk.white(" challenges ")+chalk.gray("View CTF challenges")),console.log(chalk.white(" status ")+chalk.gray("Check score & timer")))}catch(e){/ACCOUNT_BLOCKED|banned|not enabled/i.test(e?.message||"")?(C.fail("This account cannot access the competition"),console.log(),g("Signed in OK, but the account is banned / disabled / not enabled. Try a different account, or contact the organizer."),t({ctfdUrl:s})):b?(C.succeed("Connected (session mode — limited API)"),t({ctfdUrl:s,token:b,userName:y,sessionCookie:b}),console.log(),w("User",y),m("API access limited. Some features may not work."),d("Connection saved.")):(C.fail("Connection test failed"),g(e.message),t({ctfdUrl:s}),console.log(),p(`Connection saved. Try: join ${s}`))}}),C.command("logout").description("Disconnect and clear credentials").action(()=>{i("ctf logout"),t({ctfdUrl:"",token:"",sessionCookie:"",userId:null,userName:"",teamId:null,country:"",leaderToken:"",leaderTeam:""}),d("Logged out. Credentials cleared."),console.log(),console.log(chalk.gray(" What now?")),console.log(chalk.white(" join <url>")+chalk.gray(" Re-connect to competition")),console.log(chalk.white(" setup")+chalk.gray(" Switch mode")),console.log(chalk.white(" exit")+chalk.gray(" Quit ICOA CLI"))}),C.command("activate <code>").description("Validate competition code").action(async e=>{i(`ctf activate ${e}`),S();const n=f("Validating competition code...");n.start();try{const i=await fetch(`${o().ctfdUrl}/api/v1/icoa/activate`,{method:"POST",headers:{Authorization:`Token ${o().token}`,"Content-Type":"application/json"},body:JSON.stringify({code:e})});if(i.ok){const s=await i.json();n.succeed("Competition code validated"),t({competitionCode:e,teamId:s.data?.team_id||o().teamId,competitionState:"live"}),d(`Activated: ${e}`)}else n.succeed("Competition code saved"),t({competitionCode:e}),p("Code stored locally. Server validation will be attempted during competition.")}catch{n.succeed("Competition code saved"),t({competitionCode:e}),p("Code stored locally.")}}),C.command("challenges").description("List all challenges").action(async()=>{i("ctf challenges");const{client:e}=S(),o=f("Loading challenges...");o.start();try{const t=await e.getChallenges();if(o.stop(),!t||0===t.length)return void p("No challenges available yet.");const n=new Map;for(const e of t){const o=e.category||"Uncategorized";n.has(o)||n.set(o,[]),n.get(o).push(e)}const i=t.filter(e=>e.solved_by_me).length;h(`Challenges (${i}/${t.length} solved)`);const s={Web:"Find vulnerabilities in websites",Crypto:"Break ciphers & encryption",Reversing:"Analyze compiled programs",Rev:"Analyze compiled programs",Pwn:"Exploit binary vulnerabilities",Forensics:"Investigate digital evidence",Misc:"Creative & mixed challenges",OSINT:"Open-source intelligence gathering",AI:"AI security & adversarial ML"},a=e=>e<=100?chalk.green("Easy"):e<=250?chalk.yellow("Medium"):e<=500?chalk.red("Hard"):chalk.magenta("Expert"),l=[...n.entries()].sort(([e],[o])=>e.localeCompare(o)).flatMap(([e,o])=>{const t=s[e]||"";return[[t?`${chalk.cyan.bold(`── ${e} ──`)} ${chalk.gray(t)}`:chalk.cyan.bold(`── ${e} ──`),"","","",""],...o.sort((e,o)=>e.value-o.value).map(e=>[String(e.id),e.solved_by_me?chalk.gray.strikethrough(e.name):e.name,e.solved_by_me?chalk.gray(String(e.value)):chalk.yellow(String(e.value)),e.solved_by_me?chalk.gray("--"):a(e.value),e.solved_by_me?chalk.green("✓"):chalk.gray("○")])]});y(["#","Name","Points","Difficulty","Solved"],l),console.log(chalk.gray(` ${t.length} challenges, ${i} solved`)),0===i&&(console.log(),console.log(chalk.gray(" Tip: Start with ")+chalk.green("Easy")+chalk.gray(" challenges! Type ")+chalk.white("open <id>")+chalk.gray(" to read one.")))}catch(e){o.fail("Failed to load challenges"),g(e.message)}}),C.command("open <id>").description("View challenge details").action(async e=>{i(`ctf open ${e}`);const{config:o,client:n}=S(),s=f("Loading challenge...");s.start();try{const i=await n.getChallenge(parseInt(e,10));s.stop(),t({currentChallengeId:i.id,currentChallengeName:i.name,currentChallengeCategory:i.category}),h(`${i.name} [${i.category}]`),w("Points",String(i.value)),w("Solves",String(i.solves)),i.connection_info&&w("Connection",i.connection_info),console.log();let l=i.description;if("en"!==o.language)try{l=await a(l,i.id,o.language)}catch{}u(l);const c=detectFlagFormat(i.description);console.log(),c?console.log(chalk.bold.white(" Flag format: ")+chalk.green(c)):console.log(chalk.bold.white(" Flag format: ")+chalk.gray("submit the flag exactly as you receive it, including its ")+chalk.green("wrapper{...}")+chalk.gray(" — don't retype or add a prefix.")),i.files&&i.files.length>0&&(console.log(),p(`Files (${i.files.length}): use ${chalk.white(`files ${e}`)} to download`)),i.hints&&i.hints.length>0&&p(`CTFd Hints available: ${i.hints.length}`),i.connection_info&&(console.log(),p(`Quick connect: ${chalk.white(`connect ${e}`)}`));const r=!!i.connection_info&&/^https?:\/\//i.test(i.connection_info.trim());console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.bold.white(" What to do next:")),r&&console.log(chalk.white(` connect ${e}`)+chalk.gray(" How to attack & submit — full guide")),console.log(chalk.white(' hint "how to start?"')+chalk.gray(" Ask the AI teammate (if enabled this round)")),i.files&&i.files.length>0&&console.log(chalk.white(` files ${e}`)+chalk.gray(" Download challenge files")),i.connection_info&&!r&&console.log(chalk.white(` connect ${e}`)+chalk.gray(" Connect to target")),console.log(chalk.white(` submit ${e} <flag>`)+chalk.gray(" Submit your answer (paste the full flag with its wrapper)")),console.log(chalk.gray(" ─────────────────────────────────────────────"))}catch(e){s.fail("Failed to load challenge"),g(e.message)}}),C.command("submit <id> <flag>").description("Submit a flag").action(async(e,o)=>{i(`ctf submit ${e}`),s(parseInt(e,10),o);const{client:t}=S(),a=f("Submitting flag...");a.start();try{const i=await t.submitFlag(parseInt(e,10),o);switch(a.stop(),i.status){case"correct":console.log(),console.log(chalk.green.bold(" 🎉 Correct! ")+chalk.white(i.message)),console.log();break;case"incorrect":g(`Incorrect. ${i.message}`);break;case"already_solved":m("Already solved.");break;case"paused":m("Competition is paused.");break;case"ratelimited":m("Rate limited. Please wait before trying again.");break;default:p(i.message||"Unknown response")}await n()}catch(e){a.fail("Submission failed"),g(e.message)}}),C.command("scoreboard [top]").description("View scoreboard (optional: top N)").action(async e=>{i("ctf scoreboard");const{config:o,client:t}=S(),n=f("Loading scoreboard...");n.start();try{const e=await t.getScoreboard();if(n.stop(),!e||0===e.length)return void p("Scoreboard is empty.");h("Scoreboard");const i=e.map(e=>{const t=e.account_id===o.teamId,n=[String(e.pos),e.name,String(e.score)];return t?n.map(e=>chalk.yellow.bold(e)):n});y(["Rank","Team","Score"],i)}catch(e){n.fail("Failed to load scoreboard"),g(e.message)}}),C.command("status").description("Show competition status").action(async()=>{i("ctf status");const{config:e,client:o}=S();h("Competition Status");const t={pre_competition:chalk.yellow,demo:chalk.blue,live:chalk.green,finished:chalk.red,unknown:chalk.gray},n=e.competitionState||"unknown",s=t[n]||chalk.gray;console.log(` ${chalk.gray("State:")} ${chalk.bold(s({pre_competition:"PRE-COMPETITION",demo:"DEMO",live:"LIVE",finished:"FINISHED",unknown:"UNKNOWN"}[n]||n))}`);try{const e=await o.testConnection();w("User",chalk.white.bold(e.name)),w("Score",chalk.yellow.bold(String(e.score||0))),w("Rank",chalk.cyan(e.place||"N/A"))}catch{w("User",e.userName||"Unknown")}if(e.competitionEndsAt){console.log();const o=new Date(e.competitionEndsAt);new Date<o?w("Time Remaining",chalk.yellow.bold(b(o))):w("Time",chalk.red("Competition ended"))}console.log()}),C.command("time").description("Show competition countdown").action(()=>{i("ctf time");const e=o();if(!e.competitionStartsAt&&!e.competitionEndsAt)return p("Competition times not configured."),void p("They will be set when the competition server provides timing information.");const t=new Date,n=e.competitionStartsAt?new Date(e.competitionStartsAt):null,s=e.competitionEndsAt?new Date(e.competitionEndsAt):null;h("Competition Timer"),n&&t<n?(console.log(chalk.yellow(" Competition has not started yet.")),console.log(),console.log(` ${chalk.bold("Starts in:")} ${b(n)}`)):s&&t<s?(console.log(chalk.green(" Competition is LIVE")),console.log(),console.log(` ${chalk.bold("Time remaining:")} ${b(s)}`)):console.log(chalk.red(" Competition has ended."))})}
1
+ import chalk from"chalk";import{CTFdClient as e}from"../lib/ctfd-client.js";import{getConfig as o,saveConfig as t}from"../lib/config.js";import{postIntegritySnapshot as n}from"../lib/integrity-snapshot.js";import{logCommand as i,logSubmission as s}from"../lib/logger.js";import{getTranslation as a}from"../lib/translation.js";import{isLeaderAccount as l,isLeaderToken as c,leaderAuth as r}from"../lib/comms.js";import{printSuccess as d,printError as g,printWarning as m,printInfo as p,printTable as y,printMarkdown as u,printHeader as h,printKeyValue as w,createSpinner as f,formatCountdown as b}from"../lib/ui.js";import{eaiArenaTask as S,printEaiArenaGuide as v}from"./connect.js";export function detectFlagFormat(e){if(!e)return null;const o=e.match(/flag\s*format\s*[::]?\s*`?([A-Za-z][A-Za-z0-9_]{0,20}\{[^}\n]{1,60}\})`?/i);return o?o[1]:null}function C(){const t=o();t.ctfdUrl&&(t.token||t.sessionCookie)||(g("Not connected to CTFd. Run: join <url>"),process.exit(1));const n=t.sessionCookie||"",i=t.token&&!t.token.includes("session=")?t.token:"";return{config:t,client:new e(t.ctfdUrl,i,n||t.token)}}export function registerCtfCommands(k){const I=k.command("ctf").description("Competition commands");I.command("join <url>").description("Connect to a CTFd instance").action(async n=>{let s=n.trim().replace(/\/+$/,"");function a(e,o){return new Promise(t=>{process.stdout.write(chalk.white(e));const n=!!process.stdin.isTTY&&!!process.stdin.isRaw,i=process.stdin.listeners("data").slice(),s=process.stdin.listeners("keypress").slice();for(const e of i)process.stdin.removeListener("data",e);for(const e of s)process.stdin.removeListener("keypress",e);process.stdin.isTTY&&process.stdin.setRawMode?.(!0),process.stdin.resume();let a="";const l=e=>{const c=e.toString(),r=e=>{process.stdin.isTTY&&process.stdin.setRawMode?.(n),process.stdin.removeListener("data",l);for(const e of i)process.stdin.on("data",e);for(const e of s)process.stdin.on("keypress",e);process.stdout.write("\n"),t(e)};"\n"===c||"\r"===c?r(a):""===c||"\b"===c?a.length>0&&(a=a.slice(0,-1),process.stdout.write("\b \b")):""===c?r(""):(a+=c,process.stdout.write(o||c))};process.stdin.on("data",l)})}s.startsWith("http://")||s.startsWith("https://")||(s=`https://${s}`),i(`ctf join ${s}`),console.log(),p(`Connecting to ${chalk.bold(s)}`);const y=await a(" Username: ");if(c(y)){const e=f("Verifying leader token...");e.start();const o=await r(s,y);return o?(e.succeed("Leader verified"),t({ctfdUrl:s,token:"",sessionCookie:"",leaderToken:y.trim(),leaderTeam:o.team,userName:o.account,userId:null,teamId:null,joinedAt:(new Date).toISOString()}),console.log(),w("Leader",o.account),o.team&&w("Team",o.team),console.log(),console.log(chalk.yellow(" ─────────────────────────────────────────────")),console.log(chalk.bold.yellow(" Team Leader console")),console.log(),console.log(chalk.white(" scoreboard")+chalk.gray(" Live team rankings")),console.log(chalk.white(" jury")+chalk.gray(" File a clarification / appeal (recorded)")),console.log(chalk.white(" news")+chalk.gray(" Latest organizer broadcast")),console.log(chalk.white(" time")+chalk.gray(" Event clock")),console.log(chalk.white(" logout")+chalk.gray(" Sign out")),console.log(chalk.yellow(" ─────────────────────────────────────────────")),console.log(),void console.log(chalk.gray(" The challenge bracket is not available to leaders."))):(e.fail("Invalid leader token"),void g("That leader token was not accepted. Check the token on your card and retry."))}const u=await a(" Password: ","*");let h="",b="",S="";const v=f("Logging in...");v.start();try{const o=new e(s,""),t=await o.loginWithCredentials(y,u);h=t.token,b=t.session,S=t.csrf,h?v.succeed("Login successful — API token auto-generated"):v.succeed("Login successful (session mode)")}catch(e){return v.fail("Login failed"),void g(e.message)}const C=f("Testing connection...");C.start();try{const n=new e(s,h,b,S),i=await n.testConnection();C.succeed("Connected successfully"),console.log(),w("User",i.name),w("Score",String(i.score||0)),i.team_id&&w("Team ID",String(i.team_id));try{const e=await n.getCompetitionMeta(),o={ctfdUrl:s,token:h||b,userId:i.id,userName:i.name,teamId:i.team_id,sessionCookie:b,country:i.country||"",joinedAt:(new Date).toISOString()};e.start?(o.competitionStartsAt=new Date(1e3*e.start).toISOString(),w("Starts",new Date(1e3*e.start).toLocaleString())):o.competitionStartsAt="",e.end?(o.competitionEndsAt=new Date(1e3*e.end).toISOString(),w("Ends",new Date(1e3*e.end).toLocaleString())):o.competitionEndsAt="";const a=Date.now()/1e3;e.start&&a<e.start?o.competitionState="pre_competition":e.end&&a>e.end?o.competitionState="finished":o.competitionState="live",w("Status",o.competitionState),t(o)}catch{t({ctfdUrl:s,token:h,userId:i.id,userName:i.name,teamId:i.team_id,joinedAt:(new Date).toISOString()})}console.log(),d("Connection saved. You are ready!"),console.log();const a=o().mode||"";l(i.name||"")?(console.log(chalk.yellow(" ─────────────────────────────────────────────")),console.log(chalk.bold.yellow(" Team Leader console")),console.log(),console.log(chalk.white(" scoreboard")+chalk.gray(" Live team rankings")),console.log(chalk.white(" news")+chalk.gray(" Latest organizer broadcast")),console.log(chalk.white(" jury")+chalk.gray(" File a clarification / appeal (recorded)")),console.log(chalk.white(" time")+chalk.gray(" Event clock")),console.log(chalk.white(" status")+chalk.gray(" Event state")),console.log(chalk.white(" logout")+chalk.gray(" Sign out")),console.log(chalk.yellow(" ─────────────────────────────────────────────"))):"olympiad"===a?(console.log(chalk.cyan(" ─────────────────────────────────────────────")),console.log(chalk.bold.white(" How to compete:")),console.log(),console.log(chalk.white(" Step 1 ")+chalk.bold.cyan("challenges")+chalk.gray(" Browse all challenges")),console.log(chalk.white(" Step 2 ")+chalk.bold.cyan("open <id>")+chalk.gray(" Read challenge details")),console.log(chalk.white(" Step 3 ")+chalk.bold.cyan("submit <id> <flag>")+chalk.gray(" Submit your answer")),console.log(),console.log(chalk.bold.yellow(" ★ Need AI help? ")+chalk.bold.cyan("ai4ctf")+chalk.gray(" Chat freely with your AI teammate")),console.log(chalk.bold.yellow(" ★ Stuck on a tool? ")+chalk.bold.cyan("man <tool>")+chalk.gray(" how to use steghide / binwalk / nmap … (")+chalk.cyan("man tools")+chalk.gray(" = list)")),console.log(),console.log(chalk.gray(" More:")),console.log(chalk.white(" scoreboard")+chalk.gray(" Live rankings")),console.log(chalk.white(" status")+chalk.gray(" Your score & timer")),console.log(chalk.white(" memo")+chalk.gray(" Report an issue with a challenge")),console.log(chalk.white(" news")+chalk.gray(" Show the latest organizer broadcast")),console.log(chalk.cyan(" ─────────────────────────────────────────────"))):(console.log(chalk.gray(" Next:")),console.log(chalk.white(" exam list ")+chalk.gray("View available exams")),console.log(chalk.white(" challenges ")+chalk.gray("View CTF challenges")),console.log(chalk.white(" status ")+chalk.gray("Check score & timer")))}catch(e){/ACCOUNT_BLOCKED|banned|not enabled/i.test(e?.message||"")?(C.fail("This account cannot access the competition"),console.log(),g("Signed in OK, but the account is banned / disabled / not enabled. Try a different account, or contact the organizer."),t({ctfdUrl:s})):b?(C.succeed("Connected (session mode — limited API)"),t({ctfdUrl:s,token:b,userName:y,sessionCookie:b}),console.log(),w("User",y),m("API access limited. Some features may not work."),d("Connection saved.")):(C.fail("Connection test failed"),g(e.message),t({ctfdUrl:s}),console.log(),p(`Connection saved. Try: join ${s}`))}}),I.command("logout").description("Disconnect and clear credentials").action(()=>{i("ctf logout"),t({ctfdUrl:"",token:"",sessionCookie:"",userId:null,userName:"",teamId:null,country:"",leaderToken:"",leaderTeam:""}),d("Logged out. Credentials cleared."),console.log(),console.log(chalk.gray(" What now?")),console.log(chalk.white(" join <url>")+chalk.gray(" Re-connect to competition")),console.log(chalk.white(" setup")+chalk.gray(" Switch mode")),console.log(chalk.white(" exit")+chalk.gray(" Quit ICOA CLI"))}),I.command("activate <code>").description("Validate competition code").action(async e=>{i(`ctf activate ${e}`),C();const n=f("Validating competition code...");n.start();try{const i=await fetch(`${o().ctfdUrl}/api/v1/icoa/activate`,{method:"POST",headers:{Authorization:`Token ${o().token}`,"Content-Type":"application/json"},body:JSON.stringify({code:e})});if(i.ok){const s=await i.json();n.succeed("Competition code validated"),t({competitionCode:e,teamId:s.data?.team_id||o().teamId,competitionState:"live"}),d(`Activated: ${e}`)}else n.succeed("Competition code saved"),t({competitionCode:e}),p("Code stored locally. Server validation will be attempted during competition.")}catch{n.succeed("Competition code saved"),t({competitionCode:e}),p("Code stored locally.")}}),I.command("challenges").description("List all challenges").action(async()=>{i("ctf challenges");const{client:e}=C(),o=f("Loading challenges...");o.start();try{const t=await e.getChallenges();if(o.stop(),!t||0===t.length)return void p("No challenges available yet.");const n=new Map;for(const e of t){const o=e.category||"Uncategorized";n.has(o)||n.set(o,[]),n.get(o).push(e)}const i=t.filter(e=>e.solved_by_me).length;h(`Challenges (${i}/${t.length} solved)`);const s={Web:"Find vulnerabilities in websites",Crypto:"Break ciphers & encryption",Reversing:"Analyze compiled programs",Rev:"Analyze compiled programs",Pwn:"Exploit binary vulnerabilities",Forensics:"Investigate digital evidence",Misc:"Creative & mixed challenges",OSINT:"Open-source intelligence gathering",AI:"AI security & adversarial ML"},a=e=>e<=100?chalk.green("Easy"):e<=250?chalk.yellow("Medium"):e<=500?chalk.red("Hard"):chalk.magenta("Expert"),l=[...n.entries()].sort(([e],[o])=>e.localeCompare(o)).flatMap(([e,o])=>{const t=s[e]||"";return[[t?`${chalk.cyan.bold(`── ${e} ──`)} ${chalk.gray(t)}`:chalk.cyan.bold(`── ${e} ──`),"","","",""],...o.sort((e,o)=>e.value-o.value).map(e=>[String(e.id),e.solved_by_me?chalk.gray.strikethrough(e.name):e.name,e.solved_by_me?chalk.gray(String(e.value)):chalk.yellow(String(e.value)),e.solved_by_me?chalk.gray("--"):a(e.value),e.solved_by_me?chalk.green("✓"):chalk.gray("○")])]});y(["#","Name","Points","Difficulty","Solved"],l),console.log(chalk.gray(` ${t.length} challenges, ${i} solved`)),0===i&&(console.log(),console.log(chalk.gray(" Tip: Start with ")+chalk.green("Easy")+chalk.gray(" challenges! Type ")+chalk.white("open <id>")+chalk.gray(" to read one.")))}catch(e){o.fail("Failed to load challenges"),g(e.message)}}),I.command("open <id>").description("View challenge details").action(async e=>{i(`ctf open ${e}`);const{config:o,client:n}=C(),s=f("Loading challenge...");s.start();try{const i=await n.getChallenge(parseInt(e,10));s.stop(),t({currentChallengeId:i.id,currentChallengeName:i.name,currentChallengeCategory:i.category});const l=S(i);h(`${i.name} [${i.category}]`),w("Points",String(i.value)),w("Solves",String(i.solves)),i.connection_info&&!l&&w("Connection",i.connection_info),console.log();let c=i.description;if("en"!==o.language)try{c=await a(c,i.id,o.language)}catch{}u(c);const r=detectFlagFormat(i.description);if(console.log(),r?console.log(chalk.bold.white(" Flag format: ")+chalk.green(r)):console.log(chalk.bold.white(" Flag format: ")+chalk.gray("submit the flag exactly as you receive it, including its ")+chalk.green("wrapper{...}")+chalk.gray(" — don't retype or add a prefix.")),i.files&&i.files.length>0&&(console.log(),p(`Files (${i.files.length}): use ${chalk.white(`files ${e}`)} to download`)),i.hints&&i.hints.length>0&&p(`CTFd Hints available: ${i.hints.length}`),l)return console.log(),void v(e,l);i.connection_info&&(console.log(),p(`Quick connect: ${chalk.white(`connect ${e}`)}`));const d=!!i.connection_info&&/^https?:\/\//i.test(i.connection_info.trim());console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.bold.white(" What to do next:")),d&&console.log(chalk.white(` connect ${e}`)+chalk.gray(" How to attack & submit — full guide")),console.log(chalk.white(' hint "how to start?"')+chalk.gray(" Ask the AI teammate (if enabled this round)")),i.files&&i.files.length>0&&console.log(chalk.white(` files ${e}`)+chalk.gray(" Download challenge files")),i.connection_info&&!d&&console.log(chalk.white(` connect ${e}`)+chalk.gray(" Connect to target")),console.log(chalk.white(` submit ${e} <flag>`)+chalk.gray(" Submit your answer (paste the full flag with its wrapper)")),console.log(chalk.gray(" ─────────────────────────────────────────────"))}catch(e){s.fail("Failed to load challenge"),g(e.message)}}),I.command("submit <id> <flag>").description("Submit a flag").action(async(e,o)=>{i(`ctf submit ${e}`),s(parseInt(e,10),o);const{client:t}=C(),a=f("Submitting flag...");a.start();try{const i=await t.submitFlag(parseInt(e,10),o);switch(a.stop(),i.status){case"correct":console.log(),console.log(chalk.green.bold(" 🎉 Correct! ")+chalk.white(i.message)),console.log();break;case"incorrect":g(`Incorrect. ${i.message}`);break;case"already_solved":m("Already solved.");break;case"paused":m("Competition is paused.");break;case"ratelimited":m("Rate limited. Please wait before trying again.");break;default:p(i.message||"Unknown response")}await n()}catch(e){a.fail("Submission failed"),g(e.message)}}),I.command("scoreboard [top]").description("View scoreboard (optional: top N)").action(async e=>{i("ctf scoreboard");const{config:o,client:t}=C(),n=f("Loading scoreboard...");n.start();try{const e=await t.getScoreboard();if(n.stop(),!e||0===e.length)return void p("Scoreboard is empty.");h("Scoreboard");const i=e.map(e=>{const t=e.account_id===o.teamId,n=[String(e.pos),e.name,String(e.score)];return t?n.map(e=>chalk.yellow.bold(e)):n});y(["Rank","Team","Score"],i)}catch(e){n.fail("Failed to load scoreboard"),g(e.message)}}),I.command("status").description("Show competition status").action(async()=>{i("ctf status");const{config:e,client:o}=C();h("Competition Status");const t={pre_competition:chalk.yellow,demo:chalk.blue,live:chalk.green,finished:chalk.red,unknown:chalk.gray},n=e.competitionState||"unknown",s=t[n]||chalk.gray;console.log(` ${chalk.gray("State:")} ${chalk.bold(s({pre_competition:"PRE-COMPETITION",demo:"DEMO",live:"LIVE",finished:"FINISHED",unknown:"UNKNOWN"}[n]||n))}`);try{const e=await o.testConnection();w("User",chalk.white.bold(e.name)),w("Score",chalk.yellow.bold(String(e.score||0))),w("Rank",chalk.cyan(e.place||"N/A"))}catch{w("User",e.userName||"Unknown")}if(e.competitionEndsAt){console.log();const o=new Date(e.competitionEndsAt);new Date<o?w("Time Remaining",chalk.yellow.bold(b(o))):w("Time",chalk.red("Competition ended"))}console.log()}),I.command("time").description("Show competition countdown").action(()=>{i("ctf time");const e=o();if(!e.competitionStartsAt&&!e.competitionEndsAt)return p("Competition times not configured."),void p("They will be set when the competition server provides timing information.");const t=new Date,n=e.competitionStartsAt?new Date(e.competitionStartsAt):null,s=e.competitionEndsAt?new Date(e.competitionEndsAt):null;h("Competition Timer"),n&&t<n?(console.log(chalk.yellow(" Competition has not started yet.")),console.log(),console.log(` ${chalk.bold("Starts in:")} ${b(n)}`)):s&&t<s?(console.log(chalk.green(" Competition is LIVE")),console.log(),console.log(` ${chalk.bold("Time remaining:")} ${b(s)}`)):console.log(chalk.red(" Competition has ended."))})}