fluxflow-cli 4.3.4 → 4.3.5

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{$ as l,R as b,S as c,T as d,U as e,V as f,W as g,X as h,Y as i,Z as j,_ as k}from"./chunk-ZZAYAU4R.js";import"./chunk-ACHIC75V.js";import{c as a}from"./chunk-TKIVOTJ4.js";import"./chunk-SIINYZWE.js";import"./chunk-I27MASHH.js";import"./chunk-56EJGQU3.js";import"./chunk-GKFFLQSG.js";export{i as compressHistory,b as convertChannelThinkTags,j as deleteChatSummary,k as getAIStream,c as getCleanGroupedLength,f as getGoogleClient,h as initAI,a as isModelMultimodal,e as isTerminationSignaled,g as runJanitorTask,l as runSubagent,d as signalTermination};
1
+ import{$ as l,R as b,S as c,T as d,U as e,V as f,W as g,X as h,Y as i,Z as j,_ as k}from"./chunk-KQY7AHN3.js";import"./chunk-ACHIC75V.js";import{c as a}from"./chunk-TKIVOTJ4.js";import"./chunk-SIINYZWE.js";import"./chunk-I27MASHH.js";import"./chunk-56EJGQU3.js";import"./chunk-GKFFLQSG.js";export{i as compressHistory,b as convertChannelThinkTags,j as deleteChatSummary,k as getAIStream,c as getCleanGroupedLength,f as getGoogleClient,h as initAI,a as isModelMultimodal,e as isTerminationSignaled,g as runJanitorTask,l as runSubagent,d as signalTermination};
@@ -1,4 +1,4 @@
1
- import{e as ci}from"./chunk-3JTGIHTN.js";import{A as Bi,B as ir,C as vi,D as Di,E as lr,F as ar,G as wt,H as Vo,I as os,J as ki,K as Ii,L as Ai,M as Li,N as Oi,O as ns,P as jo,Q as dr,T as Ni,W as Fi,X as Ln,Y as Ui,Z as Xi,_ as $i,a as it,b as ht,c as dt,d as wi,e as Zr,f as Rr,g as kn,h as yi,i as xo,j as bi,k as je,l as qe,m as rr,n as In,o as es,p as Si,q as dn,r as Ht,s as Ci,t as An,u as ko,v as cn,w as sr,x as ts,y as Mi,z as Ei}from"./chunk-ZZAYAU4R.js";import{b as an,c as zr,k as Ti}from"./chunk-ACHIC75V.js";import{a as fi,b as hi,c as xi,e as Do,f as no,g as pi,h as Jr,i as Mt}from"./chunk-TKIVOTJ4.js";import{c as ui,d as mi,e as gi}from"./chunk-SIINYZWE.js";import{a as ln,b as Dn,c as ho,d as nr,e as qr,j as Qr}from"./chunk-I27MASHH.js";import{a as Pi}from"./chunk-56EJGQU3.js";import"./chunk-GKFFLQSG.js";import Es from"os";import e,{useState as q,useEffect as Qe,useRef as Ye,useMemo as hn}from"react";import{Box as c,Text as i,useInput as Cd,useStdout as Md,Static as Ed}from"ink";import Bd from"ink-spinner";import rt from"fs-extra";import Dt from"path";import{exec as yr}from"child_process";import{fileURLToPath as vd}from"url";import Ot,{useState as cr,useEffect as rs,useMemo as On,useCallback as ql,useRef as po}from"react";import{Box as Ql,Text as Rt,useInput as zl}from"ink";function Jl(t,g){return t.replace(/\t/g," ".repeat(g))}function ur(t){return t==null?"":t.replace(/\r\n/g,`
1
+ import{e as ci}from"./chunk-3JTGIHTN.js";import{A as Bi,B as ir,C as vi,D as Di,E as lr,F as ar,G as wt,H as Vo,I as os,J as ki,K as Ii,L as Ai,M as Li,N as Oi,O as ns,P as jo,Q as dr,T as Ni,W as Fi,X as Ln,Y as Ui,Z as Xi,_ as $i,a as it,b as ht,c as dt,d as wi,e as Zr,f as Rr,g as kn,h as yi,i as xo,j as bi,k as je,l as qe,m as rr,n as In,o as es,p as Si,q as dn,r as Ht,s as Ci,t as An,u as ko,v as cn,w as sr,x as ts,y as Mi,z as Ei}from"./chunk-KQY7AHN3.js";import{b as an,c as zr,k as Ti}from"./chunk-ACHIC75V.js";import{a as fi,b as hi,c as xi,e as Do,f as no,g as pi,h as Jr,i as Mt}from"./chunk-TKIVOTJ4.js";import{c as ui,d as mi,e as gi}from"./chunk-SIINYZWE.js";import{a as ln,b as Dn,c as ho,d as nr,e as qr,j as Qr}from"./chunk-I27MASHH.js";import{a as Pi}from"./chunk-56EJGQU3.js";import"./chunk-GKFFLQSG.js";import Es from"os";import e,{useState as q,useEffect as Qe,useRef as Ye,useMemo as hn}from"react";import{Box as c,Text as i,useInput as Cd,useStdout as Md,Static as Ed}from"ink";import Bd from"ink-spinner";import rt from"fs-extra";import Dt from"path";import{exec as yr}from"child_process";import{fileURLToPath as vd}from"url";import Ot,{useState as cr,useEffect as rs,useMemo as On,useCallback as ql,useRef as po}from"react";import{Box as Ql,Text as Rt,useInput as zl}from"ink";function Jl(t,g){return t.replace(/\t/g," ".repeat(g))}function ur(t){return t==null?"":t.replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
3
  `)}function Ko(t,g,h){let S=t,T=[...g].sort((s,v)=>s.start-v.start),p=0;for(let s of T){let v=s.start-p,u=ur(s.text).split(`
4
4
  `).length,E=s.text.length,M=(u>3?`[Pasted ${u} lines]`:`[Pasted ${E} chars]`).length,X=v+M;if(t<=v)break;if(t<X){S=s.end;break}else{let B=s.text.length-M;S+=B,p+=B}}return Math.min(S,h.length)}function ss(t,g,h,S,T=[]){let p=(t||"").slice(0,g),s=S(p).length,v=S(t||""),u=[...T].sort((O,L)=>L.start-O.start);for(let O of u){let L=S(t.slice(0,O.start)).length,$=S(O.text),ee=L+$.length,ae=ur(O.text).split(`
@@ -426,14 +426,14 @@ Stack: ${a.stack}`:"";return`ERROR: Failed to map file: ${i}${p}`}};import zn fr
426
426
  ${l}`}return`SUCCESS: TASK LIST CREATED (${u} total)
427
427
  ${l}`}if(t==="append"){if(!o)return'ERROR: Missing "tasks" for append method.';let l=d(o);await mt.recordFileChange(i),zn.appendFileSync(i,l,"utf8");let f=zn.readFileSync(i,"utf8"),u=f.split(/\r?\n/).map(m=>m.trim()),h=u.filter(m=>m.startsWith("- [ ]")||m.startsWith("- [x]")||m.startsWith("- [X]")).length,g=u.filter(m=>m.startsWith("- [x]")||m.startsWith("- [X]")).length,y=l.split(/\r?\n/).map(m=>m.trim()).filter(m=>m.startsWith("- [ ]")||m.startsWith("- [x]")||m.startsWith("- [X]")).length;return`SUCCESS: TASK APPENDED (${g} completed, ${h-g} left, ${y} added)
428
428
  ${f}`}if(t==="get"){if(!zn.existsSync(i))return"TODO GET: No task list found for this session.";let l=zn.readFileSync(i,"utf8"),f=0;if(s){let m=c(l,s);m.markedCount>0&&(l=m.content,f=m.markedCount,await mt.recordFileChange(i),zn.writeFileSync(i,l,"utf8"))}let u=l.split(/\r?\n/).map(m=>m.trim()),h=u.filter(m=>m.startsWith("- [ ]")||m.startsWith("- [x]")||m.startsWith("- [X]")).length,g=u.filter(m=>m.startsWith("- [x]")||m.startsWith("- [X]")).length;return`${f>0?`SUCCESS: ${f} TASK(S) MARKED DONE`:"TODO GET"}: ${g} Completed, ${h-g} left
429
- ${l}`}return`ERROR: Unknown method "${t}". Use create, append, or get.`}catch(l){return`ERROR: Todo tool failure: ${l instanceof Error?l.message:String(l)}`}};var Ir=async(e,n={})=>{let{runSubagent:t}=await import("./ai-OTNVN773.js"),o=O(e),s=o.task||o.instruction||o.prompt,r=o.model||null,a=o.tools||null;if(!s)return'ERROR: Missing "task" argument for invokeSync.';let i=null;if(a)try{let d=a.trim();d.startsWith("[")&&d.endsWith("]")&&(d=d.substring(1,d.length-1)),i=d.split(",").map(c=>c.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let p=o.title||s.substring(0,30);try{n.onVisualFeedback&&n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p}`);let d=await t(s,n,r,i,50);return n.onVisualFeedback&&n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p} [COMPLETED]
430
- `),d}catch(d){let{isTerminationSignaled:c}=await import("./ai-OTNVN773.js"),l=d.message==="Subagent task was cancelled by user."||c();if(n.onVisualFeedback){let f=l?"[CANCELLED]":"[FAILED]";n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p} ${f}
431
- `)}return`ERROR: Subagent execution failed: ${d.message}`}};var aa=async(e,n={})=>{let{runSubagent:t}=await import("./ai-OTNVN773.js"),o=O(e),s=o.task||o.instruction||o.prompt,r=o.model||null,a=o.title||null,i=o.tools||null;if(!s)return'ERROR: Missing "task" argument for invoke.';let p=null;if(i)try{let m=i.trim();m.startsWith("[")&&m.endsWith("]")&&(m=m.substring(1,m.length-1)),p=m.split(",").map(w=>w.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let d=`subagent-${Date.now()}-${Math.floor(Math.random()*1e3)}`,c=null,l=null,f=new Promise((m,w)=>{c=m,l=w}),u={id:d,title:a||s.substring(0,30),task:s,status:"running",startedAt:Date.now(),lastChunkTime:Date.now(),wps:0,questions:[],pendingSteerMessages:[],steer:m=>{m&&u.pendingSteerMessages.push(m)},completionPromise:f,_resolveCompletion:c,_rejectCompletion:l,progress:[]},h={chunks:[],totalWords:0};Xe.push(u),n.onSubagentUpdate&&n.onSubagentUpdate();let g=[],y={...n,taskId:d,onAskMain:async m=>{let w=`q-${Date.now()}-${Math.floor(Math.random()*1e3)}`,b=null,T=new Promise(k=>{b=k}),$={id:w,question:m,answered:!1,answer:null,askedAt:Date.now(),_resolve:b};return u.questions.push($),u.status="waiting",n.onSubagentUpdate&&n.onSubagentUpdate(),bo(`[SYSTEM] Background subagent "${u.title}" is WAITING FOR YOUR INPUT: "${m}"
429
+ ${l}`}return`ERROR: Unknown method "${t}". Use create, append, or get.`}catch(l){return`ERROR: Todo tool failure: ${l instanceof Error?l.message:String(l)}`}};var Ir=async(e,n={})=>{let{runSubagent:t}=await import("./ai-2XH7RHUX.js"),o=O(e),s=o.task||o.instruction||o.prompt,r=o.model||null,a=o.tools||null;if(!s)return'ERROR: Missing "task" argument for invokeSync.';let i=null;if(a)try{let d=a.trim();d.startsWith("[")&&d.endsWith("]")&&(d=d.substring(1,d.length-1)),i=d.split(",").map(c=>c.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let p=o.title||s.substring(0,30);try{n.onVisualFeedback&&n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p}`);let d=await t(s,n,r,i,50);return n.onVisualFeedback&&n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p} [COMPLETED]
430
+ `),d}catch(d){let{isTerminationSignaled:c}=await import("./ai-2XH7RHUX.js"),l=d.message==="Subagent task was cancelled by user."||c();if(n.onVisualFeedback){let f=l?"[CANCELLED]":"[FAILED]";n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p} ${f}
431
+ `)}return`ERROR: Subagent execution failed: ${d.message}`}};var aa=async(e,n={})=>{let{runSubagent:t}=await import("./ai-2XH7RHUX.js"),o=O(e),s=o.task||o.instruction||o.prompt,r=o.model||null,a=o.title||null,i=o.tools||null;if(!s)return'ERROR: Missing "task" argument for invoke.';let p=null;if(i)try{let m=i.trim();m.startsWith("[")&&m.endsWith("]")&&(m=m.substring(1,m.length-1)),p=m.split(",").map(w=>w.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let d=`subagent-${Date.now()}-${Math.floor(Math.random()*1e3)}`,c=null,l=null,f=new Promise((m,w)=>{c=m,l=w}),u={id:d,title:a||s.substring(0,30),task:s,status:"running",startedAt:Date.now(),lastChunkTime:Date.now(),wps:0,questions:[],pendingSteerMessages:[],steer:m=>{m&&u.pendingSteerMessages.push(m)},completionPromise:f,_resolveCompletion:c,_rejectCompletion:l,progress:[]},h={chunks:[],totalWords:0};Xe.push(u),n.onSubagentUpdate&&n.onSubagentUpdate();let g=[],y={...n,taskId:d,onAskMain:async m=>{let w=`q-${Date.now()}-${Math.floor(Math.random()*1e3)}`,b=null,T=new Promise(k=>{b=k}),$={id:w,question:m,answered:!1,answer:null,askedAt:Date.now(),_resolve:b};return u.questions.push($),u.status="waiting",n.onSubagentUpdate&&n.onSubagentUpdate(),bo(`[SYSTEM] Background subagent "${u.title}" is WAITING FOR YOUR INPUT: "${m}"
432
432
  Respond using tool: [tool:functions.Answer(id="${d}", answer="...")]
433
433
  [/SYSTEM]`),await T},onVisualFeedback:m=>{u.lastChunkTime=Date.now();let w=m.replace(/\x1b\[[0-9;]*m/g,""),b=w.match(/[✔✘✗✖🔍📖→➕↻•]\s*([A-Za-z0-9\s-]+)/);b?u.currentTool=b[1].trim():u.currentTool=w,n.onSubagentUpdate&&n.onSubagentUpdate()},onTokenChunk:(m,w)=>{let b=Date.now();if(u.lastChunkTime=b,u.currentTool="Thinking",typeof w=="number"&&w>0){h.totalWords+=w,h.chunks.push({time:b,words:w});let T=b-400;if(h.chunks=h.chunks.filter($=>$.time>=T),h.chunks.length>0){let $=h.chunks.reduce((S,_)=>S+_.words,0),R=h.chunks[0].time,k=Math.max(.4,(b-R)/1e3);u.wps=Math.round($/k*10)/10}}n.onSubagentUpdate&&n.onSubagentUpdate()}};return t(s,y,r,p,50,m=>{if(u.status==="cancelled")return;if(m.startsWith("[Subagent Turn")&&g.length>0&&(u.progress.push([...g]),g=[]),m.includes("[Executing Tool]")){let b=m.match(/\[Executing Tool\]\s*([a-zA-Z0-9_]+)/);b&&(!u.currentTool||u.currentTool==="Thinking")&&(u.currentTool=b[1])}let w=m;if(w.startsWith("[Tool Result]")){let b=w.split(`
434
434
  `);b.length>5&&(w=b.slice(0,4).join(`
435
435
  `)+`
436
- ... [Content/Diff Truncated from Logs] ...`)}g.push(w),n.onSubagentUpdate&&n.onSubagentUpdate()},!0).then(m=>{if(u.status==="cancelled"){u._resolveCompletion&&u._resolveCompletion(m);return}g.length>0&&(u.progress.push([...g]),g=[]),u.status="completed",u.finalAnswer=m,n.onSubagentUpdate&&n.onSubagentUpdate(),bo(`[SYSTEM] Background subagent "${u.title}" (id: ${d}) has FINISHED. Call GetProgress(id="${d}") to see the final result. [/SYSTEM]`),u._resolveCompletion&&u._resolveCompletion(m)}).catch(async m=>{let{isTerminationSignaled:w}=await import("./ai-OTNVN773.js");if(m.message==="Subagent task was cancelled."||u.status==="cancelled"||w()){u.status="cancelled",g.push("[SUBAGENT CANCELLED] Task was cancelled."),u.progress.push([...g]),n.onSubagentUpdate&&n.onSubagentUpdate(),u._resolveCompletion&&u._resolveCompletion(null);return}g.push(`[SUBAGENT FAILURE] Error: ${m.message}`),u.progress.push([...g]),u.status="failed",u.error=m.message,n.onSubagentUpdate&&n.onSubagentUpdate(),bo(`[SYSTEM] Background subagent "${u.title}" (id: ${d}) FAILED with error: ${m.message}. [/SYSTEM]`),u._rejectCompletion&&u._rejectCompletion(m)}),`SUCCESS: Background subagent started. Task ID: ${d}`};var Or=async(e,n={})=>{let o=O(e).id;if(!o)return'ERROR: Missing "id" argument for getProgress.';let s=Xe.find(i=>i.id===o);if(!s)return`ERROR: Subagent task with ID [${o}] not found.`;let r=`Subagent Task Status: ${s.status.toUpperCase()}
436
+ ... [Content/Diff Truncated from Logs] ...`)}g.push(w),n.onSubagentUpdate&&n.onSubagentUpdate()},!0).then(m=>{if(u.status==="cancelled"){u._resolveCompletion&&u._resolveCompletion(m);return}g.length>0&&(u.progress.push([...g]),g=[]),u.status="completed",u.finalAnswer=m,n.onSubagentUpdate&&n.onSubagentUpdate(),bo(`[SYSTEM] Background subagent "${u.title}" (id: ${d}) has FINISHED. Call GetProgress(id="${d}") to see the final result. [/SYSTEM]`),u._resolveCompletion&&u._resolveCompletion(m)}).catch(async m=>{let{isTerminationSignaled:w}=await import("./ai-2XH7RHUX.js");if(m.message==="Subagent task was cancelled."||u.status==="cancelled"||w()){u.status="cancelled",g.push("[SUBAGENT CANCELLED] Task was cancelled."),u.progress.push([...g]),n.onSubagentUpdate&&n.onSubagentUpdate(),u._resolveCompletion&&u._resolveCompletion(null);return}g.push(`[SUBAGENT FAILURE] Error: ${m.message}`),u.progress.push([...g]),u.status="failed",u.error=m.message,n.onSubagentUpdate&&n.onSubagentUpdate(),bo(`[SYSTEM] Background subagent "${u.title}" (id: ${d}) FAILED with error: ${m.message}. [/SYSTEM]`),u._rejectCompletion&&u._rejectCompletion(m)}),`SUCCESS: Background subagent started. Task ID: ${d}`};var Or=async(e,n={})=>{let o=O(e).id;if(!o)return'ERROR: Missing "id" argument for getProgress.';let s=Xe.find(i=>i.id===o);if(!s)return`ERROR: Subagent task with ID [${o}] not found.`;let r=`Subagent Task Status: ${s.status.toUpperCase()}
437
437
  `;if(r+=`Title: ${s.title}
438
438
  `,r+=`Task: ${s.task}
439
439
  `,s.startedAt){let i=Math.floor((Date.now()-s.startedAt)/1e3);r+=`Elapsed Time: ${i}s
@@ -507,7 +507,7 @@ ${l[7]}`};import{WebSocket as No}from"ws";var Yt=null,Fs=!1,ic="ws://localhost:5
507
507
  `),g=u.toLowerCase().includes("tool:functions.")||u.toLowerCase().includes("agent:generalist.");a.push(u),g&&h?p=!0:p=!1}}}),d()}}return t.length},Cc=e=>typeof e!="string"?e:e.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),xs=async(e,n,t=5,o=1e3)=>{let s=n?.signal;for(let a=0;a<t;a++){if(s?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{let i=await fetch(e,n);if(typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),i.ok||i.status!==429&&i.status<500)return i}catch(i){if(typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),i.name==="AbortError"||s?.aborted||a===t-1)throw i}s?await new Promise((i,p)=>{let d=setTimeout(()=>{s.removeEventListener("abort",c),i()},Math.min(24e3,o*Math.pow(2,a))),c=()=>{clearTimeout(d),p(new DOMException("The user aborted a request.","AbortError"))};s.addEventListener("abort",c)}):await new Promise(i=>setTimeout(i,Math.min(24e3,o*Math.pow(2,a))))}if(s?.aborted)throw new DOMException("The user aborted a request.","AbortError");let r=await fetch(e,n);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),r};async function Pa(e){let n=new TextEncoder().encode(e),t=await crypto.subtle.digest("SHA-256",n);return[...new Uint8Array(t).slice(0,16)].map(o=>o.toString(16).padStart(2,"0")).join("")}var ti=async function*(e,n,t,o,s,r,a,i,p=1){let d=[];o&&d.push({role:"system",content:o});for(let b of t){let T=b.role==="user"?"user":"assistant",$=[];if(Array.isArray(b.parts)){for(let R of b.parts)if(R.text)$.push({type:"text",text:R.text});else if(R.inlineData&&a){let k=R.inlineData.mimeType,S=R.inlineData.data;k.startsWith("image/")&&$.push({type:"image_url",image_url:{url:`data:${k};base64,${S}`}})}}else{let R=b.text||"";R&&$.push({type:"text",text:R})}d.push({role:T,content:$.length===1&&$[0].type==="text"?$[0].text:$})}let c={model:n,messages:d,stream:!0,stream_options:{include_usage:!0},temperature:p};if(s!=="Fast"){let b={Low:"high",Medium:"high",Standard:"high",High:"max",xHigh:"max"};c.reasoning_effort=b[s]||"high",c.extra_body={thinking:{type:"enabled"}}}else c.extra_body={thinking:{type:"disabled"}};let l=await xs("https://api.deepseek.com/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(c),signal:i});if(!l.ok){let b=await l.json().catch(()=>({}));throw new Error(`DeepSeek Error (${l.status}): ${b.error?.message||l.statusText}`)}let f=l.body.getReader(),u=new TextDecoder,h="",g=[],y=null,m=Date.now(),w=!1;for(;;){let{done:b,value:T}=await f.read();if(b){w&&(g.length>0||y)&&(yield{candidates:g.length>0?[{content:{parts:g}}]:[],usageMetadata:y});break}h+=u.decode(T,{stream:!0});let $=h.split(`
508
508
  `);h=$.pop();for(let R of $){let k=R.trim();if(!k||!k.startsWith("data: "))continue;let S=!1;if(k==="data: [DONE]")S=!0;else try{let _=JSON.parse(k.substring(6)),E=_.choices?.[0]?.delta,x=_.usage;if(_.choices?.[0]?.finish_reason&&(S=!0),x&&(y={totalTokenCount:x.total_tokens||x.prompt_tokens+x.completion_tokens,promptTokenCount:x.prompt_tokens||0,candidatesTokenCount:x.completion_tokens||0,cachedContentTokenCount:x.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:x.completion_tokens_details?.reasoning_tokens||0},w=!0),E){let C=E.reasoning_content||null;C&&(g.push({text:C,thought:!0}),w=!0),E.content&&(g.push({text:E.content}),w=!0)}}catch{}if((S||Date.now()-m>=150)&&w&&(yield{candidates:g.length>0?[{content:{parts:[...g]}}]:[],usageMetadata:y},g=[],m=Date.now(),w=!1),S)break}Date.now()-m>=150&&w&&(yield{candidates:g.length>0?[{content:{parts:[...g]}}]:[],usageMetadata:y},g=[],m=Date.now(),w=!1)}},ni=async function*(e,n,t,o,s,r,a,i,p=1,d=null){let c=[];o&&c.push({role:"system",content:o});for(let S of t){let _=S.role==="user"?"user":"assistant",E=[];if(Array.isArray(S.parts)){for(let x of S.parts)if(x.text)E.push({type:"text",text:x.text});else if(x.inlineData&&a){let C=x.inlineData.mimeType,I=x.inlineData.data;C.startsWith("image/")&&E.push({type:"image_url",image_url:`data:${C};base64,${I}`})}}else{let x=S.text||"";x&&E.push({type:"text",text:x})}E.length>0&&c.push({role:_,content:E.length===1&&E[0].type==="text"?E[0].text:E})}let l={Fast:"none",Low:"none",Medium:"high",Standard:"high",High:"high",xHigh:"high"},f=`${e.slice(-5)}${d||""}${s}${n}`,u=await Pa(f),h={model:n,messages:c,stream:!0,temperature:p,prompt_cache_key:u};s&&s!=="Fast"&&qs(n)&&(h.reasoning_effort=l[s]||"high");let g=await xs("https://api.mistral.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(h),signal:i});if(!g.ok){let S=await g.text().catch(()=>""),_=g.statusText;try{let E=JSON.parse(S);_=E.error?.message||E.message||JSON.stringify(E.detail||E)}catch{S&&(_=S)}throw new Error(`Mistral Error (${g.status}): ${JSON.stringify(_)}`)}let y=g.body.getReader(),m=new TextDecoder,w="",b=[],T=null,$=Date.now(),R=!1,k=S=>S?typeof S=="string"?Pn(S):Array.isArray(S)?S.map(k).filter(Boolean).join(""):typeof S=="object"&&S!==null?typeof S.text=="string"?Pn(S.text):typeof S.content=="string"?Pn(S.content):typeof S.thinking=="string"?Pn(S.thinking):typeof S.reasoning_content=="string"?Pn(S.reasoning_content):typeof S.reasoning=="string"?Pn(S.reasoning):typeof S.value=="string"?Pn(S.value):S.text?k(S.text):S.content?k(S.content):S.thinking?k(S.thinking):S.reasoning_content?k(S.reasoning_content):S.reasoning?k(S.reasoning):S.value?k(S.value):"":Pn(String(S)):"";for(;;){let{done:S,value:_}=await y.read();if(S){R&&(b.length>0||T)&&(yield{candidates:b.length>0?[{content:{parts:b}}]:[],usageMetadata:T});break}w+=m.decode(_,{stream:!0});let E=w.split(`
509
509
  `);w=E.pop();for(let x of E){let C=x.trim();if(!C||!C.startsWith("data: "))continue;let I=!1;if(C==="data: [DONE]")I=!0;else try{let L=JSON.parse(C.substring(6)),N=L.choices?.[0]?.delta,W=L.usage;if(L.choices?.[0]?.finish_reason&&(I=!0),W&&(T={totalTokenCount:W.total_tokens||(W.prompt_tokens||0)+(W.completion_tokens||0),promptTokenCount:W.prompt_tokens||0,candidatesTokenCount:W.completion_tokens||0,cachedContentTokenCount:W.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:W.completion_tokens_details?.reasoning_tokens||0},R=!0),N){let X=N.thinking||N.reasoning_content||N.reasoning,re=k(X);re&&(b.push({text:re,thought:!0}),R=!0);let Y=N.content||(!N.thinking&&!N.reasoning_content&&!N.reasoning?N.text:null);if(Y)if(Array.isArray(Y))for(let F of Y)if(typeof F=="object"&&F!==null){let U=F.type==="thinking"||F.type==="reasoning"||!!F.thought,se=k(F);se&&(b.push({text:se,...U?{thought:!0}:{}}),R=!0)}else{let U=k(F);U&&(b.push({text:U}),R=!0)}else if(typeof Y=="object"&&Y!==null){let F=Y.type==="thinking"||Y.type==="reasoning"||!!Y.thought,U=k(Y);U&&(b.push({text:U,...F?{thought:!0}:{}}),R=!0)}else{let F=k(Y);F&&(b.push({text:F}),R=!0)}}}catch{}if((I||Date.now()-$>=150)&&R&&(yield{candidates:b.length>0?[{content:{parts:[...b]}}]:[],usageMetadata:T},b=[],$=Date.now(),R=!1),I)break}Date.now()-$>=150&&R&&(yield{candidates:b.length>0?[{content:{parts:[...b]}}]:[],usageMetadata:T},b=[],$=Date.now(),R=!1)}},si=async function*(e,n,t,o,s,r,a=!1,i,p=1){let d=[];o&&d.push({role:"system",content:o}),t.forEach(se=>{let $e=se.role==="model"?"assistant":"user",A=[];Array.isArray(se.parts)&&se.parts.forEach(B=>{if(B.text)A.push({type:"text",text:B.text});else if(B.inlineData&&a){let V=B.inlineData.mimeType,J=B.inlineData.data;V.startsWith("image/")&&zt(n)&&A.push({type:"image_url",image_url:{url:`data:${V};base64,${J}`}})}}),d.push({role:$e,content:A.length===1&&A[0].type==="text"?A[0].text:A})});let l={Fast:"Fast",Low:"Fast",Medium:"Standard",Standard:"Standard",High:"High",xHigh:"High"}[s]||"High",f=l!=="Fast",u=n.includes("kimi"),h=n.includes("gemma"),g=n.includes("deepseek"),y=n.includes("glm"),m=n.includes("mistral"),w=n.includes("minimax"),b=n.includes("gpt"),T=n.includes("qwen"),$=n.includes("nemotron"),R=n.includes("llama-3"),k=n.includes("seed"),S=n.includes("poolside"),_=n.includes("thinkingmachines")||n.includes("muse"),E=R,x=null,C={Fast:"low",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},I={Fast:"64",Low:"64",Medium:"4096",Standard:"4096",High:"16384",xHigh:"16384"},L={Fast:"none",Low:"minimal",Medium:"medium",Standard:"medium",High:"max",xHigh:"max"},N=w||g||S||_?16384:32768;N=process.env.NVIDIA_BASE_URL?1024:N,N=x?1024:N;let W={model:n,messages:d,max_tokens:N,stream:!0,stream_options:{include_usage:!0},temperature:p,...b&&{thinking:C[s]||"high"}};if(!(process.env.NVIDIA_BASE_URL||E||x))if(u)W.chat_template_kwargs={thinking:f};else if(h)W.chat_template_kwargs={enable_thinking:f};else if(g)if(f){let se=l==="High"?"max":"high";W.chat_template_kwargs={thinking:!0,reasoning_effort:se}}else W.chat_template_kwargs={thinking:!1};else y?W.chat_template_kwargs={enable_thinking:f,clear_thinking:!f}:m?W.reasoning_effort=f?"high":"none":w&&n.includes("minimax-m3")?W.chat_template_kwargs={thinking_mode:f?"enabled":"disabled"}:T?W.chat_template_kwargs={enable_thinking:f}:$?l==="High"?(W.reasoning_budget=12e3,W.chat_template_kwargs={enable_thinking:!0}):l==="Standard"?(W.reasoning_budget=12e3,W.chat_template_kwargs={enable_thinking:!0,medium_effort:!0}):W.chat_template_kwargs={enable_thinking:!1}:k?f&&(W.extra_body={thinking_budget:parseInt(I[l]??"4096")}):S?W.chat_template_kwargs={enable_thinking:f}:_&&(W.reasoning_effort=L[l]||"medium");let X=0,re=6,Y=!1,F=process.env.NVIDIA_BASE_URL||"https://integrate.api.nvidia.com/v1/chat/completions",U=process.env.NVIDIA_API_KEY&&process.env.NVIDIA_BASE_URL?process.env.NVIDIA_API_KEY:e;for(F.endsWith("/chat/completions")||(F=F.replace(/\/+$/,"")+"/chat/completions");X<re;){X++;try{let se=await xs(F,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${U}`},body:JSON.stringify(W),signal:i});if(!se.ok){let je=await se.text().catch(()=>""),it=se.statusText;try{let gt=JSON.parse(je);it=gt.error?.message||gt.message||JSON.stringify(gt.detail||gt)}catch{je&&(it=je)}let ze=new Error(`NVIDIA API Error (${se.status}): ${it}`);throw ze.status=se.status,ze}let $e=se.body.getReader(),A=new TextDecoder,B="",V=[],J=null,Ue=Date.now(),Fe=!1;for(;;){let{done:je,value:it}=await $e.read();if(je){Fe&&(V.length>0||J)&&(yield{candidates:V.length>0?[{content:{parts:V}}]:[],usageMetadata:J},Y=!0);break}B+=A.decode(it,{stream:!0});let ze=B.split(`
510
- `);B=ze.pop();let gt=!1;for(let Bt of ze){let yt=Bt.trim();if(yt){if(yt==="data: [DONE]"){gt=!0;break}if(yt.startsWith("data: ")){let wt;try{wt=JSON.parse(yt.substring(6))}catch{continue}if(wt.error)throw new Error(`NVIDIA Stream Error: ${wt.error.message||JSON.stringify(wt.error)}`);wt.choices?.[0]?.finish_reason&&(gt=!0);try{let Rt=wt.usage;Rt&&(J={totalTokenCount:Rt.total_tokens||Rt.prompt_tokens+Rt.completion_tokens,promptTokenCount:Rt.prompt_tokens||0,candidatesTokenCount:Rt.completion_tokens||0,cachedContentTokenCount:Rt.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:(Rt.completion_tokens_details?.reasoning_tokens||0)+(Rt.completion_tokens_details?.thoughts_tokens||0)},Fe=!0);let ut=wt.choices?.[0]?.delta?.reasoning||wt.choices?.[0]?.delta?.reasoning_content||"",Ce=wt.choices?.[0]?.delta?.content||"";ut&&(V.push({text:ut,thought:!0}),Fe=!0),Ce&&(V.push({text:Ce}),Fe=!0)}catch{}}}}if((gt||Date.now()-Ue>=350)&&Fe&&(yield{candidates:V.length>0?[{content:{parts:[...V]}}]:[],usageMetadata:J},Y=!0,V=[],Ue=Date.now(),Fe=!1),gt)break}break}catch(se){if(Y||X>=re)throw se;await new Promise($e=>setTimeout($e,3500))}}},Mc=async function*(e,n){let t=[],o=null,s=!1,r=null,a=f=>{if(t.push(f),o){let u=o;o=null,u()}},i=n.split("/").pop();i=i.replace("llama-3.3","llama-3_3");let p=`https://api.ngc.nvidia.com/v2/predict/queues/models/qc69jvmznzxy/${i}`,d=!1,c=null,l=async()=>{try{let f=await fetch(p);if(f.ok){let u=await f.json();if(u&&u.queues&&u.queues[0]&&typeof u.queues[0].queueDepth=="number"){let h=u.queues[0].queueDepth;d||a({value:{type:"status",content:`Queue ${h||1}`},done:!1})}}else d||a({value:{type:"status",content:`Queue ${f.status}`},done:!1})}catch{}};process.env.NVIDIA_BASE_URL||(l(),c=setInterval(l,5e3)),(async()=>{try{let f=e[Symbol.asyncIterator]();for(;;){let{value:u,done:h}=await f.next();if(h)break;d=!0,c&&(clearInterval(c),c=null),a({value:u,done:!1})}s=!0,a(null)}catch(f){if(r=f,c&&(clearInterval(c),c=null),o){let u=o;o=null,u()}}})();try{for(;;){if(r)throw r;if(t.length>0){let f=t.shift();if(f===null&&s)break;yield f.value}else{if(s)break;await new Promise(f=>{o=f})}}}finally{c&&(clearInterval(c),c=null)}},oi=async function*(e,n,t,o,s,r,a,i,p=1,d=null){let c=[];o&&c.push({role:"system",content:[{type:"text",text:o}]});for(let x of t){let C=x.role==="user"?"user":"assistant",I=[];if(Array.isArray(x.parts)){for(let L of x.parts)if(L.text)I.push({type:"text",text:L.text});else if(L.inlineData&&a){let N=L.inlineData.mimeType,W=L.inlineData.data;N.startsWith("image/")?I.push({type:"image_url",image_url:{url:`data:${N};base64,${W}`}}):I.push({type:"file",file:{filename:L.filename||"file",file_data:`data:${N};base64,${W}`}})}}else{let L=x.text||"";L&&I.push({type:"text",text:L})}c.push({role:C,content:I.length===1&&I[0].type==="text"?I[0].text:I})}let l={Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},f=n,u=null;if(f.includes("::")){let x=f.split("::");f=x[0].trim();let C=x.slice(1).join("::").toLowerCase().trim();["flex","priority","default"].includes(C)&&C!=="default"&&(u=C)}let h=f;if(f.includes(":")){let[x,...C]=f.split(":"),I=C.join(":").toLowerCase().trim();u?h=`${x}:${I}/${u}`:h=`${x}:${I}`}let g=`${e.slice(-5)}${d||""}${s}${h}`,y=await Pa(g),m={model:h,messages:c,stream:!0,temperature:p,cache_control:{type:"ephemeral"},session_id:y},w=l[s];w&&s!=="Fast"&&(m.reasoning_effort=w);let b=await xs("https://openrouter.ai/api/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-Title":"FluxFlow CLI","X-Cache":"true","X-OpenRouter-Cache":"true"},body:JSON.stringify(m),signal:i});if(!b.ok){let x=await b.json().catch(()=>({}));throw new Error(`OpenRouter Error (${b.status}): ${x.error?.metadata.raw||x.error?.message||b.statusText}`)}let T=b.body.getReader(),$=new TextDecoder,R="",k=[],S=null,_=Date.now(),E=!1;for(;;){let{done:x,value:C}=await T.read();if(x){E&&(k.length>0||S)&&(yield{candidates:k.length>0?[{content:{parts:k}}]:[],usageMetadata:S});break}R+=$.decode(C,{stream:!0});let I=R.split(`
510
+ `);B=ze.pop();let gt=!1;for(let Bt of ze){let yt=Bt.trim();if(yt){if(yt==="data: [DONE]"){gt=!0;break}if(yt.startsWith("data: ")){let wt;try{wt=JSON.parse(yt.substring(6))}catch{continue}if(wt.error)throw new Error(`NVIDIA Stream Error: ${wt.error.message||JSON.stringify(wt.error)}`);wt.choices?.[0]?.finish_reason&&(gt=!0);try{let Rt=wt.usage;Rt&&(J={totalTokenCount:Rt.total_tokens||Rt.prompt_tokens+Rt.completion_tokens,promptTokenCount:Rt.prompt_tokens||0,candidatesTokenCount:Rt.completion_tokens||0,cachedContentTokenCount:Rt.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:(Rt.completion_tokens_details?.reasoning_tokens||0)+(Rt.completion_tokens_details?.thoughts_tokens||0)},Fe=!0);let ut=wt.choices?.[0]?.delta?.reasoning||wt.choices?.[0]?.delta?.reasoning_content||"",Ce=wt.choices?.[0]?.delta?.content||"";ut&&(V.push({text:ut,thought:!0}),Fe=!0),Ce&&(V.push({text:Ce}),Fe=!0)}catch{}}}}if((gt||Date.now()-Ue>=350)&&Fe&&(yield{candidates:V.length>0?[{content:{parts:[...V]}}]:[],usageMetadata:J},Y=!0,V=[],Ue=Date.now(),Fe=!1),gt)break}break}catch(se){if(Y||X>=re)throw se;await new Promise($e=>setTimeout($e,3500))}}},Mc=async function*(e,n){let t=[],o=null,s=!1,r=null,a=f=>{if(t.push(f),o){let u=o;o=null,u()}},i=n.split("/").pop();i=i.replace("llama-3.3","llama-3_3");let p=`https://api.ngc.nvidia.com/v2/predict/queues/models/qc69jvmznzxy/${i}`,d=!1,c=null,l=async()=>{try{let f=await fetch(p);if(f.ok){let u=await f.json();if(u&&u.queues&&u.queues[0]&&typeof u.queues[0].queueDepth=="number"){let h=u.queues[0].queueDepth;d||a({value:{type:"status",content:`Queue ${h||1}`},done:!1})}}else d||a({value:{type:"status",content:`Queue ${f.status}`},done:!1})}catch{}};process.env.NVIDIA_BASE_URL||(l(),c=setInterval(l,5e3)),(async()=>{try{let f=e[Symbol.asyncIterator]();for(;;){let{value:u,done:h}=await f.next();if(h)break;d=!0,c&&(clearInterval(c),c=null),a({value:u,done:!1})}s=!0,a(null)}catch(f){if(r=f,c&&(clearInterval(c),c=null),o){let u=o;o=null,u()}}})();try{for(;;){if(r)throw r;if(t.length>0){let f=t.shift();if(f===null&&s)break;yield f.value}else{if(s)break;await new Promise(f=>{o=f})}}}finally{c&&(clearInterval(c),c=null)}},oi=async function*(e,n,t,o,s,r,a,i,p=1,d=null){let c=[];o&&c.push({role:"system",content:[{type:"text",text:o}]});for(let x of t){let C=x.role==="user"?"user":"assistant",I=[];if(Array.isArray(x.parts)){for(let L of x.parts)if(L.text)I.push({type:"text",text:L.text});else if(L.inlineData&&a){let N=L.inlineData.mimeType,W=L.inlineData.data;N.startsWith("image/")?I.push({type:"image_url",image_url:{url:`data:${N};base64,${W}`}}):I.push({type:"file",file:{filename:L.filename||"file",file_data:`data:${N};base64,${W}`}})}}else{let L=x.text||"";L&&I.push({type:"text",text:L})}c.push({role:C,content:I.length===1&&I[0].type==="text"?I[0].text:I})}let l={Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},f=n,u=null;if(f.includes("::")){let x=f.split("::");f=x[0].trim();let C=x.slice(1).join("::").toLowerCase().trim();["flex","priority","default"].includes(C)&&C!=="default"&&(u=C)}let h=f;if(f.includes(":")){let[x,...C]=f.split(":"),I=C.join(":").toLowerCase().trim();u?h=`${x}:${I}/${u}`:h=`${x}:${I}`}let g=`${e.slice(-5)}${d||""}${s}${h}`,y=await Pa(g),m={model:h,messages:c,stream:!0,temperature:p,cache_control:{type:"ephemeral"},session_id:y},w=l[s];w&&s!=="Fast"&&(m.reasoning_effort=w);let b=await xs("https://openrouter.ai/api/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","HTTP-Referer":"https://fluxflow-cli.onrender.com/","X-Title":"FluxFlow CLI","X-OpenRouter-Title":"FluxFlow CLI","X-Cache":"true","X-OpenRouter-Cache":"true"},body:JSON.stringify(m),signal:i});if(!b.ok){let x=await b.json().catch(()=>({}));throw new Error(`OpenRouter Error (${b.status}): ${x.error?.metadata.raw||x.error?.message||b.statusText}`)}let T=b.body.getReader(),$=new TextDecoder,R="",k=[],S=null,_=Date.now(),E=!1;for(;;){let{done:x,value:C}=await T.read();if(x){E&&(k.length>0||S)&&(yield{candidates:k.length>0?[{content:{parts:k}}]:[],usageMetadata:S});break}R+=$.decode(C,{stream:!0});let I=R.split(`
511
511
  `);R=I.pop();for(let L of I){let N=L.trim();if(!N||!N.startsWith("data: "))continue;let W=!1;if(N==="data: [DONE]")W=!0;else try{let X=JSON.parse(N.substring(6)),re=X.choices?.[0]?.delta,Y=X.usage;if(X.choices?.[0]?.finish_reason&&(W=!0),Y&&(S={totalTokenCount:Y.total_tokens||(Y.prompt_tokens||0)+(Y.completion_tokens||0),promptTokenCount:Y.prompt_tokens||0,candidatesTokenCount:Y.completion_tokens||0,cachedContentTokenCount:Y.prompt_tokens_details?.cached_tokens||Y.prompt_tokens_details?.cache_read_input_tokens||Y.cache_read_input_tokens||0,thoughtsTokenCount:Y.completion_tokens_details?.reasoning_tokens||0},E=!0),re){let F=re.reasoning||(re.reasoning_details?re.reasoning_details.map(U=>U.text).join(""):null);F&&(k.push({text:F,thought:!0}),E=!0),re.content&&(k.push({text:re.content}),E=!0)}}catch{}if((W||Date.now()-_>=150)&&E&&(yield{candidates:k.length>0?[{content:{parts:[...k]}}]:[],usageMetadata:S},k=[],_=Date.now(),E=!1),W)break}}},Da=async function*(e,n,t,o,s,r,a,i,p=1,d="Cloud"){let c=[];o&&c.push({role:"system",content:o});for(let k of t){let S=k.role==="user"?"user":"assistant",_="",E=[];if(Array.isArray(k.parts)){_=k.parts.map(x=>x.text||"").filter(Boolean).join(`
512
512
  `);for(let x of k.parts){let C=x.inlineData||x.inline_data;C&&C.data&&E.push(C.data)}}else _=k.text||"";if(_||E.length>0){let x={role:S,content:_};E.length>0&&(x.images=E),c.push(x)}}let l=d==="Local"||!e||e==="LOCAL",u={host:l?process.env.OLLAMA_HOST||"http://127.0.0.1:11434":process.env.OLLAMA_HOST||"https://ollama.com"};!l&&e&&(u.headers={Authorization:"Bearer "+e});let h=new fc(u),g=[],y=null,m=Date.now(),w=!1,b={Fast:!1,Low:"medium",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},T=b[s]!==void 0?b[s]:!0,$={model:n,messages:c,stream:!0,think:T,keep_alive:"10m",options:{temperature:p}},R=await h.chat($);for await(let k of R){if(i?.aborted)throw new DOMException("The user aborted a request.","AbortError");if(k.message?.thinking&&(g.push({text:k.message.thinking,thought:!0}),w=!0),k.message?.content&&(g.push({text:k.message.content}),w=!0),k.done){let S=k.prompt_cached_count||0;if(!S&&k.prompt_eval_count){let _=k.prompt_eval_duration||0;_>0&&_<5e7&&(S=k.prompt_eval_count)}y={totalTokenCount:(k.prompt_eval_count||0)+(k.eval_count||0),promptTokenCount:k.prompt_eval_count||0,candidatesTokenCount:k.eval_count||0,cachedContentTokenCount:S,thoughtsTokenCount:0},w=!0}(k.done||Date.now()-m>=150&&w)&&(yield{candidates:g.length>0?[{content:{parts:[...g]}}]:[],usageMetadata:y},g=[],m=Date.now(),w=!1)}w&&(g.length>0||y)&&(yield{candidates:g.length>0?[{content:{parts:[...g]}}]:[],usageMetadata:y})},ri=async function*(e,n,t,o,s,r,a,i,p=1){let d=[];o&&d.push({role:"system",content:o});for(let T of t){let $=T.role==="user"?"user":"assistant",R=[];if(Array.isArray(T.parts)){for(let k of T.parts)if(k.text)R.push({type:"text",text:k.text});else if(k.inlineData&&a){let S=k.inlineData.mimeType,_=k.inlineData.data;S.startsWith("image/")&&R.push({type:"image_url",image_url:{url:`data:${S};base64,${_}`}})}}else{let k=T.text||"";k&&R.push({type:"text",text:k})}d.push({role:$,content:R.length===1&&R[0].type==="text"?R[0].text:R})}let c={Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},l={model:n,messages:d,stream:!0,stream_options:{include_usage:!0},temperature:p,max_completion_tokens:32768};c[s]&&(l.reasoning_effort=c[s]);let f=await xs("https://crof.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(l),signal:i});if(!f.ok){let T=await f.json().catch(()=>({}));throw new Error(`CrofAI Error (${f.status}): ${T.error?.message||f.statusText}`)}let u=f.body.getReader(),h=new TextDecoder,g="",y=[],m=null,w=Date.now(),b=!1;for(;;){let{done:T,value:$}=await u.read();if(T){b&&(y.length>0||m)&&(yield{candidates:y.length>0?[{content:{parts:y}}]:[],usageMetadata:m});break}g+=h.decode($,{stream:!0});let R=g.split(`
513
513
  `);g=R.pop();for(let k of R){let S=k.trim();if(!S||!S.startsWith("data: "))continue;let _=!1;if(S==="data: [DONE]")_=!0;else try{let E=JSON.parse(S.substring(6)),x=E.choices?.[0]?.delta,C=E.usage;if(E.choices?.[0]?.finish_reason&&(_=!0),C&&(m={totalTokenCount:C.total_tokens||(C.prompt_tokens||0)+(C.completion_tokens||0),promptTokenCount:C.prompt_tokens||0,candidatesTokenCount:C.completion_tokens||0,cachedContentTokenCount:C.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:C.completion_tokens_details?.reasoning_tokens||C.reasoning_tokens||0},b=!0),x){let I=x.reasoning_content||null;I&&(y.push({text:I,thought:!0}),b=!0),x.content&&(y.push({text:x.content}),b=!0)}}catch{}if((_||Date.now()-w>=150)&&b&&(yield{candidates:y.length>0?[{content:{parts:[...y]}}]:[],usageMetadata:m},y=[],w=Date.now(),b=!1),_)break}Date.now()-w>=150&&b&&(yield{candidates:y.length>0?[{content:{parts:[...y]}}]:[],usageMetadata:m},y=[],w=Date.now(),b=!1)}},ii=async function*(e,n,t,o,s,r,a,i,p=1){let d=[];o&&d.push({role:"system",content:o});for(let T of t){let $=T.role==="user"?"user":"assistant",R="";if(Array.isArray(T.parts))for(let k of T.parts)k.text&&(R+=(R?`
package/dist/cli.js CHANGED
@@ -57,4 +57,4 @@ Usage: fluxflow --export error`),process.exit(1)}if(T&&(console.log(`v${u}`),pro
57
57
  /docs View documentation
58
58
  /fluxflow init Create FluxFlow.md template
59
59
  /update check Check for new version
60
- /update latest Install latest release`),process.exit(0)),R){let h=t[1]||"latest";if(h==="check"){let i=t[2]==="latest";try{let f=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;f||(console.error("Error: Could not retrieve latest version."),process.exit(1)),console.log(i?`Latest version: v${f}`:f!==u?`A new version of FluxFlow is available: v${f} (current: v${u}). Run "fluxflow --update latest" to upgrade.`:`FluxFlow is up to date (v${u}).`)}catch(l){console.error("Error checking for updates:",l.message),process.exit(1)}process.exit(0)}else if(h==="latest"){console.log("Checking latest version and settings...");try{let r=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;r||(console.error("Error: Could not retrieve latest version."),process.exit(1)),r===u&&(console.log(`FluxFlow is already up to date (v${u}).`),process.exit(0));let f=async()=>{let o=(await import("react")).default,{useState:$}=o,{render:q,Box:g,Text:w}=await import("ink"),z=(await import("ink-select-input")).default,J=(await import("ink-text-input")).default;return new Promise(K=>{let Q=[{label:"NPM",value:"npm"},{label:"PNPM",value:"pnpm"},{label:"Yarn",value:"yarn"},{label:"Bun",value:"bun"},{label:"Custom Command",value:"custom"}],Z=({label:v,isSelected:b})=>o.createElement(g,{width:"100%"},o.createElement(w,{bold:b},"\u2514\u2500 ",b?"\x1B[32m\u25CF\x1B[0m":"\u25CB"," ",v)),A,ee=()=>{let[v,b]=$("select"),[te,se]=$(""),re=E=>{E.value==="custom"?b("custom"):B({manager:E.value})},ae=E=>{B({manager:"custom",customCommand:E})};return v==="custom"?o.createElement(g,{flexDirection:"column",marginY:1},o.createElement(g,{marginBottom:1},o.createElement(w,{color:"magenta",bold:!0},"\u{1F527} Enter custom update command:")),o.createElement(g,{flexDirection:"row"},o.createElement(w,{color:"cyan",bold:!0}," \u276F "),o.createElement(J,{value:te,onChange:se,onSubmit:ae})),o.createElement(g,{marginTop:1},o.createElement(w,{color:"gray",dimColor:!0,italic:!0}," (Press Enter to confirm)"))):o.createElement(g,{flexDirection:"column",marginY:1},o.createElement(g,{marginBottom:1},o.createElement(w,{color:"magenta",bold:!0},"\u{1F4E6} Select a package manager for the update:")),o.createElement(z,{items:Q,onSelect:re,itemComponent:Z,indicatorComponent:()=>null}))},B=v=>{A&&A(),K(v)},{unmount:oe}=q(o.createElement(ee,null));A=oe})},c,N="",M;try{let{loadSettings:o}=await import("./chunks/settings-NKBYU2YV.js");M=await o(),c=M?.systemSettings?.updateManager||M?.updateManager}catch{}if(!c){let o=await f();c=o.manager,N=o.customCommand}let d="";c==="pnpm"?d=`pnpm add -g fluxflow-cli@${r}`:c==="bun"?d=`bun add -g fluxflow-cli@${r}`:c==="yarn"?d=`yarn global add fluxflow-cli@${r}`:c==="custom"?d=N||M?.customUpdateCommand||`npm install -g fluxflow-cli@${r}`:d=`npm install -g fluxflow-cli@${r}`,console.log(`Updating FluxFlow to v${r} using ${c}...`),console.log(`Running: ${d}`);let{execSync:X}=await import("child_process");X(d,{stdio:"inherit"}),console.log(`\x1B[32m\u2705 Update successful! FluxFlow updated to v${r}.\x1B[0m`)}catch(i){console.error("\x1B[31m\u274C Update failed:\x1B[0m",i.message),process.exit(1)}process.exit(0)}else console.error("Unknown update command. Available options: --update, --update check, --update check latest, --update latest"),process.exit(1)}}let{default:U}=await import("react"),{render:j}=await import("ink"),{default:Y}=await import("./chunks/app-EDUR247Z.js");process.env.NODE_NO_WARNINGS="1";let G=["cuimp","Found existing binary","Binary verified","curl.exe not found","Falling back to .bat file","DeprecationWarning"],H=console.log,W=console.warn,V=console.error,S=e=>{let a=e.map(String).join(" ");return G.some(n=>a.includes(n))};console.log=(...e)=>!S(e)&&H(...e),console.warn=(...e)=>!S(e)&&W(...e),console.error=(...e)=>!S(e)&&V(...e);let C=t.findIndex(e=>e==="--cwd"||e==="--path");if(C!==-1&&C+1<t.length){let e=t[C+1],a=await import("path"),n=await import("fs-extra"),p=a.default.resolve(e);try{n.default.existsSync(p)&&n.default.statSync(p).isDirectory()?process.chdir(p):(console.error(`[ERROR] Directory not found: "${e}"`),process.exit(0))}catch(x){console.error(`[ERROR] Failed to change directory to "${e}": ${x.message}`),process.exit(0)}}process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"),process.stdout.write("\x1B[?2004h"));let I=()=>{process.stdout.isTTY&&process.stdout.write("\x1B[?2004l")};if(process.on("exit",I),["SIGINT","SIGTERM","SIGHUP"].forEach(e=>{process.once(e,()=>{I(),process.exit(0)})}),t.includes("--playground")){let e=process.cwd();process.argv.push("--original-cwd",e);let{DATA_DIR:a}=await import("./chunks/paths-R3DD7CRF.js"),n=await import("path"),p=await import("fs-extra"),x=n.default.join(a,"playground");try{p.default.ensureDirSync(x),process.chdir(x)}catch{}}j(U.createElement(Y,{args:process.argv.slice(2)}),{exitOnCtrlC:!1})}
60
+ /update latest Install latest release`),process.exit(0)),R){let h=t[1]||"latest";if(h==="check"){let i=t[2]==="latest";try{let f=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;f||(console.error("Error: Could not retrieve latest version."),process.exit(1)),console.log(i?`Latest version: v${f}`:f!==u?`A new version of FluxFlow is available: v${f} (current: v${u}). Run "fluxflow --update latest" to upgrade.`:`FluxFlow is up to date (v${u}).`)}catch(l){console.error("Error checking for updates:",l.message),process.exit(1)}process.exit(0)}else if(h==="latest"){console.log("Checking latest version and settings...");try{let r=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;r||(console.error("Error: Could not retrieve latest version."),process.exit(1)),r===u&&(console.log(`FluxFlow is already up to date (v${u}).`),process.exit(0));let f=async()=>{let o=(await import("react")).default,{useState:$}=o,{render:q,Box:g,Text:w}=await import("ink"),z=(await import("ink-select-input")).default,J=(await import("ink-text-input")).default;return new Promise(K=>{let Q=[{label:"NPM",value:"npm"},{label:"PNPM",value:"pnpm"},{label:"Yarn",value:"yarn"},{label:"Bun",value:"bun"},{label:"Custom Command",value:"custom"}],Z=({label:v,isSelected:b})=>o.createElement(g,{width:"100%"},o.createElement(w,{bold:b},"\u2514\u2500 ",b?"\x1B[32m\u25CF\x1B[0m":"\u25CB"," ",v)),A,ee=()=>{let[v,b]=$("select"),[te,se]=$(""),re=E=>{E.value==="custom"?b("custom"):B({manager:E.value})},ae=E=>{B({manager:"custom",customCommand:E})};return v==="custom"?o.createElement(g,{flexDirection:"column",marginY:1},o.createElement(g,{marginBottom:1},o.createElement(w,{color:"magenta",bold:!0},"\u{1F527} Enter custom update command:")),o.createElement(g,{flexDirection:"row"},o.createElement(w,{color:"cyan",bold:!0}," \u276F "),o.createElement(J,{value:te,onChange:se,onSubmit:ae})),o.createElement(g,{marginTop:1},o.createElement(w,{color:"gray",dimColor:!0,italic:!0}," (Press Enter to confirm)"))):o.createElement(g,{flexDirection:"column",marginY:1},o.createElement(g,{marginBottom:1},o.createElement(w,{color:"magenta",bold:!0},"\u{1F4E6} Select a package manager for the update:")),o.createElement(z,{items:Q,onSelect:re,itemComponent:Z,indicatorComponent:()=>null}))},B=v=>{A&&A(),K(v)},{unmount:oe}=q(o.createElement(ee,null));A=oe})},c,N="",M;try{let{loadSettings:o}=await import("./chunks/settings-NKBYU2YV.js");M=await o(),c=M?.systemSettings?.updateManager||M?.updateManager}catch{}if(!c){let o=await f();c=o.manager,N=o.customCommand}let d="";c==="pnpm"?d=`pnpm add -g fluxflow-cli@${r}`:c==="bun"?d=`bun add -g fluxflow-cli@${r}`:c==="yarn"?d=`yarn global add fluxflow-cli@${r}`:c==="custom"?d=N||M?.customUpdateCommand||`npm install -g fluxflow-cli@${r}`:d=`npm install -g fluxflow-cli@${r}`,console.log(`Updating FluxFlow to v${r} using ${c}...`),console.log(`Running: ${d}`);let{execSync:X}=await import("child_process");X(d,{stdio:"inherit"}),console.log(`\x1B[32m\u2705 Update successful! FluxFlow updated to v${r}.\x1B[0m`)}catch(i){console.error("\x1B[31m\u274C Update failed:\x1B[0m",i.message),process.exit(1)}process.exit(0)}else console.error("Unknown update command. Available options: --update, --update check, --update check latest, --update latest"),process.exit(1)}}let{default:U}=await import("react"),{render:j}=await import("ink"),{default:Y}=await import("./chunks/app-HIRZFKI6.js");process.env.NODE_NO_WARNINGS="1";let G=["cuimp","Found existing binary","Binary verified","curl.exe not found","Falling back to .bat file","DeprecationWarning"],H=console.log,W=console.warn,V=console.error,S=e=>{let a=e.map(String).join(" ");return G.some(n=>a.includes(n))};console.log=(...e)=>!S(e)&&H(...e),console.warn=(...e)=>!S(e)&&W(...e),console.error=(...e)=>!S(e)&&V(...e);let C=t.findIndex(e=>e==="--cwd"||e==="--path");if(C!==-1&&C+1<t.length){let e=t[C+1],a=await import("path"),n=await import("fs-extra"),p=a.default.resolve(e);try{n.default.existsSync(p)&&n.default.statSync(p).isDirectory()?process.chdir(p):(console.error(`[ERROR] Directory not found: "${e}"`),process.exit(0))}catch(x){console.error(`[ERROR] Failed to change directory to "${e}": ${x.message}`),process.exit(0)}}process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"),process.stdout.write("\x1B[?2004h"));let I=()=>{process.stdout.isTTY&&process.stdout.write("\x1B[?2004l")};if(process.on("exit",I),["SIGINT","SIGTERM","SIGHUP"].forEach(e=>{process.once(e,()=>{I(),process.exit(0)})}),t.includes("--playground")){let e=process.cwd();process.argv.push("--original-cwd",e);let{DATA_DIR:a}=await import("./chunks/paths-R3DD7CRF.js"),n=await import("path"),p=await import("fs-extra"),x=n.default.join(a,"playground");try{p.default.ensureDirSync(x),process.chdir(x)}catch{}}j(U.createElement(Y,{args:process.argv.slice(2)}),{exitOnCtrlC:!1})}
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxflow-cli",
3
- "version": "4.3.4",
3
+ "version": "4.3.5",
4
4
  "date": "2026-08-23",
5
5
  "description": "A High-Fidelity Agentic CLI with Sub-Agents for the Flux Era. Now has Computer Use.",
6
6
  "keywords": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxflow-cli",
3
- "version": "4.3.4",
3
+ "version": "4.3.5",
4
4
  "date": "2026-08-23",
5
5
  "description": "A High-Fidelity Agentic CLI with Sub-Agents for the Flux Era. Now has Computer Use.",
6
6
  "keywords": [