@ev-ai/agent-hook 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hook.mjs CHANGED
@@ -1,62 +1,62 @@
1
1
  import { createRequire as __createRequire } from 'node:module';
2
2
  const require = __createRequire(import.meta.url);
3
3
 
4
- var C_=Object.create;var Bo=Object.defineProperty;var A_=Object.getOwnPropertyDescriptor;var b_=Object.getOwnPropertyNames;var O_=Object.getPrototypeOf,k_=Object.prototype.hasOwnProperty;var s=(e,t)=>Bo(e,"name",{value:t,configurable:!0}),at=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Y=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var x_=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of b_(t))!k_.call(e,o)&&o!==n&&Bo(e,o,{get:()=>t[o],enumerable:!(r=A_(t,o))||r.enumerable});return e};var He=(e,t,n)=>(n=e!=null?C_(O_(e)):{},x_(t||!e||!e.__esModule?Bo(n,"default",{value:e,enumerable:!0}):n,e));var jr=Y(Ie=>{"use strict";Ie.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Ie.find=(e,t)=>e.nodes.find(n=>n.type===t);Ie.exceedsLimit=(e,t,n=1,r)=>r===!1||!Ie.isInteger(e)||!Ie.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Ie.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||r.type==="open"||r.type==="close")&&r.escaped!==!0&&(r.value="\\"+r.value,r.escaped=!0)};Ie.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Ie.isInvalidBrace=e=>e.type!=="brace"?!1:e.invalid===!0||e.dollar?!0:e.commas>>0+e.ranges>>0===0||e.open!==!0||e.close!==!0?(e.invalid=!0,!0):!1;Ie.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Ie.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Ie.flatten=(...e)=>{let t=[],n=s(r=>{for(let o=0;o<r.length;o++){let i=r[o];if(Array.isArray(i)){n(i);continue}i!==void 0&&t.push(i)}return t},"flat");return n(e),t}});var Br=Y((wM,Gu)=>{"use strict";var Ku=jr();Gu.exports=(e,t={})=>{let n=s((r,o={})=>{let i=t.escapeInvalid&&Ku.isInvalidBrace(o),c=r.invalid===!0&&t.escapeInvalid===!0,a="";if(r.value)return(i||c)&&Ku.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let u of r.nodes)a+=n(u);return a},"stringify");return n(e)}});var zu=Y((PM,Vu)=>{"use strict";Vu.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var tl=Y((MM,el)=>{"use strict";var Wu=zu(),Tt=s((e,t,n)=>{if(Wu(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(Wu(t)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let o=String(r.relaxZeros),i=String(r.shorthand),c=String(r.capture),a=String(r.wrap),u=e+":"+t+"="+o+i+c+a;if(Tt.cache.hasOwnProperty(u))return Tt.cache[u].result;let f=Math.min(e,t),l=Math.max(e,t);if(Math.abs(f-l)===1){let h=e+"|"+t;return r.capture?`(${h})`:r.wrap===!1?h:`(?:${h})`}let p=Qu(e)||Qu(t),d={min:e,max:t,a:f,b:l},m=[],g=[];if(p&&(d.isPadded=p,d.maxLen=String(d.max).length),f<0){let h=l<0?Math.abs(l):1;g=Ju(h,Math.abs(f),d,r),f=d.a=0}return l>=0&&(m=Ju(f,l,d,r)),d.negatives=g,d.positives=m,d.result=bE(g,m,r),r.capture===!0?d.result=`(${d.result})`:r.wrap!==!1&&m.length+g.length>1&&(d.result=`(?:${d.result})`),Tt.cache[u]=d,d.result},"toRegexRange");function bE(e,t,n){let r=Ts(e,t,"-",!1,n)||[],o=Ts(t,e,"",!1,n)||[],i=Ts(e,t,"-?",!0,n)||[];return r.concat(i).concat(o).join("|")}s(bE,"collatePatterns");function OE(e,t){let n=1,r=1,o=Xu(e,n),i=new Set([t]);for(;e<=o&&o<=t;)i.add(o),n+=1,o=Xu(e,n);for(o=qu(t+1,r)-1;e<o&&o<=t;)i.add(o),r+=1,o=qu(t+1,r)-1;return i=[...i],i.sort(IE),i}s(OE,"splitToRanges");function kE(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=xE(e,t),o=r.length,i="",c=0;for(let a=0;a<o;a++){let[u,f]=r[a];u===f?i+=u:u!=="0"||f!=="9"?i+=TE(u,f,n):c++}return c&&(i+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:i,count:[c],digits:o}}s(kE,"rangeToPattern");function Ju(e,t,n,r){let o=OE(e,t),i=[],c=e,a;for(let u=0;u<o.length;u++){let f=o[u],l=kE(String(c),String(f),r),p="";if(!n.isPadded&&a&&a.pattern===l.pattern){a.count.length>1&&a.count.pop(),a.count.push(l.count[0]),a.string=a.pattern+Zu(a.count),c=f+1;continue}n.isPadded&&(p=wE(f,n,r)),l.string=p+l.pattern+Zu(l.count),i.push(l),c=f+1,a=l}return i}s(Ju,"splitToPatterns");function Ts(e,t,n,r,o){let i=[];for(let c of e){let{string:a}=c;!r&&!Yu(t,"string",a)&&i.push(n+a),r&&Yu(t,"string",a)&&i.push(n+a)}return i}s(Ts,"filterPatterns");function xE(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}s(xE,"zip");function IE(e,t){return e>t?1:t>e?-1:0}s(IE,"compare");function Yu(e,t,n){return e.some(r=>r[t]===n)}s(Yu,"contains");function Xu(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}s(Xu,"countNines");function qu(e,t){return e-e%Math.pow(10,t)}s(qu,"countZeros");function Zu(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}s(Zu,"toQuantifier");function TE(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}s(TE,"toCharacterClass");function Qu(e){return/^-?(0+)\d/.test(e)}s(Qu,"hasPadding");function wE(e,t,n){if(!t.isPadded)return e;let r=Math.abs(t.maxLen-String(e).length),o=n.relaxZeros!==!1;switch(r){case 0:return"";case 1:return o?"0?":"0";case 2:return o?"0{0,2}":"00";default:return o?`0{0,${r}}`:`0{${r}}`}}s(wE,"padZeros");Tt.cache={};Tt.clearCache=()=>Tt.cache={};el.exports=Tt});var Ps=Y((vM,al)=>{"use strict";var NE=at("util"),rl=tl(),nl=s(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"isObject"),PE=s(e=>t=>e===!0?Number(t):String(t),"transform"),ws=s(e=>typeof e=="number"||typeof e=="string"&&e!=="","isValidValue"),Ln=s(e=>Number.isInteger(+e),"isNumber"),Ns=s(e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},"zeros"),ME=s((e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,"stringify"),LE=s((e,t,n)=>{if(t>0){let r=e[0]==="-"?"-":"";r&&(e=e.slice(1)),e=r+e.padStart(r?t-1:t,"0")}return n===!1?String(e):e},"pad"),Gr=s((e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},"toMaxLen"),vE=s((e,t,n)=>{e.negatives.sort((a,u)=>a<u?-1:a>u?1:0),e.positives.sort((a,u)=>a<u?-1:a>u?1:0);let r=t.capture?"":"?:",o="",i="",c;return e.positives.length&&(o=e.positives.map(a=>Gr(String(a),n)).join("|")),e.negatives.length&&(i=`-(${r}${e.negatives.map(a=>Gr(String(a),n)).join("|")})`),o&&i?c=`${o}|${i}`:c=o||i,t.wrap?`(${r}${c})`:c},"toSequence"),ol=s((e,t,n,r)=>{if(n)return rl(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let i=String.fromCharCode(t);return`[${o}-${i}]`},"toRange"),sl=s((e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return rl(e,t,n)},"toRegex"),il=s((...e)=>new RangeError("Invalid range arguments: "+NE.inspect(...e)),"rangeError"),cl=s((e,t,n)=>{if(n.strictRanges===!0)throw il([e,t]);return[]},"invalidRange"),UE=s((e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},"invalidStep"),HE=s((e,t,n=1,r={})=>{let o=Number(e),i=Number(t);if(!Number.isInteger(o)||!Number.isInteger(i)){if(r.strictRanges===!0)throw il([e,t]);return[]}o===0&&(o=0),i===0&&(i=0);let c=o>i,a=String(e),u=String(t),f=String(n);n=Math.max(Math.abs(n),1);let l=Ns(a)||Ns(u)||Ns(f),p=l?Math.max(a.length,u.length,f.length):0,d=l===!1&&ME(e,t,r)===!1,m=r.transform||PE(d);if(r.toRegex&&n===1)return ol(Gr(e,p),Gr(t,p),!0,r);let g={negatives:[],positives:[]},h=s(w=>g[w<0?"negatives":"positives"].push(Math.abs(w)),"push"),y=[],b=0;for(;c?o>=i:o<=i;)r.toRegex===!0&&n>1?h(o):y.push(LE(m(o,b),p,d)),o=c?o-n:o+n,b++;return r.toRegex===!0?n>1?vE(g,r,p):sl(y,null,{wrap:!1,...r}):y},"fillNumbers"),DE=s((e,t,n=1,r={})=>{if(!Ln(e)&&e.length>1||!Ln(t)&&t.length>1)return cl(e,t,r);let o=r.transform||(d=>String.fromCharCode(d)),i=`${e}`.charCodeAt(0),c=`${t}`.charCodeAt(0),a=i>c,u=Math.min(i,c),f=Math.max(i,c);if(r.toRegex&&n===1)return ol(u,f,!1,r);let l=[],p=0;for(;a?i>=c:i<=c;)l.push(o(i,p)),i=a?i-n:i+n,p++;return r.toRegex===!0?sl(l,null,{wrap:!1,options:r}):l},"fillLetters"),Kr=s((e,t,n,r={})=>{if(t==null&&ws(e))return[e];if(!ws(e)||!ws(t))return cl(e,t,r);if(typeof n=="function")return Kr(e,t,1,{transform:n});if(nl(n))return Kr(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,Ln(n)?Ln(e)&&Ln(t)?HE(e,t,n,o):DE(e,t,Math.max(Math.abs(n),1),o):n!=null&&!nl(n)?UE(n,o):Kr(e,t,1,n)},"fill");al.exports=Kr});var fl=Y((HM,ll)=>{"use strict";var FE=Ps(),ul=jr(),$E=s((e,t={})=>{let n=s((r,o={})=>{let i=ul.isInvalidBrace(o),c=r.invalid===!0&&t.escapeInvalid===!0,a=i===!0||c===!0,u=t.escapeInvalid===!0?"\\":"",f="";if(r.isOpen===!0)return u+r.value;if(r.isClose===!0)return console.log("node.isClose",u,r.value),u+r.value;if(r.type==="open")return a?u+r.value:"(";if(r.type==="close")return a?u+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":a?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let l=ul.reduce(r.nodes),p=FE(...l,{...t,wrap:!1,toRegex:!0,strictZeros:!0});if(p.length!==0)return l.length>1&&p.length>1?`(${p})`:p}if(r.nodes)for(let l of r.nodes)f+=n(l,r);return f},"walk");return n(e)},"compile");ll.exports=$E});var ml=Y((FM,pl)=>{"use strict";var jE=Ps(),dl=Br(),qt=jr(),wt=s((e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?qt.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let i of o)r.push(wt(i,t,n));else for(let i of t)n===!0&&typeof i=="string"&&(i=`{${i}}`),r.push(Array.isArray(i)?wt(o,i,n):o+i);return qt.flatten(r)},"append"),BE=s((e,t={})=>{let n=t.rangeLimit===void 0?1e3:t.rangeLimit,r=s((o,i={})=>{o.queue=[];let c=i,a=i.queue;for(;c.type!=="brace"&&c.type!=="root"&&c.parent;)c=c.parent,a=c.queue;if(o.invalid||o.dollar){a.push(wt(a.pop(),dl(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){a.push(wt(a.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let p=qt.reduce(o.nodes);if(qt.exceedsLimit(...p,t.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let d=jE(...p,t);d.length===0&&(d=dl(o,t)),a.push(wt(a.pop(),d)),o.nodes=[];return}let u=qt.encloseBrace(o),f=o.queue,l=o;for(;l.type!=="brace"&&l.type!=="root"&&l.parent;)l=l.parent,f=l.queue;for(let p=0;p<o.nodes.length;p++){let d=o.nodes[p];if(d.type==="comma"&&o.type==="brace"){p===1&&f.push(""),f.push("");continue}if(d.type==="close"){a.push(wt(a.pop(),f,u));continue}if(d.value&&d.type!=="open"){f.push(wt(f.pop(),d.value));continue}d.nodes&&r(d,o)}return f},"walk");return qt.flatten(r(e))},"expand");pl.exports=BE});var _l=Y((jM,gl)=>{"use strict";gl.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
5
- `,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Rl=Y((BM,yl)=>{"use strict";var KE=Br(),{MAX_LENGTH:hl,CHAR_BACKSLASH:Ms,CHAR_BACKTICK:GE,CHAR_COMMA:VE,CHAR_DOT:zE,CHAR_LEFT_PARENTHESES:WE,CHAR_RIGHT_PARENTHESES:JE,CHAR_LEFT_CURLY_BRACE:YE,CHAR_RIGHT_CURLY_BRACE:XE,CHAR_LEFT_SQUARE_BRACKET:Sl,CHAR_RIGHT_SQUARE_BRACKET:El,CHAR_DOUBLE_QUOTE:qE,CHAR_SINGLE_QUOTE:ZE,CHAR_NO_BREAK_SPACE:QE,CHAR_ZERO_WIDTH_NOBREAK_SPACE:ey}=_l(),ty=s((e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(hl,n.maxLength):hl;if(e.length>r)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${r})`);let o={type:"root",input:e,nodes:[]},i=[o],c=o,a=o,u=0,f=e.length,l=0,p=0,d,m=s(()=>e[l++],"advance"),g=s(h=>{if(h.type==="text"&&a.type==="dot"&&(a.type="text"),a&&a.type==="text"&&h.type==="text"){a.value+=h.value;return}return c.nodes.push(h),h.parent=c,h.prev=a,a=h,h},"push");for(g({type:"bos"});l<f;)if(c=i[i.length-1],d=m(),!(d===ey||d===QE)){if(d===Ms){g({type:"text",value:(t.keepEscaping?d:"")+m()});continue}if(d===El){g({type:"text",value:"\\"+d});continue}if(d===Sl){u++;let h;for(;l<f&&(h=m());){if(d+=h,h===Sl){u++;continue}if(h===Ms){d+=m();continue}if(h===El&&(u--,u===0))break}g({type:"text",value:d});continue}if(d===WE){c=g({type:"paren",nodes:[]}),i.push(c),g({type:"text",value:d});continue}if(d===JE){if(c.type!=="paren"){g({type:"text",value:d});continue}c=i.pop(),g({type:"text",value:d}),c=i[i.length-1];continue}if(d===qE||d===ZE||d===GE){let h=d,y;for(t.keepQuotes!==!0&&(d="");l<f&&(y=m());){if(y===Ms){d+=y+m();continue}if(y===h){t.keepQuotes===!0&&(d+=y);break}d+=y}g({type:"text",value:d});continue}if(d===YE){p++;let y={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||c.dollar===!0,depth:p,commas:0,ranges:0,nodes:[]};c=g(y),i.push(c),g({type:"open",value:d});continue}if(d===XE){if(c.type!=="brace"){g({type:"text",value:d});continue}let h="close";c=i.pop(),c.close=!0,g({type:h,value:d}),p--,c=i[i.length-1];continue}if(d===VE&&p>0){if(c.ranges>0){c.ranges=0;let h=c.nodes.shift();c.nodes=[h,{type:"text",value:KE(c)}]}g({type:"comma",value:d}),c.commas++;continue}if(d===zE&&p>0&&c.commas===0){let h=c.nodes;if(p===0||h.length===0){g({type:"text",value:d});continue}if(a.type==="dot"){if(c.range=[],a.value+=d,a.type="range",c.nodes.length!==3&&c.nodes.length!==5){c.invalid=!0,c.ranges=0,a.type="text";continue}c.ranges++,c.args=[];continue}if(a.type==="range"){h.pop();let y=h[h.length-1];y.value+=a.value+d,a=y,c.ranges--;continue}g({type:"dot",value:d});continue}g({type:"text",value:d})}do if(c=i.pop(),c.type!=="root"){c.nodes.forEach(b=>{b.nodes||(b.type==="open"&&(b.isOpen=!0),b.type==="close"&&(b.isClose=!0),b.nodes||(b.type="text"),b.invalid=!0)});let h=i[i.length-1],y=h.nodes.indexOf(c);h.nodes.splice(y,1,...c.nodes)}while(i.length>0);return g({type:"eos"}),o},"parse");yl.exports=ty});var bl=Y((GM,Al)=>{"use strict";var Cl=Br(),ny=fl(),ry=ml(),oy=Rl(),be=s((e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=be.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(be.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n},"braces");be.parse=(e,t={})=>oy(e,t);be.stringify=(e,t={})=>Cl(typeof e=="string"?be.parse(e,t):e,t);be.compile=(e,t={})=>(typeof e=="string"&&(e=be.parse(e,t)),ny(e,t));be.expand=(e,t={})=>{typeof e=="string"&&(e=be.parse(e,t));let n=ry(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};be.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?be.compile(e,t):be.expand(e,t);Al.exports=be});var vn=Y((zM,Tl)=>{"use strict";var sy=at("path"),Fe="\\\\/",Ol=`[^${Fe}]`,iy=0,qe="\\.",cy="\\+",ay="\\?",Vr="\\/",uy="(?=.)",kl="[^/]",Ls=`(?:${Vr}|$)`,xl=`(?:^|${Vr})`,vs=`${qe}{1,2}${Ls}`,ly=`(?!${qe})`,fy=`(?!${xl}${vs})`,dy=`(?!${qe}{0,1}${Ls})`,py=`(?!${vs})`,my=`[^.${Vr}]`,gy=`${kl}*?`,Il={DOT_LITERAL:qe,PLUS_LITERAL:cy,QMARK_LITERAL:ay,SLASH_LITERAL:Vr,ONE_CHAR:uy,QMARK:kl,END_ANCHOR:Ls,DOTS_SLASH:vs,NO_DOT:ly,NO_DOTS:fy,NO_DOT_SLASH:dy,NO_DOTS_SLASH:py,QMARK_NO_DOT:my,STAR:gy,START_ANCHOR:xl},_y={...Il,SLASH_LITERAL:`[${Fe}]`,QMARK:Ol,STAR:`${Ol}*?`,DOTS_SLASH:`${qe}{1,2}(?:[${Fe}]|$)`,NO_DOT:`(?!${qe})`,NO_DOTS:`(?!(?:^|[${Fe}])${qe}{1,2}(?:[${Fe}]|$))`,NO_DOT_SLASH:`(?!${qe}{0,1}(?:[${Fe}]|$))`,NO_DOTS_SLASH:`(?!${qe}{1,2}(?:[${Fe}]|$))`,QMARK_NO_DOT:`[^.${Fe}]`,START_ANCHOR:`(?:^|[${Fe}])`,END_ANCHOR:`(?:[${Fe}]|$)`},hy={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};Tl.exports={DEFAULT_MAX_EXTGLOB_RECURSION:iy,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:hy,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:sy.sep,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?_y:Il}}});var Un=Y(Se=>{"use strict";var Sy=at("path"),Ey=process.platform==="win32",{REGEX_BACKSLASH:yy,REGEX_REMOVE_BACKSLASH:Ry,REGEX_SPECIAL_CHARS:Cy,REGEX_SPECIAL_CHARS_GLOBAL:Ay}=vn();Se.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);Se.hasRegexChars=e=>Cy.test(e);Se.isRegexChar=e=>e.length===1&&Se.hasRegexChars(e);Se.escapeRegex=e=>e.replace(Ay,"\\$1");Se.toPosixSlashes=e=>e.replace(yy,"/");Se.removeBackslashes=e=>e.replace(Ry,t=>t==="\\"?"":t);Se.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};Se.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:Ey===!0||Sy.sep==="\\";Se.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?Se.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};Se.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};Se.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",i=`${r}(?:${e})${o}`;return t.negated===!0&&(i=`(?:^(?!${i}).*$)`),i}});var Hl=Y((JM,Ul)=>{"use strict";var wl=Un(),{CHAR_ASTERISK:Us,CHAR_AT:by,CHAR_BACKWARD_SLASH:Hn,CHAR_COMMA:Oy,CHAR_DOT:Hs,CHAR_EXCLAMATION_MARK:Ds,CHAR_FORWARD_SLASH:vl,CHAR_LEFT_CURLY_BRACE:Fs,CHAR_LEFT_PARENTHESES:$s,CHAR_LEFT_SQUARE_BRACKET:ky,CHAR_PLUS:xy,CHAR_QUESTION_MARK:Nl,CHAR_RIGHT_CURLY_BRACE:Iy,CHAR_RIGHT_PARENTHESES:Pl,CHAR_RIGHT_SQUARE_BRACKET:Ty}=vn(),Ml=s(e=>e===vl||e===Hn,"isPathSeparator"),Ll=s(e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},"depth"),wy=s((e,t)=>{let n=t||{},r=e.length-1,o=n.parts===!0||n.scanToEnd===!0,i=[],c=[],a=[],u=e,f=-1,l=0,p=0,d=!1,m=!1,g=!1,h=!1,y=!1,b=!1,w=!1,N=!1,x=!1,O=!1,U=0,M,k,P={value:"",depth:0,isGlob:!1},v=s(()=>f>=r,"eos"),_=s(()=>u.charCodeAt(f+1),"peek"),I=s(()=>(M=k,u.charCodeAt(++f)),"advance");for(;f<r;){k=I();let ge;if(k===Hn){w=P.backslashes=!0,k=I(),k===Fs&&(b=!0);continue}if(b===!0||k===Fs){for(U++;v()!==!0&&(k=I());){if(k===Hn){w=P.backslashes=!0,I();continue}if(k===Fs){U++;continue}if(b!==!0&&k===Hs&&(k=I())===Hs){if(d=P.isBrace=!0,g=P.isGlob=!0,O=!0,o===!0)continue;break}if(b!==!0&&k===Oy){if(d=P.isBrace=!0,g=P.isGlob=!0,O=!0,o===!0)continue;break}if(k===Iy&&(U--,U===0)){b=!1,d=P.isBrace=!0,O=!0;break}}if(o===!0)continue;break}if(k===vl){if(i.push(f),c.push(P),P={value:"",depth:0,isGlob:!1},O===!0)continue;if(M===Hs&&f===l+1){l+=2;continue}p=f+1;continue}if(n.noext!==!0&&(k===xy||k===by||k===Us||k===Nl||k===Ds)===!0&&_()===$s){if(g=P.isGlob=!0,h=P.isExtglob=!0,O=!0,k===Ds&&f===l&&(x=!0),o===!0){for(;v()!==!0&&(k=I());){if(k===Hn){w=P.backslashes=!0,k=I();continue}if(k===Pl){g=P.isGlob=!0,O=!0;break}}continue}break}if(k===Us){if(M===Us&&(y=P.isGlobstar=!0),g=P.isGlob=!0,O=!0,o===!0)continue;break}if(k===Nl){if(g=P.isGlob=!0,O=!0,o===!0)continue;break}if(k===ky){for(;v()!==!0&&(ge=I());){if(ge===Hn){w=P.backslashes=!0,I();continue}if(ge===Ty){m=P.isBracket=!0,g=P.isGlob=!0,O=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&k===Ds&&f===l){N=P.negated=!0,l++;continue}if(n.noparen!==!0&&k===$s){if(g=P.isGlob=!0,o===!0){for(;v()!==!0&&(k=I());){if(k===$s){w=P.backslashes=!0,k=I();continue}if(k===Pl){O=!0;break}}continue}break}if(g===!0){if(O=!0,o===!0)continue;break}}n.noext===!0&&(h=!1,g=!1);let B=u,Ce="",S="";l>0&&(Ce=u.slice(0,l),u=u.slice(l),p-=l),B&&g===!0&&p>0?(B=u.slice(0,p),S=u.slice(p)):g===!0?(B="",S=u):B=u,B&&B!==""&&B!=="/"&&B!==u&&Ml(B.charCodeAt(B.length-1))&&(B=B.slice(0,-1)),n.unescape===!0&&(S&&(S=wl.removeBackslashes(S)),B&&w===!0&&(B=wl.removeBackslashes(B)));let E={prefix:Ce,input:e,start:l,base:B,glob:S,isBrace:d,isBracket:m,isGlob:g,isExtglob:h,isGlobstar:y,negated:N,negatedExtglob:x};if(n.tokens===!0&&(E.maxDepth=0,Ml(k)||c.push(P),E.tokens=c),n.parts===!0||n.tokens===!0){let ge;for(let K=0;K<i.length;K++){let Me=ge?ge+1:l,Le=i[K],Ae=e.slice(Me,Le);n.tokens&&(K===0&&l!==0?(c[K].isPrefix=!0,c[K].value=Ce):c[K].value=Ae,Ll(c[K]),E.maxDepth+=c[K].depth),(K!==0||Ae!=="")&&a.push(Ae),ge=Le}if(ge&&ge+1<e.length){let K=e.slice(ge+1);a.push(K),n.tokens&&(c[c.length-1].value=K,Ll(c[c.length-1]),E.maxDepth+=c[c.length-1].depth)}E.slashes=i,E.parts=a}return E},"scan");Ul.exports=wy});var Bl=Y((XM,jl)=>{"use strict";var Dn=vn(),me=Un(),{MAX_LENGTH:zr,POSIX_REGEX_SOURCE:Ny,REGEX_NON_SPECIAL_CHARS:Py,REGEX_SPECIAL_CHARS_BACKREF:My,REPLACEMENTS:Dl}=Dn,Ly=s((e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n)}catch{return e.map(o=>me.escapeRegex(o)).join("..")}return n},"expandRange"),Zt=s((e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,"syntaxError"),Fl=s(e=>{let t=[],n=0,r=0,o=0,i="",c=!1;for(let a of e){if(c===!0){i+=a,c=!1;continue}if(a==="\\"){i+=a,c=!0;continue}if(a==='"'){o=o===1?0:1,i+=a;continue}if(o===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")r++;else if(a===")"&&r>0)r--;else if(a==="|"&&r===0){t.push(i),i="";continue}}}i+=a}return t.push(i),t},"splitTopLevel"),vy=s(e=>{let t=!1;for(let n of e){if(t===!0){t=!1;continue}if(n==="\\"){t=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},"isPlainBranch"),$l=s(e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(vy(t))return t.replace(/\\(.)/g,"$1")},"normalizeSimpleBranch"),Uy=s(e=>{let t=e.map($l).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let o=t[n],i=t[r],c=o[0];if(!(!c||o!==c.repeat(o.length)||i!==c.repeat(i.length))&&(o===i||o.startsWith(i)||i.startsWith(o)))return!0}return!1},"hasRepeatedCharPrefixOverlap"),js=s((e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,r=0,o=0,i=!1;for(let c=1;c<e.length;c++){let a=e[c];if(i===!0){i=!1;continue}if(a==="\\"){i=!0;continue}if(a==='"'){o=o===1?0:1;continue}if(o!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){r++;continue}if(a===")"&&(r--,r===0))return t===!0&&c!==e.length-1?void 0:{type:e[0],body:e.slice(2,c),end:c}}}}},"parseRepeatedExtglob"),Hy=s(e=>{let t=0,n=[];for(;t<e.length;){let o=js(e.slice(t),!1);if(!o||o.type!=="*")return;let i=Fl(o.body).map(a=>a.trim());if(i.length!==1)return;let c=$l(i[0]);if(!c||c.length!==1)return;n.push(c),t+=o.end+1}return n.length<1?void 0:`${n.length===1?me.escapeRegex(n[0]):`[${n.map(o=>me.escapeRegex(o)).join("")}]`}*`},"getStarExtglobSequenceOutput"),Dy=s(e=>{let t=0,n=e.trim(),r=js(n);for(;r;)t++,n=r.body.trim(),r=js(n);return t},"repeatedExtglobRecursion"),Fy=s((e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:Dn.DEFAULT_MAX_EXTGLOB_RECURSION,r=Fl(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||Uy(r)))return{risky:!0};for(let o of r){let i=Hy(o);if(i)return{risky:!0,safeOutput:i};if(Dy(o)>n)return{risky:!0}}return{risky:!1}},"analyzeRepeatedExtglob"),Bs=s((e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=Dl[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(zr,n.maxLength):zr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let i={type:"bos",value:"",output:n.prepend||""},c=[i],a=n.capture?"":"?:",u=me.isWindows(t),f=Dn.globChars(u),l=Dn.extglobChars(f),{DOT_LITERAL:p,PLUS_LITERAL:d,SLASH_LITERAL:m,ONE_CHAR:g,DOTS_SLASH:h,NO_DOT:y,NO_DOT_SLASH:b,NO_DOTS_SLASH:w,QMARK:N,QMARK_NO_DOT:x,STAR:O,START_ANCHOR:U}=f,M=s(A=>`(${a}(?:(?!${U}${A.dot?h:p}).)*?)`,"globstar"),k=n.dot?"":y,P=n.dot?N:x,v=n.bash===!0?M(n):O;n.capture&&(v=`(${v})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let _={input:e,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:c};e=me.removePrefix(e,_),o=e.length;let I=[],B=[],Ce=[],S=i,E,ge=s(()=>_.index===o-1,"eos"),K=_.peek=(A=1)=>e[_.index+A],Me=_.advance=()=>e[++_.index]||"",Le=s(()=>e.slice(_.index+1),"remaining"),Ae=s((A="",Z=0)=>{_.consumed+=A,_.index+=Z},"consume"),cr=s(A=>{_.output+=A.output!=null?A.output:A.value,Ae(A.value)},"append"),y_=s(()=>{let A=1;for(;K()==="!"&&(K(2)!=="("||K(3)==="?");)Me(),_.start++,A++;return A%2===0?!1:(_.negated=!0,_.start++,!0)},"negate"),ar=s(A=>{_[A]++,Ce.push(A)},"increment"),ct=s(A=>{_[A]--,Ce.pop()},"decrement"),D=s(A=>{if(S.type==="globstar"){let Z=_.braces>0&&(A.type==="comma"||A.type==="brace"),C=A.extglob===!0||I.length&&(A.type==="pipe"||A.type==="paren");A.type!=="slash"&&A.type!=="paren"&&!Z&&!C&&(_.output=_.output.slice(0,-S.output.length),S.type="star",S.value="*",S.output=v,_.output+=S.output)}if(I.length&&A.type!=="paren"&&(I[I.length-1].inner+=A.value),(A.value||A.output)&&cr(A),S&&S.type==="text"&&A.type==="text"){S.value+=A.value,S.output=(S.output||"")+A.value;return}A.prev=S,c.push(A),S=A},"push"),ur=s((A,Z)=>{let C={...l[Z],conditions:1,inner:""};C.prev=S,C.parens=_.parens,C.output=_.output,C.startIndex=_.index,C.tokensIndex=c.length;let H=(n.capture?"(":"")+C.open;ar("parens"),D({type:A,value:Z,output:_.output?"":g}),D({type:"paren",extglob:!0,value:Me(),output:H}),I.push(C)},"extglobOpen"),R_=s(A=>{let Z=e.slice(A.startIndex,_.index+1),C=e.slice(A.startIndex+2,_.index),H=Fy(C,n);if((A.type==="plus"||A.type==="star")&&H.risky){let W=H.safeOutput?(A.output?"":g)+(n.capture?`(${H.safeOutput})`:H.safeOutput):void 0,ve=c[A.tokensIndex];ve.type="text",ve.value=Z,ve.output=W||me.escapeRegex(Z);for(let Ue=A.tokensIndex+1;Ue<c.length;Ue++)c[Ue].value="",c[Ue].output="",delete c[Ue].suffix;_.output=A.output+ve.output,_.backtrack=!0,D({type:"paren",extglob:!0,value:E,output:""}),ct("parens");return}let J=A.close+(n.capture?")":""),ue;if(A.type==="negate"){let W=v;if(A.inner&&A.inner.length>1&&A.inner.includes("/")&&(W=M(n)),(W!==v||ge()||/^\)+$/.test(Le()))&&(J=A.close=`)$))${W}`),A.inner.includes("*")&&(ue=Le())&&/^\.[^\\/.]+$/.test(ue)){let ve=Bs(ue,{...t,fastpaths:!1}).output;J=A.close=`)${ve})${W})`}A.prev.type==="bos"&&(_.negatedExtglob=!0)}D({type:"paren",extglob:!0,value:E,output:J}),ct("parens")},"extglobClose");if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let A=!1,Z=e.replace(My,(C,H,J,ue,W,ve)=>ue==="\\"?(A=!0,C):ue==="?"?H?H+ue+(W?N.repeat(W.length):""):ve===0?P+(W?N.repeat(W.length):""):N.repeat(J.length):ue==="."?p.repeat(J.length):ue==="*"?H?H+ue+(W?v:""):v:H?C:`\\${C}`);return A===!0&&(n.unescape===!0?Z=Z.replace(/\\/g,""):Z=Z.replace(/\\+/g,C=>C.length%2===0?"\\\\":C?"\\":"")),Z===e&&n.contains===!0?(_.output=e,_):(_.output=me.wrapOutput(Z,_,t),_)}for(;!ge();){if(E=Me(),E==="\0")continue;if(E==="\\"){let C=K();if(C==="/"&&n.bash!==!0||C==="."||C===";")continue;if(!C){E+="\\",D({type:"text",value:E});continue}let H=/^\\+/.exec(Le()),J=0;if(H&&H[0].length>2&&(J=H[0].length,_.index+=J,J%2!==0&&(E+="\\")),n.unescape===!0?E=Me():E+=Me(),_.brackets===0){D({type:"text",value:E});continue}}if(_.brackets>0&&(E!=="]"||S.value==="["||S.value==="[^")){if(n.posix!==!1&&E===":"){let C=S.value.slice(1);if(C.includes("[")&&(S.posix=!0,C.includes(":"))){let H=S.value.lastIndexOf("["),J=S.value.slice(0,H),ue=S.value.slice(H+2),W=Ny[ue];if(W){S.value=J+W,_.backtrack=!0,Me(),!i.output&&c.indexOf(S)===1&&(i.output=g);continue}}}(E==="["&&K()!==":"||E==="-"&&K()==="]")&&(E=`\\${E}`),E==="]"&&(S.value==="["||S.value==="[^")&&(E=`\\${E}`),n.posix===!0&&E==="!"&&S.value==="["&&(E="^"),S.value+=E,cr({value:E});continue}if(_.quotes===1&&E!=='"'){E=me.escapeRegex(E),S.value+=E,cr({value:E});continue}if(E==='"'){_.quotes=_.quotes===1?0:1,n.keepQuotes===!0&&D({type:"text",value:E});continue}if(E==="("){ar("parens"),D({type:"paren",value:E});continue}if(E===")"){if(_.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Zt("opening","("));let C=I[I.length-1];if(C&&_.parens===C.parens+1){R_(I.pop());continue}D({type:"paren",value:E,output:_.parens?")":"\\)"}),ct("parens");continue}if(E==="["){if(n.nobracket===!0||!Le().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Zt("closing","]"));E=`\\${E}`}else ar("brackets");D({type:"bracket",value:E});continue}if(E==="]"){if(n.nobracket===!0||S&&S.type==="bracket"&&S.value.length===1){D({type:"text",value:E,output:`\\${E}`});continue}if(_.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Zt("opening","["));D({type:"text",value:E,output:`\\${E}`});continue}ct("brackets");let C=S.value.slice(1);if(S.posix!==!0&&C[0]==="^"&&!C.includes("/")&&(E=`/${E}`),S.value+=E,cr({value:E}),n.literalBrackets===!1||me.hasRegexChars(C))continue;let H=me.escapeRegex(S.value);if(_.output=_.output.slice(0,-S.value.length),n.literalBrackets===!0){_.output+=H,S.value=H;continue}S.value=`(${a}${H}|${S.value})`,_.output+=S.value;continue}if(E==="{"&&n.nobrace!==!0){ar("braces");let C={type:"brace",value:E,output:"(",outputIndex:_.output.length,tokensIndex:_.tokens.length};B.push(C),D(C);continue}if(E==="}"){let C=B[B.length-1];if(n.nobrace===!0||!C){D({type:"text",value:E,output:E});continue}let H=")";if(C.dots===!0){let J=c.slice(),ue=[];for(let W=J.length-1;W>=0&&(c.pop(),J[W].type!=="brace");W--)J[W].type!=="dots"&&ue.unshift(J[W].value);H=Ly(ue,n),_.backtrack=!0}if(C.comma!==!0&&C.dots!==!0){let J=_.output.slice(0,C.outputIndex),ue=_.tokens.slice(C.tokensIndex);C.value=C.output="\\{",E=H="\\}",_.output=J;for(let W of ue)_.output+=W.output||W.value}D({type:"brace",value:E,output:H}),ct("braces"),B.pop();continue}if(E==="|"){I.length>0&&I[I.length-1].conditions++,D({type:"text",value:E});continue}if(E===","){let C=E,H=B[B.length-1];H&&Ce[Ce.length-1]==="braces"&&(H.comma=!0,C="|"),D({type:"comma",value:E,output:C});continue}if(E==="/"){if(S.type==="dot"&&_.index===_.start+1){_.start=_.index+1,_.consumed="",_.output="",c.pop(),S=i;continue}D({type:"slash",value:E,output:m});continue}if(E==="."){if(_.braces>0&&S.type==="dot"){S.value==="."&&(S.output=p);let C=B[B.length-1];S.type="dots",S.output+=E,S.value+=E,C.dots=!0;continue}if(_.braces+_.parens===0&&S.type!=="bos"&&S.type!=="slash"){D({type:"text",value:E,output:p});continue}D({type:"dot",value:E,output:p});continue}if(E==="?"){if(!(S&&S.value==="(")&&n.noextglob!==!0&&K()==="("&&K(2)!=="?"){ur("qmark",E);continue}if(S&&S.type==="paren"){let H=K(),J=E;if(H==="<"&&!me.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(S.value==="("&&!/[!=<:]/.test(H)||H==="<"&&!/<([!=]|\w+>)/.test(Le()))&&(J=`\\${E}`),D({type:"text",value:E,output:J});continue}if(n.dot!==!0&&(S.type==="slash"||S.type==="bos")){D({type:"qmark",value:E,output:x});continue}D({type:"qmark",value:E,output:N});continue}if(E==="!"){if(n.noextglob!==!0&&K()==="("&&(K(2)!=="?"||!/[!=<:]/.test(K(3)))){ur("negate",E);continue}if(n.nonegate!==!0&&_.index===0){y_();continue}}if(E==="+"){if(n.noextglob!==!0&&K()==="("&&K(2)!=="?"){ur("plus",E);continue}if(S&&S.value==="("||n.regex===!1){D({type:"plus",value:E,output:d});continue}if(S&&(S.type==="bracket"||S.type==="paren"||S.type==="brace")||_.parens>0){D({type:"plus",value:E});continue}D({type:"plus",value:d});continue}if(E==="@"){if(n.noextglob!==!0&&K()==="("&&K(2)!=="?"){D({type:"at",extglob:!0,value:E,output:""});continue}D({type:"text",value:E});continue}if(E!=="*"){(E==="$"||E==="^")&&(E=`\\${E}`);let C=Py.exec(Le());C&&(E+=C[0],_.index+=C[0].length),D({type:"text",value:E});continue}if(S&&(S.type==="globstar"||S.star===!0)){S.type="star",S.star=!0,S.value+=E,S.output=v,_.backtrack=!0,_.globstar=!0,Ae(E);continue}let A=Le();if(n.noextglob!==!0&&/^\([^?]/.test(A)){ur("star",E);continue}if(S.type==="star"){if(n.noglobstar===!0){Ae(E);continue}let C=S.prev,H=C.prev,J=C.type==="slash"||C.type==="bos",ue=H&&(H.type==="star"||H.type==="globstar");if(n.bash===!0&&(!J||A[0]&&A[0]!=="/")){D({type:"star",value:E,output:""});continue}let W=_.braces>0&&(C.type==="comma"||C.type==="brace"),ve=I.length&&(C.type==="pipe"||C.type==="paren");if(!J&&C.type!=="paren"&&!W&&!ve){D({type:"star",value:E,output:""});continue}for(;A.slice(0,3)==="/**";){let Ue=e[_.index+4];if(Ue&&Ue!=="/")break;A=A.slice(3),Ae("/**",3)}if(C.type==="bos"&&ge()){S.type="globstar",S.value+=E,S.output=M(n),_.output=S.output,_.globstar=!0,Ae(E);continue}if(C.type==="slash"&&C.prev.type!=="bos"&&!ue&&ge()){_.output=_.output.slice(0,-(C.output+S.output).length),C.output=`(?:${C.output}`,S.type="globstar",S.output=M(n)+(n.strictSlashes?")":"|$)"),S.value+=E,_.globstar=!0,_.output+=C.output+S.output,Ae(E);continue}if(C.type==="slash"&&C.prev.type!=="bos"&&A[0]==="/"){let Ue=A[1]!==void 0?"|$":"";_.output=_.output.slice(0,-(C.output+S.output).length),C.output=`(?:${C.output}`,S.type="globstar",S.output=`${M(n)}${m}|${m}${Ue})`,S.value+=E,_.output+=C.output+S.output,_.globstar=!0,Ae(E+Me()),D({type:"slash",value:"/",output:""});continue}if(C.type==="bos"&&A[0]==="/"){S.type="globstar",S.value+=E,S.output=`(?:^|${m}|${M(n)}${m})`,_.output=S.output,_.globstar=!0,Ae(E+Me()),D({type:"slash",value:"/",output:""});continue}_.output=_.output.slice(0,-S.output.length),S.type="globstar",S.output=M(n),S.value+=E,_.output+=S.output,_.globstar=!0,Ae(E);continue}let Z={type:"star",value:E,output:v};if(n.bash===!0){Z.output=".*?",(S.type==="bos"||S.type==="slash")&&(Z.output=k+Z.output),D(Z);continue}if(S&&(S.type==="bracket"||S.type==="paren")&&n.regex===!0){Z.output=E,D(Z);continue}(_.index===_.start||S.type==="slash"||S.type==="dot")&&(S.type==="dot"?(_.output+=b,S.output+=b):n.dot===!0?(_.output+=w,S.output+=w):(_.output+=k,S.output+=k),K()!=="*"&&(_.output+=g,S.output+=g)),D(Z)}for(;_.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Zt("closing","]"));_.output=me.escapeLast(_.output,"["),ct("brackets")}for(;_.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Zt("closing",")"));_.output=me.escapeLast(_.output,"("),ct("parens")}for(;_.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Zt("closing","}"));_.output=me.escapeLast(_.output,"{"),ct("braces")}if(n.strictSlashes!==!0&&(S.type==="star"||S.type==="bracket")&&D({type:"maybe_slash",value:"",output:`${m}?`}),_.backtrack===!0){_.output="";for(let A of _.tokens)_.output+=A.output!=null?A.output:A.value,A.suffix&&(_.output+=A.suffix)}return _},"parse");Bs.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(zr,n.maxLength):zr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=Dl[e]||e;let i=me.isWindows(t),{DOT_LITERAL:c,SLASH_LITERAL:a,ONE_CHAR:u,DOTS_SLASH:f,NO_DOT:l,NO_DOTS:p,NO_DOTS_SLASH:d,STAR:m,START_ANCHOR:g}=Dn.globChars(i),h=n.dot?p:l,y=n.dot?d:l,b=n.capture?"":"?:",w={negated:!1,prefix:""},N=n.bash===!0?".*?":m;n.capture&&(N=`(${N})`);let x=s(k=>k.noglobstar===!0?N:`(${b}(?:(?!${g}${k.dot?f:c}).)*?)`,"globstar"),O=s(k=>{switch(k){case"*":return`${h}${u}${N}`;case".*":return`${c}${u}${N}`;case"*.*":return`${h}${N}${c}${u}${N}`;case"*/*":return`${h}${N}${a}${u}${y}${N}`;case"**":return h+x(n);case"**/*":return`(?:${h}${x(n)}${a})?${y}${u}${N}`;case"**/*.*":return`(?:${h}${x(n)}${a})?${y}${N}${c}${u}${N}`;case"**/.*":return`(?:${h}${x(n)}${a})?${c}${u}${N}`;default:{let P=/^(.*?)\.(\w+)$/.exec(k);if(!P)return;let v=O(P[1]);return v?v+c+P[2]:void 0}}},"create"),U=me.removePrefix(e,w),M=O(U);return M&&n.strictSlashes!==!0&&(M+=`${a}?`),M};jl.exports=Bs});var Gl=Y((ZM,Kl)=>{"use strict";var $y=at("path"),jy=Hl(),Ks=Bl(),Gs=Un(),By=vn(),Ky=s(e=>e&&typeof e=="object"&&!Array.isArray(e),"isObject"),oe=s((e,t,n=!1)=>{if(Array.isArray(e)){let l=e.map(d=>oe(d,t,n));return s(d=>{for(let m of l){let g=m(d);if(g)return g}return!1},"arrayMatcher")}let r=Ky(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=t||{},i=Gs.isWindows(t),c=r?oe.compileRe(e,t):oe.makeRe(e,t,!1,!0),a=c.state;delete c.state;let u=s(()=>!1,"isIgnored");if(o.ignore){let l={...t,ignore:null,onMatch:null,onResult:null};u=oe(o.ignore,l,n)}let f=s((l,p=!1)=>{let{isMatch:d,match:m,output:g}=oe.test(l,c,t,{glob:e,posix:i}),h={glob:e,state:a,regex:c,posix:i,input:l,output:g,match:m,isMatch:d};return typeof o.onResult=="function"&&o.onResult(h),d===!1?(h.isMatch=!1,p?h:!1):u(l)?(typeof o.onIgnore=="function"&&o.onIgnore(h),h.isMatch=!1,p?h:!1):(typeof o.onMatch=="function"&&o.onMatch(h),p?h:!0)},"matcher");return n&&(f.state=a),f},"picomatch");oe.test=(e,t,n,{glob:r,posix:o}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let i=n||{},c=i.format||(o?Gs.toPosixSlashes:null),a=e===r,u=a&&c?c(e):e;return a===!1&&(u=c?c(e):e,a=u===r),(a===!1||i.capture===!0)&&(i.matchBase===!0||i.basename===!0?a=oe.matchBase(e,t,n,o):a=t.exec(u)),{isMatch:!!a,match:a,output:u}};oe.matchBase=(e,t,n,r=Gs.isWindows(n))=>(t instanceof RegExp?t:oe.makeRe(t,n)).test($y.basename(e));oe.isMatch=(e,t,n)=>oe(t,n)(e);oe.parse=(e,t)=>Array.isArray(e)?e.map(n=>oe.parse(n,t)):Ks(e,{...t,fastpaths:!1});oe.scan=(e,t)=>jy(e,t);oe.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let o=t||{},i=o.contains?"":"^",c=o.contains?"":"$",a=`${i}(?:${e.output})${c}`;e&&e.negated===!0&&(a=`^(?!${a}).*$`);let u=oe.toRegex(a,t);return r===!0&&(u.state=e),u};oe.makeRe=(e,t={},n=!1,r=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let o={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(o.output=Ks.fastpaths(e,t)),o.output||(o=Ks(e,t)),oe.compileRe(o,t,n,r)};oe.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(n){if(t&&t.debug===!0)throw n;return/$^/}};oe.constants=By;Kl.exports=oe});var zl=Y((eL,Vl)=>{"use strict";Vl.exports=Gl()});var Zl=Y((tL,ql)=>{"use strict";var Jl=at("util"),Yl=bl(),$e=zl(),Vs=Un(),Wl=s(e=>e===""||e==="./","isEmptyString"),Xl=s(e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},"hasBraces"),q=s((e,t,n)=>{t=[].concat(t),e=[].concat(e);let r=new Set,o=new Set,i=new Set,c=0,a=s(l=>{i.add(l.output),n&&n.onResult&&n.onResult(l)},"onResult");for(let l=0;l<t.length;l++){let p=$e(String(t[l]),{...n,onResult:a},!0),d=p.state.negated||p.state.negatedExtglob;d&&c++;for(let m of e){let g=p(m,!0);(d?!g.isMatch:g.isMatch)&&(d?r.add(g.output):(r.delete(g.output),o.add(g.output)))}}let f=(c===t.length?[...i]:[...o]).filter(l=>!r.has(l));if(n&&f.length===0){if(n.failglob===!0)throw new Error(`No matches found for "${t.join(", ")}"`);if(n.nonull===!0||n.nullglob===!0)return n.unescape?t.map(l=>l.replace(/\\/g,"")):t}return f},"micromatch");q.match=q;q.matcher=(e,t)=>$e(e,t);q.isMatch=(e,t,n)=>$e(t,n)(e);q.any=q.isMatch;q.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],i=s(a=>{n.onResult&&n.onResult(a),o.push(a.output)},"onResult"),c=new Set(q(e,t,{...n,onResult:i}));for(let a of o)c.has(a)||r.add(a);return[...r]};q.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Jl.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>q.contains(e,r,n));if(typeof t=="string"){if(Wl(e)||Wl(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return q.isMatch(e,t,{...n,contains:!0})};q.matchKeys=(e,t,n)=>{if(!Vs.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=q(Object.keys(e),t,n),o={};for(let i of r)o[i]=e[i];return o};q.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=$e(String(o),n);if(r.some(c=>i(c)))return!0}return!1};q.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=$e(String(o),n);if(!r.every(c=>i(c)))return!1}return!0};q.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Jl.inspect(e)}"`);return[].concat(t).every(r=>$e(r,n)(e))};q.capture=(e,t,n)=>{let r=Vs.isWindows(n),i=$e.makeRe(String(e),{...n,capture:!0}).exec(r?Vs.toPosixSlashes(t):t);if(i)return i.slice(1).map(c=>c===void 0?"":c)};q.makeRe=(...e)=>$e.makeRe(...e);q.scan=(...e)=>$e.scan(...e);q.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of Yl(String(r),t))n.push($e.parse(o,t));return n};q.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!Xl(e)?[e]:Yl(e,t)};q.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return q.braces(e,{...t,expand:!0})};q.hasBraces=Xl;ql.exports=q});var Yr=Y(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.MCP_MISSING_LAUNCH_SERIALIZED=se.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;se.foldMcpName=pf;se.buildMcpFamilyCanonicalKey=pR;se.launchContainsCredentials=gR;se.serializeMcpLaunchIdentity=mf;se.hashMcpLaunchIdentity=$n;se.projectMcpMissingLaunchIdentity=SR;se.projectMcpLaunchIdentity=ER;se.maskMcpLaunchForDisplay=RR;se.normalizeMcpToolNames=CR;var dR=at("node:crypto");se.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";se.MCP_MISSING_LAUNCH_SERIALIZED=`${se.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function Ze(e){return e.toLocaleLowerCase("en-US")}s(Ze,"foldCase");function pf(e){return Ze(e)}s(pf,"foldMcpName");function pR(e){return`interface:${pf(e)}`}s(pR,"buildMcpFamilyCanonicalKey");var df=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),mR=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function tn(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(tn,"lengthPrefixed");function gR(e){return e.kind==="url"?_R(e.url):e.kind==="command"?e.arguments.some(t=>mR.test(t)):!1}s(gR,"launchContainsCredentials");function _R(e){try{let t=new URL(e);if(t.username.length>0||t.password.length>0)return!0;for(let n of t.searchParams.keys())if(df.has(Ze(n)))return!0;return!1}catch{let t=e.split("://",2),n=t.length===2?t[1]:e,r=n.indexOf("@"),o=n.indexOf("/");if(r>0&&(o===-1||r<o))return!0;let i=e.split("?",2)[1];return i===void 0?!1:i.split("&").some(c=>{let a=Ze(c.split("=",1)[0]??"");return df.has(a)})}}s(_R,"urlContainsCredentials");function mf(e){if(e.kind==="url")return[se.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",tn(Ze(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>Ze(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[se.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",tn(Ze(e.command)),String(t.length),...t.map(tn)].join("|")}return[se.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",tn(e.installationRootExternalKey),tn(e.sourcePath),tn(e.nativeKey)].join("|")}s(mf,"serializeMcpLaunchIdentity");function $n(e){return(0,dR.createHash)("sha256").update(e).digest("hex")}s($n,"hashMcpLaunchIdentity");var hR=$n(se.MCP_MISSING_LAUNCH_SERIALIZED);function SR(){return{kind:"unknown",arguments:[],serialized:se.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:hR}}s(SR,"projectMcpMissingLaunchIdentity");function ER(e){let t=mf(e);return e.kind==="url"?{kind:"url",url:Ze(e.url),arguments:[],serialized:t,contentHash:$n(t)}:e.kind==="command"?{kind:"command",command:Ze(e.command),arguments:[...e.arguments].map(n=>Ze(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:$n(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:$n(t)}}s(ER,"projectMcpLaunchIdentity");var yR=/^(https?:\/\/)([^/?#]*@)/i;function RR(e){return e.replace(yR,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}s(RR,"maskMcpLaunchForDisplay");function CR(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n.sort((r,o)=>r<o?-1:r>o?1:0),n}s(CR,"normalizeMcpToolNames")});var qr=Y(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.LOCAL_BIN_PACKAGE_VERSION_SOURCE=he.PACKAGE_FIELD_MAX=void 0;he.npxExecBin=gf;he.isExactNpmVersion=_f;he.isNodeModulesBinCommand=PR;he.packageNameFromSpec=Xr;he.pinnedPackageVersionFromSpec=hf;he.pinnedPackageVersionFromNpx=MR;he.npxPackageSpecs=Sf;he.PACKAGE_FIELD_MAX=128;var AR=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,bR=new Set(["-p","--package"]),OR=new Set(["-c","--call"]),kR=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),xR=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),IR=/^--no-/;function TR(e){return xR.has(e)||IR.test(e)}s(TR,"booleanFlag");function gf(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}s(gf,"npxExecBin");var wR=/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function _f(e){return e.length<=he.PACKAGE_FIELD_MAX&&wR.test(e)}s(_f,"isExactNpmVersion");he.LOCAL_BIN_PACKAGE_VERSION_SOURCE="node_modules_local";var NR=/(?:^|\/)node_modules\/\.bin\/[^/]+$/;function PR(e){return NR.test(e.replaceAll("\\","/"))}s(PR,"isNodeModulesBinCommand");function Xr(e){if(e.length===0||e.length>he.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return AR.test(n)?n:null}s(Xr,"packageNameFromSpec");function hf(e){let t=Xr(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return _f(n)?n:void 0}s(hf,"pinnedPackageVersionFromSpec");function MR(e,t){for(let n of Sf(e,t)){let r=hf(n);if(r!==void 0)return r}}s(MR,"pinnedPackageVersionFromNpx");function Sf(e,t){let n=gf(e);if(n===null)return[];let r=[...t];if(n==="npm"){let c=r[0]?.toLowerCase();if(c!=="exec"&&c!=="x")return[];r=r.slice(1)}let o=[],i=null;for(let c=0;c<r.length;c+=1){let a=r[c]??"";if(a==="--"){i=r[c+1]??null;break}if(!a.startsWith("-")){i=a;break}let u=a.indexOf("="),f=u===-1?a:a.slice(0,u);if(OR.has(f))return[];if(bR.has(f)){let l=u===-1?r[c+1]:a.slice(u+1);l!==void 0&&l.length>0&&o.push(l),u===-1&&(c+=1);continue}if(!(u!==-1||TR(f))){if(kR.has(f)){c+=1;continue}return[]}}return o.length>0?o.every(c=>Xr(c)!==null)?o:[]:i===null||Xr(i)===null?[]:[i]}s(Sf,"npxPackageSpecs")});var yf=Y(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.McpPackageEcosystem=void 0;Qe.resolveMcpPackageIdentity=GR;Qe.resolveLocalBinPackageIdentity=VR;var Ef=Yr(),St=qr();Qe.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var LR=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,vR=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function UR(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}s(UR,"pythonRunnerBin");var HR=new Set(["--from","--spec"]),DR=new Set(["--python","-p","--with","--with-editable","--with-requirements","--index","--index-url","--default-index","--extra-index-url","--find-links","-f","--constraint","-c","--override","--refresh-package","--cache-dir","--directory","--project","--config-file","--color","--exclude-newer","--pip-args","--verbose-pip"]),FR=new Set(["-q","--quiet","-v","--verbose","-n","--native-tls","--offline","--isolated","--preview","--refresh","--reinstall","--upgrade","-U","--force","--system","--system-site-packages","--path","--managed-python","--progress"]),$R=/^--no-/;function jR(e,t){let n=UR(e);if(n===null)return null;let r=[...t];if(n==="uv"){if(r[0]?.toLowerCase()!=="tool"||r[1]?.toLowerCase()!=="run")return null;r=r.slice(2)}else if(n==="pipx"){if(r[0]?.toLowerCase()!=="run")return null;r=r.slice(1)}let o=null,i=null;for(let c=0;c<r.length;c+=1){let a=r[c]??"";if(a==="--"){i=r[c+1]??null;break}if(!a.startsWith("-")){i=a;break}let u=a.indexOf("="),f=u===-1?a:a.slice(0,u);if(HR.has(f)){let l=u===-1?r[c+1]:a.slice(u+1);l!==void 0&&l.length>0&&(o=l),u===-1&&(c+=1);continue}if(!(u!==-1||FR.has(f)||$R.test(f))){if(DR.has(f)){c+=1;continue}return null}}return o??i}s(jR,"pythonRunnerSpec");function BR(e){if(e.length===0||e.length>St.PACKAGE_FIELD_MAX)return null;let t=e.includes("==")?"==":e.includes("@")?"@":null;if(t===null)return null;let n=e.indexOf(t),r=e.slice(0,n),o=e.slice(n+t.length);return!LR.test(r)||!vR.test(o)?null:{ecosystem:Qe.McpPackageEcosystem.PYPI,packageName:r,version:o}}s(BR,"pypiIdentityFromSpec");function KR(e){let t=(0,St.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return(0,St.isExactNpmVersion)(n)?{ecosystem:Qe.McpPackageEcosystem.NPM,packageName:t,version:n}:null}s(KR,"npmIdentityFromSpec");function GR(e){if(e?.kind!=="command"||(0,Ef.launchContainsCredentials)(e))return;for(let n of(0,St.npxPackageSpecs)(e.command,e.arguments)){let r=KR(n);if(r!==null)return r}let t=jR(e.command,e.arguments);if(t!==null)return BR(t)??void 0}s(GR,"resolveMcpPackageIdentity");function VR(e,t){if(e?.kind!=="command"||(0,Ef.launchContainsCredentials)(e)||!(0,St.isNodeModulesBinCommand)(e.command)||t.packageVersionSource!==St.LOCAL_BIN_PACKAGE_VERSION_SOURCE)return;let{packageName:n,packageVersion:r}=t;if(!(n===void 0||r===void 0||(0,St.packageNameFromSpec)(n)!==n||!(0,St.isExactNpmVersion)(r)))return{ecosystem:Qe.McpPackageEcosystem.NPM,packageName:n,version:r}}s(VR,"resolveLocalBinPackageIdentity")});var xf=Y(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.EMPTY_NPM_PUBLISHER=void 0;et.isNpmRegistryPublisher=WR;et.displayPublisherName=JR;et.classifyMcpProvenance=nC;var bf=Yr(),jn=qr();et.EMPTY_NPM_PUBLISHER="npm:";var Rf="npm:",zR=/^[A-Za-z0-9._-]+$/;function WR(e){return e.startsWith(Rf)&&e!==et.EMPTY_NPM_PUBLISHER&&zR.test(e.slice(Rf.length))}s(WR,"isNpmRegistryPublisher");function JR(e){if(!(e==null||e===""||e===et.EMPTY_NPM_PUBLISHER))return e}s(JR,"displayPublisherName");function Cf(e){let t=e.split(".").map(Number);return t.length!==4||t.some(n=>!Number.isInteger(n)||n<0||n>255)?!1:t[0]===0||t[0]===10||t[0]===127||t[0]===169&&t[1]===254||t[0]===172&&(t[1]??0)>=16&&(t[1]??0)<=31||t[0]===192&&t[1]===168}s(Cf,"privateIpv4");function YR(e){let t=/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(e);if(t?.[1])return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(e);if(!n)return;let r=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16);return`${r>>8&255}.${r&255}.${o>>8&255}.${o&255}`}s(YR,"ipv4MappedAddress");function qs(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}s(qs,"normalizedHost");function XR(e){let t=qs(e),n=YR(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||Cf(t)||n!==void 0&&Cf(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}s(XR,"privateHostname");function qR(e){let t=qs(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}s(qR,"publisherHost");function ZR(e){let t=qs(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}s(ZR,"publicOrigin");function Of(e){let t={kind:"url",url:e};if((0,bf.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||XR(n.hostname))return{origin:"UNKNOWN"};let r=qR(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:ZR(n)}}catch{return{origin:"UNKNOWN"}}}s(Of,"classifyUrl");var kf="mcp-remote";function QR(e,t){if(e===kf)return t.find(n=>/^https?:\/\//i.test(n))}s(QR,"remoteUrlChild");function eC(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}s(eC,"thirdPartyPackage");function Af(e,t,n){let r=QR(e,t);return r!==void 0?Of(r):e===kf?{origin:"UNKNOWN"}:eC(e,n)}s(Af,"classifyRegistryPackage");function tC(e){let t=e.replaceAll("\\","/");return t.startsWith("~/")||t.startsWith("/")||/^[A-Za-z]:\//.test(t)?!1:t.startsWith("./")||t.startsWith("../")||t==="scripts"||t.startsWith("scripts/")}s(tC,"isRepoRelativeCommand");function nC(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,bf.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return Of(t.url);let r=(0,jn.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,jn.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let i=Af(o,t.arguments,e.publisherName),c=typeof e.packageName=="string"?(0,jn.packageNameFromSpec)(e.packageName):null;return c!==null&&c===o&&i.packageName!==void 0?{...i,packageName:c,packageKey:c}:i}if((0,jn.isNodeModulesBinCommand)(t.command)){let o=typeof e.packageName=="string"?(0,jn.packageNameFromSpec)(e.packageName):null;return o===null||o!==e.packageName?{origin:"UNKNOWN"}:Af(o,t.arguments,e.publisherName)}return tC(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}s(nC,"classifyMcpProvenance")});var Tf=Y(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Zr.mcpServerToolSegmentForms=If;Zr.mcpServerNameMatchesToolSegment=rC;function If(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}s(If,"mcpServerToolSegmentForms");function rC(e,t){let n=t.toLowerCase();return If(e).some(r=>r.toLowerCase()===n)}s(rC,"mcpServerNameMatchesToolSegment")});var wf=Y(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.parseFrontmatterField=Ne.parseFrontmatterDescription=Ne.usableCatalogText=void 0;var oC=/^(?:>|\|)[-+]?$/,sC=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,iC=s(e=>{let t=e?.trim()??"";if(!(t.length===0||oC.test(t)))return t},"usableCatalogText");Ne.usableCatalogText=iC;var cC=s(e=>(0,Ne.parseFrontmatterField)(e,"description"),"parseFrontmatterDescription");Ne.parseFrontmatterDescription=cC;var aC=s((e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return lC(n[1],t)},"parseFrontmatterField");Ne.parseFrontmatterField=aC;var uC=s(e=>e.replace(/^["']|["']$/g,""),"stripYamlQuotes");function lC(e,t){let n=e.split(`
6
- `),r=`${t}:`,o=n.findIndex(m=>m===r||m.startsWith(`${r} `)||m.startsWith(`${r} `));if(o<0)return;let i=(n[o]??"").slice(r.length).trim(),c=sC.exec(i);if(!c){let m=uC(i).trim();return(0,Ne.usableCatalogText)(m)}let a=[];for(let m=o+1;m<n.length;m+=1){let g=n[m]??"";if(g.trim()===""){a.push("");continue}if(g.length===g.trimStart().length)break;a.push(g)}let u=a.reduce((m,g)=>g.trim()===""?m:Math.min(m,g.length-g.trimStart().length),Number.POSITIVE_INFINITY),f=[],l=c[1]?.trim();l&&f.push(l);for(let m of a)f.push(m.trim()===""?"":m.slice(u));for(;f.length>0&&f[f.length-1]==="";)f.pop();let d=i.startsWith(">")?f.join(`
4
+ var ih=Object.create;var ns=Object.defineProperty;var ah=Object.getOwnPropertyDescriptor;var ch=Object.getOwnPropertyNames;var uh=Object.getPrototypeOf,lh=Object.prototype.hasOwnProperty;var s=(e,t)=>ns(e,"name",{value:t,configurable:!0}),Be=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var W=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var fh=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ch(t))!lh.call(e,o)&&o!==n&&ns(e,o,{get:()=>t[o],enumerable:!(r=ah(t,o))||r.enumerable});return e};var Ie=(e,t,n)=>(n=e!=null?ih(uh(e)):{},fh(t||!e||!e.__esModule?ns(n,"default",{value:e,enumerable:!0}):n,e));var Jr=W(we=>{"use strict";we.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;we.find=(e,t)=>e.nodes.find(n=>n.type===t);we.exceedsLimit=(e,t,n=1,r)=>r===!1||!we.isInteger(e)||!we.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;we.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||r.type==="open"||r.type==="close")&&r.escaped!==!0&&(r.value="\\"+r.value,r.escaped=!0)};we.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;we.isInvalidBrace=e=>e.type!=="brace"?!1:e.invalid===!0||e.dollar?!0:e.commas>>0+e.ranges>>0===0||e.open!==!0||e.close!==!0?(e.invalid=!0,!0):!1;we.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;we.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);we.flatten=(...e)=>{let t=[],n=s(r=>{for(let o=0;o<r.length;o++){let i=r[o];if(Array.isArray(i)){n(i);continue}i!==void 0&&t.push(i)}return t},"flat");return n(e),t}});var Xr=W((dv,pl)=>{"use strict";var dl=Jr();pl.exports=(e,t={})=>{let n=s((r,o={})=>{let i=t.escapeInvalid&&dl.isInvalidBrace(o),a=r.invalid===!0&&t.escapeInvalid===!0,c="";if(r.value)return(i||a)&&dl.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let u of r.nodes)c+=n(u);return c},"stringify");return n(e)}});var gl=W((mv,ml)=>{"use strict";ml.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var Ol=W((gv,Al)=>{"use strict";var _l=gl(),Ht=s((e,t,n)=>{if(_l(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(_l(t)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let o=String(r.relaxZeros),i=String(r.shorthand),a=String(r.capture),c=String(r.wrap),u=e+":"+t+"="+o+i+a+c;if(Ht.cache.hasOwnProperty(u))return Ht.cache[u].result;let f=Math.min(e,t),l=Math.max(e,t);if(Math.abs(f-l)===1){let E=e+"|"+t;return r.capture?`(${E})`:r.wrap===!1?E:`(?:${E})`}let p=Cl(e)||Cl(t),d={min:e,max:t,a:f,b:l},m=[],g=[];if(p&&(d.isPadded=p,d.maxLen=String(d.max).length),f<0){let E=l<0?Math.abs(l):1;g=hl(E,Math.abs(f),d,r),f=d.a=0}return l>=0&&(m=hl(f,l,d,r)),d.negatives=g,d.positives=m,d.result=Sy(g,m,r),r.capture===!0?d.result=`(${d.result})`:r.wrap!==!1&&m.length+g.length>1&&(d.result=`(?:${d.result})`),Ht.cache[u]=d,d.result},"toRegexRange");function Sy(e,t,n){let r=zs(e,t,"-",!1,n)||[],o=zs(t,e,"",!1,n)||[],i=zs(e,t,"-?",!0,n)||[];return r.concat(i).concat(o).join("|")}s(Sy,"collatePatterns");function yy(e,t){let n=1,r=1,o=Sl(e,n),i=new Set([t]);for(;e<=o&&o<=t;)i.add(o),n+=1,o=Sl(e,n);for(o=yl(t+1,r)-1;e<o&&o<=t;)i.add(o),r+=1,o=yl(t+1,r)-1;return i=[...i],i.sort(Ay),i}s(yy,"splitToRanges");function Ry(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=Cy(e,t),o=r.length,i="",a=0;for(let c=0;c<o;c++){let[u,f]=r[c];u===f?i+=u:u!=="0"||f!=="9"?i+=Oy(u,f,n):a++}return a&&(i+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:i,count:[a],digits:o}}s(Ry,"rangeToPattern");function hl(e,t,n,r){let o=yy(e,t),i=[],a=e,c;for(let u=0;u<o.length;u++){let f=o[u],l=Ry(String(a),String(f),r),p="";if(!n.isPadded&&c&&c.pattern===l.pattern){c.count.length>1&&c.count.pop(),c.count.push(l.count[0]),c.string=c.pattern+Rl(c.count),a=f+1;continue}n.isPadded&&(p=by(f,n,r)),l.string=p+l.pattern+Rl(l.count),i.push(l),a=f+1,c=l}return i}s(hl,"splitToPatterns");function zs(e,t,n,r,o){let i=[];for(let a of e){let{string:c}=a;!r&&!El(t,"string",c)&&i.push(n+c),r&&El(t,"string",c)&&i.push(n+c)}return i}s(zs,"filterPatterns");function Cy(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}s(Cy,"zip");function Ay(e,t){return e>t?1:t>e?-1:0}s(Ay,"compare");function El(e,t,n){return e.some(r=>r[t]===n)}s(El,"contains");function Sl(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}s(Sl,"countNines");function yl(e,t){return e-e%Math.pow(10,t)}s(yl,"countZeros");function Rl(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}s(Rl,"toQuantifier");function Oy(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}s(Oy,"toCharacterClass");function Cl(e){return/^-?(0+)\d/.test(e)}s(Cl,"hasPadding");function by(e,t,n){if(!t.isPadded)return e;let r=Math.abs(t.maxLen-String(e).length),o=n.relaxZeros!==!1;switch(r){case 0:return"";case 1:return o?"0?":"0";case 2:return o?"0{0,2}":"00";default:return o?`0{0,${r}}`:`0{${r}}`}}s(by,"padZeros");Ht.cache={};Ht.clearCache=()=>Ht.cache={};Al.exports=Ht});var Js=W((hv,Nl)=>{"use strict";var Iy=Be("util"),Il=Ol(),bl=s(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"isObject"),Ty=s(e=>t=>e===!0?Number(t):String(t),"transform"),Ws=s(e=>typeof e=="number"||typeof e=="string"&&e!=="","isValidValue"),Bn=s(e=>Number.isInteger(+e),"isNumber"),Ys=s(e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},"zeros"),ky=s((e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,"stringify"),xy=s((e,t,n)=>{if(t>0){let r=e[0]==="-"?"-":"";r&&(e=e.slice(1)),e=r+e.padStart(r?t-1:t,"0")}return n===!1?String(e):e},"pad"),Zr=s((e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},"toMaxLen"),Py=s((e,t,n)=>{e.negatives.sort((c,u)=>c<u?-1:c>u?1:0),e.positives.sort((c,u)=>c<u?-1:c>u?1:0);let r=t.capture?"":"?:",o="",i="",a;return e.positives.length&&(o=e.positives.map(c=>Zr(String(c),n)).join("|")),e.negatives.length&&(i=`-(${r}${e.negatives.map(c=>Zr(String(c),n)).join("|")})`),o&&i?a=`${o}|${i}`:a=o||i,t.wrap?`(${r}${a})`:a},"toSequence"),Tl=s((e,t,n,r)=>{if(n)return Il(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let i=String.fromCharCode(t);return`[${o}-${i}]`},"toRange"),kl=s((e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return Il(e,t,n)},"toRegex"),xl=s((...e)=>new RangeError("Invalid range arguments: "+Iy.inspect(...e)),"rangeError"),Pl=s((e,t,n)=>{if(n.strictRanges===!0)throw xl([e,t]);return[]},"invalidRange"),Ny=s((e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},"invalidStep"),wy=s((e,t,n=1,r={})=>{let o=Number(e),i=Number(t);if(!Number.isInteger(o)||!Number.isInteger(i)){if(r.strictRanges===!0)throw xl([e,t]);return[]}o===0&&(o=0),i===0&&(i=0);let a=o>i,c=String(e),u=String(t),f=String(n);n=Math.max(Math.abs(n),1);let l=Ys(c)||Ys(u)||Ys(f),p=l?Math.max(c.length,u.length,f.length):0,d=l===!1&&ky(e,t,r)===!1,m=r.transform||Ty(d);if(r.toRegex&&n===1)return Tl(Zr(e,p),Zr(t,p),!0,r);let g={negatives:[],positives:[]},E=s(P=>g[P<0?"negatives":"positives"].push(Math.abs(P)),"push"),S=[],C=0;for(;a?o>=i:o<=i;)r.toRegex===!0&&n>1?E(o):S.push(xy(m(o,C),p,d)),o=a?o-n:o+n,C++;return r.toRegex===!0?n>1?Py(g,r,p):kl(S,null,{wrap:!1,...r}):S},"fillNumbers"),Ly=s((e,t,n=1,r={})=>{if(!Bn(e)&&e.length>1||!Bn(t)&&t.length>1)return Pl(e,t,r);let o=r.transform||(d=>String.fromCharCode(d)),i=`${e}`.charCodeAt(0),a=`${t}`.charCodeAt(0),c=i>a,u=Math.min(i,a),f=Math.max(i,a);if(r.toRegex&&n===1)return Tl(u,f,!1,r);let l=[],p=0;for(;c?i>=a:i<=a;)l.push(o(i,p)),i=c?i-n:i+n,p++;return r.toRegex===!0?kl(l,null,{wrap:!1,options:r}):l},"fillLetters"),qr=s((e,t,n,r={})=>{if(t==null&&Ws(e))return[e];if(!Ws(e)||!Ws(t))return Pl(e,t,r);if(typeof n=="function")return qr(e,t,1,{transform:n});if(bl(n))return qr(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,Bn(n)?Bn(e)&&Bn(t)?wy(e,t,n,o):Ly(e,t,Math.max(Math.abs(n),1),o):n!=null&&!bl(n)?Ny(n,o):qr(e,t,1,n)},"fill");Nl.exports=qr});var Ml=W((Sv,Ll)=>{"use strict";var My=Js(),wl=Jr(),vy=s((e,t={})=>{let n=s((r,o={})=>{let i=wl.isInvalidBrace(o),a=r.invalid===!0&&t.escapeInvalid===!0,c=i===!0||a===!0,u=t.escapeInvalid===!0?"\\":"",f="";if(r.isOpen===!0)return u+r.value;if(r.isClose===!0)return console.log("node.isClose",u,r.value),u+r.value;if(r.type==="open")return c?u+r.value:"(";if(r.type==="close")return c?u+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":c?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let l=wl.reduce(r.nodes),p=My(...l,{...t,wrap:!1,toRegex:!0,strictZeros:!0});if(p.length!==0)return l.length>1&&p.length>1?`(${p})`:p}if(r.nodes)for(let l of r.nodes)f+=n(l,r);return f},"walk");return n(e)},"compile");Ll.exports=vy});var Dl=W((Rv,Ul)=>{"use strict";var Uy=Js(),vl=Xr(),on=Jr(),Ft=s((e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?on.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let i of o)r.push(Ft(i,t,n));else for(let i of t)n===!0&&typeof i=="string"&&(i=`{${i}}`),r.push(Array.isArray(i)?Ft(o,i,n):o+i);return on.flatten(r)},"append"),Dy=s((e,t={})=>{let n=t.rangeLimit===void 0?1e3:t.rangeLimit,r=s((o,i={})=>{o.queue=[];let a=i,c=i.queue;for(;a.type!=="brace"&&a.type!=="root"&&a.parent;)a=a.parent,c=a.queue;if(o.invalid||o.dollar){c.push(Ft(c.pop(),vl(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){c.push(Ft(c.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let p=on.reduce(o.nodes);if(on.exceedsLimit(...p,t.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let d=Uy(...p,t);d.length===0&&(d=vl(o,t)),c.push(Ft(c.pop(),d)),o.nodes=[];return}let u=on.encloseBrace(o),f=o.queue,l=o;for(;l.type!=="brace"&&l.type!=="root"&&l.parent;)l=l.parent,f=l.queue;for(let p=0;p<o.nodes.length;p++){let d=o.nodes[p];if(d.type==="comma"&&o.type==="brace"){p===1&&f.push(""),f.push("");continue}if(d.type==="close"){c.push(Ft(c.pop(),f,u));continue}if(d.value&&d.type!=="open"){f.push(Ft(f.pop(),d.value));continue}d.nodes&&r(d,o)}return f},"walk");return on.flatten(r(e))},"expand");Ul.exports=Dy});var Fl=W((Av,Hl)=>{"use strict";Hl.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
5
+ `,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Gl=W((Ov,Kl)=>{"use strict";var Hy=Xr(),{MAX_LENGTH:$l,CHAR_BACKSLASH:Xs,CHAR_BACKTICK:Fy,CHAR_COMMA:$y,CHAR_DOT:jy,CHAR_LEFT_PARENTHESES:By,CHAR_RIGHT_PARENTHESES:Ky,CHAR_LEFT_CURLY_BRACE:Gy,CHAR_RIGHT_CURLY_BRACE:Vy,CHAR_LEFT_SQUARE_BRACKET:jl,CHAR_RIGHT_SQUARE_BRACKET:Bl,CHAR_DOUBLE_QUOTE:zy,CHAR_SINGLE_QUOTE:Wy,CHAR_NO_BREAK_SPACE:Yy,CHAR_ZERO_WIDTH_NOBREAK_SPACE:Jy}=Fl(),Xy=s((e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min($l,n.maxLength):$l;if(e.length>r)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${r})`);let o={type:"root",input:e,nodes:[]},i=[o],a=o,c=o,u=0,f=e.length,l=0,p=0,d,m=s(()=>e[l++],"advance"),g=s(E=>{if(E.type==="text"&&c.type==="dot"&&(c.type="text"),c&&c.type==="text"&&E.type==="text"){c.value+=E.value;return}return a.nodes.push(E),E.parent=a,E.prev=c,c=E,E},"push");for(g({type:"bos"});l<f;)if(a=i[i.length-1],d=m(),!(d===Jy||d===Yy)){if(d===Xs){g({type:"text",value:(t.keepEscaping?d:"")+m()});continue}if(d===Bl){g({type:"text",value:"\\"+d});continue}if(d===jl){u++;let E;for(;l<f&&(E=m());){if(d+=E,E===jl){u++;continue}if(E===Xs){d+=m();continue}if(E===Bl&&(u--,u===0))break}g({type:"text",value:d});continue}if(d===By){a=g({type:"paren",nodes:[]}),i.push(a),g({type:"text",value:d});continue}if(d===Ky){if(a.type!=="paren"){g({type:"text",value:d});continue}a=i.pop(),g({type:"text",value:d}),a=i[i.length-1];continue}if(d===zy||d===Wy||d===Fy){let E=d,S;for(t.keepQuotes!==!0&&(d="");l<f&&(S=m());){if(S===Xs){d+=S+m();continue}if(S===E){t.keepQuotes===!0&&(d+=S);break}d+=S}g({type:"text",value:d});continue}if(d===Gy){p++;let S={type:"brace",open:!0,close:!1,dollar:c.value&&c.value.slice(-1)==="$"||a.dollar===!0,depth:p,commas:0,ranges:0,nodes:[]};a=g(S),i.push(a),g({type:"open",value:d});continue}if(d===Vy){if(a.type!=="brace"){g({type:"text",value:d});continue}let E="close";a=i.pop(),a.close=!0,g({type:E,value:d}),p--,a=i[i.length-1];continue}if(d===$y&&p>0){if(a.ranges>0){a.ranges=0;let E=a.nodes.shift();a.nodes=[E,{type:"text",value:Hy(a)}]}g({type:"comma",value:d}),a.commas++;continue}if(d===jy&&p>0&&a.commas===0){let E=a.nodes;if(p===0||E.length===0){g({type:"text",value:d});continue}if(c.type==="dot"){if(a.range=[],c.value+=d,c.type="range",a.nodes.length!==3&&a.nodes.length!==5){a.invalid=!0,a.ranges=0,c.type="text";continue}a.ranges++,a.args=[];continue}if(c.type==="range"){E.pop();let S=E[E.length-1];S.value+=c.value+d,c=S,a.ranges--;continue}g({type:"dot",value:d});continue}g({type:"text",value:d})}do if(a=i.pop(),a.type!=="root"){a.nodes.forEach(C=>{C.nodes||(C.type==="open"&&(C.isOpen=!0),C.type==="close"&&(C.isClose=!0),C.nodes||(C.type="text"),C.invalid=!0)});let E=i[i.length-1],S=E.nodes.indexOf(a);E.nodes.splice(S,1,...a.nodes)}while(i.length>0);return g({type:"eos"}),o},"parse");Kl.exports=Xy});var Wl=W((Iv,zl)=>{"use strict";var Vl=Xr(),qy=Ml(),Zy=Dl(),Qy=Gl(),Te=s((e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=Te.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(Te.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n},"braces");Te.parse=(e,t={})=>Qy(e,t);Te.stringify=(e,t={})=>Vl(typeof e=="string"?Te.parse(e,t):e,t);Te.compile=(e,t={})=>(typeof e=="string"&&(e=Te.parse(e,t)),qy(e,t));Te.expand=(e,t={})=>{typeof e=="string"&&(e=Te.parse(e,t));let n=Zy(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};Te.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?Te.compile(e,t):Te.expand(e,t);zl.exports=Te});var Kn=W((kv,Zl)=>{"use strict";var eR=Be("path"),Ge="\\\\/",Yl=`[^${Ge}]`,tR=0,tt="\\.",nR="\\+",rR="\\?",Qr="\\/",oR="(?=.)",Jl="[^/]",qs=`(?:${Qr}|$)`,Xl=`(?:^|${Qr})`,Zs=`${tt}{1,2}${qs}`,sR=`(?!${tt})`,iR=`(?!${Xl}${Zs})`,aR=`(?!${tt}{0,1}${qs})`,cR=`(?!${Zs})`,uR=`[^.${Qr}]`,lR=`${Jl}*?`,ql={DOT_LITERAL:tt,PLUS_LITERAL:nR,QMARK_LITERAL:rR,SLASH_LITERAL:Qr,ONE_CHAR:oR,QMARK:Jl,END_ANCHOR:qs,DOTS_SLASH:Zs,NO_DOT:sR,NO_DOTS:iR,NO_DOT_SLASH:aR,NO_DOTS_SLASH:cR,QMARK_NO_DOT:uR,STAR:lR,START_ANCHOR:Xl},fR={...ql,SLASH_LITERAL:`[${Ge}]`,QMARK:Yl,STAR:`${Yl}*?`,DOTS_SLASH:`${tt}{1,2}(?:[${Ge}]|$)`,NO_DOT:`(?!${tt})`,NO_DOTS:`(?!(?:^|[${Ge}])${tt}{1,2}(?:[${Ge}]|$))`,NO_DOT_SLASH:`(?!${tt}{0,1}(?:[${Ge}]|$))`,NO_DOTS_SLASH:`(?!${tt}{1,2}(?:[${Ge}]|$))`,QMARK_NO_DOT:`[^.${Ge}]`,START_ANCHOR:`(?:^|[${Ge}])`,END_ANCHOR:`(?:[${Ge}]|$)`},dR={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};Zl.exports={DEFAULT_MAX_EXTGLOB_RECURSION:tR,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:dR,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:eR.sep,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?fR:ql}}});var Gn=W(ye=>{"use strict";var pR=Be("path"),mR=process.platform==="win32",{REGEX_BACKSLASH:gR,REGEX_REMOVE_BACKSLASH:_R,REGEX_SPECIAL_CHARS:hR,REGEX_SPECIAL_CHARS_GLOBAL:ER}=Kn();ye.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);ye.hasRegexChars=e=>hR.test(e);ye.isRegexChar=e=>e.length===1&&ye.hasRegexChars(e);ye.escapeRegex=e=>e.replace(ER,"\\$1");ye.toPosixSlashes=e=>e.replace(gR,"/");ye.removeBackslashes=e=>e.replace(_R,t=>t==="\\"?"":t);ye.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};ye.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:mR===!0||pR.sep==="\\";ye.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?ye.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};ye.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};ye.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",i=`${r}(?:${e})${o}`;return t.negated===!0&&(i=`(?:^(?!${i}).*$)`),i}});var af=W((Pv,sf)=>{"use strict";var Ql=Gn(),{CHAR_ASTERISK:Qs,CHAR_AT:SR,CHAR_BACKWARD_SLASH:Vn,CHAR_COMMA:yR,CHAR_DOT:ei,CHAR_EXCLAMATION_MARK:ti,CHAR_FORWARD_SLASH:of,CHAR_LEFT_CURLY_BRACE:ni,CHAR_LEFT_PARENTHESES:ri,CHAR_LEFT_SQUARE_BRACKET:RR,CHAR_PLUS:CR,CHAR_QUESTION_MARK:ef,CHAR_RIGHT_CURLY_BRACE:AR,CHAR_RIGHT_PARENTHESES:tf,CHAR_RIGHT_SQUARE_BRACKET:OR}=Kn(),nf=s(e=>e===of||e===Vn,"isPathSeparator"),rf=s(e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},"depth"),bR=s((e,t)=>{let n=t||{},r=e.length-1,o=n.parts===!0||n.scanToEnd===!0,i=[],a=[],c=[],u=e,f=-1,l=0,p=0,d=!1,m=!1,g=!1,E=!1,S=!1,C=!1,P=!1,N=!1,T=!1,b=!1,U=0,L,I,w={value:"",depth:0,isGlob:!1},v=s(()=>f>=r,"eos"),h=s(()=>u.charCodeAt(f+1),"peek"),k=s(()=>(L=I,u.charCodeAt(++f)),"advance");for(;f<r;){I=k();let he;if(I===Vn){P=w.backslashes=!0,I=k(),I===ni&&(C=!0);continue}if(C===!0||I===ni){for(U++;v()!==!0&&(I=k());){if(I===Vn){P=w.backslashes=!0,k();continue}if(I===ni){U++;continue}if(C!==!0&&I===ei&&(I=k())===ei){if(d=w.isBrace=!0,g=w.isGlob=!0,b=!0,o===!0)continue;break}if(C!==!0&&I===yR){if(d=w.isBrace=!0,g=w.isGlob=!0,b=!0,o===!0)continue;break}if(I===AR&&(U--,U===0)){C=!1,d=w.isBrace=!0,b=!0;break}}if(o===!0)continue;break}if(I===of){if(i.push(f),a.push(w),w={value:"",depth:0,isGlob:!1},b===!0)continue;if(L===ei&&f===l+1){l+=2;continue}p=f+1;continue}if(n.noext!==!0&&(I===CR||I===SR||I===Qs||I===ef||I===ti)===!0&&h()===ri){if(g=w.isGlob=!0,E=w.isExtglob=!0,b=!0,I===ti&&f===l&&(T=!0),o===!0){for(;v()!==!0&&(I=k());){if(I===Vn){P=w.backslashes=!0,I=k();continue}if(I===tf){g=w.isGlob=!0,b=!0;break}}continue}break}if(I===Qs){if(L===Qs&&(S=w.isGlobstar=!0),g=w.isGlob=!0,b=!0,o===!0)continue;break}if(I===ef){if(g=w.isGlob=!0,b=!0,o===!0)continue;break}if(I===RR){for(;v()!==!0&&(he=k());){if(he===Vn){P=w.backslashes=!0,k();continue}if(he===OR){m=w.isBracket=!0,g=w.isGlob=!0,b=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&I===ti&&f===l){N=w.negated=!0,l++;continue}if(n.noparen!==!0&&I===ri){if(g=w.isGlob=!0,o===!0){for(;v()!==!0&&(I=k());){if(I===ri){P=w.backslashes=!0,I=k();continue}if(I===tf){b=!0;break}}continue}break}if(g===!0){if(b=!0,o===!0)continue;break}}n.noext===!0&&(E=!1,g=!1);let G=u,Oe="",y="";l>0&&(Oe=u.slice(0,l),u=u.slice(l),p-=l),G&&g===!0&&p>0?(G=u.slice(0,p),y=u.slice(p)):g===!0?(G="",y=u):G=u,G&&G!==""&&G!=="/"&&G!==u&&nf(G.charCodeAt(G.length-1))&&(G=G.slice(0,-1)),n.unescape===!0&&(y&&(y=Ql.removeBackslashes(y)),G&&P===!0&&(G=Ql.removeBackslashes(G)));let R={prefix:Oe,input:e,start:l,base:G,glob:y,isBrace:d,isBracket:m,isGlob:g,isExtglob:E,isGlobstar:S,negated:N,negatedExtglob:T};if(n.tokens===!0&&(R.maxDepth=0,nf(I)||a.push(w),R.tokens=a),n.parts===!0||n.tokens===!0){let he;for(let V=0;V<i.length;V++){let He=he?he+1:l,Fe=i[V],be=e.slice(He,Fe);n.tokens&&(V===0&&l!==0?(a[V].isPrefix=!0,a[V].value=Oe):a[V].value=be,rf(a[V]),R.maxDepth+=a[V].depth),(V!==0||be!=="")&&c.push(be),he=Fe}if(he&&he+1<e.length){let V=e.slice(he+1);c.push(V),n.tokens&&(a[a.length-1].value=V,rf(a[a.length-1]),R.maxDepth+=a[a.length-1].depth)}R.slashes=i,R.parts=c}return R},"scan");sf.exports=bR});var df=W((wv,ff)=>{"use strict";var zn=Kn(),_e=Gn(),{MAX_LENGTH:eo,POSIX_REGEX_SOURCE:IR,REGEX_NON_SPECIAL_CHARS:TR,REGEX_SPECIAL_CHARS_BACKREF:kR,REPLACEMENTS:cf}=zn,xR=s((e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n)}catch{return e.map(o=>_e.escapeRegex(o)).join("..")}return n},"expandRange"),sn=s((e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,"syntaxError"),uf=s(e=>{let t=[],n=0,r=0,o=0,i="",a=!1;for(let c of e){if(a===!0){i+=c,a=!1;continue}if(c==="\\"){i+=c,a=!0;continue}if(c==='"'){o=o===1?0:1,i+=c;continue}if(o===0){if(c==="[")n++;else if(c==="]"&&n>0)n--;else if(n===0){if(c==="(")r++;else if(c===")"&&r>0)r--;else if(c==="|"&&r===0){t.push(i),i="";continue}}}i+=c}return t.push(i),t},"splitTopLevel"),PR=s(e=>{let t=!1;for(let n of e){if(t===!0){t=!1;continue}if(n==="\\"){t=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},"isPlainBranch"),lf=s(e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(PR(t))return t.replace(/\\(.)/g,"$1")},"normalizeSimpleBranch"),NR=s(e=>{let t=e.map(lf).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let o=t[n],i=t[r],a=o[0];if(!(!a||o!==a.repeat(o.length)||i!==a.repeat(i.length))&&(o===i||o.startsWith(i)||i.startsWith(o)))return!0}return!1},"hasRepeatedCharPrefixOverlap"),oi=s((e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,r=0,o=0,i=!1;for(let a=1;a<e.length;a++){let c=e[a];if(i===!0){i=!1;continue}if(c==="\\"){i=!0;continue}if(c==='"'){o=o===1?0:1;continue}if(o!==1){if(c==="["){n++;continue}if(c==="]"&&n>0){n--;continue}if(!(n>0)){if(c==="("){r++;continue}if(c===")"&&(r--,r===0))return t===!0&&a!==e.length-1?void 0:{type:e[0],body:e.slice(2,a),end:a}}}}},"parseRepeatedExtglob"),wR=s(e=>{let t=0,n=[];for(;t<e.length;){let o=oi(e.slice(t),!1);if(!o||o.type!=="*")return;let i=uf(o.body).map(c=>c.trim());if(i.length!==1)return;let a=lf(i[0]);if(!a||a.length!==1)return;n.push(a),t+=o.end+1}return n.length<1?void 0:`${n.length===1?_e.escapeRegex(n[0]):`[${n.map(o=>_e.escapeRegex(o)).join("")}]`}*`},"getStarExtglobSequenceOutput"),LR=s(e=>{let t=0,n=e.trim(),r=oi(n);for(;r;)t++,n=r.body.trim(),r=oi(n);return t},"repeatedExtglobRecursion"),MR=s((e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:zn.DEFAULT_MAX_EXTGLOB_RECURSION,r=uf(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||NR(r)))return{risky:!0};for(let o of r){let i=wR(o);if(i)return{risky:!0,safeOutput:i};if(LR(o)>n)return{risky:!0}}return{risky:!1}},"analyzeRepeatedExtglob"),si=s((e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=cf[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(eo,n.maxLength):eo,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let i={type:"bos",value:"",output:n.prepend||""},a=[i],c=n.capture?"":"?:",u=_e.isWindows(t),f=zn.globChars(u),l=zn.extglobChars(f),{DOT_LITERAL:p,PLUS_LITERAL:d,SLASH_LITERAL:m,ONE_CHAR:g,DOTS_SLASH:E,NO_DOT:S,NO_DOT_SLASH:C,NO_DOTS_SLASH:P,QMARK:N,QMARK_NO_DOT:T,STAR:b,START_ANCHOR:U}=f,L=s(O=>`(${c}(?:(?!${U}${O.dot?E:p}).)*?)`,"globstar"),I=n.dot?"":S,w=n.dot?N:T,v=n.bash===!0?L(n):b;n.capture&&(v=`(${v})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let h={input:e,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:a};e=_e.removePrefix(e,h),o=e.length;let k=[],G=[],Oe=[],y=i,R,he=s(()=>h.index===o-1,"eos"),V=h.peek=(O=1)=>e[h.index+O],He=h.advance=()=>e[++h.index]||"",Fe=s(()=>e.slice(h.index+1),"remaining"),be=s((O="",ee=0)=>{h.consumed+=O,h.index+=ee},"consume"),_r=s(O=>{h.output+=O.output!=null?O.output:O.value,be(O.value)},"append"),oh=s(()=>{let O=1;for(;V()==="!"&&(V(2)!=="("||V(3)==="?");)He(),h.start++,O++;return O%2===0?!1:(h.negated=!0,h.start++,!0)},"negate"),hr=s(O=>{h[O]++,Oe.push(O)},"increment"),pt=s(O=>{h[O]--,Oe.pop()},"decrement"),$=s(O=>{if(y.type==="globstar"){let ee=h.braces>0&&(O.type==="comma"||O.type==="brace"),A=O.extglob===!0||k.length&&(O.type==="pipe"||O.type==="paren");O.type!=="slash"&&O.type!=="paren"&&!ee&&!A&&(h.output=h.output.slice(0,-y.output.length),y.type="star",y.value="*",y.output=v,h.output+=y.output)}if(k.length&&O.type!=="paren"&&(k[k.length-1].inner+=O.value),(O.value||O.output)&&_r(O),y&&y.type==="text"&&O.type==="text"){y.value+=O.value,y.output=(y.output||"")+O.value;return}O.prev=y,a.push(O),y=O},"push"),Er=s((O,ee)=>{let A={...l[ee],conditions:1,inner:""};A.prev=y,A.parens=h.parens,A.output=h.output,A.startIndex=h.index,A.tokensIndex=a.length;let D=(n.capture?"(":"")+A.open;hr("parens"),$({type:O,value:ee,output:h.output?"":g}),$({type:"paren",extglob:!0,value:He(),output:D}),k.push(A)},"extglobOpen"),sh=s(O=>{let ee=e.slice(O.startIndex,h.index+1),A=e.slice(O.startIndex+2,h.index),D=MR(A,n);if((O.type==="plus"||O.type==="star")&&D.risky){let X=D.safeOutput?(O.output?"":g)+(n.capture?`(${D.safeOutput})`:D.safeOutput):void 0,$e=a[O.tokensIndex];$e.type="text",$e.value=ee,$e.output=X||_e.escapeRegex(ee);for(let je=O.tokensIndex+1;je<a.length;je++)a[je].value="",a[je].output="",delete a[je].suffix;h.output=O.output+$e.output,h.backtrack=!0,$({type:"paren",extglob:!0,value:R,output:""}),pt("parens");return}let Z=O.close+(n.capture?")":""),fe;if(O.type==="negate"){let X=v;if(O.inner&&O.inner.length>1&&O.inner.includes("/")&&(X=L(n)),(X!==v||he()||/^\)+$/.test(Fe()))&&(Z=O.close=`)$))${X}`),O.inner.includes("*")&&(fe=Fe())&&/^\.[^\\/.]+$/.test(fe)){let $e=si(fe,{...t,fastpaths:!1}).output;Z=O.close=`)${$e})${X})`}O.prev.type==="bos"&&(h.negatedExtglob=!0)}$({type:"paren",extglob:!0,value:R,output:Z}),pt("parens")},"extglobClose");if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let O=!1,ee=e.replace(kR,(A,D,Z,fe,X,$e)=>fe==="\\"?(O=!0,A):fe==="?"?D?D+fe+(X?N.repeat(X.length):""):$e===0?w+(X?N.repeat(X.length):""):N.repeat(Z.length):fe==="."?p.repeat(Z.length):fe==="*"?D?D+fe+(X?v:""):v:D?A:`\\${A}`);return O===!0&&(n.unescape===!0?ee=ee.replace(/\\/g,""):ee=ee.replace(/\\+/g,A=>A.length%2===0?"\\\\":A?"\\":"")),ee===e&&n.contains===!0?(h.output=e,h):(h.output=_e.wrapOutput(ee,h,t),h)}for(;!he();){if(R=He(),R==="\0")continue;if(R==="\\"){let A=V();if(A==="/"&&n.bash!==!0||A==="."||A===";")continue;if(!A){R+="\\",$({type:"text",value:R});continue}let D=/^\\+/.exec(Fe()),Z=0;if(D&&D[0].length>2&&(Z=D[0].length,h.index+=Z,Z%2!==0&&(R+="\\")),n.unescape===!0?R=He():R+=He(),h.brackets===0){$({type:"text",value:R});continue}}if(h.brackets>0&&(R!=="]"||y.value==="["||y.value==="[^")){if(n.posix!==!1&&R===":"){let A=y.value.slice(1);if(A.includes("[")&&(y.posix=!0,A.includes(":"))){let D=y.value.lastIndexOf("["),Z=y.value.slice(0,D),fe=y.value.slice(D+2),X=IR[fe];if(X){y.value=Z+X,h.backtrack=!0,He(),!i.output&&a.indexOf(y)===1&&(i.output=g);continue}}}(R==="["&&V()!==":"||R==="-"&&V()==="]")&&(R=`\\${R}`),R==="]"&&(y.value==="["||y.value==="[^")&&(R=`\\${R}`),n.posix===!0&&R==="!"&&y.value==="["&&(R="^"),y.value+=R,_r({value:R});continue}if(h.quotes===1&&R!=='"'){R=_e.escapeRegex(R),y.value+=R,_r({value:R});continue}if(R==='"'){h.quotes=h.quotes===1?0:1,n.keepQuotes===!0&&$({type:"text",value:R});continue}if(R==="("){hr("parens"),$({type:"paren",value:R});continue}if(R===")"){if(h.parens===0&&n.strictBrackets===!0)throw new SyntaxError(sn("opening","("));let A=k[k.length-1];if(A&&h.parens===A.parens+1){sh(k.pop());continue}$({type:"paren",value:R,output:h.parens?")":"\\)"}),pt("parens");continue}if(R==="["){if(n.nobracket===!0||!Fe().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(sn("closing","]"));R=`\\${R}`}else hr("brackets");$({type:"bracket",value:R});continue}if(R==="]"){if(n.nobracket===!0||y&&y.type==="bracket"&&y.value.length===1){$({type:"text",value:R,output:`\\${R}`});continue}if(h.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(sn("opening","["));$({type:"text",value:R,output:`\\${R}`});continue}pt("brackets");let A=y.value.slice(1);if(y.posix!==!0&&A[0]==="^"&&!A.includes("/")&&(R=`/${R}`),y.value+=R,_r({value:R}),n.literalBrackets===!1||_e.hasRegexChars(A))continue;let D=_e.escapeRegex(y.value);if(h.output=h.output.slice(0,-y.value.length),n.literalBrackets===!0){h.output+=D,y.value=D;continue}y.value=`(${c}${D}|${y.value})`,h.output+=y.value;continue}if(R==="{"&&n.nobrace!==!0){hr("braces");let A={type:"brace",value:R,output:"(",outputIndex:h.output.length,tokensIndex:h.tokens.length};G.push(A),$(A);continue}if(R==="}"){let A=G[G.length-1];if(n.nobrace===!0||!A){$({type:"text",value:R,output:R});continue}let D=")";if(A.dots===!0){let Z=a.slice(),fe=[];for(let X=Z.length-1;X>=0&&(a.pop(),Z[X].type!=="brace");X--)Z[X].type!=="dots"&&fe.unshift(Z[X].value);D=xR(fe,n),h.backtrack=!0}if(A.comma!==!0&&A.dots!==!0){let Z=h.output.slice(0,A.outputIndex),fe=h.tokens.slice(A.tokensIndex);A.value=A.output="\\{",R=D="\\}",h.output=Z;for(let X of fe)h.output+=X.output||X.value}$({type:"brace",value:R,output:D}),pt("braces"),G.pop();continue}if(R==="|"){k.length>0&&k[k.length-1].conditions++,$({type:"text",value:R});continue}if(R===","){let A=R,D=G[G.length-1];D&&Oe[Oe.length-1]==="braces"&&(D.comma=!0,A="|"),$({type:"comma",value:R,output:A});continue}if(R==="/"){if(y.type==="dot"&&h.index===h.start+1){h.start=h.index+1,h.consumed="",h.output="",a.pop(),y=i;continue}$({type:"slash",value:R,output:m});continue}if(R==="."){if(h.braces>0&&y.type==="dot"){y.value==="."&&(y.output=p);let A=G[G.length-1];y.type="dots",y.output+=R,y.value+=R,A.dots=!0;continue}if(h.braces+h.parens===0&&y.type!=="bos"&&y.type!=="slash"){$({type:"text",value:R,output:p});continue}$({type:"dot",value:R,output:p});continue}if(R==="?"){if(!(y&&y.value==="(")&&n.noextglob!==!0&&V()==="("&&V(2)!=="?"){Er("qmark",R);continue}if(y&&y.type==="paren"){let D=V(),Z=R;if(D==="<"&&!_e.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(y.value==="("&&!/[!=<:]/.test(D)||D==="<"&&!/<([!=]|\w+>)/.test(Fe()))&&(Z=`\\${R}`),$({type:"text",value:R,output:Z});continue}if(n.dot!==!0&&(y.type==="slash"||y.type==="bos")){$({type:"qmark",value:R,output:T});continue}$({type:"qmark",value:R,output:N});continue}if(R==="!"){if(n.noextglob!==!0&&V()==="("&&(V(2)!=="?"||!/[!=<:]/.test(V(3)))){Er("negate",R);continue}if(n.nonegate!==!0&&h.index===0){oh();continue}}if(R==="+"){if(n.noextglob!==!0&&V()==="("&&V(2)!=="?"){Er("plus",R);continue}if(y&&y.value==="("||n.regex===!1){$({type:"plus",value:R,output:d});continue}if(y&&(y.type==="bracket"||y.type==="paren"||y.type==="brace")||h.parens>0){$({type:"plus",value:R});continue}$({type:"plus",value:d});continue}if(R==="@"){if(n.noextglob!==!0&&V()==="("&&V(2)!=="?"){$({type:"at",extglob:!0,value:R,output:""});continue}$({type:"text",value:R});continue}if(R!=="*"){(R==="$"||R==="^")&&(R=`\\${R}`);let A=TR.exec(Fe());A&&(R+=A[0],h.index+=A[0].length),$({type:"text",value:R});continue}if(y&&(y.type==="globstar"||y.star===!0)){y.type="star",y.star=!0,y.value+=R,y.output=v,h.backtrack=!0,h.globstar=!0,be(R);continue}let O=Fe();if(n.noextglob!==!0&&/^\([^?]/.test(O)){Er("star",R);continue}if(y.type==="star"){if(n.noglobstar===!0){be(R);continue}let A=y.prev,D=A.prev,Z=A.type==="slash"||A.type==="bos",fe=D&&(D.type==="star"||D.type==="globstar");if(n.bash===!0&&(!Z||O[0]&&O[0]!=="/")){$({type:"star",value:R,output:""});continue}let X=h.braces>0&&(A.type==="comma"||A.type==="brace"),$e=k.length&&(A.type==="pipe"||A.type==="paren");if(!Z&&A.type!=="paren"&&!X&&!$e){$({type:"star",value:R,output:""});continue}for(;O.slice(0,3)==="/**";){let je=e[h.index+4];if(je&&je!=="/")break;O=O.slice(3),be("/**",3)}if(A.type==="bos"&&he()){y.type="globstar",y.value+=R,y.output=L(n),h.output=y.output,h.globstar=!0,be(R);continue}if(A.type==="slash"&&A.prev.type!=="bos"&&!fe&&he()){h.output=h.output.slice(0,-(A.output+y.output).length),A.output=`(?:${A.output}`,y.type="globstar",y.output=L(n)+(n.strictSlashes?")":"|$)"),y.value+=R,h.globstar=!0,h.output+=A.output+y.output,be(R);continue}if(A.type==="slash"&&A.prev.type!=="bos"&&O[0]==="/"){let je=O[1]!==void 0?"|$":"";h.output=h.output.slice(0,-(A.output+y.output).length),A.output=`(?:${A.output}`,y.type="globstar",y.output=`${L(n)}${m}|${m}${je})`,y.value+=R,h.output+=A.output+y.output,h.globstar=!0,be(R+He()),$({type:"slash",value:"/",output:""});continue}if(A.type==="bos"&&O[0]==="/"){y.type="globstar",y.value+=R,y.output=`(?:^|${m}|${L(n)}${m})`,h.output=y.output,h.globstar=!0,be(R+He()),$({type:"slash",value:"/",output:""});continue}h.output=h.output.slice(0,-y.output.length),y.type="globstar",y.output=L(n),y.value+=R,h.output+=y.output,h.globstar=!0,be(R);continue}let ee={type:"star",value:R,output:v};if(n.bash===!0){ee.output=".*?",(y.type==="bos"||y.type==="slash")&&(ee.output=I+ee.output),$(ee);continue}if(y&&(y.type==="bracket"||y.type==="paren")&&n.regex===!0){ee.output=R,$(ee);continue}(h.index===h.start||y.type==="slash"||y.type==="dot")&&(y.type==="dot"?(h.output+=C,y.output+=C):n.dot===!0?(h.output+=P,y.output+=P):(h.output+=I,y.output+=I),V()!=="*"&&(h.output+=g,y.output+=g)),$(ee)}for(;h.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(sn("closing","]"));h.output=_e.escapeLast(h.output,"["),pt("brackets")}for(;h.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(sn("closing",")"));h.output=_e.escapeLast(h.output,"("),pt("parens")}for(;h.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(sn("closing","}"));h.output=_e.escapeLast(h.output,"{"),pt("braces")}if(n.strictSlashes!==!0&&(y.type==="star"||y.type==="bracket")&&$({type:"maybe_slash",value:"",output:`${m}?`}),h.backtrack===!0){h.output="";for(let O of h.tokens)h.output+=O.output!=null?O.output:O.value,O.suffix&&(h.output+=O.suffix)}return h},"parse");si.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(eo,n.maxLength):eo,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=cf[e]||e;let i=_e.isWindows(t),{DOT_LITERAL:a,SLASH_LITERAL:c,ONE_CHAR:u,DOTS_SLASH:f,NO_DOT:l,NO_DOTS:p,NO_DOTS_SLASH:d,STAR:m,START_ANCHOR:g}=zn.globChars(i),E=n.dot?p:l,S=n.dot?d:l,C=n.capture?"":"?:",P={negated:!1,prefix:""},N=n.bash===!0?".*?":m;n.capture&&(N=`(${N})`);let T=s(I=>I.noglobstar===!0?N:`(${C}(?:(?!${g}${I.dot?f:a}).)*?)`,"globstar"),b=s(I=>{switch(I){case"*":return`${E}${u}${N}`;case".*":return`${a}${u}${N}`;case"*.*":return`${E}${N}${a}${u}${N}`;case"*/*":return`${E}${N}${c}${u}${S}${N}`;case"**":return E+T(n);case"**/*":return`(?:${E}${T(n)}${c})?${S}${u}${N}`;case"**/*.*":return`(?:${E}${T(n)}${c})?${S}${N}${a}${u}${N}`;case"**/.*":return`(?:${E}${T(n)}${c})?${a}${u}${N}`;default:{let w=/^(.*?)\.(\w+)$/.exec(I);if(!w)return;let v=b(w[1]);return v?v+a+w[2]:void 0}}},"create"),U=_e.removePrefix(e,P),L=b(U);return L&&n.strictSlashes!==!0&&(L+=`${c}?`),L};ff.exports=si});var mf=W((Mv,pf)=>{"use strict";var vR=Be("path"),UR=af(),ii=df(),ai=Gn(),DR=Kn(),HR=s(e=>e&&typeof e=="object"&&!Array.isArray(e),"isObject"),se=s((e,t,n=!1)=>{if(Array.isArray(e)){let l=e.map(d=>se(d,t,n));return s(d=>{for(let m of l){let g=m(d);if(g)return g}return!1},"arrayMatcher")}let r=HR(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=t||{},i=ai.isWindows(t),a=r?se.compileRe(e,t):se.makeRe(e,t,!1,!0),c=a.state;delete a.state;let u=s(()=>!1,"isIgnored");if(o.ignore){let l={...t,ignore:null,onMatch:null,onResult:null};u=se(o.ignore,l,n)}let f=s((l,p=!1)=>{let{isMatch:d,match:m,output:g}=se.test(l,a,t,{glob:e,posix:i}),E={glob:e,state:c,regex:a,posix:i,input:l,output:g,match:m,isMatch:d};return typeof o.onResult=="function"&&o.onResult(E),d===!1?(E.isMatch=!1,p?E:!1):u(l)?(typeof o.onIgnore=="function"&&o.onIgnore(E),E.isMatch=!1,p?E:!1):(typeof o.onMatch=="function"&&o.onMatch(E),p?E:!0)},"matcher");return n&&(f.state=c),f},"picomatch");se.test=(e,t,n,{glob:r,posix:o}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let i=n||{},a=i.format||(o?ai.toPosixSlashes:null),c=e===r,u=c&&a?a(e):e;return c===!1&&(u=a?a(e):e,c=u===r),(c===!1||i.capture===!0)&&(i.matchBase===!0||i.basename===!0?c=se.matchBase(e,t,n,o):c=t.exec(u)),{isMatch:!!c,match:c,output:u}};se.matchBase=(e,t,n,r=ai.isWindows(n))=>(t instanceof RegExp?t:se.makeRe(t,n)).test(vR.basename(e));se.isMatch=(e,t,n)=>se(t,n)(e);se.parse=(e,t)=>Array.isArray(e)?e.map(n=>se.parse(n,t)):ii(e,{...t,fastpaths:!1});se.scan=(e,t)=>UR(e,t);se.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let o=t||{},i=o.contains?"":"^",a=o.contains?"":"$",c=`${i}(?:${e.output})${a}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let u=se.toRegex(c,t);return r===!0&&(u.state=e),u};se.makeRe=(e,t={},n=!1,r=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let o={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(o.output=ii.fastpaths(e,t)),o.output||(o=ii(e,t)),se.compileRe(o,t,n,r)};se.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(n){if(t&&t.debug===!0)throw n;return/$^/}};se.constants=DR;pf.exports=se});var _f=W((Uv,gf)=>{"use strict";gf.exports=mf()});var Cf=W((Dv,Rf)=>{"use strict";var Ef=Be("util"),Sf=Wl(),Ve=_f(),ci=Gn(),hf=s(e=>e===""||e==="./","isEmptyString"),yf=s(e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},"hasBraces"),Q=s((e,t,n)=>{t=[].concat(t),e=[].concat(e);let r=new Set,o=new Set,i=new Set,a=0,c=s(l=>{i.add(l.output),n&&n.onResult&&n.onResult(l)},"onResult");for(let l=0;l<t.length;l++){let p=Ve(String(t[l]),{...n,onResult:c},!0),d=p.state.negated||p.state.negatedExtglob;d&&a++;for(let m of e){let g=p(m,!0);(d?!g.isMatch:g.isMatch)&&(d?r.add(g.output):(r.delete(g.output),o.add(g.output)))}}let f=(a===t.length?[...i]:[...o]).filter(l=>!r.has(l));if(n&&f.length===0){if(n.failglob===!0)throw new Error(`No matches found for "${t.join(", ")}"`);if(n.nonull===!0||n.nullglob===!0)return n.unescape?t.map(l=>l.replace(/\\/g,"")):t}return f},"micromatch");Q.match=Q;Q.matcher=(e,t)=>Ve(e,t);Q.isMatch=(e,t,n)=>Ve(t,n)(e);Q.any=Q.isMatch;Q.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],i=s(c=>{n.onResult&&n.onResult(c),o.push(c.output)},"onResult"),a=new Set(Q(e,t,{...n,onResult:i}));for(let c of o)a.has(c)||r.add(c);return[...r]};Q.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Ef.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>Q.contains(e,r,n));if(typeof t=="string"){if(hf(e)||hf(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return Q.isMatch(e,t,{...n,contains:!0})};Q.matchKeys=(e,t,n)=>{if(!ci.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=Q(Object.keys(e),t,n),o={};for(let i of r)o[i]=e[i];return o};Q.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=Ve(String(o),n);if(r.some(a=>i(a)))return!0}return!1};Q.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=Ve(String(o),n);if(!r.every(a=>i(a)))return!1}return!0};Q.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Ef.inspect(e)}"`);return[].concat(t).every(r=>Ve(r,n)(e))};Q.capture=(e,t,n)=>{let r=ci.isWindows(n),i=Ve.makeRe(String(e),{...n,capture:!0}).exec(r?ci.toPosixSlashes(t):t);if(i)return i.slice(1).map(a=>a===void 0?"":a)};Q.makeRe=(...e)=>Ve.makeRe(...e);Q.scan=(...e)=>Ve.scan(...e);Q.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of Sf(String(r),t))n.push(Ve.parse(o,t));return n};Q.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!yf(e)?[e]:Sf(e,t)};Q.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return Q.braces(e,{...t,expand:!0})};Q.hasBraces=yf;Rf.exports=Q});var ro=W(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.MCP_MISSING_LAUNCH_SERIALIZED=ie.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;ie.foldMcpName=Uf;ie.buildMcpFamilyCanonicalKey=cC;ie.launchContainsCredentials=lC;ie.serializeMcpLaunchIdentity=Df;ie.hashMcpLaunchIdentity=Yn;ie.projectMcpMissingLaunchIdentity=pC;ie.projectMcpLaunchIdentity=mC;ie.maskMcpLaunchForDisplay=_C;ie.normalizeMcpToolNames=hC;var aC=Be("node:crypto");ie.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";ie.MCP_MISSING_LAUNCH_SERIALIZED=`${ie.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function rt(e){return e.toLocaleLowerCase("en-US")}s(rt,"foldCase");function Uf(e){return rt(e)}s(Uf,"foldMcpName");function cC(e){return`interface:${Uf(e)}`}s(cC,"buildMcpFamilyCanonicalKey");var vf=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),uC=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function cn(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(cn,"lengthPrefixed");function lC(e){return e.kind==="url"?fC(e.url):e.kind==="command"?e.arguments.some(t=>uC.test(t)):!1}s(lC,"launchContainsCredentials");function fC(e){try{let t=new URL(e);if(t.username.length>0||t.password.length>0)return!0;for(let n of t.searchParams.keys())if(vf.has(rt(n)))return!0;return!1}catch{let t=e.split("://",2),n=t.length===2?t[1]:e,r=n.indexOf("@"),o=n.indexOf("/");if(r>0&&(o===-1||r<o))return!0;let i=e.split("?",2)[1];return i===void 0?!1:i.split("&").some(a=>{let c=rt(a.split("=",1)[0]??"");return vf.has(c)})}}s(fC,"urlContainsCredentials");function Df(e){if(e.kind==="url")return[ie.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",cn(rt(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>rt(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[ie.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",cn(rt(e.command)),String(t.length),...t.map(cn)].join("|")}return[ie.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",cn(e.installationRootExternalKey),cn(e.sourcePath),cn(e.nativeKey)].join("|")}s(Df,"serializeMcpLaunchIdentity");function Yn(e){return(0,aC.createHash)("sha256").update(e).digest("hex")}s(Yn,"hashMcpLaunchIdentity");var dC=Yn(ie.MCP_MISSING_LAUNCH_SERIALIZED);function pC(){return{kind:"unknown",arguments:[],serialized:ie.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:dC}}s(pC,"projectMcpMissingLaunchIdentity");function mC(e){let t=Df(e);return e.kind==="url"?{kind:"url",url:rt(e.url),arguments:[],serialized:t,contentHash:Yn(t)}:e.kind==="command"?{kind:"command",command:rt(e.command),arguments:[...e.arguments].map(n=>rt(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:Yn(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:Yn(t)}}s(mC,"projectMcpLaunchIdentity");var gC=/^(https?:\/\/)([^/?#]*@)/i;function _C(e){return e.replace(gC,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}s(_C,"maskMcpLaunchForDisplay");function hC(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n.sort((r,o)=>r<o?-1:r>o?1:0),n}s(hC,"normalizeMcpToolNames")});var so=W(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.LOCAL_BIN_PACKAGE_VERSION_SOURCE=Se.PACKAGE_FIELD_MAX=void 0;Se.npxExecBin=Hf;Se.isExactNpmVersion=Ff;Se.isNodeModulesBinCommand=TC;Se.packageNameFromSpec=oo;Se.pinnedPackageVersionFromSpec=$f;Se.pinnedPackageVersionFromNpx=kC;Se.npxPackageSpecs=jf;Se.PACKAGE_FIELD_MAX=128;var EC=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,SC=new Set(["-p","--package"]),yC=new Set(["-c","--call"]),RC=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),CC=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),AC=/^--no-/;function OC(e){return CC.has(e)||AC.test(e)}s(OC,"booleanFlag");function Hf(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}s(Hf,"npxExecBin");var bC=/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function Ff(e){return e.length<=Se.PACKAGE_FIELD_MAX&&bC.test(e)}s(Ff,"isExactNpmVersion");Se.LOCAL_BIN_PACKAGE_VERSION_SOURCE="node_modules_local";var IC=/(?:^|\/)node_modules\/\.bin\/[^/]+$/;function TC(e){return IC.test(e.replaceAll("\\","/"))}s(TC,"isNodeModulesBinCommand");function oo(e){if(e.length===0||e.length>Se.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return EC.test(n)?n:null}s(oo,"packageNameFromSpec");function $f(e){let t=oo(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return Ff(n)?n:void 0}s($f,"pinnedPackageVersionFromSpec");function kC(e,t){for(let n of jf(e,t)){let r=$f(n);if(r!==void 0)return r}}s(kC,"pinnedPackageVersionFromNpx");function jf(e,t){let n=Hf(e);if(n===null)return[];let r=[...t];if(n==="npm"){let a=r[0]?.toLowerCase();if(a!=="exec"&&a!=="x")return[];r=r.slice(1)}let o=[],i=null;for(let a=0;a<r.length;a+=1){let c=r[a]??"";if(c==="--"){i=r[a+1]??null;break}if(!c.startsWith("-")){i=c;break}let u=c.indexOf("="),f=u===-1?c:c.slice(0,u);if(yC.has(f))return[];if(SC.has(f)){let l=u===-1?r[a+1]:c.slice(u+1);l!==void 0&&l.length>0&&o.push(l),u===-1&&(a+=1);continue}if(!(u!==-1||OC(f))){if(RC.has(f)){a+=1;continue}return[]}}return o.length>0?o.every(a=>oo(a)!==null)?o:[]:i===null||oo(i)===null?[]:[i]}s(jf,"npxPackageSpecs")});var Kf=W(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.McpPackageEcosystem=void 0;ot.resolveMcpPackageIdentity=FC;ot.resolveLocalBinPackageIdentity=$C;var Bf=ro(),Ot=so();ot.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var xC=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,PC=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function NC(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}s(NC,"pythonRunnerBin");var wC=new Set(["--from","--spec"]),LC=new Set(["--python","-p","--with","--with-editable","--with-requirements","--index","--index-url","--default-index","--extra-index-url","--find-links","-f","--constraint","-c","--override","--refresh-package","--cache-dir","--directory","--project","--config-file","--color","--exclude-newer","--pip-args","--verbose-pip"]),MC=new Set(["-q","--quiet","-v","--verbose","-n","--native-tls","--offline","--isolated","--preview","--refresh","--reinstall","--upgrade","-U","--force","--system","--system-site-packages","--path","--managed-python","--progress"]),vC=/^--no-/;function UC(e,t){let n=NC(e);if(n===null)return null;let r=[...t];if(n==="uv"){if(r[0]?.toLowerCase()!=="tool"||r[1]?.toLowerCase()!=="run")return null;r=r.slice(2)}else if(n==="pipx"){if(r[0]?.toLowerCase()!=="run")return null;r=r.slice(1)}let o=null,i=null;for(let a=0;a<r.length;a+=1){let c=r[a]??"";if(c==="--"){i=r[a+1]??null;break}if(!c.startsWith("-")){i=c;break}let u=c.indexOf("="),f=u===-1?c:c.slice(0,u);if(wC.has(f)){let l=u===-1?r[a+1]:c.slice(u+1);l!==void 0&&l.length>0&&(o=l),u===-1&&(a+=1);continue}if(!(u!==-1||MC.has(f)||vC.test(f))){if(LC.has(f)){a+=1;continue}return null}}return o??i}s(UC,"pythonRunnerSpec");function DC(e){if(e.length===0||e.length>Ot.PACKAGE_FIELD_MAX)return null;let t=e.includes("==")?"==":e.includes("@")?"@":null;if(t===null)return null;let n=e.indexOf(t),r=e.slice(0,n),o=e.slice(n+t.length);return!xC.test(r)||!PC.test(o)?null:{ecosystem:ot.McpPackageEcosystem.PYPI,packageName:r,version:o}}s(DC,"pypiIdentityFromSpec");function HC(e){let t=(0,Ot.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return(0,Ot.isExactNpmVersion)(n)?{ecosystem:ot.McpPackageEcosystem.NPM,packageName:t,version:n}:null}s(HC,"npmIdentityFromSpec");function FC(e){if(e?.kind!=="command"||(0,Bf.launchContainsCredentials)(e))return;for(let n of(0,Ot.npxPackageSpecs)(e.command,e.arguments)){let r=HC(n);if(r!==null)return r}let t=UC(e.command,e.arguments);if(t!==null)return DC(t)??void 0}s(FC,"resolveMcpPackageIdentity");function $C(e,t){if(e?.kind!=="command"||(0,Bf.launchContainsCredentials)(e)||!(0,Ot.isNodeModulesBinCommand)(e.command)||t.packageVersionSource!==Ot.LOCAL_BIN_PACKAGE_VERSION_SOURCE)return;let{packageName:n,packageVersion:r}=t;if(!(n===void 0||r===void 0||(0,Ot.packageNameFromSpec)(n)!==n||!(0,Ot.isExactNpmVersion)(r)))return{ecosystem:ot.McpPackageEcosystem.NPM,packageName:n,version:r}}s($C,"resolveLocalBinPackageIdentity")});var Xf=W(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.EMPTY_NPM_PUBLISHER=void 0;st.isNpmRegistryPublisher=BC;st.displayPublisherName=KC;st.classifyMcpProvenance=qC;var Wf=ro(),Jn=so();st.EMPTY_NPM_PUBLISHER="npm:";var Gf="npm:",jC=/^[A-Za-z0-9._-]+$/;function BC(e){return e.startsWith(Gf)&&e!==st.EMPTY_NPM_PUBLISHER&&jC.test(e.slice(Gf.length))}s(BC,"isNpmRegistryPublisher");function KC(e){if(!(e==null||e===""||e===st.EMPTY_NPM_PUBLISHER))return e}s(KC,"displayPublisherName");function Vf(e){let t=e.split(".").map(Number);return t.length!==4||t.some(n=>!Number.isInteger(n)||n<0||n>255)?!1:t[0]===0||t[0]===10||t[0]===127||t[0]===169&&t[1]===254||t[0]===172&&(t[1]??0)>=16&&(t[1]??0)<=31||t[0]===192&&t[1]===168}s(Vf,"privateIpv4");function GC(e){let t=/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(e);if(t?.[1])return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(e);if(!n)return;let r=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16);return`${r>>8&255}.${r&255}.${o>>8&255}.${o&255}`}s(GC,"ipv4MappedAddress");function mi(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}s(mi,"normalizedHost");function VC(e){let t=mi(e),n=GC(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||Vf(t)||n!==void 0&&Vf(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}s(VC,"privateHostname");function zC(e){let t=mi(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}s(zC,"publisherHost");function WC(e){let t=mi(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}s(WC,"publicOrigin");function Yf(e){let t={kind:"url",url:e};if((0,Wf.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||VC(n.hostname))return{origin:"UNKNOWN"};let r=zC(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:WC(n)}}catch{return{origin:"UNKNOWN"}}}s(Yf,"classifyUrl");var Jf="mcp-remote";function YC(e,t){if(e===Jf)return t.find(n=>/^https?:\/\//i.test(n))}s(YC,"remoteUrlChild");function JC(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}s(JC,"thirdPartyPackage");function zf(e,t,n){let r=YC(e,t);return r!==void 0?Yf(r):e===Jf?{origin:"UNKNOWN"}:JC(e,n)}s(zf,"classifyRegistryPackage");function XC(e){let t=e.replaceAll("\\","/");return t.startsWith("~/")||t.startsWith("/")||/^[A-Za-z]:\//.test(t)?!1:t.startsWith("./")||t.startsWith("../")||t==="scripts"||t.startsWith("scripts/")}s(XC,"isRepoRelativeCommand");function qC(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,Wf.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return Yf(t.url);let r=(0,Jn.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,Jn.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let i=zf(o,t.arguments,e.publisherName),a=typeof e.packageName=="string"?(0,Jn.packageNameFromSpec)(e.packageName):null;return a!==null&&a===o&&i.packageName!==void 0?{...i,packageName:a,packageKey:a}:i}if((0,Jn.isNodeModulesBinCommand)(t.command)){let o=typeof e.packageName=="string"?(0,Jn.packageNameFromSpec)(e.packageName):null;return o===null||o!==e.packageName?{origin:"UNKNOWN"}:zf(o,t.arguments,e.publisherName)}return XC(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}s(qC,"classifyMcpProvenance")});var Zf=W(io=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});io.mcpServerToolSegmentForms=qf;io.mcpServerNameMatchesToolSegment=ZC;function qf(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}s(qf,"mcpServerToolSegmentForms");function ZC(e,t){let n=t.toLowerCase();return qf(e).some(r=>r.toLowerCase()===n)}s(ZC,"mcpServerNameMatchesToolSegment")});var Qf=W(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.parseFrontmatterField=Ue.parseFrontmatterDescription=Ue.usableCatalogText=void 0;var QC=/^(?:>|\|)[-+]?$/,eA=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,tA=s(e=>{let t=e?.trim()??"";if(!(t.length===0||QC.test(t)))return t},"usableCatalogText");Ue.usableCatalogText=tA;var nA=s(e=>(0,Ue.parseFrontmatterField)(e,"description"),"parseFrontmatterDescription");Ue.parseFrontmatterDescription=nA;var rA=s((e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return sA(n[1],t)},"parseFrontmatterField");Ue.parseFrontmatterField=rA;var oA=s(e=>e.replace(/^["']|["']$/g,""),"stripYamlQuotes");function sA(e,t){let n=e.split(`
6
+ `),r=`${t}:`,o=n.findIndex(m=>m===r||m.startsWith(`${r} `)||m.startsWith(`${r} `));if(o<0)return;let i=(n[o]??"").slice(r.length).trim(),a=eA.exec(i);if(!a){let m=oA(i).trim();return(0,Ue.usableCatalogText)(m)}let c=[];for(let m=o+1;m<n.length;m+=1){let g=n[m]??"";if(g.trim()===""){c.push("");continue}if(g.length===g.trimStart().length)break;c.push(g)}let u=c.reduce((m,g)=>g.trim()===""?m:Math.min(m,g.length-g.trimStart().length),Number.POSITIVE_INFINITY),f=[],l=a[1]?.trim();l&&f.push(l);for(let m of c)f.push(m.trim()===""?"":m.slice(u));for(;f.length>0&&f[f.length-1]==="";)f.pop();let d=i.startsWith(">")?f.join(`
7
7
  `).split(/\n{2,}/).map(m=>m.split(`
8
8
  `).map(g=>g.trim()).filter(Boolean).join(" ")).filter(m=>m.length>0).join(`
9
9
 
10
10
  `):f.join(`
11
- `).trimEnd();return(0,Ne.usableCatalogText)(d)}s(lC,"parseYamlFrontmatterScalar")});var Mf=Y(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=ie.COMPONENT_INSPECTION_TEXT_MAX_BYTES=ie.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=void 0;ie.fitSnapshotInspectionTextBudget=fC;ie.capComponentTextBytes=Pf;ie.prepareComponentInspectionText=dC;ie.redactComponentSource=Zs;ie.componentSourceContainsRedactableSecret=EC;ie.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";ie.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;ie.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function fC(e){let t=0;return e.map(n=>{let r=n,o=r.skill?.inspectionText;if(o===void 0)return n;let i=Buffer.byteLength(o,"utf8");return t+i<=ie.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES?(t+=i,n):{...n,skill:{...r.skill,inspectionText:void 0}}})}s(fC,"fitSnapshotInspectionTextBudget");function Pf(e,t){if(e==null||e.length===0)return;let n=Buffer.from(e,"utf8");if(n.byteLength<=t)return e;let r=new TextDecoder("utf-8",{fatal:!0});for(let o=t;o>0;o-=1)try{return r.decode(n.subarray(0,o))}catch{}}s(Pf,"capComponentTextBytes");function dC(e){if(!(e==null||e.length===0))return Pf(Zs(e),ie.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}s(dC,"prepareComponentInspectionText");var pC=[/\bsk-(?:proj-)?[A-Za-z0-9_-]{16,}/g,/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g,/\bgithub_pat_[A-Za-z0-9_]{20,}/g,/\bxox[baprs]-[A-Za-z0-9-]{10,}/g,/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,/\bAIza[0-9A-Za-z_-]{35}\b/g,/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g],mC=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,gC=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,_C=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,hC=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,Nf=/-----END [A-Z0-9 ]*PRIVATE KEY-----/;function SC(e){let t=e.replace(gC,(n,r)=>`${r}${ie.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${ie.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(_C,(n,r)=>`${r}${ie.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(mC,(n,r)=>`${r}${ie.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of pC)t=t.replace(n,ie.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}s(SC,"redactLine");function Zs(e){if(e.length===0)return e;let t=e.split(`
12
- `),n=!1;return t.map(o=>n?Nf.test(o)?(n=!1,o):o.trim().length===0?o:ie.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:hC.test(o)&&!Nf.test(o)?(n=!0,o):SC(o)).join(`
13
- `)}s(Zs,"redactComponentSource");function EC(e){return Zs(e)!==e}s(EC,"componentSourceContainsRedactableSecret")});var je=Y(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.redactComponentSource=R.prepareComponentInspectionText=R.fitSnapshotInspectionTextBudget=R.componentSourceContainsRedactableSecret=R.capComponentTextBytes=R.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=R.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=R.COMPONENT_INSPECTION_TEXT_MAX_BYTES=R.usableCatalogText=R.parseFrontmatterField=R.parseFrontmatterDescription=R.mcpServerToolSegmentForms=R.mcpServerNameMatchesToolSegment=R.isNpmRegistryPublisher=R.EMPTY_NPM_PUBLISHER=R.displayPublisherName=R.classifyMcpProvenance=R.resolveMcpPackageIdentity=R.resolveLocalBinPackageIdentity=R.McpPackageEcosystem=R.pinnedPackageVersionFromSpec=R.pinnedPackageVersionFromNpx=R.packageNameFromSpec=R.npxPackageSpecs=R.npxExecBin=R.isNodeModulesBinCommand=R.isExactNpmVersion=R.LOCAL_BIN_PACKAGE_VERSION_SOURCE=R.PACKAGE_FIELD_MAX=R.serializeMcpLaunchIdentity=R.projectMcpMissingLaunchIdentity=R.projectMcpLaunchIdentity=R.normalizeMcpToolNames=R.MCP_MISSING_LAUNCH_SERIALIZED=R.MCP_LAUNCH_IDENTITY_ALGORITHM=R.maskMcpLaunchForDisplay=R.launchContainsCredentials=R.hashMcpLaunchIdentity=R.foldMcpName=R.buildMcpFamilyCanonicalKey=R.ComponentKind=void 0;R.userConfigRootFromPath=NC;R.installationRootExternalKey=PC;R.normalizeRepositoryRelativePath=Lf;R.nativeKeyForSkillPath=MC;R.nativeKeyForRulePath=LC;R.nativeKeyForCommandPath=vC;R.serializeComponentIdentity=Uf;R.buildComponentReference=HC;R.validateComponentReference=DC;var yC=at("node:crypto"),RC=at("node:path"),CC="cmp1_",AC=/^cmp1_[A-Za-z0-9_-]{43}$/,bC=["/skills/","/skills-cursor/"],OC=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,kC=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,xC=/(?:^|\/)\.(?:github|copilot)\/instructions\/(.+)$/i,IC=/(?:^|\/)\.github\/prompts\/(.+)$/i,TC=[".cursor",".claude",".codex",".copilot"],wC={".claude.json":".claude",".agents":".codex",".github":".copilot",".vscode":".copilot"};R.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function NC(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>TC.includes(o));return n||(t.map(o=>wC[o]).find(o=>o!==void 0)??"unknown")}s(NC,"userConfigRootFromPath");function PC(e,t){return`runtime-install:${e}/${t}`}s(PC,"installationRootExternalKey");function Qr(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}s(Qr,"requireValue");function Lf(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=RC.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return Qr(n,"sourcePath")}s(Lf,"normalizeRepositoryRelativePath");function MC(e){let t=e.replaceAll("\\","/");for(let n of bC){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}s(MC,"nativeKeyForSkillPath");function Qs(e,t,n){let r=e.replaceAll("\\","/"),i=t.exec(r)?.[1];if(!i||i.split("/").includes(".."))return null;let c=i.replace(n,"");return c.length>0?c:null}s(Qs,"nativeKeyUnderLayoutRoot");function LC(e){return Qs(e,OC,/\.(mdc|md|rules)$/i)??vf(e,xC,/\.instructions\.md$/i)}s(LC,"nativeKeyForRulePath");function vC(e){return Qs(e,kC,/\.(md|mdc|toml)$/i)??vf(e,IC,/\.prompt\.md$/i)}s(vC,"nativeKeyForCommandPath");function vf(e,t,n){if(!n.test(e.split("#",1)[0]??""))return null;let r=Qs(e,t,n);return r===null?null:r.split("/").pop()??null}s(vf,"copilotNativeKey");function UC(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(UC,"field");function Uf(e){let t=[Qr(e.installationRootExternalKey,"installationRootExternalKey"),Qr(e.installableKind,"installableKind"),Lf(e.sourcePath),Qr(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(UC).join("|")}`,"utf8")}s(Uf,"serializeComponentIdentity");function HC(e){let t=(0,yC.createHash)("sha256").update(Uf(e)).digest("base64url");return`${CC}${t}`}s(HC,"buildComponentReference");function DC(e){return AC.test(e)}s(DC,"validateComponentReference");var Pe=Yr();Object.defineProperty(R,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:s(function(){return Pe.buildMcpFamilyCanonicalKey},"get")});Object.defineProperty(R,"foldMcpName",{enumerable:!0,get:s(function(){return Pe.foldMcpName},"get")});Object.defineProperty(R,"hashMcpLaunchIdentity",{enumerable:!0,get:s(function(){return Pe.hashMcpLaunchIdentity},"get")});Object.defineProperty(R,"launchContainsCredentials",{enumerable:!0,get:s(function(){return Pe.launchContainsCredentials},"get")});Object.defineProperty(R,"maskMcpLaunchForDisplay",{enumerable:!0,get:s(function(){return Pe.maskMcpLaunchForDisplay},"get")});Object.defineProperty(R,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:s(function(){return Pe.MCP_LAUNCH_IDENTITY_ALGORITHM},"get")});Object.defineProperty(R,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:s(function(){return Pe.MCP_MISSING_LAUNCH_SERIALIZED},"get")});Object.defineProperty(R,"normalizeMcpToolNames",{enumerable:!0,get:s(function(){return Pe.normalizeMcpToolNames},"get")});Object.defineProperty(R,"projectMcpLaunchIdentity",{enumerable:!0,get:s(function(){return Pe.projectMcpLaunchIdentity},"get")});Object.defineProperty(R,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:s(function(){return Pe.projectMcpMissingLaunchIdentity},"get")});Object.defineProperty(R,"serializeMcpLaunchIdentity",{enumerable:!0,get:s(function(){return Pe.serializeMcpLaunchIdentity},"get")});var tt=qr();Object.defineProperty(R,"PACKAGE_FIELD_MAX",{enumerable:!0,get:s(function(){return tt.PACKAGE_FIELD_MAX},"get")});Object.defineProperty(R,"LOCAL_BIN_PACKAGE_VERSION_SOURCE",{enumerable:!0,get:s(function(){return tt.LOCAL_BIN_PACKAGE_VERSION_SOURCE},"get")});Object.defineProperty(R,"isExactNpmVersion",{enumerable:!0,get:s(function(){return tt.isExactNpmVersion},"get")});Object.defineProperty(R,"isNodeModulesBinCommand",{enumerable:!0,get:s(function(){return tt.isNodeModulesBinCommand},"get")});Object.defineProperty(R,"npxExecBin",{enumerable:!0,get:s(function(){return tt.npxExecBin},"get")});Object.defineProperty(R,"npxPackageSpecs",{enumerable:!0,get:s(function(){return tt.npxPackageSpecs},"get")});Object.defineProperty(R,"packageNameFromSpec",{enumerable:!0,get:s(function(){return tt.packageNameFromSpec},"get")});Object.defineProperty(R,"pinnedPackageVersionFromNpx",{enumerable:!0,get:s(function(){return tt.pinnedPackageVersionFromNpx},"get")});Object.defineProperty(R,"pinnedPackageVersionFromSpec",{enumerable:!0,get:s(function(){return tt.pinnedPackageVersionFromSpec},"get")});var ei=yf();Object.defineProperty(R,"McpPackageEcosystem",{enumerable:!0,get:s(function(){return ei.McpPackageEcosystem},"get")});Object.defineProperty(R,"resolveLocalBinPackageIdentity",{enumerable:!0,get:s(function(){return ei.resolveLocalBinPackageIdentity},"get")});Object.defineProperty(R,"resolveMcpPackageIdentity",{enumerable:!0,get:s(function(){return ei.resolveMcpPackageIdentity},"get")});var eo=xf();Object.defineProperty(R,"classifyMcpProvenance",{enumerable:!0,get:s(function(){return eo.classifyMcpProvenance},"get")});Object.defineProperty(R,"displayPublisherName",{enumerable:!0,get:s(function(){return eo.displayPublisherName},"get")});Object.defineProperty(R,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:s(function(){return eo.EMPTY_NPM_PUBLISHER},"get")});Object.defineProperty(R,"isNpmRegistryPublisher",{enumerable:!0,get:s(function(){return eo.isNpmRegistryPublisher},"get")});var Hf=Tf();Object.defineProperty(R,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:s(function(){return Hf.mcpServerNameMatchesToolSegment},"get")});Object.defineProperty(R,"mcpServerToolSegmentForms",{enumerable:!0,get:s(function(){return Hf.mcpServerToolSegmentForms},"get")});var ti=wf();Object.defineProperty(R,"parseFrontmatterDescription",{enumerable:!0,get:s(function(){return ti.parseFrontmatterDescription},"get")});Object.defineProperty(R,"parseFrontmatterField",{enumerable:!0,get:s(function(){return ti.parseFrontmatterField},"get")});Object.defineProperty(R,"usableCatalogText",{enumerable:!0,get:s(function(){return ti.usableCatalogText},"get")});var Et=Mf();Object.defineProperty(R,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return Et.COMPONENT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(R,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:s(function(){return Et.COMPONENT_SOURCE_REDACTION_PLACEHOLDER},"get")});Object.defineProperty(R,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return Et.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(R,"capComponentTextBytes",{enumerable:!0,get:s(function(){return Et.capComponentTextBytes},"get")});Object.defineProperty(R,"componentSourceContainsRedactableSecret",{enumerable:!0,get:s(function(){return Et.componentSourceContainsRedactableSecret},"get")});Object.defineProperty(R,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:s(function(){return Et.fitSnapshotInspectionTextBudget},"get")});Object.defineProperty(R,"prepareComponentInspectionText",{enumerable:!0,get:s(function(){return Et.prepareComponentInspectionText},"get")});Object.defineProperty(R,"redactComponentSource",{enumerable:!0,get:s(function(){return Et.redactComponentSource},"get")})});import{existsSync as B_,readFileSync as K_}from"node:fs";import{hostname as oa,release as G_,userInfo as V_,version as z_}from"node:os";import*as _e from"node:os";import{performance as Ko}from"node:perf_hooks";var I_=1024*1024,T_=128;function lr(e){return Math.round(e/I_)}s(lr,"mb");function Rn(e,t){let n=10**t;return Math.round(e*n)/n}s(Rn,"round");function Bc(e=process.platform){try{let t=Ko.now(),n={},r=0,o=0,i=e!=="win32";for(let{times:u}of _e.cpus())r+=u.user+u.nice+u.sys+(i?u.irq:0),o+=u.idle;if(r+o>0&&(n.cpu_busy_ms=Math.round(r),n.cpu_idle_ms=Math.round(o)),n.uptime_s=Math.round(_e.uptime()),n.mem_free_mb=lr(_e.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=lr(process.availableMemory())),e!=="win32"){let[u,f,l]=_e.loadavg();n.load_1m=Rn(u??0,2),n.load_5m=Rn(f??0,2),n.load_15m=Rn(l??0,2)}let c=process.resourceUsage();n.proc_cpu_user_ms=Math.round(c.userCPUTime/1e3),n.proc_cpu_sys_ms=Math.round(c.systemCPUTime/1e3),n.proc_max_rss_mb=Math.round(c.maxRSS/1024),n.proc_page_faults=c.majorPageFault,e!=="win32"&&(n.proc_invol_ctx=c.involuntaryContextSwitches);let a=Ko.nodeTiming?.bootstrapComplete;return typeof a=="number"&&a>0&&(n.node_boot_ms=Rn(a,1)),n.sample_us=Math.round((Ko.now()-t)*1e3),n}catch{return}}s(Bc,"sampleSys");function Kc(){try{let e=_e.cpus(),t={},n=typeof _e.availableParallelism=="function"?_e.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,T_);r&&(t.cpu_model=r);let o=_e.totalmem();t.mem_total_mb=lr(o);let i=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof i=="number"&&i>0&&i<o&&(t.mem_limit_mb=lr(i)),t.uptime_h=Rn(_e.uptime()/3600,1),t}catch{return{}}}s(Kc,"hostSpecs");import{createHash as w_,randomBytes as N_}from"node:crypto";import{existsSync as fr,mkdirSync as P_,readdirSync as M_,readFileSync as L_,renameSync as zc,statSync as Wc,unlinkSync as Jc,writeFileSync as v_}from"node:fs";import{homedir as Yc}from"node:os";import{basename as U_,dirname as Gc,isAbsolute as H_,join as Xc,relative as qc,resolve as We,sep as D_}from"node:path";function T(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
14
- `)}s(T,"logStderr");function Cn(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}s(Cn,"stripRemoteCredentials");function An(e){return w_("sha256").update(e).digest("hex").slice(0,32)}s(An,"sha32");var F_=3;function Zc(e){return e instanceof Error&&"code"in e?e.code:void 0}s(Zc,"errnoCode");function Qc(e){let t=Zc(e);return t==="EEXIST"||t==="EPERM"||t==="EACCES"}s(Qc,"isRenameReplaceBlocked");function $_(e,t,n){let r=n;for(let o=0;o<F_;o+=1){try{Jc(t)}catch(i){if(Zc(i)!=="ENOENT")throw i}try{zc(e,t);return}catch(i){if(!Qc(i))throw i;r=i}}throw r}s($_,"replaceByUnlinkThenRename");function ae(e,t){P_(Gc(e),{recursive:!0});let n=Xc(Gc(e),`.${U_(e)}.${process.pid}.${N_(4).toString("hex")}.tmp`);try{v_(n,t,"utf8");try{zc(n,e)}catch(r){if(!Qc(r))throw r;$_(n,e,r)}}catch(r){try{Jc(n)}catch{}throw r}}s(ae,"writeFileAtomic");function dr(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}s(dr,"timestampUtc");var Vo;function zo(e){Vo=e}s(zo,"setHookStdio");function Wo(){(Vo?.stdout??process.stdout).write('{"continue":true}')}s(Wo,"emitStdoutOk");var Ct=new Set(["on","1","true"]),pr=new Set(["off","0","false"]);function F(e){let t=process.env[e];return t===void 0||t===""?void 0:t}s(F,"readEnv");async function Jo(){return new Promise(e=>{let t="";if(process.stdin.isTTY){e("");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",n=>{t+=n}),process.stdin.on("end",()=>{e(t)}),process.stdin.on("error",()=>{e(t)}),process.stdin.resume()})}s(Jo,"readStdinUntilEnd");async function mr(e){let t=Vo?.stdin??process.stdin;return new Promise(n=>{let r="",o=!1,i=s(a=>{o||(o=!0,clearTimeout(c),n(a||"{}"))},"finish"),c=setTimeout(()=>{i(r)},e);if(t.isTTY){i("{}");return}t.setEncoding("utf8"),t.on("data",a=>{r+=a}),t.on("end",()=>{i(r)}),t.on("error",()=>{i(r)}),t.resume()})}s(mr,"readStdinWithTimeout");async function we(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:i}=await import("node:util"),c=i(o);try{let{stdout:a}=await c(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:a.trim()}}catch(a){let u=a,f=typeof u.code=="number"?u.code:typeof u.status=="number"?u.status:void 0;return{ok:!1,code:f,spawnFailed:f===void 0}}}s(we,"execFileResult");async function ne(e,t,n=3e3,r={}){let o=await we(e,t,n,r);return o.ok?o.stdout:""}s(ne,"execFileText");function Go(e,t){let n=We(e),r=We(t),o=qc(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${D_}`)||H_(o)?!1:We(r,o)===n}s(Go,"isPathInside");function ea(e,t,n=Yc()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return We(e);let o=We(r),i=We(e);if(Go(i,o))return i;let c=t.CURSOR_PLUGIN_ROOT?.trim();return Go(i,We(n,".cursor"))||c!==void 0&&c.length>0&&Go(i,We(c))?o:i}s(ea,"cursorHookLaunchCwd");async function Yo(e=process.cwd(),t=process.env,n=Yc()){let r=ea(e,t,n),o=r!==We(e)&&fr(r)?r:e,i=await we("git",["rev-parse","--show-toplevel"],2e3,{cwd:o});if(i.ok&&i.stdout)return{root:i.stdout,inGitRepo:!0};if(F("EV_AI_HOOK_DEBUG")){let a=i.ok?"empty stdout":i.spawnFailed?"spawn failed":`exit ${String(i.code??"unknown")}`;T(`DEBUG: git rev-parse --show-toplevel failed (${a}) cwd=${e}`)}let c=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||F("CURSOR_PROJECT_DIR")||F("CLAUDE_PROJECT_DIR");if(c&&fr(c)){let a=await we("git",["rev-parse","--show-toplevel"],2e3,{cwd:c});return a.ok&&a.stdout?{root:a.stdout,inGitRepo:!0}:{root:c,inGitRepo:!1}}return{root:e,inGitRepo:!1}}s(Yo,"resolveGitWorkspace");async function Xo(e=process.cwd()){return(await Yo(e)).root}s(Xo,"findGitRoot");function Oe(e,t){try{return JSON.parse(e)}catch{return t}}s(Oe,"parseJsonSafe");var Vc=new Map;function Bt(e){return e.charCodeAt(0)===65279?e.slice(1):e}s(Bt,"stripUtf8Bom");function j_(e){let t;try{t=L_(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(Bt(t))}}catch{return{ok:!1,reason:"parse"}}}s(j_,"parseJsonFile");function ta(e){let t=Vc.get(e);if(t!==void 0)return t;let n=j_(e);return Vc.set(e,n),n}s(ta,"loadJsonFileStatus");function na(e){return ta(e)}s(na,"readJsonFileStatus");function Q(e,t){let n=ta(e);return n.ok?n.value:t}s(Q,"readJsonFileMemoized");function At(e){return typeof e=="string"?e:""}s(At,"pickString");function Je(e,t){let n=e[t];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(!t.includes("."))return;let r=t.split("."),o=e;for(let i of r){if(o===null||typeof o!="object"||Array.isArray(o))return;o=o[i]}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o}s(Je,"pickNestedScalar");function $(e,t){let n=Je(e,t);return typeof n=="string"?n:""}s($,"pickNestedString");var ut=500;function ra(e,t=2){if(!fr(e))return{entries:[],truncated:!1};let n=[],r=!1,o=s((i,c)=>{if(c>t||r)return;let a;try{a=M_(i,{withFileTypes:!0})}catch{return}for(let u of a){if(r)return;let f=Xc(i,u.name);if(u.isDirectory()){o(f,c+1);continue}if(u.isFile()){try{n.push({name:qc(e,f),size:Wc(f).size})}catch{continue}if(n.length>=ut){r=!0;return}}}},"walk");return o(e,1),{entries:n,truncated:r}}s(ra,"listDirFiles");function qo(e){return fr(e)?{present:!0,size:Wc(e).size}:{present:!1,size:0}}s(qo,"fileSizeOrAbsent");function Kt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(Kt,"isTruthyFlag");function sa(e=process.env){return Kt(ee("CURSOR_SANDBOX",e))}s(sa,"isCursorSandboxProcess");var W_=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function J_(e){return W_.some(t=>!!ee(t,e))}s(J_,"hasManagedCiMarker");function Y_(e){if(ee("KUBERNETES_SERVICE_HOST",e)||Kt(ee("REMOTE_CONTAINERS",e))||Kt(ee("DEVCONTAINER",e)))return!0;try{if(B_("/.dockerenv")||K_("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}s(Y_,"hasContainerMarker");function ia(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!ee(t,e))}s(ia,"hasIdeExtensionHostMarker");function X_(e,t=process.platform){return ia(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!ee(n,e)):!1}s(X_,"hasLocalIdeHostMarker");function q_(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}s(q_,"isBackgroundComposerSessionId");function Z_(e){return e==="linux"}s(Z_,"isLinuxPlatform");function ee(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return F(e)}s(ee,"readContextEnv");function Q_(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!eh(ee("CURSOR_VERSION",n))}s(Q_,"isCursorCloudHostFingerprint");function eh(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(eh,"trimEnvLocal");function Zo(e){if(q_(e.sessionId))return!0;let t=e.hostname??oa(),n=e.osUser??aa(e.env);return Q_(t,n,e.env)}s(Zo,"hasCursorCloudExclusiveEvidence");function th(e){return Kt(ee("CURSOR_AGENT",e.env))?!0:Zo(e)}s(th,"hasCursorCloudEvidence");function nh(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(ee("TERM",e)??ee("TERM_PROGRAM",e))||(ee("SSH_TTY",e)??ee("SSH_CONNECTION",e))||(ee("__CFBundleIdentifier",e)??ee("XPC_SERVICE_NAME",e))||ia(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!ee(t,e))||ee("SESSIONNAME",e))}s(nh,"hasLocalSessionMarker");function gr(e={}){let t=e.env;if(ee("GITHUB_ACTIONS",t))return"github_actions";if(Kt(ee("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!X_(t,n)&&th(e)&&(Kt(ee("CURSOR_AGENT",t))||Z_(n)))return"cursor_cloud";if(ee("CODESPACES",t)||ee("CODESPACE_NAME",t))return"codespaces";if(ee("GITLAB_CI",t))return"gitlab_ci";if(J_(t))return"managed";let r=ee("CI",t);return r&&r!=="false"&&r!=="0"?"managed":Y_(t)?"container":nh(t)?"interactive":"unknown"}s(gr,"detectContext");async function ca(){return await ne("systemd-detect-virt",[],1e3)}s(ca,"detectVirt");function aa(e=process.env,t=V_){for(let n of["USER","LOGNAME","USERNAME"]){let r=e[n];if(typeof r=="string"){let o=r.trim();if(o.length>0)return o}}try{return t().username??""}catch{return""}}s(aa,"resolveHostUsername");var rh=32;function oh(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,rh);return t.length>0?t:null}s(oh,"sanitizeOsPlatform");function sh(){try{return[z_(),G_()].filter(Boolean).join(" ").trim()}catch{return""}}s(sh,"windowsVersion");async function ua(e=!1){let t=oh(process.platform),n="";if(process.platform==="darwin")n=await ne("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:c}=await import("node:fs"),a=c("/etc/os-release","utf8"),u=a.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],f=a.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];n=u??f??""}catch{n=await ne("lsb_release",["-sd"],1e3).then(c=>c.replace(/^"|"$/g,""))}n||(n=await ne("uname",["-r"],1e3))}else process.platform==="win32"?n=sh():n=await ne("ver",[],1e3);let r=aa(),o=(process.env.SHELL??"").split(/[/\\]/).pop()??"",i="";try{i=await ne("tty",[],500),i.includes("not a tty")&&(i="")}catch{i=""}return{os:t,os_version:n||null,user:r||null,shell:o||null,tty:i||null,...e?Kc():{}}}s(ua,"hostEnv");function Qo(){return oa()}s(Qo,"hostName");import{createHash as _h}from"node:crypto";import{homedir as hh}from"node:os";import{dirname as cP,join as Sh,parse as aP,resolve as uP}from"node:path";var la="EV_AI_LAUNCHER_VERSION";var fa="EV_AI_HOOK_SOURCE",da="EV_AI_HOOK_FALLBACK_REASON",pa="EV_AI_LAUNCHER_SCOPE",es="EV_AI_LAUNCHER_READY_FD";var ma="--defer-user-spec",_r="--cap",bn="--slot";var ga=Buffer.from([1]);var $N=1024*1024,jN=4*1024*1024,BN=64*1024,KN=64*1024,GN=64*1024;var ts=4096,VN=4*1024*1024;var _a="ev-ai.agent-hook.in-process.v1";import{join as Ca}from"node:path";import{open as ha,mkdir as ih,readFile as ch,readdir as ah,rename as uh,stat as lh,rmdir as fh,unlink as dh,utimes as ph}from"node:fs/promises";var hr=new WeakMap;function Ea(e){if(e&&typeof e=="object"&&"code"in e)return e}s(Ea,"asNodeError");function Gt(e){return Ea(e)?.code==="ENOENT"}s(Gt,"isNotFound");function On(e){return Ea(e)?.code==="EEXIST"}s(On,"isAlreadyExists");async function ya(e,t){try{return await e.readdir(t)}catch(n){if(Gt(n))return[];throw n}}s(ya,"readdirOrEmpty");function Ra(){return{async open(e,t){let n=await ha(e,t),r={path:e};return hr.set(r,n),r},async write(e,t){let n=Sa(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await Sa(e).sync()},async close(e){let t=hr.get(e);hr.delete(e),t&&await t.close()},rename:uh,async readdir(e){return ah(e)},readFile:ch,async stat(e){let t=await lh(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:s(()=>t.isDirectory(),"isDirectory")}},async mkdir(e,t){await ih(e,t)},unlink:dh,rmdir:fh,utimes:ph,async fsyncDir(e){if(process.platform==="win32")return;let t=await ha(e,"r");try{await t.sync()}finally{await t.close()}}}}s(Ra,"productionFs");function Sa(e){let t=hr.get(e);if(!t)throw new Error("closed");return t}s(Sa,"requireHandle");var Aa=4,ba=10;function Sr(e=process.platform){return e==="win32"?Aa:ba}s(Sr,"defaultMaxConcurrentHooks");var Er=6e4,kn=2e3,Oa="slots",ns=64;function ka(e){return Ca(e,".ev-ai","agent-hook",Oa)}s(ka,"slotDirUnder");function yr(e,t){return Ca(e,`slot-${t}`)}s(yr,"slotPath");function Rr(e,t){return`${e}
11
+ `).trimEnd();return(0,Ue.usableCatalogText)(d)}s(sA,"parseYamlFrontmatterScalar")});var nd=W(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=ae.COMPONENT_INSPECTION_TEXT_MAX_BYTES=ae.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=void 0;ae.fitSnapshotInspectionTextBudget=iA;ae.capComponentTextBytes=td;ae.prepareComponentInspectionText=aA;ae.redactComponentSource=_i;ae.componentSourceContainsRedactableSecret=_A;ae.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";ae.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;ae.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function iA(e){let t=0;return e.map(n=>{let r=n,o=r.skill?.inspectionText;if(o===void 0)return n;let i=Buffer.byteLength(o,"utf8");return t+i<=ae.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES?(t+=i,n):{...n,skill:{...r.skill,inspectionText:void 0}}})}s(iA,"fitSnapshotInspectionTextBudget");function td(e,t){if(e==null||e.length===0)return;let n=Buffer.from(e,"utf8");if(n.byteLength<=t)return e;let r=new TextDecoder("utf-8",{fatal:!0});for(let o=t;o>0;o-=1)try{return r.decode(n.subarray(0,o))}catch{}}s(td,"capComponentTextBytes");function aA(e){if(!(e==null||e.length===0))return td(_i(e),ae.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}s(aA,"prepareComponentInspectionText");var cA=[/\bsk-(?:proj-)?[A-Za-z0-9_-]{16,}/g,/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g,/\bgithub_pat_[A-Za-z0-9_]{20,}/g,/\bxox[baprs]-[A-Za-z0-9-]{10,}/g,/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,/\bAIza[0-9A-Za-z_-]{35}\b/g,/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g],uA=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,lA=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,fA=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,dA=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,ed=/-----END [A-Z0-9 ]*PRIVATE KEY-----/,pA=new RegExp(`^(?:${["",String.raw`\$\{[A-Za-z_][A-Za-z0-9_]*\}`,String.raw`\$env:[A-Za-z_][A-Za-z0-9_]*`,String.raw`\{\{\s*[\w.-]+\s*\}\}`,String.raw`\{[A-Za-z_][^{}\s]*\}`,String.raw`<[A-Za-z][A-Za-z_-]*>`,String.raw`\[[A-Za-z][A-Za-z_-]*\]`,String.raw`(?:pass(?:word|wd)?|pwd|secret|token|x+|\*+)`].join("|")})$`,"i"),mA=new RegExp(`^(?:${[String.raw`\$[A-Z_][A-Z0-9_]*`,String.raw`%[A-Z_][A-Z0-9_]*%`,String.raw`(?=[A-Z_]*(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|PASS|PWD|CREDENTIALS?|YOUR))[A-Z]+(?:_[A-Z]+)+`].join("|")})$`);function gi(e){return pA.test(e)||mA.test(e)}s(gi,"isReferenceOrPlaceholder");function gA(e){let t=e.replace(lA,(n,r,o,i)=>gi(i)?n:`${r}${ae.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${ae.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(fA,(n,r)=>gi(n.slice(r.length))?n:`${r}${ae.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(uA,(n,r)=>gi(n.slice(r.length))?n:`${r}${ae.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of cA)t=t.replace(n,ae.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}s(gA,"redactLine");function _i(e){if(e.length===0)return e;let t=e.split(`
12
+ `),n=!1;return t.map(o=>n?ed.test(o)?(n=!1,o):o.trim().length===0?o:ae.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:dA.test(o)&&!ed.test(o)?(n=!0,o):gA(o)).join(`
13
+ `)}s(_i,"redactComponentSource");function _A(e){return _i(e)!==e}s(_A,"componentSourceContainsRedactableSecret")});var Xn=W(hi=>{"use strict";Object.defineProperty(hi,"__esModule",{value:!0});hi.isRecord=hA;function hA(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(hA,"isRecord")});var Si=W(Ei=>{"use strict";Object.defineProperty(Ei,"__esModule",{value:!0});Ei.tokenizeCommand=EA;function EA(e){let t=[],n="",r=null;for(let o of e){if(r){o===r?r=null:n+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(/\s/.test(o)){n.length>0&&(t.push(n),n="");continue}n+=o}return n.length>0&&t.push(n),t}s(EA,"tokenizeCommand")});var yi=W(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.tildePath=SA;ao.tildeHomeInText=RA;function od(e){return e.replace(/\\/g,"/")}s(od,"posixPath");function sd(e){let t=od(e).replace(/\/+$/,"");return t.length<=1?"":t}s(sd,"homePosix");function id(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}s(id,"isWindowsHome");function SA(e,t){let n=od(e);if(n==="~"||n.startsWith("~/"))return n;let r=sd(t);if(!r)return n;let o=n.slice(0,r.length);if(!(id(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let a=n.slice(r.length);return a===""?"~":a.startsWith("/")?`~${a}`:n}s(SA,"tildePath");var rd=new Map;function yA(e){let t=rd.get(e);if(t!==void 0)return t;let n=sd(e),r=null;if(n){let o=n.split("/").map(i=>i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,id(e)?"gi":"g")}return rd.set(e,r),r}s(yA,"homeTextPattern");function RA(e,t){let n=yA(t);return n?e.replace(n,"~"):e}s(RA,"tildeHomeInText")});var co=W(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.ENABLED_RAW_KEYS=Ce.TOOL_LIST_RAW_KEYS=Ce.OMITTED_VALUE=void 0;Ce.isSecretShapedValue=Ri;Ce.isAuthHeaderName=ud;Ce.redactCommandOrUrl=Ci;Ce.isAuthKeyName=fd;Ce.redactArgs=NA;Ce.mcpServerEnabledFromJson=wA;var CA=Xn();Ce.OMITTED_VALUE="<omitted>";Ce.TOOL_LIST_RAW_KEYS=[{raw:"tools",attr:"tools"},{raw:"autoApprove",attr:"auto_approve"},{raw:"auto_approve",attr:"auto_approve"},{raw:"alwaysAllow",attr:"always_allow"},{raw:"always_allow",attr:"always_allow"},{raw:"enabledTools",attr:"enabled_tools"},{raw:"enabled_tools",attr:"enabled_tools"},{raw:"disabledTools",attr:"disabled_tools"},{raw:"disabled_tools",attr:"disabled_tools"}];Ce.ENABLED_RAW_KEYS=["enabled","disabled"];var AA=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,OA=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,bA=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,IA=/^bearer(?:\s+|$)/i;function Ri(e){return bA.test(e)||IA.test(e)}s(Ri,"isSecretShapedValue");var ad=/^(?:--headers?|-H)$/,cd=/^\s*([A-Za-z0-9-]+)\s*:([\s\S]*)$/,TA=/auth|cookie|token|secret|key|passw|credential|session|signature/i,kA=/^(?:(?:bearer|basic|token)\s+)?\$(?:\{\w+\}|\w+)$/i;function ud(e){return TA.test(e)}s(ud,"isAuthHeaderName");function Ci(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}s(Ci,"redactCommandOrUrl");function xA(e){return Ri(e)?"<redacted>":e.includes("://")?Ci(e):e}s(xA,"redactSecretShapedValue");function ld(e){let t=cd.exec(e);if(!t)return Ai(e);let n=t[1]??"",r=(t[2]??"").trim();return kA.test(r)?e:ud(n)||Ri(r)?`${n}: <redacted>`:e}s(ld,"redactHeaderArg");function Ai(e){if(/^https?:\/\//i.test(e))return Ci(e);let t=e.indexOf("=");if(t>0){let n=e.slice(0,t),r=e.slice(t+1);return`${n}=${ad.test(n)?ld(r):Ai(r)}`}return xA(e)}s(Ai,"redactArg");function fd(e){return AA.test(e)||OA.test(e)}s(fd,"isAuthKeyName");function PA(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return fd(t)}s(PA,"authArgKey");function NA(e){let t=[],n=!1,r=!1;for(let o of e){if(n){t.push("<redacted>"),n=!1;continue}if(r&&(r=!1,cd.test(o))){t.push(ld(o));continue}if(ad.test(o)){t.push(o),r=!0;continue}if(PA(o)){t.push("<redacted>"),n=!o.includes("=");continue}t.push(Ai(o))}return t}s(NA,"redactArgs");function wA(e){return(0,CA.isRecord)(e)?e.enabled===!1?!1:e.disabled!==!0:!0}s(wA,"mcpServerEnabledFromJson")});var ki=W(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.MCP_CONFIG_SERVER_KEY_TREATMENT=H.MCP_CONFIG_VSCODE_INPUT_TABLE=H.MCP_CONFIG_SANDBOX_TABLE=H.MCP_CONFIG_TRANSPORT_TYPES=H.REDACTED_VALUE=void 0;H.sanitizeVariableReference=bt;H.mcpConfigFormatOf=uO;H.mcpConfigServersKey=Od;H.sanitizeMcpConfigFile=lO;var LA=Be("node:path"),_d=Si(),hd=yi(),jt=Xn(),F=co();H.REDACTED_VALUE="<redacted>";H.MCP_CONFIG_TRANSPORT_TYPES=new Set(["stdio","http","sse","ws","sdk","streamable-http","streamableHttp","local","remote"]);var MA={CLIENT_ID:"keep",CLIENT_SECRET:"secret",scopes:"string_list",redirectPort:"keep"},vA={clientId:"keep",client_id:"keep",clientSecret:"secret",client_secret:"secret",callbackPort:"keep",callback_port:"keep",callback_url:"url",redirectUri:"url",redirect_uri:"url",authServerMetadataUrl:"url",auth_server_metadata_url:"url",authorizationUrl:"url",tokenUrl:"url",issuer:"url",registrationUrl:"url",clientMetadataUrl:"url",scopes:{by:{string:"keep",array:"string_list"}},scope:"keep",oauthScopes:"string_list",audiences:"string_list",enabled:"keep",allowPrivateNetwork:"keep",authorizationResponseIssParameterSupported:"keep",tokenParamName:"keep"};H.MCP_CONFIG_SANDBOX_TABLE={filesystem:{object:{allowWrite:"path",denyRead:"path",denyWrite:"path"}},network:{object:{allowedDomains:"string_list",deniedDomains:"string_list"}}};var UA={watch:"path",debug:{object:{type:"keep",debugpyPath:"path"}}},DA={headers:"secret_map",proxy:"url",caBundlePath:"path",timeout:"keep",verifySsl:"keep",noProxy:"string_list",extraBodyProperties:"omit",clientCertificate:{object:{cert:"omit",key:"omit",passphrase:"secret"}}},HA={startup:"keep",catalog:"keep",execution:"keep"},FA={approval_mode:"keep",output_token_limit:"keep"};H.MCP_CONFIG_VSCODE_INPUT_TABLE={id:"keep",type:"keep",password:"keep",command:"keep",serverName:"keep",description:"omit",options:"omit",args:"omit",default:"secret"};var $A={type:"transport_type",command:"command",args:"args",cwd:"path",env:"secret_map",url:"url",headers:"secret_map"},jA=Object.fromEntries(F.TOOL_LIST_RAW_KEYS.map(({raw:e})=>[e,"tool_list"]));H.MCP_CONFIG_SERVER_KEY_TREATMENT={...jA,type:"transport_type",transportType:"keep",transport:{by:{string:"keep",object:{object:$A}}},disabled:"keep",enabled:"keep",required:"keep",remote:"keep",remoteConfigured:"keep",source:"keep",version:"keep",gallery:{by:{boolean:"keep",string:"url"}},description:"omit",name:"keep",serverName:"keep",faviconUrl:"url",sourceFile:"path",sourceSlug:"keep",environment_id:"keep",protocol:"keep",pool:"keep",codemode:"keep",trust:"keep",alwaysLoad:"keep",deferTools:"keep",supports_parallel_tool_calls:"keep",tool_input_schema_max_bytes:"keep",startup_readiness:"keep",extension:"omit",metadata:"omit",settings:"omit",command:{by:{string:"command",array:"args",object:{object:{path:"command",args:"args",env:"secret_map"}}}},args:"args",env:"secret_map",environment:"secret_map",env_vars:{list:{by:{string:"env_name",object:{object:{name:"env_name",source:"keep"}}}}},envVars:"secret_map",envFile:"path",cwd:"path",watchPaths:"path",dev:{object:UA},sandboxEnabled:"keep",sandbox:{object:H.MCP_CONFIG_SANDBOX_TABLE},url:"url",serverUrl:"url",httpUrl:"url",eager:"keep",timeoutSeconds:"keep",tcp:"url",headers:"secret_map",http_headers:"secret_map",env_http_headers:"env_name_map",bearer_token_env_var:"env_name",headersHelper:"helper_command",http_headers_helper:"helper_command",apiKey:"secret",requestOptions:{object:DA},auth:{by:{string:"mode",object:{object:MA}}},oauth:{by:{boolean:"keep",object:{object:vA}}},oauthClientId:"keep",oauthClientSecret:"secret",oauthResource:"url",oauth_resource:"url",oauthScopes:"string_list",scopes:{by:{string:"keep",array:"string_list"}},oauthPublicClient:"keep",oauthGrantType:"keep",authProviderType:"keep",targetAudience:"keep",targetServiceAccount:"keep",tools:{by:{array:"tool_list",boolean:"tool_list",string:"tool_list",object:{map:{object:FA}}}},includeTools:"tool_list",excludeTools:"tool_list",omit_tools_from:"tool_list",default_tools_approval_mode:"keep",defaultToolsApprovalMode:"keep",timeout:{by:{number:"keep",object:{object:HA}}},startup_timeout_sec:"keep",startup_timeout_ms:"keep",tool_timeout_sec:"keep",connectionTimeout:"keep"};function BA(e){if(e===null)return"null";if(Array.isArray(e))return"array";switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":return"object";default:return}}s(BA,"shapeOf");var KA=/^[A-Za-z_][A-Za-z0-9_]*$/,GA=[/\$\{(?:env|input|command):[A-Za-z0-9_.-]+\}/y,/\$\{file:[^}\s]+\}/y,/\$\{\{\s*secrets\.[A-Za-z0-9_]+\s*\}\}/y,/\$\{\/\}/y,/\$\{[A-Za-z_][A-Za-z0-9_.]*\}/y,/\$[A-Z_][A-Z0-9_]*/y,/%[A-Z_][A-Z0-9_]*%/y,/\{(?:env:[A-Za-z_][A-Za-z0-9_]*|file:[^}\s]+)\}/y],Oi=/\$\{([A-Za-z_][A-Za-z0-9_]*):-[^}]*\}/y;function dd(e){let t="",n=0;for(;n<e.length;){Oi.lastIndex=n;let r=Oi.exec(e);if(r){t+=`\${${r[1]??""}:-${H.REDACTED_VALUE}}`,n=Oi.lastIndex;continue}let o=!1;for(let i of GA){i.lastIndex=n;let a=i.exec(e);if(a){t+=a[0],n=i.lastIndex,o=!0;break}}if(!o)return null}return t.length>0?t:null}s(dd,"referencesOnly");function bt(e){let t=/^(bearer|basic|token)(\s+)(.+)$/i.exec(e);if(t){let n=dd(t[3]??"");return n===null?null:`${t[1]??""}${t[2]??""}${n}`}return dd(e)}s(bt,"sanitizeVariableReference");function qn(e,t){return t.home?(0,hd.tildeHomeInText)(e,t.home):e}s(qn,"tildeText");function lo(e){return(0,F.isSecretShapedValue)(e)||e.split(/[\s=,;:'"]+/).some(F.isSecretShapedValue)}s(lo,"containsSecretShapedToken");function Ed(e,t){return lo(e)?H.REDACTED_VALUE:e.includes("://")?Rd(e,t):qn(e,t)}s(Ed,"keepString");var VA=/^[A-Za-z][A-Za-z_-]{0,31}$/;function zA(e){return typeof e!="string"?F.OMITTED_VALUE:VA.test(e)&&!(0,F.isSecretShapedValue)(e)?e:H.REDACTED_VALUE}s(zA,"sanitizeMode");function WA(e,t){return typeof e=="string"?Ed(e,t):typeof e=="number"?Number.isFinite(e)?e:F.OMITTED_VALUE:typeof e=="boolean"||e===null?e:F.OMITTED_VALUE}s(WA,"keepScalar");function pd(e){return typeof e!="string"?F.OMITTED_VALUE:/[\s=]/.test(e)||lo(e)?H.REDACTED_VALUE:e}s(pd,"toolName");function YA(e){return typeof e=="boolean"?e:typeof e=="string"?pd(e):Array.isArray(e)?e.map(t=>pd(t)):F.OMITTED_VALUE}s(YA,"sanitizeToolList");function JA(e,t){return Array.isArray(e)?e.map(n=>typeof n=="string"?Ed(n,t):F.OMITTED_VALUE):F.OMITTED_VALUE}s(JA,"sanitizeStringList");function XA(e){return(0,F.isAuthHeaderName)(e)||(0,F.isAuthKeyName)(e)}s(XA,"isCredentialHeaderName");var bi=/(^|[\s"'=,;])([A-Za-z][A-Za-z0-9_-]*)(\s*:\s*)/g;function Sd(e){let t="",n=0;bi.lastIndex=0;let r;for(;(r=bi.exec(e))!==null;){let o=r[2]??"",i=r.index+r[0].length;if(!XA(o))continue;let a=e.slice(i).search(/["'\n]/),c=a===-1?e.length:i+a,u=e.slice(i,c).trim();u.length!==0&&(t+=e.slice(n,i),t+=bt(u)??H.REDACTED_VALUE,n=c,bi.lastIndex=c)}return t+e.slice(n)}s(Sd,"redactCredentialHeaders");var yd=/\b(bearer|basic|token)(\s+)([^\s"']+)/gi;function qA(e){for(let t of e.matchAll(yd))if(bt(t[3]??"")===null)return!0;return!1}s(qA,"hasLiteralAuthScheme");function ZA(e){let t=Sd(e);return qA(t)?H.REDACTED_VALUE:t}s(ZA,"redactCredentialArg");function QA(e){return Sd(e).replace(yd,(t,n,r,o)=>bt(o)===null?`${n}${r}${H.REDACTED_VALUE}`:t)}s(QA,"redactCredentialCommandLine");function eO(e){return e.map(t=>/\s/.test(t)?t.includes('"')&&!t.includes("'")?`'${t}'`:`"${t}"`:t).join(" ")}s(eO,"joinCommandTokens");function Ti(e,t){if(typeof e!="string")return F.OMITTED_VALUE;let n=(0,_d.tokenizeCommand)(QA(e));return n.length===0?e:qn(eO((0,F.redactArgs)(n)),t)}s(Ti,"sanitizeCommand");function tO(e,t){if(typeof e=="string"){let n=bt(e);if(n!==null)return n;let r=(0,_d.tokenizeCommand)(e),[o]=r;if(o===void 0)return e;let i=Ti(o,t);return r.length>1?`${String(i)} ${H.REDACTED_VALUE}`:i}return Array.isArray(e)?e.map((n,r)=>r===0?Ti(n,t):H.REDACTED_VALUE):F.OMITTED_VALUE}s(tO,"sanitizeHelperCommand");function nO(e,t){if(!Array.isArray(e))return F.OMITTED_VALUE;let n=[],r=[];e.forEach((a,c)=>{typeof a=="string"&&(n.push(c),r.push(a))});let o=(0,F.redactArgs)(r),i=e.map(()=>F.OMITTED_VALUE);return n.forEach((a,c)=>{i[a]=qn(ZA(o[c]??H.REDACTED_VALUE),t)}),i}s(nO,"sanitizeArgs");function rO(e){try{return new URL(e).href.length>0}catch{return!1}}s(rO,"canParseUrl");function Ii(e){return e.split("/").map(t=>lo(t)?H.REDACTED_VALUE:t).join("/")}s(Ii,"redactSecretPathSegments");function Rd(e,t){if(typeof e!="string")return F.OMITTED_VALUE;let n=bt(e);if(n!==null)return n;if(/^(?:unix|pipe):/i.test(e)){let l=e.indexOf("#"),p=l===-1?e:e.slice(0,l),d=l===-1?"":e.slice(l),m=p.split("?",1)[0]??"";return qn(Ii(`${m}${d}`),t)}if(/^(?:https?|wss?):/i.test(e)&&rO(e))return Ii((0,F.redactCommandOrUrl)(e));let r=e.split(/[?#]/,1)[0]??"",o=/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.exec(r)?.[0]??"",i=r.slice(o.length),a=i.indexOf("/"),u=(a===-1?i:i.slice(0,a)).lastIndexOf("@"),f=`${o}${u===-1?i:i.slice(u+1)}`;return qn(Ii(f),t)}s(Rd,"sanitizeUrl");function Cd(e){return e===null?null:typeof e=="string"?bt(e)??H.REDACTED_VALUE:H.REDACTED_VALUE}s(Cd,"sanitizeSecret");function uo(e){return typeof e!="string"?F.OMITTED_VALUE:KA.test(e)&&!(0,F.isSecretShapedValue)(e)?e:H.REDACTED_VALUE}s(uo,"envName");function oO(e){if(Array.isArray(e))return e.map(n=>{if(typeof n!="string")return F.OMITTED_VALUE;let r=n.indexOf("=");if(r===-1)return uo(n);let o=n.slice(0,r);return uo(o)!==o?H.REDACTED_VALUE:`${o}=${bt(n.slice(r+1))??H.REDACTED_VALUE}`});if(!(0,jt.isRecord)(e))return F.OMITTED_VALUE;let t={};for(let[n,r]of Object.entries(e))t[n]=Cd(r);return t}s(oO,"sanitizeSecretMap");function sO(e){if(!(0,jt.isRecord)(e))return F.OMITTED_VALUE;let t={};for(let[n,r]of Object.entries(e))t[n]=uo(r);return t}s(sO,"sanitizeEnvNameMap");function md(e,t){return lo(e)?H.REDACTED_VALUE:t.home?(0,hd.tildePath)(e,t.home):e}s(md,"pathString");function iO(e,t){return typeof e=="string"?md(e,t):Array.isArray(e)?e.map(n=>typeof n=="string"?md(n,t):F.OMITTED_VALUE):F.OMITTED_VALUE}s(iO,"sanitizePath");function Ad(e,t,n){let r={};for(let[o,i]of Object.entries(e)){let a=Object.hasOwn(t,o)?t[o]:void 0;r[o]=a===void 0?F.OMITTED_VALUE:un(i,a,n)}return r}s(Ad,"sanitizeObject");function aO(e,t,n){switch(t){case"keep":return WA(e,n);case"transport_type":return typeof e=="string"&&H.MCP_CONFIG_TRANSPORT_TYPES.has(e)?e:F.OMITTED_VALUE;case"mode":return zA(e);case"string_list":return JA(e,n);case"tool_list":return YA(e);case"command":return Ti(e,n);case"helper_command":return tO(e,n);case"args":return nO(e,n);case"url":return Rd(e,n);case"secret":return Cd(e);case"secret_map":return oO(e);case"env_name":return uo(e);case"env_name_map":return sO(e);case"path":return iO(e,n);case"omit":return F.OMITTED_VALUE}}s(aO,"applyLeaf");function un(e,t,n){if(typeof t=="string")return aO(e,t,n);if("object"in t)return(0,jt.isRecord)(e)?Ad(e,t.object,n):F.OMITTED_VALUE;if("map"in t){if(!(0,jt.isRecord)(e))return F.OMITTED_VALUE;let i={};for(let[a,c]of Object.entries(e))i[a]=un(c,t.map,n);return i}if("list"in t)return Array.isArray(e)?e.map(i=>un(i,t.list,n)):F.OMITTED_VALUE;let r=BA(e),o=r===void 0?void 0:t.by[r];return o===void 0?F.OMITTED_VALUE:un(e,o,n)}s(un,"applyTreatment");function gd(e,t){if(!(0,jt.isRecord)(e))return F.OMITTED_VALUE;let n={};for(let[r,o]of Object.entries(e))n[r]=(0,jt.isRecord)(o)?Ad(o,H.MCP_CONFIG_SERVER_KEY_TREATMENT,t):F.OMITTED_VALUE;return n}s(gd,"sanitizeServers");function cO(e){return/(?:^|[\\/])\.vscode[\\/]mcp\.json$/i.test(e)}s(cO,"isVsCodeMcpJson");function uO(e){return cO(e)?"vscode_mcp_json":(0,LA.basename)(e)===".claude.json"?"claude_json_slice":"mcp_json"}s(uO,"mcpConfigFormatOf");function Od(e){return e==="vscode_mcp_json"?"servers":"mcpServers"}s(Od,"mcpConfigServersKey");function lO(e,t,n={}){if(!(0,jt.isRecord)(e))return{};let r=Od(t);if(t==="claude_json_slice")return Object.hasOwn(e,r)?{[r]:gd(e[r],n)}:{};let o={};for(let[i,a]of Object.entries(e))i===r?o[i]=gd(a,n):t==="vscode_mcp_json"&&i==="inputs"?o[i]=un(a,{list:{object:H.MCP_CONFIG_VSCODE_INPUT_TABLE}},n):t==="vscode_mcp_json"&&i==="sandbox"?o[i]=un(a,{object:H.MCP_CONFIG_SANDBOX_TABLE},n):o[i]=F.OMITTED_VALUE;return o}s(lO,"sanitizeMcpConfigFile")});var Id=W(po=>{"use strict";Object.defineProperty(po,"__esModule",{value:!0});po.sanitizeMcpConfig=pO;po.parseMcpConfig=mO;var fO=Be("node:crypto"),fo=Xn(),bd=ki(),dO=co();function pO(e,t){let n=JSON.parse(e);return JSON.stringify((0,bd.sanitizeMcpConfigFile)(n,t),null,2)}s(pO,"sanitizeMcpConfig");function mO(e,t){let n=JSON.parse(e);if(!(0,fo.isRecord)(n))return[];let r=n[(0,bd.mcpConfigServersKey)(t)];return(0,fo.isRecord)(r)?Object.entries(r).flatMap(([o,i])=>(0,fo.isRecord)(i)?[gO(o,i)]:[]):[]}s(mO,"parseMcpConfig");function gO(e,t){return{key:e,enabled:(0,dO.mcpServerEnabledFromJson)(t),block:t,launch:_O(e,t),contentHash:(0,fO.createHash)("sha256").update(xi(t)).digest("hex")}}s(gO,"parsedServer");function _O(e,t){if(typeof t.command=="string"&&t.command.length>0){let r=Array.isArray(t.args)?t.args.filter(o=>typeof o=="string"):[];return{kind:"command",command:t.command,arguments:r}}let n=[t.url,t.serverUrl,t.httpUrl].find(r=>typeof r=="string"&&r.length>0);return n!==void 0?{kind:"url",url:n}:{kind:"unknown",installationRootExternalKey:"",sourcePath:"",nativeKey:e}}s(_O,"launchOf");function xi(e){return Array.isArray(e)?`[${e.map(xi).join(",")}]`:(0,fo.isRecord)(e)?`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${xi(e[n])}`).join(",")}}`:JSON.stringify(e)??"null"}s(xi,"canonicalJson")});var ke=W(_=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.mcpServerEnabledFromJson=_.isSecretShapedValue=_.isAuthKeyName=_.isAuthHeaderName=_.ENABLED_RAW_KEYS=_.tildePath=_.tildeHomeInText=_.tokenizeCommand=_.isRecord=_.redactComponentSource=_.prepareComponentInspectionText=_.fitSnapshotInspectionTextBudget=_.componentSourceContainsRedactableSecret=_.capComponentTextBytes=_.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=_.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=_.COMPONENT_INSPECTION_TEXT_MAX_BYTES=_.usableCatalogText=_.parseFrontmatterField=_.parseFrontmatterDescription=_.mcpServerToolSegmentForms=_.mcpServerNameMatchesToolSegment=_.isNpmRegistryPublisher=_.EMPTY_NPM_PUBLISHER=_.displayPublisherName=_.classifyMcpProvenance=_.resolveMcpPackageIdentity=_.resolveLocalBinPackageIdentity=_.McpPackageEcosystem=_.pinnedPackageVersionFromSpec=_.pinnedPackageVersionFromNpx=_.packageNameFromSpec=_.npxPackageSpecs=_.npxExecBin=_.isNodeModulesBinCommand=_.isExactNpmVersion=_.LOCAL_BIN_PACKAGE_VERSION_SOURCE=_.PACKAGE_FIELD_MAX=_.serializeMcpLaunchIdentity=_.projectMcpMissingLaunchIdentity=_.projectMcpLaunchIdentity=_.normalizeMcpToolNames=_.MCP_MISSING_LAUNCH_SERIALIZED=_.MCP_LAUNCH_IDENTITY_ALGORITHM=_.maskMcpLaunchForDisplay=_.launchContainsCredentials=_.hashMcpLaunchIdentity=_.foldMcpName=_.buildMcpFamilyCanonicalKey=_.ComponentKind=void 0;_.sanitizeMcpConfig=_.parseMcpConfig=_.sanitizeVariableReference=_.sanitizeMcpConfigFile=_.REDACTED_VALUE=_.mcpConfigServersKey=_.mcpConfigFormatOf=_.MCP_CONFIG_VSCODE_INPUT_TABLE=_.MCP_CONFIG_TRANSPORT_TYPES=_.MCP_CONFIG_SERVER_KEY_TREATMENT=_.MCP_CONFIG_SANDBOX_TABLE=_.TOOL_LIST_RAW_KEYS=_.redactCommandOrUrl=_.redactArgs=_.OMITTED_VALUE=void 0;_.userConfigRootFromPath=kO;_.repositoryConfigRootExternalKeyFromPath=wO;_.installationRootExternalKey=LO;_.normalizeRepositoryRelativePath=Td;_.nativeKeyForSkillPath=MO;_.nativeKeyForRulePath=vO;_.nativeKeyForCommandPath=UO;_.serializeComponentIdentity=xd;_.buildComponentReference=HO;_.validateComponentReference=FO;var hO=Be("node:crypto"),EO=Be("node:path"),SO="cmp1_",yO=/^cmp1_[A-Za-z0-9_-]{43}$/,RO=["/skills/","/skills-cursor/"],CO=/(?:^|\/)(?:\.(?:cursor|claude|codex)|\.gemini\/config)\/rules\/(.+)$/i,AO=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,OO=/(?:^|\/)\.(?:github|copilot)\/instructions\/(.+)$/i,bO=/(?:^|\/)\.github\/prompts\/(.+)$/i,IO=[".cursor",".claude",".codex",".copilot",".gemini"],TO={".claude.json":".claude",".agents":".codex",".github":".copilot",".vscode":".copilot"};_.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function kO(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>IO.includes(o));return n||(t.map(o=>TO[o]).find(o=>o!==void 0)??"unknown")}s(kO,"userConfigRootFromPath");var xO=new Set([".claude",".cursor",".codex",".opencode",".github"]),PO=".agents",NO=".codex";function wO(e,t){let n=t.replaceAll("\\","/").split("/").filter(Boolean),r=n.findIndex(i=>xO.has(i));if(r>=0)return`${e}:${n.slice(0,r+1).join("/")}`;let o=n.indexOf(PO);return o<0?null:`${e}:${[...n.slice(0,o),NO].join("/")}`}s(wO,"repositoryConfigRootExternalKeyFromPath");function LO(e,t){return`runtime-install:${e}/${t}`}s(LO,"installationRootExternalKey");function mo(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}s(mo,"requireValue");function Td(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=EO.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return mo(n,"sourcePath")}s(Td,"normalizeRepositoryRelativePath");function MO(e){let t=e.replaceAll("\\","/");for(let n of RO){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}s(MO,"nativeKeyForSkillPath");function Pi(e,t,n){let r=e.replaceAll("\\","/"),i=t.exec(r)?.[1];if(!i||i.split("/").includes(".."))return null;let a=i.replace(n,"");return a.length>0?a:null}s(Pi,"nativeKeyUnderLayoutRoot");function vO(e){return Pi(e,CO,/\.(mdc|md|rules)$/i)??kd(e,OO,/\.instructions\.md$/i)}s(vO,"nativeKeyForRulePath");function UO(e){return Pi(e,AO,/\.(md|mdc|toml)$/i)??kd(e,bO,/\.prompt\.md$/i)}s(UO,"nativeKeyForCommandPath");function kd(e,t,n){if(!n.test(e.split("#",1)[0]??""))return null;let r=Pi(e,t,n);return r===null?null:r.split("/").pop()??null}s(kd,"copilotNativeKey");function DO(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(DO,"field");function xd(e){let t=[mo(e.installationRootExternalKey,"installationRootExternalKey"),mo(e.installableKind,"installableKind"),Td(e.sourcePath),mo(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(DO).join("|")}`,"utf8")}s(xd,"serializeComponentIdentity");function HO(e){let t=(0,hO.createHash)("sha256").update(xd(e)).digest("base64url");return`${SO}${t}`}s(HO,"buildComponentReference");function FO(e){return yO.test(e)}s(FO,"validateComponentReference");var De=ro();Object.defineProperty(_,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:s(function(){return De.buildMcpFamilyCanonicalKey},"get")});Object.defineProperty(_,"foldMcpName",{enumerable:!0,get:s(function(){return De.foldMcpName},"get")});Object.defineProperty(_,"hashMcpLaunchIdentity",{enumerable:!0,get:s(function(){return De.hashMcpLaunchIdentity},"get")});Object.defineProperty(_,"launchContainsCredentials",{enumerable:!0,get:s(function(){return De.launchContainsCredentials},"get")});Object.defineProperty(_,"maskMcpLaunchForDisplay",{enumerable:!0,get:s(function(){return De.maskMcpLaunchForDisplay},"get")});Object.defineProperty(_,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:s(function(){return De.MCP_LAUNCH_IDENTITY_ALGORITHM},"get")});Object.defineProperty(_,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:s(function(){return De.MCP_MISSING_LAUNCH_SERIALIZED},"get")});Object.defineProperty(_,"normalizeMcpToolNames",{enumerable:!0,get:s(function(){return De.normalizeMcpToolNames},"get")});Object.defineProperty(_,"projectMcpLaunchIdentity",{enumerable:!0,get:s(function(){return De.projectMcpLaunchIdentity},"get")});Object.defineProperty(_,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:s(function(){return De.projectMcpMissingLaunchIdentity},"get")});Object.defineProperty(_,"serializeMcpLaunchIdentity",{enumerable:!0,get:s(function(){return De.serializeMcpLaunchIdentity},"get")});var it=so();Object.defineProperty(_,"PACKAGE_FIELD_MAX",{enumerable:!0,get:s(function(){return it.PACKAGE_FIELD_MAX},"get")});Object.defineProperty(_,"LOCAL_BIN_PACKAGE_VERSION_SOURCE",{enumerable:!0,get:s(function(){return it.LOCAL_BIN_PACKAGE_VERSION_SOURCE},"get")});Object.defineProperty(_,"isExactNpmVersion",{enumerable:!0,get:s(function(){return it.isExactNpmVersion},"get")});Object.defineProperty(_,"isNodeModulesBinCommand",{enumerable:!0,get:s(function(){return it.isNodeModulesBinCommand},"get")});Object.defineProperty(_,"npxExecBin",{enumerable:!0,get:s(function(){return it.npxExecBin},"get")});Object.defineProperty(_,"npxPackageSpecs",{enumerable:!0,get:s(function(){return it.npxPackageSpecs},"get")});Object.defineProperty(_,"packageNameFromSpec",{enumerable:!0,get:s(function(){return it.packageNameFromSpec},"get")});Object.defineProperty(_,"pinnedPackageVersionFromNpx",{enumerable:!0,get:s(function(){return it.pinnedPackageVersionFromNpx},"get")});Object.defineProperty(_,"pinnedPackageVersionFromSpec",{enumerable:!0,get:s(function(){return it.pinnedPackageVersionFromSpec},"get")});var Ni=Kf();Object.defineProperty(_,"McpPackageEcosystem",{enumerable:!0,get:s(function(){return Ni.McpPackageEcosystem},"get")});Object.defineProperty(_,"resolveLocalBinPackageIdentity",{enumerable:!0,get:s(function(){return Ni.resolveLocalBinPackageIdentity},"get")});Object.defineProperty(_,"resolveMcpPackageIdentity",{enumerable:!0,get:s(function(){return Ni.resolveMcpPackageIdentity},"get")});var go=Xf();Object.defineProperty(_,"classifyMcpProvenance",{enumerable:!0,get:s(function(){return go.classifyMcpProvenance},"get")});Object.defineProperty(_,"displayPublisherName",{enumerable:!0,get:s(function(){return go.displayPublisherName},"get")});Object.defineProperty(_,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:s(function(){return go.EMPTY_NPM_PUBLISHER},"get")});Object.defineProperty(_,"isNpmRegistryPublisher",{enumerable:!0,get:s(function(){return go.isNpmRegistryPublisher},"get")});var Pd=Zf();Object.defineProperty(_,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:s(function(){return Pd.mcpServerNameMatchesToolSegment},"get")});Object.defineProperty(_,"mcpServerToolSegmentForms",{enumerable:!0,get:s(function(){return Pd.mcpServerToolSegmentForms},"get")});var wi=Qf();Object.defineProperty(_,"parseFrontmatterDescription",{enumerable:!0,get:s(function(){return wi.parseFrontmatterDescription},"get")});Object.defineProperty(_,"parseFrontmatterField",{enumerable:!0,get:s(function(){return wi.parseFrontmatterField},"get")});Object.defineProperty(_,"usableCatalogText",{enumerable:!0,get:s(function(){return wi.usableCatalogText},"get")});var It=nd();Object.defineProperty(_,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return It.COMPONENT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(_,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:s(function(){return It.COMPONENT_SOURCE_REDACTION_PLACEHOLDER},"get")});Object.defineProperty(_,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return It.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(_,"capComponentTextBytes",{enumerable:!0,get:s(function(){return It.capComponentTextBytes},"get")});Object.defineProperty(_,"componentSourceContainsRedactableSecret",{enumerable:!0,get:s(function(){return It.componentSourceContainsRedactableSecret},"get")});Object.defineProperty(_,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:s(function(){return It.fitSnapshotInspectionTextBudget},"get")});Object.defineProperty(_,"prepareComponentInspectionText",{enumerable:!0,get:s(function(){return It.prepareComponentInspectionText},"get")});Object.defineProperty(_,"redactComponentSource",{enumerable:!0,get:s(function(){return It.redactComponentSource},"get")});var $O=Xn();Object.defineProperty(_,"isRecord",{enumerable:!0,get:s(function(){return $O.isRecord},"get")});var jO=Si();Object.defineProperty(_,"tokenizeCommand",{enumerable:!0,get:s(function(){return jO.tokenizeCommand},"get")});var Nd=yi();Object.defineProperty(_,"tildeHomeInText",{enumerable:!0,get:s(function(){return Nd.tildeHomeInText},"get")});Object.defineProperty(_,"tildePath",{enumerable:!0,get:s(function(){return Nd.tildePath},"get")});var at=co();Object.defineProperty(_,"ENABLED_RAW_KEYS",{enumerable:!0,get:s(function(){return at.ENABLED_RAW_KEYS},"get")});Object.defineProperty(_,"isAuthHeaderName",{enumerable:!0,get:s(function(){return at.isAuthHeaderName},"get")});Object.defineProperty(_,"isAuthKeyName",{enumerable:!0,get:s(function(){return at.isAuthKeyName},"get")});Object.defineProperty(_,"isSecretShapedValue",{enumerable:!0,get:s(function(){return at.isSecretShapedValue},"get")});Object.defineProperty(_,"mcpServerEnabledFromJson",{enumerable:!0,get:s(function(){return at.mcpServerEnabledFromJson},"get")});Object.defineProperty(_,"OMITTED_VALUE",{enumerable:!0,get:s(function(){return at.OMITTED_VALUE},"get")});Object.defineProperty(_,"redactArgs",{enumerable:!0,get:s(function(){return at.redactArgs},"get")});Object.defineProperty(_,"redactCommandOrUrl",{enumerable:!0,get:s(function(){return at.redactCommandOrUrl},"get")});Object.defineProperty(_,"TOOL_LIST_RAW_KEYS",{enumerable:!0,get:s(function(){return at.TOOL_LIST_RAW_KEYS},"get")});var ct=ki();Object.defineProperty(_,"MCP_CONFIG_SANDBOX_TABLE",{enumerable:!0,get:s(function(){return ct.MCP_CONFIG_SANDBOX_TABLE},"get")});Object.defineProperty(_,"MCP_CONFIG_SERVER_KEY_TREATMENT",{enumerable:!0,get:s(function(){return ct.MCP_CONFIG_SERVER_KEY_TREATMENT},"get")});Object.defineProperty(_,"MCP_CONFIG_TRANSPORT_TYPES",{enumerable:!0,get:s(function(){return ct.MCP_CONFIG_TRANSPORT_TYPES},"get")});Object.defineProperty(_,"MCP_CONFIG_VSCODE_INPUT_TABLE",{enumerable:!0,get:s(function(){return ct.MCP_CONFIG_VSCODE_INPUT_TABLE},"get")});Object.defineProperty(_,"mcpConfigFormatOf",{enumerable:!0,get:s(function(){return ct.mcpConfigFormatOf},"get")});Object.defineProperty(_,"mcpConfigServersKey",{enumerable:!0,get:s(function(){return ct.mcpConfigServersKey},"get")});Object.defineProperty(_,"REDACTED_VALUE",{enumerable:!0,get:s(function(){return ct.REDACTED_VALUE},"get")});Object.defineProperty(_,"sanitizeMcpConfigFile",{enumerable:!0,get:s(function(){return ct.sanitizeMcpConfigFile},"get")});Object.defineProperty(_,"sanitizeVariableReference",{enumerable:!0,get:s(function(){return ct.sanitizeVariableReference},"get")});var wd=Id();Object.defineProperty(_,"parseMcpConfig",{enumerable:!0,get:s(function(){return wd.parseMcpConfig},"get")});Object.defineProperty(_,"sanitizeMcpConfig",{enumerable:!0,get:s(function(){return wd.sanitizeMcpConfig},"get")})});import{existsSync as Ih,readFileSync as Th}from"node:fs";import{hostname as Oc,release as kh,userInfo as xh,version as Ph}from"node:os";import*as Ee from"node:os";import{performance as rs}from"node:perf_hooks";var dh=1024*1024,ph=128;function Sr(e){return Math.round(e/dh)}s(Sr,"mb");function xn(e,t){let n=10**t;return Math.round(e*n)/n}s(xn,"round");function cc(e=process.platform){try{let t=rs.now(),n={},r=0,o=0,i=e!=="win32";for(let{times:u}of Ee.cpus())r+=u.user+u.nice+u.sys+(i?u.irq:0),o+=u.idle;if(r+o>0&&(n.cpu_busy_ms=Math.round(r),n.cpu_idle_ms=Math.round(o)),n.uptime_s=Math.round(Ee.uptime()),n.mem_free_mb=Sr(Ee.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=Sr(process.availableMemory())),e!=="win32"){let[u,f,l]=Ee.loadavg();n.load_1m=xn(u??0,2),n.load_5m=xn(f??0,2),n.load_15m=xn(l??0,2)}let a=process.resourceUsage();n.proc_cpu_user_ms=Math.round(a.userCPUTime/1e3),n.proc_cpu_sys_ms=Math.round(a.systemCPUTime/1e3),n.proc_max_rss_mb=Math.round(a.maxRSS/1024),n.proc_page_faults=a.majorPageFault,e!=="win32"&&(n.proc_invol_ctx=a.involuntaryContextSwitches);let c=rs.nodeTiming?.bootstrapComplete;return typeof c=="number"&&c>0&&(n.node_boot_ms=xn(c,1)),n.sample_us=Math.round((rs.now()-t)*1e3),n}catch{return}}s(cc,"sampleSys");function uc(){try{let e=Ee.cpus(),t={},n=typeof Ee.availableParallelism=="function"?Ee.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,ph);r&&(t.cpu_model=r);let o=Ee.totalmem();t.mem_total_mb=Sr(o);let i=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof i=="number"&&i>0&&i<o&&(t.mem_limit_mb=Sr(i)),t.uptime_h=xn(Ee.uptime()/3600,1),t}catch{return{}}}s(uc,"hostSpecs");import{createHash as mh,randomBytes as gh}from"node:crypto";import{existsSync as yr,mkdirSync as _h,readdirSync as hh,readFileSync as Eh,renameSync as dc,statSync as pc,unlinkSync as mc,writeFileSync as Sh}from"node:fs";import{homedir as gc}from"node:os";import{basename as yh,dirname as lc,isAbsolute as Rh,join as _c,relative as hc,resolve as qe,sep as Ch}from"node:path";function x(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
14
+ `)}s(x,"logStderr");function Pn(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}s(Pn,"stripRemoteCredentials");function Nn(e){return mh("sha256").update(e).digest("hex").slice(0,32)}s(Nn,"sha32");var Ah=3;function Ec(e){return e instanceof Error&&"code"in e?e.code:void 0}s(Ec,"errnoCode");function Sc(e){let t=Ec(e);return t==="EEXIST"||t==="EPERM"||t==="EACCES"}s(Sc,"isRenameReplaceBlocked");function Oh(e,t,n){let r=n;for(let o=0;o<Ah;o+=1){try{mc(t)}catch(i){if(Ec(i)!=="ENOENT")throw i}try{dc(e,t);return}catch(i){if(!Sc(i))throw i;r=i}}throw r}s(Oh,"replaceByUnlinkThenRename");function le(e,t){_h(lc(e),{recursive:!0});let n=_c(lc(e),`.${yh(e)}.${process.pid}.${gh(4).toString("hex")}.tmp`);try{Sh(n,t,"utf8");try{dc(n,e)}catch(r){if(!Sc(r))throw r;Oh(n,e,r)}}catch(r){try{mc(n)}catch{}throw r}}s(le,"writeFileAtomic");function Rr(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}s(Rr,"timestampUtc");var ss;function is(e){ss=e}s(is,"setHookStdio");function as(e='{"continue":true}'){(ss?.stdout??process.stdout).write(e)}s(as,"emitStdoutOk");var Nt=new Set(["on","1","true"]),Cr=new Set(["off","0","false"]);function j(e){let t=process.env[e];return t===void 0||t===""?void 0:t}s(j,"readEnv");async function cs(){return new Promise(e=>{let t="";if(process.stdin.isTTY){e("");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",n=>{t+=n}),process.stdin.on("end",()=>{e(t)}),process.stdin.on("error",()=>{e(t)}),process.stdin.resume()})}s(cs,"readStdinUntilEnd");async function Ar(e){let t=ss?.stdin??process.stdin;return new Promise(n=>{let r="",o=!1,i=s(c=>{o||(o=!0,clearTimeout(a),n(c||"{}"))},"finish"),a=setTimeout(()=>{i(r)},e);if(t.isTTY){i("{}");return}t.setEncoding("utf8"),t.on("data",c=>{r+=c}),t.on("end",()=>{i(r)}),t.on("error",()=>{i(r)}),t.resume()})}s(Ar,"readStdinWithTimeout");async function ve(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:i}=await import("node:util"),a=i(o);try{let{stdout:c}=await a(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:c.trim()}}catch(c){let u=c,f=typeof u.code=="number"?u.code:typeof u.status=="number"?u.status:void 0;return{ok:!1,code:f,spawnFailed:f===void 0}}}s(ve,"execFileResult");async function re(e,t,n=3e3,r={}){let o=await ve(e,t,n,r);return o.ok?o.stdout:""}s(re,"execFileText");function os(e,t){let n=qe(e),r=qe(t),o=hc(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${Ch}`)||Rh(o)?!1:qe(r,o)===n}s(os,"isPathInside");function yc(e,t,n=gc()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return qe(e);let o=qe(r),i=qe(e);if(os(i,o))return i;let a=t.CURSOR_PLUGIN_ROOT?.trim();return os(i,qe(n,".cursor"))||a!==void 0&&a.length>0&&os(i,qe(a))?o:i}s(yc,"cursorHookLaunchCwd");async function us(e=process.cwd(),t=process.env,n=gc()){let r=yc(e,t,n),o=r!==qe(e)&&yr(r)?r:e,i=await ve("git",["rev-parse","--show-toplevel"],2e3,{cwd:o});if(i.ok&&i.stdout)return{root:i.stdout,inGitRepo:!0};if(j("EV_AI_HOOK_DEBUG")){let c=i.ok?"empty stdout":i.spawnFailed?"spawn failed":`exit ${String(i.code??"unknown")}`;x(`DEBUG: git rev-parse --show-toplevel failed (${c}) cwd=${e}`)}let a=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||j("CURSOR_PROJECT_DIR")||j("CLAUDE_PROJECT_DIR");if(a&&yr(a)){let c=await ve("git",["rev-parse","--show-toplevel"],2e3,{cwd:a});return c.ok&&c.stdout?{root:c.stdout,inGitRepo:!0}:{root:a,inGitRepo:!1}}return{root:e,inGitRepo:!1}}s(us,"resolveGitWorkspace");async function ls(e=process.cwd()){return(await us(e)).root}s(ls,"findGitRoot");function xe(e,t){try{return JSON.parse(e)}catch{return t}}s(xe,"parseJsonSafe");var fc=new Map;function Yt(e){return e.charCodeAt(0)===65279?e.slice(1):e}s(Yt,"stripUtf8Bom");function bh(e){let t;try{t=Eh(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(Yt(t))}}catch{return{ok:!1,reason:"parse"}}}s(bh,"parseJsonFile");function Rc(e){let t=fc.get(e);if(t!==void 0)return t;let n=bh(e);return fc.set(e,n),n}s(Rc,"loadJsonFileStatus");function Cc(e){return Rc(e)}s(Cc,"readJsonFileStatus");function J(e,t){let n=Rc(e);return n.ok?n.value:t}s(J,"readJsonFileMemoized");function wt(e){return typeof e=="string"?e:""}s(wt,"pickString");function Ze(e,t){let n=e[t];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(!t.includes("."))return;let r=t.split("."),o=e;for(let i of r){if(o===null||typeof o!="object"||Array.isArray(o))return;o=o[i]}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o}s(Ze,"pickNestedScalar");function B(e,t){let n=Ze(e,t);return typeof n=="string"?n:""}s(B,"pickNestedString");var mt=500;function Ac(e,t=2){if(!yr(e))return{entries:[],truncated:!1};let n=[],r=!1,o=s((i,a)=>{if(a>t||r)return;let c;try{c=hh(i,{withFileTypes:!0})}catch{return}for(let u of c){if(r)return;let f=_c(i,u.name);if(u.isDirectory()){o(f,a+1);continue}if(u.isFile()){try{n.push({name:hc(e,f),size:pc(f).size})}catch{continue}if(n.length>=mt){r=!0;return}}}},"walk");return o(e,1),{entries:n,truncated:r}}s(Ac,"listDirFiles");function fs(e){return yr(e)?{present:!0,size:pc(e).size}:{present:!1,size:0}}s(fs,"fileSizeOrAbsent");function Jt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(Jt,"isTruthyFlag");function bc(e=process.env){return Jt(te("CURSOR_SANDBOX",e))}s(bc,"isCursorSandboxProcess");var Nh=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function wh(e){return Nh.some(t=>!!te(t,e))}s(wh,"hasManagedCiMarker");function Lh(e){if(te("KUBERNETES_SERVICE_HOST",e)||Jt(te("REMOTE_CONTAINERS",e))||Jt(te("DEVCONTAINER",e)))return!0;try{if(Ih("/.dockerenv")||Th("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}s(Lh,"hasContainerMarker");function Ic(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!te(t,e))}s(Ic,"hasIdeExtensionHostMarker");function Mh(e,t=process.platform){return Ic(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!te(n,e)):!1}s(Mh,"hasLocalIdeHostMarker");function vh(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}s(vh,"isBackgroundComposerSessionId");function Uh(e){return e==="linux"}s(Uh,"isLinuxPlatform");function te(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return j(e)}s(te,"readContextEnv");function Dh(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!Hh(te("CURSOR_VERSION",n))}s(Dh,"isCursorCloudHostFingerprint");function Hh(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(Hh,"trimEnvLocal");function ds(e){if(vh(e.sessionId))return!0;let t=e.hostname??Oc(),n=e.osUser??kc(e.env);return Dh(t,n,e.env)}s(ds,"hasCursorCloudExclusiveEvidence");function Fh(e){return Jt(te("CURSOR_AGENT",e.env))?!0:ds(e)}s(Fh,"hasCursorCloudEvidence");function $h(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(te("TERM",e)??te("TERM_PROGRAM",e))||(te("SSH_TTY",e)??te("SSH_CONNECTION",e))||(te("__CFBundleIdentifier",e)??te("XPC_SERVICE_NAME",e))||Ic(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!te(t,e))||te("SESSIONNAME",e))}s($h,"hasLocalSessionMarker");function Or(e={}){let t=e.env;if(te("GITHUB_ACTIONS",t))return"github_actions";if(Jt(te("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!Mh(t,n)&&Fh(e)&&(Jt(te("CURSOR_AGENT",t))||Uh(n)))return"cursor_cloud";if(te("CODESPACES",t)||te("CODESPACE_NAME",t))return"codespaces";if(te("GITLAB_CI",t))return"gitlab_ci";if(wh(t))return"managed";let r=te("CI",t);return r&&r!=="false"&&r!=="0"?"managed":Lh(t)?"container":$h(t)?"interactive":"unknown"}s(Or,"detectContext");async function Tc(){return await re("systemd-detect-virt",[],1e3)}s(Tc,"detectVirt");function kc(e=process.env,t=xh){for(let n of["USER","LOGNAME","USERNAME"]){let r=e[n];if(typeof r=="string"){let o=r.trim();if(o.length>0)return o}}try{return t().username??""}catch{return""}}s(kc,"resolveHostUsername");var jh=32;function Bh(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,jh);return t.length>0?t:null}s(Bh,"sanitizeOsPlatform");function Kh(){try{return[Ph(),kh()].filter(Boolean).join(" ").trim()}catch{return""}}s(Kh,"windowsVersion");async function xc(e=!1){let t=Bh(process.platform),n="";if(process.platform==="darwin")n=await re("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:a}=await import("node:fs"),c=a("/etc/os-release","utf8"),u=c.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],f=c.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];n=u??f??""}catch{n=await re("lsb_release",["-sd"],1e3).then(a=>a.replace(/^"|"$/g,""))}n||(n=await re("uname",["-r"],1e3))}else process.platform==="win32"?n=Kh():n=await re("ver",[],1e3);let r=kc(),o=(process.env.SHELL??"").split(/[/\\]/).pop()??"",i="";try{i=await re("tty",[],500),i.includes("not a tty")&&(i="")}catch{i=""}return{os:t,os_version:n||null,user:r||null,shell:o||null,tty:i||null,...e?uc():{}}}s(xc,"hostEnv");function ps(){return Oc()}s(ps,"hostName");import{createHash as eE}from"node:crypto";import{homedir as tE}from"node:os";import{dirname as HL,join as nE,parse as FL,resolve as $L}from"node:path";var Pc="EV_AI_LAUNCHER_VERSION";var Nc="EV_AI_HOOK_SOURCE",wc="EV_AI_HOOK_FALLBACK_REASON",Lc="EV_AI_LAUNCHER_SCOPE",ms="EV_AI_LAUNCHER_READY_FD";var Mc="--defer-user-spec",br="--cap",wn="--slot";var vc=Buffer.from([1]);var hL=1024*1024,EL=4*1024*1024,SL=64*1024,yL=64*1024,RL=64*1024;var gs=4096,CL=4*1024*1024;var Uc="ev-ai.agent-hook.in-process.v1";import{join as Bc}from"node:path";import{open as Dc,mkdir as Gh,readFile as Vh,readdir as zh,rename as Wh,stat as Yh,rmdir as Jh,unlink as Xh,utimes as qh}from"node:fs/promises";var Ir=new WeakMap;function Fc(e){if(e&&typeof e=="object"&&"code"in e)return e}s(Fc,"asNodeError");function Xt(e){return Fc(e)?.code==="ENOENT"}s(Xt,"isNotFound");function Ln(e){return Fc(e)?.code==="EEXIST"}s(Ln,"isAlreadyExists");async function $c(e,t){try{return await e.readdir(t)}catch(n){if(Xt(n))return[];throw n}}s($c,"readdirOrEmpty");function jc(){return{async open(e,t){let n=await Dc(e,t),r={path:e};return Ir.set(r,n),r},async write(e,t){let n=Hc(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await Hc(e).sync()},async close(e){let t=Ir.get(e);Ir.delete(e),t&&await t.close()},rename:Wh,async readdir(e){return zh(e)},readFile:Vh,async stat(e){let t=await Yh(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:s(()=>t.isDirectory(),"isDirectory")}},async mkdir(e,t){await Gh(e,t)},unlink:Xh,rmdir:Jh,utimes:qh,async fsyncDir(e){if(process.platform==="win32")return;let t=await Dc(e,"r");try{await t.sync()}finally{await t.close()}}}}s(jc,"productionFs");function Hc(e){let t=Ir.get(e);if(!t)throw new Error("closed");return t}s(Hc,"requireHandle");var Kc=4,Gc=10;function Tr(e=process.platform){return e==="win32"?Kc:Gc}s(Tr,"defaultMaxConcurrentHooks");var kr=6e4,Mn=2e3,Vc="slots",_s=64;function zc(e){return Bc(e,".ev-ai","agent-hook",Vc)}s(zc,"slotDirUnder");function xr(e,t){return Bc(e,`slot-${t}`)}s(xr,"slotPath");function Pr(e,t){return`${e}
15
15
  ${t}
16
- `}s(Rr,"slotRecord");function rs(e){let t=e===void 0?null:/^(\d+):(\d+)$/.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&Number.isSafeInteger(r)?{index:n,acquiredAtMs:r}:void 0}s(rs,"parseSlotRef");function xa(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}s(xa,"isPidAlive");var mh=/^(\d+)\n(\d+)\n$/;function gh(e){let t=mh.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&n>0&&Number.isSafeInteger(r)?{pid:n,acquiredAtMs:r}:void 0}s(gh,"parseSlotRecord");function Ia(e,t,n){let r=gh(e);if(!r)return Math.abs(n-t)<kn;let o=n-r.acquiredAtMs;return o<-kn||o>=Er?!1:xa(r.pid)}s(Ia,"isSlotRecordHeld");var Ma="https://hooks.ev-ai.ai",La=".claude/ev-ai-runtime-report.json",va="config.json",Eh="max_concurrent_hooks",pP=1024*1024,yh=new Set(["localhost","127.0.0.1","[::1]","::1"]),Rh=["claude","cursor","codex","copilot"],Ua=[La,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],os=/^[A-Za-z0-9._~-]+$/;function Cr(e){return e!==void 0&&Rh.includes(e)}s(Cr,"isKnownRunner");function Ha(e){if(!e||typeof e!="object")return;let t=e[Eh];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}s(Ha,"maxConcurrentHooksFromConfig");function Ta(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}s(Ta,"parseCapArg");function Vt(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}s(Vt,"takeFlagValue");function Ar(e){let t,n,r,o,i,c,a;for(let u=0;u<e.length;u++){let f=e[u];if(f!==void 0){if(f==="--runner"){let l=Vt(e,u);t=l.value,u=l.next;continue}if(f.startsWith("--runner=")){t=f.slice(9);continue}if(f==="--url"){let l=Vt(e,u);l.value&&(r=l.value),u=l.next;continue}if(f.startsWith("--url=")){r=f.slice(6);continue}if(f==="--token"){let l=Vt(e,u);l.value&&(o=l.value),u=l.next;continue}if(f.startsWith("--token=")){o=f.slice(8);continue}if(f==="--base-url"){let l=Vt(e,u);l.value&&(i=l.value),u=l.next;continue}if(f.startsWith("--base-url=")){i=f.slice(11);continue}if(f===_r){let l=Vt(e,u);c=Ta(l.value)??c,u=l.next;continue}if(f.startsWith(`${_r}=`)){c=Ta(f.slice(_r.length+1))??c;continue}if(f===bn){let l=Vt(e,u);a=rs(l.value)??a,u=l.next;continue}if(f.startsWith(`${bn}=`)){a=rs(f.slice(bn.length+1))??a;continue}f!==ma&&!f.startsWith("-")&&n===void 0&&(n=f)}}return{runner:Cr(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:i,...c!==void 0?{cap:c}:{},...a!==void 0?{slot:a}:{}}}s(Ar,"parseHookArgv");function br(e,t=Ma){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}s(br,"buildCollectorUrl");function bt(e=hh()){return Sh(e,".ev-ai",va)}s(bt,"homeManifestPath");function Da(e,t){return{...e,...t}}s(Da,"mergeManifestOverlay");function wa(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=32||n===127||n===39)return!0}return!1}s(wa,"hasUnsafeCollectorUrlChars");function Or(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?yh.has(t.hostname):!1}catch{return!1}}s(Or,"isAllowedCollectorUrl");function ss(e){try{let n=new URL(e).pathname.split("/").filter(r=>r.length>0);if(n.length>=2&&n[n.length-1]==="hook"){let r=n[n.length-2];return r&&r.length>0?r:void 0}return}catch{return}}s(ss,"extractOrgTokenFromCollectorUrl");function zt(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!Or(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=ss(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!os.test(n))return`org token must match ${os.source}`;if(wa(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(wa(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}s(zt,"collectorUrlProblem");function xn(e){return new URL(e).toString()}s(xn,"normalizeCollectorUrl");function Fa(e){if(e.collector_url)return e.collector_url;let t=e.repo_ingest_token,n=typeof t=="string"?t.trim():void 0;return n?br(n):""}s(Fa,"resolveCollectorUrl");function Wt(e){try{let t=new URL(e),n=t.pathname.split("/").filter(r=>r.length>0);return n.length>=2&&n[n.length-1]==="hook"&&(n[n.length-2]="***",t.pathname=`/${n.join("/")}`),t.toString()}catch{return"<invalid-url>"}}s(Wt,"redactCollectorUrlForLog");function $a(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=br(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=zt(n);return r?{problem:r}:{url:xn(n)}}s($a,"collectorUrlFromArgv");var Ch="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",Ah="COLLECTOR_URL",Na="collector_url_override",bh=[Ch,Ah];function Oh(e){let t;for(let n of bh){let r=e[n]?.trim();if(!r)continue;let o=zt(r);if(o){t??={problem:o,envName:n};continue}return{url:xn(r),envName:n}}return t??{}}s(Oh,"collectorUrlFromPluginOption");function Pa(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=zt(t);return n?{problem:n}:{url:xn(t)}}s(Pa,"candidateFromUnknown");function ja(e){let t=[],n=Pa(e.homeConfig?.[Na]);if(n.problem&&t.push({label:Na,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=$a(Ar(e.argv));if(r.problem&&t.push({label:"--url/--token",problem:r.problem}),r.url)return{url:r.url,source:"argv",warnings:t};let o=Oh(e.env);if(o.problem&&o.envName&&t.push({label:o.envName,problem:o.problem}),o.url)return{url:o.url,source:"plugin_option",warnings:t};let i=Pa(e.homeConfig?.collector_url);if(i.problem&&t.push({label:"collector_url",problem:i.problem}),i.url)return{url:i.url,source:"home_config",warnings:t};let c=e.homeConfig?.repo_ingest_token,a=typeof c=="string"&&c.trim()?{...e.manifest,repo_ingest_token:c}:e.manifest,u=a?Fa(a):"";if(u){let f=zt(u);if(f)t.push({label:"manifest collector_url",problem:f});else return{url:xn(u),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}s(ja,"selectCollectorUrl");function Ot(e){if(zt(e))return;let t;try{t=new URL(e)}catch{return}let n=ss(e);if(!n)return;let o=t.pathname.split("/").filter(a=>a.length>0).slice(0,-2),i=o.length>0?`/${o.join("/")}`:"",c=`${t.origin}${i}/${n}`;return _h("sha256").update(c).digest("hex").slice(0,32)}s(Ot,"scopeIdForCollectorUrl");var kr=2;var Jt="ev-ai-agent-hook";function kh(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}s(kh,"hookBinaryBasenameFromPath");function Ba(e){let t=kh(e);return t===Jt||t===`${Jt}.exe`}s(Ba,"isHookBinaryPath");var _P=`current/${Jt}`,hP=`.ev-ai/agent-hook/${Jt}`,Ka=5e3,Ga=5e3,is=3e3;var xr=3e3,Va=1500,za=4*1024,cs=256*1024,xh=4*1024,Wa=32*1024,Ye="1.4.1",SP=`@ev-ai/agent-hook@${Ye}`;var Ja={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT",copilot:"PLUGIN_ROOT"};import{existsSync as hx,mkdirSync as Sx,readdirSync as Ex,readFileSync as yx,unlinkSync as om,writeFileSync as Rx}from"node:fs";import{homedir as sm}from"node:os";import{join as ic}from"node:path";import{createHash as mp,randomBytes as XO}from"node:crypto";import{existsSync as gp,mkdirSync as Xi,readFileSync as _p,unlinkSync as hp,writeFileSync as Sp}from"node:fs";import{homedir as Xn}from"node:os";import{dirname as _o,join as ho,resolve as qO}from"node:path";var Ih=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com","claude@anthropic.com","agent@cursor.local"]),Th=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function pe(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||Th.has(n)||r.includes("[bot]")||Ih.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),i=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(i.endsWith("bot")||i.includes("[bot]"))return!0}return!1}s(pe,"isBotOperatorIdentity");import{homedir as as}from"node:os";import{join as Nh}from"node:path";function Ya(e=as()){return Nh(e,".claude.json")}s(Ya,"claudeUserConfigPath");function kt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(kt,"trimString");function Xa(e=as()){let n=Q(Ya(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=kt(n.emailAddress),o=kt(n.fullName)??kt(n.displayName),i=kt(n.accountUuid),c=r??i;return!c||pe(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:c,identity_source:"claude_oauth"}}s(Xa,"readClaudeOperatorIdentity");function qa(e=as()){let n=Q(Ya(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=kt(n.emailAddress),o=kt(n.fullName)??kt(n.displayName);return pe(o,r)?null:r?.toLowerCase()??null}s(qa,"readClaudeAccountKey");import{existsSync as hS,readFileSync as ku,unlinkSync as SS}from"node:fs";import ES from"node:http";import{join as xu}from"node:path";import{randomBytes as vh}from"node:crypto";import{appendFileSync as Uh,mkdirSync as Hh,readdirSync as Dh,readFileSync as ds,renameSync as su,statSync as wn,unlinkSync as uu}from"node:fs";import{homedir as lt,tmpdir as Fh}from"node:os";import{dirname as fs,join as xt}from"node:path";var eu="EV_AI_PERF_L",us="EV_AI_PERF_H",In="EV_AI_RUN_ID",Ph="EV_AI_HOOK_PERF";var Mh=/^[a-z][a-z0-9_]{0,23}$/;var Ir={origin:0,marks:{},values:{}},Tr=!1;function tu(e=process.env){Tr=e[Ph]!=="0",Ir.origin=performance.timeOrigin}s(tu,"startTimings");function Tn(){return Tr}s(Tn,"timingsActive");function Xe(e,t=performance.now()){Tr&&(Ir.marks[e]=t)}s(Xe,"mark");function nu(){return Ir}s(nu,"ownTimings");function ru(e){return Math.round(e*10)/10}s(ru,"round1");function Za(e){return Object.entries(e).map(([t,n])=>`${t}=${ru(n)}`).join(",")}s(Za,"entries");function Lh(e){return`${ru(e.origin)}|${Za(e.marks)}|${Za(e.values)}`}s(Lh,"serializeTimings");function Qa(e,t){if(!e)return!0;for(let n of e.split(",")){let r=n.indexOf("="),o=n.slice(0,r),i=Number(n.slice(r+1));if(r<1||!Mh.test(o)||!(i>=0&&i<=36e5))return!1;t[o]=i}return Object.keys(t).length<=32}s(Qa,"parseEntries");function ls(e){if(!e||e.length>1024)return;let[t,n,r,...o]=e.split("|"),i=Number(t);if(o.length>0||!Number.isFinite(i)||i<=0)return;let c={origin:i,marks:{},values:{}};if(!(!Qa(n,c.marks)||!Qa(r,c.values)))return c}s(ls,"parseTimings");function ou(){return Tr?Lh(Ir):void 0}s(ou,"serializeOwnTimings");var $h="hooks-debug.log",jh=/^hooks-debug\.log\.\d+$/,Bh=/^hooks-debug\.log(\.1)?\.send-\d+$/,iu="ev-ai-agent-hooks.log",Kh="EV_AI_HOOK_RUN_LOG",Yt="unlimited",Gh="off",ps=1024*1024,Vh=8*1024,cu=ps/2-Vh,zh=10080*60*1e3,Wh=1024*1024,Jh="run-log-windows.json",Yh=64*1024,ms=/^[a-z0-9]{8}$/,au="abcdefghijklmnopqrstuvwxyz0123456789",Xh=/[^A-Za-z0-9._:/+-]/g,qh=128,ft={info(){},error(){}},ke=ft;function Nr(e=lt()){return xt(e,".ev-ai",$h)}s(Nr,"fileLogPath");function lu(e){try{let t=JSON.parse(Bt(ds(xt(e,".ev-ai","config.json"),"utf8")));return It(t)?t:void 0}catch{return}}s(lu,"readHomeConfig");function Zh(e){return e?.debug===!0}s(Zh,"debugFromHomeConfig");function gs(e,t=!1){return e.includes("--debug")||t}s(gs,"isHookDebugEnabled");function It(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(It,"isRecord");function Qh(e,t){let n=e?.log_until;if(typeof n!="string")return;let r=[];if(n===Yt)return{on:!0,source:"local_config",scopes:r,localUntil:n};if(n===Gh)return{on:!1,source:"local_config",scopes:r,localUntil:n};let o=Date.parse(n);return Number.isNaN(o)?void 0:{on:o>t,source:"local_config",scopes:r,localUntil:n}}s(Qh,"localRunLog");function eS(e){if(!It(e)||!It(e.config))return;let t=e.config.log_until;if(typeof t!="string")return;if(t===Yt)return{until:t,untilMs:Number.POSITIVE_INFINITY};let n=Date.parse(t);return Number.isNaN(n)?void 0:{until:t,untilMs:n}}s(eS,"scopeUntilMs");function fu(e=lt(),t=process.env,n=Date.now()){return du(e,()=>lu(e),t,n)}s(fu,"readRunLogSwitch");function du(e,t,n,r){let o=n[Kh]?.trim().toLowerCase();if(o&&Ct.has(o))return{on:!0,source:"env",scopes:[]};if(o&&pr.has(o))return{on:!1,source:"env",scopes:[]};let i=Qh(t(),r);if(i)return i;let c=[];try{let a=xt(e,".ev-ai","agent-hook","hook-config.json"),u=wn(a);if(!u.isFile()||u.size>Wh)return{on:!1,source:"remote",scopes:c};let f=JSON.parse(ds(a,"utf8"));if(It(f))for(let[l,p]of Object.entries(f)){let d=eS(p);d&&d.untilMs>r&&c.push({scopeId:l,...d})}}catch{}return{on:c.length>0,source:"remote",scopes:c}}s(du,"runLogSwitch");function pu(e=lt()){return xt(e,".ev-ai","agent-hook",Jh)}s(pu,"runLogWindowsPath");function _s(e=lt()){try{let t=pu(e),n=wn(t);if(!n.isFile()||n.size>Yh)return{};let r=JSON.parse(ds(t,"utf8")),o={};if(It(r))for(let[i,c]of Object.entries(r))typeof c=="string"&&(o[i]=c);return o}catch{return{}}}s(_s,"readRunLogWindows");function hs(e,t=lt()){try{let n=_s(t),r={...n};if(e(r),JSON.stringify(r)===JSON.stringify(n))return;ae(pu(t),`${JSON.stringify(r,null,2)}
17
- `)}catch{}}s(hs,"updateRunLogWindows");function tS(e,t){hs(n=>{for(let r of t)n[r.scopeId]=r.until},e)}s(tS,"recordRunLogWindows");function nS(e){return e.replace(/[\r\n]/g," ")}s(nS,"oneLine");function rS(e){try{if(wn(e).size<cu)return;let t=`${e}.${process.pid}`;su(e,t);try{su(t,wn(t).size>=cu?`${e}.1`:e)}catch{uu(t)}}catch{}}s(rS,"rotateIfFull");var oS=/\bhttps?:\/\/[^\s'"<>`]+/gi;function sS(e){try{let t=new URL(e);return`${t.protocol}//${t.host}${t.pathname.replace(/\/[^/]+\/hook(?![\w-])/,"/***/hook")}`}catch{return"<url>"}}s(sS,"redactUrl");function iS(e,t=lt()){let n=e.replace(oS,sS);return t.length>1?n.replaceAll(t,"~"):n}s(iS,"scrubForLog");function cS(e,t){try{Hh(fs(e),{recursive:!0}),rS(e),Uh(e,t,{encoding:"utf8",mode:384})}catch{}}s(cS,"appendLine");function mu(e=process.argv,t=Nr(),n,r){uS();let o=lt(),i,c=!1,a=s(()=>(c||(i=lu(o),c=!0),i),"readOnce"),u=gs(e,n??Zh(a())),f=u||r!==void 0?void 0:du(o,a,process.env,Date.now());if(!u&&!(r??f?.on)){ke=ft;return}f?.source==="remote"&&tS(o,f.scopes);let l=s((p,d)=>{cS(t,`${new Date().toISOString()} ${p} ${iS(nS(d),o)}
18
- `)},"write");ke={info(p){l("info",p)},error(p){l("error",p)}}}s(mu,"initFileLogger");function gu(){return ke!==ft}s(gu,"fileLoggerActive");var re={info(e){ke.info(e)},error(e){ke.error(e)}},aS=new Set(["post_failed","timeout"]),le={},Ss=!1;function uS(){le={},Ss=!1}s(uS,"resetRunState");function _u(){return Ss}s(_u,"runLineWritten");function te(e){if(ke===ft)return;if(e.outcome===void 0){le={...le,...e};return}if(le.outcome!==void 0&&aS.has(le.outcome)){le.err===void 0&&e.err!==void 0&&(le={...le,err:e.err});return}let{runner:t,event:n,session:r,tool:o,ackMs:i}=le;le={runner:t,event:n,session:r,tool:o,ackMs:i,...e}}s(te,"noteRun");function dt(e){let t=It(e)?e.cause:void 0;for(let n of[t,e])if(It(n)&&typeof n.code=="string"&&n.code!=="")return n.code;return e instanceof Error?e.name:typeof e}s(dt,"runErrorKind");var lS=4096;function fS(e){return(e.stack??"").split(`
19
- `).map(t=>t.trim()).filter(t=>t.startsWith("at ")).join(" | ")}s(fS,"stackFrames");function Nn(e){try{return dS(e).join(" ").slice(0,lS)}catch{return"err=unknown message=(unprintable)"}}s(Nn,"errorDetail");function dS(e){let t=[`err=${dt(e)}`];if(!(e instanceof Error))return t.push(`message=${String(e)}`),t;t.push(`message=${e.message}`);let n=fS(e);n&&t.push(`stack=${n}`);let r=e.cause;for(let o=0;r!==void 0&&o<3;o+=1)t.push(r instanceof Error?`cause=${pS(r)}`:`cause=${String(r)}`),r=r instanceof Error?r.cause:void 0;return t}s(dS,"errorParts");function pS(e){if(e instanceof AggregateError&&e.errors.length>0){let t=e.errors.map(n=>n instanceof Error?n.message:String(n));return`${e.name}: ${t.join("; ")}`}return`${e.name}: ${e.message}`}s(pS,"causeText");function L(e,t,n=process.env){if(ke===ft)return;let r=n[In],o=r!==void 0&&ms.test(r)?` run=${r}`:"";ke.error(`failed where=${e}${o} ${Nn(t)}`)}s(L,"logFailure");function mS(){let e="";for(let t of vh(8))e+=au[t%au.length];return e}s(mS,"newRunId");function hu(e=process.env){if(ke===ft)return;let t=e[In];if(t!==void 0&&ms.test(t))return t;let n=mS();return e[In]=n,n}s(hu,"ensureRunId");function gS(e){if(typeof e=="number")return Number.isInteger(e)?String(e):e.toFixed(1);let t=e.replace(Xh,"_").slice(0,qh);return t===""?"_":t}s(gS,"runValue");function Xt(e,t,n,r=process.env){if(ke===ft)return;Ss=!0;let o=r[In],c=[["run",o!==void 0&&ms.test(o)?o:void 0],["p",e],["start",new Date(performance.timeOrigin).toISOString()],["v",t],["runner",le.runner],["event",le.event],["tool",le.tool],["session",le.session],["outcome",le.outcome??n],["ms",performance.now()],["ack_ms",le.ackMs],["post_ms",le.postMs],["http",le.http],["err",le.err]].filter(a=>a[1]!==void 0&&a[1]!=="").map(([a,u])=>`${a}=${gS(u)}`);ke.info(`run ${c.join(" ")}`)}s(Xt,"writeRunLine");function wr(e,t){try{t-wn(e).mtimeMs>zh&&uu(e)}catch{}}s(wr,"unlinkIfStale");function Su(e=Date.now(),t=lt(),n=_S()){if(ke!==ft)return;let r=Nr(t);wr(r,e),wr(`${r}.1`,e);try{for(let o of Dh(fs(r)))(jh.test(o)||Bh.test(o))&&wr(xt(fs(r),o),e)}catch{}wr(n,e)}s(Su,"purgeStaleLog");function _S(e=process.platform){return e==="win32"?xt(Fh(),iu):xt("/tmp",iu)}s(_S,"legacyLogPath");var yS="/run/cursor/api.sock",RS="owner/user-email",CS="owner/user-id",AS=400,Eu=25,bS=4096,OS="cursor-cloud-owner.json",kS="cursor-cloud-owner.miss.json",xS=1440*60*1e3,IS=600*1e3,TS=3600*1e3,wS=60*1e3,NS="/proc/sys/kernel/random/boot_id",PS=new Set([429,500,502,503,504]),MS=new Set(["ENOENT","ECONNREFUSED","EAGAIN"]);function LS(e=process.env){let t=e.CURSOR_AGENT_SOCKET?.trim();return t&&t.length>0?t:yS}s(LS,"cursorAgentSocketPath");function vS(e){return xu(e,".ev-ai","agent-hook",OS)}s(vS,"cursorCloudOwnerCachePath");function US(e){return xu(e,".ev-ai","agent-hook",kS)}s(US,"cursorCloudOwnerMissCachePath");function HS(e){let t=e.trim();if(t.length===0)return null;if(t.startsWith("{")||t.startsWith('"'))try{let n=JSON.parse(t);if(typeof n=="string")return Mr(n);if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let r=n.value;return typeof r=="string"?Mr(r):null}}catch{}return t}s(HS,"parseCursorMetadataBody");function Mr(e){let t=e.trim();return t.length>0?t:null}s(Mr,"nonEmpty");function DS(e){let t=Array.isArray(e)?e[0]:e;if(t===void 0)return null;let n=Number(t.trim());return Number.isFinite(n)&&n>=0?n*1e3:null}s(DS,"retryAfterMs");function FS(e,t,n){return new Promise(r=>{let o=!1,i=s(u=>{o||(o=!0,clearTimeout(a),r(u))},"finish"),c=ES.request({socketPath:e,host:"cursor-agent",path:`/v1/meta-data/${t}`,method:"GET",agent:!1},u=>{let f=[],l=0;u.on("data",p=>{if(l+=p.length,l>bS){c.destroy(),i({ok:!1,retryable:!1});return}f.push(p)}),u.on("end",()=>{i({ok:!0,response:{status:u.statusCode??0,body:Buffer.concat(f).toString("utf8"),retryAfterMs:DS(u.headers["retry-after"])}})}),u.on("error",()=>i({ok:!1,retryable:!1}))}),a=setTimeout(()=>{c.destroy(),i({ok:!1,retryable:!1})},n);c.on("error",u=>{i({ok:!1,retryable:MS.has(u.code??"")})}),c.end()})}s(FS,"requestOnce");function $S(e){if(e.status===200){let t=HS(e.body);return t?{kind:"value",value:t}:{kind:"not_found"}}return e.status===404?{kind:"not_found"}:e.status===403?{kind:"forbidden"}:PS.has(e.status)?"retry":{kind:"error"}}s($S,"classify");function jS(e){return new Promise(t=>setTimeout(t,e))}s(jS,"delay");async function yu(e,t,n){let r=n-Date.now();if(r<=0)return{kind:"error"};let o=await FS(e,t,r);if(!o.ok)return o.retryable?{kind:"retry",waitMs:Eu}:{kind:"error"};let i=$S(o.response);return i==="retry"?{kind:"retry",waitMs:o.response.retryAfterMs??Eu}:i}s(yu,"attemptKey");async function Ru(e,t,n){let r=await yu(e,t,n);if(r.kind!=="retry")return r;if(Date.now()+r.waitMs>=n)return{kind:"error"};await jS(r.waitMs);let o=await yu(e,t,n);return o.kind==="retry"?{kind:"error"}:o}s(Ru,"fetchCursorMetadataKey");async function BS(e,t=AS){let n=Date.now()+t,[r,o]=await Promise.all([Ru(e,RS,n),Ru(e,CS,n)]);if(r.kind==="forbidden"||o.kind==="forbidden")return{status:"forbidden",owner:null};if(r.kind==="error"||o.kind==="error")return{status:"error",owner:null};let i={userEmail:r.kind==="value"?r.value:null,userId:o.kind==="value"?o.value:null};return!i.userEmail&&!i.userId?{status:"empty",owner:null}:{status:"ok",owner:i}}s(BS,"fetchCursorCloudOwner");function Pr(e){return typeof e=="string"?Mr(e):null}s(Pr,"nullableString");var KS=new Set(["empty","forbidden","error"]);function Iu(e){let t;try{t=JSON.parse(ku(e,"utf8"))}catch{return}if(!(t===null||typeof t!="object"||Array.isArray(t)))return t}s(Iu,"readJsonRecord");function Tu(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}s(Tu,"finiteNumber");function Cu(e){let t=Iu(e),n=Tu(t?.checked_at_ms);if(!t||n===void 0)return;let r={checked_at_ms:n,boot_id:Pr(t.boot_id),user_email:Pr(t.user_email),user_id:Pr(t.user_id)};return r.user_email??r.user_id?r:void 0}s(Cu,"readCursorCloudOwnerCache");function GS(e){let t=Iu(e),n=Tu(t?.checked_at_ms),r=t?.status;if(!(!t||n===void 0)&&!(typeof r!="string"||!KS.has(r)))return{checked_at_ms:n,boot_id:Pr(t.boot_id),status:r}}s(GS,"readCursorCloudOwnerMissCache");function Au(e,t){try{ae(e,`${JSON.stringify(t)}
20
- `)}catch(n){let r=n instanceof Error?n.message:String(n);T(`WARN: cursor cloud owner cache write failed open: ${r}`),L("cursor_cloud_owner_cache",n)}}s(Au,"writeCacheFile");function VS(e){try{SS(e)}catch{}}s(VS,"removeCacheFile");function zS(e){switch(e){case"empty":return IS;case"forbidden":return TS;default:return wS}}s(zS,"missTtl");function wu(e,t,n){let r=t-e;return r>=0&&r<n}s(wu,"ageWithin");function bu(e,t,n){return e?.boot_id!==t||!e?null:{owner:{userEmail:e.user_email,userId:e.user_id},fresh:t!==null||wu(e.checked_at_ms,n,xS)}}s(bu,"sameBootOwner");function WS(e,t,n){return e?.boot_id!==t||!e?!1:wu(e.checked_at_ms,n,zS(e.status))}s(WS,"isCursorCloudOwnerMissFresh");function JS(){try{return Mr(ku(NS,"utf8"))}catch{return null}}s(JS,"readLinuxBootId");var Ou=new Map;function Lr(e){let t=e.env??process.env,n=LS(t),r=`${e.home}\0${n}`,o=Ou.get(r);if(o)return o;let i=YS(n,e).catch(c=>(L("cursor_cloud_owner",c),null));return Ou.set(r,i),i}s(Lr,"resolveCursorCloudOwner");async function YS(e,t){let n=vS(t.home),r=US(t.home),o=t.nowMs??Date.now(),i=(t.readBootId??JS)(),c=bu(Cu(n),i,o);if(c?.fresh)return c.owner;if(WS(GS(r),i,o)||!hS(e))return c?.owner??null;let a=await BS(e,t.budgetMs);if(a.status==="ok"&&a.owner)return Au(n,{checked_at_ms:o,boot_id:i,user_email:a.owner.userEmail,user_id:a.owner.userId}),VS(r),a.owner;let u=bu(Cu(n),i,o);return u?u.owner:(Au(r,{checked_at_ms:o,boot_id:i,status:a.status==="ok"?"empty":a.status}),null)}s(YS,"resolveUncached");import{existsSync as gO,readFileSync as np,unlinkSync as _O}from"node:fs";import{homedir as Wi}from"node:os";import{join as un,resolve as hO}from"node:path";import{basename as cO,join as an}from"node:path";import{dirname as $u,resolve as Dr}from"node:path";import{existsSync as XS}from"node:fs";import{homedir as Mu}from"node:os";import{relative as Lu,resolve as De,sep as pt}from"node:path";var qS=["session_id","conversation_id","turn_id","generation_id","prompt.id","prompt_id","hook_event_name","event","source","status","stop_reason","reason","tool_name","tool","tool_use_id","skill_name","command_name","expansion_type","command_source","permission_mode","model","model_id","agent_id","agent_type","subagent_id","subagent_type","subagent_model","is_parallel_worker","effort","effort.level","duration_ms","duration","sandbox","failure_type","is_interrupt"],ZS=["prompt","tool_input","tool_response","last_assistant_message","command"],QS=new Set;function eE(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return QS}}s(eE,"excludedContentKeys");function As(e){let t=F("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?Ct.has(t.toLowerCase()):e?.collect_prompt===!0}s(As,"isPromptCaptureEnabled");function vr(e,t){let n=vu(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=F("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?Ct.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}s(vr,"promptCaptureSource");function vu(e){return F("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||gs(process.argv,e.debug===!0)||F("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}s(vu,"hookInputCaptureMode");function tE(e){let t={};for(let n of qS){let r=Je(e,n);r!==void 0&&(t[n]=r)}return t}s(tE,"allowlistedHookInput");function Ur(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=De(e),r=De(t),o=Lu(r,n);return!o||o==="."?".":o.startsWith(`..${pt}`)||o===".."||De(r,o)!==n?null:o.split(pt).join("/")}s(Ur,"cwdRelativeToGitRoot");function Uu(e,t){let n=Lu(De(t),De(e)).split(pt).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}s(Uu,"specDirRelativeToCwd");function Hu(e){return typeof e!="string"||e.length===0?null:De(e).split(pt).join("/")}s(Hu,"absoluteCwdForSend");function nE(){let e=F("CURSOR_PROJECT_DIR");if(!e)return null;let t=De(e);return XS(t)?t.split(pt).join("/"):null}s(nE,"cursorProjectDirAbs");function ys(e,t){return Ur(e,t)!==null}s(ys,"isPathInside");function rE(e,t){let n=De(t??Mu(),".cursor").split(pt).join("/");return ys(e,n)}s(rE,"isCursorUserHookLaunch");function oE(e,t,n){return t!==null&&ys(e,t)?!0:t!==null&&rE(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&ys(e,n.gitRoot)?!0:t===null}s(oE,"shouldKeepProcessCwd");function Du(e,t){let n=Hu(e.cwd);if(n!==null)return n;let r=De(process.cwd()).split(pt).join("/"),o=nE();return oE(r,o,t)?r:o??r}s(Du,"resolvedCwdForSend");function bs(e,t={}){return Du(e,t)}s(bs,"resolveLaunchCwd");function Os(e,t=Mu()){let n=De(t).split(pt).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}s(Os,"tildeHomeCwd");function Nu(e,t,n){let r=Hu(n.launchCwd)??Du(t,n);e.cwd=Os(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?Ur(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}s(Nu,"attachCwdFields");var Fu="\u2026[truncated]\u2026",Rs=Buffer.byteLength(Fu,"utf8"),sE=8;function Pn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Pn,"jsonByteLength");function Pu(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}s(Pu,"utf8Head");function iE(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(n.length-t).toString("utf8")}s(iE,"utf8Tail");function cE(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=Rs)return Pu(e,t);let r=t-Rs,o=Math.ceil(r/2),i=Math.floor(r/2);return`${Pu(e,o)}${Fu}${iE(e,i)}`}s(cE,"truncateHeadTail");function Cs(e,t,n){if(typeof e=="string"){n.push({path:t,value:e,bytes:Buffer.byteLength(e,"utf8")});return}if(Array.isArray(e)){e.forEach((r,o)=>{Cs(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||Cs(o,[...t,r],n)}s(Cs,"collectStrings");function aE(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){let c=t[i];if(c===void 0)return;r=(Array.isArray(r),r[c])}let o=t[t.length-1];if(!(o===void 0||r===null||typeof r!="object")){if(Array.isArray(r)){r[o]=n;return}r[o]=n}}s(aE,"setAtPath");var uE=256;function lE(e,t,n){let r=n,o=Math.max(n,e[0]?.bytes??n);for(;r<o;){let i=Math.ceil((r+o)/2),c=0;for(let a of e)a.bytes>i&&(c+=a.bytes-i);c>=t?r=i:o=i-1}return r}s(lE,"stringBudgetFor");function fE(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let i=Pn(e);if(i<=t)return;let c=[];Cs(e,[],c),c.sort((l,p)=>p.bytes-l.bytes);let a=c.filter(l=>l.bytes>n);if(a.length===0)return;let u=lE(a,i-t,n),f=Math.max(n,Math.min(u,r-1));if(f>=r)return;r=f;for(let l of a)l.bytes>r&&aE(e,l.path,cE(l.value,r))}}s(fE,"clampStringsToBudget");function dE(e,t){let n=Math.max(0,t-uE),r=Object.keys(e).filter(i=>!i.startsWith("_")).map(i=>({key:i,bytes:Pn(e[i])})).sort((i,c)=>c.bytes-i.bytes),o=[];for(let{key:i}of r){if(Pn(e)<=n)break;delete e[i],o.push(i)}o.length>0&&(e._dropped_keys=o.slice(0,10))}s(dE,"dropLargestKeys");function Es(e,t){let n=Pn(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,fE(r,t,Rs+sE),Pn(r)>t&&dE(r,t),r}s(Es,"fitWithinByteLimit");function pE(e,t,n){if(!(n.promptCapture??As()))return;let r=eE(n.runnerEvent);for(let o of ZS){if(r.has(o))continue;let i=t[o];i!==void 0&&(e[o]=i)}}s(pE,"attachContentFields");function Hr(e,t,n={}){let r=vu(t);if(r==="full"){let i={...e};return delete i.cwd,delete i.transcript_path,Nu(i,e,n),Es(i,cs)}let o=tE(e);return Nu(o,e,n),r==="content"?(pE(o,e,n),Es(o,cs)):Es(o,za)}s(Hr,"sanitizeHookInput");function mE(e){return typeof e=="string"&&e.length>0}s(mE,"hasOrigin");function ks(e){let t=Dr(e.home),n=Dr(e.launchCwd),r=e.gitRoot?Dr(e.gitRoot):null,o=new Set,i=[],c=null;e.inGitRepo&&mE(e.remote)&&r!==null&&r!==t&&(c=r,o.add(r)),n!==t&&!o.has(n)&&(i.push({scope:"cwd",dir:n}),o.add(n)),c!==null&&i.push({scope:"repo",dir:c});let a=null,u=r!==null&&Ur(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&u){let f=$u(r);for(;;){let l=Dr(f);if(l===t)break;let p=$u(l);if(p===l)break;if(e.hasProjectSpec(l)){i.push({scope:"parent",dir:l}),a=Uu(l,n);break}f=p}}return{anchors:i,parentRel:a}}s(ks,"resolveProjectAnchors");import{existsSync as Bu,readdirSync as hE,realpathSync as SE}from"node:fs";import{basename as EE,dirname as yE,relative as RE,resolve as CE,sep as AE}from"node:path";import{createHash as gE}from"node:crypto";import{resolve as _E}from"node:path";function X(e){return gE("sha256").update(e).digest("hex").slice(0,16)}s(X,"sha16");function xs(e){return X(_E(e))}s(xs,"dirScopeRef");function xe(e,t){return`${e}\0${t}`}s(xe,"componentKey");function Fr(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}s(Fr,"componentDeltaHash");function ju(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}s(ju,"parseComponentKey");function Mn(e){let n=[...e].sort((r,o)=>{let i=r.path.localeCompare(o.path);return i!==0?i:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
21
- `);return X(n)}s(Mn,"hashUserSpec");var Is=400,$r=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??ut}static{s(this,"UserSpecContext")}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=CE(t).split(AE).join("/");return Os(r,this.home)}let n=RE(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${X(yE(t))}/${EE(t)}`:n}claimFile(t){try{let n=SE(t);return this.seenRealpaths.has(n)?!1:(this.seenRealpaths.add(n),!0)}catch{return this.seenRealpaths.has(t)?!1:(this.seenRealpaths.add(t),!0)}}get atGlobalCap(){return this.truncated||this.components.length>=this.maxEntries}get pluginBudgetSpent(){return this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0}readEntries(t){if(!Bu(t))return[];try{return hE(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(Bu(t))return Q(t,n)}push(t){return this.components.length>=this.maxEntries?(this.truncated=!0,!1):this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0?!1:(this.pluginExpandRemaining!==void 0&&(this.pluginExpandRemaining-=1),this.components.push(t),!0)}withPluginExpandCap(t,n){let r=this.pluginExpandRemaining;this.pluginExpandRemaining=t;try{let o=n(),i=t-(this.pluginExpandRemaining??0);return{result:o,expanded:i}}finally{this.pluginExpandRemaining=r}}};import{existsSync as zs,readFileSync as zy,statSync as Wy}from"node:fs";import{basename as Ws,join as Nt,relative as Js}from"node:path";var Ql=He(Zl());var Gy=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],ef=Gy.map(e=>Ql.default.matcher(e,{dot:!0}));function Vy(e){return e===""?!1:ef.some(t=>t(`${e}/`))}s(Vy,"isExcludedDirPath");function tf(e,t){if(t==="")return!1;if(e==="")return Vy(t);let n=e.replace(/\/+$/,"");return ef.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}s(tf,"isExcludedDirBelow");var Ys=100*1024,Jy=4;function Yy(e){return e.length<=Ys?e:`${e.slice(0,Ys-1)}\u2026`}s(Yy,"truncateContentText");function Xy(e){try{let t=zy(e),n=t.toString("utf8");return{hash:X(t),length:t.length,text:Yy(n)}}catch{return null}}s(Xy,"readFileMeta");var nf={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function qy(e){return e in nf?nf[e]:"UNSPECIFIED"}s(qy,"triggerForKind");function Qt(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=Xy(t.absolutePath);if(!n)return!1;let r=t.name??Ws(t.absolutePath).replace(/\.(md|mdc|toml)$/i,""),o={kind:t.kind,name:r,path:e.componentPath(t.absolutePath),text:n.text,content_hash:n.hash,content_length:n.length,origin:t.origin,enabled:t.enabled},i=qy(t.kind);return i&&(o.trigger=i),t.attributes&&(o.attributes=t.attributes),e.push(o)}s(Qt,"addFile");function Zy(e,t,n,r){let o=Js(e,t).replace(/\\/g,"/"),i=!o||o.startsWith("..")?Ws(t):o;return r&&i.toLowerCase().endsWith(r)?Ws(i).slice(0,-r.length):n||i!==o?i.replace(/\.(md|mdc|toml)$/i,""):o}s(Zy,"nameFromWalkRoot");function Pt(e,t){let{dir:n,kind:r,origin:o,enabled:i,nested:c,extensions:a,skipDirs:u}=t;Xs(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:i,nested:c,extensions:a,skipDirs:u})}s(Pt,"walkComponentDir");function Xs(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:i,origin:c,enabled:a,nested:u,extensions:f,skipDirs:l}=t;if(!(o>Jy))for(let p of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(p.isDirectory()&&tf(n.replace(/\\/g,"/"),Js(n,Nt(r,p.name)).replace(/\\/g,"/"))||p.isDirectory()&&l?.includes(Nt(r,p.name)))continue;if(u){if(!p.isDirectory())continue;let h=Nt(r,p.name,u);if(zs(h)){let y=Js(n,Nt(r,p.name)).replace(/\\/g,"/");Qt(e,{absolutePath:h,kind:i,origin:c,enabled:a,name:y||p.name});continue}Xs(e,{walkRoot:n,currentDir:Nt(r,p.name),depth:o+1,kind:i,origin:c,enabled:a,nested:u,extensions:f,skipDirs:l});continue}if(p.isDirectory()){Xs(e,{walkRoot:n,currentDir:Nt(r,p.name),depth:o+1,kind:i,origin:c,enabled:a,nested:u,extensions:f,skipDirs:l});continue}if(!p.isFile()||!f)continue;let d=p.name.toLowerCase();if(!f.some(h=>d.endsWith(h)))continue;let m=Nt(r,p.name),g=f.find(h=>h.split(".").length>2&&d.endsWith(h));Qt(e,{absolutePath:m,kind:i,origin:c,enabled:a,name:Zy(n,m,!0,g)})}}s(Xs,"walkRecursive");function rf(e){for(let t of e)if(zs(t))try{if(Wy(t).size>0)return t}catch{continue}return e.find(t=>zs(t))}s(rf,"firstExistingFile");import{existsSync as sR}from"node:fs";import{homedir as cf}from"node:os";import{join as iR}from"node:path";import{existsSync as Qy,readdirSync as of}from"node:fs";import{homedir as Wr}from"node:os";import{join as Ee}from"node:path";function eR(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return Ee(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}s(eR,"claudeManagedSettingsDir");function tR(e=process.platform){let t=eR(e),n=[Ee(t,"managed-settings.json")],r=Ee(t,"managed-settings.d");try{if(!Qy(r))return n;let o=of(r).filter(i=>i.endsWith(".json")&&!i.startsWith(".")).sort().map(i=>Ee(r,i));n.push(...o)}catch{}return n}s(tR,"listClaudeManagedSettingsFiles");function Fn(e=process.platform,t=Wr()){return{serverManaged:Ee(t,".claude","remote-settings.json"),fileBased:tR(e)}}s(Fn,"claudeManagedSettingsSources");function nR(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return Ee(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}s(nR,"cursorEnterpriseSettingsDir");function rR(e=process.platform,t=Wr()){let n=[Ee(nR(e),"hooks.json")],r=Ee(t,".cursor","managed");try{for(let o of of(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(Ee(r,o.name,"hooks.json"))}catch{}return n}s(rR,"listCursorManagedSettingsFiles");function oR(e=process.platform,t=Wr()){let n=e==="win32"?Ee(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[Ee(n,"requirements.toml")];return e!=="win32"&&r.push(Ee(n,"managed_config.toml")),r.push(Ee(t,".codex","managed_config.toml"),Ee(n,"config.toml")),r}s(oR,"listCodexManagedSettingsFiles");function Jr(e,t=process.platform,n=Wr()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=Fn(t,n);return[r,...o]}case"cursor":return rR(t,n);default:return oR(t,n)}}s(Jr,"managedSettingsFiles");function af(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}s(af,"hookParsableSettings");var cR={claude:{shared:{skillRoots:[".claude/skills"],dirs:[{dir:".claude/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".claude/commands",kind:"COMMAND",extensions:[".md"]},{dir:".claude/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["CLAUDE.md"],["CLAUDE.local.md"],[".claude/CLAUDE.md"]],settings:[".claude/settings.json",".claude/settings.local.json",".claude/hooks.json"]},homeOnly:{mcpJson:[".claude.json"],plugins:"claude",managed:"claude"},projectOnly:{mcpJson:[".mcp.json","mcp.json"]}},cursor:{shared:{skillRoots:[".cursor/skills"],dirs:[{dir:".cursor/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".cursor/commands",kind:"COMMAND",extensions:[".md"]},{dir:".cursor/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["AGENTS.md"]],settings:[".cursor/hooks.json",".cursor/sandbox.json",".cursor/permissions.json"],mcpJson:[".cursor/mcp.json"]},homeOnly:{skillRoots:[".cursor/skills-cursor"],memory:[[".cursor/AGENTS.md"]],settings:[".cursor/cli-config.json"],plugins:"cursor",managed:"cursor"},projectOnly:{skillRoots:[".agents/skills"],settings:[".cursor/cli.json"]}},codex:{shared:{skillRoots:[".agents/skills",".codex/skills"],dirs:[{dir:".codex/agents",kind:"SUBAGENT",extensions:[".toml",".md"]},{dir:".codex/prompts",kind:"COMMAND",extensions:[".md"]},{dir:".codex/rules",kind:"RULE",extensions:[".md",".rules"]}],memory:[["AGENTS.override.md","AGENTS.md"]],settings:[".codex/hooks.json",".codex/config.toml"],mcpToml:[".codex/config.toml"]},homeOnly:{memory:[[".codex/AGENTS.override.md",".codex/AGENTS.md"]],managed:"codex"}},copilot:{shared:{skillRoots:[".claude/skills",".agents/skills"],dirs:[{dir:".github/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".github/prompts",kind:"COMMAND",extensions:[".prompt.md"]},{dir:".github/instructions",kind:"RULE",extensions:[".instructions.md"]},{dir:".copilot/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".copilot/instructions",kind:"RULE",extensions:[".instructions.md"]}],memory:[],settings:[]},homeOnly:{skillRoots:[".copilot/skills"],memory:[[".copilot/copilot-instructions.md"]],settings:[".copilot/config.json"],mcpJson:[".copilot/mcp-config.json"]},projectOnly:{skillRoots:[".github/skills"],memory:[[".github/copilot-instructions.md"],["AGENTS.md"],["CLAUDE.md"],[".claude/CLAUDE.md"]],settings:[".github/copilot/settings.json"],mcpJson:[".github/mcp.json",".vscode/mcp.json"]}}};function sf(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}s(sf,"concatOptional");function aR(e,t={}){let{shared:n}=e;return{skillRoots:[...n.skillRoots,...t.skillRoots??[]],dirs:n.dirs,memory:[...n.memory,...t.memory??[]],settings:[...n.settings,...t.settings??[]],mcpJson:sf(n.mcpJson,t.mcpJson),mcpToml:sf(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}s(aR,"layoutForScope");function uf(e){return Object.fromEntries(Object.entries(cR).map(([t,n])=>[t,aR(n,n[e])]))}s(uf,"layoutsForScope");var en=uf("homeOnly"),gt=uf("projectOnly");function uR(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}s(uR,"layoutRelativePaths");function lR(e,t){return uR(e).some(n=>sR(iR(t,n)))}s(lR,"layoutHasAnyEntry");function lf(e,t){for(let n of e)if(lR(n,t))return!0;return!1}s(lf,"anyLayoutHasAnyEntry");function mt(e){return[...new Set(e)]}s(mt,"uniqueRels");function _t(e){let t=[],n=[],r=[],o=[],i=[],c=[],a=[];for(let u of e){t.push(...u.skillRoots);for(let f of u.dirs)f.kind==="SUBAGENT"?n.push(f.dir):f.kind==="COMMAND"?r.push(f.dir):o.push(f.dir);i.push(...u.memory.flat()),c.push(...u.settings),a.push(...u.mcpJson??[],...u.mcpToml??[])}return{skills:mt(t),subagents:mt(n),commands:mt(r),rules:mt(o),memory:mt(i),settings:mt(c),mcp:mt(a)}}s(_t,"userScopePathsFromLayouts");function fR(e,t=cf(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...Jr(o.managed,n,t));return mt(r)}s(fR,"managedSettingsFromLayouts");var ht=_t(Object.values(en));function ff(e=cf(),t=process.platform){return fR(Object.values(en),e,t)}s(ff,"userScopeManagedSettings");import{existsSync as zb,readFileSync as Wb}from"node:fs";import{basename as Jb}from"node:path";function fe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(fe,"isRecord");var to=He(je(),1);var j="<omitted>",FC=["package_name","package_spec","package_version","package_version_source"],Df=100,Ff=120,rn=[{raw:"tools",attr:"tools"},{raw:"autoApprove",attr:"auto_approve"},{raw:"auto_approve",attr:"auto_approve"},{raw:"alwaysAllow",attr:"always_allow"},{raw:"always_allow",attr:"always_allow"},{raw:"enabledTools",attr:"enabled_tools"},{raw:"enabled_tools",attr:"enabled_tools"},{raw:"disabledTools",attr:"disabled_tools"},{raw:"disabled_tools",attr:"disabled_tools"}],$f=new Set(rn.map(e=>e.attr)),$C=["enabled","disabled"],jC=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],BC=new Set(["type","command","url","args","env","envVars","headers",...$C,...jC,...rn.map(e=>e.raw)]),KC=new Set(["transport","command_or_url","args","env_var_names","headers_present","auth","bearer_token_env_var","default_tools_approval_mode","env_http_header_names",...FC,...$f,...[...$f].map(e=>`${e}_truncated`)]);function jf(e,t){for(let n of t)BC.has(n)||KC.has(n)||(e[n]=j)}s(jf,"addOmittedKeys");var GC=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,VC=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,zC=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,WC=/^bearer(?:\s+|$)/i;function Mt(e){return zC.test(e)||WC.test(e)}s(Mt,"isSecretShapedValue");var Bf=/^(?:--headers?|-H)$/,Kf=/^\s*([A-Za-z0-9-]+)\s*:([\s\S]*)$/,JC=/auth|cookie|token|secret|key|passw|credential|session|signature/i,YC=/^(?:(?:bearer|basic|token)\s+)?\$(?:\{\w+\}|\w+)$/i;function si(e){return JC.test(e)}s(si,"isAuthHeaderName");function no(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}s(no,"asRecord");function Gf(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}s(Gf,"stringList");function ni(e){if(Array.isArray(e)){let n=[];for(let r of e){if(typeof r!="string"||r.length===0)continue;let o=r.split("=",1)[0]?.trim();o&&n.push(o)}return n}let t=no(e);return t?Object.keys(t).filter(n=>n.length>0):[]}s(ni,"envNamesFromValue");function nt(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}s(nt,"redactCommandOrUrl");function ii(e){return/[@\\]/.test(e)?j:(e.split(/[?#]/,1)[0]??"").trim()}s(ii,"redactUrlText");function XC(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,to.launchContainsCredentials)({kind:"url",url:e})||(0,to.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=Be([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,to.launchContainsCredentials)({kind:"url",url:r}):!0)}s(XC,"rawLaunchHadCredentials");function Vf(e,t,n){XC(t,n)&&(e.launch_had_credentials=!0)}s(Vf,"markLaunchCredentials");function qC(e){return Mt(e)?"<redacted>":e.includes("://")?nt(e):e}s(qC,"redactSecretShapedValue");function zf(e){let t=Kf.exec(e);if(!t)return ci(e);let n=t[1]??"",r=(t[2]??"").trim();return YC.test(r)?e:si(n)||Mt(r)?`${n}: <redacted>`:e}s(zf,"redactHeaderArg");function ci(e){if(/^https?:\/\//i.test(e))return nt(e);let t=e.indexOf("=");if(t>0){let n=e.slice(0,t),r=e.slice(t+1);return`${n}=${Bf.test(n)?zf(r):ci(r)}`}return qC(e)}s(ci,"redactArg");function ai(e){return GC.test(e)||VC.test(e)}s(ai,"isAuthKeyName");function ZC(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return ai(t)}s(ZC,"authArgKey");function Be(e){let t=[],n=!1,r=!1;for(let o of e){if(n){t.push("<redacted>"),n=!1;continue}if(r&&(r=!1,Kf.test(o))){t.push(zf(o));continue}if(Bf.test(o)){t.push(o),r=!0;continue}if(ZC(o)){t.push("<redacted>"),n=!o.includes("=");continue}t.push(ci(o))}return t}s(Be,"redactArgs");function QC(e){let t=Gf(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Ff?r.slice(0,Ff):r))].sort();if(n.length!==0)return n.length>Df?{names:n.slice(0,Df),truncated:!0}:{names:n,truncated:!1}}s(QC,"toolNameList");function eA(e){let t=no(e);if(!t)return{headers:[],envVars:[]};let n=[],r=[];for(let[o,i]of Object.entries(t))o.length>0&&n.push(o),typeof i=="string"&&i.length>0&&r.push(i);return{headers:n,envVars:r}}s(eA,"envHeaderNames");function Wf(e,t){let n=new Set;for(let{raw:r,attr:o}of rn){if(n.has(o)||!(r in t))continue;let i=t[r];if(o==="auto_approve"&&typeof i=="boolean"){e.auto_approve=i,n.add(o);continue}let c=QC(i);c&&(e[o]=c.names,c.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}s(Wf,"applyToolListAttributes");function Jf(e,t){let n=no(e),r={transport:t};if(!n)return r;jf(r,Object.keys(n));let o=typeof n.command=="string"?n.command:void 0,i=typeof n.url=="string"?n.url:void 0,c=typeof n.serverUrl=="string"?n.serverUrl:void 0,a=o??i??c,u=Gf(n.args);a&&(r.command_or_url=nt(a));let f=Be(u);f.length>0&&(r.args=f),Vf(r,a,u);let l=eA(n.env_http_headers),p=[...new Set([...ni(n.env),...ni(n.envVars),...ni(n.env_vars),...l.envVars,...typeof n.bearer_token_env_var=="string"&&n.bearer_token_env_var.length>0?[n.bearer_token_env_var]:[]])].sort();p.length>0&&(r.env_var_names=p),l.headers.length>0&&(r.env_http_header_names=[...new Set(l.headers)].sort());for(let h of["headers","http_headers","env_http_headers"])if(n[h]!==void 0&&n[h]!==null){r.headers_present=!0;break}let d=typeof n.auth=="string"?n.auth:void 0;d&&(r.auth=d);let m=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;m&&(r.bearer_token_env_var=m);let g=typeof n.default_tools_approval_mode=="string"?n.default_tools_approval_mode:typeof n.defaultToolsApprovalMode=="string"?n.defaultToolsApprovalMode:void 0;return g&&(r.default_tools_approval_mode=g),Wf(r,n),r}s(Jf,"sanitizeMcpServerAttributes");function Yf(e){let t=no(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}s(Yf,"mcpServerEnabledFromJson");function ui(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return X(JSON.stringify({name:e,attributes:r,enabled:n}))}s(ui,"hashSanitizedMcpAttributes");function nn(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}s(nn,"parseTomlQuoted");function Bn(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*\\[([^\\]]*)\\]`,"m").exec(e);return n?.[1]?[...n[1].matchAll(/"([^"]*)"|'([^']*)'/g)].map(r=>r[1]??r[2]??"").filter(r=>r.length>0):[]}s(Bn,"parseTomlPlainStringArray");function oi(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}s(oi,"parseTomlBoolean");function ri(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=nn(n[1]);return r.length>0?r:void 0}s(ri,"parseTomlScalarString");function tA(e,t){let n=[],r=s(c=>{for(let a of c.split(/[,\n]/)){let u=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(a);u?.[1]&&n.push([u[1],nn(u[2]??"")])}},"collect"),o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let i=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
22
- ${e}`);return i?.[1]&&r(i[1]),n}s(tA,"parseTomlMap");function Xf(e){return oi(e,"enabled")===!1?!1:oi(e,"disabled")!==!0}s(Xf,"mcpServerEnabledFromToml");function nA(e,t){let n={};for(let{raw:r,attr:o}of rn){if(o==="auto_approve"){let c=oi(t,r);if(c!==void 0){n[r]=c;continue}}let i=Bn(t,r);i.length>0&&(n[r]=i)}Wf(e,n)}s(nA,"applyToolListsFromToml");var rA=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,oA=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function sA(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
23
- `)){let i=rA.exec(o);i?.[1]&&t.add(i[1])}for(let o of e.matchAll(oA))o[1]&&t.add(o[1]);return[...t]}s(sA,"tomlDeclaredKeys");function qf(e,t){let n={transport:t};jf(n,sA(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),i=r?nn(r[1]??""):void 0,c=o?nn(o[1]??""):void 0,a=i!==void 0&&i.length>0?i:c,u=Bn(e,"args");a&&(n.command_or_url=nt(a));let f=Be(u);f.length>0&&(n.args=f),Vf(n,a,u);let l=new Set;for(let b of e.split(`
24
- `)){let w=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);w?.[1]&&l.add(w[1])}let p=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(p?.[1])for(let b of p[1].split(",")){let w=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);w?.[1]&&l.add(w[1])}let d=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
25
- ${e}`);if(d?.[1])for(let b of d[1].split(`
26
- `)){let w=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);w?.[1]&&l.add(w[1])}for(let b of Bn(e,"env_vars"))l.add(b);let m=tA(e,"env_http_headers");for(let[,b]of m)b.length>0&&l.add(b);let g=ri(e,"bearer_token_env_var");g&&(l.add(g),n.bearer_token_env_var=g),l.size>0&&(n.env_var_names=[...l].sort()),m.length>0&&(n.env_http_header_names=[...new Set(m.map(([b])=>b))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let h=ri(e,"auth");h&&(n.auth=h);let y=ri(e,"default_tools_approval_mode");return y&&(n.default_tools_approval_mode=y),nA(n,e),n}s(qf,"parseTomlMcpSection");var iA=300,cA=256;function Zf(e,t){if(!t)return e;let n=[...new Set([t,t.replace(/\\/g,"/")])].filter(o=>o.length>1),r=e;for(let o of n)r=r.split(o).join("~");return r}s(Zf,"rewriteHomePrefix");function Lt(e){let t=[],n="",r=null;for(let o of e){if(r){o===r?r=null:n+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(/\s/.test(o)){n.length>0&&(t.push(n),n="");continue}n+=o}return n.length>0&&t.push(n),t}s(Lt,"tokenizeCommand");function Qf(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}s(Qf,"capLength");function aA(e){return Qf(e,iA)}s(aA,"capCommand");function ed(e,t){let n=Zf(e.trim(),t),r=Lt(n);if(r.length===0)return"";let[o,...i]=r,c=nt(o),a=Be(i);return aA([c,...a].join(" "))}s(ed,"sanitizeHookCommand");function td(e,t){if(typeof e!="string")return null;let n=Zf(e.trim(),t),r=Lt(n)[0];if(!r)return null;let o=nt(r);return o.length===0?null:Qf(o,cA)}s(td,"executableFromCommand");import{existsSync as pA}from"node:fs";var uA=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,li="<path>",lA=new RegExp(`${li}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function ro(e){let t=e.replace(uA,li).replace(lA,li);return t.length>200?`${t.slice(0,200)}...`:t}s(ro,"redactPermissionKey");function fA(e){if(e.prompt||e.type==="prompt")return"prompt";let t=e.command??e.bash??e.powershell??"";return/\bnpx\b/i.test(t)?"npx":/\.(sh|bash|zsh|js|mjs|cjs|ts|py)(\s|$|"|')/i.test(t)||/^(\.\/|~\/|\/|[A-Za-z]:[\\/])/.test(t.trim())?"script":"inline"}s(fA,"classifyActionKind");function dA(e){return Array.isArray(e.hooks)&&e.hooks.length>0?e.hooks:[{type:e.type,command:e.command,bash:e.bash,powershell:e.powershell,prompt:e.prompt}]}s(dA,"normalizeHookActions");function fi(e,t,n,r){let o=e.componentPath(t);for(let[i,c]of Object.entries(n))if(!(!Array.isArray(c)||e.truncated))for(let a of c){if(!a||typeof a!="object"||e.truncated)continue;let u=a;for(let f of dA(u)){if(e.truncated)return;let l=f.command??f.bash??f.prompt??f.powershell??u.powershell??"",p=fA({type:f.type??u.type,command:f.command??u.command,bash:f.bash??u.bash,powershell:f.powershell??u.powershell,prompt:f.prompt??u.prompt}),d=typeof u.matcher=="string"?u.matcher:"",m=X(l),g=d?`${i}:${d}:${p}:${m}`:`${i}:${p}:${m}`,h=`${i}|${d}|${p}|${l}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:X(h),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:i,...d?{matcher:d}:{},action_kind:p,action_hash:m,...p!=="prompt"&&l.trim()?{command:ed(l,e.home)}:{}}})}}}s(fi,"collectHooksFromObject");function di(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||fi(e,t,r.hooks,n)}s(di,"collectHooksFile");var nd=200,rd=200,pi=16*1024,od=6,mA=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","allowedMcpServers","deniedMcpServers","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),gA=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),_A=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),hA=new Set(["permissions","approvalMode"]),SA={claude:mA,cursor_sandbox:gA,cursor_permissions:_A,cursor_cli:hA},EA=new Set(["allow","deny","ask"]),yA=new Set(["allowedMcpServers","deniedMcpServers"]);function rt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(rt,"isRecord");function oo(e){return e.replace(/\\/g,"/")}s(oo,"posixPath");function mi(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>mi(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${mi(t[r])}`).join(",")}}`}s(mi,"canonicalJson");function RA(e){return X(`${mi(e)}|settings1`)}s(RA,"hashSettingsAttributes");function ud(e){let t=oo(e);if(t.endsWith(".claude/settings.json")||t.endsWith(".claude/settings.local.json"))return"claude";if(t.endsWith(".cursor/sandbox.json"))return"cursor_sandbox";if(t.endsWith(".cursor/permissions.json"))return"cursor_permissions";if(t.endsWith(".cursor/cli-config.json")||t.endsWith(".cursor/cli.json"))return"cursor_cli"}s(ud,"settingsProfileFor");function ld(e,t){if(e!=="claude")return{};let n=oo(t);return n.endsWith("/.claude/remote-settings.json")?{profile:"claude",managedSource:"server"}:n.includes("/managed-settings.d/")&&n.endsWith(".json")?{profile:"claude",managedSource:"file_dropin"}:n.endsWith("/managed-settings.json")?{profile:"claude",managedSource:"file"}:{profile:"claude"}}s(ld,"managedSettingsMeta");function fd(e){let t=oo(e).replace(/\/+$/,"");return t.length<=1?"":t}s(fd,"homePosix");function dd(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}s(dd,"isWindowsHome");function hi(e,t){let n=oo(e);if(n==="~"||n.startsWith("~/"))return n;let r=fd(t);if(!r)return n;let o=n.slice(0,r.length);if(!(dd(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let c=n.slice(r.length);return c===""?"~":c.startsWith("/")?`~${c}`:n}s(hi,"tildePath");var sd=new Map;function CA(e){let t=sd.get(e);if(t!==void 0)return t;let n=fd(e),r=null;if(n){let o=n.split("/").map(i=>i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,dd(e)?"gi":"g")}return sd.set(e,r),r}s(CA,"homeTextPattern");function Si(e,t){let n=CA(t);return n?e.replace(n,"~"):e}s(Si,"tildeHomeInText");function id(e,t){return e.length<=rd?e:(t.truncated=!0,e.slice(0,rd))}s(id,"capString");function Ei(e,t){return e.length<=nd?e:(t.truncated=!0,e.slice(0,nd))}s(Ei,"capArray");function ce(e,t,n,r){if(typeof e=="string"){if(t==="path")return id(hi(e,n),r);let o=t==="rule"?ro(e):e;return id(Si(o,n),r)}if(typeof e=="number"||typeof e=="boolean"||e===null)return typeof e=="number"&&!Number.isFinite(e)?void 0:e;if(Array.isArray(e)){let o=Ei(e,r),i=[];for(let c of o){let a=ce(c,t,n,r);a!==void 0&&i.push(a)}return i}if(rt(e)){let o={};for(let[i,c]of Object.entries(e)){let a=ce(c,t,n,r);a!==void 0&&(o[i]=a)}return o}}s(ce,"transformValue");function cd(e,t,n){if(!rt(e))return ce(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let c="plain";EA.has(o)?c="rule":o==="additionalDirectories"&&(c="path");let a=ce(i,c,t,n);a!==void 0&&(r[o]=a)}return r}s(cd,"transformPermissions");function AA(e,t,n){if(!rt(e))return ce(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){if(o==="files"&&Array.isArray(i)){let a=Ei(i,n);r[o]=a.map(u=>{if(!rt(u))return ce(u,"plain",t,n);let f={};for(let[l,p]of Object.entries(u)){let m=ce(p,l==="path"?"path":"plain",t,n);m!==void 0&&(f[l]=m)}return f});continue}let c=ce(i,"plain",t,n);c!==void 0&&(r[o]=c)}return r}s(AA,"transformCredentials");function bA(e,t,n){if(!rt(e))return ce(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a=ce(i,o==="allowUnixSockets"?"path":"plain",t,n);a!==void 0&&(r[o]=a)}return r}s(bA,"transformNetwork");function OA(e,t,n){if(!rt(e))return ce(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let c;o==="excludedCommands"?c=ce(i,"rule",t,n):o==="filesystem"?c=ce(i,"path",t,n):o==="network"?c=bA(i,t,n):o==="credentials"?c=AA(i,t,n):c=ce(i,"plain",t,n),c!==void 0&&(r[o]=c)}return r}s(OA,"transformSandbox");var kA=/[a-z][a-z0-9+.-]+:[\\/]/i;function xA(e){let[t,...n]=e.filter(r=>typeof r=="string"&&r.length>0);return t===void 0?[]:[t,...Be(n)].map(r=>kA.test(r)?ii(r):r)}s(xA,"redactServerCommand");function IA(e){if(!rt(e))return j;let t={};for(let[n,r]of Object.entries(e))n==="serverName"&&typeof r=="string"?t[n]=r:n==="serverUrl"&&typeof r=="string"?t[n]=ii(r):n==="serverCommand"&&Array.isArray(r)?t[n]=xA(r):t[n]=j;return t}s(IA,"sanitizeMcpServerMatcher");function TA(e,t,n){if(!Array.isArray(e))return j;let r=Ei(e,n).map(IA);return ce(r,"plain",t,n)}s(TA,"transformMcpServerMatchers");function wA(e,t,n,r,o){return n==="claude"?e==="permissions"?cd(t,r,o):e==="sandbox"?OA(t,r,o):yA.has(e)?TA(t,r,o):ce(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?ce(t,"path",r,o):ce(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?ce(t,"rule",r,o):ce(t,"plain",r,o):e==="permissions"?cd(t,r,o):ce(t,"plain",r,o)}s(wA,"transformByProfile");function Kn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Kn,"jsonBytes");function gi(e,t){return e?`${e}.${t}`:t}s(gi,"childPath");function _i(e,t,n,r){if(Array.isArray(e)){for(let o=e.length-1;o>=0;o-=1){let i=e[o];i!==null&&typeof i=="object"&&(t+1>=od?(e.splice(o,1),r.add(n)):_i(i,t+1,n,r))}return}if(!(e===null||typeof e!="object"))for(let[o,i]of Object.entries(e))i!==null&&typeof i=="object"&&(t+1>=od?(delete e[o],r.add(gi(n,o))):_i(i,t+1,gi(n,o),r))}s(_i,"pruneDepth");function pd(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:Kn(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))pd(o,gi(t,r),n)}s(pd,"collectTrimCandidates");function NA(e,t,n){let r=Kn(e);if(r<=pi)return;t.truncated=!0;let o=[];for(pd(e,"",o);r>pi;){let i;for(let u of o)u.items.length>0&&(!i||u.bytes>i.bytes)&&(i=u);if(!i)break;let c=i.items.pop(),a=Kn(c)+(i.items.length>0?1:0);i.bytes-=a,r-=a,n.add(i.path)}for(;Kn(e)>pi;){let i,c=-1;for(let[a,u]of Object.entries(e)){let f=Kn(u);f>c&&(i=a,c=f)}if(i===void 0)break;delete e[i],n.add(i)}}s(NA,"fitSettingsJson");function PA(e,t,n){let r=SA[t],o={truncated:!1},i={},c=[];for(let u of Object.keys(e)){if(!r.has(u)){c.push(u);continue}let f=wA(u,e[u],t,n,o);f!==void 0&&(i[u]=f)}c.sort();let a=new Set;return _i(i,1,"",a),a.size>0&&(o.truncated=!0),NA(i,o,a),{settings:i,keys_omitted:c,truncated:o.truncated,trimmed_paths:[...a].sort()}}s(PA,"extractSettingsPosture");function ad(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:RA(t.attributes),attributes:t.attributes};e.push(n)}s(ad,"pushPostureRow");function yi(e,t,n,r){if(!e.claimFile(t)||!pA(t))return;let o=na(t);if(!o.ok||!rt(o.value)){if(r.profile){let f=!o.ok&&o.reason==="read"?"read_error":"parse_error",l={profile:r.profile,[f]:!0};r.managedSource&&(l.managed_source=r.managedSource),ad(e,{kind:r.kind,absPath:t,origin:n,attributes:l})}return}let i=o.value,c=i.hooks;if(rt(c)&&fi(e,t,c,n),!r.profile)return;let a=PA(i,r.profile,e.home),u={profile:r.profile,settings:a.settings,keys_omitted:a.keys_omitted};a.truncated&&(u.truncated=!0),a.trimmed_paths.length>0&&(u.trimmed_paths=a.trimmed_paths),r.managedSource&&(u.managed_source=r.managedSource),ad(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}s(yi,"collectSettingsFile");var de="<redacted>",MA=new Set(["stdio","http","sse","ws","sdk","streamable-http","streamableHttp","local","remote"]),LA={CLIENT_ID:"keep",CLIENT_SECRET:"secret",scopes:"string_list",redirectPort:"keep"},vA={clientId:"keep",client_id:"keep",clientSecret:"secret",client_secret:"secret",callbackPort:"keep",callback_port:"keep",callback_url:"url",redirectUri:"url",redirect_uri:"url",authServerMetadataUrl:"url",auth_server_metadata_url:"url",authorizationUrl:"url",tokenUrl:"url",issuer:"url",registrationUrl:"url",clientMetadataUrl:"url",scopes:{by:{string:"keep",array:"string_list"}},scope:"keep",oauthScopes:"string_list",audiences:"string_list",enabled:"keep",allowPrivateNetwork:"keep",authorizationResponseIssParameterSupported:"keep",tokenParamName:"keep"},Sd={filesystem:{object:{allowWrite:"path",denyRead:"path",denyWrite:"path"}},network:{object:{allowedDomains:"string_list",deniedDomains:"string_list"}}},UA={watch:"path",debug:{object:{type:"keep",debugpyPath:"path"}}},HA={headers:"secret_map",proxy:"url",caBundlePath:"path",timeout:"keep",verifySsl:"keep",noProxy:"string_list",extraBodyProperties:"omit",clientCertificate:{object:{cert:"omit",key:"omit",passphrase:"secret"}}},DA={startup:"keep",catalog:"keep",execution:"keep"},FA={approval_mode:"keep",output_token_limit:"keep"},$A={id:"keep",type:"keep",password:"keep",command:"keep",serverName:"keep",description:"omit",options:"omit",args:"omit",default:"secret"},jA={type:"transport_type",command:"command",args:"args",cwd:"path",env:"secret_map",url:"url",headers:"secret_map"},BA=Object.fromEntries(rn.map(({raw:e})=>[e,"tool_list"])),KA={...BA,type:"transport_type",transportType:"keep",transport:{by:{string:"keep",object:{object:jA}}},disabled:"keep",enabled:"keep",required:"keep",remote:"keep",remoteConfigured:"keep",source:"keep",version:"keep",gallery:{by:{boolean:"keep",string:"url"}},description:"omit",name:"keep",serverName:"keep",faviconUrl:"url",sourceFile:"path",sourceSlug:"keep",environment_id:"keep",protocol:"keep",pool:"keep",codemode:"keep",trust:"keep",alwaysLoad:"keep",deferTools:"keep",supports_parallel_tool_calls:"keep",tool_input_schema_max_bytes:"keep",startup_readiness:"keep",extension:"omit",metadata:"omit",settings:"omit",command:{by:{string:"command",array:"args",object:{object:{path:"command",args:"args",env:"secret_map"}}}},args:"args",env:"secret_map",environment:"secret_map",env_vars:{list:{by:{string:"env_name",object:{object:{name:"env_name",source:"keep"}}}}},envVars:"secret_map",envFile:"path",cwd:"path",watchPaths:"path",dev:{object:UA},sandboxEnabled:"keep",sandbox:{object:Sd},url:"url",serverUrl:"url",httpUrl:"url",tcp:"url",headers:"secret_map",http_headers:"secret_map",env_http_headers:"env_name_map",bearer_token_env_var:"env_name",headersHelper:"helper_command",http_headers_helper:"helper_command",apiKey:"secret",requestOptions:{object:HA},auth:{by:{string:"mode",object:{object:LA}}},oauth:{by:{boolean:"keep",object:{object:vA}}},oauthClientId:"keep",oauthClientSecret:"secret",oauthResource:"url",oauth_resource:"url",oauthScopes:"string_list",scopes:{by:{string:"keep",array:"string_list"}},oauthPublicClient:"keep",oauthGrantType:"keep",authProviderType:"keep",targetAudience:"keep",targetServiceAccount:"keep",tools:{by:{array:"tool_list",boolean:"tool_list",string:"tool_list",object:{map:{object:FA}}}},includeTools:"tool_list",excludeTools:"tool_list",omit_tools_from:"tool_list",default_tools_approval_mode:"keep",defaultToolsApprovalMode:"keep",timeout:{by:{number:"keep",object:{object:DA}}},startup_timeout_sec:"keep",startup_timeout_ms:"keep",tool_timeout_sec:"keep",connectionTimeout:"keep"};function GA(e){if(e===null)return"null";if(Array.isArray(e))return"array";switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":return"object";default:return}}s(GA,"shapeOf");var VA=/^[A-Za-z_][A-Za-z0-9_]*$/,zA=[/\$\{(?:env|input|command):[A-Za-z0-9_.-]+\}/y,/\$\{file:[^}\s]+\}/y,/\$\{\{\s*secrets\.[A-Za-z0-9_]+\s*\}\}/y,/\$\{\/\}/y,/\$\{[A-Za-z_][A-Za-z0-9_.]*\}/y,/\$[A-Z_][A-Z0-9_]*/y,/%[A-Z_][A-Z0-9_]*%/y,/\{(?:env:[A-Za-z_][A-Za-z0-9_]*|file:[^}\s]+)\}/y],Ri=/\$\{([A-Za-z_][A-Za-z0-9_]*):-[^}]*\}/y;function md(e){let t="",n=0;for(;n<e.length;){Ri.lastIndex=n;let r=Ri.exec(e);if(r){t+=`\${${r[1]??""}:-${de}}`,n=Ri.lastIndex;continue}let o=!1;for(let i of zA){i.lastIndex=n;let c=i.exec(e);if(c){t+=c[0],n=i.lastIndex,o=!0;break}}if(!o)return null}return t.length>0?t:null}s(md,"referencesOnly");function vt(e){let t=/^(bearer|basic|token)(\s+)(.+)$/i.exec(e);if(t){let n=md(t[3]??"");return n===null?null:`${t[1]??""}${t[2]??""}${n}`}return md(e)}s(vt,"sanitizeVariableReference");function Gn(e,t){return t.home?Si(e,t.home):e}s(Gn,"tildeText");function io(e){return Mt(e)||e.split(/[\s=,;:'"]+/).some(Mt)}s(io,"containsSecretShapedToken");function Ed(e,t){return io(e)?de:e.includes("://")?Cd(e,t):Gn(e,t)}s(Ed,"keepString");var WA=/^[A-Za-z][A-Za-z_-]{0,31}$/;function JA(e){return typeof e!="string"?j:WA.test(e)&&!Mt(e)?e:de}s(JA,"sanitizeMode");function YA(e,t){return typeof e=="string"?Ed(e,t):typeof e=="number"?Number.isFinite(e)?e:j:typeof e=="boolean"||e===null?e:j}s(YA,"keepScalar");function gd(e){return typeof e!="string"?j:/[\s=]/.test(e)||io(e)?de:e}s(gd,"toolName");function XA(e){return typeof e=="boolean"?e:typeof e=="string"?gd(e):Array.isArray(e)?e.map(t=>gd(t)):j}s(XA,"sanitizeToolList");function qA(e,t){return Array.isArray(e)?e.map(n=>typeof n=="string"?Ed(n,t):j):j}s(qA,"sanitizeStringList");function ZA(e){return si(e)||ai(e)}s(ZA,"isCredentialHeaderName");var Ci=/(^|[\s"'=,;])([A-Za-z][A-Za-z0-9_-]*)(\s*:\s*)/g;function yd(e){let t="",n=0;Ci.lastIndex=0;let r;for(;(r=Ci.exec(e))!==null;){let o=r[2]??"",i=r.index+r[0].length;if(!ZA(o))continue;let c=e.slice(i).search(/["'\n]/),a=c===-1?e.length:i+c,u=e.slice(i,a).trim();u.length!==0&&(t+=e.slice(n,i),t+=vt(u)??de,n=a,Ci.lastIndex=a)}return t+e.slice(n)}s(yd,"redactCredentialHeaders");var Rd=/\b(bearer|basic|token)(\s+)([^\s"']+)/gi;function QA(e){for(let t of e.matchAll(Rd))if(vt(t[3]??"")===null)return!0;return!1}s(QA,"hasLiteralAuthScheme");function eb(e){let t=yd(e);return QA(t)?de:t}s(eb,"redactCredentialArg");function tb(e){return yd(e).replace(Rd,(t,n,r,o)=>vt(o)===null?`${n}${r}${de}`:t)}s(tb,"redactCredentialCommandLine");function nb(e){return e.map(t=>/\s/.test(t)?t.includes('"')&&!t.includes("'")?`'${t}'`:`"${t}"`:t).join(" ")}s(nb,"joinCommandTokens");function bi(e,t){if(typeof e!="string")return j;let n=Lt(tb(e));return n.length===0?e:Gn(nb(Be(n)),t)}s(bi,"sanitizeCommand");function rb(e,t){if(typeof e=="string"){let n=vt(e);if(n!==null)return n;let r=Lt(e),[o]=r;if(o===void 0)return e;let i=bi(o,t);return r.length>1?`${String(i)} ${de}`:i}return Array.isArray(e)?e.map((n,r)=>r===0?bi(n,t):de):j}s(rb,"sanitizeHelperCommand");function ob(e,t){if(!Array.isArray(e))return j;let n=[],r=[];e.forEach((c,a)=>{typeof c=="string"&&(n.push(a),r.push(c))});let o=Be(r),i=e.map(()=>j);return n.forEach((c,a)=>{i[c]=Gn(eb(o[a]??de),t)}),i}s(ob,"sanitizeArgs");function sb(e){try{return new URL(e).href.length>0}catch{return!1}}s(sb,"canParseUrl");function Ai(e){return e.split("/").map(t=>io(t)?de:t).join("/")}s(Ai,"redactSecretPathSegments");function Cd(e,t){if(typeof e!="string")return j;let n=vt(e);if(n!==null)return n;if(/^(?:unix|pipe):/i.test(e)){let l=e.indexOf("#"),p=l===-1?e:e.slice(0,l),d=l===-1?"":e.slice(l),m=p.split("?",1)[0]??"";return Gn(Ai(`${m}${d}`),t)}if(/^(?:https?|wss?):/i.test(e)&&sb(e))return Ai(nt(e));let r=e.split(/[?#]/,1)[0]??"",o=/^[A-Za-z][A-Za-z0-9+.-]*:\/\//.exec(r)?.[0]??"",i=r.slice(o.length),c=i.indexOf("/"),u=(c===-1?i:i.slice(0,c)).lastIndexOf("@"),f=`${o}${u===-1?i:i.slice(u+1)}`;return Gn(Ai(f),t)}s(Cd,"sanitizeUrl");function Ad(e){return e===null?null:typeof e=="string"?vt(e)??de:de}s(Ad,"sanitizeSecret");function so(e){return typeof e!="string"?j:VA.test(e)&&!Mt(e)?e:de}s(so,"envName");function ib(e){if(Array.isArray(e))return e.map(n=>{if(typeof n!="string")return j;let r=n.indexOf("=");if(r===-1)return so(n);let o=n.slice(0,r);return so(o)!==o?de:`${o}=${vt(n.slice(r+1))??de}`});if(!fe(e))return j;let t={};for(let[n,r]of Object.entries(e))t[n]=Ad(r);return t}s(ib,"sanitizeSecretMap");function cb(e){if(!fe(e))return j;let t={};for(let[n,r]of Object.entries(e))t[n]=so(r);return t}s(cb,"sanitizeEnvNameMap");function _d(e,t){return io(e)?de:t.home?hi(e,t.home):e}s(_d,"pathString");function ab(e,t){return typeof e=="string"?_d(e,t):Array.isArray(e)?e.map(n=>typeof n=="string"?_d(n,t):j):j}s(ab,"sanitizePath");function bd(e,t,n){let r={};for(let[o,i]of Object.entries(e)){let c=Object.hasOwn(t,o)?t[o]:void 0;r[o]=c===void 0?j:on(i,c,n)}return r}s(bd,"sanitizeObject");function ub(e,t,n){switch(t){case"keep":return YA(e,n);case"transport_type":return typeof e=="string"&&MA.has(e)?e:j;case"mode":return JA(e);case"string_list":return qA(e,n);case"tool_list":return XA(e);case"command":return bi(e,n);case"helper_command":return rb(e,n);case"args":return ob(e,n);case"url":return Cd(e,n);case"secret":return Ad(e);case"secret_map":return ib(e);case"env_name":return so(e);case"env_name_map":return cb(e);case"path":return ab(e,n);case"omit":return j}}s(ub,"applyLeaf");function on(e,t,n){if(typeof t=="string")return ub(e,t,n);if("object"in t)return fe(e)?bd(e,t.object,n):j;if("map"in t){if(!fe(e))return j;let i={};for(let[c,a]of Object.entries(e))i[c]=on(a,t.map,n);return i}if("list"in t)return Array.isArray(e)?e.map(i=>on(i,t.list,n)):j;let r=GA(e),o=r===void 0?void 0:t.by[r];return o===void 0?j:on(e,o,n)}s(on,"applyTreatment");function hd(e,t){if(!fe(e))return j;let n={};for(let[r,o]of Object.entries(e))n[r]=fe(o)?bd(o,KA,t):j;return n}s(hd,"sanitizeServers");function Oi(e){return e==="vscode_mcp_json"?"servers":"mcpServers"}s(Oi,"mcpConfigServersKey");function Od(e,t,n={}){if(!fe(e))return{};let r=Oi(t);if(t==="claude_json_slice")return Object.hasOwn(e,r)?{[r]:hd(e[r],n)}:{};let o={};for(let[i,c]of Object.entries(e))i===r?o[i]=hd(c,n):t==="vscode_mcp_json"&&i==="inputs"?o[i]=on(c,{list:{object:$A}},n):t==="vscode_mcp_json"&&i==="sandbox"?o[i]=on(c,{object:Sd},n):o[i]=j;return o}s(Od,"sanitizeMcpConfigFile");var Ge=He(je(),1);import{createHash as Fb}from"node:crypto";import{join as zn}from"node:path";var Ke=He(je(),1);import{realpathSync as Pd}from"node:fs";import{basename as cn,dirname as Vn,isAbsolute as wb,join as Ni,resolve as Md,sep as Nb}from"node:path";var sn=He(je(),1);import{closeSync as lb,constants as kd,fstatSync as fb,openSync as db,readSync as pb,statSync as mb}from"node:fs";import{dirname as xd,join as ki,relative as gb,sep as _b}from"node:path";var Id="node_modules",hb=".yarn-state.yml",Sb=".package-lock.json",wd=16*1024*1024,Eb=64,yb=kd.O_RDONLY|(process.platform==="win32"?0:kd.O_NONBLOCK);function co(e,t){try{let n=mb(e);if(!n.isFile()||n.size>t)return null;let r=db(e,yb);try{let o=fb(r);if(!o.isFile()||o.size>t)return null;let i=Buffer.alloc(o.size+1),c=0;for(;c<i.length;){let u=pb(r,i,c,i.length-c,null);if(u===0)break;c+=u}if(c>t)return null;let a=i.toString("utf8",0,c);return a.charCodeAt(0)===65279?a.slice(1):a}finally{lb(r)}}catch{return null}}s(co,"readBoundedTextFile");function Td(e){if(!e.startsWith('"'))return null;try{let t=JSON.parse(e);return typeof t=="string"?t:null}catch{return null}}s(Td,"parseJsonString");var Rb="1";function Cb(e){let t=new Map,n=null,r=!1,o=!1,i=null;for(let c of e.split(`
27
- `)){let a=c.endsWith("\r")?c.slice(0,-1):c;if(a.trim().length===0||a.startsWith("#"))continue;if(!a.startsWith(" ")){if(!a.endsWith(":"))return null;let f=a.slice(0,-1);if(o=!1,r=f==="__metadata",r){n=null;continue}if(n=Td(f),n===null)return null;continue}if(a.startsWith(" - ")){if(o&&n!==null){let f=Td(a.slice(6));if(f===null)return null;let l=t.get(f)??[];l.push(n),t.set(f,l)}continue}let u=/^ {2}([A-Za-z_]+):(?: (.*))?$/.exec(a);if(u!==null){let[,f,l]=u;r&&f==="version"&&(i=l??null),o=!r&&f==="locations";continue}if(!a.startsWith(" "))return null}return i===Rb?t:null}s(Cb,"parseYarnState");var Ab=/^(?:virtual:[0-9a-f]+#)?npm:([^:#]+)(?:::__archiveUrl=[^&#]+)?$/;function bb(e){let t=e.indexOf("@",e.startsWith("@")?1:0);if(t<=0)return null;let n=e.slice(0,t),o=Ab.exec(e.slice(t+1))?.[1];return(0,sn.packageNameFromSpec)(n)!==n||o===void 0||!(0,sn.isExactNpmVersion)(o)?null:{name:n,version:o}}s(bb,"yarnLocatorEvidence");function Ob(e,t,n){let r;try{let i=new URL(e);if(i.protocol!=="https:"&&i.protocol!=="http:")return!1;r=decodeURIComponent(i.pathname)}catch{return!1}let o=t.slice(t.lastIndexOf("/")+1);return r.endsWith(`/${t}/-/${o}-${n}.tgz`)}s(Ob,"isRegistryTarballUrl");function kb(e,t){if(e===null||typeof e!="object")return null;let{name:n,version:r,resolved:o,link:i,inBundle:c}=e;if(i===!0||c===!0)return null;let a=typeof n=="string"?n:t;return(0,sn.packageNameFromSpec)(a)!==a||typeof r!="string"||!(0,sn.isExactNpmVersion)(r)||typeof o!="string"||!Ob(o,a,r)?null:{name:a,version:r}}s(kb,"npmEntryEvidence");function xb(e){let t;try{t=JSON.parse(e)}catch{return null}if(t===null||typeof t!="object")return null;let{packages:n}=t;return n===null||typeof n!="object"||Array.isArray(n)?null:new Map(Object.entries(n))}s(xb,"parseNpmHiddenLockfile");var xi=new Map,Ii=new Map;function Ib(e){if(!xi.has(e)){let t=co(e,wd);xi.set(e,t===null?null:Cb(t))}return xi.get(e)??null}s(Ib,"yarnState");function Tb(e){if(!Ii.has(e)){let t=co(e,wd);Ii.set(e,t===null?null:xb(t))}return Ii.get(e)??null}s(Tb,"npmHiddenLockfile");function Nd(e,t){let n=null,r=xd(e);for(let o=0;o<Eb;o+=1){let i=gb(r,e).split(_b).join("/");if(i.split("/").slice(0,-1).includes(Id)){let a=ki(r,Id),u=[];for(let l of Ib(ki(a,hb))?.get(i)??[])u.push(bb(l));let f=Tb(ki(a,Sb));f?.has(i)===!0&&u.push(kb(f.get(i),t));for(let l of u){if(l===null||n!==null&&(n.name!==l.name||n.version!==l.version))return null;n=l}}let c=xd(r);if(c===r)break;r=c}return n}s(Nd,"registryInstallIdentity");var wi="node_modules",Pb=1024*1024,Mb=16;function Lb(e,t){return e.startsWith("~/")||e.startsWith("~\\")?Ni(t,e.slice(2)):wb(e)?e:null}s(Lb,"absoluteLauncherPath");function vb(e){let t=e.split(Nb).join("/");return t.includes("/.yarn/")||/\.zip(?:\/|$)/i.test(t)}s(vb,"isYarnPnpPath");function Ub(e){let t=cn(e),n=Vn(e);if(cn(n)===wi)return t.startsWith("@")?null:t;let r=cn(n);return r.startsWith("@")&&cn(Vn(n))===wi?`${r}/${t}`:null}s(Ub,"nodeModulesPackageName");var Ti=new Map;function Hb(e){let t=Ni(e,"package.json");if(!Ti.has(t)){let n=co(t,Pb),r=null;if(n!==null)try{let o=JSON.parse(n);r=o!==null&&typeof o=="object"&&!Array.isArray(o)?o:null}catch{r=null}Ti.set(t,r)}return Ti.get(t)??null}s(Hb,"readManifest");function Db(e){let t=Vn(e);for(let n=0;n<Mb;n+=1){if(cn(t)===wi)return null;let r=Hb(t);if(r!==null&&typeof r.name=="string"){let{name:i,version:c}=r,a=Ub(t);if(a===null||(0,Ke.packageNameFromSpec)(i)!==i||typeof c!="string"||!(0,Ke.isExactNpmVersion)(c))return null;let u=Nd(t,a);return u?.name!==i||u.version!==c?null:{package_name:i,package_version:c,package_version_source:Ke.LOCAL_BIN_PACKAGE_VERSION_SOURCE}}let o=Vn(t);if(o===t)return null;t=o}return null}s(Db,"owningPackageIdentity");function Ld(e,t){if(typeof e!="string"||e.length===0||(0,Ke.npxExecBin)(e)!==null||!(0,Ke.isNodeModulesBinCommand)(e))return null;try{let n=Lb(e,t);if(n===null)return null;let r=Pd(n),o=Ni(Pd(Vn(n)),cn(n));return Md(r)===Md(o)||vb(r)?null:Db(r)}catch{return null}}s(Ld,"resolveLocalBinPackage");function $b(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,Ge.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}s($b,"packageVersionFields");function jb(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
28
- `);return Fb("sha512").update(t).digest("hex").slice(0,16)}s(jb,"npxCacheKey");function Bb(e){let t=process.platform==="win32"?zn(F("LOCALAPPDATA")??e,"npm-cache"):zn(e,".npm"),n=F("npm_config_cache")??F("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}s(Bb,"npmCacheRoots");function vd(e){return typeof e=="string"&&e.length>0&&e.length<=Ge.PACKAGE_FIELD_MAX?e:null}s(vd,"usableVersion");function Kb(e,t,n){let r=jb(e);for(let o of Bb(n)){let i=zn(o,"_npx",r),c=Q(zn(i,"node_modules",...t.split("/"),"package.json"),{}),a=vd(c.version);if(a!==null)return a;let u=Q(zn(i,"package-lock.json"),{}),f=vd(u.packages?.[`node_modules/${t}`]?.version);if(f!==null)return f}return null}s(Kb,"installedVersion");function Gb(e){return e.length<=Ge.PACKAGE_FIELD_MAX?e:`${e.slice(0,Ge.PACKAGE_FIELD_MAX-1)}\u2026`}s(Gb,"capField");function Vb(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,Ge.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let i=(0,Ge.packageNameFromSpec)(o);return i===null?null:{package_name:i,package_spec:Gb(o),...$b(o,Kb(r,i,n))}}s(Vb,"resolveNpxPackage");function Pi(e,t,n){return Vb(e,t,n)??Ld(e,n)}s(Pi,"resolveMcpLaunchPackage");function Ud(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=Lt(e.trim());return n===void 0?null:Pi(n,r,t)}s(Ud,"resolveNpxPackageFromCommand");function ao(e,t){if(!e||typeof e!="object"||Array.isArray(e))return null;let n=e,r=Array.isArray(n.args)?n.args.filter(o=>typeof o=="string"):[];return Pi(typeof n.command=="string"?n.command:null,r,t)}s(ao,"npxPackageFromMcpConfig");function Hd(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:Pi(nn(n[1]??""),Bn(e,"args"),t)}s(Hd,"npxPackageFromTomlSection");function Yb(e){if(!e||typeof e!="object"||Array.isArray(e))return"unknown";let t=e;return typeof t.type=="string"&&t.type.length>0?t.type:typeof t.url=="string"?"http":typeof t.command=="string"?"stdio":"unknown"}s(Yb,"mcpTransport");function Xb(e){return/(?:^|[\\/])\.vscode[\\/]mcp\.json$/i.test(e)}s(Xb,"isVsCodeMcpJson");function qb(e){return Xb(e)?"vscode_mcp_json":Jb(e)===".claude.json"?"claude_json_slice":"mcp_json"}s(qb,"mcpConfigFormat");var Zb=64*1024;function Dd(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,void 0);if(!fe(r))return;let o=qb(t),i=Oi(o),c=r[i],a=c&&typeof c=="object"?c:{},u=e.componentPath(t),f=[];for(let[l,p]of Object.entries(a)){if(e.truncated)return;let d=Yb(p),m=Jf(p,d);Object.assign(m,ao(p,e.home)??{});let g=Yf(p),h=ui(l,m,g);f.push([l,h]),e.push({kind:"MCP_SERVER",name:l,path:u,content_hash:h,origin:n,enabled:g,attributes:m})}e.truncated||o==="claude_json_slice"&&!Object.hasOwn(r,i)||Object.hasOwn(a,u)||Qb(e,{parsed:r,format:o,pathRel:u,origin:n,serverHashes:f})}s(Dd,"collectMcpJson");function Qb(e,t){let n=Od(t.parsed,t.format,{home:e.home}),r=JSON.stringify(n,null,2),o=Buffer.byteLength(r,"utf8"),i=o>Zb,c=[...t.serverHashes].sort(([a],[u])=>a<u?-1:a>u?1:0);e.push({kind:"MCP_CONFIG",name:t.pathRel,path:t.pathRel,...i?{}:{text:r,content_length:o},content_hash:X(JSON.stringify({text:r,servers:c})),origin:t.origin,enabled:!0,attributes:{format:t.format,server_count:t.serverHashes.length,...i?{text_omitted:"too_large"}:{}}})}s(Qb,"pushMcpConfigRow");function Fd(e,t,n){if(!zb(t)||!e.claimFile(t))return;let r;try{r=Wb(t,"utf8")}catch{return}let o=e.componentPath(t),i=/^\[mcp_servers(?:\.(\w+)|\."([^"]+)"|\.'([^']+)')\]\s*$/gm,c;for(;(c=i.exec(r))!==null;){if(e.truncated)return;let a=c[1]??c[2]??c[3];if(!a)continue;let u=r.slice(c.index+c[0].length),f=u.search(/^\[mcp_servers(?:\.(?:\w+|"[^"]+"|'[^']+'))\]\s*$/m),l=f===-1?u:u.slice(0,f),p="unknown";/^\s*url\s*=/m.test(l)?p="http":/^\s*command\s*=/m.test(l)&&(p="stdio");let d=qf(l,p);Object.assign(d,Hd(l,e.home)??{});let m=Xf(l);e.push({kind:"MCP_SERVER",name:a,path:o,content_hash:ui(a,d,m),origin:n,enabled:m,attributes:d})}}s(Fd,"collectCodexMcpToml");import{existsSync as eO,readdirSync as tO}from"node:fs";import{join as ye}from"node:path";var $d=50;function Wn(e,t,n,r){if(!eO(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:i}=e.withPluginExpandCap($d,()=>{Pt(e,{dir:ye(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),Pt(e,{dir:ye(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),Pt(e,{dir:ye(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});di(e,ye(t,"hooks","hooks.json"),n),di(e,ye(t,"hooks.json"),n);let c=e.components.length-o,a=i>=$d;return{componentCount:c,expandTruncated:a}}s(Wn,"expandPluginTree");function Jn(e,t){e.push({kind:"PLUGIN",name:t.pluginKey,path:t.rowPath,content_hash:t.contentHash,origin:"user",enabled:t.enabled,attributes:{...t.marketplace?{marketplace:t.marketplace}:{},...t.version?{version:t.version}:{},scope:t.scope,component_count:t.componentCount,...t.expandTruncated?{expand_truncated:!0}:{}}})}s(Jn,"addPluginRow");function Mi(e){let t=e?.enabledPlugins;if(typeof t!="object"||t===null||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}s(Mi,"readEnabledPlugins");function nO(e){let t=Mi(e.readJson(ye(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=Fn(process.platform,e.home),o=e.readJson(n,{}),i={};if(o&&Object.keys(o).length>0)i=Mi(o);else for(let c of r)Object.assign(i,Mi(e.readJson(c,{})));return{...t,...i}}s(nO,"resolveClaudeEnabledPlugins");function jd(e){let t=ye(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=nO(e),i=e.componentPath(t);for(let[c,a]of Object.entries(r)){if(e.truncated)return;let u=Array.isArray(a)?a:[a],f=u[0]??{},l=o[c]===!0,p=c.includes("@")?c.split("@").slice(1).join("@"):"",d=typeof f.version=="string"?f.version:"",m=typeof f.scope=="string"?f.scope:"user",g=`plugin:${c}`,h=0,y=!1;for(let b of u)if(typeof b.installPath=="string"&&b.installPath.length>0){let w=Wn(e,b.installPath,g,l);h+=w.componentCount,y=y||w.expandTruncated}Jn(e,{pluginKey:c,rowPath:i,enabled:l,scope:m,version:d||void 0,marketplace:p||void 0,componentCount:h,expandTruncated:y,contentHash:X(`${c}|${d}|${m}|${l}|${h}`)})}}s(jd,"collectClaudePlugins");function rO(e){let t=e,n="";try{let r=tO(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=ye(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),i=o[o.length-1];i&&(t=ye(e,i),n=i)}}catch{}return{installPath:t,version:n}}s(rO,"pickVersionDir");var oO=/^\d+$/;function sO(e){let t=e.filter(n=>!oO.test(n.pluginId));return t.length>0?t:e}s(sO,"dedupeCursorCachePlugins");function Bd(e){let t=[{base:ye(e.home,".cursor/plugins/local"),scope:"local"},{base:ye(e.home,".cursor/plugins/cache"),scope:"cache"}];for(let{base:n,scope:r}of t)if(!e.truncated)for(let o of e.readEntries(n)){if(!o.isDirectory()||e.truncated)continue;if(r==="local"){let a=o.name,u=ye(n,o.name),f=`plugin:${a}`,{componentCount:l,expandTruncated:p}=Wn(e,u,f,!0);Jn(e,{pluginKey:a,rowPath:e.componentPath(u),enabled:!0,scope:"local",componentCount:l,expandTruncated:p,contentHash:X(`${a}|local|${l}`)});continue}let i=o.name,c=[];for(let a of e.readEntries(ye(n,i))){if(!a.isDirectory())continue;let u=ye(n,i,a.name),{installPath:f,version:l}=rO(u);c.push({pluginId:a.name,installPath:f,version:l})}for(let a of sO(c)){if(e.truncated)break;let u=`${a.pluginId}@${i}`,f=`plugin:${u}`,{componentCount:l,expandTruncated:p}=Wn(e,a.installPath,f,!0);Jn(e,{pluginKey:u,rowPath:e.componentPath(a.installPath),enabled:!0,scope:"cache",version:a.version||void 0,marketplace:i,componentCount:l,expandTruncated:p,contentHash:X(`${u}|${a.version}|${l}`)})}}}s(Bd,"collectCursorPlugins");import{existsSync as iO}from"node:fs";import{join as Ve}from"node:path";var Kd=".claude/skills/synced",Gd=".claude/plugins/synced";function Vd(e){return[Ve(e,Kd),Ve(e,Gd)]}s(Vd,"claudeSyncedDirs");function uo(e){return typeof e=="string"&&e.length>0?e:void 0}s(uo,"stringField");function zd(e){let t=Ve(e.home,Kd);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ve(t,n.name),o=e.readJson(Ve(r,"manifest.json"),{}),i=new Map((o?.skills??[]).flatMap(c=>c.name?[[c.name,c]]:[]));for(let c of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}let a=Ve(r,c.name,"SKILL.md");if(!c.isDirectory()||!iO(a))continue;let u=i.get(c.name),f=uo(u?.source),l=uo(u?.creatorType);Qt(e,{absolutePath:a,kind:"SKILL",origin:"user",enabled:!0,name:c.name,attributes:{scope:"synced",...f?{source:f}:{},...l?{creator_type:l}:{}}})}}}s(zd,"collectClaudeSyncedSkills");function Wd(e){let t=Ve(e.home,Gd);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ve(t,n.name),o=e.readJson(Ve(r,"manifest.json"),{}),i=new Map((o?.plugins??[]).flatMap(c=>c.name?[[c.name,c]]:[]));for(let c of e.readEntries(r)){if(e.truncated)return;if(!c.isDirectory()||c.name.startsWith("."))continue;let a=i.get(c.name),u=uo(a?.marketplaceName),f=uo(a?.version),l=u?`${c.name}@${u}`:c.name,p=Ve(r,c.name),{componentCount:d,expandTruncated:m}=Wn(e,p,`plugin:${l}`,!0);Jn(e,{pluginKey:l,rowPath:e.componentPath(p),enabled:!0,scope:"synced",version:f,marketplace:u,componentCount:d,expandTruncated:m,contentHash:X(`${l}|${f??""}|synced|${d}`)})}}}s(Wd,"collectClaudeSyncedPlugins");function aO(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:i}=t;for(let c of n.skillRoots)Pt(e,{dir:an(r,c),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:Vd(e.home)});for(let c of n.dirs)Pt(e,{dir:an(r,c.dir),kind:c.kind,origin:o,enabled:!0,extensions:c.extensions});for(let c of n.memory){let a=rf(c.map(u=>an(r,u)));a&&Qt(e,{absolutePath:a,kind:"MEMORY",origin:o,enabled:!0,name:cO(a)})}for(let c of af(n))yi(e,an(r,c),o,{kind:"SETTINGS",profile:ud(c)});for(let c of n.mcpJson??[])Dd(e,an(r,c),o);for(let c of n.mcpToml??[])Fd(e,an(r,c),o);if(i){if(n.managed){for(let c of Jr(n.managed,process.platform,e.home))if(c.toLowerCase().endsWith(".json")){let a=ld(n.managed,c);yi(e,c,o,{kind:"MANAGED_SETTINGS",...a})}}n.plugins==="claude"?(jd(e),Wd(e),zd(e)):n.plugins==="cursor"&&Bd(e)}}s(aO,"walkPlatformLayout");function Jd(e,t){try{let n=new $r(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)aO(n,{layout:r,levelDir:t.levelDir,origin:t.origin,includeMachineWide:t.includeMachineWide});return{scopeRef:t.scopeRef,anchor:t.levelDir,components:n.components,truncated:n.truncated}}catch(n){L("user_spec_scope",n);return}}s(Jd,"walkScope");function Li(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let u=Jd(t,{layouts:Object.values(en),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:ut,scopeRef:""});u&&(r.user=u)}let i=n.inGitRepo===!0,c=null,a=n.launchCwd;if(a!==void 0){let u=Object.values(gt),f=ks({launchCwd:a,gitRoot:n.gitRoot,inGitRepo:i,remote:n.remote,home:t,hasProjectSpec:s(l=>lf(u,l),"hasProjectSpec")});c=f.parentRel;for(let l of f.anchors){let p=xs(l.dir);if(o!==void 0&&!o(l.scope,p))continue;let d=Jd(t,{layouts:u,levelDir:l.dir,origin:l.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:Is,scopeRef:p});d&&(r[l.scope]=d)}r.parent||(c=null)}return{scopes:r,parentRel:c,cwdInGitRepo:i}}s(Li,"collectUserSpec");function vi(e,t,n={}){let r=n.truncated===!0,o=Mn(e),i=new Set(e.map(l=>xe(l.path,l.name)));if(n.forceFull===!0||t===void 0)return{hash:o,count:e.length,truncated:r,full:!0,upserts:e,removed:[],unchanged:!1};let a=[],u=t;for(let l of e){let p=xe(l.path,l.name);u[p]!==Fr(l)&&a.push(l)}let f=[];if(!r){for(let l of Object.keys(u))if(!i.has(l)){let p=ju(l);p&&f.push(p)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:a,removed:f,unchanged:a.length===0&&f.length===0}}s(vi,"diffUserSpec");var Xd=2*1024*1024,uO=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function Ui(e,t,n){let r=new Set(t.map(i=>xe(i.path,i.name))),o=[];for(let i of e)i.text!==void 0&&(n.has(i.content_hash)||r.has(xe(i.path,i.name))||o.push(i));return o}s(Ui,"collectPendingTextBodies");function Hi(e,t,n){let r=new Set(e);for(let i of t)r.add(i);let o=new Set(n.map(i=>i.content_hash));return[...r].filter(i=>o.has(i))}s(Hi,"pruneDeliveredTextHashes");function Yd(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Yd,"jsonSize");function qd(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}s(qd,"withoutText");function Di(e,t=Xd){let n=[],r=[];for(let l of e)uO.has(l.kind)?n.push(l):r.push(l);r.sort((l,p)=>(l.text?.length??0)-(p.text?.length??0));let o=[...n,...r],i=[],c=2,a=0,u=0,f=[];for(let l of o){let p=i.length>0?1:0,d=Yd(l)+p;if(c+d<=t){i.push(l),c+=d,l.text!==void 0&&f.push(l.content_hash);continue}if(l.text!==void 0){let m=qd(l),g=Yd(m)+p;if(c+g<=t){i.push(m),c+=g,a+=1;continue}}u+=1}return{components:i,textDeferredCount:a,droppedCount:u,textHashesSent:f}}s(Di,"fitUserSpecWithinBudget");function Fi(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:qd(n))}s(Fi,"stripAlreadyDeliveredText");var lO=["user","cwd","repo","parent"];function $i(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,i=[];for(let x of lO){let O=t.scopes[x];if(!O)continue;let U=n(x,O.scopeRef),M=U.components,k=vi(O.components,M,{forceFull:M===void 0,truncated:O.truncated}),P=new Set(U.textHashes),v=Ui(O.components,k.upserts,P),_=Fi([...k.upserts,...v],P);i.push({scope:x,walk:O,delta:k,outgoing:_,outgoingKeys:new Set(_.map(I=>xe(I.path,I.name))),deliveredTextHashes:P,cachedComponents:M})}let c=i.flatMap(x=>x.outgoing),a=Di(c,o),u=new Set(a.components.map(x=>xe(x.path,x.name))),f=[],l=[],p=[],d=[],m=[],g=[],h=[];for(let x of i){let{scope:O,walk:U,delta:M}=x;g.push(...U.components),f.push(O);let k=a.components.filter(I=>x.outgoingKeys.has(xe(I.path,I.name))),P=[...x.outgoingKeys].some(I=>!u.has(I)),v=M.truncated||P;v?p.push(O):M.full&&l.push(O),d.push(...k),!M.full&&!v&&m.push(...M.removed);let _=M.full?{}:{...x.cachedComponents??{}};if(!v)for(let I of M.removed)delete _[xe(I.path,I.name)];for(let I of k)_[xe(I.path,I.name)]=Fr(I);h.push({scope:O,scopeRef:U.scopeRef,components:_,textHashes:Hi(x.deliveredTextHashes,k.filter(I=>I.text!==void 0).map(I=>I.content_hash),U.components),collectedAtMs:r,included:k.length>0||M.removed.length>0&&!v||M.full})}let y={user_spec_hash:Mn(g),user_spec_count:g.length,user_spec_truncated:p.length>0};f.length>0&&(y.user_spec_scopes=f,y.user_spec_full_scopes=l,y.user_spec_truncated_scopes=p,y.user_spec_cwd_in_git_repo=t.cwdInGitRepo),l.length>0&&l.length===f.length&&(y.user_spec_full=!0),d.length>0&&(y.user_spec=d),m.length>0&&(y.user_spec_removed=m),a.textDeferredCount>0&&(y.user_spec_text_deferred=a.textDeferredCount);let b=t.scopes.cwd;b&&(y.user_spec_cwd_scope_ref=b.scopeRef);let w=t.scopes.repo;w&&(y.user_spec_repo_scope_ref=w.scopeRef);let N=t.scopes.parent;return N&&(y.user_spec_parent_scope_ref=N.scopeRef,t.parentRel&&(y.user_spec_parent_rel=t.parentRel)),{fields:y,scopes:h}}s($i,"buildUserSpecSend");var lo={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function ji(e){return e==="cwd"||e==="repo"||e==="parent"}s(ji,"isProjectSpecScope");function Yn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Yn,"isPlainObject");function Bi(e){return!Yn(e)||!Yn(e.components)||!Object.values(e.components).every(t=>typeof t=="string")||!Array.isArray(e.text_hashes)||!e.text_hashes.every(t=>typeof t=="string")?!1:typeof e.collected_at_ms=="number"&&Number.isFinite(e.collected_at_ms)}s(Bi,"isDirScopeCacheEntry");function Zd(e){return fO(e)}s(Zd,"readStringHashMap");function Qd(e){return dO(e)}s(Qd,"readStringArray");function ep(e){return pO(e)}s(ep,"cloneDirScopeMap");function fO(e){if(!Yn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}s(fO,"readComponentHashMap");function dO(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}s(dO,"readTextHashes");function tp(e,t){if(!Yn(e))return;let n=e[t];return Bi(n)?n:void 0}s(tp,"readDirScopeCacheEntry");function pO(e){if(!Yn(e))return{};let t={};for(let[n,r]of Object.entries(e))Bi(r)&&(t[n]=r);return t}s(pO,"readDirScopeCacheMap");function Ki(e,t=20){let n=[];for(let[r,o]of Object.entries(e))Bi(o)&&n.push([r,o]);return n.sort((r,o)=>o[1].collected_at_ms-r[1].collected_at_ms),Object.fromEntries(n.slice(0,t))}s(Ki,"boundDirScopeCache");var SO=["allow","deny","ask"];function po(e){let t=Q(e,{}),n=[];for(let r of SO)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:ro(o),mode:r});return{model:t.model??"",permissionKeys:n}}s(po,"readClaudeSettings");function EO(e){let{serverManaged:t,fileBased:n}=Fn(process.platform,e),r=po(t);if(r.model||r.permissionKeys.length>0)return r;let o="",i=[];for(let c of n){let a=po(c);a.model&&(o=a.model),i.push(...a.permissionKeys)}return{model:o,permissionKeys:i}}s(EO,"readClaudeManagedSettings");function yO(e){let t=new Set,n=[];for(let r of e){let o=`${r.mode}\0${r.key}`;t.has(o)||(t.add(o),n.push(r))}return n}s(yO,"dedupePermissionKeys");var RO=10,CO="self-config-cache.json",rp=6;function ln(){return F("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}s(ln,"isUserSpecDisabled");function AO(){return F("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}s(AO,"isCwdSpecDisabled");var bO={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"],copilot:["copilot"]};async function OO(e,t=ne){let n=bO[e];if(!n||n.length===0)return null;let r=s(async o=>{let i=n[o];if(i===void 0)return null;let a=((await t(i,["--version"],2e3)).split(`
29
- `)[0]??"").trim();return a||r(o+1)},"tryNext");return r(0)}s(OO,"resolveCliVersion");function op(e=Wi()){return un(e,".ev-ai","agent-hook",CO)}s(op,"selfConfigCachePath");function sp(e=Wi()){try{_O(op(e))}catch(t){if(t.code==="ENOENT")return;let n=t instanceof Error?t.message:String(t);T(`WARN: self-config cache clear failed open: ${n}`),L("self_config_cache_clear",t)}}s(sp,"clearSelfConfigCache");function kO(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
30
- `);return X(n)}s(kO,"hashConfigEntries");function fo(e,t,n=!1){let r=kO(e),o=e.length;return t===r?n?{hash:r,count:o,truncated:n}:{hash:r,count:o}:n?{hash:r,count:o,entries:e,truncated:n}:{hash:r,count:o,entries:e}}s(fo,"buildHashedList");function Gi(e,t,n=[]){let r=0,o=!1,i=new Set;for(let c of[...t.map(a=>un(e,a)),...n]){let a=hO(c);if(i.has(a))continue;i.add(a);let u=qo(c);u.present&&(o=!0,r+=u.size)}return o?{present:!0,size:r}:{present:!1,size:0}}s(Gi,"filePresenceUnion");var Vi="installation_id";function zi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(zi,"isPlainRecord");function xO(e,t){if(!gO(e))return{};let n=Oe(np(e,"utf8"),{});if(!zi(n))return{};let r=n[Vi];if(t&&typeof r=="string"&&r!==t)return{};let o={};for(let[i,c]of Object.entries(n))i!==Vi&&zi(c)&&(o[i]=c);return o}s(xO,"readSelfConfigCache");function IO(e){try{let t=Oe(np(e,"utf8"),{}),n=zi(t)?t.installation_id:void 0;return typeof n=="string"&&n.length>0?n:void 0}catch{return}}s(IO,"storedInstallationId");function TO(e,t,n){let r=n?{...t,[Vi]:n}:t;try{ae(e,`${JSON.stringify(r)}
31
- `)}catch(o){let i=o instanceof Error?o.message:String(o);T(`WARN: self-config cache write failed open: ${i}`),L("self_config_cache",o)}}s(TO,"writeSelfConfigCache");function wO(e,t,n){if(t==="user")return{components:Zd(e.user_spec_components),textHashes:Qd(e.user_spec_text_hashes)};if(!ji(t))return{components:void 0,textHashes:[]};let r=tp(e[lo[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}s(wO,"cacheSliceFor");function NO(e,t,n,r){let o={...e,send_count:n};for(let i of Object.keys(t)){let c=t[i];c.entries!==void 0&&(o[i]=c.hash)}if(r){o.user_spec_layout_version=rp,r.home&&(o.user_spec_collected_at_ms=r.home.collectedAtMs,r.home.included&&(o.user_spec=r.hash,o.user_spec_components=r.home.components),o.user_spec_text_hashes=r.home.textHashes);for(let i of r.project){if(!ji(i.scope))continue;let c=lo[i.scope],a=ep(o[c]),u=a[i.scopeRef];a[i.scopeRef]={components:i.included?i.components:u?.components??{},text_hashes:i.textHashes,collected_at_ms:i.collectedAtMs},o[c]=Ki(a)}}return o}s(NO,"nextPlatformSelfConfigCache");async function ip(e,t=process.cwd(),n=Wi(),r={}){let o=e==="claude",i=r.gitRoot??t,c=await OO(e),a="",u=[];if(o){let v=EO(n),_=po(un(n,".claude/settings.json")),I=po(un(t,".claude/settings.local.json"));a=v.model||I.model||_.model,u=yO([...v.permissionKeys,..._.permissionKeys,...I.permissionKeys]).slice(0,200)}let f={present:!1,size:0},l=s(v=>{let _=[],I=!1;for(let B of v){let Ce=ra(un(n,B));if(_=_.concat(Ce.entries),I=I||Ce.truncated,_.length>=ut){_=_.slice(0,ut),I=!0;break}}return{entries:_,truncated:I}},"listScopeWithMeta"),p=op(n),d=xO(p,r.installationId),m=d[e]??{},g=(m.send_count??0)+1,h=g>0&&g%RO===0,y=s(v=>h?void 0:m[v],"cachedHash"),b=l(ht.skills),w=l(ht.subagents),N=l(ht.commands),x=l(ht.rules),O={skills:fo(b.entries,y("skills"),b.truncated),subagents:fo(w.entries,y("subagents"),w.truncated),commands:fo(N.entries,y("commands"),N.truncated),rules:fo(x.entries,y("rules"),x.truncated)},U={runner_platform:e,config_scope:"user",cli_version:c,claude_version:o?c:null,model:o&&a||null,permission_keys:u,user_scope:{skills:O.skills,subagents:O.subagents,commands:O.commands,rules:O.rules,memory:Gi(n,ht.memory),settings:Gi(n,ht.settings,ff(n)),mcp:Gi(n,ht.mcp)},local_settings:o?qo(un(t,".claude/settings.local.json")):f},M=null,k=r.nowMs??Date.now();if(!ln()){let v=m.user_spec_layout_version!==rp,_=Li(e,n,{launchCwd:AO()?void 0:r.launchCwd,gitRoot:i,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(_.scopes).length>0){let I=$i({collected:_,cacheFor:s((B,Ce)=>v?{components:void 0,textHashes:[]}:wO(m,B,Ce),"cacheFor"),nowMs:k});Object.assign(U,I.fields),M={hash:I.fields.user_spec_hash,home:I.scopes.find(B=>B.scope==="user")??null,project:I.scopes.filter(B=>B.scope!=="user")}}}let P=NO(m,O,g,M);return{config:U,commit:s(()=>{let{installationId:v,installationStorePath:_}=r;if(v&&_){let I=IO(_);if(I!==void 0&&I!==v)return}d[e]=P,TO(p,d,v)},"commit")}}s(ip,"selfConfig");import{createHash as PO}from"node:crypto";import{readFileSync as MO,statSync as ap}from"node:fs";import{homedir as LO}from"node:os";import{isAbsolute as vO,join as yt,resolve as cp}from"node:path";var UO="^(user\\.(name|email)|remote\\.origin\\.url)$",HO=3600*1e3,DO=32;function up(e){return PO("sha256").update(e).digest("hex")}s(up,"sha256");function FO(e){let t={userName:null,userEmail:null,remoteOriginUrl:null};for(let n of e.split(`
32
- `)){let r=n.trim();if(r.toLowerCase()==="remote.origin.url"){t.remoteOriginUrl=null;continue}let o=r.indexOf(" ");if(o<=0)continue;let i=r.slice(0,o).toLowerCase(),c=r.slice(o+1).trim()||null;i==="user.name"?t.userName=c:i==="user.email"?t.userEmail=c:i==="remote.origin.url"&&(t.remoteOriginUrl=c)}return t}s(FO,"parseGitConfigValues");function $O(e){return{userName:e.userName,userEmail:e.userEmail,remoteOriginUrlSha256:e.remoteOriginUrl?up(e.remoteOriginUrl):null}}s($O,"toFacts");function mo(e){try{return MO(e,"utf8")}catch{return null}}s(mo,"readTextOrNull");function jO(e){let t=yt(e,".git"),n;try{if(ap(t).isDirectory())n=t;else{let o=/^gitdir:\s*(.+?)\s*$/m.exec(mo(t)??"")?.[1];if(!o)return null;n=vO(o)?o:cp(e,o)}}catch{return null}let r=mo(yt(n,"commondir"))?.trim();return{gitDir:n,commonDir:r?cp(n,r):n}}s(jO,"repoGitDirs");function BO(e){let t=e.GIT_CONFIG_GLOBAL?.trim();if(t)return[t];let n=e.HOME?.trim()||LO(),r=e.XDG_CONFIG_HOME?.trim();return[yt(n,".gitconfig"),yt(r||yt(n,".config"),"git","config")]}s(BO,"globalConfigPaths");function KO(e){try{let t=ap(e);return`${e}|${String(t.mtimeMs)}|${String(t.size)}`}catch{return`${e}|-`}}s(KO,"fileStamp");var GO=["GIT_DIR","GIT_COMMON_DIR","GIT_CONFIG"];function VO(e){return GO.some(t=>!!e[t]?.trim())}s(VO,"hasGitLocationOverride");function zO(e,t=process.env){let n=jO(e),r=n?[yt(n.commonDir,"config"),yt(n.gitDir,"config.worktree")]:[],o=n?`HEAD|${mo(yt(n.gitDir,"HEAD"))?.trim()??"-"}`:"HEAD|-",i=[...r,...BO(t)].map(KO),c=Object.keys(t).filter(a=>a.startsWith("GIT_CONFIG")||a==="GIT_DIR"||a==="GIT_COMMON_DIR").sort().map(a=>`${a}=${t[a]??""}`);return[...i,o,...c].join(`
33
- `)}s(zO,"gitConfigStamp");function Ji(e){return typeof e=="string"&&e.length>0?e:null}s(Ji,"nullableString");function lp(e){let t=mo(e);if(!t)return{};let n;try{n=JSON.parse(t)}catch{return{}}let r=n&&typeof n=="object"?n.entries:void 0;if(!r||typeof r!="object"||Array.isArray(r))return{};let o={};for(let[i,c]of Object.entries(r)){if(!c||typeof c!="object")continue;let a=c;typeof a.read_at_ms!="number"||typeof a.stamp_sha256!="string"||(o[i]={read_at_ms:a.read_at_ms,stamp_sha256:a.stamp_sha256,user_name:Ji(a.user_name),user_email:Ji(a.user_email),remote_origin_url_sha256:Ji(a.remote_origin_url_sha256)})}return o}s(lp,"readCacheEntries");function WO(e){return!e.userName&&!e.userEmail&&!e.remoteOriginUrlSha256}s(WO,"isEmpty");function JO(e,t,n){if(e?.stamp_sha256!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<HO}s(JO,"isFresh");function YO(e,t,n){let r={...lp(e),[t]:n},o=Object.entries(r).sort(([,i],[,c])=>c.read_at_ms-i.read_at_ms).slice(0,DO);try{ae(e,`${JSON.stringify({entries:Object.fromEntries(o)})}
34
- `)}catch(i){let c=i instanceof Error?i.message:String(i);T(`WARN: git config cache write failed open: ${c}`)}}s(YO,"writeCacheEntry");async function go(e,t={}){let n=t.exec??ne,r=t.env??process.env,o=VO(r)?void 0:t.cachePath,i=o?up(zO(e,r)):"",c=t.nowMs??Date.now();if(o){let f=lp(o)[e];if(f&&JO(f,i,c))return{userName:f.user_name,userEmail:f.user_email,remoteOriginUrlSha256:f.remote_origin_url_sha256}}let a=await n("git",["config","--get-regexp",UO],2e3,{cwd:e}),u=$O(FO(a));return o&&!WO(u)&&YO(o,e,{read_at_ms:c,stamp_sha256:i,user_name:u.userName,user_email:u.userEmail,remote_origin_url_sha256:u.remoteOriginUrlSha256}),u}s(go,"readGitConfigValues");var ZO="installation.json",QO="git-config.json",ek="cloud-bootstrap.lock",tk=6e4;function Ep(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}s(Ep,"platformAgentIdCacheKey");function Re(e=Xn()){return ho(e,".ev-ai","agent-hook")}s(Re,"agentHookHome");function nk(e=Xn()){return ho(Re(e),ZO)}s(nk,"installationStorePath");function fn(e=Xn()){return ho(Re(e),QO)}s(fn,"gitConfigCachePath");function yp(e){return ho(_o(e),ek)}s(yp,"cloudBootstrapLockPath");function Rp(){return XO(8).toString("hex")}s(Rp,"randomInstallationId");function Rt(e){return mp("sha256").update(e).digest("hex").slice(0,16)}s(Rt,"sha16");function G(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(G,"trimEnv");function Cp(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}s(Cp,"isValidInstallationId");function rk(e=process.env){let t=G(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!Cp(t)){T(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}s(rk,"readInstallationIdEnvOverride");function Ap(e,t){return e&&Cp(e)?e:(e&&T(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),rk(t))}s(Ap,"resolvePinnedInstallationId");function ok(e){return/^[0-9a-f]{16}$/.test(e)}s(ok,"isEphemeralInstallationIdShape");function sk(e=process.env){if(G(e.GITHUB_ACTIONS)){let t=G(e.GITHUB_REPOSITORY_ID)??G(e.GITHUB_REPOSITORY),n=G(e.GITHUB_ACTOR)??G(e.GITHUB_TRIGGERING_ACTOR)??G(e.GITHUB_USER);if(t&&n)return Rt(`github_actions|${t}|${n}`)}if(G(e.CODESPACES)||G(e.CODESPACE_NAME)){let t=G(e.CODESPACE_NAME);if(t)return Rt(`codespaces|${t}`);let n=G(e.GITHUB_REPOSITORY_ID)??G(e.GITHUB_REPOSITORY),r=G(e.GITHUB_USER)??G(e.GITHUB_ACTOR);if(n&&r)return Rt(`codespaces|${n}|${r}`)}if(G(e.GITLAB_CI)){let t=G(e.CI_PROJECT_ID)??G(e.CI_PROJECT_PATH),n=G(e.GITLAB_USER_LOGIN)??G(e.GITLAB_USER_EMAIL)??G(e.GITLAB_USER_NAME);if(t&&n)return Rt(`gitlab|${t}|${n}`)}return null}s(sk,"deriveEphemeralInstallationId");var bp="cursoragent@cursor.com";function ik(e){let t=G(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===bp?null:t}s(ik,"cursorCloudUserEmail");function ck(e,t){return G(e.CURSOR_PROJECT_DIR)??G(e.CLAUDE_PROJECT_DIR)??t}s(ck,"cursorCloudWorkspacePath");function ak(e){return Cn(e).replace(/\.git$/i,"").toLowerCase()}s(ak,"normalizeRemoteForSeed");async function uk(e){let t=await ne("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?ak(t):e}s(uk,"resolveRepoSeed");async function lk(e){let t=G(await ne("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!pe(null,t))return t;let n=G(await ne("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!pe(null,n)?n:null}s(lk,"readClaudeRemoteOperatorEmail");function fk(e){let t=G(e?.userId??void 0);if(t)return{kind:"user_id",value:t};let n=G(e?.userEmail??void 0)?.toLowerCase();return n&&n!==bp?{kind:"email",value:n}:null}s(fk,"cursorCloudOwnerKey");function dk(e,t,n){let r=ck(e,t);if(!r)return null;let o=fk(n);return o?(re.info(`cursor_cloud installation key=${o.kind}`),{id:Rt(`cursor_cloud/v2|${r}|${o.value}`),cursorCloudSeed:"v2"}):(re.info("cursor_cloud installation key=v1"),{id:Rt(`cursor_cloud|${r}|${ik(e)??""}`),cursorCloudSeed:"v1"})}s(dk,"deriveCursorCloudInstallationSeed");async function pk(e,t,n,r,o){if(e==="cursor_cloud"&&t)return dk(n,r,await Lr({env:n,home:o}));if(e==="claude_remote"){let i=await mk(n,r,o);return i?{id:i}:null}return null}s(pk,"deriveCloudInstallationId");async function mk(e,t,n=Xn()){let r=qa(n);if(r)return re.info("claude_remote installation key=email"),Rt(`claude_remote/v2|${r}`);re.info("claude_remote installation key=v1");let o=G(e.CLAUDE_PROJECT_DIR)??t;if(!o)return null;let i=await uk(o),c=await lk(o);return Rt(`claude_remote|${i}|${c??""}`)}s(mk,"deriveClaudeRemoteInstallationId");function fp(e,t){let n=Ap(e,t);if(n)return n;let r=sk(t);return r||Rp()}s(fp,"chooseNewInstallationId");async function gk(e,t={}){let{remoteOriginUrlSha256:n}=await go(e,t);return(n??mp("sha256").update(qO(e)).digest("hex")).slice(0,16)}s(gk,"computeRepoKey");function _k(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&r.length>0&&(t[n]=r);return Object.keys(t).length>0?t:void 0}s(_k,"readPlatformAgentIds");function hk(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=_k(t.platform_agent_ids);return{installation_id:t.installation_id,...t.pinned===!0?{pinned:!0}:{},...n?{platform_agent_ids:n}:{},...typeof t.operator_identity_hash=="string"?{operator_identity_hash:t.operator_identity_hash}:{},...typeof t.operator_identity_sent_at=="string"?{operator_identity_sent_at:t.operator_identity_sent_at}:{},...t.cursor_cloud_seed==="v2"?{cursor_cloud_seed:"v2"}:{}}}catch{return}}s(hk,"parseInstallationRecord");function Ut(e){if(gp(e))try{return hk(_p(e,"utf8"))}catch{}}s(Ut,"readInstallationRecord");function qi(e){return Ut(e)}s(qi,"readInstallationStore");function Op(e,t,n){let r=Ut(e);if(!r||r.operator_identity_hash===t&&r.operator_identity_sent_at===n)return;let o={...r,operator_identity_hash:t,operator_identity_sent_at:n};try{ae(e,`${JSON.stringify(o,null,2)}
35
- `)}catch(i){let c=i instanceof Error?i.message:String(i);T(`WARN: operator identity cache write failed open: ${c}`),L("operator_identity_cache",i)}}s(Op,"writeOperatorIdentityCache");function kp(e,t=Date.now()){if(!e)return!0;if(Ut(e)?.operator_identity_hash)return!1;let n=yp(e);try{if(gp(n)){let r=Number.NaN;try{r=Number(_p(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<tk)return!1;try{hp(n)}catch{}}}catch{}try{return Xi(_o(n),{recursive:!0}),Sp(n,`${t}
36
- `,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(wp(r))return!1;let o=r instanceof Error?r.message:String(r);return T(`WARN: cloud bootstrap claim failed open: ${o}`),L("cloud_bootstrap_claim",r),!0}}s(kp,"tryClaimCloudIdentityBootstrap");function xp(e){if(e)try{hp(yp(e))}catch{}}s(xp,"releaseCloudIdentityBootstrapClaim");function Ip(e,t){let r=Ut(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}s(Ip,"readCachedPlatformAgentId");function Tp(e,t,n){if(!n)return;let r=Ut(e);if(!r||r.platform_agent_ids?.[t]===n)return;let o={...r,platform_agent_ids:{...r.platform_agent_ids,[t]:n}};try{ae(e,`${JSON.stringify(o,null,2)}
37
- `)}catch(i){let c=i instanceof Error?i.message:String(i);T(`WARN: platform_agent_id cache write failed open: ${c}`),L("platform_agent_id_cache",i)}}s(Tp,"writeCachedPlatformAgentId");function wp(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}s(wp,"isEexistError");function Sk(e,t){Xi(_o(e),{recursive:!0}),Sp(e,`${JSON.stringify(t,null,2)}
38
- `,{encoding:"utf8",flag:"wx"})}s(Sk,"writeInstallationRecordExclusive");function dp(e,t){try{return Sk(e,t),t}catch(n){if(!wp(n))throw n;return Ut(e)}}s(dp,"tryCreateInstallationRecord");function Yi(e,t){Xi(_o(e),{recursive:!0}),ae(e,`${JSON.stringify(t,null,2)}
39
- `)}s(Yi,"replaceInstallationRecord");function pp(e,t,n){return{installation_id:e,...t&&t===e?{pinned:!0}:{},...n?.cursorCloudSeed==="v2"&&n.id===e?{cursor_cloud_seed:"v2"}:{}}}s(pp,"newInstallationRecord");async function Np(e,t={}){let n=t.home??Xn(),r=t.env??process.env,o=await gk(e,{cachePath:fn(n)}),i=nk(n),c={sessionId:t.sessionId,hostname:G(r.HOSTNAME)??void 0,osUser:G(r.USER)??G(r.LOGNAME)??G(r.USERNAME)??void 0,env:r},a=gr(c),u=Ap(t.overrideId,r),f=await pk(a,a==="cursor_cloud"&&Zo(c),r,e,n),l=f?.id??null,p=Ut(i);if(p){let y=p;u&&u===p.installation_id&&p.pinned!==!0&&(y={...p,pinned:!0},Yi(i,y)),f?.cursorCloudSeed==="v2"&&f.id===y.installation_id&&y.cursor_cloud_seed!=="v2"&&(y={...y,cursor_cloud_seed:"v2"},Yi(i,y));let b=y.cursor_cloud_seed==="v2"&&f?.cursorCloudSeed!=="v2";if(!!l&&l!==y.installation_id&&!u&&y.pinned!==!0&&!b&&ok(y.installation_id)&&l){let N={installation_id:l,...y.platform_agent_ids?{platform_agent_ids:y.platform_agent_ids}:{},...f?.cursorCloudSeed==="v2"?{cursor_cloud_seed:"v2"}:{}};return Yi(i,N),sp(n),{installationId:l,storePath:i,repoKey:o}}return{installationId:y.installation_id,storePath:i,repoKey:o}}let d=u??l??fp(void 0,r),m=dp(i,pp(d,u,f));if(m)return{installationId:m.installation_id,storePath:i,repoKey:o};let g=u??l??fp(void 0,r),h=dp(i,pp(g===d?Rp():g,u,f));if(h)return{installationId:h.installation_id,storePath:i,repoKey:o};throw new Error(`Failed to create installation record at ${i}`)}s(Np,"resolveOrCreateInstallationId");import{existsSync as Ck}from"node:fs";import{existsSync as Ek}from"node:fs";import{resolve as Zi}from"node:path";function Te(e){return Zi(e).replaceAll("\\","/").replace(/\/$/,"")}s(Te,"posixAbs");function Ht(e,t){let n=new Set(t),r=[];for(let o of e)n.delete(o)&&r.push(o);for(let o of[...n].sort())r.push(o);return r}s(Ht,"uniqueOrderedRoots");function So(e,t){if(!e)return t;let n=`${e}/`,r=[],o=[];for(let i of t)i===e||i.startsWith(n)?r.push(i):o.push(i);return r.length===0?t:[...r,...o]}s(So,"preferMarkerDirRoots");var yk=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function qn(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!yk.test(t)?null:t}s(qn,"sanitizeComponentRelativePath");function dn(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let i=Te(o);n.has(i)||(n.add(i),r.push(i))}return r}s(dn,"projectAnchors");function Rk(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}s(Rk,"isInside");function ot(e,t,n,r=Ek){for(let o of e)for(let i of t){let c=Te(Zi(o,i)),a=Zi(o,i,n).replaceAll("\\","/");if(Rk(c,a)&&r(a))return a}return null}s(ot,"firstExistingUnderRoots");var Mp=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/|\.github\/|\.copilot\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Lp=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,Ak=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,Pp=new Set(["applications","app","bin","boot","data","dev","etc","home","lib","media","mnt","node_modules","opt","pkg","private","proc","projects","repos","run","sbin","src","srv","sys","tmp","usr","users","var","volumes","workspace","workspaces"]),bk=/^[a-z][a-z0-9-]{1,63}$/,Ok=[".cursor/skills",".claude/skills",".agents/skills"],kk=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],xk=Ht(Ok,_t(Object.values(gt)).skills),Ik=Ht(kk,_t(Object.values(en)).skills),Tk=new Set(["read","read_file","view"]),wk=new Set(["bash","shell","zsh"]);function Qi(e){let t=e.replace(/\\/g,"/");return Mp.exec(t)?.[1]??null}s(Qi,"skillIdFromSkillMdPath");function Nk(e){let t=e.replace(/\\/g,"/"),r=Lp.exec(t)?.[1];return r?r.toLowerCase():null}s(Nk,"skillIdFromCodexCommandPath");function Pk(e){return Qi(e)??Nk(e)}s(Pk,"skillIdFromReferencedPath");function Mk(e){for(let t of["path","file_path","target_file"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}return null}s(Mk,"pathFromToolInputRecord");function Eo(e){return typeof e=="string"?Eo(Oe(e,null)):!e||typeof e!="object"?null:Mk(e)}s(Eo,"pathFromToolInput");function vp(e){if(typeof e=="string")return vp(Oe(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}s(vp,"commandFromToolInput");function ec(e){let t=vp(e.tool_input);if(t)return t;let n=At(e.command);return n.length>0?n:null}s(ec,"commandFromHookInput");function Lk(e){let t=e.replace(/\\/g,"/"),n=Mp.exec(t);if(n?.[1])return n[1];let o=Lp.exec(t)?.[1];return o?o.toLowerCase():null}s(Lk,"skillIdFromShellCommand");function vk(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}s(vk,"toolNameFromHookInput");function tc(e){let t=Eo(e.tool_input)??At(e.file_path);return t.length>0?t:null}s(tc,"filePathFromHookInput");function Zn(e,t,n){let r=vk(e).toLowerCase();if(Tk.has(r)){let o=tc(e);return o?t(o):null}if(wk.has(r)){let o=ec(e);return o?n(o):null}return null}s(Zn,"nameFromReadOrShellHookInput");function Up(e){return Zn(e,Pk,Lk)}s(Up,"skillNameFromReadHookInput");function Uk(e){let t=new Set,n=[];for(let r of e.matchAll(Ak)){let o=r[1]?.toLowerCase();!o||t.has(o)||Hk(o)||(t.add(o),n.push(o))}return n}s(Uk,"extractSlashSkillNames");function Hk(e){let t=e.split("/")[0];return Pp.has(e)||t!==void 0&&Pp.has(t)}s(Hk,"isDeniedSlashId");function Hp(e){let t=e.skillId.toLowerCase();if(!bk.test(t))return null;let n=e.exists??Ck,r=`${t}/SKILL.md`,o=ot(dn(e.launchCwd,e.gitRoot),xk,r,n);return o!==null?o:e.home?ot([Te(e.home)],Ik,r,n):null}s(Hp,"resolveSkillMdPath");function Dk(e){return At(e.prompt)}s(Dk,"promptFromHookInput");function Dp(e){let t=$(e,"command_name");if(t){let r=$(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=Dk(e);return n?Uk(n):[]}s(Dp,"skillNamesFromHookInput");var nc=He(je(),1);import{existsSync as $k}from"node:fs";var Dt={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode",copilot:".github"};function Qn(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}s(Qn,"normalizePathSlug");function Fk(e){if(!e)return"";let t=Cn(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return Qn(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return Qn(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?Qn(o[1]):Qn(t)}s(Fk,"normalizeGitRemoteToSlug");async function yo(e=process.cwd()){let t=await we("git",["rev-parse","--is-inside-work-tree"],2e3,{cwd:e});if(!t.ok||t.stdout!=="true")return null;let[n,r,o,i]=await Promise.all([we("git",["remote","get-url","origin"],2e3,{cwd:e}),we("git",["branch","--show-current"],2e3,{cwd:e}),we("git",["rev-parse","HEAD"],2e3,{cwd:e}),we("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?Cn(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:i.ok?i.stdout.length>0:null}}s(yo,"gitSnapshot");async function Fp(e,t,n,r=process.cwd(),o,i,c){if(t)return t;let a=Dt[n];if(!a)return"";let u=Ep(n,e.scope_path,c);if(i){let g=Ip(i,u);if(g)return g}let f=o??await yo(r),l=f?.remote?Fk(f.remote):"";if(l||(l=Qn(process.env.GITHUB_REPOSITORY??"")),!l)return"";let p=e.scope_path??"",d=p?`${p}/`:"",m=`${l}:${d}${a}`;return i&&Tp(i,u,m),m}s(Fp,"derivePlatformAgentId");var jk=[".cursor/rules",".claude/rules",".codex/rules"],Bk=_t(Object.values(gt)).rules;function Kk(e){return Ht(So(e?Dt[e]:void 0,jk),Bk)}s(Kk,"ruleRootsForRunner");var Gk=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules)|\.github\/instructions\/[^'"\s]+?\.instructions\.md)\b/i;function $p(e){let t=qn(e.relativePath);if(!t)return null;let n=e.exists??$k,r=dn(e.launchCwd,e.gitRoot),o=Kk(e.runnerPlatform),i=ot(r,o,t,n);if(i!==null)return i;if(!t.includes("/")){let c=ot(r,["."],t,n);if(c!==null)return c}return e.home?ot([Te(e.home)],o,t,n):null}s($p,"resolveRuleMdPath");function Vk(e){let t=e.replace(/\\/g,"/"),r=Gk.exec(t)?.[1];return r?(0,nc.nativeKeyForRulePath)(r):null}s(Vk,"ruleNameFromShellCommand");function jp(e){return Zn(e,nc.nativeKeyForRulePath,Vk)}s(jp,"ruleNameFromReadHookInput");function Bp(e){return e.replace(/\.(mdc|md|rules)$/i,"")}s(Bp,"stripRuleExtension");function Kp(e){let t=e.attachments;if(!Array.isArray(t))return[];let n=new Set,r=[];for(let o of t){if(!o||typeof o!="object"||Array.isArray(o))continue;let i=o;if(i.type!=="rule")continue;let c=typeof i.file_path=="string"?i.file_path:"",a=qn(c);!a||n.has(a)||(n.add(a),r.push(a))}return r}s(Kp,"ruleAttachmentPathsFromHookInput");var rc=He(je(),1);import{existsSync as zk}from"node:fs";var Wk=[".cursor/commands",".claude/commands",".codex/prompts"],Jk=_t(Object.values(gt)).commands;function Yk(e){return Ht(So(e?Dt[e]:void 0,Wk),Jk)}s(Yk,"commandRootsForRunner");var Xk=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc)|\.github\/prompts\/[^'"\s]+?\.prompt\.md)\b/i,qk=".github/prompts";function Zk(e,t){return e===qk?`${t}.prompt.md`:`${t}.md`}s(Zk,"commandFileName");function Gp(e){let t=qn(e.commandId);if(!t)return null;let n=e.exists??zk,r=Yk(e.runnerPlatform),o=s(c=>{for(let a of c)for(let u of r){let f=ot([a],[u],Zk(u,t),n);if(f!==null)return f}return null},"probe"),i=o(dn(e.launchCwd,e.gitRoot));return i!==null||!e.home?i:o([Te(e.home)])}s(Gp,"resolveCommandMdPath");function Qk(e){let t=e.replace(/\\/g,"/"),r=Xk.exec(t)?.[1];return r?(0,rc.nativeKeyForCommandPath)(r):null}s(Qk,"commandNameFromShellCommand");function Vp(e){return Zn(e,rc.nativeKeyForCommandPath,Qk)}s(Vp,"commandNameFromReadHookInput");var Ro=He(je(),1);function zp(e,t){if($(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}s(zp,"cursorShapedPayload");function ex(){return!!(F("CURSOR_VERSION")??F("CURSOR_PROJECT_DIR"))}s(ex,"isCursorHostEnv");function Wp(e,t,n){return e!=="claude"&&e!=="codex"?!1:zp(t,n)?!0:ex()}s(Wp,"shouldSuppressForeignRunnerOnCursorHost");var tx=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function pn(e,t,n,r){return r==="copilot"?"copilot":zp(e,t)?"cursor":Cr(r)?r:Cr(n)?n:$(e,"turn_id")?"codex":$(e,"session_id")||tx.has(t.toLowerCase())?"claude":"unknown"}s(pn,"detectRunnerPlatform");function Co(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}s(Co,"isInProcessEvent");function nx(e){switch(e){case"sessionstart":return"session_start";case"stop":case"sessionend":case"stopfailure":return"session_end";case"pretooluse":case"posttooluse":case"posttoolusefailure":case"permissiondenied":case"beforemcpexecution":case"beforeshellexecution":case"aftershellexecution":case"beforereadfile":case"afterfileedit":case"subagentstart":case"subagentstop":return"tool_invoked";case"beforesubmitprompt":case"userpromptexpansion":case"userpromptsubmit":case"userpromptsubmitted":return"skill_invoked";default:return""}}s(nx,"mapRunnerEventToInternal");function Jp(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="userpromptsubmitted"||t==="beforesubmitprompt"}s(Jp,"isPromptSubmitRunnerEvent");function Yp(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}s(Yp,"suppressesSlashIds");function Xp(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}s(Xp,"toolSuccessFromRunnerEvent");function mn(e){return $(e,"session_id")||$(e,"conversation_id")}s(mn,"sessionIdFromHookInput");function oc(e){return $(e,"prompt.id")||$(e,"prompt_id")||$(e,"generation_id")||$(e,"turn_id")}s(oc,"turnIdFromHookInput");function sc(e){return $(e,"hook_event_name")||$(e,"event")}s(sc,"runnerEventFromHookInput");function qp(e,t,n){let r=mn(e),o=oc(e),i=sc(e),c=$(e,"source"),a=pn(e,i,t,n);return{sessionId:r,turnId:o,runnerEvent:i,hookSource:c,runnerPlatform:a}}s(qp,"normalizeHookFields");var rx=["session_start","session_end","tool_invoked","skill_invoked"];function ox(e){return rx.includes(e)}s(ox,"isKnownInternalEvent");function Ao(e,t){return e&&ox(e)?e:nx(t.toLowerCase())}s(Ao,"resolveInternalEvent");var sx={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function bo(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}s(bo,"isMcpShapedToolName");function Zp(e,t=""){let n=$(e,"tool_name")||$(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!bo(n)&&(n=`MCP:${n}`):n=sx[r]??null;let o=e.tool_input,c=(o&&typeof o=="object"?At(o.skill)||At(o.skill_name):"")||$(e,"skill_name")||null,a=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;c??=Up(a);let u=jp(a),f=Vp(a);return{toolName:n,skillName:c,ruleName:u,commandName:f}}s(Zp,"extractToolNames");var ix=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function Qp(e){for(let t of["subagent_type","agent_type"]){let n=$(e,t);if(n&&ix.test(n))return n}return null}s(Qp,"extractSubagentType");function em(e){let t=Je(e,"duration_ms");if(typeof t=="number")return t;let n=Je(e,"duration");return typeof n=="number"?n:null}s(em,"extractDurationMs");var cx="error",ax="interrupted",ux="permission_denied",lx=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function er(e){return lx.test(e)?e:null}s(er,"categoricalValue");function fx(e){for(let t of["failure_type","error_type"]){let n=er($(e,t));if(n)return n}return null}s(fx,"structuredFailureClass");function tm(e,t){return Je(e,"is_interrupt")===!0?ax:t.toLowerCase()==="permissiondenied"?ux:fx(e)??cx}s(tm,"extractFailureClass");function nm(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}s(nm,"longestDeclaredServer");function dx(e,t){return nm(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}s(dx,"matchDeclaredMcpServer");function px(e,t){return nm(t,n=>(0,Ro.mcpServerNameMatchesToolSegment)(n,e))}s(px,"matchDeclaredMcpServerSegment");function mx(e,t){let n=null,r=0;for(let i of t)if(i)for(let c of(0,Ro.mcpServerToolSegmentForms)(i)){let a=`${c}__`;e.length>a.length&&e.slice(0,a.length).toLowerCase()===a.toLowerCase()&&c.length>r&&(n={mcpServer:i,mcpTool:e.slice(a.length)},r=c.length)}if(n!==null)return n;let o=/^(.+?)__(.+)$/.exec(e);return!o?.[1]||!o[2]?{mcpServer:null,mcpTool:null}:{mcpServer:px(o[1],t)??o[1],mcpTool:o[2]}}s(mx,"parseClaudeMcpNames");function gx(e,t){if(/^mcp__/i.test(e))return mx(e.slice(5),t);if(/^MCP:/i.test(e)){let n=e.slice(4);if(!n)return{mcpServer:null,mcpTool:null};let r=n.indexOf(":");if(r>0)return{mcpServer:n.slice(0,r),mcpTool:n.slice(r+1)||null};let o=n.indexOf("__");return o>0?{mcpServer:n.slice(0,o),mcpTool:n.slice(o+2)||null}:{mcpServer:dx(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}s(gx,"parseMcpNamesFromToolName");function _x(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}s(_x,"stripEncodedMcpServerPrefix");function rm(e,t=[],n=""){let r=e?gx(e,t):{mcpServer:null,mcpTool:null},o=er(n.trim());if(!o)return r;let i=r.mcpTool;return!i&&e&&!bo(e)&&(i=e),i&&(i=_x(i,o)),{mcpServer:o,mcpTool:i}}s(rm,"extractMcpNames");var im=3e4,Cx="claims",Ax=!0,bx=100,Ox=new Set(["sessionstart","sessionend","stopfailure"]),kx=["tool_name","tool","command","file_path","url"];function xx(e=sm()){return ic(Re(e),Cx)}s(xx,"eventClaimDir");function cm(e,t){try{let n=yx(e,"utf8").split(`
40
- `,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}s(cm,"claimAgeMs");function Ix(e){let t=[];for(let n of kx){let r=$(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":An(t.join("\0"))}s(Ix,"callFingerprintFromHookInput");function Tx(e){let t=e.sessionId.trim();if(!t)return;let n=e.runnerEvent.trim().toLowerCase(),r=e.turnId.trim(),o=e.toolUseId.trim(),i=e.subagentId?.trim()??"",c=e.callFingerprint?.trim()??"",a=!!(o||r||i),u=Ox.has(n);if(!a&&!u)return;let f=e.runnerPlatform.trim()||"unknown";return An(`${f}|${t}|${n}|${r}|${o}|${c}|${i}`)}s(Tx,"eventClaimKey");function wx(e,t=Date.now()){let n;try{n=Ex(e)}catch{return}let r=0;for(let o of n){if(r>=bx)break;r+=1;let i=ic(e,o),c=cm(i,t);if(!(!Number.isFinite(c)||c<im))try{om(i)}catch{}}}s(wx,"pruneStaleEventClaims");function Nx(e,t,n=Date.now()){let r=ic(t,e);try{if(hx(r)){let o=cm(r,n);if(Number.isFinite(o)&&o>=0&&o<im)return!1;try{om(r)}catch(i){if(!(i instanceof Error&&"code"in i&&i.code==="ENOENT"))return L("event_claim_steal",i),!0}}}catch{}try{Sx(t,{recursive:!0}),Rx(r,`${n}
41
- `,{encoding:"utf8",flag:"wx"})}catch(o){if(On(o))return!1;let i=o instanceof Error?o.message:String(o);return T(`WARN: event claim failed open: ${i}`),L("event_claim",o),!0}return wx(t,n),!0}s(Nx,"tryClaimHookEvent");function Px(e,t,n){let r=mn(e),o=oc(e),i=$(e,"tool_use_id"),c=$(e,"subagent_id")||$(e,"agent_id"),a=pn(e,t,void 0,n),u=Ix(e);return{runnerPlatform:a,sessionId:r,runnerEvent:t,turnId:o,toolUseId:i,subagentId:c,callFingerprint:u}}s(Px,"identityFromHookInput");function am(e,t,n,r=sm(),o=Date.now()){if(!Ax)return!0;let i=Tx(Px(e,t,n));if(!i)return!0;let c=Nx(i,xx(r),o);return!c&&F("EV_AI_HOOK_DEBUG")&&T(`DEBUG: duplicate hook event suppressed (claim ${i.slice(0,8)}\u2026)`),c}s(am,"claimHookEvent");import{mkdirSync as Mx,readFileSync as cc,statSync as dm,unlinkSync as pm,writeFileSync as ac}from"node:fs";import{homedir as mm}from"node:os";function gm(e){return e==="session_start"||e==="session_end"}s(gm,"isCapExemptEvent");var Oo=new Set,um=!1;function uc(e=mm()){return ka(e)}s(uc,"hookSlotDir");function lc(e,t=mm(),n=process.platform){if(e!==void 0)return e>0?e:Sr(n);let r=Q(bt(t),{});return Ha(r)??Sr(n)}s(lc,"maxConcurrentHookProcesses");function tr(e){return Rr(e.pid,e.acquiredAtMs)}s(tr,"slotContent");function _m(e){try{let t=dm(e);return t.isFile()&&t.size<=ns?cc(e,"utf8"):void 0}catch{return}}s(_m,"readSlotText");function fc(e,t=uc()){if(!e)return;let n=yr(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=_m(n);if(o===tr(r))return ko(r);if(o===Rr(process.ppid,e.acquiredAtMs))try{return ac(n,tr(r),{encoding:"utf8",mode:384}),ko(r)}catch{return}}s(fc,"adoptHookSlot");function hm(e,t){if(e.path){Oo.delete(e);try{_m(e.path)===tr(e)&&ac(e.path,Rr(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}s(hm,"handOffHookSlot");function Sm(e,t=Date.now()){let n,r;try{let o=dm(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=ns?cc(e,"utf8"):""}catch{return!1}return Ia(n,r,t)}s(Sm,"isSlotHeld");function Em(e,t=uc(),n=Date.now){for(let r=0;r<e;r+=1)if(!Sm(yr(t,r),n()))return!0;return e<=0}s(Em,"hasFreeHookSlot");function ym(e){return{pid:process.pid,acquiredAtMs:e}}s(ym,"noopSlot");function lm(e,t){let n=e instanceof Error?e.message:String(e);return T(`WARN: hook process slot failed open: ${n}`),L("slot",e),ym(t)}s(lm,"failOpen");function ko(e){return Oo.add(e),um||(um=!0,process.once("exit",()=>{for(let t of[...Oo])xo(t)})),e}s(ko,"hold");function fm(e){try{return ac(e.path,tr(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(On(t))return!1;throw t}}s(fm,"tryCreateSlot");function Rm(e,t=uc(),n=Date.now){if(e<=0)return ym(n());try{Mx(t,{recursive:!0})}catch(i){return lm(i,n())}let r,o=0;for(let i=0;i<e;i+=1)try{let c={path:yr(t,i),pid:process.pid,acquiredAtMs:n()};if(fm(c))return ko(c);if(Sm(c.path,n())){o+=1;continue}try{pm(c.path)}catch(a){if(!Gt(a))throw a}if(c.acquiredAtMs=n(),fm(c))return ko(c);o+=1}catch(c){r??=c}return r!==void 0&&o>0&&L("slot",r),r===void 0||o>0?null:lm(r,n())}s(Rm,"tryAcquireHookSlot");function xo(e,t=Date.now()){if(Oo.delete(e),!(!e.path||t-e.acquiredAtMs>=Er-kn))try{cc(e.path,"utf8")===tr(e)&&pm(e.path)}catch{}}s(xo,"releaseHookSlot");function dc(e){F("EV_AI_HOOK_DEBUG")&&T(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}s(dc,"logHookCapReached");import{closeSync as Lx,writeSync as vx}from"node:fs";function Cm(e=process.env){let t=e[es];if(delete e[es],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{vx(n,ga)}catch{}try{Lx(n)}catch{}}}s(Cm,"signalLauncherReady");function pc(e=process.env){let t=e[la];if(t)return{launcherVersion:t,hookSource:e[fa]??"",fallbackReason:e[da],launcherScope:e[pa]}}s(pc,"readLauncherContext");function Am(e,t){return(e?Ot(e):void 0)===t}s(Am,"launcherScopeMatch");import{readFileSync as Ux,statSync as Hx}from"node:fs";import{homedir as Dx}from"node:os";import{join as Fx}from"node:path";var $x="perf-prev.json",jx=512,Bx=1440*60*1e3,Kx=12e4,Gx=50,nr={},bm=!1;function gc(e){return Math.round(e*10)/10}s(gc,"round1");function ze(e,t){if(!Tn())return t();let n=performance.now();return t().finally(()=>{nr[e]=gc(performance.now()-n)})}s(ze,"span");function Vx(){for(let e of Object.keys(nr))delete nr[e]}s(Vx,"clearSpans");function km(){if(!Tn())return;let e=ou();e&&(process.env[us]=e)}s(km,"handOffHookTimings");function Om(e,t){if(!e)return;let n=t-e.origin;return n>=-Gx&&n<=Kx?e:void 0}s(Om,"trusted");function zx(e){if(e===null||typeof e!="object")return!1;let t=e;return typeof t.at=="number"&&Number.isFinite(t.at)&&typeof t.post_ms=="number"&&Number.isFinite(t.post_ms)&&t.post_ms>=0}s(zx,"isPrevPost");function xm(e=Dx()){return Fx(Re(e),$x)}s(xm,"perfPrevPath");function Wx(e,t){if(!bm){bm=!0;try{let n=xm(t);if(Hx(n).size>jx)return;let r=JSON.parse(Ux(n,"utf8"));return!zx(r)||e-r.at>Bx?void 0:{at:r.at,post_ms:r.post_ms}}catch{return}}}s(Wx,"takePrevPost");function _c(e,t){if(!Tn())return;let n={at:Date.now(),post_ms:Math.max(0,Math.round(e))};try{ae(xm(t),JSON.stringify(n))}catch{}}s(_c,"recordPostDuration");function mc(e,t,n,r,o=n.marks){let i=Math.max(0,n.origin-r);e[t]=gc(i);for(let[c,a]of Object.entries(o))e[c]=gc(i+a)}s(mc,"addProcess");function Im(e,t=process.env,n,r=!1){let o=r?Bc():void 0;if(!Tn())return o?{sys:o}:void 0;let i=nu(),c="w0"in i.marks?"w":"h",a=c==="w"?Om(ls(t[us]),i.origin):void 0,u=Om(ls(t[eu]),(a??i).origin),f=u?"l":a?"h":c,l=(u??a??i).origin,p={};u&&mc(p,"l",u,l),a&&mc(p,"h",a,l),mc(p,c,i,l,{...i.marks,...e});let d={base:f,t:p};c==="w"&&a&&p.h3!==void 0&&(d.ack_ms=p.h3),u?.values.bootstrap===1&&(d.bootstrap=!0),Object.keys(nr).length>0&&(d.spans={...nr},Vx());let m=Wx(Date.now(),n);return m&&(d.prev=m),o&&(d.sys=o),d}s(Im,"buildPerf");import{realpathSync as kw}from"node:fs";import{homedir as xw}from"node:os";var V=He(je(),1);import{existsSync as Jx,readFileSync as Tm}from"node:fs";import{homedir as wm}from"node:os";import{join as Yx}from"node:path";var Xx="cloud-cache.json",qx="cloud-cache-interactive.json",Zx=1440*60*1e3,Qx=900*1e3,eI=360*60*1e3;function tI(e=wm(),t){let n=t==="interactive"?qx:Xx;return Yx(Re(e),n)}s(tI,"cloudCachePath");function nI(e){if(!Jx(e))return;let t=Oe(Tm(e,"utf8"),{});if(!(typeof t.context!="string"||typeof t.probed_at!="number"||t.result!==null&&t.result!==void 0&&typeof t.result!="object"))return{context:t.context,probed_at:t.probed_at,result:t.result??null}}s(nI,"readCloudCache");function rI(e,t){try{ae(e,`${JSON.stringify(t)}
42
- `)}catch(n){let r=n instanceof Error?n.message:String(n);T(`WARN: cloud cache write failed open: ${r}`),L("cloud_cache",n)}}s(rI,"writeCloudCache");function oI(e,t,n){return!e||e.context!==t?!1:n-e.probed_at<sI(e)}s(oI,"isCacheValid");function sI(e){return e.result!==null?Zx:e.context==="interactive"?eI:Qx}s(sI,"cacheTtlMs");var iI="7783-7084-3265-9085-8269-3286-77",cI=/^i-[0-9a-f]{8,17}$/,Io="/sys/class/dmi/id";function aI(e){try{return Tm(e,"utf8").trim()}catch{return}}s(aI,"readSysfsText");function uI(e={}){if((e.platform??process.platform)!=="linux")return!1;let n=e.readFile??aI,r=s(o=>n(o)?.toLowerCase()??"","lower");return r(`${Io}/sys_vendor`)==="amazon ec2"||r(`${Io}/product_name`)==="google compute engine"||cI.test(r(`${Io}/board_asset_tag`))||r(`${Io}/chassis_asset_tag`)===iI?!0:r("/sys/hypervisor/uuid").startsWith("ec2")}s(uI,"hasCloudVmHint");async function lI(e){let t=await fetch("http://169.254.169.254/latest/api/token",{method:"PUT",headers:{"X-aws-ec2-metadata-token-ttl-seconds":"60"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=(await t.text()).trim();if(!n)return;let r={"X-aws-ec2-metadata-token":n},[o,i]=await Promise.all([fetch("http://169.254.169.254/latest/meta-data/placement/region",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{}),fetch("http://169.254.169.254/latest/meta-data/instance-id",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{})]);if(!o?.ok&&!i?.ok)return;let c=o?.ok?(await o.text()).trim():"",a=i?.ok?(await i.text()).trim():"";if(!(!c&&!a))return{provider:"aws",region:c,instance_id:a}}s(lI,"probeAws");async function fI(e){let t=await fetch("http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true",{headers:{"Metadata-Flavor":"Google"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=typeof n.zone=="string"?n.zone.split("/").pop()??"":"",o=n.id===void 0?"":String(n.id);if(!(!r&&!o))return{provider:"gcp",region:r,instance_id:o}}s(fI,"probeGcp");async function dI(e){let t=await fetch("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{headers:{Metadata:"true"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=n.compute?.location??"",o=n.compute?.vmId??"";if(!(!r&&!o))return{provider:"azure",region:r,instance_id:o}}s(dI,"probeAzure");async function pI(e){let t=await Promise.allSettled([lI(e),fI(e),dI(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}s(pI,"runCloudProbes");async function Nm(e,t){if(e==="interactive"&&!(t?.hasCloudHint??uI)())return null;let n=t?.home??wm(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),i=tI(n,e),c=nI(i);if(oI(c,e,o))return c.result;let a=await pI(r);return rI(i,{context:e,probed_at:o,result:a}),a}s(Nm,"probeCloud");var vm=He(je(),1);import{existsSync as Mm}from"node:fs";import{homedir as Lm}from"node:os";import{join as To,resolve as hc,sep as Pm}from"node:path";function Sc(e,t,n){if(!Mm(e))return;let r=Q(e,{});for(let[o,i]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:i})}s(Sc,"readMcpServers");function mI(e,t,n){if(!Mm(e))return;let r=Q(e,{}),o=hc(t),i=null;for(let a of Object.keys(r.projects??{})){let u=hc(a);(o===u||o.startsWith(u.endsWith(Pm)?u:u+Pm))&&(i===null||u.length>hc(i).length)&&(i=a)}if(i===null)return;let c=r.projects?.[i]?.mcpServers??{};for(let[a,u]of Object.entries(c))n.set(a,{declared:{name:a,source:"claude_json_project",sourcePath:".claude.json",scope:"user"},config:u})}s(mI,"readClaudeProjectMcpServers");function Um(e,t,n,r){let o=new Map;for(let c of e.mcp_servers??[])c.name&&o.set(c.name,{declared:{name:c.name,source:"manifest"}});n==="claude"?(Sc(To(r,".claude.json"),{source:"claude_json_user"},o),mI(To(r,".claude.json"),t,o)):n==="cursor"&&Sc(To(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o);let i=[[".mcp.json","mcp_json"],[".cursor/mcp.json","cursor_mcp"]];n!=="cursor"&&i.reverse();for(let[c,a]of i)Sc(To(t,c),{source:a},o);return o}s(Um,"collectMcpServers");async function Ec(e,t=process.cwd(),n="claude",r=Lm()){return[...Um(e,t,n,r).values()].map(o=>o.declared)}s(Ec,"mcpDeclared");function Hm(e,t,n=process.cwd(),r="claude",o=Lm()){let i=Um(t,n,r,o),c=i.get(e);if(c!==void 0)return c.config??null;for(let[a,u]of i)if((0,vm.mcpServerNameMatchesToolSegment)(a,e))return u.config??null;return null}s(Hm,"mcpServerConfig");var gI=["CI","GITHUB_ACTIONS","GITLAB_CI","CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER","KUBERNETES_SERVICE_HOST","REMOTE_CONTAINERS","DEVCONTAINER","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID","GITHUB_REF","GITHUB_SHA","GITHUB_RUN_ID","GITHUB_WORKFLOW","GITHUB_ACTOR","GITHUB_TRIGGERING_ACTOR","GITHUB_ACTOR_ID","GITHUB_USER","GITLAB_USER_LOGIN","GITLAB_USER_NAME","GITLAB_USER_EMAIL","BUILD_REQUESTEDFOR","BUILD_REQUESTEDFOREMAIL","BUILD_REQUESTEDFORID","BUILDKITE_BUILD_CREATOR","BUILDKITE_BUILD_CREATOR_EMAIL","BUILD_USER","BUILD_USER_ID","BUILD_USER_EMAIL","CHANGE_AUTHOR","CHANGE_AUTHOR_EMAIL","CIRCLE_USERNAME","CODEBUILD_INITIATOR","DRONE_COMMIT_AUTHOR","DRONE_COMMIT_AUTHOR_NAME","DRONE_COMMIT_AUTHOR_EMAIL","EV_AI_HOOK_OPERATOR_NAME","EV_AI_HOOK_OPERATOR_EMAIL","EV_AI_HOOK_OPERATOR_LOGIN","GIT_AUTHOR_NAME","GIT_AUTHOR_EMAIL","GIT_COMMITTER_NAME","GIT_COMMITTER_EMAIL","EMAIL","RUNNER_OS","RUNNER_ARCH","NODE_ENV","TERM_PROGRAM","CLAUDE_CODE_REMOTE","CLAUDE_CODE_REMOTE_SESSION_ID","CURSOR_AGENT","CURSOR_VERSION","CURSOR_CODE_REMOTE","CURSOR_USER_EMAIL","CODESPACES","CODESPACE_NAME","ANTHROPIC_BASE_URL","OPENAI_BASE_URL","OPENAI_API_BASE","AZURE_OPENAI_ENDPOINT","GOOGLE_GEMINI_BASE_URL","GEMINI_API_BASE","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX"],_I=["CURSOR_PROJECT_DIR"],hI=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function SI(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)hI.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}s(SI,"stripUrlUserinfo");function Dm(e=process.env){let t=gI.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:SI(e[r]??"")}:{name:r,present:!1}),n=_I.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}s(Dm,"readEnvVars");import{homedir as GI}from"node:os";import{homedir as jm}from"node:os";import{join as Fm}from"node:path";var EI="https://api.openai.com/auth";function gn(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(gn,"trimString");function Bm(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}s(Bm,"asJsonObject");function yI(e){let t=e.split(".");if(t.length!==3||t.some(r=>r.length===0))return null;let n=t[1];if(!n)return null;try{let r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"));return Bm(r)}catch{return null}}s(yI,"decodeJwtPayload");function $m(e,t,n){return gn(e[n])??gn(t?.[n])}s($m,"claim");function RI(e=process.env,t=jm()){let n=gn(e.CODEX_HOME)??Fm(t,".codex");return Fm(n,"auth.json")}s(RI,"codexAuthPath");function Km(e=process.env,t=jm()){let n=Q(RI(e,t),{}),r=gn(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&gn(n.OPENAI_API_KEY))return null;let o=gn(n.tokens?.id_token);if(!o)return null;let i=yI(o);if(!i)return null;let c=Bm(i[EI]),a=$m(i,c,"name"),u=$m(i,c,"email");return!u||pe(a,u)?null:{git_user_name:null,git_user_email:null,platform_login:u,identity_source:"codex_oauth"}}s(Km,"readCodexOperatorIdentity");import{homedir as Po}from"node:os";import{join as st}from"node:path";import{join as CI}from"node:path";var AI="cursor-ide-identity.json",bI=840*60*1e3;function Vm(e){return CI(Re(e),AI)}s(Vm,"cursorIdeIdentityCachePath");function Gm(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Gm,"nullableString");function zm(e){let t=Q(e,{}),n=t.read_at_ms,r=t.db_path;if(!(typeof n!="number"||!Number.isFinite(n)||typeof r!="string"))return{read_at_ms:n,db_path:r,email:Gm(t.email),auth_id:Gm(t.auth_id)}}s(zm,"readCursorIdeIdentityCache");function Wm(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<bI}s(Wm,"isCursorIdeIdentityCacheFresh");function Jm(e,t){try{ae(e,`${JSON.stringify(t)}
43
- `)}catch(n){let r=n instanceof Error?n.message:String(n);T(`WARN: cursor IDE identity cache write failed open: ${r}`),L("cursor_identity_cache",n)}}s(Jm,"writeCursorIdeIdentityCache");import{execFileSync as OI}from"node:child_process";import{existsSync as kI}from"node:fs";import{createRequire as xI}from"node:module";import{pathToFileURL as II}from"node:url";var Xm=xI(import.meta.url),wo=`
16
+ `}s(Pr,"slotRecord");function hs(e){let t=e===void 0?null:/^(\d+):(\d+)$/.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&Number.isSafeInteger(r)?{index:n,acquiredAtMs:r}:void 0}s(hs,"parseSlotRef");function Wc(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}s(Wc,"isPidAlive");var Zh=/^(\d+)\n(\d+)\n$/;function Qh(e){let t=Zh.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&n>0&&Number.isSafeInteger(r)?{pid:n,acquiredAtMs:r}:void 0}s(Qh,"parseSlotRecord");function Yc(e,t,n){let r=Qh(e);if(!r)return Math.abs(n-t)<Mn;let o=n-r.acquiredAtMs;return o<-Mn||o>=kr?!1:Wc(r.pid)}s(Yc,"isSlotRecordHeld");var eu=".claude/ev-ai-runtime-report.json",tu="config.json",rE="max_concurrent_hooks",GL=1024*1024,oE=new Set(["localhost","127.0.0.1","[::1]","::1"]),sE=["claude","cursor","codex","copilot","antigravity"],nu=[eu,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],Es=/^[A-Za-z0-9._~-]+$/;function Nr(e){return e!==void 0&&sE.includes(e)}s(Nr,"isKnownRunner");function ru(e){if(!e||typeof e!="object")return;let t=e[rE];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}s(ru,"maxConcurrentHooksFromConfig");function Jc(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}s(Jc,"parseCapArg");function qt(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}s(qt,"takeFlagValue");function Zt(e){let t,n,r,o,i,a,c;for(let u=0;u<e.length;u++){let f=e[u];if(f!==void 0){if(f==="--runner"){let l=qt(e,u);t=l.value,u=l.next;continue}if(f.startsWith("--runner=")){t=f.slice(9);continue}if(f==="--url"){let l=qt(e,u);l.value&&(r=l.value),u=l.next;continue}if(f.startsWith("--url=")){r=f.slice(6);continue}if(f==="--token"){let l=qt(e,u);l.value&&(o=l.value),u=l.next;continue}if(f.startsWith("--token=")){o=f.slice(8);continue}if(f==="--base-url"){let l=qt(e,u);l.value&&(i=l.value),u=l.next;continue}if(f.startsWith("--base-url=")){i=f.slice(11);continue}if(f===br){let l=qt(e,u);a=Jc(l.value)??a,u=l.next;continue}if(f.startsWith(`${br}=`)){a=Jc(f.slice(br.length+1))??a;continue}if(f===wn){let l=qt(e,u);c=hs(l.value)??c,u=l.next;continue}if(f.startsWith(`${wn}=`)){c=hs(f.slice(wn.length+1))??c;continue}f!==Mc&&!f.startsWith("-")&&n===void 0&&(n=f)}}return{runner:Nr(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:i,...a!==void 0?{cap:a}:{},...c!==void 0?{slot:c}:{}}}s(Zt,"parseHookArgv");function Ss(e,t){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}s(Ss,"buildCollectorUrl");function Lt(e=tE()){return nE(e,".ev-ai",tu)}s(Lt,"homeManifestPath");function ou(e,t){return{...e,...t}}s(ou,"mergeManifestOverlay");function Xc(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=32||n===127||n===39)return!0}return!1}s(Xc,"hasUnsafeCollectorUrlChars");function wr(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?oE.has(t.hostname):!1}catch{return!1}}s(wr,"isAllowedCollectorUrl");function ys(e){try{let n=new URL(e).pathname.split("/").filter(r=>r.length>0);if(n.length>=2&&n[n.length-1]==="hook"){let r=n[n.length-2];return r&&r.length>0?r:void 0}return}catch{return}}s(ys,"extractOrgTokenFromCollectorUrl");function Qt(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!wr(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=ys(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Es.test(n))return`org token must match ${Es.source}`;if(Xc(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(Xc(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}s(Qt,"collectorUrlProblem");function vn(e){return new URL(e).toString()}s(vn,"normalizeCollectorUrl");function su(e){return e.collector_url??""}s(su,"resolveCollectorUrl");function qc(e){let t=e?.repo_ingest_token;return!e?.collector_url&&typeof t=="string"&&t.trim().length>0}s(qc,"hasOnlyLegacyIngestToken");function en(e){try{let t=new URL(e),n=t.pathname.split("/").filter(r=>r.length>0);return n.length>=2&&n[n.length-1]==="hook"&&(n[n.length-2]="***",t.pathname=`/${n.join("/")}`),t.toString()}catch{return"<invalid-url>"}}s(en,"redactCollectorUrlForLog");function iu(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();if(o){let i=e.baseUrl?.trim();if(!i)return{problem:"--token needs --base-url",stop:!0};n=Ss(o,i)}}if(!n)return{};let r=Qt(n);return r?{problem:r}:{url:vn(n)}}s(iu,"collectorUrlFromArgv");var iE="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",aE="COLLECTOR_URL",Zc="collector_url_override",cE=[iE,aE];function uE(e){let t;for(let n of cE){let r=e[n]?.trim();if(!r)continue;let o=Qt(r);if(o){t??={problem:o,envName:n};continue}return{url:vn(r),envName:n}}return t??{}}s(uE,"collectorUrlFromPluginOption");function Qc(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=Qt(t);return n?{problem:n}:{url:vn(t)}}s(Qc,"candidateFromUnknown");function au(e){let t=[],n=Qc(e.homeConfig?.[Zc]);if(n.problem&&t.push({label:Zc,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=iu(Zt(e.argv));if(r.problem&&t.push({label:"--url/--token",problem:r.problem}),r.url)return{url:r.url,source:"argv",warnings:t};if(r.stop)return{source:"none",warnings:t};let o=uE(e.env);if(o.problem&&o.envName&&t.push({label:o.envName,problem:o.problem}),o.url)return{url:o.url,source:"plugin_option",warnings:t};let i=Qc(e.homeConfig?.collector_url);if(i.problem&&t.push({label:"collector_url",problem:i.problem}),i.url)return{url:i.url,source:"home_config",warnings:t};let a=e.manifest?su(e.manifest):"";if(!a&&(qc(e.homeConfig)||qc(e.manifest))&&t.push({label:"repo_ingest_token",problem:"needs collector_url"}),a){let c=Qt(a);if(c)t.push({label:"manifest collector_url",problem:c});else return{url:vn(a),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}s(au,"selectCollectorUrl");function Mt(e){if(Qt(e))return;let t;try{t=new URL(e)}catch{return}let n=ys(e);if(!n)return;let o=t.pathname.split("/").filter(c=>c.length>0).slice(0,-2),i=o.length>0?`/${o.join("/")}`:"",a=`${t.origin}${i}/${n}`;return eE("sha256").update(a).digest("hex").slice(0,32)}s(Mt,"scopeIdForCollectorUrl");var Lr=2;var tn="ev-ai-agent-hook";function lE(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}s(lE,"hookBinaryBasenameFromPath");function cu(e){let t=lE(e);return t===tn||t===`${tn}.exe`}s(cu,"isHookBinaryPath");var WL=`current/${tn}`,YL=`.ev-ai/agent-hook/${tn}`,uu=5e3,lu=5e3,Rs=3e3;var Mr=3e3,fu=1500,du=4*1024,Cs=256*1024,fE=4*1024,pu=32*1024,Qe="1.4.2",JL=`@ev-ai/agent-hook@${Qe}`;var mu={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT",copilot:"PLUGIN_ROOT",antigravity:"PLUGIN_ROOT"};var gu='{"continue":true}',dE='{"decision":"allow"}',pE="{}",mE=new Set(["pretooluse","stop"]);function vr(e){let t;try{t=Zt([...e])}catch{return gu}return t.runner!=="antigravity"?gu:mE.has((t.event??"").toLowerCase())?dE:pE}s(vr,"runnerAck");var As="antigravity";function me(e,t){let n=e[t];return typeof n=="string"&&n!==""?n:void 0}s(me,"stringField");function _u(e,t){let n=e[t];return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0}s(_u,"recordField");function gE(e){let t=e.workspacePaths;if(Array.isArray(t))return t.find(n=>typeof n=="string"&&n!=="")}s(gE,"firstWorkspacePath");function _E(e,t){let n=me(e,"hookEventName")??t??"",r=n.toLowerCase();return r==="posttooluse"&&me(e,"error")!==void 0?"PostToolUseFailure":r==="preinvocation"&&e.invocationNum===0?"UserPromptSubmit":n}s(_E,"antigravityEventName");var hE=new Set(["preinvocation","postinvocation"]);function Os(e){return hE.has(e.toLowerCase())}s(Os,"isAntigravityAckOnlyEvent");function EE(e){if(!e)return;let t={...e},n=me(e,"AbsolutePath")??me(e,"TargetFile")??me(e,"Path");n!==void 0&&t.file_path===void 0&&(t.file_path=n);let r=me(e,"CommandLine");return r!==void 0&&t.command===void 0&&(t.command=r),t}s(EE,"normalizedToolArgs");var SE=new Set(["call_mcp_tool","list_mcp_resources","read_mcp_resource"]),yE=/^mcp_(?!_)(.+)$/i;function RE(e,t){if(e===void 0)return{toolName:e};if(SE.has(e)){let r=t?me(t,"ServerName"):void 0;if(r===void 0)return{toolName:e};let o=e==="call_mcp_tool"&&t?me(t,"ToolName")??e:e;return{toolName:`mcp__${r}__${o}`,mcpServerName:r}}let n=yE.exec(e);return n?.[1]?{toolName:`MCP:${n[1]}`}:{toolName:e}}s(RE,"mcpToolShape");function CE(e,t){let n={},r=s((a,c)=>{c!==void 0&&(n[a]=c)},"set"),o=_E(e,t);r("hook_event_name",o===""?void 0:o),r("session_id",me(e,"conversationId")),r("cwd",me(e,"cwd")??gE(e)),r("transcript_path",me(e,"transcriptPath")),r("model",me(e,"modelName"));let i=_u(e,"toolCall");if(i){let a=_u(i,"args"),c=RE(me(i,"name"),a);r("tool_name",c.toolName),r("mcp_server_name",c.mcpServerName),r("tool_input",EE(a)),r("tool_use_id",me(i,"id"))}return r("error",me(e,"error")),r("stop_reason",me(e,"terminationReason")),o==="UserPromptSubmit"&&r("prompt",me(e,"lastUserInput")),n}s(CE,"adaptAntigravityHookInput");function hu(e,t,n){return t===As?CE(e,n):e}s(hu,"adaptRunnerHookInput");import{existsSync as Gk,mkdirSync as Vk,readdirSync as zk,readFileSync as Wk,unlinkSync as Bm,writeFileSync as Yk}from"node:fs";import{homedir as Km}from"node:os";import{join as Ia}from"node:path";import{createHash as Jp,randomBytes as CT}from"node:crypto";import{existsSync as Xp,mkdirSync as ha,readFileSync as qp,unlinkSync as Zp,writeFileSync as Qp}from"node:fs";import{homedir as or}from"node:os";import{dirname as Po,join as No,resolve as AT}from"node:path";var AE=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com","claude@anthropic.com","agent@cursor.local"]),OE=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function ge(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||OE.has(n)||r.includes("[bot]")||AE.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),i=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(i.endsWith("bot")||i.includes("[bot]"))return!0}return!1}s(ge,"isBotOperatorIdentity");import{homedir as bs}from"node:os";import{join as IE}from"node:path";function Eu(e=bs()){return IE(e,".claude.json")}s(Eu,"claudeUserConfigPath");function vt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(vt,"trimString");function Su(e=bs()){let n=J(Eu(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=vt(n.emailAddress),o=vt(n.fullName)??vt(n.displayName),i=vt(n.accountUuid),a=r??i;return!a||ge(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:a,identity_source:"claude_oauth"}}s(Su,"readClaudeOperatorIdentity");function yu(e=bs()){let n=J(Eu(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=vt(n.emailAddress),o=vt(n.fullName)??vt(n.displayName);return ge(o,r)?null:r?.toLowerCase()??null}s(yu,"readClaudeAccountKey");import{existsSync as dS,readFileSync as Ju,unlinkSync as pS}from"node:fs";import mS from"node:http";import{join as Xu}from"node:path";import{randomBytes as PE}from"node:crypto";import{appendFileSync as NE,mkdirSync as wE,readdirSync as LE,readFileSync as xs,renameSync as ku,statSync as Hn,unlinkSync as wu}from"node:fs";import{homedir as gt,tmpdir as ME}from"node:os";import{dirname as ks,join as Ut}from"node:path";var Au="EV_AI_PERF_L",Is="EV_AI_PERF_H",Un="EV_AI_RUN_ID",TE="EV_AI_HOOK_PERF";var kE=/^[a-z][a-z0-9_]{0,23}$/;var Ur={origin:0,marks:{},values:{}},Dr=!1;function Ou(e=process.env){Dr=e[TE]!=="0",Ur.origin=performance.timeOrigin}s(Ou,"startTimings");function Dn(){return Dr}s(Dn,"timingsActive");function et(e,t=performance.now()){Dr&&(Ur.marks[e]=t)}s(et,"mark");function bu(){return Ur}s(bu,"ownTimings");function Iu(e){return Math.round(e*10)/10}s(Iu,"round1");function Ru(e){return Object.entries(e).map(([t,n])=>`${t}=${Iu(n)}`).join(",")}s(Ru,"entries");function xE(e){return`${Iu(e.origin)}|${Ru(e.marks)}|${Ru(e.values)}`}s(xE,"serializeTimings");function Cu(e,t){if(!e)return!0;for(let n of e.split(",")){let r=n.indexOf("="),o=n.slice(0,r),i=Number(n.slice(r+1));if(r<1||!kE.test(o)||!(i>=0&&i<=36e5))return!1;t[o]=i}return Object.keys(t).length<=32}s(Cu,"parseEntries");function Ts(e){if(!e||e.length>1024)return;let[t,n,r,...o]=e.split("|"),i=Number(t);if(o.length>0||!Number.isFinite(i)||i<=0)return;let a={origin:i,marks:{},values:{}};if(!(!Cu(n,a.marks)||!Cu(r,a.values)))return a}s(Ts,"parseTimings");function Tu(){return Dr?xE(Ur):void 0}s(Tu,"serializeOwnTimings");var vE="hooks-debug.log",UE=/^hooks-debug\.log\.\d+$/,DE=/^hooks-debug\.log(\.1)?\.send-\d+$/,xu="ev-ai-agent-hooks.log",HE="EV_AI_HOOK_RUN_LOG",nn="unlimited",FE="off",Ps=1024*1024,$E=8*1024,Pu=Ps/2-$E,jE=10080*60*1e3,BE=1024*1024,KE="run-log-windows.json",GE=64*1024,Ns=/^[a-z0-9]{8}$/,Nu="abcdefghijklmnopqrstuvwxyz0123456789",VE=/[^A-Za-z0-9._:/+-]/g,zE=128,_t={info(){},error(){}},Pe=_t;function Fr(e=gt()){return Ut(e,".ev-ai",vE)}s(Fr,"fileLogPath");function Lu(e){try{let t=JSON.parse(Yt(xs(Ut(e,".ev-ai","config.json"),"utf8")));return Dt(t)?t:void 0}catch{return}}s(Lu,"readHomeConfig");function WE(e){return e?.debug===!0}s(WE,"debugFromHomeConfig");function ws(e,t=!1){return e.includes("--debug")||t}s(ws,"isHookDebugEnabled");function Dt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(Dt,"isRecord");function YE(e,t){let n=e?.log_until;if(typeof n!="string")return;let r=[];if(n===nn)return{on:!0,source:"local_config",scopes:r,localUntil:n};if(n===FE)return{on:!1,source:"local_config",scopes:r,localUntil:n};let o=Date.parse(n);return Number.isNaN(o)?void 0:{on:o>t,source:"local_config",scopes:r,localUntil:n}}s(YE,"localRunLog");function JE(e){if(!Dt(e)||!Dt(e.config))return;let t=e.config.log_until;if(typeof t!="string")return;if(t===nn)return{until:t,untilMs:Number.POSITIVE_INFINITY};let n=Date.parse(t);return Number.isNaN(n)?void 0:{until:t,untilMs:n}}s(JE,"scopeUntilMs");function Mu(e=gt(),t=process.env,n=Date.now()){return vu(e,()=>Lu(e),t,n)}s(Mu,"readRunLogSwitch");function vu(e,t,n,r){let o=n[HE]?.trim().toLowerCase();if(o&&Nt.has(o))return{on:!0,source:"env",scopes:[]};if(o&&Cr.has(o))return{on:!1,source:"env",scopes:[]};let i=YE(t(),r);if(i)return i;let a=[];try{let c=Ut(e,".ev-ai","agent-hook","hook-config.json"),u=Hn(c);if(!u.isFile()||u.size>BE)return{on:!1,source:"remote",scopes:a};let f=JSON.parse(xs(c,"utf8"));if(Dt(f))for(let[l,p]of Object.entries(f)){let d=JE(p);d&&d.untilMs>r&&a.push({scopeId:l,...d})}}catch{}return{on:a.length>0,source:"remote",scopes:a}}s(vu,"runLogSwitch");function Uu(e=gt()){return Ut(e,".ev-ai","agent-hook",KE)}s(Uu,"runLogWindowsPath");function Ls(e=gt()){try{let t=Uu(e),n=Hn(t);if(!n.isFile()||n.size>GE)return{};let r=JSON.parse(xs(t,"utf8")),o={};if(Dt(r))for(let[i,a]of Object.entries(r))typeof a=="string"&&(o[i]=a);return o}catch{return{}}}s(Ls,"readRunLogWindows");function Ms(e,t=gt()){try{let n=Ls(t),r={...n};if(e(r),JSON.stringify(r)===JSON.stringify(n))return;le(Uu(t),`${JSON.stringify(r,null,2)}
17
+ `)}catch{}}s(Ms,"updateRunLogWindows");function XE(e,t){Ms(n=>{for(let r of t)n[r.scopeId]=r.until},e)}s(XE,"recordRunLogWindows");function qE(e){return e.replace(/[\r\n]/g," ")}s(qE,"oneLine");function ZE(e){try{if(Hn(e).size<Pu)return;let t=`${e}.${process.pid}`;ku(e,t);try{ku(t,Hn(t).size>=Pu?`${e}.1`:e)}catch{wu(t)}}catch{}}s(ZE,"rotateIfFull");var QE=/\bhttps?:\/\/[^\s'"<>`]+/gi;function eS(e){try{let t=new URL(e);return`${t.protocol}//${t.host}${t.pathname.replace(/\/[^/]+\/hook(?![\w-])/,"/***/hook")}`}catch{return"<url>"}}s(eS,"redactUrl");function tS(e,t=gt()){let n=e.replace(QE,eS);return t.length>1?n.replaceAll(t,"~"):n}s(tS,"scrubForLog");function nS(e,t){try{wE(ks(e),{recursive:!0}),ZE(e),NE(e,t,{encoding:"utf8",mode:384})}catch{}}s(nS,"appendLine");function Du(e=process.argv,t=Fr(),n,r){oS();let o=gt(),i,a=!1,c=s(()=>(a||(i=Lu(o),a=!0),i),"readOnce"),u=ws(e,n??WE(c())),f=u||r!==void 0?void 0:vu(o,c,process.env,Date.now());if(!u&&!(r??f?.on)){Pe=_t;return}f?.source==="remote"&&XE(o,f.scopes);let l=s((p,d)=>{nS(t,`${new Date().toISOString()} ${p} ${tS(qE(d),o)}
18
+ `)},"write");Pe={info(p){l("info",p)},error(p){l("error",p)}}}s(Du,"initFileLogger");function Hu(){return Pe!==_t}s(Hu,"fileLoggerActive");var oe={info(e){Pe.info(e)},error(e){Pe.error(e)}},rS=new Set(["post_failed","timeout"]),de={},vs=!1;function oS(){de={},vs=!1}s(oS,"resetRunState");function Fu(){return vs}s(Fu,"runLineWritten");function ne(e){if(Pe===_t)return;if(e.outcome===void 0){de={...de,...e};return}if(de.outcome!==void 0&&rS.has(de.outcome)){de.err===void 0&&e.err!==void 0&&(de={...de,err:e.err});return}let{runner:t,event:n,session:r,tool:o,ackMs:i}=de;de={runner:t,event:n,session:r,tool:o,ackMs:i,...e}}s(ne,"noteRun");function ht(e){let t=Dt(e)?e.cause:void 0;for(let n of[t,e])if(Dt(n)&&typeof n.code=="string"&&n.code!=="")return n.code;return e instanceof Error?e.name:typeof e}s(ht,"runErrorKind");var sS=4096;function iS(e){return(e.stack??"").split(`
19
+ `).map(t=>t.trim()).filter(t=>t.startsWith("at ")).join(" | ")}s(iS,"stackFrames");function Fn(e){try{return aS(e).join(" ").slice(0,sS)}catch{return"err=unknown message=(unprintable)"}}s(Fn,"errorDetail");function aS(e){let t=[`err=${ht(e)}`];if(!(e instanceof Error))return t.push(`message=${String(e)}`),t;t.push(`message=${e.message}`);let n=iS(e);n&&t.push(`stack=${n}`);let r=e.cause;for(let o=0;r!==void 0&&o<3;o+=1)t.push(r instanceof Error?`cause=${cS(r)}`:`cause=${String(r)}`),r=r instanceof Error?r.cause:void 0;return t}s(aS,"errorParts");function cS(e){if(e instanceof AggregateError&&e.errors.length>0){let t=e.errors.map(n=>n instanceof Error?n.message:String(n));return`${e.name}: ${t.join("; ")}`}return`${e.name}: ${e.message}`}s(cS,"causeText");function M(e,t,n=process.env){if(Pe===_t)return;let r=n[Un],o=r!==void 0&&Ns.test(r)?` run=${r}`:"";Pe.error(`failed where=${e}${o} ${Fn(t)}`)}s(M,"logFailure");function uS(){let e="";for(let t of PE(8))e+=Nu[t%Nu.length];return e}s(uS,"newRunId");function $u(e=process.env){if(Pe===_t)return;let t=e[Un];if(t!==void 0&&Ns.test(t))return t;let n=uS();return e[Un]=n,n}s($u,"ensureRunId");function lS(e){if(typeof e=="number")return Number.isInteger(e)?String(e):e.toFixed(1);let t=e.replace(VE,"_").slice(0,zE);return t===""?"_":t}s(lS,"runValue");function rn(e,t,n,r=process.env){if(Pe===_t)return;vs=!0;let o=r[Un],a=[["run",o!==void 0&&Ns.test(o)?o:void 0],["p",e],["start",new Date(performance.timeOrigin).toISOString()],["v",t],["runner",de.runner],["event",de.event],["tool",de.tool],["session",de.session],["outcome",de.outcome??n],["ms",performance.now()],["ack_ms",de.ackMs],["post_ms",de.postMs],["http",de.http],["err",de.err]].filter(c=>c[1]!==void 0&&c[1]!=="").map(([c,u])=>`${c}=${lS(u)}`);Pe.info(`run ${a.join(" ")}`)}s(rn,"writeRunLine");function Hr(e,t){try{t-Hn(e).mtimeMs>jE&&wu(e)}catch{}}s(Hr,"unlinkIfStale");function ju(e=Date.now(),t=gt(),n=fS()){if(Pe!==_t)return;let r=Fr(t);Hr(r,e),Hr(`${r}.1`,e);try{for(let o of LE(ks(r)))(UE.test(o)||DE.test(o))&&Hr(Ut(ks(r),o),e)}catch{}Hr(n,e)}s(ju,"purgeStaleLog");function fS(e=process.platform){return e==="win32"?Ut(ME(),xu):Ut("/tmp",xu)}s(fS,"legacyLogPath");var gS="/run/cursor/api.sock",_S="owner/user-email",hS="owner/user-id",ES=400,Bu=25,SS=4096,yS="cursor-cloud-owner.json",RS="cursor-cloud-owner.miss.json",CS=1440*60*1e3,AS=600*1e3,OS=3600*1e3,bS=60*1e3,IS="/proc/sys/kernel/random/boot_id",TS=new Set([429,500,502,503,504]),kS=new Set(["ENOENT","ECONNREFUSED","EAGAIN"]);function xS(e=process.env){let t=e.CURSOR_AGENT_SOCKET?.trim();return t&&t.length>0?t:gS}s(xS,"cursorAgentSocketPath");function PS(e){return Xu(e,".ev-ai","agent-hook",yS)}s(PS,"cursorCloudOwnerCachePath");function NS(e){return Xu(e,".ev-ai","agent-hook",RS)}s(NS,"cursorCloudOwnerMissCachePath");function wS(e){let t=e.trim();if(t.length===0)return null;if(t.startsWith("{")||t.startsWith('"'))try{let n=JSON.parse(t);if(typeof n=="string")return jr(n);if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let r=n.value;return typeof r=="string"?jr(r):null}}catch{}return t}s(wS,"parseCursorMetadataBody");function jr(e){let t=e.trim();return t.length>0?t:null}s(jr,"nonEmpty");function LS(e){let t=Array.isArray(e)?e[0]:e;if(t===void 0)return null;let n=Number(t.trim());return Number.isFinite(n)&&n>=0?n*1e3:null}s(LS,"retryAfterMs");function MS(e,t,n){return new Promise(r=>{let o=!1,i=s(u=>{o||(o=!0,clearTimeout(c),r(u))},"finish"),a=mS.request({socketPath:e,host:"cursor-agent",path:`/v1/meta-data/${t}`,method:"GET",agent:!1},u=>{let f=[],l=0;u.on("data",p=>{if(l+=p.length,l>SS){a.destroy(),i({ok:!1,retryable:!1});return}f.push(p)}),u.on("end",()=>{i({ok:!0,response:{status:u.statusCode??0,body:Buffer.concat(f).toString("utf8"),retryAfterMs:LS(u.headers["retry-after"])}})}),u.on("error",()=>i({ok:!1,retryable:!1}))}),c=setTimeout(()=>{a.destroy(),i({ok:!1,retryable:!1})},n);a.on("error",u=>{i({ok:!1,retryable:kS.has(u.code??"")})}),a.end()})}s(MS,"requestOnce");function vS(e){if(e.status===200){let t=wS(e.body);return t?{kind:"value",value:t}:{kind:"not_found"}}return e.status===404?{kind:"not_found"}:e.status===403?{kind:"forbidden"}:TS.has(e.status)?"retry":{kind:"error"}}s(vS,"classify");function US(e){return new Promise(t=>setTimeout(t,e))}s(US,"delay");async function Ku(e,t,n){let r=n-Date.now();if(r<=0)return{kind:"error"};let o=await MS(e,t,r);if(!o.ok)return o.retryable?{kind:"retry",waitMs:Bu}:{kind:"error"};let i=vS(o.response);return i==="retry"?{kind:"retry",waitMs:o.response.retryAfterMs??Bu}:i}s(Ku,"attemptKey");async function Gu(e,t,n){let r=await Ku(e,t,n);if(r.kind!=="retry")return r;if(Date.now()+r.waitMs>=n)return{kind:"error"};await US(r.waitMs);let o=await Ku(e,t,n);return o.kind==="retry"?{kind:"error"}:o}s(Gu,"fetchCursorMetadataKey");async function DS(e,t=ES){let n=Date.now()+t,[r,o]=await Promise.all([Gu(e,_S,n),Gu(e,hS,n)]);if(r.kind==="forbidden"||o.kind==="forbidden")return{status:"forbidden",owner:null};if(r.kind==="error"||o.kind==="error")return{status:"error",owner:null};let i={userEmail:r.kind==="value"?r.value:null,userId:o.kind==="value"?o.value:null};return!i.userEmail&&!i.userId?{status:"empty",owner:null}:{status:"ok",owner:i}}s(DS,"fetchCursorCloudOwner");function $r(e){return typeof e=="string"?jr(e):null}s($r,"nullableString");var HS=new Set(["empty","forbidden","error"]);function qu(e){let t;try{t=JSON.parse(Ju(e,"utf8"))}catch{return}if(!(t===null||typeof t!="object"||Array.isArray(t)))return t}s(qu,"readJsonRecord");function Zu(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}s(Zu,"finiteNumber");function Vu(e){let t=qu(e),n=Zu(t?.checked_at_ms);if(!t||n===void 0)return;let r={checked_at_ms:n,boot_id:$r(t.boot_id),user_email:$r(t.user_email),user_id:$r(t.user_id)};return r.user_email??r.user_id?r:void 0}s(Vu,"readCursorCloudOwnerCache");function FS(e){let t=qu(e),n=Zu(t?.checked_at_ms),r=t?.status;if(!(!t||n===void 0)&&!(typeof r!="string"||!HS.has(r)))return{checked_at_ms:n,boot_id:$r(t.boot_id),status:r}}s(FS,"readCursorCloudOwnerMissCache");function zu(e,t){try{le(e,`${JSON.stringify(t)}
20
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);x(`WARN: cursor cloud owner cache write failed open: ${r}`),M("cursor_cloud_owner_cache",n)}}s(zu,"writeCacheFile");function $S(e){try{pS(e)}catch{}}s($S,"removeCacheFile");function jS(e){switch(e){case"empty":return AS;case"forbidden":return OS;default:return bS}}s(jS,"missTtl");function Qu(e,t,n){let r=t-e;return r>=0&&r<n}s(Qu,"ageWithin");function Wu(e,t,n){return e?.boot_id!==t||!e?null:{owner:{userEmail:e.user_email,userId:e.user_id},fresh:t!==null||Qu(e.checked_at_ms,n,CS)}}s(Wu,"sameBootOwner");function BS(e,t,n){return e?.boot_id!==t||!e?!1:Qu(e.checked_at_ms,n,jS(e.status))}s(BS,"isCursorCloudOwnerMissFresh");function KS(){try{return jr(Ju(IS,"utf8"))}catch{return null}}s(KS,"readLinuxBootId");var Yu=new Map;function Br(e){let t=e.env??process.env,n=xS(t),r=`${e.home}\0${n}`,o=Yu.get(r);if(o)return o;let i=GS(n,e).catch(a=>(M("cursor_cloud_owner",a),null));return Yu.set(r,i),i}s(Br,"resolveCursorCloudOwner");async function GS(e,t){let n=PS(t.home),r=NS(t.home),o=t.nowMs??Date.now(),i=(t.readBootId??KS)(),a=Wu(Vu(n),i,o);if(a?.fresh)return a.owner;if(BS(FS(r),i,o)||!dS(e))return a?.owner??null;let c=await DS(e,t.budgetMs);if(c.status==="ok"&&c.owner)return zu(n,{checked_at_ms:o,boot_id:i,user_email:c.owner.userEmail,user_id:c.owner.userId}),$S(r),c.owner;let u=Wu(Vu(n),i,o);return u?u.owner:(zu(r,{checked_at_ms:o,boot_id:i,status:c.status==="ok"?"empty":c.status}),null)}s(GS,"resolveUncached");import{existsSync as jI,readFileSync as Dp,unlinkSync as BI}from"node:fs";import{homedir as ma}from"node:os";import{join as _n,resolve as KI}from"node:path";import{basename as LI,join as gn}from"node:path";import{dirname as ul,resolve as zr}from"node:path";import{existsSync as VS}from"node:fs";import{homedir as nl}from"node:os";import{relative as rl,resolve as Ke,sep as Et}from"node:path";var zS=["session_id","conversation_id","turn_id","generation_id","prompt.id","prompt_id","hook_event_name","event","source","status","stop_reason","reason","tool_name","tool","tool_use_id","skill_name","command_name","expansion_type","command_source","permission_mode","model","model_id","agent_id","agent_type","subagent_id","subagent_type","subagent_model","is_parallel_worker","effort","effort.level","duration_ms","duration","sandbox","failure_type","is_interrupt"],WS=["prompt","tool_input","tool_response","last_assistant_message","command"],YS=new Set;function JS(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return YS}}s(JS,"excludedContentKeys");function $s(e){let t=j("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?Nt.has(t.toLowerCase()):e?.collect_prompt===!0}s($s,"isPromptCaptureEnabled");function Kr(e,t){let n=ol(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=j("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?Nt.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}s(Kr,"promptCaptureSource");function ol(e){return j("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||ws(process.argv,e.debug===!0)||j("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}s(ol,"hookInputCaptureMode");function XS(e){let t={};for(let n of zS){let r=Ze(e,n);r!==void 0&&(t[n]=r)}return t}s(XS,"allowlistedHookInput");function Gr(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Ke(e),r=Ke(t),o=rl(r,n);return!o||o==="."?".":o.startsWith(`..${Et}`)||o===".."||Ke(r,o)!==n?null:o.split(Et).join("/")}s(Gr,"cwdRelativeToGitRoot");function sl(e,t){let n=rl(Ke(t),Ke(e)).split(Et).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}s(sl,"specDirRelativeToCwd");function il(e){return typeof e!="string"||e.length===0?null:Ke(e).split(Et).join("/")}s(il,"absoluteCwdForSend");function qS(){let e=j("CURSOR_PROJECT_DIR");if(!e)return null;let t=Ke(e);return VS(t)?t.split(Et).join("/"):null}s(qS,"cursorProjectDirAbs");function Ds(e,t){return Gr(e,t)!==null}s(Ds,"isPathInside");function ZS(e,t){let n=Ke(t??nl(),".cursor").split(Et).join("/");return Ds(e,n)}s(ZS,"isCursorUserHookLaunch");function QS(e,t,n){return t!==null&&Ds(e,t)?!0:t!==null&&ZS(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&Ds(e,n.gitRoot)?!0:t===null}s(QS,"shouldKeepProcessCwd");function al(e,t){let n=il(e.cwd);if(n!==null)return n;let r=Ke(process.cwd()).split(Et).join("/"),o=qS();return QS(r,o,t)?r:o??r}s(al,"resolvedCwdForSend");function js(e,t={}){return al(e,t)}s(js,"resolveLaunchCwd");function Bs(e,t=nl()){let n=Ke(t).split(Et).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}s(Bs,"tildeHomeCwd");function el(e,t,n){let r=il(n.launchCwd)??al(t,n);e.cwd=Bs(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?Gr(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}s(el,"attachCwdFields");var cl="\u2026[truncated]\u2026",Hs=Buffer.byteLength(cl,"utf8"),ey=8;function $n(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s($n,"jsonByteLength");function tl(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}s(tl,"utf8Head");function ty(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(n.length-t).toString("utf8")}s(ty,"utf8Tail");function ny(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=Hs)return tl(e,t);let r=t-Hs,o=Math.ceil(r/2),i=Math.floor(r/2);return`${tl(e,o)}${cl}${ty(e,i)}`}s(ny,"truncateHeadTail");function Fs(e,t,n){if(typeof e=="string"){n.push({path:t,value:e,bytes:Buffer.byteLength(e,"utf8")});return}if(Array.isArray(e)){e.forEach((r,o)=>{Fs(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||Fs(o,[...t,r],n)}s(Fs,"collectStrings");function ry(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){let a=t[i];if(a===void 0)return;r=(Array.isArray(r),r[a])}let o=t[t.length-1];if(!(o===void 0||r===null||typeof r!="object")){if(Array.isArray(r)){r[o]=n;return}r[o]=n}}s(ry,"setAtPath");var oy=256;function sy(e,t,n){let r=n,o=Math.max(n,e[0]?.bytes??n);for(;r<o;){let i=Math.ceil((r+o)/2),a=0;for(let c of e)c.bytes>i&&(a+=c.bytes-i);a>=t?r=i:o=i-1}return r}s(sy,"stringBudgetFor");function iy(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let i=$n(e);if(i<=t)return;let a=[];Fs(e,[],a),a.sort((l,p)=>p.bytes-l.bytes);let c=a.filter(l=>l.bytes>n);if(c.length===0)return;let u=sy(c,i-t,n),f=Math.max(n,Math.min(u,r-1));if(f>=r)return;r=f;for(let l of c)l.bytes>r&&ry(e,l.path,ny(l.value,r))}}s(iy,"clampStringsToBudget");function ay(e,t){let n=Math.max(0,t-oy),r=Object.keys(e).filter(i=>!i.startsWith("_")).map(i=>({key:i,bytes:$n(e[i])})).sort((i,a)=>a.bytes-i.bytes),o=[];for(let{key:i}of r){if($n(e)<=n)break;delete e[i],o.push(i)}o.length>0&&(e._dropped_keys=o.slice(0,10))}s(ay,"dropLargestKeys");function Us(e,t){let n=$n(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,iy(r,t,Hs+ey),$n(r)>t&&ay(r,t),r}s(Us,"fitWithinByteLimit");function cy(e,t,n){if(!(n.promptCapture??$s()))return;let r=JS(n.runnerEvent);for(let o of WS){if(r.has(o))continue;let i=t[o];i!==void 0&&(e[o]=i)}}s(cy,"attachContentFields");function Vr(e,t,n={}){let r=ol(t);if(r==="full"){let i={...e};return delete i.cwd,delete i.transcript_path,el(i,e,n),Us(i,Cs)}let o=XS(e);return el(o,e,n),r==="content"?(cy(o,e,n),Us(o,Cs)):Us(o,du)}s(Vr,"sanitizeHookInput");function uy(e){return typeof e=="string"&&e.length>0}s(uy,"hasOrigin");function Ks(e){let t=zr(e.home),n=zr(e.launchCwd),r=e.gitRoot?zr(e.gitRoot):null,o=new Set,i=[],a=null;e.inGitRepo&&uy(e.remote)&&r!==null&&r!==t&&(a=r,o.add(r)),n!==t&&!o.has(n)&&(i.push({scope:"cwd",dir:n}),o.add(n)),a!==null&&i.push({scope:"repo",dir:a});let c=null,u=r!==null&&Gr(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&u){let f=ul(r);for(;;){let l=zr(f);if(l===t)break;let p=ul(l);if(p===l)break;if(e.hasProjectSpec(l)){i.push({scope:"parent",dir:l}),c=sl(l,n);break}f=p}}return{anchors:i,parentRel:c}}s(Ks,"resolveProjectAnchors");import{existsSync as fl,readdirSync as dy,realpathSync as py}from"node:fs";import{basename as my,dirname as gy,relative as _y,resolve as hy,sep as Ey}from"node:path";import{createHash as ly}from"node:crypto";import{resolve as fy}from"node:path";function q(e){return ly("sha256").update(e).digest("hex").slice(0,16)}s(q,"sha16");function Gs(e){return q(fy(e))}s(Gs,"dirScopeRef");function Ne(e,t){return`${e}\0${t}`}s(Ne,"componentKey");function Wr(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}s(Wr,"componentDeltaHash");function ll(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}s(ll,"parseComponentKey");function jn(e){let n=[...e].sort((r,o)=>{let i=r.path.localeCompare(o.path);return i!==0?i:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
21
+ `);return q(n)}s(jn,"hashUserSpec");var Vs=400,Yr=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??mt}static{s(this,"UserSpecContext")}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=hy(t).split(Ey).join("/");return Bs(r,this.home)}let n=_y(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${q(gy(t))}/${my(t)}`:n}claimFile(t){try{let n=py(t);return this.seenRealpaths.has(n)?!1:(this.seenRealpaths.add(n),!0)}catch{return this.seenRealpaths.has(t)?!1:(this.seenRealpaths.add(t),!0)}}get atGlobalCap(){return this.truncated||this.components.length>=this.maxEntries}get pluginBudgetSpent(){return this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0}readEntries(t){if(!fl(t))return[];try{return dy(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(fl(t))return J(t,n)}push(t){return this.components.length>=this.maxEntries?(this.truncated=!0,!1):this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0?!1:(this.pluginExpandRemaining!==void 0&&(this.pluginExpandRemaining-=1),this.components.push(t),!0)}withPluginExpandCap(t,n){let r=this.pluginExpandRemaining;this.pluginExpandRemaining=t;try{let o=n(),i=t-(this.pluginExpandRemaining??0);return{result:o,expanded:i}}finally{this.pluginExpandRemaining=r}}};import{existsSync as ui,readFileSync as jR,statSync as BR}from"node:fs";import{basename as li,join as $t,relative as fi}from"node:path";var Af=Ie(Cf());var FR=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],Of=FR.map(e=>Af.default.matcher(e,{dot:!0}));function $R(e){return e===""?!1:Of.some(t=>t(`${e}/`))}s($R,"isExcludedDirPath");function bf(e,t){if(t==="")return!1;if(e==="")return $R(t);let n=e.replace(/\/+$/,"");return Of.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}s(bf,"isExcludedDirBelow");var di=100*1024,KR=4;function GR(e){return e.length<=di?e:`${e.slice(0,di-1)}\u2026`}s(GR,"truncateContentText");function VR(e){try{let t=jR(e),n=t.toString("utf8");return{hash:q(t),length:t.length,text:GR(n)}}catch{return null}}s(VR,"readFileMeta");var If={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function zR(e){return e in If?If[e]:"UNSPECIFIED"}s(zR,"triggerForKind");function St(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=VR(t.absolutePath);if(!n)return!1;let r=t.name??li(t.absolutePath).replace(/\.(md|mdc|toml)$/i,""),o={kind:t.kind,name:r,path:e.componentPath(t.absolutePath),text:n.text,content_hash:n.hash,content_length:n.length,origin:t.origin,enabled:t.enabled},i=zR(t.kind);return i&&(o.trigger=i),t.attributes&&(o.attributes=t.attributes),e.push(o)}s(St,"addFile");function WR(e,t,n,r){let o=fi(e,t).replace(/\\/g,"/"),i=!o||o.startsWith("..")?li(t):o;return r&&i.toLowerCase().endsWith(r)?li(i).slice(0,-r.length):n||i!==o?i.replace(/\.(md|mdc|toml)$/i,""):o}s(WR,"nameFromWalkRoot");function ze(e,t){let{dir:n,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u}=t;pi(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u})}s(ze,"walkComponentDir");function pi(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l}=t;if(!(o>KR))for(let p of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(p.isDirectory()&&bf(n.replace(/\\/g,"/"),fi(n,$t(r,p.name)).replace(/\\/g,"/"))||p.isDirectory()&&l?.includes($t(r,p.name)))continue;if(u){if(!p.isDirectory())continue;let E=$t(r,p.name,u);if(ui(E)){let S=fi(n,$t(r,p.name)).replace(/\\/g,"/");St(e,{absolutePath:E,kind:i,origin:a,enabled:c,name:S||p.name});continue}pi(e,{walkRoot:n,currentDir:$t(r,p.name),depth:o+1,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l});continue}if(p.isDirectory()){pi(e,{walkRoot:n,currentDir:$t(r,p.name),depth:o+1,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l});continue}if(!p.isFile()||!f)continue;let d=p.name.toLowerCase();if(!f.some(E=>d.endsWith(E)))continue;let m=$t(r,p.name),g=f.find(E=>E.split(".").length>2&&d.endsWith(E));St(e,{absolutePath:m,kind:i,origin:a,enabled:c,name:WR(n,m,!0,g)})}}s(pi,"walkRecursive");function Tf(e){for(let t of e)if(ui(t))try{if(BR(t).size>0)return t}catch{continue}return e.find(t=>ui(t))}s(Tf,"firstExistingFile");import{existsSync as eC}from"node:fs";import{homedir as Pf}from"node:os";import{join as tC}from"node:path";import{existsSync as YR,readdirSync as kf}from"node:fs";import{homedir as to}from"node:os";import{join as Re}from"node:path";function JR(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return Re(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}s(JR,"claudeManagedSettingsDir");function XR(e=process.platform){let t=JR(e),n=[Re(t,"managed-settings.json")],r=Re(t,"managed-settings.d");try{if(!YR(r))return n;let o=kf(r).filter(i=>i.endsWith(".json")&&!i.startsWith(".")).sort().map(i=>Re(r,i));n.push(...o)}catch{}return n}s(XR,"listClaudeManagedSettingsFiles");function Wn(e=process.platform,t=to()){return{serverManaged:Re(t,".claude","remote-settings.json"),fileBased:XR(e)}}s(Wn,"claudeManagedSettingsSources");function qR(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return Re(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}s(qR,"cursorEnterpriseSettingsDir");function ZR(e=process.platform,t=to()){let n=[Re(qR(e),"hooks.json")],r=Re(t,".cursor","managed");try{for(let o of kf(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(Re(r,o.name,"hooks.json"))}catch{}return n}s(ZR,"listCursorManagedSettingsFiles");function QR(e=process.platform,t=to()){let n=e==="win32"?Re(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[Re(n,"requirements.toml")];return e!=="win32"&&r.push(Re(n,"managed_config.toml")),r.push(Re(t,".codex","managed_config.toml"),Re(n,"config.toml")),r}s(QR,"listCodexManagedSettingsFiles");function no(e,t=process.platform,n=to()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=Wn(t,n);return[r,...o]}case"cursor":return ZR(t,n);default:return QR(t,n)}}s(no,"managedSettingsFiles");function Nf(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}s(Nf,"hookParsableSettings");var nC={claude:{shared:{skillRoots:[".claude/skills"],dirs:[{dir:".claude/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".claude/commands",kind:"COMMAND",extensions:[".md"]},{dir:".claude/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["CLAUDE.md"],["CLAUDE.local.md"],[".claude/CLAUDE.md"]],settings:[".claude/settings.json",".claude/settings.local.json",".claude/hooks.json"]},homeOnly:{mcpJson:[".claude.json"],plugins:"claude",managed:"claude"},projectOnly:{mcpJson:[".mcp.json","mcp.json"]}},cursor:{shared:{skillRoots:[".cursor/skills"],dirs:[{dir:".cursor/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".cursor/commands",kind:"COMMAND",extensions:[".md"]},{dir:".cursor/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["AGENTS.md"]],settings:[".cursor/hooks.json",".cursor/sandbox.json",".cursor/permissions.json"],mcpJson:[".cursor/mcp.json"]},homeOnly:{skillRoots:[".cursor/skills-cursor"],memory:[[".cursor/AGENTS.md"]],settings:[".cursor/cli-config.json"],plugins:"cursor",managed:"cursor"},projectOnly:{skillRoots:[".agents/skills"],settings:[".cursor/cli.json"]}},codex:{shared:{skillRoots:[".agents/skills",".codex/skills"],dirs:[{dir:".codex/agents",kind:"SUBAGENT",extensions:[".toml",".md"]},{dir:".codex/prompts",kind:"COMMAND",extensions:[".md"]},{dir:".codex/rules",kind:"RULE",extensions:[".md",".rules"]}],memory:[["AGENTS.override.md","AGENTS.md"]],settings:[".codex/hooks.json",".codex/config.toml"],mcpToml:[".codex/config.toml"]},homeOnly:{memory:[[".codex/AGENTS.override.md",".codex/AGENTS.md"]],managed:"codex"}},copilot:{shared:{skillRoots:[".claude/skills",".agents/skills"],dirs:[{dir:".github/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".github/prompts",kind:"COMMAND",extensions:[".prompt.md"]},{dir:".github/instructions",kind:"RULE",extensions:[".instructions.md"]},{dir:".copilot/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".copilot/instructions",kind:"RULE",extensions:[".instructions.md"]}],memory:[],settings:[]},homeOnly:{skillRoots:[".copilot/skills"],memory:[[".copilot/copilot-instructions.md"]],settings:[".copilot/config.json"],mcpJson:[".copilot/mcp-config.json"]},projectOnly:{skillRoots:[".github/skills"],memory:[[".github/copilot-instructions.md"],["AGENTS.md"],["CLAUDE.md"],[".claude/CLAUDE.md"]],settings:[".github/copilot/settings.json"],mcpJson:[".github/mcp.json",".vscode/mcp.json"]}},antigravity:{shared:{skillRoots:[],dirs:[{dir:".agents/rules",kind:"RULE",extensions:[".md"]},{dir:".agents/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".gemini/config/rules",kind:"RULE",extensions:[".md"]},{dir:".gemini/config/agents",kind:"SUBAGENT",extensions:[".md"]}],memory:[],settings:[]},homeOnly:{skillRoots:[".gemini/config/skills",".gemini/antigravity/skills",".gemini/antigravity-cli/skills",".gemini/skills"],memory:[[".gemini/GEMINI.md"],[".gemini/AGENTS.md"],[".gemini/config/GEMINI.md"],[".gemini/config/AGENTS.md"]],settings:[".gemini/config/hooks.json"],mcpJson:[".gemini/config/mcp_config.json"],plugins:"antigravity"},projectOnly:{skillRoots:[".agents/skills"],memory:[["AGENTS.md"],["GEMINI.md"],[".agents/AGENTS.md"],[".agents/GEMINI.md"]],settings:[".agents/hooks.json"],mcpJson:[".agents/mcp_config.json"]}}};function xf(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}s(xf,"concatOptional");function rC(e,t={}){let{shared:n}=e;return{skillRoots:[...n.skillRoots,...t.skillRoots??[]],dirs:n.dirs,memory:[...n.memory,...t.memory??[]],settings:[...n.settings,...t.settings??[]],mcpJson:xf(n.mcpJson,t.mcpJson),mcpToml:xf(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}s(rC,"layoutForScope");function wf(e){return Object.fromEntries(Object.entries(nC).map(([t,n])=>[t,rC(n,n[e])]))}s(wf,"layoutsForScope");var an=wf("homeOnly"),Rt=wf("projectOnly");function oC(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}s(oC,"layoutRelativePaths");function sC(e,t){return oC(e).some(n=>eC(tC(t,n)))}s(sC,"layoutHasAnyEntry");function Lf(e,t){for(let n of e)if(sC(n,t))return!0;return!1}s(Lf,"anyLayoutHasAnyEntry");function yt(e){return[...new Set(e)]}s(yt,"uniqueRels");function Ct(e){let t=[],n=[],r=[],o=[],i=[],a=[],c=[];for(let u of e){t.push(...u.skillRoots);for(let f of u.dirs)f.kind==="SUBAGENT"?n.push(f.dir):f.kind==="COMMAND"?r.push(f.dir):o.push(f.dir);i.push(...u.memory.flat()),a.push(...u.settings),c.push(...u.mcpJson??[],...u.mcpToml??[])}return{skills:yt(t),subagents:yt(n),commands:yt(r),rules:yt(o),memory:yt(i),settings:yt(a),mcp:yt(c)}}s(Ct,"userScopePathsFromLayouts");function iC(e,t=Pf(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...no(o.managed,n,t));return yt(r)}s(iC,"managedSettingsFromLayouts");var At=Ct(Object.values(an));function Mf(e=Pf(),t=process.platform){return iC(Object.values(an),e,t)}s(Mf,"userScopeManagedSettings");import{existsSync as Ub,readFileSync as Db}from"node:fs";function nt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(nt,"isRecord");var ce=Ie(ke(),1);var BO=["package_name","package_spec","package_version","package_version_source"],Ld=100,Md=120,vd=new Set(ce.TOOL_LIST_RAW_KEYS.map(e=>e.attr)),KO=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],GO=new Set(["type","command","url","args","env","envVars","headers",...ce.ENABLED_RAW_KEYS,...KO,...ce.TOOL_LIST_RAW_KEYS.map(e=>e.raw)]),VO=new Set(["transport","command_or_url","args","env_var_names","headers_present","auth","bearer_token_env_var","default_tools_approval_mode","env_http_header_names",...BO,...vd,...[...vd].map(e=>`${e}_truncated`)]);function Ud(e,t){for(let n of t)GO.has(n)||VO.has(n)||(e[n]=ce.OMITTED_VALUE)}s(Ud,"addOmittedKeys");function Ui(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}s(Ui,"asRecord");function Dd(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}s(Dd,"stringList");function Li(e){if(Array.isArray(e)){let n=[];for(let r of e){if(typeof r!="string"||r.length===0)continue;let o=r.split("=",1)[0]?.trim();o&&n.push(o)}return n}let t=Ui(e);return t?Object.keys(t).filter(n=>n.length>0):[]}s(Li,"envNamesFromValue");function Di(e){return/[@\\]/.test(e)?ce.OMITTED_VALUE:(e.split(/[?#]/,1)[0]??"").trim()}s(Di,"redactUrlText");function zO(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,ce.launchContainsCredentials)({kind:"url",url:e})||(0,ce.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=(0,ce.redactArgs)([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,ce.launchContainsCredentials)({kind:"url",url:r}):!0)}s(zO,"rawLaunchHadCredentials");function Hd(e,t,n){zO(t,n)&&(e.launch_had_credentials=!0)}s(Hd,"markLaunchCredentials");function WO(e){let t=Dd(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Md?r.slice(0,Md):r))].sort();if(n.length!==0)return n.length>Ld?{names:n.slice(0,Ld),truncated:!0}:{names:n,truncated:!1}}s(WO,"toolNameList");function YO(e){let t=Ui(e);if(!t)return{headers:[],envVars:[]};let n=[],r=[];for(let[o,i]of Object.entries(t))o.length>0&&n.push(o),typeof i=="string"&&i.length>0&&r.push(i);return{headers:n,envVars:r}}s(YO,"envHeaderNames");function Fd(e,t){let n=new Set;for(let{raw:r,attr:o}of ce.TOOL_LIST_RAW_KEYS){if(n.has(o)||!(r in t))continue;let i=t[r];if(o==="auto_approve"&&typeof i=="boolean"){e.auto_approve=i,n.add(o);continue}let a=WO(i);a&&(e[o]=a.names,a.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}s(Fd,"applyToolListAttributes");function $d(e,t){let n=Ui(e),r={transport:t};if(!n)return r;Ud(r,Object.keys(n));let o=typeof n.command=="string"?n.command:void 0,i=typeof n.url=="string"?n.url:void 0,a=typeof n.serverUrl=="string"?n.serverUrl:void 0,c=o??i??a,u=Dd(n.args);c&&(r.command_or_url=(0,ce.redactCommandOrUrl)(c));let f=(0,ce.redactArgs)(u);f.length>0&&(r.args=f),Hd(r,c,u);let l=YO(n.env_http_headers),p=[...new Set([...Li(n.env),...Li(n.envVars),...Li(n.env_vars),...l.envVars,...typeof n.bearer_token_env_var=="string"&&n.bearer_token_env_var.length>0?[n.bearer_token_env_var]:[]])].sort();p.length>0&&(r.env_var_names=p),l.headers.length>0&&(r.env_http_header_names=[...new Set(l.headers)].sort());for(let E of["headers","http_headers","env_http_headers"])if(n[E]!==void 0&&n[E]!==null){r.headers_present=!0;break}let d=typeof n.auth=="string"?n.auth:void 0;d&&(r.auth=d);let m=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;m&&(r.bearer_token_env_var=m);let g=typeof n.default_tools_approval_mode=="string"?n.default_tools_approval_mode:typeof n.defaultToolsApprovalMode=="string"?n.defaultToolsApprovalMode:void 0;return g&&(r.default_tools_approval_mode=g),Fd(r,n),r}s($d,"sanitizeMcpServerAttributes");function Hi(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return q(JSON.stringify({name:e,attributes:r,enabled:n}))}s(Hi,"hashSanitizedMcpAttributes");function ln(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}s(ln,"parseTomlQuoted");function Zn(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*\\[([^\\]]*)\\]`,"m").exec(e);return n?.[1]?[...n[1].matchAll(/"([^"]*)"|'([^']*)'/g)].map(r=>r[1]??r[2]??"").filter(r=>r.length>0):[]}s(Zn,"parseTomlPlainStringArray");function vi(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}s(vi,"parseTomlBoolean");function Mi(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=ln(n[1]);return r.length>0?r:void 0}s(Mi,"parseTomlScalarString");function JO(e,t){let n=[],r=s(a=>{for(let c of a.split(/[,\n]/)){let u=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(c);u?.[1]&&n.push([u[1],ln(u[2]??"")])}},"collect"),o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let i=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
22
+ ${e}`);return i?.[1]&&r(i[1]),n}s(JO,"parseTomlMap");function jd(e){return vi(e,"enabled")===!1?!1:vi(e,"disabled")!==!0}s(jd,"mcpServerEnabledFromToml");function XO(e,t){let n={};for(let{raw:r,attr:o}of ce.TOOL_LIST_RAW_KEYS){if(o==="auto_approve"){let a=vi(t,r);if(a!==void 0){n[r]=a;continue}}let i=Zn(t,r);i.length>0&&(n[r]=i)}Fd(e,n)}s(XO,"applyToolListsFromToml");var qO=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,ZO=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function QO(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
23
+ `)){let i=qO.exec(o);i?.[1]&&t.add(i[1])}for(let o of e.matchAll(ZO))o[1]&&t.add(o[1]);return[...t]}s(QO,"tomlDeclaredKeys");function Bd(e,t){let n={transport:t};Ud(n,QO(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),i=r?ln(r[1]??""):void 0,a=o?ln(o[1]??""):void 0,c=i!==void 0&&i.length>0?i:a,u=Zn(e,"args");c&&(n.command_or_url=(0,ce.redactCommandOrUrl)(c));let f=(0,ce.redactArgs)(u);f.length>0&&(n.args=f),Hd(n,c,u);let l=new Set;for(let C of e.split(`
24
+ `)){let P=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(C);P?.[1]&&l.add(P[1])}let p=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(p?.[1])for(let C of p[1].split(",")){let P=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(C);P?.[1]&&l.add(P[1])}let d=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
25
+ ${e}`);if(d?.[1])for(let C of d[1].split(`
26
+ `)){let P=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(C);P?.[1]&&l.add(P[1])}for(let C of Zn(e,"env_vars"))l.add(C);let m=JO(e,"env_http_headers");for(let[,C]of m)C.length>0&&l.add(C);let g=Mi(e,"bearer_token_env_var");g&&(l.add(g),n.bearer_token_env_var=g),l.size>0&&(n.env_var_names=[...l].sort()),m.length>0&&(n.env_http_header_names=[...new Set(m.map(([C])=>C))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let E=Mi(e,"auth");E&&(n.auth=E);let S=Mi(e,"default_tools_approval_mode");return S&&(n.default_tools_approval_mode=S),XO(n,e),n}s(Bd,"parseTomlMcpSection");var Tt=Ie(ke(),1);var Le=Ie(ke(),1);import{createHash as xb}from"node:crypto";import{join as er}from"node:path";var We=Ie(ke(),1);import{realpathSync as Jd}from"node:fs";import{basename as dn,dirname as Qn,isAbsolute as yb,join as Gi,resolve as Xd,sep as Rb}from"node:path";var fn=Ie(ke(),1);import{closeSync as eb,constants as Kd,fstatSync as tb,openSync as nb,readSync as rb,statSync as ob}from"node:fs";import{dirname as Gd,join as Fi,relative as sb,sep as ib}from"node:path";var Vd="node_modules",ab=".yarn-state.yml",cb=".package-lock.json",Wd=16*1024*1024,ub=64,lb=Kd.O_RDONLY|(process.platform==="win32"?0:Kd.O_NONBLOCK);function _o(e,t){try{let n=ob(e);if(!n.isFile()||n.size>t)return null;let r=nb(e,lb);try{let o=tb(r);if(!o.isFile()||o.size>t)return null;let i=Buffer.alloc(o.size+1),a=0;for(;a<i.length;){let u=rb(r,i,a,i.length-a,null);if(u===0)break;a+=u}if(a>t)return null;let c=i.toString("utf8",0,a);return c.charCodeAt(0)===65279?c.slice(1):c}finally{eb(r)}}catch{return null}}s(_o,"readBoundedTextFile");function zd(e){if(!e.startsWith('"'))return null;try{let t=JSON.parse(e);return typeof t=="string"?t:null}catch{return null}}s(zd,"parseJsonString");var fb="1";function db(e){let t=new Map,n=null,r=!1,o=!1,i=null;for(let a of e.split(`
27
+ `)){let c=a.endsWith("\r")?a.slice(0,-1):a;if(c.trim().length===0||c.startsWith("#"))continue;if(!c.startsWith(" ")){if(!c.endsWith(":"))return null;let f=c.slice(0,-1);if(o=!1,r=f==="__metadata",r){n=null;continue}if(n=zd(f),n===null)return null;continue}if(c.startsWith(" - ")){if(o&&n!==null){let f=zd(c.slice(6));if(f===null)return null;let l=t.get(f)??[];l.push(n),t.set(f,l)}continue}let u=/^ {2}([A-Za-z_]+):(?: (.*))?$/.exec(c);if(u!==null){let[,f,l]=u;r&&f==="version"&&(i=l??null),o=!r&&f==="locations";continue}if(!c.startsWith(" "))return null}return i===fb?t:null}s(db,"parseYarnState");var pb=/^(?:virtual:[0-9a-f]+#)?npm:([^:#]+)(?:::__archiveUrl=[^&#]+)?$/;function mb(e){let t=e.indexOf("@",e.startsWith("@")?1:0);if(t<=0)return null;let n=e.slice(0,t),o=pb.exec(e.slice(t+1))?.[1];return(0,fn.packageNameFromSpec)(n)!==n||o===void 0||!(0,fn.isExactNpmVersion)(o)?null:{name:n,version:o}}s(mb,"yarnLocatorEvidence");function gb(e,t,n){let r;try{let i=new URL(e);if(i.protocol!=="https:"&&i.protocol!=="http:")return!1;r=decodeURIComponent(i.pathname)}catch{return!1}let o=t.slice(t.lastIndexOf("/")+1);return r.endsWith(`/${t}/-/${o}-${n}.tgz`)}s(gb,"isRegistryTarballUrl");function _b(e,t){if(e===null||typeof e!="object")return null;let{name:n,version:r,resolved:o,link:i,inBundle:a}=e;if(i===!0||a===!0)return null;let c=typeof n=="string"?n:t;return(0,fn.packageNameFromSpec)(c)!==c||typeof r!="string"||!(0,fn.isExactNpmVersion)(r)||typeof o!="string"||!gb(o,c,r)?null:{name:c,version:r}}s(_b,"npmEntryEvidence");function hb(e){let t;try{t=JSON.parse(e)}catch{return null}if(t===null||typeof t!="object")return null;let{packages:n}=t;return n===null||typeof n!="object"||Array.isArray(n)?null:new Map(Object.entries(n))}s(hb,"parseNpmHiddenLockfile");var $i=new Map,ji=new Map;function Eb(e){if(!$i.has(e)){let t=_o(e,Wd);$i.set(e,t===null?null:db(t))}return $i.get(e)??null}s(Eb,"yarnState");function Sb(e){if(!ji.has(e)){let t=_o(e,Wd);ji.set(e,t===null?null:hb(t))}return ji.get(e)??null}s(Sb,"npmHiddenLockfile");function Yd(e,t){let n=null,r=Gd(e);for(let o=0;o<ub;o+=1){let i=sb(r,e).split(ib).join("/");if(i.split("/").slice(0,-1).includes(Vd)){let c=Fi(r,Vd),u=[];for(let l of Eb(Fi(c,ab))?.get(i)??[])u.push(mb(l));let f=Sb(Fi(c,cb));f?.has(i)===!0&&u.push(_b(f.get(i),t));for(let l of u){if(l===null||n!==null&&(n.name!==l.name||n.version!==l.version))return null;n=l}}let a=Gd(r);if(a===r)break;r=a}return n}s(Yd,"registryInstallIdentity");var Ki="node_modules",Cb=1024*1024,Ab=16;function Ob(e,t){return e.startsWith("~/")||e.startsWith("~\\")?Gi(t,e.slice(2)):yb(e)?e:null}s(Ob,"absoluteLauncherPath");function bb(e){let t=e.split(Rb).join("/");return t.includes("/.yarn/")||/\.zip(?:\/|$)/i.test(t)}s(bb,"isYarnPnpPath");function Ib(e){let t=dn(e),n=Qn(e);if(dn(n)===Ki)return t.startsWith("@")?null:t;let r=dn(n);return r.startsWith("@")&&dn(Qn(n))===Ki?`${r}/${t}`:null}s(Ib,"nodeModulesPackageName");var Bi=new Map;function Tb(e){let t=Gi(e,"package.json");if(!Bi.has(t)){let n=_o(t,Cb),r=null;if(n!==null)try{let o=JSON.parse(n);r=o!==null&&typeof o=="object"&&!Array.isArray(o)?o:null}catch{r=null}Bi.set(t,r)}return Bi.get(t)??null}s(Tb,"readManifest");function kb(e){let t=Qn(e);for(let n=0;n<Ab;n+=1){if(dn(t)===Ki)return null;let r=Tb(t);if(r!==null&&typeof r.name=="string"){let{name:i,version:a}=r,c=Ib(t);if(c===null||(0,We.packageNameFromSpec)(i)!==i||typeof a!="string"||!(0,We.isExactNpmVersion)(a))return null;let u=Yd(t,c);return u?.name!==i||u.version!==a?null:{package_name:i,package_version:a,package_version_source:We.LOCAL_BIN_PACKAGE_VERSION_SOURCE}}let o=Qn(t);if(o===t)return null;t=o}return null}s(kb,"owningPackageIdentity");function qd(e,t){if(typeof e!="string"||e.length===0||(0,We.npxExecBin)(e)!==null||!(0,We.isNodeModulesBinCommand)(e))return null;try{let n=Ob(e,t);if(n===null)return null;let r=Jd(n),o=Gi(Jd(Qn(n)),dn(n));return Xd(r)===Xd(o)||bb(r)?null:kb(r)}catch{return null}}s(qd,"resolveLocalBinPackage");function Pb(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,Le.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}s(Pb,"packageVersionFields");function Nb(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
28
+ `);return xb("sha512").update(t).digest("hex").slice(0,16)}s(Nb,"npxCacheKey");function wb(e){let t=process.platform==="win32"?er(j("LOCALAPPDATA")??e,"npm-cache"):er(e,".npm"),n=j("npm_config_cache")??j("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}s(wb,"npmCacheRoots");function Zd(e){return typeof e=="string"&&e.length>0&&e.length<=Le.PACKAGE_FIELD_MAX?e:null}s(Zd,"usableVersion");function Lb(e,t,n){let r=Nb(e);for(let o of wb(n)){let i=er(o,"_npx",r),a=J(er(i,"node_modules",...t.split("/"),"package.json"),{}),c=Zd(a.version);if(c!==null)return c;let u=J(er(i,"package-lock.json"),{}),f=Zd(u.packages?.[`node_modules/${t}`]?.version);if(f!==null)return f}return null}s(Lb,"installedVersion");function Mb(e){return e.length<=Le.PACKAGE_FIELD_MAX?e:`${e.slice(0,Le.PACKAGE_FIELD_MAX-1)}\u2026`}s(Mb,"capField");function vb(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,Le.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let i=(0,Le.packageNameFromSpec)(o);return i===null?null:{package_name:i,package_spec:Mb(o),...Pb(o,Lb(r,i,n))}}s(vb,"resolveNpxPackage");function Vi(e,t,n){return vb(e,t,n)??qd(e,n)}s(Vi,"resolveMcpLaunchPackage");function Qd(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=(0,Le.tokenizeCommand)(e.trim());return n===void 0?null:Vi(n,r,t)}s(Qd,"resolveNpxPackageFromCommand");function ho(e,t){if(!e||typeof e!="object"||Array.isArray(e))return null;let n=e,r=Array.isArray(n.args)?n.args.filter(o=>typeof o=="string"):[];return Vi(typeof n.command=="string"?n.command:null,r,t)}s(ho,"npxPackageFromMcpConfig");function ep(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:Vi(ln(n[1]??""),Zn(e,"args"),t)}s(ep,"npxPackageFromTomlSection");function Hb(e){if(!e||typeof e!="object"||Array.isArray(e))return"unknown";let t=e;return typeof t.type=="string"&&t.type.length>0?t.type:typeof t.url=="string"||typeof t.serverUrl=="string"?"http":typeof t.command=="string"?"stdio":"unknown"}s(Hb,"mcpTransport");var Fb=64*1024;function Eo(e,t,n,r={}){let o=r.parentEnabled??!0;if(!e.claimFile(t))return;let i=e.readJson(t,void 0);if(!nt(i))return;let a=(0,Tt.mcpConfigFormatOf)(t),c=(0,Tt.mcpConfigServersKey)(a),u=i[c],f=u&&typeof u=="object"?u:{},l=e.componentPath(t),p=[];for(let[d,m]of Object.entries(f)){if(e.truncated)return;let g=Hb(m),E=$d(m,g);Object.assign(E,ho(m,e.home)??{});let S=o&&(0,Tt.mcpServerEnabledFromJson)(m),C=Hi(d,E,S);p.push([d,C]),e.push({kind:"MCP_SERVER",name:d,path:l,content_hash:C,origin:n,enabled:S,attributes:E})}e.truncated||a==="claude_json_slice"&&!Object.hasOwn(i,c)||Object.hasOwn(f,l)||$b(e,{parsed:i,format:a,pathRel:l,origin:n,serverHashes:p,enabled:o})}s(Eo,"collectMcpJson");function $b(e,t){let n=(0,Tt.sanitizeMcpConfigFile)(t.parsed,t.format,{home:e.home}),r=JSON.stringify(n,null,2),o=Buffer.byteLength(r,"utf8"),i=o>Fb,a=[...t.serverHashes].sort(([c],[u])=>c<u?-1:c>u?1:0);e.push({kind:"MCP_CONFIG",name:t.pathRel,path:t.pathRel,...i?{}:{text:r,content_length:o},content_hash:q(JSON.stringify({text:r,servers:a})),origin:t.origin,enabled:t.enabled,attributes:{format:t.format,server_count:t.serverHashes.length,...i?{text_omitted:"too_large"}:{}}})}s($b,"pushMcpConfigRow");function tp(e,t,n){if(!Ub(t)||!e.claimFile(t))return;let r;try{r=Db(t,"utf8")}catch{return}let o=e.componentPath(t),i=/^\[mcp_servers(?:\.(\w+)|\."([^"]+)"|\.'([^']+)')\]\s*$/gm,a;for(;(a=i.exec(r))!==null;){if(e.truncated)return;let c=a[1]??a[2]??a[3];if(!c)continue;let u=r.slice(a.index+a[0].length),f=u.search(/^\[mcp_servers(?:\.(?:\w+|"[^"]+"|'[^']+'))\]\s*$/m),l=f===-1?u:u.slice(0,f),p="unknown";/^\s*url\s*=/m.test(l)?p="http":/^\s*command\s*=/m.test(l)&&(p="stdio");let d=Bd(l,p);Object.assign(d,ep(l,e.home)??{});let m=jd(l);e.push({kind:"MCP_SERVER",name:c,path:o,content_hash:Hi(c,d,m),origin:n,enabled:m,attributes:d})}}s(tp,"collectCodexMcpToml");import{existsSync as lp,readdirSync as sI}from"node:fs";import{basename as iI,join as pe}from"node:path";import{existsSync as rp,readdirSync as jb}from"node:fs";import{join as yo,relative as Bb,resolve as np,sep as Kb}from"node:path";var Gb=".gemini/config/plugins",Vb=".gemini/config/config.json",zb=["plugin.json",".antigravity-plugin/plugin.json"],Wb=["mcp_config.json",".antigravity-plugin/mcp_config.json"],Yb="skills";function So(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(So,"isRecord");function Jb(e){for(let t of zb){let n=yo(e,t);if(rp(n)){let r=J(n,{});return So(r)?r:{}}}return{}}s(Jb,"readManifest");function op(e,t){let n=np(e),r=np(n,t),o=Bb(n,r);return o===""||!o.startsWith("..")&&!o.startsWith(Kb)&&o!==".."?r:null}s(op,"insidePlugin");function Xb(e,t){let n=J(yo(e,Vb),{}),r=So(n)?n.plugins:void 0,o=So(r)?r[t]:void 0,i=So(o)?o.enabled:void 0;return typeof i=="boolean"?i:void 0}s(Xb,"enabledFromConfig");function qb(e,t){let n=Array.isArray(t.skills)?t.skills.filter(o=>typeof o=="string"):typeof t.skills=="string"?[t.skills]:[Yb],r=[];for(let o of n){let i=op(e,o);i!==null&&!r.includes(i)&&r.push(i)}return r}s(qb,"skillRootsOf");function Zb(e,t){let n=typeof t.mcpServers=="string"?[t.mcpServers]:[...Wb],r=[];for(let o of n){let i=op(e,o);i!==null&&rp(i)&&!r.includes(i)&&r.push(i)}return r}s(Zb,"mcpConfigFilesOf");function Qb(e){try{return jb(e,{withFileTypes:!0}).filter(t=>t.isDirectory()).sort((t,n)=>t.name<n.name?-1:t.name>n.name?1:0)}catch{return[]}}s(Qb,"readPluginDirs");function pn(e){let t=yo(e,Gb);return Qb(t).map(n=>{let r=yo(t,n.name),o=Jb(r),i=Xb(e,n.name)??o.disabled!==!0;return{key:n.name,installPath:r,enabled:i,...typeof o.version=="string"&&o.version.length>0?{version:o.version}:{},skillRoots:qb(r,o),mcpConfigFiles:Zb(r,o)}})}s(pn,"listAntigravityPlugins");function sp(e,t){return`${e}_${t}`}s(sp,"antigravityPluginServerName");var kt=Ie(ke(),1);var eI=300,tI=256;function ip(e,t){if(!t)return e;let n=[...new Set([t,t.replace(/\\/g,"/")])].filter(o=>o.length>1),r=e;for(let o of n)r=r.split(o).join("~");return r}s(ip,"rewriteHomePrefix");function ap(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}s(ap,"capLength");function nI(e){return ap(e,eI)}s(nI,"capCommand");function cp(e,t){let n=ip(e.trim(),t),r=(0,kt.tokenizeCommand)(n);if(r.length===0)return"";let[o,...i]=r,a=(0,kt.redactCommandOrUrl)(o),c=(0,kt.redactArgs)(i);return nI([a,...c].join(" "))}s(cp,"sanitizeHookCommand");function up(e,t){if(typeof e!="string")return null;let n=ip(e.trim(),t),r=(0,kt.tokenizeCommand)(n)[0];if(!r)return null;let o=(0,kt.redactCommandOrUrl)(r);return o.length===0?null:ap(o,tI)}s(up,"executableFromCommand");function rI(e){if(e.prompt||e.type==="prompt")return"prompt";let t=e.command??e.bash??e.powershell??"";return/\bnpx\b/i.test(t)?"npx":/\.(sh|bash|zsh|js|mjs|cjs|ts|py)(\s|$|"|')/i.test(t)||/^(\.\/|~\/|\/|[A-Za-z]:[\\/])/.test(t.trim())?"script":"inline"}s(rI,"classifyActionKind");function oI(e){return Array.isArray(e.hooks)&&e.hooks.length>0?e.hooks:[{type:e.type,command:e.command,bash:e.bash,powershell:e.powershell,prompt:e.prompt}]}s(oI,"normalizeHookActions");function zi(e,t,n,r){let o=e.componentPath(t);for(let[i,a]of Object.entries(n))if(!(!Array.isArray(a)||e.truncated))for(let c of a){if(!c||typeof c!="object"||e.truncated)continue;let u=c;for(let f of oI(u)){if(e.truncated)return;let l=f.command??f.bash??f.prompt??f.powershell??u.powershell??"",p=rI({type:f.type??u.type,command:f.command??u.command,bash:f.bash??u.bash,powershell:f.powershell??u.powershell,prompt:f.prompt??u.prompt}),d=typeof u.matcher=="string"?u.matcher:"",m=q(l),g=d?`${i}:${d}:${p}:${m}`:`${i}:${p}:${m}`,E=`${i}|${d}|${p}|${l}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:q(E),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:i,...d?{matcher:d}:{},action_kind:p,action_hash:m,...p!=="prompt"&&l.trim()?{command:cp(l,e.home)}:{}}})}}}s(zi,"collectHooksFromObject");function Ro(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||zi(e,t,r.hooks,n)}s(Ro,"collectHooksFile");var Co=50;function tr(e,t,n,r){if(!lp(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:i}=e.withPluginExpandCap(Co,()=>{ze(e,{dir:pe(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),ze(e,{dir:pe(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),ze(e,{dir:pe(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});Ro(e,pe(t,"hooks","hooks.json"),n),Ro(e,pe(t,"hooks.json"),n);let a=e.components.length-o,c=i>=Co;return{componentCount:a,expandTruncated:c}}s(tr,"expandPluginTree");function mn(e,t){e.push({kind:"PLUGIN",name:t.pluginKey,path:t.rowPath,content_hash:t.contentHash,origin:"user",enabled:t.enabled,attributes:{...t.marketplace?{marketplace:t.marketplace}:{},...t.version?{version:t.version}:{},scope:t.scope,component_count:t.componentCount,...t.expandTruncated?{expand_truncated:!0}:{}}})}s(mn,"addPluginRow");function Wi(e){let t=e?.enabledPlugins;if(typeof t!="object"||t===null||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}s(Wi,"readEnabledPlugins");function aI(e){let t=Wi(e.readJson(pe(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=Wn(process.platform,e.home),o=e.readJson(n,{}),i={};if(o&&Object.keys(o).length>0)i=Wi(o);else for(let a of r)Object.assign(i,Wi(e.readJson(a,{})));return{...t,...i}}s(aI,"resolveClaudeEnabledPlugins");function fp(e){let t=pe(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=aI(e),i=e.componentPath(t);for(let[a,c]of Object.entries(r)){if(e.truncated)return;let u=Array.isArray(c)?c:[c],f=u[0]??{},l=o[a]===!0,p=a.includes("@")?a.split("@").slice(1).join("@"):"",d=typeof f.version=="string"?f.version:"",m=typeof f.scope=="string"?f.scope:"user",g=`plugin:${a}`,E=0,S=!1;for(let C of u)if(typeof C.installPath=="string"&&C.installPath.length>0){let P=tr(e,C.installPath,g,l);E+=P.componentCount,S=S||P.expandTruncated}mn(e,{pluginKey:a,rowPath:i,enabled:l,scope:m,version:d||void 0,marketplace:p||void 0,componentCount:E,expandTruncated:S,contentHash:q(`${a}|${d}|${m}|${l}|${E}`)})}}s(fp,"collectClaudePlugins");function cI(e){let t=e,n="";try{let r=sI(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=pe(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),i=o[o.length-1];i&&(t=pe(e,i),n=i)}}catch{}return{installPath:t,version:n}}s(cI,"pickVersionDir");var uI=/^\d+$/;function lI(e){let t=e.filter(n=>!uI.test(n.pluginId));return t.length>0?t:e}s(lI,"dedupeCursorCachePlugins");function dp(e){let t=[{base:pe(e.home,".cursor/plugins/local"),scope:"local"},{base:pe(e.home,".cursor/plugins/cache"),scope:"cache"}];for(let{base:n,scope:r}of t)if(!e.truncated)for(let o of e.readEntries(n)){if(!o.isDirectory()||e.truncated)continue;if(r==="local"){let c=o.name,u=pe(n,o.name),f=`plugin:${c}`,{componentCount:l,expandTruncated:p}=tr(e,u,f,!0);mn(e,{pluginKey:c,rowPath:e.componentPath(u),enabled:!0,scope:"local",componentCount:l,expandTruncated:p,contentHash:q(`${c}|local|${l}`)});continue}let i=o.name,a=[];for(let c of e.readEntries(pe(n,i))){if(!c.isDirectory())continue;let u=pe(n,i,c.name),{installPath:f,version:l}=cI(u);a.push({pluginId:c.name,installPath:f,version:l})}for(let c of lI(a)){if(e.truncated)break;let u=`${c.pluginId}@${i}`,f=`plugin:${u}`,{componentCount:l,expandTruncated:p}=tr(e,c.installPath,f,!0);mn(e,{pluginKey:u,rowPath:e.componentPath(c.installPath),enabled:!0,scope:"cache",version:c.version||void 0,marketplace:i,componentCount:l,expandTruncated:p,contentHash:q(`${u}|${c.version}|${l}`)})}}}s(dp,"collectCursorPlugins");function pp(e){for(let t of pn(e.home)){if(e.truncated)return;let{key:n,installPath:r,enabled:o}=t,i=`plugin:${n}`,a=e.components.length,{expanded:c}=e.withPluginExpandCap(Co,()=>{for(let f of t.skillRoots){if(lp(pe(f,"SKILL.md"))){St(e,{absolutePath:pe(f,"SKILL.md"),kind:"SKILL",origin:i,enabled:o,name:iI(f)});continue}ze(e,{dir:f,kind:"SKILL",origin:i,enabled:o,nested:"SKILL.md"})}ze(e,{dir:pe(r,"agents"),kind:"SUBAGENT",origin:i,enabled:o,extensions:[".md"]}),ze(e,{dir:pe(r,"rules"),kind:"RULE",origin:i,enabled:o,extensions:[".md"]})});Ro(e,pe(r,"hooks.json"),i);for(let f of t.mcpConfigFiles)Eo(e,f,i,{parentEnabled:o});let u=e.components.length-a;mn(e,{pluginKey:n,rowPath:e.componentPath(r),enabled:o,scope:"local",version:t.version,componentCount:u,expandTruncated:c>=Co,contentHash:q(`${n}|local|${t.version??""}|${o}|${u}`)})}}s(pp,"collectAntigravityPlugins");import{existsSync as pI}from"node:fs";var fI=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,Yi="<path>",dI=new RegExp(`${Yi}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function Ao(e){let t=e.replace(fI,Yi).replace(dI,Yi);return t.length>200?`${t.slice(0,200)}...`:t}s(Ao,"redactPermissionKey");var Ye=Ie(ke(),1);var mp=200,gp=200,Ji=16*1024,_p=6,mI=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","allowedMcpServers","deniedMcpServers","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),gI=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),_I=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),hI=new Set(["permissions","approvalMode"]),EI={claude:mI,cursor_sandbox:gI,cursor_permissions:_I,cursor_cli:hI},SI=new Set(["allow","deny","ask"]),yI=new Set(["allowedMcpServers","deniedMcpServers"]);function ut(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(ut,"isRecord");function yp(e){return e.replace(/\\/g,"/")}s(yp,"posixPath");function Xi(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>Xi(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${Xi(t[r])}`).join(",")}}`}s(Xi,"canonicalJson");function RI(e){return q(`${Xi(e)}|settings1`)}s(RI,"hashSettingsAttributes");function Rp(e){let t=yp(e);if(t.endsWith(".claude/settings.json")||t.endsWith(".claude/settings.local.json"))return"claude";if(t.endsWith(".cursor/sandbox.json"))return"cursor_sandbox";if(t.endsWith(".cursor/permissions.json"))return"cursor_permissions";if(t.endsWith(".cursor/cli-config.json")||t.endsWith(".cursor/cli.json"))return"cursor_cli"}s(Rp,"settingsProfileFor");function Cp(e,t){if(e!=="claude")return{};let n=yp(t);return n.endsWith("/.claude/remote-settings.json")?{profile:"claude",managedSource:"server"}:n.includes("/managed-settings.d/")&&n.endsWith(".json")?{profile:"claude",managedSource:"file_dropin"}:n.endsWith("/managed-settings.json")?{profile:"claude",managedSource:"file"}:{profile:"claude"}}s(Cp,"managedSettingsMeta");function hp(e,t){return e.length<=gp?e:(t.truncated=!0,e.slice(0,gp))}s(hp,"capString");function Qi(e,t){return e.length<=mp?e:(t.truncated=!0,e.slice(0,mp))}s(Qi,"capArray");function ue(e,t,n,r){if(typeof e=="string"){if(t==="path")return hp((0,Ye.tildePath)(e,n),r);let o=t==="rule"?Ao(e):e;return hp((0,Ye.tildeHomeInText)(o,n),r)}if(typeof e=="number"||typeof e=="boolean"||e===null)return typeof e=="number"&&!Number.isFinite(e)?void 0:e;if(Array.isArray(e)){let o=Qi(e,r),i=[];for(let a of o){let c=ue(a,t,n,r);c!==void 0&&i.push(c)}return i}if(ut(e)){let o={};for(let[i,a]of Object.entries(e)){let c=ue(a,t,n,r);c!==void 0&&(o[i]=c)}return o}}s(ue,"transformValue");function Ep(e,t,n){if(!ut(e))return ue(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a="plain";SI.has(o)?a="rule":o==="additionalDirectories"&&(a="path");let c=ue(i,a,t,n);c!==void 0&&(r[o]=c)}return r}s(Ep,"transformPermissions");function CI(e,t,n){if(!ut(e))return ue(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){if(o==="files"&&Array.isArray(i)){let c=Qi(i,n);r[o]=c.map(u=>{if(!ut(u))return ue(u,"plain",t,n);let f={};for(let[l,p]of Object.entries(u)){let m=ue(p,l==="path"?"path":"plain",t,n);m!==void 0&&(f[l]=m)}return f});continue}let a=ue(i,"plain",t,n);a!==void 0&&(r[o]=a)}return r}s(CI,"transformCredentials");function AI(e,t,n){if(!ut(e))return ue(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let c=ue(i,o==="allowUnixSockets"?"path":"plain",t,n);c!==void 0&&(r[o]=c)}return r}s(AI,"transformNetwork");function OI(e,t,n){if(!ut(e))return ue(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a;o==="excludedCommands"?a=ue(i,"rule",t,n):o==="filesystem"?a=ue(i,"path",t,n):o==="network"?a=AI(i,t,n):o==="credentials"?a=CI(i,t,n):a=ue(i,"plain",t,n),a!==void 0&&(r[o]=a)}return r}s(OI,"transformSandbox");var bI=/[a-z][a-z0-9+.-]+:[\\/]/i;function II(e){let[t,...n]=e.filter(r=>typeof r=="string"&&r.length>0);return t===void 0?[]:[t,...(0,Ye.redactArgs)(n)].map(r=>bI.test(r)?Di(r):r)}s(II,"redactServerCommand");function TI(e){if(!ut(e))return Ye.OMITTED_VALUE;let t={};for(let[n,r]of Object.entries(e))n==="serverName"&&typeof r=="string"?t[n]=r:n==="serverUrl"&&typeof r=="string"?t[n]=Di(r):n==="serverCommand"&&Array.isArray(r)?t[n]=II(r):t[n]=Ye.OMITTED_VALUE;return t}s(TI,"sanitizeMcpServerMatcher");function kI(e,t,n){if(!Array.isArray(e))return Ye.OMITTED_VALUE;let r=Qi(e,n).map(TI);return ue(r,"plain",t,n)}s(kI,"transformMcpServerMatchers");function xI(e,t,n,r,o){return n==="claude"?e==="permissions"?Ep(t,r,o):e==="sandbox"?OI(t,r,o):yI.has(e)?kI(t,r,o):ue(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?ue(t,"path",r,o):ue(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?ue(t,"rule",r,o):ue(t,"plain",r,o):e==="permissions"?Ep(t,r,o):ue(t,"plain",r,o)}s(xI,"transformByProfile");function nr(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(nr,"jsonBytes");function qi(e,t){return e?`${e}.${t}`:t}s(qi,"childPath");function Zi(e,t,n,r){if(Array.isArray(e)){for(let o=e.length-1;o>=0;o-=1){let i=e[o];i!==null&&typeof i=="object"&&(t+1>=_p?(e.splice(o,1),r.add(n)):Zi(i,t+1,n,r))}return}if(!(e===null||typeof e!="object"))for(let[o,i]of Object.entries(e))i!==null&&typeof i=="object"&&(t+1>=_p?(delete e[o],r.add(qi(n,o))):Zi(i,t+1,qi(n,o),r))}s(Zi,"pruneDepth");function Ap(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:nr(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))Ap(o,qi(t,r),n)}s(Ap,"collectTrimCandidates");function PI(e,t,n){let r=nr(e);if(r<=Ji)return;t.truncated=!0;let o=[];for(Ap(e,"",o);r>Ji;){let i;for(let u of o)u.items.length>0&&(!i||u.bytes>i.bytes)&&(i=u);if(!i)break;let a=i.items.pop(),c=nr(a)+(i.items.length>0?1:0);i.bytes-=c,r-=c,n.add(i.path)}for(;nr(e)>Ji;){let i,a=-1;for(let[c,u]of Object.entries(e)){let f=nr(u);f>a&&(i=c,a=f)}if(i===void 0)break;delete e[i],n.add(i)}}s(PI,"fitSettingsJson");function NI(e,t,n){let r=EI[t],o={truncated:!1},i={},a=[];for(let u of Object.keys(e)){if(!r.has(u)){a.push(u);continue}let f=xI(u,e[u],t,n,o);f!==void 0&&(i[u]=f)}a.sort();let c=new Set;return Zi(i,1,"",c),c.size>0&&(o.truncated=!0),PI(i,o,c),{settings:i,keys_omitted:a,truncated:o.truncated,trimmed_paths:[...c].sort()}}s(NI,"extractSettingsPosture");function Sp(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:RI(t.attributes),attributes:t.attributes};e.push(n)}s(Sp,"pushPostureRow");function ea(e,t,n,r){if(!e.claimFile(t)||!pI(t))return;let o=Cc(t);if(!o.ok||!ut(o.value)){if(r.profile){let f=!o.ok&&o.reason==="read"?"read_error":"parse_error",l={profile:r.profile,[f]:!0};r.managedSource&&(l.managed_source=r.managedSource),Sp(e,{kind:r.kind,absPath:t,origin:n,attributes:l})}return}let i=o.value,a=i.hooks;if(ut(a)&&zi(e,t,a,n),!r.profile)return;let c=NI(i,r.profile,e.home),u={profile:r.profile,settings:c.settings,keys_omitted:c.keys_omitted};c.truncated&&(u.truncated=!0),c.trimmed_paths.length>0&&(u.trimmed_paths=c.trimmed_paths),r.managedSource&&(u.managed_source=r.managedSource),Sp(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}s(ea,"collectSettingsFile");import{existsSync as wI}from"node:fs";import{join as Je}from"node:path";var Op=".claude/skills/synced",bp=".claude/plugins/synced";function Ip(e){return[Je(e,Op),Je(e,bp)]}s(Ip,"claudeSyncedDirs");function Oo(e){return typeof e=="string"&&e.length>0?e:void 0}s(Oo,"stringField");function Tp(e){let t=Je(e.home,Op);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Je(t,n.name),o=e.readJson(Je(r,"manifest.json"),{}),i=new Map((o?.skills??[]).flatMap(a=>a.name?[[a.name,a]]:[]));for(let a of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}let c=Je(r,a.name,"SKILL.md");if(!a.isDirectory()||!wI(c))continue;let u=i.get(a.name),f=Oo(u?.source),l=Oo(u?.creatorType);St(e,{absolutePath:c,kind:"SKILL",origin:"user",enabled:!0,name:a.name,attributes:{scope:"synced",...f?{source:f}:{},...l?{creator_type:l}:{}}})}}}s(Tp,"collectClaudeSyncedSkills");function kp(e){let t=Je(e.home,bp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Je(t,n.name),o=e.readJson(Je(r,"manifest.json"),{}),i=new Map((o?.plugins??[]).flatMap(a=>a.name?[[a.name,a]]:[]));for(let a of e.readEntries(r)){if(e.truncated)return;if(!a.isDirectory()||a.name.startsWith("."))continue;let c=i.get(a.name),u=Oo(c?.marketplaceName),f=Oo(c?.version),l=u?`${a.name}@${u}`:a.name,p=Je(r,a.name),{componentCount:d,expandTruncated:m}=tr(e,p,`plugin:${l}`,!0);mn(e,{pluginKey:l,rowPath:e.componentPath(p),enabled:!0,scope:"synced",version:f,marketplace:u,componentCount:d,expandTruncated:m,contentHash:q(`${l}|${f??""}|synced|${d}`)})}}}s(kp,"collectClaudeSyncedPlugins");function MI(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:i}=t;for(let a of n.skillRoots)ze(e,{dir:gn(r,a),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:Ip(e.home)});for(let a of n.dirs)ze(e,{dir:gn(r,a.dir),kind:a.kind,origin:o,enabled:!0,extensions:a.extensions});for(let a of n.memory){let c=Tf(a.map(u=>gn(r,u)));c&&St(e,{absolutePath:c,kind:"MEMORY",origin:o,enabled:!0,name:LI(c)})}for(let a of Nf(n))ea(e,gn(r,a),o,{kind:"SETTINGS",profile:Rp(a)});for(let a of n.mcpJson??[])Eo(e,gn(r,a),o);for(let a of n.mcpToml??[])tp(e,gn(r,a),o);if(i){if(n.managed){for(let a of no(n.managed,process.platform,e.home))if(a.toLowerCase().endsWith(".json")){let c=Cp(n.managed,a);ea(e,a,o,{kind:"MANAGED_SETTINGS",...c})}}n.plugins==="claude"?(fp(e),kp(e),Tp(e)):n.plugins==="cursor"?dp(e):n.plugins==="antigravity"&&pp(e)}}s(MI,"walkPlatformLayout");function xp(e,t){try{let n=new Yr(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)MI(n,{layout:r,levelDir:t.levelDir,origin:t.origin,includeMachineWide:t.includeMachineWide});return{scopeRef:t.scopeRef,anchor:t.levelDir,components:n.components,truncated:n.truncated}}catch(n){M("user_spec_scope",n);return}}s(xp,"walkScope");function ta(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let u=xp(t,{layouts:Object.values(an),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:mt,scopeRef:""});u&&(r.user=u)}let i=n.inGitRepo===!0,a=null,c=n.launchCwd;if(c!==void 0){let u=Object.values(Rt),f=Ks({launchCwd:c,gitRoot:n.gitRoot,inGitRepo:i,remote:n.remote,home:t,hasProjectSpec:s(l=>Lf(u,l),"hasProjectSpec")});a=f.parentRel;for(let l of f.anchors){let p=Gs(l.dir);if(o!==void 0&&!o(l.scope,p))continue;let d=xp(t,{layouts:u,levelDir:l.dir,origin:l.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:Vs,scopeRef:p});d&&(r[l.scope]=d)}r.parent||(a=null)}return{scopes:r,parentRel:a,cwdInGitRepo:i}}s(ta,"collectUserSpec");function na(e,t,n={}){let r=n.truncated===!0,o=jn(e),i=new Set(e.map(l=>Ne(l.path,l.name)));if(n.forceFull===!0||t===void 0)return{hash:o,count:e.length,truncated:r,full:!0,upserts:e,removed:[],unchanged:!1};let c=[],u=t;for(let l of e){let p=Ne(l.path,l.name);u[p]!==Wr(l)&&c.push(l)}let f=[];if(!r){for(let l of Object.keys(u))if(!i.has(l)){let p=ll(l);p&&f.push(p)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:c,removed:f,unchanged:c.length===0&&f.length===0}}s(na,"diffUserSpec");var Np=2*1024*1024,vI=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function ra(e,t,n){let r=new Set(t.map(i=>Ne(i.path,i.name))),o=[];for(let i of e)i.text!==void 0&&(n.has(i.content_hash)||r.has(Ne(i.path,i.name))||o.push(i));return o}s(ra,"collectPendingTextBodies");function oa(e,t,n){let r=new Set(e);for(let i of t)r.add(i);let o=new Set(n.map(i=>i.content_hash));return[...r].filter(i=>o.has(i))}s(oa,"pruneDeliveredTextHashes");function Pp(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Pp,"jsonSize");function wp(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}s(wp,"withoutText");function sa(e,t=Np){let n=[],r=[];for(let l of e)vI.has(l.kind)?n.push(l):r.push(l);r.sort((l,p)=>(l.text?.length??0)-(p.text?.length??0));let o=[...n,...r],i=[],a=2,c=0,u=0,f=[];for(let l of o){let p=i.length>0?1:0,d=Pp(l)+p;if(a+d<=t){i.push(l),a+=d,l.text!==void 0&&f.push(l.content_hash);continue}if(l.text!==void 0){let m=wp(l),g=Pp(m)+p;if(a+g<=t){i.push(m),a+=g,c+=1;continue}}u+=1}return{components:i,textDeferredCount:c,droppedCount:u,textHashesSent:f}}s(sa,"fitUserSpecWithinBudget");function ia(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:wp(n))}s(ia,"stripAlreadyDeliveredText");var UI=["user","cwd","repo","parent"];function aa(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,i=[];for(let T of UI){let b=t.scopes[T];if(!b)continue;let U=n(T,b.scopeRef),L=U.components,I=na(b.components,L,{forceFull:L===void 0,truncated:b.truncated}),w=new Set(U.textHashes),v=ra(b.components,I.upserts,w),h=ia([...I.upserts,...v],w);i.push({scope:T,walk:b,delta:I,outgoing:h,outgoingKeys:new Set(h.map(k=>Ne(k.path,k.name))),deliveredTextHashes:w,cachedComponents:L})}let a=i.flatMap(T=>T.outgoing),c=sa(a,o),u=new Set(c.components.map(T=>Ne(T.path,T.name))),f=[],l=[],p=[],d=[],m=[],g=[],E=[];for(let T of i){let{scope:b,walk:U,delta:L}=T;g.push(...U.components),f.push(b);let I=c.components.filter(k=>T.outgoingKeys.has(Ne(k.path,k.name))),w=[...T.outgoingKeys].some(k=>!u.has(k)),v=L.truncated||w;v?p.push(b):L.full&&l.push(b),d.push(...I),!L.full&&!v&&m.push(...L.removed);let h=L.full?{}:{...T.cachedComponents??{}};if(!v)for(let k of L.removed)delete h[Ne(k.path,k.name)];for(let k of I)h[Ne(k.path,k.name)]=Wr(k);E.push({scope:b,scopeRef:U.scopeRef,components:h,textHashes:oa(T.deliveredTextHashes,I.filter(k=>k.text!==void 0).map(k=>k.content_hash),U.components),collectedAtMs:r,included:I.length>0||L.removed.length>0&&!v||L.full})}let S={user_spec_hash:jn(g),user_spec_count:g.length,user_spec_truncated:p.length>0};f.length>0&&(S.user_spec_scopes=f,S.user_spec_full_scopes=l,S.user_spec_truncated_scopes=p,S.user_spec_cwd_in_git_repo=t.cwdInGitRepo),l.length>0&&l.length===f.length&&(S.user_spec_full=!0),d.length>0&&(S.user_spec=d),m.length>0&&(S.user_spec_removed=m),c.textDeferredCount>0&&(S.user_spec_text_deferred=c.textDeferredCount);let C=t.scopes.cwd;C&&(S.user_spec_cwd_scope_ref=C.scopeRef);let P=t.scopes.repo;P&&(S.user_spec_repo_scope_ref=P.scopeRef);let N=t.scopes.parent;return N&&(S.user_spec_parent_scope_ref=N.scopeRef,t.parentRel&&(S.user_spec_parent_rel=t.parentRel)),{fields:S,scopes:E}}s(aa,"buildUserSpecSend");var bo={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function ca(e){return e==="cwd"||e==="repo"||e==="parent"}s(ca,"isProjectSpecScope");function rr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(rr,"isPlainObject");function ua(e){return!rr(e)||!rr(e.components)||!Object.values(e.components).every(t=>typeof t=="string")||!Array.isArray(e.text_hashes)||!e.text_hashes.every(t=>typeof t=="string")?!1:typeof e.collected_at_ms=="number"&&Number.isFinite(e.collected_at_ms)}s(ua,"isDirScopeCacheEntry");function Lp(e){return DI(e)}s(Lp,"readStringHashMap");function Mp(e){return HI(e)}s(Mp,"readStringArray");function vp(e){return FI(e)}s(vp,"cloneDirScopeMap");function DI(e){if(!rr(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}s(DI,"readComponentHashMap");function HI(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}s(HI,"readTextHashes");function Up(e,t){if(!rr(e))return;let n=e[t];return ua(n)?n:void 0}s(Up,"readDirScopeCacheEntry");function FI(e){if(!rr(e))return{};let t={};for(let[n,r]of Object.entries(e))ua(r)&&(t[n]=r);return t}s(FI,"readDirScopeCacheMap");function la(e,t=20){let n=[];for(let[r,o]of Object.entries(e))ua(o)&&n.push([r,o]);return n.sort((r,o)=>o[1].collected_at_ms-r[1].collected_at_ms),Object.fromEntries(n.slice(0,t))}s(la,"boundDirScopeCache");var GI=["allow","deny","ask"];function To(e){let t=J(e,{}),n=[];for(let r of GI)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:Ao(o),mode:r});return{model:t.model??"",permissionKeys:n}}s(To,"readClaudeSettings");function VI(e){let{serverManaged:t,fileBased:n}=Wn(process.platform,e),r=To(t);if(r.model||r.permissionKeys.length>0)return r;let o="",i=[];for(let a of n){let c=To(a);c.model&&(o=c.model),i.push(...c.permissionKeys)}return{model:o,permissionKeys:i}}s(VI,"readClaudeManagedSettings");function zI(e){let t=new Set,n=[];for(let r of e){let o=`${r.mode}\0${r.key}`;t.has(o)||(t.add(o),n.push(r))}return n}s(zI,"dedupePermissionKeys");var WI=10,YI="self-config-cache.json",Hp=7;function hn(){return j("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}s(hn,"isUserSpecDisabled");function JI(){return j("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}s(JI,"isCwdSpecDisabled");var XI={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"],copilot:["copilot"],antigravity:["agy"]};async function qI(e,t=re){let n=XI[e];if(!n||n.length===0)return null;let r=s(async o=>{let i=n[o];if(i===void 0)return null;let c=((await t(i,["--version"],2e3)).split(`
29
+ `)[0]??"").trim();return c||r(o+1)},"tryNext");return r(0)}s(qI,"resolveCliVersion");function Fp(e=ma()){return _n(e,".ev-ai","agent-hook",YI)}s(Fp,"selfConfigCachePath");function $p(e=ma()){try{BI(Fp(e))}catch(t){if(t.code==="ENOENT")return;let n=t instanceof Error?t.message:String(t);x(`WARN: self-config cache clear failed open: ${n}`),M("self_config_cache_clear",t)}}s($p,"clearSelfConfigCache");function ZI(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
30
+ `);return q(n)}s(ZI,"hashConfigEntries");function Io(e,t,n=!1){let r=ZI(e),o=e.length;return t===r?n?{hash:r,count:o,truncated:n}:{hash:r,count:o}:n?{hash:r,count:o,entries:e,truncated:n}:{hash:r,count:o,entries:e}}s(Io,"buildHashedList");function fa(e,t,n=[]){let r=0,o=!1,i=new Set;for(let a of[...t.map(c=>_n(e,c)),...n]){let c=KI(a);if(i.has(c))continue;i.add(c);let u=fs(a);u.present&&(o=!0,r+=u.size)}return o?{present:!0,size:r}:{present:!1,size:0}}s(fa,"filePresenceUnion");var da="installation_id";function pa(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(pa,"isPlainRecord");function QI(e,t){if(!jI(e))return{};let n=xe(Dp(e,"utf8"),{});if(!pa(n))return{};let r=n[da];if(t&&typeof r=="string"&&r!==t)return{};let o={};for(let[i,a]of Object.entries(n))i!==da&&pa(a)&&(o[i]=a);return o}s(QI,"readSelfConfigCache");function eT(e){try{let t=xe(Dp(e,"utf8"),{}),n=pa(t)?t.installation_id:void 0;return typeof n=="string"&&n.length>0?n:void 0}catch{return}}s(eT,"storedInstallationId");function tT(e,t,n){let r=n?{...t,[da]:n}:t;try{le(e,`${JSON.stringify(r)}
31
+ `)}catch(o){let i=o instanceof Error?o.message:String(o);x(`WARN: self-config cache write failed open: ${i}`),M("self_config_cache",o)}}s(tT,"writeSelfConfigCache");function nT(e,t,n){if(t==="user")return{components:Lp(e.user_spec_components),textHashes:Mp(e.user_spec_text_hashes)};if(!ca(t))return{components:void 0,textHashes:[]};let r=Up(e[bo[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}s(nT,"cacheSliceFor");function rT(e,t,n,r){let o={...e,send_count:n};for(let i of Object.keys(t)){let a=t[i];a.entries!==void 0&&(o[i]=a.hash)}if(r){o.user_spec_layout_version=Hp,r.home&&(o.user_spec_collected_at_ms=r.home.collectedAtMs,r.home.included&&(o.user_spec=r.hash,o.user_spec_components=r.home.components),o.user_spec_text_hashes=r.home.textHashes);for(let i of r.project){if(!ca(i.scope))continue;let a=bo[i.scope],c=vp(o[a]),u=c[i.scopeRef];c[i.scopeRef]={components:i.included?i.components:u?.components??{},text_hashes:i.textHashes,collected_at_ms:i.collectedAtMs},o[a]=la(c)}}return o}s(rT,"nextPlatformSelfConfigCache");async function jp(e,t=process.cwd(),n=ma(),r={}){let o=e==="claude",i=r.gitRoot??t,a=await qI(e),c="",u=[];if(o){let v=VI(n),h=To(_n(n,".claude/settings.json")),k=To(_n(t,".claude/settings.local.json"));c=v.model||k.model||h.model,u=zI([...v.permissionKeys,...h.permissionKeys,...k.permissionKeys]).slice(0,200)}let f={present:!1,size:0},l=s(v=>{let h=[],k=!1;for(let G of v){let Oe=Ac(_n(n,G));if(h=h.concat(Oe.entries),k=k||Oe.truncated,h.length>=mt){h=h.slice(0,mt),k=!0;break}}return{entries:h,truncated:k}},"listScopeWithMeta"),p=Fp(n),d=QI(p,r.installationId),m=d[e]??{},g=(m.send_count??0)+1,E=g>0&&g%WI===0,S=s(v=>E?void 0:m[v],"cachedHash"),C=l(At.skills),P=l(At.subagents),N=l(At.commands),T=l(At.rules),b={skills:Io(C.entries,S("skills"),C.truncated),subagents:Io(P.entries,S("subagents"),P.truncated),commands:Io(N.entries,S("commands"),N.truncated),rules:Io(T.entries,S("rules"),T.truncated)},U={runner_platform:e,config_scope:"user",cli_version:a,claude_version:o?a:null,model:o&&c||null,permission_keys:u,user_scope:{skills:b.skills,subagents:b.subagents,commands:b.commands,rules:b.rules,memory:fa(n,At.memory),settings:fa(n,At.settings,Mf(n)),mcp:fa(n,At.mcp)},local_settings:o?fs(_n(t,".claude/settings.local.json")):f},L=null,I=r.nowMs??Date.now();if(!hn()){let v=m.user_spec_layout_version!==Hp,h=ta(e,n,{launchCwd:JI()?void 0:r.launchCwd,gitRoot:i,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(h.scopes).length>0){let k=aa({collected:h,cacheFor:s((G,Oe)=>v?{components:void 0,textHashes:[]}:nT(m,G,Oe),"cacheFor"),nowMs:I});Object.assign(U,k.fields),L={hash:k.fields.user_spec_hash,home:k.scopes.find(G=>G.scope==="user")??null,project:k.scopes.filter(G=>G.scope!=="user")}}}let w=rT(m,b,g,L);return{config:U,commit:s(()=>{let{installationId:v,installationStorePath:h}=r;if(v&&h){let k=eT(h);if(k!==void 0&&k!==v)return}d[e]=w,tT(p,d,v)},"commit")}}s(jp,"selfConfig");import{createHash as oT}from"node:crypto";import{readFileSync as sT,statSync as Kp}from"node:fs";import{homedir as iT}from"node:os";import{isAbsolute as aT,join as xt,resolve as Bp}from"node:path";var cT="^(user\\.(name|email)|remote\\.origin\\.url)$",uT=3600*1e3,lT=32;function Gp(e){return oT("sha256").update(e).digest("hex")}s(Gp,"sha256");function fT(e){let t={userName:null,userEmail:null,remoteOriginUrl:null};for(let n of e.split(`
32
+ `)){let r=n.trim();if(r.toLowerCase()==="remote.origin.url"){t.remoteOriginUrl=null;continue}let o=r.indexOf(" ");if(o<=0)continue;let i=r.slice(0,o).toLowerCase(),a=r.slice(o+1).trim()||null;i==="user.name"?t.userName=a:i==="user.email"?t.userEmail=a:i==="remote.origin.url"&&(t.remoteOriginUrl=a)}return t}s(fT,"parseGitConfigValues");function dT(e){return{userName:e.userName,userEmail:e.userEmail,remoteOriginUrlSha256:e.remoteOriginUrl?Gp(e.remoteOriginUrl):null}}s(dT,"toFacts");function ko(e){try{return sT(e,"utf8")}catch{return null}}s(ko,"readTextOrNull");function pT(e){let t=xt(e,".git"),n;try{if(Kp(t).isDirectory())n=t;else{let o=/^gitdir:\s*(.+?)\s*$/m.exec(ko(t)??"")?.[1];if(!o)return null;n=aT(o)?o:Bp(e,o)}}catch{return null}let r=ko(xt(n,"commondir"))?.trim();return{gitDir:n,commonDir:r?Bp(n,r):n}}s(pT,"repoGitDirs");function mT(e){let t=e.GIT_CONFIG_GLOBAL?.trim();if(t)return[t];let n=e.HOME?.trim()||iT(),r=e.XDG_CONFIG_HOME?.trim();return[xt(n,".gitconfig"),xt(r||xt(n,".config"),"git","config")]}s(mT,"globalConfigPaths");function gT(e){try{let t=Kp(e);return`${e}|${String(t.mtimeMs)}|${String(t.size)}`}catch{return`${e}|-`}}s(gT,"fileStamp");var _T=["GIT_DIR","GIT_COMMON_DIR","GIT_CONFIG"];function hT(e){return _T.some(t=>!!e[t]?.trim())}s(hT,"hasGitLocationOverride");function ET(e,t=process.env){let n=pT(e),r=n?[xt(n.commonDir,"config"),xt(n.gitDir,"config.worktree")]:[],o=n?`HEAD|${ko(xt(n.gitDir,"HEAD"))?.trim()??"-"}`:"HEAD|-",i=[...r,...mT(t)].map(gT),a=Object.keys(t).filter(c=>c.startsWith("GIT_CONFIG")||c==="GIT_DIR"||c==="GIT_COMMON_DIR").sort().map(c=>`${c}=${t[c]??""}`);return[...i,o,...a].join(`
33
+ `)}s(ET,"gitConfigStamp");function ga(e){return typeof e=="string"&&e.length>0?e:null}s(ga,"nullableString");function Vp(e){let t=ko(e);if(!t)return{};let n;try{n=JSON.parse(t)}catch{return{}}let r=n&&typeof n=="object"?n.entries:void 0;if(!r||typeof r!="object"||Array.isArray(r))return{};let o={};for(let[i,a]of Object.entries(r)){if(!a||typeof a!="object")continue;let c=a;typeof c.read_at_ms!="number"||typeof c.stamp_sha256!="string"||(o[i]={read_at_ms:c.read_at_ms,stamp_sha256:c.stamp_sha256,user_name:ga(c.user_name),user_email:ga(c.user_email),remote_origin_url_sha256:ga(c.remote_origin_url_sha256)})}return o}s(Vp,"readCacheEntries");function ST(e){return!e.userName&&!e.userEmail&&!e.remoteOriginUrlSha256}s(ST,"isEmpty");function yT(e,t,n){if(e?.stamp_sha256!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<uT}s(yT,"isFresh");function RT(e,t,n){let r={...Vp(e),[t]:n},o=Object.entries(r).sort(([,i],[,a])=>a.read_at_ms-i.read_at_ms).slice(0,lT);try{le(e,`${JSON.stringify({entries:Object.fromEntries(o)})}
34
+ `)}catch(i){let a=i instanceof Error?i.message:String(i);x(`WARN: git config cache write failed open: ${a}`)}}s(RT,"writeCacheEntry");async function xo(e,t={}){let n=t.exec??re,r=t.env??process.env,o=hT(r)?void 0:t.cachePath,i=o?Gp(ET(e,r)):"",a=t.nowMs??Date.now();if(o){let f=Vp(o)[e];if(f&&yT(f,i,a))return{userName:f.user_name,userEmail:f.user_email,remoteOriginUrlSha256:f.remote_origin_url_sha256}}let c=await n("git",["config","--get-regexp",cT],2e3,{cwd:e}),u=dT(fT(c));return o&&!ST(u)&&RT(o,e,{read_at_ms:a,stamp_sha256:i,user_name:u.userName,user_email:u.userEmail,remote_origin_url_sha256:u.remoteOriginUrlSha256}),u}s(xo,"readGitConfigValues");var OT="installation.json",bT="git-config.json",IT="cloud-bootstrap.lock",TT=6e4;function em(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}s(em,"platformAgentIdCacheKey");function Ae(e=or()){return No(e,".ev-ai","agent-hook")}s(Ae,"agentHookHome");function kT(e=or()){return No(Ae(e),OT)}s(kT,"installationStorePath");function En(e=or()){return No(Ae(e),bT)}s(En,"gitConfigCachePath");function tm(e){return No(Po(e),IT)}s(tm,"cloudBootstrapLockPath");function nm(){return CT(8).toString("hex")}s(nm,"randomInstallationId");function Pt(e){return Jp("sha256").update(e).digest("hex").slice(0,16)}s(Pt,"sha16");function z(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(z,"trimEnv");function rm(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}s(rm,"isValidInstallationId");function xT(e=process.env){let t=z(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!rm(t)){x(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}s(xT,"readInstallationIdEnvOverride");function om(e,t){return e&&rm(e)?e:(e&&x(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),xT(t))}s(om,"resolvePinnedInstallationId");function PT(e){return/^[0-9a-f]{16}$/.test(e)}s(PT,"isEphemeralInstallationIdShape");function NT(e=process.env){if(z(e.GITHUB_ACTIONS)){let t=z(e.GITHUB_REPOSITORY_ID)??z(e.GITHUB_REPOSITORY),n=z(e.GITHUB_ACTOR)??z(e.GITHUB_TRIGGERING_ACTOR)??z(e.GITHUB_USER);if(t&&n)return Pt(`github_actions|${t}|${n}`)}if(z(e.CODESPACES)||z(e.CODESPACE_NAME)){let t=z(e.CODESPACE_NAME);if(t)return Pt(`codespaces|${t}`);let n=z(e.GITHUB_REPOSITORY_ID)??z(e.GITHUB_REPOSITORY),r=z(e.GITHUB_USER)??z(e.GITHUB_ACTOR);if(n&&r)return Pt(`codespaces|${n}|${r}`)}if(z(e.GITLAB_CI)){let t=z(e.CI_PROJECT_ID)??z(e.CI_PROJECT_PATH),n=z(e.GITLAB_USER_LOGIN)??z(e.GITLAB_USER_EMAIL)??z(e.GITLAB_USER_NAME);if(t&&n)return Pt(`gitlab|${t}|${n}`)}return null}s(NT,"deriveEphemeralInstallationId");var sm="cursoragent@cursor.com";function wT(e){let t=z(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===sm?null:t}s(wT,"cursorCloudUserEmail");function LT(e,t){return z(e.CURSOR_PROJECT_DIR)??z(e.CLAUDE_PROJECT_DIR)??t}s(LT,"cursorCloudWorkspacePath");function MT(e){return Pn(e).replace(/\.git$/i,"").toLowerCase()}s(MT,"normalizeRemoteForSeed");async function vT(e){let t=await re("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?MT(t):e}s(vT,"resolveRepoSeed");async function UT(e){let t=z(await re("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!ge(null,t))return t;let n=z(await re("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!ge(null,n)?n:null}s(UT,"readClaudeRemoteOperatorEmail");function DT(e){let t=z(e?.userId??void 0);if(t)return{kind:"user_id",value:t};let n=z(e?.userEmail??void 0)?.toLowerCase();return n&&n!==sm?{kind:"email",value:n}:null}s(DT,"cursorCloudOwnerKey");function HT(e,t,n){let r=LT(e,t);if(!r)return null;let o=DT(n);return o?(oe.info(`cursor_cloud installation key=${o.kind}`),{id:Pt(`cursor_cloud/v2|${r}|${o.value}`),cursorCloudSeed:"v2"}):(oe.info("cursor_cloud installation key=v1"),{id:Pt(`cursor_cloud|${r}|${wT(e)??""}`),cursorCloudSeed:"v1"})}s(HT,"deriveCursorCloudInstallationSeed");async function FT(e,t,n,r,o){if(e==="cursor_cloud"&&t)return HT(n,r,await Br({env:n,home:o}));if(e==="claude_remote"){let i=await $T(n,r,o);return i?{id:i}:null}return null}s(FT,"deriveCloudInstallationId");async function $T(e,t,n=or()){let r=yu(n);if(r)return oe.info("claude_remote installation key=email"),Pt(`claude_remote/v2|${r}`);oe.info("claude_remote installation key=v1");let o=z(e.CLAUDE_PROJECT_DIR)??t;if(!o)return null;let i=await vT(o),a=await UT(o);return Pt(`claude_remote|${i}|${a??""}`)}s($T,"deriveClaudeRemoteInstallationId");function zp(e,t){let n=om(e,t);if(n)return n;let r=NT(t);return r||nm()}s(zp,"chooseNewInstallationId");async function jT(e,t={}){let{remoteOriginUrlSha256:n}=await xo(e,t);return(n??Jp("sha256").update(AT(e)).digest("hex")).slice(0,16)}s(jT,"computeRepoKey");function BT(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&r.length>0&&(t[n]=r);return Object.keys(t).length>0?t:void 0}s(BT,"readPlatformAgentIds");function KT(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=BT(t.platform_agent_ids);return{installation_id:t.installation_id,...t.pinned===!0?{pinned:!0}:{},...n?{platform_agent_ids:n}:{},...typeof t.operator_identity_hash=="string"?{operator_identity_hash:t.operator_identity_hash}:{},...typeof t.operator_identity_sent_at=="string"?{operator_identity_sent_at:t.operator_identity_sent_at}:{},...t.cursor_cloud_seed==="v2"?{cursor_cloud_seed:"v2"}:{}}}catch{return}}s(KT,"parseInstallationRecord");function Bt(e){if(Xp(e))try{return KT(qp(e,"utf8"))}catch{}}s(Bt,"readInstallationRecord");function Ea(e){return Bt(e)}s(Ea,"readInstallationStore");function im(e,t,n){let r=Bt(e);if(!r||r.operator_identity_hash===t&&r.operator_identity_sent_at===n)return;let o={...r,operator_identity_hash:t,operator_identity_sent_at:n};try{le(e,`${JSON.stringify(o,null,2)}
35
+ `)}catch(i){let a=i instanceof Error?i.message:String(i);x(`WARN: operator identity cache write failed open: ${a}`),M("operator_identity_cache",i)}}s(im,"writeOperatorIdentityCache");function am(e,t=Date.now()){if(!e)return!0;if(Bt(e)?.operator_identity_hash)return!1;let n=tm(e);try{if(Xp(n)){let r=Number.NaN;try{r=Number(qp(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<TT)return!1;try{Zp(n)}catch{}}}catch{}try{return ha(Po(n),{recursive:!0}),Qp(n,`${t}
36
+ `,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(fm(r))return!1;let o=r instanceof Error?r.message:String(r);return x(`WARN: cloud bootstrap claim failed open: ${o}`),M("cloud_bootstrap_claim",r),!0}}s(am,"tryClaimCloudIdentityBootstrap");function cm(e){if(e)try{Zp(tm(e))}catch{}}s(cm,"releaseCloudIdentityBootstrapClaim");function um(e,t){let r=Bt(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}s(um,"readCachedPlatformAgentId");function lm(e,t,n){if(!n)return;let r=Bt(e);if(!r||r.platform_agent_ids?.[t]===n)return;let o={...r,platform_agent_ids:{...r.platform_agent_ids,[t]:n}};try{le(e,`${JSON.stringify(o,null,2)}
37
+ `)}catch(i){let a=i instanceof Error?i.message:String(i);x(`WARN: platform_agent_id cache write failed open: ${a}`),M("platform_agent_id_cache",i)}}s(lm,"writeCachedPlatformAgentId");function fm(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}s(fm,"isEexistError");function GT(e,t){ha(Po(e),{recursive:!0}),Qp(e,`${JSON.stringify(t,null,2)}
38
+ `,{encoding:"utf8",flag:"wx"})}s(GT,"writeInstallationRecordExclusive");function Wp(e,t){try{return GT(e,t),t}catch(n){if(!fm(n))throw n;return Bt(e)}}s(Wp,"tryCreateInstallationRecord");function _a(e,t){ha(Po(e),{recursive:!0}),le(e,`${JSON.stringify(t,null,2)}
39
+ `)}s(_a,"replaceInstallationRecord");function Yp(e,t,n){return{installation_id:e,...t&&t===e?{pinned:!0}:{},...n?.cursorCloudSeed==="v2"&&n.id===e?{cursor_cloud_seed:"v2"}:{}}}s(Yp,"newInstallationRecord");async function dm(e,t={}){let n=t.home??or(),r=t.env??process.env,o=await jT(e,{cachePath:En(n)}),i=kT(n),a={sessionId:t.sessionId,hostname:z(r.HOSTNAME)??void 0,osUser:z(r.USER)??z(r.LOGNAME)??z(r.USERNAME)??void 0,env:r},c=Or(a),u=om(t.overrideId,r),f=await FT(c,c==="cursor_cloud"&&ds(a),r,e,n),l=f?.id??null,p=Bt(i);if(p){let S=p;u&&u===p.installation_id&&p.pinned!==!0&&(S={...p,pinned:!0},_a(i,S)),f?.cursorCloudSeed==="v2"&&f.id===S.installation_id&&S.cursor_cloud_seed!=="v2"&&(S={...S,cursor_cloud_seed:"v2"},_a(i,S));let C=S.cursor_cloud_seed==="v2"&&f?.cursorCloudSeed!=="v2";if(!!l&&l!==S.installation_id&&!u&&S.pinned!==!0&&!C&&PT(S.installation_id)&&l){let N={installation_id:l,...S.platform_agent_ids?{platform_agent_ids:S.platform_agent_ids}:{},...f?.cursorCloudSeed==="v2"?{cursor_cloud_seed:"v2"}:{}};return _a(i,N),$p(n),{installationId:l,storePath:i,repoKey:o}}return{installationId:S.installation_id,storePath:i,repoKey:o}}let d=u??l??zp(void 0,r),m=Wp(i,Yp(d,u,f));if(m)return{installationId:m.installation_id,storePath:i,repoKey:o};let g=u??l??zp(void 0,r),E=Wp(i,Yp(g===d?nm():g,u,f));if(E)return{installationId:E.installation_id,storePath:i,repoKey:o};throw new Error(`Failed to create installation record at ${i}`)}s(dm,"resolveOrCreateInstallationId");import{existsSync as YT}from"node:fs";import{existsSync as VT}from"node:fs";import{resolve as Sa}from"node:path";function Me(e){return Sa(e).replaceAll("\\","/").replace(/\/$/,"")}s(Me,"posixAbs");function Kt(e,t){let n=new Set(t),r=[];for(let o of e)n.delete(o)&&r.push(o);for(let o of[...n].sort())r.push(o);return r}s(Kt,"uniqueOrderedRoots");function wo(e,t){if(!e)return t;let n=`${e}/`,r=[],o=[];for(let i of t)i===e||i.startsWith(n)?r.push(i):o.push(i);return r.length===0?t:[...r,...o]}s(wo,"preferMarkerDirRoots");var zT=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function sr(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!zT.test(t)?null:t}s(sr,"sanitizeComponentRelativePath");function Sn(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let i=Me(o);n.has(i)||(n.add(i),r.push(i))}return r}s(Sn,"projectAnchors");function WT(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}s(WT,"isInside");function lt(e,t,n,r=VT){for(let o of e)for(let i of t){let a=Me(Sa(o,i)),c=Sa(o,i,n).replaceAll("\\","/");if(WT(a,c)&&r(c))return c}return null}s(lt,"firstExistingUnderRoots");var gm=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/|\.github\/|\.copilot\/|\.gemini\/(?:config\/|antigravity(?:-cli)?\/)?)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,JT=/(?:^|\/|[\s"'=(])(?:\.gemini\/config|\.agents)\/plugins\/[^/\s"']+\/(?:[^\s"']*\/)?([^/\s"']+)\/SKILL\.md/i,_m=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,XT=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5}(?::[a-z][a-z0-9-]{1,63})?)\b/gi,pm=new Set(["applications","app","bin","boot","data","dev","etc","home","lib","media","mnt","node_modules","opt","pkg","private","proc","projects","repos","run","sbin","src","srv","sys","tmp","usr","users","var","volumes","workspace","workspaces"]),qT=/^[a-z][a-z0-9-]{1,63}$/,hm=/^([a-z][a-z0-9-]{1,63}):([a-z][a-z0-9-]{1,63})$/;function Em(e){return hm.exec(e.toLowerCase())?.[2]??e.toLowerCase()}s(Em,"skillIdOfSlashName");var ZT=[".cursor/skills",".claude/skills",".agents/skills"],QT=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],ek=Kt(ZT,Ct(Object.values(Rt)).skills),tk=Kt(QT,Ct(Object.values(an)).skills),nk=new Set(["read","read_file","view","view_file"]),rk=new Set(["bash","shell","zsh","run_command"]);function ya(e){let t=e.replace(/\\/g,"/");return(gm.exec(t)??JT.exec(t))?.[1]??null}s(ya,"skillIdFromSkillMdPath");function ok(e){let t=e.replace(/\\/g,"/"),r=_m.exec(t)?.[1];return r?r.toLowerCase():null}s(ok,"skillIdFromCodexCommandPath");function sk(e){return ya(e)??ok(e)}s(sk,"skillIdFromReferencedPath");function ik(e){for(let t of["path","file_path","target_file"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}return null}s(ik,"pathFromToolInputRecord");function Lo(e){return typeof e=="string"?Lo(xe(e,null)):!e||typeof e!="object"?null:ik(e)}s(Lo,"pathFromToolInput");function Sm(e){if(typeof e=="string")return Sm(xe(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}s(Sm,"commandFromToolInput");function Ra(e){let t=Sm(e.tool_input);if(t)return t;let n=wt(e.command);return n.length>0?n:null}s(Ra,"commandFromHookInput");function ak(e){let t=e.replace(/\\/g,"/"),n=gm.exec(t);if(n?.[1])return n[1];let o=_m.exec(t)?.[1];return o?o.toLowerCase():null}s(ak,"skillIdFromShellCommand");function ck(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}s(ck,"toolNameFromHookInput");function Ca(e){let t=Lo(e.tool_input)??wt(e.file_path);return t.length>0?t:null}s(Ca,"filePathFromHookInput");function ir(e,t,n){let r=ck(e).toLowerCase();if(nk.has(r)){let o=Ca(e);return o?t(o):null}if(rk.has(r)){let o=Ra(e);return o?n(o):null}return null}s(ir,"nameFromReadOrShellHookInput");function ym(e){return ir(e,sk,ak)}s(ym,"skillNameFromReadHookInput");function uk(e){let t=new Set,n=[];for(let r of e.matchAll(XT)){let o=r[1]?.toLowerCase();!o||t.has(o)||lk(o)||(t.add(o),n.push(o))}return n}s(uk,"extractSlashSkillNames");function lk(e){let t=e.split("/")[0];return pm.has(e)||t!==void 0&&pm.has(t)}s(lk,"isDeniedSlashId");function Rm(e){let t=e.exists??YT,n=hm.exec(e.skillId.toLowerCase());if(n?.[1]&&n[2])return e.home?mm(e.home,n[1],n[2],t):null;let r=e.skillId.toLowerCase();if(!qT.test(r))return null;let o=`${r}/SKILL.md`,i=lt(Sn(e.launchCwd,e.gitRoot),ek,o,t);return i!==null?i:e.home?lt([Me(e.home)],tk,o,t)??mm(e.home,null,r,t):null}s(Rm,"resolveSkillMdPath");function mm(e,t,n,r){let o=pn(e).filter(i=>i.enabled&&(t===null||i.key.toLowerCase()===t));for(let i of o)for(let a of i.skillRoots){let c=a.replace(/\\/g,"/"),u=`${c}/${n}/SKILL.md`;if(r(u))return u;let f=`${c}/SKILL.md`;if(c.split("/").at(-1)?.toLowerCase()===n&&r(f))return f}return null}s(mm,"antigravityPluginSkillMd");function fk(e){return wt(e.prompt)}s(fk,"promptFromHookInput");function Cm(e){let t=B(e,"command_name");if(t){let r=B(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=fk(e);return n?uk(n):[]}s(Cm,"skillNamesFromHookInput");var Aa=Ie(ke(),1);import{existsSync as pk}from"node:fs";var Gt={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode",copilot:".github"};function ar(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}s(ar,"normalizePathSlug");function dk(e){if(!e)return"";let t=Pn(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return ar(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return ar(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?ar(o[1]):ar(t)}s(dk,"normalizeGitRemoteToSlug");async function Mo(e=process.cwd()){let t=await ve("git",["rev-parse","--is-inside-work-tree"],2e3,{cwd:e});if(!t.ok||t.stdout!=="true")return null;let[n,r,o,i]=await Promise.all([ve("git",["remote","get-url","origin"],2e3,{cwd:e}),ve("git",["branch","--show-current"],2e3,{cwd:e}),ve("git",["rev-parse","HEAD"],2e3,{cwd:e}),ve("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?Pn(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:i.ok?i.stdout.length>0:null}}s(Mo,"gitSnapshot");async function Am(e,t,n,r=process.cwd(),o,i,a){if(t)return t;let c=Gt[n];if(!c)return"";let u=em(n,e.scope_path,a);if(i){let g=um(i,u);if(g)return g}let f=o??await Mo(r),l=f?.remote?dk(f.remote):"";if(l||(l=ar(process.env.GITHUB_REPOSITORY??"")),!l)return"";let p=e.scope_path??"",d=p?`${p}/`:"",m=`${l}:${d}${c}`;return i&&lm(i,u,m),m}s(Am,"derivePlatformAgentId");var mk=[".cursor/rules",".claude/rules",".codex/rules"],gk=Ct(Object.values(Rt)).rules;function _k(e){return Kt(wo(e?Gt[e]:void 0,mk),gk)}s(_k,"ruleRootsForRunner");var hk=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex|\.gemini\/config)\/rules\/[^'"\s]+?\.(?:mdc|md|rules)|\.github\/instructions\/[^'"\s]+?\.instructions\.md)\b/i;function Om(e){let t=sr(e.relativePath);if(!t)return null;let n=e.exists??pk,r=Sn(e.launchCwd,e.gitRoot),o=_k(e.runnerPlatform),i=lt(r,o,t,n);if(i!==null)return i;if(!t.includes("/")){let a=lt(r,["."],t,n);if(a!==null)return a}return e.home?lt([Me(e.home)],o,t,n):null}s(Om,"resolveRuleMdPath");function Ek(e){let t=e.replace(/\\/g,"/"),r=hk.exec(t)?.[1];return r?(0,Aa.nativeKeyForRulePath)(r):null}s(Ek,"ruleNameFromShellCommand");function bm(e){return ir(e,Aa.nativeKeyForRulePath,Ek)}s(bm,"ruleNameFromReadHookInput");function Im(e){return e.replace(/\.(mdc|md|rules)$/i,"")}s(Im,"stripRuleExtension");function Tm(e){let t=e.attachments;if(!Array.isArray(t))return[];let n=new Set,r=[];for(let o of t){if(!o||typeof o!="object"||Array.isArray(o))continue;let i=o;if(i.type!=="rule")continue;let a=typeof i.file_path=="string"?i.file_path:"",c=sr(a);!c||n.has(c)||(n.add(c),r.push(c))}return r}s(Tm,"ruleAttachmentPathsFromHookInput");var Oa=Ie(ke(),1);import{existsSync as Sk}from"node:fs";var yk=[".cursor/commands",".claude/commands",".codex/prompts"],Rk=Ct(Object.values(Rt)).commands;function Ck(e){return Kt(wo(e?Gt[e]:void 0,yk),Rk)}s(Ck,"commandRootsForRunner");var Ak=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc)|\.github\/prompts\/[^'"\s]+?\.prompt\.md)\b/i,Ok=".github/prompts";function bk(e,t){return e===Ok?`${t}.prompt.md`:`${t}.md`}s(bk,"commandFileName");function km(e){let t=sr(e.commandId);if(!t)return null;let n=e.exists??Sk,r=Ck(e.runnerPlatform),o=s(a=>{for(let c of a)for(let u of r){let f=lt([c],[u],bk(u,t),n);if(f!==null)return f}return null},"probe"),i=o(Sn(e.launchCwd,e.gitRoot));return i!==null||!e.home?i:o([Me(e.home)])}s(km,"resolveCommandMdPath");function Ik(e){let t=e.replace(/\\/g,"/"),r=Ak.exec(t)?.[1];return r?(0,Oa.nativeKeyForCommandPath)(r):null}s(Ik,"commandNameFromShellCommand");function xm(e){return ir(e,Oa.nativeKeyForCommandPath,Ik)}s(xm,"commandNameFromReadHookInput");var vo=Ie(ke(),1);function Pm(e,t){if(B(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}s(Pm,"cursorShapedPayload");function Tk(){return!!(j("CURSOR_VERSION")??j("CURSOR_PROJECT_DIR"))}s(Tk,"isCursorHostEnv");function Nm(e,t,n){return e!=="claude"&&e!=="codex"?!1:Pm(t,n)?!0:Tk()}s(Nm,"shouldSuppressForeignRunnerOnCursorHost");var kk=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function yn(e,t,n,r){return r==="copilot"?"copilot":r==="antigravity"?"antigravity":Pm(e,t)?"cursor":Nr(r)?r:Nr(n)?n:B(e,"turn_id")?"codex":B(e,"session_id")||kk.has(t.toLowerCase())?"claude":"unknown"}s(yn,"detectRunnerPlatform");function Uo(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&(t==="codex"||t==="antigravity")}s(Uo,"isInProcessEvent");function xk(e){switch(e){case"sessionstart":return"session_start";case"stop":case"sessionend":case"stopfailure":return"session_end";case"pretooluse":case"posttooluse":case"posttoolusefailure":case"permissiondenied":case"beforemcpexecution":case"beforeshellexecution":case"aftershellexecution":case"beforereadfile":case"afterfileedit":case"subagentstart":case"subagentstop":return"tool_invoked";case"beforesubmitprompt":case"userpromptexpansion":case"userpromptsubmit":case"userpromptsubmitted":return"skill_invoked";default:return""}}s(xk,"mapRunnerEventToInternal");function wm(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="userpromptsubmitted"||t==="beforesubmitprompt"}s(wm,"isPromptSubmitRunnerEvent");function Lm(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}s(Lm,"suppressesSlashIds");function Mm(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}s(Mm,"toolSuccessFromRunnerEvent");function Rn(e){return B(e,"session_id")||B(e,"conversation_id")}s(Rn,"sessionIdFromHookInput");function ba(e){return B(e,"prompt.id")||B(e,"prompt_id")||B(e,"generation_id")||B(e,"turn_id")}s(ba,"turnIdFromHookInput");function Do(e){return B(e,"hook_event_name")||B(e,"event")}s(Do,"runnerEventFromHookInput");function vm(e,t,n){let r=Rn(e),o=ba(e),i=Do(e),a=B(e,"source"),c=yn(e,i,t,n);return{sessionId:r,turnId:o,runnerEvent:i,hookSource:a,runnerPlatform:c}}s(vm,"normalizeHookFields");var Pk=["session_start","session_end","tool_invoked","skill_invoked"];function Nk(e){return Pk.includes(e)}s(Nk,"isKnownInternalEvent");function Ho(e,t){return e&&Nk(e)?e:xk(t.toLowerCase())}s(Ho,"resolveInternalEvent");var wk={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function Fo(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}s(Fo,"isMcpShapedToolName");function Um(e,t=""){let n=B(e,"tool_name")||B(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!Fo(n)&&(n=`MCP:${n}`):n=wk[r]??null;let o=e.tool_input,a=(o&&typeof o=="object"?wt(o.skill)||wt(o.skill_name):"")||B(e,"skill_name")||null,c=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;a??=ym(c);let u=bm(c),f=xm(c);return{toolName:n,skillName:a,ruleName:u,commandName:f}}s(Um,"extractToolNames");var Lk=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function Dm(e){for(let t of["subagent_type","agent_type"]){let n=B(e,t);if(n&&Lk.test(n))return n}return null}s(Dm,"extractSubagentType");function Hm(e){let t=Ze(e,"duration_ms");if(typeof t=="number")return t;let n=Ze(e,"duration");return typeof n=="number"?n:null}s(Hm,"extractDurationMs");var Mk="error",vk="interrupted",Uk="permission_denied",Dk=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function cr(e){return Dk.test(e)?e:null}s(cr,"categoricalValue");function Hk(e){for(let t of["failure_type","error_type"]){let n=cr(B(e,t));if(n)return n}return null}s(Hk,"structuredFailureClass");function Fm(e,t){return Ze(e,"is_interrupt")===!0?vk:t.toLowerCase()==="permissiondenied"?Uk:Hk(e)??Mk}s(Fm,"extractFailureClass");function $m(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}s($m,"longestDeclaredServer");function Fk(e,t){return $m(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}s(Fk,"matchDeclaredMcpServer");function $k(e,t){return $m(t,n=>(0,vo.mcpServerNameMatchesToolSegment)(n,e))}s($k,"matchDeclaredMcpServerSegment");function jk(e,t){let n=null,r=0;for(let i of t)if(i)for(let a of(0,vo.mcpServerToolSegmentForms)(i)){let c=`${a}__`;e.length>c.length&&e.slice(0,c.length).toLowerCase()===c.toLowerCase()&&a.length>r&&(n={mcpServer:i,mcpTool:e.slice(c.length)},r=a.length)}if(n!==null)return n;let o=/^(.+?)__(.+)$/.exec(e);return!o?.[1]||!o[2]?{mcpServer:null,mcpTool:null}:{mcpServer:$k(o[1],t)??o[1],mcpTool:o[2]}}s(jk,"parseClaudeMcpNames");function Bk(e,t){if(/^mcp__/i.test(e))return jk(e.slice(5),t);if(/^MCP:/i.test(e)){let n=e.slice(4);if(!n)return{mcpServer:null,mcpTool:null};let r=n.indexOf(":");if(r>0)return{mcpServer:n.slice(0,r),mcpTool:n.slice(r+1)||null};let o=n.indexOf("__");return o>0?{mcpServer:n.slice(0,o),mcpTool:n.slice(o+2)||null}:{mcpServer:Fk(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}s(Bk,"parseMcpNamesFromToolName");function Kk(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}s(Kk,"stripEncodedMcpServerPrefix");function jm(e,t=[],n=""){let r=e?Bk(e,t):{mcpServer:null,mcpTool:null},o=cr(n.trim());if(!o)return r;let i=r.mcpTool;return!i&&e&&!Fo(e)&&(i=e),i&&(i=Kk(i,o)),{mcpServer:o,mcpTool:i}}s(jm,"extractMcpNames");var Gm=3e4,Jk="claims",Xk=!0,qk=100,Zk=new Set(["sessionstart","sessionend","stopfailure"]),Qk=["tool_name","tool","command","file_path","url"];function ex(e=Km()){return Ia(Ae(e),Jk)}s(ex,"eventClaimDir");function Vm(e,t){try{let n=Wk(e,"utf8").split(`
40
+ `,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}s(Vm,"claimAgeMs");function tx(e){let t=[];for(let n of Qk){let r=B(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":Nn(t.join("\0"))}s(tx,"callFingerprintFromHookInput");function nx(e){let t=e.sessionId.trim();if(!t)return;let n=e.runnerEvent.trim().toLowerCase(),r=e.turnId.trim(),o=e.toolUseId.trim(),i=e.subagentId?.trim()??"",a=e.callFingerprint?.trim()??"",c=!!(o||r||i),u=Zk.has(n);if(!c&&!u)return;let f=e.runnerPlatform.trim()||"unknown";return Nn(`${f}|${t}|${n}|${r}|${o}|${a}|${i}`)}s(nx,"eventClaimKey");function rx(e,t=Date.now()){let n;try{n=zk(e)}catch{return}let r=0;for(let o of n){if(r>=qk)break;r+=1;let i=Ia(e,o),a=Vm(i,t);if(!(!Number.isFinite(a)||a<Gm))try{Bm(i)}catch{}}}s(rx,"pruneStaleEventClaims");function ox(e,t,n=Date.now()){let r=Ia(t,e);try{if(Gk(r)){let o=Vm(r,n);if(Number.isFinite(o)&&o>=0&&o<Gm)return!1;try{Bm(r)}catch(i){if(!(i instanceof Error&&"code"in i&&i.code==="ENOENT"))return M("event_claim_steal",i),!0}}}catch{}try{Vk(t,{recursive:!0}),Yk(r,`${n}
41
+ `,{encoding:"utf8",flag:"wx"})}catch(o){if(Ln(o))return!1;let i=o instanceof Error?o.message:String(o);return x(`WARN: event claim failed open: ${i}`),M("event_claim",o),!0}return rx(t,n),!0}s(ox,"tryClaimHookEvent");function sx(e,t,n){let r=Rn(e),o=ba(e),i=B(e,"tool_use_id"),a=B(e,"subagent_id")||B(e,"agent_id"),c=yn(e,t,void 0,n),u=tx(e);return{runnerPlatform:c,sessionId:r,runnerEvent:t,turnId:o,toolUseId:i,subagentId:a,callFingerprint:u}}s(sx,"identityFromHookInput");function zm(e,t,n,r=Km(),o=Date.now()){if(!Xk)return!0;let i=nx(sx(e,t,n));if(!i)return!0;let a=ox(i,ex(r),o);return!a&&j("EV_AI_HOOK_DEBUG")&&x(`DEBUG: duplicate hook event suppressed (claim ${i.slice(0,8)}\u2026)`),a}s(zm,"claimHookEvent");import{mkdirSync as ix,readFileSync as Ta,statSync as Xm,unlinkSync as qm,writeFileSync as ka}from"node:fs";import{homedir as Zm}from"node:os";function Qm(e){return e==="session_start"||e==="session_end"}s(Qm,"isCapExemptEvent");var $o=new Set,Wm=!1;function xa(e=Zm()){return zc(e)}s(xa,"hookSlotDir");function Pa(e,t=Zm(),n=process.platform){if(e!==void 0)return e>0?e:Tr(n);let r=J(Lt(t),{});return ru(r)??Tr(n)}s(Pa,"maxConcurrentHookProcesses");function ur(e){return Pr(e.pid,e.acquiredAtMs)}s(ur,"slotContent");function eg(e){try{let t=Xm(e);return t.isFile()&&t.size<=_s?Ta(e,"utf8"):void 0}catch{return}}s(eg,"readSlotText");function Na(e,t=xa()){if(!e)return;let n=xr(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=eg(n);if(o===ur(r))return jo(r);if(o===Pr(process.ppid,e.acquiredAtMs))try{return ka(n,ur(r),{encoding:"utf8",mode:384}),jo(r)}catch{return}}s(Na,"adoptHookSlot");function tg(e,t){if(e.path){$o.delete(e);try{eg(e.path)===ur(e)&&ka(e.path,Pr(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}s(tg,"handOffHookSlot");function ng(e,t=Date.now()){let n,r;try{let o=Xm(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=_s?Ta(e,"utf8"):""}catch{return!1}return Yc(n,r,t)}s(ng,"isSlotHeld");function rg(e,t=xa(),n=Date.now){for(let r=0;r<e;r+=1)if(!ng(xr(t,r),n()))return!0;return e<=0}s(rg,"hasFreeHookSlot");function og(e){return{pid:process.pid,acquiredAtMs:e}}s(og,"noopSlot");function Ym(e,t){let n=e instanceof Error?e.message:String(e);return x(`WARN: hook process slot failed open: ${n}`),M("slot",e),og(t)}s(Ym,"failOpen");function jo(e){return $o.add(e),Wm||(Wm=!0,process.once("exit",()=>{for(let t of[...$o])Bo(t)})),e}s(jo,"hold");function Jm(e){try{return ka(e.path,ur(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(Ln(t))return!1;throw t}}s(Jm,"tryCreateSlot");function sg(e,t=xa(),n=Date.now){if(e<=0)return og(n());try{ix(t,{recursive:!0})}catch(i){return Ym(i,n())}let r,o=0;for(let i=0;i<e;i+=1)try{let a={path:xr(t,i),pid:process.pid,acquiredAtMs:n()};if(Jm(a))return jo(a);if(ng(a.path,n())){o+=1;continue}try{qm(a.path)}catch(c){if(!Xt(c))throw c}if(a.acquiredAtMs=n(),Jm(a))return jo(a);o+=1}catch(a){r??=a}return r!==void 0&&o>0&&M("slot",r),r===void 0||o>0?null:Ym(r,n())}s(sg,"tryAcquireHookSlot");function Bo(e,t=Date.now()){if($o.delete(e),!(!e.path||t-e.acquiredAtMs>=kr-Mn))try{Ta(e.path,"utf8")===ur(e)&&qm(e.path)}catch{}}s(Bo,"releaseHookSlot");function wa(e){j("EV_AI_HOOK_DEBUG")&&x(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}s(wa,"logHookCapReached");import{closeSync as ax,writeSync as cx}from"node:fs";function ig(e=process.env){let t=e[ms];if(delete e[ms],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{cx(n,vc)}catch{}try{ax(n)}catch{}}}s(ig,"signalLauncherReady");function La(e=process.env){let t=e[Pc];if(t)return{launcherVersion:t,hookSource:e[Nc]??"",fallbackReason:e[wc],launcherScope:e[Lc]}}s(La,"readLauncherContext");function ag(e,t){return(e?Mt(e):void 0)===t}s(ag,"launcherScopeMatch");import{readFileSync as ux,statSync as lx}from"node:fs";import{homedir as fx}from"node:os";import{join as dx}from"node:path";var px="perf-prev.json",mx=512,gx=1440*60*1e3,_x=12e4,hx=50,lr={},cg=!1;function va(e){return Math.round(e*10)/10}s(va,"round1");function Xe(e,t){if(!Dn())return t();let n=performance.now();return t().finally(()=>{lr[e]=va(performance.now()-n)})}s(Xe,"span");function Ex(){for(let e of Object.keys(lr))delete lr[e]}s(Ex,"clearSpans");function lg(){if(!Dn())return;let e=Tu();e&&(process.env[Is]=e)}s(lg,"handOffHookTimings");function ug(e,t){if(!e)return;let n=t-e.origin;return n>=-hx&&n<=_x?e:void 0}s(ug,"trusted");function Sx(e){if(e===null||typeof e!="object")return!1;let t=e;return typeof t.at=="number"&&Number.isFinite(t.at)&&typeof t.post_ms=="number"&&Number.isFinite(t.post_ms)&&t.post_ms>=0}s(Sx,"isPrevPost");function fg(e=fx()){return dx(Ae(e),px)}s(fg,"perfPrevPath");function yx(e,t){if(!cg){cg=!0;try{let n=fg(t);if(lx(n).size>mx)return;let r=JSON.parse(ux(n,"utf8"));return!Sx(r)||e-r.at>gx?void 0:{at:r.at,post_ms:r.post_ms}}catch{return}}}s(yx,"takePrevPost");function Ua(e,t){if(!Dn())return;let n={at:Date.now(),post_ms:Math.max(0,Math.round(e))};try{le(fg(t),JSON.stringify(n))}catch{}}s(Ua,"recordPostDuration");function Ma(e,t,n,r,o=n.marks){let i=Math.max(0,n.origin-r);e[t]=va(i);for(let[a,c]of Object.entries(o))e[a]=va(i+c)}s(Ma,"addProcess");function dg(e,t=process.env,n,r=!1){let o=r?cc():void 0;if(!Dn())return o?{sys:o}:void 0;let i=bu(),a="w0"in i.marks?"w":"h",c=a==="w"?ug(Ts(t[Is]),i.origin):void 0,u=ug(Ts(t[Au]),(c??i).origin),f=u?"l":c?"h":a,l=(u??c??i).origin,p={};u&&Ma(p,"l",u,l),c&&Ma(p,"h",c,l),Ma(p,a,i,l,{...i.marks,...e});let d={base:f,t:p};a==="w"&&c&&p.h3!==void 0&&(d.ack_ms=p.h3),u?.values.bootstrap===1&&(d.bootstrap=!0),Object.keys(lr).length>0&&(d.spans={...lr},Ex());let m=yx(Date.now(),n);return m&&(d.prev=m),o&&(d.sys=o),d}s(dg,"buildPerf");import{realpathSync as nw}from"node:fs";import{homedir as rw}from"node:os";var K=Ie(ke(),1);import{existsSync as Rx,readFileSync as pg}from"node:fs";import{homedir as mg}from"node:os";import{join as Cx}from"node:path";var Ax="cloud-cache.json",Ox="cloud-cache-interactive.json",bx=1440*60*1e3,Ix=900*1e3,Tx=360*60*1e3;function kx(e=mg(),t){let n=t==="interactive"?Ox:Ax;return Cx(Ae(e),n)}s(kx,"cloudCachePath");function xx(e){if(!Rx(e))return;let t=xe(pg(e,"utf8"),{});if(!(typeof t.context!="string"||typeof t.probed_at!="number"||t.result!==null&&t.result!==void 0&&typeof t.result!="object"))return{context:t.context,probed_at:t.probed_at,result:t.result??null}}s(xx,"readCloudCache");function Px(e,t){try{le(e,`${JSON.stringify(t)}
42
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);x(`WARN: cloud cache write failed open: ${r}`),M("cloud_cache",n)}}s(Px,"writeCloudCache");function Nx(e,t,n){return!e||e.context!==t?!1:n-e.probed_at<wx(e)}s(Nx,"isCacheValid");function wx(e){return e.result!==null?bx:e.context==="interactive"?Tx:Ix}s(wx,"cacheTtlMs");var Lx="7783-7084-3265-9085-8269-3286-77",Mx=/^i-[0-9a-f]{8,17}$/,Ko="/sys/class/dmi/id";function vx(e){try{return pg(e,"utf8").trim()}catch{return}}s(vx,"readSysfsText");function Ux(e={}){if((e.platform??process.platform)!=="linux")return!1;let n=e.readFile??vx,r=s(o=>n(o)?.toLowerCase()??"","lower");return r(`${Ko}/sys_vendor`)==="amazon ec2"||r(`${Ko}/product_name`)==="google compute engine"||Mx.test(r(`${Ko}/board_asset_tag`))||r(`${Ko}/chassis_asset_tag`)===Lx?!0:r("/sys/hypervisor/uuid").startsWith("ec2")}s(Ux,"hasCloudVmHint");async function Dx(e){let t=await fetch("http://169.254.169.254/latest/api/token",{method:"PUT",headers:{"X-aws-ec2-metadata-token-ttl-seconds":"60"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=(await t.text()).trim();if(!n)return;let r={"X-aws-ec2-metadata-token":n},[o,i]=await Promise.all([fetch("http://169.254.169.254/latest/meta-data/placement/region",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{}),fetch("http://169.254.169.254/latest/meta-data/instance-id",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{})]);if(!o?.ok&&!i?.ok)return;let a=o?.ok?(await o.text()).trim():"",c=i?.ok?(await i.text()).trim():"";if(!(!a&&!c))return{provider:"aws",region:a,instance_id:c}}s(Dx,"probeAws");async function Hx(e){let t=await fetch("http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true",{headers:{"Metadata-Flavor":"Google"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=typeof n.zone=="string"?n.zone.split("/").pop()??"":"",o=n.id===void 0?"":String(n.id);if(!(!r&&!o))return{provider:"gcp",region:r,instance_id:o}}s(Hx,"probeGcp");async function Fx(e){let t=await fetch("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{headers:{Metadata:"true"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=n.compute?.location??"",o=n.compute?.vmId??"";if(!(!r&&!o))return{provider:"azure",region:r,instance_id:o}}s(Fx,"probeAzure");async function $x(e){let t=await Promise.allSettled([Dx(e),Hx(e),Fx(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}s($x,"runCloudProbes");async function gg(e,t){if(e==="interactive"&&!(t?.hasCloudHint??Ux)())return null;let n=t?.home??mg(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),i=kx(n,e),a=xx(i);if(Nx(a,e,o))return a.result;let c=await $x(r);return Px(i,{context:e,probed_at:o,result:c}),c}s(gg,"probeCloud");var Eg=Ie(ke(),1);import{existsSync as _g}from"node:fs";import{homedir as hg}from"node:os";import{join as Cn,relative as jx,resolve as Da,sep as Ha}from"node:path";function fr(e,t,n){if(!_g(e))return;let r=J(e,{});for(let[o,i]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:i})}s(fr,"readMcpServers");function Bx(e,t,n){if(!_g(e))return;let r=J(e,{}),o=Da(t),i=null;for(let c of Object.keys(r.projects??{})){let u=Da(c);(o===u||o.startsWith(u.endsWith(Ha)?u:u+Ha))&&(i===null||u.length>Da(i).length)&&(i=c)}if(i===null)return;let a=r.projects?.[i]?.mcpServers??{};for(let[c,u]of Object.entries(a))n.set(c,{declared:{name:c,source:"claude_json_project",sourcePath:".claude.json",scope:"user"},config:u})}s(Bx,"readClaudeProjectMcpServers");var Fa=".gemini/config/mcp_config.json",Kx=".agents/mcp_config.json";function Gx(e,t){for(let n of pn(e))if(n.enabled)for(let r of n.mcpConfigFiles){let o=J(r,{}),i=jx(e,r).split(Ha).join("/");for(let[a,c]of Object.entries(o.mcpServers??{})){let u=sp(n.key,a);t.set(u,{declared:{name:u,source:"antigravity_mcp_plugin",sourcePath:i,scope:"user",nativeKey:a},config:c})}}}s(Gx,"readAntigravityPluginMcpServers");function Sg(e,t,n,r){let o=new Map;for(let a of e.mcp_servers??[])a.name&&o.set(a.name,{declared:{name:a.name,source:"manifest"}});n==="claude"?(fr(Cn(r,".claude.json"),{source:"claude_json_user"},o),Bx(Cn(r,".claude.json"),t,o)):n==="cursor"?fr(Cn(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o):n==="antigravity"&&(fr(Cn(r,Fa),{source:"antigravity_mcp_user"},o),Gx(r,o),fr(Cn(t,Kx),{source:"antigravity_mcp_workspace"},o));let i=[[".mcp.json","mcp_json"],[".cursor/mcp.json","cursor_mcp"]];n!=="cursor"&&i.reverse();for(let[a,c]of i)fr(Cn(t,a),{source:c},o);return o}s(Sg,"collectMcpServers");async function $a(e,t=process.cwd(),n="claude",r=hg()){return[...Sg(e,t,n,r).values()].map(o=>o.declared)}s($a,"mcpDeclared");function yg(e,t,n=process.cwd(),r="claude",o=hg()){let i=Sg(t,n,r,o),a=i.get(e);if(a!==void 0)return a.config??null;for(let[c,u]of i)if((0,Eg.mcpServerNameMatchesToolSegment)(c,e))return u.config??null;return null}s(yg,"mcpServerConfig");var Vx=["CI","GITHUB_ACTIONS","GITLAB_CI","CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER","KUBERNETES_SERVICE_HOST","REMOTE_CONTAINERS","DEVCONTAINER","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID","GITHUB_REF","GITHUB_SHA","GITHUB_RUN_ID","GITHUB_WORKFLOW","GITHUB_ACTOR","GITHUB_TRIGGERING_ACTOR","GITHUB_ACTOR_ID","GITHUB_USER","GITLAB_USER_LOGIN","GITLAB_USER_NAME","GITLAB_USER_EMAIL","BUILD_REQUESTEDFOR","BUILD_REQUESTEDFOREMAIL","BUILD_REQUESTEDFORID","BUILDKITE_BUILD_CREATOR","BUILDKITE_BUILD_CREATOR_EMAIL","BUILD_USER","BUILD_USER_ID","BUILD_USER_EMAIL","CHANGE_AUTHOR","CHANGE_AUTHOR_EMAIL","CIRCLE_USERNAME","CODEBUILD_INITIATOR","DRONE_COMMIT_AUTHOR","DRONE_COMMIT_AUTHOR_NAME","DRONE_COMMIT_AUTHOR_EMAIL","EV_AI_HOOK_OPERATOR_NAME","EV_AI_HOOK_OPERATOR_EMAIL","EV_AI_HOOK_OPERATOR_LOGIN","GIT_AUTHOR_NAME","GIT_AUTHOR_EMAIL","GIT_COMMITTER_NAME","GIT_COMMITTER_EMAIL","EMAIL","RUNNER_OS","RUNNER_ARCH","NODE_ENV","TERM_PROGRAM","CLAUDE_CODE_REMOTE","CLAUDE_CODE_REMOTE_SESSION_ID","CURSOR_AGENT","CURSOR_VERSION","CURSOR_CODE_REMOTE","CURSOR_USER_EMAIL","CODESPACES","CODESPACE_NAME","ANTHROPIC_BASE_URL","OPENAI_BASE_URL","OPENAI_API_BASE","AZURE_OPENAI_ENDPOINT","GOOGLE_GEMINI_BASE_URL","GEMINI_API_BASE","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX"],zx=["CURSOR_PROJECT_DIR"],Wx=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function Yx(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)Wx.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}s(Yx,"stripUrlUserinfo");function Rg(e=process.env){let t=Vx.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:Yx(e[r]??"")}:{name:r,present:!1}),n=zx.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}s(Rg,"readEnvVars");import{homedir as yP}from"node:os";import{homedir as Og}from"node:os";import{join as Cg}from"node:path";var Jx="https://api.openai.com/auth";function An(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(An,"trimString");function bg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}s(bg,"asJsonObject");function Xx(e){let t=e.split(".");if(t.length!==3||t.some(r=>r.length===0))return null;let n=t[1];if(!n)return null;try{let r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"));return bg(r)}catch{return null}}s(Xx,"decodeJwtPayload");function Ag(e,t,n){return An(e[n])??An(t?.[n])}s(Ag,"claim");function qx(e=process.env,t=Og()){let n=An(e.CODEX_HOME)??Cg(t,".codex");return Cg(n,"auth.json")}s(qx,"codexAuthPath");function Ig(e=process.env,t=Og()){let n=J(qx(e,t),{}),r=An(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&An(n.OPENAI_API_KEY))return null;let o=An(n.tokens?.id_token);if(!o)return null;let i=Xx(o);if(!i)return null;let a=bg(i[Jx]),c=Ag(i,a,"name"),u=Ag(i,a,"email");return!u||ge(c,u)?null:{git_user_name:null,git_user_email:null,platform_login:u,identity_source:"codex_oauth"}}s(Ig,"readCodexOperatorIdentity");import{homedir as zo}from"node:os";import{join as ft}from"node:path";import{join as Zx}from"node:path";var Qx="cursor-ide-identity.json",eP=840*60*1e3;function kg(e){return Zx(Ae(e),Qx)}s(kg,"cursorIdeIdentityCachePath");function Tg(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Tg,"nullableString");function xg(e){let t=J(e,{}),n=t.read_at_ms,r=t.db_path;if(!(typeof n!="number"||!Number.isFinite(n)||typeof r!="string"))return{read_at_ms:n,db_path:r,email:Tg(t.email),auth_id:Tg(t.auth_id)}}s(xg,"readCursorIdeIdentityCache");function Pg(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<eP}s(Pg,"isCursorIdeIdentityCacheFresh");function Ng(e,t){try{le(e,`${JSON.stringify(t)}
43
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);x(`WARN: cursor IDE identity cache write failed open: ${r}`),M("cursor_identity_cache",n)}}s(Ng,"writeCursorIdeIdentityCache");import{execFileSync as tP}from"node:child_process";import{existsSync as nP}from"node:fs";import{createRequire as rP}from"node:module";import{pathToFileURL as oP}from"node:url";var Lg=rP(import.meta.url),Go=`
44
44
  SELECT key, value
45
45
  FROM ItemTable
46
46
  WHERE key LIKE 'cursorAuth/%'
47
47
  AND key NOT LIKE '%Token%'
48
48
  AND key NOT LIKE '%token%'
49
49
  ORDER BY key
50
- `.trim(),yc=new Map;function Ym(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:null}if(e instanceof Uint8Array){let t=Buffer.from(e).toString("utf8").trim();return t.length>0?t:null}return null}s(Ym,"asText");function qm(e){return e.toLowerCase().includes("token")}s(qm,"isTokenKey");function Zm(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=Ym(r.key),i=Ym(r.value);o&&i&&!qm(o)&&t.set(o,i)}return t}s(Zm,"rowsToMap");function TI(e){let t=II(e);return t.search="mode=ro&immutable=1",t.href}s(TI,"sqliteReadonlyUri");function wI(e){try{let t=Xm("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(wo)??n.prepare(wo);return Zm(r.all?.())}finally{n.close?.()}}catch{return null}}s(wI,"readViaBunSqlite");function NI(e){let t=process.emitWarning.bind(process);process.emitWarning=((n,...r)=>{(typeof n=="string"?n:n instanceof Error?n.message:"").includes("SQLite is an experimental feature")||t(n,...r)});try{return e()}finally{process.emitWarning=t}}s(NI,"withSqliteExperimentalWarningSuppressed");function PI(e){try{return NI(()=>{let t=Xm("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return Zm(n.prepare(wo).all?.())}finally{n.close?.()}})}catch{return null}}s(PI,"readViaNodeSqlite");function MI(e){let t=new Map;for(let n of e.split(`
51
- `)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let i=r.slice(0,o).trim(),c=r.slice(o+1).trim();i&&c&&!qm(i)&&t.set(i,c)}return t}s(MI,"parseCliTable");function LI(e){try{let t=OI("sqlite3",["-noheader","-batch","-separator"," ",e,wo],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return MI(t)}catch{return null}}s(LI,"readViaSqliteCli");function Qm(e){let t=yc.get(e);if(t)return t;if(!kI(e)){let o=new Map;return yc.set(e,o),o}let n=TI(e),r=wI(n)??LI(n)??PI(n)??new Map;return yc.set(e,r),r}s(Qm,"readCursorAuthItems");var vI="cursorAuth/cachedEmail",UI="cursorAuth/stripeMembershipAuthId";function No(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(No,"trimEnv");function HI(e=Po(),t=process.platform,n=process.env){let r=No(n.VSCODE_PORTABLE);if(r)return st(r,"user-data");let o=No(n.VSCODE_APPDATA);if(o)return st(o,"Cursor");switch(t){case"darwin":return st(e,"Library","Application Support","Cursor");case"win32":return st(No(n.APPDATA)??st(e,"AppData","Roaming"),"Cursor");default:return st(No(n.XDG_CONFIG_HOME)??st(e,".config"),"Cursor")}}s(HI,"cursorUserDataDir");function DI(e=Po()){return st(e,".cursor","cli-config.json")}s(DI,"cursorCliConfigPath");function FI(e=Po(),t=process.platform,n=process.env){return st(HI(e,t,n),"User","globalStorage","state.vscdb")}s(FI,"cursorIdeStateDbPath");function rr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(rr,"trimString");function $I(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):rr(e.userId)}s($I,"numericUserId");function jI(e){return rr(e.email)??rr(e.authId)??$I(e)}s(jI,"platformLogin");function Rc(e){let t=rr(e.email),n=rr(e.displayName),r=jI(e);return!r||pe(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}s(Rc,"identityFromAuth");function BI(e){let n=Q(DI(e),{}).authInfo;return!n||typeof n!="object"?null:Rc(n)}s(BI,"readCliOperatorIdentity");function KI(e,t,n){let r=FI(e,process.platform,t),o=Vm(e),i=zm(o);if(Wm(i,r,n))return Rc({email:i?.email,authId:i?.auth_id});let c=Qm(r),a=c.get(vI)??null,u=c.get(UI)??null;return Jm(o,{read_at_ms:n,db_path:r,email:a,auth_id:u}),Rc({email:a,authId:u})}s(KI,"readIdeOperatorIdentity");function eg(e=Po(),t=process.env,n=Date.now()){return BI(e)??KI(e,t,n)}s(eg,"readCursorOperatorIdentity");function VI(e,t,n="git_config",r=null){return X(`${e??""}|${t??""}|${r??""}|${n}`)}s(VI,"hashOperatorIdentity");async function zI(e,t=ne,n){let r=await go(e,{exec:t,cachePath:n});return{git_user_name:r.userName,git_user_email:r.userEmail,platform_login:null}}s(zI,"readGitOperatorIdentity");function WI(e=process.env){let t=z(e.GIT_AUTHOR_NAME),n=z(e.GIT_AUTHOR_EMAIL);if(t||n)return{git_user_name:t,git_user_email:n,platform_login:null,identity_source:"git_env"};let r=z(e.GIT_COMMITTER_NAME),o=z(e.GIT_COMMITTER_EMAIL);if(r||o)return{git_user_name:r,git_user_email:o,platform_login:null,identity_source:"git_env"};let i=z(e.EMAIL);return i?{git_user_name:null,git_user_email:i,platform_login:null,identity_source:"git_env"}:null}s(WI,"readGitEnvOperatorIdentity");function it(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}s(it,"actorIdentity");function Cc(e){let t=e?.trim();return t&&!pe(null,t)?t:null}s(Cc,"humanEmail");function JI(e,t){return Cc(t.cursorOwner?.userEmail)??Cc(e.CURSOR_USER_EMAIL)??Cc(t.hookUserEmail)??z(t.cursorOwner?.userId??void 0)}s(JI,"cursorCloudLogin");function YI(e=process.env,t,n={}){let r=z(e.EV_AI_HOOK_OPERATOR_EMAIL),o=z(e.EV_AI_HOOK_OPERATOR_LOGIN),i=it(z(e.EV_AI_HOOK_OPERATOR_NAME),r,"configured",r??o);if(i)return i;let c=z(e.GITHUB_ACTOR)??z(e.GITHUB_TRIGGERING_ACTOR)??z(e.GITHUB_USER),a=it(c,null,"github",c);if(a)return a;let u=z(e.GITLAB_USER_LOGIN),f=z(e.GITLAB_USER_EMAIL),l=it(z(e.GITLAB_USER_NAME)??u,f,"gitlab",f??u);if(l)return l;let p=z(e.BUILD_REQUESTEDFOREMAIL),d=it(z(e.BUILD_REQUESTEDFOR),p,"azure_devops",p??z(e.BUILD_REQUESTEDFORID));if(d)return d;let m=z(e.BUILDKITE_BUILD_CREATOR_EMAIL),g=it(z(e.BUILDKITE_BUILD_CREATOR),m,"buildkite",m);if(g)return g;let h=z(e.BUILD_USER_EMAIL)??z(e.CHANGE_AUTHOR_EMAIL),y=it(z(e.BUILD_USER)??z(e.CHANGE_AUTHOR),h,"jenkins",h??z(e.BUILD_USER_ID));if(y)return y;let b=z(e.CIRCLE_USERNAME),w=it(b,null,"circleci",b);if(w)return w;let N=z(e.CODEBUILD_INITIATOR),x=it(N,null,"codebuild",N);if(x)return x;let O=z(e.DRONE_COMMIT_AUTHOR_EMAIL),U=z(e.DRONE_COMMIT_AUTHOR),M=it(U??z(e.DRONE_COMMIT_AUTHOR_NAME),O,"drone",O??U);if(M)return M;if(tg(e.CLAUDE_CODE_REMOTE)||tg(e.CURSOR_AGENT)||t!==void 0&&XI.has(t)){let k=JI(e,n);return k?{git_user_name:null,git_user_email:null,platform_login:k,identity_source:"cursor_oauth"}:{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"cloud"}}return null}s(YI,"readCloudOperatorIdentity");var XI=new Set(["cursor_cloud","claude_remote"]);function Ac(e){return!!((e.git_user_name??e.git_user_email)&&!pe(e.git_user_name,e.git_user_email))}s(Ac,"isHumanOperator");function z(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(z,"trimEnv");function tg(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(tg,"isTruthyEnv");function qI(e,t,n){return e==="claude"?Xa(t):e==="cursor"?eg(t,n):e==="codex"?Km(n,t):null}s(qI,"readRunnerOperatorIdentity");async function bc(e,t=ne,n=process.env,r={}){let o=await zI(e,t,r.gitConfigCachePath),i=WI(n),c=Ac(o)?o:i&&Ac(i)?i:null,a=r.home??GI(),u=qI(r.runnerPlatform,a,n);if(u)return{git_user_name:c?.git_user_name??null,git_user_email:c?.git_user_email??null,platform_login:u.platform_login,identity_source:u.identity_source};let f=r.context==="cursor_cloud"?await Lr({env:n,home:a}):null,l=YI(n,r.context,{cursorOwner:f,hookUserEmail:r.hookUserEmail});return l?.platform_login?{git_user_name:c?.git_user_name??null,git_user_email:c?.git_user_email??null,platform_login:l.platform_login,identity_source:l.identity_source}:c?{...c,platform_login:null,identity_source:Ac(o)?"git_config":"git_env"}:l||(o.git_user_name||o.git_user_email?{...o,identity_source:"git_config"}:i||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}s(bc,"resolveOperatorIdentity");async function Oc(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??ne,i=e.env??process.env,c=await bc(t,o,i,{runnerPlatform:e.runnerPlatform,home:e.home,context:e.context,hookUserEmail:e.hookUserEmail,gitConfigCachePath:e.gitConfigCachePath}),a=VI(c.git_user_name,c.git_user_email,c.identity_source,c.platform_login),f=(n?qi(n):void 0)?.operator_identity_hash;if(!(r||f!==void 0&&f!==a||!f))return{commit:s(()=>{},"commit")};let m=n;return{operator:c,commit:s(()=>{m&&Op(m,a,dr())},"commit")}}s(Oc,"resolveOperatorForSend");function kc(e){return e?!qi(e)?.operator_identity_hash:!0}s(kc,"operatorIdentityNeverSent");var ZI=new Set(["claude","codex","copilot"]);function ng(e,t){return!(t!==void 0&&ZI.has(t))}s(ng,"shouldBootstrapCloudIdentity");import{homedir as ST}from"node:os";import{join as sg}from"node:path";import{join as Mo}from"node:path";function QI(e){return Mo(e,".ev-ai","agent-hook","js","signed-v1")}s(QI,"jsRoot");function eT(e){return Mo(QI(e),"scopes")}s(eT,"scopesRoot");function rg(e,t){return Mo(eT(e),t)}s(rg,"scopeDir");function og(e){return Mo(e,"attempts")}s(og,"attemptsDir");function xc(e){return String(e).padStart(10,"0")}s(xc,"padAttempt");var tT=/^(\d{10})$/,nT=/^(\d{10})\.done$/,rT=/^[0-9a-f]{128}$/,oT=64,ug=["check_ms","download_ms","install_ms","total_ms"],sT=36e5;async function lg(e,t,n=!1){let r=og(t),o=await ya(e,r),i=new Map,c=new Map,a=ig(o,tT),u=ig(o,nT),f=s(async d=>{let m=await ag(e,sg(r,iT(d)));return m&&i.set(d,{record:aT(m.value),mtimeMs:m.mtimeMs}),m!==void 0},"readClaimAt"),l=s(async d=>{let m=uT((await ag(e,sg(r,cT(d))))?.value);return m&&c.set(d,m),m!==void 0},"readDoneAt");if(!n)return await Promise.all([...a.map(f),...u.map(l)]),{claims:i,dones:c};await Promise.all([cg(a,f),cg(u,l)]);let p=or(i);return p<or(c)&&u.includes(p)&&await l(p),{claims:i,dones:c}}s(lg,"scanAttempts");function ig(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}s(ig,"attemptNumbers");async function cg(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}s(cg,"firstFromTop");function or(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}s(or,"maxKey");function fg(e){if(e.record!=="empty"&&e.record.started_at){let t=Date.parse(e.record.started_at);if(Number.isFinite(t))return t}return e.mtimeMs}s(fg,"claimStartMs");function dg(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of ug){let r=e[n];r!==void 0&&(t[n]=r)}return t}s(dg,"pickTimings");function iT(e){return xc(e)}s(iT,"claimFileName");function cT(e){return`${xc(e)}.done`}s(cT,"doneFileName");async function ag(e,t){let n;try{n=await e.stat(t)}catch(o){if(Gt(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>ts)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>ts?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}s(ag,"readRecord");function aT(e){if(!fe(e))return"empty";let t={};return typeof e.started_at=="string"&&(t.started_at=e.started_at),(e.owner==="bootstrap"||e.owner==="refresh")&&(t.owner=e.owner),e.resync===!0&&(t.resync=!0),t}s(aT,"parseClaim");function uT(e){if(!fe(e))return;let t=e;if(typeof t.finished_at!="string"||typeof t.outcome!="string"||typeof t.interval_s!="number"||!Number.isFinite(t.interval_s))return;let n=fT(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...lT(t)}}s(uT,"parseDoneRecord");function lT(e){let t={};typeof e.started_at=="string"&&Number.isFinite(Date.parse(e.started_at))&&(t.started_at=e.started_at);for(let n of ug){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=sT&&(t[n]=r)}return t}s(lT,"parseTimings");function fT(e){if(!fe(e))return;let t=e;if(t.kind==="bundled")return t.why==="server"||t.why==="bootstrap_failed"?{kind:"bundled",why:t.why}:void 0;if(t.kind==="cached"&&typeof t.digest=="string"&&rT.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&dT(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}s(fT,"parseSelection");function dT(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==oT||t.toString("base64")!==e))return t.toString("hex")}s(dT,"canonicalSha512Hex");function _T(e){return e==="bootstrap"?3e3:6e4}s(_T,"ownerBudgetMs");function hT(e,t){let n=or(e.claims);if(n===0)return;let r=or(e.dones),o=e.claims.get(n),i=e.dones.get(n);if(o&&!i){let a=fg(o),u=o.record==="empty"?void 0:o.record.owner,f=_T(u)+3e4;if(t-a>f)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:pg(e.dones.get(r)?.selection)}}if(r===0)return;let c=e.dones.get(r);if(c)return{n:r,latest_claim:n,outcome:c.outcome,finished_at:c.finished_at,selection_version:pg(c.selection),...dg(c)}}s(hT,"latestAttemptReport");async function mg(e,t,n){try{let r=await lg(Ra(),rg(e,t),!0);return hT(r,n)}catch{return}}s(mg,"readLatestAttemptReport");function pg(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}s(pg,"selectionVersion");function ET(e=process.env){if(Object.values(Ja).some(n=>e[n]))return"plugin";let t=e.npm_lifecycle_script?.trim().split(/\s+/)[0]?.replace(/^["']|["']$/g,"");return e.npm_lifecycle_event==="npx"&&t===Jt?"npx":null}s(ET,"hookDelivery");async function gg(e=ST()){let t=pc()?.launcherScope;if(!t)return{};let n=await mg(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}s(gg,"readSessionStartLauncherFields");function _n(e,t,n){let r={installation_id:n.installationId};n.platformAgentId&&(r.platform_agent_id=n.platformAgentId),n.sessionId&&(r.session_id=n.sessionId),n.turnId&&(r.turn_id=n.turnId);let o={schema_version:kr,event:e,timestamp:dr(),session_id:n.sessionId||null,turn_id:n.turnId||null,installation_id:n.installationId,platform:n.runnerPlatform,platform_agent_id:n.platformAgentId||null,runner_event:n.runnerEvent||null,agent_hook_version:Ye,hook_delivery:ET(),host_arch:process.arch,host_os:process.platform,node_version:process.version,policy_version:null,policy_capabilities:[],...n.promptCaptureSource!==void 0?{prompt_capture_source:n.promptCaptureSource}:{},...n.telemetry!==void 0?{telemetry_source:n.telemetry.source}:{},correlation:r,payload:t},i=pc();return i&&(o.launcher_version=i.launcherVersion,o.hook_source=i.hookSource,o.hook_fallback_reason=i.fallbackReason??null,o.launcher_scope_match=Am(n.collectorUrl,i.launcherScope)),e==="session_start"&&(n.launcher_scope&&(o.launcher_scope=n.launcher_scope),n.launcher_attempt&&(o.launcher_attempt=n.launcher_attempt)),o}s(_n,"buildEnvelope");import{existsSync as Og}from"node:fs";import{spawn as kg}from"node:child_process";import{fileURLToPath as JT}from"node:url";import{gzipSync as yT}from"node:zlib";function Ic(e){return F("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<Wa?{body:e}:{body:yT(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}s(Ic,"gzipBodyIfLarge");function Lo(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}s(Lo,"collectorPostHeaders");function Tc(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}s(Tc,"postBodyByteLength");import{readFileSync as RT,statSync as CT}from"node:fs";import{homedir as wc}from"node:os";import{join as AT}from"node:path";var bT="hook-config.json",OT=1440*60*1e3,kT=2048,xT=1024*1024;function hn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(hn,"isRecord");function _g(e=wc()){return AT(Re(e),bT)}s(_g,"hookConfigPath");function hg(e){let t=_g(e);try{let n=CT(t);if(!n.isFile()||n.size>xT)return;let r=JSON.parse(RT(t,"utf8"));return hn(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}s(hg,"readStore");function IT(e){let t={};return typeof e.collect_prompt=="boolean"&&(t.collect_prompt=e.collect_prompt),typeof e.collect_telemetry=="boolean"&&(t.collect_telemetry=e.collect_telemetry),typeof e.log_until=="string"&&(e.log_until===Yt||!Number.isNaN(Date.parse(e.log_until)))&&(t.log_until=e.log_until),t}s(IT,"knownKeys");function Sg(e,t=wc()){if(!e)return;let n=Ot(e);if(!n)return;let r=hg(t),o=r?r[n]:void 0;if(!(!hn(o)||!hn(o.config)))return IT(o.config)}s(Sg,"readHookConfig");function TT(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!hn(n)||!hn(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>kT))return n.hook_config}s(TT,"hookConfigFromBody");function wT(e,t,n,r){let o={...e},i=o[t];if(Object.keys(n).length===0)return i===void 0?void 0:(delete o[t],o);if(!(hn(i)&&JSON.stringify(i.config)===JSON.stringify(n)&&typeof i.fetched_at_ms=="number"&&i.fetched_at_ms<=r&&r-i.fetched_at_ms<OT))return o[t]={config:n,fetched_at_ms:r},o}s(wT,"nextStore");function Eg(e,t,n=wc(),r=Date.now()){let o=TT(e),i=t?Ot(t):void 0;if(o===void 0||!i)return"skipped";try{let c=hg(n);if(c===void 0)return re.error("failed where=hook_config_read err=unreadable message=hook config store is not a readable JSON object"),"skipped";let a=wT(c??{},i,o,r);return a?(ae(_g(n),`${JSON.stringify(a,null,2)}
52
- `),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(c){let a=c instanceof Error?c.message:String(c);return T(`WARN: hook config write failed open: ${a}`),L("hook_config_write",c),"failed"}}s(Eg,"applyCollectorHookConfigResponse");var Ft=class extends Error{static{s(this,"ProxyError")}code;status;constructor(t,n,r){super(n),this.name="ProxyError",this.code=t,this.status=r}};function yg(e,t){for(let n of[t,t.toUpperCase()]){let r=e[n]?.trim();if(r)return{name:n,value:r}}}s(yg,"envValue");function vo(e){let t=e.toLowerCase().replace(/\.$/,"");return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}s(vo,"bareHost");function NT(e){let t=vo(e);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}s(NT,"isLoopbackHost");function PT(e,t){let n=vo(e.hostname),r=e.port||(e.protocol==="http:"?"80":"443"),o=n.includes(":")||/^[\d.]+$/.test(n);return t.split(/[\s,]+/).some(i=>{let c=i.toLowerCase();if(c==="*")return!0;let a=/^\[([^\]]+)\](?::(\d+))?$/.exec(c)??/^([^:]+):(\d+)$/.exec(c);if(a){if(a[2]!==void 0&&a[2]!==r)return!1;c=a[1]??""}return c=c.replace(/^\*?\.?/,"").replace(/\.$/,""),c!==""&&(n===c||!o&&n.endsWith(`.${c}`))})}s(PT,"noProxyMatches");function MT(e){try{let t=new URL(e.includes("://")?e:`http://${e}`);return(t.protocol==="http:"||t.protocol==="https:")&&t.hostname?t:void 0}catch{return}}s(MT,"parseProxyUrl");function Cg(e,t=process.env,n){if(e.protocol!=="https:"&&e.protocol!=="http:"||NT(e.hostname))return;let r=yg(t,`${e.protocol.slice(0,-1)}_proxy`);if(!r)return;let o=yg(t,"no_proxy");if(o&&PT(e,o.value))return;let i=MT(r.value);return n?.(i?`${e.host} via proxy ${i.protocol}//${i.host}`:`ignoring ${r.name}: not an http(s) URL`),i}s(Cg,"proxyForUrl");function Rg(e){try{return decodeURIComponent(e)}catch{return e}}s(Rg,"decodeUserinfo");function Ag(e){if(!e.username&&!e.password)return;let t=`${Rg(e.username)}:${Rg(e.password)}`;return`Basic ${Buffer.from(t,"utf8").toString("base64")}`}s(Ag,"proxyAuthorization");var LT=16*1024;async function vT(e,t,n){let[r,o]=await Promise.all([import("node:net"),import("node:tls")]),i=vo(t.hostname),c=Number(t.port)||(t.protocol==="https:"?443:80),a=s(u=>r.isIP(u)?void 0:u,"servername");return new Promise((u,f)=>{let{signal:l,timeout:p}=n;if(l?.aborted){f(l.reason);return}let d=t.protocol==="https:"?o.connect({host:i,port:c,servername:a(i),ca:n.ca}):r.connect({host:i,port:c}),m=!1,g=Buffer.alloc(0),h=s(()=>m?!1:(m=!0,l?.removeEventListener("abort",w),d.setTimeout(0),d.removeListener("data",N),!0),"settle"),y=s(x=>{h()&&(d.destroy(),f(x))},"fail"),b=s(x=>{h()&&u(x)},"succeed"),w=s(()=>{y(l?.reason)},"onAbort");function N(x){g=Buffer.concat([g,x]);let O=g.indexOf(`\r
50
+ `.trim(),ja=new Map;function wg(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:null}if(e instanceof Uint8Array){let t=Buffer.from(e).toString("utf8").trim();return t.length>0?t:null}return null}s(wg,"asText");function Mg(e){return e.toLowerCase().includes("token")}s(Mg,"isTokenKey");function vg(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=wg(r.key),i=wg(r.value);o&&i&&!Mg(o)&&t.set(o,i)}return t}s(vg,"rowsToMap");function sP(e){let t=oP(e);return t.search="mode=ro&immutable=1",t.href}s(sP,"sqliteReadonlyUri");function iP(e){try{let t=Lg("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(Go)??n.prepare(Go);return vg(r.all?.())}finally{n.close?.()}}catch{return null}}s(iP,"readViaBunSqlite");function aP(e){let t=process.emitWarning.bind(process);process.emitWarning=((n,...r)=>{(typeof n=="string"?n:n instanceof Error?n.message:"").includes("SQLite is an experimental feature")||t(n,...r)});try{return e()}finally{process.emitWarning=t}}s(aP,"withSqliteExperimentalWarningSuppressed");function cP(e){try{return aP(()=>{let t=Lg("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return vg(n.prepare(Go).all?.())}finally{n.close?.()}})}catch{return null}}s(cP,"readViaNodeSqlite");function uP(e){let t=new Map;for(let n of e.split(`
51
+ `)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let i=r.slice(0,o).trim(),a=r.slice(o+1).trim();i&&a&&!Mg(i)&&t.set(i,a)}return t}s(uP,"parseCliTable");function lP(e){try{let t=tP("sqlite3",["-noheader","-batch","-separator"," ",e,Go],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return uP(t)}catch{return null}}s(lP,"readViaSqliteCli");function Ug(e){let t=ja.get(e);if(t)return t;if(!nP(e)){let o=new Map;return ja.set(e,o),o}let n=sP(e),r=iP(n)??lP(n)??cP(n)??new Map;return ja.set(e,r),r}s(Ug,"readCursorAuthItems");var fP="cursorAuth/cachedEmail",dP="cursorAuth/stripeMembershipAuthId";function Vo(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(Vo,"trimEnv");function pP(e=zo(),t=process.platform,n=process.env){let r=Vo(n.VSCODE_PORTABLE);if(r)return ft(r,"user-data");let o=Vo(n.VSCODE_APPDATA);if(o)return ft(o,"Cursor");switch(t){case"darwin":return ft(e,"Library","Application Support","Cursor");case"win32":return ft(Vo(n.APPDATA)??ft(e,"AppData","Roaming"),"Cursor");default:return ft(Vo(n.XDG_CONFIG_HOME)??ft(e,".config"),"Cursor")}}s(pP,"cursorUserDataDir");function mP(e=zo()){return ft(e,".cursor","cli-config.json")}s(mP,"cursorCliConfigPath");function gP(e=zo(),t=process.platform,n=process.env){return ft(pP(e,t,n),"User","globalStorage","state.vscdb")}s(gP,"cursorIdeStateDbPath");function dr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(dr,"trimString");function _P(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):dr(e.userId)}s(_P,"numericUserId");function hP(e){return dr(e.email)??dr(e.authId)??_P(e)}s(hP,"platformLogin");function Ba(e){let t=dr(e.email),n=dr(e.displayName),r=hP(e);return!r||ge(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}s(Ba,"identityFromAuth");function EP(e){let n=J(mP(e),{}).authInfo;return!n||typeof n!="object"?null:Ba(n)}s(EP,"readCliOperatorIdentity");function SP(e,t,n){let r=gP(e,process.platform,t),o=kg(e),i=xg(o);if(Pg(i,r,n))return Ba({email:i?.email,authId:i?.auth_id});let a=Ug(r),c=a.get(fP)??null,u=a.get(dP)??null;return Ng(o,{read_at_ms:n,db_path:r,email:c,auth_id:u}),Ba({email:c,authId:u})}s(SP,"readIdeOperatorIdentity");function Dg(e=zo(),t=process.env,n=Date.now()){return EP(e)??SP(e,t,n)}s(Dg,"readCursorOperatorIdentity");function RP(e,t,n="git_config",r=null){return q(`${e??""}|${t??""}|${r??""}|${n}`)}s(RP,"hashOperatorIdentity");async function CP(e,t=re,n){let r=await xo(e,{exec:t,cachePath:n});return{git_user_name:r.userName,git_user_email:r.userEmail,platform_login:null}}s(CP,"readGitOperatorIdentity");function AP(e=process.env){let t=Y(e.GIT_AUTHOR_NAME),n=Y(e.GIT_AUTHOR_EMAIL);if(t||n)return{git_user_name:t,git_user_email:n,platform_login:null,identity_source:"git_env"};let r=Y(e.GIT_COMMITTER_NAME),o=Y(e.GIT_COMMITTER_EMAIL);if(r||o)return{git_user_name:r,git_user_email:o,platform_login:null,identity_source:"git_env"};let i=Y(e.EMAIL);return i?{git_user_name:null,git_user_email:i,platform_login:null,identity_source:"git_env"}:null}s(AP,"readGitEnvOperatorIdentity");function dt(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}s(dt,"actorIdentity");function Ka(e){let t=e?.trim();return t&&!ge(null,t)?t:null}s(Ka,"humanEmail");function OP(e,t){return Ka(t.cursorOwner?.userEmail)??Ka(e.CURSOR_USER_EMAIL)??Ka(t.hookUserEmail)??Y(t.cursorOwner?.userId??void 0)}s(OP,"cursorCloudLogin");function bP(e=process.env,t,n={}){let r=Y(e.EV_AI_HOOK_OPERATOR_EMAIL),o=Y(e.EV_AI_HOOK_OPERATOR_LOGIN),i=dt(Y(e.EV_AI_HOOK_OPERATOR_NAME),r,"configured",r??o);if(i)return i;let a=Y(e.GITHUB_ACTOR)??Y(e.GITHUB_TRIGGERING_ACTOR)??Y(e.GITHUB_USER),c=dt(a,null,"github",a);if(c)return c;let u=Y(e.GITLAB_USER_LOGIN),f=Y(e.GITLAB_USER_EMAIL),l=dt(Y(e.GITLAB_USER_NAME)??u,f,"gitlab",f??u);if(l)return l;let p=Y(e.BUILD_REQUESTEDFOREMAIL),d=dt(Y(e.BUILD_REQUESTEDFOR),p,"azure_devops",p??Y(e.BUILD_REQUESTEDFORID));if(d)return d;let m=Y(e.BUILDKITE_BUILD_CREATOR_EMAIL),g=dt(Y(e.BUILDKITE_BUILD_CREATOR),m,"buildkite",m);if(g)return g;let E=Y(e.BUILD_USER_EMAIL)??Y(e.CHANGE_AUTHOR_EMAIL),S=dt(Y(e.BUILD_USER)??Y(e.CHANGE_AUTHOR),E,"jenkins",E??Y(e.BUILD_USER_ID));if(S)return S;let C=Y(e.CIRCLE_USERNAME),P=dt(C,null,"circleci",C);if(P)return P;let N=Y(e.CODEBUILD_INITIATOR),T=dt(N,null,"codebuild",N);if(T)return T;let b=Y(e.DRONE_COMMIT_AUTHOR_EMAIL),U=Y(e.DRONE_COMMIT_AUTHOR),L=dt(U??Y(e.DRONE_COMMIT_AUTHOR_NAME),b,"drone",b??U);if(L)return L;if(Hg(e.CLAUDE_CODE_REMOTE)||Hg(e.CURSOR_AGENT)||t!==void 0&&IP.has(t)){let I=OP(e,n);return I?{git_user_name:null,git_user_email:null,platform_login:I,identity_source:"cursor_oauth"}:{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"cloud"}}return null}s(bP,"readCloudOperatorIdentity");var IP=new Set(["cursor_cloud","claude_remote"]);function Ga(e){return!!((e.git_user_name??e.git_user_email)&&!ge(e.git_user_name,e.git_user_email))}s(Ga,"isHumanOperator");function Y(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(Y,"trimEnv");function Hg(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(Hg,"isTruthyEnv");function TP(e,t,n){return e==="claude"?Su(t):e==="cursor"?Dg(t,n):e==="codex"?Ig(n,t):null}s(TP,"readRunnerOperatorIdentity");async function Va(e,t=re,n=process.env,r={}){let o=await CP(e,t,r.gitConfigCachePath),i=AP(n),a=Ga(o)?o:i&&Ga(i)?i:null,c=r.home??yP(),u=TP(r.runnerPlatform,c,n);if(u)return{git_user_name:a?.git_user_name??null,git_user_email:a?.git_user_email??null,platform_login:u.platform_login,identity_source:u.identity_source};let f=r.context==="cursor_cloud"?await Br({env:n,home:c}):null,l=bP(n,r.context,{cursorOwner:f,hookUserEmail:r.hookUserEmail});return l?.platform_login?{git_user_name:a?.git_user_name??null,git_user_email:a?.git_user_email??null,platform_login:l.platform_login,identity_source:l.identity_source}:a?{...a,platform_login:null,identity_source:Ga(o)?"git_config":"git_env"}:l||(o.git_user_name||o.git_user_email?{...o,identity_source:"git_config"}:i||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}s(Va,"resolveOperatorIdentity");async function za(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??re,i=e.env??process.env,a=await Va(t,o,i,{runnerPlatform:e.runnerPlatform,home:e.home,context:e.context,hookUserEmail:e.hookUserEmail,gitConfigCachePath:e.gitConfigCachePath}),c=RP(a.git_user_name,a.git_user_email,a.identity_source,a.platform_login),f=(n?Ea(n):void 0)?.operator_identity_hash;if(!(r||f!==void 0&&f!==c||!f))return{commit:s(()=>{},"commit")};let m=n;return{operator:a,commit:s(()=>{m&&im(m,c,Rr())},"commit")}}s(za,"resolveOperatorForSend");function Wa(e){return e?!Ea(e)?.operator_identity_hash:!0}s(Wa,"operatorIdentityNeverSent");var kP=new Set(["claude","codex","copilot"]);function Fg(e,t){return!(t!==void 0&&kP.has(t))}s(Fg,"shouldBootstrapCloudIdentity");import{homedir as YP}from"node:os";import{join as Bg}from"node:path";import{join as Wo}from"node:path";function xP(e){return Wo(e,".ev-ai","agent-hook","js","signed-v1")}s(xP,"jsRoot");function PP(e){return Wo(xP(e),"scopes")}s(PP,"scopesRoot");function $g(e,t){return Wo(PP(e),t)}s($g,"scopeDir");function jg(e){return Wo(e,"attempts")}s(jg,"attemptsDir");function Ya(e){return String(e).padStart(10,"0")}s(Ya,"padAttempt");var NP=/^(\d{10})$/,wP=/^(\d{10})\.done$/,LP=/^[0-9a-f]{128}$/,MP=64,zg=["check_ms","download_ms","install_ms","total_ms"],vP=36e5;async function Wg(e,t,n=!1){let r=jg(t),o=await $c(e,r),i=new Map,a=new Map,c=Kg(o,NP),u=Kg(o,wP),f=s(async d=>{let m=await Vg(e,Bg(r,UP(d)));return m&&i.set(d,{record:HP(m.value),mtimeMs:m.mtimeMs}),m!==void 0},"readClaimAt"),l=s(async d=>{let m=FP((await Vg(e,Bg(r,DP(d))))?.value);return m&&a.set(d,m),m!==void 0},"readDoneAt");if(!n)return await Promise.all([...c.map(f),...u.map(l)]),{claims:i,dones:a};await Promise.all([Gg(c,f),Gg(u,l)]);let p=pr(i);return p<pr(a)&&u.includes(p)&&await l(p),{claims:i,dones:a}}s(Wg,"scanAttempts");function Kg(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}s(Kg,"attemptNumbers");async function Gg(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}s(Gg,"firstFromTop");function pr(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}s(pr,"maxKey");function Yg(e){if(e.record!=="empty"&&e.record.started_at){let t=Date.parse(e.record.started_at);if(Number.isFinite(t))return t}return e.mtimeMs}s(Yg,"claimStartMs");function Jg(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of zg){let r=e[n];r!==void 0&&(t[n]=r)}return t}s(Jg,"pickTimings");function UP(e){return Ya(e)}s(UP,"claimFileName");function DP(e){return`${Ya(e)}.done`}s(DP,"doneFileName");async function Vg(e,t){let n;try{n=await e.stat(t)}catch(o){if(Xt(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>gs)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>gs?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}s(Vg,"readRecord");function HP(e){if(!nt(e))return"empty";let t={};return typeof e.started_at=="string"&&(t.started_at=e.started_at),(e.owner==="bootstrap"||e.owner==="refresh")&&(t.owner=e.owner),e.resync===!0&&(t.resync=!0),t}s(HP,"parseClaim");function FP(e){if(!nt(e))return;let t=e;if(typeof t.finished_at!="string"||typeof t.outcome!="string"||typeof t.interval_s!="number"||!Number.isFinite(t.interval_s))return;let n=jP(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...$P(t)}}s(FP,"parseDoneRecord");function $P(e){let t={};typeof e.started_at=="string"&&Number.isFinite(Date.parse(e.started_at))&&(t.started_at=e.started_at);for(let n of zg){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=vP&&(t[n]=r)}return t}s($P,"parseTimings");function jP(e){if(!nt(e))return;let t=e;if(t.kind==="bundled")return t.why==="server"||t.why==="bootstrap_failed"?{kind:"bundled",why:t.why}:void 0;if(t.kind==="cached"&&typeof t.digest=="string"&&LP.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&BP(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}s(jP,"parseSelection");function BP(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==MP||t.toString("base64")!==e))return t.toString("hex")}s(BP,"canonicalSha512Hex");function zP(e){return e==="bootstrap"?3e3:6e4}s(zP,"ownerBudgetMs");function WP(e,t){let n=pr(e.claims);if(n===0)return;let r=pr(e.dones),o=e.claims.get(n),i=e.dones.get(n);if(o&&!i){let c=Yg(o),u=o.record==="empty"?void 0:o.record.owner,f=zP(u)+3e4;if(t-c>f)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:Xg(e.dones.get(r)?.selection)}}if(r===0)return;let a=e.dones.get(r);if(a)return{n:r,latest_claim:n,outcome:a.outcome,finished_at:a.finished_at,selection_version:Xg(a.selection),...Jg(a)}}s(WP,"latestAttemptReport");async function qg(e,t,n){try{let r=await Wg(jc(),$g(e,t),!0);return WP(r,n)}catch{return}}s(qg,"readLatestAttemptReport");function Xg(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}s(Xg,"selectionVersion");function JP(e=process.env){if(Object.values(mu).some(n=>e[n]))return"plugin";let t=e.npm_lifecycle_script?.trim().split(/\s+/)[0]?.replace(/^["']|["']$/g,"");return e.npm_lifecycle_event==="npx"&&t===tn?"npx":null}s(JP,"hookDelivery");async function Zg(e=YP()){let t=La()?.launcherScope;if(!t)return{};let n=await qg(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}s(Zg,"readSessionStartLauncherFields");function On(e,t,n){let r={installation_id:n.installationId};n.platformAgentId&&(r.platform_agent_id=n.platformAgentId),n.sessionId&&(r.session_id=n.sessionId),n.turnId&&(r.turn_id=n.turnId);let o={schema_version:Lr,event:e,timestamp:Rr(),session_id:n.sessionId||null,turn_id:n.turnId||null,installation_id:n.installationId,platform:n.runnerPlatform,platform_agent_id:n.platformAgentId||null,runner_event:n.runnerEvent||null,agent_hook_version:Qe,hook_delivery:JP(),host_arch:process.arch,host_os:process.platform,node_version:process.version,policy_version:null,policy_capabilities:[],...n.promptCaptureSource!==void 0?{prompt_capture_source:n.promptCaptureSource}:{},...n.telemetry!==void 0?{telemetry_source:n.telemetry.source}:{},correlation:r,payload:t},i=La();return i&&(o.launcher_version=i.launcherVersion,o.hook_source=i.hookSource,o.hook_fallback_reason=i.fallbackReason??null,o.launcher_scope_match=ag(n.collectorUrl,i.launcherScope)),e==="session_start"&&(n.launcher_scope&&(o.launcher_scope=n.launcher_scope),n.launcher_attempt&&(o.launcher_attempt=n.launcher_attempt)),o}s(On,"buildEnvelope");import{existsSync as c_}from"node:fs";import{spawn as u_}from"node:child_process";import{fileURLToPath as ON}from"node:url";import{gzipSync as XP}from"node:zlib";function Ja(e){return j("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<pu?{body:e}:{body:XP(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}s(Ja,"gzipBodyIfLarge");function Yo(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}s(Yo,"collectorPostHeaders");function Xa(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}s(Xa,"postBodyByteLength");import{readFileSync as qP,statSync as ZP}from"node:fs";import{homedir as qa}from"node:os";import{join as QP}from"node:path";var eN="hook-config.json",tN=1440*60*1e3,nN=2048,rN=1024*1024;function bn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(bn,"isRecord");function Qg(e=qa()){return QP(Ae(e),eN)}s(Qg,"hookConfigPath");function e_(e){let t=Qg(e);try{let n=ZP(t);if(!n.isFile()||n.size>rN)return;let r=JSON.parse(qP(t,"utf8"));return bn(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}s(e_,"readStore");function oN(e){let t={};return typeof e.collect_prompt=="boolean"&&(t.collect_prompt=e.collect_prompt),typeof e.collect_telemetry=="boolean"&&(t.collect_telemetry=e.collect_telemetry),typeof e.log_until=="string"&&(e.log_until===nn||!Number.isNaN(Date.parse(e.log_until)))&&(t.log_until=e.log_until),t}s(oN,"knownKeys");function t_(e,t=qa()){if(!e)return;let n=Mt(e);if(!n)return;let r=e_(t),o=r?r[n]:void 0;if(!(!bn(o)||!bn(o.config)))return oN(o.config)}s(t_,"readHookConfig");function sN(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!bn(n)||!bn(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>nN))return n.hook_config}s(sN,"hookConfigFromBody");function iN(e,t,n,r){let o={...e},i=o[t];if(Object.keys(n).length===0)return i===void 0?void 0:(delete o[t],o);if(!(bn(i)&&JSON.stringify(i.config)===JSON.stringify(n)&&typeof i.fetched_at_ms=="number"&&i.fetched_at_ms<=r&&r-i.fetched_at_ms<tN))return o[t]={config:n,fetched_at_ms:r},o}s(iN,"nextStore");function n_(e,t,n=qa(),r=Date.now()){let o=sN(e),i=t?Mt(t):void 0;if(o===void 0||!i)return"skipped";try{let a=e_(n);if(a===void 0)return oe.error("failed where=hook_config_read err=unreadable message=hook config store is not a readable JSON object"),"skipped";let c=iN(a??{},i,o,r);return c?(le(Qg(n),`${JSON.stringify(c,null,2)}
52
+ `),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(a){let c=a instanceof Error?a.message:String(a);return x(`WARN: hook config write failed open: ${c}`),M("hook_config_write",a),"failed"}}s(n_,"applyCollectorHookConfigResponse");var Vt=class extends Error{static{s(this,"ProxyError")}code;status;constructor(t,n,r){super(n),this.name="ProxyError",this.code=t,this.status=r}};function r_(e,t){for(let n of[t,t.toUpperCase()]){let r=e[n]?.trim();if(r)return{name:n,value:r}}}s(r_,"envValue");function Jo(e){let t=e.toLowerCase().replace(/\.$/,"");return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}s(Jo,"bareHost");function aN(e){let t=Jo(e);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}s(aN,"isLoopbackHost");function cN(e,t){let n=Jo(e.hostname),r=e.port||(e.protocol==="http:"?"80":"443"),o=n.includes(":")||/^[\d.]+$/.test(n);return t.split(/[\s,]+/).some(i=>{let a=i.toLowerCase();if(a==="*")return!0;let c=/^\[([^\]]+)\](?::(\d+))?$/.exec(a)??/^([^:]+):(\d+)$/.exec(a);if(c){if(c[2]!==void 0&&c[2]!==r)return!1;a=c[1]??""}return a=a.replace(/^\*?\.?/,"").replace(/\.$/,""),a!==""&&(n===a||!o&&n.endsWith(`.${a}`))})}s(cN,"noProxyMatches");function uN(e){try{let t=new URL(e.includes("://")?e:`http://${e}`);return(t.protocol==="http:"||t.protocol==="https:")&&t.hostname?t:void 0}catch{return}}s(uN,"parseProxyUrl");function s_(e,t=process.env,n){if(e.protocol!=="https:"&&e.protocol!=="http:"||aN(e.hostname))return;let r=r_(t,`${e.protocol.slice(0,-1)}_proxy`);if(!r)return;let o=r_(t,"no_proxy");if(o&&cN(e,o.value))return;let i=uN(r.value);return n?.(i?`${e.host} via proxy ${i.protocol}//${i.host}`:`ignoring ${r.name}: not an http(s) URL`),i}s(s_,"proxyForUrl");function o_(e){try{return decodeURIComponent(e)}catch{return e}}s(o_,"decodeUserinfo");function i_(e){if(!e.username&&!e.password)return;let t=`${o_(e.username)}:${o_(e.password)}`;return`Basic ${Buffer.from(t,"utf8").toString("base64")}`}s(i_,"proxyAuthorization");var lN=16*1024;async function fN(e,t,n){let[r,o]=await Promise.all([import("node:net"),import("node:tls")]),i=Jo(t.hostname),a=Number(t.port)||(t.protocol==="https:"?443:80),c=s(u=>r.isIP(u)?void 0:u,"servername");return new Promise((u,f)=>{let{signal:l,timeout:p}=n;if(l?.aborted){f(l.reason);return}let d=t.protocol==="https:"?o.connect({host:i,port:a,servername:c(i),ca:n.ca}):r.connect({host:i,port:a}),m=!1,g=Buffer.alloc(0),E=s(()=>m?!1:(m=!0,l?.removeEventListener("abort",P),d.setTimeout(0),d.removeListener("data",N),!0),"settle"),S=s(T=>{E()&&(d.destroy(),f(T))},"fail"),C=s(T=>{E()&&u(T)},"succeed"),P=s(()=>{S(l?.reason)},"onAbort");function N(T){g=Buffer.concat([g,T]);let b=g.indexOf(`\r
53
53
  \r
54
- `);if(O<0){g.length>LT&&y(new Ft("EPROXY_CONNECT","proxy CONNECT reply too large"));return}let U=Number(/^HTTP\/1\.[01] (\d{3})/.exec(g.toString("latin1",0,O))?.[1]??0);if(U<200||U>299){y(new Ft(U===407?"EPROXY_AUTH":"EPROXY_CONNECT",`proxy answered CONNECT with HTTP ${U||"garbage"}`,U||void 0));return}d.removeListener("data",N),d.pause(),O+4<g.length&&d.unshift(g.subarray(O+4));let M=vo(e.hostname);b(o.connect({socket:d,host:M,servername:a(M),ca:n.ca}))}s(N,"onData"),d.on("error",x=>{let O=x!==null&&typeof x=="object"&&"code"in x&&typeof x.code=="string"?x.code:"error";y(new Ft("EPROXY_UNREACHABLE",`proxy connection failed (${O})`))}),d.on("close",()=>{y(new Ft("EPROXY_UNREACHABLE","proxy closed the connection"))}),p!==void 0&&d.setTimeout(p,()=>{y(new Ft("EPROXY_TIMEOUT","proxy did not answer in time"))}),l?.addEventListener("abort",w,{once:!0}),d.once(t.protocol==="https:"?"secureConnect":"connect",()=>{if(e.protocol!=="https:"){b(d);return}let x=`${e.hostname}:${e.port||"443"}`,O=Ag(t);d.on("data",N),d.write(`CONNECT ${x} HTTP/1.1\r
55
- Host: ${x}\r
56
- ${O?`Proxy-Authorization: ${O}\r
54
+ `);if(b<0){g.length>lN&&S(new Vt("EPROXY_CONNECT","proxy CONNECT reply too large"));return}let U=Number(/^HTTP\/1\.[01] (\d{3})/.exec(g.toString("latin1",0,b))?.[1]??0);if(U<200||U>299){S(new Vt(U===407?"EPROXY_AUTH":"EPROXY_CONNECT",`proxy answered CONNECT with HTTP ${U||"garbage"}`,U||void 0));return}d.removeListener("data",N),d.pause(),b+4<g.length&&d.unshift(g.subarray(b+4));let L=Jo(e.hostname);C(o.connect({socket:d,host:L,servername:c(L),ca:n.ca}))}s(N,"onData"),d.on("error",T=>{let b=T!==null&&typeof T=="object"&&"code"in T&&typeof T.code=="string"?T.code:"error";S(new Vt("EPROXY_UNREACHABLE",`proxy connection failed (${b})`))}),d.on("close",()=>{S(new Vt("EPROXY_UNREACHABLE","proxy closed the connection"))}),p!==void 0&&d.setTimeout(p,()=>{S(new Vt("EPROXY_TIMEOUT","proxy did not answer in time"))}),l?.addEventListener("abort",P,{once:!0}),d.once(t.protocol==="https:"?"secureConnect":"connect",()=>{if(e.protocol!=="https:"){C(d);return}let T=`${e.hostname}:${e.port||"443"}`,b=i_(t);d.on("data",N),d.write(`CONNECT ${T} HTTP/1.1\r
55
+ Host: ${T}\r
56
+ ${b?`Proxy-Authorization: ${b}\r
57
57
  `:""}\r
58
- `)})})}s(vT,"openProxySocket");async function UT(e,t,n,r){let o=await import("node:http"),i=await vT(e,t,n),c=e.protocol==="https:",a=Ag(t),u={...n.headers,host:e.host};!c&&a&&(u["proxy-authorization"]=a);let f=o.request({method:n.method??"GET",path:c?`${e.pathname}${e.search}`:e.href,headers:u,createConnection:s(()=>i,"createConnection")},r);return n.timeout!==void 0&&f.setTimeout(n.timeout),f}s(UT,"requestViaProxy");var HT=new Set([101,103,204,205,304]);function DT(e){if(e!=null){if(typeof e=="string")return Buffer.from(e,"utf8");if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);if(e instanceof ArrayBuffer)return Buffer.from(e);throw new TypeError("proxied fetch supports string and byte bodies only")}}s(DT,"requestBody");function FT(e){let t=(e??"").split(",").map(r=>r.trim().toLowerCase()).filter(r=>r!==""&&r!=="identity"),n=t.every(r=>["gzip","x-gzip","deflate","br"].includes(r));return t.length>0&&n?t.reverse():void 0}s(FT,"codingsToUndo");function $T(e,t,n){let r={flush:t.constants.Z_SYNC_FLUSH,finishFlush:t.constants.Z_SYNC_FLUSH};if(e==="br")return t.createBrotliDecompress();if(e!=="deflate")return t.createGunzip(r);let o,i=new n({transform(c,a,u){if(!o){let f=((c[0]??0)&15)===8?t.createInflate(r):t.createInflateRaw(r);f.on("data",l=>i.push(l)),f.on("error",l=>i.destroy(l)),o=f}o.write(c,()=>u())},flush(c){if(!o){c();return}o.once("end",()=>c()),o.end()},destroy(c,a){o?.destroy(),a(c)}});return i}s($T,"decoderFor");async function jT(e){let t=new Headers;for(let a=0;a+1<e.rawHeaders.length;a+=2)t.append(e.rawHeaders[a]??"",e.rawHeaders[a+1]??"");let n=e.statusCode??0,r={status:n,statusText:e.statusMessage??"",headers:t};if(HT.has(n))return e.resume(),new Response(null,r);let o=await import("node:stream"),i=e,c=FT(t.get("content-encoding"));if(c){let a=await import("node:zlib"),u=c.map(f=>$T(f,a,o.Transform));o.pipeline([e,...u],()=>{}),i=u[u.length-1]??e,t.delete("content-encoding"),t.delete("content-length")}return new Response(o.Readable.toWeb(i),r)}s(jT,"toResponse");function BT(e,t,n,r){let o=n.signal??void 0;return new Promise((i,c)=>{if(o?.aborted){c(o.reason);return}let a,u={"accept-encoding":e.protocol==="https:"?"br, gzip, deflate":"gzip, deflate"};try{a=DT(n.body),new Headers(n.headers).forEach((y,b)=>{u[b]=y})}catch(y){c(y);return}a&&(u["content-length"]=a.byteLength);let f=!1,l,p,d=s(()=>{o?.removeEventListener("abort",h)},"detach"),m=s(y=>{f||(f=!0,y())},"settle"),g=s(y=>{m(()=>{d(),c(o?.aborted?o.reason:new TypeError("fetch failed",{cause:y}))})},"failed"),h=s(()=>{l?.destroy(),p?.destroy(o?.reason instanceof Error?o.reason:new Error("aborted")),m(()=>{d(),c(o?.reason)})},"onAbort");o?.addEventListener("abort",h,{once:!0}),UT(e,t,{method:n.method,headers:u,signal:o,ca:r},y=>{p=y,y.once("close",d),jT(y).then(b=>m(()=>i(b)),b=>{y.destroy(),g(b)})}).then(y=>{if(f){y.destroy();return}l=y,y.on("error",g),y.end(a)},g)})}s(BT,"fetchOnce");var KT=new Set([301,302,303,307,308]),GT=20,VT=["content-type","content-encoding","content-language","content-location","content-length"];function zT(e,t){try{return new URL(e,t)}catch{return}}s(zT,"resolveLocation");async function WT(e,t,n={},r={}){let o=n.redirect??"follow",i=new Headers(n.headers),c=n.method??"GET",a=n.body,u=e,f=t;for(let l=0;;l+=1){let p={method:c,headers:i,body:a,signal:n.signal,redirect:"manual"},d=f?await BT(u,f,p,r.ca):await fetch(u,p),m=d.headers.get("location");if(o==="manual"||!KT.has(d.status)||m===null)return d;await d.body?.cancel();let g=zT(m,u),h=o==="error"?"unexpected redirect":l>=GT?"redirect count exceeded":g?.protocol==="http:"||g?.protocol==="https:"?void 0:"redirect location is not http(s)";if(h!==void 0||g===void 0)throw new TypeError("fetch failed",{cause:new Error(h)});let y=c.toUpperCase();if(d.status===303&&y!=="GET"&&y!=="HEAD"||d.status<=302&&y==="POST"){c="GET",a=void 0;for(let b of VT)i.delete(b)}g.origin!==u.origin&&(i.delete("authorization"),i.delete("cookie")),u=g,f=Cg(u,r.env??process.env,r.debug)}}s(WT,"fetchViaProxy");function bg(e,t,n,r=process.env){if(process.versions.bun!==void 0||!(typeof e=="string"||e instanceof URL))return fetch(e,t);let o;try{o=new URL(e)}catch{return fetch(e,t)}let i=Cg(o,r,n);return i?WT(o,i,t,{env:r,debug:n}):fetch(e,t)}s(bg,"fetchWithEnvProxy");var Uo="__post",Sn="__work";async function YT(e,t,n={}){if(ln())return e;let r=await bc(n.gitRoot??process.cwd(),ne,process.env,{runnerPlatform:t,home:n.home,context:n.context,hookUserEmail:n.hookUserEmail,gitConfigCachePath:fn(n.home)}),o=fe(e.self_config)?e.self_config:{};return{...e,self_config:{...o,runner_platform:typeof o.runner_platform=="string"?o.runner_platform:t,operator:r}}}s(YT,"attachOperatorIdentity");function XT(e,t){let n=fe(e.payload)?Object.keys(e.payload):[],r=e.correlation&&typeof e.correlation=="object"?Object.keys(e.correlation):[];return JSON.stringify({event:e.event,schema_version:e.schema_version,agent_hook_version:e.agent_hook_version,host_arch:e.host_arch,node_version:e.node_version,build_ms:e.build_ms,body_bytes:t,correlation_keys:r,payload_keys:n})}s(XT,"debugEnvelopeSummary");function xg(e){switch(e){case"session_start":return Ka;case"session_end":return Ga;case"tool_invoked":case"skill_invoked":return is;default:return is}}s(xg,"timeoutForEvent");function qT(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
59
- ${n}`}s(qT,"frameDetachedPostStdin");function Ig(e,t=[],n=process.execPath,r=import.meta.url,o=Og){if(Ba(n))return{command:n,args:[e,...t]};let i=JT(r);return o(i)?{command:n,args:[i,e,...t]}:{command:n,args:[e,...t]}}s(Ig,"resolveSelfReexecCommand");function ZT(e=process.execPath,t=import.meta.url,n=Og){let r=process.argv.includes("--debug")?["--debug"]:[];return Ig(Uo,r,e,t,n)}s(ZT,"resolveSelfPostCommand");function QT(e){let t=e.indexOf(`
60
- `);if(t<0)return null;let n;try{n=JSON.parse(e.slice(0,t))}catch{return null}return{meta:n,body:e.slice(t+1)}}s(QT,"parseDetachedPostStdin");function ew(e){F("EV_AI_HOOK_DEBUG")&&T(`DEBUG: ${e}`)}s(ew,"debugProxy");var Tg=s((e,t)=>bg(e,t,ew),"collectorFetch");function wg(e){F("EV_AI_HOOK_DEBUG")&&T(`DEBUG: send fail ${Nn(e)}`)}s(wg,"debugFailedPost");async function Ng(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();Eg(n,t)}catch(n){L("collector_response",n)}}s(Ng,"applyCollectorHttpResponse");function Pg(e){let t=e instanceof Error?e.message:String(e);return{code:e!==null&&typeof e=="object"&&"code"in e&&typeof e.code=="string"?e.code:void 0,message:t}}s(Pg,"errorParts");var Mg=1e3;function Lg(e,t){let n=e instanceof Error&&e.name==="TimeoutError"?"timeout":"post_failed";te({outcome:n,postMs:t,err:dt(e)})}s(Lg,"noteFailedPost");async function vg(e,t=Tg){try{let n=await e(),r=QT(n);if(!r){re.error("send fail code=bad-frame message=detached post stdin was not framed"),te({outcome:"post_failed",err:"bad-frame"});return}let{meta:o,body:i}=r,c=Ic(i),a=Lo(c.contentEncoding),u=performance.now();try{let f=await t(o.url,{method:"POST",headers:a,body:c.body,signal:AbortSignal.timeout(Number(o.timeoutMs))}),l=performance.now()-u;if(!f.ok){let p=(await f.text()).slice(0,Mg).replace(/[\n\r]/g,"");re.error(`send fail http=${f.status} code=${f.status} body=${p}`),te({outcome:"post_failed",postMs:l,http:f.status});return}re.info(`send ok http=${f.status}`),te({outcome:"posted",postMs:l,http:f.status}),await Ng(f,o.url)}catch(f){let l=Pg(f);re.error(`send fail code=${l.code??"(none)"} ${Nn(f)}`),wg(f),Lg(f,performance.now()-u)}}catch(n){L("post",n),te({outcome:"error",err:dt(n)})}finally{Xt("post",Ye,"error")}}s(vg,"runDetachedPoster");async function tw(e,t,n,r=Tg){let o=xg(e),i=Ic(t),c=Lo(i.contentEncoding),a=Tc(i.body);T(`POST event=${e} url=${Wt(n)} size=${a} encoding=${i.contentEncoding??"identity"} platform=${process.platform}`);let u=Date.now(),f=performance.now();try{let l=await r(n,{method:"POST",headers:c,body:i.body,signal:AbortSignal.timeout(o)});if(!l.ok&&i.contentEncoding==="gzip"&&(l.status===400||l.status===415)){try{await l.text()}catch{}T(`POST gzip rejected http=${l.status} \u2014 retrying uncompressed`),l=await r(n,{method:"POST",headers:Lo(),body:t,signal:AbortSignal.timeout(o)})}let p=Date.now()-u,d=performance.now()-f;if(_c(d),l.ok)return T(`POST outcome=ok elapsed_ms=${p} http=${l.status}`),re.info(`send ok http=${l.status}`),te({outcome:"posted",postMs:d,http:l.status}),await Ng(l,n),!0;let m=(await l.text()).slice(0,Mg).replace(/[\n\r]/g,"");return T(`POST outcome=fail elapsed_ms=${p} http=${l.status} body=${m}`),re.error(`send fail http=${l.status} code=${l.status} body=${m}`),te({outcome:"post_failed",postMs:d,http:l.status}),!1}catch(l){let p=Date.now()-u,d=performance.now()-f;_c(d);let m=Pg(l);return T(`POST outcome=fail elapsed_ms=${p} http=000 body=${m.message}`),re.error(`send fail http=0 code=${m.code??"(none)"} ${Nn(l)}`),wg(l),Lg(l,d),!1}}s(tw,"postCollector");async function Ug(e,t,n,r,o){let i=o.replaceAll(" ","_");try{let c=r(e,t,{detached:!0,stdio:["pipe","ignore","ignore"],windowsHide:!0});c.on("error",u=>{L(i,u)}),c.stdin.on("error",u=>{L(`${i}_stdin`,u)});let a=!1;return await new Promise(u=>{let f=setTimeout(()=>{if(!a){T(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`),re.error(`failed where=${i} err=timeout message=stdin handoff timed out`);try{c.stdin.destroy()}catch{}}u()},Va),l=s(()=>{a=!0,clearTimeout(f),u()},"done");c.stdin.end(n,()=>l()),c.stdin.once("error",()=>l())}),c.unref(),c}catch(c){let a=c instanceof Error?c.message:String(c);return T(`WARN: ${o} spawn failed open: ${a}`),L(i,c),null}}s(Ug,"spawnDetachedStdinChild");async function nw(e,t,n,r=kg,o=ZT){let i=xg(e),c=qT(n,i,t),{command:a,args:u}=o();return Ug(a,u,c,r,"detached post")}s(nw,"postCollectorDetached");async function Hg(e,t,n=kg,r=Ig){let{command:o,args:i}=r(Sn,t);return Ug(o,i,e,n,"detached work")}s(Hg,"runHookDetached");async function En(e,t,n,r,o,i,c,a){if(!o)return T("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),re.error("send fail code=missing message=collector URL missing"),te({outcome:"no_collector",err:"missing"}),!1;if(!Or(o))return T(`WARN: collector URL blocked (https required): ${Wt(o)}`),re.error("send fail code=blocked message=collector URL blocked"),te({outcome:"no_collector",err:"blocked"}),!1;let u=performance.now(),f=await YT(t,n.runnerPlatform,c),l=performance.now(),p=r(e,f,{...n,collectorUrl:o});i!==void 0&&(p.build_ms=Math.max(0,Date.now()-i));let d=Im({w4:u,w4e:l,w5:performance.now()},process.env,void 0,n.telemetry?.enabled===!0);d&&(p.perf=d);let m=JSON.stringify(p),g=a?.attach(Buffer.byteLength(m,"utf8"));g&&(p.run_log=g,m=JSON.stringify(p));let h=`${m}
61
- `,y=F("EV_AI_HOOK_DEBUG");y==="full"?T(`DEBUG envelope=${m}`):y==="1"&&T(`DEBUG summary=${XT(p,Tc(h))}`);let b=process.argv.includes(Sn),w=F("EV_AI_HOOK_SYNC")==="1";if(!(Co(n.runnerEvent,n.runnerPlatform)||b||w)){let x=await nw(e,h,o);return te(x?.pid!==void 0?{outcome:"handed_off"}:{outcome:"post_failed",err:"spawn"}),!1}return tw(e,h,o)}s(En,"emitAndPost");import{closeSync as rw,fstatSync as ow,linkSync as sw,openSync as iw,readdirSync as cw,readSync as aw,renameSync as uw,unlinkSync as Gg}from"node:fs";import{homedir as lw}from"node:os";import{basename as fw,dirname as dw}from"node:path";var Dg=ps,Fg=2*1024*1024,pw=Buffer.byteLength(',"run_log":',"utf8");function $g(e){let t=`${e}.send-${process.pid}`;try{return uw(e,t),{path:e,taken:t}}catch(n){return n.code==="ENOENT"?"missing":"busy"}}s($g,"take");function jg(e){return typeof e=="object"}s(jg,"isTaken");function mw(e){let t=`${fw(e)}.`;try{return cw(dw(e)).some(n=>n.startsWith(t)&&/\.send-\d+$/.test(n))}catch{return!1}}s(mw,"anyTakenLog");function gw(e){try{sw(e.taken,e.path),Gg(e.taken)}catch{}}s(gw,"putBack");function _w(e){try{Gg(e)}catch{}}s(_w,"unlinkQuiet");function Bg(e,t){let n;try{n=iw(e,"r");let r=ow(n);if(!r.isFile())return;let o=Math.min(r.size,Math.max(0,t)),i=Buffer.alloc(o),c=0;for(;c<o;){let a=aw(n,i,c,o-c,r.size-o+c);if(a===0)break;c+=a}return{tail:i.subarray(0,c),size:r.size}}catch{return}finally{if(n!==void 0)try{rw(n)}catch{}}}s(Bg,"readTail");function hw(e){let t=e.indexOf(10);return t===-1?e:e.subarray(t+1)}s(hw,"fromFirstWholeLine");function Kg(e,t,n){hs(r=>{r[t]===n&&delete r[t]},e)}s(Kg,"forgetWindow");function Vg(e,t=lw(),n=process.env,r=Date.now()){try{let o=e?Ot(e):void 0;if(!o||gu())return;let i=_s(t)[o];if(i===void 0||i===Yt)return;let c=Date.parse(i);if(Number.isNaN(c)||c>r)return;let a=fu(t,n,r);if(a.on||a.source!=="remote")return;let u=Nr(t),f=$g(u),l=$g(`${u}.1`),p=jg(f)?f:void 0,d=jg(l)?l:void 0,m=[d,p].filter(P=>P!==void 0),g=s(()=>{for(let P of m)gw(P)},"putAllBack"),h=p?Bg(p.taken,Dg):void 0,y=d?Bg(d.taken,Dg-(h?.tail.length??0)):void 0,b=(h?.size??0)+(y?.size??0);if(b===0){g(),f!=="busy"&&l!=="busy"&&!mw(u)&&Kg(t,o,i);return}let w=Buffer.concat([y?.tail??Buffer.alloc(0),h?.tail??Buffer.alloc(0)]),N=w.length<b,x=N?hw(w):w,O={log_until:i,text:x.toString("utf8"),bytes:x.length,bytes_total:b,truncated:N},U=pw+Buffer.byteLength(JSON.stringify(O),"utf8"),M=!1,k=!1;return{attach(P){if(P+U>Fg){T(`run log deferred: body=${P} run_log=${U} over ${Fg}`);return}return M=!0,O},settle(P){if(!k){if(k=!0,!(M&&P)){g();return}for(let v of m)_w(v.taken);Kg(t,o,i)}}}}catch(o){T(`WARN: run log upload failed open: ${o instanceof Error?o.message:String(o)}`);return}}s(Vg,"prepareRunLogUpload");import{createReadStream as Sw}from"node:fs";import{stat as Ew}from"node:fs/promises";import{basename as yw,resolve as Rw}from"node:path";import{createInterface as Cw}from"node:readline";var Aw=1024*1024;function bw(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&yw(t).endsWith(".jsonl")}s(bw,"isSafeClaudeTranscriptPath");async function zg(e){if(!e||!bw(e))return null;try{let t=Rw(e),n=await Ew(t);if(!n.isFile())return null;let r=Math.max(0,n.size-Aw),o=[],i=Cw({input:Sw(t,{encoding:"utf8",start:r}),crlfDelay:1/0});for await(let c of i)c.length!==0&&o.push(c);r>0&&o.length>0&&o.shift();for(let c=o.length-1;c>=0;c--){let a=o[c];if(a)try{let u=JSON.parse(a);if(u.type!=="assistant")continue;let f=u.message;if(!f||typeof f!="object")continue;let l=f.model;if(typeof l=="string"&&l.length>0)return l}catch{continue}}return null}catch{return null}}s(zg,"lastAssistantModelFromTranscript");var Ow="EV_AI_HOOK_TELEMETRY";function Wg(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}s(Wg,"telemetryFromHomeConfig");function Jg(e,t,n=process.env){let r=n[Ow]?.trim().toLowerCase();return r&&Ct.has(r)?{enabled:!0,source:"env"}:r&&pr.has(r)?{enabled:!1,source:"env"}:e!==void 0?{enabled:e,source:"local_config"}:t?.collect_telemetry!==void 0?{enabled:t.collect_telemetry,source:"org_config"}:{enabled:!0,source:"default"}}s(Jg,"resolveTelemetry");function Ho(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:vr(e.manifest.manifest,e.manifest.hookConfig),telemetry:qg(e)}}s(Ho,"envelopeFieldsFromContext");function qg(e){return Jg(e.manifest.localTelemetry,e.manifest.hookConfig)}s(qg,"telemetryFor");function Pc(e){return gr({sessionId:e.sessionId,hostname:Qo()})}s(Pc,"runnerContextOf");function Mc(e){let t=$(e.hookInput,"user_email").trim();return t.length>0?t:void 0}s(Mc,"hookUserEmailOf");function ir(e,t,n=Pc(e)){let r=Mc(e);return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{},context:n,...r?{hookUserEmail:r}:{}}}s(ir,"operatorContextFrom");function Lc(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:As(e.manifest.hookConfig)}}s(Lc,"hookInputSanitizeOptions");async function Zg(e){let t=Date.now();await Fw(e);let{gitRoot:n}=e.manifest;await Hc(e,n);let r=Lc(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:Hr(e.hookInput,e.manifest.manifest,r),envelopeFields:Ho(e),launchCwd:bs(e.hookInput,r),home:xw()}}s(Zg,"prepareDerivedInvoke");function Yg(e){try{return Te(kw(e))}catch{return null}}s(Yg,"tryRealpath");function Qg(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}s(Qg,"isAbsolutePath");function Xg(e,t){let n=e.replaceAll("\\","/");if(!Qg(n))return null;let r=Te(e),o=Te(t),i=Yg(e)??r,c=Yg(t)??o;return i.startsWith(`${c}/`)?i.slice(c.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}s(Xg,"relativeToAnchor");function e_(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),i=Xg(e,t)??(Qg(r)?null:r),c=Xg(e,n);return{repositorySourcePath:i,userSourcePath:c}}s(e_,"sourcePathsFromResolvedFile");function Nc(e,t,n,r,o){return t_(e,e_(n,t.gitRoot,t.home),r,o)}s(Nc,"exactFileComponentFromResolvedPath");function t_(e,{repositorySourcePath:t,userSourcePath:n},r,o){let i=t??n,c=i===null?null:o(i),a=c!==null&&i!==null?Iw({installableKind:r,sourcePath:i,nativeKey:c,inRepository:t!==null,platformAgentId:e.platformAgentId,installationId:e.manifest.installationId}):void 0;return{sourcePath:i,nativeKey:c,componentReference:a}}s(t_,"exactFileComponent");function Iw(e){try{let t=e.inRepository?r_(e.platformAgentId,e.sourcePath):(0,V.installationRootExternalKey)(e.installationId,(0,V.userConfigRootFromPath)(e.sourcePath));return t?(0,V.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}s(Iw,"tryExactFileComponentReference");function n_(e){let t=e.policyFindings;return t===void 0||t.length===0?{}:{policy_findings:t,...e.policyJudgeSpawnMs!==void 0?{policy_judge_spawn_ms:e.policyJudgeSpawnMs}:{}}}s(n_,"policyPayload");function vc(e,t,n){return En("tool_invoked",{...n,...n_(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,_n,e.manifest.collectorUrl,t.buildStartedAtMs,ir(e,t.home))}s(vc,"postDerivedToolInvoked");function Tw(e){return Yp(e.runnerEvent,e.runnerPlatform)?[]:Dp(e.hookInput)}s(Tw,"slashIdsFromHookInput");function ww(e,t){return vc(e,t,{})}s(ww,"postPromptSubmitted");var Uc=new Set([...Object.values(Dt),".github"]);function r_(e,t){let n=e.indexOf(":");if(n<=0)return null;let r=e.slice(0,n),o=t.replaceAll("\\","/").split("/").filter(Boolean),i=o.findIndex(c=>Uc.has(c));return i<0?null:`${r}:${o.slice(0,i+1).join("/")}`}s(r_,"repositoryConfigRootExternalKey");var o_=".codex/config.toml",Nw=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",o_]]),Pw=new Map([["mcp_json",".mcp.json"],["cursor_mcp",".cursor/mcp.json"]]);function Mw(e){if(e===null)return null;let t=e.indexOf(":");if(t<=0||t===e.length-1)return null;let n;try{n=(0,V.normalizeRepositoryRelativePath)(e.slice(t+1))}catch{return null}let r=n.split("/").at(-1);return r===void 0||!Uc.has(r)?null:{repoSlug:e.slice(0,t),scope:n}}s(Mw,"repositoryAgentScope");function Lw(e,t){let n=r_(`${e.repoSlug}:${e.scope}`,t);return n!==null?t.split("/").find(o=>Uc.has(o))===e.scope.split("/").at(-1)?n:null:e.scope.includes("/")?null:`${e.repoSlug}:${e.scope}`}s(Lw,"repositoryMcpRootExternalKey");function vw(e,t,n,r,o,i,c){if(e===null||t===null||!(c!==null||/^mcp__.+?__.+$/i.test(e)||/^MCP:[^:]+:.+$/i.test(e)||/^MCP:.+__.+$/i.test(e)||e.toLowerCase()===`mcp:${t.toLowerCase()}`))return;let u=i.find(h=>h.name.toLowerCase()===t.toLowerCase()),f=u?Nw.get(u.source):o==="codex"?o_:void 0,l=u?.sourcePath??f;if((u?.scope==="user"||f!==void 0)&&l)try{let h=(0,V.userConfigRootFromPath)(l);return(0,V.buildComponentReference)({installationRootExternalKey:(0,V.installationRootExternalKey)(r,h),installableKind:V.ComponentKind.INTERFACE,sourcePath:l,nativeKey:u?.name??t})}catch{return}let d=u?Pw.get(u.source):void 0,m=Mw(n);if(u===void 0||d===void 0||m===null)return;let g=Lw(m,d);if(g!==null)try{return(0,V.buildComponentReference)({installationRootExternalKey:g,installableKind:V.ComponentKind.INTERFACE,sourcePath:d,nativeKey:u.name})}catch{return}}s(vw,"exactMcpComponentReference");function Uw(...e){for(let t of e)if(t)return t;return null}s(Uw,"firstNonEmpty");function jt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return T(`WARN: ${n} failed open: ${r}`),L(n,e.reason),t}s(jt,"settledOr");function Hw(e){let t={present:!1,size:0},n={hash:"",count:0};return{config:{runner_platform:e,config_scope:"user",cli_version:null,claude_version:null,model:null,permission_keys:[],user_scope:{skills:n,subagents:n,commands:n,rules:n,memory:t,settings:t,mcp:t},local_settings:t},commit:s(()=>{},"commit")}}s(Hw,"emptySelfConfigResult");function Dw(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}s(Dw,"cloudBootstrapSelfConfig");var $t=new Set,sr=null;async function Fw(e){if(ln())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if($t.has(t))return;if(!kc(n)){$t.add(t);return}let r=String(e.runnerPlatform),o=Pc(e);if(ng(o,r)){if(sr){await sr;return}sr=(async()=>{if($t.has(t)||!kc(n)){$t.add(t);return}if(!kp(n)){$t.add(t);return}let i=!1;try{let c=Date.now(),{gitRoot:a}=e.manifest,{operatorResolved:u,fields:f}=await s_(e,o,ze("git",()=>yo(a)),ze("operator",()=>Oc({gitRoot:a,installationStorePath:n,forceResend:!1,runnerPlatform:r,context:o,hookUserEmail:Mc(e),gitConfigCachePath:fn()}))),l={...f,self_config:Dw(r,u.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};i=!!await En("session_start",l,Ho(e),_n,e.manifest.collectorUrl,c,ir(e,void 0,o)),i&&(u.commit(),$t.add(t))}finally{xp(n)}})().finally(()=>{sr=null}),await sr}}s(Fw,"maybeBootstrapCloudIdentity");async function Hc(e,t,n){try{e.platformAgentId=await Fp(e.manifest.manifest,e.platformAgentId,String(e.runnerPlatform),t,n,e.manifest.installationStorePath,e.manifest.repoKey)}catch(r){let o=r instanceof Error?r.message:String(r);T(`WARN: derivePlatformAgentId failed open: ${o}`),L("platform_agent_id",r)}}s(Hc,"resolvePlatformAgentId");async function s_(e,t,n,r){let[o,i,c,a,u]=await Promise.allSettled([n,ze("virt",()=>ca()),ze("cloud",()=>Nm(t)),ze("host_env",()=>ua(qg(e).enabled)),r]),f=jt(o,null,"gitSnapshot"),l=jt(i,"","detectVirt"),p=jt(c,null,"probeCloud"),d=jt(a,{},"hostEnv"),m=jt(u,{commit:s(()=>{},"commit")},"resolveOperatorForSend");return await Hc(e,e.manifest.gitRoot,f),{operatorResolved:m,fields:{identity:{host:Qo(),context:t,virt:l||null,cloud:p,git:f},host_env:d,env_vars:Dm()}}}s(s_,"collectIdentityPayload");async function $w(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=Pc(e),o=String(e.runnerPlatform),i=Lc(e),c=bs(e.hookInput,i),a=ze("git",()=>yo(n)),u=gg().catch(M=>(L("launcher_fields",M),{})),f=ln()?Promise.resolve({commit:s(()=>{},"commit")}):ze("operator",()=>Oc({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o,context:r,hookUserEmail:Mc(e),gitConfigCachePath:fn()})),l=s_(e,r,a,f),[p,d]=await Promise.allSettled([ze("mcp_declared",()=>Ec(e.manifest.manifest,n,o)),a.catch(()=>null).then(M=>ze("self_config",()=>ip(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,installationId:e.manifest.installationId,gitRoot:n,launchCwd:c,inGitRepo:e.manifest.inGitRepo,remote:M?.remote??null})))]),{operatorResolved:m,fields:g}=await l,h=jt(p,[],"mcpDeclared"),y=jt(d,Hw(o),"selfConfig"),b=y.config,w=$(e.hookInput,"model");w&&(b.model=w);let N={...g,mcp:{declared:h},self_config:b,run_meta:{trigger:e.hookSource||"startup"},hook_input:Hr(e.hookInput,e.manifest.manifest,{...i,launchCwd:c})},x=await u,O=Vg(e.manifest.collectorUrl),U=!1;try{U=await En("session_start",N,{...Ho(e),...x},_n,e.manifest.collectorUrl,t,ir(e,void 0,r),O)}finally{O?.settle(U)}U&&(y.commit(),m.commit(),$t.add(e.manifest.installationId))}s($w,"handleSessionStart");async function jw(e){let t=Date.now(),[,n]=await Promise.all([Hc(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?zg($(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=Uw($(e.hookInput,"status"),$(e.hookInput,"stop_reason"),$(e.hookInput,"reason"),er($(e.hookInput,"error")),r==="stop"?Je(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),i=Hr(e.hookInput,e.manifest.manifest,Lc(e));n&&(i.model=n),r!=="stopfailure"&&vr(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&i.last_assistant_message===void 0&&(i.last_assistant_message=""),await En("session_end",{status:o,...n?{model:n}:{},hook_input:i},Ho(e),_n,e.manifest.collectorUrl,t,ir(e))}s(jw,"handleSessionEnd");async function Bw(e){let t=Tw(e),n=Kp(e.hookInput),r=Jp(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&vr(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let i=await Zg(e);await Promise.all([o?ww(e,i):void 0,t.length===0?void 0:Kw(e,i,t),n.length===0?void 0:Gw(e,i,n)])}s(Bw,"handleSkillInvoked");function i_(e,t,n,r){let o=r??Hp({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),i=Nc(e,t,o,V.ComponentKind.SKILL,V.nativeKeyForSkillPath);if(i.sourcePath!==null&&Qi(i.sourcePath)?.toLowerCase()===n.toLowerCase())return i.componentReference===void 0?{}:{componentReference:i.componentReference};let c=r??Gp({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),a=Nc(e,t,c,V.ComponentKind.COMMAND,V.nativeKeyForCommandPath);return a.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:a.nativeKey,...a.componentReference===void 0?{}:{componentReference:a.componentReference}}}s(i_,"slashComponentIdentity");function Kw(e,t,n){let r=Eo(e.hookInput.tool_input);return Promise.all(n.map(o=>{let i=i_(e,t,o,r);return vc(e,t,{tool_name:"Skill",skill_name:o,...i.commandName===void 0?{}:{command_name:i.commandName},...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(Kw,"postSkillInvokes");function Gw(e,t,n){return Promise.all(n.map(r=>{let o=$p({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),i=Nc(e,t,o,V.ComponentKind.RULE,V.nativeKeyForRulePath),c=i.nativeKey??Bp(r);return vc(e,t,{tool_name:"Rule",rule_name:c,...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(Gw,"postRuleInvokes");var Vw=[{kind:V.ComponentKind.SKILL,nativeKeyFn:V.nativeKeyForSkillPath},{kind:V.ComponentKind.RULE,nativeKeyFn:V.nativeKeyForRulePath},{kind:V.ComponentKind.COMMAND,nativeKeyFn:V.nativeKeyForCommandPath}];function zw(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=tc(e.hookInput);if(r===null)return n.skillName===null?{}:i_(e,t,n.skillName,null);let o=e_(r,t.gitRoot,t.home);for(let i of Vw){let c=t_(e,o,i.kind,i.nativeKeyFn);if(c.nativeKey!==null)return{...c.componentReference===void 0?{}:{componentReference:c.componentReference},...i.kind===V.ComponentKind.RULE?{ruleName:c.nativeKey}:{},...i.kind===V.ComponentKind.COMMAND?{commandName:c.nativeKey}:{}}}return{}}s(zw,"toolComponentIdentity");var Ww=/mcp/i;function Jw(e,t,n,r){let o=Ww.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let i=o?Ud(t,n):ao(r.declaredConfig,n);return i===null?{}:Object.fromEntries(Object.entries(i).filter(c=>typeof c[1]=="string").map(([c,a])=>[`mcp_${c}`,a]))}s(Jw,"mcpPackageFields");async function Yw(e){let t=await Zg(e),n=Zp(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,i=ec(e.hookInput),c=td(i,t.home),a=em(e.hookInput),u=Xp(e.runnerEvent),f=u===!1?tm(e.hookInput,e.runnerEvent):null,l=er($(e.hookInput,"mcp_server_name")),p=l!==null||r!==null&&bo(r)?await Ec(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(U=>(L("mcpDeclared",U),[])):[],{mcpServer:d,mcpTool:m}=rm(r,p.map(U=>U.name),l??""),g=vw(r,d,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),p,l),h=g===void 0?zw(e,t,n):{},y=d===null?null:Hm(d,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),b=Jw(e,i,t.home,{hasMcpIdentity:!!d||!!m,declaredConfig:y}),w=g??h.componentReference,N=h.ruleName??n.ruleName,x=h.commandName??n.commandName,O=Qp(e.hookInput);await En("tool_invoked",{tool_name:r,skill_name:o,...N?{rule_name:N}:{},...x?{command_name:x}:{},success:u,duration_ms:a,...c?{executable:c}:{},...f?{failure_reason:f}:{},...d?{mcp_server:d}:{},...m?{mcp_tool:m}:{},...b,...w?{component_reference:w}:{},...O?{subagent_type:O}:{},...n_(e),hook_input:t.hookInput},t.envelopeFields,_n,e.manifest.collectorUrl,t.buildStartedAtMs,ir(e,t.home))}s(Yw,"handleToolInvoked");async function c_(e){switch(Xe("w3"),e.internalEvent){case"session_start":await $w(e);return;case"session_end":await jw(e);return;case"skill_invoked":await Bw(e);return;case"tool_invoked":await Yw(e);return;default:return}}s(c_,"dispatchInternalEvent");import{existsSync as Fc,readFileSync as Xw}from"node:fs";import{dirname as qw,isAbsolute as Zw,join as Qw,relative as eN}from"node:path";function a_(e){for(let t of Ua){let n=Qw(e,t);if(Fc(n))return n}}s(a_,"firstExistingManifest");async function tN(e=process.cwd(),t){let n=t??await Xo(e);return a_(n)??a_(e)}s(tN,"findRepoManifestPath");async function nN(e,t){let n=t??await Xo(qw(e)),r=eN(n,e);if(r.startsWith("..")||Zw(r))return!1;let o=await we("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(T(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}s(nN,"isManifestGitTracked");function Dc(e){let t=Xw(e,"utf8");return Oe(Bt(t),{})}s(Dc,"loadRepoManifestFromFile");function rN(){return{schema_version:kr,mcp_servers:[]}}s(rN,"defaultSharedManifest");function oN(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(T(`WARN: ignoring capture_hook_input=full in git-tracked manifest ${t}; use EV_AI_HOOK_CAPTURE_FULL_INPUT=1 or an untracked operator manifest`),delete e.capture_hook_input),e.debug===!0&&r.has("debug")&&(T(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}s(oN,"stripTrackedUnsafeFields");function sN(e){let t=ja({argv:e.argv,env:process.env,homeConfig:e.homeConfig,manifest:e.manifest,manifestSource:e.manifestSource});for(let r of t.warnings){T(`WARN: ignoring ${r.label}: ${r.problem}`);let o=r.label.replace(/\s+/g,"_"),i=r.problem.replace(/\/[^/\s]+\/hook\b/g,"/***/hook");re.error(`collector ignored label=${o} message=${i}`)}let n=t.url??"";return re.info(`collector source=${t.source} url=${n?Wt(n):"(none)"}`),n}s(sN,"collectorUrlFromLoaded");function iN(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}s(iN,"recordOrUndefined");async function u_(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await Yo(e),o=F("EV_AI_HOOK_MANIFEST"),i=o&&Fc(o)?o:void 0,c=i?void 0:Fc(bt())?bt():void 0,a=i?void 0:await tN(e,n),u=c?Dc(c):void 0,f=a?Dc(a):void 0,l=Wg(i?Q(bt(),{}):u),p,d,m,g=new Set;if(i){p=Dc(i),d=i,m=i;for(let O of Object.keys(p))g.add(O)}else if(u&&f){p=Da(f,u),d=c,m=a;for(let O of Object.keys(f))O in u||g.add(O)}else if(u)p=u,d=c;else if(f){p=f,d=a,m=a;for(let O of Object.keys(f))g.add(O)}else p=rN();delete p.installation_id;let h=m?await nN(m,n):!1;oN(p,m,h,g);let{installationId:y,storePath:b,repoKey:w}=await Np(n,{sessionId:t.sessionId}),N=u??iN(Q(bt(),null)),x=sN({argv:t.argv??process.argv,homeConfig:N,manifest:i?p:f,manifestSource:i?"manifest_override":"manifest"});return{manifestPath:d??b,manifest:p,installationId:y,installationStorePath:b,repoKey:w,collectorUrl:x,hookConfig:Sg(x),...l!==void 0?{localTelemetry:l}:{},platformAgentId:p.platform_agent_id??"",gitRoot:n,inGitRepo:r}}s(u_,"loadManifest");import{mkdirSync as cN,readdirSync as aN,readFileSync as uN,statSync as l_,unlinkSync as lN,writeFileSync as fN}from"node:fs";import{homedir as Do}from"node:os";import{join as $c}from"node:path";var dN="turns",f_=1440*60*1e3,pN=100,mN=new Set(["stop","stopfailure","sessionend"]);function jc(e=Do()){return $c(Re(e),dN)}s(jc,"sessionTurnDir");function d_(e,t){return $c(e,An(t))}s(d_,"sessionTurnPath");function gN(e,t=Date.now()){let n;try{n=aN(e)}catch{return}let r=0;for(let o of n){if(r>=pN)return;r+=1;try{let i=$c(e,o);t-l_(i).mtimeMs>f_&&lN(i)}catch{}}}s(gN,"pruneStaleSessionTurns");function _N(e,t,n=Do()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let i=jc(n);cN(i,{recursive:!0}),fN(d_(i,r),o,"utf8")}catch{}}s(_N,"rememberSessionTurn");function hN(e,t=Do()){let n=e.trim();if(!n)return"";try{let r=d_(jc(t),n);return Date.now()-l_(r).mtimeMs>f_?"":uN(r,"utf8").trim()}catch{return""}}s(hN,"recallSessionTurn");function p_(e,t,n,r=Do()){let o=t.trim(),i=mN.has(n.trim().toLowerCase());return i&&gN(jc(r)),o?(_N(e,o,r),o):i?hN(e,r):""}s(p_,"resolveTurnId");function h_(e){let t=Oe(e,{});return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}s(h_,"parseHookInput");async function SN(e,t,n){let r=t??await mr(xr),o=h_(r),i=await u_(process.cwd(),{sessionId:mn(o)});if(Xe("w2"),!i){te({outcome:"no_manifest"});return}let c=qp(o,i.manifest.platform,n),a=Ao(e,c.runnerEvent);if(!a){T(`WARN: unknown hook event '${c.runnerEvent}'; skipping telemetry`),te({outcome:"unknown_event"});return}te({runner:c.runnerPlatform,event:a,session:c.sessionId});let u={hookInput:o,sessionId:c.sessionId,turnId:p_(c.sessionId,c.turnId,c.runnerEvent),runnerEvent:c.runnerEvent,runnerPlatform:c.runnerPlatform,hookSource:c.hookSource,internalEvent:a,manifest:i,platformAgentId:i.platformAgentId};await c_(u)}s(SN,"runHook");function EN(e,t=!1){if(F("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,i=pn(r,o,void 0,n.runner);return Co(o,i)?!0:t}s(EN,"shouldRunHookInProcess");function m_(e,t){let n=Ar(e),r=h_(t),o=n.event??sc(r);return sa()||Wp(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}s(m_,"preflight");function S_(e){return gm(Ao(e.parsed.event,e.runnerEvent))}s(S_,"isCapExempt");async function g_(e,t,n){let{parsed:r}=e,o=n??fc(r.slot);if(!o&&!S_(e)){let i=lc(r.cap),c=Rm(i);if(!c){dc(i),te({outcome:"cap_dropped"});return}o=c}try{await SN(r.event,t,r.runner)}finally{o&&xo(o)}}s(g_,"runHookInSlot");var Fo,yn=!1,yN=500;function RN(){let e=s(()=>{process.exit(0)},"exitNow");setTimeout(e,yN);try{process.stdout.write('{"continue":true}',e)}catch{e()}}s(RN,"ackThenExit");function $o(e,t){let n=e[0]===Sn?"w":e[0]===Uo?"post":"h";Fo=void 0,yn=!1;let r=s(c=>a=>{try{L(c,a),_u()||(te({outcome:"error",err:dt(a)}),Xt(Fo??n,Ye,"error"))}catch{}if(t){if(n==="h"&&!yn){yn=!0,RN();return}process.exit(0)}},"onCrash"),o=r("uncaught"),i=r("unhandled_rejection");return process.on("uncaughtException",o),process.on("unhandledRejection",i),()=>{process.off("uncaughtException",o),process.off("unhandledRejection",i)}}s($o,"installCrashLogging");async function jo(e=process.argv.slice(2),t=!1){if(t||mu(e),tu(),Fo=void 0,yn=!1,Xe(e[0]===Sn?"w0":"h0"),Cm(),F("EV_AI_HOOK_JUDGE")==="1"){try{await mr(xr)}catch{}return Wo(),yn=!0,0}if(e[0]===Uo){try{await vg(Jo)}catch{}return 0}if(e[0]===Sn){let i=!1;try{let c=await Jo();Xe("w1");let a=m_(e.slice(1),c);if(!a)return te({outcome:"suppressed"}),0;__(a),i=Ao(a.parsed.event,a.runnerEvent)==="session_start",await g_(a,c)}catch(c){let a=c instanceof Error?c.message:String(c);T(`WARN: detached work failed open: ${a}`),L("work",c),te({outcome:"error",err:dt(c)})}finally{Xt("w",Ye,"no_post"),i&&Su()}return 0}let n,r="error",o=!1;try{hu();let i=await mr(xr);Xe("h1");let c=m_(e,i);if(!c)return r="suppressed",0;__(c);let{parsed:a,hookInput:u,runnerEvent:f}=c;if(n=fc(a.slot),!am(u,f,a.runner))return r="duplicate",0;if(Xe("h2"),EN(c))o=!0,Fo="inproc",r="no_post",await g_(c,i,n);else{let l=n||S_(c)?void 0:lc(a.cap);if(l===void 0||Em(l)){Xe("h3"),km();let p=await Hg(i,e);n&&p?.pid!==void 0&&hm(n,p.pid),p?.pid!==void 0?r="handed_off":(r="error",te({err:"spawn"}))}else dc(l),r="cap_dropped"}}catch(i){let c=i instanceof Error?i.message:String(i);T(`WARN: hook failed open: ${c}`),L("hook",i),r="error",te({outcome:"error",err:dt(i)})}finally{n&&xo(n),Wo(),yn=!0,te({ackMs:performance.now()}),Xt(o?"inproc":"h",Ye,r)}return 0}s(jo,"main");function __({parsed:e,hookInput:t,runnerEvent:n}){te({runner:pn(t,n,void 0,e.runner),event:n,session:mn(t),tool:typeof t.tool_name=="string"?t.tool_name:void 0})}s(__,"noteInvocation");var CN=Symbol.for(_a);function E_(){return globalThis[CN]===!0}s(E_,"isLoadedByLauncher");async function AN(e){zo(e);let t=$o(e.argv,!1);try{return await jo(e.argv)}finally{t(),zo(void 0)}}s(AN,"runInLauncher");E_()||($o(process.argv.slice(2),!0),jo().then(e=>{process.exit(e)}).catch(e=>{L("entry",e);let t=e instanceof Error?e.message:String(e);process.stderr.write(`[ev-ai-agent-hook] ${t}
62
- `),process.exit(1)}));export{AN as runInLauncher};
58
+ `)})})}s(fN,"openProxySocket");async function dN(e,t,n,r){let o=await import("node:http"),i=await fN(e,t,n),a=e.protocol==="https:",c=i_(t),u={...n.headers,host:e.host};!a&&c&&(u["proxy-authorization"]=c);let f=o.request({method:n.method??"GET",path:a?`${e.pathname}${e.search}`:e.href,headers:u,createConnection:s(()=>i,"createConnection")},r);return n.timeout!==void 0&&f.setTimeout(n.timeout),f}s(dN,"requestViaProxy");var pN=new Set([101,103,204,205,304]);function mN(e){if(e!=null){if(typeof e=="string")return Buffer.from(e,"utf8");if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);if(e instanceof ArrayBuffer)return Buffer.from(e);throw new TypeError("proxied fetch supports string and byte bodies only")}}s(mN,"requestBody");function gN(e){let t=(e??"").split(",").map(r=>r.trim().toLowerCase()).filter(r=>r!==""&&r!=="identity"),n=t.every(r=>["gzip","x-gzip","deflate","br"].includes(r));return t.length>0&&n?t.reverse():void 0}s(gN,"codingsToUndo");function _N(e,t,n){let r={flush:t.constants.Z_SYNC_FLUSH,finishFlush:t.constants.Z_SYNC_FLUSH};if(e==="br")return t.createBrotliDecompress();if(e!=="deflate")return t.createGunzip(r);let o,i=new n({transform(a,c,u){if(!o){let f=((a[0]??0)&15)===8?t.createInflate(r):t.createInflateRaw(r);f.on("data",l=>i.push(l)),f.on("error",l=>i.destroy(l)),o=f}o.write(a,()=>u())},flush(a){if(!o){a();return}o.once("end",()=>a()),o.end()},destroy(a,c){o?.destroy(),c(a)}});return i}s(_N,"decoderFor");async function hN(e){let t=new Headers;for(let c=0;c+1<e.rawHeaders.length;c+=2)t.append(e.rawHeaders[c]??"",e.rawHeaders[c+1]??"");let n=e.statusCode??0,r={status:n,statusText:e.statusMessage??"",headers:t};if(pN.has(n))return e.resume(),new Response(null,r);let o=await import("node:stream"),i=e,a=gN(t.get("content-encoding"));if(a){let c=await import("node:zlib"),u=a.map(f=>_N(f,c,o.Transform));o.pipeline([e,...u],()=>{}),i=u[u.length-1]??e,t.delete("content-encoding"),t.delete("content-length")}return new Response(o.Readable.toWeb(i),r)}s(hN,"toResponse");function EN(e,t,n,r){let o=n.signal??void 0;return new Promise((i,a)=>{if(o?.aborted){a(o.reason);return}let c,u={"accept-encoding":e.protocol==="https:"?"br, gzip, deflate":"gzip, deflate"};try{c=mN(n.body),new Headers(n.headers).forEach((S,C)=>{u[C]=S})}catch(S){a(S);return}c&&(u["content-length"]=c.byteLength);let f=!1,l,p,d=s(()=>{o?.removeEventListener("abort",E)},"detach"),m=s(S=>{f||(f=!0,S())},"settle"),g=s(S=>{m(()=>{d(),a(o?.aborted?o.reason:new TypeError("fetch failed",{cause:S}))})},"failed"),E=s(()=>{l?.destroy(),p?.destroy(o?.reason instanceof Error?o.reason:new Error("aborted")),m(()=>{d(),a(o?.reason)})},"onAbort");o?.addEventListener("abort",E,{once:!0}),dN(e,t,{method:n.method,headers:u,signal:o,ca:r},S=>{p=S,S.once("close",d),hN(S).then(C=>m(()=>i(C)),C=>{S.destroy(),g(C)})}).then(S=>{if(f){S.destroy();return}l=S,S.on("error",g),S.end(c)},g)})}s(EN,"fetchOnce");var SN=new Set([301,302,303,307,308]),yN=20,RN=["content-type","content-encoding","content-language","content-location","content-length"];function CN(e,t){try{return new URL(e,t)}catch{return}}s(CN,"resolveLocation");async function AN(e,t,n={},r={}){let o=n.redirect??"follow",i=new Headers(n.headers),a=n.method??"GET",c=n.body,u=e,f=t;for(let l=0;;l+=1){let p={method:a,headers:i,body:c,signal:n.signal,redirect:"manual"},d=f?await EN(u,f,p,r.ca):await fetch(u,p),m=d.headers.get("location");if(o==="manual"||!SN.has(d.status)||m===null)return d;await d.body?.cancel();let g=CN(m,u),E=o==="error"?"unexpected redirect":l>=yN?"redirect count exceeded":g?.protocol==="http:"||g?.protocol==="https:"?void 0:"redirect location is not http(s)";if(E!==void 0||g===void 0)throw new TypeError("fetch failed",{cause:new Error(E)});let S=a.toUpperCase();if(d.status===303&&S!=="GET"&&S!=="HEAD"||d.status<=302&&S==="POST"){a="GET",c=void 0;for(let C of RN)i.delete(C)}g.origin!==u.origin&&(i.delete("authorization"),i.delete("cookie")),u=g,f=s_(u,r.env??process.env,r.debug)}}s(AN,"fetchViaProxy");function a_(e,t,n,r=process.env){if(process.versions.bun!==void 0||!(typeof e=="string"||e instanceof URL))return fetch(e,t);let o;try{o=new URL(e)}catch{return fetch(e,t)}let i=s_(o,r,n);return i?AN(o,i,t,{env:r,debug:n}):fetch(e,t)}s(a_,"fetchWithEnvProxy");var Xo="__post",In="__work";async function bN(e,t,n={}){if(hn())return e;let r=await Va(n.gitRoot??process.cwd(),re,process.env,{runnerPlatform:t,home:n.home,context:n.context,hookUserEmail:n.hookUserEmail,gitConfigCachePath:En(n.home)}),o=nt(e.self_config)?e.self_config:{};return{...e,self_config:{...o,runner_platform:typeof o.runner_platform=="string"?o.runner_platform:t,operator:r}}}s(bN,"attachOperatorIdentity");function IN(e,t){let n=nt(e.payload)?Object.keys(e.payload):[],r=e.correlation&&typeof e.correlation=="object"?Object.keys(e.correlation):[];return JSON.stringify({event:e.event,schema_version:e.schema_version,agent_hook_version:e.agent_hook_version,host_arch:e.host_arch,node_version:e.node_version,build_ms:e.build_ms,body_bytes:t,correlation_keys:r,payload_keys:n})}s(IN,"debugEnvelopeSummary");function l_(e){switch(e){case"session_start":return uu;case"session_end":return lu;case"tool_invoked":case"skill_invoked":return Rs;default:return Rs}}s(l_,"timeoutForEvent");function TN(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
59
+ ${n}`}s(TN,"frameDetachedPostStdin");function f_(e,t=[],n=process.execPath,r=import.meta.url,o=c_){if(cu(n))return{command:n,args:[e,...t]};let i=ON(r);return o(i)?{command:n,args:[i,e,...t]}:{command:n,args:[e,...t]}}s(f_,"resolveSelfReexecCommand");function kN(e=process.execPath,t=import.meta.url,n=c_){let r=process.argv.includes("--debug")?["--debug"]:[];return f_(Xo,r,e,t,n)}s(kN,"resolveSelfPostCommand");function xN(e){let t=e.indexOf(`
60
+ `);if(t<0)return null;let n;try{n=JSON.parse(e.slice(0,t))}catch{return null}return{meta:n,body:e.slice(t+1)}}s(xN,"parseDetachedPostStdin");function PN(e){j("EV_AI_HOOK_DEBUG")&&x(`DEBUG: ${e}`)}s(PN,"debugProxy");var d_=s((e,t)=>a_(e,t,PN),"collectorFetch");function p_(e){j("EV_AI_HOOK_DEBUG")&&x(`DEBUG: send fail ${Fn(e)}`)}s(p_,"debugFailedPost");async function m_(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();n_(n,t)}catch(n){M("collector_response",n)}}s(m_,"applyCollectorHttpResponse");function g_(e){let t=e instanceof Error?e.message:String(e);return{code:e!==null&&typeof e=="object"&&"code"in e&&typeof e.code=="string"?e.code:void 0,message:t}}s(g_,"errorParts");var __=1e3;function h_(e,t){let n=e instanceof Error&&e.name==="TimeoutError"?"timeout":"post_failed";ne({outcome:n,postMs:t,err:ht(e)})}s(h_,"noteFailedPost");async function E_(e,t=d_){try{let n=await e(),r=xN(n);if(!r){oe.error("send fail code=bad-frame message=detached post stdin was not framed"),ne({outcome:"post_failed",err:"bad-frame"});return}let{meta:o,body:i}=r,a=Ja(i),c=Yo(a.contentEncoding),u=performance.now();try{let f=await t(o.url,{method:"POST",headers:c,body:a.body,signal:AbortSignal.timeout(Number(o.timeoutMs))}),l=performance.now()-u;if(!f.ok){let p=(await f.text()).slice(0,__).replace(/[\n\r]/g,"");oe.error(`send fail http=${f.status} code=${f.status} body=${p}`),ne({outcome:"post_failed",postMs:l,http:f.status});return}oe.info(`send ok http=${f.status}`),ne({outcome:"posted",postMs:l,http:f.status}),await m_(f,o.url)}catch(f){let l=g_(f);oe.error(`send fail code=${l.code??"(none)"} ${Fn(f)}`),p_(f),h_(f,performance.now()-u)}}catch(n){M("post",n),ne({outcome:"error",err:ht(n)})}finally{rn("post",Qe,"error")}}s(E_,"runDetachedPoster");async function NN(e,t,n,r=d_){let o=l_(e),i=Ja(t),a=Yo(i.contentEncoding),c=Xa(i.body);x(`POST event=${e} url=${en(n)} size=${c} encoding=${i.contentEncoding??"identity"} platform=${process.platform}`);let u=Date.now(),f=performance.now();try{let l=await r(n,{method:"POST",headers:a,body:i.body,signal:AbortSignal.timeout(o)});if(!l.ok&&i.contentEncoding==="gzip"&&(l.status===400||l.status===415)){try{await l.text()}catch{}x(`POST gzip rejected http=${l.status} \u2014 retrying uncompressed`),l=await r(n,{method:"POST",headers:Yo(),body:t,signal:AbortSignal.timeout(o)})}let p=Date.now()-u,d=performance.now()-f;if(Ua(d),l.ok)return x(`POST outcome=ok elapsed_ms=${p} http=${l.status}`),oe.info(`send ok http=${l.status}`),ne({outcome:"posted",postMs:d,http:l.status}),await m_(l,n),!0;let m=(await l.text()).slice(0,__).replace(/[\n\r]/g,"");return x(`POST outcome=fail elapsed_ms=${p} http=${l.status} body=${m}`),oe.error(`send fail http=${l.status} code=${l.status} body=${m}`),ne({outcome:"post_failed",postMs:d,http:l.status}),!1}catch(l){let p=Date.now()-u,d=performance.now()-f;Ua(d);let m=g_(l);return x(`POST outcome=fail elapsed_ms=${p} http=000 body=${m.message}`),oe.error(`send fail http=0 code=${m.code??"(none)"} ${Fn(l)}`),p_(l),h_(l,d),!1}}s(NN,"postCollector");async function S_(e,t,n,r,o){let i=o.replaceAll(" ","_");try{let a=r(e,t,{detached:!0,stdio:["pipe","ignore","ignore"],windowsHide:!0});a.on("error",u=>{M(i,u)}),a.stdin.on("error",u=>{M(`${i}_stdin`,u)});let c=!1;return await new Promise(u=>{let f=setTimeout(()=>{if(!c){x(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`),oe.error(`failed where=${i} err=timeout message=stdin handoff timed out`);try{a.stdin.destroy()}catch{}}u()},fu),l=s(()=>{c=!0,clearTimeout(f),u()},"done");a.stdin.end(n,()=>l()),a.stdin.once("error",()=>l())}),a.unref(),a}catch(a){let c=a instanceof Error?a.message:String(a);return x(`WARN: ${o} spawn failed open: ${c}`),M(i,a),null}}s(S_,"spawnDetachedStdinChild");async function wN(e,t,n,r=u_,o=kN){let i=l_(e),a=TN(n,i,t),{command:c,args:u}=o();return S_(c,u,a,r,"detached post")}s(wN,"postCollectorDetached");async function y_(e,t,n=u_,r=f_){let{command:o,args:i}=r(In,t);return S_(o,i,e,n,"detached work")}s(y_,"runHookDetached");async function Tn(e,t,n,r,o,i,a,c){if(!o)return x("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),oe.error("send fail code=missing message=collector URL missing"),ne({outcome:"no_collector",err:"missing"}),!1;if(!wr(o))return x(`WARN: collector URL blocked (https required): ${en(o)}`),oe.error("send fail code=blocked message=collector URL blocked"),ne({outcome:"no_collector",err:"blocked"}),!1;let u=performance.now(),f=await bN(t,n.runnerPlatform,a),l=performance.now(),p=r(e,f,{...n,collectorUrl:o});i!==void 0&&(p.build_ms=Math.max(0,Date.now()-i));let d=dg({w4:u,w4e:l,w5:performance.now()},process.env,void 0,n.telemetry?.enabled===!0);d&&(p.perf=d);let m=JSON.stringify(p),g=c?.attach(Buffer.byteLength(m,"utf8"));g&&(p.run_log=g,m=JSON.stringify(p));let E=`${m}
61
+ `,S=j("EV_AI_HOOK_DEBUG");S==="full"?x(`DEBUG envelope=${m}`):S==="1"&&x(`DEBUG summary=${IN(p,Xa(E))}`);let C=process.argv.includes(In),P=j("EV_AI_HOOK_SYNC")==="1";if(!(Uo(n.runnerEvent,n.runnerPlatform)||C||P)){let T=await wN(e,E,o);return ne(T?.pid!==void 0?{outcome:"handed_off"}:{outcome:"post_failed",err:"spawn"}),!1}return NN(e,E,o)}s(Tn,"emitAndPost");import{closeSync as LN,fstatSync as MN,linkSync as vN,openSync as UN,readdirSync as DN,readSync as HN,renameSync as FN,unlinkSync as T_}from"node:fs";import{homedir as $N}from"node:os";import{basename as jN,dirname as BN}from"node:path";var R_=Ps,C_=2*1024*1024,KN=Buffer.byteLength(',"run_log":',"utf8");function A_(e){let t=`${e}.send-${process.pid}`;try{return FN(e,t),{path:e,taken:t}}catch(n){return n.code==="ENOENT"?"missing":"busy"}}s(A_,"take");function O_(e){return typeof e=="object"}s(O_,"isTaken");function GN(e){let t=`${jN(e)}.`;try{return DN(BN(e)).some(n=>n.startsWith(t)&&/\.send-\d+$/.test(n))}catch{return!1}}s(GN,"anyTakenLog");function VN(e){try{vN(e.taken,e.path),T_(e.taken)}catch{}}s(VN,"putBack");function zN(e){try{T_(e)}catch{}}s(zN,"unlinkQuiet");function b_(e,t){let n;try{n=UN(e,"r");let r=MN(n);if(!r.isFile())return;let o=Math.min(r.size,Math.max(0,t)),i=Buffer.alloc(o),a=0;for(;a<o;){let c=HN(n,i,a,o-a,r.size-o+a);if(c===0)break;a+=c}return{tail:i.subarray(0,a),size:r.size}}catch{return}finally{if(n!==void 0)try{LN(n)}catch{}}}s(b_,"readTail");function WN(e){let t=e.indexOf(10);return t===-1?e:e.subarray(t+1)}s(WN,"fromFirstWholeLine");function I_(e,t,n){Ms(r=>{r[t]===n&&delete r[t]},e)}s(I_,"forgetWindow");function k_(e,t=$N(),n=process.env,r=Date.now()){try{let o=e?Mt(e):void 0;if(!o||Hu())return;let i=Ls(t)[o];if(i===void 0||i===nn)return;let a=Date.parse(i);if(Number.isNaN(a)||a>r)return;let c=Mu(t,n,r);if(c.on||c.source!=="remote")return;let u=Fr(t),f=A_(u),l=A_(`${u}.1`),p=O_(f)?f:void 0,d=O_(l)?l:void 0,m=[d,p].filter(w=>w!==void 0),g=s(()=>{for(let w of m)VN(w)},"putAllBack"),E=p?b_(p.taken,R_):void 0,S=d?b_(d.taken,R_-(E?.tail.length??0)):void 0,C=(E?.size??0)+(S?.size??0);if(C===0){g(),f!=="busy"&&l!=="busy"&&!GN(u)&&I_(t,o,i);return}let P=Buffer.concat([S?.tail??Buffer.alloc(0),E?.tail??Buffer.alloc(0)]),N=P.length<C,T=N?WN(P):P,b={log_until:i,text:T.toString("utf8"),bytes:T.length,bytes_total:C,truncated:N},U=KN+Buffer.byteLength(JSON.stringify(b),"utf8"),L=!1,I=!1;return{attach(w){if(w+U>C_){x(`run log deferred: body=${w} run_log=${U} over ${C_}`);return}return L=!0,b},settle(w){if(!I){if(I=!0,!(L&&w)){g();return}for(let v of m)zN(v.taken);I_(t,o,i)}}}}catch(o){x(`WARN: run log upload failed open: ${o instanceof Error?o.message:String(o)}`);return}}s(k_,"prepareRunLogUpload");import{createReadStream as YN}from"node:fs";import{stat as JN}from"node:fs/promises";import{basename as XN,resolve as qN}from"node:path";import{createInterface as ZN}from"node:readline";var QN=1024*1024;function ew(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&XN(t).endsWith(".jsonl")}s(ew,"isSafeClaudeTranscriptPath");async function x_(e){if(!e||!ew(e))return null;try{let t=qN(e),n=await JN(t);if(!n.isFile())return null;let r=Math.max(0,n.size-QN),o=[],i=ZN({input:YN(t,{encoding:"utf8",start:r}),crlfDelay:1/0});for await(let a of i)a.length!==0&&o.push(a);r>0&&o.length>0&&o.shift();for(let a=o.length-1;a>=0;a--){let c=o[a];if(c)try{let u=JSON.parse(c);if(u.type!=="assistant")continue;let f=u.message;if(!f||typeof f!="object")continue;let l=f.model;if(typeof l=="string"&&l.length>0)return l}catch{continue}}return null}catch{return null}}s(x_,"lastAssistantModelFromTranscript");var tw="EV_AI_HOOK_TELEMETRY";function P_(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}s(P_,"telemetryFromHomeConfig");function N_(e,t,n=process.env){let r=n[tw]?.trim().toLowerCase();return r&&Nt.has(r)?{enabled:!0,source:"env"}:r&&Cr.has(r)?{enabled:!1,source:"env"}:e!==void 0?{enabled:e,source:"local_config"}:t?.collect_telemetry!==void 0?{enabled:t.collect_telemetry,source:"org_config"}:{enabled:!0,source:"default"}}s(N_,"resolveTelemetry");function qo(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:Kr(e.manifest.manifest,e.manifest.hookConfig),telemetry:M_(e)}}s(qo,"envelopeFieldsFromContext");function M_(e){return N_(e.manifest.localTelemetry,e.manifest.hookConfig)}s(M_,"telemetryFor");function Qa(e){return Or({sessionId:e.sessionId,hostname:ps()})}s(Qa,"runnerContextOf");function ec(e){let t=B(e.hookInput,"user_email").trim();return t.length>0?t:void 0}s(ec,"hookUserEmailOf");function gr(e,t,n=Qa(e)){let r=ec(e);return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{},context:n,...r?{hookUserEmail:r}:{}}}s(gr,"operatorContextFrom");function tc(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:$s(e.manifest.hookConfig)}}s(tc,"hookInputSanitizeOptions");async function v_(e){let t=Date.now();await _w(e);let{gitRoot:n}=e.manifest;await rc(e,n);let r=tc(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:Vr(e.hookInput,e.manifest.manifest,r),envelopeFields:qo(e),launchCwd:js(e.hookInput,r),home:rw()}}s(v_,"prepareDerivedInvoke");function w_(e){try{return Me(nw(e))}catch{return null}}s(w_,"tryRealpath");function U_(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}s(U_,"isAbsolutePath");function L_(e,t){let n=e.replaceAll("\\","/");if(!U_(n))return null;let r=Me(e),o=Me(t),i=w_(e)??r,a=w_(t)??o;return i.startsWith(`${a}/`)?i.slice(a.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}s(L_,"relativeToAnchor");function D_(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),i=L_(e,t)??(U_(r)?null:r),a=L_(e,n);return{repositorySourcePath:i,userSourcePath:a}}s(D_,"sourcePathsFromResolvedFile");function Za(e,t,n,r,o){return H_(e,D_(n,t.gitRoot,t.home),r,o)}s(Za,"exactFileComponentFromResolvedPath");function H_(e,{repositorySourcePath:t,userSourcePath:n},r,o){let i=t??n,a=i===null?null:o(i),c=a!==null&&i!==null?ow({installableKind:r,sourcePath:i,nativeKey:a,inRepository:t!==null,platformAgentId:e.platformAgentId,installationId:e.manifest.installationId}):void 0;return{sourcePath:i,nativeKey:a,componentReference:c}}s(H_,"exactFileComponent");function ow(e){try{let t=e.inRepository?j_(e.platformAgentId,e.sourcePath):(0,K.installationRootExternalKey)(e.installationId,(0,K.userConfigRootFromPath)(e.sourcePath));return t?(0,K.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}s(ow,"tryExactFileComponentReference");function F_(e){let t=e.policyFindings;return t===void 0||t.length===0?{}:{policy_findings:t,...e.policyJudgeSpawnMs!==void 0?{policy_judge_spawn_ms:e.policyJudgeSpawnMs}:{}}}s(F_,"policyPayload");function nc(e,t,n){return Tn("tool_invoked",{...n,...F_(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,On,e.manifest.collectorUrl,t.buildStartedAtMs,gr(e,t.home))}s(nc,"postDerivedToolInvoked");function sw(e){return Lm(e.runnerEvent,e.runnerPlatform)?[]:Cm(e.hookInput)}s(sw,"slashIdsFromHookInput");function iw(e,t){return nc(e,t,{})}s(iw,"postPromptSubmitted");var $_=new Set([...Object.values(Gt),".github"]);function j_(e,t){let n=e.indexOf(":");return n<=0?null:(0,K.repositoryConfigRootExternalKeyFromPath)(e.slice(0,n),t)}s(j_,"repositoryConfigRootExternalKey");var B_=".codex/config.toml",aw=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",B_],["antigravity_mcp_user",Fa]]),cw=new Map([["mcp_json",".mcp.json"],["cursor_mcp",".cursor/mcp.json"]]);function uw(e){if(e===null)return null;let t=e.indexOf(":");if(t<=0||t===e.length-1)return null;let n;try{n=(0,K.normalizeRepositoryRelativePath)(e.slice(t+1))}catch{return null}let r=n.split("/").at(-1);return r===void 0||!$_.has(r)?null:{repoSlug:e.slice(0,t),scope:n}}s(uw,"repositoryAgentScope");function lw(e,t){let n=j_(`${e.repoSlug}:${e.scope}`,t);return n!==null?t.split("/").find(o=>$_.has(o))===e.scope.split("/").at(-1)?n:null:e.scope.includes("/")?null:`${e.repoSlug}:${e.scope}`}s(lw,"repositoryMcpRootExternalKey");function fw(e,t,n){return e===As&&n.some(r=>r.name.toLowerCase()===t.toLowerCase())}s(fw,"isAntigravityDeclaredServer");function dw(e,t,n,r,o,i,a){if(e===null||t===null||!(a!==null||/^mcp__.+?__.+$/i.test(e)||/^MCP:[^:]+:.+$/i.test(e)||/^MCP:.+__.+$/i.test(e)||e.toLowerCase()===`mcp:${t.toLowerCase()}`||fw(o,t,i)))return;let u=i.find(E=>E.name.toLowerCase()===t.toLowerCase()),f=u?aw.get(u.source):o==="codex"?B_:void 0,l=u?.sourcePath??f;if((u?.scope==="user"||f!==void 0)&&l)try{let E=(0,K.userConfigRootFromPath)(l);return(0,K.buildComponentReference)({installationRootExternalKey:(0,K.installationRootExternalKey)(r,E),installableKind:K.ComponentKind.INTERFACE,sourcePath:l,nativeKey:u?.nativeKey??u?.name??t})}catch{return}let d=u?cw.get(u.source):void 0,m=uw(n);if(u===void 0||d===void 0||m===null)return;let g=lw(m,d);if(g!==null)try{return(0,K.buildComponentReference)({installationRootExternalKey:g,installableKind:K.ComponentKind.INTERFACE,sourcePath:d,nativeKey:u.name})}catch{return}}s(dw,"exactMcpComponentReference");function pw(...e){for(let t of e)if(t)return t;return null}s(pw,"firstNonEmpty");function Wt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return x(`WARN: ${n} failed open: ${r}`),M(n,e.reason),t}s(Wt,"settledOr");function mw(e){let t={present:!1,size:0},n={hash:"",count:0};return{config:{runner_platform:e,config_scope:"user",cli_version:null,claude_version:null,model:null,permission_keys:[],user_scope:{skills:n,subagents:n,commands:n,rules:n,memory:t,settings:t,mcp:t},local_settings:t},commit:s(()=>{},"commit")}}s(mw,"emptySelfConfigResult");function gw(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}s(gw,"cloudBootstrapSelfConfig");var zt=new Set,mr=null;async function _w(e){if(hn())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(zt.has(t))return;if(!Wa(n)){zt.add(t);return}let r=String(e.runnerPlatform),o=Qa(e);if(Fg(o,r)){if(mr){await mr;return}mr=(async()=>{if(zt.has(t)||!Wa(n)){zt.add(t);return}if(!am(n)){zt.add(t);return}let i=!1;try{let a=Date.now(),{gitRoot:c}=e.manifest,{operatorResolved:u,fields:f}=await K_(e,o,Xe("git",()=>Mo(c)),Xe("operator",()=>za({gitRoot:c,installationStorePath:n,forceResend:!1,runnerPlatform:r,context:o,hookUserEmail:ec(e),gitConfigCachePath:En()}))),l={...f,self_config:gw(r,u.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};i=!!await Tn("session_start",l,qo(e),On,e.manifest.collectorUrl,a,gr(e,void 0,o)),i&&(u.commit(),zt.add(t))}finally{cm(n)}})().finally(()=>{mr=null}),await mr}}s(_w,"maybeBootstrapCloudIdentity");async function rc(e,t,n){try{e.platformAgentId=await Am(e.manifest.manifest,e.platformAgentId,String(e.runnerPlatform),t,n,e.manifest.installationStorePath,e.manifest.repoKey)}catch(r){let o=r instanceof Error?r.message:String(r);x(`WARN: derivePlatformAgentId failed open: ${o}`),M("platform_agent_id",r)}}s(rc,"resolvePlatformAgentId");async function K_(e,t,n,r){let[o,i,a,c,u]=await Promise.allSettled([n,Xe("virt",()=>Tc()),Xe("cloud",()=>gg(t)),Xe("host_env",()=>xc(M_(e).enabled)),r]),f=Wt(o,null,"gitSnapshot"),l=Wt(i,"","detectVirt"),p=Wt(a,null,"probeCloud"),d=Wt(c,{},"hostEnv"),m=Wt(u,{commit:s(()=>{},"commit")},"resolveOperatorForSend");return await rc(e,e.manifest.gitRoot,f),{operatorResolved:m,fields:{identity:{host:ps(),context:t,virt:l||null,cloud:p,git:f},host_env:d,env_vars:Rg()}}}s(K_,"collectIdentityPayload");async function hw(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=Qa(e),o=String(e.runnerPlatform),i=tc(e),a=js(e.hookInput,i),c=Xe("git",()=>Mo(n)),u=Zg().catch(L=>(M("launcher_fields",L),{})),f=hn()?Promise.resolve({commit:s(()=>{},"commit")}):Xe("operator",()=>za({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o,context:r,hookUserEmail:ec(e),gitConfigCachePath:En()})),l=K_(e,r,c,f),[p,d]=await Promise.allSettled([Xe("mcp_declared",()=>$a(e.manifest.manifest,n,o)),c.catch(()=>null).then(L=>Xe("self_config",()=>jp(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,installationId:e.manifest.installationId,gitRoot:n,launchCwd:a,inGitRepo:e.manifest.inGitRepo,remote:L?.remote??null})))]),{operatorResolved:m,fields:g}=await l,E=Wt(p,[],"mcpDeclared"),S=Wt(d,mw(o),"selfConfig"),C=S.config,P=B(e.hookInput,"model");P&&(C.model=P);let N={...g,mcp:{declared:E.map(({nativeKey:L,...I})=>I)},self_config:C,run_meta:{trigger:e.hookSource||"startup"},hook_input:Vr(e.hookInput,e.manifest.manifest,{...i,launchCwd:a})},T=await u,b=k_(e.manifest.collectorUrl),U=!1;try{U=await Tn("session_start",N,{...qo(e),...T},On,e.manifest.collectorUrl,t,gr(e,void 0,r),b)}finally{b?.settle(U)}U&&(S.commit(),m.commit(),zt.add(e.manifest.installationId))}s(hw,"handleSessionStart");async function Ew(e){let t=Date.now(),[,n]=await Promise.all([rc(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?x_(B(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=pw(B(e.hookInput,"status"),B(e.hookInput,"stop_reason"),B(e.hookInput,"reason"),cr(B(e.hookInput,"error")),r==="stop"?Ze(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),i=Vr(e.hookInput,e.manifest.manifest,tc(e));n&&(i.model=n),r!=="stopfailure"&&Kr(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&i.last_assistant_message===void 0&&(i.last_assistant_message=""),await Tn("session_end",{status:o,...n?{model:n}:{},hook_input:i},qo(e),On,e.manifest.collectorUrl,t,gr(e))}s(Ew,"handleSessionEnd");async function Sw(e){let t=sw(e),n=Tm(e.hookInput),r=wm(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&Kr(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let i=await v_(e);await Promise.all([o?iw(e,i):void 0,t.length===0?void 0:yw(e,i,t),n.length===0?void 0:Rw(e,i,n)])}s(Sw,"handleSkillInvoked");function G_(e,t,n,r){let o=r??Rm({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),i=Za(e,t,o,K.ComponentKind.SKILL,K.nativeKeyForSkillPath);if(i.sourcePath!==null&&ya(i.sourcePath)?.toLowerCase()===Em(n))return i.componentReference===void 0?{}:{componentReference:i.componentReference};let a=r??km({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),c=Za(e,t,a,K.ComponentKind.COMMAND,K.nativeKeyForCommandPath);return c.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:c.nativeKey,...c.componentReference===void 0?{}:{componentReference:c.componentReference}}}s(G_,"slashComponentIdentity");function yw(e,t,n){let r=Lo(e.hookInput.tool_input);return Promise.all(n.map(o=>{let i=G_(e,t,o,r);return nc(e,t,{tool_name:"Skill",skill_name:o,...i.commandName===void 0?{}:{command_name:i.commandName},...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(yw,"postSkillInvokes");function Rw(e,t,n){return Promise.all(n.map(r=>{let o=Om({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),i=Za(e,t,o,K.ComponentKind.RULE,K.nativeKeyForRulePath),a=i.nativeKey??Im(r);return nc(e,t,{tool_name:"Rule",rule_name:a,...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(Rw,"postRuleInvokes");var Cw=[{kind:K.ComponentKind.SKILL,nativeKeyFn:K.nativeKeyForSkillPath},{kind:K.ComponentKind.RULE,nativeKeyFn:K.nativeKeyForRulePath},{kind:K.ComponentKind.COMMAND,nativeKeyFn:K.nativeKeyForCommandPath}];function Aw(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Ca(e.hookInput);if(r===null)return n.skillName===null?{}:G_(e,t,n.skillName,null);let o=D_(r,t.gitRoot,t.home);for(let i of Cw){let a=H_(e,o,i.kind,i.nativeKeyFn);if(a.nativeKey!==null)return{...a.componentReference===void 0?{}:{componentReference:a.componentReference},...i.kind===K.ComponentKind.RULE?{ruleName:a.nativeKey}:{},...i.kind===K.ComponentKind.COMMAND?{commandName:a.nativeKey}:{}}}return{}}s(Aw,"toolComponentIdentity");var Ow=/mcp/i;function bw(e,t,n,r){let o=Ow.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let i=o?Qd(t,n):ho(r.declaredConfig,n);return i===null?{}:Object.fromEntries(Object.entries(i).filter(a=>typeof a[1]=="string").map(([a,c])=>[`mcp_${a}`,c]))}s(bw,"mcpPackageFields");async function Iw(e){let t=await v_(e),n=Um(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,i=Ra(e.hookInput),a=up(i,t.home),c=Hm(e.hookInput),u=Mm(e.runnerEvent),f=u===!1?Fm(e.hookInput,e.runnerEvent):null,l=cr(B(e.hookInput,"mcp_server_name")),p=l!==null||r!==null&&Fo(r)?await $a(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(U=>(M("mcpDeclared",U),[])):[],{mcpServer:d,mcpTool:m}=jm(r,p.map(U=>U.name),l??""),g=dw(r,d,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),p,l),E=g===void 0?Aw(e,t,n):{},S=d===null?null:yg(d,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),C=bw(e,i,t.home,{hasMcpIdentity:!!d||!!m,declaredConfig:S}),P=g??E.componentReference,N=E.ruleName??n.ruleName,T=E.commandName??n.commandName,b=Dm(e.hookInput);await Tn("tool_invoked",{tool_name:r,skill_name:o,...N?{rule_name:N}:{},...T?{command_name:T}:{},success:u,duration_ms:c,...a?{executable:a}:{},...f?{failure_reason:f}:{},...d?{mcp_server:d}:{},...m?{mcp_tool:m}:{},...C,...P?{component_reference:P}:{},...b?{subagent_type:b}:{},...F_(e),hook_input:t.hookInput},t.envelopeFields,On,e.manifest.collectorUrl,t.buildStartedAtMs,gr(e,t.home))}s(Iw,"handleToolInvoked");async function V_(e){switch(et("w3"),e.internalEvent){case"session_start":await hw(e);return;case"session_end":await Ew(e);return;case"skill_invoked":await Sw(e);return;case"tool_invoked":await Iw(e);return;default:return}}s(V_,"dispatchInternalEvent");import{existsSync as sc,readFileSync as Tw}from"node:fs";import{dirname as kw,isAbsolute as xw,join as Pw,relative as Nw}from"node:path";function z_(e){for(let t of nu){let n=Pw(e,t);if(sc(n))return n}}s(z_,"firstExistingManifest");async function ww(e=process.cwd(),t){let n=t??await ls(e);return z_(n)??z_(e)}s(ww,"findRepoManifestPath");async function Lw(e,t){let n=t??await ls(kw(e)),r=Nw(n,e);if(r.startsWith("..")||xw(r))return!1;let o=await ve("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(x(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}s(Lw,"isManifestGitTracked");function oc(e){let t=Tw(e,"utf8");return xe(Yt(t),{})}s(oc,"loadRepoManifestFromFile");function Mw(){return{schema_version:Lr,mcp_servers:[]}}s(Mw,"defaultSharedManifest");function vw(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(x(`WARN: ignoring capture_hook_input=full in git-tracked manifest ${t}; use EV_AI_HOOK_CAPTURE_FULL_INPUT=1 or an untracked operator manifest`),delete e.capture_hook_input),e.debug===!0&&r.has("debug")&&(x(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}s(vw,"stripTrackedUnsafeFields");function Uw(e){let t=au({argv:e.argv,env:process.env,homeConfig:e.homeConfig,manifest:e.manifest,manifestSource:e.manifestSource});for(let r of t.warnings){x(`WARN: ignoring ${r.label}: ${r.problem}`);let o=r.label.replace(/\s+/g,"_"),i=r.problem.replace(/\/[^/\s]+\/hook\b/g,"/***/hook");oe.error(`collector ignored label=${o} message=${i}`)}let n=t.url??"";return oe.info(`collector source=${t.source} url=${n?en(n):"(none)"}`),n}s(Uw,"collectorUrlFromLoaded");function Dw(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}s(Dw,"recordOrUndefined");async function W_(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await us(e),o=j("EV_AI_HOOK_MANIFEST"),i=o&&sc(o)?o:void 0,a=i?void 0:sc(Lt())?Lt():void 0,c=i?void 0:await ww(e,n),u=a?oc(a):void 0,f=c?oc(c):void 0,l=P_(i?J(Lt(),{}):u),p,d,m,g=new Set;if(i){p=oc(i),d=i,m=i;for(let b of Object.keys(p))g.add(b)}else if(u&&f){p=ou(f,u),d=a,m=c;for(let b of Object.keys(f))b in u||g.add(b)}else if(u)p=u,d=a;else if(f){p=f,d=c,m=c;for(let b of Object.keys(f))g.add(b)}else p=Mw();delete p.installation_id;let E=m?await Lw(m,n):!1;vw(p,m,E,g);let{installationId:S,storePath:C,repoKey:P}=await dm(n,{sessionId:t.sessionId}),N=u??Dw(J(Lt(),null)),T=Uw({argv:t.argv??process.argv,homeConfig:N,manifest:i?p:f,manifestSource:i?"manifest_override":"manifest"});return{manifestPath:d??C,manifest:p,installationId:S,installationStorePath:C,repoKey:P,collectorUrl:T,hookConfig:t_(T),...l!==void 0?{localTelemetry:l}:{},platformAgentId:p.platform_agent_id??"",gitRoot:n,inGitRepo:r}}s(W_,"loadManifest");import{mkdirSync as Hw,readdirSync as Fw,readFileSync as $w,statSync as Y_,unlinkSync as jw,writeFileSync as Bw}from"node:fs";import{homedir as Zo}from"node:os";import{join as ic}from"node:path";var Kw="turns",J_=1440*60*1e3,Gw=100,Vw=new Set(["stop","stopfailure","sessionend"]);function ac(e=Zo()){return ic(Ae(e),Kw)}s(ac,"sessionTurnDir");function X_(e,t){return ic(e,Nn(t))}s(X_,"sessionTurnPath");function zw(e,t=Date.now()){let n;try{n=Fw(e)}catch{return}let r=0;for(let o of n){if(r>=Gw)return;r+=1;try{let i=ic(e,o);t-Y_(i).mtimeMs>J_&&jw(i)}catch{}}}s(zw,"pruneStaleSessionTurns");function Ww(e,t,n=Zo()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let i=ac(n);Hw(i,{recursive:!0}),Bw(X_(i,r),o,"utf8")}catch{}}s(Ww,"rememberSessionTurn");function Yw(e,t=Zo()){let n=e.trim();if(!n)return"";try{let r=X_(ac(t),n);return Date.now()-Y_(r).mtimeMs>J_?"":$w(r,"utf8").trim()}catch{return""}}s(Yw,"recallSessionTurn");function q_(e,t,n,r=Zo()){let o=t.trim(),i=Vw.has(n.trim().toLowerCase());return i&&zw(ac(r)),o?(Ww(e,o,r),o):i?Yw(e,r):""}s(q_,"resolveTurnId");function th(e,t,n){let r=xe(e,{}),o=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:{};return hu(o,t,n)}s(th,"parseHookInput");async function Jw(e,t,n){let r=t??await Ar(Mr),o=th(r,n,e),i=await W_(process.cwd(),{sessionId:Rn(o)});if(et("w2"),!i){ne({outcome:"no_manifest"});return}let a=vm(o,i.manifest.platform,n),c=Ho(e,a.runnerEvent);if(!c){Os(a.runnerEvent)||x(`WARN: unknown hook event '${a.runnerEvent}'; skipping telemetry`),ne({outcome:"unknown_event"});return}ne({runner:a.runnerPlatform,event:c,session:a.sessionId});let u={hookInput:o,sessionId:a.sessionId,turnId:q_(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await V_(u)}s(Jw,"runHook");function Xw(e,t=!1){if(j("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,i=yn(r,o,void 0,n.runner);return Uo(o,i)?!0:t}s(Xw,"shouldRunHookInProcess");function Z_(e,t){let n=Zt(e),r=th(t,n.runner,n.event),o=n.event??Do(r);return n.runner==="antigravity"&&Os(Do(r))||bc()||Nm(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}s(Z_,"preflight");function nh(e){return Qm(Ho(e.parsed.event,e.runnerEvent))}s(nh,"isCapExempt");async function Q_(e,t,n){let{parsed:r}=e,o=n??Na(r.slot);if(!o&&!nh(e)){let i=Pa(r.cap),a=sg(i);if(!a){wa(i),ne({outcome:"cap_dropped"});return}o=a}try{await Jw(r.event,t,r.runner)}finally{o&&Bo(o)}}s(Q_,"runHookInSlot");var Qo,kn=!1,qw=500;function Zw(e){let t=s(()=>{process.exit(0)},"exitNow");setTimeout(t,qw);try{process.stdout.write(e,t)}catch{t()}}s(Zw,"ackThenExit");function es(e,t){let n=e[0]===In?"w":e[0]===Xo?"post":"h";Qo=void 0,kn=!1;let r=s(a=>c=>{try{M(a,c),Fu()||(ne({outcome:"error",err:ht(c)}),rn(Qo??n,Qe,"error"))}catch{}if(t){if(n==="h"&&!kn){kn=!0,Zw(vr(e));return}process.exit(0)}},"onCrash"),o=r("uncaught"),i=r("unhandled_rejection");return process.on("uncaughtException",o),process.on("unhandledRejection",i),()=>{process.off("uncaughtException",o),process.off("unhandledRejection",i)}}s(es,"installCrashLogging");async function ts(e=process.argv.slice(2),t=!1){if(t||Du(e),Ou(),Qo=void 0,kn=!1,et(e[0]===In?"w0":"h0"),ig(),j("EV_AI_HOOK_JUDGE")==="1"){try{await Ar(Mr)}catch{}return as(vr(e)),kn=!0,0}if(e[0]===Xo){try{await E_(cs)}catch{}return 0}if(e[0]===In){let i=!1;try{let a=await cs();et("w1");let c=Z_(e.slice(1),a);if(!c)return ne({outcome:"suppressed"}),0;eh(c),i=Ho(c.parsed.event,c.runnerEvent)==="session_start",await Q_(c,a)}catch(a){let c=a instanceof Error?a.message:String(a);x(`WARN: detached work failed open: ${c}`),M("work",a),ne({outcome:"error",err:ht(a)})}finally{rn("w",Qe,"no_post"),i&&ju()}return 0}let n,r="error",o=!1;try{$u();let i=await Ar(Mr);et("h1");let a=Z_(e,i);if(!a)return r="suppressed",0;eh(a);let{parsed:c,hookInput:u,runnerEvent:f}=a;if(n=Na(c.slot),!zm(u,f,c.runner))return r="duplicate",0;if(et("h2"),Xw(a))o=!0,Qo="inproc",r="no_post",await Q_(a,i,n);else{let l=n||nh(a)?void 0:Pa(c.cap);if(l===void 0||rg(l)){et("h3"),lg();let p=await y_(i,e);n&&p?.pid!==void 0&&tg(n,p.pid),p?.pid!==void 0?r="handed_off":(r="error",ne({err:"spawn"}))}else wa(l),r="cap_dropped"}}catch(i){let a=i instanceof Error?i.message:String(i);x(`WARN: hook failed open: ${a}`),M("hook",i),r="error",ne({outcome:"error",err:ht(i)})}finally{n&&Bo(n),as(vr(e)),kn=!0,ne({ackMs:performance.now()}),rn(o?"inproc":"h",Qe,r)}return 0}s(ts,"main");function eh({parsed:e,hookInput:t,runnerEvent:n}){ne({runner:yn(t,n,void 0,e.runner),event:n,session:Rn(t),tool:typeof t.tool_name=="string"?t.tool_name:void 0})}s(eh,"noteInvocation");var Qw=Symbol.for(Uc);function rh(){return globalThis[Qw]===!0}s(rh,"isLoadedByLauncher");async function eL(e){is(e);let t=es(e.argv,!1);try{return await ts(e.argv)}finally{t(),is(void 0)}}s(eL,"runInLauncher");rh()||(es(process.argv.slice(2),!0),ts().then(e=>{process.exit(e)}).catch(e=>{M("entry",e);let t=e instanceof Error?e.message:String(e);process.stderr.write(`[ev-ai-agent-hook] ${t}
62
+ `),process.exit(1)}));export{eL as runInLauncher};