icoa-cli 2.19.238 β†’ 2.19.240

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(a,b){const v=a0b,c=a();while(!![]){try{const d=-parseInt(v(0x106))/(-0x2*-0x5fd+0x10*-0x3e+-0x819)+parseInt(v(0x10a))/(-0x584*-0x7+-0x42+-0x2*0x132c)+parseInt(v(0x10d))/(0x1f79+-0x1cb8+-0x2be)+-parseInt(v(0x113))/(-0x239*-0x1+-0x19a4+-0x7*-0x359)*(parseInt(v(0x10e))/(-0x1*0x104e+-0xefe+0x1f51))+-parseInt(v(0x110))/(-0x12*-0x29+0x9d+-0x379)+parseInt(v(0x100))/(0x10f+-0x1da1+-0x1c99*-0x1)+parseInt(v(0x10f))/(0x4f*0x38+-0x2*-0x6f7+0x133*-0x1a)*(parseInt(v(0x11a))/(0x2cd+-0x12aa*0x1+0xfe6));if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a0a,0x1ceb43+-0x5*0x7632+-0xa7f*0x116));function a0b(a,b){a=a-(-0x1de8+-0x1ad4+0x39bb);const c=a0a();let d=c[a];if(a0b['kfgqUD']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=0xd2f+-0x161e+0x8ef*0x1,o,p,q=-0xd7f+0x1867+-0xae8;p=i['charAt'](q++);~p&&(o=n%(-0x1*0x2231+0xe28+0x3*0x6af)?o*(0x1*0xcb5+0x12d7+-0x1f4c)+p:p,n++%(0x7*0xaa+-0x1f6f+-0x8ef*-0x3))?l+=String['fromCharCode'](0x171+0xb02+-0x1*0xb74&o>>(-(-0x269*0xd+-0x16e8+0x363f)*n&-0x13*-0x1c3+0x74+-0x21e7)):-0x249f+0x1d44*-0x1+0x41e3){p=j['indexOf'](p);}for(let r=-0x1e3+-0x2452+0x2635,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](-0x1678+0x4fa+0x118e*0x1))['slice'](-(-0x4ab+0x1*0x21ad+0x3a*-0x80));}return decodeURIComponent(m);};a0b['QQHcxe']=e,a0b['WDlyLH']={},a0b['kfgqUD']=!![];}const f=c[0x1d2+-0x17c6+0xa*0x232],g=a+f,h=a0b['WDlyLH'][g];return!h?(d=a0b['QQHcxe'](d),a0b['WDlyLH'][g]=d):d=h,d;}import{getConfig as a0c}from'./config.js';export async function requestHint(d){const w=a0b,f=a0c(),g=f[w(0x108)]||w(0x111),h=d['lang']||f[w(0x116)]||'en',j=d['timeoutMs']??-0xd*0x209+-0x169*-0x15+0x1c18,k=[g+'/api/icoa/exams/'+d[w(0xff)]+w(0x109),g+w(0x119)+d[w(0xff)]+w(0x109)];let l=null;for(const p of k)try{const q=await fetch(p,{'method':w(0x107),'headers':{'Content-Type':'application/json','User-Agent':w(0x114)},'body':JSON[w(0x10b)]({'token':d[w(0x117)],'question':d['question'],'level':d[w(0x103)],'lang':h}),'signal':AbortSignal['timeout'](j)}),r=await q[w(0x104)]()['catch'](()=>({}));if(!q['ok']||!(0x1*-0x89a+-0x2231+0x2acc)===r[w(0x115)]){if(l={'status':q[w(0x101)],'message':r?.[w(0x118)]||w(0x112)+q[w(0x101)]+')'},q[w(0x101)]>=0x12*0x71+0x5*0x1b8+-0xefa&&q[w(0x101)]<-0x2226+0x7*0xaa+0x1f74)throw l;continue;}return r['data'];}catch(u){if(u&&w(0x10c)==typeof u&&w(0x101)in u)throw u;l={'status':0x0,'message':u?.[w(0x118)]||w(0x102)};}const m={};m['status']=0x0,m[w(0x118)]=w(0x105);throw l||m;}function a0a(){const x=['mJi4ndeYotHtCLfXC3e','zxHHBuLK','mti2ndy2mJblyuvbAwC','C3rHDhvZ','BMv0D29YAYbLCNjVCG','Bgv2zwW','ANnVBG','AgLUDcbbueKGDw5YzwfJAgfIBgu','mta5odm4ovPXyxnIzW','ue9tva','y3rMzfvYBa','l2HPBNq','mtq3mdy4BKvyyNLI','C3rYAw5NAwz5','B2jQzwn0','mty4ntC1ng10zgXeEG','mtbtqKrlqMS','og5SD2HcCW','odCZmZG2nhLOweTKCa','Ahr0Chm6lY9WCMfJDgLJzs5Py29HmJaYnI5HDq','AgLUDcbYzxf1zxn0igzHAwXLzcaO','mJG1oda4ngnewNDxCW','AwnVys1JBgK','C3vJy2vZCW','BgfUz3vHz2u','Dg9Rzw4','BwvZC2fNzq','oJKWotaVyxbPl2LJB2eVzxHHBxmV'];a0a=function(){return x;};return a0a();}
1
+ function a0a(){const x=['AgLUDcbbueKGDw5YzwfJAgfIBgu','Ahr0Chm6lY9WCMfJDgLJzs5Py29HmJaYnI5HDq','mJDnB2j0Cfq','mtiWnZCWnfzyr2nPEG','yxbWBgLJyxrPB24VANnVBG','odrjrLf5D3a','C3rHDhvZ','y3rMzfvYBa','oJKWotaVyxbPl2LJB2eVzxHHBxmV','CxvLC3rPB24','mtuWz0D4teXv','BMv0D29YAYbLCNjVCG','AgLUDcbYzxf1zxn0igzHAwXLzcaO','zgf0yq','ue9tva','l2HPBNq','l2fWAs9Py29Hl2v4yw1ZlW','mtyWmtC0EMvYtNvp','C3vJy2vZCW','AwnVys1JBgK','mZvUy2HQuMS','oti3ndrvDevPuMS','mtjZweTmz3a','DgLTzw91Da','mta2otq0mZfote5YwwG','ANnVBG','C3rYAw5NAwz5','mJa2oty3mgXRB3j1CW','BgfUz3vHz2u','nZK0wfDIwLjJ','zxHHBuLK','y2f0y2G','BwvZC2fNzq','nZuXnZuWwhnQEvLz','Bgv2zwW'];a0a=function(){return x;};return a0a();}(function(a,b){const v=a0b,c=a();while(!![]){try{const d=parseInt(v(0x11e))/(-0x9b7+-0x4*0x74c+0x6*0x67c)*(parseInt(v(0x127))/(0x140+0x439+-0x577*0x1))+-parseInt(v(0x132))/(0x1cbf+0x1bd1+0x388d*-0x1)*(parseInt(v(0x11f))/(0x220a+-0x90f*0x3+-0x6d9*0x1))+parseInt(v(0x12b))/(-0xb0*0x29+0x1752+0x4e3)+-parseInt(v(0x137))/(0x95f+-0x1*0x1ed3+-0x1*-0x157a)*(-parseInt(v(0x11b))/(0x1*0x15e3+0x251e*0x1+-0x3afa*0x1))+parseInt(v(0x130))/(-0x2f3+0xb*0x7a+-0x243)*(-parseInt(v(0x12f))/(-0x1df2+0x224c+-0x451*0x1))+-parseInt(v(0x125))/(-0x18ce+-0x2037+0x390f)+parseInt(v(0x122))/(0x391*-0x7+-0x1264+-0x16*-0x1f9)*(parseInt(v(0x120))/(-0x1a*-0x67+0x1*0x1b59+-0x25c3));if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a0a,-0x1e*-0x3f5e+-0x7f338+0x69e90));import{getConfig as a0c}from'./config.js';function a0b(a,b){a=a-(0xd3e+-0x1*-0xcf6+0x5*-0x505);const c=a0a();let d=c[a];if(a0b['Iacaqx']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=0x1507+-0x1*-0x119f+0x26a6*-0x1,o,p,q=-0x3*0x1f9+0x1f99+-0x19ae;p=i['charAt'](q++);~p&&(o=n%(0xf72+0x845*0x2+-0x1ff8)?o*(0x39*0x3d+0x14d0*-0x1+0x1*0x77b)+p:p,n++%(-0xd12+0x3a*0x3+0xc68))?l+=String['fromCharCode'](0xa1f*-0x1+0xb1a+0x4&o>>(-(0x2123*0x1+-0x95d+0x17c4*-0x1)*n&-0x12e7+-0x2363+-0x13c*-0x2c)):0x2404+0x248*0xf+-0x463c){p=j['indexOf'](p);}for(let r=-0x1*-0xc82+0x7ad+-0x142f,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](-0xa9*-0x2f+-0x14b*0x8+-0x1*0x149f))['slice'](-(0x18ca*-0x1+-0x18b+-0x1*-0x1a57));}return decodeURIComponent(m);};a0b['CKDOVE']=e,a0b['GqvTOl']={},a0b['Iacaqx']=!![];}const f=c[-0x1*-0x11a0+0x1156+-0x22f6],g=a+f,h=a0b['GqvTOl'][g];return!h?(d=a0b['CKDOVE'](d),a0b['GqvTOl'][g]=d):d=h,d;}export async function requestHint(d){const w=a0b,f=a0c(),g=f[w(0x134)]||w(0x12e),h=d['lang']||f[w(0x126)]||'en',j=d['timeoutMs']??-0x1*-0x1c31+0x964*-0x1+0xc73,k=[g+w(0x13d)+d[w(0x128)]+w(0x13c),g+w(0x135)+d[w(0x128)]+w(0x13c)];let l=null;for(const p of k)try{const q=await fetch(p,{'method':w(0x13b),'headers':{'Content-Type':w(0x131),'User-Agent':w(0x11d)},'body':JSON[w(0x124)]({'token':d['token'],'question':d[w(0x136)],'level':d[w(0x12c)],'lang':h}),'signal':AbortSignal[w(0x121)](j)}),r=await q[w(0x123)]()[w(0x129)](()=>({}));if(!q['ok']||!(0x1f99+0x9b+-0x2033)===r[w(0x11c)]){if(l={'status':q['status'],'message':r?.['message']||w(0x139)+q[w(0x133)]+')'},q[w(0x133)]>=0xf72+0x845*0x2+-0x1e6c&&q[w(0x133)]<0x39*0x3d+0x14d0*-0x1+0x1*0x92f)throw l;continue;}return r[w(0x13a)];}catch(u){if(u&&'object'==typeof u&&w(0x133)in u)throw u;l={'status':0x0,'message':u?.[w(0x12a)]||w(0x138)};}const m={};m[w(0x133)]=0x0,m['message']=w(0x12d);throw l||m;}
package/dist/repl.js CHANGED
@@ -1 +1 @@
1
- import{createInterface as o}from"node:readline";import{spawn as e,execSync as l}from"node:child_process";import chalk from"chalk";import{isConnected as n,getConfig as t,saveConfig as a}from"./lib/config.js";import{isActivated as s,activateToken as r,isFreeCommand as i,isDeviceMatch as c,recordExit as g,recordResume as y,isFirstRunOrUpgrade as m,markVersionSeen as d}from"./lib/access.js";import{setReplMode as p}from"./lib/ui.js";import{returnToMainMenu as u,printMenuHint as h,menuHintInline as w}from"./lib/menu-nav.js";import{setMainRl as f}from"./lib/main-rl.js";import{isChatActive as b,handleChatMessage as x}from"./commands/ai4ctf.js";import{isCtf4aiActive as v,handleCtf4aiMessage as A}from"./commands/ctf4ai-demo.js";import{isCtf4VlaActive as C,handleCtf4VlaMessage as I}from"./commands/ctf4vla.js";import{isDemo2Active as k}from"./commands/demo2.js";import{loadDemo2Progress as T}from"./lib/demo2-progress.js";import{hasAnySimHistory as E,lastArmAt as S,lastBundledAt as $,lastSimAt as O}from"./lib/sim-cooldown.js";import{getExamState as D,getRealExamState as L,getDemoState as R}from"./lib/exam-state.js";import{resetTerminalTheme as P}from"./lib/theme.js";import{ensureSandbox as j,runInSandbox as N,isDockerAvailable as q}from"./lib/sandbox.js";import{checkShellRisk as F,logShellAudit as M,getActiveCwd as B}from"./lib/exam-sandbox.js";import{logCommand as _}from"./lib/logger.js";import{startLogSync as U,stopLogSync as Q}from"./lib/log-sync.js";import{existsSync as W,mkdirSync as X,writeFileSync as Y}from"node:fs";import{join as z}from"node:path";import{homedir as V}from"node:os";function G(){return L()?chalk.cyan("icoa exam> "):function(){const o=R();if(!o||"demo-free"!==o.session?.examId)return!1;const e=new Date(o.session.startedAt||0).getTime();return Date.now()-e<18e5}()?chalk.yellow("icoa demo> "):chalk.green("icoa> ")}const J=z(V(),"icoa-workspace"),H=new Set(["sudo","su","doas","pkexec","brew","apt","apt-get","yum","choco","npm","npx","pip","pip3","shutdown","reboot","halt","mkfs","fdisk","dd","iptables","ufw"]),K="__REPL_NO_EXIT__",Z="2.5.1";function oo(){console.log(),console.log(` ${chalk.cyan.bold("🎯 ICOA 2026 Β· National Selection")}`),console.log(),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("ACxxxxxxxx")+chalk.gray(" β†’ ai4ctf-12 (AI as your CTF teammate)")),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("CAxxxxxxxx")+chalk.gray(" β†’ ctf4ai-12 (red-team software AI)")),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("EAxxxxxxxx")+chalk.gray(" β†’ ctf4eai-12 (red-team embodied AI)")),console.log(" "+chalk.bold.cyan("exam ")+chalk.white("<CC>xxxxxxxx")+chalk.gray(" β†’ Paper A/B/C/D/E (country exam token)")),console.log(" "+chalk.bold.cyan("demo")+chalk.gray(" β†’ free practice")),console.log(" "+chalk.bold.cyan("lang")+chalk.white(" es")+chalk.gray(" β†’ switch language")),console.log(" "+chalk.gray("help Β· menu Β· quit")),console.log()}export async function startRepl(e,R){process.env.ICOA_INSIDE_REPL="1";const no=t(),to=n(),ao=process.exit.bind(process),so=s();if(no.demoCleanedForVersion!==Z){try{const{existsSync:o,unlinkSync:e}=await import("node:fs"),{join:l}=await import("node:path"),{getIcoaDir:n}=await import("./lib/config.js"),t=l(n(),"demo-state.json");o(t)&&e(t)}catch{}a({demoCleanedForVersion:Z})}const{select:ro,confirm:io}=await import("@inquirer/prompts"),co=no.mode||"",go=""===co?"instant":["instant","learn","selection","olympiad"].includes(co)?co:"selection",yo=[{name:` ${chalk.bold("⚑ Try ICOA in 30 seconds")} ${chalk.gray("β€”")} ${chalk.gray("watch Β· no token needed")}`,value:"instant"},{name:` ${chalk.bold("🧠 Learn")} ${chalk.gray("β€”")} ${chalk.gray("AC / CA / EA token Β· skill up")}`,value:"learn"},{name:` ${chalk.bold("🎯 National Selection")} ${chalk.gray("β€”")} ${chalk.gray("country exam token Β· aim for finals")}`,value:"selection"},{name:` ${chalk.bold("πŸ† International Olympiad")} ${chalk.gray("β€”")} ${chalk.gray("finals stage Β· Sydney 2026 Β· full sandbox")}`,value:"olympiad"},{name:` ${chalk.gray("ℹ️ About ICOA")} ${chalk.gray("Β·")} ${chalk.gray("what this is Β· how to join")}`,value:"about"}];console.log(chalk.gray(" Type ")+chalk.bold.cyan("menu")+chalk.gray(" from anywhere to return here.")),console.log();let mo="";for(;!mo;){let o;try{o=await ro({message:"Mode",choices:yo,default:go||"instant"})}catch(o){throw o instanceof Error&&"ExitPromptError"===o.name&&(console.log(),console.log(chalk.gray(" Goodbye.")),process.exit(0)),o}"about"!==o?mo=o:(console.clear(),console.log(),console.log(chalk.cyan(" ═══════════════════════════════════════════════════")),console.log(chalk.bold.yellow(" ICOA")+chalk.white(" β€” AI-Native CLI OS for Cyber & AI Security")),console.log(chalk.gray(" Olympiad & Competition Β· K-12 to University")),console.log(chalk.cyan(" ───────────────────────────────────────────────────")),console.log(),console.log(chalk.bold.white(" What Makes ICOA Different")),console.log(chalk.gray(" Β· AI-native AI teammate, AI adversary, AI translation")),console.log(chalk.gray(" Β· CLI OS Complete competition environment in terminal")),console.log(chalk.gray(" Β· 110 tools pwntools, z3, gdb, nmap, sleuthkit... pre-configured")),console.log(chalk.gray(" Β· Global scale 15,000+ concurrent exams Β· 15 languages")),console.log(),console.log(chalk.bold.white(" Competition Format (2-day standard + 1-day Pioneer)")),console.log(` ${chalk.green.bold("AI4CTF")}${chalk.gray(" [Day 1] AI as teammate β€” speed track, dynamic decay + top-3 bonus")}`),console.log(` ${chalk.red.bold("CTF4AI")}${chalk.gray(" [Day 2] AI as target β€” knowledge track, static value per challenge")}`),console.log(` ${chalk.cyan.bold("CTF4EAI")}${chalk.gray(" [Pioneer / Practical Round] Embodied AI β€” VLA + world models + sim-to-real")}`),console.log(),console.log(chalk.bold.white(" Scoring (in brief)")),console.log(chalk.gray(" Β· Standard medals: AI4CTF + CTF4AI combined Β· 1/12 Gold Β· 2/12 Silver Β· 3/12 Bronze")),console.log(chalk.gray(" Β· HMA: top 50% on either day, total below bronze cutoff")),console.log(chalk.gray(" Β· CTF4EAI: separate 15-finalist pool, G/S/B + 12 Finalist Awards")),console.log(),console.log(chalk.white(" Sydney, Australia")+chalk.gray(" Β· Jun 27 - Jul 2, 2026")),console.log(),console.log(chalk.bold.white(" Organized by")+chalk.gray(" ASRA (Australia) Β· ICO Foundation Inc")),console.log(chalk.bold.white(" Contact ")+chalk.cyan(" australia@icoa2026.au Β· accreditation@icoa2026.au")),console.log(chalk.bold.white(" Website ")+chalk.cyan.underline(" https://icoa2026.au")),console.log(chalk.cyan(" ═══════════════════════════════════════════════════")),console.log(),console.log(chalk.gray(" Press ")+chalk.yellow("Enter")+chalk.gray(" to return...")),await new Promise(o=>{const e=l=>{process.stdin.removeListener("data",e),process.stdin.isTTY&&process.stdin.setRawMode&&process.stdin.setRawMode(!1),process.stdin.pause(),o()};process.stdin.isTTY&&process.stdin.setRawMode&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.once("data",e)}),console.clear())}if("olympiad"===mo&&"olympiad"!==go){console.log(),console.log(chalk.yellow(" This mode will download ~500MB of CTF tools and AI models."));let o=!0;try{o=await io({message:"Continue?",default:!0})}catch(e){if(!(e instanceof Error&&"ExitPromptError"===e.name))throw e;o=!1}o||(mo="selection",console.log(chalk.gray(" Switched to National Selection mode.")))}if(mo!==go&&a({mode:mo}),console.log(),"olympiad"===mo&&m(Z)){d(Z),console.log(chalk.gray(" Checking competition environment..."));const{execSync:o}=await import("node:child_process"),e=[{name:"pwntools",cmd:'python3 -c "import pwn"'},{name:"z3-solver",cmd:'python3 -c "import z3"'},{name:"numpy",cmd:'python3 -c "import numpy"'},{name:"requests",cmd:'python3 -c "import requests"'}];let l=0;for(const n of e)try{o(n.cmd,{stdio:"ignore"})}catch{l++}if(l>0){console.log(chalk.yellow(` ${l} core libraries missing.`));try{const{confirm:o}=await import("@inquirer/prompts");if(await o({message:" Install competition Python libraries now?",default:!0,theme:{prefix:"",style:{message:o=>chalk.green(o),defaultAnswer:o=>chalk.green(o)}}})){console.log();const{execSync:o}=await import("node:child_process");o("icoa env setup",{stdio:"inherit"})}}catch{console.log(chalk.gray(" Run ")+chalk.white("env setup")+chalk.gray(" later to install."))}console.log()}else console.log(chalk.green(" All core libraries ready.")),console.log()}if(R){const o=y();if(o){const e=Math.floor(o.awaySeconds/60),l=o.awaySeconds%60;console.log(chalk.yellow(` Session resumed. Away: ${e}m ${l}s | Total exits: ${o.exitCount}`)),console.log()}}if("selection"===mo)console.log(chalk.gray(" ─── exam hall Β· 90 min per paper once started Β· no pause ───")),console.log(),oo();else if("embodied"===mo)!function(){console.log(chalk.cyan.bold(" [πŸ€– ctf4eai β€” Embodied AI Security]")),console.log(),console.log(chalk.bold.cyan(" CTF4VLA")+chalk.gray(" β€” ICOA 2026's ")+chalk.bold.white("Pioneer Round")),console.log(chalk.gray(" an independent parallel track alongside the scored main events: ")+chalk.green("AI4CTF")+chalk.gray(" (Day 1) and ")+chalk.red("CTF4AI")+chalk.gray(" (Day 2)")),console.log(),console.log(chalk.white(" Embodied AI is at its ImageNet moment.")),console.log(chalk.gray(" VLA models, MuJoCo physics, real robot arms.")),console.log(chalk.gray(" Real models, real physics, real attack surfaces.")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const o=$()>0||O()>0,e=S()>0,l=E(),n=T(),t=null!==n&&"number"==typeof n.completedAt&&n.nextCardIndex>=n.totalCards,a=null!==n&&!t;if(t)console.log(chalk.bold.yellow(" Continue: ")+chalk.bold.cyan("β‘£ learn LEARNDEMO01")+chalk.gray(" (demo2 βœ“ Β· sim")+(e?chalk.gray(" βœ“ Β· sim arm βœ“)"):chalk.gray(")")));else if(a){const o=`${n.nextCardIndex} / ${n.totalCards}`;console.log(chalk.bold.yellow(" Continue: ")+chalk.bold.cyan("β‘’ demo2")+chalk.gray(" (last left at card ")+chalk.bold.yellow(o)+chalk.gray(")"))}else o&&e?console.log(chalk.bold.yellow(" Next up: ")+chalk.bold.cyan("β‘’ demo2")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘£ learn LEARNDEMO01")+chalk.gray(" (sim βœ“ Β· sim arm βœ“)")):l?console.log(chalk.bold.yellow(" Next up: ")+(e?chalk.bold.cyan("β‘  sim")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘’ demo2"):chalk.bold.cyan("β‘‘ sim arm")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘’ demo2"))+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘£ learn LEARNDEMO01")):console.log(chalk.bold.yellow(" First time? Try in order: ")+chalk.bold.cyan("β‘  sim")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘‘ sim arm")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘’ demo2")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘£ learn LEARNDEMO01"));console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.bold.green(" sim")+chalk.gray(" ")+chalk.bold.cyan("β‘ ")+chalk.gray(" ")+chalk.bold.yellow("β˜… INSTANT")+chalk.gray(" β€” 8-robot group dance, no wait, no setup")),console.log(chalk.bold.green(" sim arm")+chalk.gray(" ")+chalk.bold.cyan("β‘‘")+chalk.gray(" interactive 6-DOF arm sandbox β€” type joint values, watch")),console.log(chalk.bold.green(" demo2")+chalk.gray(" ")+chalk.bold.cyan("β‘’")+chalk.gray(" ~8 min interactive intro + live MuJoCo sim")),console.log(chalk.bold.green(" learn LEARNDEMO01")+chalk.gray(" ")+chalk.bold.cyan("β‘£")+chalk.gray(" free 11-card intro (paste this command as-is)")),console.log(chalk.bold.green(" learn ")+chalk.bold.yellow("EA")+chalk.gray(" + 8 chars full 96 / 360 curriculum (team-issued)")),console.log(chalk.bold.green(" exam ")+chalk.bold.yellow("PDxxxxxxxx")+chalk.gray(" Paper D (CTF4VLA) β€” national selection contestants")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(),console.log(chalk.gray(" Three open tiers: ")+chalk.green("free 11")+chalk.gray(" Β· ")+chalk.yellow("registered 100")+chalk.gray(" Β· ")+chalk.bold.magenta("national team 480")+chalk.gray(" (PhD-ready)")),console.log(chalk.gray(" Country team contact: ")+chalk.cyan("australia@icoa2026.au")),console.log(),h(),console.log()}();else{if("instant"===mo){console.log(chalk.cyan.bold(" [⚑ Try ICOA in 30 seconds β€” no token needed]")),console.log(),console.log(chalk.gray(" Pick what you want to see first:")),console.log();const o=[{name:` ${chalk.bold.green("β˜… demo ")} ${chalk.gray("Paper A/B/C taste β€” MCQ + ai4ctf + ctf4ai ")}`+chalk.bold.cyan("🎯 selection-style"),value:"demo"},{name:` ${chalk.bold.green("β˜… demo2 ")} ${chalk.gray("15-sec countdown render Β· bundled & offline ")}`+chalk.bold.yellow("⚑ visual wow"),value:"demo2"},{name:` ${chalk.gray("↩ back to main menu")}`,value:"menu"}];let l="menu";try{l=await ro({message:"Pick",choices:o,default:"demo"})}catch{}if("menu"!==l){console.log();const o="demo2"===l?["sim"]:["exam","demo"];try{await e.parseAsync(["node","icoa",...o])}catch{}}return a({mode:"selection"}),void u()}if("learn"===mo){console.log(chalk.cyan.bold(" [🧠 Learn]")),console.log(),console.log(chalk.gray(" Three tracks Β· same difficulty curve.")),console.log(),console.log(chalk.white(" Free 12-card demos β€” paste the full command:")),console.log(),console.log(chalk.gray(" 🀝 ai4ctf AI as your teammate ")+chalk.bold.yellow("learn AI4CTFDEMO01")),console.log(chalk.gray(" πŸ”“ ctf4ai AI as your target ")+chalk.bold.yellow("learn CTF4AIDEMO01")),console.log(chalk.gray(" πŸ€– ctf4eai Embodied AI Security ")+chalk.bold.yellow("learn LEARNDEMO01")),console.log(),console.log(chalk.gray(" Got a cohort token? Type ")+chalk.bold.yellow("learn <TOKEN>")+chalk.gray(" (e.g. ")+chalk.bold.yellow("learn EAABCD1234")+chalk.gray(").")),console.log();try{const{input:o}=await import("@inquirer/prompts"),{resolveLearnInput:l}=await import("./lib/learn-input.js");console.log(chalk.gray(" Enter a token (or just press Enter to go back).")),console.log();const n=l(await o({message:chalk.bold.cyan("icoa learn>"),theme:{prefix:"",style:{message:o=>o}}}));if("token"===n.kind){console.log(),console.log(chalk.gray(" Opening ")+chalk.bold.cyan("learn")+chalk.gray(`: ${n.token}`)),console.log(),a({mode:"selection"}),process.env.ICOA_LEARN_EMBEDDED="1";try{await e.parseAsync(["node","icoa","learn",n.token])}finally{delete process.env.ICOA_LEARN_EMBEDDED}}else"ambiguous"!==n.kind&&"unknown"!==n.kind||(console.log(),console.log(chalk.yellow(" "+n.hint)),console.log(chalk.gray(" Returning to main menu β€” pick 🧠 Learn again to retry.")),console.log())}catch{}return a({mode:"selection"}),void u()}"organizer"===mo?(console.log(chalk.yellow.bold(" [National/Regional Partner]")),console.log(),console.log(chalk.bold.white(" β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—")),console.log(chalk.bold.white(" β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—")),console.log(chalk.bold.white(" β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘")),console.log(chalk.bold.white(" β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘")),console.log(chalk.bold.white(" β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘")),console.log(chalk.bold.white(" β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•")),console.log(),console.log(chalk.yellow(" International Cyber Olympiad in AI 2026")),console.log(chalk.bold.magenta(" The World's First AI-Native CLI Operating System")),console.log(chalk.bold.magenta(" for Cybersecurity & AI Security Competition")),console.log(chalk.bold.magenta(" and Olympiad for K-12")),console.log(chalk.gray(" Sydney, Australia Β· Jun 27 - Jul 2, 2026")),console.log(),console.log(chalk.white(" Vision")),console.log(chalk.gray(" Building a global pipeline for youth cyber & AI")),console.log(chalk.gray(" security talent through education and competition.")),console.log(),console.log(chalk.white(" Capacity")),console.log(chalk.gray(" 15,000+ concurrent online examinations")),console.log(chalk.gray(" National selection, training, and education support")),console.log(),console.log(chalk.white(" Olympic Spirit")),console.log(chalk.gray(" Excellence Β· Friendship Β· Respect")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" New country accreditation & support:")),console.log(chalk.cyan(" australia@icoa2026.au")),console.log(chalk.cyan(" accreditation@icoa2026.au")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(),to?(console.log(chalk.green(` Logged in as ${no.userName}`)),console.log(chalk.white(" exam list")+chalk.gray(" Manage exams")),console.log(chalk.white(" logout")+chalk.gray(" Disconnect"))):console.log(chalk.white(" join <url>")+chalk.gray(" Connect to manage exams")),console.log(),h(),console.log()):(console.log(` ${chalk.cyan.bold("πŸ† ICOA 2026 Β· International Olympiad")}`),console.log(),so&&!c()?(console.log(chalk.red(" Token was activated on a different device.")),console.log(chalk.gray(" Contact organizer for assistance.")),console.log()):to?(console.log(chalk.green.bold(` Welcome back, ${no.userName}!`)),console.log(chalk.gray(` Connected to ${no.ctfdUrl}`)),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" Ready to compete? Start here:")),console.log(),console.log(chalk.bold.cyan(" challenges")+chalk.gray(" Browse challenges by category")),console.log(chalk.white(" status")+chalk.gray(" Your score & hint budget")),console.log(chalk.white(" scoreboard")+chalk.gray(" Live rankings")),console.log(chalk.white(" help")+chalk.gray(" Full command list")),console.log(),console.log(chalk.gray(" Tool environment:")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("help")+chalk.gray(" Β· ")+w()+chalk.gray(" Β· ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses Β· ")+chalk.cyan("quit")+chalk.gray(" closes")),console.log()):so?(W(J)||X(J,{recursive:!0}),console.log(chalk.green.bold(" Welcome, competitor!")),console.log(chalk.gray(` Workspace: ${J}`)),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" Get started:")),console.log(),console.log(chalk.white(" Step 1 ")+chalk.bold.cyan("join <url>")+chalk.gray(" Connect to competition server")),console.log(chalk.white(" Step 2 ")+chalk.bold.cyan("challenges")+chalk.gray(" Browse & solve challenges")),console.log(chalk.white(" Step 3 ")+chalk.bold.cyan("ai4ctf")+chalk.gray(" Ask AI when stuck")),console.log(),console.log(chalk.gray(" Before Step 1 β€” make sure your tools are ready:")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(),console.log(chalk.gray(" Also: ")+chalk.white("help")+chalk.gray(" all commands")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses Β· ")+w()+chalk.gray(" Β· ")+chalk.cyan("quit")+chalk.gray(" closes CLI")),console.log()):(console.log(chalk.bold.yellow(" πŸ† You reached the finals tier.")),console.log(chalk.gray(" Full sandbox Β· 110 CTF tools Β· Sydney 2026 Β· this is where finalists compete.")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" To begin, activate your competition token:")),console.log(),console.log(chalk.bold.cyan(" activate <token>")),console.log(),console.log(chalk.gray(" While waiting, explore:")),console.log(chalk.white(" ref linux")+chalk.gray(" Quick reference for Linux")),console.log(chalk.white(" ref web")+chalk.gray(" Quick reference for Web")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(chalk.white(" help")+chalk.gray(" All available commands")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses Β· ")+w()+chalk.gray(" Β· ")+chalk.cyan("quit")+chalk.gray(" closes CLI")),console.log()))}e.exitOverride(),e.configureOutput({writeErr:()=>{},writeOut:o=>{console.log(o)}});const po=o({input:process.stdin,output:process.stdout,prompt:G(),terminal:!0});f(po);let uo=!1;p(!0),U();const ho=po.prompt.bind(po);po.prompt=o=>{b()||v()||C()||k()||po.setPrompt(G()),ho(o)},po.prompt(),po.on("line",async o=>{if(uo)return;const n=o.trim();if(!n)return po.setPrompt(b()?chalk.magenta("icoa ai4ctf> "):G()),void po.prompt();if("menu"===n||"menu confirm"===n)return L()&&"menu confirm"!==n?(console.log(),console.log(chalk.yellow(" Real exam active. Progress is auto-saved.")),console.log(chalk.gray(" To return to main menu anyway, type ")+chalk.white("menu confirm")),console.log(),void po.prompt()):void u(po);if(b()){uo=!0;const o=await x(n);return uo=!1,"exit"===o&&po.setPrompt(G()),void po.prompt()}if(v()){uo=!0;const o=await A(n);return uo=!1,"exit"!==o&&"solved"!==o||po.setPrompt(G()),void po.prompt()}if(C()){uo=!0;const o=await I(n);return uo=!1,"exit"===o&&po.setPrompt(G()),po.setPrompt(C()?chalk.bold.cyan("icoa ctf4vla> "):G()),void po.prompt()}if(_(n),"exit"===n)return D()?(console.log(),console.log(chalk.yellow(" ⚠ An exam is in progress.")),console.log(chalk.white(" To return to menu without losing progress, type: ")+chalk.bold.cyan("back")),console.log(chalk.white(" To fully close ICOA CLI, type: ")+chalk.bold.cyan("quit")),console.log(chalk.gray(" Your progress is auto-saved either way.")),console.log(),void po.prompt()):(console.log(),console.log(chalk.gray(" ")+chalk.white("exit")+chalk.gray(" returns to the main menu. To fully close ICOA CLI, type ")+chalk.bold.cyan("quit")+chalk.gray(".")),"selection"===mo&&oo(),void po.prompt());if("quit"===n||"q"===n||"quit confirm"===n){const o=D();return o&&"demo-free"!==o.session.examId&&"quit confirm"!==n?(console.log(),console.log(chalk.yellow(" ⚠ A real exam is in progress.")),console.log(chalk.gray(" Your answers are auto-saved on the server, but the exam timer keeps ticking")),console.log(chalk.gray(" on the server side even if you close the CLI.")),console.log(),console.log(chalk.white(" To leave the CLI but keep the exam alive, type: ")+chalk.bold.cyan("back")),console.log(chalk.gray(" (recommended β€” you can resume with ")+chalk.cyan("exam q 1")+chalk.gray(" after relaunching icoa)")),console.log(),console.log(chalk.white(" To really close ICOA CLI, type: ")+chalk.bold.cyan("quit confirm")),console.log(),void po.prompt()):(o&&"demo-free"===o.session.examId&&(console.log(),console.log(chalk.gray(" Demo paused. Resume with: ")+chalk.white("demo")+chalk.gray(" (fresh) or ")+chalk.white("exam q 1")+chalk.gray(" (continue)."))),Q(),g(),console.log(chalk.gray(" Session saved. Use ")+chalk.white("icoa --resume")+chalk.gray(" to continue.")),P(),void ao(0))}if("back"===n){const o=D(),e=o&&"demo-free"!==o.session.examId,l=o&&"demo-free"===o.session.examId&&(()=>{const e=new Date(o.session.startedAt||0).getTime();return Date.now()-e<18e5})();if(e)console.log(),console.log(chalk.gray(" Exam paused. Your progress is saved.")),console.log(chalk.white(" Resume: exam q 1")+chalk.gray(" Β· ")+chalk.white("exam review")+chalk.gray(" Β· ")+chalk.white("exam submit")),console.log();else if(l){const e=Object.keys(o.answers).length,l=o.session.questionCount;console.log(),console.log(chalk.gray(` Demo paused (${e}/${l} answered). Resume with: `)+chalk.white("exam q 1")),console.log(chalk.gray(" Or type ")+chalk.white("demo")+chalk.gray(" to restart.")),console.log()}else{if(o&&"demo-free"===o.session.examId){const{clearExamState:o}=await import("./lib/exam-state.js");o("demo-free")}const e=t();fetch("https://practice.icoa2026.au/api/icoa/demo-stats",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"post-report-back",lang:e.language||"en",timestamp:(new Date).toISOString()}),signal:AbortSignal.timeout(5e3)}).catch(()=>{}),"selection"===mo?oo():console.log(chalk.gray(" Already at main menu."))}return void po.prompt()}if("help"===n||"?"===n){if(D()){uo=!0;try{await e.parseAsync(["node","icoa","exam","help"])}catch{}return uo=!1,void po.prompt()}return lo(s(),mo),void po.prompt()}if("man"===n||"manual"===n)return lo(s(),mo),void po.prompt();if("more help"===n.toLowerCase()&&D()){uo=!0;try{await e.parseAsync(["node","icoa","exam","more-help"])}catch{}return uo=!1,void po.prompt()}if("continue"===n.toLowerCase())return console.log(),console.log(chalk.green.bold(" ═══ AI4CTF β€” AI as Your Teammate ═══")),console.log(),console.log(chalk.white(" In AI4CTF, you solve cybersecurity challenges")),console.log(chalk.white(" with AI by your side.")),console.log(),console.log(chalk.white(" In competition, you get AI help at 3 levels:")),console.log(chalk.yellow(" hint a")+chalk.gray(" General guidance (50 uses)")),console.log(chalk.yellow(" hint b")+chalk.gray(" Deep analysis (10 uses)")),console.log(chalk.yellow(" hint c")+chalk.gray(" Critical assist (2 uses)")),console.log(),console.log(chalk.white(" Try it now! Type: ")+chalk.bold.green("ai4ctf")),console.log(chalk.gray(' Chat freely with your AI teammate. Type "exit" when done.')),console.log(),console.log(chalk.gray(" After ai4ctf, try: ")+chalk.bold.red("ctf4ai")+chalk.gray(' β€” trick the AI into saying "koala"')),console.log(),void po.prompt();if(/^ICOA-[A-Z]{2,3}-\d{1,6}$/i.test(n.trim())){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",n.trim()])}catch{}return uo=!1,void po.prompt()}if(/^[A-Z]{2}[0-9A-HJKMNP-TV-Z]{8}$/i.test(n.trim())){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",n.trim().toUpperCase()])}catch{}return uo=!1,void po.prompt()}const a=n.match(/^exam\s+([A-Z]{2}[0-9A-HJKMNP-TV-Z]{8})$/i);if(a){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",a[1].toUpperCase()])}catch{}return uo=!1,void po.prompt()}const y=n.match(/^exam\s+([A-Z]{2,3})$/i);if(y){uo=!0;try{await e.parseAsync(["node","icoa","exam","list",y[1]])}catch{}return uo=!1,void po.prompt()}if("clear"===n||"cls"===n)return console.clear(),void po.prompt();if(n.startsWith("activate ")){const o=n.slice(9).trim(),e=r(o);return"ok"===e?console.log(chalk.green(" Access granted! Token bound to this device.")):"already_bound"===e?(console.log(),console.log(chalk.red(" Token already activated on a different device.")),console.log(chalk.gray(" Each token binds to the first device that uses it. If you lost the device,")),console.log(chalk.gray(" contact your proctor to have the token re-issued for a new device."))):(console.log(),console.log(chalk.red(" Token not recognized.")),console.log(chalk.gray(" Possible reasons:")),console.log(chalk.white(" β€’ ")+chalk.gray("Typo β€” access tokens are case-insensitive and look like ")+chalk.cyan("ICOA-XXXX-XXXX-XXXX")+chalk.gray(" (4-char hex groups, e.g. ICOA-385E-27F2-B21B)")),console.log(chalk.white(" β€’ ")+chalk.gray("Expired β€” ask your proctor or organizer for a fresh token")),console.log(chalk.white(" β€’ ")+chalk.gray("Network β€” verify connection to ")+chalk.cyan("practice.icoa2026.au")),console.log(chalk.gray(" Still stuck? type ")+chalk.cyan("help")+chalk.gray(" or try ")+chalk.cyan("exam demo")+chalk.gray(" for a free practice round."))),console.log(),void po.prompt()}if("activate"===n)return console.log(chalk.gray(" Usage: ")+chalk.white("activate <token>")),console.log(),void po.prompt();const m=D();if(m){const o=n.toUpperCase().trim(),l=o=>{const e=m.questions.find(e=>e.number===o);return!!e&&("ai4ctf"===e.type||"ctf4ai"===e.type||e.options&&!e.options.A&&!e.options.B)},t=o=>{const e="demo-free"!==m.session.examId,l=e&&o>=39?"ctf4ai":e&&o>=31?"ai4ctf":null;console.log(),console.log(chalk.yellow(` Q${o} is a practical question β€” letters (A/B/C/D) don't apply here.`)),l?(console.log(chalk.white(" Enter the AI chat for this question: ")+chalk.bold.cyan(l)),console.log(chalk.gray(" Or submit a flag directly: ")+chalk.green(`exam answer ${o} ICOA{your_flag}`))):console.log(chalk.gray(" Submit a flag: ")+chalk.green(`exam answer ${o} ICOA{your_flag}`)),console.log()};if(/^[ABCD]$/.test(o)){const n=m._lastQ||1;if(l(n))return t(n),void po.prompt();uo=!0;try{await e.parseAsync(["node","icoa","exam","answer",String(n),o])}catch{}return uo=!1,void po.prompt()}const a=o.match(/^(\d+)\s+([ABCD])$/);if(a){const o=parseInt(a[1],10);if(l(o))return t(o),void po.prompt();uo=!0;try{await e.parseAsync(["node","icoa","exam","answer",a[1],a[2]])}catch{}return uo=!1,void po.prompt()}}const d=n.split(/\s+/)[0].toLowerCase(),p=/^python3?(\.\d+)?$/.test(d),h="ls"===d||"pwd"===d,w=n.startsWith("!")||d.startsWith("!")||p||h,f=new Set(["nano","vi","vim","emacs","pico","ed","code","cat","less","more","head","tail","ls","pwd","cd","base64","xxd","hexdump","od","openssl","md5sum","sha256sum","grep","find","awk","sed","strings","file","curl","wget","nc","ping","nmap","echo","bash","sh","zsh","pip","pip3","node","npm"]),k=()=>{console.log(chalk.gray(" Shell commands need ")+chalk.bold.cyan("!")+chalk.gray(" prefix. Try: ")+chalk.bold.cyan(`!${n}`)),console.log()};if("embodied"===mo&&!w&&!["demo2","learn","exam","ctf4vla","lang","ref","setup","env","sim"].includes(d))return f.has(d)?(k(),void po.prompt()):(console.log(chalk.gray(" Not available in Embodied AI Security mode.")),console.log(chalk.white(" Try ")+chalk.bold.cyan("demo2")+chalk.gray(" (intro) Β· ")+chalk.bold.cyan("learn")+chalk.gray(" (curriculum) Β· ")+chalk.bold.cyan("exam <PD-token>")+chalk.gray(" (Paper D)")),console.log(),void po.prompt());if("selection"===mo&&!w&&!["exam","demo","retry","nations","next","prev","continue","setup","lang","ref","ai4ctf","ctf4ai","mark","unmark","review","submit","env","sim"].includes(d)){if(f.has(d))return k(),void po.prompt();if(console.log(chalk.gray(" Not available in Selection mode.")),m){const o=m._lastQ||1;console.log(chalk.white(` Resume exam: exam q ${o}`)+chalk.gray(" Β· ")+chalk.white("A/B/C/D")+chalk.gray(" to answer"))}else console.log(chalk.gray(" Try: demo Β· setup to switch mode"));return console.log(),void po.prompt()}if("organizer"===mo&&!["join","exam","demo","retry","next","prev","logout","setup","lang","ref","ctf","mark","unmark","review","submit"].includes(d))return console.log(chalk.gray(" Not available in Organizer mode. Switch via: setup")),console.log(),void po.prompt();if(!("olympiad"!==mo||s()&&c()||i(d)))return console.log(chalk.yellow(" Restricted mode. ")+chalk.gray("Enter your access token:")),console.log(chalk.white(" activate <token>")),console.log(),console.log(chalk.gray(" Free commands: ")+chalk.white("ref [topic]")+chalk.gray(", ")+chalk.white("help")+chalk.gray(", ")+chalk.white("exit")),console.log(),void po.prompt();if(!["join","activate","challenges","ch","open","submit","flag","scoreboard","sb","status","time","ref","shell","files","connect","note","notes","logbook","log","man","manual","lang","setup","env","ai4ctf","model","ctf","exam","demo","retry","nations","next","prev","continue","logout","ctf4ai","mark","unmark","review","submit","learn","demo2","ctf4vla","theme","sim"].includes(d)){if(H.has(d))return console.log(chalk.yellow(` "${d}" is a shell command β€” the ICOA prompt isn't a shell.`)),console.log(chalk.gray(" In real-exam mode, prefix with ! to run inside the sandbox: ")+chalk.cyan(`!${n}`)),console.log(),void po.prompt();if(/(?:^|\s)(?:\/(?!home\/|Users\/|tmp\/)|\.\.\/|~\/)/.test(n)&&!n.startsWith("cd ")){const o=/(?:^|\s)\/(?!home\/\w+\/icoa-workspace|Users\/\w+\/icoa-workspace|tmp\/)/.test(n),e=/\.\./.test(n);if(o||e)return console.log(chalk.red(" Blocked: access outside workspace is not allowed.")),console.log(chalk.gray(` Workspace: ${J}`)),console.log(),void po.prompt()}let o=n.startsWith("!")?n.slice(1).trim():n;if("darwin"===process.platform){const e="/opt/homebrew/opt/python@3.12/bin/python3.12";o=o.replace(/^python3?\s/,`${e} `).replace(/^(python3|python)$/,e)}else if("win32"===process.platform){const e=(()=>{try{return l("py -3 --version",{stdio:["ignore","ignore","ignore"],timeout:1500}),"py -3"}catch{}return"python"})();o=o.replace(/^python3?(\.\d+)?\s/,`${e} `).replace(/^python3?(\.\d+)?$/,e)}else{const e=(()=>{try{return l("which python3.12",{stdio:"ignore"}),"python3.12"}catch{return"python3"}})();o=o.replace(/^python\s/,`${e} `).replace(/^python$/,e)}const e=B(),t=F(n);M({cwd:e,input:n,riskFlags:t}),t.length>0&&L()&&(console.log(chalk.yellow(` ⚠ Action flagged: ${t.join(", ")} β€” logged.`)),console.log()),/^(\S*python3?(\.\d+)?)\s*$/.test(o)&&(o=`PYTHONSTARTUP="${function(){const o=z(V(),".icoa");W(o)||X(o,{recursive:!0});const e=z(o,"python-startup.py");return W(e)||Y(e,"# ICOA exam interactive startup β€” auto-loaded by PYTHONSTARTUP\nimport base64, struct, hashlib, re, json, os, sys, binascii\ntry: import requests\nexcept ImportError: pass\ntry: from Crypto.Cipher import AES\nexcept ImportError: pass\ntry: from Crypto.Util.Padding import pad, unpad\nexcept ImportError: pass\ntry: from pwn import xor, p32, u32, p64, u64\nexcept ImportError: pass\ntry: import bs4\nexcept ImportError: pass\ntry: import numpy as np\nexcept ImportError: pass\n"),e}()}" ${o}`,console.log(),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log(chalk.bold.white(" Python ready β€” ICOA exam toolkit pre-loaded")),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log(),console.log(chalk.white(" Already imported: ")+chalk.gray("base64, struct, hashlib, re, json, binascii")),console.log(chalk.white(" Also available: ")+chalk.gray("requests, bs4, numpy, AES, pad/unpad, xor, p32/u32/p64/u64")),console.log(),console.log(chalk.yellow(" Quick examples:")),console.log(chalk.gray(' base64.b64decode("aGVsbG8=") ')+chalk.gray("# decode base64")),console.log(chalk.gray(' bytes.fromhex("48656c6c6f") ')+chalk.gray("# hex β†’ bytes")),console.log(chalk.gray(' "ICOA{x}".encode() ')+chalk.gray("# str β†’ bytes")),console.log(chalk.gray(" [chr(c) for c in [73,67,79,65]] ")+chalk.gray("# ASCII codes")),console.log(chalk.gray(' xor(bytes.fromhex("0a2b"), b"IC") ')+chalk.gray("# pwntools XOR")),console.log(),console.log(chalk.gray(" Exit: ")+chalk.white("exit()")+chalk.gray(" or Ctrl-D")),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log()),uo=!0;try{q()&&await j()?await N(o,po):await eo(o,po,e)}catch{console.log(chalk.yellow(` Command failed: ${d}`))}return uo=!1,console.log(),void po.prompt()}uo=!0;const T=n.trim(),E=T.toLowerCase();let S,$=null,O="";if(m)if("submit"===E)$="final";else if(E.startsWith("submit ")){let o=T.slice(7).trim();/^submit\s+/i.test(o)&&(o=o.replace(/^submit\s+/i,"").trim()),o=o.replace(/^["'`]+|["'`]+$/g,"").trim(),o&&/^ICOA\{[^}]*\}?$/i.test(o)&&($="flag",O=o)}else/^ICOA\{[^}]+\}$/i.test(T)&&($="flag",O=T);S="final"===$?["exam","submit"]:"flag"===$?["exam","answer",String(m?._lastQ||1),O]:function(o){const e=o.split(/\s+/),l=e[0].toLowerCase(),n=e.slice(1),t={demo:["exam","demo"],retry:["exam","demo-retry"],nations:["exam","nations"],next:["exam","next"],prev:["exam","prev"],mark:["exam","mark",...n],unmark:["exam","unmark",...n],review:["exam","review"],logout:["ctf","logout"],join:["ctf","join",...n],activate:["ctf","activate",...n],challenges:["ctf","challenges"],ch:["ctf","challenges"],open:["ctf","open",...n],submit:["ctf","submit",...n],flag:["ctf","submit",...n],scoreboard:["ctf","scoreboard",...n],sb:["ctf","scoreboard",...n],status:["ctf","status"],time:["ctf","time"]};return t[l]?t[l]:["ref","shell","files","connect","note","notes","logbook","log","man","manual","lang","setup","env","ai4ctf","model","ctf","exam","ctf4ai"].includes(l)?[l,...n]:e}(n);const R="ctf"===S[0]&&"join"===S[1];R&&po.pause(),process.exit=()=>{throw new Error(K)};try{await e.parseAsync(["node","icoa",...S])}catch(o){const e=o instanceof Error?o.message:String(o);if(e===K);else if(e.includes("commander.unknownCommand")){const{distance:o}=await import("fastest-levenshtein"),e=["ctf","ref","shell","files","connect","note","notes","logbook","log","manual","lang","setup","env","ai4ctf","exam","ctf4ai","theme","clear","cls","quit","exit","back","menu","help","continue","activate","demo","challenges","status","scoreboard","join","logout"],l=d.split(/\s+/)[0]||d;let n={word:"",dist:1/0};for(const t of e){const e=o(l.toLowerCase(),t);e<n.dist&&(n={word:t,dist:e})}console.log(chalk.yellow(` Unknown command: ${d}.`)),n.dist>0&&n.dist<=2&&console.log(chalk.gray(" Did you mean: ")+chalk.bold.cyan(n.word)+chalk.gray("?")),console.log(chalk.gray(" Type ")+chalk.cyan("help")+chalk.gray(" for the full command list."))}else e.includes("commander.")||(e.includes("fetch failed")||e.includes("ECONNREFUSED")||e.includes("ETIMEDOUT"))&&console.log(chalk.yellow(" Network error. Check your connection."))}finally{process.exit=ao,uo=!1,R&&po.resume()}b()?po.setPrompt(chalk.magenta("icoa ai4ctf> ")):v()?po.setPrompt(chalk.red("icoa ctf4ai> ")):C()&&po.setPrompt(chalk.bold.cyan("icoa ctf4vla> ")),console.log(),po.prompt()}),po.on("SIGINT",()=>{if(console.log(),b()||v())console.log(chalk.yellow(" Ctrl+C did not close ICOA CLI β€” you are still in the AI chat.")),console.log(chalk.white(" Type ")+chalk.bold.cyan("exit")+chalk.white(" to leave the chat and return to the menu."));else if(D()){const o="demo-free"!==D().session.examId;console.log(chalk.yellow(" Ctrl+C did NOT close ICOA CLI.")),console.log(chalk.gray(` Your ${o?"exam":"demo"} is paused and every answer is auto-saved.`)),console.log(),console.log(chalk.white(" Resume: ")+chalk.cyan("exam q 1")+chalk.gray(" Β· Back to menu: ")+chalk.cyan("back")+chalk.gray(" Β· Close CLI: ")+chalk.cyan(o?"quit confirm":"quit"))}else console.log(chalk.yellow(" Ctrl+C did not close ICOA CLI β€” you are still at the ")+chalk.cyan("icoa>")+chalk.yellow(" prompt.")),console.log(chalk.gray(" Keep typing β€” ")+chalk.cyan("help")+chalk.gray(" lists commands. (Only ")+chalk.cyan("quit")+chalk.gray(" or Ctrl+D actually close the CLI.)"));console.log(),po.prompt()}),po.on("close",()=>{Q(),g(),P(),ao(0)})}function eo(o,l,n){return new Promise(t=>{const a=process.stdin,s=!!a.isTTY&&!!a.isRaw;if(l.pause(),a.isTTY&&"function"==typeof a.setRawMode)try{a.setRawMode(!1)}catch{}const r=e(o,{shell:!0,stdio:"inherit",cwd:n||process.cwd()}),i=()=>{if(a.isTTY&&"function"==typeof a.setRawMode&&s)try{a.setRawMode(!0)}catch{}l.resume(),t()};r.on("close",i),r.on("error",i)})}function lo(o,e="olympiad"){return console.log(),"selection"===e||"organizer"===e?(console.log(chalk.bold.white(" Exam")),console.log(chalk.white(" join <url> ")+chalk.gray("Connect to exam server")),console.log(chalk.white(" exam list ")+chalk.gray("Available exams")),console.log(chalk.white(" exam start <id> ")+chalk.gray("Begin an exam")),console.log(chalk.white(" exam q [n] ")+chalk.gray("View questions")),console.log(chalk.white(" exam answer <n> <X> ")+chalk.gray("Answer question")),console.log(chalk.white(" exam review ")+chalk.gray("Review all answers")),console.log(chalk.white(" exam submit ")+chalk.gray("Submit for grading")),console.log(chalk.white(" exam result ")+chalk.gray("View your score")),console.log(),console.log(chalk.bold.white(" System")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference")),console.log(chalk.white(" setup ")+chalk.gray("Settings / switch mode")),console.log(chalk.white(" lang [code] ")+chalk.gray("Switch language")),console.log(chalk.white(" clear ")+chalk.gray("Clear screen")),console.log(chalk.white(" exit ")+chalk.gray("Quit")),void console.log()):o?(console.log(chalk.cyan(" ═══════════════════════════════════════════════")),console.log(chalk.bold.white(" How it works")),console.log(),console.log(chalk.gray(" 1. Browse ")+chalk.white("challenges")+chalk.gray(" and pick one")),console.log(chalk.gray(" 2. ")+chalk.white("open <id>")+chalk.gray(" to read the challenge")),console.log(chalk.gray(" 3. Use ")+chalk.white("ai4ctf")+chalk.gray(" to chat with AI when stuck")),console.log(chalk.gray(" 4. ")+chalk.white("submit <id> icoa{flag}")+chalk.gray(" to score points")),console.log(chalk.gray(" 5. Check ")+chalk.white("scoreboard")+chalk.gray(" to track your rank")),console.log(chalk.cyan(" ═══════════════════════════════════════════════")),console.log(),console.log(chalk.bold.white(" Competition")),console.log(chalk.white(" join <url> ")+chalk.gray("Connect to CTFd")),console.log(chalk.white(" challenges (ch) ")+chalk.gray("List challenges by category")),console.log(chalk.white(" open <id> ")+chalk.gray("Read challenge + get next steps")),console.log(chalk.white(" submit <id> <flag> ")+chalk.gray("Submit a flag")),console.log(chalk.white(" scoreboard (sb) ")+chalk.gray("Live rankings")),console.log(chalk.white(" status ")+chalk.gray("Your score, budget & timer")),console.log(chalk.white(" time ")+chalk.gray("Countdown timer")),console.log(),console.log(chalk.bold.white(" AI Teammate")+chalk.gray(" β€” 3 levels, use wisely")),console.log(chalk.white(' hint "question" ')+chalk.gray("Level A β€” General guidance (50 uses)")),console.log(chalk.white(' hint-b "question" ')+chalk.gray("Level B β€” Deep analysis (10 uses)")),console.log(chalk.white(' hint-c "question" ')+chalk.gray("Level C β€” Critical assist (2 uses)")),console.log(chalk.white(" hint budget ")+chalk.gray("Check remaining uses")),console.log(chalk.white(" ai4ctf ")+chalk.gray("Free-chat with AI (no limit)")),console.log(),console.log(chalk.bold.white(" Tools")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference (linux, web, crypto...)")),console.log(chalk.white(" shell ")+chalk.gray("Docker sandbox")),console.log(chalk.white(" files <id> ")+chalk.gray("Download challenge files")),console.log(chalk.white(" connect <id> ")+chalk.gray("Connect to remote target")),console.log(chalk.white(" note [text] ")+chalk.gray("Add a logbook entry (in-exam: tags current Q)")),console.log(chalk.white(" logbook [n] ")+chalk.gray("View your logbook (in-exam: filter by Q)")),console.log(chalk.white(" log ")+chalk.gray("Session history")),console.log(chalk.white(" man / manual ")+chalk.gray("Show this command list (works in exam too, does not burn elimination)")),console.log(),console.log(chalk.bold.white(" System")),console.log(chalk.white(" setup ")+chalk.gray("Configure settings")),console.log(chalk.white(" lang [code] ")+chalk.gray("Switch language (15 supported)")),console.log(chalk.white(" logout ")+chalk.gray("Disconnect")),console.log(chalk.white(" clear ")+chalk.gray("Clear screen")),console.log(chalk.white(" exit ")+chalk.gray("Quit (session saved)")),void console.log()):(console.log(chalk.bold.yellow(" Restricted Mode β€” activate with a token to unlock all commands")),console.log(),console.log(chalk.white(" activate <token> ")+chalk.gray("Unlock full access")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference")),console.log(chalk.white(" exit ")+chalk.gray("Quit")),void console.log())}
1
+ import{createInterface as o}from"node:readline";import{spawn as e,execSync as l}from"node:child_process";import chalk from"chalk";import{isConnected as n,getConfig as t,saveConfig as a}from"./lib/config.js";import{isActivated as s,activateToken as r,isFreeCommand as i,isDeviceMatch as c,recordExit as g,recordResume as y,isFirstRunOrUpgrade as m,markVersionSeen as d}from"./lib/access.js";import{setReplMode as p}from"./lib/ui.js";import{returnToMainMenu as u,printMenuHint as h,menuHintInline as w}from"./lib/menu-nav.js";import{setMainRl as f}from"./lib/main-rl.js";import{isChatActive as b,handleChatMessage as x}from"./commands/ai4ctf.js";import{isCtf4aiActive as v,handleCtf4aiMessage as A}from"./commands/ctf4ai-demo.js";import{isCtf4VlaActive as C,handleCtf4VlaMessage as I}from"./commands/ctf4vla.js";import{isDemo2Active as k}from"./commands/demo2.js";import{loadDemo2Progress as T}from"./lib/demo2-progress.js";import{hasAnySimHistory as E,lastArmAt as S,lastBundledAt as $,lastSimAt as O}from"./lib/sim-cooldown.js";import{getExamState as D,getRealExamState as L,getDemoState as R}from"./lib/exam-state.js";import{resetTerminalTheme as P}from"./lib/theme.js";import{ensureSandbox as j,runInSandbox as N,isDockerAvailable as q}from"./lib/sandbox.js";import{checkShellRisk as F,logShellAudit as M,getActiveCwd as B}from"./lib/exam-sandbox.js";import{logCommand as _}from"./lib/logger.js";import{startLogSync as U,stopLogSync as Q}from"./lib/log-sync.js";import{existsSync as W,mkdirSync as X,writeFileSync as Y}from"node:fs";import{join as z}from"node:path";import{homedir as V}from"node:os";const G=Date.now();function J(){return L()?chalk.cyan("icoa exam> "):function(){const o=R();return!(!o||"demo-free"!==o.session?.examId)&&new Date(o.session.startedAt||0).getTime()>=G}()?chalk.yellow("icoa demo> "):chalk.green("icoa> ")}const H=z(V(),"icoa-workspace"),K=new Set(["sudo","su","doas","pkexec","brew","apt","apt-get","yum","choco","npm","npx","pip","pip3","shutdown","reboot","halt","mkfs","fdisk","dd","iptables","ufw"]),Z="__REPL_NO_EXIT__",oo="2.5.1";function eo(){console.log(),console.log(` ${chalk.cyan.bold("🎯 ICOA 2026 Β· National Selection")}`),console.log(),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("ACxxxxxxxx")+chalk.gray(" β†’ ai4ctf-12 (AI as your CTF teammate)")),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("CAxxxxxxxx")+chalk.gray(" β†’ ctf4ai-12 (red-team software AI)")),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("EAxxxxxxxx")+chalk.gray(" β†’ ctf4eai-12 (red-team embodied AI)")),console.log(" "+chalk.bold.cyan("exam ")+chalk.white("<CC>xxxxxxxx")+chalk.gray(" β†’ Paper A/B/C/D/E (country exam token)")),console.log(" "+chalk.bold.cyan("demo")+chalk.gray(" β†’ free practice")),console.log(" "+chalk.bold.cyan("lang")+chalk.white(" es")+chalk.gray(" β†’ switch language")),console.log(" "+chalk.gray("help Β· menu Β· quit")),console.log()}export async function startRepl(e,R){process.env.ICOA_INSIDE_REPL="1";const G=t(),to=n(),ao=process.exit.bind(process),so=s();if(G.demoCleanedForVersion!==oo){try{const{existsSync:o,unlinkSync:e}=await import("node:fs"),{join:l}=await import("node:path"),{getIcoaDir:n}=await import("./lib/config.js"),t=l(n(),"demo-state.json");o(t)&&e(t)}catch{}a({demoCleanedForVersion:oo})}const{select:ro,confirm:io}=await import("@inquirer/prompts"),co=G.mode||"",go=""===co?"instant":["instant","learn","selection","olympiad"].includes(co)?co:"selection",yo=[{name:` ${chalk.bold("⚑ Try ICOA in 30 seconds")} ${chalk.gray("β€”")} ${chalk.gray("watch Β· no token needed")}`,value:"instant"},{name:` ${chalk.bold("🧠 Learn")} ${chalk.gray("β€”")} ${chalk.gray("AC / CA / EA token Β· skill up")}`,value:"learn"},{name:` ${chalk.bold("🎯 National Selection")} ${chalk.gray("β€”")} ${chalk.gray("country exam token Β· aim for finals")}`,value:"selection"},{name:` ${chalk.bold("πŸ† International Olympiad")} ${chalk.gray("β€”")} ${chalk.gray("finals stage Β· Sydney 2026 Β· full sandbox")}`,value:"olympiad"},{name:` ${chalk.gray("ℹ️ About ICOA")} ${chalk.gray("Β·")} ${chalk.gray("what this is Β· how to join")}`,value:"about"}];console.log(chalk.gray(" Type ")+chalk.bold.cyan("menu")+chalk.gray(" from anywhere to return here.")),console.log();let mo="";for(;!mo;){let o;try{o=await ro({message:"Mode",choices:yo,default:go||"instant"})}catch(o){throw o instanceof Error&&"ExitPromptError"===o.name&&(console.log(),console.log(chalk.gray(" Goodbye.")),process.exit(0)),o}"about"!==o?mo=o:(console.clear(),console.log(),console.log(chalk.cyan(" ═══════════════════════════════════════════════════")),console.log(chalk.bold.yellow(" ICOA")+chalk.white(" β€” AI-Native CLI OS for Cyber & AI Security")),console.log(chalk.gray(" Olympiad & Competition Β· K-12 to University")),console.log(chalk.cyan(" ───────────────────────────────────────────────────")),console.log(),console.log(chalk.bold.white(" What Makes ICOA Different")),console.log(chalk.gray(" Β· AI-native AI teammate, AI adversary, AI translation")),console.log(chalk.gray(" Β· CLI OS Complete competition environment in terminal")),console.log(chalk.gray(" Β· 110 tools pwntools, z3, gdb, nmap, sleuthkit... pre-configured")),console.log(chalk.gray(" Β· Global scale 15,000+ concurrent exams Β· 15 languages")),console.log(),console.log(chalk.bold.white(" Competition Format (2-day standard + 1-day Pioneer)")),console.log(` ${chalk.green.bold("AI4CTF")}${chalk.gray(" [Day 1] AI as teammate β€” speed track, dynamic decay + top-3 bonus")}`),console.log(` ${chalk.red.bold("CTF4AI")}${chalk.gray(" [Day 2] AI as target β€” knowledge track, static value per challenge")}`),console.log(` ${chalk.cyan.bold("CTF4EAI")}${chalk.gray(" [Pioneer / Practical Round] Embodied AI β€” VLA + world models + sim-to-real")}`),console.log(),console.log(chalk.bold.white(" Scoring (in brief)")),console.log(chalk.gray(" Β· Standard medals: AI4CTF + CTF4AI combined Β· 1/12 Gold Β· 2/12 Silver Β· 3/12 Bronze")),console.log(chalk.gray(" Β· HMA: top 50% on either day, total below bronze cutoff")),console.log(chalk.gray(" Β· CTF4EAI: separate 15-finalist pool, G/S/B + 12 Finalist Awards")),console.log(),console.log(chalk.white(" Sydney, Australia")+chalk.gray(" Β· Jun 27 - Jul 2, 2026")),console.log(),console.log(chalk.bold.white(" Organized by")+chalk.gray(" ASRA (Australia) Β· ICO Foundation Inc")),console.log(chalk.bold.white(" Contact ")+chalk.cyan(" australia@icoa2026.au Β· accreditation@icoa2026.au")),console.log(chalk.bold.white(" Website ")+chalk.cyan.underline(" https://icoa2026.au")),console.log(chalk.cyan(" ═══════════════════════════════════════════════════")),console.log(),console.log(chalk.gray(" Press ")+chalk.yellow("Enter")+chalk.gray(" to return...")),await new Promise(o=>{const e=l=>{process.stdin.removeListener("data",e),process.stdin.isTTY&&process.stdin.setRawMode&&process.stdin.setRawMode(!1),process.stdin.pause(),o()};process.stdin.isTTY&&process.stdin.setRawMode&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.once("data",e)}),console.clear())}if("olympiad"===mo&&"olympiad"!==go){console.log(),console.log(chalk.yellow(" This mode will download ~500MB of CTF tools and AI models."));let o=!0;try{o=await io({message:"Continue?",default:!0})}catch(e){if(!(e instanceof Error&&"ExitPromptError"===e.name))throw e;o=!1}o||(mo="selection",console.log(chalk.gray(" Switched to National Selection mode.")))}if(mo!==go&&a({mode:mo}),console.log(),"olympiad"===mo&&m(oo)){d(oo),console.log(chalk.gray(" Checking competition environment..."));const{execSync:o}=await import("node:child_process"),e=[{name:"pwntools",cmd:'python3 -c "import pwn"'},{name:"z3-solver",cmd:'python3 -c "import z3"'},{name:"numpy",cmd:'python3 -c "import numpy"'},{name:"requests",cmd:'python3 -c "import requests"'}];let l=0;for(const n of e)try{o(n.cmd,{stdio:"ignore"})}catch{l++}if(l>0){console.log(chalk.yellow(` ${l} core libraries missing.`));try{const{confirm:o}=await import("@inquirer/prompts");if(await o({message:" Install competition Python libraries now?",default:!0,theme:{prefix:"",style:{message:o=>chalk.green(o),defaultAnswer:o=>chalk.green(o)}}})){console.log();const{execSync:o}=await import("node:child_process");o("icoa env setup",{stdio:"inherit"})}}catch{console.log(chalk.gray(" Run ")+chalk.white("env setup")+chalk.gray(" later to install."))}console.log()}else console.log(chalk.green(" All core libraries ready.")),console.log()}if(R){const o=y();if(o){const e=Math.floor(o.awaySeconds/60),l=o.awaySeconds%60;console.log(chalk.yellow(` Session resumed. Away: ${e}m ${l}s | Total exits: ${o.exitCount}`)),console.log()}}if("selection"===mo)console.log(chalk.gray(" ─── exam hall Β· 90 min per paper once started Β· no pause ───")),console.log(),eo();else if("embodied"===mo)!function(){console.log(chalk.cyan.bold(" [πŸ€– ctf4eai β€” Embodied AI Security]")),console.log(),console.log(chalk.bold.cyan(" CTF4VLA")+chalk.gray(" β€” ICOA 2026's ")+chalk.bold.white("Pioneer Round")),console.log(chalk.gray(" an independent parallel track alongside the scored main events: ")+chalk.green("AI4CTF")+chalk.gray(" (Day 1) and ")+chalk.red("CTF4AI")+chalk.gray(" (Day 2)")),console.log(),console.log(chalk.white(" Embodied AI is at its ImageNet moment.")),console.log(chalk.gray(" VLA models, MuJoCo physics, real robot arms.")),console.log(chalk.gray(" Real models, real physics, real attack surfaces.")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const o=$()>0||O()>0,e=S()>0,l=E(),n=T(),t=null!==n&&"number"==typeof n.completedAt&&n.nextCardIndex>=n.totalCards,a=null!==n&&!t;if(t)console.log(chalk.bold.yellow(" Continue: ")+chalk.bold.cyan("β‘£ learn LEARNDEMO01")+chalk.gray(" (demo2 βœ“ Β· sim")+(e?chalk.gray(" βœ“ Β· sim arm βœ“)"):chalk.gray(")")));else if(a){const o=`${n.nextCardIndex} / ${n.totalCards}`;console.log(chalk.bold.yellow(" Continue: ")+chalk.bold.cyan("β‘’ demo2")+chalk.gray(" (last left at card ")+chalk.bold.yellow(o)+chalk.gray(")"))}else o&&e?console.log(chalk.bold.yellow(" Next up: ")+chalk.bold.cyan("β‘’ demo2")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘£ learn LEARNDEMO01")+chalk.gray(" (sim βœ“ Β· sim arm βœ“)")):l?console.log(chalk.bold.yellow(" Next up: ")+(e?chalk.bold.cyan("β‘  sim")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘’ demo2"):chalk.bold.cyan("β‘‘ sim arm")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘’ demo2"))+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘£ learn LEARNDEMO01")):console.log(chalk.bold.yellow(" First time? Try in order: ")+chalk.bold.cyan("β‘  sim")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘‘ sim arm")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘’ demo2")+chalk.gray(" β†’ ")+chalk.bold.cyan("β‘£ learn LEARNDEMO01"));console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.bold.green(" sim")+chalk.gray(" ")+chalk.bold.cyan("β‘ ")+chalk.gray(" ")+chalk.bold.yellow("β˜… INSTANT")+chalk.gray(" β€” 8-robot group dance, no wait, no setup")),console.log(chalk.bold.green(" sim arm")+chalk.gray(" ")+chalk.bold.cyan("β‘‘")+chalk.gray(" interactive 6-DOF arm sandbox β€” type joint values, watch")),console.log(chalk.bold.green(" demo2")+chalk.gray(" ")+chalk.bold.cyan("β‘’")+chalk.gray(" ~8 min interactive intro + live MuJoCo sim")),console.log(chalk.bold.green(" learn LEARNDEMO01")+chalk.gray(" ")+chalk.bold.cyan("β‘£")+chalk.gray(" free 11-card intro (paste this command as-is)")),console.log(chalk.bold.green(" learn ")+chalk.bold.yellow("EA")+chalk.gray(" + 8 chars full 96 / 360 curriculum (team-issued)")),console.log(chalk.bold.green(" exam ")+chalk.bold.yellow("PDxxxxxxxx")+chalk.gray(" Paper D (CTF4VLA) β€” national selection contestants")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(),console.log(chalk.gray(" Three open tiers: ")+chalk.green("free 11")+chalk.gray(" Β· ")+chalk.yellow("registered 100")+chalk.gray(" Β· ")+chalk.bold.magenta("national team 480")+chalk.gray(" (PhD-ready)")),console.log(chalk.gray(" Country team contact: ")+chalk.cyan("australia@icoa2026.au")),console.log(),h(),console.log()}();else{if("instant"===mo){console.log(chalk.cyan.bold(" [⚑ Try ICOA in 30 seconds β€” no token needed]")),console.log(),console.log(chalk.gray(" Pick what you want to see first:")),console.log();const o=[{name:` ${chalk.bold.green("β˜… demo ")} ${chalk.gray("Paper A/B/C taste β€” MCQ + ai4ctf + ctf4ai ")}`+chalk.bold.cyan("🎯 selection-style"),value:"demo"},{name:` ${chalk.bold.green("β˜… demo2 ")} ${chalk.gray("15-sec countdown render Β· bundled & offline ")}`+chalk.bold.yellow("⚑ visual wow"),value:"demo2"},{name:` ${chalk.gray("↩ back to main menu")}`,value:"menu"}];let l="menu";try{l=await ro({message:"Pick",choices:o,default:"demo"})}catch{}if("menu"!==l){console.log();const o="demo2"===l?["sim"]:["exam","demo"];try{await e.parseAsync(["node","icoa",...o])}catch{}}return a({mode:"selection"}),void u()}if("learn"===mo){console.log(chalk.cyan.bold(" [🧠 Learn]")),console.log(),console.log(chalk.gray(" Three tracks Β· same difficulty curve.")),console.log(),console.log(chalk.white(" Free 12-card demos β€” paste the full command:")),console.log(),console.log(chalk.gray(" 🀝 ai4ctf AI as your teammate ")+chalk.bold.yellow("learn AI4CTFDEMO01")),console.log(chalk.gray(" πŸ”“ ctf4ai AI as your target ")+chalk.bold.yellow("learn CTF4AIDEMO01")),console.log(chalk.gray(" πŸ€– ctf4eai Embodied AI Security ")+chalk.bold.yellow("learn LEARNDEMO01")),console.log(),console.log(chalk.gray(" Got a cohort token? Type ")+chalk.bold.yellow("learn <TOKEN>")+chalk.gray(" (e.g. ")+chalk.bold.yellow("learn EAABCD1234")+chalk.gray(").")),console.log();try{const{input:o}=await import("@inquirer/prompts"),{resolveLearnInput:l}=await import("./lib/learn-input.js");console.log(chalk.gray(" Enter a token (or just press Enter to go back).")),console.log();const n=l(await o({message:chalk.bold.cyan("icoa learn>"),theme:{prefix:"",style:{message:o=>o}}}));if("token"===n.kind){console.log(),console.log(chalk.gray(" Opening ")+chalk.bold.cyan("learn")+chalk.gray(`: ${n.token}`)),console.log(),a({mode:"selection"}),process.env.ICOA_LEARN_EMBEDDED="1";try{await e.parseAsync(["node","icoa","learn",n.token])}finally{delete process.env.ICOA_LEARN_EMBEDDED}}else"ambiguous"!==n.kind&&"unknown"!==n.kind||(console.log(),console.log(chalk.yellow(" "+n.hint)),console.log(chalk.gray(" Returning to main menu β€” pick 🧠 Learn again to retry.")),console.log())}catch{}return a({mode:"selection"}),void u()}"organizer"===mo?(console.log(chalk.yellow.bold(" [National/Regional Partner]")),console.log(),console.log(chalk.bold.white(" β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—")),console.log(chalk.bold.white(" β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—")),console.log(chalk.bold.white(" β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘")),console.log(chalk.bold.white(" β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘")),console.log(chalk.bold.white(" β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β–ˆβ–ˆβ•‘")),console.log(chalk.bold.white(" β•šβ•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β• β•šβ•β•")),console.log(),console.log(chalk.yellow(" International Cyber Olympiad in AI 2026")),console.log(chalk.bold.magenta(" The World's First AI-Native CLI Operating System")),console.log(chalk.bold.magenta(" for Cybersecurity & AI Security Competition")),console.log(chalk.bold.magenta(" and Olympiad for K-12")),console.log(chalk.gray(" Sydney, Australia Β· Jun 27 - Jul 2, 2026")),console.log(),console.log(chalk.white(" Vision")),console.log(chalk.gray(" Building a global pipeline for youth cyber & AI")),console.log(chalk.gray(" security talent through education and competition.")),console.log(),console.log(chalk.white(" Capacity")),console.log(chalk.gray(" 15,000+ concurrent online examinations")),console.log(chalk.gray(" National selection, training, and education support")),console.log(),console.log(chalk.white(" Olympic Spirit")),console.log(chalk.gray(" Excellence Β· Friendship Β· Respect")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" New country accreditation & support:")),console.log(chalk.cyan(" australia@icoa2026.au")),console.log(chalk.cyan(" accreditation@icoa2026.au")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(),to?(console.log(chalk.green(` Logged in as ${G.userName}`)),console.log(chalk.white(" exam list")+chalk.gray(" Manage exams")),console.log(chalk.white(" logout")+chalk.gray(" Disconnect"))):console.log(chalk.white(" join <url>")+chalk.gray(" Connect to manage exams")),console.log(),h(),console.log()):(console.log(` ${chalk.cyan.bold("πŸ† ICOA 2026 Β· International Olympiad")}`),console.log(),so&&!c()?(console.log(chalk.red(" Token was activated on a different device.")),console.log(chalk.gray(" Contact organizer for assistance.")),console.log()):to?(console.log(chalk.green.bold(` Welcome back, ${G.userName}!`)),console.log(chalk.gray(` Connected to ${G.ctfdUrl}`)),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" Ready to compete? Start here:")),console.log(),console.log(chalk.bold.cyan(" challenges")+chalk.gray(" Browse challenges by category")),console.log(chalk.white(" status")+chalk.gray(" Your score & hint budget")),console.log(chalk.white(" scoreboard")+chalk.gray(" Live rankings")),console.log(chalk.white(" help")+chalk.gray(" Full command list")),console.log(),console.log(chalk.gray(" Tool environment:")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("help")+chalk.gray(" Β· ")+w()+chalk.gray(" Β· ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses Β· ")+chalk.cyan("quit")+chalk.gray(" closes")),console.log()):so?(W(H)||X(H,{recursive:!0}),console.log(chalk.green.bold(" Welcome, competitor!")),console.log(chalk.gray(` Workspace: ${H}`)),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" Get started:")),console.log(),console.log(chalk.white(" Step 1 ")+chalk.bold.cyan("join <url>")+chalk.gray(" Connect to competition server")),console.log(chalk.white(" Step 2 ")+chalk.bold.cyan("challenges")+chalk.gray(" Browse & solve challenges")),console.log(chalk.white(" Step 3 ")+chalk.bold.cyan("ai4ctf")+chalk.gray(" Ask AI when stuck")),console.log(),console.log(chalk.gray(" Before Step 1 β€” make sure your tools are ready:")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(),console.log(chalk.gray(" Also: ")+chalk.white("help")+chalk.gray(" all commands")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses Β· ")+w()+chalk.gray(" Β· ")+chalk.cyan("quit")+chalk.gray(" closes CLI")),console.log()):(console.log(chalk.bold.yellow(" πŸ† You reached the finals tier.")),console.log(chalk.gray(" Full sandbox Β· 110 CTF tools Β· Sydney 2026 Β· this is where finalists compete.")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" To begin, activate your competition token:")),console.log(),console.log(chalk.bold.cyan(" activate <token>")),console.log(),console.log(chalk.gray(" While waiting, explore:")),console.log(chalk.white(" ref linux")+chalk.gray(" Quick reference for Linux")),console.log(chalk.white(" ref web")+chalk.gray(" Quick reference for Web")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(chalk.white(" help")+chalk.gray(" All available commands")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses Β· ")+w()+chalk.gray(" Β· ")+chalk.cyan("quit")+chalk.gray(" closes CLI")),console.log()))}e.exitOverride(),e.configureOutput({writeErr:()=>{},writeOut:o=>{console.log(o)}});const po=o({input:process.stdin,output:process.stdout,prompt:J(),terminal:!0});f(po);let uo=!1;p(!0),U();const ho=po.prompt.bind(po);po.prompt=o=>{b()||v()||C()||k()||po.setPrompt(J()),ho(o)},po.prompt(),po.on("line",async o=>{if(uo)return;const n=o.trim();if(!n)return po.setPrompt(b()?chalk.magenta("icoa ai4ctf> "):J()),void po.prompt();if("menu"===n||"menu confirm"===n)return L()&&"menu confirm"!==n?(console.log(),console.log(chalk.yellow(" Real exam active. Progress is auto-saved.")),console.log(chalk.gray(" To return to main menu anyway, type ")+chalk.white("menu confirm")),console.log(),void po.prompt()):void u(po);if(b()){uo=!0;const o=await x(n);return uo=!1,"exit"===o&&po.setPrompt(J()),void po.prompt()}if(v()){uo=!0;const o=await A(n);return uo=!1,"exit"!==o&&"solved"!==o||po.setPrompt(J()),void po.prompt()}if(C()){uo=!0;const o=await I(n);return uo=!1,"exit"===o&&po.setPrompt(J()),po.setPrompt(C()?chalk.bold.cyan("icoa ctf4vla> "):J()),void po.prompt()}if(_(n),"exit"===n)return D()?(console.log(),console.log(chalk.yellow(" ⚠ An exam is in progress.")),console.log(chalk.white(" To return to menu without losing progress, type: ")+chalk.bold.cyan("back")),console.log(chalk.white(" To fully close ICOA CLI, type: ")+chalk.bold.cyan("quit")),console.log(chalk.gray(" Your progress is auto-saved either way.")),console.log(),void po.prompt()):(console.log(),console.log(chalk.gray(" ")+chalk.white("exit")+chalk.gray(" returns to the main menu. To fully close ICOA CLI, type ")+chalk.bold.cyan("quit")+chalk.gray(".")),"selection"===mo&&eo(),void po.prompt());if("quit"===n||"q"===n||"quit confirm"===n){const o=D();return o&&"demo-free"!==o.session.examId&&"quit confirm"!==n?(console.log(),console.log(chalk.yellow(" ⚠ A real exam is in progress.")),console.log(chalk.gray(" Your answers are auto-saved on the server, but the exam timer keeps ticking")),console.log(chalk.gray(" on the server side even if you close the CLI.")),console.log(),console.log(chalk.white(" To leave the CLI but keep the exam alive, type: ")+chalk.bold.cyan("back")),console.log(chalk.gray(" (recommended β€” you can resume with ")+chalk.cyan("exam q 1")+chalk.gray(" after relaunching icoa)")),console.log(),console.log(chalk.white(" To really close ICOA CLI, type: ")+chalk.bold.cyan("quit confirm")),console.log(),void po.prompt()):(o&&"demo-free"===o.session.examId&&(console.log(),console.log(chalk.gray(" Demo paused. Resume with: ")+chalk.white("demo")+chalk.gray(" (fresh) or ")+chalk.white("exam q 1")+chalk.gray(" (continue)."))),Q(),g(),console.log(chalk.gray(" Session saved. Use ")+chalk.white("icoa --resume")+chalk.gray(" to continue.")),P(),void ao(0))}if("back"===n){const o=D(),e=o&&"demo-free"!==o.session.examId,l=o&&"demo-free"===o.session.examId&&(()=>{const e=new Date(o.session.startedAt||0).getTime();return Date.now()-e<18e5})();if(e)console.log(),console.log(chalk.gray(" Exam paused. Your progress is saved.")),console.log(chalk.white(" Resume: exam q 1")+chalk.gray(" Β· ")+chalk.white("exam review")+chalk.gray(" Β· ")+chalk.white("exam submit")),console.log();else if(l){const e=Object.keys(o.answers).length,l=o.session.questionCount;console.log(),console.log(chalk.gray(` Demo paused (${e}/${l} answered). Resume with: `)+chalk.white("exam q 1")),console.log(chalk.gray(" Or type ")+chalk.white("demo")+chalk.gray(" to restart.")),console.log()}else{if(o&&"demo-free"===o.session.examId){const{clearExamState:o}=await import("./lib/exam-state.js");o("demo-free")}const e=t();fetch("https://practice.icoa2026.au/api/icoa/demo-stats",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"post-report-back",lang:e.language||"en",timestamp:(new Date).toISOString()}),signal:AbortSignal.timeout(5e3)}).catch(()=>{}),"selection"===mo?eo():console.log(chalk.gray(" Already at main menu."))}return void po.prompt()}if("help"===n||"?"===n){if(D()){uo=!0;try{await e.parseAsync(["node","icoa","exam","help"])}catch{}return uo=!1,void po.prompt()}return no(s(),mo),void po.prompt()}if("man"===n||"manual"===n)return no(s(),mo),void po.prompt();if("more help"===n.toLowerCase()&&D()){uo=!0;try{await e.parseAsync(["node","icoa","exam","more-help"])}catch{}return uo=!1,void po.prompt()}if("continue"===n.toLowerCase())return console.log(),console.log(chalk.green.bold(" ═══ AI4CTF β€” AI as Your Teammate ═══")),console.log(),console.log(chalk.white(" In AI4CTF, you solve cybersecurity challenges")),console.log(chalk.white(" with AI by your side.")),console.log(),console.log(chalk.white(" In competition, you get AI help at 3 levels:")),console.log(chalk.yellow(" hint a")+chalk.gray(" General guidance (50 uses)")),console.log(chalk.yellow(" hint b")+chalk.gray(" Deep analysis (10 uses)")),console.log(chalk.yellow(" hint c")+chalk.gray(" Critical assist (2 uses)")),console.log(),console.log(chalk.white(" Try it now! Type: ")+chalk.bold.green("ai4ctf")),console.log(chalk.gray(' Chat freely with your AI teammate. Type "exit" when done.')),console.log(),console.log(chalk.gray(" After ai4ctf, try: ")+chalk.bold.red("ctf4ai")+chalk.gray(' β€” trick the AI into saying "koala"')),console.log(),void po.prompt();if(/^ICOA-[A-Z]{2,3}-\d{1,6}$/i.test(n.trim())){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",n.trim()])}catch{}return uo=!1,void po.prompt()}if(/^[A-Z]{2}[0-9A-HJKMNP-TV-Z]{8}$/i.test(n.trim())){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",n.trim().toUpperCase()])}catch{}return uo=!1,void po.prompt()}const a=n.match(/^exam\s+([A-Z]{2}[0-9A-HJKMNP-TV-Z]{8})$/i);if(a){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",a[1].toUpperCase()])}catch{}return uo=!1,void po.prompt()}const y=n.match(/^exam\s+([A-Z]{2,3})$/i);if(y){uo=!0;try{await e.parseAsync(["node","icoa","exam","list",y[1]])}catch{}return uo=!1,void po.prompt()}if("clear"===n||"cls"===n)return console.clear(),void po.prompt();if(n.startsWith("activate ")){const o=n.slice(9).trim(),e=r(o);return"ok"===e?console.log(chalk.green(" Access granted! Token bound to this device.")):"already_bound"===e?(console.log(),console.log(chalk.red(" Token already activated on a different device.")),console.log(chalk.gray(" Each token binds to the first device that uses it. If you lost the device,")),console.log(chalk.gray(" contact your proctor to have the token re-issued for a new device."))):(console.log(),console.log(chalk.red(" Token not recognized.")),console.log(chalk.gray(" Possible reasons:")),console.log(chalk.white(" β€’ ")+chalk.gray("Typo β€” access tokens are case-insensitive and look like ")+chalk.cyan("ICOA-XXXX-XXXX-XXXX")+chalk.gray(" (4-char hex groups, e.g. ICOA-385E-27F2-B21B)")),console.log(chalk.white(" β€’ ")+chalk.gray("Expired β€” ask your proctor or organizer for a fresh token")),console.log(chalk.white(" β€’ ")+chalk.gray("Network β€” verify connection to ")+chalk.cyan("practice.icoa2026.au")),console.log(chalk.gray(" Still stuck? type ")+chalk.cyan("help")+chalk.gray(" or try ")+chalk.cyan("exam demo")+chalk.gray(" for a free practice round."))),console.log(),void po.prompt()}if("activate"===n)return console.log(chalk.gray(" Usage: ")+chalk.white("activate <token>")),console.log(),void po.prompt();const m=D();if(m){const o=n.toUpperCase().trim(),l=o=>{const e=m.questions.find(e=>e.number===o);return!!e&&("ai4ctf"===e.type||"ctf4ai"===e.type||e.options&&!e.options.A&&!e.options.B)},t=o=>{const e="demo-free"!==m.session.examId,l=e&&o>=39?"ctf4ai":e&&o>=31?"ai4ctf":null;console.log(),console.log(chalk.yellow(` Q${o} is a practical question β€” letters (A/B/C/D) don't apply here.`)),l?(console.log(chalk.white(" Enter the AI chat for this question: ")+chalk.bold.cyan(l)),console.log(chalk.gray(" Or submit a flag directly: ")+chalk.green(`exam answer ${o} ICOA{your_flag}`))):console.log(chalk.gray(" Submit a flag: ")+chalk.green(`exam answer ${o} ICOA{your_flag}`)),console.log()};if(/^[ABCD]$/.test(o)){const n=m._lastQ||1;if(l(n))return t(n),void po.prompt();uo=!0;try{await e.parseAsync(["node","icoa","exam","answer",String(n),o])}catch{}return uo=!1,void po.prompt()}const a=o.match(/^(\d+)\s+([ABCD])$/);if(a){const o=parseInt(a[1],10);if(l(o))return t(o),void po.prompt();uo=!0;try{await e.parseAsync(["node","icoa","exam","answer",a[1],a[2]])}catch{}return uo=!1,void po.prompt()}}const d=n.split(/\s+/)[0].toLowerCase(),p=/^python3?(\.\d+)?$/.test(d),h="ls"===d||"pwd"===d,w=n.startsWith("!")||d.startsWith("!")||p||h,f=new Set(["nano","vi","vim","emacs","pico","ed","code","cat","less","more","head","tail","ls","pwd","cd","base64","xxd","hexdump","od","openssl","md5sum","sha256sum","grep","find","awk","sed","strings","file","curl","wget","nc","ping","nmap","echo","bash","sh","zsh","pip","pip3","node","npm"]),k=()=>{console.log(chalk.gray(" Shell commands need ")+chalk.bold.cyan("!")+chalk.gray(" prefix. Try: ")+chalk.bold.cyan(`!${n}`)),console.log()};if("embodied"===mo&&!w&&!["demo2","learn","exam","ctf4vla","lang","ref","setup","env","sim"].includes(d))return f.has(d)?(k(),void po.prompt()):(console.log(chalk.gray(" Not available in Embodied AI Security mode.")),console.log(chalk.white(" Try ")+chalk.bold.cyan("demo2")+chalk.gray(" (intro) Β· ")+chalk.bold.cyan("learn")+chalk.gray(" (curriculum) Β· ")+chalk.bold.cyan("exam <PD-token>")+chalk.gray(" (Paper D)")),console.log(),void po.prompt());if("selection"===mo&&!w&&!["exam","demo","retry","nations","next","prev","continue","setup","lang","ref","ai4ctf","ctf4ai","mark","unmark","review","submit","env","sim"].includes(d)){if(f.has(d))return k(),void po.prompt();if(console.log(chalk.gray(" Not available in Selection mode.")),m){const o=m._lastQ||1;console.log(chalk.white(` Resume exam: exam q ${o}`)+chalk.gray(" Β· ")+chalk.white("A/B/C/D")+chalk.gray(" to answer"))}else console.log(chalk.gray(" Try: demo Β· setup to switch mode"));return console.log(),void po.prompt()}if("organizer"===mo&&!["join","exam","demo","retry","next","prev","logout","setup","lang","ref","ctf","mark","unmark","review","submit"].includes(d))return console.log(chalk.gray(" Not available in Organizer mode. Switch via: setup")),console.log(),void po.prompt();if(!("olympiad"!==mo||s()&&c()||i(d)))return console.log(chalk.yellow(" Restricted mode. ")+chalk.gray("Enter your access token:")),console.log(chalk.white(" activate <token>")),console.log(),console.log(chalk.gray(" Free commands: ")+chalk.white("ref [topic]")+chalk.gray(", ")+chalk.white("help")+chalk.gray(", ")+chalk.white("exit")),console.log(),void po.prompt();if(!["join","activate","challenges","ch","open","submit","flag","scoreboard","sb","status","time","ref","shell","files","connect","note","notes","logbook","log","man","manual","lang","setup","env","ai4ctf","model","ctf","exam","demo","retry","nations","next","prev","continue","logout","ctf4ai","mark","unmark","review","submit","learn","demo2","ctf4vla","theme","sim"].includes(d)){if(K.has(d))return console.log(chalk.yellow(` "${d}" is a shell command β€” the ICOA prompt isn't a shell.`)),console.log(chalk.gray(" In real-exam mode, prefix with ! to run inside the sandbox: ")+chalk.cyan(`!${n}`)),console.log(),void po.prompt();if(/(?:^|\s)(?:\/(?!home\/|Users\/|tmp\/)|\.\.\/|~\/)/.test(n)&&!n.startsWith("cd ")){const o=/(?:^|\s)\/(?!home\/\w+\/icoa-workspace|Users\/\w+\/icoa-workspace|tmp\/)/.test(n),e=/\.\./.test(n);if(o||e)return console.log(chalk.red(" Blocked: access outside workspace is not allowed.")),console.log(chalk.gray(` Workspace: ${H}`)),console.log(),void po.prompt()}let o=n.startsWith("!")?n.slice(1).trim():n;if("darwin"===process.platform){const e="/opt/homebrew/opt/python@3.12/bin/python3.12";o=o.replace(/^python3?\s/,`${e} `).replace(/^(python3|python)$/,e)}else if("win32"===process.platform){const e=(()=>{try{return l("py -3 --version",{stdio:["ignore","ignore","ignore"],timeout:1500}),"py -3"}catch{}return"python"})();o=o.replace(/^python3?(\.\d+)?\s/,`${e} `).replace(/^python3?(\.\d+)?$/,e)}else{const e=(()=>{try{return l("which python3.12",{stdio:"ignore"}),"python3.12"}catch{return"python3"}})();o=o.replace(/^python\s/,`${e} `).replace(/^python$/,e)}const e=B(),t=F(n);M({cwd:e,input:n,riskFlags:t}),t.length>0&&L()&&(console.log(chalk.yellow(` ⚠ Action flagged: ${t.join(", ")} β€” logged.`)),console.log()),/^(\S*python3?(\.\d+)?)\s*$/.test(o)&&(o=`PYTHONSTARTUP="${function(){const o=z(V(),".icoa");W(o)||X(o,{recursive:!0});const e=z(o,"python-startup.py");return W(e)||Y(e,"# ICOA exam interactive startup β€” auto-loaded by PYTHONSTARTUP\nimport base64, struct, hashlib, re, json, os, sys, binascii\ntry: import requests\nexcept ImportError: pass\ntry: from Crypto.Cipher import AES\nexcept ImportError: pass\ntry: from Crypto.Util.Padding import pad, unpad\nexcept ImportError: pass\ntry: from pwn import xor, p32, u32, p64, u64\nexcept ImportError: pass\ntry: import bs4\nexcept ImportError: pass\ntry: import numpy as np\nexcept ImportError: pass\n"),e}()}" ${o}`,console.log(),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log(chalk.bold.white(" Python ready β€” ICOA exam toolkit pre-loaded")),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log(),console.log(chalk.white(" Already imported: ")+chalk.gray("base64, struct, hashlib, re, json, binascii")),console.log(chalk.white(" Also available: ")+chalk.gray("requests, bs4, numpy, AES, pad/unpad, xor, p32/u32/p64/u64")),console.log(),console.log(chalk.yellow(" Quick examples:")),console.log(chalk.gray(' base64.b64decode("aGVsbG8=") ')+chalk.gray("# decode base64")),console.log(chalk.gray(' bytes.fromhex("48656c6c6f") ')+chalk.gray("# hex β†’ bytes")),console.log(chalk.gray(' "ICOA{x}".encode() ')+chalk.gray("# str β†’ bytes")),console.log(chalk.gray(" [chr(c) for c in [73,67,79,65]] ")+chalk.gray("# ASCII codes")),console.log(chalk.gray(' xor(bytes.fromhex("0a2b"), b"IC") ')+chalk.gray("# pwntools XOR")),console.log(),console.log(chalk.gray(" Exit: ")+chalk.white("exit()")+chalk.gray(" or Ctrl-D")),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log()),uo=!0;try{q()&&await j()?await N(o,po):await lo(o,po,e)}catch{console.log(chalk.yellow(` Command failed: ${d}`))}return uo=!1,console.log(),void po.prompt()}uo=!0;const T=n.trim(),E=T.toLowerCase();let S,$=null,O="";if(m)if("submit"===E)$="final";else if(E.startsWith("submit ")){let o=T.slice(7).trim();/^submit\s+/i.test(o)&&(o=o.replace(/^submit\s+/i,"").trim()),o=o.replace(/^["'`]+|["'`]+$/g,"").trim(),o&&/^ICOA\{[^}]*\}?$/i.test(o)&&($="flag",O=o)}else/^ICOA\{[^}]+\}$/i.test(T)&&($="flag",O=T);S="final"===$?["exam","submit"]:"flag"===$?["exam","answer",String(m?._lastQ||1),O]:function(o){const e=o.split(/\s+/),l=e[0].toLowerCase(),n=e.slice(1),t={demo:["exam","demo"],retry:["exam","demo-retry"],nations:["exam","nations"],next:["exam","next"],prev:["exam","prev"],mark:["exam","mark",...n],unmark:["exam","unmark",...n],review:["exam","review"],logout:["ctf","logout"],join:["ctf","join",...n],activate:["ctf","activate",...n],challenges:["ctf","challenges"],ch:["ctf","challenges"],open:["ctf","open",...n],submit:["ctf","submit",...n],flag:["ctf","submit",...n],scoreboard:["ctf","scoreboard",...n],sb:["ctf","scoreboard",...n],status:["ctf","status"],time:["ctf","time"]};return t[l]?t[l]:["ref","shell","files","connect","note","notes","logbook","log","man","manual","lang","setup","env","ai4ctf","model","ctf","exam","ctf4ai"].includes(l)?[l,...n]:e}(n);const R="ctf"===S[0]&&"join"===S[1];R&&po.pause(),process.exit=()=>{throw new Error(Z)};try{await e.parseAsync(["node","icoa",...S])}catch(o){const e=o instanceof Error?o.message:String(o);if(e===Z);else if(e.includes("commander.unknownCommand")){const{distance:o}=await import("fastest-levenshtein"),e=["ctf","ref","shell","files","connect","note","notes","logbook","log","manual","lang","setup","env","ai4ctf","exam","ctf4ai","theme","clear","cls","quit","exit","back","menu","help","continue","activate","demo","challenges","status","scoreboard","join","logout"],l=d.split(/\s+/)[0]||d;let n={word:"",dist:1/0};for(const t of e){const e=o(l.toLowerCase(),t);e<n.dist&&(n={word:t,dist:e})}console.log(chalk.yellow(` Unknown command: ${d}.`)),n.dist>0&&n.dist<=2&&console.log(chalk.gray(" Did you mean: ")+chalk.bold.cyan(n.word)+chalk.gray("?")),console.log(chalk.gray(" Type ")+chalk.cyan("help")+chalk.gray(" for the full command list."))}else e.includes("commander.")||(e.includes("fetch failed")||e.includes("ECONNREFUSED")||e.includes("ETIMEDOUT"))&&console.log(chalk.yellow(" Network error. Check your connection."))}finally{process.exit=ao,uo=!1,R&&po.resume()}b()?po.setPrompt(chalk.magenta("icoa ai4ctf> ")):v()?po.setPrompt(chalk.red("icoa ctf4ai> ")):C()&&po.setPrompt(chalk.bold.cyan("icoa ctf4vla> ")),console.log(),po.prompt()}),po.on("SIGINT",()=>{if(console.log(),b()||v())console.log(chalk.yellow(" Ctrl+C did not close ICOA CLI β€” you are still in the AI chat.")),console.log(chalk.white(" Type ")+chalk.bold.cyan("exit")+chalk.white(" to leave the chat and return to the menu."));else if(D()){const o="demo-free"!==D().session.examId;console.log(chalk.yellow(" Ctrl+C did NOT close ICOA CLI.")),console.log(chalk.gray(` Your ${o?"exam":"demo"} is paused and every answer is auto-saved.`)),console.log(),console.log(chalk.white(" Resume: ")+chalk.cyan("exam q 1")+chalk.gray(" Β· Back to menu: ")+chalk.cyan("back")+chalk.gray(" Β· Close CLI: ")+chalk.cyan(o?"quit confirm":"quit"))}else console.log(chalk.yellow(" Ctrl+C did not close ICOA CLI β€” you are still at the ")+chalk.cyan("icoa>")+chalk.yellow(" prompt.")),console.log(chalk.gray(" Keep typing β€” ")+chalk.cyan("help")+chalk.gray(" lists commands. (Only ")+chalk.cyan("quit")+chalk.gray(" or Ctrl+D actually close the CLI.)"));console.log(),po.prompt()}),po.on("close",()=>{Q(),g(),P(),ao(0)})}function lo(o,l,n){return new Promise(t=>{const a=process.stdin,s=!!a.isTTY&&!!a.isRaw;if(l.pause(),a.isTTY&&"function"==typeof a.setRawMode)try{a.setRawMode(!1)}catch{}const r=e(o,{shell:!0,stdio:"inherit",cwd:n||process.cwd()}),i=()=>{if(a.isTTY&&"function"==typeof a.setRawMode&&s)try{a.setRawMode(!0)}catch{}l.resume(),t()};r.on("close",i),r.on("error",i)})}function no(o,e="olympiad"){return console.log(),"selection"===e||"organizer"===e?(console.log(chalk.bold.white(" Exam")),console.log(chalk.white(" join <url> ")+chalk.gray("Connect to exam server")),console.log(chalk.white(" exam list ")+chalk.gray("Available exams")),console.log(chalk.white(" exam start <id> ")+chalk.gray("Begin an exam")),console.log(chalk.white(" exam q [n] ")+chalk.gray("View questions")),console.log(chalk.white(" exam answer <n> <X> ")+chalk.gray("Answer question")),console.log(chalk.white(" exam review ")+chalk.gray("Review all answers")),console.log(chalk.white(" exam submit ")+chalk.gray("Submit for grading")),console.log(chalk.white(" exam result ")+chalk.gray("View your score")),console.log(),console.log(chalk.bold.white(" System")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference")),console.log(chalk.white(" setup ")+chalk.gray("Settings / switch mode")),console.log(chalk.white(" lang [code] ")+chalk.gray("Switch language")),console.log(chalk.white(" clear ")+chalk.gray("Clear screen")),console.log(chalk.white(" exit ")+chalk.gray("Quit")),void console.log()):o?(console.log(chalk.cyan(" ═══════════════════════════════════════════════")),console.log(chalk.bold.white(" How it works")),console.log(),console.log(chalk.gray(" 1. Browse ")+chalk.white("challenges")+chalk.gray(" and pick one")),console.log(chalk.gray(" 2. ")+chalk.white("open <id>")+chalk.gray(" to read the challenge")),console.log(chalk.gray(" 3. Use ")+chalk.white("ai4ctf")+chalk.gray(" to chat with AI when stuck")),console.log(chalk.gray(" 4. ")+chalk.white("submit <id> icoa{flag}")+chalk.gray(" to score points")),console.log(chalk.gray(" 5. Check ")+chalk.white("scoreboard")+chalk.gray(" to track your rank")),console.log(chalk.cyan(" ═══════════════════════════════════════════════")),console.log(),console.log(chalk.bold.white(" Competition")),console.log(chalk.white(" join <url> ")+chalk.gray("Connect to CTFd")),console.log(chalk.white(" challenges (ch) ")+chalk.gray("List challenges by category")),console.log(chalk.white(" open <id> ")+chalk.gray("Read challenge + get next steps")),console.log(chalk.white(" submit <id> <flag> ")+chalk.gray("Submit a flag")),console.log(chalk.white(" scoreboard (sb) ")+chalk.gray("Live rankings")),console.log(chalk.white(" status ")+chalk.gray("Your score, budget & timer")),console.log(chalk.white(" time ")+chalk.gray("Countdown timer")),console.log(),console.log(chalk.bold.white(" AI Teammate")+chalk.gray(" β€” 3 levels, use wisely")),console.log(chalk.white(' hint "question" ')+chalk.gray("Level A β€” General guidance (50 uses)")),console.log(chalk.white(' hint-b "question" ')+chalk.gray("Level B β€” Deep analysis (10 uses)")),console.log(chalk.white(' hint-c "question" ')+chalk.gray("Level C β€” Critical assist (2 uses)")),console.log(chalk.white(" hint budget ")+chalk.gray("Check remaining uses")),console.log(chalk.white(" ai4ctf ")+chalk.gray("Free-chat with AI (no limit)")),console.log(),console.log(chalk.bold.white(" Tools")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference (linux, web, crypto...)")),console.log(chalk.white(" shell ")+chalk.gray("Docker sandbox")),console.log(chalk.white(" files <id> ")+chalk.gray("Download challenge files")),console.log(chalk.white(" connect <id> ")+chalk.gray("Connect to remote target")),console.log(chalk.white(" note [text] ")+chalk.gray("Add a logbook entry (in-exam: tags current Q)")),console.log(chalk.white(" logbook [n] ")+chalk.gray("View your logbook (in-exam: filter by Q)")),console.log(chalk.white(" log ")+chalk.gray("Session history")),console.log(chalk.white(" man / manual ")+chalk.gray("Show this command list (works in exam too, does not burn elimination)")),console.log(),console.log(chalk.bold.white(" System")),console.log(chalk.white(" setup ")+chalk.gray("Configure settings")),console.log(chalk.white(" lang [code] ")+chalk.gray("Switch language (15 supported)")),console.log(chalk.white(" logout ")+chalk.gray("Disconnect")),console.log(chalk.white(" clear ")+chalk.gray("Clear screen")),console.log(chalk.white(" exit ")+chalk.gray("Quit (session saved)")),void console.log()):(console.log(chalk.bold.yellow(" Restricted Mode β€” activate with a token to unlock all commands")),console.log(),console.log(chalk.white(" activate <token> ")+chalk.gray("Unlock full access")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference")),console.log(chalk.white(" exit ")+chalk.gray("Quit")),void console.log())}
@@ -0,0 +1,69 @@
1
+ # ══════════════════════════════════════════════════════════
2
+ # ICOA β€” Python version lock (single source of truth)
3
+ # ══════════════════════════════════════════════════════════
4
+ # This is a pip *constraints* file (pip install -c constraints.txt ...).
5
+ # It does NOT install anything β€” it only pins the version of whatever the
6
+ # host setup (src/commands/env.ts) or the sandbox image (docker/Dockerfile)
7
+ # actually requests, INCLUDING transitive dependencies.
8
+ #
9
+ # Why this file exists β€” anti version-drift:
10
+ # Before this, the same package was pinned in two places (env.ts manifest
11
+ # + Dockerfile) and they drifted (e.g. gmpy2 was >=2.2.0 on the host but
12
+ # ==2.1.5 in the image). Both paths now share THIS file, so a version is
13
+ # declared exactly once. Edit a pin here and both host + container follow.
14
+ #
15
+ # Tested on Python 3.12 (host target 3.12.13 / sandbox ubuntu:24.04 = 3.12).
16
+ # Keep entries == exact. Any change here should be re-verified on WSL +
17
+ # Ubuntu + macOS before publish (see CLAUDE.md cross-platform baseline).
18
+ # ══════════════════════════════════════════════════════════
19
+
20
+ # ── CTF Core ──
21
+ pwntools==4.12.0
22
+ pycryptodome==3.20.0
23
+ z3-solver==4.12.6
24
+
25
+ # ── Web & Network ──
26
+ requests==2.31.0
27
+ beautifulsoup4==4.12.3
28
+ flask==3.0.0
29
+ scapy==2.5.0
30
+ paramiko==3.4.0
31
+
32
+ # ── Crypto & Math ──
33
+ sympy==1.12
34
+ gmpy2==2.3.0 # reconciled: was env.ts >=2.2.0 vs Dockerfile ==2.1.5
35
+ cryptography==42.0.0
36
+
37
+ # ── Binary & RE ──
38
+ capstone==5.0.1
39
+ ropper==1.13.8
40
+ ROPgadget==7.4
41
+ pefile==2023.2.7
42
+
43
+ # ── Data & Forensics ──
44
+ pillow==10.2.0
45
+ numpy==1.26.4
46
+ python-magic==0.4.27
47
+ yara-python==4.5.0
48
+
49
+ # ── Tools ──
50
+ uncompyle6==3.9.1
51
+ pyserial==3.5
52
+ ipython==9.6.0 # was floating; pinned to current 3.12-compatible release
53
+
54
+ # ── Large dependency trees: top-level pinned, transitive deps float ──
55
+ # Pinned to the versions pip resolves on macOS (Apple, Python 3.12). Only the
56
+ # top-level package is locked β€” their transitive deps (claripy/cle/pyvex/
57
+ # unicorn for angr, etc.) stay free so they can't conflict with the exact
58
+ # pins above (e.g. capstone==5.0.1). Re-resolve on macOS when bumping.
59
+ angr==9.2.217
60
+ sqlmap==1.10.5
61
+ volatility3==2.28.0
62
+
63
+ # ── Intentionally NOT pinned (float to latest) ──
64
+ # Dockerfile-only pip installs with no host equivalent to resolve against.
65
+ # When a drift incident hits one of them, add a verified == pin above.
66
+ # one_gadget
67
+ # seccomp-tools
68
+ # pngcheck
69
+ # rsactftool
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icoa-cli",
3
- "version": "2.19.238",
3
+ "version": "2.19.240",
4
4
  "description": "ICOA CLI β€” The world's first CLI-native cyber & AI security olympiad terminal: AI4CTF (Day 1), CTF4AI (Day 2), VLA4CTF (Pioneer Round β€” embodied AI)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,7 +9,8 @@
9
9
  "files": [
10
10
  "dist",
11
11
  "refs",
12
- "assets"
12
+ "assets",
13
+ "docker/constraints.txt"
13
14
  ],
14
15
  "scripts": {
15
16
  "build": "tsc",