@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/COLLECTED-DATA.md +2 -2
- package/README.md +2 -2
- package/dist/cli.mjs +50 -50
- package/dist/hook.mjs +46 -46
- package/dist/launcher-update.mjs +6 -6
- package/dist/launcher.mjs +7 -7
- package/dist/managed-hooks-snippet.cjs +1759 -254
- package/dist/managed-hooks-snippet.d.ts +41 -4
- package/dist/managed-hooks-snippet.mjs +1750 -254
- package/dist/plugin-hooks.mjs +1201 -243
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -2,67 +2,67 @@
|
|
|
2
2
|
import { createRequire as __createRequire } from 'node:module';
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
|
|
5
|
-
var hh=Object.create;var ss=Object.defineProperty;var Sh=Object.getOwnPropertyDescriptor;var yh=Object.getOwnPropertyNames;var Eh=Object.getPrototypeOf,Rh=Object.prototype.hasOwnProperty;var s=(e,t)=>ss(e,"name",{value:t,configurable:!0}),mt=(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 X=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ch=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of yh(t))!Rh.call(e,o)&&o!==n&&ss(e,o,{get:()=>t[o],enumerable:!(r=Sh(t,o))||r.enumerable});return e};var $e=(e,t,n)=>(n=e!=null?hh(Eh(e)):{},Ch(t||!e||!e.__esModule?ss(n,"default",{value:e,enumerable:!0}):n,e));var no=X(Pe=>{"use strict";Pe.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Pe.find=(e,t)=>e.nodes.find(n=>n.type===t);Pe.exceedsLimit=(e,t,n=1,r)=>r===!1||!Pe.isInteger(e)||!Pe.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Pe.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)};Pe.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Pe.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;Pe.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Pe.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Pe.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 ro=X((kL,gl)=>{"use strict";var ml=no();gl.exports=(e,t={})=>{let n=s((r,o={})=>{let i=t.escapeInvalid&&ml.isInvalidBrace(o),a=r.invalid===!0&&t.escapeInvalid===!0,c="";if(r.value)return(i||a)&&ml.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 hl=X((xL,_l)=>{"use strict";_l.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=X((IL,kl)=>{"use strict";var Sl=hl(),Ft=s((e,t,n)=>{if(Sl(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(Sl(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(Ft.cache.hasOwnProperty(u))return Ft.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=bl(e)||bl(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=yl(h,Math.abs(f),d,r),f=d.a=0}return l>=0&&(m=yl(f,l,d,r)),d.negatives=g,d.positives=m,d.result=AE(g,m,r),r.capture===!0?d.result=`(${d.result})`:r.wrap!==!1&&m.length+g.length>1&&(d.result=`(?:${d.result})`),Ft.cache[u]=d,d.result},"toRegexRange");function AE(e,t,n){let r=Vs(e,t,"-",!1,n)||[],o=Vs(t,e,"",!1,n)||[],i=Vs(e,t,"-?",!0,n)||[];return r.concat(i).concat(o).join("|")}s(AE,"collatePatterns");function bE(e,t){let n=1,r=1,o=Rl(e,n),i=new Set([t]);for(;e<=o&&o<=t;)i.add(o),n+=1,o=Rl(e,n);for(o=Cl(t+1,r)-1;e<o&&o<=t;)i.add(o),r+=1,o=Cl(t+1,r)-1;return i=[...i],i.sort(xE),i}s(bE,"splitToRanges");function kE(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=OE(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+=IE(u,f,n):a++}return a&&(i+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:i,count:[a],digits:o}}s(kE,"rangeToPattern");function yl(e,t,n,r){let o=bE(e,t),i=[],a=e,c;for(let u=0;u<o.length;u++){let f=o[u],l=kE(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+Al(c.count),a=f+1;continue}n.isPadded&&(p=TE(f,n,r)),l.string=p+l.pattern+Al(l.count),i.push(l),a=f+1,c=l}return i}s(yl,"splitToPatterns");function Vs(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(Vs,"filterPatterns");function OE(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}s(OE,"zip");function xE(e,t){return e>t?1:t>e?-1:0}s(xE,"compare");function El(e,t,n){return e.some(r=>r[t]===n)}s(El,"contains");function Rl(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}s(Rl,"countNines");function Cl(e,t){return e-e%Math.pow(10,t)}s(Cl,"countZeros");function Al(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}s(Al,"toQuantifier");function IE(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}s(IE,"toCharacterClass");function bl(e){return/^-?(0+)\d/.test(e)}s(bl,"hasPadding");function TE(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(TE,"padZeros");Ft.cache={};Ft.clearCache=()=>Ft.cache={};kl.exports=Ft});var Js=X((wL,Ml)=>{"use strict";var wE=mt("util"),Il=Ol(),xl=s(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"isObject"),PE=s(e=>t=>e===!0?Number(t):String(t),"transform"),zs=s(e=>typeof e=="number"||typeof e=="string"&&e!=="","isValidValue"),Gn=s(e=>Number.isInteger(+e),"isNumber"),Ws=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"),NE=s((e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,"stringify"),ME=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"),so=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((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=>so(String(c),n)).join("|")),e.negatives.length&&(i=`-(${r}${e.negatives.map(c=>so(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"),wl=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"),Pl=s((...e)=>new RangeError("Invalid range arguments: "+wE.inspect(...e)),"rangeError"),Nl=s((e,t,n)=>{if(n.strictRanges===!0)throw Pl([e,t]);return[]},"invalidRange"),LE=s((e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},"invalidStep"),UE=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 Pl([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=Ws(c)||Ws(u)||Ws(f),p=l?Math.max(c.length,u.length,f.length):0,d=l===!1&&NE(e,t,r)===!1,m=r.transform||PE(d);if(r.toRegex&&n===1)return Tl(so(e,p),so(t,p),!0,r);let g={negatives:[],positives:[]},h=s(w=>g[w<0?"negatives":"positives"].push(Math.abs(w)),"push"),E=[],k=0;for(;a?o>=i:o<=i;)r.toRegex===!0&&n>1?h(o):E.push(ME(m(o,k),p,d)),o=a?o-n:o+n,k++;return r.toRegex===!0?n>1?vE(g,r,p):wl(E,null,{wrap:!1,...r}):E},"fillNumbers"),HE=s((e,t,n=1,r={})=>{if(!Gn(e)&&e.length>1||!Gn(t)&&t.length>1)return Nl(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?wl(l,null,{wrap:!1,options:r}):l},"fillLetters"),oo=s((e,t,n,r={})=>{if(t==null&&zs(e))return[e];if(!zs(e)||!zs(t))return Nl(e,t,r);if(typeof n=="function")return oo(e,t,1,{transform:n});if(xl(n))return oo(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,Gn(n)?Gn(e)&&Gn(t)?UE(e,t,n,o):HE(e,t,Math.max(Math.abs(n),1),o):n!=null&&!xl(n)?LE(n,o):oo(e,t,1,n)},"fill");Ml.exports=oo});var Ul=X((NL,Ll)=>{"use strict";var DE=Js(),vl=no(),FE=s((e,t={})=>{let n=s((r,o={})=>{let i=vl.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=vl.reduce(r.nodes),p=DE(...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=FE});var Fl=X((vL,Dl)=>{"use strict";var $E=Js(),Hl=ro(),sn=no(),$t=s((e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?sn.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let i of o)r.push($t(i,t,n));else for(let i of t)n===!0&&typeof i=="string"&&(i=`{${i}}`),r.push(Array.isArray(i)?$t(o,i,n):o+i);return sn.flatten(r)},"append"),jE=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($t(c.pop(),Hl(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){c.push($t(c.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let p=sn.reduce(o.nodes);if(sn.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=$E(...p,t);d.length===0&&(d=Hl(o,t)),c.push($t(c.pop(),d)),o.nodes=[];return}let u=sn.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($t(c.pop(),f,u));continue}if(d.value&&d.type!=="open"){f.push($t(f.pop(),d.value));continue}d.nodes&&r(d,o)}return f},"walk");return sn.flatten(r(e))},"expand");Dl.exports=jE});var jl=X((UL,$l)=>{"use strict";$l.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:`
|
|
6
|
-
`,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 zl=X((HL,Vl)=>{"use strict";var BE=ro(),{MAX_LENGTH:Bl,CHAR_BACKSLASH:Ys,CHAR_BACKTICK:KE,CHAR_COMMA:GE,CHAR_DOT:VE,CHAR_LEFT_PARENTHESES:zE,CHAR_RIGHT_PARENTHESES:WE,CHAR_LEFT_CURLY_BRACE:JE,CHAR_RIGHT_CURLY_BRACE:YE,CHAR_LEFT_SQUARE_BRACKET:Kl,CHAR_RIGHT_SQUARE_BRACKET:Gl,CHAR_DOUBLE_QUOTE:XE,CHAR_SINGLE_QUOTE:qE,CHAR_NO_BREAK_SPACE:ZE,CHAR_ZERO_WIDTH_NOBREAK_SPACE:QE}=jl(),eR=s((e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Bl,n.maxLength):Bl;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(h=>{if(h.type==="text"&&c.type==="dot"&&(c.type="text"),c&&c.type==="text"&&h.type==="text"){c.value+=h.value;return}return a.nodes.push(h),h.parent=a,h.prev=c,c=h,h},"push");for(g({type:"bos"});l<f;)if(a=i[i.length-1],d=m(),!(d===QE||d===ZE)){if(d===Ys){g({type:"text",value:(t.keepEscaping?d:"")+m()});continue}if(d===Gl){g({type:"text",value:"\\"+d});continue}if(d===Kl){u++;let h;for(;l<f&&(h=m());){if(d+=h,h===Kl){u++;continue}if(h===Ys){d+=m();continue}if(h===Gl&&(u--,u===0))break}g({type:"text",value:d});continue}if(d===zE){a=g({type:"paren",nodes:[]}),i.push(a),g({type:"text",value:d});continue}if(d===WE){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===XE||d===qE||d===KE){let h=d,E;for(t.keepQuotes!==!0&&(d="");l<f&&(E=m());){if(E===Ys){d+=E+m();continue}if(E===h){t.keepQuotes===!0&&(d+=E);break}d+=E}g({type:"text",value:d});continue}if(d===JE){p++;let E={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(E),i.push(a),g({type:"open",value:d});continue}if(d===YE){if(a.type!=="brace"){g({type:"text",value:d});continue}let h="close";a=i.pop(),a.close=!0,g({type:h,value:d}),p--,a=i[i.length-1];continue}if(d===GE&&p>0){if(a.ranges>0){a.ranges=0;let h=a.nodes.shift();a.nodes=[h,{type:"text",value:BE(a)}]}g({type:"comma",value:d}),a.commas++;continue}if(d===VE&&p>0&&a.commas===0){let h=a.nodes;if(p===0||h.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"){h.pop();let E=h[h.length-1];E.value+=c.value+d,c=E,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(k=>{k.nodes||(k.type==="open"&&(k.isOpen=!0),k.type==="close"&&(k.isClose=!0),k.nodes||(k.type="text"),k.invalid=!0)});let h=i[i.length-1],E=h.nodes.indexOf(a);h.nodes.splice(E,1,...a.nodes)}while(i.length>0);return g({type:"eos"}),o},"parse");Vl.exports=eR});var Yl=X((FL,Jl)=>{"use strict";var Wl=ro(),tR=Ul(),nR=Fl(),rR=zl(),Oe=s((e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=Oe.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(Oe.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n},"braces");Oe.parse=(e,t={})=>rR(e,t);Oe.stringify=(e,t={})=>Wl(typeof e=="string"?Oe.parse(e,t):e,t);Oe.compile=(e,t={})=>(typeof e=="string"&&(e=Oe.parse(e,t)),tR(e,t));Oe.expand=(e,t={})=>{typeof e=="string"&&(e=Oe.parse(e,t));let n=nR(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};Oe.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?Oe.compile(e,t):Oe.expand(e,t);Jl.exports=Oe});var Vn=X((jL,ef)=>{"use strict";var oR=mt("path"),Be="\\\\/",Xl=`[^${Be}]`,sR=0,tt="\\.",iR="\\+",aR="\\?",io="\\/",cR="(?=.)",ql="[^/]",Xs=`(?:${io}|$)`,Zl=`(?:^|${io})`,qs=`${tt}{1,2}${Xs}`,uR=`(?!${tt})`,lR=`(?!${Zl}${qs})`,fR=`(?!${tt}{0,1}${Xs})`,dR=`(?!${qs})`,pR=`[^.${io}]`,mR=`${ql}*?`,Ql={DOT_LITERAL:tt,PLUS_LITERAL:iR,QMARK_LITERAL:aR,SLASH_LITERAL:io,ONE_CHAR:cR,QMARK:ql,END_ANCHOR:Xs,DOTS_SLASH:qs,NO_DOT:uR,NO_DOTS:lR,NO_DOT_SLASH:fR,NO_DOTS_SLASH:dR,QMARK_NO_DOT:pR,STAR:mR,START_ANCHOR:Zl},gR={...Ql,SLASH_LITERAL:`[${Be}]`,QMARK:Xl,STAR:`${Xl}*?`,DOTS_SLASH:`${tt}{1,2}(?:[${Be}]|$)`,NO_DOT:`(?!${tt})`,NO_DOTS:`(?!(?:^|[${Be}])${tt}{1,2}(?:[${Be}]|$))`,NO_DOT_SLASH:`(?!${tt}{0,1}(?:[${Be}]|$))`,NO_DOTS_SLASH:`(?!${tt}{1,2}(?:[${Be}]|$))`,QMARK_NO_DOT:`[^.${Be}]`,START_ANCHOR:`(?:^|[${Be}])`,END_ANCHOR:`(?:[${Be}]|$)`},_R={__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"};ef.exports={DEFAULT_MAX_EXTGLOB_RECURSION:sR,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:_R,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:oR.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?gR:Ql}}});var zn=X(Re=>{"use strict";var hR=mt("path"),SR=process.platform==="win32",{REGEX_BACKSLASH:yR,REGEX_REMOVE_BACKSLASH:ER,REGEX_SPECIAL_CHARS:RR,REGEX_SPECIAL_CHARS_GLOBAL:CR}=Vn();Re.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);Re.hasRegexChars=e=>RR.test(e);Re.isRegexChar=e=>e.length===1&&Re.hasRegexChars(e);Re.escapeRegex=e=>e.replace(CR,"\\$1");Re.toPosixSlashes=e=>e.replace(yR,"/");Re.removeBackslashes=e=>e.replace(ER,t=>t==="\\"?"":t);Re.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};Re.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:SR===!0||hR.sep==="\\";Re.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?Re.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};Re.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};Re.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",i=`${r}(?:${e})${o}`;return t.negated===!0&&(i=`(?:^(?!${i}).*$)`),i}});var uf=X((KL,cf)=>{"use strict";var tf=zn(),{CHAR_ASTERISK:Zs,CHAR_AT:AR,CHAR_BACKWARD_SLASH:Wn,CHAR_COMMA:bR,CHAR_DOT:Qs,CHAR_EXCLAMATION_MARK:ei,CHAR_FORWARD_SLASH:af,CHAR_LEFT_CURLY_BRACE:ti,CHAR_LEFT_PARENTHESES:ni,CHAR_LEFT_SQUARE_BRACKET:kR,CHAR_PLUS:OR,CHAR_QUESTION_MARK:nf,CHAR_RIGHT_CURLY_BRACE:xR,CHAR_RIGHT_PARENTHESES:rf,CHAR_RIGHT_SQUARE_BRACKET:IR}=Vn(),of=s(e=>e===af||e===Wn,"isPathSeparator"),sf=s(e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},"depth"),TR=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,h=!1,E=!1,k=!1,w=!1,P=!1,I=!1,O=!1,U=0,M,x,N={value:"",depth:0,isGlob:!1},L=s(()=>f>=r,"eos"),_=s(()=>u.charCodeAt(f+1),"peek"),T=s(()=>(M=x,u.charCodeAt(++f)),"advance");for(;f<r;){x=T();let _e;if(x===Wn){w=N.backslashes=!0,x=T(),x===ti&&(k=!0);continue}if(k===!0||x===ti){for(U++;L()!==!0&&(x=T());){if(x===Wn){w=N.backslashes=!0,T();continue}if(x===ti){U++;continue}if(k!==!0&&x===Qs&&(x=T())===Qs){if(d=N.isBrace=!0,g=N.isGlob=!0,O=!0,o===!0)continue;break}if(k!==!0&&x===bR){if(d=N.isBrace=!0,g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===xR&&(U--,U===0)){k=!1,d=N.isBrace=!0,O=!0;break}}if(o===!0)continue;break}if(x===af){if(i.push(f),a.push(N),N={value:"",depth:0,isGlob:!1},O===!0)continue;if(M===Qs&&f===l+1){l+=2;continue}p=f+1;continue}if(n.noext!==!0&&(x===OR||x===AR||x===Zs||x===nf||x===ei)===!0&&_()===ni){if(g=N.isGlob=!0,h=N.isExtglob=!0,O=!0,x===ei&&f===l&&(I=!0),o===!0){for(;L()!==!0&&(x=T());){if(x===Wn){w=N.backslashes=!0,x=T();continue}if(x===rf){g=N.isGlob=!0,O=!0;break}}continue}break}if(x===Zs){if(M===Zs&&(E=N.isGlobstar=!0),g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===nf){if(g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===kR){for(;L()!==!0&&(_e=T());){if(_e===Wn){w=N.backslashes=!0,T();continue}if(_e===IR){m=N.isBracket=!0,g=N.isGlob=!0,O=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&x===ei&&f===l){P=N.negated=!0,l++;continue}if(n.noparen!==!0&&x===ni){if(g=N.isGlob=!0,o===!0){for(;L()!==!0&&(x=T());){if(x===ni){w=N.backslashes=!0,x=T();continue}if(x===rf){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,be="",S="";l>0&&(be=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&&of(B.charCodeAt(B.length-1))&&(B=B.slice(0,-1)),n.unescape===!0&&(S&&(S=tf.removeBackslashes(S)),B&&w===!0&&(B=tf.removeBackslashes(B)));let y={prefix:be,input:e,start:l,base:B,glob:S,isBrace:d,isBracket:m,isGlob:g,isExtglob:h,isGlobstar:E,negated:P,negatedExtglob:I};if(n.tokens===!0&&(y.maxDepth=0,of(x)||a.push(N),y.tokens=a),n.parts===!0||n.tokens===!0){let _e;for(let K=0;K<i.length;K++){let Ue=_e?_e+1:l,He=i[K],ke=e.slice(Ue,He);n.tokens&&(K===0&&l!==0?(a[K].isPrefix=!0,a[K].value=be):a[K].value=ke,sf(a[K]),y.maxDepth+=a[K].depth),(K!==0||ke!=="")&&c.push(ke),_e=He}if(_e&&_e+1<e.length){let K=e.slice(_e+1);c.push(K),n.tokens&&(a[a.length-1].value=K,sf(a[a.length-1]),y.maxDepth+=a[a.length-1].depth)}y.slashes=i,y.parts=c}return y},"scan");cf.exports=TR});var mf=X((VL,pf)=>{"use strict";var Jn=Vn(),ge=zn(),{MAX_LENGTH:ao,POSIX_REGEX_SOURCE:wR,REGEX_NON_SPECIAL_CHARS:PR,REGEX_SPECIAL_CHARS_BACKREF:NR,REPLACEMENTS:lf}=Jn,MR=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=>ge.escapeRegex(o)).join("..")}return n},"expandRange"),an=s((e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,"syntaxError"),ff=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"),vR=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"),df=s(e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(vR(t))return t.replace(/\\(.)/g,"$1")},"normalizeSimpleBranch"),LR=s(e=>{let t=e.map(df).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"),ri=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"),UR=s(e=>{let t=0,n=[];for(;t<e.length;){let o=ri(e.slice(t),!1);if(!o||o.type!=="*")return;let i=ff(o.body).map(c=>c.trim());if(i.length!==1)return;let a=df(i[0]);if(!a||a.length!==1)return;n.push(a),t+=o.end+1}return n.length<1?void 0:`${n.length===1?ge.escapeRegex(n[0]):`[${n.map(o=>ge.escapeRegex(o)).join("")}]`}*`},"getStarExtglobSequenceOutput"),HR=s(e=>{let t=0,n=e.trim(),r=ri(n);for(;r;)t++,n=r.body.trim(),r=ri(n);return t},"repeatedExtglobRecursion"),DR=s((e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:Jn.DEFAULT_MAX_EXTGLOB_RECURSION,r=ff(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||LR(r)))return{risky:!0};for(let o of r){let i=UR(o);if(i)return{risky:!0,safeOutput:i};if(HR(o)>n)return{risky:!0}}return{risky:!1}},"analyzeRepeatedExtglob"),oi=s((e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=lf[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(ao,n.maxLength):ao,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=ge.isWindows(t),f=Jn.globChars(u),l=Jn.extglobChars(f),{DOT_LITERAL:p,PLUS_LITERAL:d,SLASH_LITERAL:m,ONE_CHAR:g,DOTS_SLASH:h,NO_DOT:E,NO_DOT_SLASH:k,NO_DOTS_SLASH:w,QMARK:P,QMARK_NO_DOT:I,STAR:O,START_ANCHOR:U}=f,M=s(b=>`(${c}(?:(?!${U}${b.dot?h:p}).)*?)`,"globstar"),x=n.dot?"":E,N=n.dot?P:I,L=n.bash===!0?M(n):O;n.capture&&(L=`(${L})`),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:a};e=ge.removePrefix(e,_),o=e.length;let T=[],B=[],be=[],S=i,y,_e=s(()=>_.index===o-1,"eos"),K=_.peek=(b=1)=>e[_.index+b],Ue=_.advance=()=>e[++_.index]||"",He=s(()=>e.slice(_.index+1),"remaining"),ke=s((b="",Q=0)=>{_.consumed+=b,_.index+=Q},"consume"),_r=s(b=>{_.output+=b.output!=null?b.output:b.value,ke(b.value)},"append"),gh=s(()=>{let b=1;for(;K()==="!"&&(K(2)!=="("||K(3)==="?");)Ue(),_.start++,b++;return b%2===0?!1:(_.negated=!0,_.start++,!0)},"negate"),hr=s(b=>{_[b]++,be.push(b)},"increment"),pt=s(b=>{_[b]--,be.pop()},"decrement"),D=s(b=>{if(S.type==="globstar"){let Q=_.braces>0&&(b.type==="comma"||b.type==="brace"),A=b.extglob===!0||T.length&&(b.type==="pipe"||b.type==="paren");b.type!=="slash"&&b.type!=="paren"&&!Q&&!A&&(_.output=_.output.slice(0,-S.output.length),S.type="star",S.value="*",S.output=L,_.output+=S.output)}if(T.length&&b.type!=="paren"&&(T[T.length-1].inner+=b.value),(b.value||b.output)&&_r(b),S&&S.type==="text"&&b.type==="text"){S.value+=b.value,S.output=(S.output||"")+b.value;return}b.prev=S,a.push(b),S=b},"push"),Sr=s((b,Q)=>{let A={...l[Q],conditions:1,inner:""};A.prev=S,A.parens=_.parens,A.output=_.output,A.startIndex=_.index,A.tokensIndex=a.length;let H=(n.capture?"(":"")+A.open;hr("parens"),D({type:b,value:Q,output:_.output?"":g}),D({type:"paren",extglob:!0,value:Ue(),output:H}),T.push(A)},"extglobOpen"),_h=s(b=>{let Q=e.slice(b.startIndex,_.index+1),A=e.slice(b.startIndex+2,_.index),H=DR(A,n);if((b.type==="plus"||b.type==="star")&&H.risky){let W=H.safeOutput?(b.output?"":g)+(n.capture?`(${H.safeOutput})`:H.safeOutput):void 0,De=a[b.tokensIndex];De.type="text",De.value=Q,De.output=W||ge.escapeRegex(Q);for(let Fe=b.tokensIndex+1;Fe<a.length;Fe++)a[Fe].value="",a[Fe].output="",delete a[Fe].suffix;_.output=b.output+De.output,_.backtrack=!0,D({type:"paren",extglob:!0,value:y,output:""}),pt("parens");return}let Y=b.close+(n.capture?")":""),le;if(b.type==="negate"){let W=L;if(b.inner&&b.inner.length>1&&b.inner.includes("/")&&(W=M(n)),(W!==L||_e()||/^\)+$/.test(He()))&&(Y=b.close=`)$))${W}`),b.inner.includes("*")&&(le=He())&&/^\.[^\\/.]+$/.test(le)){let De=oi(le,{...t,fastpaths:!1}).output;Y=b.close=`)${De})${W})`}b.prev.type==="bos"&&(_.negatedExtglob=!0)}D({type:"paren",extglob:!0,value:y,output:Y}),pt("parens")},"extglobClose");if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let b=!1,Q=e.replace(NR,(A,H,Y,le,W,De)=>le==="\\"?(b=!0,A):le==="?"?H?H+le+(W?P.repeat(W.length):""):De===0?N+(W?P.repeat(W.length):""):P.repeat(Y.length):le==="."?p.repeat(Y.length):le==="*"?H?H+le+(W?L:""):L:H?A:`\\${A}`);return b===!0&&(n.unescape===!0?Q=Q.replace(/\\/g,""):Q=Q.replace(/\\+/g,A=>A.length%2===0?"\\\\":A?"\\":"")),Q===e&&n.contains===!0?(_.output=e,_):(_.output=ge.wrapOutput(Q,_,t),_)}for(;!_e();){if(y=Ue(),y==="\0")continue;if(y==="\\"){let A=K();if(A==="/"&&n.bash!==!0||A==="."||A===";")continue;if(!A){y+="\\",D({type:"text",value:y});continue}let H=/^\\+/.exec(He()),Y=0;if(H&&H[0].length>2&&(Y=H[0].length,_.index+=Y,Y%2!==0&&(y+="\\")),n.unescape===!0?y=Ue():y+=Ue(),_.brackets===0){D({type:"text",value:y});continue}}if(_.brackets>0&&(y!=="]"||S.value==="["||S.value==="[^")){if(n.posix!==!1&&y===":"){let A=S.value.slice(1);if(A.includes("[")&&(S.posix=!0,A.includes(":"))){let H=S.value.lastIndexOf("["),Y=S.value.slice(0,H),le=S.value.slice(H+2),W=wR[le];if(W){S.value=Y+W,_.backtrack=!0,Ue(),!i.output&&a.indexOf(S)===1&&(i.output=g);continue}}}(y==="["&&K()!==":"||y==="-"&&K()==="]")&&(y=`\\${y}`),y==="]"&&(S.value==="["||S.value==="[^")&&(y=`\\${y}`),n.posix===!0&&y==="!"&&S.value==="["&&(y="^"),S.value+=y,_r({value:y});continue}if(_.quotes===1&&y!=='"'){y=ge.escapeRegex(y),S.value+=y,_r({value:y});continue}if(y==='"'){_.quotes=_.quotes===1?0:1,n.keepQuotes===!0&&D({type:"text",value:y});continue}if(y==="("){hr("parens"),D({type:"paren",value:y});continue}if(y===")"){if(_.parens===0&&n.strictBrackets===!0)throw new SyntaxError(an("opening","("));let A=T[T.length-1];if(A&&_.parens===A.parens+1){_h(T.pop());continue}D({type:"paren",value:y,output:_.parens?")":"\\)"}),pt("parens");continue}if(y==="["){if(n.nobracket===!0||!He().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(an("closing","]"));y=`\\${y}`}else hr("brackets");D({type:"bracket",value:y});continue}if(y==="]"){if(n.nobracket===!0||S&&S.type==="bracket"&&S.value.length===1){D({type:"text",value:y,output:`\\${y}`});continue}if(_.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(an("opening","["));D({type:"text",value:y,output:`\\${y}`});continue}pt("brackets");let A=S.value.slice(1);if(S.posix!==!0&&A[0]==="^"&&!A.includes("/")&&(y=`/${y}`),S.value+=y,_r({value:y}),n.literalBrackets===!1||ge.hasRegexChars(A))continue;let H=ge.escapeRegex(S.value);if(_.output=_.output.slice(0,-S.value.length),n.literalBrackets===!0){_.output+=H,S.value=H;continue}S.value=`(${c}${H}|${S.value})`,_.output+=S.value;continue}if(y==="{"&&n.nobrace!==!0){hr("braces");let A={type:"brace",value:y,output:"(",outputIndex:_.output.length,tokensIndex:_.tokens.length};B.push(A),D(A);continue}if(y==="}"){let A=B[B.length-1];if(n.nobrace===!0||!A){D({type:"text",value:y,output:y});continue}let H=")";if(A.dots===!0){let Y=a.slice(),le=[];for(let W=Y.length-1;W>=0&&(a.pop(),Y[W].type!=="brace");W--)Y[W].type!=="dots"&&le.unshift(Y[W].value);H=MR(le,n),_.backtrack=!0}if(A.comma!==!0&&A.dots!==!0){let Y=_.output.slice(0,A.outputIndex),le=_.tokens.slice(A.tokensIndex);A.value=A.output="\\{",y=H="\\}",_.output=Y;for(let W of le)_.output+=W.output||W.value}D({type:"brace",value:y,output:H}),pt("braces"),B.pop();continue}if(y==="|"){T.length>0&&T[T.length-1].conditions++,D({type:"text",value:y});continue}if(y===","){let A=y,H=B[B.length-1];H&&be[be.length-1]==="braces"&&(H.comma=!0,A="|"),D({type:"comma",value:y,output:A});continue}if(y==="/"){if(S.type==="dot"&&_.index===_.start+1){_.start=_.index+1,_.consumed="",_.output="",a.pop(),S=i;continue}D({type:"slash",value:y,output:m});continue}if(y==="."){if(_.braces>0&&S.type==="dot"){S.value==="."&&(S.output=p);let A=B[B.length-1];S.type="dots",S.output+=y,S.value+=y,A.dots=!0;continue}if(_.braces+_.parens===0&&S.type!=="bos"&&S.type!=="slash"){D({type:"text",value:y,output:p});continue}D({type:"dot",value:y,output:p});continue}if(y==="?"){if(!(S&&S.value==="(")&&n.noextglob!==!0&&K()==="("&&K(2)!=="?"){Sr("qmark",y);continue}if(S&&S.type==="paren"){let H=K(),Y=y;if(H==="<"&&!ge.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(S.value==="("&&!/[!=<:]/.test(H)||H==="<"&&!/<([!=]|\w+>)/.test(He()))&&(Y=`\\${y}`),D({type:"text",value:y,output:Y});continue}if(n.dot!==!0&&(S.type==="slash"||S.type==="bos")){D({type:"qmark",value:y,output:I});continue}D({type:"qmark",value:y,output:P});continue}if(y==="!"){if(n.noextglob!==!0&&K()==="("&&(K(2)!=="?"||!/[!=<:]/.test(K(3)))){Sr("negate",y);continue}if(n.nonegate!==!0&&_.index===0){gh();continue}}if(y==="+"){if(n.noextglob!==!0&&K()==="("&&K(2)!=="?"){Sr("plus",y);continue}if(S&&S.value==="("||n.regex===!1){D({type:"plus",value:y,output:d});continue}if(S&&(S.type==="bracket"||S.type==="paren"||S.type==="brace")||_.parens>0){D({type:"plus",value:y});continue}D({type:"plus",value:d});continue}if(y==="@"){if(n.noextglob!==!0&&K()==="("&&K(2)!=="?"){D({type:"at",extglob:!0,value:y,output:""});continue}D({type:"text",value:y});continue}if(y!=="*"){(y==="$"||y==="^")&&(y=`\\${y}`);let A=PR.exec(He());A&&(y+=A[0],_.index+=A[0].length),D({type:"text",value:y});continue}if(S&&(S.type==="globstar"||S.star===!0)){S.type="star",S.star=!0,S.value+=y,S.output=L,_.backtrack=!0,_.globstar=!0,ke(y);continue}let b=He();if(n.noextglob!==!0&&/^\([^?]/.test(b)){Sr("star",y);continue}if(S.type==="star"){if(n.noglobstar===!0){ke(y);continue}let A=S.prev,H=A.prev,Y=A.type==="slash"||A.type==="bos",le=H&&(H.type==="star"||H.type==="globstar");if(n.bash===!0&&(!Y||b[0]&&b[0]!=="/")){D({type:"star",value:y,output:""});continue}let W=_.braces>0&&(A.type==="comma"||A.type==="brace"),De=T.length&&(A.type==="pipe"||A.type==="paren");if(!Y&&A.type!=="paren"&&!W&&!De){D({type:"star",value:y,output:""});continue}for(;b.slice(0,3)==="/**";){let Fe=e[_.index+4];if(Fe&&Fe!=="/")break;b=b.slice(3),ke("/**",3)}if(A.type==="bos"&&_e()){S.type="globstar",S.value+=y,S.output=M(n),_.output=S.output,_.globstar=!0,ke(y);continue}if(A.type==="slash"&&A.prev.type!=="bos"&&!le&&_e()){_.output=_.output.slice(0,-(A.output+S.output).length),A.output=`(?:${A.output}`,S.type="globstar",S.output=M(n)+(n.strictSlashes?")":"|$)"),S.value+=y,_.globstar=!0,_.output+=A.output+S.output,ke(y);continue}if(A.type==="slash"&&A.prev.type!=="bos"&&b[0]==="/"){let Fe=b[1]!==void 0?"|$":"";_.output=_.output.slice(0,-(A.output+S.output).length),A.output=`(?:${A.output}`,S.type="globstar",S.output=`${M(n)}${m}|${m}${Fe})`,S.value+=y,_.output+=A.output+S.output,_.globstar=!0,ke(y+Ue()),D({type:"slash",value:"/",output:""});continue}if(A.type==="bos"&&b[0]==="/"){S.type="globstar",S.value+=y,S.output=`(?:^|${m}|${M(n)}${m})`,_.output=S.output,_.globstar=!0,ke(y+Ue()),D({type:"slash",value:"/",output:""});continue}_.output=_.output.slice(0,-S.output.length),S.type="globstar",S.output=M(n),S.value+=y,_.output+=S.output,_.globstar=!0,ke(y);continue}let Q={type:"star",value:y,output:L};if(n.bash===!0){Q.output=".*?",(S.type==="bos"||S.type==="slash")&&(Q.output=x+Q.output),D(Q);continue}if(S&&(S.type==="bracket"||S.type==="paren")&&n.regex===!0){Q.output=y,D(Q);continue}(_.index===_.start||S.type==="slash"||S.type==="dot")&&(S.type==="dot"?(_.output+=k,S.output+=k):n.dot===!0?(_.output+=w,S.output+=w):(_.output+=x,S.output+=x),K()!=="*"&&(_.output+=g,S.output+=g)),D(Q)}for(;_.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(an("closing","]"));_.output=ge.escapeLast(_.output,"["),pt("brackets")}for(;_.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(an("closing",")"));_.output=ge.escapeLast(_.output,"("),pt("parens")}for(;_.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(an("closing","}"));_.output=ge.escapeLast(_.output,"{"),pt("braces")}if(n.strictSlashes!==!0&&(S.type==="star"||S.type==="bracket")&&D({type:"maybe_slash",value:"",output:`${m}?`}),_.backtrack===!0){_.output="";for(let b of _.tokens)_.output+=b.output!=null?b.output:b.value,b.suffix&&(_.output+=b.suffix)}return _},"parse");oi.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(ao,n.maxLength):ao,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=lf[e]||e;let i=ge.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}=Jn.globChars(i),h=n.dot?p:l,E=n.dot?d:l,k=n.capture?"":"?:",w={negated:!1,prefix:""},P=n.bash===!0?".*?":m;n.capture&&(P=`(${P})`);let I=s(x=>x.noglobstar===!0?P:`(${k}(?:(?!${g}${x.dot?f:a}).)*?)`,"globstar"),O=s(x=>{switch(x){case"*":return`${h}${u}${P}`;case".*":return`${a}${u}${P}`;case"*.*":return`${h}${P}${a}${u}${P}`;case"*/*":return`${h}${P}${c}${u}${E}${P}`;case"**":return h+I(n);case"**/*":return`(?:${h}${I(n)}${c})?${E}${u}${P}`;case"**/*.*":return`(?:${h}${I(n)}${c})?${E}${P}${a}${u}${P}`;case"**/.*":return`(?:${h}${I(n)}${c})?${a}${u}${P}`;default:{let N=/^(.*?)\.(\w+)$/.exec(x);if(!N)return;let L=O(N[1]);return L?L+a+N[2]:void 0}}},"create"),U=ge.removePrefix(e,w),M=O(U);return M&&n.strictSlashes!==!0&&(M+=`${c}?`),M};pf.exports=oi});var _f=X((WL,gf)=>{"use strict";var FR=mt("path"),$R=uf(),si=mf(),ii=zn(),jR=Vn(),BR=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=BR(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=ii.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}),h={glob:e,state:c,regex:a,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=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?ii.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=ii.isWindows(n))=>(t instanceof RegExp?t:se.makeRe(t,n)).test(FR.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)):si(e,{...t,fastpaths:!1});se.scan=(e,t)=>$R(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=si.fastpaths(e,t)),o.output||(o=si(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=jR;gf.exports=se});var Sf=X((YL,hf)=>{"use strict";hf.exports=_f()});var bf=X((XL,Af)=>{"use strict";var Ef=mt("util"),Rf=Yl(),Ke=Sf(),ai=zn(),yf=s(e=>e===""||e==="./","isEmptyString"),Cf=s(e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},"hasBraces"),Z=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=Ke(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");Z.match=Z;Z.matcher=(e,t)=>Ke(e,t);Z.isMatch=(e,t,n)=>Ke(t,n)(e);Z.any=Z.isMatch;Z.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(Z(e,t,{...n,onResult:i}));for(let c of o)a.has(c)||r.add(c);return[...r]};Z.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=>Z.contains(e,r,n));if(typeof t=="string"){if(yf(e)||yf(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return Z.isMatch(e,t,{...n,contains:!0})};Z.matchKeys=(e,t,n)=>{if(!ai.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=Z(Object.keys(e),t,n),o={};for(let i of r)o[i]=e[i];return o};Z.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=Ke(String(o),n);if(r.some(a=>i(a)))return!0}return!1};Z.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=Ke(String(o),n);if(!r.every(a=>i(a)))return!1}return!0};Z.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Ef.inspect(e)}"`);return[].concat(t).every(r=>Ke(r,n)(e))};Z.capture=(e,t,n)=>{let r=ai.isWindows(n),i=Ke.makeRe(String(e),{...n,capture:!0}).exec(r?ai.toPosixSlashes(t):t);if(i)return i.slice(1).map(a=>a===void 0?"":a)};Z.makeRe=(...e)=>Ke.makeRe(...e);Z.scan=(...e)=>Ke.scan(...e);Z.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of Rf(String(r),t))n.push(Ke.parse(o,t));return n};Z.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!Cf(e)?[e]:Rf(e,t)};Z.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return Z.braces(e,{...t,expand:!0})};Z.hasBraces=Cf;Af.exports=Z});var co=X(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.MCP_MISSING_LAUNCH_SERIALIZED=ie.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;ie.foldMcpName=Hf;ie.buildMcpFamilyCanonicalKey=iC;ie.launchContainsCredentials=cC;ie.serializeMcpLaunchIdentity=Df;ie.hashMcpLaunchIdentity=Yn;ie.projectMcpMissingLaunchIdentity=fC;ie.projectMcpLaunchIdentity=dC;ie.maskMcpLaunchForDisplay=mC;ie.normalizeMcpToolNames=gC;var sC=mt("node:crypto");ie.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";ie.MCP_MISSING_LAUNCH_SERIALIZED=`${ie.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function nt(e){return e.toLocaleLowerCase("en-US")}s(nt,"foldCase");function Hf(e){return nt(e)}s(Hf,"foldMcpName");function iC(e){return`interface:${Hf(e)}`}s(iC,"buildMcpFamilyCanonicalKey");var Uf=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),aC=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function ln(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(ln,"lengthPrefixed");function cC(e){return e.kind==="url"?uC(e.url):e.kind==="command"?e.arguments.some(t=>aC.test(t)):!1}s(cC,"launchContainsCredentials");function uC(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(Uf.has(nt(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=nt(a.split("=",1)[0]??"");return Uf.has(c)})}}s(uC,"urlContainsCredentials");function Df(e){if(e.kind==="url")return[ie.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",ln(nt(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>nt(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[ie.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",ln(nt(e.command)),String(t.length),...t.map(ln)].join("|")}return[ie.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",ln(e.installationRootExternalKey),ln(e.sourcePath),ln(e.nativeKey)].join("|")}s(Df,"serializeMcpLaunchIdentity");function Yn(e){return(0,sC.createHash)("sha256").update(e).digest("hex")}s(Yn,"hashMcpLaunchIdentity");var lC=Yn(ie.MCP_MISSING_LAUNCH_SERIALIZED);function fC(){return{kind:"unknown",arguments:[],serialized:ie.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:lC}}s(fC,"projectMcpMissingLaunchIdentity");function dC(e){let t=Df(e);return e.kind==="url"?{kind:"url",url:nt(e.url),arguments:[],serialized:t,contentHash:Yn(t)}:e.kind==="command"?{kind:"command",command:nt(e.command),arguments:[...e.arguments].map(n=>nt(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(dC,"projectMcpLaunchIdentity");var pC=/^(https?:\/\/)([^/?#]*@)/i;function mC(e){return e.replace(pC,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}s(mC,"maskMcpLaunchForDisplay");function gC(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(gC,"normalizeMcpToolNames")});var lo=X(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.LOCAL_BIN_PACKAGE_VERSION_SOURCE=ye.PACKAGE_FIELD_MAX=void 0;ye.npxExecBin=Ff;ye.isExactNpmVersion=$f;ye.isNodeModulesBinCommand=kC;ye.packageNameFromSpec=uo;ye.pinnedPackageVersionFromSpec=jf;ye.pinnedPackageVersionFromNpx=OC;ye.npxPackageSpecs=Bf;ye.PACKAGE_FIELD_MAX=128;var _C=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,hC=new Set(["-p","--package"]),SC=new Set(["-c","--call"]),yC=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),EC=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),RC=/^--no-/;function CC(e){return EC.has(e)||RC.test(e)}s(CC,"booleanFlag");function Ff(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}s(Ff,"npxExecBin");var AC=/^(?: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<=ye.PACKAGE_FIELD_MAX&&AC.test(e)}s($f,"isExactNpmVersion");ye.LOCAL_BIN_PACKAGE_VERSION_SOURCE="node_modules_local";var bC=/(?:^|\/)node_modules\/\.bin\/[^/]+$/;function kC(e){return bC.test(e.replaceAll("\\","/"))}s(kC,"isNodeModulesBinCommand");function uo(e){if(e.length===0||e.length>ye.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return _C.test(n)?n:null}s(uo,"packageNameFromSpec");function jf(e){let t=uo(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return $f(n)?n:void 0}s(jf,"pinnedPackageVersionFromSpec");function OC(e,t){for(let n of Bf(e,t)){let r=jf(n);if(r!==void 0)return r}}s(OC,"pinnedPackageVersionFromNpx");function Bf(e,t){let n=Ff(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(SC.has(f))return[];if(hC.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||CC(f))){if(yC.has(f)){a+=1;continue}return[]}}return o.length>0?o.every(a=>uo(a)!==null)?o:[]:i===null||uo(i)===null?[]:[i]}s(Bf,"npxPackageSpecs")});var Gf=X(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.McpPackageEcosystem=void 0;rt.resolveMcpPackageIdentity=HC;rt.resolveLocalBinPackageIdentity=DC;var Kf=co(),Ot=lo();rt.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var xC=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,IC=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function TC(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}s(TC,"pythonRunnerBin");var wC=new Set(["--from","--spec"]),PC=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"]),NC=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"]),MC=/^--no-/;function vC(e,t){let n=TC(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||NC.has(f)||MC.test(f))){if(PC.has(f)){a+=1;continue}return null}}return o??i}s(vC,"pythonRunnerSpec");function LC(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)||!IC.test(o)?null:{ecosystem:rt.McpPackageEcosystem.PYPI,packageName:r,version:o}}s(LC,"pypiIdentityFromSpec");function UC(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:rt.McpPackageEcosystem.NPM,packageName:t,version:n}:null}s(UC,"npmIdentityFromSpec");function HC(e){if(e?.kind!=="command"||(0,Kf.launchContainsCredentials)(e))return;for(let n of(0,Ot.npxPackageSpecs)(e.command,e.arguments)){let r=UC(n);if(r!==null)return r}let t=vC(e.command,e.arguments);if(t!==null)return LC(t)??void 0}s(HC,"resolveMcpPackageIdentity");function DC(e,t){if(e?.kind!=="command"||(0,Kf.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:rt.McpPackageEcosystem.NPM,packageName:n,version:r}}s(DC,"resolveLocalBinPackageIdentity")});var qf=X(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.EMPTY_NPM_PUBLISHER=void 0;ot.isNpmRegistryPublisher=$C;ot.displayPublisherName=jC;ot.classifyMcpProvenance=YC;var Jf=co(),Xn=lo();ot.EMPTY_NPM_PUBLISHER="npm:";var Vf="npm:",FC=/^[A-Za-z0-9._-]+$/;function $C(e){return e.startsWith(Vf)&&e!==ot.EMPTY_NPM_PUBLISHER&&FC.test(e.slice(Vf.length))}s($C,"isNpmRegistryPublisher");function jC(e){if(!(e==null||e===""||e===ot.EMPTY_NPM_PUBLISHER))return e}s(jC,"displayPublisherName");function zf(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(zf,"privateIpv4");function BC(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(BC,"ipv4MappedAddress");function pi(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}s(pi,"normalizedHost");function KC(e){let t=pi(e),n=BC(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||zf(t)||n!==void 0&&zf(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}s(KC,"privateHostname");function GC(e){let t=pi(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}s(GC,"publisherHost");function VC(e){let t=pi(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}s(VC,"publicOrigin");function Yf(e){let t={kind:"url",url:e};if((0,Jf.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||KC(n.hostname))return{origin:"UNKNOWN"};let r=GC(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:VC(n)}}catch{return{origin:"UNKNOWN"}}}s(Yf,"classifyUrl");var Xf="mcp-remote";function zC(e,t){if(e===Xf)return t.find(n=>/^https?:\/\//i.test(n))}s(zC,"remoteUrlChild");function WC(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}s(WC,"thirdPartyPackage");function Wf(e,t,n){let r=zC(e,t);return r!==void 0?Yf(r):e===Xf?{origin:"UNKNOWN"}:WC(e,n)}s(Wf,"classifyRegistryPackage");function JC(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(JC,"isRepoRelativeCommand");function YC(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,Jf.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return Yf(t.url);let r=(0,Xn.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,Xn.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let i=Wf(o,t.arguments,e.publisherName),a=typeof e.packageName=="string"?(0,Xn.packageNameFromSpec)(e.packageName):null;return a!==null&&a===o&&i.packageName!==void 0?{...i,packageName:a,packageKey:a}:i}if((0,Xn.isNodeModulesBinCommand)(t.command)){let o=typeof e.packageName=="string"?(0,Xn.packageNameFromSpec)(e.packageName):null;return o===null||o!==e.packageName?{origin:"UNKNOWN"}:Wf(o,t.arguments,e.publisherName)}return JC(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}s(YC,"classifyMcpProvenance")});var Qf=X(fo=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});fo.mcpServerToolSegmentForms=Zf;fo.mcpServerNameMatchesToolSegment=XC;function Zf(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}s(Zf,"mcpServerToolSegmentForms");function XC(e,t){let n=t.toLowerCase();return Zf(e).some(r=>r.toLowerCase()===n)}s(XC,"mcpServerNameMatchesToolSegment")});var ed=X(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.parseFrontmatterField=ve.parseFrontmatterDescription=ve.usableCatalogText=void 0;var qC=/^(?:>|\|)[-+]?$/,ZC=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,QC=s(e=>{let t=e?.trim()??"";if(!(t.length===0||qC.test(t)))return t},"usableCatalogText");ve.usableCatalogText=QC;var eA=s(e=>(0,ve.parseFrontmatterField)(e,"description"),"parseFrontmatterDescription");ve.parseFrontmatterDescription=eA;var tA=s((e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return rA(n[1],t)},"parseFrontmatterField");ve.parseFrontmatterField=tA;var nA=s(e=>e.replace(/^["']|["']$/g,""),"stripYamlQuotes");function rA(e,t){let n=e.split(`
|
|
7
|
-
`),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=
|
|
5
|
+
var tE=Object.create;var Ss=Object.defineProperty;var nE=Object.getOwnPropertyDescriptor;var rE=Object.getOwnPropertyNames;var oE=Object.getPrototypeOf,sE=Object.prototype.hasOwnProperty;var s=(e,t)=>Ss(e,"name",{value:t,configurable:!0}),Ve=(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 iE=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of rE(t))!sE.call(e,o)&&o!==n&&Ss(e,o,{get:()=>t[o],enumerable:!(r=nE(t,o))||r.enumerable});return e};var Te=(e,t,n)=>(n=e!=null?tE(oE(e)):{},iE(t||!e||!e.__esModule?Ss(n,"default",{value:e,enumerable:!0}):n,e));var uo=W(Me=>{"use strict";Me.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Me.find=(e,t)=>e.nodes.find(n=>n.type===t);Me.exceedsLimit=(e,t,n=1,r)=>r===!1||!Me.isInteger(e)||!Me.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Me.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)};Me.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Me.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;Me.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Me.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Me.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 lo=W((nU,Ml)=>{"use strict";var Ll=uo();Ml.exports=(e,t={})=>{let n=s((r,o={})=>{let i=t.escapeInvalid&&Ll.isInvalidBrace(o),a=r.invalid===!0&&t.escapeInvalid===!0,c="";if(r.value)return(i||a)&&Ll.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 Hl=W((oU,Ul)=>{"use strict";Ul.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var zl=W((sU,Vl)=>{"use strict";var Dl=Hl(),Jt=s((e,t,n)=>{if(Dl(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(Dl(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(Jt.cache.hasOwnProperty(u))return Jt.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=Gl(e)||Gl(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=Fl(E,Math.abs(f),d,r),f=d.a=0}return l>=0&&(m=Fl(f,l,d,r)),d.negatives=g,d.positives=m,d.result=aR(g,m,r),r.capture===!0?d.result=`(${d.result})`:r.wrap!==!1&&m.length+g.length>1&&(d.result=`(?:${d.result})`),Jt.cache[u]=d,d.result},"toRegexRange");function aR(e,t,n){let r=ii(e,t,"-",!1,n)||[],o=ii(t,e,"",!1,n)||[],i=ii(e,t,"-?",!0,n)||[];return r.concat(i).concat(o).join("|")}s(aR,"collatePatterns");function cR(e,t){let n=1,r=1,o=jl(e,n),i=new Set([t]);for(;e<=o&&o<=t;)i.add(o),n+=1,o=jl(e,n);for(o=Bl(t+1,r)-1;e<o&&o<=t;)i.add(o),r+=1,o=Bl(t+1,r)-1;return i=[...i],i.sort(fR),i}s(cR,"splitToRanges");function uR(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=lR(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+=dR(u,f,n):a++}return a&&(i+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:i,count:[a],digits:o}}s(uR,"rangeToPattern");function Fl(e,t,n,r){let o=cR(e,t),i=[],a=e,c;for(let u=0;u<o.length;u++){let f=o[u],l=uR(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+Kl(c.count),a=f+1;continue}n.isPadded&&(p=pR(f,n,r)),l.string=p+l.pattern+Kl(l.count),i.push(l),a=f+1,c=l}return i}s(Fl,"splitToPatterns");function ii(e,t,n,r,o){let i=[];for(let a of e){let{string:c}=a;!r&&!$l(t,"string",c)&&i.push(n+c),r&&$l(t,"string",c)&&i.push(n+c)}return i}s(ii,"filterPatterns");function lR(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}s(lR,"zip");function fR(e,t){return e>t?1:t>e?-1:0}s(fR,"compare");function $l(e,t,n){return e.some(r=>r[t]===n)}s($l,"contains");function jl(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}s(jl,"countNines");function Bl(e,t){return e-e%Math.pow(10,t)}s(Bl,"countZeros");function Kl(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}s(Kl,"toQuantifier");function dR(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}s(dR,"toCharacterClass");function Gl(e){return/^-?(0+)\d/.test(e)}s(Gl,"hasPadding");function pR(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(pR,"padZeros");Jt.cache={};Jt.clearCache=()=>Jt.cache={};Vl.exports=Jt});var ui=W((aU,Ql)=>{"use strict";var mR=Ve("util"),Jl=zl(),Wl=s(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"isObject"),gR=s(e=>t=>e===!0?Number(t):String(t),"transform"),ai=s(e=>typeof e=="number"||typeof e=="string"&&e!=="","isValidValue"),Zn=s(e=>Number.isInteger(+e),"isNumber"),ci=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"),_R=s((e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,"stringify"),hR=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"),po=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"),ER=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=>po(String(c),n)).join("|")),e.negatives.length&&(i=`-(${r}${e.negatives.map(c=>po(String(c),n)).join("|")})`),o&&i?a=`${o}|${i}`:a=o||i,t.wrap?`(${r}${a})`:a},"toSequence"),Yl=s((e,t,n,r)=>{if(n)return Jl(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let i=String.fromCharCode(t);return`[${o}-${i}]`},"toRange"),Xl=s((e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return Jl(e,t,n)},"toRegex"),ql=s((...e)=>new RangeError("Invalid range arguments: "+mR.inspect(...e)),"rangeError"),Zl=s((e,t,n)=>{if(n.strictRanges===!0)throw ql([e,t]);return[]},"invalidRange"),SR=s((e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},"invalidStep"),yR=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 ql([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=ci(c)||ci(u)||ci(f),p=l?Math.max(c.length,u.length,f.length):0,d=l===!1&&_R(e,t,r)===!1,m=r.transform||gR(d);if(r.toRegex&&n===1)return Yl(po(e,p),po(t,p),!0,r);let g={negatives:[],positives:[]},E=s(P=>g[P<0?"negatives":"positives"].push(Math.abs(P)),"push"),S=[],A=0;for(;a?o>=i:o<=i;)r.toRegex===!0&&n>1?E(o):S.push(hR(m(o,A),p,d)),o=a?o-n:o+n,A++;return r.toRegex===!0?n>1?ER(g,r,p):Xl(S,null,{wrap:!1,...r}):S},"fillNumbers"),RR=s((e,t,n=1,r={})=>{if(!Zn(e)&&e.length>1||!Zn(t)&&t.length>1)return Zl(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 Yl(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?Xl(l,null,{wrap:!1,options:r}):l},"fillLetters"),fo=s((e,t,n,r={})=>{if(t==null&&ai(e))return[e];if(!ai(e)||!ai(t))return Zl(e,t,r);if(typeof n=="function")return fo(e,t,1,{transform:n});if(Wl(n))return fo(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,Zn(n)?Zn(e)&&Zn(t)?yR(e,t,n,o):RR(e,t,Math.max(Math.abs(n),1),o):n!=null&&!Wl(n)?SR(n,o):fo(e,t,1,n)},"fill");Ql.exports=fo});var nf=W((uU,tf)=>{"use strict";var CR=ui(),ef=uo(),AR=s((e,t={})=>{let n=s((r,o={})=>{let i=ef.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=ef.reduce(r.nodes),p=CR(...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");tf.exports=AR});var sf=W((fU,of)=>{"use strict";var bR=ui(),rf=lo(),pn=uo(),Yt=s((e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?pn.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let i of o)r.push(Yt(i,t,n));else for(let i of t)n===!0&&typeof i=="string"&&(i=`{${i}}`),r.push(Array.isArray(i)?Yt(o,i,n):o+i);return pn.flatten(r)},"append"),OR=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(Yt(c.pop(),rf(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){c.push(Yt(c.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let p=pn.reduce(o.nodes);if(pn.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=bR(...p,t);d.length===0&&(d=rf(o,t)),c.push(Yt(c.pop(),d)),o.nodes=[];return}let u=pn.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(Yt(c.pop(),f,u));continue}if(d.value&&d.type!=="open"){f.push(Yt(f.pop(),d.value));continue}d.nodes&&r(d,o)}return f},"walk");return pn.flatten(r(e))},"expand");of.exports=OR});var cf=W((pU,af)=>{"use strict";af.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:`
|
|
6
|
+
`,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 pf=W((mU,df)=>{"use strict";var kR=lo(),{MAX_LENGTH:uf,CHAR_BACKSLASH:li,CHAR_BACKTICK:IR,CHAR_COMMA:TR,CHAR_DOT:xR,CHAR_LEFT_PARENTHESES:PR,CHAR_RIGHT_PARENTHESES:wR,CHAR_LEFT_CURLY_BRACE:NR,CHAR_RIGHT_CURLY_BRACE:vR,CHAR_LEFT_SQUARE_BRACKET:lf,CHAR_RIGHT_SQUARE_BRACKET:ff,CHAR_DOUBLE_QUOTE:LR,CHAR_SINGLE_QUOTE:MR,CHAR_NO_BREAK_SPACE:UR,CHAR_ZERO_WIDTH_NOBREAK_SPACE:HR}=cf(),DR=s((e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(uf,n.maxLength):uf;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===HR||d===UR)){if(d===li){g({type:"text",value:(t.keepEscaping?d:"")+m()});continue}if(d===ff){g({type:"text",value:"\\"+d});continue}if(d===lf){u++;let E;for(;l<f&&(E=m());){if(d+=E,E===lf){u++;continue}if(E===li){d+=m();continue}if(E===ff&&(u--,u===0))break}g({type:"text",value:d});continue}if(d===PR){a=g({type:"paren",nodes:[]}),i.push(a),g({type:"text",value:d});continue}if(d===wR){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===LR||d===MR||d===IR){let E=d,S;for(t.keepQuotes!==!0&&(d="");l<f&&(S=m());){if(S===li){d+=S+m();continue}if(S===E){t.keepQuotes===!0&&(d+=S);break}d+=S}g({type:"text",value:d});continue}if(d===NR){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===vR){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===TR&&p>0){if(a.ranges>0){a.ranges=0;let E=a.nodes.shift();a.nodes=[E,{type:"text",value:kR(a)}]}g({type:"comma",value:d}),a.commas++;continue}if(d===xR&&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(A=>{A.nodes||(A.type==="open"&&(A.isOpen=!0),A.type==="close"&&(A.isClose=!0),A.nodes||(A.type="text"),A.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");df.exports=DR});var _f=W((_U,gf)=>{"use strict";var mf=lo(),FR=nf(),$R=sf(),jR=pf(),xe=s((e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=xe.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(xe.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n},"braces");xe.parse=(e,t={})=>jR(e,t);xe.stringify=(e,t={})=>mf(typeof e=="string"?xe.parse(e,t):e,t);xe.compile=(e,t={})=>(typeof e=="string"&&(e=xe.parse(e,t)),FR(e,t));xe.expand=(e,t={})=>{typeof e=="string"&&(e=xe.parse(e,t));let n=$R(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};xe.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?xe.compile(e,t):xe.expand(e,t);gf.exports=xe});var Qn=W((EU,Rf)=>{"use strict";var BR=Ve("path"),We="\\\\/",hf=`[^${We}]`,KR=0,st="\\.",GR="\\+",VR="\\?",mo="\\/",zR="(?=.)",Ef="[^/]",fi=`(?:${mo}|$)`,Sf=`(?:^|${mo})`,di=`${st}{1,2}${fi}`,WR=`(?!${st})`,JR=`(?!${Sf}${di})`,YR=`(?!${st}{0,1}${fi})`,XR=`(?!${di})`,qR=`[^.${mo}]`,ZR=`${Ef}*?`,yf={DOT_LITERAL:st,PLUS_LITERAL:GR,QMARK_LITERAL:VR,SLASH_LITERAL:mo,ONE_CHAR:zR,QMARK:Ef,END_ANCHOR:fi,DOTS_SLASH:di,NO_DOT:WR,NO_DOTS:JR,NO_DOT_SLASH:YR,NO_DOTS_SLASH:XR,QMARK_NO_DOT:qR,STAR:ZR,START_ANCHOR:Sf},QR={...yf,SLASH_LITERAL:`[${We}]`,QMARK:hf,STAR:`${hf}*?`,DOTS_SLASH:`${st}{1,2}(?:[${We}]|$)`,NO_DOT:`(?!${st})`,NO_DOTS:`(?!(?:^|[${We}])${st}{1,2}(?:[${We}]|$))`,NO_DOT_SLASH:`(?!${st}{0,1}(?:[${We}]|$))`,NO_DOTS_SLASH:`(?!${st}{1,2}(?:[${We}]|$))`,QMARK_NO_DOT:`[^.${We}]`,START_ANCHOR:`(?:^|[${We}])`,END_ANCHOR:`(?:[${We}]|$)`},eC={__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"};Rf.exports={DEFAULT_MAX_EXTGLOB_RECURSION:KR,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:eC,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:BR.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?QR:yf}}});var er=W(Ae=>{"use strict";var tC=Ve("path"),nC=process.platform==="win32",{REGEX_BACKSLASH:rC,REGEX_REMOVE_BACKSLASH:oC,REGEX_SPECIAL_CHARS:sC,REGEX_SPECIAL_CHARS_GLOBAL:iC}=Qn();Ae.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);Ae.hasRegexChars=e=>sC.test(e);Ae.isRegexChar=e=>e.length===1&&Ae.hasRegexChars(e);Ae.escapeRegex=e=>e.replace(iC,"\\$1");Ae.toPosixSlashes=e=>e.replace(rC,"/");Ae.removeBackslashes=e=>e.replace(oC,t=>t==="\\"?"":t);Ae.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};Ae.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:nC===!0||tC.sep==="\\";Ae.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?Ae.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};Ae.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};Ae.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",i=`${r}(?:${e})${o}`;return t.negated===!0&&(i=`(?:^(?!${i}).*$)`),i}});var xf=W((yU,Tf)=>{"use strict";var Cf=er(),{CHAR_ASTERISK:pi,CHAR_AT:aC,CHAR_BACKWARD_SLASH:tr,CHAR_COMMA:cC,CHAR_DOT:mi,CHAR_EXCLAMATION_MARK:gi,CHAR_FORWARD_SLASH:If,CHAR_LEFT_CURLY_BRACE:_i,CHAR_LEFT_PARENTHESES:hi,CHAR_LEFT_SQUARE_BRACKET:uC,CHAR_PLUS:lC,CHAR_QUESTION_MARK:Af,CHAR_RIGHT_CURLY_BRACE:fC,CHAR_RIGHT_PARENTHESES:bf,CHAR_RIGHT_SQUARE_BRACKET:dC}=Qn(),Of=s(e=>e===If||e===tr,"isPathSeparator"),kf=s(e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},"depth"),pC=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,A=!1,P=!1,w=!1,T=!1,k=!1,U=0,v,I,N={value:"",depth:0,isGlob:!1},M=s(()=>f>=r,"eos"),h=s(()=>u.charCodeAt(f+1),"peek"),x=s(()=>(v=I,u.charCodeAt(++f)),"advance");for(;f<r;){I=x();let Ee;if(I===tr){P=N.backslashes=!0,I=x(),I===_i&&(A=!0);continue}if(A===!0||I===_i){for(U++;M()!==!0&&(I=x());){if(I===tr){P=N.backslashes=!0,x();continue}if(I===_i){U++;continue}if(A!==!0&&I===mi&&(I=x())===mi){if(d=N.isBrace=!0,g=N.isGlob=!0,k=!0,o===!0)continue;break}if(A!==!0&&I===cC){if(d=N.isBrace=!0,g=N.isGlob=!0,k=!0,o===!0)continue;break}if(I===fC&&(U--,U===0)){A=!1,d=N.isBrace=!0,k=!0;break}}if(o===!0)continue;break}if(I===If){if(i.push(f),a.push(N),N={value:"",depth:0,isGlob:!1},k===!0)continue;if(v===mi&&f===l+1){l+=2;continue}p=f+1;continue}if(n.noext!==!0&&(I===lC||I===aC||I===pi||I===Af||I===gi)===!0&&h()===hi){if(g=N.isGlob=!0,E=N.isExtglob=!0,k=!0,I===gi&&f===l&&(T=!0),o===!0){for(;M()!==!0&&(I=x());){if(I===tr){P=N.backslashes=!0,I=x();continue}if(I===bf){g=N.isGlob=!0,k=!0;break}}continue}break}if(I===pi){if(v===pi&&(S=N.isGlobstar=!0),g=N.isGlob=!0,k=!0,o===!0)continue;break}if(I===Af){if(g=N.isGlob=!0,k=!0,o===!0)continue;break}if(I===uC){for(;M()!==!0&&(Ee=x());){if(Ee===tr){P=N.backslashes=!0,x();continue}if(Ee===dC){m=N.isBracket=!0,g=N.isGlob=!0,k=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&I===gi&&f===l){w=N.negated=!0,l++;continue}if(n.noparen!==!0&&I===hi){if(g=N.isGlob=!0,o===!0){for(;M()!==!0&&(I=x());){if(I===hi){P=N.backslashes=!0,I=x();continue}if(I===bf){k=!0;break}}continue}break}if(g===!0){if(k=!0,o===!0)continue;break}}n.noext===!0&&(E=!1,g=!1);let G=u,ke="",y="";l>0&&(ke=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&&Of(G.charCodeAt(G.length-1))&&(G=G.slice(0,-1)),n.unescape===!0&&(y&&(y=Cf.removeBackslashes(y)),G&&P===!0&&(G=Cf.removeBackslashes(G)));let R={prefix:ke,input:e,start:l,base:G,glob:y,isBrace:d,isBracket:m,isGlob:g,isExtglob:E,isGlobstar:S,negated:w,negatedExtglob:T};if(n.tokens===!0&&(R.maxDepth=0,Of(I)||a.push(N),R.tokens=a),n.parts===!0||n.tokens===!0){let Ee;for(let V=0;V<i.length;V++){let je=Ee?Ee+1:l,Be=i[V],Ie=e.slice(je,Be);n.tokens&&(V===0&&l!==0?(a[V].isPrefix=!0,a[V].value=ke):a[V].value=Ie,kf(a[V]),R.maxDepth+=a[V].depth),(V!==0||Ie!=="")&&c.push(Ie),Ee=Be}if(Ee&&Ee+1<e.length){let V=e.slice(Ee+1);c.push(V),n.tokens&&(a[a.length-1].value=V,kf(a[a.length-1]),R.maxDepth+=a[a.length-1].depth)}R.slashes=i,R.parts=c}return R},"scan");Tf.exports=pC});var Lf=W((CU,vf)=>{"use strict";var nr=Qn(),he=er(),{MAX_LENGTH:go,POSIX_REGEX_SOURCE:mC,REGEX_NON_SPECIAL_CHARS:gC,REGEX_SPECIAL_CHARS_BACKREF:_C,REPLACEMENTS:Pf}=nr,hC=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=>he.escapeRegex(o)).join("..")}return n},"expandRange"),mn=s((e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,"syntaxError"),wf=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"),EC=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"),Nf=s(e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(EC(t))return t.replace(/\\(.)/g,"$1")},"normalizeSimpleBranch"),SC=s(e=>{let t=e.map(Nf).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"),Ei=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"),yC=s(e=>{let t=0,n=[];for(;t<e.length;){let o=Ei(e.slice(t),!1);if(!o||o.type!=="*")return;let i=wf(o.body).map(c=>c.trim());if(i.length!==1)return;let a=Nf(i[0]);if(!a||a.length!==1)return;n.push(a),t+=o.end+1}return n.length<1?void 0:`${n.length===1?he.escapeRegex(n[0]):`[${n.map(o=>he.escapeRegex(o)).join("")}]`}*`},"getStarExtglobSequenceOutput"),RC=s(e=>{let t=0,n=e.trim(),r=Ei(n);for(;r;)t++,n=r.body.trim(),r=Ei(n);return t},"repeatedExtglobRecursion"),CC=s((e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:nr.DEFAULT_MAX_EXTGLOB_RECURSION,r=wf(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||SC(r)))return{risky:!0};for(let o of r){let i=yC(o);if(i)return{risky:!0,safeOutput:i};if(RC(o)>n)return{risky:!0}}return{risky:!1}},"analyzeRepeatedExtglob"),Si=s((e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=Pf[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(go,n.maxLength):go,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=he.isWindows(t),f=nr.globChars(u),l=nr.extglobChars(f),{DOT_LITERAL:p,PLUS_LITERAL:d,SLASH_LITERAL:m,ONE_CHAR:g,DOTS_SLASH:E,NO_DOT:S,NO_DOT_SLASH:A,NO_DOTS_SLASH:P,QMARK:w,QMARK_NO_DOT:T,STAR:k,START_ANCHOR:U}=f,v=s(O=>`(${c}(?:(?!${U}${O.dot?E:p}).)*?)`,"globstar"),I=n.dot?"":S,N=n.dot?w:T,M=n.bash===!0?v(n):k;n.capture&&(M=`(${M})`),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=he.removePrefix(e,h),o=e.length;let x=[],G=[],ke=[],y=i,R,Ee=s(()=>h.index===o-1,"eos"),V=h.peek=(O=1)=>e[h.index+O],je=h.advance=()=>e[++h.index]||"",Be=s(()=>e.slice(h.index+1),"remaining"),Ie=s((O="",te=0)=>{h.consumed+=O,h.index+=te},"consume"),Or=s(O=>{h.output+=O.output!=null?O.output:O.value,Ie(O.value)},"append"),Qh=s(()=>{let O=1;for(;V()==="!"&&(V(2)!=="("||V(3)==="?");)je(),h.start++,O++;return O%2===0?!1:(h.negated=!0,h.start++,!0)},"negate"),kr=s(O=>{h[O]++,ke.push(O)},"increment"),St=s(O=>{h[O]--,ke.pop()},"decrement"),$=s(O=>{if(y.type==="globstar"){let te=h.braces>0&&(O.type==="comma"||O.type==="brace"),b=O.extglob===!0||x.length&&(O.type==="pipe"||O.type==="paren");O.type!=="slash"&&O.type!=="paren"&&!te&&!b&&(h.output=h.output.slice(0,-y.output.length),y.type="star",y.value="*",y.output=M,h.output+=y.output)}if(x.length&&O.type!=="paren"&&(x[x.length-1].inner+=O.value),(O.value||O.output)&&Or(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"),Ir=s((O,te)=>{let b={...l[te],conditions:1,inner:""};b.prev=y,b.parens=h.parens,b.output=h.output,b.startIndex=h.index,b.tokensIndex=a.length;let H=(n.capture?"(":"")+b.open;kr("parens"),$({type:O,value:te,output:h.output?"":g}),$({type:"paren",extglob:!0,value:je(),output:H}),x.push(b)},"extglobOpen"),eE=s(O=>{let te=e.slice(O.startIndex,h.index+1),b=e.slice(O.startIndex+2,h.index),H=CC(b,n);if((O.type==="plus"||O.type==="star")&&H.risky){let X=H.safeOutput?(O.output?"":g)+(n.capture?`(${H.safeOutput})`:H.safeOutput):void 0,Ke=a[O.tokensIndex];Ke.type="text",Ke.value=te,Ke.output=X||he.escapeRegex(te);for(let Ge=O.tokensIndex+1;Ge<a.length;Ge++)a[Ge].value="",a[Ge].output="",delete a[Ge].suffix;h.output=O.output+Ke.output,h.backtrack=!0,$({type:"paren",extglob:!0,value:R,output:""}),St("parens");return}let Q=O.close+(n.capture?")":""),de;if(O.type==="negate"){let X=M;if(O.inner&&O.inner.length>1&&O.inner.includes("/")&&(X=v(n)),(X!==M||Ee()||/^\)+$/.test(Be()))&&(Q=O.close=`)$))${X}`),O.inner.includes("*")&&(de=Be())&&/^\.[^\\/.]+$/.test(de)){let Ke=Si(de,{...t,fastpaths:!1}).output;Q=O.close=`)${Ke})${X})`}O.prev.type==="bos"&&(h.negatedExtglob=!0)}$({type:"paren",extglob:!0,value:R,output:Q}),St("parens")},"extglobClose");if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let O=!1,te=e.replace(_C,(b,H,Q,de,X,Ke)=>de==="\\"?(O=!0,b):de==="?"?H?H+de+(X?w.repeat(X.length):""):Ke===0?N+(X?w.repeat(X.length):""):w.repeat(Q.length):de==="."?p.repeat(Q.length):de==="*"?H?H+de+(X?M:""):M:H?b:`\\${b}`);return O===!0&&(n.unescape===!0?te=te.replace(/\\/g,""):te=te.replace(/\\+/g,b=>b.length%2===0?"\\\\":b?"\\":"")),te===e&&n.contains===!0?(h.output=e,h):(h.output=he.wrapOutput(te,h,t),h)}for(;!Ee();){if(R=je(),R==="\0")continue;if(R==="\\"){let b=V();if(b==="/"&&n.bash!==!0||b==="."||b===";")continue;if(!b){R+="\\",$({type:"text",value:R});continue}let H=/^\\+/.exec(Be()),Q=0;if(H&&H[0].length>2&&(Q=H[0].length,h.index+=Q,Q%2!==0&&(R+="\\")),n.unescape===!0?R=je():R+=je(),h.brackets===0){$({type:"text",value:R});continue}}if(h.brackets>0&&(R!=="]"||y.value==="["||y.value==="[^")){if(n.posix!==!1&&R===":"){let b=y.value.slice(1);if(b.includes("[")&&(y.posix=!0,b.includes(":"))){let H=y.value.lastIndexOf("["),Q=y.value.slice(0,H),de=y.value.slice(H+2),X=mC[de];if(X){y.value=Q+X,h.backtrack=!0,je(),!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,Or({value:R});continue}if(h.quotes===1&&R!=='"'){R=he.escapeRegex(R),y.value+=R,Or({value:R});continue}if(R==='"'){h.quotes=h.quotes===1?0:1,n.keepQuotes===!0&&$({type:"text",value:R});continue}if(R==="("){kr("parens"),$({type:"paren",value:R});continue}if(R===")"){if(h.parens===0&&n.strictBrackets===!0)throw new SyntaxError(mn("opening","("));let b=x[x.length-1];if(b&&h.parens===b.parens+1){eE(x.pop());continue}$({type:"paren",value:R,output:h.parens?")":"\\)"}),St("parens");continue}if(R==="["){if(n.nobracket===!0||!Be().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(mn("closing","]"));R=`\\${R}`}else kr("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(mn("opening","["));$({type:"text",value:R,output:`\\${R}`});continue}St("brackets");let b=y.value.slice(1);if(y.posix!==!0&&b[0]==="^"&&!b.includes("/")&&(R=`/${R}`),y.value+=R,Or({value:R}),n.literalBrackets===!1||he.hasRegexChars(b))continue;let H=he.escapeRegex(y.value);if(h.output=h.output.slice(0,-y.value.length),n.literalBrackets===!0){h.output+=H,y.value=H;continue}y.value=`(${c}${H}|${y.value})`,h.output+=y.value;continue}if(R==="{"&&n.nobrace!==!0){kr("braces");let b={type:"brace",value:R,output:"(",outputIndex:h.output.length,tokensIndex:h.tokens.length};G.push(b),$(b);continue}if(R==="}"){let b=G[G.length-1];if(n.nobrace===!0||!b){$({type:"text",value:R,output:R});continue}let H=")";if(b.dots===!0){let Q=a.slice(),de=[];for(let X=Q.length-1;X>=0&&(a.pop(),Q[X].type!=="brace");X--)Q[X].type!=="dots"&&de.unshift(Q[X].value);H=hC(de,n),h.backtrack=!0}if(b.comma!==!0&&b.dots!==!0){let Q=h.output.slice(0,b.outputIndex),de=h.tokens.slice(b.tokensIndex);b.value=b.output="\\{",R=H="\\}",h.output=Q;for(let X of de)h.output+=X.output||X.value}$({type:"brace",value:R,output:H}),St("braces"),G.pop();continue}if(R==="|"){x.length>0&&x[x.length-1].conditions++,$({type:"text",value:R});continue}if(R===","){let b=R,H=G[G.length-1];H&&ke[ke.length-1]==="braces"&&(H.comma=!0,b="|"),$({type:"comma",value:R,output:b});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 b=G[G.length-1];y.type="dots",y.output+=R,y.value+=R,b.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)!=="?"){Ir("qmark",R);continue}if(y&&y.type==="paren"){let H=V(),Q=R;if(H==="<"&&!he.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(y.value==="("&&!/[!=<:]/.test(H)||H==="<"&&!/<([!=]|\w+>)/.test(Be()))&&(Q=`\\${R}`),$({type:"text",value:R,output:Q});continue}if(n.dot!==!0&&(y.type==="slash"||y.type==="bos")){$({type:"qmark",value:R,output:T});continue}$({type:"qmark",value:R,output:w});continue}if(R==="!"){if(n.noextglob!==!0&&V()==="("&&(V(2)!=="?"||!/[!=<:]/.test(V(3)))){Ir("negate",R);continue}if(n.nonegate!==!0&&h.index===0){Qh();continue}}if(R==="+"){if(n.noextglob!==!0&&V()==="("&&V(2)!=="?"){Ir("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 b=gC.exec(Be());b&&(R+=b[0],h.index+=b[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=M,h.backtrack=!0,h.globstar=!0,Ie(R);continue}let O=Be();if(n.noextglob!==!0&&/^\([^?]/.test(O)){Ir("star",R);continue}if(y.type==="star"){if(n.noglobstar===!0){Ie(R);continue}let b=y.prev,H=b.prev,Q=b.type==="slash"||b.type==="bos",de=H&&(H.type==="star"||H.type==="globstar");if(n.bash===!0&&(!Q||O[0]&&O[0]!=="/")){$({type:"star",value:R,output:""});continue}let X=h.braces>0&&(b.type==="comma"||b.type==="brace"),Ke=x.length&&(b.type==="pipe"||b.type==="paren");if(!Q&&b.type!=="paren"&&!X&&!Ke){$({type:"star",value:R,output:""});continue}for(;O.slice(0,3)==="/**";){let Ge=e[h.index+4];if(Ge&&Ge!=="/")break;O=O.slice(3),Ie("/**",3)}if(b.type==="bos"&&Ee()){y.type="globstar",y.value+=R,y.output=v(n),h.output=y.output,h.globstar=!0,Ie(R);continue}if(b.type==="slash"&&b.prev.type!=="bos"&&!de&&Ee()){h.output=h.output.slice(0,-(b.output+y.output).length),b.output=`(?:${b.output}`,y.type="globstar",y.output=v(n)+(n.strictSlashes?")":"|$)"),y.value+=R,h.globstar=!0,h.output+=b.output+y.output,Ie(R);continue}if(b.type==="slash"&&b.prev.type!=="bos"&&O[0]==="/"){let Ge=O[1]!==void 0?"|$":"";h.output=h.output.slice(0,-(b.output+y.output).length),b.output=`(?:${b.output}`,y.type="globstar",y.output=`${v(n)}${m}|${m}${Ge})`,y.value+=R,h.output+=b.output+y.output,h.globstar=!0,Ie(R+je()),$({type:"slash",value:"/",output:""});continue}if(b.type==="bos"&&O[0]==="/"){y.type="globstar",y.value+=R,y.output=`(?:^|${m}|${v(n)}${m})`,h.output=y.output,h.globstar=!0,Ie(R+je()),$({type:"slash",value:"/",output:""});continue}h.output=h.output.slice(0,-y.output.length),y.type="globstar",y.output=v(n),y.value+=R,h.output+=y.output,h.globstar=!0,Ie(R);continue}let te={type:"star",value:R,output:M};if(n.bash===!0){te.output=".*?",(y.type==="bos"||y.type==="slash")&&(te.output=I+te.output),$(te);continue}if(y&&(y.type==="bracket"||y.type==="paren")&&n.regex===!0){te.output=R,$(te);continue}(h.index===h.start||y.type==="slash"||y.type==="dot")&&(y.type==="dot"?(h.output+=A,y.output+=A):n.dot===!0?(h.output+=P,y.output+=P):(h.output+=I,y.output+=I),V()!=="*"&&(h.output+=g,y.output+=g)),$(te)}for(;h.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(mn("closing","]"));h.output=he.escapeLast(h.output,"["),St("brackets")}for(;h.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(mn("closing",")"));h.output=he.escapeLast(h.output,"("),St("parens")}for(;h.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(mn("closing","}"));h.output=he.escapeLast(h.output,"{"),St("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(go,n.maxLength):go,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=Pf[e]||e;let i=he.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}=nr.globChars(i),E=n.dot?p:l,S=n.dot?d:l,A=n.capture?"":"?:",P={negated:!1,prefix:""},w=n.bash===!0?".*?":m;n.capture&&(w=`(${w})`);let T=s(I=>I.noglobstar===!0?w:`(${A}(?:(?!${g}${I.dot?f:a}).)*?)`,"globstar"),k=s(I=>{switch(I){case"*":return`${E}${u}${w}`;case".*":return`${a}${u}${w}`;case"*.*":return`${E}${w}${a}${u}${w}`;case"*/*":return`${E}${w}${c}${u}${S}${w}`;case"**":return E+T(n);case"**/*":return`(?:${E}${T(n)}${c})?${S}${u}${w}`;case"**/*.*":return`(?:${E}${T(n)}${c})?${S}${w}${a}${u}${w}`;case"**/.*":return`(?:${E}${T(n)}${c})?${a}${u}${w}`;default:{let N=/^(.*?)\.(\w+)$/.exec(I);if(!N)return;let M=k(N[1]);return M?M+a+N[2]:void 0}}},"create"),U=he.removePrefix(e,P),v=k(U);return v&&n.strictSlashes!==!0&&(v+=`${c}?`),v};vf.exports=Si});var Uf=W((bU,Mf)=>{"use strict";var AC=Ve("path"),bC=xf(),yi=Lf(),Ri=er(),OC=Qn(),kC=s(e=>e&&typeof e=="object"&&!Array.isArray(e),"isObject"),ie=s((e,t,n=!1)=>{if(Array.isArray(e)){let l=e.map(d=>ie(d,t,n));return s(d=>{for(let m of l){let g=m(d);if(g)return g}return!1},"arrayMatcher")}let r=kC(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=Ri.isWindows(t),a=r?ie.compileRe(e,t):ie.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=ie(o.ignore,l,n)}let f=s((l,p=!1)=>{let{isMatch:d,match:m,output:g}=ie.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");ie.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?Ri.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=ie.matchBase(e,t,n,o):c=t.exec(u)),{isMatch:!!c,match:c,output:u}};ie.matchBase=(e,t,n,r=Ri.isWindows(n))=>(t instanceof RegExp?t:ie.makeRe(t,n)).test(AC.basename(e));ie.isMatch=(e,t,n)=>ie(t,n)(e);ie.parse=(e,t)=>Array.isArray(e)?e.map(n=>ie.parse(n,t)):yi(e,{...t,fastpaths:!1});ie.scan=(e,t)=>bC(e,t);ie.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=ie.toRegex(c,t);return r===!0&&(u.state=e),u};ie.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=yi.fastpaths(e,t)),o.output||(o=yi(e,t)),ie.compileRe(o,t,n,r)};ie.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/$^/}};ie.constants=OC;Mf.exports=ie});var Df=W((kU,Hf)=>{"use strict";Hf.exports=Uf()});var Gf=W((IU,Kf)=>{"use strict";var $f=Ve("util"),jf=_f(),Je=Df(),Ci=er(),Ff=s(e=>e===""||e==="./","isEmptyString"),Bf=s(e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},"hasBraces"),ee=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=Je(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");ee.match=ee;ee.matcher=(e,t)=>Je(e,t);ee.isMatch=(e,t,n)=>Je(t,n)(e);ee.any=ee.isMatch;ee.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(ee(e,t,{...n,onResult:i}));for(let c of o)a.has(c)||r.add(c);return[...r]};ee.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${$f.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>ee.contains(e,r,n));if(typeof t=="string"){if(Ff(e)||Ff(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return ee.isMatch(e,t,{...n,contains:!0})};ee.matchKeys=(e,t,n)=>{if(!Ci.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=ee(Object.keys(e),t,n),o={};for(let i of r)o[i]=e[i];return o};ee.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=Je(String(o),n);if(r.some(a=>i(a)))return!0}return!1};ee.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=Je(String(o),n);if(!r.every(a=>i(a)))return!1}return!0};ee.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${$f.inspect(e)}"`);return[].concat(t).every(r=>Je(r,n)(e))};ee.capture=(e,t,n)=>{let r=Ci.isWindows(n),i=Je.makeRe(String(e),{...n,capture:!0}).exec(r?Ci.toPosixSlashes(t):t);if(i)return i.slice(1).map(a=>a===void 0?"":a)};ee.makeRe=(...e)=>Je.makeRe(...e);ee.scan=(...e)=>Je.scan(...e);ee.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of jf(String(r),t))n.push(Je.parse(o,t));return n};ee.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!Bf(e)?[e]:jf(e,t)};ee.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return ee.braces(e,{...t,expand:!0})};ee.hasBraces=Bf;Kf.exports=ee});var _o=W(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.MCP_MISSING_LAUNCH_SERIALIZED=ae.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;ae.foldMcpName=rd;ae.buildMcpFamilyCanonicalKey=GC;ae.launchContainsCredentials=zC;ae.serializeMcpLaunchIdentity=od;ae.hashMcpLaunchIdentity=rr;ae.projectMcpMissingLaunchIdentity=YC;ae.projectMcpLaunchIdentity=XC;ae.maskMcpLaunchForDisplay=ZC;ae.normalizeMcpToolNames=QC;var KC=Ve("node:crypto");ae.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";ae.MCP_MISSING_LAUNCH_SERIALIZED=`${ae.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function at(e){return e.toLocaleLowerCase("en-US")}s(at,"foldCase");function rd(e){return at(e)}s(rd,"foldMcpName");function GC(e){return`interface:${rd(e)}`}s(GC,"buildMcpFamilyCanonicalKey");var nd=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),VC=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function _n(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(_n,"lengthPrefixed");function zC(e){return e.kind==="url"?WC(e.url):e.kind==="command"?e.arguments.some(t=>VC.test(t)):!1}s(zC,"launchContainsCredentials");function WC(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(nd.has(at(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=at(a.split("=",1)[0]??"");return nd.has(c)})}}s(WC,"urlContainsCredentials");function od(e){if(e.kind==="url")return[ae.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",_n(at(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>at(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[ae.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",_n(at(e.command)),String(t.length),...t.map(_n)].join("|")}return[ae.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",_n(e.installationRootExternalKey),_n(e.sourcePath),_n(e.nativeKey)].join("|")}s(od,"serializeMcpLaunchIdentity");function rr(e){return(0,KC.createHash)("sha256").update(e).digest("hex")}s(rr,"hashMcpLaunchIdentity");var JC=rr(ae.MCP_MISSING_LAUNCH_SERIALIZED);function YC(){return{kind:"unknown",arguments:[],serialized:ae.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:JC}}s(YC,"projectMcpMissingLaunchIdentity");function XC(e){let t=od(e);return e.kind==="url"?{kind:"url",url:at(e.url),arguments:[],serialized:t,contentHash:rr(t)}:e.kind==="command"?{kind:"command",command:at(e.command),arguments:[...e.arguments].map(n=>at(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:rr(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:rr(t)}}s(XC,"projectMcpLaunchIdentity");var qC=/^(https?:\/\/)([^/?#]*@)/i;function ZC(e){return e.replace(qC,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}s(ZC,"maskMcpLaunchForDisplay");function QC(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(QC,"normalizeMcpToolNames")});var Eo=W(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.LOCAL_BIN_PACKAGE_VERSION_SOURCE=Re.PACKAGE_FIELD_MAX=void 0;Re.npxExecBin=sd;Re.isExactNpmVersion=id;Re.isNodeModulesBinCommand=uA;Re.packageNameFromSpec=ho;Re.pinnedPackageVersionFromSpec=ad;Re.pinnedPackageVersionFromNpx=lA;Re.npxPackageSpecs=cd;Re.PACKAGE_FIELD_MAX=128;var eA=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,tA=new Set(["-p","--package"]),nA=new Set(["-c","--call"]),rA=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),oA=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),sA=/^--no-/;function iA(e){return oA.has(e)||sA.test(e)}s(iA,"booleanFlag");function sd(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}s(sd,"npxExecBin");var aA=/^(?: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 id(e){return e.length<=Re.PACKAGE_FIELD_MAX&&aA.test(e)}s(id,"isExactNpmVersion");Re.LOCAL_BIN_PACKAGE_VERSION_SOURCE="node_modules_local";var cA=/(?:^|\/)node_modules\/\.bin\/[^/]+$/;function uA(e){return cA.test(e.replaceAll("\\","/"))}s(uA,"isNodeModulesBinCommand");function ho(e){if(e.length===0||e.length>Re.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return eA.test(n)?n:null}s(ho,"packageNameFromSpec");function ad(e){let t=ho(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return id(n)?n:void 0}s(ad,"pinnedPackageVersionFromSpec");function lA(e,t){for(let n of cd(e,t)){let r=ad(n);if(r!==void 0)return r}}s(lA,"pinnedPackageVersionFromNpx");function cd(e,t){let n=sd(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(nA.has(f))return[];if(tA.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||iA(f))){if(rA.has(f)){a+=1;continue}return[]}}return o.length>0?o.every(a=>ho(a)!==null)?o:[]:i===null||ho(i)===null?[]:[i]}s(cd,"npxPackageSpecs")});var ld=W(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.McpPackageEcosystem=void 0;ct.resolveMcpPackageIdentity=RA;ct.resolveLocalBinPackageIdentity=CA;var ud=_o(),Nt=Eo();ct.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var fA=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,dA=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function pA(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}s(pA,"pythonRunnerBin");var mA=new Set(["--from","--spec"]),gA=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"]),_A=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"]),hA=/^--no-/;function EA(e,t){let n=pA(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(mA.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||_A.has(f)||hA.test(f))){if(gA.has(f)){a+=1;continue}return null}}return o??i}s(EA,"pythonRunnerSpec");function SA(e){if(e.length===0||e.length>Nt.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!fA.test(r)||!dA.test(o)?null:{ecosystem:ct.McpPackageEcosystem.PYPI,packageName:r,version:o}}s(SA,"pypiIdentityFromSpec");function yA(e){let t=(0,Nt.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return(0,Nt.isExactNpmVersion)(n)?{ecosystem:ct.McpPackageEcosystem.NPM,packageName:t,version:n}:null}s(yA,"npmIdentityFromSpec");function RA(e){if(e?.kind!=="command"||(0,ud.launchContainsCredentials)(e))return;for(let n of(0,Nt.npxPackageSpecs)(e.command,e.arguments)){let r=yA(n);if(r!==null)return r}let t=EA(e.command,e.arguments);if(t!==null)return SA(t)??void 0}s(RA,"resolveMcpPackageIdentity");function CA(e,t){if(e?.kind!=="command"||(0,ud.launchContainsCredentials)(e)||!(0,Nt.isNodeModulesBinCommand)(e.command)||t.packageVersionSource!==Nt.LOCAL_BIN_PACKAGE_VERSION_SOURCE)return;let{packageName:n,packageVersion:r}=t;if(!(n===void 0||r===void 0||(0,Nt.packageNameFromSpec)(n)!==n||!(0,Nt.isExactNpmVersion)(r)))return{ecosystem:ct.McpPackageEcosystem.NPM,packageName:n,version:r}}s(CA,"resolveLocalBinPackageIdentity")});var hd=W(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.EMPTY_NPM_PUBLISHER=void 0;ut.isNpmRegistryPublisher=bA;ut.displayPublisherName=OA;ut.classifyMcpProvenance=vA;var md=_o(),or=Eo();ut.EMPTY_NPM_PUBLISHER="npm:";var fd="npm:",AA=/^[A-Za-z0-9._-]+$/;function bA(e){return e.startsWith(fd)&&e!==ut.EMPTY_NPM_PUBLISHER&&AA.test(e.slice(fd.length))}s(bA,"isNpmRegistryPublisher");function OA(e){if(!(e==null||e===""||e===ut.EMPTY_NPM_PUBLISHER))return e}s(OA,"displayPublisherName");function dd(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(dd,"privateIpv4");function kA(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(kA,"ipv4MappedAddress");function Ti(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}s(Ti,"normalizedHost");function IA(e){let t=Ti(e),n=kA(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||dd(t)||n!==void 0&&dd(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}s(IA,"privateHostname");function TA(e){let t=Ti(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}s(TA,"publisherHost");function xA(e){let t=Ti(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}s(xA,"publicOrigin");function gd(e){let t={kind:"url",url:e};if((0,md.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||IA(n.hostname))return{origin:"UNKNOWN"};let r=TA(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:xA(n)}}catch{return{origin:"UNKNOWN"}}}s(gd,"classifyUrl");var _d="mcp-remote";function PA(e,t){if(e===_d)return t.find(n=>/^https?:\/\//i.test(n))}s(PA,"remoteUrlChild");function wA(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}s(wA,"thirdPartyPackage");function pd(e,t,n){let r=PA(e,t);return r!==void 0?gd(r):e===_d?{origin:"UNKNOWN"}:wA(e,n)}s(pd,"classifyRegistryPackage");function NA(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(NA,"isRepoRelativeCommand");function vA(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,md.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return gd(t.url);let r=(0,or.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,or.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let i=pd(o,t.arguments,e.publisherName),a=typeof e.packageName=="string"?(0,or.packageNameFromSpec)(e.packageName):null;return a!==null&&a===o&&i.packageName!==void 0?{...i,packageName:a,packageKey:a}:i}if((0,or.isNodeModulesBinCommand)(t.command)){let o=typeof e.packageName=="string"?(0,or.packageNameFromSpec)(e.packageName):null;return o===null||o!==e.packageName?{origin:"UNKNOWN"}:pd(o,t.arguments,e.publisherName)}return NA(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}s(vA,"classifyMcpProvenance")});var Sd=W(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.mcpServerToolSegmentForms=Ed;So.mcpServerNameMatchesToolSegment=LA;function Ed(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}s(Ed,"mcpServerToolSegmentForms");function LA(e,t){let n=t.toLowerCase();return Ed(e).some(r=>r.toLowerCase()===n)}s(LA,"mcpServerNameMatchesToolSegment")});var yd=W(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.parseFrontmatterField=Fe.parseFrontmatterDescription=Fe.usableCatalogText=void 0;var MA=/^(?:>|\|)[-+]?$/,UA=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,HA=s(e=>{let t=e?.trim()??"";if(!(t.length===0||MA.test(t)))return t},"usableCatalogText");Fe.usableCatalogText=HA;var DA=s(e=>(0,Fe.parseFrontmatterField)(e,"description"),"parseFrontmatterDescription");Fe.parseFrontmatterDescription=DA;var FA=s((e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return jA(n[1],t)},"parseFrontmatterField");Fe.parseFrontmatterField=FA;var $A=s(e=>e.replace(/^["']|["']$/g,""),"stripYamlQuotes");function jA(e,t){let n=e.split(`
|
|
7
|
+
`),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=UA.exec(i);if(!a){let m=$A(i).trim();return(0,Fe.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(`
|
|
8
8
|
`).split(/\n{2,}/).map(m=>m.split(`
|
|
9
9
|
`).map(g=>g.trim()).filter(Boolean).join(" ")).filter(m=>m.length>0).join(`
|
|
10
10
|
|
|
11
11
|
`):f.join(`
|
|
12
|
-
`).trimEnd();return(0,
|
|
13
|
-
`),n=!1;return t.map(o=>n?
|
|
14
|
-
`)}s(mi,"redactComponentSource");function dA(e){return mi(e)!==e}s(dA,"componentSourceContainsRedactableSecret")});var Ge=X(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.redactComponentSource=C.prepareComponentInspectionText=C.fitSnapshotInspectionTextBudget=C.componentSourceContainsRedactableSecret=C.capComponentTextBytes=C.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=C.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=C.COMPONENT_INSPECTION_TEXT_MAX_BYTES=C.usableCatalogText=C.parseFrontmatterField=C.parseFrontmatterDescription=C.mcpServerToolSegmentForms=C.mcpServerNameMatchesToolSegment=C.isNpmRegistryPublisher=C.EMPTY_NPM_PUBLISHER=C.displayPublisherName=C.classifyMcpProvenance=C.resolveMcpPackageIdentity=C.resolveLocalBinPackageIdentity=C.McpPackageEcosystem=C.pinnedPackageVersionFromSpec=C.pinnedPackageVersionFromNpx=C.packageNameFromSpec=C.npxPackageSpecs=C.npxExecBin=C.isNodeModulesBinCommand=C.isExactNpmVersion=C.LOCAL_BIN_PACKAGE_VERSION_SOURCE=C.PACKAGE_FIELD_MAX=C.serializeMcpLaunchIdentity=C.projectMcpMissingLaunchIdentity=C.projectMcpLaunchIdentity=C.normalizeMcpToolNames=C.MCP_MISSING_LAUNCH_SERIALIZED=C.MCP_LAUNCH_IDENTITY_ALGORITHM=C.maskMcpLaunchForDisplay=C.launchContainsCredentials=C.hashMcpLaunchIdentity=C.foldMcpName=C.buildMcpFamilyCanonicalKey=C.ComponentKind=void 0;C.userConfigRootFromPath=bA;C.installationRootExternalKey=kA;C.normalizeRepositoryRelativePath=od;C.nativeKeyForSkillPath=OA;C.nativeKeyForRulePath=xA;C.nativeKeyForCommandPath=IA;C.serializeComponentIdentity=id;C.buildComponentReference=wA;C.validateComponentReference=PA;var pA=mt("node:crypto"),mA=mt("node:path"),gA="cmp1_",_A=/^cmp1_[A-Za-z0-9_-]{43}$/,hA=["/skills/","/skills-cursor/"],SA=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,yA=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,EA=/(?:^|\/)\.(?:github|copilot)\/instructions\/(.+)$/i,RA=/(?:^|\/)\.github\/prompts\/(.+)$/i,CA=[".cursor",".claude",".codex",".copilot"],AA={".claude.json":".claude",".agents":".codex",".github":".copilot",".vscode":".copilot"};C.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function bA(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>CA.includes(o));return n||(t.map(o=>AA[o]).find(o=>o!==void 0)??"unknown")}s(bA,"userConfigRootFromPath");function kA(e,t){return`runtime-install:${e}/${t}`}s(kA,"installationRootExternalKey");function po(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}s(po,"requireValue");function od(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=mA.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return po(n,"sourcePath")}s(od,"normalizeRepositoryRelativePath");function OA(e){let t=e.replaceAll("\\","/");for(let n of hA){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}s(OA,"nativeKeyForSkillPath");function gi(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(gi,"nativeKeyUnderLayoutRoot");function xA(e){return gi(e,SA,/\.(mdc|md|rules)$/i)??sd(e,EA,/\.instructions\.md$/i)}s(xA,"nativeKeyForRulePath");function IA(e){return gi(e,yA,/\.(md|mdc|toml)$/i)??sd(e,RA,/\.prompt\.md$/i)}s(IA,"nativeKeyForCommandPath");function sd(e,t,n){if(!n.test(e.split("#",1)[0]??""))return null;let r=gi(e,t,n);return r===null?null:r.split("/").pop()??null}s(sd,"copilotNativeKey");function TA(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(TA,"field");function id(e){let t=[po(e.installationRootExternalKey,"installationRootExternalKey"),po(e.installableKind,"installableKind"),od(e.sourcePath),po(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(TA).join("|")}`,"utf8")}s(id,"serializeComponentIdentity");function wA(e){let t=(0,pA.createHash)("sha256").update(id(e)).digest("base64url");return`${gA}${t}`}s(wA,"buildComponentReference");function PA(e){return _A.test(e)}s(PA,"validateComponentReference");var Le=co();Object.defineProperty(C,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:s(function(){return Le.buildMcpFamilyCanonicalKey},"get")});Object.defineProperty(C,"foldMcpName",{enumerable:!0,get:s(function(){return Le.foldMcpName},"get")});Object.defineProperty(C,"hashMcpLaunchIdentity",{enumerable:!0,get:s(function(){return Le.hashMcpLaunchIdentity},"get")});Object.defineProperty(C,"launchContainsCredentials",{enumerable:!0,get:s(function(){return Le.launchContainsCredentials},"get")});Object.defineProperty(C,"maskMcpLaunchForDisplay",{enumerable:!0,get:s(function(){return Le.maskMcpLaunchForDisplay},"get")});Object.defineProperty(C,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:s(function(){return Le.MCP_LAUNCH_IDENTITY_ALGORITHM},"get")});Object.defineProperty(C,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:s(function(){return Le.MCP_MISSING_LAUNCH_SERIALIZED},"get")});Object.defineProperty(C,"normalizeMcpToolNames",{enumerable:!0,get:s(function(){return Le.normalizeMcpToolNames},"get")});Object.defineProperty(C,"projectMcpLaunchIdentity",{enumerable:!0,get:s(function(){return Le.projectMcpLaunchIdentity},"get")});Object.defineProperty(C,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:s(function(){return Le.projectMcpMissingLaunchIdentity},"get")});Object.defineProperty(C,"serializeMcpLaunchIdentity",{enumerable:!0,get:s(function(){return Le.serializeMcpLaunchIdentity},"get")});var st=lo();Object.defineProperty(C,"PACKAGE_FIELD_MAX",{enumerable:!0,get:s(function(){return st.PACKAGE_FIELD_MAX},"get")});Object.defineProperty(C,"LOCAL_BIN_PACKAGE_VERSION_SOURCE",{enumerable:!0,get:s(function(){return st.LOCAL_BIN_PACKAGE_VERSION_SOURCE},"get")});Object.defineProperty(C,"isExactNpmVersion",{enumerable:!0,get:s(function(){return st.isExactNpmVersion},"get")});Object.defineProperty(C,"isNodeModulesBinCommand",{enumerable:!0,get:s(function(){return st.isNodeModulesBinCommand},"get")});Object.defineProperty(C,"npxExecBin",{enumerable:!0,get:s(function(){return st.npxExecBin},"get")});Object.defineProperty(C,"npxPackageSpecs",{enumerable:!0,get:s(function(){return st.npxPackageSpecs},"get")});Object.defineProperty(C,"packageNameFromSpec",{enumerable:!0,get:s(function(){return st.packageNameFromSpec},"get")});Object.defineProperty(C,"pinnedPackageVersionFromNpx",{enumerable:!0,get:s(function(){return st.pinnedPackageVersionFromNpx},"get")});Object.defineProperty(C,"pinnedPackageVersionFromSpec",{enumerable:!0,get:s(function(){return st.pinnedPackageVersionFromSpec},"get")});var _i=Gf();Object.defineProperty(C,"McpPackageEcosystem",{enumerable:!0,get:s(function(){return _i.McpPackageEcosystem},"get")});Object.defineProperty(C,"resolveLocalBinPackageIdentity",{enumerable:!0,get:s(function(){return _i.resolveLocalBinPackageIdentity},"get")});Object.defineProperty(C,"resolveMcpPackageIdentity",{enumerable:!0,get:s(function(){return _i.resolveMcpPackageIdentity},"get")});var mo=qf();Object.defineProperty(C,"classifyMcpProvenance",{enumerable:!0,get:s(function(){return mo.classifyMcpProvenance},"get")});Object.defineProperty(C,"displayPublisherName",{enumerable:!0,get:s(function(){return mo.displayPublisherName},"get")});Object.defineProperty(C,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:s(function(){return mo.EMPTY_NPM_PUBLISHER},"get")});Object.defineProperty(C,"isNpmRegistryPublisher",{enumerable:!0,get:s(function(){return mo.isNpmRegistryPublisher},"get")});var ad=Qf();Object.defineProperty(C,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:s(function(){return ad.mcpServerNameMatchesToolSegment},"get")});Object.defineProperty(C,"mcpServerToolSegmentForms",{enumerable:!0,get:s(function(){return ad.mcpServerToolSegmentForms},"get")});var hi=ed();Object.defineProperty(C,"parseFrontmatterDescription",{enumerable:!0,get:s(function(){return hi.parseFrontmatterDescription},"get")});Object.defineProperty(C,"parseFrontmatterField",{enumerable:!0,get:s(function(){return hi.parseFrontmatterField},"get")});Object.defineProperty(C,"usableCatalogText",{enumerable:!0,get:s(function(){return hi.usableCatalogText},"get")});var xt=rd();Object.defineProperty(C,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return xt.COMPONENT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(C,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:s(function(){return xt.COMPONENT_SOURCE_REDACTION_PLACEHOLDER},"get")});Object.defineProperty(C,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return xt.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(C,"capComponentTextBytes",{enumerable:!0,get:s(function(){return xt.capComponentTextBytes},"get")});Object.defineProperty(C,"componentSourceContainsRedactableSecret",{enumerable:!0,get:s(function(){return xt.componentSourceContainsRedactableSecret},"get")});Object.defineProperty(C,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:s(function(){return xt.fitSnapshotInspectionTextBudget},"get")});Object.defineProperty(C,"prepareComponentInspectionText",{enumerable:!0,get:s(function(){return xt.prepareComponentInspectionText},"get")});Object.defineProperty(C,"redactComponentSource",{enumerable:!0,get:s(function(){return xt.redactComponentSource},"get")})});import{realpathSync as oM}from"node:fs";import{resolve as sM}from"node:path";import{fileURLToPath as iM,pathToFileURL as aM}from"node:url";import{createHash as Vh}from"node:crypto";import{homedir as zh}from"node:os";import{dirname as $M,join as Wh,parse as jM,resolve as BM}from"node:path";var dc="EV_AI_LAUNCHER_VERSION";var pc="EV_AI_HOOK_SOURCE",mc="EV_AI_HOOK_FALLBACK_REASON",gc="EV_AI_LAUNCHER_SCOPE",is="EV_AI_LAUNCHER_READY_FD";var _c="--defer-user-spec",yr="--cap",wn="--slot";var hc=Buffer.from([1]);var pM=1024*1024,mM=4*1024*1024,gM=64*1024,_M=64*1024,hM=64*1024;var as=4096,SM=4*1024*1024;import{join as Ac}from"node:path";import{open as Sc,mkdir as Ah,readFile as bh,readdir as kh,rename as Oh,stat as xh,rmdir as Ih,unlink as Th,utimes as wh}from"node:fs/promises";var Er=new WeakMap;function Ec(e){if(e&&typeof e=="object"&&"code"in e)return e}s(Ec,"asNodeError");function Zt(e){return Ec(e)?.code==="ENOENT"}s(Zt,"isNotFound");function Pn(e){return Ec(e)?.code==="EEXIST"}s(Pn,"isAlreadyExists");async function Rc(e,t){try{return await e.readdir(t)}catch(n){if(Zt(n))return[];throw n}}s(Rc,"readdirOrEmpty");function Cc(){return{async open(e,t){let n=await Sc(e,t),r={path:e};return Er.set(r,n),r},async write(e,t){let n=yc(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await yc(e).sync()},async close(e){let t=Er.get(e);Er.delete(e),t&&await t.close()},rename:Oh,async readdir(e){return kh(e)},readFile:bh,async stat(e){let t=await xh(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:s(()=>t.isDirectory(),"isDirectory")}},async mkdir(e,t){await Ah(e,t)},unlink:Th,rmdir:Ih,utimes:wh,async fsyncDir(e){if(process.platform==="win32")return;let t=await Sc(e,"r");try{await t.sync()}finally{await t.close()}}}}s(Cc,"productionFs");function yc(e){let t=Er.get(e);if(!t)throw new Error("closed");return t}s(yc,"requireHandle");var bc=4,kc=10;function Rr(e=process.platform){return e==="win32"?bc:kc}s(Rr,"defaultMaxConcurrentHooks");var Cr=6e4,Nn=2e3,Oc="slots",cs=64;function xc(e){return Ac(e,".ev-ai","agent-hook",Oc)}s(xc,"slotDirUnder");function Ar(e,t){return Ac(e,`slot-${t}`)}s(Ar,"slotPath");function br(e,t){return`${e}
|
|
12
|
+
`).trimEnd();return(0,Fe.usableCatalogText)(d)}s(jA,"parseYamlFrontmatterScalar")});var Ad=W(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=ce.COMPONENT_INSPECTION_TEXT_MAX_BYTES=ce.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=void 0;ce.fitSnapshotInspectionTextBudget=BA;ce.capComponentTextBytes=Cd;ce.prepareComponentInspectionText=KA;ce.redactComponentSource=Pi;ce.componentSourceContainsRedactableSecret=ZA;ce.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";ce.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;ce.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function BA(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<=ce.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES?(t+=i,n):{...n,skill:{...r.skill,inspectionText:void 0}}})}s(BA,"fitSnapshotInspectionTextBudget");function Cd(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(Cd,"capComponentTextBytes");function KA(e){if(!(e==null||e.length===0))return Cd(Pi(e),ce.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}s(KA,"prepareComponentInspectionText");var GA=[/\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],VA=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,zA=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,WA=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,JA=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,Rd=/-----END [A-Z0-9 ]*PRIVATE KEY-----/,YA=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"),XA=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 xi(e){return YA.test(e)||XA.test(e)}s(xi,"isReferenceOrPlaceholder");function qA(e){let t=e.replace(zA,(n,r,o,i)=>xi(i)?n:`${r}${ce.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${ce.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(WA,(n,r)=>xi(n.slice(r.length))?n:`${r}${ce.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(VA,(n,r)=>xi(n.slice(r.length))?n:`${r}${ce.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of GA)t=t.replace(n,ce.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}s(qA,"redactLine");function Pi(e){if(e.length===0)return e;let t=e.split(`
|
|
13
|
+
`),n=!1;return t.map(o=>n?Rd.test(o)?(n=!1,o):o.trim().length===0?o:ce.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:JA.test(o)&&!Rd.test(o)?(n=!0,o):qA(o)).join(`
|
|
14
|
+
`)}s(Pi,"redactComponentSource");function ZA(e){return Pi(e)!==e}s(ZA,"componentSourceContainsRedactableSecret")});var sr=W(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});wi.isRecord=QA;function QA(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(QA,"isRecord")});var vi=W(Ni=>{"use strict";Object.defineProperty(Ni,"__esModule",{value:!0});Ni.tokenizeCommand=eb;function eb(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(eb,"tokenizeCommand")});var Li=W(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.tildePath=tb;yo.tildeHomeInText=rb;function Od(e){return e.replace(/\\/g,"/")}s(Od,"posixPath");function kd(e){let t=Od(e).replace(/\/+$/,"");return t.length<=1?"":t}s(kd,"homePosix");function Id(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}s(Id,"isWindowsHome");function tb(e,t){let n=Od(e);if(n==="~"||n.startsWith("~/"))return n;let r=kd(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(tb,"tildePath");var bd=new Map;function nb(e){let t=bd.get(e);if(t!==void 0)return t;let n=kd(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 bd.set(e,r),r}s(nb,"homeTextPattern");function rb(e,t){let n=nb(t);return n?e.replace(n,"~"):e}s(rb,"tildeHomeInText")});var Ro=W(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.ENABLED_RAW_KEYS=be.TOOL_LIST_RAW_KEYS=be.OMITTED_VALUE=void 0;be.isSecretShapedValue=Mi;be.isAuthHeaderName=Pd;be.redactCommandOrUrl=Ui;be.isAuthKeyName=Nd;be.redactArgs=pb;be.mcpServerEnabledFromJson=mb;var ob=sr();be.OMITTED_VALUE="<omitted>";be.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"}];be.ENABLED_RAW_KEYS=["enabled","disabled"];var sb=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,ib=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,ab=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,cb=/^bearer(?:\s+|$)/i;function Mi(e){return ab.test(e)||cb.test(e)}s(Mi,"isSecretShapedValue");var Td=/^(?:--headers?|-H)$/,xd=/^\s*([A-Za-z0-9-]+)\s*:([\s\S]*)$/,ub=/auth|cookie|token|secret|key|passw|credential|session|signature/i,lb=/^(?:(?:bearer|basic|token)\s+)?\$(?:\{\w+\}|\w+)$/i;function Pd(e){return ub.test(e)}s(Pd,"isAuthHeaderName");function Ui(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}s(Ui,"redactCommandOrUrl");function fb(e){return Mi(e)?"<redacted>":e.includes("://")?Ui(e):e}s(fb,"redactSecretShapedValue");function wd(e){let t=xd.exec(e);if(!t)return Hi(e);let n=t[1]??"",r=(t[2]??"").trim();return lb.test(r)?e:Pd(n)||Mi(r)?`${n}: <redacted>`:e}s(wd,"redactHeaderArg");function Hi(e){if(/^https?:\/\//i.test(e))return Ui(e);let t=e.indexOf("=");if(t>0){let n=e.slice(0,t),r=e.slice(t+1);return`${n}=${Td.test(n)?wd(r):Hi(r)}`}return fb(e)}s(Hi,"redactArg");function Nd(e){return sb.test(e)||ib.test(e)}s(Nd,"isAuthKeyName");function db(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return Nd(t)}s(db,"authArgKey");function pb(e){let t=[],n=!1,r=!1;for(let o of e){if(n){t.push("<redacted>"),n=!1;continue}if(r&&(r=!1,xd.test(o))){t.push(wd(o));continue}if(Td.test(o)){t.push(o),r=!0;continue}if(db(o)){t.push("<redacted>"),n=!o.includes("=");continue}t.push(Hi(o))}return t}s(pb,"redactArgs");function mb(e){return(0,ob.isRecord)(e)?e.enabled===!1?!1:e.disabled!==!0:!0}s(mb,"mcpServerEnabledFromJson")});var Bi=W(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.MCP_CONFIG_SERVER_KEY_TREATMENT=D.MCP_CONFIG_VSCODE_INPUT_TABLE=D.MCP_CONFIG_SANDBOX_TABLE=D.MCP_CONFIG_TRANSPORT_TYPES=D.REDACTED_VALUE=void 0;D.sanitizeVariableReference=vt;D.mcpConfigFormatOf=Vb;D.mcpConfigServersKey=Vd;D.sanitizeMcpConfigFile=zb;var gb=Ve("node:path"),Hd=vi(),Dd=Li(),qt=sr(),F=Ro();D.REDACTED_VALUE="<redacted>";D.MCP_CONFIG_TRANSPORT_TYPES=new Set(["stdio","http","sse","ws","sdk","streamable-http","streamableHttp","local","remote"]);var _b={CLIENT_ID:"keep",CLIENT_SECRET:"secret",scopes:"string_list",redirectPort:"keep"},hb={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"};D.MCP_CONFIG_SANDBOX_TABLE={filesystem:{object:{allowWrite:"path",denyRead:"path",denyWrite:"path"}},network:{object:{allowedDomains:"string_list",deniedDomains:"string_list"}}};var Eb={watch:"path",debug:{object:{type:"keep",debugpyPath:"path"}}},Sb={headers:"secret_map",proxy:"url",caBundlePath:"path",timeout:"keep",verifySsl:"keep",noProxy:"string_list",extraBodyProperties:"omit",clientCertificate:{object:{cert:"omit",key:"omit",passphrase:"secret"}}},yb={startup:"keep",catalog:"keep",execution:"keep"},Rb={approval_mode:"keep",output_token_limit:"keep"};D.MCP_CONFIG_VSCODE_INPUT_TABLE={id:"keep",type:"keep",password:"keep",command:"keep",serverName:"keep",description:"omit",options:"omit",args:"omit",default:"secret"};var Cb={type:"transport_type",command:"command",args:"args",cwd:"path",env:"secret_map",url:"url",headers:"secret_map"},Ab=Object.fromEntries(F.TOOL_LIST_RAW_KEYS.map(({raw:e})=>[e,"tool_list"]));D.MCP_CONFIG_SERVER_KEY_TREATMENT={...Ab,type:"transport_type",transportType:"keep",transport:{by:{string:"keep",object:{object:Cb}}},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:Eb},sandboxEnabled:"keep",sandbox:{object:D.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:Sb},auth:{by:{string:"mode",object:{object:_b}}},oauth:{by:{boolean:"keep",object:{object:hb}}},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:Rb}}}},includeTools:"tool_list",excludeTools:"tool_list",omit_tools_from:"tool_list",default_tools_approval_mode:"keep",defaultToolsApprovalMode:"keep",timeout:{by:{number:"keep",object:{object:yb}}},startup_timeout_sec:"keep",startup_timeout_ms:"keep",tool_timeout_sec:"keep",connectionTimeout:"keep"};function bb(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(bb,"shapeOf");var Ob=/^[A-Za-z_][A-Za-z0-9_]*$/,kb=[/\$\{(?: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],Di=/\$\{([A-Za-z_][A-Za-z0-9_]*):-[^}]*\}/y;function vd(e){let t="",n=0;for(;n<e.length;){Di.lastIndex=n;let r=Di.exec(e);if(r){t+=`\${${r[1]??""}:-${D.REDACTED_VALUE}}`,n=Di.lastIndex;continue}let o=!1;for(let i of kb){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(vd,"referencesOnly");function vt(e){let t=/^(bearer|basic|token)(\s+)(.+)$/i.exec(e);if(t){let n=vd(t[3]??"");return n===null?null:`${t[1]??""}${t[2]??""}${n}`}return vd(e)}s(vt,"sanitizeVariableReference");function ir(e,t){return t.home?(0,Dd.tildeHomeInText)(e,t.home):e}s(ir,"tildeText");function Ao(e){return(0,F.isSecretShapedValue)(e)||e.split(/[\s=,;:'"]+/).some(F.isSecretShapedValue)}s(Ao,"containsSecretShapedToken");function Fd(e,t){return Ao(e)?D.REDACTED_VALUE:e.includes("://")?Bd(e,t):ir(e,t)}s(Fd,"keepString");var Ib=/^[A-Za-z][A-Za-z_-]{0,31}$/;function Tb(e){return typeof e!="string"?F.OMITTED_VALUE:Ib.test(e)&&!(0,F.isSecretShapedValue)(e)?e:D.REDACTED_VALUE}s(Tb,"sanitizeMode");function xb(e,t){return typeof e=="string"?Fd(e,t):typeof e=="number"?Number.isFinite(e)?e:F.OMITTED_VALUE:typeof e=="boolean"||e===null?e:F.OMITTED_VALUE}s(xb,"keepScalar");function Ld(e){return typeof e!="string"?F.OMITTED_VALUE:/[\s=]/.test(e)||Ao(e)?D.REDACTED_VALUE:e}s(Ld,"toolName");function Pb(e){return typeof e=="boolean"?e:typeof e=="string"?Ld(e):Array.isArray(e)?e.map(t=>Ld(t)):F.OMITTED_VALUE}s(Pb,"sanitizeToolList");function wb(e,t){return Array.isArray(e)?e.map(n=>typeof n=="string"?Fd(n,t):F.OMITTED_VALUE):F.OMITTED_VALUE}s(wb,"sanitizeStringList");function Nb(e){return(0,F.isAuthHeaderName)(e)||(0,F.isAuthKeyName)(e)}s(Nb,"isCredentialHeaderName");var Fi=/(^|[\s"'=,;])([A-Za-z][A-Za-z0-9_-]*)(\s*:\s*)/g;function $d(e){let t="",n=0;Fi.lastIndex=0;let r;for(;(r=Fi.exec(e))!==null;){let o=r[2]??"",i=r.index+r[0].length;if(!Nb(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+=vt(u)??D.REDACTED_VALUE,n=c,Fi.lastIndex=c)}return t+e.slice(n)}s($d,"redactCredentialHeaders");var jd=/\b(bearer|basic|token)(\s+)([^\s"']+)/gi;function vb(e){for(let t of e.matchAll(jd))if(vt(t[3]??"")===null)return!0;return!1}s(vb,"hasLiteralAuthScheme");function Lb(e){let t=$d(e);return vb(t)?D.REDACTED_VALUE:t}s(Lb,"redactCredentialArg");function Mb(e){return $d(e).replace(jd,(t,n,r,o)=>vt(o)===null?`${n}${r}${D.REDACTED_VALUE}`:t)}s(Mb,"redactCredentialCommandLine");function Ub(e){return e.map(t=>/\s/.test(t)?t.includes('"')&&!t.includes("'")?`'${t}'`:`"${t}"`:t).join(" ")}s(Ub,"joinCommandTokens");function ji(e,t){if(typeof e!="string")return F.OMITTED_VALUE;let n=(0,Hd.tokenizeCommand)(Mb(e));return n.length===0?e:ir(Ub((0,F.redactArgs)(n)),t)}s(ji,"sanitizeCommand");function Hb(e,t){if(typeof e=="string"){let n=vt(e);if(n!==null)return n;let r=(0,Hd.tokenizeCommand)(e),[o]=r;if(o===void 0)return e;let i=ji(o,t);return r.length>1?`${String(i)} ${D.REDACTED_VALUE}`:i}return Array.isArray(e)?e.map((n,r)=>r===0?ji(n,t):D.REDACTED_VALUE):F.OMITTED_VALUE}s(Hb,"sanitizeHelperCommand");function Db(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]=ir(Lb(o[c]??D.REDACTED_VALUE),t)}),i}s(Db,"sanitizeArgs");function Fb(e){try{return new URL(e).href.length>0}catch{return!1}}s(Fb,"canParseUrl");function $i(e){return e.split("/").map(t=>Ao(t)?D.REDACTED_VALUE:t).join("/")}s($i,"redactSecretPathSegments");function Bd(e,t){if(typeof e!="string")return F.OMITTED_VALUE;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 ir($i(`${m}${d}`),t)}if(/^(?:https?|wss?):/i.test(e)&&Fb(e))return $i((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 ir($i(f),t)}s(Bd,"sanitizeUrl");function Kd(e){return e===null?null:typeof e=="string"?vt(e)??D.REDACTED_VALUE:D.REDACTED_VALUE}s(Kd,"sanitizeSecret");function Co(e){return typeof e!="string"?F.OMITTED_VALUE:Ob.test(e)&&!(0,F.isSecretShapedValue)(e)?e:D.REDACTED_VALUE}s(Co,"envName");function $b(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 Co(n);let o=n.slice(0,r);return Co(o)!==o?D.REDACTED_VALUE:`${o}=${vt(n.slice(r+1))??D.REDACTED_VALUE}`});if(!(0,qt.isRecord)(e))return F.OMITTED_VALUE;let t={};for(let[n,r]of Object.entries(e))t[n]=Kd(r);return t}s($b,"sanitizeSecretMap");function jb(e){if(!(0,qt.isRecord)(e))return F.OMITTED_VALUE;let t={};for(let[n,r]of Object.entries(e))t[n]=Co(r);return t}s(jb,"sanitizeEnvNameMap");function Md(e,t){return Ao(e)?D.REDACTED_VALUE:t.home?(0,Dd.tildePath)(e,t.home):e}s(Md,"pathString");function Bb(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(Bb,"sanitizePath");function Gd(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:hn(i,a,n)}return r}s(Gd,"sanitizeObject");function Kb(e,t,n){switch(t){case"keep":return xb(e,n);case"transport_type":return typeof e=="string"&&D.MCP_CONFIG_TRANSPORT_TYPES.has(e)?e:F.OMITTED_VALUE;case"mode":return Tb(e);case"string_list":return wb(e,n);case"tool_list":return Pb(e);case"command":return ji(e,n);case"helper_command":return Hb(e,n);case"args":return Db(e,n);case"url":return Bd(e,n);case"secret":return Kd(e);case"secret_map":return $b(e);case"env_name":return Co(e);case"env_name_map":return jb(e);case"path":return Bb(e,n);case"omit":return F.OMITTED_VALUE}}s(Kb,"applyLeaf");function hn(e,t,n){if(typeof t=="string")return Kb(e,t,n);if("object"in t)return(0,qt.isRecord)(e)?Gd(e,t.object,n):F.OMITTED_VALUE;if("map"in t){if(!(0,qt.isRecord)(e))return F.OMITTED_VALUE;let i={};for(let[a,c]of Object.entries(e))i[a]=hn(c,t.map,n);return i}if("list"in t)return Array.isArray(e)?e.map(i=>hn(i,t.list,n)):F.OMITTED_VALUE;let r=bb(e),o=r===void 0?void 0:t.by[r];return o===void 0?F.OMITTED_VALUE:hn(e,o,n)}s(hn,"applyTreatment");function Ud(e,t){if(!(0,qt.isRecord)(e))return F.OMITTED_VALUE;let n={};for(let[r,o]of Object.entries(e))n[r]=(0,qt.isRecord)(o)?Gd(o,D.MCP_CONFIG_SERVER_KEY_TREATMENT,t):F.OMITTED_VALUE;return n}s(Ud,"sanitizeServers");function Gb(e){return/(?:^|[\\/])\.vscode[\\/]mcp\.json$/i.test(e)}s(Gb,"isVsCodeMcpJson");function Vb(e){return Gb(e)?"vscode_mcp_json":(0,gb.basename)(e)===".claude.json"?"claude_json_slice":"mcp_json"}s(Vb,"mcpConfigFormatOf");function Vd(e){return e==="vscode_mcp_json"?"servers":"mcpServers"}s(Vd,"mcpConfigServersKey");function zb(e,t,n={}){if(!(0,qt.isRecord)(e))return{};let r=Vd(t);if(t==="claude_json_slice")return Object.hasOwn(e,r)?{[r]:Ud(e[r],n)}:{};let o={};for(let[i,a]of Object.entries(e))i===r?o[i]=Ud(a,n):t==="vscode_mcp_json"&&i==="inputs"?o[i]=hn(a,{list:{object:D.MCP_CONFIG_VSCODE_INPUT_TABLE}},n):t==="vscode_mcp_json"&&i==="sandbox"?o[i]=hn(a,{object:D.MCP_CONFIG_SANDBOX_TABLE},n):o[i]=F.OMITTED_VALUE;return o}s(zb,"sanitizeMcpConfigFile")});var Wd=W(Oo=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0});Oo.sanitizeMcpConfig=Yb;Oo.parseMcpConfig=Xb;var Wb=Ve("node:crypto"),bo=sr(),zd=Bi(),Jb=Ro();function Yb(e,t){let n=JSON.parse(e);return JSON.stringify((0,zd.sanitizeMcpConfigFile)(n,t),null,2)}s(Yb,"sanitizeMcpConfig");function Xb(e,t){let n=JSON.parse(e);if(!(0,bo.isRecord)(n))return[];let r=n[(0,zd.mcpConfigServersKey)(t)];return(0,bo.isRecord)(r)?Object.entries(r).flatMap(([o,i])=>(0,bo.isRecord)(i)?[qb(o,i)]:[]):[]}s(Xb,"parseMcpConfig");function qb(e,t){return{key:e,enabled:(0,Jb.mcpServerEnabledFromJson)(t),block:t,launch:Zb(e,t),contentHash:(0,Wb.createHash)("sha256").update(Ki(t)).digest("hex")}}s(qb,"parsedServer");function Zb(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(Zb,"launchOf");function Ki(e){return Array.isArray(e)?`[${e.map(Ki).join(",")}]`:(0,bo.isRecord)(e)?`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${Ki(e[n])}`).join(",")}}`:JSON.stringify(e)??"null"}s(Ki,"canonicalJson")});var Pe=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=lO;_.repositoryConfigRootExternalKeyFromPath=mO;_.installationRootExternalKey=gO;_.normalizeRepositoryRelativePath=Jd;_.nativeKeyForSkillPath=_O;_.nativeKeyForRulePath=hO;_.nativeKeyForCommandPath=EO;_.serializeComponentIdentity=Xd;_.buildComponentReference=yO;_.validateComponentReference=RO;var Qb=Ve("node:crypto"),eO=Ve("node:path"),tO="cmp1_",nO=/^cmp1_[A-Za-z0-9_-]{43}$/,rO=["/skills/","/skills-cursor/"],oO=/(?:^|\/)(?:\.(?:cursor|claude|codex)|\.gemini\/config)\/rules\/(.+)$/i,sO=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,iO=/(?:^|\/)\.(?:github|copilot)\/instructions\/(.+)$/i,aO=/(?:^|\/)\.github\/prompts\/(.+)$/i,cO=[".cursor",".claude",".codex",".copilot",".gemini"],uO={".claude.json":".claude",".agents":".codex",".github":".copilot",".vscode":".copilot"};_.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function lO(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>cO.includes(o));return n||(t.map(o=>uO[o]).find(o=>o!==void 0)??"unknown")}s(lO,"userConfigRootFromPath");var fO=new Set([".claude",".cursor",".codex",".opencode",".github"]),dO=".agents",pO=".codex";function mO(e,t){let n=t.replaceAll("\\","/").split("/").filter(Boolean),r=n.findIndex(i=>fO.has(i));if(r>=0)return`${e}:${n.slice(0,r+1).join("/")}`;let o=n.indexOf(dO);return o<0?null:`${e}:${[...n.slice(0,o),pO].join("/")}`}s(mO,"repositoryConfigRootExternalKeyFromPath");function gO(e,t){return`runtime-install:${e}/${t}`}s(gO,"installationRootExternalKey");function ko(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}s(ko,"requireValue");function Jd(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 ko(n,"sourcePath")}s(Jd,"normalizeRepositoryRelativePath");function _O(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(_O,"nativeKeyForSkillPath");function Gi(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(Gi,"nativeKeyUnderLayoutRoot");function hO(e){return Gi(e,oO,/\.(mdc|md|rules)$/i)??Yd(e,iO,/\.instructions\.md$/i)}s(hO,"nativeKeyForRulePath");function EO(e){return Gi(e,sO,/\.(md|mdc|toml)$/i)??Yd(e,aO,/\.prompt\.md$/i)}s(EO,"nativeKeyForCommandPath");function Yd(e,t,n){if(!n.test(e.split("#",1)[0]??""))return null;let r=Gi(e,t,n);return r===null?null:r.split("/").pop()??null}s(Yd,"copilotNativeKey");function SO(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(SO,"field");function Xd(e){let t=[ko(e.installationRootExternalKey,"installationRootExternalKey"),ko(e.installableKind,"installableKind"),Jd(e.sourcePath),ko(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(SO).join("|")}`,"utf8")}s(Xd,"serializeComponentIdentity");function yO(e){let t=(0,Qb.createHash)("sha256").update(Xd(e)).digest("base64url");return`${tO}${t}`}s(yO,"buildComponentReference");function RO(e){return nO.test(e)}s(RO,"validateComponentReference");var $e=_o();Object.defineProperty(_,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:s(function(){return $e.buildMcpFamilyCanonicalKey},"get")});Object.defineProperty(_,"foldMcpName",{enumerable:!0,get:s(function(){return $e.foldMcpName},"get")});Object.defineProperty(_,"hashMcpLaunchIdentity",{enumerable:!0,get:s(function(){return $e.hashMcpLaunchIdentity},"get")});Object.defineProperty(_,"launchContainsCredentials",{enumerable:!0,get:s(function(){return $e.launchContainsCredentials},"get")});Object.defineProperty(_,"maskMcpLaunchForDisplay",{enumerable:!0,get:s(function(){return $e.maskMcpLaunchForDisplay},"get")});Object.defineProperty(_,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:s(function(){return $e.MCP_LAUNCH_IDENTITY_ALGORITHM},"get")});Object.defineProperty(_,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:s(function(){return $e.MCP_MISSING_LAUNCH_SERIALIZED},"get")});Object.defineProperty(_,"normalizeMcpToolNames",{enumerable:!0,get:s(function(){return $e.normalizeMcpToolNames},"get")});Object.defineProperty(_,"projectMcpLaunchIdentity",{enumerable:!0,get:s(function(){return $e.projectMcpLaunchIdentity},"get")});Object.defineProperty(_,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:s(function(){return $e.projectMcpMissingLaunchIdentity},"get")});Object.defineProperty(_,"serializeMcpLaunchIdentity",{enumerable:!0,get:s(function(){return $e.serializeMcpLaunchIdentity},"get")});var lt=Eo();Object.defineProperty(_,"PACKAGE_FIELD_MAX",{enumerable:!0,get:s(function(){return lt.PACKAGE_FIELD_MAX},"get")});Object.defineProperty(_,"LOCAL_BIN_PACKAGE_VERSION_SOURCE",{enumerable:!0,get:s(function(){return lt.LOCAL_BIN_PACKAGE_VERSION_SOURCE},"get")});Object.defineProperty(_,"isExactNpmVersion",{enumerable:!0,get:s(function(){return lt.isExactNpmVersion},"get")});Object.defineProperty(_,"isNodeModulesBinCommand",{enumerable:!0,get:s(function(){return lt.isNodeModulesBinCommand},"get")});Object.defineProperty(_,"npxExecBin",{enumerable:!0,get:s(function(){return lt.npxExecBin},"get")});Object.defineProperty(_,"npxPackageSpecs",{enumerable:!0,get:s(function(){return lt.npxPackageSpecs},"get")});Object.defineProperty(_,"packageNameFromSpec",{enumerable:!0,get:s(function(){return lt.packageNameFromSpec},"get")});Object.defineProperty(_,"pinnedPackageVersionFromNpx",{enumerable:!0,get:s(function(){return lt.pinnedPackageVersionFromNpx},"get")});Object.defineProperty(_,"pinnedPackageVersionFromSpec",{enumerable:!0,get:s(function(){return lt.pinnedPackageVersionFromSpec},"get")});var Vi=ld();Object.defineProperty(_,"McpPackageEcosystem",{enumerable:!0,get:s(function(){return Vi.McpPackageEcosystem},"get")});Object.defineProperty(_,"resolveLocalBinPackageIdentity",{enumerable:!0,get:s(function(){return Vi.resolveLocalBinPackageIdentity},"get")});Object.defineProperty(_,"resolveMcpPackageIdentity",{enumerable:!0,get:s(function(){return Vi.resolveMcpPackageIdentity},"get")});var Io=hd();Object.defineProperty(_,"classifyMcpProvenance",{enumerable:!0,get:s(function(){return Io.classifyMcpProvenance},"get")});Object.defineProperty(_,"displayPublisherName",{enumerable:!0,get:s(function(){return Io.displayPublisherName},"get")});Object.defineProperty(_,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:s(function(){return Io.EMPTY_NPM_PUBLISHER},"get")});Object.defineProperty(_,"isNpmRegistryPublisher",{enumerable:!0,get:s(function(){return Io.isNpmRegistryPublisher},"get")});var qd=Sd();Object.defineProperty(_,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:s(function(){return qd.mcpServerNameMatchesToolSegment},"get")});Object.defineProperty(_,"mcpServerToolSegmentForms",{enumerable:!0,get:s(function(){return qd.mcpServerToolSegmentForms},"get")});var zi=yd();Object.defineProperty(_,"parseFrontmatterDescription",{enumerable:!0,get:s(function(){return zi.parseFrontmatterDescription},"get")});Object.defineProperty(_,"parseFrontmatterField",{enumerable:!0,get:s(function(){return zi.parseFrontmatterField},"get")});Object.defineProperty(_,"usableCatalogText",{enumerable:!0,get:s(function(){return zi.usableCatalogText},"get")});var Lt=Ad();Object.defineProperty(_,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return Lt.COMPONENT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(_,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:s(function(){return Lt.COMPONENT_SOURCE_REDACTION_PLACEHOLDER},"get")});Object.defineProperty(_,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return Lt.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(_,"capComponentTextBytes",{enumerable:!0,get:s(function(){return Lt.capComponentTextBytes},"get")});Object.defineProperty(_,"componentSourceContainsRedactableSecret",{enumerable:!0,get:s(function(){return Lt.componentSourceContainsRedactableSecret},"get")});Object.defineProperty(_,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:s(function(){return Lt.fitSnapshotInspectionTextBudget},"get")});Object.defineProperty(_,"prepareComponentInspectionText",{enumerable:!0,get:s(function(){return Lt.prepareComponentInspectionText},"get")});Object.defineProperty(_,"redactComponentSource",{enumerable:!0,get:s(function(){return Lt.redactComponentSource},"get")});var CO=sr();Object.defineProperty(_,"isRecord",{enumerable:!0,get:s(function(){return CO.isRecord},"get")});var AO=vi();Object.defineProperty(_,"tokenizeCommand",{enumerable:!0,get:s(function(){return AO.tokenizeCommand},"get")});var Zd=Li();Object.defineProperty(_,"tildeHomeInText",{enumerable:!0,get:s(function(){return Zd.tildeHomeInText},"get")});Object.defineProperty(_,"tildePath",{enumerable:!0,get:s(function(){return Zd.tildePath},"get")});var ft=Ro();Object.defineProperty(_,"ENABLED_RAW_KEYS",{enumerable:!0,get:s(function(){return ft.ENABLED_RAW_KEYS},"get")});Object.defineProperty(_,"isAuthHeaderName",{enumerable:!0,get:s(function(){return ft.isAuthHeaderName},"get")});Object.defineProperty(_,"isAuthKeyName",{enumerable:!0,get:s(function(){return ft.isAuthKeyName},"get")});Object.defineProperty(_,"isSecretShapedValue",{enumerable:!0,get:s(function(){return ft.isSecretShapedValue},"get")});Object.defineProperty(_,"mcpServerEnabledFromJson",{enumerable:!0,get:s(function(){return ft.mcpServerEnabledFromJson},"get")});Object.defineProperty(_,"OMITTED_VALUE",{enumerable:!0,get:s(function(){return ft.OMITTED_VALUE},"get")});Object.defineProperty(_,"redactArgs",{enumerable:!0,get:s(function(){return ft.redactArgs},"get")});Object.defineProperty(_,"redactCommandOrUrl",{enumerable:!0,get:s(function(){return ft.redactCommandOrUrl},"get")});Object.defineProperty(_,"TOOL_LIST_RAW_KEYS",{enumerable:!0,get:s(function(){return ft.TOOL_LIST_RAW_KEYS},"get")});var dt=Bi();Object.defineProperty(_,"MCP_CONFIG_SANDBOX_TABLE",{enumerable:!0,get:s(function(){return dt.MCP_CONFIG_SANDBOX_TABLE},"get")});Object.defineProperty(_,"MCP_CONFIG_SERVER_KEY_TREATMENT",{enumerable:!0,get:s(function(){return dt.MCP_CONFIG_SERVER_KEY_TREATMENT},"get")});Object.defineProperty(_,"MCP_CONFIG_TRANSPORT_TYPES",{enumerable:!0,get:s(function(){return dt.MCP_CONFIG_TRANSPORT_TYPES},"get")});Object.defineProperty(_,"MCP_CONFIG_VSCODE_INPUT_TABLE",{enumerable:!0,get:s(function(){return dt.MCP_CONFIG_VSCODE_INPUT_TABLE},"get")});Object.defineProperty(_,"mcpConfigFormatOf",{enumerable:!0,get:s(function(){return dt.mcpConfigFormatOf},"get")});Object.defineProperty(_,"mcpConfigServersKey",{enumerable:!0,get:s(function(){return dt.mcpConfigServersKey},"get")});Object.defineProperty(_,"REDACTED_VALUE",{enumerable:!0,get:s(function(){return dt.REDACTED_VALUE},"get")});Object.defineProperty(_,"sanitizeMcpConfigFile",{enumerable:!0,get:s(function(){return dt.sanitizeMcpConfigFile},"get")});Object.defineProperty(_,"sanitizeVariableReference",{enumerable:!0,get:s(function(){return dt.sanitizeVariableReference},"get")});var Qd=Wd();Object.defineProperty(_,"parseMcpConfig",{enumerable:!0,get:s(function(){return Qd.parseMcpConfig},"get")});Object.defineProperty(_,"sanitizeMcpConfig",{enumerable:!0,get:s(function(){return Qd.sanitizeMcpConfig},"get")})});import{realpathSync as ML}from"node:fs";import{resolve as UL}from"node:path";import{fileURLToPath as HL,pathToFileURL as DL}from"node:url";import{createHash as xE}from"node:crypto";import{homedir as PE}from"node:os";import{dirname as hM,join as wE,parse as EM,resolve as SM}from"node:path";var Nc="EV_AI_LAUNCHER_VERSION";var vc="EV_AI_HOOK_SOURCE",Lc="EV_AI_HOOK_FALLBACK_REASON",Mc="EV_AI_LAUNCHER_SCOPE",ys="EV_AI_LAUNCHER_READY_FD";var Uc="--defer-user-spec",Tr="--cap",Dn="--slot";var Hc=Buffer.from([1]);var GL=1024*1024,VL=4*1024*1024,zL=64*1024,WL=64*1024,JL=64*1024;var Rs=4096,YL=4*1024*1024;import{join as Kc}from"node:path";import{open as Dc,mkdir as aE,readFile as cE,readdir as uE,rename as lE,stat as fE,rmdir as dE,unlink as pE,utimes as mE}from"node:fs/promises";var xr=new WeakMap;function $c(e){if(e&&typeof e=="object"&&"code"in e)return e}s($c,"asNodeError");function on(e){return $c(e)?.code==="ENOENT"}s(on,"isNotFound");function Fn(e){return $c(e)?.code==="EEXIST"}s(Fn,"isAlreadyExists");async function jc(e,t){try{return await e.readdir(t)}catch(n){if(on(n))return[];throw n}}s(jc,"readdirOrEmpty");function Bc(){return{async open(e,t){let n=await Dc(e,t),r={path:e};return xr.set(r,n),r},async write(e,t){let n=Fc(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await Fc(e).sync()},async close(e){let t=xr.get(e);xr.delete(e),t&&await t.close()},rename:lE,async readdir(e){return uE(e)},readFile:cE,async stat(e){let t=await fE(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:s(()=>t.isDirectory(),"isDirectory")}},async mkdir(e,t){await aE(e,t)},unlink:pE,rmdir:dE,utimes:mE,async fsyncDir(e){if(process.platform==="win32")return;let t=await Dc(e,"r");try{await t.sync()}finally{await t.close()}}}}s(Bc,"productionFs");function Fc(e){let t=xr.get(e);if(!t)throw new Error("closed");return t}s(Fc,"requireHandle");var Gc=4,Vc=10;function Pr(e=process.platform){return e==="win32"?Gc:Vc}s(Pr,"defaultMaxConcurrentHooks");var wr=6e4,$n=2e3,zc="slots",Cs=64;function Wc(e){return Kc(e,".ev-ai","agent-hook",zc)}s(Wc,"slotDirUnder");function Nr(e,t){return Kc(e,`slot-${t}`)}s(Nr,"slotPath");function vr(e,t){return`${e}
|
|
15
15
|
${t}
|
|
16
|
-
`}s(
|
|
17
|
-
`)}s(R,"logStderr");function Mn(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}s(Mn,"stripRemoteCredentials");function vn(e){return Mh("sha256").update(e).digest("hex").slice(0,32)}s(vn,"sha32");var Bh=3;function Dc(e){return e instanceof Error&&"code"in e?e.code:void 0}s(Dc,"errnoCode");function Fc(e){let t=Dc(e);return t==="EEXIST"||t==="EPERM"||t==="EACCES"}s(Fc,"isRenameReplaceBlocked");function Kh(e,t,n){let r=n;for(let o=0;o<Bh;o+=1){try{vc(t)}catch(i){if(Dc(i)!=="ENOENT")throw i}try{Nc(e,t);return}catch(i){if(!Fc(i))throw i;r=i}}throw r}s(Kh,"replaceByUnlinkThenRename");function ue(e,t){Lh(wc(e),{recursive:!0});let n=Uc(wc(e),`.${Fh(e)}.${process.pid}.${vh(4).toString("hex")}.tmp`);try{Dh(n,t,"utf8");try{Nc(n,e)}catch(r){if(!Fc(r))throw r;Kh(n,e,r)}}catch(r){try{vc(n)}catch{}throw r}}s(ue,"writeFileAtomic");function Or(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}s(Or,"timestampUtc");var $c;function fs(){($c?.stdout??process.stdout).write('{"continue":true}')}s(fs,"emitStdoutOk");var Nt=new Set(["on","1","true"]),xr=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 Ln(){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(Ln,"readStdinUntilEnd");async function Ir(e){let t=$c?.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(Ir,"readStdinWithTimeout");async function Me(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(Me,"execFileResult");async function re(e,t,n=3e3,r={}){let o=await Me(e,t,n,r);return o.ok?o.stdout:""}s(re,"execFileText");function ls(e,t){let n=Xe(e),r=Xe(t),o=Hc(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${jh}`)||$h(o)?!1:Xe(r,o)===n}s(ls,"isPathInside");function jc(e,t,n=Lc()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return Xe(e);let o=Xe(r),i=Xe(e);if(ls(i,o))return i;let a=t.CURSOR_PLUGIN_ROOT?.trim();return ls(i,Xe(n,".cursor"))||a!==void 0&&a.length>0&&ls(i,Xe(a))?o:i}s(jc,"cursorHookLaunchCwd");async function ds(e=process.cwd(),t=process.env,n=Lc()){let r=jc(e,t,n),o=r!==Xe(e)&&kr(r)?r:e,i=await Me("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 c=i.ok?"empty stdout":i.spawnFailed?"spawn failed":`exit ${String(i.code??"unknown")}`;R(`DEBUG: git rev-parse --show-toplevel failed (${c}) cwd=${e}`)}let a=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||F("CURSOR_PROJECT_DIR")||F("CLAUDE_PROJECT_DIR");if(a&&kr(a)){let c=await Me("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(ds,"resolveGitWorkspace");async function qe(e=process.cwd()){return(await ds(e)).root}s(qe,"findGitRoot");function xe(e,t){try{return JSON.parse(e)}catch{return t}}s(xe,"parseJsonSafe");var Pc=new Map;function Qt(e){return e.charCodeAt(0)===65279?e.slice(1):e}s(Qt,"stripUtf8Bom");function Gh(e){let t;try{t=Hh(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(Qt(t))}}catch{return{ok:!1,reason:"parse"}}}s(Gh,"parseJsonFile");function Bc(e){let t=Pc.get(e);if(t!==void 0)return t;let n=Gh(e);return Pc.set(e,n),n}s(Bc,"loadJsonFileStatus");function Kc(e){return Bc(e)}s(Kc,"readJsonFileStatus");function ee(e,t){let n=Bc(e);return n.ok?n.value:t}s(ee,"readJsonFileMemoized");function Mt(e){return typeof e=="string"?e:""}s(Mt,"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 $(e,t){let n=Ze(e,t);return typeof n=="string"?n:""}s($,"pickNestedString");var gt=500;function Gc(e,t=2){if(!kr(e))return{entries:[],truncated:!1};let n=[],r=!1,o=s((i,a)=>{if(a>t||r)return;let c;try{c=Uh(i,{withFileTypes:!0})}catch{return}for(let u of c){if(r)return;let f=Uc(i,u.name);if(u.isDirectory()){o(f,a+1);continue}if(u.isFile()){try{n.push({name:Hc(e,f),size:Mc(f).size})}catch{continue}if(n.length>=gt){r=!0;return}}}},"walk");return o(e,1),{entries:n,truncated:r}}s(Gc,"listDirFiles");function ps(e){return kr(e)?{present:!0,size:Mc(e).size}:{present:!1,size:0}}s(ps,"fileSizeOrAbsent");var Yc="https://hooks.ev-ai.ai",Tr=".claude/ev-ai-runtime-report.json",Xc="config.json",Jh="max_concurrent_hooks",zM=1024*1024,Yh=new Set(["localhost","127.0.0.1","[::1]","::1"]),Xh=["claude","cursor","codex","copilot"],wr=[Tr,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],ms=/^[A-Za-z0-9._~-]+$/;function Pr(e){return e!==void 0&&Xh.includes(e)}s(Pr,"isKnownRunner");function qc(e){if(!e||typeof e!="object")return;let t=e[Jh];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}s(qc,"maxConcurrentHooksFromConfig");function Vc(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}s(Vc,"parseCapArg");function en(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}s(en,"takeFlagValue");function Nr(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=en(e,u);t=l.value,u=l.next;continue}if(f.startsWith("--runner=")){t=f.slice(9);continue}if(f==="--url"){let l=en(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=en(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=en(e,u);l.value&&(i=l.value),u=l.next;continue}if(f.startsWith("--base-url=")){i=f.slice(11);continue}if(f===yr){let l=en(e,u);a=Vc(l.value)??a,u=l.next;continue}if(f.startsWith(`${yr}=`)){a=Vc(f.slice(yr.length+1))??a;continue}if(f===wn){let l=en(e,u);c=us(l.value)??c,u=l.next;continue}if(f.startsWith(`${wn}=`)){c=us(f.slice(wn.length+1))??c;continue}f!==_c&&!f.startsWith("-")&&n===void 0&&(n=f)}}return{runner:Pr(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:i,...a!==void 0?{cap:a}:{},...c!==void 0?{slot:c}:{}}}s(Nr,"parseHookArgv");function Mr(e,t=Yc){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}s(Mr,"buildCollectorUrl");function vt(e=zh()){return Wh(e,".ev-ai",Xc)}s(vt,"homeManifestPath");function Zc(e,t){return{...e,...t}}s(Zc,"mergeManifestOverlay");function zc(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(zc,"hasUnsafeCollectorUrlChars");function vr(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?Yh.has(t.hostname):!1}catch{return!1}}s(vr,"isAllowedCollectorUrl");function gs(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(gs,"extractOrgTokenFromCollectorUrl");function Qe(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!vr(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=gs(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!ms.test(n))return`org token must match ${ms.source}`;if(zc(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(zc(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}s(Qe,"collectorUrlProblem");function _t(e){return new URL(e).toString()}s(_t,"normalizeCollectorUrl");function Qc(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?Mr(n):""}s(Qc,"resolveCollectorUrl");function tn(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(tn,"redactCollectorUrlForLog");function eu(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=Mr(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=Qe(n);return r?{problem:r}:{url:_t(n)}}s(eu,"collectorUrlFromArgv");var qh="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",Zh="COLLECTOR_URL",Wc="collector_url_override",Qh=[qh,Zh];function eS(e){let t;for(let n of Qh){let r=e[n]?.trim();if(!r)continue;let o=Qe(r);if(o){t??={problem:o,envName:n};continue}return{url:_t(r),envName:n}}return t??{}}s(eS,"collectorUrlFromPluginOption");function Jc(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=Qe(t);return n?{problem:n}:{url:_t(t)}}s(Jc,"candidateFromUnknown");function tu(e){let t=[],n=Jc(e.homeConfig?.[Wc]);if(n.problem&&t.push({label:Wc,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=eu(Nr(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=eS(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=Jc(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.homeConfig?.repo_ingest_token,c=typeof a=="string"&&a.trim()?{...e.manifest,repo_ingest_token:a}:e.manifest,u=c?Qc(c):"";if(u){let f=Qe(u);if(f)t.push({label:"manifest collector_url",problem:f});else return{url:_t(u),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}s(tu,"selectCollectorUrl");function Lt(e){if(Qe(e))return;let t;try{t=new URL(e)}catch{return}let n=gs(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 Vh("sha256").update(a).digest("hex").slice(0,32)}s(Lt,"scopeIdForCollectorUrl");var ht=2,nu="node_modules/@ev-ai/agent-hook/dist/hook.mjs",Ie="ev-ai-agent-hook";function tS(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}s(tS,"hookBinaryBasenameFromPath");function Lr(e){let t=tS(e);return t===Ie||t===`${Ie}.exe`}s(Lr,"isHookBinaryPath");var ru="https://cdn.ev-ai.ai/agent-hook";var _s=`current/${Ie}`,hs=`.ev-ai/agent-hook/${Ie}`,ou=5e3,su=5e3,Ss=3e3;var Ur=3e3,iu=1500,au=4*1024,ys=256*1024,nS=4*1024,cu=32*1024,he="1.4.1",Hr=`@ev-ai/agent-hook@${he}`,uu="ev-ai runtime report";var lu={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT",copilot:"PLUGIN_ROOT"};import{chmodSync as pm,cpSync as mm,existsSync as wt,mkdirSync as Ea,readFileSync as Hx,rmSync as Mo,symlinkSync as Dx,writeFileSync as Fx}from"node:fs";import{homedir as ct}from"node:os";import{dirname as Ra,isAbsolute as $x,join as J,relative as gm,resolve as fm,sep as jx}from"node:path";import{fileURLToPath as Bx}from"node:url";import{existsSync as rS,readdirSync as fu}from"node:fs";import{homedir as Dr}from"node:os";import{join as Ee}from"node:path";function du(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(du,"claudeManagedSettingsDir");function Es(e=process.platform){let t=du(e),n=[Ee(t,"managed-settings.json")],r=Ee(t,"managed-settings.d");try{if(!rS(r))return n;let o=fu(r).filter(i=>i.endsWith(".json")&&!i.startsWith(".")).sort().map(i=>Ee(r,i));n.push(...o)}catch{}return n}s(Es,"listClaudeManagedSettingsFiles");function Un(e=process.platform,t=Dr()){return{serverManaged:Ee(t,".claude","remote-settings.json"),fileBased:Es(e)}}s(Un,"claudeManagedSettingsSources");function oS(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(oS,"cursorEnterpriseSettingsDir");function sS(e=process.platform,t=Dr()){let n=[Ee(oS(e),"hooks.json")],r=Ee(t,".cursor","managed");try{for(let o of fu(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(Ee(r,o.name,"hooks.json"))}catch{}return n}s(sS,"listCursorManagedSettingsFiles");function iS(e=process.platform,t=Dr()){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(iS,"listCodexManagedSettingsFiles");function Fr(e,t=process.platform,n=Dr()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=Un(t,n);return[r,...o]}case"cursor":return sS(t,n);default:return iS(t,n)}}s(Fr,"managedSettingsFiles");import{createHash as Dp,randomBytes as KO}from"node:crypto";import{existsSync as Fp,mkdirSync as da,readFileSync as $p,unlinkSync as jp,writeFileSync as Bp}from"node:fs";import{homedir as sr}from"node:os";import{dirname as To,join as wo,resolve as GO}from"node:path";var aS=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com","claude@anthropic.com","agent@cursor.local"]),cS=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function me(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||cS.has(n)||r.includes("[bot]")||aS.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(me,"isBotOperatorIdentity");import{homedir as Rs}from"node:os";import{join as lS}from"node:path";function pu(e=Rs()){return lS(e,".claude.json")}s(pu,"claudeUserConfigPath");function Ut(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Ut,"trimString");function mu(e=Rs()){let n=ee(pu(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=Ut(n.emailAddress),o=Ut(n.fullName)??Ut(n.displayName),i=Ut(n.accountUuid),a=r??i;return!a||me(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:a,identity_source:"claude_oauth"}}s(mu,"readClaudeOperatorIdentity");function gu(e=Rs()){let n=ee(pu(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=Ut(n.emailAddress),o=Ut(n.fullName)??Ut(n.displayName);return me(o,r)?null:r?.toLowerCase()??null}s(gu,"readClaudeAccountKey");import{existsSync as XS,readFileSync as Ku,unlinkSync as qS}from"node:fs";import ZS from"node:http";import{join as Gu}from"node:path";import{randomBytes as mS}from"node:crypto";import{appendFileSync as gS,mkdirSync as _S,readdirSync as hS,readFileSync as ks,renameSync as Au,statSync as Fn,unlinkSync as xu}from"node:fs";import{homedir as St,tmpdir as SS}from"node:os";import{dirname as bs,join as Ht}from"node:path";var Su="EV_AI_PERF_L",Cs="EV_AI_PERF_H",Hn="EV_AI_RUN_ID",fS="EV_AI_HOOK_PERF";var dS=/^[a-z][a-z0-9_]{0,23}$/;var $r={origin:0,marks:{},values:{}},jr=!1;function yu(e=process.env){jr=e[fS]!=="0",$r.origin=performance.timeOrigin}s(yu,"startTimings");function Dn(){return jr}s(Dn,"timingsActive");function et(e,t=performance.now()){jr&&($r.marks[e]=t)}s(et,"mark");function Eu(){return $r}s(Eu,"ownTimings");function Ru(e){return Math.round(e*10)/10}s(Ru,"round1");function _u(e){return Object.entries(e).map(([t,n])=>`${t}=${Ru(n)}`).join(",")}s(_u,"entries");function pS(e){return`${Ru(e.origin)}|${_u(e.marks)}|${_u(e.values)}`}s(pS,"serializeTimings");function hu(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||!dS.test(o)||!(i>=0&&i<=36e5))return!1;t[o]=i}return Object.keys(t).length<=32}s(hu,"parseEntries");function As(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(!(!hu(n,a.marks)||!hu(r,a.values)))return a}s(As,"parseTimings");function Cu(){return jr?pS($r):void 0}s(Cu,"serializeOwnTimings");var yS="hooks-debug.log",ES=/^hooks-debug\.log\.\d+$/,RS=/^hooks-debug\.log(\.1)?\.send-\d+$/,bu="ev-ai-agent-hooks.log",CS="EV_AI_HOOK_RUN_LOG",nn="unlimited",AS="off",Os=1024*1024,bS=8*1024,ku=Os/2-bS,kS=10080*60*1e3,OS=1024*1024,xS="run-log-windows.json",IS=64*1024,xs=/^[a-z0-9]{8}$/,Ou="abcdefghijklmnopqrstuvwxyz0123456789",TS=/[^A-Za-z0-9._:/+-]/g,wS=128,yt={info(){},error(){}},Te=yt;function Kr(e=St()){return Ht(e,".ev-ai",yS)}s(Kr,"fileLogPath");function Iu(e){try{let t=JSON.parse(Qt(ks(Ht(e,".ev-ai","config.json"),"utf8")));return Dt(t)?t:void 0}catch{return}}s(Iu,"readHomeConfig");function PS(e){return e?.debug===!0}s(PS,"debugFromHomeConfig");function Is(e,t=!1){return e.includes("--debug")||t}s(Is,"isHookDebugEnabled");function Dt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(Dt,"isRecord");function NS(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===AS)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(NS,"localRunLog");function MS(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(MS,"scopeUntilMs");function Tu(e=St(),t=process.env,n=Date.now()){return wu(e,()=>Iu(e),t,n)}s(Tu,"readRunLogSwitch");function wu(e,t,n,r){let o=n[CS]?.trim().toLowerCase();if(o&&Nt.has(o))return{on:!0,source:"env",scopes:[]};if(o&&xr.has(o))return{on:!1,source:"env",scopes:[]};let i=NS(t(),r);if(i)return i;let a=[];try{let c=Ht(e,".ev-ai","agent-hook","hook-config.json"),u=Fn(c);if(!u.isFile()||u.size>OS)return{on:!1,source:"remote",scopes:a};let f=JSON.parse(ks(c,"utf8"));if(Dt(f))for(let[l,p]of Object.entries(f)){let d=MS(p);d&&d.untilMs>r&&a.push({scopeId:l,...d})}}catch{}return{on:a.length>0,source:"remote",scopes:a}}s(wu,"runLogSwitch");function Pu(e=St()){return Ht(e,".ev-ai","agent-hook",xS)}s(Pu,"runLogWindowsPath");function Ts(e=St()){try{let t=Pu(e),n=Fn(t);if(!n.isFile()||n.size>IS)return{};let r=JSON.parse(ks(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(Ts,"readRunLogWindows");function ws(e,t=St()){try{let n=Ts(t),r={...n};if(e(r),JSON.stringify(r)===JSON.stringify(n))return;ue(Pu(t),`${JSON.stringify(r,null,2)}
|
|
18
|
-
`)}catch{}}s(
|
|
19
|
-
`)},"write");
|
|
20
|
-
`).map(t=>t.trim()).filter(t=>t.startsWith("at ")).join(" | ")}s(
|
|
21
|
-
`)}catch(n){let r=n instanceof Error?n.message:String(n);R(`WARN: cursor cloud owner cache write failed open: ${r}`),v("cursor_cloud_owner_cache",n)}}s($u,"writeCacheFile");function by(e){try{qS(e)}catch{}}s(by,"removeCacheFile");function ky(e){switch(e){case"empty":return ay;case"forbidden":return cy;default:return uy}}s(ky,"missTtl");function Wu(e,t,n){let r=t-e;return r>=0&&r<n}s(Wu,"ageWithin");function ju(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,iy)}}s(ju,"sameBootOwner");function Oy(e,t,n){return e?.boot_id!==t||!e?!1:Wu(e.checked_at_ms,n,ky(e.status))}s(Oy,"isCursorCloudOwnerMissFresh");function xy(){try{return zr(Ku(ly,"utf8"))}catch{return null}}s(xy,"readLinuxBootId");var Bu=new Map;function Wr(e){let t=e.env??process.env,n=py(t),r=`${e.home}\0${n}`,o=Bu.get(r);if(o)return o;let i=Iy(n,e).catch(a=>(v("cursor_cloud_owner",a),null));return Bu.set(r,i),i}s(Wr,"resolveCursorCloudOwner");async function Iy(e,t){let n=my(t.home),r=gy(t.home),o=t.nowMs??Date.now(),i=(t.readBootId??xy)(),a=ju(Fu(n),i,o);if(a?.fresh)return a.owner;if(Oy(Ay(r),i,o)||!XS(e))return a?.owner??null;let c=await Ry(e,t.budgetMs);if(c.status==="ok"&&c.owner)return $u(n,{checked_at_ms:o,boot_id:i,user_email:c.owner.userEmail,user_id:c.owner.userId}),by(r),c.owner;let u=ju(Fu(n),i,o);return u?u.owner:($u(r,{checked_at_ms:o,boot_id:i,status:c.status==="ok"?"empty":c.status}),null)}s(Iy,"resolveUncached");import{existsSync as Py,readFileSync as Ny}from"node:fs";import{hostname as Xu,release as My,userInfo as vy,version as Ly}from"node:os";import*as Se from"node:os";import{performance as Ns}from"node:perf_hooks";var Ty=1024*1024,wy=128;function Jr(e){return Math.round(e/Ty)}s(Jr,"mb");function jn(e,t){let n=10**t;return Math.round(e*n)/n}s(jn,"round");function Ju(e=process.platform){try{let t=Ns.now(),n={},r=0,o=0,i=e!=="win32";for(let{times:u}of Se.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(Se.uptime()),n.mem_free_mb=Jr(Se.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=Jr(process.availableMemory())),e!=="win32"){let[u,f,l]=Se.loadavg();n.load_1m=jn(u??0,2),n.load_5m=jn(f??0,2),n.load_15m=jn(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=Ns.nodeTiming?.bootstrapComplete;return typeof c=="number"&&c>0&&(n.node_boot_ms=jn(c,1)),n.sample_us=Math.round((Ns.now()-t)*1e3),n}catch{return}}s(Ju,"sampleSys");function Yu(){try{let e=Se.cpus(),t={},n=typeof Se.availableParallelism=="function"?Se.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,wy);r&&(t.cpu_model=r);let o=Se.totalmem();t.mem_total_mb=Jr(o);let i=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof i=="number"&&i>0&&i<o&&(t.mem_limit_mb=Jr(i)),t.uptime_h=jn(Se.uptime()/3600,1),t}catch{return{}}}s(Yu,"hostSpecs");function on(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(on,"isTruthyFlag");function qu(e=process.env){return on(te("CURSOR_SANDBOX",e))}s(qu,"isCursorSandboxProcess");var Uy=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function Hy(e){return Uy.some(t=>!!te(t,e))}s(Hy,"hasManagedCiMarker");function Dy(e){if(te("KUBERNETES_SERVICE_HOST",e)||on(te("REMOTE_CONTAINERS",e))||on(te("DEVCONTAINER",e)))return!0;try{if(Py("/.dockerenv")||Ny("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}s(Dy,"hasContainerMarker");function Zu(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!te(t,e))}s(Zu,"hasIdeExtensionHostMarker");function Fy(e,t=process.platform){return Zu(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!te(n,e)):!1}s(Fy,"hasLocalIdeHostMarker");function $y(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}s($y,"isBackgroundComposerSessionId");function jy(e){return e==="linux"}s(jy,"isLinuxPlatform");function te(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return F(e)}s(te,"readContextEnv");function By(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!Ky(te("CURSOR_VERSION",n))}s(By,"isCursorCloudHostFingerprint");function Ky(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(Ky,"trimEnvLocal");function Ms(e){if($y(e.sessionId))return!0;let t=e.hostname??Xu(),n=e.osUser??el(e.env);return By(t,n,e.env)}s(Ms,"hasCursorCloudExclusiveEvidence");function Gy(e){return on(te("CURSOR_AGENT",e.env))?!0:Ms(e)}s(Gy,"hasCursorCloudEvidence");function Vy(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))||Zu(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!te(t,e))||te("SESSIONNAME",e))}s(Vy,"hasLocalSessionMarker");function Yr(e={}){let t=e.env;if(te("GITHUB_ACTIONS",t))return"github_actions";if(on(te("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!Fy(t,n)&&Gy(e)&&(on(te("CURSOR_AGENT",t))||jy(n)))return"cursor_cloud";if(te("CODESPACES",t)||te("CODESPACE_NAME",t))return"codespaces";if(te("GITLAB_CI",t))return"gitlab_ci";if(Hy(t))return"managed";let r=te("CI",t);return r&&r!=="false"&&r!=="0"?"managed":Dy(t)?"container":Vy(t)?"interactive":"unknown"}s(Yr,"detectContext");async function Qu(){return await re("systemd-detect-virt",[],1e3)}s(Qu,"detectVirt");function el(e=process.env,t=vy){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(el,"resolveHostUsername");var zy=32;function Wy(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,zy);return t.length>0?t:null}s(Wy,"sanitizeOsPlatform");function Jy(){try{return[Ly(),My()].filter(Boolean).join(" ").trim()}catch{return""}}s(Jy,"windowsVersion");async function tl(e=!1){let t=Wy(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=Jy():n=await re("ver",[],1e3);let r=el(),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?Yu():{}}}s(tl,"hostEnv");function vs(){return Xu()}s(vs,"hostName");import{existsSync as cO,readFileSync as Op,unlinkSync as uO}from"node:fs";import{homedir as ua}from"node:os";import{join as hn,resolve as lO}from"node:path";import{basename as eO,join as _n}from"node:path";import{dirname as fl,resolve as Qr}from"node:path";import{existsSync as Yy}from"node:fs";import{homedir as ol}from"node:os";import{relative as sl,resolve as je,sep as Rt}from"node:path";var Xy=["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"],qy=["prompt","tool_input","tool_response","last_assistant_message","command"],Zy=new Set;function Qy(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return Zy}}s(Qy,"excludedContentKeys");function Fs(e){let t=F("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?Nt.has(t.toLowerCase()):e?.collect_prompt===!0}s(Fs,"isPromptCaptureEnabled");function Xr(e,t){let n=il(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!==""?Nt.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}s(Xr,"promptCaptureSource");function il(e){return F("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||Is(process.argv,e.debug===!0)||F("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}s(il,"hookInputCaptureMode");function eE(e){let t={};for(let n of Xy){let r=Ze(e,n);r!==void 0&&(t[n]=r)}return t}s(eE,"allowlistedHookInput");function qr(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=je(e),r=je(t),o=sl(r,n);return!o||o==="."?".":o.startsWith(`..${Rt}`)||o===".."||je(r,o)!==n?null:o.split(Rt).join("/")}s(qr,"cwdRelativeToGitRoot");function al(e,t){let n=sl(je(t),je(e)).split(Rt).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}s(al,"specDirRelativeToCwd");function cl(e){return typeof e!="string"||e.length===0?null:je(e).split(Rt).join("/")}s(cl,"absoluteCwdForSend");function tE(){let e=F("CURSOR_PROJECT_DIR");if(!e)return null;let t=je(e);return Yy(t)?t.split(Rt).join("/"):null}s(tE,"cursorProjectDirAbs");function Us(e,t){return qr(e,t)!==null}s(Us,"isPathInside");function nE(e,t){let n=je(t??ol(),".cursor").split(Rt).join("/");return Us(e,n)}s(nE,"isCursorUserHookLaunch");function rE(e,t,n){return t!==null&&Us(e,t)?!0:t!==null&&nE(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&Us(e,n.gitRoot)?!0:t===null}s(rE,"shouldKeepProcessCwd");function ul(e,t){let n=cl(e.cwd);if(n!==null)return n;let r=je(process.cwd()).split(Rt).join("/"),o=tE();return rE(r,o,t)?r:o??r}s(ul,"resolvedCwdForSend");function $s(e,t={}){return ul(e,t)}s($s,"resolveLaunchCwd");function js(e,t=ol()){let n=je(t).split(Rt).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}s(js,"tildeHomeCwd");function nl(e,t,n){let r=cl(n.launchCwd)??ul(t,n);e.cwd=js(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?qr(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}s(nl,"attachCwdFields");var ll="\u2026[truncated]\u2026",Hs=Buffer.byteLength(ll,"utf8"),oE=8;function Bn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Bn,"jsonByteLength");function rl(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}s(rl,"utf8Head");function sE(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(sE,"utf8Tail");function iE(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=Hs)return rl(e,t);let r=t-Hs,o=Math.ceil(r/2),i=Math.floor(r/2);return`${rl(e,o)}${ll}${sE(e,i)}`}s(iE,"truncateHeadTail");function Ds(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)=>{Ds(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||Ds(o,[...t,r],n)}s(Ds,"collectStrings");function aE(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(aE,"setAtPath");var cE=256;function uE(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(uE,"stringBudgetFor");function lE(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let i=Bn(e);if(i<=t)return;let a=[];Ds(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=uE(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&&aE(e,l.path,iE(l.value,r))}}s(lE,"clampStringsToBudget");function fE(e,t){let n=Math.max(0,t-cE),r=Object.keys(e).filter(i=>!i.startsWith("_")).map(i=>({key:i,bytes:Bn(e[i])})).sort((i,a)=>a.bytes-i.bytes),o=[];for(let{key:i}of r){if(Bn(e)<=n)break;delete e[i],o.push(i)}o.length>0&&(e._dropped_keys=o.slice(0,10))}s(fE,"dropLargestKeys");function Ls(e,t){let n=Bn(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,lE(r,t,Hs+oE),Bn(r)>t&&fE(r,t),r}s(Ls,"fitWithinByteLimit");function dE(e,t,n){if(!(n.promptCapture??Fs()))return;let r=Qy(n.runnerEvent);for(let o of qy){if(r.has(o))continue;let i=t[o];i!==void 0&&(e[o]=i)}}s(dE,"attachContentFields");function Zr(e,t,n={}){let r=il(t);if(r==="full"){let i={...e};return delete i.cwd,delete i.transcript_path,nl(i,e,n),Ls(i,ys)}let o=eE(e);return nl(o,e,n),r==="content"?(dE(o,e,n),Ls(o,ys)):Ls(o,au)}s(Zr,"sanitizeHookInput");function pE(e){return typeof e=="string"&&e.length>0}s(pE,"hasOrigin");function Bs(e){let t=Qr(e.home),n=Qr(e.launchCwd),r=e.gitRoot?Qr(e.gitRoot):null,o=new Set,i=[],a=null;e.inGitRepo&&pE(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&&qr(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&u){let f=fl(r);for(;;){let l=Qr(f);if(l===t)break;let p=fl(l);if(p===l)break;if(e.hasProjectSpec(l)){i.push({scope:"parent",dir:l}),c=al(l,n);break}f=p}}return{anchors:i,parentRel:c}}s(Bs,"resolveProjectAnchors");import{existsSync as pl,readdirSync as _E,realpathSync as hE}from"node:fs";import{basename as SE,dirname as yE,relative as EE,resolve as RE,sep as CE}from"node:path";import{createHash as mE}from"node:crypto";import{resolve as gE}from"node:path";function q(e){return mE("sha256").update(e).digest("hex").slice(0,16)}s(q,"sha16");function Ks(e){return q(gE(e))}s(Ks,"dirScopeRef");function we(e,t){return`${e}\0${t}`}s(we,"componentKey");function eo(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}s(eo,"componentDeltaHash");function dl(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}s(dl,"parseComponentKey");function Kn(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(`
|
|
22
|
-
`);return q(n)}s(Kn,"hashUserSpec");var Gs=400,to=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??gt}static{s(this,"UserSpecContext")}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=RE(t).split(CE).join("/");return js(r,this.home)}let n=EE(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${q(yE(t))}/${SE(t)}`:n}claimFile(t){try{let n=hE(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(!pl(t))return[];try{return _E(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(pl(t))return ee(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 ci,readFileSync as VR,statSync as zR}from"node:fs";import{basename as ui,join as jt,relative as li}from"node:path";var kf=$e(bf());var KR=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],Of=KR.map(e=>kf.default.matcher(e,{dot:!0}));function GR(e){return e===""?!1:Of.some(t=>t(`${e}/`))}s(GR,"isExcludedDirPath");function xf(e,t){if(t==="")return!1;if(e==="")return GR(t);let n=e.replace(/\/+$/,"");return Of.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}s(xf,"isExcludedDirBelow");var fi=100*1024,WR=4;function JR(e){return e.length<=fi?e:`${e.slice(0,fi-1)}\u2026`}s(JR,"truncateContentText");function YR(e){try{let t=VR(e),n=t.toString("utf8");return{hash:q(t),length:t.length,text:JR(n)}}catch{return null}}s(YR,"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 XR(e){return e in If?If[e]:"UNSPECIFIED"}s(XR,"triggerForKind");function cn(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=YR(t.absolutePath);if(!n)return!1;let r=t.name??ui(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=XR(t.kind);return i&&(o.trigger=i),t.attributes&&(o.attributes=t.attributes),e.push(o)}s(cn,"addFile");function qR(e,t,n,r){let o=li(e,t).replace(/\\/g,"/"),i=!o||o.startsWith("..")?ui(t):o;return r&&i.toLowerCase().endsWith(r)?ui(i).slice(0,-r.length):n||i!==o?i.replace(/\.(md|mdc|toml)$/i,""):o}s(qR,"nameFromWalkRoot");function Bt(e,t){let{dir:n,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u}=t;di(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u})}s(Bt,"walkComponentDir");function di(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l}=t;if(!(o>WR))for(let p of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(p.isDirectory()&&xf(n.replace(/\\/g,"/"),li(n,jt(r,p.name)).replace(/\\/g,"/"))||p.isDirectory()&&l?.includes(jt(r,p.name)))continue;if(u){if(!p.isDirectory())continue;let h=jt(r,p.name,u);if(ci(h)){let E=li(n,jt(r,p.name)).replace(/\\/g,"/");cn(e,{absolutePath:h,kind:i,origin:a,enabled:c,name:E||p.name});continue}di(e,{walkRoot:n,currentDir:jt(r,p.name),depth:o+1,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l});continue}if(p.isDirectory()){di(e,{walkRoot:n,currentDir:jt(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(h=>d.endsWith(h)))continue;let m=jt(r,p.name),g=f.find(h=>h.split(".").length>2&&d.endsWith(h));cn(e,{absolutePath:m,kind:i,origin:a,enabled:c,name:qR(n,m,!0,g)})}}s(di,"walkRecursive");function Tf(e){for(let t of e)if(ci(t))try{if(zR(t).size>0)return t}catch{continue}return e.find(t=>ci(t))}s(Tf,"firstExistingFile");import{existsSync as ZR}from"node:fs";import{homedir as Pf}from"node:os";import{join as QR}from"node:path";function Nf(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}s(Nf,"hookParsableSettings");var eC={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 wf(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}s(wf,"concatOptional");function tC(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:wf(n.mcpJson,t.mcpJson),mcpToml:wf(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}s(tC,"layoutForScope");function Mf(e){return Object.fromEntries(Object.entries(eC).map(([t,n])=>[t,tC(n,n[e])]))}s(Mf,"layoutsForScope");var un=Mf("homeOnly"),At=Mf("projectOnly");function nC(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}s(nC,"layoutRelativePaths");function rC(e,t){return nC(e).some(n=>ZR(QR(t,n)))}s(rC,"layoutHasAnyEntry");function vf(e,t){for(let n of e)if(rC(n,t))return!0;return!1}s(vf,"anyLayoutHasAnyEntry");function Ct(e){return[...new Set(e)]}s(Ct,"uniqueRels");function bt(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:Ct(t),subagents:Ct(n),commands:Ct(r),rules:Ct(o),memory:Ct(i),settings:Ct(a),mcp:Ct(c)}}s(bt,"userScopePathsFromLayouts");function oC(e,t=Pf(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...Fr(o.managed,n,t));return Ct(r)}s(oC,"managedSettingsFromLayouts");var kt=bt(Object.values(un));function Lf(e=Pf(),t=process.platform){return oC(Object.values(un),e,t)}s(Lf,"userScopeManagedSettings");import{existsSync as Fk,readFileSync as $k}from"node:fs";import{basename as jk}from"node:path";function de(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(de,"isRecord");var go=$e(Ge(),1);var j="<omitted>",NA=["package_name","package_spec","package_version","package_version_source"],cd=100,ud=120,dn=[{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"}],ld=new Set(dn.map(e=>e.attr)),MA=["enabled","disabled"],vA=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],LA=new Set(["type","command","url","args","env","envVars","headers",...MA,...vA,...dn.map(e=>e.raw)]),UA=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",...NA,...ld,...[...ld].map(e=>`${e}_truncated`)]);function fd(e,t){for(let n of t)LA.has(n)||UA.has(n)||(e[n]=j)}s(fd,"addOmittedKeys");var HA=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,DA=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,FA=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,$A=/^bearer(?:\s+|$)/i;function Kt(e){return FA.test(e)||$A.test(e)}s(Kt,"isSecretShapedValue");var dd=/^(?:--headers?|-H)$/,pd=/^\s*([A-Za-z0-9-]+)\s*:([\s\S]*)$/,jA=/auth|cookie|token|secret|key|passw|credential|session|signature/i,BA=/^(?:(?:bearer|basic|token)\s+)?\$(?:\{\w+\}|\w+)$/i;function Ri(e){return jA.test(e)}s(Ri,"isAuthHeaderName");function _o(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}s(_o,"asRecord");function md(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}s(md,"stringList");function Si(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=_o(e);return t?Object.keys(t).filter(n=>n.length>0):[]}s(Si,"envNamesFromValue");function it(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}s(it,"redactCommandOrUrl");function Ci(e){return/[@\\]/.test(e)?j:(e.split(/[?#]/,1)[0]??"").trim()}s(Ci,"redactUrlText");function KA(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,go.launchContainsCredentials)({kind:"url",url:e})||(0,go.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=Ve([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,go.launchContainsCredentials)({kind:"url",url:r}):!0)}s(KA,"rawLaunchHadCredentials");function gd(e,t,n){KA(t,n)&&(e.launch_had_credentials=!0)}s(gd,"markLaunchCredentials");function GA(e){return Kt(e)?"<redacted>":e.includes("://")?it(e):e}s(GA,"redactSecretShapedValue");function _d(e){let t=pd.exec(e);if(!t)return Ai(e);let n=t[1]??"",r=(t[2]??"").trim();return BA.test(r)?e:Ri(n)||Kt(r)?`${n}: <redacted>`:e}s(_d,"redactHeaderArg");function Ai(e){if(/^https?:\/\//i.test(e))return it(e);let t=e.indexOf("=");if(t>0){let n=e.slice(0,t),r=e.slice(t+1);return`${n}=${dd.test(n)?_d(r):Ai(r)}`}return GA(e)}s(Ai,"redactArg");function bi(e){return HA.test(e)||DA.test(e)}s(bi,"isAuthKeyName");function VA(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return bi(t)}s(VA,"authArgKey");function Ve(e){let t=[],n=!1,r=!1;for(let o of e){if(n){t.push("<redacted>"),n=!1;continue}if(r&&(r=!1,pd.test(o))){t.push(_d(o));continue}if(dd.test(o)){t.push(o),r=!0;continue}if(VA(o)){t.push("<redacted>"),n=!o.includes("=");continue}t.push(Ai(o))}return t}s(Ve,"redactArgs");function zA(e){let t=md(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>ud?r.slice(0,ud):r))].sort();if(n.length!==0)return n.length>cd?{names:n.slice(0,cd),truncated:!0}:{names:n,truncated:!1}}s(zA,"toolNameList");function WA(e){let t=_o(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(WA,"envHeaderNames");function hd(e,t){let n=new Set;for(let{raw:r,attr:o}of dn){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=zA(i);a&&(e[o]=a.names,a.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}s(hd,"applyToolListAttributes");function Sd(e,t){let n=_o(e),r={transport:t};if(!n)return r;fd(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=md(n.args);c&&(r.command_or_url=it(c));let f=Ve(u);f.length>0&&(r.args=f),gd(r,c,u);let l=WA(n.env_http_headers),p=[...new Set([...Si(n.env),...Si(n.envVars),...Si(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),hd(r,n),r}s(Sd,"sanitizeMcpServerAttributes");function yd(e){let t=_o(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}s(yd,"mcpServerEnabledFromJson");function ki(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(ki,"hashSanitizedMcpAttributes");function fn(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}s(fn,"parseTomlQuoted");function qn(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(qn,"parseTomlPlainStringArray");function Ei(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}s(Ei,"parseTomlBoolean");function yi(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=fn(n[1]);return r.length>0?r:void 0}s(yi,"parseTomlScalarString");function JA(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],fn(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(`
|
|
23
|
-
${e}`);return i?.[1]&&r(i[1]),n}s(
|
|
24
|
-
`)){let i=
|
|
25
|
-
`)){let
|
|
26
|
-
${e}`);if(d?.[1])for(let
|
|
27
|
-
`)){let w=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(k);w?.[1]&&l.add(w[1])}for(let k of qn(e,"env_vars"))l.add(k);let m=JA(e,"env_http_headers");for(let[,k]of m)k.length>0&&l.add(k);let g=yi(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(([k])=>k))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let h=yi(e,"auth");h&&(n.auth=h);let E=yi(e,"default_tools_approval_mode");return E&&(n.default_tools_approval_mode=E),YA(n,e),n}s(Rd,"parseTomlMcpSection");var QA=300,eb=256;function Cd(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(Cd,"rewriteHomePrefix");function Gt(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(Gt,"tokenizeCommand");function Ad(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}s(Ad,"capLength");function tb(e){return Ad(e,QA)}s(tb,"capCommand");function bd(e,t){let n=Cd(e.trim(),t),r=Gt(n);if(r.length===0)return"";let[o,...i]=r,a=it(o),c=Ve(i);return tb([a,...c].join(" "))}s(bd,"sanitizeHookCommand");function kd(e,t){if(typeof e!="string")return null;let n=Cd(e.trim(),t),r=Gt(n)[0];if(!r)return null;let o=it(r);return o.length===0?null:Ad(o,eb)}s(kd,"executableFromCommand");import{existsSync as ib}from"node:fs";var nb=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,Oi="<path>",rb=new RegExp(`${Oi}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function ho(e){let t=e.replace(nb,Oi).replace(rb,Oi);return t.length>200?`${t.slice(0,200)}...`:t}s(ho,"redactPermissionKey");function ob(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(ob,"classifyActionKind");function sb(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(sb,"normalizeHookActions");function xi(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 sb(u)){if(e.truncated)return;let l=f.command??f.bash??f.prompt??f.powershell??u.powershell??"",p=ob({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}`,h=`${i}|${d}|${p}|${l}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:q(h),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:i,...d?{matcher:d}:{},action_kind:p,action_hash:m,...p!=="prompt"&&l.trim()?{command:bd(l,e.home)}:{}}})}}}s(xi,"collectHooksFromObject");function Ii(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||xi(e,t,r.hooks,n)}s(Ii,"collectHooksFile");var Od=200,xd=200,Ti=16*1024,Id=6,ab=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","allowedMcpServers","deniedMcpServers","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),cb=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),ub=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),lb=new Set(["permissions","approvalMode"]),fb={claude:ab,cursor_sandbox:cb,cursor_permissions:ub,cursor_cli:lb},db=new Set(["allow","deny","ask"]),pb=new Set(["allowedMcpServers","deniedMcpServers"]);function at(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(at,"isRecord");function So(e){return e.replace(/\\/g,"/")}s(So,"posixPath");function wi(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>wi(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${wi(t[r])}`).join(",")}}`}s(wi,"canonicalJson");function mb(e){return q(`${wi(e)}|settings1`)}s(mb,"hashSettingsAttributes");function Md(e){let t=So(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(Md,"settingsProfileFor");function vd(e,t){if(e!=="claude")return{};let n=So(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(vd,"managedSettingsMeta");function Ld(e){let t=So(e).replace(/\/+$/,"");return t.length<=1?"":t}s(Ld,"homePosix");function Ud(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}s(Ud,"isWindowsHome");function Mi(e,t){let n=So(e);if(n==="~"||n.startsWith("~/"))return n;let r=Ld(t);if(!r)return n;let o=n.slice(0,r.length);if(!(Ud(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let a=n.slice(r.length);return a===""?"~":a.startsWith("/")?`~${a}`:n}s(Mi,"tildePath");var Td=new Map;function gb(e){let t=Td.get(e);if(t!==void 0)return t;let n=Ld(e),r=null;if(n){let o=n.split("/").map(i=>i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,Ud(e)?"gi":"g")}return Td.set(e,r),r}s(gb,"homeTextPattern");function vi(e,t){let n=gb(t);return n?e.replace(n,"~"):e}s(vi,"tildeHomeInText");function wd(e,t){return e.length<=xd?e:(t.truncated=!0,e.slice(0,xd))}s(wd,"capString");function Li(e,t){return e.length<=Od?e:(t.truncated=!0,e.slice(0,Od))}s(Li,"capArray");function ce(e,t,n,r){if(typeof e=="string"){if(t==="path")return wd(Mi(e,n),r);let o=t==="rule"?ho(e):e;return wd(vi(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=Li(e,r),i=[];for(let a of o){let c=ce(a,t,n,r);c!==void 0&&i.push(c)}return i}if(at(e)){let o={};for(let[i,a]of Object.entries(e)){let c=ce(a,t,n,r);c!==void 0&&(o[i]=c)}return o}}s(ce,"transformValue");function Pd(e,t,n){if(!at(e))return ce(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a="plain";db.has(o)?a="rule":o==="additionalDirectories"&&(a="path");let c=ce(i,a,t,n);c!==void 0&&(r[o]=c)}return r}s(Pd,"transformPermissions");function _b(e,t,n){if(!at(e))return ce(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){if(o==="files"&&Array.isArray(i)){let c=Li(i,n);r[o]=c.map(u=>{if(!at(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 a=ce(i,"plain",t,n);a!==void 0&&(r[o]=a)}return r}s(_b,"transformCredentials");function hb(e,t,n){if(!at(e))return ce(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let c=ce(i,o==="allowUnixSockets"?"path":"plain",t,n);c!==void 0&&(r[o]=c)}return r}s(hb,"transformNetwork");function Sb(e,t,n){if(!at(e))return ce(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a;o==="excludedCommands"?a=ce(i,"rule",t,n):o==="filesystem"?a=ce(i,"path",t,n):o==="network"?a=hb(i,t,n):o==="credentials"?a=_b(i,t,n):a=ce(i,"plain",t,n),a!==void 0&&(r[o]=a)}return r}s(Sb,"transformSandbox");var yb=/[a-z][a-z0-9+.-]+:[\\/]/i;function Eb(e){let[t,...n]=e.filter(r=>typeof r=="string"&&r.length>0);return t===void 0?[]:[t,...Ve(n)].map(r=>yb.test(r)?Ci(r):r)}s(Eb,"redactServerCommand");function Rb(e){if(!at(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]=Ci(r):n==="serverCommand"&&Array.isArray(r)?t[n]=Eb(r):t[n]=j;return t}s(Rb,"sanitizeMcpServerMatcher");function Cb(e,t,n){if(!Array.isArray(e))return j;let r=Li(e,n).map(Rb);return ce(r,"plain",t,n)}s(Cb,"transformMcpServerMatchers");function Ab(e,t,n,r,o){return n==="claude"?e==="permissions"?Pd(t,r,o):e==="sandbox"?Sb(t,r,o):pb.has(e)?Cb(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"?Pd(t,r,o):ce(t,"plain",r,o)}s(Ab,"transformByProfile");function Zn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Zn,"jsonBytes");function Pi(e,t){return e?`${e}.${t}`:t}s(Pi,"childPath");function Ni(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>=Id?(e.splice(o,1),r.add(n)):Ni(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>=Id?(delete e[o],r.add(Pi(n,o))):Ni(i,t+1,Pi(n,o),r))}s(Ni,"pruneDepth");function Hd(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:Zn(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))Hd(o,Pi(t,r),n)}s(Hd,"collectTrimCandidates");function bb(e,t,n){let r=Zn(e);if(r<=Ti)return;t.truncated=!0;let o=[];for(Hd(e,"",o);r>Ti;){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=Zn(a)+(i.items.length>0?1:0);i.bytes-=c,r-=c,n.add(i.path)}for(;Zn(e)>Ti;){let i,a=-1;for(let[c,u]of Object.entries(e)){let f=Zn(u);f>a&&(i=c,a=f)}if(i===void 0)break;delete e[i],n.add(i)}}s(bb,"fitSettingsJson");function kb(e,t,n){let r=fb[t],o={truncated:!1},i={},a=[];for(let u of Object.keys(e)){if(!r.has(u)){a.push(u);continue}let f=Ab(u,e[u],t,n,o);f!==void 0&&(i[u]=f)}a.sort();let c=new Set;return Ni(i,1,"",c),c.size>0&&(o.truncated=!0),bb(i,o,c),{settings:i,keys_omitted:a,truncated:o.truncated,trimmed_paths:[...c].sort()}}s(kb,"extractSettingsPosture");function Nd(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:mb(t.attributes),attributes:t.attributes};e.push(n)}s(Nd,"pushPostureRow");function Ui(e,t,n,r){if(!e.claimFile(t)||!ib(t))return;let o=Kc(t);if(!o.ok||!at(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),Nd(e,{kind:r.kind,absPath:t,origin:n,attributes:l})}return}let i=o.value,a=i.hooks;if(at(a)&&xi(e,t,a,n),!r.profile)return;let c=kb(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),Nd(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}s(Ui,"collectSettingsFile");var pe="<redacted>",Ob=new Set(["stdio","http","sse","ws","sdk","streamable-http","streamableHttp","local","remote"]),xb={CLIENT_ID:"keep",CLIENT_SECRET:"secret",scopes:"string_list",redirectPort:"keep"},Ib={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"},Bd={filesystem:{object:{allowWrite:"path",denyRead:"path",denyWrite:"path"}},network:{object:{allowedDomains:"string_list",deniedDomains:"string_list"}}},Tb={watch:"path",debug:{object:{type:"keep",debugpyPath:"path"}}},wb={headers:"secret_map",proxy:"url",caBundlePath:"path",timeout:"keep",verifySsl:"keep",noProxy:"string_list",extraBodyProperties:"omit",clientCertificate:{object:{cert:"omit",key:"omit",passphrase:"secret"}}},Pb={startup:"keep",catalog:"keep",execution:"keep"},Nb={approval_mode:"keep",output_token_limit:"keep"},Mb={id:"keep",type:"keep",password:"keep",command:"keep",serverName:"keep",description:"omit",options:"omit",args:"omit",default:"secret"},vb={type:"transport_type",command:"command",args:"args",cwd:"path",env:"secret_map",url:"url",headers:"secret_map"},Lb=Object.fromEntries(dn.map(({raw:e})=>[e,"tool_list"])),Ub={...Lb,type:"transport_type",transportType:"keep",transport:{by:{string:"keep",object:{object:vb}}},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:Tb},sandboxEnabled:"keep",sandbox:{object:Bd},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:wb},auth:{by:{string:"mode",object:{object:xb}}},oauth:{by:{boolean:"keep",object:{object:Ib}}},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:Nb}}}},includeTools:"tool_list",excludeTools:"tool_list",omit_tools_from:"tool_list",default_tools_approval_mode:"keep",defaultToolsApprovalMode:"keep",timeout:{by:{number:"keep",object:{object:Pb}}},startup_timeout_sec:"keep",startup_timeout_ms:"keep",tool_timeout_sec:"keep",connectionTimeout:"keep"};function Hb(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(Hb,"shapeOf");var Db=/^[A-Za-z_][A-Za-z0-9_]*$/,Fb=[/\$\{(?: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],Hi=/\$\{([A-Za-z_][A-Za-z0-9_]*):-[^}]*\}/y;function Dd(e){let t="",n=0;for(;n<e.length;){Hi.lastIndex=n;let r=Hi.exec(e);if(r){t+=`\${${r[1]??""}:-${pe}}`,n=Hi.lastIndex;continue}let o=!1;for(let i of Fb){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 Vt(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(Vt,"sanitizeVariableReference");function Qn(e,t){return t.home?vi(e,t.home):e}s(Qn,"tildeText");function Eo(e){return Kt(e)||e.split(/[\s=,;:'"]+/).some(Kt)}s(Eo,"containsSecretShapedToken");function Kd(e,t){return Eo(e)?pe:e.includes("://")?zd(e,t):Qn(e,t)}s(Kd,"keepString");var $b=/^[A-Za-z][A-Za-z_-]{0,31}$/;function jb(e){return typeof e!="string"?j:$b.test(e)&&!Kt(e)?e:pe}s(jb,"sanitizeMode");function Bb(e,t){return typeof e=="string"?Kd(e,t):typeof e=="number"?Number.isFinite(e)?e:j:typeof e=="boolean"||e===null?e:j}s(Bb,"keepScalar");function Fd(e){return typeof e!="string"?j:/[\s=]/.test(e)||Eo(e)?pe:e}s(Fd,"toolName");function Kb(e){return typeof e=="boolean"?e:typeof e=="string"?Fd(e):Array.isArray(e)?e.map(t=>Fd(t)):j}s(Kb,"sanitizeToolList");function Gb(e,t){return Array.isArray(e)?e.map(n=>typeof n=="string"?Kd(n,t):j):j}s(Gb,"sanitizeStringList");function Vb(e){return Ri(e)||bi(e)}s(Vb,"isCredentialHeaderName");var Di=/(^|[\s"'=,;])([A-Za-z][A-Za-z0-9_-]*)(\s*:\s*)/g;function Gd(e){let t="",n=0;Di.lastIndex=0;let r;for(;(r=Di.exec(e))!==null;){let o=r[2]??"",i=r.index+r[0].length;if(!Vb(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+=Vt(u)??pe,n=c,Di.lastIndex=c)}return t+e.slice(n)}s(Gd,"redactCredentialHeaders");var Vd=/\b(bearer|basic|token)(\s+)([^\s"']+)/gi;function zb(e){for(let t of e.matchAll(Vd))if(Vt(t[3]??"")===null)return!0;return!1}s(zb,"hasLiteralAuthScheme");function Wb(e){let t=Gd(e);return zb(t)?pe:t}s(Wb,"redactCredentialArg");function Jb(e){return Gd(e).replace(Vd,(t,n,r,o)=>Vt(o)===null?`${n}${r}${pe}`:t)}s(Jb,"redactCredentialCommandLine");function Yb(e){return e.map(t=>/\s/.test(t)?t.includes('"')&&!t.includes("'")?`'${t}'`:`"${t}"`:t).join(" ")}s(Yb,"joinCommandTokens");function $i(e,t){if(typeof e!="string")return j;let n=Gt(Jb(e));return n.length===0?e:Qn(Yb(Ve(n)),t)}s($i,"sanitizeCommand");function Xb(e,t){if(typeof e=="string"){let n=Vt(e);if(n!==null)return n;let r=Gt(e),[o]=r;if(o===void 0)return e;let i=$i(o,t);return r.length>1?`${String(i)} ${pe}`:i}return Array.isArray(e)?e.map((n,r)=>r===0?$i(n,t):pe):j}s(Xb,"sanitizeHelperCommand");function qb(e,t){if(!Array.isArray(e))return j;let n=[],r=[];e.forEach((a,c)=>{typeof a=="string"&&(n.push(c),r.push(a))});let o=Ve(r),i=e.map(()=>j);return n.forEach((a,c)=>{i[a]=Qn(Wb(o[c]??pe),t)}),i}s(qb,"sanitizeArgs");function Zb(e){try{return new URL(e).href.length>0}catch{return!1}}s(Zb,"canParseUrl");function Fi(e){return e.split("/").map(t=>Eo(t)?pe:t).join("/")}s(Fi,"redactSecretPathSegments");function zd(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 Qn(Fi(`${m}${d}`),t)}if(/^(?:https?|wss?):/i.test(e)&&Zb(e))return Fi(it(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(Fi(f),t)}s(zd,"sanitizeUrl");function Wd(e){return e===null?null:typeof e=="string"?Vt(e)??pe:pe}s(Wd,"sanitizeSecret");function yo(e){return typeof e!="string"?j:Db.test(e)&&!Kt(e)?e:pe}s(yo,"envName");function Qb(e){if(Array.isArray(e))return e.map(n=>{if(typeof n!="string")return j;let r=n.indexOf("=");if(r===-1)return yo(n);let o=n.slice(0,r);return yo(o)!==o?pe:`${o}=${Vt(n.slice(r+1))??pe}`});if(!de(e))return j;let t={};for(let[n,r]of Object.entries(e))t[n]=Wd(r);return t}s(Qb,"sanitizeSecretMap");function ek(e){if(!de(e))return j;let t={};for(let[n,r]of Object.entries(e))t[n]=yo(r);return t}s(ek,"sanitizeEnvNameMap");function $d(e,t){return Eo(e)?pe:t.home?Mi(e,t.home):e}s($d,"pathString");function tk(e,t){return typeof e=="string"?$d(e,t):Array.isArray(e)?e.map(n=>typeof n=="string"?$d(n,t):j):j}s(tk,"sanitizePath");function Jd(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?j:pn(i,a,n)}return r}s(Jd,"sanitizeObject");function nk(e,t,n){switch(t){case"keep":return Bb(e,n);case"transport_type":return typeof e=="string"&&Ob.has(e)?e:j;case"mode":return jb(e);case"string_list":return Gb(e,n);case"tool_list":return Kb(e);case"command":return $i(e,n);case"helper_command":return Xb(e,n);case"args":return qb(e,n);case"url":return zd(e,n);case"secret":return Wd(e);case"secret_map":return Qb(e);case"env_name":return yo(e);case"env_name_map":return ek(e);case"path":return tk(e,n);case"omit":return j}}s(nk,"applyLeaf");function pn(e,t,n){if(typeof t=="string")return nk(e,t,n);if("object"in t)return de(e)?Jd(e,t.object,n):j;if("map"in t){if(!de(e))return j;let i={};for(let[a,c]of Object.entries(e))i[a]=pn(c,t.map,n);return i}if("list"in t)return Array.isArray(e)?e.map(i=>pn(i,t.list,n)):j;let r=Hb(e),o=r===void 0?void 0:t.by[r];return o===void 0?j:pn(e,o,n)}s(pn,"applyTreatment");function jd(e,t){if(!de(e))return j;let n={};for(let[r,o]of Object.entries(e))n[r]=de(o)?Jd(o,Ub,t):j;return n}s(jd,"sanitizeServers");function ji(e){return e==="vscode_mcp_json"?"servers":"mcpServers"}s(ji,"mcpConfigServersKey");function Yd(e,t,n={}){if(!de(e))return{};let r=ji(t);if(t==="claude_json_slice")return Object.hasOwn(e,r)?{[r]:jd(e[r],n)}:{};let o={};for(let[i,a]of Object.entries(e))i===r?o[i]=jd(a,n):t==="vscode_mcp_json"&&i==="inputs"?o[i]=pn(a,{list:{object:Mb}},n):t==="vscode_mcp_json"&&i==="sandbox"?o[i]=pn(a,{object:Bd},n):o[i]=j;return o}s(Yd,"sanitizeMcpConfigFile");var We=$e(Ge(),1);import{createHash as Nk}from"node:crypto";import{join as tr}from"node:path";var ze=$e(Ge(),1);import{realpathSync as np}from"node:fs";import{basename as gn,dirname as er,isAbsolute as Ak,join as Wi,resolve as rp,sep as bk}from"node:path";var mn=$e(Ge(),1);import{closeSync as rk,constants as Xd,fstatSync as ok,openSync as sk,readSync as ik,statSync as ak}from"node:fs";import{dirname as qd,join as Bi,relative as ck,sep as uk}from"node:path";var Zd="node_modules",lk=".yarn-state.yml",fk=".package-lock.json",ep=16*1024*1024,dk=64,pk=Xd.O_RDONLY|(process.platform==="win32"?0:Xd.O_NONBLOCK);function Ro(e,t){try{let n=ak(e);if(!n.isFile()||n.size>t)return null;let r=sk(e,pk);try{let o=ok(r);if(!o.isFile()||o.size>t)return null;let i=Buffer.alloc(o.size+1),a=0;for(;a<i.length;){let u=ik(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{rk(r)}}catch{return null}}s(Ro,"readBoundedTextFile");function Qd(e){if(!e.startsWith('"'))return null;try{let t=JSON.parse(e);return typeof t=="string"?t:null}catch{return null}}s(Qd,"parseJsonString");var mk="1";function gk(e){let t=new Map,n=null,r=!1,o=!1,i=null;for(let a of e.split(`
|
|
28
|
-
`)){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=
|
|
29
|
-
`);return Nk("sha512").update(t).digest("hex").slice(0,16)}s(vk,"npxCacheKey");function Lk(e){let t=process.platform==="win32"?tr(F("LOCALAPPDATA")??e,"npm-cache"):tr(e,".npm"),n=F("npm_config_cache")??F("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}s(Lk,"npmCacheRoots");function sp(e){return typeof e=="string"&&e.length>0&&e.length<=We.PACKAGE_FIELD_MAX?e:null}s(sp,"usableVersion");function Uk(e,t,n){let r=vk(e);for(let o of Lk(n)){let i=tr(o,"_npx",r),a=ee(tr(i,"node_modules",...t.split("/"),"package.json"),{}),c=sp(a.version);if(c!==null)return c;let u=ee(tr(i,"package-lock.json"),{}),f=sp(u.packages?.[`node_modules/${t}`]?.version);if(f!==null)return f}return null}s(Uk,"installedVersion");function Hk(e){return e.length<=We.PACKAGE_FIELD_MAX?e:`${e.slice(0,We.PACKAGE_FIELD_MAX-1)}\u2026`}s(Hk,"capField");function Dk(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,We.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let i=(0,We.packageNameFromSpec)(o);return i===null?null:{package_name:i,package_spec:Hk(o),...Mk(o,Uk(r,i,n))}}s(Dk,"resolveNpxPackage");function Ji(e,t,n){return Dk(e,t,n)??op(e,n)}s(Ji,"resolveMcpLaunchPackage");function ip(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=Gt(e.trim());return n===void 0?null:Ji(n,r,t)}s(ip,"resolveNpxPackageFromCommand");function Co(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 Ji(typeof n.command=="string"?n.command:null,r,t)}s(Co,"npxPackageFromMcpConfig");function ap(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:Ji(fn(n[1]??""),qn(e,"args"),t)}s(ap,"npxPackageFromTomlSection");function Bk(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(Bk,"mcpTransport");function Kk(e){return/(?:^|[\\/])\.vscode[\\/]mcp\.json$/i.test(e)}s(Kk,"isVsCodeMcpJson");function Gk(e){return Kk(e)?"vscode_mcp_json":jk(e)===".claude.json"?"claude_json_slice":"mcp_json"}s(Gk,"mcpConfigFormat");var Vk=64*1024;function cp(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,void 0);if(!de(r))return;let o=Gk(t),i=ji(o),a=r[i],c=a&&typeof a=="object"?a:{},u=e.componentPath(t),f=[];for(let[l,p]of Object.entries(c)){if(e.truncated)return;let d=Bk(p),m=Sd(p,d);Object.assign(m,Co(p,e.home)??{});let g=yd(p),h=ki(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(c,u)||zk(e,{parsed:r,format:o,pathRel:u,origin:n,serverHashes:f})}s(cp,"collectMcpJson");function zk(e,t){let n=Yd(t.parsed,t.format,{home:e.home}),r=JSON.stringify(n,null,2),o=Buffer.byteLength(r,"utf8"),i=o>Vk,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:!0,attributes:{format:t.format,server_count:t.serverHashes.length,...i?{text_omitted:"too_large"}:{}}})}s(zk,"pushMcpConfigRow");function up(e,t,n){if(!Fk(t)||!e.claimFile(t))return;let r;try{r=$k(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=Rd(l,p);Object.assign(d,ap(l,e.home)??{});let m=Ed(l);e.push({kind:"MCP_SERVER",name:c,path:o,content_hash:ki(c,d,m),origin:n,enabled:m,attributes:d})}}s(up,"collectCodexMcpToml");import{existsSync as Wk,readdirSync as Jk}from"node:fs";import{join as Ce}from"node:path";var lp=50;function nr(e,t,n,r){if(!Wk(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:i}=e.withPluginExpandCap(lp,()=>{Bt(e,{dir:Ce(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),Bt(e,{dir:Ce(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),Bt(e,{dir:Ce(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});Ii(e,Ce(t,"hooks","hooks.json"),n),Ii(e,Ce(t,"hooks.json"),n);let a=e.components.length-o,c=i>=lp;return{componentCount:a,expandTruncated:c}}s(nr,"expandPluginTree");function rr(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(rr,"addPluginRow");function Yi(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(Yi,"readEnabledPlugins");function Yk(e){let t=Yi(e.readJson(Ce(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=Un(process.platform,e.home),o=e.readJson(n,{}),i={};if(o&&Object.keys(o).length>0)i=Yi(o);else for(let a of r)Object.assign(i,Yi(e.readJson(a,{})));return{...t,...i}}s(Yk,"resolveClaudeEnabledPlugins");function fp(e){let t=Ce(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=Yk(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}`,h=0,E=!1;for(let k of u)if(typeof k.installPath=="string"&&k.installPath.length>0){let w=nr(e,k.installPath,g,l);h+=w.componentCount,E=E||w.expandTruncated}rr(e,{pluginKey:a,rowPath:i,enabled:l,scope:m,version:d||void 0,marketplace:p||void 0,componentCount:h,expandTruncated:E,contentHash:q(`${a}|${d}|${m}|${l}|${h}`)})}}s(fp,"collectClaudePlugins");function Xk(e){let t=e,n="";try{let r=Jk(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=Ce(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),i=o[o.length-1];i&&(t=Ce(e,i),n=i)}}catch{}return{installPath:t,version:n}}s(Xk,"pickVersionDir");var qk=/^\d+$/;function Zk(e){let t=e.filter(n=>!qk.test(n.pluginId));return t.length>0?t:e}s(Zk,"dedupeCursorCachePlugins");function dp(e){let t=[{base:Ce(e.home,".cursor/plugins/local"),scope:"local"},{base:Ce(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=Ce(n,o.name),f=`plugin:${c}`,{componentCount:l,expandTruncated:p}=nr(e,u,f,!0);rr(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(Ce(n,i))){if(!c.isDirectory())continue;let u=Ce(n,i,c.name),{installPath:f,version:l}=Xk(u);a.push({pluginId:c.name,installPath:f,version:l})}for(let c of Zk(a)){if(e.truncated)break;let u=`${c.pluginId}@${i}`,f=`plugin:${u}`,{componentCount:l,expandTruncated:p}=nr(e,c.installPath,f,!0);rr(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");import{existsSync as Qk}from"node:fs";import{join as Je}from"node:path";var pp=".claude/skills/synced",mp=".claude/plugins/synced";function gp(e){return[Je(e,pp),Je(e,mp)]}s(gp,"claudeSyncedDirs");function Ao(e){return typeof e=="string"&&e.length>0?e:void 0}s(Ao,"stringField");function _p(e){let t=Je(e.home,pp);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()||!Qk(c))continue;let u=i.get(a.name),f=Ao(u?.source),l=Ao(u?.creatorType);cn(e,{absolutePath:c,kind:"SKILL",origin:"user",enabled:!0,name:a.name,attributes:{scope:"synced",...f?{source:f}:{},...l?{creator_type:l}:{}}})}}}s(_p,"collectClaudeSyncedSkills");function hp(e){let t=Je(e.home,mp);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=Ao(c?.marketplaceName),f=Ao(c?.version),l=u?`${a.name}@${u}`:a.name,p=Je(r,a.name),{componentCount:d,expandTruncated:m}=nr(e,p,`plugin:${l}`,!0);rr(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(hp,"collectClaudeSyncedPlugins");function tO(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:i}=t;for(let a of n.skillRoots)Bt(e,{dir:_n(r,a),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:gp(e.home)});for(let a of n.dirs)Bt(e,{dir:_n(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=>_n(r,u)));c&&cn(e,{absolutePath:c,kind:"MEMORY",origin:o,enabled:!0,name:eO(c)})}for(let a of Nf(n))Ui(e,_n(r,a),o,{kind:"SETTINGS",profile:Md(a)});for(let a of n.mcpJson??[])cp(e,_n(r,a),o);for(let a of n.mcpToml??[])up(e,_n(r,a),o);if(i){if(n.managed){for(let a of Fr(n.managed,process.platform,e.home))if(a.toLowerCase().endsWith(".json")){let c=vd(n.managed,a);Ui(e,a,o,{kind:"MANAGED_SETTINGS",...c})}}n.plugins==="claude"?(fp(e),hp(e),_p(e)):n.plugins==="cursor"&&dp(e)}}s(tO,"walkPlatformLayout");function Sp(e,t){try{let n=new to(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)tO(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){v("user_spec_scope",n);return}}s(Sp,"walkScope");function Xi(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let u=Sp(t,{layouts:Object.values(un),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:gt,scopeRef:""});u&&(r.user=u)}let i=n.inGitRepo===!0,a=null,c=n.launchCwd;if(c!==void 0){let u=Object.values(At),f=Bs({launchCwd:c,gitRoot:n.gitRoot,inGitRepo:i,remote:n.remote,home:t,hasProjectSpec:s(l=>vf(u,l),"hasProjectSpec")});a=f.parentRel;for(let l of f.anchors){let p=Ks(l.dir);if(o!==void 0&&!o(l.scope,p))continue;let d=Sp(t,{layouts:u,levelDir:l.dir,origin:l.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:Gs,scopeRef:p});d&&(r[l.scope]=d)}r.parent||(a=null)}return{scopes:r,parentRel:a,cwdInGitRepo:i}}s(Xi,"collectUserSpec");function qi(e,t,n={}){let r=n.truncated===!0,o=Kn(e),i=new Set(e.map(l=>we(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=we(l.path,l.name);u[p]!==eo(l)&&c.push(l)}let f=[];if(!r){for(let l of Object.keys(u))if(!i.has(l)){let p=dl(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(qi,"diffUserSpec");var Ep=2*1024*1024,nO=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function Zi(e,t,n){let r=new Set(t.map(i=>we(i.path,i.name))),o=[];for(let i of e)i.text!==void 0&&(n.has(i.content_hash)||r.has(we(i.path,i.name))||o.push(i));return o}s(Zi,"collectPendingTextBodies");function Qi(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(Qi,"pruneDeliveredTextHashes");function yp(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(yp,"jsonSize");function Rp(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}s(Rp,"withoutText");function ea(e,t=Ep){let n=[],r=[];for(let l of e)nO.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=yp(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=Rp(l),g=yp(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(ea,"fitUserSpecWithinBudget");function ta(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:Rp(n))}s(ta,"stripAlreadyDeliveredText");var rO=["user","cwd","repo","parent"];function na(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,i=[];for(let I of rO){let O=t.scopes[I];if(!O)continue;let U=n(I,O.scopeRef),M=U.components,x=qi(O.components,M,{forceFull:M===void 0,truncated:O.truncated}),N=new Set(U.textHashes),L=Zi(O.components,x.upserts,N),_=ta([...x.upserts,...L],N);i.push({scope:I,walk:O,delta:x,outgoing:_,outgoingKeys:new Set(_.map(T=>we(T.path,T.name))),deliveredTextHashes:N,cachedComponents:M})}let a=i.flatMap(I=>I.outgoing),c=ea(a,o),u=new Set(c.components.map(I=>we(I.path,I.name))),f=[],l=[],p=[],d=[],m=[],g=[],h=[];for(let I of i){let{scope:O,walk:U,delta:M}=I;g.push(...U.components),f.push(O);let x=c.components.filter(T=>I.outgoingKeys.has(we(T.path,T.name))),N=[...I.outgoingKeys].some(T=>!u.has(T)),L=M.truncated||N;L?p.push(O):M.full&&l.push(O),d.push(...x),!M.full&&!L&&m.push(...M.removed);let _=M.full?{}:{...I.cachedComponents??{}};if(!L)for(let T of M.removed)delete _[we(T.path,T.name)];for(let T of x)_[we(T.path,T.name)]=eo(T);h.push({scope:O,scopeRef:U.scopeRef,components:_,textHashes:Qi(I.deliveredTextHashes,x.filter(T=>T.text!==void 0).map(T=>T.content_hash),U.components),collectedAtMs:r,included:x.length>0||M.removed.length>0&&!L||M.full})}let E={user_spec_hash:Kn(g),user_spec_count:g.length,user_spec_truncated:p.length>0};f.length>0&&(E.user_spec_scopes=f,E.user_spec_full_scopes=l,E.user_spec_truncated_scopes=p,E.user_spec_cwd_in_git_repo=t.cwdInGitRepo),l.length>0&&l.length===f.length&&(E.user_spec_full=!0),d.length>0&&(E.user_spec=d),m.length>0&&(E.user_spec_removed=m),c.textDeferredCount>0&&(E.user_spec_text_deferred=c.textDeferredCount);let k=t.scopes.cwd;k&&(E.user_spec_cwd_scope_ref=k.scopeRef);let w=t.scopes.repo;w&&(E.user_spec_repo_scope_ref=w.scopeRef);let P=t.scopes.parent;return P&&(E.user_spec_parent_scope_ref=P.scopeRef,t.parentRel&&(E.user_spec_parent_rel=t.parentRel)),{fields:E,scopes:h}}s(na,"buildUserSpecSend");var bo={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function ra(e){return e==="cwd"||e==="repo"||e==="parent"}s(ra,"isProjectSpecScope");function or(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(or,"isPlainObject");function oa(e){return!or(e)||!or(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(oa,"isDirScopeCacheEntry");function Cp(e){return oO(e)}s(Cp,"readStringHashMap");function Ap(e){return sO(e)}s(Ap,"readStringArray");function bp(e){return iO(e)}s(bp,"cloneDirScopeMap");function oO(e){if(!or(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}s(oO,"readComponentHashMap");function sO(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}s(sO,"readTextHashes");function kp(e,t){if(!or(e))return;let n=e[t];return oa(n)?n:void 0}s(kp,"readDirScopeCacheEntry");function iO(e){if(!or(e))return{};let t={};for(let[n,r]of Object.entries(e))oa(r)&&(t[n]=r);return t}s(iO,"readDirScopeCacheMap");function sa(e,t=20){let n=[];for(let[r,o]of Object.entries(e))oa(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(sa,"boundDirScopeCache");var fO=["allow","deny","ask"];function Oo(e){let t=ee(e,{}),n=[];for(let r of fO)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:ho(o),mode:r});return{model:t.model??"",permissionKeys:n}}s(Oo,"readClaudeSettings");function dO(e){let{serverManaged:t,fileBased:n}=Un(process.platform,e),r=Oo(t);if(r.model||r.permissionKeys.length>0)return r;let o="",i=[];for(let a of n){let c=Oo(a);c.model&&(o=c.model),i.push(...c.permissionKeys)}return{model:o,permissionKeys:i}}s(dO,"readClaudeManagedSettings");function pO(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(pO,"dedupePermissionKeys");var mO=10,gO="self-config-cache.json",xp=6;function Sn(){return F("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}s(Sn,"isUserSpecDisabled");function _O(){return F("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}s(_O,"isCwdSpecDisabled");var hO={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"],copilot:["copilot"]};async function SO(e,t=re){let n=hO[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(`
|
|
30
|
-
`)[0]??"").trim();return c||r(o+1)},"tryNext");return r(0)}s(
|
|
31
|
-
`);return q(n)}s(
|
|
32
|
-
`)}catch(o){let i=o instanceof Error?o.message:String(o);
|
|
33
|
-
`)){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(
|
|
34
|
-
`)}s(
|
|
35
|
-
`)}catch(i){let a=i instanceof Error?i.message:String(i);
|
|
36
|
-
`)}catch(i){let a=i instanceof Error?i.message:String(i);
|
|
37
|
-
`,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(
|
|
38
|
-
`)}catch(i){let a=i instanceof Error?i.message:String(i);
|
|
39
|
-
`,{encoding:"utf8",flag:"wx"})}s(
|
|
40
|
-
`)}s(
|
|
41
|
-
`),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(a){let c=a instanceof Error?a.message:String(a);return
|
|
42
|
-
To install a released binary instead: curl -fsSL https://cdn.ev-ai.ai/agent-hook/install.sh | sh`);let r=
|
|
43
|
-
curl -fsSL ${
|
|
16
|
+
`}s(vr,"slotRecord");function As(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(As,"parseSlotRef");function Jc(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}s(Jc,"isPidAlive");var gE=/^(\d+)\n(\d+)\n$/;function _E(e){let t=gE.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(_E,"parseSlotRecord");function Yc(e,t,n){let r=_E(e);if(!r)return Math.abs(n-t)<$n;let o=n-r.acquiredAtMs;return o<-$n||o>=wr?!1:Jc(r.pid)}s(Yc,"isSlotRecordHeld");import{createHash as hE,randomBytes as EE}from"node:crypto";import{existsSync as Lr,mkdirSync as SE,readdirSync as yE,readFileSync as RE,renameSync as Zc,statSync as Qc,unlinkSync as eu,writeFileSync as CE}from"node:fs";import{homedir as tu}from"node:os";import{basename as AE,dirname as Xc,isAbsolute as bE,join as nu,relative as ru,resolve as et,sep as OE}from"node:path";function C(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
|
|
17
|
+
`)}s(C,"logStderr");function jn(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}s(jn,"stripRemoteCredentials");function Bn(e){return hE("sha256").update(e).digest("hex").slice(0,32)}s(Bn,"sha32");var kE=3;function ou(e){return e instanceof Error&&"code"in e?e.code:void 0}s(ou,"errnoCode");function su(e){let t=ou(e);return t==="EEXIST"||t==="EPERM"||t==="EACCES"}s(su,"isRenameReplaceBlocked");function IE(e,t,n){let r=n;for(let o=0;o<kE;o+=1){try{eu(t)}catch(i){if(ou(i)!=="ENOENT")throw i}try{Zc(e,t);return}catch(i){if(!su(i))throw i;r=i}}throw r}s(IE,"replaceByUnlinkThenRename");function fe(e,t){SE(Xc(e),{recursive:!0});let n=nu(Xc(e),`.${AE(e)}.${process.pid}.${EE(4).toString("hex")}.tmp`);try{CE(n,t,"utf8");try{Zc(n,e)}catch(r){if(!su(r))throw r;IE(n,e,r)}}catch(r){try{eu(n)}catch{}throw r}}s(fe,"writeFileAtomic");function Mr(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}s(Mr,"timestampUtc");var iu;function Os(e='{"continue":true}'){(iu?.stdout??process.stdout).write(e)}s(Os,"emitStdoutOk");var jt=new Set(["on","1","true"]),Ur=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 Kn(){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(Kn,"readStdinUntilEnd");async function Hr(e){let t=iu?.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(Hr,"readStdinWithTimeout");async function De(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(De,"execFileResult");async function oe(e,t,n=3e3,r={}){let o=await De(e,t,n,r);return o.ok?o.stdout:""}s(oe,"execFileText");function bs(e,t){let n=et(e),r=et(t),o=ru(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${OE}`)||bE(o)?!1:et(r,o)===n}s(bs,"isPathInside");function au(e,t,n=tu()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return et(e);let o=et(r),i=et(e);if(bs(i,o))return i;let a=t.CURSOR_PLUGIN_ROOT?.trim();return bs(i,et(n,".cursor"))||a!==void 0&&a.length>0&&bs(i,et(a))?o:i}s(au,"cursorHookLaunchCwd");async function ks(e=process.cwd(),t=process.env,n=tu()){let r=au(e,t,n),o=r!==et(e)&&Lr(r)?r:e,i=await De("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")}`;C(`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&&Lr(a)){let c=await De("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(ks,"resolveGitWorkspace");async function tt(e=process.cwd()){return(await ks(e)).root}s(tt,"findGitRoot");function we(e,t){try{return JSON.parse(e)}catch{return t}}s(we,"parseJsonSafe");var qc=new Map;function sn(e){return e.charCodeAt(0)===65279?e.slice(1):e}s(sn,"stripUtf8Bom");function TE(e){let t;try{t=RE(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(sn(t))}}catch{return{ok:!1,reason:"parse"}}}s(TE,"parseJsonFile");function cu(e){let t=qc.get(e);if(t!==void 0)return t;let n=TE(e);return qc.set(e,n),n}s(cu,"loadJsonFileStatus");function uu(e){return cu(e)}s(uu,"readJsonFileStatus");function Y(e,t){let n=cu(e);return n.ok?n.value:t}s(Y,"readJsonFileMemoized");function Bt(e){return typeof e=="string"?e:""}s(Bt,"pickString");function nt(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(nt,"pickNestedScalar");function B(e,t){let n=nt(e,t);return typeof n=="string"?n:""}s(B,"pickNestedString");var yt=500;function lu(e,t=2){if(!Lr(e))return{entries:[],truncated:!1};let n=[],r=!1,o=s((i,a)=>{if(a>t||r)return;let c;try{c=yE(i,{withFileTypes:!0})}catch{return}for(let u of c){if(r)return;let f=nu(i,u.name);if(u.isDirectory()){o(f,a+1);continue}if(u.isFile()){try{n.push({name:ru(e,f),size:Qc(f).size})}catch{continue}if(n.length>=yt){r=!0;return}}}},"walk");return o(e,1),{entries:n,truncated:r}}s(lu,"listDirFiles");function Is(e){return Lr(e)?{present:!0,size:Qc(e).size}:{present:!1,size:0}}s(Is,"fileSizeOrAbsent");var Dr=".claude/ev-ai-runtime-report.json",_u="config.json",NE="max_concurrent_hooks",AM=1024*1024,vE=new Set(["localhost","127.0.0.1","[::1]","::1"]),LE=["claude","cursor","codex","copilot","antigravity"],Fr=[Dr,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],Ts=/^[A-Za-z0-9._~-]+$/;function $r(e){return e!==void 0&&LE.includes(e)}s($r,"isKnownRunner");function hu(e){if(!e||typeof e!="object")return;let t=e[NE];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}s(hu,"maxConcurrentHooksFromConfig");function fu(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}s(fu,"parseCapArg");function an(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}s(an,"takeFlagValue");function cn(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=an(e,u);t=l.value,u=l.next;continue}if(f.startsWith("--runner=")){t=f.slice(9);continue}if(f==="--url"){let l=an(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=an(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=an(e,u);l.value&&(i=l.value),u=l.next;continue}if(f.startsWith("--base-url=")){i=f.slice(11);continue}if(f===Tr){let l=an(e,u);a=fu(l.value)??a,u=l.next;continue}if(f.startsWith(`${Tr}=`)){a=fu(f.slice(Tr.length+1))??a;continue}if(f===Dn){let l=an(e,u);c=As(l.value)??c,u=l.next;continue}if(f.startsWith(`${Dn}=`)){c=As(f.slice(Dn.length+1))??c;continue}f!==Uc&&!f.startsWith("-")&&n===void 0&&(n=f)}}return{runner:$r(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:i,...a!==void 0?{cap:a}:{},...c!==void 0?{slot:c}:{}}}s(cn,"parseHookArgv");function xs(e,t){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}s(xs,"buildCollectorUrl");function Kt(e=PE()){return wE(e,".ev-ai",_u)}s(Kt,"homeManifestPath");function Eu(e,t){return{...e,...t}}s(Eu,"mergeManifestOverlay");function du(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(du,"hasUnsafeCollectorUrlChars");function jr(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?vE.has(t.hostname):!1}catch{return!1}}s(jr,"isAllowedCollectorUrl");function Ps(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(Ps,"extractOrgTokenFromCollectorUrl");function rt(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!jr(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Ps(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Ts.test(n))return`org token must match ${Ts.source}`;if(du(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(du(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}s(rt,"collectorUrlProblem");function Rt(e){return new URL(e).toString()}s(Rt,"normalizeCollectorUrl");function Su(e){return e.collector_url??""}s(Su,"resolveCollectorUrl");function pu(e){let t=e?.repo_ingest_token;return!e?.collector_url&&typeof t=="string"&&t.trim().length>0}s(pu,"hasOnlyLegacyIngestToken");function un(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(un,"redactCollectorUrlForLog");function yu(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=xs(o,i)}}if(!n)return{};let r=rt(n);return r?{problem:r}:{url:Rt(n)}}s(yu,"collectorUrlFromArgv");var ME="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",UE="COLLECTOR_URL",mu="collector_url_override",HE=[ME,UE];function DE(e){let t;for(let n of HE){let r=e[n]?.trim();if(!r)continue;let o=rt(r);if(o){t??={problem:o,envName:n};continue}return{url:Rt(r),envName:n}}return t??{}}s(DE,"collectorUrlFromPluginOption");function gu(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=rt(t);return n?{problem:n}:{url:Rt(t)}}s(gu,"candidateFromUnknown");function Ru(e){let t=[],n=gu(e.homeConfig?.[mu]);if(n.problem&&t.push({label:mu,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=yu(cn(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=DE(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=gu(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&&(pu(e.homeConfig)||pu(e.manifest))&&t.push({label:"repo_ingest_token",problem:"needs collector_url"}),a){let c=rt(a);if(c)t.push({label:"manifest collector_url",problem:c});else return{url:Rt(a),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}s(Ru,"selectCollectorUrl");function Gt(e){if(rt(e))return;let t;try{t=new URL(e)}catch{return}let n=Ps(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 xE("sha256").update(a).digest("hex").slice(0,32)}s(Gt,"scopeIdForCollectorUrl");var Ct=2,Cu="node_modules/@ev-ai/agent-hook/dist/hook.mjs",Ne="ev-ai-agent-hook";function FE(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}s(FE,"hookBinaryBasenameFromPath");function Br(e){let t=FE(e);return t===Ne||t===`${Ne}.exe`}s(Br,"isHookBinaryPath");var Au="https://cdn.ev-ai.ai/agent-hook";var ws=`current/${Ne}`,Ns=`.ev-ai/agent-hook/${Ne}`,bu=5e3,Ou=5e3,vs=3e3;var Kr=3e3,ku=1500,Iu=4*1024,Ls=256*1024,$E=4*1024,Tu=32*1024,Se="1.4.2",Gr=`@ev-ai/agent-hook@${Se}`,xu="ev-ai runtime report";var Pu={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT",copilot:"PLUGIN_ROOT",antigravity:"PLUGIN_ROOT"};import{chmodSync as Vm,cpSync as zm,existsSync as Ft,mkdirSync as Fa,readFileSync as ZT,rmSync as zo,symlinkSync as QT,writeFileSync as ex}from"node:fs";import{homedir as mt}from"node:os";import{dirname as $a,isAbsolute as tx,join as Z,relative as Wm,resolve as Km,sep as nx}from"node:path";import{fileURLToPath as rx}from"node:url";import{existsSync as jE,readdirSync as wu}from"node:fs";import{homedir as Vr}from"node:os";import{join as Ce}from"node:path";function Nu(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return Ce(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}s(Nu,"claudeManagedSettingsDir");function Ms(e=process.platform){let t=Nu(e),n=[Ce(t,"managed-settings.json")],r=Ce(t,"managed-settings.d");try{if(!jE(r))return n;let o=wu(r).filter(i=>i.endsWith(".json")&&!i.startsWith(".")).sort().map(i=>Ce(r,i));n.push(...o)}catch{}return n}s(Ms,"listClaudeManagedSettingsFiles");function Gn(e=process.platform,t=Vr()){return{serverManaged:Ce(t,".claude","remote-settings.json"),fileBased:Ms(e)}}s(Gn,"claudeManagedSettingsSources");function BE(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return Ce(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}s(BE,"cursorEnterpriseSettingsDir");function KE(e=process.platform,t=Vr()){let n=[Ce(BE(e),"hooks.json")],r=Ce(t,".cursor","managed");try{for(let o of wu(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(Ce(r,o.name,"hooks.json"))}catch{}return n}s(KE,"listCursorManagedSettingsFiles");function GE(e=process.platform,t=Vr()){let n=e==="win32"?Ce(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[Ce(n,"requirements.toml")];return e!=="win32"&&r.push(Ce(n,"managed_config.toml")),r.push(Ce(t,".codex","managed_config.toml"),Ce(n,"config.toml")),r}s(GE,"listCodexManagedSettingsFiles");function zr(e,t=process.platform,n=Vr()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=Gn(t,n);return[r,...o]}case"cursor":return KE(t,n);default:return GE(t,n)}}s(zr,"managedSettingsFiles");import{createHash as _m,randomBytes as oT}from"node:crypto";import{existsSync as hm,mkdirSync as wa,readFileSync as Em,unlinkSync as Sm,writeFileSync as ym}from"node:fs";import{homedir as pr}from"node:os";import{dirname as Bo,join as Ko,resolve as sT}from"node:path";var VE=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com","claude@anthropic.com","agent@cursor.local"]),zE=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function _e(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||zE.has(n)||r.includes("[bot]")||VE.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(_e,"isBotOperatorIdentity");import{homedir as Us}from"node:os";import{join as JE}from"node:path";function vu(e=Us()){return JE(e,".claude.json")}s(vu,"claudeUserConfigPath");function Vt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Vt,"trimString");function Lu(e=Us()){let n=Y(vu(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||_e(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:a,identity_source:"claude_oauth"}}s(Lu,"readClaudeOperatorIdentity");function Mu(e=Us()){let n=Y(vu(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=Vt(n.emailAddress),o=Vt(n.fullName)??Vt(n.displayName);return _e(o,r)?null:r?.toLowerCase()??null}s(Mu,"readClaudeAccountKey");import{existsSync as LS,readFileSync as ul,unlinkSync as MS}from"node:fs";import US from"node:http";import{join as ll}from"node:path";import{randomBytes as ZE}from"node:crypto";import{appendFileSync as QE,mkdirSync as eS,readdirSync as tS,readFileSync as $s,renameSync as Ku,statSync as Wn,unlinkSync as Wu}from"node:fs";import{homedir as At,tmpdir as nS}from"node:os";import{dirname as Fs,join as zt}from"node:path";var Du="EV_AI_PERF_L",Hs="EV_AI_PERF_H",Vn="EV_AI_RUN_ID",YE="EV_AI_HOOK_PERF";var XE=/^[a-z][a-z0-9_]{0,23}$/;var Wr={origin:0,marks:{},values:{}},Jr=!1;function Fu(e=process.env){Jr=e[YE]!=="0",Wr.origin=performance.timeOrigin}s(Fu,"startTimings");function zn(){return Jr}s(zn,"timingsActive");function ot(e,t=performance.now()){Jr&&(Wr.marks[e]=t)}s(ot,"mark");function $u(){return Wr}s($u,"ownTimings");function ju(e){return Math.round(e*10)/10}s(ju,"round1");function Uu(e){return Object.entries(e).map(([t,n])=>`${t}=${ju(n)}`).join(",")}s(Uu,"entries");function qE(e){return`${ju(e.origin)}|${Uu(e.marks)}|${Uu(e.values)}`}s(qE,"serializeTimings");function Hu(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||!XE.test(o)||!(i>=0&&i<=36e5))return!1;t[o]=i}return Object.keys(t).length<=32}s(Hu,"parseEntries");function Ds(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(!(!Hu(n,a.marks)||!Hu(r,a.values)))return a}s(Ds,"parseTimings");function Bu(){return Jr?qE(Wr):void 0}s(Bu,"serializeOwnTimings");var rS="hooks-debug.log",oS=/^hooks-debug\.log\.\d+$/,sS=/^hooks-debug\.log(\.1)?\.send-\d+$/,Gu="ev-ai-agent-hooks.log",iS="EV_AI_HOOK_RUN_LOG",ln="unlimited",aS="off",js=1024*1024,cS=8*1024,Vu=js/2-cS,uS=10080*60*1e3,lS=1024*1024,fS="run-log-windows.json",dS=64*1024,Bs=/^[a-z0-9]{8}$/,zu="abcdefghijklmnopqrstuvwxyz0123456789",pS=/[^A-Za-z0-9._:/+-]/g,mS=128,bt={info(){},error(){}},ve=bt;function Xr(e=At()){return zt(e,".ev-ai",rS)}s(Xr,"fileLogPath");function Ju(e){try{let t=JSON.parse(sn($s(zt(e,".ev-ai","config.json"),"utf8")));return Wt(t)?t:void 0}catch{return}}s(Ju,"readHomeConfig");function gS(e){return e?.debug===!0}s(gS,"debugFromHomeConfig");function Ks(e,t=!1){return e.includes("--debug")||t}s(Ks,"isHookDebugEnabled");function Wt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(Wt,"isRecord");function _S(e,t){let n=e?.log_until;if(typeof n!="string")return;let r=[];if(n===ln)return{on:!0,source:"local_config",scopes:r,localUntil:n};if(n===aS)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(_S,"localRunLog");function hS(e){if(!Wt(e)||!Wt(e.config))return;let t=e.config.log_until;if(typeof t!="string")return;if(t===ln)return{until:t,untilMs:Number.POSITIVE_INFINITY};let n=Date.parse(t);return Number.isNaN(n)?void 0:{until:t,untilMs:n}}s(hS,"scopeUntilMs");function Yu(e=At(),t=process.env,n=Date.now()){return Xu(e,()=>Ju(e),t,n)}s(Yu,"readRunLogSwitch");function Xu(e,t,n,r){let o=n[iS]?.trim().toLowerCase();if(o&&jt.has(o))return{on:!0,source:"env",scopes:[]};if(o&&Ur.has(o))return{on:!1,source:"env",scopes:[]};let i=_S(t(),r);if(i)return i;let a=[];try{let c=zt(e,".ev-ai","agent-hook","hook-config.json"),u=Wn(c);if(!u.isFile()||u.size>lS)return{on:!1,source:"remote",scopes:a};let f=JSON.parse($s(c,"utf8"));if(Wt(f))for(let[l,p]of Object.entries(f)){let d=hS(p);d&&d.untilMs>r&&a.push({scopeId:l,...d})}}catch{}return{on:a.length>0,source:"remote",scopes:a}}s(Xu,"runLogSwitch");function qu(e=At()){return zt(e,".ev-ai","agent-hook",fS)}s(qu,"runLogWindowsPath");function Gs(e=At()){try{let t=qu(e),n=Wn(t);if(!n.isFile()||n.size>dS)return{};let r=JSON.parse($s(t,"utf8")),o={};if(Wt(r))for(let[i,a]of Object.entries(r))typeof a=="string"&&(o[i]=a);return o}catch{return{}}}s(Gs,"readRunLogWindows");function Vs(e,t=At()){try{let n=Gs(t),r={...n};if(e(r),JSON.stringify(r)===JSON.stringify(n))return;fe(qu(t),`${JSON.stringify(r,null,2)}
|
|
18
|
+
`)}catch{}}s(Vs,"updateRunLogWindows");function ES(e,t){Vs(n=>{for(let r of t)n[r.scopeId]=r.until},e)}s(ES,"recordRunLogWindows");function SS(e){return e.replace(/[\r\n]/g," ")}s(SS,"oneLine");function yS(e){try{if(Wn(e).size<Vu)return;let t=`${e}.${process.pid}`;Ku(e,t);try{Ku(t,Wn(t).size>=Vu?`${e}.1`:e)}catch{Wu(t)}}catch{}}s(yS,"rotateIfFull");var RS=/\bhttps?:\/\/[^\s'"<>`]+/gi;function CS(e){try{let t=new URL(e);return`${t.protocol}//${t.host}${t.pathname.replace(/\/[^/]+\/hook(?![\w-])/,"/***/hook")}`}catch{return"<url>"}}s(CS,"redactUrl");function AS(e,t=At()){let n=e.replace(RS,CS);return t.length>1?n.replaceAll(t,"~"):n}s(AS,"scrubForLog");function bS(e,t){try{eS(Fs(e),{recursive:!0}),yS(e),QE(e,t,{encoding:"utf8",mode:384})}catch{}}s(bS,"appendLine");function qr(e=process.argv,t=Xr(),n,r){kS();let o=At(),i,a=!1,c=s(()=>(a||(i=Ju(o),a=!0),i),"readOnce"),u=Ks(e,n??gS(c())),f=u||r!==void 0?void 0:Xu(o,c,process.env,Date.now());if(!u&&!(r??f?.on)){ve=bt;return}f?.source==="remote"&&ES(o,f.scopes);let l=s((p,d)=>{bS(t,`${new Date().toISOString()} ${p} ${AS(SS(d),o)}
|
|
19
|
+
`)},"write");ve={info(p){l("info",p)},error(p){l("error",p)}}}s(qr,"initFileLogger");function Zu(){return ve!==bt}s(Zu,"fileLoggerActive");var se={info(e){ve.info(e)},error(e){ve.error(e)}},OS=new Set(["post_failed","timeout"]),pe={},zs=!1;function kS(){pe={},zs=!1}s(kS,"resetRunState");function Qu(){return zs}s(Qu,"runLineWritten");function re(e){if(ve===bt)return;if(e.outcome===void 0){pe={...pe,...e};return}if(pe.outcome!==void 0&&OS.has(pe.outcome)){pe.err===void 0&&e.err!==void 0&&(pe={...pe,err:e.err});return}let{runner:t,event:n,session:r,tool:o,ackMs:i}=pe;pe={runner:t,event:n,session:r,tool:o,ackMs:i,...e}}s(re,"noteRun");function Ot(e){let t=Wt(e)?e.cause:void 0;for(let n of[t,e])if(Wt(n)&&typeof n.code=="string"&&n.code!=="")return n.code;return e instanceof Error?e.name:typeof e}s(Ot,"runErrorKind");var IS=4096;function TS(e){return(e.stack??"").split(`
|
|
20
|
+
`).map(t=>t.trim()).filter(t=>t.startsWith("at ")).join(" | ")}s(TS,"stackFrames");function Jn(e){try{return xS(e).join(" ").slice(0,IS)}catch{return"err=unknown message=(unprintable)"}}s(Jn,"errorDetail");function xS(e){let t=[`err=${Ot(e)}`];if(!(e instanceof Error))return t.push(`message=${String(e)}`),t;t.push(`message=${e.message}`);let n=TS(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(xS,"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(ve===bt)return;let r=n[Vn],o=r!==void 0&&Bs.test(r)?` run=${r}`:"";ve.error(`failed where=${e}${o} ${Jn(t)}`)}s(L,"logFailure");function wS(){let e="";for(let t of ZE(8))e+=zu[t%zu.length];return e}s(wS,"newRunId");function el(e=process.env){if(ve===bt)return;let t=e[Vn];if(t!==void 0&&Bs.test(t))return t;let n=wS();return e[Vn]=n,n}s(el,"ensureRunId");function NS(e){if(typeof e=="number")return Number.isInteger(e)?String(e):e.toFixed(1);let t=e.replace(pS,"_").slice(0,mS);return t===""?"_":t}s(NS,"runValue");function fn(e,t,n,r=process.env){if(ve===bt)return;zs=!0;let o=r[Vn],a=[["run",o!==void 0&&Bs.test(o)?o:void 0],["p",e],["start",new Date(performance.timeOrigin).toISOString()],["v",t],["runner",pe.runner],["event",pe.event],["tool",pe.tool],["session",pe.session],["outcome",pe.outcome??n],["ms",performance.now()],["ack_ms",pe.ackMs],["post_ms",pe.postMs],["http",pe.http],["err",pe.err]].filter(c=>c[1]!==void 0&&c[1]!=="").map(([c,u])=>`${c}=${NS(u)}`);ve.info(`run ${a.join(" ")}`)}s(fn,"writeRunLine");function Yr(e,t){try{t-Wn(e).mtimeMs>uS&&Wu(e)}catch{}}s(Yr,"unlinkIfStale");function tl(e=Date.now(),t=At(),n=vS()){if(ve!==bt)return;let r=Xr(t);Yr(r,e),Yr(`${r}.1`,e);try{for(let o of tS(Fs(r)))(oS.test(o)||sS.test(o))&&Yr(zt(Fs(r),o),e)}catch{}Yr(n,e)}s(tl,"purgeStaleLog");function vS(e=process.platform){return e==="win32"?zt(nS(),Gu):zt("/tmp",Gu)}s(vS,"legacyLogPath");var HS="/run/cursor/api.sock",DS="owner/user-email",FS="owner/user-id",$S=400,nl=25,jS=4096,BS="cursor-cloud-owner.json",KS="cursor-cloud-owner.miss.json",GS=1440*60*1e3,VS=600*1e3,zS=3600*1e3,WS=60*1e3,JS="/proc/sys/kernel/random/boot_id",YS=new Set([429,500,502,503,504]),XS=new Set(["ENOENT","ECONNREFUSED","EAGAIN"]);function qS(e=process.env){let t=e.CURSOR_AGENT_SOCKET?.trim();return t&&t.length>0?t:HS}s(qS,"cursorAgentSocketPath");function ZS(e){return ll(e,".ev-ai","agent-hook",BS)}s(ZS,"cursorCloudOwnerCachePath");function QS(e){return ll(e,".ev-ai","agent-hook",KS)}s(QS,"cursorCloudOwnerMissCachePath");function ey(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 Qr(n);if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let r=n.value;return typeof r=="string"?Qr(r):null}}catch{}return t}s(ey,"parseCursorMetadataBody");function Qr(e){let t=e.trim();return t.length>0?t:null}s(Qr,"nonEmpty");function ty(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(ty,"retryAfterMs");function ny(e,t,n){return new Promise(r=>{let o=!1,i=s(u=>{o||(o=!0,clearTimeout(c),r(u))},"finish"),a=US.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>jS){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:ty(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:XS.has(u.code??"")})}),a.end()})}s(ny,"requestOnce");function ry(e){if(e.status===200){let t=ey(e.body);return t?{kind:"value",value:t}:{kind:"not_found"}}return e.status===404?{kind:"not_found"}:e.status===403?{kind:"forbidden"}:YS.has(e.status)?"retry":{kind:"error"}}s(ry,"classify");function oy(e){return new Promise(t=>setTimeout(t,e))}s(oy,"delay");async function rl(e,t,n){let r=n-Date.now();if(r<=0)return{kind:"error"};let o=await ny(e,t,r);if(!o.ok)return o.retryable?{kind:"retry",waitMs:nl}:{kind:"error"};let i=ry(o.response);return i==="retry"?{kind:"retry",waitMs:o.response.retryAfterMs??nl}:i}s(rl,"attemptKey");async function ol(e,t,n){let r=await rl(e,t,n);if(r.kind!=="retry")return r;if(Date.now()+r.waitMs>=n)return{kind:"error"};await oy(r.waitMs);let o=await rl(e,t,n);return o.kind==="retry"?{kind:"error"}:o}s(ol,"fetchCursorMetadataKey");async function sy(e,t=$S){let n=Date.now()+t,[r,o]=await Promise.all([ol(e,DS,n),ol(e,FS,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(sy,"fetchCursorCloudOwner");function Zr(e){return typeof e=="string"?Qr(e):null}s(Zr,"nullableString");var iy=new Set(["empty","forbidden","error"]);function fl(e){let t;try{t=JSON.parse(ul(e,"utf8"))}catch{return}if(!(t===null||typeof t!="object"||Array.isArray(t)))return t}s(fl,"readJsonRecord");function dl(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}s(dl,"finiteNumber");function sl(e){let t=fl(e),n=dl(t?.checked_at_ms);if(!t||n===void 0)return;let r={checked_at_ms:n,boot_id:Zr(t.boot_id),user_email:Zr(t.user_email),user_id:Zr(t.user_id)};return r.user_email??r.user_id?r:void 0}s(sl,"readCursorCloudOwnerCache");function ay(e){let t=fl(e),n=dl(t?.checked_at_ms),r=t?.status;if(!(!t||n===void 0)&&!(typeof r!="string"||!iy.has(r)))return{checked_at_ms:n,boot_id:Zr(t.boot_id),status:r}}s(ay,"readCursorCloudOwnerMissCache");function il(e,t){try{fe(e,`${JSON.stringify(t)}
|
|
21
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);C(`WARN: cursor cloud owner cache write failed open: ${r}`),L("cursor_cloud_owner_cache",n)}}s(il,"writeCacheFile");function cy(e){try{MS(e)}catch{}}s(cy,"removeCacheFile");function uy(e){switch(e){case"empty":return VS;case"forbidden":return zS;default:return WS}}s(uy,"missTtl");function pl(e,t,n){let r=t-e;return r>=0&&r<n}s(pl,"ageWithin");function al(e,t,n){return e?.boot_id!==t||!e?null:{owner:{userEmail:e.user_email,userId:e.user_id},fresh:t!==null||pl(e.checked_at_ms,n,GS)}}s(al,"sameBootOwner");function ly(e,t,n){return e?.boot_id!==t||!e?!1:pl(e.checked_at_ms,n,uy(e.status))}s(ly,"isCursorCloudOwnerMissFresh");function fy(){try{return Qr(ul(JS,"utf8"))}catch{return null}}s(fy,"readLinuxBootId");var cl=new Map;function eo(e){let t=e.env??process.env,n=qS(t),r=`${e.home}\0${n}`,o=cl.get(r);if(o)return o;let i=dy(n,e).catch(a=>(L("cursor_cloud_owner",a),null));return cl.set(r,i),i}s(eo,"resolveCursorCloudOwner");async function dy(e,t){let n=ZS(t.home),r=QS(t.home),o=t.nowMs??Date.now(),i=(t.readBootId??fy)(),a=al(sl(n),i,o);if(a?.fresh)return a.owner;if(ly(ay(r),i,o)||!LS(e))return a?.owner??null;let c=await sy(e,t.budgetMs);if(c.status==="ok"&&c.owner)return il(n,{checked_at_ms:o,boot_id:i,user_email:c.owner.userEmail,user_id:c.owner.userId}),cy(r),c.owner;let u=al(sl(n),i,o);return u?u.owner:(il(r,{checked_at_ms:o,boot_id:i,status:c.status==="ok"?"empty":c.status}),null)}s(dy,"resolveUncached");import{existsSync as gy,readFileSync as _y}from"node:fs";import{hostname as _l,release as hy,userInfo as Ey,version as Sy}from"node:os";import*as ye from"node:os";import{performance as Ws}from"node:perf_hooks";var py=1024*1024,my=128;function to(e){return Math.round(e/py)}s(to,"mb");function Yn(e,t){let n=10**t;return Math.round(e*n)/n}s(Yn,"round");function ml(e=process.platform){try{let t=Ws.now(),n={},r=0,o=0,i=e!=="win32";for(let{times:u}of ye.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(ye.uptime()),n.mem_free_mb=to(ye.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=to(process.availableMemory())),e!=="win32"){let[u,f,l]=ye.loadavg();n.load_1m=Yn(u??0,2),n.load_5m=Yn(f??0,2),n.load_15m=Yn(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=Ws.nodeTiming?.bootstrapComplete;return typeof c=="number"&&c>0&&(n.node_boot_ms=Yn(c,1)),n.sample_us=Math.round((Ws.now()-t)*1e3),n}catch{return}}s(ml,"sampleSys");function gl(){try{let e=ye.cpus(),t={},n=typeof ye.availableParallelism=="function"?ye.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,my);r&&(t.cpu_model=r);let o=ye.totalmem();t.mem_total_mb=to(o);let i=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof i=="number"&&i>0&&i<o&&(t.mem_limit_mb=to(i)),t.uptime_h=Yn(ye.uptime()/3600,1),t}catch{return{}}}s(gl,"hostSpecs");function dn(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(dn,"isTruthyFlag");function hl(e=process.env){return dn(ne("CURSOR_SANDBOX",e))}s(hl,"isCursorSandboxProcess");var yy=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function Ry(e){return yy.some(t=>!!ne(t,e))}s(Ry,"hasManagedCiMarker");function Cy(e){if(ne("KUBERNETES_SERVICE_HOST",e)||dn(ne("REMOTE_CONTAINERS",e))||dn(ne("DEVCONTAINER",e)))return!0;try{if(gy("/.dockerenv")||_y("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}s(Cy,"hasContainerMarker");function El(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!ne(t,e))}s(El,"hasIdeExtensionHostMarker");function Ay(e,t=process.platform){return El(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!ne(n,e)):!1}s(Ay,"hasLocalIdeHostMarker");function by(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}s(by,"isBackgroundComposerSessionId");function Oy(e){return e==="linux"}s(Oy,"isLinuxPlatform");function ne(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return j(e)}s(ne,"readContextEnv");function ky(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!Iy(ne("CURSOR_VERSION",n))}s(ky,"isCursorCloudHostFingerprint");function Iy(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(Iy,"trimEnvLocal");function Js(e){if(by(e.sessionId))return!0;let t=e.hostname??_l(),n=e.osUser??yl(e.env);return ky(t,n,e.env)}s(Js,"hasCursorCloudExclusiveEvidence");function Ty(e){return dn(ne("CURSOR_AGENT",e.env))?!0:Js(e)}s(Ty,"hasCursorCloudEvidence");function xy(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(ne("TERM",e)??ne("TERM_PROGRAM",e))||(ne("SSH_TTY",e)??ne("SSH_CONNECTION",e))||(ne("__CFBundleIdentifier",e)??ne("XPC_SERVICE_NAME",e))||El(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!ne(t,e))||ne("SESSIONNAME",e))}s(xy,"hasLocalSessionMarker");function no(e={}){let t=e.env;if(ne("GITHUB_ACTIONS",t))return"github_actions";if(dn(ne("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!Ay(t,n)&&Ty(e)&&(dn(ne("CURSOR_AGENT",t))||Oy(n)))return"cursor_cloud";if(ne("CODESPACES",t)||ne("CODESPACE_NAME",t))return"codespaces";if(ne("GITLAB_CI",t))return"gitlab_ci";if(Ry(t))return"managed";let r=ne("CI",t);return r&&r!=="false"&&r!=="0"?"managed":Cy(t)?"container":xy(t)?"interactive":"unknown"}s(no,"detectContext");async function Sl(){return await oe("systemd-detect-virt",[],1e3)}s(Sl,"detectVirt");function yl(e=process.env,t=Ey){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(yl,"resolveHostUsername");var Py=32;function wy(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,Py);return t.length>0?t:null}s(wy,"sanitizeOsPlatform");function Ny(){try{return[Sy(),hy()].filter(Boolean).join(" ").trim()}catch{return""}}s(Ny,"windowsVersion");async function Rl(e=!1){let t=wy(process.platform),n="";if(process.platform==="darwin")n=await oe("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 oe("lsb_release",["-sd"],1e3).then(a=>a.replace(/^"|"$/g,""))}n||(n=await oe("uname",["-r"],1e3))}else process.platform==="win32"?n=Ny():n=await oe("ver",[],1e3);let r=yl(),o=(process.env.SHELL??"").split(/[/\\]/).pop()??"",i="";try{i=await oe("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?gl():{}}}s(Rl,"hostEnv");function Ys(){return _l()}s(Ys,"hostName");import{existsSync as AI,readFileSync as om,unlinkSync as bI}from"node:fs";import{homedir as Ta}from"node:os";import{join as bn,resolve as OI}from"node:path";import{basename as gI,join as An}from"node:path";import{dirname as wl,resolve as io}from"node:path";import{existsSync as vy}from"node:fs";import{homedir as bl}from"node:os";import{relative as Ol,resolve as ze,sep as kt}from"node:path";var Ly=["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"],My=["prompt","tool_input","tool_response","last_assistant_message","command"],Uy=new Set;function Hy(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return Uy}}s(Hy,"excludedContentKeys");function ei(e){let t=j("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?jt.has(t.toLowerCase()):e?.collect_prompt===!0}s(ei,"isPromptCaptureEnabled");function ro(e,t){let n=kl(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!==""?jt.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}s(ro,"promptCaptureSource");function kl(e){return j("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||Ks(process.argv,e.debug===!0)||j("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}s(kl,"hookInputCaptureMode");function Dy(e){let t={};for(let n of Ly){let r=nt(e,n);r!==void 0&&(t[n]=r)}return t}s(Dy,"allowlistedHookInput");function oo(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=ze(e),r=ze(t),o=Ol(r,n);return!o||o==="."?".":o.startsWith(`..${kt}`)||o===".."||ze(r,o)!==n?null:o.split(kt).join("/")}s(oo,"cwdRelativeToGitRoot");function Il(e,t){let n=Ol(ze(t),ze(e)).split(kt).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}s(Il,"specDirRelativeToCwd");function Tl(e){return typeof e!="string"||e.length===0?null:ze(e).split(kt).join("/")}s(Tl,"absoluteCwdForSend");function Fy(){let e=j("CURSOR_PROJECT_DIR");if(!e)return null;let t=ze(e);return vy(t)?t.split(kt).join("/"):null}s(Fy,"cursorProjectDirAbs");function qs(e,t){return oo(e,t)!==null}s(qs,"isPathInside");function $y(e,t){let n=ze(t??bl(),".cursor").split(kt).join("/");return qs(e,n)}s($y,"isCursorUserHookLaunch");function jy(e,t,n){return t!==null&&qs(e,t)?!0:t!==null&&$y(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&qs(e,n.gitRoot)?!0:t===null}s(jy,"shouldKeepProcessCwd");function xl(e,t){let n=Tl(e.cwd);if(n!==null)return n;let r=ze(process.cwd()).split(kt).join("/"),o=Fy();return jy(r,o,t)?r:o??r}s(xl,"resolvedCwdForSend");function ti(e,t={}){return xl(e,t)}s(ti,"resolveLaunchCwd");function ni(e,t=bl()){let n=ze(t).split(kt).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}s(ni,"tildeHomeCwd");function Cl(e,t,n){let r=Tl(n.launchCwd)??xl(t,n);e.cwd=ni(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?oo(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}s(Cl,"attachCwdFields");var Pl="\u2026[truncated]\u2026",Zs=Buffer.byteLength(Pl,"utf8"),By=8;function Xn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Xn,"jsonByteLength");function Al(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}s(Al,"utf8Head");function Ky(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(Ky,"utf8Tail");function Gy(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=Zs)return Al(e,t);let r=t-Zs,o=Math.ceil(r/2),i=Math.floor(r/2);return`${Al(e,o)}${Pl}${Ky(e,i)}`}s(Gy,"truncateHeadTail");function Qs(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)=>{Qs(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||Qs(o,[...t,r],n)}s(Qs,"collectStrings");function Vy(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(Vy,"setAtPath");var zy=256;function Wy(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(Wy,"stringBudgetFor");function Jy(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let i=Xn(e);if(i<=t)return;let a=[];Qs(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=Wy(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&&Vy(e,l.path,Gy(l.value,r))}}s(Jy,"clampStringsToBudget");function Yy(e,t){let n=Math.max(0,t-zy),r=Object.keys(e).filter(i=>!i.startsWith("_")).map(i=>({key:i,bytes:Xn(e[i])})).sort((i,a)=>a.bytes-i.bytes),o=[];for(let{key:i}of r){if(Xn(e)<=n)break;delete e[i],o.push(i)}o.length>0&&(e._dropped_keys=o.slice(0,10))}s(Yy,"dropLargestKeys");function Xs(e,t){let n=Xn(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,Jy(r,t,Zs+By),Xn(r)>t&&Yy(r,t),r}s(Xs,"fitWithinByteLimit");function Xy(e,t,n){if(!(n.promptCapture??ei()))return;let r=Hy(n.runnerEvent);for(let o of My){if(r.has(o))continue;let i=t[o];i!==void 0&&(e[o]=i)}}s(Xy,"attachContentFields");function so(e,t,n={}){let r=kl(t);if(r==="full"){let i={...e};return delete i.cwd,delete i.transcript_path,Cl(i,e,n),Xs(i,Ls)}let o=Dy(e);return Cl(o,e,n),r==="content"?(Xy(o,e,n),Xs(o,Ls)):Xs(o,Iu)}s(so,"sanitizeHookInput");function qy(e){return typeof e=="string"&&e.length>0}s(qy,"hasOrigin");function ri(e){let t=io(e.home),n=io(e.launchCwd),r=e.gitRoot?io(e.gitRoot):null,o=new Set,i=[],a=null;e.inGitRepo&&qy(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&&oo(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&u){let f=wl(r);for(;;){let l=io(f);if(l===t)break;let p=wl(l);if(p===l)break;if(e.hasProjectSpec(l)){i.push({scope:"parent",dir:l}),c=Il(l,n);break}f=p}}return{anchors:i,parentRel:c}}s(ri,"resolveProjectAnchors");import{existsSync as vl,readdirSync as eR,realpathSync as tR}from"node:fs";import{basename as nR,dirname as rR,relative as oR,resolve as sR,sep as iR}from"node:path";import{createHash as Zy}from"node:crypto";import{resolve as Qy}from"node:path";function q(e){return Zy("sha256").update(e).digest("hex").slice(0,16)}s(q,"sha16");function oi(e){return q(Qy(e))}s(oi,"dirScopeRef");function Le(e,t){return`${e}\0${t}`}s(Le,"componentKey");function ao(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}s(ao,"componentDeltaHash");function Nl(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}s(Nl,"parseComponentKey");function qn(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(`
|
|
22
|
+
`);return q(n)}s(qn,"hashUserSpec");var si=400,co=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??yt}static{s(this,"UserSpecContext")}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=sR(t).split(iR).join("/");return ni(r,this.home)}let n=oR(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${q(rR(t))}/${nR(t)}`:n}claimFile(t){try{let n=tR(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(!vl(t))return[];try{return eR(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(vl(t))return Y(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 Ai,readFileSync as xC,statSync as PC}from"node:fs";import{basename as bi,join as Xt,relative as Oi}from"node:path";var Vf=Te(Gf());var IC=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],zf=IC.map(e=>Vf.default.matcher(e,{dot:!0}));function TC(e){return e===""?!1:zf.some(t=>t(`${e}/`))}s(TC,"isExcludedDirPath");function Wf(e,t){if(t==="")return!1;if(e==="")return TC(t);let n=e.replace(/\/+$/,"");return zf.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}s(Wf,"isExcludedDirBelow");var ki=100*1024,wC=4;function NC(e){return e.length<=ki?e:`${e.slice(0,ki-1)}\u2026`}s(NC,"truncateContentText");function vC(e){try{let t=xC(e),n=t.toString("utf8");return{hash:q(t),length:t.length,text:NC(n)}}catch{return null}}s(vC,"readFileMeta");var Jf={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function LC(e){return e in Jf?Jf[e]:"UNSPECIFIED"}s(LC,"triggerForKind");function It(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=vC(t.absolutePath);if(!n)return!1;let r=t.name??bi(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=LC(t.kind);return i&&(o.trigger=i),t.attributes&&(o.attributes=t.attributes),e.push(o)}s(It,"addFile");function MC(e,t,n,r){let o=Oi(e,t).replace(/\\/g,"/"),i=!o||o.startsWith("..")?bi(t):o;return r&&i.toLowerCase().endsWith(r)?bi(i).slice(0,-r.length):n||i!==o?i.replace(/\.(md|mdc|toml)$/i,""):o}s(MC,"nameFromWalkRoot");function Ye(e,t){let{dir:n,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u}=t;Ii(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u})}s(Ye,"walkComponentDir");function Ii(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l}=t;if(!(o>wC))for(let p of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(p.isDirectory()&&Wf(n.replace(/\\/g,"/"),Oi(n,Xt(r,p.name)).replace(/\\/g,"/"))||p.isDirectory()&&l?.includes(Xt(r,p.name)))continue;if(u){if(!p.isDirectory())continue;let E=Xt(r,p.name,u);if(Ai(E)){let S=Oi(n,Xt(r,p.name)).replace(/\\/g,"/");It(e,{absolutePath:E,kind:i,origin:a,enabled:c,name:S||p.name});continue}Ii(e,{walkRoot:n,currentDir:Xt(r,p.name),depth:o+1,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l});continue}if(p.isDirectory()){Ii(e,{walkRoot:n,currentDir:Xt(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=Xt(r,p.name),g=f.find(E=>E.split(".").length>2&&d.endsWith(E));It(e,{absolutePath:m,kind:i,origin:a,enabled:c,name:MC(n,m,!0,g)})}}s(Ii,"walkRecursive");function Yf(e){for(let t of e)if(Ai(t))try{if(PC(t).size>0)return t}catch{continue}return e.find(t=>Ai(t))}s(Yf,"firstExistingFile");import{existsSync as UC}from"node:fs";import{homedir as qf}from"node:os";import{join as HC}from"node:path";function Zf(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}s(Zf,"hookParsableSettings");var DC={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 FC(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(FC,"layoutForScope");function Qf(e){return Object.fromEntries(Object.entries(DC).map(([t,n])=>[t,FC(n,n[e])]))}s(Qf,"layoutsForScope");var gn=Qf("homeOnly"),xt=Qf("projectOnly");function $C(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}s($C,"layoutRelativePaths");function jC(e,t){return $C(e).some(n=>UC(HC(t,n)))}s(jC,"layoutHasAnyEntry");function ed(e,t){for(let n of e)if(jC(n,t))return!0;return!1}s(ed,"anyLayoutHasAnyEntry");function Tt(e){return[...new Set(e)]}s(Tt,"uniqueRels");function Pt(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:Tt(t),subagents:Tt(n),commands:Tt(r),rules:Tt(o),memory:Tt(i),settings:Tt(a),mcp:Tt(c)}}s(Pt,"userScopePathsFromLayouts");function BC(e,t=qf(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...zr(o.managed,n,t));return Tt(r)}s(BC,"managedSettingsFromLayouts");var wt=Pt(Object.values(gn));function td(e=qf(),t=process.platform){return BC(Object.values(gn),e,t)}s(td,"userScopeManagedSettings");import{existsSync as Ek,readFileSync as Sk}from"node:fs";function it(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(it,"isRecord");var ue=Te(Pe(),1);var bO=["package_name","package_spec","package_version","package_version_source"],ep=100,tp=120,np=new Set(ue.TOOL_LIST_RAW_KEYS.map(e=>e.attr)),OO=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],kO=new Set(["type","command","url","args","env","envVars","headers",...ue.ENABLED_RAW_KEYS,...OO,...ue.TOOL_LIST_RAW_KEYS.map(e=>e.raw)]),IO=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,...np,...[...np].map(e=>`${e}_truncated`)]);function rp(e,t){for(let n of t)kO.has(n)||IO.has(n)||(e[n]=ue.OMITTED_VALUE)}s(rp,"addOmittedKeys");function Xi(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}s(Xi,"asRecord");function op(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}s(op,"stringList");function Wi(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=Xi(e);return t?Object.keys(t).filter(n=>n.length>0):[]}s(Wi,"envNamesFromValue");function qi(e){return/[@\\]/.test(e)?ue.OMITTED_VALUE:(e.split(/[?#]/,1)[0]??"").trim()}s(qi,"redactUrlText");function TO(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,ue.launchContainsCredentials)({kind:"url",url:e})||(0,ue.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=(0,ue.redactArgs)([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,ue.launchContainsCredentials)({kind:"url",url:r}):!0)}s(TO,"rawLaunchHadCredentials");function sp(e,t,n){TO(t,n)&&(e.launch_had_credentials=!0)}s(sp,"markLaunchCredentials");function xO(e){let t=op(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>tp?r.slice(0,tp):r))].sort();if(n.length!==0)return n.length>ep?{names:n.slice(0,ep),truncated:!0}:{names:n,truncated:!1}}s(xO,"toolNameList");function PO(e){let t=Xi(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(PO,"envHeaderNames");function ip(e,t){let n=new Set;for(let{raw:r,attr:o}of ue.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=xO(i);a&&(e[o]=a.names,a.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}s(ip,"applyToolListAttributes");function ap(e,t){let n=Xi(e),r={transport:t};if(!n)return r;rp(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=op(n.args);c&&(r.command_or_url=(0,ue.redactCommandOrUrl)(c));let f=(0,ue.redactArgs)(u);f.length>0&&(r.args=f),sp(r,c,u);let l=PO(n.env_http_headers),p=[...new Set([...Wi(n.env),...Wi(n.envVars),...Wi(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),ip(r,n),r}s(ap,"sanitizeMcpServerAttributes");function Zi(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(Zi,"hashSanitizedMcpAttributes");function En(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}s(En,"parseTomlQuoted");function ar(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(ar,"parseTomlPlainStringArray");function Yi(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}s(Yi,"parseTomlBoolean");function Ji(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=En(n[1]);return r.length>0?r:void 0}s(Ji,"parseTomlScalarString");function wO(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],En(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(`
|
|
23
|
+
${e}`);return i?.[1]&&r(i[1]),n}s(wO,"parseTomlMap");function cp(e){return Yi(e,"enabled")===!1?!1:Yi(e,"disabled")!==!0}s(cp,"mcpServerEnabledFromToml");function NO(e,t){let n={};for(let{raw:r,attr:o}of ue.TOOL_LIST_RAW_KEYS){if(o==="auto_approve"){let a=Yi(t,r);if(a!==void 0){n[r]=a;continue}}let i=ar(t,r);i.length>0&&(n[r]=i)}ip(e,n)}s(NO,"applyToolListsFromToml");var vO=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,LO=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function MO(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
|
|
24
|
+
`)){let i=vO.exec(o);i?.[1]&&t.add(i[1])}for(let o of e.matchAll(LO))o[1]&&t.add(o[1]);return[...t]}s(MO,"tomlDeclaredKeys");function up(e,t){let n={transport:t};rp(n,MO(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),i=r?En(r[1]??""):void 0,a=o?En(o[1]??""):void 0,c=i!==void 0&&i.length>0?i:a,u=ar(e,"args");c&&(n.command_or_url=(0,ue.redactCommandOrUrl)(c));let f=(0,ue.redactArgs)(u);f.length>0&&(n.args=f),sp(n,c,u);let l=new Set;for(let A of e.split(`
|
|
25
|
+
`)){let P=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(A);P?.[1]&&l.add(P[1])}let p=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(p?.[1])for(let A of p[1].split(",")){let P=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(A);P?.[1]&&l.add(P[1])}let d=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
|
|
26
|
+
${e}`);if(d?.[1])for(let A of d[1].split(`
|
|
27
|
+
`)){let P=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(A);P?.[1]&&l.add(P[1])}for(let A of ar(e,"env_vars"))l.add(A);let m=wO(e,"env_http_headers");for(let[,A]of m)A.length>0&&l.add(A);let g=Ji(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(([A])=>A))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let E=Ji(e,"auth");E&&(n.auth=E);let S=Ji(e,"default_tools_approval_mode");return S&&(n.default_tools_approval_mode=S),NO(n,e),n}s(up,"parseTomlMcpSection");var Mt=Te(Pe(),1);var Ue=Te(Pe(),1);import{createHash as fk}from"node:crypto";import{join as ur}from"node:path";var Xe=Te(Pe(),1);import{realpathSync as _p}from"node:fs";import{basename as yn,dirname as cr,isAbsolute as nk,join as oa,resolve as hp,sep as rk}from"node:path";var Sn=Te(Pe(),1);import{closeSync as UO,constants as lp,fstatSync as HO,openSync as DO,readSync as FO,statSync as $O}from"node:fs";import{dirname as fp,join as Qi,relative as jO,sep as BO}from"node:path";var dp="node_modules",KO=".yarn-state.yml",GO=".package-lock.json",mp=16*1024*1024,VO=64,zO=lp.O_RDONLY|(process.platform==="win32"?0:lp.O_NONBLOCK);function To(e,t){try{let n=$O(e);if(!n.isFile()||n.size>t)return null;let r=DO(e,zO);try{let o=HO(r);if(!o.isFile()||o.size>t)return null;let i=Buffer.alloc(o.size+1),a=0;for(;a<i.length;){let u=FO(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{UO(r)}}catch{return null}}s(To,"readBoundedTextFile");function pp(e){if(!e.startsWith('"'))return null;try{let t=JSON.parse(e);return typeof t=="string"?t:null}catch{return null}}s(pp,"parseJsonString");var WO="1";function JO(e){let t=new Map,n=null,r=!1,o=!1,i=null;for(let a of e.split(`
|
|
28
|
+
`)){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=pp(f),n===null)return null;continue}if(c.startsWith(" - ")){if(o&&n!==null){let f=pp(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===WO?t:null}s(JO,"parseYarnState");var YO=/^(?:virtual:[0-9a-f]+#)?npm:([^:#]+)(?:::__archiveUrl=[^&#]+)?$/;function XO(e){let t=e.indexOf("@",e.startsWith("@")?1:0);if(t<=0)return null;let n=e.slice(0,t),o=YO.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(XO,"yarnLocatorEvidence");function qO(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(qO,"isRegistryTarballUrl");function ZO(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,Sn.packageNameFromSpec)(c)!==c||typeof r!="string"||!(0,Sn.isExactNpmVersion)(r)||typeof o!="string"||!qO(o,c,r)?null:{name:c,version:r}}s(ZO,"npmEntryEvidence");function QO(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(QO,"parseNpmHiddenLockfile");var ea=new Map,ta=new Map;function ek(e){if(!ea.has(e)){let t=To(e,mp);ea.set(e,t===null?null:JO(t))}return ea.get(e)??null}s(ek,"yarnState");function tk(e){if(!ta.has(e)){let t=To(e,mp);ta.set(e,t===null?null:QO(t))}return ta.get(e)??null}s(tk,"npmHiddenLockfile");function gp(e,t){let n=null,r=fp(e);for(let o=0;o<VO;o+=1){let i=jO(r,e).split(BO).join("/");if(i.split("/").slice(0,-1).includes(dp)){let c=Qi(r,dp),u=[];for(let l of ek(Qi(c,KO))?.get(i)??[])u.push(XO(l));let f=tk(Qi(c,GO));f?.has(i)===!0&&u.push(ZO(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=fp(r);if(a===r)break;r=a}return n}s(gp,"registryInstallIdentity");var ra="node_modules",ok=1024*1024,sk=16;function ik(e,t){return e.startsWith("~/")||e.startsWith("~\\")?oa(t,e.slice(2)):nk(e)?e:null}s(ik,"absoluteLauncherPath");function ak(e){let t=e.split(rk).join("/");return t.includes("/.yarn/")||/\.zip(?:\/|$)/i.test(t)}s(ak,"isYarnPnpPath");function ck(e){let t=yn(e),n=cr(e);if(yn(n)===ra)return t.startsWith("@")?null:t;let r=yn(n);return r.startsWith("@")&&yn(cr(n))===ra?`${r}/${t}`:null}s(ck,"nodeModulesPackageName");var na=new Map;function uk(e){let t=oa(e,"package.json");if(!na.has(t)){let n=To(t,ok),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}na.set(t,r)}return na.get(t)??null}s(uk,"readManifest");function lk(e){let t=cr(e);for(let n=0;n<sk;n+=1){if(yn(t)===ra)return null;let r=uk(t);if(r!==null&&typeof r.name=="string"){let{name:i,version:a}=r,c=ck(t);if(c===null||(0,Xe.packageNameFromSpec)(i)!==i||typeof a!="string"||!(0,Xe.isExactNpmVersion)(a))return null;let u=gp(t,c);return u?.name!==i||u.version!==a?null:{package_name:i,package_version:a,package_version_source:Xe.LOCAL_BIN_PACKAGE_VERSION_SOURCE}}let o=cr(t);if(o===t)return null;t=o}return null}s(lk,"owningPackageIdentity");function Ep(e,t){if(typeof e!="string"||e.length===0||(0,Xe.npxExecBin)(e)!==null||!(0,Xe.isNodeModulesBinCommand)(e))return null;try{let n=ik(e,t);if(n===null)return null;let r=_p(n),o=oa(_p(cr(n)),yn(n));return hp(r)===hp(o)||ak(r)?null:lk(r)}catch{return null}}s(Ep,"resolveLocalBinPackage");function dk(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,Ue.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}s(dk,"packageVersionFields");function pk(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
|
|
29
|
+
`);return fk("sha512").update(t).digest("hex").slice(0,16)}s(pk,"npxCacheKey");function mk(e){let t=process.platform==="win32"?ur(j("LOCALAPPDATA")??e,"npm-cache"):ur(e,".npm"),n=j("npm_config_cache")??j("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}s(mk,"npmCacheRoots");function Sp(e){return typeof e=="string"&&e.length>0&&e.length<=Ue.PACKAGE_FIELD_MAX?e:null}s(Sp,"usableVersion");function gk(e,t,n){let r=pk(e);for(let o of mk(n)){let i=ur(o,"_npx",r),a=Y(ur(i,"node_modules",...t.split("/"),"package.json"),{}),c=Sp(a.version);if(c!==null)return c;let u=Y(ur(i,"package-lock.json"),{}),f=Sp(u.packages?.[`node_modules/${t}`]?.version);if(f!==null)return f}return null}s(gk,"installedVersion");function _k(e){return e.length<=Ue.PACKAGE_FIELD_MAX?e:`${e.slice(0,Ue.PACKAGE_FIELD_MAX-1)}\u2026`}s(_k,"capField");function hk(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,Ue.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let i=(0,Ue.packageNameFromSpec)(o);return i===null?null:{package_name:i,package_spec:_k(o),...dk(o,gk(r,i,n))}}s(hk,"resolveNpxPackage");function sa(e,t,n){return hk(e,t,n)??Ep(e,n)}s(sa,"resolveMcpLaunchPackage");function yp(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=(0,Ue.tokenizeCommand)(e.trim());return n===void 0?null:sa(n,r,t)}s(yp,"resolveNpxPackageFromCommand");function xo(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 sa(typeof n.command=="string"?n.command:null,r,t)}s(xo,"npxPackageFromMcpConfig");function Rp(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:sa(En(n[1]??""),ar(e,"args"),t)}s(Rp,"npxPackageFromTomlSection");function yk(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(yk,"mcpTransport");var Rk=64*1024;function Po(e,t,n,r={}){let o=r.parentEnabled??!0;if(!e.claimFile(t))return;let i=e.readJson(t,void 0);if(!it(i))return;let a=(0,Mt.mcpConfigFormatOf)(t),c=(0,Mt.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=yk(m),E=ap(m,g);Object.assign(E,xo(m,e.home)??{});let S=o&&(0,Mt.mcpServerEnabledFromJson)(m),A=Zi(d,E,S);p.push([d,A]),e.push({kind:"MCP_SERVER",name:d,path:l,content_hash:A,origin:n,enabled:S,attributes:E})}e.truncated||a==="claude_json_slice"&&!Object.hasOwn(i,c)||Object.hasOwn(f,l)||Ck(e,{parsed:i,format:a,pathRel:l,origin:n,serverHashes:p,enabled:o})}s(Po,"collectMcpJson");function Ck(e,t){let n=(0,Mt.sanitizeMcpConfigFile)(t.parsed,t.format,{home:e.home}),r=JSON.stringify(n,null,2),o=Buffer.byteLength(r,"utf8"),i=o>Rk,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(Ck,"pushMcpConfigRow");function Cp(e,t,n){if(!Ek(t)||!e.claimFile(t))return;let r;try{r=Sk(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=up(l,p);Object.assign(d,Rp(l,e.home)??{});let m=cp(l);e.push({kind:"MCP_SERVER",name:c,path:o,content_hash:Zi(c,d,m),origin:n,enabled:m,attributes:d})}}s(Cp,"collectCodexMcpToml");import{existsSync as wp,readdirSync as jk}from"node:fs";import{basename as Bk,join as me}from"node:path";import{existsSync as bp,readdirSync as Ak}from"node:fs";import{join as No,relative as bk,resolve as Ap,sep as Ok}from"node:path";var kk=".gemini/config/plugins",Ik=".gemini/config/config.json",Tk=["plugin.json",".antigravity-plugin/plugin.json"],xk=["mcp_config.json",".antigravity-plugin/mcp_config.json"],Pk="skills";function wo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(wo,"isRecord");function wk(e){for(let t of Tk){let n=No(e,t);if(bp(n)){let r=Y(n,{});return wo(r)?r:{}}}return{}}s(wk,"readManifest");function Op(e,t){let n=Ap(e),r=Ap(n,t),o=bk(n,r);return o===""||!o.startsWith("..")&&!o.startsWith(Ok)&&o!==".."?r:null}s(Op,"insidePlugin");function Nk(e,t){let n=Y(No(e,Ik),{}),r=wo(n)?n.plugins:void 0,o=wo(r)?r[t]:void 0,i=wo(o)?o.enabled:void 0;return typeof i=="boolean"?i:void 0}s(Nk,"enabledFromConfig");function vk(e,t){let n=Array.isArray(t.skills)?t.skills.filter(o=>typeof o=="string"):typeof t.skills=="string"?[t.skills]:[Pk],r=[];for(let o of n){let i=Op(e,o);i!==null&&!r.includes(i)&&r.push(i)}return r}s(vk,"skillRootsOf");function Lk(e,t){let n=typeof t.mcpServers=="string"?[t.mcpServers]:[...xk],r=[];for(let o of n){let i=Op(e,o);i!==null&&bp(i)&&!r.includes(i)&&r.push(i)}return r}s(Lk,"mcpConfigFilesOf");function Mk(e){try{return Ak(e,{withFileTypes:!0}).filter(t=>t.isDirectory()).sort((t,n)=>t.name<n.name?-1:t.name>n.name?1:0)}catch{return[]}}s(Mk,"readPluginDirs");function Rn(e){let t=No(e,kk);return Mk(t).map(n=>{let r=No(t,n.name),o=wk(r),i=Nk(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:vk(r,o),mcpConfigFiles:Lk(r,o)}})}s(Rn,"listAntigravityPlugins");function kp(e,t){return`${e}_${t}`}s(kp,"antigravityPluginServerName");var Ut=Te(Pe(),1);var Uk=300,Hk=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 Tp(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}s(Tp,"capLength");function Dk(e){return Tp(e,Uk)}s(Dk,"capCommand");function xp(e,t){let n=Ip(e.trim(),t),r=(0,Ut.tokenizeCommand)(n);if(r.length===0)return"";let[o,...i]=r,a=(0,Ut.redactCommandOrUrl)(o),c=(0,Ut.redactArgs)(i);return Dk([a,...c].join(" "))}s(xp,"sanitizeHookCommand");function Pp(e,t){if(typeof e!="string")return null;let n=Ip(e.trim(),t),r=(0,Ut.tokenizeCommand)(n)[0];if(!r)return null;let o=(0,Ut.redactCommandOrUrl)(r);return o.length===0?null:Tp(o,Hk)}s(Pp,"executableFromCommand");function Fk(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(Fk,"classifyActionKind");function $k(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($k,"normalizeHookActions");function ia(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 $k(u)){if(e.truncated)return;let l=f.command??f.bash??f.prompt??f.powershell??u.powershell??"",p=Fk({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:xp(l,e.home)}:{}}})}}}s(ia,"collectHooksFromObject");function vo(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||ia(e,t,r.hooks,n)}s(vo,"collectHooksFile");var Lo=50;function lr(e,t,n,r){if(!wp(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:i}=e.withPluginExpandCap(Lo,()=>{Ye(e,{dir:me(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),Ye(e,{dir:me(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),Ye(e,{dir:me(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});vo(e,me(t,"hooks","hooks.json"),n),vo(e,me(t,"hooks.json"),n);let a=e.components.length-o,c=i>=Lo;return{componentCount:a,expandTruncated:c}}s(lr,"expandPluginTree");function Cn(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(Cn,"addPluginRow");function aa(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(aa,"readEnabledPlugins");function Kk(e){let t=aa(e.readJson(me(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=Gn(process.platform,e.home),o=e.readJson(n,{}),i={};if(o&&Object.keys(o).length>0)i=aa(o);else for(let a of r)Object.assign(i,aa(e.readJson(a,{})));return{...t,...i}}s(Kk,"resolveClaudeEnabledPlugins");function Np(e){let t=me(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=Kk(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 A of u)if(typeof A.installPath=="string"&&A.installPath.length>0){let P=lr(e,A.installPath,g,l);E+=P.componentCount,S=S||P.expandTruncated}Cn(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(Np,"collectClaudePlugins");function Gk(e){let t=e,n="";try{let r=jk(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=me(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),i=o[o.length-1];i&&(t=me(e,i),n=i)}}catch{}return{installPath:t,version:n}}s(Gk,"pickVersionDir");var Vk=/^\d+$/;function zk(e){let t=e.filter(n=>!Vk.test(n.pluginId));return t.length>0?t:e}s(zk,"dedupeCursorCachePlugins");function vp(e){let t=[{base:me(e.home,".cursor/plugins/local"),scope:"local"},{base:me(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=me(n,o.name),f=`plugin:${c}`,{componentCount:l,expandTruncated:p}=lr(e,u,f,!0);Cn(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(me(n,i))){if(!c.isDirectory())continue;let u=me(n,i,c.name),{installPath:f,version:l}=Gk(u);a.push({pluginId:c.name,installPath:f,version:l})}for(let c of zk(a)){if(e.truncated)break;let u=`${c.pluginId}@${i}`,f=`plugin:${u}`,{componentCount:l,expandTruncated:p}=lr(e,c.installPath,f,!0);Cn(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(vp,"collectCursorPlugins");function Lp(e){for(let t of Rn(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(Lo,()=>{for(let f of t.skillRoots){if(wp(me(f,"SKILL.md"))){It(e,{absolutePath:me(f,"SKILL.md"),kind:"SKILL",origin:i,enabled:o,name:Bk(f)});continue}Ye(e,{dir:f,kind:"SKILL",origin:i,enabled:o,nested:"SKILL.md"})}Ye(e,{dir:me(r,"agents"),kind:"SUBAGENT",origin:i,enabled:o,extensions:[".md"]}),Ye(e,{dir:me(r,"rules"),kind:"RULE",origin:i,enabled:o,extensions:[".md"]})});vo(e,me(r,"hooks.json"),i);for(let f of t.mcpConfigFiles)Po(e,f,i,{parentEnabled:o});let u=e.components.length-a;Cn(e,{pluginKey:n,rowPath:e.componentPath(r),enabled:o,scope:"local",version:t.version,componentCount:u,expandTruncated:c>=Lo,contentHash:q(`${n}|local|${t.version??""}|${o}|${u}`)})}}s(Lp,"collectAntigravityPlugins");import{existsSync as Yk}from"node:fs";var Wk=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,ca="<path>",Jk=new RegExp(`${ca}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function Mo(e){let t=e.replace(Wk,ca).replace(Jk,ca);return t.length>200?`${t.slice(0,200)}...`:t}s(Mo,"redactPermissionKey");var qe=Te(Pe(),1);var Mp=200,Up=200,ua=16*1024,Hp=6,Xk=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","allowedMcpServers","deniedMcpServers","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),qk=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),Zk=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),Qk=new Set(["permissions","approvalMode"]),eI={claude:Xk,cursor_sandbox:qk,cursor_permissions:Zk,cursor_cli:Qk},tI=new Set(["allow","deny","ask"]),nI=new Set(["allowedMcpServers","deniedMcpServers"]);function pt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(pt,"isRecord");function jp(e){return e.replace(/\\/g,"/")}s(jp,"posixPath");function la(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>la(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${la(t[r])}`).join(",")}}`}s(la,"canonicalJson");function rI(e){return q(`${la(e)}|settings1`)}s(rI,"hashSettingsAttributes");function Bp(e){let t=jp(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(Bp,"settingsProfileFor");function Kp(e,t){if(e!=="claude")return{};let n=jp(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(Kp,"managedSettingsMeta");function Dp(e,t){return e.length<=Up?e:(t.truncated=!0,e.slice(0,Up))}s(Dp,"capString");function pa(e,t){return e.length<=Mp?e:(t.truncated=!0,e.slice(0,Mp))}s(pa,"capArray");function le(e,t,n,r){if(typeof e=="string"){if(t==="path")return Dp((0,qe.tildePath)(e,n),r);let o=t==="rule"?Mo(e):e;return Dp((0,qe.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=pa(e,r),i=[];for(let a of o){let c=le(a,t,n,r);c!==void 0&&i.push(c)}return i}if(pt(e)){let o={};for(let[i,a]of Object.entries(e)){let c=le(a,t,n,r);c!==void 0&&(o[i]=c)}return o}}s(le,"transformValue");function Fp(e,t,n){if(!pt(e))return le(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a="plain";tI.has(o)?a="rule":o==="additionalDirectories"&&(a="path");let c=le(i,a,t,n);c!==void 0&&(r[o]=c)}return r}s(Fp,"transformPermissions");function oI(e,t,n){if(!pt(e))return le(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){if(o==="files"&&Array.isArray(i)){let c=pa(i,n);r[o]=c.map(u=>{if(!pt(u))return le(u,"plain",t,n);let f={};for(let[l,p]of Object.entries(u)){let m=le(p,l==="path"?"path":"plain",t,n);m!==void 0&&(f[l]=m)}return f});continue}let a=le(i,"plain",t,n);a!==void 0&&(r[o]=a)}return r}s(oI,"transformCredentials");function sI(e,t,n){if(!pt(e))return le(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let c=le(i,o==="allowUnixSockets"?"path":"plain",t,n);c!==void 0&&(r[o]=c)}return r}s(sI,"transformNetwork");function iI(e,t,n){if(!pt(e))return le(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a;o==="excludedCommands"?a=le(i,"rule",t,n):o==="filesystem"?a=le(i,"path",t,n):o==="network"?a=sI(i,t,n):o==="credentials"?a=oI(i,t,n):a=le(i,"plain",t,n),a!==void 0&&(r[o]=a)}return r}s(iI,"transformSandbox");var aI=/[a-z][a-z0-9+.-]+:[\\/]/i;function cI(e){let[t,...n]=e.filter(r=>typeof r=="string"&&r.length>0);return t===void 0?[]:[t,...(0,qe.redactArgs)(n)].map(r=>aI.test(r)?qi(r):r)}s(cI,"redactServerCommand");function uI(e){if(!pt(e))return qe.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]=qi(r):n==="serverCommand"&&Array.isArray(r)?t[n]=cI(r):t[n]=qe.OMITTED_VALUE;return t}s(uI,"sanitizeMcpServerMatcher");function lI(e,t,n){if(!Array.isArray(e))return qe.OMITTED_VALUE;let r=pa(e,n).map(uI);return le(r,"plain",t,n)}s(lI,"transformMcpServerMatchers");function fI(e,t,n,r,o){return n==="claude"?e==="permissions"?Fp(t,r,o):e==="sandbox"?iI(t,r,o):nI.has(e)?lI(t,r,o):le(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?le(t,"path",r,o):le(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?le(t,"rule",r,o):le(t,"plain",r,o):e==="permissions"?Fp(t,r,o):le(t,"plain",r,o)}s(fI,"transformByProfile");function fr(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(fr,"jsonBytes");function fa(e,t){return e?`${e}.${t}`:t}s(fa,"childPath");function da(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>=Hp?(e.splice(o,1),r.add(n)):da(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>=Hp?(delete e[o],r.add(fa(n,o))):da(i,t+1,fa(n,o),r))}s(da,"pruneDepth");function Gp(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:fr(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))Gp(o,fa(t,r),n)}s(Gp,"collectTrimCandidates");function dI(e,t,n){let r=fr(e);if(r<=ua)return;t.truncated=!0;let o=[];for(Gp(e,"",o);r>ua;){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=fr(a)+(i.items.length>0?1:0);i.bytes-=c,r-=c,n.add(i.path)}for(;fr(e)>ua;){let i,a=-1;for(let[c,u]of Object.entries(e)){let f=fr(u);f>a&&(i=c,a=f)}if(i===void 0)break;delete e[i],n.add(i)}}s(dI,"fitSettingsJson");function pI(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=fI(u,e[u],t,n,o);f!==void 0&&(i[u]=f)}a.sort();let c=new Set;return da(i,1,"",c),c.size>0&&(o.truncated=!0),dI(i,o,c),{settings:i,keys_omitted:a,truncated:o.truncated,trimmed_paths:[...c].sort()}}s(pI,"extractSettingsPosture");function $p(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($p,"pushPostureRow");function ma(e,t,n,r){if(!e.claimFile(t)||!Yk(t))return;let o=uu(t);if(!o.ok||!pt(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),$p(e,{kind:r.kind,absPath:t,origin:n,attributes:l})}return}let i=o.value,a=i.hooks;if(pt(a)&&ia(e,t,a,n),!r.profile)return;let c=pI(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),$p(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}s(ma,"collectSettingsFile");import{existsSync as mI}from"node:fs";import{join as Ze}from"node:path";var Vp=".claude/skills/synced",zp=".claude/plugins/synced";function Wp(e){return[Ze(e,Vp),Ze(e,zp)]}s(Wp,"claudeSyncedDirs");function Uo(e){return typeof e=="string"&&e.length>0?e:void 0}s(Uo,"stringField");function Jp(e){let t=Ze(e.home,Vp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ze(t,n.name),o=e.readJson(Ze(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=Ze(r,a.name,"SKILL.md");if(!a.isDirectory()||!mI(c))continue;let u=i.get(a.name),f=Uo(u?.source),l=Uo(u?.creatorType);It(e,{absolutePath:c,kind:"SKILL",origin:"user",enabled:!0,name:a.name,attributes:{scope:"synced",...f?{source:f}:{},...l?{creator_type:l}:{}}})}}}s(Jp,"collectClaudeSyncedSkills");function Yp(e){let t=Ze(e.home,zp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ze(t,n.name),o=e.readJson(Ze(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=Uo(c?.marketplaceName),f=Uo(c?.version),l=u?`${a.name}@${u}`:a.name,p=Ze(r,a.name),{componentCount:d,expandTruncated:m}=lr(e,p,`plugin:${l}`,!0);Cn(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(Yp,"collectClaudeSyncedPlugins");function _I(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:i}=t;for(let a of n.skillRoots)Ye(e,{dir:An(r,a),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:Wp(e.home)});for(let a of n.dirs)Ye(e,{dir:An(r,a.dir),kind:a.kind,origin:o,enabled:!0,extensions:a.extensions});for(let a of n.memory){let c=Yf(a.map(u=>An(r,u)));c&&It(e,{absolutePath:c,kind:"MEMORY",origin:o,enabled:!0,name:gI(c)})}for(let a of Zf(n))ma(e,An(r,a),o,{kind:"SETTINGS",profile:Bp(a)});for(let a of n.mcpJson??[])Po(e,An(r,a),o);for(let a of n.mcpToml??[])Cp(e,An(r,a),o);if(i){if(n.managed){for(let a of zr(n.managed,process.platform,e.home))if(a.toLowerCase().endsWith(".json")){let c=Kp(n.managed,a);ma(e,a,o,{kind:"MANAGED_SETTINGS",...c})}}n.plugins==="claude"?(Np(e),Yp(e),Jp(e)):n.plugins==="cursor"?vp(e):n.plugins==="antigravity"&&Lp(e)}}s(_I,"walkPlatformLayout");function Xp(e,t){try{let n=new co(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)_I(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(Xp,"walkScope");function ga(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let u=Xp(t,{layouts:Object.values(gn),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:yt,scopeRef:""});u&&(r.user=u)}let i=n.inGitRepo===!0,a=null,c=n.launchCwd;if(c!==void 0){let u=Object.values(xt),f=ri({launchCwd:c,gitRoot:n.gitRoot,inGitRepo:i,remote:n.remote,home:t,hasProjectSpec:s(l=>ed(u,l),"hasProjectSpec")});a=f.parentRel;for(let l of f.anchors){let p=oi(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:si,scopeRef:p});d&&(r[l.scope]=d)}r.parent||(a=null)}return{scopes:r,parentRel:a,cwdInGitRepo:i}}s(ga,"collectUserSpec");function _a(e,t,n={}){let r=n.truncated===!0,o=qn(e),i=new Set(e.map(l=>Le(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=Le(l.path,l.name);u[p]!==ao(l)&&c.push(l)}let f=[];if(!r){for(let l of Object.keys(u))if(!i.has(l)){let p=Nl(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(_a,"diffUserSpec");var Zp=2*1024*1024,hI=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function ha(e,t,n){let r=new Set(t.map(i=>Le(i.path,i.name))),o=[];for(let i of e)i.text!==void 0&&(n.has(i.content_hash)||r.has(Le(i.path,i.name))||o.push(i));return o}s(ha,"collectPendingTextBodies");function Ea(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(Ea,"pruneDeliveredTextHashes");function qp(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(qp,"jsonSize");function Qp(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}s(Qp,"withoutText");function Sa(e,t=Zp){let n=[],r=[];for(let l of e)hI.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=qp(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=Qp(l),g=qp(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 ya(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:Qp(n))}s(ya,"stripAlreadyDeliveredText");var EI=["user","cwd","repo","parent"];function Ra(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,i=[];for(let T of EI){let k=t.scopes[T];if(!k)continue;let U=n(T,k.scopeRef),v=U.components,I=_a(k.components,v,{forceFull:v===void 0,truncated:k.truncated}),N=new Set(U.textHashes),M=ha(k.components,I.upserts,N),h=ya([...I.upserts,...M],N);i.push({scope:T,walk:k,delta:I,outgoing:h,outgoingKeys:new Set(h.map(x=>Le(x.path,x.name))),deliveredTextHashes:N,cachedComponents:v})}let a=i.flatMap(T=>T.outgoing),c=Sa(a,o),u=new Set(c.components.map(T=>Le(T.path,T.name))),f=[],l=[],p=[],d=[],m=[],g=[],E=[];for(let T of i){let{scope:k,walk:U,delta:v}=T;g.push(...U.components),f.push(k);let I=c.components.filter(x=>T.outgoingKeys.has(Le(x.path,x.name))),N=[...T.outgoingKeys].some(x=>!u.has(x)),M=v.truncated||N;M?p.push(k):v.full&&l.push(k),d.push(...I),!v.full&&!M&&m.push(...v.removed);let h=v.full?{}:{...T.cachedComponents??{}};if(!M)for(let x of v.removed)delete h[Le(x.path,x.name)];for(let x of I)h[Le(x.path,x.name)]=ao(x);E.push({scope:k,scopeRef:U.scopeRef,components:h,textHashes:Ea(T.deliveredTextHashes,I.filter(x=>x.text!==void 0).map(x=>x.content_hash),U.components),collectedAtMs:r,included:I.length>0||v.removed.length>0&&!M||v.full})}let S={user_spec_hash:qn(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 A=t.scopes.cwd;A&&(S.user_spec_cwd_scope_ref=A.scopeRef);let P=t.scopes.repo;P&&(S.user_spec_repo_scope_ref=P.scopeRef);let w=t.scopes.parent;return w&&(S.user_spec_parent_scope_ref=w.scopeRef,t.parentRel&&(S.user_spec_parent_rel=t.parentRel)),{fields:S,scopes:E}}s(Ra,"buildUserSpecSend");var Ho={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function Ca(e){return e==="cwd"||e==="repo"||e==="parent"}s(Ca,"isProjectSpecScope");function dr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(dr,"isPlainObject");function Aa(e){return!dr(e)||!dr(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(Aa,"isDirScopeCacheEntry");function em(e){return SI(e)}s(em,"readStringHashMap");function tm(e){return yI(e)}s(tm,"readStringArray");function nm(e){return RI(e)}s(nm,"cloneDirScopeMap");function SI(e){if(!dr(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}s(SI,"readComponentHashMap");function yI(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}s(yI,"readTextHashes");function rm(e,t){if(!dr(e))return;let n=e[t];return Aa(n)?n:void 0}s(rm,"readDirScopeCacheEntry");function RI(e){if(!dr(e))return{};let t={};for(let[n,r]of Object.entries(e))Aa(r)&&(t[n]=r);return t}s(RI,"readDirScopeCacheMap");function ba(e,t=20){let n=[];for(let[r,o]of Object.entries(e))Aa(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(ba,"boundDirScopeCache");var kI=["allow","deny","ask"];function Fo(e){let t=Y(e,{}),n=[];for(let r of kI)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:Mo(o),mode:r});return{model:t.model??"",permissionKeys:n}}s(Fo,"readClaudeSettings");function II(e){let{serverManaged:t,fileBased:n}=Gn(process.platform,e),r=Fo(t);if(r.model||r.permissionKeys.length>0)return r;let o="",i=[];for(let a of n){let c=Fo(a);c.model&&(o=c.model),i.push(...c.permissionKeys)}return{model:o,permissionKeys:i}}s(II,"readClaudeManagedSettings");function TI(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(TI,"dedupePermissionKeys");var xI=10,PI="self-config-cache.json",sm=7;function On(){return j("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}s(On,"isUserSpecDisabled");function wI(){return j("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}s(wI,"isCwdSpecDisabled");var NI={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"],copilot:["copilot"],antigravity:["agy"]};async function vI(e,t=oe){let n=NI[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(`
|
|
30
|
+
`)[0]??"").trim();return c||r(o+1)},"tryNext");return r(0)}s(vI,"resolveCliVersion");function im(e=Ta()){return bn(e,".ev-ai","agent-hook",PI)}s(im,"selfConfigCachePath");function am(e=Ta()){try{bI(im(e))}catch(t){if(t.code==="ENOENT")return;let n=t instanceof Error?t.message:String(t);C(`WARN: self-config cache clear failed open: ${n}`),L("self_config_cache_clear",t)}}s(am,"clearSelfConfigCache");function LI(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
|
|
31
|
+
`);return q(n)}s(LI,"hashConfigEntries");function Do(e,t,n=!1){let r=LI(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(Do,"buildHashedList");function Oa(e,t,n=[]){let r=0,o=!1,i=new Set;for(let a of[...t.map(c=>bn(e,c)),...n]){let c=OI(a);if(i.has(c))continue;i.add(c);let u=Is(a);u.present&&(o=!0,r+=u.size)}return o?{present:!0,size:r}:{present:!1,size:0}}s(Oa,"filePresenceUnion");var ka="installation_id";function Ia(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Ia,"isPlainRecord");function MI(e,t){if(!AI(e))return{};let n=we(om(e,"utf8"),{});if(!Ia(n))return{};let r=n[ka];if(t&&typeof r=="string"&&r!==t)return{};let o={};for(let[i,a]of Object.entries(n))i!==ka&&Ia(a)&&(o[i]=a);return o}s(MI,"readSelfConfigCache");function UI(e){try{let t=we(om(e,"utf8"),{}),n=Ia(t)?t.installation_id:void 0;return typeof n=="string"&&n.length>0?n:void 0}catch{return}}s(UI,"storedInstallationId");function HI(e,t,n){let r=n?{...t,[ka]:n}:t;try{fe(e,`${JSON.stringify(r)}
|
|
32
|
+
`)}catch(o){let i=o instanceof Error?o.message:String(o);C(`WARN: self-config cache write failed open: ${i}`),L("self_config_cache",o)}}s(HI,"writeSelfConfigCache");function DI(e,t,n){if(t==="user")return{components:em(e.user_spec_components),textHashes:tm(e.user_spec_text_hashes)};if(!Ca(t))return{components:void 0,textHashes:[]};let r=rm(e[Ho[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}s(DI,"cacheSliceFor");function FI(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=sm,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=Ho[i.scope],c=nm(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]=ba(c)}}return o}s(FI,"nextPlatformSelfConfigCache");async function cm(e,t=process.cwd(),n=Ta(),r={}){let o=e==="claude",i=r.gitRoot??t,a=await vI(e),c="",u=[];if(o){let M=II(n),h=Fo(bn(n,".claude/settings.json")),x=Fo(bn(t,".claude/settings.local.json"));c=M.model||x.model||h.model,u=TI([...M.permissionKeys,...h.permissionKeys,...x.permissionKeys]).slice(0,200)}let f={present:!1,size:0},l=s(M=>{let h=[],x=!1;for(let G of M){let ke=lu(bn(n,G));if(h=h.concat(ke.entries),x=x||ke.truncated,h.length>=yt){h=h.slice(0,yt),x=!0;break}}return{entries:h,truncated:x}},"listScopeWithMeta"),p=im(n),d=MI(p,r.installationId),m=d[e]??{},g=(m.send_count??0)+1,E=g>0&&g%xI===0,S=s(M=>E?void 0:m[M],"cachedHash"),A=l(wt.skills),P=l(wt.subagents),w=l(wt.commands),T=l(wt.rules),k={skills:Do(A.entries,S("skills"),A.truncated),subagents:Do(P.entries,S("subagents"),P.truncated),commands:Do(w.entries,S("commands"),w.truncated),rules:Do(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:k.skills,subagents:k.subagents,commands:k.commands,rules:k.rules,memory:Oa(n,wt.memory),settings:Oa(n,wt.settings,td(n)),mcp:Oa(n,wt.mcp)},local_settings:o?Is(bn(t,".claude/settings.local.json")):f},v=null,I=r.nowMs??Date.now();if(!On()){let M=m.user_spec_layout_version!==sm,h=ga(e,n,{launchCwd:wI()?void 0:r.launchCwd,gitRoot:i,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(h.scopes).length>0){let x=Ra({collected:h,cacheFor:s((G,ke)=>M?{components:void 0,textHashes:[]}:DI(m,G,ke),"cacheFor"),nowMs:I});Object.assign(U,x.fields),v={hash:x.fields.user_spec_hash,home:x.scopes.find(G=>G.scope==="user")??null,project:x.scopes.filter(G=>G.scope!=="user")}}}let N=FI(m,k,g,v);return{config:U,commit:s(()=>{let{installationId:M,installationStorePath:h}=r;if(M&&h){let x=UI(h);if(x!==void 0&&x!==M)return}d[e]=N,HI(p,d,M)},"commit")}}s(cm,"selfConfig");import{createHash as $I}from"node:crypto";import{readFileSync as jI,statSync as lm}from"node:fs";import{homedir as BI}from"node:os";import{isAbsolute as KI,join as Ht,resolve as um}from"node:path";var GI="^(user\\.(name|email)|remote\\.origin\\.url)$",VI=3600*1e3,zI=32;function fm(e){return $I("sha256").update(e).digest("hex")}s(fm,"sha256");function WI(e){let t={userName:null,userEmail:null,remoteOriginUrl:null};for(let n of e.split(`
|
|
33
|
+
`)){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(WI,"parseGitConfigValues");function JI(e){return{userName:e.userName,userEmail:e.userEmail,remoteOriginUrlSha256:e.remoteOriginUrl?fm(e.remoteOriginUrl):null}}s(JI,"toFacts");function $o(e){try{return jI(e,"utf8")}catch{return null}}s($o,"readTextOrNull");function YI(e){let t=Ht(e,".git"),n;try{if(lm(t).isDirectory())n=t;else{let o=/^gitdir:\s*(.+?)\s*$/m.exec($o(t)??"")?.[1];if(!o)return null;n=KI(o)?o:um(e,o)}}catch{return null}let r=$o(Ht(n,"commondir"))?.trim();return{gitDir:n,commonDir:r?um(n,r):n}}s(YI,"repoGitDirs");function XI(e){let t=e.GIT_CONFIG_GLOBAL?.trim();if(t)return[t];let n=e.HOME?.trim()||BI(),r=e.XDG_CONFIG_HOME?.trim();return[Ht(n,".gitconfig"),Ht(r||Ht(n,".config"),"git","config")]}s(XI,"globalConfigPaths");function qI(e){try{let t=lm(e);return`${e}|${String(t.mtimeMs)}|${String(t.size)}`}catch{return`${e}|-`}}s(qI,"fileStamp");var ZI=["GIT_DIR","GIT_COMMON_DIR","GIT_CONFIG"];function QI(e){return ZI.some(t=>!!e[t]?.trim())}s(QI,"hasGitLocationOverride");function eT(e,t=process.env){let n=YI(e),r=n?[Ht(n.commonDir,"config"),Ht(n.gitDir,"config.worktree")]:[],o=n?`HEAD|${$o(Ht(n.gitDir,"HEAD"))?.trim()??"-"}`:"HEAD|-",i=[...r,...XI(t)].map(qI),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(`
|
|
34
|
+
`)}s(eT,"gitConfigStamp");function xa(e){return typeof e=="string"&&e.length>0?e:null}s(xa,"nullableString");function dm(e){let t=$o(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:xa(c.user_name),user_email:xa(c.user_email),remote_origin_url_sha256:xa(c.remote_origin_url_sha256)})}return o}s(dm,"readCacheEntries");function tT(e){return!e.userName&&!e.userEmail&&!e.remoteOriginUrlSha256}s(tT,"isEmpty");function nT(e,t,n){if(e?.stamp_sha256!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<VI}s(nT,"isFresh");function rT(e,t,n){let r={...dm(e),[t]:n},o=Object.entries(r).sort(([,i],[,a])=>a.read_at_ms-i.read_at_ms).slice(0,zI);try{fe(e,`${JSON.stringify({entries:Object.fromEntries(o)})}
|
|
35
|
+
`)}catch(i){let a=i instanceof Error?i.message:String(i);C(`WARN: git config cache write failed open: ${a}`)}}s(rT,"writeCacheEntry");async function jo(e,t={}){let n=t.exec??oe,r=t.env??process.env,o=QI(r)?void 0:t.cachePath,i=o?fm(eT(e,r)):"",a=t.nowMs??Date.now();if(o){let f=dm(o)[e];if(f&&nT(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",GI],2e3,{cwd:e}),u=JI(WI(c));return o&&!tT(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(jo,"readGitConfigValues");var iT="installation.json",aT="git-config.json",cT="cloud-bootstrap.lock",uT=6e4;function Rm(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}s(Rm,"platformAgentIdCacheKey");function Oe(e=pr()){return Ko(e,".ev-ai","agent-hook")}s(Oe,"agentHookHome");function lT(e=pr()){return Ko(Oe(e),iT)}s(lT,"installationStorePath");function kn(e=pr()){return Ko(Oe(e),aT)}s(kn,"gitConfigCachePath");function Cm(e){return Ko(Bo(e),cT)}s(Cm,"cloudBootstrapLockPath");function Am(){return oT(8).toString("hex")}s(Am,"randomInstallationId");function Dt(e){return _m("sha256").update(e).digest("hex").slice(0,16)}s(Dt,"sha16");function z(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(z,"trimEnv");function bm(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}s(bm,"isValidInstallationId");function fT(e=process.env){let t=z(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!bm(t)){C(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}s(fT,"readInstallationIdEnvOverride");function Om(e,t){return e&&bm(e)?e:(e&&C(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),fT(t))}s(Om,"resolvePinnedInstallationId");function dT(e){return/^[0-9a-f]{16}$/.test(e)}s(dT,"isEphemeralInstallationIdShape");function pT(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 Dt(`github_actions|${t}|${n}`)}if(z(e.CODESPACES)||z(e.CODESPACE_NAME)){let t=z(e.CODESPACE_NAME);if(t)return Dt(`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 Dt(`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 Dt(`gitlab|${t}|${n}`)}return null}s(pT,"deriveEphemeralInstallationId");var km="cursoragent@cursor.com";function mT(e){let t=z(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===km?null:t}s(mT,"cursorCloudUserEmail");function gT(e,t){return z(e.CURSOR_PROJECT_DIR)??z(e.CLAUDE_PROJECT_DIR)??t}s(gT,"cursorCloudWorkspacePath");function _T(e){return jn(e).replace(/\.git$/i,"").toLowerCase()}s(_T,"normalizeRemoteForSeed");async function hT(e){let t=await oe("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?_T(t):e}s(hT,"resolveRepoSeed");async function ET(e){let t=z(await oe("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!_e(null,t))return t;let n=z(await oe("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!_e(null,n)?n:null}s(ET,"readClaudeRemoteOperatorEmail");function ST(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!==km?{kind:"email",value:n}:null}s(ST,"cursorCloudOwnerKey");function yT(e,t,n){let r=gT(e,t);if(!r)return null;let o=ST(n);return o?(se.info(`cursor_cloud installation key=${o.kind}`),{id:Dt(`cursor_cloud/v2|${r}|${o.value}`),cursorCloudSeed:"v2"}):(se.info("cursor_cloud installation key=v1"),{id:Dt(`cursor_cloud|${r}|${mT(e)??""}`),cursorCloudSeed:"v1"})}s(yT,"deriveCursorCloudInstallationSeed");async function RT(e,t,n,r,o){if(e==="cursor_cloud"&&t)return yT(n,r,await eo({env:n,home:o}));if(e==="claude_remote"){let i=await CT(n,r,o);return i?{id:i}:null}return null}s(RT,"deriveCloudInstallationId");async function CT(e,t,n=pr()){let r=Mu(n);if(r)return se.info("claude_remote installation key=email"),Dt(`claude_remote/v2|${r}`);se.info("claude_remote installation key=v1");let o=z(e.CLAUDE_PROJECT_DIR)??t;if(!o)return null;let i=await hT(o),a=await ET(o);return Dt(`claude_remote|${i}|${a??""}`)}s(CT,"deriveClaudeRemoteInstallationId");function pm(e,t){let n=Om(e,t);if(n)return n;let r=pT(t);return r||Am()}s(pm,"chooseNewInstallationId");async function AT(e,t={}){let{remoteOriginUrlSha256:n}=await jo(e,t);return(n??_m("sha256").update(sT(e)).digest("hex")).slice(0,16)}s(AT,"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 OT(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(OT,"parseInstallationRecord");function Zt(e){if(hm(e))try{return OT(Em(e,"utf8"))}catch{}}s(Zt,"readInstallationRecord");function Na(e){return Zt(e)}s(Na,"readInstallationStore");function Im(e,t,n){let r=Zt(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{fe(e,`${JSON.stringify(o,null,2)}
|
|
36
|
+
`)}catch(i){let a=i instanceof Error?i.message:String(i);C(`WARN: operator identity cache write failed open: ${a}`),L("operator_identity_cache",i)}}s(Im,"writeOperatorIdentityCache");function Tm(e,t=Date.now()){if(!e)return!0;if(Zt(e)?.operator_identity_hash)return!1;let n=Cm(e);try{if(hm(n)){let r=Number.NaN;try{r=Number(Em(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<uT)return!1;try{Sm(n)}catch{}}}catch{}try{return wa(Bo(n),{recursive:!0}),ym(n,`${t}
|
|
37
|
+
`,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(Nm(r))return!1;let o=r instanceof Error?r.message:String(r);return C(`WARN: cloud bootstrap claim failed open: ${o}`),L("cloud_bootstrap_claim",r),!0}}s(Tm,"tryClaimCloudIdentityBootstrap");function xm(e){if(e)try{Sm(Cm(e))}catch{}}s(xm,"releaseCloudIdentityBootstrapClaim");function Pm(e,t){let r=Zt(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}s(Pm,"readCachedPlatformAgentId");function wm(e,t,n){if(!n)return;let r=Zt(e);if(!r||r.platform_agent_ids?.[t]===n)return;let o={...r,platform_agent_ids:{...r.platform_agent_ids,[t]:n}};try{fe(e,`${JSON.stringify(o,null,2)}
|
|
38
|
+
`)}catch(i){let a=i instanceof Error?i.message:String(i);C(`WARN: platform_agent_id cache write failed open: ${a}`),L("platform_agent_id_cache",i)}}s(wm,"writeCachedPlatformAgentId");function Nm(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}s(Nm,"isEexistError");function kT(e,t){wa(Bo(e),{recursive:!0}),ym(e,`${JSON.stringify(t,null,2)}
|
|
39
|
+
`,{encoding:"utf8",flag:"wx"})}s(kT,"writeInstallationRecordExclusive");function mm(e,t){try{return kT(e,t),t}catch(n){if(!Nm(n))throw n;return Zt(e)}}s(mm,"tryCreateInstallationRecord");function Pa(e,t){wa(Bo(e),{recursive:!0}),fe(e,`${JSON.stringify(t,null,2)}
|
|
40
|
+
`)}s(Pa,"replaceInstallationRecord");function gm(e,t,n){return{installation_id:e,...t&&t===e?{pinned:!0}:{},...n?.cursorCloudSeed==="v2"&&n.id===e?{cursor_cloud_seed:"v2"}:{}}}s(gm,"newInstallationRecord");async function Go(e,t={}){let n=t.home??pr(),r=t.env??process.env,o=await AT(e,{cachePath:kn(n)}),i=lT(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=no(a),u=Om(t.overrideId,r),f=await RT(c,c==="cursor_cloud"&&Js(a),r,e,n),l=f?.id??null,p=Zt(i);if(p){let S=p;u&&u===p.installation_id&&p.pinned!==!0&&(S={...p,pinned:!0},Pa(i,S)),f?.cursorCloudSeed==="v2"&&f.id===S.installation_id&&S.cursor_cloud_seed!=="v2"&&(S={...S,cursor_cloud_seed:"v2"},Pa(i,S));let A=S.cursor_cloud_seed==="v2"&&f?.cursorCloudSeed!=="v2";if(!!l&&l!==S.installation_id&&!u&&S.pinned!==!0&&!A&&dT(S.installation_id)&&l){let w={installation_id:l,...S.platform_agent_ids?{platform_agent_ids:S.platform_agent_ids}:{},...f?.cursorCloudSeed==="v2"?{cursor_cloud_seed:"v2"}:{}};return Pa(i,w),am(n),{installationId:l,storePath:i,repoKey:o}}return{installationId:S.installation_id,storePath:i,repoKey:o}}let d=u??l??pm(void 0,r),m=mm(i,gm(d,u,f));if(m)return{installationId:m.installation_id,storePath:i,repoKey:o};let g=u??l??pm(void 0,r),E=mm(i,gm(g===d?Am():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(Go,"resolveOrCreateInstallationId");import{existsSync as Ma,readFileSync as DT}from"node:fs";import{dirname as FT,isAbsolute as $T,join as jT,relative as BT}from"node:path";import{readFileSync as IT,statSync as TT}from"node:fs";import{homedir as va}from"node:os";import{join as xT}from"node:path";var PT="hook-config.json",wT=1440*60*1e3,NT=2048,vT=1024*1024;function In(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(In,"isRecord");function vm(e=va()){return xT(Oe(e),PT)}s(vm,"hookConfigPath");function Lm(e){let t=vm(e);try{let n=TT(t);if(!n.isFile()||n.size>vT)return;let r=JSON.parse(IT(t,"utf8"));return In(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}s(Lm,"readStore");function LT(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===ln||!Number.isNaN(Date.parse(e.log_until)))&&(t.log_until=e.log_until),t}s(LT,"knownKeys");function Mm(e,t=va()){if(!e)return;let n=Gt(e);if(!n)return;let r=Lm(t),o=r?r[n]:void 0;if(!(!In(o)||!In(o.config)))return LT(o.config)}s(Mm,"readHookConfig");function MT(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!In(n)||!In(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>NT))return n.hook_config}s(MT,"hookConfigFromBody");function UT(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(!(In(i)&&JSON.stringify(i.config)===JSON.stringify(n)&&typeof i.fetched_at_ms=="number"&&i.fetched_at_ms<=r&&r-i.fetched_at_ms<wT))return o[t]={config:n,fetched_at_ms:r},o}s(UT,"nextStore");function Um(e,t,n=va(),r=Date.now()){let o=MT(e),i=t?Gt(t):void 0;if(o===void 0||!i)return"skipped";try{let a=Lm(n);if(a===void 0)return se.error("failed where=hook_config_read err=unreadable message=hook config store is not a readable JSON object"),"skipped";let c=UT(a??{},i,o,r);return c?(fe(vm(n),`${JSON.stringify(c,null,2)}
|
|
41
|
+
`),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(a){let c=a instanceof Error?a.message:String(a);return C(`WARN: hook config write failed open: ${c}`),L("hook_config_write",a),"failed"}}s(Um,"applyCollectorHookConfigResponse");var HT="EV_AI_HOOK_TELEMETRY";function Hm(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}s(Hm,"telemetryFromHomeConfig");function Dm(e,t,n=process.env){let r=n[HT]?.trim().toLowerCase();return r&&jt.has(r)?{enabled:!0,source:"env"}:r&&Ur.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(Dm,"resolveTelemetry");function Fm(e){for(let t of Fr){let n=jT(e,t);if(Ma(n))return n}}s(Fm,"firstExistingManifest");async function KT(e=process.cwd(),t){let n=t??await tt(e);return Fm(n)??Fm(e)}s(KT,"findRepoManifestPath");async function GT(e,t){let n=t??await tt(FT(e)),r=BT(n,e);if(r.startsWith("..")||$T(r))return!1;let o=await De("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(C(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}s(GT,"isManifestGitTracked");function La(e){let t=DT(e,"utf8");return we(sn(t),{})}s(La,"loadRepoManifestFromFile");function VT(){return{schema_version:Ct,mcp_servers:[]}}s(VT,"defaultSharedManifest");function zT(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(C(`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")&&(C(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}s(zT,"stripTrackedUnsafeFields");function WT(e){let t=Ru({argv:e.argv,env:process.env,homeConfig:e.homeConfig,manifest:e.manifest,manifestSource:e.manifestSource});for(let r of t.warnings){C(`WARN: ignoring ${r.label}: ${r.problem}`);let o=r.label.replace(/\s+/g,"_"),i=r.problem.replace(/\/[^/\s]+\/hook\b/g,"/***/hook");se.error(`collector ignored label=${o} message=${i}`)}let n=t.url??"";return se.info(`collector source=${t.source} url=${n?un(n):"(none)"}`),n}s(WT,"collectorUrlFromLoaded");function JT(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}s(JT,"recordOrUndefined");async function $m(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await ks(e),o=j("EV_AI_HOOK_MANIFEST"),i=o&&Ma(o)?o:void 0,a=i?void 0:Ma(Kt())?Kt():void 0,c=i?void 0:await KT(e,n),u=a?La(a):void 0,f=c?La(c):void 0,l=Hm(i?Y(Kt(),{}):u),p,d,m,g=new Set;if(i){p=La(i),d=i,m=i;for(let k of Object.keys(p))g.add(k)}else if(u&&f){p=Eu(f,u),d=a,m=c;for(let k of Object.keys(f))k in u||g.add(k)}else if(u)p=u,d=a;else if(f){p=f,d=c,m=c;for(let k of Object.keys(f))g.add(k)}else p=VT();delete p.installation_id;let E=m?await GT(m,n):!1;zT(p,m,E,g);let{installationId:S,storePath:A,repoKey:P}=await Go(n,{sessionId:t.sessionId}),w=u??JT(Y(Kt(),null)),T=WT({argv:t.argv??process.argv,homeConfig:w,manifest:i?p:f,manifestSource:i?"manifest_override":"manifest"});return{manifestPath:d??A,manifest:p,installationId:S,installationStorePath:A,repoKey:P,collectorUrl:T,hookConfig:Mm(T),...l!==void 0?{localTelemetry:l}:{},platformAgentId:p.platform_agent_id??"",gitRoot:n,inGitRepo:r}}s($m,"loadManifest");function jm(e){return{schema_version:Ct,...e?{collector_url:e}:{},mcp_servers:[]}}s(jm,"createDefaultSharedManifest");var YT=["darwin-arm64","darwin-x64","linux-arm64","linux-x64","windows-x64","windows-arm64"];function XT(e){return e==="windows-x64"||e==="windows-arm64"}s(XT,"isWindowsSlug");function Ua(e=process.platform,t=process.arch){if(e==="darwin")return t==="arm64"?"darwin-arm64":t==="x64"?"darwin-x64":void 0;if(e==="linux")return t==="arm64"?"linux-arm64":t==="x64"?"linux-x64":void 0;if(e==="win32")return t==="x64"?"windows-x64":t==="arm64"?"windows-arm64":void 0}s(Ua,"resolvePlatformSlug");function Bm(e=process.platform,t=process.arch){let n=Ua(e,t);if(!n)throw new Error(`Unsupported platform ${e}-${t}. Supported: ${YT.join(", ")}.`);return n}s(Bm,"assertSupportedPlatform");function qT(e){return XT(e)?`${Ne}.exe`:Ne}s(qT,"hookBinaryFileName");function Ha(e){return`compile-out/bin/${e}/${qT(e)}`}s(Ha,"compiledBinaryRelativePath");function ox(e,t){let n=e.collectorUrl?.trim();if(!n)throw new Error(`${t} requires --url <https://<collector-host>/{orgToken}/hook>`);let r=rt(n);if(r)throw new Error(`collector URL rejected: ${r}`);return Rt(n)}s(ox,"requireCollectorUrl");function sx(e){let t=e.collectorUrl?.trim();if(!t)return;let n=rt(t);if(n)throw new Error(`collector URL rejected: ${n}`);return Rt(t)}s(sx,"optionalCollectorUrl");function ix(e){return ox(e,"install")}s(ix,"requireInstallCollectorUrl");function Jm(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url")}return t}s(Jm,"parseConfigureArgs");function Ym(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url");if(r==="--update")throw new Error("--update was removed; use the `update` command instead of `install --update`");if(r==="--delivery"){let o=e[n+1];(o==="npx"||o==="binary"||o==="local")&&(t.delivery=o,n+=1);continue}if(r==="--force"){t.force=!0;continue}if(r==="--no-claude"){t.skipClaude=!0;continue}if(r==="--no-cursor"){t.skipCursor=!0;continue}if(r==="--no-codex"){t.skipCodex=!0;continue}}return t}s(Ym,"parseInstallArgs");function Xm(e=process.execPath){return qm(e)?"binary":"npx"}s(Xm,"defaultHookDelivery");function ax(){return Z(mt(),".ev-ai","agent-hook")}s(ax,"agentHookBinaryHome");function cx(e=mt()){return Z(e,".ev-ai","agent-hook",ws)}s(cx,"globalHookBinaryPath");function ux(){let e=$a(rx(import.meta.url)),t=Z(e,"hook.mjs");return Ft(t)?t:Z(e,"..","dist","hook.mjs")}s(ux,"resolveBundledHookPath");function qm(e=process.execPath){return Br(e)}s(qm,"isCompiledHookBinary");function Zm(e,t){let n=Wm(Km(e),Km(t));return!n.startsWith("..")&&!tx(n)}s(Zm,"isUnderRoot");function Wo(e){return e.split(nx).join("/")}s(Wo,"toPosixPath");function lx(e){return`node "$(git rev-parse --show-toplevel)/${Wo(e)}"`}s(lx,"gitRootRelativeNodeCommand");function fx(e){return`"$(git rev-parse --show-toplevel)/${Wo(e)}"`}s(fx,"gitRootRelativeBinaryCommand");function dx(e){return Z(e,Ns)}s(dx,"projectHookBinaryPath");function Qm(e,t){let n=dx(e);Fa($a(n),{recursive:!0}),zm(t,n,{force:!0});try{Vm(n,493)}catch{}return n}s(Qm,"pinHookBinaryIntoProject");function px(e){let t=Z(ax(),"current");try{zo(t,{recursive:!0,force:!0})}catch{}QT(e,t,process.platform==="win32"?"junction":"dir")}s(px,"refreshCurrentSymlink");function eg(e,t=Se,n=mt()){let r=Z(n,".ev-ai","agent-hook",t),o=Z(r,Ne);Fa(r,{recursive:!0}),zm(e,o,{force:!0});try{Vm(o,493)}catch{}return px(r),Z(n,".ev-ai","agent-hook",ws)}s(eg,"pinHookBinary");function tg(e){let t=Ua();if(!t)return;let n=[Z(e,Ha(t)),Z(e,"packages","agent-hook",Ha(t))];for(let r of n)if(Ft(r)&&Zm(e,r))return r}s(tg,"resolveDevBundledBinary");function mx(e=mt()){let t=cx(e);return Ft(t)?t:void 0}s(mx,"resolveGlobalBinary");function gx(e,t=mt()){let n=mx(t);return n||(qm()?eg(process.execPath,Se,t):tg(e))}s(gx,"resolveBinarySource");function _x(e,t=mt()){let n=tg(e);if(!n)throw new Error(`update requires a locally compiled binary \u2014 run this package\u2019s build:hook-binary script first.
|
|
42
|
+
To install a released binary instead: curl -fsSL https://cdn.ev-ai.ai/agent-hook/install.sh | sh`);let r=eg(n,Se,t),o=Qm(e,n);return{sourcePath:n,projectPath:o,globalPath:r}}s(_x,"refreshPinnedBinariesFromCompileOut");function Gm(e){let t=[Z(e,"packages","agent-hook","dist","hook.mjs"),Z(e,Cu)],n=ux();Ft(n)&&Zm(e,n)&&t.unshift(n);for(let r of t){if(!Ft(r))continue;let o=Wo(Wm(e,r));return{command:lx(o),hookPath:o,strategy:"dev_mjs"}}}s(Gm,"resolveDevMjsHook");function hx(e){return e==="SessionStart"||e==="sessionStart"}s(hx,"isSessionStartEvent");function Ex(e){return e.replace(/\s+--prefer-offline\b/g,"")}s(Ex,"withoutPreferOffline");function Vo(e,t){return hx(e)?Ex(t):t}s(Vo,"commandForEvent");function Sx(e=Gr){return`npx -y --prefer-offline ${e}`}s(Sx,"npxHookCommand");function yx(e,t=mt(),n=Xm()){if(n==="npx")return{command:Sx(),hookPath:Gr,strategy:"npx"};if(n==="local"){let i=Gm(e);if(i)return i;throw new Error("local delivery requires packages/agent-hook/dist/hook.mjs (or node_modules/@ev-ai/agent-hook/dist/hook.mjs) under the git root \u2014 run yarn workspace @ev-ai/agent-hook build first")}let r=gx(e,t);if(r){Qm(e,r);let i=Wo(Ns);return{command:fx(i),hookPath:i,strategy:"project_binary"}}let o=Gm(e);if(o)return o;throw new Error(`ev-ai-agent-hook binary not found. Install from CDN:
|
|
43
|
+
curl -fsSL ${Au}/install.sh | sh
|
|
44
44
|
Or use npx delivery:
|
|
45
|
-
npx ${
|
|
46
|
-
`,"utf8")}s(Pt,"writeJson");function ut(e){if(wt(e))try{return JSON.parse(Hx(e,"utf8"))}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON in ${e} \u2014 fix or remove the file`,{cause:t}):t}}s(ut,"readJson");function iI(e,t){let n=um(t.collectorUrl),r={...e,schema_version:e?.schema_version??n.schema_version};return t.collectorUrl!==void 0?r.collector_url=t.collectorUrl:r.collector_url=e?.collector_url??n.collector_url,delete r.repo_ingest_token,delete r.installation_id,r.mcp_servers??=n.mcp_servers,r}s(iI,"mergeManifestForInstall");function aI(e){return(e.schema_version??ht)===ht&&e.collector_url===void 0&&(e.mcp_servers?.length??0)===0&&e.platform_agent_id===void 0&&e.capture_hook_input===void 0&&e.debug===void 0&&e.repo_ingest_token===void 0}s(aI,"isDefaultSharedManifest");function km(e,t){let n=J(e,Tr),r=ut(n),o=iI(r,t);return t.collectorUrl!==void 0||wt(n)||!aI(o)?(Pt(n,o),{manifestPath:n,wrote:!0}):{manifestPath:void 0,wrote:!1}}s(km,"upsertSharedManifest");function ya(e){if(e===null||typeof e!="object")return!1;let t=e,n=String(t.CLAUDE_CODE_ENABLE_TELEMETRY??"").toLowerCase();return n==="1"||n==="true"?!0:Object.keys(t).some(r=>r.startsWith("OTEL_"))}s(ya,"envHasOtel");function cI(e){if(ya(process.env))return!0;let t=ct();return[...Es(),J(t,".claude","settings.json"),J(t,".claude","remote-settings.json"),J(e,".claude","settings.json"),J(e,".claude","settings.local.json")].some(r=>{try{let o=ut(r);return o?ya(o.env):!1}catch{return!1}})}s(cI,"claudeOtelEnabled");function uI(e){try{let t=ut(J(e,".claude","settings.json"));return t?ya(t.env):!1}catch{return!1}}s(uI,"projectClaudeOtelEnabled");function Om(e){return Array.isArray(e)?e:[]}s(Om,"asMatcherGroups");function Lo(e){let t=[],n=s(r=>!!r&&typeof r=="object"&&bm(r.command),"isOwnedHook");for(let r of Om(e)){if(!r||typeof r!="object"){t.push(r);continue}let o=Array.isArray(r.hooks)?r.hooks:[],i=o.filter(a=>!n(a));if(!(i.length===0&&o.some(n))){if(i.length!==o.length){t.push({...r,hooks:i});continue}t.push(r)}}return t}s(Lo,"stripEvAiMatcherGroups");function xm(e,t){return[...Lo(e),...t]}s(xm,"mergeMatcherHookEvents");function Aa(e){return Array.isArray(e)?e.filter(t=>!t||typeof t!="object"?!0:!bm(t.command)):[]}s(Aa,"stripEvAiCursorHooks");function lI(e,t){return[...Aa(e),{command:t}]}s(lI,"mergeCursorEventHooks");function fI(e){return typeof e=="string"?[e]:e}s(fI,"toCommandList");function dI(e){let t=s((n="")=>({hooks:fI(e).map(r=>({type:"command",command:No(n,r)}))}),"commandHook");return{SessionStart:[t("SessionStart")],UserPromptExpansion:[t()],UserPromptSubmit:[t()],PreToolUse:[t()],PostToolUse:[t()],PostToolUseFailure:[t()],PermissionDenied:[t()],Stop:[t()],StopFailure:[t()],SessionEnd:[t()],SubagentStart:[t()],SubagentStop:[t()]}}s(dI,"desiredClaudeHookGroups");function pI(e){let t=typeof e=="string"?{command:e}:e,n=s((r="")=>({hooks:[{type:"command",command:No(r,t.command),...t.commandWindows===void 0?{}:{commandWindows:No(r,t.commandWindows)},statusMessage:uu}]}),"commandHook");return{SessionStart:[n("SessionStart")],UserPromptSubmit:[n()],PreToolUse:[n()],PostToolUse:[n()],Stop:[n()],SubagentStart:[n()],SubagentStop:[n()]}}s(pI,"desiredCodexHookGroups");var mI=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","postToolUseFailure","beforeShellExecution","beforeReadFile","beforeMCPExecution","subagentStart","subagentStop","stop"],gI=["afterShellExecution","afterFileEdit"];function _I(e,t=gI){let n={...e};for(let r of t){if(!(r in n))continue;let o=Aa(n[r]);o.length===0?delete n[r]:n[r]=o}return n}s(_I,"stripRetiredCursorEvAiEvents");function hI(e,t,n={}){let r=J(e,".claude/settings.json"),o=Ca(t,"claude"),i=ut(r)??{};if(cI(e)&&!n.force){if(i.hooks&&typeof i.hooks=="object"){let l={...i.hooks};for(let p of Object.keys(l))l[p]=Lo(l[p]),Om(l[p]).length===0&&delete l[p];Object.keys(l).length===0?delete i.hooks:i.hooks=l,Pt(r,i)}return!1}let c=i.hooks&&typeof i.hooks=="object"?i.hooks:{},u=dI(o),f={...c};for(let[l,p]of Object.entries(u))f[l]=xm(c[l],p);return i.hooks=f,Pt(r,i),!0}s(hI,"updateClaudeSettings");function SI(e,t){let n=J(e,".cursor/hooks.json"),r=Ca(t,"cursor"),o=ut(n)??{},i=o.hooks&&typeof o.hooks=="object"?o.hooks:{},a=_I({...i});for(let c of mI)a[c]=lI(a[c],No(c,r));Pt(n,{...o,version:typeof o.version=="number"?o.version:1,hooks:a})}s(SI,"updateCursorHooks");function yI(e,t){let n=J(e,".codex/hooks.json"),r=Ca(t,"codex"),o=ut(n)??{},i=o.hooks&&typeof o.hooks=="object"?o.hooks:{},a=pI(r),c={...i};for(let[u,f]of Object.entries(a))c[u]=xm(i[u],f);Pt(n,{...o,hooks:c})}s(yI,"updateCodexHooks");function EI(e){let t=J(e,".claude/settings.json"),n=ut(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1;for(let i of Object.keys(r)){let a=r[i],c=Lo(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:r[i]=c}o&&(Object.keys(r).length===0?delete n.hooks:n.hooks=r,Pt(t,n),R(`Removed ev-ai hooks from ${t}`))}s(EI,"stripEvAiFromClaudeSettings");function RI(e){let t=J(e,".cursor/hooks.json"),n=ut(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,i=0;for(let a of Object.keys(r)){let c=r[a],u=Aa(c);JSON.stringify(c)!==JSON.stringify(u)&&(o=!0),u.length===0?delete r[a]:(r[a]=u,i+=u.length)}if(o){if(i===0&&Object.keys(r).length===0&&Object.keys(n).filter(c=>c!=="hooks"&&c!=="version").length===0){Mo(t,{force:!0}),R(`Removed ${t}`);return}Pt(t,{...n,hooks:r}),R(`Removed ev-ai hooks from ${t}`)}}s(RI,"stripEvAiFromCursorHooks");function CI(e){let t=J(e,".codex/hooks.json"),n=ut(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,i=0;for(let a of Object.keys(r)){let c=r[a],u=Lo(c);JSON.stringify(c)!==JSON.stringify(u)&&(o=!0),u.length===0?delete r[a]:(r[a]=u,i+=u.length)}if(o){if(i===0&&Object.keys(r).length===0&&Object.keys(n).filter(c=>c!=="hooks").length===0){Mo(t,{force:!0}),R(`Removed ${t}`);return}Pt(t,{...n,hooks:r}),R(`Removed ev-ai hooks from ${t}`)}}s(CI,"stripEvAiFromCodexHooks");function ba(e=process.platform,t=process.arch,n={}){if(e==="win32")throw new Error("Windows install is not supported yet. Use macOS/Linux, or wait for phase-2 native commands.");(n.requireBinaryArch??!0)&&lm(e,t)}s(ba,"assertInstallSupported");async function Im(e={}){let t=Vx(e);e.collectorUrl=t;let n=e.skipClaude===!0,r=e.skipCursor===!0,o=e.skipCodex===!0;if(n&&r&&o)throw new Error("at least one runner must be wired; refuse --no-claude --no-cursor --no-codex together");let i=e.delivery??Sm();ba(process.platform,process.arch,{requireBinaryArch:i==="binary"});let a=e.cwd??process.cwd(),c=await qe(a),{command:u,hookPath:f,strategy:l}=sI(c,ct(),i),{installationId:p,storePath:d}=await Po(c,{overrideId:e.installationId}),{manifestPath:m,wrote:g}=km(c,e),h=[];return n?R("Skipped Claude hook \u2014 --no-claude"):hI(c,u,{force:e.force})?(h.push("Claude"),e.force&&uI(c)&&R("Forced Claude hook despite project native OTEL \u2014 expect duplicate session/tool events")):R("Skipped Claude hook \u2014 native OTEL telemetry already enabled (avoids duplicate events); pass --force to wire anyway"),r?R("Skipped Cursor hook \u2014 --no-cursor"):(SI(c,u),h.push("Cursor")),o?R("Skipped Codex hook \u2014 --no-codex"):(yI(c,u),h.push("Codex")),R(`Installed hook (${l}) at ${f}`),R(`Installation identity ${p} at ${d}`),g&&m?R(`Shared manifest written to ${m}`):R("Using package default collector config (no shared manifest file needed)"),R(h.length>0?`Wired ${h.join(", ")} hooks in ${c} (commands include --runner)`:`No runner hooks wired in ${c} (Claude skipped by OTEL; Cursor/Codex excluded via flags)`),l==="npx"?R("Hook commands use npx and may be committed; teammates need Node on PATH only (no install step, no env vars when collector_url is in the shared manifest)."):l==="project_binary"?R("Hook commands are git-root-relative and may be committed; each collaborator runs install once to populate .ev-ai/agent-hook/ (gitignored)."):l==="dev_mjs"&&R("Hook commands use node + monorepo packages/agent-hook/dist/hook.mjs (local delivery; rebuild with yarn workspace @ev-ai/agent-hook build)."),g&&m&&e.collectorUrl&&R("Shared manifest includes collector_url \u2014 commit it with hook configs so teammates post without env vars."),{gitRoot:c,hookPath:f,manifestPath:m,installationStorePath:d,strategy:l}}s(Im,"installAgentHook");async function Tm(e=process.cwd()){ba(process.platform,process.arch,{requireBinaryArch:!0});let t=await qe(e),{projectPath:n,globalPath:r}=tI(t);R(`Refreshed ${r}`),R(`Refreshed ${n}`),R("Hook configs and shared manifest left unchanged")}s(Tm,"updateAgentHook");async function wm(e={}){let t=Gx(e);e.collectorUrl=t,ba(process.platform,process.arch,{requireBinaryArch:!1});let n=e.cwd??process.cwd(),r=await qe(n),{manifestPath:o,wrote:i}=km(r,e);if(t!==void 0&&(!o||!i))throw new Error("configure failed to write shared collector manifest");return i&&o?R(`Wrote ${o}`):t===void 0&&R("No --url given and no shared manifest yet \u2014 pass --url <\u2026/{orgToken}/hook> to write collector destination."),R("Manifest only \u2014 enable ev-ai marketplace plugins. Do not also run file-wiring install for the same events."),{gitRoot:r,manifestPath:o}}s(wm,"configureAgentHook");function Pm(e){for(let t of[()=>EI(e),()=>RI(e),()=>CI(e)])try{t()}catch(n){let r=n instanceof Error?n.message:String(n);R(`WARN: strip skipped a hook file: ${r}`)}}s(Pm,"stripFileWiredEvAiHooks");async function Nm(e=process.cwd()){let t=await qe(e);return Pm(t),R("Stripped ev-ai file-wired hooks; shared collector manifest left in place."),R("Next: enable ev-ai marketplace plugins, then restart runners."),{gitRoot:t}}s(Nm,"migrateToPlugin");async function Mm(e=process.cwd()){let t=await qe(e);Pm(t);for(let n of wr){let r=J(t,n);if(wt(r))try{Mo(r,{force:!0}),R(`Removed ${r}`)}catch(o){let i=o instanceof Error?o.message:String(o);R(`WARN: uninstall could not remove ${r}: ${i}`)}}}s(Mm,"uninstallAgentHook");import{existsSync as RT,mkdirSync as CT,readdirSync as AT,readFileSync as bT,unlinkSync as ig,writeFileSync as kT}from"node:fs";import{homedir as ag}from"node:os";import{join as Ma}from"node:path";import{existsSync as OI}from"node:fs";import{existsSync as AI}from"node:fs";import{resolve as ka}from"node:path";function Ne(e){return ka(e).replaceAll("\\","/").replace(/\/$/,"")}s(Ne,"posixAbs");function Wt(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(Wt,"uniqueOrderedRoots");function Uo(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(Uo,"preferMarkerDirRoots");var bI=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function ir(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!bI.test(t)?null:t}s(ir,"sanitizeComponentRelativePath");function Rn(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let i=Ne(o);n.has(i)||(n.add(i),r.push(i))}return r}s(Rn,"projectAnchors");function kI(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}s(kI,"isInside");function lt(e,t,n,r=AI){for(let o of e)for(let i of t){let a=Ne(ka(o,i)),c=ka(o,i,n).replaceAll("\\","/");if(kI(a,c)&&r(c))return c}return null}s(lt,"firstExistingUnderRoots");var Lm=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/|\.github\/|\.copilot\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Um=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,xI=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,vm=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"]),II=/^[a-z][a-z0-9-]{1,63}$/,TI=[".cursor/skills",".claude/skills",".agents/skills"],wI=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],PI=Wt(TI,bt(Object.values(At)).skills),NI=Wt(wI,bt(Object.values(un)).skills),MI=new Set(["read","read_file","view"]),vI=new Set(["bash","shell","zsh"]);function Oa(e){let t=e.replace(/\\/g,"/");return Lm.exec(t)?.[1]??null}s(Oa,"skillIdFromSkillMdPath");function LI(e){let t=e.replace(/\\/g,"/"),r=Um.exec(t)?.[1];return r?r.toLowerCase():null}s(LI,"skillIdFromCodexCommandPath");function UI(e){return Oa(e)??LI(e)}s(UI,"skillIdFromReferencedPath");function HI(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(HI,"pathFromToolInputRecord");function Ho(e){return typeof e=="string"?Ho(xe(e,null)):!e||typeof e!="object"?null:HI(e)}s(Ho,"pathFromToolInput");function Hm(e){if(typeof e=="string")return Hm(xe(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}s(Hm,"commandFromToolInput");function xa(e){let t=Hm(e.tool_input);if(t)return t;let n=Mt(e.command);return n.length>0?n:null}s(xa,"commandFromHookInput");function DI(e){let t=e.replace(/\\/g,"/"),n=Lm.exec(t);if(n?.[1])return n[1];let o=Um.exec(t)?.[1];return o?o.toLowerCase():null}s(DI,"skillIdFromShellCommand");function FI(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}s(FI,"toolNameFromHookInput");function Ia(e){let t=Ho(e.tool_input)??Mt(e.file_path);return t.length>0?t:null}s(Ia,"filePathFromHookInput");function ar(e,t,n){let r=FI(e).toLowerCase();if(MI.has(r)){let o=Ia(e);return o?t(o):null}if(vI.has(r)){let o=xa(e);return o?n(o):null}return null}s(ar,"nameFromReadOrShellHookInput");function Dm(e){return ar(e,UI,DI)}s(Dm,"skillNameFromReadHookInput");function $I(e){let t=new Set,n=[];for(let r of e.matchAll(xI)){let o=r[1]?.toLowerCase();!o||t.has(o)||jI(o)||(t.add(o),n.push(o))}return n}s($I,"extractSlashSkillNames");function jI(e){let t=e.split("/")[0];return vm.has(e)||t!==void 0&&vm.has(t)}s(jI,"isDeniedSlashId");function Fm(e){let t=e.skillId.toLowerCase();if(!II.test(t))return null;let n=e.exists??OI,r=`${t}/SKILL.md`,o=lt(Rn(e.launchCwd,e.gitRoot),PI,r,n);return o!==null?o:e.home?lt([Ne(e.home)],NI,r,n):null}s(Fm,"resolveSkillMdPath");function BI(e){return Mt(e.prompt)}s(BI,"promptFromHookInput");function $m(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=BI(e);return n?$I(n):[]}s($m,"skillNamesFromHookInput");var Ta=$e(Ge(),1);import{existsSync as GI}from"node:fs";var Jt={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode",copilot:".github"};function cr(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}s(cr,"normalizePathSlug");function KI(e){if(!e)return"";let t=Mn(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return cr(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return cr(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?cr(o[1]):cr(t)}s(KI,"normalizeGitRemoteToSlug");async function Do(e=process.cwd()){let t=await Me("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([Me("git",["remote","get-url","origin"],2e3,{cwd:e}),Me("git",["branch","--show-current"],2e3,{cwd:e}),Me("git",["rev-parse","HEAD"],2e3,{cwd:e}),Me("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?Mn(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:i.ok?i.stdout.length>0:null}}s(Do,"gitSnapshot");async function jm(e,t,n,r=process.cwd(),o,i,a){if(t)return t;let c=Jt[n];if(!c)return"";let u=Kp(n,e.scope_path,a);if(i){let g=Zp(i,u);if(g)return g}let f=o??await Do(r),l=f?.remote?KI(f.remote):"";if(l||(l=cr(process.env.GITHUB_REPOSITORY??"")),!l)return"";let p=e.scope_path??"",d=p?`${p}/`:"",m=`${l}:${d}${c}`;return i&&Qp(i,u,m),m}s(jm,"derivePlatformAgentId");var VI=[".cursor/rules",".claude/rules",".codex/rules"],zI=bt(Object.values(At)).rules;function WI(e){return Wt(Uo(e?Jt[e]:void 0,VI),zI)}s(WI,"ruleRootsForRunner");var JI=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules)|\.github\/instructions\/[^'"\s]+?\.instructions\.md)\b/i;function Bm(e){let t=ir(e.relativePath);if(!t)return null;let n=e.exists??GI,r=Rn(e.launchCwd,e.gitRoot),o=WI(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([Ne(e.home)],o,t,n):null}s(Bm,"resolveRuleMdPath");function YI(e){let t=e.replace(/\\/g,"/"),r=JI.exec(t)?.[1];return r?(0,Ta.nativeKeyForRulePath)(r):null}s(YI,"ruleNameFromShellCommand");function Km(e){return ar(e,Ta.nativeKeyForRulePath,YI)}s(Km,"ruleNameFromReadHookInput");function Gm(e){return e.replace(/\.(mdc|md|rules)$/i,"")}s(Gm,"stripRuleExtension");function Vm(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=ir(a);!c||n.has(c)||(n.add(c),r.push(c))}return r}s(Vm,"ruleAttachmentPathsFromHookInput");var wa=$e(Ge(),1);import{existsSync as XI}from"node:fs";var qI=[".cursor/commands",".claude/commands",".codex/prompts"],ZI=bt(Object.values(At)).commands;function QI(e){return Wt(Uo(e?Jt[e]:void 0,qI),ZI)}s(QI,"commandRootsForRunner");var eT=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc)|\.github\/prompts\/[^'"\s]+?\.prompt\.md)\b/i,tT=".github/prompts";function nT(e,t){return e===tT?`${t}.prompt.md`:`${t}.md`}s(nT,"commandFileName");function zm(e){let t=ir(e.commandId);if(!t)return null;let n=e.exists??XI,r=QI(e.runnerPlatform),o=s(a=>{for(let c of a)for(let u of r){let f=lt([c],[u],nT(u,t),n);if(f!==null)return f}return null},"probe"),i=o(Rn(e.launchCwd,e.gitRoot));return i!==null||!e.home?i:o([Ne(e.home)])}s(zm,"resolveCommandMdPath");function rT(e){let t=e.replace(/\\/g,"/"),r=eT.exec(t)?.[1];return r?(0,wa.nativeKeyForCommandPath)(r):null}s(rT,"commandNameFromShellCommand");function Wm(e){return ar(e,wa.nativeKeyForCommandPath,rT)}s(Wm,"commandNameFromReadHookInput");var Fo=$e(Ge(),1);function Jm(e,t){if($(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}s(Jm,"cursorShapedPayload");function oT(){return!!(F("CURSOR_VERSION")??F("CURSOR_PROJECT_DIR"))}s(oT,"isCursorHostEnv");function Ym(e,t,n){return e!=="claude"&&e!=="codex"?!1:Jm(t,n)?!0:oT()}s(Ym,"shouldSuppressForeignRunnerOnCursorHost");var sT=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function Cn(e,t,n,r){return r==="copilot"?"copilot":Jm(e,t)?"cursor":Pr(r)?r:Pr(n)?n:$(e,"turn_id")?"codex":$(e,"session_id")||sT.has(t.toLowerCase())?"claude":"unknown"}s(Cn,"detectRunnerPlatform");function $o(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}s($o,"isInProcessEvent");function iT(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(iT,"mapRunnerEventToInternal");function Xm(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="userpromptsubmitted"||t==="beforesubmitprompt"}s(Xm,"isPromptSubmitRunnerEvent");function qm(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}s(qm,"suppressesSlashIds");function Zm(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}s(Zm,"toolSuccessFromRunnerEvent");function An(e){return $(e,"session_id")||$(e,"conversation_id")}s(An,"sessionIdFromHookInput");function Pa(e){return $(e,"prompt.id")||$(e,"prompt_id")||$(e,"generation_id")||$(e,"turn_id")}s(Pa,"turnIdFromHookInput");function Na(e){return $(e,"hook_event_name")||$(e,"event")}s(Na,"runnerEventFromHookInput");function Qm(e,t,n){let r=An(e),o=Pa(e),i=Na(e),a=$(e,"source"),c=Cn(e,i,t,n);return{sessionId:r,turnId:o,runnerEvent:i,hookSource:a,runnerPlatform:c}}s(Qm,"normalizeHookFields");var aT=["session_start","session_end","tool_invoked","skill_invoked"];function cT(e){return aT.includes(e)}s(cT,"isKnownInternalEvent");function jo(e,t){return e&&cT(e)?e:iT(t.toLowerCase())}s(jo,"resolveInternalEvent");var uT={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function Bo(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}s(Bo,"isMcpShapedToolName");function eg(e,t=""){let n=$(e,"tool_name")||$(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!Bo(n)&&(n=`MCP:${n}`):n=uT[r]??null;let o=e.tool_input,a=(o&&typeof o=="object"?Mt(o.skill)||Mt(o.skill_name):"")||$(e,"skill_name")||null,c=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;a??=Dm(c);let u=Km(c),f=Wm(c);return{toolName:n,skillName:a,ruleName:u,commandName:f}}s(eg,"extractToolNames");var lT=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function tg(e){for(let t of["subagent_type","agent_type"]){let n=$(e,t);if(n&&lT.test(n))return n}return null}s(tg,"extractSubagentType");function ng(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(ng,"extractDurationMs");var fT="error",dT="interrupted",pT="permission_denied",mT=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function ur(e){return mT.test(e)?e:null}s(ur,"categoricalValue");function gT(e){for(let t of["failure_type","error_type"]){let n=ur($(e,t));if(n)return n}return null}s(gT,"structuredFailureClass");function rg(e,t){return Ze(e,"is_interrupt")===!0?dT:t.toLowerCase()==="permissiondenied"?pT:gT(e)??fT}s(rg,"extractFailureClass");function og(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}s(og,"longestDeclaredServer");function _T(e,t){return og(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}s(_T,"matchDeclaredMcpServer");function hT(e,t){return og(t,n=>(0,Fo.mcpServerNameMatchesToolSegment)(n,e))}s(hT,"matchDeclaredMcpServerSegment");function ST(e,t){let n=null,r=0;for(let i of t)if(i)for(let a of(0,Fo.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:hT(o[1],t)??o[1],mcpTool:o[2]}}s(ST,"parseClaudeMcpNames");function yT(e,t){if(/^mcp__/i.test(e))return ST(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:_T(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}s(yT,"parseMcpNamesFromToolName");function ET(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}s(ET,"stripEncodedMcpServerPrefix");function sg(e,t=[],n=""){let r=e?yT(e,t):{mcpServer:null,mcpTool:null},o=ur(n.trim());if(!o)return r;let i=r.mcpTool;return!i&&e&&!Bo(e)&&(i=e),i&&(i=ET(i,o)),{mcpServer:o,mcpTool:i}}s(sg,"extractMcpNames");var cg=3e4,OT="claims",xT=!0,IT=100,TT=new Set(["sessionstart","sessionend","stopfailure"]),wT=["tool_name","tool","command","file_path","url"];function PT(e=ag()){return Ma(Ae(e),OT)}s(PT,"eventClaimDir");function ug(e,t){try{let n=bT(e,"utf8").split(`
|
|
47
|
-
`,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}s(
|
|
48
|
-
`,{encoding:"utf8",flag:"wx"})}catch(o){if(
|
|
49
|
-
`)}catch(n){let r=n instanceof Error?n.message:String(n);
|
|
50
|
-
`)}catch(n){let r=n instanceof Error?n.message:String(n);
|
|
45
|
+
npx ${Gr} install`)}s(yx,"resolveHookCommand");function ng(e){return typeof e!="string"?!1:e.includes("@ev-ai/agent-hook")||e.includes("agent-hook/dist/hook")||e.includes(".ev-ai/agent-hook")||e.includes(Ne)||/(?:^|[\s/"'])ev-ai-agent-hook(?:$|[\s"'])/.test(e)}s(ng,"isEvAiHookCommand");function ja(e,t){return`${e.replace(/\s+--runner(?:=|\s+)\S+/g,"").trimEnd()} --runner ${t}`}s(ja,"withRunnerFlag");function $t(e,t){Fa($a(e),{recursive:!0}),ex(e,`${JSON.stringify(t,null,2)}
|
|
46
|
+
`,"utf8")}s($t,"writeJson");function gt(e){if(Ft(e))try{return JSON.parse(ZT(e,"utf8"))}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON in ${e} \u2014 fix or remove the file`,{cause:t}):t}}s(gt,"readJson");function Rx(e,t){let n=jm(t.collectorUrl),r={...e,schema_version:e?.schema_version??n.schema_version};return t.collectorUrl!==void 0?r.collector_url=t.collectorUrl:r.collector_url=e?.collector_url??n.collector_url,delete r.repo_ingest_token,delete r.installation_id,r.mcp_servers??=n.mcp_servers,r}s(Rx,"mergeManifestForInstall");function Cx(e){return(e.schema_version??Ct)===Ct&&e.collector_url===void 0&&(e.mcp_servers?.length??0)===0&&e.platform_agent_id===void 0&&e.capture_hook_input===void 0&&e.debug===void 0&&e.repo_ingest_token===void 0}s(Cx,"isDefaultSharedManifest");function rg(e,t){let n=Z(e,Dr),r=gt(n),o=Rx(r,t);return t.collectorUrl!==void 0||Ft(n)||!Cx(o)?($t(n,o),{manifestPath:n,wrote:!0}):{manifestPath:void 0,wrote:!1}}s(rg,"upsertSharedManifest");function Da(e){if(e===null||typeof e!="object")return!1;let t=e,n=String(t.CLAUDE_CODE_ENABLE_TELEMETRY??"").toLowerCase();return n==="1"||n==="true"?!0:Object.keys(t).some(r=>r.startsWith("OTEL_"))}s(Da,"envHasOtel");function Ax(e){if(Da(process.env))return!0;let t=mt();return[...Ms(),Z(t,".claude","settings.json"),Z(t,".claude","remote-settings.json"),Z(e,".claude","settings.json"),Z(e,".claude","settings.local.json")].some(r=>{try{let o=gt(r);return o?Da(o.env):!1}catch{return!1}})}s(Ax,"claudeOtelEnabled");function bx(e){try{let t=gt(Z(e,".claude","settings.json"));return t?Da(t.env):!1}catch{return!1}}s(bx,"projectClaudeOtelEnabled");function og(e){return Array.isArray(e)?e:[]}s(og,"asMatcherGroups");function Jo(e){let t=[],n=s(r=>!!r&&typeof r=="object"&&ng(r.command),"isOwnedHook");for(let r of og(e)){if(!r||typeof r!="object"){t.push(r);continue}let o=Array.isArray(r.hooks)?r.hooks:[],i=o.filter(a=>!n(a));if(!(i.length===0&&o.some(n))){if(i.length!==o.length){t.push({...r,hooks:i});continue}t.push(r)}}return t}s(Jo,"stripEvAiMatcherGroups");function sg(e,t){return[...Jo(e),...t]}s(sg,"mergeMatcherHookEvents");function Ba(e){return Array.isArray(e)?e.filter(t=>!t||typeof t!="object"?!0:!ng(t.command)):[]}s(Ba,"stripEvAiCursorHooks");function Ox(e,t){return[...Ba(e),{command:t}]}s(Ox,"mergeCursorEventHooks");function kx(e){return typeof e=="string"?[e]:e}s(kx,"toCommandList");function Ix(e){let t=s((n="")=>({hooks:kx(e).map(r=>({type:"command",command:Vo(n,r)}))}),"commandHook");return{SessionStart:[t("SessionStart")],UserPromptExpansion:[t()],UserPromptSubmit:[t()],PreToolUse:[t()],PostToolUse:[t()],PostToolUseFailure:[t()],PermissionDenied:[t()],Stop:[t()],StopFailure:[t()],SessionEnd:[t()],SubagentStart:[t()],SubagentStop:[t()]}}s(Ix,"desiredClaudeHookGroups");function Tx(e){let t=typeof e=="string"?{command:e}:e,n=s((r="")=>({hooks:[{type:"command",command:Vo(r,t.command),...t.commandWindows===void 0?{}:{commandWindows:Vo(r,t.commandWindows)},statusMessage:xu}]}),"commandHook");return{SessionStart:[n("SessionStart")],UserPromptSubmit:[n()],PreToolUse:[n()],PostToolUse:[n()],Stop:[n()],SubagentStart:[n()],SubagentStop:[n()]}}s(Tx,"desiredCodexHookGroups");var xx=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","postToolUseFailure","beforeShellExecution","beforeReadFile","beforeMCPExecution","subagentStart","subagentStop","stop"],Px=["afterShellExecution","afterFileEdit"];function wx(e,t=Px){let n={...e};for(let r of t){if(!(r in n))continue;let o=Ba(n[r]);o.length===0?delete n[r]:n[r]=o}return n}s(wx,"stripRetiredCursorEvAiEvents");function Nx(e,t,n={}){let r=Z(e,".claude/settings.json"),o=ja(t,"claude"),i=gt(r)??{};if(Ax(e)&&!n.force){if(i.hooks&&typeof i.hooks=="object"){let l={...i.hooks};for(let p of Object.keys(l))l[p]=Jo(l[p]),og(l[p]).length===0&&delete l[p];Object.keys(l).length===0?delete i.hooks:i.hooks=l,$t(r,i)}return!1}let c=i.hooks&&typeof i.hooks=="object"?i.hooks:{},u=Ix(o),f={...c};for(let[l,p]of Object.entries(u))f[l]=sg(c[l],p);return i.hooks=f,$t(r,i),!0}s(Nx,"updateClaudeSettings");function vx(e,t){let n=Z(e,".cursor/hooks.json"),r=ja(t,"cursor"),o=gt(n)??{},i=o.hooks&&typeof o.hooks=="object"?o.hooks:{},a=wx({...i});for(let c of xx)a[c]=Ox(a[c],Vo(c,r));$t(n,{...o,version:typeof o.version=="number"?o.version:1,hooks:a})}s(vx,"updateCursorHooks");function Lx(e,t){let n=Z(e,".codex/hooks.json"),r=ja(t,"codex"),o=gt(n)??{},i=o.hooks&&typeof o.hooks=="object"?o.hooks:{},a=Tx(r),c={...i};for(let[u,f]of Object.entries(a))c[u]=sg(i[u],f);$t(n,{...o,hooks:c})}s(Lx,"updateCodexHooks");function Mx(e){let t=Z(e,".claude/settings.json"),n=gt(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1;for(let i of Object.keys(r)){let a=r[i],c=Jo(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:r[i]=c}o&&(Object.keys(r).length===0?delete n.hooks:n.hooks=r,$t(t,n),C(`Removed ev-ai hooks from ${t}`))}s(Mx,"stripEvAiFromClaudeSettings");function Ux(e){let t=Z(e,".cursor/hooks.json"),n=gt(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,i=0;for(let a of Object.keys(r)){let c=r[a],u=Ba(c);JSON.stringify(c)!==JSON.stringify(u)&&(o=!0),u.length===0?delete r[a]:(r[a]=u,i+=u.length)}if(o){if(i===0&&Object.keys(r).length===0&&Object.keys(n).filter(c=>c!=="hooks"&&c!=="version").length===0){zo(t,{force:!0}),C(`Removed ${t}`);return}$t(t,{...n,hooks:r}),C(`Removed ev-ai hooks from ${t}`)}}s(Ux,"stripEvAiFromCursorHooks");function Hx(e){let t=Z(e,".codex/hooks.json"),n=gt(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,i=0;for(let a of Object.keys(r)){let c=r[a],u=Jo(c);JSON.stringify(c)!==JSON.stringify(u)&&(o=!0),u.length===0?delete r[a]:(r[a]=u,i+=u.length)}if(o){if(i===0&&Object.keys(r).length===0&&Object.keys(n).filter(c=>c!=="hooks").length===0){zo(t,{force:!0}),C(`Removed ${t}`);return}$t(t,{...n,hooks:r}),C(`Removed ev-ai hooks from ${t}`)}}s(Hx,"stripEvAiFromCodexHooks");function Ka(e=process.platform,t=process.arch,n={}){if(e==="win32")throw new Error("Windows install is not supported yet. Use macOS/Linux, or wait for phase-2 native commands.");(n.requireBinaryArch??!0)&&Bm(e,t)}s(Ka,"assertInstallSupported");async function ig(e={}){let t=ix(e);e.collectorUrl=t;let n=e.skipClaude===!0,r=e.skipCursor===!0,o=e.skipCodex===!0;if(n&&r&&o)throw new Error("at least one runner must be wired; refuse --no-claude --no-cursor --no-codex together");let i=e.delivery??Xm();Ka(process.platform,process.arch,{requireBinaryArch:i==="binary"});let a=e.cwd??process.cwd(),c=await tt(a),{command:u,hookPath:f,strategy:l}=yx(c,mt(),i),{installationId:p,storePath:d}=await Go(c,{overrideId:e.installationId}),{manifestPath:m,wrote:g}=rg(c,e),E=[];return n?C("Skipped Claude hook \u2014 --no-claude"):Nx(c,u,{force:e.force})?(E.push("Claude"),e.force&&bx(c)&&C("Forced Claude hook despite project native OTEL \u2014 expect duplicate session/tool events")):C("Skipped Claude hook \u2014 native OTEL telemetry already enabled (avoids duplicate events); pass --force to wire anyway"),r?C("Skipped Cursor hook \u2014 --no-cursor"):(vx(c,u),E.push("Cursor")),o?C("Skipped Codex hook \u2014 --no-codex"):(Lx(c,u),E.push("Codex")),C(`Installed hook (${l}) at ${f}`),C(`Installation identity ${p} at ${d}`),g&&m?C(`Shared manifest written to ${m}`):C("Using package default collector config (no shared manifest file needed)"),C(E.length>0?`Wired ${E.join(", ")} hooks in ${c} (commands include --runner)`:`No runner hooks wired in ${c} (Claude skipped by OTEL; Cursor/Codex excluded via flags)`),l==="npx"?C("Hook commands use npx and may be committed; teammates need Node on PATH only (no install step, no env vars when collector_url is in the shared manifest)."):l==="project_binary"?C("Hook commands are git-root-relative and may be committed; each collaborator runs install once to populate .ev-ai/agent-hook/ (gitignored)."):l==="dev_mjs"&&C("Hook commands use node + monorepo packages/agent-hook/dist/hook.mjs (local delivery; rebuild with yarn workspace @ev-ai/agent-hook build)."),g&&m&&e.collectorUrl&&C("Shared manifest includes collector_url \u2014 commit it with hook configs so teammates post without env vars."),{gitRoot:c,hookPath:f,manifestPath:m,installationStorePath:d,strategy:l}}s(ig,"installAgentHook");async function ag(e=process.cwd()){Ka(process.platform,process.arch,{requireBinaryArch:!0});let t=await tt(e),{projectPath:n,globalPath:r}=_x(t);C(`Refreshed ${r}`),C(`Refreshed ${n}`),C("Hook configs and shared manifest left unchanged")}s(ag,"updateAgentHook");async function cg(e={}){let t=sx(e);e.collectorUrl=t,Ka(process.platform,process.arch,{requireBinaryArch:!1});let n=e.cwd??process.cwd(),r=await tt(n),{manifestPath:o,wrote:i}=rg(r,e);if(t!==void 0&&(!o||!i))throw new Error("configure failed to write shared collector manifest");return i&&o?C(`Wrote ${o}`):t===void 0&&C("No --url given and no shared manifest yet \u2014 pass --url <\u2026/{orgToken}/hook> to write collector destination."),C("Manifest only \u2014 enable ev-ai marketplace plugins. Do not also run file-wiring install for the same events."),{gitRoot:r,manifestPath:o}}s(cg,"configureAgentHook");function ug(e){for(let t of[()=>Mx(e),()=>Ux(e),()=>Hx(e)])try{t()}catch(n){let r=n instanceof Error?n.message:String(n);C(`WARN: strip skipped a hook file: ${r}`)}}s(ug,"stripFileWiredEvAiHooks");async function lg(e=process.cwd()){let t=await tt(e);return ug(t),C("Stripped ev-ai file-wired hooks; shared collector manifest left in place."),C("Next: enable ev-ai marketplace plugins, then restart runners."),{gitRoot:t}}s(lg,"migrateToPlugin");async function fg(e=process.cwd()){let t=await tt(e);ug(t);for(let n of Fr){let r=Z(t,n);if(Ft(r))try{zo(r,{force:!0}),C(`Removed ${r}`)}catch(o){let i=o instanceof Error?o.message:String(o);C(`WARN: uninstall could not remove ${r}: ${i}`)}}}s(fg,"uninstallAgentHook");var dg='{"continue":true}',Dx='{"decision":"allow"}',Fx="{}",$x=new Set(["pretooluse","stop"]);function Yo(e){let t;try{t=cn([...e])}catch{return dg}return t.runner!=="antigravity"?dg:$x.has((t.event??"").toLowerCase())?Dx:Fx}s(Yo,"runnerAck");var Ga="antigravity";function ge(e,t){let n=e[t];return typeof n=="string"&&n!==""?n:void 0}s(ge,"stringField");function pg(e,t){let n=e[t];return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0}s(pg,"recordField");function jx(e){let t=e.workspacePaths;if(Array.isArray(t))return t.find(n=>typeof n=="string"&&n!=="")}s(jx,"firstWorkspacePath");function Bx(e,t){let n=ge(e,"hookEventName")??t??"",r=n.toLowerCase();return r==="posttooluse"&&ge(e,"error")!==void 0?"PostToolUseFailure":r==="preinvocation"&&e.invocationNum===0?"UserPromptSubmit":n}s(Bx,"antigravityEventName");var Kx=new Set(["preinvocation","postinvocation"]);function Va(e){return Kx.has(e.toLowerCase())}s(Va,"isAntigravityAckOnlyEvent");function Gx(e){if(!e)return;let t={...e},n=ge(e,"AbsolutePath")??ge(e,"TargetFile")??ge(e,"Path");n!==void 0&&t.file_path===void 0&&(t.file_path=n);let r=ge(e,"CommandLine");return r!==void 0&&t.command===void 0&&(t.command=r),t}s(Gx,"normalizedToolArgs");var Vx=new Set(["call_mcp_tool","list_mcp_resources","read_mcp_resource"]),zx=/^mcp_(?!_)(.+)$/i;function Wx(e,t){if(e===void 0)return{toolName:e};if(Vx.has(e)){let r=t?ge(t,"ServerName"):void 0;if(r===void 0)return{toolName:e};let o=e==="call_mcp_tool"&&t?ge(t,"ToolName")??e:e;return{toolName:`mcp__${r}__${o}`,mcpServerName:r}}let n=zx.exec(e);return n?.[1]?{toolName:`MCP:${n[1]}`}:{toolName:e}}s(Wx,"mcpToolShape");function Jx(e,t){let n={},r=s((a,c)=>{c!==void 0&&(n[a]=c)},"set"),o=Bx(e,t);r("hook_event_name",o===""?void 0:o),r("session_id",ge(e,"conversationId")),r("cwd",ge(e,"cwd")??jx(e)),r("transcript_path",ge(e,"transcriptPath")),r("model",ge(e,"modelName"));let i=pg(e,"toolCall");if(i){let a=pg(i,"args"),c=Wx(ge(i,"name"),a);r("tool_name",c.toolName),r("mcp_server_name",c.mcpServerName),r("tool_input",Gx(a)),r("tool_use_id",ge(i,"id"))}return r("error",ge(e,"error")),r("stop_reason",ge(e,"terminationReason")),o==="UserPromptSubmit"&&r("prompt",ge(e,"lastUserInput")),n}s(Jx,"adaptAntigravityHookInput");function mg(e,t,n){return t===Ga?Jx(e,n):e}s(mg,"adaptRunnerHookInput");import{existsSync as JP,mkdirSync as YP,readdirSync as XP,readFileSync as qP,unlinkSync as Gg,writeFileSync as ZP}from"node:fs";import{homedir as Vg}from"node:os";import{join as Qa}from"node:path";import{existsSync as Zx}from"node:fs";import{existsSync as Yx}from"node:fs";import{resolve as za}from"node:path";function He(e){return za(e).replaceAll("\\","/").replace(/\/$/,"")}s(He,"posixAbs");function Qt(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(Qt,"uniqueOrderedRoots");function Xo(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(Xo,"preferMarkerDirRoots");var Xx=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function mr(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!Xx.test(t)?null:t}s(mr,"sanitizeComponentRelativePath");function Tn(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let i=He(o);n.has(i)||(n.add(i),r.push(i))}return r}s(Tn,"projectAnchors");function qx(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}s(qx,"isInside");function _t(e,t,n,r=Yx){for(let o of e)for(let i of t){let a=He(za(o,i)),c=za(o,i,n).replaceAll("\\","/");if(qx(a,c)&&r(c))return c}return null}s(_t,"firstExistingUnderRoots");var hg=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/|\.github\/|\.copilot\/|\.gemini\/(?:config\/|antigravity(?:-cli)?\/)?)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Qx=/(?:^|\/|[\s"'=(])(?:\.gemini\/config|\.agents)\/plugins\/[^/\s"']+\/(?:[^\s"']*\/)?([^/\s"']+)\/SKILL\.md/i,Eg=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,eP=/(?:^|\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,gg=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"]),tP=/^[a-z][a-z0-9-]{1,63}$/,Sg=/^([a-z][a-z0-9-]{1,63}):([a-z][a-z0-9-]{1,63})$/;function yg(e){return Sg.exec(e.toLowerCase())?.[2]??e.toLowerCase()}s(yg,"skillIdOfSlashName");var nP=[".cursor/skills",".claude/skills",".agents/skills"],rP=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],oP=Qt(nP,Pt(Object.values(xt)).skills),sP=Qt(rP,Pt(Object.values(gn)).skills),iP=new Set(["read","read_file","view","view_file"]),aP=new Set(["bash","shell","zsh","run_command"]);function Wa(e){let t=e.replace(/\\/g,"/");return(hg.exec(t)??Qx.exec(t))?.[1]??null}s(Wa,"skillIdFromSkillMdPath");function cP(e){let t=e.replace(/\\/g,"/"),r=Eg.exec(t)?.[1];return r?r.toLowerCase():null}s(cP,"skillIdFromCodexCommandPath");function uP(e){return Wa(e)??cP(e)}s(uP,"skillIdFromReferencedPath");function lP(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(lP,"pathFromToolInputRecord");function qo(e){return typeof e=="string"?qo(we(e,null)):!e||typeof e!="object"?null:lP(e)}s(qo,"pathFromToolInput");function Rg(e){if(typeof e=="string")return Rg(we(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}s(Rg,"commandFromToolInput");function Ja(e){let t=Rg(e.tool_input);if(t)return t;let n=Bt(e.command);return n.length>0?n:null}s(Ja,"commandFromHookInput");function fP(e){let t=e.replace(/\\/g,"/"),n=hg.exec(t);if(n?.[1])return n[1];let o=Eg.exec(t)?.[1];return o?o.toLowerCase():null}s(fP,"skillIdFromShellCommand");function dP(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}s(dP,"toolNameFromHookInput");function Ya(e){let t=qo(e.tool_input)??Bt(e.file_path);return t.length>0?t:null}s(Ya,"filePathFromHookInput");function gr(e,t,n){let r=dP(e).toLowerCase();if(iP.has(r)){let o=Ya(e);return o?t(o):null}if(aP.has(r)){let o=Ja(e);return o?n(o):null}return null}s(gr,"nameFromReadOrShellHookInput");function Cg(e){return gr(e,uP,fP)}s(Cg,"skillNameFromReadHookInput");function pP(e){let t=new Set,n=[];for(let r of e.matchAll(eP)){let o=r[1]?.toLowerCase();!o||t.has(o)||mP(o)||(t.add(o),n.push(o))}return n}s(pP,"extractSlashSkillNames");function mP(e){let t=e.split("/")[0];return gg.has(e)||t!==void 0&&gg.has(t)}s(mP,"isDeniedSlashId");function Ag(e){let t=e.exists??Zx,n=Sg.exec(e.skillId.toLowerCase());if(n?.[1]&&n[2])return e.home?_g(e.home,n[1],n[2],t):null;let r=e.skillId.toLowerCase();if(!tP.test(r))return null;let o=`${r}/SKILL.md`,i=_t(Tn(e.launchCwd,e.gitRoot),oP,o,t);return i!==null?i:e.home?_t([He(e.home)],sP,o,t)??_g(e.home,null,r,t):null}s(Ag,"resolveSkillMdPath");function _g(e,t,n,r){let o=Rn(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(_g,"antigravityPluginSkillMd");function gP(e){return Bt(e.prompt)}s(gP,"promptFromHookInput");function bg(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=gP(e);return n?pP(n):[]}s(bg,"skillNamesFromHookInput");var Xa=Te(Pe(),1);import{existsSync as hP}from"node:fs";var en={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode",copilot:".github"};function _r(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}s(_r,"normalizePathSlug");function _P(e){if(!e)return"";let t=jn(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return _r(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return _r(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?_r(o[1]):_r(t)}s(_P,"normalizeGitRemoteToSlug");async function Zo(e=process.cwd()){let t=await De("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([De("git",["remote","get-url","origin"],2e3,{cwd:e}),De("git",["branch","--show-current"],2e3,{cwd:e}),De("git",["rev-parse","HEAD"],2e3,{cwd:e}),De("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?jn(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:i.ok?i.stdout.length>0:null}}s(Zo,"gitSnapshot");async function Og(e,t,n,r=process.cwd(),o,i,a){if(t)return t;let c=en[n];if(!c)return"";let u=Rm(n,e.scope_path,a);if(i){let g=Pm(i,u);if(g)return g}let f=o??await Zo(r),l=f?.remote?_P(f.remote):"";if(l||(l=_r(process.env.GITHUB_REPOSITORY??"")),!l)return"";let p=e.scope_path??"",d=p?`${p}/`:"",m=`${l}:${d}${c}`;return i&&wm(i,u,m),m}s(Og,"derivePlatformAgentId");var EP=[".cursor/rules",".claude/rules",".codex/rules"],SP=Pt(Object.values(xt)).rules;function yP(e){return Qt(Xo(e?en[e]:void 0,EP),SP)}s(yP,"ruleRootsForRunner");var RP=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex|\.gemini\/config)\/rules\/[^'"\s]+?\.(?:mdc|md|rules)|\.github\/instructions\/[^'"\s]+?\.instructions\.md)\b/i;function kg(e){let t=mr(e.relativePath);if(!t)return null;let n=e.exists??hP,r=Tn(e.launchCwd,e.gitRoot),o=yP(e.runnerPlatform),i=_t(r,o,t,n);if(i!==null)return i;if(!t.includes("/")){let a=_t(r,["."],t,n);if(a!==null)return a}return e.home?_t([He(e.home)],o,t,n):null}s(kg,"resolveRuleMdPath");function CP(e){let t=e.replace(/\\/g,"/"),r=RP.exec(t)?.[1];return r?(0,Xa.nativeKeyForRulePath)(r):null}s(CP,"ruleNameFromShellCommand");function Ig(e){return gr(e,Xa.nativeKeyForRulePath,CP)}s(Ig,"ruleNameFromReadHookInput");function Tg(e){return e.replace(/\.(mdc|md|rules)$/i,"")}s(Tg,"stripRuleExtension");function xg(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=mr(a);!c||n.has(c)||(n.add(c),r.push(c))}return r}s(xg,"ruleAttachmentPathsFromHookInput");var qa=Te(Pe(),1);import{existsSync as AP}from"node:fs";var bP=[".cursor/commands",".claude/commands",".codex/prompts"],OP=Pt(Object.values(xt)).commands;function kP(e){return Qt(Xo(e?en[e]:void 0,bP),OP)}s(kP,"commandRootsForRunner");var IP=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc)|\.github\/prompts\/[^'"\s]+?\.prompt\.md)\b/i,TP=".github/prompts";function xP(e,t){return e===TP?`${t}.prompt.md`:`${t}.md`}s(xP,"commandFileName");function Pg(e){let t=mr(e.commandId);if(!t)return null;let n=e.exists??AP,r=kP(e.runnerPlatform),o=s(a=>{for(let c of a)for(let u of r){let f=_t([c],[u],xP(u,t),n);if(f!==null)return f}return null},"probe"),i=o(Tn(e.launchCwd,e.gitRoot));return i!==null||!e.home?i:o([He(e.home)])}s(Pg,"resolveCommandMdPath");function PP(e){let t=e.replace(/\\/g,"/"),r=IP.exec(t)?.[1];return r?(0,qa.nativeKeyForCommandPath)(r):null}s(PP,"commandNameFromShellCommand");function wg(e){return gr(e,qa.nativeKeyForCommandPath,PP)}s(wg,"commandNameFromReadHookInput");var Qo=Te(Pe(),1);function Ng(e,t){if(B(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}s(Ng,"cursorShapedPayload");function wP(){return!!(j("CURSOR_VERSION")??j("CURSOR_PROJECT_DIR"))}s(wP,"isCursorHostEnv");function vg(e,t,n){return e!=="claude"&&e!=="codex"?!1:Ng(t,n)?!0:wP()}s(vg,"shouldSuppressForeignRunnerOnCursorHost");var NP=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function xn(e,t,n,r){return r==="copilot"?"copilot":r==="antigravity"?"antigravity":Ng(e,t)?"cursor":$r(r)?r:$r(n)?n:B(e,"turn_id")?"codex":B(e,"session_id")||NP.has(t.toLowerCase())?"claude":"unknown"}s(xn,"detectRunnerPlatform");function es(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&(t==="codex"||t==="antigravity")}s(es,"isInProcessEvent");function vP(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(vP,"mapRunnerEventToInternal");function Lg(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="userpromptsubmitted"||t==="beforesubmitprompt"}s(Lg,"isPromptSubmitRunnerEvent");function Mg(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}s(Mg,"suppressesSlashIds");function Ug(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}s(Ug,"toolSuccessFromRunnerEvent");function Pn(e){return B(e,"session_id")||B(e,"conversation_id")}s(Pn,"sessionIdFromHookInput");function Za(e){return B(e,"prompt.id")||B(e,"prompt_id")||B(e,"generation_id")||B(e,"turn_id")}s(Za,"turnIdFromHookInput");function ts(e){return B(e,"hook_event_name")||B(e,"event")}s(ts,"runnerEventFromHookInput");function Hg(e,t,n){let r=Pn(e),o=Za(e),i=ts(e),a=B(e,"source"),c=xn(e,i,t,n);return{sessionId:r,turnId:o,runnerEvent:i,hookSource:a,runnerPlatform:c}}s(Hg,"normalizeHookFields");var LP=["session_start","session_end","tool_invoked","skill_invoked"];function MP(e){return LP.includes(e)}s(MP,"isKnownInternalEvent");function ns(e,t){return e&&MP(e)?e:vP(t.toLowerCase())}s(ns,"resolveInternalEvent");var UP={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function rs(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}s(rs,"isMcpShapedToolName");function Dg(e,t=""){let n=B(e,"tool_name")||B(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!rs(n)&&(n=`MCP:${n}`):n=UP[r]??null;let o=e.tool_input,a=(o&&typeof o=="object"?Bt(o.skill)||Bt(o.skill_name):"")||B(e,"skill_name")||null,c=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;a??=Cg(c);let u=Ig(c),f=wg(c);return{toolName:n,skillName:a,ruleName:u,commandName:f}}s(Dg,"extractToolNames");var HP=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function Fg(e){for(let t of["subagent_type","agent_type"]){let n=B(e,t);if(n&&HP.test(n))return n}return null}s(Fg,"extractSubagentType");function $g(e){let t=nt(e,"duration_ms");if(typeof t=="number")return t;let n=nt(e,"duration");return typeof n=="number"?n:null}s($g,"extractDurationMs");var DP="error",FP="interrupted",$P="permission_denied",jP=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function hr(e){return jP.test(e)?e:null}s(hr,"categoricalValue");function BP(e){for(let t of["failure_type","error_type"]){let n=hr(B(e,t));if(n)return n}return null}s(BP,"structuredFailureClass");function jg(e,t){return nt(e,"is_interrupt")===!0?FP:t.toLowerCase()==="permissiondenied"?$P:BP(e)??DP}s(jg,"extractFailureClass");function Bg(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}s(Bg,"longestDeclaredServer");function KP(e,t){return Bg(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}s(KP,"matchDeclaredMcpServer");function GP(e,t){return Bg(t,n=>(0,Qo.mcpServerNameMatchesToolSegment)(n,e))}s(GP,"matchDeclaredMcpServerSegment");function VP(e,t){let n=null,r=0;for(let i of t)if(i)for(let a of(0,Qo.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:GP(o[1],t)??o[1],mcpTool:o[2]}}s(VP,"parseClaudeMcpNames");function zP(e,t){if(/^mcp__/i.test(e))return VP(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:KP(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}s(zP,"parseMcpNamesFromToolName");function WP(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}s(WP,"stripEncodedMcpServerPrefix");function Kg(e,t=[],n=""){let r=e?zP(e,t):{mcpServer:null,mcpTool:null},o=hr(n.trim());if(!o)return r;let i=r.mcpTool;return!i&&e&&!rs(e)&&(i=e),i&&(i=WP(i,o)),{mcpServer:o,mcpTool:i}}s(Kg,"extractMcpNames");var zg=3e4,QP="claims",ew=!0,tw=100,nw=new Set(["sessionstart","sessionend","stopfailure"]),rw=["tool_name","tool","command","file_path","url"];function ow(e=Vg()){return Qa(Oe(e),QP)}s(ow,"eventClaimDir");function Wg(e,t){try{let n=qP(e,"utf8").split(`
|
|
47
|
+
`,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}s(Wg,"claimAgeMs");function sw(e){let t=[];for(let n of rw){let r=B(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":Bn(t.join("\0"))}s(sw,"callFingerprintFromHookInput");function iw(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=nw.has(n);if(!c&&!u)return;let f=e.runnerPlatform.trim()||"unknown";return Bn(`${f}|${t}|${n}|${r}|${o}|${a}|${i}`)}s(iw,"eventClaimKey");function aw(e,t=Date.now()){let n;try{n=XP(e)}catch{return}let r=0;for(let o of n){if(r>=tw)break;r+=1;let i=Qa(e,o),a=Wg(i,t);if(!(!Number.isFinite(a)||a<zg))try{Gg(i)}catch{}}}s(aw,"pruneStaleEventClaims");function cw(e,t,n=Date.now()){let r=Qa(t,e);try{if(JP(r)){let o=Wg(r,n);if(Number.isFinite(o)&&o>=0&&o<zg)return!1;try{Gg(r)}catch(i){if(!(i instanceof Error&&"code"in i&&i.code==="ENOENT"))return L("event_claim_steal",i),!0}}}catch{}try{YP(t,{recursive:!0}),ZP(r,`${n}
|
|
48
|
+
`,{encoding:"utf8",flag:"wx"})}catch(o){if(Fn(o))return!1;let i=o instanceof Error?o.message:String(o);return C(`WARN: event claim failed open: ${i}`),L("event_claim",o),!0}return aw(t,n),!0}s(cw,"tryClaimHookEvent");function uw(e,t,n){let r=Pn(e),o=Za(e),i=B(e,"tool_use_id"),a=B(e,"subagent_id")||B(e,"agent_id"),c=xn(e,t,void 0,n),u=sw(e);return{runnerPlatform:c,sessionId:r,runnerEvent:t,turnId:o,toolUseId:i,subagentId:a,callFingerprint:u}}s(uw,"identityFromHookInput");function Jg(e,t,n,r=Vg(),o=Date.now()){if(!ew)return!0;let i=iw(uw(e,t,n));if(!i)return!0;let a=cw(i,ow(r),o);return!a&&j("EV_AI_HOOK_DEBUG")&&C(`DEBUG: duplicate hook event suppressed (claim ${i.slice(0,8)}\u2026)`),a}s(Jg,"claimHookEvent");import{mkdirSync as lw,readFileSync as ec,statSync as Zg,unlinkSync as Qg,writeFileSync as tc}from"node:fs";import{homedir as e_}from"node:os";function t_(e){return e==="session_start"||e==="session_end"}s(t_,"isCapExemptEvent");var os=new Set,Yg=!1;function nc(e=e_()){return Wc(e)}s(nc,"hookSlotDir");function rc(e,t=e_(),n=process.platform){if(e!==void 0)return e>0?e:Pr(n);let r=Y(Kt(t),{});return hu(r)??Pr(n)}s(rc,"maxConcurrentHookProcesses");function Er(e){return vr(e.pid,e.acquiredAtMs)}s(Er,"slotContent");function n_(e){try{let t=Zg(e);return t.isFile()&&t.size<=Cs?ec(e,"utf8"):void 0}catch{return}}s(n_,"readSlotText");function oc(e,t=nc()){if(!e)return;let n=Nr(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=n_(n);if(o===Er(r))return ss(r);if(o===vr(process.ppid,e.acquiredAtMs))try{return tc(n,Er(r),{encoding:"utf8",mode:384}),ss(r)}catch{return}}s(oc,"adoptHookSlot");function r_(e,t){if(e.path){os.delete(e);try{n_(e.path)===Er(e)&&tc(e.path,vr(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}s(r_,"handOffHookSlot");function o_(e,t=Date.now()){let n,r;try{let o=Zg(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=Cs?ec(e,"utf8"):""}catch{return!1}return Yc(n,r,t)}s(o_,"isSlotHeld");function s_(e,t=nc(),n=Date.now){for(let r=0;r<e;r+=1)if(!o_(Nr(t,r),n()))return!0;return e<=0}s(s_,"hasFreeHookSlot");function i_(e){return{pid:process.pid,acquiredAtMs:e}}s(i_,"noopSlot");function Xg(e,t){let n=e instanceof Error?e.message:String(e);return C(`WARN: hook process slot failed open: ${n}`),L("slot",e),i_(t)}s(Xg,"failOpen");function ss(e){return os.add(e),Yg||(Yg=!0,process.once("exit",()=>{for(let t of[...os])is(t)})),e}s(ss,"hold");function qg(e){try{return tc(e.path,Er(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(Fn(t))return!1;throw t}}s(qg,"tryCreateSlot");function a_(e,t=nc(),n=Date.now){if(e<=0)return i_(n());try{lw(t,{recursive:!0})}catch(i){return Xg(i,n())}let r,o=0;for(let i=0;i<e;i+=1)try{let a={path:Nr(t,i),pid:process.pid,acquiredAtMs:n()};if(qg(a))return ss(a);if(o_(a.path,n())){o+=1;continue}try{Qg(a.path)}catch(c){if(!on(c))throw c}if(a.acquiredAtMs=n(),qg(a))return ss(a);o+=1}catch(a){r??=a}return r!==void 0&&o>0&&L("slot",r),r===void 0||o>0?null:Xg(r,n())}s(a_,"tryAcquireHookSlot");function is(e,t=Date.now()){if(os.delete(e),!(!e.path||t-e.acquiredAtMs>=wr-$n))try{ec(e.path,"utf8")===Er(e)&&Qg(e.path)}catch{}}s(is,"releaseHookSlot");function sc(e){j("EV_AI_HOOK_DEBUG")&&C(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}s(sc,"logHookCapReached");import{closeSync as fw,writeSync as dw}from"node:fs";function c_(e=process.env){let t=e[ys];if(delete e[ys],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{dw(n,Hc)}catch{}try{fw(n)}catch{}}}s(c_,"signalLauncherReady");function ic(e=process.env){let t=e[Nc];if(t)return{launcherVersion:t,hookSource:e[vc]??"",fallbackReason:e[Lc],launcherScope:e[Mc]}}s(ic,"readLauncherContext");function u_(e,t){return(e?Gt(e):void 0)===t}s(u_,"launcherScopeMatch");import{readFileSync as pw,statSync as mw}from"node:fs";import{homedir as gw}from"node:os";import{join as _w}from"node:path";var hw="perf-prev.json",Ew=512,Sw=1440*60*1e3,yw=12e4,Rw=50,Sr={},l_=!1;function cc(e){return Math.round(e*10)/10}s(cc,"round1");function Qe(e,t){if(!zn())return t();let n=performance.now();return t().finally(()=>{Sr[e]=cc(performance.now()-n)})}s(Qe,"span");function Cw(){for(let e of Object.keys(Sr))delete Sr[e]}s(Cw,"clearSpans");function d_(){if(!zn())return;let e=Bu();e&&(process.env[Hs]=e)}s(d_,"handOffHookTimings");function f_(e,t){if(!e)return;let n=t-e.origin;return n>=-Rw&&n<=yw?e:void 0}s(f_,"trusted");function Aw(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(Aw,"isPrevPost");function p_(e=gw()){return _w(Oe(e),hw)}s(p_,"perfPrevPath");function bw(e,t){if(!l_){l_=!0;try{let n=p_(t);if(mw(n).size>Ew)return;let r=JSON.parse(pw(n,"utf8"));return!Aw(r)||e-r.at>Sw?void 0:{at:r.at,post_ms:r.post_ms}}catch{return}}}s(bw,"takePrevPost");function uc(e,t){if(!zn())return;let n={at:Date.now(),post_ms:Math.max(0,Math.round(e))};try{fe(p_(t),JSON.stringify(n))}catch{}}s(uc,"recordPostDuration");function ac(e,t,n,r,o=n.marks){let i=Math.max(0,n.origin-r);e[t]=cc(i);for(let[a,c]of Object.entries(o))e[a]=cc(i+c)}s(ac,"addProcess");function m_(e,t=process.env,n,r=!1){let o=r?ml():void 0;if(!zn())return o?{sys:o}:void 0;let i=$u(),a="w0"in i.marks?"w":"h",c=a==="w"?f_(Ds(t[Hs]),i.origin):void 0,u=f_(Ds(t[Du]),(c??i).origin),f=u?"l":c?"h":a,l=(u??c??i).origin,p={};u&&ac(p,"l",u,l),c&&ac(p,"h",c,l),ac(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(Sr).length>0&&(d.spans={...Sr},Cw());let m=bw(Date.now(),n);return m&&(d.prev=m),o&&(d.sys=o),d}s(m_,"buildPerf");import{realpathSync as Yv}from"node:fs";import{homedir as Xv}from"node:os";var K=Te(Pe(),1);import{existsSync as Ow,readFileSync as g_}from"node:fs";import{homedir as __}from"node:os";import{join as kw}from"node:path";var Iw="cloud-cache.json",Tw="cloud-cache-interactive.json",xw=1440*60*1e3,Pw=900*1e3,ww=360*60*1e3;function Nw(e=__(),t){let n=t==="interactive"?Tw:Iw;return kw(Oe(e),n)}s(Nw,"cloudCachePath");function vw(e){if(!Ow(e))return;let t=we(g_(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(vw,"readCloudCache");function Lw(e,t){try{fe(e,`${JSON.stringify(t)}
|
|
49
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);C(`WARN: cloud cache write failed open: ${r}`),L("cloud_cache",n)}}s(Lw,"writeCloudCache");function Mw(e,t,n){return!e||e.context!==t?!1:n-e.probed_at<Uw(e)}s(Mw,"isCacheValid");function Uw(e){return e.result!==null?xw:e.context==="interactive"?ww:Pw}s(Uw,"cacheTtlMs");var Hw="7783-7084-3265-9085-8269-3286-77",Dw=/^i-[0-9a-f]{8,17}$/,as="/sys/class/dmi/id";function Fw(e){try{return g_(e,"utf8").trim()}catch{return}}s(Fw,"readSysfsText");function $w(e={}){if((e.platform??process.platform)!=="linux")return!1;let n=e.readFile??Fw,r=s(o=>n(o)?.toLowerCase()??"","lower");return r(`${as}/sys_vendor`)==="amazon ec2"||r(`${as}/product_name`)==="google compute engine"||Dw.test(r(`${as}/board_asset_tag`))||r(`${as}/chassis_asset_tag`)===Hw?!0:r("/sys/hypervisor/uuid").startsWith("ec2")}s($w,"hasCloudVmHint");async function jw(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(jw,"probeAws");async function Bw(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(Bw,"probeGcp");async function Kw(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(Kw,"probeAzure");async function Gw(e){let t=await Promise.allSettled([jw(e),Bw(e),Kw(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}s(Gw,"runCloudProbes");async function h_(e,t){if(e==="interactive"&&!(t?.hasCloudHint??$w)())return null;let n=t?.home??__(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),i=Nw(n,e),a=vw(i);if(Mw(a,e,o))return a.result;let c=await Gw(r);return Lw(i,{context:e,probed_at:o,result:c}),c}s(h_,"probeCloud");var y_=Te(Pe(),1);import{existsSync as E_}from"node:fs";import{homedir as S_}from"node:os";import{join as wn,relative as Vw,resolve as lc,sep as fc}from"node:path";function yr(e,t,n){if(!E_(e))return;let r=Y(e,{});for(let[o,i]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:i})}s(yr,"readMcpServers");function zw(e,t,n){if(!E_(e))return;let r=Y(e,{}),o=lc(t),i=null;for(let c of Object.keys(r.projects??{})){let u=lc(c);(o===u||o.startsWith(u.endsWith(fc)?u:u+fc))&&(i===null||u.length>lc(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(zw,"readClaudeProjectMcpServers");var dc=".gemini/config/mcp_config.json",Ww=".agents/mcp_config.json";function Jw(e,t){for(let n of Rn(e))if(n.enabled)for(let r of n.mcpConfigFiles){let o=Y(r,{}),i=Vw(e,r).split(fc).join("/");for(let[a,c]of Object.entries(o.mcpServers??{})){let u=kp(n.key,a);t.set(u,{declared:{name:u,source:"antigravity_mcp_plugin",sourcePath:i,scope:"user",nativeKey:a},config:c})}}}s(Jw,"readAntigravityPluginMcpServers");function R_(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"?(yr(wn(r,".claude.json"),{source:"claude_json_user"},o),zw(wn(r,".claude.json"),t,o)):n==="cursor"?yr(wn(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o):n==="antigravity"&&(yr(wn(r,dc),{source:"antigravity_mcp_user"},o),Jw(r,o),yr(wn(t,Ww),{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)yr(wn(t,a),{source:c},o);return o}s(R_,"collectMcpServers");async function pc(e,t=process.cwd(),n="claude",r=S_()){return[...R_(e,t,n,r).values()].map(o=>o.declared)}s(pc,"mcpDeclared");function C_(e,t,n=process.cwd(),r="claude",o=S_()){let i=R_(t,n,r,o),a=i.get(e);if(a!==void 0)return a.config??null;for(let[c,u]of i)if((0,y_.mcpServerNameMatchesToolSegment)(c,e))return u.config??null;return null}s(C_,"mcpServerConfig");var Yw=["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"],Xw=["CURSOR_PROJECT_DIR"],qw=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function Zw(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)qw.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}s(Zw,"stripUrlUserinfo");function A_(e=process.env){let t=Yw.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:Zw(e[r]??"")}:{name:r,present:!1}),n=Xw.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}s(A_,"readEnvVars");import{homedir as bN}from"node:os";import{homedir as k_}from"node:os";import{join as b_}from"node:path";var Qw="https://api.openai.com/auth";function Nn(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Nn,"trimString");function I_(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}s(I_,"asJsonObject");function eN(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 I_(r)}catch{return null}}s(eN,"decodeJwtPayload");function O_(e,t,n){return Nn(e[n])??Nn(t?.[n])}s(O_,"claim");function tN(e=process.env,t=k_()){let n=Nn(e.CODEX_HOME)??b_(t,".codex");return b_(n,"auth.json")}s(tN,"codexAuthPath");function T_(e=process.env,t=k_()){let n=Y(tN(e,t),{}),r=Nn(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&Nn(n.OPENAI_API_KEY))return null;let o=Nn(n.tokens?.id_token);if(!o)return null;let i=eN(o);if(!i)return null;let a=I_(i[Qw]),c=O_(i,a,"name"),u=O_(i,a,"email");return!u||_e(c,u)?null:{git_user_name:null,git_user_email:null,platform_login:u,identity_source:"codex_oauth"}}s(T_,"readCodexOperatorIdentity");import{homedir as ls}from"node:os";import{join as ht}from"node:path";import{join as nN}from"node:path";var rN="cursor-ide-identity.json",oN=840*60*1e3;function P_(e){return nN(Oe(e),rN)}s(P_,"cursorIdeIdentityCachePath");function x_(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(x_,"nullableString");function w_(e){let t=Y(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:x_(t.email),auth_id:x_(t.auth_id)}}s(w_,"readCursorIdeIdentityCache");function N_(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<oN}s(N_,"isCursorIdeIdentityCacheFresh");function v_(e,t){try{fe(e,`${JSON.stringify(t)}
|
|
50
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);C(`WARN: cursor IDE identity cache write failed open: ${r}`),L("cursor_identity_cache",n)}}s(v_,"writeCursorIdeIdentityCache");import{execFileSync as sN}from"node:child_process";import{existsSync as iN}from"node:fs";import{createRequire as aN}from"node:module";import{pathToFileURL as cN}from"node:url";var M_=aN(import.meta.url),cs=`
|
|
51
51
|
SELECT key, value
|
|
52
52
|
FROM ItemTable
|
|
53
53
|
WHERE key LIKE 'cursorAuth/%'
|
|
54
54
|
AND key NOT LIKE '%Token%'
|
|
55
55
|
AND key NOT LIKE '%token%'
|
|
56
56
|
ORDER BY key
|
|
57
|
-
`.trim(),
|
|
58
|
-
`)){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&&!Qg(i)&&t.set(i,a)}return t}s(Hw,"parseCliTable");function Dw(e){try{let t=Tw("sqlite3",["-noheader","-batch","-separator"," ",e,Jo],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return Hw(t)}catch{return null}}s(Dw,"readViaSqliteCli");function t_(e){let t=Wa.get(e);if(t)return t;if(!ww(e)){let o=new Map;return Wa.set(e,o),o}let n=Mw(e),r=vw(n)??Dw(n)??Uw(n)??new Map;return Wa.set(e,r),r}s(t_,"readCursorAuthItems");var Fw="cursorAuth/cachedEmail",$w="cursorAuth/stripeMembershipAuthId";function Yo(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(Yo,"trimEnv");function jw(e=Xo(),t=process.platform,n=process.env){let r=Yo(n.VSCODE_PORTABLE);if(r)return ft(r,"user-data");let o=Yo(n.VSCODE_APPDATA);if(o)return ft(o,"Cursor");switch(t){case"darwin":return ft(e,"Library","Application Support","Cursor");case"win32":return ft(Yo(n.APPDATA)??ft(e,"AppData","Roaming"),"Cursor");default:return ft(Yo(n.XDG_CONFIG_HOME)??ft(e,".config"),"Cursor")}}s(jw,"cursorUserDataDir");function Bw(e=Xo()){return ft(e,".cursor","cli-config.json")}s(Bw,"cursorCliConfigPath");function Kw(e=Xo(),t=process.platform,n=process.env){return ft(jw(e,t,n),"User","globalStorage","state.vscdb")}s(Kw,"cursorIdeStateDbPath");function dr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(dr,"trimString");function Gw(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):dr(e.userId)}s(Gw,"numericUserId");function Vw(e){return dr(e.email)??dr(e.authId)??Gw(e)}s(Vw,"platformLogin");function Ja(e){let t=dr(e.email),n=dr(e.displayName),r=Vw(e);return!r||me(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}s(Ja,"identityFromAuth");function zw(e){let n=ee(Bw(e),{}).authInfo;return!n||typeof n!="object"?null:Ja(n)}s(zw,"readCliOperatorIdentity");function Ww(e,t,n){let r=Kw(e,process.platform,t),o=Wg(e),i=Jg(o);if(Yg(i,r,n))return Ja({email:i?.email,authId:i?.auth_id});let a=t_(r),c=a.get(Fw)??null,u=a.get($w)??null;return Xg(o,{read_at_ms:n,db_path:r,email:c,auth_id:u}),Ja({email:c,authId:u})}s(Ww,"readIdeOperatorIdentity");function n_(e=Xo(),t=process.env,n=Date.now()){return zw(e)??Ww(e,t,n)}s(n_,"readCursorOperatorIdentity");function Yw(e,t,n="git_config",r=null){return q(`${e??""}|${t??""}|${r??""}|${n}`)}s(Yw,"hashOperatorIdentity");async function Xw(e,t=re,n){let r=await Io(e,{exec:t,cachePath:n});return{git_user_name:r.userName,git_user_email:r.userEmail,platform_login:null}}s(Xw,"readGitOperatorIdentity");function qw(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(qw,"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 Ya(e){let t=e?.trim();return t&&!me(null,t)?t:null}s(Ya,"humanEmail");function Zw(e,t){return Ya(t.cursorOwner?.userEmail)??Ya(e.CURSOR_USER_EMAIL)??Ya(t.hookUserEmail)??z(t.cursorOwner?.userId??void 0)}s(Zw,"cursorCloudLogin");function Qw(e=process.env,t,n={}){let r=z(e.EV_AI_HOOK_OPERATOR_EMAIL),o=z(e.EV_AI_HOOK_OPERATOR_LOGIN),i=dt(z(e.EV_AI_HOOK_OPERATOR_NAME),r,"configured",r??o);if(i)return i;let a=z(e.GITHUB_ACTOR)??z(e.GITHUB_TRIGGERING_ACTOR)??z(e.GITHUB_USER),c=dt(a,null,"github",a);if(c)return c;let u=z(e.GITLAB_USER_LOGIN),f=z(e.GITLAB_USER_EMAIL),l=dt(z(e.GITLAB_USER_NAME)??u,f,"gitlab",f??u);if(l)return l;let p=z(e.BUILD_REQUESTEDFOREMAIL),d=dt(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=dt(z(e.BUILDKITE_BUILD_CREATOR),m,"buildkite",m);if(g)return g;let h=z(e.BUILD_USER_EMAIL)??z(e.CHANGE_AUTHOR_EMAIL),E=dt(z(e.BUILD_USER)??z(e.CHANGE_AUTHOR),h,"jenkins",h??z(e.BUILD_USER_ID));if(E)return E;let k=z(e.CIRCLE_USERNAME),w=dt(k,null,"circleci",k);if(w)return w;let P=z(e.CODEBUILD_INITIATOR),I=dt(P,null,"codebuild",P);if(I)return I;let O=z(e.DRONE_COMMIT_AUTHOR_EMAIL),U=z(e.DRONE_COMMIT_AUTHOR),M=dt(U??z(e.DRONE_COMMIT_AUTHOR_NAME),O,"drone",O??U);if(M)return M;if(r_(e.CLAUDE_CODE_REMOTE)||r_(e.CURSOR_AGENT)||t!==void 0&&eP.has(t)){let x=Zw(e,n);return x?{git_user_name:null,git_user_email:null,platform_login:x,identity_source:"cursor_oauth"}:{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"cloud"}}return null}s(Qw,"readCloudOperatorIdentity");var eP=new Set(["cursor_cloud","claude_remote"]);function Xa(e){return!!((e.git_user_name??e.git_user_email)&&!me(e.git_user_name,e.git_user_email))}s(Xa,"isHumanOperator");function z(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(z,"trimEnv");function r_(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(r_,"isTruthyEnv");function tP(e,t,n){return e==="claude"?mu(t):e==="cursor"?n_(t,n):e==="codex"?Vg(n,t):null}s(tP,"readRunnerOperatorIdentity");async function qa(e,t=re,n=process.env,r={}){let o=await Xw(e,t,r.gitConfigCachePath),i=qw(n),a=Xa(o)?o:i&&Xa(i)?i:null,c=r.home??Jw(),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 Wr({env:n,home:c}):null,l=Qw(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:Xa(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(qa,"resolveOperatorIdentity");async function Za(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??re,i=e.env??process.env,a=await qa(t,o,i,{runnerPlatform:e.runnerPlatform,home:e.home,context:e.context,hookUserEmail:e.hookUserEmail,gitConfigCachePath:e.gitConfigCachePath}),c=Yw(a.git_user_name,a.git_user_email,a.identity_source,a.platform_login),f=(n?pa(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&&Yp(m,c,Or())},"commit")}}s(Za,"resolveOperatorForSend");function Qa(e){return e?!pa(e)?.operator_identity_hash:!0}s(Qa,"operatorIdentityNeverSent");var nP=new Set(["claude","codex","copilot"]);function o_(e,t){return!(t!==void 0&&nP.has(t))}s(o_,"shouldBootstrapCloudIdentity");import{homedir as CP}from"node:os";import{join as a_}from"node:path";import{join as qo}from"node:path";function rP(e){return qo(e,".ev-ai","agent-hook","js","signed-v1")}s(rP,"jsRoot");function oP(e){return qo(rP(e),"scopes")}s(oP,"scopesRoot");function s_(e,t){return qo(oP(e),t)}s(s_,"scopeDir");function i_(e){return qo(e,"attempts")}s(i_,"attemptsDir");function ec(e){return String(e).padStart(10,"0")}s(ec,"padAttempt");var sP=/^(\d{10})$/,iP=/^(\d{10})\.done$/,aP=/^[0-9a-f]{128}$/,cP=64,f_=["check_ms","download_ms","install_ms","total_ms"],uP=36e5;async function d_(e,t,n=!1){let r=i_(t),o=await Rc(e,r),i=new Map,a=new Map,c=c_(o,sP),u=c_(o,iP),f=s(async d=>{let m=await l_(e,a_(r,lP(d)));return m&&i.set(d,{record:dP(m.value),mtimeMs:m.mtimeMs}),m!==void 0},"readClaimAt"),l=s(async d=>{let m=pP((await l_(e,a_(r,fP(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([u_(c,f),u_(u,l)]);let p=pr(i);return p<pr(a)&&u.includes(p)&&await l(p),{claims:i,dones:a}}s(d_,"scanAttempts");function c_(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}s(c_,"attemptNumbers");async function u_(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}s(u_,"firstFromTop");function pr(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}s(pr,"maxKey");function p_(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(p_,"claimStartMs");function m_(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of f_){let r=e[n];r!==void 0&&(t[n]=r)}return t}s(m_,"pickTimings");function lP(e){return ec(e)}s(lP,"claimFileName");function fP(e){return`${ec(e)}.done`}s(fP,"doneFileName");async function l_(e,t){let n;try{n=await e.stat(t)}catch(o){if(Zt(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>as)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>as?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}s(l_,"readRecord");function dP(e){if(!de(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(dP,"parseClaim");function pP(e){if(!de(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=gP(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...mP(t)}}s(pP,"parseDoneRecord");function mP(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 f_){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=uP&&(t[n]=r)}return t}s(mP,"parseTimings");function gP(e){if(!de(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"&&aP.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&_P(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}s(gP,"parseSelection");function _P(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==cP||t.toString("base64")!==e))return t.toString("hex")}s(_P,"canonicalSha512Hex");function EP(e){return e==="bootstrap"?3e3:6e4}s(EP,"ownerBudgetMs");function RP(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=p_(o),u=o.record==="empty"?void 0:o.record.owner,f=EP(u)+3e4;if(t-c>f)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:g_(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:g_(a.selection),...m_(a)}}s(RP,"latestAttemptReport");async function __(e,t,n){try{let r=await d_(Cc(),s_(e,t),!0);return RP(r,n)}catch{return}}s(__,"readLatestAttemptReport");function g_(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}s(g_,"selectionVersion");function AP(e=process.env){if(Object.values(lu).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===Ie?"npx":null}s(AP,"hookDelivery");async function h_(e=CP()){let t=$a()?.launcherScope;if(!t)return{};let n=await __(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}s(h_,"readSessionStartLauncherFields");function kn(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:ht,event:e,timestamp:Or(),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:he,hook_delivery:AP(),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=$a();return i&&(o.launcher_version=i.launcherVersion,o.hook_source=i.hookSource,o.hook_fallback_reason=i.fallbackReason??null,o.launcher_scope_match=kg(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(kn,"buildEnvelope");import{existsSync as A_}from"node:fs";import{spawn as b_}from"node:child_process";import{fileURLToPath as BP}from"node:url";import{gzipSync as bP}from"node:zlib";function tc(e){return F("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<cu?{body:e}:{body:bP(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}s(tc,"gzipBodyIfLarge");function Zo(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}s(Zo,"collectorPostHeaders");function nc(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}s(nc,"postBodyByteLength");var Yt=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 S_(e,t){for(let n of[t,t.toUpperCase()]){let r=e[n]?.trim();if(r)return{name:n,value:r}}}s(S_,"envValue");function Qo(e){let t=e.toLowerCase().replace(/\.$/,"");return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}s(Qo,"bareHost");function kP(e){let t=Qo(e);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}s(kP,"isLoopbackHost");function OP(e,t){let n=Qo(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(OP,"noProxyMatches");function xP(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(xP,"parseProxyUrl");function E_(e,t=process.env,n){if(e.protocol!=="https:"&&e.protocol!=="http:"||kP(e.hostname))return;let r=S_(t,`${e.protocol.slice(0,-1)}_proxy`);if(!r)return;let o=S_(t,"no_proxy");if(o&&OP(e,o.value))return;let i=xP(r.value);return n?.(i?`${e.host} via proxy ${i.protocol}//${i.host}`:`ignoring ${r.name}: not an http(s) URL`),i}s(E_,"proxyForUrl");function y_(e){try{return decodeURIComponent(e)}catch{return e}}s(y_,"decodeUserinfo");function R_(e){if(!e.username&&!e.password)return;let t=`${y_(e.username)}:${y_(e.password)}`;return`Basic ${Buffer.from(t,"utf8").toString("base64")}`}s(R_,"proxyAuthorization");var IP=16*1024;async function TP(e,t,n){let[r,o]=await Promise.all([import("node:net"),import("node:tls")]),i=Qo(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),h=s(()=>m?!1:(m=!0,l?.removeEventListener("abort",w),d.setTimeout(0),d.removeListener("data",P),!0),"settle"),E=s(I=>{h()&&(d.destroy(),f(I))},"fail"),k=s(I=>{h()&&u(I)},"succeed"),w=s(()=>{E(l?.reason)},"onAbort");function P(I){g=Buffer.concat([g,I]);let O=g.indexOf(`\r
|
|
57
|
+
`.trim(),mc=new Map;function L_(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(L_,"asText");function U_(e){return e.toLowerCase().includes("token")}s(U_,"isTokenKey");function H_(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=L_(r.key),i=L_(r.value);o&&i&&!U_(o)&&t.set(o,i)}return t}s(H_,"rowsToMap");function uN(e){let t=cN(e);return t.search="mode=ro&immutable=1",t.href}s(uN,"sqliteReadonlyUri");function lN(e){try{let t=M_("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(cs)??n.prepare(cs);return H_(r.all?.())}finally{n.close?.()}}catch{return null}}s(lN,"readViaBunSqlite");function fN(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(fN,"withSqliteExperimentalWarningSuppressed");function dN(e){try{return fN(()=>{let t=M_("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return H_(n.prepare(cs).all?.())}finally{n.close?.()}})}catch{return null}}s(dN,"readViaNodeSqlite");function pN(e){let t=new Map;for(let n of e.split(`
|
|
58
|
+
`)){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&&!U_(i)&&t.set(i,a)}return t}s(pN,"parseCliTable");function mN(e){try{let t=sN("sqlite3",["-noheader","-batch","-separator"," ",e,cs],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return pN(t)}catch{return null}}s(mN,"readViaSqliteCli");function D_(e){let t=mc.get(e);if(t)return t;if(!iN(e)){let o=new Map;return mc.set(e,o),o}let n=uN(e),r=lN(n)??mN(n)??dN(n)??new Map;return mc.set(e,r),r}s(D_,"readCursorAuthItems");var gN="cursorAuth/cachedEmail",_N="cursorAuth/stripeMembershipAuthId";function us(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(us,"trimEnv");function hN(e=ls(),t=process.platform,n=process.env){let r=us(n.VSCODE_PORTABLE);if(r)return ht(r,"user-data");let o=us(n.VSCODE_APPDATA);if(o)return ht(o,"Cursor");switch(t){case"darwin":return ht(e,"Library","Application Support","Cursor");case"win32":return ht(us(n.APPDATA)??ht(e,"AppData","Roaming"),"Cursor");default:return ht(us(n.XDG_CONFIG_HOME)??ht(e,".config"),"Cursor")}}s(hN,"cursorUserDataDir");function EN(e=ls()){return ht(e,".cursor","cli-config.json")}s(EN,"cursorCliConfigPath");function SN(e=ls(),t=process.platform,n=process.env){return ht(hN(e,t,n),"User","globalStorage","state.vscdb")}s(SN,"cursorIdeStateDbPath");function Rr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Rr,"trimString");function yN(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):Rr(e.userId)}s(yN,"numericUserId");function RN(e){return Rr(e.email)??Rr(e.authId)??yN(e)}s(RN,"platformLogin");function gc(e){let t=Rr(e.email),n=Rr(e.displayName),r=RN(e);return!r||_e(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}s(gc,"identityFromAuth");function CN(e){let n=Y(EN(e),{}).authInfo;return!n||typeof n!="object"?null:gc(n)}s(CN,"readCliOperatorIdentity");function AN(e,t,n){let r=SN(e,process.platform,t),o=P_(e),i=w_(o);if(N_(i,r,n))return gc({email:i?.email,authId:i?.auth_id});let a=D_(r),c=a.get(gN)??null,u=a.get(_N)??null;return v_(o,{read_at_ms:n,db_path:r,email:c,auth_id:u}),gc({email:c,authId:u})}s(AN,"readIdeOperatorIdentity");function F_(e=ls(),t=process.env,n=Date.now()){return CN(e)??AN(e,t,n)}s(F_,"readCursorOperatorIdentity");function ON(e,t,n="git_config",r=null){return q(`${e??""}|${t??""}|${r??""}|${n}`)}s(ON,"hashOperatorIdentity");async function kN(e,t=oe,n){let r=await jo(e,{exec:t,cachePath:n});return{git_user_name:r.userName,git_user_email:r.userEmail,platform_login:null}}s(kN,"readGitOperatorIdentity");function IN(e=process.env){let t=J(e.GIT_AUTHOR_NAME),n=J(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=J(e.GIT_COMMITTER_NAME),o=J(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=J(e.EMAIL);return i?{git_user_name:null,git_user_email:i,platform_login:null,identity_source:"git_env"}:null}s(IN,"readGitEnvOperatorIdentity");function Et(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(Et,"actorIdentity");function _c(e){let t=e?.trim();return t&&!_e(null,t)?t:null}s(_c,"humanEmail");function TN(e,t){return _c(t.cursorOwner?.userEmail)??_c(e.CURSOR_USER_EMAIL)??_c(t.hookUserEmail)??J(t.cursorOwner?.userId??void 0)}s(TN,"cursorCloudLogin");function xN(e=process.env,t,n={}){let r=J(e.EV_AI_HOOK_OPERATOR_EMAIL),o=J(e.EV_AI_HOOK_OPERATOR_LOGIN),i=Et(J(e.EV_AI_HOOK_OPERATOR_NAME),r,"configured",r??o);if(i)return i;let a=J(e.GITHUB_ACTOR)??J(e.GITHUB_TRIGGERING_ACTOR)??J(e.GITHUB_USER),c=Et(a,null,"github",a);if(c)return c;let u=J(e.GITLAB_USER_LOGIN),f=J(e.GITLAB_USER_EMAIL),l=Et(J(e.GITLAB_USER_NAME)??u,f,"gitlab",f??u);if(l)return l;let p=J(e.BUILD_REQUESTEDFOREMAIL),d=Et(J(e.BUILD_REQUESTEDFOR),p,"azure_devops",p??J(e.BUILD_REQUESTEDFORID));if(d)return d;let m=J(e.BUILDKITE_BUILD_CREATOR_EMAIL),g=Et(J(e.BUILDKITE_BUILD_CREATOR),m,"buildkite",m);if(g)return g;let E=J(e.BUILD_USER_EMAIL)??J(e.CHANGE_AUTHOR_EMAIL),S=Et(J(e.BUILD_USER)??J(e.CHANGE_AUTHOR),E,"jenkins",E??J(e.BUILD_USER_ID));if(S)return S;let A=J(e.CIRCLE_USERNAME),P=Et(A,null,"circleci",A);if(P)return P;let w=J(e.CODEBUILD_INITIATOR),T=Et(w,null,"codebuild",w);if(T)return T;let k=J(e.DRONE_COMMIT_AUTHOR_EMAIL),U=J(e.DRONE_COMMIT_AUTHOR),v=Et(U??J(e.DRONE_COMMIT_AUTHOR_NAME),k,"drone",k??U);if(v)return v;if($_(e.CLAUDE_CODE_REMOTE)||$_(e.CURSOR_AGENT)||t!==void 0&&PN.has(t)){let I=TN(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(xN,"readCloudOperatorIdentity");var PN=new Set(["cursor_cloud","claude_remote"]);function hc(e){return!!((e.git_user_name??e.git_user_email)&&!_e(e.git_user_name,e.git_user_email))}s(hc,"isHumanOperator");function J(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(J,"trimEnv");function $_(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s($_,"isTruthyEnv");function wN(e,t,n){return e==="claude"?Lu(t):e==="cursor"?F_(t,n):e==="codex"?T_(n,t):null}s(wN,"readRunnerOperatorIdentity");async function Ec(e,t=oe,n=process.env,r={}){let o=await kN(e,t,r.gitConfigCachePath),i=IN(n),a=hc(o)?o:i&&hc(i)?i:null,c=r.home??bN(),u=wN(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 eo({env:n,home:c}):null,l=xN(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:hc(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(Ec,"resolveOperatorIdentity");async function Sc(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??oe,i=e.env??process.env,a=await Ec(t,o,i,{runnerPlatform:e.runnerPlatform,home:e.home,context:e.context,hookUserEmail:e.hookUserEmail,gitConfigCachePath:e.gitConfigCachePath}),c=ON(a.git_user_name,a.git_user_email,a.identity_source,a.platform_login),f=(n?Na(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,Mr())},"commit")}}s(Sc,"resolveOperatorForSend");function yc(e){return e?!Na(e)?.operator_identity_hash:!0}s(yc,"operatorIdentityNeverSent");var NN=new Set(["claude","codex","copilot"]);function j_(e,t){return!(t!==void 0&&NN.has(t))}s(j_,"shouldBootstrapCloudIdentity");import{homedir as ZN}from"node:os";import{join as G_}from"node:path";import{join as fs}from"node:path";function vN(e){return fs(e,".ev-ai","agent-hook","js","signed-v1")}s(vN,"jsRoot");function LN(e){return fs(vN(e),"scopes")}s(LN,"scopesRoot");function B_(e,t){return fs(LN(e),t)}s(B_,"scopeDir");function K_(e){return fs(e,"attempts")}s(K_,"attemptsDir");function Rc(e){return String(e).padStart(10,"0")}s(Rc,"padAttempt");var MN=/^(\d{10})$/,UN=/^(\d{10})\.done$/,HN=/^[0-9a-f]{128}$/,DN=64,J_=["check_ms","download_ms","install_ms","total_ms"],FN=36e5;async function Y_(e,t,n=!1){let r=K_(t),o=await jc(e,r),i=new Map,a=new Map,c=V_(o,MN),u=V_(o,UN),f=s(async d=>{let m=await W_(e,G_(r,$N(d)));return m&&i.set(d,{record:BN(m.value),mtimeMs:m.mtimeMs}),m!==void 0},"readClaimAt"),l=s(async d=>{let m=KN((await W_(e,G_(r,jN(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([z_(c,f),z_(u,l)]);let p=Cr(i);return p<Cr(a)&&u.includes(p)&&await l(p),{claims:i,dones:a}}s(Y_,"scanAttempts");function V_(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}s(V_,"attemptNumbers");async function z_(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}s(z_,"firstFromTop");function Cr(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}s(Cr,"maxKey");function X_(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(X_,"claimStartMs");function q_(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of J_){let r=e[n];r!==void 0&&(t[n]=r)}return t}s(q_,"pickTimings");function $N(e){return Rc(e)}s($N,"claimFileName");function jN(e){return`${Rc(e)}.done`}s(jN,"doneFileName");async function W_(e,t){let n;try{n=await e.stat(t)}catch(o){if(on(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>Rs)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>Rs?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}s(W_,"readRecord");function BN(e){if(!it(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(BN,"parseClaim");function KN(e){if(!it(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=VN(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...GN(t)}}s(KN,"parseDoneRecord");function GN(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 J_){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=FN&&(t[n]=r)}return t}s(GN,"parseTimings");function VN(e){if(!it(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"&&HN.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&zN(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}s(VN,"parseSelection");function zN(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==DN||t.toString("base64")!==e))return t.toString("hex")}s(zN,"canonicalSha512Hex");function XN(e){return e==="bootstrap"?3e3:6e4}s(XN,"ownerBudgetMs");function qN(e,t){let n=Cr(e.claims);if(n===0)return;let r=Cr(e.dones),o=e.claims.get(n),i=e.dones.get(n);if(o&&!i){let c=X_(o),u=o.record==="empty"?void 0:o.record.owner,f=XN(u)+3e4;if(t-c>f)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:Z_(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:Z_(a.selection),...q_(a)}}s(qN,"latestAttemptReport");async function Q_(e,t,n){try{let r=await Y_(Bc(),B_(e,t),!0);return qN(r,n)}catch{return}}s(Q_,"readLatestAttemptReport");function Z_(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}s(Z_,"selectionVersion");function QN(e=process.env){if(Object.values(Pu).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===Ne?"npx":null}s(QN,"hookDelivery");async function eh(e=ZN()){let t=ic()?.launcherScope;if(!t)return{};let n=await Q_(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}s(eh,"readSessionStartLauncherFields");function vn(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:Ct,event:e,timestamp:Mr(),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:Se,hook_delivery:QN(),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=ic();return i&&(o.launcher_version=i.launcherVersion,o.hook_source=i.hookSource,o.hook_fallback_reason=i.fallbackReason??null,o.launcher_scope_match=u_(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(vn,"buildEnvelope");import{existsSync as ih}from"node:fs";import{spawn as ah}from"node:child_process";import{fileURLToPath as Ev}from"node:url";import{gzipSync as ev}from"node:zlib";function Cc(e){return j("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<Tu?{body:e}:{body:ev(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}s(Cc,"gzipBodyIfLarge");function ds(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}s(ds,"collectorPostHeaders");function Ac(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}s(Ac,"postBodyByteLength");var tn=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 th(e,t){for(let n of[t,t.toUpperCase()]){let r=e[n]?.trim();if(r)return{name:n,value:r}}}s(th,"envValue");function ps(e){let t=e.toLowerCase().replace(/\.$/,"");return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}s(ps,"bareHost");function tv(e){let t=ps(e);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}s(tv,"isLoopbackHost");function nv(e,t){let n=ps(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(nv,"noProxyMatches");function rv(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(rv,"parseProxyUrl");function rh(e,t=process.env,n){if(e.protocol!=="https:"&&e.protocol!=="http:"||tv(e.hostname))return;let r=th(t,`${e.protocol.slice(0,-1)}_proxy`);if(!r)return;let o=th(t,"no_proxy");if(o&&nv(e,o.value))return;let i=rv(r.value);return n?.(i?`${e.host} via proxy ${i.protocol}//${i.host}`:`ignoring ${r.name}: not an http(s) URL`),i}s(rh,"proxyForUrl");function nh(e){try{return decodeURIComponent(e)}catch{return e}}s(nh,"decodeUserinfo");function oh(e){if(!e.username&&!e.password)return;let t=`${nh(e.username)}:${nh(e.password)}`;return`Basic ${Buffer.from(t,"utf8").toString("base64")}`}s(oh,"proxyAuthorization");var ov=16*1024;async function sv(e,t,n){let[r,o]=await Promise.all([import("node:net"),import("node:tls")]),i=ps(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",w),!0),"settle"),S=s(T=>{E()&&(d.destroy(),f(T))},"fail"),A=s(T=>{E()&&u(T)},"succeed"),P=s(()=>{S(l?.reason)},"onAbort");function w(T){g=Buffer.concat([g,T]);let k=g.indexOf(`\r
|
|
59
59
|
\r
|
|
60
|
-
`);if(
|
|
61
|
-
Host: ${
|
|
62
|
-
${
|
|
60
|
+
`);if(k<0){g.length>ov&&S(new tn("EPROXY_CONNECT","proxy CONNECT reply too large"));return}let U=Number(/^HTTP\/1\.[01] (\d{3})/.exec(g.toString("latin1",0,k))?.[1]??0);if(U<200||U>299){S(new tn(U===407?"EPROXY_AUTH":"EPROXY_CONNECT",`proxy answered CONNECT with HTTP ${U||"garbage"}`,U||void 0));return}d.removeListener("data",w),d.pause(),k+4<g.length&&d.unshift(g.subarray(k+4));let v=ps(e.hostname);A(o.connect({socket:d,host:v,servername:c(v),ca:n.ca}))}s(w,"onData"),d.on("error",T=>{let k=T!==null&&typeof T=="object"&&"code"in T&&typeof T.code=="string"?T.code:"error";S(new tn("EPROXY_UNREACHABLE",`proxy connection failed (${k})`))}),d.on("close",()=>{S(new tn("EPROXY_UNREACHABLE","proxy closed the connection"))}),p!==void 0&&d.setTimeout(p,()=>{S(new tn("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:"){A(d);return}let T=`${e.hostname}:${e.port||"443"}`,k=oh(t);d.on("data",w),d.write(`CONNECT ${T} HTTP/1.1\r
|
|
61
|
+
Host: ${T}\r
|
|
62
|
+
${k?`Proxy-Authorization: ${k}\r
|
|
63
63
|
`:""}\r
|
|
64
|
-
`)})})}s(
|
|
65
|
-
${n}`}s(
|
|
66
|
-
`);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(
|
|
67
|
-
`,E=F("EV_AI_HOOK_DEBUG");E==="full"?R(`DEBUG envelope=${m}`):E==="1"&&R(`DEBUG summary=${GP(p,nc(h))}`);let k=process.argv.includes(xn),w=F("EV_AI_HOOK_SYNC")==="1";if(!($o(n.runnerEvent,n.runnerPlatform)||k||w)){let I=await XP(e,h,o);return ne(I?.pid!==void 0?{outcome:"handed_off"}:{outcome:"post_failed",err:"spawn"}),!1}return YP(e,h,o)}s(In,"emitAndPost");import{closeSync as qP,fstatSync as ZP,linkSync as QP,openSync as eN,readdirSync as tN,readSync as nN,renameSync as rN,unlinkSync as j_}from"node:fs";import{homedir as oN}from"node:os";import{basename as sN,dirname as iN}from"node:path";var L_=Os,U_=2*1024*1024,aN=Buffer.byteLength(',"run_log":',"utf8");function H_(e){let t=`${e}.send-${process.pid}`;try{return rN(e,t),{path:e,taken:t}}catch(n){return n.code==="ENOENT"?"missing":"busy"}}s(H_,"take");function D_(e){return typeof e=="object"}s(D_,"isTaken");function cN(e){let t=`${sN(e)}.`;try{return tN(iN(e)).some(n=>n.startsWith(t)&&/\.send-\d+$/.test(n))}catch{return!1}}s(cN,"anyTakenLog");function uN(e){try{QP(e.taken,e.path),j_(e.taken)}catch{}}s(uN,"putBack");function lN(e){try{j_(e)}catch{}}s(lN,"unlinkQuiet");function F_(e,t){let n;try{n=eN(e,"r");let r=ZP(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=nN(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{qP(n)}catch{}}}s(F_,"readTail");function fN(e){let t=e.indexOf(10);return t===-1?e:e.subarray(t+1)}s(fN,"fromFirstWholeLine");function $_(e,t,n){ws(r=>{r[t]===n&&delete r[t]},e)}s($_,"forgetWindow");function B_(e,t=oN(),n=process.env,r=Date.now()){try{let o=e?Lt(e):void 0;if(!o||Nu())return;let i=Ts(t)[o];if(i===void 0||i===nn)return;let a=Date.parse(i);if(Number.isNaN(a)||a>r)return;let c=Tu(t,n,r);if(c.on||c.source!=="remote")return;let u=Kr(t),f=H_(u),l=H_(`${u}.1`),p=D_(f)?f:void 0,d=D_(l)?l:void 0,m=[d,p].filter(N=>N!==void 0),g=s(()=>{for(let N of m)uN(N)},"putAllBack"),h=p?F_(p.taken,L_):void 0,E=d?F_(d.taken,L_-(h?.tail.length??0)):void 0,k=(h?.size??0)+(E?.size??0);if(k===0){g(),f!=="busy"&&l!=="busy"&&!cN(u)&&$_(t,o,i);return}let w=Buffer.concat([E?.tail??Buffer.alloc(0),h?.tail??Buffer.alloc(0)]),P=w.length<k,I=P?fN(w):w,O={log_until:i,text:I.toString("utf8"),bytes:I.length,bytes_total:k,truncated:P},U=aN+Buffer.byteLength(JSON.stringify(O),"utf8"),M=!1,x=!1;return{attach(N){if(N+U>U_){R(`run log deferred: body=${N} run_log=${U} over ${U_}`);return}return M=!0,O},settle(N){if(!x){if(x=!0,!(M&&N)){g();return}for(let L of m)lN(L.taken);$_(t,o,i)}}}}catch(o){R(`WARN: run log upload failed open: ${o instanceof Error?o.message:String(o)}`);return}}s(B_,"prepareRunLogUpload");import{createReadStream as dN}from"node:fs";import{stat as pN}from"node:fs/promises";import{basename as mN,resolve as gN}from"node:path";import{createInterface as _N}from"node:readline";var hN=1024*1024;function SN(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&mN(t).endsWith(".jsonl")}s(SN,"isSafeClaudeTranscriptPath");async function K_(e){if(!e||!SN(e))return null;try{let t=gN(e),n=await pN(t);if(!n.isFile())return null;let r=Math.max(0,n.size-hN),o=[],i=_N({input:dN(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(K_,"lastAssistantModelFromTranscript");function ts(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:Xr(e.manifest.manifest,e.manifest.hookConfig),telemetry:z_(e)}}s(ts,"envelopeFieldsFromContext");function z_(e){return im(e.manifest.localTelemetry,e.manifest.hookConfig)}s(z_,"telemetryFor");function oc(e){return Yr({sessionId:e.sessionId,hostname:vs()})}s(oc,"runnerContextOf");function sc(e){let t=$(e.hookInput,"user_email").trim();return t.length>0?t:void 0}s(sc,"hookUserEmailOf");function gr(e,t,n=oc(e)){let r=sc(e);return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{},context:n,...r?{hookUserEmail:r}:{}}}s(gr,"operatorContextFrom");function ic(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:Fs(e.manifest.hookConfig)}}s(ic,"hookInputSanitizeOptions");async function W_(e){let t=Date.now();await NN(e);let{gitRoot:n}=e.manifest;await uc(e,n);let r=ic(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:Zr(e.hookInput,e.manifest.manifest,r),envelopeFields:ts(e),launchCwd:$s(e.hookInput,r),home:EN()}}s(W_,"prepareDerivedInvoke");function G_(e){try{return Ne(yN(e))}catch{return null}}s(G_,"tryRealpath");function J_(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}s(J_,"isAbsolutePath");function V_(e,t){let n=e.replaceAll("\\","/");if(!J_(n))return null;let r=Ne(e),o=Ne(t),i=G_(e)??r,a=G_(t)??o;return i.startsWith(`${a}/`)?i.slice(a.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}s(V_,"relativeToAnchor");function Y_(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),i=V_(e,t)??(J_(r)?null:r),a=V_(e,n);return{repositorySourcePath:i,userSourcePath:a}}s(Y_,"sourcePathsFromResolvedFile");function rc(e,t,n,r,o){return X_(e,Y_(n,t.gitRoot,t.home),r,o)}s(rc,"exactFileComponentFromResolvedPath");function X_(e,{repositorySourcePath:t,userSourcePath:n},r,o){let i=t??n,a=i===null?null:o(i),c=a!==null&&i!==null?RN({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(X_,"exactFileComponent");function RN(e){try{let t=e.inRepository?Z_(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(RN,"tryExactFileComponentReference");function q_(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(q_,"policyPayload");function ac(e,t,n){return In("tool_invoked",{...n,...q_(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,kn,e.manifest.collectorUrl,t.buildStartedAtMs,gr(e,t.home))}s(ac,"postDerivedToolInvoked");function CN(e){return qm(e.runnerEvent,e.runnerPlatform)?[]:$m(e.hookInput)}s(CN,"slashIdsFromHookInput");function AN(e,t){return ac(e,t,{})}s(AN,"postPromptSubmitted");var cc=new Set([...Object.values(Jt),".github"]);function Z_(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(a=>cc.has(a));return i<0?null:`${r}:${o.slice(0,i+1).join("/")}`}s(Z_,"repositoryConfigRootExternalKey");var Q_=".codex/config.toml",bN=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",Q_]]),kN=new Map([["mcp_json",".mcp.json"],["cursor_mcp",".cursor/mcp.json"]]);function ON(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||!cc.has(r)?null:{repoSlug:e.slice(0,t),scope:n}}s(ON,"repositoryAgentScope");function xN(e,t){let n=Z_(`${e.repoSlug}:${e.scope}`,t);return n!==null?t.split("/").find(o=>cc.has(o))===e.scope.split("/").at(-1)?n:null:e.scope.includes("/")?null:`${e.repoSlug}:${e.scope}`}s(xN,"repositoryMcpRootExternalKey");function IN(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()}`))return;let u=i.find(h=>h.name.toLowerCase()===t.toLowerCase()),f=u?bN.get(u.source):o==="codex"?Q_: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?kN.get(u.source):void 0,m=ON(n);if(u===void 0||d===void 0||m===null)return;let g=xN(m,d);if(g!==null)try{return(0,V.buildComponentReference)({installationRootExternalKey:g,installableKind:V.ComponentKind.INTERFACE,sourcePath:d,nativeKey:u.name})}catch{return}}s(IN,"exactMcpComponentReference");function TN(...e){for(let t of e)if(t)return t;return null}s(TN,"firstNonEmpty");function qt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return R(`WARN: ${n} failed open: ${r}`),v(n,e.reason),t}s(qt,"settledOr");function wN(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(wN,"emptySelfConfigResult");function PN(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}s(PN,"cloudBootstrapSelfConfig");var Xt=new Set,mr=null;async function NN(e){if(Sn())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(Xt.has(t))return;if(!Qa(n)){Xt.add(t);return}let r=String(e.runnerPlatform),o=oc(e);if(o_(o,r)){if(mr){await mr;return}mr=(async()=>{if(Xt.has(t)||!Qa(n)){Xt.add(t);return}if(!Xp(n)){Xt.add(t);return}let i=!1;try{let a=Date.now(),{gitRoot:c}=e.manifest,{operatorResolved:u,fields:f}=await eh(e,o,Ye("git",()=>Do(c)),Ye("operator",()=>Za({gitRoot:c,installationStorePath:n,forceResend:!1,runnerPlatform:r,context:o,hookUserEmail:sc(e),gitConfigCachePath:yn()}))),l={...f,self_config:PN(r,u.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};i=!!await In("session_start",l,ts(e),kn,e.manifest.collectorUrl,a,gr(e,void 0,o)),i&&(u.commit(),Xt.add(t))}finally{qp(n)}})().finally(()=>{mr=null}),await mr}}s(NN,"maybeBootstrapCloudIdentity");async function uc(e,t,n){try{e.platformAgentId=await jm(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);R(`WARN: derivePlatformAgentId failed open: ${o}`),v("platform_agent_id",r)}}s(uc,"resolvePlatformAgentId");async function eh(e,t,n,r){let[o,i,a,c,u]=await Promise.allSettled([n,Ye("virt",()=>Qu()),Ye("cloud",()=>Mg(t)),Ye("host_env",()=>tl(z_(e).enabled)),r]),f=qt(o,null,"gitSnapshot"),l=qt(i,"","detectVirt"),p=qt(a,null,"probeCloud"),d=qt(c,{},"hostEnv"),m=qt(u,{commit:s(()=>{},"commit")},"resolveOperatorForSend");return await uc(e,e.manifest.gitRoot,f),{operatorResolved:m,fields:{identity:{host:vs(),context:t,virt:l||null,cloud:p,git:f},host_env:d,env_vars:$g()}}}s(eh,"collectIdentityPayload");async function MN(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=oc(e),o=String(e.runnerPlatform),i=ic(e),a=$s(e.hookInput,i),c=Ye("git",()=>Do(n)),u=h_().catch(M=>(v("launcher_fields",M),{})),f=Sn()?Promise.resolve({commit:s(()=>{},"commit")}):Ye("operator",()=>Za({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o,context:r,hookUserEmail:sc(e),gitConfigCachePath:yn()})),l=eh(e,r,c,f),[p,d]=await Promise.allSettled([Ye("mcp_declared",()=>za(e.manifest.manifest,n,o)),c.catch(()=>null).then(M=>Ye("self_config",()=>wp(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,installationId:e.manifest.installationId,gitRoot:n,launchCwd:a,inGitRepo:e.manifest.inGitRepo,remote:M?.remote??null})))]),{operatorResolved:m,fields:g}=await l,h=qt(p,[],"mcpDeclared"),E=qt(d,wN(o),"selfConfig"),k=E.config,w=$(e.hookInput,"model");w&&(k.model=w);let P={...g,mcp:{declared:h},self_config:k,run_meta:{trigger:e.hookSource||"startup"},hook_input:Zr(e.hookInput,e.manifest.manifest,{...i,launchCwd:a})},I=await u,O=B_(e.manifest.collectorUrl),U=!1;try{U=await In("session_start",P,{...ts(e),...I},kn,e.manifest.collectorUrl,t,gr(e,void 0,r),O)}finally{O?.settle(U)}U&&(E.commit(),m.commit(),Xt.add(e.manifest.installationId))}s(MN,"handleSessionStart");async function vN(e){let t=Date.now(),[,n]=await Promise.all([uc(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?K_($(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=TN($(e.hookInput,"status"),$(e.hookInput,"stop_reason"),$(e.hookInput,"reason"),ur($(e.hookInput,"error")),r==="stop"?Ze(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),i=Zr(e.hookInput,e.manifest.manifest,ic(e));n&&(i.model=n),r!=="stopfailure"&&Xr(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&i.last_assistant_message===void 0&&(i.last_assistant_message=""),await In("session_end",{status:o,...n?{model:n}:{},hook_input:i},ts(e),kn,e.manifest.collectorUrl,t,gr(e))}s(vN,"handleSessionEnd");async function LN(e){let t=CN(e),n=Vm(e.hookInput),r=Xm(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&Xr(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let i=await W_(e);await Promise.all([o?AN(e,i):void 0,t.length===0?void 0:UN(e,i,t),n.length===0?void 0:HN(e,i,n)])}s(LN,"handleSkillInvoked");function th(e,t,n,r){let o=r??Fm({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),i=rc(e,t,o,V.ComponentKind.SKILL,V.nativeKeyForSkillPath);if(i.sourcePath!==null&&Oa(i.sourcePath)?.toLowerCase()===n.toLowerCase())return i.componentReference===void 0?{}:{componentReference:i.componentReference};let a=r??zm({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),c=rc(e,t,a,V.ComponentKind.COMMAND,V.nativeKeyForCommandPath);return c.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:c.nativeKey,...c.componentReference===void 0?{}:{componentReference:c.componentReference}}}s(th,"slashComponentIdentity");function UN(e,t,n){let r=Ho(e.hookInput.tool_input);return Promise.all(n.map(o=>{let i=th(e,t,o,r);return ac(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(UN,"postSkillInvokes");function HN(e,t,n){return Promise.all(n.map(r=>{let o=Bm({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),i=rc(e,t,o,V.ComponentKind.RULE,V.nativeKeyForRulePath),a=i.nativeKey??Gm(r);return ac(e,t,{tool_name:"Rule",rule_name:a,...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(HN,"postRuleInvokes");var DN=[{kind:V.ComponentKind.SKILL,nativeKeyFn:V.nativeKeyForSkillPath},{kind:V.ComponentKind.RULE,nativeKeyFn:V.nativeKeyForRulePath},{kind:V.ComponentKind.COMMAND,nativeKeyFn:V.nativeKeyForCommandPath}];function FN(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Ia(e.hookInput);if(r===null)return n.skillName===null?{}:th(e,t,n.skillName,null);let o=Y_(r,t.gitRoot,t.home);for(let i of DN){let a=X_(e,o,i.kind,i.nativeKeyFn);if(a.nativeKey!==null)return{...a.componentReference===void 0?{}:{componentReference:a.componentReference},...i.kind===V.ComponentKind.RULE?{ruleName:a.nativeKey}:{},...i.kind===V.ComponentKind.COMMAND?{commandName:a.nativeKey}:{}}}return{}}s(FN,"toolComponentIdentity");var $N=/mcp/i;function jN(e,t,n,r){let o=$N.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let i=o?ip(t,n):Co(r.declaredConfig,n);return i===null?{}:Object.fromEntries(Object.entries(i).filter(a=>typeof a[1]=="string").map(([a,c])=>[`mcp_${a}`,c]))}s(jN,"mcpPackageFields");async function BN(e){let t=await W_(e),n=eg(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,i=xa(e.hookInput),a=kd(i,t.home),c=ng(e.hookInput),u=Zm(e.runnerEvent),f=u===!1?rg(e.hookInput,e.runnerEvent):null,l=ur($(e.hookInput,"mcp_server_name")),p=l!==null||r!==null&&Bo(r)?await za(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(U=>(v("mcpDeclared",U),[])):[],{mcpServer:d,mcpTool:m}=sg(r,p.map(U=>U.name),l??""),g=IN(r,d,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),p,l),h=g===void 0?FN(e,t,n):{},E=d===null?null:Fg(d,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),k=jN(e,i,t.home,{hasMcpIdentity:!!d||!!m,declaredConfig:E}),w=g??h.componentReference,P=h.ruleName??n.ruleName,I=h.commandName??n.commandName,O=tg(e.hookInput);await In("tool_invoked",{tool_name:r,skill_name:o,...P?{rule_name:P}:{},...I?{command_name:I}:{},success:u,duration_ms:c,...a?{executable:a}:{},...f?{failure_reason:f}:{},...d?{mcp_server:d}:{},...m?{mcp_tool:m}:{},...k,...w?{component_reference:w}:{},...O?{subagent_type:O}:{},...q_(e),hook_input:t.hookInput},t.envelopeFields,kn,e.manifest.collectorUrl,t.buildStartedAtMs,gr(e,t.home))}s(BN,"handleToolInvoked");async function nh(e){switch(et("w3"),e.internalEvent){case"session_start":await MN(e);return;case"session_end":await vN(e);return;case"skill_invoked":await LN(e);return;case"tool_invoked":await BN(e);return;default:return}}s(nh,"dispatchInternalEvent");import{mkdirSync as KN,readdirSync as GN,readFileSync as VN,statSync as rh,unlinkSync as zN,writeFileSync as WN}from"node:fs";import{homedir as ns}from"node:os";import{join as lc}from"node:path";var JN="turns",oh=1440*60*1e3,YN=100,XN=new Set(["stop","stopfailure","sessionend"]);function fc(e=ns()){return lc(Ae(e),JN)}s(fc,"sessionTurnDir");function sh(e,t){return lc(e,vn(t))}s(sh,"sessionTurnPath");function qN(e,t=Date.now()){let n;try{n=GN(e)}catch{return}let r=0;for(let o of n){if(r>=YN)return;r+=1;try{let i=lc(e,o);t-rh(i).mtimeMs>oh&&zN(i)}catch{}}}s(qN,"pruneStaleSessionTurns");function ZN(e,t,n=ns()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let i=fc(n);KN(i,{recursive:!0}),WN(sh(i,r),o,"utf8")}catch{}}s(ZN,"rememberSessionTurn");function QN(e,t=ns()){let n=e.trim();if(!n)return"";try{let r=sh(fc(t),n);return Date.now()-rh(r).mtimeMs>oh?"":VN(r,"utf8").trim()}catch{return""}}s(QN,"recallSessionTurn");function ih(e,t,n,r=ns()){let o=t.trim(),i=XN.has(n.trim().toLowerCase());return i&&qN(fc(r)),o?(ZN(e,o,r),o):i?QN(e,r):""}s(ih,"resolveTurnId");function lh(e){let t=xe(e,{});return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}s(lh,"parseHookInput");async function eM(e,t,n){let r=t??await Ir(Ur),o=lh(r),i=await cm(process.cwd(),{sessionId:An(o)});if(et("w2"),!i){ne({outcome:"no_manifest"});return}let a=Qm(o,i.manifest.platform,n),c=jo(e,a.runnerEvent);if(!c){R(`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:ih(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await nh(u)}s(eM,"runHook");function tM(e,t=!1){if(F("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,i=Cn(r,o,void 0,n.runner);return $o(o,i)?!0:t}s(tM,"shouldRunHookInProcess");function ah(e,t){let n=Nr(e),r=lh(t),o=n.event??Na(r);return qu()||Ym(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}s(ah,"preflight");function fh(e){return hg(jo(e.parsed.event,e.runnerEvent))}s(fh,"isCapExempt");async function ch(e,t,n){let{parsed:r}=e,o=n??Da(r.slot);if(!o&&!fh(e)){let i=Ha(r.cap),a=Ag(i);if(!a){Fa(i),ne({outcome:"cap_dropped"});return}o=a}try{await eM(r.event,t,r.runner)}finally{o&&Vo(o)}}s(ch,"runHookInSlot");var rs,Tn=!1,nM=500;function rM(){let e=s(()=>{process.exit(0)},"exitNow");setTimeout(e,nM);try{process.stdout.write('{"continue":true}',e)}catch{e()}}s(rM,"ackThenExit");function dh(e,t){let n=e[0]===xn?"w":e[0]===On?"post":"h";rs=void 0,Tn=!1;let r=s(a=>c=>{try{v(a,c),Mu()||(ne({outcome:"error",err:Et(c)}),rn(rs??n,he,"error"))}catch{}if(t){if(n==="h"&&!Tn){Tn=!0,rM();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(dh,"installCrashLogging");async function ph(e=process.argv.slice(2),t=!1){if(t||Gr(e),yu(),rs=void 0,Tn=!1,et(e[0]===xn?"w0":"h0"),bg(),F("EV_AI_HOOK_JUDGE")==="1"){try{await Ir(Ur)}catch{}return fs(),Tn=!0,0}if(e[0]===On){try{await es(Ln)}catch{}return 0}if(e[0]===xn){let i=!1;try{let a=await Ln();et("w1");let c=ah(e.slice(1),a);if(!c)return ne({outcome:"suppressed"}),0;uh(c),i=jo(c.parsed.event,c.runnerEvent)==="session_start",await ch(c,a)}catch(a){let c=a instanceof Error?a.message:String(a);R(`WARN: detached work failed open: ${c}`),v("work",a),ne({outcome:"error",err:Et(a)})}finally{rn("w",he,"no_post"),i&&Lu()}return 0}let n,r="error",o=!1;try{vu();let i=await Ir(Ur);et("h1");let a=ah(e,i);if(!a)return r="suppressed",0;uh(a);let{parsed:c,hookInput:u,runnerEvent:f}=a;if(n=Da(c.slot),!lg(u,f,c.runner))return r="duplicate",0;if(et("h2"),tM(a))o=!0,rs="inproc",r="no_post",await ch(a,i,n);else{let l=n||fh(a)?void 0:Ha(c.cap);if(l===void 0||Rg(l)){et("h3"),Ig();let p=await v_(i,e);n&&p?.pid!==void 0&&yg(n,p.pid),p?.pid!==void 0?r="handed_off":(r="error",ne({err:"spawn"}))}else Fa(l),r="cap_dropped"}}catch(i){let a=i instanceof Error?i.message:String(i);R(`WARN: hook failed open: ${a}`),v("hook",i),r="error",ne({outcome:"error",err:Et(i)})}finally{n&&Vo(n),fs(),Tn=!0,ne({ackMs:performance.now()}),rn(o?"inproc":"h",he,r)}return 0}s(ph,"main");function uh({parsed:e,hookInput:t,runnerEvent:n}){ne({runner:Cn(t,n,void 0,e.runner),event:n,session:An(t),tool:typeof t.tool_name=="string"?t.tool_name:void 0})}s(uh,"noteInvocation");function os(){R("Usage: ev-ai-agent-hook <configure|install|migrate-to-plugin|update|uninstall|--version>"),R(" configure [--url <\u2026/{orgToken}/hook>]"),R(" (manifest only \u2014 pair with marketplace plugins)"),R(" install --url <\u2026/{orgToken}/hook>"),R(" [--delivery npx|binary|local] [--force]"),R(" [--no-claude] [--no-cursor] [--no-codex]"),R(" (fallback: merge hooks into .claude / .cursor / .codex configs)"),R(" (writes collector_url to shared manifest; hook commands use --runner only)"),R(" migrate-to-plugin"),R(" (strip ev-ai file hooks; keep collector manifest)"),R(" update (refresh binary pins from a local build; leaves hook configs alone)"),R(" uninstall"),R("Hook mode: --runner <platform> [--url <\u2026/hook>|--token <orgToken>] [event]"),R(" (--url/--token optional overrides; else collector_url from manifest)")}s(os,"printHelp");var cM=new Set(["configure","install","migrate-to-plugin","update","uninstall","help","--help","-h","--version","-V"]);function uM(e){let[t]=e;return t!==void 0&&!cM.has(t)}s(uM,"isHookModeArgv");function mh(e){return e.includes("--help")||e.includes("-h")}s(mh,"wantsHelp");async function lM(e=process.argv.slice(2)){Gr(e);let[t,...n]=e;if(t===On){try{await es(Ln)}catch(r){v("post",r)}return 0}return t==="--version"||t==="-V"?(process.stdout.write(`${he}
|
|
68
|
-
`),0):t==="configure"?
|
|
64
|
+
`)})})}s(sv,"openProxySocket");async function iv(e,t,n,r){let o=await import("node:http"),i=await sv(e,t,n),a=e.protocol==="https:",c=oh(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(iv,"requestViaProxy");var av=new Set([101,103,204,205,304]);function cv(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(cv,"requestBody");function uv(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(uv,"codingsToUndo");function lv(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(lv,"decoderFor");async function fv(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(av.has(n))return e.resume(),new Response(null,r);let o=await import("node:stream"),i=e,a=uv(t.get("content-encoding"));if(a){let c=await import("node:zlib"),u=a.map(f=>lv(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(fv,"toResponse");function dv(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=cv(n.body),new Headers(n.headers).forEach((S,A)=>{u[A]=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}),iv(e,t,{method:n.method,headers:u,signal:o,ca:r},S=>{p=S,S.once("close",d),fv(S).then(A=>m(()=>i(A)),A=>{S.destroy(),g(A)})}).then(S=>{if(f){S.destroy();return}l=S,S.on("error",g),S.end(c)},g)})}s(dv,"fetchOnce");var pv=new Set([301,302,303,307,308]),mv=20,gv=["content-type","content-encoding","content-language","content-location","content-length"];function _v(e,t){try{return new URL(e,t)}catch{return}}s(_v,"resolveLocation");async function hv(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 dv(u,f,p,r.ca):await fetch(u,p),m=d.headers.get("location");if(o==="manual"||!pv.has(d.status)||m===null)return d;await d.body?.cancel();let g=_v(m,u),E=o==="error"?"unexpected redirect":l>=mv?"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 A of gv)i.delete(A)}g.origin!==u.origin&&(i.delete("authorization"),i.delete("cookie")),u=g,f=rh(u,r.env??process.env,r.debug)}}s(hv,"fetchViaProxy");function sh(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=rh(o,r,n);return i?hv(o,i,t,{env:r,debug:n}):fetch(e,t)}s(sh,"fetchWithEnvProxy");var Ln="__post",Mn="__work";async function Sv(e,t,n={}){if(On())return e;let r=await Ec(n.gitRoot??process.cwd(),oe,process.env,{runnerPlatform:t,home:n.home,context:n.context,hookUserEmail:n.hookUserEmail,gitConfigCachePath:kn(n.home)}),o=it(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(Sv,"attachOperatorIdentity");function yv(e,t){let n=it(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(yv,"debugEnvelopeSummary");function ch(e){switch(e){case"session_start":return bu;case"session_end":return Ou;case"tool_invoked":case"skill_invoked":return vs;default:return vs}}s(ch,"timeoutForEvent");function Rv(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
|
|
65
|
+
${n}`}s(Rv,"frameDetachedPostStdin");function uh(e,t=[],n=process.execPath,r=import.meta.url,o=ih){if(Br(n))return{command:n,args:[e,...t]};let i=Ev(r);return o(i)?{command:n,args:[i,e,...t]}:{command:n,args:[e,...t]}}s(uh,"resolveSelfReexecCommand");function Cv(e=process.execPath,t=import.meta.url,n=ih){let r=process.argv.includes("--debug")?["--debug"]:[];return uh(Ln,r,e,t,n)}s(Cv,"resolveSelfPostCommand");function Av(e){let t=e.indexOf(`
|
|
66
|
+
`);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(Av,"parseDetachedPostStdin");function bv(e){j("EV_AI_HOOK_DEBUG")&&C(`DEBUG: ${e}`)}s(bv,"debugProxy");var lh=s((e,t)=>sh(e,t,bv),"collectorFetch");function fh(e){j("EV_AI_HOOK_DEBUG")&&C(`DEBUG: send fail ${Jn(e)}`)}s(fh,"debugFailedPost");async function dh(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();Um(n,t)}catch(n){L("collector_response",n)}}s(dh,"applyCollectorHttpResponse");function ph(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(ph,"errorParts");var mh=1e3;function gh(e,t){let n=e instanceof Error&&e.name==="TimeoutError"?"timeout":"post_failed";re({outcome:n,postMs:t,err:Ot(e)})}s(gh,"noteFailedPost");async function ms(e,t=lh){try{let n=await e(),r=Av(n);if(!r){se.error("send fail code=bad-frame message=detached post stdin was not framed"),re({outcome:"post_failed",err:"bad-frame"});return}let{meta:o,body:i}=r,a=Cc(i),c=ds(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,mh).replace(/[\n\r]/g,"");se.error(`send fail http=${f.status} code=${f.status} body=${p}`),re({outcome:"post_failed",postMs:l,http:f.status});return}se.info(`send ok http=${f.status}`),re({outcome:"posted",postMs:l,http:f.status}),await dh(f,o.url)}catch(f){let l=ph(f);se.error(`send fail code=${l.code??"(none)"} ${Jn(f)}`),fh(f),gh(f,performance.now()-u)}}catch(n){L("post",n),re({outcome:"error",err:Ot(n)})}finally{fn("post",Se,"error")}}s(ms,"runDetachedPoster");async function Ov(e,t,n,r=lh){let o=ch(e),i=Cc(t),a=ds(i.contentEncoding),c=Ac(i.body);C(`POST event=${e} url=${un(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{}C(`POST gzip rejected http=${l.status} \u2014 retrying uncompressed`),l=await r(n,{method:"POST",headers:ds(),body:t,signal:AbortSignal.timeout(o)})}let p=Date.now()-u,d=performance.now()-f;if(uc(d),l.ok)return C(`POST outcome=ok elapsed_ms=${p} http=${l.status}`),se.info(`send ok http=${l.status}`),re({outcome:"posted",postMs:d,http:l.status}),await dh(l,n),!0;let m=(await l.text()).slice(0,mh).replace(/[\n\r]/g,"");return C(`POST outcome=fail elapsed_ms=${p} http=${l.status} body=${m}`),se.error(`send fail http=${l.status} code=${l.status} body=${m}`),re({outcome:"post_failed",postMs:d,http:l.status}),!1}catch(l){let p=Date.now()-u,d=performance.now()-f;uc(d);let m=ph(l);return C(`POST outcome=fail elapsed_ms=${p} http=000 body=${m.message}`),se.error(`send fail http=0 code=${m.code??"(none)"} ${Jn(l)}`),fh(l),gh(l,d),!1}}s(Ov,"postCollector");async function _h(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=>{L(i,u)}),a.stdin.on("error",u=>{L(`${i}_stdin`,u)});let c=!1;return await new Promise(u=>{let f=setTimeout(()=>{if(!c){C(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`),se.error(`failed where=${i} err=timeout message=stdin handoff timed out`);try{a.stdin.destroy()}catch{}}u()},ku),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 C(`WARN: ${o} spawn failed open: ${c}`),L(i,a),null}}s(_h,"spawnDetachedStdinChild");async function kv(e,t,n,r=ah,o=Cv){let i=ch(e),a=Rv(n,i,t),{command:c,args:u}=o();return _h(c,u,a,r,"detached post")}s(kv,"postCollectorDetached");async function hh(e,t,n=ah,r=uh){let{command:o,args:i}=r(Mn,t);return _h(o,i,e,n,"detached work")}s(hh,"runHookDetached");async function Un(e,t,n,r,o,i,a,c){if(!o)return C("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),se.error("send fail code=missing message=collector URL missing"),re({outcome:"no_collector",err:"missing"}),!1;if(!jr(o))return C(`WARN: collector URL blocked (https required): ${un(o)}`),se.error("send fail code=blocked message=collector URL blocked"),re({outcome:"no_collector",err:"blocked"}),!1;let u=performance.now(),f=await Sv(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=m_({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}
|
|
67
|
+
`,S=j("EV_AI_HOOK_DEBUG");S==="full"?C(`DEBUG envelope=${m}`):S==="1"&&C(`DEBUG summary=${yv(p,Ac(E))}`);let A=process.argv.includes(Mn),P=j("EV_AI_HOOK_SYNC")==="1";if(!(es(n.runnerEvent,n.runnerPlatform)||A||P)){let T=await kv(e,E,o);return re(T?.pid!==void 0?{outcome:"handed_off"}:{outcome:"post_failed",err:"spawn"}),!1}return Ov(e,E,o)}s(Un,"emitAndPost");import{closeSync as Iv,fstatSync as Tv,linkSync as xv,openSync as Pv,readdirSync as wv,readSync as Nv,renameSync as vv,unlinkSync as bh}from"node:fs";import{homedir as Lv}from"node:os";import{basename as Mv,dirname as Uv}from"node:path";var Eh=js,Sh=2*1024*1024,Hv=Buffer.byteLength(',"run_log":',"utf8");function yh(e){let t=`${e}.send-${process.pid}`;try{return vv(e,t),{path:e,taken:t}}catch(n){return n.code==="ENOENT"?"missing":"busy"}}s(yh,"take");function Rh(e){return typeof e=="object"}s(Rh,"isTaken");function Dv(e){let t=`${Mv(e)}.`;try{return wv(Uv(e)).some(n=>n.startsWith(t)&&/\.send-\d+$/.test(n))}catch{return!1}}s(Dv,"anyTakenLog");function Fv(e){try{xv(e.taken,e.path),bh(e.taken)}catch{}}s(Fv,"putBack");function $v(e){try{bh(e)}catch{}}s($v,"unlinkQuiet");function Ch(e,t){let n;try{n=Pv(e,"r");let r=Tv(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=Nv(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{Iv(n)}catch{}}}s(Ch,"readTail");function jv(e){let t=e.indexOf(10);return t===-1?e:e.subarray(t+1)}s(jv,"fromFirstWholeLine");function Ah(e,t,n){Vs(r=>{r[t]===n&&delete r[t]},e)}s(Ah,"forgetWindow");function Oh(e,t=Lv(),n=process.env,r=Date.now()){try{let o=e?Gt(e):void 0;if(!o||Zu())return;let i=Gs(t)[o];if(i===void 0||i===ln)return;let a=Date.parse(i);if(Number.isNaN(a)||a>r)return;let c=Yu(t,n,r);if(c.on||c.source!=="remote")return;let u=Xr(t),f=yh(u),l=yh(`${u}.1`),p=Rh(f)?f:void 0,d=Rh(l)?l:void 0,m=[d,p].filter(N=>N!==void 0),g=s(()=>{for(let N of m)Fv(N)},"putAllBack"),E=p?Ch(p.taken,Eh):void 0,S=d?Ch(d.taken,Eh-(E?.tail.length??0)):void 0,A=(E?.size??0)+(S?.size??0);if(A===0){g(),f!=="busy"&&l!=="busy"&&!Dv(u)&&Ah(t,o,i);return}let P=Buffer.concat([S?.tail??Buffer.alloc(0),E?.tail??Buffer.alloc(0)]),w=P.length<A,T=w?jv(P):P,k={log_until:i,text:T.toString("utf8"),bytes:T.length,bytes_total:A,truncated:w},U=Hv+Buffer.byteLength(JSON.stringify(k),"utf8"),v=!1,I=!1;return{attach(N){if(N+U>Sh){C(`run log deferred: body=${N} run_log=${U} over ${Sh}`);return}return v=!0,k},settle(N){if(!I){if(I=!0,!(v&&N)){g();return}for(let M of m)$v(M.taken);Ah(t,o,i)}}}}catch(o){C(`WARN: run log upload failed open: ${o instanceof Error?o.message:String(o)}`);return}}s(Oh,"prepareRunLogUpload");import{createReadStream as Bv}from"node:fs";import{stat as Kv}from"node:fs/promises";import{basename as Gv,resolve as Vv}from"node:path";import{createInterface as zv}from"node:readline";var Wv=1024*1024;function Jv(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&Gv(t).endsWith(".jsonl")}s(Jv,"isSafeClaudeTranscriptPath");async function kh(e){if(!e||!Jv(e))return null;try{let t=Vv(e),n=await Kv(t);if(!n.isFile())return null;let r=Math.max(0,n.size-Wv),o=[],i=zv({input:Bv(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(kh,"lastAssistantModelFromTranscript");function gs(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:ro(e.manifest.manifest,e.manifest.hookConfig),telemetry:xh(e)}}s(gs,"envelopeFieldsFromContext");function xh(e){return Dm(e.manifest.localTelemetry,e.manifest.hookConfig)}s(xh,"telemetryFor");function Oc(e){return no({sessionId:e.sessionId,hostname:Ys()})}s(Oc,"runnerContextOf");function kc(e){let t=B(e.hookInput,"user_email").trim();return t.length>0?t:void 0}s(kc,"hookUserEmailOf");function br(e,t,n=Oc(e)){let r=kc(e);return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{},context:n,...r?{hookUserEmail:r}:{}}}s(br,"operatorContextFrom");function Ic(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:ei(e.manifest.hookConfig)}}s(Ic,"hookInputSanitizeOptions");async function Ph(e){let t=Date.now();await uL(e);let{gitRoot:n}=e.manifest;await xc(e,n);let r=Ic(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:so(e.hookInput,e.manifest.manifest,r),envelopeFields:gs(e),launchCwd:ti(e.hookInput,r),home:Xv()}}s(Ph,"prepareDerivedInvoke");function Ih(e){try{return He(Yv(e))}catch{return null}}s(Ih,"tryRealpath");function wh(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}s(wh,"isAbsolutePath");function Th(e,t){let n=e.replaceAll("\\","/");if(!wh(n))return null;let r=He(e),o=He(t),i=Ih(e)??r,a=Ih(t)??o;return i.startsWith(`${a}/`)?i.slice(a.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}s(Th,"relativeToAnchor");function Nh(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),i=Th(e,t)??(wh(r)?null:r),a=Th(e,n);return{repositorySourcePath:i,userSourcePath:a}}s(Nh,"sourcePathsFromResolvedFile");function bc(e,t,n,r,o){return vh(e,Nh(n,t.gitRoot,t.home),r,o)}s(bc,"exactFileComponentFromResolvedPath");function vh(e,{repositorySourcePath:t,userSourcePath:n},r,o){let i=t??n,a=i===null?null:o(i),c=a!==null&&i!==null?qv({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(vh,"exactFileComponent");function qv(e){try{let t=e.inRepository?Uh(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(qv,"tryExactFileComponentReference");function Lh(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(Lh,"policyPayload");function Tc(e,t,n){return Un("tool_invoked",{...n,...Lh(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,vn,e.manifest.collectorUrl,t.buildStartedAtMs,br(e,t.home))}s(Tc,"postDerivedToolInvoked");function Zv(e){return Mg(e.runnerEvent,e.runnerPlatform)?[]:bg(e.hookInput)}s(Zv,"slashIdsFromHookInput");function Qv(e,t){return Tc(e,t,{})}s(Qv,"postPromptSubmitted");var Mh=new Set([...Object.values(en),".github"]);function Uh(e,t){let n=e.indexOf(":");return n<=0?null:(0,K.repositoryConfigRootExternalKeyFromPath)(e.slice(0,n),t)}s(Uh,"repositoryConfigRootExternalKey");var Hh=".codex/config.toml",eL=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",Hh],["antigravity_mcp_user",dc]]),tL=new Map([["mcp_json",".mcp.json"],["cursor_mcp",".cursor/mcp.json"]]);function nL(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||!Mh.has(r)?null:{repoSlug:e.slice(0,t),scope:n}}s(nL,"repositoryAgentScope");function rL(e,t){let n=Uh(`${e.repoSlug}:${e.scope}`,t);return n!==null?t.split("/").find(o=>Mh.has(o))===e.scope.split("/").at(-1)?n:null:e.scope.includes("/")?null:`${e.repoSlug}:${e.scope}`}s(rL,"repositoryMcpRootExternalKey");function oL(e,t,n){return e===Ga&&n.some(r=>r.name.toLowerCase()===t.toLowerCase())}s(oL,"isAntigravityDeclaredServer");function sL(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()}`||oL(o,t,i)))return;let u=i.find(E=>E.name.toLowerCase()===t.toLowerCase()),f=u?eL.get(u.source):o==="codex"?Hh: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?tL.get(u.source):void 0,m=nL(n);if(u===void 0||d===void 0||m===null)return;let g=rL(m,d);if(g!==null)try{return(0,K.buildComponentReference)({installationRootExternalKey:g,installableKind:K.ComponentKind.INTERFACE,sourcePath:d,nativeKey:u.name})}catch{return}}s(sL,"exactMcpComponentReference");function iL(...e){for(let t of e)if(t)return t;return null}s(iL,"firstNonEmpty");function rn(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return C(`WARN: ${n} failed open: ${r}`),L(n,e.reason),t}s(rn,"settledOr");function aL(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(aL,"emptySelfConfigResult");function cL(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}s(cL,"cloudBootstrapSelfConfig");var nn=new Set,Ar=null;async function uL(e){if(On())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(nn.has(t))return;if(!yc(n)){nn.add(t);return}let r=String(e.runnerPlatform),o=Oc(e);if(j_(o,r)){if(Ar){await Ar;return}Ar=(async()=>{if(nn.has(t)||!yc(n)){nn.add(t);return}if(!Tm(n)){nn.add(t);return}let i=!1;try{let a=Date.now(),{gitRoot:c}=e.manifest,{operatorResolved:u,fields:f}=await Dh(e,o,Qe("git",()=>Zo(c)),Qe("operator",()=>Sc({gitRoot:c,installationStorePath:n,forceResend:!1,runnerPlatform:r,context:o,hookUserEmail:kc(e),gitConfigCachePath:kn()}))),l={...f,self_config:cL(r,u.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};i=!!await Un("session_start",l,gs(e),vn,e.manifest.collectorUrl,a,br(e,void 0,o)),i&&(u.commit(),nn.add(t))}finally{xm(n)}})().finally(()=>{Ar=null}),await Ar}}s(uL,"maybeBootstrapCloudIdentity");async function xc(e,t,n){try{e.platformAgentId=await Og(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);C(`WARN: derivePlatformAgentId failed open: ${o}`),L("platform_agent_id",r)}}s(xc,"resolvePlatformAgentId");async function Dh(e,t,n,r){let[o,i,a,c,u]=await Promise.allSettled([n,Qe("virt",()=>Sl()),Qe("cloud",()=>h_(t)),Qe("host_env",()=>Rl(xh(e).enabled)),r]),f=rn(o,null,"gitSnapshot"),l=rn(i,"","detectVirt"),p=rn(a,null,"probeCloud"),d=rn(c,{},"hostEnv"),m=rn(u,{commit:s(()=>{},"commit")},"resolveOperatorForSend");return await xc(e,e.manifest.gitRoot,f),{operatorResolved:m,fields:{identity:{host:Ys(),context:t,virt:l||null,cloud:p,git:f},host_env:d,env_vars:A_()}}}s(Dh,"collectIdentityPayload");async function lL(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=Oc(e),o=String(e.runnerPlatform),i=Ic(e),a=ti(e.hookInput,i),c=Qe("git",()=>Zo(n)),u=eh().catch(v=>(L("launcher_fields",v),{})),f=On()?Promise.resolve({commit:s(()=>{},"commit")}):Qe("operator",()=>Sc({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o,context:r,hookUserEmail:kc(e),gitConfigCachePath:kn()})),l=Dh(e,r,c,f),[p,d]=await Promise.allSettled([Qe("mcp_declared",()=>pc(e.manifest.manifest,n,o)),c.catch(()=>null).then(v=>Qe("self_config",()=>cm(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,installationId:e.manifest.installationId,gitRoot:n,launchCwd:a,inGitRepo:e.manifest.inGitRepo,remote:v?.remote??null})))]),{operatorResolved:m,fields:g}=await l,E=rn(p,[],"mcpDeclared"),S=rn(d,aL(o),"selfConfig"),A=S.config,P=B(e.hookInput,"model");P&&(A.model=P);let w={...g,mcp:{declared:E.map(({nativeKey:v,...I})=>I)},self_config:A,run_meta:{trigger:e.hookSource||"startup"},hook_input:so(e.hookInput,e.manifest.manifest,{...i,launchCwd:a})},T=await u,k=Oh(e.manifest.collectorUrl),U=!1;try{U=await Un("session_start",w,{...gs(e),...T},vn,e.manifest.collectorUrl,t,br(e,void 0,r),k)}finally{k?.settle(U)}U&&(S.commit(),m.commit(),nn.add(e.manifest.installationId))}s(lL,"handleSessionStart");async function fL(e){let t=Date.now(),[,n]=await Promise.all([xc(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?kh(B(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=iL(B(e.hookInput,"status"),B(e.hookInput,"stop_reason"),B(e.hookInput,"reason"),hr(B(e.hookInput,"error")),r==="stop"?nt(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),i=so(e.hookInput,e.manifest.manifest,Ic(e));n&&(i.model=n),r!=="stopfailure"&&ro(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&i.last_assistant_message===void 0&&(i.last_assistant_message=""),await Un("session_end",{status:o,...n?{model:n}:{},hook_input:i},gs(e),vn,e.manifest.collectorUrl,t,br(e))}s(fL,"handleSessionEnd");async function dL(e){let t=Zv(e),n=xg(e.hookInput),r=Lg(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&ro(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let i=await Ph(e);await Promise.all([o?Qv(e,i):void 0,t.length===0?void 0:pL(e,i,t),n.length===0?void 0:mL(e,i,n)])}s(dL,"handleSkillInvoked");function Fh(e,t,n,r){let o=r??Ag({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),i=bc(e,t,o,K.ComponentKind.SKILL,K.nativeKeyForSkillPath);if(i.sourcePath!==null&&Wa(i.sourcePath)?.toLowerCase()===yg(n))return i.componentReference===void 0?{}:{componentReference:i.componentReference};let a=r??Pg({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),c=bc(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(Fh,"slashComponentIdentity");function pL(e,t,n){let r=qo(e.hookInput.tool_input);return Promise.all(n.map(o=>{let i=Fh(e,t,o,r);return Tc(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(pL,"postSkillInvokes");function mL(e,t,n){return Promise.all(n.map(r=>{let o=kg({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),i=bc(e,t,o,K.ComponentKind.RULE,K.nativeKeyForRulePath),a=i.nativeKey??Tg(r);return Tc(e,t,{tool_name:"Rule",rule_name:a,...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(mL,"postRuleInvokes");var gL=[{kind:K.ComponentKind.SKILL,nativeKeyFn:K.nativeKeyForSkillPath},{kind:K.ComponentKind.RULE,nativeKeyFn:K.nativeKeyForRulePath},{kind:K.ComponentKind.COMMAND,nativeKeyFn:K.nativeKeyForCommandPath}];function _L(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Ya(e.hookInput);if(r===null)return n.skillName===null?{}:Fh(e,t,n.skillName,null);let o=Nh(r,t.gitRoot,t.home);for(let i of gL){let a=vh(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(_L,"toolComponentIdentity");var hL=/mcp/i;function EL(e,t,n,r){let o=hL.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let i=o?yp(t,n):xo(r.declaredConfig,n);return i===null?{}:Object.fromEntries(Object.entries(i).filter(a=>typeof a[1]=="string").map(([a,c])=>[`mcp_${a}`,c]))}s(EL,"mcpPackageFields");async function SL(e){let t=await Ph(e),n=Dg(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,i=Ja(e.hookInput),a=Pp(i,t.home),c=$g(e.hookInput),u=Ug(e.runnerEvent),f=u===!1?jg(e.hookInput,e.runnerEvent):null,l=hr(B(e.hookInput,"mcp_server_name")),p=l!==null||r!==null&&rs(r)?await pc(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(U=>(L("mcpDeclared",U),[])):[],{mcpServer:d,mcpTool:m}=Kg(r,p.map(U=>U.name),l??""),g=sL(r,d,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),p,l),E=g===void 0?_L(e,t,n):{},S=d===null?null:C_(d,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),A=EL(e,i,t.home,{hasMcpIdentity:!!d||!!m,declaredConfig:S}),P=g??E.componentReference,w=E.ruleName??n.ruleName,T=E.commandName??n.commandName,k=Fg(e.hookInput);await Un("tool_invoked",{tool_name:r,skill_name:o,...w?{rule_name:w}:{},...T?{command_name:T}:{},success:u,duration_ms:c,...a?{executable:a}:{},...f?{failure_reason:f}:{},...d?{mcp_server:d}:{},...m?{mcp_tool:m}:{},...A,...P?{component_reference:P}:{},...k?{subagent_type:k}:{},...Lh(e),hook_input:t.hookInput},t.envelopeFields,vn,e.manifest.collectorUrl,t.buildStartedAtMs,br(e,t.home))}s(SL,"handleToolInvoked");async function $h(e){switch(ot("w3"),e.internalEvent){case"session_start":await lL(e);return;case"session_end":await fL(e);return;case"skill_invoked":await dL(e);return;case"tool_invoked":await SL(e);return;default:return}}s($h,"dispatchInternalEvent");import{mkdirSync as yL,readdirSync as RL,readFileSync as CL,statSync as jh,unlinkSync as AL,writeFileSync as bL}from"node:fs";import{homedir as _s}from"node:os";import{join as Pc}from"node:path";var OL="turns",Bh=1440*60*1e3,kL=100,IL=new Set(["stop","stopfailure","sessionend"]);function wc(e=_s()){return Pc(Oe(e),OL)}s(wc,"sessionTurnDir");function Kh(e,t){return Pc(e,Bn(t))}s(Kh,"sessionTurnPath");function TL(e,t=Date.now()){let n;try{n=RL(e)}catch{return}let r=0;for(let o of n){if(r>=kL)return;r+=1;try{let i=Pc(e,o);t-jh(i).mtimeMs>Bh&&AL(i)}catch{}}}s(TL,"pruneStaleSessionTurns");function xL(e,t,n=_s()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let i=wc(n);yL(i,{recursive:!0}),bL(Kh(i,r),o,"utf8")}catch{}}s(xL,"rememberSessionTurn");function PL(e,t=_s()){let n=e.trim();if(!n)return"";try{let r=Kh(wc(t),n);return Date.now()-jh(r).mtimeMs>Bh?"":CL(r,"utf8").trim()}catch{return""}}s(PL,"recallSessionTurn");function Gh(e,t,n,r=_s()){let o=t.trim(),i=IL.has(n.trim().toLowerCase());return i&&TL(wc(r)),o?(xL(e,o,r),o):i?PL(e,r):""}s(Gh,"resolveTurnId");function Jh(e,t,n){let r=we(e,{}),o=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:{};return mg(o,t,n)}s(Jh,"parseHookInput");async function wL(e,t,n){let r=t??await Hr(Kr),o=Jh(r,n,e),i=await $m(process.cwd(),{sessionId:Pn(o)});if(ot("w2"),!i){re({outcome:"no_manifest"});return}let a=Hg(o,i.manifest.platform,n),c=ns(e,a.runnerEvent);if(!c){Va(a.runnerEvent)||C(`WARN: unknown hook event '${a.runnerEvent}'; skipping telemetry`),re({outcome:"unknown_event"});return}re({runner:a.runnerPlatform,event:c,session:a.sessionId});let u={hookInput:o,sessionId:a.sessionId,turnId:Gh(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await $h(u)}s(wL,"runHook");function NL(e,t=!1){if(j("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,i=xn(r,o,void 0,n.runner);return es(o,i)?!0:t}s(NL,"shouldRunHookInProcess");function Vh(e,t){let n=cn(e),r=Jh(t,n.runner,n.event),o=n.event??ts(r);return n.runner==="antigravity"&&Va(ts(r))||hl()||vg(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}s(Vh,"preflight");function Yh(e){return t_(ns(e.parsed.event,e.runnerEvent))}s(Yh,"isCapExempt");async function zh(e,t,n){let{parsed:r}=e,o=n??oc(r.slot);if(!o&&!Yh(e)){let i=rc(r.cap),a=a_(i);if(!a){sc(i),re({outcome:"cap_dropped"});return}o=a}try{await wL(r.event,t,r.runner)}finally{o&&is(o)}}s(zh,"runHookInSlot");var hs,Hn=!1,vL=500;function LL(e){let t=s(()=>{process.exit(0)},"exitNow");setTimeout(t,vL);try{process.stdout.write(e,t)}catch{t()}}s(LL,"ackThenExit");function Xh(e,t){let n=e[0]===Mn?"w":e[0]===Ln?"post":"h";hs=void 0,Hn=!1;let r=s(a=>c=>{try{L(a,c),Qu()||(re({outcome:"error",err:Ot(c)}),fn(hs??n,Se,"error"))}catch{}if(t){if(n==="h"&&!Hn){Hn=!0,LL(Yo(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(Xh,"installCrashLogging");async function qh(e=process.argv.slice(2),t=!1){if(t||qr(e),Fu(),hs=void 0,Hn=!1,ot(e[0]===Mn?"w0":"h0"),c_(),j("EV_AI_HOOK_JUDGE")==="1"){try{await Hr(Kr)}catch{}return Os(Yo(e)),Hn=!0,0}if(e[0]===Ln){try{await ms(Kn)}catch{}return 0}if(e[0]===Mn){let i=!1;try{let a=await Kn();ot("w1");let c=Vh(e.slice(1),a);if(!c)return re({outcome:"suppressed"}),0;Wh(c),i=ns(c.parsed.event,c.runnerEvent)==="session_start",await zh(c,a)}catch(a){let c=a instanceof Error?a.message:String(a);C(`WARN: detached work failed open: ${c}`),L("work",a),re({outcome:"error",err:Ot(a)})}finally{fn("w",Se,"no_post"),i&&tl()}return 0}let n,r="error",o=!1;try{el();let i=await Hr(Kr);ot("h1");let a=Vh(e,i);if(!a)return r="suppressed",0;Wh(a);let{parsed:c,hookInput:u,runnerEvent:f}=a;if(n=oc(c.slot),!Jg(u,f,c.runner))return r="duplicate",0;if(ot("h2"),NL(a))o=!0,hs="inproc",r="no_post",await zh(a,i,n);else{let l=n||Yh(a)?void 0:rc(c.cap);if(l===void 0||s_(l)){ot("h3"),d_();let p=await hh(i,e);n&&p?.pid!==void 0&&r_(n,p.pid),p?.pid!==void 0?r="handed_off":(r="error",re({err:"spawn"}))}else sc(l),r="cap_dropped"}}catch(i){let a=i instanceof Error?i.message:String(i);C(`WARN: hook failed open: ${a}`),L("hook",i),r="error",re({outcome:"error",err:Ot(i)})}finally{n&&is(n),Os(Yo(e)),Hn=!0,re({ackMs:performance.now()}),fn(o?"inproc":"h",Se,r)}return 0}s(qh,"main");function Wh({parsed:e,hookInput:t,runnerEvent:n}){re({runner:xn(t,n,void 0,e.runner),event:n,session:Pn(t),tool:typeof t.tool_name=="string"?t.tool_name:void 0})}s(Wh,"noteInvocation");function Es(){C("Usage: ev-ai-agent-hook <configure|install|migrate-to-plugin|update|uninstall|--version>"),C(" configure [--url <\u2026/{orgToken}/hook>]"),C(" (manifest only \u2014 pair with marketplace plugins)"),C(" install --url <\u2026/{orgToken}/hook>"),C(" [--delivery npx|binary|local] [--force]"),C(" [--no-claude] [--no-cursor] [--no-codex]"),C(" (fallback: merge hooks into .claude / .cursor / .codex configs)"),C(" (writes collector_url to shared manifest; hook commands use --runner only)"),C(" migrate-to-plugin"),C(" (strip ev-ai file hooks; keep collector manifest)"),C(" update (refresh binary pins from a local build; leaves hook configs alone)"),C(" uninstall"),C("Hook mode: --runner <platform> [--url <\u2026/hook>|--token <orgToken>] [event]"),C(" (--url/--token optional overrides; else collector_url from manifest)")}s(Es,"printHelp");var FL=new Set(["configure","install","migrate-to-plugin","update","uninstall","help","--help","-h","--version","-V"]);function $L(e){let[t]=e;return t!==void 0&&!FL.has(t)}s($L,"isHookModeArgv");function Zh(e){return e.includes("--help")||e.includes("-h")}s(Zh,"wantsHelp");async function jL(e=process.argv.slice(2)){qr(e);let[t,...n]=e;if(t===Ln){try{await ms(Kn)}catch(r){L("post",r)}return 0}return t==="--version"||t==="-V"?(process.stdout.write(`${Se}
|
|
68
|
+
`),0):t==="configure"?Zh(n)?(Es(),0):(await cg(Jm(n)),0):t==="install"?Zh(n)?(Es(),0):(await ig(Ym(n)),0):t==="migrate-to-plugin"?(await lg(),0):t==="update"?(await ag(),0):t==="uninstall"?(await fg(),0):t==="help"||t==="--help"||t==="-h"?(Es(),0):t===void 0?(Es(),1):qh(e,!0)}s(jL,"main");function BL(e,t,n=ML){if(!t)return!1;try{return e===DL(UL(t)).href?!0:n(HL(e))===n(t)}catch{return!1}}s(BL,"isCliEntrypoint");if(BL(import.meta.url,process.argv[1])&&process.env.VITEST===void 0){let e=process.argv.slice(2);$L(e)&&Xh(e,!0),jL(e).then(t=>{process.exit(t)}).catch(t=>{L("entry",t);let n=t instanceof Error?t.message:String(t);C(n),process.exit(1)})}export{BL as isCliEntrypoint,$L as isHookModeArgv,jL as main};
|