icoa-cli 2.19.266 → 2.19.267
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.
- package/dist/commands/ai4ctf.js +1 -1
- package/dist/commands/arena.js +1 -1
- package/dist/commands/ctf4ai-demo.js +1 -1
- package/dist/commands/ctf4vla.js +1 -1
- package/dist/commands/exam.js +1 -1
- package/dist/commands/ipynb.js +1 -1
- package/dist/lib/hint-client.js +1 -1
- package/dist/lib/open-file.d.ts +9 -0
- package/dist/lib/open-file.js +1 -0
- package/package.json +1 -1
package/dist/commands/ipynb.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,mkdirSync as o,writeFileSync as n}from"node:fs";import{homedir as t}from"node:os";import{createInterface as r}from"node:readline";import{join as l}from"node:path";import chalk from"chalk";import{aienvPaths as a}from"../lib/aienv.js";import{shouldExecuteCell as
|
|
1
|
+
import{existsSync as e,mkdirSync as o,writeFileSync as n}from"node:fs";import{homedir as t}from"node:os";import{createInterface as r}from"node:readline";import{join as l}from"node:path";import chalk from"chalk";import{aienvPaths as a}from"../lib/aienv.js";import{shouldExecuteCell as i}from"../lib/ipynb-input.js";import{NotebookKernel as s}from"../lib/kernel.js";import{getMainRl as c}from"../lib/main-rl.js";import{openFile as g}from"../lib/open-file.js";const y=new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`,"g");export function registerIpynbCommand(o){o.command("ipynb").description("Open an in-terminal Python notebook (AI/ML — needs `aienv setup`)").action(async()=>{await async function(){const o=a(t()),n=l(t(),".icoa","ipynb-out");if(p(),!e(o.python))return console.log(chalk.yellow(" The AI/ML environment is not set up yet.")),console.log(chalk.gray(" Run ")+chalk.bold.cyan("aienv setup")+chalk.gray(" first (one-time, ~300 MB).")),void console.log();const f=new s({venvPython:o.python,venvRoot:o.root});process.stdout.write(chalk.gray(" Starting Python kernel…"));try{await f.start()}catch{return console.log(chalk.red(" failed.")),console.log(chalk.gray(" Check the environment: ")+chalk.cyan("aienv status")),void console.log()}console.log(chalk.green(" ready.")),console.log(chalk.gray(" Type Python and press Enter. Blocks (def/for/…) continue until a blank line.")),console.log(chalk.gray(" ")+chalk.cyan("help")+chalk.gray(" · ")+chalk.cyan("clear")+chalk.gray(" · ")+chalk.cyan("restart")+chalk.gray(" (fresh kernel) · ")+chalk.cyan("quit")),console.log();const m=c(),h=null!==m,v=h?m.listeners("line").slice():[];h&&m.removeAllListeners("line");const w=h?m:r({input:process.stdin,output:process.stdout,terminal:!0}),b=[];let k=!1;const x=()=>{w.setPrompt(chalk.bold.cyan(b.length?"icoa ipynb ...> ":"icoa ipynb> ")),w.prompt()};let P=()=>{};const $=new Promise(e=>{P=e}),C=async e=>{if(k)return;const o=e.trim();if(0===b.length){const e=o.toLowerCase();if("quit"===e||"exit"===e||"back"===e||"q"===e)return void await(async()=>{if(w.removeAllListeners("line"),console.log(),console.log(chalk.gray(" Notebook closed. Kernel stopped.")),console.log(),await f.shutdown().catch(()=>{}),h){w.setPrompt(chalk.bold.cyan("icoa> "));for(const e of v)w.on("line",e);w.prompt(),P()}else P(),w.close()})();if("clear"===e||"cls"===e)return console.clear(),p(),void x();if("restart"===e)return await(async()=>{process.stdout.write(chalk.gray(" Restarting kernel…")),await f.shutdown().catch(()=>{});try{await f.start(),console.log(chalk.green(" fresh kernel ready.")+chalk.gray(" (all variables cleared)"))}catch{console.log(chalk.red(" restart failed.")+chalk.gray(" Leave and re-enter the notebook."))}})(),void x();if("help"===e||"?"===e)return console.log(),console.log(chalk.bold.white(" Notebook commands")),console.log(chalk.cyan(" help")+chalk.gray(" show this")),console.log(chalk.cyan(" clear")+chalk.gray(" clear the screen")),console.log(chalk.cyan(" restart")+chalk.gray(" restart the kernel (wipes all variables)")),console.log(chalk.cyan(" open")+chalk.gray(" reopen the last figure in your image viewer")),console.log(chalk.cyan(" quit")+chalk.gray(" leave the notebook")),console.log(chalk.gray(" Everything else runs as Python in the persistent kernel.")),console.log(),void x();if("open"===e)return u&&g(u)?console.log(chalk.gray(" reopening ")+chalk.cyan(u)):console.log(chalk.gray(" no figure yet — plot something (e.g. matplotlib) first.")),void x();if(""===o)return void x()}if(b.push(e),!i(b))return void x();const t=b.join("\n").replace(/\s+$/,"");if(b.length=0,""!==t.trim()){k=!0;try{!function(e,o){for(const n of e.outputs)if("stream"===n.kind){const e=n.text.replace(/\n$/,"");if(0===e.length)continue;console.log("stderr"===n.name?chalk.yellow(e):chalk.white(e))}else if("result"===n.kind)console.log(chalk.cyan(` Out[${e.execCount??"*"}]: `)+chalk.white(n.text));else if("error"===n.kind){console.log(chalk.bold.red(` ${n.ename}: ${n.evalue}`));for(const e of n.traceback)console.log(chalk.gray(` ${e.replace(y,"")}`))}else"display"===n.kind&&d(n.data,o)}(await f.execute(t),n)}catch(e){console.log(chalk.red(" Kernel error: ")+chalk.gray(e instanceof Error?e.message:String(e)))}k=!1,x()}else x()};w.on("line",e=>{C(e)}),h||w.on("close",async()=>{await f.shutdown().catch(()=>{}),process.exit(0)}),x(),await $}()})}function p(){console.log(),console.log(chalk.bold.white(" ICOA Notebook ")+chalk.gray("· in-terminal Python · AI/ML notebook arena")),console.log(chalk.gray(" ─────────────────────────────────────────────"))}let f=0,u=null;function d(e,t){if(e["image/png"])try{o(t,{recursive:!0}),f+=1;const r=l(t,`figure-${f}.png`);return n(r,Buffer.from(e["image/png"],"base64")),u=r,console.log(chalk.magenta(" 🖼 figure saved → ")+chalk.cyan(r)),void(g(r)?console.log(chalk.gray(" opening in your image viewer… (type ")+chalk.cyan("open")+chalk.gray(" to reopen)")):console.log(chalk.gray(" open it with your file browser (inline images need a graphical viewer).")))}catch{}e["text/plain"]&&console.log(chalk.white(` ${e["text/plain"]}`))}
|
package/dist/lib/hint-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(a,b){const v=a0b,c=a();while(!![]){try{const d
|
|
1
|
+
(function(a,b){const v=a0b,c=a();while(!![]){try{const d=-parseInt(v(0xaa))/(0x1*-0xa2d+0x185d+-0xe2f*0x1)+parseInt(v(0x9d))/(0x4*0x6a1+-0x76e+-0x1314)+-parseInt(v(0x98))/(-0x1*0x22fa+0x20d1+-0x1*-0x22c)+-parseInt(v(0x93))/(0x1b*0x51+-0x1095*0x2+0x18a3)+parseInt(v(0xab))/(-0x37e+-0x1c9*-0xb+-0x1020)*(parseInt(v(0x94))/(-0x172*0x13+-0x18b*-0xb+0xa83))+-parseInt(v(0x9f))/(0x159d*-0x1+-0xeed*-0x1+-0x6b7*-0x1)*(parseInt(v(0xa1))/(0x1a04+0x25*-0x11+-0x1787))+parseInt(v(0x95))/(0x5fd*0x1+0x13ef+0x19e3*-0x1);if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a0a,0x146*0xe93+-0x1a2e0a+-0x13*-0x1259d));function a0b(a,b){a=a-(-0xd4*0x2f+-0x4d6+0x2c55);const c=a0a();let d=c[a];if(a0b['bkABIn']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=-0x44*0x40+-0x1a8e+-0x19*-0x1be,o,p,q=0x3*0x9f7+-0x1401+-0x9e4;p=i['charAt'](q++);~p&&(o=n%(-0x12de+0x515*-0x2+0xb*0x2a4)?o*(-0x1ea5+-0x92*0x1d+0x2f6f)+p:p,n++%(-0x2233+-0x1*-0x20e0+0x157))?l+=String['fromCharCode'](0x2089+-0x2451+0x4c7&o>>(-(0x1*-0x1292+0xf12+0x382)*n&0x2093+-0xd*-0x72+-0x1*0x2657)):0x19d3+-0x83a+-0x1199){p=j['indexOf'](p);}for(let r=-0xa0+-0x52*-0x1+-0x4e*-0x1,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](-0x1566+0x7c9+0xdad))['slice'](-(-0x7cf*0x1+0x9*-0xad+0xde6));}return decodeURIComponent(m);};a0b['ODCmql']=e,a0b['csWqeD']={},a0b['bkABIn']=!![];}const f=c[0x1*0xf77+-0x1495+-0x83*-0xa],g=a+f,h=a0b['csWqeD'][g];return!h?(d=a0b['ODCmql'](d),a0b['csWqeD'][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(0x9b)]||w(0xa4),h=d[w(0xb0)]||f[w(0xa2)]||'en',j=d['timeoutMs']??0x3464+-0x37*0x9c+-0x42*-0x30,k=[g+w(0xa0)+d[w(0x9a)]+'/hint',g+w(0xac)+d[w(0x9a)]+'/hint'];let l=null;for(const p of k)try{const q=await fetch(p,{'method':w(0x97),'headers':{'Content-Type':w(0xa7),'User-Agent':w(0xa3)},'body':JSON[w(0xad)]({'token':d[w(0x9c)],'question':d[w(0x9e)],'level':d[w(0xae)],'lang':h}),'signal':AbortSignal[w(0xa8)](j)}),r=await q[w(0xaf)]()['catch'](()=>({}));if(!q['ok']||!(0x1951+0xa66+-0x23b6)===r[w(0xa5)]){if(l={'status':q[w(0xa9)],'message':r?.[w(0x96)]||'hint\x20request\x20failed\x20('+q['status']+')'},q['status']>=0x515*-0x2+0x5*-0x5a+0xd7c&&q[w(0xa9)]<-0x92*0x1d+-0x1fc0+0x323e)throw l;continue;}return r['data'];}catch(u){if(u&&w(0xa6)==typeof u&&w(0xa9)in u)throw u;l={'status':0x0,'message':u?.[w(0x96)]||w(0x99)};}const m={};m[w(0xa9)]=0x0,m['message']='hint\x20API\x20unreachable';throw l||m;}function a0a(){const x=['mtv1DLbRreW','oJKWotaVyxbPl2LJB2eVzxHHBxmV','C3rYAw5NAwz5','Bgv2zwW','ANnVBG','BgfUzW','ndK2odu3mMfSrNrHAG','mZa5nda5ogTlBunfAG','mJy2otm1mJnoDw9NDem','BwvZC2fNzq','ue9tva','mtmZmtr6qwTtzLa','BMv0D29YAYbLCNjVCG','zxHHBuLK','y3rMzfvYBa','Dg9Rzw4','mtK0nZaYmNPsDwr0AG','CxvLC3rPB24','ndaZmLrTt1DMzq','l2fWAs9Py29Hl2v4yw1ZlW','mJm5odrozwHRueC','BgfUz3vHz2u','AwnVys1JBgK','Ahr0Chm6lY9WCMfJDgLJzs5Py29HmJaYnI5HDq','C3vJy2vZCW','B2jQzwn0','yxbWBgLJyxrPB24VANnVBG','DgLTzw91Da','C3rHDhvZ','mtu4ndm1ovzeD01ZsW'];a0a=function(){return x;};return a0a();}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface OpenCommand {
|
|
2
|
+
cmd: string;
|
|
3
|
+
args: string[];
|
|
4
|
+
}
|
|
5
|
+
/** Decide the OS "open" command for `path`. Pure — platform + env are injected
|
|
6
|
+
* so every baseline target (macOS / Linux / WSL / Windows) is unit-testable. */
|
|
7
|
+
export declare function openFileCommand(path: string, platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): OpenCommand;
|
|
8
|
+
/** Open `path` in the OS default app (detached). Returns false if spawn throws. */
|
|
9
|
+
export declare function openFile(path: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawn as e}from"node:child_process";export function openFileCommand(e,r=process.platform,o=process.env){return"darwin"===r?{cmd:"open",args:[e]}:"win32"===r?{cmd:"cmd.exe",args:["/c","start","",e]}:o.WSL_DISTRO_NAME?{cmd:"explorer.exe",args:[e]}:{cmd:"xdg-open",args:[e]}}export function openFile(r){const{cmd:o,args:n}=openFileCommand(r);try{return e(o,n,{stdio:"ignore",detached:!0}).unref(),!0}catch{return!1}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "icoa-cli",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.267",
|
|
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": {
|