Lines 1-33javascript
1import{createRequire as MV}from"node:module";var UV=Object.defineProperty;var BV=($)=>$;function LV($,Z){this[$]=BV.bind(null,Z)}var S$=($,Z)=>{for(var Q in Z)UV($,Q,{get:Z[Q],enumerable:!0,configurable:!0,set:LV.bind(Z,Q)})};var F0=($,Z)=>()=>($&&(Z=$($=0)),Z);var D$=MV(import.meta.url);import{dirname as K7,resolve as PV}from"node:path";import{fileURLToPath as IV}from"node:url";function RV(){return!!globalThis.__WINDSURF_COMPILED__}function _7(){return RV()?K7(process.execPath):AV}var AV;var w7=F0(()=>{AV=PV(K7(IV(import.meta.url)),"..","..")});import{readFileSync as tZ,existsSync as eZ,mkdir ...
2`)){let J=Q.trim();if(!J||J.startsWith("#"))continue;let X=J.indexOf("=");if(X===-1)continue;let Y=J.slice(0,X).trim(),V=J.slice(X+1).trim();if(V.startsWith('"')&&V.endsWith('"')||V.startsWith("'")&&V.endsWith("'"))V=V.slice(1,-1);else{let z=V.indexOf(" #");if(z!==-1)V=V.slice(0,z).trim()}if(!process.env[Y])process.env[Y]=V}}function _V($=$8(Q8,"config.json")){if(!eZ($))return;let Z;try{Z=JSON.parse(tZ($,"utf-8"))}catch(Q){console.warn(`[WARN] config.json: failed to parse ${$}: ${Q.message}`);return}if(!Z||typeof Z!=="object"||Array.isArray(Z))return;for(let[Q,J]of Object.entries(Z)){if(Q.star ...
3`)}catch(V){try{let z=D3();O3(z,{recursive:!0}),j3(q3(z,`ls-proto-${process.pid}-errors.log`),`${new Date().toISOString()} ${Z||""} ${Q||""}: ${V.message}
4`)}catch{}}}var Dz=0,P8,Az,Fz,Kz,_z,vz,xz;var P3=F0(()=>{P8=new Map([[5,"find"],[8,"run_command"],[13,"search_web"],[10,"view_file"],[19,"list_dir"],[33,"grep_v2"],[37,"read_url_content"]]),Az=new Map([[0,"UNSPECIFIED"],[1,"OPENAI"]]),Fz=new Map([[0,"UNSPECIFIED"],[1,"O3"],[2,"GPT_4_1"],[3,"O4_MINI"]]),Kz=new Map([[0,"UNSPECIFIED"],[1,"DISABLED"],[2,"ALLOWLIST"
7`).trim(),Q=Z.match(/<([a-z][-a-z_]*)[^>]*>[\s\S]*?<\/\1>/g);if(Q?.length){let X=Q.map((Y)=>Y.match(/^<([a-z][-a-z_]*)/)?.[1]).filter(Boolean).filter((Y)=>!E3.has(Y));if(X.length)console.error(`[META_TAG_AUDIT] Unknown XML tags in user message: ${[...new Set(X)].join(", ")}`)}return Z}function $W($){let Z=String($||"");Z=Z.replace(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?/g,"<ts>").replace(/\b(Today(?:'s)?\s+(?:date|is)(?:\s+is)?\s*[:\-
9`),Z=Z.replace(new RegExp(`^([ \\t]*Recent commits\\s*:)[ \\t]*\\n[\\s\\S]*?${J}`,"gim"),`$1
11`),Z=Z.replace(new RegExp(`^([ \\t]*Recent files\\s*:)[ \\t]*\\n[\\s\\S]*?${J}`,"gim"),`$1
13`),Z=Z.replace(/(?<![`'"\w])(?=[a-f0-9]*\d)(?=[a-f0-9]*[a-f])[a-f0-9]{7,12}(?![`'"\w])/gi,"<gitsha>"),Z}function K$($){if($===null||typeof $!=="object")return JSON.stringify($);if(Array.isArray($))return"["+$.map(K$).join(",")+"]";return"{"+Object.keys($).sort().map((Q)=>JSON.stringify(Q)+":"+K$($[Q])).join(",")+"}"}function ZW($){if(typeof $?.text==="string")return{type:"text",text:K8($.text)};if(typeof $==="string")return{type:"text",text:K8($)};let Z=String($?.type||"").toLowerCase();if(Z==="image_url"||Z==="image"||Z==="input_image"){let Q=$?.image_url?.url||$?.url||"";if(typeof Q==="strin ...
14`).trim(),X=JW($);return{role:"assistant",text:J,tool_calls:X}}return{role:String(Z||"unknown"),content:B6($?.content)}}function C3($){if(process.env.CASCADE_REUSE_HASH_SYSTEM==="0")return"";let Z=$.filter((J)=>J?.role==="system");if(!Z.length)return"";let Q=Z.map((J)=>{let X=w8(J);if(Array.isArray(X.content))X.content=X.content.map((Y)=>{if(Y?.type==="text"&&typeof Y.text==="string")return{...Y,text:$W(Y.text)};return Y});return X});return l1(K$(Q),32)}function S3($={}){if(!$.emulateTools)return"";let Z=(Array.isArray($.tools)?$.tools.map((Q)=>{let J=Q?.function||Q;return{name:J?.name||"",des ...
15`)){let W=z.trim().match(/^(\d+)\s+(\d+)\s+(\d+)$/);if(!W)continue;let G=parseInt(W[1],10),H=parseInt(W[2],10),N=parseInt(W[3],10);if(Y.set(G,N),!X.has(H))X.set(H,[]);X.get(H).push(G)}let V=new Map;for(let z of Z){let W=0,G=0,H=new Set,N=[z];while(N.length){let O=N.pop();if(!Number.isInteger(O)||H.has(O))continue;if(H.add(O),Y.has(O))W+=Y.get(O)||0,G++;for(let D of X.get(O)||[])N.push(D)}if(G>0)V.set(z,{rssKb:W,rssBytes:W*1024,processCount:G})}r$={at:$,pidKey:Q,byRootPid:V}}catch(J){r$={at:$,pidKey:Q,byRootPid:new Map},j.debug(`LS RSS snapshot unavailable: ${J.message}`)}return r$.byRootPid}fu ...
HighChild Process
Package source references child process execution.
dist/app/index.jsView on unpkg · L13 HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
dist/app/index.jsView on unpkg · L1 HighCommand Output Exfiltration
Source combines command execution, command-output handling, and outbound requests; review data flow before blocking.
dist/app/index.jsView on unpkg · L1 16`);for(let B of M){if(!B)continue;if(/ERROR|error/.test(B))j.error(`[LS:${Z}] ${B}`);else j.debug(`[LS:${Z}] ${B}`)}}),P.stderr.on("data",(q)=>{let M=q.toString().trim().split(/\r?\n/);for(let B of M){if(!B)continue;let F=$5(B);j[F](`[LS:${Z}:stderr] ${B}`)}}),P.on("exit",(q,M)=>{j.warn(`LS instance ${Z} exited: code=${q} signal=${M}`);let B=Q0.get(Z),F=B?.process===P,w=_W(P);if(!w)T0.lastFailure=S4({kind:"process_exit",key:z1(Z),errorType:"ls_process_exit",code:q,signal:M,port:H,pid:P.pid||null});if(q===1)j.error("LS crashed on startup. Common causes:"),j.error(" 1. Binary incompatible with ...
17`)){let V=Y.trim();if(!V)continue;let z=V.match(/^(\d+)\s+(.*)$/);if(!z)continue;let W=parseInt(z[1],10),G=z[2],H=G.split(/\s+/,1)[0],N=!1;for(let O of J)if(O&&H===O){N=!0;break}if(!N)continue;if($++,Q.has(W))continue;if(W===process.pid)continue;try{process.kill(W,"SIGTERM"),Z++,j.info(`Killed orphan LS pid=${W} (${G.slice(0,80)}...)`)}catch(O){if(O.code!=="ESRCH")j.warn(`Could not kill orphan LS pid=${W}: ${O.message}`)}}}catch(X){j.warn(`cleanupOrphanLanguageServers: ${X.message}`)}return{scanned:$,killed:Z}}function a8(){let $=[];for(let[Z,Q]of Q0){A6(Q),_$.set(Z,{at:Date.now(),pid:Q?.proce ...
18`,X);if(Y===-1)break;let V=Y+7,z=$[Y+6]===13?V+1:V,W=$.indexOf(`
19endstream`,z);if(W===-1)break;let G=$.subarray(z,W);if(Q++,Q>PG)throw Error("PDF stream count exceeds safety limit");let H=Math.max(0,Y-500),O=$.subarray(H,Y).toString("latin1").includes("FlateDecode"),D;try{if(O){let P=MG(G,{maxOutputLength:X2});if(P.length>X2)throw Error("PDF decoded content exceeds safety limit");if(J+=P.length,J>H5)throw Error("PDF decoded content exceeds safety limit");D=P.toString("latin1")}else{if(J+=G.length,G.length>X2||J>H5)throw Error("PDF decoded content exceeds safety limit");D=G.toString("latin1")}}catch(P){if(/limit|exceed|maxOutputLength|Buffer larger/i.test(P. ...
21`)}function RG($){let Z=[],Q="",J=$.match(/BT[\s\S]*?ET/g);if(!J)return"";for(let X of J){let Y=X.matchAll(/\(([^)]*)\)\s*Tj/g);for(let z of Y)Q+=N5(z[1]);let V=X.matchAll(/\[([^\]]*)\]\s*TJ/gi);for(let z of V){let G=z[1].matchAll(/\(([^)]*)\)|(-?\d+(?:\.\d+)?)/g);for(let H of G)if(H[1]!==void 0)Q+=N5(H[1]);else if(H[2]!==void 0){if(parseFloat(H[2])<-100)Q+=" "}}if(/\d+\s+(?:-?\d+(?:\.\d+)?)\s+T[dD]/g.test(X)){if(Q.trim())Z.push(Q.trim()),Q=""}}if(Q.trim())Z.push(Q.trim());return Z.join(`
22`)}function N5($){return $.replace(/\\([nrtbf()\\]|\d{1,3})/g,(Z,Q)=>{if(Q==="n")return`
23`;if(Q==="r")return"\r";if(Q==="t")return"\t";if(Q==="b")return"\b";if(Q==="f")return"\f";if(Q==="("||Q===")"||Q==="\\")return Q;return String.fromCharCode(parseInt(Q,8))})}function T6($){try{let Z=Buffer.from($,"base64");if(Z.length<5||Z.subarray(0,5).toString()!=="%PDF-")return null;let Q=IG(Z);if(!Q.trim())return j.warn("PDF has no extractable text layer (scanned/image-only PDF)"),{text:"",pageCount:0};let J=(Z.toString("latin1").match(/\/Type\s*\/Page\b/g)||[]).length;return{text:Q,pageCount:J}}catch(Z){if(j.warn(`PDF extraction failed: ${Z.message}`),/exceeds safety limit|maxOutputLength| ...
24[PDF Document — ${V.pageCount} page(s)]
26`,j.info(`PDF extracted: ${V.pageCount} pages, ${V.text.length} chars`);else Z+=`
27[PDF Document — no extractable text (scanned/image-only PDF)]
28`}}else if(J.type==="image"){let X=J.source||{};if((X.media_type||"").toLowerCase()==="application/pdf"&&X.data){let V=T6(X.data);if(V?.text)Z+=`
29[PDF Document — ${V.pageCount} page(s)]
31`;continue}try{if((X.type==="base64"||!X.type)&&X.data){if(X.data.length>H2){j.warn("Image base64 exceeds size limit, skipping");continue}Q.push({base64_data:X.data,mime_type:X.media_type||"image/png"})}else if(X.type==="url"&&X.url)Q.push(await G2(X.url))}catch(V){j.warn(`Image extraction failed: ${V.message}`)}}else if(J.type==="image_url"){let X=J.image_url?.url||"";try{if(X.startsWith("data:")){if(X.slice(0,40).toLowerCase().startsWith("data:application/pdf")){let z=U5(X);if(z?.base64_data){let W=T6(z.base64_data);if(W?.text)Z+=`
32[PDF Document — ${W.pageCount} page(s)]
Long lines were clipped for display.