icoa-cli 2.19.250 → 2.19.251

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
- import chalk from"chalk";import{createInterface as e}from"node:readline";import{spawn as o}from"node:child_process";import{getMainRl as r}from"../lib/main-rl.js";import{existsSync as n}from"node:fs";import{dirname as l,join as t}from"node:path";import{fileURLToPath as a}from"node:url";import{loadCurriculumById as c,validateEAToken as s,syncProgress as i,syncCardFeedback as u}from"../lib/learn-curricula.js";import{getConfig as d,saveConfig as g}from"../lib/config.js";import{loadLearnState as m,saveLearnState as y,newLearnState as f,updateStreak as p,markCardComplete as h,recordMCQ as b,recordCheck as w,markPracticalComplete as k,addAchievement as C}from"../lib/learn-state.js";import{renderWelcome as v,renderKnowledgeCard as A,renderMCQCard as E,renderMCQFeedback as _,renderPracticalCard as I,renderPracticalSuccess as D,renderSimDemoCard as O,renderMilestone as S,renderStatus as P,renderPhaseComplete as $,renderCurriculumComplete as T}from"../lib/learn-render.js";import{printError as L}from"../lib/ui.js";export function registerLearnCommand(M){M.command("learn [token]").description("Enter learn mode (free demo, or team-issued EA/EI/AC/CA/IO/IA token for full curriculum)").action(async M=>{M&&M.trim()||(console.log(),console.log(chalk.gray(" No token given — starting free 11-card demo (")+chalk.bold.green("LEARNDEMO01")+chalk.gray(").")),console.log(chalk.gray(" Full curriculum: ")+chalk.bold.yellow("learn EA|EI|AC|CA|IO|IA + 8 chars")+chalk.gray(" — token from your country team leader.")),console.log(),M="LEARNDEMO01");const j=M.trim().toUpperCase();let x=null;const N=/^(LEARNDEMO01|AI4CTFDEMO01|CTF4AIDEMO01)$/i.test(j),q=/^[A-Z]{2}[A-Z0-9]{8}$/i.test(j);if(N)console.log(),console.log(chalk.gray(" Loading demo curriculum...")),x=await c(j);else if(q){const e=d().ctfdUrl||"https://practice.icoa2026.au";console.log(),console.log(chalk.gray(" Validating token..."));const o=await s(j,e);if(!o.ok)return L(`Token validation failed: ${o.message}`),console.log(),console.log(chalk.gray(" Possible causes:")),console.log(chalk.gray(" · Token expired or revoked")),console.log(chalk.gray(" · Network down (check connection)")),console.log(chalk.gray(" · Typo in token")),void console.log();if(console.log(chalk.green(` ✓ Token valid · curriculum: ${o.curriculumId} · status: ${o.status}`)),x=await c(o.curriculumId||"LEARNDEMO01"),!x)return L(`Failed to fetch curriculum '${o.curriculumId}' from server.`),console.log(chalk.gray(" This is usually a transient network issue. Try again in a minute.")),void console.log(chalk.gray(" If it persists, check ")+chalk.cyan(e)+chalk.gray(" is reachable."))}if(!x)return L(`Unknown learn token: ${j}`),console.log(),console.log(chalk.gray(" Available tokens:")),console.log(chalk.gray(" ")+chalk.bold.green("LEARNDEMO01")+chalk.gray(" free 11-card demo (anyone can use)")),console.log(chalk.gray(" ")+chalk.bold.yellow("EA|EI|AC|CA|IO|IA")+chalk.gray(" + 8 chars full curriculum (issued by team leader)")),console.log(),console.log(chalk.gray(" Tracks: ")+chalk.cyan("EA")+chalk.gray("=ctf4eai · ")+chalk.cyan("AC")+chalk.gray("=ai4ctf · ")+chalk.cyan("CA")+chalk.gray("=ctf4ai · ")+chalk.cyan("IO")+chalk.gray("=ioai · ")+chalk.cyan("IA")+chalk.gray("=iaio")),console.log(),console.log(chalk.gray(" To get a full curriculum, email ")),console.log(chalk.gray(" ")+chalk.cyan("australia@icoa2026.au")+chalk.gray(" or ask your country's team leader.")),void console.log();let F=m(),R=!1;F&&F.token===j?p(F):(F=f(j,x.id,x.totalCards),R=!0),y(F),v(x,F,R);const U=r(),z=null!==U,B=z?U.listeners("line").slice():[];z&&U.removeAllListeners("line");const J=z?U:e({input:process.stdin,output:process.stdout,terminal:!0}),W=()=>{J.setPrompt(chalk.bold.cyan("icoa learn> ")),J.prompt()};W();let K=null,Q=null,Z=null,G=null,V=!1,H=0;const X=(d().language||"en").toLowerCase().startsWith("zh"),Y=[];let ee=null;const oe=new Promise(e=>{ee=e}),re=()=>{const e=ee;ee=null,e?.()},ne="1"===process.env.ICOA_LEARN_EMBEDDED,le=e=>x.cards.find(o=>o.number===e),te=e=>{const o=x.modules.find(o=>o.cardRange[1]===e);if(!o)return!1;const r=x.modules.find(e=>e.number===o.number+1);return $(x,F,o,r),!0},ae=()=>{V=!0,console.log(chalk.gray(X?" 按 Enter 进入下一阶段…":" Press Enter to continue to the next phase…"))},ce=()=>{const e=le(F.currentCard);if(!e)return console.log(),console.log(chalk.gray(" No more cards in this curriculum.")),console.log(chalk.gray(" Type ")+chalk.bold.green("status")+chalk.gray(" for the dashboard or ")+chalk.bold.green("quit")+chalk.gray(" to exit.")),void console.log();switch(e.type){case"knowledge":A(e,x),e.check?(Z=e.number,H=Date.now()):(h(F,e.number),y(F));break;case"mcq":E(e,x),K=e.number;break;case"practical":I(e,x),Q=e.number;break;case"sim_demo":O(e,x),h(F,e.number),y(F);break;case"milestone":S(e,x),C(F,e.badge),h(F,e.number),y(F)}};J.on("line",async e=>{const r=e.trim().toLowerCase();if(null!==G){const o=e.trim(),r=G;if(G=null,""===o)console.log(chalk.gray(X?" 已取消(未提交)。":" Cancelled (nothing submitted)."));else{const e=d(),n=H>0?Date.now()-H:void 0;Y.push(u(j,e.ctfdUrl||"https://practice.icoa2026.au",{curriculum_id:x.id,card_number:r,feedback_text:o,time_on_card_ms:n}).catch(()=>{})),console.log(chalk.green(X?" ✓ 已收到,谢谢帮助完善这张卡。":" ✓ Thanks — your report was recorded."))}return console.log(),void W()}if(V)return V=!1,ce(),void W();if(r)if("menu"!==r&&"menu confirm"!==r)if("quit"!==r&&"exit"!==r&&"q"!==r){if("status"===r)return P(x,F),void W();if("lang"===r||r.startsWith("lang ")){const e=r.slice(4).trim();if(!e)return console.log(chalk.gray(" 当前语言 / current: ")+chalk.white(d().language||"en")+chalk.gray(" · ")+chalk.bold.green("lang zh")+chalk.gray(" / ")+chalk.bold.green("lang en")),void W();const o=x.cards.some(e=>null!=e._zh),n=e.toLowerCase().startsWith("zh")?"zh":e.toLowerCase(),l="en"===n||"zh"===n&&o,t=l?n:"en";return g({language:t}),l?console.log(chalk.green(" ✓ ")+chalk.gray("语言 / language → ")+chalk.white(t)):console.log(chalk.yellow(" ! ")+chalk.gray(`${e} 本课暂无翻译,已用英文 / not available — using English`)),Z=null,K=null,Q=null,G=null,V=!1,ce(),void W()}if("sim"===r){const e=le(F.currentCard);return e&&"sim_demo"===e.type?(function(e){const r=function(){const e=l(a(import.meta.url)),o=[t(e,"..","..","panda","mujoco-launcher.py"),t(e,"..","..","..","panda","mujoco-launcher.py")];for(const e of o)if(n(e))return e;return null}();if(!r)return console.log(chalk.yellow(" MuJoCo launcher not found.")),console.log(chalk.gray(" Get it from: https://github.com/newaipanda/ICOA_CLI/blob/main/panda/mujoco-launcher.py")),void console.log(chalk.gray(" Or use the sandbox-vla docker image (Phase 3)."));const c={baseline:"baseline",prompt_injected:"prompt_inj",patch_attacked:"patch",modality_confused:"confused"}[e]||"baseline";console.log(chalk.gray(` Launching MuJoCo viewer (scenario: ${c})...`)),console.log(chalk.gray(" Close the window or press ESC to return to learn mode.")),o("python3",[r,c,"--seconds","5"],{stdio:"inherit"}).on("exit",e=>{0!==e?console.log(chalk.yellow(` MuJoCo exited with code ${e} (install: pip install mujoco)`)):console.log(chalk.gray(" Returned from sim."))})}(e.simAction),void W()):(console.log(chalk.gray(" (sim only available on simulation cards)")),void W())}if("bookmark"===r){const e=F.currentCard;return F.bookmarks.includes(e)||F.bookmarks.push(e),y(F),console.log(chalk.gray(` ✓ Card ${e} bookmarked.`)),void W()}if("e"===r)return G=F.currentCard,console.log(chalk.gray(X?" 描述问题(回车提交 / 空行取消):":" Describe the issue (Enter to submit / blank to cancel):")),void W();if("back"===r||"b"===r)return F.currentCard>1&&(F.currentCard-=1),K=null,Q=null,Z=null,y(F),ce(),void W();if(r.startsWith("card ")){const e=r.slice(5).trim(),o=parseInt(e,10);return!Number.isInteger(o)||o<1||o>x.totalCards?(console.log(chalk.yellow(` Card number must be 1..${x.totalCards}. Try: `)+chalk.bold.green("card 1")),void W()):(F.currentCard=o,K=null,Q=null,Z=null,y(F),ce(),void W())}if(null!==Z&&["y","yes","n","no"].includes(r)){const e=le(Z);if(e&&"knowledge"===e.type&&e.check){const o=r.startsWith("y")?"y":"n",n=o===e.check.answer,l=Date.now()-H;h(F,e.number),w(F,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),y(F);const{renderCheckFeedback:t}=await import("../lib/learn-render.js");t(e,o,n,!1);const a=d();if(Y.push(i(j,a.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"check_answered",check_answer:o,check_correct:n,time_on_card_ms:l}).catch(()=>{})),Z=null,e.solution&&e.solution.length>0)return void W();if(F.currentCard<x.totalCards){const e=F.currentCard;F.currentCard+=1,y(F),te(e)?ae():ce(),W()}else T(x,F),W();return}}if(null!==K&&["a","b","c","d"].includes(r)){const e=le(K);if(e&&"mcq"===e.type){const o=r.toUpperCase(),n=o===e.answer;b(F,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),h(F,e.number),y(F),_(e,o,n,F);const l=d();return Y.push(i(j,l.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"mcq_answered",mcq_answer:o,mcq_correct:n}).catch(()=>{})),K=null,void(n?F.currentCard<x.totalCards?(F.currentCard+=1,y(F),ce()):(T(x,F),W()):W())}}if(null!==Q){if("done"===r){const e=le(Q);if(e&&"practical"===e.type)return k(F,e.number),h(F,e.number),y(F),D(e),Q=null,void W()}if("skip"===r)return h(F,Q),y(F),console.log(chalk.gray(" Skipped (counts as not completed).")),console.log(),Q=null,void W()}if("ok"===r||"next"===r||"continue"===r||"n"===r){if(null!==K)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void W();if(null!==Q)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void W();if(null!==Z)return console.log(chalk.yellow(" Please answer the check above (")+chalk.bold.green("y")+chalk.yellow(" or ")+chalk.bold.green("n")+chalk.yellow(").")),void W();const e=F.currentCard;return F.currentCard+=1,y(F),F.currentCard>x.totalCards?T(x,F):te(e)?ae():ce(),void W()}if(null!==Z)return console.log(chalk.yellow(" Please answer the check above (")+chalk.bold.green("y")+chalk.yellow(" or ")+chalk.bold.green("n")+chalk.yellow(").")),void W();if(null!==K)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void W();if(null!==Q)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void W();console.log(chalk.gray(" Unknown command. Try: ")+chalk.white("ok")+chalk.gray(" / ")+chalk.white("status")+chalk.gray(" / ")+chalk.white("card N")+chalk.gray(" / ")+chalk.white("quit")),W()}else if(Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,5e3))]),console.log(),console.log(chalk.gray(" Saved. See you next session.")),console.log(chalk.gray(" Streak: ")+chalk.yellow(`🔥 ${F.streakDays} day(s)`)),console.log(),z){J.removeAllListeners("line");for(const e of B)J.on("line",e);J.prompt(),re()}else J.removeAllListeners("line"),J.close();else if(Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,3e3))]),J.removeAllListeners("line"),z||!ne){const{returnToMainMenu:e}=await import("../lib/menu-nav.js");e(z?J:void 0),re()}else J.close();else W()}),z||J.on("close",async()=>{Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,5e3))]),ne?re():process.exit(0)}),ce(),W(),await oe}),M.command("learn-pull [id]").description("Pre-download learn curricula to ~/.icoa/learn-cache/ for offline use (default: all)").action(async e=>{const o=e?[e.trim()]:["LEARNDEMO01","AI4CTFDEMO01","CTF4AIDEMO01","ai4ctf-96","ai4ctf-360","ctf4ai-96","ctf4ai-360","ctf4eai-96","ctf4eai-360","embodied-ai-100","embodied-ai-480"];console.log(),console.log(chalk.bold.cyan(" ICOA learn-pull — fetching curricula for offline use")),console.log(chalk.gray(` Server: ${(()=>{try{return JSON.parse(require("node:fs").readFileSync(require("node:path").join(require("node:os").homedir(),".icoa","config.json"),"utf-8")).ctfdUrl||"https://practice.icoa2026.au"}catch{return"https://practice.icoa2026.au"}})()}`)),console.log();let r=0,n=0,l=0;for(const e of o){process.stdout.write(` ${e.padEnd(22)} `);const o=Date.now(),t=await c(e),a=Date.now()-o;if(t){const e=t.cards,o=Array.isArray(e)?e.length:0,n=JSON.stringify(t).length;l+=n,console.log(chalk.green("✓ ")+chalk.gray(`${o.toString().padStart(3)} cards · ${(n/1024).toFixed(1).padStart(6)} KB · ${a.toString().padStart(4)} ms`)),r++}else console.log(chalk.red("✗ failed (server unreachable or unknown id)")),n++}console.log(),console.log(chalk.gray(" Summary: ")+chalk.green.bold(`${r} cached`)+chalk.gray(` · ${n} failed · total ${(l/1024).toFixed(0)} KB`)),console.log(chalk.gray(" Cache: ")+chalk.cyan("~/.icoa/learn-cache/")),console.log()})}
1
+ import chalk from"chalk";import{createInterface as e}from"node:readline";import{spawn as o}from"node:child_process";import{getMainRl as r}from"../lib/main-rl.js";import{existsSync as n}from"node:fs";import{dirname as l,join as t}from"node:path";import{fileURLToPath as a}from"node:url";import{loadCurriculumById as c,validateEAToken as s,syncProgress as i,syncCardFeedback as u}from"../lib/learn-curricula.js";import{getConfig as d,saveConfig as g}from"../lib/config.js";import{loadLearnState as m,saveLearnState as y,newLearnState as f,updateStreak as p,markCardComplete as h,recordMCQ as b,recordCheck as w,markPracticalComplete as k,addAchievement as C}from"../lib/learn-state.js";import{renderWelcome as v,renderKnowledgeCard as A,renderMCQCard as E,renderMCQFeedback as _,renderPracticalCard as I,renderPracticalSuccess as D,renderSimDemoCard as S,renderMilestone as O,renderStatus as $,renderPhaseComplete as P,renderCurriculumComplete as L}from"../lib/learn-render.js";import{printError as M}from"../lib/ui.js";export function registerLearnCommand(T){T.command("learn [token]").description("Enter learn mode (free demo, or team-issued EA/EI/AC/CA/IO/IA token for full curriculum)").action(async T=>{T&&T.trim()||(console.log(),console.log(chalk.gray(" No token given — starting free 11-card demo (")+chalk.bold.green("LEARNDEMO01")+chalk.gray(").")),console.log(chalk.gray(" Full curriculum: ")+chalk.bold.yellow("learn EA|EI|AC|CA|IO|IA + 8 chars")+chalk.gray(" — token from your country team leader.")),console.log(),T="LEARNDEMO01");const j=T.trim().toUpperCase();let x=null;const N=/^(LEARNDEMO01|AI4CTFDEMO01|CTF4AIDEMO01)$/i.test(j),q=/^[A-Z]{2}[A-Z0-9]{8}$/i.test(j);if(N)console.log(),console.log(chalk.gray(" Loading demo curriculum...")),x=await c(j);else if(q){const e=d().ctfdUrl||"https://practice.icoa2026.au";console.log(),console.log(chalk.gray(" Validating token..."));const o=await s(j,e);if(!o.ok)return M(`Token validation failed: ${o.message}`),console.log(),console.log(chalk.gray(" Possible causes:")),console.log(chalk.gray(" · Token expired or revoked")),console.log(chalk.gray(" · Network down (check connection)")),console.log(chalk.gray(" · Typo in token")),void console.log();if(console.log(chalk.green(` ✓ Token valid · curriculum: ${o.curriculumId} · status: ${o.status}`)),x=await c(o.curriculumId||"LEARNDEMO01"),!x)return M(`Failed to fetch curriculum '${o.curriculumId}' from server.`),console.log(chalk.gray(" The full curriculum is ~3 MB; on a slow connection the download")),console.log(chalk.gray(" can take a while. Stay on a stable link and run ")+chalk.bold.yellow(`learn ${j}`)+chalk.gray(" again")),console.log(chalk.gray(" — once it loads, it is cached and opens instantly next time.")),void console.log(chalk.gray(" If it keeps failing, check ")+chalk.cyan(e)+chalk.gray(" is reachable."))}if(!x)return M(`Unknown learn token: ${j}`),console.log(),console.log(chalk.gray(" Available tokens:")),console.log(chalk.gray(" ")+chalk.bold.green("LEARNDEMO01")+chalk.gray(" free 11-card demo (anyone can use)")),console.log(chalk.gray(" ")+chalk.bold.yellow("EA|EI|AC|CA|IO|IA")+chalk.gray(" + 8 chars full curriculum (issued by team leader)")),console.log(),console.log(chalk.gray(" Tracks: ")+chalk.cyan("EA")+chalk.gray("=ctf4eai · ")+chalk.cyan("AC")+chalk.gray("=ai4ctf · ")+chalk.cyan("CA")+chalk.gray("=ctf4ai · ")+chalk.cyan("IO")+chalk.gray("=ioai · ")+chalk.cyan("IA")+chalk.gray("=iaio")),console.log(),console.log(chalk.gray(" To get a full curriculum, email ")),console.log(chalk.gray(" ")+chalk.cyan("australia@icoa2026.au")+chalk.gray(" or ask your country's team leader.")),void console.log();let F=m(),R=!1;F&&F.token===j?p(F):(F=f(j,x.id,x.totalCards),R=!0),y(F),v(x,F,R);const U=r(),z=null!==U,B=z?U.listeners("line").slice():[];z&&U.removeAllListeners("line");const J=z?U:e({input:process.stdin,output:process.stdout,terminal:!0}),W=()=>{J.setPrompt(chalk.bold.cyan("icoa learn> ")),J.prompt()};W();let K=null,Q=null,Z=null,G=null,V=!1,H=0;const X=(d().language||"en").toLowerCase().startsWith("zh"),Y=[];let ee=null;const oe=new Promise(e=>{ee=e}),re=()=>{const e=ee;ee=null,e?.()},ne="1"===process.env.ICOA_LEARN_EMBEDDED,le=e=>x.cards.find(o=>o.number===e),te=e=>{const o=x.modules.find(o=>o.cardRange[1]===e);if(!o)return!1;const r=x.modules.find(e=>e.number===o.number+1);return P(x,F,o,r),!0},ae=()=>{V=!0,console.log(chalk.gray(X?" 按 Enter 进入下一阶段…":" Press Enter to continue to the next phase…"))},ce=()=>{const e=le(F.currentCard);if(!e)return console.log(),console.log(chalk.gray(" No more cards in this curriculum.")),console.log(chalk.gray(" Type ")+chalk.bold.green("status")+chalk.gray(" for the dashboard or ")+chalk.bold.green("quit")+chalk.gray(" to exit.")),void console.log();switch(e.type){case"knowledge":A(e,x),e.check?(Z=e.number,H=Date.now()):(h(F,e.number),y(F));break;case"mcq":E(e,x),K=e.number;break;case"practical":I(e,x),Q=e.number;break;case"sim_demo":S(e,x),h(F,e.number),y(F);break;case"milestone":O(e,x),C(F,e.badge),h(F,e.number),y(F)}};J.on("line",async e=>{const r=e.trim().toLowerCase();if(null!==G){const o=e.trim(),r=G;if(G=null,""===o)console.log(chalk.gray(X?" 已取消(未提交)。":" Cancelled (nothing submitted)."));else{const e=d(),n=H>0?Date.now()-H:void 0;Y.push(u(j,e.ctfdUrl||"https://practice.icoa2026.au",{curriculum_id:x.id,card_number:r,feedback_text:o,time_on_card_ms:n}).catch(()=>{})),console.log(chalk.green(X?" ✓ 已收到,谢谢帮助完善这张卡。":" ✓ Thanks — your report was recorded."))}return console.log(),void W()}if(V)return V=!1,ce(),void W();if(r)if("menu"!==r&&"menu confirm"!==r)if("quit"!==r&&"exit"!==r&&"q"!==r){if("status"===r)return $(x,F),void W();if("lang"===r||r.startsWith("lang ")){const e=r.slice(4).trim();if(!e)return console.log(chalk.gray(" 当前语言 / current: ")+chalk.white(d().language||"en")+chalk.gray(" · ")+chalk.bold.green("lang zh")+chalk.gray(" / ")+chalk.bold.green("lang en")),void W();const o=x.cards.some(e=>null!=e._zh),n=e.toLowerCase().startsWith("zh")?"zh":e.toLowerCase(),l="en"===n||"zh"===n&&o,t=l?n:"en";return g({language:t}),l?console.log(chalk.green(" ✓ ")+chalk.gray("语言 / language → ")+chalk.white(t)):console.log(chalk.yellow(" ! ")+chalk.gray(`${e} 本课暂无翻译,已用英文 / not available — using English`)),Z=null,K=null,Q=null,G=null,V=!1,ce(),void W()}if("sim"===r){const e=le(F.currentCard);return e&&"sim_demo"===e.type?(function(e){const r=function(){const e=l(a(import.meta.url)),o=[t(e,"..","..","panda","mujoco-launcher.py"),t(e,"..","..","..","panda","mujoco-launcher.py")];for(const e of o)if(n(e))return e;return null}();if(!r)return console.log(chalk.yellow(" MuJoCo launcher not found.")),console.log(chalk.gray(" Get it from: https://github.com/newaipanda/ICOA_CLI/blob/main/panda/mujoco-launcher.py")),void console.log(chalk.gray(" Or use the sandbox-vla docker image (Phase 3)."));const c={baseline:"baseline",prompt_injected:"prompt_inj",patch_attacked:"patch",modality_confused:"confused"}[e]||"baseline";console.log(chalk.gray(` Launching MuJoCo viewer (scenario: ${c})...`)),console.log(chalk.gray(" Close the window or press ESC to return to learn mode.")),o("python3",[r,c,"--seconds","5"],{stdio:"inherit"}).on("exit",e=>{0!==e?console.log(chalk.yellow(` MuJoCo exited with code ${e} (install: pip install mujoco)`)):console.log(chalk.gray(" Returned from sim."))})}(e.simAction),void W()):(console.log(chalk.gray(" (sim only available on simulation cards)")),void W())}if("bookmark"===r){const e=F.currentCard;return F.bookmarks.includes(e)||F.bookmarks.push(e),y(F),console.log(chalk.gray(` ✓ Card ${e} bookmarked.`)),void W()}if("e"===r)return G=F.currentCard,console.log(chalk.gray(X?" 描述问题(回车提交 / 空行取消):":" Describe the issue (Enter to submit / blank to cancel):")),void W();if("back"===r||"b"===r)return F.currentCard>1&&(F.currentCard-=1),K=null,Q=null,Z=null,y(F),ce(),void W();if(r.startsWith("card ")){const e=r.slice(5).trim(),o=parseInt(e,10);return!Number.isInteger(o)||o<1||o>x.totalCards?(console.log(chalk.yellow(` Card number must be 1..${x.totalCards}. Try: `)+chalk.bold.green("card 1")),void W()):(F.currentCard=o,K=null,Q=null,Z=null,y(F),ce(),void W())}if(null!==Z&&["y","yes","n","no"].includes(r)){const e=le(Z);if(e&&"knowledge"===e.type&&e.check){const o=r.startsWith("y")?"y":"n",n=o===e.check.answer,l=Date.now()-H;h(F,e.number),w(F,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),y(F);const{renderCheckFeedback:t}=await import("../lib/learn-render.js");t(e,o,n,!1);const a=d();if(Y.push(i(j,a.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"check_answered",check_answer:o,check_correct:n,time_on_card_ms:l}).catch(()=>{})),Z=null,e.solution&&e.solution.length>0)return void W();if(F.currentCard<x.totalCards){const e=F.currentCard;F.currentCard+=1,y(F),te(e)?ae():ce(),W()}else L(x,F),W();return}}if(null!==K&&["a","b","c","d"].includes(r)){const e=le(K);if(e&&"mcq"===e.type){const o=r.toUpperCase(),n=o===e.answer;b(F,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),h(F,e.number),y(F),_(e,o,n,F);const l=d();return Y.push(i(j,l.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"mcq_answered",mcq_answer:o,mcq_correct:n}).catch(()=>{})),K=null,void(n?F.currentCard<x.totalCards?(F.currentCard+=1,y(F),ce()):(L(x,F),W()):W())}}if(null!==Q){if("done"===r){const e=le(Q);if(e&&"practical"===e.type)return k(F,e.number),h(F,e.number),y(F),D(e),Q=null,void W()}if("skip"===r)return h(F,Q),y(F),console.log(chalk.gray(" Skipped (counts as not completed).")),console.log(),Q=null,void W()}if("ok"===r||"next"===r||"continue"===r||"n"===r){if(null!==K)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void W();if(null!==Q)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void W();if(null!==Z)return console.log(chalk.yellow(" Please answer the check above (")+chalk.bold.green("y")+chalk.yellow(" or ")+chalk.bold.green("n")+chalk.yellow(").")),void W();const e=F.currentCard;return F.currentCard+=1,y(F),F.currentCard>x.totalCards?L(x,F):te(e)?ae():ce(),void W()}if(null!==Z)return console.log(chalk.yellow(" Please answer the check above (")+chalk.bold.green("y")+chalk.yellow(" or ")+chalk.bold.green("n")+chalk.yellow(").")),void W();if(null!==K)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void W();if(null!==Q)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void W();console.log(chalk.gray(" Unknown command. Try: ")+chalk.white("ok")+chalk.gray(" / ")+chalk.white("status")+chalk.gray(" / ")+chalk.white("card N")+chalk.gray(" / ")+chalk.white("quit")),W()}else if(Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,5e3))]),console.log(),console.log(chalk.gray(" Saved. See you next session.")),console.log(chalk.gray(" Streak: ")+chalk.yellow(`🔥 ${F.streakDays} day(s)`)),console.log(),z){J.removeAllListeners("line");for(const e of B)J.on("line",e);J.prompt(),re()}else J.removeAllListeners("line"),J.close();else if(Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,3e3))]),J.removeAllListeners("line"),z||!ne){const{returnToMainMenu:e}=await import("../lib/menu-nav.js");e(z?J:void 0),re()}else J.close();else W()}),z||J.on("close",async()=>{Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,5e3))]),ne?re():process.exit(0)}),ce(),W(),await oe}),T.command("learn-pull [id]").description("Pre-download learn curricula to ~/.icoa/learn-cache/ for offline use (default: all)").action(async e=>{const o=e?[e.trim()]:["LEARNDEMO01","AI4CTFDEMO01","CTF4AIDEMO01","ai4ctf-96","ai4ctf-360","ctf4ai-96","ctf4ai-360","ctf4eai-96","ctf4eai-360","embodied-ai-100","embodied-ai-480"];console.log(),console.log(chalk.bold.cyan(" ICOA learn-pull — fetching curricula for offline use")),console.log(chalk.gray(` Server: ${(()=>{try{return JSON.parse(require("node:fs").readFileSync(require("node:path").join(require("node:os").homedir(),".icoa","config.json"),"utf-8")).ctfdUrl||"https://practice.icoa2026.au"}catch{return"https://practice.icoa2026.au"}})()}`)),console.log();let r=0,n=0,l=0;for(const e of o){process.stdout.write(` ${e.padEnd(22)} `);const o=Date.now(),t=await c(e),a=Date.now()-o;if(t){const e=t.cards,o=Array.isArray(e)?e.length:0,n=JSON.stringify(t).length;l+=n,console.log(chalk.green("✓ ")+chalk.gray(`${o.toString().padStart(3)} cards · ${(n/1024).toFixed(1).padStart(6)} KB · ${a.toString().padStart(4)} ms`)),r++}else console.log(chalk.red("✗ failed (server unreachable or unknown id)")),n++}console.log(),console.log(chalk.gray(" Summary: ")+chalk.green.bold(`${r} cached`)+chalk.gray(` · ${n} failed · total ${(l/1024).toFixed(0)} KB`)),console.log(chalk.gray(" Cache: ")+chalk.cyan("~/.icoa/learn-cache/")),console.log()})}
@@ -1 +1 @@
1
- (function(a,b){const v=a0b,c=a();while(!![]){try{const d=parseInt(v(0x87))/(-0x75f*0x4+0x3*-0x2ee+0x2647)*(-parseInt(v(0x89))/(-0x4*-0x4f8+-0x189b+0x4bd*0x1))+parseInt(v(0x71))/(-0x1cfb+-0x214f+-0x185*-0x29)+parseInt(v(0x7d))/(-0x1*0x2652+0x11*-0x1df+-0x1*-0x4625)*(-parseInt(v(0x7b))/(0xf73+-0x2*-0x78b+0x117*-0x1c))+-parseInt(v(0x82))/(0x17*-0x2+0x95f*-0x3+0x1c51)+-parseInt(v(0x8c))/(0x9*0x275+0x1bc1+0x3*-0x109d)+-parseInt(v(0x75))/(0x227d+-0x5d2+0x1ca3*-0x1)*(-parseInt(v(0x6f))/(-0x1de1*-0x1+0x7cf+0x237*-0x11))+parseInt(v(0x73))/(0x1bd9+0x1e2d+-0x39fc);if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a0a,-0x676dc+0x2a381+-0x2c18*-0x2c));function a0a(){const x=['AwnVys1JBgK','DgLTzw91De1Z','AgLUDcbYzxf1zxn0igzHAwXLzcaO','nZmWu0vHu0Xm','oJKWotaVyxbPl2LJB2eVzxHHBxmV','odK0AgLfENbY','y2f0y2G','yxbWBgLJyxrPB24VANnVBG','mZm0nZy4Dgfiyxjs','zxHHBuLK','ue9tva','nJqYodDSu3DKrge','Ahr0Chm6lY9WCMfJDgLJzs5Py29HmJaYnI5HDq','mty5mdGWDhvTwNvT','ANnVBG','oduYmti3mgjIteP6Ea','C3rYAw5NAwz5','mJGWyvbUALrQ','BgfUz3vHz2u','C3vJy2vZCW','Bgv2zwW','zgf0yq','AgLUDcbbueKGDw5YzwfJAgfIBgu','otaZmJu1CenXq2rO','l2HPBNq','oePiAePRCq','BwvZC2fNzq','BgfUzW','CxvLC3rPB24','C3rHDhvZ','mta2mJu5nhv2uxv0AW','l2fWAs9Py29Hl2v4yw1ZlW'];a0a=function(){return x;};return a0a();}import{getConfig as a0c}from'./config.js';function a0b(a,b){a=a-(0x1*-0xa41+-0x359*-0x7+0x44*-0x30);const c=a0a();let d=c[a];if(a0b['HFBmXd']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=-0xbc4+-0x21d*0xd+-0xcd*-0x31,o,p,q=0x4f*0x3a+0x8*0x488+-0x1*0x3626;p=i['charAt'](q++);~p&&(o=n%(0xd3e+0x1f38+0x1639*-0x2)?o*(-0x1f*0x9b+0x1707+-0x12*0x39)+p:p,n++%(-0xe9*0x1d+-0x19ea+0x3453))?l+=String['fromCharCode'](-0xdd*-0x17+0x7*0x4f3+-0x3581&o>>(-(-0x11aa+0x26f9+0x7*-0x30b)*n&0x2d*-0xd6+0x1c30+0x974)):0x6d0+-0x6+-0x6ca){p=j['indexOf'](p);}for(let r=-0xc*0xaf+-0x14a4+0xd*0x238,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](-0x1b94+0xde9+0xdbb))['slice'](-(-0x216*-0x2+-0xeb0+0xa86));}return decodeURIComponent(m);};a0b['IwniuV']=e,a0b['XYpVeZ']={},a0b['HFBmXd']=!![];}const f=c[-0x6d7+0x1981+-0x12aa],g=a+f,h=a0b['XYpVeZ'][g];return!h?(d=a0b['IwniuV'](d),a0b['XYpVeZ'][g]=d):d=h,d;}export async function requestHint(d){const w=a0b,f=a0c(),g=f['ctfdUrl']||w(0x70),h=d[w(0x7f)]||f[w(0x76)]||'en',j=d[w(0x85)]??-0x12d3+-0x79*0x5d+-0xb1*-0x88,k=[g+w(0x83)+d['examId']+w(0x7c),g+w(0x88)+d[w(0x8d)]+'/hint'];let l=null;for(const p of k)try{const q=await fetch(p,{'method':w(0x6e),'headers':{'Content-Type':w(0x8b),'User-Agent':w(0x84)},'body':JSON[w(0x74)]({'token':d['token'],'question':d[w(0x80)],'level':d[w(0x78)],'lang':h}),'signal':AbortSignal['timeout'](j)}),r=await q[w(0x72)]()[w(0x8a)](()=>({}));if(!q['ok']||!(0x4f*0x3a+0x8*0x488+-0x1*0x3625)===r[w(0x77)]){if(l={'status':q[w(0x81)],'message':r?.['message']||w(0x86)+q[w(0x81)]+')'},q['status']>=0xd3e+0x1f38+0x242*-0x13&&q[w(0x81)]<-0x1f*0x9b+0x1707+-0x5*0x76)throw l;continue;}return r[w(0x79)];}catch(u){if(u&&'object'==typeof u&&w(0x81)in u)throw u;l={'status':0x0,'message':u?.['message']||'network\x20error'};}const m={};m['status']=0x0,m[w(0x7e)]=w(0x7a);throw l||m;}
1
+ function a0b(a,b){a=a-(-0x15d9+0x1cd*-0x8+0x25c3*0x1);const c=a0a();let d=c[a];if(a0b['Qkydoc']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=0xdc3*0x2+-0xd67*0x2+0x5c*-0x2,o,p,q=0xa96+-0x5af*0x1+-0x5*0xfb;p=i['charAt'](q++);~p&&(o=n%(-0x13*-0x98+0xa*-0x3e3+-0x1b9a*-0x1)?o*(-0x88e*-0x1+0x23ed+-0xa9*0x43)+p:p,n++%(0x1*0x95+-0x1d2*0xa+0x11a3))?l+=String['fromCharCode'](0x177c+-0x210b*0x1+0xa8e&o>>(-(-0x2052+-0x9b3*0x3+0x3d6d*0x1)*n&-0xc50*0x1+0xa54*0x1+0x1*0x202)):-0xe6e*0x2+-0x7b*0x2a+0x310a){p=j['indexOf'](p);}for(let r=0x1*0xf67+0x1a91+-0x29f8,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](-0x656*-0x3+0x9d0+0x2*-0xe61))['slice'](-(0xb*-0x2d4+-0xe53+0x2d71));}return decodeURIComponent(m);};a0b['frhvQy']=e,a0b['CdesmO']={},a0b['Qkydoc']=!![];}const f=c[-0x426+0x12ee+-0xec8],g=a+f,h=a0b['CdesmO'][g];return!h?(d=a0b['frhvQy'](d),a0b['CdesmO'][g]=d):d=h,d;}(function(a,b){const v=a0b,c=a();while(!![]){try{const d=-parseInt(v(0x18a))/(0x1408+0x195b*-0x1+-0x1f*-0x2c)*(parseInt(v(0x1a0))/(0x3*0x844+0x22b6+-0x3b80))+parseInt(v(0x198))/(0x11f2*0x1+-0xff+0x43c*-0x4)+-parseInt(v(0x18c))/(-0xa00+-0x5e*-0xd+0x2*0x29f)*(-parseInt(v(0x18e))/(-0x3*-0x2a2+-0x1*-0x123f+0xb*-0x260))+parseInt(v(0x18f))/(-0x1*0xe3f+-0x1f*0xcf+0x2756)+-parseInt(v(0x191))/(0x2*-0x595+0x130f+-0x7de)+-parseInt(v(0x19e))/(-0x243d+-0x15c+0xa9*0x39)+parseInt(v(0x190))/(0x1*0x21d7+-0x9a9*0x1+-0x1825*0x1);if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a0a,0x10*-0x17b9+-0x10c2ca+0x1abcf2));import{getConfig as a0c}from'./config.js';function a0a(){const x=['nte4nZC0vwzgwxjh','AwnVys1JBgK','mtmYmduYmhzluKflDG','yxbWBgLJyxrPB24VANnVBG','nxvnr1rOyG','mtK0nZaZme9dzNfjsa','nZKYmtm2ohrlAMDOqG','nte0nZyZoxzKEe1HEq','y3rMzfvYBa','AgLUDcbbueKGDw5YzwfJAgfIBgu','y2f0y2G','l2fWAs9Py29Hl2v4yw1ZlW','Dg9Rzw4','zxHHBuLK','mtiWnJm1ngDTrgHABa','AgLUDcbYzxf1zxn0igzHAwXLzcaO','BwvZC2fNzq','l2HPBNq','C3rYAw5NAwz5','DgLTzw91De1Z','mtaWodq2ngPkuwrMEq','oJKWotaVyxbPl2LJB2eVzxHHBxmV','mK5IuLHeqq','CxvLC3rPB24','C3vJy2vZCW','ue9tva','zgf0yq','DgLTzw91Da','BgfUz3vHz2u','Bgv2zwW','BgfUzW','ANnVBG','C3rHDhvZ'];a0a=function(){return x;};return a0a();}export async function requestHint(d){const w=a0b,f=a0c(),g=f[w(0x192)]||'https://practice.icoa2026.au',h=d[w(0x187)]||f[w(0x185)]||'en',j=d[w(0x19d)]??0x2ae3*-0x1+0x36c4+0x227*0x9,k=[g+w(0x195)+d[w(0x197)]+w(0x19b),g+w(0x19f)+d[w(0x197)]+w(0x19b)];let l=null;for(const p of k)try{const q=await fetch(p,{'method':w(0x182),'headers':{'Content-Type':w(0x18d),'User-Agent':w(0x18b)},'body':JSON[w(0x19c)]({'token':d[w(0x196)],'question':d[w(0x1a1)],'level':d[w(0x186)],'lang':h}),'signal':AbortSignal[w(0x184)](j)}),r=await q[w(0x188)]()[w(0x194)](()=>({}));if(!q['ok']||!(0xa96+-0x5af*0x1+-0x21*0x26)===r[w(0x1a2)]){if(l={'status':q['status'],'message':r?.[w(0x19a)]||w(0x199)+q[w(0x189)]+')'},q[w(0x189)]>=-0x13*-0x98+0xa*-0x3e3+-0x1d26*-0x1&&q[w(0x189)]<-0x88e*-0x1+0x23ed+-0xbf*0x39)throw l;continue;}return r[w(0x183)];}catch(u){if(u&&'object'==typeof u&&w(0x189)in u)throw u;l={'status':0x0,'message':u?.['message']||'network\x20error'};}const m={};m[w(0x189)]=0x0,m[w(0x19a)]=w(0x193);throw l||m;}
@@ -1 +1 @@
1
- export function localized(t,e){if(!e.startsWith("zh")||!t._zh)return t;const r=t._zh,n={...t};for(const t of Object.keys(r))void 0!==r[t]&&(n[t]=r[t]);return n}import{readFileSync as t,writeFileSync as e,mkdirSync as r,existsSync as n,statSync as c,utimesSync as a}from"node:fs";import{join as o}from"node:path";import{homedir as i}from"node:os";const s=o(i(),".icoa","learn-cache");function u(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return o(s,`${e}.json`)}function l(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return o(s,`${e}.etag`)}export async function loadCurriculumById(d){"ctf4eai-12"===d&&(d="LEARNDEMO01");const f=function(e){const r=u(e);if(!n(r))return null;try{const e=c(r),n=Date.now()-e.mtimeMs;return{curriculum:JSON.parse(t(r,"utf-8")),ageMs:n}}catch{return null}}(d);if(f&&f.ageMs<6048e5)return f.curriculum;const m=await async function(e){const r=function(){try{const e=JSON.parse(t(o(i(),".icoa","config.json"),"utf-8"));if("string"==typeof e.ctfdUrl&&e.ctfdUrl)return e.ctfdUrl}catch{}return"https://practice.icoa2026.au"}().replace(/\/$/,"")+"/api/icoa/learn/curriculum/"+encodeURIComponent(e),c={},a=function(e){const r=l(e);if(!n(r))return null;try{return t(r,"utf-8").trim()||null}catch{return null}}(e);a&&(c["If-None-Match"]=a);try{const t=await fetch(r,{headers:c,signal:AbortSignal.timeout(1e4)});if(304===t.status)return{kind:"unchanged"};if(!t.ok)return{kind:"error"};const e=await t.json();if(!e.success||!e.data)return{kind:"error"};const n=t.headers.get("etag")||t.headers.get("ETag")||void 0;return{kind:"fresh",curriculum:e.data,etag:n||void 0}}catch{return{kind:"error"}}}(d);return"fresh"===m.kind?(function(t,n,c){try{r(s,{recursive:!0}),e(u(t),JSON.stringify(n)),c&&e(l(t),c)}catch{}}(d,m.curriculum,m.etag),m.curriculum):"unchanged"===m.kind&&f?(function(t){try{const e=u(t);if(n(e)){const t=Date.now()/1e3;a(e,t,t)}}catch{}}(d),f.curriculum):f?f.curriculum:null}export function loadCurriculum(t){return null}export async function validateEAToken(t,e){const r=e.replace(/\/$/,"")+"/api/icoa/learn/validate";try{const e=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t.toUpperCase()}),signal:AbortSignal.timeout(8e3)});if(!e.ok)return{ok:!1,message:(await e.json().catch(()=>({}))).message||`HTTP ${e.status}`};const n=await e.json();return n.success&&n.data?{ok:!0,curriculumId:n.data.curriculum_id,status:n.data.status,validUntil:n.data.valid_until}:{ok:!1,message:n.message||"Validation failed"}}catch(t){return{ok:!1,message:`Network error: ${t instanceof Error?t.message:String(t)}`}}}export async function syncProgress(t,e,r){if("LEARNDEMO01"===t.toUpperCase())return;const n=e.replace(/\/$/,"")+"/api/icoa/learn/progress/"+t.toUpperCase();try{await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({card_number:r.card_number,event_type:r.event_type,mcq_answer:r.mcq_answer,mcq_correct:r.mcq_correct?1:0,check_answer:r.check_answer,check_correct:r.check_correct?1:0,time_on_card_ms:r.time_on_card_ms}),signal:AbortSignal.timeout(5e3)})}catch{}}export async function syncCardFeedback(t,e,r){const n=e.replace(/\/$/,"")+"/api/icoa/learn/feedback/"+t.toUpperCase();try{await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({curriculum_id:r.curriculum_id,card_number:r.card_number,feedback_text:r.feedback_text,time_on_card_ms:r.time_on_card_ms}),signal:AbortSignal.timeout(5e3)})}catch{}}
1
+ export function localized(t,e){if(!e.startsWith("zh")||!t._zh)return t;const r=t._zh,n={...t};for(const t of Object.keys(r))void 0!==r[t]&&(n[t]=r[t]);return n}import{readFileSync as t,writeFileSync as e,mkdirSync as r,existsSync as n,statSync as c,utimesSync as a}from"node:fs";import{join as o}from"node:path";import{homedir as i}from"node:os";const s=o(i(),".icoa","learn-cache");function u(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return o(s,`${e}.json`)}function l(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return o(s,`${e}.etag`)}export async function loadCurriculumById(d){"ctf4eai-12"===d&&(d="LEARNDEMO01");const f=function(e){const r=u(e);if(!n(r))return null;try{const e=c(r),n=Date.now()-e.mtimeMs;return{curriculum:JSON.parse(t(r,"utf-8")),ageMs:n}}catch{return null}}(d);if(f&&f.ageMs<6048e5)return f.curriculum;const m=await async function(e){const r=function(){try{const e=JSON.parse(t(o(i(),".icoa","config.json"),"utf-8"));if("string"==typeof e.ctfdUrl&&e.ctfdUrl)return e.ctfdUrl}catch{}return"https://practice.icoa2026.au"}().replace(/\/$/,"")+"/api/icoa/learn/curriculum/"+encodeURIComponent(e),c={},a=function(e){const r=l(e);if(!n(r))return null;try{return t(r,"utf-8").trim()||null}catch{return null}}(e);a&&(c["If-None-Match"]=a);try{const t=await fetch(r,{headers:c,signal:AbortSignal.timeout(6e4)});if(304===t.status)return{kind:"unchanged"};if(!t.ok)return{kind:"error"};const e=await t.json();if(!e.success||!e.data)return{kind:"error"};const n=t.headers.get("etag")||t.headers.get("ETag")||void 0;return{kind:"fresh",curriculum:e.data,etag:n||void 0}}catch{return{kind:"error"}}}(d);return"fresh"===m.kind?(function(t,n,c){try{r(s,{recursive:!0}),e(u(t),JSON.stringify(n)),c&&e(l(t),c)}catch{}}(d,m.curriculum,m.etag),m.curriculum):"unchanged"===m.kind&&f?(function(t){try{const e=u(t);if(n(e)){const t=Date.now()/1e3;a(e,t,t)}}catch{}}(d),f.curriculum):f?f.curriculum:null}export function loadCurriculum(t){return null}export async function validateEAToken(t,e){const r=e.replace(/\/$/,"")+"/api/icoa/learn/validate";try{const e=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t.toUpperCase()}),signal:AbortSignal.timeout(8e3)});if(!e.ok)return{ok:!1,message:(await e.json().catch(()=>({}))).message||`HTTP ${e.status}`};const n=await e.json();return n.success&&n.data?{ok:!0,curriculumId:n.data.curriculum_id,status:n.data.status,validUntil:n.data.valid_until}:{ok:!1,message:n.message||"Validation failed"}}catch(t){return{ok:!1,message:`Network error: ${t instanceof Error?t.message:String(t)}`}}}export async function syncProgress(t,e,r){if("LEARNDEMO01"===t.toUpperCase())return;const n=e.replace(/\/$/,"")+"/api/icoa/learn/progress/"+t.toUpperCase();try{await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({card_number:r.card_number,event_type:r.event_type,mcq_answer:r.mcq_answer,mcq_correct:r.mcq_correct?1:0,check_answer:r.check_answer,check_correct:r.check_correct?1:0,time_on_card_ms:r.time_on_card_ms}),signal:AbortSignal.timeout(5e3)})}catch{}}export async function syncCardFeedback(t,e,r){const n=e.replace(/\/$/,"")+"/api/icoa/learn/feedback/"+t.toUpperCase();try{await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({curriculum_id:r.curriculum_id,card_number:r.card_number,feedback_text:r.feedback_text,time_on_card_ms:r.time_on_card_ms}),signal:AbortSignal.timeout(5e3)})}catch{}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icoa-cli",
3
- "version": "2.19.250",
3
+ "version": "2.19.251",
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": {