fluxflow-cli 4.37.3 → 4.38.0

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.
Files changed (74) hide show
  1. package/dist/chunks/{9router-CKETGMBB.js → 9router-E4LQZ5XF.js} +1 -1
  2. package/dist/chunks/{addMemScore-76XLEW3K.js → addMemScore-PBVNSFPN.js} +1 -1
  3. package/dist/chunks/{ai-JI4UX2WD.js → ai-YQJYUPXQ.js} +1 -1
  4. package/dist/chunks/{aihubmix-YSGVPUM4.js → aihubmix-UBV5ARET.js} +1 -1
  5. package/dist/chunks/{apinex-VI576FVJ.js → apinex-L3Y6BP6J.js} +1 -1
  6. package/dist/chunks/{app-3NZMHG65.js → app-SIXVPE6Z.js} +5 -5
  7. package/dist/chunks/{chat-RLEHK3MX.js → chat-C7HYXKVZ.js} +1 -1
  8. package/dist/chunks/chunk-26BQ45XP.js +2 -0
  9. package/dist/chunks/{chunk-T4ZG2WCV.js → chunk-4BLSASW6.js} +1 -1
  10. package/dist/chunks/{chunk-QOT4BYHM.js → chunk-52STSLCN.js} +1 -1
  11. package/dist/chunks/{chunk-3JI2CRXK.js → chunk-6EYQQ7GQ.js} +1 -1
  12. package/dist/chunks/{chunk-HOZQBBAO.js → chunk-6H2P5XUL.js} +1 -1
  13. package/dist/chunks/{chunk-MJL6DHQM.js → chunk-77QN4HDY.js} +1 -1
  14. package/dist/chunks/{chunk-CBFC5KUU.js → chunk-CZK3QF2C.js} +1 -1
  15. package/dist/chunks/{chunk-2VV5ZE53.js → chunk-EYTM4NZD.js} +1 -1
  16. package/dist/chunks/{chunk-ET66XVIM.js → chunk-FXRFFNRK.js} +1 -1
  17. package/dist/chunks/{chunk-FAEB3V5R.js → chunk-HFTI3R3Q.js} +1 -1
  18. package/dist/chunks/{chunk-BTMPM5BT.js → chunk-IHDJDAG3.js} +1 -1
  19. package/dist/chunks/{chunk-FSE4BZZZ.js → chunk-IZQAF6KJ.js} +1 -1
  20. package/dist/chunks/{chunk-PRTGV2R4.js → chunk-KMOTPBF5.js} +1 -1
  21. package/dist/chunks/chunk-P5HBJA23.js +1 -0
  22. package/dist/chunks/{chunk-K4AZXTU6.js → chunk-QW6IGMYV.js} +1 -1
  23. package/dist/chunks/{chunk-M4GC3CRN.js → chunk-ZCXQPXVK.js} +171 -171
  24. package/dist/chunks/{click-B4ZRHV4Z.js → click-J7DMHVDU.js} +2 -2
  25. package/dist/chunks/{computer_action-2RYMIFAM.js → computer_action-D52LLX3E.js} +1 -1
  26. package/dist/chunks/{custom_openai-TLPPKENJ.js → custom_openai-S6YIOHQN.js} +1 -1
  27. package/dist/chunks/{deepseek-2GJCWFSR.js → deepseek-CQRKTOL6.js} +1 -1
  28. package/dist/chunks/{drag-RNGTIO2V.js → drag-CMUD2ZB5.js} +1 -1
  29. package/dist/chunks/{emergency_rollback-NXD2JKBG.js → emergency_rollback-ZHQXCIHW.js} +1 -1
  30. package/dist/chunks/{explabs-YICY4AMR.js → explabs-6TWS34VQ.js} +1 -1
  31. package/dist/chunks/{export-C6VVIYP5.js → export-RU6LCZUB.js} +1 -1
  32. package/dist/chunks/{file_map-T5FHB3F6.js → file_map-UA4BA5OH.js} +1 -1
  33. package/dist/chunks/{find_file-LZR7NET3.js → find_file-HYHHFHUJ.js} +1 -1
  34. package/dist/chunks/{generate_image-75IV5P3L.js → generate_image-5D57XGLP.js} +1 -1
  35. package/dist/chunks/{inferx-YMU7LMOQ.js → inferx-A42H43ZV.js} +1 -1
  36. package/dist/chunks/{infron-A4BOV2AA.js → infron-NZI2FQFA.js} +1 -1
  37. package/dist/chunks/{invoke-7JAD5QTF.js → invoke-4P5QQPCF.js} +2 -2
  38. package/dist/chunks/{invokeSync-WUKJNYGQ.js → invokeSync-BSFWXLD7.js} +2 -2
  39. package/dist/chunks/{key_press-3VU6SHNQ.js → key_press-LWJGR25H.js} +1 -1
  40. package/dist/chunks/{keyboard_typing-PCW3ISET.js → keyboard_typing-A72GI7EW.js} +1 -1
  41. package/dist/chunks/{memory-4DXO4K5C.js → memory-7YOYCOXE.js} +1 -1
  42. package/dist/chunks/{mistral-2CZKHKDT.js → mistral-OXTDZX3G.js} +1 -1
  43. package/dist/chunks/{model_config-VYWFV55M.js → model_config-32SB7PTZ.js} +1 -1
  44. package/dist/chunks/{nvidia-EOLGFGFZ.js → nvidia-5DDRU422.js} +1 -1
  45. package/dist/chunks/{ollama-OHD5BFI7.js → ollama-4PI2BDMM.js} +1 -1
  46. package/dist/chunks/{openrouter-SK7LO52I.js → openrouter-YU3RE7RH.js} +1 -1
  47. package/dist/chunks/{paths-EQFOJDZC.js → paths-RQRI2XRY.js} +1 -1
  48. package/dist/chunks/{poolside-SAAXTNGR.js → poolside-H2NCP5XT.js} +1 -1
  49. package/dist/chunks/{saveSummary-ZSJ2UKLG.js → saveSummary-W2JMDVZJ.js} +1 -1
  50. package/dist/chunks/{screen_grid-Z2S4GMN5.js → screen_grid-4Z2EBIB2.js} +1 -1
  51. package/dist/chunks/{scroll-YSFTTROP.js → scroll-LXQJ25NK.js} +1 -1
  52. package/dist/chunks/{search_keyword-SD6Q3UZE.js → search_keyword-ABVAWJKX.js} +1 -1
  53. package/dist/chunks/{secrets-GHW6AWRR.js → secrets-5TCTEPEV.js} +1 -1
  54. package/dist/chunks/{sensenova-MQKZ7TNO.js → sensenova-UT5CZFCW.js} +1 -1
  55. package/dist/chunks/settings-ZBXCJL25.js +1 -0
  56. package/dist/chunks/{todo-KQCKHQBJ.js → todo-CJLWLWJB.js} +1 -1
  57. package/dist/chunks/{tokenharbor-QL33UGF4.js → tokenharbor-S66MGK52.js} +1 -1
  58. package/dist/chunks/{update_file-OQMKLO6R.js → update_file-6F64CFSU.js} +1 -1
  59. package/dist/chunks/{usage-2WRVNL44.js → usage-WOYKJLZL.js} +1 -1
  60. package/dist/chunks/{usageServer-6XH36WK3.js → usageServer-3KLDOFIX.js} +1 -1
  61. package/dist/chunks/view_file-I77KYUO5.js +1 -0
  62. package/dist/chunks/{web_scrape-KBKSNVBI.js → web_scrape-MW6YSZ7L.js} +1 -1
  63. package/dist/chunks/{web_search-HACFAHXR.js → web_search-NT3HXUO3.js} +1 -1
  64. package/dist/chunks/{write_docx-M5RMUI4W.js → write_docx-E3MTFXTQ.js} +1 -1
  65. package/dist/chunks/{write_file-2ZFCDYSW.js → write_file-JDMRLJKT.js} +1 -1
  66. package/dist/chunks/{write_pdf-E5HQYOTR.js → write_pdf-26OQPNEP.js} +1 -1
  67. package/dist/cli.js +6 -6
  68. package/dist/package.json +1 -1
  69. package/flux-flow.cjs +17 -17
  70. package/package.json +1 -1
  71. package/dist/chunks/chunk-L3W2X74K.js +0 -1
  72. package/dist/chunks/chunk-M2ULCOL3.js +0 -2
  73. package/dist/chunks/settings-5R5ADGXX.js +0 -1
  74. package/dist/chunks/view_file-TZD6DAER.js +0 -1
@@ -1,2 +1,2 @@
1
- import{a as W}from"./chunk-CBFC5KUU.js";import{f as B,h as S}from"./chunk-MJL6DHQM.js";import{a as P}from"./chunk-Y5JU726N.js";import X from"screenshot-desktop";import O from"sharp";import j from"fs-extra";import G from"path";import"@nut-tree-fork/nut-js";async function U(t,o,e){if(!(!process.env.SHOW_DEBUG_GRID&&!process.env.DEBUG_OCR))try{let s=G.resolve(process.cwd(),"screenshots",t);await j.ensureDir(s),await j.writeFile(G.join(s,o),e)}catch{}}function K(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Q(t,o,e=1/0){if(t===o)return 0;if(t.length===0)return o.length;if(o.length===0)return t.length;if(Math.abs(t.length-o.length)>e)return e+1;let s=Array.from({length:o.length+1},(r,i)=>i);for(let r=1;r<=t.length;r++){let i=[r],a=r;for(let n=1;n<=o.length;n++){let c=t[r-1]===o[n-1]?0:1,l=Math.min(i[n-1]+1,s[n]+1,s[n-1]+c);i.push(l),l<a&&(a=l)}if(s=i,a>e)return e+1}return s[o.length]}function V(t){return t<=4?0:t<=8?1:2}async function H(t,o=3){let e=await O(t).metadata();return O(t).resize(Math.round(e.width*o),Math.round(e.height*o),{kernel:"lanczos3"}).greyscale().normalise().toBuffer()}function Y(t){if(!t)return{words:[],lines:[]};let o=[],e=new Map;for(let r of t.split(`
2
- `)){let i=r.split(" ");if(i.length<12||parseInt(i[0])!==5)continue;let n=i[2],c=i[3],l=i[4],w=parseInt(i[6]),x=parseInt(i[7]),R=parseInt(i[8]),M=parseInt(i[9]),f=parseFloat(i[10]),h=i.slice(11).join(" ").trim();if(!h||f<0)continue;let p={x0:w,y0:x,x1:w+R,y1:x+M},g={text:h,confidence:f,bbox:p};o.push(g);let u=`${n}_${c}_${l}`;e.has(u)||e.set(u,{words:[],bbox:{x0:1/0,y0:1/0,x1:-1/0,y1:-1/0}});let d=e.get(u);d.words.push(g),d.bbox.x0=Math.min(d.bbox.x0,p.x0),d.bbox.y0=Math.min(d.bbox.y0,p.y0),d.bbox.x1=Math.max(d.bbox.x1,p.x1),d.bbox.y1=Math.max(d.bbox.y1,p.y1)}let s=[];for(let r of e.values())r.words.length>0&&s.push({text:r.words.map(i=>i.text).join(" "),bbox:r.bbox,words:r.words});return{words:o,lines:s}}function Z(t){if(!(t.words&&t.words.length>0)){if(t.blocks&&t.blocks.length>0){t.words=[],t.lines=[];for(let o of t.blocks)for(let e of o.paragraphs||[])for(let s of e.lines||[]){s.bbox&&t.lines.push(s);for(let r of s.words||[])r.bbox&&t.words.push(r)}if(t.words.length>0)return}if(t.tsv){let o=Y(t.tsv);t.words=o.words,t.lines=o.lines}}}function L(t,o,e=0,s=0,r=1){Z(t);let i=n=>({x0:Math.round(n.x0/r)+e,y0:Math.round(n.y0/r)+s,x1:Math.round(n.x1/r)+e,y1:Math.round(n.y1/r)+s}),a=[];if(t.lines&&t.lines.length>0)for(let n of t.lines){let c=n.text?n.text.toLowerCase().trim():"";if(!c||!n.bbox||!(c===o||new RegExp(`\\b${K(o)}\\b`,"i").test(c)))continue;let w=n.words||(t.words?t.words.filter(f=>f.bbox&&f.bbox.x0>=n.bbox.x0-5&&f.bbox.x1<=n.bbox.x1+5&&f.bbox.y0>=n.bbox.y0-5&&f.bbox.y1<=n.bbox.y1+5):[]),x=o.split(/\s+/),R=x.map(f=>f.replace(/[^a-z0-9]/g,"")).join(" "),M=!1;if(w.length>0)for(let f=0;f<=w.length-x.length;f++){let h=w.slice(f,f+x.length),p=h.map(g=>(g.text||"").toLowerCase().trim().replace(/[^a-z0-9]/g,"")).join(" ");if(p===R||p.includes(R)){let g={x0:Math.min(...h.map(u=>u.bbox.x0)),y0:Math.min(...h.map(u=>u.bbox.y0)),x1:Math.max(...h.map(u=>u.bbox.x1)),y1:Math.max(...h.map(u=>u.bbox.y1))};a.push(i(g)),M=!0}}M||a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0)for(let n of t.words){let c=n.text?n.text.toLowerCase().trim().replace(/[^a-z0-9]/g,""):"",l=o.replace(/[^a-z0-9]/g,"");c===l&&n.bbox&&a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0){let n=V(o.length);for(let c of t.words){let l=c.text?c.text.toLowerCase().trim():"";l.length>=3&&Math.abs(l.length-o.length)<=n&&Q(l,o,n)<=n&&c.bbox&&a.push(i(c.bbox))}}return a}function N(t,o){let e=null,s=1/0;for(let r of t){let i=Math.round((r.x0+r.x1)/2),a=Math.round((r.y0+r.y1)/2),n=o.x>=r.x0&&o.x<=r.x1&&o.y>=r.y0&&o.y<=r.y1,c=Math.hypot(i-o.x,a-o.y),l=n?0:c;l<s&&(s=l,e={x:i,y:a,dist:c,containsPoint:n,bbox:r})}return e}var C=null;async function tt(){return C||(C=(async()=>{let{createWorker:t}=await import("tesseract.js"),o=await import("fs-extra"),{CU_CACHE_DIR:e}=await import("./paths-EQFOJDZC.js");return o.ensureDirSync(e),t("eng",1,{cachePath:e,logger:()=>{}})})().catch(t=>{throw C=null,t})),C}var I=null,F=null;async function et(){let{getActiveDisplay:t}=await import("./screen_grid-Z2S4GMN5.js"),o=await t();if(I&&F===o)return I;F=o,I={format:"png"};try{let e=await X.listDisplays();e&&e.length>0&&(I={format:"png",screen:(e[o]||e[0]).id})}catch{}return I}var pt=async(t,o={})=>{let e=P(t),s=e.gridId||e.grid||e.coordinate||e.target||e.id,r=(e.type||e.clickType||"single").toLowerCase(),i=(e.button||"left").toLowerCase(),a=e.intendedClickText||e.text||"",n=e.ocrCorrection!==void 0?e.ocrCorrection===!0||e.ocrCorrection==="true":e.useOCR!==void 0?e.useOCR===!0||e.useOCR==="true":!1;if(!s&&!a)return'ERROR: Missing required "gridId" parameter for Click tool.';let c=s;if(n&&a)try{let x=s?B(s):null,R=await et(),M=await X(R),f=await O(M).metadata(),h=f.width||1920,p=f.height||1080,g=x?{x:Math.round(x.x*(h/1280)),y:Math.round(x.y*(p/720))}:{x:h/2,y:p/2},u=a.toLowerCase().trim(),d=await tt(),D=null,T="",q=x?320:500;if(x){let m=Math.min(Math.round(h/2),h),y=Math.min(Math.round(p/2),p),b=Math.max(0,Math.min(h-m,g.x-Math.floor(m/2))),k=Math.max(0,Math.min(p-y,g.y-Math.floor(y/2))),_=await O(M).extract({left:b,top:k,width:m,height:y}).toBuffer(),z=2,A=await H(_,z),J=u.replace(/[^a-z0-9]/g,"_");await U("cropped",`crop_${Date.now()}_${J}.png`,A),await d.setParameters({tessedit_pageseg_mode:"11"});let{data:v}=await d.recognize(A,{},{tsv:!0,blocks:!0});if(v&&v.text){let E=L(v,u,b,k,z);if(E.length>0){let $=N(E,g);$&&($.containsPoint||$.dist<=q)&&(D=$,T="centered target crop OCR")}}}if(!D){let m=await H(M,2),y=u.replace(/[^a-z0-9]/g,"_");await U("fullscreen",`full_${Date.now()}_${y}.png`,m),await d.setParameters({tessedit_pageseg_mode:"3"});let{data:b}=await d.recognize(m,{},{tsv:!0,blocks:!0});if(b&&b.text){let k=L(b,u,0,0,2);if(k.length>0){let _=N(k,g);_&&(D=_,T="full-screen OCR")}}}if(D){let m={x:Math.round(D.x*(1280/h)),y:Math.round(D.y*(720/p))},y=await W("click",m,{button:i,clickType:r});if(typeof y=="string"&&y.startsWith("ERROR:"))return y;let b=S(m),k=`${r==="double"?"Double":"Single"} clicked ${i} button`;return s&&b&&String(s)!==String(b)?`${k}. Tried clicking grid ${s}, but OCR corrected to grid ${b} (${T} for "${a}"). If the click landed unintended, try with ocr correction off.`:`${k} on grid ${b||s} (${T} for "${a}").`}}catch{}let l=await W("click",c,{button:i,clickType:r});if(typeof l=="string"&&l.startsWith("ERROR:"))return l;let w=s||(typeof c=="object"?S(c):c);return`${r==="double"?"Double":"Single"} clicked ${i} button on grid ${w}.`};export{pt as click};
1
+ import{a as W}from"./chunk-CZK3QF2C.js";import{f as B,h as S}from"./chunk-77QN4HDY.js";import{a as P}from"./chunk-Y5JU726N.js";import X from"screenshot-desktop";import O from"sharp";import j from"fs-extra";import G from"path";import"@nut-tree-fork/nut-js";async function U(t,o,e){if(!(!process.env.SHOW_DEBUG_GRID&&!process.env.DEBUG_OCR))try{let s=G.resolve(process.cwd(),"screenshots",t);await j.ensureDir(s),await j.writeFile(G.join(s,o),e)}catch{}}function K(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Q(t,o,e=1/0){if(t===o)return 0;if(t.length===0)return o.length;if(o.length===0)return t.length;if(Math.abs(t.length-o.length)>e)return e+1;let s=Array.from({length:o.length+1},(r,i)=>i);for(let r=1;r<=t.length;r++){let i=[r],a=r;for(let n=1;n<=o.length;n++){let c=t[r-1]===o[n-1]?0:1,l=Math.min(i[n-1]+1,s[n]+1,s[n-1]+c);i.push(l),l<a&&(a=l)}if(s=i,a>e)return e+1}return s[o.length]}function V(t){return t<=4?0:t<=8?1:2}async function H(t,o=3){let e=await O(t).metadata();return O(t).resize(Math.round(e.width*o),Math.round(e.height*o),{kernel:"lanczos3"}).greyscale().normalise().toBuffer()}function Y(t){if(!t)return{words:[],lines:[]};let o=[],e=new Map;for(let r of t.split(`
2
+ `)){let i=r.split(" ");if(i.length<12||parseInt(i[0])!==5)continue;let n=i[2],c=i[3],l=i[4],w=parseInt(i[6]),x=parseInt(i[7]),R=parseInt(i[8]),M=parseInt(i[9]),f=parseFloat(i[10]),h=i.slice(11).join(" ").trim();if(!h||f<0)continue;let p={x0:w,y0:x,x1:w+R,y1:x+M},g={text:h,confidence:f,bbox:p};o.push(g);let u=`${n}_${c}_${l}`;e.has(u)||e.set(u,{words:[],bbox:{x0:1/0,y0:1/0,x1:-1/0,y1:-1/0}});let d=e.get(u);d.words.push(g),d.bbox.x0=Math.min(d.bbox.x0,p.x0),d.bbox.y0=Math.min(d.bbox.y0,p.y0),d.bbox.x1=Math.max(d.bbox.x1,p.x1),d.bbox.y1=Math.max(d.bbox.y1,p.y1)}let s=[];for(let r of e.values())r.words.length>0&&s.push({text:r.words.map(i=>i.text).join(" "),bbox:r.bbox,words:r.words});return{words:o,lines:s}}function Z(t){if(!(t.words&&t.words.length>0)){if(t.blocks&&t.blocks.length>0){t.words=[],t.lines=[];for(let o of t.blocks)for(let e of o.paragraphs||[])for(let s of e.lines||[]){s.bbox&&t.lines.push(s);for(let r of s.words||[])r.bbox&&t.words.push(r)}if(t.words.length>0)return}if(t.tsv){let o=Y(t.tsv);t.words=o.words,t.lines=o.lines}}}function L(t,o,e=0,s=0,r=1){Z(t);let i=n=>({x0:Math.round(n.x0/r)+e,y0:Math.round(n.y0/r)+s,x1:Math.round(n.x1/r)+e,y1:Math.round(n.y1/r)+s}),a=[];if(t.lines&&t.lines.length>0)for(let n of t.lines){let c=n.text?n.text.toLowerCase().trim():"";if(!c||!n.bbox||!(c===o||new RegExp(`\\b${K(o)}\\b`,"i").test(c)))continue;let w=n.words||(t.words?t.words.filter(f=>f.bbox&&f.bbox.x0>=n.bbox.x0-5&&f.bbox.x1<=n.bbox.x1+5&&f.bbox.y0>=n.bbox.y0-5&&f.bbox.y1<=n.bbox.y1+5):[]),x=o.split(/\s+/),R=x.map(f=>f.replace(/[^a-z0-9]/g,"")).join(" "),M=!1;if(w.length>0)for(let f=0;f<=w.length-x.length;f++){let h=w.slice(f,f+x.length),p=h.map(g=>(g.text||"").toLowerCase().trim().replace(/[^a-z0-9]/g,"")).join(" ");if(p===R||p.includes(R)){let g={x0:Math.min(...h.map(u=>u.bbox.x0)),y0:Math.min(...h.map(u=>u.bbox.y0)),x1:Math.max(...h.map(u=>u.bbox.x1)),y1:Math.max(...h.map(u=>u.bbox.y1))};a.push(i(g)),M=!0}}M||a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0)for(let n of t.words){let c=n.text?n.text.toLowerCase().trim().replace(/[^a-z0-9]/g,""):"",l=o.replace(/[^a-z0-9]/g,"");c===l&&n.bbox&&a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0){let n=V(o.length);for(let c of t.words){let l=c.text?c.text.toLowerCase().trim():"";l.length>=3&&Math.abs(l.length-o.length)<=n&&Q(l,o,n)<=n&&c.bbox&&a.push(i(c.bbox))}}return a}function N(t,o){let e=null,s=1/0;for(let r of t){let i=Math.round((r.x0+r.x1)/2),a=Math.round((r.y0+r.y1)/2),n=o.x>=r.x0&&o.x<=r.x1&&o.y>=r.y0&&o.y<=r.y1,c=Math.hypot(i-o.x,a-o.y),l=n?0:c;l<s&&(s=l,e={x:i,y:a,dist:c,containsPoint:n,bbox:r})}return e}var C=null;async function tt(){return C||(C=(async()=>{let{createWorker:t}=await import("tesseract.js"),o=await import("fs-extra"),{CU_CACHE_DIR:e}=await import("./paths-RQRI2XRY.js");return o.ensureDirSync(e),t("eng",1,{cachePath:e,logger:()=>{}})})().catch(t=>{throw C=null,t})),C}var I=null,F=null;async function et(){let{getActiveDisplay:t}=await import("./screen_grid-4Z2EBIB2.js"),o=await t();if(I&&F===o)return I;F=o,I={format:"png"};try{let e=await X.listDisplays();e&&e.length>0&&(I={format:"png",screen:(e[o]||e[0]).id})}catch{}return I}var pt=async(t,o={})=>{let e=P(t),s=e.gridId||e.grid||e.coordinate||e.target||e.id,r=(e.type||e.clickType||"single").toLowerCase(),i=(e.button||"left").toLowerCase(),a=e.intendedClickText||e.text||"",n=e.ocrCorrection!==void 0?e.ocrCorrection===!0||e.ocrCorrection==="true":e.useOCR!==void 0?e.useOCR===!0||e.useOCR==="true":!1;if(!s&&!a)return'ERROR: Missing required "gridId" parameter for Click tool.';let c=s;if(n&&a)try{let x=s?B(s):null,R=await et(),M=await X(R),f=await O(M).metadata(),h=f.width||1920,p=f.height||1080,g=x?{x:Math.round(x.x*(h/1280)),y:Math.round(x.y*(p/720))}:{x:h/2,y:p/2},u=a.toLowerCase().trim(),d=await tt(),D=null,T="",q=x?320:500;if(x){let m=Math.min(Math.round(h/2),h),y=Math.min(Math.round(p/2),p),b=Math.max(0,Math.min(h-m,g.x-Math.floor(m/2))),k=Math.max(0,Math.min(p-y,g.y-Math.floor(y/2))),_=await O(M).extract({left:b,top:k,width:m,height:y}).toBuffer(),z=2,A=await H(_,z),J=u.replace(/[^a-z0-9]/g,"_");await U("cropped",`crop_${Date.now()}_${J}.png`,A),await d.setParameters({tessedit_pageseg_mode:"11"});let{data:v}=await d.recognize(A,{},{tsv:!0,blocks:!0});if(v&&v.text){let E=L(v,u,b,k,z);if(E.length>0){let $=N(E,g);$&&($.containsPoint||$.dist<=q)&&(D=$,T="centered target crop OCR")}}}if(!D){let m=await H(M,2),y=u.replace(/[^a-z0-9]/g,"_");await U("fullscreen",`full_${Date.now()}_${y}.png`,m),await d.setParameters({tessedit_pageseg_mode:"3"});let{data:b}=await d.recognize(m,{},{tsv:!0,blocks:!0});if(b&&b.text){let k=L(b,u,0,0,2);if(k.length>0){let _=N(k,g);_&&(D=_,T="full-screen OCR")}}}if(D){let m={x:Math.round(D.x*(1280/h)),y:Math.round(D.y*(720/p))},y=await W("click",m,{button:i,clickType:r});if(typeof y=="string"&&y.startsWith("ERROR:"))return y;let b=S(m),k=`${r==="double"?"Double":"Single"} clicked ${i} button`;return s&&b&&String(s)!==String(b)?`${k}. Tried clicking grid ${s}, but OCR corrected to grid ${b} (${T} for "${a}"). If the click landed unintended, try with ocr correction off.`:`${k} on grid ${b||s} (${T} for "${a}").`}}catch{}let l=await W("click",c,{button:i,clickType:r});if(typeof l=="string"&&l.startsWith("ERROR:"))return l;let w=s||(typeof c=="object"?S(c):c);return`${r==="double"?"Double":"Single"} clicked ${i} button on grid ${w}.`};export{pt as click};
@@ -1 +1 @@
1
- import{a as i,b as s}from"./chunk-CBFC5KUU.js";import"./chunk-MJL6DHQM.js";import{a as c}from"./chunk-Y5JU726N.js";var d=async(a,p={})=>{let e=c(a),r=e.action||e.type||e.cmd,n=e.target||e.grid||e.gridCode||e.location||e.input;if(!r)return'ERROR: Missing required "action" argument for computer_action (e.g. move, click, drag, scroll, type, key_press, key_combination).';let t=r.toLowerCase();if(t.startsWith("mouse_")||["move","click","drag","scroll"].includes(t)){let o=t.replace("mouse_","");return await i(o,n,{button:e.button,clickType:e.clickType||e.type,from:e.from,to:e.to,direction:e.direction,amount:e.amount?parseInt(e.amount,10):void 0})}if(t.startsWith("key_")||t==="type"||t==="press"){let o=t;t==="press"&&(o="key_press");let u=e.autoPressEnter===!0||e.autoPressEnter==="true"||e.enter===!0||e.enter==="true";return await s(o,n||e.text||e.keys,{...e,autoPressEnter:u})}return`ERROR: Unrecognized action "${r}". Supported actions: move, click, drag, scroll, type, key_press, key_combination.`};export{d as computer_action};
1
+ import{a as i,b as s}from"./chunk-CZK3QF2C.js";import"./chunk-77QN4HDY.js";import{a as c}from"./chunk-Y5JU726N.js";var d=async(a,p={})=>{let e=c(a),r=e.action||e.type||e.cmd,n=e.target||e.grid||e.gridCode||e.location||e.input;if(!r)return'ERROR: Missing required "action" argument for computer_action (e.g. move, click, drag, scroll, type, key_press, key_combination).';let t=r.toLowerCase();if(t.startsWith("mouse_")||["move","click","drag","scroll"].includes(t)){let o=t.replace("mouse_","");return await i(o,n,{button:e.button,clickType:e.clickType||e.type,from:e.from,to:e.to,direction:e.direction,amount:e.amount?parseInt(e.amount,10):void 0})}if(t.startsWith("key_")||t==="type"||t==="press"){let o=t;t==="press"&&(o="key_press");let u=e.autoPressEnter===!0||e.autoPressEnter==="true"||e.enter===!0||e.enter==="true";return await s(o,n||e.text||e.keys,{...e,autoPressEnter:u})}return`ERROR: Unrecognized action "${r}". Supported actions: move, click, drag, scroll, type, key_press, key_combination.`};export{d as computer_action};
@@ -1,3 +1,3 @@
1
- import{a as m}from"./chunk-NL4MAQSB.js";import{a as M}from"./chunk-FAEB3V5R.js";import"./chunk-M2ULCOL3.js";var z=async function*(k,C,U,A,E,K,v,d,$=1,L=""){let x=[];A&&x.push({role:"system",content:A});for(let t of U){let e=t.role==="user"?"user":"assistant",n=[];if(Array.isArray(t.parts)){for(let o of t.parts)if(o.text)n.push({type:"text",text:o.text});else if(o.inlineData&&v){let c=o.inlineData.mimeType,u=o.inlineData.data;c.startsWith("image/")&&n.push({type:"image_url",image_url:{url:`data:${c};base64,${u}`}})}}else{let o=t.text||"";o&&n.push({type:"text",text:o})}x.push({role:e,content:n.length===1&&n[0].type==="text"?n[0].text:n})}let P=M("c_openai",C,E),_=P!==null?P:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"xhigh"}[E],a={model:C,messages:x,stream:!0,stream_options:{include_usage:!0},temperature:$,tools:[],tool_choice:"none"};_&&_!=="none"&&(a.reasoning_effort=_,a.reasoning={effort:_});let O=(L||process.env.CUSTOM_OPENAI_URL||process.env.C_OPENAI_URL||"").trim();if(!O)throw new Error("Custom OpenAI Base URL is not configured. Please set Base URL in /settings -> Providers.");let f=O.replace(/\/+$/,"");f.endsWith("/chat/completions")||(f.endsWith("/v1")?f=`${f}/chat/completions`:f=`${f}/chat/completions`);let p={"Content-Type":"application/json",Accept:"text/event-stream, application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow"},T=k&&k!=="LOCAL"?k:process.env.CUSTOM_OPENAI_API_KEY||process.env.C_OPENAI_API_KEY||"";if(T&&T.trim()!==""){let t=T.trim();p.Authorization=t.startsWith("Bearer ")?t:`Bearer ${t}`,p["api-key"]=t}let s=await m(f,{method:"POST",headers:p,body:JSON.stringify(a),signal:d});if(!s.ok&&(s.status===400||s.status===422)&&(a.reasoning||a.reasoning_effort)){if(console.info(`
1
+ import{a as m}from"./chunk-NL4MAQSB.js";import{a as M}from"./chunk-HFTI3R3Q.js";import"./chunk-26BQ45XP.js";var z=async function*(k,C,U,A,E,K,v,d,$=1,L=""){let x=[];A&&x.push({role:"system",content:A});for(let t of U){let e=t.role==="user"?"user":"assistant",n=[];if(Array.isArray(t.parts)){for(let o of t.parts)if(o.text)n.push({type:"text",text:o.text});else if(o.inlineData&&v){let c=o.inlineData.mimeType,u=o.inlineData.data;c.startsWith("image/")&&n.push({type:"image_url",image_url:{url:`data:${c};base64,${u}`}})}}else{let o=t.text||"";o&&n.push({type:"text",text:o})}x.push({role:e,content:n.length===1&&n[0].type==="text"?n[0].text:n})}let P=M("c_openai",C,E),_=P!==null?P:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"xhigh"}[E],a={model:C,messages:x,stream:!0,stream_options:{include_usage:!0},temperature:$,tools:[],tool_choice:"none"};_&&_!=="none"&&(a.reasoning_effort=_,a.reasoning={effort:_});let O=(L||process.env.CUSTOM_OPENAI_URL||process.env.C_OPENAI_URL||"").trim();if(!O)throw new Error("Custom OpenAI Base URL is not configured. Please set Base URL in /settings -> Providers.");let f=O.replace(/\/+$/,"");f.endsWith("/chat/completions")||(f.endsWith("/v1")?f=`${f}/chat/completions`:f=`${f}/chat/completions`);let p={"Content-Type":"application/json",Accept:"text/event-stream, application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow"},T=k&&k!=="LOCAL"?k:process.env.CUSTOM_OPENAI_API_KEY||process.env.C_OPENAI_API_KEY||"";if(T&&T.trim()!==""){let t=T.trim();p.Authorization=t.startsWith("Bearer ")?t:`Bearer ${t}`,p["api-key"]=t}let s=await m(f,{method:"POST",headers:p,body:JSON.stringify(a),signal:d});if(!s.ok&&(s.status===400||s.status===422)&&(a.reasoning||a.reasoning_effort)){if(console.info(`
2
2
  `),a.reasoning&&a.reasoning_effort){let t={...a};delete t.reasoning_effort;let e=await m(f,{method:"POST",headers:p,body:JSON.stringify(t),signal:d}).catch(()=>null);e&&e.ok&&(s=e)}if(!s.ok&&a.reasoning_effort){let t={...a};delete t.reasoning;let e=await m(f,{method:"POST",headers:p,body:JSON.stringify(t),signal:d}).catch(()=>null);e&&e.ok&&(s=e)}if(!s.ok){let t={...a};delete t.reasoning,delete t.reasoning_effort;let e=await m(f,{method:"POST",headers:p,body:JSON.stringify(t),signal:d}).catch(()=>null);e&&e.ok&&(s=e)}}if(!s.ok){let t=await s.json().catch(()=>({})),e=t.error?.metadata?.raw||t.error?.message||(typeof t.error=="string"?t.error:"")||t.message||s.statusText||"Unknown error";throw new Error(`Custom OpenAI Error (${s.status}): ${e}`)}let W=s.body.getReader(),B=new TextDecoder,w="",i=[],l=null,y=Date.now(),g=!1,F=(t,e)=>{if(!t&&!e)return null;if(t){if(typeof t.reasoning_content=="string"&&t.reasoning_content)return t.reasoning_content;if(typeof t.reasoning=="string"&&t.reasoning)return t.reasoning;if(typeof t.thinking=="string"&&t.thinking)return t.thinking;if(typeof t.thought=="string"&&t.thought)return t.thought;if(typeof t.reasoning_text=="string"&&t.reasoning_text)return t.reasoning_text;if(Array.isArray(t.reasoning_details)&&t.reasoning_details.length>0){let n=t.reasoning_details.map(o=>typeof o=="string"?o:o?.text||o?.content||"").filter(Boolean).join("");if(n)return n}}if(e){if(typeof e.reasoning_content=="string"&&e.reasoning_content)return e.reasoning_content;if(typeof e.reasoning=="string"&&e.reasoning)return e.reasoning}return null},J=(t,e)=>{if(t){if(typeof t.content=="string"&&t.content)return t.content;if(typeof t.text=="string"&&t.text)return t.text;if(Array.isArray(t.content))return t.content.map(n=>typeof n=="string"?n:n?.text||"").join("")}return e&&typeof e.text=="string"&&e.text?e.text:""},R=t=>{let e=t.usage||t.usageMetadata||t.choices?.[0]?.usage||null;if(!e)return null;let n=e.prompt_tokens||e.promptTokenCount||e.input_tokens||0,o=e.completion_tokens||e.candidatesTokenCount||e.output_tokens||0,c=e.total_tokens||e.totalTokenCount||n+o,u=e.prompt_tokens_details?.cached_tokens||e.prompt_tokens_details?.cache_read_input_tokens||e.cachedContentTokenCount||e.cache_read_input_tokens||0,r=e.completion_tokens_details?.reasoning_tokens||e.thoughtsTokenCount||e.reasoning_tokens||0;return{totalTokenCount:c,promptTokenCount:n,candidatesTokenCount:o,cachedContentTokenCount:u,thoughtsTokenCount:r}};for(;;){let{done:t,value:e}=await W.read();if(t){g&&(i.length>0||l)&&(yield{candidates:i.length>0?[{content:{parts:i}}]:[],usageMetadata:l});break}w+=B.decode(e,{stream:!0});let n=w.split(`
3
3
  `);w=n.pop();for(let o of n){let c=o.trim();if(!c||!c.startsWith("data: "))continue;let u=!1;if(c==="data: [DONE]"||c==="data: [DONE]\r")u=!0;else try{let r=JSON.parse(c.substring(6));if(r.error){let H=r.error.metadata?.raw||r.error.message||(typeof r.error=="string"?r.error:JSON.stringify(r.error));throw new Error(`Custom OpenAI Stream Error: ${H}`)}let h=r.choices?.[0],S=h?.delta;h?.finish_reason&&h.finish_reason!=="null"&&(u=!0);let D=R(r);D&&(l=D,g=!0);let N=F(S,h);N&&(i.push({text:N,thought:!0}),g=!0);let I=J(S,h);I&&(i.push({text:I}),g=!0)}catch(r){if(r.message&&r.message.startsWith("Custom OpenAI Stream Error:"))throw r}if((u||Date.now()-y>=150)&&g&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:l},i=[],y=Date.now(),g=!1),u)break}Date.now()-y>=150&&g&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:l},i=[],y=Date.now(),g=!1)}};export{z as getCustomOpenAIStream};
@@ -1,2 +1,2 @@
1
- import{a as b}from"./chunk-NL4MAQSB.js";import{a as T}from"./chunk-FAEB3V5R.js";import"./chunk-M2ULCOL3.js";var B=async function*(C,y,M,x,g,O,S,E,$=1){let m=[];x&&m.push({role:"system",content:x});for(let o of M){let k=o.role==="user"?"user":"assistant",a=[];if(Array.isArray(o.parts)){for(let e of o.parts)if(e.text)a.push({type:"text",text:e.text});else if((e.inlineData||e.inline_data)&&S){let s=e.inlineData||e.inline_data,r=s.mimeType||s.mime_type||"image/jpeg",l=s.data;r.startsWith("image/")&&a.push({type:"image_url",image_url:{url:`data:${r};base64,${l}`}})}}else{let e=o.text||"";e&&a.push({type:"text",text:e})}m.push({role:k,content:a.length===1&&a[0].type==="text"?a[0].text:a})}let f={model:y,messages:m,stream:!0,stream_options:{include_usage:!0},temperature:$,tools:[],tool_choice:"none"},D=T("DeepSeek",y,g),c=D!==null?D:g!=="Fast"?{Low:"low",Medium:"high",Standard:"high",High:"max",xHigh:"max"}[g]||"high":null;c&&c!=="disabled"&&c!=="none"&&c!=="false"&&c!==!1?(f.reasoning_effort=c,f.extra_body={thinking:{type:"enabled"}}):f.extra_body={thinking:{type:"disabled"}};let p=await b("https://api.deepseek.com/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${C}`,"Content-Type":"application/json"},body:JSON.stringify(f),signal:E});if(!p.ok){let o=await p.json().catch(()=>({}));throw new Error(`DeepSeek Error (${p.status}): ${o.error?.message||p.statusText}`)}let j=p.body.getReader(),N=new TextDecoder,_="",t=[],d=null,h=Date.now(),n=!1;for(;;){let{done:o,value:k}=await j.read();if(o){n&&(t.length>0||d)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:d});break}_+=N.decode(k,{stream:!0});let a=_.split(`
1
+ import{a as b}from"./chunk-NL4MAQSB.js";import{a as T}from"./chunk-HFTI3R3Q.js";import"./chunk-26BQ45XP.js";var B=async function*(C,y,M,x,g,O,S,E,$=1){let m=[];x&&m.push({role:"system",content:x});for(let o of M){let k=o.role==="user"?"user":"assistant",a=[];if(Array.isArray(o.parts)){for(let e of o.parts)if(e.text)a.push({type:"text",text:e.text});else if((e.inlineData||e.inline_data)&&S){let s=e.inlineData||e.inline_data,r=s.mimeType||s.mime_type||"image/jpeg",l=s.data;r.startsWith("image/")&&a.push({type:"image_url",image_url:{url:`data:${r};base64,${l}`}})}}else{let e=o.text||"";e&&a.push({type:"text",text:e})}m.push({role:k,content:a.length===1&&a[0].type==="text"?a[0].text:a})}let f={model:y,messages:m,stream:!0,stream_options:{include_usage:!0},temperature:$,tools:[],tool_choice:"none"},D=T("DeepSeek",y,g),c=D!==null?D:g!=="Fast"?{Low:"low",Medium:"high",Standard:"high",High:"max",xHigh:"max"}[g]||"high":null;c&&c!=="disabled"&&c!=="none"&&c!=="false"&&c!==!1?(f.reasoning_effort=c,f.extra_body={thinking:{type:"enabled"}}):f.extra_body={thinking:{type:"disabled"}};let p=await b("https://api.deepseek.com/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${C}`,"Content-Type":"application/json"},body:JSON.stringify(f),signal:E});if(!p.ok){let o=await p.json().catch(()=>({}));throw new Error(`DeepSeek Error (${p.status}): ${o.error?.message||p.statusText}`)}let j=p.body.getReader(),N=new TextDecoder,_="",t=[],d=null,h=Date.now(),n=!1;for(;;){let{done:o,value:k}=await j.read();if(o){n&&(t.length>0||d)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:d});break}_+=N.decode(k,{stream:!0});let a=_.split(`
2
2
  `);_=a.pop();for(let e of a){let s=e.trim();if(!s||!s.startsWith("data: "))continue;let r=!1;if(s==="data: [DONE]")r=!0;else try{let l=JSON.parse(s.substring(6)),u=l.choices?.[0]?.delta,i=l.usage;if(l.choices?.[0]?.finish_reason&&(r=!0),i&&(d={totalTokenCount:i.total_tokens||i.prompt_tokens+i.completion_tokens,promptTokenCount:i.prompt_tokens||0,candidatesTokenCount:i.completion_tokens||0,cachedContentTokenCount:i.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:i.completion_tokens_details?.reasoning_tokens||0},n=!0),u){let w=u.reasoning_content||null;w&&(t.push({text:w,thought:!0}),n=!0),u.content&&(t.push({text:u.content}),n=!0)}}catch{}if((r||Date.now()-h>=150)&&n&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:d},t=[],h=Date.now(),n=!1),r)break}Date.now()-h>=150&&n&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:d},t=[],h=Date.now(),n=!1)}};export{B as getDeepSeekStream};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-CBFC5KUU.js";import"./chunk-MJL6DHQM.js";import{a as d}from"./chunk-Y5JU726N.js";var m=async(a,i={})=>{let r=d(a),o=r.fromGridId||r.from||r.start,t=r.toGridId||r.to||r.end;return!o||!t?'ERROR: Drag requires both "fromGridId" and "toGridId" parameters.':await e("drag",o,{from:o,to:t})};export{m as drag};
1
+ import{a as e}from"./chunk-CZK3QF2C.js";import"./chunk-77QN4HDY.js";import{a as d}from"./chunk-Y5JU726N.js";var m=async(a,i={})=>{let r=d(a),o=r.fromGridId||r.from||r.start,t=r.toGridId||r.to||r.end;return!o||!t?'ERROR: Drag requires both "fromGridId" and "toGridId" parameters.':await e("drag",o,{from:o,to:t})};export{m as drag};
@@ -1,4 +1,4 @@
1
- import{a as i}from"./chunk-QOT4BYHM.js";import{a as f}from"./chunk-Y5JU726N.js";import"./chunk-L3W2X74K.js";import"./chunk-M2ULCOL3.js";var m=async(k,c={})=>{let l=f(k),s=l.method,d=l.id,a=c.chatId;if(!c.systemSettings?.advanceRollback)return"ERROR: Advance Rollback feature is currently disabled in settings under Security. Tell user to enable it if needed.";if(!a)return"ERROR: No active chat transaction found for rollback.";if(s==="getCheckpoint"){let r=await i.getCheckpoints(a);if(r.length===0)return"No checkpoints available.";let n={write_file:"WriteFile",update_file:"PatchFile",view_file:"ReadFile",read_folder:"ReadFolder",exec_command:"Run",web_search:"WebSearch",web_scrape:"WebScrape",search_keyword:"SearchKeyword",CodeSearch:"SearchKeyword",code_search:"SearchKeyword",write_pdf:"WritePDF",write_docx:"WriteDoc",generate_image:"GenerateImage",file_map:"FileMap",todo:"Todo",goal:"Goal",Goal:"Goal",await:"Await",ask:"AskUser",ask_user:"AskUser",AskUser:"AskUser",askuser:"AskUser",invoke:"Invoke",invokesync:"InvokeSync",getprogress:"GetProgress",cancel:"Cancel",emergency_rollback:"EmergencyRollback",emergencyrollback:"EmergencyRollback"},t=e=>n[e]||n[e.toLowerCase()]||e,o=`Available checkpoints for rollback:
1
+ import{a as i}from"./chunk-52STSLCN.js";import{a as f}from"./chunk-Y5JU726N.js";import"./chunk-P5HBJA23.js";import"./chunk-26BQ45XP.js";var m=async(k,c={})=>{let l=f(k),s=l.method,d=l.id,a=c.chatId;if(!c.systemSettings?.advanceRollback)return"ERROR: Advance Rollback feature is currently disabled in settings under Security. Tell user to enable it if needed.";if(!a)return"ERROR: No active chat transaction found for rollback.";if(s==="getCheckpoint"){let r=await i.getCheckpoints(a);if(r.length===0)return"No checkpoints available.";let n={write_file:"WriteFile",update_file:"PatchFile",view_file:"ReadFile",read_folder:"ReadFolder",exec_command:"Run",web_search:"WebSearch",web_scrape:"WebScrape",search_keyword:"SearchKeyword",CodeSearch:"SearchKeyword",code_search:"SearchKeyword",write_pdf:"WritePDF",write_docx:"WriteDoc",generate_image:"GenerateImage",file_map:"FileMap",todo:"Todo",goal:"Goal",Goal:"Goal",await:"Await",ask:"AskUser",ask_user:"AskUser",AskUser:"AskUser",askuser:"AskUser",invoke:"Invoke",invokesync:"InvokeSync",getprogress:"GetProgress",cancel:"Cancel",emergency_rollback:"EmergencyRollback",emergencyrollback:"EmergencyRollback"},t=e=>n[e]||n[e.toLowerCase()]||e,o=`Available checkpoints for rollback:
2
2
 
3
3
  `;for(let e of r)if(e.id==="initial")o+=`--- Initial State (id: initial) ---
4
4
  Tools Used: User Prompted for task
@@ -1,2 +1,2 @@
1
- import{a as D}from"./chunk-NL4MAQSB.js";import{a as A}from"./chunk-FAEB3V5R.js";import"./chunk-M2ULCOL3.js";var U=async function*(L,_,b,y,x,R,P,S,C=1){let g=[];y&&g.push({role:"system",content:y});for(let o of b){let m=o.role==="user"?"user":"assistant",e=[];if(Array.isArray(o.parts)){for(let n of o.parts)if(n.text)e.push({type:"text",text:n.text});else if(n.inlineData&&P){let i=n.inlineData.mimeType,p=n.inlineData.data;i.startsWith("image/")&&e.push({type:"image_url",image_url:{url:`data:${i};base64,${p}`}})}}else{let n=o.text||"";n&&e.push({type:"text",text:n})}g.push({role:m,content:e.length===1&&e[0].type==="text"?e[0].text:e})}let k=A("ExpLabs",_,x),E=k!==null?k:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[x],w={model:_,messages:g,stream:!0,stream_options:{include_usage:!0},temperature:C,tools:[],tool_choice:"none"};E&&(w.reasoning_effort=E);let M=process.env.EXPLABS_URL||process.env.EXPERIENTIALLABS_URL||"https://api.experientiallabs.ai/v1/chat/completions",T={"Content-Type":"application/json"},v=L||process.env.EXPLABS_API_KEY||process.env.EXPERIENTIALLABS_API_KEY||"";T.Authorization=`Bearer ${v}`;let c=await D(M,{method:"POST",headers:T,body:JSON.stringify(w),signal:S});if(!c.ok){let o=await c.json().catch(()=>({}));throw new Error(`Experiential Labs Error (${c.status}): ${o.error?.message||o.message||c.statusText}`)}let B=c.body.getReader(),I=new TextDecoder,h="",t=[],l=null,f=Date.now(),a=!1;for(;;){let{done:o,value:m}=await B.read();if(o){a&&(t.length>0||l)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:l});break}h+=I.decode(m,{stream:!0});let e=h.split(`
1
+ import{a as D}from"./chunk-NL4MAQSB.js";import{a as A}from"./chunk-HFTI3R3Q.js";import"./chunk-26BQ45XP.js";var U=async function*(L,_,b,y,x,R,P,S,C=1){let g=[];y&&g.push({role:"system",content:y});for(let o of b){let m=o.role==="user"?"user":"assistant",e=[];if(Array.isArray(o.parts)){for(let n of o.parts)if(n.text)e.push({type:"text",text:n.text});else if(n.inlineData&&P){let i=n.inlineData.mimeType,p=n.inlineData.data;i.startsWith("image/")&&e.push({type:"image_url",image_url:{url:`data:${i};base64,${p}`}})}}else{let n=o.text||"";n&&e.push({type:"text",text:n})}g.push({role:m,content:e.length===1&&e[0].type==="text"?e[0].text:e})}let k=A("ExpLabs",_,x),E=k!==null?k:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[x],w={model:_,messages:g,stream:!0,stream_options:{include_usage:!0},temperature:C,tools:[],tool_choice:"none"};E&&(w.reasoning_effort=E);let M=process.env.EXPLABS_URL||process.env.EXPERIENTIALLABS_URL||"https://api.experientiallabs.ai/v1/chat/completions",T={"Content-Type":"application/json"},v=L||process.env.EXPLABS_API_KEY||process.env.EXPERIENTIALLABS_API_KEY||"";T.Authorization=`Bearer ${v}`;let c=await D(M,{method:"POST",headers:T,body:JSON.stringify(w),signal:S});if(!c.ok){let o=await c.json().catch(()=>({}));throw new Error(`Experiential Labs Error (${c.status}): ${o.error?.message||o.message||c.statusText}`)}let B=c.body.getReader(),I=new TextDecoder,h="",t=[],l=null,f=Date.now(),a=!1;for(;;){let{done:o,value:m}=await B.read();if(o){a&&(t.length>0||l)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:l});break}h+=I.decode(m,{stream:!0});let e=h.split(`
2
2
  `);h=e.pop();for(let n of e){let i=n.trim();if(!i||!i.startsWith("data: "))continue;let p=!1;if(i==="data: [DONE]")p=!0;else try{let d=JSON.parse(i.substring(6)),r=d.choices?.[0]?.delta,s=d.usage;if(s&&(l={totalTokenCount:s.total_tokens||(s.prompt_tokens||0)+(s.completion_tokens||0),promptTokenCount:s.prompt_tokens||0,candidatesTokenCount:s.completion_tokens||0,cachedContentTokenCount:s.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:s.completion_tokens_details?.reasoning_tokens||s.reasoning_tokens||0},a=!0),r){let u=r.reasoning_content||r.reasoning||null;!u&&Array.isArray(r.reasoning_details)&&r.reasoning_details.length>0&&(u=r.reasoning_details.map(N=>N.text||"").filter(Boolean).join("")),u&&(t.push({text:u,thought:!0}),a=!0),r.content&&(t.push({text:r.content}),a=!0)}}catch{}if((p||Date.now()-f>=150)&&a&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:l},t=[],f=Date.now(),a=!1),p)break}Date.now()-f>=150&&a&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:l},t=[],f=Date.now(),a=!1)}};export{U as getExpLabsStream};
@@ -1,4 +1,4 @@
1
- import{d as $}from"./chunk-M2ULCOL3.js";import R from"fs-extra";import y from"path";var N=l=>{if(!l)return[];let u=[],p=/\[(?:tool|action):(.*?)\(([\s\S]*?)\)\]/g,n=0,i;for(;(i=p.exec(l))!==null;){if(i.index>n){let t=l.slice(n,i.index);t.trim()&&u.push({type:"output",content:t})}u.push({type:"tool",toolName:i[1],args:i[2]}),n=p.lastIndex}if(n<l.length){let t=l.slice(n);t.trim()&&u.push({type:"output",content:t})}return u},b=async(l,u,p=process.cwd())=>{let n=`export-fluxflow-${l}.txt`,i=y.join(p,n),t=[],o=!1;for(let m=0;m<u.length;m++){let r=u[m];if(r&&!(r.role==="system"||r.isMeta||r.isLogo||String(r.id).startsWith("welcome"))){if(r.role==="user"){let s=r.text||"";s=s.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),t.length>0&&t.push(""),t.push("[USER]"),t.push(s),o=!1}else if(r.role==="think"){o||(t.push(""),t.push("[AGENT]"),o=!0);let s=(r.text||"").replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/gi,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULT\]/gi,"").trim();s&&(t.push("[thoughts]"),t.push(s))}else if(r.role==="agent"){o||(t.push(""),t.push("[AGENT]"),o=!0);let s=N(r.text||"");for(let c of s)if(c.type==="output"){let a=c.content.replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/gi,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULT\]/gi,"").trim();a&&(t.push("[output]"),t.push(a))}else c.type==="tool"&&(t.push("[tool]"),t.push(`${c.toolName} ${c.args}`))}}}let O=t.join(`
1
+ import{d as $}from"./chunk-26BQ45XP.js";import R from"fs-extra";import y from"path";var N=l=>{if(!l)return[];let u=[],p=/\[(?:tool|action):(.*?)\(([\s\S]*?)\)\]/g,n=0,i;for(;(i=p.exec(l))!==null;){if(i.index>n){let t=l.slice(n,i.index);t.trim()&&u.push({type:"output",content:t})}u.push({type:"tool",toolName:i[1],args:i[2]}),n=p.lastIndex}if(n<l.length){let t=l.slice(n);t.trim()&&u.push({type:"output",content:t})}return u},b=async(l,u,p=process.cwd())=>{let n=`export-fluxflow-${l}.txt`,i=y.join(p,n),t=[],o=!1;for(let m=0;m<u.length;m++){let r=u[m];if(r&&!(r.role==="system"||r.isMeta||r.isLogo||String(r.id).startsWith("welcome"))){if(r.role==="user"){let s=r.text||"";s=s.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),t.length>0&&t.push(""),t.push("[USER]"),t.push(s),o=!1}else if(r.role==="think"){o||(t.push(""),t.push("[AGENT]"),o=!0);let s=(r.text||"").replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/gi,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULT\]/gi,"").trim();s&&(t.push("[thoughts]"),t.push(s))}else if(r.role==="agent"){o||(t.push(""),t.push("[AGENT]"),o=!0);let s=N(r.text||"");for(let c of s)if(c.type==="output"){let a=c.content.replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/gi,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULT\]/gi,"").trim();a&&(t.push("[output]"),t.push(a))}else c.type==="tool"&&(t.push("[tool]"),t.push(`${c.toolName} ${c.args}`))}}}let O=t.join(`
2
2
  `);return await R.writeFile(i,O,"utf8"),{exportFile:n,exportPath:i,totalLines:t.length}},j=(l,u="FluxFlow",p=null)=>{if(!l||!l.trim())return[];let n=l.split(`
3
3
  `),i=[],t=[],o=/^\s*(?:CRITICAL\s+ERROR|ERROR|DEBUG|SEARCH|PUPPETEER|WARN|WARNING|INFO)\b/i,O=/^\s*-{3,}\s*$/,m=!1;for(let s of n)if(o.test(s)){m=!0;break}if(!m){let s=l.trim();if(!s)return[];let c=p?new Date(p).toLocaleString():"Unknown Time",a=/\bjanitor\b/i.test(s)?"Memory":u;return[{timestamp:c,level:"ERROR",source:a,message:s}]}for(let s of n)O.test(s)?t.length>0&&(i.push(t.join(`
4
4
  `).trim()),t=[]):o.test(s)?(t.length>0&&(i.push(t.join(`
@@ -1,4 +1,4 @@
1
- import{a as R}from"./chunk-BTMPM5BT.js";import{a as N}from"./chunk-Y5JU726N.js";import{t as $}from"./chunk-M2ULCOL3.js";import F from"fs-extra";import d from"path";import{createRequire as I}from"module";var E=I(import.meta.url),P=E("web-tree-sitter"),S=!1,b=new Set(["class_declaration","function_declaration","method_definition","arrow_function","function_expression","if_statement","else_clause","for_statement","for_in_statement","for_of_statement","while_statement","do_statement","switch_statement","try_statement","catch_clause","variable_declarator","export_statement","lexical_declaration","variable_declaration","interface_declaration","type_alias_declaration","enum_declaration","import_declaration","jsx_element","jsx_self_closing_element","class_definition","function_definition","decorated_definition","import_from_statement","import_statement","preproc_include","method_declaration","constructor_declaration","assignment_expression","pair","class_specifier","struct_specifier","enum_specifier","field_declaration","element","script_element","style_element"]),O=new Set(["export_statement","lexical_declaration","variable_declaration","variable_declarator","pair","assignment_expression"]);function o(n,t=50){if(!n)return"";let r=n.replace(/\s+/g," ").trim();return r.length>t?r.substring(0,t-3)+"...":r}function v(n){let t=n.type;if(t==="if_statement"){let e=n.childForFieldName("condition");return e?`if (${o(e.text,40)})`:"if"}if(t==="else_clause")return"else";if(t==="while_statement"||t==="do_statement"){let e=n.childForFieldName("condition");return`${t.split("_")[0]} (${e?o(e.text,40):""})`}if(t==="for_statement"||t==="for_in_statement"||t==="for_of_statement"){let i=n.text.split(`
1
+ import{a as R}from"./chunk-IHDJDAG3.js";import{a as N}from"./chunk-Y5JU726N.js";import{t as $}from"./chunk-26BQ45XP.js";import F from"fs-extra";import d from"path";import{createRequire as I}from"module";var E=I(import.meta.url),P=E("web-tree-sitter"),S=!1,b=new Set(["class_declaration","function_declaration","method_definition","arrow_function","function_expression","if_statement","else_clause","for_statement","for_in_statement","for_of_statement","while_statement","do_statement","switch_statement","try_statement","catch_clause","variable_declarator","export_statement","lexical_declaration","variable_declaration","interface_declaration","type_alias_declaration","enum_declaration","import_declaration","jsx_element","jsx_self_closing_element","class_definition","function_definition","decorated_definition","import_from_statement","import_statement","preproc_include","method_declaration","constructor_declaration","assignment_expression","pair","class_specifier","struct_specifier","enum_specifier","field_declaration","element","script_element","style_element"]),O=new Set(["export_statement","lexical_declaration","variable_declaration","variable_declarator","pair","assignment_expression"]);function o(n,t=50){if(!n)return"";let r=n.replace(/\s+/g," ").trim();return r.length>t?r.substring(0,t-3)+"...":r}function v(n){let t=n.type;if(t==="if_statement"){let e=n.childForFieldName("condition");return e?`if (${o(e.text,40)})`:"if"}if(t==="else_clause")return"else";if(t==="while_statement"||t==="do_statement"){let e=n.childForFieldName("condition");return`${t.split("_")[0]} (${e?o(e.text,40):""})`}if(t==="for_statement"||t==="for_in_statement"||t==="for_of_statement"){let i=n.text.split(`
2
2
  `)[0].match(/for\s*(?:await\s*)?\((.*)\)/);return i?`for (${o(i[1],40)})`:"for"}if(t==="switch_statement"){let e=n.childForFieldName("value");return`switch (${e?o(e.text,40):""})`}if(t==="try_statement")return"try";if(t==="catch_clause")return"catch";if(t==="element"||t==="script_element"||t==="style_element"||t==="jsx_element"||t==="jsx_self_closing_element"){let e=n.childForFieldName("opening_element")||n.childForFieldName("start_tag")||n.children.find(c=>c.type==="start_tag")||n,i=e.childForFieldName("name")||e.childForFieldName("tag_name")||e.children.find(c=>c.type==="tag_name");return i?`<${o(i.text,30)}>`:null}if(["import_declaration","import_from_statement","import_statement","preproc_include"].includes(t))return o(n.text.split(`
3
3
  `)[0],60);if(t==="pair"){let e=n.childForFieldName("key");return e?o(e.text.replace(/["']/g,""),40):null}if(t==="assignment_expression"){let e=n.childForFieldName("left");return e?`${o(e.text,30)} = ...`:null}if(t==="variable_declarator"){let e=n.childForFieldName("name")||n.children.find(i=>["identifier","object_pattern","array_pattern"].includes(i.type));return e?o(e.text,40):null}let r=n.childForFieldName("name")||n.childForFieldName("declarator")||n.children.find(e=>["identifier","type_identifier","field_identifier","property_identifier","shorthand_property_identifier"].includes(e.type));if(r){if(r.type.includes("declarator")){let e=r.descendantsOfType("identifier")[0]||r.descendantsOfType("field_identifier")[0];if(e)return o(e.text,40)}return o(r.text,40)}if(["arrow_function","function_expression","function_declaration"].includes(t)){let e=n.parent;for(;e&&e.type!=="program";){let i=v(e);if(i)return i;if(!O.has(e.type))break;e=e.parent}}return null}function L(n){let t=[];function r(e){for(let i of e.children)b.has(i.type)?t.push(i):r(i)}return r(n),t}function j(n){return n.replace(/_([a-z])/g,t=>t[1].toUpperCase())}function T(n,t=0,r=!0,e="",i=null,c=12){let s=n.type,l=v(n),u=b.has(s)||t===0,m=L(n),_=u&&t>0&&(O.has(s)&&m.length>0||l!==null&&l===i&&m.length>0),a="",p=e,g=t,h=i;if(u&&!_){let f=n.startPosition.row+1,x=n.endPosition.row+1,y=j(s),w=l?`${y} [${l}]`:y;t===0?(a+=`\u{1F4C1} ROOT (Lines: ${f}-${x})
4
4
  `,p=e):(a+=`${e}${r?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${w} (Lines: ${f}-${x})
@@ -1,4 +1,4 @@
1
- import{a as E}from"./chunk-Y5JU726N.js";import{w as F,x as S}from"./chunk-M2ULCOL3.js";import W from"fs/promises";import y from"path";function R(n){let e=n.toLowerCase();if(e.length===0)return[];if(e.length===1)return[e];let o=[];for(let t=0;t<e.length-1;t++)o.push(e.slice(t,t+2));return o}function w(n,e){if(n===e)return 1;if(!n||!e)return 0;let o=R(n),t=R(e);if(o.length===0||t.length===0)return 0;let i=new Map;for(let l of t)i.set(l,(i.get(l)||0)+1);let r=0;for(let l of o){let a=i.get(l)||0;a>0&&(r++,i.set(l,a-1))}return 2*r/(o.length+t.length)}async function x(n,e,o=n,t=1,i=15){if(t>i)return[];let r;try{r=await W.readdir(n,{withFileTypes:!0})}catch{return[]}let l=[];for(let a of r){if(e.has(a.name))continue;let u=y.join(n,a.name);if(a.isDirectory()){let m=await x(u,e,o,t+1,i);l.push(...m)}else{let m=y.relative(o,u).replace(/\\/g,"/");l.push({name:a.name,relPath:`./${m}`})}}return l}var O=async n=>{let e=typeof n=="object"&&n!==null?n:E(n),o=e.basename||e.name||e.path||e.file||e.filename||e.query;if(!o&&typeof n=="string"&&n.trim()){let f=n.trim().replace(/^["']|["']$/g,"");!f.startsWith("{")&&!f.includes("=")&&(o=f)}if(!o)return'ERROR: "basename" parameter is required for FindFile';let t=String(o).trim().replace(/^["']|["']$/g,""),i=t.replace(/^(\.\/|\.\\)/,"").replace(/\\/g,"/"),r=i.toLowerCase(),a=t.includes("*")||t.includes("?")?new RegExp("^"+t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")+"$","i"):null,u=process.cwd(),m=new Set([...F,...S(u)]);try{let f=await x(u,m,u),g=[];for(let s of f){let h=s.name.toLowerCase(),P=y.parse(s.name).name.toLowerCase(),p=s.relPath.toLowerCase(),d=p.startsWith("./")?p.slice(2):p,c=0;if(s.name===i||s.relPath===`./${i}`)c=1;else if(h===r||p===`./${r}`||d===r)c=.98;else if(P===r)c=.95;else if(a&&(a.test(s.name)||a.test(d)))c=.9;else if(h.includes(r)||d.includes(r))c=.7+r.length/Math.max(h.length,r.length)*.15;else{let C=w(r,h),q=w(r,P),M=w(r,d),L=Math.max(C,q,M);L>=.75&&(c=L*.85)}c>=.6&&g.push({relPath:s.relPath,score:c})}if(g.length===0)return`No file found matching name "${t}"`;g.sort((s,h)=>h.score-s.score||s.relPath.length-h.relPath.length);let $=Array.from(new Set(g.map(s=>s.relPath))),b=$.length;return`${`Found ${b} file${b===1?"":"s"} matching "${t}":
1
+ import{a as E}from"./chunk-Y5JU726N.js";import{w as F,x as S}from"./chunk-26BQ45XP.js";import W from"fs/promises";import y from"path";function R(n){let e=n.toLowerCase();if(e.length===0)return[];if(e.length===1)return[e];let o=[];for(let t=0;t<e.length-1;t++)o.push(e.slice(t,t+2));return o}function w(n,e){if(n===e)return 1;if(!n||!e)return 0;let o=R(n),t=R(e);if(o.length===0||t.length===0)return 0;let i=new Map;for(let l of t)i.set(l,(i.get(l)||0)+1);let r=0;for(let l of o){let a=i.get(l)||0;a>0&&(r++,i.set(l,a-1))}return 2*r/(o.length+t.length)}async function x(n,e,o=n,t=1,i=15){if(t>i)return[];let r;try{r=await W.readdir(n,{withFileTypes:!0})}catch{return[]}let l=[];for(let a of r){if(e.has(a.name))continue;let u=y.join(n,a.name);if(a.isDirectory()){let m=await x(u,e,o,t+1,i);l.push(...m)}else{let m=y.relative(o,u).replace(/\\/g,"/");l.push({name:a.name,relPath:`./${m}`})}}return l}var O=async n=>{let e=typeof n=="object"&&n!==null?n:E(n),o=e.basename||e.name||e.path||e.file||e.filename||e.query;if(!o&&typeof n=="string"&&n.trim()){let f=n.trim().replace(/^["']|["']$/g,"");!f.startsWith("{")&&!f.includes("=")&&(o=f)}if(!o)return'ERROR: "basename" parameter is required for FindFile';let t=String(o).trim().replace(/^["']|["']$/g,""),i=t.replace(/^(\.\/|\.\\)/,"").replace(/\\/g,"/"),r=i.toLowerCase(),a=t.includes("*")||t.includes("?")?new RegExp("^"+t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")+"$","i"):null,u=process.cwd(),m=new Set([...F,...S(u)]);try{let f=await x(u,m,u),g=[];for(let s of f){let h=s.name.toLowerCase(),P=y.parse(s.name).name.toLowerCase(),p=s.relPath.toLowerCase(),d=p.startsWith("./")?p.slice(2):p,c=0;if(s.name===i||s.relPath===`./${i}`)c=1;else if(h===r||p===`./${r}`||d===r)c=.98;else if(P===r)c=.95;else if(a&&(a.test(s.name)||a.test(d)))c=.9;else if(h.includes(r)||d.includes(r))c=.7+r.length/Math.max(h.length,r.length)*.15;else{let C=w(r,h),q=w(r,P),M=w(r,d),L=Math.max(C,q,M);L>=.75&&(c=L*.85)}c>=.6&&g.push({relPath:s.relPath,score:c})}if(g.length===0)return`No file found matching name "${t}"`;g.sort((s,h)=>h.score-s.score||s.relPath.length-h.relPath.length);let $=Array.from(new Set(g.map(s=>s.relPath))),b=$.length;return`${`Found ${b} file${b===1?"":"s"} matching "${t}":
2
2
 
3
3
  `}${$.join(`
4
4
  `)}`}catch(f){return`ERROR: Failed to find file: ${f.message}`}};export{O as find_file};
@@ -1 +1 @@
1
- import{a as k}from"./chunk-3JI2CRXK.js";import{a as b}from"./chunk-Y5JU726N.js";import{t as B,u as T,v as $}from"./chunk-K4AZXTU6.js";import{a as I}from"./chunk-FSE4BZZZ.js";import"./chunk-PRTGV2R4.js";import"./chunk-L3W2X74K.js";import"./chunk-M2ULCOL3.js";import C from"fs-extra";import x from"path";var F=(a,y={})=>{try{if(a.length<8||a[0]!==137||a[1]!==80||a[2]!==78||a[3]!==71)return a;let s=[],c=[];for(let r=0;r<256;r++){let e=r;for(let n=0;n<8;n++)e&1?e=3988292384^e>>>1:e=e>>>1;c[r]=e}let l=r=>{let e=4294967295;for(let n=0;n<r.length;n++)e=c[(e^r[n])&255]^e>>>8;return(e^4294967295)>>>0},f=(r,e)=>{let n=Buffer.from(r,"ascii"),i=Buffer.from(e,"utf-8"),u=n.length+1+i.length,o=Buffer.alloc(8+u+4);o.writeUInt32BE(u,0),o.write("tEXt",4,"ascii"),n.copy(o,8),o[8+n.length]=0,i.copy(o,8+n.length+1);let w=l(o.subarray(4,8+u));return o.writeUInt32BE(w,8+u),o};for(let[r,e]of Object.entries(y))e!=null&&s.push(f(r,String(e)));if(s.length===0)return a;if(a.subarray(12,16).toString("ascii")==="IHDR"){let e=a.subarray(0,33),n=a.subarray(33);return Buffer.concat([e,...s,n])}return a}catch{return a}},N=async(a,y={})=>{let s=b(a),c=s.prompt||s.text,l=s.path||s.outputPath||s.output||"generated_image.png",f=s.ratio;if(!c)return'ERROR: Missing "prompt" argument for generate_image.';let r=["nsfw","naked","nudity","nude","porn","sex","xxx","erotic","gore","bloody","violence","abuse","suicide","murder","hentai","pedophile","rape"],e=c.toLowerCase();if(r.some(i=>e.includes(i)))return"ERROR: Prompt blocked by system safety filter (inappropriate or unsafe content detected).";try{let i=await I();if(!await B(i))return`ERROR: Insufficient Quota for selected quality. Either tell user reduce quality or wait for next refresh cycle (${(await T()).nextResetMin||60}m).`;let o=i.imageSettings||{keyType:"Default",quality:"Low-High",apiKey:""},w=o.keyType==="Custom"&&o.apiKey?o.apiKey:FALLBACK_IMAGE_KEY,E={Low:"flux","Low-High":"zimage",Medium:"gptimage","Medium-High":"gptimage",High:"qwen-image",Ultra:"gptimage-large",Premium:"nanobanana-pro"}[o.quality]||"zimage",g=1024,m=1024;if(f){let t=f.replace(/\s+/g,"");t==="16:9"?(g=1024,m=576):t==="9:16"?(g=576,m=1024):t==="4:3"?(g=1024,m=768):t==="3:4"?(g=768,m=1024):t==="1:1"&&(g=1024,m=1024)}let M=Math.floor(Math.random()*1e7),S=`https://gen.pollinations.ai/image/${encodeURIComponent(c)}?model=${E}&width=${g}&height=${m}&seed=${M}&enhance=true&reasoning=high&quality=high&negative=${encodeURIComponent("deformed, distorted, disfigured, poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, disconnected limbs, mutation, mutated hands and fingers, blurry, low quality, low resolution, extra fingers, censored, watermarks, signatures")}`,d=await fetch(S,{method:"GET",headers:{Authorization:`Bearer ${w}`}});if(!d.ok){let t=d.status,h="";try{h=await d.text()}catch{}return t===402||h.includes("Insufficient balance")||h.includes("PAYMENT_REQUIRED")?"ERROR: Image Generation Currently unavailable. Try again later.":`ERROR: Image Generation failed with status [${t}]: ${h||"Unknown API Error"}`}if((d.headers.get("content-type")||"").includes("application/json")){let t=await d.json();return t.status===402||t.error&&t.error.code==="PAYMENT_REQUIRED"?"ERROR: Image Generation Currently unavailable. Try again later.":`ERROR: Image Generation failed: ${t.error?.message||JSON.stringify(t)}`}let O=await d.arrayBuffer(),p=Buffer.from(O),P={Title:c,Description:"Generated via FluxFlow CLI",Software:"FluxFlow CLI",Author:"FluxFlow","Creation Time":new Date().toISOString(),Prompt:c,Model:`Fluxflow:${E}`,Ratio:f||"1:1",Seed:String(M)};p=F(p,P);let R=x.resolve(process.cwd(),l);await C.ensureDir(x.dirname(R)),await k.recordFileChange(R),await C.writeFile(R,p),await $(i);let v=x.extname(l).toLowerCase(),L={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"}[v]||"image/png";return y.isMultiModal!==!1?{text:`Image successfully generated from prompt [${c}] and saved to [${l}]. Output attached to multimodal part`,binaryPart:{inlineData:{data:p.toString("base64"),mimeType:L}}}:`Image successfully generated from prompt [${c}] and saved to [${l}].`}catch(i){return`ERROR: Failed during image generation: ${i instanceof Error?i.message:String(i)}`}};export{N as generate_image};
1
+ import{a as k}from"./chunk-6EYQQ7GQ.js";import{a as b}from"./chunk-Y5JU726N.js";import{t as B,u as T,v as $}from"./chunk-QW6IGMYV.js";import{a as I}from"./chunk-IZQAF6KJ.js";import"./chunk-KMOTPBF5.js";import"./chunk-P5HBJA23.js";import"./chunk-26BQ45XP.js";import C from"fs-extra";import x from"path";var F=(a,y={})=>{try{if(a.length<8||a[0]!==137||a[1]!==80||a[2]!==78||a[3]!==71)return a;let s=[],c=[];for(let r=0;r<256;r++){let e=r;for(let n=0;n<8;n++)e&1?e=3988292384^e>>>1:e=e>>>1;c[r]=e}let l=r=>{let e=4294967295;for(let n=0;n<r.length;n++)e=c[(e^r[n])&255]^e>>>8;return(e^4294967295)>>>0},f=(r,e)=>{let n=Buffer.from(r,"ascii"),i=Buffer.from(e,"utf-8"),u=n.length+1+i.length,o=Buffer.alloc(8+u+4);o.writeUInt32BE(u,0),o.write("tEXt",4,"ascii"),n.copy(o,8),o[8+n.length]=0,i.copy(o,8+n.length+1);let w=l(o.subarray(4,8+u));return o.writeUInt32BE(w,8+u),o};for(let[r,e]of Object.entries(y))e!=null&&s.push(f(r,String(e)));if(s.length===0)return a;if(a.subarray(12,16).toString("ascii")==="IHDR"){let e=a.subarray(0,33),n=a.subarray(33);return Buffer.concat([e,...s,n])}return a}catch{return a}},N=async(a,y={})=>{let s=b(a),c=s.prompt||s.text,l=s.path||s.outputPath||s.output||"generated_image.png",f=s.ratio;if(!c)return'ERROR: Missing "prompt" argument for generate_image.';let r=["nsfw","naked","nudity","nude","porn","sex","xxx","erotic","gore","bloody","violence","abuse","suicide","murder","hentai","pedophile","rape"],e=c.toLowerCase();if(r.some(i=>e.includes(i)))return"ERROR: Prompt blocked by system safety filter (inappropriate or unsafe content detected).";try{let i=await I();if(!await B(i))return`ERROR: Insufficient Quota for selected quality. Either tell user reduce quality or wait for next refresh cycle (${(await T()).nextResetMin||60}m).`;let o=i.imageSettings||{keyType:"Default",quality:"Low-High",apiKey:""},w=o.keyType==="Custom"&&o.apiKey?o.apiKey:FALLBACK_IMAGE_KEY,E={Low:"flux","Low-High":"zimage",Medium:"gptimage","Medium-High":"gptimage",High:"qwen-image",Ultra:"gptimage-large",Premium:"nanobanana-pro"}[o.quality]||"zimage",g=1024,m=1024;if(f){let t=f.replace(/\s+/g,"");t==="16:9"?(g=1024,m=576):t==="9:16"?(g=576,m=1024):t==="4:3"?(g=1024,m=768):t==="3:4"?(g=768,m=1024):t==="1:1"&&(g=1024,m=1024)}let M=Math.floor(Math.random()*1e7),S=`https://gen.pollinations.ai/image/${encodeURIComponent(c)}?model=${E}&width=${g}&height=${m}&seed=${M}&enhance=true&reasoning=high&quality=high&negative=${encodeURIComponent("deformed, distorted, disfigured, poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, disconnected limbs, mutation, mutated hands and fingers, blurry, low quality, low resolution, extra fingers, censored, watermarks, signatures")}`,d=await fetch(S,{method:"GET",headers:{Authorization:`Bearer ${w}`}});if(!d.ok){let t=d.status,h="";try{h=await d.text()}catch{}return t===402||h.includes("Insufficient balance")||h.includes("PAYMENT_REQUIRED")?"ERROR: Image Generation Currently unavailable. Try again later.":`ERROR: Image Generation failed with status [${t}]: ${h||"Unknown API Error"}`}if((d.headers.get("content-type")||"").includes("application/json")){let t=await d.json();return t.status===402||t.error&&t.error.code==="PAYMENT_REQUIRED"?"ERROR: Image Generation Currently unavailable. Try again later.":`ERROR: Image Generation failed: ${t.error?.message||JSON.stringify(t)}`}let O=await d.arrayBuffer(),p=Buffer.from(O),P={Title:c,Description:"Generated via FluxFlow CLI",Software:"FluxFlow CLI",Author:"FluxFlow","Creation Time":new Date().toISOString(),Prompt:c,Model:`Fluxflow:${E}`,Ratio:f||"1:1",Seed:String(M)};p=F(p,P);let R=x.resolve(process.cwd(),l);await C.ensureDir(x.dirname(R)),await k.recordFileChange(R),await C.writeFile(R,p),await $(i);let v=x.extname(l).toLowerCase(),L={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"}[v]||"image/png";return y.isMultiModal!==!1?{text:`Image successfully generated from prompt [${c}] and saved to [${l}]. Output attached to multimodal part`,binaryPart:{inlineData:{data:p.toString("base64"),mimeType:L}}}:`Image successfully generated from prompt [${c}] and saved to [${l}].`}catch(i){return`ERROR: Failed during image generation: ${i instanceof Error?i.message:String(i)}`}};export{N as generate_image};
@@ -1,3 +1,3 @@
1
- import{a as D}from"./chunk-NL4MAQSB.js";import{a as b}from"./chunk-FAEB3V5R.js";import"./chunk-M2ULCOL3.js";var v=async function*(S,r,E,x,y,J,P,L,N=1){let h=[];x&&h.push({role:"system",content:x});for(let t of E){let o=t.role==="user"?"user":"assistant",e="";if(Array.isArray(t.parts))for(let f of t.parts)f.text&&(e+=(e?`
1
+ import{a as D}from"./chunk-NL4MAQSB.js";import{a as b}from"./chunk-HFTI3R3Q.js";import"./chunk-26BQ45XP.js";var v=async function*(S,r,E,x,y,J,P,L,N=1){let h=[];x&&h.push({role:"system",content:x});for(let t of E){let o=t.role==="user"?"user":"assistant",e="";if(Array.isArray(t.parts))for(let f of t.parts)f.text&&(e+=(e?`
2
2
  `:"")+f.text);else e=t.text||"";h.push({role:o,content:e})}let g=b("InferX",r,y),T=g!==null?g:{Fast:"low",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[y],O=r&&r.toLowerCase().includes("qwen3.8-27b")&&g===null,q=r&&(r.toLowerCase().includes("qwen3.8-27b")||r.toLowerCase().includes("qwen3.6-35b-a3b-fp8")),m={model:r,messages:h.filter(t=>t.content&&String(t.content).trim().length>0),stream:!0,stream_options:{include_usage:!0},temperature:N,tools:[],tool_choice:"none"};!O&&T&&(m.stream_options={include_usage:!0},m.reasoning_effort=T);let c=await D("https://model.inferx.net/endpoints/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${S}`,"Content-Type":"application/json"},body:JSON.stringify(m),signal:L});if(!c.ok){let t=await c.text().catch(()=>""),o="";try{let e=JSON.parse(t);o=e.error?.message||e.error?.detail||e.message||e.detail||(typeof e.error=="string"?e.error:"")||(t&&t!=="{}"?t:"")}catch{o=t}throw(!o||o==="{}")&&(o=c.statusText||"Unknown error"),new Error(`InferX Error (${c.status}): ${o}`)}let A=c.body.getReader(),F=new TextDecoder,k="",n=[],i=null,u=Date.now(),a=!1,C=!0;for(;;){let{done:t,value:o}=await A.read();if(t){a&&(n.length>0||i)&&(yield{candidates:n.length>0?[{content:{parts:n}}]:[],usageMetadata:i});break}k+=F.decode(o,{stream:!0});let e=k.split(`
3
3
  `);k=e.pop();for(let f of e){let d=f.trim();if(!d||!d.startsWith("data: "))continue;let w=!1;if(d==="data: [DONE]")w=!0;else try{let _=JSON.parse(d.substring(6)),l=_.choices?.[0]?.delta,s=_.usage;if(s&&(i={totalTokenCount:s.total_tokens||(s.prompt_tokens||0)+(s.completion_tokens||0),promptTokenCount:s.prompt_tokens||0,candidatesTokenCount:s.completion_tokens||0,cachedContentTokenCount:s.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:s.completion_tokens_details?.reasoning_tokens||s.reasoning_tokens||0},a=!0),l){let M=l.reasoning||l.reasoning_content||null;if(M&&(n.push({text:M,thought:!0}),a=!0),l.content){let p=l.content;q&&C&&p.length>0&&(p="<think>"+p,C=!1),n.push({text:p}),a=!0}}}catch{}if((w||Date.now()-u>=150||i)&&a&&(yield{candidates:n.length>0?[{content:{parts:[...n]}}]:[],usageMetadata:i},n=[],u=Date.now(),a=!1),w)break}Date.now()-u>=150&&a&&(yield{candidates:n.length>0?[{content:{parts:[...n]}}]:[],usageMetadata:i},n=[],u=Date.now(),a=!1)}};export{v as getInferXStream};
@@ -1,2 +1,2 @@
1
- import{a as A}from"./chunk-NL4MAQSB.js";import{a as b}from"./chunk-FAEB3V5R.js";import"./chunk-M2ULCOL3.js";var B=async function*(C,v,E,w,x,j,N,O,S=1){let a=v,m=null;if(typeof a=="string"){let t={};if(a.includes("::")){let e=a.indexOf("::"),n=a.slice(0,e).trim();n&&(t.only=[n]),a=a.slice(e+2).trim()}let d=["flex","standard","priority"],o={fp16:"fp16",f16:"fp16",fp8:"fp8",f8:"fp8",int8:"int8",in8:"int8",int4:"int4",in4:"int4"},s=["throughput","latency","price","ttft"];if(a.includes(":")){let e=a.split(":");for(;e.length>1;){let n=e[e.length-1].toLowerCase().trim();if(d.includes(n))t.service_tier=n,t.allow_fallbacks=!1,e.pop();else if(o[n])t.quantizations=[o[n]],t.allow_fallbacks=!1,e.pop();else if(s.includes(n))t.sort=n,t.allow_fallbacks=!1,e.pop();else break}a=e.join(":").trim()}Object.keys(t).length>0&&(m=t)}let _=[];w&&_.push({role:"system",content:w});for(let t of E){let d=t.role==="user"?"user":"assistant",o=[];if(Array.isArray(t.parts)){for(let s of t.parts)if(s.text)o.push({type:"text",text:s.text});else if(s.inlineData&&N){let e=s.inlineData.mimeType,n=s.inlineData.data;e.startsWith("image/")&&o.push({type:"image_url",image_url:{url:`data:${e};base64,${n}`}})}}else{let s=t.text||"";s&&o.push({type:"text",text:s})}_.push({role:d,content:o.length===1&&o[0].type==="text"?o[0].text:o})}let T=b("Infron",a,x),D=T!==null?T:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[x],y={model:a,messages:_,stream:!0,stream_options:{include_usage:!0},temperature:S,tools:[],tool_choice:"none"};m&&(y.provider=m),D&&(y.reasoning={effort:D});let M=process.env.INFRON_URL||"https://llm.onerouter.pro/v1/chat/completions",I={"Content-Type":"application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow","HTTP-Referer":"https://fluxflow-cli.onrender.com/"},F=C||process.env.INFRON_API_KEY||"";I.Authorization=`Bearer ${F}`;let f=await A(M,{method:"POST",headers:I,body:JSON.stringify(y),signal:O});if(!f.ok){let t=await f.json().catch(()=>({}));throw new Error(`Infron Error (${f.status}): ${t.error?.message||t.message||f.statusText}`)}let R=f.body.getReader(),L=new TextDecoder,k="",i=[],p=null,u=Date.now(),l=!1;for(;;){let{done:t,value:d}=await R.read();if(t){l&&(i.length>0||p)&&(yield{candidates:i.length>0?[{content:{parts:i}}]:[],usageMetadata:p});break}k+=L.decode(d,{stream:!0});let o=k.split(`
1
+ import{a as A}from"./chunk-NL4MAQSB.js";import{a as b}from"./chunk-HFTI3R3Q.js";import"./chunk-26BQ45XP.js";var B=async function*(C,v,E,w,x,j,N,O,S=1){let a=v,m=null;if(typeof a=="string"){let t={};if(a.includes("::")){let e=a.indexOf("::"),n=a.slice(0,e).trim();n&&(t.only=[n]),a=a.slice(e+2).trim()}let d=["flex","standard","priority"],o={fp16:"fp16",f16:"fp16",fp8:"fp8",f8:"fp8",int8:"int8",in8:"int8",int4:"int4",in4:"int4"},s=["throughput","latency","price","ttft"];if(a.includes(":")){let e=a.split(":");for(;e.length>1;){let n=e[e.length-1].toLowerCase().trim();if(d.includes(n))t.service_tier=n,t.allow_fallbacks=!1,e.pop();else if(o[n])t.quantizations=[o[n]],t.allow_fallbacks=!1,e.pop();else if(s.includes(n))t.sort=n,t.allow_fallbacks=!1,e.pop();else break}a=e.join(":").trim()}Object.keys(t).length>0&&(m=t)}let _=[];w&&_.push({role:"system",content:w});for(let t of E){let d=t.role==="user"?"user":"assistant",o=[];if(Array.isArray(t.parts)){for(let s of t.parts)if(s.text)o.push({type:"text",text:s.text});else if(s.inlineData&&N){let e=s.inlineData.mimeType,n=s.inlineData.data;e.startsWith("image/")&&o.push({type:"image_url",image_url:{url:`data:${e};base64,${n}`}})}}else{let s=t.text||"";s&&o.push({type:"text",text:s})}_.push({role:d,content:o.length===1&&o[0].type==="text"?o[0].text:o})}let T=b("Infron",a,x),D=T!==null?T:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[x],y={model:a,messages:_,stream:!0,stream_options:{include_usage:!0},temperature:S,tools:[],tool_choice:"none"};m&&(y.provider=m),D&&(y.reasoning={effort:D});let M=process.env.INFRON_URL||"https://llm.onerouter.pro/v1/chat/completions",I={"Content-Type":"application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow","HTTP-Referer":"https://fluxflow-cli.onrender.com/"},F=C||process.env.INFRON_API_KEY||"";I.Authorization=`Bearer ${F}`;let f=await A(M,{method:"POST",headers:I,body:JSON.stringify(y),signal:O});if(!f.ok){let t=await f.json().catch(()=>({}));throw new Error(`Infron Error (${f.status}): ${t.error?.message||t.message||f.statusText}`)}let R=f.body.getReader(),L=new TextDecoder,k="",i=[],p=null,u=Date.now(),l=!1;for(;;){let{done:t,value:d}=await R.read();if(t){l&&(i.length>0||p)&&(yield{candidates:i.length>0?[{content:{parts:i}}]:[],usageMetadata:p});break}k+=L.decode(d,{stream:!0});let o=k.split(`
2
2
  `);k=o.pop();for(let s of o){let e=s.trim();if(!e||!e.startsWith("data: "))continue;let n=!1;if(e==="data: [DONE]")n=!0;else try{let g=JSON.parse(e.substring(6)),c=g.choices?.[0]?.delta,r=g.usage;if(r&&(p={totalTokenCount:r.total_tokens||(r.prompt_tokens||0)+(r.completion_tokens||0),promptTokenCount:r.prompt_tokens||0,candidatesTokenCount:r.completion_tokens||0,cachedContentTokenCount:r.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:r.completion_tokens_details?.reasoning_tokens||r.reasoning_tokens||0},l=!0),c){let h=c.reasoning_content||c.reasoning||null;!h&&Array.isArray(c.reasoning_details)&&c.reasoning_details.length>0&&(h=c.reasoning_details.map(P=>P.text||"").filter(Boolean).join("")),h&&(i.push({text:h,thought:!0}),l=!0),c.content&&(i.push({text:c.content}),l=!0)}}catch{}if((n||Date.now()-u>=150)&&l&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:p},i=[],u=Date.now(),l=!1),n)break}Date.now()-u>=150&&l&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:p},i=[],u=Date.now(),l=!1)}};export{B as getInfronStream};
@@ -1,6 +1,6 @@
1
- import{a as k,c as d}from"./chunk-56EJGQU3.js";import{a as b}from"./chunk-Y5JU726N.js";var I=async(w,s={})=>{let{runSubagent:U}=await import("./ai-JI4UX2WD.js"),l=b(w),c=l.task||l.instruction||l.prompt,E=l.model||null,C=l.title||null,m=l.tools||null;if(!c)return'ERROR: Missing "task" argument for invoke.';let f=null;if(m)try{let t=m.trim();t.startsWith("[")&&t.endsWith("]")&&(t=t.substring(1,t.length-1)),f=t.split(",").map(n=>n.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let i=`subagent-${Date.now()}-${Math.floor(Math.random()*1e3)}`,h=null,S=null,$=new Promise((t,n)=>{h=t,S=n}),e={id:i,title:C||c.substring(0,30),task:c,status:"running",startedAt:Date.now(),lastChunkTime:Date.now(),wps:0,questions:[],pendingSteerMessages:[],steer:t=>{t&&e.pendingSteerMessages.push(t)},completionPromise:$,_resolveCompletion:h,_rejectCompletion:S,progress:[]},r={chunks:[],totalWords:0};k.push(e),s.onSubagentUpdate&&s.onSubagentUpdate();let a=[],A={...s,taskId:i,onAskMain:async t=>{let n=`q-${Date.now()}-${Math.floor(Math.random()*1e3)}`,o=null,p=new Promise(g=>{o=g}),u={id:n,question:t,answered:!1,answer:null,askedAt:Date.now(),_resolve:o};return e.questions.push(u),e.status="waiting",s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" is WAITING FOR YOUR INPUT: "${t}"
1
+ import{a as k,c as d}from"./chunk-56EJGQU3.js";import{a as b}from"./chunk-Y5JU726N.js";var I=async(w,s={})=>{let{runSubagent:U}=await import("./ai-YQJYUPXQ.js"),l=b(w),c=l.task||l.instruction||l.prompt,E=l.model||null,C=l.title||null,m=l.tools||null;if(!c)return'ERROR: Missing "task" argument for invoke.';let f=null;if(m)try{let t=m.trim();t.startsWith("[")&&t.endsWith("]")&&(t=t.substring(1,t.length-1)),f=t.split(",").map(n=>n.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let i=`subagent-${Date.now()}-${Math.floor(Math.random()*1e3)}`,h=null,S=null,$=new Promise((t,n)=>{h=t,S=n}),e={id:i,title:C||c.substring(0,30),task:c,status:"running",startedAt:Date.now(),lastChunkTime:Date.now(),wps:0,questions:[],pendingSteerMessages:[],steer:t=>{t&&e.pendingSteerMessages.push(t)},completionPromise:$,_resolveCompletion:h,_rejectCompletion:S,progress:[]},r={chunks:[],totalWords:0};k.push(e),s.onSubagentUpdate&&s.onSubagentUpdate();let a=[],A={...s,taskId:i,onAskMain:async t=>{let n=`q-${Date.now()}-${Math.floor(Math.random()*1e3)}`,o=null,p=new Promise(g=>{o=g}),u={id:n,question:t,answered:!1,answer:null,askedAt:Date.now(),_resolve:o};return e.questions.push(u),e.status="waiting",s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" is WAITING FOR YOUR INPUT: "${t}"
2
2
  Respond using tool: [action:Answer(id="${i}", answer="...")]
3
3
  [/SYSTEM]`),await p},onVisualFeedback:t=>{e.lastChunkTime=Date.now();let n=t.replace(/\x1b\[[0-9;]*m/g,""),o=n.match(/[✔✘✗✖🔍📖→➕↻•]\s*([A-Za-z0-9\s-]+)/);o?e.currentTool=o[1].trim():e.currentTool=n,s.onSubagentUpdate&&s.onSubagentUpdate()},onTokenChunk:(t,n)=>{let o=Date.now();if(e.lastChunkTime=o,e.currentTool="Thinking",typeof n=="number"&&n>0){r.totalWords+=n,r.chunks.push({time:o,words:n});let p=o-400;if(r.chunks=r.chunks.filter(u=>u.time>=p),r.chunks.length>0){let u=r.chunks.reduce((M,_)=>M+_.words,0),T=r.chunks[0].time,g=Math.max(.4,(o-T)/1e3);e.wps=Math.round(u/g)}}s.onSubagentUpdate&&s.onSubagentUpdate()}};return U(c,A,E,f,50,t=>{if(e.status==="cancelled")return;if(t.startsWith("[Subagent Turn")&&a.length>0&&(e.progress.push([...a]),a=[]),t.includes("[Executing Tool]")){let o=t.match(/\[Executing Tool\]\s*([a-zA-Z0-9_]+)/);o&&(!e.currentTool||e.currentTool==="Thinking")&&(e.currentTool=o[1])}let n=t;if(n.startsWith("[Tool Result]")||n.startsWith("[Action Result]")){let o=n.split(`
4
4
  `);o.length>5&&(n=o.slice(0,4).join(`
5
5
  `)+`
6
- ... [Content/Diff Truncated from Logs] ...`)}a.push(n),s.onSubagentUpdate&&s.onSubagentUpdate()},!0).then(t=>{if(e.status==="cancelled"){e._resolveCompletion&&e._resolveCompletion(t);return}a.length>0&&(e.progress.push([...a]),a=[]),e.status="completed",e.finalAnswer=t,s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" (id: ${i}) has FINISHED. Call GetProgress(id="${i}") to see the final result. [/SYSTEM]`),e._resolveCompletion&&e._resolveCompletion(t)}).catch(async t=>{let{isTerminationSignaled:n}=await import("./ai-JI4UX2WD.js");if(t.message==="Subagent task was cancelled."||e.status==="cancelled"||n()){e.status="cancelled",a.push("[SUBAGENT CANCELLED] Task was cancelled."),e.progress.push([...a]),s.onSubagentUpdate&&s.onSubagentUpdate(),e._resolveCompletion&&e._resolveCompletion(null);return}a.push(`[SUBAGENT FAILURE] Error: ${t.message}`),e.progress.push([...a]),e.status="failed",e.error=t.message,s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" (id: ${i}) FAILED with error: ${t.message}. [/SYSTEM]`),e._rejectCompletion&&e._rejectCompletion(t)}),`Background subagent started. Task ID: ${i}`};export{I as invoke};
6
+ ... [Content/Diff Truncated from Logs] ...`)}a.push(n),s.onSubagentUpdate&&s.onSubagentUpdate()},!0).then(t=>{if(e.status==="cancelled"){e._resolveCompletion&&e._resolveCompletion(t);return}a.length>0&&(e.progress.push([...a]),a=[]),e.status="completed",e.finalAnswer=t,s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" (id: ${i}) has FINISHED. Call GetProgress(id="${i}") to see the final result. [/SYSTEM]`),e._resolveCompletion&&e._resolveCompletion(t)}).catch(async t=>{let{isTerminationSignaled:n}=await import("./ai-YQJYUPXQ.js");if(t.message==="Subagent task was cancelled."||e.status==="cancelled"||n()){e.status="cancelled",a.push("[SUBAGENT CANCELLED] Task was cancelled."),e.progress.push([...a]),s.onSubagentUpdate&&s.onSubagentUpdate(),e._resolveCompletion&&e._resolveCompletion(null);return}a.push(`[SUBAGENT FAILURE] Error: ${t.message}`),e.progress.push([...a]),e.status="failed",e.error=t.message,s.onSubagentUpdate&&s.onSubagentUpdate(),d(`[SYSTEM] Background subagent "${e.title}" (id: ${i}) FAILED with error: ${t.message}. [/SYSTEM]`),e._rejectCompletion&&e._rejectCompletion(t)}),`Background subagent started. Task ID: ${i}`};export{I as invoke};
@@ -1,3 +1,3 @@
1
- import{a as o}from"./chunk-Y5JU726N.js";var k=async(b,t={})=>{let{runSubagent:u}=await import("./ai-JI4UX2WD.js"),s=o(b),a=s.task||s.instruction||s.prompt,m=s.model||null,l=s.tools||null;if(!a)return'ERROR: Missing "task" argument for invokeSync.';let r=null;if(l)try{let e=l.trim();e.startsWith("[")&&e.endsWith("]")&&(e=e.substring(1,e.length-1)),r=e.split(",").map(i=>i.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let n=s.title||a.substring(0,30);try{t.onVisualFeedback&&t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n}`);let e=await u(a,t,m,r,50);return t.onVisualFeedback&&t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n} [COMPLETED]
2
- `),e}catch(e){let{isTerminationSignaled:i}=await import("./ai-JI4UX2WD.js"),c=e.message==="Subagent task was cancelled by user."||i();if(t.onVisualFeedback){let d=c?"[CANCELLED]":"[FAILED]";t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n} ${d}
1
+ import{a as o}from"./chunk-Y5JU726N.js";var k=async(b,t={})=>{let{runSubagent:u}=await import("./ai-YQJYUPXQ.js"),s=o(b),a=s.task||s.instruction||s.prompt,m=s.model||null,l=s.tools||null;if(!a)return'ERROR: Missing "task" argument for invokeSync.';let r=null;if(l)try{let e=l.trim();e.startsWith("[")&&e.endsWith("]")&&(e=e.substring(1,e.length-1)),r=e.split(",").map(i=>i.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let n=s.title||a.substring(0,30);try{t.onVisualFeedback&&t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n}`);let e=await u(a,t,m,r,50);return t.onVisualFeedback&&t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n} [COMPLETED]
2
+ `),e}catch(e){let{isTerminationSignaled:i}=await import("./ai-YQJYUPXQ.js"),c=e.message==="Subagent task was cancelled by user."||i();if(t.onVisualFeedback){let d=c?"[CANCELLED]":"[FAILED]";t.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${n} ${d}
3
3
  `)}return`ERROR: Subagent execution failed: ${e.message}`}};export{k as invokeSync};
@@ -1 +1 @@
1
- import{b as e}from"./chunk-CBFC5KUU.js";import"./chunk-MJL6DHQM.js";import{a as i}from"./chunk-Y5JU726N.js";var k=async(s,c={})=>{let t=i(s),a=t.key||t.keys||t.input||t.shortcut;if(!a)return'ERROR: Missing required "key" parameter for KeyPress tool.';let r=String(a).trim().toLowerCase();if(r==="clearinput"||r==="clear_input"||r==="clear")return await e("clear_input");if(r==="back"||r==="browser_back"||r==="browserBack")return await e("browser_back");if(r.includes(";")||r.includes("+")){let o=r.split(/[;+]/).map(n=>n.trim()).filter(Boolean);return await e("key_combination",o)}return await e("key_press",r)};export{k as key_press};
1
+ import{b as e}from"./chunk-CZK3QF2C.js";import"./chunk-77QN4HDY.js";import{a as i}from"./chunk-Y5JU726N.js";var k=async(s,c={})=>{let t=i(s),a=t.key||t.keys||t.input||t.shortcut;if(!a)return'ERROR: Missing required "key" parameter for KeyPress tool.';let r=String(a).trim().toLowerCase();if(r==="clearinput"||r==="clear_input"||r==="clear")return await e("clear_input");if(r==="back"||r==="browser_back"||r==="browserBack")return await e("browser_back");if(r.includes(";")||r.includes("+")){let o=r.split(/[;+]/).map(n=>n.trim()).filter(Boolean);return await e("key_combination",o)}return await e("key_press",r)};export{k as key_press};
@@ -1 +1 @@
1
- import{b as n}from"./chunk-CBFC5KUU.js";import"./chunk-MJL6DHQM.js";import{a as r}from"./chunk-Y5JU726N.js";var p=async(o,u={})=>{let t=r(o),e=t.text||t.input||t.value||"",s=t.autoPressEnter===!0||t.autoPressEnter==="true"||t.enter===!0||t.enter==="true";return e==null?'ERROR: Missing required "text" parameter for KeyboardTyping tool.':await n("type",String(e),{autoPressEnter:s})};export{p as keyboard_typing};
1
+ import{b as n}from"./chunk-CZK3QF2C.js";import"./chunk-77QN4HDY.js";import{a as r}from"./chunk-Y5JU726N.js";var p=async(o,u={})=>{let t=r(o),e=t.text||t.input||t.value||"",s=t.autoPressEnter===!0||t.autoPressEnter==="true"||t.enter===!0||t.enter==="true";return e==null?'ERROR: Missing required "text" parameter for KeyboardTyping tool.':await n("type",String(e),{autoPressEnter:s})};export{p as keyboard_typing};
@@ -1 +1 @@
1
- import{c as M,d as m}from"./chunk-L3W2X74K.js";import{k as a,l as $}from"./chunk-M2ULCOL3.js";var O=4*(1024*2),v=async(p,E={})=>{let s=t=>{let e=new RegExp(`${t}\\s*[:=]\\s*(["'])(.*?)\\1(?=\\s*[,)]|\\s+\\w+\\s*[:=]|$)`,"s"),n=p.match(e);if(n)return n[2].trim();let o=new RegExp(`${t}\\s*[:=]\\s*([^,\\s)]+)`,"s"),r=p.match(o);return r?r[1].trim():null},R=s("action"),u=s("method"),c=s("content"),w=s("content-new"),S=s("content-old"),y=s("id"),d=s("chat-id")||E.chatId||E.sessionId||"default-session";if(R==="temp"){if(!c)return"ERROR: Missing 'content' for temp memory.";let t=M($,{});t[d]||(t[d]=[]),t[d].push(c),m($,t);let e=t[d].reduce((n,o)=>n+o.length,0);return`Temporary context saved for session [${d}]. (Size: ${e} chars)`}if(R==="user"){let t=M(a,[]).map(e=>(e.score===void 0&&(e.score=.5),e));if(u==="add"){if(!c)return"ERROR: Missing 'content' for memory addition.";let e=new Date,n=`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()}`,o=c.includes("[Saved on:")?c:`${c.trim()} [Saved on: ${n}]`,r=O,i=t.reduce((g,I)=>g+(I.memory?.length||0),0);for(;t.length>0&&i+o.length>r;){let g=t.shift();i-=g.memory?.length||0}let l=s("score"),f=l?parseFloat(l):.5,h={id:`mem-${Date.now().toString(36)}`,memory:o,score:Math.min(2,isNaN(f)?.5:f)};return t.push(h),m(a,t),`Memory added with ID [${h.id}] and score [${h.score}]. (Vault Size: ${i+o.length} chars)`}if(u==="update"){let e=y||S,n=w||c;if(!e||!n)return"ERROR: Missing 'id' or content for update.";let o=t.findIndex(f=>f.id===e);if(o===-1)return`ERROR: Memory ID [${e}] not found.`;let r=new Date,i=`${r.getDate()}/${r.getMonth()+1}/${r.getFullYear()}`,l=n.includes("[Saved on:")?n:`${n.trim()} [Saved on: ${i}]`;return t[o].memory=l,m(a,t),`Memory [${e}] updated.`}if(u==="delete"){let e=y||c;if(!e)return"ERROR: Missing 'id' for deletion.";let n=t.length,o=t.filter(r=>r.id!==e);return o.length===n?`ERROR: Memory ID [${e}] not found.`:(m(a,o),`Memory [${e}] deleted.`)}return`ERROR: Invalid method [${u}] for user memory. Use 'add', 'update', or 'delete'.`}return`ERROR: Unknown action [${R}] for memory tool.`};export{v as memory};
1
+ import{c as M,d as m}from"./chunk-P5HBJA23.js";import{k as a,l as $}from"./chunk-26BQ45XP.js";var O=4*(1024*2),v=async(p,E={})=>{let s=t=>{let e=new RegExp(`${t}\\s*[:=]\\s*(["'])(.*?)\\1(?=\\s*[,)]|\\s+\\w+\\s*[:=]|$)`,"s"),n=p.match(e);if(n)return n[2].trim();let o=new RegExp(`${t}\\s*[:=]\\s*([^,\\s)]+)`,"s"),r=p.match(o);return r?r[1].trim():null},R=s("action"),u=s("method"),c=s("content"),w=s("content-new"),S=s("content-old"),y=s("id"),d=s("chat-id")||E.chatId||E.sessionId||"default-session";if(R==="temp"){if(!c)return"ERROR: Missing 'content' for temp memory.";let t=M($,{});t[d]||(t[d]=[]),t[d].push(c),m($,t);let e=t[d].reduce((n,o)=>n+o.length,0);return`Temporary context saved for session [${d}]. (Size: ${e} chars)`}if(R==="user"){let t=M(a,[]).map(e=>(e.score===void 0&&(e.score=.5),e));if(u==="add"){if(!c)return"ERROR: Missing 'content' for memory addition.";let e=new Date,n=`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()}`,o=c.includes("[Saved on:")?c:`${c.trim()} [Saved on: ${n}]`,r=O,i=t.reduce((g,I)=>g+(I.memory?.length||0),0);for(;t.length>0&&i+o.length>r;){let g=t.shift();i-=g.memory?.length||0}let l=s("score"),f=l?parseFloat(l):.5,h={id:`mem-${Date.now().toString(36)}`,memory:o,score:Math.min(2,isNaN(f)?.5:f)};return t.push(h),m(a,t),`Memory added with ID [${h.id}] and score [${h.score}]. (Vault Size: ${i+o.length} chars)`}if(u==="update"){let e=y||S,n=w||c;if(!e||!n)return"ERROR: Missing 'id' or content for update.";let o=t.findIndex(f=>f.id===e);if(o===-1)return`ERROR: Memory ID [${e}] not found.`;let r=new Date,i=`${r.getDate()}/${r.getMonth()+1}/${r.getFullYear()}`,l=n.includes("[Saved on:")?n:`${n.trim()} [Saved on: ${i}]`;return t[o].memory=l,m(a,t),`Memory [${e}] updated.`}if(u==="delete"){let e=y||c;if(!e)return"ERROR: Missing 'id' for deletion.";let n=t.length,o=t.filter(r=>r.id!==e);return o.length===n?`ERROR: Memory ID [${e}] not found.`:(m(a,o),`Memory [${e}] deleted.`)}return`ERROR: Invalid method [${u}] for user memory. Use 'add', 'update', or 'delete'.`}return`ERROR: Unknown action [${R}] for memory tool.`};export{v as memory};
@@ -1,2 +1,2 @@
1
- import{a as O,b as j,c as f}from"./chunk-NL4MAQSB.js";import{a as N}from"./chunk-FAEB3V5R.js";import"./chunk-PRTGV2R4.js";import"./chunk-M2ULCOL3.js";var X=async function*(M,T,B,b,m,K,E,J,P=1,W=null){let w=[];b&&w.push({role:"system",content:b});for(let t of B){let g=t.role==="user"?"user":"assistant",e=[];if(Array.isArray(t.parts)){for(let i of t.parts)if(i.text)e.push({type:"text",text:i.text});else if(i.inlineData&&E){let p=i.inlineData.mimeType,d=i.inlineData.data;p.startsWith("image/")&&e.push({type:"image_url",image_url:`data:${p};base64,${d}`})}}else{let i=t.text||"";i&&e.push({type:"text",text:i})}e.length>0&&w.push({role:g,content:e.length===1&&e[0].type==="text"?e[0].text:e})}let S={Fast:"none",Low:"none",Medium:"high",Standard:"high",High:"high",xHigh:"high"},F=`${M.slice(-5)}${W||""}${m}${T}`,H=await j(F),C={model:T,messages:w,stream:!0,temperature:P,prompt_cache_key:H,tools:[],tool_choice:"none"},h=N("Mistral",T,m);h!==null&&h!=="none"?h&&h!=="none"&&h!=="disabled"&&h!==!1&&(C.reasoning_effort=h):m&&S[m]!=="none"&&(C.reasoning_effort=S[m]||"high");let y=await O("https://api.mistral.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${M}`,"Content-Type":"application/json"},body:JSON.stringify(C),signal:J});if(!y.ok){let t=await y.text().catch(()=>""),g=y.statusText;try{let e=JSON.parse(t);g=e.error?.message||e.message||JSON.stringify(e.detail||e)}catch{t&&(g=t)}throw new Error(`Mistral Error (${y.status}): ${JSON.stringify(g)}`)}let R=y.body.getReader(),q=new TextDecoder,D="",n=[],x=null,k=Date.now(),r=!1,o=t=>t?typeof t=="string"?f(t):Array.isArray(t)?t.map(o).filter(Boolean).join(""):typeof t=="object"&&t!==null?typeof t.text=="string"?f(t.text):typeof t.content=="string"?f(t.content):typeof t.thinking=="string"?f(t.thinking):typeof t.reasoning_content=="string"?f(t.reasoning_content):typeof t.reasoning=="string"?f(t.reasoning):typeof t.value=="string"?f(t.value):t.text?o(t.text):t.content?o(t.content):t.thinking?o(t.thinking):t.reasoning_content?o(t.reasoning_content):t.reasoning?o(t.reasoning):t.value?o(t.value):"":f(String(t)):"";for(;;){let{done:t,value:g}=await R.read();if(t){r&&(n.length>0||x)&&(yield{candidates:n.length>0?[{content:{parts:n}}]:[],usageMetadata:x});break}D+=q.decode(g,{stream:!0});let e=D.split(`
1
+ import{a as O,b as j,c as f}from"./chunk-NL4MAQSB.js";import{a as N}from"./chunk-HFTI3R3Q.js";import"./chunk-KMOTPBF5.js";import"./chunk-26BQ45XP.js";var X=async function*(M,T,B,b,m,K,E,J,P=1,W=null){let w=[];b&&w.push({role:"system",content:b});for(let t of B){let g=t.role==="user"?"user":"assistant",e=[];if(Array.isArray(t.parts)){for(let i of t.parts)if(i.text)e.push({type:"text",text:i.text});else if(i.inlineData&&E){let p=i.inlineData.mimeType,d=i.inlineData.data;p.startsWith("image/")&&e.push({type:"image_url",image_url:`data:${p};base64,${d}`})}}else{let i=t.text||"";i&&e.push({type:"text",text:i})}e.length>0&&w.push({role:g,content:e.length===1&&e[0].type==="text"?e[0].text:e})}let S={Fast:"none",Low:"none",Medium:"high",Standard:"high",High:"high",xHigh:"high"},F=`${M.slice(-5)}${W||""}${m}${T}`,H=await j(F),C={model:T,messages:w,stream:!0,temperature:P,prompt_cache_key:H,tools:[],tool_choice:"none"},h=N("Mistral",T,m);h!==null&&h!=="none"?h&&h!=="none"&&h!=="disabled"&&h!==!1&&(C.reasoning_effort=h):m&&S[m]!=="none"&&(C.reasoning_effort=S[m]||"high");let y=await O("https://api.mistral.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${M}`,"Content-Type":"application/json"},body:JSON.stringify(C),signal:J});if(!y.ok){let t=await y.text().catch(()=>""),g=y.statusText;try{let e=JSON.parse(t);g=e.error?.message||e.message||JSON.stringify(e.detail||e)}catch{t&&(g=t)}throw new Error(`Mistral Error (${y.status}): ${JSON.stringify(g)}`)}let R=y.body.getReader(),q=new TextDecoder,D="",n=[],x=null,k=Date.now(),r=!1,o=t=>t?typeof t=="string"?f(t):Array.isArray(t)?t.map(o).filter(Boolean).join(""):typeof t=="object"&&t!==null?typeof t.text=="string"?f(t.text):typeof t.content=="string"?f(t.content):typeof t.thinking=="string"?f(t.thinking):typeof t.reasoning_content=="string"?f(t.reasoning_content):typeof t.reasoning=="string"?f(t.reasoning):typeof t.value=="string"?f(t.value):t.text?o(t.text):t.content?o(t.content):t.thinking?o(t.thinking):t.reasoning_content?o(t.reasoning_content):t.reasoning?o(t.reasoning):t.value?o(t.value):"":f(String(t)):"";for(;;){let{done:t,value:g}=await R.read();if(t){r&&(n.length>0||x)&&(yield{candidates:n.length>0?[{content:{parts:n}}]:[],usageMetadata:x});break}D+=q.decode(g,{stream:!0});let e=D.split(`
2
2
  `);D=e.pop();for(let i of e){let p=i.trim();if(!p||!p.startsWith("data: "))continue;let d=!1;if(p==="data: [DONE]")d=!0;else try{let _=JSON.parse(p.substring(6)),c=_.choices?.[0]?.delta,u=_.usage;if(_.choices?.[0]?.finish_reason&&(d=!0),u&&(x={totalTokenCount:u.total_tokens||(u.prompt_tokens||0)+(u.completion_tokens||0),promptTokenCount:u.prompt_tokens||0,candidatesTokenCount:u.completion_tokens||0,cachedContentTokenCount:u.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:u.completion_tokens_details?.reasoning_tokens||0},r=!0),c){let z=c.thinking||c.reasoning_content||c.reasoning,$=o(z);$&&(n.push({text:$,thought:!0}),r=!0);let a=c.content||(!c.thinking&&!c.reasoning_content&&!c.reasoning?c.text:null);if(a)if(Array.isArray(a))for(let s of a)if(typeof s=="object"&&s!==null){let l=s.type==="thinking"||s.type==="reasoning"||!!s.thought,A=o(s);A&&(n.push({text:A,...l?{thought:!0}:{}}),r=!0)}else{let l=o(s);l&&(n.push({text:l}),r=!0)}else if(typeof a=="object"&&a!==null){let s=a.type==="thinking"||a.type==="reasoning"||!!a.thought,l=o(a);l&&(n.push({text:l,...s?{thought:!0}:{}}),r=!0)}else{let s=o(a);s&&(n.push({text:s}),r=!0)}}}catch{}if((d||Date.now()-k>=150)&&r&&(yield{candidates:n.length>0?[{content:{parts:[...n]}}]:[],usageMetadata:x},n=[],k=Date.now(),r=!1),d)break}Date.now()-k>=150&&r&&(yield{candidates:n.length>0?[{content:{parts:[...n]}}]:[],usageMetadata:x},n=[],k=Date.now(),r=!1)}};export{X as getMistralStream};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-PRTGV2R4.js";import"./chunk-M2ULCOL3.js";export{a as DEFAULT_MODEL_CONFIG,o as getDefaultModel,q as getFallbackValue,b as getModelConfig,p as getModelPricing,n as getModels,m as hasModelReasoning,l as isModelMultimodal,h as removeModelFromProvider,i as renameModelInProvider,c as saveModelConfigToDisk,d as saveModelToProvider,j as setCustomMultimodal,g as setDefaultModelForProvider,f as setModelMultimodalInProvider,k as setOllamaMultimodal,e as updateModelInfoInProvider};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"./chunk-KMOTPBF5.js";import"./chunk-26BQ45XP.js";export{a as DEFAULT_MODEL_CONFIG,o as getDefaultModel,q as getFallbackValue,b as getModelConfig,p as getModelPricing,n as getModels,m as hasModelReasoning,l as isModelMultimodal,h as removeModelFromProvider,i as renameModelInProvider,c as saveModelConfigToDisk,d as saveModelToProvider,j as setCustomMultimodal,g as setDefaultModelForProvider,f as setModelMultimodalInProvider,k as setOllamaMultimodal,e as updateModelInfoInProvider};
@@ -1,2 +1,2 @@
1
- import{a as j}from"./chunk-NL4MAQSB.js";import{a as W}from"./chunk-FAEB3V5R.js";import{l as K}from"./chunk-PRTGV2R4.js";import"./chunk-M2ULCOL3.js";var ue=async function*(M,e,k,c,g,D,w=!1,I,H=1){let A=[];c&&A.push({role:"system",content:c}),k.forEach(i=>{let N=i.role==="model"?"assistant":"user",d=[];Array.isArray(i.parts)&&i.parts.forEach(u=>{if(u.text)d.push({type:"text",text:u.text});else if(u.inlineData&&w){let r=u.inlineData.mimeType,f=u.inlineData.data;r.startsWith("image/")&&K(e)&&d.push({type:"image_url",image_url:{url:`data:${r};base64,${f}`}})}}),A.push({role:N,content:d.length===1&&d[0].type==="text"?d[0].text:d})});let T=W("NVIDIA",e,g),t=T!==null?T:{Fast:"Fast",Low:"Fast",Medium:"Standard",Standard:"Standard",High:"High",xHigh:"High"}[g]||"High",o=t!=="Fast"&&t!=="none"&&t!=="disabled"&&t!==!1,s=e.includes("kimi"),n=e.includes("gemma"),h=e.includes("deepseek"),y=e.includes("glm"),z=e.includes("mistral"),P=e.includes("minimax"),J=e.includes("gpt"),Y=e.includes("qwen"),Q=e.includes("nemotron"),X=e.includes("llama-3"),Z=e.includes("seed"),B=e.includes("poolside"),C=e.includes("thinkingmachines")||e.includes("muse"),ee=X,te={Fast:"low",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},se={Fast:"64",Low:"64",Medium:"4096",Standard:"4096",High:"16384",xHigh:"16384"},ne={Fast:"none",Low:"minimal",Medium:"medium",Standard:"medium",High:"max",xHigh:"max"},U=P||h||B||C?16384:32768;U=process.env.NVIDIA_BASE_URL?1024:U;let a={model:e,messages:A,max_tokens:U,stream:!0,stream_options:{include_usage:!0},temperature:H,tools:[],tool_choice:"none",...J&&{thinking:te[g]||"high"}};if(!(process.env.NVIDIA_BASE_URL||ee))if(s)a.chat_template_kwargs={thinking:o};else if(n)a.chat_template_kwargs={enable_thinking:o};else if(h)if(o){let i=t==="High"?"max":"high";a.chat_template_kwargs={thinking:!0,reasoning_effort:i}}else a.chat_template_kwargs={thinking:!1};else y?a.chat_template_kwargs={enable_thinking:o,clear_thinking:!o}:z?a.reasoning_effort=o?"high":"none":P&&e.includes("minimax-m3")?a.chat_template_kwargs={thinking_mode:o?"enabled":"disabled"}:Y?a.chat_template_kwargs={enable_thinking:o}:Q?t==="High"?a.chat_template_kwargs={enable_thinking:!0}:t==="Standard"?a.chat_template_kwargs={enable_thinking:!0,medium_effort:!0}:a.chat_template_kwargs={enable_thinking:!1}:Z?o&&(a.extra_body={thinking_budget:parseInt(se[t]??"4096")}):B?a.chat_template_kwargs={enable_thinking:o}:C&&(a.reasoning_effort=ne[t]||"medium");let V=0,G=6,$=!1,R=(process.env.NVIDIA_BASE_URL||"https://integrate.api.nvidia.com/v1").trim(),v=R.replace(/\/+$/,"");if(!v.endsWith("/v1")&&!v.endsWith("/v1/chat/completions"))throw new Error(`Invalid NVIDIA Base URL: "${R}". Endpoint URL MUST end with /v1 (e.g. https://integrate.api.nvidia.com/v1 or http://.../v1).`);let ae=v.endsWith("/chat/completions")?v:`${v}/chat/completions`,ie=process.env.NVIDIA_API_KEY&&process.env.NVIDIA_BASE_URL?process.env.NVIDIA_API_KEY:M;for(;V<G;){V++;try{let i=await j(ae,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ie}`},body:JSON.stringify(a),signal:I});if(!i.ok){let x=await i.text().catch(()=>""),S=i.statusText;try{let m=JSON.parse(x);S=m.error?.message||m.message||JSON.stringify(m.detail||m)}catch{x&&(S=x)}let b=new Error(`NVIDIA API Error (${i.status}): ${S}`);throw b.status=i.status,b}let N=i.body.getReader(),d=new TextDecoder,u="",r=[],f=null,q=Date.now(),_=!1;for(;;){let{done:x,value:S}=await N.read();if(x){_&&(r.length>0||f)&&(yield{candidates:r.length>0?[{content:{parts:r}}]:[],usageMetadata:f},$=!0);break}u+=d.decode(S,{stream:!0});let b=u.split(`
1
+ import{a as j}from"./chunk-NL4MAQSB.js";import{a as W}from"./chunk-HFTI3R3Q.js";import{l as K}from"./chunk-KMOTPBF5.js";import"./chunk-26BQ45XP.js";var ue=async function*(M,e,k,c,g,D,w=!1,I,H=1){let A=[];c&&A.push({role:"system",content:c}),k.forEach(i=>{let N=i.role==="model"?"assistant":"user",d=[];Array.isArray(i.parts)&&i.parts.forEach(u=>{if(u.text)d.push({type:"text",text:u.text});else if(u.inlineData&&w){let r=u.inlineData.mimeType,f=u.inlineData.data;r.startsWith("image/")&&K(e)&&d.push({type:"image_url",image_url:{url:`data:${r};base64,${f}`}})}}),A.push({role:N,content:d.length===1&&d[0].type==="text"?d[0].text:d})});let T=W("NVIDIA",e,g),t=T!==null?T:{Fast:"Fast",Low:"Fast",Medium:"Standard",Standard:"Standard",High:"High",xHigh:"High"}[g]||"High",o=t!=="Fast"&&t!=="none"&&t!=="disabled"&&t!==!1,s=e.includes("kimi"),n=e.includes("gemma"),h=e.includes("deepseek"),y=e.includes("glm"),z=e.includes("mistral"),P=e.includes("minimax"),J=e.includes("gpt"),Y=e.includes("qwen"),Q=e.includes("nemotron"),X=e.includes("llama-3"),Z=e.includes("seed"),B=e.includes("poolside"),C=e.includes("thinkingmachines")||e.includes("muse"),ee=X,te={Fast:"low",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},se={Fast:"64",Low:"64",Medium:"4096",Standard:"4096",High:"16384",xHigh:"16384"},ne={Fast:"none",Low:"minimal",Medium:"medium",Standard:"medium",High:"max",xHigh:"max"},U=P||h||B||C?16384:32768;U=process.env.NVIDIA_BASE_URL?1024:U;let a={model:e,messages:A,max_tokens:U,stream:!0,stream_options:{include_usage:!0},temperature:H,tools:[],tool_choice:"none",...J&&{thinking:te[g]||"high"}};if(!(process.env.NVIDIA_BASE_URL||ee))if(s)a.chat_template_kwargs={thinking:o};else if(n)a.chat_template_kwargs={enable_thinking:o};else if(h)if(o){let i=t==="High"?"max":"high";a.chat_template_kwargs={thinking:!0,reasoning_effort:i}}else a.chat_template_kwargs={thinking:!1};else y?a.chat_template_kwargs={enable_thinking:o,clear_thinking:!o}:z?a.reasoning_effort=o?"high":"none":P&&e.includes("minimax-m3")?a.chat_template_kwargs={thinking_mode:o?"enabled":"disabled"}:Y?a.chat_template_kwargs={enable_thinking:o}:Q?t==="High"?a.chat_template_kwargs={enable_thinking:!0}:t==="Standard"?a.chat_template_kwargs={enable_thinking:!0,medium_effort:!0}:a.chat_template_kwargs={enable_thinking:!1}:Z?o&&(a.extra_body={thinking_budget:parseInt(se[t]??"4096")}):B?a.chat_template_kwargs={enable_thinking:o}:C&&(a.reasoning_effort=ne[t]||"medium");let V=0,G=6,$=!1,R=(process.env.NVIDIA_BASE_URL||"https://integrate.api.nvidia.com/v1").trim(),v=R.replace(/\/+$/,"");if(!v.endsWith("/v1")&&!v.endsWith("/v1/chat/completions"))throw new Error(`Invalid NVIDIA Base URL: "${R}". Endpoint URL MUST end with /v1 (e.g. https://integrate.api.nvidia.com/v1 or http://.../v1).`);let ae=v.endsWith("/chat/completions")?v:`${v}/chat/completions`,ie=process.env.NVIDIA_API_KEY&&process.env.NVIDIA_BASE_URL?process.env.NVIDIA_API_KEY:M;for(;V<G;){V++;try{let i=await j(ae,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ie}`},body:JSON.stringify(a),signal:I});if(!i.ok){let x=await i.text().catch(()=>""),S=i.statusText;try{let m=JSON.parse(x);S=m.error?.message||m.message||JSON.stringify(m.detail||m)}catch{x&&(S=x)}let b=new Error(`NVIDIA API Error (${i.status}): ${S}`);throw b.status=i.status,b}let N=i.body.getReader(),d=new TextDecoder,u="",r=[],f=null,q=Date.now(),_=!1;for(;;){let{done:x,value:S}=await N.read();if(x){_&&(r.length>0||f)&&(yield{candidates:r.length>0?[{content:{parts:r}}]:[],usageMetadata:f},$=!0);break}u+=d.decode(S,{stream:!0});let b=u.split(`
2
2
  `);u=b.pop();let m=!1;for(let oe of b){let E=oe.trim();if(E){if(E==="data: [DONE]"){m=!0;break}if(E.startsWith("data: ")){let p;try{p=JSON.parse(E.substring(6))}catch{continue}if(p.error)throw new Error(`NVIDIA Stream Error: ${p.error.message||JSON.stringify(p.error)}`);try{let l=p.usage;l&&(f={totalTokenCount:l.total_tokens||l.prompt_tokens+l.completion_tokens,promptTokenCount:l.prompt_tokens||0,candidatesTokenCount:l.completion_tokens||0,cachedContentTokenCount:l.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:(l.completion_tokens_details?.reasoning_tokens||0)+(l.completion_tokens_details?.thoughts_tokens||0)},_=!0);let F=p.choices?.[0]?.delta?.reasoning||p.choices?.[0]?.delta?.reasoning_content||"",O=p.choices?.[0]?.delta?.content||"";F&&(r.push({text:F,thought:!0}),_=!0),O&&(r.push({text:O}),_=!0)}catch{}}}}if((m||Date.now()-q>=350)&&_&&(yield{candidates:r.length>0?[{content:{parts:[...r]}}]:[],usageMetadata:f},$=!0,r=[],q=Date.now(),_=!1),m)break}break}catch(i){if($||V>=G)throw i;await new Promise(N=>setTimeout(N,3500))}}},he=async function*(M,e){let k=[],c=null,g=!1,D=null,w=s=>{if(k.push(s),c){let n=c;c=null,n()}},I=e.split("/").pop(),H=Array.from(new Set([I,I.replace(/\./g,"-"),I.replace(/\./g,"_")])),T=["https://buildapi.ngc.nvidia.com/v2/predict/queues/models/qc69jvmznzxy","https://api.ngc.nvidia.com/v2/predict/queues/models/qc69jvmznzxy"].flatMap(s=>H.map(n=>`${s}/${n}`)),L=!1,t=null,o=async()=>{try{let n=await(await Promise.any(T.map(async h=>{let y=await fetch(h);if(!y.ok)throw new Error(`HTTP ${y.status}`);return y}))).json();if(n&&n.queues&&n.queues[0]&&typeof n.queues[0].queueDepth=="number"){let h=n.queues[0].queueDepth;L||w({value:{type:"status",content:`Queue ${h||1}`},done:!1})}}catch{}};process.env.NVIDIA_BASE_URL||(o(),t=setInterval(o,5e3)),(async()=>{try{let s=M[Symbol.asyncIterator]();for(;;){let{value:n,done:h}=await s.next();if(h)break;L=!0,t&&(clearInterval(t),t=null),w({value:n,done:!1})}g=!0,w(null)}catch(s){if(D=s,t&&(clearInterval(t),t=null),c){let n=c;c=null,n()}}})();try{for(;;){if(D)throw D;if(k.length>0){let s=k.shift();if(s===null&&g)break;yield s.value}else{if(g)break;await new Promise(s=>{c=s})}}}finally{t&&(clearInterval(t),t=null)}};export{ue as getNVIDIAStream,he as wrapNvidiaStreamWithQueueDepth};
@@ -1,2 +1,2 @@
1
- import{a as O}from"./chunk-FAEB3V5R.js";import"./chunk-M2ULCOL3.js";import{Ollama as D}from"ollama";var y=async function*(r,p,M,d,u,b,S,T,v=1,w="Cloud"){let m=[];d&&m.push({role:"system",content:d});for(let t of M){let l=t.role==="user"?"user":"assistant",a="",c=[];if(Array.isArray(t.parts)){a=t.parts.map(o=>o.text||"").filter(Boolean).join(`
1
+ import{a as O}from"./chunk-HFTI3R3Q.js";import"./chunk-26BQ45XP.js";import{Ollama as D}from"ollama";var y=async function*(r,p,M,d,u,b,S,T,v=1,w="Cloud"){let m=[];d&&m.push({role:"system",content:d});for(let t of M){let l=t.role==="user"?"user":"assistant",a="",c=[];if(Array.isArray(t.parts)){a=t.parts.map(o=>o.text||"").filter(Boolean).join(`
2
2
  `);for(let o of t.parts){let h=o.inlineData||o.inline_data;h&&h.data&&c.push(h.data)}}else a=t.text||"";if(a||c.length>0){let o={role:l,content:a};c.length>0&&(o.images=c),m.push(o)}}let f=w==="Local"||!r||r==="LOCAL",g={host:f?process.env.OLLAMA_HOST||"http://127.0.0.1:11434":process.env.OLLAMA_HOST||"https://ollama.com"};!f&&r&&(g.headers={Authorization:"Bearer "+r});let C=new D(g),e=[],i=null,_=Date.now(),n=!1,s=O("Ollama",p,u),k={Fast:!1,Low:"medium",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},A=s!==null?s==="false"||s===!1?!1:s==="true"||s===!0?!0:s:k[u]!==void 0?k[u]:!0,x={model:p,messages:m,stream:!0,think:A,keep_alive:"10m",tools:[],tool_choice:"none",options:{temperature:v}},L=await C.chat(x);for await(let t of L){if(T?.aborted)throw new DOMException("The user aborted a request.","AbortError");if(t.message?.thinking&&(e.push({text:t.message.thinking,thought:!0}),n=!0),t.message?.content&&(e.push({text:t.message.content}),n=!0),t.done){let l=t.prompt_cached_count||0;if(!l&&t.prompt_eval_count){let a=t.prompt_eval_duration||0;a>0&&a<5e7&&(l=t.prompt_eval_count)}i={totalTokenCount:(t.prompt_eval_count||0)+(t.eval_count||0),promptTokenCount:t.prompt_eval_count||0,candidatesTokenCount:t.eval_count||0,cachedContentTokenCount:l,thoughtsTokenCount:0},n=!0}(t.done||Date.now()-_>=150&&n)&&(yield{candidates:e.length>0?[{content:{parts:[...e]}}]:[],usageMetadata:i},e=[],_=Date.now(),n=!1)}n&&(e.length>0||i)&&(yield{candidates:e.length>0?[{content:{parts:[...e]}}]:[],usageMetadata:i})};export{y as getOllamaStream};
@@ -1,2 +1,2 @@
1
- import{a as E,b as R}from"./chunk-NL4MAQSB.js";import{a as b}from"./chunk-FAEB3V5R.js";import"./chunk-M2ULCOL3.js";var B=async function*(C,O,S,$,m,A,M,F,I=1,N=null){let y=[];$&&y.push({role:"system",content:[{type:"text",text:$}]});for(let e of S){let t=e.role==="user"?"user":"assistant",s=[];if(Array.isArray(e.parts)){for(let n of e.parts)if(n.text)s.push({type:"text",text:n.text});else if(n.inlineData&&M){let l=n.inlineData.mimeType,c=n.inlineData.data;l.startsWith("image/")?s.push({type:"image_url",image_url:{url:`data:${l};base64,${c}`}}):s.push({type:"file",file:{filename:n.filename||"file",file_data:`data:${l};base64,${c}`}})}}else{let n=e.text||"";n&&s.push({type:"text",text:n})}y.push({role:t,content:s.length===1&&s[0].type==="text"?s[0].text:s})}let j={Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},r=O,u=null,h=null;if(typeof r=="string"&&r.includes("::")){let e=r.indexOf("::"),t=r.slice(0,e).trim();t&&(u={only:[t],allow_fallbacks:!1}),r=r.slice(e+2).trim()}if(r.includes(":")){let e=r.split(":");if(e.length>1){let t=e[e.length-1].toLowerCase().trim();(t==="flex"||t==="priority")&&(h=t,e.pop())}r=e.join(":").trim()}let v=`${C.slice(-5)}${N||""}${m}${r}${h||""}${u?JSON.stringify(u):""}`,P=await R(v),g={model:r,messages:y,stream:!0,temperature:I,cache_control:{type:"ephemeral"},tools:[],tool_choice:"none",session_id:P};h&&(g.service_tier=h),u&&(g.provider=u);let x=b("OpenRouter",O,m),k=x!==null?x:j[m];k&&k!=="none"&&(x!==null||m!=="Fast")&&(g.reasoning_effort=k);let d=await E("https://openrouter.ai/api/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${C}`,"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(g),signal:F});if(!d.ok){let e=await d.json().catch(()=>({})),t=e.error?.metadata?.raw||e.error?.message||(typeof e.error=="string"?e.error:"")||d.statusText||"Unknown error";throw new Error(`OpenRouter Error (${d.status}): ${t}`)}let J=d.body.getReader(),W=new TextDecoder,T="",i=[],_=null,D=Date.now(),p=!1;for(;;){let{done:e,value:t}=await J.read();if(e){p&&(i.length>0||_)&&(yield{candidates:i.length>0?[{content:{parts:i}}]:[],usageMetadata:_});break}T+=W.decode(t,{stream:!0});let s=T.split(`
1
+ import{a as E,b as R}from"./chunk-NL4MAQSB.js";import{a as b}from"./chunk-HFTI3R3Q.js";import"./chunk-26BQ45XP.js";var B=async function*(C,O,S,$,m,A,M,F,I=1,N=null){let y=[];$&&y.push({role:"system",content:[{type:"text",text:$}]});for(let e of S){let t=e.role==="user"?"user":"assistant",s=[];if(Array.isArray(e.parts)){for(let n of e.parts)if(n.text)s.push({type:"text",text:n.text});else if(n.inlineData&&M){let l=n.inlineData.mimeType,c=n.inlineData.data;l.startsWith("image/")?s.push({type:"image_url",image_url:{url:`data:${l};base64,${c}`}}):s.push({type:"file",file:{filename:n.filename||"file",file_data:`data:${l};base64,${c}`}})}}else{let n=e.text||"";n&&s.push({type:"text",text:n})}y.push({role:t,content:s.length===1&&s[0].type==="text"?s[0].text:s})}let j={Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},r=O,u=null,h=null;if(typeof r=="string"&&r.includes("::")){let e=r.indexOf("::"),t=r.slice(0,e).trim();t&&(u={only:[t],allow_fallbacks:!1}),r=r.slice(e+2).trim()}if(r.includes(":")){let e=r.split(":");if(e.length>1){let t=e[e.length-1].toLowerCase().trim();(t==="flex"||t==="priority")&&(h=t,e.pop())}r=e.join(":").trim()}let v=`${C.slice(-5)}${N||""}${m}${r}${h||""}${u?JSON.stringify(u):""}`,P=await R(v),g={model:r,messages:y,stream:!0,temperature:I,cache_control:{type:"ephemeral"},tools:[],tool_choice:"none",session_id:P};h&&(g.service_tier=h),u&&(g.provider=u);let x=b("OpenRouter",O,m),k=x!==null?x:j[m];k&&k!=="none"&&(x!==null||m!=="Fast")&&(g.reasoning_effort=k);let d=await E("https://openrouter.ai/api/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${C}`,"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(g),signal:F});if(!d.ok){let e=await d.json().catch(()=>({})),t=e.error?.metadata?.raw||e.error?.message||(typeof e.error=="string"?e.error:"")||d.statusText||"Unknown error";throw new Error(`OpenRouter Error (${d.status}): ${t}`)}let J=d.body.getReader(),W=new TextDecoder,T="",i=[],_=null,D=Date.now(),p=!1;for(;;){let{done:e,value:t}=await J.read();if(e){p&&(i.length>0||_)&&(yield{candidates:i.length>0?[{content:{parts:i}}]:[],usageMetadata:_});break}T+=W.decode(t,{stream:!0});let s=T.split(`
2
2
  `);T=s.pop();for(let n of s){let l=n.trim();if(!l||!l.startsWith("data: "))continue;let c=!1;if(l==="data: [DONE]")c=!0;else try{let o=JSON.parse(l.substring(6));if(o.error){let w=o.error.metadata?.raw||o.error.message||JSON.stringify(o.error);throw new Error(`OpenRouter Stream Error: ${w}`)}let f=o.choices?.[0]?.delta,a=o.usage;if(o.choices?.[0]?.finish_reason&&(c=!0),a&&(_={totalTokenCount:a.total_tokens||(a.prompt_tokens||0)+(a.completion_tokens||0),promptTokenCount:a.prompt_tokens||0,candidatesTokenCount:a.completion_tokens||0,cachedContentTokenCount:a.prompt_tokens_details?.cached_tokens||a.prompt_tokens_details?.cache_read_input_tokens||a.cache_read_input_tokens||0,thoughtsTokenCount:a.completion_tokens_details?.reasoning_tokens||0},p=!0),f){let w=f.reasoning||(f.reasoning_details?f.reasoning_details.map(X=>X.text).join(""):null);w&&(i.push({text:w,thought:!0}),p=!0),f.content&&(i.push({text:f.content}),p=!0)}}catch(o){if(o.message&&o.message.startsWith("OpenRouter Stream Error:"))throw o}if((c||Date.now()-D>=150)&&p&&(yield{candidates:i.length>0?[{content:{parts:[...i]}}]:[],usageMetadata:_},i=[],D=Date.now(),p=!1),c)break}}};export{B as getOpenRouterStream};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y}from"./chunk-M2ULCOL3.js";export{q as ACTIVE_TX_FILE,n as BACKUPS_DIR,s as CONTEXT_FILE,u as CU_CACHE_DIR,c as DATA_DIR,w as DEFAULT_EXCLUDES,a as FLUXFLOW_DIR,g as HISTORY_DIR,f as HISTORY_FILE,p as LEDGER_ADVANCE_FILE,o as LEDGER_FILE,d as LOGS_DIR,k as MEMORIES_FILE,t as PARSER_DIR,r as PATHS_FILE,e as SECRET_DIR,b as SETTINGS_FILE,m as TEMP_MEM_CHAT_FILE,l as TEMP_MEM_FILE,v as THINKING_CONFIG_FILE,i as USAGE_FILE,h as USAGE_FILE_OLD,j as USAGE_FILE_TIMED,x as getGitignoreExcludes,y as matchesPathPattern};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y}from"./chunk-26BQ45XP.js";export{q as ACTIVE_TX_FILE,n as BACKUPS_DIR,s as CONTEXT_FILE,u as CU_CACHE_DIR,c as DATA_DIR,w as DEFAULT_EXCLUDES,a as FLUXFLOW_DIR,g as HISTORY_DIR,f as HISTORY_FILE,p as LEDGER_ADVANCE_FILE,o as LEDGER_FILE,d as LOGS_DIR,k as MEMORIES_FILE,t as PARSER_DIR,r as PATHS_FILE,e as SECRET_DIR,b as SETTINGS_FILE,m as TEMP_MEM_CHAT_FILE,l as TEMP_MEM_FILE,v as THINKING_CONFIG_FILE,i as USAGE_FILE,h as USAGE_FILE_OLD,j as USAGE_FILE_TIMED,x as getGitignoreExcludes,y as matchesPathPattern};
@@ -1,2 +1,2 @@
1
- import{a as D}from"./chunk-NL4MAQSB.js";import{a as x}from"./chunk-FAEB3V5R.js";import"./chunk-M2ULCOL3.js";var F=async function*(b,k,C,y,w,S,P,M,$=1){let g=[];y&&g.push({role:"system",content:y});for(let i of C){let _=i.role==="user"?"user":"assistant",e=[];if(Array.isArray(i.parts)){for(let n of i.parts)if(n.text)e.push({type:"text",text:n.text});else if(n.inlineData&&P){let r=n.inlineData.mimeType,l=n.inlineData.data;r.startsWith("image/")&&e.push({type:"image_url",image_url:{url:`data:${r};base64,${l}`}})}}else{let n=i.text||"";n&&e.push({type:"text",text:n})}g.push({role:_,content:e.length===1&&e[0].type==="text"?e[0].text:e})}let s=x("Poolside",k,w),j=s!==null?s===!1||s==="false"||s==="none"||s==="Fast":w==="Fast",f={model:k,messages:g,stream:!0,stream_options:{include_usage:!0},temperature:$,tools:[],tool_choice:"none"};j?f.chat_template_kwargs={enable_thinking:!1}:s!==null&&typeof s=="object"?f.chat_template_kwargs=s:f.chat_template_kwargs={enable_thinking:!0};let c=await D("https://inference.poolside.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${b}`,"Content-Type":"application/json"},body:JSON.stringify(f),signal:M});if(!c.ok){let i=await c.json().catch(()=>({}));throw new Error(`Poolside Error (${c.status}): ${i.error?.message||c.statusText}`)}let N=c.body.getReader(),O=new TextDecoder,m="",t=[],p=null,h=Date.now(),o=!1;for(;;){let{done:i,value:_}=await N.read();if(i){o&&(t.length>0||p)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:p});break}m+=O.decode(_,{stream:!0});let e=m.split(`
1
+ import{a as D}from"./chunk-NL4MAQSB.js";import{a as x}from"./chunk-HFTI3R3Q.js";import"./chunk-26BQ45XP.js";var F=async function*(b,k,C,y,w,S,P,M,$=1){let g=[];y&&g.push({role:"system",content:y});for(let i of C){let _=i.role==="user"?"user":"assistant",e=[];if(Array.isArray(i.parts)){for(let n of i.parts)if(n.text)e.push({type:"text",text:n.text});else if(n.inlineData&&P){let r=n.inlineData.mimeType,l=n.inlineData.data;r.startsWith("image/")&&e.push({type:"image_url",image_url:{url:`data:${r};base64,${l}`}})}}else{let n=i.text||"";n&&e.push({type:"text",text:n})}g.push({role:_,content:e.length===1&&e[0].type==="text"?e[0].text:e})}let s=x("Poolside",k,w),j=s!==null?s===!1||s==="false"||s==="none"||s==="Fast":w==="Fast",f={model:k,messages:g,stream:!0,stream_options:{include_usage:!0},temperature:$,tools:[],tool_choice:"none"};j?f.chat_template_kwargs={enable_thinking:!1}:s!==null&&typeof s=="object"?f.chat_template_kwargs=s:f.chat_template_kwargs={enable_thinking:!0};let c=await D("https://inference.poolside.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${b}`,"Content-Type":"application/json"},body:JSON.stringify(f),signal:M});if(!c.ok){let i=await c.json().catch(()=>({}));throw new Error(`Poolside Error (${c.status}): ${i.error?.message||c.statusText}`)}let N=c.body.getReader(),O=new TextDecoder,m="",t=[],p=null,h=Date.now(),o=!1;for(;;){let{done:i,value:_}=await N.read();if(i){o&&(t.length>0||p)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:p});break}m+=O.decode(_,{stream:!0});let e=m.split(`
2
2
  `);m=e.pop();for(let n of e){let r=n.trim();if(!r||!r.startsWith("data: "))continue;let l=!1;if(r==="data: [DONE]")l=!0;else try{let u=JSON.parse(r.substring(6)),d=u.choices?.[0]?.delta,a=u.usage;if(u.choices?.[0]?.finish_reason&&(l=!0),a&&(p={totalTokenCount:a.total_tokens||(a.prompt_tokens||0)+(a.completion_tokens||0),promptTokenCount:a.prompt_tokens||0,candidatesTokenCount:a.completion_tokens||0,cachedContentTokenCount:a.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:a.completion_tokens_details?.reasoning_tokens||a.reasoning_tokens||0},o=!0),d){let T=d.reasoning_content||d.reasoning||null;T&&(t.push({text:T,thought:!0}),o=!0),d.content&&(t.push({text:d.content}),o=!0)}}catch{}if((l||Date.now()-h>=150)&&o&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:p},t=[],h=Date.now(),o=!1),l)break}Date.now()-h>=150&&o&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:p},t=[],h=Date.now(),o=!1)}};export{F as getPoolsideStream};
@@ -1 +1 @@
1
- import{c as a,d as n}from"./chunk-L3W2X74K.js";import{l as s,m as o}from"./chunk-M2ULCOL3.js";var g=async(u,E={})=>{let m=r=>{let t=new RegExp(`${r}\\s*[:=]\\s*(["'])(.*?)\\1(?=\\s*[,)]|\\s+\\w+\\s*[:=]|$)`,"s"),i=u.match(t);return i?i[2].trim():null},e=m("id"),c=m("summary");if(!e||!c)return"ERROR: Missing 'id' or 'summary' for saveSummary tool.";try{let r=a(s,{}),t=a(o,{});return t[e]=c,delete r[e],n(o,t),n(s,r),`Saved summary and purged raw memories for chat [${e}].`}catch(r){let t=r instanceof Error?r.message:String(r);return`ERROR: Failed to save summary for chat [${e}]: ${t}`}};export{g as saveSummary};
1
+ import{c as a,d as n}from"./chunk-P5HBJA23.js";import{l as s,m as o}from"./chunk-26BQ45XP.js";var g=async(u,E={})=>{let m=r=>{let t=new RegExp(`${r}\\s*[:=]\\s*(["'])(.*?)\\1(?=\\s*[,)]|\\s+\\w+\\s*[:=]|$)`,"s"),i=u.match(t);return i?i[2].trim():null},e=m("id"),c=m("summary");if(!e||!c)return"ERROR: Missing 'id' or 'summary' for saveSummary tool.";try{let r=a(s,{}),t=a(o,{});return t[e]=c,delete r[e],n(o,t),n(s,r),`Saved summary and purged raw memories for chat [${e}].`}catch(r){let t=r instanceof Error?r.message:String(r);return`ERROR: Failed to save summary for chat [${e}]: ${t}`}};export{g as saveSummary};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h}from"./chunk-MJL6DHQM.js";export{a as GRID_CONFIG,e as captureGriddedScreenshot,h as coordinates720pToGridId,d as getActiveDisplay,g as gridToNativeCoordinates,f as parseGridCodeTo720p,c as rawModelOnly,b as useModel};
1
+ import{a,b,c,d,e,f,g,h}from"./chunk-77QN4HDY.js";export{a as GRID_CONFIG,e as captureGriddedScreenshot,h as coordinates720pToGridId,d as getActiveDisplay,g as gridToNativeCoordinates,f as parseGridCodeTo720p,c as rawModelOnly,b as useModel};
@@ -1 +1 @@
1
- import{a as r}from"./chunk-CBFC5KUU.js";import"./chunk-MJL6DHQM.js";import{a as t}from"./chunk-Y5JU726N.js";var m=async(n,i={})=>{let o=t(n),e=(o.direction||"down").toLowerCase(),c=o.amount?parseInt(o.amount,10):6,s=o.gridId||o.grid||o.coordinate||o.target||o.id||null;return await r("scroll",s,{direction:e,amount:c})};export{m as scroll};
1
+ import{a as r}from"./chunk-CZK3QF2C.js";import"./chunk-77QN4HDY.js";import{a as t}from"./chunk-Y5JU726N.js";var m=async(n,i={})=>{let o=t(n),e=(o.direction||"down").toLowerCase(),c=o.amount?parseInt(o.amount,10):6,s=o.gridId||o.grid||o.coordinate||o.target||o.id||null;return await r("scroll",s,{direction:e,amount:c})};export{m as scroll};
@@ -1,4 +1,4 @@
1
- import{a as Y}from"./chunk-Y5JU726N.js";import{a as Q}from"./chunk-FSE4BZZZ.js";import"./chunk-PRTGV2R4.js";import"./chunk-L3W2X74K.js";import{w as V,x as q,y as J}from"./chunk-M2ULCOL3.js";import K from"fs/promises";import E from"path";import j from"fast-glob";import{Minimatch as tt}from"minimatch";async function A(f,o,n=f,p=1){if(p>12)return[];let h=[],s;try{s=await K.readdir(f,{withFileTypes:!0})}catch{return[]}for(let t of s){let a=E.join(f,t.name),y=E.relative(n,a),L=y.split(E.sep).map(w=>w.toLowerCase()),O=t.name.toLowerCase();if(!o.some(w=>{let F=w.toLowerCase();return F.startsWith(".")&&O.endsWith(F)?!0:L.some(M=>M===F||M.startsWith(".pnpm"))}))if(t.isDirectory()){let w=await A(a,o,n,p+1);h=h.concat(w)}else t.isFile()&&h.push({fullPath:a,relativePath:y})}return h}function rt(f,o,n=1/0){if(f===o)return 0;if(f.length===0)return o.length;if(o.length===0)return f.length;if(Math.abs(f.length-o.length)>n)return n+1;let p=Array.from({length:o.length+1},(h,s)=>s);for(let h=1;h<=f.length;h++){let s=[h],t=h;for(let a=1;a<=o.length;a++){let y=f[h-1]===o[a-1]?0:1,L=Math.min(s[a-1]+1,p[a]+1,p[a-1]+y);s.push(L),L<t&&(t=L)}if(p=s,t>n)return n+1}return p[o.length]}function nt(f,o){if(!f||!o)return!1;let n=f.toLowerCase(),p=o.toLowerCase();if(n.includes(p))return!0;let h=n.split(/[^a-z0-9]+/).filter(t=>t.length>0),s=p.split(/[^a-z0-9]+/).filter(t=>t.length>1||p.length===1&&t.length>0);return s.length===0?!1:s.every(t=>{let a=t.length<=2?0:t.length<=5?1:2;for(let y of h)if(y.includes(t)||t.length>=3&&y.length>=3&&Math.abs(y.length-t.length)<=a&&rt(t,y,a)<=a)return!0;return!1})}var gt=async f=>{let{keyword:o,path:n,fuzzy:p,subString:h,regex:s}=Y(f);if(o==null)return'ERROR: Missing "keyword" argument.';let t=String(o);if(n){let e=n.trim().toLowerCase();if(e==="#docs"||e==="#doc"||e==="#documentation"||e.includes("#skill/global/fluxflow")||e.startsWith("#skill"))return"ERROR: Cannot search in reserved VFS '#skill' namespace. Use 'ReadFile' to read specific skills."}let a=e=>e===!0||e==="true"||e===1||e==="1"||e==="yes",y=s===!1||s==="false"||s===0||s==="0"||s==="no",L=s===!0||s==="true"||s===1||s==="1"||s==="yes",O=a(p)||a(h),G=null,w=null;if(y)O||(w=new RegExp(`(?<![\\w])${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w])`,"i"));else{try{G=new RegExp(t,"i")}catch(e){if(L)return`ERROR: Invalid regex pattern "${t}": ${e.message}`}w=new RegExp(`(?<![\\w])${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w])`,"i")}let F=Array.from(new Set([...V,...q(process.cwd())])),M=150;try{let e=[],P=process.cwd(),u=null;if(n){let i=r=>r.startsWith("!")||!r.startsWith("-")?r:"!"+r.replace(/^-+/,""),g=n.split(";").map(r=>r.trim()).filter(Boolean).map(i).filter(r=>r!=="!"),c=g.some(r=>r.startsWith("!"));if(g.some(r=>j.isDynamicPattern(r)||/[*?{}[\]()|+]/.test(r))){u="glob";let r=n.replace(/\\/g,"/"),l=g.map(m=>m.replace(/\\/g,"/")),z=F.map(m=>m.startsWith(".")?`**/*${m}`:`**/${m}/**`);if(c&&!g.some(m=>!m.startsWith("!"))){let m=await A(P,F,P),R=$=>$.endsWith("/")?$+"**":$,d=l.filter($=>$.startsWith("!")).map($=>R($.slice(1))),v=l.filter($=>!$.startsWith("!")).map(R);e=m.filter($=>{let x=$.relativePath.replace(/\\/g,"/"),_=v.length===0||v.some(b=>{try{return new tt(b).match(x)}catch{return!1}}),Z=d.some(b=>{try{return new tt(b).match(x)}catch{return!1}});return _&&!Z})}else{let m=l.some(d=>/[\(\)\|]|\.\*/.test(d)),R=[];if(!m)try{R=await j(l,{cwd:P,ignore:z,dot:!0,onlyFiles:!0,absolute:!1})}catch{R=[]}if(R.length===0&&(m||j.isDynamicPattern(r))){let d=r.match(/^([^\*\?\(\)\|\[\]\s]+)\//),v=d&&!/[\*\?\(\)\|\[\]]/.test(d[1])?E.resolve(P,d[1]):P,$=await A(v,F,P);try{let x=r.replace(/^\.\//,"");x=x.replace(/\.\*\/(\\.|[^\/])/g,".*$1"),!x.startsWith("^")&&!x.startsWith(".*")&&(x=`.*${x}`);let _=new RegExp(x.endsWith("$")?x:`${x}$`,"i");e=$.filter(Z=>{let b=Z.relativePath.replace(/\\/g,"/");return _.test(b)})}catch{e=[]}}else e=R.map(d=>({fullPath:E.resolve(P,d),relativePath:d}))}}else{let r=[],l=!1,z=!1;for(let k of g){let m=k.replace(/[\/\\]+$/,""),R=E.resolve(P,m);try{let d=await K.stat(R);if(d.isDirectory()){z=!0;let v=await A(R,F,P);r.push(...v)}else if(d.isFile())l=!0,r.push({fullPath:R,relativePath:E.relative(P,R)});else return`ERROR: Path is neither a file nor a directory: ${k}`}catch{return`ERROR: Path not found: ${k}`}}e=r,l&&!z?u="file":u="dir"}}else e=await A(P,F);let et=e.map(async i=>{try{let g=await K.readFile(i.fullPath,"utf-8");if(g.includes("\0"))return[];let c=g.split(/\r?\n/),W=[];for(let l=0;l<c.length;l++)(O?c[l].toLowerCase().includes(t.toLowerCase())||nt(c[l],t):y?w&&w.test(c[l]):G&&G.test(c[l])||w&&w.test(c[l]))&&W.push({line:l+1,content:c[l].trim()});return W.length===0?null:{path:i.relativePath.replace(/\\/g,"/"),matches:W}}catch{return[]}}),st=await Promise.all(et),S=[],D=0;for(let i of st){if(!i||!i.matches)continue;if(D>=M)break;let g=M-D,c=i.matches.slice(0,g);S.push({path:i.path,matches:c}),D+=c.length}typeof global.gc=="function"&&global.gc();let I=null;if(S.length===0){let i=u==="file"?` in '${n}'`:u==="dir"||u==="glob"?` in '${n}'`:". Try to specify files",g=u==="dir"?"[DIR]":u==="glob"?"[GLOB]":"";return`${g}${g?" ":""}Found 0 matches of '${t}'${i}${I?` ${I}`:""}`}let B=I?` ${I}`:"",T=`${S.length} file${S.length===1?"":"s"}`,U=`${D} match${D===1?"":"es"}`,N;u==="file"?N=`Found ${U} of '${t}' in '${n}'${B}:`:u==="dir"||u==="glob"?N=`Found ${U} of '${t}' in '${n}' across ${T}${B}:`:N=`Found ${U} of '${t}' across ${T}${B}:`;let X=u==="dir"?"[DIR]":u==="glob"?"[GLOB]":"",C=`${X}${X?" ":""}${N}
1
+ import{a as Y}from"./chunk-Y5JU726N.js";import{a as Q}from"./chunk-IZQAF6KJ.js";import"./chunk-KMOTPBF5.js";import"./chunk-P5HBJA23.js";import{w as V,x as q,y as J}from"./chunk-26BQ45XP.js";import K from"fs/promises";import E from"path";import j from"fast-glob";import{Minimatch as tt}from"minimatch";async function A(f,o,n=f,p=1){if(p>12)return[];let h=[],s;try{s=await K.readdir(f,{withFileTypes:!0})}catch{return[]}for(let t of s){let a=E.join(f,t.name),y=E.relative(n,a),L=y.split(E.sep).map(w=>w.toLowerCase()),O=t.name.toLowerCase();if(!o.some(w=>{let F=w.toLowerCase();return F.startsWith(".")&&O.endsWith(F)?!0:L.some(M=>M===F||M.startsWith(".pnpm"))}))if(t.isDirectory()){let w=await A(a,o,n,p+1);h=h.concat(w)}else t.isFile()&&h.push({fullPath:a,relativePath:y})}return h}function rt(f,o,n=1/0){if(f===o)return 0;if(f.length===0)return o.length;if(o.length===0)return f.length;if(Math.abs(f.length-o.length)>n)return n+1;let p=Array.from({length:o.length+1},(h,s)=>s);for(let h=1;h<=f.length;h++){let s=[h],t=h;for(let a=1;a<=o.length;a++){let y=f[h-1]===o[a-1]?0:1,L=Math.min(s[a-1]+1,p[a]+1,p[a-1]+y);s.push(L),L<t&&(t=L)}if(p=s,t>n)return n+1}return p[o.length]}function nt(f,o){if(!f||!o)return!1;let n=f.toLowerCase(),p=o.toLowerCase();if(n.includes(p))return!0;let h=n.split(/[^a-z0-9]+/).filter(t=>t.length>0),s=p.split(/[^a-z0-9]+/).filter(t=>t.length>1||p.length===1&&t.length>0);return s.length===0?!1:s.every(t=>{let a=t.length<=2?0:t.length<=5?1:2;for(let y of h)if(y.includes(t)||t.length>=3&&y.length>=3&&Math.abs(y.length-t.length)<=a&&rt(t,y,a)<=a)return!0;return!1})}var gt=async f=>{let{keyword:o,path:n,fuzzy:p,subString:h,regex:s}=Y(f);if(o==null)return'ERROR: Missing "keyword" argument.';let t=String(o);if(n){let e=n.trim().toLowerCase();if(e==="#docs"||e==="#doc"||e==="#documentation"||e.includes("#skill/global/fluxflow")||e.startsWith("#skill"))return"ERROR: Cannot search in reserved VFS '#skill' namespace. Use 'ReadFile' to read specific skills."}let a=e=>e===!0||e==="true"||e===1||e==="1"||e==="yes",y=s===!1||s==="false"||s===0||s==="0"||s==="no",L=s===!0||s==="true"||s===1||s==="1"||s==="yes",O=a(p)||a(h),G=null,w=null;if(y)O||(w=new RegExp(`(?<![\\w])${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w])`,"i"));else{try{G=new RegExp(t,"i")}catch(e){if(L)return`ERROR: Invalid regex pattern "${t}": ${e.message}`}w=new RegExp(`(?<![\\w])${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w])`,"i")}let F=Array.from(new Set([...V,...q(process.cwd())])),M=150;try{let e=[],P=process.cwd(),u=null;if(n){let i=r=>r.startsWith("!")||!r.startsWith("-")?r:"!"+r.replace(/^-+/,""),g=n.split(";").map(r=>r.trim()).filter(Boolean).map(i).filter(r=>r!=="!"),c=g.some(r=>r.startsWith("!"));if(g.some(r=>j.isDynamicPattern(r)||/[*?{}[\]()|+]/.test(r))){u="glob";let r=n.replace(/\\/g,"/"),l=g.map(m=>m.replace(/\\/g,"/")),z=F.map(m=>m.startsWith(".")?`**/*${m}`:`**/${m}/**`);if(c&&!g.some(m=>!m.startsWith("!"))){let m=await A(P,F,P),R=$=>$.endsWith("/")?$+"**":$,d=l.filter($=>$.startsWith("!")).map($=>R($.slice(1))),v=l.filter($=>!$.startsWith("!")).map(R);e=m.filter($=>{let x=$.relativePath.replace(/\\/g,"/"),_=v.length===0||v.some(b=>{try{return new tt(b).match(x)}catch{return!1}}),Z=d.some(b=>{try{return new tt(b).match(x)}catch{return!1}});return _&&!Z})}else{let m=l.some(d=>/[\(\)\|]|\.\*/.test(d)),R=[];if(!m)try{R=await j(l,{cwd:P,ignore:z,dot:!0,onlyFiles:!0,absolute:!1})}catch{R=[]}if(R.length===0&&(m||j.isDynamicPattern(r))){let d=r.match(/^([^\*\?\(\)\|\[\]\s]+)\//),v=d&&!/[\*\?\(\)\|\[\]]/.test(d[1])?E.resolve(P,d[1]):P,$=await A(v,F,P);try{let x=r.replace(/^\.\//,"");x=x.replace(/\.\*\/(\\.|[^\/])/g,".*$1"),!x.startsWith("^")&&!x.startsWith(".*")&&(x=`.*${x}`);let _=new RegExp(x.endsWith("$")?x:`${x}$`,"i");e=$.filter(Z=>{let b=Z.relativePath.replace(/\\/g,"/");return _.test(b)})}catch{e=[]}}else e=R.map(d=>({fullPath:E.resolve(P,d),relativePath:d}))}}else{let r=[],l=!1,z=!1;for(let k of g){let m=k.replace(/[\/\\]+$/,""),R=E.resolve(P,m);try{let d=await K.stat(R);if(d.isDirectory()){z=!0;let v=await A(R,F,P);r.push(...v)}else if(d.isFile())l=!0,r.push({fullPath:R,relativePath:E.relative(P,R)});else return`ERROR: Path is neither a file nor a directory: ${k}`}catch{return`ERROR: Path not found: ${k}`}}e=r,l&&!z?u="file":u="dir"}}else e=await A(P,F);let et=e.map(async i=>{try{let g=await K.readFile(i.fullPath,"utf-8");if(g.includes("\0"))return[];let c=g.split(/\r?\n/),W=[];for(let l=0;l<c.length;l++)(O?c[l].toLowerCase().includes(t.toLowerCase())||nt(c[l],t):y?w&&w.test(c[l]):G&&G.test(c[l])||w&&w.test(c[l]))&&W.push({line:l+1,content:c[l].trim()});return W.length===0?null:{path:i.relativePath.replace(/\\/g,"/"),matches:W}}catch{return[]}}),st=await Promise.all(et),S=[],D=0;for(let i of st){if(!i||!i.matches)continue;if(D>=M)break;let g=M-D,c=i.matches.slice(0,g);S.push({path:i.path,matches:c}),D+=c.length}typeof global.gc=="function"&&global.gc();let I=null;if(S.length===0){let i=u==="file"?` in '${n}'`:u==="dir"||u==="glob"?` in '${n}'`:". Try to specify files",g=u==="dir"?"[DIR]":u==="glob"?"[GLOB]":"";return`${g}${g?" ":""}Found 0 matches of '${t}'${i}${I?` ${I}`:""}`}let B=I?` ${I}`:"",T=`${S.length} file${S.length===1?"":"s"}`,U=`${D} match${D===1?"":"es"}`,N;u==="file"?N=`Found ${U} of '${t}' in '${n}'${B}:`:u==="dir"||u==="glob"?N=`Found ${U} of '${t}' in '${n}' across ${T}${B}:`:N=`Found ${U} of '${t}' across ${T}${B}:`;let X=u==="dir"?"[DIR]":u==="glob"?"[GLOB]":"",C=`${X}${X?" ":""}${N}
2
2
 
3
3
  `,H="";try{let i=await Q();i?.systemSettings?.alwaysAskFiles&&(H=i.systemSettings.alwaysAskFiles)}catch{}for(let i of S)if(C+=`${i.path}:
4
4
  `,J(i.path,H)){let c=i.matches.map(W=>`Line ${W.line}`).join(", ");C+=` ${c}. Line snapshot not available due to file restriction policy. ReadFile if needed
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-ET66XVIM.js";import"./chunk-L3W2X74K.js";import"./chunk-M2ULCOL3.js";export{a as getAPIKey,b as getProviderAPIKey,f as getSearchSecrets,d as getSecret,k as removeAPIKey,j as removeSecret,g as saveAPIKey,c as saveProviderAPIKey,i as saveSearchId,h as saveSearchKey,e as saveSecret};
1
+ import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-FXRFFNRK.js";import"./chunk-P5HBJA23.js";import"./chunk-26BQ45XP.js";export{a as getAPIKey,b as getProviderAPIKey,f as getSearchSecrets,d as getSecret,k as removeAPIKey,j as removeSecret,g as saveAPIKey,c as saveProviderAPIKey,i as saveSearchId,h as saveSearchKey,e as saveSecret};
@@ -1,2 +1,2 @@
1
- import{a as C}from"./chunk-NL4MAQSB.js";import{a as T}from"./chunk-FAEB3V5R.js";import"./chunk-M2ULCOL3.js";var W=async function*(M,m,S,k,_,O,b,N,v=1){let f=[];k&&f.push({role:"system",content:k});for(let s of S){let g=s.role==="user"?"user":"assistant",e=[];if(Array.isArray(s.parts)){for(let o of s.parts)if(o.text)e.push({type:"text",text:o.text});else if(o.inlineData&&b){let i=o.inlineData.mimeType,l=o.inlineData.data;i.startsWith("image/")&&e.push({type:"image_url",image_url:{url:`data:${i};base64,${l}`}})}}else{let o=s.text||"";o&&e.push({type:"text",text:o})}f.push({role:g,content:e.length===1&&e[0].type==="text"?e[0].text:e})}let y=T("SenseNova",m,_),w=y!==null?y:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[_],x={model:m,messages:f,stream:!0,stream_options:{include_usage:!0},temperature:v,tools:[],tool_choice:"none"};w&&(x.reasoning_effort=w);let c=await C("https://token.sensenova.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${M}`,"Content-Type":"application/json"},body:JSON.stringify(x),signal:N});if(!c.ok){let s=await c.json().catch(()=>({}));throw new Error(`SenseNova Error (${c.status}): ${s.error?.message||c.statusText}`)}let E=c.body.getReader(),$=new TextDecoder,h="",t=[],r=null,p=Date.now(),a=!1;for(;;){let{done:s,value:g}=await E.read();if(s){a&&(t.length>0||r)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:r});break}h+=$.decode(g,{stream:!0});let e=h.split(`
1
+ import{a as C}from"./chunk-NL4MAQSB.js";import{a as T}from"./chunk-HFTI3R3Q.js";import"./chunk-26BQ45XP.js";var W=async function*(M,m,S,k,_,O,b,N,v=1){let f=[];k&&f.push({role:"system",content:k});for(let s of S){let g=s.role==="user"?"user":"assistant",e=[];if(Array.isArray(s.parts)){for(let o of s.parts)if(o.text)e.push({type:"text",text:o.text});else if(o.inlineData&&b){let i=o.inlineData.mimeType,l=o.inlineData.data;i.startsWith("image/")&&e.push({type:"image_url",image_url:{url:`data:${i};base64,${l}`}})}}else{let o=s.text||"";o&&e.push({type:"text",text:o})}f.push({role:g,content:e.length===1&&e[0].type==="text"?e[0].text:e})}let y=T("SenseNova",m,_),w=y!==null?y:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[_],x={model:m,messages:f,stream:!0,stream_options:{include_usage:!0},temperature:v,tools:[],tool_choice:"none"};w&&(x.reasoning_effort=w);let c=await C("https://token.sensenova.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${M}`,"Content-Type":"application/json"},body:JSON.stringify(x),signal:N});if(!c.ok){let s=await c.json().catch(()=>({}));throw new Error(`SenseNova Error (${c.status}): ${s.error?.message||c.statusText}`)}let E=c.body.getReader(),$=new TextDecoder,h="",t=[],r=null,p=Date.now(),a=!1;for(;;){let{done:s,value:g}=await E.read();if(s){a&&(t.length>0||r)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:r});break}h+=$.decode(g,{stream:!0});let e=h.split(`
2
2
  `);h=e.pop();for(let o of e){let i=o.trim();if(!i||!i.startsWith("data: "))continue;let l=!1;if(i==="data: [DONE]")l=!0;else try{let d=JSON.parse(i.substring(6)),u=d.choices?.[0]?.delta,n=d.usage;if(n&&(r={totalTokenCount:n.total_tokens||(n.prompt_tokens||0)+(n.completion_tokens||0),promptTokenCount:n.prompt_tokens||0,candidatesTokenCount:n.completion_tokens||0,cachedContentTokenCount:n.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:n.completion_tokens_details?.reasoning_tokens||n.reasoning_tokens||0},a=!0),u){let D=u.reasoning||u.reasoning_content||null;D&&(t.push({text:D,thought:!0}),a=!0),u.content&&(t.push({text:u.content}),a=!0)}}catch{}if((l||Date.now()-p>=150||r)&&a&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:r},t=[],p=Date.now(),a=!1),l)break}Date.now()-p>=150&&a&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:r},t=[],p=Date.now(),a=!1)}};export{W as getSenseNovaStream};
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-IZQAF6KJ.js";import"./chunk-KMOTPBF5.js";import"./chunk-P5HBJA23.js";import"./chunk-26BQ45XP.js";export{a as loadSettings,b as saveSettings};
@@ -1,4 +1,4 @@
1
- import{a as h}from"./chunk-3JI2CRXK.js";import{a as C}from"./chunk-Y5JU726N.js";import"./chunk-L3W2X74K.js";import{c as $}from"./chunk-M2ULCOL3.js";import l from"fs";import R from"path";var E=async(x,S={})=>{let{method:f,tasks:m,markDone:d}=C(x),A=S.chatId||"default";if(!f)return'ERROR: Missing "method" argument for Goal tool (create/append/get).';let u=R.join($,"plan",A),o=R.join(u,"todo.md"),W=t=>{if(!t||Array.isArray(t))return t;let s=String(t).trim();if(s.startsWith("[")&&s.endsWith("]")){let i=s.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);return i?i.map(n=>n.slice(1,-1).replace(/\\(.)/g,"$1")):s.slice(1,-1).split(",").map(n=>n.trim()).filter(Boolean)}return t},k=t=>{let s=W(t);return s?(Array.isArray(s)?s:String(s).split(`
1
+ import{a as h}from"./chunk-6EYQQ7GQ.js";import{a as C}from"./chunk-Y5JU726N.js";import"./chunk-P5HBJA23.js";import{c as $}from"./chunk-26BQ45XP.js";import l from"fs";import R from"path";var E=async(x,S={})=>{let{method:f,tasks:m,markDone:d}=C(x),A=S.chatId||"default";if(!f)return'ERROR: Missing "method" argument for Goal tool (create/append/get).';let u=R.join($,"plan",A),o=R.join(u,"todo.md"),W=t=>{if(!t||Array.isArray(t))return t;let s=String(t).trim();if(s.startsWith("[")&&s.endsWith("]")){let i=s.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);return i?i.map(n=>n.slice(1,-1).replace(/\\(.)/g,"$1")):s.slice(1,-1).split(",").map(n=>n.trim()).filter(Boolean)}return t},k=t=>{let s=W(t);return s?(Array.isArray(s)?s:String(s).split(`
2
2
  `)).map(n=>{let r=String(n).trim();return r?r.startsWith("- [ ]")||r.startsWith("- [x]")||r.startsWith("- [X]")?r:`- [ ] ${r}`:null}).filter(Boolean).join(`
3
3
  `)+`
4
4
  `:""},y=(t,s)=>{if(!s)return{content:t,markedCount:0};let i=W(s),n=(Array.isArray(i)?i:[i]).map(p=>String(p).replace(/^- \[[xX ]\]\s*/i,"").trim()).filter(Boolean),r=t.split(`
@@ -1,2 +1,2 @@
1
- import{a as R}from"./chunk-NL4MAQSB.js";import{a as C}from"./chunk-FAEB3V5R.js";import"./chunk-M2ULCOL3.js";var J=async function*(A,k,N,y,x,$,M,v,B=1){let g=[];y&&g.push({role:"system",content:y});for(let s of N){let T=s.role==="user"?"user":"assistant",e=[];if(Array.isArray(s.parts)){for(let n of s.parts)if(n.text)e.push({type:"text",text:n.text});else if(n.inlineData&&M){let i=n.inlineData.mimeType,u=n.inlineData.data;i.startsWith("image/")&&e.push({type:"image_url",image_url:{url:`data:${i};base64,${u}`}})}}else{let n=s.text||"";n&&e.push({type:"text",text:n})}g.push({role:T,content:e.length===1&&e[0].type==="text"?e[0].text:e})}let w=C("TokenHarbor",k,x),H=w!==null?w:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[x],D={model:k,messages:g,stream:!0,stream_options:{include_usage:!0},temperature:B,tools:[],tool_choice:"none"};H&&(D.reasoning_effort=H);let K=process.env.TOKENHARBOR_URL||process.env.TOKEN_HARBOR_URL||"https://tokenharbor.ai/v1/chat/completions",O={"Content-Type":"application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow","HTTP-Referer":"https://fluxflow-cli.onrender.com/"},P=A||process.env.TOKENHARBOR_API_KEY||process.env.TOKEN_HARBOR_API_KEY||"";O.Authorization=`Bearer ${P}`;let l=await R(K,{method:"POST",headers:O,body:JSON.stringify(D),signal:v});if(!l.ok){let s=await l.json().catch(()=>({}));throw new Error(`Token Harbor Error (${l.status}): ${s.error?.message||s.message||l.statusText}`)}let F=l.body.getReader(),L=new TextDecoder,m="",t=[],c=null,f=Date.now(),o=!1,d=[],E=0,S=5,b=!0,_=()=>{d.length>0&&(t.push(...d),d=[],o=!0),b=!1};for(;;){let{done:s,value:T}=await F.read();if(s){_(),o&&(t.length>0||c)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:c});break}m+=L.decode(T,{stream:!0});let e=m.split(`
1
+ import{a as R}from"./chunk-NL4MAQSB.js";import{a as C}from"./chunk-HFTI3R3Q.js";import"./chunk-26BQ45XP.js";var J=async function*(A,k,N,y,x,$,M,v,B=1){let g=[];y&&g.push({role:"system",content:y});for(let s of N){let T=s.role==="user"?"user":"assistant",e=[];if(Array.isArray(s.parts)){for(let n of s.parts)if(n.text)e.push({type:"text",text:n.text});else if(n.inlineData&&M){let i=n.inlineData.mimeType,u=n.inlineData.data;i.startsWith("image/")&&e.push({type:"image_url",image_url:{url:`data:${i};base64,${u}`}})}}else{let n=s.text||"";n&&e.push({type:"text",text:n})}g.push({role:T,content:e.length===1&&e[0].type==="text"?e[0].text:e})}let w=C("TokenHarbor",k,x),H=w!==null?w:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[x],D={model:k,messages:g,stream:!0,stream_options:{include_usage:!0},temperature:B,tools:[],tool_choice:"none"};H&&(D.reasoning_effort=H);let K=process.env.TOKENHARBOR_URL||process.env.TOKEN_HARBOR_URL||"https://tokenharbor.ai/v1/chat/completions",O={"Content-Type":"application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow","HTTP-Referer":"https://fluxflow-cli.onrender.com/"},P=A||process.env.TOKENHARBOR_API_KEY||process.env.TOKEN_HARBOR_API_KEY||"";O.Authorization=`Bearer ${P}`;let l=await R(K,{method:"POST",headers:O,body:JSON.stringify(D),signal:v});if(!l.ok){let s=await l.json().catch(()=>({}));throw new Error(`Token Harbor Error (${l.status}): ${s.error?.message||s.message||l.statusText}`)}let F=l.body.getReader(),L=new TextDecoder,m="",t=[],c=null,f=Date.now(),o=!1,d=[],E=0,S=5,b=!0,_=()=>{d.length>0&&(t.push(...d),d=[],o=!0),b=!1};for(;;){let{done:s,value:T}=await F.read();if(s){_(),o&&(t.length>0||c)&&(yield{candidates:t.length>0?[{content:{parts:t}}]:[],usageMetadata:c});break}m+=L.decode(T,{stream:!0});let e=m.split(`
2
2
  `);m=e.pop();for(let n of e){let i=n.trim();if(!i||!i.startsWith("data: "))continue;let u=!1;if(i==="data: [DONE]")u=!0,_();else try{let p=JSON.parse(i.substring(6)),a=p.choices?.[0]?.delta,r=p.usage;if(r&&(c={totalTokenCount:r.total_tokens||(r.prompt_tokens||0)+(r.completion_tokens||0),promptTokenCount:r.prompt_tokens||0,candidatesTokenCount:r.completion_tokens||0,cachedContentTokenCount:r.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:r.completion_tokens_details?.reasoning_tokens||r.reasoning_tokens||0},o=!0),a){let h=a.reasoning_content||a.reasoning||null;!h&&Array.isArray(a.reasoning_details)&&a.reasoning_details.length>0&&(h=a.reasoning_details.map(U=>U.text||"").filter(Boolean).join("")),h&&(t.push({text:h,thought:!0}),o=!0),a.content&&(b?(d.push({text:a.content}),E++,E>=S&&_()):(t.push({text:a.content}),o=!0))}}catch{}if((u||Date.now()-f>=150)&&o&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:c},t=[],f=Date.now(),o=!1),u)break}Date.now()-f>=150&&o&&(yield{candidates:t.length>0?[{content:{parts:[...t]}}]:[],usageMetadata:c},t=[],f=Date.now(),o=!1)}};export{J as getTokenHarborStream};
@@ -1,4 +1,4 @@
1
- import{g as h,h as m,i as R}from"./chunk-2VV5ZE53.js";import{a as F}from"./chunk-3JI2CRXK.js";import{a as $}from"./chunk-Y5JU726N.js";import{a as g}from"./chunk-FSE4BZZZ.js";import"./chunk-PRTGV2R4.js";import"./chunk-L3W2X74K.js";import"./chunk-M2ULCOL3.js";import c from"fs";import P from"path";var j=async(w,y={})=>{let n=$(w),t=n.path;if(!t)return'ERROR: Missing "path" argument for PatchFile.';let{patchPairs:o,allowMultiple:E,error:p}=h(n);if(p)return`ERROR: ${p}`;if(o.length===0)return"ERROR: No valid replacement pairs found. Use searchContent1, newContent1, etc.";let M=n.allowMultiple!==void 0?n.allowMultiple===!0||String(n.allowMultiple).toLowerCase()==="true":E,i=P.resolve(process.cwd(),t);try{if(!c.existsSync(i))return`ERROR: File [${t}] does not exist. Use WriteFile instead.`;let e=y.forcedContent||c.readFileSync(i,"utf8");e.startsWith("\uFEFF")&&(e=e.slice(1));let s=e.replace(/\r\n/g,`
1
+ import{g as h,h as m,i as R}from"./chunk-EYTM4NZD.js";import{a as F}from"./chunk-6EYQQ7GQ.js";import{a as $}from"./chunk-Y5JU726N.js";import{a as g}from"./chunk-IZQAF6KJ.js";import"./chunk-KMOTPBF5.js";import"./chunk-P5HBJA23.js";import"./chunk-26BQ45XP.js";import c from"fs";import P from"path";var j=async(w,y={})=>{let n=$(w),t=n.path;if(!t)return'ERROR: Missing "path" argument for PatchFile.';let{patchPairs:o,allowMultiple:E,error:p}=h(n);if(p)return`ERROR: ${p}`;if(o.length===0)return"ERROR: No valid replacement pairs found. Use searchContent1, newContent1, etc.";let M=n.allowMultiple!==void 0?n.allowMultiple===!0||String(n.allowMultiple).toLowerCase()==="true":E,i=P.resolve(process.cwd(),t);try{if(!c.existsSync(i))return`ERROR: File [${t}] does not exist. Use WriteFile instead.`;let e=y.forcedContent||c.readFileSync(i,"utf8");e.startsWith("\uFEFF")&&(e=e.slice(1));let s=e.replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
3
  `),{content:u,results:l}=m(s,o,{allowMultiple:M}),a=l.filter(r=>!r.success),f=l.filter(r=>r.success);if(f.length===0)return`ERROR: Patch Failed to apply to [${t}].
4
4
  ${a.map(r=>` \u2022 ${r.error}`).join(`
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"./chunk-K4AZXTU6.js";import"./chunk-FSE4BZZZ.js";import"./chunk-PRTGV2R4.js";import"./chunk-L3W2X74K.js";import"./chunk-M2ULCOL3.js";export{n as addToUsage,c as calculateTokenCost,t as checkImageQuota,q as checkQuota,p as checkQuotaDetailed,e as forceFlushUsage,w as getAllUsageData,o as getCustomPeriodUsage,j as getDailyUsage,r as getImageQuotaBuckets,s as getImageQuotaLimit,u as getImageQuotaStats,k as getMonthlyUsage,h as getTimedUsage,l as incrementUsage,i as initUsage,d as invalidateCachedBaseUrl,g as purgeTimedUsage,v as recordImageGeneration,f as recordTimedUsage,m as runtimeSession,b as sendUsageFinalize,a as sendUsageHeartbeat};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"./chunk-QW6IGMYV.js";import"./chunk-IZQAF6KJ.js";import"./chunk-KMOTPBF5.js";import"./chunk-P5HBJA23.js";import"./chunk-26BQ45XP.js";export{n as addToUsage,c as calculateTokenCost,t as checkImageQuota,q as checkQuota,p as checkQuotaDetailed,e as forceFlushUsage,w as getAllUsageData,o as getCustomPeriodUsage,j as getDailyUsage,r as getImageQuotaBuckets,s as getImageQuotaLimit,u as getImageQuotaStats,k as getMonthlyUsage,h as getTimedUsage,l as incrementUsage,i as initUsage,d as invalidateCachedBaseUrl,g as purgeTimedUsage,v as recordImageGeneration,f as recordTimedUsage,m as runtimeSession,b as sendUsageFinalize,a as sendUsageHeartbeat};