fluxflow-cli 5.4.1 → 5.5.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/README.md +1 -1
- package/dist/chunks/{ai-TVKJMVCH.js → ai-6AZZQUJJ.js} +1 -1
- package/dist/chunks/answerSubagent-LFLPQQSS.js +1 -0
- package/dist/chunks/{app-HBLCJLMN.js → app-SKIGDYWL.js} +14 -14
- package/dist/chunks/ask_user-4KTNP4MZ.js +1 -0
- package/dist/chunks/{auto_completion-SGFPH6MP.js → auto_completion-ZYVGXNQC.js} +1 -1
- package/dist/chunks/{awaitSubagent-JKQ2EHVY.js → awaitSubagent-ZXLUWTW7.js} +1 -1
- package/dist/chunks/cancel-C2BQ3FGV.js +1 -0
- package/dist/chunks/chat-34HLGFEJ.js +1 -0
- package/dist/chunks/{chunk-BNKY5QOA.js → chunk-5KBOEKGE.js} +6 -6
- package/dist/chunks/chunk-H2EXH5PL.js +898 -0
- package/dist/chunks/chunk-JWNCKRN6.js +4 -0
- package/dist/chunks/{chunk-4PTLFXTU.js → chunk-O74INBF3.js} +3 -3
- package/dist/chunks/{chunk-RINQH4H4.js → chunk-YI3O7C3D.js} +6 -6
- package/dist/chunks/{click-WWAFZ4BZ.js → click-M5D2RARW.js} +2 -2
- package/dist/chunks/computer_action-N7WIG3L4.js +1 -0
- package/dist/chunks/drag-K5ITERVW.js +1 -0
- package/dist/chunks/{emergency_rollback-J3SMQXBP.js → emergency_rollback-X55BPJ7Q.js} +1 -1
- package/dist/chunks/{exec_command-SQB5LU5X.js → exec_command-QBBSYF2H.js} +1 -1
- package/dist/chunks/{file_map-U6SWDUPK.js → file_map-3YMVODEE.js} +8 -8
- package/dist/chunks/find_file-RBJ4LKPD.js +4 -0
- package/dist/chunks/generate_image-53KQ3EDL.js +1 -0
- package/dist/chunks/{getProgress-J34K43Y7.js → getProgress-4D67AF3H.js} +2 -2
- package/dist/chunks/invoke-GUW4734N.js +6 -0
- package/dist/chunks/invokeSync-2PXPUJSJ.js +7 -0
- package/dist/chunks/key_press-RQ32VDHR.js +1 -0
- package/dist/chunks/keyboard_typing-BH4JHUQO.js +1 -0
- package/dist/chunks/{read_folder-UWFC5DNX.js → read_folder-OJ7UWWOR.js} +1 -1
- package/dist/chunks/recapture_screen-YJNK64KL.js +1 -0
- package/dist/chunks/scroll-IQUZ3QLU.js +1 -0
- package/dist/chunks/search_keyword-2JQ75HEQ.js +9 -0
- package/dist/chunks/steerSubagent-UNAOFQZJ.js +1 -0
- package/dist/chunks/{todo-ZFQ6BQVI.js → todo-OX7SMIKN.js} +2 -2
- package/dist/chunks/update_file-2EZILIMQ.js +15 -0
- package/dist/chunks/view_file-XYWGDYAY.js +1 -0
- package/dist/chunks/wait-RQSCCCXW.js +1 -0
- package/dist/chunks/{web_search-MOI3CNWS.js → web_search-B2XM4T5D.js} +11 -11
- package/dist/chunks/write_docx-BMIF6ZDY.js +13 -0
- package/dist/chunks/{write_file-MNAF43T6.js → write_file-O3LLIRLR.js} +1 -1
- package/dist/chunks/write_pdf-CTBFENCU.js +31 -0
- package/dist/cli.js +4 -4
- package/dist/package.json +2 -2
- package/package.json +2 -2
- package/dist/chunks/answerSubagent-BPNNJXPC.js +0 -1
- package/dist/chunks/ask_user-K2DLZF6H.js +0 -1
- package/dist/chunks/cancel-F3ZOEBKW.js +0 -1
- package/dist/chunks/chat-V5FZDYET.js +0 -1
- package/dist/chunks/chunk-AUXKQKSZ.js +0 -888
- package/dist/chunks/chunk-Y5JU726N.js +0 -4
- package/dist/chunks/computer_action-B6QH77NT.js +0 -1
- package/dist/chunks/drag-3VRYDGVU.js +0 -1
- package/dist/chunks/find_file-GBEBP5NZ.js +0 -4
- package/dist/chunks/generate_image-2JIYAW5L.js +0 -1
- package/dist/chunks/invoke-JSHBXNXZ.js +0 -6
- package/dist/chunks/invokeSync-NP7Z3LUE.js +0 -3
- package/dist/chunks/key_press-J2ZSWOT2.js +0 -1
- package/dist/chunks/keyboard_typing-FFC7OTDM.js +0 -1
- package/dist/chunks/recapture_screen-P7YVVVSF.js +0 -1
- package/dist/chunks/scroll-GBV6YRQT.js +0 -1
- package/dist/chunks/search_keyword-KE5VBMVA.js +0 -9
- package/dist/chunks/steerSubagent-UETXH2CB.js +0 -1
- package/dist/chunks/update_file-C5HRYCQN.js +0 -15
- package/dist/chunks/view_file-PEZ7HS36.js +0 -1
- package/dist/chunks/wait-TJR6LAR4.js +0 -1
- package/dist/chunks/write_docx-A3GAUZEW.js +0 -13
- package/dist/chunks/write_pdf-YQ3JTZ5U.js +0 -31
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var I=(e,C=[])=>{let y={};if(!e)return y;let A=b=>!Array.isArray(C)||C.length===0?!0:C.some(n=>n instanceof RegExp?n.test(b):typeof n=="string"?n.endsWith("*")?b.startsWith(n.slice(0,-1)):n===b:!1),t=0;for(;t<e.length;){for(;t<e.length&&/[\s,]/.test(e[t]);)t++;if(t>=e.length)break;let b=e.substring(t).match(/^(\w+)\s*=\s*/);if(!b||!A(b[1])){t++;continue}let n=b[1];t+=b[0].length;let s="";if(t<e.length&&(e[t]==='"'||e[t]==="'"||e[t]==="`")){let c=e[t];t++;let i=t,o=-1,r=t;for(;r<e.length;){let l=e.indexOf(c,r);if(l===-1)break;let h=0;for(let a=l-1;a>=0&&e[a]==="\\";a--)h++;if(h%2!==0){r=l+1;continue}let w=e.substring(l+1),x=w.trim(),m=!1,W=x.match(/^,\s*(\w+)\s*=/);if(W){let a=W[1];if(!A(a))m=!1;else if(y[a]!==void 0)m=!1;else{let q=x.substring(W[0].length);if(q.search(new RegExp(`,\\s*${a}\\s*=`,"i"))!==-1)m=!1;else{let f=q.trim();if(f.startsWith('"')||f.startsWith("'")||f.startsWith("`")){let p=f[0],k=!1;for(let d=1;d<f.length;d++)if(f[d]===p){let D=0;for(let L=d-1;L>=0&&f[L]==="\\";L--)D++;if(D%2===0){k=!0;break}}m=k}else if(f.startsWith("[")){let p=0,k=!1;for(let d=0;d<f.length;d++)if(f[d]==="[")p++;else if(f[d]==="]"&&(p--,p===0)){k=!0;break}m=k}else{let p=f.split(/[,\)\s]/)[0]||"";m=!/["'`]/.test(p)}}}}let R=x===""||m||x.startsWith(")")&&(x.length===1||/^\)\s*([,\]\s]|\[\[?tool:)/i.test(x));if(R&&w.startsWith(`
|
|
2
|
+
`)){let a=x.split(`
|
|
3
|
+
`)[0];if(!a.includes("=")&&!a.includes(")")){r=l+1;continue}}if(R){o=l;break}r=l+1}o!==-1?(s=e.substring(i,o),t=o+1):(s=e.substring(i),t=e.length);let u=n.toLowerCase().includes("path")||["dest","source","to","from"].includes(n.toLowerCase());s=s.replace(/\\(.)/g,(l,h)=>{switch(h){case"n":return`
|
|
4
|
+
`;case"r":return"\r";case"t":return" ";case"\\":return"\\";default:return h===c?c:h}})}else if(t<e.length&&e[t]==="["){let c=0,i=null,o=t,r=-1;for(let u=t;u<e.length;u++){let l=e[u];if(i&&l===i){let h=0;for(let w=u-1;w>=0&&e[w]==="\\";w--)h++;h%2===0&&(i=null)}else!i&&(l==='"'||l==="'"||l==="`")&&(i=l);if(!i&&(l==="["?c++:l==="]"&&c--,c===0)){r=u;break}}if(r!==-1){s=e.substring(o,r+1),t=r+1;try{let u=s.trim();u.startsWith("'")||u.includes("'")}catch{}}else s=e.substring(o),t=e.length}else{let c=e.substring(t),i=c.match(/,\s*\w+\s*=|(?:\s*\)\s*(?:$|\]\]))/);if(i){let o=i.index;s=c.substring(0,o).trim(),t+=o}else s=c.trim(),t=e.length}s==="true"?s=!0:s==="false"?s=!1:typeof s=="string"&&!isNaN(s)&&s.trim()!==""&&(s=Number(s)),typeof s=="string"&&(n.toLowerCase().includes("path")||["dest","source","to","from"].includes(n.toLowerCase()))&&(s=s.replace(/\x0C/g,"\\f").replace(/\x0D/g,"\\r").replace(/\x0B/g,"\\v").replace(/\x08/g,"\\b")),y[n]=s}return y};export{I as a};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{a as W}from"./chunk-
|
|
1
|
+
import{a as W}from"./chunk-JWNCKRN6.js";import{a as P,z as I}from"./chunk-NPXJIGAI.js";import s from"fs";import g from"path";var G=i=>{if(!i)return null;let o=i.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!o)return null;let e=o[1];if((o[2]||"").trim().length===0)return null;let r="",l=e.match(/^name:\s*(.+)$/m);return l&&(r=l[1].trim().replace(/^["']|["']$/g,"")),r?{name:r}:null},H=i=>{let o=[];if(!i||!s.existsSync(i))return o;let e=(m,r=0)=>{if(!(r>5))try{let l=s.readdirSync(m,{withFileTypes:!0});for(let n of l){let a=g.join(m,n.name),c=n.name.toLowerCase();n.isFile()?c==="skill.md"&&o.push(a):n.isDirectory()&&(r===0?(c==="skills"||c===".skills"||c==="skill"||c===".skill")&&e(a,r+1):e(a,r+1))}}catch{}};return e(i,0),o},J=i=>i.replace(/^\s*---\r?\n[\s\S]*?\r?\n---\s*(\r?\n)?/,""),U=(i,o)=>{if(!o)return null;let e=g.join(i,o);if(s.existsSync(e))try{if(s.statSync(e).isFile())return e}catch{}if(!o.toLowerCase().endsWith(".md")){let n=g.join(i,`${o}.md`);if(s.existsSync(n))try{if(s.statSync(n).isFile())return n}catch{}}let m=o.replace(/\\/g,"/").split("/").filter(Boolean),r=i,l=!0;for(let n=0;n<m.length;n++){let a=m[n].toLowerCase(),c=n===m.length-1;try{if(!s.existsSync(r)||!s.statSync(r).isDirectory()){l=!1;break}let w=s.readdirSync(r).find(C=>{let R=C.toLowerCase();return!!(R===a||c&&!a.endsWith(".md")&&R===`${a}.md`)});if(!w){l=!1;break}let $=g.join(r,w);if(c){if(s.statSync($).isFile())return $;l=!1}else r=$}catch{l=!1;break}}if(m.length===1){let n=m[0],a=["references","reference","scripts","script","examples","example","resources","resource"];for(let c of a){let y=g.join(i,c);if(s.existsSync(y)){let w=U(y,n);if(w)return w}}}return null},ee=async(i,o={})=>{let{path:e,StartLine:m,EndLine:r,start_line:l,end_line:n,startLine:a,endLine:c}=W(i,["path","StartLine","EndLine","start_line","end_line","startLine","endLine"]),y=parseInt(m||l||a),w=parseInt(r||n||c),$=!isNaN(y),C=!isNaN(w),R=y||1,O=w||(y?y+800:800);if(!e)return'ERROR: Missing "path" argument for ReadFile.';let{resolvedPath:_,isTildeResolved:B}=I(e);if(e=_,e.trim().toLowerCase().startsWith("#skill")){let f=e.trim().replace(/\\/g,"/").replace(/^#skills?\/?/i,"").split("/").filter(Boolean),E=null,u="",d="";if(f[0]?.toLowerCase()==="global"||f[0]?.toLowerCase()==="project"?(E=f[0].toLowerCase(),u=f[1],d=f.slice(2).join("/")):(u=f[0],d=f.slice(1).join("/")),!u)return`ERROR: Missing skill name in path [${e}].`;let k=t=>{let h=H(t);for(let p of h)try{let F=s.readFileSync(p,"utf8"),x=G(F),M=g.basename(g.dirname(p)).toLowerCase();if(x?.name&&x.name.toLowerCase()===u.toLowerCase()||M===u.toLowerCase()||p.toLowerCase()===g.join(t,"skill.md").toLowerCase()&&u.toLowerCase()==="skill")return p}catch{}return null},L=null,b=!1;if(E){let t=E==="global"?P:process.cwd();L=k(t)}else{let t=k(process.cwd()),h=k(P);t&&h&&(b=!0),L=t||h}if(!L)return`No '${u}' exist in given scope.`;let j=g.dirname(L),v=L,N=!0;if(d){let t=U(j,d);if(!t)return`No such file or reference '${d}' exist for skill '${u}'. It could be standard file path?`;v=t,N=!1}try{let t=s.readFileSync(v,"utf8");t.startsWith("\uFEFF")&&(t=t.slice(1)),t=t.replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
3
|
`),N&&(t=J(t));let h=t.split(`
|
|
4
|
-
`),p=h.length,
|
|
4
|
+
`),p=h.length,F=$?Math.max(0,R-1):0,x=C?Math.min(p,O):p,M=h.slice(F,x),T=e.replace(/\\/g,"/").toLowerCase(),z=T.includes("#skill/global/fluxflow")||T.includes("#skills/global/fluxflow"),A=b?` (Found ${e} in both global & project scope. Loaded [project] as default fallback. Use '#skills/global/...' if needed global)`:"",X=`${z?"DOCs":"Skill"}: [${e.replace(/\\/g,"/")}]${A}`,Y=M.map(q=>q.trimEnd()).join(`
|
|
5
5
|
`);return`${X}
|
|
6
6
|
|
|
7
7
|
${Y}`}catch(t){let h=t instanceof Error?t.message:String(t);return`ERROR: Failed to read skill file [${e}]: ${h}`}}try{let S=g.resolve(process.cwd(),e);if(!s.existsSync(S))return`ERROR: File [${e}] does not exist.`;if(s.statSync(S).isDirectory())return`ERROR: Path [${e}] is a directory. Use ReadFolder instead.`;let f=g.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 u={".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(u[f]){if(!(o.isMultiModal!==!1))return`ERROR: Multimodality is not supported for the current model. Unable to load [${e}].`;let x=s.readFileSync(S).toString("base64"),M=u[f];return{text:`[BINARY FILE]: ${e} (${M}) - Loaded as multimodal part.`,binaryPart:{inlineData:{data:x,mimeType:M}}}}let d=s.readFileSync(S,"utf8");d.startsWith("\uFEFF")&&(d=d.slice(1)),d=d.replace(/\r\n/g,`
|
|
8
8
|
`).replace(/\r/g,`
|
|
9
9
|
`);let k=d.split(`
|
|
10
|
-
`),
|
|
10
|
+
`),L=k.length;!$&&!C&&L>800&&(R=1,O=50);let b=Math.max(0,R-1),j=Math.min(L,O),v=k.slice(b,j),N=`File: [${e}] (Showing lines ${b+1}-${j} of ${L}).`,t=v.map((p,F)=>`${String(b+F+1).padStart(4)}: ${p.trimEnd()}`).join(`
|
|
11
11
|
`);return`${N}
|
|
12
12
|
|
|
13
13
|
${t}${B?`
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{a as E,d as $,e as D}from"./chunk-
|
|
1
|
+
import{a as E,d as $,e as D}from"./chunk-5KBOEKGE.js";import{a as j}from"./chunk-JWNCKRN6.js";import{spawn as S}from"child_process";var v=null;try{let u=await import("node-pty");v=u.default||u}catch{}var M=!!v,y=u=>typeof u!="string"?u:u.replace(/(?:\u001b][\s\S]*?(?:\u0007|\u001b\\))|(?:[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><])/g,""),L=u=>{if(!u)return"";let p=[[]],t=0,o=0,m=/\x1b\[([0-9;]*?)([a-zA-Z])/g,g=0,d,h=x=>{for(let e=0;e<x.length;e++){let s=x[e];if(s===`
|
|
2
2
|
`)for(t++,o=0;t>=p.length;)p.push([]);else if(s==="\r")o=0;else{for(;t>=p.length;)p.push([]);let n=p[t];for(;o>n.length;)n.push(" ");n[o]=s,o++}}};for(;(d=m.exec(u))!==null;){h(u.substring(g,d.index));let x=d[1],e=d[2],s=x?x.split(";").map(Number):[];if(e==="A"){let n=s[0]||1;t=Math.max(0,t-n)}else if(e==="B"){let n=s[0]||1;for(t=t+n;t>=p.length;)p.push([])}else if(e==="C"){let n=s[0]||1;o=o+n}else if(e==="D"){let n=s[0]||1;o=Math.max(0,o-n)}else if(e==="G"){let n=(s[0]||1)-1;o=Math.max(0,n)}else if(e==="H"||e==="f"){let n=(s[0]||1)-1,l=(s[1]||1)-1;for(t=Math.max(0,n),o=Math.max(0,l);t>=p.length;)p.push([])}else if(e==="K"){let n=s[0]||0;if(t<p.length){let l=p[t];if(n===0)l.length=o;else if(n===1)for(let c=0;c<o&&c<l.length;c++)l[c]=" ";else n===2&&(l.length=0)}}else if(e==="J"){let n=s[0]||0;(n===2||n===3)&&(p.length=0,p.push([]),t=0,o=0)}g=m.lastIndex}h(u.substring(g));let w=p.map(x=>x.join(""));for(;w.length>0&&w[w.length-1]==="";)w.pop();return w.join(`
|
|
3
|
-
`)},b=null,
|
|
3
|
+
`)},b=null,k=!1,F=u=>{try{b&&(k&&typeof b.write=="function"?b.write(u):b.stdin&&b.stdin.writable&&b.stdin.write(u))}catch{}},q=()=>{if(b){try{k&&typeof b.destroy=="function"?b.destroy():typeof b.kill=="function"&&(process.platform==="win32"?S("taskkill",["/pid",b.pid,"/f","/t"]):b.kill("SIGKILL"))}catch{}b=null,k=!1}},A=(u,p=!1)=>{if(process.platform!=="win32"||process.env.ADJUST_WINDOWS_COMMAND!=="true")return u;let t=[],o="",m=null,g=!1;for(let e=0;e<u.length;e++){let s=u[e];if(g){o+=s,g=!1;continue}if(s==="\\"){if(!m&&u[e+1]===" "){o+=" ",e++;continue}o+=s,g=!0;continue}m?(s===m&&(m=null),o+=s):s==='"'||s==="'"?(m=s,o+=s):s===";"&&!o.includes("://")?(o.length>0&&(t.push(o),o=""),t.push(p?";":"&")):s==="&"&&!o.includes("://")?u[e+1]==="&"?(o.length>0&&(t.push(o),o=""),t.push("&&"),e++):o.endsWith("2>")&&u[e+1]==="1"?(t.push("2>&1"),o="",e++):(o.length>0&&(t.push(o),o=""),t.push("&")):s==="|"&&!o.includes("://")?(o.length>0&&(t.push(o),o=""),t.push("|")):(s===">"||s==="<")&&(e===0||/\s|['"]/.test(u[e-1]||""))?(o.length>0&&(t.push(o),o=""),s===">"&&u[e+1]===">"?(t.push(">>"),e++):t.push(s)):/\s/.test(s)?o.length>0&&(t.push(o),o=""):o+=s}o.length>0&&t.push(o);let d=e=>!(!e.includes("/")||/^(https?|file|ftp):\/\//i.test(e)||e.startsWith("@")||e.startsWith("/")&&(e.match(/\//g)||[]).length===1||/\s\/|\/\s/.test(e)||/[\(\)\{\}\;\<\>\=\'\"]/.test(e)),h=[];for(let e=0;e<t.length;e++){let s=t[e];if(s==="mkdir"&&p&&$()){let n=[],l=e+1;for(;l<t.length;){let c=t[l];if([">",">>","<","&","&&","|","||",";"].includes(c))break;c!=="-p"&&c!=="--parents"&&c!=="-v"&&c!=="--verbose"&&n.push(c),l++}if(n.length>0){let c=n.map(a=>{let i=a.replace(/^['"]|['"]$/g,""),r=a;return d(i)&&(r=a.replace(/\//g,"\\")),r});h.push("New-Item","-ItemType","Directory","-Force","-Path",c.join(","))}else h.push("New-Item","-ItemType","Directory","-Force");e=l-1;continue}if(s==="rm"&&p&&$()){let n=[],l=!1,c=!1,a=e+1;for(;a<t.length;){let r=t[a];if([">",">>","<","&","&&","|","||",";"].includes(r))break;r==="-rf"||r==="-fr"?(l=!0,c=!0):r==="-r"||r==="-R"||r==="--recursive"?l=!0:r==="-f"||r==="--force"?c=!0:n.push(r),a++}let i=["Remove-Item"];if(l&&i.push("-Recurse"),c&&i.push("-Force"),n.length>0){let r=n.map(f=>{let P=f.replace(/^['"]|['"]$/g,""),O=f;return d(P)&&(O=f.replace(/\//g,"\\")),O});i.push("-Path",r.join(","))}h.push(...i),e=a-1;continue}if(s==="cp"&&p&&$()){let n=[],l=!1,c=!1,a=e+1;for(;a<t.length;){let r=t[a];if([">",">>","<","&","&&","|","||",";"].includes(r))break;r==="-r"||r==="-R"||r==="--recursive"?l=!0:r==="-f"||r==="--force"?c=!0:n.push(r),a++}let i=["Copy-Item"];if(l&&i.push("-Recurse"),c&&i.push("-Force"),n.length>0){let r=n.map(f=>{let P=f.replace(/^['"]|['"]$/g,""),O=f;return d(P)&&(O=f.replace(/\//g,"\\")),O});if(r.length>1){let f=r.pop();i.push("-Path",r.join(","),"-Destination",f)}else i.push("-Path",r[0])}h.push(...i),e=a-1;continue}if(s==="touch"&&p&&$()){let n=[],l=e+1;for(;l<t.length;){let c=t[l];if([">",">>","<","&","&&","|","||",";"].includes(c))break;n.push(c),l++}if(n.length>0){let a=`(${n.map(i=>{let r=i.replace(/^['"]|['"]$/g,""),f=i;return d(r)&&(f=i.replace(/\//g,"\\")),f}).join(", ")}) | ForEach-Object { if (Test-Path $_) { (Get-Item $_).LastWriteTime = [System.DateTime]::Now } else { $null | Out-File -FilePath $_ } }`;h.push(a)}e=l-1;continue}if(s==="|"&&t[e+1]==="tee"){t[e+2]==="-a"?(h.push(">>"),e+=2):(h.push(">"),e+=1);continue}if(s==="|"&&t[e+1]==="cat"&&t[e+2]===">"){h.push(">"),e+=2;continue}if(s==="|"){let n=t[e+1];if(n){let l=n.replace(/^['"]|['"]$/g,""),c=/\.(txt|md|json|log|csv|html|css|py|js|xml|yaml|yml|pdf|docx|pptx|xlsx)$/i.test(l);if(d(l)&&c){h.push(">");continue}}}h.push(s)}let w=!1,x=h.map(e=>{if(e==="echo")return w=!0,e;[">",">>","<","&","&&","|","||",";"].includes(e)&&(w=!1);let n=/^['"]|['"]$/.test(e),l=e;w&&n&&(l=e.replace(/^['"]|['"]$/g,""));let c=/^['"]|['"]$/.test(l),a=l.replace(/^['"]|['"]$/g,"");d(a)&&(l=l.replace(/\//g,"\\"));let i=l.replace(/^['"]|['"]$/g,"");return i.includes(" ")&&!c&&(l=`"${i}"`),l});if(p){let e="",s=0;for(let n=0;n<x.length;n++){let l=x[n];l==="&&"?(e+="; if ($?) {",s++):l===";"?(e+=" }".repeat(s)+";",s=0):(e&&!e.endsWith(" ")&&!e.endsWith("{")&&(e+=" "),e+=l)}return e+=" }".repeat(s),e}return x.join(" ")},B=async(u,p={})=>{let t=j(u,["command","usePowershell","forcePowershell","useCwd","useCmd","forceCwd","forceCmd"]),o=t.command,{onChunk:m}=p;if(!o)return'ERROR: Missing "command" argument for Run.';let g=t.usePowershell===!0||t.usePowershell==="true"||t.usePowershell===1||t.forcePowershell===!0||t.forcePowershell==="true"||t.forcePowershell===1||t.useCwd===!0||t.useCwd==="true"||t.useCwd===1||t.useCmd===!0||t.useCmd==="true"||t.useCmd===1||t.forceCwd===!0||t.forceCwd==="true"||t.forceCwd===1||t.forceCmd===!0||t.forceCmd==="true"||t.forceCmd===1,d=process.platform==="win32",h=p.systemSettings||{},w={};return h.networkAccess===!1&&(w.HTTP_PROXY="http://127.0.0.1:9999",w.HTTPS_PROXY="http://127.0.0.1:9999",w.ALL_PROXY="socks5://127.0.0.1:9999",w.http_proxy="http://127.0.0.1:9999",w.https_proxy="http://127.0.0.1:9999",w.all_proxy="socks5://127.0.0.1:9999",w.NO_PROXY="localhost,127.0.0.1"),new Promise(x=>{let e=s=>{let n=s==="pwsh"||s==="powershell",l=s==="bash",c=l?o:A(o,n),a;d?s==="bash"?a=E()||"bash.exe":s==="pwsh"?a="pwsh.exe":s==="powershell"?a="powershell.exe":a="cmd.exe":a=process.env.SHELL||"bash";let i=d?l?["-c",c]:n?["-NoProfile","-Command",c]:["/c",c]:["-c",c];if(h.networkAccess===!1&&!d){let r=a,f=[...i];if(process.platform==="linux")a="unshare",i=["-n","-r",r,...f];else if(process.platform==="darwin"){let P=`(version 1)
|
|
4
4
|
(allow default)
|
|
5
5
|
(deny network-outbound)
|
|
6
6
|
(allow network-outbound (remote ip "localhost:*"))
|
|
7
7
|
(allow network-outbound (remote ip "127.0.0.1:*"))
|
|
8
|
-
`;a="sandbox-exec",i=["-p",P,r,...f]}}if(v)try{let r=v.spawn(a,i,{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",...w}});b=r,
|
|
8
|
+
`;a="sandbox-exec",i=["-p",P,r,...f]}}if(v)try{let r=v.spawn(a,i,{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",...w}});b=r,k=!0;let f="",P=!1;return r.onData(O=>{if(!P){f+=O,m&&m(O);let R=y(f);/(?: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(R)&&(P=!0,setTimeout(()=>x(`Dev server started successfully in background.
|
|
9
9
|
|
|
10
10
|
${R}`),500))}}),r.onExit(({exitCode:O})=>{if(P)return;b=null;let R=L(f||""),N=y(R).replace(/\n{3,}/g,`
|
|
11
11
|
|
|
@@ -13,12 +13,12 @@ ${R}`),500))}}),r.onExit(({exitCode:O})=>{if(P)return;b=null;let R=L(f||""),N=y(
|
|
|
13
13
|
|
|
14
14
|
${N}`:`Command [${o}] completed.
|
|
15
15
|
|
|
16
|
-
${N}`)}),!0}catch(r){return d&&(s==="bash"||s==="pwsh"||s==="powershell")&&r.code==="ENOENT"?!1:(
|
|
16
|
+
${N}`)}),!0}catch(r){return d&&(s==="bash"||s==="pwsh"||s==="powershell")&&r.code==="ENOENT"?!1:(C(x,c,o,w,m,s,h),!0)}else return C(x,c,o,w,m,s,h),!0};if(d){let s=!g&&h.preferBash!==!1,n=D(s);e(n)||(n==="bash"?e("pwsh")||e("powershell")||e("cmd"):n==="pwsh"?e("powershell")||e("cmd"):n==="powershell"&&e("cmd"))}else e("bash")})},C=(u,p,t,o,m,g="powershell",d={})=>{let h=process.platform==="win32",w=g==="pwsh"||g==="powershell",x=g==="bash",e;h?g==="bash"?e=E()||"bash.exe":g==="pwsh"?e="pwsh.exe":g==="powershell"?e="powershell.exe":e="cmd.exe":e=process.env.SHELL||"bash";let s=h?x?["-c",p]:w?["-NoProfile","-Command",p]:["/c",p]:["-c",p];if(d.networkAccess===!1&&!h){let i=e,r=[...s];if(process.platform==="linux")e="unshare",s=["-n","-r",i,...r];else if(process.platform==="darwin"){let f=`(version 1)
|
|
17
17
|
(allow default)
|
|
18
18
|
(deny network-outbound)
|
|
19
19
|
(allow network-outbound (remote ip "localhost:*"))
|
|
20
20
|
(allow network-outbound (remote ip "127.0.0.1:*"))
|
|
21
|
-
`;e="sandbox-exec",s=["-p",f,i,...r]}}let n=h?S(e,s,{cwd:process.cwd(),env:{...process.env,...o}}):S(e,s,{cwd:process.cwd(),env:{...process.env,CI:"false",TERM:"xterm-256color",FORCE_COLOR:"1",...o}});b=n,
|
|
21
|
+
`;e="sandbox-exec",s=["-p",f,i,...r]}}let n=h?S(e,s,{cwd:process.cwd(),env:{...process.env,...o}}):S(e,s,{cwd:process.cwd(),env:{...process.env,CI:"false",TERM:"xterm-256color",FORCE_COLOR:"1",...o}});b=n,k=!1,n.stdin&&n.stdin.on("error",()=>{b=null});let l="",c="",a=!1;n.stdout.on("data",i=>{if(!a){let r=i.toString();l+=r,m&&m(r);let f=y(l);/(?: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(f)&&(a=!0,setTimeout(()=>u(`Dev server started successfully in background.
|
|
22
22
|
|
|
23
23
|
${f}`),500))}}),n.stderr.on("data",i=>{if(!a){let r=i.toString();c+=r,m&&m(r)}}),n.on("close",i=>{if(a)return;b=null;let r=[],f=L(l),P=L(c);f&&r.push(`STDOUT:
|
|
24
24
|
${f}`),P&&r.push(`STDERR:
|
|
@@ -30,4 +30,4 @@ ${P}`),i!==0&&r.push(`EXIT CODE: ${i}`);let O=r.join(`
|
|
|
30
30
|
|
|
31
31
|
${R}`:`Command [${t}] completed.
|
|
32
32
|
|
|
33
|
-
${R}`)}),n.on("error",i=>{if(h&&i.code==="ENOENT"){if(g==="bash"){let f=A(t,!0);return
|
|
33
|
+
${R}`)}),n.on("error",i=>{if(h&&i.code==="ENOENT"){if(g==="bash"){let f=A(t,!0);return C(u,f,t,o,m,"pwsh",d)}else if(g==="pwsh"){let f=A(t,!0);return C(u,f,t,o,m,"powershell",d)}else if(g==="powershell"){let f=A(t,!1);return C(u,f,t,o,m,"cmd",d)}}b=null;let r=i instanceof Error?i.message:String(i);u(`ERROR: Failed to start command [${t}]: ${r}`)})};export{M as a,y as b,L as c,b as d,k as e,F as f,q as g,A as h,B as i};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as W}from"./chunk-ZPSNXBWW.js";import{g as B,i as S}from"./chunk-3SMC2C3F.js";import{a as P}from"./chunk-
|
|
2
|
-
`)){let i=r.split(" ");if(i.length<12||parseInt(i[0])!==5)continue;let n=i[2],c=i[3],l=i[4],w=parseInt(i[6]),x=parseInt(i[7]),R=parseInt(i[8]),M=parseInt(i[9]),f=parseFloat(i[10]),h=i.slice(11).join(" ").trim();if(!h||f<0)continue;let p={x0:w,y0:x,x1:w+R,y1:x+M},g={text:h,confidence:f,bbox:p};o.push(g);let u=`${n}_${c}_${l}`;e.has(u)||e.set(u,{words:[],bbox:{x0:1/0,y0:1/0,x1:-1/0,y1:-1/0}});let d=e.get(u);d.words.push(g),d.bbox.x0=Math.min(d.bbox.x0,p.x0),d.bbox.y0=Math.min(d.bbox.y0,p.y0),d.bbox.x1=Math.max(d.bbox.x1,p.x1),d.bbox.y1=Math.max(d.bbox.y1,p.y1)}let s=[];for(let r of e.values())r.words.length>0&&s.push({text:r.words.map(i=>i.text).join(" "),bbox:r.bbox,words:r.words});return{words:o,lines:s}}function Z(t){if(!(t.words&&t.words.length>0)){if(t.blocks&&t.blocks.length>0){t.words=[],t.lines=[];for(let o of t.blocks)for(let e of o.paragraphs||[])for(let s of e.lines||[]){s.bbox&&t.lines.push(s);for(let r of s.words||[])r.bbox&&t.words.push(r)}if(t.words.length>0)return}if(t.tsv){let o=Y(t.tsv);t.words=o.words,t.lines=o.lines}}}function L(t,o,e=0,s=0,r=1){Z(t);let i=n=>({x0:Math.round(n.x0/r)+e,y0:Math.round(n.y0/r)+s,x1:Math.round(n.x1/r)+e,y1:Math.round(n.y1/r)+s}),a=[];if(t.lines&&t.lines.length>0)for(let n of t.lines){let c=n.text?n.text.toLowerCase().trim():"";if(!c||!n.bbox||!(c===o||new RegExp(`\\b${K(o)}\\b`,"i").test(c)))continue;let w=n.words||(t.words?t.words.filter(f=>f.bbox&&f.bbox.x0>=n.bbox.x0-5&&f.bbox.x1<=n.bbox.x1+5&&f.bbox.y0>=n.bbox.y0-5&&f.bbox.y1<=n.bbox.y1+5):[]),x=o.split(/\s+/),R=x.map(f=>f.replace(/[^a-z0-9]/g,"")).join(" "),M=!1;if(w.length>0)for(let f=0;f<=w.length-x.length;f++){let h=w.slice(f,f+x.length),p=h.map(g=>(g.text||"").toLowerCase().trim().replace(/[^a-z0-9]/g,"")).join(" ");if(p===R||p.includes(R)){let g={x0:Math.min(...h.map(u=>u.bbox.x0)),y0:Math.min(...h.map(u=>u.bbox.y0)),x1:Math.max(...h.map(u=>u.bbox.x1)),y1:Math.max(...h.map(u=>u.bbox.y1))};a.push(i(g)),M=!0}}M||a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0)for(let n of t.words){let c=n.text?n.text.toLowerCase().trim().replace(/[^a-z0-9]/g,""):"",l=o.replace(/[^a-z0-9]/g,"");c===l&&n.bbox&&a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0){let n=V(o.length);for(let c of t.words){let l=c.text?c.text.toLowerCase().trim():"";l.length>=3&&Math.abs(l.length-o.length)<=n&&Q(l,o,n)<=n&&c.bbox&&a.push(i(c.bbox))}}return a}function N(t,o){let e=null,s=1/0;for(let r of t){let i=Math.round((r.x0+r.x1)/2),a=Math.round((r.y0+r.y1)/2),n=o.x>=r.x0&&o.x<=r.x1&&o.y>=r.y0&&o.y<=r.y1,c=Math.hypot(i-o.x,a-o.y),l=n?0:c;l<s&&(s=l,e={x:i,y:a,dist:c,containsPoint:n,bbox:r})}return e}var
|
|
1
|
+
import{a as W}from"./chunk-ZPSNXBWW.js";import{g as B,i as S}from"./chunk-3SMC2C3F.js";import{a as P}from"./chunk-JWNCKRN6.js";import X from"screenshot-desktop";import O from"sharp";import j from"fs-extra";import G from"path";import"@nut-tree-fork/nut-js";async function U(t,o,e){if(!(!process.env.SHOW_DEBUG_GRID&&!process.env.DEBUG_OCR))try{let s=G.resolve(process.cwd(),"screenshots",t);await j.ensureDir(s),await j.writeFile(G.join(s,o),e)}catch{}}function K(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Q(t,o,e=1/0){if(t===o)return 0;if(t.length===0)return o.length;if(o.length===0)return t.length;if(Math.abs(t.length-o.length)>e)return e+1;let s=Array.from({length:o.length+1},(r,i)=>i);for(let r=1;r<=t.length;r++){let i=[r],a=r;for(let n=1;n<=o.length;n++){let c=t[r-1]===o[n-1]?0:1,l=Math.min(i[n-1]+1,s[n]+1,s[n-1]+c);i.push(l),l<a&&(a=l)}if(s=i,a>e)return e+1}return s[o.length]}function V(t){return t<=4?0:t<=8?1:2}async function H(t,o=3){let e=await O(t).metadata();return O(t).resize(Math.round(e.width*o),Math.round(e.height*o),{kernel:"lanczos3"}).greyscale().normalise().toBuffer()}function Y(t){if(!t)return{words:[],lines:[]};let o=[],e=new Map;for(let r of t.split(`
|
|
2
|
+
`)){let i=r.split(" ");if(i.length<12||parseInt(i[0])!==5)continue;let n=i[2],c=i[3],l=i[4],w=parseInt(i[6]),x=parseInt(i[7]),R=parseInt(i[8]),M=parseInt(i[9]),f=parseFloat(i[10]),h=i.slice(11).join(" ").trim();if(!h||f<0)continue;let p={x0:w,y0:x,x1:w+R,y1:x+M},g={text:h,confidence:f,bbox:p};o.push(g);let u=`${n}_${c}_${l}`;e.has(u)||e.set(u,{words:[],bbox:{x0:1/0,y0:1/0,x1:-1/0,y1:-1/0}});let d=e.get(u);d.words.push(g),d.bbox.x0=Math.min(d.bbox.x0,p.x0),d.bbox.y0=Math.min(d.bbox.y0,p.y0),d.bbox.x1=Math.max(d.bbox.x1,p.x1),d.bbox.y1=Math.max(d.bbox.y1,p.y1)}let s=[];for(let r of e.values())r.words.length>0&&s.push({text:r.words.map(i=>i.text).join(" "),bbox:r.bbox,words:r.words});return{words:o,lines:s}}function Z(t){if(!(t.words&&t.words.length>0)){if(t.blocks&&t.blocks.length>0){t.words=[],t.lines=[];for(let o of t.blocks)for(let e of o.paragraphs||[])for(let s of e.lines||[]){s.bbox&&t.lines.push(s);for(let r of s.words||[])r.bbox&&t.words.push(r)}if(t.words.length>0)return}if(t.tsv){let o=Y(t.tsv);t.words=o.words,t.lines=o.lines}}}function L(t,o,e=0,s=0,r=1){Z(t);let i=n=>({x0:Math.round(n.x0/r)+e,y0:Math.round(n.y0/r)+s,x1:Math.round(n.x1/r)+e,y1:Math.round(n.y1/r)+s}),a=[];if(t.lines&&t.lines.length>0)for(let n of t.lines){let c=n.text?n.text.toLowerCase().trim():"";if(!c||!n.bbox||!(c===o||new RegExp(`\\b${K(o)}\\b`,"i").test(c)))continue;let w=n.words||(t.words?t.words.filter(f=>f.bbox&&f.bbox.x0>=n.bbox.x0-5&&f.bbox.x1<=n.bbox.x1+5&&f.bbox.y0>=n.bbox.y0-5&&f.bbox.y1<=n.bbox.y1+5):[]),x=o.split(/\s+/),R=x.map(f=>f.replace(/[^a-z0-9]/g,"")).join(" "),M=!1;if(w.length>0)for(let f=0;f<=w.length-x.length;f++){let h=w.slice(f,f+x.length),p=h.map(g=>(g.text||"").toLowerCase().trim().replace(/[^a-z0-9]/g,"")).join(" ");if(p===R||p.includes(R)){let g={x0:Math.min(...h.map(u=>u.bbox.x0)),y0:Math.min(...h.map(u=>u.bbox.y0)),x1:Math.max(...h.map(u=>u.bbox.x1)),y1:Math.max(...h.map(u=>u.bbox.y1))};a.push(i(g)),M=!0}}M||a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0)for(let n of t.words){let c=n.text?n.text.toLowerCase().trim().replace(/[^a-z0-9]/g,""):"",l=o.replace(/[^a-z0-9]/g,"");c===l&&n.bbox&&a.push(i(n.bbox))}if(a.length===0&&t.words&&t.words.length>0){let n=V(o.length);for(let c of t.words){let l=c.text?c.text.toLowerCase().trim():"";l.length>=3&&Math.abs(l.length-o.length)<=n&&Q(l,o,n)<=n&&c.bbox&&a.push(i(c.bbox))}}return a}function N(t,o){let e=null,s=1/0;for(let r of t){let i=Math.round((r.x0+r.x1)/2),a=Math.round((r.y0+r.y1)/2),n=o.x>=r.x0&&o.x<=r.x1&&o.y>=r.y0&&o.y<=r.y1,c=Math.hypot(i-o.x,a-o.y),l=n?0:c;l<s&&(s=l,e={x:i,y:a,dist:c,containsPoint:n,bbox:r})}return e}var $=null;async function tt(){return $||($=(async()=>{let{createWorker:t}=await import("tesseract.js"),o=await import("fs-extra"),{CU_CACHE_DIR:e}=await import("./paths-4NQOSFLK.js");return o.ensureDirSync(e),t("eng",1,{cachePath:e,logger:()=>{}})})().catch(t=>{throw $=null,t})),$}var I=null,F=null;async function et(){let{getActiveDisplay:t}=await import("./screen_grid-Z5JHZZKA.js"),o=await t();if(I&&F===o)return I;F=o,I={format:"png"};try{let e=await X.listDisplays();e&&e.length>0&&(I={format:"png",screen:(e[o]||e[0]).id})}catch{}return I}var pt=async(t,o={})=>{let e=P(t,["gridId","grid","coordinate","target","id","type","clickType","button","intendedClickText","text","ocrCorrection","useOCR","words","lines"]),s=e.gridId||e.grid||e.coordinate||e.target||e.id,r=(e.type||e.clickType||"single").toLowerCase(),i=(e.button||"left").toLowerCase(),a=e.intendedClickText||e.text||"",n=e.ocrCorrection!==void 0?e.ocrCorrection===!0||e.ocrCorrection==="true":e.useOCR!==void 0?e.useOCR===!0||e.useOCR==="true":!1;if(!s&&!a)return'ERROR: Missing required "gridId" parameter for Click tool.';let c=s;if(n&&a)try{let x=s?B(s):null,R=await et(),M=await X(R),f=await O(M).metadata(),h=f.width||1920,p=f.height||1080,g=x?{x:Math.round(x.x*(h/1280)),y:Math.round(x.y*(p/720))}:{x:h/2,y:p/2},u=a.toLowerCase().trim(),d=await tt(),C=null,T="",q=x?320:500;if(x){let y=Math.min(Math.round(h/2),h),m=Math.min(Math.round(p/2),p),b=Math.max(0,Math.min(h-y,g.x-Math.floor(y/2))),k=Math.max(0,Math.min(p-m,g.y-Math.floor(m/2))),D=await O(M).extract({left:b,top:k,width:y,height:m}).toBuffer(),z=2,A=await H(D,z),J=u.replace(/[^a-z0-9]/g,"_");await U("cropped",`crop_${Date.now()}_${J}.png`,A),await d.setParameters({tessedit_pageseg_mode:"11"});let{data:v}=await d.recognize(A,{},{tsv:!0,blocks:!0});if(v&&v.text){let E=L(v,u,b,k,z);if(E.length>0){let _=N(E,g);_&&(_.containsPoint||_.dist<=q)&&(C=_,T="centered target crop OCR")}}}if(!C){let y=await H(M,2),m=u.replace(/[^a-z0-9]/g,"_");await U("fullscreen",`full_${Date.now()}_${m}.png`,y),await d.setParameters({tessedit_pageseg_mode:"3"});let{data:b}=await d.recognize(y,{},{tsv:!0,blocks:!0});if(b&&b.text){let k=L(b,u,0,0,2);if(k.length>0){let D=N(k,g);D&&(C=D,T="full-screen OCR")}}}if(C){let y={x:Math.round(C.x*(1280/h)),y:Math.round(C.y*(720/p))},m=await W("click",y,{button:i,clickType:r});if(typeof m=="string"&&m.startsWith("ERROR:"))return m;let b=S(y),k=`${r==="double"?"Double":"Single"} clicked ${i} button`;return s&&b&&String(s)!==String(b)?`${k}. Tried clicking grid ${s}, but OCR corrected to grid ${b} (${T} for "${a}"). If the click landed unintended, try with ocr correction off.`:`${k} on grid ${b||s} (${T} for "${a}").`}}catch{}let l=await W("click",c,{button:i,clickType:r});if(typeof l=="string"&&l.startsWith("ERROR:"))return l;let w=s||(typeof c=="object"?S(c):c);return`${r==="double"?"Double":"Single"} clicked ${i} button on grid ${w}.`};export{pt as click};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i,b as s}from"./chunk-ZPSNXBWW.js";import"./chunk-3SMC2C3F.js";import{a as c}from"./chunk-JWNCKRN6.js";var l=async(a,p={})=>{let t=c(a,["action","type","cmd","target","grid","gridCode","location","input","button","clickType","from","to","direction","amount","autoPressEnter","enter","text","keys"]),r=t.action||t.type||t.cmd,n=t.target||t.grid||t.gridCode||t.location||t.input;if(!r)return'ERROR: Missing required "action" argument for computer_action (e.g. move, click, drag, scroll, type, key_press, key_combination).';let e=r.toLowerCase();if(e.startsWith("mouse_")||["move","click","drag","scroll"].includes(e)){let o=e.replace("mouse_","");return await i(o,n,{button:t.button,clickType:t.clickType||t.type,from:t.from,to:t.to,direction:t.direction,amount:t.amount?parseInt(t.amount,10):void 0})}if(e.startsWith("key_")||e==="type"||e==="press"){let o=e;e==="press"&&(o="key_press");let u=t.autoPressEnter===!0||t.autoPressEnter==="true"||t.enter===!0||t.enter==="true";return await s(o,n||t.text||t.keys,{...t,autoPressEnter:u})}return`ERROR: Unrecognized action "${r}". Supported actions: move, click, drag, scroll, type, key_press, key_combination.`};export{l as computer_action};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-ZPSNXBWW.js";import"./chunk-3SMC2C3F.js";import{a as d}from"./chunk-JWNCKRN6.js";var n=async(i,a={})=>{let r=d(i,["fromGridId","from","start","toGridId","to","end"]),o=r.fromGridId||r.from||r.start,t=r.toGridId||r.to||r.end;return!o||!t?'ERROR: Drag requires both "fromGridId" and "toGridId" parameters.':await e("drag",o,{from:o,to:t})};export{n as drag};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as l}from"./chunk-NJTM7OYZ.js";import{a as f}from"./chunk-
|
|
1
|
+
import{a as l}from"./chunk-NJTM7OYZ.js";import{a as f}from"./chunk-JWNCKRN6.js";import"./chunk-ZGORMZE5.js";import"./chunk-NPXJIGAI.js";var m=async(k,c={})=>{let d=f(k,["method","id"]),s=d.method,n=d.id,i=c.chatId;if(!c.systemSettings?.advanceRollback)return"ERROR: Advance Rollback feature is currently disabled in settings under Security. Tell user to enable it if needed.";if(!i)return"ERROR: No active chat transaction found for rollback.";if(s==="getCheckpoint"){let r=await l.getCheckpoints(i);if(r.length===0)return"No checkpoints available.";let a={write_file:"WriteFile",update_file:"PatchFile",view_file:"ReadFile",read_folder:"ReadFolder",exec_command:"Run",web_search:"WebSearch",web_scrape:"WebScrape",search_keyword:"SearchKeyword",CodeSearch:"SearchKeyword",code_search:"SearchKeyword",write_pdf:"WritePDF",write_docx:"WriteDoc",generate_image:"GenerateImage",file_map:"FileMap",todo:"Todo",goal:"Goal",Goal:"Goal",await:"Await",ask:"AskUser",ask_user:"AskUser",AskUser:"AskUser",askuser:"AskUser",invoke:"Invoke",invokesync:"InvokeSync",getprogress:"GetProgress",cancel:"Cancel",emergency_rollback:"EmergencyRollback",emergencyrollback:"EmergencyRollback"},t=e=>a[e]||a[e.toLowerCase()]||e,o=`Available checkpoints for rollback:
|
|
2
2
|
|
|
3
3
|
`;for(let e of r)if(e.id==="initial")o+=`--- Initial State (id: initial) ---
|
|
4
4
|
Tools Used: User Prompted for task
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i}from"./chunk-YI3O7C3D.js";import"./chunk-5KBOEKGE.js";import"./chunk-JWNCKRN6.js";export{d as activeChildProcess,h as adjustWindowsCommand,c as cleanTerminalOutput,i as exec_command,e as isActiveCommandPty,a as isPtyAvailable,b as stripAnsi,g as terminateActiveCommand,f as writeToActiveCommand};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{a as R}from"./chunk-FMKFTJB3.js";import{a as N}from"./chunk-
|
|
1
|
+
import{a as R}from"./chunk-FMKFTJB3.js";import{a as N}from"./chunk-JWNCKRN6.js";import{t as $}from"./chunk-NPXJIGAI.js";import F from"fs-extra";import d from"path";import{createRequire as I}from"module";var E=I(import.meta.url),P=E("web-tree-sitter"),S=!1,b=new Set(["class_declaration","function_declaration","method_definition","arrow_function","function_expression","if_statement","else_clause","for_statement","for_in_statement","for_of_statement","while_statement","do_statement","switch_statement","try_statement","catch_clause","variable_declarator","export_statement","lexical_declaration","variable_declaration","interface_declaration","type_alias_declaration","enum_declaration","import_declaration","jsx_element","jsx_self_closing_element","class_definition","function_definition","decorated_definition","import_from_statement","import_statement","preproc_include","method_declaration","constructor_declaration","assignment_expression","pair","class_specifier","struct_specifier","enum_specifier","field_declaration","element","script_element","style_element"]),O=new Set(["export_statement","lexical_declaration","variable_declaration","variable_declarator","pair","assignment_expression"]);function o(n,t=50){if(!n)return"";let r=n.replace(/\s+/g," ").trim();return r.length>t?r.substring(0,t-3)+"...":r}function v(n){let t=n.type;if(t==="if_statement"){let e=n.childForFieldName("condition");return e?`if (${o(e.text,40)})`:"if"}if(t==="else_clause")return"else";if(t==="while_statement"||t==="do_statement"){let e=n.childForFieldName("condition");return`${t.split("_")[0]} (${e?o(e.text,40):""})`}if(t==="for_statement"||t==="for_in_statement"||t==="for_of_statement"){let i=n.text.split(`
|
|
2
2
|
`)[0].match(/for\s*(?:await\s*)?\((.*)\)/);return i?`for (${o(i[1],40)})`:"for"}if(t==="switch_statement"){let e=n.childForFieldName("value");return`switch (${e?o(e.text,40):""})`}if(t==="try_statement")return"try";if(t==="catch_clause")return"catch";if(t==="element"||t==="script_element"||t==="style_element"||t==="jsx_element"||t==="jsx_self_closing_element"){let e=n.childForFieldName("opening_element")||n.childForFieldName("start_tag")||n.children.find(c=>c.type==="start_tag")||n,i=e.childForFieldName("name")||e.childForFieldName("tag_name")||e.children.find(c=>c.type==="tag_name");return i?`<${o(i.text,30)}>`:null}if(["import_declaration","import_from_statement","import_statement","preproc_include"].includes(t))return o(n.text.split(`
|
|
3
|
-
`)[0],60);if(t==="pair"){let e=n.childForFieldName("key");return e?o(e.text.replace(/["']/g,""),40):null}if(t==="assignment_expression"){let e=n.childForFieldName("left");return e?`${o(e.text,30)} = ...`:null}if(t==="variable_declarator"){let e=n.childForFieldName("name")||n.children.find(i=>["identifier","object_pattern","array_pattern"].includes(i.type));return e?o(e.text,40):null}let r=n.childForFieldName("name")||n.childForFieldName("declarator")||n.children.find(e=>["identifier","type_identifier","field_identifier","property_identifier","shorthand_property_identifier"].includes(e.type));if(r){if(r.type.includes("declarator")){let e=r.descendantsOfType("identifier")[0]||r.descendantsOfType("field_identifier")[0];if(e)return o(e.text,40)}return o(r.text,40)}if(["arrow_function","function_expression","function_declaration"].includes(t)){let e=n.parent;for(;e&&e.type!=="program";){let i=v(e);if(i)return i;if(!O.has(e.type))break;e=e.parent}}return null}function L(n){let t=[];function r(e){for(let i of e.children)b.has(i.type)?t.push(i):r(i)}return r(n),t}function j(n){return n.replace(/_([a-z])/g,t=>t[1].toUpperCase())}function T(n,t=0,r=!0,e="",i=null,c=12){let s=n.type,l=v(n),
|
|
4
|
-
`,
|
|
5
|
-
`,
|
|
6
|
-
`:m.forEach((f,x)=>{let y=x===m.length-1;a+=T(f,g,_?r&&y:y,
|
|
7
|
-
`).length,a=12;_>1e4?a=2:_>=8e3?a=3:_>=5e3?a=5:_>=4e3?a=8:_>2e3&&(a=10);let
|
|
8
|
-
${g}`}catch(s){let l=s instanceof Error?s.message:typeof s=="object"?JSON.stringify(s):String(s),
|
|
9
|
-
Stack: ${s.stack}`:"";return`ERROR: Failed to map file: ${l}${
|
|
3
|
+
`)[0],60);if(t==="pair"){let e=n.childForFieldName("key");return e?o(e.text.replace(/["']/g,""),40):null}if(t==="assignment_expression"){let e=n.childForFieldName("left");return e?`${o(e.text,30)} = ...`:null}if(t==="variable_declarator"){let e=n.childForFieldName("name")||n.children.find(i=>["identifier","object_pattern","array_pattern"].includes(i.type));return e?o(e.text,40):null}let r=n.childForFieldName("name")||n.childForFieldName("declarator")||n.children.find(e=>["identifier","type_identifier","field_identifier","property_identifier","shorthand_property_identifier"].includes(e.type));if(r){if(r.type.includes("declarator")){let e=r.descendantsOfType("identifier")[0]||r.descendantsOfType("field_identifier")[0];if(e)return o(e.text,40)}return o(r.text,40)}if(["arrow_function","function_expression","function_declaration"].includes(t)){let e=n.parent;for(;e&&e.type!=="program";){let i=v(e);if(i)return i;if(!O.has(e.type))break;e=e.parent}}return null}function L(n){let t=[];function r(e){for(let i of e.children)b.has(i.type)?t.push(i):r(i)}return r(n),t}function j(n){return n.replace(/_([a-z])/g,t=>t[1].toUpperCase())}function T(n,t=0,r=!0,e="",i=null,c=12){let s=n.type,l=v(n),p=b.has(s)||t===0,m=L(n),_=p&&t>0&&(O.has(s)&&m.length>0||l!==null&&l===i&&m.length>0),a="",u=e,g=t,h=i;if(p&&!_){let f=n.startPosition.row+1,x=n.endPosition.row+1,y=j(s),w=l?`${y} [${l}]`:y;t===0?(a+=`\u{1F4C1} ROOT (Lines: ${f}-${x})
|
|
4
|
+
`,u=e):(a+=`${e}${r?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 "}${w} (Lines: ${f}-${x})
|
|
5
|
+
`,u+=r?" ":"\u2502 "),g=t+1,h=l}return g>c&&m.length>0?a+=`${u}\u2514\u2500\u2500 ... depth exceeded ...
|
|
6
|
+
`:m.forEach((f,x)=>{let y=x===m.length-1;a+=T(f,g,_?r&&y:y,u,h,c)}),a}var D=async n=>{let t;try{t=N(n,["path"]).path}catch{return`ERROR: Failed to parse arguments: ${n}`}if(!t)return'ERROR: No file path provided. Use [tool:functions.FileMap(path="...")]';let r=d.isAbsolute(t)?t:d.resolve(process.cwd(),t);if(!F.existsSync(r))return`ERROR: File not found: ${t}`;let e=d.extname(r).slice(1).toLowerCase(),i=R[e];if(!i)return`ERROR: Unsupported file extension: .${e}`;let c=d.resolve($,i);if(!F.existsSync(c))return`ERROR: Parser for .${e} not found. Please download it in Settings > Other.`;try{let s=P.Parser;if(!S){let h;try{h=d.join(d.dirname(E.resolve("web-tree-sitter")),"tree-sitter.wasm")}catch{h=d.join(process.cwd(),"node_modules","web-tree-sitter","tree-sitter.wasm")}await s.init({locateFile:f=>f==="tree-sitter.wasm"||f.endsWith("tree-sitter.wasm")?h:f}),S=!0}let l=new s,p=await P.Language.load(c);l.setLanguage(p);let m=await F.readFile(r,"utf8"),_=m.split(`
|
|
7
|
+
`).length,a=12;_>1e4?a=2:_>=8e3?a=3:_>=5e3?a=5:_>=4e3?a=8:_>2e3&&(a=10);let u=l.parse(m),g=T(u.rootNode,0,!0," ",null,a);return`\u{1F4C4} File Map for: ${t}
|
|
8
|
+
${g}`}catch(s){let l=s instanceof Error?s.message:typeof s=="object"?JSON.stringify(s):String(s),p=s instanceof Error?`
|
|
9
|
+
Stack: ${s.stack}`:"";return`ERROR: Failed to map file: ${l}${p}`}};export{D as file_map};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as R}from"./chunk-JWNCKRN6.js";import{w as C,x as F}from"./chunk-NPXJIGAI.js";import D from"fs/promises";import y from"path";function S(n){let e=n.toLowerCase();if(e.length===0)return[];if(e.length===1)return[e];let o=[];for(let t=0;t<e.length-1;t++)o.push(e.slice(t,t+2));return o}function w(n,e){if(n===e)return 1;if(!n||!e)return 0;let o=S(n),t=S(e);if(o.length===0||t.length===0)return 0;let s=new Map;for(let l of t)s.set(l,(s.get(l)||0)+1);let r=0;for(let l of o){let a=s.get(l)||0;a>0&&(r++,s.set(l,a-1))}return 2*r/(o.length+t.length)}async function E(n,e,o=n,t=1,s=15){if(t>s)return[];let r;try{r=await D.readdir(n,{withFileTypes:!0})}catch{return[]}let l=[];for(let a of r){if(e.has(a.name))continue;let h=y.join(n,a.name);if(a.isDirectory()){let m=await E(h,e,o,t+1,s);l.push(...m)}else{let m=y.relative(o,h).replace(/\\/g,"/");l.push({name:a.name,relPath:`./${m}`})}}return l}var O=async n=>{let e=typeof n=="object"&&n!==null?n:R(n,["basename","name","path","file","filename","query","directory"]),o=e.basename||e.name||e.path||e.file||e.filename||e.query;if(!o&&typeof n=="string"&&n.trim()){let f=n.trim().replace(/^["']|["']$/g,"");!f.startsWith("{")&&!f.includes("=")&&(o=f)}if(!o)return'ERROR: "basename" parameter is required for FindFile';let t=String(o).trim().replace(/^["']|["']$/g,""),s=t.replace(/^(\.\/|\.\\)/,"").replace(/\\/g,"/"),r=s.toLowerCase(),a=t.includes("*")||t.includes("?")?new RegExp("^"+t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")+"$","i"):null,h=process.cwd(),m=new Set([...C,...F(h)]);try{let f=await E(h,m,h),g=[];for(let i of f){let u=i.name.toLowerCase(),P=y.parse(i.name).name.toLowerCase(),p=i.relPath.toLowerCase(),d=p.startsWith("./")?p.slice(2):p,c=0;if(i.name===s||i.relPath===`./${s}`)c=1;else if(u===r||p===`./${r}`||d===r)c=.98;else if(P===r)c=.95;else if(a&&(a.test(i.name)||a.test(d)))c=.9;else if(u.includes(r)||d.includes(r))c=.7+r.length/Math.max(u.length,r.length)*.15;else{let W=w(r,u),q=w(r,P),x=w(r,d),L=Math.max(W,q,x);L>=.75&&(c=L*.85)}c>=.6&&g.push({relPath:i.relPath,score:c})}if(g.length===0)return`No file found matching name "${t}" in CWD. If working outside CWD use Run`;g.sort((i,u)=>u.score-i.score||i.relPath.length-u.relPath.length);let $=Array.from(new Set(g.map(i=>i.relPath))),b=$.length;return`${`Found ${b} file${b===1?"":"s"} matching "${t}" in CWD:
|
|
2
|
+
|
|
3
|
+
`}${$.join(`
|
|
4
|
+
`)}`}catch(f){return`ERROR: Failed to find file: ${f.message}`}};export{O as find_file};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as k}from"./chunk-2RTYI6K3.js";import{a as b}from"./chunk-JWNCKRN6.js";import{v as B,w as T,x as $}from"./chunk-5MJKHQVE.js";import{b as I}from"./chunk-KQNW7DK5.js";import"./chunk-Y6O7SAPD.js";import"./chunk-ZGORMZE5.js";import"./chunk-NPXJIGAI.js";import C from"fs-extra";import x from"path";var F=(a,y={})=>{try{if(a.length<8||a[0]!==137||a[1]!==80||a[2]!==78||a[3]!==71)return a;let s=[],c=[];for(let r=0;r<256;r++){let e=r;for(let n=0;n<8;n++)e&1?e=3988292384^e>>>1:e=e>>>1;c[r]=e}let l=r=>{let e=4294967295;for(let n=0;n<r.length;n++)e=c[(e^r[n])&255]^e>>>8;return(e^4294967295)>>>0},p=(r,e)=>{let n=Buffer.from(r,"ascii"),i=Buffer.from(e,"utf-8"),u=n.length+1+i.length,o=Buffer.alloc(8+u+4);o.writeUInt32BE(u,0),o.write("tEXt",4,"ascii"),n.copy(o,8),o[8+n.length]=0,i.copy(o,8+n.length+1);let w=l(o.subarray(4,8+u));return o.writeUInt32BE(w,8+u),o};for(let[r,e]of Object.entries(y))e!=null&&s.push(p(r,String(e)));if(s.length===0)return a;if(a.subarray(12,16).toString("ascii")==="IHDR"){let e=a.subarray(0,33),n=a.subarray(33);return Buffer.concat([e,...s,n])}return a}catch{return a}},N=async(a,y={})=>{let s=b(a,["prompt","text","path","outputPath","output","ratio"]),c=s.prompt||s.text,l=s.path||s.outputPath||s.output||"generated_image.png",p=s.ratio;if(!c)return'ERROR: Missing "prompt" argument for generate_image.';let r=["nsfw","naked","nudity","nude","porn","sex","xxx","erotic","gore","bloody","violence","abuse","suicide","murder","hentai","pedophile","rape"],e=c.toLowerCase();if(r.some(i=>e.includes(i)))return"ERROR: Prompt blocked by system safety filter (inappropriate or unsafe content detected).";try{let i=await I();if(!await B(i))return`ERROR: Insufficient Quota for selected quality. Either tell user reduce quality or wait for next refresh cycle (${(await T()).nextResetMin||60}m).`;let o=i.imageSettings||{keyType:"Default",quality:"Low-High",apiKey:""},w=o.keyType==="Custom"&&o.apiKey?o.apiKey:FALLBACK_IMAGE_KEY,E={Low:"flux","Low-High":"zimage",Medium:"gptimage","Medium-High":"gptimage",High:"qwen-image",Ultra:"gptimage-large",Premium:"nanobanana-pro"}[o.quality]||"zimage",g=1024,m=1024;if(p){let t=p.replace(/\s+/g,"");t==="16:9"?(g=1024,m=576):t==="9:16"?(g=576,m=1024):t==="4:3"?(g=1024,m=768):t==="3:4"?(g=768,m=1024):t==="1:1"&&(g=1024,m=1024)}let M=Math.floor(Math.random()*1e7),S=`https://gen.pollinations.ai/image/${encodeURIComponent(c)}?model=${E}&width=${g}&height=${m}&seed=${M}&enhance=true&reasoning=high&quality=high&negative=${encodeURIComponent("deformed, distorted, disfigured, poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, disconnected limbs, mutation, mutated hands and fingers, blurry, low quality, low resolution, extra fingers, censored, watermarks, signatures")}`,d=await fetch(S,{method:"GET",headers:{Authorization:`Bearer ${w}`}});if(!d.ok){let t=d.status,h="";try{h=await d.text()}catch{}return t===402||h.includes("Insufficient balance")||h.includes("PAYMENT_REQUIRED")?"ERROR: Image Generation Currently unavailable. Try again later.":`ERROR: Image Generation failed with status [${t}]: ${h||"Unknown API Error"}`}if((d.headers.get("content-type")||"").includes("application/json")){let t=await d.json();return t.status===402||t.error&&t.error.code==="PAYMENT_REQUIRED"?"ERROR: Image Generation Currently unavailable. Try again later.":`ERROR: Image Generation failed: ${t.error?.message||JSON.stringify(t)}`}let O=await d.arrayBuffer(),f=Buffer.from(O),P={Title:c,Description:"Generated via FluxFlow CLI",Software:"FluxFlow CLI",Author:"FluxFlow","Creation Time":new Date().toISOString(),Prompt:c,Model:`Fluxflow:${E}`,Ratio:p||"1:1",Seed:String(M)};f=F(f,P);let R=x.resolve(process.cwd(),l);await C.ensureDir(x.dirname(R)),await k.recordFileChange(R),await C.writeFile(R,f),await $(i);let v=x.extname(l).toLowerCase(),L={".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png",".webp":"image/webp"}[v]||"image/png";return y.isMultiModal!==!1?{text:`Image successfully generated from prompt [${c}] and saved to [${l}]. Output attached to multimodal part`,binaryPart:{inlineData:{data:f.toString("base64"),mimeType:L}}}:`Image successfully generated from prompt [${c}] and saved to [${l}].`}catch(i){return`ERROR: Failed during image generation: ${i instanceof Error?i.message:String(i)}`}};export{N as generate_image};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as k}from"./chunk-56EJGQU3.js";import{a as w}from"./chunk-
|
|
1
|
+
import{a as k}from"./chunk-56EJGQU3.js";import{a as w}from"./chunk-JWNCKRN6.js";var q=async(E,x={})=>{let d=w(E,["id"]).id;if(!d)return'ERROR: Missing "id" argument for getProgress.';let t=k.find(r=>r.id===d);if(!t)return`ERROR: Subagent task with ID [${d}] not found.`;let s=`Subagent task status: ${t.status.toUpperCase()}
|
|
2
2
|
`;if(s+=`Title: ${t.title}
|
|
3
3
|
`,s+=`Task: ${t.task}
|
|
4
4
|
`,t.startedAt){let r=Math.floor((Date.now()-t.startedAt)/1e3);s+=`Elapsed Time: ${r}s
|
|
@@ -13,7 +13,7 @@ import{a as k}from"./chunk-56EJGQU3.js";import{a as w}from"./chunk-Y5JU726N.js";
|
|
|
13
13
|
`)}return s+=`
|
|
14
14
|
Progress Log:
|
|
15
15
|
`,t.progress.forEach((r,i)=>{s+=`--- Turn ${i+1} ---
|
|
16
|
-
`;let R=r.filter(o=>!o.startsWith("[SUBAGENT SUCCESS]")).map(o=>{if(o.startsWith("[Subagent Response]")){let m="[Subagent Response]",e=o.substring(m.length),$=["action:","tool:"];for(;;){let C=e.toLowerCase(),c=-1,L="";for(let n of $){let f=C.indexOf(n);f!==-1&&(c===-1||f<c)&&(c=f,L=n)}if(c===-1)break;let h=c,p=h,
|
|
16
|
+
`;let R=r.filter(o=>!o.startsWith("[SUBAGENT SUCCESS]")).map(o=>{if(o.startsWith("[Subagent Response]")){let m="[Subagent Response]",e=o.substring(m.length),$=["action:","tool:"];for(;;){let C=e.toLowerCase(),c=-1,L="";for(let n of $){let f=C.indexOf(n);f!==-1&&(c===-1||f<c)&&(c=f,L=n)}if(c===-1)break;let h=c,p=h,b=!1,u=h-1;for(;u>=0&&/\s/.test(e[u]);)u--;u>=0&&e[u]==="["&&(p=u,b=!0);let T=0,S=!1,a=null,l=h;for(;l<e.length;){let n=e[l];if(!a&&(n==="'"||n==='"'||n==="`")?a=n:a&&n===a&&e[l-1]!=="\\"&&(a=null),a||(n==="("?(T++,S=!0):n===")"&&T--),S&&T===0&&!a){let f=l;if(b){let g=l+1;for(;g<e.length&&/\s/.test(e[g]);)g++;g<e.length&&e[g]==="]"&&(f=g)}e=e.substring(0,p)+e.substring(f+1);break}if(l++,l===e.length){e=e.substring(0,p);break}}}return m+`
|
|
17
17
|
`+e.trim()}return o.startsWith("[Executing Tool]")&&o.length>256?o.substring(0,256)+"...[truncated from logs]":o});s+=R.join(`
|
|
18
18
|
`)+`
|
|
19
19
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as b,c as p}from"./chunk-56EJGQU3.js";import{a as D}from"./chunk-JWNCKRN6.js";var q=async(_,s={})=>{let{runSubagent:y}=await import("./ai-6AZZQUJJ.js"),a=D(_,["task","instruction","prompt","model","title","tools","id"]),u=a.task||a.instruction||a.prompt,A=a.model||null,g=a.title||null,w=a.tools||null,m=a.id&&a.id!=="null"&&a.id!=="undefined"&&a.id!==""?String(a.id).trim():null;if(!u)return'ERROR: Missing "task" argument for invoke.';let d=null,U="";m&&(d=b.find(e=>e.id===m));let f=!!d,r=f?d.id:m||`subagent-${Date.now()}-${Math.floor(Math.random()*1e3)}`,I=f?d.history||[]:[],C=null;if(w)try{let e=w.trim();e.startsWith("[")&&e.endsWith("]")&&(e=e.substring(1,e.length-1)),C=e.split(",").map(n=>n.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let h=null,S=null,E=new Promise((e,n)=>{h=e,S=n}),t=d;t?(t.status="running",t.task=u,g&&(t.title=g),t.startedAt=Date.now(),t.lastChunkTime=Date.now(),t.completionPromise=E,t._resolveCompletion=h,t._rejectCompletion=S):(t={id:r,title:g||u.substring(0,30),task:u,status:"running",startedAt:Date.now(),lastChunkTime:Date.now(),wps:0,questions:[],pendingSteerMessages:[],steer:e=>{e&&t.pendingSteerMessages.push(e)},completionPromise:E,_resolveCompletion:h,_rejectCompletion:S,progress:[],history:[]},b.push(t));let l={chunks:[],totalWords:0};s.onSubagentUpdate&&s.onSubagentUpdate();let i=[],M={...s,taskId:r,onHistoryUpdate:e=>{t.history=[...e]},onAskMain:async e=>{let n=`q-${Date.now()}-${Math.floor(Math.random()*1e3)}`,o=null,k=new Promise(T=>{o=T}),c={id:n,question:e,answered:!1,answer:null,askedAt:Date.now(),_resolve:o};return t.questions.push(c),t.status="waiting",s.onSubagentUpdate&&s.onSubagentUpdate(),p(`[SYSTEM] Background subagent "${t.title}" is WAITING FOR YOUR INPUT: "${e}"
|
|
2
|
+
Respond using tool: [action:Answer(id="${r}", answer="...")]
|
|
3
|
+
[/SYSTEM]`),await k},onVisualFeedback:e=>{t.lastChunkTime=Date.now();let n=e.replace(/\x1b\[[0-9;]*m/g,""),o=n.match(/[✔✘✗✖🔍📖→➕↻•]\s*([A-Za-z0-9\s-]+)/);o?t.currentTool=o[1].trim():t.currentTool=n,s.onSubagentUpdate&&s.onSubagentUpdate()},onTokenChunk:(e,n)=>{let o=Date.now();if(t.lastChunkTime=o,t.currentTool="Thinking",typeof n=="number"&&n>0){l.totalWords+=n,l.chunks.push({time:o,words:n});let k=o-400;if(l.chunks=l.chunks.filter(c=>c.time>=k),l.chunks.length>0){let c=l.chunks.reduce((v,R)=>v+R.words,0),$=l.chunks[0].time,T=Math.max(.4,(o-$)/1e3);t.wps=Math.round(c/T)}}s.onSubagentUpdate&&s.onSubagentUpdate()}};return y(u,M,A,C,null,e=>{if(t.status==="cancelled")return;if(e.startsWith("[Subagent Turn")&&i.length>0&&(t.progress.push([...i]),i=[]),e.includes("[Executing Tool]")){let o=e.match(/\[Executing Tool\]\s*([a-zA-Z0-9_]+)/);o&&(!t.currentTool||t.currentTool==="Thinking")&&(t.currentTool=o[1])}let n=e;if(n.startsWith("[Tool Result]")||n.startsWith("[Action Result]")){let o=n.split(`
|
|
4
|
+
`);o.length>5&&(n=o.slice(0,4).join(`
|
|
5
|
+
`)+`
|
|
6
|
+
... [Content/Diff Truncated from Logs] ...`)}i.push(n),s.onSubagentUpdate&&s.onSubagentUpdate()},!0,I).then(e=>{if(t.status==="cancelled"){t._resolveCompletion&&t._resolveCompletion(e);return}i.length>0&&(t.progress.push([...i]),i=[]),t.status="completed",t.finalAnswer=e,s.onSubagentUpdate&&s.onSubagentUpdate(),p(`[SYSTEM] Background subagent "${t.title}" (id: ${r}) has FINISHED. Call GetProgress(id="${r}") to see the final result. [/SYSTEM]`),t._resolveCompletion&&t._resolveCompletion(e)}).catch(async e=>{let{isTerminationSignaled:n}=await import("./ai-6AZZQUJJ.js");if(e.message==="Subagent task was cancelled."||t.status==="cancelled"||n()){t.status="cancelled",i.push("[SUBAGENT CANCELLED] Task was cancelled."),t.progress.push([...i]),s.onSubagentUpdate&&s.onSubagentUpdate(),t._resolveCompletion&&t._resolveCompletion(null);return}i.push(`[SUBAGENT FAILURE] Error: ${e.message}`),t.progress.push([...i]),t.status="failed",t.error=e.message,s.onSubagentUpdate&&s.onSubagentUpdate(),p(`[SYSTEM] Background subagent "${t.title}" (id: ${r}) FAILED with error: ${e.message}. [/SYSTEM]`),t._rejectCompletion&&t._rejectCompletion(e)}),f?`Background subagent ${r} resumed.`:U?`Background subagent started. Task ID: ${r}.${U}`:`Background subagent started. Task ID: ${r}`};export{q as invoke};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as m}from"./chunk-56EJGQU3.js";import{a as g}from"./chunk-JWNCKRN6.js";var A=async(p,a={})=>{let{runSubagent:f}=await import("./ai-6AZZQUJJ.js"),e=g(p,["task","instruction","prompt","model","tools","title","id"]),l=e.task||e.instruction||e.prompt,k=e.model||null,c=e.tools||null,u=e.id&&e.id!=="null"&&e.id!=="undefined"&&e.id!==""?String(e.id).trim():null;if(!l)return'ERROR: Missing "task" argument for invokeSync.';let n=null,d="";u&&(n=m.find(t=>t.id===u));let o=n?n.id:u||`subagent-sync-${Date.now()}-${Math.floor(Math.random()*1e3)}`,$=n?.history||[],b=null;if(c)try{let t=c.trim();t.startsWith("[")&&t.endsWith("]")&&(t=t.substring(1,t.length-1)),b=t.split(",").map(i=>i.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let r=e.title||(n?n.title:l.substring(0,30)),s=n;s?(s.status="running",s.task=l):(s={id:o,title:r,task:l,status:"running",startedAt:Date.now(),progress:[],history:[]},m.push(s));let y={...a,taskId:o,onHistoryUpdate:t=>{s.history=[...t]}};try{a.onVisualFeedback&&a.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${r}${n?" (Resumed)":""}`);let t=await f(l,y,k,b,null,null,!1,$);s.status="completed",s.finalAnswer=`Subagent task completed. (ID: ${o})
|
|
2
|
+
Final Answer:
|
|
3
|
+
${t}`,a.onVisualFeedback&&a.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${r} [COMPLETED]
|
|
4
|
+
`);let i=`Subagent task completed. (ID: ${o})
|
|
5
|
+
Final Answer:
|
|
6
|
+
${t}`;return d?`${i}${d}`:i}catch(t){s.status="failed",s.error=t.message;let{isTerminationSignaled:i}=await import("./ai-6AZZQUJJ.js"),h=t.message==="Subagent task was cancelled by user."||i();if(a.onVisualFeedback){let S=h?"[CANCELLED]":"[FAILED]";a.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${r} ${S}
|
|
7
|
+
`)}return`ERROR: Subagent execution failed: ${t.message}${d}`}};export{A as invokeSync};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as e}from"./chunk-ZPSNXBWW.js";import"./chunk-3SMC2C3F.js";import{a as i}from"./chunk-JWNCKRN6.js";var k=async(a,c={})=>{let t=i(a,["key","keys","input","shortcut"]),s=t.key||t.keys||t.input||t.shortcut;if(!s)return'ERROR: Missing required "key" parameter for KeyPress tool.';let r=String(s).trim().toLowerCase();if(r==="clearinput"||r==="clear_input"||r==="clear")return await e("clear_input");if(r==="back"||r==="browser_back"||r==="browserBack")return await e("browser_back");if(r.includes(";")||r.includes("+")){let o=r.split(/[;+]/).map(n=>n.trim()).filter(Boolean);return await e("key_combination",o)}return await e("key_press",r)};export{k as key_press};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as n}from"./chunk-ZPSNXBWW.js";import"./chunk-3SMC2C3F.js";import{a as r}from"./chunk-JWNCKRN6.js";var p=async(o,u={})=>{let t=r(o,["text","input","value","autoPressEnter"]),e=t.text||t.input||t.value||"",s=t.autoPressEnter===!0||t.autoPressEnter==="true"||t.enter===!0||t.enter==="true";return e==null?'ERROR: Missing required "text" parameter for KeyboardTyping tool.':await n("type",String(e),{autoPressEnter:s})};export{p as keyboard_typing};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as M}from"./chunk-
|
|
1
|
+
import{a as M}from"./chunk-JWNCKRN6.js";import h from"fs";import A from"path";var j=new Set([".git","node_modules",".gemini","dist","build",".next","out",".cache","bin","obj","vendor","venv",".idea",".gradle",".terraform","target","coverage",".vscode",".svn",".hg",".fslckout",".github",".gitlab",".circleci",".gitea",".gitee",".lerna",".changeset",".nx",".npm",".yarn",".pnpm-store",".expo",".nuxt",".svelte-kit",".docusaurus",".turbo",".vercel","bower_components",".netlify",".vuepress",".quasar",".output",".angular","jspm_packages",".parcel-cache",".rollup.cache",".rspack",".vitepress","__pycache__",".pytest_cache",".mypy_cache",".tox",".poetry","env","vhdl",".ipynb_checkpoints",".jupyter",".conda",".pdm-build",".bundle",".yardoc",".metadata","App_Data","ClientBin",".cargo",".rustc_info",".go","Godeps","_vendor",".rake_tasks","CMakefiles",".wakatime",".dart_tool",".fvm",".cocoapods","Pods",".pub-cache",".symlinks","DerivedData",".xcworkspace",".serverless",".aws",".gcloud",".azure",".kube",".vagrant",".docker","postgres-data","redis-data","mongo-data",".Spotlight-V100",".Trashes","$RECYCLE.BIN","System Volume Information",".DocumentRevisions-V100",".fseventsd","AppData","Application Data","Local","LocalLow","Roaming","$WinREAgent","$WINDOWS.~BT","$WINDOWS.~WS","scw","System32","SysWOW64",".AppleDouble",".AppleDB",".AppleDesktop","_CodeSignature",".cmio",".LSOverride",".localized",".TemporaryItems",".Trash",".Trash-0",".Trash-1000",".gvfs",".local",".config",".dbus",".fontconfig",".snap",".var",".lost+found","lost+found",".thumb",".thumbnails","EFI","boot","grub","logs","log",".nyc_output",".sonar",".ruff_cache",".VSCodeCounter",".skills","skills"]),z=(r,a=!1)=>a&&(r.includes("skills")||r.includes(".skills")||r.includes("skill")||r.includes(".skill"))?!1:j.has(r)||r.startsWith(".pnpm"),N=r=>{try{let a=String(r.getMonth()+1).padStart(2,"0"),S=String(r.getDate()).padStart(2,"0"),i=String(r.getHours()).padStart(2,"0"),n=String(r.getMinutes()).padStart(2,"0");return`${a}-${S} ${i}:${n}`}catch{return"N/A"}},q=async r=>{let a=M(r,["path","recurse"]),S=a.path||null;if(!S)return"ERROR: No directory path provided.";if(S.trim().toLowerCase().startsWith("#skills"))return"ERROR: '#skill' is reserved VFS namespace, not folder. Use 'ReadFile' to read specific skills.";let i=0,n=S.trim(),T=n.match(/[/\\]\+(\d+)$/);T&&(i=parseInt(T[1],10),n=n.slice(0,T.index).trim()||".");let l=1;if(a.recurse!==void 0&&a.recurse!==null)if(typeof a.recurse=="number")l=a.recurse;else if(typeof a.recurse=="boolean")l=a.recurse?2:1;else{let o=parseInt(String(a.recurse).trim(),10);l=isNaN(o)?1:o}l=Math.max(1,Math.min(3,l));try{let o=A.resolve(process.cwd(),n);if(!h.existsSync(o))return`ERROR: Path [${n}] does not exist.`;if(!h.statSync(o).isDirectory())return`ERROR: Path [${n}] is a file, not a directory. Use ReadFile instead.`;if(l===1){let g=[];try{g=h.readdirSync(o)}catch{return`ERROR: Inaccessible Directory [${n}].`}let u=[],m=[];for(let s of g){let f=A.join(o,s),x=!1,C="N/A",w="N/A";try{let _=h.statSync(f);x=_.isDirectory(),C=(_.size/1024).toFixed(1)+"KB",w=N(_.mtime)}catch{}x?u.push({name:s,type:"directory",size:C,mtime:w}):m.push({name:s,type:"file",size:C,mtime:w})}u.sort((s,f)=>s.name.localeCompare(f.name)),m.sort((s,f)=>s.name.localeCompare(f.name));let $=[...u,...m],d=$.length,c=$.slice(i,i+150),y=c.map(s=>s.type==="directory"?`${s.name}/`:`${s.name} (${s.size}, ${s.mtime})`).join(`
|
|
2
2
|
`),p=`
|
|
3
3
|
|
|
4
4
|
(Total items in folder: ${d})`,e=i+c.length,t=n.replace(/\\/g,"/");if(i>0||e<d){let s=d===0?0:i+1,f=i+c.length;if(p=`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as n}from"./chunk-3SMC2C3F.js";import{a as c}from"./chunk-JWNCKRN6.js";var i=async(a,o={})=>{let t=typeof a=="string"?c(a,["canvasMode","canvas_mode"]):a||{},r=t.canvasMode===!0||t.canvasMode==="true"||t.canvas_mode===!0||t.canvas_mode==="true";try{let e=await n({canvasMode:r});if(e&&e.base64)return{text:`Screen recaptured${r?" (static canvas grid mode)":""}.`,binaryPart:{inlineData:{mimeType:e.mimeType,data:e.base64}}}}catch{}return"Screen recaptured."};export{i as recapture_screen};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-ZPSNXBWW.js";import"./chunk-3SMC2C3F.js";import{a as t}from"./chunk-JWNCKRN6.js";var g=async(n,c={})=>{let o=t(n,["direction","amount","gridId","grid","coordinate","target","id"]),e=(o.direction||"down").toLowerCase(),i=o.amount?parseInt(o.amount,10):6,d=o.gridId||o.grid||o.coordinate||o.target||o.id||null;return await r("scroll",d,{direction:e,amount:i})};export{g as scroll};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{a as nt}from"./chunk-JWNCKRN6.js";import{b as rt}from"./chunk-KQNW7DK5.js";import"./chunk-Y6O7SAPD.js";import"./chunk-ZGORMZE5.js";import{w as Y,x as tt,y as et,z as st}from"./chunk-NPXJIGAI.js";import X from"fs/promises";import E from"path";import K from"fast-glob";import{Minimatch as it}from"minimatch";async function O(f,l,y=f,d=1){if(d>12)return[];let h=[],r;try{r=await X.readdir(f,{withFileTypes:!0})}catch{return[]}for(let t of r){let e=E.join(f,t.name),w=E.relative(y,e),F=w.split(E.sep).map(L=>L.toLowerCase()),N=t.name.toLowerCase();if(!l.some(L=>{let v=L.toLowerCase();return v.startsWith(".")&&N.endsWith(v)?!0:F.some(P=>P===v||P.startsWith(".pnpm"))}))if(t.isDirectory()){let L=await O(e,l,y,d+1);h=h.concat(L)}else t.isFile()&&h.push({fullPath:e,relativePath:w})}return h}function at(f,l,y=1/0){if(f===l)return 0;if(f.length===0)return l.length;if(l.length===0)return f.length;if(Math.abs(f.length-l.length)>y)return y+1;let d=Array.from({length:l.length+1},(h,r)=>r);for(let h=1;h<=f.length;h++){let r=[h],t=h;for(let e=1;e<=l.length;e++){let w=f[h-1]===l[e-1]?0:1,F=Math.min(r[e-1]+1,d[e]+1,d[e-1]+w);r.push(F),F<t&&(t=F)}if(d=r,t>y)return y+1}return d[l.length]}function ct(f,l){if(!f||!l)return!1;let y=f.toLowerCase(),d=l.toLowerCase();if(y.includes(d))return!0;let h=y.split(/[^a-z0-9]+/).filter(t=>t.length>0),r=d.split(/[^a-z0-9]+/).filter(t=>t.length>1||d.length===1&&t.length>0);return r.length===0?!1:r.every(t=>{let e=t.length<=2?0:t.length<=5?1:2;for(let w of h)if(w.includes(t)||t.length>=3&&w.length>=3&&Math.abs(w.length-t.length)<=e&&at(t,w,e)<=e)return!0;return!1})}var yt=async f=>{let{keyword:l,path:y,fuzzy:d,subString:h,regex:r}=nt(f,["keyword","path"]);if(l==null)return'ERROR: Missing "keyword" argument.';let t=String(l),e=y,w=!1;if(e){let{resolvedPath:s,isTildeResolved:u}=st(e);e=s,w=u;let n=e.trim().toLowerCase();if(n==="#docs"||n==="#doc"||n==="#documentation"||n.includes("#skill/global/fluxflow")||n.startsWith("#skill"))return"ERROR: Cannot search in reserved VFS '#skill' namespace. Use 'ReadFile' to read specific skills."}let F=s=>s===!0||s==="true"||s===1||s==="1"||s==="yes",N=r===!1||r==="false"||r===0||r==="0"||r==="no",T=r===!0||r==="true"||r===1||r==="1"||r==="yes",L=F(d)||F(h),v=null,P=null,H=s=>{let u=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=/^\w/.test(s)?"(?<![\\w])":"",k=/\w$/.test(s)?"(?![\\w])":"";return new RegExp(`${n}${u}${k}`,"i")};if(N)L||(P=H(t));else{try{let s=t;v=new RegExp(s,"i")}catch(s){if(T)return`ERROR: Invalid regex pattern "${t}": ${s.message}`}P=H(t)}let S=Array.from(new Set([...Y,...tt(process.cwd())])),V=150;try{let s=[],u=process.cwd(),n=null;if(e){let o=i=>i.startsWith("!")||!i.startsWith("-")?i:"!"+i.replace(/^-+/,""),g=e.split(";").map(i=>i.trim()).filter(Boolean).map(o).filter(i=>i!=="!"),c=g.some(i=>i.startsWith("!"));if(g.some(i=>K.isDynamicPattern(i)||/[*?{}[\]()|+]/.test(i))){n="glob";let i=e.replace(/\\/g,"/"),a=g.map(m=>m.replace(/\\/g,"/")),z=S.map(m=>m.startsWith(".")?`**/*${m}`:`**/${m}/**`);if(c&&!g.some(m=>!m.startsWith("!"))){let m=await O(u,S,u),R=$=>$.endsWith("/")?$+"**":$,p=a.filter($=>$.startsWith("!")).map($=>R($.slice(1))),M=a.filter($=>!$.startsWith("!")).map(R);s=m.filter($=>{let x=$.relativePath.replace(/\\/g,"/"),Z=M.length===0||M.some(C=>{try{return new it(C).match(x)}catch{return!1}}),j=p.some(C=>{try{return new it(C).match(x)}catch{return!1}});return Z&&!j})}else{let m=a.some(p=>/[\(\)\|]|\.\*/.test(p)),R=[];if(!m)try{R=await K(a,{cwd:u,ignore:z,dot:!0,onlyFiles:!0,absolute:!1})}catch{R=[]}if(R.length===0&&(m||K.isDynamicPattern(i))){let p=i.match(/^([^\*\?\(\)\|\[\]\s]+)\//),M=p&&!/[\*\?\(\)\|\[\]]/.test(p[1])?E.resolve(u,p[1]):u,$=await O(M,S,u);try{let x=i.replace(/^\.\//,"");x=x.replace(/\.\*\/(\\.|[^\/])/g,".*$1"),!x.startsWith("^")&&!x.startsWith(".*")&&(x=`.*${x}`);let Z=new RegExp(x.endsWith("$")?x:`${x}$`,"i");s=$.filter(j=>{let C=j.relativePath.replace(/\\/g,"/");return Z.test(C)})}catch{s=[]}}else s=R.map(p=>({fullPath:E.resolve(u,p),relativePath:p}))}}else{let i=[],a=!1,z=!1;for(let I of g){let m=I.replace(/[\/\\]+$/,""),R=E.resolve(u,m);try{let p=await X.stat(R);if(p.isDirectory()){z=!0;let M=await O(R,S,u);i.push(...M)}else if(p.isFile())a=!0,i.push({fullPath:R,relativePath:E.relative(u,R)});else return`ERROR: Path is neither a file nor a directory: ${I}`}catch{return`ERROR: Path not found: ${I}`}}s=i,a&&!z?n="file":n="dir"}}else s=await O(u,S);let k=s.map(async o=>{try{let g=await X.readFile(o.fullPath,"utf-8");if(g.includes("\0"))return[];let c=g.split(/\r?\n/),W=[];for(let a=0;a<c.length;a++)(L?c[a].toLowerCase().includes(t.toLowerCase())||ct(c[a],t):N?P&&P.test(c[a]):v&&v.test(c[a])||P&&P.test(c[a]))&&W.push({line:a+1,content:c[a].trim()});return W.length===0?null:{path:o.relativePath.replace(/\\/g,"/"),matches:W}}catch{return[]}}),ot=await Promise.all(k),D=[],b=0;for(let o of ot){if(!o||!o.matches)continue;if(b>=V)break;let g=V-b,c=o.matches.slice(0,g);D.push({path:o.path,matches:c}),b+=c.length}typeof global.gc=="function"&&global.gc();let B=null;if(D.length===0){let o=n==="file"?` in '${e}'`:n==="dir"||n==="glob"?` in '${e}'`:". Try to specify files",g=n==="dir"?"[DIR]":n==="glob"?"[GLOB]":"";return`${g}${g?" ":""}Found 0 matches of '${t}'${o}${B?` ${B}`:""}`}let U=B?` ${B}`:"",q=`${D.length} file${D.length===1?"":"s"}`,_=`${b} match${b===1?"":"es"}`,G;n==="file"?G=`Found ${_} of '${t}' in '${e}'${U}:`:n==="dir"||n==="glob"?G=`Found ${_} of '${t}' in '${e}' across ${q}${U}:`:G=`Found ${_} of '${t}' across ${q}${U}:`;let J=n==="dir"?"[DIR]":n==="glob"?"[GLOB]":"",A=`${J}${J?" ":""}${G}
|
|
2
|
+
|
|
3
|
+
`,Q="";try{let o=await rt();o?.systemSettings?.alwaysAskFiles&&(Q=o.systemSettings.alwaysAskFiles)}catch{}for(let o of D)if(A+=`${o.path}:
|
|
4
|
+
`,et(o.path,Q)){let c=o.matches.map(W=>`Line ${W.line}`).join(", ");A+=` ${c}. Line snapshot not available due to file restriction policy. ReadFile if needed
|
|
5
|
+
|
|
6
|
+
`}else{for(let c of o.matches)A+=` Line ${c.line}: ${c.content}
|
|
7
|
+
`;A+=`
|
|
8
|
+
`}let lt=w?`
|
|
9
|
+
[Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:"";return`${A.trimEnd()}${lt}`}catch(s){return`ERROR: ${s.message}`}};export{yt as search_keyword};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-56EJGQU3.js";import{a}from"./chunk-JWNCKRN6.js";var p=async(o,r={})=>{let t=a(o,["id","message","instruction","text","prompt"]),s=t.id,n=t.message||t.instruction||t.text||t.prompt;if(!s)return'ERROR: Missing "id" argument for Steer.';if(!n)return'ERROR: Missing "message" argument for Steer.';let e=i.find(u=>u.id===s);return e?e.status==="completed"||e.status==="failed"||e.status==="cancelled"?`ERROR: Cannot steer subagent task [${s}] because it has already finished with status [${e.status.toUpperCase()}].`:(typeof e.steer=="function"?e.steer(n):(e.pendingSteerMessages||(e.pendingSteerMessages=[]),e.pendingSteerMessages.push(n)),r.onSubagentUpdate&&r.onSubagentUpdate(),`Steering instruction injected into subagent task [${s}]. It will be processed on the subagent's turn.`):`ERROR: Subagent task with ID [${s}] not found.`};export{p as steerSubagent};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as h}from"./chunk-2RTYI6K3.js";import{a as C}from"./chunk-
|
|
1
|
+
import{a as h}from"./chunk-2RTYI6K3.js";import{a as C}from"./chunk-JWNCKRN6.js";import"./chunk-ZGORMZE5.js";import{c as $}from"./chunk-NPXJIGAI.js";import l from"fs";import R from"path";var D=async(x,S={})=>{let{method:f,tasks:m,markDone:d}=C(x,["method","tasks","markDone"]),A=S.chatId||"default";if(!f)return'ERROR: Missing "method" argument for Goal tool (create/append/get).';let u=R.join($,"plan",A),o=R.join(u,"todo.md"),W=t=>{if(!t||Array.isArray(t))return t;let s=String(t).trim();if(s.startsWith("[")&&s.endsWith("]")){let i=s.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);return i?i.map(n=>n.slice(1,-1).replace(/\\(.)/g,"$1")):s.slice(1,-1).split(",").map(n=>n.trim()).filter(Boolean)}return t},k=t=>{let s=W(t);return s?(Array.isArray(s)?s:String(s).split(`
|
|
2
2
|
`)).map(n=>{let r=String(n).trim();return r?r.startsWith("- [ ]")||r.startsWith("- [x]")||r.startsWith("- [X]")?r:`- [ ] ${r}`:null}).filter(Boolean).join(`
|
|
3
3
|
`)+`
|
|
4
4
|
`:""},y=(t,s)=>{if(!s)return{content:t,markedCount:0};let i=W(s),n=(Array.isArray(i)?i:[i]).map(p=>String(p).replace(/^- \[[xX ]\]\s*/i,"").trim()).filter(Boolean),r=t.split(`
|
|
@@ -7,4 +7,4 @@ import{a as h}from"./chunk-2RTYI6K3.js";import{a as C}from"./chunk-Y5JU726N.js";
|
|
|
7
7
|
${t}`}return`Goal Created (${i} total)
|
|
8
8
|
${t}`}if(f==="append"){if(!m)return'ERROR: Missing "tasks" for append method.';let t=k(m);await h.recordFileChange(o),l.appendFileSync(o,t,"utf8");let s=l.readFileSync(o,"utf8"),i=s.split(/\r?\n/).map(e=>e.trim()),n=i.filter(e=>e.startsWith("- [ ]")||e.startsWith("- [x]")||e.startsWith("- [X]")).length,r=i.filter(e=>e.startsWith("- [x]")||e.startsWith("- [X]")).length,c=t.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.startsWith("- [ ]")||e.startsWith("- [x]")||e.startsWith("- [X]")).length;return`Goal Appended (${r} completed, ${n-r} left, ${c} added)
|
|
9
9
|
${s}`}if(f==="get"){if(!l.existsSync(o))return"Goal: No task list found for this session.";let t=l.readFileSync(o,"utf8"),s=0;if(d){let e=y(t,d);e.markedCount>0&&(t=e.content,s=e.markedCount,await h.recordFileChange(o),l.writeFileSync(o,t,"utf8"))}let i=t.split(/\r?\n/).map(e=>e.trim()),n=i.filter(e=>e.startsWith("- [ ]")||e.startsWith("- [x]")||e.startsWith("- [X]")).length,r=i.filter(e=>e.startsWith("- [x]")||e.startsWith("- [X]")).length;return`${s>0?`${s} Goal(s) Marked Done`:"Goal"}: ${r} Completed, ${n-r} left
|
|
10
|
-
${t}`}return`ERROR: Unknown method "${f}". Use create, append, or get.`}catch(t){return`ERROR: Goal failure: ${t instanceof Error?t.message:String(t)}`}};export{
|
|
10
|
+
${t}`}return`ERROR: Unknown method "${f}". Use create, append, or get.`}catch(t){return`ERROR: Goal failure: ${t instanceof Error?t.message:String(t)}`}};export{D as todo};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{g as F,h as C,i as y,j as P}from"./chunk-JMMO76HS.js";import{a as E}from"./chunk-2RTYI6K3.js";import{a as M}from"./chunk-JWNCKRN6.js";import{o as w}from"./chunk-5MJKHQVE.js";import{b as $}from"./chunk-KQNW7DK5.js";import"./chunk-Y6O7SAPD.js";import"./chunk-ZGORMZE5.js";import{z as R}from"./chunk-NPXJIGAI.js";import p from"fs";import N from"path";var q=async(S,v={})=>{let n=M(S,["path","allowMultiple","searchContent*","replaceContent*","newContent*"]),e=n.path;if(!e)return'ERROR: Missing "path" argument for PatchFile.';let{resolvedPath:O,isTildeResolved:T}=R(e);e=O;let{patchPairs:i,allowMultiple:b,error:d}=F(n);if(d)return`ERROR: ${d}`;if(i.length===0)return"ERROR: No valid replacement pairs found. Use searchContent1, newContent1, etc.";let k=n.allowMultiple!==void 0?n.allowMultiple===!0||String(n.allowMultiple).toLowerCase()==="true":b,l=N.resolve(process.cwd(),e);try{if(!p.existsSync(l))return`ERROR: File [${e}] does not exist. Use WriteFile instead.`;let t=v.forcedContent||p.readFileSync(l,"utf8");t.startsWith("\uFEFF")&&(t=t.slice(1));let o=t.replace(/\r\n/g,`
|
|
2
|
+
`).replace(/\r/g,`
|
|
3
|
+
`),{content:a,results:s}=C(o,i,{allowMultiple:k}),c=s.filter(r=>!r.success),u=s.filter(r=>r.success);if(u.length===0)return`ERROR: Patch Failed to apply to [${e}].
|
|
4
|
+
${c.map(r=>` \u2022 ${r.error}`).join(`
|
|
5
|
+
`)}`;await E.recordFileChange(l,o),p.writeFileSync(l,a,"utf8");let{systemSettings:x}=await $(),f=P(o,a,s,12,x?.compressToolResults),{added:h,removed:m}=y(o,a);(h>0||m>0)&&await w({added:h,removed:m,file:e});let g=T?`
|
|
6
|
+
|
|
7
|
+
[Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:"";return c.length>0?`File [${e}] updated with some blocks failed. [${u.length}/${i.length}] blocks applied.
|
|
8
|
+
|
|
9
|
+
Failures:
|
|
10
|
+
${c.map(r=>` \u2022 ${r.error}`).join(`
|
|
11
|
+
`)}
|
|
12
|
+
|
|
13
|
+
${f}${g}`:`File [${e}] updated. [${s.length}/${i.length}] blocks applied.
|
|
14
|
+
|
|
15
|
+
${f}${g}`}catch(t){let o=t instanceof Error?t.message:String(t);return`ERROR: Failed to update file [${e}]: ${o}`}};export{q as update_file};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-O74INBF3.js";import"./chunk-JWNCKRN6.js";import"./chunk-NPXJIGAI.js";export{a as view_file};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-JWNCKRN6.js";var c=async(i,f={})=>{let o=r(i,["seconds","sec","time","timeout"]),a=o.seconds??o.sec??o.time??o.timeout??45,t=parseFloat(a);isNaN(t)&&(t=45),t<10?t=10:t>120&&(t=120);let n=(e=>{if(e>=60){let m=Math.floor(e/60),s=e%60;return`${m}m${s>0?` ${s}s`:""}`}return`${e}s`})(t);return await new Promise(e=>setTimeout(e,t*1e3)),`Waited for ${n}${t===120?" (Max: 120s)":""}${t===10?" (Min: 10s)":""}.`},$=c;export{$ as default,c as wait};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as b}from"./chunk-YX4X2ZTX.js";import{a as _}from"./chunk-
|
|
1
|
+
import{a as b}from"./chunk-YX4X2ZTX.js";import{a as _}from"./chunk-JWNCKRN6.js";import{d as D}from"./chunk-NPXJIGAI.js";import j from"puppeteer";import P from"fs";import U from"path";var V=async q=>{let{query:E,limit:F=5,aiMode:L=!1}=_(q,["query","limit","aiMode"]);if(!E)return'ERROR: Missing "query" argument for WebSearch.';let g=3,I=null;if(L){let u=`Query: ${E}
|
|
2
2
|
|
|
3
3
|
RESPONSE RULES:
|
|
4
4
|
- ANSWER CONCISELY (TL;DR style) WITH REQUIRED DETAILS UNDER 300 WORDS.
|
|
@@ -13,28 +13,28 @@ Sources:
|
|
|
13
13
|
|
|
14
14
|
- LIST ONE RAW URL PER BULLET.
|
|
15
15
|
- DO NOT USE MARKDOWN LINKS.
|
|
16
|
-
- DO NOT INCLUDE ANY TEXT, NOTES, OR EXPLANATIONS AFTER THE SOURCES SECTION.`;for(let s=1;s<=g;s++){let o=null;try{let
|
|
16
|
+
- DO NOT INCLUDE ANY TEXT, NOTES, OR EXPLANATIONS AFTER THE SOURCES SECTION.`;for(let s=1;s<=g;s++){let o=null;try{let i=b();o=await j.launch({headless:!0,executablePath:i.executablePath||void 0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-gpu","--disable-dev-shm-usage"]});let n=await o.newPage();await n.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.7778.178 Safari/537.36"),await n.setViewport({width:1366,height:768});let d=s===1?Math.random()*1e3+500:Math.random()*2e3+1e3;await new Promise(e=>setTimeout(e,d));let x=`https://search.brave.com/ask?q=${encodeURIComponent(u)}&source=web`;await n.goto(x,{waitUntil:"domcontentloaded",timeout:18e4});let l=null,W=45e3,w=Date.now();for(;Date.now()-w<W;){if(l=await n.evaluate(()=>{let e=Array.from(document.querySelectorAll('.message:not(.user), .answer-text, .llm-content, [data-type="answer"]')),t="";if(e.length>0&&(t=e.map(T=>T.innerText.trim()).filter(Boolean).join(`
|
|
17
17
|
|
|
18
18
|
`)),t||(t=document.body.innerText),t.includes("anomaly"))throw new Error("ANOMALY_DETECTED");let R=!!document.querySelector('.spinner, .loading, .typing, .streaming, [data-streaming="true"], [data-state="loading"], svg.animate-spin, circle[cx], div[class*="spin"]'),r=e[0]||document.body,f=r?r.innerText.trim():"",O=/^(?:[✓✔]\s*)?Finished/i.test(f)||!!(r&&r.querySelector(".status-finished, .finished")),A=!R&&(O||t.includes("Sources:")&&!R),v={};return document.querySelectorAll("a[href]").forEach(T=>{let a=T.getAttribute("href")||T.href||"";if(a.includes("uddg=")&&(a=decodeURIComponent(a.split("uddg=")[1].split("&")[0])),a.includes("url=")&&(a=decodeURIComponent(a.split("url=")[1].split("&")[0])),a&&(a.startsWith("http://")||a.startsWith("https://"))&&!a.includes("search.brave.com")){let k=T.innerText.trim();k&&(v[k]=a),T.textContent=a}}),{isFinished:A,text:t,hrefMap:v}}),l&&l.isFinished){await new Promise(e=>setTimeout(e,1e3));break}await new Promise(e=>setTimeout(e,1e3))}let c=(l?l.text:"")||"",h=l?l.hrefMap||{}:{},N="DO NOT INCLUDE ANY TEXT, NOTES, OR EXPLANATIONS AFTER THE SOURCES SECTION.";c.includes(N)&&(c=c.split(N).pop()),c=c.replace(/^.*?(Ctrl \+ Shift \+ O|Ask\nAll\nImages)/s,"").replace(/AI-generated answer\. Please verify critical facts\..*/s,"").replace(/Brave Search uses private usage metrics.*/s,"");let m=c,S="";if(c.includes("Sources:")){let e=c.split("Sources:");m=e[0],S=e.slice(1).join("Sources:")}let p=[];for(let e of m.split(`
|
|
19
19
|
`)){let t=e.trim();t&&(/^(View all|Finished|Searching|Answering|Thinking)$/i.test(t)||/^[\+\-]?\d+$/.test(t)||t.includes("search.brave.com")||t.startsWith("https://www.youtube.com/watch")||t.startsWith("https://youtube.com/watch")||p.push(e))}let C=p.join(`
|
|
20
20
|
`).replace(/^(?:[\+\-]?\d+\s*)+/i,"").replace(/\n{3,}/g,`
|
|
21
21
|
|
|
22
|
-
`).trim(),y=e=>!e||e.includes("search.brave.com")||e.includes("youtube.com")||e.includes("youtu.be")
|
|
22
|
+
`).trim(),y=e=>!e||e.includes("search.brave.com")||e.includes("youtube.com")||e.includes("youtu.be"),M="";if(S){let e=S.match(/https?:\/\/[^\s\)\>]+/g)||[],t=[];for(let r of e){let f=r.replace(/[\.\,\;]+$/,""),O=Object.keys(h).find(A=>A.startsWith(f)||f.startsWith(A));O&&h[O]&&(f=h[O]),y(f)||t.push(f)}Object.values(h).forEach(r=>{!y(r)&&!t.includes(r)&&t.push(r)});let R=Array.from(new Set(t));R.length>0&&(M=`Sources:
|
|
23
23
|
`+R.map(r=>`- ${r}`).join(`
|
|
24
|
-
`))}let
|
|
24
|
+
`))}let $=C+(M?`
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
`+M:"");if(!$||/^(\+\d+|Searching|Answering|Thinking|Finished)$/i.test($))throw new Error("EMPTY_AI_RESPONSE");return await o.close(),`AI Search results for [${E}]:
|
|
27
27
|
|
|
28
|
-
${
|
|
28
|
+
${$}`}catch(i){I=i;try{let n=U.join(D,"web_tools","search","ai_mode");P.mkdirSync(n,{recursive:!0});let d=b().executablePath||"(puppeteer default discovery)";P.writeFileSync(U.join(n,"ERROR.txt"),`[${new Date().toISOString()}] ${i.message}
|
|
29
29
|
executablePath: ${d}
|
|
30
|
-
`)}catch{}if(o&&await o.close(),s<g){let
|
|
30
|
+
`)}catch{}if(o&&await o.close(),s<g){let n=Math.pow(2,s)*1e3;await new Promise(d=>setTimeout(d,n))}}}}for(let u=1;u<=g;u++){let s=null;try{let o=b();s=await j.launch({headless:!0,executablePath:o.executablePath||void 0,args:["--no-sandbox","--disable-setuid-sandbox","--disable-gpu","--disable-dev-shm-usage"]});let i=await s.newPage();await i.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.7778.178 Safari/537.36"),await i.setViewport({width:1366,height:768});let n=u===1?Math.random()*1e3+500:Math.random()*2e3+1e3;await new Promise(w=>setTimeout(w,n));let d=`https://html.duckduckgo.com/html/?q=${encodeURIComponent(E)}`;await i.goto(d,{waitUntil:"networkidle2",timeout:18e4});let x=await i.$$eval(".result",(w,c)=>w.slice(0,c).map((h,N)=>{let m=h.querySelector(".result__a"),S=h.querySelector(".result__snippet"),p=m?m.href:"";p.includes("uddg=")&&(p=decodeURIComponent(p.split("uddg=")[1].split("&")[0]));let C=m?m.innerText.trim():"No Title",y=S?S.innerText.trim():"No Snippet";return`${N+1}. ${C}
|
|
31
31
|
Source: ${p}
|
|
32
|
-
Snippet: ${y}`}),F);if(x.length===0){if((await
|
|
32
|
+
Snippet: ${y}`}),F);if(x.length===0){if((await i.evaluate(()=>document.body.innerText)).includes("anomaly"))throw new Error("ANOMALY_DETECTED");return await s.close(),`No results found for query: [${E}].`}let l=x.join(`
|
|
33
33
|
|
|
34
34
|
`);return await s.close(),`${L?`AI Mode temporarily failed, used Standard search.
|
|
35
35
|
|
|
36
36
|
`:""}Search results for [${E}]:
|
|
37
37
|
|
|
38
|
-
${l}`}catch(o){I=o,s&&await s.close();try{let
|
|
39
|
-
executablePath: ${
|
|
40
|
-
`)}catch{}if(u<g){let
|
|
38
|
+
${l}`}catch(o){I=o,s&&await s.close();try{let i=U.join(D,"web_tools","search","standard_mode");P.mkdirSync(i,{recursive:!0});let n=b().executablePath||"(puppeteer default discovery)";P.writeFileSync(U.join(i,"ERROR.txt"),`[${new Date().toISOString()}] ${o.message}
|
|
39
|
+
executablePath: ${n}
|
|
40
|
+
`)}catch{}if(u<g){let i=Math.pow(2,u)*1e3;await new Promise(n=>setTimeout(n,i))}}}return`ERROR: Search failed after ${g+1} attempts. Last error: ${I.message}`};export{V as web_search};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{a as c}from"./chunk-2RTYI6K3.js";import{a as s}from"./chunk-JWNCKRN6.js";import"./chunk-ZGORMZE5.js";import"./chunk-NPXJIGAI.js";import l from"fs-extra";import a from"path";import u from"html-to-docx";var w=async m=>{let{path:t,content:r}=s(m,["path","content"]);if(!t)return'ERROR: Missing "path" argument for write_docx.';if(!r)return'ERROR: Missing "content" (HTML) for write_docx.';let o=a.resolve(process.cwd(),t);try{await l.ensureDir(a.dirname(o)),await c.recordFileChange(o);let e=a.basename(t),n=r.includes("<html")?r:`
|
|
2
|
+
<!DOCTYPE html>
|
|
3
|
+
<html lang="en">
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<title>FluxFlow Document</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
${r}
|
|
10
|
+
</body>
|
|
11
|
+
</html>
|
|
12
|
+
`,i=await u(n,null,{title:`FluxFlow_${e}`,creator:"FluxFlow CLI",description:"Generated by Agentic AI System",table:{row:{cantSplit:!0}},footer:!0,pageNumber:!0});return await l.writeFile(o,i),`Word document [${t}] generated successfully.
|
|
13
|
+
- Size: ${(i.length/1024).toFixed(1)} KB`}catch(e){let n=e instanceof Error?e.message:String(e);return`ERROR: Failed to generate DOCX [${t}]: ${n}`}};export{w as write_docx};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as k}from"./chunk-2RTYI6K3.js";import{a as P}from"./chunk-
|
|
1
|
+
import{a as k}from"./chunk-2RTYI6K3.js";import{a as P}from"./chunk-JWNCKRN6.js";import{o as x}from"./chunk-5MJKHQVE.js";import{b as j}from"./chunk-KQNW7DK5.js";import"./chunk-Y6O7SAPD.js";import"./chunk-ZGORMZE5.js";import{c as F,z as C}from"./chunk-NPXJIGAI.js";import t from"fs";import f from"path";import T from"crypto";var G=async(A,B={})=>{let{path:e,content:p}=P(A,["path","content"]);if(!e)return'ERROR: Missing "path" argument for WriteFile.';if(p===void 0)return'ERROR: Missing "content" argument for WriteFile.';let{resolvedPath:L,isTildeResolved:O}=C(e);e=L,p=p.replace(/^```[\w]*\n?/,"").replace(/```\s*$/,"").replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
3
|
`);let n=f.resolve(process.cwd(),e),v=f.dirname(n);try{await k.recordFileChange(n);let{systemSettings:o}=await j(),h=o?.overwriteProtection!==!1,c="",R=0;if(t.existsSync(n))try{let i=t.readFileSync(n,"utf8").split(/\r?\n/);if(R=i.length,!h)c="";else if(i.length<=50)c=`Old File contents:
|
|
4
4
|
${i.map((l,d)=>`${d+1} | ${l}`).join(`
|