fluxflow-cli 4.44.0 → 4.45.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.
- package/dist/chunks/ai-5NWQNNMC.js +1 -0
- package/dist/chunks/app-KYCCN4ZF.js +333 -0
- package/dist/chunks/{auto_completion-FSSLSASK.js → auto_completion-MS7UGN4H.js} +1 -1
- package/dist/chunks/{chunk-VHCXFHUU.js → chunk-5UIG3YUH.js} +1 -1
- package/dist/chunks/{chunk-UFLKOWYM.js → chunk-EIJ6AAGK.js} +1 -1
- package/dist/chunks/chunk-HTOLY3HR.js +1 -0
- package/dist/chunks/{chunk-3HU67EUI.js → chunk-KYQFLMZE.js} +11 -11
- package/dist/chunks/chunk-MKC4AVAL.js +44 -0
- package/dist/chunks/chunk-OECY2H5A.js +943 -0
- package/dist/chunks/{chunk-2SMAZY6E.js → chunk-TPUNXYGC.js} +1 -1
- package/dist/chunks/chunk-TQOQHYJ6.js +33 -0
- package/dist/chunks/chunk-UXLD7KTZ.js +1 -0
- package/dist/chunks/chunk-YEVCTH3B.js +1 -0
- package/dist/chunks/chunk-YSMPGXV3.js +1 -0
- package/dist/chunks/{click-C4LULADR.js → click-TFBIMVSS.js} +2 -2
- package/dist/chunks/{computer_action-HG5P5DOG.js → computer_action-DM2RWE3G.js} +1 -1
- package/dist/chunks/{drag-CIAOFEBD.js → drag-VXALN3P3.js} +1 -1
- package/dist/chunks/{exec_command-GXJWBNEI.js → exec_command-BDFXJQZJ.js} +1 -1
- package/dist/chunks/{generate_image-RAFSX2PO.js → generate_image-ABIDYET4.js} +1 -1
- package/dist/chunks/getProgress-J34K43Y7.js +24 -0
- package/dist/chunks/{invoke-K5DKH37G.js → invoke-7HHBCMTV.js} +2 -2
- package/dist/chunks/{invokeSync-U5FLY2AB.js → invokeSync-AULNCDC5.js} +2 -2
- package/dist/chunks/{key_press-3MUADXYA.js → key_press-YIUO27XG.js} +1 -1
- package/dist/chunks/{keyboard_typing-RDYAUO2I.js → keyboard_typing-Q5CUT6YK.js} +1 -1
- package/dist/chunks/{mistral-KIAEM23F.js → mistral-YTTOZB2J.js} +1 -1
- package/dist/chunks/{model_config-Q3PYM77Y.js → model_config-JTMSQGKH.js} +1 -1
- package/dist/chunks/{nvidia-2N7GMNVP.js → nvidia-ON4Q6Q26.js} +1 -1
- package/dist/chunks/{recapture_screen-CGAT4ZDO.js → recapture_screen-ILVFVUJF.js} +1 -1
- package/dist/chunks/{screen_grid-PAVYL4U2.js → screen_grid-MSVBHIGV.js} +1 -1
- package/dist/chunks/{scroll-V3SVOZW6.js → scroll-5XSQ6ZBZ.js} +1 -1
- package/dist/chunks/{search_keyword-OHDFK7MO.js → search_keyword-VY5KXDOB.js} +1 -1
- package/dist/chunks/secrets-HXB3H4UI.js +1 -0
- package/dist/chunks/secrets_v2-AEJNZCOS.js +1 -0
- package/dist/chunks/{settings-PADKHNGC.js → settings-XLD5ZEHD.js} +1 -1
- package/dist/chunks/{update_file-XM5PHLQU.js → update_file-VOCN7OPY.js} +1 -1
- package/dist/chunks/{usage-PVC3CXDR.js → usage-TNW22X3Y.js} +1 -1
- package/dist/chunks/{usageServer-SMP52LUG.js → usageServer-TAVWXYT6.js} +1 -1
- package/dist/chunks/{write_file-NTWH4NCN.js → write_file-R6BAMSDH.js} +1 -1
- package/dist/cli.js +5 -5
- package/dist/package.json +2 -2
- package/package.json +2 -2
- package/dist/chunks/ai-3J4SUC3U.js +0 -1
- package/dist/chunks/app-JSYMH7WB.js +0 -332
- package/dist/chunks/chunk-BB5UISPJ.js +0 -1
- package/dist/chunks/chunk-H3IDSRDO.js +0 -1
- package/dist/chunks/chunk-JDSDLNHL.js +0 -1
- package/dist/chunks/chunk-NN5WVXEF.js +0 -938
- package/dist/chunks/chunk-SML2NARF.js +0 -44
- package/dist/chunks/chunk-TXMOUQPV.js +0 -33
- package/dist/chunks/getProgress-FXNG2ISE.js +0 -26
- package/dist/chunks/secrets-FRPTIOJI.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{B as u}from"./chunk-
|
|
1
|
+
import{B as u}from"./chunk-OECY2H5A.js";import"./chunk-HFTI3R3Q.js";import"./chunk-52STSLCN.js";import"./chunk-56EJGQU3.js";import"./chunk-4BLSASW6.js";import"./chunk-MKC4AVAL.js";import"./chunk-KYQFLMZE.js";import"./chunk-Z5D4VQSG.js";import"./chunk-6EYQQ7GQ.js";import"./chunk-Y5JU726N.js";import{b as p}from"./chunk-UXLD7KTZ.js";import"./chunk-YEVCTH3B.js";import"./chunk-EIJ6AAGK.js";import{b as d}from"./chunk-YSMPGXV3.js";import{o as a}from"./chunk-HTOLY3HR.js";import"./chunk-P5HBJA23.js";import{a as l}from"./chunk-26BQ45XP.js";import m from"fs";import g from"path";var f=["Identity: Embedded IDE code completion engine","Context given: Code \xB1 cursor, file name & language","Task: Predict contextually accurate code at cursor position","","Rules:","- Return ONLY the raw code to insert at the cursor. No explanations, commentary or rambling","- Do NOT wrap in markdown code fences","- NEVER repeat code that exist before & after cursor, if nothing sensible possible to predict, return empty string","- Match surrounding indentation and code style","- Complete the current line statement","- Never include placeholder comments like // TODO or # your code here","- Do not put anything except the code to insert between the tags"].join(`
|
|
2
2
|
`);try{let t=g.join(l,".cache");m.existsSync(t)||m.mkdirSync(t,{recursive:!0}),m.writeFileSync(g.join(t,"completion.json"),JSON.stringify({systemPrompt:f},null,2))}catch{}var y=t=>{if(!t)return"";let e=t.match(/<completion>([\s\S]*?)<\/completion>/i);return e?e[1]:t},x=({prefix:t="",suffix:e="",fileName:o="",language:n="",recentChanges:r="",clipboard:i=""})=>{let c=r?["### Recent manual changes (context):",r,""]:[],s=i?["### Clipboard (context):",i,""]:[];return[`File: ${o}`,`Language: ${n}`,"","### Code before cursor:",t,"","[cursor here]","","### Code after cursor:",e,"",...c,...s,"### Completion to insert at cursor:"].join(`
|
|
3
3
|
`)},T=async(t={})=>{try{let e=await d(),o=e.autoCompletion||{};if(!o.enabled)return"";let n=o.provider||e.aiProvider||"Google",r=o.model&&o.model!=="Default"?o.model:e.activeModel||a(n,e.apiTier)||a(n,"paid");if(!r)return"";let i=await p(n);if(!i&&!(n==="c_openai"&&e.systemSettings?.customOpenAIBaseUrl))return"";let c={aiProvider:n,apiKey:i,model:r,mode:"flow",thinkingLevel:"Fast",systemSettings:e.systemSettings||{}},s=[{role:"user",parts:[{text:x(t)}]}],{text:h}=await u(c,r,s,f,"Fast");return y(h||"")}catch{return""}};export{f as AUTOCOMPLETE_SYSTEM_PROMPT,y as extractCompletion,T as generateAutoCompletion};
|
|
@@ -2,4 +2,4 @@ import{screen as j}from"@nut-tree-fork/nut-js";import P from"screenshot-desktop"
|
|
|
2
2
|
<rect x="${p+1}" y="${o+1}" width="${i-2}" height="${c-2}" fill="rgba(0, 255, 255, 0.015)" stroke="rgba(255, 255, 0, 0.3)" stroke-width="1.1" rx="2"/>
|
|
3
3
|
`;let w=s.some(t=>t!==a&&t.startY+t.cellH>=o-6&&t.startY<o&&Math.max(0,Math.min(p+i,t.startX+t.cellW)-Math.max(p,t.startX))>10),C=s.some(t=>t!==a&&t.startY<=o+c+6&&t.startY>o&&Math.max(0,Math.min(p+i,t.startX+t.cellW)-Math.max(p,t.startX))>10),g;if(a.isCustomY)g=u,!w&&g<o+11&&(g=Math.max(10,Math.min(g,o+4)));else{let t=a.yOffset!==void 0?a.yOffset:3;!w&&t<0&&(t=Math.min(t,-12));let Y=u+t,I=!w&&(t<0||Y<o+11)?Math.max(10,o+4):o+11,S=!C&&(t>0||Y>o+c-2)?Math.min(n-2,o+c+6):o+c+3;g=Math.max(I,Math.min(S,Y))}x+=`
|
|
4
4
|
<text x="${r}" y="${g}" font-family="'Segoe UI', Roboto, sans-serif" font-size="14" font-weight="600" fill="#FFFF00" stroke="#000000" stroke-width="2" paint-order="stroke fill" stroke-linejoin="round" opacity="0.8" text-anchor="middle">${M}</text>
|
|
5
|
-
`}return`<svg width="${e}" height="${n}" xmlns="http://www.w3.org/2000/svg">${x}</svg>`}var ot=1,J=e=>new Promise(n=>setTimeout(n,e));async function st(){try{let{loadSettings:e}=await import("./settings-
|
|
5
|
+
`}return`<svg width="${e}" height="${n}" xmlns="http://www.w3.org/2000/svg">${x}</svg>`}var ot=1,J=e=>new Promise(n=>setTimeout(n,e));async function st(){try{let{loadSettings:e}=await import("./settings-XLD5ZEHD.js"),n=await e();return Number(n.display||0)}catch{return 0}}async function at(){let e=await st();try{let n=await P.listDisplays();if(n&&n.length>0)return{format:"png",screen:(n[e]||n[0]).id}}catch{}return{format:"png"}}async function it(){let e=0,n=await at();for(;e<2;){let f=await P(n);await J(500);let m=await P(n);if(f.equals(m))return m;e++,e<2&&await J(3e3)}return await J(3e3),await P(n)}function ft(e=[],n=[]){if(!e||e.length===0)return n||[];if(!n||n.length===0)return e;let f=[...e],m=typeof e.getModelConfidence=="function"?e.getModelConfidence.bind(e):null;for(let s of n){if(m&&m(s.startX,s.startY,s.cellW,s.cellH)<.01)continue;let h=s.startX,y=s.startX+s.cellW,x=s.startY,a=s.startY+s.cellH;for(let M of e){let w=M.startX,C=M.startY,g=M.startX+M.cellW,t=M.startY+M.cellH;if(Math.max(0,Math.min(a,t)-Math.max(x,C))>s.cellH*.4&&w<y&&g>h){let I=(w+g)/2,S=(h+y)/2;I<=S?h=Math.max(h,g):y=Math.min(y,w)}}let l=y-h;if(l<18)continue;let d=h,p=x,o=y,i=a,c=Math.floor(h+l/2),r=s.cy,u=!1;for(let M of e){let w=M.startX,C=M.startY,g=M.startX+M.cellW,t=M.startY+M.cellH;if(c>=w&&c<=g&&r>=C&&r<=t){u=!0;break}let Y=Math.max(d,w),I=Math.max(p,C),S=Math.min(o,g),G=Math.min(i,t),X=Math.max(0,S-Y)*Math.max(0,G-I),T=(o-d)*(i-p);if(X/(T||1)>=.25){u=!0;break}}u||f.push({...s,startX:d,cellW:l,cx:c})}return f.sort((s,h)=>Math.abs(s.startY-h.startY)>18?s.startY-h.startY:s.startX-h.startX),f.forEach((s,h)=>{s.badgeId=h+1}),f}function ht(e,n,f,m){let s=e/f,h=n/m,y="";for(let a=0;a<=f;a++){let l=a*s;y+=`<line x1="${l}" y1="0" x2="${l}" y2="${n}" stroke="rgba(255, 255, 255, 0.28)" stroke-width="1.2"/>`}for(let a=0;a<=m;a++){let l=a*h;y+=`<line x1="0" y1="${l}" x2="${e}" y2="${l}" stroke="rgba(255, 255, 255, 0.28)" stroke-width="1.2"/>`}let x=1;for(let a=0;a<m;a++)for(let l=0;l<f;l++){let d=Math.floor(l*s+s/2),p=Math.floor(a*h+h/2)+5;y+=`<text x="${d}" y="${p}" font-family="'Segoe UI', Roboto, sans-serif" font-size="14" font-weight="700" fill="#FFFF00" stroke="#000000" stroke-width="2" paint-order="stroke fill" stroke-linejoin="round" opacity="0.95" text-anchor="middle">${x}</text>`,x++}return`<svg width="${e}" height="${n}" xmlns="http://www.w3.org/2000/svg">${y}</svg>`}async function pt(e={}){let n=typeof e=="boolean"?e:e?.canvasMode===!0||e?.canvas_mode===!0;try{let f=await it(),m=null,s="";if(n){U=!0;let d=q.COLS,p=q.ROWS,o=H.TARGET_WIDTH/d,i=H.TARGET_HEIGHT/p,c=[],r=1;for(let u=0;u<p;u++)for(let M=0;M<d;M++){let w=Math.floor(M*o),C=Math.floor(u*i);c.push({badgeId:r,cellNum:r,startX:w,startY:C,cellW:o,cellH:i,cx:Math.floor(w+o/2),cy:Math.floor(C+i/2)}),r++}_=c,m=c,s=ht(H.TARGET_WIDTH,H.TARGET_HEIGHT,d,p)}else{if(U=!1,rt){let d=(async()=>{try{let{detectUIBoxesONNX:p}=await import("./ui_detector_onnx-XRKXFWLG.js");return await p(f,H.TARGET_WIDTH,H.TARGET_HEIGHT)}catch{return null}})();if(lt)m=await d||[];else{let p=Z(f,!0),[o,i]=await Promise.all([d,p]);m=o&&o.length>0?ft(o,i):await Z(f,!1)}}else m=await Z(f,!1);_=m,s=ct(H.TARGET_WIDTH,H.TARGET_HEIGHT,H.COLS,H.ROWS,m)}let h=await K(f).resize(H.TARGET_WIDTH,H.TARGET_HEIGHT,{fit:"fill"}).composite([{input:Buffer.from(s),top:0,left:0}]).png({quality:100}).toBuffer();if(process.env.SHOW_DEBUG_GRID)try{let d=et.resolve(process.cwd(),"screenshots");await tt.ensureDir(d);let p=et.join(d,`${ot}.png`);await tt.writeFile(p,h),ot++}catch{}let y=h.toString("base64"),x=m?m.length:0,a=f,l=h;return a=null,l=null,{base64:y,mimeType:"image/png",width:H.TARGET_WIDTH,height:H.TARGET_HEIGHT,detectedCount:x}}catch(f){return console.error("Failed to capture gridded screenshot:",f),null}}function ut(e){if(e==null)return null;let n=null;if(typeof e=="number")n=e;else if(typeof e=="string"){let o=e.trim();if(/^\d+$/.test(o))n=parseInt(o,10);else{let i=o.match(/^([A-Z])([0-9]{1,2})$/i);if(i){let c=i[1].toUpperCase().charCodeAt(0)-65,r=parseInt(i[2],10)-1;n=c*H.COLS+r+1}}}if(n===null||isNaN(n))return null;if(_&&_.length>0){let o=_.find(i=>i.badgeId===n)||_.find(i=>i.cellNum===n);if(o){let i=U?q.COLS:H.COLS,c=o.col!==void 0?o.col:Math.floor((o.cellNum-1)%i),r=o.row!==void 0?o.row:Math.floor((o.cellNum-1)/i);return{x:o.cx,y:o.cy,colIdx:c>=0?c:0,rowIdx:r>=0?r:0,cellNum:n}}}let f=U?q.COLS:H.COLS,m=U?q.ROWS:H.ROWS,s=f*m;if(n<1||n>s)return null;let h=n-1,y=Math.floor(h/f),x=h%f,a=H.TARGET_WIDTH/f,l=H.TARGET_HEIGHT/m,d=Math.floor(x*a+a/2),p=Math.floor(y*l+l/2);return{x:d,y:p,colIdx:x,rowIdx:y,cellNum:n}}async function gt(e,n,f){let m=null;if(typeof e=="number"||typeof e=="string"?m=ut(e):e&&typeof e.x=="number"&&typeof e.y=="number"&&(m=e),!m)return null;let s=n,h=f,y=0,x=0,a=await st();try{let i=await P.listDisplays();if(i&&i.length>0){let c=i[a]||i[0];c.width&&c.height&&(s=c.width,h=c.height),c.left!==void 0&&(y=c.left),c.top!==void 0&&(x=c.top)}}catch{}if(!s||!h)try{let i=await P({}),c=await K(i).metadata();c&&c.width&&c.height?(s=c.width,h=c.height):(s=await j.width(),h=await j.height())}catch{(!s||!h)&&(s=await j.width(),h=await j.height())}let l=s/H.TARGET_WIDTH,d=h/H.TARGET_HEIGHT,p=Math.round(m.x*l)+y,o=Math.round(m.y*d)+x;return{x:p,y:o,screenW:s,screenH:h,offsetX:y,offsetY:x}}function wt(e){if(!e||typeof e.x!="number"||typeof e.y!="number")return null;if(_&&_.length>0){let x=_.find(d=>e.x>=d.startX&&e.x<=d.startX+d.cellW&&e.y>=d.startY&&e.y<=d.startY+d.cellH);if(x)return x.badgeId!==void 0?x.badgeId:x.cellNum;let a=null,l=1/0;for(let d of _){let p=e.x-d.cx,o=e.y-d.cy,i=p*p+o*o;i<l&&(l=i,a=d)}if(a&&l<=2025)return a.badgeId!==void 0?a.badgeId:a.cellNum}let n=U?q.COLS:H.COLS,f=U?q.ROWS:H.ROWS,m=H.TARGET_WIDTH/n,s=H.TARGET_HEIGHT/f,h=Math.max(0,Math.min(n-1,Math.floor(e.x/m)));return Math.max(0,Math.min(f-1,Math.floor(e.y/s)))*n+h+1}export{H as a,q as b,rt as c,lt as d,st as e,pt as f,ut as g,gt as h,wt as i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as z}from"./chunk-
|
|
1
|
+
import{b as z}from"./chunk-YSMPGXV3.js";import{p as ut}from"./chunk-HTOLY3HR.js";import{a as mt,b as W}from"./chunk-P5HBJA23.js";import{d as J,h as Z,i as M,j as b}from"./chunk-26BQ45XP.js";import S from"fs-extra";import U from"path";import bt from"http";import N from"fs-extra";import et from"path";import{spawn as vt}from"child_process";import{fileURLToPath as Ft}from"url";var $=52991,Rt=15e3,ft=et.join(J,"usage","usage_error.txt"),ht=async(e,t)=>{let o=t?.stack||t?.message||String(t);console.error(`[Usage Daemon Error] [${e}]:`,t);try{await N.ensureDir(et.dirname(ft));let s=`[${new Date().toISOString()}] [Daemon:${e}] ${o}
|
|
2
2
|
-------------------------------------
|
|
3
3
|
|
|
4
4
|
`;await N.appendFile(ft,s,"utf8")}catch{}},B={agent:0,background:0,search:0,toolSuccess:0,toolFailure:0,toolDenied:0,duration:0,tokens:0,cachedTokens:0,candidateTokens:0,linesAdded:0,linesRemoved:0,cost:0,imageCalls:[]},tt=(e,t)=>{if(!e)return{};let o=Object.keys(e),i=new Date(new Date(t).getTime()-720*60*60*1e3),s={};for(let n of o)new Date(n)>=i&&(s[n]=e[n]);return s};async function Ut(){let e=new Date().toISOString().split("T")[0],t=null;try{if(await N.exists(M)){let o=(await N.readFile(M,"utf8")).trim();o.startsWith("{")||o.startsWith("[")?t=JSON.parse(o):t=JSON.parse(W(o))}}catch(o){await ht("loadUsageFromDisk",o)}if(t){let o={...B,...t.stats||{}};Array.isArray(o.imageCalls)||(o.imageCalls=[]);let i=t.history||{},s=tt(i,e);if(t.date===e)return{...t,stats:o,history:s};{let n=t.date,c={...s};return n&&(c[n]=o),{date:e,stats:{...B},history:tt(c,e)}}}return{date:e,stats:{...B},history:{}}}async function Ot(e=$){let t=await Ut(),o=!1,i=!1,s=Date.now(),n=null,c=async()=>{if(t)try{await N.ensureDir(et.dirname(M));let l=new Date().toISOString().split("T")[0];t.history=tt(t.history||{},t.date||l),t.saveId=Math.random().toString(36).substring(2)+Date.now().toString(36);let a=mt(JSON.stringify(t,null,2));await N.writeFile(M,a,"utf8"),i=!1}catch(l){await ht("flushToDisk",l)}},r=async()=>{n&&clearInterval(n),await c(),m.close(()=>{process.exit(0)}),setTimeout(()=>process.exit(0),1e3).unref()};n=setInterval(async()=>{if(o)return;Date.now()-s>Rt&&await r()},5e3),n.unref&&n.unref();let m=bt.createServer(async(l,a)=>{let u=l.url||"";if(l.method==="POST"&&u==="/heartbeat"){o||(s=Date.now()),a.writeHead(200,{"Content-Type":"application/json"}),a.end(JSON.stringify({ok:!0}));return}if((l.method==="GET"||l.method==="POST")&&u==="/finalize"){o=!0,n&&clearInterval(n),await c(),a.writeHead(200,{"Content-Type":"application/json"}),a.end(JSON.stringify({success:!0,message:"Finalized and written to disk"})),setTimeout(()=>{m.close(()=>process.exit(0)),setTimeout(()=>process.exit(0),500).unref()},3e3);return}if(l.method==="POST"&&u==="/flush"){o||(s=Date.now(),await c()),a.writeHead(200,{"Content-Type":"application/json"}),a.end(JSON.stringify({success:!0}));return}if(l.method==="POST"&&u==="/write"){if(o){a.writeHead(403,{"Content-Type":"application/json"}),a.end(JSON.stringify({error:"Daemon finalized. Writes locked."}));return}s=Date.now();let d="";l.on("data",p=>{d+=p}),l.on("end",async()=>{try{let p=JSON.parse(d||"{}"),C=new Date().toISOString().split("T")[0];if(t.date!==C){let y=t.date;y&&(t.history||(t.history={}),t.history[y]={...t.stats}),t.date=C,t.stats={...B}}t.stats||(t.stats={...B});let{key:h,amount:f=1,provider:w,model:T}=p;if(h&&t.stats[h]!==void 0&&(h==="cost"?t.stats.cost=Number(((t.stats.cost||0)+Number(f)).toFixed(6)):typeof t.stats[h]=="number"&&(t.stats[h]+=Math.floor(f))),h==="agent"&&w&&(t.stats.providerRequests||(t.stats.providerRequests={}),t.stats.providerRequests[w]=(t.stats.providerRequests[w]||0)+Math.floor(f)),w&&T&&(h==="tokens"||h==="cachedTokens"||h==="candidateTokens"||h==="ttft"||h==="cost")){t.stats.models||(t.stats.models={}),t.stats.models[w]||(t.stats.models[w]={}),t.stats.models[w][T]||(t.stats.models[w][T]={tokens:0,cachedTokens:0,candidateTokens:0,ttftSum:0,ttftCalls:0,cost:0});let y=t.stats.models[w][T];h==="tokens"&&(y.tokens+=Math.floor(f)),h==="cachedTokens"&&(y.cachedTokens+=Math.floor(f)),h==="candidateTokens"&&(y.candidateTokens+=Math.floor(f)),h==="cost"&&(y.cost=Number(((y.cost||0)+Number(f)).toFixed(6))),h==="ttft"&&(y.ttftSum=(y.ttftSum||0)+Math.floor(f),y.ttftCalls=(y.ttftCalls||0)+1)}i=!0,await c(),a.writeHead(200,{"Content-Type":"application/json"}),a.end(JSON.stringify({success:!0}))}catch(p){a.writeHead(400,{"Content-Type":"application/json"}),a.end(JSON.stringify({error:p.message}))}});return}a.writeHead(404,{"Content-Type":"text/plain"}),a.end("Not Found")});m.listen(e,"127.0.0.1",()=>{s=Date.now()}),m.on("error",l=>{l.code==="EADDRINUSE"&&process.exit(0)})}async function At(e=$){try{if((await fetch(`http://127.0.0.1:${e}/heartbeat`,{method:"POST",signal:AbortSignal.timeout(300)})).ok)return!0}catch{}try{let t=Ft(import.meta.url);vt(process.execPath,[t,"--usage-daemon-worker",`--port=${e}`],{detached:!0,stdio:"ignore",windowsHide:!0}).unref();for(let i=0;i<10;i++){await new Promise(s=>setTimeout(s,100));try{if((await fetch(`http://127.0.0.1:${e}/heartbeat`,{method:"POST",signal:AbortSignal.timeout(300)})).ok)return!0}catch{}}}catch{}return!1}async function st(e,t=$){try{await At(t),await fetch(`http://127.0.0.1:${t}/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:AbortSignal.timeout(1e3)})}catch{}}async function It(e=$){try{await fetch(`http://127.0.0.1:${e}/heartbeat`,{method:"POST",signal:AbortSignal.timeout(600)})}catch{}}async function Et(e=$){try{await fetch(`http://127.0.0.1:${e}/finalize`,{method:"GET",signal:AbortSignal.timeout(1e3)})}catch{}}if(process.argv.includes("--usage-daemon-worker")){let e=process.argv.find(o=>o.startsWith("--port=")),t=e?parseInt(e.split("=")[1],10):$;Ot(t)}var pt=U.join(J,"usage","usage_error.txt"),H=new Map,Nt=(e,t)=>{let o=`${e}:${t}`;if(H.has(o))return H.get(o);try{let i=yt();if(S.existsSync(i)){let n=S.readFileSync(i,"utf8").split(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"./chunk-26BQ45XP.js";import d from"fs";import _ from"path";import{fileURLToPath as I}from"url";var g={version:0,release:20261004,fallbacks:{janitor_default:"gemini-3.5-flash-lite",janitor_attempts_fallback:"gemma-4-26b-a4b-it",janitor_open_router:"google/gemma-4-26b-a4b-it:free",general_fallback:"gemini-3.5-flash-lite",deepseek_fast_fallback:"deepseek-v4-flash",deepseek_level_1:"deepseek-flash",deepseek_level_2:"deepseek-pro",mistral_janitor_fallback:"",mistral_level_1:"",nvidia_janitor_fallback:"mistralai/mistral-nemotron",nvidia_chat_summarizer_fallback:"nvidia/nemotron-3-super-120b-a12b",google_level_1:"gemini-3-flash-preview",google_level_2:"gemini-3.7-flash",gemma_emergency:"gemma-4-31b-it",gemma_janitor_fallback_google_openrouter:"google/gemma-4-26b-a4b-it:free",gemma_janitor_fallback_google:"gemma-4-26b-a4b-it",inferx_fallback:"",sensenova_fallback:"",crofai_fallback:"",aihubmix_fallback:"",poolside_fallback:"","9router_fallback":"",explabs_fallback:"",tokenharbor_fallback:"",infron_fallback:"",xkiro_fallback:"",c_openai_fallback:""},providers:{}};var C=I(import.meta.url),F=_.dirname(C),y="",O=[_.join(F,"../../model_config.json"),_.join(F,"../model_config.json")];for(let e of O)try{if(d.existsSync(e)){y=e;break}}catch{}var v=_.join(p,"model_config.json"),a=null,k=()=>{if(y)try{let e=d.readFileSync(y,"utf-8"),t=JSON.parse(e);if(t&&typeof t=="object")return t}catch{}return g&&typeof g=="object"?JSON.parse(JSON.stringify(g)):{version:0,release:20260913,fallbacks:{},providers:{}}};if(d.existsSync(v))try{let e=d.readFileSync(v,"utf-8"),t=JSON.parse(e);if(t&&typeof t=="object"){let o=k();t.fallbacks={...o.fallbacks||{},...t.fallbacks||{}},t.providers||(t.providers={}),t.release||(t.release=o.release||20260913),a=t}}catch{}a||(a=k());var x=new Set,h=new Set,m=()=>{let e=new Set,t=new Set;if(a.providers)for(let o of Object.keys(a.providers)){let r=a.providers[o];if(r&&r.models){let i=["Free","Paid"];for(let n of i){let s=r.models[n];if(Array.isArray(s)){for(let l of s)if(l&&l.cmd){let f=l.cmd.trim().toLowerCase();l.multimodal===!0&&e.add(f),l.hasReasoning===!0&&t.add(f)}}}}}if(Array.isArray(a.multimodal_models))for(let o of a.multimodal_models)o&&typeof o=="string"&&e.add(o.trim().toLowerCase());x=e,h=t};m();var $=()=>a,u=()=>{try{return d.existsSync(p)||d.mkdirSync(p,{recursive:!0}),d.writeFileSync(v,JSON.stringify(a,null,2),"utf-8"),!0}catch{return!1}},U=(e,t,o=!1,r=null,i=null)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let n=t.trim();if(!n)return{success:!1,reason:"Model ID cannot be empty"};a.providers||(a.providers={}),a.providers[e]||(a.providers[e]={default_free:"",default_paid:"",models:{Free:[],Paid:[]}});let s=a.providers[e];s.models||(s.models={Free:[],Paid:[]}),Array.isArray(s.models.Free)||(s.models.Free=[]);let l=i?String(i).trim().replace(/\/+$/,""):null,f=s.models.Free.find(c=>(typeof c=="string"?c:c?.cmd)===n);if(f)if(typeof f=="string"){let c=s.models.Free.indexOf(f),b={cmd:n,multimodal:!!o,desc:n};r&&Object.keys(r).length>0&&(b.info=r),l&&(b.baseUrl=l),s.models.Free[c]=b}else f.multimodal=!!o,r&&Object.keys(r).length>0&&(f.info={...f.info||{},...r}),l&&(f.baseUrl=l);else{let c={cmd:n,multimodal:!!o,desc:n};r&&Object.keys(r).length>0&&(c.info=r),l&&(c.baseUrl=l),s.models.Free.push(c)}return m(),u(),{success:!0}},R=(e,t,o={})=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let r=t.trim();if(!r)return{success:!1,reason:"Model ID cannot be empty"};a.providers||(a.providers={}),a.providers[e]||(a.providers[e]={default_free:"",default_paid:"",models:{Free:[],Paid:[]}});let i=a.providers[e];i.models||(i.models={Free:[],Paid:[]}),Array.isArray(i.models.Free)||(i.models.Free=[]);let n=r.toLowerCase(),s=i.models.Free.find(l=>{let f=typeof l=="string"?l:l?.cmd;return f&&f.trim().toLowerCase()===n});if(o===null)s&&typeof s=="object"&&delete s.info;else if(!s)i.models.Free.push({cmd:r,multimodal:!1,desc:r,info:o});else if(typeof s=="string"){let l=i.models.Free.indexOf(s);i.models.Free[l]={cmd:s,multimodal:!1,desc:s,info:o}}else s.info={...s.info||{},...o};return u(),{success:!0}},T=(e,t,o=!0)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let r=t.trim();if(!r)return{success:!1,reason:"Model ID cannot be empty"};let i=a.providers?.[e];if(!i||!i.models||!Array.isArray(i.models.Free))return{success:!1,reason:`Provider ${e} has no models configured`};let n=i.models.Free.find(s=>(typeof s=="string"?s:s?.cmd)===r);if(!n)return{success:!1,reason:`Model "${r}" not found in ${e} model list`};if(typeof n=="string"){let s=i.models.Free.indexOf(n);i.models.Free[s]={cmd:r,multimodal:!!o,desc:r}}else n.multimodal=!!o;return m(),u(),{success:!0}},J=(e,t,o=!1,r=null)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let i=t.trim();if(!i)return{success:!1,reason:"Model ID cannot be empty"};a.providers||(a.providers={}),a.providers[e]||(a.providers[e]={default_free:"",default_paid:"",models:{Free:[],Paid:[]}});let n=a.providers[e];n.models||(n.models={Free:[],Paid:[]}),Array.isArray(n.models.Free)||(n.models.Free=[]);let s=n.models.Free.find(l=>(typeof l=="string"?l:l?.cmd)===i);if(s)if(typeof s=="string"){let l=n.models.Free.indexOf(s),f={cmd:i,multimodal:!!o,desc:i};r&&Object.keys(r).length>0&&(f.info=r),n.models.Free[l]=f}else o&&(s.multimodal=!0),r&&Object.keys(r).length>0&&(s.info={...s.info||{},...r});else{let l={cmd:i,multimodal:!!o,desc:i};r&&Object.keys(r).length>0&&(l.info=r),n.models.Free.push(l)}return n.default_free=i,m(),u(),{success:!0}},W=(e,t)=>{if(!e||!t)return{success:!1,reason:"Invalid provider or model ID"};let o=t.trim();if(!o)return{success:!1,reason:"Model ID cannot be empty"};let r=a.providers?.[e];if(!r||!r.models||!Array.isArray(r.models.Free))return{success:!1,reason:`Provider ${e} has no models configured`};let i=r.models.Free.findIndex(n=>(typeof n=="string"?n:n?.cmd)===o);return i===-1?{success:!1,reason:`Model "${o}" not found in ${e} model list`}:(r.models.Free.splice(i,1),r.default_free===o&&(r.default_free=""),r.default_paid===o&&(r.default_paid=""),m(),u(),{success:!0})},E=(e,t,o)=>{if(!e||!t||!o)return{success:!1,reason:"Invalid provider or model IDs"};let r=t.trim(),i=o.trim();if(!r||!i)return{success:!1,reason:"Model IDs cannot be empty"};let n=a.providers?.[e];if(!n||!n.models||!Array.isArray(n.models.Free))return{success:!1,reason:`Provider ${e} has no models configured`};let s=n.models.Free.find(l=>(typeof l=="string"?l:l?.cmd)===r);if(!s)return{success:!1,reason:`Model "${r}" not found in ${e} model list`};if(typeof s=="string"){let l=n.models.Free.indexOf(s);n.models.Free[l]={cmd:i,multimodal:!1,desc:i}}else s.cmd=i,(s.desc===r||!s.desc)&&(s.desc=i);return m(),u(),{success:!0}},M=!1,P=e=>{M=!!e},z=P,G=e=>{if(!e)return!1;let t=e.trim().toLowerCase();return!!(M||x.has(t)||t.startsWith("gemini-")||t.startsWith("gemma-"))},K=e=>{if(!e)return!1;let t=e.trim().toLowerCase();return h.has(t)},V=(e,t,o=null)=>{let r=a.providers[e];if(!r)return[];let i=r.models[t==="Free"?"Free":"Paid"]||[];if(e==="c_openai"&&o){let n=String(o).trim().replace(/\/+$/,"");return i.filter(s=>typeof s=="object"&&s?.baseUrl?s.baseUrl.replace(/\/+$/,"")===n:!0)}return i},X=(e,t)=>{let o=a.providers[e];return o?t==="Free"?o.default_free:o.default_paid:""},q=(e,t)=>{if(!e||!t||!a.providers)return null;let o=a.providers[e];if(!o||!o.models)return null;let r=t.trim().toLowerCase(),i=["Free","Paid"];for(let n of i){let s=o.models[n];if(Array.isArray(s)){for(let l of s)if(typeof l=="object"&&l?.cmd&&l.cmd.trim().toLowerCase()===r&&l.info)return{IN:Number(l.info.IN)||0,OUT:Number(l.info.OUT)||0,CR:Number(l.info.CR)||0,CW:Number(l.info.CW)||0}}}return null},B=e=>a?.fallbacks?.[e];export{g as a,$ as b,u as c,U as d,R as e,T as f,J as g,W as h,E as i,P as j,z as k,G as l,K as m,V as n,X as o,q as p,B as q};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import{execSync as
|
|
2
|
-
- Same file, multiple edits? One PatchFile \u226415 blocks${
|
|
1
|
+
import{execSync as a}from"child_process";import l from"fs";import c from"path";var t,I=()=>{if(process.platform!=="win32")return"bash";if(t!==void 0)return t;if(process.env.GIT_BASH_PATH&&l.existsSync(process.env.GIT_BASH_PATH))return t=process.env.GIT_BASH_PATH,t;let e=["C:\\Program Files\\Git\\bin\\bash.exe","C:\\Program Files (x86)\\Git\\bin\\bash.exe",c.join(process.env.LOCALAPPDATA||"","Programs\\Git\\bin\\bash.exe")];for(let r of e)if(r&&l.existsSync(r))return t=r,t;try{let n=a("where.exe git.exe",{encoding:"utf8",stdio:["ignore","pipe","ignore"],windowsHide:!0}).split(/\r?\n/).find(i=>i.trim().length>0);if(n){let i=c.resolve(c.dirname(n),"..","bin","bash.exe");if(l.existsSync(i))return t=i,t}}catch{}try{let n=a("where.exe bash.exe",{encoding:"utf8",stdio:["ignore","pipe","ignore"],windowsHide:!0}).split(/\r?\n/).find(i=>i.trim().length>0);if(n&&!n.toLowerCase().includes("system32"))return t=n,t}catch{}return t=null,null},b=()=>process.platform!=="win32"?!0:!!I(),s=null,k=()=>{if(process.platform!=="win32")return!1;if(s!==null)return s;try{a("where.exe pwsh.exe",{stdio:"ignore",windowsHide:!0}),s=!0}catch{s=!1}return s},o=null,d=()=>{if(process.platform!=="win32")return!1;if(o!==null)return o;try{a("where.exe powershell.exe",{stdio:"ignore",windowsHide:!0}),o=!0}catch{o=!1}return o},L=(e=!1)=>e&&b()?"bash":k()?"pwsh":d()?"powershell":"cmd",u=null,W=(e,r,n,i,w=!1,x=!0,v,y=!1,P=!0)=>{u===null&&(u=w);let p=r==="Windows",A=p&&P&&b(),g="Run(command=string)",f=`Runs ${p?d()?"powershell":"windows CMD":"bash"} command`;A&&(g=`Run(command=string, ${k()||d()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,f="Runs in git bash. Or force native shell");let C=`- JSON escape literal sequences, backslash: \\\\, newLine: \\ n
|
|
2
|
+
- Same file, multiple edits? One PatchFile \u226415 blocks${v?"":`
|
|
3
3
|
- Action denied? Ask for guidance`}
|
|
4
4
|
- Need text or large file? CodeSearch > Full Read
|
|
5
5
|
- Stuck on syntax error? Tell user > waste time
|
|
6
|
-
`,
|
|
6
|
+
`,h=`**Workspace (path = relative; first argument; separator: '/')**
|
|
7
7
|
- ReadFile(path=string, startLine?=int, endLine?=int)
|
|
8
8
|
- FindFile(basename=string)
|
|
9
9
|
- ReadFolder(path=string, recurse?=int[1..3])
|
|
10
10
|
- PatchFile(path=string, allowMultiple?=bool, searchContent1="string match OR ^LINE:start..end$", newContent1=string, ...MAX15). Small searchString. Line Anchor: ^LINE:...$ syntax, must for large blocks & escape sequences
|
|
11
11
|
- WriteFile(path=string, content=string). Creates/Overwrites. File Exist? PatchFile > WriteFile
|
|
12
12
|
- CodeSearch(keyword=string, path?="file/glob, inclusion !exclusion ;-separated", regex?=bool:auto)
|
|
13
|
-
-
|
|
13
|
+
- ${g}. ${f}. Destructive command \u2192 Ask user${y?"":`
|
|
14
14
|
- Goal(method="create/append/get", tasks=string[], markDone=string[]). If long multi-task: create Goals before starting. get + markDone marks complete`}
|
|
15
|
-
${
|
|
15
|
+
${u?`
|
|
16
16
|
**Emergency**
|
|
17
17
|
Info: initial = current task prompt. Revert id = turn before disaster (eg. disaster: turn_3 \u2192 revert: turn_2). Reason explicitly
|
|
18
18
|
- EmergencyRollback(method="getCheckpoint/forceRevert", id=string). Rollback workspace in this agent loop. ONLY for catastrophic corruption. Before ending, verify no catastrophe. getCheckpoint: id excluded
|
|
19
|
-
`:""}${
|
|
19
|
+
`:""}${x?`
|
|
20
20
|
**Sub Agent**
|
|
21
21
|
Default to using subagents whenever helpful, no user nudge needed
|
|
22
22
|
Invocations:
|
|
@@ -26,9 +26,9 @@ Invocations:
|
|
|
26
26
|
- Await(id=string, timeout?=int[..180])
|
|
27
27
|
- GetProgress(id=string). Poll sparingly; Work or await
|
|
28
28
|
- Steer(id=string, message=string). Inject additional instruction into active async subagent
|
|
29
|
-
- Cancel(id=string). Cancel async task ONLY if stalled for 2m+ or incorrect`:""}`,
|
|
29
|
+
- Cancel(id=string). Cancel async task ONLY if stalled for 2m+ or incorrect`:""}`,S=`**Creative Actions (path = relative; first argument, path separator: '/')**
|
|
30
30
|
- WritePDF(path=string, content=string, orientation="landscape/portrait"). Proactive A4 page breaks must in css. HTML/CSS for premium layout, stable margins & headers/footers, no watermarks
|
|
31
|
-
- WriteDoc(path=string, content=string). A4 Word document, no watermarks, stable margins & headers/footers`,
|
|
31
|
+
- WriteDoc(path=string, content=string). A4 Word document, no watermarks, stable margins & headers/footers`,m=`**Computer Use (Desktop Automation)**
|
|
32
32
|
- Click(gridId=int, type="single/double", button="left/middle/right", intendedClickText?=string, ocrCorrection=bool). Click target grid number, intendedClickText: literal text on screen (OCR scannable, upto 3 words). Double click desktop icons, clicking text? set ocrCorrection=true
|
|
33
33
|
- Scroll(direction="up/down", gridId=int). Scrolls viewport, gridId to hover over window
|
|
34
34
|
- KeyboardTyping(text=string, autoPressEnter?=bool). Type text string into currently active input. JSON escape literal escape sequences
|
|
@@ -38,7 +38,7 @@ Invocations:
|
|
|
38
38
|
In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
|
|
39
39
|
Rules:
|
|
40
40
|
- Max 5 actions/turn
|
|
41
|
-
${e==="Flux"||e.toLowerCase()==="fluxcu"?`${
|
|
41
|
+
${e==="Flux"||e.toLowerCase()==="fluxcu"?`${C}`:""}
|
|
42
42
|
**User Communication**
|
|
43
43
|
- AskUser(question=string, optionA?="title::description", ...MAX4). Any Ambiguity
|
|
44
44
|
|
|
@@ -46,5 +46,5 @@ ${e==="Flux"||e.toLowerCase()==="fluxcu"?`${p}`:""}
|
|
|
46
46
|
- WebSearch(query=string, aiMode?=bool:false, limit?=int[3..10]). Proactive use for unknown/latest info
|
|
47
47
|
- WebScrape(url=string). Proactive use for specific webpage/docs
|
|
48
48
|
|
|
49
|
-
${e==="ICU"?`${
|
|
50
|
-
${
|
|
49
|
+
${e==="ICU"?`${m}`:e==="FluxCU"?`${h}
|
|
50
|
+
${m}`:e==="Flux"?`${h}`:`${S}`}`.trim()};export{I as a,b,k as c,d,L as e,W as f};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import{c as U}from"./chunk-26BQ45XP.js";import G from"os";import{structuredPatch as V}from"diff";var R=e=>typeof e!="string"?e:e.length>12?(e+"").replace("",""):e,D=(e,o)=>{if(!e)return"";let d=/\x1B\[[0-?]*[ -/]*[@-~]/g,p=e.split(`
|
|
2
|
+
`),c=[];if(o<=5)return e;let i=t=>t<32||t>=127&&t<160||t>=768&&t<=879||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071?0:t>=4352&&t<=4447||t>=9001&&t<=9002||t>=11904&&t<=12350||t>=12352&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65135||t>=65280&&t<=65376||t>=65504&&t<=65510||t>=127744&&t<=128591||t>=128640&&t<=128767||t>=131072&&t<=262141?2:1,m=t=>{let r=t.replace(d,""),s=0;for(let l=0;l<r.length;l++){let h=r.codePointAt(l);h>65535&&l++,s+=i(h)}return s},I=(t,r)=>{let s=0,l=t.length,h=!1;for(let g=0;g<t.length;g++){if(t[g]==="\x1B"&&t[g+1]==="["&&(h=!0),h){(t[g]==="m"||t[g]>="@"&&t[g]<="~"&&t[g]!=="[")&&(h=!1);continue}let $=t.codePointAt(g);$>65535&&g++;let S=i($);if(s+S>r){l=$>65535?g-1:g;break}if(s+=S,s>=r){l=g+1;break}}return{head:t.substring(0,l),tail:t.substring(l)}};return p.forEach(t=>{if(m(t)<=o){c.push(t);return}let s=t.split(/(\s+)/),l="",h=0,g=t.match(/^(\s*)/),$=g?g[1]:"";s.forEach(S=>{if(S.length===0)return;let a=S;for(;a.length>0;){let F=m(a);if(h+F<=o){l+=a,h+=F;break}l.trim().length>0&&(c.push(l.trimEnd()),l=$.substring(0,Math.min($.length,8)),h=m(l));let n=Math.max(1,o-h);if(m(a)>n){let{head:f,tail:u}=I(a,n);c.push((l+f).trimEnd()),l=$.substring(0,Math.min($.length,8)),h=m(l),a=u}else l+=a,h+=m(a),a=""}}),(l.trimEnd().length>0||l===$)&&c.push(l.trimEnd())}),R(c.join(`
|
|
3
|
+
`))},oe=e=>{if(!e)return 0;let o=0,d=e.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g);d&&(o+=d.length*.55);let p=e.replace(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g," "),c=p.match(/[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g);c&&(o+=c.length);let i=p.split(/[\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+/g).filter(Boolean);return o+=i.length,Math.max(.1,o)},le=e=>e?e.match(/[\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]|\s+|[<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}-]+|[^\s<>/\._@#$%^&*+=`~|\\:;!?'"()\[\]{}\-\u4e00-\u9fa5\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]+/g)||[e]:[],ce=e=>{if(!e&&e!==0)return"0.0k";let o=typeof e=="string"?parseFloat(e):e;return o>=1e6?`${(o/1e6).toFixed(1)}m`:o>=1e3?`${(o/1e3).toFixed(1)}k`:o.toString()},ae=(e,o=40)=>{let d=U.replaceAll("\\\\","\\");if(e=e.replace(G.homedir(),"~").replace(d,"FluxFlow").replaceAll("\\","/"),!e||e.length<=o)return R(e);let p=Math.floor((o-3)/2);return R(e.substring(0,p)+"..."+e.substring(e.length-p).replaceAll("\\","/"))},fe=e=>{let o=[],d=new Set,p=e.allowMultiple===!0||String(e.allowMultiple).toLowerCase()==="true";Object.keys(e).forEach(t=>{let r=t.match(/^(searchContent|search_content|replaceContent|replace_content|newContent|new_content|content_to_replace|content_to_add|searchBlock|search_block|newBlock|new_block)_?(\d+)?$/i);if(r){let s=r[2]?parseInt(r[2],10):1;d.add(s)}});let c=Array.from(d).sort((t,r)=>t-r),i=["searchContent","search_content","replaceContent","replace_content","content_to_replace","searchBlock","search_block"],m=["newContent","new_content","content_to_add","newBlock","new_block"],I=(t,r,s)=>{let l,h;for(let g of r){let $=t===1?[`${g}1`,g,`${g}_1`]:[`${g}${t}`,`${g}_${t}`];for(let S of $)if(e[S]!==void 0){l=e[S];break}if(l!==void 0)break}for(let g of s){let $=t===1?[`${g}1`,g,`${g}_1`]:[`${g}${t}`,`${g}_${t}`];for(let S of $)if(e[S]!==void 0){h=e[S];break}if(h!==void 0)break}return{r:l,n:h}};for(let t of c){let{r,n:s}=I(t,i,m);if(r!==void 0&&s!==void 0)o.push({replace:r,new:s});else if(r!==void 0||s!==void 0)return{error:`Mismatched replacement pair for index ${t}. Both replacement and new content must be provided.`,allowMultiple:p}}return{patchPairs:o,allowMultiple:p}},Z=e=>{if(!e)return null;let o="",d=0,p=e.length;for(;d<p;){let c=e[d];if(c==="\\"){for(;d<p&&e[d]==="\\";)d++;o+="\\\\*"}else if(c===`
|
|
4
|
+
`)o+="(?:\\r?\\n|\\\\*n|\\\\*r|\\s*)",d++;else if(c==="\r")o+="(?:\\r|\\\\*r)?",d++;else if(c===" ")o+="(?:\\t|\\\\*t|\\s*)",d++;else if(c==='"'||c==="'"||c==="`")o.endsWith("\\\\*")||(o+="\\\\*"),o+=c,d++;else if(/[.*+?^${}()|[\]]/.test(c))o+="\\"+c,d++;else if(/\s/.test(c)){for(;d<p&&/\s/.test(e[d])&&e[d]!==`
|
|
5
|
+
`&&e[d]!=="\r"&&e[d]!==" ";)d++;o+="\\s*"}else o+=c,d++}if(!o)return null;try{return new RegExp(o,"g")}catch{return null}},ue=(e,o,d={})=>{let p=typeof d=="boolean"?d:!!(d&&d.allowMultiple),c=e.replace(/\r\n/g,`
|
|
6
|
+
`).replace(/\r/g,`
|
|
7
|
+
`),i=n=>n.replace(/^```[\w]*\n?/,"").replace(/```\s*$/,"").replace(/\r\n/g,`
|
|
8
|
+
`).replace(/\r/g,`
|
|
9
|
+
`),m=n=>n.match(/^\s*/)[0],I=n=>{let f=n.split(`
|
|
10
|
+
`).filter(E=>E.trim()!=="");if(f.length===0)return"";let u=m(f[0]);for(let E of f){let w=m(E);w.length<u.length&&(u=w)}return u},t=(n,f,u="")=>{if(!n||f===void 0)return n;let w=/^\t/m.test(f)?" ":" ",C=b=>b.split(`
|
|
11
|
+
`).find(y=>y.trim()!=="")??"",L=C(f).match(/^\s*/)[0].length,x=C(n).match(/^\s*/)[0].length,k=L-x,A=(u.match(/^\s*/)||[""])[0].length;return n.split(`
|
|
12
|
+
`).map((b,y)=>{if(b.trim()===""&&y!==0)return"";let _=b.match(/^\s*/)[0].length,T=Math.max(0,_+k);return y===0&&(T=Math.max(0,T-A)),w.repeat(T)+b.trimStart()}).join(`
|
|
13
|
+
`)},r=[];for(let n=0;n<o.length;n++){let f=o[n],u=(f.replace||"").trim(),E=i(f.new||"");if(u.startsWith("^LINE:")&&u.endsWith("$")){let A=u.slice(6,-1).trim().split(".."),M=parseInt(A[0]),b=A[1]!==void 0?parseInt(A[1]):M;if(!isNaN(M)&&!isNaN(b)){let y=c.split(`
|
|
14
|
+
`);if(M<1||M>y.length||b<M||b>y.length){r.push({index:n,success:!1,error:`Block ${n+1}: Line range ^LINE:${M}..${b}$ out of bounds (file has ${y.length} lines).`});continue}let T=y.slice(M-1,b).join(`
|
|
15
|
+
`),O=0;for(let P=0;P<M-1;P++)O+=y[P].length+1;r.push({index:n,success:!0,startPos:O,firstMatchContent:T,content_to_add:E});continue}}let w=i(f.replace||"");if(w===""&&E===""){r.push({index:n,success:!1,error:`Block ${n+1}: Empty replace and add content.`});continue}let C=w.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),L=null;if(w!==""&&c.includes(w))L=new RegExp(C,"g");else{let k=w.split(`
|
|
16
|
+
`).map(A=>A.trim()).filter(A=>A.length>0).map(A=>A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s*"));if(k.length>0){let A=k.join("\\s*");try{L=new RegExp(A,"g")}catch{L=new RegExp(C,"g")}}else L=new RegExp(C,"g")}let x=[...c.matchAll(L)];if(x.length===0&&w!==""){let k=Z(w);k&&(x=[...c.matchAll(k)])}if(x.length===0){r.push({index:n,success:!1,error:`Block ${n+1}: Could not find match.`});continue}if(x.length>1&&!p){r.push({index:n,success:!1,error:`Block ${n+1}: Found ${x.length} matches (must be unique or use allowMultiple: true if sure).`});continue}for(let k of x)r.push({index:n,success:!0,startPos:k.index,firstMatchContent:k[0],content_to_add:E})}let s=r.filter(n=>n.success).sort((n,f)=>n.startPos-f.startPos);for(let n=0;n<s.length-1;n++){let f=s[n],u=s[n+1];f.startPos+f.firstMatchContent.length>u.startPos&&(f.success=!1,f.error=`Block ${f.index+1}: Overlaps with another block.`,u.success=!1,u.error=`Block ${u.index+1}: Overlaps with another block.`)}let l=new Map,h=c,g=0,$=0,S=r.filter(n=>n.success).sort((n,f)=>n.startPos-f.startPos);for(let n of S){let f=n.startPos,u=c.substring(0,f).split(`
|
|
17
|
+
`).length,E=f+g,w=u+$,C=h.lastIndexOf(`
|
|
18
|
+
`,E)+1,L=h.substring(C,E),x=t(n.content_to_add,n.firstMatchContent,L),k=h.split(`
|
|
19
|
+
`),A=[];for(let _=Math.max(0,w-4);_<w-1;_++)A.push({num:_+1,text:k[_]});let M=n.firstMatchContent.split(`
|
|
20
|
+
`),b=[],y=w+M.length-1;for(let _=y;_<Math.min(k.length,y+3);_++)b.push({num:_+1,text:k[_]});l.set(n,{success:!0,index:n.index,oldContent:n.firstMatchContent,newContent:x,originalStartLine:u,finalStartLine:w,contextBefore:A,contextAfter:b}),h=h.substring(0,E)+x+h.substring(E+n.firstMatchContent.length),g+=x.length-n.firstMatchContent.length,$+=x.split(`
|
|
21
|
+
`).length-n.firstMatchContent.split(`
|
|
22
|
+
`).length}let a=[];for(let n=0;n<o.length;n++){let f=S.filter(u=>u.index===n);if(f.length>0)for(let u of f)l.has(u)&&a.push(l.get(u));else{let u=r.find(E=>E.index===n);a.push({success:!1,error:u?u.error:`Block ${n+1}: Unknown error.`})}}let F=a.filter(n=>!n.success&&n.error&&n.error.includes("Could not find match"));if(F.length===1)F[0].error+=" (Use Line Anchor or Run tool safely if search string fails)";else if(F.length>1){let n=F[F.length-1];n.error+=`
|
|
23
|
+
(Tip: Use Line Anchor or Run tool safely if search string fails)`}return{content:h,results:a}},he=(e,o,d,p=8,c=!1)=>{if(e===o)return"";let i=(e||"").split(/\r?\n/),m=(o||"").split(/\r?\n/),I=Math.max(i.length,m.length,1),t=Math.max(4,String(I).length),r=g=>String(g).padStart(t," "),s=`[DIFF_START]
|
|
24
|
+
`,l="\u2550".repeat(88),h=V("","",e||"",o||"","","",{context:3});if(!h||!h.hunks||h.hunks.length===0)return"";if(h.hunks.forEach((g,$)=>{$>0&&(s+=`[UI_CONTEXT] ${l}
|
|
25
|
+
`);let S=g.oldStart,a=g.newStart;for(let F of g.lines){let n=F[0],f=F.slice(1);n===" "?(s+=`[UI_CONTEXT] ${r(a)} |${f}
|
|
26
|
+
`,S++,a++):n==="-"?(s+=`-${r(S)} |${f}
|
|
27
|
+
`,S++):n==="+"&&(s+=`+${r(a)} |${f}
|
|
28
|
+
`,a++)}}),c){let g=`[DIFF_START]
|
|
29
|
+
`,$=s.substring(g.length),S=`[UI_CONTEXT] ${l}
|
|
30
|
+
`,F=$.split(S).map(n=>n.split(`
|
|
31
|
+
`).filter(u=>u.trim()!=="").length>120?`[[VERIFIED]]
|
|
32
|
+
${n}
|
|
33
|
+
[[/VERIFIED]]`:n);s=g+F.join(S)}return s+="[DIFF_END]",R(s)},K=e=>{if(!e)return null;let o=e.replace("[UI_CONTEXT]","").replace(/\r/g,""),d=o.startsWith("-"),p=o.startsWith("+"),c=d||p?o.substring(1):o,i=c.indexOf("|"),m=i!==-1?R(c.substring(0,i).trim()):"",I=R(i!==-1?c.substring(i+1):c);return{isR:d,isA:p,num:m,content:I}},Y=(e,o)=>{if(!e&&!o)return 1;if(!e||!o)return 0;let d=e.length,p=o.length,c=e,i=o;d<p&&(c=o,i=e);let m=c.length,I=i.length,t=new Int32Array(I+1),r=new Int32Array(I+1);for(let h=0;h<=I;h++)t[h]=h;for(let h=1;h<=m;h++){r[0]=h;let g=c[h-1];for(let $=1;$<=I;$++)g===i[$-1]?r[$]=t[$-1]:r[$]=Math.min(t[$],r[$-1],t[$-1])+1;t.set(r)}let s=t[I],l=Math.max(d,p);return l===0?1:1-s/l},H=e=>{let o=[],d=[];e.forEach((s,l)=>{s.parsed.isR?o.push({index:l,content:s.parsed.content}):s.parsed.isA&&d.push({index:l,content:s.parsed.content})});let p=o.length,c=d.length;if(p===0||c===0)return;let i=Array.from({length:p+1},()=>Array(c+1).fill(0)),m=Array.from({length:p+1},()=>Array(c+1).fill(""));for(let s=1;s<=p;s++)m[s][0]="up";for(let s=1;s<=c;s++)m[0][s]="left";let I=Array.from({length:p},()=>Array(c).fill(0));for(let s=0;s<p;s++)for(let l=0;l<c;l++)I[s][l]=Y(o[s].content.trim(),d[l].content.trim());for(let s=1;s<=p;s++)for(let l=1;l<=c;l++){let h=I[s-1][l-1],g=h>=.2?h:-10,$=i[s-1][l-1]+g,S=i[s-1][l],a=i[s][l-1];$>=S&&$>=a?(i[s][l]=$,m[s][l]="diag"):S>=a?(i[s][l]=S,m[s][l]="up"):(i[s][l]=a,m[s][l]="left")}let t=p,r=c;for(;t>0||r>0;)if(m[t][r]==="diag"){if(I[t-1][r-1]>=.2){let l=o[t-1].index,h=d[r-1].index;e[l].pairContent=e[h].parsed.content,e[h].pairContent=e[l].parsed.content}t--,r--}else m[t][r]==="up"?t--:r--},B=new Map,W=new Map,X=200,j=5,z=(e,o)=>{o.set(e.key,e),e.type==="chunk"&&e.blocks&&e.blocks.forEach(d=>z(d,o))},de=(e,o)=>{if(!e)return{completed:[],active:[]};let d=`${e.id}-${e.text?.length||0}-${o}-${e.isStreaming}-${e.workedDuration||0}`;if(!e.isStreaming&&B.has(d))return B.get(d);let p=R(ne(e.text||"",e.role)),c=`${e.id}-${o}`,i=new Map;if(e.isStreaming){let a=W.get(c);a&&p.startsWith(a.text)&&(i=a.blocksMap)}let m=(a,F,n,f={})=>{let u=i.get(a);if(u&&u.text===n&&u.type===F&&!!u.isActiveBlock==!!f.isActiveBlock&&!!u.isStreaming==!!f.isStreaming&&u.pairContent===f.pairContent)return u;let E=R(n),w={...f};return typeof w.pairContent=="string"&&(w.pairContent=R(w.pairContent)),Array.isArray(w.wrappedLines)&&(w.wrappedLines=w.wrappedLines.map(R)),{key:a,isStreamingMsg:!!e.isStreaming,workedDuration:e.workedDuration,type:F,text:E,msg:F==="full-message"?e:void 0,...w}};if(p.includes("- Content Preview:")){let a="",F=p.match(/File\s+\[(.*?)\]/i);F&&(a=F[1].split(".").pop().toLowerCase());let w=((p.split("- Content Preview:")[1]||"").split("[SYSTEM] Check the content preview for verification [/SYSTEM]")[0]?.trim()||"").split(`
|
|
34
|
+
`).map(b=>b.replace(/\r$/,"")),C=String(w.length).length,L=[],x=null,k=[],A=()=>{if(!k.length)return;let b=k;k=[],L.push(b.length===1?b[0]:{key:`${b[0].key}-chunk`,type:"chunk",blocks:b})},M=o-(C+6);return w.forEach((b,y)=>{let _=y===w.length-1,T=D(b,M).split(`
|
|
35
|
+
`),O=m(`${e.id||Date.now()}-write-line-${y}`,"write-line",b,{gutterWidth:C,lineNum:y+1,isFirstLine:y===0,isLastLine:_,extension:a,wrappedLines:T});_&&e.isStreaming?(A(),x=O):(k.push(O),k.length>=j&&A())}),A(),{completed:L,active:x?[x]:[]}}if(p.includes("[DIFF_START]")){let a=p.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),n=(a?a[1].trim():"").split(`
|
|
36
|
+
`).map(x=>x.replace(/\r$/,"")),f=n.map(x=>({line:x,parsed:K(x),pairContent:null})),u=[];for(let x=0;x<f.length;x++){let k=f[x];k.parsed&&(k.parsed.isR||k.parsed.isA)?u.push(k):u.length>0&&(H(u),u=[])}u.length>0&&H(u);let E=[],w=null,C=[],L=()=>{if(!C.length)return;let x=C;C=[],E.push(x.length===1?x[0]:{key:`${x[0].key}-chunk`,type:"chunk",blocks:x})};return n.forEach((x,k)=>{let A=k===n.length-1,M=f[k].parsed,b=null;M&&(b=D(M.content,o-17).split(`
|
|
37
|
+
`));let y=m(`${e.id||Date.now()}-diff-${k}`,"diff-line",x,{isFirstLine:k===0,isLastLine:A,pairContent:f[k].pairContent,wrappedLines:b});A&&e.isStreaming?(L(),w=y):(C.push(y),C.length>=j&&L())}),L(),{completed:E,active:w?[w]:[]}}if(e.role==="system"||e.isLogo||e.isHelpRecord||e.isTerminalRecord||e.isHomeWarning||e.isImageStats||e.isAskRecord||e.isAboutRecord||e.isUpdateNotification||e.role==="user"){if(!p&&!e.isLogo&&!e.isHelpRecord&&!e.isTerminalRecord&&!e.isHomeWarning&&!e.isImageStats&&!e.isAskRecord&&!e.isAboutRecord&&!e.isUpdateNotification){let a={completed:[],active:[]};return B.set(d,a),a}return{completed:[m(`${e.id||Date.now()}-full`,"full-message",p)],active:[]}}if(!p&&!e.isStreaming){let a={completed:[],active:[]};return B.set(d,a),a}let I=[],t=null,r=[],s=null,l=()=>{if(!r.length)return;let a=r;r=[],s=null,I.push(a.length===1?a[0]:{key:`${e.id||"x"}-chunk-${a[0].key}`,type:"chunk",blocks:a})},h=(a,F=!1)=>{if(s!==null&&s!==a.type&&l(),r.push(a),s=a.type,r.length>=j){if(e.isStreaming&&F)return;l()}},g=Math.max(20,(o||80)-6),$=Math.max(20,(o||80)-8);if(e.role==="think"){I.push(m(`${e.id}-header`,"think-header","",{duration:e.duration}));let a=p.split(`
|
|
38
|
+
`),F=[];a.forEach(n=>{D(n,$).split(`
|
|
39
|
+
`).forEach(u=>F.push(u))}),F.forEach((n,f)=>{let u=f===F.length-1;h(m(`${e.id}-${f}`,"think-line",n,{}),u)}),e.isStreaming||(l(),I.push({key:`${e.id}-footer-padding`,type:"think-footer-padding",text:""}))}else{let a=p.split(`
|
|
40
|
+
`),F=!1,n=[],f=!1,u="",E=0,w=0,C=[];a.forEach(L=>{let x=L.trim();x.startsWith("```")?(f=!f,C.push(L)):f||x.startsWith("|")?C.push(L):D(L,g).split(`
|
|
41
|
+
`).forEach(A=>C.push(A))}),f=!1,C.forEach((L,x)=>{let k=x===C.length-1,A=L.trim().startsWith("|"),M=L.trim().startsWith("```");if(f)M?(f=!1,h(m(`${e.id}-code-close-${w}`,"code-fence-close","",{}),k)):(E++,h(m(`${e.id}-code-line-${x}`,"code-line",L,{lineNum:E,lang:u}),k));else if(M)f=!0,w=x,E=0,u=L.trim().replace(/^```/,"").trim(),h(m(`${e.id}-code-open-${x}`,"code-fence-open",u,{}),k);else if(A){if(F||(F=!0,n=[]),n.push(L),n.length===2){let b=n[0],y=b.split("|");y[0]!==void 0&&y[0].trim()===""&&y.shift(),y.length>0&&y[y.length-1].trim()===""&&y.pop();let _=y.map(T=>T.trim());h(m(`${e.id}-table-hdr-${x}`,"table-header",b,{colHeaders:_,colCount:_.length}),k)}else if(n.length>2){let b=L.split("|");b[0]!==void 0&&b[0].trim()===""&&b.shift(),b.length>0&&b[b.length-1].trim()===""&&b.pop();let y=b.map(P=>P.trim()),_=n[0].split("|");_[0]!==void 0&&_[0].trim()===""&&_.shift(),_.length>0&&_[_.length-1].trim()===""&&_.pop();let T=_.map(P=>P.trim()),O=Math.max(1,T.length);h(m(`${e.id}-table-row-${x}`,"table-row",L,{cells:y,colHeaders:T,colCount:O,rowIndex:n.length-3}),k)}k&&!e.isStreaming&&(l(),h(m(`${e.id}-table-end-${x}`,"table-close","",{}),!0))}else F&&(h(m(`${e.id}-table-end-${x}`,"table-close","",{}),k),F=!1,n=[]),h(m(`${e.id}-${x}`,"agent-line",L,{}),k)}),!e.isStreaming&&e.workedDuration&&(l(),I.push(m(`${e.id}-worked-duration`,"worked-duration","")))}e.isStreaming&&r.length>0?t=r.length===1?r[0]:{key:`${e.id||"x"}-chunk-active-${r[0].key}`,type:"chunk",blocks:r}:l();let S={completed:I,active:t?[t]:[]};if(e.isStreaming){let a=new Map;if(I.forEach(F=>z(F,a)),t&&z(t,a),W.set(c,{text:p,blocksMap:a}),W.size>X){let F=W.keys().next().value;W.delete(F)}}else{if(B.set(d,S),B.size>X){let a=B.keys().next().value;B.delete(a)}W.delete(c)}return S},q={},J=/(\r?\n){2}(?=\[?(?:tool:(?:functions\.)?|tool\.functions|action:(?:functions\.)?|action:|action\.functions|\s*turn\s*:))/gi,N=(e,o)=>{let d=!1,p=!1,c=0;for(;c<o;){if(e.startsWith("```",c)){d=!d,c+=3;continue}if(d){c++;continue}if(e[c]===`
|
|
42
|
+
`){p=!1,c++;continue}e[c]==="`"&&(c===0||e[c-1]!=="\\")&&(p=!p),c++}if(d)return!0;if(p){let i=e.indexOf(`
|
|
43
|
+
`,o),m=i===-1?e.length:i;if(e.substring(o,m).includes("`"))return!0}return!1},Q=/\[SYSTEM\][\s\S]*?\[\/SYSTEM\]|\[ANSWER\][\s\S]*?(?:\[\/ANSWER\]|$)|\[(?:TOOL|ACTION) RESULTS?\]:?\s*|\[\s*turn\s*:\s*(continue|finish)\s*\]|\[\[END\]\]|\[\s*turn\s*:?.*?$|\n\s*turn\s*:?.*?$|\[\s*(?:turn|ANSWER|TOOL|ACTION).*?$|\n\nResponded on .*|\n\n\[Prompted on: .*\]|@\[TerminalName:.*?, ProcessId:.*?\]/gm,ee=/(\$?\\?\/?\\rightarrow\$?|\$\\rightarrow\$)|(\$?\\?\/?\\leftarrow\$?|\$\\leftarrow\$)|(\$?\\?\/?\\uparrow\$?|\$\\uparrow\$)|(\$?\\?\/?\\downarrow\$?|\$\\downarrow\$)|(\$?\\?\/?\\leftrightarrow\$?|\$\\leftrightarrow\$)/gi,te=/\b(write_file|update_file|read_folder|view_file|exec_command|web_search|web_scrape|search_keyword|write_pdf|write_docx|generate_image)\b/gi,v=!1,ne=(e,o="agent")=>{if(!e)return e;let d=o===!0||o==="think",p=o===!1||o==="agent",c=e.replace(/<\|channel>thought/gi,"<think_fluxflow>").replace(/<channel\|>/gi,"</think_fluxflow>");if(d)return c.replace(/^<think_fluxflow>/gi,"").replace(/<\/think_fluxflow>$/gi,"").replace(/^\r?\n+/,"").replace(/\r?\n+$/,"");let i=c;if(c.trimStart().startsWith("ERROR: [INTERNAL CRITICAL] "))return"";p&&(i=i.replace(/<\/?think_fluxflow>/gi,(t,r,s)=>N(s,r)?t:""),i=i.replace(J,(t,r,s,l)=>!v&&N(l,s)?t:""),i&&(i.includes("[tool:")||i.includes("[action:"))&&(i=i.replace(/<(\w+)(?:[^>]*)>\s*([\s\S]*?\[(?:tool|action):[^\]]*\][\s\S]*?)\s*<\/\1>/gi,(t,r,s)=>s&&(s.includes("[tool:")||s.includes("[action:"))?s.trim():t),v&&(i=i.replace(/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi,(t,r)=>r.includes("[tool:")||r.includes("[action:")?r.trim():t))));let m="tool:",I="action:";if(p&&(i.toLowerCase().includes(m)||i.toLowerCase().includes(I)))for(;;){let t=i.toLowerCase(),r=t.indexOf(m),s=t.indexOf(I),l=m,h=r;if((r===-1||s!==-1&&s<r)&&(l=I,h=s),h===-1)break;if(!v&&N(i,h)){let u=-1,E=0;for(;;){let w=t.indexOf(m,E),C=t.indexOf(I,E),L=-1,x=m;if(w===-1&&C===-1)break;if(w===-1||C!==-1&&C<w?(L=C,x=I):L=w,!N(i,L)){u=L,l=x;break}E=L+x.length}if(u===-1)break;h=u}let g=h,$=!1,S=h-1;for(;S>=0&&/\s/.test(i[S]);)S--;S>=0&&i[S]==="["&&(g=S,$=!0);let a=0,F=!1,n=null,f=h;for(;f<i.length;){let u=i[f];if(!n&&(u==="'"||u==='"'||u==="`")?n=u:n&&u===n&&i[f-1]!=="\\"&&(n=null),n||(u==="("?(a++,F=!0):u===")"&&a--),F&&a===0&&!n){let E=f;if($){let w=f+1;for(;w<i.length&&/\s/.test(i[w]);)w++;w<i.length&&i[w]==="]"&&(E=w)}i=i.substring(0,g)+i.substring(E+1);break}if(f++,f===i.length){i=i.substring(0,g);break}}}return p&&(i=i.replace(/\[\s*(?:tool|action):[a-zA-Z0-9_.]*\s*\([\s\S]*?\)\s*\]/gi,(t,r,s)=>!v&&N(s,r)?t:""),i=i.replace(/\[\s*(?:tool|action):[a-zA-Z0-9_.]*[\s\S]*$/gi,(t,r,s)=>!v&&N(s,r)?t:""),i=i.replace(/^(?:\s*=\s*["'][^"'\n]*["']|\s*[a-zA-Z0-9_]+\s*=\s*(?:["'][^"'\n]*["']|\d+|true|false))(?:\s*,\s*[a-zA-Z0-9_]+\s*=\s*(?:["'][^"'\n]*["']|\d+|true|false))*\s*\)?\]\s*/gm,(t,r,s)=>!v&&N(s,r)?t:""),i=i.replace(/(?:\r?\n|^)\s*=\s*["'][^"'\n]*["'][\s\S]*?\s*\)?\]\s*/g,(t,r,s)=>!v&&N(s,r)?t:`
|
|
44
|
+
`)),i=i.replace(Q,""),i=i.replace(ee,t=>{let r=t.toLowerCase();return r.includes("leftrightarrow")?"\u2194":r.includes("rightarrow")?"\u2192":r.includes("leftarrow")?"\u2190":r.includes("uparrow")?"\u2191":r.includes("downarrow")?"\u2193":t}),i=i.replace(te,t=>q[t.toLowerCase()]||t),i.trim()},pe=()=>{B.clear(),W.clear()};export{R as a,D as b,oe as c,le as d,ce as e,ae as f,fe as g,ue as h,he as i,K as j,H as k,de as l,ne as m,pe as n};
|