icoa-cli 2.19.532 → 2.19.533
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/ctf4ai-demo.js +1 -1
- package/dist/commands/ctf4vla.js +1 -1
- package/dist/commands/demo2.js +1 -1
- package/dist/commands/exam.js +1 -1
- package/dist/commands/gfssm.js +1 -1
- package/dist/commands/learn.js +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/comms.js +1 -1
- package/dist/lib/learn-certificate.js +1 -0
- package/dist/lib/learn-door.js +1 -1
- package/dist/lib/learn-render.js +1 -1
- package/dist/repl.js +1 -1
- package/package.json +1 -1
package/dist/commands/gfssm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{execFile as e}from"node:child_process";import{mkdir as o,writeFile as n}from"node:fs/promises";import{homedir as t}from"node:os";import{join as r}from"node:path";import{createInterface as s,Interface as i}from"node:readline";import chalk from"chalk";import{getMainRl as a}from"../lib/main-rl.js";const l=process.env.RENDER_BOX||"http://172.235.198.124:9098",c=r(t(),".icoa","render-out");let d=[],g=null,u=null;function f(e){return new Promise(o=>{const n=a();if(n)return u=o,n.setPrompt(e),void n.prompt();const t=s({input:process.stdin,output:process.stdout});t.question(e,e=>{t.close(),o(e)})})}function p(o,n){const t="darwin"===process.platform?"open":"xdg-open";e(t,[o],e=>{e&&console.log(chalk.yellow((n?" 用文件浏览器打开:":" Open in your file browser: ")+o))})}let m=null,h=null;function y(e){console.log(chalk.yellow(e?" ⏸ GPU 还没准备好 — 渲染箱不在线。":" ⏸ GPU not ready — the render box is offline right now.")),console.log(chalk.gray(e?" 晚点再来试;":" Try again later; ")+chalk.bold.green("back")+chalk.gray(e?" 回上一层。":" returns to the previous layer."))}async function w(e,t,s){let i;try{const o=await fetch(`${l}/render`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,seconds:5,base_job:s}),signal:AbortSignal.timeout(8e3)});if(!o.ok)return void y(t);i=(await o.json()).job,h=i}catch{return void y(t)}console.log(chalk.gray((t?" 任务 ":" job ")+i+(t?" 已提交,AI 正在写场景代码…":" queued — AI is writing the scene…")));const a=async()=>{try{return await(await fetch(`${l}/status/${i}`)).json()}catch{return null}},d=async e=>{try{await o(c,{recursive:!0});const e=Buffer.from(await(await fetch(`${l}/video/${i}`)).arrayBuffer());m=r(c,`gfssm-${i}.mp4`),await n(m,e)}catch(e){const o=e instanceof Error?e.message:String(e);return void console.log(chalk.red((t?" ✗ 下载失败:":" ✗ download failed: ")+o))}const s=((e.bytes||0)/1e6).toFixed(1);console.log(chalk.green((t?` ✅ 渲染完成(GPU ${e.render_s}s,${s}MB)→ `:` ✅ rendered (GPU ${e.render_s}s, ${s}MB) → `)+m)),p(m,t)},g=!0===process.stdout.isTTY,u=Date.now();let f=15;for(;;){for(let e=f;e>0;e--){if(Date.now()-u>48e4)return g&&process.stdout.write("\r[2K"),void console.log(chalk.red(t?" ✗ 等待超时。":" ✗ timed out."));const o=await a();if("error"===o?.state)return g&&process.stdout.write("\r[2K"),void console.log(chalk.red(" ✗ "+(o.detail||"render failed")));if("done"===o?.state)return g&&process.stdout.write("\r[2K"),void await d(o);const n=Math.floor((Date.now()-u)/1e3),r=E(o?.state,n,t),s="▓".repeat(Math.max(0,f-e)).padEnd(f,"░"),i=chalk.white(` ${r}`)+chalk.gray(" ")+chalk.cyan(s)+chalk.gray(` ${e}s`);g?process.stdout.write("\r[2K"+i):e===f&&console.log(i),await new Promise(e=>setTimeout(e,1e3))}const e=await a();if("error"===e?.state)return g&&process.stdout.write("\r[2K"),void console.log(chalk.red(" ✗ "+(e.detail||"render failed")));if("done"===e?.state)return g&&process.stdout.write("\r[2K"),void await d(e);g&&process.stdout.write("\r[2K"),console.log(chalk.gray(t?" 还没好,再等 5 秒…":" not yet — 5 more seconds…")),f=5}}function b(e){console.log(chalk.gray(e?" ▸ 描述新场景渲染 · 改 <改动> 微调上一段(如 改 加一个穹顶 / 改 0.8g) · open 重看 · quit 退出":" ▸ describe a scene · refine <change> tweaks the last clip (e.g. refine 0.8g) · open · quit"))}const A={generating:{zh:["🤖 AI 正在把你这句话翻译成 Blender 代码…","✍ 摆放几何体:球体、环、柱子、地面…","💡 设定材质、灯光和世界背景色…","🎥 规划相机轨道和每一帧的关键帧…"],en:["🤖 AI is turning your sentence into Blender code…","✍ placing primitives: spheres, torus, cylinders, ground…","💡 setting materials, lights, and the world background…","🎥 planning the camera path and keyframes…"]},rendering:{zh:["🎬 GPU 正在逐帧渲染(120 帧 = 5 秒 @24fps)…","✨ EEVEE 光栅化:每帧 16 次采样抗锯齿…","⚡ 这块 RTX 4000 Ada 每秒能渲十几帧…","📦 快好了,正在把帧合成 mp4…"],en:["🎬 the GPU is rendering frame by frame (120 frames = 5s)…","✨ EEVEE rasterizing: 16 samples per frame…","⚡ this RTX 4000 Ada renders ~10 frames a second…","📦 almost there — muxing the frames into mp4…"]},repairing:{zh:["🔧 渲染报了个小错,AI 正在自动修复…","🔧 把报错回喂给 AI,请它改一行再试…","🔧 自愈中(最多试 3 次)——这就是 AI 写代码的日常…"],en:["🔧 render hit a small bug — AI is auto-fixing it…","🔧 feeding the error back to the AI for a one-line fix…","🔧 self-healing (up to 3 tries) — the reality of AI codegen…"]},queued:{zh:["⏳ 前面还有任务,排队中…"],en:["⏳ another job is ahead — queued…"]}};function E(e,o,n){const t="queued"===e?"queued":"generating"===e?"generating":e&&e.startsWith("repairing")?"repairing":"rendering",r=A[t][n?"zh":"en"];return r[Math.floor(o/3)%r.length]}export async function runGfssm(e="en"){const o=e.toLowerCase().startsWith("zh");!function(){const e=a();e&&(d=e.listeners("line").slice(),e.removeAllListeners("line"),g=e.prompt.bind(e),e.prompt=i.prototype.prompt.bind(e),e.on("line",e=>{const o=u;u=null,o&&o(e)}))}();try{for(function(e){console.clear(),console.log(),console.log(chalk.cyan(" "+"═".repeat(
|
|
1
|
+
import{execFile as e}from"node:child_process";import{mkdir as o,writeFile as n}from"node:fs/promises";import{homedir as t}from"node:os";import{join as r}from"node:path";import{createInterface as s,Interface as i}from"node:readline";import chalk from"chalk";import{getMainRl as a}from"../lib/main-rl.js";const l=process.env.RENDER_BOX||"http://172.235.198.124:9098",c=r(t(),".icoa","render-out");let d=[],g=null,u=null;function f(e){return new Promise(o=>{const n=a();if(n)return u=o,n.setPrompt(e),void n.prompt();const t=s({input:process.stdin,output:process.stdout});t.question(e,e=>{t.close(),o(e)})})}function p(o,n){const t="darwin"===process.platform?"open":"xdg-open";e(t,[o],e=>{e&&console.log(chalk.yellow((n?" 用文件浏览器打开:":" Open in your file browser: ")+o))})}let m=null,h=null;function y(e){console.log(chalk.yellow(e?" ⏸ GPU 还没准备好 — 渲染箱不在线。":" ⏸ GPU not ready — the render box is offline right now.")),console.log(chalk.gray(e?" 晚点再来试;":" Try again later; ")+chalk.bold.green("back")+chalk.gray(e?" 回上一层。":" returns to the previous layer."))}async function w(e,t,s){let i;try{const o=await fetch(`${l}/render`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:e,seconds:5,base_job:s}),signal:AbortSignal.timeout(8e3)});if(!o.ok)return void y(t);i=(await o.json()).job,h=i}catch{return void y(t)}console.log(chalk.gray((t?" 任务 ":" job ")+i+(t?" 已提交,AI 正在写场景代码…":" queued — AI is writing the scene…")));const a=async()=>{try{return await(await fetch(`${l}/status/${i}`)).json()}catch{return null}},d=async e=>{try{await o(c,{recursive:!0});const e=Buffer.from(await(await fetch(`${l}/video/${i}`)).arrayBuffer());m=r(c,`gfssm-${i}.mp4`),await n(m,e)}catch(e){const o=e instanceof Error?e.message:String(e);return void console.log(chalk.red((t?" ✗ 下载失败:":" ✗ download failed: ")+o))}const s=((e.bytes||0)/1e6).toFixed(1);console.log(chalk.green((t?` ✅ 渲染完成(GPU ${e.render_s}s,${s}MB)→ `:` ✅ rendered (GPU ${e.render_s}s, ${s}MB) → `)+m)),p(m,t)},g=!0===process.stdout.isTTY,u=Date.now();let f=15;for(;;){for(let e=f;e>0;e--){if(Date.now()-u>48e4)return g&&process.stdout.write("\r[2K"),void console.log(chalk.red(t?" ✗ 等待超时。":" ✗ timed out."));const o=await a();if("error"===o?.state)return g&&process.stdout.write("\r[2K"),void console.log(chalk.red(" ✗ "+(o.detail||"render failed")));if("done"===o?.state)return g&&process.stdout.write("\r[2K"),void await d(o);const n=Math.floor((Date.now()-u)/1e3),r=E(o?.state,n,t),s="▓".repeat(Math.max(0,f-e)).padEnd(f,"░"),i=chalk.white(` ${r}`)+chalk.gray(" ")+chalk.cyan(s)+chalk.gray(` ${e}s`);g?process.stdout.write("\r[2K"+i):e===f&&console.log(i),await new Promise(e=>setTimeout(e,1e3))}const e=await a();if("error"===e?.state)return g&&process.stdout.write("\r[2K"),void console.log(chalk.red(" ✗ "+(e.detail||"render failed")));if("done"===e?.state)return g&&process.stdout.write("\r[2K"),void await d(e);g&&process.stdout.write("\r[2K"),console.log(chalk.gray(t?" 还没好,再等 5 秒…":" not yet — 5 more seconds…")),f=5}}function b(e){console.log(chalk.gray(e?" ▸ 描述新场景渲染 · 改 <改动> 微调上一段(如 改 加一个穹顶 / 改 0.8g) · open 重看 · quit 退出":" ▸ describe a scene · refine <change> tweaks the last clip (e.g. refine 0.8g) · open · quit"))}const A={generating:{zh:["🤖 AI 正在把你这句话翻译成 Blender 代码…","✍ 摆放几何体:球体、环、柱子、地面…","💡 设定材质、灯光和世界背景色…","🎥 规划相机轨道和每一帧的关键帧…"],en:["🤖 AI is turning your sentence into Blender code…","✍ placing primitives: spheres, torus, cylinders, ground…","💡 setting materials, lights, and the world background…","🎥 planning the camera path and keyframes…"]},rendering:{zh:["🎬 GPU 正在逐帧渲染(120 帧 = 5 秒 @24fps)…","✨ EEVEE 光栅化:每帧 16 次采样抗锯齿…","⚡ 这块 RTX 4000 Ada 每秒能渲十几帧…","📦 快好了,正在把帧合成 mp4…"],en:["🎬 the GPU is rendering frame by frame (120 frames = 5s)…","✨ EEVEE rasterizing: 16 samples per frame…","⚡ this RTX 4000 Ada renders ~10 frames a second…","📦 almost there — muxing the frames into mp4…"]},repairing:{zh:["🔧 渲染报了个小错,AI 正在自动修复…","🔧 把报错回喂给 AI,请它改一行再试…","🔧 自愈中(最多试 3 次)——这就是 AI 写代码的日常…"],en:["🔧 render hit a small bug — AI is auto-fixing it…","🔧 feeding the error back to the AI for a one-line fix…","🔧 self-healing (up to 3 tries) — the reality of AI codegen…"]},queued:{zh:["⏳ 前面还有任务,排队中…"],en:["⏳ another job is ahead — queued…"]}};function E(e,o,n){const t="queued"===e?"queued":"generating"===e?"generating":e&&e.startsWith("repairing")?"repairing":"rendering",r=A[t][n?"zh":"en"];return r[Math.floor(o/3)%r.length]}export async function runGfssm(e="en"){const o=e.toLowerCase().startsWith("zh");!function(){const e=a();e&&(d=e.listeners("line").slice(),e.removeAllListeners("line"),g=e.prompt.bind(e),e.prompt=i.prototype.prompt.bind(e),e.on("line",e=>{const o=u;u=null,o&&o(e)}))}();try{for(function(e){console.clear(),console.log();const o=Math.max(24,Math.min(62,(process.stdout.columns||80)-4));console.log(chalk.cyan(" "+"═".repeat(o))),console.log(chalk.bold.white(" 🚀 GFSSM SPACE SCHOLAR — 一句话渲一段太空动画")),console.log(chalk.gray(" "+(e?"你描述场景,服务端 AI 变成 Blender 代码,GPU 渲成 5 秒 mp4":"you describe a scene; a GPU turns it into 5 seconds of Blender"))),console.log(chalk.cyan(" "+"═".repeat(o))),console.log(),e?(console.log(chalk.white(" 用一句话描述一个太空场景,回车提交。例如:")),console.log(chalk.gray(" · 一个旋转的斯坦福环空间站,金属外壳,深空背景,镜头缓缓掠过")),console.log(chalk.gray(" · 火星表面三个白色穹顶基地,中间一根发光信标,相机环绕一周")),console.log(chalk.gray(" · 一颗蓝色行星和它的两颗卫星,缓慢公转"))):(console.log(chalk.white(" Describe a space scene in one line, then Enter. For example:")),console.log(chalk.gray(" · a rotating Stanford-torus station, metal hull, deep space, camera drifts past")),console.log(chalk.gray(" · three white domes on Mars with a glowing beacon, camera orbits once")),console.log(chalk.gray(" · a blue planet and its two moons orbiting slowly"))),console.log()}(o),b(o);;){const e=(await f(chalk.bold.cyan("icoa gfssm> "))).trim();if(!e)continue;const n=e.toLowerCase();if(["quit","q","exit","menu","back"].includes(n))return void console.log(chalk.gray(o?"\n 已退出。\n":"\n Left the demo.\n"));if("open"===n){m?p(m,o):console.log(chalk.yellow(o?" 还没渲染过。先描述一个场景。":" Nothing rendered yet — describe a scene first."));continue}if(["zh","en","lang zh","lang en"].includes(n))return runGfssm(n.endsWith("zh")?"zh":"en");const t=e.match(/^(改|refine|more|微调)\s+(.+)/i);if(t){if(!h){console.log(chalk.yellow(o?" 还没有可微调的上一段。先描述一个场景。":" Nothing to refine yet — describe a scene first."));continue}console.log(chalk.gray(o?" 在上一段基础上修改…":" refining the last clip…")),await w(t[2],o,h)}else await w(e,o,null);console.log(),b(o)}}finally{!function(){const e=a();if(e){e.removeAllListeners("line"),g&&(e.prompt=g);for(const o of d)e.on("line",o);d=[],g=null,u=null}}()}}export function registerGfssmCommand(e){e.command("gfssm [lang]",{hidden:!0}).description("SPACE SCHOLAR — hidden natural-language render demo").action(async e=>{try{await runGfssm(e||"en")}catch(e){const o=e instanceof Error?e.message:String(e);if("__REPL_NO_EXIT__"===o)throw e;console.log(chalk.yellow("\n gfssm ended: "+o))}})}
|