@ev-ai/agent-hook 1.3.8 → 1.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COLLECTED-DATA.md +4 -0
- package/README.md +9 -0
- package/dist/cli.mjs +45 -42
- package/dist/hook.mjs +41 -38
- package/dist/launcher-update.mjs +4 -4
- package/dist/launcher.mjs +6 -6
- package/dist/managed-hooks-snippet.cjs +70 -4
- package/dist/managed-hooks-snippet.d.ts +1 -0
- package/dist/managed-hooks-snippet.mjs +67 -3
- package/dist/plugin-hooks.mjs +12 -3
- package/package.json +3 -2
package/dist/cli.mjs
CHANGED
|
@@ -2,54 +2,57 @@
|
|
|
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(
|
|
7
|
-
`).split(/\n{2,}/).map(
|
|
8
|
-
`).map(
|
|
5
|
+
var Eg=Object.create;var Mo=Object.defineProperty;var yg=Object.getOwnPropertyDescriptor;var Rg=Object.getOwnPropertyNames;var Cg=Object.getPrototypeOf,Ag=Object.prototype.hasOwnProperty;var s=(e,t)=>Mo(e,"name",{value:t,configurable:!0}),rt=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Y=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var bg=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rg(t))!Ag.call(e,o)&&o!==n&&Mo(e,o,{get:()=>t[o],enumerable:!(r=yg(t,o))||r.enumerable});return e};var ot=(e,t,n)=>(n=e!=null?Eg(Cg(e)):{},bg(t||!e||!e.__esModule?Mo(n,"default",{value:e,enumerable:!0}):n,e));var Dr=Y(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.MCP_MISSING_LAUNCH_SERIALIZED=ne.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;ne.foldMcpName=Zu;ne.buildMcpFamilyCanonicalKey=yE;ne.launchContainsCredentials=CE;ne.serializeMcpLaunchIdentity=Qu;ne.hashMcpLaunchIdentity=In;ne.projectMcpMissingLaunchIdentity=kE;ne.projectMcpLaunchIdentity=xE;ne.maskMcpLaunchForDisplay=IE;ne.normalizeMcpToolNames=TE;var EE=rt("node:crypto");ne.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";ne.MCP_MISSING_LAUNCH_SERIALIZED=`${ne.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function qe(e){return e.toLocaleLowerCase("en-US")}s(qe,"foldCase");function Zu(e){return qe(e)}s(Zu,"foldMcpName");function yE(e){return`interface:${Zu(e)}`}s(yE,"buildMcpFamilyCanonicalKey");var qu=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),RE=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function Xt(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(Xt,"lengthPrefixed");function CE(e){return e.kind==="url"?AE(e.url):e.kind==="command"?e.arguments.some(t=>RE.test(t)):!1}s(CE,"launchContainsCredentials");function AE(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(qu.has(qe(n)))return!0;return!1}catch{let t=e.split("://",2),n=t.length===2?t[1]:e,r=n.indexOf("@"),o=n.indexOf("/");if(r>0&&(o===-1||r<o))return!0;let i=e.split("?",2)[1];return i===void 0?!1:i.split("&").some(a=>{let c=qe(a.split("=",1)[0]??"");return qu.has(c)})}}s(AE,"urlContainsCredentials");function Qu(e){if(e.kind==="url")return[ne.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",Xt(qe(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>qe(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[ne.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",Xt(qe(e.command)),String(t.length),...t.map(Xt)].join("|")}return[ne.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",Xt(e.installationRootExternalKey),Xt(e.sourcePath),Xt(e.nativeKey)].join("|")}s(Qu,"serializeMcpLaunchIdentity");function In(e){return(0,EE.createHash)("sha256").update(e).digest("hex")}s(In,"hashMcpLaunchIdentity");var bE=In(ne.MCP_MISSING_LAUNCH_SERIALIZED);function kE(){return{kind:"unknown",arguments:[],serialized:ne.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:bE}}s(kE,"projectMcpMissingLaunchIdentity");function xE(e){let t=Qu(e);return e.kind==="url"?{kind:"url",url:qe(e.url),arguments:[],serialized:t,contentHash:In(t)}:e.kind==="command"?{kind:"command",command:qe(e.command),arguments:[...e.arguments].map(n=>qe(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:In(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:In(t)}}s(xE,"projectMcpLaunchIdentity");var OE=/^(https?:\/\/)([^/?#]*@)/i;function IE(e){return e.replace(OE,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}s(IE,"maskMcpLaunchForDisplay");function TE(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n.sort((r,o)=>r<o?-1:r>o?1:0),n}s(TE,"normalizeMcpToolNames")});var $r=Y(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.PACKAGE_FIELD_MAX=void 0;Ue.npxExecBin=el;Ue.packageNameFromSpec=Fr;Ue.pinnedPackageVersionFromSpec=tl;Ue.pinnedPackageVersionFromNpx=DE;Ue.npxPackageSpecs=nl;Ue.PACKAGE_FIELD_MAX=128;var PE=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,wE=new Set(["-p","--package"]),NE=new Set(["-c","--call"]),vE=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),ME=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),LE=/^--no-/;function HE(e){return ME.has(e)||LE.test(e)}s(HE,"booleanFlag");function el(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}s(el,"npxExecBin");var UE=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function Fr(e){if(e.length===0||e.length>Ue.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return PE.test(n)?n:null}s(Fr,"packageNameFromSpec");function tl(e){let t=Fr(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return UE.test(n)?n:void 0}s(tl,"pinnedPackageVersionFromSpec");function DE(e,t){for(let n of nl(e,t)){let r=tl(n);if(r!==void 0)return r}}s(DE,"pinnedPackageVersionFromNpx");function nl(e,t){let n=el(e);if(n===null)return[];let r=[...t];if(n==="npm"){let a=r[0]?.toLowerCase();if(a!=="exec"&&a!=="x")return[];r=r.slice(1)}let o=[],i=null;for(let a=0;a<r.length;a+=1){let c=r[a]??"";if(c==="--"){i=r[a+1]??null;break}if(!c.startsWith("-")){i=c;break}let u=c.indexOf("="),f=u===-1?c:c.slice(0,u);if(NE.has(f))return[];if(wE.has(f)){let l=u===-1?r[a+1]:c.slice(u+1);l!==void 0&&l.length>0&&o.push(l),u===-1&&(a+=1);continue}if(!(u!==-1||HE(f))){if(vE.has(f)){a+=1;continue}return[]}}return o.length>0?o.every(a=>Fr(a)!==null)?o:[]:i===null||Fr(i)===null?[]:[i]}s(nl,"npxPackageSpecs")});var rl=Y(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.McpPackageEcosystem=void 0;Tt.resolveMcpPackageIdentity=qE;var FE=Dr(),Os=$r();Tt.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var $E=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,jE=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,BE=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function KE(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}s(KE,"pythonRunnerBin");var GE=new Set(["--from","--spec"]),VE=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"]),WE=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"]),zE=/^--no-/;function JE(e,t){let n=KE(e);if(n===null)return null;let r=[...t];if(n==="uv"){if(r[0]?.toLowerCase()!=="tool"||r[1]?.toLowerCase()!=="run")return null;r=r.slice(2)}else if(n==="pipx"){if(r[0]?.toLowerCase()!=="run")return null;r=r.slice(1)}let o=null,i=null;for(let a=0;a<r.length;a+=1){let c=r[a]??"";if(c==="--"){i=r[a+1]??null;break}if(!c.startsWith("-")){i=c;break}let u=c.indexOf("="),f=u===-1?c:c.slice(0,u);if(GE.has(f)){let l=u===-1?r[a+1]:c.slice(u+1);l!==void 0&&l.length>0&&(o=l),u===-1&&(a+=1);continue}if(!(u!==-1||WE.has(f)||zE.test(f))){if(VE.has(f)){a+=1;continue}return null}}return o??i}s(JE,"pythonRunnerSpec");function YE(e){if(e.length===0||e.length>Os.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!jE.test(r)||!BE.test(o)?null:{ecosystem:Tt.McpPackageEcosystem.PYPI,packageName:r,version:o}}s(YE,"pypiIdentityFromSpec");function XE(e){let t=(0,Os.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return $E.test(n)?{ecosystem:Tt.McpPackageEcosystem.NPM,packageName:t,version:n}:null}s(XE,"npmIdentityFromSpec");function qE(e){if(e?.kind!=="command"||(0,FE.launchContainsCredentials)(e))return;for(let n of(0,Os.npxPackageSpecs)(e.command,e.arguments)){let r=XE(n);if(r!==null)return r}let t=JE(e.command,e.arguments);if(t!==null)return YE(t)??void 0}s(qE,"resolveMcpPackageIdentity")});var ul=Y(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.EMPTY_NPM_PUBLISHER=void 0;Ze.isNpmRegistryPublisher=QE;Ze.displayPublisherName=ey;Ze.classifyMcpProvenance=uy;var il=Dr(),Is=$r();Ze.EMPTY_NPM_PUBLISHER="npm:";var ol="npm:",ZE=/^[A-Za-z0-9._-]+$/;function QE(e){return e.startsWith(ol)&&e!==Ze.EMPTY_NPM_PUBLISHER&&ZE.test(e.slice(ol.length))}s(QE,"isNpmRegistryPublisher");function ey(e){if(!(e==null||e===""||e===Ze.EMPTY_NPM_PUBLISHER))return e}s(ey,"displayPublisherName");function sl(e){let t=e.split(".").map(Number);return t.length!==4||t.some(n=>!Number.isInteger(n)||n<0||n>255)?!1:t[0]===0||t[0]===10||t[0]===127||t[0]===169&&t[1]===254||t[0]===172&&(t[1]??0)>=16&&(t[1]??0)<=31||t[0]===192&&t[1]===168}s(sl,"privateIpv4");function ty(e){let t=/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(e);if(t?.[1])return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(e);if(!n)return;let r=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16);return`${r>>8&255}.${r&255}.${o>>8&255}.${o&255}`}s(ty,"ipv4MappedAddress");function Ts(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}s(Ts,"normalizedHost");function ny(e){let t=Ts(e),n=ty(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||sl(t)||n!==void 0&&sl(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}s(ny,"privateHostname");function ry(e){let t=Ts(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}s(ry,"publisherHost");function oy(e){let t=Ts(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}s(oy,"publicOrigin");function al(e){let t={kind:"url",url:e};if((0,il.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||ny(n.hostname))return{origin:"UNKNOWN"};let r=ry(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:oy(n)}}catch{return{origin:"UNKNOWN"}}}s(al,"classifyUrl");var cl="mcp-remote";function sy(e,t){if(e===cl)return t.find(n=>/^https?:\/\//i.test(n))}s(sy,"remoteUrlChild");function iy(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}s(iy,"thirdPartyPackage");function ay(e,t,n){let r=sy(e,t);return r!==void 0?al(r):e===cl?{origin:"UNKNOWN"}:iy(e,n)}s(ay,"classifyRegistryPackage");function cy(e){let t=e.replaceAll("\\","/");return t.startsWith("~/")||t.startsWith("/")||/^[A-Za-z]:\//.test(t)?!1:t.startsWith("./")||t.startsWith("../")||t==="scripts"||t.startsWith("scripts/")}s(cy,"isRepoRelativeCommand");function uy(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,il.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return al(t.url);let r=(0,Is.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,Is.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let i=ay(o,t.arguments,e.publisherName),a=typeof e.packageName=="string"?(0,Is.packageNameFromSpec)(e.packageName):null;return a!==null&&a===o&&i.packageName!==void 0?{...i,packageName:a,packageKey:a}:i}return cy(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}s(uy,"classifyMcpProvenance")});var fl=Y(jr=>{"use strict";Object.defineProperty(jr,"__esModule",{value:!0});jr.mcpServerToolSegmentForms=ll;jr.mcpServerNameMatchesToolSegment=ly;function ll(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}s(ll,"mcpServerToolSegmentForms");function ly(e,t){let n=t.toLowerCase();return ll(e).some(r=>r.toLowerCase()===n)}s(ly,"mcpServerNameMatchesToolSegment")});var dl=Y(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.parseFrontmatterField=Pe.parseFrontmatterDescription=Pe.usableCatalogText=void 0;var fy=/^(?:>|\|)[-+]?$/,dy=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,py=s(e=>{let t=e?.trim()??"";if(!(t.length===0||fy.test(t)))return t},"usableCatalogText");Pe.usableCatalogText=py;var my=s(e=>(0,Pe.parseFrontmatterField)(e,"description"),"parseFrontmatterDescription");Pe.parseFrontmatterDescription=my;var gy=s((e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return hy(n[1],t)},"parseFrontmatterField");Pe.parseFrontmatterField=gy;var _y=s(e=>e.replace(/^["']|["']$/g,""),"stripYamlQuotes");function hy(e,t){let n=e.split(`
|
|
6
|
+
`),r=`${t}:`,o=n.findIndex(m=>m===r||m.startsWith(`${r} `)||m.startsWith(`${r} `));if(o<0)return;let i=(n[o]??"").slice(r.length).trim(),a=dy.exec(i);if(!a){let m=_y(i).trim();return(0,Pe.usableCatalogText)(m)}let c=[];for(let m=o+1;m<n.length;m+=1){let _=n[m]??"";if(_.trim()===""){c.push("");continue}if(_.length===_.trimStart().length)break;c.push(_)}let u=c.reduce((m,_)=>_.trim()===""?m:Math.min(m,_.length-_.trimStart().length),Number.POSITIVE_INFINITY),f=[],l=a[1]?.trim();l&&f.push(l);for(let m of c)f.push(m.trim()===""?"":m.slice(u));for(;f.length>0&&f[f.length-1]==="";)f.pop();let p=i.startsWith(">")?f.join(`
|
|
7
|
+
`).split(/\n{2,}/).map(m=>m.split(`
|
|
8
|
+
`).map(_=>_.trim()).filter(Boolean).join(" ")).filter(m=>m.length>0).join(`
|
|
9
9
|
|
|
10
|
-
`):
|
|
11
|
-
`).trimEnd();return(0,
|
|
12
|
-
`),n=!1;return t.map(o=>n?
|
|
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}
|
|
10
|
+
`):f.join(`
|
|
11
|
+
`).trimEnd();return(0,Pe.usableCatalogText)(p)}s(hy,"parseYamlFrontmatterScalar")});var gl=Y(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=re.COMPONENT_INSPECTION_TEXT_MAX_BYTES=re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=void 0;re.fitSnapshotInspectionTextBudget=Sy;re.capComponentTextBytes=ml;re.prepareComponentInspectionText=Ey;re.redactComponentSource=Ps;re.componentSourceContainsRedactableSecret=xy;re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";re.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;re.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function Sy(e){let t=0;return e.map(n=>{let r=n,o=r.skill?.inspectionText;if(o===void 0)return n;let i=Buffer.byteLength(o,"utf8");return t+i<=re.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES?(t+=i,n):{...n,skill:{...r.skill,inspectionText:void 0}}})}s(Sy,"fitSnapshotInspectionTextBudget");function ml(e,t){if(e==null||e.length===0)return;let n=Buffer.from(e,"utf8");if(n.byteLength<=t)return e;let r=new TextDecoder("utf-8",{fatal:!0});for(let o=t;o>0;o-=1)try{return r.decode(n.subarray(0,o))}catch{}}s(ml,"capComponentTextBytes");function Ey(e){if(!(e==null||e.length===0))return ml(Ps(e),re.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}s(Ey,"prepareComponentInspectionText");var yy=[/\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],Ry=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,Cy=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,Ay=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,by=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,pl=/-----END [A-Z0-9 ]*PRIVATE KEY-----/;function ky(e){let t=e.replace(Cy,(n,r)=>`${r}${re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(Ay,(n,r)=>`${r}${re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(Ry,(n,r)=>`${r}${re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of yy)t=t.replace(n,re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}s(ky,"redactLine");function Ps(e){if(e.length===0)return e;let t=e.split(`
|
|
12
|
+
`),n=!1;return t.map(o=>n?pl.test(o)?(n=!1,o):o.trim().length===0?o:re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:by.test(o)&&!pl.test(o)?(n=!0,o):ky(o)).join(`
|
|
13
|
+
`)}s(Ps,"redactComponentSource");function xy(e){return Ps(e)!==e}s(xy,"componentSourceContainsRedactableSecret")});var St=Y(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.redactComponentSource=R.prepareComponentInspectionText=R.fitSnapshotInspectionTextBudget=R.componentSourceContainsRedactableSecret=R.capComponentTextBytes=R.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=R.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=R.COMPONENT_INSPECTION_TEXT_MAX_BYTES=R.usableCatalogText=R.parseFrontmatterField=R.parseFrontmatterDescription=R.mcpServerToolSegmentForms=R.mcpServerNameMatchesToolSegment=R.isNpmRegistryPublisher=R.EMPTY_NPM_PUBLISHER=R.displayPublisherName=R.classifyMcpProvenance=R.resolveMcpPackageIdentity=R.McpPackageEcosystem=R.pinnedPackageVersionFromSpec=R.pinnedPackageVersionFromNpx=R.packageNameFromSpec=R.npxPackageSpecs=R.npxExecBin=R.PACKAGE_FIELD_MAX=R.serializeMcpLaunchIdentity=R.projectMcpMissingLaunchIdentity=R.projectMcpLaunchIdentity=R.normalizeMcpToolNames=R.MCP_MISSING_LAUNCH_SERIALIZED=R.MCP_LAUNCH_IDENTITY_ALGORITHM=R.maskMcpLaunchForDisplay=R.launchContainsCredentials=R.hashMcpLaunchIdentity=R.foldMcpName=R.buildMcpFamilyCanonicalKey=R.ComponentKind=void 0;R.userConfigRootFromPath=Hy;R.installationRootExternalKey=Uy;R.normalizeRepositoryRelativePath=_l;R.nativeKeyForSkillPath=Dy;R.nativeKeyForRulePath=Fy;R.nativeKeyForCommandPath=$y;R.serializeComponentIdentity=Sl;R.buildComponentReference=By;R.validateComponentReference=Ky;var Oy=rt("node:crypto"),Iy=rt("node:path"),Ty="cmp1_",Py=/^cmp1_[A-Za-z0-9_-]{43}$/,wy=["/skills/","/skills-cursor/"],Ny=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,vy=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,My=[".cursor",".claude",".codex"],Ly={".claude.json":".claude",".agents":".codex"};R.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function Hy(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>My.includes(o));return n||(t.map(o=>Ly[o]).find(o=>o!==void 0)??"unknown")}s(Hy,"userConfigRootFromPath");function Uy(e,t){return`runtime-install:${e}/${t}`}s(Uy,"installationRootExternalKey");function Br(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}s(Br,"requireValue");function _l(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=Iy.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return Br(n,"sourcePath")}s(_l,"normalizeRepositoryRelativePath");function Dy(e){let t=e.replaceAll("\\","/");for(let n of wy){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}s(Dy,"nativeKeyForSkillPath");function hl(e,t,n){let r=e.replaceAll("\\","/"),i=t.exec(r)?.[1];if(!i||i.split("/").includes(".."))return null;let a=i.replace(n,"");return a.length>0?a:null}s(hl,"nativeKeyUnderLayoutRoot");function Fy(e){return hl(e,Ny,/\.(mdc|md|rules)$/i)}s(Fy,"nativeKeyForRulePath");function $y(e){return hl(e,vy,/\.(md|mdc|toml)$/i)}s($y,"nativeKeyForCommandPath");function jy(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(jy,"field");function Sl(e){let t=[Br(e.installationRootExternalKey,"installationRootExternalKey"),Br(e.installableKind,"installableKind"),_l(e.sourcePath),Br(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(jy).join("|")}`,"utf8")}s(Sl,"serializeComponentIdentity");function By(e){let t=(0,Oy.createHash)("sha256").update(Sl(e)).digest("base64url");return`${Ty}${t}`}s(By,"buildComponentReference");function Ky(e){return Py.test(e)}s(Ky,"validateComponentReference");var we=Dr();Object.defineProperty(R,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:s(function(){return we.buildMcpFamilyCanonicalKey},"get")});Object.defineProperty(R,"foldMcpName",{enumerable:!0,get:s(function(){return we.foldMcpName},"get")});Object.defineProperty(R,"hashMcpLaunchIdentity",{enumerable:!0,get:s(function(){return we.hashMcpLaunchIdentity},"get")});Object.defineProperty(R,"launchContainsCredentials",{enumerable:!0,get:s(function(){return we.launchContainsCredentials},"get")});Object.defineProperty(R,"maskMcpLaunchForDisplay",{enumerable:!0,get:s(function(){return we.maskMcpLaunchForDisplay},"get")});Object.defineProperty(R,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:s(function(){return we.MCP_LAUNCH_IDENTITY_ALGORITHM},"get")});Object.defineProperty(R,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:s(function(){return we.MCP_MISSING_LAUNCH_SERIALIZED},"get")});Object.defineProperty(R,"normalizeMcpToolNames",{enumerable:!0,get:s(function(){return we.normalizeMcpToolNames},"get")});Object.defineProperty(R,"projectMcpLaunchIdentity",{enumerable:!0,get:s(function(){return we.projectMcpLaunchIdentity},"get")});Object.defineProperty(R,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:s(function(){return we.projectMcpMissingLaunchIdentity},"get")});Object.defineProperty(R,"serializeMcpLaunchIdentity",{enumerable:!0,get:s(function(){return we.serializeMcpLaunchIdentity},"get")});var qt=$r();Object.defineProperty(R,"PACKAGE_FIELD_MAX",{enumerable:!0,get:s(function(){return qt.PACKAGE_FIELD_MAX},"get")});Object.defineProperty(R,"npxExecBin",{enumerable:!0,get:s(function(){return qt.npxExecBin},"get")});Object.defineProperty(R,"npxPackageSpecs",{enumerable:!0,get:s(function(){return qt.npxPackageSpecs},"get")});Object.defineProperty(R,"packageNameFromSpec",{enumerable:!0,get:s(function(){return qt.packageNameFromSpec},"get")});Object.defineProperty(R,"pinnedPackageVersionFromNpx",{enumerable:!0,get:s(function(){return qt.pinnedPackageVersionFromNpx},"get")});Object.defineProperty(R,"pinnedPackageVersionFromSpec",{enumerable:!0,get:s(function(){return qt.pinnedPackageVersionFromSpec},"get")});var El=rl();Object.defineProperty(R,"McpPackageEcosystem",{enumerable:!0,get:s(function(){return El.McpPackageEcosystem},"get")});Object.defineProperty(R,"resolveMcpPackageIdentity",{enumerable:!0,get:s(function(){return El.resolveMcpPackageIdentity},"get")});var Kr=ul();Object.defineProperty(R,"classifyMcpProvenance",{enumerable:!0,get:s(function(){return Kr.classifyMcpProvenance},"get")});Object.defineProperty(R,"displayPublisherName",{enumerable:!0,get:s(function(){return Kr.displayPublisherName},"get")});Object.defineProperty(R,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:s(function(){return Kr.EMPTY_NPM_PUBLISHER},"get")});Object.defineProperty(R,"isNpmRegistryPublisher",{enumerable:!0,get:s(function(){return Kr.isNpmRegistryPublisher},"get")});var yl=fl();Object.defineProperty(R,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:s(function(){return yl.mcpServerNameMatchesToolSegment},"get")});Object.defineProperty(R,"mcpServerToolSegmentForms",{enumerable:!0,get:s(function(){return yl.mcpServerToolSegmentForms},"get")});var ws=dl();Object.defineProperty(R,"parseFrontmatterDescription",{enumerable:!0,get:s(function(){return ws.parseFrontmatterDescription},"get")});Object.defineProperty(R,"parseFrontmatterField",{enumerable:!0,get:s(function(){return ws.parseFrontmatterField},"get")});Object.defineProperty(R,"usableCatalogText",{enumerable:!0,get:s(function(){return ws.usableCatalogText},"get")});var ht=gl();Object.defineProperty(R,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return ht.COMPONENT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(R,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:s(function(){return ht.COMPONENT_SOURCE_REDACTION_PLACEHOLDER},"get")});Object.defineProperty(R,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return ht.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(R,"capComponentTextBytes",{enumerable:!0,get:s(function(){return ht.capComponentTextBytes},"get")});Object.defineProperty(R,"componentSourceContainsRedactableSecret",{enumerable:!0,get:s(function(){return ht.componentSourceContainsRedactableSecret},"get")});Object.defineProperty(R,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:s(function(){return ht.fitSnapshotInspectionTextBudget},"get")});Object.defineProperty(R,"prepareComponentInspectionText",{enumerable:!0,get:s(function(){return ht.prepareComponentInspectionText},"get")});Object.defineProperty(R,"redactComponentSource",{enumerable:!0,get:s(function(){return ht.redactComponentSource},"get")})});var uo=Y(Oe=>{"use strict";Oe.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Oe.find=(e,t)=>e.nodes.find(n=>n.type===t);Oe.exceedsLimit=(e,t,n=1,r)=>r===!1||!Oe.isInteger(e)||!Oe.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Oe.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)};Oe.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Oe.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;Oe.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Oe.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Oe.flatten=(...e)=>{let t=[],n=s(r=>{for(let o=0;o<r.length;o++){let i=r[o];if(Array.isArray(i)){n(i);continue}i!==void 0&&t.push(i)}return t},"flat");return n(e),t}});var lo=Y((Vv,ed)=>{"use strict";var Qf=uo();ed.exports=(e,t={})=>{let n=s((r,o={})=>{let i=t.escapeInvalid&&Qf.isInvalidBrace(o),a=r.invalid===!0&&t.escapeInvalid===!0,c="";if(r.value)return(i||a)&&Qf.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let u of r.nodes)c+=n(u);return c},"stringify");return n(e)}});var nd=Y((zv,td)=>{"use strict";td.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var fd=Y((Jv,ld)=>{"use strict";var rd=nd(),wt=s((e,t,n)=>{if(rd(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(rd(t)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let o=String(r.relaxZeros),i=String(r.shorthand),a=String(r.capture),c=String(r.wrap),u=e+":"+t+"="+o+i+a+c;if(wt.cache.hasOwnProperty(u))return wt.cache[u].result;let f=Math.min(e,t),l=Math.max(e,t);if(Math.abs(f-l)===1){let h=e+"|"+t;return r.capture?`(${h})`:r.wrap===!1?h:`(?:${h})`}let d=ud(e)||ud(t),p={min:e,max:t,a:f,b:l},m=[],_=[];if(d&&(p.isPadded=d,p.maxLen=String(p.max).length),f<0){let h=l<0?Math.abs(l):1;_=od(h,Math.abs(f),p,r),f=p.a=0}return l>=0&&(m=od(f,l,p,r)),p.negatives=_,p.positives=m,p.result=bA(_,m,r),r.capture===!0?p.result=`(${p.result})`:r.wrap!==!1&&m.length+_.length>1&&(p.result=`(?:${p.result})`),wt.cache[u]=p,p.result},"toRegexRange");function bA(e,t,n){let r=fi(e,t,"-",!1,n)||[],o=fi(t,e,"",!1,n)||[],i=fi(e,t,"-?",!0,n)||[];return r.concat(i).concat(o).join("|")}s(bA,"collatePatterns");function kA(e,t){let n=1,r=1,o=id(e,n),i=new Set([t]);for(;e<=o&&o<=t;)i.add(o),n+=1,o=id(e,n);for(o=ad(t+1,r)-1;e<o&&o<=t;)i.add(o),r+=1,o=ad(t+1,r)-1;return i=[...i],i.sort(IA),i}s(kA,"splitToRanges");function xA(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=OA(e,t),o=r.length,i="",a=0;for(let c=0;c<o;c++){let[u,f]=r[c];u===f?i+=u:u!=="0"||f!=="9"?i+=TA(u,f,n):a++}return a&&(i+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:i,count:[a],digits:o}}s(xA,"rangeToPattern");function od(e,t,n,r){let o=kA(e,t),i=[],a=e,c;for(let u=0;u<o.length;u++){let f=o[u],l=xA(String(a),String(f),r),d="";if(!n.isPadded&&c&&c.pattern===l.pattern){c.count.length>1&&c.count.pop(),c.count.push(l.count[0]),c.string=c.pattern+cd(c.count),a=f+1;continue}n.isPadded&&(d=PA(f,n,r)),l.string=d+l.pattern+cd(l.count),i.push(l),a=f+1,c=l}return i}s(od,"splitToPatterns");function fi(e,t,n,r,o){let i=[];for(let a of e){let{string:c}=a;!r&&!sd(t,"string",c)&&i.push(n+c),r&&sd(t,"string",c)&&i.push(n+c)}return i}s(fi,"filterPatterns");function OA(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}s(OA,"zip");function IA(e,t){return e>t?1:t>e?-1:0}s(IA,"compare");function sd(e,t,n){return e.some(r=>r[t]===n)}s(sd,"contains");function id(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}s(id,"countNines");function ad(e,t){return e-e%Math.pow(10,t)}s(ad,"countZeros");function cd(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}s(cd,"toQuantifier");function TA(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}s(TA,"toCharacterClass");function ud(e){return/^-?(0+)\d/.test(e)}s(ud,"hasPadding");function PA(e,t,n){if(!t.isPadded)return e;let r=Math.abs(t.maxLen-String(e).length),o=n.relaxZeros!==!1;switch(r){case 0:return"";case 1:return o?"0?":"0";case 2:return o?"0{0,2}":"00";default:return o?`0{0,${r}}`:`0{${r}}`}}s(PA,"padZeros");wt.cache={};wt.clearCache=()=>wt.cache={};ld.exports=wt});var mi=Y((Xv,Sd)=>{"use strict";var wA=rt("util"),pd=fd(),dd=s(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"isObject"),NA=s(e=>t=>e===!0?Number(t):String(t),"transform"),di=s(e=>typeof e=="number"||typeof e=="string"&&e!=="","isValidValue"),Un=s(e=>Number.isInteger(+e),"isNumber"),pi=s(e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},"zeros"),vA=s((e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,"stringify"),MA=s((e,t,n)=>{if(t>0){let r=e[0]==="-"?"-":"";r&&(e=e.slice(1)),e=r+e.padStart(r?t-1:t,"0")}return n===!1?String(e):e},"pad"),po=s((e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},"toMaxLen"),LA=s((e,t,n)=>{e.negatives.sort((c,u)=>c<u?-1:c>u?1:0),e.positives.sort((c,u)=>c<u?-1:c>u?1:0);let r=t.capture?"":"?:",o="",i="",a;return e.positives.length&&(o=e.positives.map(c=>po(String(c),n)).join("|")),e.negatives.length&&(i=`-(${r}${e.negatives.map(c=>po(String(c),n)).join("|")})`),o&&i?a=`${o}|${i}`:a=o||i,t.wrap?`(${r}${a})`:a},"toSequence"),md=s((e,t,n,r)=>{if(n)return pd(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let i=String.fromCharCode(t);return`[${o}-${i}]`},"toRange"),gd=s((e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return pd(e,t,n)},"toRegex"),_d=s((...e)=>new RangeError("Invalid range arguments: "+wA.inspect(...e)),"rangeError"),hd=s((e,t,n)=>{if(n.strictRanges===!0)throw _d([e,t]);return[]},"invalidRange"),HA=s((e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},"invalidStep"),UA=s((e,t,n=1,r={})=>{let o=Number(e),i=Number(t);if(!Number.isInteger(o)||!Number.isInteger(i)){if(r.strictRanges===!0)throw _d([e,t]);return[]}o===0&&(o=0),i===0&&(i=0);let a=o>i,c=String(e),u=String(t),f=String(n);n=Math.max(Math.abs(n),1);let l=pi(c)||pi(u)||pi(f),d=l?Math.max(c.length,u.length,f.length):0,p=l===!1&&vA(e,t,r)===!1,m=r.transform||NA(p);if(r.toRegex&&n===1)return md(po(e,d),po(t,d),!0,r);let _={negatives:[],positives:[]},h=s(T=>_[T<0?"negatives":"positives"].push(Math.abs(T)),"push"),b=[],k=0;for(;a?o>=i:o<=i;)r.toRegex===!0&&n>1?h(o):b.push(MA(m(o,k),d,p)),o=a?o-n:o+n,k++;return r.toRegex===!0?n>1?LA(_,r,d):gd(b,null,{wrap:!1,...r}):b},"fillNumbers"),DA=s((e,t,n=1,r={})=>{if(!Un(e)&&e.length>1||!Un(t)&&t.length>1)return hd(e,t,r);let o=r.transform||(p=>String.fromCharCode(p)),i=`${e}`.charCodeAt(0),a=`${t}`.charCodeAt(0),c=i>a,u=Math.min(i,a),f=Math.max(i,a);if(r.toRegex&&n===1)return md(u,f,!1,r);let l=[],d=0;for(;c?i>=a:i<=a;)l.push(o(i,d)),i=c?i-n:i+n,d++;return r.toRegex===!0?gd(l,null,{wrap:!1,options:r}):l},"fillLetters"),fo=s((e,t,n,r={})=>{if(t==null&&di(e))return[e];if(!di(e)||!di(t))return hd(e,t,r);if(typeof n=="function")return fo(e,t,1,{transform:n});if(dd(n))return fo(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,Un(n)?Un(e)&&Un(t)?UA(e,t,n,o):DA(e,t,Math.max(Math.abs(n),1),o):n!=null&&!dd(n)?HA(n,o):fo(e,t,1,n)},"fill");Sd.exports=fo});var Rd=Y((Zv,yd)=>{"use strict";var FA=mi(),Ed=uo(),$A=s((e,t={})=>{let n=s((r,o={})=>{let i=Ed.isInvalidBrace(o),a=r.invalid===!0&&t.escapeInvalid===!0,c=i===!0||a===!0,u=t.escapeInvalid===!0?"\\":"",f="";if(r.isOpen===!0)return u+r.value;if(r.isClose===!0)return console.log("node.isClose",u,r.value),u+r.value;if(r.type==="open")return c?u+r.value:"(";if(r.type==="close")return c?u+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":c?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let l=Ed.reduce(r.nodes),d=FA(...l,{...t,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return l.length>1&&d.length>1?`(${d})`:d}if(r.nodes)for(let l of r.nodes)f+=n(l,r);return f},"walk");return n(e)},"compile");yd.exports=$A});var bd=Y((eM,Ad)=>{"use strict";var jA=mi(),Cd=lo(),tn=uo(),Nt=s((e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?tn.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let i of o)r.push(Nt(i,t,n));else for(let i of t)n===!0&&typeof i=="string"&&(i=`{${i}}`),r.push(Array.isArray(i)?Nt(o,i,n):o+i);return tn.flatten(r)},"append"),BA=s((e,t={})=>{let n=t.rangeLimit===void 0?1e3:t.rangeLimit,r=s((o,i={})=>{o.queue=[];let a=i,c=i.queue;for(;a.type!=="brace"&&a.type!=="root"&&a.parent;)a=a.parent,c=a.queue;if(o.invalid||o.dollar){c.push(Nt(c.pop(),Cd(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){c.push(Nt(c.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let d=tn.reduce(o.nodes);if(tn.exceedsLimit(...d,t.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let p=jA(...d,t);p.length===0&&(p=Cd(o,t)),c.push(Nt(c.pop(),p)),o.nodes=[];return}let u=tn.encloseBrace(o),f=o.queue,l=o;for(;l.type!=="brace"&&l.type!=="root"&&l.parent;)l=l.parent,f=l.queue;for(let d=0;d<o.nodes.length;d++){let p=o.nodes[d];if(p.type==="comma"&&o.type==="brace"){d===1&&f.push(""),f.push("");continue}if(p.type==="close"){c.push(Nt(c.pop(),f,u));continue}if(p.value&&p.type!=="open"){f.push(Nt(f.pop(),p.value));continue}p.nodes&&r(p,o)}return f},"walk");return tn.flatten(r(e))},"expand");Ad.exports=BA});var xd=Y((nM,kd)=>{"use strict";kd.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 wd=Y((rM,Pd)=>{"use strict";var KA=lo(),{MAX_LENGTH:Od,CHAR_BACKSLASH:gi,CHAR_BACKTICK:GA,CHAR_COMMA:VA,CHAR_DOT:WA,CHAR_LEFT_PARENTHESES:zA,CHAR_RIGHT_PARENTHESES:JA,CHAR_LEFT_CURLY_BRACE:YA,CHAR_RIGHT_CURLY_BRACE:XA,CHAR_LEFT_SQUARE_BRACKET:Id,CHAR_RIGHT_SQUARE_BRACKET:Td,CHAR_DOUBLE_QUOTE:qA,CHAR_SINGLE_QUOTE:ZA,CHAR_NO_BREAK_SPACE:QA,CHAR_ZERO_WIDTH_NOBREAK_SPACE:eb}=xd(),tb=s((e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Od,n.maxLength):Od;if(e.length>r)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${r})`);let o={type:"root",input:e,nodes:[]},i=[o],a=o,c=o,u=0,f=e.length,l=0,d=0,p,m=s(()=>e[l++],"advance"),_=s(h=>{if(h.type==="text"&&c.type==="dot"&&(c.type="text"),c&&c.type==="text"&&h.type==="text"){c.value+=h.value;return}return a.nodes.push(h),h.parent=a,h.prev=c,c=h,h},"push");for(_({type:"bos"});l<f;)if(a=i[i.length-1],p=m(),!(p===eb||p===QA)){if(p===gi){_({type:"text",value:(t.keepEscaping?p:"")+m()});continue}if(p===Td){_({type:"text",value:"\\"+p});continue}if(p===Id){u++;let h;for(;l<f&&(h=m());){if(p+=h,h===Id){u++;continue}if(h===gi){p+=m();continue}if(h===Td&&(u--,u===0))break}_({type:"text",value:p});continue}if(p===zA){a=_({type:"paren",nodes:[]}),i.push(a),_({type:"text",value:p});continue}if(p===JA){if(a.type!=="paren"){_({type:"text",value:p});continue}a=i.pop(),_({type:"text",value:p}),a=i[i.length-1];continue}if(p===qA||p===ZA||p===GA){let h=p,b;for(t.keepQuotes!==!0&&(p="");l<f&&(b=m());){if(b===gi){p+=b+m();continue}if(b===h){t.keepQuotes===!0&&(p+=b);break}p+=b}_({type:"text",value:p});continue}if(p===YA){d++;let b={type:"brace",open:!0,close:!1,dollar:c.value&&c.value.slice(-1)==="$"||a.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};a=_(b),i.push(a),_({type:"open",value:p});continue}if(p===XA){if(a.type!=="brace"){_({type:"text",value:p});continue}let h="close";a=i.pop(),a.close=!0,_({type:h,value:p}),d--,a=i[i.length-1];continue}if(p===VA&&d>0){if(a.ranges>0){a.ranges=0;let h=a.nodes.shift();a.nodes=[h,{type:"text",value:KA(a)}]}_({type:"comma",value:p}),a.commas++;continue}if(p===WA&&d>0&&a.commas===0){let h=a.nodes;if(d===0||h.length===0){_({type:"text",value:p});continue}if(c.type==="dot"){if(a.range=[],c.value+=p,c.type="range",a.nodes.length!==3&&a.nodes.length!==5){a.invalid=!0,a.ranges=0,c.type="text";continue}a.ranges++,a.args=[];continue}if(c.type==="range"){h.pop();let b=h[h.length-1];b.value+=c.value+p,c=b,a.ranges--;continue}_({type:"dot",value:p});continue}_({type:"text",value:p})}do if(a=i.pop(),a.type!=="root"){a.nodes.forEach(k=>{k.nodes||(k.type==="open"&&(k.isOpen=!0),k.type==="close"&&(k.isClose=!0),k.nodes||(k.type="text"),k.invalid=!0)});let h=i[i.length-1],b=h.nodes.indexOf(a);h.nodes.splice(b,1,...a.nodes)}while(i.length>0);return _({type:"eos"}),o},"parse");Pd.exports=tb});var Md=Y((sM,vd)=>{"use strict";var Nd=lo(),nb=Rd(),rb=bd(),ob=wd(),Ce=s((e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=Ce.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(Ce.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n},"braces");Ce.parse=(e,t={})=>ob(e,t);Ce.stringify=(e,t={})=>Nd(typeof e=="string"?Ce.parse(e,t):e,t);Ce.compile=(e,t={})=>(typeof e=="string"&&(e=Ce.parse(e,t)),nb(e,t));Ce.expand=(e,t={})=>{typeof e=="string"&&(e=Ce.parse(e,t));let n=rb(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};Ce.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?Ce.compile(e,t):Ce.expand(e,t);vd.exports=Ce});var Dn=Y((aM,Fd)=>{"use strict";var sb=rt("path"),$e="\\\\/",Ld=`[^${$e}]`,ib=0,tt="\\.",ab="\\+",cb="\\?",mo="\\/",ub="(?=.)",Hd="[^/]",_i=`(?:${mo}|$)`,Ud=`(?:^|${mo})`,hi=`${tt}{1,2}${_i}`,lb=`(?!${tt})`,fb=`(?!${Ud}${hi})`,db=`(?!${tt}{0,1}${_i})`,pb=`(?!${hi})`,mb=`[^.${mo}]`,gb=`${Hd}*?`,Dd={DOT_LITERAL:tt,PLUS_LITERAL:ab,QMARK_LITERAL:cb,SLASH_LITERAL:mo,ONE_CHAR:ub,QMARK:Hd,END_ANCHOR:_i,DOTS_SLASH:hi,NO_DOT:lb,NO_DOTS:fb,NO_DOT_SLASH:db,NO_DOTS_SLASH:pb,QMARK_NO_DOT:mb,STAR:gb,START_ANCHOR:Ud},_b={...Dd,SLASH_LITERAL:`[${$e}]`,QMARK:Ld,STAR:`${Ld}*?`,DOTS_SLASH:`${tt}{1,2}(?:[${$e}]|$)`,NO_DOT:`(?!${tt})`,NO_DOTS:`(?!(?:^|[${$e}])${tt}{1,2}(?:[${$e}]|$))`,NO_DOT_SLASH:`(?!${tt}{0,1}(?:[${$e}]|$))`,NO_DOTS_SLASH:`(?!${tt}{1,2}(?:[${$e}]|$))`,QMARK_NO_DOT:`[^.${$e}]`,START_ANCHOR:`(?:^|[${$e}])`,END_ANCHOR:`(?:[${$e}]|$)`},hb={__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"};Fd.exports={DEFAULT_MAX_EXTGLOB_RECURSION:ib,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:hb,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:sb.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?_b:Dd}}});var Fn=Y(_e=>{"use strict";var Sb=rt("path"),Eb=process.platform==="win32",{REGEX_BACKSLASH:yb,REGEX_REMOVE_BACKSLASH:Rb,REGEX_SPECIAL_CHARS:Cb,REGEX_SPECIAL_CHARS_GLOBAL:Ab}=Dn();_e.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);_e.hasRegexChars=e=>Cb.test(e);_e.isRegexChar=e=>e.length===1&&_e.hasRegexChars(e);_e.escapeRegex=e=>e.replace(Ab,"\\$1");_e.toPosixSlashes=e=>e.replace(yb,"/");_e.removeBackslashes=e=>e.replace(Rb,t=>t==="\\"?"":t);_e.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};_e.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:Eb===!0||Sb.sep==="\\";_e.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?_e.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};_e.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};_e.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",i=`${r}(?:${e})${o}`;return t.negated===!0&&(i=`(?:^(?!${i}).*$)`),i}});var zd=Y((uM,Wd)=>{"use strict";var $d=Fn(),{CHAR_ASTERISK:Si,CHAR_AT:bb,CHAR_BACKWARD_SLASH:$n,CHAR_COMMA:kb,CHAR_DOT:Ei,CHAR_EXCLAMATION_MARK:yi,CHAR_FORWARD_SLASH:Vd,CHAR_LEFT_CURLY_BRACE:Ri,CHAR_LEFT_PARENTHESES:Ci,CHAR_LEFT_SQUARE_BRACKET:xb,CHAR_PLUS:Ob,CHAR_QUESTION_MARK:jd,CHAR_RIGHT_CURLY_BRACE:Ib,CHAR_RIGHT_PARENTHESES:Bd,CHAR_RIGHT_SQUARE_BRACKET:Tb}=Dn(),Kd=s(e=>e===Vd||e===$n,"isPathSeparator"),Gd=s(e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},"depth"),Pb=s((e,t)=>{let n=t||{},r=e.length-1,o=n.parts===!0||n.scanToEnd===!0,i=[],a=[],c=[],u=e,f=-1,l=0,d=0,p=!1,m=!1,_=!1,h=!1,b=!1,k=!1,T=!1,N=!1,w=!1,I=!1,$=0,v,x,P={value:"",depth:0,isGlob:!1},U=s(()=>f>=r,"eos"),g=s(()=>u.charCodeAt(f+1),"peek"),O=s(()=>(v=x,u.charCodeAt(++f)),"advance");for(;f<r;){x=O();let de;if(x===$n){T=P.backslashes=!0,x=O(),x===Ri&&(k=!0);continue}if(k===!0||x===Ri){for($++;U()!==!0&&(x=O());){if(x===$n){T=P.backslashes=!0,O();continue}if(x===Ri){$++;continue}if(k!==!0&&x===Ei&&(x=O())===Ei){if(p=P.isBrace=!0,_=P.isGlob=!0,I=!0,o===!0)continue;break}if(k!==!0&&x===kb){if(p=P.isBrace=!0,_=P.isGlob=!0,I=!0,o===!0)continue;break}if(x===Ib&&($--,$===0)){k=!1,p=P.isBrace=!0,I=!0;break}}if(o===!0)continue;break}if(x===Vd){if(i.push(f),a.push(P),P={value:"",depth:0,isGlob:!1},I===!0)continue;if(v===Ei&&f===l+1){l+=2;continue}d=f+1;continue}if(n.noext!==!0&&(x===Ob||x===bb||x===Si||x===jd||x===yi)===!0&&g()===Ci){if(_=P.isGlob=!0,h=P.isExtglob=!0,I=!0,x===yi&&f===l&&(w=!0),o===!0){for(;U()!==!0&&(x=O());){if(x===$n){T=P.backslashes=!0,x=O();continue}if(x===Bd){_=P.isGlob=!0,I=!0;break}}continue}break}if(x===Si){if(v===Si&&(b=P.isGlobstar=!0),_=P.isGlob=!0,I=!0,o===!0)continue;break}if(x===jd){if(_=P.isGlob=!0,I=!0,o===!0)continue;break}if(x===xb){for(;U()!==!0&&(de=O());){if(de===$n){T=P.backslashes=!0,O();continue}if(de===Tb){m=P.isBracket=!0,_=P.isGlob=!0,I=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&x===yi&&f===l){N=P.negated=!0,l++;continue}if(n.noparen!==!0&&x===Ci){if(_=P.isGlob=!0,o===!0){for(;U()!==!0&&(x=O());){if(x===Ci){T=P.backslashes=!0,x=O();continue}if(x===Bd){I=!0;break}}continue}break}if(_===!0){if(I=!0,o===!0)continue;break}}n.noext===!0&&(h=!1,_=!1);let j=u,Se="",S="";l>0&&(Se=u.slice(0,l),u=u.slice(l),d-=l),j&&_===!0&&d>0?(j=u.slice(0,d),S=u.slice(d)):_===!0?(j="",S=u):j=u,j&&j!==""&&j!=="/"&&j!==u&&Kd(j.charCodeAt(j.length-1))&&(j=j.slice(0,-1)),n.unescape===!0&&(S&&(S=$d.removeBackslashes(S)),j&&T===!0&&(j=$d.removeBackslashes(j)));let E={prefix:Se,input:e,start:l,base:j,glob:S,isBrace:p,isBracket:m,isGlob:_,isExtglob:h,isGlobstar:b,negated:N,negatedExtglob:w};if(n.tokens===!0&&(E.maxDepth=0,Kd(x)||a.push(P),E.tokens=a),n.parts===!0||n.tokens===!0){let de;for(let B=0;B<i.length;B++){let Ne=de?de+1:l,ve=i[B],Ee=e.slice(Ne,ve);n.tokens&&(B===0&&l!==0?(a[B].isPrefix=!0,a[B].value=Se):a[B].value=Ee,Gd(a[B]),E.maxDepth+=a[B].depth),(B!==0||Ee!=="")&&c.push(Ee),de=ve}if(de&&de+1<e.length){let B=e.slice(de+1);c.push(B),n.tokens&&(a[a.length-1].value=B,Gd(a[a.length-1]),E.maxDepth+=a[a.length-1].depth)}E.slashes=i,E.parts=c}return E},"scan");Wd.exports=Pb});var Zd=Y((fM,qd)=>{"use strict";var jn=Dn(),fe=Fn(),{MAX_LENGTH:go,POSIX_REGEX_SOURCE:wb,REGEX_NON_SPECIAL_CHARS:Nb,REGEX_SPECIAL_CHARS_BACKREF:vb,REPLACEMENTS:Jd}=jn,Mb=s((e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n)}catch{return e.map(o=>fe.escapeRegex(o)).join("..")}return n},"expandRange"),nn=s((e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,"syntaxError"),Yd=s(e=>{let t=[],n=0,r=0,o=0,i="",a=!1;for(let c of e){if(a===!0){i+=c,a=!1;continue}if(c==="\\"){i+=c,a=!0;continue}if(c==='"'){o=o===1?0:1,i+=c;continue}if(o===0){if(c==="[")n++;else if(c==="]"&&n>0)n--;else if(n===0){if(c==="(")r++;else if(c===")"&&r>0)r--;else if(c==="|"&&r===0){t.push(i),i="";continue}}}i+=c}return t.push(i),t},"splitTopLevel"),Lb=s(e=>{let t=!1;for(let n of e){if(t===!0){t=!1;continue}if(n==="\\"){t=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},"isPlainBranch"),Xd=s(e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(Lb(t))return t.replace(/\\(.)/g,"$1")},"normalizeSimpleBranch"),Hb=s(e=>{let t=e.map(Xd).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let o=t[n],i=t[r],a=o[0];if(!(!a||o!==a.repeat(o.length)||i!==a.repeat(i.length))&&(o===i||o.startsWith(i)||i.startsWith(o)))return!0}return!1},"hasRepeatedCharPrefixOverlap"),Ai=s((e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,r=0,o=0,i=!1;for(let a=1;a<e.length;a++){let c=e[a];if(i===!0){i=!1;continue}if(c==="\\"){i=!0;continue}if(c==='"'){o=o===1?0:1;continue}if(o!==1){if(c==="["){n++;continue}if(c==="]"&&n>0){n--;continue}if(!(n>0)){if(c==="("){r++;continue}if(c===")"&&(r--,r===0))return t===!0&&a!==e.length-1?void 0:{type:e[0],body:e.slice(2,a),end:a}}}}},"parseRepeatedExtglob"),Ub=s(e=>{let t=0,n=[];for(;t<e.length;){let o=Ai(e.slice(t),!1);if(!o||o.type!=="*")return;let i=Yd(o.body).map(c=>c.trim());if(i.length!==1)return;let a=Xd(i[0]);if(!a||a.length!==1)return;n.push(a),t+=o.end+1}return n.length<1?void 0:`${n.length===1?fe.escapeRegex(n[0]):`[${n.map(o=>fe.escapeRegex(o)).join("")}]`}*`},"getStarExtglobSequenceOutput"),Db=s(e=>{let t=0,n=e.trim(),r=Ai(n);for(;r;)t++,n=r.body.trim(),r=Ai(n);return t},"repeatedExtglobRecursion"),Fb=s((e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:jn.DEFAULT_MAX_EXTGLOB_RECURSION,r=Yd(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||Hb(r)))return{risky:!0};for(let o of r){let i=Ub(o);if(i)return{risky:!0,safeOutput:i};if(Db(o)>n)return{risky:!0}}return{risky:!1}},"analyzeRepeatedExtglob"),bi=s((e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=Jd[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(go,n.maxLength):go,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let i={type:"bos",value:"",output:n.prepend||""},a=[i],c=n.capture?"":"?:",u=fe.isWindows(t),f=jn.globChars(u),l=jn.extglobChars(f),{DOT_LITERAL:d,PLUS_LITERAL:p,SLASH_LITERAL:m,ONE_CHAR:_,DOTS_SLASH:h,NO_DOT:b,NO_DOT_SLASH:k,NO_DOTS_SLASH:T,QMARK:N,QMARK_NO_DOT:w,STAR:I,START_ANCHOR:$}=f,v=s(A=>`(${c}(?:(?!${$}${A.dot?h:d}).)*?)`,"globstar"),x=n.dot?"":b,P=n.dot?N:w,U=n.bash===!0?v(n):I;n.capture&&(U=`(${U})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let g={input:e,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:a};e=fe.removePrefix(e,g),o=e.length;let O=[],j=[],Se=[],S=i,E,de=s(()=>g.index===o-1,"eos"),B=g.peek=(A=1)=>e[g.index+A],Ne=g.advance=()=>e[++g.index]||"",ve=s(()=>e.slice(g.index+1),"remaining"),Ee=s((A="",q=0)=>{g.consumed+=A,g.index+=q},"consume"),Zn=s(A=>{g.output+=A.output!=null?A.output:A.value,Ee(A.value)},"append"),hg=s(()=>{let A=1;for(;B()==="!"&&(B(2)!=="("||B(3)==="?");)Ne(),g.start++,A++;return A%2===0?!1:(g.negated=!0,g.start++,!0)},"negate"),Qn=s(A=>{g[A]++,Se.push(A)},"increment"),nt=s(A=>{g[A]--,Se.pop()},"decrement"),H=s(A=>{if(S.type==="globstar"){let q=g.braces>0&&(A.type==="comma"||A.type==="brace"),C=A.extglob===!0||O.length&&(A.type==="pipe"||A.type==="paren");A.type!=="slash"&&A.type!=="paren"&&!q&&!C&&(g.output=g.output.slice(0,-S.output.length),S.type="star",S.value="*",S.output=U,g.output+=S.output)}if(O.length&&A.type!=="paren"&&(O[O.length-1].inner+=A.value),(A.value||A.output)&&Zn(A),S&&S.type==="text"&&A.type==="text"){S.value+=A.value,S.output=(S.output||"")+A.value;return}A.prev=S,a.push(A),S=A},"push"),er=s((A,q)=>{let C={...l[q],conditions:1,inner:""};C.prev=S,C.parens=g.parens,C.output=g.output,C.startIndex=g.index,C.tokensIndex=a.length;let M=(n.capture?"(":"")+C.open;Qn("parens"),H({type:A,value:q,output:g.output?"":_}),H({type:"paren",extglob:!0,value:Ne(),output:M}),O.push(C)},"extglobOpen"),Sg=s(A=>{let q=e.slice(A.startIndex,g.index+1),C=e.slice(A.startIndex+2,g.index),M=Fb(C,n);if((A.type==="plus"||A.type==="star")&&M.risky){let W=M.safeOutput?(A.output?"":_)+(n.capture?`(${M.safeOutput})`:M.safeOutput):void 0,Me=a[A.tokensIndex];Me.type="text",Me.value=q,Me.output=W||fe.escapeRegex(q);for(let Le=A.tokensIndex+1;Le<a.length;Le++)a[Le].value="",a[Le].output="",delete a[Le].suffix;g.output=A.output+Me.output,g.backtrack=!0,H({type:"paren",extglob:!0,value:E,output:""}),nt("parens");return}let J=A.close+(n.capture?")":""),ae;if(A.type==="negate"){let W=U;if(A.inner&&A.inner.length>1&&A.inner.includes("/")&&(W=v(n)),(W!==U||de()||/^\)+$/.test(ve()))&&(J=A.close=`)$))${W}`),A.inner.includes("*")&&(ae=ve())&&/^\.[^\\/.]+$/.test(ae)){let Me=bi(ae,{...t,fastpaths:!1}).output;J=A.close=`)${Me})${W})`}A.prev.type==="bos"&&(g.negatedExtglob=!0)}H({type:"paren",extglob:!0,value:E,output:J}),nt("parens")},"extglobClose");if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let A=!1,q=e.replace(vb,(C,M,J,ae,W,Me)=>ae==="\\"?(A=!0,C):ae==="?"?M?M+ae+(W?N.repeat(W.length):""):Me===0?P+(W?N.repeat(W.length):""):N.repeat(J.length):ae==="."?d.repeat(J.length):ae==="*"?M?M+ae+(W?U:""):U:M?C:`\\${C}`);return A===!0&&(n.unescape===!0?q=q.replace(/\\/g,""):q=q.replace(/\\+/g,C=>C.length%2===0?"\\\\":C?"\\":"")),q===e&&n.contains===!0?(g.output=e,g):(g.output=fe.wrapOutput(q,g,t),g)}for(;!de();){if(E=Ne(),E==="\0")continue;if(E==="\\"){let C=B();if(C==="/"&&n.bash!==!0||C==="."||C===";")continue;if(!C){E+="\\",H({type:"text",value:E});continue}let M=/^\\+/.exec(ve()),J=0;if(M&&M[0].length>2&&(J=M[0].length,g.index+=J,J%2!==0&&(E+="\\")),n.unescape===!0?E=Ne():E+=Ne(),g.brackets===0){H({type:"text",value:E});continue}}if(g.brackets>0&&(E!=="]"||S.value==="["||S.value==="[^")){if(n.posix!==!1&&E===":"){let C=S.value.slice(1);if(C.includes("[")&&(S.posix=!0,C.includes(":"))){let M=S.value.lastIndexOf("["),J=S.value.slice(0,M),ae=S.value.slice(M+2),W=wb[ae];if(W){S.value=J+W,g.backtrack=!0,Ne(),!i.output&&a.indexOf(S)===1&&(i.output=_);continue}}}(E==="["&&B()!==":"||E==="-"&&B()==="]")&&(E=`\\${E}`),E==="]"&&(S.value==="["||S.value==="[^")&&(E=`\\${E}`),n.posix===!0&&E==="!"&&S.value==="["&&(E="^"),S.value+=E,Zn({value:E});continue}if(g.quotes===1&&E!=='"'){E=fe.escapeRegex(E),S.value+=E,Zn({value:E});continue}if(E==='"'){g.quotes=g.quotes===1?0:1,n.keepQuotes===!0&&H({type:"text",value:E});continue}if(E==="("){Qn("parens"),H({type:"paren",value:E});continue}if(E===")"){if(g.parens===0&&n.strictBrackets===!0)throw new SyntaxError(nn("opening","("));let C=O[O.length-1];if(C&&g.parens===C.parens+1){Sg(O.pop());continue}H({type:"paren",value:E,output:g.parens?")":"\\)"}),nt("parens");continue}if(E==="["){if(n.nobracket===!0||!ve().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(nn("closing","]"));E=`\\${E}`}else Qn("brackets");H({type:"bracket",value:E});continue}if(E==="]"){if(n.nobracket===!0||S&&S.type==="bracket"&&S.value.length===1){H({type:"text",value:E,output:`\\${E}`});continue}if(g.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(nn("opening","["));H({type:"text",value:E,output:`\\${E}`});continue}nt("brackets");let C=S.value.slice(1);if(S.posix!==!0&&C[0]==="^"&&!C.includes("/")&&(E=`/${E}`),S.value+=E,Zn({value:E}),n.literalBrackets===!1||fe.hasRegexChars(C))continue;let M=fe.escapeRegex(S.value);if(g.output=g.output.slice(0,-S.value.length),n.literalBrackets===!0){g.output+=M,S.value=M;continue}S.value=`(${c}${M}|${S.value})`,g.output+=S.value;continue}if(E==="{"&&n.nobrace!==!0){Qn("braces");let C={type:"brace",value:E,output:"(",outputIndex:g.output.length,tokensIndex:g.tokens.length};j.push(C),H(C);continue}if(E==="}"){let C=j[j.length-1];if(n.nobrace===!0||!C){H({type:"text",value:E,output:E});continue}let M=")";if(C.dots===!0){let J=a.slice(),ae=[];for(let W=J.length-1;W>=0&&(a.pop(),J[W].type!=="brace");W--)J[W].type!=="dots"&&ae.unshift(J[W].value);M=Mb(ae,n),g.backtrack=!0}if(C.comma!==!0&&C.dots!==!0){let J=g.output.slice(0,C.outputIndex),ae=g.tokens.slice(C.tokensIndex);C.value=C.output="\\{",E=M="\\}",g.output=J;for(let W of ae)g.output+=W.output||W.value}H({type:"brace",value:E,output:M}),nt("braces"),j.pop();continue}if(E==="|"){O.length>0&&O[O.length-1].conditions++,H({type:"text",value:E});continue}if(E===","){let C=E,M=j[j.length-1];M&&Se[Se.length-1]==="braces"&&(M.comma=!0,C="|"),H({type:"comma",value:E,output:C});continue}if(E==="/"){if(S.type==="dot"&&g.index===g.start+1){g.start=g.index+1,g.consumed="",g.output="",a.pop(),S=i;continue}H({type:"slash",value:E,output:m});continue}if(E==="."){if(g.braces>0&&S.type==="dot"){S.value==="."&&(S.output=d);let C=j[j.length-1];S.type="dots",S.output+=E,S.value+=E,C.dots=!0;continue}if(g.braces+g.parens===0&&S.type!=="bos"&&S.type!=="slash"){H({type:"text",value:E,output:d});continue}H({type:"dot",value:E,output:d});continue}if(E==="?"){if(!(S&&S.value==="(")&&n.noextglob!==!0&&B()==="("&&B(2)!=="?"){er("qmark",E);continue}if(S&&S.type==="paren"){let M=B(),J=E;if(M==="<"&&!fe.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(S.value==="("&&!/[!=<:]/.test(M)||M==="<"&&!/<([!=]|\w+>)/.test(ve()))&&(J=`\\${E}`),H({type:"text",value:E,output:J});continue}if(n.dot!==!0&&(S.type==="slash"||S.type==="bos")){H({type:"qmark",value:E,output:w});continue}H({type:"qmark",value:E,output:N});continue}if(E==="!"){if(n.noextglob!==!0&&B()==="("&&(B(2)!=="?"||!/[!=<:]/.test(B(3)))){er("negate",E);continue}if(n.nonegate!==!0&&g.index===0){hg();continue}}if(E==="+"){if(n.noextglob!==!0&&B()==="("&&B(2)!=="?"){er("plus",E);continue}if(S&&S.value==="("||n.regex===!1){H({type:"plus",value:E,output:p});continue}if(S&&(S.type==="bracket"||S.type==="paren"||S.type==="brace")||g.parens>0){H({type:"plus",value:E});continue}H({type:"plus",value:p});continue}if(E==="@"){if(n.noextglob!==!0&&B()==="("&&B(2)!=="?"){H({type:"at",extglob:!0,value:E,output:""});continue}H({type:"text",value:E});continue}if(E!=="*"){(E==="$"||E==="^")&&(E=`\\${E}`);let C=Nb.exec(ve());C&&(E+=C[0],g.index+=C[0].length),H({type:"text",value:E});continue}if(S&&(S.type==="globstar"||S.star===!0)){S.type="star",S.star=!0,S.value+=E,S.output=U,g.backtrack=!0,g.globstar=!0,Ee(E);continue}let A=ve();if(n.noextglob!==!0&&/^\([^?]/.test(A)){er("star",E);continue}if(S.type==="star"){if(n.noglobstar===!0){Ee(E);continue}let C=S.prev,M=C.prev,J=C.type==="slash"||C.type==="bos",ae=M&&(M.type==="star"||M.type==="globstar");if(n.bash===!0&&(!J||A[0]&&A[0]!=="/")){H({type:"star",value:E,output:""});continue}let W=g.braces>0&&(C.type==="comma"||C.type==="brace"),Me=O.length&&(C.type==="pipe"||C.type==="paren");if(!J&&C.type!=="paren"&&!W&&!Me){H({type:"star",value:E,output:""});continue}for(;A.slice(0,3)==="/**";){let Le=e[g.index+4];if(Le&&Le!=="/")break;A=A.slice(3),Ee("/**",3)}if(C.type==="bos"&&de()){S.type="globstar",S.value+=E,S.output=v(n),g.output=S.output,g.globstar=!0,Ee(E);continue}if(C.type==="slash"&&C.prev.type!=="bos"&&!ae&&de()){g.output=g.output.slice(0,-(C.output+S.output).length),C.output=`(?:${C.output}`,S.type="globstar",S.output=v(n)+(n.strictSlashes?")":"|$)"),S.value+=E,g.globstar=!0,g.output+=C.output+S.output,Ee(E);continue}if(C.type==="slash"&&C.prev.type!=="bos"&&A[0]==="/"){let Le=A[1]!==void 0?"|$":"";g.output=g.output.slice(0,-(C.output+S.output).length),C.output=`(?:${C.output}`,S.type="globstar",S.output=`${v(n)}${m}|${m}${Le})`,S.value+=E,g.output+=C.output+S.output,g.globstar=!0,Ee(E+Ne()),H({type:"slash",value:"/",output:""});continue}if(C.type==="bos"&&A[0]==="/"){S.type="globstar",S.value+=E,S.output=`(?:^|${m}|${v(n)}${m})`,g.output=S.output,g.globstar=!0,Ee(E+Ne()),H({type:"slash",value:"/",output:""});continue}g.output=g.output.slice(0,-S.output.length),S.type="globstar",S.output=v(n),S.value+=E,g.output+=S.output,g.globstar=!0,Ee(E);continue}let q={type:"star",value:E,output:U};if(n.bash===!0){q.output=".*?",(S.type==="bos"||S.type==="slash")&&(q.output=x+q.output),H(q);continue}if(S&&(S.type==="bracket"||S.type==="paren")&&n.regex===!0){q.output=E,H(q);continue}(g.index===g.start||S.type==="slash"||S.type==="dot")&&(S.type==="dot"?(g.output+=k,S.output+=k):n.dot===!0?(g.output+=T,S.output+=T):(g.output+=x,S.output+=x),B()!=="*"&&(g.output+=_,S.output+=_)),H(q)}for(;g.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(nn("closing","]"));g.output=fe.escapeLast(g.output,"["),nt("brackets")}for(;g.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(nn("closing",")"));g.output=fe.escapeLast(g.output,"("),nt("parens")}for(;g.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(nn("closing","}"));g.output=fe.escapeLast(g.output,"{"),nt("braces")}if(n.strictSlashes!==!0&&(S.type==="star"||S.type==="bracket")&&H({type:"maybe_slash",value:"",output:`${m}?`}),g.backtrack===!0){g.output="";for(let A of g.tokens)g.output+=A.output!=null?A.output:A.value,A.suffix&&(g.output+=A.suffix)}return g},"parse");bi.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(go,n.maxLength):go,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=Jd[e]||e;let i=fe.isWindows(t),{DOT_LITERAL:a,SLASH_LITERAL:c,ONE_CHAR:u,DOTS_SLASH:f,NO_DOT:l,NO_DOTS:d,NO_DOTS_SLASH:p,STAR:m,START_ANCHOR:_}=jn.globChars(i),h=n.dot?d:l,b=n.dot?p:l,k=n.capture?"":"?:",T={negated:!1,prefix:""},N=n.bash===!0?".*?":m;n.capture&&(N=`(${N})`);let w=s(x=>x.noglobstar===!0?N:`(${k}(?:(?!${_}${x.dot?f:a}).)*?)`,"globstar"),I=s(x=>{switch(x){case"*":return`${h}${u}${N}`;case".*":return`${a}${u}${N}`;case"*.*":return`${h}${N}${a}${u}${N}`;case"*/*":return`${h}${N}${c}${u}${b}${N}`;case"**":return h+w(n);case"**/*":return`(?:${h}${w(n)}${c})?${b}${u}${N}`;case"**/*.*":return`(?:${h}${w(n)}${c})?${b}${N}${a}${u}${N}`;case"**/.*":return`(?:${h}${w(n)}${c})?${a}${u}${N}`;default:{let P=/^(.*?)\.(\w+)$/.exec(x);if(!P)return;let U=I(P[1]);return U?U+a+P[2]:void 0}}},"create"),$=fe.removePrefix(e,T),v=I($);return v&&n.strictSlashes!==!0&&(v+=`${c}?`),v};qd.exports=bi});var ep=Y((pM,Qd)=>{"use strict";var $b=rt("path"),jb=zd(),ki=Zd(),xi=Fn(),Bb=Dn(),Kb=s(e=>e&&typeof e=="object"&&!Array.isArray(e),"isObject"),oe=s((e,t,n=!1)=>{if(Array.isArray(e)){let l=e.map(p=>oe(p,t,n));return s(p=>{for(let m of l){let _=m(p);if(_)return _}return!1},"arrayMatcher")}let r=Kb(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=t||{},i=xi.isWindows(t),a=r?oe.compileRe(e,t):oe.makeRe(e,t,!1,!0),c=a.state;delete a.state;let u=s(()=>!1,"isIgnored");if(o.ignore){let l={...t,ignore:null,onMatch:null,onResult:null};u=oe(o.ignore,l,n)}let f=s((l,d=!1)=>{let{isMatch:p,match:m,output:_}=oe.test(l,a,t,{glob:e,posix:i}),h={glob:e,state:c,regex:a,posix:i,input:l,output:_,match:m,isMatch:p};return typeof o.onResult=="function"&&o.onResult(h),p===!1?(h.isMatch=!1,d?h:!1):u(l)?(typeof o.onIgnore=="function"&&o.onIgnore(h),h.isMatch=!1,d?h:!1):(typeof o.onMatch=="function"&&o.onMatch(h),d?h:!0)},"matcher");return n&&(f.state=c),f},"picomatch");oe.test=(e,t,n,{glob:r,posix:o}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let i=n||{},a=i.format||(o?xi.toPosixSlashes:null),c=e===r,u=c&&a?a(e):e;return c===!1&&(u=a?a(e):e,c=u===r),(c===!1||i.capture===!0)&&(i.matchBase===!0||i.basename===!0?c=oe.matchBase(e,t,n,o):c=t.exec(u)),{isMatch:!!c,match:c,output:u}};oe.matchBase=(e,t,n,r=xi.isWindows(n))=>(t instanceof RegExp?t:oe.makeRe(t,n)).test($b.basename(e));oe.isMatch=(e,t,n)=>oe(t,n)(e);oe.parse=(e,t)=>Array.isArray(e)?e.map(n=>oe.parse(n,t)):ki(e,{...t,fastpaths:!1});oe.scan=(e,t)=>jb(e,t);oe.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let o=t||{},i=o.contains?"":"^",a=o.contains?"":"$",c=`${i}(?:${e.output})${a}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let u=oe.toRegex(c,t);return r===!0&&(u.state=e),u};oe.makeRe=(e,t={},n=!1,r=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let o={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(o.output=ki.fastpaths(e,t)),o.output||(o=ki(e,t)),oe.compileRe(o,t,n,r)};oe.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(n){if(t&&t.debug===!0)throw n;return/$^/}};oe.constants=Bb;Qd.exports=oe});var np=Y((gM,tp)=>{"use strict";tp.exports=ep()});var cp=Y((_M,ap)=>{"use strict";var op=rt("util"),sp=Md(),je=np(),Oi=Fn(),rp=s(e=>e===""||e==="./","isEmptyString"),ip=s(e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},"hasBraces"),X=s((e,t,n)=>{t=[].concat(t),e=[].concat(e);let r=new Set,o=new Set,i=new Set,a=0,c=s(l=>{i.add(l.output),n&&n.onResult&&n.onResult(l)},"onResult");for(let l=0;l<t.length;l++){let d=je(String(t[l]),{...n,onResult:c},!0),p=d.state.negated||d.state.negatedExtglob;p&&a++;for(let m of e){let _=d(m,!0);(p?!_.isMatch:_.isMatch)&&(p?r.add(_.output):(r.delete(_.output),o.add(_.output)))}}let f=(a===t.length?[...i]:[...o]).filter(l=>!r.has(l));if(n&&f.length===0){if(n.failglob===!0)throw new Error(`No matches found for "${t.join(", ")}"`);if(n.nonull===!0||n.nullglob===!0)return n.unescape?t.map(l=>l.replace(/\\/g,"")):t}return f},"micromatch");X.match=X;X.matcher=(e,t)=>je(e,t);X.isMatch=(e,t,n)=>je(t,n)(e);X.any=X.isMatch;X.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],i=s(c=>{n.onResult&&n.onResult(c),o.push(c.output)},"onResult"),a=new Set(X(e,t,{...n,onResult:i}));for(let c of o)a.has(c)||r.add(c);return[...r]};X.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${op.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>X.contains(e,r,n));if(typeof t=="string"){if(rp(e)||rp(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return X.isMatch(e,t,{...n,contains:!0})};X.matchKeys=(e,t,n)=>{if(!Oi.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=X(Object.keys(e),t,n),o={};for(let i of r)o[i]=e[i];return o};X.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=je(String(o),n);if(r.some(a=>i(a)))return!0}return!1};X.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=je(String(o),n);if(!r.every(a=>i(a)))return!1}return!0};X.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${op.inspect(e)}"`);return[].concat(t).every(r=>je(r,n)(e))};X.capture=(e,t,n)=>{let r=Oi.isWindows(n),i=je.makeRe(String(e),{...n,capture:!0}).exec(r?Oi.toPosixSlashes(t):t);if(i)return i.slice(1).map(a=>a===void 0?"":a)};X.makeRe=(...e)=>je.makeRe(...e);X.scan=(...e)=>je.scan(...e);X.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of sp(String(r),t))n.push(je.parse(o,t));return n};X.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!ip(e)?[e]:sp(e,t)};X.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return X.braces(e,{...t,expand:!0})};X.hasBraces=ip;ap.exports=X});import{realpathSync as fI}from"node:fs";import{resolve as dI}from"node:path";import{fileURLToPath as pI,pathToFileURL as mI}from"node:url";import{createHash as Vg}from"node:crypto";import{homedir as Wg}from"node:os";import{dirname as zI,join as zg,parse as JI,resolve as YI}from"node:path";var da="EV_AI_LAUNCHER_VERSION";var pa="EV_AI_HOOK_SOURCE",ma="EV_AI_HOOK_FALLBACK_REASON",ga="EV_AI_LAUNCHER_SCOPE",Lo="EV_AI_LAUNCHER_READY_FD";var _a="--defer-user-spec",tr="--cap",mn="--slot";var ha=Buffer.from([1]);var yI=1024*1024,RI=4*1024*1024,CI=64*1024,AI=64*1024,bI=64*1024;var Ho=4096,kI=4*1024*1024;import{join as Aa}from"node:path";import{open as Sa,mkdir as kg,readFile as xg,readdir as Og,rename as Ig,stat as Tg,rmdir as Pg,unlink as wg,utimes as Ng}from"node:fs/promises";var nr=new WeakMap;function ya(e){if(e&&typeof e=="object"&&"code"in e)return e}s(ya,"asNodeError");function Ft(e){return ya(e)?.code==="ENOENT"}s(Ft,"isNotFound");function gn(e){return ya(e)?.code==="EEXIST"}s(gn,"isAlreadyExists");async function Ra(e,t){try{return await e.readdir(t)}catch(n){if(Ft(n))return[];throw n}}s(Ra,"readdirOrEmpty");function Ca(){return{async open(e,t){let n=await Sa(e,t),r={path:e};return nr.set(r,n),r},async write(e,t){let n=Ea(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await Ea(e).sync()},async close(e){let t=nr.get(e);nr.delete(e),t&&await t.close()},rename:Ig,async readdir(e){return Og(e)},readFile:xg,async stat(e){let t=await Tg(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:s(()=>t.isDirectory(),"isDirectory")}},async mkdir(e,t){await kg(e,t)},unlink:wg,rmdir:Pg,utimes:Ng,async fsyncDir(e){if(process.platform==="win32")return;let t=await Sa(e,"r");try{await t.sync()}finally{await t.close()}}}}s(Ca,"productionFs");function Ea(e){let t=nr.get(e);if(!t)throw new Error("closed");return t}s(Ea,"requireHandle");var ba=4,ka=10;function rr(e=process.platform){return e==="win32"?ba:ka}s(rr,"defaultMaxConcurrentHooks");var or=6e4,_n=2e3,xa="slots",Uo=64;function Oa(e){return Aa(e,".ev-ai","agent-hook",xa)}s(Oa,"slotDirUnder");function sr(e,t){return Aa(e,`slot-${t}`)}s(sr,"slotPath");function ir(e,t){return`${e}
|
|
15
15
|
${t}
|
|
16
|
-
`}function
|
|
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
|
|
19
|
-
|
|
20
|
-
`)}catch(s){let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
`)
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
`}s(ir,"slotRecord");function Do(e){let t=e===void 0?null:/^(\d+):(\d+)$/.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&Number.isSafeInteger(r)?{index:n,acquiredAtMs:r}:void 0}s(Do,"parseSlotRef");function Ia(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}s(Ia,"isPidAlive");var vg=/^(\d+)\n(\d+)\n$/;function Mg(e){let t=vg.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&n>0&&Number.isSafeInteger(r)?{pid:n,acquiredAtMs:r}:void 0}s(Mg,"parseSlotRecord");function Ta(e,t,n){let r=Mg(e);if(!r)return Math.abs(n-t)<_n;let o=n-r.acquiredAtMs;return o<-_n||o>=or?!1:Ia(r.pid)}s(Ta,"isSlotRecordHeld");import{createHash as Lg,randomBytes as Hg}from"node:crypto";import{existsSync as ar,mkdirSync as Ug,readdirSync as Dg,readFileSync as Fg,renameSync as Pa,statSync as Ma,unlinkSync as wa,writeFileSync as $g}from"node:fs";import{homedir as La}from"node:os";import{basename as jg,dirname as Na,isAbsolute as Bg,join as Ha,relative as Ua,resolve as Ge,sep as Kg}from"node:path";function y(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
|
|
17
|
+
`)}s(y,"logStderr");function hn(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}s(hn,"stripRemoteCredentials");function Sn(e){return Lg("sha256").update(e).digest("hex").slice(0,32)}s(Sn,"sha32");function ue(e,t){Ug(Na(e),{recursive:!0});let n=Ha(Na(e),`.${jg(e)}.${process.pid}.${Hg(4).toString("hex")}.tmp`);try{$g(n,t,"utf8");try{Pa(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){wa(e),Pa(n,e);return}throw r}}catch(r){try{wa(n)}catch{}throw r}}s(ue,"writeFileAtomic");function cr(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}s(cr,"timestampUtc");var Da;function $o(){(Da?.stdout??process.stdout).write('{"continue":true}')}s($o,"emitStdoutOk");var Rt=new Set(["on","1","true"]),ur=new Set(["off","0","false"]);function D(e){let t=process.env[e];return t===void 0||t===""?void 0:t}s(D,"readEnv");async function En(){return new Promise(e=>{let t="";if(process.stdin.isTTY){e("");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",n=>{t+=n}),process.stdin.on("end",()=>{e(t)}),process.stdin.on("error",()=>{e(t)}),process.stdin.resume()})}s(En,"readStdinUntilEnd");async function lr(e){let t=Da?.stdin??process.stdin;return new Promise(n=>{let r="",o=!1,i=s(c=>{o||(o=!0,clearTimeout(a),n(c||"{}"))},"finish"),a=setTimeout(()=>{i(r)},e);if(t.isTTY){i("{}");return}t.setEncoding("utf8"),t.on("data",c=>{r+=c}),t.on("end",()=>{i(r)}),t.on("error",()=>{i(r)}),t.resume()})}s(lr,"readStdinWithTimeout");async function Ie(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:i}=await import("node:util"),a=i(o);try{let{stdout:c}=await a(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:c.trim()}}catch(c){let u=c,f=typeof u.code=="number"?u.code:typeof u.status=="number"?u.status:void 0;return{ok:!1,code:f,spawnFailed:f===void 0}}}s(Ie,"execFileResult");async function se(e,t,n=3e3,r={}){let o=await Ie(e,t,n,r);return o.ok?o.stdout:""}s(se,"execFileText");function Fo(e,t){let n=Ge(e),r=Ge(t),o=Ua(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${Kg}`)||Bg(o)?!1:Ge(r,o)===n}s(Fo,"isPathInside");function Fa(e,t,n=La()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return Ge(e);let o=Ge(r),i=Ge(e);if(Fo(i,o))return i;let a=t.CURSOR_PLUGIN_ROOT?.trim();return Fo(i,Ge(n,".cursor"))||a!==void 0&&a.length>0&&Fo(i,Ge(a))?o:i}s(Fa,"cursorHookLaunchCwd");async function jo(e=process.cwd(),t=process.env,n=La()){let r=Fa(e,t,n),o=r!==Ge(e)&&ar(r)?r:e,i=await Ie("git",["rev-parse","--show-toplevel"],2e3,{cwd:o});if(i.ok&&i.stdout)return{root:i.stdout,inGitRepo:!0};if(D("EV_AI_HOOK_DEBUG")){let c=i.ok?"empty stdout":i.spawnFailed?"spawn failed":`exit ${String(i.code??"unknown")}`;y(`DEBUG: git rev-parse --show-toplevel failed (${c}) cwd=${e}`)}let a=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||D("CURSOR_PROJECT_DIR")||D("CLAUDE_PROJECT_DIR");if(a&&ar(a)){let c=await Ie("git",["rev-parse","--show-toplevel"],2e3,{cwd:a});return c.ok&&c.stdout?{root:c.stdout,inGitRepo:!0}:{root:a,inGitRepo:!1}}return{root:e,inGitRepo:!1}}s(jo,"resolveGitWorkspace");async function Ve(e=process.cwd()){return(await jo(e)).root}s(Ve,"findGitRoot");function Te(e,t){try{return JSON.parse(e)}catch{return t}}s(Te,"parseJsonSafe");var va=new Map;function $t(e){return e.charCodeAt(0)===65279?e.slice(1):e}s($t,"stripUtf8Bom");function Gg(e){let t;try{t=Fg(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse($t(t))}}catch{return{ok:!1,reason:"parse"}}}s(Gg,"parseJsonFile");function $a(e){let t=va.get(e);if(t!==void 0)return t;let n=Gg(e);return va.set(e,n),n}s($a,"loadJsonFileStatus");function ja(e){return $a(e)}s(ja,"readJsonFileStatus");function Q(e,t){let n=$a(e);return n.ok?n.value:t}s(Q,"readJsonFileMemoized");function Ct(e){return typeof e=="string"?e:""}s(Ct,"pickString");function We(e,t){let n=e[t];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(!t.includes("."))return;let r=t.split("."),o=e;for(let i of r){if(o===null||typeof o!="object"||Array.isArray(o))return;o=o[i]}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o}s(We,"pickNestedScalar");function F(e,t){let n=We(e,t);return typeof n=="string"?n:""}s(F,"pickNestedString");var st=500;function Ba(e,t=2){if(!ar(e))return{entries:[],truncated:!1};let n=[],r=!1,o=s((i,a)=>{if(a>t||r)return;let c;try{c=Dg(i,{withFileTypes:!0})}catch{return}for(let u of c){if(r)return;let f=Ha(i,u.name);if(u.isDirectory()){o(f,a+1);continue}if(u.isFile()){try{n.push({name:Ua(e,f),size:Ma(f).size})}catch{continue}if(n.length>=st){r=!0;return}}}},"walk");return o(e,1),{entries:n,truncated:r}}s(Ba,"listDirFiles");function Bo(e){return ar(e)?{present:!0,size:Ma(e).size}:{present:!1,size:0}}s(Bo,"fileSizeOrAbsent");var za="https://hooks.ev-ai.ai",fr=".claude/ev-ai-runtime-report.json",Ja="config.json",Jg="max_concurrent_hooks",QI=1024*1024,Yg=new Set(["localhost","127.0.0.1","[::1]","::1"]),Xg=["claude","cursor","codex"],dr=[fr,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],Ko=/^[A-Za-z0-9._~-]+$/;function pr(e){return e!==void 0&&Xg.includes(e)}s(pr,"isKnownRunner");function Ya(e){if(!e||typeof e!="object")return;let t=e[Jg];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}s(Ya,"maxConcurrentHooksFromConfig");function Ka(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}s(Ka,"parseCapArg");function jt(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}s(jt,"takeFlagValue");function mr(e){let t,n,r,o,i,a,c;for(let u=0;u<e.length;u++){let f=e[u];if(f!==void 0){if(f==="--runner"){let l=jt(e,u);t=l.value,u=l.next;continue}if(f.startsWith("--runner=")){t=f.slice(9);continue}if(f==="--url"){let l=jt(e,u);l.value&&(r=l.value),u=l.next;continue}if(f.startsWith("--url=")){r=f.slice(6);continue}if(f==="--token"){let l=jt(e,u);l.value&&(o=l.value),u=l.next;continue}if(f.startsWith("--token=")){o=f.slice(8);continue}if(f==="--base-url"){let l=jt(e,u);l.value&&(i=l.value),u=l.next;continue}if(f.startsWith("--base-url=")){i=f.slice(11);continue}if(f===tr){let l=jt(e,u);a=Ka(l.value)??a,u=l.next;continue}if(f.startsWith(`${tr}=`)){a=Ka(f.slice(tr.length+1))??a;continue}if(f===mn){let l=jt(e,u);c=Do(l.value)??c,u=l.next;continue}if(f.startsWith(`${mn}=`)){c=Do(f.slice(mn.length+1))??c;continue}f!==_a&&!f.startsWith("-")&&n===void 0&&(n=f)}}return{runner:pr(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:i,...a!==void 0?{cap:a}:{},...c!==void 0?{slot:c}:{}}}s(mr,"parseHookArgv");function gr(e,t=za){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}s(gr,"buildCollectorUrl");function At(e=Wg()){return zg(e,".ev-ai",Ja)}s(At,"homeManifestPath");function Xa(e,t){return{...e,...t}}s(Xa,"mergeManifestOverlay");function Ga(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=32||n===127||n===39)return!0}return!1}s(Ga,"hasUnsafeCollectorUrlChars");function _r(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?Yg.has(t.hostname):!1}catch{return!1}}s(_r,"isAllowedCollectorUrl");function Go(e){try{let n=new URL(e).pathname.split("/").filter(r=>r.length>0);if(n.length>=2&&n[n.length-1]==="hook"){let r=n[n.length-2];return r&&r.length>0?r:void 0}return}catch{return}}s(Go,"extractOrgTokenFromCollectorUrl");function ze(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!_r(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Go(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Ko.test(n))return`org token must match ${Ko.source}`;if(Ga(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(Ga(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}s(ze,"collectorUrlProblem");function it(e){return new URL(e).toString()}s(it,"normalizeCollectorUrl");function qa(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?gr(n):""}s(qa,"resolveCollectorUrl");function Bt(e){try{let t=new URL(e),n=t.pathname.split("/").filter(r=>r.length>0);return n.length>=2&&n[n.length-1]==="hook"&&(n[n.length-2]="***",t.pathname=`/${n.join("/")}`),t.toString()}catch{return"<invalid-url>"}}s(Bt,"redactCollectorUrlForLog");function Za(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=gr(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=ze(n);return r?{problem:r}:{url:it(n)}}s(Za,"collectorUrlFromArgv");var qg="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",Zg="COLLECTOR_URL",Va="collector_url_override",Qg=[qg,Zg];function e_(e){let t;for(let n of Qg){let r=e[n]?.trim();if(!r)continue;let o=ze(r);if(o){t??={problem:o,envName:n};continue}return{url:it(r),envName:n}}return t??{}}s(e_,"collectorUrlFromPluginOption");function Wa(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=ze(t);return n?{problem:n}:{url:it(t)}}s(Wa,"candidateFromUnknown");function Qa(e){let t=[],n=Wa(e.homeConfig?.[Va]);if(n.problem&&t.push({label:Va,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=Za(mr(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=e_(e.env);if(o.problem&&o.envName&&t.push({label:o.envName,problem:o.problem}),o.url)return{url:o.url,source:"plugin_option",warnings:t};let i=Wa(e.homeConfig?.collector_url);if(i.problem&&t.push({label:"collector_url",problem:i.problem}),i.url)return{url:i.url,source:"home_config",warnings:t};let a=e.homeConfig?.repo_ingest_token,c=typeof a=="string"&&a.trim()?{...e.manifest,repo_ingest_token:a}:e.manifest,u=c?qa(c):"";if(u){let f=ze(u);if(f)t.push({label:"manifest collector_url",problem:f});else return{url:it(u),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}s(Qa,"selectCollectorUrl");function bt(e){if(ze(e))return;let t;try{t=new URL(e)}catch{return}let n=Go(e);if(!n)return;let o=t.pathname.split("/").filter(c=>c.length>0).slice(0,-2),i=o.length>0?`/${o.join("/")}`:"",a=`${t.origin}${i}/${n}`;return Vg("sha256").update(a).digest("hex").slice(0,32)}s(bt,"scopeIdForCollectorUrl");var at=2,ec="node_modules/@ev-ai/agent-hook/dist/hook.mjs",Ae="ev-ai-agent-hook";function t_(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}s(t_,"hookBinaryBasenameFromPath");function hr(e){let t=t_(e);return t===Ae||t===`${Ae}.exe`}s(hr,"isHookBinaryPath");var tc="https://cdn.ev-ai.ai/agent-hook";var Vo=`current/${Ae}`,Wo=`.ev-ai/agent-hook/${Ae}`,nc=5e3,rc=5e3,zo=3e3;var Sr=3e3,oc=1500,sc=4*1024,Jo=256*1024,n_=4*1024,ic=32*1024,pe="1.3.10",Er=`@ev-ai/agent-hook@${pe}`,ac="ev-ai runtime report";var cc={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT"};import{chmodSync as hu,cpSync as Su,existsSync as ft,mkdirSync as Ss,readFileSync as iS,rmSync as vr,symlinkSync as aS,writeFileSync as cS}from"node:fs";import{homedir as Ye}from"node:os";import{dirname as Es,isAbsolute as uS,join as z,relative as Eu,resolve as gu,sep as lS}from"node:path";import{fileURLToPath as fS}from"node:url";import{existsSync as r_,readdirSync as uc}from"node:fs";import{homedir as yr}from"node:os";import{join as ge}from"node:path";function lc(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return ge(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}s(lc,"claudeManagedSettingsDir");function Yo(e=process.platform){let t=lc(e),n=[ge(t,"managed-settings.json")],r=ge(t,"managed-settings.d");try{if(!r_(r))return n;let o=uc(r).filter(i=>i.endsWith(".json")&&!i.startsWith(".")).sort().map(i=>ge(r,i));n.push(...o)}catch{}return n}s(Yo,"listClaudeManagedSettingsFiles");function yn(e=process.platform,t=yr()){return{serverManaged:ge(t,".claude","remote-settings.json"),fileBased:Yo(e)}}s(yn,"claudeManagedSettingsSources");function o_(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return ge(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}s(o_,"cursorEnterpriseSettingsDir");function s_(e=process.platform,t=yr()){let n=[ge(o_(e),"hooks.json")],r=ge(t,".cursor","managed");try{for(let o of uc(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(ge(r,o.name,"hooks.json"))}catch{}return n}s(s_,"listCursorManagedSettingsFiles");function i_(e=process.platform,t=yr()){let n=e==="win32"?ge(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[ge(n,"requirements.toml")];return e!=="win32"&&r.push(ge(n,"managed_config.toml")),r.push(ge(t,".codex","managed_config.toml"),ge(n,"config.toml")),r}s(i_,"listCodexManagedSettingsFiles");function Rr(e,t=process.platform,n=yr()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=yn(t,n);return[r,...o]}case"cursor":return s_(t,n);default:return i_(t,n)}}s(Rr,"managedSettingsFiles");import{createHash as Kc,randomBytes as mh}from"node:crypto";import{existsSync as Gc,mkdirSync as cs,readFileSync as Vc,unlinkSync as Wc,writeFileSync as zc}from"node:fs";import{homedir as us}from"node:os";import{dirname as Pr,join as ls,resolve as gh}from"node:path";var a_=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),c_=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function ye(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||c_.has(n)||r.includes("[bot]")||a_.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),i=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(i.endsWith("bot")||i.includes("[bot]"))return!0}return!1}s(ye,"isBotOperatorIdentity");import{existsSync as f_,readFileSync as d_}from"node:fs";import{hostname as pc,release as p_,userInfo as m_,version as g_}from"node:os";import*as me from"node:os";import{performance as Xo}from"node:perf_hooks";var u_=1024*1024,l_=128;function Cr(e){return Math.round(e/u_)}s(Cr,"mb");function Rn(e,t){let n=10**t;return Math.round(e*n)/n}s(Rn,"round");function fc(e=process.platform){try{let t=Xo.now(),n={},r=0,o=0,i=e!=="win32";for(let{times:u}of me.cpus())r+=u.user+u.nice+u.sys+(i?u.irq:0),o+=u.idle;if(r+o>0&&(n.cpu_busy_ms=Math.round(r),n.cpu_idle_ms=Math.round(o)),n.uptime_s=Math.round(me.uptime()),n.mem_free_mb=Cr(me.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=Cr(process.availableMemory())),e!=="win32"){let[u,f,l]=me.loadavg();n.load_1m=Rn(u??0,2),n.load_5m=Rn(f??0,2),n.load_15m=Rn(l??0,2)}let a=process.resourceUsage();n.proc_cpu_user_ms=Math.round(a.userCPUTime/1e3),n.proc_cpu_sys_ms=Math.round(a.systemCPUTime/1e3),n.proc_max_rss_mb=Math.round(a.maxRSS/1024),n.proc_page_faults=a.majorPageFault,e!=="win32"&&(n.proc_invol_ctx=a.involuntaryContextSwitches);let c=Xo.nodeTiming?.bootstrapComplete;return typeof c=="number"&&c>0&&(n.node_boot_ms=Rn(c,1)),n.sample_us=Math.round((Xo.now()-t)*1e3),n}catch{return}}s(fc,"sampleSys");function dc(){try{let e=me.cpus(),t={},n=typeof me.availableParallelism=="function"?me.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,l_);r&&(t.cpu_model=r);let o=me.totalmem();t.mem_total_mb=Cr(o);let i=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof i=="number"&&i>0&&i<o&&(t.mem_limit_mb=Cr(i)),t.uptime_h=Rn(me.uptime()/3600,1),t}catch{return{}}}s(dc,"hostSpecs");function Kt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(Kt,"isTruthyFlag");function mc(e=process.env){return Kt(Z("CURSOR_SANDBOX",e))}s(mc,"isCursorSandboxProcess");var __=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function h_(e){return __.some(t=>!!Z(t,e))}s(h_,"hasManagedCiMarker");function S_(e){if(Z("KUBERNETES_SERVICE_HOST",e)||Kt(Z("REMOTE_CONTAINERS",e))||Kt(Z("DEVCONTAINER",e)))return!0;try{if(f_("/.dockerenv")||d_("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}s(S_,"hasContainerMarker");function gc(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!Z(t,e))}s(gc,"hasIdeExtensionHostMarker");function E_(e,t=process.platform){return gc(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!Z(n,e)):!1}s(E_,"hasLocalIdeHostMarker");function y_(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}s(y_,"isBackgroundComposerSessionId");function R_(e){return e==="linux"}s(R_,"isLinuxPlatform");function Z(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return D(e)}s(Z,"readContextEnv");function C_(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!A_(Z("CURSOR_VERSION",n))}s(C_,"isCursorCloudHostFingerprint");function A_(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(A_,"trimEnvLocal");function qo(e){if(y_(e.sessionId))return!0;let t=e.hostname??pc(),n=e.osUser??hc(e.env);return C_(t,n,e.env)}s(qo,"hasCursorCloudExclusiveEvidence");function b_(e){return Kt(Z("CURSOR_AGENT",e.env))?!0:qo(e)}s(b_,"hasCursorCloudEvidence");function k_(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(Z("TERM",e)??Z("TERM_PROGRAM",e))||(Z("SSH_TTY",e)??Z("SSH_CONNECTION",e))||(Z("__CFBundleIdentifier",e)??Z("XPC_SERVICE_NAME",e))||gc(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!Z(t,e))||Z("SESSIONNAME",e))}s(k_,"hasLocalSessionMarker");function Cn(e={}){let t=e.env;if(Z("GITHUB_ACTIONS",t))return"github_actions";if(Kt(Z("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!E_(t,n)&&b_(e)&&(Kt(Z("CURSOR_AGENT",t))||R_(n)))return"cursor_cloud";if(Z("CODESPACES",t)||Z("CODESPACE_NAME",t))return"codespaces";if(Z("GITLAB_CI",t))return"gitlab_ci";if(h_(t))return"managed";let r=Z("CI",t);return r&&r!=="false"&&r!=="0"?"managed":S_(t)?"container":k_(t)?"interactive":"unknown"}s(Cn,"detectContext");async function _c(){return await se("systemd-detect-virt",[],1e3)}s(_c,"detectVirt");function hc(e=process.env,t=m_){for(let n of["USER","LOGNAME","USERNAME"]){let r=e[n];if(typeof r=="string"){let o=r.trim();if(o.length>0)return o}}try{return t().username??""}catch{return""}}s(hc,"resolveHostUsername");var x_=32;function O_(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,x_);return t.length>0?t:null}s(O_,"sanitizeOsPlatform");function I_(){try{return[g_(),p_()].filter(Boolean).join(" ").trim()}catch{return""}}s(I_,"windowsVersion");async function Sc(e=!1){let t=O_(process.platform),n="";if(process.platform==="darwin")n=await se("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:a}=await import("node:fs"),c=a("/etc/os-release","utf8"),u=c.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],f=c.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];n=u??f??""}catch{n=await se("lsb_release",["-sd"],1e3).then(a=>a.replace(/^"|"$/g,""))}n||(n=await se("uname",["-r"],1e3))}else process.platform==="win32"?n=I_():n=await se("ver",[],1e3);let r=hc(),o=(process.env.SHELL??"").split(/[/\\]/).pop()??"",i="";try{i=await se("tty",[],500),i.includes("not a tty")&&(i="")}catch{i=""}return{os:t,os_version:n||null,user:r||null,shell:o||null,tty:i||null,...e?dc():{}}}s(Sc,"hostEnv");function Ar(){return pc()}s(Ar,"hostName");import{randomBytes as N_}from"node:crypto";import{appendFileSync as v_,mkdirSync as M_,readdirSync as L_,readFileSync as ts,renameSync as xc,statSync as kn,unlinkSync as Pc}from"node:fs";import{homedir as ct,tmpdir as H_}from"node:os";import{dirname as es,join as kt}from"node:path";var Rc="EV_AI_PERF_L",Zo="EV_AI_PERF_H",An="EV_AI_RUN_ID",T_="EV_AI_HOOK_PERF";var P_=/^[a-z][a-z0-9_]{0,23}$/;var br={origin:0,marks:{},values:{}},kr=!1;function Cc(e=process.env){kr=e[T_]!=="0",br.origin=performance.timeOrigin}s(Cc,"startTimings");function bn(){return kr}s(bn,"timingsActive");function Je(e,t=performance.now()){kr&&(br.marks[e]=t)}s(Je,"mark");function Ac(){return br}s(Ac,"ownTimings");function bc(e){return Math.round(e*10)/10}s(bc,"round1");function Ec(e){return Object.entries(e).map(([t,n])=>`${t}=${bc(n)}`).join(",")}s(Ec,"entries");function w_(e){return`${bc(e.origin)}|${Ec(e.marks)}|${Ec(e.values)}`}s(w_,"serializeTimings");function yc(e,t){if(!e)return!0;for(let n of e.split(",")){let r=n.indexOf("="),o=n.slice(0,r),i=Number(n.slice(r+1));if(r<1||!P_.test(o)||!(i>=0&&i<=36e5))return!1;t[o]=i}return Object.keys(t).length<=32}s(yc,"parseEntries");function Qo(e){if(!e||e.length>1024)return;let[t,n,r,...o]=e.split("|"),i=Number(t);if(o.length>0||!Number.isFinite(i)||i<=0)return;let a={origin:i,marks:{},values:{}};if(!(!yc(n,a.marks)||!yc(r,a.values)))return a}s(Qo,"parseTimings");function kc(){return kr?w_(br):void 0}s(kc,"serializeOwnTimings");var U_="hooks-debug.log",D_=/^hooks-debug\.log\.\d+$/,F_=/^hooks-debug\.log(\.1)?\.send-\d+$/,Oc="ev-ai-agent-hooks.log",$_="EV_AI_HOOK_RUN_LOG",Gt="unlimited",j_="off",ns=1024*1024,B_=8*1024,Ic=ns/2-B_,K_=10080*60*1e3,G_=1024*1024,V_="run-log-windows.json",W_=64*1024,rs=/^[a-z0-9]{8}$/,Tc="abcdefghijklmnopqrstuvwxyz0123456789",z_=/[^A-Za-z0-9._:/+-]/g,J_=128,ut={info(){},error(){}},be=ut;function Or(e=ct()){return kt(e,".ev-ai",U_)}s(Or,"fileLogPath");function wc(e){try{let t=JSON.parse($t(ts(kt(e,".ev-ai","config.json"),"utf8")));return xt(t)?t:void 0}catch{return}}s(wc,"readHomeConfig");function Y_(e){return e?.debug===!0}s(Y_,"debugFromHomeConfig");function os(e,t=!1){return e.includes("--debug")||t}s(os,"isHookDebugEnabled");function xt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(xt,"isRecord");function X_(e,t){let n=e?.log_until;if(typeof n!="string")return;let r=[];if(n===Gt)return{on:!0,source:"local_config",scopes:r,localUntil:n};if(n===j_)return{on:!1,source:"local_config",scopes:r,localUntil:n};let o=Date.parse(n);return Number.isNaN(o)?void 0:{on:o>t,source:"local_config",scopes:r,localUntil:n}}s(X_,"localRunLog");function q_(e){if(!xt(e)||!xt(e.config))return;let t=e.config.log_until;if(typeof t!="string")return;if(t===Gt)return{until:t,untilMs:Number.POSITIVE_INFINITY};let n=Date.parse(t);return Number.isNaN(n)?void 0:{until:t,untilMs:n}}s(q_,"scopeUntilMs");function Nc(e=ct(),t=process.env,n=Date.now()){return vc(e,()=>wc(e),t,n)}s(Nc,"readRunLogSwitch");function vc(e,t,n,r){let o=n[$_]?.trim().toLowerCase();if(o&&Rt.has(o))return{on:!0,source:"env",scopes:[]};if(o&&ur.has(o))return{on:!1,source:"env",scopes:[]};let i=X_(t(),r);if(i)return i;let a=[];try{let c=kt(e,".ev-ai","agent-hook","hook-config.json"),u=kn(c);if(!u.isFile()||u.size>G_)return{on:!1,source:"remote",scopes:a};let f=JSON.parse(ts(c,"utf8"));if(xt(f))for(let[l,d]of Object.entries(f)){let p=q_(d);p&&p.untilMs>r&&a.push({scopeId:l,...p})}}catch{}return{on:a.length>0,source:"remote",scopes:a}}s(vc,"runLogSwitch");function Mc(e=ct()){return kt(e,".ev-ai","agent-hook",V_)}s(Mc,"runLogWindowsPath");function ss(e=ct()){try{let t=Mc(e),n=kn(t);if(!n.isFile()||n.size>W_)return{};let r=JSON.parse(ts(t,"utf8")),o={};if(xt(r))for(let[i,a]of Object.entries(r))typeof a=="string"&&(o[i]=a);return o}catch{return{}}}s(ss,"readRunLogWindows");function is(e,t=ct()){try{let n=ss(t),r={...n};if(e(r),JSON.stringify(r)===JSON.stringify(n))return;ue(Mc(t),`${JSON.stringify(r,null,2)}
|
|
18
|
+
`)}catch{}}s(is,"updateRunLogWindows");function Z_(e,t){is(n=>{for(let r of t)n[r.scopeId]=r.until},e)}s(Z_,"recordRunLogWindows");function Q_(e){return e.replace(/[\r\n]/g," ")}s(Q_,"oneLine");function eh(e){try{if(kn(e).size<Ic)return;let t=`${e}.${process.pid}`;xc(e,t);try{xc(t,kn(t).size>=Ic?`${e}.1`:e)}catch{Pc(t)}}catch{}}s(eh,"rotateIfFull");var th=/\bhttps?:\/\/[^\s'"<>`]+/gi;function nh(e){try{let t=new URL(e);return`${t.protocol}//${t.host}${t.pathname.replace(/\/[^/]+\/hook(?![\w-])/,"/***/hook")}`}catch{return"<url>"}}s(nh,"redactUrl");function rh(e,t=ct()){let n=e.replace(th,nh);return t.length>1?n.replaceAll(t,"~"):n}s(rh,"scrubForLog");function oh(e,t){try{M_(es(e),{recursive:!0}),eh(e),v_(e,t,{encoding:"utf8",mode:384})}catch{}}s(oh,"appendLine");function Ir(e=process.argv,t=Or(),n,r){ih();let o=ct(),i,a=!1,c=s(()=>(a||(i=wc(o),a=!0),i),"readOnce"),u=os(e,n??Y_(c())),f=u||r!==void 0?void 0:vc(o,c,process.env,Date.now());if(!u&&!(r??f?.on)){be=ut;return}f?.source==="remote"&&Z_(o,f.scopes);let l=s((d,p)=>{oh(t,`${new Date().toISOString()} ${d} ${rh(Q_(p),o)}
|
|
19
|
+
`)},"write");be={info(d){l("info",d)},error(d){l("error",d)}}}s(Ir,"initFileLogger");function Lc(){return be!==ut}s(Lc,"fileLoggerActive");var le={info(e){be.info(e)},error(e){be.error(e)}},sh=new Set(["post_failed","timeout"]),ce={},as=!1;function ih(){ce={},as=!1}s(ih,"resetRunState");function Hc(){return as}s(Hc,"runLineWritten");function ee(e){if(be===ut)return;if(e.outcome===void 0){ce={...ce,...e};return}if(ce.outcome!==void 0&&sh.has(ce.outcome)){ce.err===void 0&&e.err!==void 0&&(ce={...ce,err:e.err});return}let{runner:t,event:n,session:r,tool:o,ackMs:i}=ce;ce={runner:t,event:n,session:r,tool:o,ackMs:i,...e}}s(ee,"noteRun");function lt(e){let t=xt(e)?e.cause:void 0;for(let n of[t,e])if(xt(n)&&typeof n.code=="string"&&n.code!=="")return n.code;return e instanceof Error?e.name:typeof e}s(lt,"runErrorKind");var ah=4096;function ch(e){return(e.stack??"").split(`
|
|
20
|
+
`).map(t=>t.trim()).filter(t=>t.startsWith("at ")).join(" | ")}s(ch,"stackFrames");function Tr(e){try{return uh(e).join(" ").slice(0,ah)}catch{return"err=unknown message=(unprintable)"}}s(Tr,"errorDetail");function uh(e){let t=[`err=${lt(e)}`];if(!(e instanceof Error))return t.push(`message=${String(e)}`),t;t.push(`message=${e.message}`);let n=ch(e);n&&t.push(`stack=${n}`);let r=e.cause;for(let o=0;r!==void 0&&o<3;o+=1)t.push(r instanceof Error?`cause=${lh(r)}`:`cause=${String(r)}`),r=r instanceof Error?r.cause:void 0;return t}s(uh,"errorParts");function lh(e){if(e instanceof AggregateError&&e.errors.length>0){let t=e.errors.map(n=>n instanceof Error?n.message:String(n));return`${e.name}: ${t.join("; ")}`}return`${e.name}: ${e.message}`}s(lh,"causeText");function L(e,t,n=process.env){if(be===ut)return;let r=n[An],o=r!==void 0&&rs.test(r)?` run=${r}`:"";be.error(`failed where=${e}${o} ${Tr(t)}`)}s(L,"logFailure");function fh(){let e="";for(let t of N_(8))e+=Tc[t%Tc.length];return e}s(fh,"newRunId");function Uc(e=process.env){if(be===ut)return;let t=e[An];if(t!==void 0&&rs.test(t))return t;let n=fh();return e[An]=n,n}s(Uc,"ensureRunId");function dh(e){if(typeof e=="number")return Number.isInteger(e)?String(e):e.toFixed(1);let t=e.replace(z_,"_").slice(0,J_);return t===""?"_":t}s(dh,"runValue");function Vt(e,t,n,r=process.env){if(be===ut)return;as=!0;let o=r[An],a=[["run",o!==void 0&&rs.test(o)?o:void 0],["p",e],["start",new Date(performance.timeOrigin).toISOString()],["v",t],["runner",ce.runner],["event",ce.event],["tool",ce.tool],["session",ce.session],["outcome",ce.outcome??n],["ms",performance.now()],["ack_ms",ce.ackMs],["post_ms",ce.postMs],["http",ce.http],["err",ce.err]].filter(c=>c[1]!==void 0&&c[1]!=="").map(([c,u])=>`${c}=${dh(u)}`);be.info(`run ${a.join(" ")}`)}s(Vt,"writeRunLine");function xr(e,t){try{t-kn(e).mtimeMs>K_&&Pc(e)}catch{}}s(xr,"unlinkIfStale");function Dc(e=Date.now(),t=ct(),n=ph()){if(be!==ut)return;let r=Or(t);xr(r,e),xr(`${r}.1`,e);try{for(let o of L_(es(r)))(D_.test(o)||F_.test(o))&&xr(kt(es(r),o),e)}catch{}xr(n,e)}s(Dc,"purgeStaleLog");function ph(e=process.platform){return e==="win32"?kt(H_(),Oc):kt("/tmp",Oc)}s(ph,"legacyLogPath");var _h="installation.json",hh="cloud-bootstrap.lock",Sh=6e4;function Jc(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}s(Jc,"platformAgentIdCacheKey");function Re(e=us()){return ls(e,".ev-ai","agent-hook")}s(Re,"agentHookHome");function Eh(e=us()){return ls(Re(e),_h)}s(Eh,"installationStorePath");function Yc(e){return ls(Pr(e),hh)}s(Yc,"cloudBootstrapLockPath");function Xc(){return mh(8).toString("hex")}s(Xc,"randomInstallationId");function Wt(e){return Kc("sha256").update(e).digest("hex").slice(0,16)}s(Wt,"sha16");function K(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(K,"trimEnv");function qc(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}s(qc,"isValidInstallationId");function yh(e=process.env){let t=K(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!qc(t)){y(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}s(yh,"readInstallationIdEnvOverride");function Zc(e,t){return e&&qc(e)?e:(e&&y(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),yh(t))}s(Zc,"resolvePinnedInstallationId");function Rh(e){return/^[0-9a-f]{16}$/.test(e)}s(Rh,"isEphemeralInstallationIdShape");function Ch(e=process.env){if(K(e.GITHUB_ACTIONS)){let t=K(e.GITHUB_REPOSITORY_ID)??K(e.GITHUB_REPOSITORY),n=K(e.GITHUB_ACTOR)??K(e.GITHUB_TRIGGERING_ACTOR)??K(e.GITHUB_USER);if(t&&n)return Wt(`github_actions|${t}|${n}`)}if(K(e.CODESPACES)||K(e.CODESPACE_NAME)){let t=K(e.CODESPACE_NAME);if(t)return Wt(`codespaces|${t}`);let n=K(e.GITHUB_REPOSITORY_ID)??K(e.GITHUB_REPOSITORY),r=K(e.GITHUB_USER)??K(e.GITHUB_ACTOR);if(n&&r)return Wt(`codespaces|${n}|${r}`)}if(K(e.GITLAB_CI)){let t=K(e.CI_PROJECT_ID)??K(e.CI_PROJECT_PATH),n=K(e.GITLAB_USER_LOGIN)??K(e.GITLAB_USER_EMAIL)??K(e.GITLAB_USER_NAME);if(t&&n)return Wt(`gitlab|${t}|${n}`)}return null}s(Ch,"deriveEphemeralInstallationId");var Ah="cursoragent@cursor.com";function bh(e){let t=K(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===Ah?null:t}s(bh,"cursorCloudUserEmail");function kh(e,t){return K(e.CURSOR_PROJECT_DIR)??K(e.CLAUDE_PROJECT_DIR)??t}s(kh,"cursorCloudWorkspacePath");function xh(e){return hn(e).replace(/\.git$/i,"").toLowerCase()}s(xh,"normalizeRemoteForSeed");async function Oh(e){let t=await se("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?xh(t):e}s(Oh,"resolveRepoSeed");async function Ih(e){let t=K(await se("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!ye(null,t))return t;let n=K(await se("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!ye(null,n)?n:null}s(Ih,"readClaudeRemoteOperatorEmail");function Th(e,t){let n=kh(e,t);return n?Wt(`cursor_cloud|${n}|${bh(e)??""}`):null}s(Th,"deriveCursorCloudInstallationId");async function Ph(e,t){let n=K(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await Oh(n),o=await Ih(n);return Wt(`claude_remote|${r}|${o??""}`)}s(Ph,"deriveClaudeRemoteInstallationId");function Fc(e,t){let n=Zc(e,t);if(n)return n;let r=Ch(t);return r||Xc()}s(Fc,"chooseNewInstallationId");async function wh(e){let n=await se("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||gh(e);return Kc("sha256").update(n).digest("hex").slice(0,16)}s(wh,"computeRepoKey");function Nh(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&r.length>0&&(t[n]=r);return Object.keys(t).length>0?t:void 0}s(Nh,"readPlatformAgentIds");function vh(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=Nh(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}}s(vh,"parseInstallationRecord");function Ot(e){if(Gc(e))try{return vh(Vc(e,"utf8"))}catch{}}s(Ot,"readInstallationRecord");function fs(e){return Ot(e)}s(fs,"readInstallationStore");function Qc(e,t,n){let r=Ot(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{ue(e,`${JSON.stringify(o,null,2)}
|
|
21
|
+
`)}catch(i){let a=i instanceof Error?i.message:String(i);y(`WARN: operator identity cache write failed open: ${a}`),L("operator_identity_cache",i)}}s(Qc,"writeOperatorIdentityCache");function eu(e,t=Date.now()){if(!e)return!0;if(Ot(e)?.operator_identity_hash)return!1;let n=Yc(e);try{if(Gc(n)){let r=Number.NaN;try{r=Number(Vc(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<Sh)return!1;try{Wc(n)}catch{}}}catch{}try{return cs(Pr(n),{recursive:!0}),zc(n,`${t}
|
|
22
|
+
`,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(ou(r))return!1;let o=r instanceof Error?r.message:String(r);return y(`WARN: cloud bootstrap claim failed open: ${o}`),L("cloud_bootstrap_claim",r),!0}}s(eu,"tryClaimCloudIdentityBootstrap");function tu(e){if(e)try{Wc(Yc(e))}catch{}}s(tu,"releaseCloudIdentityBootstrapClaim");function nu(e,t){let r=Ot(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}s(nu,"readCachedPlatformAgentId");function ru(e,t,n){if(!n)return;let r=Ot(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{ue(e,`${JSON.stringify(o,null,2)}
|
|
23
|
+
`)}catch(i){let a=i instanceof Error?i.message:String(i);y(`WARN: platform_agent_id cache write failed open: ${a}`),L("platform_agent_id_cache",i)}}s(ru,"writeCachedPlatformAgentId");function ou(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}s(ou,"isEexistError");function Mh(e,t){cs(Pr(e),{recursive:!0}),zc(e,`${JSON.stringify(t,null,2)}
|
|
24
|
+
`,{encoding:"utf8",flag:"wx"})}s(Mh,"writeInstallationRecordExclusive");function $c(e,t){try{return Mh(e,t),t}catch(n){if(!ou(n))throw n;return Ot(e)}}s($c,"tryCreateInstallationRecord");function jc(e,t){cs(Pr(e),{recursive:!0}),ue(e,`${JSON.stringify(t,null,2)}
|
|
25
|
+
`)}s(jc,"replaceInstallationRecord");function Bc(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}s(Bc,"newInstallationRecord");async function wr(e,t={}){let n=t.home??us(),r=t.env??process.env,o=await wh(e),i=Eh(n),a={sessionId:t.sessionId,hostname:K(r.HOSTNAME)??void 0,osUser:K(r.USER)??K(r.LOGNAME)??K(r.USERNAME)??void 0,env:r},c=Cn(a),u=Zc(t.overrideId,r),f=c==="cursor_cloud"&&qo(a)?Th(r,e):c==="claude_remote"?await Ph(r,e):null,l=Ot(i);if(l){let h=l;if(u&&u===l.installation_id&&l.pinned!==!0&&(h={...l,pinned:!0},jc(i,h)),!!f&&f!==h.installation_id&&!u&&h.pinned!==!0&&Rh(h.installation_id)&&f){let k={installation_id:f,...h.platform_agent_ids?{platform_agent_ids:h.platform_agent_ids}:{}};return jc(i,k),{installationId:f,storePath:i,repoKey:o}}return{installationId:h.installation_id,storePath:i,repoKey:o}}let d=u??f??Fc(void 0,r),p=$c(i,Bc(d,u));if(p)return{installationId:p.installation_id,storePath:i,repoKey:o};let m=u??f??Fc(void 0,r),_=$c(i,Bc(m===d?Xc():m,u));if(_)return{installationId:_.installation_id,storePath:i,repoKey:o};throw new Error(`Failed to create installation record at ${i}`)}s(wr,"resolveOrCreateInstallationId");import{existsSync as ms,readFileSync as Wh}from"node:fs";import{dirname as zh,isAbsolute as Jh,join as Yh,relative as Xh}from"node:path";import{readFileSync as Lh,statSync as Hh}from"node:fs";import{homedir as ds}from"node:os";import{join as Uh}from"node:path";var Dh="hook-config.json",Fh=1440*60*1e3,$h=2048,jh=1024*1024;function zt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(zt,"isRecord");function su(e=ds()){return Uh(Re(e),Dh)}s(su,"hookConfigPath");function iu(e){let t=su(e);try{let n=Hh(t);if(!n.isFile()||n.size>jh)return;let r=JSON.parse(Lh(t,"utf8"));return zt(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}s(iu,"readStore");function Bh(e){let t={};return typeof e.collect_prompt=="boolean"&&(t.collect_prompt=e.collect_prompt),typeof e.collect_telemetry=="boolean"&&(t.collect_telemetry=e.collect_telemetry),typeof e.log_until=="string"&&(e.log_until===Gt||!Number.isNaN(Date.parse(e.log_until)))&&(t.log_until=e.log_until),t}s(Bh,"knownKeys");function au(e,t=ds()){if(!e)return;let n=bt(e);if(!n)return;let r=iu(t),o=r?r[n]:void 0;if(!(!zt(o)||!zt(o.config)))return Bh(o.config)}s(au,"readHookConfig");function Kh(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!zt(n)||!zt(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>$h))return n.hook_config}s(Kh,"hookConfigFromBody");function Gh(e,t,n,r){let o={...e},i=o[t];if(Object.keys(n).length===0)return i===void 0?void 0:(delete o[t],o);if(!(zt(i)&&JSON.stringify(i.config)===JSON.stringify(n)&&typeof i.fetched_at_ms=="number"&&i.fetched_at_ms<=r&&r-i.fetched_at_ms<Fh))return o[t]={config:n,fetched_at_ms:r},o}s(Gh,"nextStore");function cu(e,t,n=ds(),r=Date.now()){let o=Kh(e),i=t?bt(t):void 0;if(o===void 0||!i)return"skipped";try{let a=iu(n);if(a===void 0)return le.error("failed where=hook_config_read err=unreadable message=hook config store is not a readable JSON object"),"skipped";let c=Gh(a??{},i,o,r);return c?(ue(su(n),`${JSON.stringify(c,null,2)}
|
|
26
|
+
`),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(a){let c=a instanceof Error?a.message:String(a);return y(`WARN: hook config write failed open: ${c}`),L("hook_config_write",a),"failed"}}s(cu,"applyCollectorHookConfigResponse");var Vh="EV_AI_HOOK_TELEMETRY";function uu(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}s(uu,"telemetryFromHomeConfig");function lu(e,t,n=process.env){let r=n[Vh]?.trim().toLowerCase();return r&&Rt.has(r)?{enabled:!0,source:"env"}:r&&ur.has(r)?{enabled:!1,source:"env"}:e!==void 0?{enabled:e,source:"local_config"}:t?.collect_telemetry!==void 0?{enabled:t.collect_telemetry,source:"org_config"}:{enabled:!0,source:"default"}}s(lu,"resolveTelemetry");function fu(e){for(let t of dr){let n=Yh(e,t);if(ms(n))return n}}s(fu,"firstExistingManifest");async function qh(e=process.cwd(),t){let n=t??await Ve(e);return fu(n)??fu(e)}s(qh,"findRepoManifestPath");async function Zh(e,t){let n=t??await Ve(zh(e)),r=Xh(n,e);if(r.startsWith("..")||Jh(r))return!1;let o=await Ie("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(y(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}s(Zh,"isManifestGitTracked");function ps(e){let t=Wh(e,"utf8");return Te($t(t),{})}s(ps,"loadRepoManifestFromFile");function Qh(){return{schema_version:at,mcp_servers:[]}}s(Qh,"defaultSharedManifest");function eS(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(y(`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")&&(y(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}s(eS,"stripTrackedUnsafeFields");function tS(e){let t=Qa({argv:e.argv,env:process.env,homeConfig:e.homeConfig,manifest:e.manifest,manifestSource:e.manifestSource});for(let r of t.warnings){y(`WARN: ignoring ${r.label}: ${r.problem}`);let o=r.label.replace(/\s+/g,"_"),i=r.problem.replace(/\/[^/\s]+\/hook\b/g,"/***/hook");le.error(`collector ignored label=${o} message=${i}`)}let n=t.url??"";return le.info(`collector source=${t.source} url=${n?Bt(n):"(none)"}`),n}s(tS,"collectorUrlFromLoaded");function nS(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}s(nS,"recordOrUndefined");async function du(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await jo(e),o=D("EV_AI_HOOK_MANIFEST"),i=o&&ms(o)?o:void 0,a=i?void 0:ms(At())?At():void 0,c=i?void 0:await qh(e,n),u=a?ps(a):void 0,f=c?ps(c):void 0,l=uu(i?Q(At(),{}):u),d,p,m,_=new Set;if(i){d=ps(i),p=i,m=i;for(let I of Object.keys(d))_.add(I)}else if(u&&f){d=Xa(f,u),p=a,m=c;for(let I of Object.keys(f))I in u||_.add(I)}else if(u)d=u,p=a;else if(f){d=f,p=c,m=c;for(let I of Object.keys(f))_.add(I)}else d=Qh();delete d.installation_id;let h=m?await Zh(m,n):!1;eS(d,m,h,_);let{installationId:b,storePath:k,repoKey:T}=await wr(n,{sessionId:t.sessionId}),N=u??nS(Q(At(),null)),w=tS({argv:t.argv??process.argv,homeConfig:N,manifest:i?d:f,manifestSource:i?"manifest_override":"manifest"});return{manifestPath:p??k,manifest:d,installationId:b,installationStorePath:k,repoKey:T,collectorUrl:w,hookConfig:au(w),...l!==void 0?{localTelemetry:l}:{},platformAgentId:d.platform_agent_id??"",gitRoot:n,inGitRepo:r}}s(du,"loadManifest");function pu(e){return{schema_version:at,...e?{collector_url:e}:{},mcp_servers:[]}}s(pu,"createDefaultSharedManifest");var rS=["darwin-arm64","darwin-x64","linux-arm64","linux-x64","windows-x64","windows-arm64"];function oS(e){return e==="windows-x64"||e==="windows-arm64"}s(oS,"isWindowsSlug");function gs(e=process.platform,t=process.arch){if(e==="darwin")return t==="arm64"?"darwin-arm64":t==="x64"?"darwin-x64":void 0;if(e==="linux")return t==="arm64"?"linux-arm64":t==="x64"?"linux-x64":void 0;if(e==="win32")return t==="x64"?"windows-x64":t==="arm64"?"windows-arm64":void 0}s(gs,"resolvePlatformSlug");function mu(e=process.platform,t=process.arch){let n=gs(e,t);if(!n)throw new Error(`Unsupported platform ${e}-${t}. Supported: ${rS.join(", ")}.`);return n}s(mu,"assertSupportedPlatform");function sS(e){return oS(e)?`${Ae}.exe`:Ae}s(sS,"hookBinaryFileName");function _s(e){return`compile-out/bin/${e}/${sS(e)}`}s(_s,"compiledBinaryRelativePath");function dS(e,t){let n=e.collectorUrl?.trim();if(!n)throw new Error(`${t} requires --url <https://hooks.ev-ai.ai/{orgToken}/hook>`);let r=ze(n);if(r)throw new Error(`collector URL rejected: ${r}`);return it(n)}s(dS,"requireCollectorUrl");function pS(e){let t=e.collectorUrl?.trim();if(!t)return;let n=ze(t);if(n)throw new Error(`collector URL rejected: ${n}`);return it(t)}s(pS,"optionalCollectorUrl");function mS(e){return dS(e,"install")}s(mS,"requireInstallCollectorUrl");function yu(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url")}return t}s(yu,"parseConfigureArgs");function Ru(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url");if(r==="--update")throw new Error("--update was removed; use the `update` command instead of `install --update`");if(r==="--delivery"){let o=e[n+1];(o==="npx"||o==="binary"||o==="local")&&(t.delivery=o,n+=1);continue}if(r==="--force"){t.force=!0;continue}if(r==="--no-claude"){t.skipClaude=!0;continue}if(r==="--no-cursor"){t.skipCursor=!0;continue}if(r==="--no-codex"){t.skipCodex=!0;continue}}return t}s(Ru,"parseInstallArgs");function Cu(e=process.execPath){return Au(e)?"binary":"npx"}s(Cu,"defaultHookDelivery");function gS(){return z(Ye(),".ev-ai","agent-hook")}s(gS,"agentHookBinaryHome");function _S(e=Ye()){return z(e,".ev-ai","agent-hook",Vo)}s(_S,"globalHookBinaryPath");function hS(){let e=Es(fS(import.meta.url)),t=z(e,"hook.mjs");return ft(t)?t:z(e,"..","dist","hook.mjs")}s(hS,"resolveBundledHookPath");function Au(e=process.execPath){return hr(e)}s(Au,"isCompiledHookBinary");function bu(e,t){let n=Eu(gu(e),gu(t));return!n.startsWith("..")&&!uS(n)}s(bu,"isUnderRoot");function Mr(e){return e.split(lS).join("/")}s(Mr,"toPosixPath");function SS(e){return`node "$(git rev-parse --show-toplevel)/${Mr(e)}"`}s(SS,"gitRootRelativeNodeCommand");function ES(e){return`"$(git rev-parse --show-toplevel)/${Mr(e)}"`}s(ES,"gitRootRelativeBinaryCommand");function yS(e){return z(e,Wo)}s(yS,"projectHookBinaryPath");function ku(e,t){let n=yS(e);Ss(Es(n),{recursive:!0}),Su(t,n,{force:!0});try{hu(n,493)}catch{}return n}s(ku,"pinHookBinaryIntoProject");function RS(e){let t=z(gS(),"current");try{vr(t,{recursive:!0,force:!0})}catch{}aS(e,t,process.platform==="win32"?"junction":"dir")}s(RS,"refreshCurrentSymlink");function xu(e,t=pe,n=Ye()){let r=z(n,".ev-ai","agent-hook",t),o=z(r,Ae);Ss(r,{recursive:!0}),Su(e,o,{force:!0});try{hu(o,493)}catch{}return RS(r),z(n,".ev-ai","agent-hook",Vo)}s(xu,"pinHookBinary");function Ou(e){let t=gs();if(!t)return;let n=[z(e,_s(t)),z(e,"packages","agent-hook",_s(t))];for(let r of n)if(ft(r)&&bu(e,r))return r}s(Ou,"resolveDevBundledBinary");function CS(e=Ye()){let t=_S(e);return ft(t)?t:void 0}s(CS,"resolveGlobalBinary");function AS(e,t=Ye()){let n=CS(t);return n||(Au()?xu(process.execPath,pe,t):Ou(e))}s(AS,"resolveBinarySource");function bS(e,t=Ye()){let n=Ou(e);if(!n)throw new Error(`update requires a locally compiled binary \u2014 run this package\u2019s build:hook-binary script first.
|
|
27
|
+
To install a released binary instead: curl -fsSL https://cdn.ev-ai.ai/agent-hook/install.sh | sh`);let r=xu(n,pe,t),o=ku(e,n);return{sourcePath:n,projectPath:o,globalPath:r}}s(bS,"refreshPinnedBinariesFromCompileOut");function _u(e){let t=[z(e,"packages","agent-hook","dist","hook.mjs"),z(e,ec)],n=hS();ft(n)&&bu(e,n)&&t.unshift(n);for(let r of t){if(!ft(r))continue;let o=Mr(Eu(e,r));return{command:SS(o),hookPath:o,strategy:"dev_mjs"}}}s(_u,"resolveDevMjsHook");function kS(e){return e==="SessionStart"||e==="sessionStart"}s(kS,"isSessionStartEvent");function xS(e){return e.replace(/\s+--prefer-offline\b/g,"")}s(xS,"withoutPreferOffline");function Nr(e,t){return kS(e)?xS(t):t}s(Nr,"commandForEvent");function OS(e=Er){return`npx -y --prefer-offline ${e}`}s(OS,"npxHookCommand");function IS(e,t=Ye(),n=Cu()){if(n==="npx")return{command:OS(),hookPath:Er,strategy:"npx"};if(n==="local"){let i=_u(e);if(i)return i;throw new Error("local delivery requires packages/agent-hook/dist/hook.mjs (or node_modules/@ev-ai/agent-hook/dist/hook.mjs) under the git root \u2014 run yarn workspace @ev-ai/agent-hook build first")}let r=AS(e,t);if(r){ku(e,r);let i=Mr(Wo);return{command:ES(i),hookPath:i,strategy:"project_binary"}}let o=_u(e);if(o)return o;throw new Error(`ev-ai-agent-hook binary not found. Install from CDN:
|
|
28
|
+
curl -fsSL ${tc}/install.sh | sh
|
|
26
29
|
Or use npx delivery:
|
|
27
|
-
npx ${
|
|
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
|
|
30
|
-
`,{encoding:"utf8",flag:"wx"})}catch(o){if(
|
|
31
|
-
`)}catch(n){let r=n instanceof Error?n.message:String(n);
|
|
32
|
-
`)}catch(n){let r=n instanceof Error?n.message:String(n);
|
|
30
|
+
npx ${Er} install`)}s(IS,"resolveHookCommand");function Iu(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(Ae)||/(?:^|[\s/"'])ev-ai-agent-hook(?:$|[\s"'])/.test(e)}s(Iu,"isEvAiHookCommand");function ys(e,t){return`${e.replace(/\s+--runner(?:=|\s+)\S+/g,"").trimEnd()} --runner ${t}`}s(ys,"withRunnerFlag");function dt(e,t){Ss(Es(e),{recursive:!0}),cS(e,`${JSON.stringify(t,null,2)}
|
|
31
|
+
`,"utf8")}s(dt,"writeJson");function Xe(e){if(ft(e))try{return JSON.parse(iS(e,"utf8"))}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON in ${e} \u2014 fix or remove the file`,{cause:t}):t}}s(Xe,"readJson");function TS(e,t){let n=pu(t.collectorUrl),r={...e,schema_version:e?.schema_version??n.schema_version};return t.collectorUrl!==void 0?r.collector_url=t.collectorUrl:r.collector_url=e?.collector_url??n.collector_url,delete r.repo_ingest_token,delete r.installation_id,r.mcp_servers??=n.mcp_servers,r}s(TS,"mergeManifestForInstall");function PS(e){return(e.schema_version??at)===at&&e.collector_url===void 0&&(e.mcp_servers?.length??0)===0&&e.platform_agent_id===void 0&&e.capture_hook_input===void 0&&e.debug===void 0&&e.repo_ingest_token===void 0}s(PS,"isDefaultSharedManifest");function Tu(e,t){let n=z(e,fr),r=Xe(n),o=TS(r,t);return t.collectorUrl!==void 0||ft(n)||!PS(o)?(dt(n,o),{manifestPath:n,wrote:!0}):{manifestPath:void 0,wrote:!1}}s(Tu,"upsertSharedManifest");function hs(e){if(e===null||typeof e!="object")return!1;let t=e,n=String(t.CLAUDE_CODE_ENABLE_TELEMETRY??"").toLowerCase();return n==="1"||n==="true"?!0:Object.keys(t).some(r=>r.startsWith("OTEL_"))}s(hs,"envHasOtel");function wS(e){if(hs(process.env))return!0;let t=Ye();return[...Yo(),z(t,".claude","settings.json"),z(t,".claude","remote-settings.json"),z(e,".claude","settings.json"),z(e,".claude","settings.local.json")].some(r=>{try{let o=Xe(r);return o?hs(o.env):!1}catch{return!1}})}s(wS,"claudeOtelEnabled");function NS(e){try{let t=Xe(z(e,".claude","settings.json"));return t?hs(t.env):!1}catch{return!1}}s(NS,"projectClaudeOtelEnabled");function Pu(e){return Array.isArray(e)?e:[]}s(Pu,"asMatcherGroups");function Lr(e){let t=[],n=s(r=>!!r&&typeof r=="object"&&Iu(r.command),"isOwnedHook");for(let r of Pu(e)){if(!r||typeof r!="object"){t.push(r);continue}let o=Array.isArray(r.hooks)?r.hooks:[],i=o.filter(a=>!n(a));if(!(i.length===0&&o.some(n))){if(i.length!==o.length){t.push({...r,hooks:i});continue}t.push(r)}}return t}s(Lr,"stripEvAiMatcherGroups");function wu(e,t){return[...Lr(e),...t]}s(wu,"mergeMatcherHookEvents");function Rs(e){return Array.isArray(e)?e.filter(t=>!t||typeof t!="object"?!0:!Iu(t.command)):[]}s(Rs,"stripEvAiCursorHooks");function vS(e,t){return[...Rs(e),{command:t}]}s(vS,"mergeCursorEventHooks");function MS(e){return typeof e=="string"?[e]:e}s(MS,"toCommandList");function LS(e){let t=s((n="")=>({hooks:MS(e).map(r=>({type:"command",command:Nr(n,r)}))}),"commandHook");return{SessionStart:[t("SessionStart")],UserPromptExpansion:[t()],UserPromptSubmit:[t()],PreToolUse:[t()],PostToolUse:[t()],PostToolUseFailure:[t()],PermissionDenied:[t()],Stop:[t()],StopFailure:[t()],SessionEnd:[t()],SubagentStart:[t()],SubagentStop:[t()]}}s(LS,"desiredClaudeHookGroups");function HS(e){let t=typeof e=="string"?{command:e}:e,n=s((r="")=>({hooks:[{type:"command",command:Nr(r,t.command),...t.commandWindows===void 0?{}:{commandWindows:Nr(r,t.commandWindows)},statusMessage:ac}]}),"commandHook");return{SessionStart:[n("SessionStart")],UserPromptSubmit:[n()],PreToolUse:[n()],PostToolUse:[n()],Stop:[n()],SubagentStart:[n()],SubagentStop:[n()]}}s(HS,"desiredCodexHookGroups");var US=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","postToolUseFailure","beforeShellExecution","beforeReadFile","beforeMCPExecution","subagentStart","subagentStop","stop"],DS=["afterShellExecution","afterFileEdit"];function FS(e,t=DS){let n={...e};for(let r of t){if(!(r in n))continue;let o=Rs(n[r]);o.length===0?delete n[r]:n[r]=o}return n}s(FS,"stripRetiredCursorEvAiEvents");function $S(e,t,n={}){let r=z(e,".claude/settings.json"),o=ys(t,"claude"),i=Xe(r)??{};if(wS(e)&&!n.force){if(i.hooks&&typeof i.hooks=="object"){let l={...i.hooks};for(let d of Object.keys(l))l[d]=Lr(l[d]),Pu(l[d]).length===0&&delete l[d];Object.keys(l).length===0?delete i.hooks:i.hooks=l,dt(r,i)}return!1}let c=i.hooks&&typeof i.hooks=="object"?i.hooks:{},u=LS(o),f={...c};for(let[l,d]of Object.entries(u))f[l]=wu(c[l],d);return i.hooks=f,dt(r,i),!0}s($S,"updateClaudeSettings");function jS(e,t){let n=z(e,".cursor/hooks.json"),r=ys(t,"cursor"),o=Xe(n)??{},i=o.hooks&&typeof o.hooks=="object"?o.hooks:{},a=FS({...i});for(let c of US)a[c]=vS(a[c],Nr(c,r));dt(n,{...o,version:typeof o.version=="number"?o.version:1,hooks:a})}s(jS,"updateCursorHooks");function BS(e,t){let n=z(e,".codex/hooks.json"),r=ys(t,"codex"),o=Xe(n)??{},i=o.hooks&&typeof o.hooks=="object"?o.hooks:{},a=HS(r),c={...i};for(let[u,f]of Object.entries(a))c[u]=wu(i[u],f);dt(n,{...o,hooks:c})}s(BS,"updateCodexHooks");function KS(e){let t=z(e,".claude/settings.json"),n=Xe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1;for(let i of Object.keys(r)){let a=r[i],c=Lr(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:r[i]=c}o&&(Object.keys(r).length===0?delete n.hooks:n.hooks=r,dt(t,n),y(`Removed ev-ai hooks from ${t}`))}s(KS,"stripEvAiFromClaudeSettings");function GS(e){let t=z(e,".cursor/hooks.json"),n=Xe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,i=0;for(let a of Object.keys(r)){let c=r[a],u=Rs(c);JSON.stringify(c)!==JSON.stringify(u)&&(o=!0),u.length===0?delete r[a]:(r[a]=u,i+=u.length)}if(o){if(i===0&&Object.keys(r).length===0&&Object.keys(n).filter(c=>c!=="hooks"&&c!=="version").length===0){vr(t,{force:!0}),y(`Removed ${t}`);return}dt(t,{...n,hooks:r}),y(`Removed ev-ai hooks from ${t}`)}}s(GS,"stripEvAiFromCursorHooks");function VS(e){let t=z(e,".codex/hooks.json"),n=Xe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,i=0;for(let a of Object.keys(r)){let c=r[a],u=Lr(c);JSON.stringify(c)!==JSON.stringify(u)&&(o=!0),u.length===0?delete r[a]:(r[a]=u,i+=u.length)}if(o){if(i===0&&Object.keys(r).length===0&&Object.keys(n).filter(c=>c!=="hooks").length===0){vr(t,{force:!0}),y(`Removed ${t}`);return}dt(t,{...n,hooks:r}),y(`Removed ev-ai hooks from ${t}`)}}s(VS,"stripEvAiFromCodexHooks");function Cs(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)&&mu(e,t)}s(Cs,"assertInstallSupported");async function Nu(e={}){let t=mS(e);e.collectorUrl=t;let n=e.skipClaude===!0,r=e.skipCursor===!0,o=e.skipCodex===!0;if(n&&r&&o)throw new Error("at least one runner must be wired; refuse --no-claude --no-cursor --no-codex together");let i=e.delivery??Cu();Cs(process.platform,process.arch,{requireBinaryArch:i==="binary"});let a=e.cwd??process.cwd(),c=await Ve(a),{command:u,hookPath:f,strategy:l}=IS(c,Ye(),i),{installationId:d,storePath:p}=await wr(c,{overrideId:e.installationId}),{manifestPath:m,wrote:_}=Tu(c,e),h=[];return n?y("Skipped Claude hook \u2014 --no-claude"):$S(c,u,{force:e.force})?(h.push("Claude"),e.force&&NS(c)&&y("Forced Claude hook despite project native OTEL \u2014 expect duplicate session/tool events")):y("Skipped Claude hook \u2014 native OTEL telemetry already enabled (avoids duplicate events); pass --force to wire anyway"),r?y("Skipped Cursor hook \u2014 --no-cursor"):(jS(c,u),h.push("Cursor")),o?y("Skipped Codex hook \u2014 --no-codex"):(BS(c,u),h.push("Codex")),y(`Installed hook (${l}) at ${f}`),y(`Installation identity ${d} at ${p}`),_&&m?y(`Shared manifest written to ${m}`):y("Using package default collector config (no shared manifest file needed)"),y(h.length>0?`Wired ${h.join(", ")} hooks in ${c} (commands include --runner)`:`No runner hooks wired in ${c} (Claude skipped by OTEL; Cursor/Codex excluded via flags)`),l==="npx"?y("Hook commands use npx and may be committed; teammates need Node on PATH only (no install step, no env vars when collector_url is in the shared manifest)."):l==="project_binary"?y("Hook commands are git-root-relative and may be committed; each collaborator runs install once to populate .ev-ai/agent-hook/ (gitignored)."):l==="dev_mjs"&&y("Hook commands use node + monorepo packages/agent-hook/dist/hook.mjs (local delivery; rebuild with yarn workspace @ev-ai/agent-hook build)."),_&&m&&e.collectorUrl&&y("Shared manifest includes collector_url \u2014 commit it with hook configs so teammates post without env vars."),{gitRoot:c,hookPath:f,manifestPath:m,installationStorePath:p,strategy:l}}s(Nu,"installAgentHook");async function vu(e=process.cwd()){Cs(process.platform,process.arch,{requireBinaryArch:!0});let t=await Ve(e),{projectPath:n,globalPath:r}=bS(t);y(`Refreshed ${r}`),y(`Refreshed ${n}`),y("Hook configs and shared manifest left unchanged")}s(vu,"updateAgentHook");async function Mu(e={}){let t=pS(e);e.collectorUrl=t,Cs(process.platform,process.arch,{requireBinaryArch:!1});let n=e.cwd??process.cwd(),r=await Ve(n),{manifestPath:o,wrote:i}=Tu(r,e);if(t!==void 0&&(!o||!i))throw new Error("configure failed to write shared collector manifest");return i&&o?y(`Wrote ${o}`):t===void 0&&y("No --url given and no shared manifest yet \u2014 pass --url <\u2026/{orgToken}/hook> to write collector destination."),y("Manifest only \u2014 enable ev-ai marketplace plugins. Do not also run file-wiring install for the same events."),{gitRoot:r,manifestPath:o}}s(Mu,"configureAgentHook");function Lu(e){for(let t of[()=>KS(e),()=>GS(e),()=>VS(e)])try{t()}catch(n){let r=n instanceof Error?n.message:String(n);y(`WARN: strip skipped a hook file: ${r}`)}}s(Lu,"stripFileWiredEvAiHooks");async function Hu(e=process.cwd()){let t=await Ve(e);return Lu(t),y("Stripped ev-ai file-wired hooks; shared collector manifest left in place."),y("Next: enable ev-ai marketplace plugins, then restart runners."),{gitRoot:t}}s(Hu,"migrateToPlugin");async function Uu(e=process.cwd()){let t=await Ve(e);Lu(t);for(let n of dr){let r=z(t,n);if(ft(r))try{vr(r,{force:!0}),y(`Removed ${r}`)}catch(o){let i=o instanceof Error?o.message:String(o);y(`WARN: uninstall could not remove ${r}: ${i}`)}}}s(Uu,"uninstallAgentHook");import{existsSync as yR,mkdirSync as RR,readdirSync as CR,readFileSync as AR,unlinkSync as $l,writeFileSync as bR}from"node:fs";import{homedir as jl}from"node:os";import{join as Hs}from"node:path";import{existsSync as nE}from"node:fs";import{existsSync as WS}from"node:fs";import{homedir as Fu}from"node:os";import{join as zS}from"node:path";function $u(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}s($u,"hookParsableSettings");var JS={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 Du(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}s(Du,"concatOptional");function YS(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:Du(n.mcpJson,t.mcpJson),mcpToml:Du(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}s(YS,"layoutForScope");function ju(e){return Object.fromEntries(Object.entries(JS).map(([t,n])=>[t,YS(n,n[e])]))}s(ju,"layoutsForScope");var Jt=ju("homeOnly"),mt=ju("projectOnly");function XS(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}s(XS,"layoutRelativePaths");function qS(e,t){return XS(e).some(n=>WS(zS(t,n)))}s(qS,"layoutHasAnyEntry");function Bu(e,t){for(let n of e)if(qS(n,t))return!0;return!1}s(Bu,"anyLayoutHasAnyEntry");function pt(e){return[...new Set(e)]}s(pt,"uniqueRels");function gt(e){let t=[],n=[],r=[],o=[],i=[],a=[],c=[];for(let u of e){t.push(...u.skillRoots);for(let f of u.dirs)f.kind==="SUBAGENT"?n.push(f.dir):f.kind==="COMMAND"?r.push(f.dir):o.push(f.dir);i.push(...u.memory.flat()),a.push(...u.settings),c.push(...u.mcpJson??[],...u.mcpToml??[])}return{skills:pt(t),subagents:pt(n),commands:pt(r),rules:pt(o),memory:pt(i),settings:pt(a),mcp:pt(c)}}s(gt,"userScopePathsFromLayouts");function ZS(e,t=Fu(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...Rr(o.managed,n,t));return pt(r)}s(ZS,"managedSettingsFromLayouts");var _t=gt(Object.values(Jt));function Ku(e=Fu(),t=process.platform){return ZS(Object.values(Jt),e,t)}s(Ku,"userScopeManagedSettings");import{existsSync as QS}from"node:fs";import{resolve as As}from"node:path";function ke(e){return As(e).replaceAll("\\","/").replace(/\/$/,"")}s(ke,"posixAbs");function It(e,t){let n=new Set(t),r=[];for(let o of e)n.delete(o)&&r.push(o);for(let o of[...n].sort())r.push(o);return r}s(It,"uniqueOrderedRoots");function Hr(e,t){if(!e)return t;let n=`${e}/`,r=[],o=[];for(let i of t)i===e||i.startsWith(n)?r.push(i):o.push(i);return r.length===0?t:[...r,...o]}s(Hr,"preferMarkerDirRoots");var eE=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function xn(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!eE.test(t)?null:t}s(xn,"sanitizeComponentRelativePath");function Yt(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let i=ke(o);n.has(i)||(n.add(i),r.push(i))}return r}s(Yt,"projectAnchors");function tE(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}s(tE,"isInside");function He(e,t,n,r=QS){for(let o of e)for(let i of t){let a=ke(As(o,i)),c=As(o,i,n).replaceAll("\\","/");if(tE(a,c)&&r(c))return c}return null}s(He,"firstExistingUnderRoots");var Vu=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Wu=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,rE=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,Gu=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"]),oE=/^[a-z][a-z0-9-]{1,63}$/,sE=[".cursor/skills",".claude/skills",".agents/skills"],iE=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],aE=It(sE,gt(Object.values(mt)).skills),cE=It(iE,gt(Object.values(Jt)).skills),uE=new Set(["read","read_file","view"]),lE=new Set(["bash","shell","zsh"]);function bs(e){let t=e.replace(/\\/g,"/");return Vu.exec(t)?.[1]??null}s(bs,"skillIdFromSkillMdPath");function fE(e){let t=e.replace(/\\/g,"/"),r=Wu.exec(t)?.[1];return r?r.toLowerCase():null}s(fE,"skillIdFromCodexCommandPath");function dE(e){return bs(e)??fE(e)}s(dE,"skillIdFromReferencedPath");function pE(e){for(let t of["path","file_path","target_file"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}return null}s(pE,"pathFromToolInputRecord");function Ur(e){return typeof e=="string"?Ur(Te(e,null)):!e||typeof e!="object"?null:pE(e)}s(Ur,"pathFromToolInput");function zu(e){if(typeof e=="string")return zu(Te(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}s(zu,"commandFromToolInput");function ks(e){let t=zu(e.tool_input);if(t)return t;let n=Ct(e.command);return n.length>0?n:null}s(ks,"commandFromHookInput");function mE(e){let t=e.replace(/\\/g,"/"),n=Vu.exec(t);if(n?.[1])return n[1];let o=Wu.exec(t)?.[1];return o?o.toLowerCase():null}s(mE,"skillIdFromShellCommand");function gE(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}s(gE,"toolNameFromHookInput");function xs(e){let t=Ur(e.tool_input)??Ct(e.file_path);return t.length>0?t:null}s(xs,"filePathFromHookInput");function On(e,t,n){let r=gE(e).toLowerCase();if(uE.has(r)){let o=xs(e);return o?t(o):null}if(lE.has(r)){let o=ks(e);return o?n(o):null}return null}s(On,"nameFromReadOrShellHookInput");function Ju(e){return On(e,dE,mE)}s(Ju,"skillNameFromReadHookInput");function _E(e){let t=new Set,n=[];for(let r of e.matchAll(rE)){let o=r[1]?.toLowerCase();!o||t.has(o)||hE(o)||(t.add(o),n.push(o))}return n}s(_E,"extractSlashSkillNames");function hE(e){let t=e.split("/")[0];return Gu.has(e)||t!==void 0&&Gu.has(t)}s(hE,"isDeniedSlashId");function Yu(e){let t=e.skillId.toLowerCase();if(!oE.test(t))return null;let n=e.exists??nE,r=`${t}/SKILL.md`,o=He(Yt(e.launchCwd,e.gitRoot),aE,r,n);return o!==null?o:e.home?He([ke(e.home)],cE,r,n):null}s(Yu,"resolveSkillMdPath");function SE(e){return Ct(e.prompt)}s(SE,"promptFromHookInput");function Xu(e){let t=F(e,"command_name");if(t){let r=F(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=SE(e);return n?_E(n):[]}s(Xu,"skillNamesFromHookInput");var Ns=ot(St(),1);import{existsSync as Vy}from"node:fs";var Pt={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function Tn(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}s(Tn,"normalizePathSlug");function Gy(e){if(!e)return"";let t=hn(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return Tn(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return Tn(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?Tn(o[1]):Tn(t)}s(Gy,"normalizeGitRemoteToSlug");async function Gr(e=process.cwd()){let t=await Ie("git",["rev-parse","--is-inside-work-tree"],2e3,{cwd:e});if(!t.ok||t.stdout!=="true")return null;let[n,r,o,i]=await Promise.all([Ie("git",["remote","get-url","origin"],2e3,{cwd:e}),Ie("git",["branch","--show-current"],2e3,{cwd:e}),Ie("git",["rev-parse","HEAD"],2e3,{cwd:e}),Ie("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?hn(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:i.ok?i.stdout.length>0:null}}s(Gr,"gitSnapshot");async function Rl(e,t,n,r=process.cwd(),o,i,a){if(t)return t;let c=Pt[n];if(!c)return"";let u=Jc(n,e.scope_path,a);if(i){let _=nu(i,u);if(_)return _}let f=o??await Gr(r),l=f?.remote?Gy(f.remote):"";if(l||(l=Tn(process.env.GITHUB_REPOSITORY??"")),!l)return"";let d=e.scope_path??"",p=d?`${d}/`:"",m=`${l}:${p}${c}`;return i&&ru(i,u,m),m}s(Rl,"derivePlatformAgentId");var Wy=[".cursor/rules",".claude/rules",".codex/rules"],zy=gt(Object.values(mt)).rules;function Jy(e){return It(Hr(e?Pt[e]:void 0,Wy),zy)}s(Jy,"ruleRootsForRunner");var Yy=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function Cl(e){let t=xn(e.relativePath);if(!t)return null;let n=e.exists??Vy,r=Yt(e.launchCwd,e.gitRoot),o=Jy(e.runnerPlatform),i=He(r,o,t,n);if(i!==null)return i;if(!t.includes("/")){let a=He(r,["."],t,n);if(a!==null)return a}return e.home?He([ke(e.home)],o,t,n):null}s(Cl,"resolveRuleMdPath");function Xy(e){let t=e.replace(/\\/g,"/"),r=Yy.exec(t)?.[1];return r?(0,Ns.nativeKeyForRulePath)(r):null}s(Xy,"ruleNameFromShellCommand");function Al(e){return On(e,Ns.nativeKeyForRulePath,Xy)}s(Al,"ruleNameFromReadHookInput");function bl(e){return e.replace(/\.(mdc|md|rules)$/i,"")}s(bl,"stripRuleExtension");function kl(e){let t=e.attachments;if(!Array.isArray(t))return[];let n=new Set,r=[];for(let o of t){if(!o||typeof o!="object"||Array.isArray(o))continue;let i=o;if(i.type!=="rule")continue;let a=typeof i.file_path=="string"?i.file_path:"",c=xn(a);!c||n.has(c)||(n.add(c),r.push(c))}return r}s(kl,"ruleAttachmentPathsFromHookInput");var vs=ot(St(),1);import{existsSync as qy}from"node:fs";var Zy=[".cursor/commands",".claude/commands",".codex/prompts"],Qy=gt(Object.values(mt)).commands;function eR(e){return It(Hr(e?Pt[e]:void 0,Zy),Qy)}s(eR,"commandRootsForRunner");var tR=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function xl(e){let t=xn(e.commandId);if(!t)return null;let n=e.exists??qy,r=`${t}.md`,o=eR(e.runnerPlatform),i=He(Yt(e.launchCwd,e.gitRoot),o,r,n);return i!==null?i:e.home?He([ke(e.home)],o,r,n):null}s(xl,"resolveCommandMdPath");function nR(e){let t=e.replace(/\\/g,"/"),r=tR.exec(t)?.[1];return r?(0,vs.nativeKeyForCommandPath)(r):null}s(nR,"commandNameFromShellCommand");function Ol(e){return On(e,vs.nativeKeyForCommandPath,nR)}s(Ol,"commandNameFromReadHookInput");var Vr=ot(St(),1);function Il(e,t){if(F(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}s(Il,"cursorShapedPayload");function rR(){return!!(D("CURSOR_VERSION")??D("CURSOR_PROJECT_DIR"))}s(rR,"isCursorHostEnv");function Tl(e,t,n){return e!=="claude"&&e!=="codex"?!1:Il(t,n)?!0:rR()}s(Tl,"shouldSuppressForeignRunnerOnCursorHost");var oR=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function Zt(e,t,n,r){return Il(e,t)?"cursor":pr(r)?r:pr(n)?n:F(e,"turn_id")?"codex":F(e,"session_id")||oR.has(t.toLowerCase())?"claude":"unknown"}s(Zt,"detectRunnerPlatform");function Wr(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}s(Wr,"isInProcessEvent");function sR(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""}}s(sR,"mapRunnerEventToInternal");function Pl(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}s(Pl,"isPromptSubmitRunnerEvent");function wl(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}s(wl,"suppressesSlashIds");function Nl(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}s(Nl,"toolSuccessFromRunnerEvent");function Qt(e){return F(e,"session_id")||F(e,"conversation_id")}s(Qt,"sessionIdFromHookInput");function Ms(e){return F(e,"prompt.id")||F(e,"prompt_id")||F(e,"generation_id")||F(e,"turn_id")}s(Ms,"turnIdFromHookInput");function Ls(e){return F(e,"hook_event_name")||F(e,"event")}s(Ls,"runnerEventFromHookInput");function vl(e,t,n){let r=Qt(e),o=Ms(e),i=Ls(e),a=F(e,"source"),c=Zt(e,i,t,n);return{sessionId:r,turnId:o,runnerEvent:i,hookSource:a,runnerPlatform:c}}s(vl,"normalizeHookFields");var iR=["session_start","session_end","tool_invoked","skill_invoked"];function aR(e){return iR.includes(e)}s(aR,"isKnownInternalEvent");function zr(e,t){return e&&aR(e)?e:sR(t.toLowerCase())}s(zr,"resolveInternalEvent");var cR={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function Jr(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}s(Jr,"isMcpShapedToolName");function Ml(e,t=""){let n=F(e,"tool_name")||F(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!Jr(n)&&(n=`MCP:${n}`):n=cR[r]??null;let o=e.tool_input,a=(o&&typeof o=="object"?Ct(o.skill)||Ct(o.skill_name):"")||F(e,"skill_name")||null,c=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;a??=Ju(c);let u=Al(c),f=Ol(c);return{toolName:n,skillName:a,ruleName:u,commandName:f}}s(Ml,"extractToolNames");var uR=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function Ll(e){for(let t of["subagent_type","agent_type"]){let n=F(e,t);if(n&&uR.test(n))return n}return null}s(Ll,"extractSubagentType");function Hl(e){let t=We(e,"duration_ms");if(typeof t=="number")return t;let n=We(e,"duration");return typeof n=="number"?n:null}s(Hl,"extractDurationMs");var lR="error",fR="interrupted",dR="permission_denied",pR=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function Pn(e){return pR.test(e)?e:null}s(Pn,"categoricalValue");function mR(e){for(let t of["failure_type","error_type"]){let n=Pn(F(e,t));if(n)return n}return null}s(mR,"structuredFailureClass");function Ul(e,t){return We(e,"is_interrupt")===!0?fR:t.toLowerCase()==="permissiondenied"?dR:mR(e)??lR}s(Ul,"extractFailureClass");function Dl(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}s(Dl,"longestDeclaredServer");function gR(e,t){return Dl(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}s(gR,"matchDeclaredMcpServer");function _R(e,t){return Dl(t,n=>(0,Vr.mcpServerNameMatchesToolSegment)(n,e))}s(_R,"matchDeclaredMcpServerSegment");function hR(e,t){let n=null,r=0;for(let i of t)if(i)for(let a of(0,Vr.mcpServerToolSegmentForms)(i)){let c=`${a}__`;e.length>c.length&&e.slice(0,c.length).toLowerCase()===c.toLowerCase()&&a.length>r&&(n={mcpServer:i,mcpTool:e.slice(c.length)},r=a.length)}if(n!==null)return n;let o=/^(.+?)__(.+)$/.exec(e);return!o?.[1]||!o[2]?{mcpServer:null,mcpTool:null}:{mcpServer:_R(o[1],t)??o[1],mcpTool:o[2]}}s(hR,"parseClaudeMcpNames");function SR(e,t){if(/^mcp__/i.test(e))return hR(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:gR(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}s(SR,"parseMcpNamesFromToolName");function ER(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}s(ER,"stripEncodedMcpServerPrefix");function Fl(e,t=[],n=""){let r=e?SR(e,t):{mcpServer:null,mcpTool:null},o=Pn(n.trim());if(!o)return r;let i=r.mcpTool;return!i&&e&&!Jr(e)&&(i=e),i&&(i=ER(i,o)),{mcpServer:o,mcpTool:i}}s(Fl,"extractMcpNames");var Bl=3e4,kR="claims",xR=!0,OR=100,IR=new Set(["sessionstart","sessionend","stopfailure"]),TR=["tool_name","tool","command","file_path","url"];function PR(e=jl()){return Hs(Re(e),kR)}s(PR,"eventClaimDir");function Kl(e,t){try{let n=AR(e,"utf8").split(`
|
|
32
|
+
`,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}s(Kl,"claimAgeMs");function wR(e){let t=[];for(let n of TR){let r=F(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":Sn(t.join("\0"))}s(wR,"callFingerprintFromHookInput");function NR(e){let t=e.sessionId.trim();if(!t)return;let n=e.runnerEvent.trim().toLowerCase(),r=e.turnId.trim(),o=e.toolUseId.trim(),i=e.subagentId?.trim()??"",a=e.callFingerprint?.trim()??"",c=!!(o||r||i),u=IR.has(n);if(!c&&!u)return;let f=e.runnerPlatform.trim()||"unknown";return Sn(`${f}|${t}|${n}|${r}|${o}|${a}|${i}`)}s(NR,"eventClaimKey");function vR(e,t=Date.now()){let n;try{n=CR(e)}catch{return}let r=0;for(let o of n){if(r>=OR)break;r+=1;let i=Hs(e,o),a=Kl(i,t);if(!(!Number.isFinite(a)||a<Bl))try{$l(i)}catch{}}}s(vR,"pruneStaleEventClaims");function MR(e,t,n=Date.now()){let r=Hs(t,e);try{if(yR(r)){let o=Kl(r,n);if(Number.isFinite(o)&&o>=0&&o<Bl)return!1;try{$l(r)}catch(i){if(!(i instanceof Error&&"code"in i&&i.code==="ENOENT"))return L("event_claim_steal",i),!0}}}catch{}try{RR(t,{recursive:!0}),bR(r,`${n}
|
|
33
|
+
`,{encoding:"utf8",flag:"wx"})}catch(o){if(gn(o))return!1;let i=o instanceof Error?o.message:String(o);return y(`WARN: event claim failed open: ${i}`),L("event_claim",o),!0}return vR(t,n),!0}s(MR,"tryClaimHookEvent");function LR(e,t,n){let r=Qt(e),o=Ms(e),i=F(e,"tool_use_id"),a=F(e,"subagent_id")||F(e,"agent_id"),c=Zt(e,t,void 0,n),u=wR(e);return{runnerPlatform:c,sessionId:r,runnerEvent:t,turnId:o,toolUseId:i,subagentId:a,callFingerprint:u}}s(LR,"identityFromHookInput");function Gl(e,t,n,r=jl(),o=Date.now()){if(!xR)return!0;let i=NR(LR(e,t,n));if(!i)return!0;let a=MR(i,PR(r),o);return!a&&D("EV_AI_HOOK_DEBUG")&&y(`DEBUG: duplicate hook event suppressed (claim ${i.slice(0,8)}\u2026)`),a}s(Gl,"claimHookEvent");import{mkdirSync as HR,readFileSync as Us,statSync as Jl,unlinkSync as Yl,writeFileSync as Ds}from"node:fs";import{homedir as Xl}from"node:os";function ql(e){return e==="session_start"||e==="session_end"}s(ql,"isCapExemptEvent");var Yr=new Set,Vl=!1;function Fs(e=Xl()){return Oa(e)}s(Fs,"hookSlotDir");function $s(e,t=Xl(),n=process.platform){if(e!==void 0)return e>0?e:rr(n);let r=Q(At(t),{});return Ya(r)??rr(n)}s($s,"maxConcurrentHookProcesses");function wn(e){return ir(e.pid,e.acquiredAtMs)}s(wn,"slotContent");function Zl(e){try{let t=Jl(e);return t.isFile()&&t.size<=Uo?Us(e,"utf8"):void 0}catch{return}}s(Zl,"readSlotText");function js(e,t=Fs()){if(!e)return;let n=sr(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=Zl(n);if(o===wn(r))return Xr(r);if(o===ir(process.ppid,e.acquiredAtMs))try{return Ds(n,wn(r),{encoding:"utf8",mode:384}),Xr(r)}catch{return}}s(js,"adoptHookSlot");function Ql(e,t){if(e.path){Yr.delete(e);try{Zl(e.path)===wn(e)&&Ds(e.path,ir(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}s(Ql,"handOffHookSlot");function ef(e,t=Date.now()){let n,r;try{let o=Jl(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=Uo?Us(e,"utf8"):""}catch{return!1}return Ta(n,r,t)}s(ef,"isSlotHeld");function tf(e,t=Fs(),n=Date.now){for(let r=0;r<e;r+=1)if(!ef(sr(t,r),n()))return!0;return e<=0}s(tf,"hasFreeHookSlot");function nf(e){return{pid:process.pid,acquiredAtMs:e}}s(nf,"noopSlot");function Wl(e,t){let n=e instanceof Error?e.message:String(e);return y(`WARN: hook process slot failed open: ${n}`),L("slot",e),nf(t)}s(Wl,"failOpen");function Xr(e){return Yr.add(e),Vl||(Vl=!0,process.once("exit",()=>{for(let t of[...Yr])qr(t)})),e}s(Xr,"hold");function zl(e){try{return Ds(e.path,wn(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(gn(t))return!1;throw t}}s(zl,"tryCreateSlot");function rf(e,t=Fs(),n=Date.now){if(e<=0)return nf(n());try{HR(t,{recursive:!0})}catch(i){return Wl(i,n())}let r,o=0;for(let i=0;i<e;i+=1)try{let a={path:sr(t,i),pid:process.pid,acquiredAtMs:n()};if(zl(a))return Xr(a);if(ef(a.path,n())){o+=1;continue}try{Yl(a.path)}catch(c){if(!Ft(c))throw c}if(a.acquiredAtMs=n(),zl(a))return Xr(a);o+=1}catch(a){r??=a}return r!==void 0&&o>0&&L("slot",r),r===void 0||o>0?null:Wl(r,n())}s(rf,"tryAcquireHookSlot");function qr(e,t=Date.now()){if(Yr.delete(e),!(!e.path||t-e.acquiredAtMs>=or-_n))try{Us(e.path,"utf8")===wn(e)&&Yl(e.path)}catch{}}s(qr,"releaseHookSlot");function Bs(e){D("EV_AI_HOOK_DEBUG")&&y(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}s(Bs,"logHookCapReached");import{closeSync as UR,writeSync as DR}from"node:fs";function of(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{DR(n,ha)}catch{}try{UR(n)}catch{}}}s(of,"signalLauncherReady");function Ks(e=process.env){let t=e[da];if(t)return{launcherVersion:t,hookSource:e[pa]??"",fallbackReason:e[ma],launcherScope:e[ga]}}s(Ks,"readLauncherContext");function sf(e,t){return(e?bt(e):void 0)===t}s(sf,"launcherScopeMatch");import{readFileSync as FR,statSync as $R}from"node:fs";import{homedir as jR}from"node:os";import{join as BR}from"node:path";var KR="perf-prev.json",GR=512,VR=1440*60*1e3,WR=12e4,zR=50,Nn={},af=!1;function Vs(e){return Math.round(e*10)/10}s(Vs,"round1");function De(e,t){if(!bn())return t();let n=performance.now();return t().finally(()=>{Nn[e]=Vs(performance.now()-n)})}s(De,"span");function JR(){for(let e of Object.keys(Nn))delete Nn[e]}s(JR,"clearSpans");function uf(){if(!bn())return;let e=kc();e&&(process.env[Zo]=e)}s(uf,"handOffHookTimings");function cf(e,t){if(!e)return;let n=t-e.origin;return n>=-zR&&n<=WR?e:void 0}s(cf,"trusted");function YR(e){if(e===null||typeof e!="object")return!1;let t=e;return typeof t.at=="number"&&Number.isFinite(t.at)&&typeof t.post_ms=="number"&&Number.isFinite(t.post_ms)&&t.post_ms>=0}s(YR,"isPrevPost");function lf(e=jR()){return BR(Re(e),KR)}s(lf,"perfPrevPath");function XR(e,t){if(!af){af=!0;try{let n=lf(t);if($R(n).size>GR)return;let r=JSON.parse(FR(n,"utf8"));return!YR(r)||e-r.at>VR?void 0:{at:r.at,post_ms:r.post_ms}}catch{return}}}s(XR,"takePrevPost");function Ws(e,t){if(!bn())return;let n={at:Date.now(),post_ms:Math.max(0,Math.round(e))};try{ue(lf(t),JSON.stringify(n))}catch{}}s(Ws,"recordPostDuration");function Gs(e,t,n,r,o=n.marks){let i=Math.max(0,n.origin-r);e[t]=Vs(i);for(let[a,c]of Object.entries(o))e[a]=Vs(i+c)}s(Gs,"addProcess");function ff(e,t=process.env,n,r=!1){let o=r?fc():void 0;if(!bn())return o?{sys:o}:void 0;let i=Ac(),a="w0"in i.marks?"w":"h",c=a==="w"?cf(Qo(t[Zo]),i.origin):void 0,u=cf(Qo(t[Rc]),(c??i).origin),f=u?"l":c?"h":a,l=(u??c??i).origin,d={};u&&Gs(d,"l",u,l),c&&Gs(d,"h",c,l),Gs(d,a,i,l,{...i.marks,...e});let p={base:f,t:d};a==="w"&&c&&d.h3!==void 0&&(p.ack_ms=d.h3),u?.values.bootstrap===1&&(p.bootstrap=!0),Object.keys(Nn).length>0&&(p.spans={...Nn},JR());let m=XR(Date.now(),n);return m&&(p.prev=m),o&&(p.sys=o),p}s(ff,"buildPerf");import{realpathSync as IO}from"node:fs";import{homedir as TO}from"node:os";var V=ot(St(),1);import{existsSync as qR,readFileSync as ZR}from"node:fs";import{homedir as df}from"node:os";import{join as QR}from"node:path";var eC="cloud-cache.json",tC=1440*60*1e3,nC=900*1e3;function rC(e=df()){return QR(Re(e),eC)}s(rC,"cloudCachePath");function oC(e){if(!qR(e))return;let t=Te(ZR(e,"utf8"),{});if(!(typeof t.context!="string"||typeof t.probed_at!="number"||t.result!==null&&t.result!==void 0&&typeof t.result!="object"))return{context:t.context,probed_at:t.probed_at,result:t.result??null}}s(oC,"readCloudCache");function sC(e,t){try{ue(e,`${JSON.stringify(t)}
|
|
34
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);y(`WARN: cloud cache write failed open: ${r}`),L("cloud_cache",n)}}s(sC,"writeCloudCache");function iC(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?nC:tC;return n-e.probed_at<r}s(iC,"isCacheValid");async function aC(e){let t=await fetch("http://169.254.169.254/latest/api/token",{method:"PUT",headers:{"X-aws-ec2-metadata-token-ttl-seconds":"60"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=(await t.text()).trim();if(!n)return;let r={"X-aws-ec2-metadata-token":n},[o,i]=await Promise.all([fetch("http://169.254.169.254/latest/meta-data/placement/region",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{}),fetch("http://169.254.169.254/latest/meta-data/instance-id",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{})]);if(!o?.ok&&!i?.ok)return;let a=o?.ok?(await o.text()).trim():"",c=i?.ok?(await i.text()).trim():"";if(!(!a&&!c))return{provider:"aws",region:a,instance_id:c}}s(aC,"probeAws");async function cC(e){let t=await fetch("http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true",{headers:{"Metadata-Flavor":"Google"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=typeof n.zone=="string"?n.zone.split("/").pop()??"":"",o=n.id===void 0?"":String(n.id);if(!(!r&&!o))return{provider:"gcp",region:r,instance_id:o}}s(cC,"probeGcp");async function uC(e){let t=await fetch("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{headers:{Metadata:"true"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=n.compute?.location??"",o=n.compute?.vmId??"";if(!(!r&&!o))return{provider:"azure",region:r,instance_id:o}}s(uC,"probeAzure");async function lC(e){let t=await Promise.allSettled([aC(e),cC(e),uC(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}s(lC,"runCloudProbes");async function pf(e,t){if(e==="interactive")return null;let n=t?.home??df(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),i=rC(n),a=oC(i);if(iC(a,e,o))return a.result;let c=await lC(r);return sC(i,{context:e,probed_at:o,result:c}),c}s(pf,"probeCloud");var hf=ot(St(),1);import{existsSync as gf}from"node:fs";import{homedir as _f}from"node:os";import{join as vn,resolve as zs,sep as mf}from"node:path";function Zr(e,t,n){if(!gf(e))return;let r=Q(e,{});for(let[o,i]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:i})}s(Zr,"readMcpServers");function fC(e,t,n){if(!gf(e))return;let r=Q(e,{}),o=zs(t),i=null;for(let c of Object.keys(r.projects??{})){let u=zs(c);(o===u||o.startsWith(u.endsWith(mf)?u:u+mf))&&(i===null||u.length>zs(i).length)&&(i=c)}if(i===null)return;let a=r.projects?.[i]?.mcpServers??{};for(let[c,u]of Object.entries(a))n.set(c,{declared:{name:c,source:"claude_json_project",sourcePath:".claude.json",scope:"user"},config:u})}s(fC,"readClaudeProjectMcpServers");function Sf(e,t,n,r){let o=new Map;for(let i of e.mcp_servers??[])i.name&&o.set(i.name,{declared:{name:i.name,source:"manifest"}});return n==="claude"?(Zr(vn(r,".claude.json"),{source:"claude_json_user"},o),fC(vn(r,".claude.json"),t,o)):n==="cursor"&&Zr(vn(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),Zr(vn(t,".mcp.json"),{source:"mcp_json"},o),Zr(vn(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}s(Sf,"collectMcpServers");async function Js(e,t=process.cwd(),n="claude",r=_f()){return[...Sf(e,t,n,r).values()].map(o=>o.declared)}s(Js,"mcpDeclared");function Ef(e,t,n=process.cwd(),r="claude",o=_f()){let i=Sf(t,n,r,o),a=i.get(e);if(a!==void 0)return a.config??null;for(let[c,u]of i)if((0,hf.mcpServerNameMatchesToolSegment)(c,e))return u.config??null;return null}s(Ef,"mcpServerConfig");var dC=["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"],pC=["CURSOR_PROJECT_DIR"],mC=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function gC(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)mC.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}s(gC,"stripUrlUserinfo");function yf(e=process.env){let t=dC.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:gC(e[r]??"")}:{name:r,present:!1}),n=pC.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}s(yf,"readEnvVars");import{homedir as VC}from"node:os";import{homedir as Rf}from"node:os";import{join as _C}from"node:path";function hC(e=Rf()){return _C(e,".claude.json")}s(hC,"claudeUserConfigPath");function Qr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Qr,"trimString");function Cf(e=Rf()){let n=Q(hC(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=Qr(n.emailAddress),o=Qr(n.fullName)??Qr(n.displayName),i=Qr(n.accountUuid),a=r??i;return!a||ye(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:a,identity_source:"claude_oauth"}}s(Cf,"readClaudeOperatorIdentity");import{homedir as kf}from"node:os";import{join as Af}from"node:path";var SC="https://api.openai.com/auth";function en(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(en,"trimString");function xf(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}s(xf,"asJsonObject");function EC(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 xf(r)}catch{return null}}s(EC,"decodeJwtPayload");function bf(e,t,n){return en(e[n])??en(t?.[n])}s(bf,"claim");function yC(e=process.env,t=kf()){let n=en(e.CODEX_HOME)??Af(t,".codex");return Af(n,"auth.json")}s(yC,"codexAuthPath");function Of(e=process.env,t=kf()){let n=Q(yC(e,t),{}),r=en(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&en(n.OPENAI_API_KEY))return null;let o=en(n.tokens?.id_token);if(!o)return null;let i=EC(o);if(!i)return null;let a=xf(i[SC]),c=bf(i,a,"name"),u=bf(i,a,"email");return!u||ye(c,u)?null:{git_user_name:null,git_user_email:null,platform_login:u,identity_source:"codex_oauth"}}s(Of,"readCodexOperatorIdentity");import{homedir as no}from"node:os";import{join as Qe}from"node:path";import{join as RC}from"node:path";var CC="cursor-ide-identity.json",AC=840*60*1e3;function Tf(e){return RC(Re(e),CC)}s(Tf,"cursorIdeIdentityCachePath");function If(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(If,"nullableString");function Pf(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:If(t.email),auth_id:If(t.auth_id)}}s(Pf,"readCursorIdeIdentityCache");function wf(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<AC}s(wf,"isCursorIdeIdentityCacheFresh");function Nf(e,t){try{ue(e,`${JSON.stringify(t)}
|
|
35
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);y(`WARN: cursor IDE identity cache write failed open: ${r}`),L("cursor_identity_cache",n)}}s(Nf,"writeCursorIdeIdentityCache");import{execFileSync as bC}from"node:child_process";import{existsSync as kC}from"node:fs";import{createRequire as xC}from"node:module";import{pathToFileURL as OC}from"node:url";var Mf=xC(import.meta.url),eo=`
|
|
33
36
|
SELECT key, value
|
|
34
37
|
FROM ItemTable
|
|
35
38
|
WHERE key LIKE 'cursorAuth/%'
|
|
36
39
|
AND key NOT LIKE '%Token%'
|
|
37
40
|
AND key NOT LIKE '%token%'
|
|
38
41
|
ORDER BY key
|
|
39
|
-
`.trim(),
|
|
40
|
-
`)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let
|
|
41
|
-
`);return
|
|
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
|
|
44
|
-
`)){let
|
|
45
|
-
`)){let
|
|
46
|
-
${e}`);if(
|
|
47
|
-
`)){let
|
|
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
|
|
50
|
-
`);return
|
|
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
|
|
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
|
|
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"?
|
|
42
|
+
`.trim(),Ys=new Map;function vf(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:null}if(e instanceof Uint8Array){let t=Buffer.from(e).toString("utf8").trim();return t.length>0?t:null}return null}s(vf,"asText");function Lf(e){return e.toLowerCase().includes("token")}s(Lf,"isTokenKey");function Hf(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=vf(r.key),i=vf(r.value);o&&i&&!Lf(o)&&t.set(o,i)}return t}s(Hf,"rowsToMap");function IC(e){let t=OC(e);return t.search="mode=ro&immutable=1",t.href}s(IC,"sqliteReadonlyUri");function TC(e){try{let t=Mf("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(eo)??n.prepare(eo);return Hf(r.all?.())}finally{n.close?.()}}catch{return null}}s(TC,"readViaBunSqlite");function PC(e){let t=process.emitWarning.bind(process);process.emitWarning=((n,...r)=>{(typeof n=="string"?n:n instanceof Error?n.message:"").includes("SQLite is an experimental feature")||t(n,...r)});try{return e()}finally{process.emitWarning=t}}s(PC,"withSqliteExperimentalWarningSuppressed");function wC(e){try{return PC(()=>{let t=Mf("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return Hf(n.prepare(eo).all?.())}finally{n.close?.()}})}catch{return null}}s(wC,"readViaNodeSqlite");function NC(e){let t=new Map;for(let n of e.split(`
|
|
43
|
+
`)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let i=r.slice(0,o).trim(),a=r.slice(o+1).trim();i&&a&&!Lf(i)&&t.set(i,a)}return t}s(NC,"parseCliTable");function vC(e){try{let t=bC("sqlite3",["-noheader","-batch","-separator"," ",e,eo],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return NC(t)}catch{return null}}s(vC,"readViaSqliteCli");function Uf(e){let t=Ys.get(e);if(t)return t;if(!kC(e)){let o=new Map;return Ys.set(e,o),o}let n=IC(e),r=TC(n)??vC(n)??wC(n)??new Map;return Ys.set(e,r),r}s(Uf,"readCursorAuthItems");var MC="cursorAuth/cachedEmail",LC="cursorAuth/stripeMembershipAuthId";function to(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(to,"trimEnv");function HC(e=no(),t=process.platform,n=process.env){let r=to(n.VSCODE_PORTABLE);if(r)return Qe(r,"user-data");let o=to(n.VSCODE_APPDATA);if(o)return Qe(o,"Cursor");switch(t){case"darwin":return Qe(e,"Library","Application Support","Cursor");case"win32":return Qe(to(n.APPDATA)??Qe(e,"AppData","Roaming"),"Cursor");default:return Qe(to(n.XDG_CONFIG_HOME)??Qe(e,".config"),"Cursor")}}s(HC,"cursorUserDataDir");function UC(e=no()){return Qe(e,".cursor","cli-config.json")}s(UC,"cursorCliConfigPath");function DC(e=no(),t=process.platform,n=process.env){return Qe(HC(e,t,n),"User","globalStorage","state.vscdb")}s(DC,"cursorIdeStateDbPath");function Mn(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Mn,"trimString");function FC(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):Mn(e.userId)}s(FC,"numericUserId");function $C(e){return Mn(e.email)??Mn(e.authId)??FC(e)}s($C,"platformLogin");function Xs(e){let t=Mn(e.email),n=Mn(e.displayName),r=$C(e);return!r||ye(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}s(Xs,"identityFromAuth");function jC(e){let n=Q(UC(e),{}).authInfo;return!n||typeof n!="object"?null:Xs(n)}s(jC,"readCliOperatorIdentity");function BC(e,t,n){let r=DC(e,process.platform,t),o=Tf(e),i=Pf(o);if(wf(i,r,n))return Xs({email:i?.email,authId:i?.auth_id});let a=Uf(r),c=a.get(MC)??null,u=a.get(LC)??null;return Nf(o,{read_at_ms:n,db_path:r,email:c,auth_id:u}),Xs({email:c,authId:u})}s(BC,"readIdeOperatorIdentity");function Df(e=no(),t=process.env,n=Date.now()){return jC(e)??BC(e,t,n)}s(Df,"readCursorOperatorIdentity");import{createHash as KC}from"node:crypto";import{resolve as GC}from"node:path";function te(e){return KC("sha256").update(e).digest("hex").slice(0,16)}s(te,"sha16");function qs(e){return te(GC(e))}s(qs,"dirScopeRef");function xe(e,t){return`${e}\0${t}`}s(xe,"componentKey");function ro(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}s(ro,"componentDeltaHash");function Ff(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}s(Ff,"parseComponentKey");function Ln(e){let n=[...e].sort((r,o)=>{let i=r.path.localeCompare(o.path);return i!==0?i:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
|
|
44
|
+
`);return te(n)}s(Ln,"hashUserSpec");function WC(e,t,n="git_config",r=null){return te(`${e??""}|${t??""}|${r??""}|${n}`)}s(WC,"hashOperatorIdentity");function zC(e){let t=null,n=null;for(let r of e.split(`
|
|
45
|
+
`)){let o=r.trim();if(!o)continue;let i=o.indexOf(" ");if(i<=0)continue;let a=o.slice(0,i).toLowerCase(),c=o.slice(i+1).trim();c&&(a==="user.name"?t=c:a==="user.email"&&(n=c))}return{git_user_name:t,git_user_email:n,platform_login:null}}s(zC,"parseGitUserConfig");async function JC(e,t=se){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return zC(n)}s(JC,"readGitOperatorIdentity");function YC(e=process.env){let t=G(e.GIT_AUTHOR_NAME),n=G(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=G(e.GIT_COMMITTER_NAME),o=G(e.GIT_COMMITTER_EMAIL);if(r||o)return{git_user_name:r,git_user_email:o,platform_login:null,identity_source:"git_env"};let i=G(e.EMAIL);return i?{git_user_name:null,git_user_email:i,platform_login:null,identity_source:"git_env"}:null}s(YC,"readGitEnvOperatorIdentity");function et(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}s(et,"actorIdentity");function XC(e=process.env){let t=G(e.EV_AI_HOOK_OPERATOR_EMAIL),n=G(e.EV_AI_HOOK_OPERATOR_LOGIN),r=et(G(e.EV_AI_HOOK_OPERATOR_NAME),t,"configured",t??n);if(r)return r;let o=G(e.GITHUB_ACTOR)??G(e.GITHUB_TRIGGERING_ACTOR)??G(e.GITHUB_USER),i=et(o,null,"github",o);if(i)return i;let a=G(e.GITLAB_USER_LOGIN),c=G(e.GITLAB_USER_EMAIL),u=et(G(e.GITLAB_USER_NAME)??a,c,"gitlab",c??a);if(u)return u;let f=G(e.BUILD_REQUESTEDFOREMAIL),l=et(G(e.BUILD_REQUESTEDFOR),f,"azure_devops",f??G(e.BUILD_REQUESTEDFORID));if(l)return l;let d=G(e.BUILDKITE_BUILD_CREATOR_EMAIL),p=et(G(e.BUILDKITE_BUILD_CREATOR),d,"buildkite",d);if(p)return p;let m=G(e.BUILD_USER_EMAIL)??G(e.CHANGE_AUTHOR_EMAIL),_=et(G(e.BUILD_USER)??G(e.CHANGE_AUTHOR),m,"jenkins",m??G(e.BUILD_USER_ID));if(_)return _;let h=G(e.CIRCLE_USERNAME),b=et(h,null,"circleci",h);if(b)return b;let k=G(e.CODEBUILD_INITIATOR),T=et(k,null,"codebuild",k);if(T)return T;let N=G(e.DRONE_COMMIT_AUTHOR_EMAIL),w=G(e.DRONE_COMMIT_AUTHOR),I=et(w??G(e.DRONE_COMMIT_AUTHOR_NAME),N,"drone",N??w);if(I)return I;if($f(e.CLAUDE_CODE_REMOTE)||$f(e.CURSOR_AGENT)){let $=G(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:$&&!ye(null,$)?$:null,identity_source:"cloud"}}return null}s(XC,"readCloudOperatorIdentity");function Zs(e){return!!((e.git_user_name??e.git_user_email)&&!ye(e.git_user_name,e.git_user_email))}s(Zs,"isHumanOperator");function G(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(G,"trimEnv");function $f(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s($f,"isTruthyEnv");function qC(e,t,n){return e==="claude"?Cf(t):e==="cursor"?Df(t,n):e==="codex"?Of(n,t):null}s(qC,"readRunnerOperatorIdentity");async function Qs(e,t=se,n=process.env,r={}){let o=await JC(e,t),i=YC(n),a=Zs(o)?o:i&&Zs(i)?i:null,c=qC(r.runnerPlatform,r.home??VC(),n);if(c)return{git_user_name:a?.git_user_name??null,git_user_email:a?.git_user_email??null,platform_login:c.platform_login,identity_source:c.identity_source};let u=XC(n);return u?.platform_login?{git_user_name:a?.git_user_name??null,git_user_email:a?.git_user_email??null,platform_login:u.platform_login,identity_source:u.identity_source}:a?{...a,platform_login:null,identity_source:Zs(o)?"git_config":"git_env"}:u||(o.git_user_name||o.git_user_email?{...o,identity_source:"git_config"}:i||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}s(Qs,"resolveOperatorIdentity");async function ei(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??se,i=e.env??process.env,a=await Qs(t,o,i,{runnerPlatform:e.runnerPlatform,home:e.home}),c=WC(a.git_user_name,a.git_user_email,a.identity_source,a.platform_login),f=(n?fs(n):void 0)?.operator_identity_hash;if(!(r||f!==void 0&&f!==c||!f))return{commit:s(()=>{},"commit")};let m=n;return{operator:a,commit:s(()=>{m&&Qc(m,c,cr())},"commit")}}s(ei,"resolveOperatorForSend");function ti(e){return e?!fs(e)?.operator_identity_hash:!0}s(ti,"operatorIdentityNeverSent");function jf(e){return!0}s(jf,"shouldBootstrapCloudIdentity");import{existsSync as px,readFileSync as mx}from"node:fs";import{homedir as fm}from"node:os";import{join as an,resolve as gx}from"node:path";import{basename as sx,join as sn}from"node:path";import{dirname as qf,resolve as ao}from"node:path";import{existsSync as ZC}from"node:fs";import{homedir as Gf}from"node:os";import{relative as Vf,resolve as Fe,sep as Et}from"node:path";var QC=["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"],eA=["prompt","tool_input","tool_response","last_assistant_message","command"],tA=new Set;function nA(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return tA}}s(nA,"excludedContentKeys");function ii(e){let t=D("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?Rt.has(t.toLowerCase()):e?.collect_prompt===!0}s(ii,"isPromptCaptureEnabled");function oo(e,t){let n=Wf(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=D("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?Rt.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}s(oo,"promptCaptureSource");function Wf(e){return D("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||os(process.argv,e.debug===!0)||D("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}s(Wf,"hookInputCaptureMode");function rA(e){let t={};for(let n of QC){let r=We(e,n);r!==void 0&&(t[n]=r)}return t}s(rA,"allowlistedHookInput");function so(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Fe(e),r=Fe(t),o=Vf(r,n);return!o||o==="."?".":o.startsWith(`..${Et}`)||o===".."||Fe(r,o)!==n?null:o.split(Et).join("/")}s(so,"cwdRelativeToGitRoot");function zf(e,t){let n=Vf(Fe(t),Fe(e)).split(Et).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}s(zf,"specDirRelativeToCwd");function Jf(e){return typeof e!="string"||e.length===0?null:Fe(e).split(Et).join("/")}s(Jf,"absoluteCwdForSend");function oA(){let e=D("CURSOR_PROJECT_DIR");if(!e)return null;let t=Fe(e);return ZC(t)?t.split(Et).join("/"):null}s(oA,"cursorProjectDirAbs");function ri(e,t){return so(e,t)!==null}s(ri,"isPathInside");function sA(e,t){let n=Fe(t??Gf(),".cursor").split(Et).join("/");return ri(e,n)}s(sA,"isCursorUserHookLaunch");function iA(e,t,n){return t!==null&&ri(e,t)?!0:t!==null&&sA(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&ri(e,n.gitRoot)?!0:t===null}s(iA,"shouldKeepProcessCwd");function Yf(e,t){let n=Jf(e.cwd);if(n!==null)return n;let r=Fe(process.cwd()).split(Et).join("/"),o=oA();return iA(r,o,t)?r:o??r}s(Yf,"resolvedCwdForSend");function ai(e,t={}){return Yf(e,t)}s(ai,"resolveLaunchCwd");function ci(e,t=Gf()){let n=Fe(t).split(Et).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}s(ci,"tildeHomeCwd");function Bf(e,t,n){let r=Jf(n.launchCwd)??Yf(t,n);e.cwd=ci(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?so(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}s(Bf,"attachCwdFields");var Xf="\u2026[truncated]\u2026",oi=Buffer.byteLength(Xf,"utf8"),aA=8;function Hn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Hn,"jsonByteLength");function Kf(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}s(Kf,"utf8Head");function cA(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(n.length-t).toString("utf8")}s(cA,"utf8Tail");function uA(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=oi)return Kf(e,t);let r=t-oi,o=Math.ceil(r/2),i=Math.floor(r/2);return`${Kf(e,o)}${Xf}${cA(e,i)}`}s(uA,"truncateHeadTail");function si(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)=>{si(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||si(o,[...t,r],n)}s(si,"collectStrings");function lA(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){let a=t[i];if(a===void 0)return;r=(Array.isArray(r),r[a])}let o=t[t.length-1];if(!(o===void 0||r===null||typeof r!="object")){if(Array.isArray(r)){r[o]=n;return}r[o]=n}}s(lA,"setAtPath");var fA=256;function dA(e,t,n){let r=n,o=Math.max(n,e[0]?.bytes??n);for(;r<o;){let i=Math.ceil((r+o)/2),a=0;for(let c of e)c.bytes>i&&(a+=c.bytes-i);a>=t?r=i:o=i-1}return r}s(dA,"stringBudgetFor");function pA(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let i=Hn(e);if(i<=t)return;let a=[];si(e,[],a),a.sort((l,d)=>d.bytes-l.bytes);let c=a.filter(l=>l.bytes>n);if(c.length===0)return;let u=dA(c,i-t,n),f=Math.max(n,Math.min(u,r-1));if(f>=r)return;r=f;for(let l of c)l.bytes>r&&lA(e,l.path,uA(l.value,r))}}s(pA,"clampStringsToBudget");function mA(e,t){let n=Math.max(0,t-fA),r=Object.keys(e).filter(i=>!i.startsWith("_")).map(i=>({key:i,bytes:Hn(e[i])})).sort((i,a)=>a.bytes-i.bytes),o=[];for(let{key:i}of r){if(Hn(e)<=n)break;delete e[i],o.push(i)}o.length>0&&(e._dropped_keys=o.slice(0,10))}s(mA,"dropLargestKeys");function ni(e,t){let n=Hn(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,pA(r,t,oi+aA),Hn(r)>t&&mA(r,t),r}s(ni,"fitWithinByteLimit");function gA(e,t,n){if(!(n.promptCapture??ii()))return;let r=nA(n.runnerEvent);for(let o of eA){if(r.has(o))continue;let i=t[o];i!==void 0&&(e[o]=i)}}s(gA,"attachContentFields");function io(e,t,n={}){let r=Wf(t);if(r==="full"){let i={...e};return delete i.cwd,delete i.transcript_path,Bf(i,e,n),ni(i,Jo)}let o=rA(e);return Bf(o,e,n),r==="content"?(gA(o,e,n),ni(o,Jo)):ni(o,sc)}s(io,"sanitizeHookInput");function _A(e){return typeof e=="string"&&e.length>0}s(_A,"hasOrigin");function ui(e){let t=ao(e.home),n=ao(e.launchCwd),r=e.gitRoot?ao(e.gitRoot):null,o=new Set,i=[],a=null;e.inGitRepo&&_A(e.remote)&&r!==null&&r!==t&&(a=r,o.add(r)),n!==t&&!o.has(n)&&(i.push({scope:"cwd",dir:n}),o.add(n)),a!==null&&i.push({scope:"repo",dir:a});let c=null,u=r!==null&&so(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&u){let f=qf(r);for(;;){let l=ao(f);if(l===t)break;let d=qf(l);if(d===l)break;if(e.hasProjectSpec(l)){i.push({scope:"parent",dir:l}),c=zf(l,n);break}f=d}}return{anchors:i,parentRel:c}}s(ui,"resolveProjectAnchors");import{existsSync as Zf,readdirSync as hA,realpathSync as SA}from"node:fs";import{basename as EA,dirname as yA,relative as RA,resolve as CA,sep as AA}from"node:path";var li=400,co=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??st}static{s(this,"UserSpecContext")}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=CA(t).split(AA).join("/");return ci(r,this.home)}let n=RA(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${te(yA(t))}/${EA(t)}`:n}claimFile(t){try{let n=SA(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(!Zf(t))return[];try{return hA(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(Zf(t))return Q(t,n)}push(t){return this.components.length>=this.maxEntries?(this.truncated=!0,!1):this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0?!1:(this.pluginExpandRemaining!==void 0&&(this.pluginExpandRemaining-=1),this.components.push(t),!0)}withPluginExpandCap(t,n){let r=this.pluginExpandRemaining;this.pluginExpandRemaining=t;try{let o=n(),i=t-(this.pluginExpandRemaining??0);return{result:o,expanded:i}}finally{this.pluginExpandRemaining=r}}};import{existsSync as Ii,readFileSync as Wb,statSync as zb}from"node:fs";import{basename as pp,join as vt,relative as Ti}from"node:path";var up=ot(cp());var Gb=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],lp=Gb.map(e=>up.default.matcher(e,{dot:!0}));function Vb(e){return e===""?!1:lp.some(t=>t(`${e}/`))}s(Vb,"isExcludedDirPath");function fp(e,t){if(t==="")return!1;if(e==="")return Vb(t);let n=e.replace(/\/+$/,"");return lp.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}s(fp,"isExcludedDirBelow");var Pi=100*1024,Jb=4;function Yb(e){return e.length<=Pi?e:`${e.slice(0,Pi-1)}\u2026`}s(Yb,"truncateContentText");function Xb(e){try{let t=Wb(e),n=t.toString("utf8");return{hash:te(t),length:t.length,text:Yb(n)}}catch{return null}}s(Xb,"readFileMeta");var dp={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function qb(e){return e in dp?dp[e]:"UNSPECIFIED"}s(qb,"triggerForKind");function rn(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=Xb(t.absolutePath);if(!n)return!1;let r=t.name??pp(t.absolutePath).replace(/\.(md|mdc|toml)$/i,""),o={kind:t.kind,name:r,path:e.componentPath(t.absolutePath),text:n.text,content_hash:n.hash,content_length:n.length,origin:t.origin,enabled:t.enabled},i=qb(t.kind);return i&&(o.trigger=i),t.attributes&&(o.attributes=t.attributes),e.push(o)}s(rn,"addFile");function Zb(e,t,n){let r=Ti(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?pp(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}s(Zb,"nameFromWalkRoot");function Mt(e,t){let{dir:n,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u}=t;wi(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u})}s(Mt,"walkComponentDir");function wi(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l}=t;if(!(o>Jb))for(let d of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(d.isDirectory()&&fp(n.replace(/\\/g,"/"),Ti(n,vt(r,d.name)).replace(/\\/g,"/"))||d.isDirectory()&&l?.includes(vt(r,d.name)))continue;if(u){if(!d.isDirectory())continue;let _=vt(r,d.name,u);if(Ii(_)){let h=Ti(n,vt(r,d.name)).replace(/\\/g,"/");rn(e,{absolutePath:_,kind:i,origin:a,enabled:c,name:h||d.name});continue}wi(e,{walkRoot:n,currentDir:vt(r,d.name),depth:o+1,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l});continue}if(d.isDirectory()){wi(e,{walkRoot:n,currentDir:vt(r,d.name),depth:o+1,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l});continue}if(!d.isFile()||!f)continue;let p=d.name.toLowerCase();if(!f.some(_=>p.endsWith(_)))continue;let m=vt(r,d.name);rn(e,{absolutePath:m,kind:i,origin:a,enabled:c,name:Zb(n,m,!0)})}}s(wi,"walkRecursive");function mp(e){for(let t of e)if(Ii(t))try{if(zb(t).size>0)return t}catch{continue}return e.find(t=>Ii(t))}s(mp,"firstExistingFile");import{existsSync as Ik,readFileSync as Tk}from"node:fs";var _o=ot(St(),1);var Qb="<omitted>",ek=["package_name","package_spec","package_version","package_version_source"],gp=100,_p=120,ho=[{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"}],hp=new Set(ho.map(e=>e.attr)),tk=["enabled","disabled"],nk=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],rk=new Set(["type","command","url","args","env","envVars","headers",...tk,...nk,...ho.map(e=>e.raw)]),ok=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",...ek,...hp,...[...hp].map(e=>`${e}_truncated`)]);function Sp(e,t){for(let n of t)rk.has(n)||ok.has(n)||(e[n]=Qb)}s(Sp,"addOmittedKeys");var sk=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,ik=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,ak=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,ck=/^bearer(?:\s+|$)/i;function So(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}s(So,"asRecord");function Ep(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}s(Ep,"stringList");function Ni(e){if(Array.isArray(e)){let n=[];for(let r of e){if(typeof r!="string"||r.length===0)continue;let o=r.split("=",1)[0]?.trim();o&&n.push(o)}return n}let t=So(e);return t?Object.keys(t).filter(n=>n.length>0):[]}s(Ni,"envNamesFromValue");function Lt(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}s(Lt,"redactCommandOrUrl");function uk(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,_o.launchContainsCredentials)({kind:"url",url:e})||(0,_o.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,_o.launchContainsCredentials)({kind:"url",url:r}):!0)}s(uk,"rawLaunchHadCredentials");function yp(e,t,n){uk(t,n)&&(e.launch_had_credentials=!0)}s(yp,"markLaunchCredentials");function lk(e){return ak.test(e)||ck.test(e)?"<redacted>":e.includes("://")?Lt(e):e}s(lk,"redactSecretShapedValue");function Rp(e){if(/^https?:\/\//i.test(e))return Lt(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${Rp(e.slice(t+1))}`:lk(e)}s(Rp,"redactArg");function fk(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return sk.test(t)||ik.test(t)}s(fk,"authArgKey");function Kn(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(fk(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(Rp(r))}return t}s(Kn,"redactArgs");function dk(e){let t=Ep(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>_p?r.slice(0,_p):r))].sort();if(n.length!==0)return n.length>gp?{names:n.slice(0,gp),truncated:!0}:{names:n,truncated:!1}}s(dk,"toolNameList");function pk(e){let t=So(e);if(!t)return{headers:[],envVars:[]};let n=[],r=[];for(let[o,i]of Object.entries(t))o.length>0&&n.push(o),typeof i=="string"&&i.length>0&&r.push(i);return{headers:n,envVars:r}}s(pk,"envHeaderNames");function Cp(e,t){let n=new Set;for(let{raw:r,attr:o}of ho){if(n.has(o)||!(r in t))continue;let i=t[r];if(o==="auto_approve"&&typeof i=="boolean"){e.auto_approve=i,n.add(o);continue}let a=dk(i);a&&(e[o]=a.names,a.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}s(Cp,"applyToolListAttributes");function Ap(e,t){let n=So(e),r={transport:t};if(!n)return r;Sp(r,Object.keys(n));let o=typeof n.command=="string"?n.command:void 0,i=typeof n.url=="string"?n.url:void 0,a=typeof n.serverUrl=="string"?n.serverUrl:void 0,c=o??i??a,u=Ep(n.args);c&&(r.command_or_url=Lt(c));let f=Kn(u);f.length>0&&(r.args=f),yp(r,c,u);let l=pk(n.env_http_headers),d=[...new Set([...Ni(n.env),...Ni(n.envVars),...Ni(n.env_vars),...l.envVars,...typeof n.bearer_token_env_var=="string"&&n.bearer_token_env_var.length>0?[n.bearer_token_env_var]:[]])].sort();d.length>0&&(r.env_var_names=d),l.headers.length>0&&(r.env_http_header_names=[...new Set(l.headers)].sort());for(let h of["headers","http_headers","env_http_headers"])if(n[h]!==void 0&&n[h]!==null){r.headers_present=!0;break}let p=typeof n.auth=="string"?n.auth:void 0;p&&(r.auth=p);let m=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;m&&(r.bearer_token_env_var=m);let _=typeof n.default_tools_approval_mode=="string"?n.default_tools_approval_mode:typeof n.defaultToolsApprovalMode=="string"?n.defaultToolsApprovalMode:void 0;return _&&(r.default_tools_approval_mode=_),Cp(r,n),r}s(Ap,"sanitizeMcpServerAttributes");function bp(e){let t=So(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}s(bp,"mcpServerEnabledFromJson");function Li(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return te(JSON.stringify({name:e,attributes:r,enabled:n}))}s(Li,"hashSanitizedMcpAttributes");function on(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}s(on,"parseTomlQuoted");function Bn(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*\\[([^\\]]*)\\]`,"m").exec(e);return n?.[1]?[...n[1].matchAll(/"([^"]*)"|'([^']*)'/g)].map(r=>r[1]??r[2]??"").filter(r=>r.length>0):[]}s(Bn,"parseTomlPlainStringArray");function Mi(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}s(Mi,"parseTomlBoolean");function vi(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=on(n[1]);return r.length>0?r:void 0}s(vi,"parseTomlScalarString");function mk(e,t){let n=[],r=s(a=>{for(let c of a.split(/[,\n]/)){let u=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(c);u?.[1]&&n.push([u[1],on(u[2]??"")])}},"collect"),o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let i=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
|
|
46
|
+
${e}`);return i?.[1]&&r(i[1]),n}s(mk,"parseTomlMap");function kp(e){return Mi(e,"enabled")===!1?!1:Mi(e,"disabled")!==!0}s(kp,"mcpServerEnabledFromToml");function gk(e,t){let n={};for(let{raw:r,attr:o}of ho){if(o==="auto_approve"){let a=Mi(t,r);if(a!==void 0){n[r]=a;continue}}let i=Bn(t,r);i.length>0&&(n[r]=i)}Cp(e,n)}s(gk,"applyToolListsFromToml");var _k=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,hk=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function Sk(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
|
|
47
|
+
`)){let i=_k.exec(o);i?.[1]&&t.add(i[1])}for(let o of e.matchAll(hk))o[1]&&t.add(o[1]);return[...t]}s(Sk,"tomlDeclaredKeys");function xp(e,t){let n={transport:t};Sp(n,Sk(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),i=r?on(r[1]??""):void 0,a=o?on(o[1]??""):void 0,c=i!==void 0&&i.length>0?i:a,u=Bn(e,"args");c&&(n.command_or_url=Lt(c));let f=Kn(u);f.length>0&&(n.args=f),yp(n,c,u);let l=new Set;for(let k of e.split(`
|
|
48
|
+
`)){let T=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(k);T?.[1]&&l.add(T[1])}let d=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(d?.[1])for(let k of d[1].split(",")){let T=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(k);T?.[1]&&l.add(T[1])}let p=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
|
|
49
|
+
${e}`);if(p?.[1])for(let k of p[1].split(`
|
|
50
|
+
`)){let T=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(k);T?.[1]&&l.add(T[1])}for(let k of Bn(e,"env_vars"))l.add(k);let m=mk(e,"env_http_headers");for(let[,k]of m)k.length>0&&l.add(k);let _=vi(e,"bearer_token_env_var");_&&(l.add(_),n.bearer_token_env_var=_),l.size>0&&(n.env_var_names=[...l].sort()),m.length>0&&(n.env_http_header_names=[...new Set(m.map(([k])=>k))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let h=vi(e,"auth");h&&(n.auth=h);let b=vi(e,"default_tools_approval_mode");return b&&(n.default_tools_approval_mode=b),gk(n,e),n}s(xp,"parseTomlMcpSection");var Be=ot(St(),1);import{createHash as Ck}from"node:crypto";import{join as Gn}from"node:path";var Ek=300,yk=256;function Op(e,t){if(!t)return e;let n=[...new Set([t,t.replace(/\\/g,"/")])].filter(o=>o.length>1),r=e;for(let o of n)r=r.split(o).join("~");return r}s(Op,"rewriteHomePrefix");function Eo(e){let t=[],n="",r=null;for(let o of e){if(r){o===r?r=null:n+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(/\s/.test(o)){n.length>0&&(t.push(n),n="");continue}n+=o}return n.length>0&&t.push(n),t}s(Eo,"tokenizeCommand");function Ip(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}s(Ip,"capLength");function Rk(e){return Ip(e,Ek)}s(Rk,"capCommand");function Tp(e,t){let n=Op(e.trim(),t),r=Eo(n);if(r.length===0)return"";let[o,...i]=r,a=Lt(o),c=Kn(i);return Rk([a,...c].join(" "))}s(Tp,"sanitizeHookCommand");function Pp(e,t){if(typeof e!="string")return null;let n=Op(e.trim(),t),r=Eo(n)[0];if(!r)return null;let o=Lt(r);return o.length===0?null:Ip(o,yk)}s(Pp,"executableFromCommand");function Ak(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,Be.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}s(Ak,"packageVersionFields");function bk(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
|
|
51
|
+
`);return Ck("sha512").update(t).digest("hex").slice(0,16)}s(bk,"npxCacheKey");function kk(e){let t=process.platform==="win32"?Gn(D("LOCALAPPDATA")??e,"npm-cache"):Gn(e,".npm"),n=D("npm_config_cache")??D("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}s(kk,"npmCacheRoots");function wp(e){return typeof e=="string"&&e.length>0&&e.length<=Be.PACKAGE_FIELD_MAX?e:null}s(wp,"usableVersion");function xk(e,t,n){let r=bk(e);for(let o of kk(n)){let i=Gn(o,"_npx",r),a=Q(Gn(i,"node_modules",...t.split("/"),"package.json"),{}),c=wp(a.version);if(c!==null)return c;let u=Q(Gn(i,"package-lock.json"),{}),f=wp(u.packages?.[`node_modules/${t}`]?.version);if(f!==null)return f}return null}s(xk,"installedVersion");function Ok(e){return e.length<=Be.PACKAGE_FIELD_MAX?e:`${e.slice(0,Be.PACKAGE_FIELD_MAX-1)}\u2026`}s(Ok,"capField");function Hi(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,Be.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let i=(0,Be.packageNameFromSpec)(o);return i===null?null:{package_name:i,package_spec:Ok(o),...Ak(o,xk(r,i,n))}}s(Hi,"resolveNpxPackage");function Np(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=Eo(e.trim());return n===void 0?null:Hi(n,r,t)}s(Np,"resolveNpxPackageFromCommand");function yo(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 Hi(typeof n.command=="string"?n.command:null,r,t)}s(yo,"npxPackageFromMcpConfig");function vp(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:Hi(on(n[1]??""),Bn(e,"args"),t)}s(vp,"npxPackageFromTomlSection");function Pk(e){if(!e||typeof e!="object"||Array.isArray(e))return"unknown";let t=e;return typeof t.type=="string"&&t.type.length>0?t.type:typeof t.url=="string"?"http":typeof t.command=="string"?"stdio":"unknown"}s(Pk,"mcpTransport");function Mp(e,t,n){if(!e.claimFile(t))return;let o=e.readJson(t,{})?.mcpServers;if(!o||typeof o!="object")return;let i=e.componentPath(t);for(let[a,c]of Object.entries(o)){if(e.truncated)return;let u=Pk(c),f=Ap(c,u);Object.assign(f,yo(c,e.home)??{});let l=bp(c);e.push({kind:"MCP_SERVER",name:a,path:i,content_hash:Li(a,f,l),origin:n,enabled:l,attributes:f})}}s(Mp,"collectMcpJson");function Lp(e,t,n){if(!Ik(t)||!e.claimFile(t))return;let r;try{r=Tk(t,"utf8")}catch{return}let o=e.componentPath(t),i=/^\[mcp_servers(?:\.(\w+)|\."([^"]+)"|\.'([^']+)')\]\s*$/gm,a;for(;(a=i.exec(r))!==null;){if(e.truncated)return;let c=a[1]??a[2]??a[3];if(!c)continue;let u=r.slice(a.index+a[0].length),f=u.search(/^\[mcp_servers(?:\.(?:\w+|"[^"]+"|'[^']+'))\]\s*$/m),l=f===-1?u:u.slice(0,f),d="unknown";/^\s*url\s*=/m.test(l)?d="http":/^\s*command\s*=/m.test(l)&&(d="stdio");let p=xp(l,d);Object.assign(p,vp(l,e.home)??{});let m=kp(l);e.push({kind:"MCP_SERVER",name:c,path:o,content_hash:Li(c,p,m),origin:n,enabled:m,attributes:p})}}s(Lp,"collectCodexMcpToml");import{existsSync as vk,readdirSync as Mk}from"node:fs";import{join as he}from"node:path";function wk(e){if(e.prompt||e.type==="prompt")return"prompt";let t=e.command??e.bash??e.powershell??"";return/\bnpx\b/i.test(t)?"npx":/\.(sh|bash|zsh|js|mjs|cjs|ts|py)(\s|$|"|')/i.test(t)||/^(\.\/|~\/|\/|[A-Za-z]:[\\/])/.test(t.trim())?"script":"inline"}s(wk,"classifyActionKind");function Nk(e){return Array.isArray(e.hooks)&&e.hooks.length>0?e.hooks:[{type:e.type,command:e.command,bash:e.bash,powershell:e.powershell,prompt:e.prompt}]}s(Nk,"normalizeHookActions");function Ui(e,t,n,r){let o=e.componentPath(t);for(let[i,a]of Object.entries(n))if(!(!Array.isArray(a)||e.truncated))for(let c of a){if(!c||typeof c!="object"||e.truncated)continue;let u=c;for(let f of Nk(u)){if(e.truncated)return;let l=f.command??f.bash??f.prompt??f.powershell??u.powershell??"",d=wk({type:f.type??u.type,command:f.command??u.command,bash:f.bash??u.bash,powershell:f.powershell??u.powershell,prompt:f.prompt??u.prompt}),p=typeof u.matcher=="string"?u.matcher:"",m=te(l),_=p?`${i}:${p}:${d}:${m}`:`${i}:${d}:${m}`,h=`${i}|${p}|${d}|${l}|attrs2`;e.push({kind:"HOOK",name:_,path:o,content_hash:te(h),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:i,...p?{matcher:p}:{},action_kind:d,action_hash:m,...d!=="prompt"&&l.trim()?{command:Tp(l,e.home)}:{}}})}}}s(Ui,"collectHooksFromObject");function Di(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||Ui(e,t,r.hooks,n)}s(Di,"collectHooksFile");var Hp=50;function Vn(e,t,n,r){if(!vk(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:i}=e.withPluginExpandCap(Hp,()=>{Mt(e,{dir:he(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),Mt(e,{dir:he(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),Mt(e,{dir:he(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});Di(e,he(t,"hooks","hooks.json"),n),Di(e,he(t,"hooks.json"),n);let a=e.components.length-o,c=i>=Hp;return{componentCount:a,expandTruncated:c}}s(Vn,"expandPluginTree");function Wn(e,t){e.push({kind:"PLUGIN",name:t.pluginKey,path:t.rowPath,content_hash:t.contentHash,origin:"user",enabled:t.enabled,attributes:{...t.marketplace?{marketplace:t.marketplace}:{},...t.version?{version:t.version}:{},scope:t.scope,component_count:t.componentCount,...t.expandTruncated?{expand_truncated:!0}:{}}})}s(Wn,"addPluginRow");function Fi(e){let t=e?.enabledPlugins;if(typeof t!="object"||t===null||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}s(Fi,"readEnabledPlugins");function Lk(e){let t=Fi(e.readJson(he(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=yn(process.platform,e.home),o=e.readJson(n,{}),i={};if(o&&Object.keys(o).length>0)i=Fi(o);else for(let a of r)Object.assign(i,Fi(e.readJson(a,{})));return{...t,...i}}s(Lk,"resolveClaudeEnabledPlugins");function Up(e){let t=he(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=Lk(e),i=e.componentPath(t);for(let[a,c]of Object.entries(r)){if(e.truncated)return;let u=Array.isArray(c)?c:[c],f=u[0]??{},l=o[a]===!0,d=a.includes("@")?a.split("@").slice(1).join("@"):"",p=typeof f.version=="string"?f.version:"",m=typeof f.scope=="string"?f.scope:"user",_=`plugin:${a}`,h=0,b=!1;for(let k of u)if(typeof k.installPath=="string"&&k.installPath.length>0){let T=Vn(e,k.installPath,_,l);h+=T.componentCount,b=b||T.expandTruncated}Wn(e,{pluginKey:a,rowPath:i,enabled:l,scope:m,version:p||void 0,marketplace:d||void 0,componentCount:h,expandTruncated:b,contentHash:te(`${a}|${p}|${m}|${l}|${h}`)})}}s(Up,"collectClaudePlugins");function Hk(e){let t=e,n="";try{let r=Mk(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=he(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),i=o[o.length-1];i&&(t=he(e,i),n=i)}}catch{}return{installPath:t,version:n}}s(Hk,"pickVersionDir");var Uk=/^\d+$/;function Dk(e){let t=e.filter(n=>!Uk.test(n.pluginId));return t.length>0?t:e}s(Dk,"dedupeCursorCachePlugins");function Dp(e){let t=[{base:he(e.home,".cursor/plugins/local"),scope:"local"},{base:he(e.home,".cursor/plugins/cache"),scope:"cache"}];for(let{base:n,scope:r}of t)if(!e.truncated)for(let o of e.readEntries(n)){if(!o.isDirectory()||e.truncated)continue;if(r==="local"){let c=o.name,u=he(n,o.name),f=`plugin:${c}`,{componentCount:l,expandTruncated:d}=Vn(e,u,f,!0);Wn(e,{pluginKey:c,rowPath:e.componentPath(u),enabled:!0,scope:"local",componentCount:l,expandTruncated:d,contentHash:te(`${c}|local|${l}`)});continue}let i=o.name,a=[];for(let c of e.readEntries(he(n,i))){if(!c.isDirectory())continue;let u=he(n,i,c.name),{installPath:f,version:l}=Hk(u);a.push({pluginId:c.name,installPath:f,version:l})}for(let c of Dk(a)){if(e.truncated)break;let u=`${c.pluginId}@${i}`,f=`plugin:${u}`,{componentCount:l,expandTruncated:d}=Vn(e,c.installPath,f,!0);Wn(e,{pluginKey:u,rowPath:e.componentPath(c.installPath),enabled:!0,scope:"cache",version:c.version||void 0,marketplace:i,componentCount:l,expandTruncated:d,contentHash:te(`${u}|${c.version}|${l}`)})}}}s(Dp,"collectCursorPlugins");import{existsSync as jk}from"node:fs";var Fk=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,$i="<path>",$k=new RegExp(`${$i}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function Ro(e){let t=e.replace(Fk,$i).replace($k,$i);return t.length>200?`${t.slice(0,200)}...`:t}s(Ro,"redactPermissionKey");var Fp=200,$p=200,ji=16*1024,jp=6,Bk=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),Kk=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),Gk=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),Vk=new Set(["permissions"]),Wk={claude:Bk,cursor_sandbox:Kk,cursor_permissions:Gk,cursor_cli:Vk},zk=new Set(["allow","deny","ask"]);function yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(yt,"isRecord");function Co(e){return e.replace(/\\/g,"/")}s(Co,"posixPath");function Bi(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>Bi(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${Bi(t[r])}`).join(",")}}`}s(Bi,"canonicalJson");function Jk(e){return te(`${Bi(e)}|settings1`)}s(Jk,"hashSettingsAttributes");function Wp(e){let t=Co(e);if(t.endsWith(".claude/settings.json")||t.endsWith(".claude/settings.local.json"))return"claude";if(t.endsWith(".cursor/sandbox.json"))return"cursor_sandbox";if(t.endsWith(".cursor/permissions.json"))return"cursor_permissions";if(t.endsWith(".cursor/cli-config.json")||t.endsWith(".cursor/cli.json"))return"cursor_cli"}s(Wp,"settingsProfileFor");function zp(e,t){if(e!=="claude")return{};let n=Co(t);return n.endsWith("/.claude/remote-settings.json")?{profile:"claude",managedSource:"server"}:n.includes("/managed-settings.d/")&&n.endsWith(".json")?{profile:"claude",managedSource:"file_dropin"}:n.endsWith("/managed-settings.json")?{profile:"claude",managedSource:"file"}:{profile:"claude"}}s(zp,"managedSettingsMeta");function Jp(e){let t=Co(e).replace(/\/+$/,"");return t.length<=1?"":t}s(Jp,"homePosix");function Yp(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}s(Yp,"isWindowsHome");function Yk(e,t){let n=Co(e);if(n==="~"||n.startsWith("~/"))return n;let r=Jp(t);if(!r)return n;let o=n.slice(0,r.length);if(!(Yp(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let a=n.slice(r.length);return a===""?"~":a.startsWith("/")?`~${a}`:n}s(Yk,"tildePath");var Bp=new Map;function Xk(e){let t=Bp.get(e);if(t!==void 0)return t;let n=Jp(e),r=null;if(n){let o=n.split("/").map(i=>i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,Yp(e)?"gi":"g")}return Bp.set(e,r),r}s(Xk,"homeTextPattern");function qk(e,t){let n=Xk(t);return n?e.replace(n,"~"):e}s(qk,"tildeHomeInText");function Kp(e,t){return e.length<=$p?e:(t.truncated=!0,e.slice(0,$p))}s(Kp,"capString");function Xp(e,t){return e.length<=Fp?e:(t.truncated=!0,e.slice(0,Fp))}s(Xp,"capArray");function ie(e,t,n,r){if(typeof e=="string"){if(t==="path")return Kp(Yk(e,n),r);let o=t==="rule"?Ro(e):e;return Kp(qk(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=Xp(e,r),i=[];for(let a of o){let c=ie(a,t,n,r);c!==void 0&&i.push(c)}return i}if(yt(e)){let o={};for(let[i,a]of Object.entries(e)){let c=ie(a,t,n,r);c!==void 0&&(o[i]=c)}return o}}s(ie,"transformValue");function Gp(e,t,n){if(!yt(e))return ie(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a="plain";zk.has(o)?a="rule":o==="additionalDirectories"&&(a="path");let c=ie(i,a,t,n);c!==void 0&&(r[o]=c)}return r}s(Gp,"transformPermissions");function Zk(e,t,n){if(!yt(e))return ie(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){if(o==="files"&&Array.isArray(i)){let c=Xp(i,n);r[o]=c.map(u=>{if(!yt(u))return ie(u,"plain",t,n);let f={};for(let[l,d]of Object.entries(u)){let m=ie(d,l==="path"?"path":"plain",t,n);m!==void 0&&(f[l]=m)}return f});continue}let a=ie(i,"plain",t,n);a!==void 0&&(r[o]=a)}return r}s(Zk,"transformCredentials");function Qk(e,t,n){if(!yt(e))return ie(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let c=ie(i,o==="allowUnixSockets"?"path":"plain",t,n);c!==void 0&&(r[o]=c)}return r}s(Qk,"transformNetwork");function ex(e,t,n){if(!yt(e))return ie(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a;o==="excludedCommands"?a=ie(i,"rule",t,n):o==="filesystem"?a=ie(i,"path",t,n):o==="network"?a=Qk(i,t,n):o==="credentials"?a=Zk(i,t,n):a=ie(i,"plain",t,n),a!==void 0&&(r[o]=a)}return r}s(ex,"transformSandbox");function tx(e,t,n,r,o){return n==="claude"?e==="permissions"?Gp(t,r,o):e==="sandbox"?ex(t,r,o):ie(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?ie(t,"path",r,o):ie(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?ie(t,"rule",r,o):ie(t,"plain",r,o):e==="permissions"?Gp(t,r,o):ie(t,"plain",r,o)}s(tx,"transformByProfile");function zn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(zn,"jsonBytes");function Ki(e,t){return e?`${e}.${t}`:t}s(Ki,"childPath");function Gi(e,t,n,r){if(Array.isArray(e)){for(let o=e.length-1;o>=0;o-=1){let i=e[o];i!==null&&typeof i=="object"&&(t+1>=jp?(e.splice(o,1),r.add(n)):Gi(i,t+1,n,r))}return}if(!(e===null||typeof e!="object"))for(let[o,i]of Object.entries(e))i!==null&&typeof i=="object"&&(t+1>=jp?(delete e[o],r.add(Ki(n,o))):Gi(i,t+1,Ki(n,o),r))}s(Gi,"pruneDepth");function qp(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:zn(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))qp(o,Ki(t,r),n)}s(qp,"collectTrimCandidates");function nx(e,t,n){let r=zn(e);if(r<=ji)return;t.truncated=!0;let o=[];for(qp(e,"",o);r>ji;){let i;for(let u of o)u.items.length>0&&(!i||u.bytes>i.bytes)&&(i=u);if(!i)break;let a=i.items.pop(),c=zn(a)+(i.items.length>0?1:0);i.bytes-=c,r-=c,n.add(i.path)}for(;zn(e)>ji;){let i,a=-1;for(let[c,u]of Object.entries(e)){let f=zn(u);f>a&&(i=c,a=f)}if(i===void 0)break;delete e[i],n.add(i)}}s(nx,"fitSettingsJson");function rx(e,t,n){let r=Wk[t],o={truncated:!1},i={},a=[];for(let u of Object.keys(e)){if(!r.has(u)){a.push(u);continue}let f=tx(u,e[u],t,n,o);f!==void 0&&(i[u]=f)}a.sort();let c=new Set;return Gi(i,1,"",c),c.size>0&&(o.truncated=!0),nx(i,o,c),{settings:i,keys_omitted:a,truncated:o.truncated,trimmed_paths:[...c].sort()}}s(rx,"extractSettingsPosture");function Vp(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:Jk(t.attributes),attributes:t.attributes};e.push(n)}s(Vp,"pushPostureRow");function Vi(e,t,n,r){if(!e.claimFile(t)||!jk(t))return;let o=ja(t);if(!o.ok||!yt(o.value)){if(r.profile){let f=!o.ok&&o.reason==="read"?"read_error":"parse_error",l={profile:r.profile,[f]:!0};r.managedSource&&(l.managed_source=r.managedSource),Vp(e,{kind:r.kind,absPath:t,origin:n,attributes:l})}return}let i=o.value,a=i.hooks;if(yt(a)&&Ui(e,t,a,n),!r.profile)return;let c=rx(i,r.profile,e.home),u={profile:r.profile,settings:c.settings,keys_omitted:c.keys_omitted};c.truncated&&(u.truncated=!0),c.trimmed_paths.length>0&&(u.trimmed_paths=c.trimmed_paths),r.managedSource&&(u.managed_source=r.managedSource),Vp(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}s(Vi,"collectSettingsFile");import{existsSync as ox}from"node:fs";import{join as Ke}from"node:path";var Zp=".claude/skills/synced",Qp=".claude/plugins/synced";function em(e){return[Ke(e,Zp),Ke(e,Qp)]}s(em,"claudeSyncedDirs");function Ao(e){return typeof e=="string"&&e.length>0?e:void 0}s(Ao,"stringField");function tm(e){let t=Ke(e.home,Zp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ke(t,n.name),o=e.readJson(Ke(r,"manifest.json"),{}),i=new Map((o?.skills??[]).flatMap(a=>a.name?[[a.name,a]]:[]));for(let a of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}let c=Ke(r,a.name,"SKILL.md");if(!a.isDirectory()||!ox(c))continue;let u=i.get(a.name),f=Ao(u?.source),l=Ao(u?.creatorType);rn(e,{absolutePath:c,kind:"SKILL",origin:"user",enabled:!0,name:a.name,attributes:{scope:"synced",...f?{source:f}:{},...l?{creator_type:l}:{}}})}}}s(tm,"collectClaudeSyncedSkills");function nm(e){let t=Ke(e.home,Qp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ke(t,n.name),o=e.readJson(Ke(r,"manifest.json"),{}),i=new Map((o?.plugins??[]).flatMap(a=>a.name?[[a.name,a]]:[]));for(let a of e.readEntries(r)){if(e.truncated)return;if(!a.isDirectory()||a.name.startsWith("."))continue;let c=i.get(a.name),u=Ao(c?.marketplaceName),f=Ao(c?.version),l=u?`${a.name}@${u}`:a.name,d=Ke(r,a.name),{componentCount:p,expandTruncated:m}=Vn(e,d,`plugin:${l}`,!0);Wn(e,{pluginKey:l,rowPath:e.componentPath(d),enabled:!0,scope:"synced",version:f,marketplace:u,componentCount:p,expandTruncated:m,contentHash:te(`${l}|${f??""}|synced|${p}`)})}}}s(nm,"collectClaudeSyncedPlugins");function ix(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:i}=t;for(let a of n.skillRoots)Mt(e,{dir:sn(r,a),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:em(e.home)});for(let a of n.dirs)Mt(e,{dir:sn(r,a.dir),kind:a.kind,origin:o,enabled:!0,extensions:a.extensions});for(let a of n.memory){let c=mp(a.map(u=>sn(r,u)));c&&rn(e,{absolutePath:c,kind:"MEMORY",origin:o,enabled:!0,name:sx(c)})}for(let a of $u(n))Vi(e,sn(r,a),o,{kind:"SETTINGS",profile:Wp(a)});for(let a of n.mcpJson??[])Mp(e,sn(r,a),o);for(let a of n.mcpToml??[])Lp(e,sn(r,a),o);if(i){if(n.managed){for(let a of Rr(n.managed,process.platform,e.home))if(a.toLowerCase().endsWith(".json")){let c=zp(n.managed,a);Vi(e,a,o,{kind:"MANAGED_SETTINGS",...c})}}n.plugins==="claude"?(Up(e),nm(e),tm(e)):n.plugins==="cursor"&&Dp(e)}}s(ix,"walkPlatformLayout");function rm(e,t){try{let n=new co(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)ix(n,{layout:r,levelDir:t.levelDir,origin:t.origin,includeMachineWide:t.includeMachineWide});return{scopeRef:t.scopeRef,anchor:t.levelDir,components:n.components,truncated:n.truncated}}catch(n){L("user_spec_scope",n);return}}s(rm,"walkScope");function Wi(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let u=rm(t,{layouts:Object.values(Jt),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:st,scopeRef:""});u&&(r.user=u)}let i=n.inGitRepo===!0,a=null,c=n.launchCwd;if(c!==void 0){let u=Object.values(mt),f=ui({launchCwd:c,gitRoot:n.gitRoot,inGitRepo:i,remote:n.remote,home:t,hasProjectSpec:s(l=>Bu(u,l),"hasProjectSpec")});a=f.parentRel;for(let l of f.anchors){let d=qs(l.dir);if(o!==void 0&&!o(l.scope,d))continue;let p=rm(t,{layouts:u,levelDir:l.dir,origin:l.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:li,scopeRef:d});p&&(r[l.scope]=p)}r.parent||(a=null)}return{scopes:r,parentRel:a,cwdInGitRepo:i}}s(Wi,"collectUserSpec");function zi(e,t,n={}){let r=n.truncated===!0,o=Ln(e),i=new Set(e.map(l=>xe(l.path,l.name)));if(n.forceFull===!0||t===void 0)return{hash:o,count:e.length,truncated:r,full:!0,upserts:e,removed:[],unchanged:!1};let c=[],u=t;for(let l of e){let d=xe(l.path,l.name);u[d]!==ro(l)&&c.push(l)}let f=[];if(!r){for(let l of Object.keys(u))if(!i.has(l)){let d=Ff(l);d&&f.push(d)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:c,removed:f,unchanged:c.length===0&&f.length===0}}s(zi,"diffUserSpec");var sm=2*1024*1024,ax=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function Ji(e,t,n){let r=new Set(t.map(i=>xe(i.path,i.name))),o=[];for(let i of e)i.text!==void 0&&(n.has(i.content_hash)||r.has(xe(i.path,i.name))||o.push(i));return o}s(Ji,"collectPendingTextBodies");function Yi(e,t,n){let r=new Set(e);for(let i of t)r.add(i);let o=new Set(n.map(i=>i.content_hash));return[...r].filter(i=>o.has(i))}s(Yi,"pruneDeliveredTextHashes");function om(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(om,"jsonSize");function im(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}s(im,"withoutText");function Xi(e,t=sm){let n=[],r=[];for(let l of e)ax.has(l.kind)?n.push(l):r.push(l);r.sort((l,d)=>(l.text?.length??0)-(d.text?.length??0));let o=[...n,...r],i=[],a=2,c=0,u=0,f=[];for(let l of o){let d=i.length>0?1:0,p=om(l)+d;if(a+p<=t){i.push(l),a+=p,l.text!==void 0&&f.push(l.content_hash);continue}if(l.text!==void 0){let m=im(l),_=om(m)+d;if(a+_<=t){i.push(m),a+=_,c+=1;continue}}u+=1}return{components:i,textDeferredCount:c,droppedCount:u,textHashesSent:f}}s(Xi,"fitUserSpecWithinBudget");function qi(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:im(n))}s(qi,"stripAlreadyDeliveredText");var cx=["user","cwd","repo","parent"];function Zi(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,i=[];for(let w of cx){let I=t.scopes[w];if(!I)continue;let $=n(w,I.scopeRef),v=$.components,x=zi(I.components,v,{forceFull:v===void 0,truncated:I.truncated}),P=new Set($.textHashes),U=Ji(I.components,x.upserts,P),g=qi([...x.upserts,...U],P);i.push({scope:w,walk:I,delta:x,outgoing:g,outgoingKeys:new Set(g.map(O=>xe(O.path,O.name))),deliveredTextHashes:P,cachedComponents:v})}let a=i.flatMap(w=>w.outgoing),c=Xi(a,o),u=new Set(c.components.map(w=>xe(w.path,w.name))),f=[],l=[],d=[],p=[],m=[],_=[],h=[];for(let w of i){let{scope:I,walk:$,delta:v}=w;_.push(...$.components),f.push(I);let x=c.components.filter(O=>w.outgoingKeys.has(xe(O.path,O.name))),P=[...w.outgoingKeys].some(O=>!u.has(O)),U=v.truncated||P;U?d.push(I):v.full&&l.push(I),p.push(...x),!v.full&&!U&&m.push(...v.removed);let g=v.full?{}:{...w.cachedComponents??{}};if(!U)for(let O of v.removed)delete g[xe(O.path,O.name)];for(let O of x)g[xe(O.path,O.name)]=ro(O);h.push({scope:I,scopeRef:$.scopeRef,components:g,textHashes:Yi(w.deliveredTextHashes,x.filter(O=>O.text!==void 0).map(O=>O.content_hash),$.components),collectedAtMs:r,included:x.length>0||v.removed.length>0&&!U||v.full})}let b={user_spec_hash:Ln(_),user_spec_count:_.length,user_spec_truncated:d.length>0};f.length>0&&(b.user_spec_scopes=f,b.user_spec_full_scopes=l,b.user_spec_truncated_scopes=d,b.user_spec_cwd_in_git_repo=t.cwdInGitRepo),l.length>0&&l.length===f.length&&(b.user_spec_full=!0),p.length>0&&(b.user_spec=p),m.length>0&&(b.user_spec_removed=m),c.textDeferredCount>0&&(b.user_spec_text_deferred=c.textDeferredCount);let k=t.scopes.cwd;k&&(b.user_spec_cwd_scope_ref=k.scopeRef);let T=t.scopes.repo;T&&(b.user_spec_repo_scope_ref=T.scopeRef);let N=t.scopes.parent;return N&&(b.user_spec_parent_scope_ref=N.scopeRef,t.parentRel&&(b.user_spec_parent_rel=t.parentRel)),{fields:b,scopes:h}}s(Zi,"buildUserSpecSend");var bo={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function Qi(e){return e==="cwd"||e==="repo"||e==="parent"}s(Qi,"isProjectSpecScope");function Jn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Jn,"isPlainObject");function ea(e){return!Jn(e)||!Jn(e.components)||!Object.values(e.components).every(t=>typeof t=="string")||!Array.isArray(e.text_hashes)||!e.text_hashes.every(t=>typeof t=="string")?!1:typeof e.collected_at_ms=="number"&&Number.isFinite(e.collected_at_ms)}s(ea,"isDirScopeCacheEntry");function am(e){return ux(e)}s(am,"readStringHashMap");function cm(e){return lx(e)}s(cm,"readStringArray");function um(e){return fx(e)}s(um,"cloneDirScopeMap");function ux(e){if(!Jn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}s(ux,"readComponentHashMap");function lx(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}s(lx,"readTextHashes");function lm(e,t){if(!Jn(e))return;let n=e[t];return ea(n)?n:void 0}s(lm,"readDirScopeCacheEntry");function fx(e){if(!Jn(e))return{};let t={};for(let[n,r]of Object.entries(e))ea(r)&&(t[n]=r);return t}s(fx,"readDirScopeCacheMap");function ta(e,t=20){let n=[];for(let[r,o]of Object.entries(e))ea(o)&&n.push([r,o]);return n.sort((r,o)=>o[1].collected_at_ms-r[1].collected_at_ms),Object.fromEntries(n.slice(0,t))}s(ta,"boundDirScopeCache");var _x=["allow","deny","ask"];function xo(e){let t=Q(e,{}),n=[];for(let r of _x)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:Ro(o),mode:r});return{model:t.model??"",permissionKeys:n}}s(xo,"readClaudeSettings");function hx(e){let{serverManaged:t,fileBased:n}=yn(process.platform,e),r=xo(t);if(r.model||r.permissionKeys.length>0)return r;let o="",i=[];for(let a of n){let c=xo(a);c.model&&(o=c.model),i.push(...c.permissionKeys)}return{model:o,permissionKeys:i}}s(hx,"readClaudeManagedSettings");function Sx(e){let t=new Set,n=[];for(let r of e){let o=`${r.mode}\0${r.key}`;t.has(o)||(t.add(o),n.push(r))}return n}s(Sx,"dedupePermissionKeys");var Ex=10,yx="self-config-cache.json",dm=5;function cn(){return D("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}s(cn,"isUserSpecDisabled");function Rx(){return D("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}s(Rx,"isCwdSpecDisabled");var Cx={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function Ax(e,t=se){let n=Cx[e];if(!n||n.length===0)return null;let r=s(async o=>{let i=n[o];if(i===void 0)return null;let c=((await t(i,["--version"],2e3)).split(`
|
|
52
|
+
`)[0]??"").trim();return c||r(o+1)},"tryNext");return r(0)}s(Ax,"resolveCliVersion");function bx(e=fm()){return an(e,".ev-ai","agent-hook",yx)}s(bx,"selfConfigCachePath");function kx(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
|
|
53
|
+
`);return te(n)}s(kx,"hashConfigEntries");function ko(e,t,n=!1){let r=kx(e),o=e.length;return t===r?n?{hash:r,count:o,truncated:n}:{hash:r,count:o}:n?{hash:r,count:o,entries:e,truncated:n}:{hash:r,count:o,entries:e}}s(ko,"buildHashedList");function na(e,t,n=[]){let r=0,o=!1,i=new Set;for(let a of[...t.map(c=>an(e,c)),...n]){let c=gx(a);if(i.has(c))continue;i.add(c);let u=Bo(a);u.present&&(o=!0,r+=u.size)}return o?{present:!0,size:r}:{present:!1,size:0}}s(na,"filePresenceUnion");function xx(e){return px(e)?Te(mx(e,"utf8"),{}):{}}s(xx,"readSelfConfigCache");function Ox(e,t){try{ue(e,`${JSON.stringify(t)}
|
|
54
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);y(`WARN: self-config cache write failed open: ${r}`),L("self_config_cache",n)}}s(Ox,"writeSelfConfigCache");function Ix(e,t,n){if(t==="user")return{components:am(e.user_spec_components),textHashes:cm(e.user_spec_text_hashes)};if(!Qi(t))return{components:void 0,textHashes:[]};let r=lm(e[bo[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}s(Ix,"cacheSliceFor");function Tx(e,t,n,r){let o={...e,send_count:n};for(let i of Object.keys(t)){let a=t[i];a.entries!==void 0&&(o[i]=a.hash)}if(r){o.user_spec_layout_version=dm,r.home&&(o.user_spec_collected_at_ms=r.home.collectedAtMs,r.home.included&&(o.user_spec=r.hash,o.user_spec_components=r.home.components),o.user_spec_text_hashes=r.home.textHashes);for(let i of r.project){if(!Qi(i.scope))continue;let a=bo[i.scope],c=um(o[a]),u=c[i.scopeRef];c[i.scopeRef]={components:i.included?i.components:u?.components??{},text_hashes:i.textHashes,collected_at_ms:i.collectedAtMs},o[a]=ta(c)}}return o}s(Tx,"nextPlatformSelfConfigCache");async function pm(e,t=process.cwd(),n=fm(),r={}){let o=e==="claude",i=r.gitRoot??t,a=await Ax(e),c="",u=[];if(o){let U=hx(n),g=xo(an(n,".claude/settings.json")),O=xo(an(t,".claude/settings.local.json"));c=U.model||O.model||g.model,u=Sx([...U.permissionKeys,...g.permissionKeys,...O.permissionKeys]).slice(0,200)}let f={present:!1,size:0},l=s(U=>{let g=[],O=!1;for(let j of U){let Se=Ba(an(n,j));if(g=g.concat(Se.entries),O=O||Se.truncated,g.length>=st){g=g.slice(0,st),O=!0;break}}return{entries:g,truncated:O}},"listScopeWithMeta"),d=bx(n),p=xx(d),m=p[e]??{},_=(m.send_count??0)+1,h=_>0&&_%Ex===0,b=s(U=>h?void 0:m[U],"cachedHash"),k=l(_t.skills),T=l(_t.subagents),N=l(_t.commands),w=l(_t.rules),I={skills:ko(k.entries,b("skills"),k.truncated),subagents:ko(T.entries,b("subagents"),T.truncated),commands:ko(N.entries,b("commands"),N.truncated),rules:ko(w.entries,b("rules"),w.truncated)},$={runner_platform:e,config_scope:"user",cli_version:a,claude_version:o?a:null,model:o&&c||null,permission_keys:u,user_scope:{skills:I.skills,subagents:I.subagents,commands:I.commands,rules:I.rules,memory:na(n,_t.memory),settings:na(n,_t.settings,Ku(n)),mcp:na(n,_t.mcp)},local_settings:o?Bo(an(t,".claude/settings.local.json")):f},v=null,x=r.nowMs??Date.now();if(!cn()){let U=m.user_spec_layout_version!==dm,g=Wi(e,n,{launchCwd:Rx()?void 0:r.launchCwd,gitRoot:i,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(g.scopes).length>0){let O=Zi({collected:g,cacheFor:s((j,Se)=>U?{components:void 0,textHashes:[]}:Ix(m,j,Se),"cacheFor"),nowMs:x});Object.assign($,O.fields),v={hash:O.fields.user_spec_hash,home:O.scopes.find(j=>j.scope==="user")??null,project:O.scopes.filter(j=>j.scope!=="user")}}}let P=Tx(m,I,_,v);return{config:$,commit:s(()=>{p[e]=P,Ox(d,p)},"commit")}}s(pm,"selfConfig");import{homedir as Yx}from"node:os";import{join as _m}from"node:path";function Ht(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(Ht,"isRecord");import{join as Oo}from"node:path";function Px(e){return Oo(e,".ev-ai","agent-hook","js","signed-v1")}s(Px,"jsRoot");function wx(e){return Oo(Px(e),"scopes")}s(wx,"scopesRoot");function mm(e,t){return Oo(wx(e),t)}s(mm,"scopeDir");function gm(e){return Oo(e,"attempts")}s(gm,"attemptsDir");function ra(e){return String(e).padStart(10,"0")}s(ra,"padAttempt");var Nx=/^(\d{10})$/,vx=/^(\d{10})\.done$/,Mx=/^[0-9a-f]{128}$/,Lx=64,ym=["check_ms","download_ms","install_ms","total_ms"],Hx=36e5;async function Rm(e,t,n=!1){let r=gm(t),o=await Ra(e,r),i=new Map,a=new Map,c=hm(o,Nx),u=hm(o,vx),f=s(async p=>{let m=await Em(e,_m(r,Ux(p)));return m&&i.set(p,{record:Fx(m.value),mtimeMs:m.mtimeMs}),m!==void 0},"readClaimAt"),l=s(async p=>{let m=$x((await Em(e,_m(r,Dx(p))))?.value);return m&&a.set(p,m),m!==void 0},"readDoneAt");if(!n)return await Promise.all([...c.map(f),...u.map(l)]),{claims:i,dones:a};await Promise.all([Sm(c,f),Sm(u,l)]);let d=Yn(i);return d<Yn(a)&&u.includes(d)&&await l(d),{claims:i,dones:a}}s(Rm,"scanAttempts");function hm(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}s(hm,"attemptNumbers");async function Sm(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}s(Sm,"firstFromTop");function Yn(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}s(Yn,"maxKey");function Cm(e){if(e.record!=="empty"&&e.record.started_at){let t=Date.parse(e.record.started_at);if(Number.isFinite(t))return t}return e.mtimeMs}s(Cm,"claimStartMs");function Am(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of ym){let r=e[n];r!==void 0&&(t[n]=r)}return t}s(Am,"pickTimings");function Ux(e){return ra(e)}s(Ux,"claimFileName");function Dx(e){return`${ra(e)}.done`}s(Dx,"doneFileName");async function Em(e,t){let n;try{n=await e.stat(t)}catch(o){if(Ft(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>Ho)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>Ho?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}s(Em,"readRecord");function Fx(e){if(!Ht(e))return"empty";let t={};return typeof e.started_at=="string"&&(t.started_at=e.started_at),(e.owner==="bootstrap"||e.owner==="refresh")&&(t.owner=e.owner),e.resync===!0&&(t.resync=!0),t}s(Fx,"parseClaim");function $x(e){if(!Ht(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=Bx(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...jx(t)}}s($x,"parseDoneRecord");function jx(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 ym){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=Hx&&(t[n]=r)}return t}s(jx,"parseTimings");function Bx(e){if(!Ht(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"&&Mx.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&Kx(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}s(Bx,"parseSelection");function Kx(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==Lx||t.toString("base64")!==e))return t.toString("hex")}s(Kx,"canonicalSha512Hex");function zx(e){return e==="bootstrap"?3e3:6e4}s(zx,"ownerBudgetMs");function Jx(e,t){let n=Yn(e.claims);if(n===0)return;let r=Yn(e.dones),o=e.claims.get(n),i=e.dones.get(n);if(o&&!i){let c=Cm(o),u=o.record==="empty"?void 0:o.record.owner,f=zx(u)+3e4;if(t-c>f)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:bm(e.dones.get(r)?.selection)}}if(r===0)return;let a=e.dones.get(r);if(a)return{n:r,latest_claim:n,outcome:a.outcome,finished_at:a.finished_at,selection_version:bm(a.selection),...Am(a)}}s(Jx,"latestAttemptReport");async function km(e,t,n){try{let r=await Rm(Ca(),mm(e,t),!0);return Jx(r,n)}catch{return}}s(km,"readLatestAttemptReport");function bm(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}s(bm,"selectionVersion");function Xx(e=process.env){if(Object.values(cc).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===Ae?"npx":null}s(Xx,"hookDelivery");async function xm(e=Yx()){let t=Ks()?.launcherScope;if(!t)return{};let n=await km(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}s(xm,"readSessionStartLauncherFields");function un(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:at,event:e,timestamp:cr(),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:pe,hook_delivery:Xx(),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},i=Ks();return i&&(o.launcher_version=i.launcherVersion,o.hook_source=i.hookSource,o.hook_fallback_reason=i.fallbackReason??null,o.launcher_scope_match=sf(n.collectorUrl,i.launcherScope)),e==="session_start"&&(n.launcher_scope&&(o.launcher_scope=n.launcher_scope),n.launcher_attempt&&(o.launcher_attempt=n.launcher_attempt)),o}s(un,"buildEnvelope");import{existsSync as Om}from"node:fs";import{spawn as Im}from"node:child_process";import{fileURLToPath as Zx}from"node:url";import{gzipSync as qx}from"node:zlib";function oa(e){return D("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<ic?{body:e}:{body:qx(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}s(oa,"gzipBodyIfLarge");function Io(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}s(Io,"collectorPostHeaders");function sa(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}s(sa,"postBodyByteLength");var ln="__post",fn="__work";async function Qx(e,t,n={}){if(cn())return e;let r=await Qs(n.gitRoot??process.cwd(),se,process.env,{runnerPlatform:t,home:n.home}),o=Ht(e.self_config)?e.self_config:{};return{...e,self_config:{...o,runner_platform:typeof o.runner_platform=="string"?o.runner_platform:t,operator:r}}}s(Qx,"attachOperatorIdentity");function eO(e,t){let n=Ht(e.payload)?Object.keys(e.payload):[],r=e.correlation&&typeof e.correlation=="object"?Object.keys(e.correlation):[];return JSON.stringify({event:e.event,schema_version:e.schema_version,agent_hook_version:e.agent_hook_version,host_arch:e.host_arch,node_version:e.node_version,build_ms:e.build_ms,body_bytes:t,correlation_keys:r,payload_keys:n})}s(eO,"debugEnvelopeSummary");function Tm(e){switch(e){case"session_start":return nc;case"session_end":return rc;case"tool_invoked":case"skill_invoked":return zo;default:return zo}}s(Tm,"timeoutForEvent");function tO(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
|
|
55
|
+
${n}`}s(tO,"frameDetachedPostStdin");function Pm(e,t=[],n=process.execPath,r=import.meta.url,o=Om){if(hr(n))return{command:n,args:[e,...t]};let i=Zx(r);return o(i)?{command:n,args:[i,e,...t]}:{command:n,args:[e,...t]}}s(Pm,"resolveSelfReexecCommand");function nO(e=process.execPath,t=import.meta.url,n=Om){let r=process.argv.includes("--debug")?["--debug"]:[];return Pm(ln,r,e,t,n)}s(nO,"resolveSelfPostCommand");function rO(e){let t=e.indexOf(`
|
|
56
|
+
`);if(t<0)return null;let n;try{n=JSON.parse(e.slice(0,t))}catch{return null}return{meta:n,body:e.slice(t+1)}}s(rO,"parseDetachedPostStdin");async function wm(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();cu(n,t)}catch(n){L("collector_response",n)}}s(wm,"applyCollectorHttpResponse");function Nm(e){let t=e instanceof Error?e.message:String(e);return{code:e!==null&&typeof e=="object"&&"code"in e&&typeof e.code=="string"?e.code:void 0,message:t}}s(Nm,"errorParts");var vm=1e3;function Mm(e,t){let n=e instanceof Error&&e.name==="TimeoutError"?"timeout":"post_failed";ee({outcome:n,postMs:t,err:lt(e)})}s(Mm,"noteFailedPost");async function To(e,t=fetch){try{let n=await e(),r=rO(n);if(!r){le.error("send fail code=bad-frame message=detached post stdin was not framed"),ee({outcome:"post_failed",err:"bad-frame"});return}let{meta:o,body:i}=r,a=oa(i),c=Io(a.contentEncoding),u=performance.now();try{let f=await t(o.url,{method:"POST",headers:c,body:a.body,signal:AbortSignal.timeout(Number(o.timeoutMs))}),l=performance.now()-u;if(!f.ok){let d=(await f.text()).slice(0,vm).replace(/[\n\r]/g,"");le.error(`send fail http=${f.status} code=${f.status} body=${d}`),ee({outcome:"post_failed",postMs:l,http:f.status});return}le.info(`send ok http=${f.status}`),ee({outcome:"posted",postMs:l,http:f.status}),await wm(f,o.url)}catch(f){let l=Nm(f);le.error(`send fail code=${l.code??"(none)"} ${Tr(f)}`),Mm(f,performance.now()-u)}}catch(n){L("post",n),ee({outcome:"error",err:lt(n)})}finally{Vt("post",pe,"error")}}s(To,"runDetachedPoster");async function oO(e,t,n,r=fetch){let o=Tm(e),i=oa(t),a=Io(i.contentEncoding),c=sa(i.body);y(`POST event=${e} url=${Bt(n)} size=${c} encoding=${i.contentEncoding??"identity"} platform=${process.platform}`);let u=Date.now(),f=performance.now();try{let l=await r(n,{method:"POST",headers:a,body:i.body,signal:AbortSignal.timeout(o)});if(!l.ok&&i.contentEncoding==="gzip"&&(l.status===400||l.status===415)){try{await l.text()}catch{}y(`POST gzip rejected http=${l.status} \u2014 retrying uncompressed`),l=await r(n,{method:"POST",headers:Io(),body:t,signal:AbortSignal.timeout(o)})}let d=Date.now()-u,p=performance.now()-f;if(Ws(p),l.ok)return y(`POST outcome=ok elapsed_ms=${d} http=${l.status}`),le.info(`send ok http=${l.status}`),ee({outcome:"posted",postMs:p,http:l.status}),await wm(l,n),!0;let m=(await l.text()).slice(0,vm).replace(/[\n\r]/g,"");return y(`POST outcome=fail elapsed_ms=${d} http=${l.status} body=${m}`),le.error(`send fail http=${l.status} code=${l.status} body=${m}`),ee({outcome:"post_failed",postMs:p,http:l.status}),!1}catch(l){let d=Date.now()-u,p=performance.now()-f;Ws(p);let m=Nm(l);return y(`POST outcome=fail elapsed_ms=${d} http=000 body=${m.message}`),le.error(`send fail http=0 code=${m.code??"(none)"} ${Tr(l)}`),Mm(l,p),!1}}s(oO,"postCollector");async function Lm(e,t,n,r,o){let i=o.replaceAll(" ","_");try{let a=r(e,t,{detached:!0,stdio:["pipe","ignore","ignore"],windowsHide:!0});a.on("error",u=>{L(i,u)}),a.stdin.on("error",u=>{L(`${i}_stdin`,u)});let c=!1;return await new Promise(u=>{let f=setTimeout(()=>{if(!c){y(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`),le.error(`failed where=${i} err=timeout message=stdin handoff timed out`);try{a.stdin.destroy()}catch{}}u()},oc),l=s(()=>{c=!0,clearTimeout(f),u()},"done");a.stdin.end(n,()=>l()),a.stdin.once("error",()=>l())}),a.unref(),a}catch(a){let c=a instanceof Error?a.message:String(a);return y(`WARN: ${o} spawn failed open: ${c}`),L(i,a),null}}s(Lm,"spawnDetachedStdinChild");async function sO(e,t,n,r=Im,o=nO){let i=Tm(e),a=tO(n,i,t),{command:c,args:u}=o();return Lm(c,u,a,r,"detached post")}s(sO,"postCollectorDetached");async function Hm(e,t,n=Im,r=Pm){let{command:o,args:i}=r(fn,t);return Lm(o,i,e,n,"detached work")}s(Hm,"runHookDetached");async function dn(e,t,n,r,o,i,a,c){if(!o)return y("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),le.error("send fail code=missing message=collector URL missing"),ee({outcome:"no_collector",err:"missing"}),!1;if(!_r(o))return y(`WARN: collector URL blocked (https required): ${Bt(o)}`),le.error("send fail code=blocked message=collector URL blocked"),ee({outcome:"no_collector",err:"blocked"}),!1;let u=performance.now(),f=await Qx(t,n.runnerPlatform,a),l=performance.now(),d=r(e,f,{...n,collectorUrl:o});i!==void 0&&(d.build_ms=Math.max(0,Date.now()-i));let p=ff({w4:u,w4e:l,w5:performance.now()},process.env,void 0,n.telemetry?.enabled===!0);p&&(d.perf=p);let m=JSON.stringify(d),_=c?.attach(Buffer.byteLength(m,"utf8"));_&&(d.run_log=_,m=JSON.stringify(d));let h=`${m}
|
|
57
|
+
`,b=D("EV_AI_HOOK_DEBUG");b==="full"?y(`DEBUG envelope=${m}`):b==="1"&&y(`DEBUG summary=${eO(d,sa(h))}`);let k=process.argv.includes(fn),T=D("EV_AI_HOOK_SYNC")==="1";if(!(Wr(n.runnerEvent,n.runnerPlatform)||k||T)){let w=await sO(e,h,o);return ee(w?.pid!==void 0?{outcome:"handed_off"}:{outcome:"post_failed",err:"spawn"}),!1}return oO(e,h,o)}s(dn,"emitAndPost");import{closeSync as iO,fstatSync as aO,linkSync as cO,openSync as uO,readdirSync as lO,readSync as fO,renameSync as dO,unlinkSync as Km}from"node:fs";import{homedir as pO}from"node:os";import{basename as mO,dirname as gO}from"node:path";var Um=ns,Dm=2*1024*1024,_O=Buffer.byteLength(',"run_log":',"utf8");function Fm(e){let t=`${e}.send-${process.pid}`;try{return dO(e,t),{path:e,taken:t}}catch(n){return n.code==="ENOENT"?"missing":"busy"}}s(Fm,"take");function $m(e){return typeof e=="object"}s($m,"isTaken");function hO(e){let t=`${mO(e)}.`;try{return lO(gO(e)).some(n=>n.startsWith(t)&&/\.send-\d+$/.test(n))}catch{return!1}}s(hO,"anyTakenLog");function SO(e){try{cO(e.taken,e.path),Km(e.taken)}catch{}}s(SO,"putBack");function EO(e){try{Km(e)}catch{}}s(EO,"unlinkQuiet");function jm(e,t){let n;try{n=uO(e,"r");let r=aO(n);if(!r.isFile())return;let o=Math.min(r.size,Math.max(0,t)),i=Buffer.alloc(o),a=0;for(;a<o;){let c=fO(n,i,a,o-a,r.size-o+a);if(c===0)break;a+=c}return{tail:i.subarray(0,a),size:r.size}}catch{return}finally{if(n!==void 0)try{iO(n)}catch{}}}s(jm,"readTail");function yO(e){let t=e.indexOf(10);return t===-1?e:e.subarray(t+1)}s(yO,"fromFirstWholeLine");function Bm(e,t,n){is(r=>{r[t]===n&&delete r[t]},e)}s(Bm,"forgetWindow");function Gm(e,t=pO(),n=process.env,r=Date.now()){try{let o=e?bt(e):void 0;if(!o||Lc())return;let i=ss(t)[o];if(i===void 0||i===Gt)return;let a=Date.parse(i);if(Number.isNaN(a)||a>r)return;let c=Nc(t,n,r);if(c.on||c.source!=="remote")return;let u=Or(t),f=Fm(u),l=Fm(`${u}.1`),d=$m(f)?f:void 0,p=$m(l)?l:void 0,m=[p,d].filter(P=>P!==void 0),_=s(()=>{for(let P of m)SO(P)},"putAllBack"),h=d?jm(d.taken,Um):void 0,b=p?jm(p.taken,Um-(h?.tail.length??0)):void 0,k=(h?.size??0)+(b?.size??0);if(k===0){_(),f!=="busy"&&l!=="busy"&&!hO(u)&&Bm(t,o,i);return}let T=Buffer.concat([b?.tail??Buffer.alloc(0),h?.tail??Buffer.alloc(0)]),N=T.length<k,w=N?yO(T):T,I={log_until:i,text:w.toString("utf8"),bytes:w.length,bytes_total:k,truncated:N},$=_O+Buffer.byteLength(JSON.stringify(I),"utf8"),v=!1,x=!1;return{attach(P){if(P+$>Dm){y(`run log deferred: body=${P} run_log=${$} over ${Dm}`);return}return v=!0,I},settle(P){if(!x){if(x=!0,!(v&&P)){_();return}for(let U of m)EO(U.taken);Bm(t,o,i)}}}}catch(o){y(`WARN: run log upload failed open: ${o instanceof Error?o.message:String(o)}`);return}}s(Gm,"prepareRunLogUpload");import{createReadStream as RO}from"node:fs";import{stat as CO}from"node:fs/promises";import{basename as AO,resolve as bO}from"node:path";import{createInterface as kO}from"node:readline";var xO=1024*1024;function OO(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&AO(t).endsWith(".jsonl")}s(OO,"isSafeClaudeTranscriptPath");async function Vm(e){if(!e||!OO(e))return null;try{let t=bO(e),n=await CO(t);if(!n.isFile())return null;let r=Math.max(0,n.size-xO),o=[],i=kO({input:RO(t,{encoding:"utf8",start:r}),crlfDelay:1/0});for await(let a of i)a.length!==0&&o.push(a);r>0&&o.length>0&&o.shift();for(let a=o.length-1;a>=0;a--){let c=o[a];if(c)try{let u=JSON.parse(c);if(u.type!=="assistant")continue;let f=u.message;if(!f||typeof f!="object")continue;let l=f.model;if(typeof l=="string"&&l.length>0)return l}catch{continue}}return null}catch{return null}}s(Vm,"lastAssistantModelFromTranscript");function Po(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:oo(e.manifest.manifest,e.manifest.hookConfig),telemetry:Jm(e)}}s(Po,"envelopeFieldsFromContext");function Jm(e){return lu(e.manifest.localTelemetry,e.manifest.hookConfig)}s(Jm,"telemetryFor");function qn(e,t){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{}}}s(qn,"operatorContextFrom");function aa(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:ii(e.manifest.hookConfig)}}s(aa,"hookInputSanitizeOptions");async function Ym(e){let t=Date.now();await FO(e);let{gitRoot:n}=e.manifest;await ua(e,n);let r=aa(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:io(e.hookInput,e.manifest.manifest,r),envelopeFields:Po(e),launchCwd:ai(e.hookInput,r),home:TO()}}s(Ym,"prepareDerivedInvoke");function Wm(e){try{return ke(IO(e))}catch{return null}}s(Wm,"tryRealpath");function Xm(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}s(Xm,"isAbsolutePath");function zm(e,t){let n=e.replaceAll("\\","/");if(!Xm(n))return null;let r=ke(e),o=ke(t),i=Wm(e)??r,a=Wm(t)??o;return i.startsWith(`${a}/`)?i.slice(a.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}s(zm,"relativeToAnchor");function qm(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),i=zm(e,t)??(Xm(r)?null:r),a=zm(e,n);return{repositorySourcePath:i,userSourcePath:a}}s(qm,"sourcePathsFromResolvedFile");function ia(e,t,n,r,o){return Zm(e,qm(n,t.gitRoot,t.home),r,o)}s(ia,"exactFileComponentFromResolvedPath");function Zm(e,{repositorySourcePath:t,userSourcePath:n},r,o){let i=t??n,a=i===null?null:o(i),c=a!==null&&i!==null?PO({installableKind:r,sourcePath:i,nativeKey:a,inRepository:t!==null,platformAgentId:e.platformAgentId,installationId:e.manifest.installationId}):void 0;return{sourcePath:i,nativeKey:a,componentReference:c}}s(Zm,"exactFileComponent");function PO(e){try{let t=e.inRepository?vO(e.platformAgentId,e.sourcePath):(0,V.installationRootExternalKey)(e.installationId,(0,V.userConfigRootFromPath)(e.sourcePath));return t?(0,V.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}s(PO,"tryExactFileComponentReference");function Qm(e){let t=e.policyFindings;return t===void 0||t.length===0?{}:{policy_findings:t,...e.policyJudgeSpawnMs!==void 0?{policy_judge_spawn_ms:e.policyJudgeSpawnMs}:{}}}s(Qm,"policyPayload");function ca(e,t,n){return dn("tool_invoked",{...n,...Qm(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,un,e.manifest.collectorUrl,t.buildStartedAtMs,qn(e,t.home))}s(ca,"postDerivedToolInvoked");function wO(e){return wl(e.runnerEvent,e.runnerPlatform)?[]:Xu(e.hookInput)}s(wO,"slashIdsFromHookInput");function NO(e,t){return ca(e,t,{})}s(NO,"postPromptSubmitted");var eg=new Set([...Object.values(Pt),".github"]);function vO(e,t){let n=e.indexOf(":");if(n<=0)return null;let r=e.slice(0,n),o=t.replaceAll("\\","/").split("/").filter(Boolean),i=o.findIndex(a=>eg.has(a));return i<0?null:`${r}:${o.slice(0,i+1).join("/")}`}s(vO,"repositoryConfigRootExternalKey");var tg=".codex/config.toml",MO=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",tg]]);function LO(e,t,n,r,o,i,a){if(e===null||t===null||!(a!==null||/^mcp__.+?__.+$/i.test(e)||/^MCP:[^:]+:.+$/i.test(e)||/^MCP:.+__.+$/i.test(e)||e.toLowerCase()===`mcp:${t.toLowerCase()}`))return;let u=i.find(h=>h.name.toLowerCase()===t.toLowerCase()),f=u?MO.get(u.source):o==="codex"?tg:void 0,l=u?.sourcePath??f;if((u?.scope==="user"||f!==void 0)&&l)try{let h=(0,V.userConfigRootFromPath)(l);return(0,V.buildComponentReference)({installationRootExternalKey:(0,V.installationRootExternalKey)(r,h),installableKind:V.ComponentKind.INTERFACE,sourcePath:l,nativeKey:u?.name??t})}catch{return}if(n===null)return;let p=n.indexOf(":");if(p<=0||p===n.length-1)return;let m=n.slice(p+1),_=m.replaceAll("\\","/").split("/").at(-1);if(!(_===void 0||!eg.has(_)))try{return(0,V.buildComponentReference)({installationRootExternalKey:n,installableKind:V.ComponentKind.INTERFACE,sourcePath:m,nativeKey:t})}catch{return}}s(LO,"exactMcpComponentReference");function HO(...e){for(let t of e)if(t)return t;return null}s(HO,"firstNonEmpty");function Dt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return y(`WARN: ${n} failed open: ${r}`),L(n,e.reason),t}s(Dt,"settledOr");function UO(e){let t={present:!1,size:0},n={hash:"",count:0};return{config:{runner_platform:e,config_scope:"user",cli_version:null,claude_version:null,model:null,permission_keys:[],user_scope:{skills:n,subagents:n,commands:n,rules:n,memory:t,settings:t,mcp:t},local_settings:t},commit:s(()=>{},"commit")}}s(UO,"emptySelfConfigResult");function DO(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}s(DO,"cloudBootstrapSelfConfig");var Ut=new Set,Xn=null;async function FO(e){if(cn())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(Ut.has(t))return;if(!ti(n)){Ut.add(t);return}let r=Cn({sessionId:e.sessionId,hostname:Ar()});if(jf(r)){if(Xn){await Xn;return}Xn=(async()=>{if(Ut.has(t)||!ti(n)){Ut.add(t);return}if(!eu(n)){Ut.add(t);return}let o=!1;try{let i=Date.now(),{gitRoot:a}=e.manifest,c=String(e.runnerPlatform),{operatorResolved:u,fields:f}=await ng(e,r,De("git",()=>Gr(a)),De("operator",()=>ei({gitRoot:a,installationStorePath:n,forceResend:!1,runnerPlatform:c}))),l={...f,self_config:DO(c,u.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await dn("session_start",l,Po(e),un,e.manifest.collectorUrl,i,qn(e)),o&&(u.commit(),Ut.add(t))}finally{tu(n)}})().finally(()=>{Xn=null}),await Xn}}s(FO,"maybeBootstrapCloudIdentity");async function ua(e,t,n){try{e.platformAgentId=await Rl(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);y(`WARN: derivePlatformAgentId failed open: ${o}`),L("platform_agent_id",r)}}s(ua,"resolvePlatformAgentId");async function ng(e,t,n,r){let[o,i,a,c,u]=await Promise.allSettled([n,De("virt",()=>_c()),De("cloud",()=>pf(t)),De("host_env",()=>Sc(Jm(e).enabled)),r]),f=Dt(o,null,"gitSnapshot"),l=Dt(i,"","detectVirt"),d=Dt(a,null,"probeCloud"),p=Dt(c,{},"hostEnv"),m=Dt(u,{commit:s(()=>{},"commit")},"resolveOperatorForSend");return await ua(e,e.manifest.gitRoot,f),{operatorResolved:m,fields:{identity:{host:Ar(),context:t,virt:l||null,cloud:d,git:f},host_env:p,env_vars:yf()}}}s(ng,"collectIdentityPayload");async function $O(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=Cn({sessionId:e.sessionId,hostname:Ar()}),o=String(e.runnerPlatform),i=aa(e),a=ai(e.hookInput,i),c=De("git",()=>Gr(n)),u=xm().catch(v=>(L("launcher_fields",v),{})),f=cn()?Promise.resolve({commit:s(()=>{},"commit")}):De("operator",()=>ei({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o})),l=ng(e,r,c,f),[d,p]=await Promise.allSettled([De("mcp_declared",()=>Js(e.manifest.manifest,n,o)),c.catch(()=>null).then(v=>De("self_config",()=>pm(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:a,inGitRepo:e.manifest.inGitRepo,remote:v?.remote??null})))]),{operatorResolved:m,fields:_}=await l,h=Dt(d,[],"mcpDeclared"),b=Dt(p,UO(o),"selfConfig"),k=b.config,T=F(e.hookInput,"model");T&&(k.model=T);let N={..._,mcp:{declared:h},self_config:k,run_meta:{trigger:e.hookSource||"startup"},hook_input:io(e.hookInput,e.manifest.manifest,{...i,launchCwd:a})},w=await u,I=Gm(e.manifest.collectorUrl),$=!1;try{$=await dn("session_start",N,{...Po(e),...w},un,e.manifest.collectorUrl,t,qn(e),I)}finally{I?.settle($)}$&&(b.commit(),m.commit(),Ut.add(e.manifest.installationId))}s($O,"handleSessionStart");async function jO(e){let t=Date.now(),[,n]=await Promise.all([ua(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?Vm(F(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=HO(F(e.hookInput,"status"),F(e.hookInput,"stop_reason"),F(e.hookInput,"reason"),Pn(F(e.hookInput,"error")),r==="stop"?We(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),i=io(e.hookInput,e.manifest.manifest,aa(e));n&&(i.model=n),r!=="stopfailure"&&oo(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&i.last_assistant_message===void 0&&(i.last_assistant_message=""),await dn("session_end",{status:o,...n?{model:n}:{},hook_input:i},Po(e),un,e.manifest.collectorUrl,t,qn(e))}s(jO,"handleSessionEnd");async function BO(e){let t=wO(e),n=kl(e.hookInput),r=Pl(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&oo(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let i=await Ym(e);await Promise.all([o?NO(e,i):void 0,t.length===0?void 0:KO(e,i,t),n.length===0?void 0:GO(e,i,n)])}s(BO,"handleSkillInvoked");function rg(e,t,n,r){let o=r??Yu({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),i=ia(e,t,o,V.ComponentKind.SKILL,V.nativeKeyForSkillPath);if(i.sourcePath!==null&&bs(i.sourcePath)?.toLowerCase()===n.toLowerCase())return i.componentReference===void 0?{}:{componentReference:i.componentReference};let a=r??xl({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),c=ia(e,t,a,V.ComponentKind.COMMAND,V.nativeKeyForCommandPath);return c.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:c.nativeKey,...c.componentReference===void 0?{}:{componentReference:c.componentReference}}}s(rg,"slashComponentIdentity");function KO(e,t,n){let r=Ur(e.hookInput.tool_input);return Promise.all(n.map(o=>{let i=rg(e,t,o,r);return ca(e,t,{tool_name:"Skill",skill_name:o,...i.commandName===void 0?{}:{command_name:i.commandName},...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(KO,"postSkillInvokes");function GO(e,t,n){return Promise.all(n.map(r=>{let o=Cl({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),i=ia(e,t,o,V.ComponentKind.RULE,V.nativeKeyForRulePath),a=i.nativeKey??bl(r);return ca(e,t,{tool_name:"Rule",rule_name:a,...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(GO,"postRuleInvokes");var VO=[{kind:V.ComponentKind.SKILL,nativeKeyFn:V.nativeKeyForSkillPath},{kind:V.ComponentKind.RULE,nativeKeyFn:V.nativeKeyForRulePath},{kind:V.ComponentKind.COMMAND,nativeKeyFn:V.nativeKeyForCommandPath}];function WO(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=xs(e.hookInput);if(r===null)return n.skillName===null?{}:rg(e,t,n.skillName,null);let o=qm(r,t.gitRoot,t.home);for(let i of VO){let a=Zm(e,o,i.kind,i.nativeKeyFn);if(a.nativeKey!==null)return{...a.componentReference===void 0?{}:{componentReference:a.componentReference},...i.kind===V.ComponentKind.RULE?{ruleName:a.nativeKey}:{},...i.kind===V.ComponentKind.COMMAND?{commandName:a.nativeKey}:{}}}return{}}s(WO,"toolComponentIdentity");var zO=/mcp/i;function JO(e,t,n,r){let o=zO.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let i=o?Np(t,n):yo(r.declaredConfig,n);return i===null?{}:Object.fromEntries(Object.entries(i).filter(a=>typeof a[1]=="string").map(([a,c])=>[`mcp_${a}`,c]))}s(JO,"mcpPackageFields");async function YO(e){let t=await Ym(e),n=Ml(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,i=ks(e.hookInput),a=Pp(i,t.home),c=Hl(e.hookInput),u=Nl(e.runnerEvent),f=u===!1?Ul(e.hookInput,e.runnerEvent):null,l=Pn(F(e.hookInput,"mcp_server_name")),d=l!==null||r!==null&&Jr(r)?await Js(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch($=>(L("mcpDeclared",$),[])):[],{mcpServer:p,mcpTool:m}=Fl(r,d.map($=>$.name),l??""),_=LO(r,p,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),d,l),h=_===void 0?WO(e,t,n):{},b=p===null?null:Ef(p,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),k=JO(e,i,t.home,{hasMcpIdentity:!!p||!!m,declaredConfig:b}),T=_??h.componentReference,N=h.ruleName??n.ruleName,w=h.commandName??n.commandName,I=Ll(e.hookInput);await dn("tool_invoked",{tool_name:r,skill_name:o,...N?{rule_name:N}:{},...w?{command_name:w}:{},success:u,duration_ms:c,...a?{executable:a}:{},...f?{failure_reason:f}:{},...p?{mcp_server:p}:{},...m?{mcp_tool:m}:{},...k,...T?{component_reference:T}:{},...I?{subagent_type:I}:{},...Qm(e),hook_input:t.hookInput},t.envelopeFields,un,e.manifest.collectorUrl,t.buildStartedAtMs,qn(e,t.home))}s(YO,"handleToolInvoked");async function og(e){switch(Je("w3"),e.internalEvent){case"session_start":await $O(e);return;case"session_end":await jO(e);return;case"skill_invoked":await BO(e);return;case"tool_invoked":await YO(e);return;default:return}}s(og,"dispatchInternalEvent");import{mkdirSync as XO,readdirSync as qO,readFileSync as ZO,statSync as sg,unlinkSync as QO,writeFileSync as eI}from"node:fs";import{homedir as wo}from"node:os";import{join as la}from"node:path";var tI="turns",ig=1440*60*1e3,nI=100,rI=new Set(["stop","stopfailure","sessionend"]);function fa(e=wo()){return la(Re(e),tI)}s(fa,"sessionTurnDir");function ag(e,t){return la(e,Sn(t))}s(ag,"sessionTurnPath");function oI(e,t=Date.now()){let n;try{n=qO(e)}catch{return}let r=0;for(let o of n){if(r>=nI)return;r+=1;try{let i=la(e,o);t-sg(i).mtimeMs>ig&&QO(i)}catch{}}}s(oI,"pruneStaleSessionTurns");function sI(e,t,n=wo()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let i=fa(n);XO(i,{recursive:!0}),eI(ag(i,r),o,"utf8")}catch{}}s(sI,"rememberSessionTurn");function iI(e,t=wo()){let n=e.trim();if(!n)return"";try{let r=ag(fa(t),n);return Date.now()-sg(r).mtimeMs>ig?"":ZO(r,"utf8").trim()}catch{return""}}s(iI,"recallSessionTurn");function cg(e,t,n,r=wo()){let o=t.trim(),i=rI.has(n.trim().toLowerCase());return i&&oI(fa(r)),o?(sI(e,o,r),o):i?iI(e,r):""}s(cg,"resolveTurnId");function dg(e){let t=Te(e,{});return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}s(dg,"parseHookInput");async function aI(e,t,n){let r=t??await lr(Sr),o=dg(r),i=await du(process.cwd(),{sessionId:Qt(o)});if(Je("w2"),!i){ee({outcome:"no_manifest"});return}let a=vl(o,i.manifest.platform,n),c=zr(e,a.runnerEvent);if(!c){y(`WARN: unknown hook event '${a.runnerEvent}'; skipping telemetry`),ee({outcome:"unknown_event"});return}ee({runner:a.runnerPlatform,event:c,session:a.sessionId});let u={hookInput:o,sessionId:a.sessionId,turnId:cg(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await og(u)}s(aI,"runHook");function cI(e,t=!1){if(D("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,i=Zt(r,o,void 0,n.runner);return Wr(o,i)?!0:t}s(cI,"shouldRunHookInProcess");function ug(e,t){let n=mr(e),r=dg(t),o=n.event??Ls(r);return mc()||Tl(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}s(ug,"preflight");function pg(e){return ql(zr(e.parsed.event,e.runnerEvent))}s(pg,"isCapExempt");async function lg(e,t,n){let{parsed:r}=e,o=n??js(r.slot);if(!o&&!pg(e)){let i=$s(r.cap),a=rf(i);if(!a){Bs(i),ee({outcome:"cap_dropped"});return}o=a}try{await aI(r.event,t,r.runner)}finally{o&&qr(o)}}s(lg,"runHookInSlot");var No,pn=!1,uI=500;function lI(){let e=s(()=>{process.exit(0)},"exitNow");setTimeout(e,uI);try{process.stdout.write('{"continue":true}',e)}catch{e()}}s(lI,"ackThenExit");function mg(e,t){let n=e[0]===fn?"w":e[0]===ln?"post":"h";No=void 0,pn=!1;let r=s(a=>c=>{try{L(a,c),Hc()||(ee({outcome:"error",err:lt(c)}),Vt(No??n,pe,"error"))}catch{}if(t){if(n==="h"&&!pn){pn=!0,lI();return}process.exit(0)}},"onCrash"),o=r("uncaught"),i=r("unhandled_rejection");return process.on("uncaughtException",o),process.on("unhandledRejection",i),()=>{process.off("uncaughtException",o),process.off("unhandledRejection",i)}}s(mg,"installCrashLogging");async function gg(e=process.argv.slice(2),t=!1){if(t||Ir(e),Cc(),No=void 0,pn=!1,Je(e[0]===fn?"w0":"h0"),of(),D("EV_AI_HOOK_JUDGE")==="1"){try{await lr(Sr)}catch{}return $o(),pn=!0,0}if(e[0]===ln){try{await To(En)}catch{}return 0}if(e[0]===fn){let i=!1;try{let a=await En();Je("w1");let c=ug(e.slice(1),a);if(!c)return ee({outcome:"suppressed"}),0;fg(c),i=zr(c.parsed.event,c.runnerEvent)==="session_start",await lg(c,a)}catch(a){let c=a instanceof Error?a.message:String(a);y(`WARN: detached work failed open: ${c}`),L("work",a),ee({outcome:"error",err:lt(a)})}finally{Vt("w",pe,"no_post"),i&&Dc()}return 0}let n,r="error",o=!1;try{Uc();let i=await lr(Sr);Je("h1");let a=ug(e,i);if(!a)return r="suppressed",0;fg(a);let{parsed:c,hookInput:u,runnerEvent:f}=a;if(n=js(c.slot),!Gl(u,f,c.runner))return r="duplicate",0;if(Je("h2"),cI(a))o=!0,No="inproc",r="no_post",await lg(a,i,n);else{let l=n||pg(a)?void 0:$s(c.cap);if(l===void 0||tf(l)){Je("h3"),uf();let d=await Hm(i,e);n&&d?.pid!==void 0&&Ql(n,d.pid),d?.pid!==void 0?r="handed_off":(r="error",ee({err:"spawn"}))}else Bs(l),r="cap_dropped"}}catch(i){let a=i instanceof Error?i.message:String(i);y(`WARN: hook failed open: ${a}`),L("hook",i),r="error",ee({outcome:"error",err:lt(i)})}finally{n&&qr(n),$o(),pn=!0,ee({ackMs:performance.now()}),Vt(o?"inproc":"h",pe,r)}return 0}s(gg,"main");function fg({parsed:e,hookInput:t,runnerEvent:n}){ee({runner:Zt(t,n,void 0,e.runner),event:n,session:Qt(t),tool:typeof t.tool_name=="string"?t.tool_name:void 0})}s(fg,"noteInvocation");function vo(){y("Usage: ev-ai-agent-hook <configure|install|migrate-to-plugin|update|uninstall|--version>"),y(" configure [--url <\u2026/{orgToken}/hook>]"),y(" (manifest only \u2014 pair with marketplace plugins)"),y(" install --url <\u2026/{orgToken}/hook>"),y(" [--delivery npx|binary|local] [--force]"),y(" [--no-claude] [--no-cursor] [--no-codex]"),y(" (fallback: merge hooks into .claude / .cursor / .codex configs)"),y(" (writes collector_url to shared manifest; hook commands use --runner only)"),y(" migrate-to-plugin"),y(" (strip ev-ai file hooks; keep collector manifest)"),y(" update (refresh binary pins from a local build; leaves hook configs alone)"),y(" uninstall"),y("Hook mode: --runner <platform> [--url <\u2026/hook>|--token <orgToken>] [event]"),y(" (--url/--token optional overrides; else collector_url from manifest)")}s(vo,"printHelp");var gI=new Set(["configure","install","migrate-to-plugin","update","uninstall","help","--help","-h","--version","-V"]);function _I(e){let[t]=e;return t!==void 0&&!gI.has(t)}s(_I,"isHookModeArgv");function _g(e){return e.includes("--help")||e.includes("-h")}s(_g,"wantsHelp");async function hI(e=process.argv.slice(2)){Ir(e);let[t,...n]=e;if(t===ln){try{await To(En)}catch(r){L("post",r)}return 0}return t==="--version"||t==="-V"?(process.stdout.write(`${pe}
|
|
58
|
+
`),0):t==="configure"?_g(n)?(vo(),0):(await Mu(yu(n)),0):t==="install"?_g(n)?(vo(),0):(await Nu(Ru(n)),0):t==="migrate-to-plugin"?(await Hu(),0):t==="update"?(await vu(),0):t==="uninstall"?(await Uu(),0):t==="help"||t==="--help"||t==="-h"?(vo(),0):t===void 0?(vo(),1):gg(e,!0)}s(hI,"main");function SI(e,t,n=fI){if(!t)return!1;try{return e===mI(dI(t)).href?!0:n(pI(e))===n(t)}catch{return!1}}s(SI,"isCliEntrypoint");if(SI(import.meta.url,process.argv[1])&&process.env.VITEST===void 0){let e=process.argv.slice(2);_I(e)&&mg(e,!0),hI(e).then(t=>{process.exit(t)}).catch(t=>{L("entry",t);let n=t instanceof Error?t.message:String(t);y(n),process.exit(1)})}export{SI as isCliEntrypoint,_I as isHookModeArgv,hI as main};
|