Lines 32-111javascript
33`)}${B}`}}catch(m){return{success:!1,output:"",error:`[read_file]: ${E(m)}`}}}},{name:"write_file",description:"Create or overwrite a file with content",safety:"confirm",parameters:{path:{type:"string",description:"File path to write",required:!0},content:{type:"string",description:"Content to write",required:!0}},execute:async f=>{try{if(!f.path)return{success:!1,output:"",error:"[write_file]: path is required"};if(f.content===void 0)return{success:!1,output:"",error:"[write_file]: content is required"};let m=e(f.path);return Ms.existsSync(m)&&await Ue(m),await P.mkdir(Ce.dirname(m),{recursiv ...
35`).map(ze=>ze.trimEnd()).join(`
36`),Z=B(h),ve=B(y),ke=Es(Z,ve);ke===1&&(v=ve,k=ke)}if(k===0)return{success:!1,output:"",error:`[edit_file]: old_content not found in file. Check for whitespace/newline differences. File preview: "${
38`).map(Z=>Z.trimEnd()).join(`
39`))(h):h).replace(v,w);await P.writeFile(m,_,"utf-8");let G=wt(f.path,h,_);return{success:!0,output:`Edited: ${f.path}
40${G}`}}catch(m){return{success:!1,output:"",error:`[edit_file]: ${E(m)}`}}}},{name:"patch_file",description:"Replace lines in a file using line numbers. More reliable than edit_file. Use read_file first to see line numbers.",safety:"confirm",parameters:{path:{type:"string",description:"File path",required:!0},start_line:{type:
41`),w=y.length,k=f.start_line,v=f.end_line;if(k<1||k>w)return{success:!1,output:"",error:`[patch_file]: start_line ${k} is out of range (file has ${w} lines)`};if(v<k||v>w)return{success:!1,output:"",error:`[patch_file]: end_line ${v} is out of range (start_line=${k}, total=${w})`};await Ue(m);let S=y.slice(0,k-1),T=y.slice(v),_=f.new_content.split(`
42`),G=[...S,..._,...T].join(`
43`);await P.writeFile(m,G,"utf-8");let B=wt(f.path,h,G),Z=v-k+1,ve=_.length;return{success:!0,output:`Patched: ${f.path} (replaced ${Z} lines with ${ve})
44${B}`}}catch(m){return{success:!1,output:"",error:`[patch_file]: ${E(m)}`}}}},{name:"search_and_replace",description:"Find and replace all occurrences of a pattern in a file. Supports regex. Returns count of replacements made.",safety:"confirm",parameters:{path:{type:"string",description:"File path",required:!0},search:{type:"string",description:"Search pattern (string or regex)",required:!0},replace:{type:"string",description:"Replacement string",required:!0},is_regex:{type:"boolean",description:"Treat search as regex (default: false)",required:!1}},execute:async f=>{try{if(!f.path)return{suc ...
45`)}}catch(m){return{success:!1,output:"",error:`[get_file_info]: ${E(m)}`}}}}]}function Es(t,e){let s=0,r=0;for(;;){
46`,c.isDirectory()){let d=e+(l?" ":"\u2502 ");i+=await qr(Ce.join(t,c.name),d,s,r+1)}}return i}function ki(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}var Hr=require("child_process");var Br=require("child_process"),Ut=class{processes=new Map;config;nextId=1;constructor(e){this.config={workingDir:e.workingDir,defaultTimeout:e.defaultTimeout||3e5,maxOutputSize:e.maxOutputSize||5e5}}start(e,s){let r=`bg_${this.nextId++}`,n=s?.timeout||this.config.defaultTimeout,o=(0,Br.spawn)(e,{shell:!0,cwd:this.config.workingDir,env:{...process.env,.. ...
47Error: ${a.message}`}),n>0&&setTimeout(()=>{i.status==="running"&&(this.kill(r),i.status="timeout",i.stderr+=`
48Process timed out after ${n}ms`)},n),this.processes.set(r,i),r}readOutput(e,s){let r=this.processes.get(e);if(!r)return{success:!1,output:"",status:"not_found",error:`Background process ${e} not found`};let n=s?.type||"both",o
49`),o+=r.stderr),s?.lastLines&&(o=o.split(`
50`).slice(-s.lastLines).join(`
51`)),{success:!0,output:o,status:r.status}}kill(e){let s=this.processes.get(e);if(!s)return!1;if(s.process.pid)try{process.kill(-s.process.pid,"SIGTERM")}catch{try{process.kill(s.process.pid,"SIGTERM")}catch{}}return s.status="killed",!0
52PID: ${Wr(t).getProcess(c)?.pid}
53Use bash_output to read output: bash_output(process_id="${c}")`}}return new Promise(c=>{let l=(0,Hr.exec)(r,{cwd:t,timeout:o,maxBuffer:10485760,env:{...process.env,FORCE_COLOR:"0"}}),u="",p="";l.stdout?.on("data",d=>{u+=d}),l.stderr?.on("data",d=>{p+=d}),l.on("close",d=>{let m=(h,y)=>h.length>8e3?h.slice(0,8e3)+`
54... [${y} truncated \u2014 ${h.length} chars total]`:h;c(d===0?{success:!0,output:m(u,"stdout")||"(no output)"}:{success:!1,output:m(u,"stdout"),error:m(p||`Exit code: ${d}`,"stderr")})}),l.on("error",d=>{c({success:!1,output:"",error:d.message})})})}}}var qt=x(require("fs/promises")),Ae=x(require("path")),Ti=new Set(["node_modules",".git","__pycache__",".venv","dist","build",".next",".cache"]),_i=new Set([".ts",".js",".tsx",".jsx",".py",".go",".rs",".java",".c",".cpp",".h",".css",".html",".json",".md",".yaml",".yml",".toml"]);function zr(t){return{name:"search_codebase",description:"Search fo ...
56... and ${n.length-50} more matches`:"";return{success:!0,output:o+i}}catch(s){return{success:!1,output:"",error:`Search failed: ${E(s)}`}}}}}async
57`),l=Ae.relative(r,i);for(let u=0;u<c.length;u++)new RegExp(e,"i").test(c[u])&&s.push(`${l}:${u+
58`);for(let a of i){let c=a.match(/^(.+?)\((\d+),\d+\):\s*(error|warning)\s+
59`);for(let a of i){let c=a.match(/^\s*(\d+):(\d+)\s+(error|warning)\s+(.+?)\s+(\S+)$/);c&&e.push({file:"unknown",line:parseInt(c[1],10),severity:c[3]==="error"?"error":"warning",message:`${c[4]} (${c[5]})`,source:"eslint"})}}}return e}function Ai(t,e,s){let r;
60`);for(let i=0;i<o.length;i++){let a=o[i],c=i+1;/\bconsole\.(log|debug)\b/.test(a)
61`)}function Mi(t,e){let s=[];for(let r of t)if(r.source==="pattern"&&r.message.includes("console.log")){let n=Re.join(e,r.file);try{let i=se.readFileSync(n,"utf-8").split(`
62`);r.line>0&&r.line<=i.length&&(i[r.line-1]="// "+i[r.line-1],se.writeFileSync(n,i.join(`
63`),"utf-8"),s.push({bug:r,fixed:!0,action:"Commented out console.log"}))}catch{s.push({bug:r,fixed:!1,action:"Failed to read/write file"})}}else s.push({bug:r,fixed:!1,action:"Requires manual fix or LLM assistance"});return s}function Jr(t){return{name:"detect_bugs",description:"Scan the project for bugs using TypeScript checking, ESLint, and pattern analysis. Returns a report of found issues.",safety:"safe",parameters:{path:{type:"string",description:"Project path to scan (default: current directory)",required:!1},fix:{type:"string",description:'Set to "true" to auto-fix simple issues',requir ...
65 Auto-fixed: ${i}/${n.length} issues`}}return{success:!0,output:Vr(n)}}catch(n){return{success:!1,output:"",error:`Bug detection failed: ${n instanceof Error?n.
66`),e=e.replace(/<(br|hr)\s*\/?>/gi,`
CriticalSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution with blocking evidence.
dist/index.jsView on unpkg · L52 67`),e=e.replace(/<\/?(ul|ol)>/gi,`
68`),e=e.replace(/<h([1-6])[^>]*>([\s\S]*?)<\/h\1>/gi,(s,r,n)=>`
69${"#".repeat(parseInt(r))} ${n.replace(/<[^>]+>/g,"").trim()}
70`),e=e.replace(/<a[^>]+href=["']([^"']+)["'][^>]*>([\s\S]*?)<\/a>/gi,(s,r,n)=>{let o=n.replace(/<[^>]
72`),e=e.replace(/^\s+|\s+$/gm,""),e.trim()}function Pi(t){let e=t.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(e)return e[1].replace(/<[^>]+>/g,"").trim();let s=t.match(/<h1[^>]*>([\s\S]*?)<\/h1>/i);return s?s[1].replace(/<[^>]+>/g,"").trim():"Untitled"}function Oi(t,e){let s=[],r=/<a[^>]+href=["']([^"']+)["'][^>]*>([\s\S]*?)<\/a>/gi,n,o=new Set;for(;(n=r.exec(t))!==null;){let i=n[1].trim(),a=n[2].replace(/<[^>]+>/g,"").trim();if(!(i.startsWith("#")||i.startsWith("javascript:")||i.startsWith("mailto:"))){try{i=new URL(i,e).href}catch{continue}o.has(i)||(o.add(i),s.push({text:a||i,url:i}))}}retu ...
74[... content truncated ...]`),{success:!0,output:[`# ${o}`,`URL: ${r}`,`Fetched: ${new Date().toISOString()}`,"",i].join(`
75`)}}catch(s){let r=s instanceof Error?s.message:String(s);return{success:!1,output:"",error:`Failed to scrape ${e}: ${r}`}}}},{name:"extract_links",description:"Extract all links (URLs) from a web page. Returns a list of link text and URLs. Useful for finding documentation pages, navigation, or related resources.",safety:"safe",parameters:{url:{type:"string",description:
76`);return{success:!0,output:`Found ${i.length} links:
78${a}`}}catch(r){let n=r instanceof Error?r.message:String(r);return{success:!1,output:"",error:`Failed to extract links from ${e}: ${n}`}}}}]}var Fi=3600*1e3,tt=new Map;function Di(t){let e=tt.get(t.toLowerCase().trim());return e?Date.now()-e.timestamp>Fi?(tt.delete(t.toLowerCase().trim()),null):e.results:null}function Li(t,e){if(tt.size>200){let s=tt.keys().next().value;s!==void 0&&tt.delete(s)}tt.set(t.toLowerCase().trim(),{results:e,timestamp:Date.now()})}async function Ni(t,e){let s=process.env.BRAVE_API_KEY||process.env.BRAVE_SEARCH_API_KEY;if(!s)return null;try{let r=new URLSearchParams( ...
79`)}}catch(r){return{success:!1,output:"",error:`Search failed: ${r instanceof Error?r.message:String(r)}`}}}}}var ye=x(require
83`).trim(),pages:n,metadata:s}}function on(t){let e=[],s=/\(([^)]*)\)\s*Tj/g,r;for(;(r=s.exec(t))!==null;)e.push(qe(r[1]));let n=/\[((?:\([^)]*\)|[^])*?)\]\s*TJ/g;for(;(r=n.exec(t))!==null;){let c=r[1].match(/\(([^)]*)\)/g);if(c){let l=c.map(u=>qe(u.slice(1,-1))).join("");e.push(l)}}let o=/\(([^)]*)\)\s*'/g;for(;(r=o.exec(t))!==null;)e.push(qe(r[1]));let i=e.join(" ");return i=i.replace(/\\n/g,`
84`).replace(/\\r/g,"").replace(/\\t/g," ").replace(/\\\(/g,"(").replace(/\\\)/g,")").replace(/\\\\/g,"\\"),i}function qe(t){return t.replace(/\\n/g,`
85`).replace(/\\r/g,"\r").replace(/\\t/g," ").replace(/\\\(/g,"(").replace(/\\\)/g,")").replace(/\\\\/g,"\\").replace(/\\(\d{3})/g,(e,s)=>String.fromCharCode(parseInt(s,8)))}function cn(t){let e=s=>an.resolve(t,s);return[{name:"read_pdf",description:"Read a PDF file and extract its text content. Returns the text from the PDF, useful for reading documentation, papers, specifications, contracts, etc. For scanned PDFs (images only), text extraction may be limited.",safety:"safe",parameters:{path:{type:"string",description:"Path to the PDF file (relative to working directory)",required:!0},page:{typ ...
87[No extractable text found \u2014 this may be a scanned/image-only PDF. Use OCR tools for scanned documents.]`};let l=i;return l.length>rn&&(l=l.slice(0,rn)+`
89[... content truncated ...]`),{success:!0,output:`${[`PDF: ${s.path}`,`Pages: ${a}`,c.title?`Title: ${c.title}`:"",c.author?`Author: ${c.
91${l}`}}catch(o){return{success:!1,output:"",error:`Failed to read PDF: ${o instanceof Error?o.message:String(o)}`}}}},{name:"pdf_metadata",description:
92`)}}catch(n){return{success:!1,output:"",error:`Failed to read PDF metadata: ${n instanceof Error?n.message:String(n)}`}}}}]}var pn=require("child_process"
93Errors/Warnings:`:"Errors:"),o.push(n.stderr)),!n.stdout&&!n.stderr&&o.push("(no output)"),{success:n.success,output:o.join(`
HighCommand Output Exfiltration
Source combines command execution, command-output handling, and outbound requests; review data flow before blocking.
dist/index.jsView on unpkg · L77 94`),error:n.success?void 0:n.stderr||`Exit code: ${n.exitCode}`}}}]}var zt=x(require("fs")),le=x(require("path"));var Wi=["images.unsplash.com","unsplash.com","images.pexels.com"
97Size: ${n.length} bytes`}}catch(n){return{success:!1,output:"",error:`download failed: ${E(n)}`}}}}}var Gt=x(require("fs"));var Vt=x(require("path"));var Ds=15e3,Sn=5;function Tn(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function _n(t,e){return t[e]|t[e+1]<<8}function Zi(t){let e=2;for(;e<t.length-9;){if(t[e]!==255){e++;continue}let s=t[e+1],r=(t[e+2]<<8)+t[e+3];if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(s))return{height:(t[e+5]<<8)+t[e+6],width:(t[e+7]<<8)+t[e+8]};e+=2+r}return{}}function ea(t){let e=t.toString("ascii",12,16);if(e==="VP8X"&&t.length>=30)return{wi ...
99Context from user: "${t}"
101Return this exact JSON structure \u2014 no markdown, no commentary:
103 "description": "one sentence describing what is in the image",
107 "suggestedUse": "generic",
108 "summary": "one short sentence verdict"
Long lines were clipped for display.