@ev-ai/agent-hook 1.3.8 → 1.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -2,54 +2,55 @@
2
2
  import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
 
5
- var _m=Object.create;var Ui=Object.defineProperty;var hm=Object.getOwnPropertyDescriptor;var Sm=Object.getOwnPropertyNames;var Em=Object.getPrototypeOf,ym=Object.prototype.hasOwnProperty;var Xe=(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 z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Rm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Sm(t))!ym.call(e,o)&&o!==n&&Ui(e,o,{get:()=>t[o],enumerable:!(r=hm(t,o))||r.enumerable});return e};var qe=(e,t,n)=>(n=e!=null?_m(Em(e)):{},Rm(t||!e||!e.__esModule?Ui(n,"default",{value:e,enumerable:!0}):n,e));var gr=z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.MCP_MISSING_LAUNCH_SERIALIZED=Q.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;Q.foldMcpName=tu;Q.buildMcpFamilyCanonicalKey=Ph;Q.launchContainsCredentials=Nh;Q.serializeMcpLaunchIdentity=nu;Q.hashMcpLaunchIdentity=on;Q.projectMcpMissingLaunchIdentity=Lh;Q.projectMcpLaunchIdentity=Hh;Q.maskMcpLaunchForDisplay=Dh;Q.normalizeMcpToolNames=Fh;var Th=Xe("node:crypto");Q.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";Q.MCP_MISSING_LAUNCH_SERIALIZED=`${Q.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function Ke(e){return e.toLocaleLowerCase("en-US")}function tu(e){return Ke(e)}function Ph(e){return`interface:${tu(e)}`}var eu=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),wh=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function vt(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function Nh(e){return e.kind==="url"?vh(e.url):e.kind==="command"?e.arguments.some(t=>wh.test(t)):!1}function vh(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(eu.has(Ke(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 s=e.split("?",2)[1];return s===void 0?!1:s.split("&").some(i=>{let a=Ke(i.split("=",1)[0]??"");return eu.has(a)})}}function nu(e){if(e.kind==="url")return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",vt(Ke(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>Ke(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",vt(Ke(e.command)),String(t.length),...t.map(vt)].join("|")}return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",vt(e.installationRootExternalKey),vt(e.sourcePath),vt(e.nativeKey)].join("|")}function on(e){return(0,Th.createHash)("sha256").update(e).digest("hex")}var Mh=on(Q.MCP_MISSING_LAUNCH_SERIALIZED);function Lh(){return{kind:"unknown",arguments:[],serialized:Q.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:Mh}}function Hh(e){let t=nu(e);return e.kind==="url"?{kind:"url",url:Ke(e.url),arguments:[],serialized:t,contentHash:on(t)}:e.kind==="command"?{kind:"command",command:Ke(e.command),arguments:[...e.arguments].map(n=>Ke(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:on(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:on(t)}}var Uh=/^(https?:\/\/)([^/?#]*@)/i;function Dh(e){return e.replace(Uh,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}function Fh(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}});var hr=z(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.PACKAGE_FIELD_MAX=void 0;Pe.npxExecBin=ru;Pe.packageNameFromSpec=_r;Pe.pinnedPackageVersionFromSpec=ou;Pe.pinnedPackageVersionFromNpx=Jh;Pe.npxPackageSpecs=su;Pe.PACKAGE_FIELD_MAX=128;var $h=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,jh=new Set(["-p","--package"]),Bh=new Set(["-c","--call"]),Kh=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),Gh=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),Vh=/^--no-/;function Wh(e){return Gh.has(e)||Vh.test(e)}function ru(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}var zh=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function _r(e){if(e.length===0||e.length>Pe.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return $h.test(n)?n:null}function ou(e){let t=_r(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return zh.test(n)?n:void 0}function Jh(e,t){for(let n of su(e,t)){let r=ou(n);if(r!==void 0)return r}}function su(e,t){let n=ru(e);if(n===null)return[];let r=[...t];if(n==="npm"){let i=r[0]?.toLowerCase();if(i!=="exec"&&i!=="x")return[];r=r.slice(1)}let o=[],s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(Bh.has(l))return[];if(jh.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&o.push(u),c===-1&&(i+=1);continue}if(!(c!==-1||Wh(l))){if(Kh.has(l)){i+=1;continue}return[]}}return o.length>0?o.every(i=>_r(i)!==null)?o:[]:s===null||_r(s)===null?[]:[s]}});var iu=z(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.McpPackageEcosystem=void 0;mt.resolveMcpPackageIdentity=aS;var Yh=gr(),Yo=hr();mt.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var Xh=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,qh=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,Zh=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function Qh(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}var eS=new Set(["--from","--spec"]),tS=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"]),nS=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"]),rS=/^--no-/;function oS(e,t){let n=Qh(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,s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(eS.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&(o=u),c===-1&&(i+=1);continue}if(!(c!==-1||nS.has(l)||rS.test(l))){if(tS.has(l)){i+=1;continue}return null}}return o??s}function sS(e){if(e.length===0||e.length>Yo.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!qh.test(r)||!Zh.test(o)?null:{ecosystem:mt.McpPackageEcosystem.PYPI,packageName:r,version:o}}function iS(e){let t=(0,Yo.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return Xh.test(n)?{ecosystem:mt.McpPackageEcosystem.NPM,packageName:t,version:n}:null}function aS(e){if(e?.kind!=="command"||(0,Yh.launchContainsCredentials)(e))return;for(let n of(0,Yo.npxPackageSpecs)(e.command,e.arguments)){let r=iS(n);if(r!==null)return r}let t=oS(e.command,e.arguments);if(t!==null)return sS(t)??void 0}});var du=z(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.EMPTY_NPM_PUBLISHER=void 0;Ge.isNpmRegistryPublisher=uS;Ge.displayPublisherName=lS;Ge.classifyMcpProvenance=ES;var uu=gr(),Xo=hr();Ge.EMPTY_NPM_PUBLISHER="npm:";var au="npm:",cS=/^[A-Za-z0-9._-]+$/;function uS(e){return e.startsWith(au)&&e!==Ge.EMPTY_NPM_PUBLISHER&&cS.test(e.slice(au.length))}function lS(e){if(!(e==null||e===""||e===Ge.EMPTY_NPM_PUBLISHER))return e}function cu(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}function fS(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}`}function qo(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}function dS(e){let t=qo(e),n=fS(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||cu(t)||n!==void 0&&cu(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}function pS(e){let t=qo(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}function mS(e){let t=qo(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}function lu(e){let t={kind:"url",url:e};if((0,uu.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||dS(n.hostname))return{origin:"UNKNOWN"};let r=pS(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:mS(n)}}catch{return{origin:"UNKNOWN"}}}var fu="mcp-remote";function gS(e,t){if(e===fu)return t.find(n=>/^https?:\/\//i.test(n))}function _S(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}function hS(e,t,n){let r=gS(e,t);return r!==void 0?lu(r):e===fu?{origin:"UNKNOWN"}:_S(e,n)}function SS(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/")}function ES(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,uu.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return lu(t.url);let r=(0,Xo.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,Xo.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let s=hS(o,t.arguments,e.publisherName),i=typeof e.packageName=="string"?(0,Xo.packageNameFromSpec)(e.packageName):null;return i!==null&&i===o&&s.packageName!==void 0?{...s,packageName:i,packageKey:i}:s}return SS(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}});var mu=z(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.mcpServerToolSegmentForms=pu;Sr.mcpServerNameMatchesToolSegment=yS;function pu(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}function yS(e,t){let n=t.toLowerCase();return pu(e).some(r=>r.toLowerCase()===n)}});var gu=z(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.parseFrontmatterField=Ae.parseFrontmatterDescription=Ae.usableCatalogText=void 0;var RS=/^(?:>|\|)[-+]?$/,CS=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,AS=e=>{let t=e?.trim()??"";if(!(t.length===0||RS.test(t)))return t};Ae.usableCatalogText=AS;var bS=e=>(0,Ae.parseFrontmatterField)(e,"description");Ae.parseFrontmatterDescription=bS;var kS=(e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return OS(n[1],t)};Ae.parseFrontmatterField=kS;var xS=e=>e.replace(/^["']|["']$/g,"");function OS(e,t){let n=e.split(`
6
- `),r=`${t}:`,o=n.findIndex(p=>p===r||p.startsWith(`${r} `)||p.startsWith(`${r} `));if(o<0)return;let s=(n[o]??"").slice(r.length).trim(),i=CS.exec(s);if(!i){let p=xS(s).trim();return(0,Ae.usableCatalogText)(p)}let a=[];for(let p=o+1;p<n.length;p+=1){let g=n[p]??"";if(g.trim()===""){a.push("");continue}if(g.length===g.trimStart().length)break;a.push(g)}let c=a.reduce((p,g)=>g.trim()===""?p:Math.min(p,g.length-g.trimStart().length),Number.POSITIVE_INFINITY),l=[],u=i[1]?.trim();u&&l.push(u);for(let p of a)l.push(p.trim()===""?"":p.slice(c));for(;l.length>0&&l[l.length-1]==="";)l.pop();let f=s.startsWith(">")?l.join(`
5
+ var km=Object.create;var Fi=Object.defineProperty;var xm=Object.getOwnPropertyDescriptor;var Om=Object.getOwnPropertyNames;var Im=Object.getPrototypeOf,Tm=Object.prototype.hasOwnProperty;var Ze=(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 z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Pm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Om(t))!Tm.call(e,o)&&o!==n&&Fi(e,o,{get:()=>t[o],enumerable:!(r=xm(t,o))||r.enumerable});return e};var Qe=(e,t,n)=>(n=e!=null?km(Im(e)):{},Pm(t||!e||!e.__esModule?Fi(n,"default",{value:e,enumerable:!0}):n,e));var Sr=z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.MCP_MISSING_LAUNCH_SERIALIZED=Q.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;Q.foldMcpName=lu;Q.buildMcpFamilyCanonicalKey=Yh;Q.launchContainsCredentials=qh;Q.serializeMcpLaunchIdentity=fu;Q.hashMcpLaunchIdentity=an;Q.projectMcpMissingLaunchIdentity=eS;Q.projectMcpLaunchIdentity=tS;Q.maskMcpLaunchForDisplay=rS;Q.normalizeMcpToolNames=oS;var Jh=Ze("node:crypto");Q.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";Q.MCP_MISSING_LAUNCH_SERIALIZED=`${Q.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function Ve(e){return e.toLocaleLowerCase("en-US")}function lu(e){return Ve(e)}function Yh(e){return`interface:${lu(e)}`}var uu=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),Xh=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function Lt(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function qh(e){return e.kind==="url"?Zh(e.url):e.kind==="command"?e.arguments.some(t=>Xh.test(t)):!1}function Zh(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(uu.has(Ve(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 s=e.split("?",2)[1];return s===void 0?!1:s.split("&").some(i=>{let a=Ve(i.split("=",1)[0]??"");return uu.has(a)})}}function fu(e){if(e.kind==="url")return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",Lt(Ve(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>Ve(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",Lt(Ve(e.command)),String(t.length),...t.map(Lt)].join("|")}return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",Lt(e.installationRootExternalKey),Lt(e.sourcePath),Lt(e.nativeKey)].join("|")}function an(e){return(0,Jh.createHash)("sha256").update(e).digest("hex")}var Qh=an(Q.MCP_MISSING_LAUNCH_SERIALIZED);function eS(){return{kind:"unknown",arguments:[],serialized:Q.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:Qh}}function tS(e){let t=fu(e);return e.kind==="url"?{kind:"url",url:Ve(e.url),arguments:[],serialized:t,contentHash:an(t)}:e.kind==="command"?{kind:"command",command:Ve(e.command),arguments:[...e.arguments].map(n=>Ve(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:an(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:an(t)}}var nS=/^(https?:\/\/)([^/?#]*@)/i;function rS(e){return e.replace(nS,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}function oS(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}});var yr=z(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.PACKAGE_FIELD_MAX=void 0;we.npxExecBin=du;we.packageNameFromSpec=Er;we.pinnedPackageVersionFromSpec=pu;we.pinnedPackageVersionFromNpx=pS;we.npxPackageSpecs=mu;we.PACKAGE_FIELD_MAX=128;var sS=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,iS=new Set(["-p","--package"]),aS=new Set(["-c","--call"]),cS=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),uS=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),lS=/^--no-/;function fS(e){return uS.has(e)||lS.test(e)}function du(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}var dS=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function Er(e){if(e.length===0||e.length>we.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return sS.test(n)?n:null}function pu(e){let t=Er(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return dS.test(n)?n:void 0}function pS(e,t){for(let n of mu(e,t)){let r=pu(n);if(r!==void 0)return r}}function mu(e,t){let n=du(e);if(n===null)return[];let r=[...t];if(n==="npm"){let i=r[0]?.toLowerCase();if(i!=="exec"&&i!=="x")return[];r=r.slice(1)}let o=[],s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(aS.has(l))return[];if(iS.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&o.push(u),c===-1&&(i+=1);continue}if(!(c!==-1||fS(l))){if(cS.has(l)){i+=1;continue}return[]}}return o.length>0?o.every(i=>Er(i)!==null)?o:[]:s===null||Er(s)===null?[]:[s]}});var gu=z(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.McpPackageEcosystem=void 0;ht.resolveMcpPackageIdentity=xS;var mS=Sr(),qo=yr();ht.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var gS=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,_S=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,hS=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function SS(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}var ES=new Set(["--from","--spec"]),yS=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"]),RS=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"]),CS=/^--no-/;function AS(e,t){let n=SS(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,s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(ES.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&(o=u),c===-1&&(i+=1);continue}if(!(c!==-1||RS.has(l)||CS.test(l))){if(yS.has(l)){i+=1;continue}return null}}return o??s}function bS(e){if(e.length===0||e.length>qo.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!_S.test(r)||!hS.test(o)?null:{ecosystem:ht.McpPackageEcosystem.PYPI,packageName:r,version:o}}function kS(e){let t=(0,qo.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return gS.test(n)?{ecosystem:ht.McpPackageEcosystem.NPM,packageName:t,version:n}:null}function xS(e){if(e?.kind!=="command"||(0,mS.launchContainsCredentials)(e))return;for(let n of(0,qo.npxPackageSpecs)(e.command,e.arguments)){let r=kS(n);if(r!==null)return r}let t=AS(e.command,e.arguments);if(t!==null)return bS(t)??void 0}});var Ru=z(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.EMPTY_NPM_PUBLISHER=void 0;We.isNpmRegistryPublisher=IS;We.displayPublisherName=TS;We.classifyMcpProvenance=DS;var Su=Sr(),Zo=yr();We.EMPTY_NPM_PUBLISHER="npm:";var _u="npm:",OS=/^[A-Za-z0-9._-]+$/;function IS(e){return e.startsWith(_u)&&e!==We.EMPTY_NPM_PUBLISHER&&OS.test(e.slice(_u.length))}function TS(e){if(!(e==null||e===""||e===We.EMPTY_NPM_PUBLISHER))return e}function hu(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}function PS(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}`}function Qo(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}function wS(e){let t=Qo(e),n=PS(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||hu(t)||n!==void 0&&hu(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}function NS(e){let t=Qo(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}function vS(e){let t=Qo(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}function Eu(e){let t={kind:"url",url:e};if((0,Su.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||wS(n.hostname))return{origin:"UNKNOWN"};let r=NS(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:vS(n)}}catch{return{origin:"UNKNOWN"}}}var yu="mcp-remote";function MS(e,t){if(e===yu)return t.find(n=>/^https?:\/\//i.test(n))}function LS(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}function HS(e,t,n){let r=MS(e,t);return r!==void 0?Eu(r):e===yu?{origin:"UNKNOWN"}:LS(e,n)}function US(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/")}function DS(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,Su.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return Eu(t.url);let r=(0,Zo.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,Zo.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let s=HS(o,t.arguments,e.publisherName),i=typeof e.packageName=="string"?(0,Zo.packageNameFromSpec)(e.packageName):null;return i!==null&&i===o&&s.packageName!==void 0?{...s,packageName:i,packageKey:i}:s}return US(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}});var Au=z(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.mcpServerToolSegmentForms=Cu;Rr.mcpServerNameMatchesToolSegment=FS;function Cu(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}function FS(e,t){let n=t.toLowerCase();return Cu(e).some(r=>r.toLowerCase()===n)}});var bu=z(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.parseFrontmatterField=be.parseFrontmatterDescription=be.usableCatalogText=void 0;var $S=/^(?:>|\|)[-+]?$/,jS=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,BS=e=>{let t=e?.trim()??"";if(!(t.length===0||$S.test(t)))return t};be.usableCatalogText=BS;var KS=e=>(0,be.parseFrontmatterField)(e,"description");be.parseFrontmatterDescription=KS;var GS=(e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return WS(n[1],t)};be.parseFrontmatterField=GS;var VS=e=>e.replace(/^["']|["']$/g,"");function WS(e,t){let n=e.split(`
6
+ `),r=`${t}:`,o=n.findIndex(p=>p===r||p.startsWith(`${r} `)||p.startsWith(`${r} `));if(o<0)return;let s=(n[o]??"").slice(r.length).trim(),i=jS.exec(s);if(!i){let p=VS(s).trim();return(0,be.usableCatalogText)(p)}let a=[];for(let p=o+1;p<n.length;p+=1){let g=n[p]??"";if(g.trim()===""){a.push("");continue}if(g.length===g.trimStart().length)break;a.push(g)}let c=a.reduce((p,g)=>g.trim()===""?p:Math.min(p,g.length-g.trimStart().length),Number.POSITIVE_INFINITY),l=[],u=i[1]?.trim();u&&l.push(u);for(let p of a)l.push(p.trim()===""?"":p.slice(c));for(;l.length>0&&l[l.length-1]==="";)l.pop();let f=s.startsWith(">")?l.join(`
7
7
  `).split(/\n{2,}/).map(p=>p.split(`
8
8
  `).map(g=>g.trim()).filter(Boolean).join(" ")).filter(p=>p.length>0).join(`
9
9
 
10
10
  `):l.join(`
11
- `).trimEnd();return(0,Ae.usableCatalogText)(f)}});var Su=z(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=ee.COMPONENT_INSPECTION_TEXT_MAX_BYTES=ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=void 0;ee.fitSnapshotInspectionTextBudget=IS;ee.capComponentTextBytes=hu;ee.prepareComponentInspectionText=TS;ee.redactComponentSource=Zo;ee.componentSourceContainsRedactableSecret=HS;ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";ee.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;ee.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function IS(e){let t=0;return e.map(n=>{let r=n,o=r.skill?.inspectionText;if(o===void 0)return n;let s=Buffer.byteLength(o,"utf8");return t+s<=ee.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES?(t+=s,n):{...n,skill:{...r.skill,inspectionText:void 0}}})}function hu(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{}}function TS(e){if(!(e==null||e.length===0))return hu(Zo(e),ee.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}var PS=[/\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],wS=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,NS=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,vS=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,MS=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,_u=/-----END [A-Z0-9 ]*PRIVATE KEY-----/;function LS(e){let t=e.replace(NS,(n,r)=>`${r}${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(vS,(n,r)=>`${r}${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(wS,(n,r)=>`${r}${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of PS)t=t.replace(n,ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}function Zo(e){if(e.length===0)return e;let t=e.split(`
12
- `),n=!1;return t.map(o=>n?_u.test(o)?(n=!1,o):o.trim().length===0?o:ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:MS.test(o)&&!_u.test(o)?(n=!0,o):LS(o)).join(`
13
- `)}function HS(e){return Zo(e)!==e}});var at=z(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.redactComponentSource=y.prepareComponentInspectionText=y.fitSnapshotInspectionTextBudget=y.componentSourceContainsRedactableSecret=y.capComponentTextBytes=y.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=y.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=y.COMPONENT_INSPECTION_TEXT_MAX_BYTES=y.usableCatalogText=y.parseFrontmatterField=y.parseFrontmatterDescription=y.mcpServerToolSegmentForms=y.mcpServerNameMatchesToolSegment=y.isNpmRegistryPublisher=y.EMPTY_NPM_PUBLISHER=y.displayPublisherName=y.classifyMcpProvenance=y.resolveMcpPackageIdentity=y.McpPackageEcosystem=y.pinnedPackageVersionFromSpec=y.pinnedPackageVersionFromNpx=y.packageNameFromSpec=y.npxPackageSpecs=y.npxExecBin=y.PACKAGE_FIELD_MAX=y.serializeMcpLaunchIdentity=y.projectMcpMissingLaunchIdentity=y.projectMcpLaunchIdentity=y.normalizeMcpToolNames=y.MCP_MISSING_LAUNCH_SERIALIZED=y.MCP_LAUNCH_IDENTITY_ALGORITHM=y.maskMcpLaunchForDisplay=y.launchContainsCredentials=y.hashMcpLaunchIdentity=y.foldMcpName=y.buildMcpFamilyCanonicalKey=y.ComponentKind=void 0;y.userConfigRootFromPath=WS;y.installationRootExternalKey=zS;y.normalizeRepositoryRelativePath=Eu;y.nativeKeyForSkillPath=JS;y.nativeKeyForRulePath=YS;y.nativeKeyForCommandPath=XS;y.serializeComponentIdentity=Ru;y.buildComponentReference=ZS;y.validateComponentReference=QS;var US=Xe("node:crypto"),DS=Xe("node:path"),FS="cmp1_",$S=/^cmp1_[A-Za-z0-9_-]{43}$/,jS=["/skills/","/skills-cursor/"],BS=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,KS=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,GS=[".cursor",".claude",".codex"],VS={".claude.json":".claude",".agents":".codex"};y.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function WS(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>GS.includes(o));return n||(t.map(o=>VS[o]).find(o=>o!==void 0)??"unknown")}function zS(e,t){return`runtime-install:${e}/${t}`}function Er(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}function Eu(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=DS.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return Er(n,"sourcePath")}function JS(e){let t=e.replaceAll("\\","/");for(let n of jS){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}function yu(e,t,n){let r=e.replaceAll("\\","/"),s=t.exec(r)?.[1];if(!s||s.split("/").includes(".."))return null;let i=s.replace(n,"");return i.length>0?i:null}function YS(e){return yu(e,BS,/\.(mdc|md|rules)$/i)}function XS(e){return yu(e,KS,/\.(md|mdc|toml)$/i)}function qS(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function Ru(e){let t=[Er(e.installationRootExternalKey,"installationRootExternalKey"),Er(e.installableKind,"installableKind"),Eu(e.sourcePath),Er(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(qS).join("|")}`,"utf8")}function ZS(e){let t=(0,US.createHash)("sha256").update(Ru(e)).digest("base64url");return`${FS}${t}`}function QS(e){return $S.test(e)}var be=gr();Object.defineProperty(y,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:function(){return be.buildMcpFamilyCanonicalKey}});Object.defineProperty(y,"foldMcpName",{enumerable:!0,get:function(){return be.foldMcpName}});Object.defineProperty(y,"hashMcpLaunchIdentity",{enumerable:!0,get:function(){return be.hashMcpLaunchIdentity}});Object.defineProperty(y,"launchContainsCredentials",{enumerable:!0,get:function(){return be.launchContainsCredentials}});Object.defineProperty(y,"maskMcpLaunchForDisplay",{enumerable:!0,get:function(){return be.maskMcpLaunchForDisplay}});Object.defineProperty(y,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:function(){return be.MCP_LAUNCH_IDENTITY_ALGORITHM}});Object.defineProperty(y,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:function(){return be.MCP_MISSING_LAUNCH_SERIALIZED}});Object.defineProperty(y,"normalizeMcpToolNames",{enumerable:!0,get:function(){return be.normalizeMcpToolNames}});Object.defineProperty(y,"projectMcpLaunchIdentity",{enumerable:!0,get:function(){return be.projectMcpLaunchIdentity}});Object.defineProperty(y,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:function(){return be.projectMcpMissingLaunchIdentity}});Object.defineProperty(y,"serializeMcpLaunchIdentity",{enumerable:!0,get:function(){return be.serializeMcpLaunchIdentity}});var Mt=hr();Object.defineProperty(y,"PACKAGE_FIELD_MAX",{enumerable:!0,get:function(){return Mt.PACKAGE_FIELD_MAX}});Object.defineProperty(y,"npxExecBin",{enumerable:!0,get:function(){return Mt.npxExecBin}});Object.defineProperty(y,"npxPackageSpecs",{enumerable:!0,get:function(){return Mt.npxPackageSpecs}});Object.defineProperty(y,"packageNameFromSpec",{enumerable:!0,get:function(){return Mt.packageNameFromSpec}});Object.defineProperty(y,"pinnedPackageVersionFromNpx",{enumerable:!0,get:function(){return Mt.pinnedPackageVersionFromNpx}});Object.defineProperty(y,"pinnedPackageVersionFromSpec",{enumerable:!0,get:function(){return Mt.pinnedPackageVersionFromSpec}});var Cu=iu();Object.defineProperty(y,"McpPackageEcosystem",{enumerable:!0,get:function(){return Cu.McpPackageEcosystem}});Object.defineProperty(y,"resolveMcpPackageIdentity",{enumerable:!0,get:function(){return Cu.resolveMcpPackageIdentity}});var yr=du();Object.defineProperty(y,"classifyMcpProvenance",{enumerable:!0,get:function(){return yr.classifyMcpProvenance}});Object.defineProperty(y,"displayPublisherName",{enumerable:!0,get:function(){return yr.displayPublisherName}});Object.defineProperty(y,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:function(){return yr.EMPTY_NPM_PUBLISHER}});Object.defineProperty(y,"isNpmRegistryPublisher",{enumerable:!0,get:function(){return yr.isNpmRegistryPublisher}});var Au=mu();Object.defineProperty(y,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:function(){return Au.mcpServerNameMatchesToolSegment}});Object.defineProperty(y,"mcpServerToolSegmentForms",{enumerable:!0,get:function(){return Au.mcpServerToolSegmentForms}});var Qo=gu();Object.defineProperty(y,"parseFrontmatterDescription",{enumerable:!0,get:function(){return Qo.parseFrontmatterDescription}});Object.defineProperty(y,"parseFrontmatterField",{enumerable:!0,get:function(){return Qo.parseFrontmatterField}});Object.defineProperty(y,"usableCatalogText",{enumerable:!0,get:function(){return Qo.usableCatalogText}});var it=Su();Object.defineProperty(y,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return it.COMPONENT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:function(){return it.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}});Object.defineProperty(y,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return it.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"capComponentTextBytes",{enumerable:!0,get:function(){return it.capComponentTextBytes}});Object.defineProperty(y,"componentSourceContainsRedactableSecret",{enumerable:!0,get:function(){return it.componentSourceContainsRedactableSecret}});Object.defineProperty(y,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:function(){return it.fitSnapshotInspectionTextBudget}});Object.defineProperty(y,"prepareComponentInspectionText",{enumerable:!0,get:function(){return it.prepareComponentInspectionText}});Object.defineProperty(y,"redactComponentSource",{enumerable:!0,get:function(){return it.redactComponentSource}})});var jr=z(Re=>{"use strict";Re.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Re.find=(e,t)=>e.nodes.find(n=>n.type===t);Re.exceedsLimit=(e,t,n=1,r)=>r===!1||!Re.isInteger(e)||!Re.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Re.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)};Re.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Re.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;Re.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Re.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Re.flatten=(...e)=>{let t=[],n=r=>{for(let o=0;o<r.length;o++){let s=r[o];if(Array.isArray(s)){n(s);continue}s!==void 0&&t.push(s)}return t};return n(e),t}});var Br=z((IP,ff)=>{"use strict";var lf=jr();ff.exports=(e,t={})=>{let n=(r,o={})=>{let s=t.escapeInvalid&&lf.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a="";if(r.value)return(s||i)&&lf.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let c of r.nodes)a+=n(c);return a};return n(e)}});var pf=z((TP,df)=>{"use strict";df.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var Cf=z((PP,Rf)=>{"use strict";var mf=pf(),_t=(e,t,n)=>{if(mf(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(mf(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),s=String(r.shorthand),i=String(r.capture),a=String(r.wrap),c=e+":"+t+"="+o+s+i+a;if(_t.cache.hasOwnProperty(c))return _t.cache[c].result;let l=Math.min(e,t),u=Math.max(e,t);if(Math.abs(l-u)===1){let S=e+"|"+t;return r.capture?`(${S})`:r.wrap===!1?S:`(?:${S})`}let d=yf(e)||yf(t),f={min:e,max:t,a:l,b:u},p=[],g=[];if(d&&(f.isPadded=d,f.maxLen=String(f.max).length),l<0){let S=u<0?Math.abs(u):1;g=gf(S,Math.abs(l),f,r),l=f.a=0}return u>=0&&(p=gf(l,u,f,r)),f.negatives=g,f.positives=p,f.result=UR(g,p,r),r.capture===!0?f.result=`(${f.result})`:r.wrap!==!1&&p.length+g.length>1&&(f.result=`(?:${f.result})`),_t.cache[c]=f,f.result};function UR(e,t,n){let r=Hs(e,t,"-",!1,n)||[],o=Hs(t,e,"",!1,n)||[],s=Hs(e,t,"-?",!0,n)||[];return r.concat(s).concat(o).join("|")}function DR(e,t){let n=1,r=1,o=hf(e,n),s=new Set([t]);for(;e<=o&&o<=t;)s.add(o),n+=1,o=hf(e,n);for(o=Sf(t+1,r)-1;e<o&&o<=t;)s.add(o),r+=1,o=Sf(t+1,r)-1;return s=[...s],s.sort(jR),s}function FR(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=$R(e,t),o=r.length,s="",i=0;for(let a=0;a<o;a++){let[c,l]=r[a];c===l?s+=c:c!=="0"||l!=="9"?s+=BR(c,l,n):i++}return i&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[i],digits:o}}function gf(e,t,n,r){let o=DR(e,t),s=[],i=e,a;for(let c=0;c<o.length;c++){let l=o[c],u=FR(String(i),String(l),r),d="";if(!n.isPadded&&a&&a.pattern===u.pattern){a.count.length>1&&a.count.pop(),a.count.push(u.count[0]),a.string=a.pattern+Ef(a.count),i=l+1;continue}n.isPadded&&(d=KR(l,n,r)),u.string=d+u.pattern+Ef(u.count),s.push(u),i=l+1,a=u}return s}function Hs(e,t,n,r,o){let s=[];for(let i of e){let{string:a}=i;!r&&!_f(t,"string",a)&&s.push(n+a),r&&_f(t,"string",a)&&s.push(n+a)}return s}function $R(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}function jR(e,t){return e>t?1:t>e?-1:0}function _f(e,t,n){return e.some(r=>r[t]===n)}function hf(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}function Sf(e,t){return e-e%Math.pow(10,t)}function Ef(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}function BR(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}function yf(e){return/^-?(0+)\d/.test(e)}function KR(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}}`}}_t.cache={};_t.clearCache=()=>_t.cache={};Rf.exports=_t});var Fs=z((wP,Tf)=>{"use strict";var GR=Xe("util"),bf=Cf(),Af=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),VR=e=>t=>e===!0?Number(t):String(t),Us=e=>typeof e=="number"||typeof e=="string"&&e!=="",hn=e=>Number.isInteger(+e),Ds=e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},WR=(e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,zR=(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},Gr=(e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},JR=(e,t,n)=>{e.negatives.sort((a,c)=>a<c?-1:a>c?1:0),e.positives.sort((a,c)=>a<c?-1:a>c?1:0);let r=t.capture?"":"?:",o="",s="",i;return e.positives.length&&(o=e.positives.map(a=>Gr(String(a),n)).join("|")),e.negatives.length&&(s=`-(${r}${e.negatives.map(a=>Gr(String(a),n)).join("|")})`),o&&s?i=`${o}|${s}`:i=o||s,t.wrap?`(${r}${i})`:i},kf=(e,t,n,r)=>{if(n)return bf(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let s=String.fromCharCode(t);return`[${o}-${s}]`},xf=(e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return bf(e,t,n)},Of=(...e)=>new RangeError("Invalid range arguments: "+GR.inspect(...e)),If=(e,t,n)=>{if(n.strictRanges===!0)throw Of([e,t]);return[]},YR=(e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},XR=(e,t,n=1,r={})=>{let o=Number(e),s=Number(t);if(!Number.isInteger(o)||!Number.isInteger(s)){if(r.strictRanges===!0)throw Of([e,t]);return[]}o===0&&(o=0),s===0&&(s=0);let i=o>s,a=String(e),c=String(t),l=String(n);n=Math.max(Math.abs(n),1);let u=Ds(a)||Ds(c)||Ds(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&WR(e,t,r)===!1,p=r.transform||VR(f);if(r.toRegex&&n===1)return kf(Gr(e,d),Gr(t,d),!0,r);let g={negatives:[],positives:[]},S=O=>g[O<0?"negatives":"positives"].push(Math.abs(O)),A=[],b=0;for(;i?o>=s:o<=s;)r.toRegex===!0&&n>1?S(o):A.push(zR(p(o,b),d,f)),o=i?o-n:o+n,b++;return r.toRegex===!0?n>1?JR(g,r,d):xf(A,null,{wrap:!1,...r}):A},qR=(e,t,n=1,r={})=>{if(!hn(e)&&e.length>1||!hn(t)&&t.length>1)return If(e,t,r);let o=r.transform||(f=>String.fromCharCode(f)),s=`${e}`.charCodeAt(0),i=`${t}`.charCodeAt(0),a=s>i,c=Math.min(s,i),l=Math.max(s,i);if(r.toRegex&&n===1)return kf(c,l,!1,r);let u=[],d=0;for(;a?s>=i:s<=i;)u.push(o(s,d)),s=a?s-n:s+n,d++;return r.toRegex===!0?xf(u,null,{wrap:!1,options:r}):u},Kr=(e,t,n,r={})=>{if(t==null&&Us(e))return[e];if(!Us(e)||!Us(t))return If(e,t,r);if(typeof n=="function")return Kr(e,t,1,{transform:n});if(Af(n))return Kr(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,hn(n)?hn(e)&&hn(t)?XR(e,t,n,o):qR(e,t,Math.max(Math.abs(n),1),o):n!=null&&!Af(n)?YR(n,o):Kr(e,t,1,n)};Tf.exports=Kr});var Nf=z((NP,wf)=>{"use strict";var ZR=Fs(),Pf=jr(),QR=(e,t={})=>{let n=(r,o={})=>{let s=Pf.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a=s===!0||i===!0,c=t.escapeInvalid===!0?"\\":"",l="";if(r.isOpen===!0)return c+r.value;if(r.isClose===!0)return console.log("node.isClose",c,r.value),c+r.value;if(r.type==="open")return a?c+r.value:"(";if(r.type==="close")return a?c+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":a?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let u=Pf.reduce(r.nodes),d=ZR(...u,{...t,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return u.length>1&&d.length>1?`(${d})`:d}if(r.nodes)for(let u of r.nodes)l+=n(u,r);return l};return n(e)};wf.exports=QR});var Lf=z((vP,Mf)=>{"use strict";var eC=Fs(),vf=Br(),Ht=jr(),ht=(e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?Ht.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let s of o)r.push(ht(s,t,n));else for(let s of t)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?ht(o,s,n):o+s);return Ht.flatten(r)},tC=(e,t={})=>{let n=t.rangeLimit===void 0?1e3:t.rangeLimit,r=(o,s={})=>{o.queue=[];let i=s,a=s.queue;for(;i.type!=="brace"&&i.type!=="root"&&i.parent;)i=i.parent,a=i.queue;if(o.invalid||o.dollar){a.push(ht(a.pop(),vf(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){a.push(ht(a.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let d=Ht.reduce(o.nodes);if(Ht.exceedsLimit(...d,t.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=eC(...d,t);f.length===0&&(f=vf(o,t)),a.push(ht(a.pop(),f)),o.nodes=[];return}let c=Ht.encloseBrace(o),l=o.queue,u=o;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let d=0;d<o.nodes.length;d++){let f=o.nodes[d];if(f.type==="comma"&&o.type==="brace"){d===1&&l.push(""),l.push("");continue}if(f.type==="close"){a.push(ht(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(ht(l.pop(),f.value));continue}f.nodes&&r(f,o)}return l};return Ht.flatten(r(e))};Mf.exports=tC});var Uf=z((MP,Hf)=>{"use strict";Hf.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:`
14
- `,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 Bf=z((LP,jf)=>{"use strict";var nC=Br(),{MAX_LENGTH:Df,CHAR_BACKSLASH:$s,CHAR_BACKTICK:rC,CHAR_COMMA:oC,CHAR_DOT:sC,CHAR_LEFT_PARENTHESES:iC,CHAR_RIGHT_PARENTHESES:aC,CHAR_LEFT_CURLY_BRACE:cC,CHAR_RIGHT_CURLY_BRACE:uC,CHAR_LEFT_SQUARE_BRACKET:Ff,CHAR_RIGHT_SQUARE_BRACKET:$f,CHAR_DOUBLE_QUOTE:lC,CHAR_SINGLE_QUOTE:fC,CHAR_NO_BREAK_SPACE:dC,CHAR_ZERO_WIDTH_NOBREAK_SPACE:pC}=Uf(),mC=(e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Df,n.maxLength):Df;if(e.length>r)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${r})`);let o={type:"root",input:e,nodes:[]},s=[o],i=o,a=o,c=0,l=e.length,u=0,d=0,f,p=()=>e[u++],g=S=>{if(S.type==="text"&&a.type==="dot"&&(a.type="text"),a&&a.type==="text"&&S.type==="text"){a.value+=S.value;return}return i.nodes.push(S),S.parent=i,S.prev=a,a=S,S};for(g({type:"bos"});u<l;)if(i=s[s.length-1],f=p(),!(f===pC||f===dC)){if(f===$s){g({type:"text",value:(t.keepEscaping?f:"")+p()});continue}if(f===$f){g({type:"text",value:"\\"+f});continue}if(f===Ff){c++;let S;for(;u<l&&(S=p());){if(f+=S,S===Ff){c++;continue}if(S===$s){f+=p();continue}if(S===$f&&(c--,c===0))break}g({type:"text",value:f});continue}if(f===iC){i=g({type:"paren",nodes:[]}),s.push(i),g({type:"text",value:f});continue}if(f===aC){if(i.type!=="paren"){g({type:"text",value:f});continue}i=s.pop(),g({type:"text",value:f}),i=s[s.length-1];continue}if(f===lC||f===fC||f===rC){let S=f,A;for(t.keepQuotes!==!0&&(f="");u<l&&(A=p());){if(A===$s){f+=A+p();continue}if(A===S){t.keepQuotes===!0&&(f+=A);break}f+=A}g({type:"text",value:f});continue}if(f===cC){d++;let A={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||i.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};i=g(A),s.push(i),g({type:"open",value:f});continue}if(f===uC){if(i.type!=="brace"){g({type:"text",value:f});continue}let S="close";i=s.pop(),i.close=!0,g({type:S,value:f}),d--,i=s[s.length-1];continue}if(f===oC&&d>0){if(i.ranges>0){i.ranges=0;let S=i.nodes.shift();i.nodes=[S,{type:"text",value:nC(i)}]}g({type:"comma",value:f}),i.commas++;continue}if(f===sC&&d>0&&i.commas===0){let S=i.nodes;if(d===0||S.length===0){g({type:"text",value:f});continue}if(a.type==="dot"){if(i.range=[],a.value+=f,a.type="range",i.nodes.length!==3&&i.nodes.length!==5){i.invalid=!0,i.ranges=0,a.type="text";continue}i.ranges++,i.args=[];continue}if(a.type==="range"){S.pop();let A=S[S.length-1];A.value+=a.value+f,a=A,i.ranges--;continue}g({type:"dot",value:f});continue}g({type:"text",value:f})}do if(i=s.pop(),i.type!=="root"){i.nodes.forEach(b=>{b.nodes||(b.type==="open"&&(b.isOpen=!0),b.type==="close"&&(b.isClose=!0),b.nodes||(b.type="text"),b.invalid=!0)});let S=s[s.length-1],A=S.nodes.indexOf(i);S.nodes.splice(A,1,...i.nodes)}while(s.length>0);return g({type:"eos"}),o};jf.exports=mC});var Vf=z((HP,Gf)=>{"use strict";var Kf=Br(),gC=Nf(),_C=Lf(),hC=Bf(),_e=(e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=_e.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(_e.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n};_e.parse=(e,t={})=>hC(e,t);_e.stringify=(e,t={})=>Kf(typeof e=="string"?_e.parse(e,t):e,t);_e.compile=(e,t={})=>(typeof e=="string"&&(e=_e.parse(e,t)),gC(e,t));_e.expand=(e,t={})=>{typeof e=="string"&&(e=_e.parse(e,t));let n=_C(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};_e.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?_e.compile(e,t):_e.expand(e,t);Gf.exports=_e});var Sn=z((UP,Xf)=>{"use strict";var SC=Xe("path"),ve="\\\\/",Wf=`[^${ve}]`,EC=0,Je="\\.",yC="\\+",RC="\\?",Vr="\\/",CC="(?=.)",zf="[^/]",js=`(?:${Vr}|$)`,Jf=`(?:^|${Vr})`,Bs=`${Je}{1,2}${js}`,AC=`(?!${Je})`,bC=`(?!${Jf}${Bs})`,kC=`(?!${Je}{0,1}${js})`,xC=`(?!${Bs})`,OC=`[^.${Vr}]`,IC=`${zf}*?`,Yf={DOT_LITERAL:Je,PLUS_LITERAL:yC,QMARK_LITERAL:RC,SLASH_LITERAL:Vr,ONE_CHAR:CC,QMARK:zf,END_ANCHOR:js,DOTS_SLASH:Bs,NO_DOT:AC,NO_DOTS:bC,NO_DOT_SLASH:kC,NO_DOTS_SLASH:xC,QMARK_NO_DOT:OC,STAR:IC,START_ANCHOR:Jf},TC={...Yf,SLASH_LITERAL:`[${ve}]`,QMARK:Wf,STAR:`${Wf}*?`,DOTS_SLASH:`${Je}{1,2}(?:[${ve}]|$)`,NO_DOT:`(?!${Je})`,NO_DOTS:`(?!(?:^|[${ve}])${Je}{1,2}(?:[${ve}]|$))`,NO_DOT_SLASH:`(?!${Je}{0,1}(?:[${ve}]|$))`,NO_DOTS_SLASH:`(?!${Je}{1,2}(?:[${ve}]|$))`,QMARK_NO_DOT:`[^.${ve}]`,START_ANCHOR:`(?:^|[${ve}])`,END_ANCHOR:`(?:[${ve}]|$)`},PC={__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"};Xf.exports={DEFAULT_MAX_EXTGLOB_RECURSION:EC,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:PC,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:SC.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?TC:Yf}}});var En=z(le=>{"use strict";var wC=Xe("path"),NC=process.platform==="win32",{REGEX_BACKSLASH:vC,REGEX_REMOVE_BACKSLASH:MC,REGEX_SPECIAL_CHARS:LC,REGEX_SPECIAL_CHARS_GLOBAL:HC}=Sn();le.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);le.hasRegexChars=e=>LC.test(e);le.isRegexChar=e=>e.length===1&&le.hasRegexChars(e);le.escapeRegex=e=>e.replace(HC,"\\$1");le.toPosixSlashes=e=>e.replace(vC,"/");le.removeBackslashes=e=>e.replace(MC,t=>t==="\\"?"":t);le.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};le.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:NC===!0||wC.sep==="\\";le.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?le.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};le.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};le.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",s=`${r}(?:${e})${o}`;return t.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var od=z((FP,rd)=>{"use strict";var qf=En(),{CHAR_ASTERISK:Ks,CHAR_AT:UC,CHAR_BACKWARD_SLASH:yn,CHAR_COMMA:DC,CHAR_DOT:Gs,CHAR_EXCLAMATION_MARK:Vs,CHAR_FORWARD_SLASH:nd,CHAR_LEFT_CURLY_BRACE:Ws,CHAR_LEFT_PARENTHESES:zs,CHAR_LEFT_SQUARE_BRACKET:FC,CHAR_PLUS:$C,CHAR_QUESTION_MARK:Zf,CHAR_RIGHT_CURLY_BRACE:jC,CHAR_RIGHT_PARENTHESES:Qf,CHAR_RIGHT_SQUARE_BRACKET:BC}=Sn(),ed=e=>e===nd||e===yn,td=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},KC=(e,t)=>{let n=t||{},r=e.length-1,o=n.parts===!0||n.scanToEnd===!0,s=[],i=[],a=[],c=e,l=-1,u=0,d=0,f=!1,p=!1,g=!1,S=!1,A=!1,b=!1,O=!1,P=!1,I=!1,T=!1,K=0,D,x,N={value:"",depth:0,isGlob:!1},H=()=>l>=r,m=()=>c.charCodeAt(l+1),k=()=>(D=x,c.charCodeAt(++l));for(;l<r;){x=k();let ie;if(x===yn){O=N.backslashes=!0,x=k(),x===Ws&&(b=!0);continue}if(b===!0||x===Ws){for(K++;H()!==!0&&(x=k());){if(x===yn){O=N.backslashes=!0,k();continue}if(x===Ws){K++;continue}if(b!==!0&&x===Gs&&(x=k())===Gs){if(f=N.isBrace=!0,g=N.isGlob=!0,T=!0,o===!0)continue;break}if(b!==!0&&x===DC){if(f=N.isBrace=!0,g=N.isGlob=!0,T=!0,o===!0)continue;break}if(x===jC&&(K--,K===0)){b=!1,f=N.isBrace=!0,T=!0;break}}if(o===!0)continue;break}if(x===nd){if(s.push(l),i.push(N),N={value:"",depth:0,isGlob:!1},T===!0)continue;if(D===Gs&&l===u+1){u+=2;continue}d=l+1;continue}if(n.noext!==!0&&(x===$C||x===UC||x===Ks||x===Zf||x===Vs)===!0&&m()===zs){if(g=N.isGlob=!0,S=N.isExtglob=!0,T=!0,x===Vs&&l===u&&(I=!0),o===!0){for(;H()!==!0&&(x=k());){if(x===yn){O=N.backslashes=!0,x=k();continue}if(x===Qf){g=N.isGlob=!0,T=!0;break}}continue}break}if(x===Ks){if(D===Ks&&(A=N.isGlobstar=!0),g=N.isGlob=!0,T=!0,o===!0)continue;break}if(x===Zf){if(g=N.isGlob=!0,T=!0,o===!0)continue;break}if(x===FC){for(;H()!==!0&&(ie=k());){if(ie===yn){O=N.backslashes=!0,k();continue}if(ie===BC){p=N.isBracket=!0,g=N.isGlob=!0,T=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&x===Vs&&l===u){P=N.negated=!0,u++;continue}if(n.noparen!==!0&&x===zs){if(g=N.isGlob=!0,o===!0){for(;H()!==!0&&(x=k());){if(x===zs){O=N.backslashes=!0,x=k();continue}if(x===Qf){T=!0;break}}continue}break}if(g===!0){if(T=!0,o===!0)continue;break}}n.noext===!0&&(S=!1,g=!1);let U=c,de="",_="";u>0&&(de=c.slice(0,u),c=c.slice(u),d-=u),U&&g===!0&&d>0?(U=c.slice(0,d),_=c.slice(d)):g===!0?(U="",_=c):U=c,U&&U!==""&&U!=="/"&&U!==c&&ed(U.charCodeAt(U.length-1))&&(U=U.slice(0,-1)),n.unescape===!0&&(_&&(_=qf.removeBackslashes(_)),U&&O===!0&&(U=qf.removeBackslashes(U)));let h={prefix:de,input:e,start:u,base:U,glob:_,isBrace:f,isBracket:p,isGlob:g,isExtglob:S,isGlobstar:A,negated:P,negatedExtglob:I};if(n.tokens===!0&&(h.maxDepth=0,ed(x)||i.push(N),h.tokens=i),n.parts===!0||n.tokens===!0){let ie;for(let F=0;F<s.length;F++){let ke=ie?ie+1:u,xe=s[F],pe=e.slice(ke,xe);n.tokens&&(F===0&&u!==0?(i[F].isPrefix=!0,i[F].value=de):i[F].value=pe,td(i[F]),h.maxDepth+=i[F].depth),(F!==0||pe!=="")&&a.push(pe),ie=xe}if(ie&&ie+1<e.length){let F=e.slice(ie+1);a.push(F),n.tokens&&(i[i.length-1].value=F,td(i[i.length-1]),h.maxDepth+=i[i.length-1].depth)}h.slashes=s,h.parts=a}return h};rd.exports=KC});var ud=z(($P,cd)=>{"use strict";var Rn=Sn(),se=En(),{MAX_LENGTH:Wr,POSIX_REGEX_SOURCE:GC,REGEX_NON_SPECIAL_CHARS:VC,REGEX_SPECIAL_CHARS_BACKREF:WC,REPLACEMENTS:sd}=Rn,zC=(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=>se.escapeRegex(o)).join("..")}return n},Ut=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,id=e=>{let t=[],n=0,r=0,o=0,s="",i=!1;for(let a of e){if(i===!0){s+=a,i=!1;continue}if(a==="\\"){s+=a,i=!0;continue}if(a==='"'){o=o===1?0:1,s+=a;continue}if(o===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")r++;else if(a===")"&&r>0)r--;else if(a==="|"&&r===0){t.push(s),s="";continue}}}s+=a}return t.push(s),t},JC=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},ad=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(JC(t))return t.replace(/\\(.)/g,"$1")},YC=e=>{let t=e.map(ad).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let o=t[n],s=t[r],i=o[0];if(!(!i||o!==i.repeat(o.length)||s!==i.repeat(s.length))&&(o===s||o.startsWith(s)||s.startsWith(o)))return!0}return!1},Js=(e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,r=0,o=0,s=!1;for(let i=1;i<e.length;i++){let a=e[i];if(s===!0){s=!1;continue}if(a==="\\"){s=!0;continue}if(a==='"'){o=o===1?0:1;continue}if(o!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){r++;continue}if(a===")"&&(r--,r===0))return t===!0&&i!==e.length-1?void 0:{type:e[0],body:e.slice(2,i),end:i}}}}},XC=e=>{let t=0,n=[];for(;t<e.length;){let o=Js(e.slice(t),!1);if(!o||o.type!=="*")return;let s=id(o.body).map(a=>a.trim());if(s.length!==1)return;let i=ad(s[0]);if(!i||i.length!==1)return;n.push(i),t+=o.end+1}return n.length<1?void 0:`${n.length===1?se.escapeRegex(n[0]):`[${n.map(o=>se.escapeRegex(o)).join("")}]`}*`},qC=e=>{let t=0,n=e.trim(),r=Js(n);for(;r;)t++,n=r.body.trim(),r=Js(n);return t},ZC=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:Rn.DEFAULT_MAX_EXTGLOB_RECURSION,r=id(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||YC(r)))return{risky:!0};for(let o of r){let s=XC(o);if(s)return{risky:!0,safeOutput:s};if(qC(o)>n)return{risky:!0}}return{risky:!1}},Ys=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=sd[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(Wr,n.maxLength):Wr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},i=[s],a=n.capture?"":"?:",c=se.isWindows(t),l=Rn.globChars(c),u=Rn.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,SLASH_LITERAL:p,ONE_CHAR:g,DOTS_SLASH:S,NO_DOT:A,NO_DOT_SLASH:b,NO_DOTS_SLASH:O,QMARK:P,QMARK_NO_DOT:I,STAR:T,START_ANCHOR:K}=l,D=C=>`(${a}(?:(?!${K}${C.dot?S:d}).)*?)`,x=n.dot?"":A,N=n.dot?P:I,H=n.bash===!0?D(n):T;n.capture&&(H=`(${H})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let m={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:i};e=se.removePrefix(e,m),o=e.length;let k=[],U=[],de=[],_=s,h,ie=()=>m.index===o-1,F=m.peek=(C=1)=>e[m.index+C],ke=m.advance=()=>e[++m.index]||"",xe=()=>e.slice(m.index+1),pe=(C="",Y=0)=>{m.consumed+=C,m.index+=Y},Mn=C=>{m.output+=C.output!=null?C.output:C.value,pe(C.value)},mm=()=>{let C=1;for(;F()==="!"&&(F(2)!=="("||F(3)==="?");)ke(),m.start++,C++;return C%2===0?!1:(m.negated=!0,m.start++,!0)},Ln=C=>{m[C]++,de.push(C)},Ye=C=>{m[C]--,de.pop()},v=C=>{if(_.type==="globstar"){let Y=m.braces>0&&(C.type==="comma"||C.type==="brace"),R=C.extglob===!0||k.length&&(C.type==="pipe"||C.type==="paren");C.type!=="slash"&&C.type!=="paren"&&!Y&&!R&&(m.output=m.output.slice(0,-_.output.length),_.type="star",_.value="*",_.output=H,m.output+=_.output)}if(k.length&&C.type!=="paren"&&(k[k.length-1].inner+=C.value),(C.value||C.output)&&Mn(C),_&&_.type==="text"&&C.type==="text"){_.value+=C.value,_.output=(_.output||"")+C.value;return}C.prev=_,i.push(C),_=C},Hn=(C,Y)=>{let R={...u[Y],conditions:1,inner:""};R.prev=_,R.parens=m.parens,R.output=m.output,R.startIndex=m.index,R.tokensIndex=i.length;let w=(n.capture?"(":"")+R.open;Ln("parens"),v({type:C,value:Y,output:m.output?"":g}),v({type:"paren",extglob:!0,value:ke(),output:w}),k.push(R)},gm=C=>{let Y=e.slice(C.startIndex,m.index+1),R=e.slice(C.startIndex+2,m.index),w=ZC(R,n);if((C.type==="plus"||C.type==="star")&&w.risky){let G=w.safeOutput?(C.output?"":g)+(n.capture?`(${w.safeOutput})`:w.safeOutput):void 0,Oe=i[C.tokensIndex];Oe.type="text",Oe.value=Y,Oe.output=G||se.escapeRegex(Y);for(let Ie=C.tokensIndex+1;Ie<i.length;Ie++)i[Ie].value="",i[Ie].output="",delete i[Ie].suffix;m.output=C.output+Oe.output,m.backtrack=!0,v({type:"paren",extglob:!0,value:h,output:""}),Ye("parens");return}let W=C.close+(n.capture?")":""),oe;if(C.type==="negate"){let G=H;if(C.inner&&C.inner.length>1&&C.inner.includes("/")&&(G=D(n)),(G!==H||ie()||/^\)+$/.test(xe()))&&(W=C.close=`)$))${G}`),C.inner.includes("*")&&(oe=xe())&&/^\.[^\\/.]+$/.test(oe)){let Oe=Ys(oe,{...t,fastpaths:!1}).output;W=C.close=`)${Oe})${G})`}C.prev.type==="bos"&&(m.negatedExtglob=!0)}v({type:"paren",extglob:!0,value:h,output:W}),Ye("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let C=!1,Y=e.replace(WC,(R,w,W,oe,G,Oe)=>oe==="\\"?(C=!0,R):oe==="?"?w?w+oe+(G?P.repeat(G.length):""):Oe===0?N+(G?P.repeat(G.length):""):P.repeat(W.length):oe==="."?d.repeat(W.length):oe==="*"?w?w+oe+(G?H:""):H:w?R:`\\${R}`);return C===!0&&(n.unescape===!0?Y=Y.replace(/\\/g,""):Y=Y.replace(/\\+/g,R=>R.length%2===0?"\\\\":R?"\\":"")),Y===e&&n.contains===!0?(m.output=e,m):(m.output=se.wrapOutput(Y,m,t),m)}for(;!ie();){if(h=ke(),h==="\0")continue;if(h==="\\"){let R=F();if(R==="/"&&n.bash!==!0||R==="."||R===";")continue;if(!R){h+="\\",v({type:"text",value:h});continue}let w=/^\\+/.exec(xe()),W=0;if(w&&w[0].length>2&&(W=w[0].length,m.index+=W,W%2!==0&&(h+="\\")),n.unescape===!0?h=ke():h+=ke(),m.brackets===0){v({type:"text",value:h});continue}}if(m.brackets>0&&(h!=="]"||_.value==="["||_.value==="[^")){if(n.posix!==!1&&h===":"){let R=_.value.slice(1);if(R.includes("[")&&(_.posix=!0,R.includes(":"))){let w=_.value.lastIndexOf("["),W=_.value.slice(0,w),oe=_.value.slice(w+2),G=GC[oe];if(G){_.value=W+G,m.backtrack=!0,ke(),!s.output&&i.indexOf(_)===1&&(s.output=g);continue}}}(h==="["&&F()!==":"||h==="-"&&F()==="]")&&(h=`\\${h}`),h==="]"&&(_.value==="["||_.value==="[^")&&(h=`\\${h}`),n.posix===!0&&h==="!"&&_.value==="["&&(h="^"),_.value+=h,Mn({value:h});continue}if(m.quotes===1&&h!=='"'){h=se.escapeRegex(h),_.value+=h,Mn({value:h});continue}if(h==='"'){m.quotes=m.quotes===1?0:1,n.keepQuotes===!0&&v({type:"text",value:h});continue}if(h==="("){Ln("parens"),v({type:"paren",value:h});continue}if(h===")"){if(m.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Ut("opening","("));let R=k[k.length-1];if(R&&m.parens===R.parens+1){gm(k.pop());continue}v({type:"paren",value:h,output:m.parens?")":"\\)"}),Ye("parens");continue}if(h==="["){if(n.nobracket===!0||!xe().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Ut("closing","]"));h=`\\${h}`}else Ln("brackets");v({type:"bracket",value:h});continue}if(h==="]"){if(n.nobracket===!0||_&&_.type==="bracket"&&_.value.length===1){v({type:"text",value:h,output:`\\${h}`});continue}if(m.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Ut("opening","["));v({type:"text",value:h,output:`\\${h}`});continue}Ye("brackets");let R=_.value.slice(1);if(_.posix!==!0&&R[0]==="^"&&!R.includes("/")&&(h=`/${h}`),_.value+=h,Mn({value:h}),n.literalBrackets===!1||se.hasRegexChars(R))continue;let w=se.escapeRegex(_.value);if(m.output=m.output.slice(0,-_.value.length),n.literalBrackets===!0){m.output+=w,_.value=w;continue}_.value=`(${a}${w}|${_.value})`,m.output+=_.value;continue}if(h==="{"&&n.nobrace!==!0){Ln("braces");let R={type:"brace",value:h,output:"(",outputIndex:m.output.length,tokensIndex:m.tokens.length};U.push(R),v(R);continue}if(h==="}"){let R=U[U.length-1];if(n.nobrace===!0||!R){v({type:"text",value:h,output:h});continue}let w=")";if(R.dots===!0){let W=i.slice(),oe=[];for(let G=W.length-1;G>=0&&(i.pop(),W[G].type!=="brace");G--)W[G].type!=="dots"&&oe.unshift(W[G].value);w=zC(oe,n),m.backtrack=!0}if(R.comma!==!0&&R.dots!==!0){let W=m.output.slice(0,R.outputIndex),oe=m.tokens.slice(R.tokensIndex);R.value=R.output="\\{",h=w="\\}",m.output=W;for(let G of oe)m.output+=G.output||G.value}v({type:"brace",value:h,output:w}),Ye("braces"),U.pop();continue}if(h==="|"){k.length>0&&k[k.length-1].conditions++,v({type:"text",value:h});continue}if(h===","){let R=h,w=U[U.length-1];w&&de[de.length-1]==="braces"&&(w.comma=!0,R="|"),v({type:"comma",value:h,output:R});continue}if(h==="/"){if(_.type==="dot"&&m.index===m.start+1){m.start=m.index+1,m.consumed="",m.output="",i.pop(),_=s;continue}v({type:"slash",value:h,output:p});continue}if(h==="."){if(m.braces>0&&_.type==="dot"){_.value==="."&&(_.output=d);let R=U[U.length-1];_.type="dots",_.output+=h,_.value+=h,R.dots=!0;continue}if(m.braces+m.parens===0&&_.type!=="bos"&&_.type!=="slash"){v({type:"text",value:h,output:d});continue}v({type:"dot",value:h,output:d});continue}if(h==="?"){if(!(_&&_.value==="(")&&n.noextglob!==!0&&F()==="("&&F(2)!=="?"){Hn("qmark",h);continue}if(_&&_.type==="paren"){let w=F(),W=h;if(w==="<"&&!se.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(_.value==="("&&!/[!=<:]/.test(w)||w==="<"&&!/<([!=]|\w+>)/.test(xe()))&&(W=`\\${h}`),v({type:"text",value:h,output:W});continue}if(n.dot!==!0&&(_.type==="slash"||_.type==="bos")){v({type:"qmark",value:h,output:I});continue}v({type:"qmark",value:h,output:P});continue}if(h==="!"){if(n.noextglob!==!0&&F()==="("&&(F(2)!=="?"||!/[!=<:]/.test(F(3)))){Hn("negate",h);continue}if(n.nonegate!==!0&&m.index===0){mm();continue}}if(h==="+"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){Hn("plus",h);continue}if(_&&_.value==="("||n.regex===!1){v({type:"plus",value:h,output:f});continue}if(_&&(_.type==="bracket"||_.type==="paren"||_.type==="brace")||m.parens>0){v({type:"plus",value:h});continue}v({type:"plus",value:f});continue}if(h==="@"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){v({type:"at",extglob:!0,value:h,output:""});continue}v({type:"text",value:h});continue}if(h!=="*"){(h==="$"||h==="^")&&(h=`\\${h}`);let R=VC.exec(xe());R&&(h+=R[0],m.index+=R[0].length),v({type:"text",value:h});continue}if(_&&(_.type==="globstar"||_.star===!0)){_.type="star",_.star=!0,_.value+=h,_.output=H,m.backtrack=!0,m.globstar=!0,pe(h);continue}let C=xe();if(n.noextglob!==!0&&/^\([^?]/.test(C)){Hn("star",h);continue}if(_.type==="star"){if(n.noglobstar===!0){pe(h);continue}let R=_.prev,w=R.prev,W=R.type==="slash"||R.type==="bos",oe=w&&(w.type==="star"||w.type==="globstar");if(n.bash===!0&&(!W||C[0]&&C[0]!=="/")){v({type:"star",value:h,output:""});continue}let G=m.braces>0&&(R.type==="comma"||R.type==="brace"),Oe=k.length&&(R.type==="pipe"||R.type==="paren");if(!W&&R.type!=="paren"&&!G&&!Oe){v({type:"star",value:h,output:""});continue}for(;C.slice(0,3)==="/**";){let Ie=e[m.index+4];if(Ie&&Ie!=="/")break;C=C.slice(3),pe("/**",3)}if(R.type==="bos"&&ie()){_.type="globstar",_.value+=h,_.output=D(n),m.output=_.output,m.globstar=!0,pe(h);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&!oe&&ie()){m.output=m.output.slice(0,-(R.output+_.output).length),R.output=`(?:${R.output}`,_.type="globstar",_.output=D(n)+(n.strictSlashes?")":"|$)"),_.value+=h,m.globstar=!0,m.output+=R.output+_.output,pe(h);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&C[0]==="/"){let Ie=C[1]!==void 0?"|$":"";m.output=m.output.slice(0,-(R.output+_.output).length),R.output=`(?:${R.output}`,_.type="globstar",_.output=`${D(n)}${p}|${p}${Ie})`,_.value+=h,m.output+=R.output+_.output,m.globstar=!0,pe(h+ke()),v({type:"slash",value:"/",output:""});continue}if(R.type==="bos"&&C[0]==="/"){_.type="globstar",_.value+=h,_.output=`(?:^|${p}|${D(n)}${p})`,m.output=_.output,m.globstar=!0,pe(h+ke()),v({type:"slash",value:"/",output:""});continue}m.output=m.output.slice(0,-_.output.length),_.type="globstar",_.output=D(n),_.value+=h,m.output+=_.output,m.globstar=!0,pe(h);continue}let Y={type:"star",value:h,output:H};if(n.bash===!0){Y.output=".*?",(_.type==="bos"||_.type==="slash")&&(Y.output=x+Y.output),v(Y);continue}if(_&&(_.type==="bracket"||_.type==="paren")&&n.regex===!0){Y.output=h,v(Y);continue}(m.index===m.start||_.type==="slash"||_.type==="dot")&&(_.type==="dot"?(m.output+=b,_.output+=b):n.dot===!0?(m.output+=O,_.output+=O):(m.output+=x,_.output+=x),F()!=="*"&&(m.output+=g,_.output+=g)),v(Y)}for(;m.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ut("closing","]"));m.output=se.escapeLast(m.output,"["),Ye("brackets")}for(;m.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ut("closing",")"));m.output=se.escapeLast(m.output,"("),Ye("parens")}for(;m.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ut("closing","}"));m.output=se.escapeLast(m.output,"{"),Ye("braces")}if(n.strictSlashes!==!0&&(_.type==="star"||_.type==="bracket")&&v({type:"maybe_slash",value:"",output:`${p}?`}),m.backtrack===!0){m.output="";for(let C of m.tokens)m.output+=C.output!=null?C.output:C.value,C.suffix&&(m.output+=C.suffix)}return m};Ys.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(Wr,n.maxLength):Wr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=sd[e]||e;let s=se.isWindows(t),{DOT_LITERAL:i,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:d,NO_DOTS_SLASH:f,STAR:p,START_ANCHOR:g}=Rn.globChars(s),S=n.dot?d:u,A=n.dot?f:u,b=n.capture?"":"?:",O={negated:!1,prefix:""},P=n.bash===!0?".*?":p;n.capture&&(P=`(${P})`);let I=x=>x.noglobstar===!0?P:`(${b}(?:(?!${g}${x.dot?l:i}).)*?)`,T=x=>{switch(x){case"*":return`${S}${c}${P}`;case".*":return`${i}${c}${P}`;case"*.*":return`${S}${P}${i}${c}${P}`;case"*/*":return`${S}${P}${a}${c}${A}${P}`;case"**":return S+I(n);case"**/*":return`(?:${S}${I(n)}${a})?${A}${c}${P}`;case"**/*.*":return`(?:${S}${I(n)}${a})?${A}${P}${i}${c}${P}`;case"**/.*":return`(?:${S}${I(n)}${a})?${i}${c}${P}`;default:{let N=/^(.*?)\.(\w+)$/.exec(x);if(!N)return;let H=T(N[1]);return H?H+i+N[2]:void 0}}},K=se.removePrefix(e,O),D=T(K);return D&&n.strictSlashes!==!0&&(D+=`${a}?`),D};cd.exports=Ys});var fd=z((jP,ld)=>{"use strict";var QC=Xe("path"),eA=od(),Xs=ud(),qs=En(),tA=Sn(),nA=e=>e&&typeof e=="object"&&!Array.isArray(e),te=(e,t,n=!1)=>{if(Array.isArray(e)){let u=e.map(f=>te(f,t,n));return f=>{for(let p of u){let g=p(f);if(g)return g}return!1}}let r=nA(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||{},s=qs.isWindows(t),i=r?te.compileRe(e,t):te.makeRe(e,t,!1,!0),a=i.state;delete i.state;let c=()=>!1;if(o.ignore){let u={...t,ignore:null,onMatch:null,onResult:null};c=te(o.ignore,u,n)}let l=(u,d=!1)=>{let{isMatch:f,match:p,output:g}=te.test(u,i,t,{glob:e,posix:s}),S={glob:e,state:a,regex:i,posix:s,input:u,output:g,match:p,isMatch:f};return typeof o.onResult=="function"&&o.onResult(S),f===!1?(S.isMatch=!1,d?S:!1):c(u)?(typeof o.onIgnore=="function"&&o.onIgnore(S),S.isMatch=!1,d?S:!1):(typeof o.onMatch=="function"&&o.onMatch(S),d?S:!0)};return n&&(l.state=a),l};te.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 s=n||{},i=s.format||(o?qs.toPosixSlashes:null),a=e===r,c=a&&i?i(e):e;return a===!1&&(c=i?i(e):e,a=c===r),(a===!1||s.capture===!0)&&(s.matchBase===!0||s.basename===!0?a=te.matchBase(e,t,n,o):a=t.exec(c)),{isMatch:!!a,match:a,output:c}};te.matchBase=(e,t,n,r=qs.isWindows(n))=>(t instanceof RegExp?t:te.makeRe(t,n)).test(QC.basename(e));te.isMatch=(e,t,n)=>te(t,n)(e);te.parse=(e,t)=>Array.isArray(e)?e.map(n=>te.parse(n,t)):Xs(e,{...t,fastpaths:!1});te.scan=(e,t)=>eA(e,t);te.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let o=t||{},s=o.contains?"":"^",i=o.contains?"":"$",a=`${s}(?:${e.output})${i}`;e&&e.negated===!0&&(a=`^(?!${a}).*$`);let c=te.toRegex(a,t);return r===!0&&(c.state=e),c};te.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=Xs.fastpaths(e,t)),o.output||(o=Xs(e,t)),te.compileRe(o,t,n,r)};te.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/$^/}};te.constants=tA;ld.exports=te});var pd=z((BP,dd)=>{"use strict";dd.exports=fd()});var Ed=z((KP,Sd)=>{"use strict";var gd=Xe("util"),_d=Vf(),Me=pd(),Zs=En(),md=e=>e===""||e==="./",hd=e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},J=(e,t,n)=>{t=[].concat(t),e=[].concat(e);let r=new Set,o=new Set,s=new Set,i=0,a=u=>{s.add(u.output),n&&n.onResult&&n.onResult(u)};for(let u=0;u<t.length;u++){let d=Me(String(t[u]),{...n,onResult:a},!0),f=d.state.negated||d.state.negatedExtglob;f&&i++;for(let p of e){let g=d(p,!0);(f?!g.isMatch:g.isMatch)&&(f?r.add(g.output):(r.delete(g.output),o.add(g.output)))}}let l=(i===t.length?[...s]:[...o]).filter(u=>!r.has(u));if(n&&l.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(u=>u.replace(/\\/g,"")):t}return l};J.match=J;J.matcher=(e,t)=>Me(e,t);J.isMatch=(e,t,n)=>Me(t,n)(e);J.any=J.isMatch;J.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],s=a=>{n.onResult&&n.onResult(a),o.push(a.output)},i=new Set(J(e,t,{...n,onResult:s}));for(let a of o)i.has(a)||r.add(a);return[...r]};J.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${gd.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>J.contains(e,r,n));if(typeof t=="string"){if(md(e)||md(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return J.isMatch(e,t,{...n,contains:!0})};J.matchKeys=(e,t,n)=>{if(!Zs.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=J(Object.keys(e),t,n),o={};for(let s of r)o[s]=e[s];return o};J.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Me(String(o),n);if(r.some(i=>s(i)))return!0}return!1};J.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Me(String(o),n);if(!r.every(i=>s(i)))return!1}return!0};J.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${gd.inspect(e)}"`);return[].concat(t).every(r=>Me(r,n)(e))};J.capture=(e,t,n)=>{let r=Zs.isWindows(n),s=Me.makeRe(String(e),{...n,capture:!0}).exec(r?Zs.toPosixSlashes(t):t);if(s)return s.slice(1).map(i=>i===void 0?"":i)};J.makeRe=(...e)=>Me.makeRe(...e);J.scan=(...e)=>Me.scan(...e);J.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of _d(String(r),t))n.push(Me.parse(o,t));return n};J.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!hd(e)?[e]:_d(e,t)};J.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return J.braces(e,{...t,expand:!0})};J.hasBraces=hd;Sd.exports=J});import{realpathSync as ax}from"node:fs";import{resolve as cx}from"node:path";import{fileURLToPath as ux,pathToFileURL as lx}from"node:url";import{createHash as Bm}from"node:crypto";import{homedir as Km}from"node:os";import{dirname as Dx,join as Gm,parse as Fx,resolve as $x}from"node:path";var Di="EV_AI_LAUNCHER_VERSION";var Fi="EV_AI_HOOK_SOURCE",$i="EV_AI_HOOK_FALLBACK_REASON",ji="EV_AI_LAUNCHER_SCOPE",lo="EV_AI_LAUNCHER_READY_FD";var Bi="--defer-user-spec",Un="--cap",Vt="--slot";var Ki=Buffer.from([1]);var mx=1024*1024,gx=4*1024*1024,_x=64*1024,hx=64*1024,Sx=64*1024;var fo=4096,Ex=4*1024*1024;import{join as Yi}from"node:path";import{open as Gi,mkdir as Cm,readFile as Am,readdir as bm,rename as km,stat as xm,rmdir as Om,unlink as Im,utimes as Tm}from"node:fs/promises";var Dn=new WeakMap;function Wi(e){if(e&&typeof e=="object"&&"code"in e)return e}function bt(e){return Wi(e)?.code==="ENOENT"}function Wt(e){return Wi(e)?.code==="EEXIST"}async function zi(e,t){try{return await e.readdir(t)}catch(n){if(bt(n))return[];throw n}}function Ji(){return{async open(e,t){let n=await Gi(e,t),r={path:e};return Dn.set(r,n),r},async write(e,t){let n=Vi(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await Vi(e).sync()},async close(e){let t=Dn.get(e);Dn.delete(e),t&&await t.close()},rename:km,async readdir(e){return bm(e)},readFile:Am,async stat(e){let t=await xm(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:()=>t.isDirectory()}},async mkdir(e,t){await Cm(e,t)},unlink:Im,rmdir:Om,utimes:Tm,async fsyncDir(e){if(process.platform==="win32")return;let t=await Gi(e,"r");try{await t.sync()}finally{await t.close()}}}}function Vi(e){let t=Dn.get(e);if(!t)throw new Error("closed");return t}var Xi=4,qi=10;function Fn(e=process.platform){return e==="win32"?Xi:qi}var $n=6e4,zt=2e3,Zi="slots",po=64;function Qi(e){return Yi(e,".ev-ai","agent-hook",Zi)}function jn(e,t){return Yi(e,`slot-${t}`)}function Bn(e,t){return`${e}
11
+ `).trimEnd();return(0,be.usableCatalogText)(f)}});var Ou=z(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=ee.COMPONENT_INSPECTION_TEXT_MAX_BYTES=ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=void 0;ee.fitSnapshotInspectionTextBudget=zS;ee.capComponentTextBytes=xu;ee.prepareComponentInspectionText=JS;ee.redactComponentSource=es;ee.componentSourceContainsRedactableSecret=tE;ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";ee.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;ee.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function zS(e){let t=0;return e.map(n=>{let r=n,o=r.skill?.inspectionText;if(o===void 0)return n;let s=Buffer.byteLength(o,"utf8");return t+s<=ee.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES?(t+=s,n):{...n,skill:{...r.skill,inspectionText:void 0}}})}function xu(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{}}function JS(e){if(!(e==null||e.length===0))return xu(es(e),ee.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}var YS=[/\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],XS=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,qS=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,ZS=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,QS=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,ku=/-----END [A-Z0-9 ]*PRIVATE KEY-----/;function eE(e){let t=e.replace(qS,(n,r)=>`${r}${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(ZS,(n,r)=>`${r}${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(XS,(n,r)=>`${r}${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of YS)t=t.replace(n,ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}function es(e){if(e.length===0)return e;let t=e.split(`
12
+ `),n=!1;return t.map(o=>n?ku.test(o)?(n=!1,o):o.trim().length===0?o:ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:QS.test(o)&&!ku.test(o)?(n=!0,o):eE(o)).join(`
13
+ `)}function tE(e){return es(e)!==e}});var lt=z(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.redactComponentSource=y.prepareComponentInspectionText=y.fitSnapshotInspectionTextBudget=y.componentSourceContainsRedactableSecret=y.capComponentTextBytes=y.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=y.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=y.COMPONENT_INSPECTION_TEXT_MAX_BYTES=y.usableCatalogText=y.parseFrontmatterField=y.parseFrontmatterDescription=y.mcpServerToolSegmentForms=y.mcpServerNameMatchesToolSegment=y.isNpmRegistryPublisher=y.EMPTY_NPM_PUBLISHER=y.displayPublisherName=y.classifyMcpProvenance=y.resolveMcpPackageIdentity=y.McpPackageEcosystem=y.pinnedPackageVersionFromSpec=y.pinnedPackageVersionFromNpx=y.packageNameFromSpec=y.npxPackageSpecs=y.npxExecBin=y.PACKAGE_FIELD_MAX=y.serializeMcpLaunchIdentity=y.projectMcpMissingLaunchIdentity=y.projectMcpLaunchIdentity=y.normalizeMcpToolNames=y.MCP_MISSING_LAUNCH_SERIALIZED=y.MCP_LAUNCH_IDENTITY_ALGORITHM=y.maskMcpLaunchForDisplay=y.launchContainsCredentials=y.hashMcpLaunchIdentity=y.foldMcpName=y.buildMcpFamilyCanonicalKey=y.ComponentKind=void 0;y.userConfigRootFromPath=fE;y.installationRootExternalKey=dE;y.normalizeRepositoryRelativePath=Iu;y.nativeKeyForSkillPath=pE;y.nativeKeyForRulePath=mE;y.nativeKeyForCommandPath=gE;y.serializeComponentIdentity=Pu;y.buildComponentReference=hE;y.validateComponentReference=SE;var nE=Ze("node:crypto"),rE=Ze("node:path"),oE="cmp1_",sE=/^cmp1_[A-Za-z0-9_-]{43}$/,iE=["/skills/","/skills-cursor/"],aE=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,cE=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,uE=[".cursor",".claude",".codex"],lE={".claude.json":".claude",".agents":".codex"};y.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function fE(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>uE.includes(o));return n||(t.map(o=>lE[o]).find(o=>o!==void 0)??"unknown")}function dE(e,t){return`runtime-install:${e}/${t}`}function Cr(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}function Iu(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=rE.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return Cr(n,"sourcePath")}function pE(e){let t=e.replaceAll("\\","/");for(let n of iE){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}function Tu(e,t,n){let r=e.replaceAll("\\","/"),s=t.exec(r)?.[1];if(!s||s.split("/").includes(".."))return null;let i=s.replace(n,"");return i.length>0?i:null}function mE(e){return Tu(e,aE,/\.(mdc|md|rules)$/i)}function gE(e){return Tu(e,cE,/\.(md|mdc|toml)$/i)}function _E(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function Pu(e){let t=[Cr(e.installationRootExternalKey,"installationRootExternalKey"),Cr(e.installableKind,"installableKind"),Iu(e.sourcePath),Cr(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(_E).join("|")}`,"utf8")}function hE(e){let t=(0,nE.createHash)("sha256").update(Pu(e)).digest("base64url");return`${oE}${t}`}function SE(e){return sE.test(e)}var ke=Sr();Object.defineProperty(y,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:function(){return ke.buildMcpFamilyCanonicalKey}});Object.defineProperty(y,"foldMcpName",{enumerable:!0,get:function(){return ke.foldMcpName}});Object.defineProperty(y,"hashMcpLaunchIdentity",{enumerable:!0,get:function(){return ke.hashMcpLaunchIdentity}});Object.defineProperty(y,"launchContainsCredentials",{enumerable:!0,get:function(){return ke.launchContainsCredentials}});Object.defineProperty(y,"maskMcpLaunchForDisplay",{enumerable:!0,get:function(){return ke.maskMcpLaunchForDisplay}});Object.defineProperty(y,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:function(){return ke.MCP_LAUNCH_IDENTITY_ALGORITHM}});Object.defineProperty(y,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:function(){return ke.MCP_MISSING_LAUNCH_SERIALIZED}});Object.defineProperty(y,"normalizeMcpToolNames",{enumerable:!0,get:function(){return ke.normalizeMcpToolNames}});Object.defineProperty(y,"projectMcpLaunchIdentity",{enumerable:!0,get:function(){return ke.projectMcpLaunchIdentity}});Object.defineProperty(y,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:function(){return ke.projectMcpMissingLaunchIdentity}});Object.defineProperty(y,"serializeMcpLaunchIdentity",{enumerable:!0,get:function(){return ke.serializeMcpLaunchIdentity}});var Ht=yr();Object.defineProperty(y,"PACKAGE_FIELD_MAX",{enumerable:!0,get:function(){return Ht.PACKAGE_FIELD_MAX}});Object.defineProperty(y,"npxExecBin",{enumerable:!0,get:function(){return Ht.npxExecBin}});Object.defineProperty(y,"npxPackageSpecs",{enumerable:!0,get:function(){return Ht.npxPackageSpecs}});Object.defineProperty(y,"packageNameFromSpec",{enumerable:!0,get:function(){return Ht.packageNameFromSpec}});Object.defineProperty(y,"pinnedPackageVersionFromNpx",{enumerable:!0,get:function(){return Ht.pinnedPackageVersionFromNpx}});Object.defineProperty(y,"pinnedPackageVersionFromSpec",{enumerable:!0,get:function(){return Ht.pinnedPackageVersionFromSpec}});var wu=gu();Object.defineProperty(y,"McpPackageEcosystem",{enumerable:!0,get:function(){return wu.McpPackageEcosystem}});Object.defineProperty(y,"resolveMcpPackageIdentity",{enumerable:!0,get:function(){return wu.resolveMcpPackageIdentity}});var Ar=Ru();Object.defineProperty(y,"classifyMcpProvenance",{enumerable:!0,get:function(){return Ar.classifyMcpProvenance}});Object.defineProperty(y,"displayPublisherName",{enumerable:!0,get:function(){return Ar.displayPublisherName}});Object.defineProperty(y,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:function(){return Ar.EMPTY_NPM_PUBLISHER}});Object.defineProperty(y,"isNpmRegistryPublisher",{enumerable:!0,get:function(){return Ar.isNpmRegistryPublisher}});var Nu=Au();Object.defineProperty(y,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:function(){return Nu.mcpServerNameMatchesToolSegment}});Object.defineProperty(y,"mcpServerToolSegmentForms",{enumerable:!0,get:function(){return Nu.mcpServerToolSegmentForms}});var ts=bu();Object.defineProperty(y,"parseFrontmatterDescription",{enumerable:!0,get:function(){return ts.parseFrontmatterDescription}});Object.defineProperty(y,"parseFrontmatterField",{enumerable:!0,get:function(){return ts.parseFrontmatterField}});Object.defineProperty(y,"usableCatalogText",{enumerable:!0,get:function(){return ts.usableCatalogText}});var ut=Ou();Object.defineProperty(y,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return ut.COMPONENT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:function(){return ut.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}});Object.defineProperty(y,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return ut.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"capComponentTextBytes",{enumerable:!0,get:function(){return ut.capComponentTextBytes}});Object.defineProperty(y,"componentSourceContainsRedactableSecret",{enumerable:!0,get:function(){return ut.componentSourceContainsRedactableSecret}});Object.defineProperty(y,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:function(){return ut.fitSnapshotInspectionTextBudget}});Object.defineProperty(y,"prepareComponentInspectionText",{enumerable:!0,get:function(){return ut.prepareComponentInspectionText}});Object.defineProperty(y,"redactComponentSource",{enumerable:!0,get:function(){return ut.redactComponentSource}})});var Gr=z(Ce=>{"use strict";Ce.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Ce.find=(e,t)=>e.nodes.find(n=>n.type===t);Ce.exceedsLimit=(e,t,n=1,r)=>r===!1||!Ce.isInteger(e)||!Ce.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Ce.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)};Ce.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Ce.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;Ce.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Ce.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Ce.flatten=(...e)=>{let t=[],n=r=>{for(let o=0;o<r.length;o++){let s=r[o];if(Array.isArray(s)){n(s);continue}s!==void 0&&t.push(s)}return t};return n(e),t}});var Vr=z((ZP,Ef)=>{"use strict";var Sf=Gr();Ef.exports=(e,t={})=>{let n=(r,o={})=>{let s=t.escapeInvalid&&Sf.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a="";if(r.value)return(s||i)&&Sf.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let c of r.nodes)a+=n(c);return a};return n(e)}});var Rf=z((QP,yf)=>{"use strict";yf.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var Pf=z((ew,Tf)=>{"use strict";var Cf=Rf(),Et=(e,t,n)=>{if(Cf(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(Cf(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),s=String(r.shorthand),i=String(r.capture),a=String(r.wrap),c=e+":"+t+"="+o+s+i+a;if(Et.cache.hasOwnProperty(c))return Et.cache[c].result;let l=Math.min(e,t),u=Math.max(e,t);if(Math.abs(l-u)===1){let S=e+"|"+t;return r.capture?`(${S})`:r.wrap===!1?S:`(?:${S})`}let d=If(e)||If(t),f={min:e,max:t,a:l,b:u},p=[],g=[];if(d&&(f.isPadded=d,f.maxLen=String(f.max).length),l<0){let S=u<0?Math.abs(u):1;g=Af(S,Math.abs(l),f,r),l=f.a=0}return u>=0&&(p=Af(l,u,f,r)),f.negatives=g,f.positives=p,f.result=nC(g,p,r),r.capture===!0?f.result=`(${f.result})`:r.wrap!==!1&&p.length+g.length>1&&(f.result=`(?:${f.result})`),Et.cache[c]=f,f.result};function nC(e,t,n){let r=Ds(e,t,"-",!1,n)||[],o=Ds(t,e,"",!1,n)||[],s=Ds(e,t,"-?",!0,n)||[];return r.concat(s).concat(o).join("|")}function rC(e,t){let n=1,r=1,o=kf(e,n),s=new Set([t]);for(;e<=o&&o<=t;)s.add(o),n+=1,o=kf(e,n);for(o=xf(t+1,r)-1;e<o&&o<=t;)s.add(o),r+=1,o=xf(t+1,r)-1;return s=[...s],s.sort(iC),s}function oC(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=sC(e,t),o=r.length,s="",i=0;for(let a=0;a<o;a++){let[c,l]=r[a];c===l?s+=c:c!=="0"||l!=="9"?s+=aC(c,l,n):i++}return i&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[i],digits:o}}function Af(e,t,n,r){let o=rC(e,t),s=[],i=e,a;for(let c=0;c<o.length;c++){let l=o[c],u=oC(String(i),String(l),r),d="";if(!n.isPadded&&a&&a.pattern===u.pattern){a.count.length>1&&a.count.pop(),a.count.push(u.count[0]),a.string=a.pattern+Of(a.count),i=l+1;continue}n.isPadded&&(d=cC(l,n,r)),u.string=d+u.pattern+Of(u.count),s.push(u),i=l+1,a=u}return s}function Ds(e,t,n,r,o){let s=[];for(let i of e){let{string:a}=i;!r&&!bf(t,"string",a)&&s.push(n+a),r&&bf(t,"string",a)&&s.push(n+a)}return s}function sC(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}function iC(e,t){return e>t?1:t>e?-1:0}function bf(e,t,n){return e.some(r=>r[t]===n)}function kf(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}function xf(e,t){return e-e%Math.pow(10,t)}function Of(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}function aC(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}function If(e){return/^-?(0+)\d/.test(e)}function cC(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}}`}}Et.cache={};Et.clearCache=()=>Et.cache={};Tf.exports=Et});var js=z((tw,Uf)=>{"use strict";var uC=Ze("util"),Nf=Pf(),wf=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),lC=e=>t=>e===!0?Number(t):String(t),Fs=e=>typeof e=="number"||typeof e=="string"&&e!=="",En=e=>Number.isInteger(+e),$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},fC=(e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,dC=(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},zr=(e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},pC=(e,t,n)=>{e.negatives.sort((a,c)=>a<c?-1:a>c?1:0),e.positives.sort((a,c)=>a<c?-1:a>c?1:0);let r=t.capture?"":"?:",o="",s="",i;return e.positives.length&&(o=e.positives.map(a=>zr(String(a),n)).join("|")),e.negatives.length&&(s=`-(${r}${e.negatives.map(a=>zr(String(a),n)).join("|")})`),o&&s?i=`${o}|${s}`:i=o||s,t.wrap?`(${r}${i})`:i},vf=(e,t,n,r)=>{if(n)return Nf(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let s=String.fromCharCode(t);return`[${o}-${s}]`},Mf=(e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return Nf(e,t,n)},Lf=(...e)=>new RangeError("Invalid range arguments: "+uC.inspect(...e)),Hf=(e,t,n)=>{if(n.strictRanges===!0)throw Lf([e,t]);return[]},mC=(e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},gC=(e,t,n=1,r={})=>{let o=Number(e),s=Number(t);if(!Number.isInteger(o)||!Number.isInteger(s)){if(r.strictRanges===!0)throw Lf([e,t]);return[]}o===0&&(o=0),s===0&&(s=0);let i=o>s,a=String(e),c=String(t),l=String(n);n=Math.max(Math.abs(n),1);let u=$s(a)||$s(c)||$s(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&fC(e,t,r)===!1,p=r.transform||lC(f);if(r.toRegex&&n===1)return vf(zr(e,d),zr(t,d),!0,r);let g={negatives:[],positives:[]},S=I=>g[I<0?"negatives":"positives"].push(Math.abs(I)),A=[],b=0;for(;i?o>=s:o<=s;)r.toRegex===!0&&n>1?S(o):A.push(dC(p(o,b),d,f)),o=i?o-n:o+n,b++;return r.toRegex===!0?n>1?pC(g,r,d):Mf(A,null,{wrap:!1,...r}):A},_C=(e,t,n=1,r={})=>{if(!En(e)&&e.length>1||!En(t)&&t.length>1)return Hf(e,t,r);let o=r.transform||(f=>String.fromCharCode(f)),s=`${e}`.charCodeAt(0),i=`${t}`.charCodeAt(0),a=s>i,c=Math.min(s,i),l=Math.max(s,i);if(r.toRegex&&n===1)return vf(c,l,!1,r);let u=[],d=0;for(;a?s>=i:s<=i;)u.push(o(s,d)),s=a?s-n:s+n,d++;return r.toRegex===!0?Mf(u,null,{wrap:!1,options:r}):u},Wr=(e,t,n,r={})=>{if(t==null&&Fs(e))return[e];if(!Fs(e)||!Fs(t))return Hf(e,t,r);if(typeof n=="function")return Wr(e,t,1,{transform:n});if(wf(n))return Wr(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,En(n)?En(e)&&En(t)?gC(e,t,n,o):_C(e,t,Math.max(Math.abs(n),1),o):n!=null&&!wf(n)?mC(n,o):Wr(e,t,1,n)};Uf.exports=Wr});var $f=z((nw,Ff)=>{"use strict";var hC=js(),Df=Gr(),SC=(e,t={})=>{let n=(r,o={})=>{let s=Df.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a=s===!0||i===!0,c=t.escapeInvalid===!0?"\\":"",l="";if(r.isOpen===!0)return c+r.value;if(r.isClose===!0)return console.log("node.isClose",c,r.value),c+r.value;if(r.type==="open")return a?c+r.value:"(";if(r.type==="close")return a?c+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":a?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let u=Df.reduce(r.nodes),d=hC(...u,{...t,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return u.length>1&&d.length>1?`(${d})`:d}if(r.nodes)for(let u of r.nodes)l+=n(u,r);return l};return n(e)};Ff.exports=SC});var Kf=z((rw,Bf)=>{"use strict";var EC=js(),jf=Vr(),Dt=Gr(),yt=(e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?Dt.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let s of o)r.push(yt(s,t,n));else for(let s of t)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?yt(o,s,n):o+s);return Dt.flatten(r)},yC=(e,t={})=>{let n=t.rangeLimit===void 0?1e3:t.rangeLimit,r=(o,s={})=>{o.queue=[];let i=s,a=s.queue;for(;i.type!=="brace"&&i.type!=="root"&&i.parent;)i=i.parent,a=i.queue;if(o.invalid||o.dollar){a.push(yt(a.pop(),jf(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){a.push(yt(a.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let d=Dt.reduce(o.nodes);if(Dt.exceedsLimit(...d,t.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=EC(...d,t);f.length===0&&(f=jf(o,t)),a.push(yt(a.pop(),f)),o.nodes=[];return}let c=Dt.encloseBrace(o),l=o.queue,u=o;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let d=0;d<o.nodes.length;d++){let f=o.nodes[d];if(f.type==="comma"&&o.type==="brace"){d===1&&l.push(""),l.push("");continue}if(f.type==="close"){a.push(yt(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(yt(l.pop(),f.value));continue}f.nodes&&r(f,o)}return l};return Dt.flatten(r(e))};Bf.exports=yC});var Vf=z((ow,Gf)=>{"use strict";Gf.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:`
14
+ `,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 Xf=z((sw,Yf)=>{"use strict";var RC=Vr(),{MAX_LENGTH:Wf,CHAR_BACKSLASH:Bs,CHAR_BACKTICK:CC,CHAR_COMMA:AC,CHAR_DOT:bC,CHAR_LEFT_PARENTHESES:kC,CHAR_RIGHT_PARENTHESES:xC,CHAR_LEFT_CURLY_BRACE:OC,CHAR_RIGHT_CURLY_BRACE:IC,CHAR_LEFT_SQUARE_BRACKET:zf,CHAR_RIGHT_SQUARE_BRACKET:Jf,CHAR_DOUBLE_QUOTE:TC,CHAR_SINGLE_QUOTE:PC,CHAR_NO_BREAK_SPACE:wC,CHAR_ZERO_WIDTH_NOBREAK_SPACE:NC}=Vf(),vC=(e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Wf,n.maxLength):Wf;if(e.length>r)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${r})`);let o={type:"root",input:e,nodes:[]},s=[o],i=o,a=o,c=0,l=e.length,u=0,d=0,f,p=()=>e[u++],g=S=>{if(S.type==="text"&&a.type==="dot"&&(a.type="text"),a&&a.type==="text"&&S.type==="text"){a.value+=S.value;return}return i.nodes.push(S),S.parent=i,S.prev=a,a=S,S};for(g({type:"bos"});u<l;)if(i=s[s.length-1],f=p(),!(f===NC||f===wC)){if(f===Bs){g({type:"text",value:(t.keepEscaping?f:"")+p()});continue}if(f===Jf){g({type:"text",value:"\\"+f});continue}if(f===zf){c++;let S;for(;u<l&&(S=p());){if(f+=S,S===zf){c++;continue}if(S===Bs){f+=p();continue}if(S===Jf&&(c--,c===0))break}g({type:"text",value:f});continue}if(f===kC){i=g({type:"paren",nodes:[]}),s.push(i),g({type:"text",value:f});continue}if(f===xC){if(i.type!=="paren"){g({type:"text",value:f});continue}i=s.pop(),g({type:"text",value:f}),i=s[s.length-1];continue}if(f===TC||f===PC||f===CC){let S=f,A;for(t.keepQuotes!==!0&&(f="");u<l&&(A=p());){if(A===Bs){f+=A+p();continue}if(A===S){t.keepQuotes===!0&&(f+=A);break}f+=A}g({type:"text",value:f});continue}if(f===OC){d++;let A={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||i.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};i=g(A),s.push(i),g({type:"open",value:f});continue}if(f===IC){if(i.type!=="brace"){g({type:"text",value:f});continue}let S="close";i=s.pop(),i.close=!0,g({type:S,value:f}),d--,i=s[s.length-1];continue}if(f===AC&&d>0){if(i.ranges>0){i.ranges=0;let S=i.nodes.shift();i.nodes=[S,{type:"text",value:RC(i)}]}g({type:"comma",value:f}),i.commas++;continue}if(f===bC&&d>0&&i.commas===0){let S=i.nodes;if(d===0||S.length===0){g({type:"text",value:f});continue}if(a.type==="dot"){if(i.range=[],a.value+=f,a.type="range",i.nodes.length!==3&&i.nodes.length!==5){i.invalid=!0,i.ranges=0,a.type="text";continue}i.ranges++,i.args=[];continue}if(a.type==="range"){S.pop();let A=S[S.length-1];A.value+=a.value+f,a=A,i.ranges--;continue}g({type:"dot",value:f});continue}g({type:"text",value:f})}do if(i=s.pop(),i.type!=="root"){i.nodes.forEach(b=>{b.nodes||(b.type==="open"&&(b.isOpen=!0),b.type==="close"&&(b.isClose=!0),b.nodes||(b.type="text"),b.invalid=!0)});let S=s[s.length-1],A=S.nodes.indexOf(i);S.nodes.splice(A,1,...i.nodes)}while(s.length>0);return g({type:"eos"}),o};Yf.exports=vC});var Qf=z((iw,Zf)=>{"use strict";var qf=Vr(),MC=$f(),LC=Kf(),HC=Xf(),he=(e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=he.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(he.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n};he.parse=(e,t={})=>HC(e,t);he.stringify=(e,t={})=>qf(typeof e=="string"?he.parse(e,t):e,t);he.compile=(e,t={})=>(typeof e=="string"&&(e=he.parse(e,t)),MC(e,t));he.expand=(e,t={})=>{typeof e=="string"&&(e=he.parse(e,t));let n=LC(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};he.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?he.compile(e,t):he.expand(e,t);Zf.exports=he});var yn=z((aw,od)=>{"use strict";var UC=Ze("path"),Me="\\\\/",ed=`[^${Me}]`,DC=0,Xe="\\.",FC="\\+",$C="\\?",Jr="\\/",jC="(?=.)",td="[^/]",Ks=`(?:${Jr}|$)`,nd=`(?:^|${Jr})`,Gs=`${Xe}{1,2}${Ks}`,BC=`(?!${Xe})`,KC=`(?!${nd}${Gs})`,GC=`(?!${Xe}{0,1}${Ks})`,VC=`(?!${Gs})`,WC=`[^.${Jr}]`,zC=`${td}*?`,rd={DOT_LITERAL:Xe,PLUS_LITERAL:FC,QMARK_LITERAL:$C,SLASH_LITERAL:Jr,ONE_CHAR:jC,QMARK:td,END_ANCHOR:Ks,DOTS_SLASH:Gs,NO_DOT:BC,NO_DOTS:KC,NO_DOT_SLASH:GC,NO_DOTS_SLASH:VC,QMARK_NO_DOT:WC,STAR:zC,START_ANCHOR:nd},JC={...rd,SLASH_LITERAL:`[${Me}]`,QMARK:ed,STAR:`${ed}*?`,DOTS_SLASH:`${Xe}{1,2}(?:[${Me}]|$)`,NO_DOT:`(?!${Xe})`,NO_DOTS:`(?!(?:^|[${Me}])${Xe}{1,2}(?:[${Me}]|$))`,NO_DOT_SLASH:`(?!${Xe}{0,1}(?:[${Me}]|$))`,NO_DOTS_SLASH:`(?!${Xe}{1,2}(?:[${Me}]|$))`,QMARK_NO_DOT:`[^.${Me}]`,START_ANCHOR:`(?:^|[${Me}])`,END_ANCHOR:`(?:[${Me}]|$)`},YC={__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"};od.exports={DEFAULT_MAX_EXTGLOB_RECURSION:DC,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:YC,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:UC.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?JC:rd}}});var Rn=z(le=>{"use strict";var XC=Ze("path"),qC=process.platform==="win32",{REGEX_BACKSLASH:ZC,REGEX_REMOVE_BACKSLASH:QC,REGEX_SPECIAL_CHARS:eA,REGEX_SPECIAL_CHARS_GLOBAL:tA}=yn();le.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);le.hasRegexChars=e=>eA.test(e);le.isRegexChar=e=>e.length===1&&le.hasRegexChars(e);le.escapeRegex=e=>e.replace(tA,"\\$1");le.toPosixSlashes=e=>e.replace(ZC,"/");le.removeBackslashes=e=>e.replace(QC,t=>t==="\\"?"":t);le.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};le.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:qC===!0||XC.sep==="\\";le.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?le.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};le.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};le.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",s=`${r}(?:${e})${o}`;return t.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var dd=z((uw,fd)=>{"use strict";var sd=Rn(),{CHAR_ASTERISK:Vs,CHAR_AT:nA,CHAR_BACKWARD_SLASH:Cn,CHAR_COMMA:rA,CHAR_DOT:Ws,CHAR_EXCLAMATION_MARK:zs,CHAR_FORWARD_SLASH:ld,CHAR_LEFT_CURLY_BRACE:Js,CHAR_LEFT_PARENTHESES:Ys,CHAR_LEFT_SQUARE_BRACKET:oA,CHAR_PLUS:sA,CHAR_QUESTION_MARK:id,CHAR_RIGHT_CURLY_BRACE:iA,CHAR_RIGHT_PARENTHESES:ad,CHAR_RIGHT_SQUARE_BRACKET:aA}=yn(),cd=e=>e===ld||e===Cn,ud=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},cA=(e,t)=>{let n=t||{},r=e.length-1,o=n.parts===!0||n.scanToEnd===!0,s=[],i=[],a=[],c=e,l=-1,u=0,d=0,f=!1,p=!1,g=!1,S=!1,A=!1,b=!1,I=!1,P=!1,T=!1,O=!1,K=0,D,x,N={value:"",depth:0,isGlob:!1},H=()=>l>=r,m=()=>c.charCodeAt(l+1),k=()=>(D=x,c.charCodeAt(++l));for(;l<r;){x=k();let ie;if(x===Cn){I=N.backslashes=!0,x=k(),x===Js&&(b=!0);continue}if(b===!0||x===Js){for(K++;H()!==!0&&(x=k());){if(x===Cn){I=N.backslashes=!0,k();continue}if(x===Js){K++;continue}if(b!==!0&&x===Ws&&(x=k())===Ws){if(f=N.isBrace=!0,g=N.isGlob=!0,O=!0,o===!0)continue;break}if(b!==!0&&x===rA){if(f=N.isBrace=!0,g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===iA&&(K--,K===0)){b=!1,f=N.isBrace=!0,O=!0;break}}if(o===!0)continue;break}if(x===ld){if(s.push(l),i.push(N),N={value:"",depth:0,isGlob:!1},O===!0)continue;if(D===Ws&&l===u+1){u+=2;continue}d=l+1;continue}if(n.noext!==!0&&(x===sA||x===nA||x===Vs||x===id||x===zs)===!0&&m()===Ys){if(g=N.isGlob=!0,S=N.isExtglob=!0,O=!0,x===zs&&l===u&&(T=!0),o===!0){for(;H()!==!0&&(x=k());){if(x===Cn){I=N.backslashes=!0,x=k();continue}if(x===ad){g=N.isGlob=!0,O=!0;break}}continue}break}if(x===Vs){if(D===Vs&&(A=N.isGlobstar=!0),g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===id){if(g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===oA){for(;H()!==!0&&(ie=k());){if(ie===Cn){I=N.backslashes=!0,k();continue}if(ie===aA){p=N.isBracket=!0,g=N.isGlob=!0,O=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&x===zs&&l===u){P=N.negated=!0,u++;continue}if(n.noparen!==!0&&x===Ys){if(g=N.isGlob=!0,o===!0){for(;H()!==!0&&(x=k());){if(x===Ys){I=N.backslashes=!0,x=k();continue}if(x===ad){O=!0;break}}continue}break}if(g===!0){if(O=!0,o===!0)continue;break}}n.noext===!0&&(S=!1,g=!1);let U=c,de="",_="";u>0&&(de=c.slice(0,u),c=c.slice(u),d-=u),U&&g===!0&&d>0?(U=c.slice(0,d),_=c.slice(d)):g===!0?(U="",_=c):U=c,U&&U!==""&&U!=="/"&&U!==c&&cd(U.charCodeAt(U.length-1))&&(U=U.slice(0,-1)),n.unescape===!0&&(_&&(_=sd.removeBackslashes(_)),U&&I===!0&&(U=sd.removeBackslashes(U)));let h={prefix:de,input:e,start:u,base:U,glob:_,isBrace:f,isBracket:p,isGlob:g,isExtglob:S,isGlobstar:A,negated:P,negatedExtglob:T};if(n.tokens===!0&&(h.maxDepth=0,cd(x)||i.push(N),h.tokens=i),n.parts===!0||n.tokens===!0){let ie;for(let F=0;F<s.length;F++){let xe=ie?ie+1:u,Oe=s[F],pe=e.slice(xe,Oe);n.tokens&&(F===0&&u!==0?(i[F].isPrefix=!0,i[F].value=de):i[F].value=pe,ud(i[F]),h.maxDepth+=i[F].depth),(F!==0||pe!=="")&&a.push(pe),ie=Oe}if(ie&&ie+1<e.length){let F=e.slice(ie+1);a.push(F),n.tokens&&(i[i.length-1].value=F,ud(i[i.length-1]),h.maxDepth+=i[i.length-1].depth)}h.slashes=s,h.parts=a}return h};fd.exports=cA});var hd=z((lw,_d)=>{"use strict";var An=yn(),se=Rn(),{MAX_LENGTH:Yr,POSIX_REGEX_SOURCE:uA,REGEX_NON_SPECIAL_CHARS:lA,REGEX_SPECIAL_CHARS_BACKREF:fA,REPLACEMENTS:pd}=An,dA=(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=>se.escapeRegex(o)).join("..")}return n},Ft=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,md=e=>{let t=[],n=0,r=0,o=0,s="",i=!1;for(let a of e){if(i===!0){s+=a,i=!1;continue}if(a==="\\"){s+=a,i=!0;continue}if(a==='"'){o=o===1?0:1,s+=a;continue}if(o===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")r++;else if(a===")"&&r>0)r--;else if(a==="|"&&r===0){t.push(s),s="";continue}}}s+=a}return t.push(s),t},pA=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},gd=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(pA(t))return t.replace(/\\(.)/g,"$1")},mA=e=>{let t=e.map(gd).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let o=t[n],s=t[r],i=o[0];if(!(!i||o!==i.repeat(o.length)||s!==i.repeat(s.length))&&(o===s||o.startsWith(s)||s.startsWith(o)))return!0}return!1},Xs=(e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,r=0,o=0,s=!1;for(let i=1;i<e.length;i++){let a=e[i];if(s===!0){s=!1;continue}if(a==="\\"){s=!0;continue}if(a==='"'){o=o===1?0:1;continue}if(o!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){r++;continue}if(a===")"&&(r--,r===0))return t===!0&&i!==e.length-1?void 0:{type:e[0],body:e.slice(2,i),end:i}}}}},gA=e=>{let t=0,n=[];for(;t<e.length;){let o=Xs(e.slice(t),!1);if(!o||o.type!=="*")return;let s=md(o.body).map(a=>a.trim());if(s.length!==1)return;let i=gd(s[0]);if(!i||i.length!==1)return;n.push(i),t+=o.end+1}return n.length<1?void 0:`${n.length===1?se.escapeRegex(n[0]):`[${n.map(o=>se.escapeRegex(o)).join("")}]`}*`},_A=e=>{let t=0,n=e.trim(),r=Xs(n);for(;r;)t++,n=r.body.trim(),r=Xs(n);return t},hA=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:An.DEFAULT_MAX_EXTGLOB_RECURSION,r=md(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||mA(r)))return{risky:!0};for(let o of r){let s=gA(o);if(s)return{risky:!0,safeOutput:s};if(_A(o)>n)return{risky:!0}}return{risky:!1}},qs=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=pd[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(Yr,n.maxLength):Yr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},i=[s],a=n.capture?"":"?:",c=se.isWindows(t),l=An.globChars(c),u=An.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,SLASH_LITERAL:p,ONE_CHAR:g,DOTS_SLASH:S,NO_DOT:A,NO_DOT_SLASH:b,NO_DOTS_SLASH:I,QMARK:P,QMARK_NO_DOT:T,STAR:O,START_ANCHOR:K}=l,D=C=>`(${a}(?:(?!${K}${C.dot?S:d}).)*?)`,x=n.dot?"":A,N=n.dot?P:T,H=n.bash===!0?D(n):O;n.capture&&(H=`(${H})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let m={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:i};e=se.removePrefix(e,m),o=e.length;let k=[],U=[],de=[],_=s,h,ie=()=>m.index===o-1,F=m.peek=(C=1)=>e[m.index+C],xe=m.advance=()=>e[++m.index]||"",Oe=()=>e.slice(m.index+1),pe=(C="",Y=0)=>{m.consumed+=C,m.index+=Y},Hn=C=>{m.output+=C.output!=null?C.output:C.value,pe(C.value)},Am=()=>{let C=1;for(;F()==="!"&&(F(2)!=="("||F(3)==="?");)xe(),m.start++,C++;return C%2===0?!1:(m.negated=!0,m.start++,!0)},Un=C=>{m[C]++,de.push(C)},qe=C=>{m[C]--,de.pop()},v=C=>{if(_.type==="globstar"){let Y=m.braces>0&&(C.type==="comma"||C.type==="brace"),R=C.extglob===!0||k.length&&(C.type==="pipe"||C.type==="paren");C.type!=="slash"&&C.type!=="paren"&&!Y&&!R&&(m.output=m.output.slice(0,-_.output.length),_.type="star",_.value="*",_.output=H,m.output+=_.output)}if(k.length&&C.type!=="paren"&&(k[k.length-1].inner+=C.value),(C.value||C.output)&&Hn(C),_&&_.type==="text"&&C.type==="text"){_.value+=C.value,_.output=(_.output||"")+C.value;return}C.prev=_,i.push(C),_=C},Dn=(C,Y)=>{let R={...u[Y],conditions:1,inner:""};R.prev=_,R.parens=m.parens,R.output=m.output,R.startIndex=m.index,R.tokensIndex=i.length;let w=(n.capture?"(":"")+R.open;Un("parens"),v({type:C,value:Y,output:m.output?"":g}),v({type:"paren",extglob:!0,value:xe(),output:w}),k.push(R)},bm=C=>{let Y=e.slice(C.startIndex,m.index+1),R=e.slice(C.startIndex+2,m.index),w=hA(R,n);if((C.type==="plus"||C.type==="star")&&w.risky){let G=w.safeOutput?(C.output?"":g)+(n.capture?`(${w.safeOutput})`:w.safeOutput):void 0,Ie=i[C.tokensIndex];Ie.type="text",Ie.value=Y,Ie.output=G||se.escapeRegex(Y);for(let Te=C.tokensIndex+1;Te<i.length;Te++)i[Te].value="",i[Te].output="",delete i[Te].suffix;m.output=C.output+Ie.output,m.backtrack=!0,v({type:"paren",extglob:!0,value:h,output:""}),qe("parens");return}let W=C.close+(n.capture?")":""),oe;if(C.type==="negate"){let G=H;if(C.inner&&C.inner.length>1&&C.inner.includes("/")&&(G=D(n)),(G!==H||ie()||/^\)+$/.test(Oe()))&&(W=C.close=`)$))${G}`),C.inner.includes("*")&&(oe=Oe())&&/^\.[^\\/.]+$/.test(oe)){let Ie=qs(oe,{...t,fastpaths:!1}).output;W=C.close=`)${Ie})${G})`}C.prev.type==="bos"&&(m.negatedExtglob=!0)}v({type:"paren",extglob:!0,value:h,output:W}),qe("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let C=!1,Y=e.replace(fA,(R,w,W,oe,G,Ie)=>oe==="\\"?(C=!0,R):oe==="?"?w?w+oe+(G?P.repeat(G.length):""):Ie===0?N+(G?P.repeat(G.length):""):P.repeat(W.length):oe==="."?d.repeat(W.length):oe==="*"?w?w+oe+(G?H:""):H:w?R:`\\${R}`);return C===!0&&(n.unescape===!0?Y=Y.replace(/\\/g,""):Y=Y.replace(/\\+/g,R=>R.length%2===0?"\\\\":R?"\\":"")),Y===e&&n.contains===!0?(m.output=e,m):(m.output=se.wrapOutput(Y,m,t),m)}for(;!ie();){if(h=xe(),h==="\0")continue;if(h==="\\"){let R=F();if(R==="/"&&n.bash!==!0||R==="."||R===";")continue;if(!R){h+="\\",v({type:"text",value:h});continue}let w=/^\\+/.exec(Oe()),W=0;if(w&&w[0].length>2&&(W=w[0].length,m.index+=W,W%2!==0&&(h+="\\")),n.unescape===!0?h=xe():h+=xe(),m.brackets===0){v({type:"text",value:h});continue}}if(m.brackets>0&&(h!=="]"||_.value==="["||_.value==="[^")){if(n.posix!==!1&&h===":"){let R=_.value.slice(1);if(R.includes("[")&&(_.posix=!0,R.includes(":"))){let w=_.value.lastIndexOf("["),W=_.value.slice(0,w),oe=_.value.slice(w+2),G=uA[oe];if(G){_.value=W+G,m.backtrack=!0,xe(),!s.output&&i.indexOf(_)===1&&(s.output=g);continue}}}(h==="["&&F()!==":"||h==="-"&&F()==="]")&&(h=`\\${h}`),h==="]"&&(_.value==="["||_.value==="[^")&&(h=`\\${h}`),n.posix===!0&&h==="!"&&_.value==="["&&(h="^"),_.value+=h,Hn({value:h});continue}if(m.quotes===1&&h!=='"'){h=se.escapeRegex(h),_.value+=h,Hn({value:h});continue}if(h==='"'){m.quotes=m.quotes===1?0:1,n.keepQuotes===!0&&v({type:"text",value:h});continue}if(h==="("){Un("parens"),v({type:"paren",value:h});continue}if(h===")"){if(m.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Ft("opening","("));let R=k[k.length-1];if(R&&m.parens===R.parens+1){bm(k.pop());continue}v({type:"paren",value:h,output:m.parens?")":"\\)"}),qe("parens");continue}if(h==="["){if(n.nobracket===!0||!Oe().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Ft("closing","]"));h=`\\${h}`}else Un("brackets");v({type:"bracket",value:h});continue}if(h==="]"){if(n.nobracket===!0||_&&_.type==="bracket"&&_.value.length===1){v({type:"text",value:h,output:`\\${h}`});continue}if(m.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Ft("opening","["));v({type:"text",value:h,output:`\\${h}`});continue}qe("brackets");let R=_.value.slice(1);if(_.posix!==!0&&R[0]==="^"&&!R.includes("/")&&(h=`/${h}`),_.value+=h,Hn({value:h}),n.literalBrackets===!1||se.hasRegexChars(R))continue;let w=se.escapeRegex(_.value);if(m.output=m.output.slice(0,-_.value.length),n.literalBrackets===!0){m.output+=w,_.value=w;continue}_.value=`(${a}${w}|${_.value})`,m.output+=_.value;continue}if(h==="{"&&n.nobrace!==!0){Un("braces");let R={type:"brace",value:h,output:"(",outputIndex:m.output.length,tokensIndex:m.tokens.length};U.push(R),v(R);continue}if(h==="}"){let R=U[U.length-1];if(n.nobrace===!0||!R){v({type:"text",value:h,output:h});continue}let w=")";if(R.dots===!0){let W=i.slice(),oe=[];for(let G=W.length-1;G>=0&&(i.pop(),W[G].type!=="brace");G--)W[G].type!=="dots"&&oe.unshift(W[G].value);w=dA(oe,n),m.backtrack=!0}if(R.comma!==!0&&R.dots!==!0){let W=m.output.slice(0,R.outputIndex),oe=m.tokens.slice(R.tokensIndex);R.value=R.output="\\{",h=w="\\}",m.output=W;for(let G of oe)m.output+=G.output||G.value}v({type:"brace",value:h,output:w}),qe("braces"),U.pop();continue}if(h==="|"){k.length>0&&k[k.length-1].conditions++,v({type:"text",value:h});continue}if(h===","){let R=h,w=U[U.length-1];w&&de[de.length-1]==="braces"&&(w.comma=!0,R="|"),v({type:"comma",value:h,output:R});continue}if(h==="/"){if(_.type==="dot"&&m.index===m.start+1){m.start=m.index+1,m.consumed="",m.output="",i.pop(),_=s;continue}v({type:"slash",value:h,output:p});continue}if(h==="."){if(m.braces>0&&_.type==="dot"){_.value==="."&&(_.output=d);let R=U[U.length-1];_.type="dots",_.output+=h,_.value+=h,R.dots=!0;continue}if(m.braces+m.parens===0&&_.type!=="bos"&&_.type!=="slash"){v({type:"text",value:h,output:d});continue}v({type:"dot",value:h,output:d});continue}if(h==="?"){if(!(_&&_.value==="(")&&n.noextglob!==!0&&F()==="("&&F(2)!=="?"){Dn("qmark",h);continue}if(_&&_.type==="paren"){let w=F(),W=h;if(w==="<"&&!se.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(_.value==="("&&!/[!=<:]/.test(w)||w==="<"&&!/<([!=]|\w+>)/.test(Oe()))&&(W=`\\${h}`),v({type:"text",value:h,output:W});continue}if(n.dot!==!0&&(_.type==="slash"||_.type==="bos")){v({type:"qmark",value:h,output:T});continue}v({type:"qmark",value:h,output:P});continue}if(h==="!"){if(n.noextglob!==!0&&F()==="("&&(F(2)!=="?"||!/[!=<:]/.test(F(3)))){Dn("negate",h);continue}if(n.nonegate!==!0&&m.index===0){Am();continue}}if(h==="+"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){Dn("plus",h);continue}if(_&&_.value==="("||n.regex===!1){v({type:"plus",value:h,output:f});continue}if(_&&(_.type==="bracket"||_.type==="paren"||_.type==="brace")||m.parens>0){v({type:"plus",value:h});continue}v({type:"plus",value:f});continue}if(h==="@"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){v({type:"at",extglob:!0,value:h,output:""});continue}v({type:"text",value:h});continue}if(h!=="*"){(h==="$"||h==="^")&&(h=`\\${h}`);let R=lA.exec(Oe());R&&(h+=R[0],m.index+=R[0].length),v({type:"text",value:h});continue}if(_&&(_.type==="globstar"||_.star===!0)){_.type="star",_.star=!0,_.value+=h,_.output=H,m.backtrack=!0,m.globstar=!0,pe(h);continue}let C=Oe();if(n.noextglob!==!0&&/^\([^?]/.test(C)){Dn("star",h);continue}if(_.type==="star"){if(n.noglobstar===!0){pe(h);continue}let R=_.prev,w=R.prev,W=R.type==="slash"||R.type==="bos",oe=w&&(w.type==="star"||w.type==="globstar");if(n.bash===!0&&(!W||C[0]&&C[0]!=="/")){v({type:"star",value:h,output:""});continue}let G=m.braces>0&&(R.type==="comma"||R.type==="brace"),Ie=k.length&&(R.type==="pipe"||R.type==="paren");if(!W&&R.type!=="paren"&&!G&&!Ie){v({type:"star",value:h,output:""});continue}for(;C.slice(0,3)==="/**";){let Te=e[m.index+4];if(Te&&Te!=="/")break;C=C.slice(3),pe("/**",3)}if(R.type==="bos"&&ie()){_.type="globstar",_.value+=h,_.output=D(n),m.output=_.output,m.globstar=!0,pe(h);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&!oe&&ie()){m.output=m.output.slice(0,-(R.output+_.output).length),R.output=`(?:${R.output}`,_.type="globstar",_.output=D(n)+(n.strictSlashes?")":"|$)"),_.value+=h,m.globstar=!0,m.output+=R.output+_.output,pe(h);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&C[0]==="/"){let Te=C[1]!==void 0?"|$":"";m.output=m.output.slice(0,-(R.output+_.output).length),R.output=`(?:${R.output}`,_.type="globstar",_.output=`${D(n)}${p}|${p}${Te})`,_.value+=h,m.output+=R.output+_.output,m.globstar=!0,pe(h+xe()),v({type:"slash",value:"/",output:""});continue}if(R.type==="bos"&&C[0]==="/"){_.type="globstar",_.value+=h,_.output=`(?:^|${p}|${D(n)}${p})`,m.output=_.output,m.globstar=!0,pe(h+xe()),v({type:"slash",value:"/",output:""});continue}m.output=m.output.slice(0,-_.output.length),_.type="globstar",_.output=D(n),_.value+=h,m.output+=_.output,m.globstar=!0,pe(h);continue}let Y={type:"star",value:h,output:H};if(n.bash===!0){Y.output=".*?",(_.type==="bos"||_.type==="slash")&&(Y.output=x+Y.output),v(Y);continue}if(_&&(_.type==="bracket"||_.type==="paren")&&n.regex===!0){Y.output=h,v(Y);continue}(m.index===m.start||_.type==="slash"||_.type==="dot")&&(_.type==="dot"?(m.output+=b,_.output+=b):n.dot===!0?(m.output+=I,_.output+=I):(m.output+=x,_.output+=x),F()!=="*"&&(m.output+=g,_.output+=g)),v(Y)}for(;m.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ft("closing","]"));m.output=se.escapeLast(m.output,"["),qe("brackets")}for(;m.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ft("closing",")"));m.output=se.escapeLast(m.output,"("),qe("parens")}for(;m.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ft("closing","}"));m.output=se.escapeLast(m.output,"{"),qe("braces")}if(n.strictSlashes!==!0&&(_.type==="star"||_.type==="bracket")&&v({type:"maybe_slash",value:"",output:`${p}?`}),m.backtrack===!0){m.output="";for(let C of m.tokens)m.output+=C.output!=null?C.output:C.value,C.suffix&&(m.output+=C.suffix)}return m};qs.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(Yr,n.maxLength):Yr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=pd[e]||e;let s=se.isWindows(t),{DOT_LITERAL:i,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:d,NO_DOTS_SLASH:f,STAR:p,START_ANCHOR:g}=An.globChars(s),S=n.dot?d:u,A=n.dot?f:u,b=n.capture?"":"?:",I={negated:!1,prefix:""},P=n.bash===!0?".*?":p;n.capture&&(P=`(${P})`);let T=x=>x.noglobstar===!0?P:`(${b}(?:(?!${g}${x.dot?l:i}).)*?)`,O=x=>{switch(x){case"*":return`${S}${c}${P}`;case".*":return`${i}${c}${P}`;case"*.*":return`${S}${P}${i}${c}${P}`;case"*/*":return`${S}${P}${a}${c}${A}${P}`;case"**":return S+T(n);case"**/*":return`(?:${S}${T(n)}${a})?${A}${c}${P}`;case"**/*.*":return`(?:${S}${T(n)}${a})?${A}${P}${i}${c}${P}`;case"**/.*":return`(?:${S}${T(n)}${a})?${i}${c}${P}`;default:{let N=/^(.*?)\.(\w+)$/.exec(x);if(!N)return;let H=O(N[1]);return H?H+i+N[2]:void 0}}},K=se.removePrefix(e,I),D=O(K);return D&&n.strictSlashes!==!0&&(D+=`${a}?`),D};_d.exports=qs});var Ed=z((fw,Sd)=>{"use strict";var SA=Ze("path"),EA=dd(),Zs=hd(),Qs=Rn(),yA=yn(),RA=e=>e&&typeof e=="object"&&!Array.isArray(e),te=(e,t,n=!1)=>{if(Array.isArray(e)){let u=e.map(f=>te(f,t,n));return f=>{for(let p of u){let g=p(f);if(g)return g}return!1}}let r=RA(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||{},s=Qs.isWindows(t),i=r?te.compileRe(e,t):te.makeRe(e,t,!1,!0),a=i.state;delete i.state;let c=()=>!1;if(o.ignore){let u={...t,ignore:null,onMatch:null,onResult:null};c=te(o.ignore,u,n)}let l=(u,d=!1)=>{let{isMatch:f,match:p,output:g}=te.test(u,i,t,{glob:e,posix:s}),S={glob:e,state:a,regex:i,posix:s,input:u,output:g,match:p,isMatch:f};return typeof o.onResult=="function"&&o.onResult(S),f===!1?(S.isMatch=!1,d?S:!1):c(u)?(typeof o.onIgnore=="function"&&o.onIgnore(S),S.isMatch=!1,d?S:!1):(typeof o.onMatch=="function"&&o.onMatch(S),d?S:!0)};return n&&(l.state=a),l};te.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 s=n||{},i=s.format||(o?Qs.toPosixSlashes:null),a=e===r,c=a&&i?i(e):e;return a===!1&&(c=i?i(e):e,a=c===r),(a===!1||s.capture===!0)&&(s.matchBase===!0||s.basename===!0?a=te.matchBase(e,t,n,o):a=t.exec(c)),{isMatch:!!a,match:a,output:c}};te.matchBase=(e,t,n,r=Qs.isWindows(n))=>(t instanceof RegExp?t:te.makeRe(t,n)).test(SA.basename(e));te.isMatch=(e,t,n)=>te(t,n)(e);te.parse=(e,t)=>Array.isArray(e)?e.map(n=>te.parse(n,t)):Zs(e,{...t,fastpaths:!1});te.scan=(e,t)=>EA(e,t);te.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let o=t||{},s=o.contains?"":"^",i=o.contains?"":"$",a=`${s}(?:${e.output})${i}`;e&&e.negated===!0&&(a=`^(?!${a}).*$`);let c=te.toRegex(a,t);return r===!0&&(c.state=e),c};te.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=Zs.fastpaths(e,t)),o.output||(o=Zs(e,t)),te.compileRe(o,t,n,r)};te.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/$^/}};te.constants=yA;Sd.exports=te});var Rd=z((dw,yd)=>{"use strict";yd.exports=Ed()});var Od=z((pw,xd)=>{"use strict";var Ad=Ze("util"),bd=Qf(),Le=Rd(),ei=Rn(),Cd=e=>e===""||e==="./",kd=e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},J=(e,t,n)=>{t=[].concat(t),e=[].concat(e);let r=new Set,o=new Set,s=new Set,i=0,a=u=>{s.add(u.output),n&&n.onResult&&n.onResult(u)};for(let u=0;u<t.length;u++){let d=Le(String(t[u]),{...n,onResult:a},!0),f=d.state.negated||d.state.negatedExtglob;f&&i++;for(let p of e){let g=d(p,!0);(f?!g.isMatch:g.isMatch)&&(f?r.add(g.output):(r.delete(g.output),o.add(g.output)))}}let l=(i===t.length?[...s]:[...o]).filter(u=>!r.has(u));if(n&&l.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(u=>u.replace(/\\/g,"")):t}return l};J.match=J;J.matcher=(e,t)=>Le(e,t);J.isMatch=(e,t,n)=>Le(t,n)(e);J.any=J.isMatch;J.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],s=a=>{n.onResult&&n.onResult(a),o.push(a.output)},i=new Set(J(e,t,{...n,onResult:s}));for(let a of o)i.has(a)||r.add(a);return[...r]};J.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Ad.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>J.contains(e,r,n));if(typeof t=="string"){if(Cd(e)||Cd(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return J.isMatch(e,t,{...n,contains:!0})};J.matchKeys=(e,t,n)=>{if(!ei.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=J(Object.keys(e),t,n),o={};for(let s of r)o[s]=e[s];return o};J.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Le(String(o),n);if(r.some(i=>s(i)))return!0}return!1};J.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Le(String(o),n);if(!r.every(i=>s(i)))return!1}return!0};J.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Ad.inspect(e)}"`);return[].concat(t).every(r=>Le(r,n)(e))};J.capture=(e,t,n)=>{let r=ei.isWindows(n),s=Le.makeRe(String(e),{...n,capture:!0}).exec(r?ei.toPosixSlashes(t):t);if(s)return s.slice(1).map(i=>i===void 0?"":i)};J.makeRe=(...e)=>Le.makeRe(...e);J.scan=(...e)=>Le.scan(...e);J.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of bd(String(r),t))n.push(Le.parse(o,t));return n};J.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!kd(e)?[e]:bd(e,t)};J.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return J.braces(e,{...t,expand:!0})};J.hasBraces=kd;xd.exports=J});import{realpathSync as xx}from"node:fs";import{resolve as Ox}from"node:path";import{fileURLToPath as Ix,pathToFileURL as Tx}from"node:url";import{createHash as qm}from"node:crypto";import{homedir as Zm}from"node:os";import{dirname as rO,join as Qm,parse as oO,resolve as sO}from"node:path";var $i="EV_AI_LAUNCHER_VERSION";var ji="EV_AI_HOOK_SOURCE",Bi="EV_AI_HOOK_FALLBACK_REASON",Ki="EV_AI_LAUNCHER_SCOPE",mo="EV_AI_LAUNCHER_READY_FD";var Gi="--defer-user-spec",Fn="--cap",zt="--slot";var Vi=Buffer.from([1]);var vx=1024*1024,Mx=4*1024*1024,Lx=64*1024,Hx=64*1024,Ux=64*1024;var go=4096,Dx=4*1024*1024;import{join as qi}from"node:path";import{open as Wi,mkdir as wm,readFile as Nm,readdir as vm,rename as Mm,stat as Lm,rmdir as Hm,unlink as Um,utimes as Dm}from"node:fs/promises";var $n=new WeakMap;function Ji(e){if(e&&typeof e=="object"&&"code"in e)return e}function Ot(e){return Ji(e)?.code==="ENOENT"}function Jt(e){return Ji(e)?.code==="EEXIST"}async function Yi(e,t){try{return await e.readdir(t)}catch(n){if(Ot(n))return[];throw n}}function Xi(){return{async open(e,t){let n=await Wi(e,t),r={path:e};return $n.set(r,n),r},async write(e,t){let n=zi(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await zi(e).sync()},async close(e){let t=$n.get(e);$n.delete(e),t&&await t.close()},rename:Mm,async readdir(e){return vm(e)},readFile:Nm,async stat(e){let t=await Lm(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:()=>t.isDirectory()}},async mkdir(e,t){await wm(e,t)},unlink:Um,rmdir:Hm,utimes:Dm,async fsyncDir(e){if(process.platform==="win32")return;let t=await Wi(e,"r");try{await t.sync()}finally{await t.close()}}}}function zi(e){let t=$n.get(e);if(!t)throw new Error("closed");return t}var Zi=4,Qi=10;function jn(e=process.platform){return e==="win32"?Zi:Qi}var Bn=6e4,Yt=2e3,ea="slots",_o=64;function ta(e){return qi(e,".ev-ai","agent-hook",ea)}function Kn(e,t){return qi(e,`slot-${t}`)}function Gn(e,t){return`${e}
15
15
  ${t}
16
- `}function mo(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}function ea(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}var Pm=/^(\d+)\n(\d+)\n$/;function wm(e){let t=Pm.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}function ta(e,t,n){let r=wm(e);if(!r)return Math.abs(n-t)<zt;let o=n-r.acquiredAtMs;return o<-zt||o>=$n?!1:ea(r.pid)}import{createHash as Nm,randomBytes as vm}from"node:crypto";import{existsSync as Kn,mkdirSync as Mm,readdirSync as Lm,readFileSync as Hm,renameSync as na,statSync as ia,unlinkSync as ra,writeFileSync as Um}from"node:fs";import{homedir as aa}from"node:os";import{basename as Dm,dirname as oa,isAbsolute as Fm,join as ca,relative as ua,resolve as Ue,sep as $m}from"node:path";function E(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
17
- `)}function Jt(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}function Yt(e){return Nm("sha256").update(e).digest("hex").slice(0,32)}function ce(e,t){Mm(oa(e),{recursive:!0});let n=ca(oa(e),`.${Dm(e)}.${process.pid}.${vm(4).toString("hex")}.tmp`);try{Um(n,t,"utf8");try{na(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){ra(e),na(n,e);return}throw r}}catch(r){try{ra(n)}catch{}throw r}}function Gn(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}var la;function _o(){(la?.stdout??process.stdout).write('{"continue":true}')}var Xt=new Set(["on","1","true"]),fa=new Set(["off","0","false"]);function M(e){let t=process.env[e];return t===void 0||t===""?void 0:t}async function qt(){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()})}async function Vn(e){let t=la?.stdin??process.stdin;return new Promise(n=>{let r="",o=!1,s=a=>{o||(o=!0,clearTimeout(i),n(a||"{}"))},i=setTimeout(()=>{s(r)},e);if(t.isTTY){s("{}");return}t.setEncoding("utf8"),t.on("data",a=>{r+=a}),t.on("end",()=>{s(r)}),t.on("error",()=>{s(r)}),t.resume()})}async function Ce(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:s}=await import("node:util"),i=s(o);try{let{stdout:a}=await i(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:a.trim()}}catch(a){let c=a,l=typeof c.code=="number"?c.code:typeof c.status=="number"?c.status:void 0;return{ok:!1,code:l,spawnFailed:l===void 0}}}async function ne(e,t,n=3e3,r={}){let o=await Ce(e,t,n,r);return o.ok?o.stdout:""}function go(e,t){let n=Ue(e),r=Ue(t),o=ua(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${$m}`)||Fm(o)?!1:Ue(r,o)===n}function da(e,t,n=aa()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return Ue(e);let o=Ue(r),s=Ue(e);if(go(s,o))return s;let i=t.CURSOR_PLUGIN_ROOT?.trim();return go(s,Ue(n,".cursor"))||i!==void 0&&i.length>0&&go(s,Ue(i))?o:s}async function ho(e=process.cwd(),t=process.env,n=aa()){let r=da(e,t,n),o=r!==Ue(e)&&Kn(r)?r:e,s=await Ce("git",["rev-parse","--show-toplevel"],2e3,{cwd:o});if(s.ok&&s.stdout)return{root:s.stdout,inGitRepo:!0};if(M("EV_AI_HOOK_DEBUG")){let a=s.ok?"empty stdout":s.spawnFailed?"spawn failed":`exit ${String(s.code??"unknown")}`;E(`DEBUG: git rev-parse --show-toplevel failed (${a}) cwd=${e}`)}let i=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||M("CURSOR_PROJECT_DIR")||M("CLAUDE_PROJECT_DIR");if(i&&Kn(i)){let a=await Ce("git",["rev-parse","--show-toplevel"],2e3,{cwd:i});return a.ok&&a.stdout?{root:a.stdout,inGitRepo:!0}:{root:i,inGitRepo:!1}}return{root:e,inGitRepo:!1}}async function De(e=process.cwd()){return(await ho(e)).root}function he(e,t){try{return JSON.parse(e)}catch{return t}}var sa=new Map;function Wn(e){return e.charCodeAt(0)===65279?e.slice(1):e}function jm(e){let t;try{t=Hm(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(Wn(t))}}catch{return{ok:!1,reason:"parse"}}}function pa(e){let t=sa.get(e);if(t!==void 0)return t;let n=jm(e);return sa.set(e,n),n}function ma(e){return pa(e)}function Z(e,t){let n=pa(e);return n.ok?n.value:t}function lt(e){return typeof e=="string"?e:""}function Fe(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 s of r){if(o===null||typeof o!="object"||Array.isArray(o))return;o=o[s]}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o}function L(e,t){let n=Fe(e,t);return typeof n=="string"?n:""}var Ze=500;function ga(e,t=2){if(!Kn(e))return{entries:[],truncated:!1};let n=[],r=!1,o=(s,i)=>{if(i>t||r)return;let a;try{a=Lm(s,{withFileTypes:!0})}catch{return}for(let c of a){if(r)return;let l=ca(s,c.name);if(c.isDirectory()){o(l,i+1);continue}if(c.isFile()){try{n.push({name:ua(e,l),size:ia(l).size})}catch{continue}if(n.length>=Ze){r=!0;return}}}};return o(e,1),{entries:n,truncated:r}}function So(e){return Kn(e)?{present:!0,size:ia(e).size}:{present:!1,size:0}}var Sa="https://hooks.ev-ai.ai",zn=".claude/ev-ai-runtime-report.json",Ea="config.json",Vm="max_concurrent_hooks",Gx=1024*1024,Wm=new Set(["localhost","127.0.0.1","[::1]","::1"]),zm=["claude","cursor","codex"],Jn=[zn,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],Eo=/^[A-Za-z0-9._~-]+$/;function Yn(e){return e!==void 0&&zm.includes(e)}function ya(e){if(!e||typeof e!="object")return;let t=e[Vm];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}function _a(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function kt(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function yo(e){let t,n,r,o,s,i,a;for(let c=0;c<e.length;c++){let l=e[c];if(l!==void 0){if(l==="--runner"){let u=kt(e,c);t=u.value,c=u.next;continue}if(l.startsWith("--runner=")){t=l.slice(9);continue}if(l==="--url"){let u=kt(e,c);u.value&&(r=u.value),c=u.next;continue}if(l.startsWith("--url=")){r=l.slice(6);continue}if(l==="--token"){let u=kt(e,c);u.value&&(o=u.value),c=u.next;continue}if(l.startsWith("--token=")){o=l.slice(8);continue}if(l==="--base-url"){let u=kt(e,c);u.value&&(s=u.value),c=u.next;continue}if(l.startsWith("--base-url=")){s=l.slice(11);continue}if(l===Un){let u=kt(e,c);i=_a(u.value)??i,c=u.next;continue}if(l.startsWith(`${Un}=`)){i=_a(l.slice(Un.length+1))??i;continue}if(l===Vt){let u=kt(e,c);a=mo(u.value)??a,c=u.next;continue}if(l.startsWith(`${Vt}=`)){a=mo(l.slice(Vt.length+1))??a;continue}l!==Bi&&!l.startsWith("-")&&n===void 0&&(n=l)}}return{runner:Yn(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:s,...i!==void 0?{cap:i}:{},...a!==void 0?{slot:a}:{}}}function Xn(e,t=Sa){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}function xt(e=Km()){return Gm(e,".ev-ai",Ea)}function Ra(e,t){return{...e,...t}}function ha(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}function qn(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?Wm.has(t.hostname):!1}catch{return!1}}function Ro(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}}function ft(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!qn(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Ro(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Eo.test(n))return`org token must match ${Eo.source} (got: ${n})`;if(ha(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(ha(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function Ot(e){return new URL(e).toString()}function Co(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?Xn(n):""}function Zn(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>"}}function Ca(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=Xn(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=ft(n);return r?{problem:r}:{url:Ot(n)}}var Jm="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",Ym="COLLECTOR_URL",Xm=[Ym,Jm];function Aa(e){let t;for(let n of Xm){let r=e[n]?.trim();if(!r)continue;let o=ft(r);if(o){t??={problem:o,envName:n};continue}return{url:Ot(r),envName:n}}return t??{}}function Zt(e){if(ft(e))return;let t;try{t=new URL(e)}catch{return}let n=Ro(e);if(!n)return;let o=t.pathname.split("/").filter(a=>a.length>0).slice(0,-2),s=o.length>0?`/${o.join("/")}`:"",i=`${t.origin}${s}/${n}`;return Bm("sha256").update(i).digest("hex").slice(0,32)}var Qe=2,ba="node_modules/@ev-ai/agent-hook/dist/hook.mjs",Se="ev-ai-agent-hook";function qm(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}function Qn(e){let t=qm(e);return t===Se||t===`${Se}.exe`}var ka="https://cdn.ev-ai.ai/agent-hook";var Ao=`current/${Se}`,bo=`.ev-ai/agent-hook/${Se}`,xa=5e3,Oa=5e3,ko=3e3;var er=3e3,Ia=1500,Ta=4*1024,xo=256*1024,Zm=4*1024,Pa=32*1024,$e="1.3.8",tr=`@ev-ai/agent-hook@${$e}`,wa="ev-ai runtime report";var Na={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT"};import{chmodSync as yc,cpSync as Rc,existsSync as et,mkdirSync as $o,readFileSync as __,rmSync as lr,symlinkSync as h_,writeFileSync as S_}from"node:fs";import{homedir as je}from"node:os";import{dirname as jo,isAbsolute as E_,join as V,relative as Cc,resolve as Sc,sep as y_}from"node:path";import{fileURLToPath as R_}from"node:url";import{existsSync as Qm,readdirSync as va}from"node:fs";import{homedir as nr}from"node:os";import{join as ue}from"node:path";function Ma(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return ue(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}function Oo(e=process.platform){let t=Ma(e),n=[ue(t,"managed-settings.json")],r=ue(t,"managed-settings.d");try{if(!Qm(r))return n;let o=va(r).filter(s=>s.endsWith(".json")&&!s.startsWith(".")).sort().map(s=>ue(r,s));n.push(...o)}catch{}return n}function Qt(e=process.platform,t=nr()){return{serverManaged:ue(t,".claude","remote-settings.json"),fileBased:Oo(e)}}function eg(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return ue(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}function tg(e=process.platform,t=nr()){let n=[ue(eg(e),"hooks.json")],r=ue(t,".cursor","managed");try{for(let o of va(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(ue(r,o.name,"hooks.json"))}catch{}return n}function ng(e=process.platform,t=nr()){let n=e==="win32"?ue(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[ue(n,"requirements.toml")];return e!=="win32"&&r.push(ue(n,"managed_config.toml")),r.push(ue(t,".codex","managed_config.toml"),ue(n,"config.toml")),r}function rr(e,t=process.platform,n=nr()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=Qt(t,n);return[r,...o]}case"cursor":return tg(t,n);default:return ng(t,n)}}import{createHash as za,randomBytes as kg}from"node:crypto";import{existsSync as Ja,mkdirSync as Po,readFileSync as Ya,unlinkSync as Xa,writeFileSync as qa}from"node:fs";import{homedir as wo}from"node:os";import{dirname as ir,join as No,resolve as xg}from"node:path";var rg=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),og=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]")||og.has(n)||r.includes("[bot]")||rg.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),s=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(s.endsWith("bot")||s.includes("[bot]"))return!0}return!1}import{existsSync as ag,readFileSync as cg}from"node:fs";import{hostname as Ua,release as ug,userInfo as lg,version as fg}from"node:os";import*as ae from"node:os";import{performance as Io}from"node:perf_hooks";var sg=1024*1024,ig=128;function or(e){return Math.round(e/sg)}function en(e,t){let n=10**t;return Math.round(e*n)/n}function La(e=process.platform){try{let t=Io.now(),n={},r=0,o=0,s=e!=="win32";for(let{times:c}of ae.cpus())r+=c.user+c.nice+c.sys+(s?c.irq:0),o+=c.idle;if(r+o>0&&(n.cpu_busy_ms=Math.round(r),n.cpu_idle_ms=Math.round(o)),n.uptime_s=Math.round(ae.uptime()),n.mem_free_mb=or(ae.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=or(process.availableMemory())),e!=="win32"){let[c,l,u]=ae.loadavg();n.load_1m=en(c??0,2),n.load_5m=en(l??0,2),n.load_15m=en(u??0,2)}let i=process.resourceUsage();n.proc_cpu_user_ms=Math.round(i.userCPUTime/1e3),n.proc_cpu_sys_ms=Math.round(i.systemCPUTime/1e3),n.proc_max_rss_mb=Math.round(i.maxRSS/1024),n.proc_page_faults=i.majorPageFault,e!=="win32"&&(n.proc_invol_ctx=i.involuntaryContextSwitches);let a=Io.nodeTiming?.bootstrapComplete;return typeof a=="number"&&a>0&&(n.node_boot_ms=en(a,1)),n.sample_us=Math.round((Io.now()-t)*1e3),n}catch{return}}function Ha(){try{let e=ae.cpus(),t={},n=typeof ae.availableParallelism=="function"?ae.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,ig);r&&(t.cpu_model=r);let o=ae.totalmem();t.mem_total_mb=or(o);let s=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof s=="number"&&s>0&&s<o&&(t.mem_limit_mb=or(s)),t.uptime_h=en(ae.uptime()/3600,1),t}catch{return{}}}function It(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function Da(e=process.env){return It(X("CURSOR_SANDBOX",e))}var dg=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function pg(e){return dg.some(t=>!!X(t,e))}function mg(e){if(X("KUBERNETES_SERVICE_HOST",e)||It(X("REMOTE_CONTAINERS",e))||It(X("DEVCONTAINER",e)))return!0;try{if(ag("/.dockerenv")||cg("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}function Fa(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!X(t,e))}function gg(e,t=process.platform){return Fa(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!X(n,e)):!1}function _g(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}function hg(e){return e==="linux"}function X(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return M(e)}function Sg(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!Eg(X("CURSOR_VERSION",n))}function Eg(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function To(e){if(_g(e.sessionId))return!0;let t=e.hostname??Ua(),n=e.osUser??ja(e.env);return Sg(t,n,e.env)}function yg(e){return It(X("CURSOR_AGENT",e.env))?!0:To(e)}function Rg(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(X("TERM",e)??X("TERM_PROGRAM",e))||(X("SSH_TTY",e)??X("SSH_CONNECTION",e))||(X("__CFBundleIdentifier",e)??X("XPC_SERVICE_NAME",e))||Fa(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!X(t,e))||X("SESSIONNAME",e))}function tn(e={}){let t=e.env;if(X("GITHUB_ACTIONS",t))return"github_actions";if(It(X("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!gg(t,n)&&yg(e)&&(It(X("CURSOR_AGENT",t))||hg(n)))return"cursor_cloud";if(X("CODESPACES",t)||X("CODESPACE_NAME",t))return"codespaces";if(X("GITLAB_CI",t))return"gitlab_ci";if(pg(t))return"managed";let r=X("CI",t);return r&&r!=="false"&&r!=="0"?"managed":mg(t)?"container":Rg(t)?"interactive":"unknown"}async function $a(){return await ne("systemd-detect-virt",[],1e3)}function ja(e=process.env,t=lg){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""}}var Cg=32;function Ag(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,Cg);return t.length>0?t:null}function bg(){try{return[fg(),ug()].filter(Boolean).join(" ").trim()}catch{return""}}async function Ba(e=!1){let t=Ag(process.platform),n="";if(process.platform==="darwin")n=await ne("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:i}=await import("node:fs"),a=i("/etc/os-release","utf8"),c=a.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],l=a.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];n=c??l??""}catch{n=await ne("lsb_release",["-sd"],1e3).then(i=>i.replace(/^"|"$/g,""))}n||(n=await ne("uname",["-r"],1e3))}else process.platform==="win32"?n=bg():n=await ne("ver",[],1e3);let r=ja(),o=(process.env.SHELL??"").split(/[/\\]/).pop()??"",s="";try{s=await ne("tty",[],500),s.includes("not a tty")&&(s="")}catch{s=""}return{os:t,os_version:n||null,user:r||null,shell:o||null,tty:s||null,...e?Ha():{}}}function sr(){return Ua()}var Og="installation.json",Ig="cloud-bootstrap.lock",Tg=6e4;function Za(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}function ge(e=wo()){return No(e,".ev-ai","agent-hook")}function Pg(e=wo()){return No(ge(e),Og)}function Qa(e){return No(ir(e),Ig)}function ec(){return kg(8).toString("hex")}function Tt(e){return za("sha256").update(e).digest("hex").slice(0,16)}function $(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function tc(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}function wg(e=process.env){let t=$(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!tc(t)){E(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}function nc(e,t){return e&&tc(e)?e:(e&&E(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),wg(t))}function Ng(e){return/^[0-9a-f]{16}$/.test(e)}function vg(e=process.env){if($(e.GITHUB_ACTIONS)){let t=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),n=$(e.GITHUB_ACTOR)??$(e.GITHUB_TRIGGERING_ACTOR)??$(e.GITHUB_USER);if(t&&n)return Tt(`github_actions|${t}|${n}`)}if($(e.CODESPACES)||$(e.CODESPACE_NAME)){let t=$(e.CODESPACE_NAME);if(t)return Tt(`codespaces|${t}`);let n=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),r=$(e.GITHUB_USER)??$(e.GITHUB_ACTOR);if(n&&r)return Tt(`codespaces|${n}|${r}`)}if($(e.GITLAB_CI)){let t=$(e.CI_PROJECT_ID)??$(e.CI_PROJECT_PATH),n=$(e.GITLAB_USER_LOGIN)??$(e.GITLAB_USER_EMAIL)??$(e.GITLAB_USER_NAME);if(t&&n)return Tt(`gitlab|${t}|${n}`)}return null}var Mg="cursoragent@cursor.com";function Lg(e){let t=$(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===Mg?null:t}function Hg(e,t){return $(e.CURSOR_PROJECT_DIR)??$(e.CLAUDE_PROJECT_DIR)??t}function Ug(e){return Jt(e).replace(/\.git$/i,"").toLowerCase()}async function Dg(e){let t=await ne("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?Ug(t):e}async function Fg(e){let t=$(await ne("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!me(null,t))return t;let n=$(await ne("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!me(null,n)?n:null}function $g(e,t){let n=Hg(e,t);return n?Tt(`cursor_cloud|${n}|${Lg(e)??""}`):null}async function jg(e,t){let n=$(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await Dg(n),o=await Fg(n);return Tt(`claude_remote|${r}|${o??""}`)}function Ka(e,t){let n=nc(e,t);if(n)return n;let r=vg(t);return r||ec()}async function Bg(e){let n=await ne("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||xg(e);return za("sha256").update(n).digest("hex").slice(0,16)}function Kg(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}function Gg(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=Kg(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}:{}}}catch{return}}function dt(e){if(Ja(e))try{return Gg(Ya(e,"utf8"))}catch{}}function vo(e){return dt(e)}function rc(e,t,n){let r=dt(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{ce(e,`${JSON.stringify(o,null,2)}
18
- `)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: operator identity cache write failed open: ${i}`)}}function oc(e,t=Date.now()){if(!e)return!0;if(dt(e)?.operator_identity_hash)return!1;let n=Qa(e);try{if(Ja(n)){let r=Number.NaN;try{r=Number(Ya(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<Tg)return!1;try{Xa(n)}catch{}}}catch{}try{return Po(ir(n),{recursive:!0}),qa(n,`${t}
19
- `,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(cc(r))return!1;let o=r instanceof Error?r.message:String(r);return E(`WARN: cloud bootstrap claim failed open: ${o}`),!0}}function sc(e){if(e)try{Xa(Qa(e))}catch{}}function ic(e,t){let r=dt(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}function ac(e,t,n){if(!n)return;let r=dt(e);if(!r||r.platform_agent_ids?.[t]===n)return;let o={installation_id:r.installation_id,platform_agent_ids:{...r.platform_agent_ids,[t]:n},...r.operator_identity_hash?{operator_identity_hash:r.operator_identity_hash}:{},...r.operator_identity_sent_at?{operator_identity_sent_at:r.operator_identity_sent_at}:{}};try{ce(e,`${JSON.stringify(o,null,2)}
20
- `)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: platform_agent_id cache write failed open: ${i}`)}}function cc(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}function Vg(e,t){Po(ir(e),{recursive:!0}),qa(e,`${JSON.stringify(t,null,2)}
21
- `,{encoding:"utf8",flag:"wx"})}function Ga(e,t){try{return Vg(e,t),t}catch(n){if(!cc(n))throw n;return dt(e)}}function Va(e,t){Po(ir(e),{recursive:!0}),ce(e,`${JSON.stringify(t,null,2)}
22
- `)}function Wa(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}async function ar(e,t={}){let n=t.home??wo(),r=t.env??process.env,o=await Bg(e),s=Pg(n),i={sessionId:t.sessionId,hostname:$(r.HOSTNAME)??void 0,osUser:$(r.USER)??$(r.LOGNAME)??$(r.USERNAME)??void 0,env:r},a=tn(i),c=nc(t.overrideId,r),l=a==="cursor_cloud"&&To(i)?$g(r,e):a==="claude_remote"?await jg(r,e):null,u=dt(s);if(u){let S=u;if(c&&c===u.installation_id&&u.pinned!==!0&&(S={...u,pinned:!0},Va(s,S)),!!l&&l!==S.installation_id&&!c&&S.pinned!==!0&&Ng(S.installation_id)&&l){let b={installation_id:l,...S.platform_agent_ids?{platform_agent_ids:S.platform_agent_ids}:{}};return Va(s,b),{installationId:l,storePath:s,repoKey:o}}return{installationId:S.installation_id,storePath:s,repoKey:o}}let d=c??l??Ka(void 0,r),f=Ga(s,Wa(d,c));if(f)return{installationId:f.installation_id,storePath:s,repoKey:o};let p=c??l??Ka(void 0,r),g=Ga(s,Wa(p===d?ec():p,c));if(g)return{installationId:g.installation_id,storePath:s,repoKey:o};throw new Error(`Failed to create installation record at ${s}`)}import{existsSync as Ho,readFileSync as r_}from"node:fs";import{dirname as o_,isAbsolute as s_,join as i_,relative as a_}from"node:path";import{readFileSync as Wg,statSync as zg}from"node:fs";import{homedir as Mo}from"node:os";import{join as Jg}from"node:path";var Yg="hook-config.json",Xg=1440*60*1e3,qg=2048,Zg=1024*1024;function Pt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function uc(e=Mo()){return Jg(ge(e),Yg)}function lc(e){let t=uc(e);try{let n=zg(t);if(!n.isFile()||n.size>Zg)return;let r=JSON.parse(Wg(t,"utf8"));return Pt(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}function Qg(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),t}function cr(e,t=Mo()){if(!e)return;let n=Zt(e);if(!n)return;let r=lc(t),o=r?r[n]:void 0;if(!(!Pt(o)||!Pt(o.config)))return Qg(o.config)}function e_(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!Pt(n)||!Pt(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>qg))return n.hook_config}function t_(e,t,n,r){let o={...e},s=o[t];if(Object.keys(n).length===0)return s===void 0?void 0:(delete o[t],o);if(!(Pt(s)&&JSON.stringify(s.config)===JSON.stringify(n)&&typeof s.fetched_at_ms=="number"&&s.fetched_at_ms<=r&&r-s.fetched_at_ms<Xg))return o[t]={config:n,fetched_at_ms:r},o}function fc(e,t,n=Mo(),r=Date.now()){let o=e_(e),s=t?Zt(t):void 0;if(o===void 0||!s)return"skipped";try{let i=lc(n);if(i===void 0)return"skipped";let a=t_(i??{},s,o,r);return a?(ce(uc(n),`${JSON.stringify(a,null,2)}
23
- `),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(i){let a=i instanceof Error?i.message:String(i);return E(`WARN: hook config write failed open: ${a}`),"failed"}}var n_="EV_AI_HOOK_TELEMETRY";function dc(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}function pc(e,t,n=process.env){let r=n[n_]?.trim().toLowerCase();return r&&Xt.has(r)?{enabled:!0,source:"env"}:r&&fa.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"}}function mc(e){for(let t of Jn){let n=i_(e,t);if(Ho(n))return n}}async function c_(e=process.cwd(),t){let n=t??await De(e);return mc(n)??mc(e)}async function u_(e,t){let n=t??await De(o_(e)),r=a_(n,e);if(r.startsWith("..")||s_(r))return!1;let o=await Ce("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(E(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}function Lo(e){let t=r_(e,"utf8");return he(Wn(t),{})}function l_(){return{schema_version:Qe,mcp_servers:[]}}function f_(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(E(`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")&&(E(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}function d_(){let e=Aa(process.env);return e.problem&&E(`WARN: ignoring ${e.envName}: ${e.problem}`),e.url??""}async function gc(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await ho(e),o=M("EV_AI_HOOK_MANIFEST"),s=o&&Ho(o)?o:void 0,i=s?void 0:Ho(xt())?xt():void 0,a=s?void 0:await c_(e,n),c=i?Lo(i):void 0,l=a?Lo(a):void 0,u=dc(s?Z(xt(),{}):c),d,f,p,g=new Set;if(s){d=Lo(s),f=s,p=s;for(let I of Object.keys(d))g.add(I)}else if(c&&l){d=Ra(l,c),f=i,p=a;for(let I of Object.keys(l))I in c||g.add(I)}else if(c)d=c,f=i;else if(l){d=l,f=a,p=a;for(let I of Object.keys(l))g.add(I)}else d=l_();delete d.installation_id;let S=p?await u_(p,n):!1;f_(d,p,S,g);let{installationId:A,storePath:b,repoKey:O}=await ar(n,{sessionId:t.sessionId}),P=Co(d)||d_();return{manifestPath:f??b,manifest:d,installationId:A,installationStorePath:b,repoKey:O,collectorUrl:P,hookConfig:cr(P),...u!==void 0?{localTelemetry:u}:{},platformAgentId:d.platform_agent_id??"",gitRoot:n,inGitRepo:r}}function _c(e){return{schema_version:Qe,...e?{collector_url:e}:{},mcp_servers:[]}}var p_=["darwin-arm64","darwin-x64","linux-arm64","linux-x64","windows-x64","windows-arm64"];function m_(e){return e==="windows-x64"||e==="windows-arm64"}function Uo(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}function hc(e=process.platform,t=process.arch){let n=Uo(e,t);if(!n)throw new Error(`Unsupported platform ${e}-${t}. Supported: ${p_.join(", ")}.`);return n}function g_(e){return m_(e)?`${Se}.exe`:Se}function Do(e){return`compile-out/bin/${e}/${g_(e)}`}function C_(e,t){let n=e.collectorUrl?.trim();if(!n)throw new Error(`${t} requires --url <https://hooks.ev-ai.ai/{orgToken}/hook>`);let r=ft(n);if(r)throw new Error(`collector URL rejected: ${r}`);return Ot(n)}function A_(e){let t=e.collectorUrl?.trim();if(!t)return;let n=ft(t);if(n)throw new Error(`collector URL rejected: ${n}`);return Ot(t)}function b_(e){return C_(e,"install")}function Ac(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}function bc(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}function kc(e=process.execPath){return xc(e)?"binary":"npx"}function k_(){return V(je(),".ev-ai","agent-hook")}function x_(e=je()){return V(e,".ev-ai","agent-hook",Ao)}function O_(){let e=jo(R_(import.meta.url)),t=V(e,"hook.mjs");return et(t)?t:V(e,"..","dist","hook.mjs")}function xc(e=process.execPath){return Qn(e)}function Oc(e,t){let n=Cc(Sc(e),Sc(t));return!n.startsWith("..")&&!E_(n)}function fr(e){return e.split(y_).join("/")}function I_(e){return`node "$(git rev-parse --show-toplevel)/${fr(e)}"`}function T_(e){return`"$(git rev-parse --show-toplevel)/${fr(e)}"`}function P_(e){return V(e,bo)}function Ic(e,t){let n=P_(e);$o(jo(n),{recursive:!0}),Rc(t,n,{force:!0});try{yc(n,493)}catch{}return n}function w_(e){let t=V(k_(),"current");try{lr(t,{recursive:!0,force:!0})}catch{}h_(e,t,process.platform==="win32"?"junction":"dir")}function Tc(e,t=$e,n=je()){let r=V(n,".ev-ai","agent-hook",t),o=V(r,Se);$o(r,{recursive:!0}),Rc(e,o,{force:!0});try{yc(o,493)}catch{}return w_(r),V(n,".ev-ai","agent-hook",Ao)}function Pc(e){let t=Uo();if(!t)return;let n=[V(e,Do(t)),V(e,"packages","agent-hook",Do(t))];for(let r of n)if(et(r)&&Oc(e,r))return r}function N_(e=je()){let t=x_(e);return et(t)?t:void 0}function v_(e,t=je()){let n=N_(t);return n||(xc()?Tc(process.execPath,$e,t):Pc(e))}function M_(e,t=je()){let n=Pc(e);if(!n)throw new Error(`update requires a locally compiled binary \u2014 run this package\u2019s build:hook-binary script first.
24
- To install a released binary instead: curl -fsSL https://cdn.ev-ai.ai/agent-hook/install.sh | sh`);let r=Tc(n,$e,t),o=Ic(e,n);return{sourcePath:n,projectPath:o,globalPath:r}}function Ec(e){let t=[V(e,"packages","agent-hook","dist","hook.mjs"),V(e,ba)],n=O_();et(n)&&Oc(e,n)&&t.unshift(n);for(let r of t){if(!et(r))continue;let o=fr(Cc(e,r));return{command:I_(o),hookPath:o,strategy:"dev_mjs"}}}function L_(e){return e==="SessionStart"||e==="sessionStart"}function H_(e){return e.replace(/\s+--prefer-offline\b/g,"")}function ur(e,t){return L_(e)?H_(t):t}function U_(e=tr){return`npx -y --prefer-offline ${e}`}function D_(e,t=je(),n=kc()){if(n==="npx")return{command:U_(),hookPath:tr,strategy:"npx"};if(n==="local"){let s=Ec(e);if(s)return s;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=v_(e,t);if(r){Ic(e,r);let s=fr(bo);return{command:T_(s),hookPath:s,strategy:"project_binary"}}let o=Ec(e);if(o)return o;throw new Error(`ev-ai-agent-hook binary not found. Install from CDN:
25
- curl -fsSL ${ka}/install.sh | sh
16
+ `}function ho(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}function na(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}var Fm=/^(\d+)\n(\d+)\n$/;function $m(e){let t=Fm.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}function ra(e,t,n){let r=$m(e);if(!r)return Math.abs(n-t)<Yt;let o=n-r.acquiredAtMs;return o<-Yt||o>=Bn?!1:na(r.pid)}import{createHash as jm,randomBytes as Bm}from"node:crypto";import{existsSync as Vn,mkdirSync as Km,readdirSync as Gm,readFileSync as Vm,renameSync as oa,statSync as ca,unlinkSync as sa,writeFileSync as Wm}from"node:fs";import{homedir as ua}from"node:os";import{basename as zm,dirname as ia,isAbsolute as Jm,join as la,relative as fa,resolve as De,sep as Ym}from"node:path";function E(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
17
+ `)}function Xt(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}function qt(e){return jm("sha256").update(e).digest("hex").slice(0,32)}function ce(e,t){Km(ia(e),{recursive:!0});let n=la(ia(e),`.${zm(e)}.${process.pid}.${Bm(4).toString("hex")}.tmp`);try{Wm(n,t,"utf8");try{oa(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){sa(e),oa(n,e);return}throw r}}catch(r){try{sa(n)}catch{}throw r}}function Wn(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}var da;function Eo(){(da?.stdout??process.stdout).write('{"continue":true}')}var Zt=new Set(["on","1","true"]),pa=new Set(["off","0","false"]);function M(e){let t=process.env[e];return t===void 0||t===""?void 0:t}async function Qt(){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()})}async function zn(e){let t=da?.stdin??process.stdin;return new Promise(n=>{let r="",o=!1,s=a=>{o||(o=!0,clearTimeout(i),n(a||"{}"))},i=setTimeout(()=>{s(r)},e);if(t.isTTY){s("{}");return}t.setEncoding("utf8"),t.on("data",a=>{r+=a}),t.on("end",()=>{s(r)}),t.on("error",()=>{s(r)}),t.resume()})}async function Ae(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:s}=await import("node:util"),i=s(o);try{let{stdout:a}=await i(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:a.trim()}}catch(a){let c=a,l=typeof c.code=="number"?c.code:typeof c.status=="number"?c.status:void 0;return{ok:!1,code:l,spawnFailed:l===void 0}}}async function ne(e,t,n=3e3,r={}){let o=await Ae(e,t,n,r);return o.ok?o.stdout:""}function So(e,t){let n=De(e),r=De(t),o=fa(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${Ym}`)||Jm(o)?!1:De(r,o)===n}function ma(e,t,n=ua()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return De(e);let o=De(r),s=De(e);if(So(s,o))return s;let i=t.CURSOR_PLUGIN_ROOT?.trim();return So(s,De(n,".cursor"))||i!==void 0&&i.length>0&&So(s,De(i))?o:s}async function yo(e=process.cwd(),t=process.env,n=ua()){let r=ma(e,t,n),o=r!==De(e)&&Vn(r)?r:e,s=await Ae("git",["rev-parse","--show-toplevel"],2e3,{cwd:o});if(s.ok&&s.stdout)return{root:s.stdout,inGitRepo:!0};if(M("EV_AI_HOOK_DEBUG")){let a=s.ok?"empty stdout":s.spawnFailed?"spawn failed":`exit ${String(s.code??"unknown")}`;E(`DEBUG: git rev-parse --show-toplevel failed (${a}) cwd=${e}`)}let i=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||M("CURSOR_PROJECT_DIR")||M("CLAUDE_PROJECT_DIR");if(i&&Vn(i)){let a=await Ae("git",["rev-parse","--show-toplevel"],2e3,{cwd:i});return a.ok&&a.stdout?{root:a.stdout,inGitRepo:!0}:{root:i,inGitRepo:!1}}return{root:e,inGitRepo:!1}}async function Fe(e=process.cwd()){return(await yo(e)).root}function Se(e,t){try{return JSON.parse(e)}catch{return t}}var aa=new Map;function Jn(e){return e.charCodeAt(0)===65279?e.slice(1):e}function Xm(e){let t;try{t=Vm(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(Jn(t))}}catch{return{ok:!1,reason:"parse"}}}function ga(e){let t=aa.get(e);if(t!==void 0)return t;let n=Xm(e);return aa.set(e,n),n}function _a(e){return ga(e)}function q(e,t){let n=ga(e);return n.ok?n.value:t}function pt(e){return typeof e=="string"?e:""}function $e(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 s of r){if(o===null||typeof o!="object"||Array.isArray(o))return;o=o[s]}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o}function L(e,t){let n=$e(e,t);return typeof n=="string"?n:""}var et=500;function ha(e,t=2){if(!Vn(e))return{entries:[],truncated:!1};let n=[],r=!1,o=(s,i)=>{if(i>t||r)return;let a;try{a=Gm(s,{withFileTypes:!0})}catch{return}for(let c of a){if(r)return;let l=la(s,c.name);if(c.isDirectory()){o(l,i+1);continue}if(c.isFile()){try{n.push({name:fa(e,l),size:ca(l).size})}catch{continue}if(n.length>=et){r=!0;return}}}};return o(e,1),{entries:n,truncated:r}}function Ro(e){return Vn(e)?{present:!0,size:ca(e).size}:{present:!1,size:0}}var Ca="https://hooks.ev-ai.ai",Yn=".claude/ev-ai-runtime-report.json",Aa="config.json",eg="max_concurrent_hooks",uO=1024*1024,tg=new Set(["localhost","127.0.0.1","[::1]","::1"]),ng=["claude","cursor","codex"],Xn=[Yn,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],Co=/^[A-Za-z0-9._~-]+$/;function qn(e){return e!==void 0&&ng.includes(e)}function ba(e){if(!e||typeof e!="object")return;let t=e[eg];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}function Sa(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function It(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function Zn(e){let t,n,r,o,s,i,a;for(let c=0;c<e.length;c++){let l=e[c];if(l!==void 0){if(l==="--runner"){let u=It(e,c);t=u.value,c=u.next;continue}if(l.startsWith("--runner=")){t=l.slice(9);continue}if(l==="--url"){let u=It(e,c);u.value&&(r=u.value),c=u.next;continue}if(l.startsWith("--url=")){r=l.slice(6);continue}if(l==="--token"){let u=It(e,c);u.value&&(o=u.value),c=u.next;continue}if(l.startsWith("--token=")){o=l.slice(8);continue}if(l==="--base-url"){let u=It(e,c);u.value&&(s=u.value),c=u.next;continue}if(l.startsWith("--base-url=")){s=l.slice(11);continue}if(l===Fn){let u=It(e,c);i=Sa(u.value)??i,c=u.next;continue}if(l.startsWith(`${Fn}=`)){i=Sa(l.slice(Fn.length+1))??i;continue}if(l===zt){let u=It(e,c);a=ho(u.value)??a,c=u.next;continue}if(l.startsWith(`${zt}=`)){a=ho(l.slice(zt.length+1))??a;continue}l!==Gi&&!l.startsWith("-")&&n===void 0&&(n=l)}}return{runner:qn(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:s,...i!==void 0?{cap:i}:{},...a!==void 0?{slot:a}:{}}}function Qn(e,t=Ca){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}function mt(e=Zm()){return Qm(e,".ev-ai",Aa)}function ka(e,t){return{...e,...t}}function Ea(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}function er(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?tg.has(t.hostname):!1}catch{return!1}}function Ao(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}}function je(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!er(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Ao(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Co.test(n))return`org token must match ${Co.source} (got: ${n})`;if(Ea(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(Ea(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function tt(e){return new URL(e).toString()}function xa(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?Qn(n):""}function Tt(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>"}}function Oa(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=Qn(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=je(n);return r?{problem:r}:{url:tt(n)}}var rg="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",og="COLLECTOR_URL",ya="collector_url_override",sg=[rg,og];function ig(e){let t;for(let n of sg){let r=e[n]?.trim();if(!r)continue;let o=je(r);if(o){t??={problem:o,envName:n};continue}return{url:tt(r),envName:n}}return t??{}}function Ra(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=je(t);return n?{problem:n}:{url:tt(t)}}function Ia(e){let t=[],n=Ra(e.homeConfig?.[ya]);if(n.problem&&t.push({label:ya,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=Oa(Zn(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=ig(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 s=Ra(e.homeConfig?.collector_url);if(s.problem&&t.push({label:"collector_url",problem:s.problem}),s.url)return{url:s.url,source:"home_config",warnings:t};let i=e.homeConfig?.repo_ingest_token,a=typeof i=="string"&&i.trim()?{...e.manifest,repo_ingest_token:i}:e.manifest,c=a?xa(a):"";if(c){let l=je(c);if(l)t.push({label:"manifest collector_url",problem:l});else return{url:tt(c),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}function en(e){if(je(e))return;let t;try{t=new URL(e)}catch{return}let n=Ao(e);if(!n)return;let o=t.pathname.split("/").filter(a=>a.length>0).slice(0,-2),s=o.length>0?`/${o.join("/")}`:"",i=`${t.origin}${s}/${n}`;return qm("sha256").update(i).digest("hex").slice(0,32)}var nt=2,Ta="node_modules/@ev-ai/agent-hook/dist/hook.mjs",Ee="ev-ai-agent-hook";function ag(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}function tr(e){let t=ag(e);return t===Ee||t===`${Ee}.exe`}var Pa="https://cdn.ev-ai.ai/agent-hook";var bo=`current/${Ee}`,ko=`.ev-ai/agent-hook/${Ee}`,wa=5e3,Na=5e3,xo=3e3;var nr=3e3,va=1500,Ma=4*1024,Oo=256*1024,cg=4*1024,La=32*1024,Be="1.3.9",rr=`@ev-ai/agent-hook@${Be}`,Ha="ev-ai runtime report";var Ua={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT"};import{chmodSync as Tc,cpSync as Pc,existsSync as rt,mkdirSync as Bo,readFileSync as L_,rmSync as pr,symlinkSync as H_,writeFileSync as U_}from"node:fs";import{homedir as Ke}from"node:os";import{dirname as Ko,isAbsolute as D_,join as V,relative as wc,resolve as Oc,sep as F_}from"node:path";import{fileURLToPath as $_}from"node:url";import{existsSync as ug,readdirSync as Da}from"node:fs";import{homedir as or}from"node:os";import{join as ue}from"node:path";function Fa(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return ue(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}function Io(e=process.platform){let t=Fa(e),n=[ue(t,"managed-settings.json")],r=ue(t,"managed-settings.d");try{if(!ug(r))return n;let o=Da(r).filter(s=>s.endsWith(".json")&&!s.startsWith(".")).sort().map(s=>ue(r,s));n.push(...o)}catch{}return n}function tn(e=process.platform,t=or()){return{serverManaged:ue(t,".claude","remote-settings.json"),fileBased:Io(e)}}function lg(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return ue(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}function fg(e=process.platform,t=or()){let n=[ue(lg(e),"hooks.json")],r=ue(t,".cursor","managed");try{for(let o of Da(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(ue(r,o.name,"hooks.json"))}catch{}return n}function dg(e=process.platform,t=or()){let n=e==="win32"?ue(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[ue(n,"requirements.toml")];return e!=="win32"&&r.push(ue(n,"managed_config.toml")),r.push(ue(t,".codex","managed_config.toml"),ue(n,"config.toml")),r}function sr(e,t=process.platform,n=or()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=tn(t,n);return[r,...o]}case"cursor":return fg(t,n);default:return dg(t,n)}}import{createHash as Za,randomBytes as Lg}from"node:crypto";import{existsSync as Qa,mkdirSync as wo,readFileSync as ec,unlinkSync as tc,writeFileSync as nc}from"node:fs";import{homedir as No}from"node:os";import{dirname as cr,join as vo,resolve as Hg}from"node:path";var pg=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),mg=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]")||mg.has(n)||r.includes("[bot]")||pg.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),s=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(s.endsWith("bot")||s.includes("[bot]"))return!0}return!1}import{existsSync as hg,readFileSync as Sg}from"node:fs";import{hostname as Ba,release as Eg,userInfo as yg,version as Rg}from"node:os";import*as ae from"node:os";import{performance as To}from"node:perf_hooks";var gg=1024*1024,_g=128;function ir(e){return Math.round(e/gg)}function nn(e,t){let n=10**t;return Math.round(e*n)/n}function $a(e=process.platform){try{let t=To.now(),n={},r=0,o=0,s=e!=="win32";for(let{times:c}of ae.cpus())r+=c.user+c.nice+c.sys+(s?c.irq:0),o+=c.idle;if(r+o>0&&(n.cpu_busy_ms=Math.round(r),n.cpu_idle_ms=Math.round(o)),n.uptime_s=Math.round(ae.uptime()),n.mem_free_mb=ir(ae.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=ir(process.availableMemory())),e!=="win32"){let[c,l,u]=ae.loadavg();n.load_1m=nn(c??0,2),n.load_5m=nn(l??0,2),n.load_15m=nn(u??0,2)}let i=process.resourceUsage();n.proc_cpu_user_ms=Math.round(i.userCPUTime/1e3),n.proc_cpu_sys_ms=Math.round(i.systemCPUTime/1e3),n.proc_max_rss_mb=Math.round(i.maxRSS/1024),n.proc_page_faults=i.majorPageFault,e!=="win32"&&(n.proc_invol_ctx=i.involuntaryContextSwitches);let a=To.nodeTiming?.bootstrapComplete;return typeof a=="number"&&a>0&&(n.node_boot_ms=nn(a,1)),n.sample_us=Math.round((To.now()-t)*1e3),n}catch{return}}function ja(){try{let e=ae.cpus(),t={},n=typeof ae.availableParallelism=="function"?ae.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,_g);r&&(t.cpu_model=r);let o=ae.totalmem();t.mem_total_mb=ir(o);let s=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof s=="number"&&s>0&&s<o&&(t.mem_limit_mb=ir(s)),t.uptime_h=nn(ae.uptime()/3600,1),t}catch{return{}}}function Pt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function Ka(e=process.env){return Pt(X("CURSOR_SANDBOX",e))}var Cg=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function Ag(e){return Cg.some(t=>!!X(t,e))}function bg(e){if(X("KUBERNETES_SERVICE_HOST",e)||Pt(X("REMOTE_CONTAINERS",e))||Pt(X("DEVCONTAINER",e)))return!0;try{if(hg("/.dockerenv")||Sg("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}function Ga(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!X(t,e))}function kg(e,t=process.platform){return Ga(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!X(n,e)):!1}function xg(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}function Og(e){return e==="linux"}function X(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return M(e)}function Ig(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!Tg(X("CURSOR_VERSION",n))}function Tg(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function Po(e){if(xg(e.sessionId))return!0;let t=e.hostname??Ba(),n=e.osUser??Wa(e.env);return Ig(t,n,e.env)}function Pg(e){return Pt(X("CURSOR_AGENT",e.env))?!0:Po(e)}function wg(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(X("TERM",e)??X("TERM_PROGRAM",e))||(X("SSH_TTY",e)??X("SSH_CONNECTION",e))||(X("__CFBundleIdentifier",e)??X("XPC_SERVICE_NAME",e))||Ga(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!X(t,e))||X("SESSIONNAME",e))}function rn(e={}){let t=e.env;if(X("GITHUB_ACTIONS",t))return"github_actions";if(Pt(X("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!kg(t,n)&&Pg(e)&&(Pt(X("CURSOR_AGENT",t))||Og(n)))return"cursor_cloud";if(X("CODESPACES",t)||X("CODESPACE_NAME",t))return"codespaces";if(X("GITLAB_CI",t))return"gitlab_ci";if(Ag(t))return"managed";let r=X("CI",t);return r&&r!=="false"&&r!=="0"?"managed":bg(t)?"container":wg(t)?"interactive":"unknown"}async function Va(){return await ne("systemd-detect-virt",[],1e3)}function Wa(e=process.env,t=yg){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""}}var Ng=32;function vg(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,Ng);return t.length>0?t:null}function Mg(){try{return[Rg(),Eg()].filter(Boolean).join(" ").trim()}catch{return""}}async function za(e=!1){let t=vg(process.platform),n="";if(process.platform==="darwin")n=await ne("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:i}=await import("node:fs"),a=i("/etc/os-release","utf8"),c=a.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],l=a.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];n=c??l??""}catch{n=await ne("lsb_release",["-sd"],1e3).then(i=>i.replace(/^"|"$/g,""))}n||(n=await ne("uname",["-r"],1e3))}else process.platform==="win32"?n=Mg():n=await ne("ver",[],1e3);let r=Wa(),o=(process.env.SHELL??"").split(/[/\\]/).pop()??"",s="";try{s=await ne("tty",[],500),s.includes("not a tty")&&(s="")}catch{s=""}return{os:t,os_version:n||null,user:r||null,shell:o||null,tty:s||null,...e?ja():{}}}function ar(){return Ba()}var Ug="installation.json",Dg="cloud-bootstrap.lock",Fg=6e4;function rc(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}function ge(e=No()){return vo(e,".ev-ai","agent-hook")}function $g(e=No()){return vo(ge(e),Ug)}function oc(e){return vo(cr(e),Dg)}function sc(){return Lg(8).toString("hex")}function wt(e){return Za("sha256").update(e).digest("hex").slice(0,16)}function $(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function ic(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}function jg(e=process.env){let t=$(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!ic(t)){E(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}function ac(e,t){return e&&ic(e)?e:(e&&E(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),jg(t))}function Bg(e){return/^[0-9a-f]{16}$/.test(e)}function Kg(e=process.env){if($(e.GITHUB_ACTIONS)){let t=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),n=$(e.GITHUB_ACTOR)??$(e.GITHUB_TRIGGERING_ACTOR)??$(e.GITHUB_USER);if(t&&n)return wt(`github_actions|${t}|${n}`)}if($(e.CODESPACES)||$(e.CODESPACE_NAME)){let t=$(e.CODESPACE_NAME);if(t)return wt(`codespaces|${t}`);let n=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),r=$(e.GITHUB_USER)??$(e.GITHUB_ACTOR);if(n&&r)return wt(`codespaces|${n}|${r}`)}if($(e.GITLAB_CI)){let t=$(e.CI_PROJECT_ID)??$(e.CI_PROJECT_PATH),n=$(e.GITLAB_USER_LOGIN)??$(e.GITLAB_USER_EMAIL)??$(e.GITLAB_USER_NAME);if(t&&n)return wt(`gitlab|${t}|${n}`)}return null}var Gg="cursoragent@cursor.com";function Vg(e){let t=$(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===Gg?null:t}function Wg(e,t){return $(e.CURSOR_PROJECT_DIR)??$(e.CLAUDE_PROJECT_DIR)??t}function zg(e){return Xt(e).replace(/\.git$/i,"").toLowerCase()}async function Jg(e){let t=await ne("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?zg(t):e}async function Yg(e){let t=$(await ne("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!me(null,t))return t;let n=$(await ne("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!me(null,n)?n:null}function Xg(e,t){let n=Wg(e,t);return n?wt(`cursor_cloud|${n}|${Vg(e)??""}`):null}async function qg(e,t){let n=$(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await Jg(n),o=await Yg(n);return wt(`claude_remote|${r}|${o??""}`)}function Ja(e,t){let n=ac(e,t);if(n)return n;let r=Kg(t);return r||sc()}async function Zg(e){let n=await ne("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||Hg(e);return Za("sha256").update(n).digest("hex").slice(0,16)}function Qg(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}function e_(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=Qg(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}:{}}}catch{return}}function gt(e){if(Qa(e))try{return e_(ec(e,"utf8"))}catch{}}function Mo(e){return gt(e)}function cc(e,t,n){let r=gt(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{ce(e,`${JSON.stringify(o,null,2)}
18
+ `)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: operator identity cache write failed open: ${i}`)}}function uc(e,t=Date.now()){if(!e)return!0;if(gt(e)?.operator_identity_hash)return!1;let n=oc(e);try{if(Qa(n)){let r=Number.NaN;try{r=Number(ec(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<Fg)return!1;try{tc(n)}catch{}}}catch{}try{return wo(cr(n),{recursive:!0}),nc(n,`${t}
19
+ `,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(pc(r))return!1;let o=r instanceof Error?r.message:String(r);return E(`WARN: cloud bootstrap claim failed open: ${o}`),!0}}function lc(e){if(e)try{tc(oc(e))}catch{}}function fc(e,t){let r=gt(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}function dc(e,t,n){if(!n)return;let r=gt(e);if(!r||r.platform_agent_ids?.[t]===n)return;let o={installation_id:r.installation_id,platform_agent_ids:{...r.platform_agent_ids,[t]:n},...r.operator_identity_hash?{operator_identity_hash:r.operator_identity_hash}:{},...r.operator_identity_sent_at?{operator_identity_sent_at:r.operator_identity_sent_at}:{}};try{ce(e,`${JSON.stringify(o,null,2)}
20
+ `)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: platform_agent_id cache write failed open: ${i}`)}}function pc(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}function t_(e,t){wo(cr(e),{recursive:!0}),nc(e,`${JSON.stringify(t,null,2)}
21
+ `,{encoding:"utf8",flag:"wx"})}function Ya(e,t){try{return t_(e,t),t}catch(n){if(!pc(n))throw n;return gt(e)}}function Xa(e,t){wo(cr(e),{recursive:!0}),ce(e,`${JSON.stringify(t,null,2)}
22
+ `)}function qa(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}async function ur(e,t={}){let n=t.home??No(),r=t.env??process.env,o=await Zg(e),s=$g(n),i={sessionId:t.sessionId,hostname:$(r.HOSTNAME)??void 0,osUser:$(r.USER)??$(r.LOGNAME)??$(r.USERNAME)??void 0,env:r},a=rn(i),c=ac(t.overrideId,r),l=a==="cursor_cloud"&&Po(i)?Xg(r,e):a==="claude_remote"?await qg(r,e):null,u=gt(s);if(u){let S=u;if(c&&c===u.installation_id&&u.pinned!==!0&&(S={...u,pinned:!0},Xa(s,S)),!!l&&l!==S.installation_id&&!c&&S.pinned!==!0&&Bg(S.installation_id)&&l){let b={installation_id:l,...S.platform_agent_ids?{platform_agent_ids:S.platform_agent_ids}:{}};return Xa(s,b),{installationId:l,storePath:s,repoKey:o}}return{installationId:S.installation_id,storePath:s,repoKey:o}}let d=c??l??Ja(void 0,r),f=Ya(s,qa(d,c));if(f)return{installationId:f.installation_id,storePath:s,repoKey:o};let p=c??l??Ja(void 0,r),g=Ya(s,qa(p===d?sc():p,c));if(g)return{installationId:g.installation_id,storePath:s,repoKey:o};throw new Error(`Failed to create installation record at ${s}`)}import{existsSync as Do,readFileSync as R_}from"node:fs";import{dirname as C_,isAbsolute as A_,join as b_,relative as k_}from"node:path";import{readFileSync as n_,statSync as r_}from"node:fs";import{homedir as Lo}from"node:os";import{join as o_}from"node:path";var s_="hook-config.json",i_=1440*60*1e3,a_=2048,c_=1024*1024;function Nt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mc(e=Lo()){return o_(ge(e),s_)}function gc(e){let t=mc(e);try{let n=r_(t);if(!n.isFile()||n.size>c_)return;let r=JSON.parse(n_(t,"utf8"));return Nt(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}function u_(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),t}function _c(e,t=Lo()){if(!e)return;let n=en(e);if(!n)return;let r=gc(t),o=r?r[n]:void 0;if(!(!Nt(o)||!Nt(o.config)))return u_(o.config)}function l_(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!Nt(n)||!Nt(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>a_))return n.hook_config}function f_(e,t,n,r){let o={...e},s=o[t];if(Object.keys(n).length===0)return s===void 0?void 0:(delete o[t],o);if(!(Nt(s)&&JSON.stringify(s.config)===JSON.stringify(n)&&typeof s.fetched_at_ms=="number"&&s.fetched_at_ms<=r&&r-s.fetched_at_ms<i_))return o[t]={config:n,fetched_at_ms:r},o}function hc(e,t,n=Lo(),r=Date.now()){let o=l_(e),s=t?en(t):void 0;if(o===void 0||!s)return"skipped";try{let i=gc(n);if(i===void 0)return"skipped";let a=f_(i??{},s,o,r);return a?(ce(mc(n),`${JSON.stringify(a,null,2)}
23
+ `),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(i){let a=i instanceof Error?i.message:String(i);return E(`WARN: hook config write failed open: ${a}`),"failed"}}var d_="EV_AI_HOOK_TELEMETRY";function Sc(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}function Ec(e,t,n=process.env){let r=n[d_]?.trim().toLowerCase();return r&&Zt.has(r)?{enabled:!0,source:"env"}:r&&pa.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"}}import{appendFileSync as p_,mkdirSync as m_,readFileSync as g_}from"node:fs";import{homedir as yc}from"node:os";import{dirname as __,join as Rc}from"node:path";var h_="hooks-debug.log",Cc={info(){},error(){}},lr=Cc;function S_(e=yc()){return Rc(e,".ev-ai",h_)}function E_(e=yc()){try{let t=JSON.parse(g_(Rc(e,".ev-ai","config.json"),"utf8"));return t!==null&&typeof t=="object"&&!Array.isArray(t)&&t.debug===!0}catch{return!1}}function Ho(e,t=!1){return e.includes("--debug")||t}function y_(e){return e.replace(/[\r\n]/g," ")}function fr(e=process.argv,t=S_(),n=E_()){if(!Ho(e,n)){lr=Cc;return}let r=(o,s)=>{try{m_(__(t),{recursive:!0}),p_(t,`${new Date().toISOString()} ${o} ${y_(s)}
24
+ `,"utf8")}catch{}};lr={info(o){r("info",o)},error(o){r("error",o)}}}var _e={info(e){lr.info(e)},error(e){lr.error(e)}};function Ac(e){for(let t of Xn){let n=b_(e,t);if(Do(n))return n}}async function x_(e=process.cwd(),t){let n=t??await Fe(e);return Ac(n)??Ac(e)}async function O_(e,t){let n=t??await Fe(C_(e)),r=k_(n,e);if(r.startsWith("..")||A_(r))return!1;let o=await Ae("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(E(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}function Uo(e){let t=R_(e,"utf8");return Se(Jn(t),{})}function I_(){return{schema_version:nt,mcp_servers:[]}}function T_(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(E(`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")&&(E(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}function P_(e){let t=Ia({argv:e.argv,env:process.env,homeConfig:e.homeConfig,manifest:e.manifest,manifestSource:e.manifestSource});for(let r of t.warnings)E(`WARN: ignoring ${r.label}: ${r.problem}`),_e.error(`collector ${r.label} ignored: ${r.problem}`);let n=t.url??"";return _e.info(`collector source=${t.source} url=${n?Tt(n):"(none)"}`),n}function w_(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}async function bc(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await yo(e),o=M("EV_AI_HOOK_MANIFEST"),s=o&&Do(o)?o:void 0,i=s?void 0:Do(mt())?mt():void 0,a=s?void 0:await x_(e,n),c=i?Uo(i):void 0,l=a?Uo(a):void 0,u=Sc(s?q(mt(),{}):c),d,f,p,g=new Set;if(s){d=Uo(s),f=s,p=s;for(let O of Object.keys(d))g.add(O)}else if(c&&l){d=ka(l,c),f=i,p=a;for(let O of Object.keys(l))O in c||g.add(O)}else if(c)d=c,f=i;else if(l){d=l,f=a,p=a;for(let O of Object.keys(l))g.add(O)}else d=I_();delete d.installation_id;let S=p?await O_(p,n):!1;T_(d,p,S,g);let{installationId:A,storePath:b,repoKey:I}=await ur(n,{sessionId:t.sessionId}),P=c??w_(q(mt(),null)),T=P_({argv:t.argv??process.argv,homeConfig:P,manifest:s?d:l,manifestSource:s?"manifest_override":"manifest"});return{manifestPath:f??b,manifest:d,installationId:A,installationStorePath:b,repoKey:I,collectorUrl:T,hookConfig:_c(T),...u!==void 0?{localTelemetry:u}:{},platformAgentId:d.platform_agent_id??"",gitRoot:n,inGitRepo:r}}function kc(e){return{schema_version:nt,...e?{collector_url:e}:{},mcp_servers:[]}}var N_=["darwin-arm64","darwin-x64","linux-arm64","linux-x64","windows-x64","windows-arm64"];function v_(e){return e==="windows-x64"||e==="windows-arm64"}function Fo(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}function xc(e=process.platform,t=process.arch){let n=Fo(e,t);if(!n)throw new Error(`Unsupported platform ${e}-${t}. Supported: ${N_.join(", ")}.`);return n}function M_(e){return v_(e)?`${Ee}.exe`:Ee}function $o(e){return`compile-out/bin/${e}/${M_(e)}`}function j_(e,t){let n=e.collectorUrl?.trim();if(!n)throw new Error(`${t} requires --url <https://hooks.ev-ai.ai/{orgToken}/hook>`);let r=je(n);if(r)throw new Error(`collector URL rejected: ${r}`);return tt(n)}function B_(e){let t=e.collectorUrl?.trim();if(!t)return;let n=je(t);if(n)throw new Error(`collector URL rejected: ${n}`);return tt(t)}function K_(e){return j_(e,"install")}function Nc(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}function vc(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}function Mc(e=process.execPath){return Lc(e)?"binary":"npx"}function G_(){return V(Ke(),".ev-ai","agent-hook")}function V_(e=Ke()){return V(e,".ev-ai","agent-hook",bo)}function W_(){let e=Ko($_(import.meta.url)),t=V(e,"hook.mjs");return rt(t)?t:V(e,"..","dist","hook.mjs")}function Lc(e=process.execPath){return tr(e)}function Hc(e,t){let n=wc(Oc(e),Oc(t));return!n.startsWith("..")&&!D_(n)}function mr(e){return e.split(F_).join("/")}function z_(e){return`node "$(git rev-parse --show-toplevel)/${mr(e)}"`}function J_(e){return`"$(git rev-parse --show-toplevel)/${mr(e)}"`}function Y_(e){return V(e,ko)}function Uc(e,t){let n=Y_(e);Bo(Ko(n),{recursive:!0}),Pc(t,n,{force:!0});try{Tc(n,493)}catch{}return n}function X_(e){let t=V(G_(),"current");try{pr(t,{recursive:!0,force:!0})}catch{}H_(e,t,process.platform==="win32"?"junction":"dir")}function Dc(e,t=Be,n=Ke()){let r=V(n,".ev-ai","agent-hook",t),o=V(r,Ee);Bo(r,{recursive:!0}),Pc(e,o,{force:!0});try{Tc(o,493)}catch{}return X_(r),V(n,".ev-ai","agent-hook",bo)}function Fc(e){let t=Fo();if(!t)return;let n=[V(e,$o(t)),V(e,"packages","agent-hook",$o(t))];for(let r of n)if(rt(r)&&Hc(e,r))return r}function q_(e=Ke()){let t=V_(e);return rt(t)?t:void 0}function Z_(e,t=Ke()){let n=q_(t);return n||(Lc()?Dc(process.execPath,Be,t):Fc(e))}function Q_(e,t=Ke()){let n=Fc(e);if(!n)throw new Error(`update requires a locally compiled binary \u2014 run this package\u2019s build:hook-binary script first.
25
+ To install a released binary instead: curl -fsSL https://cdn.ev-ai.ai/agent-hook/install.sh | sh`);let r=Dc(n,Be,t),o=Uc(e,n);return{sourcePath:n,projectPath:o,globalPath:r}}function Ic(e){let t=[V(e,"packages","agent-hook","dist","hook.mjs"),V(e,Ta)],n=W_();rt(n)&&Hc(e,n)&&t.unshift(n);for(let r of t){if(!rt(r))continue;let o=mr(wc(e,r));return{command:z_(o),hookPath:o,strategy:"dev_mjs"}}}function eh(e){return e==="SessionStart"||e==="sessionStart"}function th(e){return e.replace(/\s+--prefer-offline\b/g,"")}function dr(e,t){return eh(e)?th(t):t}function nh(e=rr){return`npx -y --prefer-offline ${e}`}function rh(e,t=Ke(),n=Mc()){if(n==="npx")return{command:nh(),hookPath:rr,strategy:"npx"};if(n==="local"){let s=Ic(e);if(s)return s;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=Z_(e,t);if(r){Uc(e,r);let s=mr(ko);return{command:J_(s),hookPath:s,strategy:"project_binary"}}let o=Ic(e);if(o)return o;throw new Error(`ev-ai-agent-hook binary not found. Install from CDN:
26
+ curl -fsSL ${Pa}/install.sh | sh
26
27
  Or use npx delivery:
27
- npx ${tr} install`)}function wc(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(Se)||/(?:^|[\s/"'])ev-ai-agent-hook(?:$|[\s"'])/.test(e)}function Bo(e,t){return`${e.replace(/\s+--runner(?:=|\s+)\S+/g,"").trimEnd()} --runner ${t}`}function tt(e,t){$o(jo(e),{recursive:!0}),S_(e,`${JSON.stringify(t,null,2)}
28
- `,"utf8")}function Be(e){if(et(e))try{return JSON.parse(__(e,"utf8"))}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON in ${e} \u2014 fix or remove the file`,{cause:t}):t}}function F_(e,t){let n=_c(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}function $_(e){return(e.schema_version??Qe)===Qe&&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}function Nc(e,t){let n=V(e,zn),r=Be(n),o=F_(r,t);return t.collectorUrl!==void 0||et(n)||!$_(o)?(tt(n,o),{manifestPath:n,wrote:!0}):{manifestPath:void 0,wrote:!1}}function Fo(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_"))}function j_(e){if(Fo(process.env))return!0;let t=je();return[...Oo(),V(t,".claude","settings.json"),V(t,".claude","remote-settings.json"),V(e,".claude","settings.json"),V(e,".claude","settings.local.json")].some(r=>{try{let o=Be(r);return o?Fo(o.env):!1}catch{return!1}})}function B_(e){try{let t=Be(V(e,".claude","settings.json"));return t?Fo(t.env):!1}catch{return!1}}function vc(e){return Array.isArray(e)?e:[]}function dr(e){let t=[],n=r=>!!r&&typeof r=="object"&&wc(r.command);for(let r of vc(e)){if(!r||typeof r!="object"){t.push(r);continue}let o=Array.isArray(r.hooks)?r.hooks:[],s=o.filter(i=>!n(i));if(!(s.length===0&&o.some(n))){if(s.length!==o.length){t.push({...r,hooks:s});continue}t.push(r)}}return t}function Mc(e,t){return[...dr(e),...t]}function Ko(e){return Array.isArray(e)?e.filter(t=>!t||typeof t!="object"?!0:!wc(t.command)):[]}function K_(e,t){return[...Ko(e),{command:t}]}function G_(e){return typeof e=="string"?[e]:e}function V_(e){let t=(n="")=>({hooks:G_(e).map(r=>({type:"command",command:ur(n,r)}))});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()]}}function W_(e){let t=typeof e=="string"?{command:e}:e,n=(r="")=>({hooks:[{type:"command",command:ur(r,t.command),...t.commandWindows===void 0?{}:{commandWindows:ur(r,t.commandWindows)},statusMessage:wa}]});return{SessionStart:[n("SessionStart")],UserPromptSubmit:[n()],PreToolUse:[n()],PostToolUse:[n()],Stop:[n()],SubagentStart:[n()],SubagentStop:[n()]}}var z_=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","postToolUseFailure","beforeShellExecution","beforeReadFile","beforeMCPExecution","subagentStart","subagentStop","stop"],J_=["afterShellExecution","afterFileEdit"];function Y_(e,t=J_){let n={...e};for(let r of t){if(!(r in n))continue;let o=Ko(n[r]);o.length===0?delete n[r]:n[r]=o}return n}function X_(e,t,n={}){let r=V(e,".claude/settings.json"),o=Bo(t,"claude"),s=Be(r)??{};if(j_(e)&&!n.force){if(s.hooks&&typeof s.hooks=="object"){let u={...s.hooks};for(let d of Object.keys(u))u[d]=dr(u[d]),vc(u[d]).length===0&&delete u[d];Object.keys(u).length===0?delete s.hooks:s.hooks=u,tt(r,s)}return!1}let a=s.hooks&&typeof s.hooks=="object"?s.hooks:{},c=V_(o),l={...a};for(let[u,d]of Object.entries(c))l[u]=Mc(a[u],d);return s.hooks=l,tt(r,s),!0}function q_(e,t){let n=V(e,".cursor/hooks.json"),r=Bo(t,"cursor"),o=Be(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=Y_({...s});for(let a of z_)i[a]=K_(i[a],ur(a,r));tt(n,{...o,version:typeof o.version=="number"?o.version:1,hooks:i})}function Z_(e,t){let n=V(e,".codex/hooks.json"),r=Bo(t,"codex"),o=Be(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=W_(r),a={...s};for(let[c,l]of Object.entries(i))a[c]=Mc(s[c],l);tt(n,{...o,hooks:a})}function Q_(e){let t=V(e,".claude/settings.json"),n=Be(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1;for(let s of Object.keys(r)){let i=r[s],a=dr(i);JSON.stringify(i)!==JSON.stringify(a)&&(o=!0),a.length===0?delete r[s]:r[s]=a}o&&(Object.keys(r).length===0?delete n.hooks:n.hooks=r,tt(t,n),E(`Removed ev-ai hooks from ${t}`))}function eh(e){let t=V(e,".cursor/hooks.json"),n=Be(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=Ko(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks"&&a!=="version").length===0){lr(t,{force:!0}),E(`Removed ${t}`);return}tt(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function th(e){let t=V(e,".codex/hooks.json"),n=Be(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=dr(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks").length===0){lr(t,{force:!0}),E(`Removed ${t}`);return}tt(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function Go(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)&&hc(e,t)}async function Lc(e={}){let t=b_(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 s=e.delivery??kc();Go(process.platform,process.arch,{requireBinaryArch:s==="binary"});let i=e.cwd??process.cwd(),a=await De(i),{command:c,hookPath:l,strategy:u}=D_(a,je(),s),{installationId:d,storePath:f}=await ar(a,{overrideId:e.installationId}),{manifestPath:p,wrote:g}=Nc(a,e),S=[];return n?E("Skipped Claude hook \u2014 --no-claude"):X_(a,c,{force:e.force})?(S.push("Claude"),e.force&&B_(a)&&E("Forced Claude hook despite project native OTEL \u2014 expect duplicate session/tool events")):E("Skipped Claude hook \u2014 native OTEL telemetry already enabled (avoids duplicate events); pass --force to wire anyway"),r?E("Skipped Cursor hook \u2014 --no-cursor"):(q_(a,c),S.push("Cursor")),o?E("Skipped Codex hook \u2014 --no-codex"):(Z_(a,c),S.push("Codex")),E(`Installed hook (${u}) at ${l}`),E(`Installation identity ${d} at ${f}`),g&&p?E(`Shared manifest written to ${p}`):E("Using package default collector config (no shared manifest file needed)"),E(S.length>0?`Wired ${S.join(", ")} hooks in ${a} (commands include --runner)`:`No runner hooks wired in ${a} (Claude skipped by OTEL; Cursor/Codex excluded via flags)`),u==="npx"?E("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)."):u==="project_binary"?E("Hook commands are git-root-relative and may be committed; each collaborator runs install once to populate .ev-ai/agent-hook/ (gitignored)."):u==="dev_mjs"&&E("Hook commands use node + monorepo packages/agent-hook/dist/hook.mjs (local delivery; rebuild with yarn workspace @ev-ai/agent-hook build)."),g&&p&&e.collectorUrl&&E("Shared manifest includes collector_url \u2014 commit it with hook configs so teammates post without env vars."),{gitRoot:a,hookPath:l,manifestPath:p,installationStorePath:f,strategy:u}}async function Hc(e=process.cwd()){Go(process.platform,process.arch,{requireBinaryArch:!0});let t=await De(e),{projectPath:n,globalPath:r}=M_(t);E(`Refreshed ${r}`),E(`Refreshed ${n}`),E("Hook configs and shared manifest left unchanged")}async function Uc(e={}){let t=A_(e);e.collectorUrl=t,Go(process.platform,process.arch,{requireBinaryArch:!1});let n=e.cwd??process.cwd(),r=await De(n),{manifestPath:o,wrote:s}=Nc(r,e);if(t!==void 0&&(!o||!s))throw new Error("configure failed to write shared collector manifest");return s&&o?E(`Wrote ${o}`):t===void 0&&E("No --url given and no shared manifest yet \u2014 pass --url <\u2026/{orgToken}/hook> to write collector destination."),E("Manifest only \u2014 enable ev-ai marketplace plugins. Do not also run file-wiring install for the same events."),{gitRoot:r,manifestPath:o}}function Dc(e){for(let t of[()=>Q_(e),()=>eh(e),()=>th(e)])try{t()}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: strip skipped a hook file: ${r}`)}}async function Fc(e=process.cwd()){let t=await De(e);return Dc(t),E("Stripped ev-ai file-wired hooks; shared collector manifest left in place."),E("Next: enable ev-ai marketplace plugins, then restart runners."),{gitRoot:t}}async function $c(e=process.cwd()){let t=await De(e);Dc(t);for(let n of Jn){let r=V(t,n);if(et(r))try{lr(r,{force:!0}),E(`Removed ${r}`)}catch(o){let s=o instanceof Error?o.message:String(o);E(`WARN: uninstall could not remove ${r}: ${s}`)}}}import{existsSync as PE,mkdirSync as wE,readdirSync as NE,readFileSync as vE,unlinkSync as Gu,writeFileSync as ME}from"node:fs";import{homedir as Vu}from"node:os";import{join as ss}from"node:path";import{existsSync as dh}from"node:fs";import{existsSync as nh}from"node:fs";import{homedir as Bc}from"node:os";import{join as rh}from"node:path";function Kc(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}var oh={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"}}};function jc(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}function sh(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:jc(n.mcpJson,t.mcpJson),mcpToml:jc(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}function Gc(e){return Object.fromEntries(Object.entries(oh).map(([t,n])=>[t,sh(n,n[e])]))}var wt=Gc("homeOnly"),rt=Gc("projectOnly");function ih(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}function ah(e,t){return ih(e).some(n=>nh(rh(t,n)))}function Vc(e,t){for(let n of e)if(ah(n,t))return!0;return!1}function nt(e){return[...new Set(e)]}function ot(e){let t=[],n=[],r=[],o=[],s=[],i=[],a=[];for(let c of e){t.push(...c.skillRoots);for(let l of c.dirs)l.kind==="SUBAGENT"?n.push(l.dir):l.kind==="COMMAND"?r.push(l.dir):o.push(l.dir);s.push(...c.memory.flat()),i.push(...c.settings),a.push(...c.mcpJson??[],...c.mcpToml??[])}return{skills:nt(t),subagents:nt(n),commands:nt(r),rules:nt(o),memory:nt(s),settings:nt(i),mcp:nt(a)}}function ch(e,t=Bc(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...rr(o.managed,n,t));return nt(r)}var st=ot(Object.values(wt));function Wc(e=Bc(),t=process.platform){return ch(Object.values(wt),e,t)}import{existsSync as uh}from"node:fs";import{resolve as Vo}from"node:path";function Ee(e){return Vo(e).replaceAll("\\","/").replace(/\/$/,"")}function pt(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}function pr(e,t){if(!e)return t;let n=`${e}/`,r=[],o=[];for(let s of t)s===e||s.startsWith(n)?r.push(s):o.push(s);return r.length===0?t:[...r,...o]}var lh=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function nn(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!lh.test(t)?null:t}function Nt(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let s=Ee(o);n.has(s)||(n.add(s),r.push(s))}return r}function fh(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}function Te(e,t,n,r=uh){for(let o of e)for(let s of t){let i=Ee(Vo(o,s)),a=Vo(o,s,n).replaceAll("\\","/");if(fh(i,a)&&r(a))return a}return null}var Jc=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Yc=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,ph=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,zc=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"]),mh=/^[a-z][a-z0-9-]{1,63}$/,gh=[".cursor/skills",".claude/skills",".agents/skills"],_h=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],hh=pt(gh,ot(Object.values(rt)).skills),Sh=pt(_h,ot(Object.values(wt)).skills),Eh=new Set(["read","read_file","view"]),yh=new Set(["bash","shell","zsh"]);function Wo(e){let t=e.replace(/\\/g,"/");return Jc.exec(t)?.[1]??null}function Rh(e){let t=e.replace(/\\/g,"/"),r=Yc.exec(t)?.[1];return r?r.toLowerCase():null}function Ch(e){return Wo(e)??Rh(e)}function Ah(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}function mr(e){return typeof e=="string"?mr(he(e,null)):!e||typeof e!="object"?null:Ah(e)}function Xc(e){if(typeof e=="string")return Xc(he(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}function zo(e){let t=Xc(e.tool_input);if(t)return t;let n=lt(e.command);return n.length>0?n:null}function bh(e){let t=e.replace(/\\/g,"/"),n=Jc.exec(t);if(n?.[1])return n[1];let o=Yc.exec(t)?.[1];return o?o.toLowerCase():null}function kh(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}function Jo(e){let t=mr(e.tool_input)??lt(e.file_path);return t.length>0?t:null}function rn(e,t,n){let r=kh(e).toLowerCase();if(Eh.has(r)){let o=Jo(e);return o?t(o):null}if(yh.has(r)){let o=zo(e);return o?n(o):null}return null}function qc(e){return rn(e,Ch,bh)}function xh(e){let t=new Set,n=[];for(let r of e.matchAll(ph)){let o=r[1]?.toLowerCase();!o||t.has(o)||Oh(o)||(t.add(o),n.push(o))}return n}function Oh(e){let t=e.split("/")[0];return zc.has(e)||t!==void 0&&zc.has(t)}function Zc(e){let t=e.skillId.toLowerCase();if(!mh.test(t))return null;let n=e.exists??dh,r=`${t}/SKILL.md`,o=Te(Nt(e.launchCwd,e.gitRoot),hh,r,n);return o!==null?o:e.home?Te([Ee(e.home)],Sh,r,n):null}function Ih(e){return lt(e.prompt)}function Qc(e){let t=L(e,"command_name");if(t){let r=L(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=Ih(e);return n?xh(n):[]}var es=qe(at(),1);import{existsSync as tE}from"node:fs";var gt={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function sn(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}function eE(e){if(!e)return"";let t=Jt(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return sn(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return sn(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?sn(o[1]):sn(t)}async function Rr(e=process.cwd()){let t=await Ce("git",["rev-parse","--is-inside-work-tree"],2e3,{cwd:e});if(!t.ok||t.stdout!=="true")return null;let[n,r,o,s]=await Promise.all([Ce("git",["remote","get-url","origin"],2e3,{cwd:e}),Ce("git",["branch","--show-current"],2e3,{cwd:e}),Ce("git",["rev-parse","HEAD"],2e3,{cwd:e}),Ce("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?Jt(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:s.ok?s.stdout.length>0:null}}async function bu(e,t,n,r=process.cwd(),o,s,i){if(t)return t;let a=gt[n];if(!a)return"";let c=Za(n,e.scope_path,i);if(s){let g=ic(s,c);if(g)return g}let l=o??await Rr(r),u=l?.remote?eE(l.remote):"";if(u||(u=sn(process.env.GITHUB_REPOSITORY??"")),!u)return"";let d=e.scope_path??"",f=d?`${d}/`:"",p=`${u}:${f}${a}`;return s&&ac(s,c,p),p}var nE=[".cursor/rules",".claude/rules",".codex/rules"],rE=ot(Object.values(rt)).rules;function oE(e){return pt(pr(e?gt[e]:void 0,nE),rE)}var sE=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function ku(e){let t=nn(e.relativePath);if(!t)return null;let n=e.exists??tE,r=Nt(e.launchCwd,e.gitRoot),o=oE(e.runnerPlatform),s=Te(r,o,t,n);if(s!==null)return s;if(!t.includes("/")){let i=Te(r,["."],t,n);if(i!==null)return i}return e.home?Te([Ee(e.home)],o,t,n):null}function iE(e){let t=e.replace(/\\/g,"/"),r=sE.exec(t)?.[1];return r?(0,es.nativeKeyForRulePath)(r):null}function xu(e){return rn(e,es.nativeKeyForRulePath,iE)}function Ou(e){return e.replace(/\.(mdc|md|rules)$/i,"")}function Iu(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 s=o;if(s.type!=="rule")continue;let i=typeof s.file_path=="string"?s.file_path:"",a=nn(i);!a||n.has(a)||(n.add(a),r.push(a))}return r}var ts=qe(at(),1);import{existsSync as aE}from"node:fs";var cE=[".cursor/commands",".claude/commands",".codex/prompts"],uE=ot(Object.values(rt)).commands;function lE(e){return pt(pr(e?gt[e]:void 0,cE),uE)}var fE=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function Tu(e){let t=nn(e.commandId);if(!t)return null;let n=e.exists??aE,r=`${t}.md`,o=lE(e.runnerPlatform),s=Te(Nt(e.launchCwd,e.gitRoot),o,r,n);return s!==null?s:e.home?Te([Ee(e.home)],o,r,n):null}function dE(e){let t=e.replace(/\\/g,"/"),r=fE.exec(t)?.[1];return r?(0,ts.nativeKeyForCommandPath)(r):null}function Pu(e){return rn(e,ts.nativeKeyForCommandPath,dE)}var Cr=qe(at(),1);function wu(e){let t=Ca(e);if(t.problem){E(`WARN: ignoring --url/--token collector override: ${t.problem}`);return}return t.url}function Nu(e,t){if(L(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}function pE(){return!!(M("CURSOR_VERSION")??M("CURSOR_PROJECT_DIR"))}function vu(e,t,n){return e!=="claude"&&e!=="codex"?!1:Nu(t,n)?!0:pE()}var mE=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function an(e,t,n,r){return Nu(e,t)?"cursor":Yn(r)?r:Yn(n)?n:L(e,"turn_id")?"codex":L(e,"session_id")||mE.has(t.toLowerCase())?"claude":"unknown"}function Ar(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function gE(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":return"skill_invoked";default:return""}}function Mu(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}function Lu(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}function Hu(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}function cn(e){return L(e,"session_id")||L(e,"conversation_id")}function ns(e){return L(e,"prompt.id")||L(e,"prompt_id")||L(e,"generation_id")||L(e,"turn_id")}function rs(e){return L(e,"hook_event_name")||L(e,"event")}function Uu(e,t,n){let r=cn(e),o=ns(e),s=rs(e),i=L(e,"source"),a=an(e,s,t,n);return{sessionId:r,turnId:o,runnerEvent:s,hookSource:i,runnerPlatform:a}}var _E=["session_start","session_end","tool_invoked","skill_invoked"];function hE(e){return _E.includes(e)}function os(e,t){return e&&hE(e)?e:gE(t.toLowerCase())}var SE={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function br(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}function Du(e,t=""){let n=L(e,"tool_name")||L(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!br(n)&&(n=`MCP:${n}`):n=SE[r]??null;let o=e.tool_input,i=(o&&typeof o=="object"?lt(o.skill)||lt(o.skill_name):"")||L(e,"skill_name")||null,a=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;i??=qc(a);let c=xu(a),l=Pu(a);return{toolName:n,skillName:i,ruleName:c,commandName:l}}var EE=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function Fu(e){for(let t of["subagent_type","agent_type"]){let n=L(e,t);if(n&&EE.test(n))return n}return null}function $u(e){let t=Fe(e,"duration_ms");if(typeof t=="number")return t;let n=Fe(e,"duration");return typeof n=="number"?n:null}var yE="error",RE="interrupted",CE="permission_denied",AE=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function un(e){return AE.test(e)?e:null}function bE(e){for(let t of["failure_type","error_type"]){let n=un(L(e,t));if(n)return n}return null}function ju(e,t){return Fe(e,"is_interrupt")===!0?RE:t.toLowerCase()==="permissiondenied"?CE:bE(e)??yE}function Bu(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}function kE(e,t){return Bu(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}function xE(e,t){return Bu(t,n=>(0,Cr.mcpServerNameMatchesToolSegment)(n,e))}function OE(e,t){let n=null,r=0;for(let s of t)if(s)for(let i of(0,Cr.mcpServerToolSegmentForms)(s)){let a=`${i}__`;e.length>a.length&&e.slice(0,a.length).toLowerCase()===a.toLowerCase()&&i.length>r&&(n={mcpServer:s,mcpTool:e.slice(a.length)},r=i.length)}if(n!==null)return n;let o=/^(.+?)__(.+)$/.exec(e);return!o?.[1]||!o[2]?{mcpServer:null,mcpTool:null}:{mcpServer:xE(o[1],t)??o[1],mcpTool:o[2]}}function IE(e,t){if(/^mcp__/i.test(e))return OE(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:kE(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}function TE(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}function Ku(e,t=[],n=""){let r=e?IE(e,t):{mcpServer:null,mcpTool:null},o=un(n.trim());if(!o)return r;let s=r.mcpTool;return!s&&e&&!br(e)&&(s=e),s&&(s=TE(s,o)),{mcpServer:o,mcpTool:s}}var Wu=3e4,LE="claims",HE=!0,UE=100,DE=new Set(["sessionstart","sessionend","stopfailure"]),FE=["tool_name","tool","command","file_path","url"];function $E(e=Vu()){return ss(ge(e),LE)}function zu(e,t){try{let n=vE(e,"utf8").split(`
29
- `,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}function jE(e){let t=[];for(let n of FE){let r=L(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":Yt(t.join("\0"))}function BE(e){let t=e.sessionId.trim();if(!t)return;let n=e.runnerEvent.trim().toLowerCase(),r=e.turnId.trim(),o=e.toolUseId.trim(),s=e.subagentId?.trim()??"",i=e.callFingerprint?.trim()??"",a=!!(o||r||s),c=DE.has(n);if(!a&&!c)return;let l=e.runnerPlatform.trim()||"unknown";return Yt(`${l}|${t}|${n}|${r}|${o}|${i}|${s}`)}function KE(e,t=Date.now()){let n;try{n=NE(e)}catch{return}let r=0;for(let o of n){if(r>=UE)break;r+=1;let s=ss(e,o),i=zu(s,t);if(!(!Number.isFinite(i)||i<Wu))try{Gu(s)}catch{}}}function GE(e,t,n=Date.now()){let r=ss(t,e);try{if(PE(r)){let o=zu(r,n);if(Number.isFinite(o)&&o>=0&&o<Wu)return!1;try{Gu(r)}catch{}}}catch{}try{wE(t,{recursive:!0}),ME(r,`${n}
30
- `,{encoding:"utf8",flag:"wx"})}catch(o){if(Wt(o))return!1;let s=o instanceof Error?o.message:String(o);return E(`WARN: event claim failed open: ${s}`),!0}return KE(t,n),!0}function VE(e,t,n){let r=cn(e),o=ns(e),s=L(e,"tool_use_id"),i=L(e,"subagent_id")||L(e,"agent_id"),a=an(e,t,void 0,n),c=jE(e);return{runnerPlatform:a,sessionId:r,runnerEvent:t,turnId:o,toolUseId:s,subagentId:i,callFingerprint:c}}function Ju(e,t,n,r=Vu(),o=Date.now()){if(!HE)return!0;let s=BE(VE(e,t,n));if(!s)return!0;let i=GE(s,$E(r),o);return!i&&M("EV_AI_HOOK_DEBUG")&&E(`DEBUG: duplicate hook event suppressed (claim ${s.slice(0,8)}\u2026)`),i}import{mkdirSync as WE,readFileSync as is,statSync as Zu,unlinkSync as Qu,writeFileSync as as}from"node:fs";import{homedir as el}from"node:os";function tl(e){return e==="session_start"||e==="session_end"}var kr=new Set,Yu=!1;function cs(e=el()){return Qi(e)}function us(e,t=el(),n=process.platform){if(e!==void 0)return e>0?e:Fn(n);let r=Z(xt(t),{});return ya(r)??Fn(n)}function ln(e){return Bn(e.pid,e.acquiredAtMs)}function nl(e){try{let t=Zu(e);return t.isFile()&&t.size<=po?is(e,"utf8"):void 0}catch{return}}function ls(e,t=cs()){if(!e)return;let n=jn(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=nl(n);if(o===ln(r))return xr(r);if(o===Bn(process.ppid,e.acquiredAtMs))try{return as(n,ln(r),{encoding:"utf8",mode:384}),xr(r)}catch{return}}function rl(e,t){if(e.path){kr.delete(e);try{nl(e.path)===ln(e)&&as(e.path,Bn(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}function ol(e,t=Date.now()){let n,r;try{let o=Zu(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=po?is(e,"utf8"):""}catch{return!1}return ta(n,r,t)}function sl(e,t=cs(),n=Date.now){for(let r=0;r<e;r+=1)if(!ol(jn(t,r),n()))return!0;return e<=0}function il(e){return{pid:process.pid,acquiredAtMs:e}}function Xu(e,t){let n=e instanceof Error?e.message:String(e);return E(`WARN: hook process slot failed open: ${n}`),il(t)}function xr(e){return kr.add(e),Yu||(Yu=!0,process.once("exit",()=>{for(let t of[...kr])Or(t)})),e}function qu(e){try{return as(e.path,ln(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(Wt(t))return!1;throw t}}function al(e,t=cs(),n=Date.now){if(e<=0)return il(n());try{WE(t,{recursive:!0})}catch(s){return Xu(s,n())}let r,o=0;for(let s=0;s<e;s+=1)try{let i={path:jn(t,s),pid:process.pid,acquiredAtMs:n()};if(qu(i))return xr(i);if(ol(i.path,n())){o+=1;continue}try{Qu(i.path)}catch(a){if(!bt(a))throw a}if(i.acquiredAtMs=n(),qu(i))return xr(i);o+=1}catch(i){r??=i}return r===void 0||o>0?null:Xu(r,n())}function Or(e,t=Date.now()){if(kr.delete(e),!(!e.path||t-e.acquiredAtMs>=$n-zt))try{is(e.path,"utf8")===ln(e)&&Qu(e.path)}catch{}}function fs(e){M("EV_AI_HOOK_DEBUG")&&E(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}import{closeSync as zE,writeSync as JE}from"node:fs";function cl(e=process.env){let t=e[lo];if(delete e[lo],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{JE(n,Ki)}catch{}try{zE(n)}catch{}}}function ds(e=process.env){let t=e[Di];if(t)return{launcherVersion:t,hookSource:e[Fi]??"",fallbackReason:e[$i],launcherScope:e[ji]}}function ul(e,t){return(e?Zt(e):void 0)===t}import{readFileSync as ZE,statSync as QE}from"node:fs";import{homedir as ey}from"node:os";import{join as ty}from"node:path";var dl="EV_AI_PERF_L",ps="EV_AI_PERF_H",YE="EV_AI_HOOK_PERF";var XE=/^[a-z][a-z0-9_]{0,23}$/;var Ir={origin:0,marks:{},values:{}},Tr=!1;function pl(e=process.env){Tr=e[YE]!=="0",Ir.origin=performance.timeOrigin}function fn(){return Tr}function Ve(e,t=performance.now()){Tr&&(Ir.marks[e]=t)}function ml(){return Ir}function gl(e){return Math.round(e*10)/10}function ll(e){return Object.entries(e).map(([t,n])=>`${t}=${gl(n)}`).join(",")}function qE(e){return`${gl(e.origin)}|${ll(e.marks)}|${ll(e.values)}`}function fl(e,t){if(!e)return!0;for(let n of e.split(",")){let r=n.indexOf("="),o=n.slice(0,r),s=Number(n.slice(r+1));if(r<1||!XE.test(o)||!(s>=0&&s<=36e5))return!1;t[o]=s}return Object.keys(t).length<=32}function ms(e){if(!e||e.length>1024)return;let[t,n,r,...o]=e.split("|"),s=Number(t);if(o.length>0||!Number.isFinite(s)||s<=0)return;let i={origin:s,marks:{},values:{}};if(!(!fl(n,i.marks)||!fl(r,i.values)))return i}function _l(){return Tr?qE(Ir):void 0}var ny="perf-prev.json",ry=512,oy=1440*60*1e3,sy=12e4,iy=50,dn={},hl=!1;function _s(e){return Math.round(e*10)/10}function we(e,t){if(!fn())return t();let n=performance.now();return t().finally(()=>{dn[e]=_s(performance.now()-n)})}function ay(){for(let e of Object.keys(dn))delete dn[e]}function El(){if(!fn())return;let e=_l();e&&(process.env[ps]=e)}function Sl(e,t){if(!e)return;let n=t-e.origin;return n>=-iy&&n<=sy?e:void 0}function cy(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}function yl(e=ey()){return ty(ge(e),ny)}function uy(e,t){if(!hl){hl=!0;try{let n=yl(t);if(QE(n).size>ry)return;let r=JSON.parse(ZE(n,"utf8"));return!cy(r)||e-r.at>oy?void 0:{at:r.at,post_ms:r.post_ms}}catch{return}}}function hs(e,t){if(!fn())return;let n={at:Date.now(),post_ms:Math.max(0,Math.round(e))};try{ce(yl(t),JSON.stringify(n))}catch{}}function gs(e,t,n,r,o=n.marks){let s=Math.max(0,n.origin-r);e[t]=_s(s);for(let[i,a]of Object.entries(o))e[i]=_s(s+a)}function Rl(e,t=process.env,n,r=!1){let o=r?La():void 0;if(!fn())return o?{sys:o}:void 0;let s=ml(),i="w0"in s.marks?"w":"h",a=i==="w"?Sl(ms(t[ps]),s.origin):void 0,c=Sl(ms(t[dl]),(a??s).origin),l=c?"l":a?"h":i,u=(c??a??s).origin,d={};c&&gs(d,"l",c,u),a&&gs(d,"h",a,u),gs(d,i,s,u,{...s.marks,...e});let f={base:l,t:d};i==="w"&&a&&d.h3!==void 0&&(f.ack_ms=d.h3),c?.values.bootstrap===1&&(f.bootstrap=!0),Object.keys(dn).length>0&&(f.spans={...dn},ay());let p=uy(Date.now(),n);return p&&(f.prev=p),o&&(f.sys=o),f}import{realpathSync as xk}from"node:fs";import{homedir as Ok}from"node:os";var B=qe(at(),1);import{existsSync as ly,readFileSync as fy}from"node:fs";import{homedir as Cl}from"node:os";import{join as dy}from"node:path";var py="cloud-cache.json",my=1440*60*1e3,gy=900*1e3;function _y(e=Cl()){return dy(ge(e),py)}function hy(e){if(!ly(e))return;let t=he(fy(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}}function Sy(e,t){try{ce(e,`${JSON.stringify(t)}
31
- `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: cloud cache write failed open: ${r}`)}}function Ey(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?gy:my;return n-e.probed_at<r}async function yy(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,s]=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&&!s?.ok)return;let i=o?.ok?(await o.text()).trim():"",a=s?.ok?(await s.text()).trim():"";if(!(!i&&!a))return{provider:"aws",region:i,instance_id:a}}async function Ry(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}}async function Cy(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}}async function Ay(e){let t=await Promise.allSettled([yy(e),Ry(e),Cy(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}async function Al(e,t){if(e==="interactive")return null;let n=t?.home??Cl(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),s=_y(n),i=hy(s);if(Ey(i,e,o))return i.result;let a=await Ay(r);return Sy(s,{context:e,probed_at:o,result:a}),a}var Ol=qe(at(),1);import{existsSync as kl}from"node:fs";import{homedir as xl}from"node:os";import{join as pn,resolve as Ss,sep as bl}from"node:path";function Pr(e,t,n){if(!kl(e))return;let r=Z(e,{});for(let[o,s]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:s})}function by(e,t,n){if(!kl(e))return;let r=Z(e,{}),o=Ss(t),s=null;for(let a of Object.keys(r.projects??{})){let c=Ss(a);(o===c||o.startsWith(c.endsWith(bl)?c:c+bl))&&(s===null||c.length>Ss(s).length)&&(s=a)}if(s===null)return;let i=r.projects?.[s]?.mcpServers??{};for(let[a,c]of Object.entries(i))n.set(a,{declared:{name:a,source:"claude_json_project",sourcePath:".claude.json",scope:"user"},config:c})}function Il(e,t,n,r){let o=new Map;for(let s of e.mcp_servers??[])s.name&&o.set(s.name,{declared:{name:s.name,source:"manifest"}});return n==="claude"?(Pr(pn(r,".claude.json"),{source:"claude_json_user"},o),by(pn(r,".claude.json"),t,o)):n==="cursor"&&Pr(pn(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),Pr(pn(t,".mcp.json"),{source:"mcp_json"},o),Pr(pn(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}async function Es(e,t=process.cwd(),n="claude",r=xl()){return[...Il(e,t,n,r).values()].map(o=>o.declared)}function Tl(e,t,n=process.cwd(),r="claude",o=xl()){let s=Il(t,n,r,o),i=s.get(e);if(i!==void 0)return i.config??null;for(let[a,c]of s)if((0,Ol.mcpServerNameMatchesToolSegment)(a,e))return c.config??null;return null}var ky=["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"],xy=["CURSOR_PROJECT_DIR"],Oy=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function Iy(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)Oy.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}function Pl(e=process.env){let t=ky.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:Iy(e[r]??"")}:{name:r,present:!1}),n=xy.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}import{homedir as oR}from"node:os";import{homedir as wl}from"node:os";import{join as Ty}from"node:path";function Py(e=wl()){return Ty(e,".claude.json")}function wr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Nl(e=wl()){let n=Z(Py(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=wr(n.emailAddress),o=wr(n.fullName)??wr(n.displayName),s=wr(n.accountUuid),i=r??s;return!i||me(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:i,identity_source:"claude_oauth"}}import{homedir as Ll}from"node:os";import{join as vl}from"node:path";var wy="https://api.openai.com/auth";function Lt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Hl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function Ny(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 Hl(r)}catch{return null}}function Ml(e,t,n){return Lt(e[n])??Lt(t?.[n])}function vy(e=process.env,t=Ll()){let n=Lt(e.CODEX_HOME)??vl(t,".codex");return vl(n,"auth.json")}function Ul(e=process.env,t=Ll()){let n=Z(vy(e,t),{}),r=Lt(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&Lt(n.OPENAI_API_KEY))return null;let o=Lt(n.tokens?.id_token);if(!o)return null;let s=Ny(o);if(!s)return null;let i=Hl(s[wy]),a=Ml(s,i,"name"),c=Ml(s,i,"email");return!c||me(a,c)?null:{git_user_name:null,git_user_email:null,platform_login:c,identity_source:"codex_oauth"}}import{homedir as Mr}from"node:os";import{join as We}from"node:path";import{join as My}from"node:path";var Ly="cursor-ide-identity.json",Hy=840*60*1e3;function Fl(e){return My(ge(e),Ly)}function Dl(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function $l(e){let t=Z(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:Dl(t.email),auth_id:Dl(t.auth_id)}}function jl(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<Hy}function Bl(e,t){try{ce(e,`${JSON.stringify(t)}
32
- `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: cursor IDE identity cache write failed open: ${r}`)}}import{execFileSync as Uy}from"node:child_process";import{existsSync as Dy}from"node:fs";import{createRequire as Fy}from"node:module";import{pathToFileURL as $y}from"node:url";var Gl=Fy(import.meta.url),Nr=`
28
+ npx ${rr} install`)}function $c(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(Ee)||/(?:^|[\s/"'])ev-ai-agent-hook(?:$|[\s"'])/.test(e)}function Go(e,t){return`${e.replace(/\s+--runner(?:=|\s+)\S+/g,"").trimEnd()} --runner ${t}`}function ot(e,t){Bo(Ko(e),{recursive:!0}),U_(e,`${JSON.stringify(t,null,2)}
29
+ `,"utf8")}function Ge(e){if(rt(e))try{return JSON.parse(L_(e,"utf8"))}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON in ${e} \u2014 fix or remove the file`,{cause:t}):t}}function oh(e,t){let n=kc(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}function sh(e){return(e.schema_version??nt)===nt&&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}function jc(e,t){let n=V(e,Yn),r=Ge(n),o=oh(r,t);return t.collectorUrl!==void 0||rt(n)||!sh(o)?(ot(n,o),{manifestPath:n,wrote:!0}):{manifestPath:void 0,wrote:!1}}function jo(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_"))}function ih(e){if(jo(process.env))return!0;let t=Ke();return[...Io(),V(t,".claude","settings.json"),V(t,".claude","remote-settings.json"),V(e,".claude","settings.json"),V(e,".claude","settings.local.json")].some(r=>{try{let o=Ge(r);return o?jo(o.env):!1}catch{return!1}})}function ah(e){try{let t=Ge(V(e,".claude","settings.json"));return t?jo(t.env):!1}catch{return!1}}function Bc(e){return Array.isArray(e)?e:[]}function gr(e){let t=[],n=r=>!!r&&typeof r=="object"&&$c(r.command);for(let r of Bc(e)){if(!r||typeof r!="object"){t.push(r);continue}let o=Array.isArray(r.hooks)?r.hooks:[],s=o.filter(i=>!n(i));if(!(s.length===0&&o.some(n))){if(s.length!==o.length){t.push({...r,hooks:s});continue}t.push(r)}}return t}function Kc(e,t){return[...gr(e),...t]}function Vo(e){return Array.isArray(e)?e.filter(t=>!t||typeof t!="object"?!0:!$c(t.command)):[]}function ch(e,t){return[...Vo(e),{command:t}]}function uh(e){return typeof e=="string"?[e]:e}function lh(e){let t=(n="")=>({hooks:uh(e).map(r=>({type:"command",command:dr(n,r)}))});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()]}}function fh(e){let t=typeof e=="string"?{command:e}:e,n=(r="")=>({hooks:[{type:"command",command:dr(r,t.command),...t.commandWindows===void 0?{}:{commandWindows:dr(r,t.commandWindows)},statusMessage:Ha}]});return{SessionStart:[n("SessionStart")],UserPromptSubmit:[n()],PreToolUse:[n()],PostToolUse:[n()],Stop:[n()],SubagentStart:[n()],SubagentStop:[n()]}}var dh=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","postToolUseFailure","beforeShellExecution","beforeReadFile","beforeMCPExecution","subagentStart","subagentStop","stop"],ph=["afterShellExecution","afterFileEdit"];function mh(e,t=ph){let n={...e};for(let r of t){if(!(r in n))continue;let o=Vo(n[r]);o.length===0?delete n[r]:n[r]=o}return n}function gh(e,t,n={}){let r=V(e,".claude/settings.json"),o=Go(t,"claude"),s=Ge(r)??{};if(ih(e)&&!n.force){if(s.hooks&&typeof s.hooks=="object"){let u={...s.hooks};for(let d of Object.keys(u))u[d]=gr(u[d]),Bc(u[d]).length===0&&delete u[d];Object.keys(u).length===0?delete s.hooks:s.hooks=u,ot(r,s)}return!1}let a=s.hooks&&typeof s.hooks=="object"?s.hooks:{},c=lh(o),l={...a};for(let[u,d]of Object.entries(c))l[u]=Kc(a[u],d);return s.hooks=l,ot(r,s),!0}function _h(e,t){let n=V(e,".cursor/hooks.json"),r=Go(t,"cursor"),o=Ge(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=mh({...s});for(let a of dh)i[a]=ch(i[a],dr(a,r));ot(n,{...o,version:typeof o.version=="number"?o.version:1,hooks:i})}function hh(e,t){let n=V(e,".codex/hooks.json"),r=Go(t,"codex"),o=Ge(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=fh(r),a={...s};for(let[c,l]of Object.entries(i))a[c]=Kc(s[c],l);ot(n,{...o,hooks:a})}function Sh(e){let t=V(e,".claude/settings.json"),n=Ge(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1;for(let s of Object.keys(r)){let i=r[s],a=gr(i);JSON.stringify(i)!==JSON.stringify(a)&&(o=!0),a.length===0?delete r[s]:r[s]=a}o&&(Object.keys(r).length===0?delete n.hooks:n.hooks=r,ot(t,n),E(`Removed ev-ai hooks from ${t}`))}function Eh(e){let t=V(e,".cursor/hooks.json"),n=Ge(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=Vo(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks"&&a!=="version").length===0){pr(t,{force:!0}),E(`Removed ${t}`);return}ot(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function yh(e){let t=V(e,".codex/hooks.json"),n=Ge(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=gr(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks").length===0){pr(t,{force:!0}),E(`Removed ${t}`);return}ot(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function Wo(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)&&xc(e,t)}async function Gc(e={}){let t=K_(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 s=e.delivery??Mc();Wo(process.platform,process.arch,{requireBinaryArch:s==="binary"});let i=e.cwd??process.cwd(),a=await Fe(i),{command:c,hookPath:l,strategy:u}=rh(a,Ke(),s),{installationId:d,storePath:f}=await ur(a,{overrideId:e.installationId}),{manifestPath:p,wrote:g}=jc(a,e),S=[];return n?E("Skipped Claude hook \u2014 --no-claude"):gh(a,c,{force:e.force})?(S.push("Claude"),e.force&&ah(a)&&E("Forced Claude hook despite project native OTEL \u2014 expect duplicate session/tool events")):E("Skipped Claude hook \u2014 native OTEL telemetry already enabled (avoids duplicate events); pass --force to wire anyway"),r?E("Skipped Cursor hook \u2014 --no-cursor"):(_h(a,c),S.push("Cursor")),o?E("Skipped Codex hook \u2014 --no-codex"):(hh(a,c),S.push("Codex")),E(`Installed hook (${u}) at ${l}`),E(`Installation identity ${d} at ${f}`),g&&p?E(`Shared manifest written to ${p}`):E("Using package default collector config (no shared manifest file needed)"),E(S.length>0?`Wired ${S.join(", ")} hooks in ${a} (commands include --runner)`:`No runner hooks wired in ${a} (Claude skipped by OTEL; Cursor/Codex excluded via flags)`),u==="npx"?E("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)."):u==="project_binary"?E("Hook commands are git-root-relative and may be committed; each collaborator runs install once to populate .ev-ai/agent-hook/ (gitignored)."):u==="dev_mjs"&&E("Hook commands use node + monorepo packages/agent-hook/dist/hook.mjs (local delivery; rebuild with yarn workspace @ev-ai/agent-hook build)."),g&&p&&e.collectorUrl&&E("Shared manifest includes collector_url \u2014 commit it with hook configs so teammates post without env vars."),{gitRoot:a,hookPath:l,manifestPath:p,installationStorePath:f,strategy:u}}async function Vc(e=process.cwd()){Wo(process.platform,process.arch,{requireBinaryArch:!0});let t=await Fe(e),{projectPath:n,globalPath:r}=Q_(t);E(`Refreshed ${r}`),E(`Refreshed ${n}`),E("Hook configs and shared manifest left unchanged")}async function Wc(e={}){let t=B_(e);e.collectorUrl=t,Wo(process.platform,process.arch,{requireBinaryArch:!1});let n=e.cwd??process.cwd(),r=await Fe(n),{manifestPath:o,wrote:s}=jc(r,e);if(t!==void 0&&(!o||!s))throw new Error("configure failed to write shared collector manifest");return s&&o?E(`Wrote ${o}`):t===void 0&&E("No --url given and no shared manifest yet \u2014 pass --url <\u2026/{orgToken}/hook> to write collector destination."),E("Manifest only \u2014 enable ev-ai marketplace plugins. Do not also run file-wiring install for the same events."),{gitRoot:r,manifestPath:o}}function zc(e){for(let t of[()=>Sh(e),()=>Eh(e),()=>yh(e)])try{t()}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: strip skipped a hook file: ${r}`)}}async function Jc(e=process.cwd()){let t=await Fe(e);return zc(t),E("Stripped ev-ai file-wired hooks; shared collector manifest left in place."),E("Next: enable ev-ai marketplace plugins, then restart runners."),{gitRoot:t}}async function Yc(e=process.cwd()){let t=await Fe(e);zc(t);for(let n of Xn){let r=V(t,n);if(rt(r))try{pr(r,{force:!0}),E(`Removed ${r}`)}catch(o){let s=o instanceof Error?o.message:String(o);E(`WARN: uninstall could not remove ${r}: ${s}`)}}}import{existsSync as YE,mkdirSync as XE,readdirSync as qE,readFileSync as ZE,unlinkSync as Zu,writeFileSync as QE}from"node:fs";import{homedir as Qu}from"node:os";import{join as as}from"node:path";import{existsSync as wh}from"node:fs";import{existsSync as Rh}from"node:fs";import{homedir as qc}from"node:os";import{join as Ch}from"node:path";function Zc(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}var Ah={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"}}};function Xc(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}function bh(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:Xc(n.mcpJson,t.mcpJson),mcpToml:Xc(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}function Qc(e){return Object.fromEntries(Object.entries(Ah).map(([t,n])=>[t,bh(n,n[e])]))}var vt=Qc("homeOnly"),it=Qc("projectOnly");function kh(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}function xh(e,t){return kh(e).some(n=>Rh(Ch(t,n)))}function eu(e,t){for(let n of e)if(xh(n,t))return!0;return!1}function st(e){return[...new Set(e)]}function at(e){let t=[],n=[],r=[],o=[],s=[],i=[],a=[];for(let c of e){t.push(...c.skillRoots);for(let l of c.dirs)l.kind==="SUBAGENT"?n.push(l.dir):l.kind==="COMMAND"?r.push(l.dir):o.push(l.dir);s.push(...c.memory.flat()),i.push(...c.settings),a.push(...c.mcpJson??[],...c.mcpToml??[])}return{skills:st(t),subagents:st(n),commands:st(r),rules:st(o),memory:st(s),settings:st(i),mcp:st(a)}}function Oh(e,t=qc(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...sr(o.managed,n,t));return st(r)}var ct=at(Object.values(vt));function tu(e=qc(),t=process.platform){return Oh(Object.values(vt),e,t)}import{existsSync as Ih}from"node:fs";import{resolve as zo}from"node:path";function ye(e){return zo(e).replaceAll("\\","/").replace(/\/$/,"")}function _t(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}function _r(e,t){if(!e)return t;let n=`${e}/`,r=[],o=[];for(let s of t)s===e||s.startsWith(n)?r.push(s):o.push(s);return r.length===0?t:[...r,...o]}var Th=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function on(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!Th.test(t)?null:t}function Mt(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let s=ye(o);n.has(s)||(n.add(s),r.push(s))}return r}function Ph(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}function Pe(e,t,n,r=Ih){for(let o of e)for(let s of t){let i=ye(zo(o,s)),a=zo(o,s,n).replaceAll("\\","/");if(Ph(i,a)&&r(a))return a}return null}var ru=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,ou=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,Nh=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,nu=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"]),vh=/^[a-z][a-z0-9-]{1,63}$/,Mh=[".cursor/skills",".claude/skills",".agents/skills"],Lh=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],Hh=_t(Mh,at(Object.values(it)).skills),Uh=_t(Lh,at(Object.values(vt)).skills),Dh=new Set(["read","read_file","view"]),Fh=new Set(["bash","shell","zsh"]);function Jo(e){let t=e.replace(/\\/g,"/");return ru.exec(t)?.[1]??null}function $h(e){let t=e.replace(/\\/g,"/"),r=ou.exec(t)?.[1];return r?r.toLowerCase():null}function jh(e){return Jo(e)??$h(e)}function Bh(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}function hr(e){return typeof e=="string"?hr(Se(e,null)):!e||typeof e!="object"?null:Bh(e)}function su(e){if(typeof e=="string")return su(Se(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}function Yo(e){let t=su(e.tool_input);if(t)return t;let n=pt(e.command);return n.length>0?n:null}function Kh(e){let t=e.replace(/\\/g,"/"),n=ru.exec(t);if(n?.[1])return n[1];let o=ou.exec(t)?.[1];return o?o.toLowerCase():null}function Gh(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}function Xo(e){let t=hr(e.tool_input)??pt(e.file_path);return t.length>0?t:null}function sn(e,t,n){let r=Gh(e).toLowerCase();if(Dh.has(r)){let o=Xo(e);return o?t(o):null}if(Fh.has(r)){let o=Yo(e);return o?n(o):null}return null}function iu(e){return sn(e,jh,Kh)}function Vh(e){let t=new Set,n=[];for(let r of e.matchAll(Nh)){let o=r[1]?.toLowerCase();!o||t.has(o)||Wh(o)||(t.add(o),n.push(o))}return n}function Wh(e){let t=e.split("/")[0];return nu.has(e)||t!==void 0&&nu.has(t)}function au(e){let t=e.skillId.toLowerCase();if(!vh.test(t))return null;let n=e.exists??wh,r=`${t}/SKILL.md`,o=Pe(Mt(e.launchCwd,e.gitRoot),Hh,r,n);return o!==null?o:e.home?Pe([ye(e.home)],Uh,r,n):null}function zh(e){return pt(e.prompt)}function cu(e){let t=L(e,"command_name");if(t){let r=L(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=zh(e);return n?Vh(n):[]}var ns=Qe(lt(),1);import{existsSync as yE}from"node:fs";var St={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function cn(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}function EE(e){if(!e)return"";let t=Xt(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return cn(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return cn(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?cn(o[1]):cn(t)}async function br(e=process.cwd()){let t=await Ae("git",["rev-parse","--is-inside-work-tree"],2e3,{cwd:e});if(!t.ok||t.stdout!=="true")return null;let[n,r,o,s]=await Promise.all([Ae("git",["remote","get-url","origin"],2e3,{cwd:e}),Ae("git",["branch","--show-current"],2e3,{cwd:e}),Ae("git",["rev-parse","HEAD"],2e3,{cwd:e}),Ae("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?Xt(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:s.ok?s.stdout.length>0:null}}async function vu(e,t,n,r=process.cwd(),o,s,i){if(t)return t;let a=St[n];if(!a)return"";let c=rc(n,e.scope_path,i);if(s){let g=fc(s,c);if(g)return g}let l=o??await br(r),u=l?.remote?EE(l.remote):"";if(u||(u=cn(process.env.GITHUB_REPOSITORY??"")),!u)return"";let d=e.scope_path??"",f=d?`${d}/`:"",p=`${u}:${f}${a}`;return s&&dc(s,c,p),p}var RE=[".cursor/rules",".claude/rules",".codex/rules"],CE=at(Object.values(it)).rules;function AE(e){return _t(_r(e?St[e]:void 0,RE),CE)}var bE=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function Mu(e){let t=on(e.relativePath);if(!t)return null;let n=e.exists??yE,r=Mt(e.launchCwd,e.gitRoot),o=AE(e.runnerPlatform),s=Pe(r,o,t,n);if(s!==null)return s;if(!t.includes("/")){let i=Pe(r,["."],t,n);if(i!==null)return i}return e.home?Pe([ye(e.home)],o,t,n):null}function kE(e){let t=e.replace(/\\/g,"/"),r=bE.exec(t)?.[1];return r?(0,ns.nativeKeyForRulePath)(r):null}function Lu(e){return sn(e,ns.nativeKeyForRulePath,kE)}function Hu(e){return e.replace(/\.(mdc|md|rules)$/i,"")}function Uu(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 s=o;if(s.type!=="rule")continue;let i=typeof s.file_path=="string"?s.file_path:"",a=on(i);!a||n.has(a)||(n.add(a),r.push(a))}return r}var rs=Qe(lt(),1);import{existsSync as xE}from"node:fs";var OE=[".cursor/commands",".claude/commands",".codex/prompts"],IE=at(Object.values(it)).commands;function TE(e){return _t(_r(e?St[e]:void 0,OE),IE)}var PE=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function Du(e){let t=on(e.commandId);if(!t)return null;let n=e.exists??xE,r=`${t}.md`,o=TE(e.runnerPlatform),s=Pe(Mt(e.launchCwd,e.gitRoot),o,r,n);return s!==null?s:e.home?Pe([ye(e.home)],o,r,n):null}function wE(e){let t=e.replace(/\\/g,"/"),r=PE.exec(t)?.[1];return r?(0,rs.nativeKeyForCommandPath)(r):null}function Fu(e){return sn(e,rs.nativeKeyForCommandPath,wE)}var kr=Qe(lt(),1);function $u(e,t){if(L(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}function NE(){return!!(M("CURSOR_VERSION")??M("CURSOR_PROJECT_DIR"))}function ju(e,t,n){return e!=="claude"&&e!=="codex"?!1:$u(t,n)?!0:NE()}var vE=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function un(e,t,n,r){return $u(e,t)?"cursor":qn(r)?r:qn(n)?n:L(e,"turn_id")?"codex":L(e,"session_id")||vE.has(t.toLowerCase())?"claude":"unknown"}function xr(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function ME(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":return"skill_invoked";default:return""}}function Bu(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}function Ku(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}function Gu(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}function ln(e){return L(e,"session_id")||L(e,"conversation_id")}function os(e){return L(e,"prompt.id")||L(e,"prompt_id")||L(e,"generation_id")||L(e,"turn_id")}function ss(e){return L(e,"hook_event_name")||L(e,"event")}function Vu(e,t,n){let r=ln(e),o=os(e),s=ss(e),i=L(e,"source"),a=un(e,s,t,n);return{sessionId:r,turnId:o,runnerEvent:s,hookSource:i,runnerPlatform:a}}var LE=["session_start","session_end","tool_invoked","skill_invoked"];function HE(e){return LE.includes(e)}function is(e,t){return e&&HE(e)?e:ME(t.toLowerCase())}var UE={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function Or(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}function Wu(e,t=""){let n=L(e,"tool_name")||L(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!Or(n)&&(n=`MCP:${n}`):n=UE[r]??null;let o=e.tool_input,i=(o&&typeof o=="object"?pt(o.skill)||pt(o.skill_name):"")||L(e,"skill_name")||null,a=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;i??=iu(a);let c=Lu(a),l=Fu(a);return{toolName:n,skillName:i,ruleName:c,commandName:l}}var DE=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function zu(e){for(let t of["subagent_type","agent_type"]){let n=L(e,t);if(n&&DE.test(n))return n}return null}function Ju(e){let t=$e(e,"duration_ms");if(typeof t=="number")return t;let n=$e(e,"duration");return typeof n=="number"?n:null}var FE="error",$E="interrupted",jE="permission_denied",BE=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function fn(e){return BE.test(e)?e:null}function KE(e){for(let t of["failure_type","error_type"]){let n=fn(L(e,t));if(n)return n}return null}function Yu(e,t){return $e(e,"is_interrupt")===!0?$E:t.toLowerCase()==="permissiondenied"?jE:KE(e)??FE}function Xu(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}function GE(e,t){return Xu(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}function VE(e,t){return Xu(t,n=>(0,kr.mcpServerNameMatchesToolSegment)(n,e))}function WE(e,t){let n=null,r=0;for(let s of t)if(s)for(let i of(0,kr.mcpServerToolSegmentForms)(s)){let a=`${i}__`;e.length>a.length&&e.slice(0,a.length).toLowerCase()===a.toLowerCase()&&i.length>r&&(n={mcpServer:s,mcpTool:e.slice(a.length)},r=i.length)}if(n!==null)return n;let o=/^(.+?)__(.+)$/.exec(e);return!o?.[1]||!o[2]?{mcpServer:null,mcpTool:null}:{mcpServer:VE(o[1],t)??o[1],mcpTool:o[2]}}function zE(e,t){if(/^mcp__/i.test(e))return WE(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:GE(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}function JE(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}function qu(e,t=[],n=""){let r=e?zE(e,t):{mcpServer:null,mcpTool:null},o=fn(n.trim());if(!o)return r;let s=r.mcpTool;return!s&&e&&!Or(e)&&(s=e),s&&(s=JE(s,o)),{mcpServer:o,mcpTool:s}}var el=3e4,ey="claims",ty=!0,ny=100,ry=new Set(["sessionstart","sessionend","stopfailure"]),oy=["tool_name","tool","command","file_path","url"];function sy(e=Qu()){return as(ge(e),ey)}function tl(e,t){try{let n=ZE(e,"utf8").split(`
30
+ `,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}function iy(e){let t=[];for(let n of oy){let r=L(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":qt(t.join("\0"))}function ay(e){let t=e.sessionId.trim();if(!t)return;let n=e.runnerEvent.trim().toLowerCase(),r=e.turnId.trim(),o=e.toolUseId.trim(),s=e.subagentId?.trim()??"",i=e.callFingerprint?.trim()??"",a=!!(o||r||s),c=ry.has(n);if(!a&&!c)return;let l=e.runnerPlatform.trim()||"unknown";return qt(`${l}|${t}|${n}|${r}|${o}|${i}|${s}`)}function cy(e,t=Date.now()){let n;try{n=qE(e)}catch{return}let r=0;for(let o of n){if(r>=ny)break;r+=1;let s=as(e,o),i=tl(s,t);if(!(!Number.isFinite(i)||i<el))try{Zu(s)}catch{}}}function uy(e,t,n=Date.now()){let r=as(t,e);try{if(YE(r)){let o=tl(r,n);if(Number.isFinite(o)&&o>=0&&o<el)return!1;try{Zu(r)}catch{}}}catch{}try{XE(t,{recursive:!0}),QE(r,`${n}
31
+ `,{encoding:"utf8",flag:"wx"})}catch(o){if(Jt(o))return!1;let s=o instanceof Error?o.message:String(o);return E(`WARN: event claim failed open: ${s}`),!0}return cy(t,n),!0}function ly(e,t,n){let r=ln(e),o=os(e),s=L(e,"tool_use_id"),i=L(e,"subagent_id")||L(e,"agent_id"),a=un(e,t,void 0,n),c=iy(e);return{runnerPlatform:a,sessionId:r,runnerEvent:t,turnId:o,toolUseId:s,subagentId:i,callFingerprint:c}}function nl(e,t,n,r=Qu(),o=Date.now()){if(!ty)return!0;let s=ay(ly(e,t,n));if(!s)return!0;let i=uy(s,sy(r),o);return!i&&M("EV_AI_HOOK_DEBUG")&&E(`DEBUG: duplicate hook event suppressed (claim ${s.slice(0,8)}\u2026)`),i}import{mkdirSync as fy,readFileSync as cs,statSync as il,unlinkSync as al,writeFileSync as us}from"node:fs";import{homedir as cl}from"node:os";function ul(e){return e==="session_start"||e==="session_end"}var Ir=new Set,rl=!1;function ls(e=cl()){return ta(e)}function fs(e,t=cl(),n=process.platform){if(e!==void 0)return e>0?e:jn(n);let r=q(mt(t),{});return ba(r)??jn(n)}function dn(e){return Gn(e.pid,e.acquiredAtMs)}function ll(e){try{let t=il(e);return t.isFile()&&t.size<=_o?cs(e,"utf8"):void 0}catch{return}}function ds(e,t=ls()){if(!e)return;let n=Kn(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=ll(n);if(o===dn(r))return Tr(r);if(o===Gn(process.ppid,e.acquiredAtMs))try{return us(n,dn(r),{encoding:"utf8",mode:384}),Tr(r)}catch{return}}function fl(e,t){if(e.path){Ir.delete(e);try{ll(e.path)===dn(e)&&us(e.path,Gn(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}function dl(e,t=Date.now()){let n,r;try{let o=il(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=_o?cs(e,"utf8"):""}catch{return!1}return ra(n,r,t)}function pl(e,t=ls(),n=Date.now){for(let r=0;r<e;r+=1)if(!dl(Kn(t,r),n()))return!0;return e<=0}function ml(e){return{pid:process.pid,acquiredAtMs:e}}function ol(e,t){let n=e instanceof Error?e.message:String(e);return E(`WARN: hook process slot failed open: ${n}`),ml(t)}function Tr(e){return Ir.add(e),rl||(rl=!0,process.once("exit",()=>{for(let t of[...Ir])Pr(t)})),e}function sl(e){try{return us(e.path,dn(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(Jt(t))return!1;throw t}}function gl(e,t=ls(),n=Date.now){if(e<=0)return ml(n());try{fy(t,{recursive:!0})}catch(s){return ol(s,n())}let r,o=0;for(let s=0;s<e;s+=1)try{let i={path:Kn(t,s),pid:process.pid,acquiredAtMs:n()};if(sl(i))return Tr(i);if(dl(i.path,n())){o+=1;continue}try{al(i.path)}catch(a){if(!Ot(a))throw a}if(i.acquiredAtMs=n(),sl(i))return Tr(i);o+=1}catch(i){r??=i}return r===void 0||o>0?null:ol(r,n())}function Pr(e,t=Date.now()){if(Ir.delete(e),!(!e.path||t-e.acquiredAtMs>=Bn-Yt))try{cs(e.path,"utf8")===dn(e)&&al(e.path)}catch{}}function ps(e){M("EV_AI_HOOK_DEBUG")&&E(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}import{closeSync as dy,writeSync as py}from"node:fs";function _l(e=process.env){let t=e[mo];if(delete e[mo],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{py(n,Vi)}catch{}try{dy(n)}catch{}}}function ms(e=process.env){let t=e[$i];if(t)return{launcherVersion:t,hookSource:e[ji]??"",fallbackReason:e[Bi],launcherScope:e[Ki]}}function hl(e,t){return(e?en(e):void 0)===t}import{readFileSync as hy,statSync as Sy}from"node:fs";import{homedir as Ey}from"node:os";import{join as yy}from"node:path";var yl="EV_AI_PERF_L",gs="EV_AI_PERF_H",my="EV_AI_HOOK_PERF";var gy=/^[a-z][a-z0-9_]{0,23}$/;var wr={origin:0,marks:{},values:{}},Nr=!1;function Rl(e=process.env){Nr=e[my]!=="0",wr.origin=performance.timeOrigin}function pn(){return Nr}function ze(e,t=performance.now()){Nr&&(wr.marks[e]=t)}function Cl(){return wr}function Al(e){return Math.round(e*10)/10}function Sl(e){return Object.entries(e).map(([t,n])=>`${t}=${Al(n)}`).join(",")}function _y(e){return`${Al(e.origin)}|${Sl(e.marks)}|${Sl(e.values)}`}function El(e,t){if(!e)return!0;for(let n of e.split(",")){let r=n.indexOf("="),o=n.slice(0,r),s=Number(n.slice(r+1));if(r<1||!gy.test(o)||!(s>=0&&s<=36e5))return!1;t[o]=s}return Object.keys(t).length<=32}function _s(e){if(!e||e.length>1024)return;let[t,n,r,...o]=e.split("|"),s=Number(t);if(o.length>0||!Number.isFinite(s)||s<=0)return;let i={origin:s,marks:{},values:{}};if(!(!El(n,i.marks)||!El(r,i.values)))return i}function bl(){return Nr?_y(wr):void 0}var Ry="perf-prev.json",Cy=512,Ay=1440*60*1e3,by=12e4,ky=50,mn={},kl=!1;function Ss(e){return Math.round(e*10)/10}function Ne(e,t){if(!pn())return t();let n=performance.now();return t().finally(()=>{mn[e]=Ss(performance.now()-n)})}function xy(){for(let e of Object.keys(mn))delete mn[e]}function Ol(){if(!pn())return;let e=bl();e&&(process.env[gs]=e)}function xl(e,t){if(!e)return;let n=t-e.origin;return n>=-ky&&n<=by?e:void 0}function Oy(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}function Il(e=Ey()){return yy(ge(e),Ry)}function Iy(e,t){if(!kl){kl=!0;try{let n=Il(t);if(Sy(n).size>Cy)return;let r=JSON.parse(hy(n,"utf8"));return!Oy(r)||e-r.at>Ay?void 0:{at:r.at,post_ms:r.post_ms}}catch{return}}}function Es(e,t){if(!pn())return;let n={at:Date.now(),post_ms:Math.max(0,Math.round(e))};try{ce(Il(t),JSON.stringify(n))}catch{}}function hs(e,t,n,r,o=n.marks){let s=Math.max(0,n.origin-r);e[t]=Ss(s);for(let[i,a]of Object.entries(o))e[i]=Ss(s+a)}function Tl(e,t=process.env,n,r=!1){let o=r?$a():void 0;if(!pn())return o?{sys:o}:void 0;let s=Cl(),i="w0"in s.marks?"w":"h",a=i==="w"?xl(_s(t[gs]),s.origin):void 0,c=xl(_s(t[yl]),(a??s).origin),l=c?"l":a?"h":i,u=(c??a??s).origin,d={};c&&hs(d,"l",c,u),a&&hs(d,"h",a,u),hs(d,i,s,u,{...s.marks,...e});let f={base:l,t:d};i==="w"&&a&&d.h3!==void 0&&(f.ack_ms=d.h3),c?.values.bootstrap===1&&(f.bootstrap=!0),Object.keys(mn).length>0&&(f.spans={...mn},xy());let p=Iy(Date.now(),n);return p&&(f.prev=p),o&&(f.sys=o),f}import{realpathSync as Vk}from"node:fs";import{homedir as Wk}from"node:os";var B=Qe(lt(),1);import{existsSync as Ty,readFileSync as Py}from"node:fs";import{homedir as Pl}from"node:os";import{join as wy}from"node:path";var Ny="cloud-cache.json",vy=1440*60*1e3,My=900*1e3;function Ly(e=Pl()){return wy(ge(e),Ny)}function Hy(e){if(!Ty(e))return;let t=Se(Py(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}}function Uy(e,t){try{ce(e,`${JSON.stringify(t)}
32
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: cloud cache write failed open: ${r}`)}}function Dy(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?My:vy;return n-e.probed_at<r}async function Fy(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,s]=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&&!s?.ok)return;let i=o?.ok?(await o.text()).trim():"",a=s?.ok?(await s.text()).trim():"";if(!(!i&&!a))return{provider:"aws",region:i,instance_id:a}}async function $y(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}}async function jy(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}}async function By(e){let t=await Promise.allSettled([Fy(e),$y(e),jy(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}async function wl(e,t){if(e==="interactive")return null;let n=t?.home??Pl(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),s=Ly(n),i=Hy(s);if(Dy(i,e,o))return i.result;let a=await By(r);return Uy(s,{context:e,probed_at:o,result:a}),a}var Ll=Qe(lt(),1);import{existsSync as vl}from"node:fs";import{homedir as Ml}from"node:os";import{join as gn,resolve as ys,sep as Nl}from"node:path";function vr(e,t,n){if(!vl(e))return;let r=q(e,{});for(let[o,s]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:s})}function Ky(e,t,n){if(!vl(e))return;let r=q(e,{}),o=ys(t),s=null;for(let a of Object.keys(r.projects??{})){let c=ys(a);(o===c||o.startsWith(c.endsWith(Nl)?c:c+Nl))&&(s===null||c.length>ys(s).length)&&(s=a)}if(s===null)return;let i=r.projects?.[s]?.mcpServers??{};for(let[a,c]of Object.entries(i))n.set(a,{declared:{name:a,source:"claude_json_project",sourcePath:".claude.json",scope:"user"},config:c})}function Hl(e,t,n,r){let o=new Map;for(let s of e.mcp_servers??[])s.name&&o.set(s.name,{declared:{name:s.name,source:"manifest"}});return n==="claude"?(vr(gn(r,".claude.json"),{source:"claude_json_user"},o),Ky(gn(r,".claude.json"),t,o)):n==="cursor"&&vr(gn(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),vr(gn(t,".mcp.json"),{source:"mcp_json"},o),vr(gn(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}async function Rs(e,t=process.cwd(),n="claude",r=Ml()){return[...Hl(e,t,n,r).values()].map(o=>o.declared)}function Ul(e,t,n=process.cwd(),r="claude",o=Ml()){let s=Hl(t,n,r,o),i=s.get(e);if(i!==void 0)return i.config??null;for(let[a,c]of s)if((0,Ll.mcpServerNameMatchesToolSegment)(a,e))return c.config??null;return null}var Gy=["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"],Vy=["CURSOR_PROJECT_DIR"],Wy=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function zy(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)Wy.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}function Dl(e=process.env){let t=Gy.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:zy(e[r]??"")}:{name:r,present:!1}),n=Vy.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}import{homedir as AR}from"node:os";import{homedir as Fl}from"node:os";import{join as Jy}from"node:path";function Yy(e=Fl()){return Jy(e,".claude.json")}function Mr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function $l(e=Fl()){let n=q(Yy(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=Mr(n.emailAddress),o=Mr(n.fullName)??Mr(n.displayName),s=Mr(n.accountUuid),i=r??s;return!i||me(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:i,identity_source:"claude_oauth"}}import{homedir as Kl}from"node:os";import{join as jl}from"node:path";var Xy="https://api.openai.com/auth";function Ut(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Gl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function qy(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 Gl(r)}catch{return null}}function Bl(e,t,n){return Ut(e[n])??Ut(t?.[n])}function Zy(e=process.env,t=Kl()){let n=Ut(e.CODEX_HOME)??jl(t,".codex");return jl(n,"auth.json")}function Vl(e=process.env,t=Kl()){let n=q(Zy(e,t),{}),r=Ut(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&Ut(n.OPENAI_API_KEY))return null;let o=Ut(n.tokens?.id_token);if(!o)return null;let s=qy(o);if(!s)return null;let i=Gl(s[Xy]),a=Bl(s,i,"name"),c=Bl(s,i,"email");return!c||me(a,c)?null:{git_user_name:null,git_user_email:null,platform_login:c,identity_source:"codex_oauth"}}import{homedir as Ur}from"node:os";import{join as Je}from"node:path";import{join as Qy}from"node:path";var eR="cursor-ide-identity.json",tR=840*60*1e3;function zl(e){return Qy(ge(e),eR)}function Wl(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Jl(e){let t=q(e,{}),n=t.read_at_ms,r=t.db_path;if(!(typeof n!="number"||!Number.isFinite(n)||typeof r!="string"))return{read_at_ms:n,db_path:r,email:Wl(t.email),auth_id:Wl(t.auth_id)}}function Yl(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<tR}function Xl(e,t){try{ce(e,`${JSON.stringify(t)}
33
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: cursor IDE identity cache write failed open: ${r}`)}}import{execFileSync as nR}from"node:child_process";import{existsSync as rR}from"node:fs";import{createRequire as oR}from"node:module";import{pathToFileURL as sR}from"node:url";var Zl=oR(import.meta.url),Lr=`
33
34
  SELECT key, value
34
35
  FROM ItemTable
35
36
  WHERE key LIKE 'cursorAuth/%'
36
37
  AND key NOT LIKE '%Token%'
37
38
  AND key NOT LIKE '%token%'
38
39
  ORDER BY key
39
- `.trim(),ys=new Map;function Kl(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}function Vl(e){return e.toLowerCase().includes("token")}function Wl(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=Kl(r.key),s=Kl(r.value);o&&s&&!Vl(o)&&t.set(o,s)}return t}function jy(e){let t=$y(e);return t.search="mode=ro&immutable=1",t.href}function By(e){try{let t=Gl("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(Nr)??n.prepare(Nr);return Wl(r.all?.())}finally{n.close?.()}}catch{return null}}function Ky(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}}function Gy(e){try{return Ky(()=>{let t=Gl("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return Wl(n.prepare(Nr).all?.())}finally{n.close?.()}})}catch{return null}}function Vy(e){let t=new Map;for(let n of e.split(`
40
- `)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let s=r.slice(0,o).trim(),i=r.slice(o+1).trim();s&&i&&!Vl(s)&&t.set(s,i)}return t}function Wy(e){try{let t=Uy("sqlite3",["-noheader","-batch","-separator"," ",e,Nr],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return Vy(t)}catch{return null}}function zl(e){let t=ys.get(e);if(t)return t;if(!Dy(e)){let o=new Map;return ys.set(e,o),o}let n=jy(e),r=By(n)??Wy(n)??Gy(n)??new Map;return ys.set(e,r),r}var zy="cursorAuth/cachedEmail",Jy="cursorAuth/stripeMembershipAuthId";function vr(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function Yy(e=Mr(),t=process.platform,n=process.env){let r=vr(n.VSCODE_PORTABLE);if(r)return We(r,"user-data");let o=vr(n.VSCODE_APPDATA);if(o)return We(o,"Cursor");switch(t){case"darwin":return We(e,"Library","Application Support","Cursor");case"win32":return We(vr(n.APPDATA)??We(e,"AppData","Roaming"),"Cursor");default:return We(vr(n.XDG_CONFIG_HOME)??We(e,".config"),"Cursor")}}function Xy(e=Mr()){return We(e,".cursor","cli-config.json")}function qy(e=Mr(),t=process.platform,n=process.env){return We(Yy(e,t,n),"User","globalStorage","state.vscdb")}function mn(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Zy(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):mn(e.userId)}function Qy(e){return mn(e.email)??mn(e.authId)??Zy(e)}function Rs(e){let t=mn(e.email),n=mn(e.displayName),r=Qy(e);return!r||me(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}function eR(e){let n=Z(Xy(e),{}).authInfo;return!n||typeof n!="object"?null:Rs(n)}function tR(e,t,n){let r=qy(e,process.platform,t),o=Fl(e),s=$l(o);if(jl(s,r,n))return Rs({email:s?.email,authId:s?.auth_id});let i=zl(r),a=i.get(zy)??null,c=i.get(Jy)??null;return Bl(o,{read_at_ms:n,db_path:r,email:a,auth_id:c}),Rs({email:a,authId:c})}function Jl(e=Mr(),t=process.env,n=Date.now()){return eR(e)??tR(e,t,n)}import{createHash as nR}from"node:crypto";import{resolve as rR}from"node:path";function q(e){return nR("sha256").update(e).digest("hex").slice(0,16)}function Cs(e){return q(rR(e))}function ye(e,t){return`${e}\0${t}`}function Lr(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}function Yl(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}function gn(e){let n=[...e].sort((r,o)=>{let s=r.path.localeCompare(o.path);return s!==0?s:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
41
- `);return q(n)}function sR(e,t,n="git_config",r=null){return q(`${e??""}|${t??""}|${r??""}|${n}`)}function iR(e){let t=null,n=null;for(let r of e.split(`
42
- `)){let o=r.trim();if(!o)continue;let s=o.indexOf(" ");if(s<=0)continue;let i=o.slice(0,s).toLowerCase(),a=o.slice(s+1).trim();a&&(i==="user.name"?t=a:i==="user.email"&&(n=a))}return{git_user_name:t,git_user_email:n,platform_login:null}}async function aR(e,t=ne){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return iR(n)}function cR(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 s=j(e.EMAIL);return s?{git_user_name:null,git_user_email:s,platform_login:null,identity_source:"git_env"}:null}function ze(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}function uR(e=process.env){let t=j(e.EV_AI_HOOK_OPERATOR_EMAIL),n=j(e.EV_AI_HOOK_OPERATOR_LOGIN),r=ze(j(e.EV_AI_HOOK_OPERATOR_NAME),t,"configured",t??n);if(r)return r;let o=j(e.GITHUB_ACTOR)??j(e.GITHUB_TRIGGERING_ACTOR)??j(e.GITHUB_USER),s=ze(o,null,"github",o);if(s)return s;let i=j(e.GITLAB_USER_LOGIN),a=j(e.GITLAB_USER_EMAIL),c=ze(j(e.GITLAB_USER_NAME)??i,a,"gitlab",a??i);if(c)return c;let l=j(e.BUILD_REQUESTEDFOREMAIL),u=ze(j(e.BUILD_REQUESTEDFOR),l,"azure_devops",l??j(e.BUILD_REQUESTEDFORID));if(u)return u;let d=j(e.BUILDKITE_BUILD_CREATOR_EMAIL),f=ze(j(e.BUILDKITE_BUILD_CREATOR),d,"buildkite",d);if(f)return f;let p=j(e.BUILD_USER_EMAIL)??j(e.CHANGE_AUTHOR_EMAIL),g=ze(j(e.BUILD_USER)??j(e.CHANGE_AUTHOR),p,"jenkins",p??j(e.BUILD_USER_ID));if(g)return g;let S=j(e.CIRCLE_USERNAME),A=ze(S,null,"circleci",S);if(A)return A;let b=j(e.CODEBUILD_INITIATOR),O=ze(b,null,"codebuild",b);if(O)return O;let P=j(e.DRONE_COMMIT_AUTHOR_EMAIL),I=j(e.DRONE_COMMIT_AUTHOR),T=ze(I??j(e.DRONE_COMMIT_AUTHOR_NAME),P,"drone",P??I);if(T)return T;if(Xl(e.CLAUDE_CODE_REMOTE)||Xl(e.CURSOR_AGENT)){let K=j(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:K&&!me(null,K)?K:null,identity_source:"cloud"}}return null}function As(e){return!!((e.git_user_name??e.git_user_email)&&!me(e.git_user_name,e.git_user_email))}function j(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function Xl(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function lR(e,t,n){return e==="claude"?Nl(t):e==="cursor"?Jl(t,n):e==="codex"?Ul(n,t):null}async function bs(e,t=ne,n=process.env,r={}){let o=await aR(e,t),s=cR(n),i=As(o)?o:s&&As(s)?s:null,a=lR(r.runnerPlatform,r.home??oR(),n);if(a)return{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:a.platform_login,identity_source:a.identity_source};let c=uR(n);return c?.platform_login?{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:c.platform_login,identity_source:c.identity_source}:i?{...i,platform_login:null,identity_source:As(o)?"git_config":"git_env"}:c||(o.git_user_name||o.git_user_email?{...o,identity_source:"git_config"}:s||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}async function ks(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??ne,s=e.env??process.env,i=await bs(t,o,s,{runnerPlatform:e.runnerPlatform,home:e.home}),a=sR(i.git_user_name,i.git_user_email,i.identity_source,i.platform_login),l=(n?vo(n):void 0)?.operator_identity_hash;if(!(r||l!==void 0&&l!==a||!l))return{commit:()=>{}};let p=n;return{operator:i,commit:()=>{p&&rc(p,a,Gn())}}}function xs(e){return e?!vo(e)?.operator_identity_hash:!0}function ql(e){return!0}import{existsSync as xb,readFileSync as Ob}from"node:fs";import{homedir as Cp}from"node:os";import{join as jt,resolve as Ib}from"node:path";import{basename as Sb,join as $t}from"node:path";import{dirname as cf,resolve as Fr}from"node:path";import{existsSync as fR}from"node:fs";import{homedir as ef}from"node:os";import{relative as tf,resolve as Ne,sep as ct}from"node:path";var dR=["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"],pR=["prompt","tool_input","tool_response","last_assistant_message","command"],mR=new Set;function gR(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return mR}}function ws(e){let t=M("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?Xt.has(t.toLowerCase()):e?.collect_prompt===!0}function Hr(e,t){let n=nf(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=M("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?Xt.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}function nf(e){return M("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||e.debug===!0||M("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}function _R(e){let t={};for(let n of dR){let r=Fe(e,n);r!==void 0&&(t[n]=r)}return t}function Ur(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Ne(e),r=Ne(t),o=tf(r,n);return!o||o==="."?".":o.startsWith(`..${ct}`)||o===".."||Ne(r,o)!==n?null:o.split(ct).join("/")}function rf(e,t){let n=tf(Ne(t),Ne(e)).split(ct).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}function of(e){return typeof e!="string"||e.length===0?null:Ne(e).split(ct).join("/")}function hR(){let e=M("CURSOR_PROJECT_DIR");if(!e)return null;let t=Ne(e);return fR(t)?t.split(ct).join("/"):null}function Is(e,t){return Ur(e,t)!==null}function SR(e,t){let n=Ne(t??ef(),".cursor").split(ct).join("/");return Is(e,n)}function ER(e,t,n){return t!==null&&Is(e,t)?!0:t!==null&&SR(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&Is(e,n.gitRoot)?!0:t===null}function sf(e,t){let n=of(e.cwd);if(n!==null)return n;let r=Ne(process.cwd()).split(ct).join("/"),o=hR();return ER(r,o,t)?r:o??r}function Ns(e,t={}){return sf(e,t)}function vs(e,t=ef()){let n=Ne(t).split(ct).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function Zl(e,t,n){let r=of(n.launchCwd)??sf(t,n);e.cwd=vs(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?Ur(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}var af="\u2026[truncated]\u2026",Ts=Buffer.byteLength(af,"utf8"),yR=8;function _n(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Ql(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}function RR(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(n.length-t).toString("utf8")}function CR(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=Ts)return Ql(e,t);let r=t-Ts,o=Math.ceil(r/2),s=Math.floor(r/2);return`${Ql(e,o)}${af}${RR(e,s)}`}function Ps(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)=>{Ps(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||Ps(o,[...t,r],n)}function AR(e,t,n){let r=e;for(let s=0;s<t.length-1;s++){let i=t[s];if(i===void 0)return;r=(Array.isArray(r),r[i])}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}}var bR=256;function kR(e,t,n){let r=n,o=Math.max(n,e[0]?.bytes??n);for(;r<o;){let s=Math.ceil((r+o)/2),i=0;for(let a of e)a.bytes>s&&(i+=a.bytes-s);i>=t?r=s:o=s-1}return r}function xR(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let s=_n(e);if(s<=t)return;let i=[];Ps(e,[],i),i.sort((u,d)=>d.bytes-u.bytes);let a=i.filter(u=>u.bytes>n);if(a.length===0)return;let c=kR(a,s-t,n),l=Math.max(n,Math.min(c,r-1));if(l>=r)return;r=l;for(let u of a)u.bytes>r&&AR(e,u.path,CR(u.value,r))}}function OR(e,t){let n=Math.max(0,t-bR),r=Object.keys(e).filter(s=>!s.startsWith("_")).map(s=>({key:s,bytes:_n(e[s])})).sort((s,i)=>i.bytes-s.bytes),o=[];for(let{key:s}of r){if(_n(e)<=n)break;delete e[s],o.push(s)}o.length>0&&(e._dropped_keys=o.slice(0,10))}function Os(e,t){let n=_n(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,xR(r,t,Ts+yR),_n(r)>t&&OR(r,t),r}function IR(e,t,n){if(!(n.promptCapture??ws()))return;let r=gR(n.runnerEvent);for(let o of pR){if(r.has(o))continue;let s=t[o];s!==void 0&&(e[o]=s)}}function Dr(e,t,n={}){let r=nf(t);if(r==="full"){let s={...e};return delete s.cwd,delete s.transcript_path,Zl(s,e,n),Os(s,xo)}let o=_R(e);return Zl(o,e,n),r==="content"?(IR(o,e,n),Os(o,xo)):Os(o,Ta)}function TR(e){return typeof e=="string"&&e.length>0}function Ms(e){let t=Fr(e.home),n=Fr(e.launchCwd),r=e.gitRoot?Fr(e.gitRoot):null,o=new Set,s=[],i=null;e.inGitRepo&&TR(e.remote)&&r!==null&&r!==t&&(i=r,o.add(r)),n!==t&&!o.has(n)&&(s.push({scope:"cwd",dir:n}),o.add(n)),i!==null&&s.push({scope:"repo",dir:i});let a=null,c=r!==null&&Ur(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&c){let l=cf(r);for(;;){let u=Fr(l);if(u===t)break;let d=cf(u);if(d===u)break;if(e.hasProjectSpec(u)){s.push({scope:"parent",dir:u}),a=rf(u,n);break}l=d}}return{anchors:s,parentRel:a}}import{existsSync as uf,readdirSync as PR,realpathSync as wR}from"node:fs";import{basename as NR,dirname as vR,relative as MR,resolve as LR,sep as HR}from"node:path";var Ls=400,$r=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??Ze}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=LR(t).split(HR).join("/");return vs(r,this.home)}let n=MR(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${q(vR(t))}/${NR(t)}`:n}claimFile(t){try{let n=wR(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(!uf(t))return[];try{return PR(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(uf(t))return Z(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(),s=t-(this.pluginExpandRemaining??0);return{result:o,expanded:s}}finally{this.pluginExpandRemaining=r}}};import{existsSync as Qs,readFileSync as sA,statSync as iA}from"node:fs";import{basename as bd,join as St,relative as ei}from"node:path";var yd=qe(Ed());var rA=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],Rd=rA.map(e=>yd.default.matcher(e,{dot:!0}));function oA(e){return e===""?!1:Rd.some(t=>t(`${e}/`))}function Cd(e,t){if(t==="")return!1;if(e==="")return oA(t);let n=e.replace(/\/+$/,"");return Rd.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}var ti=100*1024,aA=4;function cA(e){return e.length<=ti?e:`${e.slice(0,ti-1)}\u2026`}function uA(e){try{let t=sA(e),n=t.toString("utf8");return{hash:q(t),length:t.length,text:cA(n)}}catch{return null}}var Ad={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function lA(e){return e in Ad?Ad[e]:"UNSPECIFIED"}function Dt(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=uA(t.absolutePath);if(!n)return!1;let r=t.name??bd(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},s=lA(t.kind);return s&&(o.trigger=s),t.attributes&&(o.attributes=t.attributes),e.push(o)}function fA(e,t,n){let r=ei(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?bd(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}function Et(e,t){let{dir:n,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c}=t;ni(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c})}function ni(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u}=t;if(!(o>aA))for(let d of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(d.isDirectory()&&Cd(n.replace(/\\/g,"/"),ei(n,St(r,d.name)).replace(/\\/g,"/"))||d.isDirectory()&&u?.includes(St(r,d.name)))continue;if(c){if(!d.isDirectory())continue;let g=St(r,d.name,c);if(Qs(g)){let S=ei(n,St(r,d.name)).replace(/\\/g,"/");Dt(e,{absolutePath:g,kind:s,origin:i,enabled:a,name:S||d.name});continue}ni(e,{walkRoot:n,currentDir:St(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(d.isDirectory()){ni(e,{walkRoot:n,currentDir:St(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(!d.isFile()||!l)continue;let f=d.name.toLowerCase();if(!l.some(g=>f.endsWith(g)))continue;let p=St(r,d.name);Dt(e,{absolutePath:p,kind:s,origin:i,enabled:a,name:fA(n,p,!0)})}}function kd(e){for(let t of e)if(Qs(t))try{if(iA(t).size>0)return t}catch{continue}return e.find(t=>Qs(t))}import{existsSync as jA,readFileSync as BA}from"node:fs";var zr=qe(at(),1);var dA="<omitted>",pA=["package_name","package_spec","package_version","package_version_source"],xd=100,Od=120,Jr=[{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"}],Id=new Set(Jr.map(e=>e.attr)),mA=["enabled","disabled"],gA=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],_A=new Set(["type","command","url","args","env","envVars","headers",...mA,...gA,...Jr.map(e=>e.raw)]),hA=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",...pA,...Id,...[...Id].map(e=>`${e}_truncated`)]);function Td(e,t){for(let n of t)_A.has(n)||hA.has(n)||(e[n]=dA)}var SA=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,EA=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,yA=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,RA=/^bearer(?:\s+|$)/i;function Yr(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Pd(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function ri(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=Yr(e);return t?Object.keys(t).filter(n=>n.length>0):[]}function yt(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}function CA(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,zr.launchContainsCredentials)({kind:"url",url:e})||(0,zr.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=An([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,zr.launchContainsCredentials)({kind:"url",url:r}):!0)}function wd(e,t,n){CA(t,n)&&(e.launch_had_credentials=!0)}function AA(e){return yA.test(e)||RA.test(e)?"<redacted>":e.includes("://")?yt(e):e}function Nd(e){if(/^https?:\/\//i.test(e))return yt(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${Nd(e.slice(t+1))}`:AA(e)}function bA(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return SA.test(t)||EA.test(t)}function An(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(bA(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(Nd(r))}return t}function kA(e){let t=Pd(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Od?r.slice(0,Od):r))].sort();if(n.length!==0)return n.length>xd?{names:n.slice(0,xd),truncated:!0}:{names:n,truncated:!1}}function xA(e){let t=Yr(e);if(!t)return{headers:[],envVars:[]};let n=[],r=[];for(let[o,s]of Object.entries(t))o.length>0&&n.push(o),typeof s=="string"&&s.length>0&&r.push(s);return{headers:n,envVars:r}}function vd(e,t){let n=new Set;for(let{raw:r,attr:o}of Jr){if(n.has(o)||!(r in t))continue;let s=t[r];if(o==="auto_approve"&&typeof s=="boolean"){e.auto_approve=s,n.add(o);continue}let i=kA(s);i&&(e[o]=i.names,i.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}function Md(e,t){let n=Yr(e),r={transport:t};if(!n)return r;Td(r,Object.keys(n));let o=typeof n.command=="string"?n.command:void 0,s=typeof n.url=="string"?n.url:void 0,i=typeof n.serverUrl=="string"?n.serverUrl:void 0,a=o??s??i,c=Pd(n.args);a&&(r.command_or_url=yt(a));let l=An(c);l.length>0&&(r.args=l),wd(r,a,c);let u=xA(n.env_http_headers),d=[...new Set([...ri(n.env),...ri(n.envVars),...ri(n.env_vars),...u.envVars,...typeof n.bearer_token_env_var=="string"&&n.bearer_token_env_var.length>0?[n.bearer_token_env_var]:[]])].sort();d.length>0&&(r.env_var_names=d),u.headers.length>0&&(r.env_http_header_names=[...new Set(u.headers)].sort());for(let S of["headers","http_headers","env_http_headers"])if(n[S]!==void 0&&n[S]!==null){r.headers_present=!0;break}let f=typeof n.auth=="string"?n.auth:void 0;f&&(r.auth=f);let p=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;p&&(r.bearer_token_env_var=p);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),vd(r,n),r}function Ld(e){let t=Yr(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}function ii(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}))}function Ft(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function Cn(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):[]}function si(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}function oi(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=Ft(n[1]);return r.length>0?r:void 0}function OA(e,t){let n=[],r=i=>{for(let a of i.split(/[,\n]/)){let c=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(a);c?.[1]&&n.push([c[1],Ft(c[2]??"")])}},o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let s=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
43
- ${e}`);return s?.[1]&&r(s[1]),n}function Hd(e){return si(e,"enabled")===!1?!1:si(e,"disabled")!==!0}function IA(e,t){let n={};for(let{raw:r,attr:o}of Jr){if(o==="auto_approve"){let i=si(t,r);if(i!==void 0){n[r]=i;continue}}let s=Cn(t,r);s.length>0&&(n[r]=s)}vd(e,n)}var TA=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,PA=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function wA(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
44
- `)){let s=TA.exec(o);s?.[1]&&t.add(s[1])}for(let o of e.matchAll(PA))o[1]&&t.add(o[1]);return[...t]}function Ud(e,t){let n={transport:t};Td(n,wA(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),s=r?Ft(r[1]??""):void 0,i=o?Ft(o[1]??""):void 0,a=s!==void 0&&s.length>0?s:i,c=Cn(e,"args");a&&(n.command_or_url=yt(a));let l=An(c);l.length>0&&(n.args=l),wd(n,a,c);let u=new Set;for(let b of e.split(`
45
- `)){let O=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);O?.[1]&&u.add(O[1])}let d=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(d?.[1])for(let b of d[1].split(",")){let O=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);O?.[1]&&u.add(O[1])}let f=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
40
+ `.trim(),Cs=new Map;function ql(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}function Ql(e){return e.toLowerCase().includes("token")}function ef(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=ql(r.key),s=ql(r.value);o&&s&&!Ql(o)&&t.set(o,s)}return t}function iR(e){let t=sR(e);return t.search="mode=ro&immutable=1",t.href}function aR(e){try{let t=Zl("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(Lr)??n.prepare(Lr);return ef(r.all?.())}finally{n.close?.()}}catch{return null}}function cR(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}}function uR(e){try{return cR(()=>{let t=Zl("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return ef(n.prepare(Lr).all?.())}finally{n.close?.()}})}catch{return null}}function lR(e){let t=new Map;for(let n of e.split(`
41
+ `)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let s=r.slice(0,o).trim(),i=r.slice(o+1).trim();s&&i&&!Ql(s)&&t.set(s,i)}return t}function fR(e){try{let t=nR("sqlite3",["-noheader","-batch","-separator"," ",e,Lr],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return lR(t)}catch{return null}}function tf(e){let t=Cs.get(e);if(t)return t;if(!rR(e)){let o=new Map;return Cs.set(e,o),o}let n=iR(e),r=aR(n)??fR(n)??uR(n)??new Map;return Cs.set(e,r),r}var dR="cursorAuth/cachedEmail",pR="cursorAuth/stripeMembershipAuthId";function Hr(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function mR(e=Ur(),t=process.platform,n=process.env){let r=Hr(n.VSCODE_PORTABLE);if(r)return Je(r,"user-data");let o=Hr(n.VSCODE_APPDATA);if(o)return Je(o,"Cursor");switch(t){case"darwin":return Je(e,"Library","Application Support","Cursor");case"win32":return Je(Hr(n.APPDATA)??Je(e,"AppData","Roaming"),"Cursor");default:return Je(Hr(n.XDG_CONFIG_HOME)??Je(e,".config"),"Cursor")}}function gR(e=Ur()){return Je(e,".cursor","cli-config.json")}function _R(e=Ur(),t=process.platform,n=process.env){return Je(mR(e,t,n),"User","globalStorage","state.vscdb")}function _n(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function hR(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):_n(e.userId)}function SR(e){return _n(e.email)??_n(e.authId)??hR(e)}function As(e){let t=_n(e.email),n=_n(e.displayName),r=SR(e);return!r||me(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}function ER(e){let n=q(gR(e),{}).authInfo;return!n||typeof n!="object"?null:As(n)}function yR(e,t,n){let r=_R(e,process.platform,t),o=zl(e),s=Jl(o);if(Yl(s,r,n))return As({email:s?.email,authId:s?.auth_id});let i=tf(r),a=i.get(dR)??null,c=i.get(pR)??null;return Xl(o,{read_at_ms:n,db_path:r,email:a,auth_id:c}),As({email:a,authId:c})}function nf(e=Ur(),t=process.env,n=Date.now()){return ER(e)??yR(e,t,n)}import{createHash as RR}from"node:crypto";import{resolve as CR}from"node:path";function Z(e){return RR("sha256").update(e).digest("hex").slice(0,16)}function bs(e){return Z(CR(e))}function Re(e,t){return`${e}\0${t}`}function Dr(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}function rf(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}function hn(e){let n=[...e].sort((r,o)=>{let s=r.path.localeCompare(o.path);return s!==0?s:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
42
+ `);return Z(n)}function bR(e,t,n="git_config",r=null){return Z(`${e??""}|${t??""}|${r??""}|${n}`)}function kR(e){let t=null,n=null;for(let r of e.split(`
43
+ `)){let o=r.trim();if(!o)continue;let s=o.indexOf(" ");if(s<=0)continue;let i=o.slice(0,s).toLowerCase(),a=o.slice(s+1).trim();a&&(i==="user.name"?t=a:i==="user.email"&&(n=a))}return{git_user_name:t,git_user_email:n,platform_login:null}}async function xR(e,t=ne){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return kR(n)}function OR(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 s=j(e.EMAIL);return s?{git_user_name:null,git_user_email:s,platform_login:null,identity_source:"git_env"}:null}function Ye(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}function IR(e=process.env){let t=j(e.EV_AI_HOOK_OPERATOR_EMAIL),n=j(e.EV_AI_HOOK_OPERATOR_LOGIN),r=Ye(j(e.EV_AI_HOOK_OPERATOR_NAME),t,"configured",t??n);if(r)return r;let o=j(e.GITHUB_ACTOR)??j(e.GITHUB_TRIGGERING_ACTOR)??j(e.GITHUB_USER),s=Ye(o,null,"github",o);if(s)return s;let i=j(e.GITLAB_USER_LOGIN),a=j(e.GITLAB_USER_EMAIL),c=Ye(j(e.GITLAB_USER_NAME)??i,a,"gitlab",a??i);if(c)return c;let l=j(e.BUILD_REQUESTEDFOREMAIL),u=Ye(j(e.BUILD_REQUESTEDFOR),l,"azure_devops",l??j(e.BUILD_REQUESTEDFORID));if(u)return u;let d=j(e.BUILDKITE_BUILD_CREATOR_EMAIL),f=Ye(j(e.BUILDKITE_BUILD_CREATOR),d,"buildkite",d);if(f)return f;let p=j(e.BUILD_USER_EMAIL)??j(e.CHANGE_AUTHOR_EMAIL),g=Ye(j(e.BUILD_USER)??j(e.CHANGE_AUTHOR),p,"jenkins",p??j(e.BUILD_USER_ID));if(g)return g;let S=j(e.CIRCLE_USERNAME),A=Ye(S,null,"circleci",S);if(A)return A;let b=j(e.CODEBUILD_INITIATOR),I=Ye(b,null,"codebuild",b);if(I)return I;let P=j(e.DRONE_COMMIT_AUTHOR_EMAIL),T=j(e.DRONE_COMMIT_AUTHOR),O=Ye(T??j(e.DRONE_COMMIT_AUTHOR_NAME),P,"drone",P??T);if(O)return O;if(of(e.CLAUDE_CODE_REMOTE)||of(e.CURSOR_AGENT)){let K=j(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:K&&!me(null,K)?K:null,identity_source:"cloud"}}return null}function ks(e){return!!((e.git_user_name??e.git_user_email)&&!me(e.git_user_name,e.git_user_email))}function j(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function of(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function TR(e,t,n){return e==="claude"?$l(t):e==="cursor"?nf(t,n):e==="codex"?Vl(n,t):null}async function xs(e,t=ne,n=process.env,r={}){let o=await xR(e,t),s=OR(n),i=ks(o)?o:s&&ks(s)?s:null,a=TR(r.runnerPlatform,r.home??AR(),n);if(a)return{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:a.platform_login,identity_source:a.identity_source};let c=IR(n);return c?.platform_login?{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:c.platform_login,identity_source:c.identity_source}:i?{...i,platform_login:null,identity_source:ks(o)?"git_config":"git_env"}:c||(o.git_user_name||o.git_user_email?{...o,identity_source:"git_config"}:s||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}async function Os(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??ne,s=e.env??process.env,i=await xs(t,o,s,{runnerPlatform:e.runnerPlatform,home:e.home}),a=bR(i.git_user_name,i.git_user_email,i.identity_source,i.platform_login),l=(n?Mo(n):void 0)?.operator_identity_hash;if(!(r||l!==void 0&&l!==a||!l))return{commit:()=>{}};let p=n;return{operator:i,commit:()=>{p&&cc(p,a,Wn())}}}function Is(e){return e?!Mo(e)?.operator_identity_hash:!0}function sf(e){return!0}import{existsSync as Vb,readFileSync as Wb}from"node:fs";import{homedir as Pp}from"node:os";import{join as Kt,resolve as zb}from"node:path";import{basename as Ub,join as Bt}from"node:path";import{dirname as _f,resolve as Br}from"node:path";import{existsSync as PR}from"node:fs";import{homedir as uf}from"node:os";import{relative as lf,resolve as ve,sep as ft}from"node:path";var wR=["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"],NR=["prompt","tool_input","tool_response","last_assistant_message","command"],vR=new Set;function MR(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return vR}}function vs(e){let t=M("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?Zt.has(t.toLowerCase()):e?.collect_prompt===!0}function Fr(e,t){let n=ff(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=M("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?Zt.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}function ff(e){return M("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||Ho(process.argv,e.debug===!0)||M("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}function LR(e){let t={};for(let n of wR){let r=$e(e,n);r!==void 0&&(t[n]=r)}return t}function $r(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=ve(e),r=ve(t),o=lf(r,n);return!o||o==="."?".":o.startsWith(`..${ft}`)||o===".."||ve(r,o)!==n?null:o.split(ft).join("/")}function df(e,t){let n=lf(ve(t),ve(e)).split(ft).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}function pf(e){return typeof e!="string"||e.length===0?null:ve(e).split(ft).join("/")}function HR(){let e=M("CURSOR_PROJECT_DIR");if(!e)return null;let t=ve(e);return PR(t)?t.split(ft).join("/"):null}function Ps(e,t){return $r(e,t)!==null}function UR(e,t){let n=ve(t??uf(),".cursor").split(ft).join("/");return Ps(e,n)}function DR(e,t,n){return t!==null&&Ps(e,t)?!0:t!==null&&UR(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&Ps(e,n.gitRoot)?!0:t===null}function mf(e,t){let n=pf(e.cwd);if(n!==null)return n;let r=ve(process.cwd()).split(ft).join("/"),o=HR();return DR(r,o,t)?r:o??r}function Ms(e,t={}){return mf(e,t)}function Ls(e,t=uf()){let n=ve(t).split(ft).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function af(e,t,n){let r=pf(n.launchCwd)??mf(t,n);e.cwd=Ls(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?$r(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}var gf="\u2026[truncated]\u2026",ws=Buffer.byteLength(gf,"utf8"),FR=8;function Sn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function cf(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}function $R(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(n.length-t).toString("utf8")}function jR(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=ws)return cf(e,t);let r=t-ws,o=Math.ceil(r/2),s=Math.floor(r/2);return`${cf(e,o)}${gf}${$R(e,s)}`}function Ns(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)=>{Ns(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||Ns(o,[...t,r],n)}function BR(e,t,n){let r=e;for(let s=0;s<t.length-1;s++){let i=t[s];if(i===void 0)return;r=(Array.isArray(r),r[i])}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}}var KR=256;function GR(e,t,n){let r=n,o=Math.max(n,e[0]?.bytes??n);for(;r<o;){let s=Math.ceil((r+o)/2),i=0;for(let a of e)a.bytes>s&&(i+=a.bytes-s);i>=t?r=s:o=s-1}return r}function VR(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let s=Sn(e);if(s<=t)return;let i=[];Ns(e,[],i),i.sort((u,d)=>d.bytes-u.bytes);let a=i.filter(u=>u.bytes>n);if(a.length===0)return;let c=GR(a,s-t,n),l=Math.max(n,Math.min(c,r-1));if(l>=r)return;r=l;for(let u of a)u.bytes>r&&BR(e,u.path,jR(u.value,r))}}function WR(e,t){let n=Math.max(0,t-KR),r=Object.keys(e).filter(s=>!s.startsWith("_")).map(s=>({key:s,bytes:Sn(e[s])})).sort((s,i)=>i.bytes-s.bytes),o=[];for(let{key:s}of r){if(Sn(e)<=n)break;delete e[s],o.push(s)}o.length>0&&(e._dropped_keys=o.slice(0,10))}function Ts(e,t){let n=Sn(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,VR(r,t,ws+FR),Sn(r)>t&&WR(r,t),r}function zR(e,t,n){if(!(n.promptCapture??vs()))return;let r=MR(n.runnerEvent);for(let o of NR){if(r.has(o))continue;let s=t[o];s!==void 0&&(e[o]=s)}}function jr(e,t,n={}){let r=ff(t);if(r==="full"){let s={...e};return delete s.cwd,delete s.transcript_path,af(s,e,n),Ts(s,Oo)}let o=LR(e);return af(o,e,n),r==="content"?(zR(o,e,n),Ts(o,Oo)):Ts(o,Ma)}function JR(e){return typeof e=="string"&&e.length>0}function Hs(e){let t=Br(e.home),n=Br(e.launchCwd),r=e.gitRoot?Br(e.gitRoot):null,o=new Set,s=[],i=null;e.inGitRepo&&JR(e.remote)&&r!==null&&r!==t&&(i=r,o.add(r)),n!==t&&!o.has(n)&&(s.push({scope:"cwd",dir:n}),o.add(n)),i!==null&&s.push({scope:"repo",dir:i});let a=null,c=r!==null&&$r(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&c){let l=_f(r);for(;;){let u=Br(l);if(u===t)break;let d=_f(u);if(d===u)break;if(e.hasProjectSpec(u)){s.push({scope:"parent",dir:u}),a=df(u,n);break}l=d}}return{anchors:s,parentRel:a}}import{existsSync as hf,readdirSync as YR,realpathSync as XR}from"node:fs";import{basename as qR,dirname as ZR,relative as QR,resolve as eC,sep as tC}from"node:path";var Us=400,Kr=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??et}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=eC(t).split(tC).join("/");return Ls(r,this.home)}let n=QR(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${Z(ZR(t))}/${qR(t)}`:n}claimFile(t){try{let n=XR(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(!hf(t))return[];try{return YR(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(hf(t))return q(t,n)}push(t){return this.components.length>=this.maxEntries?(this.truncated=!0,!1):this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0?!1:(this.pluginExpandRemaining!==void 0&&(this.pluginExpandRemaining-=1),this.components.push(t),!0)}withPluginExpandCap(t,n){let r=this.pluginExpandRemaining;this.pluginExpandRemaining=t;try{let o=n(),s=t-(this.pluginExpandRemaining??0);return{result:o,expanded:s}}finally{this.pluginExpandRemaining=r}}};import{existsSync as ti,readFileSync as bA,statSync as kA}from"node:fs";import{basename as Nd,join as Rt,relative as ni}from"node:path";var Id=Qe(Od());var CA=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],Td=CA.map(e=>Id.default.matcher(e,{dot:!0}));function AA(e){return e===""?!1:Td.some(t=>t(`${e}/`))}function Pd(e,t){if(t==="")return!1;if(e==="")return AA(t);let n=e.replace(/\/+$/,"");return Td.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}var ri=100*1024,xA=4;function OA(e){return e.length<=ri?e:`${e.slice(0,ri-1)}\u2026`}function IA(e){try{let t=bA(e),n=t.toString("utf8");return{hash:Z(t),length:t.length,text:OA(n)}}catch{return null}}var wd={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function TA(e){return e in wd?wd[e]:"UNSPECIFIED"}function $t(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=IA(t.absolutePath);if(!n)return!1;let r=t.name??Nd(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},s=TA(t.kind);return s&&(o.trigger=s),t.attributes&&(o.attributes=t.attributes),e.push(o)}function PA(e,t,n){let r=ni(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?Nd(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}function Ct(e,t){let{dir:n,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c}=t;oi(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c})}function oi(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u}=t;if(!(o>xA))for(let d of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(d.isDirectory()&&Pd(n.replace(/\\/g,"/"),ni(n,Rt(r,d.name)).replace(/\\/g,"/"))||d.isDirectory()&&u?.includes(Rt(r,d.name)))continue;if(c){if(!d.isDirectory())continue;let g=Rt(r,d.name,c);if(ti(g)){let S=ni(n,Rt(r,d.name)).replace(/\\/g,"/");$t(e,{absolutePath:g,kind:s,origin:i,enabled:a,name:S||d.name});continue}oi(e,{walkRoot:n,currentDir:Rt(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(d.isDirectory()){oi(e,{walkRoot:n,currentDir:Rt(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(!d.isFile()||!l)continue;let f=d.name.toLowerCase();if(!l.some(g=>f.endsWith(g)))continue;let p=Rt(r,d.name);$t(e,{absolutePath:p,kind:s,origin:i,enabled:a,name:PA(n,p,!0)})}}function vd(e){for(let t of e)if(ti(t))try{if(kA(t).size>0)return t}catch{continue}return e.find(t=>ti(t))}import{existsSync as ib,readFileSync as ab}from"node:fs";var Xr=Qe(lt(),1);var wA="<omitted>",NA=["package_name","package_spec","package_version","package_version_source"],Md=100,Ld=120,qr=[{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"}],Hd=new Set(qr.map(e=>e.attr)),vA=["enabled","disabled"],MA=["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",...vA,...MA,...qr.map(e=>e.raw)]),HA=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,...Hd,...[...Hd].map(e=>`${e}_truncated`)]);function Ud(e,t){for(let n of t)LA.has(n)||HA.has(n)||(e[n]=wA)}var UA=/^(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 Zr(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Dd(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}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=Zr(e);return t?Object.keys(t).filter(n=>n.length>0):[]}function At(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}function jA(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,Xr.launchContainsCredentials)({kind:"url",url:e})||(0,Xr.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=kn([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,Xr.launchContainsCredentials)({kind:"url",url:r}):!0)}function Fd(e,t,n){jA(t,n)&&(e.launch_had_credentials=!0)}function BA(e){return FA.test(e)||$A.test(e)?"<redacted>":e.includes("://")?At(e):e}function $d(e){if(/^https?:\/\//i.test(e))return At(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${$d(e.slice(t+1))}`:BA(e)}function KA(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return UA.test(t)||DA.test(t)}function kn(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(KA(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push($d(r))}return t}function GA(e){let t=Dd(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Ld?r.slice(0,Ld):r))].sort();if(n.length!==0)return n.length>Md?{names:n.slice(0,Md),truncated:!0}:{names:n,truncated:!1}}function VA(e){let t=Zr(e);if(!t)return{headers:[],envVars:[]};let n=[],r=[];for(let[o,s]of Object.entries(t))o.length>0&&n.push(o),typeof s=="string"&&s.length>0&&r.push(s);return{headers:n,envVars:r}}function jd(e,t){let n=new Set;for(let{raw:r,attr:o}of qr){if(n.has(o)||!(r in t))continue;let s=t[r];if(o==="auto_approve"&&typeof s=="boolean"){e.auto_approve=s,n.add(o);continue}let i=GA(s);i&&(e[o]=i.names,i.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}function Bd(e,t){let n=Zr(e),r={transport:t};if(!n)return r;Ud(r,Object.keys(n));let o=typeof n.command=="string"?n.command:void 0,s=typeof n.url=="string"?n.url:void 0,i=typeof n.serverUrl=="string"?n.serverUrl:void 0,a=o??s??i,c=Dd(n.args);a&&(r.command_or_url=At(a));let l=kn(c);l.length>0&&(r.args=l),Fd(r,a,c);let u=VA(n.env_http_headers),d=[...new Set([...si(n.env),...si(n.envVars),...si(n.env_vars),...u.envVars,...typeof n.bearer_token_env_var=="string"&&n.bearer_token_env_var.length>0?[n.bearer_token_env_var]:[]])].sort();d.length>0&&(r.env_var_names=d),u.headers.length>0&&(r.env_http_header_names=[...new Set(u.headers)].sort());for(let S of["headers","http_headers","env_http_headers"])if(n[S]!==void 0&&n[S]!==null){r.headers_present=!0;break}let f=typeof n.auth=="string"?n.auth:void 0;f&&(r.auth=f);let p=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;p&&(r.bearer_token_env_var=p);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),jd(r,n),r}function Kd(e){let t=Zr(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}function ci(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return Z(JSON.stringify({name:e,attributes:r,enabled:n}))}function jt(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function bn(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*\\[([^\\]]*)\\]`,"m").exec(e);return n?.[1]?[...n[1].matchAll(/"([^"]*)"|'([^']*)'/g)].map(r=>r[1]??r[2]??"").filter(r=>r.length>0):[]}function ai(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}function ii(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=jt(n[1]);return r.length>0?r:void 0}function WA(e,t){let n=[],r=i=>{for(let a of i.split(/[,\n]/)){let c=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(a);c?.[1]&&n.push([c[1],jt(c[2]??"")])}},o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let s=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
44
+ ${e}`);return s?.[1]&&r(s[1]),n}function Gd(e){return ai(e,"enabled")===!1?!1:ai(e,"disabled")!==!0}function zA(e,t){let n={};for(let{raw:r,attr:o}of qr){if(o==="auto_approve"){let i=ai(t,r);if(i!==void 0){n[r]=i;continue}}let s=bn(t,r);s.length>0&&(n[r]=s)}jd(e,n)}var JA=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,YA=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function XA(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
45
+ `)){let s=JA.exec(o);s?.[1]&&t.add(s[1])}for(let o of e.matchAll(YA))o[1]&&t.add(o[1]);return[...t]}function Vd(e,t){let n={transport:t};Ud(n,XA(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),s=r?jt(r[1]??""):void 0,i=o?jt(o[1]??""):void 0,a=s!==void 0&&s.length>0?s:i,c=bn(e,"args");a&&(n.command_or_url=At(a));let l=kn(c);l.length>0&&(n.args=l),Fd(n,a,c);let u=new Set;for(let b of e.split(`
46
+ `)){let I=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);I?.[1]&&u.add(I[1])}let d=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(d?.[1])for(let b of d[1].split(",")){let I=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);I?.[1]&&u.add(I[1])}let f=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
46
47
  ${e}`);if(f?.[1])for(let b of f[1].split(`
47
- `)){let O=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);O?.[1]&&u.add(O[1])}for(let b of Cn(e,"env_vars"))u.add(b);let p=OA(e,"env_http_headers");for(let[,b]of p)b.length>0&&u.add(b);let g=oi(e,"bearer_token_env_var");g&&(u.add(g),n.bearer_token_env_var=g),u.size>0&&(n.env_var_names=[...u].sort()),p.length>0&&(n.env_http_header_names=[...new Set(p.map(([b])=>b))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let S=oi(e,"auth");S&&(n.auth=S);let A=oi(e,"default_tools_approval_mode");return A&&(n.default_tools_approval_mode=A),IA(n,e),n}var Le=qe(at(),1);import{createHash as LA}from"node:crypto";import{join as bn}from"node:path";var NA=300,vA=256;function Dd(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}function Xr(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}function Fd(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function MA(e){return Fd(e,NA)}function $d(e,t){let n=Dd(e.trim(),t),r=Xr(n);if(r.length===0)return"";let[o,...s]=r,i=yt(o),a=An(s);return MA([i,...a].join(" "))}function jd(e,t){if(typeof e!="string")return null;let n=Dd(e.trim(),t),r=Xr(n)[0];if(!r)return null;let o=yt(r);return o.length===0?null:Fd(o,vA)}function HA(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,Le.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}function UA(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
48
- `);return LA("sha512").update(t).digest("hex").slice(0,16)}function DA(e){let t=process.platform==="win32"?bn(M("LOCALAPPDATA")??e,"npm-cache"):bn(e,".npm"),n=M("npm_config_cache")??M("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}function Bd(e){return typeof e=="string"&&e.length>0&&e.length<=Le.PACKAGE_FIELD_MAX?e:null}function FA(e,t,n){let r=UA(e);for(let o of DA(n)){let s=bn(o,"_npx",r),i=Z(bn(s,"node_modules",...t.split("/"),"package.json"),{}),a=Bd(i.version);if(a!==null)return a;let c=Z(bn(s,"package-lock.json"),{}),l=Bd(c.packages?.[`node_modules/${t}`]?.version);if(l!==null)return l}return null}function $A(e){return e.length<=Le.PACKAGE_FIELD_MAX?e:`${e.slice(0,Le.PACKAGE_FIELD_MAX-1)}\u2026`}function ai(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,Le.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let s=(0,Le.packageNameFromSpec)(o);return s===null?null:{package_name:s,package_spec:$A(o),...HA(o,FA(r,s,n))}}function Kd(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=Xr(e.trim());return n===void 0?null:ai(n,r,t)}function qr(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 ai(typeof n.command=="string"?n.command:null,r,t)}function Gd(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:ai(Ft(n[1]??""),Cn(e,"args"),t)}function KA(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"}function Vd(e,t,n){if(!e.claimFile(t))return;let o=e.readJson(t,{})?.mcpServers;if(!o||typeof o!="object")return;let s=e.componentPath(t);for(let[i,a]of Object.entries(o)){if(e.truncated)return;let c=KA(a),l=Md(a,c);Object.assign(l,qr(a,e.home)??{});let u=Ld(a);e.push({kind:"MCP_SERVER",name:i,path:s,content_hash:ii(i,l,u),origin:n,enabled:u,attributes:l})}}function Wd(e,t,n){if(!jA(t)||!e.claimFile(t))return;let r;try{r=BA(t,"utf8")}catch{return}let o=e.componentPath(t),s=/^\[mcp_servers(?:\.(\w+)|\."([^"]+)"|\.'([^']+)')\]\s*$/gm,i;for(;(i=s.exec(r))!==null;){if(e.truncated)return;let a=i[1]??i[2]??i[3];if(!a)continue;let c=r.slice(i.index+i[0].length),l=c.search(/^\[mcp_servers(?:\.(?:\w+|"[^"]+"|'[^']+'))\]\s*$/m),u=l===-1?c:c.slice(0,l),d="unknown";/^\s*url\s*=/m.test(u)?d="http":/^\s*command\s*=/m.test(u)&&(d="stdio");let f=Ud(u,d);Object.assign(f,Gd(u,e.home)??{});let p=Hd(u);e.push({kind:"MCP_SERVER",name:a,path:o,content_hash:ii(a,f,p),origin:n,enabled:p,attributes:f})}}import{existsSync as WA,readdirSync as zA}from"node:fs";import{join as fe}from"node:path";function GA(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"}function VA(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}]}function ci(e,t,n,r){let o=e.componentPath(t);for(let[s,i]of Object.entries(n))if(!(!Array.isArray(i)||e.truncated))for(let a of i){if(!a||typeof a!="object"||e.truncated)continue;let c=a;for(let l of VA(c)){if(e.truncated)return;let u=l.command??l.bash??l.prompt??l.powershell??c.powershell??"",d=GA({type:l.type??c.type,command:l.command??c.command,bash:l.bash??c.bash,powershell:l.powershell??c.powershell,prompt:l.prompt??c.prompt}),f=typeof c.matcher=="string"?c.matcher:"",p=q(u),g=f?`${s}:${f}:${d}:${p}`:`${s}:${d}:${p}`,S=`${s}|${f}|${d}|${u}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:q(S),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:s,...f?{matcher:f}:{},action_kind:d,action_hash:p,...d!=="prompt"&&u.trim()?{command:$d(u,e.home)}:{}}})}}}function ui(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||ci(e,t,r.hooks,n)}var zd=50;function kn(e,t,n,r){if(!WA(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:s}=e.withPluginExpandCap(zd,()=>{Et(e,{dir:fe(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),Et(e,{dir:fe(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),Et(e,{dir:fe(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});ui(e,fe(t,"hooks","hooks.json"),n),ui(e,fe(t,"hooks.json"),n);let i=e.components.length-o,a=s>=zd;return{componentCount:i,expandTruncated:a}}function xn(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}:{}}})}function li(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}function JA(e){let t=li(e.readJson(fe(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=Qt(process.platform,e.home),o=e.readJson(n,{}),s={};if(o&&Object.keys(o).length>0)s=li(o);else for(let i of r)Object.assign(s,li(e.readJson(i,{})));return{...t,...s}}function Jd(e){let t=fe(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=JA(e),s=e.componentPath(t);for(let[i,a]of Object.entries(r)){if(e.truncated)return;let c=Array.isArray(a)?a:[a],l=c[0]??{},u=o[i]===!0,d=i.includes("@")?i.split("@").slice(1).join("@"):"",f=typeof l.version=="string"?l.version:"",p=typeof l.scope=="string"?l.scope:"user",g=`plugin:${i}`,S=0,A=!1;for(let b of c)if(typeof b.installPath=="string"&&b.installPath.length>0){let O=kn(e,b.installPath,g,u);S+=O.componentCount,A=A||O.expandTruncated}xn(e,{pluginKey:i,rowPath:s,enabled:u,scope:p,version:f||void 0,marketplace:d||void 0,componentCount:S,expandTruncated:A,contentHash:q(`${i}|${f}|${p}|${u}|${S}`)})}}function YA(e){let t=e,n="";try{let r=zA(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=fe(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),s=o[o.length-1];s&&(t=fe(e,s),n=s)}}catch{}return{installPath:t,version:n}}var XA=/^\d+$/;function qA(e){let t=e.filter(n=>!XA.test(n.pluginId));return t.length>0?t:e}function Yd(e){let t=[{base:fe(e.home,".cursor/plugins/local"),scope:"local"},{base:fe(e.home,".cursor/plugins/cache"),scope:"cache"}];for(let{base:n,scope:r}of t)if(!e.truncated)for(let o of e.readEntries(n)){if(!o.isDirectory()||e.truncated)continue;if(r==="local"){let a=o.name,c=fe(n,o.name),l=`plugin:${a}`,{componentCount:u,expandTruncated:d}=kn(e,c,l,!0);xn(e,{pluginKey:a,rowPath:e.componentPath(c),enabled:!0,scope:"local",componentCount:u,expandTruncated:d,contentHash:q(`${a}|local|${u}`)});continue}let s=o.name,i=[];for(let a of e.readEntries(fe(n,s))){if(!a.isDirectory())continue;let c=fe(n,s,a.name),{installPath:l,version:u}=YA(c);i.push({pluginId:a.name,installPath:l,version:u})}for(let a of qA(i)){if(e.truncated)break;let c=`${a.pluginId}@${s}`,l=`plugin:${c}`,{componentCount:u,expandTruncated:d}=kn(e,a.installPath,l,!0);xn(e,{pluginKey:c,rowPath:e.componentPath(a.installPath),enabled:!0,scope:"cache",version:a.version||void 0,marketplace:s,componentCount:u,expandTruncated:d,contentHash:q(`${c}|${a.version}|${u}`)})}}}import{existsSync as eb}from"node:fs";var ZA=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,fi="<path>",QA=new RegExp(`${fi}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function Zr(e){let t=e.replace(ZA,fi).replace(QA,fi);return t.length>200?`${t.slice(0,200)}...`:t}var Xd=200,qd=200,di=16*1024,Zd=6,tb=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),nb=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),rb=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),ob=new Set(["permissions"]),sb={claude:tb,cursor_sandbox:nb,cursor_permissions:rb,cursor_cli:ob},ib=new Set(["allow","deny","ask"]);function ut(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Qr(e){return e.replace(/\\/g,"/")}function pi(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>pi(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${pi(t[r])}`).join(",")}}`}function ab(e){return q(`${pi(e)}|settings1`)}function rp(e){let t=Qr(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"}function op(e,t){if(e!=="claude")return{};let n=Qr(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"}}function sp(e){let t=Qr(e).replace(/\/+$/,"");return t.length<=1?"":t}function ip(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}function cb(e,t){let n=Qr(e);if(n==="~"||n.startsWith("~/"))return n;let r=sp(t);if(!r)return n;let o=n.slice(0,r.length);if(!(ip(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let i=n.slice(r.length);return i===""?"~":i.startsWith("/")?`~${i}`:n}var Qd=new Map;function ub(e){let t=Qd.get(e);if(t!==void 0)return t;let n=sp(e),r=null;if(n){let o=n.split("/").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,ip(e)?"gi":"g")}return Qd.set(e,r),r}function lb(e,t){let n=ub(t);return n?e.replace(n,"~"):e}function ep(e,t){return e.length<=qd?e:(t.truncated=!0,e.slice(0,qd))}function ap(e,t){return e.length<=Xd?e:(t.truncated=!0,e.slice(0,Xd))}function re(e,t,n,r){if(typeof e=="string"){if(t==="path")return ep(cb(e,n),r);let o=t==="rule"?Zr(e):e;return ep(lb(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=ap(e,r),s=[];for(let i of o){let a=re(i,t,n,r);a!==void 0&&s.push(a)}return s}if(ut(e)){let o={};for(let[s,i]of Object.entries(e)){let a=re(i,t,n,r);a!==void 0&&(o[s]=a)}return o}}function tp(e,t,n){if(!ut(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i="plain";ib.has(o)?i="rule":o==="additionalDirectories"&&(i="path");let a=re(s,i,t,n);a!==void 0&&(r[o]=a)}return r}function fb(e,t,n){if(!ut(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){if(o==="files"&&Array.isArray(s)){let a=ap(s,n);r[o]=a.map(c=>{if(!ut(c))return re(c,"plain",t,n);let l={};for(let[u,d]of Object.entries(c)){let p=re(d,u==="path"?"path":"plain",t,n);p!==void 0&&(l[u]=p)}return l});continue}let i=re(s,"plain",t,n);i!==void 0&&(r[o]=i)}return r}function db(e,t,n){if(!ut(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let a=re(s,o==="allowUnixSockets"?"path":"plain",t,n);a!==void 0&&(r[o]=a)}return r}function pb(e,t,n){if(!ut(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i;o==="excludedCommands"?i=re(s,"rule",t,n):o==="filesystem"?i=re(s,"path",t,n):o==="network"?i=db(s,t,n):o==="credentials"?i=fb(s,t,n):i=re(s,"plain",t,n),i!==void 0&&(r[o]=i)}return r}function mb(e,t,n,r,o){return n==="claude"?e==="permissions"?tp(t,r,o):e==="sandbox"?pb(t,r,o):re(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?re(t,"path",r,o):re(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?re(t,"rule",r,o):re(t,"plain",r,o):e==="permissions"?tp(t,r,o):re(t,"plain",r,o)}function On(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function mi(e,t){return e?`${e}.${t}`:t}function gi(e,t,n,r){if(Array.isArray(e)){for(let o=e.length-1;o>=0;o-=1){let s=e[o];s!==null&&typeof s=="object"&&(t+1>=Zd?(e.splice(o,1),r.add(n)):gi(s,t+1,n,r))}return}if(!(e===null||typeof e!="object"))for(let[o,s]of Object.entries(e))s!==null&&typeof s=="object"&&(t+1>=Zd?(delete e[o],r.add(mi(n,o))):gi(s,t+1,mi(n,o),r))}function cp(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:On(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))cp(o,mi(t,r),n)}function gb(e,t,n){let r=On(e);if(r<=di)return;t.truncated=!0;let o=[];for(cp(e,"",o);r>di;){let s;for(let c of o)c.items.length>0&&(!s||c.bytes>s.bytes)&&(s=c);if(!s)break;let i=s.items.pop(),a=On(i)+(s.items.length>0?1:0);s.bytes-=a,r-=a,n.add(s.path)}for(;On(e)>di;){let s,i=-1;for(let[a,c]of Object.entries(e)){let l=On(c);l>i&&(s=a,i=l)}if(s===void 0)break;delete e[s],n.add(s)}}function _b(e,t,n){let r=sb[t],o={truncated:!1},s={},i=[];for(let c of Object.keys(e)){if(!r.has(c)){i.push(c);continue}let l=mb(c,e[c],t,n,o);l!==void 0&&(s[c]=l)}i.sort();let a=new Set;return gi(s,1,"",a),a.size>0&&(o.truncated=!0),gb(s,o,a),{settings:s,keys_omitted:i,truncated:o.truncated,trimmed_paths:[...a].sort()}}function np(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:ab(t.attributes),attributes:t.attributes};e.push(n)}function _i(e,t,n,r){if(!e.claimFile(t)||!eb(t))return;let o=ma(t);if(!o.ok||!ut(o.value)){if(r.profile){let l=!o.ok&&o.reason==="read"?"read_error":"parse_error",u={profile:r.profile,[l]:!0};r.managedSource&&(u.managed_source=r.managedSource),np(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}return}let s=o.value,i=s.hooks;if(ut(i)&&ci(e,t,i,n),!r.profile)return;let a=_b(s,r.profile,e.home),c={profile:r.profile,settings:a.settings,keys_omitted:a.keys_omitted};a.truncated&&(c.truncated=!0),a.trimmed_paths.length>0&&(c.trimmed_paths=a.trimmed_paths),r.managedSource&&(c.managed_source=r.managedSource),np(e,{kind:r.kind,absPath:t,origin:n,attributes:c})}import{existsSync as hb}from"node:fs";import{join as He}from"node:path";var up=".claude/skills/synced",lp=".claude/plugins/synced";function fp(e){return[He(e,up),He(e,lp)]}function eo(e){return typeof e=="string"&&e.length>0?e:void 0}function dp(e){let t=He(e.home,up);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=He(t,n.name),o=e.readJson(He(r,"manifest.json"),{}),s=new Map((o?.skills??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}let a=He(r,i.name,"SKILL.md");if(!i.isDirectory()||!hb(a))continue;let c=s.get(i.name),l=eo(c?.source),u=eo(c?.creatorType);Dt(e,{absolutePath:a,kind:"SKILL",origin:"user",enabled:!0,name:i.name,attributes:{scope:"synced",...l?{source:l}:{},...u?{creator_type:u}:{}}})}}}function pp(e){let t=He(e.home,lp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=He(t,n.name),o=e.readJson(He(r,"manifest.json"),{}),s=new Map((o?.plugins??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.truncated)return;if(!i.isDirectory()||i.name.startsWith("."))continue;let a=s.get(i.name),c=eo(a?.marketplaceName),l=eo(a?.version),u=c?`${i.name}@${c}`:i.name,d=He(r,i.name),{componentCount:f,expandTruncated:p}=kn(e,d,`plugin:${u}`,!0);xn(e,{pluginKey:u,rowPath:e.componentPath(d),enabled:!0,scope:"synced",version:l,marketplace:c,componentCount:f,expandTruncated:p,contentHash:q(`${u}|${l??""}|synced|${f}`)})}}}function Eb(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:s}=t;for(let i of n.skillRoots)Et(e,{dir:$t(r,i),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:fp(e.home)});for(let i of n.dirs)Et(e,{dir:$t(r,i.dir),kind:i.kind,origin:o,enabled:!0,extensions:i.extensions});for(let i of n.memory){let a=kd(i.map(c=>$t(r,c)));a&&Dt(e,{absolutePath:a,kind:"MEMORY",origin:o,enabled:!0,name:Sb(a)})}for(let i of Kc(n))_i(e,$t(r,i),o,{kind:"SETTINGS",profile:rp(i)});for(let i of n.mcpJson??[])Vd(e,$t(r,i),o);for(let i of n.mcpToml??[])Wd(e,$t(r,i),o);if(s){if(n.managed){for(let i of rr(n.managed,process.platform,e.home))if(i.toLowerCase().endsWith(".json")){let a=op(n.managed,i);_i(e,i,o,{kind:"MANAGED_SETTINGS",...a})}}n.plugins==="claude"?(Jd(e),pp(e),dp(e)):n.plugins==="cursor"&&Yd(e)}}function mp(e,t){try{let n=new $r(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)Eb(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{return}}function hi(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let c=mp(t,{layouts:Object.values(wt),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:Ze,scopeRef:""});c&&(r.user=c)}let s=n.inGitRepo===!0,i=null,a=n.launchCwd;if(a!==void 0){let c=Object.values(rt),l=Ms({launchCwd:a,gitRoot:n.gitRoot,inGitRepo:s,remote:n.remote,home:t,hasProjectSpec:u=>Vc(c,u)});i=l.parentRel;for(let u of l.anchors){let d=Cs(u.dir);if(o!==void 0&&!o(u.scope,d))continue;let f=mp(t,{layouts:c,levelDir:u.dir,origin:u.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:Ls,scopeRef:d});f&&(r[u.scope]=f)}r.parent||(i=null)}return{scopes:r,parentRel:i,cwdInGitRepo:s}}function Si(e,t,n={}){let r=n.truncated===!0,o=gn(e),s=new Set(e.map(u=>ye(u.path,u.name)));if(n.forceFull===!0||t===void 0)return{hash:o,count:e.length,truncated:r,full:!0,upserts:e,removed:[],unchanged:!1};let a=[],c=t;for(let u of e){let d=ye(u.path,u.name);c[d]!==Lr(u)&&a.push(u)}let l=[];if(!r){for(let u of Object.keys(c))if(!s.has(u)){let d=Yl(u);d&&l.push(d)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:a,removed:l,unchanged:a.length===0&&l.length===0}}var _p=2*1024*1024,yb=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function Ei(e,t,n){let r=new Set(t.map(s=>ye(s.path,s.name))),o=[];for(let s of e)s.text!==void 0&&(n.has(s.content_hash)||r.has(ye(s.path,s.name))||o.push(s));return o}function yi(e,t,n){let r=new Set(e);for(let s of t)r.add(s);let o=new Set(n.map(s=>s.content_hash));return[...r].filter(s=>o.has(s))}function gp(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function hp(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}function Ri(e,t=_p){let n=[],r=[];for(let u of e)yb.has(u.kind)?n.push(u):r.push(u);r.sort((u,d)=>(u.text?.length??0)-(d.text?.length??0));let o=[...n,...r],s=[],i=2,a=0,c=0,l=[];for(let u of o){let d=s.length>0?1:0,f=gp(u)+d;if(i+f<=t){s.push(u),i+=f,u.text!==void 0&&l.push(u.content_hash);continue}if(u.text!==void 0){let p=hp(u),g=gp(p)+d;if(i+g<=t){s.push(p),i+=g,a+=1;continue}}c+=1}return{components:s,textDeferredCount:a,droppedCount:c,textHashesSent:l}}function Ci(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:hp(n))}var Rb=["user","cwd","repo","parent"];function Ai(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,s=[];for(let I of Rb){let T=t.scopes[I];if(!T)continue;let K=n(I,T.scopeRef),D=K.components,x=Si(T.components,D,{forceFull:D===void 0,truncated:T.truncated}),N=new Set(K.textHashes),H=Ei(T.components,x.upserts,N),m=Ci([...x.upserts,...H],N);s.push({scope:I,walk:T,delta:x,outgoing:m,outgoingKeys:new Set(m.map(k=>ye(k.path,k.name))),deliveredTextHashes:N,cachedComponents:D})}let i=s.flatMap(I=>I.outgoing),a=Ri(i,o),c=new Set(a.components.map(I=>ye(I.path,I.name))),l=[],u=[],d=[],f=[],p=[],g=[],S=[];for(let I of s){let{scope:T,walk:K,delta:D}=I;g.push(...K.components),l.push(T);let x=a.components.filter(k=>I.outgoingKeys.has(ye(k.path,k.name))),N=[...I.outgoingKeys].some(k=>!c.has(k)),H=D.truncated||N;H?d.push(T):D.full&&u.push(T),f.push(...x),!D.full&&!H&&p.push(...D.removed);let m=D.full?{}:{...I.cachedComponents??{}};if(!H)for(let k of D.removed)delete m[ye(k.path,k.name)];for(let k of x)m[ye(k.path,k.name)]=Lr(k);S.push({scope:T,scopeRef:K.scopeRef,components:m,textHashes:yi(I.deliveredTextHashes,x.filter(k=>k.text!==void 0).map(k=>k.content_hash),K.components),collectedAtMs:r,included:x.length>0||D.removed.length>0&&!H||D.full})}let A={user_spec_hash:gn(g),user_spec_count:g.length,user_spec_truncated:d.length>0};l.length>0&&(A.user_spec_scopes=l,A.user_spec_full_scopes=u,A.user_spec_truncated_scopes=d,A.user_spec_cwd_in_git_repo=t.cwdInGitRepo),u.length>0&&u.length===l.length&&(A.user_spec_full=!0),f.length>0&&(A.user_spec=f),p.length>0&&(A.user_spec_removed=p),a.textDeferredCount>0&&(A.user_spec_text_deferred=a.textDeferredCount);let b=t.scopes.cwd;b&&(A.user_spec_cwd_scope_ref=b.scopeRef);let O=t.scopes.repo;O&&(A.user_spec_repo_scope_ref=O.scopeRef);let P=t.scopes.parent;return P&&(A.user_spec_parent_scope_ref=P.scopeRef,t.parentRel&&(A.user_spec_parent_rel=t.parentRel)),{fields:A,scopes:S}}var to={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function bi(e){return e==="cwd"||e==="repo"||e==="parent"}function In(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ki(e){return!In(e)||!In(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)}function Sp(e){return Cb(e)}function Ep(e){return Ab(e)}function yp(e){return bb(e)}function Cb(e){if(!In(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}function Ab(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Rp(e,t){if(!In(e))return;let n=e[t];return ki(n)?n:void 0}function bb(e){if(!In(e))return{};let t={};for(let[n,r]of Object.entries(e))ki(r)&&(t[n]=r);return t}function xi(e,t=20){let n=[];for(let[r,o]of Object.entries(e))ki(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))}var Tb=["allow","deny","ask"];function ro(e){let t=Z(e,{}),n=[];for(let r of Tb)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:Zr(o),mode:r});return{model:t.model??"",permissionKeys:n}}function Pb(e){let{serverManaged:t,fileBased:n}=Qt(process.platform,e),r=ro(t);if(r.model||r.permissionKeys.length>0)return r;let o="",s=[];for(let i of n){let a=ro(i);a.model&&(o=a.model),s.push(...a.permissionKeys)}return{model:o,permissionKeys:s}}function wb(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}var Nb=10,vb="self-config-cache.json",Ap=5;function Bt(){return M("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}function Mb(){return M("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}var Lb={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function Hb(e,t=ne){let n=Lb[e];if(!n||n.length===0)return null;let r=async o=>{let s=n[o];if(s===void 0)return null;let a=((await t(s,["--version"],2e3)).split(`
49
- `)[0]??"").trim();return a||r(o+1)};return r(0)}function Ub(e=Cp()){return jt(e,".ev-ai","agent-hook",vb)}function Db(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
50
- `);return q(n)}function no(e,t,n=!1){let r=Db(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}}function Oi(e,t,n=[]){let r=0,o=!1,s=new Set;for(let i of[...t.map(a=>jt(e,a)),...n]){let a=Ib(i);if(s.has(a))continue;s.add(a);let c=So(i);c.present&&(o=!0,r+=c.size)}return o?{present:!0,size:r}:{present:!1,size:0}}function Fb(e){return xb(e)?he(Ob(e,"utf8"),{}):{}}function $b(e,t){try{ce(e,`${JSON.stringify(t)}
51
- `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: self-config cache write failed open: ${r}`)}}function jb(e,t,n){if(t==="user")return{components:Sp(e.user_spec_components),textHashes:Ep(e.user_spec_text_hashes)};if(!bi(t))return{components:void 0,textHashes:[]};let r=Rp(e[to[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}function Bb(e,t,n,r){let o={...e,send_count:n};for(let s of Object.keys(t)){let i=t[s];i.entries!==void 0&&(o[s]=i.hash)}if(r){o.user_spec_layout_version=Ap,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 s of r.project){if(!bi(s.scope))continue;let i=to[s.scope],a=yp(o[i]),c=a[s.scopeRef];a[s.scopeRef]={components:s.included?s.components:c?.components??{},text_hashes:s.textHashes,collected_at_ms:s.collectedAtMs},o[i]=xi(a)}}return o}async function bp(e,t=process.cwd(),n=Cp(),r={}){let o=e==="claude",s=r.gitRoot??t,i=await Hb(e),a="",c=[];if(o){let H=Pb(n),m=ro(jt(n,".claude/settings.json")),k=ro(jt(t,".claude/settings.local.json"));a=H.model||k.model||m.model,c=wb([...H.permissionKeys,...m.permissionKeys,...k.permissionKeys]).slice(0,200)}let l={present:!1,size:0},u=H=>{let m=[],k=!1;for(let U of H){let de=ga(jt(n,U));if(m=m.concat(de.entries),k=k||de.truncated,m.length>=Ze){m=m.slice(0,Ze),k=!0;break}}return{entries:m,truncated:k}},d=Ub(n),f=Fb(d),p=f[e]??{},g=(p.send_count??0)+1,S=g>0&&g%Nb===0,A=H=>S?void 0:p[H],b=u(st.skills),O=u(st.subagents),P=u(st.commands),I=u(st.rules),T={skills:no(b.entries,A("skills"),b.truncated),subagents:no(O.entries,A("subagents"),O.truncated),commands:no(P.entries,A("commands"),P.truncated),rules:no(I.entries,A("rules"),I.truncated)},K={runner_platform:e,config_scope:"user",cli_version:i,claude_version:o?i:null,model:o&&a||null,permission_keys:c,user_scope:{skills:T.skills,subagents:T.subagents,commands:T.commands,rules:T.rules,memory:Oi(n,st.memory),settings:Oi(n,st.settings,Wc(n)),mcp:Oi(n,st.mcp)},local_settings:o?So(jt(t,".claude/settings.local.json")):l},D=null,x=r.nowMs??Date.now();if(!Bt()){let H=p.user_spec_layout_version!==Ap,m=hi(e,n,{launchCwd:Mb()?void 0:r.launchCwd,gitRoot:s,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(m.scopes).length>0){let k=Ai({collected:m,cacheFor:(U,de)=>H?{components:void 0,textHashes:[]}:jb(p,U,de),nowMs:x});Object.assign(K,k.fields),D={hash:k.fields.user_spec_hash,home:k.scopes.find(U=>U.scope==="user")??null,project:k.scopes.filter(U=>U.scope!=="user")}}}let N=Bb(p,T,g,D);return{config:K,commit:()=>{f[e]=N,$b(d,f)}}}import{homedir as ck}from"node:os";import{join as Op}from"node:path";function Rt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}import{join as oo}from"node:path";function Kb(e){return oo(e,".ev-ai","agent-hook","js","signed-v1")}function Gb(e){return oo(Kb(e),"scopes")}function kp(e,t){return oo(Gb(e),t)}function xp(e){return oo(e,"attempts")}function Ii(e){return String(e).padStart(10,"0")}var Vb=/^(\d{10})$/,Wb=/^(\d{10})\.done$/,zb=/^[0-9a-f]{128}$/,Jb=64,wp=["check_ms","download_ms","install_ms","total_ms"],Yb=36e5;async function Np(e,t,n=!1){let r=xp(t),o=await zi(e,r),s=new Map,i=new Map,a=Ip(o,Vb),c=Ip(o,Wb),l=async f=>{let p=await Pp(e,Op(r,Xb(f)));return p&&s.set(f,{record:Zb(p.value),mtimeMs:p.mtimeMs}),p!==void 0},u=async f=>{let p=Qb((await Pp(e,Op(r,qb(f))))?.value);return p&&i.set(f,p),p!==void 0};if(!n)return await Promise.all([...a.map(l),...c.map(u)]),{claims:s,dones:i};await Promise.all([Tp(a,l),Tp(c,u)]);let d=Tn(s);return d<Tn(i)&&c.includes(d)&&await u(d),{claims:s,dones:i}}function Ip(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}async function Tp(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}function Tn(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}function vp(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}function Mp(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of wp){let r=e[n];r!==void 0&&(t[n]=r)}return t}function Xb(e){return Ii(e)}function qb(e){return`${Ii(e)}.done`}async function Pp(e,t){let n;try{n=await e.stat(t)}catch(o){if(bt(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>fo)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>fo?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}function Zb(e){if(!Rt(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}function Qb(e){if(!Rt(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=tk(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...ek(t)}}function ek(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 wp){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=Yb&&(t[n]=r)}return t}function tk(e){if(!Rt(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"&&zb.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&nk(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}function nk(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==Jb||t.toString("base64")!==e))return t.toString("hex")}function ik(e){return e==="bootstrap"?3e3:6e4}function ak(e,t){let n=Tn(e.claims);if(n===0)return;let r=Tn(e.dones),o=e.claims.get(n),s=e.dones.get(n);if(o&&!s){let a=vp(o),c=o.record==="empty"?void 0:o.record.owner,l=ik(c)+3e4;if(t-a>l)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:Lp(e.dones.get(r)?.selection)}}if(r===0)return;let i=e.dones.get(r);if(i)return{n:r,latest_claim:n,outcome:i.outcome,finished_at:i.finished_at,selection_version:Lp(i.selection),...Mp(i)}}async function Hp(e,t,n){try{let r=await Np(Ji(),kp(e,t),!0);return ak(r,n)}catch{return}}function Lp(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}function uk(e=process.env){if(Object.values(Na).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===Se?"npx":null}async function Up(e=ck()){let t=ds()?.launcherScope;if(!t)return{};let n=await Hp(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}function Kt(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:Qe,event:e,timestamp:Gn(),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:$e,hook_delivery:uk(),host_arch:process.arch,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},s=ds();return s&&(o.launcher_version=s.launcherVersion,o.hook_source=s.hookSource,o.hook_fallback_reason=s.fallbackReason??null,o.launcher_scope_match=ul(n.collectorUrl,s.launcherScope)),e==="session_start"&&(n.launcher_scope&&(o.launcher_scope=n.launcher_scope),n.launcher_attempt&&(o.launcher_attempt=n.launcher_attempt)),o}import{existsSync as Dp}from"node:fs";import{spawn as Fp}from"node:child_process";import{fileURLToPath as fk}from"node:url";import{gzipSync as lk}from"node:zlib";function Ti(e){return M("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<Pa?{body:e}:{body:lk(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}function so(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}function Pi(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}var Pn="__post",wn="__work";async function dk(e,t,n={}){if(Bt())return e;let r=await bs(n.gitRoot??process.cwd(),ne,process.env,{runnerPlatform:t,home:n.home}),o=Rt(e.self_config)?e.self_config:{};return{...e,self_config:{...o,runner_platform:typeof o.runner_platform=="string"?o.runner_platform:t,operator:r}}}function pk(e,t){let n=Rt(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})}function $p(e){switch(e){case"session_start":return xa;case"session_end":return Oa;case"tool_invoked":case"skill_invoked":return ko;default:return ko}}function mk(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
52
- ${n}`}function jp(e,t=[],n=process.execPath,r=import.meta.url,o=Dp){if(Qn(n))return{command:n,args:[e,...t]};let s=fk(r);return o(s)?{command:n,args:[s,e,...t]}:{command:n,args:[e,...t]}}function gk(e=process.execPath,t=import.meta.url,n=Dp){return jp(Pn,[],e,t,n)}function _k(e){let t=e.indexOf(`
53
- `);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)}}async function Bp(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();fc(n,t)}catch{}}async function io(e,t=fetch){let n=await e(),r=_k(n);if(!r)return;let{meta:o,body:s}=r,i=Ti(s),a=so(i.contentEncoding);try{let c=await t(o.url,{method:"POST",headers:a,body:i.body,signal:AbortSignal.timeout(Number(o.timeoutMs))});await Bp(c,o.url)}catch{}}async function hk(e,t,n,r=fetch){let o=$p(e),s=Ti(t),i=so(s.contentEncoding),a=Pi(s.body);E(`POST event=${e} url=${Zn(n)} size=${a} encoding=${s.contentEncoding??"identity"} platform=${process.platform}`);let c=Date.now(),l=performance.now();try{let u=await r(n,{method:"POST",headers:i,body:s.body,signal:AbortSignal.timeout(o)});if(!u.ok&&s.contentEncoding==="gzip"&&(u.status===400||u.status===415)){try{await u.text()}catch{}E(`POST gzip rejected http=${u.status} \u2014 retrying uncompressed`),u=await r(n,{method:"POST",headers:so(),body:t,signal:AbortSignal.timeout(o)})}let d=Date.now()-c;if(hs(performance.now()-l),u.ok)return E(`POST outcome=ok elapsed_ms=${d} http=${u.status}`),await Bp(u,n),!0;let f=(await u.text()).slice(0,200).replace(/[\n\r]/g,"");return E(`POST outcome=fail elapsed_ms=${d} http=${u.status} body=${f}`),!1}catch(u){let d=Date.now()-c;hs(performance.now()-l);let f=u instanceof Error?u.message:String(u);return E(`POST outcome=fail elapsed_ms=${d} http=000 body=${f}`),!1}}async function Kp(e,t,n,r,o){try{let s=r(e,t,{detached:!0,stdio:["pipe","ignore","ignore"],windowsHide:!0});s.on("error",()=>{}),s.stdin.on("error",()=>{});let i=!1;return await new Promise(a=>{let c=setTimeout(()=>{if(!i){E(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`);try{s.stdin.destroy()}catch{}}a()},Ia),l=()=>{i=!0,clearTimeout(c),a()};s.stdin.end(n,()=>l()),s.stdin.once("error",()=>l())}),s.unref(),s}catch(s){let i=s instanceof Error?s.message:String(s);return E(`WARN: ${o} spawn failed open: ${i}`),null}}async function Sk(e,t,n,r=Fp,o=gk){let s=$p(e),i=mk(n,s,t),{command:a,args:c}=o();return Kp(a,c,i,r,"detached post")}async function Gp(e,t,n=Fp,r=jp){let{command:o,args:s}=r(wn,t);return Kp(o,s,e,n,"detached work")}async function Gt(e,t,n,r,o,s,i){if(!o)return E("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),!1;if(!qn(o))return E(`WARN: collector URL blocked (https required): ${Zn(o)}`),!1;let a=performance.now(),c=await dk(t,n.runnerPlatform,i),l=performance.now(),u=r(e,c,{...n,collectorUrl:o});s!==void 0&&(u.build_ms=Math.max(0,Date.now()-s));let d=Rl({w4:a,w4e:l,w5:performance.now()},process.env,void 0,n.telemetry?.enabled===!0);d&&(u.perf=d);let f=JSON.stringify(u),p=`${f}
54
- `,g=M("EV_AI_HOOK_DEBUG");g==="full"?E(`DEBUG envelope=${f}`):g==="1"&&E(`DEBUG summary=${pk(u,Pi(p))}`);let S=process.argv.includes(wn),A=M("EV_AI_HOOK_SYNC")==="1";return Ar(n.runnerEvent,n.runnerPlatform)||S||A?hk(e,p,o):(await Sk(e,p,o),!1)}import{createReadStream as Ek}from"node:fs";import{stat as yk}from"node:fs/promises";import{basename as Rk,resolve as Ck}from"node:path";import{createInterface as Ak}from"node:readline";var bk=1024*1024;function kk(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&Rk(t).endsWith(".jsonl")}async function Vp(e){if(!e||!kk(e))return null;try{let t=Ck(e),n=await yk(t);if(!n.isFile())return null;let r=Math.max(0,n.size-bk),o=[],s=Ak({input:Ek(t,{encoding:"utf8",start:r}),crlfDelay:1/0});for await(let i of s)i.length!==0&&o.push(i);r>0&&o.length>0&&o.shift();for(let i=o.length-1;i>=0;i--){let a=o[i];if(a)try{let c=JSON.parse(a);if(c.type!=="assistant")continue;let l=c.message;if(!l||typeof l!="object")continue;let u=l.model;if(typeof u=="string"&&u.length>0)return u}catch{continue}}return null}catch{return null}}function ao(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:Hr(e.manifest.manifest,e.manifest.hookConfig),telemetry:Jp(e)}}function Jp(e){return pc(e.manifest.localTelemetry,e.manifest.hookConfig)}function vn(e,t){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{}}}function Ni(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:ws(e.manifest.hookConfig)}}async function Yp(e){let t=Date.now();await Uk(e);let{gitRoot:n}=e.manifest;await Mi(e,n);let r=Ni(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:Dr(e.hookInput,e.manifest.manifest,r),envelopeFields:ao(e),launchCwd:Ns(e.hookInput,r),home:Ok()}}function Wp(e){try{return Ee(xk(e))}catch{return null}}function Xp(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function zp(e,t){let n=e.replaceAll("\\","/");if(!Xp(n))return null;let r=Ee(e),o=Ee(t),s=Wp(e)??r,i=Wp(t)??o;return s.startsWith(`${i}/`)?s.slice(i.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}function qp(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),s=zp(e,t)??(Xp(r)?null:r),i=zp(e,n);return{repositorySourcePath:s,userSourcePath:i}}function wi(e,t,n,r,o){return Zp(e,qp(n,t.gitRoot,t.home),r,o)}function Zp(e,{repositorySourcePath:t,userSourcePath:n},r,o){let s=t??n,i=s===null?null:o(s),a=i!==null&&s!==null?Ik({installableKind:r,sourcePath:s,nativeKey:i,inRepository:t!==null,platformAgentId:e.platformAgentId,installationId:e.manifest.installationId}):void 0;return{sourcePath:s,nativeKey:i,componentReference:a}}function Ik(e){try{let t=e.inRepository?wk(e.platformAgentId,e.sourcePath):(0,B.installationRootExternalKey)(e.installationId,(0,B.userConfigRootFromPath)(e.sourcePath));return t?(0,B.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}function Qp(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}:{}}}function vi(e,t,n){return Gt("tool_invoked",{...n,...Qp(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,Kt,e.manifest.collectorUrl,t.buildStartedAtMs,vn(e,t.home))}function Tk(e){return Lu(e.runnerEvent,e.runnerPlatform)?[]:Qc(e.hookInput)}function Pk(e,t){return vi(e,t,{})}var em=new Set([...Object.values(gt),".github"]);function wk(e,t){let n=e.indexOf(":");if(n<=0)return null;let r=e.slice(0,n),o=t.replaceAll("\\","/").split("/").filter(Boolean),s=o.findIndex(i=>em.has(i));return s<0?null:`${r}:${o.slice(0,s+1).join("/")}`}var tm=".codex/config.toml",Nk=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",tm]]);function vk(e,t,n,r,o,s,i){if(e===null||t===null||!(i!==null||/^mcp__.+?__.+$/i.test(e)||/^MCP:[^:]+:.+$/i.test(e)||/^MCP:.+__.+$/i.test(e)||e.toLowerCase()===`mcp:${t.toLowerCase()}`))return;let c=s.find(S=>S.name.toLowerCase()===t.toLowerCase()),l=c?Nk.get(c.source):o==="codex"?tm:void 0,u=c?.sourcePath??l;if((c?.scope==="user"||l!==void 0)&&u)try{let S=(0,B.userConfigRootFromPath)(u);return(0,B.buildComponentReference)({installationRootExternalKey:(0,B.installationRootExternalKey)(r,S),installableKind:B.ComponentKind.INTERFACE,sourcePath:u,nativeKey:c?.name??t})}catch{return}if(n===null)return;let f=n.indexOf(":");if(f<=0||f===n.length-1)return;let p=n.slice(f+1),g=p.replaceAll("\\","/").split("/").at(-1);if(!(g===void 0||!em.has(g)))try{return(0,B.buildComponentReference)({installationRootExternalKey:n,installableKind:B.ComponentKind.INTERFACE,sourcePath:p,nativeKey:t})}catch{return}}function Mk(...e){for(let t of e)if(t)return t;return null}function At(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return E(`WARN: ${n} failed open: ${r}`),t}function Lk(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:()=>{}}}function Hk(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}var Ct=new Set,Nn=null;async function Uk(e){if(Bt())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(Ct.has(t))return;if(!xs(n)){Ct.add(t);return}let r=tn({sessionId:e.sessionId,hostname:sr()});if(ql(r)){if(Nn){await Nn;return}Nn=(async()=>{if(Ct.has(t)||!xs(n)){Ct.add(t);return}if(!oc(n)){Ct.add(t);return}let o=!1;try{let s=Date.now(),{gitRoot:i}=e.manifest,a=String(e.runnerPlatform),{operatorResolved:c,fields:l}=await nm(e,r,we("git",()=>Rr(i)),we("operator",()=>ks({gitRoot:i,installationStorePath:n,forceResend:!1,runnerPlatform:a}))),u={...l,self_config:Hk(a,c.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await Gt("session_start",u,ao(e),Kt,e.manifest.collectorUrl,s,vn(e)),o&&(c.commit(),Ct.add(t))}finally{sc(n)}})().finally(()=>{Nn=null}),await Nn}}async function Mi(e,t,n){try{e.platformAgentId=await bu(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);E(`WARN: derivePlatformAgentId failed open: ${o}`)}}async function nm(e,t,n,r){let[o,s,i,a,c]=await Promise.allSettled([n,we("virt",()=>$a()),we("cloud",()=>Al(t)),we("host_env",()=>Ba(Jp(e).enabled)),r]),l=At(o,null,"gitSnapshot"),u=At(s,"","detectVirt"),d=At(i,null,"probeCloud"),f=At(a,{},"hostEnv"),p=At(c,{commit:()=>{}},"resolveOperatorForSend");return await Mi(e,e.manifest.gitRoot,l),{operatorResolved:p,fields:{identity:{host:sr(),context:t,virt:u||null,cloud:d,git:l},host_env:f,env_vars:Pl()}}}async function Dk(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=tn({sessionId:e.sessionId,hostname:sr()}),o=String(e.runnerPlatform),s=Ni(e),i=Ns(e.hookInput,s),a=we("git",()=>Rr(n)),c=Up().catch(()=>({})),l=Bt()?Promise.resolve({commit:()=>{}}):we("operator",()=>ks({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o})),u=nm(e,r,a,l),[d,f]=await Promise.allSettled([we("mcp_declared",()=>Es(e.manifest.manifest,n,o)),a.catch(()=>null).then(K=>we("self_config",()=>bp(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:i,inGitRepo:e.manifest.inGitRepo,remote:K?.remote??null})))]),{operatorResolved:p,fields:g}=await u,S=At(d,[],"mcpDeclared"),A=At(f,Lk(o),"selfConfig"),b=A.config,O=L(e.hookInput,"model");O&&(b.model=O);let P={...g,mcp:{declared:S},self_config:b,run_meta:{trigger:e.hookSource||"startup"},hook_input:Dr(e.hookInput,e.manifest.manifest,{...s,launchCwd:i})},I=await c;await Gt("session_start",P,{...ao(e),...I},Kt,e.manifest.collectorUrl,t,vn(e))&&(A.commit(),p.commit(),Ct.add(e.manifest.installationId))}async function Fk(e){let t=Date.now(),[,n]=await Promise.all([Mi(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?Vp(L(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=Mk(L(e.hookInput,"status"),L(e.hookInput,"stop_reason"),L(e.hookInput,"reason"),un(L(e.hookInput,"error")),r==="stop"?Fe(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),s=Dr(e.hookInput,e.manifest.manifest,Ni(e));n&&(s.model=n),r!=="stopfailure"&&Hr(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&s.last_assistant_message===void 0&&(s.last_assistant_message=""),await Gt("session_end",{status:o,...n?{model:n}:{},hook_input:s},ao(e),Kt,e.manifest.collectorUrl,t,vn(e))}async function $k(e){let t=Tk(e),n=Iu(e.hookInput),r=Mu(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&Hr(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let s=await Yp(e);await Promise.all([o?Pk(e,s):void 0,t.length===0?void 0:jk(e,s,t),n.length===0?void 0:Bk(e,s,n)])}function rm(e,t,n,r){let o=r??Zc({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),s=wi(e,t,o,B.ComponentKind.SKILL,B.nativeKeyForSkillPath);if(s.sourcePath!==null&&Wo(s.sourcePath)?.toLowerCase()===n.toLowerCase())return s.componentReference===void 0?{}:{componentReference:s.componentReference};let i=r??Tu({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),a=wi(e,t,i,B.ComponentKind.COMMAND,B.nativeKeyForCommandPath);return a.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:a.nativeKey,...a.componentReference===void 0?{}:{componentReference:a.componentReference}}}function jk(e,t,n){let r=mr(e.hookInput.tool_input);return Promise.all(n.map(o=>{let s=rm(e,t,o,r);return vi(e,t,{tool_name:"Skill",skill_name:o,...s.commandName===void 0?{}:{command_name:s.commandName},...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}function Bk(e,t,n){return Promise.all(n.map(r=>{let o=ku({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),s=wi(e,t,o,B.ComponentKind.RULE,B.nativeKeyForRulePath),i=s.nativeKey??Ou(r);return vi(e,t,{tool_name:"Rule",rule_name:i,...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}var Kk=[{kind:B.ComponentKind.SKILL,nativeKeyFn:B.nativeKeyForSkillPath},{kind:B.ComponentKind.RULE,nativeKeyFn:B.nativeKeyForRulePath},{kind:B.ComponentKind.COMMAND,nativeKeyFn:B.nativeKeyForCommandPath}];function Gk(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Jo(e.hookInput);if(r===null)return n.skillName===null?{}:rm(e,t,n.skillName,null);let o=qp(r,t.gitRoot,t.home);for(let s of Kk){let i=Zp(e,o,s.kind,s.nativeKeyFn);if(i.nativeKey!==null)return{...i.componentReference===void 0?{}:{componentReference:i.componentReference},...s.kind===B.ComponentKind.RULE?{ruleName:i.nativeKey}:{},...s.kind===B.ComponentKind.COMMAND?{commandName:i.nativeKey}:{}}}return{}}var Vk=/mcp/i;function Wk(e,t,n,r){let o=Vk.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let s=o?Kd(t,n):qr(r.declaredConfig,n);return s===null?{}:Object.fromEntries(Object.entries(s).filter(i=>typeof i[1]=="string").map(([i,a])=>[`mcp_${i}`,a]))}async function zk(e){let t=await Yp(e),n=Du(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,s=zo(e.hookInput),i=jd(s,t.home),a=$u(e.hookInput),c=Hu(e.runnerEvent),l=c===!1?ju(e.hookInput,e.runnerEvent):null,u=un(L(e.hookInput,"mcp_server_name")),d=u!==null||r!==null&&br(r)?await Es(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(()=>[]):[],{mcpServer:f,mcpTool:p}=Ku(r,d.map(K=>K.name),u??""),g=vk(r,f,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),d,u),S=g===void 0?Gk(e,t,n):{},A=f===null?null:Tl(f,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),b=Wk(e,s,t.home,{hasMcpIdentity:!!f||!!p,declaredConfig:A}),O=g??S.componentReference,P=S.ruleName??n.ruleName,I=S.commandName??n.commandName,T=Fu(e.hookInput);await Gt("tool_invoked",{tool_name:r,skill_name:o,...P?{rule_name:P}:{},...I?{command_name:I}:{},success:c,duration_ms:a,...i?{executable:i}:{},...l?{failure_reason:l}:{},...f?{mcp_server:f}:{},...p?{mcp_tool:p}:{},...b,...O?{component_reference:O}:{},...T?{subagent_type:T}:{},...Qp(e),hook_input:t.hookInput},t.envelopeFields,Kt,e.manifest.collectorUrl,t.buildStartedAtMs,vn(e,t.home))}async function om(e){switch(Ve("w3"),e.internalEvent){case"session_start":await Dk(e);return;case"session_end":await Fk(e);return;case"skill_invoked":await $k(e);return;case"tool_invoked":await zk(e);return;default:return}}import{mkdirSync as Jk,readdirSync as Yk,readFileSync as Xk,statSync as sm,unlinkSync as qk,writeFileSync as Zk}from"node:fs";import{homedir as co}from"node:os";import{join as Li}from"node:path";var Qk="turns",im=1440*60*1e3,ex=100,tx=new Set(["stop","stopfailure","sessionend"]);function Hi(e=co()){return Li(ge(e),Qk)}function am(e,t){return Li(e,Yt(t))}function nx(e,t=Date.now()){let n;try{n=Yk(e)}catch{return}let r=0;for(let o of n){if(r>=ex)return;r+=1;try{let s=Li(e,o);t-sm(s).mtimeMs>im&&qk(s)}catch{}}}function rx(e,t,n=co()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let s=Hi(n);Jk(s,{recursive:!0}),Zk(am(s,r),o,"utf8")}catch{}}function ox(e,t=co()){let n=e.trim();if(!n)return"";try{let r=am(Hi(t),n);return Date.now()-sm(r).mtimeMs>im?"":Xk(r,"utf8").trim()}catch{return""}}function cm(e,t,n,r=co()){let o=t.trim(),s=tx.has(n.trim().toLowerCase());return s&&nx(Hi(r)),o?(rx(e,o,r),o):s?ox(e,r):""}async function sx(e,t,n,r){let o=t??await Vn(er),s=he(o,{}),i=await gc(process.cwd(),{sessionId:cn(s)});if(Ve("w2"),!i)return;r&&(i.collectorUrl=r,i.hookConfig=cr(r));let a=Uu(s,i.manifest.platform,n),c=os(e,a.runnerEvent);if(!c){E(`WARN: unknown hook event '${a.runnerEvent}'; skipping telemetry`);return}let l={hookInput:s,sessionId:a.sessionId,turnId:cm(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await om(l)}function ix(e,t=!1){if(M("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,s=an(r,o,void 0,n.runner);return Ar(o,s)?!0:t}function um(e,t){let n=yo(e),r=he(t,{}),o=n.event??rs(r);return Da()||vu(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}function fm(e){return tl(os(e.parsed.event,e.runnerEvent))}async function lm(e,t,n){let{parsed:r}=e,o=n??ls(r.slot);if(!o&&!fm(e)){let s=us(r.cap),i=al(s);if(!i){fs(s);return}o=i}try{await sx(r.event,t,r.runner,wu(r))}finally{o&&Or(o)}}async function dm(e=process.argv.slice(2)){if(pl(),Ve(e[0]===wn?"w0":"h0"),cl(),M("EV_AI_HOOK_JUDGE")==="1"){try{await Vn(er)}catch{}return _o(),0}if(e[0]===Pn){try{await io(qt)}catch{}return 0}if(e[0]===wn){try{let n=await qt();Ve("w1");let r=um(e.slice(1),n);if(!r)return 0;await lm(r,n)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: detached work failed open: ${r}`)}return 0}let t;try{let n=await Vn(er);Ve("h1");let r=um(e,n);if(!r)return 0;let{parsed:o,hookInput:s,runnerEvent:i}=r;if(t=ls(o.slot),!Ju(s,i,o.runner))return 0;if(Ve("h2"),ix(r))await lm(r,n,t);else{let a=t||fm(r)?void 0:us(o.cap);if(a===void 0||sl(a)){Ve("h3"),El();let c=await Gp(n,e);t&&c?.pid!==void 0&&rl(t,c.pid)}else fs(a)}}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: hook failed open: ${r}`)}finally{t&&Or(t),_o()}return 0}function uo(){E("Usage: ev-ai-agent-hook <configure|install|migrate-to-plugin|update|uninstall|--version>"),E(" configure [--url <\u2026/{orgToken}/hook>]"),E(" (manifest only \u2014 pair with marketplace plugins)"),E(" install --url <\u2026/{orgToken}/hook>"),E(" [--delivery npx|binary|local] [--force]"),E(" [--no-claude] [--no-cursor] [--no-codex]"),E(" (fallback: merge hooks into .claude / .cursor / .codex configs)"),E(" (writes collector_url to shared manifest; hook commands use --runner only)"),E(" migrate-to-plugin"),E(" (strip ev-ai file hooks; keep collector manifest)"),E(" update (refresh binary pins from a local build; leaves hook configs alone)"),E(" uninstall"),E("Hook mode: --runner <platform> [--url <\u2026/hook>|--token <orgToken>] [event]"),E(" (--url/--token optional overrides; else collector_url from manifest)")}function pm(e){return e.includes("--help")||e.includes("-h")}async function fx(e=process.argv.slice(2)){let[t,...n]=e;if(t===Pn){try{await io(qt)}catch{}return 0}return t==="--version"||t==="-V"?(process.stdout.write(`${$e}
55
- `),0):t==="configure"?pm(n)?(uo(),0):(await Uc(Ac(n)),0):t==="install"?pm(n)?(uo(),0):(await Lc(bc(n)),0):t==="migrate-to-plugin"?(await Fc(),0):t==="update"?(await Hc(),0):t==="uninstall"?(await $c(),0):t==="help"||t==="--help"||t==="-h"?(uo(),0):t===void 0?(uo(),1):dm(e)}function dx(e,t,n=ax){if(!t)return!1;try{return e===lx(cx(t)).href?!0:n(ux(e))===n(t)}catch{return!1}}dx(import.meta.url,process.argv[1])&&process.env.VITEST===void 0&&fx().then(e=>{process.exit(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);E(t),process.exit(1)});export{dx as isCliEntrypoint,fx as main};
48
+ `)){let I=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);I?.[1]&&u.add(I[1])}for(let b of bn(e,"env_vars"))u.add(b);let p=WA(e,"env_http_headers");for(let[,b]of p)b.length>0&&u.add(b);let g=ii(e,"bearer_token_env_var");g&&(u.add(g),n.bearer_token_env_var=g),u.size>0&&(n.env_var_names=[...u].sort()),p.length>0&&(n.env_http_header_names=[...new Set(p.map(([b])=>b))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let S=ii(e,"auth");S&&(n.auth=S);let A=ii(e,"default_tools_approval_mode");return A&&(n.default_tools_approval_mode=A),zA(n,e),n}var He=Qe(lt(),1);import{createHash as eb}from"node:crypto";import{join as xn}from"node:path";var qA=300,ZA=256;function Wd(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}function Qr(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}function zd(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function QA(e){return zd(e,qA)}function Jd(e,t){let n=Wd(e.trim(),t),r=Qr(n);if(r.length===0)return"";let[o,...s]=r,i=At(o),a=kn(s);return QA([i,...a].join(" "))}function Yd(e,t){if(typeof e!="string")return null;let n=Wd(e.trim(),t),r=Qr(n)[0];if(!r)return null;let o=At(r);return o.length===0?null:zd(o,ZA)}function tb(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,He.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}function nb(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
49
+ `);return eb("sha512").update(t).digest("hex").slice(0,16)}function rb(e){let t=process.platform==="win32"?xn(M("LOCALAPPDATA")??e,"npm-cache"):xn(e,".npm"),n=M("npm_config_cache")??M("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}function Xd(e){return typeof e=="string"&&e.length>0&&e.length<=He.PACKAGE_FIELD_MAX?e:null}function ob(e,t,n){let r=nb(e);for(let o of rb(n)){let s=xn(o,"_npx",r),i=q(xn(s,"node_modules",...t.split("/"),"package.json"),{}),a=Xd(i.version);if(a!==null)return a;let c=q(xn(s,"package-lock.json"),{}),l=Xd(c.packages?.[`node_modules/${t}`]?.version);if(l!==null)return l}return null}function sb(e){return e.length<=He.PACKAGE_FIELD_MAX?e:`${e.slice(0,He.PACKAGE_FIELD_MAX-1)}\u2026`}function ui(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,He.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let s=(0,He.packageNameFromSpec)(o);return s===null?null:{package_name:s,package_spec:sb(o),...tb(o,ob(r,s,n))}}function qd(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=Qr(e.trim());return n===void 0?null:ui(n,r,t)}function eo(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 ui(typeof n.command=="string"?n.command:null,r,t)}function Zd(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:ui(jt(n[1]??""),bn(e,"args"),t)}function cb(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"}function Qd(e,t,n){if(!e.claimFile(t))return;let o=e.readJson(t,{})?.mcpServers;if(!o||typeof o!="object")return;let s=e.componentPath(t);for(let[i,a]of Object.entries(o)){if(e.truncated)return;let c=cb(a),l=Bd(a,c);Object.assign(l,eo(a,e.home)??{});let u=Kd(a);e.push({kind:"MCP_SERVER",name:i,path:s,content_hash:ci(i,l,u),origin:n,enabled:u,attributes:l})}}function ep(e,t,n){if(!ib(t)||!e.claimFile(t))return;let r;try{r=ab(t,"utf8")}catch{return}let o=e.componentPath(t),s=/^\[mcp_servers(?:\.(\w+)|\."([^"]+)"|\.'([^']+)')\]\s*$/gm,i;for(;(i=s.exec(r))!==null;){if(e.truncated)return;let a=i[1]??i[2]??i[3];if(!a)continue;let c=r.slice(i.index+i[0].length),l=c.search(/^\[mcp_servers(?:\.(?:\w+|"[^"]+"|'[^']+'))\]\s*$/m),u=l===-1?c:c.slice(0,l),d="unknown";/^\s*url\s*=/m.test(u)?d="http":/^\s*command\s*=/m.test(u)&&(d="stdio");let f=Vd(u,d);Object.assign(f,Zd(u,e.home)??{});let p=Gd(u);e.push({kind:"MCP_SERVER",name:a,path:o,content_hash:ci(a,f,p),origin:n,enabled:p,attributes:f})}}import{existsSync as fb,readdirSync as db}from"node:fs";import{join as fe}from"node:path";function ub(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"}function lb(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}]}function li(e,t,n,r){let o=e.componentPath(t);for(let[s,i]of Object.entries(n))if(!(!Array.isArray(i)||e.truncated))for(let a of i){if(!a||typeof a!="object"||e.truncated)continue;let c=a;for(let l of lb(c)){if(e.truncated)return;let u=l.command??l.bash??l.prompt??l.powershell??c.powershell??"",d=ub({type:l.type??c.type,command:l.command??c.command,bash:l.bash??c.bash,powershell:l.powershell??c.powershell,prompt:l.prompt??c.prompt}),f=typeof c.matcher=="string"?c.matcher:"",p=Z(u),g=f?`${s}:${f}:${d}:${p}`:`${s}:${d}:${p}`,S=`${s}|${f}|${d}|${u}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:Z(S),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:s,...f?{matcher:f}:{},action_kind:d,action_hash:p,...d!=="prompt"&&u.trim()?{command:Jd(u,e.home)}:{}}})}}}function fi(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||li(e,t,r.hooks,n)}var tp=50;function On(e,t,n,r){if(!fb(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:s}=e.withPluginExpandCap(tp,()=>{Ct(e,{dir:fe(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),Ct(e,{dir:fe(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),Ct(e,{dir:fe(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});fi(e,fe(t,"hooks","hooks.json"),n),fi(e,fe(t,"hooks.json"),n);let i=e.components.length-o,a=s>=tp;return{componentCount:i,expandTruncated:a}}function In(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}:{}}})}function di(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}function pb(e){let t=di(e.readJson(fe(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=tn(process.platform,e.home),o=e.readJson(n,{}),s={};if(o&&Object.keys(o).length>0)s=di(o);else for(let i of r)Object.assign(s,di(e.readJson(i,{})));return{...t,...s}}function np(e){let t=fe(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=pb(e),s=e.componentPath(t);for(let[i,a]of Object.entries(r)){if(e.truncated)return;let c=Array.isArray(a)?a:[a],l=c[0]??{},u=o[i]===!0,d=i.includes("@")?i.split("@").slice(1).join("@"):"",f=typeof l.version=="string"?l.version:"",p=typeof l.scope=="string"?l.scope:"user",g=`plugin:${i}`,S=0,A=!1;for(let b of c)if(typeof b.installPath=="string"&&b.installPath.length>0){let I=On(e,b.installPath,g,u);S+=I.componentCount,A=A||I.expandTruncated}In(e,{pluginKey:i,rowPath:s,enabled:u,scope:p,version:f||void 0,marketplace:d||void 0,componentCount:S,expandTruncated:A,contentHash:Z(`${i}|${f}|${p}|${u}|${S}`)})}}function mb(e){let t=e,n="";try{let r=db(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=fe(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),s=o[o.length-1];s&&(t=fe(e,s),n=s)}}catch{}return{installPath:t,version:n}}var gb=/^\d+$/;function _b(e){let t=e.filter(n=>!gb.test(n.pluginId));return t.length>0?t:e}function rp(e){let t=[{base:fe(e.home,".cursor/plugins/local"),scope:"local"},{base:fe(e.home,".cursor/plugins/cache"),scope:"cache"}];for(let{base:n,scope:r}of t)if(!e.truncated)for(let o of e.readEntries(n)){if(!o.isDirectory()||e.truncated)continue;if(r==="local"){let a=o.name,c=fe(n,o.name),l=`plugin:${a}`,{componentCount:u,expandTruncated:d}=On(e,c,l,!0);In(e,{pluginKey:a,rowPath:e.componentPath(c),enabled:!0,scope:"local",componentCount:u,expandTruncated:d,contentHash:Z(`${a}|local|${u}`)});continue}let s=o.name,i=[];for(let a of e.readEntries(fe(n,s))){if(!a.isDirectory())continue;let c=fe(n,s,a.name),{installPath:l,version:u}=mb(c);i.push({pluginId:a.name,installPath:l,version:u})}for(let a of _b(i)){if(e.truncated)break;let c=`${a.pluginId}@${s}`,l=`plugin:${c}`,{componentCount:u,expandTruncated:d}=On(e,a.installPath,l,!0);In(e,{pluginKey:c,rowPath:e.componentPath(a.installPath),enabled:!0,scope:"cache",version:a.version||void 0,marketplace:s,componentCount:u,expandTruncated:d,contentHash:Z(`${c}|${a.version}|${u}`)})}}}import{existsSync as Eb}from"node:fs";var hb=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,pi="<path>",Sb=new RegExp(`${pi}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function to(e){let t=e.replace(hb,pi).replace(Sb,pi);return t.length>200?`${t.slice(0,200)}...`:t}var op=200,sp=200,mi=16*1024,ip=6,yb=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),Rb=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),Cb=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),Ab=new Set(["permissions"]),bb={claude:yb,cursor_sandbox:Rb,cursor_permissions:Cb,cursor_cli:Ab},kb=new Set(["allow","deny","ask"]);function dt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function no(e){return e.replace(/\\/g,"/")}function gi(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>gi(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${gi(t[r])}`).join(",")}}`}function xb(e){return Z(`${gi(e)}|settings1`)}function fp(e){let t=no(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"}function dp(e,t){if(e!=="claude")return{};let n=no(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"}}function pp(e){let t=no(e).replace(/\/+$/,"");return t.length<=1?"":t}function mp(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}function Ob(e,t){let n=no(e);if(n==="~"||n.startsWith("~/"))return n;let r=pp(t);if(!r)return n;let o=n.slice(0,r.length);if(!(mp(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let i=n.slice(r.length);return i===""?"~":i.startsWith("/")?`~${i}`:n}var ap=new Map;function Ib(e){let t=ap.get(e);if(t!==void 0)return t;let n=pp(e),r=null;if(n){let o=n.split("/").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,mp(e)?"gi":"g")}return ap.set(e,r),r}function Tb(e,t){let n=Ib(t);return n?e.replace(n,"~"):e}function cp(e,t){return e.length<=sp?e:(t.truncated=!0,e.slice(0,sp))}function gp(e,t){return e.length<=op?e:(t.truncated=!0,e.slice(0,op))}function re(e,t,n,r){if(typeof e=="string"){if(t==="path")return cp(Ob(e,n),r);let o=t==="rule"?to(e):e;return cp(Tb(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=gp(e,r),s=[];for(let i of o){let a=re(i,t,n,r);a!==void 0&&s.push(a)}return s}if(dt(e)){let o={};for(let[s,i]of Object.entries(e)){let a=re(i,t,n,r);a!==void 0&&(o[s]=a)}return o}}function up(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i="plain";kb.has(o)?i="rule":o==="additionalDirectories"&&(i="path");let a=re(s,i,t,n);a!==void 0&&(r[o]=a)}return r}function Pb(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){if(o==="files"&&Array.isArray(s)){let a=gp(s,n);r[o]=a.map(c=>{if(!dt(c))return re(c,"plain",t,n);let l={};for(let[u,d]of Object.entries(c)){let p=re(d,u==="path"?"path":"plain",t,n);p!==void 0&&(l[u]=p)}return l});continue}let i=re(s,"plain",t,n);i!==void 0&&(r[o]=i)}return r}function wb(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let a=re(s,o==="allowUnixSockets"?"path":"plain",t,n);a!==void 0&&(r[o]=a)}return r}function Nb(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i;o==="excludedCommands"?i=re(s,"rule",t,n):o==="filesystem"?i=re(s,"path",t,n):o==="network"?i=wb(s,t,n):o==="credentials"?i=Pb(s,t,n):i=re(s,"plain",t,n),i!==void 0&&(r[o]=i)}return r}function vb(e,t,n,r,o){return n==="claude"?e==="permissions"?up(t,r,o):e==="sandbox"?Nb(t,r,o):re(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?re(t,"path",r,o):re(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?re(t,"rule",r,o):re(t,"plain",r,o):e==="permissions"?up(t,r,o):re(t,"plain",r,o)}function Tn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function _i(e,t){return e?`${e}.${t}`:t}function hi(e,t,n,r){if(Array.isArray(e)){for(let o=e.length-1;o>=0;o-=1){let s=e[o];s!==null&&typeof s=="object"&&(t+1>=ip?(e.splice(o,1),r.add(n)):hi(s,t+1,n,r))}return}if(!(e===null||typeof e!="object"))for(let[o,s]of Object.entries(e))s!==null&&typeof s=="object"&&(t+1>=ip?(delete e[o],r.add(_i(n,o))):hi(s,t+1,_i(n,o),r))}function _p(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:Tn(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))_p(o,_i(t,r),n)}function Mb(e,t,n){let r=Tn(e);if(r<=mi)return;t.truncated=!0;let o=[];for(_p(e,"",o);r>mi;){let s;for(let c of o)c.items.length>0&&(!s||c.bytes>s.bytes)&&(s=c);if(!s)break;let i=s.items.pop(),a=Tn(i)+(s.items.length>0?1:0);s.bytes-=a,r-=a,n.add(s.path)}for(;Tn(e)>mi;){let s,i=-1;for(let[a,c]of Object.entries(e)){let l=Tn(c);l>i&&(s=a,i=l)}if(s===void 0)break;delete e[s],n.add(s)}}function Lb(e,t,n){let r=bb[t],o={truncated:!1},s={},i=[];for(let c of Object.keys(e)){if(!r.has(c)){i.push(c);continue}let l=vb(c,e[c],t,n,o);l!==void 0&&(s[c]=l)}i.sort();let a=new Set;return hi(s,1,"",a),a.size>0&&(o.truncated=!0),Mb(s,o,a),{settings:s,keys_omitted:i,truncated:o.truncated,trimmed_paths:[...a].sort()}}function lp(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:xb(t.attributes),attributes:t.attributes};e.push(n)}function Si(e,t,n,r){if(!e.claimFile(t)||!Eb(t))return;let o=_a(t);if(!o.ok||!dt(o.value)){if(r.profile){let l=!o.ok&&o.reason==="read"?"read_error":"parse_error",u={profile:r.profile,[l]:!0};r.managedSource&&(u.managed_source=r.managedSource),lp(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}return}let s=o.value,i=s.hooks;if(dt(i)&&li(e,t,i,n),!r.profile)return;let a=Lb(s,r.profile,e.home),c={profile:r.profile,settings:a.settings,keys_omitted:a.keys_omitted};a.truncated&&(c.truncated=!0),a.trimmed_paths.length>0&&(c.trimmed_paths=a.trimmed_paths),r.managedSource&&(c.managed_source=r.managedSource),lp(e,{kind:r.kind,absPath:t,origin:n,attributes:c})}import{existsSync as Hb}from"node:fs";import{join as Ue}from"node:path";var hp=".claude/skills/synced",Sp=".claude/plugins/synced";function Ep(e){return[Ue(e,hp),Ue(e,Sp)]}function ro(e){return typeof e=="string"&&e.length>0?e:void 0}function yp(e){let t=Ue(e.home,hp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ue(t,n.name),o=e.readJson(Ue(r,"manifest.json"),{}),s=new Map((o?.skills??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}let a=Ue(r,i.name,"SKILL.md");if(!i.isDirectory()||!Hb(a))continue;let c=s.get(i.name),l=ro(c?.source),u=ro(c?.creatorType);$t(e,{absolutePath:a,kind:"SKILL",origin:"user",enabled:!0,name:i.name,attributes:{scope:"synced",...l?{source:l}:{},...u?{creator_type:u}:{}}})}}}function Rp(e){let t=Ue(e.home,Sp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ue(t,n.name),o=e.readJson(Ue(r,"manifest.json"),{}),s=new Map((o?.plugins??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.truncated)return;if(!i.isDirectory()||i.name.startsWith("."))continue;let a=s.get(i.name),c=ro(a?.marketplaceName),l=ro(a?.version),u=c?`${i.name}@${c}`:i.name,d=Ue(r,i.name),{componentCount:f,expandTruncated:p}=On(e,d,`plugin:${u}`,!0);In(e,{pluginKey:u,rowPath:e.componentPath(d),enabled:!0,scope:"synced",version:l,marketplace:c,componentCount:f,expandTruncated:p,contentHash:Z(`${u}|${l??""}|synced|${f}`)})}}}function Db(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:s}=t;for(let i of n.skillRoots)Ct(e,{dir:Bt(r,i),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:Ep(e.home)});for(let i of n.dirs)Ct(e,{dir:Bt(r,i.dir),kind:i.kind,origin:o,enabled:!0,extensions:i.extensions});for(let i of n.memory){let a=vd(i.map(c=>Bt(r,c)));a&&$t(e,{absolutePath:a,kind:"MEMORY",origin:o,enabled:!0,name:Ub(a)})}for(let i of Zc(n))Si(e,Bt(r,i),o,{kind:"SETTINGS",profile:fp(i)});for(let i of n.mcpJson??[])Qd(e,Bt(r,i),o);for(let i of n.mcpToml??[])ep(e,Bt(r,i),o);if(s){if(n.managed){for(let i of sr(n.managed,process.platform,e.home))if(i.toLowerCase().endsWith(".json")){let a=dp(n.managed,i);Si(e,i,o,{kind:"MANAGED_SETTINGS",...a})}}n.plugins==="claude"?(np(e),Rp(e),yp(e)):n.plugins==="cursor"&&rp(e)}}function Cp(e,t){try{let n=new Kr(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)Db(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{return}}function Ei(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let c=Cp(t,{layouts:Object.values(vt),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:et,scopeRef:""});c&&(r.user=c)}let s=n.inGitRepo===!0,i=null,a=n.launchCwd;if(a!==void 0){let c=Object.values(it),l=Hs({launchCwd:a,gitRoot:n.gitRoot,inGitRepo:s,remote:n.remote,home:t,hasProjectSpec:u=>eu(c,u)});i=l.parentRel;for(let u of l.anchors){let d=bs(u.dir);if(o!==void 0&&!o(u.scope,d))continue;let f=Cp(t,{layouts:c,levelDir:u.dir,origin:u.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:Us,scopeRef:d});f&&(r[u.scope]=f)}r.parent||(i=null)}return{scopes:r,parentRel:i,cwdInGitRepo:s}}function yi(e,t,n={}){let r=n.truncated===!0,o=hn(e),s=new Set(e.map(u=>Re(u.path,u.name)));if(n.forceFull===!0||t===void 0)return{hash:o,count:e.length,truncated:r,full:!0,upserts:e,removed:[],unchanged:!1};let a=[],c=t;for(let u of e){let d=Re(u.path,u.name);c[d]!==Dr(u)&&a.push(u)}let l=[];if(!r){for(let u of Object.keys(c))if(!s.has(u)){let d=rf(u);d&&l.push(d)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:a,removed:l,unchanged:a.length===0&&l.length===0}}var bp=2*1024*1024,Fb=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function Ri(e,t,n){let r=new Set(t.map(s=>Re(s.path,s.name))),o=[];for(let s of e)s.text!==void 0&&(n.has(s.content_hash)||r.has(Re(s.path,s.name))||o.push(s));return o}function Ci(e,t,n){let r=new Set(e);for(let s of t)r.add(s);let o=new Set(n.map(s=>s.content_hash));return[...r].filter(s=>o.has(s))}function Ap(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function kp(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}function Ai(e,t=bp){let n=[],r=[];for(let u of e)Fb.has(u.kind)?n.push(u):r.push(u);r.sort((u,d)=>(u.text?.length??0)-(d.text?.length??0));let o=[...n,...r],s=[],i=2,a=0,c=0,l=[];for(let u of o){let d=s.length>0?1:0,f=Ap(u)+d;if(i+f<=t){s.push(u),i+=f,u.text!==void 0&&l.push(u.content_hash);continue}if(u.text!==void 0){let p=kp(u),g=Ap(p)+d;if(i+g<=t){s.push(p),i+=g,a+=1;continue}}c+=1}return{components:s,textDeferredCount:a,droppedCount:c,textHashesSent:l}}function bi(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:kp(n))}var $b=["user","cwd","repo","parent"];function ki(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,s=[];for(let T of $b){let O=t.scopes[T];if(!O)continue;let K=n(T,O.scopeRef),D=K.components,x=yi(O.components,D,{forceFull:D===void 0,truncated:O.truncated}),N=new Set(K.textHashes),H=Ri(O.components,x.upserts,N),m=bi([...x.upserts,...H],N);s.push({scope:T,walk:O,delta:x,outgoing:m,outgoingKeys:new Set(m.map(k=>Re(k.path,k.name))),deliveredTextHashes:N,cachedComponents:D})}let i=s.flatMap(T=>T.outgoing),a=Ai(i,o),c=new Set(a.components.map(T=>Re(T.path,T.name))),l=[],u=[],d=[],f=[],p=[],g=[],S=[];for(let T of s){let{scope:O,walk:K,delta:D}=T;g.push(...K.components),l.push(O);let x=a.components.filter(k=>T.outgoingKeys.has(Re(k.path,k.name))),N=[...T.outgoingKeys].some(k=>!c.has(k)),H=D.truncated||N;H?d.push(O):D.full&&u.push(O),f.push(...x),!D.full&&!H&&p.push(...D.removed);let m=D.full?{}:{...T.cachedComponents??{}};if(!H)for(let k of D.removed)delete m[Re(k.path,k.name)];for(let k of x)m[Re(k.path,k.name)]=Dr(k);S.push({scope:O,scopeRef:K.scopeRef,components:m,textHashes:Ci(T.deliveredTextHashes,x.filter(k=>k.text!==void 0).map(k=>k.content_hash),K.components),collectedAtMs:r,included:x.length>0||D.removed.length>0&&!H||D.full})}let A={user_spec_hash:hn(g),user_spec_count:g.length,user_spec_truncated:d.length>0};l.length>0&&(A.user_spec_scopes=l,A.user_spec_full_scopes=u,A.user_spec_truncated_scopes=d,A.user_spec_cwd_in_git_repo=t.cwdInGitRepo),u.length>0&&u.length===l.length&&(A.user_spec_full=!0),f.length>0&&(A.user_spec=f),p.length>0&&(A.user_spec_removed=p),a.textDeferredCount>0&&(A.user_spec_text_deferred=a.textDeferredCount);let b=t.scopes.cwd;b&&(A.user_spec_cwd_scope_ref=b.scopeRef);let I=t.scopes.repo;I&&(A.user_spec_repo_scope_ref=I.scopeRef);let P=t.scopes.parent;return P&&(A.user_spec_parent_scope_ref=P.scopeRef,t.parentRel&&(A.user_spec_parent_rel=t.parentRel)),{fields:A,scopes:S}}var oo={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function xi(e){return e==="cwd"||e==="repo"||e==="parent"}function Pn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Oi(e){return!Pn(e)||!Pn(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)}function xp(e){return jb(e)}function Op(e){return Bb(e)}function Ip(e){return Kb(e)}function jb(e){if(!Pn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}function Bb(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Tp(e,t){if(!Pn(e))return;let n=e[t];return Oi(n)?n:void 0}function Kb(e){if(!Pn(e))return{};let t={};for(let[n,r]of Object.entries(e))Oi(r)&&(t[n]=r);return t}function Ii(e,t=20){let n=[];for(let[r,o]of Object.entries(e))Oi(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))}var Jb=["allow","deny","ask"];function io(e){let t=q(e,{}),n=[];for(let r of Jb)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:to(o),mode:r});return{model:t.model??"",permissionKeys:n}}function Yb(e){let{serverManaged:t,fileBased:n}=tn(process.platform,e),r=io(t);if(r.model||r.permissionKeys.length>0)return r;let o="",s=[];for(let i of n){let a=io(i);a.model&&(o=a.model),s.push(...a.permissionKeys)}return{model:o,permissionKeys:s}}function Xb(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}var qb=10,Zb="self-config-cache.json",wp=5;function Gt(){return M("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}function Qb(){return M("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}var ek={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function tk(e,t=ne){let n=ek[e];if(!n||n.length===0)return null;let r=async o=>{let s=n[o];if(s===void 0)return null;let a=((await t(s,["--version"],2e3)).split(`
50
+ `)[0]??"").trim();return a||r(o+1)};return r(0)}function nk(e=Pp()){return Kt(e,".ev-ai","agent-hook",Zb)}function rk(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
51
+ `);return Z(n)}function so(e,t,n=!1){let r=rk(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}}function Ti(e,t,n=[]){let r=0,o=!1,s=new Set;for(let i of[...t.map(a=>Kt(e,a)),...n]){let a=zb(i);if(s.has(a))continue;s.add(a);let c=Ro(i);c.present&&(o=!0,r+=c.size)}return o?{present:!0,size:r}:{present:!1,size:0}}function ok(e){return Vb(e)?Se(Wb(e,"utf8"),{}):{}}function sk(e,t){try{ce(e,`${JSON.stringify(t)}
52
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: self-config cache write failed open: ${r}`)}}function ik(e,t,n){if(t==="user")return{components:xp(e.user_spec_components),textHashes:Op(e.user_spec_text_hashes)};if(!xi(t))return{components:void 0,textHashes:[]};let r=Tp(e[oo[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}function ak(e,t,n,r){let o={...e,send_count:n};for(let s of Object.keys(t)){let i=t[s];i.entries!==void 0&&(o[s]=i.hash)}if(r){o.user_spec_layout_version=wp,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 s of r.project){if(!xi(s.scope))continue;let i=oo[s.scope],a=Ip(o[i]),c=a[s.scopeRef];a[s.scopeRef]={components:s.included?s.components:c?.components??{},text_hashes:s.textHashes,collected_at_ms:s.collectedAtMs},o[i]=Ii(a)}}return o}async function Np(e,t=process.cwd(),n=Pp(),r={}){let o=e==="claude",s=r.gitRoot??t,i=await tk(e),a="",c=[];if(o){let H=Yb(n),m=io(Kt(n,".claude/settings.json")),k=io(Kt(t,".claude/settings.local.json"));a=H.model||k.model||m.model,c=Xb([...H.permissionKeys,...m.permissionKeys,...k.permissionKeys]).slice(0,200)}let l={present:!1,size:0},u=H=>{let m=[],k=!1;for(let U of H){let de=ha(Kt(n,U));if(m=m.concat(de.entries),k=k||de.truncated,m.length>=et){m=m.slice(0,et),k=!0;break}}return{entries:m,truncated:k}},d=nk(n),f=ok(d),p=f[e]??{},g=(p.send_count??0)+1,S=g>0&&g%qb===0,A=H=>S?void 0:p[H],b=u(ct.skills),I=u(ct.subagents),P=u(ct.commands),T=u(ct.rules),O={skills:so(b.entries,A("skills"),b.truncated),subagents:so(I.entries,A("subagents"),I.truncated),commands:so(P.entries,A("commands"),P.truncated),rules:so(T.entries,A("rules"),T.truncated)},K={runner_platform:e,config_scope:"user",cli_version:i,claude_version:o?i:null,model:o&&a||null,permission_keys:c,user_scope:{skills:O.skills,subagents:O.subagents,commands:O.commands,rules:O.rules,memory:Ti(n,ct.memory),settings:Ti(n,ct.settings,tu(n)),mcp:Ti(n,ct.mcp)},local_settings:o?Ro(Kt(t,".claude/settings.local.json")):l},D=null,x=r.nowMs??Date.now();if(!Gt()){let H=p.user_spec_layout_version!==wp,m=Ei(e,n,{launchCwd:Qb()?void 0:r.launchCwd,gitRoot:s,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(m.scopes).length>0){let k=ki({collected:m,cacheFor:(U,de)=>H?{components:void 0,textHashes:[]}:ik(p,U,de),nowMs:x});Object.assign(K,k.fields),D={hash:k.fields.user_spec_hash,home:k.scopes.find(U=>U.scope==="user")??null,project:k.scopes.filter(U=>U.scope!=="user")}}}let N=ak(p,O,g,D);return{config:K,commit:()=>{f[e]=N,sk(d,f)}}}import{homedir as Ok}from"node:os";import{join as Lp}from"node:path";function bt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}import{join as ao}from"node:path";function ck(e){return ao(e,".ev-ai","agent-hook","js","signed-v1")}function uk(e){return ao(ck(e),"scopes")}function vp(e,t){return ao(uk(e),t)}function Mp(e){return ao(e,"attempts")}function Pi(e){return String(e).padStart(10,"0")}var lk=/^(\d{10})$/,fk=/^(\d{10})\.done$/,dk=/^[0-9a-f]{128}$/,pk=64,Fp=["check_ms","download_ms","install_ms","total_ms"],mk=36e5;async function $p(e,t,n=!1){let r=Mp(t),o=await Yi(e,r),s=new Map,i=new Map,a=Hp(o,lk),c=Hp(o,fk),l=async f=>{let p=await Dp(e,Lp(r,gk(f)));return p&&s.set(f,{record:hk(p.value),mtimeMs:p.mtimeMs}),p!==void 0},u=async f=>{let p=Sk((await Dp(e,Lp(r,_k(f))))?.value);return p&&i.set(f,p),p!==void 0};if(!n)return await Promise.all([...a.map(l),...c.map(u)]),{claims:s,dones:i};await Promise.all([Up(a,l),Up(c,u)]);let d=wn(s);return d<wn(i)&&c.includes(d)&&await u(d),{claims:s,dones:i}}function Hp(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}async function Up(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}function wn(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}function jp(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}function Bp(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of Fp){let r=e[n];r!==void 0&&(t[n]=r)}return t}function gk(e){return Pi(e)}function _k(e){return`${Pi(e)}.done`}async function Dp(e,t){let n;try{n=await e.stat(t)}catch(o){if(Ot(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>go)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>go?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}function hk(e){if(!bt(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}function Sk(e){if(!bt(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=yk(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...Ek(t)}}function Ek(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 Fp){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=mk&&(t[n]=r)}return t}function yk(e){if(!bt(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"&&dk.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&Rk(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}function Rk(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==pk||t.toString("base64")!==e))return t.toString("hex")}function kk(e){return e==="bootstrap"?3e3:6e4}function xk(e,t){let n=wn(e.claims);if(n===0)return;let r=wn(e.dones),o=e.claims.get(n),s=e.dones.get(n);if(o&&!s){let a=jp(o),c=o.record==="empty"?void 0:o.record.owner,l=kk(c)+3e4;if(t-a>l)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:Kp(e.dones.get(r)?.selection)}}if(r===0)return;let i=e.dones.get(r);if(i)return{n:r,latest_claim:n,outcome:i.outcome,finished_at:i.finished_at,selection_version:Kp(i.selection),...Bp(i)}}async function Gp(e,t,n){try{let r=await $p(Xi(),vp(e,t),!0);return xk(r,n)}catch{return}}function Kp(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}function Ik(e=process.env){if(Object.values(Ua).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===Ee?"npx":null}async function Vp(e=Ok()){let t=ms()?.launcherScope;if(!t)return{};let n=await Gp(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}function Vt(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:nt,event:e,timestamp:Wn(),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:Be,hook_delivery:Ik(),host_arch:process.arch,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},s=ms();return s&&(o.launcher_version=s.launcherVersion,o.hook_source=s.hookSource,o.hook_fallback_reason=s.fallbackReason??null,o.launcher_scope_match=hl(n.collectorUrl,s.launcherScope)),e==="session_start"&&(n.launcher_scope&&(o.launcher_scope=n.launcher_scope),n.launcher_attempt&&(o.launcher_attempt=n.launcher_attempt)),o}import{existsSync as Wp}from"node:fs";import{spawn as zp}from"node:child_process";import{fileURLToPath as Pk}from"node:url";import{gzipSync as Tk}from"node:zlib";function wi(e){return M("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<La?{body:e}:{body:Tk(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}function co(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}function Ni(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}var Nn="__post",vn="__work";async function wk(e,t,n={}){if(Gt())return e;let r=await xs(n.gitRoot??process.cwd(),ne,process.env,{runnerPlatform:t,home:n.home}),o=bt(e.self_config)?e.self_config:{};return{...e,self_config:{...o,runner_platform:typeof o.runner_platform=="string"?o.runner_platform:t,operator:r}}}function Nk(e,t){let n=bt(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})}function Jp(e){switch(e){case"session_start":return wa;case"session_end":return Na;case"tool_invoked":case"skill_invoked":return xo;default:return xo}}function vk(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
53
+ ${n}`}function Yp(e,t=[],n=process.execPath,r=import.meta.url,o=Wp){if(tr(n))return{command:n,args:[e,...t]};let s=Pk(r);return o(s)?{command:n,args:[s,e,...t]}:{command:n,args:[e,...t]}}function Mk(e=process.execPath,t=import.meta.url,n=Wp){let r=process.argv.includes("--debug")?["--debug"]:[];return Yp(Nn,r,e,t,n)}function Lk(e){let t=e.indexOf(`
54
+ `);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)}}async function Xp(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();hc(n,t)}catch{}}function qp(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}}async function uo(e,t=fetch){let n=await e(),r=Lk(n);if(!r){_e.error("send fail code=bad-frame message=detached post stdin was not framed");return}let{meta:o,body:s}=r,i=wi(s),a=co(i.contentEncoding);try{let c=await t(o.url,{method:"POST",headers:a,body:i.body,signal:AbortSignal.timeout(Number(o.timeoutMs))});if(!c.ok){let l=(await c.text()).slice(0,200).replace(/[\n\r]/g,"");_e.error(`send fail http=${c.status} code=${c.status} message=${l}`);return}_e.info(`send ok http=${c.status}`),await Xp(c,o.url)}catch(c){let l=qp(c);_e.error(`send fail code=${l.code??"(none)"} message=${l.message}`)}}async function Hk(e,t,n,r=fetch){let o=Jp(e),s=wi(t),i=co(s.contentEncoding),a=Ni(s.body);E(`POST event=${e} url=${Tt(n)} size=${a} encoding=${s.contentEncoding??"identity"} platform=${process.platform}`);let c=Date.now(),l=performance.now();try{let u=await r(n,{method:"POST",headers:i,body:s.body,signal:AbortSignal.timeout(o)});if(!u.ok&&s.contentEncoding==="gzip"&&(u.status===400||u.status===415)){try{await u.text()}catch{}E(`POST gzip rejected http=${u.status} \u2014 retrying uncompressed`),u=await r(n,{method:"POST",headers:co(),body:t,signal:AbortSignal.timeout(o)})}let d=Date.now()-c;if(Es(performance.now()-l),u.ok)return E(`POST outcome=ok elapsed_ms=${d} http=${u.status}`),_e.info(`send ok http=${u.status}`),await Xp(u,n),!0;let f=(await u.text()).slice(0,200).replace(/[\n\r]/g,"");return E(`POST outcome=fail elapsed_ms=${d} http=${u.status} body=${f}`),_e.error(`send fail http=${u.status} code=${u.status} message=${f}`),!1}catch(u){let d=Date.now()-c;Es(performance.now()-l);let f=qp(u);return E(`POST outcome=fail elapsed_ms=${d} http=000 body=${f.message}`),_e.error(`send fail http=0 code=${f.code??"(none)"} message=${f.message}`),!1}}async function Zp(e,t,n,r,o){try{let s=r(e,t,{detached:!0,stdio:["pipe","ignore","ignore"],windowsHide:!0});s.on("error",()=>{}),s.stdin.on("error",()=>{});let i=!1;return await new Promise(a=>{let c=setTimeout(()=>{if(!i){E(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`);try{s.stdin.destroy()}catch{}}a()},va),l=()=>{i=!0,clearTimeout(c),a()};s.stdin.end(n,()=>l()),s.stdin.once("error",()=>l())}),s.unref(),s}catch(s){let i=s instanceof Error?s.message:String(s);return E(`WARN: ${o} spawn failed open: ${i}`),null}}async function Uk(e,t,n,r=zp,o=Mk){let s=Jp(e),i=vk(n,s,t),{command:a,args:c}=o();return Zp(a,c,i,r,"detached post")}async function Qp(e,t,n=zp,r=Yp){let{command:o,args:s}=r(vn,t);return Zp(o,s,e,n,"detached work")}async function Wt(e,t,n,r,o,s,i){if(!o)return E("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),_e.error("send fail code=missing message=collector URL missing"),!1;if(!er(o))return E(`WARN: collector URL blocked (https required): ${Tt(o)}`),_e.error("send fail code=blocked message=collector URL blocked"),!1;let a=performance.now(),c=await wk(t,n.runnerPlatform,i),l=performance.now(),u=r(e,c,{...n,collectorUrl:o});s!==void 0&&(u.build_ms=Math.max(0,Date.now()-s));let d=Tl({w4:a,w4e:l,w5:performance.now()},process.env,void 0,n.telemetry?.enabled===!0);d&&(u.perf=d);let f=JSON.stringify(u),p=`${f}
55
+ `,g=M("EV_AI_HOOK_DEBUG");g==="full"?E(`DEBUG envelope=${f}`):g==="1"&&E(`DEBUG summary=${Nk(u,Ni(p))}`);let S=process.argv.includes(vn),A=M("EV_AI_HOOK_SYNC")==="1";return xr(n.runnerEvent,n.runnerPlatform)||S||A?Hk(e,p,o):(await Uk(e,p,o),!1)}import{createReadStream as Dk}from"node:fs";import{stat as Fk}from"node:fs/promises";import{basename as $k,resolve as jk}from"node:path";import{createInterface as Bk}from"node:readline";var Kk=1024*1024;function Gk(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&$k(t).endsWith(".jsonl")}async function em(e){if(!e||!Gk(e))return null;try{let t=jk(e),n=await Fk(t);if(!n.isFile())return null;let r=Math.max(0,n.size-Kk),o=[],s=Bk({input:Dk(t,{encoding:"utf8",start:r}),crlfDelay:1/0});for await(let i of s)i.length!==0&&o.push(i);r>0&&o.length>0&&o.shift();for(let i=o.length-1;i>=0;i--){let a=o[i];if(a)try{let c=JSON.parse(a);if(c.type!=="assistant")continue;let l=c.message;if(!l||typeof l!="object")continue;let u=l.model;if(typeof u=="string"&&u.length>0)return u}catch{continue}}return null}catch{return null}}function lo(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:Fr(e.manifest.manifest,e.manifest.hookConfig),telemetry:rm(e)}}function rm(e){return Ec(e.manifest.localTelemetry,e.manifest.hookConfig)}function Ln(e,t){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{}}}function Mi(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:vs(e.manifest.hookConfig)}}async function om(e){let t=Date.now();await nx(e);let{gitRoot:n}=e.manifest;await Hi(e,n);let r=Mi(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:jr(e.hookInput,e.manifest.manifest,r),envelopeFields:lo(e),launchCwd:Ms(e.hookInput,r),home:Wk()}}function tm(e){try{return ye(Vk(e))}catch{return null}}function sm(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function nm(e,t){let n=e.replaceAll("\\","/");if(!sm(n))return null;let r=ye(e),o=ye(t),s=tm(e)??r,i=tm(t)??o;return s.startsWith(`${i}/`)?s.slice(i.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}function im(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),s=nm(e,t)??(sm(r)?null:r),i=nm(e,n);return{repositorySourcePath:s,userSourcePath:i}}function vi(e,t,n,r,o){return am(e,im(n,t.gitRoot,t.home),r,o)}function am(e,{repositorySourcePath:t,userSourcePath:n},r,o){let s=t??n,i=s===null?null:o(s),a=i!==null&&s!==null?zk({installableKind:r,sourcePath:s,nativeKey:i,inRepository:t!==null,platformAgentId:e.platformAgentId,installationId:e.manifest.installationId}):void 0;return{sourcePath:s,nativeKey:i,componentReference:a}}function zk(e){try{let t=e.inRepository?Xk(e.platformAgentId,e.sourcePath):(0,B.installationRootExternalKey)(e.installationId,(0,B.userConfigRootFromPath)(e.sourcePath));return t?(0,B.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}function cm(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}:{}}}function Li(e,t,n){return Wt("tool_invoked",{...n,...cm(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,Vt,e.manifest.collectorUrl,t.buildStartedAtMs,Ln(e,t.home))}function Jk(e){return Ku(e.runnerEvent,e.runnerPlatform)?[]:cu(e.hookInput)}function Yk(e,t){return Li(e,t,{})}var um=new Set([...Object.values(St),".github"]);function Xk(e,t){let n=e.indexOf(":");if(n<=0)return null;let r=e.slice(0,n),o=t.replaceAll("\\","/").split("/").filter(Boolean),s=o.findIndex(i=>um.has(i));return s<0?null:`${r}:${o.slice(0,s+1).join("/")}`}var lm=".codex/config.toml",qk=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",lm]]);function Zk(e,t,n,r,o,s,i){if(e===null||t===null||!(i!==null||/^mcp__.+?__.+$/i.test(e)||/^MCP:[^:]+:.+$/i.test(e)||/^MCP:.+__.+$/i.test(e)||e.toLowerCase()===`mcp:${t.toLowerCase()}`))return;let c=s.find(S=>S.name.toLowerCase()===t.toLowerCase()),l=c?qk.get(c.source):o==="codex"?lm:void 0,u=c?.sourcePath??l;if((c?.scope==="user"||l!==void 0)&&u)try{let S=(0,B.userConfigRootFromPath)(u);return(0,B.buildComponentReference)({installationRootExternalKey:(0,B.installationRootExternalKey)(r,S),installableKind:B.ComponentKind.INTERFACE,sourcePath:u,nativeKey:c?.name??t})}catch{return}if(n===null)return;let f=n.indexOf(":");if(f<=0||f===n.length-1)return;let p=n.slice(f+1),g=p.replaceAll("\\","/").split("/").at(-1);if(!(g===void 0||!um.has(g)))try{return(0,B.buildComponentReference)({installationRootExternalKey:n,installableKind:B.ComponentKind.INTERFACE,sourcePath:p,nativeKey:t})}catch{return}}function Qk(...e){for(let t of e)if(t)return t;return null}function xt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return E(`WARN: ${n} failed open: ${r}`),t}function ex(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:()=>{}}}function tx(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}var kt=new Set,Mn=null;async function nx(e){if(Gt())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(kt.has(t))return;if(!Is(n)){kt.add(t);return}let r=rn({sessionId:e.sessionId,hostname:ar()});if(sf(r)){if(Mn){await Mn;return}Mn=(async()=>{if(kt.has(t)||!Is(n)){kt.add(t);return}if(!uc(n)){kt.add(t);return}let o=!1;try{let s=Date.now(),{gitRoot:i}=e.manifest,a=String(e.runnerPlatform),{operatorResolved:c,fields:l}=await fm(e,r,Ne("git",()=>br(i)),Ne("operator",()=>Os({gitRoot:i,installationStorePath:n,forceResend:!1,runnerPlatform:a}))),u={...l,self_config:tx(a,c.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await Wt("session_start",u,lo(e),Vt,e.manifest.collectorUrl,s,Ln(e)),o&&(c.commit(),kt.add(t))}finally{lc(n)}})().finally(()=>{Mn=null}),await Mn}}async function Hi(e,t,n){try{e.platformAgentId=await vu(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);E(`WARN: derivePlatformAgentId failed open: ${o}`)}}async function fm(e,t,n,r){let[o,s,i,a,c]=await Promise.allSettled([n,Ne("virt",()=>Va()),Ne("cloud",()=>wl(t)),Ne("host_env",()=>za(rm(e).enabled)),r]),l=xt(o,null,"gitSnapshot"),u=xt(s,"","detectVirt"),d=xt(i,null,"probeCloud"),f=xt(a,{},"hostEnv"),p=xt(c,{commit:()=>{}},"resolveOperatorForSend");return await Hi(e,e.manifest.gitRoot,l),{operatorResolved:p,fields:{identity:{host:ar(),context:t,virt:u||null,cloud:d,git:l},host_env:f,env_vars:Dl()}}}async function rx(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=rn({sessionId:e.sessionId,hostname:ar()}),o=String(e.runnerPlatform),s=Mi(e),i=Ms(e.hookInput,s),a=Ne("git",()=>br(n)),c=Vp().catch(()=>({})),l=Gt()?Promise.resolve({commit:()=>{}}):Ne("operator",()=>Os({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o})),u=fm(e,r,a,l),[d,f]=await Promise.allSettled([Ne("mcp_declared",()=>Rs(e.manifest.manifest,n,o)),a.catch(()=>null).then(K=>Ne("self_config",()=>Np(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:i,inGitRepo:e.manifest.inGitRepo,remote:K?.remote??null})))]),{operatorResolved:p,fields:g}=await u,S=xt(d,[],"mcpDeclared"),A=xt(f,ex(o),"selfConfig"),b=A.config,I=L(e.hookInput,"model");I&&(b.model=I);let P={...g,mcp:{declared:S},self_config:b,run_meta:{trigger:e.hookSource||"startup"},hook_input:jr(e.hookInput,e.manifest.manifest,{...s,launchCwd:i})},T=await c;await Wt("session_start",P,{...lo(e),...T},Vt,e.manifest.collectorUrl,t,Ln(e))&&(A.commit(),p.commit(),kt.add(e.manifest.installationId))}async function ox(e){let t=Date.now(),[,n]=await Promise.all([Hi(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?em(L(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=Qk(L(e.hookInput,"status"),L(e.hookInput,"stop_reason"),L(e.hookInput,"reason"),fn(L(e.hookInput,"error")),r==="stop"?$e(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),s=jr(e.hookInput,e.manifest.manifest,Mi(e));n&&(s.model=n),r!=="stopfailure"&&Fr(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&s.last_assistant_message===void 0&&(s.last_assistant_message=""),await Wt("session_end",{status:o,...n?{model:n}:{},hook_input:s},lo(e),Vt,e.manifest.collectorUrl,t,Ln(e))}async function sx(e){let t=Jk(e),n=Uu(e.hookInput),r=Bu(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&Fr(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let s=await om(e);await Promise.all([o?Yk(e,s):void 0,t.length===0?void 0:ix(e,s,t),n.length===0?void 0:ax(e,s,n)])}function dm(e,t,n,r){let o=r??au({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),s=vi(e,t,o,B.ComponentKind.SKILL,B.nativeKeyForSkillPath);if(s.sourcePath!==null&&Jo(s.sourcePath)?.toLowerCase()===n.toLowerCase())return s.componentReference===void 0?{}:{componentReference:s.componentReference};let i=r??Du({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),a=vi(e,t,i,B.ComponentKind.COMMAND,B.nativeKeyForCommandPath);return a.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:a.nativeKey,...a.componentReference===void 0?{}:{componentReference:a.componentReference}}}function ix(e,t,n){let r=hr(e.hookInput.tool_input);return Promise.all(n.map(o=>{let s=dm(e,t,o,r);return Li(e,t,{tool_name:"Skill",skill_name:o,...s.commandName===void 0?{}:{command_name:s.commandName},...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}function ax(e,t,n){return Promise.all(n.map(r=>{let o=Mu({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),s=vi(e,t,o,B.ComponentKind.RULE,B.nativeKeyForRulePath),i=s.nativeKey??Hu(r);return Li(e,t,{tool_name:"Rule",rule_name:i,...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}var cx=[{kind:B.ComponentKind.SKILL,nativeKeyFn:B.nativeKeyForSkillPath},{kind:B.ComponentKind.RULE,nativeKeyFn:B.nativeKeyForRulePath},{kind:B.ComponentKind.COMMAND,nativeKeyFn:B.nativeKeyForCommandPath}];function ux(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Xo(e.hookInput);if(r===null)return n.skillName===null?{}:dm(e,t,n.skillName,null);let o=im(r,t.gitRoot,t.home);for(let s of cx){let i=am(e,o,s.kind,s.nativeKeyFn);if(i.nativeKey!==null)return{...i.componentReference===void 0?{}:{componentReference:i.componentReference},...s.kind===B.ComponentKind.RULE?{ruleName:i.nativeKey}:{},...s.kind===B.ComponentKind.COMMAND?{commandName:i.nativeKey}:{}}}return{}}var lx=/mcp/i;function fx(e,t,n,r){let o=lx.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let s=o?qd(t,n):eo(r.declaredConfig,n);return s===null?{}:Object.fromEntries(Object.entries(s).filter(i=>typeof i[1]=="string").map(([i,a])=>[`mcp_${i}`,a]))}async function dx(e){let t=await om(e),n=Wu(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,s=Yo(e.hookInput),i=Yd(s,t.home),a=Ju(e.hookInput),c=Gu(e.runnerEvent),l=c===!1?Yu(e.hookInput,e.runnerEvent):null,u=fn(L(e.hookInput,"mcp_server_name")),d=u!==null||r!==null&&Or(r)?await Rs(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(()=>[]):[],{mcpServer:f,mcpTool:p}=qu(r,d.map(K=>K.name),u??""),g=Zk(r,f,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),d,u),S=g===void 0?ux(e,t,n):{},A=f===null?null:Ul(f,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),b=fx(e,s,t.home,{hasMcpIdentity:!!f||!!p,declaredConfig:A}),I=g??S.componentReference,P=S.ruleName??n.ruleName,T=S.commandName??n.commandName,O=zu(e.hookInput);await Wt("tool_invoked",{tool_name:r,skill_name:o,...P?{rule_name:P}:{},...T?{command_name:T}:{},success:c,duration_ms:a,...i?{executable:i}:{},...l?{failure_reason:l}:{},...f?{mcp_server:f}:{},...p?{mcp_tool:p}:{},...b,...I?{component_reference:I}:{},...O?{subagent_type:O}:{},...cm(e),hook_input:t.hookInput},t.envelopeFields,Vt,e.manifest.collectorUrl,t.buildStartedAtMs,Ln(e,t.home))}async function pm(e){switch(ze("w3"),e.internalEvent){case"session_start":await rx(e);return;case"session_end":await ox(e);return;case"skill_invoked":await sx(e);return;case"tool_invoked":await dx(e);return;default:return}}import{mkdirSync as px,readdirSync as mx,readFileSync as gx,statSync as mm,unlinkSync as _x,writeFileSync as hx}from"node:fs";import{homedir as fo}from"node:os";import{join as Ui}from"node:path";var Sx="turns",gm=1440*60*1e3,Ex=100,yx=new Set(["stop","stopfailure","sessionend"]);function Di(e=fo()){return Ui(ge(e),Sx)}function _m(e,t){return Ui(e,qt(t))}function Rx(e,t=Date.now()){let n;try{n=mx(e)}catch{return}let r=0;for(let o of n){if(r>=Ex)return;r+=1;try{let s=Ui(e,o);t-mm(s).mtimeMs>gm&&_x(s)}catch{}}}function Cx(e,t,n=fo()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let s=Di(n);px(s,{recursive:!0}),hx(_m(s,r),o,"utf8")}catch{}}function Ax(e,t=fo()){let n=e.trim();if(!n)return"";try{let r=_m(Di(t),n);return Date.now()-mm(r).mtimeMs>gm?"":gx(r,"utf8").trim()}catch{return""}}function hm(e,t,n,r=fo()){let o=t.trim(),s=yx.has(n.trim().toLowerCase());return s&&Rx(Di(r)),o?(Cx(e,o,r),o):s?Ax(e,r):""}async function bx(e,t,n){let r=t??await zn(nr),o=Se(r,{}),s=await bc(process.cwd(),{sessionId:ln(o)});if(ze("w2"),!s)return;let i=Vu(o,s.manifest.platform,n),a=is(e,i.runnerEvent);if(!a){E(`WARN: unknown hook event '${i.runnerEvent}'; skipping telemetry`);return}let c={hookInput:o,sessionId:i.sessionId,turnId:hm(i.sessionId,i.turnId,i.runnerEvent),runnerEvent:i.runnerEvent,runnerPlatform:i.runnerPlatform,hookSource:i.hookSource,internalEvent:a,manifest:s,platformAgentId:s.platformAgentId};await pm(c)}function kx(e,t=!1){if(M("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,s=un(r,o,void 0,n.runner);return xr(o,s)?!0:t}function Sm(e,t){let n=Zn(e),r=Se(t,{}),o=n.event??ss(r);return Ka()||ju(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}function ym(e){return ul(is(e.parsed.event,e.runnerEvent))}async function Em(e,t,n){let{parsed:r}=e,o=n??ds(r.slot);if(!o&&!ym(e)){let s=fs(r.cap),i=gl(s);if(!i){ps(s);return}o=i}try{await bx(r.event,t,r.runner)}finally{o&&Pr(o)}}async function Rm(e=process.argv.slice(2)){if(fr(e),Rl(),ze(e[0]===vn?"w0":"h0"),_l(),M("EV_AI_HOOK_JUDGE")==="1"){try{await zn(nr)}catch{}return Eo(),0}if(e[0]===Nn){try{await uo(Qt)}catch{}return 0}if(e[0]===vn){try{let n=await Qt();ze("w1");let r=Sm(e.slice(1),n);if(!r)return 0;await Em(r,n)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: detached work failed open: ${r}`)}return 0}let t;try{let n=await zn(nr);ze("h1");let r=Sm(e,n);if(!r)return 0;let{parsed:o,hookInput:s,runnerEvent:i}=r;if(t=ds(o.slot),!nl(s,i,o.runner))return 0;if(ze("h2"),kx(r))await Em(r,n,t);else{let a=t||ym(r)?void 0:fs(o.cap);if(a===void 0||pl(a)){ze("h3"),Ol();let c=await Qp(n,e);t&&c?.pid!==void 0&&fl(t,c.pid)}else ps(a)}}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: hook failed open: ${r}`)}finally{t&&Pr(t),Eo()}return 0}function po(){E("Usage: ev-ai-agent-hook <configure|install|migrate-to-plugin|update|uninstall|--version>"),E(" configure [--url <\u2026/{orgToken}/hook>]"),E(" (manifest only \u2014 pair with marketplace plugins)"),E(" install --url <\u2026/{orgToken}/hook>"),E(" [--delivery npx|binary|local] [--force]"),E(" [--no-claude] [--no-cursor] [--no-codex]"),E(" (fallback: merge hooks into .claude / .cursor / .codex configs)"),E(" (writes collector_url to shared manifest; hook commands use --runner only)"),E(" migrate-to-plugin"),E(" (strip ev-ai file hooks; keep collector manifest)"),E(" update (refresh binary pins from a local build; leaves hook configs alone)"),E(" uninstall"),E("Hook mode: --runner <platform> [--url <\u2026/hook>|--token <orgToken>] [event]"),E(" (--url/--token optional overrides; else collector_url from manifest)")}function Cm(e){return e.includes("--help")||e.includes("-h")}async function Px(e=process.argv.slice(2)){fr(e);let[t,...n]=e;if(t===Nn){try{await uo(Qt)}catch{}return 0}return t==="--version"||t==="-V"?(process.stdout.write(`${Be}
56
+ `),0):t==="configure"?Cm(n)?(po(),0):(await Wc(Nc(n)),0):t==="install"?Cm(n)?(po(),0):(await Gc(vc(n)),0):t==="migrate-to-plugin"?(await Jc(),0):t==="update"?(await Vc(),0):t==="uninstall"?(await Yc(),0):t==="help"||t==="--help"||t==="-h"?(po(),0):t===void 0?(po(),1):Rm(e)}function wx(e,t,n=xx){if(!t)return!1;try{return e===Tx(Ox(t)).href?!0:n(Ix(e))===n(t)}catch{return!1}}wx(import.meta.url,process.argv[1])&&process.env.VITEST===void 0&&Px().then(e=>{process.exit(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);E(t),process.exit(1)});export{wx as isCliEntrypoint,Px as main};