fluxflow-cli 4.10.2 → 4.12.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 (64) hide show
  1. package/README.md +2 -2
  2. package/dist/chunks/addMemScore-EIIMCED3.js +1 -0
  3. package/dist/chunks/ai-OCOM32HV.js +1 -0
  4. package/dist/chunks/answerSubagent-JUVFNLE5.js +1 -0
  5. package/dist/chunks/app-LKK2QTJ7.js +238 -0
  6. package/dist/chunks/ask_user-K2DLZF6H.js +1 -0
  7. package/dist/chunks/awaitSubagent-JTUSJDKD.js +7 -0
  8. package/dist/chunks/cancel-7IMADALP.js +1 -0
  9. package/dist/chunks/chat-5CITJOXW.js +1 -0
  10. package/dist/chunks/chunk-2TASXARO.js +1 -0
  11. package/dist/chunks/chunk-5GEXRVU6.js +15 -0
  12. package/dist/chunks/chunk-5K4X2VUW.js +33 -0
  13. package/dist/chunks/chunk-6GTIZENY.js +48 -0
  14. package/dist/chunks/chunk-A73NNVCZ.js +1 -0
  15. package/dist/chunks/chunk-DHQHSTTS.js +1 -0
  16. package/dist/chunks/chunk-FJGY5C4M.js +52 -0
  17. package/dist/chunks/chunk-LRJGBXD6.js +880 -0
  18. package/dist/chunks/{chunk-W43IBIRT.js → chunk-MZGMZ4T6.js} +1 -1
  19. package/dist/chunks/chunk-R67K3FEP.js +1 -0
  20. package/dist/chunks/{chunk-TA42E3DA.js → chunk-RNEHIJXX.js} +1 -1
  21. package/dist/chunks/chunk-TGINXVDR.js +1 -0
  22. package/dist/chunks/chunk-TJII6UKN.js +6 -0
  23. package/dist/chunks/chunk-VNPYQFKQ.js +3 -0
  24. package/dist/chunks/{chunk-Q7SNDU5P.js → chunk-WZW77OYB.js} +1 -1
  25. package/dist/chunks/chunk-Y5JU726N.js +4 -0
  26. package/dist/chunks/click-V2WBK6PX.js +2 -0
  27. package/dist/chunks/computer_action-QGLK3SY6.js +1 -0
  28. package/dist/chunks/drag-6P367RA2.js +1 -0
  29. package/dist/chunks/emergency_rollback-A67M4DU6.js +18 -0
  30. package/dist/chunks/exec_command-43ZNHLVJ.js +1 -0
  31. package/dist/chunks/file_map-YYKJC7LP.js +9 -0
  32. package/dist/chunks/generate_image-6K34FOJJ.js +1 -0
  33. package/dist/chunks/getProgress-KLWGCCPA.js +26 -0
  34. package/dist/chunks/invoke-D2QN5M3S.js +6 -0
  35. package/dist/chunks/invokeSync-U5GA5PGM.js +3 -0
  36. package/dist/chunks/key_press-BRS2DIB5.js +1 -0
  37. package/dist/chunks/keyboard_typing-3YF72D7X.js +1 -0
  38. package/dist/chunks/memory-22U3WGHY.js +1 -0
  39. package/dist/chunks/read_folder-OOKZITME.js +15 -0
  40. package/dist/chunks/recapture_screen-5FKLOHJL.js +1 -0
  41. package/dist/chunks/saveSummary-2LC63SYI.js +1 -0
  42. package/dist/chunks/{screen_grid-Y5PT4VFL.js → screen_grid-IUKQWDZG.js} +1 -1
  43. package/dist/chunks/scroll-VJJ2SHXR.js +1 -0
  44. package/dist/chunks/search_keyword-Y2B3YELW.js +8 -0
  45. package/dist/chunks/{settings-2QSWNLAX.js → settings-ZHS26QZ5.js} +1 -1
  46. package/dist/chunks/steerSubagent-L2JVT4QN.js +1 -0
  47. package/dist/chunks/todo-VFONYOUK.js +10 -0
  48. package/dist/chunks/update_file-KPFDUPKK.js +13 -0
  49. package/dist/chunks/usageServer-DMWM5ECL.js +1 -0
  50. package/dist/chunks/view_file-SRYT37FH.js +1 -0
  51. package/dist/chunks/web_scrape-EWLJFTMV.js +16 -0
  52. package/dist/chunks/web_search-KNT73E64.js +36 -0
  53. package/dist/chunks/write_docx-T4UJCJ3L.js +13 -0
  54. package/dist/chunks/write_file-LYTIK6LS.js +29 -0
  55. package/dist/chunks/write_pdf-NGUPNIEZ.js +31 -0
  56. package/dist/cli.js +10 -10
  57. package/dist/package.json +2 -2
  58. package/flux-flow.cjs +17 -16
  59. package/package.json +2 -2
  60. package/dist/chunks/ai-LWFS4KRY.js +0 -1
  61. package/dist/chunks/app-IMH36EZP.js +0 -225
  62. package/dist/chunks/chunk-K26OGD74.js +0 -3
  63. package/dist/chunks/chunk-YPTXLUPC.js +0 -1246
  64. package/dist/chunks/usageServer-HYLLNJRZ.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-Y5JU726N.js";var u=async(c,e)=>{let t=n(c),{question:i}=t;if(!i)return'ERROR: Missing "question" argument for ask.';if(!e.onAskUser)return"ERROR: onAskUser callback not provided in tool context.";let o=[];Object.keys(t).forEach(r=>{if(r.startsWith("option")){let s=t[r];if(typeof s=="string"&&s.includes("::")){let[a,l]=s.split("::");o.push({id:r,label:a.trim(),description:l.trim()})}else o.push({id:r,label:String(s).trim(),description:""})}});try{return`USER CHOOSE: ${await e.onAskUser(i,o)}`}catch(r){return`ERROR: Failed to get user input: ${r instanceof Error?r.message:String(r)}`}};export{u as ask_user};
@@ -0,0 +1,7 @@
1
+ import{a as o}from"./chunk-56EJGQU3.js";import{a as i}from"./chunk-Y5JU726N.js";var d=async(u,c={})=>{let a=i(u),e=a.id,r=parseInt(a.timeout||a.time||"120",10);if((isNaN(r)||r<=0)&&(r=120),r>300&&(r=300),!e)return a.time?(await new Promise(n=>setTimeout(n,r*1e3)),`SUCCESS: Waited for ${r}s.`):'ERROR: Missing "id" argument for Await.';let t=o.find(n=>n.id===e);if(!t)return`ERROR: Subagent task with ID [${e}] not found.`;if(t.status==="completed")return`SUCCESS: Subagent task [${e}] completed.
2
+ Final Answer:
3
+ ${t.finalAnswer||"(No output)"}`;if(t.status==="failed")return`ERROR: Subagent task [${e}] failed.
4
+ Error: ${t.error||"Unknown error"}`;if(t.status==="cancelled")return`INFO: Subagent task [${e}] was cancelled.`;let s,l=new Promise(n=>{s=setTimeout(()=>{n({type:"timeout"})},r*1e3)});try{let n=await Promise.race([t.completionPromise.then(()=>({type:"completion"})),l]);return clearTimeout(s),n.type==="timeout"?`TIMEOUT: Subagent task [${e}] is still running (status: ${t.status.toUpperCase()}) after ${r}s. You can continue other work or call Await again.`:t.status==="completed"?`SUCCESS: Subagent task [${e}] completed.
5
+ Final Answer:
6
+ ${t.finalAnswer||"(No output)"}`:t.status==="failed"?`ERROR: Subagent task [${e}] failed.
7
+ Error: ${t.error||"Unknown error"}`:t.status==="cancelled"?`INFO: Subagent task [${e}] was cancelled.`:`INFO: Subagent task [${e}] status changed to ${t.status.toUpperCase()}.`}catch(n){return clearTimeout(s),`ERROR: Exception while awaiting subagent [${e}]: ${n.message}`}};export{d as awaitSubagent};
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-56EJGQU3.js";import{a as s}from"./chunk-Y5JU726N.js";var o=async(r,e={})=>{let t=s(r).id;if(!t)return'ERROR: Missing "id" argument for cancel.';let a=n.find(i=>i.id===t);return a?a.status==="completed"||a.status==="failed"?`INFO: Subagent task with ID [${t}] has already finished with status [${a.status.toUpperCase()}].`:a.status==="cancelled"?`INFO: Subagent task with ID [${t}] is already cancelled.`:(a.status="cancelled",e.onSubagentUpdate&&e.onSubagentUpdate(),`SUCCESS: Subagent task with ID [${t}] has been cancelled.`):`ERROR: Subagent task with ID [${t}] not found.`};export{o as cancel};
@@ -0,0 +1 @@
1
+ import{c as a}from"./chunk-TJII6UKN.js";import"./chunk-TGINXVDR.js";import"./chunk-SIINYZWE.js";import"./chunk-4TZKD2XR.js";import{a as s}from"./chunk-Y5JU726N.js";var R=async(i,o={})=>{let t=s(i).title,r=o.chatId||o.sessionId;if(!r)return"ERROR: No active chatId found in tool context.";if(!t)return"ERROR: Missing 'title' argument.";try{return await a(r,t),`SUCCESS: Chat title updated to [${t}] for session [${r}].`}catch(e){return`ERROR: Failed to update chat title: ${e instanceof Error?e.message:String(e)}`}};export{R as chat};
@@ -0,0 +1 @@
1
+ import{c as F,d as y}from"./chunk-SIINYZWE.js";import{c as g,o as h}from"./chunk-4TZKD2XR.js";import o from"fs-extra";import a from"path";var P=["node_modules","dist","bin","logs",".git",".fluxflow","secret",".gemini",".agents","tmp","temp","build","out","snapshots"];async function k(t,s=t){let e={},i=await o.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let c of i){if(P.includes(c.name))continue;let l=a.join(t,c.name),d=a.relative(s,l).replace(/\\/g,"/");if(c.isDirectory()){let n=await k(l,s);Object.assign(e,n)}else{let n=await o.stat(l).catch(()=>null);n&&(e[d]={size:n.size,mtime:n.mtimeMs})}}return e}async function E(t,s){await o.ensureDir(t);for(let e of Object.keys(s)){let i=a.join(process.cwd(),e),c=a.join(t,e);await o.ensureDir(a.dirname(c)),await o.copyFile(i,c).catch(()=>{})}}async function j(t,s,e=null,i=null){if(!await o.pathExists(t))return;i||(i=t);let c=await o.readdir(t,{withFileTypes:!0}).catch(()=>[]);for(let l of c){let d=a.join(t,l.name),n=a.join(s,l.name);if(l.isDirectory())await j(d,n,e,i);else{let u=a.relative(i,d).replace(/\\/g,"/"),p=await o.pathExists(n);p&&await o.chmod(n,438).catch(()=>{}),await o.ensureDir(a.dirname(n));let f=await o.copyFile(d,n).then(()=>!0).catch(()=>!1);await o.chmod(n,438).catch(()=>{}),e&&(f?p?e.replaced++:e.restored++:e.failed.push(u))}}}var C={async takeInitialSnapshot(t){try{let s=a.join(g,"snapshots",t);await o.remove(s).catch(()=>{}),await o.ensureDir(s);let e=await k(process.cwd());await E(a.join(s,"initial"),e);let i=F(h,{});i[t]={initialManifest:e,currentManifest:e,checkpoints:[{id:"initial",timestamp:new Date().toISOString(),newFiles:[],modifiedFiles:[],deletedFiles:[],toolsUsed:[]}]},y(h,i)}catch{}},async recordTurnDelta(t,s,e=[]){try{let i=F(h,{}),c=i[t];if(!c)return;let l=c.currentManifest||c.initialManifest,d=await k(process.cwd()),n=[],u=[],p=[];for(let[r,m]of Object.entries(d)){let w=l[r];w?(w.size!==m.size||w.mtime!==m.mtime)&&u.push(r):n.push(r)}for(let r of Object.keys(l))d[r]||p.push(r);let f=[...n,...u];if(f.length>0||p.length>0){let r={};for(let w of f)r[w]=d[w];let m=a.join(g,"snapshots",t,`turn_${s}`);await E(m,r)}c.checkpoints.push({id:`turn_${s}`,timestamp:new Date().toISOString(),newFiles:n,modifiedFiles:u,deletedFiles:p,toolsUsed:e}),c.currentManifest=d,y(h,i)}catch{}},async getCheckpoints(t){try{let e=F(h,{})[t];return e?e.checkpoints||[]:[]}catch{return[]}},async rollbackToCheckpoint(t,s){try{let e=F(h,{}),i=e[t];if(!i)throw new Error("No session active for Advance Rollback.");let c=i.checkpoints||[],l=c.findIndex(f=>f.id===s);if(l===-1)throw new Error(`Checkpoint [${s}] not found.`);let d=a.join(g,"snapshots",t),n={restored:0,replaced:0,failed:[]},u=await k(process.cwd());for(let f of Object.keys(u)){let r=a.join(process.cwd(),f);await o.chmod(r,438).catch(()=>{}),await o.remove(r).catch(()=>{})}let p=a.join(d,"initial");await j(p,process.cwd(),n,p);for(let f=1;f<=l;f++){let r=c[f],m=a.join(d,r.id);if(await j(m,process.cwd(),n,m),r.deletedFiles&&r.deletedFiles.length>0)for(let w of r.deletedFiles){let D=a.join(process.cwd(),w);await o.chmod(D,438).catch(()=>{}),await o.remove(D).catch(()=>{})}}return i.checkpoints=c.slice(0,l+1),i.currentManifest=await k(process.cwd()),y(h,e),{checkpointId:s,stats:n}}catch(e){throw new Error(`Rollback failed: ${e.message}`)}},async getLatestFileChanges(t){try{let e=F(h,{})[t];if(!e||!e.checkpoints||e.checkpoints.length===0)return{newFiles:[],modifiedFiles:[],deletedFiles:[]};let i=e.checkpoints[e.checkpoints.length-1];return{newFiles:i.newFiles||[],modifiedFiles:i.modifiedFiles||[],deletedFiles:i.deletedFiles||[]}}catch{return{newFiles:[],modifiedFiles:[],deletedFiles:[]}}},async cleanup(t){try{let s=a.join(g,"snapshots",t);await o.remove(s).catch(()=>{});let e=F(h,{});e[t]&&(delete e[t],y(h,e))}catch{}}};export{C as a};
@@ -0,0 +1,15 @@
1
+ import{a as P}from"./chunk-4TZKD2XR.js";import{a as I}from"./chunk-Y5JU726N.js";import c from"fs";import d from"path";var z=s=>{if(!s)return null;let n=s.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!n)return null;let e=n[1];if((n[2]||"").trim().length===0)return null;let r="",i=e.match(/^name:\s*(.+)$/m);return i&&(r=i[1].trim().replace(/^["']|["']$/g,"")),r?{name:r}:null},A=s=>{let n=[];if(!s||!c.existsSync(s))return n;let e=(p,r=0)=>{if(!(r>5))try{let i=c.readdirSync(p,{withFileTypes:!0});for(let l of i){let a=d.join(p,l.name),o=l.name.toLowerCase();l.isFile()?o==="skill.md"&&n.push(a):l.isDirectory()&&(r===0?(o==="skills"||o===".skills"||o==="skill"||o===".skill")&&e(a,r+1):e(a,r+1))}}catch{}};return e(s,0),n},X=s=>s.replace(/^(\s*---\r?\n)([\s\S]*?)(\r?\n---)/,(n,e,p,r)=>{let i=p.split(`
2
+ `),l=[],a=!1;for(let o of i){if(/^\s*description\s*:/i.test(o)){a=!0;continue}if(a){if(/^\s+/.test(o))continue;a=!1}l.push(o)}return`${e}${l.join(`
3
+ `)}${r}`}),Y=(s,n)=>{let e=[d.join(s,"references"),d.join(s,"reference"),s],p=n.toLowerCase().endsWith(".md")?n.toLowerCase():`${n.toLowerCase()}.md`,r=n.toLowerCase();for(let i of e)if(c.existsSync(i)&&c.statSync(i).isDirectory())try{let l=c.readdirSync(i);for(let a of l){let o=a.toLowerCase();if(o===p||o===r){let R=d.join(i,a);if(c.statSync(R).isFile())return R}}}catch{}return null},Q=async(s,n={})=>{let{path:e,StartLine:p,EndLine:r,start_line:i,end_line:l,startLine:a,endLine:o}=I(s),R=parseInt(p||i||a),v=parseInt(r||l||o),O=!isNaN(R),D=!isNaN(v),x=R||1,b=v||(R?R+800:800);if(!e)return'ERROR: Missing "path" argument for ReadFile.';if(e.trim().toLowerCase().startsWith("#skill")){let f=e.trim().replace(/\\/g,"/").replace(/^#skills?\/?/i,"").split("/").filter(Boolean),S=f[0]?.toLowerCase();if(S!=="global"&&S!=="project")return`ERROR: Invalid skill scope '${S||""}'. Expected 'global' or 'project'.`;let g=f[1];if(!g)return`ERROR: Missing skill name in path [${e}].`;let h=f[2]?.toLowerCase()==="references"||f[2]?.toLowerCase()==="reference",F=h?f.slice(3).join("/"):null,$=S==="global"?P:process.cwd(),k=A($),L=null;for(let t of k)try{let m=c.readFileSync(t,"utf8"),w=z(m),y=d.basename(d.dirname(t)).toLowerCase();if(w?.name&&w.name.toLowerCase()===g.toLowerCase()||y===g.toLowerCase()||t.toLowerCase()===d.join($,"skill.md").toLowerCase()&&g.toLowerCase()==="skill"){L=t;break}}catch{}if(!L)return`No '${g}' exist in given scope.`;let j=d.dirname(L),E=L,C=!0;if(h){if(!F)return`ERROR: Missing reference file name in path [${e}].`;let t=Y(j,F);if(!t)return`No such reference exist for skill '${g}'`;E=t,C=!1}try{let t=c.readFileSync(E,"utf8");t.startsWith("\uFEFF")&&(t=t.slice(1)),t=t.replace(/\r\n/g,`
4
+ `).replace(/\r/g,`
5
+ `),C&&(t=X(t));let m=t.split(`
6
+ `),w=m.length,y=O?Math.max(0,x-1):0,T=D?Math.min(w,b):w,U=m.slice(y,T),N=e.replace(/\\/g,"/").toLowerCase(),W=`${N.includes("#skill/global/fluxflow")||N.includes("#skills/global/fluxflow")?"DOCs":"Skill"}: [${e.replace(/\\/g,"/")}]`,_=U.map(B=>B.trimEnd()).join(`
7
+ `);return`${W}
8
+
9
+ ${_}`}catch(t){let m=t instanceof Error?t.message:String(t);return`ERROR: Failed to read skill file [${e}]: ${m}`}}try{let u=d.resolve(process.cwd(),e);if(!c.existsSync(u))return`ERROR: File [${e}] does not exist.`;if(c.statSync(u).isDirectory())return`ERROR: Path [${e}] is a directory. Use list_files instead.`;let f=d.extname(e).toLowerCase();if([".mp4",".mkv",".avi",".mov",".webm",".flv",".wmv",".mpeg",".mpg"].includes(f))return`ERROR: Unable to read. Type ${f.slice(1).toUpperCase()} not supported`;let g={".pdf":"application/pdf",".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".doc":"application/msword"};if(g[f]){if(!(n.isMultiModal!==!1))return`ERROR: Multimodality is not supported for the current model. Unable to load [${e}].`;let w=c.readFileSync(u).toString("base64"),y=g[f];return{text:`[BINARY FILE]: ${e} (${y}) - Loaded as multimodal part.`,binaryPart:{inlineData:{data:w,mimeType:y}}}}let h=c.readFileSync(u,"utf8");h.startsWith("\uFEFF")&&(h=h.slice(1)),h=h.replace(/\r\n/g,`
10
+ `).replace(/\r/g,`
11
+ `);let F=h.split(`
12
+ `),$=F.length;!O&&!D&&$>800&&(x=1,b=50);let k=Math.max(0,x-1),L=Math.min($,b),j=F.slice(k,L),E=`File: [${e}] (Showing lines ${k+1}-${L} of ${$}).`,C=j.map((t,m)=>`${String(k+m+1).padStart(4)}: ${t.trimEnd()}`).join(`
13
+ `);return`${E}
14
+
15
+ ${C}`}catch(u){let M=u instanceof Error?u.message:String(u);return`ERROR: Failed to read file [${e}]: ${M}`}};export{Q as a};
@@ -0,0 +1,33 @@
1
+ import{a as b,b as T}from"./chunk-FJGY5C4M.js";import{a as A}from"./chunk-Y5JU726N.js";import{spawn as C}from"child_process";var P=null;try{let f=await import("node-pty");P=f.default||f}catch{}var _=!!P,S=f=>typeof f!="string"?f:f.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),E=f=>{if(!f)return"";let p=[[]],n=0,o=0,w=/\x1b\[([0-9;]*?)([a-zA-Z])/g,g=0,h,d=u=>{for(let e=0;e<u.length;e++){let s=u[e];if(s===`
2
+ `)for(n++,o=0;n>=p.length;)p.push([]);else if(s==="\r")o=0;else{for(;n>=p.length;)p.push([]);let t=p[n];for(;o>t.length;)t.push(" ");t[o]=s,o++}}};for(;(h=w.exec(f))!==null;){d(f.substring(g,h.index));let u=h[1],e=h[2],s=u?u.split(";").map(Number):[];if(e==="A"){let t=s[0]||1;n=Math.max(0,n-t)}else if(e==="B"){let t=s[0]||1;for(n=n+t;n>=p.length;)p.push([])}else if(e==="C"){let t=s[0]||1;o=o+t}else if(e==="D"){let t=s[0]||1;o=Math.max(0,o-t)}else if(e==="G"){let t=(s[0]||1)-1;o=Math.max(0,t)}else if(e==="H"||e==="f"){let t=(s[0]||1)-1,r=(s[1]||1)-1;for(n=Math.max(0,t),o=Math.max(0,r);n>=p.length;)p.push([])}else if(e==="K"){let t=s[0]||0;if(n<p.length){let r=p[n];if(t===0)r.length=o;else if(t===1)for(let c=0;c<o&&c<r.length;c++)r[c]=" ";else t===2&&(r.length=0)}}else if(e==="J"){let t=s[0]||0;(t===2||t===3)&&(p.length=0,p.push([]),n=0,o=0)}g=w.lastIndex}d(f.substring(g));let O=p.map(u=>u.join(""));for(;O.length>0&&O[O.length-1]==="";)O.pop();return O.join(`
3
+ `)},x=null,k=!1,D=f=>{try{x&&(k&&typeof x.write=="function"?x.write(f):x.stdin&&x.stdin.writable&&x.stdin.write(f))}catch{}},F=()=>{if(x){try{k&&typeof x.destroy=="function"?x.destroy():typeof x.kill=="function"&&(process.platform==="win32"?C("taskkill",["/pid",x.pid,"/f","/t"]):x.kill("SIGKILL"))}catch{}x=null,k=!1}},v=(f,p=!1)=>{if(process.platform!=="win32")return f;let n=[],o="",w=null,g=!1;for(let e=0;e<f.length;e++){let s=f[e];if(g){o+=s,g=!1;continue}if(s==="\\"){if(f[e+1]===" "){o+=" ",e++;continue}o+=s,g=!0;continue}w?(s===w&&(w=null),o+=s):s==='"'||s==="'"?(w=s,o+=s):s===";"&&!o.includes("://")?(o.length>0&&(n.push(o),o=""),n.push(p?";":"&")):s==="&"&&!o.includes("://")?f[e+1]==="&"?(o.length>0&&(n.push(o),o=""),n.push("&&"),e++):(o.length>0&&(n.push(o),o=""),n.push("&")):s==="|"&&!o.includes("://")?(o.length>0&&(n.push(o),o=""),n.push("|")):/\s/.test(s)?o.length>0&&(n.push(o),o=""):o+=s}o.length>0&&n.push(o);let h=e=>!(!e.includes("/")||/^(https?|file|ftp):\/\//i.test(e)||e.startsWith("@")||e.startsWith("/")&&(e.match(/\//g)||[]).length===1||/\s\/|\/\s/.test(e)||/[\(\)\{\}\;\<\>\=\'\"]/.test(e)),d=[];for(let e=0;e<n.length;e++){let s=n[e];if(s==="mkdir"&&p&&b()){let t=[],r=e+1;for(;r<n.length;){let c=n[r];if([">",">>","<","&","&&","|","||",";"].includes(c))break;c!=="-p"&&c!=="--parents"&&c!=="-v"&&c!=="--verbose"&&t.push(c),r++}if(t.length>0){let c=t.map(i=>{let a=i.replace(/^['"]|['"]$/g,""),l=i;return h(a)&&(l=i.replace(/\//g,"\\")),l});d.push("New-Item","-ItemType","Directory","-Force","-Path",c.join(","))}else d.push("New-Item","-ItemType","Directory","-Force");e=r-1;continue}if(s==="rm"&&p&&b()){let t=[],r=!1,c=!1,i=e+1;for(;i<n.length;){let l=n[i];if([">",">>","<","&","&&","|","||",";"].includes(l))break;l==="-rf"||l==="-fr"?(r=!0,c=!0):l==="-r"||l==="-R"||l==="--recursive"?r=!0:l==="-f"||l==="--force"?c=!0:t.push(l),i++}let a=["Remove-Item"];if(r&&a.push("-Recurse"),c&&a.push("-Force"),t.length>0){let l=t.map(m=>{let $=m.replace(/^['"]|['"]$/g,""),R=m;return h($)&&(R=m.replace(/\//g,"\\")),R});a.push("-Path",l.join(","))}d.push(...a),e=i-1;continue}if(s==="cp"&&p&&b()){let t=[],r=!1,c=!1,i=e+1;for(;i<n.length;){let l=n[i];if([">",">>","<","&","&&","|","||",";"].includes(l))break;l==="-r"||l==="-R"||l==="--recursive"?r=!0:l==="-f"||l==="--force"?c=!0:t.push(l),i++}let a=["Copy-Item"];if(r&&a.push("-Recurse"),c&&a.push("-Force"),t.length>0){let l=t.map(m=>{let $=m.replace(/^['"]|['"]$/g,""),R=m;return h($)&&(R=m.replace(/\//g,"\\")),R});if(l.length>1){let m=l.pop();a.push("-Path",l.join(","),"-Destination",m)}else a.push("-Path",l[0])}d.push(...a),e=i-1;continue}if(s==="touch"&&p&&b()){let t=[],r=e+1;for(;r<n.length;){let c=n[r];if([">",">>","<","&","&&","|","||",";"].includes(c))break;t.push(c),r++}if(t.length>0){let i=`(${t.map(a=>{let l=a.replace(/^['"]|['"]$/g,""),m=a;return h(l)&&(m=a.replace(/\//g,"\\")),m}).join(", ")}) | ForEach-Object { if (Test-Path $_) { (Get-Item $_).LastWriteTime = [System.DateTime]::Now } else { $null | Out-File -FilePath $_ } }`;d.push(i)}e=r-1;continue}if(s==="|"&&n[e+1]==="tee"){n[e+2]==="-a"?(d.push(">>"),e+=2):(d.push(">"),e+=1);continue}if(s==="|"&&n[e+1]==="cat"&&n[e+2]===">"){d.push(">"),e+=2;continue}if(s==="|"){let t=n[e+1];if(t){let r=t.replace(/^['"]|['"]$/g,""),c=/\.(txt|md|json|log|csv|html|css|py|js|xml|yaml|yml|pdf|docx|pptx|xlsx)$/i.test(r);if(h(r)&&c){d.push(">");continue}}}d.push(s)}let O=!1,u=d.map(e=>{if(e==="echo")return O=!0,e;[">",">>","<","&","&&","|","||",";"].includes(e)&&(O=!1);let t=/^['"]|['"]$/.test(e),r=e;O&&t&&(r=e.replace(/^['"]|['"]$/g,""));let c=/^['"]|['"]$/.test(r),i=r.replace(/^['"]|['"]$/g,"");h(i)&&(r=r.replace(/\//g,"\\"));let a=r.replace(/^['"]|['"]$/g,"");return a.includes(" ")&&!c&&(r=`"${a}"`),r});if(p){let e="",s=0;for(let t=0;t<u.length;t++){let r=u[t];r==="&&"?(e+="; if ($?) {",s++):r===";"?(e+=" }".repeat(s)+";",s=0):(e&&!e.endsWith(" ")&&!e.endsWith("{")&&(e+=" "),e+=r)}return e+=" }".repeat(s),e}return u.join(" ")},M=async(f,p={})=>{let{command:n}=A(f),{onChunk:o}=p;if(!n)return'ERROR: Missing "command" argument for exec_command.';let w=process.platform==="win32",g=p.systemSettings||{},h={};return g.networkAccess===!1&&(h.HTTP_PROXY="http://127.0.0.1:9999",h.HTTPS_PROXY="http://127.0.0.1:9999",h.ALL_PROXY="socks5://127.0.0.1:9999",h.http_proxy="http://127.0.0.1:9999",h.https_proxy="http://127.0.0.1:9999",h.all_proxy="socks5://127.0.0.1:9999",h.NO_PROXY="localhost,127.0.0.1"),new Promise(d=>{let O=u=>{let e=u==="pwsh"||u==="powershell",s=v(n,e),t;w?u==="pwsh"?t="pwsh.exe":u==="powershell"?t="powershell.exe":t="cmd.exe":t=process.env.SHELL||"bash";let r=w?e?["-NoProfile","-Command",s]:["/c",s]:["-c",s];if(g.networkAccess===!1&&!w){let c=t,i=[...r];if(process.platform==="linux")t="unshare",r=["-n","-r",c,...i];else if(process.platform==="darwin"){let a=`(version 1)
4
+ (allow default)
5
+ (deny network-outbound)
6
+ (allow network-outbound (remote ip "localhost:*"))
7
+ (allow network-outbound (remote ip "127.0.0.1:*"))
8
+ `;t="sandbox-exec",r=["-p",a,c,...i]}}if(P)try{let c=P.spawn(t,r,{name:"xterm-256color",cols:p.cols||120,rows:p.rows||30,cwd:process.cwd(),env:{...process.env,CI:"false",TERM:"xterm-256color",FORCE_COLOR:"1",...h}});x=c,k=!0;let i="",a=!1;return c.onData(l=>{if(!a){i+=l,o&&o(l);let m=S(i);/(?:Network:\s+use\s+--host\s+to|Network:\s+Type\s+--host\s+to|Local:\s+http:\/\/localhost:\d+|ready in \d+\s*ms|Compiled successfully|Development server is running|Listening on:)/i.test(m)&&(a=!0,setTimeout(()=>d(`SUCCESS: Dev server started successfully in background.
9
+
10
+ ${m}`),500))}}),c.onExit(({exitCode:l})=>{if(a)return;x=null;let m=E(i||""),$=S(m).replace(/\n{3,}/g,`
11
+
12
+ `)||"Command executed with no output.";d(l!==0?`ERROR: Command [${n}] failed with exit code [${l}].
13
+
14
+ ${$}`:`SUCCESS: Command [${n}] completed.
15
+
16
+ ${$}`)}),!0}catch(c){return w&&(u==="pwsh"||u==="powershell")&&c.code==="ENOENT"?!1:(y(d,s,n,h,o,u,g),!0)}else return y(d,s,n,h,o,u,g),!0};if(w){let u=T();O(u)||(u==="pwsh"&&!O("powershell")||u==="powershell")&&O("cmd")}else O("bash")})},y=(f,p,n,o,w,g="powershell",h={})=>{let d=process.platform==="win32",O=g==="pwsh"||g==="powershell",u;d?g==="pwsh"?u="pwsh.exe":g==="powershell"?u="powershell.exe":u="cmd.exe":u=process.env.SHELL||"bash";let e=d?O?["-NoProfile","-Command",p]:["/c",p]:["-c",p];if(h.networkAccess===!1&&!d){let i=u,a=[...e];if(process.platform==="linux")u="unshare",e=["-n","-r",i,...a];else if(process.platform==="darwin"){let l=`(version 1)
17
+ (allow default)
18
+ (deny network-outbound)
19
+ (allow network-outbound (remote ip "localhost:*"))
20
+ (allow network-outbound (remote ip "127.0.0.1:*"))
21
+ `;u="sandbox-exec",e=["-p",l,i,...a]}}let s=d?C(u,e,{cwd:process.cwd(),env:{...process.env,...o}}):C(u,e,{cwd:process.cwd(),env:{...process.env,CI:"false",TERM:"xterm-256color",FORCE_COLOR:"1",...o}});x=s,k=!1,s.stdin&&s.stdin.on("error",()=>{x=null});let t="",r="",c=!1;s.stdout.on("data",i=>{if(!c){let a=i.toString();t+=a,w&&w(a);let l=S(t);/(?:Network:\s+use\s+--host\s+to|Network:\s+Type\s+--host\s+to|Local:\s+http:\/\/localhost:\d+|ready in \d+\s*ms|Compiled successfully|Development server is running|Listening on:)/i.test(l)&&(c=!0,setTimeout(()=>f(`SUCCESS: Dev server started successfully in background.
22
+
23
+ ${l}`),500))}}),s.stderr.on("data",i=>{if(!c){let a=i.toString();r+=a,w&&w(a)}}),s.on("close",i=>{if(c)return;x=null;let a=[],l=E(t),m=E(r);l&&a.push(`STDOUT:
24
+ ${l}`),m&&a.push(`STDERR:
25
+ ${m}`),i!==0&&a.push(`EXIT CODE: ${i}`);let $=a.join(`
26
+
27
+ `)||"Command executed with no output.",R=S($).replace(/\n{3,}/g,`
28
+
29
+ `);f(i!==0?`ERROR: Command [${n}] failed with exit code [${i}].
30
+
31
+ ${R}`:`SUCCESS: Command [${n}] completed.
32
+
33
+ ${R}`)}),s.on("error",i=>{if(d&&i.code==="ENOENT"){if(g==="pwsh"){let l=v(n,!0);return y(f,l,n,o,w,"powershell",h)}else if(g==="powershell"){let l=v(n,!1);return y(f,l,n,o,w,"cmd",h)}}x=null;let a=i instanceof Error?i.message:String(i);f(`ERROR: Failed to start command [${n}]: ${a}`)})};export{_ as a,E as b,x as c,k as d,D as e,F as f,v as g,M as h};
@@ -0,0 +1,48 @@
1
+ import{c as W}from"./chunk-4TZKD2XR.js";import G from"os";var A=t=>typeof t!="string"?t:t.length>12?(t+"").replace("",""):t,U=(t,o)=>{if(!t)return"";let u=/\x1B\[[0-?]*[ -/]*[@-~]/g,m=t.split(`
2
+ `),a=[];if(o<=5)return t;let r=h=>h.replace(u,"").length;return m.forEach(h=>{if(r(h)<=o){a.push(h);return}let f=h.split(/(\s+)/),e="",i=0,p=h.match(/^(\s*)/),s=p?p[1]:"";f.forEach((b,c)=>{if(b.length===0)return;let l=r(b);if(i+l>o)if(e.trim().length>0)a.push(e.trimEnd()),e=s.substring(0,Math.min(s.length,8))+b,i=r(e);else if(u.test(b))a.push(b),e=s,i=r(e);else{let S=b;for(;r(S)>o&&o>10;)a.push(S.substring(0,o)),S=S.substring(o);e=S,i=r(e)}else e+=b,i+=l}),(e.trimEnd().length>0||e===s)&&a.push(e.trimEnd())}),A(a.join(`
3
+ `))},it=t=>{if(!t&&t!==0)return"0.0k";let o=typeof t=="string"?parseFloat(t):t;return o>=1e6?`${(o/1e6).toFixed(1)}m`:o>=1e3?`${(o/1e3).toFixed(1)}k`:o.toString()},st=(t,o=40)=>{let u=W.replaceAll("\\\\","\\");if(t=t.replace(G.homedir(),"~").replace(u,"FluxFlow").replaceAll("\\","/"),!t||t.length<=o)return A(t);let m=Math.floor((o-3)/2);return A(t.substring(0,m)+"..."+t.substring(t.length-m).replaceAll("\\","/"))},rt=t=>{let o=[],u=new Set,m=t.allowMultiple===!0||String(t.allowMultiple).toLowerCase()==="true";Object.keys(t).forEach(f=>{let e=f.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(e){let i=e[2]?parseInt(e[2],10):1;u.add(i)}});let a=Array.from(u).sort((f,e)=>f-e),r=["searchContent","search_content","replaceContent","replace_content","content_to_replace","searchBlock","search_block"],h=["newContent","new_content","content_to_add","newBlock","new_block"],y=(f,e,i)=>{let p,s;for(let b of e){let c=f===1?[`${b}1`,b,`${b}_1`]:[`${b}${f}`,`${b}_${f}`];for(let l of c)if(t[l]!==void 0){p=t[l];break}if(p!==void 0)break}for(let b of i){let c=f===1?[`${b}1`,b,`${b}_1`]:[`${b}${f}`,`${b}_${f}`];for(let l of c)if(t[l]!==void 0){s=t[l];break}if(s!==void 0)break}return{r:p,n:s}};for(let f of a){let{r:e,n:i}=y(f,r,h);if(e!==void 0&&i!==void 0)o.push({replace:e,new:i});else if(e!==void 0||i!==void 0)return{error:`Mismatched replacement pair for index ${f}. Both replacement and new content must be provided.`,allowMultiple:m}}return{patchPairs:o,allowMultiple:m}},H=t=>{if(!t)return null;let o="",u=0,m=t.length;for(;u<m;){let a=t[u];if(a==="\\"){for(;u<m&&t[u]==="\\";)u++;o+="\\\\*"}else if(a===`
4
+ `)o+="(?:\\r?\\n|\\\\*n|\\\\*r|\\s*)",u++;else if(a==="\r")o+="(?:\\r|\\\\*r)?",u++;else if(a===" ")o+="(?:\\t|\\\\*t|\\s*)",u++;else if(a==='"'||a==="'"||a==="`")o.endsWith("\\\\*")||(o+="\\\\*"),o+=a,u++;else if(/[.*+?^${}()|[\]]/.test(a))o+="\\"+a,u++;else if(/\s/.test(a)){for(;u<m&&/\s/.test(t[u])&&t[u]!==`
5
+ `&&t[u]!=="\r"&&t[u]!==" ";)u++;o+="\\s*"}else o+=a,u++}if(!o)return null;try{return new RegExp(o,"g")}catch{return null}},ot=(t,o,u={})=>{let m=typeof u=="boolean"?u:!!(u&&u.allowMultiple),a=t.replace(/\r\n/g,`
6
+ `).replace(/\r/g,`
7
+ `),r=n=>n.replace(/^```[\w]*\n?/,"").replace(/```\s*$/,"").replace(/\r\n/g,`
8
+ `).replace(/\r/g,`
9
+ `),h=n=>n.match(/^\s*/)[0],y=n=>{let d=n.split(`
10
+ `).filter(g=>g.trim()!=="");if(d.length===0)return"";let $=h(d[0]);for(let g of d){let L=h(g);L.length<$.length&&($=L)}return $},f=(n,d,$="")=>{if(!n||d===void 0)return n;let L=/^\t/m.test(d)?" ":" ",I=T=>T.split(`
11
+ `).find(M=>M.trim()!=="")??"",w=I(d).match(/^\s*/)[0].length,k=I(n).match(/^\s*/)[0].length,C=w-k,E=($.match(/^\s*/)||[""])[0].length;return n.split(`
12
+ `).map((T,M)=>{if(T.trim()===""&&M!==0)return"";let _=T.match(/^\s*/)[0].length,R=Math.max(0,_+C);return M===0&&(R=Math.max(0,R-E)),L.repeat(R)+T.trimStart()}).join(`
13
+ `)},e=[];for(let n=0;n<o.length;n++){let d=o[n],$=(d.replace||"").trim(),g=r(d.new||"");if($.startsWith("^LINE:")&&$.endsWith("$")){let E=$.slice(6,-1).trim().split(".."),x=parseInt(E[0]),T=E[1]!==void 0?parseInt(E[1]):x;if(!isNaN(x)&&!isNaN(T)){let M=a.split(`
14
+ `);if(x<1||x>M.length||T<x||T>M.length){e.push({index:n,success:!1,error:`Block ${n+1}: Line range ^LINE:${x}..${T}$ out of bounds (file has ${M.length} lines).`});continue}let R=M.slice(x-1,T).join(`
15
+ `),j=0;for(let N=0;N<x-1;N++)j+=M[N].length+1;e.push({index:n,success:!0,startPos:j,firstMatchContent:R,content_to_add:g});continue}}let L=r(d.replace||"");if(L===""&&g===""){e.push({index:n,success:!1,error:`Block ${n+1}: Empty replace and add content.`});continue}let I=L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),w=null;if(L!==""&&a.includes(L))w=new RegExp(I,"g");else{let C=L.split(`
16
+ `).map(E=>E.trim()).filter(E=>E.length>0).map(E=>E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"\\s*"));if(C.length>0){let E=C.join("\\s*");try{w=new RegExp(E,"g")}catch{w=new RegExp(I,"g")}}else w=new RegExp(I,"g")}let k=[...a.matchAll(w)];if(k.length===0&&L!==""){let C=H(L);C&&(k=[...a.matchAll(C)])}if(k.length===0){e.push({index:n,success:!1,error:`Block ${n+1}: Could not find match.`});continue}if(k.length>1&&!m){e.push({index:n,success:!1,error:`Block ${n+1}: Found ${k.length} matches (must be unique or use allowMultiple: true if sure).`});continue}for(let C of k)e.push({index:n,success:!0,startPos:C.index,firstMatchContent:C[0],content_to_add:g})}let i=e.filter(n=>n.success).sort((n,d)=>n.startPos-d.startPos);for(let n=0;n<i.length-1;n++){let d=i[n],$=i[n+1];d.startPos+d.firstMatchContent.length>$.startPos&&(d.success=!1,d.error=`Block ${d.index+1}: Overlaps with another block.`,$.success=!1,$.error=`Block ${$.index+1}: Overlaps with another block.`)}let p=new Map,s=a,b=0,c=0,l=e.filter(n=>n.success).sort((n,d)=>n.startPos-d.startPos);for(let n of l){let d=n.startPos,$=a.substring(0,d).split(`
17
+ `).length,g=d+b,L=$+c,I=s.lastIndexOf(`
18
+ `,g)+1,w=s.substring(I,g),k=f(n.content_to_add,n.firstMatchContent,w),C=s.split(`
19
+ `),E=[];for(let _=Math.max(0,L-4);_<L-1;_++)E.push({num:_+1,text:C[_]});let x=n.firstMatchContent.split(`
20
+ `),T=[],M=L+x.length-1;for(let _=M;_<Math.min(C.length,M+3);_++)T.push({num:_+1,text:C[_]});p.set(n,{success:!0,index:n.index,oldContent:n.firstMatchContent,newContent:k,originalStartLine:$,finalStartLine:L,contextBefore:E,contextAfter:T}),s=s.substring(0,g)+k+s.substring(g+n.firstMatchContent.length),b+=k.length-n.firstMatchContent.length,c+=k.split(`
21
+ `).length-n.firstMatchContent.split(`
22
+ `).length}let S=[];for(let n=0;n<o.length;n++){let d=l.filter($=>$.index===n);if(d.length>0)for(let $ of d)p.has($)&&S.push(p.get($));else{let $=e.find(g=>g.index===n);S.push({success:!1,error:$?$.error:`Block ${n+1}: Unknown error.`})}}return{content:s,results:S}},lt=(t,o,u,m=8,a=!1)=>{if(!u||u.length===0)return"";let r=t.split(/\r?\n/),h=o.split(/\r?\n/),y=Math.max(r.length,h.length,1),f=Math.max(4,String(y).length),e=l=>String(l).padStart(f," "),i=`[DIFF_START]
23
+ `,p="\u2550".repeat(88),s=0,b=null,c=u.filter(l=>l.success).sort((l,S)=>l.originalStartLine-S.originalStartLine);if(c.forEach((l,S)=>{let n=l.finalStartLine!==void 0?l.finalStartLine:l.originalStartLine;if(b===null)for(s=Math.max(0,n-4);s<n-1;)i+=`[UI_CONTEXT] ${e(s+1)} |${h[s]||""}
24
+ `,s++;else{let k=b,C=k.originalStartLine+k.oldContent.split(`
25
+ `).length-1;if(l.originalStartLine-C-1>=m){let x=Math.min(h.length,s+3);for(;s<x;)i+=`[UI_CONTEXT] ${e(s+1)} |${h[s]||""}
26
+ `,s++;for(i+=`[UI_CONTEXT] ${p}
27
+ `,s=Math.max(s,n-4);s<n-1;)i+=`[UI_CONTEXT] ${e(s+1)} |${h[s]||""}
28
+ `,s++}else for(;s<n-1;)i+=`[UI_CONTEXT] ${e(s+1)} |${h[s]||""}
29
+ `,s++}let d=l.originalStartLine-1,$=r[d]||"",g=l.oldContent.split(`
30
+ `),L=$.match(/^\s*/),I=L?L[0]:"";g.forEach((k,C)=>{let E=k;if(g.length===1&&$.trim().length>0&&$.includes(k.trim()))E=$;else if(C===0){let x=k.match(/^\s*/);(x?x[0]:"").length<I.length&&$.includes(k.trim())&&(E=I+k.trimStart())}i+=`-${e(l.originalStartLine+C)} |${E}
31
+ `});let w=s;if(l.finalStartLine!==void 0)w=l.finalStartLine-1+(l.newContent?l.newContent.split(`
32
+ `).length:0);else{let k=l.originalStartLine+g.length-1,C=r[k]||null;if(C!==null){let E=S<c.length-1?(c[S+1].originalStartLine||h.length)+10:h.length;for(let x=s;x<E;x++){if(h[x]===C){w=x;break}x===h.length-1&&(w=h.length)}}else w=h.length}for(;s<w;)i+=`+${e(s+1)} |${h[s]||""}
33
+ `,s++;b=l}),b!==null){let l=Math.min(h.length,s+3);for(;s<l;)i+=`[UI_CONTEXT] ${e(s+1)} |${h[s]||""}
34
+ `,s++}if(a){let l=`[DIFF_START]
35
+ `,S=i.substring(l.length),n=`[UI_CONTEXT] ${p}
36
+ `,$=S.split(n).map(g=>g.split(`
37
+ `).filter(I=>I.trim()!=="").length>45?`[[VERIFIED]]
38
+ ${g}
39
+ [[/VERIFIED]]`:g);i=l+$.join(n)}return i+="[DIFF_END]",A(i)},V=t=>{if(!t)return null;let o=t.replace("[UI_CONTEXT]","").replace(/\r/g,""),u=o.startsWith("-"),m=o.startsWith("+"),a=u||m?o.substring(1):o,r=a.indexOf("|"),h=r!==-1?A(a.substring(0,r).trim()):"",y=A(r!==-1?a.substring(r+1):a);return{isR:u,isA:m,num:h,content:y}},K=(t,o)=>{if(!t&&!o)return 1;if(!t||!o)return 0;let u=t.length,m=o.length,a=t,r=o;u<m&&(a=o,r=t);let h=a.length,y=r.length,f=new Int32Array(y+1),e=new Int32Array(y+1);for(let s=0;s<=y;s++)f[s]=s;for(let s=1;s<=h;s++){e[0]=s;let b=a[s-1];for(let c=1;c<=y;c++)b===r[c-1]?e[c]=f[c-1]:e[c]=Math.min(f[c],e[c-1],f[c-1])+1;f.set(e)}let i=f[y],p=Math.max(u,m);return p===0?1:1-i/p},X=t=>{let o=[],u=[];t.forEach((i,p)=>{i.parsed.isR?o.push({index:p,content:i.parsed.content}):i.parsed.isA&&u.push({index:p,content:i.parsed.content})});let m=o.length,a=u.length;if(m===0||a===0)return;let r=Array.from({length:m+1},()=>Array(a+1).fill(0)),h=Array.from({length:m+1},()=>Array(a+1).fill(""));for(let i=1;i<=m;i++)h[i][0]="up";for(let i=1;i<=a;i++)h[0][i]="left";let y=Array.from({length:m},()=>Array(a).fill(0));for(let i=0;i<m;i++)for(let p=0;p<a;p++)y[i][p]=K(o[i].content.trim(),u[p].content.trim());for(let i=1;i<=m;i++)for(let p=1;p<=a;p++){let s=y[i-1][p-1],b=s>=.2?s:-10,c=r[i-1][p-1]+b,l=r[i-1][p],S=r[i][p-1];c>=l&&c>=S?(r[i][p]=c,h[i][p]="diag"):l>=S?(r[i][p]=l,h[i][p]="up"):(r[i][p]=S,h[i][p]="left")}let f=m,e=a;for(;f>0||e>0;)if(h[f][e]==="diag"){if(y[f-1][e-1]>=.2){let p=o[f-1].index,s=u[e-1].index;t[p].pairContent=t[s].parsed.content,t[s].pairContent=t[p].parsed.content}f--,e--}else h[f][e]==="up"?f--:e--},O=new Map,B=new Map,z=200,v=6,D=(t,o)=>{o.set(t.key,t),t.type==="chunk"&&t.blocks&&t.blocks.forEach(u=>D(u,o))},ct=(t,o)=>{if(!t)return{completed:[],active:[]};let u=`${t.id}-${t.text?.length||0}-${o}-${t.isStreaming}-${t.workedDuration||0}`;if(!t.isStreaming&&O.has(u))return O.get(u);let m=A(tt(t.text||"",t.role)),a=`${t.id}-${o}`,r=new Map;if(t.isStreaming){let c=B.get(a);c&&m.startsWith(c.text)&&(r=c.blocksMap)}let h=(c,l,S,n={})=>{let d=r.get(c);if(d&&d.text===S&&d.type===l&&!!d.isActiveBlock==!!n.isActiveBlock&&!!d.isStreaming==!!n.isStreaming&&d.pairContent===n.pairContent)return d;let $=A(S),g={...n};return typeof g.pairContent=="string"&&(g.pairContent=A(g.pairContent)),Array.isArray(g.wrappedLines)&&(g.wrappedLines=g.wrappedLines.map(A)),{key:c,isStreamingMsg:!!t.isStreaming,workedDuration:t.workedDuration,type:l,text:$,msg:l==="full-message"?t:void 0,...g}};if(m.includes("- Content Preview:")){let c="",l=m.match(/File\s+\[(.*?)\]/i);l&&(c=l[1].split(".").pop().toLowerCase());let g=((m.split("- Content Preview:")[1]||"").split("[SYSTEM] Check the content preview for verification [/SYSTEM]")[0]?.trim()||"").split(`
40
+ `).map(x=>x.replace(/\r$/,"")),L=String(g.length).length,I=[],w=null,k=[],C=()=>{if(!k.length)return;let x=k;k=[],I.push(x.length===1?x[0]:{key:`${x[0].key}-chunk`,type:"chunk",blocks:x})},E=o-(L+6);return g.forEach((x,T)=>{let M=T===g.length-1,_=U(x,E).split(`
41
+ `),R=h(`${t.id||Date.now()}-write-line-${T}`,"write-line",x,{gutterWidth:L,lineNum:T+1,isFirstLine:T===0,isLastLine:M,extension:c,wrappedLines:_});M&&t.isStreaming?(C(),w=R):(k.push(R),k.length>=v&&C())}),C(),{completed:I,active:w?[w]:[]}}if(m.includes("[DIFF_START]")){let c=m.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),S=(c?c[1].trim():"").split(`
42
+ `).map(w=>w.replace(/\r$/,"")),n=S.map(w=>({line:w,parsed:V(w),pairContent:null})),d=[];for(let w=0;w<n.length;w++){let k=n[w];k.parsed&&(k.parsed.isR||k.parsed.isA)?d.push(k):d.length>0&&(X(d),d=[])}d.length>0&&X(d);let $=[],g=null,L=[],I=()=>{if(!L.length)return;let w=L;L=[],$.push(w.length===1?w[0]:{key:`${w[0].key}-chunk`,type:"chunk",blocks:w})};return S.forEach((w,k)=>{let C=k===S.length-1,E=n[k].parsed,x=null;E&&(x=U(E.content,o-17).split(`
43
+ `));let T=h(`${t.id||Date.now()}-diff-${k}`,"diff-line",w,{isFirstLine:k===0,isLastLine:C,pairContent:n[k].pairContent,wrappedLines:x});C&&t.isStreaming?(I(),g=T):(L.push(T),L.length>=v&&I())}),I(),{completed:$,active:g?[g]:[]}}if(t.role==="system"||t.isLogo||t.isHelpRecord||t.isTerminalRecord||t.isHomeWarning||t.isImageStats||t.isAskRecord||t.isAboutRecord||t.isUpdateNotification||t.role==="user")return{completed:[h(`${t.id||Date.now()}-full`,"full-message",m)],active:[]};if(!m&&!t.isStreaming){let c={completed:[],active:[]};return O.set(u,c),c}let y=[],f=null,e=[],i=null,p=()=>{if(!e.length)return;let c=e;e=[],i=null,y.push(c.length===1?c[0]:{key:`${t.id||"x"}-chunk-${c[0].key}`,type:"chunk",blocks:c})},s=(c,l=!1)=>{if(i!==null&&i!==c.type&&p(),e.push(c),i=c.type,e.length>=v){if(t.isStreaming&&l)return;p()}};if(t.role==="think"){y.push(h(`${t.id}-header`,"think-header",""));let c=m.split(`
44
+ `);c.forEach((l,S)=>{let n=S===c.length-1;s(h(`${t.id}-${S}`,"think-line",l,{}),n)}),t.isStreaming||(p(),y.push({key:`${t.id}-footer-padding`,type:"think-footer-padding",text:""}))}else{let c=m.split(`
45
+ `),l=!1,S=[],n=!1,d="",$=0,g=0;c.forEach((L,I)=>{let w=I===c.length-1,k=L.trim().startsWith("|"),C=L.trim().startsWith("```");n?C?(n=!1,s(h(`${t.id}-code-close-${g}`,"code-fence-close","",{}),w)):($++,s(h(`${t.id}-code-line-${I}`,"code-line",L,{lineNum:$,lang:d}),w)):C?(n=!0,g=I,$=0,d=L.trim().replace(/^```/,"").trim(),s(h(`${t.id}-code-open-${I}`,"code-fence-open",d,{}),w)):k?(l=!0,S.push(L),w&&(p(),t.isStreaming?f=h(`${t.id}-table-${I}`,"table",S.join(`
46
+ `),{isStreaming:!0}):y.push(h(`${t.id}-table-${I}`,"table",S.join(`
47
+ `),{isStreaming:!1})))):(l&&(p(),y.push(h(`${t.id}-table-${I}`,"table",S.join(`
48
+ `),{isStreaming:!1})),l=!1,S=[]),s(h(`${t.id}-${I}`,"agent-line",L,{}),w))}),!t.isStreaming&&t.workedDuration&&(p(),y.push(h(`${t.id}-worked-duration`,"worked-duration","")))}t.isStreaming&&e.length>0?f=e.length===1?e[0]:{key:`${t.id||"x"}-chunk-active-${e[0].key}`,type:"chunk",blocks:e}:p();let b={completed:y,active:f?[f]:[]};if(t.isStreaming){let c=new Map;if(y.forEach(l=>D(l,c)),f&&D(f,c),B.set(a,{text:m,blocksMap:c}),B.size>z){let l=B.keys().next().value;B.delete(l)}}else{if(O.set(u,b),O.size>z){let c=O.keys().next().value;O.delete(c)}B.delete(a)}return b},Y={},q=/(\r?\n){2}(?=\[?(?:tool:functions|tool\.functions|agent:generalist|agent\.generalist|\s*turn\s*:))/gi,F=(t,o)=>{let u=!1,m=!1,a=0;for(;a<o;){if(t.startsWith("```",a)){m=!m,a+=3;continue}!m&&t[a]==="`"&&(a===0||t[a-1]!=="\\")&&(u=!u),a++}return m||u},Z=/\[SYSTEM\][\s\S]*?\[\/SYSTEM\]|\[ANSWER\][\s\S]*?(?:\[\/ANSWER\]|$)|\[TOOL RESULT\]:?\s*|^\s*(SUCCESS|ERROR):.*(\r?\n)?|\[\s*turn\s*:\s*(continue|finish)\s*\]|\[\[END\]\]|\[\s*turn\s*:?.*?$|\n\s*turn\s*:?.*?$|\[\s*(?:turn|ANSWER|TOOL).*?$|\n\nResponded on .*|\n\n\[Prompted on: .*\]|@\[TerminalName:.*?, ProcessId:.*?\]/gm,J=/(\$?\\?\/?\\rightarrow\$?|\$\\rightarrow\$)|(\$?\\?\/?\\leftarrow\$?|\$\\leftarrow\$)|(\$?\\?\/?\\uparrow\$?|\$\\uparrow\$)|(\$?\\?\/?\\downarrow\$?|\$\\downarrow\$)|(\$?\\?\/?\\leftrightarrow\$?|\$\\leftrightarrow\$)/gi,Q=/\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,P=!1,tt=(t,o="agent")=>{if(!t)return t;let u=o===!0||o==="think",m=o===!1||o==="agent",a=t.replace(/<\|channel>thought/gi,"<think>").replace(/<channel\|>/gi,"</think>");if(u)return a.replace(/^<(think|thought|thoughts|thinking)>/gi,"").replace(/<\/(think|thought|thoughts|thinking)>$/gi,"").replace(/^\r?\n+/,"").replace(/\r?\n+$/,"");let r=a;m&&(r=r.replace(/<\/?(?:think|thought|thoughts|thinking)>/gi,(f,e,i)=>F(i,e)?f:""),r=r.replace(q,(f,e,i,p)=>!P&&F(p,i)?f:""),r&&r.includes("[tool:")&&(r=r.replace(/<(\w+)(?:[^>]*)>\s*([\s\S]*?\[tool:[^\]]*\][\s\S]*?)\s*<\/\1>/gi,(f,e,i)=>i&&i.includes("[tool:")?i.trim():f),P&&(r=r.replace(/```(?:tool|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi,(f,e)=>e.includes("[tool:")?e.trim():f))));let h="tool:functions.",y="agent:generalist.";if(m&&(r.toLowerCase().includes(h)||r.toLowerCase().includes(y)))for(;;){let f=r.toLowerCase(),e=f.indexOf(h),i=f.indexOf(y),p=h,s=e;if((e===-1||i!==-1&&i<e)&&(p=y,s=i),s===-1)break;if(!P&&F(r,s)){let g=s+p.length,L=f.indexOf(h,g),I=f.indexOf(y,g);if(L===-1&&I===-1)break;let w=-1,k=0;for(;;){let C=f.indexOf(h,k),E=f.indexOf(y,k),x=-1,T=h;if(C===-1&&E===-1)break;if(C===-1||E!==-1&&E<C?(x=E,T=y):x=C,!F(r,x)){w=x,p=T;break}k=x+T.length}if(w===-1)break;s=w}let b=s,c=!1,l=s-1;for(;l>=0&&/\s/.test(r[l]);)l--;l>=0&&r[l]==="["&&(b=l,c=!0);let S=0,n=!1,d=null,$=s;for(;$<r.length;){let g=r[$];if(!d&&(g==="'"||g==='"'||g==="`")?d=g:d&&g===d&&r[$-1]!=="\\"&&(d=null),d||(g==="("?(S++,n=!0):g===")"&&S--),n&&S===0&&!d){let L=$;if(c){let I=$+1;for(;I<r.length&&/\s/.test(r[I]);)I++;I<r.length&&r[I]==="]"&&(L=I)}r=r.substring(0,b)+r.substring(L+1);break}if($++,$===r.length)return n&&S>0&&(r=r.substring(0,b)),r}}return r=r.replace(Z,""),r=r.replace(J,f=>{let e=f.toLowerCase();return e.includes("leftrightarrow")?"\u2194":e.includes("rightarrow")?"\u2192":e.includes("leftarrow")?"\u2190":e.includes("uparrow")?"\u2191":e.includes("downarrow")?"\u2193":f}),r=r.replace(Q,f=>Y[f.toLowerCase()]||f),r.trim()},at=()=>{O.clear(),B.clear()};export{A as a,U as b,it as c,st as d,rt as e,ot as f,lt as g,V as h,X as i,ct as j,P as k,tt as l,at as m};
@@ -0,0 +1 @@
1
+ import S from"os";import a from"path";import n from"fs";import{createRequire as D}from"module";import{fileURLToPath as g}from"url";var w=D(import.meta.url),C=a.dirname(g(import.meta.url));function $(){let m=S.platform(),h=S.arch(),i="",s="",u="";if(m==="win32")i=h==="x64"?"win64":"win32",s="chrome.exe",u=`chrome-${i}`;else if(m==="darwin"){i=h==="arm64"?"mac_arm":"mac";let f=h==="arm64"?"arm64":"x64";s="Google Chrome.app/Contents/MacOS/Google Chrome",u=`chrome-mac-${f}`}else if(m==="linux")i="linux",s="chrome",u="chrome-linux64";else return{};let l=a.resolve(C,"..","..",".puppeteerrc.cjs");if(n.existsSync(l)||(l=a.resolve(C,"..",".puppeteerrc.cjs")),!n.existsSync(l))return{};try{let f=w(l),o=f.cacheDirectory,r=f.chrome?.version;if(o){if(process.env.PUPPETEER_CACHE_DIR=o,r){let c=a.join(o,"chrome",`${i}-${r}`,u,s);if(n.existsSync(c))return{executablePath:c,cacheDirectory:o}}let p=c=>{if(!n.existsSync(c))return null;try{let y=n.readdirSync(c),x=[];for(let t of y){let e=a.join(c,t),P;try{P=n.statSync(e)}catch{continue}if(P.isDirectory())x.push(e);else if(t.toLowerCase()===s.toLowerCase()&&(!r||e.includes(r)))return e}if(r){for(let t of x)if(t.includes(r)){let e=p(t);if(e)return e}}for(let t of x)if(!r||!t.includes(r)){let e=p(t);if(e)return e}}catch{}return null},d=p(o);if(d)return{executablePath:d,cacheDirectory:o}}}catch{}return{}}export{$ as a};
@@ -0,0 +1 @@
1
+ import{s as o}from"./chunk-4TZKD2XR.js";import r from"fs-extra";import l from"path";import d from"https";var j={js:"tree-sitter-javascript.wasm",jsx:"tree-sitter-javascript.wasm",ts:"tree-sitter-typescript.wasm",tsx:"tree-sitter-tsx.wasm",py:"tree-sitter-python.wasm",c:"tree-sitter-c.wasm",cpp:"tree-sitter-cpp.wasm",java:"tree-sitter-java.wasm",html:"tree-sitter-html.wasm"};async function f(t,s=null){let p=s||`https://unpkg.com/tree-sitter-wasms@0.1.13/out/${t}`,i=l.join(o,t);return await r.ensureDir(o),new Promise((m,n)=>{let h={headers:{"User-Agent":"FluxFlow-Agent"}};d.get(p,h,e=>{if([301,302,307,308].includes(e.statusCode)&&e.headers.location){let a=e.headers.location;if(!a.startsWith("http")){let u=new URL(p);a=`${u.protocol}//${u.host}${a}`}f(t,a).then(m).catch(n);return}if(e.statusCode!==200){n(new Error(`Failed to download ${t}: HTTP ${e.statusCode}`));return}let c=r.createWriteStream(i);e.pipe(c),c.on("finish",()=>{c.close(),m()})}).on("error",e=>{r.existsSync(i)&&r.unlink(i,()=>{}),n(e)})})}function S(t){let s=l.join(o,t);return r.existsSync(s)}async function $(t){let s=l.join(o,t);r.existsSync(s)&&await r.unlink(s)}export{j as a,f as b,S as c,$ as d};
@@ -0,0 +1,52 @@
1
+ import{execSync as o}from"child_process";var t=null,h=()=>{if(process.platform!=="win32")return!1;if(t!==null)return t;try{o("where.exe pwsh.exe",{stdio:"ignore",windowsHide:!0}),t=!0}catch{t=!1}return t},r=null,a=()=>{if(process.platform!=="win32")return!1;if(r!==null)return r;try{o("where.exe powershell.exe",{stdio:"ignore",windowsHide:!0}),r=!0}catch{r=!1}return r},b=()=>h()?"pwsh":a()?"powershell":"cmd",n=null,w=(e,l,c,u,d=!1,g=!0,p)=>{n===null&&(n=d);let f=`- Mandatorily JSON escape literal sequences (backslash: \\\\, newLine: \\ n, quote: \\")
2
+ - Same file, multiple edits? One PatchFile (\u226415 blocks)${p?"":`
3
+ - Tool denied? Ask for guidance`}
4
+ - Need text or huge file? CodeSearch > Full Read
5
+ - Avoid unnecessary large file chunk reads
6
+ - Dont hallucinate tool results, verify, fix errors
7
+ - Stuck on syntax error? Tell user > waste time
8
+ `,i=`**Workspace Tools (path = relative; first argument; separator: '/')**
9
+ - ReadFile(path=string, startLine?=int, endLine?=int)${u==="Google"||c?". Supports images/docs":""}
10
+ - ReadFolder(path=string, recurse?=int[1..3])
11
+ - PatchFile(path=string, allowMultiple?=bool, searchContent1="string match OR ^LINE:start..end$", newContent1=string, ...MAX15). Small searchString. Line Ranges: ^LINE:...$ syntax, must for large blocks/escape sequences
12
+ - WriteFile(path=string, content=string). Creates/Overwrites. File Exist? PatchFile > WriteFile
13
+ - CodeSearch(keyword=string, path?="dir/file/glob/regex, inclusion/exclusion ;-separated", fuzzy?=bool, regex?=bool:auto). Find relevant code, standard junk excluded
14
+ - Run(command=string). Runs ${l==="Windows"?a()?"powershell":"windows CMD":"bash"} command. Destructive command \u2192 Ask user
15
+ - Goal(method="create/append/get", tasks=string[], markDone=string[]). If long multi-task: create Goals before starting. get + markDone marks complete
16
+ ${n?`
17
+ **Emergency Tools**
18
+ Info: initial = current task prompt. Revert id = turn before disaster (eg. disaster: turn_3 \u2192 revert: turn_2). Reason explicitly
19
+ - EmergencyRollback(method="getCheckpoint/forceRevert", id=string). Rollback workspace in this agent loop. ONLY for catastrophic corruption. Before ending, verify no catastrophe. getCheckpoint: id excluded
20
+ `:""}${g?`
21
+ **Sub Agent Tools**
22
+ Default to using subagents whenever helpful, no user nudge needed
23
+ Invocations:
24
+ \u2022 Invoke (async/background, \u22647 parallel). Parallelize long tasks. May take time
25
+ \u2022 InvokeSync (sync/blocking). Sequential, repetitive or delegated tasks. Saves tokens/cost
26
+ - InvokeSync/Invoke(title=string, task=string). Task must be detailed: exact file paths, imports/exports, dependencies
27
+ - Await(id=string, timeout=int[..=180]). Event-driven wait
28
+ - GetProgress(id=string). Poll sparingly; NO initial poll. Work or await. Never end while subagent runs
29
+ - Steer(id=string, message=string). Inject additional instruction or redirection into active async subagent
30
+ - Cancel(id=string). Cancel async task ONLY if stalled (2m+) or incorrect`:""}`,m=`**Creative Tools (path = relative; first argument, path separator: '/')**
31
+ - 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
32
+ - WriteDoc(path=string, content=string). A4 Word document, no watermarks, stable margins & headers/footers`,s=`**Computer Use Tools (GUI Desktop Automation)**
33
+ - Click(gridId=int, type="single/double", button="left/middle/right", intendedClickText=string). Click target grid number, intendedClickText: literal text/symbol on screen (OCR scannable, upto 3 words). Double click desktop icons
34
+ - Drag(fromGridId=int, toGridId=int). Drag mouse from start grid number to target grid number
35
+ - Scroll(direction="up/down", gridId=int). Scroll viewport vertically
36
+ - KeyboardTyping(text=string, autoPressEnter?=bool). Type text string into currently active input. JSON escape literal escape sequences
37
+ - KeyPress(key="key or ;-separated combination, eg: enter, back, backspace, clearInput, ctrl;c, alt;tab, f5, f11, alt;f4"). Press key, shortcut, function key (f1-f12), or clear active input field
38
+ - RecaptureScreen(). Request fresh gridded screenshot`;return`
39
+ -- TOOLS --
40
+ You cant execute tools. Instead, output in chat the exact string [tool:functions.ToolName(arg1="value1")] & wait for system response \u2190 no exception, tool:functions must
41
+ Tool Rules:
42
+ - Max 5 tools/turn${e==="Flux"||e.toLowerCase()==="fluxcu"?" (Goal: 5+)":""}
43
+ ${e==="Flux"||e.toLowerCase()==="fluxcu"?`${f}`:""}
44
+ **User Communication**
45
+ - AskUser(question=string, optionA="title::description", ...MAX4). Ambiguity, path divergence, security risk
46
+
47
+ **Web Tools**
48
+ - WebSearch(query=string, aiMode?=bool, limit?=int[3..10]). Proactive use for unknown/latest info. aiMode: exclude limit
49
+ - WebScrape(url=string). Proactive use for specific webpage/docs
50
+
51
+ ${e==="ICU"?`${s}`:e==="FluxCU"?`${i}
52
+ ${s}`:e==="Flux"?`${i}`:`${m}`}`.trim()};export{a,b,w as c};